[opencv] 02/17: New upstream version 3.3.0+dfsg
Nobuhiro Iwamatsu
iwamatsu at moszumanska.debian.org
Tue Sep 5 23:03:40 UTC 2017
This is an automated email from the git hooks/post-receive script.
iwamatsu pushed a commit to branch master
in repository opencv.
commit 50ed9332cec6f1302a07d759120f1b14f4ac3c2f
Author: Nobuhiro Iwamatsu <iwamatsu at nigauri.org>
Date: Mon Aug 28 08:32:06 2017 +0900
New upstream version 3.3.0+dfsg
---
CMakeLists.txt | 206 +-
apps/CMakeLists.txt | 2 +
apps/annotation/opencv_annotation.cpp | 48 +-
apps/interactive-calibration/CMakeLists.txt | 5 +-
apps/interactive-calibration/frameProcessor.cpp | 12 +-
apps/interactive-calibration/frameProcessor.hpp | 6 +-
apps/interactive-calibration/main.cpp | 24 +-
apps/traincascade/cascadeclassifier.cpp | 4 +-
apps/version/opencv_version.cpp | 6 +
cmake/FindCUDA/run_nvcc.cmake | 2 +-
cmake/FindOpenVX.cmake | 14 +
cmake/OpenCVCRTLinkage.cmake | 9 +-
cmake/OpenCVCompilerDefenses.cmake | 87 +
cmake/OpenCVCompilerOptimizations.cmake | 740 +
cmake/OpenCVCompilerOptions.cmake | 213 +-
cmake/OpenCVDetectCStripes.cmake | 2 +-
cmake/OpenCVDetectCUDA.cmake | 13 +-
cmake/OpenCVDetectCXXCompiler.cmake | 32 +-
cmake/OpenCVDetectHalide.cmake | 45 +
cmake/OpenCVDetectMediaSDK.cmake | 38 +
cmake/OpenCVDetectTBB.cmake | 4 +-
cmake/OpenCVDetectTrace.cmake | 13 +
cmake/OpenCVDownload.cmake | 237 +
cmake/OpenCVFindIPP.cmake | 72 +-
cmake/OpenCVFindIPPIW.cmake | 169 +
cmake/OpenCVFindLAPACK.cmake | 214 +-
cmake/OpenCVFindLibProtobuf.cmake | 33 +
cmake/OpenCVFindLibsGUI.cmake | 8 +-
cmake/OpenCVFindLibsGrfmt.cmake | 8 +-
cmake/OpenCVFindLibsPerf.cmake | 30 +-
cmake/OpenCVFindLibsVideo.cmake | 72 +-
cmake/OpenCVFindMKL.cmake | 68 +-
cmake/OpenCVGenABI.cmake | 10 +-
cmake/OpenCVGenConfig.cmake | 16 +-
cmake/OpenCVGenHeaders.cmake | 4 +
cmake/OpenCVGenInfoPlist.cmake | 9 +-
cmake/OpenCVMinDepVersions.cmake | 2 +-
cmake/OpenCVModule.cmake | 76 +-
cmake/OpenCVPCHSupport.cmake | 44 +-
cmake/OpenCVUtils.cmake | 308 +-
cmake/OpenCVVersion.cmake | 7 +
cmake/checks/cpu_avx.cpp | 9 +
cmake/checks/cpu_avx2.cpp | 10 +
cmake/checks/cpu_avx512.cpp | 10 +
cmake/checks/cpu_fp16.cpp | 33 +
cmake/checks/cpu_neon.cpp | 27 +
cmake/checks/cpu_popcnt.cpp | 22 +
cmake/checks/cpu_sse.cpp | 2 +
cmake/checks/cpu_sse2.cpp | 2 +
cmake/checks/cpu_sse3.cpp | 7 +
cmake/checks/cpu_sse41.cpp | 6 +
cmake/checks/cpu_sse42.cpp | 7 +
cmake/checks/cpu_ssse3.cpp | 7 +
cmake/checks/cxx11.cpp | 13 +
cmake/checks/ffmpeg_test.cpp | 5 +
cmake/checks/fp16.cpp | 33 -
cmake/checks/lapack_check.cpp | 14 +
cmake/checks/openvx_refenum_test.cpp | 5 +
cmake/cl2cpp.cmake | 28 +-
cmake/templates/OpenCV.mk.in | 2 +
cmake/templates/OpenCVConfig-IPPIW.cmake.in | 7 +
cmake/templates/OpenCVConfig.cmake.in | 1 +
cmake/templates/OpenCVConfig.root-WIN32.cmake.in | 2 +-
cmake/templates/cv_cpu_config.h.in | 5 +
cmake/templates/cvconfig.h.in | 46 +-
cmake/templates/vs_version.rc.in | 38 +
contrib/modules/README.md | 4 +-
contrib/modules/aruco/include/opencv2/aruco.hpp | 39 +-
.../aruco/include/opencv2/aruco/charuco.hpp | 6 +-
contrib/modules/aruco/samples/calibrate_camera.cpp | 2 +-
.../aruco/samples/calibrate_camera_charuco.cpp | 2 +-
contrib/modules/aruco/samples/detect_board.cpp | 4 +-
.../modules/aruco/samples/detect_board_charuco.cpp | 2 +-
contrib/modules/aruco/samples/detect_diamonds.cpp | 2 +-
contrib/modules/aruco/samples/detect_markers.cpp | 4 +-
contrib/modules/aruco/samples/detector_params.yml | 2 +-
contrib/modules/aruco/src/aruco.cpp | 269 +-
contrib/modules/aruco/src/charuco.cpp | 4 +-
contrib/modules/aruco/test/test_boarddetection.cpp | 4 +-
contrib/modules/aruco/test/test_misc.cpp | 24 +
.../aruco_board_detection.markdown | 24 +-
.../aruco_calibration/aruco_calibration.markdown | 18 +-
.../aruco_detection/aruco_detection.markdown | 41 +-
.../charuco_detection/charuco_detection.markdown | 46 +-
.../charuco_diamond_detection.markdown | 18 +-
contrib/modules/bgsegm/CMakeLists.txt | 2 +-
contrib/modules/bgsegm/README.md | 9 +-
contrib/modules/bgsegm/include/opencv2/bgsegm.hpp | 59 +-
contrib/modules/bgsegm/samples/bgfg.cpp | 104 +
contrib/modules/bgsegm/samples/bgfg_gmg.cpp | 81 -
contrib/modules/bgsegm/src/bgfg_gmg.cpp | 2 +-
contrib/modules/bgsegm/src/bgfg_subcnt.cpp | 421 +
.../include/opencv2/bioinspired/retina.hpp | 5 -
.../bioinspired/perf/opencl/perf_retina.cpp | 126 -
.../bioinspired/perf/opencl/perf_retina.ocl.cpp | 47 +
contrib/modules/bioinspired/perf/perf_main.cpp | 10 +-
.../bioinspired/src/opencl/retina_kernel.cl | 417 +-
contrib/modules/bioinspired/src/precomp.hpp | 5 +-
contrib/modules/bioinspired/src/retina.cpp | 108 +-
contrib/modules/bioinspired/src/retina_ocl.cpp | 802 +-
contrib/modules/bioinspired/src/retina_ocl.hpp | 257 +-
.../modules/bioinspired/test/test_retina_ocl.cpp | 100 +-
contrib/modules/ccalib/CMakeLists.txt | 2 +-
.../modules/ccalib/samples/omni_calibration.cpp | 135 +-
contrib/modules/ccalib/src/omnidir.cpp | 4 +-
.../ccalib/tutorials/omnidir_tutorial.markdown | 2 +-
contrib/modules/contrib_world/CMakeLists.txt | 1 -
contrib/modules/datasets/CMakeLists.txt | 2 +-
.../modules/datasets/samples/fr_lfw_benchmark.cpp | 101 +-
contrib/modules/datasets/src/or_pascal.cpp | 2 +-
contrib/modules/datasets/src/tinyxml2/tinyxml2.cpp | 19 +-
.../opencv2/datasets => src}/tinyxml2/tinyxml2.h | 0
contrib/modules/datasets/src/tr_svt.cpp | 2 +-
contrib/modules/datasets/src/track_alov.cpp | 2 +-
contrib/modules/datasets/src/track_vot.cpp | 2 +-
.../modules/dnn/3rdparty/protobuf/CMakeLists.txt | 151 -
contrib/modules/dnn/CMakeLists.txt | 91 -
contrib/modules/dnn/README.md | 2 -
.../modules/dnn/cmake/OpenCVFindLibProtobuf.cmake | 56 -
contrib/modules/dnn/cmake/download_model.cmake | 31 -
contrib/modules/dnn/cmake/download_protobuf.cmake | 51 -
contrib/modules/dnn/include/opencv2/dnn.hpp | 64 -
.../modules/dnn/include/opencv2/dnn/all_layers.hpp | 405 -
contrib/modules/dnn/include/opencv2/dnn/blob.hpp | 341 -
.../modules/dnn/include/opencv2/dnn/blob.inl.hpp | 533 -
contrib/modules/dnn/include/opencv2/dnn/dict.hpp | 143 -
contrib/modules/dnn/include/opencv2/dnn/dnn.hpp | 347 -
.../modules/dnn/include/opencv2/dnn/dnn.inl.hpp | 351 -
contrib/modules/dnn/include/opencv2/dnn/layer.hpp | 148 -
.../dnn/include/opencv2/dnn/shape_utils.hpp | 137 -
contrib/modules/dnn/misc/caffe/caffe.pb.cc | 45683 ----------------
contrib/modules/dnn/misc/caffe/caffe.pb.h | 24439 ---------
contrib/modules/dnn/misc/python/pyopencv_dnn.hpp | 108 -
contrib/modules/dnn/perf/perf_convolution.cpp | 80 -
contrib/modules/dnn/perf/perf_main.cpp | 3 -
contrib/modules/dnn/samples/.gitignore | 1 -
.../VGG_VOC0712_SSD_300x300_iter_60000.prototxt | 1547 -
contrib/modules/dnn/samples/caffe_googlenet.cpp | 144 -
contrib/modules/dnn/samples/fcn_semsegm.cpp | 159 -
contrib/modules/dnn/samples/googlenet_python.py | 34 -
.../modules/dnn/samples/ssd_object_detection.cpp | 153 -
contrib/modules/dnn/samples/tf_inception.cpp | 182 -
contrib/modules/dnn/src/blob.cpp | 421 -
contrib/modules/dnn/src/caffe/caffe.proto | 1267 -
contrib/modules/dnn/src/caffe/caffe_importer.cpp | 391 -
contrib/modules/dnn/src/caffe/caffe_io.cpp | 1115 -
contrib/modules/dnn/src/caffe/caffe_io.hpp | 108 -
contrib/modules/dnn/src/caffe/glog_emulator.hpp | 104 -
contrib/modules/dnn/src/caffe/layer_loaders.cpp | 304 -
contrib/modules/dnn/src/caffe/layer_loaders.hpp | 60 -
contrib/modules/dnn/src/dnn.cpp | 711 -
contrib/modules/dnn/src/init.cpp | 112 -
contrib/modules/dnn/src/layers/blank_layer.hpp | 74 -
contrib/modules/dnn/src/layers/concat_layer.cpp | 121 -
contrib/modules/dnn/src/layers/concat_layer.hpp | 70 -
.../modules/dnn/src/layers/convolution_layer.cpp | 352 -
.../modules/dnn/src/layers/convolution_layer.hpp | 107 -
contrib/modules/dnn/src/layers/crop_layer.cpp | 128 -
contrib/modules/dnn/src/layers/crop_layer.hpp | 62 -
.../dnn/src/layers/detection_output_layer.cpp | 750 -
.../dnn/src/layers/detection_output_layer.hpp | 226 -
.../modules/dnn/src/layers/elementwise_layers.cpp | 46 -
.../modules/dnn/src/layers/elementwise_layers.hpp | 318 -
contrib/modules/dnn/src/layers/eltwise_layer.cpp | 127 -
contrib/modules/dnn/src/layers/eltwise_layer.hpp | 62 -
contrib/modules/dnn/src/layers/flatten_layer.cpp | 117 -
contrib/modules/dnn/src/layers/flatten_layer.hpp | 67 -
.../dnn/src/layers/fully_connected_layer.cpp | 129 -
.../dnn/src/layers/fully_connected_layer.hpp | 71 -
contrib/modules/dnn/src/layers/layers_common.cpp | 192 -
contrib/modules/dnn/src/layers/layers_common.hpp | 65 -
contrib/modules/dnn/src/layers/lrn_layer.cpp | 260 -
contrib/modules/dnn/src/layers/lrn_layer.hpp | 79 -
contrib/modules/dnn/src/layers/mvn_layer.cpp | 101 -
contrib/modules/dnn/src/layers/mvn_layer.hpp | 63 -
.../dnn/src/layers/normalize_bbox_layer.cpp | 201 -
.../dnn/src/layers/normalize_bbox_layer.hpp | 94 -
contrib/modules/dnn/src/layers/op_blas.cpp | 171 -
contrib/modules/dnn/src/layers/op_blas.hpp | 59 -
contrib/modules/dnn/src/layers/op_im2col.cpp | 168 -
contrib/modules/dnn/src/layers/op_im2col.hpp | 242 -
contrib/modules/dnn/src/layers/permute_layer.cpp | 185 -
contrib/modules/dnn/src/layers/permute_layer.hpp | 75 -
contrib/modules/dnn/src/layers/pooling_layer.cpp | 295 -
contrib/modules/dnn/src/layers/pooling_layer.hpp | 81 -
contrib/modules/dnn/src/layers/prior_box_layer.cpp | 307 -
contrib/modules/dnn/src/layers/prior_box_layer.hpp | 101 -
.../modules/dnn/src/layers/recurrent_layers.cpp | 442 -
.../modules/dnn/src/layers/recurrent_layers.hpp | 54 -
contrib/modules/dnn/src/layers/reshape_layer.cpp | 123 -
contrib/modules/dnn/src/layers/reshape_layer.hpp | 70 -
contrib/modules/dnn/src/layers/shift_layer.cpp | 157 -
contrib/modules/dnn/src/layers/shift_layer.hpp | 36 -
contrib/modules/dnn/src/layers/slice_layer.cpp | 147 -
contrib/modules/dnn/src/layers/slice_layer.hpp | 71 -
contrib/modules/dnn/src/layers/softmax_layer.cpp | 224 -
contrib/modules/dnn/src/layers/softmax_layer.hpp | 72 -
contrib/modules/dnn/src/layers/split_layer.cpp | 88 -
contrib/modules/dnn/src/layers/split_layer.hpp | 66 -
contrib/modules/dnn/src/opencl/activations.cl | 44 -
contrib/modules/dnn/src/opencl/pooling.cl | 94 -
contrib/modules/dnn/src/precomp.hpp | 44 -
contrib/modules/dnn/src/tensorflow/tf_importer.cpp | 749 -
contrib/modules/dnn/src/tensorflow/tf_io.cpp | 63 -
contrib/modules/dnn/src/tensorflow/tf_io.hpp | 29 -
contrib/modules/dnn/src/torch/THDiskFile.cpp | 611 -
contrib/modules/dnn/src/torch/THDiskFile.h | 17 -
contrib/modules/dnn/src/torch/THFile.cpp | 163 -
contrib/modules/dnn/src/torch/THFile.h | 87 -
contrib/modules/dnn/src/torch/THFilePrivate.h | 43 -
contrib/modules/dnn/src/torch/THGeneral.cpp | 255 -
contrib/modules/dnn/src/torch/THGeneral.h | 89 -
contrib/modules/dnn/src/torch/torch_importer.cpp | 726 -
contrib/modules/dnn/test/npy_blob.hpp | 65 -
contrib/modules/dnn/test/test_alexnet.cpp | 81 -
contrib/modules/dnn/test/test_caffe_importer.cpp | 76 -
contrib/modules/dnn/test/test_common.hpp | 65 -
contrib/modules/dnn/test/test_googlenet.cpp | 94 -
contrib/modules/dnn/test/test_layers.cpp | 396 -
contrib/modules/dnn/test/test_main.cpp | 31 -
contrib/modules/dnn/test/test_tf_importer.cpp | 51 -
contrib/modules/dnn/test/test_torch_importer.cpp | 128 -
contrib/modules/dnn/testdata/dnn/.gitignore | 1 -
.../testdata/dnn/layers/layer_convolution.prototxt | 39 -
.../dnn/layers/layer_deconvolution.prototxt | 39 -
.../dnn/layers/layer_inner_product.prototxt | 32 -
.../dnn/layers/layer_lrn_channels.prototxt | 21 -
.../testdata/dnn/layers/layer_lrn_spatial.prototxt | 22 -
.../dnn/testdata/dnn/layers/layer_mvn.prototxt | 21 -
.../testdata/dnn/layers/layer_pooling_ave.prototxt | 26 -
.../testdata/dnn/layers/layer_pooling_max.prototxt | 26 -
.../dnn/testdata/dnn/layers/layer_softmax.prototxt | 15 -
.../dnn/layers/reshape_and_slice_routines.prototxt | 77 -
contrib/modules/dnn/testdata/dnn/layers/run.py | 45 -
.../dnn/testdata/dnn/torch/torch_gen_test_data.lua | 67 -
.../dnn/testdata/dnn/torch/torch_nn_echo.lua | 2 -
contrib/modules/dnn/tutorials/images/build_1.png | Bin 32126 -> 0 bytes
contrib/modules/dnn/tutorials/images/build_2.png | Bin 41345 -> 0 bytes
contrib/modules/dnn/tutorials/images/build_3.png | Bin 46802 -> 0 bytes
contrib/modules/dnn/tutorials/images/build_4.png | Bin 40770 -> 0 bytes
contrib/modules/dnn/tutorials/images/build_5.png | Bin 40924 -> 0 bytes
.../dnn/tutorials/tutorial_dnn_build.markdown | 68 -
.../dnn/tutorials/tutorial_dnn_googlenet.markdown | 66 -
contrib/modules/dnn_modern/CMakeLists.txt | 174 +
contrib/modules/dnn_modern/README.md | 50 +
contrib/modules/dnn_modern/cmake/FindNNPACK.cmake | 54 +
contrib/modules/dnn_modern/cmake/FindTinyDNN.cmake | 47 +
.../dnn_modern/include/opencv2/dnn_modern.hpp | 106 +
contrib/modules/dnn_modern/samples/simple_test.cpp | 93 +
contrib/modules/dnn_modern/src/caffe_converter.cpp | 204 +
contrib/modules/dnn_modern/src/dnn_modern_init.cpp | 47 +
contrib/modules/dnn_modern/src/precomp.hpp | 50 +
contrib/modules/dpm/include/opencv2/dpm.hpp | 5 +
contrib/modules/dpm/src/precomp.cpp | 44 -
contrib/modules/face/include/opencv2/face.hpp | 21 +-
contrib/modules/face/include/opencv2/face/bif.hpp | 14 +-
.../modules/face/include/opencv2/face/facerec.hpp | 235 +-
contrib/modules/face/samples/facerec_demo.cpp | 6 +-
.../modules/face/samples/facerec_eigenfaces.cpp | 8 +-
.../modules/face/samples/facerec_fisherfaces.cpp | 6 +-
contrib/modules/face/samples/facerec_lbph.cpp | 6 +-
contrib/modules/face/samples/facerec_save_load.cpp | 11 +-
contrib/modules/face/samples/facerec_video.cpp | 2 +-
contrib/modules/face/src/bif.cpp | 2 +-
contrib/modules/face/src/eigen_faces.cpp | 14 +-
contrib/modules/face/src/face_basic.cpp | 97 +
contrib/modules/face/src/face_basic.hpp | 175 -
contrib/modules/face/src/face_utils.hpp | 108 +
contrib/modules/face/src/facerec.cpp | 8 +-
contrib/modules/face/src/fisher_faces.cpp | 14 +-
contrib/modules/face/src/lbph_faces.cpp | 25 +-
contrib/modules/face/src/precomp.hpp | 2 -
contrib/modules/face/test/test_bif.cpp | 10 +-
.../modules/face/tutorials/face_tutorial.markdown | 6 +-
contrib/modules/freetype/CMakeLists.txt | 6 +-
.../modules/freetype/include/opencv2/freetype.hpp | 62 +-
contrib/modules/freetype/src/freetype.cpp | 249 +-
contrib/modules/fuzzy/doc/fuzzy.bib | 60 +-
contrib/modules/fuzzy/include/opencv2/fuzzy.hpp | 13 +-
.../fuzzy/include/opencv2/fuzzy/fuzzy_F0_math.hpp | 81 +-
.../fuzzy/include/opencv2/fuzzy/fuzzy_F1_math.hpp | 124 +
.../fuzzy/include/opencv2/fuzzy/fuzzy_image.hpp | 12 +-
.../modules/fuzzy/include/opencv2/fuzzy/types.hpp | 10 +-
contrib/modules/fuzzy/samples/fuzzy_inpainting.cpp | 6 +-
contrib/modules/fuzzy/src/fuzzy_F0_math.cpp | 302 +-
contrib/modules/fuzzy/src/fuzzy_F1_math.cpp | 305 +
contrib/modules/fuzzy/src/fuzzy_image.cpp | 2 +-
contrib/modules/fuzzy/test/test_f0.cpp | 100 +-
contrib/modules/fuzzy/test/test_f1.cpp | 399 +
contrib/modules/fuzzy/test/test_image.cpp | 6 +-
.../fuzzy/tutorials/filtering/filtering.markdown | 60 +
.../filtering/images/fuzzy_filt_output.jpg | Bin 0 -> 67111 bytes
contrib/modules/fuzzy/tutorials/fuzzy.markdown | 26 +
.../inpainting/images/fuzzy_inp_input.jpg | Bin 0 -> 124418 bytes
.../inpainting/images/fuzzy_inp_output.jpg | Bin 0 -> 83853 bytes
.../fuzzy/tutorials/inpainting/inpainting.markdown | 104 +
.../tutorials/theory/images/fuzzy_BF_view.jpg | Bin 0 -> 33998 bytes
.../tutorials/theory/images/fuzzy_pixel_view.jpg | Bin 0 -> 36251 bytes
.../modules/fuzzy/tutorials/theory/theory.markdown | 85 +
contrib/modules/hdf/CMakeLists.txt | 5 +-
contrib/modules/img_hash/CMakeLists.txt | 3 +
contrib/modules/img_hash/README.md | 5 +
.../modules/img_hash/doc/attack_performance.JPG | Bin 0 -> 112908 bytes
.../modules/img_hash/doc/hash_comparison_chart.JPG | Bin 0 -> 44833 bytes
.../img_hash/doc/hash_computation_chart.JPG | Bin 0 -> 46971 bytes
contrib/modules/img_hash/doc/img_hash.bib | 23 +
.../modules/img_hash/include/opencv2/img_hash.hpp | 78 +
.../include/opencv2/img_hash/average_hash.hpp | 39 +
.../include/opencv2/img_hash/block_mean_hash.hpp | 52 +
.../include/opencv2/img_hash/color_moment_hash.hpp | 41 +
.../include/opencv2/img_hash/img_hash_base.hpp | 46 +
.../opencv2/img_hash/marr_hildreth_hash.hpp | 64 +
.../img_hash/include/opencv2/img_hash/phash.hpp | 41 +
.../opencv2/img_hash/radial_variance_hash.hpp | 58 +
contrib/modules/img_hash/samples/hash_samples.cpp | 53 +
contrib/modules/img_hash/src/average_hash.cpp | 86 +
contrib/modules/img_hash/src/block_mean_hash.cpp | 167 +
contrib/modules/img_hash/src/color_moment_hash.cpp | 95 +
contrib/modules/img_hash/src/img_hash_base.cpp | 28 +
.../modules/img_hash/src/marr_hildreth_hash.cpp | 212 +
contrib/modules/img_hash/src/phash.cpp | 93 +
contrib/modules/img_hash/src/precomp.hpp | 29 +
.../modules/img_hash/src/radial_variance_hash.cpp | 361 +
.../modules/img_hash/test/test_average_hash.cpp | 58 +
.../modules/img_hash/test/test_block_mean_hash.cpp | 212 +
contrib/modules/img_hash/test/test_main.cpp | 7 +
.../img_hash/test/test_marr_hildreth_hash.cpp | 60 +
contrib/modules/img_hash/test/test_phash.cpp | 58 +
contrib/modules/img_hash/test/test_precomp.hpp | 20 +
.../img_hash/test/test_radial_variance_hash.cpp | 150 +
contrib/modules/line_descriptor/CMakeLists.txt | 2 +-
.../include/opencv2/line_descriptor/descriptor.hpp | 8 +-
.../modules/line_descriptor/perf/perf_precomp.hpp | 1 -
.../samples/compute_descriptors.cpp | 15 +-
.../line_descriptor/samples/knn_matching.cpp | 14 +-
.../line_descriptor/samples/lines_extraction.cpp | 17 +-
.../samples/lsd_lines_extraction.cpp | 17 +-
.../modules/line_descriptor/samples/matching.cpp | 16 +-
.../line_descriptor/samples/radius_matching.cpp | 15 +-
contrib/modules/line_descriptor/src/precomp.hpp | 4 +-
.../modules/line_descriptor/test/test_precomp.hpp | 1 -
contrib/modules/matlab/CMakeLists.txt | 32 +-
contrib/modules/matlab/generator/build_info.py | 6 +-
contrib/modules/matlab/generator/cvmex.py | 6 +-
contrib/modules/matlab/generator/gen_matlab.py | 6 +-
.../matlab/include/opencv2/matlab/bridge.hpp | 7 +-
contrib/modules/optflow/CMakeLists.txt | 2 +-
.../opencv2/optflow/sparse_matching_gpc.hpp | 1 -
.../optflow/perf/opencl/perf_dis_optflow.cpp | 113 +
contrib/modules/optflow/perf/perf_disflow.cpp | 4 +-
.../modules/optflow/samples/dis_opticalflow.cpp | 74 +
contrib/modules/optflow/samples/gpc_evaluate.cpp | 18 +-
contrib/modules/optflow/samples/motempl.py | 5 +-
contrib/modules/optflow/src/deepflow.cpp | 4 +-
contrib/modules/optflow/src/dis_flow.cpp | 385 +-
contrib/modules/optflow/src/interfaces.cpp | 1 -
contrib/modules/optflow/src/opencl/dis_flow.cl | 522 +
contrib/modules/optflow/src/precomp.hpp | 2 +
.../modules/optflow/src/sparse_matching_gpc.cpp | 8 +-
contrib/modules/optflow/test/ocl/test_dis.cpp | 100 +
.../optflow/test/test_OF_reproducibility.cpp | 8 +-
contrib/modules/phase_unwrapping/CMakeLists.txt | 2 +-
.../modules/phase_unwrapping/test/test_precomp.hpp | 1 -
contrib/modules/plot/CMakeLists.txt | 2 +-
contrib/modules/plot/src/plot.cpp | 24 +-
contrib/modules/plot/src/precomp.cpp | 50 -
contrib/modules/reg/include/opencv2/reg/map.hpp | 14 +-
.../modules/reg/include/opencv2/reg/mapaffine.hpp | 24 +-
contrib/modules/reg/include/opencv2/reg/mapper.hpp | 12 +-
.../reg/include/opencv2/reg/mappergradaffine.hpp | 8 +-
.../reg/include/opencv2/reg/mappergradeuclid.hpp | 10 +-
.../reg/include/opencv2/reg/mappergradproj.hpp | 10 +-
.../reg/include/opencv2/reg/mappergradshift.hpp | 10 +-
.../reg/include/opencv2/reg/mappergradsimilar.hpp | 10 +-
.../reg/include/opencv2/reg/mapperpyramid.hpp | 41 +-
.../modules/reg/include/opencv2/reg/mapprojec.hpp | 22 +-
.../modules/reg/include/opencv2/reg/mapshift.hpp | 21 +-
contrib/modules/reg/perf/perf_precomp.cpp | 44 -
contrib/modules/reg/perf/perf_reg.cpp | 25 +-
contrib/modules/reg/samples/map_test.cpp | 37 +-
contrib/modules/reg/samples/reg_shift.py | 20 +
contrib/modules/reg/src/map.cpp | 4 +-
contrib/modules/reg/src/mapaffine.cpp | 15 +-
contrib/modules/reg/src/mapper.cpp | 35 +-
contrib/modules/reg/src/mappergradaffine.cpp | 27 +-
contrib/modules/reg/src/mappergradeuclid.cpp | 28 +-
contrib/modules/reg/src/mappergradproj.cpp | 28 +-
contrib/modules/reg/src/mappergradshift.cpp | 28 +-
contrib/modules/reg/src/mappergradsimilar.cpp | 28 +-
contrib/modules/reg/src/mapperpyramid.cpp | 28 +-
contrib/modules/reg/src/mapprojec.cpp | 15 +-
contrib/modules/reg/src/mapshift.cpp | 15 +-
contrib/modules/reg/src/precomp.cpp | 39 -
contrib/modules/reg/test/test_precomp.cpp | 44 -
contrib/modules/reg/test/test_reg.cpp | 80 +-
contrib/modules/rgbd/CMakeLists.txt | 3 +-
contrib/modules/rgbd/include/opencv2/rgbd.hpp | 6 +-
.../modules/rgbd/include/opencv2/rgbd/linemod.hpp | 100 +-
.../modules/rgbd/misc/python/pyopencv_linemod.hpp | 46 +
contrib/modules/rgbd/src/depth_to_3d.cpp | 8 +-
contrib/modules/rgbd/src/odometry.cpp | 63 +-
contrib/modules/rgbd/test/test_precomp.cpp | 1 -
contrib/modules/saliency/CMakeLists.txt | 3 +-
.../saliency/saliencySpecializedClasses.hpp | 2 +-
contrib/modules/saliency/src/BING/CmFile.cpp | 2 +-
contrib/modules/saliency/src/BING/CmShow.cpp | 7 +-
contrib/modules/saliency/src/BING/CmShow.hpp | 2 +-
contrib/modules/saliency/src/BING/FilterTIG.cpp | 2 +-
contrib/modules/saliency/src/BING/ValStructVec.cpp | 2 +-
.../modules/saliency/src/BING/objectnessBING.cpp | 2 +-
contrib/modules/sfm/CMakeLists.txt | 4 +-
contrib/modules/sfm/cmake/FindGflags.cmake | 36 +-
.../sfm/include/opencv2/sfm/reconstruct.hpp | 4 +-
.../sfm/include/opencv2/sfm/simple_pipeline.hpp | 8 +-
contrib/modules/sfm/samples/match_reconstruct.cpp | 165 +
.../modules/sfm/samples/scene_reconstruction.cpp | 5 +-
.../sfm/samples/trajectory_reconstruccion.cpp | 5 +-
contrib/modules/sfm/src/libmv_capi.h | 5 +-
.../sfm/src/libmv_light/libmv/logging/logging.h | 5 +
.../libmv_light/libmv/simple_pipeline/pipeline.cc | 4 -
contrib/modules/sfm/src/reconstruct.cpp | 10 +-
contrib/modules/sfm/src/simple_pipeline.cpp | 12 +-
contrib/modules/sfm/test/test_common.cpp | 7 +-
.../sfm_installation/sfm_installation.markdown | 5 +-
contrib/modules/stereo/CMakeLists.txt | 2 +-
contrib/modules/stereo/src/precomp.hpp | 1 -
contrib/modules/structured_light/CMakeLists.txt | 2 +-
.../opencv2/structured_light/sinusoidalpattern.hpp | 2 +-
.../samples/projectorcalibration.cpp | 2 +-
.../structured_light/src/graycodepattern.cpp | 4 +-
.../structured_light/src/sinusoidalpattern.cpp | 4 +-
.../modules/structured_light/test/test_plane.cpp | 3 +-
.../modules/structured_light/test/test_precomp.hpp | 3 +-
.../include/opencv2/surface_matching/icp.hpp | 14 +-
.../opencv2/surface_matching/ppf_helpers.hpp | 10 +-
.../opencv2/surface_matching/ppf_match_3d.hpp | 4 +-
.../modules/surface_matching/samples/ppf_icp.py | 52 +
.../samples/ppf_normal_computation.cpp | 2 +-
contrib/modules/surface_matching/src/c_utils.hpp | 12 +-
contrib/modules/surface_matching/src/icp.cpp | 84 +-
.../modules/surface_matching/src/ppf_helpers.cpp | 42 +-
.../modules/surface_matching/src/ppf_match_3d.cpp | 54 +-
contrib/modules/text/CMakeLists.txt | 2 +-
contrib/modules/text/README.md | 6 +-
contrib/modules/text/doc/text.bib | 34 +
contrib/modules/text/include/opencv2/text.hpp | 10 +-
.../modules/text/include/opencv2/text/erfilter.hpp | 85 +-
contrib/modules/text/include/opencv2/text/ocr.hpp | 109 +-
.../modules/text/samples/character_recognition.cpp | 2 +-
.../text/samples/cropped_word_recognition.cpp | 4 +-
.../text/samples/end_to_end_recognition.cpp | 6 +-
.../text/samples/segmented_word_recognition.cpp | 2 +-
contrib/modules/text/samples/textdetection.py | 2 +-
contrib/modules/text/samples/webcam_demo.cpp | 2 +-
contrib/modules/text/src/erfilter.cpp | 105 +-
.../modules/text/src/ocr_beamsearch_decoder.cpp | 38 +-
contrib/modules/text/src/ocr_hmm_decoder.cpp | 49 +-
contrib/modules/tracking/CMakeLists.txt | 3 +-
.../include/opencv2/tracking/tldDataset.hpp | 6 +-
.../tracking/include/opencv2/tracking/tracker.hpp | 192 +-
contrib/modules/tracking/perf/perf_Tracker.cpp | 8 +-
contrib/modules/tracking/samples/benchmark.cpp | 4 +-
contrib/modules/tracking/samples/goturnTracker.cpp | 24 +-
contrib/modules/tracking/samples/kcf.cpp | 132 +-
.../tracking/samples/multiTracker_dataset.cpp | 4 +-
contrib/modules/tracking/samples/multitracker.cpp | 25 +-
contrib/modules/tracking/samples/multitracker.py | 36 +-
.../modules/tracking/samples/samples_utility.hpp | 28 +
contrib/modules/tracking/samples/tracker.cpp | 59 +-
contrib/modules/tracking/samples/tracker.py | 19 +-
.../modules/tracking/samples/tracker_dataset.cpp | 4 +-
.../samples/tutorial_customizing_cn_tracker.cpp | 3 +-
.../samples/tutorial_introduction_to_tracker.cpp | 2 +-
.../tracking/samples/tutorial_multitracker.cpp | 19 +-
contrib/modules/tracking/src/gtrTracker.cpp | 33 +-
contrib/modules/tracking/src/gtrTracker.hpp | 12 +-
contrib/modules/tracking/src/gtrUtils.cpp | 6 +-
contrib/modules/tracking/src/gtrUtils.hpp | 6 +-
contrib/modules/tracking/src/multiTracker.cpp | 13 +-
contrib/modules/tracking/src/multiTracker_alt.cpp | 64 +-
contrib/modules/tracking/src/roiSelector.cpp | 185 -
contrib/modules/tracking/src/tldDataset.cpp | 6 +-
contrib/modules/tracking/src/tldTracker.cpp | 6 +-
contrib/modules/tracking/src/tldTracker.hpp | 9 +-
contrib/modules/tracking/src/tldUtils.cpp | 28 -
contrib/modules/tracking/src/tldUtils.hpp | 5 +-
contrib/modules/tracking/src/tracker.cpp | 25 +-
contrib/modules/tracking/src/trackerBoosting.cpp | 5 +-
contrib/modules/tracking/src/trackerKCF.cpp | 92 +-
contrib/modules/tracking/src/trackerMIL.cpp | 5 +-
contrib/modules/tracking/src/trackerMedianFlow.cpp | 447 +-
contrib/modules/tracking/test/test_aukf.cpp | 4 +-
contrib/modules/tracking/test/test_trackerOPE.cpp | 443 -
.../tracking/test/test_trackerParametersIO.cpp | 127 +
contrib/modules/tracking/test/test_trackerSRE.cpp | 550 -
contrib/modules/tracking/test/test_trackerTRE.cpp | 520 -
contrib/modules/tracking/test/test_trackers.cpp | 541 +
contrib/modules/tracking/test/test_ukf.cpp | 4 +-
.../tutorial_introduction_to_tracker.markdown | 1 -
.../tutorials/tutorial_multitracker.markdown | 3 +-
contrib/modules/ximgproc/CMakeLists.txt | 5 +-
.../modules/ximgproc/doc/pics/superpixels_slic.png | Bin 775391 -> 989318 bytes
contrib/modules/ximgproc/doc/ximgproc.bib | 53 +
.../modules/ximgproc/include/opencv2/ximgproc.hpp | 50 +-
.../include/opencv2/ximgproc/paillou_filter.hpp | 4 +-
.../include/opencv2/ximgproc/segmentation.hpp | 2 +-
.../ximgproc/include/opencv2/ximgproc/slic.hpp | 19 +-
.../opencv2/ximgproc/structured_edge_detection.hpp | 26 +-
.../opencv2/ximgproc/weighted_median_filter.hpp | 15 +-
contrib/modules/ximgproc/samples/filterdemo.cpp | 105 +
.../ximgproc/samples/niblack_thresholding.cpp | 5 +-
contrib/modules/ximgproc/samples/paillou_demo.cpp | 18 +-
.../samples/selectivesearchsegmentation_demo.py | 60 +
contrib/modules/ximgproc/samples/slic.cpp | 4 +-
.../ximgproc/samples/structured_edge_detection.cpp | 10 +
contrib/modules/ximgproc/samples/thinning.cpp | 5 +-
contrib/modules/ximgproc/src/anisodiff.cpp | 293 +
.../ximgproc/src/bilateral_texture_filter.cpp | 2 +-
contrib/modules/ximgproc/src/deriche_filter.cpp | 1 -
contrib/modules/ximgproc/src/disparity_filters.cpp | 16 +-
.../modules/ximgproc/src/fast_line_detector.cpp | 16 +-
contrib/modules/ximgproc/src/lsc.cpp | 60 +-
.../modules/ximgproc/src/niblack_thresholding.cpp | 33 +-
contrib/modules/ximgproc/src/opencl/anisodiff.cl | 39 +
contrib/modules/ximgproc/src/paillou_filter.cpp | 382 +-
.../ximgproc/src/rolling_guidance_filter.cpp | 1 -
.../ximgproc/src/selectivesearchsegmentation.cpp | 5 +-
contrib/modules/ximgproc/src/slic.cpp | 635 +-
.../ximgproc/src/structured_edge_detection.cpp | 193 +-
.../ximgproc/src/weighted_median_filter.cpp | 17 +-
contrib/modules/ximgproc/test/test_anisodiff.cpp | 25 +
.../ximgproc/test/test_rolling_guidance_filter.cpp | 7 +-
.../ximgproc/test/test_weighted_median_filter.cpp | 10 +
contrib/modules/xobjdetect/CMakeLists.txt | 6 +-
.../xobjdetect/include/opencv2/xobjdetect.hpp | 1 -
contrib/modules/xobjdetect/src/precomp.hpp | 1 -
contrib/modules/xobjdetect/src/wbdetector.hpp | 1 -
.../waldboost_detector/waldboost_detector.cpp | 7 +-
contrib/modules/xphoto/CMakeLists.txt | 2 +-
contrib/modules/xphoto/src/annf.hpp | 16 +-
.../xphoto/src/bm3d_denoising_invoker_commons.hpp | 2 +-
contrib/modules/xphoto/test/test_precomp.hpp | 1 -
data/haarcascades/haarcascade_frontalcatface.xml | 4 +-
.../haarcascade_frontalcatface_extended.xml | 4 +-
data/haarcascades/haarcascade_smile.xml | 4 +-
data/haarcascades_cuda/haarcascade_smile.xml | 4 +-
data/lbpcascades/lbpcascade_frontalcatface.xml | 4 +-
.../lbpcascade_frontalface_improved.xml | 1469 +
doc/CMakeLists.txt | 2 +-
doc/Doxyfile.in | 8 +-
doc/DoxygenLayout.xml | 1 -
doc/footer.html | 2 +-
doc/opencv.bib | 7 +
doc/pattern_tools/gen_pattern.py | 14 +-
doc/pattern_tools/svgfig.py | 104 +-
.../py_calibration/py_calibration.markdown | 2 +-
.../py_epipolar_geometry.markdown | 2 +-
.../py_core/py_basic_ops/py_basic_ops.markdown | 14 +-
.../py_image_arithmetics.markdown | 4 +-
.../py_optimization/py_optimization.markdown | 2 +-
.../py_feature2d/py_brief/py_brief.markdown | 4 +-
.../py_feature2d/py_fast/py_fast.markdown | 10 +-
.../py_feature_homography.markdown | 4 +-
.../py_features_meaning.markdown | 2 +-
.../py_feature2d/py_matcher/py_matcher.markdown | 4 +-
.../py_surf_intro/py_surf_intro.markdown | 12 +-
.../py_image_display/py_image_display.markdown | 6 +-
.../py_mouse_handling/py_mouse_handling.markdown | 2 +-
.../py_video_display/py_video_display.markdown | 24 +-
.../py_colorspaces/py_colorspaces.markdown | 4 +-
.../py_contour_features.markdown | 2 +-
.../py_contours_begin/py_contours_begin.markdown | 17 +-
.../py_contours_hierarchy.markdown | 4 +-
.../py_contours_more_functions.markdown | 2 +-
.../py_histogram_begins.markdown | 2 +-
.../py_histogram_equalization.markdown | 2 +-
.../py_houghlines/py_houghlines.markdown | 100 +-
.../py_thresholding/py_thresholding.markdown | 2 +-
.../py_fourier_transform.markdown | 4 +-
.../py_knn/py_knn_opencv/py_knn_opencv.markdown | 6 +-
.../py_knn_understanding.markdown | 6 +-
.../py_svm/py_svm_opencv/py_svm_opencv.markdown | 103 +-
.../py_setup_in_fedora/py_setup_in_fedora.markdown | 31 +-
.../py_setup_in_windows.markdown | 10 +-
.../camera_calibration_square_chess.markdown | 21 +-
.../calib3d/table_of_content_calib3d.markdown | 3 +-
.../basic_linear_transform.markdown | 167 +-
.../Basic_Linear_Transform_Tutorial_gamma.png | Bin 0 -> 92059 bytes
..._Linear_Transform_Tutorial_gamma_correction.jpg | Bin 0 -> 276052 bytes
.../Basic_Linear_Transform_Tutorial_hist_alpha.png | Bin 0 -> 3192 bytes
.../Basic_Linear_Transform_Tutorial_hist_beta.png | Bin 0 -> 3531 bytes
...Linear_Transform_Tutorial_histogram_compare.png | Bin 0 -> 1448 bytes
...nsform_Tutorial_linear_transform_correction.jpg | Bin 0 -> 227228 bytes
.../how_to_scan_images/how_to_scan_images.markdown | 30 +-
.../how_to_use_OpenCV_parallel_for_.markdown | 188 +
...e_OpenCV_parallel_for_640px-Mandelset_hires.png | Bin 0 -> 16752 bytes
.../how_to_use_OpenCV_parallel_for_Mandelbrot.png | Bin 0 -> 63249 bytes
...enCV_parallel_for_sqrt_scale_transformation.png | Bin 0 -> 33815 bytes
doc/tutorials/core/mat_operations.markdown | 2 +-
.../mat_the_basic_image_container.markdown | 4 +-
doc/tutorials/core/table_of_content_core.markdown | 7 +
.../dnn/dnn_googlenet/dnn_googlenet.markdown | 66 +
doc/tutorials/dnn/dnn_halide/dnn_halide.markdown | 130 +
.../dnn_halide_scheduling.markdown | 82 +
.../tutorials/dnn/images}/space_shuttle.jpg | Bin
doc/tutorials/dnn/table_of_content_dnn.markdown | 26 +
.../harris_detector/harris_detector.markdown | 2 +-
.../gpu_basics_similarity.markdown | 66 +-
.../gpu-thrust-interop/gpu_thrust_interop.markdown | 4 +-
doc/tutorials/gpu/table_of_content_gpu.markdown | 7 +
doc/tutorials/highgui/trackbar/trackbar.markdown | 2 +-
.../erosion_dilatation/erosion_dilatation.markdown | 26 +-
.../template_matching/template_matching.markdown | 261 +-
doc/tutorials/imgproc/hitOrMiss/hitOrMiss.markdown | 60 +
.../imgproc/hitOrMiss/images/hitmiss_example2.png | Bin 0 -> 22299 bytes
.../imgproc/hitOrMiss/images/hitmiss_example3.png | Bin 0 -> 22802 bytes
.../imgproc/hitOrMiss/images/hitmiss_input.png | Bin 0 -> 25033 bytes
.../imgproc/hitOrMiss/images/hitmiss_kernels.png | Bin 0 -> 11040 bytes
.../imgproc/hitOrMiss/images/hitmiss_output.png | Bin 0 -> 18677 bytes
.../canny_detector/canny_detector.markdown | 12 +-
.../imgproc/imgtrans/filter_2d/filter_2d.markdown | 4 +-
.../imgtrans/hough_circle/hough_circle.markdown | 2 +-
.../imgtrans/warp_affine/warp_affine.markdown | 34 +-
.../imgproc/table_of_content_imgproc.markdown | 30 +-
.../introduction/biicode/images/bii_lena.png | Bin 102674 -> 0 bytes
.../building_tegra_cuda.markdown | 2 +-
.../java_eclipse/java_eclipse.markdown | 2 +-
.../linux_install/linux_install.markdown | 16 +-
.../load_save_image/load_save_image.markdown | 2 +-
.../windows_install/images/MiktexInstall.png | Bin 10347 -> 0 bytes
.../windows_install/images/Sphinx_Install.png | Bin 21619 -> 0 bytes
.../windows_install/images/WindowsBuildDoc.png | Bin 4627 -> 0 bytes
.../windows_install/images/cmsdstartwindows.jpg | Bin 8795 -> 0 bytes
.../windows_install/windows_install.markdown | 110 +-
.../windows_visual_studio_Opencv.markdown | 27 +-
.../cascade_classifier/cascade_classifier.markdown | 6 +-
doc/tutorials/tutorials.markdown | 26 +-
modules/calib3d/include/opencv2/calib3d.hpp | 205 +-
modules/calib3d/misc/java/gen_dict.json | 42 +
modules/calib3d/misc/java/test/Calib3dTest.java | 2 +-
modules/calib3d/perf/perf_stereosgbm.cpp | 14 +-
modules/calib3d/src/ap3p.cpp | 418 +
modules/calib3d/src/ap3p.h | 67 +
modules/calib3d/src/calibinit.cpp | 22 +-
modules/calib3d/src/calibration.cpp | 140 +-
modules/calib3d/src/circlesgrid.cpp | 19 +-
modules/calib3d/src/circlesgrid.hpp | 28 +-
modules/calib3d/src/compat_ptsetreg.cpp | 4 -
modules/calib3d/src/dls.h | 2 +-
modules/calib3d/src/epnp.cpp | 14 +-
modules/calib3d/src/fisheye.cpp | 34 +-
modules/calib3d/src/five-point.cpp | 42 +-
modules/calib3d/src/fundam.cpp | 4 +-
modules/calib3d/src/homography_decomp.cpp | 2 +-
modules/calib3d/src/p3p.cpp | 35 +
modules/calib3d/src/p3p.h | 6 +-
modules/calib3d/src/ptsetreg.cpp | 20 +-
modules/calib3d/src/rho.cpp | 54 +-
modules/calib3d/src/solvepnp.cpp | 161 +-
modules/calib3d/src/stereobm.cpp | 546 +-
modules/calib3d/src/stereosgbm.cpp | 748 +-
modules/calib3d/src/triangulate.cpp | 48 +-
modules/calib3d/src/upnp.cpp | 6 +-
modules/calib3d/test/test_affine2d_estimator.cpp | 28 +
.../test/test_affine_partial2d_estimator.cpp | 27 +
modules/calib3d/test/test_cameracalibration.cpp | 3 +-
modules/calib3d/test/test_chesscorners.cpp | 10 -
modules/calib3d/test/test_fisheye.cpp | 91 +-
modules/calib3d/test/test_homography_decomp.cpp | 2 +-
modules/calib3d/test/test_solvepnp_ransac.cpp | 168 +-
modules/calib3d/test/test_stereomatching.cpp | 22 +
modules/calib3d/test/test_undistort_points.cpp | 13 +-
modules/core/CMakeLists.txt | 32 +-
modules/core/include/opencv2/core.hpp | 24 +-
modules/core/include/opencv2/core/affine.hpp | 8 +-
modules/core/include/opencv2/core/base.hpp | 75 +-
modules/core/include/opencv2/core/bufferpool.hpp | 9 +
modules/core/include/opencv2/core/core_c.h | 4 +-
modules/core/include/opencv2/core/cuda.hpp | 34 +-
modules/core/include/opencv2/core/cuda/warp.hpp | 2 +-
.../core/include/opencv2/core/cv_cpu_dispatch.h | 210 +
modules/core/include/opencv2/core/cv_cpu_helper.h | 184 +
modules/core/include/opencv2/core/cvdef.h | 245 +-
modules/core/include/opencv2/core/cvstd.hpp | 45 +-
modules/core/include/opencv2/core/cvstd.inl.hpp | 51 +-
modules/core/include/opencv2/core/fast_math.hpp | 72 +-
modules/core/include/opencv2/core/hal/intrin.hpp | 53 +
.../core/include/opencv2/core/hal/intrin_cpp.hpp | 76 +-
.../core/include/opencv2/core/hal/intrin_neon.hpp | 71 +-
.../core/include/opencv2/core/hal/intrin_sse.hpp | 172 +-
modules/core/include/opencv2/core/mat.hpp | 170 +-
modules/core/include/opencv2/core/mat.inl.hpp | 201 +-
modules/core/include/opencv2/core/matx.hpp | 49 +-
modules/core/include/opencv2/core/ocl.hpp | 111 +-
modules/core/include/opencv2/core/ocl_genbase.hpp | 25 +-
.../core/opencl/runtime/opencl_clamdblas.hpp | 2 +-
.../core/opencl/runtime/opencl_clamdfft.hpp | 2 +-
.../opencv2/core/opencl/runtime/opencl_core.hpp | 2 +-
.../core/include/opencv2/core/openvx/ovx_defs.hpp | 8 +
modules/core/include/opencv2/core/operations.hpp | 6 +-
modules/core/include/opencv2/core/optim.hpp | 2 +-
modules/core/include/opencv2/core/persistence.hpp | 98 +-
modules/core/include/opencv2/core/private.cuda.hpp | 14 -
modules/core/include/opencv2/core/private.hpp | 308 +-
.../private/cv_cpu_include_simd_declarations.hpp | 30 +
modules/core/include/opencv2/core/softfloat.hpp | 245 +
modules/core/include/opencv2/core/types.hpp | 49 +-
modules/core/include/opencv2/core/types_c.h | 38 +-
modules/core/include/opencv2/core/utility.hpp | 112 +-
modules/core/include/opencv2/core/utils/logger.hpp | 84 +
modules/core/include/opencv2/core/utils/trace.hpp | 250 +
.../include/opencv2/core/utils/trace.private.hpp | 419 +
modules/core/include/opencv2/core/version.hpp | 2 +-
modules/core/misc/java/gen_dict.json | 896 +
modules/core/misc/java/src/java/core+DMatch.java | 3 -
.../core/misc/java/src/java/core+MatOfRect2d.java | 81 +
modules/core/misc/java/src/java/core+Rect.java | 4 +
modules/core/misc/java/src/java/core+Rect2d.java | 104 +
modules/core/misc/java/src/java/core+Size.java | 4 +
modules/core/perf/opencl/perf_matop.cpp | 2 +-
modules/core/perf/perf_lut.cpp | 26 +
modules/core/perf/perf_norm.cpp | 58 +-
modules/core/src/algorithm.cpp | 5 +
modules/core/src/alloc.cpp | 647 +-
modules/core/src/arithm.cpp | 27 +-
modules/core/src/array.cpp | 3 +-
modules/core/src/command_line_parser.cpp | 4 +-
modules/core/src/convert.avx2.cpp | 78 +
modules/core/src/convert.cpp | 915 +-
modules/core/src/convert.fp16.cpp | 167 +
modules/core/src/convert.hpp | 188 +
modules/core/src/convert.sse4_1.cpp | 241 +
modules/core/src/copy.cpp | 437 +-
modules/core/src/cuda_stream.cpp | 46 +-
modules/core/src/datastructs.cpp | 3 +-
modules/core/src/directx.cpp | 2 +
modules/core/src/dxt.cpp | 39 +-
modules/core/src/glob.cpp | 4 +-
modules/core/src/hal_internal.cpp | 40 +-
modules/core/src/intel_gpu_gemm.inl.hpp | 147 +
modules/core/src/kmeans.cpp | 33 +-
modules/core/src/lapack.cpp | 222 +-
modules/core/src/lda.cpp | 6 +-
modules/core/src/lpsolver.cpp | 1 -
modules/core/src/mathfuncs.cpp | 109 +-
modules/core/src/mathfuncs_core.cpp | 1587 -
modules/core/src/mathfuncs_core.dispatch.cpp | 215 +
modules/core/src/mathfuncs_core.simd.hpp | 1553 +
modules/core/src/matmul.cpp | 193 +-
modules/core/src/matrix.cpp | 703 +-
modules/core/src/ocl.cpp | 1567 +-
modules/core/src/ocl_deprecated.hpp | 1211 +
modules/core/src/opencl/halfconvert.cl | 73 +
modules/core/src/opencl/intel_gemm.cl | 1082 +
modules/core/src/opencl/runtime/opencl_core.cpp | 5 +-
modules/core/src/opengl.cpp | 6 +-
modules/core/src/out.cpp | 2 +-
modules/core/src/ovx.cpp | 34 +-
modules/core/src/parallel.cpp | 148 +-
modules/core/src/parallel_pthreads.cpp | 27 +-
modules/core/src/persistence.cpp | 212 +-
modules/core/src/precomp.hpp | 22 +-
modules/core/src/rand.cpp | 24 +-
modules/core/src/softfloat.cpp | 3945 ++
modules/core/src/stat.cpp | 969 +-
modules/core/src/stat.dispatch.cpp | 28 +
modules/core/src/stat.simd.hpp | 171 +
modules/core/src/system.cpp | 617 +-
modules/core/src/trace.cpp | 1128 +
modules/core/src/umatrix.cpp | 17 +-
modules/core/test/ocl/test_arithm.cpp | 73 +-
modules/core/test/test_arithm.cpp | 94 +
modules/core/test/test_countnonzero.cpp | 27 +
modules/core/test/test_eigen.cpp | 4 +-
modules/core/test/test_intrin.cpp | 42 +-
modules/core/test/test_io.cpp | 383 +-
modules/core/test/test_ippasync.cpp | 11 -
modules/core/test/test_mat.cpp | 207 +
modules/core/test/test_math.cpp | 577 +-
modules/core/test/test_misc.cpp | 16 +
modules/core/test/test_operations.cpp | 173 +-
modules/core/test/test_rand.cpp | 36 +
modules/core/test/test_umat.cpp | 14 +
modules/cudaarithm/include/opencv2/cudaarithm.hpp | 30 +
modules/cudaarithm/src/arithm.cpp | 197 +-
modules/cudaarithm/src/cuda/absdiff_scalar.cu | 63 +-
modules/cudaarithm/test/test_arithm.cpp | 27 +
modules/cudabgsegm/perf/perf_bgsegm.cpp | 19 +-
modules/cudabgsegm/test/test_bgsegm.cpp | 15 +-
modules/cudacodec/perf/perf_video.cpp | 17 +-
modules/cudacodec/src/ffmpeg_video_source.cpp | 2 +-
modules/cudacodec/src/precomp.hpp | 2 +-
modules/cudacodec/src/thread.cpp | 4 +-
modules/cudacodec/src/video_writer.cpp | 8 +-
modules/cudacodec/test/test_video.cpp | 4 +-
modules/cudafilters/src/cuda/median_filter.cu | 5 -
modules/cudafilters/src/filtering.cpp | 7 +-
.../cudaimgproc/include/opencv2/cudaimgproc.hpp | 9 +
modules/cudaimgproc/src/cuda/hist.cu | 66 +
modules/cudaimgproc/src/histogram.cpp | 14 +-
modules/cudaimgproc/test/test_histogram.cpp | 43 +
modules/cudalegacy/perf/perf_bgsegm.cpp | 17 +-
modules/cudaobjdetect/src/cuda/hog.cu | 151 +-
modules/cudaobjdetect/src/hog.cpp | 170 +-
.../cudaoptflow/include/opencv2/cudaoptflow.hpp | 2 +-
modules/cudaoptflow/src/cuda/pyrlk.cu | 19 +-
modules/cudaoptflow/src/pyrlk.cpp | 6 +-
modules/cudev/include/opencv2/cudev/warp/warp.hpp | 2 +-
modules/dnn/CMakeLists.txt | 90 +
modules/dnn/include/opencv2/dnn.hpp | 64 +
modules/dnn/include/opencv2/dnn/all_layers.hpp | 471 +
modules/dnn/include/opencv2/dnn/dict.hpp | 152 +
modules/dnn/include/opencv2/dnn/dnn.hpp | 697 +
modules/dnn/include/opencv2/dnn/dnn.inl.hpp | 373 +
modules/dnn/include/opencv2/dnn/layer.details.hpp | 78 +
modules/dnn/include/opencv2/dnn/layer.hpp | 85 +
modules/dnn/include/opencv2/dnn/shape_utils.hpp | 197 +
modules/dnn/misc/caffe/caffe.pb.cc | 53676 +++++++++++++++++++
modules/dnn/misc/caffe/caffe.pb.h | 28612 ++++++++++
modules/dnn/misc/java/filelist_common | 1 +
modules/dnn/misc/java/gen_dict.json | 55 +
modules/dnn/misc/java/src/cpp/dnn_converters.cpp | 94 +
modules/dnn/misc/java/src/cpp/dnn_converters.hpp | 36 +
modules/dnn/misc/java/test/DnnTensorFlowTest.java | 113 +
modules/dnn/misc/python/pyopencv_dnn.hpp | 39 +
.../dnn/misc/tensorflow/attr_value.pb.cc | 0
.../dnn/misc/tensorflow/attr_value.pb.h | 0
.../dnn/misc/tensorflow/function.pb.cc | 0
.../dnn/misc/tensorflow/function.pb.h | 0
.../dnn/misc/tensorflow/graph.pb.cc | 0
.../dnn/misc/tensorflow/graph.pb.h | 0
.../dnn/misc/tensorflow/op_def.pb.cc | 0
.../dnn/misc/tensorflow/op_def.pb.h | 0
.../dnn/misc/tensorflow/tensor.pb.cc | 0
.../dnn/misc/tensorflow/tensor.pb.h | 0
.../dnn/misc/tensorflow/tensor_shape.pb.cc | 0
.../dnn/misc/tensorflow/tensor_shape.pb.h | 0
.../dnn/misc/tensorflow/types.pb.cc | 0
.../dnn/misc/tensorflow/types.pb.h | 0
.../dnn/misc/tensorflow/versions.pb.cc | 0
.../dnn/misc/tensorflow/versions.pb.h | 0
modules/dnn/perf/perf_convolution.cpp | 106 +
modules/dnn/perf/perf_halide_net.cpp | 174 +
modules/dnn/perf/perf_main.cpp | 12 +
.../modules => modules}/dnn/perf/perf_precomp.hpp | 0
modules/dnn/src/caffe/caffe.proto | 1581 +
modules/dnn/src/caffe/caffe_importer.cpp | 393 +
modules/dnn/src/caffe/caffe_io.cpp | 1151 +
modules/dnn/src/caffe/caffe_io.hpp | 108 +
modules/dnn/src/caffe/glog_emulator.hpp | 106 +
modules/dnn/src/dnn.cpp | 2263 +
modules/dnn/src/halide_scheduler.cpp | 285 +
modules/dnn/src/halide_scheduler.hpp | 37 +
modules/dnn/src/init.cpp | 121 +
modules/dnn/src/layers/batch_norm_layer.cpp | 201 +
modules/dnn/src/layers/blank_layer.cpp | 82 +
modules/dnn/src/layers/concat_layer.cpp | 226 +
modules/dnn/src/layers/convolution_layer.cpp | 1225 +
modules/dnn/src/layers/crop_layer.cpp | 157 +
modules/dnn/src/layers/detection_output_layer.cpp | 728 +
modules/dnn/src/layers/elementwise_layers.cpp | 583 +
modules/dnn/src/layers/eltwise_layer.cpp | 335 +
modules/dnn/src/layers/flatten_layer.cpp | 129 +
modules/dnn/src/layers/fully_connected_layer.cpp | 310 +
modules/dnn/src/layers/layers_common.cpp | 207 +
modules/dnn/src/layers/layers_common.hpp | 76 +
modules/dnn/src/layers/layers_common.simd.hpp | 370 +
modules/dnn/src/layers/lrn_layer.cpp | 345 +
modules/dnn/src/layers/max_unpooling_layer.cpp | 131 +
modules/dnn/src/layers/mvn_layer.cpp | 112 +
modules/dnn/src/layers/normalize_bbox_layer.cpp | 227 +
modules/dnn/src/layers/padding_layer.cpp | 134 +
modules/dnn/src/layers/permute_layer.cpp | 321 +
modules/dnn/src/layers/pooling_layer.cpp | 641 +
modules/dnn/src/layers/prior_box_layer.cpp | 384 +
modules/dnn/src/layers/recurrent_layers.cpp | 452 +
modules/dnn/src/layers/reshape_layer.cpp | 251 +
modules/dnn/src/layers/scale_layer.cpp | 150 +
modules/dnn/src/layers/shift_layer.cpp | 99 +
modules/dnn/src/layers/slice_layer.cpp | 144 +
modules/dnn/src/layers/softmax_layer.cpp | 221 +
modules/dnn/src/layers/split_layer.cpp | 101 +
modules/dnn/src/op_halide.cpp | 209 +
modules/dnn/src/op_halide.hpp | 84 +
modules/dnn/src/opencl/activations.cl | 44 +
.../modules => modules}/dnn/src/opencl/col2im.cl | 0
.../modules => modules}/dnn/src/opencl/im2col.cl | 0
{contrib/modules => modules}/dnn/src/opencl/lrn.cl | 0
modules/dnn/src/opencl/pooling.cl | 106 +
.../modules => modules}/dnn/src/opencl/softmax.cl | 0
modules/dnn/src/precomp.hpp | 54 +
.../dnn/src/tensorflow/attr_value.proto | 0
.../dnn/src/tensorflow/function.proto | 0
.../dnn/src/tensorflow/graph.proto | 0
.../dnn/src/tensorflow/op_def.proto | 0
.../dnn/src/tensorflow/tensor.proto | 0
.../dnn/src/tensorflow/tensor_shape.proto | 0
modules/dnn/src/tensorflow/tf_importer.cpp | 915 +
modules/dnn/src/tensorflow/tf_io.cpp | 63 +
modules/dnn/src/tensorflow/tf_io.hpp | 29 +
.../dnn/src/tensorflow/types.proto | 0
.../dnn/src/tensorflow/versions.proto | 0
.../dnn/src/torch/COPYRIGHT.txt | 0
modules/dnn/src/torch/THDiskFile.cpp | 532 +
modules/dnn/src/torch/THDiskFile.h | 23 +
modules/dnn/src/torch/THFile.cpp | 122 +
modules/dnn/src/torch/THFile.h | 55 +
modules/dnn/src/torch/THFilePrivate.h | 37 +
modules/dnn/src/torch/THGeneral.cpp | 13 +
modules/dnn/src/torch/THGeneral.h | 22 +
modules/dnn/src/torch/torch_importer.cpp | 1039 +
modules/dnn/test/cityscapes_semsegm_test_enet.py | 140 +
{contrib/modules => modules}/dnn/test/cnpy.cpp | 0
{contrib/modules => modules}/dnn/test/cnpy.h | 0
modules/dnn/test/imagenet_cls_test_alexnet.py | 241 +
modules/dnn/test/imagenet_cls_test_googlenet.py | 39 +
modules/dnn/test/imagenet_cls_test_inception.py | 77 +
modules/dnn/test/npy_blob.hpp | 65 +
modules/dnn/test/pascal_semsegm_test_fcn.py | 224 +
modules/dnn/test/test_caffe_importer.cpp | 191 +
modules/dnn/test/test_common.hpp | 60 +
modules/dnn/test/test_googlenet.cpp | 131 +
modules/dnn/test/test_halide_layers.cpp | 651 +
modules/dnn/test/test_halide_nets.cpp | 175 +
modules/dnn/test/test_layers.cpp | 435 +
modules/dnn/test/test_main.cpp | 20 +
.../modules => modules}/dnn/test/test_precomp.hpp | 0
modules/dnn/test/test_tf_importer.cpp | 128 +
modules/dnn/test/test_torch_importer.cpp | 207 +
modules/features2d/CMakeLists.txt | 2 +-
modules/features2d/misc/java/gen_dict.json | 21 +
modules/features2d/perf/opencl/perf_fast.cpp | 47 -
modules/features2d/perf/opencl/perf_feature2d.cpp | 81 +
modules/features2d/perf/opencl/perf_orb.cpp | 87 -
modules/features2d/perf/perf_agast.cpp | 42 -
modules/features2d/perf/perf_fast.cpp | 40 -
modules/features2d/perf/perf_feature2d.cpp | 66 +
modules/features2d/perf/perf_feature2d.hpp | 87 +
modules/features2d/perf/perf_orb.cpp | 80 -
modules/features2d/src/agast_score.cpp | 7 +-
modules/features2d/src/akaze.cpp | 14 +-
modules/features2d/src/brisk.cpp | 10 +-
modules/features2d/src/evaluation.cpp | 2 +-
modules/features2d/src/fast.cpp | 126 +-
modules/features2d/src/kaze.cpp | 3 +-
modules/features2d/src/kaze/AKAZEFeatures.cpp | 1913 +-
modules/features2d/src/kaze/AKAZEFeatures.h | 42 +-
modules/features2d/src/kaze/KAZEFeatures.cpp | 48 +-
modules/features2d/src/kaze/TEvolution.h | 1 +
modules/features2d/src/kaze/fed.cpp | 2 +-
.../features2d/src/kaze/nldiffusion_functions.cpp | 35 +-
.../features2d/src/kaze/nldiffusion_functions.h | 8 +-
modules/features2d/src/kaze/utils.h | 55 -
modules/features2d/src/keypoint.cpp | 2 +
modules/features2d/src/mser.cpp | 141 +-
modules/features2d/src/opencl/akaze.cl | 122 +
.../test/ocl/test_brute_force_matcher.cpp | 6 +-
modules/features2d/test/test_akaze.cpp | 47 +
.../test/test_descriptors_invariance.cpp | 194 +
.../test/test_descriptors_regression.cpp | 224 +-
.../features2d/test/test_detectors_invariance.cpp | 255 +
.../features2d/test/test_detectors_regression.cpp | 20 +-
modules/features2d/test/test_invariance_utils.hpp | 92 +
modules/features2d/test/test_mser.cpp | 23 +
modules/features2d/test/test_precomp.hpp | 1 -
.../test/test_rotation_and_scale_invariance.cpp | 717 -
modules/flann/include/opencv2/flann.hpp | 28 +-
modules/flann/include/opencv2/flann/allocator.h | 1 +
modules/flann/include/opencv2/flann/any.h | 6 +
.../flann/include/opencv2/flann/autotuned_index.h | 3 +
modules/flann/include/opencv2/flann/defines.h | 15 +-
modules/flann/include/opencv2/flann/dist.h | 4 +-
modules/flann/include/opencv2/flann/dummy.h | 2 +-
.../flann/include/opencv2/flann/dynamic_bitset.h | 2 +-
modules/flann/include/opencv2/flann/flann_base.hpp | 6 +-
modules/flann/include/opencv2/flann/kdtree_index.h | 5 +
.../include/opencv2/flann/kdtree_single_index.h | 1 +
modules/flann/include/opencv2/flann/logger.h | 5 +
modules/flann/include/opencv2/flann/lsh_table.h | 31 +-
modules/flann/include/opencv2/flann/matrix.h | 2 +-
modules/flann/include/opencv2/flann/random.h | 28 +-
modules/flann/include/opencv2/flann/result_set.h | 2 +-
modules/flann/misc/python/pyopencv_flann.hpp | 3 +
modules/highgui/CMakeLists.txt | 11 +-
modules/highgui/include/opencv2/highgui.hpp | 40 +-
.../highgui/include/opencv2/highgui/highgui_c.h | 2 +-
modules/highgui/misc/java/gen_dict.json | 31 +
modules/highgui/src/precomp.hpp | 4 +-
modules/highgui/src/roiSelector.cpp | 203 +
modules/highgui/src/window.cpp | 26 +-
modules/highgui/src/window_QT.cpp | 2 +-
modules/highgui/src/window_QT.h | 4 +
modules/highgui/src/window_carbon.cpp | 6 +-
modules/highgui/src/window_cocoa.mm | 30 +-
modules/highgui/src/window_gtk.cpp | 14 +-
modules/highgui/src/window_w32.cpp | 6 +-
modules/highgui/src/window_winrt_bridge.cpp | 2 +
modules/imgcodecs/CMakeLists.txt | 11 +-
modules/imgcodecs/include/opencv2/imgcodecs.hpp | 4 +-
modules/imgcodecs/src/bitstrm.cpp | 2 +
modules/imgcodecs/src/exif.cpp | 51 +-
modules/imgcodecs/src/exif.hpp | 10 +-
modules/imgcodecs/src/grfmt_base.cpp | 1 +
modules/imgcodecs/src/grfmt_bmp.cpp | 5 +-
modules/imgcodecs/src/grfmt_exr.cpp | 17 +-
modules/imgcodecs/src/grfmt_gdal.cpp | 7 +-
modules/imgcodecs/src/grfmt_jpeg.cpp | 8 +-
modules/imgcodecs/src/grfmt_jpeg2000.cpp | 6 +-
modules/imgcodecs/src/grfmt_pam.cpp | 3 +
modules/imgcodecs/src/grfmt_png.cpp | 1 +
modules/imgcodecs/src/grfmt_pxm.cpp | 3 +
modules/imgcodecs/src/grfmt_sunras.cpp | 6 +-
modules/imgcodecs/src/grfmt_tiff.cpp | 2 +-
modules/imgcodecs/src/grfmt_webp.cpp | 9 +-
modules/imgcodecs/src/ios_conversions.mm | 6 +-
modules/imgcodecs/src/loadsave.cpp | 140 +-
modules/imgcodecs/src/precomp.hpp | 2 +-
modules/imgcodecs/test/test_grfmt.cpp | 1050 +-
modules/imgcodecs/test/test_jpeg.cpp | 180 +
modules/imgcodecs/test/test_png.cpp | 95 +
modules/imgcodecs/test/test_precomp.hpp | 7 +-
modules/imgcodecs/test/test_read_write.cpp | 122 +
modules/imgcodecs/test/test_tiff.cpp | 202 +
modules/imgcodecs/test/test_webp.cpp | 106 +
modules/imgproc/CMakeLists.txt | 1 +
modules/imgproc/doc/pics/ellipse.png | Bin 2425 -> 0 bytes
modules/imgproc/doc/pics/ellipse.svg | 1156 +
modules/imgproc/include/opencv2/imgproc.hpp | 197 +-
.../imgproc/include/opencv2/imgproc/hal/hal.hpp | 104 +-
modules/imgproc/include/opencv2/imgproc/types_c.h | 23 +-
modules/imgproc/misc/java/gen_dict.json | 134 +
modules/imgproc/perf/opencl/perf_blend.cpp | 2 +-
modules/imgproc/perf/opencl/perf_imgproc.cpp | 8 +-
modules/imgproc/perf/perf_accumulate.cpp | 96 +
modules/imgproc/perf/perf_canny.cpp | 4 +-
modules/imgproc/perf/perf_cvt_color.cpp | 10 +-
modules/imgproc/perf/perf_filter2d.cpp | 27 +
modules/imgproc/perf/perf_pyramids.cpp | 21 +
modules/imgproc/perf/perf_resize.cpp | 4 +-
modules/imgproc/perf/perf_warp.cpp | 74 +-
modules/imgproc/src/accum.cpp | 1724 +-
modules/imgproc/src/accum.dispatch.cpp | 20 +
modules/imgproc/src/accum.simd.hpp | 3136 ++
modules/imgproc/src/approx.cpp | 1 +
modules/imgproc/src/blend.cpp | 256 +-
modules/imgproc/src/canny.cpp | 1269 +-
modules/imgproc/src/color.cpp | 2019 +-
modules/imgproc/src/colormap.cpp | 28 +
modules/imgproc/src/connectedcomponents.cpp | 4435 +-
modules/imgproc/src/contours.cpp | 112 +-
modules/imgproc/src/convhull.cpp | 33 +-
modules/imgproc/src/corner.avx.cpp | 181 +
modules/imgproc/src/corner.cpp | 262 +-
modules/imgproc/src/corner.hpp | 60 +
modules/imgproc/src/demosaicing.cpp | 7 +-
modules/imgproc/src/deriv.cpp | 545 +-
modules/imgproc/src/distransform.cpp | 8 +-
modules/imgproc/src/drawing.cpp | 64 +-
modules/imgproc/src/emd.cpp | 14 +-
modules/imgproc/src/featureselect.cpp | 5 +-
modules/imgproc/src/filter.avx2.cpp | 200 +
modules/imgproc/src/filter.cpp | 770 +-
modules/imgproc/src/filter.hpp | 57 +
modules/imgproc/src/grabcut.cpp | 3 +-
modules/imgproc/src/histogram.cpp | 319 +-
modules/imgproc/src/hough.cpp | 59 +-
modules/imgproc/src/imgwarp.avx2.cpp | 299 +
modules/imgproc/src/imgwarp.cpp | 1061 +-
modules/imgproc/src/imgwarp.hpp | 89 +
modules/imgproc/src/imgwarp.sse4_1.cpp | 678 +
modules/imgproc/src/lsd.cpp | 8 +-
modules/imgproc/src/matchcontours.cpp | 22 +
modules/imgproc/src/min_enclosing_triangle.cpp | 2 +-
modules/imgproc/src/moments.cpp | 277 +-
modules/imgproc/src/morph.cpp | 664 +-
modules/imgproc/src/opencl/clahe.cl | 12 +-
modules/imgproc/src/opencl/cvtcolor.cl | 69 +-
modules/imgproc/src/precomp.hpp | 26 +-
modules/imgproc/src/pyramids.cpp | 17 +-
modules/imgproc/src/samplers.cpp | 2 +-
modules/imgproc/src/shapedescr.cpp | 2 +-
modules/imgproc/src/smooth.cpp | 769 +-
modules/imgproc/src/spatialgradient.cpp | 21 +-
modules/imgproc/src/sumpixels.cpp | 82 +-
modules/imgproc/src/templmatch.cpp | 202 +-
modules/imgproc/src/thresh.cpp | 18 +-
modules/imgproc/src/undistort.avx2.cpp | 200 +
modules/imgproc/src/undistort.cpp | 31 +-
modules/imgproc/src/undistort.hpp | 59 +
modules/imgproc/test/ocl/test_warp.cpp | 2 +-
modules/imgproc/test/test_bilateral_filter.cpp | 9 +-
modules/imgproc/test/test_color.cpp | 25 +
modules/imgproc/test/test_drawing.cpp | 25 +
modules/imgproc/test/test_filter.cpp | 35 +-
modules/imgproc/test/test_houghLines.cpp | 2 +-
modules/imgproc/test/test_imgwarp.cpp | 23 +-
modules/java/CMakeLists.txt | 112 +-
modules/java/android_lib/jni/Android.mk | 1 -
.../src/org/opencv/test/OpenCVTestRunner.java | 2 +-
modules/java/build.xml.in | 17 +-
modules/java/generator/gen_java.py | 785 +-
modules/java/generator/src/cpp/common.h | 15 +-
modules/java/generator/src/cpp/converters.cpp | 16 +-
modules/java/generator/src/cpp/converters.h | 3 +
modules/java/generator/src/cpp/listconverters.cpp | 59 +
modules/java/generator/src/cpp/listconverters.hpp | 19 +
.../src/java/android+AsyncServiceHelper.java | 6 +-
.../src/java/android+BaseLoaderCallback.java | 2 +-
.../src/java/android+CameraBridgeViewBase.java | 2 +-
.../generator/src/java/android+JavaCameraView.java | 27 +-
.../generator/src/java/android+OpenCVLoader.java | 116 -
.../src/java/android+OpenCVLoader.java.in | 127 +
modules/java/generator/src/java/android+sync.py | 7 -
.../generator/src/java/osgi+OpenCVInterface.java | 8 +
.../src/java/osgi+OpenCVNativeLoader.java.in | 18 +
.../java/generator/src/java/utils+Converters.java | 37 +
modules/java/include/opencv2/java.hpp | 49 +
modules/java/pure_test/CMakeLists.txt | 4 +-
modules/ml/include/opencv2/ml.hpp | 175 +-
modules/ml/misc/java/test/MLTest.java | 42 +
modules/ml/src/boost.cpp | 5 +
modules/ml/src/data.cpp | 4 +-
modules/ml/src/em.cpp | 5 +
modules/ml/src/inner_functions.cpp | 10 +
modules/ml/src/lr.cpp | 18 +-
modules/ml/src/nbayes.cpp | 6 +
modules/ml/src/rtrees.cpp | 96 +-
modules/ml/src/svm.cpp | 37 +
modules/ml/src/svmsgd.cpp | 6 +
modules/ml/src/tree.cpp | 9 +-
modules/ml/test/test_emknearestkmeans.cpp | 4 +
modules/ml/test/test_lr.cpp | 8 +
modules/ml/test/test_mltests.cpp | 47 +
modules/ml/test/test_mltests2.cpp | 11 +
modules/objdetect/CMakeLists.txt | 2 +-
modules/objdetect/include/opencv2/objdetect.hpp | 20 +-
.../include/opencv2/objdetect/objdetect_c.h | 1 +
modules/objdetect/src/cascadedetect.cpp | 31 +-
modules/objdetect/src/cascadedetect.hpp | 10 +-
modules/objdetect/src/detection_based_tracker.cpp | 8 +-
modules/objdetect/src/haar.avx.cpp | 369 +
modules/objdetect/src/haar.cpp | 411 +-
modules/objdetect/src/haar.hpp | 101 +
modules/objdetect/src/hog.cpp | 24 +-
modules/objdetect/src/precomp.hpp | 8 -
modules/photo/CMakeLists.txt | 2 +-
modules/photo/include/opencv2/photo.hpp | 12 +-
modules/photo/src/calibrate.cpp | 97 +-
modules/photo/src/denoise_tvl1.cpp | 15 +-
modules/photo/src/denoising.cpp | 1 +
.../photo/src/fast_nlmeans_denoising_invoker.hpp | 4 +
.../src/fast_nlmeans_denoising_invoker_commons.hpp | 4 +-
.../photo/src/fast_nlmeans_denoising_opencl.hpp | 9 +-
modules/photo/src/hdr_common.cpp | 9 +-
modules/photo/src/hdr_common.hpp | 2 +-
modules/photo/src/inpaint.cpp | 76 +-
modules/photo/src/merge.cpp | 2 +-
modules/photo/test/test_hdr.cpp | 17 +-
modules/photo/test/test_inpaint.cpp | 23 +
modules/photo/test/test_npr.cpp | 13 +-
modules/python/CMakeLists.txt | 26 +-
modules/python/common.cmake | 11 +-
modules/python/src2/cv2.cpp | 200 +-
modules/python/src2/gen2.py | 66 +-
modules/python/src2/hdr_parser.py | 72 +-
modules/python/test/test.py | 20 +
modules/python/test/test_shape.py | 23 +
modules/python/test/test_stitching.py | 20 +
modules/shape/CMakeLists.txt | 2 +-
.../shape/include/opencv2/shape/shape_distance.hpp | 3 +
modules/shape/src/aff_trans.cpp | 2 +
modules/shape/src/emdL1.cpp | 2 +
modules/shape/src/emdL1_def.hpp | 8 +
modules/shape/src/haus_dis.cpp | 7 +
modules/shape/src/precomp.cpp | 45 -
modules/shape/src/sc_dis.cpp | 8 +
modules/shape/src/scd_def.hpp | 3 +-
modules/shape/src/tps_trans.cpp | 2 +
modules/shape/test/test_shape.cpp | 22 +
modules/stitching/CMakeLists.txt | 6 +-
.../include/opencv2/stitching/detail/blenders.hpp | 4 +
.../opencv2/stitching/detail/motion_estimators.hpp | 8 +-
.../include/opencv2/stitching/detail/warpers.hpp | 2 +-
modules/stitching/perf/opencl/perf_stitch.cpp | 31 +-
modules/stitching/perf/perf_precomp.hpp | 17 +
modules/stitching/perf/perf_stich.cpp | 28 +-
modules/stitching/src/blenders.cpp | 199 +-
modules/stitching/src/cuda/multiband_blend.cu | 112 +
modules/stitching/src/matchers.cpp | 8 +-
modules/stitching/src/motion_estimators.cpp | 2 +-
modules/stitching/src/seam_finders.cpp | 2 +-
modules/stitching/src/stitcher.cpp | 18 +-
modules/stitching/src/util_log.hpp | 2 +-
modules/stitching/test/test_blenders.cuda.cpp | 93 +
modules/superres/CMakeLists.txt | 4 +-
modules/superres/src/btv_l1.cpp | 25 +-
modules/superres/src/input_array_utility.cpp | 7 +-
modules/superres/test/test_precomp.hpp | 13 -
modules/superres/test/test_superres.cpp | 4 +-
modules/ts/include/opencv2/ts.hpp | 58 +-
modules/ts/include/opencv2/ts/cuda_perf.hpp | 7 +-
modules/ts/include/opencv2/ts/cuda_test.hpp | 16 +-
modules/ts/include/opencv2/ts/ocl_perf.hpp | 22 +-
modules/ts/include/opencv2/ts/ocl_test.hpp | 6 +-
modules/ts/include/opencv2/ts/ts_ext.hpp | 9 +-
modules/ts/include/opencv2/ts/ts_gtest.h | 20 +-
modules/ts/include/opencv2/ts/ts_perf.hpp | 25 +-
modules/ts/misc/run.py | 5 +-
modules/ts/misc/run_long.py | 16 +-
modules/ts/misc/run_suite.py | 41 +-
modules/ts/misc/run_utils.py | 8 +-
modules/ts/misc/trace_profiler.py | 435 +
modules/ts/src/cuda_perf.cpp | 2 +-
modules/ts/src/ocl_test.cpp | 3 +
modules/ts/src/precomp.hpp | 4 +-
modules/ts/src/ts.cpp | 15 +-
modules/ts/src/ts_func.cpp | 6 +-
modules/ts/src/ts_perf.cpp | 55 +-
.../include/opencv2/video/background_segm.hpp | 15 +-
modules/video/include/opencv2/video/tracking.hpp | 34 +-
modules/video/misc/java/gen_dict.json | 16 +
modules/video/perf/opencl/perf_bgfg_mog2.cpp | 19 +-
modules/video/perf/perf_optflowpyrlk.cpp | 52 +
modules/video/src/bgfg_KNN.cpp | 11 +-
modules/video/src/bgfg_gaussmix2.cpp | 22 +-
modules/video/src/ecc.cpp | 10 +
modules/video/src/lkpyramid.cpp | 19 +-
modules/video/src/opencl/pyrlk.cl | 68 +-
modules/video/src/optflowgf.cpp | 2 +-
modules/video/test/ocl/test_bgfg_mog2.cpp | 17 +-
modules/video/test/ocl/test_optflowpyrlk.cpp | 14 +-
modules/video/test/test_camshift.cpp | 4 +-
modules/videoio/CMakeLists.txt | 30 +-
modules/videoio/include/opencv2/videoio.hpp | 37 +-
modules/videoio/include/opencv2/videoio/cap_ios.h | 10 +-
modules/videoio/misc/gen_dict.json | 63 +
modules/videoio/perf/perf_input.cpp | 33 +-
modules/videoio/perf/perf_output.cpp | 43 +-
modules/videoio/perf/perf_precomp.hpp | 29 -
modules/videoio/src/cap.cpp | 221 +-
modules/videoio/src/cap_aravis.cpp | 47 +-
modules/videoio/src/cap_avfoundation.mm | 3 +-
modules/videoio/src/cap_avfoundation_mac.mm | 15 +-
modules/videoio/src/cap_cmu.cpp | 4 +-
modules/videoio/src/cap_dc1394.cpp | 2 +-
modules/videoio/src/cap_dc1394_v2.cpp | 4 +-
modules/videoio/src/cap_dshow.cpp | 115 +-
modules/videoio/src/cap_ffmpeg.cpp | 8 +-
modules/videoio/src/cap_ffmpeg_api.hpp | 2 +-
modules/videoio/src/cap_ffmpeg_impl.hpp | 67 +-
modules/videoio/src/cap_giganetix.cpp | 2 +-
modules/videoio/src/cap_gphoto2.cpp | 2 +-
modules/videoio/src/cap_gstreamer.cpp | 164 +-
modules/videoio/src/cap_images.cpp | 5 +-
modules/videoio/src/cap_libv4l.cpp | 11 +-
modules/videoio/src/cap_mfx_common.cpp | 183 +
modules/videoio/src/cap_mfx_common.hpp | 318 +
modules/videoio/src/cap_mfx_reader.cpp | 273 +
modules/videoio/src/cap_mfx_reader.hpp | 41 +
modules/videoio/src/cap_mfx_writer.cpp | 272 +
modules/videoio/src/cap_mfx_writer.hpp | 48 +
modules/videoio/src/cap_mjpeg_decoder.cpp | 3 +-
modules/videoio/src/cap_mjpeg_encoder.cpp | 12 +-
modules/videoio/src/cap_msmf.cpp | 2 +-
modules/videoio/src/cap_pvapi.cpp | 8 +-
modules/videoio/src/cap_qtkit.mm | 2 -
modules/videoio/src/cap_v4l.cpp | 18 +-
modules/videoio/src/cap_vfw.cpp | 24 +-
modules/videoio/src/cap_ximea.cpp | 8 +-
modules/videoio/src/ffmpeg_codecs.hpp | 2 +-
modules/videoio/src/precomp.hpp | 6 +-
modules/videoio/test/test_basic_props.cpp | 157 -
modules/videoio/test/test_ffmpeg.cpp | 2 +-
modules/videoio/test/test_framecount.cpp | 114 -
modules/videoio/test/test_mfx.cpp | 154 +
modules/videoio/test/test_positioning.cpp | 223 -
modules/videoio/test/test_precomp.hpp | 89 +-
modules/videoio/test/test_video_io.cpp | 685 +-
modules/videoio/test/test_video_pos.cpp | 179 -
.../include/opencv2/videostab/fast_marching.hpp | 2 +-
.../include/opencv2/videostab/global_motion.hpp | 1 +
modules/videostab/src/global_motion.cpp | 24 +-
modules/videostab/src/stabilizer.cpp | 5 +
modules/videostab/src/wobble_suppression.cpp | 2 +-
modules/videostab/test/test_main.cpp | 3 +
modules/videostab/test/test_motion_estimation.cpp | 171 +
modules/videostab/test/test_precomp.hpp | 16 +
modules/viz/CMakeLists.txt | 27 +-
.../viz/test/{test_precomp.cpp => test_common.cpp} | 0
modules/viz/test/test_common.hpp | 92 +
modules/viz/test/test_precomp.hpp | 114 +-
modules/viz/test/test_tutorial2.cpp | 2 +-
modules/viz/test/test_tutorial3.cpp | 2 +-
modules/world/CMakeLists.txt | 16 +-
platforms/android/README.android | 2 +-
platforms/android/android.toolchain.cmake | 10 +-
platforms/android/build-tests/test_ndk_build.py | 19 +-
platforms/android/build_sdk.py | 2 +-
.../android/service/engine/AndroidManifest.xml | 4 +-
.../src/org/opencv/engine/OpenCVEngineService.java | 2 +-
platforms/android/service/readme.txt | 2 +-
platforms/ios/Info.Dynamic.plist.in | 28 +
platforms/ios/build_framework.py | 144 +-
platforms/ios/cmake/Modules/Platform/iOS.cmake | 9 +-
.../cmake/Toolchains/common-ios-toolchain.cmake | 53 +-
platforms/maven/README.md | 35 +-
platforms/maven/opencv-it/pom.xml | 98 +
.../java/org/opencv/osgi/DeployOpenCVTest.java | 97 +
platforms/maven/opencv/pom.xml | 270 +
.../resources/OSGI-INF/blueprint/blueprint.xml | 11 +
platforms/maven/opencv/scripts/deb_package_check | 102 +
platforms/maven/opencv/scripts/execstack_check | 32 +
platforms/maven/{ => opencv}/scripts/properties | 0
platforms/maven/pom.xml | 253 +-
platforms/maven/scripts/deb_package_check | 42 -
platforms/osx/build_framework.py | 13 +-
platforms/scripts/valgrind.supp | 198 +-
platforms/scripts/valgrind_3rdparty.supp | 113 +
platforms/winrt/setup_winrt.ps1 | 12 +-
samples/CMakeLists.txt | 7 +-
samples/android/face-detection/jni/Android.mk | 1 -
samples/cpp/application_trace.cpp | 92 +
samples/cpp/create_mask.cpp | 27 +-
samples/cpp/detect_mser.cpp | 4 +-
samples/cpp/drawing.cpp | 32 +-
samples/cpp/edge.cpp | 8 +-
samples/cpp/falsecolor.cpp | 150 +
samples/cpp/grabcut.cpp | 11 +-
samples/cpp/image_alignment.cpp | 33 +-
samples/cpp/image_sequence.cpp | 9 +-
samples/cpp/inpaint.cpp | 9 +-
samples/cpp/kmeans.cpp | 8 +-
samples/cpp/laplace.cpp | 9 +-
samples/cpp/letter_recog.cpp | 14 +-
samples/cpp/lkdemo.cpp | 13 +-
samples/cpp/mask_tmpl.cpp | 8 +-
samples/cpp/npr_demo.cpp | 2 +-
samples/cpp/polar_transforms.cpp | 7 +-
samples/cpp/shape_example.cpp | 1 +
.../HighGUI/BasicLinearTransformsTrackbar.cpp | 13 +-
.../Histograms_Matching/MatchTemplate_Demo.cpp | 25 +-
.../ImgProc/BasicLinearTransforms.cpp | 94 +-
samples/cpp/tutorial_code/ImgProc/HitMiss.cpp | 37 +
samples/cpp/tutorial_code/ImgProc/Morphology_2.cpp | 9 +-
samples/cpp/tutorial_code/ImgProc/Threshold.cpp | 9 +-
.../changing_contrast_brightness_image.cpp | 98 +
.../tutorial_code/ImgTrans/HoughCircle_Demo.cpp | 14 +-
.../cpp/tutorial_code/ImgTrans/HoughLines_Demo.cpp | 11 +-
.../cpp/tutorial_code/ImgTrans/Laplace_Demo.cpp | 9 +-
samples/cpp/tutorial_code/ImgTrans/Remap_Demo.cpp | 6 +-
samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp | 9 +-
.../tutorial_code/ImgTrans/copyMakeBorder_demo.cpp | 9 +-
.../cpp/tutorial_code/ImgTrans/filter2D_demo.cpp | 9 +-
.../tutorial_code/ImgTrans/imageSegmentation.cpp | 4 +-
.../ShapeDescriptors/findContours_demo.cpp | 10 +-
.../camera_calibration/camera_calibration.cpp | 21 +-
.../real_time_pose_estimation/src/PnPProblem.cpp | 6 +-
.../real_time_pose_estimation/src/PnPProblem.h | 2 +-
.../tutorial_code/calib3d/stereoBM/SBM_Sample.cpp | 9 +-
.../core/AddingImages/AddingImages.cpp | 19 +-
.../how_to_use_OpenCV_parallel_for_.cpp | 147 +
.../mat_the_basic_image_container.cpp | 8 +-
.../cpp/tutorial_code/features2D/AKAZE_match.cpp | 5 +-
.../features2D/AKAZE_tracking/planar_tracking.cpp | 26 +-
.../features2D/AKAZE_tracking/utils.h | 55 -
.../ml/introduction_to_pca/introduction_to_pca.cpp | 14 +-
.../objectDetection/objectDetection.cpp | 18 +-
.../objectDetection/objectDetection2.cpp | 98 -
.../cpp/tutorial_code/xfeatures2D/LATCH_match.cpp | 6 +-
samples/data/dnn/MobileNetSSD_300x300.prototxt | 3102 ++
.../VGG_VOC0712_SSD_300x300_iter_60000.prototxt | 1546 +
.../data/dnn}/bvlc_googlenet.prototxt | 0
samples/data/dnn/enet-classes.txt | 20 +
.../data/dnn}/fcn32s-heavy-pascal.prototxt | 0
.../data/dnn}/fcn8s-heavy-pascal.prototxt | 0
.../data/dnn}/pascal-classes.txt | 0
.../dnn/samples => samples/data/dnn}/rgb.jpg | Bin
.../images => samples/data/dnn}/space_shuttle.jpg | Bin
.../samples => samples/data/dnn}/synset_words.txt | 0
samples/data/lena_tmpl.jpg | Bin 79467 -> 0 bytes
samples/dnn/CMakeLists.txt | 55 +
samples/dnn/caffe_googlenet.cpp | 152 +
samples/dnn/fcn_semsegm.cpp | 152 +
samples/dnn/googlenet_python.py | 24 +
samples/dnn/mobilenet_ssd_python.py | 87 +
samples/dnn/squeezenet_halide.cpp | 118 +
samples/dnn/ssd_mobilenet_object_detection.cpp | 161 +
samples/dnn/ssd_object_detection.cpp | 152 +
samples/dnn/tf_inception.cpp | 173 +
samples/dnn/torch_enet.cpp | 209 +
samples/gpu/CMakeLists.txt | 12 +-
samples/gpu/cascadeclassifier.cpp | 2 +-
samples/gpu/driver_api_stereo_multi.cpp | 2 +-
samples/gpu/farneback_optical_flow.cpp | 1 +
samples/gpu/hog.cpp | 2 +-
samples/gpu/opengl.cpp | 5 +-
samples/gpu/performance/CMakeLists.txt | 4 +-
samples/gpu/pyrlk_optical_flow.cpp | 225 +-
samples/gpu/stereo_match.cpp | 4 +-
samples/gpu/stereo_multi.cpp | 6 +-
samples/gpu/surf_keypoint_matcher.cpp | 2 +-
samples/gpu/video_writer.cpp | 2 +-
samples/java/tutorial_code/CMakeLists.txt | 39 +
.../MatchTemplateDemo.java | 196 +
samples/java/tutorial_code/build.xml | 13 +
samples/opengl/opengl_interop.cpp | 18 +-
samples/opengl/winapp.hpp | 22 +-
samples/python/digits.py | 2 +-
samples/python/mosse.py | 2 +-
.../hough_line_transform/hough_line_transform.py | 22 +
.../probabilistic_hough_line_transform.py | 12 +
.../imgProc/match_template/match_template.py | 96 +
.../tutorial_code/ml/py_svm_opencv/hogsvm.py | 71 +
samples/tapi/hog.cpp | 10 -
samples/tapi/tvl1_optical_flow.cpp | 2 +-
1415 files changed, 179625 insertions(+), 120676 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cc45f6f..af5e2c1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,12 +6,19 @@
#
# ----------------------------------------------------------------------------
+# Disable in-source builds to prevent source tree corruption.
+if(" ${CMAKE_SOURCE_DIR}" STREQUAL " ${CMAKE_BINARY_DIR}")
+ message(FATAL_ERROR "
+FATAL: In-source builds are not allowed.
+ You should create separate directory for build files.
+")
+endif()
include(cmake/OpenCVMinDepVersions.cmake)
if(CMAKE_GENERATOR MATCHES Xcode AND XCODE_VERSION VERSION_GREATER 4.3)
- cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)
+ cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
elseif(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore)
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
#Required to resolve linker error issues due to incompatibility with CMake v3.0+ policies.
@@ -25,19 +32,21 @@ endif()
# Following block can broke build in case of cross-compilng
# but CMAKE_CROSSCOMPILING variable will be set only on project(OpenCV) command
# so we will try to detect crosscompiling by presense of CMAKE_TOOLCHAIN_FILE
-if(NOT CMAKE_TOOLCHAIN_FILE)
- # it _must_ go before project(OpenCV) in order to work
- if(WIN32)
+if(NOT DEFINED CMAKE_INSTALL_PREFIX)
+ if(NOT CMAKE_TOOLCHAIN_FILE)
+ # it _must_ go before project(OpenCV) in order to work
+ if(WIN32)
+ set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation Directory")
+ else()
+ set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation Directory")
+ endif()
+ else(NOT CMAKE_TOOLCHAIN_FILE)
+ #Android: set output folder to ${CMAKE_BINARY_DIR}
+ set( LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_BINARY_DIR} CACHE PATH "root for library output, set this to change where android libs are compiled to" )
+ # any crosscompiling
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation Directory")
- else()
- set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation Directory")
- endif()
-else(NOT CMAKE_TOOLCHAIN_FILE)
- #Android: set output folder to ${CMAKE_BINARY_DIR}
- set( LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_BINARY_DIR} CACHE PATH "root for library output, set this to change where android libs are compiled to" )
- # any crosscompiling
- set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation Directory")
-endif(NOT CMAKE_TOOLCHAIN_FILE)
+ endif(NOT CMAKE_TOOLCHAIN_FILE)
+endif()
if(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore)
set(WINRT TRUE)
@@ -76,6 +85,10 @@ if(POLICY CMP0022)
cmake_policy(SET CMP0022 OLD)
endif()
+if(POLICY CMP0023)
+ cmake_policy(SET CMP0023 NEW)
+endif()
+
if(POLICY CMP0026)
# silence cmake 3.0+ warnings about reading LOCATION attribute
cmake_policy(SET CMP0026 OLD)
@@ -85,6 +98,22 @@ if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif()
+if(POLICY CMP0046)
+ cmake_policy(SET CMP0046 OLD)
+endif()
+
+if(POLICY CMP0051)
+ cmake_policy(SET CMP0051 NEW)
+endif()
+
+if(POLICY CMP0056)
+ cmake_policy(SET CMP0056 NEW)
+endif()
+
+if(POLICY CMP0067)
+ cmake_policy(SET CMP0067 NEW)
+endif()
+
include(cmake/OpenCVUtils.cmake)
# must go before the project command
@@ -105,6 +134,8 @@ ocv_cmake_eval(DEBUG_PRE ONCE)
ocv_clear_vars(OpenCVModules_TARGETS)
+include(cmake/OpenCVDownload.cmake)
+
# ----------------------------------------------------------------------------
# Break in case of popular CMake configuration mistakes
# ----------------------------------------------------------------------------
@@ -116,6 +147,7 @@ endif()
# ----------------------------------------------------------------------------
# Detect compiler and target platform architecture
# ----------------------------------------------------------------------------
+OCV_OPTION(ENABLE_CXX11 "Enable C++11 compilation mode" "${OPENCV_CXX11}")
include(cmake/OpenCVDetectCXXCompiler.cmake)
# Add these standard paths to the search paths for FIND_LIBRARY
@@ -172,6 +204,7 @@ OCV_OPTION(WITH_1394 "Include IEEE1394 support" ON
OCV_OPTION(WITH_AVFOUNDATION "Use AVFoundation for Video I/O (iOS/Mac)" ON IF APPLE)
OCV_OPTION(WITH_CARBON "Use Carbon for UI instead of Cocoa" OFF IF APPLE )
OCV_OPTION(WITH_CAROTENE "Use NVidia carotene acceleration library for ARM platform" ON IF (ARM OR AARCH64) AND NOT IOS AND NOT (CMAKE_VERSION VERSION_LESS "2.8.11"))
+OCV_OPTION(WITH_CPUFEATURES "Use cpufeatures Android library" ON IF ANDROID)
OCV_OPTION(WITH_VTK "Include VTK library support (and build opencv_viz module eiher)" ON IF (NOT ANDROID AND NOT IOS AND NOT WINRT AND NOT CMAKE_CROSSCOMPILING) )
OCV_OPTION(WITH_CUDA "Include NVidia Cuda Runtime support" ON IF (NOT IOS AND NOT WINRT) )
OCV_OPTION(WITH_CUFFT "Include NVidia Cuda Fast Fourier Transform (FFT) library support" ON IF (NOT IOS AND NOT WINRT) )
@@ -185,9 +218,10 @@ OCV_OPTION(WITH_GSTREAMER_0_10 "Enable Gstreamer 0.10 support (instead of 1.x)"
OCV_OPTION(WITH_GTK "Include GTK support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID) )
OCV_OPTION(WITH_GTK_2_X "Use GTK version 2" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID) )
OCV_OPTION(WITH_IPP "Include Intel IPP support" NOT MINGW IF (X86_64 OR X86) AND NOT WINRT )
+OCV_OPTION(WITH_HALIDE "Include Halide support" OFF)
OCV_OPTION(WITH_JASPER "Include JPEG2K support" ON IF (NOT IOS) )
OCV_OPTION(WITH_JPEG "Include JPEG support" ON)
-OCV_OPTION(WITH_WEBP "Include WebP support" ON IF (NOT IOS AND NOT WINRT) )
+OCV_OPTION(WITH_WEBP "Include WebP support" ON IF (NOT WINRT) )
OCV_OPTION(WITH_OPENEXR "Include ILM support via OpenEXR" ON IF (NOT IOS AND NOT WINRT) )
OCV_OPTION(WITH_OPENGL "Include OpenGL support" OFF IF (NOT ANDROID AND NOT WINRT) )
OCV_OPTION(WITH_OPENVX "Include OpenVX support" OFF)
@@ -225,9 +259,11 @@ OCV_OPTION(WITH_IPP_A "Include Intel IPP_A support" OFF
OCV_OPTION(WITH_MATLAB "Include Matlab support" ON IF (NOT ANDROID AND NOT IOS AND NOT WINRT))
OCV_OPTION(WITH_VA "Include VA support" OFF IF (UNIX AND NOT ANDROID) )
OCV_OPTION(WITH_VA_INTEL "Include Intel VA-API/OpenCL support" OFF IF (UNIX AND NOT ANDROID) )
+OCV_OPTION(WITH_MFX "Include Intel Media SDK support" OFF IF (UNIX AND NOT ANDROID) )
OCV_OPTION(WITH_GDAL "Include GDAL Support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
OCV_OPTION(WITH_GPHOTO2 "Include gPhoto2 library support" ON IF (UNIX AND NOT ANDROID) )
OCV_OPTION(WITH_LAPACK "Include Lapack library support" ON IF (NOT ANDROID AND NOT IOS) )
+OCV_OPTION(WITH_ITT "Include Intel ITT support" ON IF (NOT APPLE_FRAMEWORK) )
# OpenCV build components
# ===================================================
@@ -254,6 +290,8 @@ OCV_OPTION(BUILD_JPEG "Build libjpeg from source" WIN32 O
OCV_OPTION(BUILD_PNG "Build libpng from source" WIN32 OR ANDROID OR APPLE )
OCV_OPTION(BUILD_OPENEXR "Build openexr from source" (WIN32 OR ANDROID OR APPLE) AND NOT WINRT)
OCV_OPTION(BUILD_TBB "Download and build TBB from source" ANDROID )
+OCV_OPTION(BUILD_IPP_IW "Build IPP IW from source" NOT MINGW IF (X86_64 OR X86) AND NOT WINRT )
+OCV_OPTION(BUILD_ITT "Build Intel ITT from source" NOT MINGW IF (X86_64 OR X86) AND NOT WINRT AND NOT APPLE_FRAMEWORK )
# OpenCV installation options
# ===================================================
@@ -274,26 +312,19 @@ OCV_OPTION(ENABLE_COVERAGE "Enable coverage collection with GCov"
OCV_OPTION(ENABLE_OMIT_FRAME_POINTER "Enable -fomit-frame-pointer for GCC" ON IF CMAKE_COMPILER_IS_GNUCXX AND NOT (APPLE AND CMAKE_COMPILER_IS_CLANGCXX) )
OCV_OPTION(ENABLE_POWERPC "Enable PowerPC for GCC" ON IF (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_PROCESSOR MATCHES powerpc.*) )
OCV_OPTION(ENABLE_FAST_MATH "Enable -ffast-math (not recommended for GCC 4.6.x)" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
-OCV_OPTION(ENABLE_SSE "Enable SSE instructions" ON IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
-OCV_OPTION(ENABLE_SSE2 "Enable SSE2 instructions" ON IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
-OCV_OPTION(ENABLE_SSE3 "Enable SSE3 instructions" ON IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX OR CV_ICC) AND (X86 OR X86_64)) )
-OCV_OPTION(ENABLE_SSSE3 "Enable SSSE3 instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
-OCV_OPTION(ENABLE_SSE41 "Enable SSE4.1 instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX OR CV_ICC) AND (X86 OR X86_64)) )
-OCV_OPTION(ENABLE_SSE42 "Enable SSE4.2 instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
-OCV_OPTION(ENABLE_POPCNT "Enable POPCNT instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
-OCV_OPTION(ENABLE_AVX "Enable AVX instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
-OCV_OPTION(ENABLE_AVX2 "Enable AVX2 instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
-OCV_OPTION(ENABLE_FMA3 "Enable FMA3 instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
-OCV_OPTION(ENABLE_NEON "Enable NEON instructions" "${NEON}" IF CMAKE_COMPILER_IS_GNUCXX AND (ARM OR AARCH64 OR IOS) )
+OCV_OPTION(ENABLE_NEON "Enable NEON instructions" (NEON OR ANDROID_ARM_NEON OR AARCH64) IF CMAKE_COMPILER_IS_GNUCXX AND (ARM OR AARCH64 OR IOS) )
OCV_OPTION(ENABLE_VFPV3 "Enable VFPv3-D32 instructions" OFF IF CMAKE_COMPILER_IS_GNUCXX AND (ARM OR AARCH64 OR IOS) )
OCV_OPTION(ENABLE_NOISY_WARNINGS "Show all warnings even if they are too noisy" OFF )
OCV_OPTION(OPENCV_WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF )
OCV_OPTION(ANDROID_EXAMPLES_WITH_LIBS "Build binaries of Android examples with native libraries" OFF IF ANDROID )
OCV_OPTION(ENABLE_IMPL_COLLECTION "Collect implementation data on function call" OFF )
OCV_OPTION(ENABLE_INSTRUMENTATION "Instrument functions to collect calls trace and performance" OFF )
+OCV_OPTION(ENABLE_GNU_STL_DEBUG "Enable GNU STL Debug mode (defines _GLIBCXX_DEBUG)" OFF IF ((NOT CMAKE_VERSION VERSION_LESS "2.8.11") AND CMAKE_COMPILER_IS_GNUCXX) )
+OCV_OPTION(ENABLE_BUILD_HARDENING "Enable hardening of the resulting binaries (against security attacks, detects memory corruption, etc)" OFF)
OCV_OPTION(GENERATE_ABI_DESCRIPTOR "Generate XML file for abi_compliance_checker tool" OFF IF UNIX)
-
-OCV_OPTION(DOWNLOAD_EXTERNAL_TEST_DATA "Download external test data (Python executable and OPENCV_TEST_DATA_PATH environment variable may be required)" OFF )
+OCV_OPTION(CV_ENABLE_INTRINSICS "Use intrinsic-based optimized code" ON )
+OCV_OPTION(CV_DISABLE_OPTIMIZATION "Disable explicit optimized code (dispatched code/intrinsics/loop unrolling/etc)" OFF )
+OCV_OPTION(CV_TRACE "Enable OpenCV code trace" ON)
if(ENABLE_IMPL_COLLECTION)
@@ -492,6 +523,9 @@ if(CMAKE_GENERATOR MATCHES "Makefiles|Ninja" AND "${CMAKE_BUILD_TYPE}" STREQUAL
set(CMAKE_BUILD_TYPE Release)
endif()
+# --- Python Support ---
+include(cmake/OpenCVDetectPython.cmake)
+
include(cmake/OpenCVCompilerOptions.cmake)
@@ -512,9 +546,12 @@ endif(WIN32 AND NOT MINGW)
# CHECK FOR SYSTEM LIBRARIES, OPTIONS, ETC..
# ----------------------------------------------------------------------------
if(UNIX)
- find_package(PkgConfig QUIET)
+ if(NOT APPLE_FRAMEWORK)
+ find_package(PkgConfig QUIET)
+ endif()
include(CheckFunctionExists)
include(CheckIncludeFile)
+ include(CheckSymbolExists)
if(NOT APPLE)
CHECK_INCLUDE_FILE(pthread.h HAVE_LIBPTHREAD)
@@ -530,6 +567,12 @@ if(UNIX)
else()
set(HAVE_LIBPTHREAD YES)
endif()
+
+ CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
+ CHECK_INCLUDE_FILE(malloc.h HAVE_MALLOC_H)
+ if(HAVE_MALLOC_H)
+ CHECK_SYMBOL_EXISTS(memalign malloc.h HAVE_MEMALIGN)
+ endif()
endif()
include(cmake/OpenCVPCHSupport.cmake)
@@ -552,6 +595,11 @@ endif()
# Detect 3rd-party libraries
# ----------------------------------------------------------------------------
+if(ANDROID AND WITH_CPUFEATURES)
+ add_subdirectory(3rdparty/cpufeatures)
+ set(HAVE_CPUFEATURES 1)
+endif()
+
include(cmake/OpenCVFindLibsGrfmt.cmake)
include(cmake/OpenCVFindLibsGUI.cmake)
include(cmake/OpenCVFindLibsVideo.cmake)
@@ -569,9 +617,6 @@ else()
unset(DOXYGEN_FOUND CACHE)
endif()
-# --- Python Support ---
-include(cmake/OpenCVDetectPython.cmake)
-
# --- Java Support ---
include(cmake/OpenCVDetectApacheAnt.cmake)
if(ANDROID)
@@ -595,6 +640,11 @@ if(WITH_OPENCL)
include(cmake/OpenCVDetectOpenCL.cmake)
endif()
+# --- Halide ---
+if(WITH_HALIDE)
+ include(cmake/OpenCVDetectHalide.cmake)
+endif()
+
# --- DirectX ---
if(WITH_DIRECTX)
include(cmake/OpenCVDetectDirectX.cmake)
@@ -683,9 +733,23 @@ if(HAVE_CUDA)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDA_cufft_LIBRARY})
endif()
foreach(p ${CUDA_LIBS_PATH})
- set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CMAKE_LIBRARY_PATH_FLAG}${p})
+ if(MSVC AND CMAKE_GENERATOR MATCHES "Ninja|JOM")
+ set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CMAKE_LIBRARY_PATH_FLAG}"${p}")
+ else()
+ set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CMAKE_LIBRARY_PATH_FLAG}${p})
+ endif()
endforeach()
endif()
+
+
+# ----------------------------------------------------------------------------
+# Code trace support
+# ----------------------------------------------------------------------------
+if(CV_TRACE)
+ include(cmake/OpenCVDetectTrace.cmake)
+endif()
+
+
# ----------------------------------------------------------------------------
# Solution folders:
# ----------------------------------------------------------------------------
@@ -736,7 +800,9 @@ endif()
include(cmake/OpenCVGenHeaders.cmake)
# Generate opencv.pc for pkg-config command
-include(cmake/OpenCVGenPkgconfig.cmake)
+if(NOT OPENCV_SKIP_PKGCONFIG_GENERATION)
+ include(cmake/OpenCVGenPkgconfig.cmake)
+endif()
# Generate OpenCV.mk for ndk-build (Android build tool)
include(cmake/OpenCVGenAndroidMK.cmake)
@@ -860,6 +926,33 @@ if(NOT CMAKE_GENERATOR MATCHES "Xcode|Visual Studio")
status(" Configuration:" ${CMAKE_BUILD_TYPE})
endif()
+
+# ========================= CPU code generation mode =========================
+status("")
+status(" CPU/HW features:")
+status(" Baseline:" "${CPU_BASELINE_FINAL}")
+if(NOT CPU_BASELINE STREQUAL CPU_BASELINE_FINAL)
+ status(" requested:" "${CPU_BASELINE}")
+endif()
+if(CPU_BASELINE_REQUIRE)
+ status(" required:" "${CPU_BASELINE_REQUIRE}")
+endif()
+if(CPU_BASELINE_DISABLE)
+ status(" disabled:" "${CPU_BASELINE_DISABLE}")
+endif()
+if(CPU_DISPATCH_FINAL OR CPU_DISPATCH)
+ status(" Dispatched code generation:" "${CPU_DISPATCH_FINAL}")
+ if(NOT CPU_DISPATCH STREQUAL CPU_DISPATCH_FINAL)
+ status(" requested:" "${CPU_DISPATCH}")
+ endif()
+ if(CPU_DISPATCH_REQUIRE)
+ status(" required:" "${CPU_DISPATCH_REQUIRE}")
+ endif()
+ foreach(OPT ${CPU_DISPATCH_FINAL})
+ status(" ${OPT} (${CPU_${OPT}_USAGE_COUNT} files):" "+ ${CPU_DISPATCH_${OPT}_INCLUDED}")
+ endforeach()
+endif()
+
# ========================== C/C++ options ==========================
if(CMAKE_CXX_COMPILER_VERSION)
set(OPENCV_COMPILER_STR "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} (ver ${CMAKE_CXX_COMPILER_VERSION})")
@@ -875,6 +968,9 @@ string(STRIP "${OPENCV_COMPILER_STR}" OPENCV_COMPILER_STR)
status("")
status(" C/C++:")
status(" Built as dynamic libs?:" BUILD_SHARED_LIBS THEN YES ELSE NO)
+if(ENABLE_CXX11 OR HAVE_CXX11)
+status(" C++11:" HAVE_CXX11 THEN YES ELSE NO)
+endif()
status(" C++ Compiler:" ${OPENCV_COMPILER_STR})
status(" C++ flags (Release):" ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE})
status(" C++ flags (Debug):" ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG})
@@ -1071,7 +1167,7 @@ endif(DEFINED WITH_1394)
if(DEFINED WITH_FFMPEG OR HAVE_FFMPEG)
if(WIN32)
- status(" FFMPEG:" WITH_FFMPEG THEN "YES (prebuilt binaries)" ELSE NO)
+ status(" FFMPEG:" HAVE_FFMPEG THEN "YES (prebuilt binaries)" ELSE NO)
else()
status(" FFMPEG:" HAVE_FFMPEG THEN YES ELSE NO)
endif()
@@ -1170,6 +1266,10 @@ if(DEFINED WITH_INTELPERC)
status(" Intel PerC:" HAVE_INTELPERC THEN "YES" ELSE NO)
endif(DEFINED WITH_INTELPERC)
+if(DEFINED WITH_MFX)
+ status(" Intel Media SDK:" HAVE_MFX THEN "YES (${MFX_LIBRARY})" ELSE NO)
+endif()
+
if(DEFINED WITH_GPHOTO2)
status(" gPhoto2:" HAVE_GPHOTO2 THEN "YES" ELSE NO)
endif(DEFINED WITH_GPHOTO2)
@@ -1195,23 +1295,41 @@ endif()
status("")
status(" Parallel framework:" TRUE THEN "${CV_PARALLEL_FRAMEWORK}" ELSE NO)
+if(CV_TRACE OR OPENCV_TRACE)
+ set(__msg "")
+ if(HAVE_ITT)
+ set(__msg "with Intel ITT")
+ endif()
+ status("")
+ status(" Trace: " OPENCV_TRACE THEN "YES (${__msg})" ELSE NO)
+endif()
# ========================== Other third-party libraries ==========================
status("")
status(" Other third-party libraries:")
if(WITH_IPP AND HAVE_IPP)
- status(" Use IPP:" "${IPP_VERSION_STR} [${IPP_VERSION_MAJOR}.${IPP_VERSION_MINOR}.${IPP_VERSION_BUILD}]")
- status(" at:" "${IPP_ROOT_DIR}")
+ status(" Use Intel IPP:" "${IPP_VERSION_STR} [${IPP_VERSION_MAJOR}.${IPP_VERSION_MINOR}.${IPP_VERSION_BUILD}]")
+ status(" at:" "${IPP_ROOT_DIR}")
if(NOT HAVE_IPP_ICV_ONLY)
- status(" linked:" BUILD_WITH_DYNAMIC_IPP THEN "dynamic" ELSE "static")
+ status(" linked:" BUILD_WITH_DYNAMIC_IPP THEN "dynamic" ELSE "static")
+ endif()
+ if(HAVE_IPP_IW)
+ if(BUILD_IPP_IW)
+ status(" Use Intel IPP IW:" "build (${IW_VERSION_MAJOR}.${IW_VERSION_MINOR}.${IW_VERSION_UPDATE})")
+ else()
+ status(" Use Intel IPP IW:" "prebuilt binaries (${IW_VERSION_MAJOR}.${IW_VERSION_MINOR}.${IW_VERSION_UPDATE})")
+ endif()
+ else()
+ status(" Use Intel IPP IW:" NO)
endif()
else()
- status(" Use IPP:" WITH_IPP AND NOT HAVE_IPP THEN "IPP not found or implicitly disabled" ELSE NO)
+ status(" Use Intel IPP:" WITH_IPP AND NOT HAVE_IPP THEN "IPP not found or implicitly disabled" ELSE NO)
+ status(" Use Intel IPP IW:" WITH_IPP AND NOT HAVE_IPP AND HAVE_IPP_IW THEN "IPP not found or implicitly disabled" ELSE NO)
endif()
if(DEFINED WITH_IPP_A)
-status(" Use IPP Async:" HAVE_IPP_A THEN "YES" ELSE NO)
+status(" Use Intel IPP Async:" HAVE_IPP_A THEN "YES" ELSE NO)
endif(DEFINED WITH_IPP_A)
if(DEFINED WITH_VA)
@@ -1229,6 +1347,9 @@ endif(DEFINED WITH_LAPACK)
status(" Use Eigen:" HAVE_EIGEN THEN "YES (ver ${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION})" ELSE NO)
status(" Use Cuda:" HAVE_CUDA THEN "YES (ver ${CUDA_VERSION_STRING})" ELSE NO)
status(" Use OpenCL:" HAVE_OPENCL THEN YES ELSE NO)
+if(WITH_HALIDE OR HAVE_HALIDE)
+status(" Use Halide:" HAVE_HALIDE THEN "YES (${HALIDE_LIBRARIES} ${HALIDE_INCLUDE_DIRS})" ELSE NO)
+endif()
status(" Use OpenVX:" HAVE_OPENVX THEN "YES (${OPENVX_LIBRARIES})" ELSE "NO")
status(" Use custom HAL:" OpenCV_USED_HAL THEN "YES (${OpenCV_USED_HAL})" ELSE "NO")
@@ -1350,13 +1471,6 @@ status("")
ocv_finalize_status()
# ----------------------------------------------------------------------------
-# Warn in the case of in-source build
-# ----------------------------------------------------------------------------
-if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
- message(WARNING "The source directory is the same as binary directory. \"make clean\" may damage the source tree")
-endif()
-
-# ----------------------------------------------------------------------------
# CPack stuff
# ----------------------------------------------------------------------------
diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt
index f2cdc87..ed66375 100644
--- a/apps/CMakeLists.txt
+++ b/apps/CMakeLists.txt
@@ -1,4 +1,6 @@
add_definitions(-D__OPENCV_BUILD=1)
+add_definitions(-D__OPENCV_APPS=1)
+
link_libraries(${OPENCV_LINKER_LIBS})
add_subdirectory(traincascade)
diff --git a/apps/annotation/opencv_annotation.cpp b/apps/annotation/opencv_annotation.cpp
index febe9fc..5d1eede 100644
--- a/apps/annotation/opencv_annotation.cpp
+++ b/apps/annotation/opencv_annotation.cpp
@@ -59,12 +59,7 @@ Adapted by: Puttemans Steven - April 2016 - Vectorize the process to enable bett
#include <fstream>
#include <iostream>
-
-#if defined(_WIN32)
- #include <direct.h>
-#else
- #include <sys/stat.h>
-#endif
+#include <map>
using namespace std;
using namespace cv;
@@ -249,34 +244,20 @@ int main( int argc, const char** argv )
int resizeFactor = parser.get<int>("resizeFactor");
int const maxWindowHeight = parser.get<int>("maxWindowHeight") > 0 ? parser.get<int>("maxWindowHeight") : -1;
- // Check if the folder actually exists
- // If -1 is returned then the folder actually exists, and thus you can continue
- // In all other cases there was a folder creation and thus the folder did not exist
- #if defined(_WIN32)
- if(_mkdir(image_folder.c_str()) != -1){
- // Generate an error message
- cerr << "The image folder given does not exist. Please check again!" << endl;
- // Remove the created folder again, to ensure a second run with same code fails again
- _rmdir(image_folder.c_str());
- return 0;
- }
- #else
- if(mkdir(image_folder.c_str(), 0777) != -1){
- // Generate an error message
- cerr << "The image folder given does not exist. Please check again!" << endl;
- // Remove the created folder again, to ensure a second run with same code fails again
- remove(image_folder.c_str());
- return 0;
- }
- #endif
-
// Start by processing the data
// Return the image filenames inside the image folder
- vector< vector<Rect> > annotations;
+ map< String, vector<Rect> > annotations;
vector<String> filenames;
String folder(image_folder);
glob(folder, filenames);
+ // Add key tips on how to use the software when running it
+ cout << "* mark rectangles with the left mouse button," << endl;
+ cout << "* press 'c' to accept a selection," << endl;
+ cout << "* press 'd' to delete the latest selection," << endl;
+ cout << "* press 'n' to proceed with next image," << endl;
+ cout << "* press 'esc' to stop." << endl;
+
// Loop through each image stored in the images folder
// Create and temporarily store the annotations
// At the end write everything to the annotations file
@@ -306,7 +287,7 @@ int main( int argc, const char** argv )
current_annotations[j].height = current_annotations[j].height * resizeFactor;
}
}
- annotations.push_back(current_annotations);
+ annotations[filenames[i]] = current_annotations;
// Check if the ESC key was hit, then exit earlier then expected
if(stop){
@@ -323,10 +304,11 @@ int main( int argc, const char** argv )
}
// Store the annotations, write to the output file
- for(int i = 0; i < (int)annotations.size(); i++){
- output << filenames[i] << " " << annotations[i].size();
- for(int j=0; j < (int)annotations[i].size(); j++){
- Rect temp = annotations[i][j];
+ for(map<String, vector<Rect> >::iterator it = annotations.begin(); it != annotations.end(); it++){
+ vector<Rect> &anno = it->second;
+ output << it->first << " " << anno.size();
+ for(size_t j=0; j < anno.size(); j++){
+ Rect temp = anno[j];
output << " " << temp.x << " " << temp.y << " " << temp.width << " " << temp.height;
}
output << endl;
diff --git a/apps/interactive-calibration/CMakeLists.txt b/apps/interactive-calibration/CMakeLists.txt
index 735c453..41abf7c 100644
--- a/apps/interactive-calibration/CMakeLists.txt
+++ b/apps/interactive-calibration/CMakeLists.txt
@@ -1,4 +1,7 @@
-set(OPENCV_INTERACTIVECALIBRATION_DEPS opencv_core opencv_imgproc opencv_features2d opencv_aruco opencv_highgui opencv_calib3d opencv_videoio)
+set(OPENCV_INTERACTIVECALIBRATION_DEPS opencv_core opencv_imgproc opencv_features2d opencv_highgui opencv_calib3d opencv_videoio)
+if(${BUILD_opencv_aruco})
+ list(APPEND OPENCV_INTERACTIVECALIBRATION_DEPS opencv_aruco)
+endif()
ocv_check_dependencies(${OPENCV_INTERACTIVECALIBRATION_DEPS})
if(NOT OCV_DEPENDENCIES_FOUND)
diff --git a/apps/interactive-calibration/frameProcessor.cpp b/apps/interactive-calibration/frameProcessor.cpp
index 1e672b0..07b32db 100644
--- a/apps/interactive-calibration/frameProcessor.cpp
+++ b/apps/interactive-calibration/frameProcessor.cpp
@@ -7,7 +7,6 @@
#include <opencv2/calib3d.hpp>
#include <opencv2/imgproc.hpp>
-#include <opencv2/aruco/charuco.hpp>
#include <opencv2/highgui.hpp>
#include <vector>
@@ -75,6 +74,7 @@ bool CalibProcessor::detectAndParseChessboard(const cv::Mat &frame)
bool CalibProcessor::detectAndParseChAruco(const cv::Mat &frame)
{
+#ifdef HAVE_OPENCV_ARUCO
cv::Ptr<cv::aruco::Board> board = mCharucoBoard.staticCast<cv::aruco::Board>();
std::vector<std::vector<cv::Point2f> > corners, rejected;
@@ -95,14 +95,16 @@ bool CalibProcessor::detectAndParseChAruco(const cv::Mat &frame)
}
centerX /= currentCharucoCorners.size[0];
centerY /= currentCharucoCorners.size[0];
- //cv::circle(frame, cv::Point2f(centerX, centerY), 10, cv::Scalar(0, 255, 0), 10);
+
mTemplateLocations.insert(mTemplateLocations.begin(), cv::Point2f(centerX, centerY));
cv::aruco::drawDetectedCornersCharuco(frame, currentCharucoCorners, currentCharucoIds);
mCurrentCharucoCorners = currentCharucoCorners;
mCurrentCharucoIds = currentCharucoIds;
return true;
}
-
+#else
+ (void)frame;
+#endif
return false;
}
@@ -231,6 +233,7 @@ bool CalibProcessor::checkLastFrame()
}
}
else {
+#ifdef HAVE_OPENCV_ARUCO
cv::Mat r, t, angles;
std::vector<cv::Point3f> allObjPoints;
allObjPoints.reserve(mCurrentCharucoIds.total());
@@ -248,6 +251,7 @@ bool CalibProcessor::checkLastFrame()
mCalibData->allCharucoCorners.pop_back();
mCalibData->allCharucoIds.pop_back();
}
+#endif
}
return isFrameBad;
}
@@ -266,10 +270,12 @@ CalibProcessor::CalibProcessor(cv::Ptr<calibrationData> data, captureParameters
switch(mBoardType)
{
case chAruco:
+#ifdef HAVE_OPENCV_ARUCO
mArucoDictionary = cv::aruco::getPredefinedDictionary(
cv::aruco::PREDEFINED_DICTIONARY_NAME(capParams.charucoDictName));
mCharucoBoard = cv::aruco::CharucoBoard::create(mBoardSize.width, mBoardSize.height, capParams.charucoSquareLenght,
capParams.charucoMarkerSize, mArucoDictionary);
+#endif
break;
case AcirclesGrid:
mBlobDetectorPtr = cv::SimpleBlobDetector::create();
diff --git a/apps/interactive-calibration/frameProcessor.hpp b/apps/interactive-calibration/frameProcessor.hpp
index 4dbb8ab..222b831 100644
--- a/apps/interactive-calibration/frameProcessor.hpp
+++ b/apps/interactive-calibration/frameProcessor.hpp
@@ -6,8 +6,10 @@
#define FRAME_PROCESSOR_HPP
#include <opencv2/core.hpp>
-#include <opencv2/aruco/charuco.hpp>
#include <opencv2/calib3d.hpp>
+#ifdef HAVE_OPENCV_ARUCO
+#include <opencv2/aruco/charuco.hpp>
+#endif
#include "calibCommon.hpp"
#include "calibController.hpp"
@@ -37,8 +39,10 @@ protected:
cv::Mat mCurrentCharucoIds;
cv::Ptr<cv::SimpleBlobDetector> mBlobDetectorPtr;
+#ifdef HAVE_OPENCV_ARUCO
cv::Ptr<cv::aruco::Dictionary> mArucoDictionary;
cv::Ptr<cv::aruco::CharucoBoard> mCharucoBoard;
+#endif
int mNeededFramesNum;
unsigned mDelayBetweenCaptures;
diff --git a/apps/interactive-calibration/main.cpp b/apps/interactive-calibration/main.cpp
index af62d4e..10d3690 100644
--- a/apps/interactive-calibration/main.cpp
+++ b/apps/interactive-calibration/main.cpp
@@ -4,10 +4,13 @@
#include <opencv2/core.hpp>
#include <opencv2/calib3d.hpp>
-#include <opencv2/aruco/charuco.hpp>
#include <opencv2/cvconfig.h>
#include <opencv2/highgui.hpp>
+#ifdef HAVE_OPENCV_ARUCO
+#include <opencv2/aruco/charuco.hpp>
+#endif
+
#include <string>
#include <vector>
#include <stdexcept>
@@ -50,31 +53,27 @@ bool calib::showOverlayMessage(const std::string& message)
#endif
}
-static void deleteButton(int state, void* data)
+static void deleteButton(int, void* data)
{
- state++; //to avoid gcc warnings
(static_cast<cv::Ptr<calibDataController>*>(data))->get()->deleteLastFrame();
calib::showOverlayMessage("Last frame deleted");
}
-static void deleteAllButton(int state, void* data)
+static void deleteAllButton(int, void* data)
{
- state++;
(static_cast<cv::Ptr<calibDataController>*>(data))->get()->deleteAllData();
calib::showOverlayMessage("All frames deleted");
}
-static void saveCurrentParamsButton(int state, void* data)
+static void saveCurrentParamsButton(int, void* data)
{
- state++;
if((static_cast<cv::Ptr<calibDataController>*>(data))->get()->saveCurrentCameraParameters())
calib::showOverlayMessage("Calibration parameters saved");
}
#ifdef HAVE_QT
-static void switchVisualizationModeButton(int state, void* data)
+static void switchVisualizationModeButton(int, void* data)
{
- state++;
ShowProcessor* processor = static_cast<ShowProcessor*>(((cv::Ptr<FrameProcessor>*)data)->get());
processor->switchVisualizationMode();
}
@@ -103,6 +102,11 @@ int main(int argc, char** argv)
captureParameters capParams = paramsController.getCaptureParameters();
internalParameters intParams = paramsController.getInternalParameters();
+#ifndef HAVE_OPENCV_ARUCO
+ if(capParams.board == chAruco)
+ CV_Error(cv::Error::StsNotImplemented, "Aruco module is disabled in current build configuration."
+ " Consider usage of another calibration pattern\n");
+#endif
cv::TermCriteria solverTermCrit = cv::TermCriteria(cv::TermCriteria::COUNT+cv::TermCriteria::EPS,
intParams.solverMaxIters, intParams.solverEps);
@@ -172,6 +176,7 @@ int main(int argc, char** argv)
calibrationFlags, solverTermCrit);
}
else {
+#ifdef HAVE_OPENCV_ARUCO
cv::Ptr<cv::aruco::Dictionary> dictionary =
cv::aruco::getPredefinedDictionary(cv::aruco::PREDEFINED_DICTIONARY_NAME(capParams.charucoDictName));
cv::Ptr<cv::aruco::CharucoBoard> charucoboard =
@@ -183,6 +188,7 @@ int main(int argc, char** argv)
globalData->cameraMatrix, globalData->distCoeffs,
cv::noArray(), cv::noArray(), globalData->stdDeviations, cv::noArray(),
globalData->perViewErrors, calibrationFlags, solverTermCrit);
+#endif
}
dataController->updateUndistortMap();
dataController->printParametersToConsole(std::cout);
diff --git a/apps/traincascade/cascadeclassifier.cpp b/apps/traincascade/cascadeclassifier.cpp
index ebfb43e..fabbda9 100644
--- a/apps/traincascade/cascadeclassifier.cpp
+++ b/apps/traincascade/cascadeclassifier.cpp
@@ -139,7 +139,7 @@ bool CvCascadeClassifier::train( const string _cascadeDirName,
double acceptanceRatioBreakValue )
{
// Start recording clock ticks for training time output
- const clock_t begin_time = clock();
+ double time = (double)getTickCount();
if( _cascadeDirName.empty() || _posFilename.empty() || _negFilename.empty() )
CV_Error( CV_StsBadArg, "_cascadeDirName or _bgfileName or _vecFileName is NULL" );
@@ -267,7 +267,7 @@ bool CvCascadeClassifier::train( const string _cascadeDirName,
fs << "}";
// Output training time up till now
- float seconds = float( clock () - begin_time ) / CLOCKS_PER_SEC;
+ double seconds = ( (double)getTickCount() - time)/ getTickFrequency();
int days = int(seconds) / 60 / 60 / 24;
int hours = (int(seconds) / 60 / 60) % 24;
int minutes = (int(seconds) / 60) % 60;
diff --git a/apps/version/opencv_version.cpp b/apps/version/opencv_version.cpp
index 78f2810..9ad4bac 100644
--- a/apps/version/opencv_version.cpp
+++ b/apps/version/opencv_version.cpp
@@ -5,9 +5,15 @@
#include <iostream>
#include <opencv2/core.hpp>
+#include <opencv2/core/utils/trace.hpp>
int main(int argc, const char** argv)
{
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG(argc);
+ CV_TRACE_ARG_VALUE(argv0, "argv0", argv[0]);
+ CV_TRACE_ARG_VALUE(argv1, "argv1", argv[1]);
+
cv::CommandLineParser parser(argc, argv,
"{ help h usage ? | | show this help message }"
"{ verbose v | | show build configuration log }"
diff --git a/cmake/FindCUDA/run_nvcc.cmake b/cmake/FindCUDA/run_nvcc.cmake
index abdd307..8d1ceb1 100644
--- a/cmake/FindCUDA/run_nvcc.cmake
+++ b/cmake/FindCUDA/run_nvcc.cmake
@@ -72,7 +72,7 @@ set(generated_cubin_file_internal "@generated_cubin_file@") # path
set(CUDA_NVCC_EXECUTABLE "@CUDA_NVCC_EXECUTABLE@") # path
set(CUDA_NVCC_FLAGS @CUDA_NVCC_FLAGS@ ;; @CUDA_WRAP_OPTION_NVCC_FLAGS@) # list
@CUDA_NVCC_FLAGS_CONFIG@
-set(nvcc_flags @nvcc_flags@) # list
+set(nvcc_flags "@nvcc_flags@") # list
set(CUDA_NVCC_INCLUDE_ARGS "@CUDA_NVCC_INCLUDE_ARGS@") # list (needs to be in quotes to handle spaces properly).
set(format_flag "@format_flag@") # string
diff --git a/cmake/FindOpenVX.cmake b/cmake/FindOpenVX.cmake
index 0a55e95..6cba527 100644
--- a/cmake/FindOpenVX.cmake
+++ b/cmake/FindOpenVX.cmake
@@ -25,6 +25,20 @@ endif()
if(OPENVX_INCLUDE_DIR AND OPENVX_LIBRARIES)
set(HAVE_OPENVX TRUE)
+
+ try_compile(OPENVX_RENAMED_REF
+ "${OpenCV_BINARY_DIR}"
+ "${OpenCV_SOURCE_DIR}/cmake/checks/openvx_refenum_test.cpp"
+ CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${OPENVX_INCLUDE_DIR}"
+ LINK_LIBRARIES ${OPENVX_LIBRARIES}
+ OUTPUT_VARIABLE OUTPUT
+ )
+ if(OPENVX_RENAMED_REF)
+ add_definitions(-DIVX_RENAMED_REFS=1)
+ message(STATUS "OpenVX: Checking reference attribute name convention... New")
+ else()
+ message(STATUS "OpenVX: Checking reference attribute name convention... Old")
+ endif()
endif()
if(NOT HAVE_OPENVX)
diff --git a/cmake/OpenCVCRTLinkage.cmake b/cmake/OpenCVCRTLinkage.cmake
index f5509d8..2b6f95c 100644
--- a/cmake/OpenCVCRTLinkage.cmake
+++ b/cmake/OpenCVCRTLinkage.cmake
@@ -38,6 +38,9 @@ if(MSVC AND WINRT)
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /INCREMENTAL:NO /OPT:NOREF /OPT:NOICF")
endif()
+# Ignore warning: This object file does not define any previously undefined public symbols, ...
+set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /IGNORE:4221")
+
if(NOT BUILD_SHARED_LIBS AND BUILD_WITH_STATIC_CRT)
foreach(flag_var
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
@@ -52,9 +55,9 @@ if(NOT BUILD_SHARED_LIBS AND BUILD_WITH_STATIC_CRT)
endif()
endforeach(flag_var)
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcrtd.lib")
- set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib")
- set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libcmtd.lib")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:atlthunk.lib")
+ set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcpmt.lib /NODEFAULTLIB:msvcrt.lib")
+ set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:libcpmtd.lib /NODEFAULTLIB:msvcrtd.lib")
else()
foreach(flag_var
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
diff --git a/cmake/OpenCVCompilerDefenses.cmake b/cmake/OpenCVCompilerDefenses.cmake
new file mode 100644
index 0000000..7d1ba0b
--- /dev/null
+++ b/cmake/OpenCVCompilerDefenses.cmake
@@ -0,0 +1,87 @@
+# Enable build defense flags.
+# Performance may be affected.
+# More information:
+# - https://www.owasp.org/index.php/C-Based_Toolchain_Hardening
+# - https://wiki.debian.org/Hardening
+# - https://wiki.gentoo.org/wiki/Hardened/Toolchain
+# - https://docs.microsoft.com/en-us/cpp/build/reference/sdl-enable-additional-security-checks
+
+
+set(OPENCV_LINKER_DEFENSES_FLAGS_COMMON "")
+
+macro(ocv_add_defense_compiler_flag option)
+ ocv_check_flag_support(CXX "${option}" _varname "${ARGN}")
+ if(${_varname})
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${option}")
+ endif()
+
+ ocv_check_flag_support(C "${option}" _varname "${ARGN}")
+ if(${_varname})
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${option}")
+ endif()
+endmacro()
+
+macro(ocv_add_defense_compiler_flag_release option)
+ ocv_check_flag_support(CXX "${option}" _varname "${ARGN}")
+ if(${_varname})
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${option}")
+ endif()
+
+ ocv_check_flag_support(C "${option}" _varname "${ARGN}")
+ if(${_varname})
+ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${option}")
+ endif()
+endmacro()
+
+# Define flags
+
+if(MSVC)
+ ocv_add_defense_compiler_flag("/GS")
+ ocv_add_defense_compiler_flag("/DynamicBase")
+ ocv_add_defense_compiler_flag("/SafeSEH")
+ ocv_add_defense_compiler_flag("/sdl")
+elseif(CMAKE_COMPILER_IS_GNUCXX)
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9")
+ ocv_add_defense_compiler_flag("-fstack-protector")
+ else()
+ ocv_add_defense_compiler_flag("-fstack-protector-strong")
+ endif()
+
+ # These flags is added by general options: -Wformat -Wformat-security
+ if(NOT CMAKE_CXX_FLAGS MATCHES "-Wformat" OR NOT CMAKE_CXX_FLAGS MATCHES "format-security")
+ message(FATAL_ERROR "Defense flags: uncompatible options")
+ endif()
+
+ if(ANDROID)
+ ocv_add_defense_compiler_flag_release("-D_FORTIFY_SOURCE=2")
+ if(NOT CMAKE_CXX_FLAGS_RELEASE MATCHES "-D_FORTIFY_SOURCE=2") # TODO Check this
+ ocv_add_defense_compiler_flag_release("-D_FORTIFY_SOURCE=1")
+ endif()
+ else()
+ ocv_add_defense_compiler_flag_release("-D_FORTIFY_SOURCE=2")
+ endif()
+
+ set(OPENCV_LINKER_DEFENSES_FLAGS_COMMON "${OPENCV_LINKER_DEFENSES_FLAGS_COMMON} -z noexecstack -z relro -z now" )
+else()
+ # not supported
+endif()
+
+set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
+if(NOT CMAKE_CXX_FLAGS MATCHES "-fPIC")
+ ocv_add_defense_compiler_flag("-fPIC")
+endif()
+if(CMAKE_COMPILER_IS_GNUCXX)
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIE -pie")
+endif()
+
+set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OPENCV_LINKER_DEFENSES_FLAGS_COMMON}" )
+set( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${OPENCV_LINKER_DEFENSES_FLAGS_COMMON}" )
+set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OPENCV_LINKER_DEFENSES_FLAGS_COMMON}" )
+
+if(CMAKE_COMPILER_IS_GNUCXX)
+ foreach(flags
+ CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG
+ CMAKE_C_FLAGS CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_DEBUG)
+ string(REPLACE "-O3" "-O2" ${flags} "${${flags}}")
+ endforeach()
+endif()
diff --git a/cmake/OpenCVCompilerOptimizations.cmake b/cmake/OpenCVCompilerOptimizations.cmake
new file mode 100644
index 0000000..45a536b
--- /dev/null
+++ b/cmake/OpenCVCompilerOptimizations.cmake
@@ -0,0 +1,740 @@
+# x86/x86-64 arch:
+# SSE / SSE2 (always available on 64-bit CPUs)
+# SSE3 / SSSE3
+# SSE4_1 / SSE4_2 / POPCNT
+# AVX / AVX2 / AVX512
+# FMA3
+
+# CPU_{opt}_SUPPORTED=ON/OFF - compiler support (possibly with additional flag)
+# CPU_{opt}_IMPLIES=<list>
+# CPU_{opt}_FORCE=<list> - subset of "implies" list
+# CPU_{opt}_FLAGS_ON=""
+# CPU_{opt}_FEATURE_ALIAS - mapping to CV_CPU_* HWFeature enum
+
+# Input variables:
+# CPU_BASELINE=<list> - preferred list of baseline optimizations
+# CPU_DISPATCH=<list> - preferred list of dispatched optimizations
+
+# Advanced input variables:
+# CPU_BASELINE_REQUIRE=<list> - list of required baseline optimizations
+# CPU_DISPATCH_REQUIRE=<list> - list of required dispatched optimizations
+# CPU_BASELINE_DISABLE=<list> - list of disabled baseline optimizations
+
+# Output variables:
+# CPU_BASELINE_FINAL=<list> - final list of enabled compiler optimizations
+# CPU_DISPATCH_FINAL=<list> - final list of dispatched optimizations
+#
+# CPU_DISPATCH_FLAGS_${opt} - flags for source files compiled separately (_opt_avx2.cpp)
+
+set(CPU_ALL_OPTIMIZATIONS "SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3") # without AVX512
+list(APPEND CPU_ALL_OPTIMIZATIONS NEON VFPV3 FP16)
+list(REMOVE_DUPLICATES CPU_ALL_OPTIMIZATIONS)
+
+ocv_update(CPU_VFPV3_FEATURE_ALIAS "")
+
+
+set(HELP_CPU_BASELINE "Specify list of enabled baseline CPU optimizations")
+set(HELP_CPU_BASELINE_REQUIRE "Specify list of required baseline CPU optimizations")
+set(HELP_CPU_BASELINE_DISABLE "Specify list of forbidden baseline CPU optimizations")
+set(HELP_CPU_DISPATCH "Specify list of dispatched CPU optimizations")
+set(HELP_CPU_DISPATCH_REQUIRE "Specify list of required dispatched CPU optimizations")
+
+foreach(var CPU_BASELINE CPU_BASELINE_REQUIRE CPU_BASELINE_DISABLE CPU_DISPATCH CPU_DISPATCH_REQUIRE)
+ if(DEFINED ${var})
+ string(REPLACE "," ";" _list "${${var}}")
+ set(${var} "${_list}" CACHE STRING "${HELP_${var}}" FORCE)
+ endif()
+endforeach()
+
+# process legacy flags
+macro(ocv_optimization_process_obsolete_option legacy_flag OPT legacy_warn)
+ if(DEFINED ${legacy_flag})
+ if(${legacy_warn})
+ message(STATUS "WARNING: Option ${legacy_flag}='${${legacy_flag}}' is deprecated and should not be used anymore")
+ message(STATUS " Behaviour of this option is not backward compatible")
+ message(STATUS " Refer to 'CPU_BASELINE'/'CPU_DISPATCH' CMake options documentation")
+ endif()
+ if(${legacy_flag})
+ if(NOT ";${CPU_BASELINE_REQUIRE};" MATCHES ";${OPT};")
+ set(CPU_BASELINE_REQUIRE "${CPU_BASELINE_REQUIRE};${OPT}" CACHE STRING "${HELP_CPU_BASELINE_REQUIRE}" FORCE)
+ endif()
+ else()
+ if(NOT ";${CPU_BASELINE_DISABLE};" MATCHES ";${OPT};")
+ set(CPU_BASELINE_DISABLE "${CPU_BASELINE_DISABLE};${OPT}" CACHE STRING "${HELP_CPU_BASELINE_DISABLE}" FORCE)
+ endif()
+ endif()
+ endif()
+endmacro()
+ocv_optimization_process_obsolete_option(ENABLE_SSE SSE ON)
+ocv_optimization_process_obsolete_option(ENABLE_SSE2 SSE2 ON)
+ocv_optimization_process_obsolete_option(ENABLE_SSE3 SSE3 ON)
+ocv_optimization_process_obsolete_option(ENABLE_SSSE3 SSSE3 ON)
+ocv_optimization_process_obsolete_option(ENABLE_SSE41 SSE4_1 ON)
+ocv_optimization_process_obsolete_option(ENABLE_SSE42 SSE4_2 ON)
+ocv_optimization_process_obsolete_option(ENABLE_POPCNT POPCNT ON)
+ocv_optimization_process_obsolete_option(ENABLE_AVX AVX ON)
+ocv_optimization_process_obsolete_option(ENABLE_AVX2 AVX2 ON)
+ocv_optimization_process_obsolete_option(ENABLE_FMA3 FMA3 ON)
+
+ocv_optimization_process_obsolete_option(ENABLE_VFPV3 VFPV3 OFF)
+ocv_optimization_process_obsolete_option(ENABLE_NEON NEON OFF)
+
+
+macro(ocv_is_optimization_in_list resultvar check_opt)
+ set(__checked "")
+ set(__queue ${ARGN})
+ set(${resultvar} 0)
+ while(__queue AND NOT ${resultvar})
+ list(REMOVE_DUPLICATES __queue)
+ set(__queue_current ${__queue})
+ set(__queue "")
+ foreach(OPT ${__queue_current})
+ if("x${OPT}" STREQUAL "x${check_opt}")
+ set(${resultvar} 1)
+ break()
+ elseif(NOT ";${__checked};" MATCHES ";${OPT};")
+ list(APPEND __queue ${CPU_${OPT}_IMPLIES})
+ endif()
+ list(APPEND __checked ${OPT})
+ endforeach()
+ endwhile()
+endmacro()
+
+macro(ocv_is_optimization_in_force_list resultvar check_opt)
+ set(__checked "")
+ set(__queue ${ARGN})
+ set(${resultvar} 0)
+ while(__queue AND NOT ${resultvar})
+ list(REMOVE_DUPLICATES __queue)
+ set(__queue_current ${__queue})
+ set(__queue "")
+ foreach(OPT ${__queue_current})
+ if(OPT STREQUAL "${check_opt}")
+ set(${resultvar} 1)
+ break()
+ elseif(NOT ";${__checked};" MATCHES ";${OPT};")
+ list(APPEND __queue ${CPU_${OPT}_FORCE})
+ endif()
+ list(APPEND __checked ${OPT})
+ endforeach()
+ endwhile()
+endmacro()
+
+macro(ocv_append_optimization_flag var OPT)
+ if(CPU_${OPT}_FLAGS_CONFLICT)
+ string(REGEX REPLACE " ${CPU_${OPT}_FLAGS_CONFLICT}" "" ${var} " ${${var}} ")
+ string(REGEX REPLACE "^ +" "" ${var} "${${var}}")
+ endif()
+ set(${var} "${${var}} ${CPU_${OPT}_FLAGS_ON}")
+endmacro()
+
+# Support GCC -march=native or Intel Compiler -xHost flags
+if(";${CPU_BASELINE};" MATCHES ";NATIVE;" OR ";${CPU_BASELINE};" MATCHES ";HOST;")
+ set(CPU_BASELINE_DETECT ON)
+ set(_add_native_flag ON)
+elseif(";${CPU_BASELINE};" MATCHES ";DETECT;")
+ set(CPU_BASELINE_DETECT ON)
+elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ")
+ if(DEFINED CPU_BASELINE)
+ message(STATUS "CPU: Detected '-march=native' or '-xHost' compiler flag. Force CPU_BASELINE=DETECT.")
+ endif()
+ set(CPU_BASELINE "DETECT" CACHE STRING "${HELP_CPU_BASELINE}")
+ set(CPU_BASELINE_DETECT ON)
+endif()
+
+if(X86 OR X86_64)
+ ocv_update(CPU_KNOWN_OPTIMIZATIONS "SSE;SSE2;SSE3;SSSE3;SSE4_1;POPCNT;SSE4_2;FP16;FMA3;AVX;AVX2") # without AVX512
+
+ ocv_update(CPU_SSE_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_sse.cpp")
+ ocv_update(CPU_SSE2_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_sse2.cpp")
+ ocv_update(CPU_SSE3_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_sse3.cpp")
+ ocv_update(CPU_SSSE3_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_ssse3.cpp")
+ ocv_update(CPU_SSE4_1_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_sse41.cpp")
+ ocv_update(CPU_SSE4_2_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_sse42.cpp")
+ ocv_update(CPU_POPCNT_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_popcnt.cpp")
+ ocv_update(CPU_AVX_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx.cpp")
+ ocv_update(CPU_AVX2_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx2.cpp")
+ ocv_update(CPU_FP16_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_fp16.cpp")
+ ocv_update(CPU_AVX512_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx512.cpp")
+
+ if(NOT OPENCV_CPU_OPT_IMPLIES_IGNORE)
+ ocv_update(CPU_AVX512_IMPLIES "AVX2")
+ ocv_update(CPU_AVX512_FORCE "") # Don't force other optimizations
+ ocv_update(CPU_AVX2_IMPLIES "AVX;FMA3;FP16")
+ ocv_update(CPU_FMA3_IMPLIES "AVX2")
+ ocv_update(CPU_FMA3_FORCE "") # Don't force other optimizations
+ ocv_update(CPU_FP16_IMPLIES "AVX")
+ ocv_update(CPU_FP16_FORCE "") # Don't force other optimizations
+ ocv_update(CPU_AVX_IMPLIES "SSE4_2")
+ ocv_update(CPU_SSE4_2_IMPLIES "SSE4_1;POPCNT")
+ ocv_update(CPU_POPCNT_IMPLIES "SSE4_1")
+ ocv_update(CPU_POPCNT_FORCE "") # Don't force other optimizations
+ ocv_update(CPU_SSE4_1_IMPLIES "SSE3;SSSE3")
+ ocv_update(CPU_SSSE3_IMPLIES "SSE3")
+ ocv_update(CPU_SSE3_IMPLIES "SSE2")
+ ocv_update(CPU_SSE2_IMPLIES "SSE")
+ endif()
+
+ if(CV_ICC)
+ macro(ocv_intel_compiler_optimization_option name unix_flags msvc_flags)
+ ocv_update(CPU_${name}_FLAGS_NAME "${name}")
+ if(MSVC)
+ set(enable_flags "${msvc_flags}")
+ set(flags_conflict "/arch:[^ ]+")
+ else()
+ set(enable_flags "${unix_flags}")
+ set(flags_conflict "-msse[^ ]*|-mssse3|-mavx[^ ]*|-march[^ ]+")
+ endif()
+ ocv_update(CPU_${name}_FLAGS_ON "${enable_flags}")
+ if(flags_conflict)
+ ocv_update(CPU_${name}_FLAGS_CONFLICT "${flags_conflict}")
+ endif()
+ endmacro()
+ ocv_intel_compiler_optimization_option(AVX2 "-march=core-avx2" "/arch:CORE-AVX2")
+ ocv_intel_compiler_optimization_option(FP16 "-mavx" "/arch:AVX")
+ ocv_intel_compiler_optimization_option(AVX "-mavx" "/arch:AVX")
+ ocv_intel_compiler_optimization_option(FMA3 "" "")
+ ocv_intel_compiler_optimization_option(POPCNT "" "")
+ ocv_intel_compiler_optimization_option(SSE4_2 "-msse4.2" "/arch:SSE4.2")
+ ocv_intel_compiler_optimization_option(SSE4_1 "-msse4.1" "/arch:SSE4.1")
+ ocv_intel_compiler_optimization_option(SSE3 "-msse3" "/arch:SSE3")
+ ocv_intel_compiler_optimization_option(SSSE3 "-mssse3" "/arch:SSSE3")
+ ocv_intel_compiler_optimization_option(SSE2 "-msse2" "/arch:SSE2")
+ if(NOT X86_64) # x64 compiler doesn't support /arch:sse
+ ocv_intel_compiler_optimization_option(SSE "-msse" "/arch:SSE")
+ endif()
+ #ocv_intel_compiler_optimization_option(AVX512 "-march=core-avx512")
+ elseif(CMAKE_COMPILER_IS_GNUCXX)
+ ocv_update(CPU_AVX2_FLAGS_ON "-mavx2")
+ ocv_update(CPU_FP16_FLAGS_ON "-mf16c")
+ ocv_update(CPU_AVX_FLAGS_ON "-mavx")
+ ocv_update(CPU_FMA3_FLAGS_ON "-mfma")
+ ocv_update(CPU_POPCNT_FLAGS_ON "-mpopcnt")
+ ocv_update(CPU_SSE4_2_FLAGS_ON "-msse4.2")
+ ocv_update(CPU_SSE4_1_FLAGS_ON "-msse4.1")
+ ocv_update(CPU_SSE3_FLAGS_ON "-msse3")
+ ocv_update(CPU_SSSE3_FLAGS_ON "-mssse3")
+ ocv_update(CPU_SSE2_FLAGS_ON "-msse2")
+ ocv_update(CPU_SSE_FLAGS_ON "-msse")
+ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0")
+ ocv_update(CPU_AVX512_FLAGS_ON "-mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl -mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi")
+ endif()
+ elseif(MSVC)
+ ocv_update(CPU_AVX2_FLAGS_ON "/arch:AVX2")
+ ocv_update(CPU_AVX_FLAGS_ON "/arch:AVX")
+ if(NOT MSVC64)
+ # 64-bit MSVC compiler uses SSE/SSE2 by default
+ ocv_update(CPU_SSE_FLAGS_ON "/arch:SSE")
+ ocv_update(CPU_SSE_SUPPORTED ON)
+ ocv_update(CPU_SSE2_FLAGS_ON "/arch:SSE2")
+ ocv_update(CPU_SSE2_SUPPORTED ON)
+ else()
+ ocv_update(CPU_SSE_SUPPORTED ON)
+ ocv_update(CPU_SSE2_SUPPORTED ON)
+ endif()
+ # Other instruction sets are supported by default since MSVC 2008 at least
+ else()
+ message(WARNING "TODO: Unsupported compiler")
+ endif()
+
+ if(NOT DEFINED CPU_DISPATCH)
+ set(CPU_DISPATCH "SSE4_1;SSE4_2;AVX;FP16;AVX2" CACHE STRING "${HELP_CPU_DISPATCH}")
+ endif()
+
+ if(NOT DEFINED CPU_BASELINE)
+ if(X86_64)
+ set(CPU_BASELINE "SSE3" CACHE STRING "${HELP_CPU_BASELINE}")
+ else()
+ set(CPU_BASELINE "SSE2" CACHE STRING "${HELP_CPU_BASELINE}")
+ endif()
+ endif()
+
+elseif(ARM OR AARCH64)
+ ocv_update(CPU_NEON_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_neon.cpp")
+ ocv_update(CPU_FP16_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_fp16.cpp")
+ if(NOT AARCH64)
+ ocv_update(CPU_KNOWN_OPTIMIZATIONS "VFPV3;NEON;FP16")
+ ocv_update(CPU_VFPV3_FLAGS_ON "-mfpu=vfpv3")
+ ocv_update(CPU_NEON_FLAGS_ON "-mfpu=neon")
+ ocv_update(CPU_NEON_FLAGS_CONFLICT "-mfpu=[^ ]*")
+ ocv_update(CPU_FP16_FLAGS_ON "-mfpu=neon-fp16")
+ ocv_update(CPU_FP16_IMPLIES "NEON")
+ ocv_update(CPU_FP16_FLAGS_CONFLICT "-mfpu=[^ ]*")
+ else()
+ ocv_update(CPU_KNOWN_OPTIMIZATIONS "NEON;FP16")
+ ocv_update(CPU_NEON_FLAGS_ON "")
+ ocv_update(CPU_FP16_IMPLIES "NEON")
+ set(CPU_BASELINE "NEON;FP16" CACHE STRING "${HELP_CPU_BASELINE}")
+ endif()
+endif()
+
+# Helper values for cmake-gui
+set(CPU_BASELINE "DETECT" CACHE STRING "${HELP_CPU_BASELINE}")
+set(CPU_DISPATCH "" CACHE STRING "${HELP_CPU_DISPATCH}")
+set_property(CACHE CPU_BASELINE PROPERTY STRINGS "" ${CPU_KNOWN_OPTIMIZATIONS})
+set_property(CACHE CPU_DISPATCH PROPERTY STRINGS "" ${CPU_KNOWN_OPTIMIZATIONS})
+
+# Update CPU_BASELINE_DETECT flag
+if(";${CPU_BASELINE};" MATCHES ";DETECT;")
+ set(CPU_BASELINE_DETECT ON)
+endif()
+
+set(CPU_BASELINE_FLAGS "")
+
+set(CPU_BASELINE_FINAL "")
+set(CPU_DISPATCH_FINAL "")
+
+if(CV_DISABLE_OPTIMIZATION)
+ set(CPU_DISPATCH "")
+ set(CPU_DISPATCH_REQUIRE "")
+endif()
+
+macro(ocv_check_compiler_optimization OPT)
+ if(NOT DEFINED CPU_${OPT}_SUPPORTED)
+ if((DEFINED CPU_${OPT}_FLAGS_ON AND NOT "x${CPU_${OPT}_FLAGS_ON}" STREQUAL "x") OR CPU_${OPT}_TEST_FILE)
+ set(_varname "")
+ if(CPU_${OPT}_TEST_FILE)
+ set(__available 0)
+ if(CPU_BASELINE_DETECT)
+ set(_varname "HAVE_CPU_${OPT}_SUPPORT")
+ ocv_check_compiler_flag(CXX "${CPU_BASELINE_FLAGS}" "${_varname}" "${CPU_${OPT}_TEST_FILE}")
+ if(${_varname})
+ list(APPEND CPU_BASELINE_FINAL ${OPT})
+ set(__available 1)
+ endif()
+ endif()
+ if(NOT __available)
+ if(NOT "x${CPU_${OPT}_FLAGS_NAME}" STREQUAL "x")
+ set(_varname "HAVE_CPU_${CPU_${OPT}_FLAGS_NAME}")
+ set(_compile_flags "${CPU_BASELINE_FLAGS}")
+ ocv_append_optimization_flag(_compile_flags ${OPT})
+ ocv_check_compiler_flag(CXX "${_compile_flags}" "${_varname}" "${CPU_${OPT}_TEST_FILE}")
+ elseif(NOT "x${CPU_${OPT}_FLAGS_ON}" STREQUAL "x")
+ ocv_check_flag_support(CXX "${CPU_${OPT}_FLAGS_ON}" _varname "" "${CPU_${OPT}_TEST_FILE}")
+ else()
+ set(_varname "HAVE_CPU_${OPT}_SUPPORT")
+ set(_compile_flags "${CPU_BASELINE_FLAGS}")
+ ocv_append_optimization_flag(_compile_flags ${OPT})
+ ocv_check_compiler_flag(CXX "${_compile_flags}" "${_varname}" "${CPU_${OPT}_TEST_FILE}")
+ endif()
+ endif()
+ else()
+ ocv_check_flag_support(CXX "${CPU_${OPT}_FLAGS_ON}" _varname "")
+ endif()
+ if(_varname AND ${_varname})
+ set(CPU_${OPT}_SUPPORTED ON)
+ elseif(NOT CPU_${OPT}_SUPPORTED)
+ message(STATUS "${OPT} is not supported by C++ compiler")
+ endif()
+ else()
+ set(CPU_${OPT}_SUPPORTED ON)
+ endif()
+ endif()
+endmacro()
+
+foreach(OPT ${CPU_KNOWN_OPTIMIZATIONS})
+ set(CPU_${OPT}_USAGE_COUNT 0 CACHE INTERNAL "")
+ if(NOT DEFINED CPU_${OPT}_FORCE)
+ set(CPU_${OPT}_FORCE "${CPU_${OPT}_IMPLIES}")
+ endif()
+endforeach()
+
+if(_add_native_flag)
+ set(_varname "HAVE_CPU_NATIVE_SUPPORT")
+ ocv_check_compiler_flag(CXX "-march=native" "${_varname}" "")
+ if(_varname)
+ set(CPU_BASELINE_FLAGS "${CPU_BASELINE_FLAGS} -march=native")
+ else()
+ set(_varname "HAVE_CPU_HOST_SUPPORT")
+ if(MSVC)
+ set(_flag "/QxHost")
+ else()
+ set(_flag "-xHost")
+ endif()
+ ocv_check_compiler_flag(CXX "${_flag}" "${_varname}" "")
+ if(_varname)
+ set(CPU_BASELINE_FLAGS "${CPU_BASELINE_FLAGS} ${flag}")
+ endif()
+ endif()
+endif()
+
+foreach(OPT ${CPU_KNOWN_OPTIMIZATIONS})
+ set(__is_disabled 0)
+ foreach(OPT2 ${CPU_BASELINE_DISABLE})
+ ocv_is_optimization_in_list(__is_disabled ${OPT2} ${OPT})
+ if(__is_disabled)
+ break()
+ endif()
+ endforeach()
+ if(__is_disabled)
+ set(__is_from_baseline 0)
+ else()
+ ocv_is_optimization_in_list(__is_from_baseline ${OPT} ${CPU_BASELINE_REQUIRE})
+ if(NOT __is_from_baseline)
+ ocv_is_optimization_in_list(__is_from_baseline ${OPT} ${CPU_BASELINE})
+ endif()
+ endif()
+ ocv_is_optimization_in_list(__is_from_dispatch ${OPT} ${CPU_DISPATCH_REQUIRE})
+ if(NOT __is_from_dispatch)
+ ocv_is_optimization_in_list(__is_from_dispatch ${OPT} ${CPU_DISPATCH})
+ endif()
+ if(__is_from_dispatch OR __is_from_baseline OR CPU_BASELINE_DETECT)
+ ocv_check_compiler_optimization(${OPT})
+ endif()
+ if(CPU_BASELINE_DETECT AND NOT __is_from_baseline AND NOT __is_disabled)
+ ocv_is_optimization_in_list(__is_from_baseline ${OPT} ${CPU_BASELINE_FINAL})
+ endif()
+ if(CPU_${OPT}_SUPPORTED)
+ if(";${CPU_DISPATCH};" MATCHES ";${OPT};" AND NOT __is_from_baseline)
+ list(APPEND CPU_DISPATCH_FINAL ${OPT})
+ elseif(__is_from_baseline)
+ list(APPEND CPU_BASELINE_FINAL ${OPT})
+ ocv_append_optimization_flag(CPU_BASELINE_FLAGS ${OPT})
+ endif()
+ endif()
+endforeach()
+
+foreach(OPT ${CPU_BASELINE_REQUIRE})
+ if(NOT ";${CPU_BASELINE_FINAL};" MATCHES ";${OPT};")
+ message(SEND_ERROR "Required baseline optimization is not supported: ${OPT} (CPU_BASELINE_REQUIRE=${CPU_BASELINE_REQUIRE})")
+ endif()
+endforeach()
+
+foreach(OPT ${CPU_BASELINE})
+ if(OPT STREQUAL "DETECT" OR OPT STREQUAL "HOST" OR OPT STREQUAL "NATIVE")
+ # nothing
+ elseif(NOT ";${CPU_BASELINE_FINAL};" MATCHES ";${OPT};")
+ message(STATUS "Optimization ${OPT} is not available, skipped")
+ endif()
+endforeach()
+
+foreach(OPT ${CPU_DISPATCH_REQUIRE})
+ if(";${CPU_DISPATCH_FINAL};" MATCHES ";${OPT};")
+ # OK
+ elseif(";${CPU_BASELINE_FINAL};" MATCHES ";${OPT};")
+ message(SEND_ERROR "Dispatched optimization ${OPT} is in baseline list (CPU_DISPATCH_REQUIRE=${CPU_DISPATCH_REQUIRE})")
+ else()
+ message(SEND_ERROR "Required dispatch optimization is not supported: ${OPT} (CPU_DISPATCH_REQUIRE=${CPU_DISPATCH_REQUIRE})")
+ endif()
+endforeach()
+
+foreach(OPT ${CPU_DISPATCH})
+ if(";${CPU_DISPATCH_FINAL};" MATCHES ";${OPT};")
+ # OK
+ elseif(";${CPU_BASELINE_FINAL};" MATCHES ";${OPT};")
+ # OK
+ else()
+ message(STATUS "Dispatch optimization ${OPT} is not available, skipped")
+ endif()
+endforeach()
+
+#message(STATUS "CPU_BASELINE_FINAL=${CPU_BASELINE_FINAL}")
+#message(STATUS "CPU_DISPATCH_FINAL=${CPU_DISPATCH_FINAL}")
+
+#if(CPU_DISPATCH_FINAL AND NOT PYTHON_DEFAULT_EXECUTABLE)
+# message(FATAL_ERROR "Python is required for CPU dispatched optimization support")
+#endif()
+
+macro(ocv_compiler_optimization_options)
+ set(__flags "${OPENCV_EXTRA_CXX_FLAGS} ${CPU_BASELINE_FLAGS}")
+ if(NOT __flags STREQUAL CACHED_CPU_BASELINE_FLAGS)
+ set(CACHED_CPU_BASELINE_FLAGS "${__flags}" CACHE INTERNAL "" FORCE)
+ ocv_clear_vars(HAVE_CPU_BASELINE_FLAGS)
+ endif()
+ ocv_check_compiler_flag(CXX "${__flags}" HAVE_CPU_BASELINE_FLAGS)
+ if(NOT HAVE_CPU_BASELINE_FLAGS)
+ message(FATAL_ERROR "Compiler doesn't support baseline optimization flags: ${CPU_BASELINE_FLAGS}")
+ endif()
+ add_extra_compiler_option_force("${CPU_BASELINE_FLAGS}")
+
+ foreach(OPT ${CPU_DISPATCH_FINAL})
+ set(__dispatch_flags "")
+ set(__dispatch_definitions "")
+ set(__dispatch_opts "")
+ set(__dispatch_opts_force "")
+ foreach(OPT2 ${CPU_KNOWN_OPTIMIZATIONS})
+ if(NOT CPU_${OPT2}_SUPPORTED)
+ #continue()
+ else()
+ ocv_is_optimization_in_list(__is_from_baseline ${OPT2} ${CPU_BASELINE_FINAL})
+ if(NOT __is_from_baseline)
+ ocv_is_optimization_in_list(__is_active ${OPT2} ${OPT})
+ if(__is_active)
+ ocv_append_optimization_flag(__dispatch_flags ${OPT2})
+ list(APPEND __dispatch_definitions "CV_CPU_COMPILE_${OPT2}=1")
+ list(APPEND __dispatch_opts "${OPT2}")
+ endif()
+ ocv_is_optimization_in_force_list(__is_force ${OPT2} ${OPT})
+ if(__is_force)
+ list(APPEND __dispatch_opts_force "${OPT2}")
+ endif()
+ endif()
+ endif()
+ endforeach()
+ set(__flags "${OPENCV_EXTRA_CXX_FLAGS} ${__dispatch_flags}")
+ if(NOT __flags STREQUAL CACHED_CPU_DISPATCH_${OPT}_FLAGS)
+ set(CACHED_CPU_DISPATCH_${OPT}_FLAGS "${__flags}" CACHE INTERNAL "" FORCE)
+ ocv_clear_vars(HAVE_CPU_DISPATCH_FLAGS_${OPT})
+ endif()
+ ocv_check_compiler_flag(CXX "${__flags}" HAVE_CPU_DISPATCH_FLAGS_${OPT})
+ if(NOT HAVE_CPU_DISPATCH_FLAGS_${OPT})
+ message(FATAL_ERROR "Compiler doesn't support optimization flags for ${OPT} dispatch mode: ${__dispatch_flags}")
+ endif()
+ set(CPU_DISPATCH_FLAGS_${OPT} "${__dispatch_flags}")
+ set(CPU_DISPATCH_DEFINITIONS_${OPT} "${__dispatch_definitions}")
+ set(CPU_DISPATCH_${OPT}_INCLUDED "${__dispatch_opts}")
+ set(CPU_DISPATCH_${OPT}_FORCED "${__dispatch_opts_force}")
+ endforeach()
+
+ if(ENABLE_POWERPC)
+ add_extra_compiler_option("-mcpu=G3 -mtune=G5")
+ endif()
+ if(ARM)
+ add_extra_compiler_option("-mfp16-format=ieee")
+ endif(ARM)
+endmacro()
+
+macro(ocv_compiler_optimization_options_finalize)
+ if(CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64))
+ if(NOT APPLE AND CMAKE_SIZEOF_VOID_P EQUAL 4)
+ if(OPENCV_EXTRA_CXX_FLAGS MATCHES "-m(sse2|avx)")
+ add_extra_compiler_option(-mfpmath=sse) # !! important - be on the same wave with x64 compilers
+ else()
+ add_extra_compiler_option(-mfpmath=387)
+ endif()
+ endif()
+ endif()
+
+ if(MSVC)
+ # Generate Intrinsic Functions
+ set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /Oi")
+
+ if((X86 OR X86_64) AND CMAKE_SIZEOF_VOID_P EQUAL 4 AND ";${CPU_BASELINE_FINAL};" MATCHES ";SSE;")
+ set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /fp:fast") # !! important - be on the same wave with x64 compilers
+ endif()
+ endif(MSVC)
+endmacro()
+
+macro(ocv_compiler_optimization_process_sources SOURCES_VAR_NAME LIBS_VAR_NAME TARGET_BASE_NAME)
+ set(__result "")
+ set(__result_libs "")
+ foreach(OPT ${CPU_DISPATCH_FINAL})
+ set(__result_${OPT} "")
+ endforeach()
+ foreach(fname ${${SOURCES_VAR_NAME}})
+ string(TOLOWER "${fname}" fname_LOWER)
+ get_filename_component(fname_LOWER "${fname_LOWER}" NAME)
+ if(fname_LOWER MATCHES "\\.(.*)\\.cpp$")
+ string(TOUPPER "${CMAKE_MATCH_1}" OPT_)
+ if(OPT_ MATCHES "(CUDA.*|DISPATCH.*|OCL)") # don't touch files like filename.cuda.cpp
+ list(APPEND __result "${fname}")
+ #continue()
+ elseif(CV_DISABLE_OPTIMIZATION OR NOT CV_ENABLE_INTRINSICS)
+ message(STATUS "Excluding from source files list (optimization is disabled): ${fname}")
+ #continue()
+ else()
+ get_source_file_property(__definitions "${fname}" COMPILE_DEFINITIONS)
+ if(__definitions)
+ list(APPEND __definitions "CV_CPU_DISPATCH_MODE=${OPT_}")
+ else()
+ set(__definitions "CV_CPU_DISPATCH_MODE=${OPT_}")
+ endif()
+ set_source_files_properties("${fname}" PROPERTIES COMPILE_DEFINITIONS "${__definitions}")
+
+ set(__opt_found 0)
+ foreach(OPT ${CPU_BASELINE_FINAL})
+ string(TOLOWER "${OPT}" OPT_LOWER)
+ if(fname_LOWER MATCHES "\\.${OPT_LOWER}\\.cpp$")
+#message("${fname} BASELINE-${OPT}")
+ set(__opt_found 1)
+ list(APPEND __result "${fname}")
+ break()
+ endif()
+ endforeach()
+ foreach(OPT ${CPU_DISPATCH_FINAL})
+ foreach(OPT2 ${CPU_DISPATCH_${OPT}_FORCED})
+ string(TOLOWER "${OPT2}" OPT2_LOWER)
+ if(fname_LOWER MATCHES "\\.${OPT2_LOWER}\\.cpp$")
+ list(APPEND __result_${OPT} "${fname}")
+ math(EXPR CPU_${OPT}_USAGE_COUNT "${CPU_${OPT}_USAGE_COUNT}+1")
+ set(CPU_${OPT}_USAGE_COUNT "${CPU_${OPT}_USAGE_COUNT}" CACHE INTERNAL "" FORCE)
+#message("(${CPU_${OPT}_USAGE_COUNT})${fname} ${OPT}")
+#message(" ${CPU_DISPATCH_${OPT}_INCLUDED}")
+#message(" ${CPU_DISPATCH_DEFINITIONS_${OPT}}")
+#message(" ${CPU_DISPATCH_FLAGS_${OPT}}")
+ set(__opt_found 1)
+ break()
+ endif()
+ endforeach()
+ if(__opt_found)
+ set(__opt_found 1)
+ break()
+ endif()
+ endforeach()
+ if(NOT __opt_found)
+ message(STATUS "Excluding from source files list: ${fname}")
+ endif()
+ endif()
+ else()
+ list(APPEND __result "${fname}")
+ endif()
+ endforeach()
+
+ foreach(OPT ${CPU_DISPATCH_FINAL})
+ if(__result_${OPT})
+#message("${OPT}: ${__result_${OPT}}")
+ if(CMAKE_GENERATOR MATCHES "^Visual")
+ # extra flags are added before common flags, so switching between optimizations doesn't work correctly
+ # Also CMAKE_CXX_FLAGS doesn't work (it is directory-based, so add_subdirectory is required)
+ add_library(${TARGET_BASE_NAME}_${OPT} OBJECT ${__result_${OPT}})
+ ocv_append_dependant_targets(${TARGET_BASE_NAME} ${TARGET_BASE_NAME}_${OPT})
+ set_target_properties(${TARGET_BASE_NAME}_${OPT} PROPERTIES COMPILE_DEFINITIONS "${CPU_DISPATCH_DEFINITIONS_${OPT}}")
+ set_target_properties(${TARGET_BASE_NAME}_${OPT} PROPERTIES COMPILE_FLAGS "${CPU_DISPATCH_FLAGS_${OPT}}")
+ target_include_directories(${TARGET_BASE_NAME}_${OPT} PRIVATE $<TARGET_PROPERTY:${TARGET_BASE_NAME},INCLUDE_DIRECTORIES>)
+ #list(APPEND __result_libs ${TARGET_BASE_NAME}_${OPT})
+ list(APPEND __result "$<TARGET_OBJECTS:${TARGET_BASE_NAME}_${OPT}>")
+ else()
+ foreach(fname ${__result_${OPT}})
+ get_source_file_property(__definitions "${fname}" COMPILE_DEFINITIONS)
+ if(__definitions)
+ list(APPEND __definitions "${CPU_DISPATCH_DEFINITIONS_${OPT}}")
+ else()
+ set(__definitions "${CPU_DISPATCH_DEFINITIONS_${OPT}}")
+ endif()
+ set_source_files_properties("${fname}" PROPERTIES COMPILE_DEFINITIONS "${__definitions}")
+ set_source_files_properties("${fname}" PROPERTIES COMPILE_FLAGS "${CPU_DISPATCH_FLAGS_${OPT}}")
+ endforeach()
+ list(APPEND __result ${__result_${OPT}})
+ endif()
+ endif()
+ endforeach()
+ set(${SOURCES_VAR_NAME} "${__result}")
+ list(APPEND ${LIBS_VAR_NAME} ${__result_libs})
+endmacro()
+
+macro(ocv_compiler_optimization_fill_cpu_config)
+ set(OPENCV_CPU_BASELINE_DEFINITIONS_CONFIGMAKE "")
+ foreach(OPT ${CPU_BASELINE_FINAL})
+ set(OPENCV_CPU_BASELINE_DEFINITIONS_CONFIGMAKE "${OPENCV_CPU_BASELINE_DEFINITIONS_CONFIGMAKE}
+#define CV_CPU_COMPILE_${OPT} 1
+#define CV_CPU_BASELINE_COMPILE_${OPT} 1
+")
+ endforeach()
+
+ set(OPENCV_CPU_BASELINE_DEFINITIONS_CONFIGMAKE "${OPENCV_CPU_BASELINE_DEFINITIONS_CONFIGMAKE}
+#define CV_CPU_BASELINE_FEATURES 0 \\")
+ foreach(OPT ${CPU_BASELINE_FINAL})
+ if(NOT DEFINED CPU_${OPT}_FEATURE_ALIAS OR NOT "x${CPU_${OPT}_FEATURE_ALIAS}" STREQUAL "x")
+ set(OPENCV_CPU_BASELINE_DEFINITIONS_CONFIGMAKE "${OPENCV_CPU_BASELINE_DEFINITIONS_CONFIGMAKE}
+ , CV_CPU_${OPT} \\")
+ endif()
+ endforeach()
+ set(OPENCV_CPU_BASELINE_DEFINITIONS_CONFIGMAKE "${OPENCV_CPU_BASELINE_DEFINITIONS_CONFIGMAKE}\n")
+
+ set(__dispatch_modes "")
+ foreach(OPT ${CPU_DISPATCH_FINAL})
+ list(APPEND __dispatch_modes ${CPU_DISPATCH_${OPT}_FORCE} ${OPT})
+ endforeach()
+ list(REMOVE_DUPLICATES __dispatch_modes)
+ set(OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE "")
+ foreach(OPT ${__dispatch_modes})
+ set(OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE "${OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE}
+#define CV_CPU_DISPATCH_COMPILE_${OPT} 1")
+ endforeach()
+
+ set(OPENCV_CPU_CONTROL_DEFINITIONS_CONFIGMAKE "// AUTOGENERATED, DO NOT EDIT\n")
+ foreach(OPT ${CPU_ALL_OPTIMIZATIONS})
+ if(NOT DEFINED CPU_${OPT}_FEATURE_ALIAS OR NOT "x${CPU_${OPT}_FEATURE_ALIAS}" STREQUAL "x")
+ set(OPENCV_CPU_CONTROL_DEFINITIONS_CONFIGMAKE "${OPENCV_CPU_CONTROL_DEFINITIONS_CONFIGMAKE}
+#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_${OPT}
+# define CV_TRY_${OPT} 1
+# define CV_CPU_HAS_SUPPORT_${OPT} 1
+# define CV_CPU_CALL_${OPT}(fn, args) return (opt_${OPT}::fn args)
+#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_${OPT}
+# define CV_TRY_${OPT} 1
+# define CV_CPU_HAS_SUPPORT_${OPT} (cv::checkHardwareSupport(CV_CPU_${OPT}))
+# define CV_CPU_CALL_${OPT}(fn, args) if (CV_CPU_HAS_SUPPORT_${OPT}) return (opt_${OPT}::fn args)
+#else
+# define CV_TRY_${OPT} 0
+# define CV_CPU_HAS_SUPPORT_${OPT} 0
+# define CV_CPU_CALL_${OPT}(fn, args)
+#endif
+#define __CV_CPU_DISPATCH_CHAIN_${OPT}(fn, args, mode, ...) CV_CPU_CALL_${OPT}(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
+")
+ endif()
+ endforeach()
+
+ set(OPENCV_CPU_CONTROL_DEFINITIONS_CONFIGMAKE "${OPENCV_CPU_CONTROL_DEFINITIONS_CONFIGMAKE}
+#define CV_CPU_CALL_BASELINE(fn, args) return (cpu_baseline::fn args)
+#define __CV_CPU_DISPATCH_CHAIN_BASELINE(fn, args, mode, ...) CV_CPU_CALL_BASELINE(fn, args) /* last in sequence */
+")
+
+
+ set(__file "${CMAKE_SOURCE_DIR}/modules/core/include/opencv2/core/cv_cpu_helper.h")
+ if(EXISTS "${__file}")
+ file(READ "${__file}" __content)
+ endif()
+ if(__content STREQUAL OPENCV_CPU_CONTROL_DEFINITIONS_CONFIGMAKE)
+ #message(STATUS "${__file} contains same content")
+ else()
+ file(WRITE "${__file}" "${OPENCV_CPU_CONTROL_DEFINITIONS_CONFIGMAKE}")
+ message(WARNING "${__file} is updated")
+ endif()
+endmacro()
+
+macro(ocv_add_dispatched_file filename)
+ if(NOT OPENCV_INITIAL_PASS)
+ set(__codestr "
+#include \"precomp.hpp\"
+#include \"${filename}.simd.hpp\"
+")
+
+ set(__declarations_str "#define CV_CPU_SIMD_FILENAME \"${filename}.simd.hpp\"")
+ set(__dispatch_modes "BASELINE")
+
+ set(__optimizations "${ARGN}")
+ if(CV_DISABLE_OPTIMIZATION OR NOT CV_ENABLE_INTRINSICS)
+ set(__optimizations "")
+ endif()
+
+ foreach(OPT ${__optimizations})
+ string(TOLOWER "${OPT}" OPT_LOWER)
+ set(__file "${CMAKE_CURRENT_BINARY_DIR}/${filename}.${OPT_LOWER}.cpp")
+ if(EXISTS "${__file}")
+ file(READ "${__file}" __content)
+ endif()
+ if(__content STREQUAL __codestr)
+ #message(STATUS "${__file} contains up-to-date content")
+ else()
+ file(WRITE "${__file}" "${__codestr}")
+ endif()
+ list(APPEND OPENCV_MODULE_${the_module}_SOURCES_DISPATCHED "${__file}")
+
+ set(__declarations_str "${__declarations_str}
+#define CV_CPU_DISPATCH_MODE ${OPT}
+#include \"opencv2/core/private/cv_cpu_include_simd_declarations.hpp\"
+")
+ set(__dispatch_modes "${OPT}, ${__dispatch_modes}")
+ endforeach()
+
+ set(__declarations_str "${__declarations_str}
+#define CV_CPU_DISPATCH_MODES_ALL ${__dispatch_modes}
+")
+
+ set(__file "${CMAKE_CURRENT_BINARY_DIR}/${filename}.simd_declarations.hpp")
+ if(EXISTS "${__file}")
+ file(READ "${__file}" __content)
+ endif()
+ if(__content STREQUAL __declarations_str)
+ #message(STATUS "${__file} contains up-to-date content")
+ else()
+ file(WRITE "${__file}" "${__declarations_str}")
+ endif()
+ endif()
+endmacro()
+
+if(CV_DISABLE_OPTIMIZATION OR CV_ICC)
+ ocv_update(CV_ENABLE_UNROLLED 0)
+else()
+ ocv_update(CV_ENABLE_UNROLLED 1)
+endif()
diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake
index 5bb0479..2fcc373 100644
--- a/cmake/OpenCVCompilerOptions.cmake
+++ b/cmake/OpenCVCompilerOptions.cmake
@@ -18,9 +18,9 @@ if(ENABLE_CCACHE AND NOT CMAKE_COMPILER_IS_CCACHE)
message(STATUS "Unable to compile program with enabled ccache, reverting...")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${__OLD_RULE_LAUNCH_COMPILE}")
endif()
- else()
- message(STATUS "Looking for ccache - not found")
endif()
+ else()
+ message(STATUS "Looking for ccache - not found")
endif()
endif()
@@ -31,24 +31,21 @@ endif()
if(MINGW OR (X86 AND UNIX AND NOT APPLE))
# mingw compiler is known to produce unstable SSE code with -O3 hence we are trying to use -O2 instead
if(CMAKE_COMPILER_IS_GNUCXX)
- foreach(flags CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG)
- string(REPLACE "-O3" "-O2" ${flags} "${${flags}}")
- endforeach()
- endif()
-
- if(CMAKE_COMPILER_IS_GNUCC)
- foreach(flags CMAKE_C_FLAGS CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_DEBUG)
+ foreach(flags
+ CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG
+ CMAKE_C_FLAGS CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_DEBUG)
string(REPLACE "-O3" "-O2" ${flags} "${${flags}}")
endforeach()
endif()
endif()
if(MSVC)
- string(REGEX REPLACE "^ *| * $" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
- string(REGEX REPLACE "^ *| * $" "" CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT}")
+ string(STRIP "${CMAKE_CXX_FLAGS}" CMAKE_CXX_FLAGS)
+ string(STRIP "${CMAKE_CXX_FLAGS_INIT}" CMAKE_CXX_FLAGS_INIT)
if(CMAKE_CXX_FLAGS STREQUAL CMAKE_CXX_FLAGS_INIT)
# override cmake default exception handling option
- string(REPLACE "/EHsc" "/EHa" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+ string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHa")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "Flags used by the compiler during all build types." FORCE)
endif()
endif()
@@ -63,9 +60,6 @@ set(OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE "")
set(OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG "")
macro(add_extra_compiler_option option)
- if(CMAKE_BUILD_TYPE)
- set(CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_BUILD_TYPE})
- endif()
ocv_check_flag_support(CXX "${option}" _varname "${OPENCV_EXTRA_CXX_FLAGS} ${ARGN}")
if(${_varname})
set(OPENCV_EXTRA_CXX_FLAGS "${OPENCV_EXTRA_CXX_FLAGS} ${option}")
@@ -77,6 +71,12 @@ macro(add_extra_compiler_option option)
endif()
endmacro()
+macro(add_extra_compiler_option_force option)
+ set(OPENCV_EXTRA_CXX_FLAGS "${OPENCV_EXTRA_CXX_FLAGS} ${option}")
+ set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} ${option}")
+endmacro()
+
+
# Gets environment variable and puts its value to the corresponding preprocessor definition
# Useful for WINRT that has no access to environment variables
macro(add_env_definitions option)
@@ -102,7 +102,11 @@ if(MINGW)
endif()
if(CV_ICC AND NOT ENABLE_FAST_MATH)
- add_extra_compiler_option("-fp-model precise")
+ if(MSVC)
+ add_extra_compiler_option("/fp:precise")
+ else()
+ add_extra_compiler_option("-fp-model precise")
+ endif()
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
@@ -123,6 +127,8 @@ if(CMAKE_COMPILER_IS_GNUCXX)
add_extra_compiler_option(-Wpointer-arith)
add_extra_compiler_option(-Wshadow)
add_extra_compiler_option(-Wsign-promo)
+ add_extra_compiler_option(-Wuninitialized)
+ add_extra_compiler_option(-Winit-self)
if(ENABLE_NOISY_WARNINGS)
add_extra_compiler_option(-Wcast-align)
@@ -141,7 +147,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
endif()
# We need pthread's
- if(UNIX AND NOT ANDROID AND NOT (APPLE AND CMAKE_COMPILER_IS_CLANGCXX))
+ if(UNIX AND NOT ANDROID AND NOT (APPLE AND CMAKE_COMPILER_IS_CLANGCXX)) # TODO
add_extra_compiler_option(-pthread)
endif()
@@ -170,83 +176,6 @@ if(CMAKE_COMPILER_IS_GNUCXX)
if(ENABLE_FAST_MATH)
add_extra_compiler_option(-ffast-math)
endif()
- if(ENABLE_POWERPC)
- add_extra_compiler_option("-mcpu=G3 -mtune=G5")
- endif()
- if(ENABLE_SSE)
- add_extra_compiler_option(-msse)
- endif()
- if(ENABLE_SSE2)
- add_extra_compiler_option(-msse2)
- elseif(X86 OR X86_64)
- add_extra_compiler_option(-mno-sse2)
- endif()
- if(ARM)
- add_extra_compiler_option("-mfp16-format=ieee")
- endif(ARM)
- if(ENABLE_NEON)
- add_extra_compiler_option("-mfpu=neon")
- endif()
- if(ENABLE_VFPV3 AND NOT ENABLE_NEON)
- add_extra_compiler_option("-mfpu=vfpv3")
- endif()
-
- # SSE3 and further should be disabled under MingW because it generates compiler errors
- if(NOT MINGW)
- if(ENABLE_AVX)
- add_extra_compiler_option(-mavx)
- elseif(X86 OR X86_64)
- add_extra_compiler_option(-mno-avx)
- endif()
- if(ENABLE_AVX2)
- add_extra_compiler_option(-mavx2)
-
- if(ENABLE_FMA3)
- add_extra_compiler_option(-mfma)
- endif()
- endif()
-
- # GCC depresses SSEx instructions when -mavx is used. Instead, it generates new AVX instructions or AVX equivalence for all SSEx instructions when needed.
- if(NOT OPENCV_EXTRA_CXX_FLAGS MATCHES "-mavx")
- if(ENABLE_SSE3)
- add_extra_compiler_option(-msse3)
- elseif(X86 OR X86_64)
- add_extra_compiler_option(-mno-sse3)
- endif()
-
- if(ENABLE_SSSE3)
- add_extra_compiler_option(-mssse3)
- elseif(X86 OR X86_64)
- add_extra_compiler_option(-mno-ssse3)
- endif()
-
- if(ENABLE_SSE41)
- add_extra_compiler_option(-msse4.1)
- elseif(X86 OR X86_64)
- add_extra_compiler_option(-mno-sse4.1)
- endif()
-
- if(ENABLE_SSE42)
- add_extra_compiler_option(-msse4.2)
- elseif(X86 OR X86_64)
- add_extra_compiler_option(-mno-sse4.2)
- endif()
-
- if(ENABLE_POPCNT)
- add_extra_compiler_option(-mpopcnt)
- endif()
- endif()
- endif(NOT MINGW)
-
- if(X86 OR X86_64)
- if(NOT APPLE AND CMAKE_SIZEOF_VOID_P EQUAL 4)
- if(OPENCV_EXTRA_CXX_FLAGS MATCHES "-m(sse2|avx)")
- add_extra_compiler_option(-mfpmath=sse)# !! important - be on the same wave with x64 compilers
- else()
- add_extra_compiler_option(-mfpmath=387)
- endif()
- endif()
- endif()
# Profiling?
if(ENABLE_PROFILING)
@@ -257,7 +186,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
string(REPLACE "-fomit-frame-pointer" "" ${flags} "${${flags}}")
string(REPLACE "-ffunction-sections" "" ${flags} "${${flags}}")
endforeach()
- elseif(NOT APPLE AND NOT ANDROID)
+ elseif(NOT ((IOS OR ANDROID) AND NOT BUILD_SHARED_LIBS))
# Remove unreferenced functions: function level linking
add_extra_compiler_option(-ffunction-sections)
endif()
@@ -265,6 +194,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
if(ENABLE_COVERAGE)
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} --coverage")
set(OPENCV_EXTRA_CXX_FLAGS "${OPENCV_EXTRA_CXX_FLAGS} --coverage")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
endif()
if(ENABLE_INSTRUMENTATION)
@@ -273,11 +203,18 @@ if(CMAKE_COMPILER_IS_GNUCXX)
endif()
set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE} -DNDEBUG")
- set(OPENCV_EXTRA_FLAGS_DEBUG "${OPENCV_EXTRA_FLAGS_DEBUG} -O0 -DDEBUG -D_DEBUG")
+ if(NOT " ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} " MATCHES "-O")
+ set(OPENCV_EXTRA_FLAGS_DEBUG "${OPENCV_EXTRA_FLAGS_DEBUG} -O0")
+ endif()
+ set(OPENCV_EXTRA_FLAGS_DEBUG "${OPENCV_EXTRA_FLAGS_DEBUG} -DDEBUG -D_DEBUG")
endif()
if(MSVC)
- set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS")
+ #TODO Code refactoring is required to resolve security warnings
+ #if(NOT ENABLE_BUILD_HARDENING)
+ set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS")
+ #endif()
+
# 64-bit portability warnings, in MSVC80
if(MSVC80)
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /Wp64")
@@ -296,41 +233,6 @@ if(MSVC)
set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE} /Zi")
endif()
- if(ENABLE_AVX2 AND NOT MSVC_VERSION LESS 1800)
- set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:AVX2")
- endif()
- if(ENABLE_AVX AND NOT MSVC_VERSION LESS 1600 AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:")
- set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:AVX")
- endif()
-
- if(ENABLE_SSE4_1 AND CV_ICC AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:")
- set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE4.1")
- endif()
-
- if(ENABLE_SSE3 AND CV_ICC AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:")
- set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE3")
- endif()
-
- if(NOT MSVC64)
- # 64-bit MSVC compiler uses SSE/SSE2 by default
- if(ENABLE_SSE2 AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:")
- set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE2")
- endif()
- if(ENABLE_SSE AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:")
- set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE")
- endif()
- endif()
-
- if(ENABLE_SSE OR ENABLE_SSE2 OR ENABLE_SSE3 OR ENABLE_SSE4_1 OR ENABLE_AVX OR ENABLE_AVX2)
- set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /Oi")
- endif()
-
- if(X86 OR X86_64)
- if(CMAKE_SIZEOF_VOID_P EQUAL 4 AND ENABLE_SSE2)
- set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /fp:fast") # !! important - be on the same wave with x64 compilers
- endif()
- endif()
-
if(OPENCV_WARNINGS_ARE_ERRORS)
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /WX")
endif()
@@ -349,10 +251,22 @@ endif()
# Extra link libs if the user selects building static libs:
if(NOT BUILD_SHARED_LIBS AND CMAKE_COMPILER_IS_GNUCXX AND NOT ANDROID)
# Android does not need these settings because they are already set by toolchain file
- set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} stdc++)
+ if(NOT MINGW)
+ set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} stdc++)
+ endif()
set(OPENCV_EXTRA_FLAGS "-fPIC ${OPENCV_EXTRA_FLAGS}")
endif()
+include(cmake/OpenCVCompilerOptimizations.cmake)
+
+if(COMMAND ocv_compiler_optimization_options)
+ ocv_compiler_optimization_options()
+endif()
+
+if(COMMAND ocv_compiler_optimization_options_finalize)
+ ocv_compiler_optimization_options_finalize()
+endif()
+
# Add user supplied extra options (optimization, etc...)
# ==========================================================
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS}" CACHE INTERNAL "Extra compiler options")
@@ -370,34 +284,6 @@ if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_OPENCV_GCC_VERSION_NUM GREATER 399)
add_extra_compiler_option(-fvisibility-inlines-hidden)
endif()
-if(NOT OPENCV_FP16_DISABLE AND NOT IOS)
- if(ARM AND ENABLE_NEON)
- set(FP16_OPTION "-mfpu=neon-fp16")
- elseif((X86 OR X86_64) AND NOT MSVC AND ENABLE_AVX)
- set(FP16_OPTION "-mf16c")
- endif()
- try_compile(__VALID_FP16
- "${OpenCV_BINARY_DIR}"
- "${OpenCV_SOURCE_DIR}/cmake/checks/fp16.cpp"
- COMPILE_DEFINITIONS "-DCHECK_FP16" "${FP16_OPTION}"
- OUTPUT_VARIABLE TRY_OUT
- )
- if(NOT __VALID_FP16)
- if((X86 OR X86_64) AND NOT MSVC AND NOT ENABLE_AVX)
- # GCC enables AVX when mf16c is passed
- message(STATUS "FP16: Feature disabled")
- else()
- message(STATUS "FP16: Compiler support is not available")
- endif()
- else()
- message(STATUS "FP16: Compiler support is available")
- set(HAVE_FP16 1)
- if(NOT ${FP16_OPTION} STREQUAL "")
- add_extra_compiler_option(${FP16_OPTION})
- endif()
- endif()
-endif()
-
#combine all "extra" options
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPENCV_EXTRA_FLAGS} ${OPENCV_EXTRA_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENCV_EXTRA_FLAGS} ${OPENCV_EXTRA_CXX_FLAGS}")
@@ -453,3 +339,8 @@ endif()
if(APPLE AND NOT CMAKE_CROSSCOMPILING AND NOT DEFINED ENV{LDFLAGS} AND EXISTS "/usr/local/lib")
link_directories("/usr/local/lib")
endif()
+
+
+if(ENABLE_BUILD_HARDENING)
+ include(${CMAKE_CURRENT_LIST_DIR}/OpenCVCompilerDefenses.cmake)
+endif()
diff --git a/cmake/OpenCVDetectCStripes.cmake b/cmake/OpenCVDetectCStripes.cmake
index 279a339..dce52d9 100644
--- a/cmake/OpenCVDetectCStripes.cmake
+++ b/cmake/OpenCVDetectCStripes.cmake
@@ -1,6 +1,6 @@
if(WIN32)
find_path( CSTRIPES_LIB_DIR
- NAMES "С=.lib"
+ NAMES "C=.lib"
DOC "The path to C= lib and dll")
if(CSTRIPES_LIB_DIR)
ocv_include_directories("${CSTRIPES_LIB_DIR}/..")
diff --git a/cmake/OpenCVDetectCUDA.cmake b/cmake/OpenCVDetectCUDA.cmake
index 3116d9f..282ba3e 100644
--- a/cmake/OpenCVDetectCUDA.cmake
+++ b/cmake/OpenCVDetectCUDA.cmake
@@ -88,7 +88,17 @@ if(CUDA_FOUND)
set(__cuda_arch_bin "3.2")
set(__cuda_arch_ptx "")
elseif(AARCH64)
- set(__cuda_arch_bin "5.3")
+ execute_process( COMMAND "${CUDA_NVCC_EXECUTABLE}" "${OpenCV_SOURCE_DIR}/cmake/checks/OpenCVDetectCudaArch.cu" "--run"
+ WORKING_DIRECTORY "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/"
+ RESULT_VARIABLE _nvcc_res OUTPUT_VARIABLE _nvcc_out
+ ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if(NOT _nvcc_res EQUAL 0)
+ message(STATUS "Automatic detection of CUDA generation failed. Going to build for all known architectures.")
+ set(__cuda_arch_bin "5.3 6.2")
+ else()
+ set(__cuda_arch_bin "${_nvcc_out}")
+ string(REPLACE "2.1" "2.1(2.0)" __cuda_arch_bin "${__cuda_arch_bin}")
+ endif()
set(__cuda_arch_ptx "")
else()
if(${CUDA_VERSION} VERSION_LESS "8.0")
@@ -96,7 +106,6 @@ if(CUDA_FOUND)
else()
set(__cuda_arch_bin "2.0 3.0 3.5 3.7 5.0 5.2 6.0 6.1")
endif()
- set(__cuda_arch_ptx "")
endif()
endif()
diff --git a/cmake/OpenCVDetectCXXCompiler.cmake b/cmake/OpenCVDetectCXXCompiler.cmake
index 8ecf4d8..67e2a0f 100644
--- a/cmake/OpenCVDetectCXXCompiler.cmake
+++ b/cmake/OpenCVDetectCXXCompiler.cmake
@@ -160,7 +160,7 @@ if(MSVC)
set(OpenCV_RUNTIME vc12)
elseif(MSVC_VERSION EQUAL 1900)
set(OpenCV_RUNTIME vc14)
- elseif(MSVC_VERSION EQUAL 1910)
+ elseif(MSVC_VERSION EQUAL 1910 OR MSVC_VERSION EQUAL 1911)
set(OpenCV_RUNTIME vc15)
endif()
elseif(MINGW)
@@ -172,3 +172,33 @@ elseif(MINGW)
set(OpenCV_ARCH x86)
endif()
endif()
+
+# Fix handling of duplicated files in the same static library:
+# https://public.kitware.com/Bug/view.php?id=14874
+if(CMAKE_VERSION VERSION_LESS "3.1")
+ foreach(var CMAKE_C_ARCHIVE_APPEND CMAKE_CXX_ARCHIVE_APPEND)
+ if(${var} MATCHES "^<CMAKE_AR> r")
+ string(REPLACE "<CMAKE_AR> r" "<CMAKE_AR> q" ${var} "${${var}}")
+ endif()
+ endforeach()
+endif()
+
+if(ENABLE_CXX11)
+ #cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
+ set(CMAKE_CXX_STANDARD 11)
+ set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
+ set(CMAKE_CXX_EXTENSIONS OFF) # use -std=c++11 instead of -std=gnu++11
+ if(CMAKE_CXX11_COMPILE_FEATURES)
+ set(HAVE_CXX11 ON)
+ endif()
+endif()
+if(NOT HAVE_CXX11)
+ ocv_check_compiler_flag(CXX "" HAVE_CXX11 "${OpenCV_SOURCE_DIR}/cmake/checks/cxx11.cpp")
+ if(NOT HAVE_CXX11 AND ENABLE_CXX11)
+ ocv_check_compiler_flag(CXX "-std=c++11" HAVE_STD_CXX11 "${OpenCV_SOURCE_DIR}/cmake/checks/cxx11.cpp")
+ if(HAVE_STD_CXX11)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+ set(HAVE_CXX11 ON)
+ endif()
+ endif()
+endif()
diff --git a/cmake/OpenCVDetectHalide.cmake b/cmake/OpenCVDetectHalide.cmake
new file mode 100644
index 0000000..790f692
--- /dev/null
+++ b/cmake/OpenCVDetectHalide.cmake
@@ -0,0 +1,45 @@
+cmake_minimum_required(VERSION 3.1)
+
+if(" ${HALIDE_ROOT_DIR}" STREQUAL " ")
+ unset(HALIDE_ROOT_DIR CACHE)
+endif()
+ocv_check_environment_variables(HALIDE_ROOT_DIR)
+set(HALIDE_ROOT_DIR "${HALIDE_ROOT_DIR}" CACHE PATH "Halide root directory")
+
+if(NOT HAVE_HALIDE)
+ find_package(Halide QUIET) # Try CMake-based config files
+ if(Halide_FOUND)
+ set(HALIDE_INCLUDE_DIRS "${Halide_INCLUDE_DIRS}" CACHE PATH "Halide include directories" FORCE)
+ set(HALIDE_LIBRARIES "${Halide_LIBRARIES}" CACHE PATH "Halide libraries" FORCE)
+ set(HAVE_HALIDE TRUE)
+ endif()
+endif()
+
+if(NOT HAVE_HALIDE AND HALIDE_ROOT_DIR)
+ # Try manual search
+ find_library(HALIDE_LIBRARY
+ NAMES Halide
+ HINTS ${HALIDE_ROOT_DIR}/lib # Unix
+ HINTS ${HALIDE_ROOT_DIR}/lib/Release # Win32
+ )
+ find_path(HALIDE_INCLUDE_DIR
+ NAMES Halide.h HalideRuntime.h
+ HINTS ${HALIDE_ROOT_DIR}/include
+ )
+ if(HALIDE_LIBRARY AND HALIDE_INCLUDE_DIR)
+ # TODO try_compile
+ set(HALIDE_INCLUDE_DIRS "${HALIDE_INCLUDE_DIR}" CACHE PATH "Halide include directories" FORCE)
+ set(HALIDE_LIBRARIES "${HALIDE_LIBRARY}" CACHE PATH "Halide libraries" FORCE)
+ set(HAVE_HALIDE TRUE)
+ endif()
+ if(NOT HAVE_HALIDE)
+ ocv_clear_vars(HALIDE_LIBRARIES HALIDE_INCLUDE_DIRS CACHE)
+ endif()
+endif()
+
+if(HAVE_HALIDE)
+ include_directories(${HALIDE_INCLUDE_DIRS})
+ list(APPEND OPENCV_LINKER_LIBS ${HALIDE_LIBRARIES})
+else()
+ ocv_clear_vars(HALIDE_INCLUDE_DIRS HALIDE_LIBRARIES)
+endif()
diff --git a/cmake/OpenCVDetectMediaSDK.cmake b/cmake/OpenCVDetectMediaSDK.cmake
new file mode 100644
index 0000000..bc0b2ed
--- /dev/null
+++ b/cmake/OpenCVDetectMediaSDK.cmake
@@ -0,0 +1,38 @@
+set(root "$ENV{MFX_HOME}")
+
+find_path(MFX_INCLUDE mfxdefs.h PATHS "${root}/include" NO_DEFAULT_PATH)
+
+# TODO: ICC? MINGW? ARM? IOS?
+if(WIN32)
+ if(X86_64)
+ set(arch "x64")
+ else()
+ set(arch "win32")
+ endif()
+elseif(UNIX)
+ set(arch "lin_x64")
+else()
+ # ???
+endif()
+
+find_library(MFX_LIBRARY mfx PATHS "${root}/lib/${arch}" NO_DEFAULT_PATH)
+find_library(MFX_VA_LIBRARY va)
+find_library(MFX_VA_DRM_LIBRARY va-drm)
+
+if(MFX_INCLUDE AND MFX_LIBRARY AND MFX_VA_LIBRARY AND MFX_VA_DRM_LIBRARY)
+ add_library(mfx-va UNKNOWN IMPORTED)
+ set_target_properties(mfx-va PROPERTIES IMPORTED_LOCATION "${MFX_VA_LIBRARY}")
+
+ add_library(mfx-va-drm UNKNOWN IMPORTED)
+ set_target_properties(mfx-va-drm PROPERTIES IMPORTED_LOCATION "${MFX_VA_DRM_LIBRARY}")
+
+ add_library(mfx UNKNOWN IMPORTED)
+ set_target_properties(mfx PROPERTIES
+ IMPORTED_LOCATION "${MFX_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${MFX_INCLUDE}"
+ INTERFACE_LINK_LIBRARIES "mfx-va;mfx-va-drm;-Wl,--exclude-libs=libmfx"
+ )
+ set(HAVE_MFX 1)
+else()
+ set(HAVE_MFX 0)
+endif()
diff --git a/cmake/OpenCVDetectTBB.cmake b/cmake/OpenCVDetectTBB.cmake
index 89e4970..426487a 100644
--- a/cmake/OpenCVDetectTBB.cmake
+++ b/cmake/OpenCVDetectTBB.cmake
@@ -68,7 +68,9 @@ endfunction()
if(BUILD_TBB)
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/tbb")
- message(STATUS "Found TBB: build")
+ if(NOT TARGET tbb)
+ return()
+ endif()
set(HAVE_TBB TRUE)
endif()
diff --git a/cmake/OpenCVDetectTrace.cmake b/cmake/OpenCVDetectTrace.cmake
new file mode 100644
index 0000000..07a8f64
--- /dev/null
+++ b/cmake/OpenCVDetectTrace.cmake
@@ -0,0 +1,13 @@
+if(WITH_ITT)
+ if(BUILD_ITT)
+ add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/ittnotify")
+ set(ITT_INCLUDE_DIR "${OpenCV_SOURCE_DIR}/3rdparty/ittnotify/include")
+ set(ITT_INCLUDE_DIRS "${ITT_INCLUDE_DIR}")
+ set(ITT_LIBRARIES "ittnotify")
+ set(HAVE_ITT 1)
+ else()
+ #TODO
+ endif()
+endif()
+
+set(OPENCV_TRACE 1)
diff --git a/cmake/OpenCVDownload.cmake b/cmake/OpenCVDownload.cmake
new file mode 100644
index 0000000..67a416c
--- /dev/null
+++ b/cmake/OpenCVDownload.cmake
@@ -0,0 +1,237 @@
+#
+# Download and optionally unpack a file
+#
+# ocv_download(FILENAME p HASH h URL u1 [u2 ...] DESTINATION_DIR d [ID id] [STATUS s] [UNPACK] [RELATIVE_URL])
+# FILENAME - filename
+# HASH - MD5 hash
+# URL - full download url (first nonempty value will be chosen)
+# DESTINATION_DIR - file will be copied to this directory
+# ID - identifier for project/group of downloaded files
+# STATUS - passed variable will be updated in parent scope,
+# function will not fail the build in case of download problem if this option is provided,
+# but will fail in case when other operations (copy, remove, etc.) failed
+# UNPACK - downloaded file will be unpacked to DESTINATION_DIR
+# RELATIVE_URL - if set, then URL is treated as a base, and FILENAME will be appended to it
+# Note: uses OPENCV_DOWNLOAD_PATH folder as cache, default is <opencv>/.cache
+
+set(HELP_OPENCV_DOWNLOAD_PATH "Cache directory for downloaded files")
+if(DEFINED ENV{OPENCV_DOWNLOAD_PATH})
+ set(OPENCV_DOWNLOAD_PATH "$ENV{OPENCV_DOWNLOAD_PATH}" CACHE PATH "${HELP_OPENCV_DOWNLOAD_PATH}")
+endif()
+set(OPENCV_DOWNLOAD_PATH "${OpenCV_SOURCE_DIR}/.cache" CACHE PATH "${HELP_OPENCV_DOWNLOAD_PATH}")
+set(OPENCV_DOWNLOAD_LOG "${OpenCV_BINARY_DIR}/CMakeDownloadLog.txt")
+
+# Init download cache directory and log file
+if(NOT EXISTS "${OPENCV_DOWNLOAD_PATH}")
+ file(MAKE_DIRECTORY ${OPENCV_DOWNLOAD_PATH})
+endif()
+if(NOT EXISTS "${OPENCV_DOWNLOAD_PATH}/.gitignore")
+ file(WRITE "${OPENCV_DOWNLOAD_PATH}/.gitignore" "*\n")
+endif()
+file(WRITE "${OPENCV_DOWNLOAD_LOG}" "use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
+
+
+function(ocv_download)
+ cmake_parse_arguments(DL "UNPACK;RELATIVE_URL" "FILENAME;HASH;DESTINATION_DIR;ID;STATUS" "URL" ${ARGN})
+
+ macro(ocv_download_log)
+ file(APPEND "${OPENCV_DOWNLOAD_LOG}" "${ARGN}\n")
+ endmacro()
+
+ ocv_assert(DL_FILENAME)
+ ocv_assert(DL_HASH)
+ ocv_assert(DL_URL)
+ ocv_assert(DL_DESTINATION_DIR)
+ if((NOT " ${DL_UNPARSED_ARGUMENTS}" STREQUAL " ")
+ OR DL_FILENAME STREQUAL ""
+ OR DL_HASH STREQUAL ""
+ OR DL_URL STREQUAL ""
+ OR DL_DESTINATION_DIR STREQUAL ""
+ )
+ set(msg_level FATAL_ERROR)
+ if(DEFINED DL_STATUS)
+ set(${DL_STATUS} FALSE PARENT_SCOPE)
+ set(msg_level WARNING)
+ endif()
+ message(${msg_level} "ERROR: ocv_download() unsupported arguments: ${ARGV}")
+ return()
+ endif()
+
+ if(DEFINED DL_STATUS)
+ set(${DL_STATUS} TRUE PARENT_SCOPE)
+ endif()
+
+ # Check CMake cache for already processed tasks
+ string(FIND "${DL_DESTINATION_DIR}" "${CMAKE_BINARY_DIR}" DL_BINARY_PATH_POS)
+ if(DL_BINARY_PATH_POS EQUAL 0)
+ set(__file_id "${DL_DESTINATION_DIR}/${DL_FILENAME}")
+ file(RELATIVE_PATH __file_id "${CMAKE_BINARY_DIR}" "${__file_id}")
+ string(REGEX REPLACE "[^a-zA-Z0-9_]" "_" __file_id "${__file_id}")
+ if(DL_ID)
+ string(TOUPPER ${DL_ID} __id)
+ string(REGEX REPLACE "[^a-zA-Z0-9_]" "_" __id "${__id}")
+ set(OCV_DOWNLOAD_HASH_NAME "OCV_DOWNLOAD_${__id}_HASH_${__file_id}")
+ else()
+ set(OCV_DOWNLOAD_HASH_NAME "OCV_DOWNLOAD_HASH_${__file_id}")
+ endif()
+ if(" ${${OCV_DOWNLOAD_HASH_NAME}}" STREQUAL " ${DL_HASH}")
+ ocv_download_log("#match_hash_in_cmake_cache \"${OCV_DOWNLOAD_HASH_NAME}\"")
+ return()
+ endif()
+ unset("${OCV_DOWNLOAD_HASH_NAME}" CACHE)
+ else()
+ set(OCV_DOWNLOAD_HASH_NAME "")
+ #message(WARNING "Download destination is not in CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}: ${DL_DESTINATION_DIR}")
+ endif()
+
+ # Select first non-empty url
+ foreach(url ${DL_URL})
+ if(url)
+ set(DL_URL "${url}")
+ break()
+ endif()
+ endforeach()
+
+ # Append filename to url if needed
+ if(DL_RELATIVE_URL)
+ set(DL_URL "${DL_URL}${DL_FILENAME}")
+ endif()
+
+ set(mode "copy")
+ if(DL_UNPACK)
+ set(mode "unpack")
+ endif()
+
+ # Log all calls to file
+ ocv_download_log("do_${mode} \"${DL_FILENAME}\" \"${DL_HASH}\" \"${DL_URL}\" \"${DL_DESTINATION_DIR}\"")
+ # ... and to console
+ set(__msg_prefix "")
+ if(DL_ID)
+ set(__msg_prefix "${DL_ID}: ")
+ endif()
+ message(STATUS "${__msg_prefix}Download: ${DL_FILENAME}")
+
+ # Copy mode: check if copy destination exists and is correct
+ if(NOT DL_UNPACK)
+ set(COPY_DESTINATION "${DL_DESTINATION_DIR}/${DL_FILENAME}")
+ if(EXISTS "${COPY_DESTINATION}")
+ ocv_download_log("#check_md5 \"${COPY_DESTINATION}\"")
+ file(MD5 "${COPY_DESTINATION}" target_md5)
+ if(target_md5 STREQUAL DL_HASH)
+ ocv_download_log("#match_md5 \"${COPY_DESTINATION}\" \"${target_md5}\"")
+ if(OCV_DOWNLOAD_HASH_NAME)
+ set(${OCV_DOWNLOAD_HASH_NAME} "${DL_HASH}" CACHE INTERNAL "")
+ endif()
+ return()
+ endif()
+ ocv_download_log("#mismatch_md5 \"${COPY_DESTINATION}\" \"${target_md5}\"")
+ else()
+ ocv_download_log("#missing \"${COPY_DESTINATION}\"")
+ endif()
+ endif()
+
+ # Check cache first
+ if(DL_ID)
+ string(TOLOWER "${DL_ID}" __id)
+ string(REGEX REPLACE "[^a-zA-Z0-9_/ ]" "_" __id "${__id}")
+ set(CACHE_CANDIDATE "${OPENCV_DOWNLOAD_PATH}/${__id}/${DL_HASH}-${DL_FILENAME}")
+ else()
+ set(CACHE_CANDIDATE "${OPENCV_DOWNLOAD_PATH}/${DL_HASH}-${DL_FILENAME}")
+ endif()
+ if(EXISTS "${CACHE_CANDIDATE}")
+ ocv_download_log("#check_md5 \"${CACHE_CANDIDATE}\"")
+ file(MD5 "${CACHE_CANDIDATE}" target_md5)
+ if(NOT target_md5 STREQUAL DL_HASH)
+ ocv_download_log("#mismatch_md5 \"${CACHE_CANDIDATE}\" \"${target_md5}\"")
+ ocv_download_log("#delete \"${CACHE_CANDIDATE}\"")
+ file(REMOVE ${CACHE_CANDIDATE})
+ endif()
+ endif()
+
+ # Download
+ if(NOT EXISTS "${CACHE_CANDIDATE}")
+ ocv_download_log("#cmake_download \"${CACHE_CANDIDATE}\" \"${DL_URL}\"")
+ file(DOWNLOAD "${DL_URL}" "${CACHE_CANDIDATE}"
+ INACTIVITY_TIMEOUT 60
+ TIMEOUT 600
+ STATUS status
+ LOG __log)
+ string(LENGTH "${__log}" __log_length)
+ if(__log_length LESS 65536)
+ string(REPLACE "\n" "\n# " __log "${__log}")
+ ocv_download_log("# ${__log}\n")
+ endif()
+ if(NOT status EQUAL 0)
+ set(msg_level FATAL_ERROR)
+ if(DEFINED DL_STATUS)
+ set(${DL_STATUS} FALSE PARENT_SCOPE)
+ set(msg_level WARNING)
+ endif()
+ if(status MATCHES "Couldn't resolve host name")
+ message(STATUS "
+=======================================================================
+ Couldn't download files from the Internet.
+ Please check the Internet access on this host.
+=======================================================================
+")
+ elseif(status MATCHES "Couldn't connect to server")
+ message(STATUS "
+=======================================================================
+ Couldn't connect to server from the Internet.
+ Perhaps direct connections are not allowed in the current network.
+ To use proxy please check/specify these environment variables:
+ - http_proxy/https_proxy
+ - and/or HTTP_PROXY/HTTPS_PROXY
+=======================================================================
+")
+ endif()
+ message(${msg_level} "${__msg_prefix}Download failed: ${status}
+For details please refer to the download log file:
+${OPENCV_DOWNLOAD_LOG}
+")
+ return()
+ endif()
+
+ # Don't remove this code, because EXPECTED_MD5 parameter doesn't fail "file(DOWNLOAD)" step on wrong hash
+ ocv_download_log("#check_md5 \"${CACHE_CANDIDATE}\"")
+ file(MD5 "${CACHE_CANDIDATE}" target_md5)
+ if(NOT target_md5 STREQUAL DL_HASH)
+ ocv_download_log("#mismatch_md5 \"${CACHE_CANDIDATE}\" \"${target_md5}\"")
+ set(msg_level FATAL_ERROR)
+ if(DEFINED DL_STATUS)
+ set(${DL_STATUS} FALSE PARENT_SCOPE)
+ set(msg_level WARNING)
+ endif()
+ message(${msg_level} "${__msg_prefix}Hash mismatch: ${target_md5}")
+ return()
+ endif()
+ endif()
+
+ # Unpack or copy
+ if(DL_UNPACK)
+ if(EXISTS "${DL_DESTINATION_DIR}")
+ ocv_download_log("#remove_unpack \"${DL_DESTINATION_DIR}\"")
+ file(REMOVE_RECURSE "${DL_DESTINATION_DIR}")
+ endif()
+ ocv_download_log("#mkdir \"${DL_DESTINATION_DIR}\"")
+ file(MAKE_DIRECTORY "${DL_DESTINATION_DIR}")
+ ocv_download_log("#unpack \"${DL_DESTINATION_DIR}\" \"${CACHE_CANDIDATE}\"")
+ execute_process(COMMAND "${CMAKE_COMMAND}" -E tar xz "${CACHE_CANDIDATE}"
+ WORKING_DIRECTORY "${DL_DESTINATION_DIR}"
+ RESULT_VARIABLE res)
+ if(NOT res EQUAL 0)
+ message(FATAL_ERROR "${__msg_prefix}Unpack failed: ${res}")
+ endif()
+ else()
+ ocv_download_log("#copy \"${COPY_DESTINATION}\" \"${CACHE_CANDIDATE}\"")
+ execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CACHE_CANDIDATE}" "${COPY_DESTINATION}"
+ RESULT_VARIABLE res)
+ if(NOT res EQUAL 0)
+ message(FATAL_ERROR "${__msg_prefix}Copy failed: ${res}")
+ endif()
+ endif()
+
+ if(OCV_DOWNLOAD_HASH_NAME)
+ set(${OCV_DOWNLOAD_HASH_NAME} "${DL_HASH}" CACHE INTERNAL "")
+ endif()
+endfunction()
diff --git a/cmake/OpenCVFindIPP.cmake b/cmake/OpenCVFindIPP.cmake
index 6913052..04b17f7 100644
--- a/cmake/OpenCVFindIPP.cmake
+++ b/cmake/OpenCVFindIPP.cmake
@@ -35,7 +35,7 @@ unset(IPP_VERSION_MINOR)
unset(IPP_VERSION_BUILD)
if (X86 AND UNIX AND NOT APPLE AND NOT ANDROID AND BUILD_SHARED_LIBS)
- message(STATUS "On 32-bit Linux IPP can not currently be used with dynamic libs because of linker errors. Set BUILD_SHARED_LIBS=OFF")
+ message(STATUS "On 32-bit Linux Intel IPP can not currently be used with dynamic libs because of linker errors. Set BUILD_SHARED_LIBS=OFF")
return()
endif()
@@ -47,14 +47,14 @@ if(CMAKE_CL_64)
set(IPP_X64 1)
endif()
-# This function detects IPP version by analyzing .h file
+# This function detects Intel IPP version by analyzing .h file
macro(ipp_get_version VERSION_FILE)
unset(_VERSION_STR)
unset(_MAJOR)
unset(_MINOR)
unset(_BUILD)
- # read IPP version info from file
+ # read Intel IPP version info from file
file(STRINGS ${VERSION_FILE} STR1 REGEX "IPP_VERSION_MAJOR")
file(STRINGS ${VERSION_FILE} STR2 REGEX "IPP_VERSION_MINOR")
file(STRINGS ${VERSION_FILE} STR3 REGEX "IPP_VERSION_BUILD")
@@ -96,29 +96,29 @@ macro(ipp_detect_version)
elseif(EXISTS ${IPP_ROOT_DIR}/include/ipp.h)
# nothing
else()
- _ipp_not_supported("Can't resolve IPP directory: ${IPP_ROOT_DIR}")
+ _ipp_not_supported("Can't resolve Intel IPP directory: ${IPP_ROOT_DIR}")
endif()
ipp_get_version(${IPP_INCLUDE_DIRS}/ippversion.h)
ocv_assert(IPP_VERSION_STR VERSION_GREATER "1.0")
- message(STATUS "found IPP${__msg}: ${_MAJOR}.${_MINOR}.${_BUILD} [${IPP_VERSION_STR}]")
+ message(STATUS "found Intel IPP${__msg}: ${_MAJOR}.${_MINOR}.${_BUILD} [${IPP_VERSION_STR}]")
message(STATUS "at: ${IPP_ROOT_DIR}")
if(${IPP_VERSION_STR} VERSION_LESS "7.0")
- _ipp_not_supported("IPP ${IPP_VERSION_STR} is not supported")
+ _ipp_not_supported("Intel IPP ${IPP_VERSION_STR} is not supported")
endif()
set(HAVE_IPP 1)
macro(_ipp_set_library_dir DIR)
if(NOT EXISTS ${DIR})
- _ipp_not_supported("IPP library directory not found")
+ _ipp_not_supported("Intel IPP library directory not found")
endif()
set(IPP_LIBRARY_DIR ${DIR})
endmacro()
- if(APPLE)
+ if(APPLE AND NOT HAVE_IPP_ICV_ONLY)
_ipp_set_library_dir(${IPP_ROOT_DIR}/lib)
elseif(IPP_X64)
_ipp_set_library_dir(${IPP_ROOT_DIR}/lib/intel64)
@@ -127,17 +127,22 @@ macro(ipp_detect_version)
endif()
macro(_ipp_add_library name)
- # dynamic linking is only supported for standalone version of IPP
+ # dynamic linking is only supported for standalone version of Intel IPP
if (BUILD_WITH_DYNAMIC_IPP AND NOT HAVE_IPP_ICV_ONLY)
- set(IPP_LIB_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX})
- set(IPP_LIB_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
+ if (WIN32)
+ set(IPP_LIB_PREFIX ${CMAKE_IMPORT_LIBRARY_PREFIX})
+ set(IPP_LIB_SUFFIX ${CMAKE_IMPORT_LIBRARY_SUFFIX})
+ else (WIN32)
+ set(IPP_LIB_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX})
+ set(IPP_LIB_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
+ endif (WIN32)
else ()
set(IPP_LIB_PREFIX ${CMAKE_STATIC_LIBRARY_PREFIX})
set(IPP_LIB_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX})
endif ()
if (EXISTS ${IPP_LIBRARY_DIR}/${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX})
if (BUILD_WITH_DYNAMIC_IPP AND NOT HAVE_IPP_ICV_ONLY)
- # When using dynamic libraries from standalone IPP it is your responsibility to install those on the target system
+ # When using dynamic libraries from standalone Intel IPP it is your responsibility to install those on the target system
list(APPEND IPP_LIBRARIES ${IPP_LIBRARY_DIR}/${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX})
else ()
add_library(ipp${name} STATIC IMPORTED)
@@ -156,47 +161,46 @@ macro(ipp_detect_version)
endif()
endif()
else()
- message(STATUS "Can't find IPP library: ${name} at ${IPP_LIBRARY_DIR}/${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX}")
+ message(STATUS "Can't find Intel IPP library: ${name} at ${IPP_LIBRARY_DIR}/${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX}")
endif()
endmacro()
set(IPP_PREFIX "ipp")
if(${IPP_VERSION_STR} VERSION_LESS "8.0")
if (BUILD_WITH_DYNAMIC_IPP AND NOT HAVE_IPP_ICV_ONLY)
- set(IPP_SUFFIX "") # dynamic not threaded libs suffix IPP 7.x
+ set(IPP_SUFFIX "") # dynamic not threaded libs suffix Intel IPP 7.x
else ()
- set(IPP_SUFFIX "_l") # static not threaded libs suffix IPP 7.x
+ set(IPP_SUFFIX "_l") # static not threaded libs suffix Intel IPP 7.x
endif ()
else ()
if(WIN32)
if (BUILD_WITH_DYNAMIC_IPP AND NOT HAVE_IPP_ICV_ONLY)
- set(IPP_SUFFIX "") # dynamic not threaded libs suffix IPP 8.x for Windows
+ set(IPP_SUFFIX "") # dynamic not threaded libs suffix Intel IPP 8.x for Windows
else ()
- set(IPP_SUFFIX "mt") # static not threaded libs suffix IPP 8.x for Windows
+ set(IPP_SUFFIX "mt") # static not threaded libs suffix Intel IPP 8.x for Windows
endif ()
else()
- set(IPP_SUFFIX "") # static not threaded libs suffix IPP 8.x for Linux/OS X
+ set(IPP_SUFFIX "") # static not threaded libs suffix Intel IPP 8.x for Linux/OS X
endif()
endif()
if(HAVE_IPP_ICV_ONLY)
_ipp_add_library(icv)
else()
- _ipp_add_library(core)
- _ipp_add_library(s)
+ _ipp_add_library(cv)
_ipp_add_library(i)
_ipp_add_library(cc)
- _ipp_add_library(cv)
+ _ipp_add_library(s)
_ipp_add_library(vm)
- _ipp_add_library(m)
+ _ipp_add_library(core)
- if(UNIX)
+ if(UNIX AND IPP_VERSION_MAJOR LESS 2017)
get_filename_component(INTEL_COMPILER_LIBRARY_DIR ${IPP_ROOT_DIR}/../lib REALPATH)
if(NOT EXISTS ${INTEL_COMPILER_LIBRARY_DIR})
get_filename_component(INTEL_COMPILER_LIBRARY_DIR ${IPP_ROOT_DIR}/../compiler/lib REALPATH)
endif()
if(NOT EXISTS ${INTEL_COMPILER_LIBRARY_DIR})
- _ipp_not_supported("IPP configuration error: can't find Intel compiler library dir ${INTEL_COMPILER_LIBRARY_DIR}")
+ _ipp_not_supported("Intel IPP configuration error: can't find Intel compiler library dir ${INTEL_COMPILER_LIBRARY_DIR}")
endif()
if(NOT APPLE)
if(IPP_X64)
@@ -223,27 +227,21 @@ macro(ipp_detect_version)
_ipp_add_compiler_library(irc)
_ipp_add_compiler_library(imf)
_ipp_add_compiler_library(svml)
- endif(UNIX)
+ endif()
endif()
- #message(STATUS "IPP libs: ${IPP_LIBRARIES}")
+ #message(STATUS "Intel IPP libs: ${IPP_LIBRARIES}")
endmacro()
# OPENCV_IPP_PATH is an environment variable for internal usage only, do not use it
if(DEFINED ENV{OPENCV_IPP_PATH} AND NOT DEFINED IPPROOT)
set(IPPROOT "$ENV{OPENCV_IPP_PATH}")
endif()
+
if(NOT DEFINED IPPROOT)
- if(IOS AND NOT x86_64)
- # 2016/10: There is an issue with MacOS binary .a file.
- # It is fat multiarch library, and can't be "merged" multiple times.
- # So try to ignore i386 version
- return()
- endif()
- include("${OpenCV_SOURCE_DIR}/3rdparty/ippicv/downloader.cmake")
- if(DEFINED OPENCV_ICV_PATH)
- set(IPPROOT "${OPENCV_ICV_PATH}")
- else()
+ include("${OpenCV_SOURCE_DIR}/3rdparty/ippicv/ippicv.cmake")
+ download_ippicv(IPPROOT)
+ if(NOT IPPROOT)
return()
endif()
endif()
@@ -256,7 +254,7 @@ endif()
if(WIN32 AND MINGW AND NOT IPP_VERSION_MAJOR LESS 7)
- # Since IPP built with Microsoft compiler and /GS option
+ # Since Intel IPP built with Microsoft compiler and /GS option
# ======================================================
# From Windows SDK 7.1
# (usually in "C:\Program Files\Microsoft Visual Studio 10.0\VC\lib"),
diff --git a/cmake/OpenCVFindIPPIW.cmake b/cmake/OpenCVFindIPPIW.cmake
new file mode 100644
index 0000000..c7927f5
--- /dev/null
+++ b/cmake/OpenCVFindIPPIW.cmake
@@ -0,0 +1,169 @@
+#
+# The script to detect Intel(R) Integrated Performance Primitives Integration Wrappers (IPP IW)
+# installation/package
+#
+#
+# On return this will define:
+#
+# HAVE_IPP_IW - True if Intel IPP found
+# IPP_IW_PATH - Root of Intel IPP IW directory
+# IPP_IW_LIBRARIES - Intel IPP IW libraries
+# IPP_IW_INCLUDES - Intel IPP IW include folder
+#
+
+unset(HAVE_IPP_IW CACHE)
+unset(IPP_IW_PATH)
+unset(IPP_IW_LIBRARIES)
+unset(IPP_IW_INCLUDES)
+unset(IW_CONFIG_DEBUG)
+#set(IW_CONFIG_DEBUG 1)
+
+if(NOT HAVE_IPP)
+ return()
+endif()
+
+macro(ippiw_debugmsg MESSAGE)
+ if(DEFINED IW_CONFIG_DEBUG)
+ message(STATUS "${MESSAGE}")
+ endif()
+endmacro()
+
+# This function detects Intel IPP IW version by analyzing .h file
+macro(ippiw_setup PATH BUILD)
+ set(FILE "${PATH}/include/iw/iw_version.h")
+ ippiw_debugmsg("Checking path: ${PATH}")
+ if(EXISTS "${FILE}")
+ ippiw_debugmsg("vfile\tok")
+ file(STRINGS "${FILE}" IW_VERSION_MAJOR REGEX "IW_VERSION_MAJOR")
+ file(STRINGS "${FILE}" IW_VERSION_MINOR REGEX "IW_VERSION_MINOR")
+ file(STRINGS "${FILE}" IW_VERSION_UPDATE REGEX "IW_VERSION_UPDATE")
+
+ file(STRINGS "${FILE}" IW_MIN_COMPATIBLE_IPP_MAJOR REGEX "IW_MIN_COMPATIBLE_IPP_MAJOR")
+ file(STRINGS "${FILE}" IW_MIN_COMPATIBLE_IPP_MINOR REGEX "IW_MIN_COMPATIBLE_IPP_MINOR")
+ file(STRINGS "${FILE}" IW_MIN_COMPATIBLE_IPP_UPDATE REGEX "IW_MIN_COMPATIBLE_IPP_UPDATE")
+
+ string(REGEX MATCH "[0-9]+" IW_MIN_COMPATIBLE_IPP_MAJOR ${IW_MIN_COMPATIBLE_IPP_MAJOR})
+ string(REGEX MATCH "[0-9]+" IW_MIN_COMPATIBLE_IPP_MINOR ${IW_MIN_COMPATIBLE_IPP_MINOR})
+ string(REGEX MATCH "[0-9]+" IW_MIN_COMPATIBLE_IPP_UPDATE ${IW_MIN_COMPATIBLE_IPP_UPDATE})
+
+ string(REGEX MATCH "[0-9]+" IW_VERSION_MAJOR ${IW_VERSION_MAJOR})
+ string(REGEX MATCH "[0-9]+" IW_VERSION_MINOR ${IW_VERSION_MINOR})
+ string(REGEX MATCH "[0-9]+" IW_VERSION_UPDATE ${IW_VERSION_UPDATE})
+
+ math(EXPR IPP_VERSION_EXP "${IPP_VERSION_MAJOR}*10000 + ${IPP_VERSION_MINOR}*100 + ${IPP_VERSION_BUILD}")
+ math(EXPR IW_MIN_COMPATIBLE_IPP_EXP "${IW_MIN_COMPATIBLE_IPP_MAJOR}*10000 + ${IW_MIN_COMPATIBLE_IPP_MINOR}*100 + ${IW_MIN_COMPATIBLE_IPP_UPDATE}")
+
+ if((IPP_VERSION_EXP GREATER IW_MIN_COMPATIBLE_IPP_EXP) OR (IPP_VERSION_EXP EQUAL IW_MIN_COMPATIBLE_IPP_EXP))
+ ippiw_debugmsg("version\tok")
+ if(${BUILD})
+ # check sources
+ if(EXISTS "${PATH}/src/iw_core.c")
+ ippiw_debugmsg("sources\tok")
+ set(IPP_IW_PATH "${PATH}")
+ message(STATUS "found Intel IPP IW sources: ${IW_VERSION_MAJOR}.${IW_VERSION_MINOR}.${IW_VERSION_UPDATE}")
+ message(STATUS "at: ${IPP_IW_PATH}")
+
+ set(IPP_IW_LIBRARY ippiw)
+ set(IPP_IW_INCLUDES "${IPP_IW_PATH}/include")
+ set(IPP_IW_LIBRARIES ${IPP_IW_LIBRARY})
+ execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OpenCV_SOURCE_DIR}/3rdparty/ippicv/CMakeLists.txt" "${IPP_IW_PATH}/")
+ add_subdirectory("${IPP_IW_PATH}/" ${OpenCV_BINARY_DIR}/3rdparty/ippiw)
+
+ set(HAVE_IPP_IW 1)
+ return()
+ endif()
+ else()
+ # check binaries
+ if(IPP_X64)
+ set(FILE "${PATH}/lib/intel64/${CMAKE_STATIC_LIBRARY_PREFIX}ipp_iw${CMAKE_STATIC_LIBRARY_SUFFIX}")
+ else()
+ set(FILE "${PATH}/lib/ia32/${CMAKE_STATIC_LIBRARY_PREFIX}ipp_iw${CMAKE_STATIC_LIBRARY_SUFFIX}")
+ endif()
+ if(EXISTS ${FILE})
+ ippiw_debugmsg("binaries\tok (64=${IPP_X64})")
+ set(IPP_IW_PATH "${PATH}")
+ message(STATUS "found Intel IPP IW binaries: ${IW_VERSION_MAJOR}.${IW_VERSION_MINOR}.${IW_VERSION_UPDATE}")
+ message(STATUS "at: ${IPP_IW_PATH}")
+
+ add_library(ippiw STATIC IMPORTED)
+ set_target_properties(ippiw PROPERTIES
+ IMPORTED_LINK_INTERFACE_LIBRARIES ""
+ IMPORTED_LOCATION "${FILE}"
+ )
+ if (NOT BUILD_SHARED_LIBS)
+ # CMake doesn't support "install(TARGETS ${name} ...)" command with imported targets
+ install(FILES "${FILE}"
+ DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
+ set(IPPIW_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/${OPENCV_3P_LIB_INSTALL_PATH}/${CMAKE_STATIC_LIBRARY_PREFIX}ipp_iw${CMAKE_STATIC_LIBRARY_SUFFIX}" CACHE INTERNAL "" FORCE)
+ set(IPPIW_LOCATION_PATH "${FILE}" CACHE INTERNAL "" FORCE)
+ endif()
+
+ set(IPP_IW_INCLUDES "${IPP_IW_PATH}/include")
+ set(IPP_IW_LIBRARIES ippiw)
+
+ set(HAVE_IPP_IW 1)
+ set(BUILD_IPP_IW 0)
+ return()
+ endif()
+ endif()
+ endif()
+ endif()
+ set(HAVE_IPP_IW 0)
+endmacro()
+
+# check os and architecture
+if(APPLE)
+ set(IW_PACKAGE_SUBDIR "ippiw_mac")
+elseif((UNIX AND NOT ANDROID) OR (UNIX AND ANDROID_ABI MATCHES "x86"))
+ set(IW_PACKAGE_SUBDIR "ippiw_lnx")
+elseif(WIN32 AND NOT ARM)
+ set(IW_PACKAGE_SUBDIR "ippiw_win")
+else()
+ message(SEND_ERROR "Improper system for Intel IPP Integrations Wrappers. This message shouldn't appear. Check Intel IPP configurations steps")
+ return()
+endif()
+
+# check build options first
+if(BUILD_IPP_IW)
+ # custom path
+ if(DEFINED IPPIWROOT)
+ ippiw_setup("${IPPIWROOT}/" 1)
+ message(STATUS "Can't find Intel IPP IW sources at: ${IPPIWROOT}")
+ endif()
+
+ # local sources
+ ippiw_setup("${OpenCV_SOURCE_DIR}/3rdparty/ippiw" 1)
+
+ # Package sources
+ ippiw_setup("${IPPROOT}/../${IW_PACKAGE_SUBDIR}/" 1)
+endif()
+
+
+# custom binaries
+if(DEFINED IPPIWROOT)
+ ippiw_setup("${IPPIWROOT}/" 0)
+ message(STATUS "Can't find Intel IPP IW sources at: ${IPPIWROOT}")
+endif()
+
+# check binaries in IPP folder
+ippiw_setup("${IPPROOT}/" 0)
+
+# check binaries near IPP folder
+ippiw_setup("${IPPROOT}/../${IW_PACKAGE_SUBDIR}/" 0)
+
+
+# take Intel IPP IW from ICV package
+if(NOT HAVE_IPP_ICV_ONLY AND BUILD_IPP_IW)
+ message(STATUS "Cannot find Intel IPP IW. Checking \"Intel IPP for OpenCV\" package")
+ set(TEMP_ROOT 0)
+ include("${OpenCV_SOURCE_DIR}/3rdparty/ippicv/ippicv.cmake")
+ download_ippicv(TEMP_ROOT)
+
+ # Package sources. Only sources are compatible with regular Intel IPP
+ ippiw_setup("${TEMP_ROOT}/../${IW_PACKAGE_SUBDIR}/" 1)
+endif()
+
+
+set(HAVE_IPP_IW 0)
+message(STATUS "Cannot find Intel IPP Integration Wrappers, optimizations will be limited. Use IPPIWROOT to set custom location")
+return()
diff --git a/cmake/OpenCVFindLAPACK.cmake b/cmake/OpenCVFindLAPACK.cmake
index dfacf24..e281b4b 100644
--- a/cmake/OpenCVFindLAPACK.cmake
+++ b/cmake/OpenCVFindLAPACK.cmake
@@ -1,78 +1,164 @@
-macro(_find_file_in_dirs VAR NAME DIRS)
- find_path(${VAR} ${NAME} ${DIRS} NO_DEFAULT_PATH)
- set(${VAR} ${${VAR}}/${NAME})
- unset(${VAR} CACHE)
+macro(_find_header_file_in_dirs VAR NAME)
+ unset(${VAR})
+ unset(${VAR} CACHE)
+ if(" ${ARGN}" STREQUAL " ")
+ check_include_file("${NAME}" HAVE_${VAR})
+ if(HAVE_${VAR})
+ set(${VAR} "${NAME}") # fallback
+ else()
+ set(${VAR} "")
+ endif()
+ else()
+ find_path(${VAR} "${NAME}" ${ARGN} NO_DEFAULT_PATH)
+ if(${VAR})
+ set(${VAR} "${${VAR}}/${NAME}")
+ unset(${VAR} CACHE)
+ else()
+ unset(${VAR} CACHE)
+ set(${VAR} "")
+ endif()
+ endif()
+endmacro()
+
+macro(ocv_lapack_check)
+ string(REGEX REPLACE "[^a-zA-Z0-9_]" "_" _lapack_impl "${LAPACK_IMPL}")
+ message(STATUS "LAPACK(${LAPACK_IMPL}): LAPACK_LIBRARIES: ${LAPACK_LIBRARIES}")
+ _find_header_file_in_dirs(OPENCV_CBLAS_H_PATH_${_lapack_impl} "${LAPACK_CBLAS_H}" "${LAPACK_INCLUDE_DIR}")
+ _find_header_file_in_dirs(OPENCV_LAPACKE_H_PATH_${_lapack_impl} "${LAPACK_LAPACKE_H}" "${LAPACK_INCLUDE_DIR}")
+ if(NOT OPENCV_CBLAS_H_PATH_${_lapack_impl} OR NOT OPENCV_LAPACKE_H_PATH_${_lapack_impl})
+ message(WARNING "LAPACK(${LAPACK_IMPL}): CBLAS/LAPACK headers are not found in '${LAPACK_INCLUDE_DIR}'")
+ unset(LAPACK_LIBRARIES)
+ else()
+ # adding proxy opencv_lapack.h header
+ set(CBLAS_H_PROXY_PATH ${CMAKE_BINARY_DIR}/opencv_lapack.h)
+ set(_lapack_include_str "\#include \"${OPENCV_CBLAS_H_PATH_${_lapack_impl}}\"")
+ if(NOT "${OPENCV_CBLAS_H_PATH_${_lapack_impl}}" STREQUAL "${OPENCV_LAPACKE_H_PATH_${_lapack_impl}}")
+ set(_lapack_include_str "${_lapack_include_str}\n#include \"${OPENCV_LAPACKE_H_PATH_${_lapack_impl}}\"")
+ endif()
+ # update file contents (if required)
+ set(__content_str "")
+ if(EXISTS "${CBLAS_H_PROXY_PATH}")
+ file(READ "${CBLAS_H_PROXY_PATH}" __content_str)
+ endif()
+ if(NOT " ${__content_str}" STREQUAL " ${_lapack_include_str}")
+ file(WRITE "${CBLAS_H_PROXY_PATH}" "${_lapack_include_str}")
+ endif()
+
+ try_compile(__VALID_LAPACK
+ "${OpenCV_BINARY_DIR}"
+ "${OpenCV_SOURCE_DIR}/cmake/checks/lapack_check.cpp"
+ CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${LAPACK_INCLUDE_DIR}\;${CMAKE_BINARY_DIR}"
+ "-DLINK_DIRECTORIES:STRING=${LAPACK_LINK_LIBRARIES}"
+ "-DLINK_LIBRARIES:STRING=${LAPACK_LIBRARIES}"
+ OUTPUT_VARIABLE TRY_OUT
+ )
+ if(NOT __VALID_LAPACK)
+ #message(FATAL_ERROR "LAPACK: check build log:\n${TRY_OUT}")
+ message(STATUS "LAPACK(${LAPACK_IMPL}): Can't build LAPACK check code. This LAPACK version is not supported.")
+ unset(LAPACK_LIBRARIES)
+ else()
+ message(STATUS "LAPACK(${LAPACK_IMPL}): Support is enabled.")
+ ocv_include_directories(${LAPACK_INCLUDE_DIR})
+ set(HAVE_LAPACK 1)
+ endif()
+ endif()
endmacro()
if(WITH_LAPACK)
- ocv_update(LAPACK_IMPL "Unknown")
- if(NOT LAPACK_LIBRARIES)
- include(cmake/OpenCVFindMKL.cmake)
- if(HAVE_MKL)
- set(LAPACK_INCLUDE_DIR ${MKL_INCLUDE_DIRS})
- set(LAPACK_LIBRARIES ${MKL_LIBRARIES} )
- set(LAPACK_CBLAS_H "mkl_cblas.h" )
- set(LAPACK_LAPACKE_H "mkl_lapack.h" )
- set(LAPACK_IMPL "MKL")
- endif()
+ ocv_update(LAPACK_IMPL "Unknown")
+ if(NOT OPENCV_LAPACK_FIND_PACKAGE_ONLY)
+ if(NOT LAPACK_LIBRARIES AND NOT OPENCV_LAPACK_DISABLE_MKL)
+ include(cmake/OpenCVFindMKL.cmake)
+ if(HAVE_MKL)
+ set(LAPACK_INCLUDE_DIR ${MKL_INCLUDE_DIRS})
+ set(LAPACK_LIBRARIES ${MKL_LIBRARIES})
+ set(LAPACK_CBLAS_H "mkl_cblas.h")
+ set(LAPACK_LAPACKE_H "mkl_lapack.h")
+ set(LAPACK_IMPL "MKL")
+ ocv_lapack_check()
+ endif()
endif()
if(NOT LAPACK_LIBRARIES)
- include(cmake/OpenCVFindOpenBLAS.cmake)
- if(OpenBLAS_FOUND)
- set(LAPACK_INCLUDE_DIR ${OpenBLAS_INCLUDE_DIR} )
- set(LAPACK_LIBRARIES ${OpenBLAS_LIB} )
- set(LAPACK_CBLAS_H "cblas.h" )
- set(LAPACK_LAPACKE_H "lapacke.h" )
- set(LAPACK_IMPL "OpenBLAS")
- endif()
+ include(cmake/OpenCVFindOpenBLAS.cmake)
+ if(OpenBLAS_FOUND)
+ set(LAPACK_INCLUDE_DIR ${OpenBLAS_INCLUDE_DIR})
+ set(LAPACK_LIBRARIES ${OpenBLAS_LIB})
+ set(LAPACK_CBLAS_H "cblas.h")
+ set(LAPACK_LAPACKE_H "lapacke.h")
+ set(LAPACK_IMPL "OpenBLAS")
+ ocv_lapack_check()
+ endif()
endif()
if(NOT LAPACK_LIBRARIES AND UNIX)
- include(cmake/OpenCVFindAtlas.cmake)
- if(ATLAS_FOUND)
- set(LAPACK_INCLUDE_DIR ${Atlas_INCLUDE_DIR})
- set(LAPACK_LIBRARIES ${Atlas_LIBRARIES} )
- set(LAPACK_CBLAS_H "cblas.h" )
- set(LAPACK_LAPACKE_H "lapacke.h" )
- set(LAPACK_IMPL "Atlas")
- endif()
+ include(cmake/OpenCVFindAtlas.cmake)
+ if(ATLAS_FOUND)
+ set(LAPACK_INCLUDE_DIR ${Atlas_INCLUDE_DIR})
+ set(LAPACK_LIBRARIES ${Atlas_LIBRARIES})
+ set(LAPACK_CBLAS_H "cblas.h")
+ set(LAPACK_LAPACKE_H "lapacke.h")
+ set(LAPACK_IMPL "Atlas")
+ ocv_lapack_check()
+ endif()
endif()
+ endif()
- if(NOT LAPACK_LIBRARIES AND APPLE)
- set(LAPACK_INCLUDE_DIR "Accelerate")
- set(LAPACK_LIBRARIES "-framework Accelerate")
- set(LAPACK_CBLAS_H "cblas.h" )
- set(LAPACK_LAPACKE_H "lapacke.h" )
- set(LAPACK_IMPL "Apple")
+ if(NOT LAPACK_LIBRARIES)
+ if(WIN32 AND NOT OPENCV_LAPACK_SHARED_LIBS)
+ set(BLA_STATIC 1)
+ endif()
+ find_package(LAPACK)
+ if(LAPACK_FOUND)
+ if(NOT DEFINED LAPACKE_INCLUDE_DIR)
+ find_path(LAPACKE_INCLUDE_DIR "lapacke.h")
+ endif()
+ if(NOT DEFINED MKL_LAPACKE_INCLUDE_DIR)
+ find_path(MKL_LAPACKE_INCLUDE_DIR "mkl_lapack.h")
+ endif()
+ if(MKL_LAPACKE_INCLUDE_DIR AND NOT OPENCV_LAPACK_DISABLE_MKL)
+ set(LAPACK_INCLUDE_DIR ${MKL_LAPACKE_INCLUDE_DIR})
+ set(LAPACK_CBLAS_H "mkl_cblas.h")
+ set(LAPACK_LAPACKE_H "mkl_lapack.h")
+ set(LAPACK_IMPL "LAPACK/MKL")
+ ocv_lapack_check()
+ endif()
+ if(LAPACKE_INCLUDE_DIR AND NOT HAVE_LAPACK)
+ set(LAPACK_INCLUDE_DIR ${LAPACKE_INCLUDE_DIR})
+ set(LAPACK_CBLAS_H "cblas.h")
+ set(LAPACK_LAPACKE_H "lapacke.h")
+ set(LAPACK_IMPL "LAPACK/Generic")
+ ocv_lapack_check()
+ elseif(APPLE)
+ set(LAPACK_CBLAS_H "Accelerate/Accelerate.h")
+ set(LAPACK_LAPACKE_H "Accelerate/Accelerate.h")
+ set(LAPACK_IMPL "LAPACK/Apple")
+ ocv_lapack_check()
+ else()
+ unset(LAPACK_LIBRARIES)
+ unset(LAPACK_LIBRARIES CACHE)
+ endif()
+ else()
+ # LAPACK not found
+ unset(LAPACK_LIBRARIES)
+ unset(LAPACK_LIBRARIES CACHE)
endif()
+ endif()
- set(LAPACK_INCLUDE_DIR ${LAPACK_INCLUDE_DIR} CACHE PATH "Path to BLAS include dir" FORCE)
- set(LAPACK_CBLAS_H ${LAPACK_CBLAS_H} CACHE STRING "Alternative name of cblas.h" FORCE)
- set(LAPACK_LAPACKE_H ${LAPACK_LAPACKE_H} CACHE STRING "Alternative name of lapacke.h" FORCE)
- set(LAPACK_LIBRARIES ${LAPACK_LIBRARIES} CACHE STRING "Names of BLAS & LAPACK binaries (.so, .dll, .a, .lib)" FORCE)
- set(LAPACK_IMPL ${LAPACK_IMPL} CACHE STRING "Lapack implementation id" FORCE)
+ if(NOT LAPACK_LIBRARIES AND APPLE AND NOT OPENCV_LAPACK_FIND_PACKAGE_ONLY)
+ set(LAPACK_INCLUDE_DIR "")
+ set(LAPACK_LIBRARIES "-framework Accelerate")
+ set(LAPACK_CBLAS_H "Accelerate/Accelerate.h")
+ set(LAPACK_LAPACKE_H "Accelerate/Accelerate.h")
+ set(LAPACK_IMPL "Apple")
+ ocv_lapack_check()
+ endif()
- if(LAPACK_LIBRARIES) #adding proxy cblas.h header
- message(STATUS "LAPACK_IMPL: ${LAPACK_IMPL}, LAPACK_LIBRARIES: ${LAPACK_LIBRARIES}")
- if("${LAPACK_IMPL}" STREQUAL "Apple")
- set(CBLAS_H_PATH "Accelerate/Accelerate.h")
- set(LAPACKE_H_PATH "Accelerate/Accelerate.h")
- else()
- _find_file_in_dirs(CBLAS_H_PATH "${LAPACK_CBLAS_H}" "${LAPACK_INCLUDE_DIR}")
- _find_file_in_dirs(LAPACKE_H_PATH "${LAPACK_LAPACKE_H}" "${LAPACK_INCLUDE_DIR}")
- endif()
- if(NOT CBLAS_H_PATH OR NOT LAPACKE_H_PATH)
- message(WARNING "CBLAS/LAPACK headers are not found in '${LAPACK_INCLUDE_DIR}'")
- endif()
- ocv_include_directories(${LAPACK_INCLUDE_DIR})
- list(APPEND OPENCV_LINKER_LIBS ${LAPACK_LIBRARIES})
- set(HAVE_LAPACK 1)
+ if(NOT HAVE_LAPACK AND LAPACK_LIBRARIES AND LAPACK_CBLAS_H AND LAPACK_LAPACKE_H)
+ ocv_lapack_check()
+ endif()
- set(CBLAS_H_PROXY_PATH ${CMAKE_BINARY_DIR}/opencv_lapack.h)
- set(_include_str "\#include \"${CBLAS_H_PATH}\"")
- if("${CBLAS_H_PATH}" STREQUAL "${LAPACKE_H_PATH}")
- else()
- set(_include_str "${_include_str}\n\#include \"${LAPACKE_H_PATH}\"")
- endif()
- file(WRITE ${CBLAS_H_PROXY_PATH} ${_include_str})
- endif()
+ set(LAPACK_INCLUDE_DIR ${LAPACK_INCLUDE_DIR} CACHE PATH "Path to BLAS include dir" FORCE)
+ set(LAPACK_CBLAS_H ${LAPACK_CBLAS_H} CACHE STRING "Alternative name of cblas.h" FORCE)
+ set(LAPACK_LAPACKE_H ${LAPACK_LAPACKE_H} CACHE STRING "Alternative name of lapacke.h" FORCE)
+ set(LAPACK_LIBRARIES ${LAPACK_LIBRARIES} CACHE STRING "Names of BLAS & LAPACK binaries (.so, .dll, .a, .lib)" FORCE)
+ set(LAPACK_IMPL ${LAPACK_IMPL} CACHE STRING "Lapack implementation id" FORCE)
endif()
diff --git a/cmake/OpenCVFindLibProtobuf.cmake b/cmake/OpenCVFindLibProtobuf.cmake
new file mode 100644
index 0000000..b6ce1e7
--- /dev/null
+++ b/cmake/OpenCVFindLibProtobuf.cmake
@@ -0,0 +1,33 @@
+# By default, we use protobuf sources from 3rdparty subdirectory and pre-generated .proto files
+# Note: In case of .proto model updates these variables should be used:
+# - Protobuf_PROTOC_EXECUTABLE (required)
+# - Protobuf_INCLUDE_DIRS
+# - Protobuf_LIBRARIES or Protobuf_LIBRARY / Protobuf_LIBRARY_DEBUG for find_package()
+OCV_OPTION(BUILD_PROTOBUF "Force to build libprotobuf from sources" ON)
+OCV_OPTION(PROTOBUF_UPDATE_FILES "Force to rebuild .proto files" OFF)
+
+if(PROTOBUF_UPDATE_FILES)
+ if(NOT DEFINED Protobuf_PROTOC_EXECUTABLE)
+ find_package(Protobuf QUIET)
+ endif()
+ if(DEFINED Protobuf_PROTOC_EXECUTABLE AND EXISTS ${Protobuf_PROTOC_EXECUTABLE})
+ message(STATUS "The protocol buffer compiler is found (${Protobuf_PROTOC_EXECUTABLE})")
+ else()
+ message(FATAL_ERROR "The protocol buffer compiler is not found (Protobuf_PROTOC_EXECUTABLE='${Protobuf_PROTOC_EXECUTABLE}')")
+ endif()
+endif()
+
+if(NOT BUILD_PROTOBUF AND NOT (DEFINED Protobuf_INCLUDE_DIRS AND DEFINED Protobuf_LIBRARIES))
+ find_package(Protobuf QUIET)
+endif()
+
+if(Protobuf_FOUND)
+ # nothing
+else()
+ set(Protobuf_LIBRARIES libprotobuf)
+ set(Protobuf_INCLUDE_DIRS "${OpenCV_SOURCE_DIR}/3rdparty/protobuf/src")
+ if(NOT TARGET ${Protobuf_LIBRARIES})
+ add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/protobuf" "${OpenCV_BINARY_DIR}/3rdparty/protobuf")
+ endif()
+ set(Protobuf_FOUND 1)
+endif()
diff --git a/cmake/OpenCVFindLibsGUI.cmake b/cmake/OpenCVFindLibsGUI.cmake
index 1c13619..f58b3de 100644
--- a/cmake/OpenCVFindLibsGUI.cmake
+++ b/cmake/OpenCVFindLibsGUI.cmake
@@ -42,24 +42,24 @@ endif()
ocv_clear_vars(HAVE_GTK HAVE_GTK3 HAVE_GTHREAD HAVE_GTKGLEXT)
if(WITH_GTK AND NOT HAVE_QT)
if(NOT WITH_GTK_2_X)
- CHECK_MODULE(gtk+-3.0 HAVE_GTK3)
+ CHECK_MODULE(gtk+-3.0 HAVE_GTK3 HIGHGUI)
if(HAVE_GTK3)
set(HAVE_GTK TRUE)
endif()
endif()
if(NOT HAVE_GTK)
- CHECK_MODULE(gtk+-2.0 HAVE_GTK)
+ CHECK_MODULE(gtk+-2.0 HAVE_GTK HIGHGUI)
if(HAVE_GTK AND (ALIASOF_gtk+-2.0_VERSION VERSION_LESS MIN_VER_GTK))
message (FATAL_ERROR "GTK support requires a minimum version of ${MIN_VER_GTK} (${ALIASOF_gtk+-2.0_VERSION} found)")
set(HAVE_GTK FALSE)
endif()
endif()
- CHECK_MODULE(gthread-2.0 HAVE_GTHREAD)
+ CHECK_MODULE(gthread-2.0 HAVE_GTHREAD HIGHGUI)
if(HAVE_GTK AND NOT HAVE_GTHREAD)
message(FATAL_ERROR "gthread not found. This library is required when building with GTK support")
endif()
if(WITH_OPENGL AND NOT HAVE_GTK3)
- CHECK_MODULE(gtkglext-1.0 HAVE_GTKGLEXT)
+ CHECK_MODULE(gtkglext-1.0 HAVE_GTKGLEXT HIGHGUI)
endif()
endif()
diff --git a/cmake/OpenCVFindLibsGrfmt.cmake b/cmake/OpenCVFindLibsGrfmt.cmake
index cc82575..e555d1f 100644
--- a/cmake/OpenCVFindLibsGrfmt.cmake
+++ b/cmake/OpenCVFindLibsGrfmt.cmake
@@ -96,17 +96,23 @@ if(WITH_WEBP)
ocv_clear_vars(WEBP_FOUND WEBP_LIBRARY WEBP_LIBRARIES WEBP_INCLUDE_DIR)
else()
include(cmake/OpenCVFindWebP.cmake)
+ if(WEBP_FOUND)
+ set(HAVE_WEBP 1)
+ endif()
endif()
endif()
# --- Add libwebp to 3rdparty/libwebp and compile it if not available ---
-if(WITH_WEBP AND NOT WEBP_FOUND)
+if(WITH_WEBP AND NOT WEBP_FOUND
+ AND (NOT ANDROID OR HAVE_CPUFEATURES)
+)
set(WEBP_LIBRARY libwebp)
set(WEBP_LIBRARIES ${WEBP_LIBRARY})
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libwebp")
set(WEBP_INCLUDE_DIR "${${WEBP_LIBRARY}_SOURCE_DIR}")
+ set(HAVE_WEBP 1)
endif()
if(NOT WEBP_VERSION AND WEBP_INCLUDE_DIR)
diff --git a/cmake/OpenCVFindLibsPerf.cmake b/cmake/OpenCVFindLibsPerf.cmake
index 70b6cf5..143d9b1 100644
--- a/cmake/OpenCVFindLibsPerf.cmake
+++ b/cmake/OpenCVFindLibsPerf.cmake
@@ -2,31 +2,6 @@
# Detect other 3rd-party performance and math libraries
# ----------------------------------------------------------------------------
-# --- Lapack ---
-# if(WITH_LAPACK)
-# if(WIN32)
-# set(BLA_STATIC 1)
-# endif()
-# find_package(LAPACK)
-# if(LAPACK_FOUND)
-# find_path(LAPACKE_INCLUDE_DIR "lapacke.h")
-# find_path(MKL_LAPACKE_INCLUDE_DIR "mkl_lapack.h")
-# if(LAPACKE_INCLUDE_DIR)
-# ocv_include_directories(${LAPACKE_INCLUDE_DIR})
-# set(HAVE_LAPACK 1)
-# set(HAVE_LAPACK_GENERIC 1)
-# elseif(MKL_LAPACKE_INCLUDE_DIR)
-# ocv_include_directories(${MKL_LAPACKE_INCLUDE_DIR})
-# set(HAVE_LAPACK 1)
-# set(HAVE_LAPACK_MKL 1)
-# elseif(APPLE)
-# set(HAVE_LAPACK 1)
-# set(HAVE_LAPACK_APPLE 1)
-# endif()
-# list(APPEND OPENCV_LINKER_LIBS ${LAPACK_LIBRARIES})
-# endif()
-# endif()
-
# --- TBB ---
if(WITH_TBB)
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectTBB.cmake")
@@ -36,6 +11,11 @@ endif(WITH_TBB)
if(WITH_IPP)
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindIPP.cmake")
if(HAVE_IPP)
+ include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindIPPIW.cmake")
+ if(HAVE_IPP_IW)
+ ocv_include_directories(${IPP_IW_INCLUDES})
+ list(APPEND OPENCV_LINKER_LIBS ${IPP_IW_LIBRARIES})
+ endif()
ocv_include_directories(${IPP_INCLUDE_DIRS})
list(APPEND OPENCV_LINKER_LIBS ${IPP_LIBRARIES})
endif()
diff --git a/cmake/OpenCVFindLibsVideo.cmake b/cmake/OpenCVFindLibsVideo.cmake
index 1eff03b..062b165 100644
--- a/cmake/OpenCVFindLibsVideo.cmake
+++ b/cmake/OpenCVFindLibsVideo.cmake
@@ -27,11 +27,11 @@ if(WITH_GSTREAMER AND NOT WITH_GSTREAMER_0_10)
ENDIF(GSTREAMER_gstbase_LIBRARY AND GSTREAMER_gstvideo_LIBRARY AND GSTREAMER_gstapp_LIBRARY AND GSTREAMER_gstpbutils_LIBRARY AND GSTREAMER_gstriff_LIBRARY)
else(WIN32)
- CHECK_MODULE(gstreamer-base-1.0 HAVE_GSTREAMER_BASE)
- CHECK_MODULE(gstreamer-video-1.0 HAVE_GSTREAMER_VIDEO)
- CHECK_MODULE(gstreamer-app-1.0 HAVE_GSTREAMER_APP)
- CHECK_MODULE(gstreamer-riff-1.0 HAVE_GSTREAMER_RIFF)
- CHECK_MODULE(gstreamer-pbutils-1.0 HAVE_GSTREAMER_PBUTILS)
+ CHECK_MODULE(gstreamer-base-1.0 HAVE_GSTREAMER_BASE VIDEOIO)
+ CHECK_MODULE(gstreamer-video-1.0 HAVE_GSTREAMER_VIDEO VIDEOIO)
+ CHECK_MODULE(gstreamer-app-1.0 HAVE_GSTREAMER_APP VIDEOIO)
+ CHECK_MODULE(gstreamer-riff-1.0 HAVE_GSTREAMER_RIFF VIDEOIO)
+ CHECK_MODULE(gstreamer-pbutils-1.0 HAVE_GSTREAMER_PBUTILS VIDEOIO)
if(HAVE_GSTREAMER_BASE AND HAVE_GSTREAMER_VIDEO AND HAVE_GSTREAMER_APP AND HAVE_GSTREAMER_RIFF AND HAVE_GSTREAMER_PBUTILS)
set(HAVE_GSTREAMER TRUE)
@@ -46,11 +46,11 @@ endif(WITH_GSTREAMER AND NOT WITH_GSTREAMER_0_10)
# if gstreamer 1.x was not found, or we specified we wanted 0.10, try to find it
if(WITH_GSTREAMER AND NOT HAVE_GSTREAMER OR WITH_GSTREAMER_0_10)
- CHECK_MODULE(gstreamer-base-0.10 HAVE_GSTREAMER_BASE)
- CHECK_MODULE(gstreamer-video-0.10 HAVE_GSTREAMER_VIDEO)
- CHECK_MODULE(gstreamer-app-0.10 HAVE_GSTREAMER_APP)
- CHECK_MODULE(gstreamer-riff-0.10 HAVE_GSTREAMER_RIFF)
- CHECK_MODULE(gstreamer-pbutils-0.10 HAVE_GSTREAMER_PBUTILS)
+ CHECK_MODULE(gstreamer-base-0.10 HAVE_GSTREAMER_BASE VIDEOIO)
+ CHECK_MODULE(gstreamer-video-0.10 HAVE_GSTREAMER_VIDEO VIDEOIO)
+ CHECK_MODULE(gstreamer-app-0.10 HAVE_GSTREAMER_APP VIDEOIO)
+ CHECK_MODULE(gstreamer-riff-0.10 HAVE_GSTREAMER_RIFF VIDEOIO)
+ CHECK_MODULE(gstreamer-pbutils-0.10 HAVE_GSTREAMER_PBUTILS VIDEOIO)
if(HAVE_GSTREAMER_BASE AND HAVE_GSTREAMER_VIDEO AND HAVE_GSTREAMER_APP AND HAVE_GSTREAMER_RIFF AND HAVE_GSTREAMER_PBUTILS)
set(HAVE_GSTREAMER TRUE)
@@ -65,8 +65,8 @@ endif(WITH_GSTREAMER AND NOT HAVE_GSTREAMER OR WITH_GSTREAMER_0_10)
# --- unicap ---
ocv_clear_vars(HAVE_UNICAP)
if(WITH_UNICAP)
- CHECK_MODULE(libunicap HAVE_UNICAP_)
- CHECK_MODULE(libucil HAVE_UNICAP_UCIL)
+ CHECK_MODULE(libunicap HAVE_UNICAP_ VIDEOIO)
+ CHECK_MODULE(libucil HAVE_UNICAP_UCIL VIDEOIO)
if(HAVE_UNICAP_ AND HAVE_UNICAP_UCIL)
set(HAVE_UNICAP TRUE)
endif()
@@ -127,13 +127,18 @@ endif(WITH_GIGEAPI)
# --- Aravis SDK ---
ocv_clear_vars(HAVE_ARAVIS_API)
if(WITH_ARAVIS)
- find_path(ARAVIS_INCLUDE_PATH "arv.h"
- PATHS /usr/local /var /opt /usr ENV ProgramFiles ENV ProgramW6432
- PATH_SUFFIXES include "aravis-0.6" "aravis-0.4"
- DOC "The path to Aravis SDK headers")
- find_library(ARAVIS_LIBRARIES NAMES "aravis-0.6" "aravis-0.4" )
- if(ARAVIS_LIBRARIES AND ARAVIS_INCLUDE_PATH)
- set(HAVE_ARAVIS_API TRUE)
+ check_module(glib-2.0 HAVE_ARAVIS_GLIB VIDEOIO)
+ if(HAVE_ARAVIS_GLIB)
+ find_path(ARAVIS_INCLUDE_PATH "arv.h"
+ PATHS /usr/local /var /opt /usr ENV ProgramFiles ENV ProgramW6432
+ PATH_SUFFIXES include "aravis-0.6" "aravis-0.4"
+ DOC "The path to Aravis SDK headers")
+ find_library(ARAVIS_LIBRARIES NAMES "aravis-0.6" "aravis-0.4" )
+ if(ARAVIS_LIBRARIES AND ARAVIS_INCLUDE_PATH)
+ set(HAVE_ARAVIS_API TRUE)
+ endif()
+ else()
+ message("Can not build Aravis support without glib2")
endif()
endif(WITH_ARAVIS)
@@ -162,9 +167,9 @@ if(WITH_1394)
"${CMU1394_LIB_DIR}/lib1394camera.a")
endif(HAVE_DC1394_2)
else(WIN32 AND MINGW)
- CHECK_MODULE(libdc1394-2 HAVE_DC1394_2)
+ CHECK_MODULE(libdc1394-2 HAVE_DC1394_2 VIDEOIO)
if(NOT HAVE_DC1394_2)
- CHECK_MODULE(libdc1394 HAVE_DC1394)
+ CHECK_MODULE(libdc1394 HAVE_DC1394 VIDEOIO)
endif()
endif(WIN32 AND MINGW)
endif(WITH_1394)
@@ -172,15 +177,15 @@ endif(WITH_1394)
# --- xine ---
ocv_clear_vars(HAVE_XINE)
if(WITH_XINE)
- CHECK_MODULE(libxine HAVE_XINE)
+ CHECK_MODULE(libxine HAVE_XINE VIDEOIO)
endif(WITH_XINE)
# --- V4L ---
ocv_clear_vars(HAVE_LIBV4L HAVE_CAMV4L HAVE_CAMV4L2 HAVE_VIDEOIO)
if(WITH_V4L)
if(WITH_LIBV4L)
- CHECK_MODULE(libv4l1 HAVE_LIBV4L1)
- CHECK_MODULE(libv4l2 HAVE_LIBV4L2)
+ CHECK_MODULE(libv4l1 HAVE_LIBV4L1 VIDEOIO)
+ CHECK_MODULE(libv4l2 HAVE_LIBV4L2 VIDEOIO)
if(HAVE_LIBV4L1 AND HAVE_LIBV4L2)
set(HAVE_LIBV4L YES)
else()
@@ -217,7 +222,11 @@ ocv_clear_vars(HAVE_FFMPEG)
if(WITH_FFMPEG)
if(WIN32 AND NOT ARM)
include("${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/ffmpeg.cmake")
- set(HAVE_FFMPEG TRUE)
+ download_win_ffmpeg(FFMPEG_CMAKE_SCRIPT)
+ if(FFMPEG_CMAKE_SCRIPT)
+ set(HAVE_FFMPEG TRUE)
+ include("${FFMPEG_CMAKE_SCRIPT}")
+ endif()
elseif(PKG_CONFIG_FOUND)
ocv_check_modules(FFMPEG libavcodec libavformat libavutil libswscale)
ocv_check_modules(FFMPEG_libavresample libavresample)
@@ -248,8 +257,11 @@ endif(WITH_FFMPEG)
# --- VideoInput/DirectShow ---
if(WITH_DSHOW)
- # always have VideoInput on Windows
- set(HAVE_DSHOW 1)
+ if(MSVC_VERSION GREATER 1499)
+ set(HAVE_DSHOW 1)
+ elseif(NOT HAVE_DSHOW)
+ check_include_file(DShow.h HAVE_DSHOW)
+ endif()
endif(WITH_DSHOW)
# --- VideoInput/Microsoft Media Foundation ---
@@ -290,10 +302,14 @@ if(WITH_INTELPERC)
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindIntelPerCSDK.cmake")
endif(WITH_INTELPERC)
+if(WITH_MFX)
+ include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectMediaSDK.cmake")
+endif()
+
# --- gPhoto2 ---
ocv_clear_vars(HAVE_GPHOTO2)
if(WITH_GPHOTO2)
- CHECK_MODULE(libgphoto2 HAVE_GPHOTO2)
+ CHECK_MODULE(libgphoto2 HAVE_GPHOTO2 VIDEOIO)
endif(WITH_GPHOTO2)
# --- VA & VA_INTEL ---
diff --git a/cmake/OpenCVFindMKL.cmake b/cmake/OpenCVFindMKL.cmake
index f43ce9c..d920672 100644
--- a/cmake/OpenCVFindMKL.cmake
+++ b/cmake/OpenCVFindMKL.cmake
@@ -7,10 +7,10 @@
#
# On return this will define:
#
-# HAVE_MKL - True if Intel IPP found
-# MKL_ROOT_DIR - root of IPP installation
-# MKL_INCLUDE_DIRS - IPP include folder
-# MKL_LIBRARIES - IPP libraries that are used by OpenCV
+# HAVE_MKL - True if Intel MKL found
+# MKL_ROOT_DIR - root of MKL installation
+# MKL_INCLUDE_DIRS - MKL include folder
+# MKL_LIBRARIES - MKL libraries that are used by OpenCV
#
macro (mkl_find_lib VAR NAME DIRS)
@@ -20,10 +20,8 @@ macro (mkl_find_lib VAR NAME DIRS)
endmacro()
macro(mkl_fail)
- set(HAVE_MKL OFF CACHE BOOL "True if MKL found")
- set(MKL_ROOT_DIR ${MKL_ROOT_DIR} CACHE PATH "Path to MKL directory")
- unset(MKL_INCLUDE_DIRS CACHE)
- unset(MKL_LIBRARIES CACHE)
+ set(HAVE_MKL OFF)
+ set(MKL_ROOT_DIR "${MKL_ROOT_DIR}" CACHE PATH "Path to MKL directory")
return()
endmacro()
@@ -48,27 +46,35 @@ if(NOT DEFINED MKL_USE_MULTITHREAD)
endif()
#check current MKL_ROOT_DIR
-if(NOT MKL_ROOT_DIR OR NOT EXISTS ${MKL_ROOT_DIR}/include/mkl.h)
- set(mkl_root_paths ${MKL_ROOT_DIR})
- if(DEFINED $ENV{MKLROOT})
- list(APPEND mkl_root_paths $ENV{MKLROOT})
+if(NOT MKL_ROOT_DIR OR NOT EXISTS "${MKL_ROOT_DIR}/include/mkl.h")
+ set(mkl_root_paths "${MKL_ROOT_DIR}")
+ if(DEFINED ENV{MKLROOT})
+ list(APPEND mkl_root_paths "$ENV{MKLROOT}")
endif()
- if(WIN32)
+
+ if(WITH_MKL AND NOT mkl_root_paths)
+ if(WIN32)
set(ProgramFilesx86 "ProgramFiles(x86)")
list(APPEND mkl_root_paths $ENV{${ProgramFilesx86}}/IntelSWTools/compilers_and_libraries/windows/mkl)
- endif()
- if(UNIX)
+ endif()
+ if(UNIX)
list(APPEND mkl_root_paths "/opt/intel/mkl")
+ endif()
endif()
find_path(MKL_ROOT_DIR include/mkl.h PATHS ${mkl_root_paths})
endif()
-if(NOT MKL_ROOT_DIR)
+set(MKL_INCLUDE_DIRS "${MKL_ROOT_DIR}/include" CACHE PATH "Path to MKL include directory")
+
+if(NOT MKL_ROOT_DIR
+ OR NOT EXISTS "${MKL_ROOT_DIR}"
+ OR NOT EXISTS "${MKL_INCLUDE_DIRS}"
+ OR NOT EXISTS "${MKL_INCLUDE_DIRS}/mkl_version.h"
+)
mkl_fail()
endif()
-set(MKL_INCLUDE_DIRS ${MKL_ROOT_DIR}/include)
get_mkl_version(${MKL_INCLUDE_DIRS}/mkl_version.h)
#determine arch
@@ -79,12 +85,13 @@ if(CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8)
include(CheckTypeSize)
CHECK_TYPE_SIZE(int _sizeof_int)
if (_sizeof_int EQUAL 4)
- set(MKL_LP64 "lp64")
+ set(MKL_ARCH_SUFFIX "lp64")
else()
- set(MKL_LP64 "ilp64")
+ set(MKL_ARCH_SUFFIX "ilp64")
endif()
else()
set(MKL_ARCH "ia32")
+ set(MKL_ARCH_SUFFIX "c")
endif()
if(${MKL_VERSION_STR} VERSION_GREATER "11.3.0" OR ${MKL_VERSION_STR} VERSION_EQUAL "11.3.0")
@@ -92,9 +99,7 @@ if(${MKL_VERSION_STR} VERSION_GREATER "11.3.0" OR ${MKL_VERSION_STR} VERSION_EQU
${MKL_ROOT_DIR}/lib
${MKL_ROOT_DIR}/lib/${MKL_ARCH} ${MKL_ROOT_DIR}/../tbb/lib/${MKL_ARCH})
- set(mkl_lib_list
- mkl_core
- mkl_intel_${MKL_LP64})
+ set(mkl_lib_list "mkl_intel_${MKL_ARCH_SUFFIX}")
if(MKL_WITH_TBB)
list(APPEND mkl_lib_list mkl_tbb_thread tbb)
@@ -102,17 +107,18 @@ if(${MKL_VERSION_STR} VERSION_GREATER "11.3.0" OR ${MKL_VERSION_STR} VERSION_EQU
if(MSVC)
list(APPEND mkl_lib_list mkl_intel_thread libiomp5md)
else()
- list(APPEND mkl_lib_list libmkl_gnu_thread)
+ list(APPEND mkl_lib_list mkl_gnu_thread)
endif()
else()
list(APPEND mkl_lib_list mkl_sequential)
endif()
+
+ list(APPEND mkl_lib_list mkl_core)
else()
message(STATUS "MKL version ${MKL_VERSION_STR} is not supported")
mkl_fail()
endif()
-
set(MKL_LIBRARIES "")
foreach(lib ${mkl_lib_list})
find_library(${lib} ${lib} ${mkl_lib_find_paths})
@@ -124,13 +130,11 @@ foreach(lib ${mkl_lib_list})
endforeach()
message(STATUS "Found MKL ${MKL_VERSION_STR} at: ${MKL_ROOT_DIR}")
-set(HAVE_MKL ON CACHE BOOL "True if MKL found")
-set(MKL_ROOT_DIR ${MKL_ROOT_DIR} CACHE PATH "Path to MKL directory")
-set(MKL_INCLUDE_DIRS ${MKL_INCLUDE_DIRS} CACHE PATH "Path to MKL include directory")
-if(NOT UNIX)
- set(MKL_LIBRARIES ${MKL_LIBRARIES} CACHE FILEPATH "MKL libarries")
-else()
+set(HAVE_MKL ON)
+set(MKL_ROOT_DIR "${MKL_ROOT_DIR}" CACHE PATH "Path to MKL directory")
+set(MKL_INCLUDE_DIRS "${MKL_INCLUDE_DIRS}" CACHE PATH "Path to MKL include directory")
+set(MKL_LIBRARIES "${MKL_LIBRARIES}" CACHE STRING "MKL libarries")
+if(UNIX AND NOT MKL_LIBRARIES_DONT_HACK)
#it's ugly but helps to avoid cyclic lib problem
set(MKL_LIBRARIES ${MKL_LIBRARIES} ${MKL_LIBRARIES} ${MKL_LIBRARIES} "-lpthread" "-lm" "-ldl")
- set(MKL_LIBRARIES ${MKL_LIBRARIES} CACHE STRING "MKL libarries")
-endif()
\ No newline at end of file
+endif()
diff --git a/cmake/OpenCVGenABI.cmake b/cmake/OpenCVGenABI.cmake
index 86aa78b..e9d6a33 100644
--- a/cmake/OpenCVGenABI.cmake
+++ b/cmake/OpenCVGenABI.cmake
@@ -33,10 +33,12 @@ foreach(mod ${OPENCV_MODULES_BUILD})
list(APPEND OPENCV_ABI_SKIP_HEADERS "${h}")
endforeach()
# libraries
- set(lib_name "")
- get_target_property(lib_name opencv_${mod} LOCATION)
- get_filename_component(lib_name "${lib_name}" NAME)
- list(APPEND OPENCV_ABI_SKIP_LIBRARIES "${lib_name}")
+ if(TARGET opencv_${mod}) # opencv_world
+ set(lib_name "")
+ get_target_property(lib_name opencv_${mod} LOCATION)
+ get_filename_component(lib_name "${lib_name}" NAME)
+ list(APPEND OPENCV_ABI_SKIP_LIBRARIES "${lib_name}")
+ endif()
endif()
endforeach()
string(REPLACE ";" "\n " OPENCV_ABI_SKIP_HEADERS "${OPENCV_ABI_SKIP_HEADERS}")
diff --git a/cmake/OpenCVGenConfig.cmake b/cmake/OpenCVGenConfig.cmake
index 206acfd..fb62638 100644
--- a/cmake/OpenCVGenConfig.cmake
+++ b/cmake/OpenCVGenConfig.cmake
@@ -45,12 +45,20 @@ export(TARGETS ${OpenCVModules_TARGETS} FILE "${CMAKE_BINARY_DIR}/OpenCVModules.
if(TARGET ippicv AND NOT BUILD_SHARED_LIBS)
set(USE_IPPICV TRUE)
- file(RELATIVE_PATH IPPICV_INSTALL_PATH_RELATIVE_CONFIGCMAKE ${CMAKE_BINARY_DIR} ${IPPICV_LOCATION_PATH})
+ file(RELATIVE_PATH IPPICV_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_BINARY_DIR}" "${IPPICV_LOCATION_PATH}")
ocv_cmake_configure("${CMAKE_CURRENT_LIST_DIR}/templates/OpenCVConfig-IPPICV.cmake.in" IPPICV_CONFIGCMAKE @ONLY)
else()
set(USE_IPPICV FALSE)
endif()
+if(TARGET ippiw AND NOT BUILD_SHARED_LIBS AND IPPIW_INSTALL_PATH)
+ set(USE_IPPIW TRUE)
+ file(RELATIVE_PATH IPPIW_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_BINARY_DIR}" "${IPPIW_LOCATION_PATH}")
+ ocv_cmake_configure("${CMAKE_CURRENT_LIST_DIR}/templates/OpenCVConfig-IPPIW.cmake.in" IPPIW_CONFIGCMAKE @ONLY)
+else()
+ set(USE_IPPIW FALSE)
+endif()
+
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig.cmake" @ONLY)
#support for version checking when finding opencv. find_package(OpenCV 2.3.1 EXACT) should now work.
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig-version.cmake" @ONLY)
@@ -62,9 +70,13 @@ file(RELATIVE_PATH OpenCV_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_INSTALL_PRE
set(OpenCV_INCLUDE_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_INSTALL_PATH}\" \"\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_INSTALL_PATH}/opencv\"")
if(USE_IPPICV)
- file(RELATIVE_PATH IPPICV_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}" ${IPPICV_INSTALL_PATH})
+ file(RELATIVE_PATH IPPICV_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}" "${IPPICV_INSTALL_PATH}")
ocv_cmake_configure("${CMAKE_CURRENT_LIST_DIR}/templates/OpenCVConfig-IPPICV.cmake.in" IPPICV_CONFIGCMAKE @ONLY)
endif()
+if(USE_IPPIW)
+ file(RELATIVE_PATH IPPIW_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}" "${IPPIW_INSTALL_PATH}")
+ ocv_cmake_configure("${CMAKE_CURRENT_LIST_DIR}/templates/OpenCVConfig-IPPIW.cmake.in" IPPIW_CONFIGCMAKE @ONLY)
+endif()
function(ocv_gen_config TMP_DIR NESTED_PATH ROOT_NAME)
ocv_path_join(__install_nested "${OPENCV_CONFIG_INSTALL_PATH}" "${NESTED_PATH}")
diff --git a/cmake/OpenCVGenHeaders.cmake b/cmake/OpenCVGenHeaders.cmake
index 2988979..477b910 100644
--- a/cmake/OpenCVGenHeaders.cmake
+++ b/cmake/OpenCVGenHeaders.cmake
@@ -3,6 +3,10 @@ configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/cvconfig.h.in" "${OPENCV_CO
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/cvconfig.h.in" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/cvconfig.h")
install(FILES "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h" DESTINATION ${OPENCV_INCLUDE_INSTALL_PATH}/opencv2 COMPONENT dev)
+# platform-specific config file
+ocv_compiler_optimization_fill_cpu_config()
+configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/cv_cpu_config.h.in" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cv_cpu_config.h")
+
# ----------------------------------------------------------------------------
# opencv_modules.hpp based on actual modules list
# ----------------------------------------------------------------------------
diff --git a/cmake/OpenCVGenInfoPlist.cmake b/cmake/OpenCVGenInfoPlist.cmake
index 2b78ae1..6dbdc5b 100644
--- a/cmake/OpenCVGenInfoPlist.cmake
+++ b/cmake/OpenCVGenInfoPlist.cmake
@@ -2,8 +2,13 @@ set(OPENCV_APPLE_BUNDLE_NAME "OpenCV")
set(OPENCV_APPLE_BUNDLE_ID "org.opencv")
if(IOS)
- configure_file("${OpenCV_SOURCE_DIR}/platforms/ios/Info.plist.in"
- "${CMAKE_BINARY_DIR}/ios/Info.plist")
+ if (APPLE_FRAMEWORK AND BUILD_SHARED_LIBS)
+ configure_file("${OpenCV_SOURCE_DIR}/platforms/ios/Info.Dynamic.plist.in"
+ "${CMAKE_BINARY_DIR}/ios/Info.plist")
+ else()
+ configure_file("${OpenCV_SOURCE_DIR}/platforms/ios/Info.plist.in"
+ "${CMAKE_BINARY_DIR}/ios/Info.plist")
+ endif()
elseif(APPLE)
configure_file("${OpenCV_SOURCE_DIR}/platforms/osx/Info.plist.in"
"${CMAKE_BINARY_DIR}/osx/Info.plist")
diff --git a/cmake/OpenCVMinDepVersions.cmake b/cmake/OpenCVMinDepVersions.cmake
index 44dbf6e..d2c5b7c 100644
--- a/cmake/OpenCVMinDepVersions.cmake
+++ b/cmake/OpenCVMinDepVersions.cmake
@@ -1,4 +1,4 @@
-set(MIN_VER_CMAKE 2.8.7)
+set(MIN_VER_CMAKE 2.8.12.2)
set(MIN_VER_CUDA 6.5)
set(MIN_VER_PYTHON2 2.6)
set(MIN_VER_PYTHON3 3.2)
diff --git a/cmake/OpenCVModule.cmake b/cmake/OpenCVModule.cmake
index 742a287..ea85e21 100644
--- a/cmake/OpenCVModule.cmake
+++ b/cmake/OpenCVModule.cmake
@@ -65,6 +65,7 @@ foreach(mod ${OPENCV_MODULES_BUILD} ${OPENCV_MODULES_DISABLED_USER} ${OPENCV_MOD
unset(OPENCV_MODULE_${mod}_PRIVATE_OPT_DEPS CACHE)
unset(OPENCV_MODULE_${mod}_LINK_DEPS CACHE)
unset(OPENCV_MODULE_${mod}_WRAPPERS CACHE)
+ unset(OPENCV_DEPENDANT_TARGETS_${mod} CACHE)
endforeach()
# clean modules info which needs to be recalculated
@@ -182,7 +183,7 @@ macro(ocv_add_module _name)
# add self to the world dependencies
if((NOT DEFINED OPENCV_MODULE_IS_PART_OF_WORLD
AND NOT OPENCV_MODULE_${the_module}_CLASS STREQUAL "BINDINGS"
- AND NOT OPENCV_PROCESSING_EXTRA_MODULES
+ AND (NOT OPENCV_PROCESSING_EXTRA_MODULES OR NOT OPENCV_WORLD_EXCLUDE_EXTRA_MODULES)
AND (NOT BUILD_SHARED_LIBS OR NOT "x${OPENCV_MODULE_TYPE}" STREQUAL "xSTATIC"))
OR OPENCV_MODULE_IS_PART_OF_WORLD
)
@@ -222,14 +223,20 @@ macro(ocv_add_module _name)
if(NOT BUILD_${the_module})
return() # extra protection from redefinition
endif()
- if((NOT OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD AND NOT ${the_module} STREQUAL opencv_world) OR NOT ${BUILD_opencv_world})
- project(${the_module})
+ if(NOT OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD OR NOT ${BUILD_opencv_world})
+ if (NOT ${the_module} STREQUAL opencv_world)
+ project(${the_module})
+ endif()
+ add_definitions(
+ -D_USE_MATH_DEFINES # M_PI constant in MSVS
+ -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS # to use C libraries from C++ code (ffmpeg)
+ )
endif()
endif()
endmacro()
# excludes module from current configuration
-macro(ocv_module_disable module)
+macro(ocv_module_disable_ module)
set(__modname ${module})
if(NOT __modname MATCHES "^opencv_")
set(__modname opencv_${module})
@@ -242,9 +249,12 @@ macro(ocv_module_disable module)
# touch variable controlling build of the module to suppress "unused variable" CMake warning
endif()
unset(__modname)
- return() # leave the current folder
endmacro()
+macro(ocv_module_disable module)
+ ocv_module_disable_(${module})
+ return() # leave the current folder
+endmacro()
# collect modules from specified directories
# NB: must be called only once!
@@ -306,6 +316,7 @@ macro(ocv_glob_modules)
set(OPENCV_INITIAL_PASS OFF)
if(${BUILD_opencv_world})
foreach(m ${OPENCV_MODULES_BUILD})
+ set(the_module "${m}")
if("${m}" STREQUAL opencv_world)
add_subdirectory("${OPENCV_MODULE_opencv_world_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/world")
elseif(NOT OPENCV_MODULE_${m}_IS_PART_OF_WORLD AND NOT ${m} STREQUAL opencv_world)
@@ -321,6 +332,7 @@ macro(ocv_glob_modules)
endforeach()
else()
foreach(m ${OPENCV_MODULES_BUILD})
+ set(the_module "${m}")
if(m MATCHES "^opencv_")
string(REGEX REPLACE "^opencv_" "" __shortname "${m}")
add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/${__shortname}")
@@ -638,6 +650,10 @@ macro(ocv_set_module_sources)
ocv_get_module_external_sources()
endif()
+ if(OPENCV_MODULE_${the_module}_SOURCES_DISPATCHED)
+ list(APPEND OPENCV_MODULE_${the_module}_SOURCES ${OPENCV_MODULE_${the_module}_SOURCES_DISPATCHED})
+ endif()
+
# use full paths for module to be independent from the module location
ocv_convert_to_full_paths(OPENCV_MODULE_${the_module}_HEADERS)
@@ -669,6 +685,8 @@ macro(ocv_glob_module_sources)
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.h"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/hal/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/hal/*.h"
+ "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/utils/*.hpp"
+ "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/utils/*.h"
)
file(GLOB lib_hdrs_detail
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/detail/*.hpp"
@@ -720,8 +738,10 @@ endmacro()
# ocv_create_module(<extra link dependencies>)
# ocv_create_module()
macro(ocv_create_module)
- ocv_debug_message("ocv_create_module(" ${ARGN} ")")
- set(OPENCV_MODULE_${the_module}_LINK_DEPS "${OPENCV_MODULE_${the_module}_LINK_DEPS};${ARGN}" CACHE INTERNAL "")
+ ocv_debug_message("${the_module}: ocv_create_module(" ${ARGN} ")")
+ if(NOT " ${ARGN}" STREQUAL " ")
+ set(OPENCV_MODULE_${the_module}_LINK_DEPS "${OPENCV_MODULE_${the_module}_LINK_DEPS};${ARGN}" CACHE INTERNAL "")
+ endif()
if(${BUILD_opencv_world} AND OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD)
# nothing
set(the_module_target opencv_world)
@@ -754,6 +774,11 @@ macro(ocv_create_module)
endmacro()
macro(_ocv_create_module)
+
+ ocv_compiler_optimization_process_sources(OPENCV_MODULE_${the_module}_SOURCES OPENCV_MODULE_${the_module}_DEPS_EXT ${the_module})
+ set(OPENCV_MODULE_${the_module}_HEADERS ${OPENCV_MODULE_${the_module}_HEADERS} CACHE INTERNAL "List of header files for ${the_module}")
+ set(OPENCV_MODULE_${the_module}_SOURCES ${OPENCV_MODULE_${the_module}_SOURCES} CACHE INTERNAL "List of source files for ${the_module}")
+
# The condition we ought to be testing here is whether ocv_add_precompiled_headers will
# be called at some point in the future. We can't look into the future, though,
# so this will have to do.
@@ -779,11 +804,37 @@ macro(_ocv_create_module)
endforeach()
endif()
+ if(WIN32
+ AND (BUILD_SHARED_LIBS AND NOT "x${OPENCV_MODULE_TYPE}" STREQUAL "xSTATIC")
+ AND NOT OPENCV_VS_VERSIONINFO_SKIP)
+ if(DEFINED OPENCV_VS_VERSIONINFO_FILE)
+ set(_VS_VERSION_FILE "${OPENCV_VS_VERSIONINFO_FILE}")
+ elseif(DEFINED OPENCV_VS_VERSIONINFO_${the_module}_FILE)
+ set(_VS_VERSION_FILE "${OPENCV_VS_VERSIONINFO_${the_module}_FILE}")
+ elseif(NOT OPENCV_VS_VERSIONINFO_SKIP_GENERATION)
+ set(_VS_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/vs_version.rc")
+ ocv_generate_vs_version_file("${_VS_VERSION_FILE}"
+ NAME "${the_module}"
+ FILEDESCRIPTION "OpenCV module: ${OPENCV_MODULE_${the_module}_DESCRIPTION}"
+ INTERNALNAME "${the_module}${OPENCV_DLLVERSION}"
+ ORIGINALFILENAME "${the_module}${OPENCV_DLLVERSION}.dll"
+ )
+ endif()
+ if(_VS_VERSION_FILE)
+ if(NOT EXISTS "${_VS_VERSION_FILE}")
+ message(STATUS "${the_module}: Required .rc file is missing: ${_VS_VERSION_FILE}")
+ endif()
+ source_group("Src" FILES "${_VS_VERSION_FILE}")
+ endif()
+ endif()
+
source_group("Include" FILES "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/opencv_modules.hpp")
source_group("Src" FILES "${${the_module}_pch}")
ocv_add_library(${the_module} ${OPENCV_MODULE_TYPE} ${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES}
"${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/opencv_modules.hpp"
- ${${the_module}_pch} ${sub_objs})
+ ${${the_module}_pch} ${sub_objs}
+ ${_VS_VERSION_FILE}
+ )
if (cuda_objs)
target_link_libraries(${the_module} ${cuda_objs})
@@ -849,10 +900,13 @@ macro(_ocv_create_module)
if((NOT DEFINED OPENCV_MODULE_TYPE AND BUILD_SHARED_LIBS)
OR (DEFINED OPENCV_MODULE_TYPE AND OPENCV_MODULE_TYPE STREQUAL SHARED))
- set_target_properties(${the_module} PROPERTIES COMPILE_DEFINITIONS CVAPI_EXPORTS)
set_target_properties(${the_module} PROPERTIES DEFINE_SYMBOL CVAPI_EXPORTS)
endif()
+ if (ENABLE_GNU_STL_DEBUG)
+ target_compile_definitions(${the_module} PUBLIC _GLIBCXX_DEBUG)
+ endif()
+
if(MSVC)
if(CMAKE_CROSSCOMPILING)
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:secchk")
@@ -879,7 +933,7 @@ macro(_ocv_create_module)
if(OPENCV_MODULE_${m}_HEADERS AND ";${OPENCV_MODULES_PUBLIC};" MATCHES ";${m};")
foreach(hdr ${OPENCV_MODULE_${m}_HEADERS})
string(REGEX REPLACE "^.*opencv2/" "opencv2/" hdr2 "${hdr}")
- if(NOT hdr2 MATCHES "opencv2/${m}/private.*" AND hdr2 MATCHES "^(opencv2/?.*)/[^/]+.h(..)?$" )
+ if(NOT hdr2 MATCHES "private" AND hdr2 MATCHES "^(opencv2/?.*)/[^/]+.h(..)?$" )
install(FILES ${hdr} OPTIONAL DESTINATION "${OPENCV_INCLUDE_INSTALL_PATH}/${CMAKE_MATCH_1}" COMPONENT dev)
endif()
endforeach()
@@ -1110,6 +1164,8 @@ function(ocv_add_accuracy_tests)
RUNTIME_OUTPUT_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}"
)
+ ocv_append_target_property(${the_target} COMPILE_DEFINITIONS "__OPENCV_TESTS=1")
+
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_target} PROPERTIES FOLDER "tests accuracy")
endif()
diff --git a/cmake/OpenCVPCHSupport.cmake b/cmake/OpenCVPCHSupport.cmake
index 90437cb..12e804d 100644
--- a/cmake/OpenCVPCHSupport.cmake
+++ b/cmake/OpenCVPCHSupport.cmake
@@ -65,6 +65,9 @@ MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
ocv_is_opencv_directory(__result ${item})
if(__result)
LIST(APPEND ${_out_compile_flags} "${_PCH_include_prefix}\"${item}\"")
+ elseif(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0" AND
+ item MATCHES "/usr/include$")
+ # workaround for GCC 6.x bug
else()
LIST(APPEND ${_out_compile_flags} "${_PCH_isystem_prefix}\"${item}\"")
endif()
@@ -75,6 +78,9 @@ MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
ocv_is_opencv_directory(__result ${item})
if(__result)
LIST(APPEND ${_out_compile_flags} "${_PCH_include_prefix}\"${item}\"")
+ elseif(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0" AND
+ item MATCHES "/usr/include$")
+ # workaround for GCC 6.x bug
else()
LIST(APPEND ${_out_compile_flags} "${_PCH_isystem_prefix}\"${item}\"")
endif()
@@ -91,8 +97,8 @@ MACRO(_PCH_WRITE_PCHDEP_CXX _targetName _include_file _dephelp)
set(${_dephelp} "${CMAKE_CURRENT_BINARY_DIR}/${_targetName}_pch_dephelp.cxx")
set(_content "")
- if(EXISTS "${_dephelp}")
- file(READ "${_dephelp}" _content)
+ if(EXISTS "${${_dephelp}}")
+ file(READ "${${_dephelp}}" _content)
endif()
set(_dummy_str
"#include \"${_include_file}\"
@@ -190,18 +196,20 @@ MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use )
_PCH_GET_TARGET_COMPILE_FLAGS(_target_cflags ${_name} ${_pch_output_to_use} ${_dowarn})
#MESSAGE("Add flags ${_target_cflags} to ${_targetName} " )
+ if(CMAKE_COMPILER_IS_GNUCXX)
+ set(_target_cflags "${_target_cflags} -include \"${CMAKE_CURRENT_BINARY_DIR}/${_name}\"")
+ endif()
GET_TARGET_PROPERTY(_sources ${_targetName} SOURCES)
FOREACH(src ${_sources})
if(NOT "${src}" MATCHES "\\.mm$")
get_source_file_property(_flags "${src}" COMPILE_FLAGS)
- if(_flags)
- set(_flags "${_flags} ${_target_cflags}")
+ get_source_file_property(_flags2 "${src}" COMPILE_DEFINITIONS)
+ if(NOT _flags AND NOT _flags2)
+ set_source_files_properties("${src}" PROPERTIES COMPILE_FLAGS "${_target_cflags}")
else()
- set(_flags "${_target_cflags}")
+ #ocv_debug_message("Skip PCH, flags: ${oldProps} defines: ${oldProps2}, file: ${src}")
endif()
-
- set_source_files_properties("${src}" PROPERTIES COMPILE_FLAGS "${_flags}")
endif()
ENDFOREACH()
@@ -278,19 +286,6 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _input)
DEPENDS ${_targetName}_pch_dephelp
)
- get_target_property(_sources ${_targetName} SOURCES)
- foreach(src ${_sources})
- if(NOT "${src}" MATCHES "\\.mm$")
- get_source_file_property(oldProps "${src}" COMPILE_FLAGS)
- if(NOT oldProps)
- set(newProperties "-include \"${CMAKE_CURRENT_BINARY_DIR}/${_name}\"")
- set_source_files_properties("${src}" PROPERTIES COMPILE_FLAGS "${newProperties}")
- else()
- ocv_debug_message("Skip PCH, flags: ${oldProps} , file: ${src}")
- endif()
- endif()
- endforeach()
-
ADD_PRECOMPILED_HEADER_TO_TARGET(${_targetName} ${_input} ${_output} ${_dowarn})
ENDMACRO(ADD_PRECOMPILED_HEADER)
@@ -303,9 +298,11 @@ ENDMACRO(ADD_PRECOMPILED_HEADER)
MACRO(GET_NATIVE_PRECOMPILED_HEADER _targetName _input)
+ if(ENABLE_PRECOMPILED_HEADERS)
if(CMAKE_GENERATOR MATCHES "^Visual.*$")
set(${_targetName}_pch ${CMAKE_CURRENT_BINARY_DIR}/${_targetName}_pch.cpp)
endif()
+ endif()
ENDMACRO(GET_NATIVE_PRECOMPILED_HEADER)
@@ -326,13 +323,14 @@ MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _input)
get_target_property(_sources ${_targetName} SOURCES)
foreach(src ${_sources})
- if(NOT "${src}" MATCHES "\\.mm$")
+ if("${src}" MATCHES "\\.c(pp|xx)?$")
get_source_file_property(oldProps "${src}" COMPILE_FLAGS)
- if(NOT oldProps)
+ get_source_file_property(oldProps2 "${src}" COMPILE_DEFINITIONS)
+ if(NOT oldProps AND NOT oldProps2)
set(newProperties "/Yu\"${_input}\" /FI\"${_input}\"")
set_source_files_properties("${src}" PROPERTIES COMPILE_FLAGS "${newProperties}")
else()
- ocv_debug_message("Skip PCH, flags: ${oldProps} , file: ${src}")
+ ocv_debug_message("Skip PCH, flags: ${oldProps} defines: ${oldProps2}, file: ${src}")
endif()
endif()
endforeach()
diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake
index cdf257d..8ef7205 100644
--- a/cmake/OpenCVUtils.cmake
+++ b/cmake/OpenCVUtils.cmake
@@ -2,21 +2,22 @@ include(CMakeParseArguments)
# Debugging function
function(ocv_cmake_dump_vars)
- set(VARS "")
- get_cmake_property(_variableNames VARIABLES)
+ get_cmake_property(__variableNames VARIABLES)
cmake_parse_arguments(DUMP "" "TOFILE" "" ${ARGN})
set(regex "${DUMP_UNPARSED_ARGUMENTS}")
string(TOLOWER "${regex}" regex_lower)
- foreach(_variableName ${_variableNames})
- string(TOLOWER "${_variableName}" _variableName_lower)
- if(_variableName MATCHES "${regex}" OR _variableName_lower MATCHES "${regex_lower}")
- set(VARS "${VARS}${_variableName}=${${_variableName}}\n")
+ set(__VARS "")
+ foreach(__variableName ${__variableNames})
+ string(TOLOWER "${__variableName}" __variableName_lower)
+ if((__variableName MATCHES "${regex}" OR __variableName_lower MATCHES "${regex_lower}")
+ AND NOT __variableName_lower MATCHES "^__")
+ set(__VARS "${__VARS}${__variableName}=${${__variableName}}\n")
endif()
endforeach()
if(DUMP_TOFILE)
- file(WRITE ${CMAKE_BINARY_DIR}/${DUMP_TOFILE} "${VARS}")
+ file(WRITE ${CMAKE_BINARY_DIR}/${DUMP_TOFILE} "${__VARS}")
else()
- message(AUTHOR_WARNING "${VARS}")
+ message(AUTHOR_WARNING "${__VARS}")
endif()
endfunction()
@@ -37,7 +38,11 @@ endmacro()
macro(ocv_update VAR)
if(NOT DEFINED ${VAR})
- set(${VAR} ${ARGN})
+ if("x${ARGN}" STREQUAL "x")
+ set(${VAR} "")
+ else()
+ set(${VAR} ${ARGN})
+ endif()
else()
#ocv_debug_message("Preserve old value for ${VAR}: ${${VAR}}")
endif()
@@ -75,7 +80,7 @@ endmacro()
macro(ocv_check_environment_variables)
foreach(_var ${ARGN})
- if(NOT DEFINED ${_var} AND DEFINED ENV{${_var}})
+ if(" ${${_var}}" STREQUAL " " AND DEFINED ENV{${_var}})
set(__value "$ENV{${_var}}")
file(TO_CMAKE_PATH "${__value}" __value) # Assume that we receive paths
set(${_var} "${__value}")
@@ -151,8 +156,15 @@ function(ocv_append_target_property target prop)
endif()
endfunction()
+function(ocv_append_dependant_targets target)
+ #ocv_debug_message("ocv_append_dependant_targets(${target} ${ARGN})")
+ _ocv_fix_target(target)
+ set(OPENCV_DEPENDANT_TARGETS_${target} "${OPENCV_DEPENDANT_TARGETS_${target}};${ARGN}" CACHE INTERNAL "" FORCE)
+endfunction()
+
# adds include directories in such way that directories from the OpenCV source tree go first
function(ocv_target_include_directories target)
+ #ocv_debug_message("ocv_target_include_directories(${target} ${ARGN})")
_ocv_fix_target(target)
set(__params "")
if(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0" AND
@@ -173,6 +185,11 @@ function(ocv_target_include_directories target)
else()
if(TARGET ${target})
target_include_directories(${target} PRIVATE ${__params})
+ if(OPENCV_DEPENDANT_TARGETS_${target})
+ foreach(t ${OPENCV_DEPENDANT_TARGETS_${target}})
+ target_include_directories(${t} PRIVATE ${__params})
+ endforeach()
+ endif()
else()
set(__new_inc "${OCV_TARGET_INCLUDE_DIRS_${target}};${__params}")
set(OCV_TARGET_INCLUDE_DIRS_${target} "${__new_inc}" CACHE INTERNAL "")
@@ -205,8 +222,11 @@ set(OCV_COMPILER_FAIL_REGEX
)
MACRO(ocv_check_compiler_flag LANG FLAG RESULT)
+ set(_fname "${ARGN}")
if(NOT DEFINED ${RESULT})
- if("_${LANG}_" MATCHES "_CXX_")
+ if(_fname)
+ # nothing
+ elseif("_${LANG}_" MATCHES "_CXX_")
set(_fname "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx")
if("${CMAKE_CXX_FLAGS} ${FLAG} " MATCHES "-Werror " OR "${CMAKE_CXX_FLAGS} ${FLAG} " MATCHES "-Werror=unknown-pragmas ")
FILE(WRITE "${_fname}" "int main() { return 0; }\n")
@@ -231,10 +251,17 @@ MACRO(ocv_check_compiler_flag LANG FLAG RESULT)
unset(_fname)
endif()
if(_fname)
- MESSAGE(STATUS "Performing Test ${RESULT}")
+ if(NOT "x${ARGN}" STREQUAL "x")
+ file(RELATIVE_PATH __msg "${CMAKE_SOURCE_DIR}" "${ARGN}")
+ set(__msg " (check file: ${__msg})")
+ else()
+ set(__msg "")
+ endif()
+ MESSAGE(STATUS "Performing Test ${RESULT}${__msg}")
TRY_COMPILE(${RESULT}
"${CMAKE_BINARY_DIR}"
"${_fname}"
+ CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}" # CMP0056 do this on new CMake
COMPILE_DEFINITIONS "${FLAG}"
OUTPUT_VARIABLE OUTPUT)
@@ -278,7 +305,11 @@ MACRO(ocv_check_compiler_flag LANG FLAG RESULT)
endif()
ENDMACRO()
-macro(ocv_check_flag_support lang flag varname)
+macro(ocv_check_flag_support lang flag varname base_options)
+ if(CMAKE_BUILD_TYPE)
+ set(CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_BUILD_TYPE})
+ endif()
+
if("_${lang}_" MATCHES "_CXX_")
set(_lang CXX)
elseif("_${lang}_" MATCHES "_C_")
@@ -293,7 +324,7 @@ macro(ocv_check_flag_support lang flag varname)
string(REGEX REPLACE "^(/|-)" "HAVE_${_lang}_" ${varname} "${${varname}}")
string(REGEX REPLACE " -|-|=| |\\." "_" ${varname} "${${varname}}")
- ocv_check_compiler_flag("${_lang}" "${ARGN} ${flag}" ${${varname}})
+ ocv_check_compiler_flag("${_lang}" "${base_options} ${flag}" ${${varname}} ${ARGN})
endmacro()
# turns off warnings
@@ -327,7 +358,7 @@ macro(ocv_warnings_disable)
string(REPLACE "${warning}" "" ${var} "${${var}}")
string(REPLACE "-W" "-Wno-" warning "${warning}")
endif()
- ocv_check_flag_support(${var} "${warning}" _varname)
+ ocv_check_flag_support(${var} "${warning}" _varname "")
if(${_varname})
set(${var} "${${var}} ${warning}")
endif()
@@ -342,7 +373,7 @@ macro(ocv_warnings_disable)
else()
string(REPLACE "-wd" "-Qwd" warning "${warning}")
endif()
- ocv_check_flag_support(${var} "${warning}" _varname)
+ ocv_check_flag_support(${var} "${warning}" _varname "")
if(${_varname})
set(${var} "${${var}} ${warning}")
endif()
@@ -356,8 +387,18 @@ macro(ocv_warnings_disable)
endif(NOT ENABLE_NOISY_WARNINGS)
endmacro()
+macro(ocv_append_sourge_file_compile_definitions source)
+ get_source_file_property(_value "${source}" COMPILE_DEFINITIONS)
+ if(_value)
+ set(_value ${_value} ${ARGN})
+ else()
+ set(_value ${ARGN})
+ endif()
+ set_source_files_properties("${source}" PROPERTIES COMPILE_DEFINITIONS "${_value}")
+endmacro()
+
macro(add_apple_compiler_options the_module)
- ocv_check_flag_support(OBJCXX "-fobjc-exceptions" HAVE_OBJC_EXCEPTIONS)
+ ocv_check_flag_support(OBJCXX "-fobjc-exceptions" HAVE_OBJC_EXCEPTIONS "")
if(HAVE_OBJC_EXCEPTIONS)
foreach(source ${OPENCV_MODULE_${the_module}_SOURCES})
if("${source}" MATCHES "\\.mm$")
@@ -459,7 +500,7 @@ endmacro()
# Macros that checks if module have been installed.
# After it adds module to build and define
# constants passed as second arg
-macro(CHECK_MODULE module_name define)
+macro(CHECK_MODULE module_name define cv_module)
set(${define} 0)
if(PKG_CONFIG_FOUND)
set(ALIAS ALIASOF_${module_name})
@@ -469,25 +510,9 @@ macro(CHECK_MODULE module_name define)
set(ALIAS_LIBRARIES ${ALIAS}_LIBRARIES)
PKG_CHECK_MODULES(${ALIAS} ${module_name})
-
if(${ALIAS_FOUND})
set(${define} 1)
- foreach(P "${ALIAS_INCLUDE_DIRS}")
- if(${P})
- list(APPEND VIDEOIO_INCLUDE_DIRS ${${P}})
- list(APPEND HIGHGUI_INCLUDE_DIRS ${${P}})
- endif()
- endforeach()
-
- foreach(P "${ALIAS_LIBRARY_DIRS}")
- if(${P})
- list(APPEND VIDEOIO_LIBRARY_DIRS ${${P}})
- list(APPEND HIGHGUI_LIBRARY_DIRS ${${P}})
- endif()
- endforeach()
-
- list(APPEND VIDEOIO_LIBRARIES ${${ALIAS_LIBRARIES}})
- list(APPEND HIGHGUI_LIBRARIES ${${ALIAS_LIBRARIES}})
+ ocv_append_build_options(${cv_module} ${ALIAS})
endif()
endif()
endmacro()
@@ -508,6 +533,12 @@ macro(ocv_finalize_status)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OPENCV_BUILD_INFO_FILE}" "${OPENCV_MODULE_opencv_core_BINARY_DIR}/version_string.inc" OUTPUT_QUIET)
endif()
endif()
+
+ if(UNIX)
+ install(FILES "${OpenCV_SOURCE_DIR}/platforms/scripts/valgrind.supp"
+ "${OpenCV_SOURCE_DIR}/platforms/scripts/valgrind_3rdparty.supp"
+ DESTINATION "${OPENCV_OTHER_INSTALL_PATH}" COMPONENT "dev")
+ endif()
endmacro()
@@ -668,7 +699,11 @@ endfunction()
# add install command
function(ocv_install_target)
- install(TARGETS ${ARGN})
+ if(APPLE_FRAMEWORK AND BUILD_SHARED_LIBS)
+ install(TARGETS ${ARGN} FRAMEWORK DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH})
+ else()
+ install(TARGETS ${ARGN})
+ endif()
set(isPackage 0)
unset(__package)
@@ -883,7 +918,14 @@ function(ocv_target_link_libraries target)
if(";${LINK_DEPS};" MATCHES ";${target};")
list(REMOVE_ITEM LINK_DEPS "${target}") # prevent "link to itself" warning (world problem)
endif()
- target_link_libraries(${target} ${LINK_DEPS})
+ if(NOT TARGET ${target})
+ if(NOT DEFINED OPENCV_MODULE_${target}_LOCATION)
+ message(FATAL_ERROR "ocv_target_link_libraries: invalid target: '${target}'")
+ endif()
+ set(OPENCV_MODULE_${target}_LINK_DEPS ${OPENCV_MODULE_${target}_LINK_DEPS} ${LINK_DEPS} CACHE INTERNAL "" FORCE)
+ else()
+ target_link_libraries(${target} ${LINK_DEPS})
+ endif()
endfunction()
function(_ocv_append_target_includes target)
@@ -892,6 +934,11 @@ function(_ocv_append_target_includes target)
if (TARGET ${target}_object)
target_include_directories(${target}_object PRIVATE ${OCV_TARGET_INCLUDE_DIRS_${target}})
endif()
+ if(OPENCV_DEPENDANT_TARGETS_${target})
+ foreach(t ${OPENCV_DEPENDANT_TARGETS_${target}})
+ target_include_directories(${t} PRIVATE ${OCV_TARGET_INCLUDE_DIRS_${target}})
+ endforeach()
+ endif()
unset(OCV_TARGET_INCLUDE_DIRS_${target} CACHE)
endif()
endfunction()
@@ -931,9 +978,39 @@ function(ocv_add_library target)
unset(sources)
endif()
+ if(APPLE_FRAMEWORK AND BUILD_SHARED_LIBS)
+ message(STATUS "Setting Apple target properties for ${target}")
+
+ set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG 1)
+
+ set_target_properties(${target} PROPERTIES
+ FRAMEWORK TRUE
+ MACOSX_FRAMEWORK_IDENTIFIER org.opencv
+ MACOSX_FRAMEWORK_INFO_PLIST ${CMAKE_BINARY_DIR}/ios/Info.plist
+ # "current version" in semantic format in Mach-O binary file
+ VERSION ${OPENCV_LIBVERSION}
+ # "compatibility version" in semantic format in Mach-O binary file
+ SOVERSION ${OPENCV_LIBVERSION}
+ INSTALL_RPATH ""
+ INSTALL_NAME_DIR "@rpath"
+ BUILD_WITH_INSTALL_RPATH 1
+ LIBRARY_OUTPUT_NAME "opencv2"
+ XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2"
+ #PUBLIC_HEADER "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h"
+ #XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
+ )
+ endif()
+
_ocv_append_target_includes(${target})
endfunction()
+
+macro(ocv_get_libname var_name)
+ get_filename_component(__libname "${ARGN}" NAME)
+ string(REGEX REPLACE "^lib(.+).(a|so)(.[.0-9]+)?$" "\\1" __libname "${__libname}")
+ set(${var_name} "${__libname}")
+endmacro()
+
# build the list of opencv libs and dependencies for all modules
# _modules - variable to hold list of all modules
# _extra - variable to hold list of extra dependencies
@@ -961,11 +1038,31 @@ macro(ocv_get_all_libs _modules _extra _3rdparty)
foreach (dep ${deps} ${OPENCV_LINKER_LIBS})
if (NOT DEFINED OPENCV_MODULE_${dep}_LOCATION)
if (TARGET ${dep})
- get_target_property(_output ${dep} ARCHIVE_OUTPUT_DIRECTORY)
- if ("${_output}" STREQUAL "${3P_LIBRARY_OUTPUT_PATH}")
- list(INSERT ${_3rdparty} 0 ${dep})
+ get_target_property(_type ${dep} TYPE)
+ if(_type STREQUAL "STATIC_LIBRARY" AND BUILD_SHARED_LIBS)
+ # nothing
else()
- list(INSERT ${_extra} 0 ${dep})
+ get_target_property(_output ${dep} IMPORTED_LOCATION)
+ if(NOT _output)
+ get_target_property(_output ${dep} ARCHIVE_OUTPUT_DIRECTORY)
+ get_target_property(_output_name ${dep} OUTPUT_NAME)
+ if(NOT _output_name)
+ set(_output_name "${dep}")
+ endif()
+ else()
+ get_filename_component(_output_name "${_output}" NAME)
+ endif()
+ string(FIND "${_output}" "${CMAKE_BINARY_DIR}" _POS)
+ if (_POS EQUAL 0)
+ ocv_get_libname(_libname "${_output_name}")
+ list(INSERT ${_3rdparty} 0 ${_libname})
+ else()
+ if(_output)
+ list(INSERT ${_extra} 0 ${_output})
+ else()
+ list(INSERT ${_extra} 0 ${dep})
+ endif()
+ endif()
endif()
else()
list(INSERT ${_extra} 0 ${dep})
@@ -974,15 +1071,6 @@ macro(ocv_get_all_libs _modules _extra _3rdparty)
endforeach()
endforeach()
- # ippicv specific handling
- list(FIND ${_extra} "ippicv" ippicv_idx)
- if (${ippicv_idx} GREATER -1)
- list(REMOVE_ITEM ${_extra} "ippicv")
- if(NOT BUILD_SHARED_LIBS)
- list(INSERT ${_3rdparty} 0 "ippicv")
- endif()
- endif()
-
ocv_list_filterout(${_modules} "^[\$]<")
ocv_list_filterout(${_3rdparty} "^[\$]<")
ocv_list_filterout(${_extra} "^[\$]<")
@@ -994,78 +1082,6 @@ macro(ocv_get_all_libs _modules _extra _3rdparty)
endforeach()
endmacro()
-function(ocv_download)
- cmake_parse_arguments(DL "" "PACKAGE;HASH;URL;DESTINATION_DIR;DOWNLOAD_DIR" "" ${ARGN})
- if(NOT DL_DOWNLOAD_DIR)
- set(DL_DOWNLOAD_DIR "${DL_DESTINATION_DIR}/downloads")
- endif()
- if(DEFINED DL_DESTINATION_DIR)
- set(DESTINATION_TARGET "${DL_DESTINATION_DIR}/${DL_PACKAGE}")
- if(EXISTS "${DESTINATION_TARGET}")
- file(MD5 "${DESTINATION_TARGET}" target_md5)
- if(NOT target_md5 STREQUAL DL_HASH)
- file(REMOVE "${DESTINATION_TARGET}")
- else()
- set(DOWNLOAD_PACKAGE_LOCATION "" PARENT_SCOPE)
- unset(DOWNLOAD_PACKAGE_LOCATION)
- return()
- endif()
- endif()
- endif()
- set(DOWNLOAD_TARGET "${DL_DOWNLOAD_DIR}/${DL_HASH}/${DL_PACKAGE}")
- get_filename_component(DOWNLOAD_TARGET_DIR "${DOWNLOAD_TARGET}" PATH)
- if(EXISTS "${DOWNLOAD_TARGET}")
- file(MD5 "${DOWNLOAD_TARGET}" target_md5)
- if(NOT target_md5 STREQUAL DL_HASH)
- message(WARNING "Download: Local copy of ${DL_PACKAGE} has invalid MD5 hash: ${target_md5} (expected: ${DL_HASH})")
- file(REMOVE "${DOWNLOAD_TARGET}")
- file(REMOVE_RECURSE "${DOWNLOAD_TARGET_DIR}")
- endif()
- endif()
-
- if(NOT EXISTS "${DOWNLOAD_TARGET}")
- set(__url "")
- foreach(__url_i ${DL_URL})
- if(NOT ("${__url_i}" STREQUAL ""))
- set(__url "${__url_i}")
- break()
- endif()
- endforeach()
- if("${__url}" STREQUAL "")
- message(FATAL_ERROR "Download URL is not specified for package ${DL_PACKAGE}")
- endif()
-
- if(NOT EXISTS "${DOWNLOAD_TARGET_DIR}")
- file(MAKE_DIRECTORY ${DOWNLOAD_TARGET_DIR})
- endif()
- message(STATUS "Downloading ${DL_PACKAGE}...")
- #message(STATUS " ${__url}${DL_PACKAGE}")
- file(DOWNLOAD "${__url}${DL_PACKAGE}" "${DOWNLOAD_TARGET}"
- TIMEOUT 600 STATUS __status
- EXPECTED_MD5 ${DL_HASH})
- if(NOT __status EQUAL 0)
- message(FATAL_ERROR "Failed to download ${DL_PACKAGE}. Status=${__status}")
- else()
- # Don't remove this code, because EXPECTED_MD5 parameter doesn't fail "file(DOWNLOAD)" step on wrong hash
- file(MD5 "${DOWNLOAD_TARGET}" target_md5)
- if(NOT target_md5 STREQUAL DL_HASH)
- message(FATAL_ERROR "Downloaded copy of ${DL_PACKAGE} has invalid MD5 hash: ${target_md5} (expected: ${DL_HASH})")
- endif()
- endif()
- message(STATUS "Downloading ${DL_PACKAGE}... Done")
- endif()
-
- if(DEFINED DL_DESTINATION_DIR)
- execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${DOWNLOAD_TARGET}" "${DL_DESTINATION_DIR}/"
- RESULT_VARIABLE __result)
-
- if(NOT __result EQUAL 0)
- message(FATAL_ERROR "Downloader: Failed to copy package from ${DOWNLOAD_TARGET} to ${DL_DESTINATION_DIR} with error ${__result}")
- endif()
- endif()
-
- set(DOWNLOAD_PACKAGE_LOCATION ${DOWNLOAD_TARGET} PARENT_SCOPE)
-endfunction()
function(ocv_add_test_from_target test_name test_kind the_target)
if(CMAKE_VERSION VERSION_GREATER "2.8" AND NOT CMAKE_CROSSCOMPILING)
@@ -1106,10 +1122,56 @@ macro(ocv_add_testdata basedir dest_subdir)
endif()
if(INSTALL_TESTS)
install(DIRECTORY ${basedir}/
- DESTINATION ${OPENCV_TEST_DATA_INSTALL_PATH}/contrib/text
+ DESTINATION ${OPENCV_TEST_DATA_INSTALL_PATH}/${dest_subdir}
COMPONENT "tests"
${ARGN}
)
endif()
endif()
endmacro()
+
+macro(ocv_generate_vs_version_file DESTINATION)
+ cmake_parse_arguments(VS_VER "" "NAME;FILEDESCRIPTION;FILEVERSION;INTERNALNAME;COPYRIGHT;ORIGINALFILENAME;PRODUCTNAME;PRODUCTVERSION;COMMENTS;FILEVERSION_QUAD;PRODUCTVERSION_QUAD" "" ${ARGN})
+
+ macro(__vs_ver_update_variable name)
+ if(VS_VER_NAME AND DEFINED OPENCV_${VS_VER_NAME}_VS_VER_${name})
+ set(OPENCV_VS_VER_${name} "${OPENCV_${VS_VER_NAME}_VS_VER_${name}}")
+ elseif(VS_VER_${name})
+ set(OPENCV_VS_VER_${name} "${VS_VER_${name}}")
+ endif()
+ endmacro()
+
+ __vs_ver_update_variable(FILEVERSION_QUAD)
+ __vs_ver_update_variable(PRODUCTVERSION_QUAD)
+
+ macro(__vs_ver_update_str_variable name)
+ if(VS_VER_NAME AND DEFINED OPENCV_${VS_VER_NAME}_VS_VER_${name})
+ set(OPENCV_VS_VER_${name}_STR "${OPENCV_${VS_VER_NAME}_VS_VER_${name}}")
+ elseif(VS_VER_${name})
+ set(OPENCV_VS_VER_${name}_STR "${VS_VER_${name}}")
+ endif()
+ endmacro()
+
+ __vs_ver_update_str_variable(FILEDESCRIPTION)
+ __vs_ver_update_str_variable(FILEVERSION)
+ __vs_ver_update_str_variable(INTERNALNAME)
+ __vs_ver_update_str_variable(COPYRIGHT)
+ __vs_ver_update_str_variable(ORIGINALFILENAME)
+ __vs_ver_update_str_variable(PRODUCTNAME)
+ __vs_ver_update_str_variable(PRODUCTVERSION)
+ __vs_ver_update_str_variable(COMMENTS)
+
+ if(OPENCV_VS_VER_COPYRIGHT_STR)
+ set(OPENCV_VS_VER_HAVE_COPYRIGHT_STR 1)
+ else()
+ set(OPENCV_VS_VER_HAVE_COPYRIGHT_STR 0)
+ endif()
+
+ if(OPENCV_VS_VER_COMMENTS_STR)
+ set(OPENCV_VS_VER_HAVE_COMMENTS_STR 1)
+ else()
+ set(OPENCV_VS_VER_HAVE_COMMENTS_STR 0)
+ endif()
+
+ configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/vs_version.rc.in" "${DESTINATION}" @ONLY)
+endmacro()
diff --git a/cmake/OpenCVVersion.cmake b/cmake/OpenCVVersion.cmake
index 60ac164..dda0474 100644
--- a/cmake/OpenCVVersion.cmake
+++ b/cmake/OpenCVVersion.cmake
@@ -16,3 +16,10 @@ set(OPENCV_LIBVERSION "${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}.${OPENCV_
# create a dependency on version file
# we never use output of the following command but cmake will rerun automatically if the version file changes
configure_file("${OPENCV_VERSION_FILE}" "${CMAKE_BINARY_DIR}/junk/version.junk" COPYONLY)
+
+ocv_update(OPENCV_VS_VER_FILEVERSION_QUAD "${OPENCV_VERSION_MAJOR},${OPENCV_VERSION_MINOR},${OPENCV_VERSION_PATCH},0")
+ocv_update(OPENCV_VS_VER_PRODUCTVERSION_QUAD "${OPENCV_VERSION_MAJOR},${OPENCV_VERSION_MINOR},${OPENCV_VERSION_PATCH},0")
+ocv_update(OPENCV_VS_VER_FILEVERSION_STR "${OPENCV_VERSION}")
+ocv_update(OPENCV_VS_VER_PRODUCTVERSION_STR "${OPENCV_VERSION}")
+ocv_update(OPENCV_VS_VER_PRODUCTNAME_STR "OpenCV library")
+ocv_update(OPENCV_VS_VER_COMMENTS_STR "http://opencv.org/")
diff --git a/cmake/checks/cpu_avx.cpp b/cmake/checks/cpu_avx.cpp
new file mode 100644
index 0000000..05536f4
--- /dev/null
+++ b/cmake/checks/cpu_avx.cpp
@@ -0,0 +1,9 @@
+#if !defined __AVX__ // MSVC supports this flag since MSVS 2013
+#error "__AVX__ define is missing"
+#endif
+#include <immintrin.h>
+void test()
+{
+ __m256 a = _mm256_set1_ps(0.0f);
+}
+int main() { return 0; }
diff --git a/cmake/checks/cpu_avx2.cpp b/cmake/checks/cpu_avx2.cpp
new file mode 100644
index 0000000..3ab1143
--- /dev/null
+++ b/cmake/checks/cpu_avx2.cpp
@@ -0,0 +1,10 @@
+#if !defined __AVX2__ // MSVC supports this flag since MSVS 2013
+#error "__AVX2__ define is missing"
+#endif
+#include <immintrin.h>
+void test()
+{
+ int data[8] = {0,0,0,0, 0,0,0,0};
+ __m256i a = _mm256_loadu_si256((const __m256i *)data);
+}
+int main() { return 0; }
diff --git a/cmake/checks/cpu_avx512.cpp b/cmake/checks/cpu_avx512.cpp
new file mode 100644
index 0000000..d0898ab
--- /dev/null
+++ b/cmake/checks/cpu_avx512.cpp
@@ -0,0 +1,10 @@
+#if defined __AVX512__ || defined __AVX512F__
+#include <immintrin.h>
+void test()
+{
+ __m512i zmm = _mm512_setzero_si512();
+}
+#else
+#error "AVX512 is not supported"
+#endif
+int main() { return 0; }
diff --git a/cmake/checks/cpu_fp16.cpp b/cmake/checks/cpu_fp16.cpp
new file mode 100644
index 0000000..6951f1c
--- /dev/null
+++ b/cmake/checks/cpu_fp16.cpp
@@ -0,0 +1,33 @@
+#include <stdio.h>
+
+#if defined __F16C__ || (defined _MSC_VER && _MSC_VER >= 1700) || (defined __INTEL_COMPILER && defined __AVX__)
+#include <immintrin.h>
+int test()
+{
+ const float src[] = { 0.0f, 0.0f, 0.0f, 0.0f };
+ short dst[8];
+ __m128 v_src = _mm_load_ps(src);
+ __m128i v_dst = _mm_cvtps_ph(v_src, 0);
+ _mm_storel_epi64((__m128i*)dst, v_dst);
+ return (int)dst[0];
+}
+#elif defined __GNUC__ && (defined __arm__ || defined __aarch64__)
+#include "arm_neon.h"
+int test()
+{
+ const float src[] = { 0.0f, 0.0f, 0.0f, 0.0f };
+ short dst[8];
+ float32x4_t v_src = *(float32x4_t*)src;
+ float16x4_t v_dst = vcvt_f16_f32(v_src);
+ *(float16x4_t*)dst = v_dst;
+ return (int)dst[0];
+}
+#else
+#error "FP16 is not supported"
+#endif
+
+int main()
+{
+ printf("%d\n", test());
+ return 0;
+}
diff --git a/cmake/checks/cpu_neon.cpp b/cmake/checks/cpu_neon.cpp
new file mode 100644
index 0000000..dda6e08
--- /dev/null
+++ b/cmake/checks/cpu_neon.cpp
@@ -0,0 +1,27 @@
+#include <stdio.h>
+
+#if defined _WIN32 && defined(_M_ARM)
+# include <Intrin.h>
+# include <arm_neon.h>
+# define CV_NEON 1
+#elif defined(__ARM_NEON__) || (defined (__ARM_NEON) && defined(__aarch64__))
+# include <arm_neon.h>
+# define CV_NEON 1
+#endif
+
+#if defined CV_NEON
+int test()
+{
+ const float src[] = { 0.0f, 0.0f, 0.0f, 0.0f };
+ float32x4_t val = vld1q_f32((const float32_t*)(src));
+ return (int)vgetq_lane_f32(val, 0);
+}
+#else
+#error "NEON is not supported"
+#endif
+
+int main()
+{
+ printf("%d\n", test());
+ return 0;
+}
diff --git a/cmake/checks/cpu_popcnt.cpp b/cmake/checks/cpu_popcnt.cpp
new file mode 100644
index 0000000..16e5575
--- /dev/null
+++ b/cmake/checks/cpu_popcnt.cpp
@@ -0,0 +1,22 @@
+#ifdef _MSC_VER
+# include <nmmintrin.h>
+# if defined(_M_X64)
+# define CV_POPCNT_U64 _mm_popcnt_u64
+# endif
+# define CV_POPCNT_U32 _mm_popcnt_u32
+#else
+# include <popcntintrin.h>
+# if defined(__x86_64__)
+# define CV_POPCNT_U64 __builtin_popcountll
+# endif
+# define CV_POPCNT_U32 __builtin_popcount
+#endif
+
+int main()
+{
+#ifdef CV_POPCNT_U64
+ int i = CV_POPCNT_U64(1);
+#endif
+ int j = CV_POPCNT_U32(1);
+ return 0;
+}
diff --git a/cmake/checks/cpu_sse.cpp b/cmake/checks/cpu_sse.cpp
new file mode 100644
index 0000000..c6269ac
--- /dev/null
+++ b/cmake/checks/cpu_sse.cpp
@@ -0,0 +1,2 @@
+#include <xmmintrin.h>
+int main() { return 0; }
diff --git a/cmake/checks/cpu_sse2.cpp b/cmake/checks/cpu_sse2.cpp
new file mode 100644
index 0000000..68a69f8
--- /dev/null
+++ b/cmake/checks/cpu_sse2.cpp
@@ -0,0 +1,2 @@
+#include <emmintrin.h>
+int main() { return 0; }
diff --git a/cmake/checks/cpu_sse3.cpp b/cmake/checks/cpu_sse3.cpp
new file mode 100644
index 0000000..98ce219
--- /dev/null
+++ b/cmake/checks/cpu_sse3.cpp
@@ -0,0 +1,7 @@
+#include <pmmintrin.h>
+int main() {
+ __m128 u, v;
+ u = _mm_set1_ps(0.0f);
+ v = _mm_moveldup_ps(u); // SSE3
+ return 0;
+}
diff --git a/cmake/checks/cpu_sse41.cpp b/cmake/checks/cpu_sse41.cpp
new file mode 100644
index 0000000..ddd835b
--- /dev/null
+++ b/cmake/checks/cpu_sse41.cpp
@@ -0,0 +1,6 @@
+#include <smmintrin.h>
+int main() {
+ __m128i a = _mm_setzero_si128(), b = _mm_setzero_si128();
+ __m128i c = _mm_packus_epi32(a, b);
+ return 0;
+}
diff --git a/cmake/checks/cpu_sse42.cpp b/cmake/checks/cpu_sse42.cpp
new file mode 100644
index 0000000..2a1ce99
--- /dev/null
+++ b/cmake/checks/cpu_sse42.cpp
@@ -0,0 +1,7 @@
+#include <nmmintrin.h>
+
+int main()
+{
+ unsigned int res = _mm_crc32_u8(1, 2);
+ return 0;
+}
diff --git a/cmake/checks/cpu_ssse3.cpp b/cmake/checks/cpu_ssse3.cpp
new file mode 100644
index 0000000..e583199
--- /dev/null
+++ b/cmake/checks/cpu_ssse3.cpp
@@ -0,0 +1,7 @@
+#include <tmmintrin.h>
+const double v = 0;
+int main() {
+ __m128i a = _mm_setzero_si128();
+ __m128i b = _mm_abs_epi32(a);
+ return 0;
+}
diff --git a/cmake/checks/cxx11.cpp b/cmake/checks/cxx11.cpp
new file mode 100644
index 0000000..ea719d6
--- /dev/null
+++ b/cmake/checks/cxx11.cpp
@@ -0,0 +1,13 @@
+#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600)
+// OK
+#else
+#error "C++11 is not supported"
+#endif
+
+static int test() { return 0; }
+
+int main()
+{
+ auto res = test();
+ return res;
+}
diff --git a/cmake/checks/ffmpeg_test.cpp b/cmake/checks/ffmpeg_test.cpp
index 7b49c38..4a7a3e0 100644
--- a/cmake/checks/ffmpeg_test.cpp
+++ b/cmake/checks/ffmpeg_test.cpp
@@ -1,3 +1,5 @@
+#define __STDC_CONSTANT_MACROS
+
#include <stdlib.h>
extern "C" {
@@ -13,12 +15,15 @@ static void test()
AVFormatContext* c = 0;
AVCodec* avcodec = 0;
AVFrame* frame = 0;
+ (void)avcodec;
+ (void)frame;
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(52, 111, 0)
int err = avformat_open_input(&c, "", NULL, NULL);
#else
int err = av_open_input_file(&c, "", NULL, 0, NULL);
#endif
+ (void)err;
}
int main() { test(); return 0; }
diff --git a/cmake/checks/fp16.cpp b/cmake/checks/fp16.cpp
deleted file mode 100644
index c77c844..0000000
--- a/cmake/checks/fp16.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-#include <stdio.h>
-
-#if defined __F16C__ || (defined _MSC_VER && _MSC_VER >= 1700)
-#include <immintrin.h>
-int test()
-{
- const float src[] = { 0.0f, 0.0f, 0.0f, 0.0f };
- short dst[8];
- __m128 v_src = _mm_load_ps(src);
- __m128i v_dst = _mm_cvtps_ph(v_src, 0);
- _mm_storel_epi64((__m128i*)dst, v_dst);
- return (int)dst[0];
-}
-#elif defined __GNUC__ && (defined __arm__ || defined __aarch64__)
-#include "arm_neon.h"
-int test()
-{
- const float src[] = { 0.0f, 0.0f, 0.0f, 0.0f };
- short dst[8];
- float32x4_t v_src = *(float32x4_t*)src;
- float16x4_t v_dst = vcvt_f16_f32(v_src);
- *(float16x4_t*)dst = v_dst;
- return (int)dst[0];
-}
-#else
-#error "FP16 is not supported"
-#endif
-
-int main()
-{
- printf("%d\n", test());
- return 0;
-}
diff --git a/cmake/checks/lapack_check.cpp b/cmake/checks/lapack_check.cpp
new file mode 100644
index 0000000..0457c44
--- /dev/null
+++ b/cmake/checks/lapack_check.cpp
@@ -0,0 +1,14 @@
+#include "opencv_lapack.h"
+
+static char* check_fn1 = (char*)sgesv_;
+static char* check_fn2 = (char*)sposv_;
+static char* check_fn3 = (char*)spotrf_;
+static char* check_fn4 = (char*)sgesdd_;
+
+int main(int argc, char* argv[])
+{
+ (void)argv;
+ if(argc > 1000)
+ return check_fn1[0] + check_fn2[0] + check_fn3[0] + check_fn4[0];
+ return 0;
+}
diff --git a/cmake/checks/openvx_refenum_test.cpp b/cmake/checks/openvx_refenum_test.cpp
new file mode 100644
index 0000000..f28db05
--- /dev/null
+++ b/cmake/checks/openvx_refenum_test.cpp
@@ -0,0 +1,5 @@
+#include <VX/vx.h>
+int main()
+{
+ return VX_REFERENCE_COUNT == VX_REFERENCE_TYPE ? VX_REFERENCE_NAME : 0;
+}
diff --git a/cmake/cl2cpp.cmake b/cmake/cl2cpp.cmake
index ed5dcb8..f9e3655 100644
--- a/cmake/cl2cpp.cmake
+++ b/cmake/cl2cpp.cmake
@@ -9,17 +9,11 @@ if (NOT cl_list)
message(FATAL_ERROR "Can't find OpenCL kernels in directory: ${CL_DIR}")
endif()
-string(REPLACE ".cpp" ".hpp" OUTPUT_HPP "${OUTPUT}")
+string(REGEX REPLACE "\\.cpp$" ".hpp" OUTPUT_HPP "${OUTPUT}")
get_filename_component(OUTPUT_HPP_NAME "${OUTPUT_HPP}" NAME)
-if("${MODULE_NAME}" STREQUAL "ocl")
- set(nested_namespace_start "")
- set(nested_namespace_end "")
-else()
- set(new_mode ON)
- set(nested_namespace_start "namespace ${MODULE_NAME}\n{")
- set(nested_namespace_end "}")
-endif()
+set(nested_namespace_start "namespace ${MODULE_NAME}\n{")
+set(nested_namespace_end "}")
set(STR_CPP "// This file is auto-generated. Do not edit!
@@ -35,6 +29,8 @@ namespace ocl
{
${nested_namespace_start}
+static const char* const moduleName = \"${MODULE_NAME}\";
+
")
set(STR_HPP "// This file is auto-generated. Do not edit!
@@ -76,19 +72,15 @@ foreach(cl ${cl_list})
string(MD5 hash "${lines}")
- set(STR_CPP_DECL "const struct ProgramEntry ${cl_filename}={\"${cl_filename}\",\n\"${lines}, \"${hash}\"};\n")
- set(STR_HPP_DECL "extern const struct ProgramEntry ${cl_filename};\n")
- if(new_mode)
- set(STR_CPP_DECL "${STR_CPP_DECL}ProgramSource ${cl_filename}_oclsrc(${cl_filename}.programStr);\n")
- set(STR_HPP_DECL "${STR_HPP_DECL}extern ProgramSource ${cl_filename}_oclsrc;\n")
- endif()
+ set(STR_CPP_DECL "struct cv::ocl::internal::ProgramEntry ${cl_filename}_oclsrc={moduleName, \"${cl_filename}\",\n\"${lines}, \"${hash}\", NULL};\n")
+ set(STR_HPP_DECL "extern struct cv::ocl::internal::ProgramEntry ${cl_filename}_oclsrc;\n")
set(STR_CPP "${STR_CPP}${STR_CPP_DECL}")
set(STR_HPP "${STR_HPP}${STR_HPP_DECL}")
endforeach()
-set(STR_CPP "${STR_CPP}}\n${nested_namespace_end}}\n#endif\n")
-set(STR_HPP "${STR_HPP}}\n${nested_namespace_end}}\n#endif\n")
+set(STR_CPP "${STR_CPP}\n${nested_namespace_end}}}\n#endif\n")
+set(STR_HPP "${STR_HPP}\n${nested_namespace_end}}}\n#endif\n")
file(WRITE "${OUTPUT}" "${STR_CPP}")
@@ -96,7 +88,7 @@ if(EXISTS "${OUTPUT_HPP}")
file(READ "${OUTPUT_HPP}" hpp_lines)
endif()
if("${hpp_lines}" STREQUAL "${STR_HPP}")
- message(STATUS "${OUTPUT_HPP} contains same content")
+ message(STATUS "${OUTPUT_HPP} contains the same content")
else()
file(WRITE "${OUTPUT_HPP}" "${STR_HPP}")
endif()
diff --git a/cmake/templates/OpenCV.mk.in b/cmake/templates/OpenCV.mk.in
index e99b1ad..addde3a 100644
--- a/cmake/templates/OpenCV.mk.in
+++ b/cmake/templates/OpenCV.mk.in
@@ -94,6 +94,8 @@ LOCAL_CFLAGS += $(OPENCV_LOCAL_CFLAGS)
ifeq ($(OPENCV_INSTALL_MODULES),on)
LOCAL_$(OPENCV_LIB_TYPE)_LIBRARIES += $(foreach mod, $(OPENCV_LIBS), opencv_$(mod))
else
+ $(call __ndk_info,OpenCV: You should ignore warning about 'non-system libraries in linker flags' and 'opencv_java' library.)
+ $(call __ndk_info, 'OPENCV_INSTALL_MODULES:=on' can be used to build APK with included OpenCV binaries)
LOCAL_LDLIBS += -L$(call host-path,$(LOCAL_PATH)/$(OPENCV_LIBS_DIR)) $(foreach lib, $(OPENCV_LIBS), -lopencv_$(lib))
endif
diff --git a/cmake/templates/OpenCVConfig-IPPIW.cmake.in b/cmake/templates/OpenCVConfig-IPPIW.cmake.in
new file mode 100644
index 0000000..36cfed0
--- /dev/null
+++ b/cmake/templates/OpenCVConfig-IPPIW.cmake.in
@@ -0,0 +1,7 @@
+if(NOT TARGET ippiw)
+ add_library(ippiw STATIC IMPORTED)
+ set_target_properties(ippiw PROPERTIES
+ IMPORTED_LINK_INTERFACE_LIBRARIES ""
+ IMPORTED_LOCATION "${OpenCV_INSTALL_PATH}/@IPPIW_INSTALL_PATH_RELATIVE_CONFIGCMAKE@"
+ )
+endif()
diff --git a/cmake/templates/OpenCVConfig.cmake.in b/cmake/templates/OpenCVConfig.cmake.in
index 47751f5..c0a5838 100644
--- a/cmake/templates/OpenCVConfig.cmake.in
+++ b/cmake/templates/OpenCVConfig.cmake.in
@@ -97,6 +97,7 @@ endif()
@ANDROID_CONFIGCMAKE@
@IPPICV_CONFIGCMAKE@
+ at IPPIW_CONFIGCMAKE@
# Some additional settings are required if OpenCV is built as static libs
set(OpenCV_SHARED @BUILD_SHARED_LIBS@)
diff --git a/cmake/templates/OpenCVConfig.root-WIN32.cmake.in b/cmake/templates/OpenCVConfig.root-WIN32.cmake.in
index bd98b71..7dc6666 100644
--- a/cmake/templates/OpenCVConfig.root-WIN32.cmake.in
+++ b/cmake/templates/OpenCVConfig.root-WIN32.cmake.in
@@ -78,7 +78,7 @@ if(MSVC)
set(OpenCV_RUNTIME vc12)
elseif(MSVC_VERSION EQUAL 1900)
set(OpenCV_RUNTIME vc14)
- elseif(MSVC_VERSION EQUAL 1910)
+ elseif(MSVC_VERSION EQUAL 1910 OR MSVC_VERSION EQUAL 1911)
set(OpenCV_RUNTIME vc15)
endif()
elseif(MINGW)
diff --git a/cmake/templates/cv_cpu_config.h.in b/cmake/templates/cv_cpu_config.h.in
new file mode 100644
index 0000000..27b2731
--- /dev/null
+++ b/cmake/templates/cv_cpu_config.h.in
@@ -0,0 +1,5 @@
+// OpenCV CPU baseline features
+ at OPENCV_CPU_BASELINE_DEFINITIONS_CONFIGMAKE@
+
+// OpenCV supported CPU dispatched features
+ at OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE@
diff --git a/cmake/templates/cvconfig.h.in b/cmake/templates/cvconfig.h.in
index 05add9e..76bb431 100644
--- a/cmake/templates/cvconfig.h.in
+++ b/cmake/templates/cvconfig.h.in
@@ -1,6 +1,15 @@
+#ifndef OPENCV_CVCONFIG_H_INCLUDED
+#define OPENCV_CVCONFIG_H_INCLUDED
+
/* OpenCV compiled as static or dynamic libs */
#cmakedefine BUILD_SHARED_LIBS
+/* OpenCV intrinsics optimized code */
+#cmakedefine CV_ENABLE_INTRINSICS
+
+/* OpenCV additional optimized code */
+#cmakedefine CV_DISABLE_OPTIMIZATION
+
/* Compile for 'real' NVIDIA GPU architectures */
#define CUDA_ARCH_BIN "${OPENCV_CUDA_ARCH_BIN}"
@@ -83,6 +92,9 @@
/* GTK+ 2.x toolkit */
#cmakedefine HAVE_GTK
+/* Halide support */
+#cmakedefine HAVE_HALIDE
+
/* Define to 1 if you have the <inttypes.h> header file. */
#cmakedefine HAVE_INTTYPES_H 1
@@ -92,6 +104,7 @@
/* Intel Integrated Performance Primitives */
#cmakedefine HAVE_IPP
#cmakedefine HAVE_IPP_ICV_ONLY
+#cmakedefine HAVE_IPP_IW
/* Intel IPP Async */
#cmakedefine HAVE_IPP_A
@@ -195,14 +208,41 @@
/* Intel VA-API/OpenCL */
#cmakedefine HAVE_VA_INTEL
+/* Intel Media SDK */
+#cmakedefine HAVE_MFX
+
/* Lapack */
#cmakedefine HAVE_LAPACK
-/* FP16 */
-#cmakedefine HAVE_FP16
-
/* Library was compiled with functions instrumentation */
#cmakedefine ENABLE_INSTRUMENTATION
/* OpenVX */
#cmakedefine HAVE_OPENVX
+
+#if defined(HAVE_XINE) || \
+ defined(HAVE_GSTREAMER) || \
+ defined(HAVE_QUICKTIME) || \
+ defined(HAVE_QTKIT) || \
+ defined(HAVE_AVFOUNDATION) || \
+ /*defined(HAVE_OPENNI) || too specialized */ \
+ defined(HAVE_FFMPEG) || \
+ defined(HAVE_MSMF)
+#define HAVE_VIDEO_INPUT
+#endif
+
+#if /*defined(HAVE_XINE) || */\
+ defined(HAVE_GSTREAMER) || \
+ defined(HAVE_QUICKTIME) || \
+ defined(HAVE_QTKIT) || \
+ defined(HAVE_AVFOUNDATION) || \
+ defined(HAVE_FFMPEG) || \
+ defined(HAVE_MSMF)
+#define HAVE_VIDEO_OUTPUT
+#endif
+
+/* OpenCV trace utilities */
+#cmakedefine OPENCV_TRACE
+
+
+#endif // OPENCV_CVCONFIG_H_INCLUDED
diff --git a/cmake/templates/vs_version.rc.in b/cmake/templates/vs_version.rc.in
new file mode 100644
index 0000000..3da8c3d
--- /dev/null
+++ b/cmake/templates/vs_version.rc.in
@@ -0,0 +1,38 @@
+#include <winver.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @OPENCV_VS_VER_FILEVERSION_QUAD@
+ PRODUCTVERSION @OPENCV_VS_VER_PRODUCTVERSION_QUAD@
+ FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
+#ifdef _DEBUG
+ FILEFLAGS 1
+#else
+ FILEFLAGS 0
+#endif
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE 0
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904E4"
+ BEGIN
+ VALUE "FileDescription", "@OPENCV_VS_VER_FILEDESCRIPTION_STR@\0"
+ VALUE "FileVersion", "@OPENCV_VS_VER_FILEVERSION_STR@\0"
+ VALUE "InternalName", "@OPENCV_VS_VER_INTERNALNAME_STR@\0"
+#if @OPENCV_VS_VER_HAVE_COPYRIGHT_STR@
+ VALUE "LegalCopyright", "@OPENCV_VS_VER_COPYRIGHT_STR@\0"
+#endif
+ VALUE "OriginalFilename", "@OPENCV_VS_VER_ORIGINALFILENAME_STR@\0"
+ VALUE "ProductName", "@OPENCV_VS_VER_PRODUCTNAME_STR@\0"
+ VALUE "ProductVersion", "@OPENCV_VS_VER_PRODUCTVERSION_STR@\0"
+#if @OPENCV_VS_VER_HAVE_COMMENTS_STR@
+ VALUE "Comments", "@OPENCV_VS_VER_COMMENTS_STR@\0"
+#endif
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x0409, 1252
+ END
+END
diff --git a/contrib/modules/README.md b/contrib/modules/README.md
index 8a42492..d0cde4b 100644
--- a/contrib/modules/README.md
+++ b/contrib/modules/README.md
@@ -10,7 +10,7 @@ $ cmake -D OPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules -D BUILD_opencv_<r
- **aruco**: ArUco and ChArUco Markers -- Augmented reality ArUco marker and "ChARUco" markers where ArUco markers embedded inside the white areas of the checker board.
-- **bgsegm**: Background Segmentation -- Improved Adaptive Background Mixture Model and use for real time human tracking under Variable-Lighting Conditions.
+- **bgsegm**: Background segmentation algorithm combining statistical background image estimation and per-pixel Bayesian segmentation.
- **bioinspired**: Biological Vision -- Biologically inspired vision model: minimize noise and luminance variance, transient event segmentation, high dynamic range tone mapping methods.
@@ -24,8 +24,6 @@ $ cmake -D OPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules -D BUILD_opencv_<r
- **datasets**: Datasets Reader -- Code for reading existing computer vision databases and samples of using the readers to train, test and run using that dataset's data.
-- **dnn**: Deep Neural Networks (DNNs) -- This module can read in image recogniton networks trained in the Caffe neural netowrk library and run them efficiently on CPU.
-
- **dnns_easily_fooled**: Subvert DNNs -- This code can use the activations in a network to fool the networks into recognizing something else.
- **dpm**: Deformable Part Model -- Felzenszwalb's Cascade with deformable parts object recognition code.
diff --git a/contrib/modules/aruco/include/opencv2/aruco.hpp b/contrib/modules/aruco/include/opencv2/aruco.hpp
index e9e88c5..5aa7894 100644
--- a/contrib/modules/aruco/include/opencv2/aruco.hpp
+++ b/contrib/modules/aruco/include/opencv2/aruco.hpp
@@ -76,7 +76,11 @@ namespace aruco {
//! @addtogroup aruco
//! @{
-
+enum CornerRefineMethod{
+ CORNER_REFINE_NONE, // default corners
+ CORNER_REFINE_SUBPIX, // refine the corners using subpix
+ CORNER_REFINE_CONTOUR // refine the corners using the contour-points
+};
/**
* @brief Parameters for the detectMarker process:
@@ -100,7 +104,8 @@ namespace aruco {
* - minMarkerDistanceRate: minimum mean distance beetween two marker corners to be considered
* similar, so that the smaller one is removed. The rate is relative to the smaller perimeter
* of the two markers (default 0.05).
- * - doCornerRefinement: do subpixel refinement or not
+ * - cornerRefinementMethod: corner refinement method. (CORNER_REFINE_NONE, no refinement.
+ * CORNER_REFINE_SUBPIX, do subpixel refinement. CORNER_REFINE_CONTOUR use contour-Points)
* - cornerRefinementWinSize: window size for the corner refinement process (in pixels) (default 5).
* - cornerRefinementMaxIterations: maximum number of iterations for stop criteria of the corner
* refinement process (default 30).
@@ -137,7 +142,7 @@ struct CV_EXPORTS_W DetectorParameters {
CV_PROP_RW double minCornerDistanceRate;
CV_PROP_RW int minDistanceToBorder;
CV_PROP_RW double minMarkerDistanceRate;
- CV_PROP_RW bool doCornerRefinement;
+ CV_PROP_RW int cornerRefinementMethod;
CV_PROP_RW int cornerRefinementWinSize;
CV_PROP_RW int cornerRefinementMaxIterations;
CV_PROP_RW double cornerRefinementMinAccuracy;
@@ -165,6 +170,10 @@ struct CV_EXPORTS_W DetectorParameters {
* @param parameters marker detection parameters
* @param rejectedImgPoints contains the imgPoints of those squares whose inner code has not a
* correct codification. Useful for debugging purposes.
+ * @param cameraMatrix optional input 3x3 floating-point camera matrix
+ * \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$
+ * @param distCoeff optional vector of distortion coefficients
+ * \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
*
* Performs marker detection in the input image. Only markers included in the specific dictionary
* are searched. For each detected marker, it returns the 2D position of its corner in the image
@@ -175,7 +184,7 @@ struct CV_EXPORTS_W DetectorParameters {
*/
CV_EXPORTS_W void detectMarkers(InputArray image, const Ptr<Dictionary> &dictionary, OutputArrayOfArrays corners,
OutputArray ids, const Ptr<DetectorParameters> ¶meters = DetectorParameters::create(),
- OutputArrayOfArrays rejectedImgPoints = noArray());
+ OutputArrayOfArrays rejectedImgPoints = noArray(), InputArray cameraMatrix= noArray(), InputArray distCoeff= noArray());
@@ -196,6 +205,7 @@ CV_EXPORTS_W void detectMarkers(InputArray image, const Ptr<Dictionary> &diction
* Each element in rvecs corresponds to the specific marker in imgPoints.
* @param tvecs array of output translation vectors (e.g. std::vector<cv::Vec3d>).
* Each element in tvecs corresponds to the specific marker in imgPoints.
+ * @param _objPoints array of object points of all the marker corners
*
* This function receives the detected markers and returns their pose estimation respect to
* the camera individually. So for each marker, one rotation and translation vector is returned.
@@ -209,7 +219,7 @@ CV_EXPORTS_W void detectMarkers(InputArray image, const Ptr<Dictionary> &diction
*/
CV_EXPORTS_W void estimatePoseSingleMarkers(InputArrayOfArrays corners, float markerLength,
InputArray cameraMatrix, InputArray distCoeffs,
- OutputArray rvecs, OutputArray tvecs);
+ OutputArray rvecs, OutputArray tvecs, OutputArray _objPoints = noArray());
@@ -331,8 +341,9 @@ class CV_EXPORTS_W GridBoard : public Board {
* @param distCoeffs vector of distortion coefficients
* \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
* @param rvec Output vector (e.g. cv::Mat) corresponding to the rotation vector of the board
- * (@sa Rodrigues). Used as initial guess if not empty.
+ * (see cv::Rodrigues). Used as initial guess if not empty.
* @param tvec Output vector (e.g. cv::Mat) corresponding to the translation vector of the board.
+ * @param useExtrinsicGuess defines whether initial guess for \b rvec and \b tvec will be used or not.
* Used as initial guess if not empty.
*
* This function receives the detected markers and returns the pose of a marker board composed
@@ -346,7 +357,7 @@ class CV_EXPORTS_W GridBoard : public Board {
*/
CV_EXPORTS_W int estimatePoseBoard(InputArrayOfArrays corners, InputArray ids, const Ptr<Board> &board,
InputArray cameraMatrix, InputArray distCoeffs, OutputArray rvec,
- OutputArray tvec);
+ OutputArray tvec, bool useExtrinsicGuess = false);
@@ -534,6 +545,20 @@ CV_EXPORTS_W double calibrateCameraAruco(
TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON));
+/**
+ * @brief Given a board configuration and a set of detected markers, returns the corresponding
+ * image points and object points to call solvePnP
+ *
+ * @param board Marker board layout.
+ * @param detectedCorners List of detected marker corners of the board.
+ * @param detectedIds List of identifiers for each marker.
+ * @param objPoints Vector of vectors of board marker points in the board coordinate space.
+ * @param imgPoints Vector of vectors of the projections of board marker corner points.
+*/
+CV_EXPORTS_W void getBoardObjectAndImagePoints(const Ptr<Board> &board, InputArrayOfArrays detectedCorners,
+ InputArray detectedIds, OutputArray objPoints, OutputArray imgPoints);
+
+
//! @}
}
}
diff --git a/contrib/modules/aruco/include/opencv2/aruco/charuco.hpp b/contrib/modules/aruco/include/opencv2/aruco/charuco.hpp
index 7be82ed..be535c7 100644
--- a/contrib/modules/aruco/include/opencv2/aruco/charuco.hpp
+++ b/contrib/modules/aruco/include/opencv2/aruco/charuco.hpp
@@ -174,8 +174,9 @@ CV_EXPORTS_W int interpolateCornersCharuco(InputArrayOfArrays markerCorners, Inp
* @param distCoeffs vector of distortion coefficients
* \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
* @param rvec Output vector (e.g. cv::Mat) corresponding to the rotation vector of the board
- * (@sa Rodrigues).
+ * (see cv::Rodrigues).
* @param tvec Output vector (e.g. cv::Mat) corresponding to the translation vector of the board.
+ * @param useExtrinsicGuess defines whether initial guess for \b rvec and \b tvec will be used or not.
*
* This function estimates a Charuco board pose from some detected corners.
* The function checks if the input corners are enough and valid to perform pose estimation.
@@ -183,7 +184,8 @@ CV_EXPORTS_W int interpolateCornersCharuco(InputArrayOfArrays markerCorners, Inp
*/
CV_EXPORTS_W bool estimatePoseCharucoBoard(InputArray charucoCorners, InputArray charucoIds,
const Ptr<CharucoBoard> &board, InputArray cameraMatrix,
- InputArray distCoeffs, OutputArray rvec, OutputArray tvec);
+ InputArray distCoeffs, OutputArray rvec, OutputArray tvec,
+ bool useExtrinsicGuess = false);
diff --git a/contrib/modules/aruco/samples/calibrate_camera.cpp b/contrib/modules/aruco/samples/calibrate_camera.cpp
index f0cf77f..727b2a9 100644
--- a/contrib/modules/aruco/samples/calibrate_camera.cpp
+++ b/contrib/modules/aruco/samples/calibrate_camera.cpp
@@ -90,7 +90,7 @@ static bool readDetectorParameters(string filename, Ptr<aruco::DetectorParameter
fs["minCornerDistanceRate"] >> params->minCornerDistanceRate;
fs["minDistanceToBorder"] >> params->minDistanceToBorder;
fs["minMarkerDistanceRate"] >> params->minMarkerDistanceRate;
- fs["doCornerRefinement"] >> params->doCornerRefinement;
+ fs["cornerRefinementMethod"] >> params->cornerRefinementMethod;
fs["cornerRefinementWinSize"] >> params->cornerRefinementWinSize;
fs["cornerRefinementMaxIterations"] >> params->cornerRefinementMaxIterations;
fs["cornerRefinementMinAccuracy"] >> params->cornerRefinementMinAccuracy;
diff --git a/contrib/modules/aruco/samples/calibrate_camera_charuco.cpp b/contrib/modules/aruco/samples/calibrate_camera_charuco.cpp
index 0b29349..42adeec 100644
--- a/contrib/modules/aruco/samples/calibrate_camera_charuco.cpp
+++ b/contrib/modules/aruco/samples/calibrate_camera_charuco.cpp
@@ -90,7 +90,7 @@ static bool readDetectorParameters(string filename, Ptr<aruco::DetectorParameter
fs["minCornerDistanceRate"] >> params->minCornerDistanceRate;
fs["minDistanceToBorder"] >> params->minDistanceToBorder;
fs["minMarkerDistanceRate"] >> params->minMarkerDistanceRate;
- fs["doCornerRefinement"] >> params->doCornerRefinement;
+ fs["cornerRefinementMethod"] >> params->cornerRefinementMethod;
fs["cornerRefinementWinSize"] >> params->cornerRefinementWinSize;
fs["cornerRefinementMaxIterations"] >> params->cornerRefinementMaxIterations;
fs["cornerRefinementMinAccuracy"] >> params->cornerRefinementMinAccuracy;
diff --git a/contrib/modules/aruco/samples/detect_board.cpp b/contrib/modules/aruco/samples/detect_board.cpp
index 5b173cc..00d13ab 100644
--- a/contrib/modules/aruco/samples/detect_board.cpp
+++ b/contrib/modules/aruco/samples/detect_board.cpp
@@ -93,7 +93,7 @@ static bool readDetectorParameters(string filename, Ptr<aruco::DetectorParameter
fs["minCornerDistanceRate"] >> params->minCornerDistanceRate;
fs["minDistanceToBorder"] >> params->minDistanceToBorder;
fs["minMarkerDistanceRate"] >> params->minMarkerDistanceRate;
- fs["doCornerRefinement"] >> params->doCornerRefinement;
+ fs["cornerRefinementMethod"] >> params->cornerRefinementMethod;
fs["cornerRefinementWinSize"] >> params->cornerRefinementWinSize;
fs["cornerRefinementMaxIterations"] >> params->cornerRefinementMaxIterations;
fs["cornerRefinementMinAccuracy"] >> params->cornerRefinementMinAccuracy;
@@ -145,7 +145,7 @@ int main(int argc, char *argv[]) {
return 0;
}
}
- detectorParams->doCornerRefinement = true; // do corner refinement in markers
+ detectorParams->cornerRefinementMethod = aruco::CORNER_REFINE_SUBPIX; // do corner refinement in markers
String video;
if(parser.has("v")) {
diff --git a/contrib/modules/aruco/samples/detect_board_charuco.cpp b/contrib/modules/aruco/samples/detect_board_charuco.cpp
index 57f0c0d..fd106f3 100644
--- a/contrib/modules/aruco/samples/detect_board_charuco.cpp
+++ b/contrib/modules/aruco/samples/detect_board_charuco.cpp
@@ -93,7 +93,7 @@ static bool readDetectorParameters(string filename, Ptr<aruco::DetectorParameter
fs["minCornerDistanceRate"] >> params->minCornerDistanceRate;
fs["minDistanceToBorder"] >> params->minDistanceToBorder;
fs["minMarkerDistanceRate"] >> params->minMarkerDistanceRate;
- fs["doCornerRefinement"] >> params->doCornerRefinement;
+ fs["cornerRefinementMethod"] >> params->cornerRefinementMethod;
fs["cornerRefinementWinSize"] >> params->cornerRefinementWinSize;
fs["cornerRefinementMaxIterations"] >> params->cornerRefinementMaxIterations;
fs["cornerRefinementMinAccuracy"] >> params->cornerRefinementMinAccuracy;
diff --git a/contrib/modules/aruco/samples/detect_diamonds.cpp b/contrib/modules/aruco/samples/detect_diamonds.cpp
index eda0dfc..ae1e1b1 100644
--- a/contrib/modules/aruco/samples/detect_diamonds.cpp
+++ b/contrib/modules/aruco/samples/detect_diamonds.cpp
@@ -94,7 +94,7 @@ static bool readDetectorParameters(string filename, Ptr<aruco::DetectorParameter
fs["minCornerDistanceRate"] >> params->minCornerDistanceRate;
fs["minDistanceToBorder"] >> params->minDistanceToBorder;
fs["minMarkerDistanceRate"] >> params->minMarkerDistanceRate;
- fs["doCornerRefinement"] >> params->doCornerRefinement;
+ fs["cornerRefinementMethod"] >> params->cornerRefinementMethod;
fs["cornerRefinementWinSize"] >> params->cornerRefinementWinSize;
fs["cornerRefinementMaxIterations"] >> params->cornerRefinementMaxIterations;
fs["cornerRefinementMinAccuracy"] >> params->cornerRefinementMinAccuracy;
diff --git a/contrib/modules/aruco/samples/detect_markers.cpp b/contrib/modules/aruco/samples/detect_markers.cpp
index d006a98..e954431 100644
--- a/contrib/modules/aruco/samples/detect_markers.cpp
+++ b/contrib/modules/aruco/samples/detect_markers.cpp
@@ -88,7 +88,7 @@ static bool readDetectorParameters(string filename, Ptr<aruco::DetectorParameter
fs["minCornerDistanceRate"] >> params->minCornerDistanceRate;
fs["minDistanceToBorder"] >> params->minDistanceToBorder;
fs["minMarkerDistanceRate"] >> params->minMarkerDistanceRate;
- fs["doCornerRefinement"] >> params->doCornerRefinement;
+ fs["cornerRefinementMethod"] >> params->cornerRefinementMethod;
fs["cornerRefinementWinSize"] >> params->cornerRefinementWinSize;
fs["cornerRefinementMaxIterations"] >> params->cornerRefinementMaxIterations;
fs["cornerRefinementMinAccuracy"] >> params->cornerRefinementMinAccuracy;
@@ -127,7 +127,7 @@ int main(int argc, char *argv[]) {
return 0;
}
}
- detectorParams->doCornerRefinement = true; // do corner refinement in markers
+ detectorParams->cornerRefinementMethod = aruco::CORNER_REFINE_SUBPIX; // do corner refinement in markers
int camId = parser.get<int>("ci");
diff --git a/contrib/modules/aruco/samples/detector_params.yml b/contrib/modules/aruco/samples/detector_params.yml
index ab94c03..6f804e5 100644
--- a/contrib/modules/aruco/samples/detector_params.yml
+++ b/contrib/modules/aruco/samples/detector_params.yml
@@ -12,7 +12,7 @@ minCornerDistance: 10.0
minDistanceToBorder: 3
minMarkerDistance: 10.0
minMarkerDistanceRate: 0.05
-doCornerRefinement: false
+cornerRefinementMethod: 0
cornerRefinementWinSize: 5
cornerRefinementMaxIterations: 30
cornerRefinementMinAccuracy: 0.1
diff --git a/contrib/modules/aruco/src/aruco.cpp b/contrib/modules/aruco/src/aruco.cpp
index f71aeca..04ef91d 100644
--- a/contrib/modules/aruco/src/aruco.cpp
+++ b/contrib/modules/aruco/src/aruco.cpp
@@ -63,7 +63,7 @@ DetectorParameters::DetectorParameters()
minCornerDistanceRate(0.05),
minDistanceToBorder(3),
minMarkerDistanceRate(0.05),
- doCornerRefinement(false),
+ cornerRefinementMethod(CORNER_REFINE_NONE),
cornerRefinementWinSize(5),
cornerRefinementMaxIterations(30),
cornerRefinementMinAccuracy(0.1),
@@ -602,7 +602,7 @@ static void _copyVector2Output(vector< vector< Point2f > > &vec, OutputArrayOfAr
* @brief Identify square candidates according to a marker dictionary
*/
static void _identifyCandidates(InputArray _image, vector< vector< Point2f > >& _candidates,
- InputArrayOfArrays _contours, const Ptr<Dictionary> &_dictionary,
+ vector< vector<Point> >& _contours, const Ptr<Dictionary> &_dictionary,
vector< vector< Point2f > >& _accepted, vector< int >& ids,
const Ptr<DetectorParameters> ¶ms,
OutputArrayOfArrays _rejected = noArray()) {
@@ -612,6 +612,8 @@ static void _identifyCandidates(InputArray _image, vector< vector< Point2f > >&
vector< vector< Point2f > > accepted;
vector< vector< Point2f > > rejected;
+ vector< vector< Point > > contours;
+
CV_Assert(_image.getMat().total() != 0);
Mat grey;
@@ -639,6 +641,9 @@ static void _identifyCandidates(InputArray _image, vector< vector< Point2f > >&
if(validCandidates[i] == 1) {
accepted.push_back(_candidates[i]);
ids.push_back(idsTmp[i]);
+
+ contours.push_back(_contours[i]);
+
} else {
rejected.push_back(_candidates[i]);
}
@@ -647,6 +652,8 @@ static void _identifyCandidates(InputArray _image, vector< vector< Point2f > >&
// parse output
_accepted = accepted;
+ _contours= contours;
+
if(_rejected.needed()) {
_copyVector2Output(rejected, _rejected);
}
@@ -656,7 +663,7 @@ static void _identifyCandidates(InputArray _image, vector< vector< Point2f > >&
/**
* @brief Final filter of markers after its identification
*/
-static void _filterDetectedMarkers(vector< vector< Point2f > >& _corners, vector< int >& _ids) {
+static void _filterDetectedMarkers(vector< vector< Point2f > >& _corners, vector< int >& _ids, vector< vector< Point> >& _contours) {
CV_Assert(_corners.size() == _ids.size());
if(_corners.empty()) return;
@@ -707,15 +714,21 @@ static void _filterDetectedMarkers(vector< vector< Point2f > >& _corners, vector
vector< vector< Point2f > >::iterator filteredCorners = _corners.begin();
vector< int >::iterator filteredIds = _ids.begin();
+ vector< vector< Point > >::iterator filteredContours = _contours.begin();
+
for(unsigned int i = 0; i < toRemove.size(); i++) {
if(!toRemove[i]) {
*filteredCorners++ = _corners[i];
*filteredIds++ = _ids[i];
+
+ *filteredContours++ = _contours[i];
}
}
_ids.erase(filteredIds, _ids.end());
_corners.erase(filteredCorners, _corners.end());
+
+ _contours.erase(filteredContours, _contours.end());
}
}
@@ -771,13 +784,183 @@ class MarkerSubpixelParallel : public ParallelLoopBody {
const Ptr<DetectorParameters> ¶ms;
};
+/**
+ * Line fitting A * B = C :: Called from function refineCandidateLines
+ * @param nContours, contour-container
+ */
+static Point3f _interpolate2Dline(const std::vector<cv::Point2f>& nContours){
+ float minX, minY, maxX, maxY;
+ minX = maxX = nContours[0].x;
+ minY = maxY = nContours[0].y;
+
+ for(unsigned int i = 0; i< nContours.size(); i++){
+ minX = nContours[i].x < minX ? nContours[i].x : minX;
+ minY = nContours[i].y < minY ? nContours[i].y : minY;
+ maxX = nContours[i].x > maxX ? nContours[i].x : maxX;
+ maxY = nContours[i].y > maxY ? nContours[i].y : maxY;
+ }
+
+ Mat A = Mat::ones((int)nContours.size(), 2, CV_32F); // Coefficient Matrix (N x 2)
+ Mat B((int)nContours.size(), 1, CV_32F); // Variables Matrix (N x 1)
+ Mat C; // Constant
+
+ if(maxX - minX > maxY - minY){
+ for(unsigned int i =0; i < nContours.size(); i++){
+ A.at<float>(i,0)= nContours[i].x;
+ B.at<float>(i,0)= nContours[i].y;
+ }
+
+ solve(A, B, C, DECOMP_NORMAL);
+
+ return Point3f(C.at<float>(0, 0), -1., C.at<float>(1, 0));
+ }
+ else{
+ for(unsigned int i =0; i < nContours.size(); i++){
+ A.at<float>(i,0)= nContours[i].y;
+ B.at<float>(i,0)= nContours[i].x;
+ }
+
+ solve(A, B, C, DECOMP_NORMAL);
+
+ return Point3f(-1., C.at<float>(0, 0), C.at<float>(1, 0));
+ }
+
+}
+
+/**
+ * Find the Point where the lines crosses :: Called from function refineCandidateLines
+ * @param nLine1
+ * @param nLine2
+ * @return Crossed Point
+ */
+static Point2f _getCrossPoint(Point3f nLine1, Point3f nLine2){
+ Matx22f A(nLine1.x, nLine1.y, nLine2.x, nLine2.y);
+ Vec2f B(-nLine1.z, -nLine2.z);
+ return Vec2f(A.solve(B).val);
+}
+
+static void _distortPoints(vector<cv::Point2f>& in, const Mat& camMatrix, const Mat& distCoeff) {
+ // trivial extrinsics
+ Matx31f Rvec(0,0,0);
+ Matx31f Tvec(0,0,0);
+
+ // calculate 3d points and then reproject, so opencv makes the distortion internally
+ vector<cv::Point3f> cornersPoints3d;
+ for (unsigned int i = 0; i < in.size(); i++){
+ float x= (in[i].x - float(camMatrix.at<double>(0, 2))) / float(camMatrix.at<double>(0, 0));
+ float y= (in[i].y - float(camMatrix.at<double>(1, 2))) / float(camMatrix.at<double>(1, 1));
+ cornersPoints3d.push_back(Point3f(x,y,1));
+ }
+ cv::projectPoints(cornersPoints3d, Rvec, Tvec, camMatrix, distCoeff, in);
+}
+
+/**
+ * Refine Corners using the contour vector :: Called from function detectMarkers
+ * @param nContours, contour-container
+ * @param nCorners, candidate Corners
+ * @param camMatrix, cameraMatrix input 3x3 floating-point camera matrix
+ * @param distCoeff, distCoeffs vector of distortion coefficient
+ */
+static void _refineCandidateLines(std::vector<Point>& nContours, std::vector<Point2f>& nCorners, const Mat& camMatrix, const Mat& distCoeff){
+ vector<Point2f> contour2f(nContours.begin(), nContours.end());
+
+ if(!camMatrix.empty() && !distCoeff.empty()){
+ undistortPoints(contour2f, contour2f, camMatrix, distCoeff);
+ }
+
+ /* 5 groups :: to group the edges
+ * 4 - classified by its corner
+ * extra group - (temporary) if contours do not begin with a corner
+ */
+ vector<Point2f> cntPts[5];
+ int cornerIndex[4]={-1};
+ int group=4;
+
+ for ( unsigned int i =0; i < nContours.size(); i++ ) {
+ for(unsigned int j=0; j<4; j++){
+ if ( nCorners[j] == contour2f[i] ){
+ cornerIndex[j] = i;
+ group=j;
+ }
+ }
+ cntPts[group].push_back(contour2f[i]);
+ }
+
+ // saves extra group into corresponding
+ if( !cntPts[4].empty() ){
+ for( unsigned int i=0; i < cntPts[4].size() ; i++ )
+ cntPts[group].push_back(cntPts[4].at(i));
+ cntPts[4].clear();
+ }
+
+ //Evaluate contour direction :: using the position of the detected corners
+ int inc=1;
+
+ inc = ( (cornerIndex[0] > cornerIndex[1]) && (cornerIndex[3] > cornerIndex[0]) ) ? -1:inc;
+ inc = ( (cornerIndex[2] > cornerIndex[3]) && (cornerIndex[1] > cornerIndex[2]) ) ? -1:inc;
+
+ // calculate the line :: who passes through the grouped points
+ Point3f lines[4];
+ for(int i=0; i<4; i++){
+ lines[i]=_interpolate2Dline(cntPts[i]);
+ }
+
+ /*
+ * calculate the corner :: where the lines crosses to each other
+ * clockwise direction no clockwise direction
+ * 0 1
+ * .---. 1 .---. 2
+ * | | | |
+ * 3 .___. 0 .___.
+ * 2 3
+ */
+ for(int i=0; i < 4; i++){
+ if(inc<0)
+ nCorners[i] = _getCrossPoint(lines[ i ], lines[ (i+1)%4 ]); // 01 12 23 30
+ else
+ nCorners[i] = _getCrossPoint(lines[ i ], lines[ (i+3)%4 ]); // 30 01 12 23
+ }
+
+ if(!camMatrix.empty() && !distCoeff.empty()){
+ _distortPoints(nCorners, camMatrix, distCoeff);
+ }
+}
+
+
+/**
+ * ParallelLoopBody class for the parallelization of the marker corner contour refinement
+ * Called from function detectMarkers()
+ */
+class MarkerContourParallel : public ParallelLoopBody {
+ public:
+ MarkerContourParallel( vector< vector< Point > >& _contours, vector< vector< Point2f > >& _candidates, const Mat& _camMatrix, const Mat& _distCoeff)
+ : contours(_contours), candidates(_candidates), camMatrix(_camMatrix), distCoeff(_distCoeff){}
+
+ void operator()(const Range &range) const {
+
+ for(int i = range.start; i < range.end; i++) {
+ _refineCandidateLines(contours[i], candidates[i], camMatrix, distCoeff);
+ }
+ }
+
+ private:
+ MarkerContourParallel &operator=(const MarkerContourParallel &){
+ return *this;
+ }
+
+ vector< vector< Point > >& contours;
+ vector< vector< Point2f > >& candidates;
+ const Mat& camMatrix;
+ const Mat& distCoeff;
+};
+
/**
*/
void detectMarkers(InputArray _image, const Ptr<Dictionary> &_dictionary, OutputArrayOfArrays _corners,
OutputArray _ids, const Ptr<DetectorParameters> &_params,
- OutputArrayOfArrays _rejectedImgPoints) {
+ OutputArrayOfArrays _rejectedImgPoints, InputArrayOfArrays camMatrix, InputArrayOfArrays distCoeff) {
CV_Assert(!_image.empty());
@@ -795,14 +978,14 @@ void detectMarkers(InputArray _image, const Ptr<Dictionary> &_dictionary, Output
_rejectedImgPoints);
/// STEP 3: Filter detected markers;
- _filterDetectedMarkers(candidates, ids);
+ _filterDetectedMarkers(candidates, ids, contours);
// copy to output arrays
_copyVector2Output(candidates, _corners);
Mat(ids).copyTo(_ids);
- /// STEP 4: Corner refinement
- if(_params->doCornerRefinement) {
+ /// STEP 4: Corner refinement :: use corner subpix
+ if( _params->cornerRefinementMethod == CORNER_REFINE_SUBPIX ) {
CV_Assert(_params->cornerRefinementWinSize > 0 && _params->cornerRefinementMaxIterations > 0 &&
_params->cornerRefinementMinAccuracy > 0);
@@ -819,6 +1002,19 @@ void detectMarkers(InputArray _image, const Ptr<Dictionary> &_dictionary, Output
parallel_for_(Range(0, _corners.cols()),
MarkerSubpixelParallel(&grey, _corners, _params));
}
+
+ /// STEP 4, Optional : Corner refinement :: use contour container
+ if( _params->cornerRefinementMethod == CORNER_REFINE_CONTOUR){
+
+ if(! _ids.empty()){
+
+ // do corner refinement using the contours for each detected markers
+ parallel_for_(Range(0, _corners.cols()), MarkerContourParallel(contours, candidates, camMatrix.getMat(), distCoeff.getMat()));
+
+ // copy the corners to the output array
+ _copyVector2Output(candidates, _corners);
+ }
+ }
}
@@ -861,7 +1057,7 @@ class SinglePoseEstimationParallel : public ParallelLoopBody {
*/
void estimatePoseSingleMarkers(InputArrayOfArrays _corners, float markerLength,
InputArray _cameraMatrix, InputArray _distCoeffs,
- OutputArray _rvecs, OutputArray _tvecs) {
+ OutputArray _rvecs, OutputArray _tvecs, OutputArray _objPoints) {
CV_Assert(markerLength > 0);
@@ -883,22 +1079,20 @@ void estimatePoseSingleMarkers(InputArrayOfArrays _corners, float markerLength,
parallel_for_(Range(0, nMarkers),
SinglePoseEstimationParallel(markerObjPoints, _corners, _cameraMatrix,
_distCoeffs, rvecs, tvecs));
+ if(_objPoints.needed()){
+ markerObjPoints.convertTo(_objPoints, -1);
+ }
}
-/**
- * @brief Given a board configuration and a set of detected markers, returns the corresponding
- * image points and object points to call solvePnP
- */
-static void _getBoardObjectAndImagePoints(const Ptr<Board> &_board, InputArray _detectedIds,
- InputArrayOfArrays _detectedCorners,
- OutputArray _imgPoints, OutputArray _objPoints) {
+void getBoardObjectAndImagePoints(const Ptr<Board> &board, InputArrayOfArrays detectedCorners,
+ InputArray detectedIds, OutputArray objPoints, OutputArray imgPoints) {
- CV_Assert(_board->ids.size() == _board->objPoints.size());
- CV_Assert(_detectedIds.total() == _detectedCorners.total());
+ CV_Assert(board->ids.size() == board->objPoints.size());
+ CV_Assert(detectedIds.total() == detectedCorners.total());
- size_t nDetectedMarkers = _detectedIds.total();
+ size_t nDetectedMarkers = detectedIds.total();
vector< Point3f > objPnts;
objPnts.reserve(nDetectedMarkers);
@@ -908,20 +1102,20 @@ static void _getBoardObjectAndImagePoints(const Ptr<Board> &_board, InputArray _
// look for detected markers that belong to the board and get their information
for(unsigned int i = 0; i < nDetectedMarkers; i++) {
- int currentId = _detectedIds.getMat().ptr< int >(0)[i];
- for(unsigned int j = 0; j < _board->ids.size(); j++) {
- if(currentId == _board->ids[j]) {
+ int currentId = detectedIds.getMat().ptr< int >(0)[i];
+ for(unsigned int j = 0; j < board->ids.size(); j++) {
+ if(currentId == board->ids[j]) {
for(int p = 0; p < 4; p++) {
- objPnts.push_back(_board->objPoints[j][p]);
- imgPnts.push_back(_detectedCorners.getMat(i).ptr< Point2f >(0)[p]);
+ objPnts.push_back(board->objPoints[j][p]);
+ imgPnts.push_back(detectedCorners.getMat(i).ptr< Point2f >(0)[p]);
}
}
}
}
// create output
- Mat(objPnts).copyTo(_objPoints);
- Mat(imgPnts).copyTo(_imgPoints);
+ Mat(objPnts).copyTo(objPoints);
+ Mat(imgPnts).copyTo(imgPoints);
}
@@ -1166,7 +1360,7 @@ void refineDetectedMarkers(InputArray _image, const Ptr<Board> &_board,
if(closestCandidateIdx >= 0) {
// subpixel refinement
- if(params.doCornerRefinement) {
+ if(_params->cornerRefinementMethod == CORNER_REFINE_SUBPIX) {
CV_Assert(params.cornerRefinementWinSize > 0 &&
params.cornerRefinementMaxIterations > 0 &&
params.cornerRefinementMinAccuracy > 0);
@@ -1237,26 +1431,19 @@ void refineDetectedMarkers(InputArray _image, const Ptr<Board> &_board,
*/
int estimatePoseBoard(InputArrayOfArrays _corners, InputArray _ids, const Ptr<Board> &board,
InputArray _cameraMatrix, InputArray _distCoeffs, OutputArray _rvec,
- OutputArray _tvec) {
+ OutputArray _tvec, bool useExtrinsicGuess) {
CV_Assert(_corners.total() == _ids.total());
// get object and image points for the solvePnP function
Mat objPoints, imgPoints;
- _getBoardObjectAndImagePoints(board, _ids, _corners, imgPoints, objPoints);
+ getBoardObjectAndImagePoints(board, _corners, _ids, objPoints, imgPoints);
CV_Assert(imgPoints.total() == objPoints.total());
if(objPoints.total() == 0) // 0 of the detected markers in board
return 0;
- bool useExtrinsicGuess = true;
- if (_rvec.empty() || _tvec.empty())
- {
- _rvec.create(3, 1, CV_64FC1);
- _tvec.create(3, 1, CV_64FC1);
- useExtrinsicGuess = false;
- }
solvePnP(objPoints, imgPoints, _cameraMatrix, _distCoeffs, _rvec, _tvec, useExtrinsicGuess);
// divide by four since all the four corners are concatenated in the array for each marker
@@ -1278,12 +1465,17 @@ void GridBoard::draw(Size outSize, OutputArray _img, int marginSize, int borderB
Ptr<Board> Board::create(InputArrayOfArrays objPoints, const Ptr<Dictionary> &dictionary, InputArray ids) {
CV_Assert(objPoints.total() == ids.total());
- CV_Assert(objPoints.type() == CV_32FC3);
+ CV_Assert(objPoints.type() == CV_32FC3 || objPoints.type() == CV_32FC1);
std::vector< std::vector< Point3f > > obj_points_vector;
for (unsigned int i = 0; i < objPoints.total(); i++) {
std::vector<Point3f> corners;
Mat corners_mat = objPoints.getMat(i);
+
+ if(corners_mat.type() == CV_32FC1)
+ corners_mat = corners_mat.reshape(3);
+ CV_Assert(corners_mat.total() == 4);
+
for (int j = 0; j < 4; j++) {
corners.push_back(corners_mat.at<Point3f>(j));
}
@@ -1484,6 +1676,7 @@ void _drawPlanarBoardImpl(Board *_board, Size outSize, OutputArray _img, int mar
// get marker
Size dst_sz(outCorners[2] - outCorners[0]); // assuming CCW order
+ dst_sz.width = dst_sz.height = std::min(dst_sz.width, dst_sz.height); //marker should be square
dictionary.drawMarker(_board->ids[m], dst_sz.width, marker, borderBits);
if((outCorners[0].y == outCorners[1].y) && (outCorners[1].x == outCorners[2].x)) {
@@ -1546,8 +1739,8 @@ double calibrateCameraAruco(InputArrayOfArrays _corners, InputArray _ids, InputA
}
markerCounter += nMarkersInThisFrame;
Mat currentImgPoints, currentObjPoints;
- _getBoardObjectAndImagePoints(board, thisFrameIds, thisFrameCorners, currentImgPoints,
- currentObjPoints);
+ getBoardObjectAndImagePoints(board, thisFrameCorners, thisFrameIds, currentObjPoints,
+ currentImgPoints);
if(currentImgPoints.total() > 0 && currentObjPoints.total() > 0) {
processedImagePoints.push_back(currentImgPoints);
processedObjectPoints.push_back(currentObjPoints);
diff --git a/contrib/modules/aruco/src/charuco.cpp b/contrib/modules/aruco/src/charuco.cpp
index 9b9dea1..20854da 100644
--- a/contrib/modules/aruco/src/charuco.cpp
+++ b/contrib/modules/aruco/src/charuco.cpp
@@ -656,7 +656,7 @@ static bool _arePointsEnoughForPoseEstimation(const vector< Point3f > &points) {
*/
bool estimatePoseCharucoBoard(InputArray _charucoCorners, InputArray _charucoIds,
const Ptr<CharucoBoard> &_board, InputArray _cameraMatrix, InputArray _distCoeffs,
- OutputArray _rvec, OutputArray _tvec) {
+ OutputArray _rvec, OutputArray _tvec, bool useExtrinsicGuess) {
CV_Assert((_charucoCorners.getMat().total() == _charucoIds.getMat().total()));
@@ -674,7 +674,7 @@ bool estimatePoseCharucoBoard(InputArray _charucoCorners, InputArray _charucoIds
// points need to be in different lines, check if detected points are enough
if(!_arePointsEnoughForPoseEstimation(objPoints)) return false;
- solvePnP(objPoints, _charucoCorners, _cameraMatrix, _distCoeffs, _rvec, _tvec);
+ solvePnP(objPoints, _charucoCorners, _cameraMatrix, _distCoeffs, _rvec, _tvec, useExtrinsicGuess);
return true;
}
diff --git a/contrib/modules/aruco/test/test_boarddetection.cpp b/contrib/modules/aruco/test/test_boarddetection.cpp
index e5a2bd4..c57b2dd 100644
--- a/contrib/modules/aruco/test/test_boarddetection.cpp
+++ b/contrib/modules/aruco/test/test_boarddetection.cpp
@@ -299,7 +299,7 @@ void CV_ArucoRefine::run(int) {
vector< int > ids;
Ptr<aruco::DetectorParameters> params = aruco::DetectorParameters::create();
params->minDistanceToBorder = 3;
- params->doCornerRefinement = true;
+ params->cornerRefinementMethod = aruco::CORNER_REFINE_SUBPIX;
params->markerBorderBits = markerBorder;
aruco::detectMarkers(img, dictionary, corners, ids, params, rejected);
@@ -400,7 +400,7 @@ TEST(CV_ArucoBoardPose, CheckNegativeZ)
pts2d.push_back(cv::Point2f(586.3f, 188.5f));
corners.push_back(pts2d);
- nUsed = cv::aruco::estimatePoseBoard(corners, board.ids, boardPtr, cameraMatrix, Mat(), rvec, tvec);
+ nUsed = cv::aruco::estimatePoseBoard(corners, board.ids, boardPtr, cameraMatrix, Mat(), rvec, tvec, true);
ASSERT_EQ(nUsed, 2);
cv::Rodrigues(rvec, rotm);
diff --git a/contrib/modules/aruco/test/test_misc.cpp b/contrib/modules/aruco/test/test_misc.cpp
new file mode 100644
index 0000000..db9e83a
--- /dev/null
+++ b/contrib/modules/aruco/test/test_misc.cpp
@@ -0,0 +1,24 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "test_precomp.hpp"
+#include <opencv2/aruco/charuco.hpp>
+
+TEST(CV_ArucoDrawMarker, regression_1226)
+{
+ int squares_x = 7;
+ int squares_y = 5;
+ int bwidth = 1600;
+ int bheight = 1200;
+
+ cv::Ptr<cv::aruco::Dictionary> dict = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_4X4_50);
+ cv::Ptr<cv::aruco::CharucoBoard> board = cv::aruco::CharucoBoard::create(squares_x, squares_y, 1.0, 0.75, dict);
+ cv::Size sz(bwidth, bheight);
+ cv::Mat mat;
+
+ ASSERT_NO_THROW(
+ {
+ board->draw(sz, mat, 0, 1);
+ });
+}
diff --git a/contrib/modules/aruco/tutorials/aruco_board_detection/aruco_board_detection.markdown b/contrib/modules/aruco/tutorials/aruco_board_detection/aruco_board_detection.markdown
index c4eeb40..0b88b06 100644
--- a/contrib/modules/aruco/tutorials/aruco_board_detection/aruco_board_detection.markdown
+++ b/contrib/modules/aruco/tutorials/aruco_board_detection/aruco_board_detection.markdown
@@ -30,7 +30,7 @@ The aruco module allows the use of Boards. The main class is the ```cv::aruco::B
class Board {
public:
std::vector<std::vector<cv::Point3f> > objPoints;
- cv::aruco::Dictionary dictionary;
+ cv::Ptr<cv::aruco::Dictionary> dictionary;
std::vector<int> ids;
};
```
@@ -57,10 +57,10 @@ The aruco module provides a specific function, ```estimatePoseBoard()```, to per
cv::Mat cameraMatrix, distCoeffs;
readCameraParameters(cameraMatrix, distCoeffs);
// assume we have a function to create the board object
- cv::aruco::Board board = createBoard();
+ cv::Ptr<cv::aruco::Board> board = cv::aruco::Board::create();
...
- vector< int > markerIds;
- vector< vector<Point2f> > markerCorners;
+ std::vector<int> markerIds;
+ std::vector<std::vector<cv::Point2f>> markerCorners;
cv::aruco::detectMarkers(inputImage, board.dictionary, markerCorners, markerIds);
// if at least one marker detected
if(markerIds.size() > 0) {
@@ -137,9 +137,9 @@ After creating a Grid Board, we probably want to print it and use it. A function
of a ```GridBoard``` is provided in ```cv::aruco::GridBoard::draw()```. For example:
``` c++
- cv::aruco::GridBoard board = cv::aruco::GridBoard::create(5, 7, 0.04, 0.01, dictionary);
+ cv::Ptr<cv::aruco::GridBoard> board = cv::aruco::GridBoard::create(5, 7, 0.04, 0.01, dictionary);
cv::Mat boardImage;
- board.draw( cv::Size(600, 500), boardImage, 10, 1 );
+ board->draw( cv::Size(600, 500), boardImage, 10, 1 );
```
- The first parameter is the size of the output image in pixels. In this case 600x500 pixels. If this is not proportional
@@ -170,8 +170,8 @@ Finally, a full example of board detection:
// camera parameters are read from somewhere
readCameraParameters(cameraMatrix, distCoeffs);
- cv::aruco::Dictionary dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
- cv::aruco::GridBoard board = cv::aruco::GridBoard::create(5, 7, 0.04, 0.01, dictionary);
+ cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
+ cv::Ptr<cv::aruco::GridBoard> board = cv::aruco::GridBoard::create(5, 7, 0.04, 0.01, dictionary);
while (inputVideo.grab()) {
cv::Mat image, imageCopy;
@@ -256,10 +256,10 @@ internal bits are not analyzed at all and only the corner distances are evaluate
This is an example of using the ```refineDetectedMarkers()``` function:
``` c++
- cv::aruco::Dictionary dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
- cv::aruco::GridBoard board = cv::aruco::GridBoard::create(5, 7, 0.04, 0.01, dictionary);
- vector< int > markerIds;
- vector< vector<Point2f> > markerCorners, rejectedCandidates;
+ cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
+ cv::Ptr<cv::aruco::GridBoard> board = cv::aruco::GridBoard::create(5, 7, 0.04, 0.01, dictionary);
+ std::vector<int> markerIds;
+ std::vector<std::vector<cv::Point2f>> markerCorners, rejectedCandidates;
cv::aruco::detectMarkers(inputImage, dictionary, markerCorners, markerIds, cv::aruco::DetectorParameters(), rejectedCandidates);
cv::aruco::refineDetectedMarkersinputImage, board, markerCorners, markerIds, rejectedCandidates);
diff --git a/contrib/modules/aruco/tutorials/aruco_calibration/aruco_calibration.markdown b/contrib/modules/aruco/tutorials/aruco_calibration/aruco_calibration.markdown
index e9f6e36..617dc55 100644
--- a/contrib/modules/aruco/tutorials/aruco_calibration/aruco_calibration.markdown
+++ b/contrib/modules/aruco/tutorials/aruco_calibration/aruco_calibration.markdown
@@ -33,18 +33,18 @@ visible in all the viewpoints.
The function to calibrate is ```calibrateCameraCharuco()```. Example:
``` c++
- aruco::CharucoBoard board = ... // create charuco board
+ cv::Ptr<aruco::CharucoBoard> board = ... // create charuco board
cv::Size imgSize = ... // camera image size
- std::vector< std::vector<cv::Point2f> > allCharucoCorners;
- std::vector< std::vector<int> > allCharucoIds;
+ std::vector<std::vector<cv::Point2f>> allCharucoCorners;
+ std::vector<std::vector<int>> allCharucoIds;
// Detect charuco board from several viewpoints and fill allCharucoCorners and allCharucoIds
...
...
// After capturing in several viewpoints, start calibration
cv::Mat cameraMatrix, distCoeffs;
- std::vector< Mat > rvecs, tvecs;
+ std::vector<cv::Mat> rvecs, tvecs;
int calibrationFlags = ... // Set calibration flags (same than in calibrateCamera() function)
double repError = cv::aruco::calibrateCameraCharuco(allCharucoCorners, allCharucoIds, board, imgSize, cameraMatrix, distCoeffs, rvecs, tvecs, calibrationFlags);
@@ -81,19 +81,19 @@ requires the detections of an ArUco board from different viewpoints.
Example of ```calibrateCameraAruco()``` use:
``` c++
- aruco::Board board = ... // create aruco board
+ cv::Ptr<aruco::Board> board = ... // create aruco board
cv::Size imgSize = ... // camera image size
- std::vector< std::vector< cv::Point2f > > allCornersConcatenated;
- std::vector< int > allIdsConcatenated;
- std::vector< int > markerCounterPerFrame;
+ std::vector<std::vector<cv::Point2f>> allCornersConcatenated;
+ std::vector<int> allIdsConcatenated;
+ std::vector<int> markerCounterPerFrame;
// Detect aruco board from several viewpoints and fill allCornersConcatenated, allIdsConcatenated and markerCounterPerFrame
...
...
// After capturing in several viewpoints, start calibration
cv::Mat cameraMatrix, distCoeffs;
- std::vector< Mat > rvecs, tvecs;
+ std::vector<cv::Mat> rvecs, tvecs;
int calibrationFlags = ... // Set calibration flags (same than in calibrateCamera() function)
double repError = cv::aruco::calibrateCameraAruco(allCornersConcatenated, allIdsConcatenated, markerCounterPerFrame, board, imgSize, cameraMatrix, distCoeffs, rvecs, tvecs, calibrationFlags);
diff --git a/contrib/modules/aruco/tutorials/aruco_detection/aruco_detection.markdown b/contrib/modules/aruco/tutorials/aruco_detection/aruco_detection.markdown
index 4ebda3e..b641d3a 100644
--- a/contrib/modules/aruco/tutorials/aruco_detection/aruco_detection.markdown
+++ b/contrib/modules/aruco/tutorials/aruco_detection/aruco_detection.markdown
@@ -20,7 +20,7 @@ a popular library for detection of square fiducial markers developed by Rafael M
The aruco functionalities are included in:
``` c++
- \#include <opencv2/aruco.hpp>
+ #include <opencv2/aruco.hpp>
```
@@ -71,7 +71,7 @@ For example, lets analyze the following call:
``` c++
cv::Mat markerImage;
- cv::aruco::Dictionary dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
+ cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
cv::aruco::drawMarker(dictionary, 23, 200, markerImage, 1);
```
@@ -156,10 +156,10 @@ An example of marker detection:
``` c++
cv::Mat inputImage;
...
- vector< int > markerIds;
- vector< vector<Point2f> > markerCorners, rejectedCandidates;
- cv::aruco::DetectorParameters parameters;
- cv::aruco::Dictionary dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
+ std::vector<int> markerIds;
+ std::vector<std::vector<cv::Point2f>> markerCorners, rejectedCandidates;
+ cv::Ptr<cv::aruco::DetectorParameters> parameters;
+ cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
cv::aruco::detectMarkers(inputImage, dictionary, markerCorners, markerIds, parameters, rejectedCandidates);
```
@@ -204,7 +204,7 @@ camera:
``` c++
cv::VideoCapture inputVideo;
inputVideo.open(0);
- cv::aruco::Dictionary dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
+ cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
while (inputVideo.grab()) {
cv::Mat image, imageCopy;
inputVideo.retrieve(image);
@@ -263,9 +263,9 @@ information).
The aruco module provides a function to estimate the poses of all the detected markers:
``` c++
- Mat cameraMatrix, distCoeffs;
+ cv::Mat cameraMatrix, distCoeffs;
...
- vector< Vec3d > rvecs, tvecs;
+ std::vector<cv::Vec3d> rvecs, tvecs;
cv::aruco::estimatePoseSingleMarkers(corners, 0.05, cameraMatrix, distCoeffs, rvecs, tvecs);
```
@@ -303,7 +303,7 @@ A basic full example for pose estimation from single markers:
// camera parameters are read from somewhere
readCameraParameters(cameraMatrix, distCoeffs);
- cv::aruco::Dictionary dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
+ cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
while (inputVideo.grab()) {
cv::Mat image, imageCopy;
@@ -311,14 +311,14 @@ A basic full example for pose estimation from single markers:
image.copyTo(imageCopy);
std::vector<int> ids;
- std::vector<std::vector<cv::Point2f> > corners;
+ std::vector<std::vector<cv::Point2f>> corners;
cv::aruco::detectMarkers(image, dictionary, corners, ids);
// if at least one marker detected
if (ids.size() > 0) {
cv::aruco::drawDetectedMarkers(imageCopy, corners, ids);
- vector< Mat > rvecs, tvecs;
+ std::vector<cv::Mat> rvecs, tvecs;
cv::aruco::estimatePoseSingleMarkers(corners, 0.05, cameraMatrix, distCoeffs, rvecs, tvecs);
// draw axis for each marker
for(int i=0; i<ids.size(); i++)
@@ -374,7 +374,7 @@ This is the easiest way to select a dictionary. The aruco module includes a set
of a variety of marker sizes and number of markers. For instance:
``` c++
- cv::aruco::Dictionary dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
+ cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
```
DICT_6X6_250 is an example of predefined dictionary of markers with 6x6 bits and a total of 250
@@ -390,7 +390,7 @@ The dictionary can be generated automatically to adjust to the desired number of
the inter-marker distance is optimized:
``` c++
- cv::aruco::Dictionary dictionary = cv::aruco::generateCustomDictionary(36, 5);
+ cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::generateCustomDictionary(36, 5);
```
This will generate a customized dictionary composed by 36 markers of 5x5 bits. The process can take several
@@ -432,7 +432,7 @@ Fortunately, a marker can be easily transformed to this form using the static me
For example:
``` c++
- Dictionary dictionary;
+ cv::aruco::Dictionary dictionary;
// markers of 6x6 bits
dictionary.markerSize = 6;
// maximum number of bit corrections
@@ -440,10 +440,11 @@ For example:
// lets create a dictionary of 100 markers
for(int i=0; i<100; i++)
+ {
// assume generateMarkerBits() generate a new marker in binary format, so that
// markerBits is a 6x6 matrix of CV_8UC1 type, only containing 0s and 1s
cv::Mat markerBits = generateMarkerBits();
- cv::Mat markerCompressed = getByteListFromBits(markerBits);
+ cv::Mat markerCompressed = cv::aruco::Dictionary::getByteListFromBits(markerBits);
// add the marker as a new row
dictionary.bytesList.push_back(markerCompressed);
}
@@ -701,23 +702,23 @@ Default value: 0.6
#### Corner Refinement
After markers have been detected and identified, the last step is performing subpixel refinement
-in the corner positions (see OpenCV ```cornerSubPix()```)
+in the corner positions (see OpenCV ```cornerSubPix()``` and ```cv::aruco::CornerRefineMethod```)
Note that this step is optional and it only makes sense if the position of the marker corners have to
be accurate, for instance for pose estimation. It is usually a time consuming step and it is disabled by default.
-- ```bool doCornerRefinement```
+- ```int cornerRefinementMethod```
This parameter determines if the corner subpixel process is performed or not. It can be disabled
if accurate corners are not necessary.
-Default value: false.
+Default value: ```CORNER_REFINE_NONE```.
- ```int cornerRefinementWinSize```
This parameter determines the window size of the subpixel refinement process.
-High values can produce that close image corners are included in the window region, so that the
+High values can produce the effect that close image corners are included in the window region, so that the
marker corner moves to a different and wrong location during the process. Furthermore
it can affect to performance.
diff --git a/contrib/modules/aruco/tutorials/charuco_detection/charuco_detection.markdown b/contrib/modules/aruco/tutorials/charuco_detection/charuco_detection.markdown
index 1d66970..dcba5f9 100644
--- a/contrib/modules/aruco/tutorials/charuco_detection/charuco_detection.markdown
+++ b/contrib/modules/aruco/tutorials/charuco_detection/charuco_detection.markdown
@@ -29,7 +29,7 @@ The aruco module provides the ```cv::aruco::CharucoBoard``` class that represent
This class, as the rest of ChArUco functionalities, are defined in:
``` c++
- \#include <opencv2/aruco/charuco.hpp>
+ #include <opencv2/aruco/charuco.hpp>
```
To define a ```CharucoBoard```, it is necesary:
@@ -60,9 +60,9 @@ Once we have our ```CharucoBoard``` object, we can create an image to print it.
```CharucoBoard::draw()``` method:
``` c++
- cv::aruco::CharucoBoard board = cv::aruco::CharucoBoard::create(5, 7, 0.04, 0.02, dictionary);
+ cv::Ptr<cv::aruco::CharucoBoard> board = cv::aruco::CharucoBoard::create(5, 7, 0.04, 0.02, dictionary);
cv::Mat boardImage;
- board.draw( cv::Size(600, 500), boardImage, 10, 1 );
+ board->draw( cv::Size(600, 500), boardImage, 10, 1 );
```
- The first parameter is the size of the output image in pixels. In this case 600x500 pixels. If this is not proportional
@@ -94,8 +94,8 @@ in the board.
So, a detected ChArUco board consists in:
-- ```vector<Point2f> charucoCorners``` : list of image positions of the detected corners.
-- ```vector <int> charucoIds``` : ids for each of the detected corners in ```charucoCorners```.
+- ```std::vector<cv::Point2f> charucoCorners``` : list of image positions of the detected corners.
+- ```std::vector<int> charucoIds``` : ids for each of the detected corners in ```charucoCorners```.
The detection of the ChArUco corners is based on the previous detected markers. So that, first markers are detected, and then
ChArUco corners are interpolated from markers.
@@ -107,11 +107,11 @@ The function that detect the ChArUco corners is ```cv::aruco::interpolateCorners
cv::Mat cameraMatrix, distCoeffs;
// camera parameters are read from somewhere
readCameraParameters(cameraMatrix, distCoeffs);
- cv::aruco::Dictionary dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
- cv::aruco::CharucoBoard board = cv::aruco::CharucoBoard::create(5, 7, 0.04, 0.02, dictionary);
+ cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
+ cv::Ptr<cv::aruco::CharucoBoard> board = cv::aruco::CharucoBoard::create(5, 7, 0.04, 0.02, dictionary);
...
- vector< int > markerIds;
- vector< vector<Point2f> > markerCorners;
+ std::vector<int> markerIds;
+ std::vector<std::vector<cv::Point2f>> markerCorners;
cv::aruco::detectMarkers(inputImage, board.dictionary, markerCorners, markerIds);
// if at least one marker detected
@@ -136,13 +136,13 @@ are optional. A similar example without these parameters would be:
``` c++
cv::Mat inputImage;
- cv::aruco::Dictionary dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
- cv::aruco::CharucoBoard board = cv::aruco::CharucoBoard::create(5, 7, 0.04, 0.02, dictionary);
+ cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
+ cv::Ptr<cv::aruco::CharucoBoard> board = cv::aruco::CharucoBoard::create(5, 7, 0.04, 0.02, dictionary);
...
- vector< int > markerIds;
- vector< vector<Point2f> > markerCorners;
- DetectorParameters params;
- params.doCornerRefinement = false;
+ std::vector<int> markerIds;
+ std::vector<std::vector<cv::Point2f>> markerCorners;
+ cv::Ptr<cv::aruco::DetectorParameters> params;
+ params->cornerRefinementMethod = cv::aruco::CORNER_REFINE_NONE;
cv::aruco::detectMarkers(inputImage, board.dictionary, markerCorners, markerIds, params);
// if at least one marker detected
@@ -203,11 +203,11 @@ Finally, this is a full example of ChArUco detection (without using calibration
cv::VideoCapture inputVideo;
inputVideo.open(0);
- cv::aruco::Dictionary dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
- cv::aruco::CharucoBoard board = cv::aruco::CharucoBoard::create(5, 7, 0.04, 0.02, dictionary);
+ cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
+ cv::Ptr<cv::aruco::CharucoBoard> board = cv::aruco::CharucoBoard::create(5, 7, 0.04, 0.02, dictionary);
- DetectorParameters params;
- params.doCornerRefinement = false;
+ cv::Ptr<cv::aruco::DetectorParameters> params;
+ params->cornerRefinementMethod = cv::aruco::CORNER_REFINE_NONE;
while (inputVideo.grab()) {
cv::Mat image, imageCopy;
@@ -215,7 +215,7 @@ Finally, this is a full example of ChArUco detection (without using calibration
image.copyTo(imageCopy);
std::vector<int> ids;
- std::vector<std::vector<cv::Point2f> > corners;
+ std::vector<std::vector<cv::Point2f>> corners;
cv::aruco::detectMarkers(image, dictionary, corners, ids, params);
// if at least one marker detected
@@ -286,8 +286,8 @@ A full example of ChArUco detection with pose estimation:
// camera parameters are read from somewhere
readCameraParameters(cameraMatrix, distCoeffs);
- cv::aruco::Dictionary dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
- cv::aruco::CharucoBoard board = cv::aruco::CharucoBoard::create(5, 7, 0.04, 0.02, dictionary);
+ cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
+ cv::Ptr<cv::aruco::CharucoBoard> board = cv::aruco::CharucoBoard::create(5, 7, 0.04, 0.02, dictionary);
while (inputVideo.grab()) {
cv::Mat image, imageCopy;
@@ -295,7 +295,7 @@ A full example of ChArUco detection with pose estimation:
image.copyTo(imageCopy);
std::vector<int> ids;
- std::vector<std::vector<cv::Point2f> > corners;
+ std::vector<std::vector<cv::Point2f>> corners;
cv::aruco::detectMarkers(image, dictionary, corners, ids);
// if at least one marker detected
diff --git a/contrib/modules/aruco/tutorials/charuco_diamond_detection/charuco_diamond_detection.markdown b/contrib/modules/aruco/tutorials/charuco_diamond_detection/charuco_diamond_detection.markdown
index 9f56cc2..62bbc66 100644
--- a/contrib/modules/aruco/tutorials/charuco_diamond_detection/charuco_diamond_detection.markdown
+++ b/contrib/modules/aruco/tutorials/charuco_diamond_detection/charuco_diamond_detection.markdown
@@ -46,7 +46,7 @@ For instance:
``` c++
cv::Mat diamondImage;
- cv::aruco::Dictionary dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
+ cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
cv::aruco::drawCharucoDiamond(dictionary, cv::Vec4i(45,68,28,74), 200, 120, markerImage);
```
@@ -78,14 +78,14 @@ After detecting markers, diamond are detected using the ```detectCharucoDiamond(
...
- std::vector< int > markerIds;
- std::vector< std::vector< cv::Point2f > > markerCorners;
+ std::vector<int> markerIds;
+ std::vector<std::vector< cv::Point2f>> markerCorners;
// detect ArUco markers
cv::aruco::detectMarkers(inputImage, dictionary, markerCorners, markerIds);
- std::vector< cv::Vec4i > diamondIds;
- std::vector< std::vector< cv::Point2f > > diamondCorners;
+ std::vector<cv::Vec4i> diamondIds;
+ std::vector<std::vector<cv::Point2f>> diamondCorners;
// detect diamon diamonds
cv::aruco::detectCharucoDiamond(inputImage, markerCorners, markerIds, squareLength / markerLength, diamondCorners, diamondIds);
@@ -107,8 +107,8 @@ corners and ids:
``` c++
...
- std::vector< cv::Vec4i > diamondIds;
- std::vector< std::vector< cv::Point2f > > diamondCorners;
+ std::vector<cv::Vec4i> diamondIds;
+ std::vector<std::vector<cv::Point2f>> diamondCorners;
cv::aruco::detectCharucoDiamond(inputImage, markerCorners, markerIds, squareLength / markerLength, diamondCorners, diamondIds);
cv::aruco::drawDetectedDiamonds(inputImage, diamondCorners, diamondIds);
@@ -134,8 +134,8 @@ i.e. using the ```estimatePoseSingleMarkers()``` function. For instance:
``` c++
...
- std::vector< cv::Vec4i > diamondIds;
- std::vector< std::vector< cv::Point2f > > diamondCorners;
+ std::vector<cv::Vec4i> diamondIds;
+ std::vector<std::vector<cv::Point2f>> diamondCorners;
// detect diamon diamonds
cv::aruco::detectCharucoDiamond(inputImage, markerCorners, markerIds, squareLength / markerLength, diamondCorners, diamondIds);
diff --git a/contrib/modules/bgsegm/CMakeLists.txt b/contrib/modules/bgsegm/CMakeLists.txt
index 14152ba..7759fe0 100644
--- a/contrib/modules/bgsegm/CMakeLists.txt
+++ b/contrib/modules/bgsegm/CMakeLists.txt
@@ -1,2 +1,2 @@
set(the_description "Background Segmentation Algorithms")
-ocv_define_module(bgsegm opencv_core opencv_imgproc opencv_video opencv_highgui WRAP python)
+ocv_define_module(bgsegm opencv_core opencv_imgproc opencv_video WRAP python)
diff --git a/contrib/modules/bgsegm/README.md b/contrib/modules/bgsegm/README.md
index 041eeb2..a678929 100644
--- a/contrib/modules/bgsegm/README.md
+++ b/contrib/modules/bgsegm/README.md
@@ -1,5 +1,10 @@
Improved Background-Foreground Segmentation Methods
===================================================
-1. Adaptive Background Mixture Model for Real-time Tracking
-2. Visual Tracking of Human Visitors under Variable-Lighting Conditions.
\ No newline at end of file
+This algorithm combines statistical background image estimation and per-pixel Bayesian segmentation. It[1] was introduced by Andrew B. Godbehere, Akihiro Matsukawa, Ken Goldberg in 2012. As per the paper, the system ran a successful interactive audio art installation called “Are We There Yet?” from March 31 - July 31 2011 at the Contemporary Jewish Museum in San Francisco, California.
+
+It uses first few (120 by default) frames for background modelling. It employs probabilistic foreground segmentation algorithm that identifies possible foreground objects using Bayesian inference. The estimates are adaptive; newer observations are more heavily weighted than old observations to accommodate variable illumination. Several morphological filtering operations like closing and opening are done to remove unwanted noise. You will get a black window during first few frames.
+
+References
+----------
+[1]: A.B. Godbehere, A. Matsukawa, K. Goldberg. Visual tracking of human visitors under variable-lighting conditions for a responsive audio art installation. American Control Conference. (2012), pp. 4305–4312
\ No newline at end of file
diff --git a/contrib/modules/bgsegm/include/opencv2/bgsegm.hpp b/contrib/modules/bgsegm/include/opencv2/bgsegm.hpp
index 5a4ae3f..868cb86 100644
--- a/contrib/modules/bgsegm/include/opencv2/bgsegm.hpp
+++ b/contrib/modules/bgsegm/include/opencv2/bgsegm.hpp
@@ -183,7 +183,64 @@ public:
@param decisionThreshold Threshold value, above which it is marked foreground, else background.
*/
CV_EXPORTS_W Ptr<BackgroundSubtractorGMG> createBackgroundSubtractorGMG(int initializationFrames=120,
- double decisionThreshold=0.8);
+ double decisionThreshold=0.8);
+
+/** @brief Background subtraction based on counting.
+
+ About as fast as MOG2 on a high end system.
+ More than twice faster than MOG2 on cheap hardware (benchmarked on Raspberry Pi3).
+
+ %Algorithm by Sagi Zeevi ( https://github.com/sagi-z/BackgroundSubtractorCNT )
+*/
+class CV_EXPORTS_W BackgroundSubtractorCNT : public BackgroundSubtractor
+{
+public:
+ // BackgroundSubtractor interface
+ CV_WRAP virtual void apply(InputArray image, OutputArray fgmask, double learningRate=-1) = 0;
+ CV_WRAP virtual void getBackgroundImage(OutputArray backgroundImage) const = 0;
+
+ /** @brief Returns number of frames with same pixel color to consider stable.
+ */
+ CV_WRAP virtual int getMinPixelStability() const = 0;
+ /** @brief Sets the number of frames with same pixel color to consider stable.
+ */
+ CV_WRAP virtual void setMinPixelStability(int value) = 0;
+
+ /** @brief Returns maximum allowed credit for a pixel in history.
+ */
+ CV_WRAP virtual int getMaxPixelStability() const = 0;
+ /** @brief Sets the maximum allowed credit for a pixel in history.
+ */
+ CV_WRAP virtual void setMaxPixelStability(int value) = 0;
+
+ /** @brief Returns if we're giving a pixel credit for being stable for a long time.
+ */
+ CV_WRAP virtual bool getUseHistory() const = 0;
+ /** @brief Sets if we're giving a pixel credit for being stable for a long time.
+ */
+ CV_WRAP virtual void setUseHistory(bool value) = 0;
+
+ /** @brief Returns if we're parallelizing the algorithm.
+ */
+ CV_WRAP virtual bool getIsParallel() const = 0;
+ /** @brief Sets if we're parallelizing the algorithm.
+ */
+ CV_WRAP virtual void setIsParallel(bool value) = 0;
+};
+
+/** @brief Creates a CNT Background Subtractor
+
+ at param minPixelStability number of frames with same pixel color to consider stable
+ at param useHistory determines if we're giving a pixel credit for being stable for a long time
+ at param maxPixelStability maximum allowed credit for a pixel in history
+ at param isParallel determines if we're parallelizing the algorithm
+ */
+
+CV_EXPORTS_W Ptr<BackgroundSubtractorCNT>
+createBackgroundSubtractorCNT(int minPixelStability = 15,
+ bool useHistory = true,
+ int maxPixelStability = 15*60,
+ bool isParallel = true);
//! @}
diff --git a/contrib/modules/bgsegm/samples/bgfg.cpp b/contrib/modules/bgsegm/samples/bgfg.cpp
new file mode 100644
index 0000000..f1e846a
--- /dev/null
+++ b/contrib/modules/bgsegm/samples/bgfg.cpp
@@ -0,0 +1,104 @@
+#include "opencv2/bgsegm.hpp"
+#include "opencv2/videoio.hpp"
+#include "opencv2/highgui.hpp"
+#include <opencv2/core/utility.hpp>
+#include <iostream>
+
+using namespace cv;
+using namespace cv::bgsegm;
+
+const String about =
+ "\nA program demonstrating the use and capabilities of different background subtraction algrorithms\n"
+ "Using OpenCV version " + String(CV_VERSION) +
+ "\nPress q or ESC to exit\n";
+
+const String keys =
+ "{help h usage ? | | print this message }"
+ "{vid | | path to a video file }"
+ "{algo | GMG | name of the algorithm (GMG, CNT, KNN, MOG, MOG2) }"
+ ;
+
+static Ptr<BackgroundSubtractor> createBGSubtractorByName(const String& algoName)
+{
+ Ptr<BackgroundSubtractor> algo;
+ if(algoName == String("GMG"))
+ algo = createBackgroundSubtractorGMG(20, 0.7);
+ else if(algoName == String("CNT"))
+ algo = createBackgroundSubtractorCNT();
+ else if(algoName == String("KNN"))
+ algo = createBackgroundSubtractorKNN();
+ else if(algoName == String("MOG"))
+ algo = createBackgroundSubtractorMOG();
+ else if(algoName == String("MOG2"))
+ algo = createBackgroundSubtractorMOG2();
+
+ return algo;
+}
+
+int main(int argc, char** argv)
+{
+ setUseOptimized(true);
+ setNumThreads(8);
+
+ CommandLineParser parser(argc, argv, keys);
+ parser.about(about);
+ parser.printMessage();
+ if (parser.has("help"))
+ {
+ parser.printMessage();
+ return 0;
+ }
+
+ String videoPath = parser.get<String>("vid");
+ String algoName = parser.get<String>("algo");
+
+ if (!parser.check())
+ {
+ parser.printErrors();
+ return 0;
+ }
+
+ Ptr<BackgroundSubtractor> bgfs = createBGSubtractorByName(algoName);
+ if (!bgfs)
+ {
+ std::cerr << "Failed to create " << algoName << " background subtractor" << std::endl;
+ return -1;
+ }
+
+ VideoCapture cap;
+ if (argc > 1)
+ cap.open(videoPath);
+ else
+ cap.open(0);
+
+ if (!cap.isOpened())
+ {
+ std::cerr << "Cannot read video. Try moving video file to sample directory." << std::endl;
+ return -1;
+ }
+
+ Mat frame, fgmask, segm;
+
+ namedWindow("FG Segmentation", WINDOW_NORMAL);
+
+ for (;;)
+ {
+ cap >> frame;
+
+ if (frame.empty())
+ break;
+
+ bgfs->apply(frame, fgmask);
+
+ frame.convertTo(segm, CV_8U, 0.5);
+ add(frame, Scalar(100, 100, 0), segm, fgmask);
+
+ imshow("FG Segmentation", segm);
+
+ int c = waitKey(30);
+ if (c == 'q' || c == 'Q' || (c & 255) == 27)
+ break;
+ }
+
+ return 0;
+}
diff --git a/contrib/modules/bgsegm/samples/bgfg_gmg.cpp b/contrib/modules/bgsegm/samples/bgfg_gmg.cpp
deleted file mode 100644
index 5df71de..0000000
--- a/contrib/modules/bgsegm/samples/bgfg_gmg.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * FGBGTest.cpp
- *
- * Created on: May 7, 2012
- * Author: Andrew B. Godbehere
- */
-
-#include "opencv2/bgsegm.hpp"
-#include "opencv2/videoio.hpp"
-#include "opencv2/highgui.hpp"
-#include <opencv2/core/utility.hpp>
-#include <iostream>
-
-using namespace cv;
-using namespace cv::bgsegm;
-
-static void help()
-{
- std::cout <<
- "\nA program demonstrating the use and capabilities of a particular BackgroundSubtraction\n"
- "algorithm described in A. Godbehere, A. Matsukawa, K. Goldberg, \n"
- "\"Visual Tracking of Human Visitors under Variable-Lighting Conditions for a Responsive\n"
- "Audio Art Installation\", American Control Conference, 2012, used in an interactive\n"
- "installation at the Contemporary Jewish Museum in San Francisco, CA from March 31 through\n"
- "July 31, 2011.\n"
- "Call:\n"
- "./BackgroundSubtractorGMG_sample\n"
- "Using OpenCV version " << CV_VERSION << "\n"<<std::endl;
-}
-
-int main(int argc, char** argv)
-{
- help();
-
- setUseOptimized(true);
- setNumThreads(8);
-
- Ptr<BackgroundSubtractor> fgbg = createBackgroundSubtractorGMG(20, 0.7);
- if (!fgbg)
- {
- std::cerr << "Failed to create BackgroundSubtractor.GMG Algorithm." << std::endl;
- return -1;
- }
-
- VideoCapture cap;
- if (argc > 1)
- cap.open(argv[1]);
- else
- cap.open(0);
-
- if (!cap.isOpened())
- {
- std::cerr << "Cannot read video. Try moving video file to sample directory." << std::endl;
- return -1;
- }
-
- Mat frame, fgmask, segm;
-
- namedWindow("FG Segmentation", WINDOW_NORMAL);
-
- for (;;)
- {
- cap >> frame;
-
- if (frame.empty())
- break;
-
- fgbg->apply(frame, fgmask);
-
- frame.convertTo(segm, CV_8U, 0.5);
- add(frame, Scalar(100, 100, 0), segm, fgmask);
-
- imshow("FG Segmentation", segm);
-
- int c = waitKey(30);
- if (c == 'q' || c == 'Q' || (c & 255) == 27)
- break;
- }
-
- return 0;
-}
diff --git a/contrib/modules/bgsegm/src/bgfg_gmg.cpp b/contrib/modules/bgsegm/src/bgfg_gmg.cpp
index 5f5f60f..2258451 100644
--- a/contrib/modules/bgsegm/src/bgfg_gmg.cpp
+++ b/contrib/modules/bgsegm/src/bgfg_gmg.cpp
@@ -41,7 +41,7 @@
//M*/
/*
- * This class implements an algorithm described in "Visual Tracking of Human Visitors under
+ * This class implements a particular BackgroundSubtraction algorithm described in "Visual Tracking of Human Visitors under
* Variable-Lighting Conditions for a Responsive Audio Art Installation," A. Godbehere,
* A. Matsukawa, K. Goldberg, American Control Conference, Montreal, June 2012.
*
diff --git a/contrib/modules/bgsegm/src/bgfg_subcnt.cpp b/contrib/modules/bgsegm/src/bgfg_subcnt.cpp
new file mode 100644
index 0000000..1e2a1a3
--- /dev/null
+++ b/contrib/modules/bgsegm/src/bgfg_subcnt.cpp
@@ -0,0 +1,421 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// (3-clause BSD License)
+// For BackgroundSubtractorCNT
+// (Background Subtraction based on Counting)
+//
+// Copyright (C) 2016, Sagi Zeevi (www.theimpossiblecode.com), all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+
+#include "precomp.hpp"
+#include <functional>
+
+namespace cv
+{
+namespace bgsegm
+{
+
+class BackgroundSubtractorCNTImpl: public BackgroundSubtractorCNT
+{
+public:
+
+ BackgroundSubtractorCNTImpl(int minStability,
+ bool useHistory,
+ int maxStability,
+ bool isParallel);
+
+ // BackgroundSubtractor interface
+ virtual void apply(InputArray image, OutputArray fgmask, double learningRate);
+ virtual void getBackgroundImage(OutputArray backgroundImage) const;
+
+ int getMinPixelStability() const;
+ void setMinPixelStability(int value);
+
+ int getMaxPixelStability() const;
+ void setMaxPixelStability(int value);
+
+ bool getUseHistory() const;
+ void setUseHistory(bool value);
+
+ bool getIsParallel() const;
+ void setIsParallel(bool value);
+
+ //! the destructor
+ virtual ~BackgroundSubtractorCNTImpl() {}
+
+private:
+ int minPixelStability;
+ int maxPixelStability;
+ int threshold;
+ bool useHistory;
+ bool isParallel;
+ // These 3 commented expressed in 1 'data' for faster single access
+ // Mat_<int> stability; // data[0] => Candidate for historyStability if pixel is ~same as in prevFrame
+ // Mat_<int> history; // data[1] => Color which got most hits for the past maxPixelStability frames
+ // Mat_<int> historyStability; // data[2] => How many hits this pixel got for the color in history
+ // Mat_<int> background; // data[3] => Current background as detected by algorithm
+ Mat_<Vec4i> data;
+ Mat prevFrame;
+ Mat fgMaskPrev;
+};
+
+BackgroundSubtractorCNTImpl::BackgroundSubtractorCNTImpl(int minStability,
+ bool _useHistory,
+ int maxStability,
+ bool _isParallel)
+ : minPixelStability(minStability),
+ maxPixelStability(maxStability),
+ threshold(5),
+ useHistory(_useHistory),
+ isParallel(_isParallel)
+{
+}
+
+void BackgroundSubtractorCNTImpl::getBackgroundImage(OutputArray _backgroundImage) const
+{
+ CV_Assert(! data.empty());
+
+ _backgroundImage.create(prevFrame.size(), CV_8U); // OutputArray usage requires this step
+ Mat backgroundImage = _backgroundImage.getMat();
+
+ // mixChannels requires same types to mix,
+ // so imixing with tmp Mat and conerting
+ Mat_<int> tmp(prevFrame.rows, prevFrame.cols);
+ int from_bg_model_to_user[] = {3, 0};
+ mixChannels(&data, 1, &tmp, 1, from_bg_model_to_user, 1);
+ tmp.convertTo(backgroundImage, CV_8U);
+}
+
+int BackgroundSubtractorCNTImpl::getMinPixelStability() const
+{
+ return minPixelStability;
+}
+
+void BackgroundSubtractorCNTImpl::setMinPixelStability(int value)
+{
+ CV_Assert(value > 0 && value < maxPixelStability);
+ minPixelStability = value;
+}
+
+int BackgroundSubtractorCNTImpl::getMaxPixelStability() const
+{
+ return maxPixelStability;
+}
+
+void BackgroundSubtractorCNTImpl::setMaxPixelStability(int value)
+{
+ CV_Assert(value > minPixelStability);
+ maxPixelStability = value;
+}
+
+bool BackgroundSubtractorCNTImpl::getUseHistory() const
+{
+ return useHistory;
+}
+
+void BackgroundSubtractorCNTImpl::setUseHistory(bool value)
+{
+ useHistory = value;
+}
+
+bool BackgroundSubtractorCNTImpl::getIsParallel() const
+{
+ return isParallel;
+}
+
+void BackgroundSubtractorCNTImpl::setIsParallel(bool value)
+{
+ isParallel = value;
+}
+
+class CNTFunctor
+{
+public:
+ virtual void operator()(Vec4i &vec, uchar currColor, uchar prevColor, uchar &fgMaskPixelRef) = 0;
+ //! the destructor
+ virtual ~CNTFunctor() {}
+};
+
+struct BGSubtractPixel : public CNTFunctor
+{
+ BGSubtractPixel(int _minPixelStability, int _threshold,
+ const Mat &_frame, const Mat &_prevFrame, Mat &_fgMask)
+ : minPixelStability(_minPixelStability),
+ threshold(_threshold),
+ frame(_frame),
+ prevFrame(_prevFrame),
+ fgMask(_fgMask)
+ {}
+
+ //! the destructor
+ virtual ~BGSubtractPixel() {}
+
+ void operator()(Vec4i &vec, uchar currColor, uchar prevColor, uchar &fgMaskPixelRef)
+ {
+ int &stabilityRef = vec[0];
+ int &bgImgRef = vec[3];
+ if (abs(currColor - prevColor) < threshold)
+ {
+ ++stabilityRef;
+ if (stabilityRef == minPixelStability)
+ { // bg
+ --stabilityRef;
+ bgImgRef = prevColor;
+ }
+ else
+ { // fg
+ fgMaskPixelRef = 255;
+ }
+ }
+ else
+ { // fg
+ stabilityRef = 0;
+ fgMaskPixelRef = 255;
+ }
+ }
+
+ int minPixelStability;
+ int threshold;
+ const Mat &frame;
+ const Mat &prevFrame;
+ Mat &fgMask;
+};
+
+struct BGSubtractPixelWithHistory : public CNTFunctor
+{
+ BGSubtractPixelWithHistory(int _minPixelStability, int _maxPixelStability, int _threshold,
+ const Mat &_frame, const Mat &_prevFrame, Mat &_fgMask)
+ : minPixelStability(_minPixelStability),
+ maxPixelStability(_maxPixelStability),
+ threshold(_threshold),
+ thresholdHistory(30),
+ frame(_frame),
+ prevFrame(_prevFrame),
+ fgMask(_fgMask)
+ {}
+
+ //! the destructor
+ virtual ~BGSubtractPixelWithHistory() {}
+
+ void incrStability(int &histStabilityRef)
+ {
+ if (histStabilityRef < maxPixelStability)
+ {
+ ++histStabilityRef;
+ }
+ }
+
+ void decrStability(int &histStabilityRef)
+ {
+ if (histStabilityRef > 0)
+ {
+ --histStabilityRef;
+ }
+ }
+
+ void operator()(Vec4i &vec, uchar currColor, uchar prevColor, uchar &fgMaskPixelRef)
+ {
+ int &stabilityRef = vec[0];
+ int &historyColorRef = vec[1];
+ int &histStabilityRef = vec[2];
+ int &bgImgRef = vec[3];
+ if (abs(currColor - historyColorRef) < thresholdHistory)
+ { // No change compared to history - this is maybe a background
+ stabilityRef = 0;
+ incrStability(histStabilityRef);
+ if (histStabilityRef <= minPixelStability)
+ {
+ fgMaskPixelRef = 255;
+ }
+ else
+ {
+ bgImgRef = historyColorRef;
+ }
+ }
+ else if (abs(currColor - prevColor) < threshold)
+ { // No change compared to prev - this is maybe a background
+ incrStability(stabilityRef);
+ if (stabilityRef > minPixelStability)
+ { // Stable color - this is maybe a background
+ if (stabilityRef >= histStabilityRef)
+ {
+ historyColorRef = currColor;
+ histStabilityRef = stabilityRef;
+ bgImgRef = historyColorRef;
+ }
+ else
+ { // Stable but different from stable history - this is a foreground
+ decrStability(histStabilityRef);
+ fgMaskPixelRef = 255;
+ }
+ }
+ else
+ { // This is FG.
+ fgMaskPixelRef = 255;
+ }
+ }
+ else
+ { // Color changed - this is defently a foreground
+ stabilityRef = 0;
+ decrStability(histStabilityRef);
+ fgMaskPixelRef = 255;
+ }
+
+ }
+
+ int minPixelStability;
+ int maxPixelStability;
+ int threshold;
+ int thresholdHistory;
+ const Mat &frame;
+ const Mat &prevFrame;
+ Mat &fgMask;
+};
+
+class CNTInvoker : public ParallelLoopBody
+{
+public:
+ CNTInvoker(Mat_<Vec4i> &_data, Mat &_img, Mat &_prevFrame, Mat &_fgMask, CNTFunctor &_functor)
+ : data(_data), img(_img), prevFrame(_prevFrame), fgMask(_fgMask), functor(_functor)
+ {
+ }
+
+ // Iterate rows
+ void operator()(const Range& range) const
+ {
+ for (int r = range.start; r < range.end; ++r)
+ {
+ Vec4i* row = data.ptr<Vec4i>(r);
+ uchar* frameRow = img.ptr<uchar>(r);
+ uchar* prevFrameRow = prevFrame.ptr<uchar>(r);
+ uchar* fgMaskRow = fgMask.ptr<uchar>(r);
+ for (int c = 0; c < data.cols; ++c)
+ {
+ functor(row[c], frameRow[c], prevFrameRow[c], fgMaskRow[c]);
+ }
+ }
+ }
+
+private:
+ Mat_<Vec4i> &data;
+ Mat &img;
+ Mat &prevFrame;
+ Mat &fgMask;
+ CNTFunctor &functor;
+};
+
+void BackgroundSubtractorCNTImpl::apply(InputArray image, OutputArray _fgmask, double learningRate)
+{
+ CV_Assert(image.depth() == CV_8U);
+
+ Mat frameIn = image.getMat();
+ if(frameIn.channels() != 1)
+ cvtColor(frameIn, frameIn, COLOR_BGR2GRAY);
+
+ _fgmask.create(image.size(), CV_8U); // OutputArray usage requires this step
+ Mat fgMask = _fgmask.getMat();
+
+ bool needToInitialize = data.empty() || learningRate >= 1 || frameIn.size() != prevFrame.size();
+
+ Mat frame = frameIn.clone();
+
+ if (needToInitialize)
+ { // Usually done only once
+ data = Mat_<Vec4i>::zeros(frame.rows, frame.cols);
+ prevFrame = frame;
+
+ // mixChannels requires same types to mix,
+ // so imixing with tmp Mat and conerting
+ Mat tmp;
+ prevFrame.convertTo(tmp, CV_32S);
+ int from_gray_to_history_color[] = {0,1};
+ mixChannels(&tmp, 1, &data, 1, from_gray_to_history_color, 1);
+ }
+
+ fgMask = Scalar(0);
+ CNTFunctor *functor;
+ if (useHistory && learningRate)
+ {
+ double scaleMaxStability = 1.0;
+ if (learningRate > 0 && learningRate < 1.0)
+ {
+ scaleMaxStability = learningRate;
+ }
+ functor = new BGSubtractPixelWithHistory(minPixelStability, int(maxPixelStability * scaleMaxStability),
+ threshold, frame, prevFrame, fgMask);
+ }
+ else
+ {
+ functor = new BGSubtractPixel(minPixelStability, threshold*3, frame, prevFrame, fgMask);
+ }
+
+ if (isParallel)
+ {
+ parallel_for_(Range(0, frame.rows),
+ CNTInvoker(data, frame, prevFrame, fgMask, *functor));
+ }
+ else
+ {
+ for (int r = 0; r < data.rows; ++r)
+ {
+ Vec4i* row = data.ptr<Vec4i>(r);
+ uchar* frameRow = frame.ptr<uchar>(r);
+ uchar* prevFrameRow = prevFrame.ptr<uchar>(r);
+ uchar* fgMaskRow = fgMask.ptr<uchar>(r);
+ for (int c = 0; c < data.cols; ++c)
+ {
+ (*functor)(row[c], frameRow[c], prevFrameRow[c], fgMaskRow[c]);
+ }
+ }
+ }
+
+ delete functor;
+
+ prevFrame = frame;
+}
+
+
+Ptr<BackgroundSubtractorCNT> createBackgroundSubtractorCNT(int minPixelStability, bool useHistory, int maxStability, bool isParallel)
+{
+ return makePtr<BackgroundSubtractorCNTImpl>(minPixelStability, useHistory, maxStability, isParallel);
+}
+
+}
+}
+
+/* End of file. */
diff --git a/contrib/modules/bioinspired/include/opencv2/bioinspired/retina.hpp b/contrib/modules/bioinspired/include/opencv2/bioinspired/retina.hpp
index e531614..583599c 100644
--- a/contrib/modules/bioinspired/include/opencv2/bioinspired/retina.hpp
+++ b/contrib/modules/bioinspired/include/opencv2/bioinspired/retina.hpp
@@ -447,11 +447,6 @@ the log scale that is applied
*/
CV_EXPORTS_W Ptr<Retina> createRetina(Size inputSize, const bool colorMode, int colorSamplingMethod=RETINA_COLOR_BAYER, const bool useRetinaLogSampling=false, const float reductionFactor=1.0f, const float samplingStrenght=10.0f);
-#ifdef HAVE_OPENCV_OCL
-Ptr<Retina> createRetina_OCL(Size inputSize);
-Ptr<Retina> createRetina_OCL(Size inputSize, const bool colorMode, int colorSamplingMethod=RETINA_COLOR_BAYER, const bool useRetinaLogSampling=false, const float reductionFactor=1.0f, const float samplingStrenght=10.0f);
-#endif
-
//! @}
//! @}
diff --git a/contrib/modules/bioinspired/perf/opencl/perf_retina.cpp b/contrib/modules/bioinspired/perf/opencl/perf_retina.cpp
deleted file mode 100644
index 05c0cfa..0000000
--- a/contrib/modules/bioinspired/perf/opencl/perf_retina.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
-// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// @Authors
-// Fangfang Bai, fangfang at multicorewareinc.com
-// Jin Ma, jin at multicorewareinc.com
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors as is and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "perf_precomp.hpp"
-
-#include "opencv2/imgproc.hpp"
-#include "opencv2/highgui.hpp"
-#include "opencv2/core/ocl.hpp"
-
-#ifdef HAVE_OPENCV_OCL
-
-#include "opencv2/ocl.hpp"
-
-using namespace std::tr1;
-using namespace cv;
-using namespace perf;
-
-namespace cvtest {
-namespace ocl {
-
-///////////////////////// Retina ////////////////////////
-
-typedef tuple<bool, int, double, double> RetinaParams;
-typedef TestBaseWithParam<RetinaParams> RetinaFixture;
-
-#define OCL_TEST_CYCLE() for(; startTimer(), next(); cv::ocl::finish(), stopTimer())
-
-PERF_TEST_P(RetinaFixture, Retina,
- ::testing::Combine(testing::Bool(), testing::Values((int)cv::bioinspired::RETINA_COLOR_BAYER),
- testing::Values(1.0, 0.5), testing::Values(10.0, 5.0)))
-{
- if (!cv::ocl::haveOpenCL())
- throw TestBase::PerfSkipTestException();
-
- RetinaParams params = GetParam();
- bool colorMode = get<0>(params), useLogSampling = false;
- int colorSamplingMethod = get<1>(params);
- double reductionFactor = get<2>(params), samplingStrength = get<3>(params);
-
- Mat input = cv::imread(cvtest::TS::ptr()->get_data_path() + "shared/lena.png", colorMode);
- ASSERT_FALSE(input.empty());
-
- Mat gold_parvo, gold_magno;
-
- if (getSelectedImpl() == "plain")
- {
- Ptr<bioinspired::Retina> gold_retina = bioinspired::createRetina(
- input.size(), colorMode, colorSamplingMethod,
- useLogSampling, reductionFactor, samplingStrength);
-
- TEST_CYCLE()
- {
- gold_retina->run(input);
-
- gold_retina->getParvo(gold_parvo);
- gold_retina->getMagno(gold_magno);
- }
- }
- else if (getSelectedImpl() == "ocl")
- {
- cv::ocl::oclMat ocl_input(input), ocl_parvo, ocl_magno;
-
- Ptr<cv::bioinspired::Retina> ocl_retina = cv::bioinspired::createRetina_OCL(
- input.size(), colorMode, colorSamplingMethod, useLogSampling,
- reductionFactor, samplingStrength);
-
- OCL_TEST_CYCLE()
- {
- ocl_retina->run(ocl_input);
-
- ocl_retina->getParvo(ocl_parvo);
- ocl_retina->getMagno(ocl_magno);
- }
- }
- else
- CV_TEST_FAIL_NO_IMPL();
-
- SANITY_CHECK_NOTHING();
-}
-
-} } // namespace cvtest::ocl
-
-#endif // HAVE_OPENCV_OCL
diff --git a/contrib/modules/bioinspired/perf/opencl/perf_retina.ocl.cpp b/contrib/modules/bioinspired/perf/opencl/perf_retina.ocl.cpp
new file mode 100644
index 0000000..2fe2cc5
--- /dev/null
+++ b/contrib/modules/bioinspired/perf/opencl/perf_retina.ocl.cpp
@@ -0,0 +1,47 @@
+#include "../perf_precomp.hpp"
+#include "opencv2/ts/ocl_perf.hpp"
+
+using namespace std::tr1;
+using namespace cv;
+using namespace perf;
+
+namespace cvtest {
+namespace ocl {
+
+///////////////////////// Retina ////////////////////////
+
+typedef tuple<bool, int, double, double> RetinaParams;
+typedef TestBaseWithParam<RetinaParams> RetinaFixture;
+
+OCL_PERF_TEST_P(RetinaFixture, Retina,
+ ::testing::Combine(testing::Bool(), testing::Values((int)cv::bioinspired::RETINA_COLOR_BAYER),
+ testing::Values(1.0, 0.5), testing::Values(10.0, 5.0)))
+{
+ RetinaParams params = GetParam();
+ bool colorMode = get<0>(params), useLogSampling = false;
+ int colorSamplingMethod = get<1>(params);
+ float reductionFactor = static_cast<float>(get<2>(params));
+ float samplingStrength = static_cast<float>(get<3>(params));
+
+ Mat input = imread(getDataPath("cv/shared/lena.png"), colorMode);
+ ASSERT_FALSE(input.empty());
+
+ UMat ocl_parvo, ocl_magno;
+
+ {
+ Ptr<cv::bioinspired::Retina> retina = cv::bioinspired::createRetina(
+ input.size(), colorMode, colorSamplingMethod, useLogSampling,
+ reductionFactor, samplingStrength);
+
+ OCL_TEST_CYCLE()
+ {
+ retina->run(input);
+ retina->getParvo(ocl_parvo);
+ retina->getMagno(ocl_magno);
+ }
+ }
+
+ SANITY_CHECK_NOTHING();
+}
+
+} } // namespace cvtest::ocl
diff --git a/contrib/modules/bioinspired/perf/perf_main.cpp b/contrib/modules/bioinspired/perf/perf_main.cpp
index 10ffdb2..8a9ed8e 100644
--- a/contrib/modules/bioinspired/perf/perf_main.cpp
+++ b/contrib/modules/bioinspired/perf/perf_main.cpp
@@ -42,12 +42,4 @@
#include "perf_precomp.hpp"
-static const char * impls[] =
-{
-#ifdef HAVE_OPENCV_OCL
- "ocl",
-#endif
- "plain"
-};
-
-CV_PERF_TEST_MAIN_WITH_IMPLS(ocl, impls, ::perf::TestBase::setModulePerformanceStrategy(::perf::PERF_STRATEGY_SIMPLE))
+CV_PERF_TEST_MAIN(bioinspired)
diff --git a/contrib/modules/bioinspired/src/opencl/retina_kernel.cl b/contrib/modules/bioinspired/src/opencl/retina_kernel.cl
index 02b7a83..226e1e3 100644
--- a/contrib/modules/bioinspired/src/opencl/retina_kernel.cl
+++ b/contrib/modules/bioinspired/src/opencl/retina_kernel.cl
@@ -75,72 +75,35 @@ kernel void horizontalCausalFilter_addInput(
output + mad24(gid, elements_per_row, out_offset / 4);
float res;
- float4 in_v4, out_v4, res_v4 = (float4)(0);
+ float4 in_v4, out_v4, sum_v4, res_v4 = (float4)(0);
//vectorize to increase throughput
for(int i = 0; i < cols / 4; ++i, iptr += 4, optr += 4)
{
in_v4 = vload4(0, iptr);
- out_v4 = vload4(0, optr);
+ out_v4 = vload4(0, optr) * _tau;
+ sum_v4 = in_v4 + out_v4;
- res_v4.x = in_v4.x + _tau * out_v4.x + _a * res_v4.w;
- res_v4.y = in_v4.y + _tau * out_v4.y + _a * res_v4.x;
- res_v4.z = in_v4.z + _tau * out_v4.z + _a * res_v4.y;
- res_v4.w = in_v4.w + _tau * out_v4.w + _a * res_v4.z;
+ res_v4.x = sum_v4.x + _a * res_v4.w;
+ res_v4.y = sum_v4.y + _a * res_v4.x;
+ res_v4.z = sum_v4.z + _a * res_v4.y;
+ res_v4.w = sum_v4.w + _a * res_v4.z;
vstore4(res_v4, 0, optr);
}
- res = res_v4.w;
- // there may be left some
- for(int i = 0; i < cols % 4; ++i, ++iptr, ++optr)
- {
- res = *iptr + _tau * *optr + _a * res;
- *optr = res;
- }
-}
-
-//_horizontalAnticausalFilter
-kernel void horizontalAnticausalFilter(
- global float * output,
- const int cols,
- const int rows,
- const int elements_per_row,
- const int out_offset,
- const float _a
-)
-{
- int gid = get_global_id(0);
- if(gid >= rows)
- {
- return;
- }
- global float * optr = output +
- mad24(gid + 1, elements_per_row, - 1 + out_offset / 4);
-
- float4 result_v4 = (float4)(0), out_v4;
- float result = 0;
- // we assume elements_per_row is multple of WIDTH_MULTIPLE
- for(int i = 0; i < WIDTH_MULTIPLE; ++ i, -- optr)
- {
- if(i >= elements_per_row - cols)
- {
- result = *optr + _a * result;
- }
- *optr = result;
- }
- result_v4.x = result;
- optr -= 3;
- for(int i = WIDTH_MULTIPLE / 4; i < elements_per_row / 4; ++i, optr -= 4)
+ optr = output + mad24(gid + 1, elements_per_row, -4 + out_offset / 4);
+ res_v4 = (float4)(0);
+ for(int i = 0; i < elements_per_row / 4; ++i, optr -= 4)
{
// shift left, `offset` is type `size_t` so it cannot be negative
out_v4 = vload4(0, optr);
- result_v4.w = out_v4.w + _a * result_v4.x;
- result_v4.z = out_v4.z + _a * result_v4.w;
- result_v4.y = out_v4.y + _a * result_v4.z;
- result_v4.x = out_v4.x + _a * result_v4.y;
+ res_v4.w = out_v4.w + _a * res_v4.x;
+ res_v4.z = out_v4.z + _a * res_v4.w;
+ res_v4.y = out_v4.y + _a * res_v4.z;
+ res_v4.x = out_v4.x + _a * res_v4.y;
- vstore4(result_v4, 0, optr);
+ vstore4(res_v4, 0, optr);
}
}
@@ -151,26 +114,37 @@ kernel void verticalCausalFilter(
const int rows,
const int elements_per_row,
const int out_offset,
- const float _a
+ const float _a,
+ const float _gain
)
{
- int gid = get_global_id(0);
+ int gid = get_global_id(0) * 2;
if(gid >= cols)
{
return;
}
global float * optr = output + gid + out_offset / 4;
- float result = 0;
+ float2 input;
+ float2 result = (float2)0;
for(int i = 0; i < rows; ++i, optr += elements_per_row)
{
- result = *optr + _a * result;
- *optr = result;
+ input = vload2(0, optr);
+ result = input + _a * result;
+ vstore2(result, 0, optr);
+ }
+
+ optr = output + (rows - 1) * elements_per_row + gid + out_offset / 4;
+ result = (float2)0;
+ for(int i = 0; i < rows; ++i, optr -= elements_per_row)
+ {
+ input = vload2(0, optr);
+ result = input + _a * result;
+ vstore2(_gain * result, 0, optr);
}
}
-//_verticalCausalFilter
-kernel void verticalAnticausalFilter_multGain(
+kernel void verticalCausalFilter_multichannel(
global float * output,
const int cols,
const int rows,
@@ -180,74 +154,69 @@ kernel void verticalAnticausalFilter_multGain(
const float _gain
)
{
- int gid = get_global_id(0);
+ int gid = get_global_id(0) * 2;
if(gid >= cols)
{
return;
}
- global float * optr = output + (rows - 1) * elements_per_row + gid + out_offset / 4;
- float result = 0;
- for(int i = 0; i < rows; ++i, optr -= elements_per_row)
- {
- result = *optr + _a * result;
- *optr = _gain * result;
- }
-}
-//
-// end of _spatiotemporalLPfilter
-/////////////////////////////////////////////////////////////////////
+ global float * optr[3];
+ float2 input[3];
+ float2 result[3] = { (float2)0, (float2)0, (float2)0 };
-//////////////// horizontalAnticausalFilter_Irregular ////////////////
-kernel void horizontalAnticausalFilter_Irregular(
- global float * output,
- global float * buffer,
- const int cols,
- const int rows,
- const int elements_per_row,
- const int out_offset,
- const int buffer_offset
-)
-{
- int gid = get_global_id(0);
- if(gid >= rows)
- {
- return;
- }
+ optr[0] = output + gid + out_offset / 4;
+ optr[1] = output + gid + out_offset / 4 + rows * elements_per_row;
+ optr[2] = output + gid + out_offset / 4 + 2 * rows * elements_per_row;
- global float * optr =
- output + mad24(rows - gid, elements_per_row, -1 + out_offset / 4);
- global float * bptr =
- buffer + mad24(rows - gid, elements_per_row, -1 + buffer_offset / 4);
-
- float4 buf_v4, out_v4, res_v4 = (float4)(0);
- float result = 0;
- // we assume elements_per_row is multple of WIDTH_MULTIPLE
- for(int i = 0; i < WIDTH_MULTIPLE; ++ i, -- optr, -- bptr)
+ for(int i = 0; i < rows; ++i)
{
- if(i >= elements_per_row - cols)
- {
- result = *optr + *bptr * result;
- }
- *optr = result;
+ input[0] = vload2(0, optr[0]);
+ input[1] = vload2(0, optr[1]);
+ input[2] = vload2(0, optr[2]);
+
+ result[0] = input[0] + _a * result[0];
+ result[1] = input[1] + _a * result[1];
+ result[2] = input[2] + _a * result[2];
+
+ vstore2(result[0], 0, optr[0]);
+ vstore2(result[1], 0, optr[1]);
+ vstore2(result[2], 0, optr[2]);
+
+ optr[0] += elements_per_row;
+ optr[1] += elements_per_row;
+ optr[2] += elements_per_row;
}
- res_v4.x = result;
- optr -= 3;
- bptr -= 3;
- for(int i = WIDTH_MULTIPLE / 4; i < elements_per_row / 4; ++i, optr -= 4, bptr -= 4)
+
+ optr[0] = output + (rows - 1) * elements_per_row + gid + out_offset / 4;
+ optr[1] = output + (rows - 1) * elements_per_row + gid + out_offset / 4 + rows * elements_per_row;
+ optr[2] = output + (rows - 1) * elements_per_row + gid + out_offset / 4 + 2 * rows * elements_per_row;
+ result[0] = result[1] = result[2] = (float2)0;
+
+ for(int i = 0; i < rows; ++i)
{
- buf_v4 = vload4(0, bptr);
- out_v4 = vload4(0, optr);
+ input[0] = vload2(0, optr[0]);
+ input[1] = vload2(0, optr[1]);
+ input[2] = vload2(0, optr[2]);
- res_v4.w = out_v4.w + buf_v4.w * res_v4.x;
- res_v4.z = out_v4.z + buf_v4.z * res_v4.w;
- res_v4.y = out_v4.y + buf_v4.y * res_v4.z;
- res_v4.x = out_v4.x + buf_v4.x * res_v4.y;
+ result[0] = input[0] + _a * result[0];
+ result[1] = input[1] + _a * result[1];
+ result[2] = input[2] + _a * result[2];
- vstore4(res_v4, 0, optr);
+ vstore2(_gain * result[0], 0, optr[0]);
+ vstore2(_gain * result[1], 0, optr[1]);
+ vstore2(_gain * result[2], 0, optr[2]);
+
+ optr[0] -= elements_per_row;
+ optr[1] -= elements_per_row;
+ optr[2] -= elements_per_row;
}
}
+//
+// end of _spatiotemporalLPfilter
+/////////////////////////////////////////////////////////////////////
+
+//////////////// verticalCausalFilter_Irregular ////////////////
//////////////// verticalCausalFilter_Irregular ////////////////
kernel void verticalCausalFilter_Irregular(
global float * output,
@@ -256,22 +225,61 @@ kernel void verticalCausalFilter_Irregular(
const int rows,
const int elements_per_row,
const int out_offset,
- const int buffer_offset
+ const int buffer_offset,
+ const float gain
)
{
- int gid = get_global_id(0);
+ int gid = get_global_id(0) * 2;
if(gid >= cols)
{
return;
}
- global float * optr = output + gid + out_offset / 4;
+ global float * optr[3];
global float * bptr = buffer + gid + buffer_offset / 4;
- float result = 0;
- for(int i = 0; i < rows; ++i, optr += elements_per_row, bptr += elements_per_row)
- {
- result = *optr + *bptr * result;
- *optr = result;
+ float2 result[3] = { (float2)0, (float2)0, (float2)0 };
+ float2 grad, input[3];
+ optr[0] = output + gid + out_offset / 4;
+ optr[1] = output + gid + out_offset / 4 + rows * elements_per_row;
+ optr[2] = output + gid + out_offset / 4 + 2 * rows * elements_per_row;
+ for(int i = 0; i < rows; ++i, bptr += elements_per_row)
+ {
+ input[0] = vload2(0, optr[0]);
+ input[1] = vload2(0, optr[1]);
+ input[2] = vload2(0, optr[2]);
+ grad = vload2(0, bptr);
+ result[0] = input[0] + grad * result[0];
+ result[1] = input[1] + grad * result[1];
+ result[2] = input[2] + grad * result[2];
+ vstore2(result[0], 0, optr[0]);
+ vstore2(result[1], 0, optr[1]);
+ vstore2(result[2], 0, optr[2]);
+ optr[0] += elements_per_row;
+ optr[1] += elements_per_row;
+ optr[2] += elements_per_row;
+ }
+
+ int start_idx = mad24(rows - 1, elements_per_row, gid);
+ optr[0] = output + start_idx + out_offset / 4;
+ optr[1] = output + start_idx + out_offset / 4 + rows * elements_per_row;
+ optr[2] = output + start_idx + out_offset / 4 + 2 * rows * elements_per_row;
+ bptr = buffer + start_idx + buffer_offset / 4;
+ result[0] = result[1] = result[2] = (float2)0;
+ for(int i = 0; i < rows; ++i, bptr -= elements_per_row)
+ {
+ input[0] = vload2(0, optr[0]);
+ input[1] = vload2(0, optr[1]);
+ input[2] = vload2(0, optr[2]);
+ grad = vload2(0, bptr);
+ result[0] = input[0] + grad * result[0];
+ result[1] = input[1] + grad * result[1];
+ result[2] = input[2] + grad * result[2];
+ vstore2(gain * result[0], 0, optr[0]);
+ vstore2(gain * result[1], 0, optr[1]);
+ vstore2(gain * result[2], 0, optr[2]);
+ optr[0] -= elements_per_row;
+ optr[1] -= elements_per_row;
+ optr[2] -= elements_per_row;
}
}
@@ -314,41 +322,22 @@ kernel void adaptiveHorizontalCausalFilter_addInput(
vstore4(res_v4, 0, optr);
}
- for(int i = 0; i < cols % 4; ++i, ++iptr, ++gptr, ++optr)
- {
- res_v4.w = *iptr + *gptr * res_v4.w;
- *optr = res_v4.w;
- }
-}
-//////////////// _adaptiveVerticalAnticausalFilter_multGain ////////////////
-kernel void adaptiveVerticalAnticausalFilter_multGain(
- global const float * gradient,
- global float * output,
- const int cols,
- const int rows,
- const int elements_per_row,
- const int grad_offset,
- const int out_offset,
- const float gain
-)
-{
- int gid = get_global_id(0);
- if(gid >= cols)
- {
- return;
- }
+ optr = output + mad24(gid + 1, elements_per_row, -4 + out_offset / 4);
+ gptr = gradient + mad24(gid + 1, elements_per_row, -4 + grad_offset / 4);
+ res_v4 = (float4)(0);
- int start_idx = mad24(rows - 1, elements_per_row, gid);
+ for(int i = 0; i < cols / 4; ++i, gptr -= 4, optr -= 4)
+ {
+ grad_v4 = vload4(0, gptr);
+ out_v4 = vload4(0, optr);
- global const float * gptr = gradient + start_idx + grad_offset / 4;
- global float * optr = output + start_idx + out_offset / 4;
+ res_v4.w = out_v4.w + grad_v4.w * res_v4.x;
+ res_v4.z = out_v4.z + grad_v4.z * res_v4.w;
+ res_v4.y = out_v4.y + grad_v4.y * res_v4.z;
+ res_v4.x = out_v4.x + grad_v4.x * res_v4.y;
- float result = 0;
- for(int i = 0; i < rows; ++i, gptr -= elements_per_row, optr -= elements_per_row)
- {
- result = *optr + *gptr * result;
- *optr = gain * result;
+ vstore4(res_v4, 0, optr);
}
}
@@ -367,17 +356,18 @@ kernel void localLuminanceAdaptation(
const float _maxInputValue
)
{
- int gidx = get_global_id(0), gidy = get_global_id(1);
+ int gidx = get_global_id(0) * 4, gidy = get_global_id(1);
if(gidx >= cols || gidy >= rows)
{
return;
}
int offset = mad24(gidy, elements_per_row, gidx);
-
- float X0 = luma[offset] * _localLuminanceFactor + _localLuminanceAddon;
- float input_val = input[offset];
+ float4 luma_vec = vload4(0, luma + offset);
+ float4 X0 = luma_vec * _localLuminanceFactor + _localLuminanceAddon;
+ float4 input_val = vload4(0, input + offset);
// output of the following line may be different between GPU and CPU
- output[offset] = (_maxInputValue + X0) * input_val / (input_val + X0 + 0.00000000001f);
+ float4 out_vec = (_maxInputValue + X0) * input_val / (input_val + X0 + 0.00000000001f);
+ vstore4(out_vec, 0, output + offset);
}
// end of basicretinafilter
//------------------------------------------------------
@@ -403,7 +393,7 @@ kernel void amacrineCellsComputing(
const float coeff
)
{
- int gidx = get_global_id(0), gidy = get_global_id(1);
+ int gidx = get_global_id(0) * 4, gidy = get_global_id(1);
if(gidx >= cols || gidy >= rows)
{
return;
@@ -417,13 +407,16 @@ kernel void amacrineCellsComputing(
out_on += offset;
out_off += offset;
- float magnoXonPixelResult = coeff * (*out_on + *opl_on - *prev_in_on);
- *out_on = fmax(magnoXonPixelResult, 0);
- float magnoXoffPixelResult = coeff * (*out_off + *opl_off - *prev_in_off);
- *out_off = fmax(magnoXoffPixelResult, 0);
+ float4 val_opl_on = vload4(0, opl_on);
+ float4 val_opl_off = vload4(0, opl_off);
- *prev_in_on = *opl_on;
- *prev_in_off = *opl_off;
+ float4 magnoXonPixelResult = coeff * (vload4(0, out_on) + val_opl_on - vload4(0, prev_in_on));
+ vstore4(fmax(magnoXonPixelResult, 0), 0, out_on);
+ float4 magnoXoffPixelResult = coeff * (vload4(0, out_off) + val_opl_off - vload4(0, prev_in_off));
+ vstore4(fmax(magnoXoffPixelResult, 0), 0, out_off);
+
+ vstore4(val_opl_on, 0, prev_in_on);
+ vstore4(val_opl_off, 0, prev_in_off);
}
/////////////////////////////////////////////////////////
@@ -457,11 +450,7 @@ kernel void OPL_OnOffWaysComputing(
parvo_off += offset;
float4 diff = *photo_out - *horiz_out;
- float4 isPositive;// = convert_float4(diff > (float4)(0.0f, 0.0f, 0.0f, 0.0f));
- isPositive.x = diff.x > 0.0f;
- isPositive.y = diff.y > 0.0f;
- isPositive.z = diff.z > 0.0f;
- isPositive.w = diff.w > 0.0f;
+ float4 isPositive = convert_float4(abs(diff > (float4)0.0f));
float4 res_on = isPositive * diff;
float4 res_off = (isPositive - (float4)(1.0f)) * diff;
@@ -491,14 +480,19 @@ kernel void runColorMultiplexingBayer(
const int elements_per_row
)
{
- int gidx = get_global_id(0), gidy = get_global_id(1);
+ int gidx = get_global_id(0) * 4, gidy = get_global_id(1);
if(gidx >= cols || gidy >= rows)
{
return;
}
int offset = mad24(gidy, elements_per_row, gidx);
- output[offset] = input[bayerSampleOffset(elements_per_row, rows, gidx, gidy)];
+ float4 val;
+ val.x = input[bayerSampleOffset(elements_per_row, rows, gidx + 0, gidy)];
+ val.y = input[bayerSampleOffset(elements_per_row, rows, gidx + 1, gidy)];
+ val.z = input[bayerSampleOffset(elements_per_row, rows, gidx + 2, gidy)];
+ val.w = input[bayerSampleOffset(elements_per_row, rows, gidx + 3, gidy)];
+ vstore4(val, 0, output + offset);
}
kernel void runColorDemultiplexingBayer(
@@ -509,14 +503,18 @@ kernel void runColorDemultiplexingBayer(
const int elements_per_row
)
{
- int gidx = get_global_id(0), gidy = get_global_id(1);
+ int gidx = get_global_id(0) * 4, gidy = get_global_id(1);
if(gidx >= cols || gidy >= rows)
{
return;
}
int offset = mad24(gidy, elements_per_row, gidx);
- output[bayerSampleOffset(elements_per_row, rows, gidx, gidy)] = input[offset];
+ float4 val = vload4(0, input + offset);
+ output[bayerSampleOffset(elements_per_row, rows, gidx + 0, gidy)] = val.x;
+ output[bayerSampleOffset(elements_per_row, rows, gidx + 1, gidy)] = val.y;
+ output[bayerSampleOffset(elements_per_row, rows, gidx + 2, gidy)] = val.z;
+ output[bayerSampleOffset(elements_per_row, rows, gidx + 3, gidy)] = val.w;
}
kernel void demultiplexAssign(
@@ -550,16 +548,16 @@ kernel void normalizeGrayOutputCentredSigmoide(
)
{
- int gidx = get_global_id(0), gidy = get_global_id(1);
+ int gidx = get_global_id(0) * 4, gidy = get_global_id(1);
if(gidx >= cols || gidy >= rows)
{
return;
}
int offset = mad24(gidy, elements_per_row, gidx);
- float input_val = input[offset];
- output[offset] = meanval +
- (meanval + X0) * (input_val - meanval) / (fabs(input_val - meanval) + X0);
+ float4 input_val = vload4(0, input + offset);
+ input_val = meanval + (meanval + X0) * (input_val - meanval) / (fabs(input_val - meanval) + X0);
+ vstore4(input_val, 0, output + offset);
}
//// normalize by photoreceptors density
@@ -575,7 +573,7 @@ kernel void normalizePhotoDensity(
const float pG
)
{
- const int gidx = get_global_id(0), gidy = get_global_id(1);
+ const int gidx = get_global_id(0) * 4, gidy = get_global_id(1);
if(gidx >= cols || gidy >= rows)
{
return;
@@ -583,16 +581,19 @@ kernel void normalizePhotoDensity(
const int offset = mad24(gidy, elements_per_row, gidx);
int index = offset;
- float Cr = chroma[index] * colorDensity[index];
+ float4 Cr = vload4(0, chroma + index) * vload4(0, colorDensity + index);
index += elements_per_row * rows;
- float Cg = chroma[index] * colorDensity[index];
+ float4 Cg = vload4(0, chroma + index) * vload4(0, colorDensity + index);
index += elements_per_row * rows;
- float Cb = chroma[index] * colorDensity[index];
-
- const float luma_res = (Cr + Cg + Cb) * pG;
- luma[offset] = luma_res;
- demultiplex[bayerSampleOffset(elements_per_row, rows, gidx, gidy)] =
- multiplex[offset] - luma_res;
+ float4 Cb = vload4(0, chroma + index) * vload4(0, colorDensity + index);
+
+ const float4 luma_res = (Cr + Cg + Cb) * pG;
+ vstore4(luma_res, 0, luma + offset);
+ float4 res_v4 = vload4(0, multiplex + offset) - luma_res;
+ demultiplex[bayerSampleOffset(elements_per_row, rows, gidx + 0, gidy)] = res_v4.x;
+ demultiplex[bayerSampleOffset(elements_per_row, rows, gidx + 1, gidy)] = res_v4.y;
+ demultiplex[bayerSampleOffset(elements_per_row, rows, gidx + 2, gidy)] = res_v4.z;
+ demultiplex[bayerSampleOffset(elements_per_row, rows, gidx + 3, gidy)] = res_v4.w;
}
@@ -629,7 +630,8 @@ kernel void computeGradient(
const float horiz_grad = 0.5f * h_grad + 0.25f * (h_grad_p + h_grad_n);
const float verti_grad = 0.5f * v_grad + 0.25f * (v_grad_p + v_grad_n);
- const bool is_vertical_greater = horiz_grad < verti_grad;
+ const bool is_vertical_greater = (horiz_grad < verti_grad) &&
+ ((verti_grad - horiz_grad) > 1e-5);
gradient[offset + elements_per_row * rows] = is_vertical_greater ? 0.06f : 0.57f;
gradient[offset ] = is_vertical_greater ? 0.57f : 0.06f;
@@ -647,7 +649,7 @@ kernel void substractResidual(
const float pB
)
{
- const int gidx = get_global_id(0), gidy = get_global_id(1);
+ const int gidx = get_global_id(0) * 4, gidy = get_global_id(1);
if(gidx >= cols || gidy >= rows)
{
return;
@@ -658,12 +660,15 @@ kernel void substractResidual(
mad24(gidy + rows, elements_per_row, gidx),
mad24(gidy + 2 * rows, elements_per_row, gidx)
};
- float vals[3] = {input[indices[0]], input[indices[1]], input[indices[2]]};
- float residu = pR * vals[0] + pG * vals[1] + pB * vals[2];
-
- input[indices[0]] = vals[0] - residu;
- input[indices[1]] = vals[1] - residu;
- input[indices[2]] = vals[2] - residu;
+ float4 vals[3];
+ vals[0] = vload4(0, input + indices[0]);
+ vals[1] = vload4(0, input + indices[1]);
+ vals[2] = vload4(0, input + indices[2]);
+
+ float4 residu = pR * vals[0] + pG * vals[1] + pB * vals[2];
+ vstore4(vals[0] - residu, 0, input + indices[0]);
+ vstore4(vals[1] - residu, 0, input + indices[1]);
+ vstore4(vals[2] - residu, 0, input + indices[2]);
}
///// clipRGBOutput_0_maxInputValue /////
@@ -675,15 +680,15 @@ kernel void clipRGBOutput_0_maxInputValue(
const float maxVal
)
{
- const int gidx = get_global_id(0), gidy = get_global_id(1);
+ const int gidx = get_global_id(0) * 4, gidy = get_global_id(1);
if(gidx >= cols || gidy >= rows)
{
return;
}
const int offset = mad24(gidy, elements_per_row, gidx);
- float val = input[offset];
+ float4 val = vload4(0, input + offset);
val = clamp(val, 0.0f, maxVal);
- input[offset] = val;
+ vstore4(val, 0, input + offset);
}
//// normalizeGrayOutputNearZeroCentreredSigmoide ////
@@ -697,15 +702,16 @@ kernel void normalizeGrayOutputNearZeroCentreredSigmoide(
const float X0cube
)
{
- const int gidx = get_global_id(0), gidy = get_global_id(1);
+ const int gidx = get_global_id(0) * 4, gidy = get_global_id(1);
if(gidx >= cols || gidy >= rows)
{
return;
}
const int offset = mad24(gidy, elements_per_row, gidx);
- float currentCubeLuminance = input[offset];
+ float4 currentCubeLuminance = vload4(0, input + offset);
currentCubeLuminance = currentCubeLuminance * currentCubeLuminance * currentCubeLuminance;
- output[offset] = currentCubeLuminance * X0cube / (X0cube + currentCubeLuminance);
+ float4 val = currentCubeLuminance * X0cube / (X0cube + currentCubeLuminance);
+ vstore4(val, 0, output + offset);
}
//// centerReductImageLuminance ////
@@ -718,15 +724,16 @@ kernel void centerReductImageLuminance(
const float std_dev
)
{
- const int gidx = get_global_id(0), gidy = get_global_id(1);
+ const int gidx = get_global_id(0) * 4, gidy = get_global_id(1);
if(gidx >= cols || gidy >= rows)
{
return;
}
const int offset = mad24(gidy, elements_per_row, gidx);
- float val = input[offset];
- input[offset] = (val - mean) / std_dev;
+ float4 val = vload4(0, input + offset);
+ val = (val - mean) / std_dev;
+ vstore4(val, 0, input + offset);
}
//// inverseValue ////
@@ -737,13 +744,15 @@ kernel void inverseValue(
const int elements_per_row
)
{
- const int gidx = get_global_id(0), gidy = get_global_id(1);
+ const int gidx = get_global_id(0) * 4, gidy = get_global_id(1);
if(gidx >= cols || gidy >= rows)
{
return;
}
const int offset = mad24(gidy, elements_per_row, gidx);
- input[offset] = 1.f / input[offset];
+ float4 val = vload4(0, input + offset);
+ val = 1.f / val;
+ vstore4(val, 0, input + offset);
}
#define CV_PI 3.1415926535897932384626433832795
diff --git a/contrib/modules/bioinspired/src/precomp.hpp b/contrib/modules/bioinspired/src/precomp.hpp
index 61aeb54..d2e19bd 100644
--- a/contrib/modules/bioinspired/src/precomp.hpp
+++ b/contrib/modules/bioinspired/src/precomp.hpp
@@ -48,13 +48,10 @@
#include "opencv2/core/utility.hpp"
#include "opencv2/core/private.hpp"
#include "opencv2/core/ocl.hpp"
+#include "opencv2/core/opencl/ocl_defs.hpp"
#include <valarray>
-#ifdef HAVE_OPENCV_OCL
- #include "opencv2/ocl/private/util.hpp"
-#endif
-
namespace cv
{
diff --git a/contrib/modules/bioinspired/src/retina.cpp b/contrib/modules/bioinspired/src/retina.cpp
index 1e518f8..deb3906 100644
--- a/contrib/modules/bioinspired/src/retina.cpp
+++ b/contrib/modules/bioinspired/src/retina.cpp
@@ -70,6 +70,7 @@
*/
#include "precomp.hpp"
#include "retinafilter.hpp"
+#include "retina_ocl.hpp"
#include <cstdio>
#include <sstream>
#include <valarray>
@@ -292,11 +293,25 @@ private:
bool _convertCvMat2ValarrayBuffer(InputArray inputMatToConvert, std::valarray<float> &outputValarrayMatrix);
+#ifdef HAVE_OPENCL
+ ocl::RetinaOCLImpl* _ocl_retina;
+
+ bool ocl_run(InputArray inputImage);
+ bool ocl_getParvo(OutputArray retinaOutput_parvo);
+ bool ocl_getMagno(OutputArray retinaOutput_magno);
+ bool ocl_getParvoRAW(OutputArray retinaOutput_parvo);
+ bool ocl_getMagnoRAW(OutputArray retinaOutput_magno);
+#endif
};
// smart pointers allocation :
-Ptr<Retina> createRetina(Size inputSize){ return makePtr<RetinaImpl>(inputSize); }
-Ptr<Retina> createRetina(Size inputSize, const bool colorMode, int colorSamplingMethod, const bool useRetinaLogSampling, const float reductionFactor, const float samplingStrenght){
+Ptr<Retina> createRetina(Size inputSize)
+{
+ return makePtr<RetinaImpl>(inputSize);
+}
+
+Ptr<Retina> createRetina(Size inputSize, const bool colorMode, int colorSamplingMethod, const bool useRetinaLogSampling, const float reductionFactor, const float samplingStrenght)
+{
return makePtr<RetinaImpl>(inputSize, colorMode, colorSamplingMethod, useRetinaLogSampling, reductionFactor, samplingStrenght);
}
@@ -306,18 +321,34 @@ RetinaImpl::RetinaImpl(const cv::Size inputSz)
{
_retinaFilter = 0;
_init(inputSz, true, RETINA_COLOR_BAYER, false);
+#ifdef HAVE_OPENCL
+ _ocl_retina = 0;
+ if (inputSz.width % 4 == 0)
+ _ocl_retina = new ocl::RetinaOCLImpl(inputSz);
+#endif
}
RetinaImpl::RetinaImpl(const cv::Size inputSz, const bool colorMode, int colorSamplingMethod, const bool useRetinaLogSampling, const float reductionFactor, const float samplingStrenght)
{
_retinaFilter = 0;
_init(inputSz, colorMode, colorSamplingMethod, useRetinaLogSampling, reductionFactor, samplingStrenght);
+#ifdef HAVE_OPENCL
+ _ocl_retina = 0;
+ if (inputSz.width % 4 == 0)
+ _ocl_retina = new ocl::RetinaOCLImpl(inputSz, colorMode, colorSamplingMethod,
+ useRetinaLogSampling, reductionFactor, samplingStrenght);
+#endif
}
RetinaImpl::~RetinaImpl()
{
if (_retinaFilter)
delete _retinaFilter;
+
+#ifdef HAVE_OPENCL
+ if (_ocl_retina)
+ delete _ocl_retina;
+#endif
}
/**
@@ -529,8 +560,18 @@ void RetinaImpl::setupIPLMagnoChannel(const bool normaliseOutput, const float pa
_retinaParameters.IplMagno.localAdaptintegration_k = localAdaptintegration_k;
}
+#ifdef HAVE_OPENCL
+bool RetinaImpl::ocl_run(InputArray inputMatToConvert)
+{
+ _ocl_retina->run(inputMatToConvert);
+ return true;
+}
+#endif
+
void RetinaImpl::run(InputArray inputMatToConvert)
{
+ CV_OCL_RUN((_ocl_retina != 0), ocl_run(inputMatToConvert));
+
// first convert input image to the compatible format : std::valarray<float>
const bool colorMode = _convertCvMat2ValarrayBuffer(inputMatToConvert.getMat(), _inputBuffer);
// process the retina
@@ -559,8 +600,18 @@ void RetinaImpl::applyFastToneMapping(InputArray inputImage, OutputArray outputT
}
+#ifdef HAVE_OPENCL
+bool RetinaImpl::ocl_getParvo(OutputArray retinaOutput_parvo)
+{
+ _ocl_retina->getParvo(retinaOutput_parvo);
+ return true;
+}
+#endif
+
void RetinaImpl::getParvo(OutputArray retinaOutput_parvo)
{
+ CV_OCL_RUN((_ocl_retina != 0) && retinaOutput_parvo.isUMat(), ocl_getParvo(retinaOutput_parvo));
+
if (_retinaFilter->getColorMode())
{
// reallocate output buffer (if necessary)
@@ -572,24 +623,57 @@ void RetinaImpl::getParvo(OutputArray retinaOutput_parvo)
}
//retinaOutput_parvo/=255.0;
}
+
+#ifdef HAVE_OPENCL
+bool RetinaImpl::ocl_getMagno(OutputArray retinaOutput_magno)
+{
+ _ocl_retina->getMagno(retinaOutput_magno);
+ return true;
+}
+#endif
+
void RetinaImpl::getMagno(OutputArray retinaOutput_magno)
{
+ CV_OCL_RUN((_ocl_retina != 0) && retinaOutput_magno.isUMat(), ocl_getMagno(retinaOutput_magno));
+
// reallocate output buffer (if necessary)
_convertValarrayBuffer2cvMat(_retinaFilter->getMovingContours(), _retinaFilter->getOutputNBrows(), _retinaFilter->getOutputNBcolumns(), false, retinaOutput_magno);
//retinaOutput_magno/=255.0;
}
+#ifdef HAVE_OPENCL
+bool RetinaImpl::ocl_getMagnoRAW(OutputArray magnoOutputBufferCopy)
+{
+ _ocl_retina->getMagnoRAW(magnoOutputBufferCopy);
+ return true;
+}
+#endif
+
// original API level data accessors : copy buffers if size matches, reallocate if required
void RetinaImpl::getMagnoRAW(OutputArray magnoOutputBufferCopy){
+
+ CV_OCL_RUN((_ocl_retina != 0) && magnoOutputBufferCopy.isUMat(), ocl_getMagnoRAW(magnoOutputBufferCopy));
+
// get magno channel header
const cv::Mat magnoChannel=cv::Mat(getMagnoRAW());
// copy data
magnoChannel.copyTo(magnoOutputBufferCopy);
}
+#ifdef HAVE_OPENCL
+bool RetinaImpl::ocl_getParvoRAW(OutputArray parvoOutputBufferCopy)
+{
+ _ocl_retina->getParvoRAW(parvoOutputBufferCopy);
+ return true;
+}
+#endif
+
void RetinaImpl::getParvoRAW(OutputArray parvoOutputBufferCopy){
+
+ CV_OCL_RUN((_ocl_retina != 0) && parvoOutputBufferCopy.isUMat(), ocl_getParvoRAW(parvoOutputBufferCopy));
+
// get parvo channel header
- const cv::Mat parvoChannel=cv::Mat(getMagnoRAW());
+ const cv::Mat parvoChannel=cv::Mat(getParvoRAW());
// copy data
parvoChannel.copyTo(parvoOutputBufferCopy);
}
@@ -649,7 +733,7 @@ void RetinaImpl::_convertValarrayBuffer2cvMat(const std::valarray<float> &grayMa
for (unsigned int j=0;j<nbColumns;++j)
{
cv::Point2d pixel(j,i);
- outMat.at<unsigned char>(pixel)=(unsigned char)*(valarrayPTR++);
+ outMat.at<unsigned char>(pixel)=(unsigned char)cvRound(*(valarrayPTR++));
}
}
}
@@ -665,9 +749,9 @@ void RetinaImpl::_convertValarrayBuffer2cvMat(const std::valarray<float> &grayMa
{
cv::Point2d pixel(j,i);
cv::Vec3b pixelValues;
- pixelValues[2]=(unsigned char)*(valarrayPTR);
- pixelValues[1]=(unsigned char)*(valarrayPTR+nbPixels);
- pixelValues[0]=(unsigned char)*(valarrayPTR+doubleNBpixels);
+ pixelValues[2]=(unsigned char)cvRound(*(valarrayPTR));
+ pixelValues[1]=(unsigned char)cvRound(*(valarrayPTR+nbPixels));
+ pixelValues[0]=(unsigned char)cvRound(*(valarrayPTR+doubleNBpixels));
outMat.at<cv::Vec3b>(pixel)=pixelValues;
}
@@ -729,7 +813,15 @@ bool RetinaImpl::_convertCvMat2ValarrayBuffer(InputArray inputMat, std::valarray
return imageNumberOfChannels>1; // return bool : false for gray level image processing, true for color mode
}
-void RetinaImpl::clearBuffers() { _retinaFilter->clearAllBuffers(); }
+void RetinaImpl::clearBuffers()
+{
+#ifdef HAVE_OPENCL
+ if (_ocl_retina != 0)
+ _ocl_retina->clearBuffers();
+#endif
+
+ _retinaFilter->clearAllBuffers();
+}
void RetinaImpl::activateMovingContoursProcessing(const bool activate) { _retinaFilter->activateMovingContoursProcessing(activate); }
diff --git a/contrib/modules/bioinspired/src/retina_ocl.cpp b/contrib/modules/bioinspired/src/retina_ocl.cpp
index 364a6ea..41a26c7 100644
--- a/contrib/modules/bioinspired/src/retina_ocl.cpp
+++ b/contrib/modules/bioinspired/src/retina_ocl.cpp
@@ -48,70 +48,34 @@
#include <iostream>
#include <sstream>
-#ifdef HAVE_OPENCV_OCL
+#ifdef HAVE_OPENCL
-#include "opencl_kernels.hpp"
+#include "opencl_kernels_bioinspired.hpp"
#define NOT_IMPLEMENTED CV_Error(cv::Error::StsNotImplemented, "Not implemented")
-namespace cv
+namespace
{
-static ocl::ProgramEntry retina_kernel = ocl::bioinspired::retina_kernel;
+ template <typename T, size_t N>
+ inline int sizeOfArray(const T(&)[N])
+ {
+ return (int)N;
+ }
+ inline void ensureSizeIsEnough(int rows, int cols, int type, cv::UMat &m)
+ {
+ m.create(rows, cols, type, m.usageFlags);
+ }
+}
+
+namespace cv
+{
namespace bioinspired
{
namespace ocl
{
using namespace cv::ocl;
-class RetinaOCLImpl : public Retina
-{
-public:
- RetinaOCLImpl(Size getInputSize);
- RetinaOCLImpl(Size getInputSize, const bool colorMode, int colorSamplingMethod = RETINA_COLOR_BAYER, const bool useRetinaLogSampling = false, const double reductionFactor = 1.0, const double samplingStrenght = 10.0);
- virtual ~RetinaOCLImpl();
-
- Size getInputSize();
- Size getOutputSize();
-
- void setup(String retinaParameterFile = "", const bool applyDefaultSetupOnFailure = true);
- void setup(cv::FileStorage &fs, const bool applyDefaultSetupOnFailure = true);
- void setup(RetinaParameters newParameters);
-
- RetinaOCLImpl::RetinaParameters getParameters();
-
- const String printSetup();
- virtual void write( String fs ) const;
- virtual void write( FileStorage& fs ) const;
-
- void setupOPLandIPLParvoChannel(const bool colorMode = true, const bool normaliseOutput = true, const float photoreceptorsLocalAdaptationSensitivity = 0.7, const float photoreceptorsTemporalConstant = 0.5, const float photoreceptorsSpatialConstant = 0.53, const float horizontalCellsGain = 0, const float HcellsTemporalConstant = 1, const float HcellsSpatialConstant = 7, const float ganglionCellsSensitivity = 0.7);
- void setupIPLMagnoChannel(const bool normaliseOutput = true, const float parasolCells_beta = 0, const float parasolCells_tau = 0, const float parasolCells_k = 7, const float amacrinCellsTemporalCutFrequency = 1.2, const float V0CompressionParameter = 0.95, const float localAdaptintegration_tau = 0, const float localAdaptintegration_k = 7);
-
- void run(InputArray inputImage);
- void getParvo(OutputArray retinaOutput_parvo);
- void getMagno(OutputArray retinaOutput_magno);
-
- void setColorSaturation(const bool saturateColors = true, const float colorSaturationValue = 4.0);
- void clearBuffers();
- void activateMovingContoursProcessing(const bool activate);
- void activateContoursProcessing(const bool activate);
-
- // unimplemented interfaces:
- void applyFastToneMapping(InputArray /*inputImage*/, OutputArray /*outputToneMappedImage*/) { NOT_IMPLEMENTED; }
- void getParvoRAW(OutputArray /*retinaOutput_parvo*/) { NOT_IMPLEMENTED; }
- void getMagnoRAW(OutputArray /*retinaOutput_magno*/) { NOT_IMPLEMENTED; }
- const Mat getMagnoRAW() const { NOT_IMPLEMENTED; return Mat(); }
- const Mat getParvoRAW() const { NOT_IMPLEMENTED; return Mat(); }
-
-protected:
- RetinaParameters _retinaParameters;
- cv::ocl::oclMat _inputBuffer;
- RetinaFilter* _retinaFilter;
- bool convertToColorPlanes(const cv::ocl::oclMat& input, cv::ocl::oclMat &output);
- void convertToInterleaved(const cv::ocl::oclMat& input, bool colorMode, cv::ocl::oclMat &output);
- void _init(const Size getInputSize, const bool colorMode, int colorSamplingMethod = RETINA_COLOR_BAYER, const bool useRetinaLogSampling = false, const double reductionFactor = 1.0, const double samplingStrenght = 10.0);
-};
-
RetinaOCLImpl::RetinaOCLImpl(const cv::Size inputSz)
{
_retinaFilter = 0;
@@ -133,7 +97,7 @@ RetinaOCLImpl::~RetinaOCLImpl()
}
/**
-* retreive retina input buffer size
+* retrieve retina input buffer size
*/
Size RetinaOCLImpl::getInputSize()
{
@@ -141,7 +105,7 @@ Size RetinaOCLImpl::getInputSize()
}
/**
-* retreive retina output buffer size
+* retrieve retina output buffer size
*/
Size RetinaOCLImpl::getOutputSize()
{
@@ -154,7 +118,7 @@ void RetinaOCLImpl::setColorSaturation(const bool saturateColors, const float co
_retinaFilter->setColorSaturation(saturateColors, colorSaturationValue);
}
-struct RetinaOCLImpl::RetinaParameters RetinaOCLImpl::getParameters()
+struct RetinaParameters RetinaOCLImpl::getParameters()
{
return _retinaParameters;
}
@@ -170,7 +134,7 @@ void RetinaOCLImpl::setup(String retinaParameterFile, const bool applyDefaultSet
}
catch(Exception &e)
{
- std::cout << "RetinaOCLImpl::setup: wrong/unappropriate xml parameter file : error report :`n=>" << e.what() << std::endl;
+ std::cout << "RetinaOCLImpl::setup: wrong/inappropriate xml parameter file : error report :`n=>" << e.what() << std::endl;
if (applyDefaultSetupOnFailure)
{
std::cout << "RetinaOCLImpl::setup: resetting retina with default parameters" << std::endl;
@@ -191,7 +155,7 @@ void RetinaOCLImpl::setup(cv::FileStorage &fs, const bool applyDefaultSetupOnFai
// read parameters file if it exists or apply default setup if asked for
if (!fs.isOpened())
{
- std::cout << "RetinaOCLImpl::setup: provided parameters file could not be open... skeeping configuration" << std::endl;
+ std::cout << "RetinaOCLImpl::setup: provided parameters file could not be open... skipping configuration" << std::endl;
return;
// implicit else case : retinaParameterFile could be open (it exists at least)
}
@@ -230,15 +194,15 @@ void RetinaOCLImpl::setup(cv::FileStorage &fs, const bool applyDefaultSetupOnFai
setupOPLandIPLParvoChannel();
setupIPLMagnoChannel();
}
- std::cout << "RetinaOCLImpl::setup: wrong/unappropriate xml parameter file : error report :`n=>" << e.what() << std::endl;
+ std::cout << "RetinaOCLImpl::setup: wrong/inappropriate xml parameter file : error report :`n=>" << e.what() << std::endl;
std::cout << "=> keeping current parameters" << std::endl;
}
}
-void RetinaOCLImpl::setup(cv::bioinspired::Retina::RetinaParameters newConfiguration)
+void RetinaOCLImpl::setup(cv::bioinspired::RetinaParameters newConfiguration)
{
// simply copy structures
- memcpy(&_retinaParameters, &newConfiguration, sizeof(cv::bioinspired::Retina::RetinaParameters));
+ memcpy(&_retinaParameters, &newConfiguration, sizeof(cv::bioinspired::RetinaParameters));
// apply setup
setupOPLandIPLParvoChannel(_retinaParameters.OPLandIplParvo.colorMode, _retinaParameters.OPLandIplParvo.normaliseOutput, _retinaParameters.OPLandIplParvo.photoreceptorsLocalAdaptationSensitivity, _retinaParameters.OPLandIplParvo.photoreceptorsTemporalConstant, _retinaParameters.OPLandIplParvo.photoreceptorsSpatialConstant, _retinaParameters.OPLandIplParvo.horizontalCellsGain, _retinaParameters.OPLandIplParvo.hcellsTemporalConstant, _retinaParameters.OPLandIplParvo.hcellsSpatialConsta [...]
setupIPLMagnoChannel(_retinaParameters.IplMagno.normaliseOutput, _retinaParameters.IplMagno.parasolCells_beta, _retinaParameters.IplMagno.parasolCells_tau, _retinaParameters.IplMagno.parasolCells_k, _retinaParameters.IplMagno.amacrinCellsTemporalCutFrequency, _retinaParameters.IplMagno.V0CompressionParameter, _retinaParameters.IplMagno.localAdaptintegration_tau, _retinaParameters.IplMagno.localAdaptintegration_k);
@@ -321,7 +285,7 @@ void RetinaOCLImpl::setupOPLandIPLParvoChannel(const bool colorMode, const bool
_retinaFilter->setParvoGanglionCellsLocalAdaptationSensitivity(ganglionCellsSensitivity);
_retinaFilter->activateNormalizeParvoOutput_0_maxOutputValue(normaliseOutput);
- // update parameters struture
+ // update parameters structure
_retinaParameters.OPLandIplParvo.colorMode = colorMode;
_retinaParameters.OPLandIplParvo.normaliseOutput = normaliseOutput;
@@ -340,7 +304,7 @@ void RetinaOCLImpl::setupIPLMagnoChannel(const bool normaliseOutput, const float
_retinaFilter->setMagnoCoefficientsTable(parasolCells_beta, parasolCells_tau, parasolCells_k, amacrinCellsTemporalCutFrequency, V0CompressionParameter, localAdaptintegration_tau, localAdaptintegration_k);
_retinaFilter->activateNormalizeMagnoOutput_0_maxOutputValue(normaliseOutput);
- // update parameters struture
+ // update parameters structure
_retinaParameters.IplMagno.normaliseOutput = normaliseOutput;
_retinaParameters.IplMagno.parasolCells_beta = parasolCells_beta;
_retinaParameters.IplMagno.parasolCells_tau = parasolCells_tau;
@@ -353,7 +317,7 @@ void RetinaOCLImpl::setupIPLMagnoChannel(const bool normaliseOutput, const float
void RetinaOCLImpl::run(InputArray input)
{
- oclMat &inputMatToConvert = getOclMatRef(input);
+ UMat inputMatToConvert = input.getUMat();
bool colorMode = convertToColorPlanes(inputMatToConvert, _inputBuffer);
// first convert input image to the compatible format : std::valarray<float>
// process the retina
@@ -365,7 +329,7 @@ void RetinaOCLImpl::run(InputArray input)
void RetinaOCLImpl::getParvo(OutputArray output)
{
- oclMat &retinaOutput_parvo = getOclMatRef(output);
+ UMat &retinaOutput_parvo = output.getUMatRef();
if (_retinaFilter->getColorMode())
{
// reallocate output buffer (if necessary)
@@ -380,12 +344,12 @@ void RetinaOCLImpl::getParvo(OutputArray output)
}
void RetinaOCLImpl::getMagno(OutputArray output)
{
- oclMat &retinaOutput_magno = getOclMatRef(output);
+ UMat &retinaOutput_magno = output.getUMatRef();
// reallocate output buffer (if necessary)
convertToInterleaved(_retinaFilter->getMovingContours(), false, retinaOutput_magno);
//retinaOutput_magno/=255.0;
}
-// private method called by constructirs
+// private method called by constructors
void RetinaOCLImpl::_init(const cv::Size inputSz, const bool colorMode, int colorSamplingMethod, const bool useRetinaLogSampling, const double reductionFactor, const double samplingStrenght)
{
// basic error check
@@ -408,22 +372,22 @@ void RetinaOCLImpl::_init(const cv::Size inputSz, const bool colorMode, int colo
_retinaFilter->clearAllBuffers();
}
-bool RetinaOCLImpl::convertToColorPlanes(const oclMat& input, oclMat &output)
+bool RetinaOCLImpl::convertToColorPlanes(const UMat& input, UMat &output)
{
- oclMat convert_input;
+ UMat convert_input;
input.convertTo(convert_input, CV_32F);
if(convert_input.channels() == 3 || convert_input.channels() == 4)
{
- ocl::ensureSizeIsEnough(int(_retinaFilter->getInputNBrows() * 4),
- int(_retinaFilter->getInputNBcolumns()), CV_32FC1, output);
- oclMat channel_splits[4] =
- {
- output(Rect(Point(0, _retinaFilter->getInputNBrows() * 2), getInputSize())),
- output(Rect(Point(0, _retinaFilter->getInputNBrows()), getInputSize())),
- output(Rect(Point(0, 0), getInputSize())),
- output(Rect(Point(0, _retinaFilter->getInputNBrows() * 3), getInputSize()))
- };
- ocl::split(convert_input, channel_splits);
+ ensureSizeIsEnough(int(_retinaFilter->getInputNBrows() * 4),
+ int(_retinaFilter->getInputNBcolumns()), CV_32FC1, output);
+ std::vector<UMat> channel_splits;
+ channel_splits.reserve(4);
+ channel_splits.push_back(output(Rect(Point(0, _retinaFilter->getInputNBrows() * 2), getInputSize())));
+ channel_splits.push_back(output(Rect(Point(0, _retinaFilter->getInputNBrows()), getInputSize())));
+ channel_splits.push_back(output(Rect(Point(0, 0), getInputSize())));
+ channel_splits.push_back(output(Rect(Point(0, _retinaFilter->getInputNBrows() * 3), getInputSize())));
+
+ cv::split(convert_input, channel_splits);
return true;
}
else if(convert_input.channels() == 1)
@@ -437,13 +401,13 @@ bool RetinaOCLImpl::convertToColorPlanes(const oclMat& input, oclMat &output)
return false;
}
}
-void RetinaOCLImpl::convertToInterleaved(const oclMat& input, bool colorMode, oclMat &output)
+void RetinaOCLImpl::convertToInterleaved(const UMat& input, bool colorMode, UMat &output)
{
input.convertTo(output, CV_8U);
if(colorMode)
{
int numOfSplits = input.rows / getInputSize().height;
- std::vector<oclMat> channel_splits(numOfSplits);
+ std::vector<UMat> channel_splits(numOfSplits);
for(int i = 0; i < static_cast<int>(channel_splits.size()); i ++)
{
channel_splits[i] =
@@ -472,6 +436,29 @@ void RetinaOCLImpl::activateContoursProcessing(const bool activate)
_retinaFilter->activateContoursProcessing(activate);
}
+void RetinaOCLImpl::getParvoRAW(OutputArray retinaOutput_parvo)
+{
+ UMat raw_parvo;
+
+ if (_retinaFilter->getColorMode())
+ raw_parvo = _retinaFilter->getColorOutput();
+ else
+ raw_parvo = _retinaFilter->getContours();
+
+ raw_parvo.copyTo(retinaOutput_parvo);
+}
+
+void RetinaOCLImpl::getMagnoRAW(OutputArray retinaOutput_magno)
+{
+ UMat raw_magno = _retinaFilter->getMovingContours();
+ raw_magno.copyTo(retinaOutput_magno);
+}
+
+// unimplemented interfaces:
+void RetinaOCLImpl::applyFastToneMapping(InputArray /*inputImage*/, OutputArray /*outputToneMappedImage*/) { NOT_IMPLEMENTED; }
+const Mat RetinaOCLImpl::getMagnoRAW() const { NOT_IMPLEMENTED; return Mat(); }
+const Mat RetinaOCLImpl::getParvoRAW() const { NOT_IMPLEMENTED; return Mat(); }
+
///////////////////////////////////////
///////// BasicRetinaFilter ///////////
///////////////////////////////////////
@@ -534,72 +521,73 @@ void BasicRetinaFilter::setLPfilterParameters(const float beta, const float tau,
_filteringCoeficientsTable[1 + tableOffset] = (1.0f - a) * (1.0f - a) * (1.0f - a) * (1.0f - a) / (1.0f + _beta);
_filteringCoeficientsTable[2 + tableOffset] = tau;
}
-const oclMat &BasicRetinaFilter::runFilter_LocalAdapdation(const oclMat &inputFrame, const oclMat &localLuminance)
+const UMat &BasicRetinaFilter::runFilter_LocalAdapdation(const UMat &inputFrame, const UMat &localLuminance)
{
_localLuminanceAdaptation(inputFrame, localLuminance, _filterOutput);
return _filterOutput;
}
-void BasicRetinaFilter::runFilter_LocalAdapdation(const oclMat &inputFrame, const oclMat &localLuminance, oclMat &outputFrame)
+void BasicRetinaFilter::runFilter_LocalAdapdation(const UMat &inputFrame, const UMat &localLuminance, UMat &outputFrame)
{
_localLuminanceAdaptation(inputFrame, localLuminance, outputFrame);
}
-const oclMat &BasicRetinaFilter::runFilter_LocalAdapdation_autonomous(const oclMat &inputFrame)
+const UMat &BasicRetinaFilter::runFilter_LocalAdapdation_autonomous(const UMat &inputFrame)
{
_spatiotemporalLPfilter(inputFrame, _filterOutput);
_localLuminanceAdaptation(inputFrame, _filterOutput, _filterOutput);
return _filterOutput;
}
-void BasicRetinaFilter::runFilter_LocalAdapdation_autonomous(const oclMat &inputFrame, oclMat &outputFrame)
+void BasicRetinaFilter::runFilter_LocalAdapdation_autonomous(const UMat &inputFrame, UMat &outputFrame)
{
_spatiotemporalLPfilter(inputFrame, _filterOutput);
_localLuminanceAdaptation(inputFrame, _filterOutput, outputFrame);
}
-void BasicRetinaFilter::_localLuminanceAdaptation(oclMat &inputOutputFrame, const oclMat &localLuminance)
+void BasicRetinaFilter::_localLuminanceAdaptation(UMat &inputOutputFrame, const UMat &localLuminance)
{
_localLuminanceAdaptation(inputOutputFrame, localLuminance, inputOutputFrame, false);
}
-void BasicRetinaFilter::_localLuminanceAdaptation(const oclMat &inputFrame, const oclMat &localLuminance, oclMat &outputFrame, const bool updateLuminanceMean)
+void BasicRetinaFilter::_localLuminanceAdaptation(const UMat &inputFrame, const UMat &localLuminance, UMat &outputFrame, const bool updateLuminanceMean)
{
if (updateLuminanceMean)
{
- float meanLuminance = saturate_cast<float>(ocl::sum(inputFrame)[0]) / getNBpixels();
+ float meanLuminance = saturate_cast<float>(cv::sum(inputFrame)[0]) / getNBpixels();
updateCompressionParameter(meanLuminance);
}
int elements_per_row = static_cast<int>(inputFrame.step / inputFrame.elemSize());
- Context * ctx = Context::getContext();
- std::vector<std::pair<size_t, const void *> > args;
- size_t globalSize[] = {_NBcols, _NBrows, 1};
- size_t localSize[] = {16, 16, 1};
+ size_t globalSize[] = {(size_t)_NBcols / 4, (size_t)_NBrows};
+ size_t localSize[] = {16, 16};
- args.push_back(std::make_pair(sizeof(cl_mem), &localLuminance.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &inputFrame.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &outputFrame.data));
- args.push_back(std::make_pair(sizeof(cl_int), &_NBcols));
- args.push_back(std::make_pair(sizeof(cl_int), &_NBrows));
- args.push_back(std::make_pair(sizeof(cl_int), &elements_per_row));
- args.push_back(std::make_pair(sizeof(cl_float), &_localLuminanceAddon));
- args.push_back(std::make_pair(sizeof(cl_float), &_localLuminanceFactor));
- args.push_back(std::make_pair(sizeof(cl_float), &_maxInputValue));
- openCLExecuteKernel(ctx, &retina_kernel, "localLuminanceAdaptation", globalSize, localSize, args, -1, -1);
+ Kernel kernel("localLuminanceAdaptation", ocl::bioinspired::retina_kernel_oclsrc);
+ kernel.args(ocl::KernelArg::PtrReadOnly(localLuminance),
+ ocl::KernelArg::PtrReadOnly(inputFrame),
+ ocl::KernelArg::PtrWriteOnly(outputFrame),
+ (int)_NBcols, (int)_NBrows, (int)elements_per_row,
+ (float)_localLuminanceAddon, (float)_localLuminanceFactor, (float)_maxInputValue);
+ kernel.run(sizeOfArray(globalSize), globalSize, localSize, false);
}
-const oclMat &BasicRetinaFilter::runFilter_LPfilter(const oclMat &inputFrame, const unsigned int filterIndex)
+const UMat &BasicRetinaFilter::runFilter_LPfilter(const UMat &inputFrame, const unsigned int filterIndex)
{
_spatiotemporalLPfilter(inputFrame, _filterOutput, filterIndex);
return _filterOutput;
}
-void BasicRetinaFilter::runFilter_LPfilter(const oclMat &inputFrame, oclMat &outputFrame, const unsigned int filterIndex)
+void BasicRetinaFilter::runFilter_LPfilter(const UMat &inputFrame, UMat &outputFrame, const unsigned int filterIndex)
{
_spatiotemporalLPfilter(inputFrame, outputFrame, filterIndex);
}
-void BasicRetinaFilter::_spatiotemporalLPfilter(const oclMat &inputFrame, oclMat &LPfilterOutput, const unsigned int filterIndex)
+void BasicRetinaFilter::_spatiotemporalLPfilter(const UMat &inputFrame, UMat &LPfilterOutput, const unsigned int filterIndex)
+{
+ _spatiotemporalLPfilter_h(inputFrame, LPfilterOutput, filterIndex);
+ _spatiotemporalLPfilter_v(LPfilterOutput, 0);
+}
+
+void BasicRetinaFilter::_spatiotemporalLPfilter_h(const UMat &inputFrame, UMat &LPfilterOutput, const unsigned int filterIndex)
{
unsigned int coefTableOffset = filterIndex * 3;
@@ -608,137 +596,88 @@ void BasicRetinaFilter::_spatiotemporalLPfilter(const oclMat &inputFrame, oclMat
_tau = _filteringCoeficientsTable[2 + coefTableOffset];
_horizontalCausalFilter_addInput(inputFrame, LPfilterOutput);
- _horizontalAnticausalFilter(LPfilterOutput);
- _verticalCausalFilter(LPfilterOutput);
- _verticalAnticausalFilter_multGain(LPfilterOutput);
}
-void BasicRetinaFilter::_horizontalCausalFilter_addInput(const oclMat &inputFrame, oclMat &outputFrame)
+void BasicRetinaFilter::_spatiotemporalLPfilter_v(UMat &LPfilterOutput, const unsigned int multichannel)
{
- int elements_per_row = static_cast<int>(inputFrame.step / inputFrame.elemSize());
-
- Context * ctx = Context::getContext();
- std::vector<std::pair<size_t, const void *> > args;
- size_t globalSize[] = {_NBrows, 1, 1};
- size_t localSize[] = {256, 1, 1};
-
- args.push_back(std::make_pair(sizeof(cl_mem), &inputFrame.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &outputFrame.data));
- args.push_back(std::make_pair(sizeof(cl_int), &_NBcols));
- args.push_back(std::make_pair(sizeof(cl_int), &_NBrows));
- args.push_back(std::make_pair(sizeof(cl_int), &elements_per_row));
- args.push_back(std::make_pair(sizeof(cl_int), &inputFrame.offset));
- args.push_back(std::make_pair(sizeof(cl_int), &inputFrame.offset));
- args.push_back(std::make_pair(sizeof(cl_float), &_tau));
- args.push_back(std::make_pair(sizeof(cl_float), &_a));
- openCLExecuteKernel(ctx, &retina_kernel, "horizontalCausalFilter_addInput", globalSize, localSize, args, -1, -1);
-}
-
-void BasicRetinaFilter::_horizontalAnticausalFilter(oclMat &outputFrame)
-{
- int elements_per_row = static_cast<int>(outputFrame.step / outputFrame.elemSize());
-
- Context * ctx = Context::getContext();
- std::vector<std::pair<size_t, const void *> > args;
- size_t globalSize[] = {_NBrows, 1, 1};
- size_t localSize[] = {256, 1, 1};
-
- args.push_back(std::make_pair(sizeof(cl_mem), &outputFrame.data));
- args.push_back(std::make_pair(sizeof(cl_int), &_NBcols));
- args.push_back(std::make_pair(sizeof(cl_int), &_NBrows));
- args.push_back(std::make_pair(sizeof(cl_int), &elements_per_row));
- args.push_back(std::make_pair(sizeof(cl_int), &outputFrame.offset));
- args.push_back(std::make_pair(sizeof(cl_float), &_a));
- openCLExecuteKernel(ctx, &retina_kernel, "horizontalAnticausalFilter", globalSize, localSize, args, -1, -1);
+ if (multichannel == 0)
+ _verticalCausalFilter(LPfilterOutput);
+ else
+ _verticalCausalFilter_multichannel(LPfilterOutput);
}
-void BasicRetinaFilter::_verticalCausalFilter(oclMat &outputFrame)
+void BasicRetinaFilter::_horizontalCausalFilter_addInput(const UMat &inputFrame, UMat &outputFrame)
{
- int elements_per_row = static_cast<int>(outputFrame.step / outputFrame.elemSize());
+ int elements_per_row = static_cast<int>(inputFrame.step / inputFrame.elemSize());
- Context * ctx = Context::getContext();
- std::vector<std::pair<size_t, const void *> > args;
- size_t globalSize[] = {_NBcols, 1, 1};
- size_t localSize[] = {256, 1, 1};
+ size_t globalSize[] = {(size_t)_NBrows};
+ size_t localSize[] = { 256 };
- args.push_back(std::make_pair(sizeof(cl_mem), &outputFrame.data));
- args.push_back(std::make_pair(sizeof(cl_int), &_NBcols));
- args.push_back(std::make_pair(sizeof(cl_int), &_NBrows));
- args.push_back(std::make_pair(sizeof(cl_int), &elements_per_row));
- args.push_back(std::make_pair(sizeof(cl_int), &outputFrame.offset));
- args.push_back(std::make_pair(sizeof(cl_float), &_a));
- openCLExecuteKernel(ctx, &retina_kernel, "verticalCausalFilter", globalSize, localSize, args, -1, -1);
+ Kernel kernel("horizontalCausalFilter_addInput", ocl::bioinspired::retina_kernel_oclsrc);
+ kernel.args(ocl::KernelArg::PtrReadOnly(inputFrame),
+ ocl::KernelArg::PtrWriteOnly(outputFrame),
+ (int)_NBcols, (int)_NBrows, (int)elements_per_row,
+ (int)inputFrame.offset, (int)inputFrame.offset,
+ (float)_tau, (float)_a);
+ kernel.run(sizeOfArray(globalSize), globalSize, localSize, false);
}
-void BasicRetinaFilter::_verticalAnticausalFilter_multGain(oclMat &outputFrame)
+void BasicRetinaFilter::_verticalCausalFilter(UMat &outputFrame)
{
int elements_per_row = static_cast<int>(outputFrame.step / outputFrame.elemSize());
- Context * ctx = Context::getContext();
- std::vector<std::pair<size_t, const void *> > args;
- size_t globalSize[] = {_NBcols, 1, 1};
- size_t localSize[] = {256, 1, 1};
+ size_t globalSize[] = {(size_t)_NBcols / 2};
+ size_t localSize[] = { 256 };
- args.push_back(std::make_pair(sizeof(cl_mem), &outputFrame.data));
- args.push_back(std::make_pair(sizeof(cl_int), &_NBcols));
- args.push_back(std::make_pair(sizeof(cl_int), &_NBrows));
- args.push_back(std::make_pair(sizeof(cl_int), &elements_per_row));
- args.push_back(std::make_pair(sizeof(cl_int), &outputFrame.offset));
- args.push_back(std::make_pair(sizeof(cl_float), &_a));
- args.push_back(std::make_pair(sizeof(cl_float), &_gain));
- openCLExecuteKernel(ctx, &retina_kernel, "verticalAnticausalFilter_multGain", globalSize, localSize, args, -1, -1);
+ Kernel kernel("verticalCausalFilter", ocl::bioinspired::retina_kernel_oclsrc);
+ kernel.args(ocl::KernelArg::PtrReadWrite(outputFrame),
+ (int)_NBcols, (int)_NBrows, (int)elements_per_row,
+ (int)outputFrame.offset, (float)_a, (float)_gain);
+ kernel.run(sizeOfArray(globalSize), globalSize, localSize, false);
}
-void BasicRetinaFilter::_horizontalAnticausalFilter_Irregular(oclMat &outputFrame, const oclMat &spatialConstantBuffer)
+void BasicRetinaFilter::_verticalCausalFilter_multichannel(UMat &outputFrame)
{
int elements_per_row = static_cast<int>(outputFrame.step / outputFrame.elemSize());
- Context * ctx = Context::getContext();
- std::vector<std::pair<size_t, const void *> > args;
- size_t globalSize[] = {outputFrame.rows, 1, 1};
- size_t localSize[] = {256, 1, 1};
+ size_t globalSize[] = {(size_t)_NBcols / 2};
+ size_t localSize[] = { 256 };
- args.push_back(std::make_pair(sizeof(cl_mem), &outputFrame.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &spatialConstantBuffer.data));
- args.push_back(std::make_pair(sizeof(cl_int), &outputFrame.cols));
- args.push_back(std::make_pair(sizeof(cl_int), &outputFrame.rows));
- args.push_back(std::make_pair(sizeof(cl_int), &elements_per_row));
- args.push_back(std::make_pair(sizeof(cl_int), &outputFrame.offset));
- args.push_back(std::make_pair(sizeof(cl_int), &spatialConstantBuffer.offset));
- openCLExecuteKernel(ctx, &retina_kernel, "horizontalAnticausalFilter_Irregular", globalSize, localSize, args, -1, -1);
+ Kernel kernel("verticalCausalFilter_multichannel", ocl::bioinspired::retina_kernel_oclsrc);
+ kernel.args(ocl::KernelArg::PtrReadWrite(outputFrame),
+ (int)_NBcols, (int)_NBrows, (int)elements_per_row,
+ (int)outputFrame.offset, (float)_a, (float)_gain);
+ kernel.run(sizeOfArray(globalSize), globalSize, localSize, false);
}
// vertical anticausal filter
-void BasicRetinaFilter::_verticalCausalFilter_Irregular(oclMat &outputFrame, const oclMat &spatialConstantBuffer)
+void BasicRetinaFilter::_verticalCausalFilter_Irregular(UMat &outputFrame, const UMat &spatialConstantBuffer)
{
int elements_per_row = static_cast<int>(outputFrame.step / outputFrame.elemSize());
- Context * ctx = Context::getContext();
- std::vector<std::pair<size_t, const void *> > args;
- size_t globalSize[] = {outputFrame.cols, 1, 1};
- size_t localSize[] = {256, 1, 1};
+ size_t globalSize[] = {(size_t)outputFrame.cols / 2};
+ size_t localSize[] = { 256 };
- args.push_back(std::make_pair(sizeof(cl_mem), &outputFrame.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &spatialConstantBuffer.data));
- args.push_back(std::make_pair(sizeof(cl_int), &outputFrame.cols));
- args.push_back(std::make_pair(sizeof(cl_int), &outputFrame.rows));
- args.push_back(std::make_pair(sizeof(cl_int), &elements_per_row));
- args.push_back(std::make_pair(sizeof(cl_int), &outputFrame.offset));
- args.push_back(std::make_pair(sizeof(cl_int), &spatialConstantBuffer.offset));
- openCLExecuteKernel(ctx, &retina_kernel, "verticalCausalFilter_Irregular", globalSize, localSize, args, -1, -1);
+ Kernel kernel("verticalCausalFilter_Irregular", ocl::bioinspired::retina_kernel_oclsrc);
+ kernel.args(ocl::KernelArg::PtrReadWrite(outputFrame),
+ ocl::KernelArg::PtrReadWrite(spatialConstantBuffer),
+ (int)outputFrame.cols, (int)(outputFrame.rows / 3),
+ (int)elements_per_row, (int)outputFrame.offset,
+ (int)spatialConstantBuffer.offset, (float)_gain);
+ kernel.run(sizeOfArray(globalSize), globalSize, localSize, false);
}
-void normalizeGrayOutput_0_maxOutputValue(oclMat &inputOutputBuffer, const float maxOutputValue)
+void normalizeGrayOutput_0_maxOutputValue(UMat &inputOutputBuffer, const float maxOutputValue)
{
double min_val, max_val;
- ocl::minMax(inputOutputBuffer, &min_val, &max_val);
+ cv::minMaxLoc(inputOutputBuffer, &min_val, &max_val);
float factor = maxOutputValue / static_cast<float>(max_val - min_val);
float offset = - static_cast<float>(min_val) * factor;
- ocl::multiply(factor, inputOutputBuffer, inputOutputBuffer);
- ocl::add(inputOutputBuffer, offset, inputOutputBuffer);
+ cv::multiply(factor, inputOutputBuffer, inputOutputBuffer);
+ cv::add(inputOutputBuffer, offset, inputOutputBuffer);
}
-void normalizeGrayOutputCentredSigmoide(const float meanValue, const float sensitivity, oclMat &in, oclMat &out, const float maxValue)
+void normalizeGrayOutputCentredSigmoide(const float meanValue, const float sensitivity, UMat &in, UMat &out, const float maxValue)
{
if (sensitivity == 1.0f)
{
@@ -749,63 +688,54 @@ void normalizeGrayOutputCentredSigmoide(const float meanValue, const float sensi
float X0 = maxValue / (sensitivity - 1.0f);
- Context * ctx = Context::getContext();
- std::vector<std::pair<size_t, const void *> > args;
- size_t globalSize[] = {in.cols, out.rows, 1};
- size_t localSize[] = {16, 16, 1};
+ size_t globalSize[] = {(size_t)in.cols / 4, (size_t)out.rows};
+ size_t localSize[] = {16, 16};
int elements_per_row = static_cast<int>(out.step / out.elemSize());
- args.push_back(std::make_pair(sizeof(cl_mem), &in.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &out.data));
- args.push_back(std::make_pair(sizeof(cl_int), &in.cols));
- args.push_back(std::make_pair(sizeof(cl_int), &in.rows));
- args.push_back(std::make_pair(sizeof(cl_int), &elements_per_row));
- args.push_back(std::make_pair(sizeof(cl_float), &meanValue));
- args.push_back(std::make_pair(sizeof(cl_float), &X0));
- openCLExecuteKernel(ctx, &retina_kernel, "normalizeGrayOutputCentredSigmoide", globalSize, localSize, args, -1, -1);
+ Kernel kernel("normalizeGrayOutputCentredSigmoide", ocl::bioinspired::retina_kernel_oclsrc);
+ kernel.args(ocl::KernelArg::PtrReadOnly(in),
+ ocl::KernelArg::PtrWriteOnly(out),
+ (int)in.cols, (int)in.rows, (int)elements_per_row,
+ (float)meanValue, (float)X0);
+ kernel.run(sizeOfArray(globalSize), globalSize, localSize, false);
}
-void normalizeGrayOutputNearZeroCentreredSigmoide(oclMat &inputPicture, oclMat &outputBuffer, const float sensitivity, const float maxOutputValue)
+void normalizeGrayOutputNearZeroCentreredSigmoide(UMat &inputPicture, UMat &outputBuffer, const float sensitivity, const float maxOutputValue)
{
float X0cube = sensitivity * sensitivity * sensitivity;
- Context * ctx = Context::getContext();
- std::vector<std::pair<size_t, const void *> > args;
- size_t globalSize[] = {inputPicture.cols, inputPicture.rows, 1};
- size_t localSize[] = {16, 16, 1};
+ size_t globalSize[] = {(size_t)inputPicture.cols, (size_t)inputPicture.rows};
+ size_t localSize[] = { 16, 16 };
int elements_per_row = static_cast<int>(inputPicture.step / inputPicture.elemSize());
- args.push_back(std::make_pair(sizeof(cl_mem), &inputPicture.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &outputBuffer.data));
- args.push_back(std::make_pair(sizeof(cl_int), &inputPicture.cols));
- args.push_back(std::make_pair(sizeof(cl_int), &inputPicture.rows));
- args.push_back(std::make_pair(sizeof(cl_int), &elements_per_row));
- args.push_back(std::make_pair(sizeof(cl_float), &maxOutputValue));
- args.push_back(std::make_pair(sizeof(cl_float), &X0cube));
- openCLExecuteKernel(ctx, &retina_kernel, "normalizeGrayOutputNearZeroCentreredSigmoide", globalSize, localSize, args, -1, -1);
+
+ Kernel kernel("normalizeGrayOutputNearZeroCentreredSigmoide", ocl::bioinspired::retina_kernel_oclsrc);
+ kernel.args(ocl::KernelArg::PtrReadOnly(inputPicture),
+ ocl::KernelArg::PtrWriteOnly(outputBuffer),
+ (int)inputPicture.cols, (int)inputPicture.rows, (int)elements_per_row,
+ (float)maxOutputValue, (float)X0cube);
+ kernel.run(sizeOfArray(globalSize), globalSize, localSize, false);
}
-void centerReductImageLuminance(oclMat &inputoutput)
+void centerReductImageLuminance(UMat &inputoutput)
{
Scalar mean, stddev;
- cv::meanStdDev((Mat)inputoutput, mean, stddev);
+ cv::meanStdDev(inputoutput.getMat(ACCESS_READ), mean, stddev);
- Context * ctx = Context::getContext();
- std::vector<std::pair<size_t, const void *> > args;
- size_t globalSize[] = {inputoutput.cols, inputoutput.rows, 1};
- size_t localSize[] = {16, 16, 1};
+ Context ctx = Context::getDefault();
+ size_t globalSize[] = {(size_t)inputoutput.cols / 4, (size_t)inputoutput.rows};
+ size_t localSize[] = {16, 16};
float f_mean = static_cast<float>(mean[0]);
float f_stddev = static_cast<float>(stddev[0]);
int elements_per_row = static_cast<int>(inputoutput.step / inputoutput.elemSize());
- args.push_back(std::make_pair(sizeof(cl_mem), &inputoutput.data));
- args.push_back(std::make_pair(sizeof(cl_int), &inputoutput.cols));
- args.push_back(std::make_pair(sizeof(cl_int), &inputoutput.rows));
- args.push_back(std::make_pair(sizeof(cl_int), &elements_per_row));
- args.push_back(std::make_pair(sizeof(cl_float), &f_mean));
- args.push_back(std::make_pair(sizeof(cl_float), &f_stddev));
- openCLExecuteKernel(ctx, &retina_kernel, "centerReductImageLuminance", globalSize, localSize, args, -1, -1);
+
+ Kernel kernel("centerReductImageLuminance", ocl::bioinspired::retina_kernel_oclsrc);
+ kernel.args(ocl::KernelArg::PtrReadWrite(inputoutput),
+ (int)inputoutput.cols, (int)inputoutput.rows, (int)elements_per_row,
+ (float)f_mean, (float)f_stddev);
+ kernel.run(sizeOfArray(globalSize), globalSize, localSize, false);
}
///////////////////////////////////////
@@ -873,7 +803,7 @@ void ParvoRetinaFilter::setOPLandParvoFiltersParameters(const float beta1, const
setLPfilterParameters(0, tau1, k1, 2);
}
-const oclMat &ParvoRetinaFilter::runFilter(const oclMat &inputFrame, const bool useParvoOutput)
+const UMat &ParvoRetinaFilter::runFilter(const UMat &inputFrame, const bool useParvoOutput)
{
_spatiotemporalLPfilter(inputFrame, _photoreceptorsOutput);
_spatiotemporalLPfilter(_photoreceptorsOutput, _horizontalCellsOutput, 1);
@@ -886,7 +816,7 @@ const oclMat &ParvoRetinaFilter::runFilter(const oclMat &inputFrame, const bool
_localLuminanceAdaptation(_parvocellularOutputON, _localAdaptationON);
_spatiotemporalLPfilter(_bipolarCellsOutputOFF, _localAdaptationOFF, 2);
_localLuminanceAdaptation(_parvocellularOutputOFF, _localAdaptationOFF);
- ocl::subtract(_parvocellularOutputON, _parvocellularOutputOFF, _parvocellularOutputONminusOFF);
+ cv::subtract(_parvocellularOutputON, _parvocellularOutputOFF, _parvocellularOutputONminusOFF);
}
return _parvocellularOutputONminusOFF;
@@ -895,21 +825,18 @@ void ParvoRetinaFilter::_OPL_OnOffWaysComputing()
{
int elements_per_row = static_cast<int>(_photoreceptorsOutput.step / _photoreceptorsOutput.elemSize());
- Context * ctx = Context::getContext();
- std::vector<std::pair<size_t, const void *> > args;
- size_t globalSize[] = {(_photoreceptorsOutput.cols + 3) / 4, _photoreceptorsOutput.rows, 1};
- size_t localSize[] = {16, 16, 1};
+ size_t globalSize[] = {((size_t)_photoreceptorsOutput.cols + 3) / 4, (size_t)_photoreceptorsOutput.rows};
+ size_t localSize[] = { 16, 16 };
- args.push_back(std::make_pair(sizeof(cl_mem), &_photoreceptorsOutput.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &_horizontalCellsOutput.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &_bipolarCellsOutputON.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &_bipolarCellsOutputOFF.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &_parvocellularOutputON.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &_parvocellularOutputOFF.data));
- args.push_back(std::make_pair(sizeof(cl_int), &_photoreceptorsOutput.cols));
- args.push_back(std::make_pair(sizeof(cl_int), &_photoreceptorsOutput.rows));
- args.push_back(std::make_pair(sizeof(cl_int), &elements_per_row));
- openCLExecuteKernel(ctx, &retina_kernel, "OPL_OnOffWaysComputing", globalSize, localSize, args, -1, -1);
+ Kernel kernel("OPL_OnOffWaysComputing", ocl::bioinspired::retina_kernel_oclsrc);
+ kernel.args(ocl::KernelArg::PtrReadOnly(_photoreceptorsOutput),
+ ocl::KernelArg::PtrReadOnly(_horizontalCellsOutput),
+ ocl::KernelArg::PtrWriteOnly(_bipolarCellsOutputON),
+ ocl::KernelArg::PtrWriteOnly(_bipolarCellsOutputOFF),
+ ocl::KernelArg::PtrWriteOnly(_parvocellularOutputON),
+ ocl::KernelArg::PtrWriteOnly(_parvocellularOutputOFF),
+ (int)_photoreceptorsOutput.cols, (int)_photoreceptorsOutput.rows, (int)elements_per_row);
+ kernel.run(sizeOfArray(globalSize), globalSize, localSize, false);
}
///////////////////////////////////////
@@ -978,31 +905,28 @@ void MagnoRetinaFilter::setCoefficientsTable(const float parasolCells_beta, cons
}
void MagnoRetinaFilter::_amacrineCellsComputing(
- const oclMat &OPL_ON,
- const oclMat &OPL_OFF
+ const UMat &OPL_ON,
+ const UMat &OPL_OFF
)
{
int elements_per_row = static_cast<int>(OPL_ON.step / OPL_ON.elemSize());
- Context * ctx = Context::getContext();
- std::vector<std::pair<size_t, const void *> > args;
- size_t globalSize[] = {OPL_ON.cols, OPL_ON.rows, 1};
- size_t localSize[] = {16, 16, 1};
+ size_t globalSize[] = {(size_t)OPL_ON.cols / 4, (size_t)OPL_ON.rows};
+ size_t localSize[] = { 16, 16 };
- args.push_back(std::make_pair(sizeof(cl_mem), &OPL_ON.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &OPL_OFF.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &_previousInput_ON.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &_previousInput_OFF.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &_amacrinCellsTempOutput_ON.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &_amacrinCellsTempOutput_OFF.data));
- args.push_back(std::make_pair(sizeof(cl_int), &OPL_ON.cols));
- args.push_back(std::make_pair(sizeof(cl_int), &OPL_ON.rows));
- args.push_back(std::make_pair(sizeof(cl_int), &elements_per_row));
- args.push_back(std::make_pair(sizeof(cl_float), &_temporalCoefficient));
- openCLExecuteKernel(ctx, &retina_kernel, "amacrineCellsComputing", globalSize, localSize, args, -1, -1);
+ Kernel kernel("amacrineCellsComputing", ocl::bioinspired::retina_kernel_oclsrc);
+ kernel.args(ocl::KernelArg::PtrReadOnly(OPL_ON),
+ ocl::KernelArg::PtrReadOnly(OPL_OFF),
+ ocl::KernelArg::PtrReadWrite(_previousInput_ON),
+ ocl::KernelArg::PtrReadWrite(_previousInput_OFF),
+ ocl::KernelArg::PtrReadWrite(_amacrinCellsTempOutput_ON),
+ ocl::KernelArg::PtrReadWrite(_amacrinCellsTempOutput_OFF),
+ (int)OPL_ON.cols, (int)OPL_ON.rows, (int)elements_per_row,
+ (float)_temporalCoefficient);
+ kernel.run(sizeOfArray(globalSize), globalSize, localSize, false);
}
-const oclMat &MagnoRetinaFilter::runFilter(const oclMat &OPL_ON, const oclMat &OPL_OFF)
+const UMat &MagnoRetinaFilter::runFilter(const UMat &OPL_ON, const UMat &OPL_OFF)
{
// Compute the high pass temporal filter
_amacrineCellsComputing(OPL_ON, OPL_OFF);
@@ -1018,7 +942,7 @@ const oclMat &MagnoRetinaFilter::runFilter(const oclMat &OPL_ON, const oclMat &O
_spatiotemporalLPfilter(_magnoXOutputOFF, _localProcessBufferOFF, 1);
_localLuminanceAdaptation(_magnoXOutputOFF, _localProcessBufferOFF);
- _magnoYOutput = _magnoXOutputON + _magnoXOutputOFF;
+ add(_magnoXOutputON, _magnoXOutputOFF, _magnoYOutput);
return _magnoYOutput;
}
@@ -1029,7 +953,7 @@ const oclMat &MagnoRetinaFilter::runFilter(const oclMat &OPL_ON, const oclMat &O
// define an array of ROI headers of input x
#define MAKE_OCLMAT_SLICES(x, n) \
- oclMat x##_slices[n];\
+ UMat x##_slices[n];\
for(int _SLICE_INDEX_ = 0; _SLICE_INDEX_ < n; _SLICE_INDEX_ ++)\
{\
x##_slices[_SLICE_INDEX_] = x(getROI(_SLICE_INDEX_));\
@@ -1107,20 +1031,17 @@ void RetinaColor::resize(const unsigned int NBrows, const unsigned int NBcolumns
clearAllBuffers();
}
-static void inverseValue(oclMat &input)
+static void inverseValue(UMat &input)
{
int elements_per_row = static_cast<int>(input.step / input.elemSize());
- Context * ctx = Context::getContext();
- std::vector<std::pair<size_t, const void *> > args;
- size_t globalSize[] = {input.cols, input.rows, 1};
- size_t localSize[] = {16, 16, 1};
+ size_t globalSize[] = {(size_t)input.cols / 4, (size_t)input.rows};
+ size_t localSize[] = { 16, 16 };
- args.push_back(std::make_pair(sizeof(cl_mem), &input.data));
- args.push_back(std::make_pair(sizeof(cl_int), &input.cols));
- args.push_back(std::make_pair(sizeof(cl_int), &input.rows));
- args.push_back(std::make_pair(sizeof(cl_int), &elements_per_row));
- openCLExecuteKernel(ctx, &retina_kernel, "inverseValue", globalSize, localSize, args, -1, -1);
+ Kernel kernel("inverseValue", ocl::bioinspired::retina_kernel_oclsrc);
+ kernel.args(ocl::KernelArg::PtrReadWrite(input),
+ (int)input.cols, (int)input.rows, (int)elements_per_row);
+ kernel.run(sizeOfArray(globalSize), globalSize, localSize, false);
}
void RetinaColor::_initColorSampling()
@@ -1129,76 +1050,69 @@ void RetinaColor::_initColorSampling()
_pR = _pB = 0.25;
_pG = 0.5;
// filling the mosaic buffer:
- _RGBmosaic = 0;
- Mat tmp_mat(_NBrows * 3, _NBcols, CV_32FC1);
+ Mat tmp_mat(_NBrows * 3, _NBcols, CV_32FC1, Scalar(0));
float * tmp_mat_ptr = tmp_mat.ptr<float>();
- tmp_mat.setTo(0);
for (unsigned int index = 0 ; index < getNBpixels(); ++index)
{
tmp_mat_ptr[bayerSampleOffset(index)] = 1.0;
}
- _RGBmosaic.upload(tmp_mat);
+ tmp_mat.copyTo(_RGBmosaic);
// computing photoreceptors local density
MAKE_OCLMAT_SLICES(_RGBmosaic, 3);
MAKE_OCLMAT_SLICES(_colorLocalDensity, 3);
_colorLocalDensity.setTo(0);
- _spatiotemporalLPfilter(_RGBmosaic_slices[0], _colorLocalDensity_slices[0]);
- _spatiotemporalLPfilter(_RGBmosaic_slices[1], _colorLocalDensity_slices[1]);
- _spatiotemporalLPfilter(_RGBmosaic_slices[2], _colorLocalDensity_slices[2]);
+ _spatiotemporalLPfilter_h(_RGBmosaic_slices[0], _colorLocalDensity_slices[0]);
+ _spatiotemporalLPfilter_h(_RGBmosaic_slices[1], _colorLocalDensity_slices[1]);
+ _spatiotemporalLPfilter_h(_RGBmosaic_slices[2], _colorLocalDensity_slices[2]);
+ _spatiotemporalLPfilter_v(_colorLocalDensity, 1);
- //_colorLocalDensity = oclMat(_colorLocalDensity.size(), _colorLocalDensity.type(), 1.f) / _colorLocalDensity;
+ //_colorLocalDensity = UMat(_colorLocalDensity.size(), _colorLocalDensity.type(), 1.f) / _colorLocalDensity;
inverseValue(_colorLocalDensity);
_objectInit = true;
}
-static void demultiplex(const oclMat &input, oclMat &ouput)
+static void demultiplex(const UMat &input, UMat &ouput)
{
int elements_per_row = static_cast<int>(input.step / input.elemSize());
- Context * ctx = Context::getContext();
- std::vector<std::pair<size_t, const void *> > args;
- size_t globalSize[] = {input.cols, input.rows, 1};
- size_t localSize[] = {16, 16, 1};
+ size_t globalSize[] = {(size_t)input.cols / 4, (size_t)input.rows};
+ size_t localSize[] = { 16, 16 };
- args.push_back(std::make_pair(sizeof(cl_mem), &input.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &ouput.data));
- args.push_back(std::make_pair(sizeof(cl_int), &input.cols));
- args.push_back(std::make_pair(sizeof(cl_int), &input.rows));
- args.push_back(std::make_pair(sizeof(cl_int), &elements_per_row));
- openCLExecuteKernel(ctx, &retina_kernel, "runColorDemultiplexingBayer", globalSize, localSize, args, -1, -1);
+ Kernel kernel("runColorDemultiplexingBayer", ocl::bioinspired::retina_kernel_oclsrc);
+ kernel.args(ocl::KernelArg::PtrReadOnly(input),
+ ocl::KernelArg::PtrWriteOnly(ouput),
+ (int)input.cols, (int)input.rows, (int)elements_per_row);
+ kernel.run(sizeOfArray(globalSize), globalSize, localSize, false);
}
static void normalizePhotoDensity(
- const oclMat &chroma,
- const oclMat &colorDensity,
- const oclMat &multiplex,
- oclMat &ocl_luma,
- oclMat &demultiplex,
+ const UMat &chroma,
+ const UMat &colorDensity,
+ const UMat &multiplex,
+ UMat &ocl_luma,
+ UMat &demultiplex,
const float pG
)
{
int elements_per_row = static_cast<int>(ocl_luma.step / ocl_luma.elemSize());
- Context * ctx = Context::getContext();
- std::vector<std::pair<size_t, const void *> > args;
- size_t globalSize[] = {ocl_luma.cols, ocl_luma.rows, 1};
- size_t localSize[] = {16, 16, 1};
+ size_t globalSize[] = {(size_t)ocl_luma.cols / 4, (size_t)ocl_luma.rows};
+ size_t localSize[] = { 16, 16 };
- args.push_back(std::make_pair(sizeof(cl_mem), &chroma.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &colorDensity.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &multiplex.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &ocl_luma.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &demultiplex.data));
- args.push_back(std::make_pair(sizeof(cl_int), &ocl_luma.cols));
- args.push_back(std::make_pair(sizeof(cl_int), &ocl_luma.rows));
- args.push_back(std::make_pair(sizeof(cl_int), &elements_per_row));
- args.push_back(std::make_pair(sizeof(cl_float), &pG));
- openCLExecuteKernel(ctx, &retina_kernel, "normalizePhotoDensity", globalSize, localSize, args, -1, -1);
+ Kernel kernel("normalizePhotoDensity", ocl::bioinspired::retina_kernel_oclsrc);
+ kernel.args(ocl::KernelArg::PtrReadOnly(chroma),
+ ocl::KernelArg::PtrReadOnly(colorDensity),
+ ocl::KernelArg::PtrReadOnly(multiplex),
+ ocl::KernelArg::PtrWriteOnly(ocl_luma),
+ ocl::KernelArg::PtrWriteOnly(demultiplex),
+ (int)ocl_luma.cols, (int)ocl_luma.rows, (int)elements_per_row,
+ (float)pG);
+ kernel.run(sizeOfArray(globalSize), globalSize, localSize, false);
}
static void substractResidual(
- oclMat &colorDemultiplex,
+ UMat &colorDemultiplex,
float pR,
float pG,
float pB
@@ -1206,43 +1120,35 @@ static void substractResidual(
{
int elements_per_row = static_cast<int>(colorDemultiplex.step / colorDemultiplex.elemSize());
- Context * ctx = Context::getContext();
- std::vector<std::pair<size_t, const void *> > args;
int rows = colorDemultiplex.rows / 3, cols = colorDemultiplex.cols;
- size_t globalSize[] = {cols, rows, 1};
- size_t localSize[] = {16, 16, 1};
+ size_t globalSize[] = {(size_t)cols / 4, (size_t)rows};
+ size_t localSize[] = { 16, 16 };
- args.push_back(std::make_pair(sizeof(cl_mem), &colorDemultiplex.data));
- args.push_back(std::make_pair(sizeof(cl_int), &cols));
- args.push_back(std::make_pair(sizeof(cl_int), &rows));
- args.push_back(std::make_pair(sizeof(cl_int), &elements_per_row));
- args.push_back(std::make_pair(sizeof(cl_float), &pR));
- args.push_back(std::make_pair(sizeof(cl_float), &pG));
- args.push_back(std::make_pair(sizeof(cl_float), &pB));
- openCLExecuteKernel(ctx, &retina_kernel, "substractResidual", globalSize, localSize, args, -1, -1);
+ Kernel kernel("substractResidual", ocl::bioinspired::retina_kernel_oclsrc);
+ kernel.args(ocl::KernelArg::PtrReadWrite(colorDemultiplex),
+ (int)cols, (int)rows, (int)elements_per_row,
+ (float)pR, (float)pG, (float)pB);
+ kernel.run(sizeOfArray(globalSize), globalSize, localSize, false);
}
-static void demultiplexAssign(const oclMat& input, const oclMat& output)
+static void demultiplexAssign(const UMat& input, const UMat& output)
{
// only supports bayer
int elements_per_row = static_cast<int>(input.step / input.elemSize());
- Context * ctx = Context::getContext();
- std::vector<std::pair<size_t, const void *> > args;
int rows = input.rows / 3, cols = input.cols;
- size_t globalSize[] = {cols, rows, 1};
- size_t localSize[] = {16, 16, 1};
+ size_t globalSize[] = {(size_t)cols, (size_t)rows};
+ size_t localSize[] = { 16, 16 };
- args.push_back(std::make_pair(sizeof(cl_mem), &input.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &output.data));
- args.push_back(std::make_pair(sizeof(cl_int), &cols));
- args.push_back(std::make_pair(sizeof(cl_int), &rows));
- args.push_back(std::make_pair(sizeof(cl_int), &elements_per_row));
- openCLExecuteKernel(ctx, &retina_kernel, "demultiplexAssign", globalSize, localSize, args, -1, -1);
+ Kernel kernel("demultiplexAssign", ocl::bioinspired::retina_kernel_oclsrc);
+ kernel.args(ocl::KernelArg::PtrReadOnly(input),
+ ocl::KernelArg::PtrWriteOnly(output),
+ (int)cols, (int)rows, (int)elements_per_row);
+ kernel.run(sizeOfArray(globalSize), globalSize, localSize, false);
}
void RetinaColor::runColorDemultiplexing(
- const oclMat &ocl_multiplexed_input,
+ const UMat &ocl_multiplexed_input,
const bool adaptiveFiltering,
const float maxInputValue
)
@@ -1262,9 +1168,10 @@ void RetinaColor::runColorDemultiplexing(
CV_Assert(adaptiveFiltering == false);
}
- _spatiotemporalLPfilter(_demultiplexedTempBuffer_slices[0], _chrominance_slices[0]);
- _spatiotemporalLPfilter(_demultiplexedTempBuffer_slices[1], _chrominance_slices[1]);
- _spatiotemporalLPfilter(_demultiplexedTempBuffer_slices[2], _chrominance_slices[2]);
+ _spatiotemporalLPfilter_h(_demultiplexedTempBuffer_slices[0], _chrominance_slices[0]);
+ _spatiotemporalLPfilter_h(_demultiplexedTempBuffer_slices[1], _chrominance_slices[1]);
+ _spatiotemporalLPfilter_h(_demultiplexedTempBuffer_slices[2], _chrominance_slices[2]);
+ _spatiotemporalLPfilter_v(_chrominance, 1);
if (!adaptiveFiltering)// compute the gradient on the luminance
{
@@ -1277,27 +1184,39 @@ void RetinaColor::runColorDemultiplexing(
// compute the gradient of the luminance
_computeGradient(_luminance, _imageGradient);
- _adaptiveSpatialLPfilter(_RGBmosaic_slices[0], _imageGradient, _chrominance_slices[0]);
- _adaptiveSpatialLPfilter(_RGBmosaic_slices[1], _imageGradient, _chrominance_slices[1]);
- _adaptiveSpatialLPfilter(_RGBmosaic_slices[2], _imageGradient, _chrominance_slices[2]);
+ _adaptiveSpatialLPfilter_h(_RGBmosaic_slices[0], _imageGradient, _chrominance_slices[0]);
+ _adaptiveSpatialLPfilter_h(_RGBmosaic_slices[1], _imageGradient, _chrominance_slices[1]);
+ _adaptiveSpatialLPfilter_h(_RGBmosaic_slices[2], _imageGradient, _chrominance_slices[2]);
+ _adaptiveSpatialLPfilter_v(_imageGradient, _chrominance);
- _adaptiveSpatialLPfilter(_demultiplexedTempBuffer_slices[0], _imageGradient, _demultiplexedColorFrame_slices[0]);
- _adaptiveSpatialLPfilter(_demultiplexedTempBuffer_slices[1], _imageGradient, _demultiplexedColorFrame_slices[1]);
- _adaptiveSpatialLPfilter(_demultiplexedTempBuffer_slices[2], _imageGradient, _demultiplexedColorFrame_slices[2]);
+ _adaptiveSpatialLPfilter_h(_demultiplexedTempBuffer_slices[0], _imageGradient, _demultiplexedColorFrame_slices[0]);
+ _adaptiveSpatialLPfilter_h(_demultiplexedTempBuffer_slices[1], _imageGradient, _demultiplexedColorFrame_slices[1]);
+ _adaptiveSpatialLPfilter_h(_demultiplexedTempBuffer_slices[2], _imageGradient, _demultiplexedColorFrame_slices[2]);
+ _adaptiveSpatialLPfilter_v(_imageGradient, _demultiplexedColorFrame);
- _demultiplexedColorFrame /= _chrominance; // per element division
+ divide(_demultiplexedColorFrame, _chrominance, _demultiplexedColorFrame);
substractResidual(_demultiplexedColorFrame, _pR, _pG, _pB);
runColorMultiplexing(_demultiplexedColorFrame, _tempMultiplexedFrame);
_demultiplexedTempBuffer.setTo(0);
- _luminance = ocl_multiplexed_input - _tempMultiplexedFrame;
+ subtract(ocl_multiplexed_input, _tempMultiplexedFrame, _luminance);
demultiplexAssign(_demultiplexedColorFrame, _demultiplexedTempBuffer);
- for(int i = 0; i < 3; i ++)
- {
- _spatiotemporalLPfilter(_demultiplexedTempBuffer_slices[i], _demultiplexedTempBuffer_slices[i]);
- _demultiplexedColorFrame_slices[i] = _demultiplexedTempBuffer_slices[i] * _colorLocalDensity_slices[i] + _luminance;
- }
+ _spatiotemporalLPfilter_h(_demultiplexedTempBuffer_slices[0], _demultiplexedTempBuffer_slices[0]);
+ _spatiotemporalLPfilter_h(_demultiplexedTempBuffer_slices[1], _demultiplexedTempBuffer_slices[1]);
+ _spatiotemporalLPfilter_h(_demultiplexedTempBuffer_slices[2], _demultiplexedTempBuffer_slices[2]);
+ _spatiotemporalLPfilter_v(_demultiplexedTempBuffer, 1);
+
+ multiply(_demultiplexedTempBuffer, _colorLocalDensity, _demultiplexedColorFrame);
+
+ std::vector<UMat> m;
+ UMat _luminance_concat;
+
+ m.push_back(_luminance);
+ m.push_back(_luminance);
+ m.push_back(_luminance);
+ vconcat(m, _luminance_concat);
+ add(_demultiplexedColorFrame, _luminance_concat, _demultiplexedColorFrame);
}
// eliminate saturated colors by simple clipping values to the input range
clipRGBOutput_0_maxInputValue(_demultiplexedColorFrame, maxInputValue);
@@ -1307,44 +1226,38 @@ void RetinaColor::runColorDemultiplexing(
ocl::normalizeGrayOutputCentredSigmoide(128, maxInputValue, _demultiplexedColorFrame, _demultiplexedColorFrame);
}
}
-void RetinaColor::runColorMultiplexing(const oclMat &demultiplexedInputFrame, oclMat &multiplexedFrame)
+void RetinaColor::runColorMultiplexing(const UMat &demultiplexedInputFrame, UMat &multiplexedFrame)
{
int elements_per_row = static_cast<int>(multiplexedFrame.step / multiplexedFrame.elemSize());
- Context * ctx = Context::getContext();
- std::vector<std::pair<size_t, const void *> > args;
- size_t globalSize[] = {multiplexedFrame.cols, multiplexedFrame.rows, 1};
- size_t localSize[] = {16, 16, 1};
+ size_t globalSize[] = {(size_t)multiplexedFrame.cols / 4, (size_t)multiplexedFrame.rows};
+ size_t localSize[] = { 16, 16 };
- args.push_back(std::make_pair(sizeof(cl_mem), &demultiplexedInputFrame.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &multiplexedFrame.data));
- args.push_back(std::make_pair(sizeof(cl_int), &multiplexedFrame.cols));
- args.push_back(std::make_pair(sizeof(cl_int), &multiplexedFrame.rows));
- args.push_back(std::make_pair(sizeof(cl_int), &elements_per_row));
- openCLExecuteKernel(ctx, &retina_kernel, "runColorMultiplexingBayer", globalSize, localSize, args, -1, -1);
+ Kernel kernel("runColorMultiplexingBayer", ocl::bioinspired::retina_kernel_oclsrc);
+ kernel.args(ocl::KernelArg::PtrReadOnly(demultiplexedInputFrame),
+ ocl::KernelArg::PtrWriteOnly(multiplexedFrame),
+ (int)multiplexedFrame.cols, (int)multiplexedFrame.rows, (int)elements_per_row);
+ kernel.run(sizeOfArray(globalSize), globalSize, localSize, false);
}
-void RetinaColor::clipRGBOutput_0_maxInputValue(oclMat &inputOutputBuffer, const float maxInputValue)
+void RetinaColor::clipRGBOutput_0_maxInputValue(UMat &inputOutputBuffer, const float maxInputValue)
{
// the kernel is equivalent to:
//ocl::threshold(inputOutputBuffer, inputOutputBuffer, maxInputValue, maxInputValue, THRESH_TRUNC);
//ocl::threshold(inputOutputBuffer, inputOutputBuffer, 0, 0, THRESH_TOZERO);
int elements_per_row = static_cast<int>(inputOutputBuffer.step / inputOutputBuffer.elemSize());
- Context * ctx = Context::getContext();
- std::vector<std::pair<size_t, const void *> > args;
- size_t globalSize[] = {_NBcols, inputOutputBuffer.rows, 1};
- size_t localSize[] = {16, 16, 1};
+ size_t globalSize[] = {(size_t)_NBcols / 4, (size_t)inputOutputBuffer.rows};
+ size_t localSize[] = { 16, 16 };
- args.push_back(std::make_pair(sizeof(cl_mem), &inputOutputBuffer.data));
- args.push_back(std::make_pair(sizeof(cl_int), &_NBcols));
- args.push_back(std::make_pair(sizeof(cl_int), &inputOutputBuffer.rows));
- args.push_back(std::make_pair(sizeof(cl_int), &elements_per_row));
- args.push_back(std::make_pair(sizeof(cl_float), &maxInputValue));
- openCLExecuteKernel(ctx, &retina_kernel, "clipRGBOutput_0_maxInputValue", globalSize, localSize, args, -1, -1);
+ Kernel kernel("clipRGBOutput_0_maxInputValue", ocl::bioinspired::retina_kernel_oclsrc);
+ kernel.args(ocl::KernelArg::PtrReadWrite(inputOutputBuffer),
+ (int)_NBcols, (int)inputOutputBuffer.rows, (int)elements_per_row,
+ (float)maxInputValue);
+ kernel.run(sizeOfArray(globalSize), globalSize, localSize, false);
}
-void RetinaColor::_adaptiveSpatialLPfilter(const oclMat &inputFrame, const oclMat &gradient, oclMat &outputFrame)
+void RetinaColor::_adaptiveSpatialLPfilter_h(const UMat &inputFrame, const UMat &gradient, UMat &outputFrame)
{
/**********/
_gain = (1 - 0.57f) * (1 - 0.57f) * (1 - 0.06f) * (1 - 0.06f);
@@ -1352,69 +1265,41 @@ void RetinaColor::_adaptiveSpatialLPfilter(const oclMat &inputFrame, const oclMa
// launch the serie of 1D directional filters in order to compute the 2D low pass filter
// -> horizontal filters work with the first layer of imageGradient
_adaptiveHorizontalCausalFilter_addInput(inputFrame, gradient, outputFrame);
- _horizontalAnticausalFilter_Irregular(outputFrame, gradient);
- // -> horizontal filters work with the second layer of imageGradient
- _verticalCausalFilter_Irregular(outputFrame, gradient(getROI(1)));
- _adaptiveVerticalAnticausalFilter_multGain(gradient, outputFrame);
}
-void RetinaColor::_adaptiveHorizontalCausalFilter_addInput(const oclMat &inputFrame, const oclMat &gradient, oclMat &outputFrame)
+void RetinaColor::_adaptiveSpatialLPfilter_v(const UMat &gradient, UMat &outputFrame)
{
- int elements_per_row = static_cast<int>(inputFrame.step / inputFrame.elemSize());
-
- Context * ctx = Context::getContext();
- std::vector<std::pair<size_t, const void *> > args;
- size_t globalSize[] = {_NBrows, 1, 1};
- size_t localSize[] = {256, 1, 1};
-
- args.push_back(std::make_pair(sizeof(cl_mem), &inputFrame.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &gradient.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &outputFrame.data));
- args.push_back(std::make_pair(sizeof(cl_int), &_NBcols));
- args.push_back(std::make_pair(sizeof(cl_int), &_NBrows));
- args.push_back(std::make_pair(sizeof(cl_int), &elements_per_row));
- args.push_back(std::make_pair(sizeof(cl_int), &inputFrame.offset));
- args.push_back(std::make_pair(sizeof(cl_int), &gradient.offset));
- args.push_back(std::make_pair(sizeof(cl_int), &outputFrame.offset));
- openCLExecuteKernel(ctx, &retina_kernel, "adaptiveHorizontalCausalFilter_addInput", globalSize, localSize, args, -1, -1);
+ _verticalCausalFilter_Irregular(outputFrame, gradient(getROI(1)));
}
-void RetinaColor::_adaptiveVerticalAnticausalFilter_multGain(const oclMat &gradient, oclMat &outputFrame)
+void RetinaColor::_adaptiveHorizontalCausalFilter_addInput(const UMat &inputFrame, const UMat &gradient, UMat &outputFrame)
{
- int elements_per_row = static_cast<int>(outputFrame.step / outputFrame.elemSize());
-
- Context * ctx = Context::getContext();
- std::vector<std::pair<size_t, const void *> > args;
- size_t globalSize[] = {_NBcols, 1, 1};
- size_t localSize[] = {256, 1, 1};
+ int elements_per_row = static_cast<int>(inputFrame.step / inputFrame.elemSize());
- int gradOffset = gradient.offset + static_cast<int>(gradient.step * _NBrows);
+ size_t globalSize[] = {(size_t)_NBrows};
+ size_t localSize[] = { 256 };
- args.push_back(std::make_pair(sizeof(cl_mem), &gradient.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &outputFrame.data));
- args.push_back(std::make_pair(sizeof(cl_int), &_NBcols));
- args.push_back(std::make_pair(sizeof(cl_int), &_NBrows));
- args.push_back(std::make_pair(sizeof(cl_int), &elements_per_row));
- args.push_back(std::make_pair(sizeof(cl_int), &gradOffset));
- args.push_back(std::make_pair(sizeof(cl_int), &outputFrame.offset));
- args.push_back(std::make_pair(sizeof(cl_float), &_gain));
- openCLExecuteKernel(ctx, &retina_kernel, "adaptiveVerticalAnticausalFilter_multGain", globalSize, localSize, args, -1, -1);
+ Kernel kernel("adaptiveHorizontalCausalFilter_addInput", ocl::bioinspired::retina_kernel_oclsrc);
+ kernel.args(ocl::KernelArg::PtrReadOnly(inputFrame),
+ ocl::KernelArg::PtrReadOnly(gradient),
+ ocl::KernelArg::PtrWriteOnly(outputFrame),
+ (int)_NBcols, (int)_NBrows, (int)elements_per_row, (int)inputFrame.offset,
+ (int)gradient.offset, (int)outputFrame.offset);
+ kernel.run(sizeOfArray(globalSize), globalSize, localSize, false);
}
-void RetinaColor::_computeGradient(const oclMat &luminance, oclMat &gradient)
+
+void RetinaColor::_computeGradient(const UMat &luminance, UMat &gradient)
{
int elements_per_row = static_cast<int>(luminance.step / luminance.elemSize());
- Context * ctx = Context::getContext();
- std::vector<std::pair<size_t, const void *> > args;
- size_t globalSize[] = {_NBcols, _NBrows, 1};
- size_t localSize[] = {16, 16, 1};
+ size_t globalSize[] = {(size_t)_NBcols, (size_t)_NBrows};
+ size_t localSize[] = { 16, 16 };
- args.push_back(std::make_pair(sizeof(cl_mem), &luminance.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &gradient.data));
- args.push_back(std::make_pair(sizeof(cl_int), &_NBcols));
- args.push_back(std::make_pair(sizeof(cl_int), &_NBrows));
- args.push_back(std::make_pair(sizeof(cl_int), &elements_per_row));
- openCLExecuteKernel(ctx, &retina_kernel, "computeGradient", globalSize, localSize, args, -1, -1);
+ Kernel kernel("computeGradient", ocl::bioinspired::retina_kernel_oclsrc);
+ kernel.args(ocl::KernelArg::PtrReadOnly(luminance),
+ ocl::KernelArg::PtrWriteOnly(gradient),
+ (int)_NBcols, (int)_NBrows, (int)elements_per_row);
+ kernel.run(sizeOfArray(globalSize), globalSize, localSize, false);
}
///////////////////////////////////////
@@ -1500,7 +1385,7 @@ void RetinaFilter::setGlobalParameters(const float OPLspatialResponse1, const fl
_setInitPeriodCount();
}
-bool RetinaFilter::checkInput(const oclMat &input, const bool)
+bool RetinaFilter::checkInput(const UMat &input, const bool)
{
BasicRetinaFilter *inputTarget = &_photoreceptorsPrefilter;
@@ -1518,7 +1403,7 @@ bool RetinaFilter::checkInput(const oclMat &input, const bool)
}
// main function that runs the filter for a given input frame
-bool RetinaFilter::runFilter(const oclMat &imageInput, const bool useAdaptiveFiltering, const bool processRetinaParvoMagnoMapping, const bool useColorMode, const bool inputIsColorMultiplexed)
+bool RetinaFilter::runFilter(const UMat &imageInput, const bool useAdaptiveFiltering, const bool processRetinaParvoMagnoMapping, const bool useColorMode, const bool inputIsColorMultiplexed)
{
// preliminary check
bool processSuccess = true;
@@ -1537,8 +1422,8 @@ bool RetinaFilter::runFilter(const oclMat &imageInput, const bool useAdaptiveFil
_useColorMode = useColorMode;
- oclMat selectedPhotoreceptorsLocalAdaptationInput = imageInput;
- oclMat selectedPhotoreceptorsColorInput = imageInput;
+ UMat selectedPhotoreceptorsLocalAdaptationInput = imageInput;
+ UMat selectedPhotoreceptorsColorInput = imageInput;
//********** Following is input data specific photoreceptors processing
if (useColorMode && (!inputIsColorMultiplexed)) // not multiplexed color input case
@@ -1592,7 +1477,7 @@ bool RetinaFilter::runFilter(const oclMat &imageInput, const bool useAdaptiveFil
return processSuccess;
}
-const oclMat &RetinaFilter::getContours()
+const UMat &RetinaFilter::getContours()
{
if (_useColorMode)
{
@@ -1605,8 +1490,8 @@ const oclMat &RetinaFilter::getContours()
}
void RetinaFilter::_processRetinaParvoMagnoMapping()
{
- oclMat parvo = _ParvoRetinaFilter.getOutput();
- oclMat magno = _MagnoRetinaFilter.getOutput();
+ UMat parvo = _ParvoRetinaFilter.getOutput();
+ UMat magno = _MagnoRetinaFilter.getOutput();
int halfRows = parvo.rows / 2;
int halfCols = parvo.cols / 2;
@@ -1614,30 +1499,19 @@ void RetinaFilter::_processRetinaParvoMagnoMapping()
int elements_per_row = static_cast<int>(parvo.step / parvo.elemSize());
- Context * ctx = Context::getContext();
- std::vector<std::pair<size_t, const void *> > args;
- size_t globalSize[] = {parvo.cols, parvo.rows, 1};
- size_t localSize[] = {16, 16, 1};
-
- args.push_back(std::make_pair(sizeof(cl_mem), &parvo.data));
- args.push_back(std::make_pair(sizeof(cl_mem), &magno.data));
- args.push_back(std::make_pair(sizeof(cl_int), &parvo.cols));
- args.push_back(std::make_pair(sizeof(cl_int), &parvo.rows));
- args.push_back(std::make_pair(sizeof(cl_int), &halfCols));
- args.push_back(std::make_pair(sizeof(cl_int), &halfRows));
- args.push_back(std::make_pair(sizeof(cl_int), &elements_per_row));
- args.push_back(std::make_pair(sizeof(cl_float), &minDistance));
- openCLExecuteKernel(ctx, &retina_kernel, "processRetinaParvoMagnoMapping", globalSize, localSize, args, -1, -1);
-}
-} /* namespace ocl */
+ size_t globalSize[] = {(size_t)parvo.cols, (size_t)parvo.rows};
+ size_t localSize[] = { 16, 16 };
-Ptr<Retina> createRetina_OCL(Size getInputSize){ return makePtr<ocl::RetinaOCLImpl>(getInputSize); }
-Ptr<Retina> createRetina_OCL(Size getInputSize, const bool colorMode, int colorSamplingMethod, const bool useRetinaLogSampling, const double reductionFactor, const double samplingStrenght)
-{
- return makePtr<ocl::RetinaOCLImpl>(getInputSize, colorMode, colorSamplingMethod, useRetinaLogSampling, reductionFactor, samplingStrenght);
+ Kernel kernel("processRetinaParvoMagnoMapping", ocl::bioinspired::retina_kernel_oclsrc);
+ kernel.args(ocl::KernelArg::PtrReadOnly(parvo),
+ ocl::KernelArg::PtrReadOnly(magno),
+ (int)parvo.cols, (int)parvo.rows, (int)halfCols,
+ (int)halfRows, (int)elements_per_row, (float)minDistance);
+ kernel.run(sizeOfArray(globalSize), globalSize, localSize, false);
}
+} /* namespace ocl */
} /* namespace bioinspired */
} /* namespace cv */
-#endif /* #ifdef HAVE_OPENCV_OCL */
+#endif /* #ifdef HAVE_OPENCL */
diff --git a/contrib/modules/bioinspired/src/retina_ocl.hpp b/contrib/modules/bioinspired/src/retina_ocl.hpp
index 11da48b..777e670 100644
--- a/contrib/modules/bioinspired/src/retina_ocl.hpp
+++ b/contrib/modules/bioinspired/src/retina_ocl.hpp
@@ -47,8 +47,9 @@
#define __OCL_RETINA_HPP__
#include "precomp.hpp"
+#include "opencv2/bioinspired/retina.hpp"
-#ifdef HAVE_OPENCV_OCL
+#ifdef HAVE_OPENCL
// please refer to c++ headers for API comments
namespace cv
@@ -57,10 +58,10 @@ namespace bioinspired
{
namespace ocl
{
-void normalizeGrayOutputCentredSigmoide(const float meanValue, const float sensitivity, cv::ocl::oclMat &in, cv::ocl::oclMat &out, const float maxValue = 255.f);
-void normalizeGrayOutput_0_maxOutputValue(cv::ocl::oclMat &inputOutputBuffer, const float maxOutputValue = 255.0);
-void normalizeGrayOutputNearZeroCentreredSigmoide(cv::ocl::oclMat &inputPicture, cv::ocl::oclMat &outputBuffer, const float sensitivity = 40, const float maxOutputValue = 255.0f);
-void centerReductImageLuminance(cv::ocl::oclMat &inputOutputBuffer);
+void normalizeGrayOutputCentredSigmoide(const float meanValue, const float sensitivity, UMat &in, UMat &out, const float maxValue = 255.f);
+void normalizeGrayOutput_0_maxOutputValue(UMat &inputOutputBuffer, const float maxOutputValue = 255.0);
+void normalizeGrayOutputNearZeroCentreredSigmoide(UMat &inputPicture, UMat &outputBuffer, const float sensitivity = 40, const float maxOutputValue = 255.0f);
+void centerReductImageLuminance(UMat &inputOutputBuffer);
class BasicRetinaFilter
{
@@ -81,13 +82,13 @@ public:
clearSecondaryBuffer();
}
void resize(const unsigned int NBrows, const unsigned int NBcolumns);
- const cv::ocl::oclMat &runFilter_LPfilter(const cv::ocl::oclMat &inputFrame, const unsigned int filterIndex = 0);
- void runFilter_LPfilter(const cv::ocl::oclMat &inputFrame, cv::ocl::oclMat &outputFrame, const unsigned int filterIndex = 0);
- void runFilter_LPfilter_Autonomous(cv::ocl::oclMat &inputOutputFrame, const unsigned int filterIndex = 0);
- const cv::ocl::oclMat &runFilter_LocalAdapdation(const cv::ocl::oclMat &inputOutputFrame, const cv::ocl::oclMat &localLuminance);
- void runFilter_LocalAdapdation(const cv::ocl::oclMat &inputFrame, const cv::ocl::oclMat &localLuminance, cv::ocl::oclMat &outputFrame);
- const cv::ocl::oclMat &runFilter_LocalAdapdation_autonomous(const cv::ocl::oclMat &inputFrame);
- void runFilter_LocalAdapdation_autonomous(const cv::ocl::oclMat &inputFrame, cv::ocl::oclMat &outputFrame);
+ const UMat &runFilter_LPfilter(const UMat &inputFrame, const unsigned int filterIndex = 0);
+ void runFilter_LPfilter(const UMat &inputFrame, UMat &outputFrame, const unsigned int filterIndex = 0);
+ void runFilter_LPfilter_Autonomous(UMat &inputOutputFrame, const unsigned int filterIndex = 0);
+ const UMat &runFilter_LocalAdapdation(const UMat &inputOutputFrame, const UMat &localLuminance);
+ void runFilter_LocalAdapdation(const UMat &inputFrame, const UMat &localLuminance, UMat &outputFrame);
+ const UMat &runFilter_LocalAdapdation_autonomous(const UMat &inputFrame);
+ void runFilter_LocalAdapdation_autonomous(const UMat &inputFrame, UMat &outputFrame);
void setLPfilterParameters(const float beta, const float tau, const float k, const unsigned int filterIndex = 0);
inline void setV0CompressionParameter(const float v0, const float maxInputValue, const float)
{
@@ -122,7 +123,7 @@ public:
{
return _v0 / _maxInputValue;
}
- inline const cv::ocl::oclMat &getOutput() const
+ inline const UMat &getOutput() const
{
return _filterOutput;
}
@@ -166,8 +167,8 @@ protected:
unsigned int _halfNBrows;
unsigned int _halfNBcolumns;
- cv::ocl::oclMat _filterOutput;
- cv::ocl::oclMat _localBuffer;
+ UMat _filterOutput;
+ UMat _localBuffer;
std::valarray <float>_filteringCoeficientsTable;
float _v0;
@@ -180,19 +181,19 @@ protected:
float _tau;
float _gain;
- void _spatiotemporalLPfilter(const cv::ocl::oclMat &inputFrame, cv::ocl::oclMat &LPfilterOutput, const unsigned int coefTableOffset = 0);
- float _squaringSpatiotemporalLPfilter(const cv::ocl::oclMat &inputFrame, cv::ocl::oclMat &outputFrame, const unsigned int filterIndex = 0);
- void _spatiotemporalLPfilter_Irregular(const cv::ocl::oclMat &inputFrame, cv::ocl::oclMat &outputFrame, const unsigned int filterIndex = 0);
- void _localSquaringSpatioTemporalLPfilter(const cv::ocl::oclMat &inputFrame, cv::ocl::oclMat &LPfilterOutput, const unsigned int *integrationAreas, const unsigned int filterIndex = 0);
- void _localLuminanceAdaptation(const cv::ocl::oclMat &inputFrame, const cv::ocl::oclMat &localLuminance, cv::ocl::oclMat &outputFrame, const bool updateLuminanceMean = true);
- void _localLuminanceAdaptation(cv::ocl::oclMat &inputOutputFrame, const cv::ocl::oclMat &localLuminance);
- void _localLuminanceAdaptationPosNegValues(const cv::ocl::oclMat &inputFrame, const cv::ocl::oclMat &localLuminance, float *outputFrame);
- void _horizontalCausalFilter_addInput(const cv::ocl::oclMat &inputFrame, cv::ocl::oclMat &outputFrame);
- void _horizontalAnticausalFilter(cv::ocl::oclMat &outputFrame);
- void _verticalCausalFilter(cv::ocl::oclMat &outputFrame);
- void _horizontalAnticausalFilter_Irregular(cv::ocl::oclMat &outputFrame, const cv::ocl::oclMat &spatialConstantBuffer);
- void _verticalCausalFilter_Irregular(cv::ocl::oclMat &outputFrame, const cv::ocl::oclMat &spatialConstantBuffer);
- void _verticalAnticausalFilter_multGain(cv::ocl::oclMat &outputFrame);
+ void _spatiotemporalLPfilter(const UMat &inputFrame, UMat &LPfilterOutput, const unsigned int coefTableOffset = 0);
+ void _spatiotemporalLPfilter_h(const UMat &inputFrame, UMat &LPfilterOutput, const unsigned int coefTableOffset = 0);
+ void _spatiotemporalLPfilter_v(UMat &LPfilterOutput, const unsigned int multichannel = 0);
+ float _squaringSpatiotemporalLPfilter(const UMat &inputFrame, UMat &outputFrame, const unsigned int filterIndex = 0);
+ void _spatiotemporalLPfilter_Irregular(const UMat &inputFrame, UMat &outputFrame, const unsigned int filterIndex = 0);
+ void _localSquaringSpatioTemporalLPfilter(const UMat &inputFrame, UMat &LPfilterOutput, const unsigned int *integrationAreas, const unsigned int filterIndex = 0);
+ void _localLuminanceAdaptation(const UMat &inputFrame, const UMat &localLuminance, UMat &outputFrame, const bool updateLuminanceMean = true);
+ void _localLuminanceAdaptation(UMat &inputOutputFrame, const UMat &localLuminance);
+ void _localLuminanceAdaptationPosNegValues(const UMat &inputFrame, const UMat &localLuminance, float *outputFrame);
+ void _horizontalCausalFilter_addInput(const UMat &inputFrame, UMat &outputFrame);
+ void _verticalCausalFilter(UMat &outputFrame);
+ void _verticalCausalFilter_multichannel(UMat &outputFrame);
+ void _verticalCausalFilter_Irregular(UMat &outputFrame, const UMat &spatialConstantBuffer);
};
class MagnoRetinaFilter: public BasicRetinaFilter
@@ -204,17 +205,17 @@ public:
void resize(const unsigned int NBrows, const unsigned int NBcolumns);
void setCoefficientsTable(const float parasolCells_beta, const float parasolCells_tau, const float parasolCells_k, const float amacrinCellsTemporalCutFrequency, const float localAdaptIntegration_tau, const float localAdaptIntegration_k);
- const cv::ocl::oclMat &runFilter(const cv::ocl::oclMat &OPL_ON, const cv::ocl::oclMat &OPL_OFF);
+ const UMat &runFilter(const UMat &OPL_ON, const UMat &OPL_OFF);
- inline const cv::ocl::oclMat &getMagnoON() const
+ inline const UMat &getMagnoON() const
{
return _magnoXOutputON;
}
- inline const cv::ocl::oclMat &getMagnoOFF() const
+ inline const UMat &getMagnoOFF() const
{
return _magnoXOutputOFF;
}
- inline const cv::ocl::oclMat &getMagnoYsaturated() const
+ inline const UMat &getMagnoYsaturated() const
{
return _magnoYsaturated;
}
@@ -227,19 +228,19 @@ public:
return this->_filteringCoeficientsTable[2];
}
private:
- cv::ocl::oclMat _previousInput_ON;
- cv::ocl::oclMat _previousInput_OFF;
- cv::ocl::oclMat _amacrinCellsTempOutput_ON;
- cv::ocl::oclMat _amacrinCellsTempOutput_OFF;
- cv::ocl::oclMat _magnoXOutputON;
- cv::ocl::oclMat _magnoXOutputOFF;
- cv::ocl::oclMat _localProcessBufferON;
- cv::ocl::oclMat _localProcessBufferOFF;
- cv::ocl::oclMat _magnoYOutput;
- cv::ocl::oclMat _magnoYsaturated;
+ UMat _previousInput_ON;
+ UMat _previousInput_OFF;
+ UMat _amacrinCellsTempOutput_ON;
+ UMat _amacrinCellsTempOutput_OFF;
+ UMat _magnoXOutputON;
+ UMat _magnoXOutputOFF;
+ UMat _localProcessBufferON;
+ UMat _localProcessBufferOFF;
+ UMat _magnoYOutput;
+ UMat _magnoYsaturated;
float _temporalCoefficient;
- void _amacrineCellsComputing(const cv::ocl::oclMat &OPL_ON, const cv::ocl::oclMat &OPL_OFF);
+ void _amacrineCellsComputing(const UMat &OPL_ON, const UMat &OPL_OFF);
};
class ParvoRetinaFilter: public BasicRetinaFilter
@@ -255,34 +256,34 @@ public:
{
BasicRetinaFilter::setLPfilterParameters(0, tau, k, 2);
}
- const cv::ocl::oclMat &runFilter(const cv::ocl::oclMat &inputFrame, const bool useParvoOutput = true);
+ const UMat &runFilter(const UMat &inputFrame, const bool useParvoOutput = true);
- inline const cv::ocl::oclMat &getPhotoreceptorsLPfilteringOutput() const
+ inline const UMat &getPhotoreceptorsLPfilteringOutput() const
{
return _photoreceptorsOutput;
}
- inline const cv::ocl::oclMat &getHorizontalCellsOutput() const
+ inline const UMat &getHorizontalCellsOutput() const
{
return _horizontalCellsOutput;
}
- inline const cv::ocl::oclMat &getParvoON() const
+ inline const UMat &getParvoON() const
{
return _parvocellularOutputON;
}
- inline const cv::ocl::oclMat &getParvoOFF() const
+ inline const UMat &getParvoOFF() const
{
return _parvocellularOutputOFF;
}
- inline const cv::ocl::oclMat &getBipolarCellsON() const
+ inline const UMat &getBipolarCellsON() const
{
return _bipolarCellsOutputON;
}
- inline const cv::ocl::oclMat &getBipolarCellsOFF() const
+ inline const UMat &getBipolarCellsOFF() const
{
return _bipolarCellsOutputOFF;
}
@@ -297,15 +298,15 @@ public:
return this->_filteringCoeficientsTable[5];
}
private:
- cv::ocl::oclMat _photoreceptorsOutput;
- cv::ocl::oclMat _horizontalCellsOutput;
- cv::ocl::oclMat _parvocellularOutputON;
- cv::ocl::oclMat _parvocellularOutputOFF;
- cv::ocl::oclMat _bipolarCellsOutputON;
- cv::ocl::oclMat _bipolarCellsOutputOFF;
- cv::ocl::oclMat _localAdaptationOFF;
- cv::ocl::oclMat _localAdaptationON;
- cv::ocl::oclMat _parvocellularOutputONminusOFF;
+ UMat _photoreceptorsOutput;
+ UMat _horizontalCellsOutput;
+ UMat _parvocellularOutputON;
+ UMat _parvocellularOutputOFF;
+ UMat _bipolarCellsOutputON;
+ UMat _bipolarCellsOutputOFF;
+ UMat _localAdaptationOFF;
+ UMat _localAdaptationON;
+ UMat _parvocellularOutputONminusOFF;
void _OPL_OnOffWaysComputing();
};
class RetinaColor: public BasicRetinaFilter
@@ -316,12 +317,12 @@ public:
void clearAllBuffers();
void resize(const unsigned int NBrows, const unsigned int NBcolumns);
- inline void runColorMultiplexing(const cv::ocl::oclMat &inputRGBFrame)
+ inline void runColorMultiplexing(const UMat &inputRGBFrame)
{
runColorMultiplexing(inputRGBFrame, _multiplexedFrame);
}
- void runColorMultiplexing(const cv::ocl::oclMat &demultiplexedInputFrame, cv::ocl::oclMat &multiplexedFrame);
- void runColorDemultiplexing(const cv::ocl::oclMat &multiplexedColorFrame, const bool adaptiveFiltering = false, const float maxInputValue = 255.0);
+ void runColorMultiplexing(const UMat &demultiplexedInputFrame, UMat &multiplexedFrame);
+ void runColorDemultiplexing(const UMat &multiplexedColorFrame, const bool adaptiveFiltering = false, const float maxInputValue = 255.0);
void setColorSaturation(const bool saturateColors = true, const float colorSaturationValue = 4.0)
{
@@ -334,29 +335,29 @@ public:
setLPfilterParameters(beta, tau, k);
}
- bool applyKrauskopfLMS2Acr1cr2Transform(cv::ocl::oclMat &result);
- bool applyLMS2LabTransform(cv::ocl::oclMat &result);
- inline const cv::ocl::oclMat &getMultiplexedFrame() const
+ bool applyKrauskopfLMS2Acr1cr2Transform(UMat &result);
+ bool applyLMS2LabTransform(UMat &result);
+ inline const UMat &getMultiplexedFrame() const
{
return _multiplexedFrame;
}
- inline const cv::ocl::oclMat &getDemultiplexedColorFrame() const
+ inline const UMat &getDemultiplexedColorFrame() const
{
return _demultiplexedColorFrame;
}
- inline const cv::ocl::oclMat &getLuminance() const
+ inline const UMat &getLuminance() const
{
return _luminance;
}
- inline const cv::ocl::oclMat &getChrominance() const
+ inline const UMat &getChrominance() const
{
return _chrominance;
}
- void clipRGBOutput_0_maxInputValue(cv::ocl::oclMat &inputOutputBuffer, const float maxOutputValue = 255.0);
+ void clipRGBOutput_0_maxInputValue(UMat &inputOutputBuffer, const float maxOutputValue = 255.0);
void normalizeRGBOutput_0_maxOutputValue(const float maxOutputValue = 255.0);
- inline void setDemultiplexedColorFrame(const cv::ocl::oclMat &demultiplexedImage)
+ inline void setDemultiplexedColorFrame(const UMat &demultiplexedImage)
{
_demultiplexedColorFrame = demultiplexedImage;
}
@@ -372,26 +373,26 @@ protected:
int _samplingMethod;
bool _saturateColors;
float _colorSaturationValue;
- cv::ocl::oclMat _luminance;
- cv::ocl::oclMat _multiplexedFrame;
- cv::ocl::oclMat _RGBmosaic;
- cv::ocl::oclMat _tempMultiplexedFrame;
- cv::ocl::oclMat _demultiplexedTempBuffer;
- cv::ocl::oclMat _demultiplexedColorFrame;
- cv::ocl::oclMat _chrominance;
- cv::ocl::oclMat _colorLocalDensity;
- cv::ocl::oclMat _imageGradient;
+ UMat _luminance;
+ UMat _multiplexedFrame;
+ UMat _RGBmosaic;
+ UMat _tempMultiplexedFrame;
+ UMat _demultiplexedTempBuffer;
+ UMat _demultiplexedColorFrame;
+ UMat _chrominance;
+ UMat _colorLocalDensity;
+ UMat _imageGradient;
float _pR, _pG, _pB;
bool _objectInit;
void _initColorSampling();
- void _adaptiveSpatialLPfilter(const cv::ocl::oclMat &inputFrame, const cv::ocl::oclMat &gradient, cv::ocl::oclMat &outputFrame);
- void _adaptiveHorizontalCausalFilter_addInput(const cv::ocl::oclMat &inputFrame, const cv::ocl::oclMat &gradient, cv::ocl::oclMat &outputFrame);
- void _adaptiveVerticalAnticausalFilter_multGain(const cv::ocl::oclMat &gradient, cv::ocl::oclMat &outputFrame);
- void _computeGradient(const cv::ocl::oclMat &luminance, cv::ocl::oclMat &gradient);
+ void _adaptiveSpatialLPfilter_h(const UMat &inputFrame, const UMat &gradient, UMat &outputFrame);
+ void _adaptiveSpatialLPfilter_v(const UMat &gradient, UMat &outputFrame);
+ void _adaptiveHorizontalCausalFilter_addInput(const UMat &inputFrame, const UMat &gradient, UMat &outputFrame);
+ void _computeGradient(const UMat &luminance, UMat &gradient);
void _normalizeOutputs_0_maxOutputValue(void);
- void _applyImageColorSpaceConversion(const cv::ocl::oclMat &inputFrame, cv::ocl::oclMat &outputFrame, const float *transformTable);
+ void _applyImageColorSpaceConversion(const UMat &inputFrame, UMat &outputFrame, const float *transformTable);
};
class RetinaFilter
{
@@ -401,8 +402,8 @@ public:
void clearAllBuffers();
void resize(const unsigned int NBrows, const unsigned int NBcolumns);
- bool checkInput(const cv::ocl::oclMat &input, const bool colorMode);
- bool runFilter(const cv::ocl::oclMat &imageInput, const bool useAdaptiveFiltering = true, const bool processRetinaParvoMagnoMapping = false, const bool useColorMode = false, const bool inputIsColorMultiplexed = false);
+ bool checkInput(const UMat &input, const bool colorMode);
+ bool runFilter(const UMat &imageInput, const bool useAdaptiveFiltering = true, const bool processRetinaParvoMagnoMapping = false, const bool useColorMode = false, const bool inputIsColorMultiplexed = false);
void setGlobalParameters(const float OPLspatialResponse1 = 0.7, const float OPLtemporalresponse1 = 1, const float OPLassymetryGain = 0, const float OPLspatialResponse2 = 5, const float OPLtemporalresponse2 = 1, const float LPfilterSpatialResponse = 5, const float LPfilterGain = 0, const float LPfilterTemporalresponse = 0, const float MovingContoursExtractorCoefficient = 5, const bool normalizeParvoOutput_0_maxOutputValue = false, const bool normalizeMagnoOutput_0_maxOutputValue = fal [...]
@@ -467,16 +468,16 @@ public:
{
_colorEngine.setColorSaturation(saturateColors, colorSaturationValue);
}
- inline const cv::ocl::oclMat &getLocalAdaptation() const
+ inline const UMat &getLocalAdaptation() const
{
return _photoreceptorsPrefilter.getOutput();
}
- inline const cv::ocl::oclMat &getPhotoreceptors() const
+ inline const UMat &getPhotoreceptors() const
{
return _ParvoRetinaFilter.getPhotoreceptorsLPfilteringOutput();
}
- inline const cv::ocl::oclMat &getHorizontalCells() const
+ inline const UMat &getHorizontalCells() const
{
return _ParvoRetinaFilter.getHorizontalCellsOutput();
}
@@ -484,20 +485,20 @@ public:
{
return _useParvoOutput;
}
- bool getParvoFoveaResponse(cv::ocl::oclMat &parvoFovealResponse);
+ bool getParvoFoveaResponse(UMat &parvoFovealResponse);
inline void activateContoursProcessing(const bool useParvoOutput)
{
_useParvoOutput = useParvoOutput;
}
- const cv::ocl::oclMat &getContours();
+ const UMat &getContours();
- inline const cv::ocl::oclMat &getContoursON() const
+ inline const UMat &getContoursON() const
{
return _ParvoRetinaFilter.getParvoON();
}
- inline const cv::ocl::oclMat &getContoursOFF() const
+ inline const UMat &getContoursOFF() const
{
return _ParvoRetinaFilter.getParvoOFF();
}
@@ -512,41 +513,41 @@ public:
_useMagnoOutput = useMagnoOutput;
}
- inline const cv::ocl::oclMat &getMovingContours() const
+ inline const UMat &getMovingContours() const
{
return _MagnoRetinaFilter.getOutput();
}
- inline const cv::ocl::oclMat &getMovingContoursSaturated() const
+ inline const UMat &getMovingContoursSaturated() const
{
return _MagnoRetinaFilter.getMagnoYsaturated();
}
- inline const cv::ocl::oclMat &getMovingContoursON() const
+ inline const UMat &getMovingContoursON() const
{
return _MagnoRetinaFilter.getMagnoON();
}
- inline const cv::ocl::oclMat &getMovingContoursOFF() const
+ inline const UMat &getMovingContoursOFF() const
{
return _MagnoRetinaFilter.getMagnoOFF();
}
- inline const cv::ocl::oclMat &getRetinaParvoMagnoMappedOutput() const
+ inline const UMat &getRetinaParvoMagnoMappedOutput() const
{
return _retinaParvoMagnoMappedFrame;
}
- inline const cv::ocl::oclMat &getParvoContoursChannel() const
+ inline const UMat &getParvoContoursChannel() const
{
return _colorEngine.getLuminance();
}
- inline const cv::ocl::oclMat &getParvoChrominance() const
+ inline const UMat &getParvoChrominance() const
{
return _colorEngine.getChrominance();
}
- inline const cv::ocl::oclMat &getColorOutput() const
+ inline const UMat &getColorOutput() const
{
return _colorEngine.getDemultiplexedColorFrame();
}
@@ -609,7 +610,7 @@ private:
unsigned int _ellapsedFramesSinceLastReset;
unsigned int _globalTemporalConstant;
- cv::ocl::oclMat _retinaParvoMagnoMappedFrame;
+ UMat _retinaParvoMagnoMappedFrame;
BasicRetinaFilter _photoreceptorsPrefilter;
ParvoRetinaFilter _ParvoRetinaFilter;
MagnoRetinaFilter _MagnoRetinaFilter;
@@ -623,12 +624,60 @@ private:
void _setInitPeriodCount();
void _processRetinaParvoMagnoMapping();
- void _runGrayToneMapping(const cv::ocl::oclMat &grayImageInput, cv::ocl::oclMat &grayImageOutput , const float PhotoreceptorsCompression = 0.6, const float ganglionCellsCompression = 0.6);
+ void _runGrayToneMapping(const UMat &grayImageInput, UMat &grayImageOutput , const float PhotoreceptorsCompression = 0.6, const float ganglionCellsCompression = 0.6);
+};
+
+class RetinaOCLImpl : public Retina
+{
+public:
+ RetinaOCLImpl(Size getInputSize);
+ RetinaOCLImpl(Size getInputSize, const bool colorMode, int colorSamplingMethod = RETINA_COLOR_BAYER, const bool useRetinaLogSampling = false, const double reductionFactor = 1.0, const double samplingStrenght = 10.0);
+ virtual ~RetinaOCLImpl();
+
+ Size getInputSize();
+ Size getOutputSize();
+
+ void setup(String retinaParameterFile = "", const bool applyDefaultSetupOnFailure = true);
+ void setup(cv::FileStorage &fs, const bool applyDefaultSetupOnFailure = true);
+ void setup(RetinaParameters newParameters);
+
+ RetinaParameters getParameters();
+
+ const String printSetup();
+ virtual void write(String fs) const;
+ virtual void write(FileStorage& fs) const;
+
+ void setupOPLandIPLParvoChannel(const bool colorMode = true, const bool normaliseOutput = true, const float photoreceptorsLocalAdaptationSensitivity = 0.7, const float photoreceptorsTemporalConstant = 0.5, const float photoreceptorsSpatialConstant = 0.53, const float horizontalCellsGain = 0, const float HcellsTemporalConstant = 1, const float HcellsSpatialConstant = 7, const float ganglionCellsSensitivity = 0.7);
+ void setupIPLMagnoChannel(const bool normaliseOutput = true, const float parasolCells_beta = 0, const float parasolCells_tau = 0, const float parasolCells_k = 7, const float amacrinCellsTemporalCutFrequency = 1.2, const float V0CompressionParameter = 0.95, const float localAdaptintegration_tau = 0, const float localAdaptintegration_k = 7);
+
+ void run(InputArray inputImage);
+ void getParvo(OutputArray retinaOutput_parvo);
+ void getMagno(OutputArray retinaOutput_magno);
+
+ void setColorSaturation(const bool saturateColors = true, const float colorSaturationValue = 4.0);
+ void clearBuffers();
+ void activateMovingContoursProcessing(const bool activate);
+ void activateContoursProcessing(const bool activate);
+
+ // unimplemented interfaces:
+ void applyFastToneMapping(InputArray /*inputImage*/, OutputArray /*outputToneMappedImage*/);
+ void getParvoRAW(OutputArray /*retinaOutput_parvo*/);
+ void getMagnoRAW(OutputArray /*retinaOutput_magno*/);
+ const Mat getMagnoRAW() const;
+ const Mat getParvoRAW() const;
+
+protected:
+ RetinaParameters _retinaParameters;
+ UMat _inputBuffer;
+ RetinaFilter* _retinaFilter;
+ bool convertToColorPlanes(const UMat& input, UMat &output);
+ void convertToInterleaved(const UMat& input, bool colorMode, UMat &output);
+ void _init(const Size getInputSize, const bool colorMode, int colorSamplingMethod = RETINA_COLOR_BAYER, const bool useRetinaLogSampling = false, const double reductionFactor = 1.0, const double samplingStrenght = 10.0);
};
} /* namespace ocl */
} /* namespace bioinspired */
} /* namespace cv */
-#endif /* HAVE_OPENCV_OCL */
+#endif /* HAVE_OPENCL */
#endif /* __OCL_RETINA_HPP__ */
diff --git a/contrib/modules/bioinspired/test/test_retina_ocl.cpp b/contrib/modules/bioinspired/test/test_retina_ocl.cpp
index bfccdd5..8f3067e 100644
--- a/contrib/modules/bioinspired/test/test_retina_ocl.cpp
+++ b/contrib/modules/bioinspired/test/test_retina_ocl.cpp
@@ -44,87 +44,39 @@
//M*/
#include "test_precomp.hpp"
-#include "opencv2/opencv_modules.hpp"
-#include "opencv2/bioinspired.hpp"
-#include "opencv2/imgproc.hpp"
-#include "opencv2/highgui.hpp"
+#include "opencv2/ts/ocl_test.hpp"
-#include "opencv2/core/ocl.hpp" // cv::ocl::haveOpenCL
+#ifdef HAVE_OPENCL
-#if defined(HAVE_OPENCV_OCL)
-
-#include "opencv2/ocl.hpp"
#define RETINA_ITERATIONS 5
-static double checkNear(const cv::Mat &m1, const cv::Mat &m2)
-{
- return cv::norm(m1, m2, cv::NORM_INF);
-}
-
-#define PARAM_TEST_CASE(name, ...) struct name : testing::TestWithParam< std::tr1::tuple< __VA_ARGS__ > >
-#define GET_PARAM(k) std::tr1::get< k >(GetParam())
-
-static int oclInit = false;
-static int oclAvailable = false;
+namespace cvtest {
+namespace ocl {
PARAM_TEST_CASE(Retina_OCL, bool, int, bool, double, double)
{
bool colorMode;
int colorSamplingMethod;
bool useLogSampling;
- double reductionFactor;
- double samplingStrength;
+ float reductionFactor;
+ float samplingStrength;
virtual void SetUp()
{
colorMode = GET_PARAM(0);
colorSamplingMethod = GET_PARAM(1);
useLogSampling = GET_PARAM(2);
- reductionFactor = GET_PARAM(3);
- samplingStrength = GET_PARAM(4);
-
- if (!oclInit)
- {
- if (cv::ocl::haveOpenCL())
- {
- try
- {
- const cv::ocl::DeviceInfo& dev = cv::ocl::Context::getContext()->getDeviceInfo();
- std::cout << "Device name:" << dev.deviceName << std::endl;
- oclAvailable = true;
- }
- catch (...)
- {
- std::cout << "Device name: N/A" << std::endl;
- }
- }
- oclInit = true;
- }
+ reductionFactor = static_cast<float>(GET_PARAM(3));
+ samplingStrength = static_cast<float>(GET_PARAM(4));
}
};
-TEST_P(Retina_OCL, Accuracy)
+OCL_TEST_P(Retina_OCL, Accuracy)
{
- if (!oclAvailable)
- {
- std::cout << "SKIP test" << std::endl;
- return;
- }
-
- using namespace cv;
Mat input = imread(cvtest::TS::ptr()->get_data_path() + "shared/lena.png", colorMode);
CV_Assert(!input.empty());
- ocl::oclMat ocl_input(input);
-
- Ptr<bioinspired::Retina> ocl_retina = bioinspired::createRetina_OCL(
- input.size(),
- colorMode,
- colorSamplingMethod,
- useLogSampling,
- reductionFactor,
- samplingStrength);
- Ptr<bioinspired::Retina> gold_retina = bioinspired::createRetina(
+ Ptr<bioinspired::Retina> retina = bioinspired::createRetina(
input.size(),
colorMode,
colorSamplingMethod,
@@ -134,31 +86,35 @@ TEST_P(Retina_OCL, Accuracy)
Mat gold_parvo;
Mat gold_magno;
- ocl::oclMat ocl_parvo;
- ocl::oclMat ocl_magno;
+ UMat ocl_parvo;
+ UMat ocl_magno;
for(int i = 0; i < RETINA_ITERATIONS; i ++)
{
- ocl_retina->run(ocl_input);
- gold_retina->run(input);
-
- gold_retina->getParvo(gold_parvo);
- gold_retina->getMagno(gold_magno);
+ OCL_OFF(retina->run(input));
+ OCL_OFF(retina->getParvo(gold_parvo));
+ OCL_OFF(retina->getMagno(gold_magno));
+ OCL_OFF(retina->clearBuffers());
- ocl_retina->getParvo(ocl_parvo);
- ocl_retina->getMagno(ocl_magno);
+ OCL_ON(retina->run(input));
+ OCL_ON(retina->getParvo(ocl_parvo));
+ OCL_ON(retina->getMagno(ocl_magno));
+ OCL_ON(retina->clearBuffers());
- int eps = colorMode ? 2 : 1;
+ int eps = 1;
- EXPECT_LE(checkNear(gold_parvo, (Mat)ocl_parvo), eps);
- EXPECT_LE(checkNear(gold_magno, (Mat)ocl_magno), eps);
+ EXPECT_MAT_NEAR(gold_parvo, ocl_parvo, eps);
+ EXPECT_MAT_NEAR(gold_magno, ocl_magno, eps);
}
}
-INSTANTIATE_TEST_CASE_P(Contrib, Retina_OCL, testing::Combine(
+OCL_INSTANTIATE_TEST_CASE_P(Contrib, Retina_OCL, testing::Combine(
testing::Bool(),
testing::Values((int)cv::bioinspired::RETINA_COLOR_BAYER),
testing::Values(false/*,true*/),
testing::Values(1.0, 0.5),
testing::Values(10.0, 5.0)));
-#endif
+
+} } // namespace cvtest::ocl
+
+#endif // HAVE_OPENCL
diff --git a/contrib/modules/ccalib/CMakeLists.txt b/contrib/modules/ccalib/CMakeLists.txt
index 5700a12..f803322 100644
--- a/contrib/modules/ccalib/CMakeLists.txt
+++ b/contrib/modules/ccalib/CMakeLists.txt
@@ -1,2 +1,2 @@
set(the_description "Custom Calibration Pattern")
-ocv_define_module(ccalib opencv_core opencv_imgproc opencv_calib3d opencv_features2d WRAP python)
+ocv_define_module(ccalib opencv_core opencv_imgproc opencv_calib3d opencv_features2d opencv_highgui WRAP python)
diff --git a/contrib/modules/ccalib/samples/omni_calibration.cpp b/contrib/modules/ccalib/samples/omni_calibration.cpp
index 578a880..594feb5 100644
--- a/contrib/modules/ccalib/samples/omni_calibration.cpp
+++ b/contrib/modules/ccalib/samples/omni_calibration.cpp
@@ -11,31 +11,7 @@
using namespace cv;
using namespace std;
-const char * usage =
-"\n example command line for omnidirectional camera calibration.\n"
-" omni_calibration -w 6 -h 9 -sw 80 -sh 80 imagelist.xml \n"
-" \n"
-" the file imagelist.xml is generated by imagelist_creator as\n"
-"imagelist_creator imagelist.xml *.*";
-
-static void help()
-{
- printf("\n This is a sample for omnidirectional camera calibration.\n"
- "Usage: omni_calibration\n"
- " -w <board_width> # the number of inner corners per one of board dimension\n"
- " -h <board_height> # the number of inner corners per another board dimension\n"
- " [-sw <square_width>] # the width of square in some user-defined units (1 by default)\n"
- " [-sh <square_height>] # the height of square in some user-defined units (1 by default)\n"
- " [-o <out_camera_params>] # the output filename for intrinsic [and extrinsic] parameters\n"
- " [-fs <fix_skew>] # fix skew\n"
- " [-fp ] # fix the principal point at the center\n"
- " input_data # input data - text file with a list of the images of the board, which is generated by imagelist_creator"
- );
- printf("\n %s", usage);
-}
-
-static void calcChessboardCorners(Size boardSize, double square_width, double square_height,
- Mat& corners)
+static void calcChessboardCorners(const Size &boardSize, const Size2d &squareSize, Mat& corners)
{
// corners has type of CV_64FC3
corners.release();
@@ -46,7 +22,7 @@ static void calcChessboardCorners(Size boardSize, double square_width, double sq
{
for (int j = 0; j < boardSize.width; ++j)
{
- ptr[i*boardSize.width + j] = Vec3d(double(j * square_width), double(i * square_height), 0.0);
+ ptr[i*boardSize.width + j] = Vec3d(double(j * squareSize.width), double(i * squareSize.height), 0.0);
}
}
}
@@ -60,6 +36,7 @@ static bool detecChessboardCorners(const vector<string>& list, vector<string>& l
Mat img;
for(int i = 0; i < n_img; ++i)
{
+ cout << list[i] << "... ";
Mat points;
img = imread(list[i], IMREAD_GRAYSCALE);
bool found = findChessboardCorners( img, boardSize, points);
@@ -70,6 +47,7 @@ static bool detecChessboardCorners(const vector<string>& list, vector<string>& l
imagePoints.push_back(points);
list_detected.push_back(list[i]);
}
+ cout << (found ? "FOUND" : "NO") << endl;
}
if (!img.empty())
imageSize = img.size();
@@ -95,8 +73,8 @@ static bool readStringList( const string& filename, vector<string>& l )
}
static void saveCameraParams( const string & filename, int flags, const Mat& cameraMatrix,
- const Mat& distCoeffs, const double xi, const vector<Vec3d>& rvecs, const vector<Vec3d>& tvecs,
- vector<string> detec_list, const Mat& idx, const double rms, const vector<Mat>& imagePoints)
+ const Mat& distCoeffs, const double xi, const vector<Vec3d>& rvecs, const vector<Vec3d>& tvecs,
+ vector<string> detec_list, const Mat& idx, const double rms, const vector<Mat>& imagePoints)
{
FileStorage fs( filename, FileStorage::WRITE );
@@ -152,7 +130,7 @@ static void saveCameraParams( const string & filename, int flags, const Mat& cam
fs << "extrinsic_parameters" << rvec_tvec;
}
- fs << "rms" << rms;
+ fs << "rms" << rms;
if ( !imagePoints.empty() )
{
@@ -169,78 +147,64 @@ static void saveCameraParams( const string & filename, int flags, const Mat& cam
int main(int argc, char** argv)
{
- Size boardSize, imageSize;
- int flags = 0;
- double square_width = 0.0, square_height = 0.0;
- const char* outputFilename = "out_camera_params.xml";
- const char* inputFilename = 0;
- vector<Mat> objectPoints;
- vector<Mat> imagePoints;
-
- if(argc < 2)
+ cv::CommandLineParser parser(argc, argv,
+ "{w||board width}"
+ "{h||board height}"
+ "{sw|1.0|square width}"
+ "{sh|1.0|square height}"
+ "{o|out_camera_params.xml|output file}"
+ "{fs|false|fix skew}"
+ "{fp|false|fix principal point at the center}"
+ "{@input||input file - xml file with a list of the images, created with cpp-example-imagelist_creator tool}"
+ "{help||show help}"
+ );
+ parser.about("This is a sample for omnidirectional camera calibration. Example command line:\n"
+ " omni_calibration -w=6 -h=9 -sw=80 -sh=80 imagelist.xml \n");
+ if (parser.has("help") || !parser.has("w") || !parser.has("h"))
{
- help();
- return 1;
+ parser.printMessage();
+ return 0;
}
- for(int i = 1; i < argc; i++)
+ Size boardSize(parser.get<int>("w"), parser.get<int>("h"));
+ Size2d squareSize(parser.get<double>("sw"), parser.get<double>("sh"));
+ int flags = 0;
+ if (parser.get<bool>("fs"))
+ flags |= omnidir::CALIB_FIX_SKEW;
+ if (parser.get<bool>("fp"))
+ flags |= omnidir::CALIB_FIX_CENTER;
+ const string outputFilename = parser.get<string>("o");
+ const string inputFilename = parser.get<string>(0);
+
+ if (!parser.check())
{
- const char* s = argv[i];
- if( strcmp( s, "-w") == 0)
- {
- if( sscanf( argv[++i], "%u", &boardSize.width ) != 1 || boardSize.width <= 0 )
- return fprintf( stderr, "Invalid board width\n" ), -1;
- }
- else if( strcmp( s, "-h" ) == 0 )
- {
- if( sscanf( argv[++i], "%u", &boardSize.height ) != 1 || boardSize.height <= 0 )
- return fprintf( stderr, "Invalid board height\n" ), -1;
- }
- else if( strcmp( s, "-sw" ) == 0 )
- {
- if( sscanf( argv[++i], "%lf", &square_width ) != 1 || square_width <= 0 )
- return fprintf(stderr, "Invalid square width\n"), -1;
- }
- else if( strcmp( s, "-sh" ) == 0 )
- {
- if( sscanf( argv[++i], "%lf", &square_height) != 1 || square_height <= 0 )
- return fprintf(stderr, "Invalid square height\n"), -1;
- }
- else if( strcmp( s, "-o" ) == 0 )
- {
- outputFilename = argv[++i];
- }
- else if( strcmp( s, "-fs" ) == 0 )
- {
- flags |= omnidir::CALIB_FIX_SKEW;
- }
- else if( strcmp( s, "-fp" ) == 0 )
- {
- flags |= omnidir::CALIB_FIX_CENTER;
- }
- else if( s[0] != '-')
- {
- inputFilename = s;
- }
- else
- {
- return fprintf( stderr, "Unknown option %s\n", s ), -1;
- }
+ parser.printErrors();
+ return -1;
}
// get image name list
vector<string> image_list, detec_list;
if(!readStringList(inputFilename, image_list))
- return fprintf( stderr, "Failed to read image list\n"), -1;
+ {
+ cout << "Can not read imagelist" << endl;
+ return -1;
+ }
// find corners in images
// some images may be failed in automatic corner detection, passed cases are in detec_list
+ cout << "Detecting chessboards (" << image_list.size() << ")" << endl;
+ vector<Mat> imagePoints;
+ Size imageSize;
if(!detecChessboardCorners(image_list, detec_list, imagePoints, boardSize, imageSize))
- return fprintf(stderr, "Not enough corner detected images\n"), -1;
+ {
+ cout << "Not enough corner detected images" << endl;
+ return -1;
+ }
// calculate object coordinates
+ vector<Mat> objectPoints;
Mat object;
- calcChessboardCorners(boardSize, square_width, square_height, object);
+ calcChessboardCorners(boardSize, squareSize, object);
for(int i = 0; i < (int)detec_list.size(); ++i)
objectPoints.push_back(object);
@@ -252,6 +216,7 @@ int main(int argc, char** argv)
TermCriteria criteria(3, 200, 1e-8);
rms = omnidir::calibrate(objectPoints, imagePoints, imageSize, K, xi, D, rvecs, tvecs, flags, criteria, idx);
_xi = xi.at<double>(0);
+ cout << "Saving camera params to " << outputFilename << endl;
saveCameraParams(outputFilename, flags, K, D, _xi,
rvecs, tvecs, detec_list, idx, rms, imagePoints);
}
diff --git a/contrib/modules/ccalib/src/omnidir.cpp b/contrib/modules/ccalib/src/omnidir.cpp
index 177929d..097fbfa 100644
--- a/contrib/modules/ccalib/src/omnidir.cpp
+++ b/contrib/modules/ccalib/src/omnidir.cpp
@@ -1125,7 +1125,7 @@ double cv::omnidir::calibrate(InputArrayOfArrays patternPoints, InputArrayOfArra
double epsilon = 0.01 * std::pow(0.9, (double)iter/10);
cv::omnidir::internal::computeJacobian(_patternPoints, _imagePoints, currentParam, JTJ_inv, JTError, flags, epsilon);
- // Gauss�CNewton
+ // Gauss - Newton
Mat G = alpha_smooth2*JTJ_inv * JTError;
omnidir::internal::fillFixed(G, flags, n);
@@ -1278,7 +1278,7 @@ double cv::omnidir::stereoCalibrate(InputOutputArrayOfArrays objectPoints, Input
cv::omnidir::internal::computeJacobianStereo(_objectPointsFilt, _imagePoints1Filt, _imagePoints2Filt, currentParam,
JTJ_inv, JTError, flags, epsilon);
- // Gauss�CNewton
+ // Gauss - Newton
Mat G = alpha_smooth2*JTJ_inv * JTError;
omnidir::internal::fillFixedStereo(G, flags, n);
diff --git a/contrib/modules/ccalib/tutorials/omnidir_tutorial.markdown b/contrib/modules/ccalib/tutorials/omnidir_tutorial.markdown
index 4460d43..422c2cf 100644
--- a/contrib/modules/ccalib/tutorials/omnidir_tutorial.markdown
+++ b/contrib/modules/ccalib/tutorials/omnidir_tutorial.markdown
@@ -169,7 +169,7 @@ int pointType = omnidir::XYZRGB;
cv::Matx33d KNew(imgSize.width / 3.1415, 0, 0, 0, imgSize.height / 3.1415, 0, 0, 0, 1);
Mat imageRec1, imageRec2, pointCloud;
-cv::omnidir::stereoReconstruct(img1, img2, K1, D1, xi1, K2, D2, xi2, R, T, flag, numDisparities, SADWindowSize, imageRec1, imageRec2, disMap, imgSize, KNew, pointCloud);
+cv::omnidir::stereoReconstruct(img1, img2, K1, D1, xi1, K2, D2, xi2, R, T, flag, numDisparities, SADWindowSize, disMap, imageRec1, imageRec2, imgSize, KNew, pointCloud);
```
Here variable ```flag``` indicates the recectify type, only ```RECTIFY_LONGLATI```(recommend) and ```RECTIFY_PERSPECTIVE``` make sense. ```numDisparities``` is the max disparity value and ```SADWindowSize``` is the window size of ```cv::StereoSGBM```. ```pointType``` is a flag to define the type of point cloud, ```omnidir::XYZRGB``` each point is a 6-dimensional vector, the first three elements are xyz coordinate, the last three elements are rgb color information. Another type ```omnidir [...]
diff --git a/contrib/modules/contrib_world/CMakeLists.txt b/contrib/modules/contrib_world/CMakeLists.txt
index 17e4bba..d288548 100644
--- a/contrib/modules/contrib_world/CMakeLists.txt
+++ b/contrib/modules/contrib_world/CMakeLists.txt
@@ -11,7 +11,6 @@ set(OPENCV_MODULE_CHILDREN
ccalib
cvv
datasets
- dnn
dpm
face
fuzzy
diff --git a/contrib/modules/datasets/CMakeLists.txt b/contrib/modules/datasets/CMakeLists.txt
index 47afccb..621e160 100644
--- a/contrib/modules/datasets/CMakeLists.txt
+++ b/contrib/modules/datasets/CMakeLists.txt
@@ -1,4 +1,4 @@
set(the_description "datasets framework")
-ocv_define_module(datasets opencv_core opencv_face opencv_ml opencv_flann opencv_text WRAP python)
+ocv_define_module(datasets opencv_core opencv_imgcodecs opencv_ml opencv_flann opencv_text WRAP python)
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4267) # flann, Win64
diff --git a/contrib/modules/datasets/samples/fr_lfw_benchmark.cpp b/contrib/modules/datasets/samples/fr_lfw_benchmark.cpp
index 7ec939e..07079c2 100644
--- a/contrib/modules/datasets/samples/fr_lfw_benchmark.cpp
+++ b/contrib/modules/datasets/samples/fr_lfw_benchmark.cpp
@@ -41,38 +41,17 @@
#include "opencv2/core.hpp"
#include "opencv2/imgcodecs.hpp"
-
-#include "opencv2/face.hpp"
#include "opencv2/datasets/fr_lfw.hpp"
#include <iostream>
-
#include <cstdio>
-
#include <string>
#include <vector>
-#include <map>
using namespace std;
using namespace cv;
using namespace cv::datasets;
-using namespace cv::face;
-map<string, int> people;
-
-int getLabel(const string &imagePath);
-int getLabel(const string &imagePath)
-{
- size_t pos = imagePath.find('/');
- string curr = imagePath.substr(0, pos);
- map<string, int>::iterator it = people.find(curr);
- if (people.end() == it)
- {
- people.insert(make_pair(curr, (int)people.size()));
- it = people.find(curr);
- }
- return (*it).second;
-}
int main(int argc, const char *argv[])
{
@@ -90,9 +69,8 @@ int main(int argc, const char *argv[])
}
string trainMethod(parser.get<string>("train"));
- // These vectors hold the images and corresponding labels.
- vector<Mat> images;
- vector<int> labels;
+ // our trained threshold for "same":
+ double threshold = 0;
// load dataset
Ptr<FR_lfw> dataset = FR_lfw::create();
@@ -106,33 +84,26 @@ int main(int argc, const char *argv[])
printf("train size: %u\n", (numSplits-1) * (unsigned int)dataset->getTest().size());
printf("test size: %u\n", (unsigned int)dataset->getTest().size());
- // 2200 pairsDevTrain, first split: correct: 373, from: 600 -> 62.1667%
- Ptr<FaceRecognizer> model = createLBPHFaceRecognizer();
- // 2200 pairsDevTrain, first split: correct: correct: 369, from: 600 -> 61.5%
- //Ptr<FaceRecognizer> model = createEigenFaceRecognizer();
- // 2200 pairsDevTrain, first split: correct: 372, from: 600 -> 62%
- //Ptr<FaceRecognizer> model = createFisherFaceRecognizer();
if (trainMethod == "dev") // train on personsDevTrain.txt
{
+ // collect average same-distances:
+ double avg = 0;
+ int count = 0;
for (unsigned int i=0; i<dataset->getTrain().size(); ++i)
{
FR_lfwObj *example = static_cast<FR_lfwObj *>(dataset->getTrain()[i].get());
- int currNum = getLabel(example->image1);
- Mat img = imread(path+example->image1, IMREAD_GRAYSCALE);
- images.push_back(img);
- labels.push_back(currNum);
-
- currNum = getLabel(example->image2);
- img = imread(path+example->image2, IMREAD_GRAYSCALE);
- images.push_back(img);
- labels.push_back(currNum);
+ Mat a = imread(path+example->image1, IMREAD_GRAYSCALE);
+ Mat b = imread(path+example->image2, IMREAD_GRAYSCALE);
+ double dist = norm(a,b);
+ if (example->same)
+ {
+ avg += dist;
+ count ++;
+ }
}
- model->train(images, labels);
- //string saveModelPath = "face-rec-model.txt";
- //cout << "Saving the trained model to " << saveModelPath << endl;
- //model->save(saveModelPath);
+ threshold = avg / count;
}
vector<double> p;
@@ -140,8 +111,8 @@ int main(int argc, const char *argv[])
{
if (trainMethod == "split") // train on the remaining 9 splits from pairs.txt
{
- images.clear();
- labels.clear();
+ double avg = 0;
+ int count = 0;
for (unsigned int j2=0; j2<numSplits; ++j2)
{
if (j==j2) continue; // skip test split for training
@@ -150,19 +121,17 @@ int main(int argc, const char *argv[])
for (unsigned int i=0; i<curr.size(); ++i)
{
FR_lfwObj *example = static_cast<FR_lfwObj *>(curr[i].get());
-
- int currNum = getLabel(example->image1);
- Mat img = imread(path+example->image1, IMREAD_GRAYSCALE);
- images.push_back(img);
- labels.push_back(currNum);
-
- currNum = getLabel(example->image2);
- img = imread(path+example->image2, IMREAD_GRAYSCALE);
- images.push_back(img);
- labels.push_back(currNum);
+ Mat a = imread(path+example->image1, IMREAD_GRAYSCALE);
+ Mat b = imread(path+example->image2, IMREAD_GRAYSCALE);
+ double dist = norm(a,b);
+ if (example->same)
+ {
+ avg += dist;
+ count ++;
+ }
}
}
- model->train(images, labels);
+ threshold = avg / count;
}
unsigned int incorrect = 0, correct = 0;
@@ -171,26 +140,18 @@ int main(int argc, const char *argv[])
{
FR_lfwObj *example = static_cast<FR_lfwObj *>(curr[i].get());
- //int currNum = getLabel(example->image1);
- Mat img = imread(path+example->image1, IMREAD_GRAYSCALE);
- int predictedLabel1 = model->predict(img);
-
- //currNum = getLabel(example->image2);
- img = imread(path+example->image2, IMREAD_GRAYSCALE);
- int predictedLabel2 = model->predict(img);
-
- if ((predictedLabel1 == predictedLabel2 && example->same) ||
- (predictedLabel1 != predictedLabel2 && !example->same))
- {
+ Mat a = imread(path+example->image1, IMREAD_GRAYSCALE);
+ Mat b = imread(path+example->image2, IMREAD_GRAYSCALE);
+ bool same = (norm(a,b) <= threshold);
+ if (same == example->same)
correct++;
- } else
- {
+ else
incorrect++;
- }
}
p.push_back(1.0*correct/(correct+incorrect));
printf("correct: %u, from: %u -> %f\n", correct, correct+incorrect, p.back());
}
+
double mu = 0.0;
for (vector<double>::iterator it=p.begin(); it!=p.end(); ++it)
{
diff --git a/contrib/modules/datasets/src/or_pascal.cpp b/contrib/modules/datasets/src/or_pascal.cpp
index 9afdf1d..a20fa44 100644
--- a/contrib/modules/datasets/src/or_pascal.cpp
+++ b/contrib/modules/datasets/src/or_pascal.cpp
@@ -41,7 +41,7 @@
#include "opencv2/datasets/or_pascal.hpp"
#include "opencv2/datasets/util.hpp"
-#include <opencv2/datasets/tinyxml2/tinyxml2.h>
+#include "tinyxml2/tinyxml2.h"
#include <fstream>
namespace cv
diff --git a/contrib/modules/datasets/src/tinyxml2/tinyxml2.cpp b/contrib/modules/datasets/src/tinyxml2/tinyxml2.cpp
index 8151969..47a1a0a 100755
--- a/contrib/modules/datasets/src/tinyxml2/tinyxml2.cpp
+++ b/contrib/modules/datasets/src/tinyxml2/tinyxml2.cpp
@@ -21,7 +21,7 @@ must not be misrepresented as being the original software.
distribution.
*/
-#include "opencv2/datasets/tinyxml2/tinyxml2.h"
+#include "tinyxml2/tinyxml2.h"
#include <new> // yes, this one new style header, is in the Android SDK.
# ifdef ANDROID_NDK
@@ -593,7 +593,7 @@ XMLNode::~XMLNode()
}
}
-const char* XMLNode::Value() const
+const char* XMLNode::Value() const
{
return _value.GetStr();
}
@@ -1063,12 +1063,12 @@ bool XMLUnknown::Accept( XMLVisitor* visitor ) const
// --------- XMLAttribute ---------- //
-const char* XMLAttribute::Name() const
+const char* XMLAttribute::Name() const
{
return _name.GetStr();
}
-const char* XMLAttribute::Value() const
+const char* XMLAttribute::Value() const
{
return _value.GetStr();
}
@@ -1271,7 +1271,7 @@ void XMLElement::SetText( const char* inText )
}
-void XMLElement::SetText( int v )
+void XMLElement::SetText( int v )
{
char buf[BUF_SIZE];
XMLUtil::ToStr( v, buf, BUF_SIZE );
@@ -1279,7 +1279,7 @@ void XMLElement::SetText( int v )
}
-void XMLElement::SetText( unsigned v )
+void XMLElement::SetText( unsigned v )
{
char buf[BUF_SIZE];
XMLUtil::ToStr( v, buf, BUF_SIZE );
@@ -1287,7 +1287,7 @@ void XMLElement::SetText( unsigned v )
}
-void XMLElement::SetText( bool v )
+void XMLElement::SetText( bool v )
{
char buf[BUF_SIZE];
XMLUtil::ToStr( v, buf, BUF_SIZE );
@@ -1295,7 +1295,7 @@ void XMLElement::SetText( bool v )
}
-void XMLElement::SetText( float v )
+void XMLElement::SetText( float v )
{
char buf[BUF_SIZE];
XMLUtil::ToStr( v, buf, BUF_SIZE );
@@ -1303,7 +1303,7 @@ void XMLElement::SetText( float v )
}
-void XMLElement::SetText( double v )
+void XMLElement::SetText( double v )
{
char buf[BUF_SIZE];
XMLUtil::ToStr( v, buf, BUF_SIZE );
@@ -2201,4 +2201,3 @@ bool XMLPrinter::Visit( const XMLUnknown& unknown )
}
} // namespace tinyxml2
-
diff --git a/contrib/modules/datasets/include/opencv2/datasets/tinyxml2/tinyxml2.h b/contrib/modules/datasets/src/tinyxml2/tinyxml2.h
similarity index 100%
rename from contrib/modules/datasets/include/opencv2/datasets/tinyxml2/tinyxml2.h
rename to contrib/modules/datasets/src/tinyxml2/tinyxml2.h
diff --git a/contrib/modules/datasets/src/tr_svt.cpp b/contrib/modules/datasets/src/tr_svt.cpp
index af853d4..6d7d5a8 100644
--- a/contrib/modules/datasets/src/tr_svt.cpp
+++ b/contrib/modules/datasets/src/tr_svt.cpp
@@ -42,7 +42,7 @@
#include "opencv2/datasets/tr_svt.hpp"
#include "opencv2/datasets/util.hpp"
-#include <opencv2/datasets/tinyxml2/tinyxml2.h>
+#include "tinyxml2/tinyxml2.h"
namespace cv
{
diff --git a/contrib/modules/datasets/src/track_alov.cpp b/contrib/modules/datasets/src/track_alov.cpp
index 0cdd521..4fee54c 100644
--- a/contrib/modules/datasets/src/track_alov.cpp
+++ b/contrib/modules/datasets/src/track_alov.cpp
@@ -43,7 +43,7 @@
#include <sys/stat.h>
#include <opencv2/core.hpp>
-#include <opencv2/highgui.hpp>
+#include "opencv2/imgcodecs.hpp"
using namespace std;
diff --git a/contrib/modules/datasets/src/track_vot.cpp b/contrib/modules/datasets/src/track_vot.cpp
index 64e32f2..1c5ba9e 100644
--- a/contrib/modules/datasets/src/track_vot.cpp
+++ b/contrib/modules/datasets/src/track_vot.cpp
@@ -43,7 +43,7 @@
#include <sys/stat.h>
#include <opencv2/core.hpp>
-#include <opencv2/highgui.hpp>
+#include "opencv2/imgcodecs.hpp"
using namespace std;
diff --git a/contrib/modules/dnn/3rdparty/protobuf/CMakeLists.txt b/contrib/modules/dnn/3rdparty/protobuf/CMakeLists.txt
deleted file mode 100644
index 9c4a9ed..0000000
--- a/contrib/modules/dnn/3rdparty/protobuf/CMakeLists.txt
+++ /dev/null
@@ -1,151 +0,0 @@
-project(libprotobuf)
-
-include(CheckIncludeFiles)
-
-if(NOT MSVC)
- check_include_files("pthread.h" HAVE_PTHREAD)
- if(HAVE_PTHREAD)
- add_definitions(-DHAVE_PTHREAD=1)
- endif()
-endif()
-
-if(MSVC)
- add_definitions( -D_CRT_SECURE_NO_WARNINGS=1 )
- ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146
- /wd4305 /wd4127 /wd4100 /wd4512 /wd4125 /wd4389 /wd4510 /wd4610
- /wd4702 /wd4456 /wd4457 /wd4065 /wd4310 /wd4661 /wd4506
- )
-else()
- ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated -Wmissing-prototypes -Wmissing-declarations -Wshadow
- -Wunused-parameter -Wunused-local-typedefs -Wsign-compare -Wsign-promo
- -Wundef -Wtautological-undefined-compare -Wignored-qualifiers -Wextra
- -Wunused-function -Wunused-const-variable
- )
-endif()
-if(CV_ICC)
- ocv_warnings_disable(CMAKE_CXX_FLAGS
- -wd265 -wd858 -wd873 -wd2196
- )
-endif()
-
-# Easier to support different versions of protobufs
-function(append_if_exist OUTPUT_LIST)
- set(${OUTPUT_LIST})
- foreach(fil ${ARGN})
- if(EXISTS ${fil})
- list(APPEND ${OUTPUT_LIST} "${fil}")
- else()
- message(WARNING "file missing: ${fil}")
- endif()
- endforeach()
- set(${OUTPUT_LIST} ${${OUTPUT_LIST}} PARENT_SCOPE)
-endfunction()
-
-set(PROTOBUF_ROOT "${PROTOBUF_CPP_PATH}/protobuf-3.1.0")
-
-if(MSVC)
- set(ATOMICOPS_INTERNALS ${PROTOBUF_ROOT}/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc)
-else()
- set(ATOMICOPS_INTERNALS ${PROTOBUF_ROOT}/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc)
-endif()
-
-
-append_if_exist(PROTOBUF_SRCS
-# libprotobuf-lite
- ${PROTOBUF_ROOT}/src/google/protobuf/arena.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/arenastring.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/extension_set.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/generated_message_util.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/io/coded_stream.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/io/zero_copy_stream.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/io/zero_copy_stream_impl_lite.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/message_lite.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/repeated_field.cc
- ${ATOMICOPS_INTERNALS}
- ${PROTOBUF_ROOT}/src/google/protobuf/stubs/bytestream.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/stubs/common.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/stubs/int128.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/stubs/once.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/stubs/status.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/stubs/statusor.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/stubs/stringpiece.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/stubs/stringprintf.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/stubs/structurally_valid.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/stubs/strutil.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/stubs/time.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/wire_format_lite.cc
-# libprotobuf
- ${PROTOBUF_ROOT}/src/google/protobuf/any.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/any.pb.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/api.pb.cc
-# ${PROTOBUF_ROOT}/src/google/protobuf/compiler/importer.cc
-# ${PROTOBUF_ROOT}/src/google/protobuf/compiler/parser.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/descriptor.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/descriptor.pb.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/descriptor_database.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/duration.pb.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/dynamic_message.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/empty.pb.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/extension_set_heavy.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/field_mask.pb.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/generated_message_reflection.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/io/gzip_stream.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/io/printer.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/io/strtod.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/io/tokenizer.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/io/zero_copy_stream_impl.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/map_field.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/message.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/reflection_ops.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/service.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/source_context.pb.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/struct.pb.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/stubs/mathlimits.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/stubs/substitute.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/text_format.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/timestamp.pb.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/type.pb.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/unknown_field_set.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/util/field_comparator.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/util/field_mask_util.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/datapiece.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/default_value_objectwriter.cc
-# ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/error_listener.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/field_mask_utility.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/json_escaping.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/json_objectwriter.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/json_stream_parser.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/object_writer.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/proto_writer.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/protostream_objectsource.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/protostream_objectwriter.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/type_info.cc
-# ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/type_info_test_helper.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/util/internal/utility.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/util/json_util.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/util/message_differencer.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/util/time_util.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/util/type_resolver_util.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/wire_format.cc
- ${PROTOBUF_ROOT}/src/google/protobuf/wrappers.pb.cc
-)
-
-if(CMAKE_VERSION VERSION_LESS 2.8.9 AND UNIX)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
-endif()
-
-add_library(libprotobuf STATIC ${PROTOBUF_SRCS})
-include_directories(${PROTOBUF_ROOT}/src)
-
-set_target_properties(libprotobuf
- PROPERTIES
- FOLDER "3rdparty"
- POSITION_INDEPENDENT_CODE 1 # CMake 2.8.9+
- OUTPUT_NAME libprotobuf
- DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
- ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH}
- )
-
-if(NOT BUILD_SHARED_LIBS)
- ocv_install_target(libprotobuf EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
-endif()
diff --git a/contrib/modules/dnn/CMakeLists.txt b/contrib/modules/dnn/CMakeLists.txt
deleted file mode 100644
index 7e7a471..0000000
--- a/contrib/modules/dnn/CMakeLists.txt
+++ /dev/null
@@ -1,91 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-
-if(APPLE_FRAMEWORK OR WINRT
- OR AARCH64 # protobuf doesn't know this platform
-)
- ocv_module_disable(dnn)
-endif()
-
-set(the_description "Deep neural network module. It allows to load models from different frameworks and to make forward pass")
-set(OPENCV_MODULE_IS_PART_OF_WORLD OFF)
-
-ocv_add_module(dnn opencv_core opencv_imgproc WRAP python matlab)
-ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-shadow -Wno-parentheses -Wmaybe-uninitialized -Wsign-promo
- -Wmissing-declarations -Wmissing-prototypes
-)
-ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4701 /wd4100)
-
-if(MSVC)
- add_definitions( -D_CRT_SECURE_NO_WARNINGS=1 )
- ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146
- /wd4305 /wd4127 /wd4100 /wd4512 /wd4125 /wd4389 /wd4510 /wd4610
- /wd4702 /wd4456 /wd4457 /wd4065 /wd4310 /wd4661 /wd4506
- )
-else()
- ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated -Wmissing-prototypes -Wmissing-declarations -Wshadow
- -Wunused-parameter -Wunused-local-typedefs -Wsign-compare -Wsign-promo
- -Wundef -Wtautological-undefined-compare -Wignored-qualifiers -Wextra
- -Wunused-function -Wunused-const-variable -Wdeprecated-declarations
- )
-endif()
-
-# ----------------------------------------------------------------------------
-# Resolve libprotobuf dependency
-# ----------------------------------------------------------------------------
-include(cmake/OpenCVFindLibProtobuf.cmake)
-ocv_source_group("Src\\protobuf" FILES ${PROTOBUF_SRCS} ${PROTOBUF_HDRS})
-ocv_module_include_directories(include ${PROTOBUF_INCLUDE_DIR})
-
-ocv_glob_module_sources(${PROTOBUF_SRCS} ${PROTOBUF_HDRS} ${CBLAS_H_PROXY_PATH})
-ocv_create_module(${PROTOBUF_LIBRARIES})
-ocv_add_samples()
-ocv_add_accuracy_tests()
-ocv_add_perf_tests()
-
-# ----------------------------------------------------------------------------
-# Download pre-trained models for complex testing on GoogLeNet and AlexNet
-# ----------------------------------------------------------------------------
-OCV_OPTION(${the_module}_DOWNLOAD_CAFFE_MODELS "Use GoogLeNet Caffe model for testing" OFF IF BUILD_TESTS AND DEFINED ENV{OPENCV_TEST_DATA_PATH})
-if(BUILD_TESTS AND DEFINED ENV{OPENCV_TEST_DATA_PATH} AND (DOWNLOAD_EXTERNAL_TEST_DATA OR ${the_module}_DOWNLOAD_CAFFE_MODELS))
- add_custom_command( TARGET opencv_test_${name} POST_BUILD
- COMMAND ${CMAKE_COMMAND} -Dmodel=GoogleNet -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/download_model.cmake)
- add_definitions(-DENABLE_CAFFE_MODEL_TESTS=1)
-endif()
-
-# ----------------------------------------------------------------------------
-# Torch7 importer of blobs and models, produced by Torch.nn module
-# ----------------------------------------------------------------------------
-OCV_OPTION(${the_module}_BUILD_TORCH_IMPORTER "Build Torch model importer (experimental functionality!)" OFF)
-if(${the_module}_BUILD_TORCH_IMPORTER)
- add_definitions(-DENABLE_TORCH_IMPORTER=1)
- ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4702 /wd4127 /wd4267) #supress warnings in original torch files
-
- if(NOT DEFINED HAVE_TORCH_EXE)
- execute_process(COMMAND th ${CMAKE_CURRENT_SOURCE_DIR}/testdata/dnn/torch/torch_nn_echo.lua RESULT_VARIABLE TORCH_EXE_STATUS)
- set(HAVE_TORCH_EXE OFF)
- if(${TORCH_EXE_STATUS} EQUAL 0)
- set(HAVE_TORCH_EXE ON)
- endif()
- set(HAVE_TORCH_EXE ${HAVE_TORCH_EXE} CACHE INTERNAL "Have torch binary")
- endif()
-endif()
-
-# ----------------------------------------------------------------------------
-# Generating test data for Torch importer
-# ----------------------------------------------------------------------------
-OCV_OPTION(${the_module}_BUILD_TORCH_TESTS "Build Torch tests (installed torch7 with nn module is required)" ON IF BUILD_TESTS AND ${the_module}_BUILD_TORCH_IMPORTER AND HAVE_TORCH_EXE)
-if(${the_module}_BUILD_TORCH_TESTS)
-
- if(NOT DEFINED ENV{OPENCV_TEST_DATA_PATH})
- message(FATAL_ERROR "OPENCV_TEST_DATA_PATH environment variable was not specified")
- endif()
-
- if(NOT HAVE_TORCH_EXE)
- message(FATAL_ERROR "Torch executable \"th\" not found or nn module not found")
- endif()
-
- add_custom_command( TARGET opencv_test_${name} POST_BUILD
- COMMAND th ${CMAKE_CURRENT_SOURCE_DIR}/testdata/dnn/torch/torch_gen_test_data.lua
- WORKING_DIRECTORY $ENV{OPENCV_TEST_DATA_PATH}/dnn/torch )
- add_definitions(-DENABLE_TORCH_TESTS=1)
-endif()
diff --git a/contrib/modules/dnn/README.md b/contrib/modules/dnn/README.md
deleted file mode 100644
index 6e7e9c4..0000000
--- a/contrib/modules/dnn/README.md
+++ /dev/null
@@ -1,2 +0,0 @@
-Deep Neural Network module
-==========================
\ No newline at end of file
diff --git a/contrib/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake b/contrib/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake
deleted file mode 100644
index eb2a729..0000000
--- a/contrib/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake
+++ /dev/null
@@ -1,56 +0,0 @@
-# By default, we use built-in protobuf sources and pre-generated .proto files
-# Note: In case of .proto model updates these variables should be used:
-# - PROTOBUF_PROTOC_EXECUTABLE (required)
-# - PROTOBUF_INCLUDE_DIR
-# - PROTOBUF_LIBRARIES or PROTOBUF_LIBRARY / PROTOBUF_LIBRARY_DEBUG for find_package()
-OCV_OPTION(BUILD_PROTOBUF "Force to build libprotobuf from sources" ON)
-OCV_OPTION(UPDATE_PROTO_FILES "Force to rebuild .proto files" OFF)
-
-if(UPDATE_PROTO_FILES)
- if(NOT DEFINED PROTOBUF_PROTOC_EXECUTABLE)
- find_package(Protobuf QUIET)
- endif()
- if(DEFINED PROTOBUF_PROTOC_EXECUTABLE AND EXISTS ${PROTOBUF_PROTOC_EXECUTABLE})
- message(STATUS "The protocol buffer compiler is found (${PROTOBUF_PROTOC_EXECUTABLE})")
- file(GLOB proto_files src/tensorflow/*.proto)
- list(APPEND proto_files src/caffe/caffe.proto)
- PROTOBUF_GENERATE_CPP(PROTOBUF_HDRS PROTOBUF_SRCS ${proto_files})
- else()
- message(FATAL_ERROR "The protocol buffer compiler is not found (PROTOBUF_PROTOC_EXECUTABLE='${PROTOBUF_PROTOC_EXECUTABLE}')")
- endif()
-endif()
-
-if(NOT BUILD_PROTOBUF AND NOT (DEFINED PROTOBUF_INCLUDE_DIR AND DEFINED PROTOBUF_LIBRARIES))
- find_package(Protobuf QUIET)
-endif()
-
-if(PROTOBUF_FOUND)
- # nothing
-else()
- include(${CMAKE_CURRENT_LIST_DIR}/download_protobuf.cmake)
- add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/protobuf)
- set(PROTOBUF_LIBRARIES libprotobuf)
- set(PROTOBUF_INCLUDE_DIR ${PROTOBUF_CPP_PATH}/protobuf-3.1.0/src)
-endif()
-
-if(NOT UPDATE_PROTO_FILES)
- file(GLOB fw_srcs ${CMAKE_CURRENT_SOURCE_DIR}/misc/tensorflow/*.cc)
- file(GLOB fw_hdrs ${CMAKE_CURRENT_SOURCE_DIR}/misc/tensorflow/*.h)
- list(APPEND fw_srcs ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/caffe.pb.cc)
- list(APPEND fw_hdrs ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/caffe.pb.h)
- list(APPEND PROTOBUF_SRCS ${fw_srcs})
- list(APPEND PROTOBUF_HDRS ${fw_hdrs})
- list(APPEND PROTOBUF_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe)
- list(APPEND PROTOBUF_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/misc/tensorflow)
-endif()
-
-add_definitions(-DHAVE_PROTOBUF=1)
-
-#supress warnings in autogenerated caffe.pb.* files
-ocv_warnings_disable(CMAKE_CXX_FLAGS
- -Wunused-parameter -Wundef -Wignored-qualifiers -Wno-enum-compare
- -Wdeprecated-declarations
- /wd4125 /wd4267 /wd4127 /wd4244 /wd4512 /wd4702
- /wd4456 /wd4510 /wd4610 /wd4800
- -wd858 -wd2196
-)
diff --git a/contrib/modules/dnn/cmake/download_model.cmake b/contrib/modules/dnn/cmake/download_model.cmake
deleted file mode 100644
index ebe57d9..0000000
--- a/contrib/modules/dnn/cmake/download_model.cmake
+++ /dev/null
@@ -1,31 +0,0 @@
-set(GoogleNet_url "http://dl.caffe.berkeleyvision.org/bvlc_googlenet.caffemodel")
-set(GoogleNet_dst "$ENV{OPENCV_TEST_DATA_PATH}/dnn/bvlc_googlenet.caffemodel")
-set(GoogleNet_sha "405fc5acd08a3bb12de8ee5e23a96bec22f08204")
-
-set(VGG16_url "http://www.robots.ox.ac.uk/~vgg/software/very_deep/caffe/VGG_ILSVRC_16_layers.caffemodel")
-set(GG16_dst "$ENV{OPENCV_TEST_DATA_PATH}/dnn/VGG_ILSVRC_16_layers.caffemodel")
-
-set(voc-fcn32s_url "http://dl.caffe.berkeleyvision.org/fcn32s-heavy-pascal.caffemodel")
-set(voc-fcn32s_dst "$ENV{OPENCV_TEST_DATA_PATH}/dnn/fcn32s-heavy-pascal.caffemodel")
-
-if(NOT model)
- set(model "GoogleNet")
-endif()
-
-message(STATUS "Downloading ${${model}_url} to ${${model}_dst}")
-
-if(NOT EXISTS ${${model}_dst})
- if(${${model}_sha})
- file(DOWNLOAD ${${model}_url} ${${model}_dst} SHOW_PROGRESS EXPECTED_HASH SHA1=${${model}_sha} STATUS status_vec)
- else()
- file(DOWNLOAD ${${model}_url} ${${model}_dst} SHOW_PROGRESS STATUS status_vec)
- endif()
-
- list(GET status_vec 0 status)
- list(GET status_vec 1 status_msg)
- if(status EQUAL 0)
- message(STATUS "Ok! ${status_msg}")
- else()
- message(STATUS "Fail! ${status_msg}")
- endif()
-endif()
diff --git a/contrib/modules/dnn/cmake/download_protobuf.cmake b/contrib/modules/dnn/cmake/download_protobuf.cmake
deleted file mode 100644
index 66ca853..0000000
--- a/contrib/modules/dnn/cmake/download_protobuf.cmake
+++ /dev/null
@@ -1,51 +0,0 @@
-set(PROTOBUF_CPP_NAME "libprotobuf")
-set(PROTOBUF_CPP_DOWNLOAD_HASH "bd5e3eed635a8d32e2b99658633815ef")
-set(PROTOBUF_CPP_PATH "${CMAKE_CURRENT_BINARY_DIR}/3rdparty/protobuf/sources") # /protobuf-3.1.0 subdirectory
-
-set(OPENCV_PROTOBUF_CPP_DOWNLOAD_URL ${OPENCV_PROTOBUF_URL};$ENV{OPENCV_PROTOBUF_URL};https://github.com/google/protobuf/releases/download/)
-
-function(ocv_protobuf_download file ID)
- if(DEFINED ${ID}_DOWNLOADED_HASH
- AND ${ID}_DOWNLOADED_HASH STREQUAL ${ID}_DOWNLOAD_HASH
- AND EXISTS ${${ID}_PATH})
- # Files have been downloaded and checked by the previous CMake run
- return()
- else()
- if(EXISTS ${${ID}_PATH})
- message(STATUS "${${ID}_NAME}: Removing previous unpacked files: ${${ID}_PATH}")
- file(REMOVE_RECURSE ${${ID}_PATH})
- endif()
- endif()
- unset(${ID}_DOWNLOADED_HASH CACHE)
-
- file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/.download)
- file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/.download/.gitignore" "*\n")
- ocv_download(PACKAGE ${file}
- HASH ${${ID}_DOWNLOAD_HASH}
- URL ${OPENCV_${ID}_DOWNLOAD_URL}
- DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/.download)
- set(${ID}_ARCHIVE "${DOWNLOAD_PACKAGE_LOCATION}")
-
- ocv_assert(EXISTS "${${ID}_ARCHIVE}")
- ocv_assert(NOT EXISTS "${${ID}_PATH}")
- file(MAKE_DIRECTORY ${${ID}_PATH})
- ocv_assert(EXISTS "${${ID}_PATH}")
- file(WRITE "${${ID}_PATH}/.gitignore" "*\n")
-
- message(STATUS "${${ID}_NAME}: Unpacking ${file} to ${${ID}_PATH}...")
- execute_process(COMMAND ${CMAKE_COMMAND} -E tar xz "${${ID}_ARCHIVE}"
- WORKING_DIRECTORY "${${ID}_PATH}"
- RESULT_VARIABLE __result)
-
- if(NOT __result EQUAL 0)
- message(FATAL_ERROR "${${ID}_NAME}: Failed to unpack ${ID} archive from ${${ID}_ARCHIVE} to ${${ID}_PATH} with error ${__result}")
- endif()
-
- ocv_assert(EXISTS "${${ID}_PATH}")
-
- set(${ID}_DOWNLOADED_HASH "${${ID}_DOWNLOAD_HASH}" CACHE INTERNAL "${ID} hash")
-
- #message(STATUS "${${ID}_NAME}: Successfully downloaded")
-endfunction()
-
-ocv_protobuf_download(v3.1.0/protobuf-cpp-3.1.0.tar.gz PROTOBUF_CPP)
diff --git a/contrib/modules/dnn/include/opencv2/dnn.hpp b/contrib/modules/dnn/include/opencv2/dnn.hpp
deleted file mode 100644
index 37be989..0000000
--- a/contrib/modules/dnn/include/opencv2/dnn.hpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_HPP__
-#define __OPENCV_DNN_HPP__
-
-// This is an umbrealla header to include into you project.
-// We are free to change headers layout in dnn subfolder, so please include
-// this header for future compartibility
-
-
-/** @defgroup dnn Deep Neural Network module
- @{
- This module contains:
- - API for new layers creation, layers are building bricks of neural networks;
- - set of built-in most-useful Layers;
- - API to constuct and modify comprehensive neural networks from layers;
- - functionality for loading serialized networks models from differnet frameworks.
-
- Functionality of this module is designed only for forward pass computations (i. e. network testing).
- A network training is in principle not supported.
- @}
-*/
-#include <opencv2/dnn/dnn.hpp>
-
-#endif /* __OPENCV_DNN_HPP__ */
diff --git a/contrib/modules/dnn/include/opencv2/dnn/all_layers.hpp b/contrib/modules/dnn/include/opencv2/dnn/all_layers.hpp
deleted file mode 100644
index ace63dd..0000000
--- a/contrib/modules/dnn/include/opencv2/dnn/all_layers.hpp
+++ /dev/null
@@ -1,405 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_DNN_ALL_LAYERS_HPP__
-#define __OPENCV_DNN_DNN_ALL_LAYERS_HPP__
-#include <opencv2/dnn.hpp>
-
-namespace cv
-{
-namespace dnn
-{
-//! @addtogroup dnn
-//! @{
-
-/** @defgroup dnnLayerList Partial List of Implemented Layers
- @{
- This subsection of dnn module contains information about bult-in layers and their descriptions.
-
- Classes listed here, in fact, provides C++ API for creating intances of bult-in layers.
- In addition to this way of layers instantiation, there is a more common factory API (see @ref dnnLayerFactory), it allows to create layers dynamically (by name) and register new ones.
- You can use both API, but factory API is less convinient for native C++ programming and basically designed for use inside importers (see @ref Importer, @ref createCaffeImporter(), @ref createTorchImporter()).
-
- Bult-in layers partially reproduce functionality of corresponding Caffe and Torch7 layers.
- In partuclar, the following layers and Caffe @ref Importer were tested to reproduce <a href="http://caffe.berkeleyvision.org/tutorial/layers.html">Caffe</a> functionality:
- - Convolution
- - Deconvolution
- - Pooling
- - InnerProduct
- - TanH, ReLU, Sigmoid, BNLL, Power, AbsVal
- - Softmax
- - Reshape, Flatten, Slice, Split
- - LRN
- - MVN
- - Dropout (since it does nothing on forward pass -))
-*/
-
- //! LSTM recurrent layer
- class CV_EXPORTS_W LSTMLayer : public Layer
- {
- public:
- /** Creates instance of LSTM layer */
- static CV_WRAP Ptr<LSTMLayer> create();
-
- /** Set trained weights for LSTM layer.
- LSTM behavior on each step is defined by current input, previous output, previous cell state and learned weights.
-
- Let @f$x_t at f$ be current input, @f$h_t at f$ be current output, @f$c_t at f$ be current state.
- Than current output and current cell state is computed as follows:
- @f{eqnarray*}{
- h_t &= o_t \odot tanh(c_t), \\
- c_t &= f_t \odot c_{t-1} + i_t \odot g_t, \\
- @f}
- where @f$\odot at f$ is per-element multiply operation and @f$i_t, f_t, o_t, g_t at f$ is internal gates that are computed using learned wights.
-
- Gates are computed as follows:
- @f{eqnarray*}{
- i_t &= sigmoid&(W_{xi} x_t + W_{hi} h_{t-1} + b_i), \\
- f_t &= sigmoid&(W_{xf} x_t + W_{hf} h_{t-1} + b_f), \\
- o_t &= sigmoid&(W_{xo} x_t + W_{ho} h_{t-1} + b_o), \\
- g_t &= tanh &(W_{xg} x_t + W_{hg} h_{t-1} + b_g), \\
- @f}
- where @f$W_{x?}@f$, @f$W_{h?}@f$ and @f$b_{?}@f$ are learned weights represented as matrices:
- @f$W_{x?} \in R^{N_h \times N_x}@f$, @f$W_{h?} \in R^{N_h \times N_h}@f$, @f$b_? \in R^{N_h}@f$.
-
- For simplicity and performance purposes we use @f$ W_x = [W_{xi}; W_{xf}; W_{xo}, W_{xg}] @f$
- (i.e. @f$W_x at f$ is vertical contacentaion of @f$ W_{x?} @f$), @f$ W_x \in R^{4N_h \times N_x} @f$.
- The same for @f$ W_h = [W_{hi}; W_{hf}; W_{ho}, W_{hg}], W_h \in R^{4N_h \times N_h} @f$
- and for @f$ b = [b_i; b_f, b_o, b_g]@f$, @f$b \in R^{4N_h} @f$.
-
- @param Wh is matrix defining how previous output is transformed to internal gates (i.e. according to abovemtioned notation is @f$ W_h @f$)
- @param Wx is matrix defining how current input is transformed to internal gates (i.e. according to abovemtioned notation is @f$ W_x @f$)
- @param b is bias vector (i.e. according to abovemtioned notation is @f$ b @f$)
- */
- CV_WRAP virtual void setWeights(const Blob &Wh, const Blob &Wx, const Blob &b) = 0;
-
- /** @brief Specifies shape of output blob which will be [[`T`], `N`] + @p outTailShape.
- * @details If this parameter is empty or unset then @p outTailShape = [`Wh`.size(0)] will be used,
- * where `Wh` is parameter from setWeights().
- */
- CV_WRAP virtual void setOutShape(const BlobShape &outTailShape = BlobShape::empty()) = 0;
-
- /** @brief Set @f$ h_{t-1} @f$ value that will be used in next forward() calls.
- * @details By-default @f$ h_{t-1} @f$ is inited by zeros and updated after each forward() call.
- */
- CV_WRAP virtual void setH(const Blob &H) = 0;
- /** @brief Returns current @f$ h_{t-1} @f$ value (deep copy). */
- CV_WRAP virtual Blob getH() const = 0;
-
- /** @brief Set @f$ c_{t-1} @f$ value that will be used in next forward() calls.
- * @details By-default @f$ c_{t-1} @f$ is inited by zeros and updated after each forward() call.
- */
- CV_WRAP virtual void setC(const Blob &C) = 0;
- /** @brief Returns current @f$ c_{t-1} @f$ value (deep copy). */
- CV_WRAP virtual Blob getC() const = 0;
-
- /** @brief Specifies either interpet first dimension of input blob as timestamp dimenion either as sample.
- *
- * If flag is set to true then shape of input blob will be interpeted as [`T`, `N`, `[data dims]`] where `T` specifies number of timpestamps, `N` is number of independent streams.
- * In this case each forward() call will iterate through `T` timestamps and update layer's state `T` times.
- *
- * If flag is set to false then shape of input blob will be interpeted as [`N`, `[data dims]`].
- * In this case each forward() call will make one iteration and produce one timestamp with shape [`N`, `[out dims]`].
- */
- CV_WRAP virtual void setUseTimstampsDim(bool use = true) = 0;
-
- /** @brief If this flag is set to true then layer will produce @f$ c_t @f$ as second output.
- * @details Shape of the second output is the same as first output.
- */
- CV_WRAP virtual void setProduceCellOutput(bool produce = false) = 0;
-
- /** In common case it use single input with @f$x_t at f$ values to compute output(s) @f$h_t at f$ (and @f$c_t at f$).
- * @param input should contain packed values @f$x_t at f$
- * @param output contains computed outputs: @f$h_t at f$ (and @f$c_t at f$ if setProduceCellOutput() flag was set to true).
- *
- * If setUseTimstampsDim() is set to true then @p input[0] should has at least two dimensions with the following shape: [`T`, `N`, `[data dims]`],
- * where `T` specifies number of timpestamps, `N` is number of independent streams (i.e. @f$ x_{t_0 + t}^{stream} @f$ is stored inside @p input[0][t, stream, ...]).
- *
- * If setUseTimstampsDim() is set to fase then @p input[0] should contain single timestamp, its shape should has form [`N`, `[data dims]`] with at least one dimension.
- * (i.e. @f$ x_{t}^{stream} @f$ is stored inside @p input[0][stream, ...]).
- */
- void forward(std::vector<Blob*> &input, std::vector<Blob> &output);
-
- int inputNameToIndex(String inputName);
-
- int outputNameToIndex(String outputName);
- };
-
- //! Classical recurrent layer
- class CV_EXPORTS_W RNNLayer : public Layer
- {
- public:
- /** Creates instance of RNNLayer */
- static CV_WRAP Ptr<RNNLayer> create();
-
- /** Setups learned weights.
-
- Recurrent-layer behavior on each step is defined by current input @f$ x_t @f$, previous state @f$ h_t @f$ and learned weights as follows:
- @f{eqnarray*}{
- h_t &= tanh&(W_{hh} h_{t-1} + W_{xh} x_t + b_h), \\
- o_t &= tanh&(W_{ho} h_t + b_o),
- @f}
-
- @param Wxh is @f$ W_{xh} @f$ matrix
- @param bh is @f$ b_{h} @f$ vector
- @param Whh is @f$ W_{hh} @f$ matrix
- @param Who is @f$ W_{xo} @f$ matrix
- @param bo is @f$ b_{o} @f$ vector
- */
- CV_WRAP virtual void setWeights(const Blob &Wxh, const Blob &bh, const Blob &Whh, const Blob &Who, const Blob &bo) = 0;
-
- /** @brief If this flag is set to true then layer will produce @f$ h_t @f$ as second output.
- * @details Shape of the second output is the same as first output.
- */
- CV_WRAP virtual void setProduceHiddenOutput(bool produce = false) = 0;
-
- /** Accepts two inputs @f$x_t at f$ and @f$h_{t-1}@f$ and compute two outputs @f$o_t at f$ and @f$h_t at f$.
-
- @param input should contain packed input @f$x_t at f$.
- @param output should contain output @f$o_t at f$ (and @f$h_t at f$ if setProduceHiddenOutput() is set to true).
-
- @p input[0] should have shape [`T`, `N`, `data_dims`] where `T` and `N` is number of timestamps and number of independent samples of @f$x_t at f$ respectively.
-
- @p output[0] will have shape [`T`, `N`, @f$N_o at f$], where @f$N_o at f$ is number of rows in @f$ W_{xo} @f$ matrix.
-
- If setProduceHiddenOutput() is set to true then @p output[1] will contain a Blob with shape [`T`, `N`, @f$N_h at f$], where @f$N_h at f$ is number of rows in @f$ W_{hh} @f$ matrix.
- */
- void forward(std::vector<Blob*> &input, std::vector<Blob> &output);
- };
-
- class CV_EXPORTS_W BaseConvolutionLayer : public Layer
- {
- public:
-
- CV_PROP_RW Size kernel, stride, pad, dilation;
- CV_PROP_RW String padMode;
- };
-
- class CV_EXPORTS_W ConvolutionLayer : public BaseConvolutionLayer
- {
- public:
-
- static CV_WRAP Ptr<BaseConvolutionLayer> create(Size kernel = Size(3, 3), Size stride = Size(1, 1), Size pad = Size(0, 0), Size dilation = Size(1, 1));
- };
-
- class CV_EXPORTS_W DeconvolutionLayer : public BaseConvolutionLayer
- {
- public:
-
- static CV_WRAP Ptr<BaseConvolutionLayer> create(Size kernel = Size(3, 3), Size stride = Size(1, 1), Size pad = Size(0, 0), Size dilation = Size(1, 1));
- };
-
- class CV_EXPORTS_W LRNLayer : public Layer
- {
- public:
-
- enum Type
- {
- CHANNEL_NRM,
- SPATIAL_NRM
- };
- CV_PROP_RW int type;
-
- CV_PROP_RW int size;
- CV_PROP_RW double alpha, beta, bias;
- CV_PROP_RW bool normBySize;
-
- static CV_WRAP Ptr<LRNLayer> create(int type = LRNLayer::CHANNEL_NRM, int size = 5,
- double alpha = 1, double beta = 0.75, double bias = 1,
- bool normBySize = true);
- };
-
- class CV_EXPORTS_W PoolingLayer : public Layer
- {
- public:
-
- enum Type
- {
- MAX,
- AVE,
- STOCHASTIC
- };
-
- CV_PROP_RW int type;
- CV_PROP_RW Size kernel, stride, pad;
- CV_PROP_RW bool globalPooling;
- CV_PROP_RW String padMode;
-
- static CV_WRAP Ptr<PoolingLayer> create(int type = PoolingLayer::MAX, Size kernel = Size(2, 2),
- Size stride = Size(1, 1), Size pad = Size(0, 0),
- const cv::String& padMode = "");
- static CV_WRAP Ptr<PoolingLayer> createGlobal(int type = PoolingLayer::MAX);
- };
-
- class CV_EXPORTS_W SoftmaxLayer : public Layer
- {
- public:
-
- static CV_WRAP Ptr<SoftmaxLayer> create(int axis = 1);
- };
-
- class CV_EXPORTS_W InnerProductLayer : public Layer
- {
- public:
- CV_PROP_RW int axis;
-
- static CV_WRAP Ptr<InnerProductLayer> create(int axis = 1);
- };
-
- class CV_EXPORTS_W MVNLayer : public Layer
- {
- public:
- CV_PROP_RW double eps;
- CV_PROP_RW bool normVariance, acrossChannels;
-
- static CV_WRAP Ptr<MVNLayer> create(bool normVariance = true, bool acrossChannels = false, double eps = 1e-9);
- };
-
- /* Reshaping */
-
- class CV_EXPORTS_W ReshapeLayer : public Layer
- {
- public:
- CV_PROP_RW BlobShape newShapeDesc;
- CV_PROP_RW Range newShapeRange;
-
- static CV_WRAP Ptr<ReshapeLayer> create(const BlobShape &newShape, Range applyingRange = Range::all(),
- bool enableReordering = false);
- };
-
- class CV_EXPORTS_W ConcatLayer : public Layer
- {
- public:
- int axis;
-
- static CV_WRAP Ptr<ConcatLayer> create(int axis = 1);
- };
-
- class CV_EXPORTS_W SplitLayer : public Layer
- {
- public:
- int outputsCount; //!< Number of copies that will be produced (is ignored when negative).
-
- static CV_WRAP Ptr<SplitLayer> create(int outputsCount = -1);
- };
-
- class CV_EXPORTS_W SliceLayer : public Layer
- {
- public:
- CV_PROP_RW int axis;
- CV_PROP std::vector<int> sliceIndices;
-
- static CV_WRAP Ptr<SliceLayer> create(int axis);
- static CV_WRAP Ptr<SliceLayer> create(int axis, const std::vector<int> &sliceIndices);
- };
-
- /* Activations */
-
- class CV_EXPORTS_W ReLULayer : public Layer
- {
- public:
- CV_PROP_RW double negativeSlope;
-
- static CV_WRAP Ptr<ReLULayer> create(double negativeSlope = 0);
- };
-
- class CV_EXPORTS_W TanHLayer : public Layer
- {
- public:
- static CV_WRAP Ptr<TanHLayer> create();
- };
-
- class CV_EXPORTS_W SigmoidLayer : public Layer
- {
- public:
- static CV_WRAP Ptr<SigmoidLayer> create();
- };
-
- class CV_EXPORTS_W BNLLLayer : public Layer
- {
- public:
- static CV_WRAP Ptr<BNLLLayer> create();
- };
-
- class CV_EXPORTS_W AbsLayer : public Layer
- {
- public:
- static CV_WRAP Ptr<AbsLayer> create();
- };
-
- class CV_EXPORTS_W PowerLayer : public Layer
- {
- public:
- CV_PROP_RW double power, scale, shift;
-
- static CV_WRAP Ptr<PowerLayer> create(double power = 1, double scale = 1, double shift = 0);
- };
-
- /* Layers using in semantic segmentation */
-
- class CV_EXPORTS_W CropLayer : public Layer
- {
- public:
- CV_PROP int startAxis;
- CV_PROP std::vector<int> offset;
-
- static Ptr<CropLayer> create(int start_axis, const std::vector<int> &offset);
- };
-
- class CV_EXPORTS_W EltwiseLayer : public Layer
- {
- public:
- enum EltwiseOp
- {
- PROD = 0,
- SUM = 1,
- MAX = 2,
- };
-
- static Ptr<EltwiseLayer> create(EltwiseOp op, const std::vector<int> &coeffs);
- };
-
-//! @}
-//! @}
-
-}
-}
-#endif
diff --git a/contrib/modules/dnn/include/opencv2/dnn/blob.hpp b/contrib/modules/dnn/include/opencv2/dnn/blob.hpp
deleted file mode 100644
index 71e929d..0000000
--- a/contrib/modules/dnn/include/opencv2/dnn/blob.hpp
+++ /dev/null
@@ -1,341 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_DNN_BLOB_HPP__
-#define __OPENCV_DNN_DNN_BLOB_HPP__
-#include <opencv2/core.hpp>
-#include <vector>
-#include <ostream>
-#include <iostream>
-
-namespace cv
-{
-namespace dnn
-{
-//! @addtogroup dnn
-//! @{
-
- /** @brief Lightweight class for storing and processing a shape of blob (or anything else). */
- struct CV_EXPORTS_W BlobShape
- {
- BlobShape(); //!< Creates [1, 1, 1, 1] shape @todo Make more clearer behavior.
- explicit BlobShape(int s0); //!< Creates 1-dim shape [@p s0]
- BlobShape(int s0, int s1); //!< @overload
- BlobShape(int s0, int s1, int s2); //!< @overload
- BlobShape(int num, int cn, int rows, int cols); //!< Creates 4-dim shape [@p num, @p cn, @p rows, @p cols]
-
- //! Creates n-dim shape from the @p sizes array; if @p sizes is NULL then shape will contain unspecified data
- BlobShape(int ndims, const int *sizes);
- BlobShape(const std::vector<int> &sizes); //!< Creates n-dim shape from the @p sizes vector
- template<int n>
- BlobShape(const Vec<int, n> &shape); //!< Creates n-dim shape from @ref cv::Vec
-
- //! Creates n-dim shape and fill its by @p fill
- static BlobShape all(int ndims, int fill = 1);
-
- /** @brief Returns number of dimensions. */
- int dims() const;
-
- /** @brief Returns reference to the size of the specified @p axis.
- *
- * Negative @p axis is supported, in this case a counting starts from the last axis,
- * i. e. -1 corresponds to last axis.
- * If non-existing axis was passed then an error will be generated.
- */
- int &size(int axis);
-
- /** @brief Returns the size of the specified @p axis.
- * @see size()
- */
- int size(int axis) const;
-
- int operator[](int axis) const; //!< Does the same thing as size(axis).
- int &operator[](int axis); //!< Does the same thing as size(int) const.
-
- /** @brief Returns the size of the specified @p axis.
- *
- * Does the same thing as size(int) const, but if non-existing axis will be passed then 1 will be returned,
- * therefore this function always finishes successfully.
- */
- int xsize(int axis) const;
-
- /** @brief Converts @p axis index to canonical format (where 0 <= @p axis < dims()). */
- int canonicalAxis(int axis) const;
-
- /** @brief Returns the product of all sizes of axes. */
- ptrdiff_t total() const;
-
- /** @brief Computes the product of sizes of axes among the specified axes range [@p startAxis; @p endAxis).
- * @details Negative axis indexing can be used. @sa Blob::total(int,int)
- */
- ptrdiff_t total(int startAxis, int endAxis = INT_MAX) const;
-
- /** @brief Constructs new shape from axes in range [@p startAxis; @p endAxis).
- * @details Negative axis indexing can be used. @sa Blob::total(int,int)
- */
- BlobShape slice(int startAxis, int endAxis = INT_MAX) const;
-
- /** @brief Returns pointer to the first element of continuous size array. */
- const int *ptr() const;
- /** @overload */
- int *ptr();
-
- bool equal(const BlobShape &other) const; //!< Checks equality of two shapes.
- bool operator== (const BlobShape &r) const; //!< @sa equal()
-
- BlobShape operator+ (const BlobShape &r) const; //!< Contacenates two shapes.
-
- static BlobShape like(const Mat &m); //!< Returns shape of passed Mat.
- static BlobShape like(const UMat &m); //!< Returns shape of passed UMat.
-
- static BlobShape empty(); //!< Returns empty shape [].
- bool isEmpty() const; //!< Returns true if shape is empty (i.e []).
-
-#ifdef CV_CXX_MOVE_SEMANTICS
- //TBD
-#endif
-
- private:
- cv::AutoBuffer<int,4> sz;
- };
-
-
- /** @brief This class provides methods for continuous n-dimensional CPU and GPU array processing.
- *
- * The class is realized as a wrapper over @ref cv::Mat and @ref cv::UMat.
- * It will support methods for switching and logical synchronization between CPU and GPU.
- */
- class CV_EXPORTS_W Blob
- {
- public:
- Blob();
-
- /** @brief Constructs blob with specified @p shape and @p type. */
- explicit Blob(const BlobShape &shape, int type = CV_32F, int allocFlags = ALLOC_MAT);
-
- /** @brief Constructs Blob from existing Mat or UMat. */
- Blob(InputArray data);
-
- /** @brief Constructs 4-dimensional blob (so-called batch) from image or array of images.
- * @param image 2-dimensional multi-channel or 3-dimensional single-channel image (or array of such images)
- * @param dstCn specifies size of second axis of ouptut blob
- */
- static Blob fromImages(InputArray image, int dstCn = -1);
-
- /** @brief Works like Blob::fromImages() but in-place. */
- void batchFromImages(InputArray image, int dstCn = -1);
-
- /** @brief Creates blob with specified @p shape and @p type. */
- void create(const BlobShape &shape, int type = CV_32F, int allocFlags = ALLOC_MAT);
-
- /** @brief Creates blob from Mat or UMat without copying the data.
- * @details If in is Mat then Mat data is populated, otherwise - UMat.
- */
- void fill(InputArray in);
-
- /** @brief Creates blob from user data.
- * @details If @p deepCopy is false then CPU data will not be allocated.
- */
- void fill(const BlobShape &shape, int type, void *data, bool deepCopy = true);
-
- /** @brief Sets @p value to the last used data (if @p allocFlags = -1).
- * @details If @p allocFlags != -1 then destination data (Mat or UMat) is determined by flags from AllocFlag enum like in create().
- */
- void setTo(InputArray value, int allocFlags = -1);
-
- Mat& matRef(bool writeOnly = true); //!< Returns reference to cv::Mat, containing blob data.
- const Mat& matRefConst() const; //!< Returns reference to cv::Mat, containing blob data, for read-only purposes.
- UMat &umatRef(bool writeOnly = true); //!< Returns reference to cv::UMat, containing blob data.
- const UMat &umatRefConst() const; //!< Returns reference to cv::UMat, containing blob data, for read-only purposes.
-
- template<typename XMat>
- XMat &getRef(bool writeOnly = true);
- template<typename XMat>
- const XMat &getRefConst() const;
-
- void updateMat(bool syncData = true) const; //!< Actualizes data stored inside Mat of Blob; if @p syncData is false then only shape will be actualized.
- void updateUMat(bool syncData = true) const; //!< Actualizes data stored inside Mat of Blob; if @p syncData is false then only shape will be actualized.
- void sync() const; //!< Updates Mat and UMat of Blob.
-
- /** @brief Returns number of blob dimensions. */
- int dims() const;
-
- /** @brief Returns the size of the specified @p axis.
- *
- * Negative @p axis is supported, in this case a counting starts from the last axis,
- * i. e. -1 corresponds to last axis.
- * If non-existing axis was passed then an error will be generated.
- */
- int size(int axis) const;
-
- /** @brief Returns the size of the specified @p axis.
- *
- * Does the same thing as size(int) const, but if non-existing axis will be passed then 1 will be returned,
- * therefore this function always finishes successfully.
- */
- int xsize(int axis) const;
-
- /** @brief Computes the product of sizes of axes among the specified axes range [@p startAxis; @p endAxis).
- * @param startAxis the first axis to include in the range.
- * @param endAxis the first axis to exclude from the range.
- * @details Negative axis indexing can be used.
- */
- size_t total(int startAxis = 0, int endAxis = INT_MAX) const;
-
- /** @brief Converts @p axis index to canonical format (where 0 <= @p axis < dims()). */
- int canonicalAxis(int axis) const;
-
- /** @brief Returns shape of the blob. */
- BlobShape shape() const;
-
- /** @brief Checks equality of two blobs shapes. */
- bool equalShape(const Blob &other) const;
-
- /** @brief Returns slice of first two dimensions.
- * @details The behaviour is similar to the following numpy code: blob[n, cn, ...]
- */
- Mat getPlane(int n, int cn);
-
- /** @brief Returns slice of first dimension.
- * @details The behaviour is similar to getPlane(), but returns all
- * channels * rows * cols values, corresponding to the n-th value
- * of the first dimension.
- */
- Mat getPlanes(int n);
-
- /* Shape getters of 4-dimensional blobs. */
- int cols() const; //!< Returns size of the fourth axis blob.
- int rows() const; //!< Returns size of the thrid axis blob.
- int channels() const; //!< Returns size of the second axis blob.
- int num() const; //!< Returns size of the first axis blob.
- Size size2() const; //!< Returns cv::Size(cols(), rows())
- Vec4i shape4() const; //!< Returns shape of first four blob axes.
-
- /** @brief Returns linear index of the element with specified coordinates in the blob.
- *
- * If @p n < dims() then unspecified coordinates will be filled by zeros.
- * If @p n > dims() then extra coordinates will be ignored.
- */
- template<int n>
- size_t offset(const Vec<int, n> &pos) const;
- /** @overload */
- size_t offset(int n = 0, int cn = 0, int row = 0, int col = 0) const;
-
- /* CPU pointer getters */
- /** @brief Returns pointer to the blob element with the specified position, stored in CPU memory.
- *
- * @p n correspond to the first axis, @p cn - to the second, etc.
- * If dims() > 4 then unspecified coordinates will be filled by zeros.
- * If dims() < 4 then extra coordinates will be ignored.
- */
- uchar *ptr(int n = 0, int cn = 0, int row = 0, int col = 0);
- /** @overload */
- template<typename Type>
- Type *ptr(int n = 0, int cn = 0, int row = 0, int col = 0);
- /** @overload ptr<float>() */
- float *ptrf(int n = 0, int cn = 0, int row = 0, int col = 0);
- //TODO: add const ptr methods
-
- /** @brief Shares data from other @p blob.
- * @returns *this
- */
- Blob &shareFrom(const Blob &blob);
-
- /** @brief Changes shape of the blob without copying the data.
- * @returns *this
- */
- Blob &reshape(const BlobShape &shape);
-
- /** @brief Changes shape of the blob without copying the data.
- * @returns shallow copy of original blob with new shape.
- */
- Blob reshaped(const BlobShape &newShape) const;
-
- int type() const; //!< Returns type of the blob.
- int elemSize() const; //!< Returns size of single element in bytes.
- int getState() const; //!< Returns current state of the blob, @see DataState.
-
- private:
- const int *sizes() const;
-
-# define CV_DNN_UMAT //DBG
-#ifdef HAVE_OPENCL
-# define CV_DNN_UMAT
-#endif
-
-#ifdef CV_DNN_UMAT
-# define CV_DNN_UMAT_ONLY(expr) (expr)
-#else
-# define CV_DNN_UMAT_ONLY(expr)
-#endif
-
-#ifndef CV_DNN_UMAT
- Mat m;
-#else
- mutable Mat m;
- mutable UMat um;
- mutable uchar state;
-#endif
-
-public:
- enum DataState
- {
- UNINITIALIZED = 0,
- HEAD_AT_MAT = 1 << 0,
- HEAD_AT_UMAT = 1 << 1,
- SYNCED = HEAD_AT_MAT | HEAD_AT_UMAT
- };
-
- enum AllocFlag
- {
- ALLOC_MAT = HEAD_AT_MAT,
- ALLOC_UMAT = HEAD_AT_UMAT,
- ALLOC_BOTH = SYNCED
- };
- };
-
-//! @}
-}
-}
-
-#include "blob.inl.hpp"
-
-#endif
diff --git a/contrib/modules/dnn/include/opencv2/dnn/blob.inl.hpp b/contrib/modules/dnn/include/opencv2/dnn/blob.inl.hpp
deleted file mode 100644
index b7f741e..0000000
--- a/contrib/modules/dnn/include/opencv2/dnn/blob.inl.hpp
+++ /dev/null
@@ -1,533 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_DNN_BLOB_INL_HPP__
-#define __OPENCV_DNN_DNN_BLOB_INL_HPP__
-#include "blob.hpp"
-
-namespace cv
-{
-namespace dnn
-{
-
-inline BlobShape::BlobShape()
-{
- sz.allocate(4);
- for (size_t i = 0; i < sz.size(); i++)
- sz[i] = 1;
-}
-
-inline BlobShape BlobShape::all(int ndims, int fill)
-{
- CV_Assert(ndims >= 0);
- BlobShape res;
- res.sz.allocate(ndims);
- for (int i = 0; i < ndims; i++)
- res.sz[i] = fill;
- return res;
-}
-
-inline BlobShape::BlobShape(int ndims, const int *sizes) : sz( (size_t)std::max(ndims, 0) )
-{
- CV_Assert(ndims >= 0);
- if (!sizes)
- return;
- for (int i = 0; i < ndims; i++)
- sz[i] = sizes[i];
-}
-
-inline BlobShape::BlobShape(int s0) : sz(1)
-{
- sz[0] = s0;
-}
-
-inline BlobShape::BlobShape(int s0, int s1) : sz(2)
-{
- sz[0] = s0;
- sz[1] = s1;
-}
-
-inline BlobShape::BlobShape(int s0, int s1, int s2) : sz(3)
-{
- sz[0] = s0;
- sz[1] = s1;
- sz[2] = s2;
-}
-
-inline BlobShape::BlobShape(int num, int cn, int rows, int cols) : sz(4)
-{
- sz[0] = num;
- sz[1] = cn;
- sz[2] = rows;
- sz[3] = cols;
-}
-
-inline BlobShape::BlobShape(const std::vector<int> &sizes) : sz( sizes.size() )
-{
- for (int i = 0; i < (int)sizes.size(); i++)
- sz[i] = sizes[i];
-}
-
-template<int n>
-inline BlobShape::BlobShape(const Vec<int, n> &shape) : sz(n)
-{
- for (int i = 0; i < n; i++)
- sz[i] = shape[i];
-}
-
-inline int BlobShape::dims() const
-{
- return (int)sz.size();
-}
-
-inline int BlobShape::xsize(int axis) const
-{
- if (axis < -dims() || axis >= dims())
- return 1;
-
- return sz[(axis < 0) ? axis + dims() : axis];
-}
-
-inline int BlobShape::size(int axis) const
-{
- CV_Assert(-dims() <= axis && axis < dims());
- return sz[(axis < 0) ? axis + dims() : axis];
-}
-
-inline int &BlobShape::size(int axis)
-{
- CV_Assert(-dims() <= axis && axis < dims());
- return sz[(axis < 0) ? axis + dims() : axis];
-}
-
-inline int BlobShape::operator[] (int axis) const
-{
- CV_Assert(-dims() <= axis && axis < dims());
- return sz[(axis < 0) ? axis + dims() : axis];
-}
-
-inline int &BlobShape::operator[] (int axis)
-{
- CV_Assert(-dims() <= axis && axis < dims());
- return sz[(axis < 0) ? axis + dims() : axis];
-}
-
-inline int BlobShape::canonicalAxis(int axis) const
-{
- CV_Assert(-dims() <= axis && axis < dims());
- return (axis < 0) ? axis + dims() : axis;
-}
-
-inline ptrdiff_t BlobShape::total() const
-{
- if (dims() == 0)
- return 0;
-
- ptrdiff_t res = 1;
- for (int i = 0; i < dims(); i++)
- res *= sz[i];
- return res;
-}
-
-inline ptrdiff_t BlobShape::total(int startAxis, int endAxis) const
-{
- if (isEmpty())
- return 0;
-
- if (endAxis == INT_MAX)
- endAxis = dims();
- else if (endAxis < 0)
- endAxis += dims();
- startAxis = (startAxis < 0) ? startAxis + dims() : startAxis;
- CV_Assert(0 <= startAxis && startAxis <= endAxis && endAxis <= dims());
-
- ptrdiff_t res = 1;
- for (int i = startAxis; i < endAxis; i++)
- res *= sz[i];
- return res;
-}
-
-inline BlobShape BlobShape::slice(int startAxis, int endAxis) const
-{
- if (isEmpty())
- return BlobShape::empty();
-
- if (endAxis == INT_MAX)
- endAxis = dims();
- else if (endAxis < 0)
- endAxis += dims();
- startAxis = (startAxis < 0) ? startAxis + dims() : startAxis;
- CV_Assert(0 <= startAxis && startAxis <= endAxis && endAxis <= dims());
-
- BlobShape res(endAxis - startAxis, (const int*)NULL);
- for (int i = startAxis; i < endAxis; i++)
- res[i - startAxis] = sz[i];
- return res;
-}
-
-inline const int *BlobShape::ptr() const
-{
- return sz;
-}
-
-inline int *BlobShape::ptr()
-{
- return sz;
-}
-
-inline bool BlobShape::equal(const BlobShape &other) const
-{
- if (this->dims() != other.dims())
- return false;
-
- for (int i = 0; i < other.dims(); i++)
- {
- if (sz[i] != other.sz[i])
- return false;
- }
-
- return true;
-}
-
-inline bool BlobShape::operator==(const BlobShape &r) const
-{
- return this->equal(r);
-}
-
-inline BlobShape BlobShape::like(const Mat &m)
-{
- return BlobShape(m.dims, (const int*)m.size);
-}
-
-inline BlobShape BlobShape::like(const UMat &m)
-{
- return BlobShape(m.dims, (const int*)m.size);
-}
-
-inline BlobShape BlobShape::empty()
-{
- return BlobShape(0, (const int*)NULL);
-}
-
-inline bool BlobShape::isEmpty() const
-{
- return dims() == 0;
-}
-
-inline BlobShape BlobShape::operator+(const BlobShape &r) const
-{
- BlobShape newShape(this->dims() + r.dims(), (int*)NULL);
- for (int i = 0; i < this->dims(); i++)
- newShape[i] = (*this)[i];
- for (int i = 0; i < r.dims(); i++)
- newShape[this->dims() + i] = r[i];
- return newShape;
-}
-
-CV_EXPORTS std::ostream &operator<< (std::ostream &stream, const BlobShape &shape);
-
-/////////////////////////////////////////////////////////////////////
-
-#ifndef CV_DNN_UMAT
-# define CV_DNN_SWITCH_MU(cpu_expr, gpu_expr) (cpu_expr)
-#else
-# define CV_DNN_SWITCH_MU(cpu_expr, gpu_expr) ((state == HEAD_AT_UMAT) ? (gpu_expr) : (cpu_expr))
-#endif
-
-
-inline int Blob::dims() const
-{
- return CV_DNN_SWITCH_MU(m.dims, um.dims);
-}
-
-inline const int * Blob::sizes() const
-{
- return CV_DNN_SWITCH_MU((const int*)m.size, (const int*)um.size);
-}
-
-inline int Blob::type() const
-{
- return CV_DNN_SWITCH_MU(m.type(), um.type());
-}
-
-template<int n>
-inline size_t Blob::offset(const Vec<int, n> &pos) const
-{
- const MatStep &step = CV_DNN_SWITCH_MU(m.step, um.step);
- size_t ofs = 0;
- int i;
- for (i = 0; i < std::min(n, dims()); i++)
- {
- CV_DbgAssert(pos[i] >= 0 && pos[i] < size(i));
- ofs += step[i] * pos[i];
- }
- for (; i < dims(); i++)
- CV_DbgAssert(pos[i] == 0);
- CV_DbgAssert(ofs % elemSize() == 0);
- return ofs / elemSize();
-}
-
-inline int Blob::canonicalAxis(int axis) const
-{
- CV_Assert(-dims() <= axis && axis < dims());
- return (axis < 0) ? axis + dims() : axis;
-}
-
-inline int Blob::xsize(int axis) const
-{
- if (axis < -dims() || axis >= dims())
- return 1;
-
- return sizes()[(axis < 0) ? axis + dims() : axis];
-}
-
-inline int Blob::size(int axis) const
-{
- CV_Assert(-dims() <= axis && axis < dims());
- return sizes()[(axis < 0) ? axis + dims() : axis];
-}
-
-inline size_t Blob::total(int startAxis, int endAxis) const
-{
- if (startAxis < 0)
- startAxis += dims();
-
- if (endAxis == INT_MAX)
- endAxis = dims();
- else if (endAxis < 0)
- endAxis += dims();
-
- CV_Assert(0 <= startAxis && startAxis <= endAxis && endAxis <= dims());
-
- size_t cnt = 1; //fix: assume that slice isn't empty
- for (int i = startAxis; i < endAxis; i++)
- cnt *= (size_t)sizes()[i];
-
- return cnt;
-}
-
-inline size_t Blob::offset(int n, int cn, int row, int col) const
-{
- return offset(Vec4i(n, cn, row, col));
-}
-
-inline float *Blob::ptrf(int n, int cn, int row, int col)
-{
- return matRef(false).ptr<float>() + offset(n, cn, row, col);
-}
-
-inline uchar *Blob::ptr(int n, int cn, int row, int col)
-{
- Mat &mat = matRef(false);
- return mat.ptr() + mat.elemSize() * offset(n, cn, row, col);
-}
-
-template<typename Dtype>
-inline Dtype* Blob::ptr(int n, int cn, int row, int col)
-{
- CV_Assert(type() == cv::DataDepth<Dtype>::value);
- return (Dtype*) ptr(n, cn, row, col);
-}
-
-inline BlobShape Blob::shape() const
-{
- return BlobShape(dims(), sizes());
-}
-
-inline bool Blob::equalShape(const Blob &other) const
-{
- if (this->dims() != other.dims())
- return false;
-
- for (int i = 0; i < dims(); i++)
- {
- if (this->sizes()[i] != other.sizes()[i])
- return false;
- }
- return true;
-}
-
-inline Mat& Blob::matRef(bool writeOnly)
-{
-#ifdef CV_DNN_UMAT
- updateMat(!writeOnly);
- state = HEAD_AT_MAT;
-#else
- (void)writeOnly;
-#endif
- return m;
-}
-
-inline const Mat& Blob::matRefConst() const
-{
- CV_DNN_UMAT_ONLY( updateMat() );
- return m;
-}
-
-inline UMat &Blob::umatRef(bool writeOnly)
-{
-#ifndef CV_DNN_UMAT
- CV_Error(Error::GpuNotSupported, "");
- (void)writeOnly;
- return *(new UMat());
-#else
- updateUMat(!writeOnly);
- state = HEAD_AT_UMAT;
- return um;
-#endif
-}
-
-inline const UMat &Blob::umatRefConst() const
-{
-#ifndef CV_DNN_UMAT
- CV_Error(Error::GpuNotSupported, "");
- return *(new UMat());
-#else
- updateUMat();
- return um;
-#endif
-}
-
-template<>
-inline Mat &Blob::getRef<Mat>(bool writeOnly)
-{
- return matRef(writeOnly);
-}
-
-template<>
-inline UMat &Blob::getRef<UMat>(bool writeOnly)
-{
- return umatRef(writeOnly);
-}
-
-template<>
-inline const Mat &Blob::getRefConst<Mat>() const
-{
- return matRefConst();
-}
-
-template<>
-inline const UMat &Blob::getRefConst<UMat>() const
-{
- return umatRefConst();
-}
-
-inline Mat Blob::getPlane(int n, int cn)
-{
- CV_Assert(dims() > 2);
- return Mat(dims() - 2, sizes() + 2, type(), ptr(n, cn));
-}
-
-inline Mat Blob::getPlanes(int n)
-{
- CV_Assert(dims() > 3);
- return Mat(dims() - 1, sizes() + 1, type(), ptr(n));
-}
-
-inline int Blob::cols() const
-{
- return xsize(3);
-}
-
-inline int Blob::rows() const
-{
- return xsize(2);
-}
-
-inline int Blob::channels() const
-{
- return xsize(1);
-}
-
-inline int Blob::num() const
-{
- return xsize(0);
-}
-
-inline Size Blob::size2() const
-{
- return Size(cols(), rows());
-}
-
-inline Blob &Blob::shareFrom(const Blob &blob)
-{
- this->m = blob.m;
-#ifdef CV_DNN_UMAT
- this->um = blob.um;
- this->state = blob.state;
-#endif
- return *this;
-}
-
-inline Blob &Blob::reshape(const BlobShape &newShape)
-{
- if (!m.empty()) m = m.reshape(1, newShape.dims(), newShape.ptr());
-#ifdef CV_DNN_UMAT
- if (!um.empty()) um = um.reshape(1, newShape.dims(), newShape.ptr());
-#endif
- return *this;
-}
-
-inline Blob Blob::reshaped(const BlobShape &newShape) const
-{
- Blob res(*this); //also, res.shareFrom(*this) could be used
- res.reshape(newShape);
- return res;
-}
-
-inline int Blob::elemSize() const
-{
- return CV_ELEM_SIZE(type());
-}
-
-inline int Blob::getState() const
-{
-#ifdef CV_DNN_UMAT
- return this->state;
-#else
- return m.empty() ? UNINITIALIZED : HEAD_AT_MAT;
-#endif
-}
-
-}
-}
-
-#endif
diff --git a/contrib/modules/dnn/include/opencv2/dnn/dict.hpp b/contrib/modules/dnn/include/opencv2/dnn/dict.hpp
deleted file mode 100644
index f7cd0f2..0000000
--- a/contrib/modules/dnn/include/opencv2/dnn/dict.hpp
+++ /dev/null
@@ -1,143 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_DNN_DICT_HPP__
-#define __OPENCV_DNN_DNN_DICT_HPP__
-
-#include <opencv2/core.hpp>
-#include <map>
-#include <ostream>
-
-namespace cv
-{
-namespace dnn
-{
-//! @addtogroup dnn
-//! @{
-
-/** @brief This struct stores the scalar value (or array) of one of the following type: double, cv::String or int64.
- * @todo Maybe int64 is useless because double type exactly stores at least 2^52 integers.
- */
-struct DictValue
-{
- DictValue(const DictValue &r);
- DictValue(int64 i = 0) : type(Param::INT), pi(new AutoBuffer<int64,1>) { (*pi)[0] = i; } //!< Constructs integer scalar
- DictValue(int i) : type(Param::INT), pi(new AutoBuffer<int64,1>) { (*pi)[0] = i; } //!< Constructs integer scalar
- DictValue(unsigned p) : type(Param::INT), pi(new AutoBuffer<int64,1>) { (*pi)[0] = p; } //!< Constructs integer scalar
- DictValue(double p) : type(Param::REAL), pd(new AutoBuffer<double,1>) { (*pd)[0] = p; } //!< Constructs floating point scalar
- DictValue(const String &s) : type(Param::STRING), ps(new AutoBuffer<String,1>) { (*ps)[0] = s; } //!< Constructs string scalar
- DictValue(const char *s) : type(Param::STRING), ps(new AutoBuffer<String,1>) { (*ps)[0] = s; } //!< @overload
-
- template<typename TypeIter>
- static DictValue arrayInt(TypeIter begin, int size); //!< Constructs integer array
- template<typename TypeIter>
- static DictValue arrayReal(TypeIter begin, int size); //!< Constructs floating point array
- template<typename TypeIter>
- static DictValue arrayString(TypeIter begin, int size); //!< Constructs array of strings
-
- template<typename T>
- T get(int idx = -1) const; //!< Tries to convert array element with specified index to requested type and returns its.
-
- int size() const;
-
- bool isInt() const;
- bool isString() const;
- bool isReal() const;
-
- DictValue &operator=(const DictValue &r);
-
- friend std::ostream &operator<<(std::ostream &stream, const DictValue &dictv);
-
- ~DictValue();
-
-private:
-
- int type;
-
- union
- {
- AutoBuffer<int64, 1> *pi;
- AutoBuffer<double, 1> *pd;
- AutoBuffer<String, 1> *ps;
- void *pv;
- };
-
- DictValue(int _type, void *_p) : type(_type), pv(_p) {}
- void release();
-};
-
-/** @brief This class implements name-value dictionary, values are instances of DictValue. */
-class CV_EXPORTS Dict
-{
- typedef std::map<String, DictValue> _Dict;
- _Dict dict;
-
-public:
-
- //! Checks a presence of the @p key in the dictionary.
- bool has(const String &key) const;
-
- //! If the @p key in the dictionary then returns pointer to its value, else returns NULL.
- DictValue *ptr(const String &key);
-
- //! If the @p key in the dictionary then returns its value, else an error will be generated.
- const DictValue &get(const String &key) const;
-
- /** @overload */
- template <typename T>
- T get(const String &key) const;
-
- //! If the @p key in the dictionary then returns its value, else returns @p defaultValue.
- template <typename T>
- T get(const String &key, const T &defaultValue) const;
-
- //! Sets new @p value for the @p key, or adds new key-value pair into the dictionary.
- template<typename T>
- const T &set(const String &key, const T &value);
-
- friend std::ostream &operator<<(std::ostream &stream, const Dict &dict);
-};
-
-//! @}
-}
-}
-
-#endif
diff --git a/contrib/modules/dnn/include/opencv2/dnn/dnn.hpp b/contrib/modules/dnn/include/opencv2/dnn/dnn.hpp
deleted file mode 100644
index ca4a6ab..0000000
--- a/contrib/modules/dnn/include/opencv2/dnn/dnn.hpp
+++ /dev/null
@@ -1,347 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_DNN_HPP__
-#define __OPENCV_DNN_DNN_HPP__
-
-#include <vector>
-#include <opencv2/core.hpp>
-#include <opencv2/dnn/dict.hpp>
-#include <opencv2/dnn/blob.hpp>
-
-namespace cv
-{
-namespace dnn //! This namespace is used for dnn module functionlaity.
-{
-//! @addtogroup dnn
-//! @{
-
- /** @brief Initialize dnn module and built-in layers.
- *
- * This function automatically called on most of OpenCV builds,
- * but you need to call it manually on some specific configurations (iOS for example).
- */
- CV_EXPORTS_W void initModule();
-
- /** @brief This class provides all data needed to initialize layer.
- *
- * It includes dictionary with scalar params (which can be readed by using Dict interface),
- * blob params #blobs and optional meta information: #name and #type of layer instance.
- */
- class CV_EXPORTS LayerParams : public Dict
- {
- public:
- //TODO: Add ability to name blob params
- std::vector<Blob> blobs; //!< List of learned parameters stored as blobs.
-
- String name; //!< Name of the layer instance (optional, can be used internal purposes).
- String type; //!< Type name which was used for creating layer by layer factory (optional).
- };
-
- /** @brief This interface class allows to build new Layers - are building blocks of networks.
- *
- * Each class, derived from Layer, must implement allocate() methods to declare own outputs and forward() to compute outputs.
- * Also before using the new layer into networks you must register your layer by using one of @ref dnnLayerFactory "LayerFactory" macros.
- */
- class CV_EXPORTS_W Layer
- {
- public:
-
- //! List of learned parameters must be stored here to allow read them by using Net::getParam().
- CV_PROP_RW std::vector<Blob> blobs;
-
- /** @brief Allocates internal buffers and output blobs with respect to the shape of inputs.
- * @param[in] input vector of already allocated input blobs
- * @param[out] output vector of output blobs, which must be allocated
- *
- * This method must create each produced blob according to shape of @p input blobs and internal layer params.
- * If this method is called first time then @p output vector consists from empty blobs and its size determined by number of output connections.
- * This method can be called multiple times if size of any @p input blob was changed.
- */
- virtual void allocate(const std::vector<Blob*> &input, std::vector<Blob> &output) = 0;
-
- /** @brief Given the @p input blobs, computes the output @p blobs.
- * @param[in] input the input blobs.
- * @param[out] output allocated output blobs, which will store results of the computation.
- */
- virtual void forward(std::vector<Blob*> &input, std::vector<Blob> &output) = 0;
-
- /** @brief @overload */
- CV_WRAP void allocate(const std::vector<Blob> &inputs, CV_OUT std::vector<Blob> &outputs);
-
- /** @brief @overload */
- CV_WRAP std::vector<Blob> allocate(const std::vector<Blob> &inputs);
-
- /** @brief @overload */
- CV_WRAP void forward(const std::vector<Blob> &inputs, CV_IN_OUT std::vector<Blob> &outputs);
-
- /** @brief Allocates layer and computes output. */
- CV_WRAP void run(const std::vector<Blob> &inputs, CV_OUT std::vector<Blob> &outputs);
-
- /** @brief Returns index of input blob into the input array.
- * @param inputName label of input blob
- *
- * Each layer input and output can be labeled to easily identify them using "%<layer_name%>[.output_name]" notation.
- * This method maps label of input blob to its index into input vector.
- */
- virtual int inputNameToIndex(String inputName);
- /** @brief Returns index of output blob in output array.
- * @see inputNameToIndex()
- */
- virtual int outputNameToIndex(String outputName);
-
- CV_PROP String name; //!< Name of the layer instance, can be used for logging or other internal purposes.
- CV_PROP String type; //!< Type name which was used for creating layer by layer factory.
-
- Layer();
- explicit Layer(const LayerParams ¶ms); //!< Initializes only #name, #type and #blobs fields.
- void setParamsFrom(const LayerParams ¶ms); //!< Initializes only #name, #type and #blobs fields.
- virtual ~Layer();
- };
-
- /** @brief This class allows to create and manipulate comprehensive artificial neural networks.
- *
- * Neural network is presented as directed acyclic graph (DAG), where vertices are Layer instances,
- * and edges specify relationships between layers inputs and outputs.
- *
- * Each network layer has unique integer id and unique string name inside its network.
- * LayerId can store either layer name or layer id.
- *
- * This class supports reference counting of its instances, i. e. copies point to the same instance.
- */
- class CV_EXPORTS_W_SIMPLE Net
- {
- public:
-
- CV_WRAP Net(); //!< Default constructor.
- CV_WRAP ~Net(); //!< Destructor frees the net only if there aren't references to the net anymore.
-
- /** Returns true if there are no layers in the network. */
- CV_WRAP bool empty() const;
-
- /** @brief Adds new layer to the net.
- * @param name unique name of the adding layer.
- * @param type typename of the adding layer (type must be registered in LayerRegister).
- * @param params parameters which will be used to initialize the creating layer.
- * @returns unique identifier of created layer, or -1 if a failure will happen.
- */
- int addLayer(const String &name, const String &type, LayerParams ¶ms);
- /** @brief Adds new layer and connects its first input to the first output of previously added layer.
- * @see addLayer()
- */
- int addLayerToPrev(const String &name, const String &type, LayerParams ¶ms);
-
- /** @brief Converts string name of the layer to the integer identifier.
- * @returns id of the layer, or -1 if the layer wasn't found.
- */
- CV_WRAP int getLayerId(const String &layer);
-
- CV_WRAP std::vector<String> getLayerNames() const;
-
- /** @brief Container for strings and integers. */
- typedef DictValue LayerId;
-
- /** @brief Returns pointer to layer with specified name which the network use. */
- CV_WRAP Ptr<Layer> getLayer(LayerId layerId);
-
- /** @brief Delete layer for the network (not implemented yet) */
- CV_WRAP void deleteLayer(LayerId layer);
-
- /** @brief Connects output of the first layer to input of the second layer.
- * @param outPin descriptor of the first layer output.
- * @param inpPin descriptor of the second layer input.
- *
- * Descriptors have the following template <DFN><layer_name>[.input_number]</DFN>:
- * - the first part of the template <DFN>layer_name</DFN> is sting name of the added layer.
- * If this part is empty then the network input pseudo layer will be used;
- * - the second optional part of the template <DFN>input_number</DFN>
- * is either number of the layer input, either label one.
- * If this part is omitted then the first layer input will be used.
- *
- * @see setNetInputs(), Layer::inputNameToIndex(), Layer::outputNameToIndex()
- */
- CV_WRAP void connect(String outPin, String inpPin);
-
- /** @brief Connects #@p outNum output of the first layer to #@p inNum input of the second layer.
- * @param outLayerId identifier of the first layer
- * @param inpLayerId identifier of the second layer
- * @param outNum number of the first layer output
- * @param inpNum number of the second layer input
- */
- void connect(int outLayerId, int outNum, int inpLayerId, int inpNum);
-
- /** @brief Sets outputs names of the network input pseudo layer.
- *
- * Each net always has special own the network input pseudo layer with id=0.
- * This layer stores the user blobs only and don't make any computations.
- * In fact, this layer provides the only way to pass user data into the network.
- * As any other layer, this layer can label its outputs and this function provides an easy way to do this.
- */
- CV_WRAP void setNetInputs(const std::vector<String> &inputBlobNames);
-
- /** @brief Initializes and allocates all layers. */
- CV_WRAP void allocate();
-
- /** @brief Runs forward pass to compute output of layer @p toLayer.
- * @details By default runs forward pass for the whole network.
- */
- CV_WRAP void forward(LayerId toLayer = String());
- /** @brief Runs forward pass to compute output of layer @p toLayer, but computations start from @p startLayer */
- void forward(LayerId startLayer, LayerId toLayer);
- /** @overload */
- void forward(const std::vector<LayerId> &startLayers, const std::vector<LayerId> &toLayers);
-
- //TODO:
- /** @brief Optimized forward.
- * @warning Not implemented yet.
- * @details Makes forward only those layers which weren't changed after previous forward().
- */
- void forwardOpt(LayerId toLayer);
- /** @overload */
- void forwardOpt(const std::vector<LayerId> &toLayers);
-
- /** @brief Sets the new value for the layer output blob
- * @param outputName descriptor of the updating layer output blob.
- * @param blob new blob.
- * @see connect(String, String) to know format of the descriptor.
- * @note If updating blob is not empty then @p blob must have the same shape,
- * because network reshaping is not implemented yet.
- */
- CV_WRAP void setBlob(String outputName, const Blob &blob);
-
- /** @brief Returns the layer output blob.
- * @param outputName the descriptor of the returning layer output blob.
- * @see connect(String, String)
- */
- CV_WRAP Blob getBlob(String outputName);
-
- /** @brief Sets the new value for the learned param of the layer.
- * @param layer name or id of the layer.
- * @param numParam index of the layer parameter in the Layer::blobs array.
- * @param blob the new value.
- * @see Layer::blobs
- * @note If shape of the new blob differs from the previous shape,
- * then the following forward pass may fail.
- */
- CV_WRAP void setParam(LayerId layer, int numParam, const Blob &blob);
-
- /** @brief Returns parameter blob of the layer.
- * @param layer name or id of the layer.
- * @param numParam index of the layer parameter in the Layer::blobs array.
- * @see Layer::blobs
- */
- CV_WRAP Blob getParam(LayerId layer, int numParam = 0);
-
- private:
-
- struct Impl;
- Ptr<Impl> impl;
- };
-
- /** @brief Small interface class for loading trained serialized models of different dnn-frameworks. */
- class CV_EXPORTS_W Importer
- {
- public:
-
- /** @brief Adds loaded layers into the @p net and sets connections between them. */
- CV_WRAP virtual void populateNet(Net net) = 0;
-
- virtual ~Importer();
- };
-
- /** @brief Creates the importer of <a href="http://caffe.berkeleyvision.org">Caffe</a> framework network.
- * @param prototxt path to the .prototxt file with text description of the network architecture.
- * @param caffeModel path to the .caffemodel file with learned network.
- * @returns Pointer to the created importer, NULL in failure cases.
- */
- CV_EXPORTS_W Ptr<Importer> createCaffeImporter(const String &prototxt, const String &caffeModel = String());
-
- /** @brief Reads a network model stored in Caffe model files.
- * @details This is shortcut consisting from createCaffeImporter and Net::populateNet calls.
- */
- CV_EXPORTS_W Net readNetFromCaffe(const String &prototxt, const String &caffeModel = String());
-
- /** @brief Creates the importer of <a href="http://www.tensorflow.org">TensorFlow</a> framework network.
- * @param model path to the .pb file with binary protobuf description of the network architecture.
- * @returns Pointer to the created importer, NULL in failure cases.
- */
- CV_EXPORTS Ptr<Importer> createTensorflowImporter(const String &model);
-
- /** @brief Creates the importer of <a href="http://torch.ch">Torch7</a> framework network.
- * @param filename path to the file, dumped from Torch by using torch.save() function.
- * @param isBinary specifies whether the network was serialized in ascii mode or binary.
- * @returns Pointer to the created importer, NULL in failure cases.
- *
- * @warning Torch7 importer is experimental now, you need explicitly set CMake `opencv_dnn_BUILD_TORCH_IMPORTER` flag to compile its.
- *
- * @note Ascii mode of Torch serializer is more preferable, because binary mode extensively use `long` type of C language,
- * which has various bit-length on different systems.
- *
- * The loading file must contain serialized <a href="https://github.com/torch/nn/blob/master/doc/module.md">nn.Module</a> object
- * with importing network. Try to eliminate a custom objects from serialazing data to avoid importing errors.
- *
- * List of supported layers (i.e. object instances derived from Torch nn.Module class):
- * - nn.Sequential
- * - nn.Parallel
- * - nn.Concat
- * - nn.Linear
- * - nn.SpatialConvolution
- * - nn.SpatialMaxPooling, nn.SpatialAveragePooling
- * - nn.ReLU, nn.TanH, nn.Sigmoid
- * - nn.Reshape
- *
- * Also some equivalents of these classes from cunn, cudnn, and fbcunn may be successfully imported.
- */
- CV_EXPORTS_W Ptr<Importer> createTorchImporter(const String &filename, bool isBinary = true);
-
- /** @brief Loads blob which was serialized as torch.Tensor object of Torch7 framework.
- * @warning This function has the same limitations as createTorchImporter().
- */
- CV_EXPORTS_W Blob readTorchBlob(const String &filename, bool isBinary = true);
-
-//! @}
-}
-}
-
-#include <opencv2/dnn/layer.hpp>
-#include <opencv2/dnn/dnn.inl.hpp>
-
-#endif /* __OPENCV_DNN_DNN_HPP__ */
diff --git a/contrib/modules/dnn/include/opencv2/dnn/dnn.inl.hpp b/contrib/modules/dnn/include/opencv2/dnn/dnn.inl.hpp
deleted file mode 100644
index a272044..0000000
--- a/contrib/modules/dnn/include/opencv2/dnn/dnn.inl.hpp
+++ /dev/null
@@ -1,351 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_DNN_INL_HPP__
-#define __OPENCV_DNN_DNN_INL_HPP__
-
-#include <opencv2/dnn.hpp>
-
-namespace cv
-{
-namespace dnn
-{
-
-template<typename TypeIter>
-DictValue DictValue::arrayInt(TypeIter begin, int size)
-{
- DictValue res(Param::INT, new AutoBuffer<int64, 1>(size));
- for (int j = 0; j < size; begin++, j++)
- (*res.pi)[j] = *begin;
- return res;
-}
-
-template<typename TypeIter>
-DictValue DictValue::arrayReal(TypeIter begin, int size)
-{
- DictValue res(Param::REAL, new AutoBuffer<double, 1>(size));
- for (int j = 0; j < size; begin++, j++)
- (*res.pd)[j] = *begin;
- return res;
-}
-
-template<typename TypeIter>
-DictValue DictValue::arrayString(TypeIter begin, int size)
-{
- DictValue res(Param::STRING, new AutoBuffer<String, 1>(size));
- for (int j = 0; j < size; begin++, j++)
- (*res.ps)[j] = *begin;
- return res;
-}
-
-template<>
-inline DictValue DictValue::get<DictValue>(int idx) const
-{
- CV_Assert(idx == -1);
- return *this;
-}
-
-template<>
-inline int64 DictValue::get<int64>(int idx) const
-{
- CV_Assert((idx == -1 && size() == 1) || (idx >= 0 && idx < size()));
- idx = (idx == -1) ? 0 : idx;
-
- if (type == Param::INT)
- {
- return (*pi)[idx];
- }
- else if (type == Param::REAL)
- {
- double doubleValue = (*pd)[idx];
-
- double fracpart, intpart;
- fracpart = std::modf(doubleValue, &intpart);
- CV_Assert(fracpart == 0.0);
-
- return (int64)doubleValue;
- }
- else
- {
- CV_Assert(isInt() || isReal());
- return 0;
- }
-}
-
-template<>
-inline int DictValue::get<int>(int idx) const
-{
- return (int)get<int64>(idx);
-}
-
-template<>
-inline unsigned DictValue::get<unsigned>(int idx) const
-{
- return (unsigned)get<int64>(idx);
-}
-
-template<>
-inline bool DictValue::get<bool>(int idx) const
-{
- return (get<int64>(idx) != 0);
-}
-
-template<>
-inline double DictValue::get<double>(int idx) const
-{
- CV_Assert((idx == -1 && size() == 1) || (idx >= 0 && idx < size()));
- idx = (idx == -1) ? 0 : idx;
-
- if (type == Param::REAL)
- {
- return (*pd)[idx];
- }
- else if (type == Param::INT)
- {
- return (double)(*pi)[idx];
- }
- else
- {
- CV_Assert(isReal() || isInt());
- return 0;
- }
-}
-
-template<>
-inline float DictValue::get<float>(int idx) const
-{
- return (float)get<double>(idx);
-}
-
-template<>
-inline String DictValue::get<String>(int idx) const
-{
- CV_Assert(isString());
- CV_Assert((idx == -1 && ps->size() == 1) || (idx >= 0 && idx < (int)ps->size()));
- return (*ps)[(idx == -1) ? 0 : idx];
-}
-
-inline void DictValue::release()
-{
- switch (type)
- {
- case Param::INT:
- delete pi;
- break;
- case Param::STRING:
- delete ps;
- break;
- case Param::REAL:
- delete pd;
- break;
- }
-}
-
-inline DictValue::~DictValue()
-{
- release();
-}
-
-inline DictValue & DictValue::operator=(const DictValue &r)
-{
- if (&r == this)
- return *this;
-
- if (r.type == Param::INT)
- {
- AutoBuffer<int64, 1> *tmp = new AutoBuffer<int64, 1>(*r.pi);
- release();
- pi = tmp;
- }
- else if (r.type == Param::STRING)
- {
- AutoBuffer<String, 1> *tmp = new AutoBuffer<String, 1>(*r.ps);
- release();
- ps = tmp;
- }
- else if (r.type == Param::REAL)
- {
- AutoBuffer<double, 1> *tmp = new AutoBuffer<double, 1>(*r.pd);
- release();
- pd = tmp;
- }
-
- type = r.type;
-
- return *this;
-}
-
-inline DictValue::DictValue(const DictValue &r)
-{
- type = r.type;
-
- if (r.type == Param::INT)
- pi = new AutoBuffer<int64, 1>(*r.pi);
- else if (r.type == Param::STRING)
- ps = new AutoBuffer<String, 1>(*r.ps);
- else if (r.type == Param::REAL)
- pd = new AutoBuffer<double, 1>(*r.pd);
-}
-
-inline bool DictValue::isString() const
-{
- return (type == Param::STRING);
-}
-
-inline bool DictValue::isInt() const
-{
- return (type == Param::INT);
-}
-
-inline bool DictValue::isReal() const
-{
- return (type == Param::REAL || type == Param::INT);
-}
-
-inline int DictValue::size() const
-{
- switch (type)
- {
- case Param::INT:
- return (int)pi->size();
- break;
- case Param::STRING:
- return (int)ps->size();
- break;
- case Param::REAL:
- return (int)pd->size();
- break;
- default:
- CV_Error(Error::StsInternal, "");
- return -1;
- }
-}
-
-inline std::ostream &operator<<(std::ostream &stream, const DictValue &dictv)
-{
- int i;
-
- if (dictv.isInt())
- {
- for (i = 0; i < dictv.size() - 1; i++)
- stream << dictv.get<int64>(i) << ", ";
- stream << dictv.get<int64>(i);
- }
- else if (dictv.isReal())
- {
- for (i = 0; i < dictv.size() - 1; i++)
- stream << dictv.get<double>(i) << ", ";
- stream << dictv.get<double>(i);
- }
- else if (dictv.isString())
- {
- for (i = 0; i < dictv.size() - 1; i++)
- stream << "\"" << dictv.get<String>(i) << "\", ";
- stream << dictv.get<String>(i);
- }
-
- return stream;
-}
-
-/////////////////////////////////////////////////////////////////
-
-inline bool Dict::has(const String &key) const
-{
- return dict.count(key) != 0;
-}
-
-inline DictValue *Dict::ptr(const String &key)
-{
- _Dict::iterator i = dict.find(key);
- return (i == dict.end()) ? NULL : &i->second;
-}
-
-inline const DictValue &Dict::get(const String &key) const
-{
- _Dict::const_iterator i = dict.find(key);
- if (i == dict.end())
- CV_Error(Error::StsObjectNotFound, "Required argument \"" + key + "\" not found into dictionary");
- return i->second;
-}
-
-template <typename T>
-inline T Dict::get(const String &key) const
-{
- return this->get(key).get<T>();
-}
-
-template <typename T>
-inline T Dict::get(const String &key, const T &defaultValue) const
-{
- _Dict::const_iterator i = dict.find(key);
-
- if (i != dict.end())
- return i->second.get<T>();
- else
- return defaultValue;
-}
-
-template<typename T>
-inline const T &Dict::set(const String &key, const T &value)
-{
- _Dict::iterator i = dict.find(key);
-
- if (i != dict.end())
- i->second = DictValue(value);
- else
- dict.insert(std::make_pair(key, DictValue(value)));
-
- return value;
-}
-
-inline std::ostream &operator<<(std::ostream &stream, const Dict &dict)
-{
- Dict::_Dict::const_iterator it;
- for (it = dict.dict.begin(); it != dict.dict.end(); it++)
- stream << it->first << " : " << it->second << "\n";
-
- return stream;
-}
-
-}
-}
-
-#endif
diff --git a/contrib/modules/dnn/include/opencv2/dnn/layer.hpp b/contrib/modules/dnn/include/opencv2/dnn/layer.hpp
deleted file mode 100644
index e051041..0000000
--- a/contrib/modules/dnn/include/opencv2/dnn/layer.hpp
+++ /dev/null
@@ -1,148 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_LAYER_HPP__
-#define __OPENCV_DNN_LAYER_HPP__
-#include <opencv2/dnn.hpp>
-
-namespace cv
-{
-namespace dnn
-{
-//! @addtogroup dnn
-//! @{
-//!
-//! @defgroup dnnLayerFactory Utilities for New Layers Registration
-//! @{
-
-/** @brief %Layer factory allows to create instances of registered layers. */
-class CV_EXPORTS LayerFactory
-{
-public:
-
- //! Each Layer class must provide this function to the factory
- typedef Ptr<Layer>(*Constuctor)(LayerParams ¶ms);
-
- //! Registers the layer class with typename @p type and specified @p constructor.
- static void registerLayer(const String &type, Constuctor constructor);
-
- //! Unregisters registered layer with specified type name.
- static void unregisterLayer(const String &type);
-
- /** @brief Creates instance of registered layer.
- * @param type type name of creating layer.
- * @param params parameters which will be used for layer initialization.
- */
- static Ptr<Layer> createLayerInstance(const String &type, LayerParams& params);
-
-private:
- LayerFactory();
-
- struct Impl;
- static Ptr<Impl> impl();
-};
-
-/** @brief Registers layer constructor in runtime.
-* @param type string, containing type name of the layer.
-* @param constuctorFunc pointer to the function of type LayerRegister::Constuctor, which creates the layer.
-* @details This macros must be placed inside the function code.
-*/
-#define REG_RUNTIME_LAYER_FUNC(type, constuctorFunc) \
- cv::dnn::LayerFactory::registerLayer(#type, constuctorFunc);
-
-/** @brief Registers layer class in runtime.
- * @param type string, containing type name of the layer.
- * @param class C++ class, derived from Layer.
- * @details This macros must be placed inside the function code.
- */
-#define REG_RUNTIME_LAYER_CLASS(type, class) \
- cv::dnn::LayerFactory::registerLayer(#type, _layerDynamicRegisterer<class>);
-
-/** @brief Registers layer constructor on module load time.
-* @param type string, containing type name of the layer.
-* @param constuctorFunc pointer to the function of type LayerRegister::Constuctor, which creates the layer.
-* @details This macros must be placed outside the function code.
-*/
-#define REG_STATIC_LAYER_FUNC(type, constuctorFunc) \
-static cv::dnn::_LayerStaticRegisterer __LayerStaticRegisterer_##type(#type, constuctorFunc);
-
-/** @brief Registers layer class on module load time.
- * @param type string, containing type name of the layer.
- * @param class C++ class, derived from Layer.
- * @details This macros must be placed outside the function code.
- */
-#define REG_STATIC_LAYER_CLASS(type, class) \
-Ptr<Layer> __LayerStaticRegisterer_func_##type(LayerParams ¶ms) \
- { return Ptr<Layer>(new class(params)); } \
-static _LayerStaticRegisterer __LayerStaticRegisterer_##type(#type, __LayerStaticRegisterer_func_##type);
-
-
-//! @}
-//! @}
-
-
-template<typename LayerClass>
-Ptr<Layer> _layerDynamicRegisterer(LayerParams ¶ms)
-{
- return Ptr<Layer>(new LayerClass(params));
-}
-
-//allows automatically register created layer on module load time
-class _LayerStaticRegisterer
-{
- String type;
-public:
-
- _LayerStaticRegisterer(const String &layerType, LayerFactory::Constuctor layerConstuctor)
- {
- this->type = layerType;
- LayerFactory::registerLayer(layerType, layerConstuctor);
- }
-
- ~_LayerStaticRegisterer()
- {
- LayerFactory::unregisterLayer(type);
- }
-};
-
-}
-}
-#endif
diff --git a/contrib/modules/dnn/include/opencv2/dnn/shape_utils.hpp b/contrib/modules/dnn/include/opencv2/dnn/shape_utils.hpp
deleted file mode 100644
index f52e5b9..0000000
--- a/contrib/modules/dnn/include/opencv2/dnn/shape_utils.hpp
+++ /dev/null
@@ -1,137 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_DNN_SHAPE_UTILS_HPP__
-#define __OPENCV_DNN_DNN_SHAPE_UTILS_HPP__
-
-#include <opencv2/core.hpp>
-#include <ostream>
-
-namespace cv {
-namespace dnn {
-
-//Useful shortcut
-typedef BlobShape Shape;
-
-inline std::ostream &operator<< (std::ostream &s, cv::Range &r)
-{
- return s << "[" << r.start << ", " << r.end << ")";
-}
-
-//Reshaping
-//TODO: add -1 specifier for automatic size inferring
-
-template<typename Mat>
-void reshape(Mat &m, const BlobShape &shape)
-{
- m = m.reshape(1, shape.dims(), shape.ptr());
-}
-
-template<typename Mat>
-Mat reshaped(const Mat &m, const BlobShape &shape)
-{
- return m.reshape(1, shape.dims(), shape.ptr());
-}
-
-
-//Slicing
-
-struct _Range : public cv::Range
-{
- _Range(const Range &r) : cv::Range(r) {}
- _Range(int start, int size = 1) : cv::Range(start, start + size) {}
-};
-
-template<typename Mat>
-Mat slice(const Mat &m, const _Range &r0)
-{
- //CV_Assert(m.dims >= 1);
- cv::AutoBuffer<cv::Range, 4> ranges(m.dims);
- for (int i = 1; i < m.dims; i++)
- ranges[i] = Range::all();
- ranges[0] = r0;
- return m(&ranges[0]);
-}
-
-template<typename Mat>
-Mat slice(const Mat &m, const _Range &r0, const _Range &r1)
-{
- CV_Assert(m.dims >= 2);
- cv::AutoBuffer<cv::Range, 4> ranges(m.dims);
- for (int i = 2; i < m.dims; i++)
- ranges[i] = Range::all();
- ranges[0] = r0;
- ranges[1] = r1;
- return m(&ranges[0]);
-}
-
-template<typename Mat>
-Mat slice(const Mat &m, const _Range &r0, const _Range &r1, const _Range &r2)
-{
- CV_Assert(m.dims <= 3);
- cv::AutoBuffer<cv::Range, 4> ranges(m.dims);
- for (int i = 3; i < m.dims; i++)
- ranges[i] = Range::all();
- ranges[0] = r0;
- ranges[1] = r1;
- ranges[2] = r2;
- return m(&ranges[0]);
-}
-
-template<typename Mat>
-Mat slice(const Mat &m, const _Range &r0, const _Range &r1, const _Range &r2, const _Range &r3)
-{
- CV_Assert(m.dims <= 4);
- cv::AutoBuffer<cv::Range, 4> ranges(m.dims);
- for (int i = 4; i < m.dims; i++)
- ranges[i] = Range::all();
- ranges[0] = r0;
- ranges[1] = r1;
- ranges[2] = r2;
- ranges[3] = r3;
- return m(&ranges[0]);
-}
-
-BlobShape computeShapeByReshapeMask(const BlobShape &srcShape, const BlobShape &maskShape, Range srcRange = Range::all());
-
-}
-}
-#endif
diff --git a/contrib/modules/dnn/misc/caffe/caffe.pb.cc b/contrib/modules/dnn/misc/caffe/caffe.pb.cc
deleted file mode 100644
index 7bd91f1..0000000
--- a/contrib/modules/dnn/misc/caffe/caffe.pb.cc
+++ /dev/null
@@ -1,45683 +0,0 @@
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: caffe.proto
-
-#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
-#include "caffe.pb.h"
-
-#include <algorithm>
-
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/port.h>
-#include <google/protobuf/stubs/once.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/wire_format_lite_inl.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/reflection_ops.h>
-#include <google/protobuf/wire_format.h>
-// @@protoc_insertion_point(includes)
-
-namespace caffe {
-
-namespace {
-
-const ::google::protobuf::Descriptor* BlobShape_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- BlobShape_reflection_ = NULL;
-const ::google::protobuf::Descriptor* BlobProto_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- BlobProto_reflection_ = NULL;
-const ::google::protobuf::Descriptor* BlobProtoVector_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- BlobProtoVector_reflection_ = NULL;
-const ::google::protobuf::Descriptor* CropParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- CropParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* PermuteParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- PermuteParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* NormalizeBBoxParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- NormalizeBBoxParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* PriorBoxParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- PriorBoxParameter_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* PriorBoxParameter_CodeType_descriptor_ = NULL;
-const ::google::protobuf::Descriptor* DetectionOutputParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- DetectionOutputParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* Datum_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- Datum_reflection_ = NULL;
-const ::google::protobuf::Descriptor* FillerParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- FillerParameter_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* FillerParameter_VarianceNorm_descriptor_ = NULL;
-const ::google::protobuf::Descriptor* NetParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- NetParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* SolverParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- SolverParameter_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* SolverParameter_SolverMode_descriptor_ = NULL;
-const ::google::protobuf::EnumDescriptor* SolverParameter_SolverType_descriptor_ = NULL;
-const ::google::protobuf::Descriptor* SolverState_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- SolverState_reflection_ = NULL;
-const ::google::protobuf::Descriptor* NetState_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- NetState_reflection_ = NULL;
-const ::google::protobuf::Descriptor* NetStateRule_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- NetStateRule_reflection_ = NULL;
-const ::google::protobuf::Descriptor* ParamSpec_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- ParamSpec_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* ParamSpec_DimCheckMode_descriptor_ = NULL;
-const ::google::protobuf::Descriptor* LayerParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- LayerParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* TransformationParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- TransformationParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* LossParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- LossParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* AccuracyParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- AccuracyParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* ArgMaxParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- ArgMaxParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* ConcatParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- ConcatParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* ContrastiveLossParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- ContrastiveLossParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* ConvolutionParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- ConvolutionParameter_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* ConvolutionParameter_Engine_descriptor_ = NULL;
-const ::google::protobuf::Descriptor* DataParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- DataParameter_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* DataParameter_DB_descriptor_ = NULL;
-const ::google::protobuf::Descriptor* DropoutParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- DropoutParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* DummyDataParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- DummyDataParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* EltwiseParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- EltwiseParameter_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* EltwiseParameter_EltwiseOp_descriptor_ = NULL;
-const ::google::protobuf::Descriptor* ExpParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- ExpParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* FlattenParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- FlattenParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* HDF5DataParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- HDF5DataParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* HDF5OutputParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- HDF5OutputParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* HingeLossParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- HingeLossParameter_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* HingeLossParameter_Norm_descriptor_ = NULL;
-const ::google::protobuf::Descriptor* ImageDataParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- ImageDataParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* InfogainLossParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- InfogainLossParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* InnerProductParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- InnerProductParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* LogParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- LogParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* LRNParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- LRNParameter_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* LRNParameter_NormRegion_descriptor_ = NULL;
-const ::google::protobuf::Descriptor* MemoryDataParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- MemoryDataParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* MVNParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- MVNParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* PoolingParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- PoolingParameter_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* PoolingParameter_PoolMethod_descriptor_ = NULL;
-const ::google::protobuf::EnumDescriptor* PoolingParameter_Engine_descriptor_ = NULL;
-const ::google::protobuf::Descriptor* PowerParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- PowerParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* PythonParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- PythonParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* ReductionParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- ReductionParameter_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* ReductionParameter_ReductionOp_descriptor_ = NULL;
-const ::google::protobuf::Descriptor* ReLUParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- ReLUParameter_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* ReLUParameter_Engine_descriptor_ = NULL;
-const ::google::protobuf::Descriptor* ReshapeParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- ReshapeParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* SigmoidParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- SigmoidParameter_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* SigmoidParameter_Engine_descriptor_ = NULL;
-const ::google::protobuf::Descriptor* SliceParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- SliceParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* SoftmaxParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- SoftmaxParameter_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* SoftmaxParameter_Engine_descriptor_ = NULL;
-const ::google::protobuf::Descriptor* TanHParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- TanHParameter_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* TanHParameter_Engine_descriptor_ = NULL;
-const ::google::protobuf::Descriptor* ThresholdParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- ThresholdParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* WindowDataParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- WindowDataParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* SPPParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- SPPParameter_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* SPPParameter_PoolMethod_descriptor_ = NULL;
-const ::google::protobuf::EnumDescriptor* SPPParameter_Engine_descriptor_ = NULL;
-const ::google::protobuf::Descriptor* V1LayerParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- V1LayerParameter_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* V1LayerParameter_LayerType_descriptor_ = NULL;
-const ::google::protobuf::EnumDescriptor* V1LayerParameter_DimCheckMode_descriptor_ = NULL;
-const ::google::protobuf::Descriptor* V0LayerParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- V0LayerParameter_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* V0LayerParameter_PoolMethod_descriptor_ = NULL;
-const ::google::protobuf::Descriptor* PReLUParameter_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- PReLUParameter_reflection_ = NULL;
-const ::google::protobuf::Descriptor* NormalizedBBox_descriptor_ = NULL;
-const ::google::protobuf::internal::GeneratedMessageReflection*
- NormalizedBBox_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* Phase_descriptor_ = NULL;
-
-} // namespace
-
-
-void protobuf_AssignDesc_caffe_2eproto() GOOGLE_ATTRIBUTE_COLD;
-void protobuf_AssignDesc_caffe_2eproto() {
- protobuf_AddDesc_caffe_2eproto();
- const ::google::protobuf::FileDescriptor* file =
- ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
- "caffe.proto");
- GOOGLE_CHECK(file != NULL);
- BlobShape_descriptor_ = file->message_type(0);
- static const int BlobShape_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobShape, dim_),
- };
- BlobShape_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- BlobShape_descriptor_,
- BlobShape::internal_default_instance(),
- BlobShape_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobShape, _has_bits_),
- -1,
- -1,
- sizeof(BlobShape),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobShape, _internal_metadata_));
- BlobProto_descriptor_ = file->message_type(1);
- static const int BlobProto_offsets_[7] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, shape_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, data_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, diff_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, num_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, channels_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, height_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, width_),
- };
- BlobProto_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- BlobProto_descriptor_,
- BlobProto::internal_default_instance(),
- BlobProto_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, _has_bits_),
- -1,
- -1,
- sizeof(BlobProto),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, _internal_metadata_));
- BlobProtoVector_descriptor_ = file->message_type(2);
- static const int BlobProtoVector_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProtoVector, blobs_),
- };
- BlobProtoVector_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- BlobProtoVector_descriptor_,
- BlobProtoVector::internal_default_instance(),
- BlobProtoVector_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProtoVector, _has_bits_),
- -1,
- -1,
- sizeof(BlobProtoVector),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProtoVector, _internal_metadata_));
- CropParameter_descriptor_ = file->message_type(3);
- static const int CropParameter_offsets_[2] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CropParameter, axis_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CropParameter, offset_),
- };
- CropParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- CropParameter_descriptor_,
- CropParameter::internal_default_instance(),
- CropParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CropParameter, _has_bits_),
- -1,
- -1,
- sizeof(CropParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CropParameter, _internal_metadata_));
- PermuteParameter_descriptor_ = file->message_type(4);
- static const int PermuteParameter_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PermuteParameter, order_),
- };
- PermuteParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- PermuteParameter_descriptor_,
- PermuteParameter::internal_default_instance(),
- PermuteParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PermuteParameter, _has_bits_),
- -1,
- -1,
- sizeof(PermuteParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PermuteParameter, _internal_metadata_));
- NormalizeBBoxParameter_descriptor_ = file->message_type(5);
- static const int NormalizeBBoxParameter_offsets_[4] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizeBBoxParameter, across_spatial_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizeBBoxParameter, scale_filler_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizeBBoxParameter, channel_shared_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizeBBoxParameter, eps_),
- };
- NormalizeBBoxParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- NormalizeBBoxParameter_descriptor_,
- NormalizeBBoxParameter::internal_default_instance(),
- NormalizeBBoxParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizeBBoxParameter, _has_bits_),
- -1,
- -1,
- sizeof(NormalizeBBoxParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizeBBoxParameter, _internal_metadata_));
- PriorBoxParameter_descriptor_ = file->message_type(6);
- static const int PriorBoxParameter_offsets_[6] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, min_size_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, max_size_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, aspect_ratio_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, flip_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, clip_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, variance_),
- };
- PriorBoxParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- PriorBoxParameter_descriptor_,
- PriorBoxParameter::internal_default_instance(),
- PriorBoxParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, _has_bits_),
- -1,
- -1,
- sizeof(PriorBoxParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, _internal_metadata_));
- PriorBoxParameter_CodeType_descriptor_ = PriorBoxParameter_descriptor_->enum_type(0);
- DetectionOutputParameter_descriptor_ = file->message_type(7);
- static const int DetectionOutputParameter_offsets_[9] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, num_classes_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, share_location_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, background_label_id_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, code_type_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, variance_encoded_in_target_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, keep_top_k_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, confidence_threshold_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, nms_threshold_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, top_k_),
- };
- DetectionOutputParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- DetectionOutputParameter_descriptor_,
- DetectionOutputParameter::internal_default_instance(),
- DetectionOutputParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, _has_bits_),
- -1,
- -1,
- sizeof(DetectionOutputParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, _internal_metadata_));
- Datum_descriptor_ = file->message_type(8);
- static const int Datum_offsets_[7] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Datum, channels_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Datum, height_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Datum, width_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Datum, data_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Datum, label_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Datum, float_data_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Datum, encoded_),
- };
- Datum_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- Datum_descriptor_,
- Datum::internal_default_instance(),
- Datum_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Datum, _has_bits_),
- -1,
- -1,
- sizeof(Datum),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Datum, _internal_metadata_));
- FillerParameter_descriptor_ = file->message_type(9);
- static const int FillerParameter_offsets_[8] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, type_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, value_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, min_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, max_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, mean_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, std_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, sparse_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, variance_norm_),
- };
- FillerParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- FillerParameter_descriptor_,
- FillerParameter::internal_default_instance(),
- FillerParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, _has_bits_),
- -1,
- -1,
- sizeof(FillerParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, _internal_metadata_));
- FillerParameter_VarianceNorm_descriptor_ = FillerParameter_descriptor_->enum_type(0);
- NetParameter_descriptor_ = file->message_type(10);
- static const int NetParameter_offsets_[9] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, input_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, input_shape_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, input_dim_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, force_backward_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, state_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, debug_info_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, layer_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, layers_),
- };
- NetParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- NetParameter_descriptor_,
- NetParameter::internal_default_instance(),
- NetParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, _has_bits_),
- -1,
- -1,
- sizeof(NetParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, _internal_metadata_));
- SolverParameter_descriptor_ = file->message_type(11);
- static const int SolverParameter_offsets_[36] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, net_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, net_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, train_net_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, test_net_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, train_net_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, test_net_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, train_state_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, test_state_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, test_iter_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, test_interval_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, test_compute_loss_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, test_initialization_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, base_lr_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, display_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, average_loss_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, max_iter_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, iter_size_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, lr_policy_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, gamma_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, power_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, momentum_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, weight_decay_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, regularization_type_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, stepsize_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, stepvalue_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, clip_gradients_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, snapshot_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, snapshot_prefix_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, snapshot_diff_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, solver_mode_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, device_id_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, random_seed_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, solver_type_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, delta_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, debug_info_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, snapshot_after_train_),
- };
- SolverParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- SolverParameter_descriptor_,
- SolverParameter::internal_default_instance(),
- SolverParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, _has_bits_),
- -1,
- -1,
- sizeof(SolverParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, _internal_metadata_));
- SolverParameter_SolverMode_descriptor_ = SolverParameter_descriptor_->enum_type(0);
- SolverParameter_SolverType_descriptor_ = SolverParameter_descriptor_->enum_type(1);
- SolverState_descriptor_ = file->message_type(12);
- static const int SolverState_offsets_[4] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverState, iter_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverState, learned_net_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverState, history_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverState, current_step_),
- };
- SolverState_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- SolverState_descriptor_,
- SolverState::internal_default_instance(),
- SolverState_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverState, _has_bits_),
- -1,
- -1,
- sizeof(SolverState),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverState, _internal_metadata_));
- NetState_descriptor_ = file->message_type(13);
- static const int NetState_offsets_[3] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetState, phase_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetState, level_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetState, stage_),
- };
- NetState_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- NetState_descriptor_,
- NetState::internal_default_instance(),
- NetState_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetState, _has_bits_),
- -1,
- -1,
- sizeof(NetState),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetState, _internal_metadata_));
- NetStateRule_descriptor_ = file->message_type(14);
- static const int NetStateRule_offsets_[5] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetStateRule, phase_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetStateRule, min_level_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetStateRule, max_level_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetStateRule, stage_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetStateRule, not_stage_),
- };
- NetStateRule_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- NetStateRule_descriptor_,
- NetStateRule::internal_default_instance(),
- NetStateRule_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetStateRule, _has_bits_),
- -1,
- -1,
- sizeof(NetStateRule),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetStateRule, _internal_metadata_));
- ParamSpec_descriptor_ = file->message_type(15);
- static const int ParamSpec_offsets_[4] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ParamSpec, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ParamSpec, share_mode_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ParamSpec, lr_mult_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ParamSpec, decay_mult_),
- };
- ParamSpec_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- ParamSpec_descriptor_,
- ParamSpec::internal_default_instance(),
- ParamSpec_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ParamSpec, _has_bits_),
- -1,
- -1,
- sizeof(ParamSpec),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ParamSpec, _internal_metadata_));
- ParamSpec_DimCheckMode_descriptor_ = ParamSpec_descriptor_->enum_type(0);
- LayerParameter_descriptor_ = file->message_type(16);
- static const int LayerParameter_offsets_[53] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, type_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, bottom_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, top_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, phase_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, loss_weight_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, blobs_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, propagate_down_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, include_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, exclude_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, transform_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, loss_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, accuracy_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, argmax_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, concat_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, contrastive_loss_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, convolution_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, crop_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, data_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, detection_output_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, dropout_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, dummy_data_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, eltwise_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, exp_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, flatten_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, hdf5_data_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, hdf5_output_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, hinge_loss_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, image_data_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, infogain_loss_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, inner_product_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, log_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, lrn_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, memory_data_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, mvn_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, normalize_bbox_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, permute_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, pooling_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, power_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, prelu_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, prior_box_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, python_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, reduction_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, relu_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, reshape_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, sigmoid_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, slice_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, softmax_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, spp_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, tanh_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, threshold_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, window_data_param_),
- };
- LayerParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- LayerParameter_descriptor_,
- LayerParameter::internal_default_instance(),
- LayerParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, _has_bits_),
- -1,
- -1,
- sizeof(LayerParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, _internal_metadata_));
- TransformationParameter_descriptor_ = file->message_type(17);
- static const int TransformationParameter_offsets_[7] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TransformationParameter, scale_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TransformationParameter, mirror_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TransformationParameter, crop_size_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TransformationParameter, mean_file_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TransformationParameter, mean_value_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TransformationParameter, force_color_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TransformationParameter, force_gray_),
- };
- TransformationParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- TransformationParameter_descriptor_,
- TransformationParameter::internal_default_instance(),
- TransformationParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TransformationParameter, _has_bits_),
- -1,
- -1,
- sizeof(TransformationParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TransformationParameter, _internal_metadata_));
- LossParameter_descriptor_ = file->message_type(18);
- static const int LossParameter_offsets_[2] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LossParameter, ignore_label_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LossParameter, normalize_),
- };
- LossParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- LossParameter_descriptor_,
- LossParameter::internal_default_instance(),
- LossParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LossParameter, _has_bits_),
- -1,
- -1,
- sizeof(LossParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LossParameter, _internal_metadata_));
- AccuracyParameter_descriptor_ = file->message_type(19);
- static const int AccuracyParameter_offsets_[3] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(AccuracyParameter, top_k_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(AccuracyParameter, axis_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(AccuracyParameter, ignore_label_),
- };
- AccuracyParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- AccuracyParameter_descriptor_,
- AccuracyParameter::internal_default_instance(),
- AccuracyParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(AccuracyParameter, _has_bits_),
- -1,
- -1,
- sizeof(AccuracyParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(AccuracyParameter, _internal_metadata_));
- ArgMaxParameter_descriptor_ = file->message_type(20);
- static const int ArgMaxParameter_offsets_[2] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ArgMaxParameter, out_max_val_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ArgMaxParameter, top_k_),
- };
- ArgMaxParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- ArgMaxParameter_descriptor_,
- ArgMaxParameter::internal_default_instance(),
- ArgMaxParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ArgMaxParameter, _has_bits_),
- -1,
- -1,
- sizeof(ArgMaxParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ArgMaxParameter, _internal_metadata_));
- ConcatParameter_descriptor_ = file->message_type(21);
- static const int ConcatParameter_offsets_[2] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConcatParameter, axis_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConcatParameter, concat_dim_),
- };
- ConcatParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- ConcatParameter_descriptor_,
- ConcatParameter::internal_default_instance(),
- ConcatParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConcatParameter, _has_bits_),
- -1,
- -1,
- sizeof(ConcatParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConcatParameter, _internal_metadata_));
- ContrastiveLossParameter_descriptor_ = file->message_type(22);
- static const int ContrastiveLossParameter_offsets_[2] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ContrastiveLossParameter, margin_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ContrastiveLossParameter, legacy_version_),
- };
- ContrastiveLossParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- ContrastiveLossParameter_descriptor_,
- ContrastiveLossParameter::internal_default_instance(),
- ContrastiveLossParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ContrastiveLossParameter, _has_bits_),
- -1,
- -1,
- sizeof(ContrastiveLossParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ContrastiveLossParameter, _internal_metadata_));
- ConvolutionParameter_descriptor_ = file->message_type(23);
- static const int ConvolutionParameter_offsets_[18] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, num_output_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, bias_term_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, pad_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, pad_h_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, pad_w_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, kernel_size_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, kernel_h_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, kernel_w_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, group_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, stride_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, stride_h_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, stride_w_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, weight_filler_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, bias_filler_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, engine_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, dilation_h_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, dilation_w_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, dilation_),
- };
- ConvolutionParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- ConvolutionParameter_descriptor_,
- ConvolutionParameter::internal_default_instance(),
- ConvolutionParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, _has_bits_),
- -1,
- -1,
- sizeof(ConvolutionParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, _internal_metadata_));
- ConvolutionParameter_Engine_descriptor_ = ConvolutionParameter_descriptor_->enum_type(0);
- DataParameter_descriptor_ = file->message_type(24);
- static const int DataParameter_offsets_[9] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, source_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, batch_size_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, rand_skip_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, backend_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, scale_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, mean_file_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, crop_size_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, mirror_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, force_encoded_color_),
- };
- DataParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- DataParameter_descriptor_,
- DataParameter::internal_default_instance(),
- DataParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, _has_bits_),
- -1,
- -1,
- sizeof(DataParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, _internal_metadata_));
- DataParameter_DB_descriptor_ = DataParameter_descriptor_->enum_type(0);
- DropoutParameter_descriptor_ = file->message_type(25);
- static const int DropoutParameter_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DropoutParameter, dropout_ratio_),
- };
- DropoutParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- DropoutParameter_descriptor_,
- DropoutParameter::internal_default_instance(),
- DropoutParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DropoutParameter, _has_bits_),
- -1,
- -1,
- sizeof(DropoutParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DropoutParameter, _internal_metadata_));
- DummyDataParameter_descriptor_ = file->message_type(26);
- static const int DummyDataParameter_offsets_[6] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DummyDataParameter, data_filler_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DummyDataParameter, shape_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DummyDataParameter, num_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DummyDataParameter, channels_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DummyDataParameter, height_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DummyDataParameter, width_),
- };
- DummyDataParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- DummyDataParameter_descriptor_,
- DummyDataParameter::internal_default_instance(),
- DummyDataParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DummyDataParameter, _has_bits_),
- -1,
- -1,
- sizeof(DummyDataParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DummyDataParameter, _internal_metadata_));
- EltwiseParameter_descriptor_ = file->message_type(27);
- static const int EltwiseParameter_offsets_[3] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EltwiseParameter, operation_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EltwiseParameter, coeff_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EltwiseParameter, stable_prod_grad_),
- };
- EltwiseParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- EltwiseParameter_descriptor_,
- EltwiseParameter::internal_default_instance(),
- EltwiseParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EltwiseParameter, _has_bits_),
- -1,
- -1,
- sizeof(EltwiseParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EltwiseParameter, _internal_metadata_));
- EltwiseParameter_EltwiseOp_descriptor_ = EltwiseParameter_descriptor_->enum_type(0);
- ExpParameter_descriptor_ = file->message_type(28);
- static const int ExpParameter_offsets_[3] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExpParameter, base_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExpParameter, scale_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExpParameter, shift_),
- };
- ExpParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- ExpParameter_descriptor_,
- ExpParameter::internal_default_instance(),
- ExpParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExpParameter, _has_bits_),
- -1,
- -1,
- sizeof(ExpParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExpParameter, _internal_metadata_));
- FlattenParameter_descriptor_ = file->message_type(29);
- static const int FlattenParameter_offsets_[2] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FlattenParameter, axis_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FlattenParameter, end_axis_),
- };
- FlattenParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- FlattenParameter_descriptor_,
- FlattenParameter::internal_default_instance(),
- FlattenParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FlattenParameter, _has_bits_),
- -1,
- -1,
- sizeof(FlattenParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FlattenParameter, _internal_metadata_));
- HDF5DataParameter_descriptor_ = file->message_type(30);
- static const int HDF5DataParameter_offsets_[3] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5DataParameter, source_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5DataParameter, batch_size_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5DataParameter, shuffle_),
- };
- HDF5DataParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- HDF5DataParameter_descriptor_,
- HDF5DataParameter::internal_default_instance(),
- HDF5DataParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5DataParameter, _has_bits_),
- -1,
- -1,
- sizeof(HDF5DataParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5DataParameter, _internal_metadata_));
- HDF5OutputParameter_descriptor_ = file->message_type(31);
- static const int HDF5OutputParameter_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5OutputParameter, file_name_),
- };
- HDF5OutputParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- HDF5OutputParameter_descriptor_,
- HDF5OutputParameter::internal_default_instance(),
- HDF5OutputParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5OutputParameter, _has_bits_),
- -1,
- -1,
- sizeof(HDF5OutputParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5OutputParameter, _internal_metadata_));
- HingeLossParameter_descriptor_ = file->message_type(32);
- static const int HingeLossParameter_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HingeLossParameter, norm_),
- };
- HingeLossParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- HingeLossParameter_descriptor_,
- HingeLossParameter::internal_default_instance(),
- HingeLossParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HingeLossParameter, _has_bits_),
- -1,
- -1,
- sizeof(HingeLossParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HingeLossParameter, _internal_metadata_));
- HingeLossParameter_Norm_descriptor_ = HingeLossParameter_descriptor_->enum_type(0);
- ImageDataParameter_descriptor_ = file->message_type(33);
- static const int ImageDataParameter_offsets_[12] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, source_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, batch_size_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, rand_skip_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, shuffle_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, new_height_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, new_width_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, is_color_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, scale_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, mean_file_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, crop_size_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, mirror_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, root_folder_),
- };
- ImageDataParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- ImageDataParameter_descriptor_,
- ImageDataParameter::internal_default_instance(),
- ImageDataParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, _has_bits_),
- -1,
- -1,
- sizeof(ImageDataParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, _internal_metadata_));
- InfogainLossParameter_descriptor_ = file->message_type(34);
- static const int InfogainLossParameter_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InfogainLossParameter, source_),
- };
- InfogainLossParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- InfogainLossParameter_descriptor_,
- InfogainLossParameter::internal_default_instance(),
- InfogainLossParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InfogainLossParameter, _has_bits_),
- -1,
- -1,
- sizeof(InfogainLossParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InfogainLossParameter, _internal_metadata_));
- InnerProductParameter_descriptor_ = file->message_type(35);
- static const int InnerProductParameter_offsets_[5] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InnerProductParameter, num_output_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InnerProductParameter, bias_term_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InnerProductParameter, weight_filler_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InnerProductParameter, bias_filler_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InnerProductParameter, axis_),
- };
- InnerProductParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- InnerProductParameter_descriptor_,
- InnerProductParameter::internal_default_instance(),
- InnerProductParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InnerProductParameter, _has_bits_),
- -1,
- -1,
- sizeof(InnerProductParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InnerProductParameter, _internal_metadata_));
- LogParameter_descriptor_ = file->message_type(36);
- static const int LogParameter_offsets_[3] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LogParameter, base_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LogParameter, scale_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LogParameter, shift_),
- };
- LogParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- LogParameter_descriptor_,
- LogParameter::internal_default_instance(),
- LogParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LogParameter, _has_bits_),
- -1,
- -1,
- sizeof(LogParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LogParameter, _internal_metadata_));
- LRNParameter_descriptor_ = file->message_type(37);
- static const int LRNParameter_offsets_[5] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LRNParameter, local_size_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LRNParameter, alpha_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LRNParameter, beta_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LRNParameter, norm_region_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LRNParameter, k_),
- };
- LRNParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- LRNParameter_descriptor_,
- LRNParameter::internal_default_instance(),
- LRNParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LRNParameter, _has_bits_),
- -1,
- -1,
- sizeof(LRNParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LRNParameter, _internal_metadata_));
- LRNParameter_NormRegion_descriptor_ = LRNParameter_descriptor_->enum_type(0);
- MemoryDataParameter_descriptor_ = file->message_type(38);
- static const int MemoryDataParameter_offsets_[4] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MemoryDataParameter, batch_size_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MemoryDataParameter, channels_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MemoryDataParameter, height_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MemoryDataParameter, width_),
- };
- MemoryDataParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- MemoryDataParameter_descriptor_,
- MemoryDataParameter::internal_default_instance(),
- MemoryDataParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MemoryDataParameter, _has_bits_),
- -1,
- -1,
- sizeof(MemoryDataParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MemoryDataParameter, _internal_metadata_));
- MVNParameter_descriptor_ = file->message_type(39);
- static const int MVNParameter_offsets_[3] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MVNParameter, normalize_variance_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MVNParameter, across_channels_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MVNParameter, eps_),
- };
- MVNParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- MVNParameter_descriptor_,
- MVNParameter::internal_default_instance(),
- MVNParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MVNParameter, _has_bits_),
- -1,
- -1,
- sizeof(MVNParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MVNParameter, _internal_metadata_));
- PoolingParameter_descriptor_ = file->message_type(40);
- static const int PoolingParameter_offsets_[12] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, pool_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, pad_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, pad_h_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, pad_w_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, kernel_size_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, kernel_h_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, kernel_w_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, stride_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, stride_h_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, stride_w_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, engine_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, global_pooling_),
- };
- PoolingParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- PoolingParameter_descriptor_,
- PoolingParameter::internal_default_instance(),
- PoolingParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, _has_bits_),
- -1,
- -1,
- sizeof(PoolingParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, _internal_metadata_));
- PoolingParameter_PoolMethod_descriptor_ = PoolingParameter_descriptor_->enum_type(0);
- PoolingParameter_Engine_descriptor_ = PoolingParameter_descriptor_->enum_type(1);
- PowerParameter_descriptor_ = file->message_type(41);
- static const int PowerParameter_offsets_[3] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PowerParameter, power_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PowerParameter, scale_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PowerParameter, shift_),
- };
- PowerParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- PowerParameter_descriptor_,
- PowerParameter::internal_default_instance(),
- PowerParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PowerParameter, _has_bits_),
- -1,
- -1,
- sizeof(PowerParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PowerParameter, _internal_metadata_));
- PythonParameter_descriptor_ = file->message_type(42);
- static const int PythonParameter_offsets_[2] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PythonParameter, module_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PythonParameter, layer_),
- };
- PythonParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- PythonParameter_descriptor_,
- PythonParameter::internal_default_instance(),
- PythonParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PythonParameter, _has_bits_),
- -1,
- -1,
- sizeof(PythonParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PythonParameter, _internal_metadata_));
- ReductionParameter_descriptor_ = file->message_type(43);
- static const int ReductionParameter_offsets_[3] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReductionParameter, operation_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReductionParameter, axis_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReductionParameter, coeff_),
- };
- ReductionParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- ReductionParameter_descriptor_,
- ReductionParameter::internal_default_instance(),
- ReductionParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReductionParameter, _has_bits_),
- -1,
- -1,
- sizeof(ReductionParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReductionParameter, _internal_metadata_));
- ReductionParameter_ReductionOp_descriptor_ = ReductionParameter_descriptor_->enum_type(0);
- ReLUParameter_descriptor_ = file->message_type(44);
- static const int ReLUParameter_offsets_[2] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReLUParameter, negative_slope_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReLUParameter, engine_),
- };
- ReLUParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- ReLUParameter_descriptor_,
- ReLUParameter::internal_default_instance(),
- ReLUParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReLUParameter, _has_bits_),
- -1,
- -1,
- sizeof(ReLUParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReLUParameter, _internal_metadata_));
- ReLUParameter_Engine_descriptor_ = ReLUParameter_descriptor_->enum_type(0);
- ReshapeParameter_descriptor_ = file->message_type(45);
- static const int ReshapeParameter_offsets_[3] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReshapeParameter, shape_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReshapeParameter, axis_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReshapeParameter, num_axes_),
- };
- ReshapeParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- ReshapeParameter_descriptor_,
- ReshapeParameter::internal_default_instance(),
- ReshapeParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReshapeParameter, _has_bits_),
- -1,
- -1,
- sizeof(ReshapeParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReshapeParameter, _internal_metadata_));
- SigmoidParameter_descriptor_ = file->message_type(46);
- static const int SigmoidParameter_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SigmoidParameter, engine_),
- };
- SigmoidParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- SigmoidParameter_descriptor_,
- SigmoidParameter::internal_default_instance(),
- SigmoidParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SigmoidParameter, _has_bits_),
- -1,
- -1,
- sizeof(SigmoidParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SigmoidParameter, _internal_metadata_));
- SigmoidParameter_Engine_descriptor_ = SigmoidParameter_descriptor_->enum_type(0);
- SliceParameter_descriptor_ = file->message_type(47);
- static const int SliceParameter_offsets_[3] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SliceParameter, axis_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SliceParameter, slice_point_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SliceParameter, slice_dim_),
- };
- SliceParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- SliceParameter_descriptor_,
- SliceParameter::internal_default_instance(),
- SliceParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SliceParameter, _has_bits_),
- -1,
- -1,
- sizeof(SliceParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SliceParameter, _internal_metadata_));
- SoftmaxParameter_descriptor_ = file->message_type(48);
- static const int SoftmaxParameter_offsets_[2] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SoftmaxParameter, engine_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SoftmaxParameter, axis_),
- };
- SoftmaxParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- SoftmaxParameter_descriptor_,
- SoftmaxParameter::internal_default_instance(),
- SoftmaxParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SoftmaxParameter, _has_bits_),
- -1,
- -1,
- sizeof(SoftmaxParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SoftmaxParameter, _internal_metadata_));
- SoftmaxParameter_Engine_descriptor_ = SoftmaxParameter_descriptor_->enum_type(0);
- TanHParameter_descriptor_ = file->message_type(49);
- static const int TanHParameter_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TanHParameter, engine_),
- };
- TanHParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- TanHParameter_descriptor_,
- TanHParameter::internal_default_instance(),
- TanHParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TanHParameter, _has_bits_),
- -1,
- -1,
- sizeof(TanHParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TanHParameter, _internal_metadata_));
- TanHParameter_Engine_descriptor_ = TanHParameter_descriptor_->enum_type(0);
- ThresholdParameter_descriptor_ = file->message_type(50);
- static const int ThresholdParameter_offsets_[1] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ThresholdParameter, threshold_),
- };
- ThresholdParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- ThresholdParameter_descriptor_,
- ThresholdParameter::internal_default_instance(),
- ThresholdParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ThresholdParameter, _has_bits_),
- -1,
- -1,
- sizeof(ThresholdParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ThresholdParameter, _internal_metadata_));
- WindowDataParameter_descriptor_ = file->message_type(51);
- static const int WindowDataParameter_offsets_[13] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, source_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, scale_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, mean_file_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, batch_size_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, crop_size_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, mirror_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, fg_threshold_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, bg_threshold_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, fg_fraction_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, context_pad_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, crop_mode_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, cache_images_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, root_folder_),
- };
- WindowDataParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- WindowDataParameter_descriptor_,
- WindowDataParameter::internal_default_instance(),
- WindowDataParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, _has_bits_),
- -1,
- -1,
- sizeof(WindowDataParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, _internal_metadata_));
- SPPParameter_descriptor_ = file->message_type(52);
- static const int SPPParameter_offsets_[3] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SPPParameter, pyramid_height_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SPPParameter, pool_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SPPParameter, engine_),
- };
- SPPParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- SPPParameter_descriptor_,
- SPPParameter::internal_default_instance(),
- SPPParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SPPParameter, _has_bits_),
- -1,
- -1,
- sizeof(SPPParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SPPParameter, _internal_metadata_));
- SPPParameter_PoolMethod_descriptor_ = SPPParameter_descriptor_->enum_type(0);
- SPPParameter_Engine_descriptor_ = SPPParameter_descriptor_->enum_type(1);
- V1LayerParameter_descriptor_ = file->message_type(53);
- static const int V1LayerParameter_offsets_[43] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, bottom_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, top_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, include_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, exclude_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, type_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, blobs_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, blob_share_mode_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, blobs_lr_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, weight_decay_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, loss_weight_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, accuracy_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, argmax_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, concat_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, contrastive_loss_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, convolution_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, data_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, dropout_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, dummy_data_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, eltwise_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, exp_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, hdf5_data_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, hdf5_output_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, hinge_loss_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, image_data_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, infogain_loss_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, inner_product_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, lrn_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, memory_data_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, mvn_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, pooling_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, power_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, relu_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, sigmoid_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, softmax_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, slice_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, tanh_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, threshold_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, window_data_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, transform_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, loss_param_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, layer_),
- };
- V1LayerParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- V1LayerParameter_descriptor_,
- V1LayerParameter::internal_default_instance(),
- V1LayerParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, _has_bits_),
- -1,
- -1,
- sizeof(V1LayerParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, _internal_metadata_));
- V1LayerParameter_LayerType_descriptor_ = V1LayerParameter_descriptor_->enum_type(0);
- V1LayerParameter_DimCheckMode_descriptor_ = V1LayerParameter_descriptor_->enum_type(1);
- V0LayerParameter_descriptor_ = file->message_type(54);
- static const int V0LayerParameter_offsets_[38] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, name_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, type_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, num_output_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, biasterm_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, weight_filler_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, bias_filler_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, pad_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, kernelsize_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, group_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, stride_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, pool_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, dropout_ratio_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, local_size_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, alpha_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, beta_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, k_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, source_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, scale_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, meanfile_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, batchsize_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, cropsize_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, mirror_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, blobs_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, blobs_lr_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, weight_decay_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, rand_skip_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, det_fg_threshold_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, det_bg_threshold_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, det_fg_fraction_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, det_context_pad_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, det_crop_mode_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, new_num_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, new_channels_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, new_height_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, new_width_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, shuffle_images_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, concat_dim_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, hdf5_output_param_),
- };
- V0LayerParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- V0LayerParameter_descriptor_,
- V0LayerParameter::internal_default_instance(),
- V0LayerParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, _has_bits_),
- -1,
- -1,
- sizeof(V0LayerParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, _internal_metadata_));
- V0LayerParameter_PoolMethod_descriptor_ = V0LayerParameter_descriptor_->enum_type(0);
- PReLUParameter_descriptor_ = file->message_type(55);
- static const int PReLUParameter_offsets_[2] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PReLUParameter, filler_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PReLUParameter, channel_shared_),
- };
- PReLUParameter_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- PReLUParameter_descriptor_,
- PReLUParameter::internal_default_instance(),
- PReLUParameter_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PReLUParameter, _has_bits_),
- -1,
- -1,
- sizeof(PReLUParameter),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PReLUParameter, _internal_metadata_));
- NormalizedBBox_descriptor_ = file->message_type(56);
- static const int NormalizedBBox_offsets_[8] = {
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, xmin_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, ymin_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, xmax_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, ymax_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, label_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, difficult_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, score_),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, size_),
- };
- NormalizedBBox_reflection_ =
- ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
- NormalizedBBox_descriptor_,
- NormalizedBBox::internal_default_instance(),
- NormalizedBBox_offsets_,
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, _has_bits_),
- -1,
- -1,
- sizeof(NormalizedBBox),
- GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, _internal_metadata_));
- Phase_descriptor_ = file->enum_type(0);
-}
-
-namespace {
-
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
-void protobuf_AssignDescriptorsOnce() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
- &protobuf_AssignDesc_caffe_2eproto);
-}
-
-void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;
-void protobuf_RegisterTypes(const ::std::string&) {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- BlobShape_descriptor_, BlobShape::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- BlobProto_descriptor_, BlobProto::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- BlobProtoVector_descriptor_, BlobProtoVector::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- CropParameter_descriptor_, CropParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- PermuteParameter_descriptor_, PermuteParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- NormalizeBBoxParameter_descriptor_, NormalizeBBoxParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- PriorBoxParameter_descriptor_, PriorBoxParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- DetectionOutputParameter_descriptor_, DetectionOutputParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- Datum_descriptor_, Datum::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- FillerParameter_descriptor_, FillerParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- NetParameter_descriptor_, NetParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- SolverParameter_descriptor_, SolverParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- SolverState_descriptor_, SolverState::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- NetState_descriptor_, NetState::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- NetStateRule_descriptor_, NetStateRule::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- ParamSpec_descriptor_, ParamSpec::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- LayerParameter_descriptor_, LayerParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- TransformationParameter_descriptor_, TransformationParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- LossParameter_descriptor_, LossParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- AccuracyParameter_descriptor_, AccuracyParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- ArgMaxParameter_descriptor_, ArgMaxParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- ConcatParameter_descriptor_, ConcatParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- ContrastiveLossParameter_descriptor_, ContrastiveLossParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- ConvolutionParameter_descriptor_, ConvolutionParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- DataParameter_descriptor_, DataParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- DropoutParameter_descriptor_, DropoutParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- DummyDataParameter_descriptor_, DummyDataParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- EltwiseParameter_descriptor_, EltwiseParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- ExpParameter_descriptor_, ExpParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- FlattenParameter_descriptor_, FlattenParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- HDF5DataParameter_descriptor_, HDF5DataParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- HDF5OutputParameter_descriptor_, HDF5OutputParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- HingeLossParameter_descriptor_, HingeLossParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- ImageDataParameter_descriptor_, ImageDataParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- InfogainLossParameter_descriptor_, InfogainLossParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- InnerProductParameter_descriptor_, InnerProductParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- LogParameter_descriptor_, LogParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- LRNParameter_descriptor_, LRNParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- MemoryDataParameter_descriptor_, MemoryDataParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- MVNParameter_descriptor_, MVNParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- PoolingParameter_descriptor_, PoolingParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- PowerParameter_descriptor_, PowerParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- PythonParameter_descriptor_, PythonParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- ReductionParameter_descriptor_, ReductionParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- ReLUParameter_descriptor_, ReLUParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- ReshapeParameter_descriptor_, ReshapeParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- SigmoidParameter_descriptor_, SigmoidParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- SliceParameter_descriptor_, SliceParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- SoftmaxParameter_descriptor_, SoftmaxParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- TanHParameter_descriptor_, TanHParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- ThresholdParameter_descriptor_, ThresholdParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- WindowDataParameter_descriptor_, WindowDataParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- SPPParameter_descriptor_, SPPParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- V1LayerParameter_descriptor_, V1LayerParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- V0LayerParameter_descriptor_, V0LayerParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- PReLUParameter_descriptor_, PReLUParameter::internal_default_instance());
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
- NormalizedBBox_descriptor_, NormalizedBBox::internal_default_instance());
-}
-
-} // namespace
-
-void protobuf_ShutdownFile_caffe_2eproto() {
- BlobShape_default_instance_.Shutdown();
- delete BlobShape_reflection_;
- BlobProto_default_instance_.Shutdown();
- delete BlobProto_reflection_;
- BlobProtoVector_default_instance_.Shutdown();
- delete BlobProtoVector_reflection_;
- CropParameter_default_instance_.Shutdown();
- delete CropParameter_reflection_;
- PermuteParameter_default_instance_.Shutdown();
- delete PermuteParameter_reflection_;
- NormalizeBBoxParameter_default_instance_.Shutdown();
- delete NormalizeBBoxParameter_reflection_;
- PriorBoxParameter_default_instance_.Shutdown();
- delete PriorBoxParameter_reflection_;
- DetectionOutputParameter_default_instance_.Shutdown();
- delete DetectionOutputParameter_reflection_;
- Datum_default_instance_.Shutdown();
- delete Datum_reflection_;
- FillerParameter_default_instance_.Shutdown();
- delete FillerParameter_reflection_;
- delete FillerParameter::_default_type_;
- NetParameter_default_instance_.Shutdown();
- delete NetParameter_reflection_;
- SolverParameter_default_instance_.Shutdown();
- delete SolverParameter_reflection_;
- delete SolverParameter::_default_regularization_type_;
- SolverState_default_instance_.Shutdown();
- delete SolverState_reflection_;
- NetState_default_instance_.Shutdown();
- delete NetState_reflection_;
- NetStateRule_default_instance_.Shutdown();
- delete NetStateRule_reflection_;
- ParamSpec_default_instance_.Shutdown();
- delete ParamSpec_reflection_;
- LayerParameter_default_instance_.Shutdown();
- delete LayerParameter_reflection_;
- TransformationParameter_default_instance_.Shutdown();
- delete TransformationParameter_reflection_;
- LossParameter_default_instance_.Shutdown();
- delete LossParameter_reflection_;
- AccuracyParameter_default_instance_.Shutdown();
- delete AccuracyParameter_reflection_;
- ArgMaxParameter_default_instance_.Shutdown();
- delete ArgMaxParameter_reflection_;
- ConcatParameter_default_instance_.Shutdown();
- delete ConcatParameter_reflection_;
- ContrastiveLossParameter_default_instance_.Shutdown();
- delete ContrastiveLossParameter_reflection_;
- ConvolutionParameter_default_instance_.Shutdown();
- delete ConvolutionParameter_reflection_;
- DataParameter_default_instance_.Shutdown();
- delete DataParameter_reflection_;
- DropoutParameter_default_instance_.Shutdown();
- delete DropoutParameter_reflection_;
- DummyDataParameter_default_instance_.Shutdown();
- delete DummyDataParameter_reflection_;
- EltwiseParameter_default_instance_.Shutdown();
- delete EltwiseParameter_reflection_;
- ExpParameter_default_instance_.Shutdown();
- delete ExpParameter_reflection_;
- FlattenParameter_default_instance_.Shutdown();
- delete FlattenParameter_reflection_;
- HDF5DataParameter_default_instance_.Shutdown();
- delete HDF5DataParameter_reflection_;
- HDF5OutputParameter_default_instance_.Shutdown();
- delete HDF5OutputParameter_reflection_;
- HingeLossParameter_default_instance_.Shutdown();
- delete HingeLossParameter_reflection_;
- ImageDataParameter_default_instance_.Shutdown();
- delete ImageDataParameter_reflection_;
- InfogainLossParameter_default_instance_.Shutdown();
- delete InfogainLossParameter_reflection_;
- InnerProductParameter_default_instance_.Shutdown();
- delete InnerProductParameter_reflection_;
- LogParameter_default_instance_.Shutdown();
- delete LogParameter_reflection_;
- LRNParameter_default_instance_.Shutdown();
- delete LRNParameter_reflection_;
- MemoryDataParameter_default_instance_.Shutdown();
- delete MemoryDataParameter_reflection_;
- MVNParameter_default_instance_.Shutdown();
- delete MVNParameter_reflection_;
- PoolingParameter_default_instance_.Shutdown();
- delete PoolingParameter_reflection_;
- PowerParameter_default_instance_.Shutdown();
- delete PowerParameter_reflection_;
- PythonParameter_default_instance_.Shutdown();
- delete PythonParameter_reflection_;
- ReductionParameter_default_instance_.Shutdown();
- delete ReductionParameter_reflection_;
- ReLUParameter_default_instance_.Shutdown();
- delete ReLUParameter_reflection_;
- ReshapeParameter_default_instance_.Shutdown();
- delete ReshapeParameter_reflection_;
- SigmoidParameter_default_instance_.Shutdown();
- delete SigmoidParameter_reflection_;
- SliceParameter_default_instance_.Shutdown();
- delete SliceParameter_reflection_;
- SoftmaxParameter_default_instance_.Shutdown();
- delete SoftmaxParameter_reflection_;
- TanHParameter_default_instance_.Shutdown();
- delete TanHParameter_reflection_;
- ThresholdParameter_default_instance_.Shutdown();
- delete ThresholdParameter_reflection_;
- WindowDataParameter_default_instance_.Shutdown();
- delete WindowDataParameter_reflection_;
- delete WindowDataParameter::_default_crop_mode_;
- SPPParameter_default_instance_.Shutdown();
- delete SPPParameter_reflection_;
- V1LayerParameter_default_instance_.Shutdown();
- delete V1LayerParameter_reflection_;
- V0LayerParameter_default_instance_.Shutdown();
- delete V0LayerParameter_reflection_;
- delete V0LayerParameter::_default_det_crop_mode_;
- PReLUParameter_default_instance_.Shutdown();
- delete PReLUParameter_reflection_;
- NormalizedBBox_default_instance_.Shutdown();
- delete NormalizedBBox_reflection_;
-}
-
-void protobuf_InitDefaults_caffe_2eproto_impl() {
- GOOGLE_PROTOBUF_VERIFY_VERSION;
-
- BlobShape_default_instance_.DefaultConstruct();
- BlobProto_default_instance_.DefaultConstruct();
- BlobProtoVector_default_instance_.DefaultConstruct();
- CropParameter_default_instance_.DefaultConstruct();
- PermuteParameter_default_instance_.DefaultConstruct();
- NormalizeBBoxParameter_default_instance_.DefaultConstruct();
- PriorBoxParameter_default_instance_.DefaultConstruct();
- DetectionOutputParameter_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- Datum_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- FillerParameter::_default_type_ =
- new ::std::string("constant", 8);
- FillerParameter_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- NetParameter_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- SolverParameter::_default_regularization_type_ =
- new ::std::string("L2", 2);
- SolverParameter_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- SolverState_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- NetState_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- NetStateRule_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- ParamSpec_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- LayerParameter_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- TransformationParameter_default_instance_.DefaultConstruct();
- LossParameter_default_instance_.DefaultConstruct();
- AccuracyParameter_default_instance_.DefaultConstruct();
- ArgMaxParameter_default_instance_.DefaultConstruct();
- ConcatParameter_default_instance_.DefaultConstruct();
- ContrastiveLossParameter_default_instance_.DefaultConstruct();
- ConvolutionParameter_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- DataParameter_default_instance_.DefaultConstruct();
- DropoutParameter_default_instance_.DefaultConstruct();
- DummyDataParameter_default_instance_.DefaultConstruct();
- EltwiseParameter_default_instance_.DefaultConstruct();
- ExpParameter_default_instance_.DefaultConstruct();
- FlattenParameter_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- HDF5DataParameter_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- HDF5OutputParameter_default_instance_.DefaultConstruct();
- HingeLossParameter_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- ImageDataParameter_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- InfogainLossParameter_default_instance_.DefaultConstruct();
- InnerProductParameter_default_instance_.DefaultConstruct();
- LogParameter_default_instance_.DefaultConstruct();
- LRNParameter_default_instance_.DefaultConstruct();
- MemoryDataParameter_default_instance_.DefaultConstruct();
- MVNParameter_default_instance_.DefaultConstruct();
- PoolingParameter_default_instance_.DefaultConstruct();
- PowerParameter_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- PythonParameter_default_instance_.DefaultConstruct();
- ReductionParameter_default_instance_.DefaultConstruct();
- ReLUParameter_default_instance_.DefaultConstruct();
- ReshapeParameter_default_instance_.DefaultConstruct();
- SigmoidParameter_default_instance_.DefaultConstruct();
- SliceParameter_default_instance_.DefaultConstruct();
- SoftmaxParameter_default_instance_.DefaultConstruct();
- TanHParameter_default_instance_.DefaultConstruct();
- ThresholdParameter_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- WindowDataParameter::_default_crop_mode_ =
- new ::std::string("warp", 4);
- WindowDataParameter_default_instance_.DefaultConstruct();
- SPPParameter_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- V1LayerParameter_default_instance_.DefaultConstruct();
- ::google::protobuf::internal::GetEmptyString();
- V0LayerParameter::_default_det_crop_mode_ =
- new ::std::string("warp", 4);
- V0LayerParameter_default_instance_.DefaultConstruct();
- PReLUParameter_default_instance_.DefaultConstruct();
- NormalizedBBox_default_instance_.DefaultConstruct();
- BlobShape_default_instance_.get_mutable()->InitAsDefaultInstance();
- BlobProto_default_instance_.get_mutable()->InitAsDefaultInstance();
- BlobProtoVector_default_instance_.get_mutable()->InitAsDefaultInstance();
- CropParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- PermuteParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- NormalizeBBoxParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- PriorBoxParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- DetectionOutputParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- Datum_default_instance_.get_mutable()->InitAsDefaultInstance();
- FillerParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- NetParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- SolverParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- SolverState_default_instance_.get_mutable()->InitAsDefaultInstance();
- NetState_default_instance_.get_mutable()->InitAsDefaultInstance();
- NetStateRule_default_instance_.get_mutable()->InitAsDefaultInstance();
- ParamSpec_default_instance_.get_mutable()->InitAsDefaultInstance();
- LayerParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- TransformationParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- LossParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- AccuracyParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- ArgMaxParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- ConcatParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- ContrastiveLossParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- ConvolutionParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- DataParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- DropoutParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- DummyDataParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- EltwiseParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- ExpParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- FlattenParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- HDF5DataParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- HDF5OutputParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- HingeLossParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- ImageDataParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- InfogainLossParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- InnerProductParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- LogParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- LRNParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- MemoryDataParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- MVNParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- PoolingParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- PowerParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- PythonParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- ReductionParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- ReLUParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- ReshapeParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- SigmoidParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- SliceParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- SoftmaxParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- TanHParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- ThresholdParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- WindowDataParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- SPPParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- V1LayerParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- V0LayerParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- PReLUParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
- NormalizedBBox_default_instance_.get_mutable()->InitAsDefaultInstance();
-}
-
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_caffe_2eproto_once_);
-void protobuf_InitDefaults_caffe_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_caffe_2eproto_once_,
- &protobuf_InitDefaults_caffe_2eproto_impl);
-}
-void protobuf_AddDesc_caffe_2eproto_impl() {
- GOOGLE_PROTOBUF_VERIFY_VERSION;
-
- protobuf_InitDefaults_caffe_2eproto();
- ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
- "\n\013caffe.proto\022\005caffe\"\034\n\tBlobShape\022\017\n\003dim"
- "\030\001 \003(\003B\002\020\001\"\232\001\n\tBlobProto\022\037\n\005shape\030\007 \001(\0132"
- "\020.caffe.BlobShape\022\020\n\004data\030\005 \003(\002B\002\020\001\022\020\n\004d"
- "iff\030\006 \003(\002B\002\020\001\022\016\n\003num\030\001 \001(\005:\0010\022\023\n\010channel"
- "s\030\002 \001(\005:\0010\022\021\n\006height\030\003 \001(\005:\0010\022\020\n\005width\030\004"
- " \001(\005:\0010\"2\n\017BlobProtoVector\022\037\n\005blobs\030\001 \003("
- "\0132\020.caffe.BlobProto\"0\n\rCropParameter\022\017\n\004"
- "axis\030\001 \001(\005:\0012\022\016\n\006offset\030\002 \003(\r\"!\n\020Permute"
- "Parameter\022\r\n\005order\030\001 \003(\r\"\226\001\n\026NormalizeBB"
- "oxParameter\022\034\n\016across_spatial\030\001 \001(\010:\004tru"
- "e\022,\n\014scale_filler\030\002 \001(\0132\026.caffe.FillerPa"
- "rameter\022\034\n\016channel_shared\030\003 \001(\010:\004true\022\022\n"
- "\003eps\030\004 \001(\002:\0051e-10\"\260\001\n\021PriorBoxParameter\022"
- "\020\n\010min_size\030\001 \001(\002\022\020\n\010max_size\030\002 \001(\002\022\024\n\014a"
- "spect_ratio\030\003 \003(\002\022\022\n\004flip\030\004 \001(\010:\004true\022\022\n"
- "\004clip\030\005 \001(\010:\004true\022\020\n\010variance\030\006 \003(\002\"\'\n\010C"
- "odeType\022\n\n\006CORNER\020\001\022\017\n\013CENTER_SIZE\020\002\"\267\002\n"
- "\030DetectionOutputParameter\022\023\n\013num_classes"
- "\030\001 \001(\r\022\034\n\016share_location\030\002 \001(\010:\004true\022\036\n\023"
- "background_label_id\030\003 \001(\005:\0010\022<\n\tcode_typ"
- "e\030\006 \001(\0162!.caffe.PriorBoxParameter.CodeTy"
- "pe:\006CORNER\022)\n\032variance_encoded_in_target"
- "\030\010 \001(\010:\005false\022\026\n\nkeep_top_k\030\007 \001(\005:\002-1\022\034\n"
- "\024confidence_threshold\030\t \001(\002\022\032\n\rnms_thres"
- "hold\030\n \001(\002:\0030.3\022\r\n\005top_k\030\013 \001(\005\"\201\001\n\005Datum"
- "\022\020\n\010channels\030\001 \001(\005\022\016\n\006height\030\002 \001(\005\022\r\n\005wi"
- "dth\030\003 \001(\005\022\014\n\004data\030\004 \001(\014\022\r\n\005label\030\005 \001(\005\022\022"
- "\n\nfloat_data\030\006 \003(\002\022\026\n\007encoded\030\007 \001(\010:\005fal"
- "se\"\212\002\n\017FillerParameter\022\026\n\004type\030\001 \001(\t:\010co"
- "nstant\022\020\n\005value\030\002 \001(\002:\0010\022\016\n\003min\030\003 \001(\002:\0010"
- "\022\016\n\003max\030\004 \001(\002:\0011\022\017\n\004mean\030\005 \001(\002:\0010\022\016\n\003std"
- "\030\006 \001(\002:\0011\022\022\n\006sparse\030\007 \001(\005:\002-1\022B\n\rvarianc"
- "e_norm\030\010 \001(\0162#.caffe.FillerParameter.Var"
- "ianceNorm:\006FAN_IN\"4\n\014VarianceNorm\022\n\n\006FAN"
- "_IN\020\000\022\013\n\007FAN_OUT\020\001\022\013\n\007AVERAGE\020\002\"\216\002\n\014NetP"
- "arameter\022\014\n\004name\030\001 \001(\t\022\r\n\005input\030\003 \003(\t\022%\n"
- "\013input_shape\030\010 \003(\0132\020.caffe.BlobShape\022\021\n\t"
- "input_dim\030\004 \003(\005\022\035\n\016force_backward\030\005 \001(\010:"
- "\005false\022\036\n\005state\030\006 \001(\0132\017.caffe.NetState\022\031"
- "\n\ndebug_info\030\007 \001(\010:\005false\022$\n\005layer\030d \003(\013"
- "2\025.caffe.LayerParameter\022\'\n\006layers\030\002 \003(\0132"
- "\027.caffe.V1LayerParameter\"\275\010\n\017SolverParam"
- "eter\022\013\n\003net\030\030 \001(\t\022&\n\tnet_param\030\031 \001(\0132\023.c"
- "affe.NetParameter\022\021\n\ttrain_net\030\001 \001(\t\022\020\n\010"
- "test_net\030\002 \003(\t\022,\n\017train_net_param\030\025 \001(\0132"
- "\023.caffe.NetParameter\022+\n\016test_net_param\030\026"
- " \003(\0132\023.caffe.NetParameter\022$\n\013train_state"
- "\030\032 \001(\0132\017.caffe.NetState\022#\n\ntest_state\030\033 "
- "\003(\0132\017.caffe.NetState\022\021\n\ttest_iter\030\003 \003(\005\022"
- "\030\n\rtest_interval\030\004 \001(\005:\0010\022 \n\021test_comput"
- "e_loss\030\023 \001(\010:\005false\022!\n\023test_initializati"
- "on\030 \001(\010:\004true\022\017\n\007base_lr\030\005 \001(\002\022\017\n\007displ"
- "ay\030\006 \001(\005\022\027\n\014average_loss\030! \001(\005:\0011\022\020\n\010max"
- "_iter\030\007 \001(\005\022\024\n\titer_size\030$ \001(\005:\0011\022\021\n\tlr_"
- "policy\030\010 \001(\t\022\r\n\005gamma\030\t \001(\002\022\r\n\005power\030\n \001"
- "(\002\022\020\n\010momentum\030\013 \001(\002\022\024\n\014weight_decay\030\014 \001"
- "(\002\022\037\n\023regularization_type\030\035 \001(\t:\002L2\022\020\n\010s"
- "tepsize\030\r \001(\005\022\021\n\tstepvalue\030\" \003(\005\022\032\n\016clip"
- "_gradients\030# \001(\002:\002-1\022\023\n\010snapshot\030\016 \001(\005:\001"
- "0\022\027\n\017snapshot_prefix\030\017 \001(\t\022\034\n\rsnapshot_d"
- "iff\030\020 \001(\010:\005false\022;\n\013solver_mode\030\021 \001(\0162!."
- "caffe.SolverParameter.SolverMode:\003GPU\022\024\n"
- "\tdevice_id\030\022 \001(\005:\0010\022\027\n\013random_seed\030\024 \001(\003"
- ":\002-1\022;\n\013solver_type\030\036 \001(\0162!.caffe.Solver"
- "Parameter.SolverType:\003SGD\022\024\n\005delta\030\037 \001(\002"
- ":\0051e-08\022\031\n\ndebug_info\030\027 \001(\010:\005false\022\"\n\024sn"
- "apshot_after_train\030\034 \001(\010:\004true\"\036\n\nSolver"
- "Mode\022\007\n\003CPU\020\000\022\007\n\003GPU\020\001\"0\n\nSolverType\022\007\n\003"
- "SGD\020\000\022\014\n\010NESTEROV\020\001\022\013\n\007ADAGRAD\020\002\"l\n\013Solv"
- "erState\022\014\n\004iter\030\001 \001(\005\022\023\n\013learned_net\030\002 \001"
- "(\t\022!\n\007history\030\003 \003(\0132\020.caffe.BlobProto\022\027\n"
- "\014current_step\030\004 \001(\005:\0010\"N\n\010NetState\022!\n\005ph"
- "ase\030\001 \001(\0162\014.caffe.Phase:\004TEST\022\020\n\005level\030\002"
- " \001(\005:\0010\022\r\n\005stage\030\003 \003(\t\"s\n\014NetStateRule\022\033"
- "\n\005phase\030\001 \001(\0162\014.caffe.Phase\022\021\n\tmin_level"
- "\030\002 \001(\005\022\021\n\tmax_level\030\003 \001(\005\022\r\n\005stage\030\004 \003(\t"
- "\022\021\n\tnot_stage\030\005 \003(\t\"\243\001\n\tParamSpec\022\014\n\004nam"
- "e\030\001 \001(\t\0221\n\nshare_mode\030\002 \001(\0162\035.caffe.Para"
- "mSpec.DimCheckMode\022\022\n\007lr_mult\030\003 \001(\002:\0011\022\025"
- "\n\ndecay_mult\030\004 \001(\002:\0011\"*\n\014DimCheckMode\022\n\n"
- "\006STRICT\020\000\022\016\n\nPERMISSIVE\020\001\"\301\022\n\016LayerParam"
- "eter\022\014\n\004name\030\001 \001(\t\022\014\n\004type\030\002 \001(\t\022\016\n\006bott"
- "om\030\003 \003(\t\022\013\n\003top\030\004 \003(\t\022\033\n\005phase\030\n \001(\0162\014.c"
- "affe.Phase\022\023\n\013loss_weight\030\005 \003(\002\022\037\n\005param"
- "\030\006 \003(\0132\020.caffe.ParamSpec\022\037\n\005blobs\030\007 \003(\0132"
- "\020.caffe.BlobProto\022\026\n\016propagate_down\030\013 \003("
- "\010\022$\n\007include\030\010 \003(\0132\023.caffe.NetStateRule\022"
- "$\n\007exclude\030\t \003(\0132\023.caffe.NetStateRule\0227\n"
- "\017transform_param\030d \001(\0132\036.caffe.Transform"
- "ationParameter\022(\n\nloss_param\030e \001(\0132\024.caf"
- "fe.LossParameter\0220\n\016accuracy_param\030f \001(\013"
- "2\030.caffe.AccuracyParameter\022,\n\014argmax_par"
- "am\030g \001(\0132\026.caffe.ArgMaxParameter\022,\n\014conc"
- "at_param\030h \001(\0132\026.caffe.ConcatParameter\022\?"
- "\n\026contrastive_loss_param\030i \001(\0132\037.caffe.C"
- "ontrastiveLossParameter\0226\n\021convolution_p"
- "aram\030j \001(\0132\033.caffe.ConvolutionParameter\022"
- ")\n\ncrop_param\030\211\001 \001(\0132\024.caffe.CropParamet"
- "er\022(\n\ndata_param\030k \001(\0132\024.caffe.DataParam"
- "eter\022@\n\026detection_output_param\030\215\001 \001(\0132\037."
- "caffe.DetectionOutputParameter\022.\n\rdropou"
- "t_param\030l \001(\0132\027.caffe.DropoutParameter\0223"
- "\n\020dummy_data_param\030m \001(\0132\031.caffe.DummyDa"
- "taParameter\022.\n\reltwise_param\030n \001(\0132\027.caf"
- "fe.EltwiseParameter\022&\n\texp_param\030o \001(\0132\023"
- ".caffe.ExpParameter\022/\n\rflatten_param\030\207\001 "
- "\001(\0132\027.caffe.FlattenParameter\0221\n\017hdf5_dat"
- "a_param\030p \001(\0132\030.caffe.HDF5DataParameter\022"
- "5\n\021hdf5_output_param\030q \001(\0132\032.caffe.HDF5O"
- "utputParameter\0223\n\020hinge_loss_param\030r \001(\013"
- "2\031.caffe.HingeLossParameter\0223\n\020image_dat"
- "a_param\030s \001(\0132\031.caffe.ImageDataParameter"
- "\0229\n\023infogain_loss_param\030t \001(\0132\034.caffe.In"
- "fogainLossParameter\0229\n\023inner_product_par"
- "am\030u \001(\0132\034.caffe.InnerProductParameter\022\'"
- "\n\tlog_param\030\206\001 \001(\0132\023.caffe.LogParameter\022"
- "&\n\tlrn_param\030v \001(\0132\023.caffe.LRNParameter\022"
- "5\n\021memory_data_param\030w \001(\0132\032.caffe.Memor"
- "yDataParameter\022&\n\tmvn_param\030x \001(\0132\023.caff"
- "e.MVNParameter\022<\n\024normalize_bbox_param\030\213"
- "\001 \001(\0132\035.caffe.NormalizeBBoxParameter\022/\n\r"
- "permute_param\030\212\001 \001(\0132\027.caffe.PermutePara"
- "meter\022.\n\rpooling_param\030y \001(\0132\027.caffe.Poo"
- "lingParameter\022*\n\013power_param\030z \001(\0132\025.caf"
- "fe.PowerParameter\022+\n\013prelu_param\030\203\001 \001(\0132"
- "\025.caffe.PReLUParameter\0222\n\017prior_box_para"
- "m\030\214\001 \001(\0132\030.caffe.PriorBoxParameter\022-\n\014py"
- "thon_param\030\202\001 \001(\0132\026.caffe.PythonParamete"
- "r\0223\n\017reduction_param\030\210\001 \001(\0132\031.caffe.Redu"
- "ctionParameter\022(\n\nrelu_param\030{ \001(\0132\024.caf"
- "fe.ReLUParameter\022/\n\rreshape_param\030\205\001 \001(\013"
- "2\027.caffe.ReshapeParameter\022.\n\rsigmoid_par"
- "am\030| \001(\0132\027.caffe.SigmoidParameter\022*\n\013sli"
- "ce_param\030~ \001(\0132\025.caffe.SliceParameter\022.\n"
- "\rsoftmax_param\030} \001(\0132\027.caffe.SoftmaxPara"
- "meter\022\'\n\tspp_param\030\204\001 \001(\0132\023.caffe.SPPPar"
- "ameter\022(\n\ntanh_param\030\177 \001(\0132\024.caffe.TanHP"
- "arameter\0223\n\017threshold_param\030\200\001 \001(\0132\031.caf"
- "fe.ThresholdParameter\0226\n\021window_data_par"
- "am\030\201\001 \001(\0132\032.caffe.WindowDataParameter\"\266\001"
- "\n\027TransformationParameter\022\020\n\005scale\030\001 \001(\002"
- ":\0011\022\025\n\006mirror\030\002 \001(\010:\005false\022\024\n\tcrop_size\030"
- "\003 \001(\r:\0010\022\021\n\tmean_file\030\004 \001(\t\022\022\n\nmean_valu"
- "e\030\005 \003(\002\022\032\n\013force_color\030\006 \001(\010:\005false\022\031\n\nf"
- "orce_gray\030\007 \001(\010:\005false\">\n\rLossParameter\022"
- "\024\n\014ignore_label\030\001 \001(\005\022\027\n\tnormalize\030\002 \001(\010"
- ":\004true\"L\n\021AccuracyParameter\022\020\n\005top_k\030\001 \001"
- "(\r:\0011\022\017\n\004axis\030\002 \001(\005:\0011\022\024\n\014ignore_label\030\003"
- " \001(\005\"\?\n\017ArgMaxParameter\022\032\n\013out_max_val\030\001"
- " \001(\010:\005false\022\020\n\005top_k\030\002 \001(\r:\0011\"9\n\017ConcatP"
- "arameter\022\017\n\004axis\030\002 \001(\005:\0011\022\025\n\nconcat_dim\030"
- "\001 \001(\r:\0011\"L\n\030ContrastiveLossParameter\022\021\n\006"
- "margin\030\001 \001(\002:\0011\022\035\n\016legacy_version\030\002 \001(\010:"
- "\005false\"\371\003\n\024ConvolutionParameter\022\022\n\nnum_o"
- "utput\030\001 \001(\r\022\027\n\tbias_term\030\002 \001(\010:\004true\022\016\n\003"
- "pad\030\003 \001(\r:\0010\022\020\n\005pad_h\030\t \001(\r:\0010\022\020\n\005pad_w\030"
- "\n \001(\r:\0010\022\023\n\013kernel_size\030\004 \001(\r\022\020\n\010kernel_"
- "h\030\013 \001(\r\022\020\n\010kernel_w\030\014 \001(\r\022\020\n\005group\030\005 \001(\r"
- ":\0011\022\021\n\006stride\030\006 \001(\r:\0011\022\020\n\010stride_h\030\r \001(\r"
- "\022\020\n\010stride_w\030\016 \001(\r\022-\n\rweight_filler\030\007 \001("
- "\0132\026.caffe.FillerParameter\022+\n\013bias_filler"
- "\030\010 \001(\0132\026.caffe.FillerParameter\022;\n\006engine"
- "\030\017 \001(\0162\".caffe.ConvolutionParameter.Engi"
- "ne:\007DEFAULT\022\022\n\ndilation_h\030\022 \001(\r\022\022\n\ndilat"
- "ion_w\030\023 \001(\r\022\020\n\010dilation\030\024 \001(\r\"+\n\006Engine\022"
- "\013\n\007DEFAULT\020\000\022\t\n\005CAFFE\020\001\022\t\n\005CUDNN\020\002\"\217\002\n\rD"
- "ataParameter\022\016\n\006source\030\001 \001(\t\022\022\n\nbatch_si"
- "ze\030\004 \001(\r\022\024\n\trand_skip\030\007 \001(\r:\0010\0221\n\007backen"
- "d\030\010 \001(\0162\027.caffe.DataParameter.DB:\007LEVELD"
- "B\022\020\n\005scale\030\002 \001(\002:\0011\022\021\n\tmean_file\030\003 \001(\t\022\024"
- "\n\tcrop_size\030\005 \001(\r:\0010\022\025\n\006mirror\030\006 \001(\010:\005fa"
- "lse\022\"\n\023force_encoded_color\030\t \001(\010:\005false\""
- "\033\n\002DB\022\013\n\007LEVELDB\020\000\022\010\n\004LMDB\020\001\".\n\020DropoutP"
- "arameter\022\032\n\rdropout_ratio\030\001 \001(\002:\0030.5\"\240\001\n"
- "\022DummyDataParameter\022+\n\013data_filler\030\001 \003(\013"
- "2\026.caffe.FillerParameter\022\037\n\005shape\030\006 \003(\0132"
- "\020.caffe.BlobShape\022\013\n\003num\030\002 \003(\r\022\020\n\010channe"
- "ls\030\003 \003(\r\022\016\n\006height\030\004 \003(\r\022\r\n\005width\030\005 \003(\r\""
- "\245\001\n\020EltwiseParameter\0229\n\toperation\030\001 \001(\0162"
- "!.caffe.EltwiseParameter.EltwiseOp:\003SUM\022"
- "\r\n\005coeff\030\002 \003(\002\022\036\n\020stable_prod_grad\030\003 \001(\010"
- ":\004true\"\'\n\tEltwiseOp\022\010\n\004PROD\020\000\022\007\n\003SUM\020\001\022\007"
- "\n\003MAX\020\002\"D\n\014ExpParameter\022\020\n\004base\030\001 \001(\002:\002-"
- "1\022\020\n\005scale\030\002 \001(\002:\0011\022\020\n\005shift\030\003 \001(\002:\0010\"9\n"
- "\020FlattenParameter\022\017\n\004axis\030\001 \001(\005:\0011\022\024\n\010en"
- "d_axis\030\002 \001(\005:\002-1\"O\n\021HDF5DataParameter\022\016\n"
- "\006source\030\001 \001(\t\022\022\n\nbatch_size\030\002 \001(\r\022\026\n\007shu"
- "ffle\030\003 \001(\010:\005false\"(\n\023HDF5OutputParameter"
- "\022\021\n\tfile_name\030\001 \001(\t\"^\n\022HingeLossParamete"
- "r\0220\n\004norm\030\001 \001(\0162\036.caffe.HingeLossParamet"
- "er.Norm:\002L1\"\026\n\004Norm\022\006\n\002L1\020\001\022\006\n\002L2\020\002\"\224\002\n\022"
- "ImageDataParameter\022\016\n\006source\030\001 \001(\t\022\022\n\nba"
- "tch_size\030\004 \001(\r\022\024\n\trand_skip\030\007 \001(\r:\0010\022\026\n\007"
- "shuffle\030\010 \001(\010:\005false\022\025\n\nnew_height\030\t \001(\r"
- ":\0010\022\024\n\tnew_width\030\n \001(\r:\0010\022\026\n\010is_color\030\013 "
- "\001(\010:\004true\022\020\n\005scale\030\002 \001(\002:\0011\022\021\n\tmean_file"
- "\030\003 \001(\t\022\024\n\tcrop_size\030\005 \001(\r:\0010\022\025\n\006mirror\030\006"
- " \001(\010:\005false\022\025\n\013root_folder\030\014 \001(\t:\000\"\'\n\025In"
- "fogainLossParameter\022\016\n\006source\030\001 \001(\t\"\261\001\n\025"
- "InnerProductParameter\022\022\n\nnum_output\030\001 \001("
- "\r\022\027\n\tbias_term\030\002 \001(\010:\004true\022-\n\rweight_fil"
- "ler\030\003 \001(\0132\026.caffe.FillerParameter\022+\n\013bia"
- "s_filler\030\004 \001(\0132\026.caffe.FillerParameter\022\017"
- "\n\004axis\030\005 \001(\005:\0011\"D\n\014LogParameter\022\020\n\004base\030"
- "\001 \001(\002:\002-1\022\020\n\005scale\030\002 \001(\002:\0011\022\020\n\005shift\030\003 \001"
- "(\002:\0010\"\326\001\n\014LRNParameter\022\025\n\nlocal_size\030\001 \001"
- "(\r:\0015\022\020\n\005alpha\030\002 \001(\002:\0011\022\022\n\004beta\030\003 \001(\002:\0040"
- ".75\022D\n\013norm_region\030\004 \001(\0162\036.caffe.LRNPara"
- "meter.NormRegion:\017ACROSS_CHANNELS\022\014\n\001k\030\005"
- " \001(\002:\0011\"5\n\nNormRegion\022\023\n\017ACROSS_CHANNELS"
- "\020\000\022\022\n\016WITHIN_CHANNEL\020\001\"Z\n\023MemoryDataPara"
- "meter\022\022\n\nbatch_size\030\001 \001(\r\022\020\n\010channels\030\002 "
- "\001(\r\022\016\n\006height\030\003 \001(\r\022\r\n\005width\030\004 \001(\r\"d\n\014MV"
- "NParameter\022 \n\022normalize_variance\030\001 \001(\010:\004"
- "true\022\036\n\017across_channels\030\002 \001(\010:\005false\022\022\n\003"
- "eps\030\003 \001(\002:\0051e-09\"\242\003\n\020PoolingParameter\0225\n"
- "\004pool\030\001 \001(\0162\".caffe.PoolingParameter.Poo"
- "lMethod:\003MAX\022\016\n\003pad\030\004 \001(\r:\0010\022\020\n\005pad_h\030\t "
- "\001(\r:\0010\022\020\n\005pad_w\030\n \001(\r:\0010\022\023\n\013kernel_size\030"
- "\002 \001(\r\022\020\n\010kernel_h\030\005 \001(\r\022\020\n\010kernel_w\030\006 \001("
- "\r\022\021\n\006stride\030\003 \001(\r:\0011\022\020\n\010stride_h\030\007 \001(\r\022\020"
- "\n\010stride_w\030\010 \001(\r\0227\n\006engine\030\013 \001(\0162\036.caffe"
- ".PoolingParameter.Engine:\007DEFAULT\022\035\n\016glo"
- "bal_pooling\030\014 \001(\010:\005false\".\n\nPoolMethod\022\007"
- "\n\003MAX\020\000\022\007\n\003AVE\020\001\022\016\n\nSTOCHASTIC\020\002\"+\n\006Engi"
- "ne\022\013\n\007DEFAULT\020\000\022\t\n\005CAFFE\020\001\022\t\n\005CUDNN\020\002\"F\n"
- "\016PowerParameter\022\020\n\005power\030\001 \001(\002:\0011\022\020\n\005sca"
- "le\030\002 \001(\002:\0011\022\020\n\005shift\030\003 \001(\002:\0010\"0\n\017PythonP"
- "arameter\022\016\n\006module\030\001 \001(\t\022\r\n\005layer\030\002 \001(\t\""
- "\255\001\n\022ReductionParameter\022=\n\toperation\030\001 \001("
- "\0162%.caffe.ReductionParameter.ReductionOp"
- ":\003SUM\022\017\n\004axis\030\002 \001(\005:\0010\022\020\n\005coeff\030\003 \001(\002:\0011"
- "\"5\n\013ReductionOp\022\007\n\003SUM\020\001\022\010\n\004ASUM\020\002\022\t\n\005SU"
- "MSQ\020\003\022\010\n\004MEAN\020\004\"\215\001\n\rReLUParameter\022\031\n\016neg"
- "ative_slope\030\001 \001(\002:\0010\0224\n\006engine\030\002 \001(\0162\033.c"
- "affe.ReLUParameter.Engine:\007DEFAULT\"+\n\006En"
- "gine\022\013\n\007DEFAULT\020\000\022\t\n\005CAFFE\020\001\022\t\n\005CUDNN\020\002\""
- "Z\n\020ReshapeParameter\022\037\n\005shape\030\001 \001(\0132\020.caf"
- "fe.BlobShape\022\017\n\004axis\030\002 \001(\005:\0010\022\024\n\010num_axe"
- "s\030\003 \001(\005:\002-1\"x\n\020SigmoidParameter\0227\n\006engin"
- "e\030\001 \001(\0162\036.caffe.SigmoidParameter.Engine:"
- "\007DEFAULT\"+\n\006Engine\022\013\n\007DEFAULT\020\000\022\t\n\005CAFFE"
- "\020\001\022\t\n\005CUDNN\020\002\"L\n\016SliceParameter\022\017\n\004axis\030"
- "\003 \001(\005:\0011\022\023\n\013slice_point\030\002 \003(\r\022\024\n\tslice_d"
- "im\030\001 \001(\r:\0011\"\211\001\n\020SoftmaxParameter\0227\n\006engi"
- "ne\030\001 \001(\0162\036.caffe.SoftmaxParameter.Engine"
- ":\007DEFAULT\022\017\n\004axis\030\002 \001(\005:\0011\"+\n\006Engine\022\013\n\007"
- "DEFAULT\020\000\022\t\n\005CAFFE\020\001\022\t\n\005CUDNN\020\002\"r\n\rTanHP"
- "arameter\0224\n\006engine\030\001 \001(\0162\033.caffe.TanHPar"
- "ameter.Engine:\007DEFAULT\"+\n\006Engine\022\013\n\007DEFA"
- "ULT\020\000\022\t\n\005CAFFE\020\001\022\t\n\005CUDNN\020\002\"*\n\022Threshold"
- "Parameter\022\024\n\tthreshold\030\001 \001(\002:\0010\"\301\002\n\023Wind"
- "owDataParameter\022\016\n\006source\030\001 \001(\t\022\020\n\005scale"
- "\030\002 \001(\002:\0011\022\021\n\tmean_file\030\003 \001(\t\022\022\n\nbatch_si"
- "ze\030\004 \001(\r\022\024\n\tcrop_size\030\005 \001(\r:\0010\022\025\n\006mirror"
- "\030\006 \001(\010:\005false\022\031\n\014fg_threshold\030\007 \001(\002:\0030.5"
- "\022\031\n\014bg_threshold\030\010 \001(\002:\0030.5\022\031\n\013fg_fracti"
- "on\030\t \001(\002:\0040.25\022\026\n\013context_pad\030\n \001(\r:\0010\022\027"
- "\n\tcrop_mode\030\013 \001(\t:\004warp\022\033\n\014cache_images\030"
- "\014 \001(\010:\005false\022\025\n\013root_folder\030\r \001(\t:\000\"\353\001\n\014"
- "SPPParameter\022\026\n\016pyramid_height\030\001 \001(\r\0221\n\004"
- "pool\030\002 \001(\0162\036.caffe.SPPParameter.PoolMeth"
- "od:\003MAX\0223\n\006engine\030\006 \001(\0162\032.caffe.SPPParam"
- "eter.Engine:\007DEFAULT\".\n\nPoolMethod\022\007\n\003MA"
- "X\020\000\022\007\n\003AVE\020\001\022\016\n\nSTOCHASTIC\020\002\"+\n\006Engine\022\013"
- "\n\007DEFAULT\020\000\022\t\n\005CAFFE\020\001\022\t\n\005CUDNN\020\002\"\340\023\n\020V1"
- "LayerParameter\022\016\n\006bottom\030\002 \003(\t\022\013\n\003top\030\003 "
- "\003(\t\022\014\n\004name\030\004 \001(\t\022$\n\007include\030 \003(\0132\023.caf"
- "fe.NetStateRule\022$\n\007exclude\030! \003(\0132\023.caffe"
- ".NetStateRule\022/\n\004type\030\005 \001(\0162!.caffe.V1La"
- "yerParameter.LayerType\022\037\n\005blobs\030\006 \003(\0132\020."
- "caffe.BlobProto\022\016\n\005param\030\351\007 \003(\t\022>\n\017blob_"
- "share_mode\030\352\007 \003(\0162$.caffe.V1LayerParamet"
- "er.DimCheckMode\022\020\n\010blobs_lr\030\007 \003(\002\022\024\n\014wei"
- "ght_decay\030\010 \003(\002\022\023\n\013loss_weight\030# \003(\002\0220\n\016"
- "accuracy_param\030\033 \001(\0132\030.caffe.AccuracyPar"
- "ameter\022,\n\014argmax_param\030\027 \001(\0132\026.caffe.Arg"
- "MaxParameter\022,\n\014concat_param\030\t \001(\0132\026.caf"
- "fe.ConcatParameter\022\?\n\026contrastive_loss_p"
- "aram\030( \001(\0132\037.caffe.ContrastiveLossParame"
- "ter\0226\n\021convolution_param\030\n \001(\0132\033.caffe.C"
- "onvolutionParameter\022(\n\ndata_param\030\013 \001(\0132"
- "\024.caffe.DataParameter\022.\n\rdropout_param\030\014"
- " \001(\0132\027.caffe.DropoutParameter\0223\n\020dummy_d"
- "ata_param\030\032 \001(\0132\031.caffe.DummyDataParamet"
- "er\022.\n\reltwise_param\030\030 \001(\0132\027.caffe.Eltwis"
- "eParameter\022&\n\texp_param\030) \001(\0132\023.caffe.Ex"
- "pParameter\0221\n\017hdf5_data_param\030\r \001(\0132\030.ca"
- "ffe.HDF5DataParameter\0225\n\021hdf5_output_par"
- "am\030\016 \001(\0132\032.caffe.HDF5OutputParameter\0223\n\020"
- "hinge_loss_param\030\035 \001(\0132\031.caffe.HingeLoss"
- "Parameter\0223\n\020image_data_param\030\017 \001(\0132\031.ca"
- "ffe.ImageDataParameter\0229\n\023infogain_loss_"
- "param\030\020 \001(\0132\034.caffe.InfogainLossParamete"
- "r\0229\n\023inner_product_param\030\021 \001(\0132\034.caffe.I"
- "nnerProductParameter\022&\n\tlrn_param\030\022 \001(\0132"
- "\023.caffe.LRNParameter\0225\n\021memory_data_para"
- "m\030\026 \001(\0132\032.caffe.MemoryDataParameter\022&\n\tm"
- "vn_param\030\" \001(\0132\023.caffe.MVNParameter\022.\n\rp"
- "ooling_param\030\023 \001(\0132\027.caffe.PoolingParame"
- "ter\022*\n\013power_param\030\025 \001(\0132\025.caffe.PowerPa"
- "rameter\022(\n\nrelu_param\030\036 \001(\0132\024.caffe.ReLU"
- "Parameter\022.\n\rsigmoid_param\030& \001(\0132\027.caffe"
- ".SigmoidParameter\022.\n\rsoftmax_param\030\' \001(\013"
- "2\027.caffe.SoftmaxParameter\022*\n\013slice_param"
- "\030\037 \001(\0132\025.caffe.SliceParameter\022(\n\ntanh_pa"
- "ram\030% \001(\0132\024.caffe.TanHParameter\0222\n\017thres"
- "hold_param\030\031 \001(\0132\031.caffe.ThresholdParame"
- "ter\0225\n\021window_data_param\030\024 \001(\0132\032.caffe.W"
- "indowDataParameter\0227\n\017transform_param\030$ "
- "\001(\0132\036.caffe.TransformationParameter\022(\n\nl"
- "oss_param\030* \001(\0132\024.caffe.LossParameter\022&\n"
- "\005layer\030\001 \001(\0132\027.caffe.V0LayerParameter\"\330\004"
- "\n\tLayerType\022\010\n\004NONE\020\000\022\n\n\006ABSVAL\020#\022\014\n\010ACC"
- "URACY\020\001\022\n\n\006ARGMAX\020\036\022\010\n\004BNLL\020\002\022\n\n\006CONCAT\020"
- "\003\022\024\n\020CONTRASTIVE_LOSS\020%\022\017\n\013CONVOLUTION\020\004"
- "\022\010\n\004DATA\020\005\022\021\n\rDECONVOLUTION\020\'\022\013\n\007DROPOUT"
- "\020\006\022\016\n\nDUMMY_DATA\020 \022\022\n\016EUCLIDEAN_LOSS\020\007\022\013"
- "\n\007ELTWISE\020\031\022\007\n\003EXP\020&\022\013\n\007FLATTEN\020\010\022\r\n\tHDF"
- "5_DATA\020\t\022\017\n\013HDF5_OUTPUT\020\n\022\016\n\nHINGE_LOSS\020"
- "\034\022\n\n\006IM2COL\020\013\022\016\n\nIMAGE_DATA\020\014\022\021\n\rINFOGAI"
- "N_LOSS\020\r\022\021\n\rINNER_PRODUCT\020\016\022\007\n\003LRN\020\017\022\017\n\013"
- "MEMORY_DATA\020\035\022\035\n\031MULTINOMIAL_LOGISTIC_LO"
- "SS\020\020\022\007\n\003MVN\020\"\022\013\n\007POOLING\020\021\022\t\n\005POWER\020\032\022\010\n"
- "\004RELU\020\022\022\013\n\007SIGMOID\020\023\022\036\n\032SIGMOID_CROSS_EN"
- "TROPY_LOSS\020\033\022\013\n\007SILENCE\020$\022\013\n\007SOFTMAX\020\024\022\020"
- "\n\014SOFTMAX_LOSS\020\025\022\t\n\005SPLIT\020\026\022\t\n\005SLICE\020!\022\010"
- "\n\004TANH\020\027\022\017\n\013WINDOW_DATA\020\030\022\r\n\tTHRESHOLD\020\037"
- "\"*\n\014DimCheckMode\022\n\n\006STRICT\020\000\022\016\n\nPERMISSI"
- "VE\020\001\"\375\007\n\020V0LayerParameter\022\014\n\004name\030\001 \001(\t\022"
- "\014\n\004type\030\002 \001(\t\022\022\n\nnum_output\030\003 \001(\r\022\026\n\010bia"
- "sterm\030\004 \001(\010:\004true\022-\n\rweight_filler\030\005 \001(\013"
- "2\026.caffe.FillerParameter\022+\n\013bias_filler\030"
- "\006 \001(\0132\026.caffe.FillerParameter\022\016\n\003pad\030\007 \001"
- "(\r:\0010\022\022\n\nkernelsize\030\010 \001(\r\022\020\n\005group\030\t \001(\r"
- ":\0011\022\021\n\006stride\030\n \001(\r:\0011\0225\n\004pool\030\013 \001(\0162\".c"
- "affe.V0LayerParameter.PoolMethod:\003MAX\022\032\n"
- "\rdropout_ratio\030\014 \001(\002:\0030.5\022\025\n\nlocal_size\030"
- "\r \001(\r:\0015\022\020\n\005alpha\030\016 \001(\002:\0011\022\022\n\004beta\030\017 \001(\002"
- ":\0040.75\022\014\n\001k\030\026 \001(\002:\0011\022\016\n\006source\030\020 \001(\t\022\020\n\005"
- "scale\030\021 \001(\002:\0011\022\020\n\010meanfile\030\022 \001(\t\022\021\n\tbatc"
- "hsize\030\023 \001(\r\022\023\n\010cropsize\030\024 \001(\r:\0010\022\025\n\006mirr"
- "or\030\025 \001(\010:\005false\022\037\n\005blobs\0302 \003(\0132\020.caffe.B"
- "lobProto\022\020\n\010blobs_lr\0303 \003(\002\022\024\n\014weight_dec"
- "ay\0304 \003(\002\022\024\n\trand_skip\0305 \001(\r:\0010\022\035\n\020det_fg"
- "_threshold\0306 \001(\002:\0030.5\022\035\n\020det_bg_threshol"
- "d\0307 \001(\002:\0030.5\022\035\n\017det_fg_fraction\0308 \001(\002:\0040"
- ".25\022\032\n\017det_context_pad\030: \001(\r:\0010\022\033\n\rdet_c"
- "rop_mode\030; \001(\t:\004warp\022\022\n\007new_num\030< \001(\005:\0010"
- "\022\027\n\014new_channels\030= \001(\005:\0010\022\025\n\nnew_height\030"
- "> \001(\005:\0010\022\024\n\tnew_width\030\? \001(\005:\0010\022\035\n\016shuffl"
- "e_images\030@ \001(\010:\005false\022\025\n\nconcat_dim\030A \001("
- "\r:\0011\0226\n\021hdf5_output_param\030\351\007 \001(\0132\032.caffe"
- ".HDF5OutputParameter\".\n\nPoolMethod\022\007\n\003MA"
- "X\020\000\022\007\n\003AVE\020\001\022\016\n\nSTOCHASTIC\020\002\"W\n\016PReLUPar"
- "ameter\022&\n\006filler\030\001 \001(\0132\026.caffe.FillerPar"
- "ameter\022\035\n\016channel_shared\030\002 \001(\010:\005false\"\207\001"
- "\n\016NormalizedBBox\022\014\n\004xmin\030\001 \001(\002\022\014\n\004ymin\030\002"
- " \001(\002\022\014\n\004xmax\030\003 \001(\002\022\014\n\004ymax\030\004 \001(\002\022\r\n\005labe"
- "l\030\005 \001(\005\022\021\n\tdifficult\030\006 \001(\010\022\r\n\005score\030\007 \001("
- "\002\022\014\n\004size\030\010 \001(\002*\034\n\005Phase\022\t\n\005TRAIN\020\000\022\010\n\004T"
- "EST\020\001", 14445);
- ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
- "caffe.proto", &protobuf_RegisterTypes);
- ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_caffe_2eproto);
-}
-
-GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_caffe_2eproto_once_);
-void protobuf_AddDesc_caffe_2eproto() {
- ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_caffe_2eproto_once_,
- &protobuf_AddDesc_caffe_2eproto_impl);
-}
-// Force AddDescriptors() to be called at static initialization time.
-struct StaticDescriptorInitializer_caffe_2eproto {
- StaticDescriptorInitializer_caffe_2eproto() {
- protobuf_AddDesc_caffe_2eproto();
- }
-} static_descriptor_initializer_caffe_2eproto_;
-const ::google::protobuf::EnumDescriptor* Phase_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return Phase_descriptor_;
-}
-bool Phase_IsValid(int value) {
- switch (value) {
- case 0:
- case 1:
- return true;
- default:
- return false;
- }
-}
-
-
-namespace {
-
-static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN;
-static void MergeFromFail(int line) {
- ::google::protobuf::internal::MergeFromFail(__FILE__, line);
-}
-
-} // namespace
-
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int BlobShape::kDimFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-BlobShape::BlobShape()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.BlobShape)
-}
-
-void BlobShape::InitAsDefaultInstance() {
-}
-
-BlobShape::BlobShape(const BlobShape& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.BlobShape)
-}
-
-void BlobShape::SharedCtor() {
- _cached_size_ = 0;
-}
-
-BlobShape::~BlobShape() {
- // @@protoc_insertion_point(destructor:caffe.BlobShape)
- SharedDtor();
-}
-
-void BlobShape::SharedDtor() {
-}
-
-void BlobShape::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* BlobShape::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return BlobShape_descriptor_;
-}
-
-const BlobShape& BlobShape::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<BlobShape> BlobShape_default_instance_;
-
-BlobShape* BlobShape::New(::google::protobuf::Arena* arena) const {
- BlobShape* n = new BlobShape;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void BlobShape::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.BlobShape)
- dim_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool BlobShape::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.BlobShape)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // repeated int64 dim = 1 [packed = true];
- case 1: {
- if (tag == 10) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive<
- ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
- input, this->mutable_dim())));
- } else if (tag == 8) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline<
- ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
- 1, 10, input, this->mutable_dim())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.BlobShape)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.BlobShape)
- return false;
-#undef DO_
-}
-
-void BlobShape::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.BlobShape)
- // repeated int64 dim = 1 [packed = true];
- if (this->dim_size() > 0) {
- ::google::protobuf::internal::WireFormatLite::WriteTag(1, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output);
- output->WriteVarint32(_dim_cached_byte_size_);
- }
- for (int i = 0; i < this->dim_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteInt64NoTag(
- this->dim(i), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.BlobShape)
-}
-
-::google::protobuf::uint8* BlobShape::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.BlobShape)
- // repeated int64 dim = 1 [packed = true];
- if (this->dim_size() > 0) {
- target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray(
- 1,
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,
- target);
- target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(
- _dim_cached_byte_size_, target);
- }
- for (int i = 0; i < this->dim_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteInt64NoTagToArray(this->dim(i), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.BlobShape)
- return target;
-}
-
-size_t BlobShape::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.BlobShape)
- size_t total_size = 0;
-
- // repeated int64 dim = 1 [packed = true];
- {
- size_t data_size = 0;
- unsigned int count = this->dim_size();
- for (unsigned int i = 0; i < count; i++) {
- data_size += ::google::protobuf::internal::WireFormatLite::
- Int64Size(this->dim(i));
- }
- if (data_size > 0) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _dim_cached_byte_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- total_size += data_size;
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void BlobShape::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.BlobShape)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const BlobShape* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const BlobShape>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.BlobShape)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.BlobShape)
- UnsafeMergeFrom(*source);
- }
-}
-
-void BlobShape::MergeFrom(const BlobShape& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.BlobShape)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void BlobShape::UnsafeMergeFrom(const BlobShape& from) {
- GOOGLE_DCHECK(&from != this);
- dim_.UnsafeMergeFrom(from.dim_);
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void BlobShape::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.BlobShape)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void BlobShape::CopyFrom(const BlobShape& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.BlobShape)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool BlobShape::IsInitialized() const {
-
- return true;
-}
-
-void BlobShape::Swap(BlobShape* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void BlobShape::InternalSwap(BlobShape* other) {
- dim_.UnsafeArenaSwap(&other->dim_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata BlobShape::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = BlobShape_descriptor_;
- metadata.reflection = BlobShape_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// BlobShape
-
-// repeated int64 dim = 1 [packed = true];
-int BlobShape::dim_size() const {
- return dim_.size();
-}
-void BlobShape::clear_dim() {
- dim_.Clear();
-}
-::google::protobuf::int64 BlobShape::dim(int index) const {
- // @@protoc_insertion_point(field_get:caffe.BlobShape.dim)
- return dim_.Get(index);
-}
-void BlobShape::set_dim(int index, ::google::protobuf::int64 value) {
- dim_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.BlobShape.dim)
-}
-void BlobShape::add_dim(::google::protobuf::int64 value) {
- dim_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.BlobShape.dim)
-}
-const ::google::protobuf::RepeatedField< ::google::protobuf::int64 >&
-BlobShape::dim() const {
- // @@protoc_insertion_point(field_list:caffe.BlobShape.dim)
- return dim_;
-}
-::google::protobuf::RepeatedField< ::google::protobuf::int64 >*
-BlobShape::mutable_dim() {
- // @@protoc_insertion_point(field_mutable_list:caffe.BlobShape.dim)
- return &dim_;
-}
-
-inline const BlobShape* BlobShape::internal_default_instance() {
- return &BlobShape_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int BlobProto::kShapeFieldNumber;
-const int BlobProto::kDataFieldNumber;
-const int BlobProto::kDiffFieldNumber;
-const int BlobProto::kNumFieldNumber;
-const int BlobProto::kChannelsFieldNumber;
-const int BlobProto::kHeightFieldNumber;
-const int BlobProto::kWidthFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-BlobProto::BlobProto()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.BlobProto)
-}
-
-void BlobProto::InitAsDefaultInstance() {
- shape_ = const_cast< ::caffe::BlobShape*>(
- ::caffe::BlobShape::internal_default_instance());
-}
-
-BlobProto::BlobProto(const BlobProto& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.BlobProto)
-}
-
-void BlobProto::SharedCtor() {
- _cached_size_ = 0;
- shape_ = NULL;
- ::memset(&num_, 0, reinterpret_cast<char*>(&width_) -
- reinterpret_cast<char*>(&num_) + sizeof(width_));
-}
-
-BlobProto::~BlobProto() {
- // @@protoc_insertion_point(destructor:caffe.BlobProto)
- SharedDtor();
-}
-
-void BlobProto::SharedDtor() {
- if (this != &BlobProto_default_instance_.get()) {
- delete shape_;
- }
-}
-
-void BlobProto::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* BlobProto::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return BlobProto_descriptor_;
-}
-
-const BlobProto& BlobProto::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<BlobProto> BlobProto_default_instance_;
-
-BlobProto* BlobProto::New(::google::protobuf::Arena* arena) const {
- BlobProto* n = new BlobProto;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void BlobProto::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.BlobProto)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(BlobProto, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<BlobProto*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- if (_has_bits_[0 / 32] & 121u) {
- ZR_(num_, width_);
- if (has_shape()) {
- if (shape_ != NULL) shape_->::caffe::BlobShape::Clear();
- }
- }
-
-#undef ZR_HELPER_
-#undef ZR_
-
- data_.Clear();
- diff_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool BlobProto::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.BlobProto)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional int32 num = 1 [default = 0];
- case 1: {
- if (tag == 8) {
- set_has_num();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &num_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_channels;
- break;
- }
-
- // optional int32 channels = 2 [default = 0];
- case 2: {
- if (tag == 16) {
- parse_channels:
- set_has_channels();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &channels_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(24)) goto parse_height;
- break;
- }
-
- // optional int32 height = 3 [default = 0];
- case 3: {
- if (tag == 24) {
- parse_height:
- set_has_height();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &height_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(32)) goto parse_width;
- break;
- }
-
- // optional int32 width = 4 [default = 0];
- case 4: {
- if (tag == 32) {
- parse_width:
- set_has_width();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &width_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(42)) goto parse_data;
- break;
- }
-
- // repeated float data = 5 [packed = true];
- case 5: {
- if (tag == 42) {
- parse_data:
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, this->mutable_data())));
- } else if (tag == 45) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- 1, 42, input, this->mutable_data())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(50)) goto parse_diff;
- break;
- }
-
- // repeated float diff = 6 [packed = true];
- case 6: {
- if (tag == 50) {
- parse_diff:
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, this->mutable_diff())));
- } else if (tag == 53) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- 1, 50, input, this->mutable_diff())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(58)) goto parse_shape;
- break;
- }
-
- // optional .caffe.BlobShape shape = 7;
- case 7: {
- if (tag == 58) {
- parse_shape:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_shape()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.BlobProto)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.BlobProto)
- return false;
-#undef DO_
-}
-
-void BlobProto::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.BlobProto)
- // optional int32 num = 1 [default = 0];
- if (has_num()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->num(), output);
- }
-
- // optional int32 channels = 2 [default = 0];
- if (has_channels()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->channels(), output);
- }
-
- // optional int32 height = 3 [default = 0];
- if (has_height()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->height(), output);
- }
-
- // optional int32 width = 4 [default = 0];
- if (has_width()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->width(), output);
- }
-
- // repeated float data = 5 [packed = true];
- if (this->data_size() > 0) {
- ::google::protobuf::internal::WireFormatLite::WriteTag(5, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output);
- output->WriteVarint32(_data_cached_byte_size_);
- }
- for (int i = 0; i < this->data_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteFloatNoTag(
- this->data(i), output);
- }
-
- // repeated float diff = 6 [packed = true];
- if (this->diff_size() > 0) {
- ::google::protobuf::internal::WireFormatLite::WriteTag(6, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output);
- output->WriteVarint32(_diff_cached_byte_size_);
- }
- for (int i = 0; i < this->diff_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteFloatNoTag(
- this->diff(i), output);
- }
-
- // optional .caffe.BlobShape shape = 7;
- if (has_shape()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 7, *this->shape_, output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.BlobProto)
-}
-
-::google::protobuf::uint8* BlobProto::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.BlobProto)
- // optional int32 num = 1 [default = 0];
- if (has_num()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->num(), target);
- }
-
- // optional int32 channels = 2 [default = 0];
- if (has_channels()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->channels(), target);
- }
-
- // optional int32 height = 3 [default = 0];
- if (has_height()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->height(), target);
- }
-
- // optional int32 width = 4 [default = 0];
- if (has_width()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->width(), target);
- }
-
- // repeated float data = 5 [packed = true];
- if (this->data_size() > 0) {
- target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray(
- 5,
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,
- target);
- target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(
- _data_cached_byte_size_, target);
- }
- for (int i = 0; i < this->data_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteFloatNoTagToArray(this->data(i), target);
- }
-
- // repeated float diff = 6 [packed = true];
- if (this->diff_size() > 0) {
- target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray(
- 6,
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,
- target);
- target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(
- _diff_cached_byte_size_, target);
- }
- for (int i = 0; i < this->diff_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteFloatNoTagToArray(this->diff(i), target);
- }
-
- // optional .caffe.BlobShape shape = 7;
- if (has_shape()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 7, *this->shape_, false, target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.BlobProto)
- return target;
-}
-
-size_t BlobProto::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.BlobProto)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 121u) {
- // optional .caffe.BlobShape shape = 7;
- if (has_shape()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->shape_);
- }
-
- // optional int32 num = 1 [default = 0];
- if (has_num()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->num());
- }
-
- // optional int32 channels = 2 [default = 0];
- if (has_channels()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->channels());
- }
-
- // optional int32 height = 3 [default = 0];
- if (has_height()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->height());
- }
-
- // optional int32 width = 4 [default = 0];
- if (has_width()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->width());
- }
-
- }
- // repeated float data = 5 [packed = true];
- {
- size_t data_size = 0;
- unsigned int count = this->data_size();
- data_size = 4UL * count;
- if (data_size > 0) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _data_cached_byte_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- total_size += data_size;
- }
-
- // repeated float diff = 6 [packed = true];
- {
- size_t data_size = 0;
- unsigned int count = this->diff_size();
- data_size = 4UL * count;
- if (data_size > 0) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _diff_cached_byte_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- total_size += data_size;
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void BlobProto::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.BlobProto)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const BlobProto* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const BlobProto>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.BlobProto)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.BlobProto)
- UnsafeMergeFrom(*source);
- }
-}
-
-void BlobProto::MergeFrom(const BlobProto& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.BlobProto)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void BlobProto::UnsafeMergeFrom(const BlobProto& from) {
- GOOGLE_DCHECK(&from != this);
- data_.UnsafeMergeFrom(from.data_);
- diff_.UnsafeMergeFrom(from.diff_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_shape()) {
- mutable_shape()->::caffe::BlobShape::MergeFrom(from.shape());
- }
- if (from.has_num()) {
- set_num(from.num());
- }
- if (from.has_channels()) {
- set_channels(from.channels());
- }
- if (from.has_height()) {
- set_height(from.height());
- }
- if (from.has_width()) {
- set_width(from.width());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void BlobProto::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.BlobProto)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void BlobProto::CopyFrom(const BlobProto& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.BlobProto)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool BlobProto::IsInitialized() const {
-
- return true;
-}
-
-void BlobProto::Swap(BlobProto* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void BlobProto::InternalSwap(BlobProto* other) {
- std::swap(shape_, other->shape_);
- data_.UnsafeArenaSwap(&other->data_);
- diff_.UnsafeArenaSwap(&other->diff_);
- std::swap(num_, other->num_);
- std::swap(channels_, other->channels_);
- std::swap(height_, other->height_);
- std::swap(width_, other->width_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata BlobProto::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = BlobProto_descriptor_;
- metadata.reflection = BlobProto_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// BlobProto
-
-// optional .caffe.BlobShape shape = 7;
-bool BlobProto::has_shape() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void BlobProto::set_has_shape() {
- _has_bits_[0] |= 0x00000001u;
-}
-void BlobProto::clear_has_shape() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void BlobProto::clear_shape() {
- if (shape_ != NULL) shape_->::caffe::BlobShape::Clear();
- clear_has_shape();
-}
-const ::caffe::BlobShape& BlobProto::shape() const {
- // @@protoc_insertion_point(field_get:caffe.BlobProto.shape)
- return shape_ != NULL ? *shape_
- : *::caffe::BlobShape::internal_default_instance();
-}
-::caffe::BlobShape* BlobProto::mutable_shape() {
- set_has_shape();
- if (shape_ == NULL) {
- shape_ = new ::caffe::BlobShape;
- }
- // @@protoc_insertion_point(field_mutable:caffe.BlobProto.shape)
- return shape_;
-}
-::caffe::BlobShape* BlobProto::release_shape() {
- // @@protoc_insertion_point(field_release:caffe.BlobProto.shape)
- clear_has_shape();
- ::caffe::BlobShape* temp = shape_;
- shape_ = NULL;
- return temp;
-}
-void BlobProto::set_allocated_shape(::caffe::BlobShape* shape) {
- delete shape_;
- shape_ = shape;
- if (shape) {
- set_has_shape();
- } else {
- clear_has_shape();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.BlobProto.shape)
-}
-
-// repeated float data = 5 [packed = true];
-int BlobProto::data_size() const {
- return data_.size();
-}
-void BlobProto::clear_data() {
- data_.Clear();
-}
-float BlobProto::data(int index) const {
- // @@protoc_insertion_point(field_get:caffe.BlobProto.data)
- return data_.Get(index);
-}
-void BlobProto::set_data(int index, float value) {
- data_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.BlobProto.data)
-}
-void BlobProto::add_data(float value) {
- data_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.BlobProto.data)
-}
-const ::google::protobuf::RepeatedField< float >&
-BlobProto::data() const {
- // @@protoc_insertion_point(field_list:caffe.BlobProto.data)
- return data_;
-}
-::google::protobuf::RepeatedField< float >*
-BlobProto::mutable_data() {
- // @@protoc_insertion_point(field_mutable_list:caffe.BlobProto.data)
- return &data_;
-}
-
-// repeated float diff = 6 [packed = true];
-int BlobProto::diff_size() const {
- return diff_.size();
-}
-void BlobProto::clear_diff() {
- diff_.Clear();
-}
-float BlobProto::diff(int index) const {
- // @@protoc_insertion_point(field_get:caffe.BlobProto.diff)
- return diff_.Get(index);
-}
-void BlobProto::set_diff(int index, float value) {
- diff_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.BlobProto.diff)
-}
-void BlobProto::add_diff(float value) {
- diff_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.BlobProto.diff)
-}
-const ::google::protobuf::RepeatedField< float >&
-BlobProto::diff() const {
- // @@protoc_insertion_point(field_list:caffe.BlobProto.diff)
- return diff_;
-}
-::google::protobuf::RepeatedField< float >*
-BlobProto::mutable_diff() {
- // @@protoc_insertion_point(field_mutable_list:caffe.BlobProto.diff)
- return &diff_;
-}
-
-// optional int32 num = 1 [default = 0];
-bool BlobProto::has_num() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-void BlobProto::set_has_num() {
- _has_bits_[0] |= 0x00000008u;
-}
-void BlobProto::clear_has_num() {
- _has_bits_[0] &= ~0x00000008u;
-}
-void BlobProto::clear_num() {
- num_ = 0;
- clear_has_num();
-}
-::google::protobuf::int32 BlobProto::num() const {
- // @@protoc_insertion_point(field_get:caffe.BlobProto.num)
- return num_;
-}
-void BlobProto::set_num(::google::protobuf::int32 value) {
- set_has_num();
- num_ = value;
- // @@protoc_insertion_point(field_set:caffe.BlobProto.num)
-}
-
-// optional int32 channels = 2 [default = 0];
-bool BlobProto::has_channels() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-void BlobProto::set_has_channels() {
- _has_bits_[0] |= 0x00000010u;
-}
-void BlobProto::clear_has_channels() {
- _has_bits_[0] &= ~0x00000010u;
-}
-void BlobProto::clear_channels() {
- channels_ = 0;
- clear_has_channels();
-}
-::google::protobuf::int32 BlobProto::channels() const {
- // @@protoc_insertion_point(field_get:caffe.BlobProto.channels)
- return channels_;
-}
-void BlobProto::set_channels(::google::protobuf::int32 value) {
- set_has_channels();
- channels_ = value;
- // @@protoc_insertion_point(field_set:caffe.BlobProto.channels)
-}
-
-// optional int32 height = 3 [default = 0];
-bool BlobProto::has_height() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-void BlobProto::set_has_height() {
- _has_bits_[0] |= 0x00000020u;
-}
-void BlobProto::clear_has_height() {
- _has_bits_[0] &= ~0x00000020u;
-}
-void BlobProto::clear_height() {
- height_ = 0;
- clear_has_height();
-}
-::google::protobuf::int32 BlobProto::height() const {
- // @@protoc_insertion_point(field_get:caffe.BlobProto.height)
- return height_;
-}
-void BlobProto::set_height(::google::protobuf::int32 value) {
- set_has_height();
- height_ = value;
- // @@protoc_insertion_point(field_set:caffe.BlobProto.height)
-}
-
-// optional int32 width = 4 [default = 0];
-bool BlobProto::has_width() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-void BlobProto::set_has_width() {
- _has_bits_[0] |= 0x00000040u;
-}
-void BlobProto::clear_has_width() {
- _has_bits_[0] &= ~0x00000040u;
-}
-void BlobProto::clear_width() {
- width_ = 0;
- clear_has_width();
-}
-::google::protobuf::int32 BlobProto::width() const {
- // @@protoc_insertion_point(field_get:caffe.BlobProto.width)
- return width_;
-}
-void BlobProto::set_width(::google::protobuf::int32 value) {
- set_has_width();
- width_ = value;
- // @@protoc_insertion_point(field_set:caffe.BlobProto.width)
-}
-
-inline const BlobProto* BlobProto::internal_default_instance() {
- return &BlobProto_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int BlobProtoVector::kBlobsFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-BlobProtoVector::BlobProtoVector()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.BlobProtoVector)
-}
-
-void BlobProtoVector::InitAsDefaultInstance() {
-}
-
-BlobProtoVector::BlobProtoVector(const BlobProtoVector& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.BlobProtoVector)
-}
-
-void BlobProtoVector::SharedCtor() {
- _cached_size_ = 0;
-}
-
-BlobProtoVector::~BlobProtoVector() {
- // @@protoc_insertion_point(destructor:caffe.BlobProtoVector)
- SharedDtor();
-}
-
-void BlobProtoVector::SharedDtor() {
-}
-
-void BlobProtoVector::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* BlobProtoVector::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return BlobProtoVector_descriptor_;
-}
-
-const BlobProtoVector& BlobProtoVector::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<BlobProtoVector> BlobProtoVector_default_instance_;
-
-BlobProtoVector* BlobProtoVector::New(::google::protobuf::Arena* arena) const {
- BlobProtoVector* n = new BlobProtoVector;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void BlobProtoVector::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.BlobProtoVector)
- blobs_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool BlobProtoVector::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.BlobProtoVector)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // repeated .caffe.BlobProto blobs = 1;
- case 1: {
- if (tag == 10) {
- DO_(input->IncrementRecursionDepth());
- parse_loop_blobs:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
- input, add_blobs()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(10)) goto parse_loop_blobs;
- input->UnsafeDecrementRecursionDepth();
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.BlobProtoVector)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.BlobProtoVector)
- return false;
-#undef DO_
-}
-
-void BlobProtoVector::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.BlobProtoVector)
- // repeated .caffe.BlobProto blobs = 1;
- for (unsigned int i = 0, n = this->blobs_size(); i < n; i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 1, this->blobs(i), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.BlobProtoVector)
-}
-
-::google::protobuf::uint8* BlobProtoVector::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.BlobProtoVector)
- // repeated .caffe.BlobProto blobs = 1;
- for (unsigned int i = 0, n = this->blobs_size(); i < n; i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 1, this->blobs(i), false, target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.BlobProtoVector)
- return target;
-}
-
-size_t BlobProtoVector::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.BlobProtoVector)
- size_t total_size = 0;
-
- // repeated .caffe.BlobProto blobs = 1;
- {
- unsigned int count = this->blobs_size();
- total_size += 1UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->blobs(i));
- }
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void BlobProtoVector::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.BlobProtoVector)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const BlobProtoVector* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const BlobProtoVector>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.BlobProtoVector)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.BlobProtoVector)
- UnsafeMergeFrom(*source);
- }
-}
-
-void BlobProtoVector::MergeFrom(const BlobProtoVector& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.BlobProtoVector)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void BlobProtoVector::UnsafeMergeFrom(const BlobProtoVector& from) {
- GOOGLE_DCHECK(&from != this);
- blobs_.MergeFrom(from.blobs_);
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void BlobProtoVector::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.BlobProtoVector)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void BlobProtoVector::CopyFrom(const BlobProtoVector& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.BlobProtoVector)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool BlobProtoVector::IsInitialized() const {
-
- return true;
-}
-
-void BlobProtoVector::Swap(BlobProtoVector* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void BlobProtoVector::InternalSwap(BlobProtoVector* other) {
- blobs_.UnsafeArenaSwap(&other->blobs_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata BlobProtoVector::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = BlobProtoVector_descriptor_;
- metadata.reflection = BlobProtoVector_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// BlobProtoVector
-
-// repeated .caffe.BlobProto blobs = 1;
-int BlobProtoVector::blobs_size() const {
- return blobs_.size();
-}
-void BlobProtoVector::clear_blobs() {
- blobs_.Clear();
-}
-const ::caffe::BlobProto& BlobProtoVector::blobs(int index) const {
- // @@protoc_insertion_point(field_get:caffe.BlobProtoVector.blobs)
- return blobs_.Get(index);
-}
-::caffe::BlobProto* BlobProtoVector::mutable_blobs(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.BlobProtoVector.blobs)
- return blobs_.Mutable(index);
-}
-::caffe::BlobProto* BlobProtoVector::add_blobs() {
- // @@protoc_insertion_point(field_add:caffe.BlobProtoVector.blobs)
- return blobs_.Add();
-}
-::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
-BlobProtoVector::mutable_blobs() {
- // @@protoc_insertion_point(field_mutable_list:caffe.BlobProtoVector.blobs)
- return &blobs_;
-}
-const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
-BlobProtoVector::blobs() const {
- // @@protoc_insertion_point(field_list:caffe.BlobProtoVector.blobs)
- return blobs_;
-}
-
-inline const BlobProtoVector* BlobProtoVector::internal_default_instance() {
- return &BlobProtoVector_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int CropParameter::kAxisFieldNumber;
-const int CropParameter::kOffsetFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-CropParameter::CropParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.CropParameter)
-}
-
-void CropParameter::InitAsDefaultInstance() {
-}
-
-CropParameter::CropParameter(const CropParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.CropParameter)
-}
-
-void CropParameter::SharedCtor() {
- _cached_size_ = 0;
- axis_ = 2;
-}
-
-CropParameter::~CropParameter() {
- // @@protoc_insertion_point(destructor:caffe.CropParameter)
- SharedDtor();
-}
-
-void CropParameter::SharedDtor() {
-}
-
-void CropParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* CropParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return CropParameter_descriptor_;
-}
-
-const CropParameter& CropParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<CropParameter> CropParameter_default_instance_;
-
-CropParameter* CropParameter::New(::google::protobuf::Arena* arena) const {
- CropParameter* n = new CropParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void CropParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.CropParameter)
- axis_ = 2;
- offset_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool CropParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.CropParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional int32 axis = 1 [default = 2];
- case 1: {
- if (tag == 8) {
- set_has_axis();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &axis_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_offset;
- break;
- }
-
- // repeated uint32 offset = 2;
- case 2: {
- if (tag == 16) {
- parse_offset:
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- 1, 16, input, this->mutable_offset())));
- } else if (tag == 18) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, this->mutable_offset())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_offset;
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.CropParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.CropParameter)
- return false;
-#undef DO_
-}
-
-void CropParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.CropParameter)
- // optional int32 axis = 1 [default = 2];
- if (has_axis()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->axis(), output);
- }
-
- // repeated uint32 offset = 2;
- for (int i = 0; i < this->offset_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(
- 2, this->offset(i), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.CropParameter)
-}
-
-::google::protobuf::uint8* CropParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.CropParameter)
- // optional int32 axis = 1 [default = 2];
- if (has_axis()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->axis(), target);
- }
-
- // repeated uint32 offset = 2;
- for (int i = 0; i < this->offset_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteUInt32ToArray(2, this->offset(i), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.CropParameter)
- return target;
-}
-
-size_t CropParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.CropParameter)
- size_t total_size = 0;
-
- // optional int32 axis = 1 [default = 2];
- if (has_axis()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->axis());
- }
-
- // repeated uint32 offset = 2;
- {
- size_t data_size = 0;
- unsigned int count = this->offset_size();
- for (unsigned int i = 0; i < count; i++) {
- data_size += ::google::protobuf::internal::WireFormatLite::
- UInt32Size(this->offset(i));
- }
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->offset_size());
- total_size += data_size;
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void CropParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.CropParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const CropParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const CropParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.CropParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.CropParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void CropParameter::MergeFrom(const CropParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.CropParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void CropParameter::UnsafeMergeFrom(const CropParameter& from) {
- GOOGLE_DCHECK(&from != this);
- offset_.UnsafeMergeFrom(from.offset_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_axis()) {
- set_axis(from.axis());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void CropParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.CropParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void CropParameter::CopyFrom(const CropParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.CropParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool CropParameter::IsInitialized() const {
-
- return true;
-}
-
-void CropParameter::Swap(CropParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void CropParameter::InternalSwap(CropParameter* other) {
- std::swap(axis_, other->axis_);
- offset_.UnsafeArenaSwap(&other->offset_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata CropParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = CropParameter_descriptor_;
- metadata.reflection = CropParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// CropParameter
-
-// optional int32 axis = 1 [default = 2];
-bool CropParameter::has_axis() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void CropParameter::set_has_axis() {
- _has_bits_[0] |= 0x00000001u;
-}
-void CropParameter::clear_has_axis() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void CropParameter::clear_axis() {
- axis_ = 2;
- clear_has_axis();
-}
-::google::protobuf::int32 CropParameter::axis() const {
- // @@protoc_insertion_point(field_get:caffe.CropParameter.axis)
- return axis_;
-}
-void CropParameter::set_axis(::google::protobuf::int32 value) {
- set_has_axis();
- axis_ = value;
- // @@protoc_insertion_point(field_set:caffe.CropParameter.axis)
-}
-
-// repeated uint32 offset = 2;
-int CropParameter::offset_size() const {
- return offset_.size();
-}
-void CropParameter::clear_offset() {
- offset_.Clear();
-}
-::google::protobuf::uint32 CropParameter::offset(int index) const {
- // @@protoc_insertion_point(field_get:caffe.CropParameter.offset)
- return offset_.Get(index);
-}
-void CropParameter::set_offset(int index, ::google::protobuf::uint32 value) {
- offset_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.CropParameter.offset)
-}
-void CropParameter::add_offset(::google::protobuf::uint32 value) {
- offset_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.CropParameter.offset)
-}
-const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-CropParameter::offset() const {
- // @@protoc_insertion_point(field_list:caffe.CropParameter.offset)
- return offset_;
-}
-::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-CropParameter::mutable_offset() {
- // @@protoc_insertion_point(field_mutable_list:caffe.CropParameter.offset)
- return &offset_;
-}
-
-inline const CropParameter* CropParameter::internal_default_instance() {
- return &CropParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int PermuteParameter::kOrderFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-PermuteParameter::PermuteParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.PermuteParameter)
-}
-
-void PermuteParameter::InitAsDefaultInstance() {
-}
-
-PermuteParameter::PermuteParameter(const PermuteParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.PermuteParameter)
-}
-
-void PermuteParameter::SharedCtor() {
- _cached_size_ = 0;
-}
-
-PermuteParameter::~PermuteParameter() {
- // @@protoc_insertion_point(destructor:caffe.PermuteParameter)
- SharedDtor();
-}
-
-void PermuteParameter::SharedDtor() {
-}
-
-void PermuteParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* PermuteParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return PermuteParameter_descriptor_;
-}
-
-const PermuteParameter& PermuteParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<PermuteParameter> PermuteParameter_default_instance_;
-
-PermuteParameter* PermuteParameter::New(::google::protobuf::Arena* arena) const {
- PermuteParameter* n = new PermuteParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void PermuteParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.PermuteParameter)
- order_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool PermuteParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.PermuteParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // repeated uint32 order = 1;
- case 1: {
- if (tag == 8) {
- parse_order:
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- 1, 8, input, this->mutable_order())));
- } else if (tag == 10) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, this->mutable_order())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(8)) goto parse_order;
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.PermuteParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.PermuteParameter)
- return false;
-#undef DO_
-}
-
-void PermuteParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.PermuteParameter)
- // repeated uint32 order = 1;
- for (int i = 0; i < this->order_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(
- 1, this->order(i), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.PermuteParameter)
-}
-
-::google::protobuf::uint8* PermuteParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.PermuteParameter)
- // repeated uint32 order = 1;
- for (int i = 0; i < this->order_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteUInt32ToArray(1, this->order(i), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.PermuteParameter)
- return target;
-}
-
-size_t PermuteParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.PermuteParameter)
- size_t total_size = 0;
-
- // repeated uint32 order = 1;
- {
- size_t data_size = 0;
- unsigned int count = this->order_size();
- for (unsigned int i = 0; i < count; i++) {
- data_size += ::google::protobuf::internal::WireFormatLite::
- UInt32Size(this->order(i));
- }
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->order_size());
- total_size += data_size;
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void PermuteParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.PermuteParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const PermuteParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const PermuteParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.PermuteParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.PermuteParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void PermuteParameter::MergeFrom(const PermuteParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.PermuteParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void PermuteParameter::UnsafeMergeFrom(const PermuteParameter& from) {
- GOOGLE_DCHECK(&from != this);
- order_.UnsafeMergeFrom(from.order_);
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void PermuteParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.PermuteParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void PermuteParameter::CopyFrom(const PermuteParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.PermuteParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool PermuteParameter::IsInitialized() const {
-
- return true;
-}
-
-void PermuteParameter::Swap(PermuteParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void PermuteParameter::InternalSwap(PermuteParameter* other) {
- order_.UnsafeArenaSwap(&other->order_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata PermuteParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = PermuteParameter_descriptor_;
- metadata.reflection = PermuteParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// PermuteParameter
-
-// repeated uint32 order = 1;
-int PermuteParameter::order_size() const {
- return order_.size();
-}
-void PermuteParameter::clear_order() {
- order_.Clear();
-}
-::google::protobuf::uint32 PermuteParameter::order(int index) const {
- // @@protoc_insertion_point(field_get:caffe.PermuteParameter.order)
- return order_.Get(index);
-}
-void PermuteParameter::set_order(int index, ::google::protobuf::uint32 value) {
- order_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.PermuteParameter.order)
-}
-void PermuteParameter::add_order(::google::protobuf::uint32 value) {
- order_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.PermuteParameter.order)
-}
-const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-PermuteParameter::order() const {
- // @@protoc_insertion_point(field_list:caffe.PermuteParameter.order)
- return order_;
-}
-::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-PermuteParameter::mutable_order() {
- // @@protoc_insertion_point(field_mutable_list:caffe.PermuteParameter.order)
- return &order_;
-}
-
-inline const PermuteParameter* PermuteParameter::internal_default_instance() {
- return &PermuteParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int NormalizeBBoxParameter::kAcrossSpatialFieldNumber;
-const int NormalizeBBoxParameter::kScaleFillerFieldNumber;
-const int NormalizeBBoxParameter::kChannelSharedFieldNumber;
-const int NormalizeBBoxParameter::kEpsFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-NormalizeBBoxParameter::NormalizeBBoxParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.NormalizeBBoxParameter)
-}
-
-void NormalizeBBoxParameter::InitAsDefaultInstance() {
- scale_filler_ = const_cast< ::caffe::FillerParameter*>(
- ::caffe::FillerParameter::internal_default_instance());
-}
-
-NormalizeBBoxParameter::NormalizeBBoxParameter(const NormalizeBBoxParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.NormalizeBBoxParameter)
-}
-
-void NormalizeBBoxParameter::SharedCtor() {
- _cached_size_ = 0;
- scale_filler_ = NULL;
- across_spatial_ = true;
- channel_shared_ = true;
- eps_ = 1e-10f;
-}
-
-NormalizeBBoxParameter::~NormalizeBBoxParameter() {
- // @@protoc_insertion_point(destructor:caffe.NormalizeBBoxParameter)
- SharedDtor();
-}
-
-void NormalizeBBoxParameter::SharedDtor() {
- if (this != &NormalizeBBoxParameter_default_instance_.get()) {
- delete scale_filler_;
- }
-}
-
-void NormalizeBBoxParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* NormalizeBBoxParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return NormalizeBBoxParameter_descriptor_;
-}
-
-const NormalizeBBoxParameter& NormalizeBBoxParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<NormalizeBBoxParameter> NormalizeBBoxParameter_default_instance_;
-
-NormalizeBBoxParameter* NormalizeBBoxParameter::New(::google::protobuf::Arena* arena) const {
- NormalizeBBoxParameter* n = new NormalizeBBoxParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void NormalizeBBoxParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.NormalizeBBoxParameter)
- if (_has_bits_[0 / 32] & 15u) {
- across_spatial_ = true;
- if (has_scale_filler()) {
- if (scale_filler_ != NULL) scale_filler_->::caffe::FillerParameter::Clear();
- }
- channel_shared_ = true;
- eps_ = 1e-10f;
- }
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool NormalizeBBoxParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.NormalizeBBoxParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional bool across_spatial = 1 [default = true];
- case 1: {
- if (tag == 8) {
- set_has_across_spatial();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &across_spatial_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(18)) goto parse_scale_filler;
- break;
- }
-
- // optional .caffe.FillerParameter scale_filler = 2;
- case 2: {
- if (tag == 18) {
- parse_scale_filler:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_scale_filler()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(24)) goto parse_channel_shared;
- break;
- }
-
- // optional bool channel_shared = 3 [default = true];
- case 3: {
- if (tag == 24) {
- parse_channel_shared:
- set_has_channel_shared();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &channel_shared_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(37)) goto parse_eps;
- break;
- }
-
- // optional float eps = 4 [default = 1e-10];
- case 4: {
- if (tag == 37) {
- parse_eps:
- set_has_eps();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &eps_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.NormalizeBBoxParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.NormalizeBBoxParameter)
- return false;
-#undef DO_
-}
-
-void NormalizeBBoxParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.NormalizeBBoxParameter)
- // optional bool across_spatial = 1 [default = true];
- if (has_across_spatial()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(1, this->across_spatial(), output);
- }
-
- // optional .caffe.FillerParameter scale_filler = 2;
- if (has_scale_filler()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 2, *this->scale_filler_, output);
- }
-
- // optional bool channel_shared = 3 [default = true];
- if (has_channel_shared()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(3, this->channel_shared(), output);
- }
-
- // optional float eps = 4 [default = 1e-10];
- if (has_eps()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(4, this->eps(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.NormalizeBBoxParameter)
-}
-
-::google::protobuf::uint8* NormalizeBBoxParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.NormalizeBBoxParameter)
- // optional bool across_spatial = 1 [default = true];
- if (has_across_spatial()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->across_spatial(), target);
- }
-
- // optional .caffe.FillerParameter scale_filler = 2;
- if (has_scale_filler()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 2, *this->scale_filler_, false, target);
- }
-
- // optional bool channel_shared = 3 [default = true];
- if (has_channel_shared()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(3, this->channel_shared(), target);
- }
-
- // optional float eps = 4 [default = 1e-10];
- if (has_eps()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(4, this->eps(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.NormalizeBBoxParameter)
- return target;
-}
-
-size_t NormalizeBBoxParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.NormalizeBBoxParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 15u) {
- // optional bool across_spatial = 1 [default = true];
- if (has_across_spatial()) {
- total_size += 1 + 1;
- }
-
- // optional .caffe.FillerParameter scale_filler = 2;
- if (has_scale_filler()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->scale_filler_);
- }
-
- // optional bool channel_shared = 3 [default = true];
- if (has_channel_shared()) {
- total_size += 1 + 1;
- }
-
- // optional float eps = 4 [default = 1e-10];
- if (has_eps()) {
- total_size += 1 + 4;
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void NormalizeBBoxParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.NormalizeBBoxParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const NormalizeBBoxParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const NormalizeBBoxParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.NormalizeBBoxParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.NormalizeBBoxParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void NormalizeBBoxParameter::MergeFrom(const NormalizeBBoxParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.NormalizeBBoxParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void NormalizeBBoxParameter::UnsafeMergeFrom(const NormalizeBBoxParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_across_spatial()) {
- set_across_spatial(from.across_spatial());
- }
- if (from.has_scale_filler()) {
- mutable_scale_filler()->::caffe::FillerParameter::MergeFrom(from.scale_filler());
- }
- if (from.has_channel_shared()) {
- set_channel_shared(from.channel_shared());
- }
- if (from.has_eps()) {
- set_eps(from.eps());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void NormalizeBBoxParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.NormalizeBBoxParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void NormalizeBBoxParameter::CopyFrom(const NormalizeBBoxParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.NormalizeBBoxParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool NormalizeBBoxParameter::IsInitialized() const {
-
- return true;
-}
-
-void NormalizeBBoxParameter::Swap(NormalizeBBoxParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void NormalizeBBoxParameter::InternalSwap(NormalizeBBoxParameter* other) {
- std::swap(across_spatial_, other->across_spatial_);
- std::swap(scale_filler_, other->scale_filler_);
- std::swap(channel_shared_, other->channel_shared_);
- std::swap(eps_, other->eps_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata NormalizeBBoxParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = NormalizeBBoxParameter_descriptor_;
- metadata.reflection = NormalizeBBoxParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// NormalizeBBoxParameter
-
-// optional bool across_spatial = 1 [default = true];
-bool NormalizeBBoxParameter::has_across_spatial() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void NormalizeBBoxParameter::set_has_across_spatial() {
- _has_bits_[0] |= 0x00000001u;
-}
-void NormalizeBBoxParameter::clear_has_across_spatial() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void NormalizeBBoxParameter::clear_across_spatial() {
- across_spatial_ = true;
- clear_has_across_spatial();
-}
-bool NormalizeBBoxParameter::across_spatial() const {
- // @@protoc_insertion_point(field_get:caffe.NormalizeBBoxParameter.across_spatial)
- return across_spatial_;
-}
-void NormalizeBBoxParameter::set_across_spatial(bool value) {
- set_has_across_spatial();
- across_spatial_ = value;
- // @@protoc_insertion_point(field_set:caffe.NormalizeBBoxParameter.across_spatial)
-}
-
-// optional .caffe.FillerParameter scale_filler = 2;
-bool NormalizeBBoxParameter::has_scale_filler() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void NormalizeBBoxParameter::set_has_scale_filler() {
- _has_bits_[0] |= 0x00000002u;
-}
-void NormalizeBBoxParameter::clear_has_scale_filler() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void NormalizeBBoxParameter::clear_scale_filler() {
- if (scale_filler_ != NULL) scale_filler_->::caffe::FillerParameter::Clear();
- clear_has_scale_filler();
-}
-const ::caffe::FillerParameter& NormalizeBBoxParameter::scale_filler() const {
- // @@protoc_insertion_point(field_get:caffe.NormalizeBBoxParameter.scale_filler)
- return scale_filler_ != NULL ? *scale_filler_
- : *::caffe::FillerParameter::internal_default_instance();
-}
-::caffe::FillerParameter* NormalizeBBoxParameter::mutable_scale_filler() {
- set_has_scale_filler();
- if (scale_filler_ == NULL) {
- scale_filler_ = new ::caffe::FillerParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.NormalizeBBoxParameter.scale_filler)
- return scale_filler_;
-}
-::caffe::FillerParameter* NormalizeBBoxParameter::release_scale_filler() {
- // @@protoc_insertion_point(field_release:caffe.NormalizeBBoxParameter.scale_filler)
- clear_has_scale_filler();
- ::caffe::FillerParameter* temp = scale_filler_;
- scale_filler_ = NULL;
- return temp;
-}
-void NormalizeBBoxParameter::set_allocated_scale_filler(::caffe::FillerParameter* scale_filler) {
- delete scale_filler_;
- scale_filler_ = scale_filler;
- if (scale_filler) {
- set_has_scale_filler();
- } else {
- clear_has_scale_filler();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.NormalizeBBoxParameter.scale_filler)
-}
-
-// optional bool channel_shared = 3 [default = true];
-bool NormalizeBBoxParameter::has_channel_shared() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void NormalizeBBoxParameter::set_has_channel_shared() {
- _has_bits_[0] |= 0x00000004u;
-}
-void NormalizeBBoxParameter::clear_has_channel_shared() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void NormalizeBBoxParameter::clear_channel_shared() {
- channel_shared_ = true;
- clear_has_channel_shared();
-}
-bool NormalizeBBoxParameter::channel_shared() const {
- // @@protoc_insertion_point(field_get:caffe.NormalizeBBoxParameter.channel_shared)
- return channel_shared_;
-}
-void NormalizeBBoxParameter::set_channel_shared(bool value) {
- set_has_channel_shared();
- channel_shared_ = value;
- // @@protoc_insertion_point(field_set:caffe.NormalizeBBoxParameter.channel_shared)
-}
-
-// optional float eps = 4 [default = 1e-10];
-bool NormalizeBBoxParameter::has_eps() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-void NormalizeBBoxParameter::set_has_eps() {
- _has_bits_[0] |= 0x00000008u;
-}
-void NormalizeBBoxParameter::clear_has_eps() {
- _has_bits_[0] &= ~0x00000008u;
-}
-void NormalizeBBoxParameter::clear_eps() {
- eps_ = 1e-10f;
- clear_has_eps();
-}
-float NormalizeBBoxParameter::eps() const {
- // @@protoc_insertion_point(field_get:caffe.NormalizeBBoxParameter.eps)
- return eps_;
-}
-void NormalizeBBoxParameter::set_eps(float value) {
- set_has_eps();
- eps_ = value;
- // @@protoc_insertion_point(field_set:caffe.NormalizeBBoxParameter.eps)
-}
-
-inline const NormalizeBBoxParameter* NormalizeBBoxParameter::internal_default_instance() {
- return &NormalizeBBoxParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-const ::google::protobuf::EnumDescriptor* PriorBoxParameter_CodeType_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return PriorBoxParameter_CodeType_descriptor_;
-}
-bool PriorBoxParameter_CodeType_IsValid(int value) {
- switch (value) {
- case 1:
- case 2:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const PriorBoxParameter_CodeType PriorBoxParameter::CORNER;
-const PriorBoxParameter_CodeType PriorBoxParameter::CENTER_SIZE;
-const PriorBoxParameter_CodeType PriorBoxParameter::CodeType_MIN;
-const PriorBoxParameter_CodeType PriorBoxParameter::CodeType_MAX;
-const int PriorBoxParameter::CodeType_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int PriorBoxParameter::kMinSizeFieldNumber;
-const int PriorBoxParameter::kMaxSizeFieldNumber;
-const int PriorBoxParameter::kAspectRatioFieldNumber;
-const int PriorBoxParameter::kFlipFieldNumber;
-const int PriorBoxParameter::kClipFieldNumber;
-const int PriorBoxParameter::kVarianceFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-PriorBoxParameter::PriorBoxParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.PriorBoxParameter)
-}
-
-void PriorBoxParameter::InitAsDefaultInstance() {
-}
-
-PriorBoxParameter::PriorBoxParameter(const PriorBoxParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.PriorBoxParameter)
-}
-
-void PriorBoxParameter::SharedCtor() {
- _cached_size_ = 0;
- ::memset(&min_size_, 0, reinterpret_cast<char*>(&max_size_) -
- reinterpret_cast<char*>(&min_size_) + sizeof(max_size_));
- flip_ = true;
- clip_ = true;
-}
-
-PriorBoxParameter::~PriorBoxParameter() {
- // @@protoc_insertion_point(destructor:caffe.PriorBoxParameter)
- SharedDtor();
-}
-
-void PriorBoxParameter::SharedDtor() {
-}
-
-void PriorBoxParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* PriorBoxParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return PriorBoxParameter_descriptor_;
-}
-
-const PriorBoxParameter& PriorBoxParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<PriorBoxParameter> PriorBoxParameter_default_instance_;
-
-PriorBoxParameter* PriorBoxParameter::New(::google::protobuf::Arena* arena) const {
- PriorBoxParameter* n = new PriorBoxParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void PriorBoxParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.PriorBoxParameter)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(PriorBoxParameter, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<PriorBoxParameter*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- if (_has_bits_[0 / 32] & 27u) {
- ZR_(min_size_, max_size_);
- flip_ = true;
- clip_ = true;
- }
-
-#undef ZR_HELPER_
-#undef ZR_
-
- aspect_ratio_.Clear();
- variance_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool PriorBoxParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.PriorBoxParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional float min_size = 1;
- case 1: {
- if (tag == 13) {
- set_has_min_size();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &min_size_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(21)) goto parse_max_size;
- break;
- }
-
- // optional float max_size = 2;
- case 2: {
- if (tag == 21) {
- parse_max_size:
- set_has_max_size();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &max_size_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(29)) goto parse_aspect_ratio;
- break;
- }
-
- // repeated float aspect_ratio = 3;
- case 3: {
- if (tag == 29) {
- parse_aspect_ratio:
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- 1, 29, input, this->mutable_aspect_ratio())));
- } else if (tag == 26) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, this->mutable_aspect_ratio())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(29)) goto parse_aspect_ratio;
- if (input->ExpectTag(32)) goto parse_flip;
- break;
- }
-
- // optional bool flip = 4 [default = true];
- case 4: {
- if (tag == 32) {
- parse_flip:
- set_has_flip();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &flip_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(40)) goto parse_clip;
- break;
- }
-
- // optional bool clip = 5 [default = true];
- case 5: {
- if (tag == 40) {
- parse_clip:
- set_has_clip();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &clip_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(53)) goto parse_variance;
- break;
- }
-
- // repeated float variance = 6;
- case 6: {
- if (tag == 53) {
- parse_variance:
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- 1, 53, input, this->mutable_variance())));
- } else if (tag == 50) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, this->mutable_variance())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(53)) goto parse_variance;
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.PriorBoxParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.PriorBoxParameter)
- return false;
-#undef DO_
-}
-
-void PriorBoxParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.PriorBoxParameter)
- // optional float min_size = 1;
- if (has_min_size()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->min_size(), output);
- }
-
- // optional float max_size = 2;
- if (has_max_size()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->max_size(), output);
- }
-
- // repeated float aspect_ratio = 3;
- for (int i = 0; i < this->aspect_ratio_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(
- 3, this->aspect_ratio(i), output);
- }
-
- // optional bool flip = 4 [default = true];
- if (has_flip()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(4, this->flip(), output);
- }
-
- // optional bool clip = 5 [default = true];
- if (has_clip()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(5, this->clip(), output);
- }
-
- // repeated float variance = 6;
- for (int i = 0; i < this->variance_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(
- 6, this->variance(i), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.PriorBoxParameter)
-}
-
-::google::protobuf::uint8* PriorBoxParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.PriorBoxParameter)
- // optional float min_size = 1;
- if (has_min_size()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->min_size(), target);
- }
-
- // optional float max_size = 2;
- if (has_max_size()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->max_size(), target);
- }
-
- // repeated float aspect_ratio = 3;
- for (int i = 0; i < this->aspect_ratio_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteFloatToArray(3, this->aspect_ratio(i), target);
- }
-
- // optional bool flip = 4 [default = true];
- if (has_flip()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(4, this->flip(), target);
- }
-
- // optional bool clip = 5 [default = true];
- if (has_clip()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(5, this->clip(), target);
- }
-
- // repeated float variance = 6;
- for (int i = 0; i < this->variance_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteFloatToArray(6, this->variance(i), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.PriorBoxParameter)
- return target;
-}
-
-size_t PriorBoxParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.PriorBoxParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 27u) {
- // optional float min_size = 1;
- if (has_min_size()) {
- total_size += 1 + 4;
- }
-
- // optional float max_size = 2;
- if (has_max_size()) {
- total_size += 1 + 4;
- }
-
- // optional bool flip = 4 [default = true];
- if (has_flip()) {
- total_size += 1 + 1;
- }
-
- // optional bool clip = 5 [default = true];
- if (has_clip()) {
- total_size += 1 + 1;
- }
-
- }
- // repeated float aspect_ratio = 3;
- {
- size_t data_size = 0;
- unsigned int count = this->aspect_ratio_size();
- data_size = 4UL * count;
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->aspect_ratio_size());
- total_size += data_size;
- }
-
- // repeated float variance = 6;
- {
- size_t data_size = 0;
- unsigned int count = this->variance_size();
- data_size = 4UL * count;
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->variance_size());
- total_size += data_size;
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void PriorBoxParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.PriorBoxParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const PriorBoxParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const PriorBoxParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.PriorBoxParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.PriorBoxParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void PriorBoxParameter::MergeFrom(const PriorBoxParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.PriorBoxParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void PriorBoxParameter::UnsafeMergeFrom(const PriorBoxParameter& from) {
- GOOGLE_DCHECK(&from != this);
- aspect_ratio_.UnsafeMergeFrom(from.aspect_ratio_);
- variance_.UnsafeMergeFrom(from.variance_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_min_size()) {
- set_min_size(from.min_size());
- }
- if (from.has_max_size()) {
- set_max_size(from.max_size());
- }
- if (from.has_flip()) {
- set_flip(from.flip());
- }
- if (from.has_clip()) {
- set_clip(from.clip());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void PriorBoxParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.PriorBoxParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void PriorBoxParameter::CopyFrom(const PriorBoxParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.PriorBoxParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool PriorBoxParameter::IsInitialized() const {
-
- return true;
-}
-
-void PriorBoxParameter::Swap(PriorBoxParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void PriorBoxParameter::InternalSwap(PriorBoxParameter* other) {
- std::swap(min_size_, other->min_size_);
- std::swap(max_size_, other->max_size_);
- aspect_ratio_.UnsafeArenaSwap(&other->aspect_ratio_);
- std::swap(flip_, other->flip_);
- std::swap(clip_, other->clip_);
- variance_.UnsafeArenaSwap(&other->variance_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata PriorBoxParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = PriorBoxParameter_descriptor_;
- metadata.reflection = PriorBoxParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// PriorBoxParameter
-
-// optional float min_size = 1;
-bool PriorBoxParameter::has_min_size() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void PriorBoxParameter::set_has_min_size() {
- _has_bits_[0] |= 0x00000001u;
-}
-void PriorBoxParameter::clear_has_min_size() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void PriorBoxParameter::clear_min_size() {
- min_size_ = 0;
- clear_has_min_size();
-}
-float PriorBoxParameter::min_size() const {
- // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.min_size)
- return min_size_;
-}
-void PriorBoxParameter::set_min_size(float value) {
- set_has_min_size();
- min_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.min_size)
-}
-
-// optional float max_size = 2;
-bool PriorBoxParameter::has_max_size() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void PriorBoxParameter::set_has_max_size() {
- _has_bits_[0] |= 0x00000002u;
-}
-void PriorBoxParameter::clear_has_max_size() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void PriorBoxParameter::clear_max_size() {
- max_size_ = 0;
- clear_has_max_size();
-}
-float PriorBoxParameter::max_size() const {
- // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.max_size)
- return max_size_;
-}
-void PriorBoxParameter::set_max_size(float value) {
- set_has_max_size();
- max_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.max_size)
-}
-
-// repeated float aspect_ratio = 3;
-int PriorBoxParameter::aspect_ratio_size() const {
- return aspect_ratio_.size();
-}
-void PriorBoxParameter::clear_aspect_ratio() {
- aspect_ratio_.Clear();
-}
-float PriorBoxParameter::aspect_ratio(int index) const {
- // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.aspect_ratio)
- return aspect_ratio_.Get(index);
-}
-void PriorBoxParameter::set_aspect_ratio(int index, float value) {
- aspect_ratio_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.aspect_ratio)
-}
-void PriorBoxParameter::add_aspect_ratio(float value) {
- aspect_ratio_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.PriorBoxParameter.aspect_ratio)
-}
-const ::google::protobuf::RepeatedField< float >&
-PriorBoxParameter::aspect_ratio() const {
- // @@protoc_insertion_point(field_list:caffe.PriorBoxParameter.aspect_ratio)
- return aspect_ratio_;
-}
-::google::protobuf::RepeatedField< float >*
-PriorBoxParameter::mutable_aspect_ratio() {
- // @@protoc_insertion_point(field_mutable_list:caffe.PriorBoxParameter.aspect_ratio)
- return &aspect_ratio_;
-}
-
-// optional bool flip = 4 [default = true];
-bool PriorBoxParameter::has_flip() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-void PriorBoxParameter::set_has_flip() {
- _has_bits_[0] |= 0x00000008u;
-}
-void PriorBoxParameter::clear_has_flip() {
- _has_bits_[0] &= ~0x00000008u;
-}
-void PriorBoxParameter::clear_flip() {
- flip_ = true;
- clear_has_flip();
-}
-bool PriorBoxParameter::flip() const {
- // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.flip)
- return flip_;
-}
-void PriorBoxParameter::set_flip(bool value) {
- set_has_flip();
- flip_ = value;
- // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.flip)
-}
-
-// optional bool clip = 5 [default = true];
-bool PriorBoxParameter::has_clip() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-void PriorBoxParameter::set_has_clip() {
- _has_bits_[0] |= 0x00000010u;
-}
-void PriorBoxParameter::clear_has_clip() {
- _has_bits_[0] &= ~0x00000010u;
-}
-void PriorBoxParameter::clear_clip() {
- clip_ = true;
- clear_has_clip();
-}
-bool PriorBoxParameter::clip() const {
- // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.clip)
- return clip_;
-}
-void PriorBoxParameter::set_clip(bool value) {
- set_has_clip();
- clip_ = value;
- // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.clip)
-}
-
-// repeated float variance = 6;
-int PriorBoxParameter::variance_size() const {
- return variance_.size();
-}
-void PriorBoxParameter::clear_variance() {
- variance_.Clear();
-}
-float PriorBoxParameter::variance(int index) const {
- // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.variance)
- return variance_.Get(index);
-}
-void PriorBoxParameter::set_variance(int index, float value) {
- variance_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.variance)
-}
-void PriorBoxParameter::add_variance(float value) {
- variance_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.PriorBoxParameter.variance)
-}
-const ::google::protobuf::RepeatedField< float >&
-PriorBoxParameter::variance() const {
- // @@protoc_insertion_point(field_list:caffe.PriorBoxParameter.variance)
- return variance_;
-}
-::google::protobuf::RepeatedField< float >*
-PriorBoxParameter::mutable_variance() {
- // @@protoc_insertion_point(field_mutable_list:caffe.PriorBoxParameter.variance)
- return &variance_;
-}
-
-inline const PriorBoxParameter* PriorBoxParameter::internal_default_instance() {
- return &PriorBoxParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int DetectionOutputParameter::kNumClassesFieldNumber;
-const int DetectionOutputParameter::kShareLocationFieldNumber;
-const int DetectionOutputParameter::kBackgroundLabelIdFieldNumber;
-const int DetectionOutputParameter::kCodeTypeFieldNumber;
-const int DetectionOutputParameter::kVarianceEncodedInTargetFieldNumber;
-const int DetectionOutputParameter::kKeepTopKFieldNumber;
-const int DetectionOutputParameter::kConfidenceThresholdFieldNumber;
-const int DetectionOutputParameter::kNmsThresholdFieldNumber;
-const int DetectionOutputParameter::kTopKFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-DetectionOutputParameter::DetectionOutputParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.DetectionOutputParameter)
-}
-
-void DetectionOutputParameter::InitAsDefaultInstance() {
-}
-
-DetectionOutputParameter::DetectionOutputParameter(const DetectionOutputParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.DetectionOutputParameter)
-}
-
-void DetectionOutputParameter::SharedCtor() {
- _cached_size_ = 0;
- ::memset(&num_classes_, 0, reinterpret_cast<char*>(&top_k_) -
- reinterpret_cast<char*>(&num_classes_) + sizeof(top_k_));
- share_location_ = true;
- code_type_ = 1;
- keep_top_k_ = -1;
- nms_threshold_ = 0.3f;
-}
-
-DetectionOutputParameter::~DetectionOutputParameter() {
- // @@protoc_insertion_point(destructor:caffe.DetectionOutputParameter)
- SharedDtor();
-}
-
-void DetectionOutputParameter::SharedDtor() {
-}
-
-void DetectionOutputParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* DetectionOutputParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return DetectionOutputParameter_descriptor_;
-}
-
-const DetectionOutputParameter& DetectionOutputParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<DetectionOutputParameter> DetectionOutputParameter_default_instance_;
-
-DetectionOutputParameter* DetectionOutputParameter::New(::google::protobuf::Arena* arena) const {
- DetectionOutputParameter* n = new DetectionOutputParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void DetectionOutputParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.DetectionOutputParameter)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(DetectionOutputParameter, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<DetectionOutputParameter*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- if (_has_bits_[0 / 32] & 255u) {
- ZR_(num_classes_, confidence_threshold_);
- share_location_ = true;
- code_type_ = 1;
- keep_top_k_ = -1;
- nms_threshold_ = 0.3f;
- }
- top_k_ = 0;
-
-#undef ZR_HELPER_
-#undef ZR_
-
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool DetectionOutputParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.DetectionOutputParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional uint32 num_classes = 1;
- case 1: {
- if (tag == 8) {
- set_has_num_classes();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &num_classes_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_share_location;
- break;
- }
-
- // optional bool share_location = 2 [default = true];
- case 2: {
- if (tag == 16) {
- parse_share_location:
- set_has_share_location();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &share_location_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(24)) goto parse_background_label_id;
- break;
- }
-
- // optional int32 background_label_id = 3 [default = 0];
- case 3: {
- if (tag == 24) {
- parse_background_label_id:
- set_has_background_label_id();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &background_label_id_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(48)) goto parse_code_type;
- break;
- }
-
- // optional .caffe.PriorBoxParameter.CodeType code_type = 6 [default = CORNER];
- case 6: {
- if (tag == 48) {
- parse_code_type:
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::PriorBoxParameter_CodeType_IsValid(value)) {
- set_code_type(static_cast< ::caffe::PriorBoxParameter_CodeType >(value));
- } else {
- mutable_unknown_fields()->AddVarint(6, value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(56)) goto parse_keep_top_k;
- break;
- }
-
- // optional int32 keep_top_k = 7 [default = -1];
- case 7: {
- if (tag == 56) {
- parse_keep_top_k:
- set_has_keep_top_k();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &keep_top_k_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(64)) goto parse_variance_encoded_in_target;
- break;
- }
-
- // optional bool variance_encoded_in_target = 8 [default = false];
- case 8: {
- if (tag == 64) {
- parse_variance_encoded_in_target:
- set_has_variance_encoded_in_target();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &variance_encoded_in_target_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(77)) goto parse_confidence_threshold;
- break;
- }
-
- // optional float confidence_threshold = 9;
- case 9: {
- if (tag == 77) {
- parse_confidence_threshold:
- set_has_confidence_threshold();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &confidence_threshold_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(85)) goto parse_nms_threshold;
- break;
- }
-
- // optional float nms_threshold = 10 [default = 0.3];
- case 10: {
- if (tag == 85) {
- parse_nms_threshold:
- set_has_nms_threshold();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &nms_threshold_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(88)) goto parse_top_k;
- break;
- }
-
- // optional int32 top_k = 11;
- case 11: {
- if (tag == 88) {
- parse_top_k:
- set_has_top_k();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &top_k_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.DetectionOutputParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.DetectionOutputParameter)
- return false;
-#undef DO_
-}
-
-void DetectionOutputParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.DetectionOutputParameter)
- // optional uint32 num_classes = 1;
- if (has_num_classes()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->num_classes(), output);
- }
-
- // optional bool share_location = 2 [default = true];
- if (has_share_location()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->share_location(), output);
- }
-
- // optional int32 background_label_id = 3 [default = 0];
- if (has_background_label_id()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->background_label_id(), output);
- }
-
- // optional .caffe.PriorBoxParameter.CodeType code_type = 6 [default = CORNER];
- if (has_code_type()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 6, this->code_type(), output);
- }
-
- // optional int32 keep_top_k = 7 [default = -1];
- if (has_keep_top_k()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(7, this->keep_top_k(), output);
- }
-
- // optional bool variance_encoded_in_target = 8 [default = false];
- if (has_variance_encoded_in_target()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(8, this->variance_encoded_in_target(), output);
- }
-
- // optional float confidence_threshold = 9;
- if (has_confidence_threshold()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(9, this->confidence_threshold(), output);
- }
-
- // optional float nms_threshold = 10 [default = 0.3];
- if (has_nms_threshold()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(10, this->nms_threshold(), output);
- }
-
- // optional int32 top_k = 11;
- if (has_top_k()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(11, this->top_k(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.DetectionOutputParameter)
-}
-
-::google::protobuf::uint8* DetectionOutputParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.DetectionOutputParameter)
- // optional uint32 num_classes = 1;
- if (has_num_classes()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->num_classes(), target);
- }
-
- // optional bool share_location = 2 [default = true];
- if (has_share_location()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->share_location(), target);
- }
-
- // optional int32 background_label_id = 3 [default = 0];
- if (has_background_label_id()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->background_label_id(), target);
- }
-
- // optional .caffe.PriorBoxParameter.CodeType code_type = 6 [default = CORNER];
- if (has_code_type()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 6, this->code_type(), target);
- }
-
- // optional int32 keep_top_k = 7 [default = -1];
- if (has_keep_top_k()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(7, this->keep_top_k(), target);
- }
-
- // optional bool variance_encoded_in_target = 8 [default = false];
- if (has_variance_encoded_in_target()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(8, this->variance_encoded_in_target(), target);
- }
-
- // optional float confidence_threshold = 9;
- if (has_confidence_threshold()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(9, this->confidence_threshold(), target);
- }
-
- // optional float nms_threshold = 10 [default = 0.3];
- if (has_nms_threshold()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(10, this->nms_threshold(), target);
- }
-
- // optional int32 top_k = 11;
- if (has_top_k()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(11, this->top_k(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.DetectionOutputParameter)
- return target;
-}
-
-size_t DetectionOutputParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.DetectionOutputParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 255u) {
- // optional uint32 num_classes = 1;
- if (has_num_classes()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->num_classes());
- }
-
- // optional bool share_location = 2 [default = true];
- if (has_share_location()) {
- total_size += 1 + 1;
- }
-
- // optional int32 background_label_id = 3 [default = 0];
- if (has_background_label_id()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->background_label_id());
- }
-
- // optional .caffe.PriorBoxParameter.CodeType code_type = 6 [default = CORNER];
- if (has_code_type()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->code_type());
- }
-
- // optional bool variance_encoded_in_target = 8 [default = false];
- if (has_variance_encoded_in_target()) {
- total_size += 1 + 1;
- }
-
- // optional int32 keep_top_k = 7 [default = -1];
- if (has_keep_top_k()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->keep_top_k());
- }
-
- // optional float confidence_threshold = 9;
- if (has_confidence_threshold()) {
- total_size += 1 + 4;
- }
-
- // optional float nms_threshold = 10 [default = 0.3];
- if (has_nms_threshold()) {
- total_size += 1 + 4;
- }
-
- }
- // optional int32 top_k = 11;
- if (has_top_k()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->top_k());
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void DetectionOutputParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.DetectionOutputParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const DetectionOutputParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const DetectionOutputParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.DetectionOutputParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.DetectionOutputParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void DetectionOutputParameter::MergeFrom(const DetectionOutputParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.DetectionOutputParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void DetectionOutputParameter::UnsafeMergeFrom(const DetectionOutputParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_num_classes()) {
- set_num_classes(from.num_classes());
- }
- if (from.has_share_location()) {
- set_share_location(from.share_location());
- }
- if (from.has_background_label_id()) {
- set_background_label_id(from.background_label_id());
- }
- if (from.has_code_type()) {
- set_code_type(from.code_type());
- }
- if (from.has_variance_encoded_in_target()) {
- set_variance_encoded_in_target(from.variance_encoded_in_target());
- }
- if (from.has_keep_top_k()) {
- set_keep_top_k(from.keep_top_k());
- }
- if (from.has_confidence_threshold()) {
- set_confidence_threshold(from.confidence_threshold());
- }
- if (from.has_nms_threshold()) {
- set_nms_threshold(from.nms_threshold());
- }
- }
- if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) {
- if (from.has_top_k()) {
- set_top_k(from.top_k());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void DetectionOutputParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.DetectionOutputParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void DetectionOutputParameter::CopyFrom(const DetectionOutputParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.DetectionOutputParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool DetectionOutputParameter::IsInitialized() const {
-
- return true;
-}
-
-void DetectionOutputParameter::Swap(DetectionOutputParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void DetectionOutputParameter::InternalSwap(DetectionOutputParameter* other) {
- std::swap(num_classes_, other->num_classes_);
- std::swap(share_location_, other->share_location_);
- std::swap(background_label_id_, other->background_label_id_);
- std::swap(code_type_, other->code_type_);
- std::swap(variance_encoded_in_target_, other->variance_encoded_in_target_);
- std::swap(keep_top_k_, other->keep_top_k_);
- std::swap(confidence_threshold_, other->confidence_threshold_);
- std::swap(nms_threshold_, other->nms_threshold_);
- std::swap(top_k_, other->top_k_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata DetectionOutputParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = DetectionOutputParameter_descriptor_;
- metadata.reflection = DetectionOutputParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// DetectionOutputParameter
-
-// optional uint32 num_classes = 1;
-bool DetectionOutputParameter::has_num_classes() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void DetectionOutputParameter::set_has_num_classes() {
- _has_bits_[0] |= 0x00000001u;
-}
-void DetectionOutputParameter::clear_has_num_classes() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void DetectionOutputParameter::clear_num_classes() {
- num_classes_ = 0u;
- clear_has_num_classes();
-}
-::google::protobuf::uint32 DetectionOutputParameter::num_classes() const {
- // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.num_classes)
- return num_classes_;
-}
-void DetectionOutputParameter::set_num_classes(::google::protobuf::uint32 value) {
- set_has_num_classes();
- num_classes_ = value;
- // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.num_classes)
-}
-
-// optional bool share_location = 2 [default = true];
-bool DetectionOutputParameter::has_share_location() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void DetectionOutputParameter::set_has_share_location() {
- _has_bits_[0] |= 0x00000002u;
-}
-void DetectionOutputParameter::clear_has_share_location() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void DetectionOutputParameter::clear_share_location() {
- share_location_ = true;
- clear_has_share_location();
-}
-bool DetectionOutputParameter::share_location() const {
- // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.share_location)
- return share_location_;
-}
-void DetectionOutputParameter::set_share_location(bool value) {
- set_has_share_location();
- share_location_ = value;
- // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.share_location)
-}
-
-// optional int32 background_label_id = 3 [default = 0];
-bool DetectionOutputParameter::has_background_label_id() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void DetectionOutputParameter::set_has_background_label_id() {
- _has_bits_[0] |= 0x00000004u;
-}
-void DetectionOutputParameter::clear_has_background_label_id() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void DetectionOutputParameter::clear_background_label_id() {
- background_label_id_ = 0;
- clear_has_background_label_id();
-}
-::google::protobuf::int32 DetectionOutputParameter::background_label_id() const {
- // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.background_label_id)
- return background_label_id_;
-}
-void DetectionOutputParameter::set_background_label_id(::google::protobuf::int32 value) {
- set_has_background_label_id();
- background_label_id_ = value;
- // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.background_label_id)
-}
-
-// optional .caffe.PriorBoxParameter.CodeType code_type = 6 [default = CORNER];
-bool DetectionOutputParameter::has_code_type() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-void DetectionOutputParameter::set_has_code_type() {
- _has_bits_[0] |= 0x00000008u;
-}
-void DetectionOutputParameter::clear_has_code_type() {
- _has_bits_[0] &= ~0x00000008u;
-}
-void DetectionOutputParameter::clear_code_type() {
- code_type_ = 1;
- clear_has_code_type();
-}
-::caffe::PriorBoxParameter_CodeType DetectionOutputParameter::code_type() const {
- // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.code_type)
- return static_cast< ::caffe::PriorBoxParameter_CodeType >(code_type_);
-}
-void DetectionOutputParameter::set_code_type(::caffe::PriorBoxParameter_CodeType value) {
- assert(::caffe::PriorBoxParameter_CodeType_IsValid(value));
- set_has_code_type();
- code_type_ = value;
- // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.code_type)
-}
-
-// optional bool variance_encoded_in_target = 8 [default = false];
-bool DetectionOutputParameter::has_variance_encoded_in_target() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-void DetectionOutputParameter::set_has_variance_encoded_in_target() {
- _has_bits_[0] |= 0x00000010u;
-}
-void DetectionOutputParameter::clear_has_variance_encoded_in_target() {
- _has_bits_[0] &= ~0x00000010u;
-}
-void DetectionOutputParameter::clear_variance_encoded_in_target() {
- variance_encoded_in_target_ = false;
- clear_has_variance_encoded_in_target();
-}
-bool DetectionOutputParameter::variance_encoded_in_target() const {
- // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.variance_encoded_in_target)
- return variance_encoded_in_target_;
-}
-void DetectionOutputParameter::set_variance_encoded_in_target(bool value) {
- set_has_variance_encoded_in_target();
- variance_encoded_in_target_ = value;
- // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.variance_encoded_in_target)
-}
-
-// optional int32 keep_top_k = 7 [default = -1];
-bool DetectionOutputParameter::has_keep_top_k() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-void DetectionOutputParameter::set_has_keep_top_k() {
- _has_bits_[0] |= 0x00000020u;
-}
-void DetectionOutputParameter::clear_has_keep_top_k() {
- _has_bits_[0] &= ~0x00000020u;
-}
-void DetectionOutputParameter::clear_keep_top_k() {
- keep_top_k_ = -1;
- clear_has_keep_top_k();
-}
-::google::protobuf::int32 DetectionOutputParameter::keep_top_k() const {
- // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.keep_top_k)
- return keep_top_k_;
-}
-void DetectionOutputParameter::set_keep_top_k(::google::protobuf::int32 value) {
- set_has_keep_top_k();
- keep_top_k_ = value;
- // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.keep_top_k)
-}
-
-// optional float confidence_threshold = 9;
-bool DetectionOutputParameter::has_confidence_threshold() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-void DetectionOutputParameter::set_has_confidence_threshold() {
- _has_bits_[0] |= 0x00000040u;
-}
-void DetectionOutputParameter::clear_has_confidence_threshold() {
- _has_bits_[0] &= ~0x00000040u;
-}
-void DetectionOutputParameter::clear_confidence_threshold() {
- confidence_threshold_ = 0;
- clear_has_confidence_threshold();
-}
-float DetectionOutputParameter::confidence_threshold() const {
- // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.confidence_threshold)
- return confidence_threshold_;
-}
-void DetectionOutputParameter::set_confidence_threshold(float value) {
- set_has_confidence_threshold();
- confidence_threshold_ = value;
- // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.confidence_threshold)
-}
-
-// optional float nms_threshold = 10 [default = 0.3];
-bool DetectionOutputParameter::has_nms_threshold() const {
- return (_has_bits_[0] & 0x00000080u) != 0;
-}
-void DetectionOutputParameter::set_has_nms_threshold() {
- _has_bits_[0] |= 0x00000080u;
-}
-void DetectionOutputParameter::clear_has_nms_threshold() {
- _has_bits_[0] &= ~0x00000080u;
-}
-void DetectionOutputParameter::clear_nms_threshold() {
- nms_threshold_ = 0.3f;
- clear_has_nms_threshold();
-}
-float DetectionOutputParameter::nms_threshold() const {
- // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.nms_threshold)
- return nms_threshold_;
-}
-void DetectionOutputParameter::set_nms_threshold(float value) {
- set_has_nms_threshold();
- nms_threshold_ = value;
- // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.nms_threshold)
-}
-
-// optional int32 top_k = 11;
-bool DetectionOutputParameter::has_top_k() const {
- return (_has_bits_[0] & 0x00000100u) != 0;
-}
-void DetectionOutputParameter::set_has_top_k() {
- _has_bits_[0] |= 0x00000100u;
-}
-void DetectionOutputParameter::clear_has_top_k() {
- _has_bits_[0] &= ~0x00000100u;
-}
-void DetectionOutputParameter::clear_top_k() {
- top_k_ = 0;
- clear_has_top_k();
-}
-::google::protobuf::int32 DetectionOutputParameter::top_k() const {
- // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.top_k)
- return top_k_;
-}
-void DetectionOutputParameter::set_top_k(::google::protobuf::int32 value) {
- set_has_top_k();
- top_k_ = value;
- // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.top_k)
-}
-
-inline const DetectionOutputParameter* DetectionOutputParameter::internal_default_instance() {
- return &DetectionOutputParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int Datum::kChannelsFieldNumber;
-const int Datum::kHeightFieldNumber;
-const int Datum::kWidthFieldNumber;
-const int Datum::kDataFieldNumber;
-const int Datum::kLabelFieldNumber;
-const int Datum::kFloatDataFieldNumber;
-const int Datum::kEncodedFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-Datum::Datum()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.Datum)
-}
-
-void Datum::InitAsDefaultInstance() {
-}
-
-Datum::Datum(const Datum& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.Datum)
-}
-
-void Datum::SharedCtor() {
- _cached_size_ = 0;
- data_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- ::memset(&channels_, 0, reinterpret_cast<char*>(&encoded_) -
- reinterpret_cast<char*>(&channels_) + sizeof(encoded_));
-}
-
-Datum::~Datum() {
- // @@protoc_insertion_point(destructor:caffe.Datum)
- SharedDtor();
-}
-
-void Datum::SharedDtor() {
- data_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-
-void Datum::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* Datum::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return Datum_descriptor_;
-}
-
-const Datum& Datum::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<Datum> Datum_default_instance_;
-
-Datum* Datum::New(::google::protobuf::Arena* arena) const {
- Datum* n = new Datum;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void Datum::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.Datum)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(Datum, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<Datum*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- if (_has_bits_[0 / 32] & 95u) {
- ZR_(channels_, encoded_);
- if (has_data()) {
- data_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- }
-
-#undef ZR_HELPER_
-#undef ZR_
-
- float_data_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool Datum::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.Datum)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional int32 channels = 1;
- case 1: {
- if (tag == 8) {
- set_has_channels();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &channels_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_height;
- break;
- }
-
- // optional int32 height = 2;
- case 2: {
- if (tag == 16) {
- parse_height:
- set_has_height();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &height_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(24)) goto parse_width;
- break;
- }
-
- // optional int32 width = 3;
- case 3: {
- if (tag == 24) {
- parse_width:
- set_has_width();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &width_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(34)) goto parse_data;
- break;
- }
-
- // optional bytes data = 4;
- case 4: {
- if (tag == 34) {
- parse_data:
- DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
- input, this->mutable_data()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(40)) goto parse_label;
- break;
- }
-
- // optional int32 label = 5;
- case 5: {
- if (tag == 40) {
- parse_label:
- set_has_label();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &label_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(53)) goto parse_float_data;
- break;
- }
-
- // repeated float float_data = 6;
- case 6: {
- if (tag == 53) {
- parse_float_data:
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- 1, 53, input, this->mutable_float_data())));
- } else if (tag == 50) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, this->mutable_float_data())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(53)) goto parse_float_data;
- if (input->ExpectTag(56)) goto parse_encoded;
- break;
- }
-
- // optional bool encoded = 7 [default = false];
- case 7: {
- if (tag == 56) {
- parse_encoded:
- set_has_encoded();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &encoded_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.Datum)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.Datum)
- return false;
-#undef DO_
-}
-
-void Datum::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.Datum)
- // optional int32 channels = 1;
- if (has_channels()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->channels(), output);
- }
-
- // optional int32 height = 2;
- if (has_height()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->height(), output);
- }
-
- // optional int32 width = 3;
- if (has_width()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->width(), output);
- }
-
- // optional bytes data = 4;
- if (has_data()) {
- ::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(
- 4, this->data(), output);
- }
-
- // optional int32 label = 5;
- if (has_label()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(5, this->label(), output);
- }
-
- // repeated float float_data = 6;
- for (int i = 0; i < this->float_data_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(
- 6, this->float_data(i), output);
- }
-
- // optional bool encoded = 7 [default = false];
- if (has_encoded()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(7, this->encoded(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.Datum)
-}
-
-::google::protobuf::uint8* Datum::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.Datum)
- // optional int32 channels = 1;
- if (has_channels()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->channels(), target);
- }
-
- // optional int32 height = 2;
- if (has_height()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->height(), target);
- }
-
- // optional int32 width = 3;
- if (has_width()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->width(), target);
- }
-
- // optional bytes data = 4;
- if (has_data()) {
- target =
- ::google::protobuf::internal::WireFormatLite::WriteBytesToArray(
- 4, this->data(), target);
- }
-
- // optional int32 label = 5;
- if (has_label()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(5, this->label(), target);
- }
-
- // repeated float float_data = 6;
- for (int i = 0; i < this->float_data_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteFloatToArray(6, this->float_data(i), target);
- }
-
- // optional bool encoded = 7 [default = false];
- if (has_encoded()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(7, this->encoded(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.Datum)
- return target;
-}
-
-size_t Datum::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.Datum)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 95u) {
- // optional int32 channels = 1;
- if (has_channels()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->channels());
- }
-
- // optional int32 height = 2;
- if (has_height()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->height());
- }
-
- // optional int32 width = 3;
- if (has_width()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->width());
- }
-
- // optional bytes data = 4;
- if (has_data()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::BytesSize(
- this->data());
- }
-
- // optional int32 label = 5;
- if (has_label()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->label());
- }
-
- // optional bool encoded = 7 [default = false];
- if (has_encoded()) {
- total_size += 1 + 1;
- }
-
- }
- // repeated float float_data = 6;
- {
- size_t data_size = 0;
- unsigned int count = this->float_data_size();
- data_size = 4UL * count;
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->float_data_size());
- total_size += data_size;
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void Datum::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.Datum)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const Datum* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const Datum>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.Datum)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.Datum)
- UnsafeMergeFrom(*source);
- }
-}
-
-void Datum::MergeFrom(const Datum& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.Datum)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void Datum::UnsafeMergeFrom(const Datum& from) {
- GOOGLE_DCHECK(&from != this);
- float_data_.UnsafeMergeFrom(from.float_data_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_channels()) {
- set_channels(from.channels());
- }
- if (from.has_height()) {
- set_height(from.height());
- }
- if (from.has_width()) {
- set_width(from.width());
- }
- if (from.has_data()) {
- set_has_data();
- data_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.data_);
- }
- if (from.has_label()) {
- set_label(from.label());
- }
- if (from.has_encoded()) {
- set_encoded(from.encoded());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void Datum::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.Datum)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void Datum::CopyFrom(const Datum& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.Datum)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool Datum::IsInitialized() const {
-
- return true;
-}
-
-void Datum::Swap(Datum* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void Datum::InternalSwap(Datum* other) {
- std::swap(channels_, other->channels_);
- std::swap(height_, other->height_);
- std::swap(width_, other->width_);
- data_.Swap(&other->data_);
- std::swap(label_, other->label_);
- float_data_.UnsafeArenaSwap(&other->float_data_);
- std::swap(encoded_, other->encoded_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata Datum::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = Datum_descriptor_;
- metadata.reflection = Datum_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// Datum
-
-// optional int32 channels = 1;
-bool Datum::has_channels() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void Datum::set_has_channels() {
- _has_bits_[0] |= 0x00000001u;
-}
-void Datum::clear_has_channels() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void Datum::clear_channels() {
- channels_ = 0;
- clear_has_channels();
-}
-::google::protobuf::int32 Datum::channels() const {
- // @@protoc_insertion_point(field_get:caffe.Datum.channels)
- return channels_;
-}
-void Datum::set_channels(::google::protobuf::int32 value) {
- set_has_channels();
- channels_ = value;
- // @@protoc_insertion_point(field_set:caffe.Datum.channels)
-}
-
-// optional int32 height = 2;
-bool Datum::has_height() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void Datum::set_has_height() {
- _has_bits_[0] |= 0x00000002u;
-}
-void Datum::clear_has_height() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void Datum::clear_height() {
- height_ = 0;
- clear_has_height();
-}
-::google::protobuf::int32 Datum::height() const {
- // @@protoc_insertion_point(field_get:caffe.Datum.height)
- return height_;
-}
-void Datum::set_height(::google::protobuf::int32 value) {
- set_has_height();
- height_ = value;
- // @@protoc_insertion_point(field_set:caffe.Datum.height)
-}
-
-// optional int32 width = 3;
-bool Datum::has_width() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void Datum::set_has_width() {
- _has_bits_[0] |= 0x00000004u;
-}
-void Datum::clear_has_width() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void Datum::clear_width() {
- width_ = 0;
- clear_has_width();
-}
-::google::protobuf::int32 Datum::width() const {
- // @@protoc_insertion_point(field_get:caffe.Datum.width)
- return width_;
-}
-void Datum::set_width(::google::protobuf::int32 value) {
- set_has_width();
- width_ = value;
- // @@protoc_insertion_point(field_set:caffe.Datum.width)
-}
-
-// optional bytes data = 4;
-bool Datum::has_data() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-void Datum::set_has_data() {
- _has_bits_[0] |= 0x00000008u;
-}
-void Datum::clear_has_data() {
- _has_bits_[0] &= ~0x00000008u;
-}
-void Datum::clear_data() {
- data_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_data();
-}
-const ::std::string& Datum::data() const {
- // @@protoc_insertion_point(field_get:caffe.Datum.data)
- return data_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void Datum::set_data(const ::std::string& value) {
- set_has_data();
- data_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.Datum.data)
-}
-void Datum::set_data(const char* value) {
- set_has_data();
- data_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.Datum.data)
-}
-void Datum::set_data(const void* value, size_t size) {
- set_has_data();
- data_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.Datum.data)
-}
-::std::string* Datum::mutable_data() {
- set_has_data();
- // @@protoc_insertion_point(field_mutable:caffe.Datum.data)
- return data_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* Datum::release_data() {
- // @@protoc_insertion_point(field_release:caffe.Datum.data)
- clear_has_data();
- return data_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void Datum::set_allocated_data(::std::string* data) {
- if (data != NULL) {
- set_has_data();
- } else {
- clear_has_data();
- }
- data_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), data);
- // @@protoc_insertion_point(field_set_allocated:caffe.Datum.data)
-}
-
-// optional int32 label = 5;
-bool Datum::has_label() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-void Datum::set_has_label() {
- _has_bits_[0] |= 0x00000010u;
-}
-void Datum::clear_has_label() {
- _has_bits_[0] &= ~0x00000010u;
-}
-void Datum::clear_label() {
- label_ = 0;
- clear_has_label();
-}
-::google::protobuf::int32 Datum::label() const {
- // @@protoc_insertion_point(field_get:caffe.Datum.label)
- return label_;
-}
-void Datum::set_label(::google::protobuf::int32 value) {
- set_has_label();
- label_ = value;
- // @@protoc_insertion_point(field_set:caffe.Datum.label)
-}
-
-// repeated float float_data = 6;
-int Datum::float_data_size() const {
- return float_data_.size();
-}
-void Datum::clear_float_data() {
- float_data_.Clear();
-}
-float Datum::float_data(int index) const {
- // @@protoc_insertion_point(field_get:caffe.Datum.float_data)
- return float_data_.Get(index);
-}
-void Datum::set_float_data(int index, float value) {
- float_data_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.Datum.float_data)
-}
-void Datum::add_float_data(float value) {
- float_data_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.Datum.float_data)
-}
-const ::google::protobuf::RepeatedField< float >&
-Datum::float_data() const {
- // @@protoc_insertion_point(field_list:caffe.Datum.float_data)
- return float_data_;
-}
-::google::protobuf::RepeatedField< float >*
-Datum::mutable_float_data() {
- // @@protoc_insertion_point(field_mutable_list:caffe.Datum.float_data)
- return &float_data_;
-}
-
-// optional bool encoded = 7 [default = false];
-bool Datum::has_encoded() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-void Datum::set_has_encoded() {
- _has_bits_[0] |= 0x00000040u;
-}
-void Datum::clear_has_encoded() {
- _has_bits_[0] &= ~0x00000040u;
-}
-void Datum::clear_encoded() {
- encoded_ = false;
- clear_has_encoded();
-}
-bool Datum::encoded() const {
- // @@protoc_insertion_point(field_get:caffe.Datum.encoded)
- return encoded_;
-}
-void Datum::set_encoded(bool value) {
- set_has_encoded();
- encoded_ = value;
- // @@protoc_insertion_point(field_set:caffe.Datum.encoded)
-}
-
-inline const Datum* Datum::internal_default_instance() {
- return &Datum_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-const ::google::protobuf::EnumDescriptor* FillerParameter_VarianceNorm_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return FillerParameter_VarianceNorm_descriptor_;
-}
-bool FillerParameter_VarianceNorm_IsValid(int value) {
- switch (value) {
- case 0:
- case 1:
- case 2:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const FillerParameter_VarianceNorm FillerParameter::FAN_IN;
-const FillerParameter_VarianceNorm FillerParameter::FAN_OUT;
-const FillerParameter_VarianceNorm FillerParameter::AVERAGE;
-const FillerParameter_VarianceNorm FillerParameter::VarianceNorm_MIN;
-const FillerParameter_VarianceNorm FillerParameter::VarianceNorm_MAX;
-const int FillerParameter::VarianceNorm_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-::std::string* FillerParameter::_default_type_ = NULL;
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int FillerParameter::kTypeFieldNumber;
-const int FillerParameter::kValueFieldNumber;
-const int FillerParameter::kMinFieldNumber;
-const int FillerParameter::kMaxFieldNumber;
-const int FillerParameter::kMeanFieldNumber;
-const int FillerParameter::kStdFieldNumber;
-const int FillerParameter::kSparseFieldNumber;
-const int FillerParameter::kVarianceNormFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-FillerParameter::FillerParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.FillerParameter)
-}
-
-void FillerParameter::InitAsDefaultInstance() {
-}
-
-FillerParameter::FillerParameter(const FillerParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.FillerParameter)
-}
-
-void FillerParameter::SharedCtor() {
- _cached_size_ = 0;
- type_.UnsafeSetDefault(_default_type_);
- ::memset(&value_, 0, reinterpret_cast<char*>(&variance_norm_) -
- reinterpret_cast<char*>(&value_) + sizeof(variance_norm_));
- sparse_ = -1;
- max_ = 1;
- std_ = 1;
-}
-
-FillerParameter::~FillerParameter() {
- // @@protoc_insertion_point(destructor:caffe.FillerParameter)
- SharedDtor();
-}
-
-void FillerParameter::SharedDtor() {
- type_.DestroyNoArena(_default_type_);
-}
-
-void FillerParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* FillerParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return FillerParameter_descriptor_;
-}
-
-const FillerParameter& FillerParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<FillerParameter> FillerParameter_default_instance_;
-
-FillerParameter* FillerParameter::New(::google::protobuf::Arena* arena) const {
- FillerParameter* n = new FillerParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void FillerParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.FillerParameter)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(FillerParameter, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<FillerParameter*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- if (_has_bits_[0 / 32] & 255u) {
- ZR_(value_, variance_norm_);
- if (has_type()) {
- type_.ClearToDefaultNoArena(_default_type_);
- }
- max_ = 1;
- std_ = 1;
- sparse_ = -1;
- }
-
-#undef ZR_HELPER_
-#undef ZR_
-
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool FillerParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.FillerParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional string type = 1 [default = "constant"];
- case 1: {
- if (tag == 10) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_type()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->type().data(), this->type().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.FillerParameter.type");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(21)) goto parse_value;
- break;
- }
-
- // optional float value = 2 [default = 0];
- case 2: {
- if (tag == 21) {
- parse_value:
- set_has_value();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &value_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(29)) goto parse_min;
- break;
- }
-
- // optional float min = 3 [default = 0];
- case 3: {
- if (tag == 29) {
- parse_min:
- set_has_min();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &min_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(37)) goto parse_max;
- break;
- }
-
- // optional float max = 4 [default = 1];
- case 4: {
- if (tag == 37) {
- parse_max:
- set_has_max();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &max_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(45)) goto parse_mean;
- break;
- }
-
- // optional float mean = 5 [default = 0];
- case 5: {
- if (tag == 45) {
- parse_mean:
- set_has_mean();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &mean_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(53)) goto parse_std;
- break;
- }
-
- // optional float std = 6 [default = 1];
- case 6: {
- if (tag == 53) {
- parse_std:
- set_has_std();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &std_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(56)) goto parse_sparse;
- break;
- }
-
- // optional int32 sparse = 7 [default = -1];
- case 7: {
- if (tag == 56) {
- parse_sparse:
- set_has_sparse();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &sparse_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(64)) goto parse_variance_norm;
- break;
- }
-
- // optional .caffe.FillerParameter.VarianceNorm variance_norm = 8 [default = FAN_IN];
- case 8: {
- if (tag == 64) {
- parse_variance_norm:
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::FillerParameter_VarianceNorm_IsValid(value)) {
- set_variance_norm(static_cast< ::caffe::FillerParameter_VarianceNorm >(value));
- } else {
- mutable_unknown_fields()->AddVarint(8, value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.FillerParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.FillerParameter)
- return false;
-#undef DO_
-}
-
-void FillerParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.FillerParameter)
- // optional string type = 1 [default = "constant"];
- if (has_type()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->type().data(), this->type().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.FillerParameter.type");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 1, this->type(), output);
- }
-
- // optional float value = 2 [default = 0];
- if (has_value()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->value(), output);
- }
-
- // optional float min = 3 [default = 0];
- if (has_min()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->min(), output);
- }
-
- // optional float max = 4 [default = 1];
- if (has_max()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(4, this->max(), output);
- }
-
- // optional float mean = 5 [default = 0];
- if (has_mean()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(5, this->mean(), output);
- }
-
- // optional float std = 6 [default = 1];
- if (has_std()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(6, this->std(), output);
- }
-
- // optional int32 sparse = 7 [default = -1];
- if (has_sparse()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(7, this->sparse(), output);
- }
-
- // optional .caffe.FillerParameter.VarianceNorm variance_norm = 8 [default = FAN_IN];
- if (has_variance_norm()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 8, this->variance_norm(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.FillerParameter)
-}
-
-::google::protobuf::uint8* FillerParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.FillerParameter)
- // optional string type = 1 [default = "constant"];
- if (has_type()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->type().data(), this->type().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.FillerParameter.type");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 1, this->type(), target);
- }
-
- // optional float value = 2 [default = 0];
- if (has_value()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->value(), target);
- }
-
- // optional float min = 3 [default = 0];
- if (has_min()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->min(), target);
- }
-
- // optional float max = 4 [default = 1];
- if (has_max()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(4, this->max(), target);
- }
-
- // optional float mean = 5 [default = 0];
- if (has_mean()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(5, this->mean(), target);
- }
-
- // optional float std = 6 [default = 1];
- if (has_std()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(6, this->std(), target);
- }
-
- // optional int32 sparse = 7 [default = -1];
- if (has_sparse()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(7, this->sparse(), target);
- }
-
- // optional .caffe.FillerParameter.VarianceNorm variance_norm = 8 [default = FAN_IN];
- if (has_variance_norm()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 8, this->variance_norm(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.FillerParameter)
- return target;
-}
-
-size_t FillerParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.FillerParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 255u) {
- // optional string type = 1 [default = "constant"];
- if (has_type()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->type());
- }
-
- // optional float value = 2 [default = 0];
- if (has_value()) {
- total_size += 1 + 4;
- }
-
- // optional float min = 3 [default = 0];
- if (has_min()) {
- total_size += 1 + 4;
- }
-
- // optional float max = 4 [default = 1];
- if (has_max()) {
- total_size += 1 + 4;
- }
-
- // optional float mean = 5 [default = 0];
- if (has_mean()) {
- total_size += 1 + 4;
- }
-
- // optional float std = 6 [default = 1];
- if (has_std()) {
- total_size += 1 + 4;
- }
-
- // optional int32 sparse = 7 [default = -1];
- if (has_sparse()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->sparse());
- }
-
- // optional .caffe.FillerParameter.VarianceNorm variance_norm = 8 [default = FAN_IN];
- if (has_variance_norm()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->variance_norm());
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void FillerParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.FillerParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const FillerParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const FillerParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.FillerParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.FillerParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void FillerParameter::MergeFrom(const FillerParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.FillerParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void FillerParameter::UnsafeMergeFrom(const FillerParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_type()) {
- set_has_type();
- type_.AssignWithDefault(_default_type_, from.type_);
- }
- if (from.has_value()) {
- set_value(from.value());
- }
- if (from.has_min()) {
- set_min(from.min());
- }
- if (from.has_max()) {
- set_max(from.max());
- }
- if (from.has_mean()) {
- set_mean(from.mean());
- }
- if (from.has_std()) {
- set_std(from.std());
- }
- if (from.has_sparse()) {
- set_sparse(from.sparse());
- }
- if (from.has_variance_norm()) {
- set_variance_norm(from.variance_norm());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void FillerParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.FillerParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void FillerParameter::CopyFrom(const FillerParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.FillerParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool FillerParameter::IsInitialized() const {
-
- return true;
-}
-
-void FillerParameter::Swap(FillerParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void FillerParameter::InternalSwap(FillerParameter* other) {
- type_.Swap(&other->type_);
- std::swap(value_, other->value_);
- std::swap(min_, other->min_);
- std::swap(max_, other->max_);
- std::swap(mean_, other->mean_);
- std::swap(std_, other->std_);
- std::swap(sparse_, other->sparse_);
- std::swap(variance_norm_, other->variance_norm_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata FillerParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = FillerParameter_descriptor_;
- metadata.reflection = FillerParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// FillerParameter
-
-// optional string type = 1 [default = "constant"];
-bool FillerParameter::has_type() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void FillerParameter::set_has_type() {
- _has_bits_[0] |= 0x00000001u;
-}
-void FillerParameter::clear_has_type() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void FillerParameter::clear_type() {
- type_.ClearToDefaultNoArena(_default_type_);
- clear_has_type();
-}
-const ::std::string& FillerParameter::type() const {
- // @@protoc_insertion_point(field_get:caffe.FillerParameter.type)
- return type_.GetNoArena(_default_type_);
-}
-void FillerParameter::set_type(const ::std::string& value) {
- set_has_type();
- type_.SetNoArena(_default_type_, value);
- // @@protoc_insertion_point(field_set:caffe.FillerParameter.type)
-}
-void FillerParameter::set_type(const char* value) {
- set_has_type();
- type_.SetNoArena(_default_type_, ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.FillerParameter.type)
-}
-void FillerParameter::set_type(const char* value, size_t size) {
- set_has_type();
- type_.SetNoArena(_default_type_,
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.FillerParameter.type)
-}
-::std::string* FillerParameter::mutable_type() {
- set_has_type();
- // @@protoc_insertion_point(field_mutable:caffe.FillerParameter.type)
- return type_.MutableNoArena(_default_type_);
-}
-::std::string* FillerParameter::release_type() {
- // @@protoc_insertion_point(field_release:caffe.FillerParameter.type)
- clear_has_type();
- return type_.ReleaseNoArena(_default_type_);
-}
-void FillerParameter::set_allocated_type(::std::string* type) {
- if (type != NULL) {
- set_has_type();
- } else {
- clear_has_type();
- }
- type_.SetAllocatedNoArena(_default_type_, type);
- // @@protoc_insertion_point(field_set_allocated:caffe.FillerParameter.type)
-}
-
-// optional float value = 2 [default = 0];
-bool FillerParameter::has_value() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void FillerParameter::set_has_value() {
- _has_bits_[0] |= 0x00000002u;
-}
-void FillerParameter::clear_has_value() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void FillerParameter::clear_value() {
- value_ = 0;
- clear_has_value();
-}
-float FillerParameter::value() const {
- // @@protoc_insertion_point(field_get:caffe.FillerParameter.value)
- return value_;
-}
-void FillerParameter::set_value(float value) {
- set_has_value();
- value_ = value;
- // @@protoc_insertion_point(field_set:caffe.FillerParameter.value)
-}
-
-// optional float min = 3 [default = 0];
-bool FillerParameter::has_min() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void FillerParameter::set_has_min() {
- _has_bits_[0] |= 0x00000004u;
-}
-void FillerParameter::clear_has_min() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void FillerParameter::clear_min() {
- min_ = 0;
- clear_has_min();
-}
-float FillerParameter::min() const {
- // @@protoc_insertion_point(field_get:caffe.FillerParameter.min)
- return min_;
-}
-void FillerParameter::set_min(float value) {
- set_has_min();
- min_ = value;
- // @@protoc_insertion_point(field_set:caffe.FillerParameter.min)
-}
-
-// optional float max = 4 [default = 1];
-bool FillerParameter::has_max() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-void FillerParameter::set_has_max() {
- _has_bits_[0] |= 0x00000008u;
-}
-void FillerParameter::clear_has_max() {
- _has_bits_[0] &= ~0x00000008u;
-}
-void FillerParameter::clear_max() {
- max_ = 1;
- clear_has_max();
-}
-float FillerParameter::max() const {
- // @@protoc_insertion_point(field_get:caffe.FillerParameter.max)
- return max_;
-}
-void FillerParameter::set_max(float value) {
- set_has_max();
- max_ = value;
- // @@protoc_insertion_point(field_set:caffe.FillerParameter.max)
-}
-
-// optional float mean = 5 [default = 0];
-bool FillerParameter::has_mean() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-void FillerParameter::set_has_mean() {
- _has_bits_[0] |= 0x00000010u;
-}
-void FillerParameter::clear_has_mean() {
- _has_bits_[0] &= ~0x00000010u;
-}
-void FillerParameter::clear_mean() {
- mean_ = 0;
- clear_has_mean();
-}
-float FillerParameter::mean() const {
- // @@protoc_insertion_point(field_get:caffe.FillerParameter.mean)
- return mean_;
-}
-void FillerParameter::set_mean(float value) {
- set_has_mean();
- mean_ = value;
- // @@protoc_insertion_point(field_set:caffe.FillerParameter.mean)
-}
-
-// optional float std = 6 [default = 1];
-bool FillerParameter::has_std() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-void FillerParameter::set_has_std() {
- _has_bits_[0] |= 0x00000020u;
-}
-void FillerParameter::clear_has_std() {
- _has_bits_[0] &= ~0x00000020u;
-}
-void FillerParameter::clear_std() {
- std_ = 1;
- clear_has_std();
-}
-float FillerParameter::std() const {
- // @@protoc_insertion_point(field_get:caffe.FillerParameter.std)
- return std_;
-}
-void FillerParameter::set_std(float value) {
- set_has_std();
- std_ = value;
- // @@protoc_insertion_point(field_set:caffe.FillerParameter.std)
-}
-
-// optional int32 sparse = 7 [default = -1];
-bool FillerParameter::has_sparse() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-void FillerParameter::set_has_sparse() {
- _has_bits_[0] |= 0x00000040u;
-}
-void FillerParameter::clear_has_sparse() {
- _has_bits_[0] &= ~0x00000040u;
-}
-void FillerParameter::clear_sparse() {
- sparse_ = -1;
- clear_has_sparse();
-}
-::google::protobuf::int32 FillerParameter::sparse() const {
- // @@protoc_insertion_point(field_get:caffe.FillerParameter.sparse)
- return sparse_;
-}
-void FillerParameter::set_sparse(::google::protobuf::int32 value) {
- set_has_sparse();
- sparse_ = value;
- // @@protoc_insertion_point(field_set:caffe.FillerParameter.sparse)
-}
-
-// optional .caffe.FillerParameter.VarianceNorm variance_norm = 8 [default = FAN_IN];
-bool FillerParameter::has_variance_norm() const {
- return (_has_bits_[0] & 0x00000080u) != 0;
-}
-void FillerParameter::set_has_variance_norm() {
- _has_bits_[0] |= 0x00000080u;
-}
-void FillerParameter::clear_has_variance_norm() {
- _has_bits_[0] &= ~0x00000080u;
-}
-void FillerParameter::clear_variance_norm() {
- variance_norm_ = 0;
- clear_has_variance_norm();
-}
-::caffe::FillerParameter_VarianceNorm FillerParameter::variance_norm() const {
- // @@protoc_insertion_point(field_get:caffe.FillerParameter.variance_norm)
- return static_cast< ::caffe::FillerParameter_VarianceNorm >(variance_norm_);
-}
-void FillerParameter::set_variance_norm(::caffe::FillerParameter_VarianceNorm value) {
- assert(::caffe::FillerParameter_VarianceNorm_IsValid(value));
- set_has_variance_norm();
- variance_norm_ = value;
- // @@protoc_insertion_point(field_set:caffe.FillerParameter.variance_norm)
-}
-
-inline const FillerParameter* FillerParameter::internal_default_instance() {
- return &FillerParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int NetParameter::kNameFieldNumber;
-const int NetParameter::kInputFieldNumber;
-const int NetParameter::kInputShapeFieldNumber;
-const int NetParameter::kInputDimFieldNumber;
-const int NetParameter::kForceBackwardFieldNumber;
-const int NetParameter::kStateFieldNumber;
-const int NetParameter::kDebugInfoFieldNumber;
-const int NetParameter::kLayerFieldNumber;
-const int NetParameter::kLayersFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-NetParameter::NetParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.NetParameter)
-}
-
-void NetParameter::InitAsDefaultInstance() {
- state_ = const_cast< ::caffe::NetState*>(
- ::caffe::NetState::internal_default_instance());
-}
-
-NetParameter::NetParameter(const NetParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.NetParameter)
-}
-
-void NetParameter::SharedCtor() {
- _cached_size_ = 0;
- name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- state_ = NULL;
- ::memset(&force_backward_, 0, reinterpret_cast<char*>(&debug_info_) -
- reinterpret_cast<char*>(&force_backward_) + sizeof(debug_info_));
-}
-
-NetParameter::~NetParameter() {
- // @@protoc_insertion_point(destructor:caffe.NetParameter)
- SharedDtor();
-}
-
-void NetParameter::SharedDtor() {
- name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- if (this != &NetParameter_default_instance_.get()) {
- delete state_;
- }
-}
-
-void NetParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* NetParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return NetParameter_descriptor_;
-}
-
-const NetParameter& NetParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<NetParameter> NetParameter_default_instance_;
-
-NetParameter* NetParameter::New(::google::protobuf::Arena* arena) const {
- NetParameter* n = new NetParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void NetParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.NetParameter)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(NetParameter, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<NetParameter*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- if (_has_bits_[0 / 32] & 113u) {
- ZR_(force_backward_, debug_info_);
- if (has_name()) {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- if (has_state()) {
- if (state_ != NULL) state_->::caffe::NetState::Clear();
- }
- }
-
-#undef ZR_HELPER_
-#undef ZR_
-
- input_.Clear();
- input_shape_.Clear();
- input_dim_.Clear();
- layer_.Clear();
- layers_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool NetParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.NetParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional string name = 1;
- case 1: {
- if (tag == 10) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_name()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->name().data(), this->name().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.NetParameter.name");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(18)) goto parse_layers;
- break;
- }
-
- // repeated .caffe.V1LayerParameter layers = 2;
- case 2: {
- if (tag == 18) {
- parse_layers:
- DO_(input->IncrementRecursionDepth());
- parse_loop_layers:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
- input, add_layers()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(18)) goto parse_loop_layers;
- input->UnsafeDecrementRecursionDepth();
- if (input->ExpectTag(26)) goto parse_input;
- break;
- }
-
- // repeated string input = 3;
- case 3: {
- if (tag == 26) {
- parse_input:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->add_input()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->input(this->input_size() - 1).data(),
- this->input(this->input_size() - 1).length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.NetParameter.input");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(26)) goto parse_input;
- if (input->ExpectTag(32)) goto parse_input_dim;
- break;
- }
-
- // repeated int32 input_dim = 4;
- case 4: {
- if (tag == 32) {
- parse_input_dim:
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- 1, 32, input, this->mutable_input_dim())));
- } else if (tag == 34) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, this->mutable_input_dim())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(32)) goto parse_input_dim;
- if (input->ExpectTag(40)) goto parse_force_backward;
- break;
- }
-
- // optional bool force_backward = 5 [default = false];
- case 5: {
- if (tag == 40) {
- parse_force_backward:
- set_has_force_backward();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &force_backward_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(50)) goto parse_state;
- break;
- }
-
- // optional .caffe.NetState state = 6;
- case 6: {
- if (tag == 50) {
- parse_state:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_state()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(56)) goto parse_debug_info;
- break;
- }
-
- // optional bool debug_info = 7 [default = false];
- case 7: {
- if (tag == 56) {
- parse_debug_info:
- set_has_debug_info();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &debug_info_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(66)) goto parse_input_shape;
- break;
- }
-
- // repeated .caffe.BlobShape input_shape = 8;
- case 8: {
- if (tag == 66) {
- parse_input_shape:
- DO_(input->IncrementRecursionDepth());
- parse_loop_input_shape:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
- input, add_input_shape()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(66)) goto parse_loop_input_shape;
- if (input->ExpectTag(802)) goto parse_loop_layer;
- input->UnsafeDecrementRecursionDepth();
- break;
- }
-
- // repeated .caffe.LayerParameter layer = 100;
- case 100: {
- if (tag == 802) {
- DO_(input->IncrementRecursionDepth());
- parse_loop_layer:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
- input, add_layer()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(802)) goto parse_loop_layer;
- input->UnsafeDecrementRecursionDepth();
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.NetParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.NetParameter)
- return false;
-#undef DO_
-}
-
-void NetParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.NetParameter)
- // optional string name = 1;
- if (has_name()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->name().data(), this->name().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.NetParameter.name");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 1, this->name(), output);
- }
-
- // repeated .caffe.V1LayerParameter layers = 2;
- for (unsigned int i = 0, n = this->layers_size(); i < n; i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 2, this->layers(i), output);
- }
-
- // repeated string input = 3;
- for (int i = 0; i < this->input_size(); i++) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->input(i).data(), this->input(i).length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.NetParameter.input");
- ::google::protobuf::internal::WireFormatLite::WriteString(
- 3, this->input(i), output);
- }
-
- // repeated int32 input_dim = 4;
- for (int i = 0; i < this->input_dim_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(
- 4, this->input_dim(i), output);
- }
-
- // optional bool force_backward = 5 [default = false];
- if (has_force_backward()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(5, this->force_backward(), output);
- }
-
- // optional .caffe.NetState state = 6;
- if (has_state()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 6, *this->state_, output);
- }
-
- // optional bool debug_info = 7 [default = false];
- if (has_debug_info()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(7, this->debug_info(), output);
- }
-
- // repeated .caffe.BlobShape input_shape = 8;
- for (unsigned int i = 0, n = this->input_shape_size(); i < n; i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 8, this->input_shape(i), output);
- }
-
- // repeated .caffe.LayerParameter layer = 100;
- for (unsigned int i = 0, n = this->layer_size(); i < n; i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 100, this->layer(i), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.NetParameter)
-}
-
-::google::protobuf::uint8* NetParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.NetParameter)
- // optional string name = 1;
- if (has_name()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->name().data(), this->name().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.NetParameter.name");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 1, this->name(), target);
- }
-
- // repeated .caffe.V1LayerParameter layers = 2;
- for (unsigned int i = 0, n = this->layers_size(); i < n; i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 2, this->layers(i), false, target);
- }
-
- // repeated string input = 3;
- for (int i = 0; i < this->input_size(); i++) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->input(i).data(), this->input(i).length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.NetParameter.input");
- target = ::google::protobuf::internal::WireFormatLite::
- WriteStringToArray(3, this->input(i), target);
- }
-
- // repeated int32 input_dim = 4;
- for (int i = 0; i < this->input_dim_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteInt32ToArray(4, this->input_dim(i), target);
- }
-
- // optional bool force_backward = 5 [default = false];
- if (has_force_backward()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(5, this->force_backward(), target);
- }
-
- // optional .caffe.NetState state = 6;
- if (has_state()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 6, *this->state_, false, target);
- }
-
- // optional bool debug_info = 7 [default = false];
- if (has_debug_info()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(7, this->debug_info(), target);
- }
-
- // repeated .caffe.BlobShape input_shape = 8;
- for (unsigned int i = 0, n = this->input_shape_size(); i < n; i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 8, this->input_shape(i), false, target);
- }
-
- // repeated .caffe.LayerParameter layer = 100;
- for (unsigned int i = 0, n = this->layer_size(); i < n; i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 100, this->layer(i), false, target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.NetParameter)
- return target;
-}
-
-size_t NetParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.NetParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 113u) {
- // optional string name = 1;
- if (has_name()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->name());
- }
-
- // optional bool force_backward = 5 [default = false];
- if (has_force_backward()) {
- total_size += 1 + 1;
- }
-
- // optional .caffe.NetState state = 6;
- if (has_state()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->state_);
- }
-
- // optional bool debug_info = 7 [default = false];
- if (has_debug_info()) {
- total_size += 1 + 1;
- }
-
- }
- // repeated string input = 3;
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->input_size());
- for (int i = 0; i < this->input_size(); i++) {
- total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
- this->input(i));
- }
-
- // repeated .caffe.BlobShape input_shape = 8;
- {
- unsigned int count = this->input_shape_size();
- total_size += 1UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->input_shape(i));
- }
- }
-
- // repeated int32 input_dim = 4;
- {
- size_t data_size = 0;
- unsigned int count = this->input_dim_size();
- for (unsigned int i = 0; i < count; i++) {
- data_size += ::google::protobuf::internal::WireFormatLite::
- Int32Size(this->input_dim(i));
- }
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->input_dim_size());
- total_size += data_size;
- }
-
- // repeated .caffe.LayerParameter layer = 100;
- {
- unsigned int count = this->layer_size();
- total_size += 2UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->layer(i));
- }
- }
-
- // repeated .caffe.V1LayerParameter layers = 2;
- {
- unsigned int count = this->layers_size();
- total_size += 1UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->layers(i));
- }
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void NetParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.NetParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const NetParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const NetParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.NetParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.NetParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void NetParameter::MergeFrom(const NetParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.NetParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void NetParameter::UnsafeMergeFrom(const NetParameter& from) {
- GOOGLE_DCHECK(&from != this);
- input_.UnsafeMergeFrom(from.input_);
- input_shape_.MergeFrom(from.input_shape_);
- input_dim_.UnsafeMergeFrom(from.input_dim_);
- layer_.MergeFrom(from.layer_);
- layers_.MergeFrom(from.layers_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_name()) {
- set_has_name();
- name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
- }
- if (from.has_force_backward()) {
- set_force_backward(from.force_backward());
- }
- if (from.has_state()) {
- mutable_state()->::caffe::NetState::MergeFrom(from.state());
- }
- if (from.has_debug_info()) {
- set_debug_info(from.debug_info());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void NetParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.NetParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void NetParameter::CopyFrom(const NetParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.NetParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool NetParameter::IsInitialized() const {
-
- return true;
-}
-
-void NetParameter::Swap(NetParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void NetParameter::InternalSwap(NetParameter* other) {
- name_.Swap(&other->name_);
- input_.UnsafeArenaSwap(&other->input_);
- input_shape_.UnsafeArenaSwap(&other->input_shape_);
- input_dim_.UnsafeArenaSwap(&other->input_dim_);
- std::swap(force_backward_, other->force_backward_);
- std::swap(state_, other->state_);
- std::swap(debug_info_, other->debug_info_);
- layer_.UnsafeArenaSwap(&other->layer_);
- layers_.UnsafeArenaSwap(&other->layers_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata NetParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = NetParameter_descriptor_;
- metadata.reflection = NetParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// NetParameter
-
-// optional string name = 1;
-bool NetParameter::has_name() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void NetParameter::set_has_name() {
- _has_bits_[0] |= 0x00000001u;
-}
-void NetParameter::clear_has_name() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void NetParameter::clear_name() {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_name();
-}
-const ::std::string& NetParameter::name() const {
- // @@protoc_insertion_point(field_get:caffe.NetParameter.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void NetParameter::set_name(const ::std::string& value) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.NetParameter.name)
-}
-void NetParameter::set_name(const char* value) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.NetParameter.name)
-}
-void NetParameter::set_name(const char* value, size_t size) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.NetParameter.name)
-}
-::std::string* NetParameter::mutable_name() {
- set_has_name();
- // @@protoc_insertion_point(field_mutable:caffe.NetParameter.name)
- return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* NetParameter::release_name() {
- // @@protoc_insertion_point(field_release:caffe.NetParameter.name)
- clear_has_name();
- return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void NetParameter::set_allocated_name(::std::string* name) {
- if (name != NULL) {
- set_has_name();
- } else {
- clear_has_name();
- }
- name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
- // @@protoc_insertion_point(field_set_allocated:caffe.NetParameter.name)
-}
-
-// repeated string input = 3;
-int NetParameter::input_size() const {
- return input_.size();
-}
-void NetParameter::clear_input() {
- input_.Clear();
-}
-const ::std::string& NetParameter::input(int index) const {
- // @@protoc_insertion_point(field_get:caffe.NetParameter.input)
- return input_.Get(index);
-}
-::std::string* NetParameter::mutable_input(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.NetParameter.input)
- return input_.Mutable(index);
-}
-void NetParameter::set_input(int index, const ::std::string& value) {
- // @@protoc_insertion_point(field_set:caffe.NetParameter.input)
- input_.Mutable(index)->assign(value);
-}
-void NetParameter::set_input(int index, const char* value) {
- input_.Mutable(index)->assign(value);
- // @@protoc_insertion_point(field_set_char:caffe.NetParameter.input)
-}
-void NetParameter::set_input(int index, const char* value, size_t size) {
- input_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:caffe.NetParameter.input)
-}
-::std::string* NetParameter::add_input() {
- // @@protoc_insertion_point(field_add_mutable:caffe.NetParameter.input)
- return input_.Add();
-}
-void NetParameter::add_input(const ::std::string& value) {
- input_.Add()->assign(value);
- // @@protoc_insertion_point(field_add:caffe.NetParameter.input)
-}
-void NetParameter::add_input(const char* value) {
- input_.Add()->assign(value);
- // @@protoc_insertion_point(field_add_char:caffe.NetParameter.input)
-}
-void NetParameter::add_input(const char* value, size_t size) {
- input_.Add()->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_add_pointer:caffe.NetParameter.input)
-}
-const ::google::protobuf::RepeatedPtrField< ::std::string>&
-NetParameter::input() const {
- // @@protoc_insertion_point(field_list:caffe.NetParameter.input)
- return input_;
-}
-::google::protobuf::RepeatedPtrField< ::std::string>*
-NetParameter::mutable_input() {
- // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.input)
- return &input_;
-}
-
-// repeated .caffe.BlobShape input_shape = 8;
-int NetParameter::input_shape_size() const {
- return input_shape_.size();
-}
-void NetParameter::clear_input_shape() {
- input_shape_.Clear();
-}
-const ::caffe::BlobShape& NetParameter::input_shape(int index) const {
- // @@protoc_insertion_point(field_get:caffe.NetParameter.input_shape)
- return input_shape_.Get(index);
-}
-::caffe::BlobShape* NetParameter::mutable_input_shape(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.NetParameter.input_shape)
- return input_shape_.Mutable(index);
-}
-::caffe::BlobShape* NetParameter::add_input_shape() {
- // @@protoc_insertion_point(field_add:caffe.NetParameter.input_shape)
- return input_shape_.Add();
-}
-::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >*
-NetParameter::mutable_input_shape() {
- // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.input_shape)
- return &input_shape_;
-}
-const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >&
-NetParameter::input_shape() const {
- // @@protoc_insertion_point(field_list:caffe.NetParameter.input_shape)
- return input_shape_;
-}
-
-// repeated int32 input_dim = 4;
-int NetParameter::input_dim_size() const {
- return input_dim_.size();
-}
-void NetParameter::clear_input_dim() {
- input_dim_.Clear();
-}
-::google::protobuf::int32 NetParameter::input_dim(int index) const {
- // @@protoc_insertion_point(field_get:caffe.NetParameter.input_dim)
- return input_dim_.Get(index);
-}
-void NetParameter::set_input_dim(int index, ::google::protobuf::int32 value) {
- input_dim_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.NetParameter.input_dim)
-}
-void NetParameter::add_input_dim(::google::protobuf::int32 value) {
- input_dim_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.NetParameter.input_dim)
-}
-const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
-NetParameter::input_dim() const {
- // @@protoc_insertion_point(field_list:caffe.NetParameter.input_dim)
- return input_dim_;
-}
-::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
-NetParameter::mutable_input_dim() {
- // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.input_dim)
- return &input_dim_;
-}
-
-// optional bool force_backward = 5 [default = false];
-bool NetParameter::has_force_backward() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-void NetParameter::set_has_force_backward() {
- _has_bits_[0] |= 0x00000010u;
-}
-void NetParameter::clear_has_force_backward() {
- _has_bits_[0] &= ~0x00000010u;
-}
-void NetParameter::clear_force_backward() {
- force_backward_ = false;
- clear_has_force_backward();
-}
-bool NetParameter::force_backward() const {
- // @@protoc_insertion_point(field_get:caffe.NetParameter.force_backward)
- return force_backward_;
-}
-void NetParameter::set_force_backward(bool value) {
- set_has_force_backward();
- force_backward_ = value;
- // @@protoc_insertion_point(field_set:caffe.NetParameter.force_backward)
-}
-
-// optional .caffe.NetState state = 6;
-bool NetParameter::has_state() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-void NetParameter::set_has_state() {
- _has_bits_[0] |= 0x00000020u;
-}
-void NetParameter::clear_has_state() {
- _has_bits_[0] &= ~0x00000020u;
-}
-void NetParameter::clear_state() {
- if (state_ != NULL) state_->::caffe::NetState::Clear();
- clear_has_state();
-}
-const ::caffe::NetState& NetParameter::state() const {
- // @@protoc_insertion_point(field_get:caffe.NetParameter.state)
- return state_ != NULL ? *state_
- : *::caffe::NetState::internal_default_instance();
-}
-::caffe::NetState* NetParameter::mutable_state() {
- set_has_state();
- if (state_ == NULL) {
- state_ = new ::caffe::NetState;
- }
- // @@protoc_insertion_point(field_mutable:caffe.NetParameter.state)
- return state_;
-}
-::caffe::NetState* NetParameter::release_state() {
- // @@protoc_insertion_point(field_release:caffe.NetParameter.state)
- clear_has_state();
- ::caffe::NetState* temp = state_;
- state_ = NULL;
- return temp;
-}
-void NetParameter::set_allocated_state(::caffe::NetState* state) {
- delete state_;
- state_ = state;
- if (state) {
- set_has_state();
- } else {
- clear_has_state();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.NetParameter.state)
-}
-
-// optional bool debug_info = 7 [default = false];
-bool NetParameter::has_debug_info() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-void NetParameter::set_has_debug_info() {
- _has_bits_[0] |= 0x00000040u;
-}
-void NetParameter::clear_has_debug_info() {
- _has_bits_[0] &= ~0x00000040u;
-}
-void NetParameter::clear_debug_info() {
- debug_info_ = false;
- clear_has_debug_info();
-}
-bool NetParameter::debug_info() const {
- // @@protoc_insertion_point(field_get:caffe.NetParameter.debug_info)
- return debug_info_;
-}
-void NetParameter::set_debug_info(bool value) {
- set_has_debug_info();
- debug_info_ = value;
- // @@protoc_insertion_point(field_set:caffe.NetParameter.debug_info)
-}
-
-// repeated .caffe.LayerParameter layer = 100;
-int NetParameter::layer_size() const {
- return layer_.size();
-}
-void NetParameter::clear_layer() {
- layer_.Clear();
-}
-const ::caffe::LayerParameter& NetParameter::layer(int index) const {
- // @@protoc_insertion_point(field_get:caffe.NetParameter.layer)
- return layer_.Get(index);
-}
-::caffe::LayerParameter* NetParameter::mutable_layer(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.NetParameter.layer)
- return layer_.Mutable(index);
-}
-::caffe::LayerParameter* NetParameter::add_layer() {
- // @@protoc_insertion_point(field_add:caffe.NetParameter.layer)
- return layer_.Add();
-}
-::google::protobuf::RepeatedPtrField< ::caffe::LayerParameter >*
-NetParameter::mutable_layer() {
- // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.layer)
- return &layer_;
-}
-const ::google::protobuf::RepeatedPtrField< ::caffe::LayerParameter >&
-NetParameter::layer() const {
- // @@protoc_insertion_point(field_list:caffe.NetParameter.layer)
- return layer_;
-}
-
-// repeated .caffe.V1LayerParameter layers = 2;
-int NetParameter::layers_size() const {
- return layers_.size();
-}
-void NetParameter::clear_layers() {
- layers_.Clear();
-}
-const ::caffe::V1LayerParameter& NetParameter::layers(int index) const {
- // @@protoc_insertion_point(field_get:caffe.NetParameter.layers)
- return layers_.Get(index);
-}
-::caffe::V1LayerParameter* NetParameter::mutable_layers(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.NetParameter.layers)
- return layers_.Mutable(index);
-}
-::caffe::V1LayerParameter* NetParameter::add_layers() {
- // @@protoc_insertion_point(field_add:caffe.NetParameter.layers)
- return layers_.Add();
-}
-::google::protobuf::RepeatedPtrField< ::caffe::V1LayerParameter >*
-NetParameter::mutable_layers() {
- // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.layers)
- return &layers_;
-}
-const ::google::protobuf::RepeatedPtrField< ::caffe::V1LayerParameter >&
-NetParameter::layers() const {
- // @@protoc_insertion_point(field_list:caffe.NetParameter.layers)
- return layers_;
-}
-
-inline const NetParameter* NetParameter::internal_default_instance() {
- return &NetParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-const ::google::protobuf::EnumDescriptor* SolverParameter_SolverMode_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return SolverParameter_SolverMode_descriptor_;
-}
-bool SolverParameter_SolverMode_IsValid(int value) {
- switch (value) {
- case 0:
- case 1:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const SolverParameter_SolverMode SolverParameter::CPU;
-const SolverParameter_SolverMode SolverParameter::GPU;
-const SolverParameter_SolverMode SolverParameter::SolverMode_MIN;
-const SolverParameter_SolverMode SolverParameter::SolverMode_MAX;
-const int SolverParameter::SolverMode_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-const ::google::protobuf::EnumDescriptor* SolverParameter_SolverType_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return SolverParameter_SolverType_descriptor_;
-}
-bool SolverParameter_SolverType_IsValid(int value) {
- switch (value) {
- case 0:
- case 1:
- case 2:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const SolverParameter_SolverType SolverParameter::SGD;
-const SolverParameter_SolverType SolverParameter::NESTEROV;
-const SolverParameter_SolverType SolverParameter::ADAGRAD;
-const SolverParameter_SolverType SolverParameter::SolverType_MIN;
-const SolverParameter_SolverType SolverParameter::SolverType_MAX;
-const int SolverParameter::SolverType_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-::std::string* SolverParameter::_default_regularization_type_ = NULL;
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int SolverParameter::kNetFieldNumber;
-const int SolverParameter::kNetParamFieldNumber;
-const int SolverParameter::kTrainNetFieldNumber;
-const int SolverParameter::kTestNetFieldNumber;
-const int SolverParameter::kTrainNetParamFieldNumber;
-const int SolverParameter::kTestNetParamFieldNumber;
-const int SolverParameter::kTrainStateFieldNumber;
-const int SolverParameter::kTestStateFieldNumber;
-const int SolverParameter::kTestIterFieldNumber;
-const int SolverParameter::kTestIntervalFieldNumber;
-const int SolverParameter::kTestComputeLossFieldNumber;
-const int SolverParameter::kTestInitializationFieldNumber;
-const int SolverParameter::kBaseLrFieldNumber;
-const int SolverParameter::kDisplayFieldNumber;
-const int SolverParameter::kAverageLossFieldNumber;
-const int SolverParameter::kMaxIterFieldNumber;
-const int SolverParameter::kIterSizeFieldNumber;
-const int SolverParameter::kLrPolicyFieldNumber;
-const int SolverParameter::kGammaFieldNumber;
-const int SolverParameter::kPowerFieldNumber;
-const int SolverParameter::kMomentumFieldNumber;
-const int SolverParameter::kWeightDecayFieldNumber;
-const int SolverParameter::kRegularizationTypeFieldNumber;
-const int SolverParameter::kStepsizeFieldNumber;
-const int SolverParameter::kStepvalueFieldNumber;
-const int SolverParameter::kClipGradientsFieldNumber;
-const int SolverParameter::kSnapshotFieldNumber;
-const int SolverParameter::kSnapshotPrefixFieldNumber;
-const int SolverParameter::kSnapshotDiffFieldNumber;
-const int SolverParameter::kSolverModeFieldNumber;
-const int SolverParameter::kDeviceIdFieldNumber;
-const int SolverParameter::kRandomSeedFieldNumber;
-const int SolverParameter::kSolverTypeFieldNumber;
-const int SolverParameter::kDeltaFieldNumber;
-const int SolverParameter::kDebugInfoFieldNumber;
-const int SolverParameter::kSnapshotAfterTrainFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-SolverParameter::SolverParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.SolverParameter)
-}
-
-void SolverParameter::InitAsDefaultInstance() {
- net_param_ = const_cast< ::caffe::NetParameter*>(
- ::caffe::NetParameter::internal_default_instance());
- train_net_param_ = const_cast< ::caffe::NetParameter*>(
- ::caffe::NetParameter::internal_default_instance());
- train_state_ = const_cast< ::caffe::NetState*>(
- ::caffe::NetState::internal_default_instance());
-}
-
-SolverParameter::SolverParameter(const SolverParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.SolverParameter)
-}
-
-void SolverParameter::SharedCtor() {
- net_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- train_net_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- lr_policy_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- regularization_type_.UnsafeSetDefault(_default_regularization_type_);
- snapshot_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- net_param_ = NULL;
- train_net_param_ = NULL;
- train_state_ = NULL;
- ::memset(&test_interval_, 0, reinterpret_cast<char*>(&solver_type_) -
- reinterpret_cast<char*>(&test_interval_) + sizeof(solver_type_));
- average_loss_ = 1;
- iter_size_ = 1;
- test_initialization_ = true;
- snapshot_after_train_ = true;
- clip_gradients_ = -1;
- random_seed_ = GOOGLE_LONGLONG(-1);
- solver_mode_ = 1;
- delta_ = 1e-08f;
- _cached_size_ = 0;
-}
-
-SolverParameter::~SolverParameter() {
- // @@protoc_insertion_point(destructor:caffe.SolverParameter)
- SharedDtor();
-}
-
-void SolverParameter::SharedDtor() {
- net_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- train_net_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- lr_policy_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- regularization_type_.DestroyNoArena(_default_regularization_type_);
- snapshot_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- if (this != &SolverParameter_default_instance_.get()) {
- delete net_param_;
- delete train_net_param_;
- delete train_state_;
- }
-}
-
-void SolverParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* SolverParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return SolverParameter_descriptor_;
-}
-
-const SolverParameter& SolverParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<SolverParameter> SolverParameter_default_instance_;
-
-SolverParameter* SolverParameter::New(::google::protobuf::Arena* arena) const {
- SolverParameter* n = new SolverParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void SolverParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.SolverParameter)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(SolverParameter, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<SolverParameter*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- if (_has_bits_[0 / 32] & 87u) {
- if (has_net()) {
- net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- if (has_net_param()) {
- if (net_param_ != NULL) net_param_->::caffe::NetParameter::Clear();
- }
- if (has_train_net()) {
- train_net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- if (has_train_net_param()) {
- if (train_net_param_ != NULL) train_net_param_->::caffe::NetParameter::Clear();
- }
- if (has_train_state()) {
- if (train_state_ != NULL) train_state_->::caffe::NetState::Clear();
- }
- }
- if (_has_bits_[8 / 32] & 65024u) {
- ZR_(test_interval_, max_iter_);
- test_compute_loss_ = false;
- test_initialization_ = true;
- average_loss_ = 1;
- }
- if (_has_bits_[16 / 32] & 16711680u) {
- ZR_(gamma_, stepsize_);
- iter_size_ = 1;
- if (has_lr_policy()) {
- lr_policy_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- if (has_regularization_type()) {
- regularization_type_.ClearToDefaultNoArena(_default_regularization_type_);
- }
- }
- if (_has_bits_[24 / 32] & 4261412864u) {
- ZR_(snapshot_, device_id_);
- clip_gradients_ = -1;
- if (has_snapshot_prefix()) {
- snapshot_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- snapshot_diff_ = false;
- solver_mode_ = 1;
- random_seed_ = GOOGLE_LONGLONG(-1);
- }
- if (_has_bits_[32 / 32] & 15u) {
- solver_type_ = 0;
- delta_ = 1e-08f;
- debug_info_ = false;
- snapshot_after_train_ = true;
- }
-
-#undef ZR_HELPER_
-#undef ZR_
-
- test_net_.Clear();
- test_net_param_.Clear();
- test_state_.Clear();
- test_iter_.Clear();
- stepvalue_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool SolverParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.SolverParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional string train_net = 1;
- case 1: {
- if (tag == 10) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_train_net()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->train_net().data(), this->train_net().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.SolverParameter.train_net");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(18)) goto parse_test_net;
- break;
- }
-
- // repeated string test_net = 2;
- case 2: {
- if (tag == 18) {
- parse_test_net:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->add_test_net()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->test_net(this->test_net_size() - 1).data(),
- this->test_net(this->test_net_size() - 1).length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.SolverParameter.test_net");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(18)) goto parse_test_net;
- if (input->ExpectTag(24)) goto parse_test_iter;
- break;
- }
-
- // repeated int32 test_iter = 3;
- case 3: {
- if (tag == 24) {
- parse_test_iter:
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- 1, 24, input, this->mutable_test_iter())));
- } else if (tag == 26) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, this->mutable_test_iter())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(24)) goto parse_test_iter;
- if (input->ExpectTag(32)) goto parse_test_interval;
- break;
- }
-
- // optional int32 test_interval = 4 [default = 0];
- case 4: {
- if (tag == 32) {
- parse_test_interval:
- set_has_test_interval();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &test_interval_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(45)) goto parse_base_lr;
- break;
- }
-
- // optional float base_lr = 5;
- case 5: {
- if (tag == 45) {
- parse_base_lr:
- set_has_base_lr();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &base_lr_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(48)) goto parse_display;
- break;
- }
-
- // optional int32 display = 6;
- case 6: {
- if (tag == 48) {
- parse_display:
- set_has_display();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &display_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(56)) goto parse_max_iter;
- break;
- }
-
- // optional int32 max_iter = 7;
- case 7: {
- if (tag == 56) {
- parse_max_iter:
- set_has_max_iter();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &max_iter_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(66)) goto parse_lr_policy;
- break;
- }
-
- // optional string lr_policy = 8;
- case 8: {
- if (tag == 66) {
- parse_lr_policy:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_lr_policy()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->lr_policy().data(), this->lr_policy().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.SolverParameter.lr_policy");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(77)) goto parse_gamma;
- break;
- }
-
- // optional float gamma = 9;
- case 9: {
- if (tag == 77) {
- parse_gamma:
- set_has_gamma();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &gamma_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(85)) goto parse_power;
- break;
- }
-
- // optional float power = 10;
- case 10: {
- if (tag == 85) {
- parse_power:
- set_has_power();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &power_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(93)) goto parse_momentum;
- break;
- }
-
- // optional float momentum = 11;
- case 11: {
- if (tag == 93) {
- parse_momentum:
- set_has_momentum();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &momentum_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(101)) goto parse_weight_decay;
- break;
- }
-
- // optional float weight_decay = 12;
- case 12: {
- if (tag == 101) {
- parse_weight_decay:
- set_has_weight_decay();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &weight_decay_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(104)) goto parse_stepsize;
- break;
- }
-
- // optional int32 stepsize = 13;
- case 13: {
- if (tag == 104) {
- parse_stepsize:
- set_has_stepsize();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &stepsize_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(112)) goto parse_snapshot;
- break;
- }
-
- // optional int32 snapshot = 14 [default = 0];
- case 14: {
- if (tag == 112) {
- parse_snapshot:
- set_has_snapshot();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &snapshot_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(122)) goto parse_snapshot_prefix;
- break;
- }
-
- // optional string snapshot_prefix = 15;
- case 15: {
- if (tag == 122) {
- parse_snapshot_prefix:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_snapshot_prefix()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->snapshot_prefix().data(), this->snapshot_prefix().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.SolverParameter.snapshot_prefix");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(128)) goto parse_snapshot_diff;
- break;
- }
-
- // optional bool snapshot_diff = 16 [default = false];
- case 16: {
- if (tag == 128) {
- parse_snapshot_diff:
- set_has_snapshot_diff();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &snapshot_diff_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(136)) goto parse_solver_mode;
- break;
- }
-
- // optional .caffe.SolverParameter.SolverMode solver_mode = 17 [default = GPU];
- case 17: {
- if (tag == 136) {
- parse_solver_mode:
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::SolverParameter_SolverMode_IsValid(value)) {
- set_solver_mode(static_cast< ::caffe::SolverParameter_SolverMode >(value));
- } else {
- mutable_unknown_fields()->AddVarint(17, value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(144)) goto parse_device_id;
- break;
- }
-
- // optional int32 device_id = 18 [default = 0];
- case 18: {
- if (tag == 144) {
- parse_device_id:
- set_has_device_id();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &device_id_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(152)) goto parse_test_compute_loss;
- break;
- }
-
- // optional bool test_compute_loss = 19 [default = false];
- case 19: {
- if (tag == 152) {
- parse_test_compute_loss:
- set_has_test_compute_loss();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &test_compute_loss_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(160)) goto parse_random_seed;
- break;
- }
-
- // optional int64 random_seed = 20 [default = -1];
- case 20: {
- if (tag == 160) {
- parse_random_seed:
- set_has_random_seed();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
- input, &random_seed_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(170)) goto parse_train_net_param;
- break;
- }
-
- // optional .caffe.NetParameter train_net_param = 21;
- case 21: {
- if (tag == 170) {
- parse_train_net_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_train_net_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(178)) goto parse_test_net_param;
- break;
- }
-
- // repeated .caffe.NetParameter test_net_param = 22;
- case 22: {
- if (tag == 178) {
- parse_test_net_param:
- DO_(input->IncrementRecursionDepth());
- parse_loop_test_net_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
- input, add_test_net_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(178)) goto parse_loop_test_net_param;
- input->UnsafeDecrementRecursionDepth();
- if (input->ExpectTag(184)) goto parse_debug_info;
- break;
- }
-
- // optional bool debug_info = 23 [default = false];
- case 23: {
- if (tag == 184) {
- parse_debug_info:
- set_has_debug_info();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &debug_info_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(194)) goto parse_net;
- break;
- }
-
- // optional string net = 24;
- case 24: {
- if (tag == 194) {
- parse_net:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_net()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->net().data(), this->net().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.SolverParameter.net");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(202)) goto parse_net_param;
- break;
- }
-
- // optional .caffe.NetParameter net_param = 25;
- case 25: {
- if (tag == 202) {
- parse_net_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_net_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(210)) goto parse_train_state;
- break;
- }
-
- // optional .caffe.NetState train_state = 26;
- case 26: {
- if (tag == 210) {
- parse_train_state:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_train_state()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(218)) goto parse_test_state;
- break;
- }
-
- // repeated .caffe.NetState test_state = 27;
- case 27: {
- if (tag == 218) {
- parse_test_state:
- DO_(input->IncrementRecursionDepth());
- parse_loop_test_state:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
- input, add_test_state()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(218)) goto parse_loop_test_state;
- input->UnsafeDecrementRecursionDepth();
- if (input->ExpectTag(224)) goto parse_snapshot_after_train;
- break;
- }
-
- // optional bool snapshot_after_train = 28 [default = true];
- case 28: {
- if (tag == 224) {
- parse_snapshot_after_train:
- set_has_snapshot_after_train();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &snapshot_after_train_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(234)) goto parse_regularization_type;
- break;
- }
-
- // optional string regularization_type = 29 [default = "L2"];
- case 29: {
- if (tag == 234) {
- parse_regularization_type:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_regularization_type()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->regularization_type().data(), this->regularization_type().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.SolverParameter.regularization_type");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(240)) goto parse_solver_type;
- break;
- }
-
- // optional .caffe.SolverParameter.SolverType solver_type = 30 [default = SGD];
- case 30: {
- if (tag == 240) {
- parse_solver_type:
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::SolverParameter_SolverType_IsValid(value)) {
- set_solver_type(static_cast< ::caffe::SolverParameter_SolverType >(value));
- } else {
- mutable_unknown_fields()->AddVarint(30, value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(253)) goto parse_delta;
- break;
- }
-
- // optional float delta = 31 [default = 1e-08];
- case 31: {
- if (tag == 253) {
- parse_delta:
- set_has_delta();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &delta_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(256)) goto parse_test_initialization;
- break;
- }
-
- // optional bool test_initialization = 32 [default = true];
- case 32: {
- if (tag == 256) {
- parse_test_initialization:
- set_has_test_initialization();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &test_initialization_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(264)) goto parse_average_loss;
- break;
- }
-
- // optional int32 average_loss = 33 [default = 1];
- case 33: {
- if (tag == 264) {
- parse_average_loss:
- set_has_average_loss();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &average_loss_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(272)) goto parse_stepvalue;
- break;
- }
-
- // repeated int32 stepvalue = 34;
- case 34: {
- if (tag == 272) {
- parse_stepvalue:
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- 2, 272, input, this->mutable_stepvalue())));
- } else if (tag == 274) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, this->mutable_stepvalue())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(272)) goto parse_stepvalue;
- if (input->ExpectTag(285)) goto parse_clip_gradients;
- break;
- }
-
- // optional float clip_gradients = 35 [default = -1];
- case 35: {
- if (tag == 285) {
- parse_clip_gradients:
- set_has_clip_gradients();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &clip_gradients_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(288)) goto parse_iter_size;
- break;
- }
-
- // optional int32 iter_size = 36 [default = 1];
- case 36: {
- if (tag == 288) {
- parse_iter_size:
- set_has_iter_size();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &iter_size_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.SolverParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.SolverParameter)
- return false;
-#undef DO_
-}
-
-void SolverParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.SolverParameter)
- // optional string train_net = 1;
- if (has_train_net()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->train_net().data(), this->train_net().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.SolverParameter.train_net");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 1, this->train_net(), output);
- }
-
- // repeated string test_net = 2;
- for (int i = 0; i < this->test_net_size(); i++) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->test_net(i).data(), this->test_net(i).length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.SolverParameter.test_net");
- ::google::protobuf::internal::WireFormatLite::WriteString(
- 2, this->test_net(i), output);
- }
-
- // repeated int32 test_iter = 3;
- for (int i = 0; i < this->test_iter_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(
- 3, this->test_iter(i), output);
- }
-
- // optional int32 test_interval = 4 [default = 0];
- if (has_test_interval()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->test_interval(), output);
- }
-
- // optional float base_lr = 5;
- if (has_base_lr()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(5, this->base_lr(), output);
- }
-
- // optional int32 display = 6;
- if (has_display()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(6, this->display(), output);
- }
-
- // optional int32 max_iter = 7;
- if (has_max_iter()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(7, this->max_iter(), output);
- }
-
- // optional string lr_policy = 8;
- if (has_lr_policy()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->lr_policy().data(), this->lr_policy().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.SolverParameter.lr_policy");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 8, this->lr_policy(), output);
- }
-
- // optional float gamma = 9;
- if (has_gamma()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(9, this->gamma(), output);
- }
-
- // optional float power = 10;
- if (has_power()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(10, this->power(), output);
- }
-
- // optional float momentum = 11;
- if (has_momentum()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(11, this->momentum(), output);
- }
-
- // optional float weight_decay = 12;
- if (has_weight_decay()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(12, this->weight_decay(), output);
- }
-
- // optional int32 stepsize = 13;
- if (has_stepsize()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(13, this->stepsize(), output);
- }
-
- // optional int32 snapshot = 14 [default = 0];
- if (has_snapshot()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(14, this->snapshot(), output);
- }
-
- // optional string snapshot_prefix = 15;
- if (has_snapshot_prefix()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->snapshot_prefix().data(), this->snapshot_prefix().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.SolverParameter.snapshot_prefix");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 15, this->snapshot_prefix(), output);
- }
-
- // optional bool snapshot_diff = 16 [default = false];
- if (has_snapshot_diff()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(16, this->snapshot_diff(), output);
- }
-
- // optional .caffe.SolverParameter.SolverMode solver_mode = 17 [default = GPU];
- if (has_solver_mode()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 17, this->solver_mode(), output);
- }
-
- // optional int32 device_id = 18 [default = 0];
- if (has_device_id()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(18, this->device_id(), output);
- }
-
- // optional bool test_compute_loss = 19 [default = false];
- if (has_test_compute_loss()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(19, this->test_compute_loss(), output);
- }
-
- // optional int64 random_seed = 20 [default = -1];
- if (has_random_seed()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt64(20, this->random_seed(), output);
- }
-
- // optional .caffe.NetParameter train_net_param = 21;
- if (has_train_net_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 21, *this->train_net_param_, output);
- }
-
- // repeated .caffe.NetParameter test_net_param = 22;
- for (unsigned int i = 0, n = this->test_net_param_size(); i < n; i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 22, this->test_net_param(i), output);
- }
-
- // optional bool debug_info = 23 [default = false];
- if (has_debug_info()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(23, this->debug_info(), output);
- }
-
- // optional string net = 24;
- if (has_net()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->net().data(), this->net().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.SolverParameter.net");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 24, this->net(), output);
- }
-
- // optional .caffe.NetParameter net_param = 25;
- if (has_net_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 25, *this->net_param_, output);
- }
-
- // optional .caffe.NetState train_state = 26;
- if (has_train_state()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 26, *this->train_state_, output);
- }
-
- // repeated .caffe.NetState test_state = 27;
- for (unsigned int i = 0, n = this->test_state_size(); i < n; i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 27, this->test_state(i), output);
- }
-
- // optional bool snapshot_after_train = 28 [default = true];
- if (has_snapshot_after_train()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(28, this->snapshot_after_train(), output);
- }
-
- // optional string regularization_type = 29 [default = "L2"];
- if (has_regularization_type()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->regularization_type().data(), this->regularization_type().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.SolverParameter.regularization_type");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 29, this->regularization_type(), output);
- }
-
- // optional .caffe.SolverParameter.SolverType solver_type = 30 [default = SGD];
- if (has_solver_type()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 30, this->solver_type(), output);
- }
-
- // optional float delta = 31 [default = 1e-08];
- if (has_delta()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(31, this->delta(), output);
- }
-
- // optional bool test_initialization = 32 [default = true];
- if (has_test_initialization()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(32, this->test_initialization(), output);
- }
-
- // optional int32 average_loss = 33 [default = 1];
- if (has_average_loss()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(33, this->average_loss(), output);
- }
-
- // repeated int32 stepvalue = 34;
- for (int i = 0; i < this->stepvalue_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(
- 34, this->stepvalue(i), output);
- }
-
- // optional float clip_gradients = 35 [default = -1];
- if (has_clip_gradients()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(35, this->clip_gradients(), output);
- }
-
- // optional int32 iter_size = 36 [default = 1];
- if (has_iter_size()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(36, this->iter_size(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.SolverParameter)
-}
-
-::google::protobuf::uint8* SolverParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.SolverParameter)
- // optional string train_net = 1;
- if (has_train_net()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->train_net().data(), this->train_net().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.SolverParameter.train_net");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 1, this->train_net(), target);
- }
-
- // repeated string test_net = 2;
- for (int i = 0; i < this->test_net_size(); i++) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->test_net(i).data(), this->test_net(i).length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.SolverParameter.test_net");
- target = ::google::protobuf::internal::WireFormatLite::
- WriteStringToArray(2, this->test_net(i), target);
- }
-
- // repeated int32 test_iter = 3;
- for (int i = 0; i < this->test_iter_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteInt32ToArray(3, this->test_iter(i), target);
- }
-
- // optional int32 test_interval = 4 [default = 0];
- if (has_test_interval()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->test_interval(), target);
- }
-
- // optional float base_lr = 5;
- if (has_base_lr()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(5, this->base_lr(), target);
- }
-
- // optional int32 display = 6;
- if (has_display()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(6, this->display(), target);
- }
-
- // optional int32 max_iter = 7;
- if (has_max_iter()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(7, this->max_iter(), target);
- }
-
- // optional string lr_policy = 8;
- if (has_lr_policy()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->lr_policy().data(), this->lr_policy().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.SolverParameter.lr_policy");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 8, this->lr_policy(), target);
- }
-
- // optional float gamma = 9;
- if (has_gamma()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(9, this->gamma(), target);
- }
-
- // optional float power = 10;
- if (has_power()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(10, this->power(), target);
- }
-
- // optional float momentum = 11;
- if (has_momentum()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(11, this->momentum(), target);
- }
-
- // optional float weight_decay = 12;
- if (has_weight_decay()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(12, this->weight_decay(), target);
- }
-
- // optional int32 stepsize = 13;
- if (has_stepsize()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(13, this->stepsize(), target);
- }
-
- // optional int32 snapshot = 14 [default = 0];
- if (has_snapshot()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(14, this->snapshot(), target);
- }
-
- // optional string snapshot_prefix = 15;
- if (has_snapshot_prefix()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->snapshot_prefix().data(), this->snapshot_prefix().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.SolverParameter.snapshot_prefix");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 15, this->snapshot_prefix(), target);
- }
-
- // optional bool snapshot_diff = 16 [default = false];
- if (has_snapshot_diff()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(16, this->snapshot_diff(), target);
- }
-
- // optional .caffe.SolverParameter.SolverMode solver_mode = 17 [default = GPU];
- if (has_solver_mode()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 17, this->solver_mode(), target);
- }
-
- // optional int32 device_id = 18 [default = 0];
- if (has_device_id()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(18, this->device_id(), target);
- }
-
- // optional bool test_compute_loss = 19 [default = false];
- if (has_test_compute_loss()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(19, this->test_compute_loss(), target);
- }
-
- // optional int64 random_seed = 20 [default = -1];
- if (has_random_seed()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(20, this->random_seed(), target);
- }
-
- // optional .caffe.NetParameter train_net_param = 21;
- if (has_train_net_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 21, *this->train_net_param_, false, target);
- }
-
- // repeated .caffe.NetParameter test_net_param = 22;
- for (unsigned int i = 0, n = this->test_net_param_size(); i < n; i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 22, this->test_net_param(i), false, target);
- }
-
- // optional bool debug_info = 23 [default = false];
- if (has_debug_info()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(23, this->debug_info(), target);
- }
-
- // optional string net = 24;
- if (has_net()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->net().data(), this->net().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.SolverParameter.net");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 24, this->net(), target);
- }
-
- // optional .caffe.NetParameter net_param = 25;
- if (has_net_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 25, *this->net_param_, false, target);
- }
-
- // optional .caffe.NetState train_state = 26;
- if (has_train_state()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 26, *this->train_state_, false, target);
- }
-
- // repeated .caffe.NetState test_state = 27;
- for (unsigned int i = 0, n = this->test_state_size(); i < n; i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 27, this->test_state(i), false, target);
- }
-
- // optional bool snapshot_after_train = 28 [default = true];
- if (has_snapshot_after_train()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(28, this->snapshot_after_train(), target);
- }
-
- // optional string regularization_type = 29 [default = "L2"];
- if (has_regularization_type()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->regularization_type().data(), this->regularization_type().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.SolverParameter.regularization_type");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 29, this->regularization_type(), target);
- }
-
- // optional .caffe.SolverParameter.SolverType solver_type = 30 [default = SGD];
- if (has_solver_type()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 30, this->solver_type(), target);
- }
-
- // optional float delta = 31 [default = 1e-08];
- if (has_delta()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(31, this->delta(), target);
- }
-
- // optional bool test_initialization = 32 [default = true];
- if (has_test_initialization()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(32, this->test_initialization(), target);
- }
-
- // optional int32 average_loss = 33 [default = 1];
- if (has_average_loss()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(33, this->average_loss(), target);
- }
-
- // repeated int32 stepvalue = 34;
- for (int i = 0; i < this->stepvalue_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteInt32ToArray(34, this->stepvalue(i), target);
- }
-
- // optional float clip_gradients = 35 [default = -1];
- if (has_clip_gradients()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(35, this->clip_gradients(), target);
- }
-
- // optional int32 iter_size = 36 [default = 1];
- if (has_iter_size()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(36, this->iter_size(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.SolverParameter)
- return target;
-}
-
-size_t SolverParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.SolverParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 87u) {
- // optional string net = 24;
- if (has_net()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->net());
- }
-
- // optional .caffe.NetParameter net_param = 25;
- if (has_net_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->net_param_);
- }
-
- // optional string train_net = 1;
- if (has_train_net()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->train_net());
- }
-
- // optional .caffe.NetParameter train_net_param = 21;
- if (has_train_net_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->train_net_param_);
- }
-
- // optional .caffe.NetState train_state = 26;
- if (has_train_state()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->train_state_);
- }
-
- }
- if (_has_bits_[9 / 32] & 65024u) {
- // optional int32 test_interval = 4 [default = 0];
- if (has_test_interval()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->test_interval());
- }
-
- // optional bool test_compute_loss = 19 [default = false];
- if (has_test_compute_loss()) {
- total_size += 2 + 1;
- }
-
- // optional bool test_initialization = 32 [default = true];
- if (has_test_initialization()) {
- total_size += 2 + 1;
- }
-
- // optional float base_lr = 5;
- if (has_base_lr()) {
- total_size += 1 + 4;
- }
-
- // optional int32 display = 6;
- if (has_display()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->display());
- }
-
- // optional int32 average_loss = 33 [default = 1];
- if (has_average_loss()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->average_loss());
- }
-
- // optional int32 max_iter = 7;
- if (has_max_iter()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->max_iter());
- }
-
- }
- if (_has_bits_[16 / 32] & 16711680u) {
- // optional int32 iter_size = 36 [default = 1];
- if (has_iter_size()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->iter_size());
- }
-
- // optional string lr_policy = 8;
- if (has_lr_policy()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->lr_policy());
- }
-
- // optional float gamma = 9;
- if (has_gamma()) {
- total_size += 1 + 4;
- }
-
- // optional float power = 10;
- if (has_power()) {
- total_size += 1 + 4;
- }
-
- // optional float momentum = 11;
- if (has_momentum()) {
- total_size += 1 + 4;
- }
-
- // optional float weight_decay = 12;
- if (has_weight_decay()) {
- total_size += 1 + 4;
- }
-
- // optional string regularization_type = 29 [default = "L2"];
- if (has_regularization_type()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->regularization_type());
- }
-
- // optional int32 stepsize = 13;
- if (has_stepsize()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->stepsize());
- }
-
- }
- if (_has_bits_[25 / 32] & 4261412864u) {
- // optional float clip_gradients = 35 [default = -1];
- if (has_clip_gradients()) {
- total_size += 2 + 4;
- }
-
- // optional int32 snapshot = 14 [default = 0];
- if (has_snapshot()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->snapshot());
- }
-
- // optional string snapshot_prefix = 15;
- if (has_snapshot_prefix()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->snapshot_prefix());
- }
-
- // optional bool snapshot_diff = 16 [default = false];
- if (has_snapshot_diff()) {
- total_size += 2 + 1;
- }
-
- // optional .caffe.SolverParameter.SolverMode solver_mode = 17 [default = GPU];
- if (has_solver_mode()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->solver_mode());
- }
-
- // optional int32 device_id = 18 [default = 0];
- if (has_device_id()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->device_id());
- }
-
- // optional int64 random_seed = 20 [default = -1];
- if (has_random_seed()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::Int64Size(
- this->random_seed());
- }
-
- }
- if (_has_bits_[32 / 32] & 15u) {
- // optional .caffe.SolverParameter.SolverType solver_type = 30 [default = SGD];
- if (has_solver_type()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->solver_type());
- }
-
- // optional float delta = 31 [default = 1e-08];
- if (has_delta()) {
- total_size += 2 + 4;
- }
-
- // optional bool debug_info = 23 [default = false];
- if (has_debug_info()) {
- total_size += 2 + 1;
- }
-
- // optional bool snapshot_after_train = 28 [default = true];
- if (has_snapshot_after_train()) {
- total_size += 2 + 1;
- }
-
- }
- // repeated string test_net = 2;
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->test_net_size());
- for (int i = 0; i < this->test_net_size(); i++) {
- total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
- this->test_net(i));
- }
-
- // repeated .caffe.NetParameter test_net_param = 22;
- {
- unsigned int count = this->test_net_param_size();
- total_size += 2UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->test_net_param(i));
- }
- }
-
- // repeated .caffe.NetState test_state = 27;
- {
- unsigned int count = this->test_state_size();
- total_size += 2UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->test_state(i));
- }
- }
-
- // repeated int32 test_iter = 3;
- {
- size_t data_size = 0;
- unsigned int count = this->test_iter_size();
- for (unsigned int i = 0; i < count; i++) {
- data_size += ::google::protobuf::internal::WireFormatLite::
- Int32Size(this->test_iter(i));
- }
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->test_iter_size());
- total_size += data_size;
- }
-
- // repeated int32 stepvalue = 34;
- {
- size_t data_size = 0;
- unsigned int count = this->stepvalue_size();
- for (unsigned int i = 0; i < count; i++) {
- data_size += ::google::protobuf::internal::WireFormatLite::
- Int32Size(this->stepvalue(i));
- }
- total_size += 2 *
- ::google::protobuf::internal::FromIntSize(this->stepvalue_size());
- total_size += data_size;
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void SolverParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.SolverParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const SolverParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const SolverParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.SolverParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.SolverParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void SolverParameter::MergeFrom(const SolverParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.SolverParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void SolverParameter::UnsafeMergeFrom(const SolverParameter& from) {
- GOOGLE_DCHECK(&from != this);
- test_net_.UnsafeMergeFrom(from.test_net_);
- test_net_param_.MergeFrom(from.test_net_param_);
- test_state_.MergeFrom(from.test_state_);
- test_iter_.UnsafeMergeFrom(from.test_iter_);
- stepvalue_.UnsafeMergeFrom(from.stepvalue_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_net()) {
- set_has_net();
- net_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.net_);
- }
- if (from.has_net_param()) {
- mutable_net_param()->::caffe::NetParameter::MergeFrom(from.net_param());
- }
- if (from.has_train_net()) {
- set_has_train_net();
- train_net_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.train_net_);
- }
- if (from.has_train_net_param()) {
- mutable_train_net_param()->::caffe::NetParameter::MergeFrom(from.train_net_param());
- }
- if (from.has_train_state()) {
- mutable_train_state()->::caffe::NetState::MergeFrom(from.train_state());
- }
- }
- if (from._has_bits_[9 / 32] & (0xffu << (9 % 32))) {
- if (from.has_test_interval()) {
- set_test_interval(from.test_interval());
- }
- if (from.has_test_compute_loss()) {
- set_test_compute_loss(from.test_compute_loss());
- }
- if (from.has_test_initialization()) {
- set_test_initialization(from.test_initialization());
- }
- if (from.has_base_lr()) {
- set_base_lr(from.base_lr());
- }
- if (from.has_display()) {
- set_display(from.display());
- }
- if (from.has_average_loss()) {
- set_average_loss(from.average_loss());
- }
- if (from.has_max_iter()) {
- set_max_iter(from.max_iter());
- }
- }
- if (from._has_bits_[16 / 32] & (0xffu << (16 % 32))) {
- if (from.has_iter_size()) {
- set_iter_size(from.iter_size());
- }
- if (from.has_lr_policy()) {
- set_has_lr_policy();
- lr_policy_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.lr_policy_);
- }
- if (from.has_gamma()) {
- set_gamma(from.gamma());
- }
- if (from.has_power()) {
- set_power(from.power());
- }
- if (from.has_momentum()) {
- set_momentum(from.momentum());
- }
- if (from.has_weight_decay()) {
- set_weight_decay(from.weight_decay());
- }
- if (from.has_regularization_type()) {
- set_has_regularization_type();
- regularization_type_.AssignWithDefault(_default_regularization_type_, from.regularization_type_);
- }
- if (from.has_stepsize()) {
- set_stepsize(from.stepsize());
- }
- }
- if (from._has_bits_[25 / 32] & (0xffu << (25 % 32))) {
- if (from.has_clip_gradients()) {
- set_clip_gradients(from.clip_gradients());
- }
- if (from.has_snapshot()) {
- set_snapshot(from.snapshot());
- }
- if (from.has_snapshot_prefix()) {
- set_has_snapshot_prefix();
- snapshot_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.snapshot_prefix_);
- }
- if (from.has_snapshot_diff()) {
- set_snapshot_diff(from.snapshot_diff());
- }
- if (from.has_solver_mode()) {
- set_solver_mode(from.solver_mode());
- }
- if (from.has_device_id()) {
- set_device_id(from.device_id());
- }
- if (from.has_random_seed()) {
- set_random_seed(from.random_seed());
- }
- }
- if (from._has_bits_[32 / 32] & (0xffu << (32 % 32))) {
- if (from.has_solver_type()) {
- set_solver_type(from.solver_type());
- }
- if (from.has_delta()) {
- set_delta(from.delta());
- }
- if (from.has_debug_info()) {
- set_debug_info(from.debug_info());
- }
- if (from.has_snapshot_after_train()) {
- set_snapshot_after_train(from.snapshot_after_train());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void SolverParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.SolverParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void SolverParameter::CopyFrom(const SolverParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.SolverParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool SolverParameter::IsInitialized() const {
-
- return true;
-}
-
-void SolverParameter::Swap(SolverParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void SolverParameter::InternalSwap(SolverParameter* other) {
- net_.Swap(&other->net_);
- std::swap(net_param_, other->net_param_);
- train_net_.Swap(&other->train_net_);
- test_net_.UnsafeArenaSwap(&other->test_net_);
- std::swap(train_net_param_, other->train_net_param_);
- test_net_param_.UnsafeArenaSwap(&other->test_net_param_);
- std::swap(train_state_, other->train_state_);
- test_state_.UnsafeArenaSwap(&other->test_state_);
- test_iter_.UnsafeArenaSwap(&other->test_iter_);
- std::swap(test_interval_, other->test_interval_);
- std::swap(test_compute_loss_, other->test_compute_loss_);
- std::swap(test_initialization_, other->test_initialization_);
- std::swap(base_lr_, other->base_lr_);
- std::swap(display_, other->display_);
- std::swap(average_loss_, other->average_loss_);
- std::swap(max_iter_, other->max_iter_);
- std::swap(iter_size_, other->iter_size_);
- lr_policy_.Swap(&other->lr_policy_);
- std::swap(gamma_, other->gamma_);
- std::swap(power_, other->power_);
- std::swap(momentum_, other->momentum_);
- std::swap(weight_decay_, other->weight_decay_);
- regularization_type_.Swap(&other->regularization_type_);
- std::swap(stepsize_, other->stepsize_);
- stepvalue_.UnsafeArenaSwap(&other->stepvalue_);
- std::swap(clip_gradients_, other->clip_gradients_);
- std::swap(snapshot_, other->snapshot_);
- snapshot_prefix_.Swap(&other->snapshot_prefix_);
- std::swap(snapshot_diff_, other->snapshot_diff_);
- std::swap(solver_mode_, other->solver_mode_);
- std::swap(device_id_, other->device_id_);
- std::swap(random_seed_, other->random_seed_);
- std::swap(solver_type_, other->solver_type_);
- std::swap(delta_, other->delta_);
- std::swap(debug_info_, other->debug_info_);
- std::swap(snapshot_after_train_, other->snapshot_after_train_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- std::swap(_has_bits_[1], other->_has_bits_[1]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata SolverParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = SolverParameter_descriptor_;
- metadata.reflection = SolverParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// SolverParameter
-
-// optional string net = 24;
-bool SolverParameter::has_net() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void SolverParameter::set_has_net() {
- _has_bits_[0] |= 0x00000001u;
-}
-void SolverParameter::clear_has_net() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void SolverParameter::clear_net() {
- net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_net();
-}
-const ::std::string& SolverParameter::net() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.net)
- return net_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void SolverParameter::set_net(const ::std::string& value) {
- set_has_net();
- net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.net)
-}
-void SolverParameter::set_net(const char* value) {
- set_has_net();
- net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.net)
-}
-void SolverParameter::set_net(const char* value, size_t size) {
- set_has_net();
- net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.net)
-}
-::std::string* SolverParameter::mutable_net() {
- set_has_net();
- // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.net)
- return net_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* SolverParameter::release_net() {
- // @@protoc_insertion_point(field_release:caffe.SolverParameter.net)
- clear_has_net();
- return net_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void SolverParameter::set_allocated_net(::std::string* net) {
- if (net != NULL) {
- set_has_net();
- } else {
- clear_has_net();
- }
- net_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), net);
- // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.net)
-}
-
-// optional .caffe.NetParameter net_param = 25;
-bool SolverParameter::has_net_param() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void SolverParameter::set_has_net_param() {
- _has_bits_[0] |= 0x00000002u;
-}
-void SolverParameter::clear_has_net_param() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void SolverParameter::clear_net_param() {
- if (net_param_ != NULL) net_param_->::caffe::NetParameter::Clear();
- clear_has_net_param();
-}
-const ::caffe::NetParameter& SolverParameter::net_param() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.net_param)
- return net_param_ != NULL ? *net_param_
- : *::caffe::NetParameter::internal_default_instance();
-}
-::caffe::NetParameter* SolverParameter::mutable_net_param() {
- set_has_net_param();
- if (net_param_ == NULL) {
- net_param_ = new ::caffe::NetParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.net_param)
- return net_param_;
-}
-::caffe::NetParameter* SolverParameter::release_net_param() {
- // @@protoc_insertion_point(field_release:caffe.SolverParameter.net_param)
- clear_has_net_param();
- ::caffe::NetParameter* temp = net_param_;
- net_param_ = NULL;
- return temp;
-}
-void SolverParameter::set_allocated_net_param(::caffe::NetParameter* net_param) {
- delete net_param_;
- net_param_ = net_param;
- if (net_param) {
- set_has_net_param();
- } else {
- clear_has_net_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.net_param)
-}
-
-// optional string train_net = 1;
-bool SolverParameter::has_train_net() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void SolverParameter::set_has_train_net() {
- _has_bits_[0] |= 0x00000004u;
-}
-void SolverParameter::clear_has_train_net() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void SolverParameter::clear_train_net() {
- train_net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_train_net();
-}
-const ::std::string& SolverParameter::train_net() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.train_net)
- return train_net_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void SolverParameter::set_train_net(const ::std::string& value) {
- set_has_train_net();
- train_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.train_net)
-}
-void SolverParameter::set_train_net(const char* value) {
- set_has_train_net();
- train_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.train_net)
-}
-void SolverParameter::set_train_net(const char* value, size_t size) {
- set_has_train_net();
- train_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.train_net)
-}
-::std::string* SolverParameter::mutable_train_net() {
- set_has_train_net();
- // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.train_net)
- return train_net_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* SolverParameter::release_train_net() {
- // @@protoc_insertion_point(field_release:caffe.SolverParameter.train_net)
- clear_has_train_net();
- return train_net_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void SolverParameter::set_allocated_train_net(::std::string* train_net) {
- if (train_net != NULL) {
- set_has_train_net();
- } else {
- clear_has_train_net();
- }
- train_net_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), train_net);
- // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.train_net)
-}
-
-// repeated string test_net = 2;
-int SolverParameter::test_net_size() const {
- return test_net_.size();
-}
-void SolverParameter::clear_test_net() {
- test_net_.Clear();
-}
-const ::std::string& SolverParameter::test_net(int index) const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_net)
- return test_net_.Get(index);
-}
-::std::string* SolverParameter::mutable_test_net(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.test_net)
- return test_net_.Mutable(index);
-}
-void SolverParameter::set_test_net(int index, const ::std::string& value) {
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_net)
- test_net_.Mutable(index)->assign(value);
-}
-void SolverParameter::set_test_net(int index, const char* value) {
- test_net_.Mutable(index)->assign(value);
- // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.test_net)
-}
-void SolverParameter::set_test_net(int index, const char* value, size_t size) {
- test_net_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.test_net)
-}
-::std::string* SolverParameter::add_test_net() {
- // @@protoc_insertion_point(field_add_mutable:caffe.SolverParameter.test_net)
- return test_net_.Add();
-}
-void SolverParameter::add_test_net(const ::std::string& value) {
- test_net_.Add()->assign(value);
- // @@protoc_insertion_point(field_add:caffe.SolverParameter.test_net)
-}
-void SolverParameter::add_test_net(const char* value) {
- test_net_.Add()->assign(value);
- // @@protoc_insertion_point(field_add_char:caffe.SolverParameter.test_net)
-}
-void SolverParameter::add_test_net(const char* value, size_t size) {
- test_net_.Add()->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_add_pointer:caffe.SolverParameter.test_net)
-}
-const ::google::protobuf::RepeatedPtrField< ::std::string>&
-SolverParameter::test_net() const {
- // @@protoc_insertion_point(field_list:caffe.SolverParameter.test_net)
- return test_net_;
-}
-::google::protobuf::RepeatedPtrField< ::std::string>*
-SolverParameter::mutable_test_net() {
- // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.test_net)
- return &test_net_;
-}
-
-// optional .caffe.NetParameter train_net_param = 21;
-bool SolverParameter::has_train_net_param() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-void SolverParameter::set_has_train_net_param() {
- _has_bits_[0] |= 0x00000010u;
-}
-void SolverParameter::clear_has_train_net_param() {
- _has_bits_[0] &= ~0x00000010u;
-}
-void SolverParameter::clear_train_net_param() {
- if (train_net_param_ != NULL) train_net_param_->::caffe::NetParameter::Clear();
- clear_has_train_net_param();
-}
-const ::caffe::NetParameter& SolverParameter::train_net_param() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.train_net_param)
- return train_net_param_ != NULL ? *train_net_param_
- : *::caffe::NetParameter::internal_default_instance();
-}
-::caffe::NetParameter* SolverParameter::mutable_train_net_param() {
- set_has_train_net_param();
- if (train_net_param_ == NULL) {
- train_net_param_ = new ::caffe::NetParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.train_net_param)
- return train_net_param_;
-}
-::caffe::NetParameter* SolverParameter::release_train_net_param() {
- // @@protoc_insertion_point(field_release:caffe.SolverParameter.train_net_param)
- clear_has_train_net_param();
- ::caffe::NetParameter* temp = train_net_param_;
- train_net_param_ = NULL;
- return temp;
-}
-void SolverParameter::set_allocated_train_net_param(::caffe::NetParameter* train_net_param) {
- delete train_net_param_;
- train_net_param_ = train_net_param;
- if (train_net_param) {
- set_has_train_net_param();
- } else {
- clear_has_train_net_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.train_net_param)
-}
-
-// repeated .caffe.NetParameter test_net_param = 22;
-int SolverParameter::test_net_param_size() const {
- return test_net_param_.size();
-}
-void SolverParameter::clear_test_net_param() {
- test_net_param_.Clear();
-}
-const ::caffe::NetParameter& SolverParameter::test_net_param(int index) const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_net_param)
- return test_net_param_.Get(index);
-}
-::caffe::NetParameter* SolverParameter::mutable_test_net_param(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.test_net_param)
- return test_net_param_.Mutable(index);
-}
-::caffe::NetParameter* SolverParameter::add_test_net_param() {
- // @@protoc_insertion_point(field_add:caffe.SolverParameter.test_net_param)
- return test_net_param_.Add();
-}
-::google::protobuf::RepeatedPtrField< ::caffe::NetParameter >*
-SolverParameter::mutable_test_net_param() {
- // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.test_net_param)
- return &test_net_param_;
-}
-const ::google::protobuf::RepeatedPtrField< ::caffe::NetParameter >&
-SolverParameter::test_net_param() const {
- // @@protoc_insertion_point(field_list:caffe.SolverParameter.test_net_param)
- return test_net_param_;
-}
-
-// optional .caffe.NetState train_state = 26;
-bool SolverParameter::has_train_state() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-void SolverParameter::set_has_train_state() {
- _has_bits_[0] |= 0x00000040u;
-}
-void SolverParameter::clear_has_train_state() {
- _has_bits_[0] &= ~0x00000040u;
-}
-void SolverParameter::clear_train_state() {
- if (train_state_ != NULL) train_state_->::caffe::NetState::Clear();
- clear_has_train_state();
-}
-const ::caffe::NetState& SolverParameter::train_state() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.train_state)
- return train_state_ != NULL ? *train_state_
- : *::caffe::NetState::internal_default_instance();
-}
-::caffe::NetState* SolverParameter::mutable_train_state() {
- set_has_train_state();
- if (train_state_ == NULL) {
- train_state_ = new ::caffe::NetState;
- }
- // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.train_state)
- return train_state_;
-}
-::caffe::NetState* SolverParameter::release_train_state() {
- // @@protoc_insertion_point(field_release:caffe.SolverParameter.train_state)
- clear_has_train_state();
- ::caffe::NetState* temp = train_state_;
- train_state_ = NULL;
- return temp;
-}
-void SolverParameter::set_allocated_train_state(::caffe::NetState* train_state) {
- delete train_state_;
- train_state_ = train_state;
- if (train_state) {
- set_has_train_state();
- } else {
- clear_has_train_state();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.train_state)
-}
-
-// repeated .caffe.NetState test_state = 27;
-int SolverParameter::test_state_size() const {
- return test_state_.size();
-}
-void SolverParameter::clear_test_state() {
- test_state_.Clear();
-}
-const ::caffe::NetState& SolverParameter::test_state(int index) const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_state)
- return test_state_.Get(index);
-}
-::caffe::NetState* SolverParameter::mutable_test_state(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.test_state)
- return test_state_.Mutable(index);
-}
-::caffe::NetState* SolverParameter::add_test_state() {
- // @@protoc_insertion_point(field_add:caffe.SolverParameter.test_state)
- return test_state_.Add();
-}
-::google::protobuf::RepeatedPtrField< ::caffe::NetState >*
-SolverParameter::mutable_test_state() {
- // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.test_state)
- return &test_state_;
-}
-const ::google::protobuf::RepeatedPtrField< ::caffe::NetState >&
-SolverParameter::test_state() const {
- // @@protoc_insertion_point(field_list:caffe.SolverParameter.test_state)
- return test_state_;
-}
-
-// repeated int32 test_iter = 3;
-int SolverParameter::test_iter_size() const {
- return test_iter_.size();
-}
-void SolverParameter::clear_test_iter() {
- test_iter_.Clear();
-}
-::google::protobuf::int32 SolverParameter::test_iter(int index) const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_iter)
- return test_iter_.Get(index);
-}
-void SolverParameter::set_test_iter(int index, ::google::protobuf::int32 value) {
- test_iter_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_iter)
-}
-void SolverParameter::add_test_iter(::google::protobuf::int32 value) {
- test_iter_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.SolverParameter.test_iter)
-}
-const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
-SolverParameter::test_iter() const {
- // @@protoc_insertion_point(field_list:caffe.SolverParameter.test_iter)
- return test_iter_;
-}
-::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
-SolverParameter::mutable_test_iter() {
- // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.test_iter)
- return &test_iter_;
-}
-
-// optional int32 test_interval = 4 [default = 0];
-bool SolverParameter::has_test_interval() const {
- return (_has_bits_[0] & 0x00000200u) != 0;
-}
-void SolverParameter::set_has_test_interval() {
- _has_bits_[0] |= 0x00000200u;
-}
-void SolverParameter::clear_has_test_interval() {
- _has_bits_[0] &= ~0x00000200u;
-}
-void SolverParameter::clear_test_interval() {
- test_interval_ = 0;
- clear_has_test_interval();
-}
-::google::protobuf::int32 SolverParameter::test_interval() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_interval)
- return test_interval_;
-}
-void SolverParameter::set_test_interval(::google::protobuf::int32 value) {
- set_has_test_interval();
- test_interval_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_interval)
-}
-
-// optional bool test_compute_loss = 19 [default = false];
-bool SolverParameter::has_test_compute_loss() const {
- return (_has_bits_[0] & 0x00000400u) != 0;
-}
-void SolverParameter::set_has_test_compute_loss() {
- _has_bits_[0] |= 0x00000400u;
-}
-void SolverParameter::clear_has_test_compute_loss() {
- _has_bits_[0] &= ~0x00000400u;
-}
-void SolverParameter::clear_test_compute_loss() {
- test_compute_loss_ = false;
- clear_has_test_compute_loss();
-}
-bool SolverParameter::test_compute_loss() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_compute_loss)
- return test_compute_loss_;
-}
-void SolverParameter::set_test_compute_loss(bool value) {
- set_has_test_compute_loss();
- test_compute_loss_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_compute_loss)
-}
-
-// optional bool test_initialization = 32 [default = true];
-bool SolverParameter::has_test_initialization() const {
- return (_has_bits_[0] & 0x00000800u) != 0;
-}
-void SolverParameter::set_has_test_initialization() {
- _has_bits_[0] |= 0x00000800u;
-}
-void SolverParameter::clear_has_test_initialization() {
- _has_bits_[0] &= ~0x00000800u;
-}
-void SolverParameter::clear_test_initialization() {
- test_initialization_ = true;
- clear_has_test_initialization();
-}
-bool SolverParameter::test_initialization() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_initialization)
- return test_initialization_;
-}
-void SolverParameter::set_test_initialization(bool value) {
- set_has_test_initialization();
- test_initialization_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_initialization)
-}
-
-// optional float base_lr = 5;
-bool SolverParameter::has_base_lr() const {
- return (_has_bits_[0] & 0x00001000u) != 0;
-}
-void SolverParameter::set_has_base_lr() {
- _has_bits_[0] |= 0x00001000u;
-}
-void SolverParameter::clear_has_base_lr() {
- _has_bits_[0] &= ~0x00001000u;
-}
-void SolverParameter::clear_base_lr() {
- base_lr_ = 0;
- clear_has_base_lr();
-}
-float SolverParameter::base_lr() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.base_lr)
- return base_lr_;
-}
-void SolverParameter::set_base_lr(float value) {
- set_has_base_lr();
- base_lr_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.base_lr)
-}
-
-// optional int32 display = 6;
-bool SolverParameter::has_display() const {
- return (_has_bits_[0] & 0x00002000u) != 0;
-}
-void SolverParameter::set_has_display() {
- _has_bits_[0] |= 0x00002000u;
-}
-void SolverParameter::clear_has_display() {
- _has_bits_[0] &= ~0x00002000u;
-}
-void SolverParameter::clear_display() {
- display_ = 0;
- clear_has_display();
-}
-::google::protobuf::int32 SolverParameter::display() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.display)
- return display_;
-}
-void SolverParameter::set_display(::google::protobuf::int32 value) {
- set_has_display();
- display_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.display)
-}
-
-// optional int32 average_loss = 33 [default = 1];
-bool SolverParameter::has_average_loss() const {
- return (_has_bits_[0] & 0x00004000u) != 0;
-}
-void SolverParameter::set_has_average_loss() {
- _has_bits_[0] |= 0x00004000u;
-}
-void SolverParameter::clear_has_average_loss() {
- _has_bits_[0] &= ~0x00004000u;
-}
-void SolverParameter::clear_average_loss() {
- average_loss_ = 1;
- clear_has_average_loss();
-}
-::google::protobuf::int32 SolverParameter::average_loss() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.average_loss)
- return average_loss_;
-}
-void SolverParameter::set_average_loss(::google::protobuf::int32 value) {
- set_has_average_loss();
- average_loss_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.average_loss)
-}
-
-// optional int32 max_iter = 7;
-bool SolverParameter::has_max_iter() const {
- return (_has_bits_[0] & 0x00008000u) != 0;
-}
-void SolverParameter::set_has_max_iter() {
- _has_bits_[0] |= 0x00008000u;
-}
-void SolverParameter::clear_has_max_iter() {
- _has_bits_[0] &= ~0x00008000u;
-}
-void SolverParameter::clear_max_iter() {
- max_iter_ = 0;
- clear_has_max_iter();
-}
-::google::protobuf::int32 SolverParameter::max_iter() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.max_iter)
- return max_iter_;
-}
-void SolverParameter::set_max_iter(::google::protobuf::int32 value) {
- set_has_max_iter();
- max_iter_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.max_iter)
-}
-
-// optional int32 iter_size = 36 [default = 1];
-bool SolverParameter::has_iter_size() const {
- return (_has_bits_[0] & 0x00010000u) != 0;
-}
-void SolverParameter::set_has_iter_size() {
- _has_bits_[0] |= 0x00010000u;
-}
-void SolverParameter::clear_has_iter_size() {
- _has_bits_[0] &= ~0x00010000u;
-}
-void SolverParameter::clear_iter_size() {
- iter_size_ = 1;
- clear_has_iter_size();
-}
-::google::protobuf::int32 SolverParameter::iter_size() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.iter_size)
- return iter_size_;
-}
-void SolverParameter::set_iter_size(::google::protobuf::int32 value) {
- set_has_iter_size();
- iter_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.iter_size)
-}
-
-// optional string lr_policy = 8;
-bool SolverParameter::has_lr_policy() const {
- return (_has_bits_[0] & 0x00020000u) != 0;
-}
-void SolverParameter::set_has_lr_policy() {
- _has_bits_[0] |= 0x00020000u;
-}
-void SolverParameter::clear_has_lr_policy() {
- _has_bits_[0] &= ~0x00020000u;
-}
-void SolverParameter::clear_lr_policy() {
- lr_policy_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_lr_policy();
-}
-const ::std::string& SolverParameter::lr_policy() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.lr_policy)
- return lr_policy_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void SolverParameter::set_lr_policy(const ::std::string& value) {
- set_has_lr_policy();
- lr_policy_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.lr_policy)
-}
-void SolverParameter::set_lr_policy(const char* value) {
- set_has_lr_policy();
- lr_policy_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.lr_policy)
-}
-void SolverParameter::set_lr_policy(const char* value, size_t size) {
- set_has_lr_policy();
- lr_policy_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.lr_policy)
-}
-::std::string* SolverParameter::mutable_lr_policy() {
- set_has_lr_policy();
- // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.lr_policy)
- return lr_policy_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* SolverParameter::release_lr_policy() {
- // @@protoc_insertion_point(field_release:caffe.SolverParameter.lr_policy)
- clear_has_lr_policy();
- return lr_policy_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void SolverParameter::set_allocated_lr_policy(::std::string* lr_policy) {
- if (lr_policy != NULL) {
- set_has_lr_policy();
- } else {
- clear_has_lr_policy();
- }
- lr_policy_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), lr_policy);
- // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.lr_policy)
-}
-
-// optional float gamma = 9;
-bool SolverParameter::has_gamma() const {
- return (_has_bits_[0] & 0x00040000u) != 0;
-}
-void SolverParameter::set_has_gamma() {
- _has_bits_[0] |= 0x00040000u;
-}
-void SolverParameter::clear_has_gamma() {
- _has_bits_[0] &= ~0x00040000u;
-}
-void SolverParameter::clear_gamma() {
- gamma_ = 0;
- clear_has_gamma();
-}
-float SolverParameter::gamma() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.gamma)
- return gamma_;
-}
-void SolverParameter::set_gamma(float value) {
- set_has_gamma();
- gamma_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.gamma)
-}
-
-// optional float power = 10;
-bool SolverParameter::has_power() const {
- return (_has_bits_[0] & 0x00080000u) != 0;
-}
-void SolverParameter::set_has_power() {
- _has_bits_[0] |= 0x00080000u;
-}
-void SolverParameter::clear_has_power() {
- _has_bits_[0] &= ~0x00080000u;
-}
-void SolverParameter::clear_power() {
- power_ = 0;
- clear_has_power();
-}
-float SolverParameter::power() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.power)
- return power_;
-}
-void SolverParameter::set_power(float value) {
- set_has_power();
- power_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.power)
-}
-
-// optional float momentum = 11;
-bool SolverParameter::has_momentum() const {
- return (_has_bits_[0] & 0x00100000u) != 0;
-}
-void SolverParameter::set_has_momentum() {
- _has_bits_[0] |= 0x00100000u;
-}
-void SolverParameter::clear_has_momentum() {
- _has_bits_[0] &= ~0x00100000u;
-}
-void SolverParameter::clear_momentum() {
- momentum_ = 0;
- clear_has_momentum();
-}
-float SolverParameter::momentum() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.momentum)
- return momentum_;
-}
-void SolverParameter::set_momentum(float value) {
- set_has_momentum();
- momentum_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.momentum)
-}
-
-// optional float weight_decay = 12;
-bool SolverParameter::has_weight_decay() const {
- return (_has_bits_[0] & 0x00200000u) != 0;
-}
-void SolverParameter::set_has_weight_decay() {
- _has_bits_[0] |= 0x00200000u;
-}
-void SolverParameter::clear_has_weight_decay() {
- _has_bits_[0] &= ~0x00200000u;
-}
-void SolverParameter::clear_weight_decay() {
- weight_decay_ = 0;
- clear_has_weight_decay();
-}
-float SolverParameter::weight_decay() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.weight_decay)
- return weight_decay_;
-}
-void SolverParameter::set_weight_decay(float value) {
- set_has_weight_decay();
- weight_decay_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.weight_decay)
-}
-
-// optional string regularization_type = 29 [default = "L2"];
-bool SolverParameter::has_regularization_type() const {
- return (_has_bits_[0] & 0x00400000u) != 0;
-}
-void SolverParameter::set_has_regularization_type() {
- _has_bits_[0] |= 0x00400000u;
-}
-void SolverParameter::clear_has_regularization_type() {
- _has_bits_[0] &= ~0x00400000u;
-}
-void SolverParameter::clear_regularization_type() {
- regularization_type_.ClearToDefaultNoArena(_default_regularization_type_);
- clear_has_regularization_type();
-}
-const ::std::string& SolverParameter::regularization_type() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.regularization_type)
- return regularization_type_.GetNoArena(_default_regularization_type_);
-}
-void SolverParameter::set_regularization_type(const ::std::string& value) {
- set_has_regularization_type();
- regularization_type_.SetNoArena(_default_regularization_type_, value);
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.regularization_type)
-}
-void SolverParameter::set_regularization_type(const char* value) {
- set_has_regularization_type();
- regularization_type_.SetNoArena(_default_regularization_type_, ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.regularization_type)
-}
-void SolverParameter::set_regularization_type(const char* value, size_t size) {
- set_has_regularization_type();
- regularization_type_.SetNoArena(_default_regularization_type_,
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.regularization_type)
-}
-::std::string* SolverParameter::mutable_regularization_type() {
- set_has_regularization_type();
- // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.regularization_type)
- return regularization_type_.MutableNoArena(_default_regularization_type_);
-}
-::std::string* SolverParameter::release_regularization_type() {
- // @@protoc_insertion_point(field_release:caffe.SolverParameter.regularization_type)
- clear_has_regularization_type();
- return regularization_type_.ReleaseNoArena(_default_regularization_type_);
-}
-void SolverParameter::set_allocated_regularization_type(::std::string* regularization_type) {
- if (regularization_type != NULL) {
- set_has_regularization_type();
- } else {
- clear_has_regularization_type();
- }
- regularization_type_.SetAllocatedNoArena(_default_regularization_type_, regularization_type);
- // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.regularization_type)
-}
-
-// optional int32 stepsize = 13;
-bool SolverParameter::has_stepsize() const {
- return (_has_bits_[0] & 0x00800000u) != 0;
-}
-void SolverParameter::set_has_stepsize() {
- _has_bits_[0] |= 0x00800000u;
-}
-void SolverParameter::clear_has_stepsize() {
- _has_bits_[0] &= ~0x00800000u;
-}
-void SolverParameter::clear_stepsize() {
- stepsize_ = 0;
- clear_has_stepsize();
-}
-::google::protobuf::int32 SolverParameter::stepsize() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.stepsize)
- return stepsize_;
-}
-void SolverParameter::set_stepsize(::google::protobuf::int32 value) {
- set_has_stepsize();
- stepsize_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.stepsize)
-}
-
-// repeated int32 stepvalue = 34;
-int SolverParameter::stepvalue_size() const {
- return stepvalue_.size();
-}
-void SolverParameter::clear_stepvalue() {
- stepvalue_.Clear();
-}
-::google::protobuf::int32 SolverParameter::stepvalue(int index) const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.stepvalue)
- return stepvalue_.Get(index);
-}
-void SolverParameter::set_stepvalue(int index, ::google::protobuf::int32 value) {
- stepvalue_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.stepvalue)
-}
-void SolverParameter::add_stepvalue(::google::protobuf::int32 value) {
- stepvalue_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.SolverParameter.stepvalue)
-}
-const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
-SolverParameter::stepvalue() const {
- // @@protoc_insertion_point(field_list:caffe.SolverParameter.stepvalue)
- return stepvalue_;
-}
-::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
-SolverParameter::mutable_stepvalue() {
- // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.stepvalue)
- return &stepvalue_;
-}
-
-// optional float clip_gradients = 35 [default = -1];
-bool SolverParameter::has_clip_gradients() const {
- return (_has_bits_[0] & 0x02000000u) != 0;
-}
-void SolverParameter::set_has_clip_gradients() {
- _has_bits_[0] |= 0x02000000u;
-}
-void SolverParameter::clear_has_clip_gradients() {
- _has_bits_[0] &= ~0x02000000u;
-}
-void SolverParameter::clear_clip_gradients() {
- clip_gradients_ = -1;
- clear_has_clip_gradients();
-}
-float SolverParameter::clip_gradients() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.clip_gradients)
- return clip_gradients_;
-}
-void SolverParameter::set_clip_gradients(float value) {
- set_has_clip_gradients();
- clip_gradients_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.clip_gradients)
-}
-
-// optional int32 snapshot = 14 [default = 0];
-bool SolverParameter::has_snapshot() const {
- return (_has_bits_[0] & 0x04000000u) != 0;
-}
-void SolverParameter::set_has_snapshot() {
- _has_bits_[0] |= 0x04000000u;
-}
-void SolverParameter::clear_has_snapshot() {
- _has_bits_[0] &= ~0x04000000u;
-}
-void SolverParameter::clear_snapshot() {
- snapshot_ = 0;
- clear_has_snapshot();
-}
-::google::protobuf::int32 SolverParameter::snapshot() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot)
- return snapshot_;
-}
-void SolverParameter::set_snapshot(::google::protobuf::int32 value) {
- set_has_snapshot();
- snapshot_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot)
-}
-
-// optional string snapshot_prefix = 15;
-bool SolverParameter::has_snapshot_prefix() const {
- return (_has_bits_[0] & 0x08000000u) != 0;
-}
-void SolverParameter::set_has_snapshot_prefix() {
- _has_bits_[0] |= 0x08000000u;
-}
-void SolverParameter::clear_has_snapshot_prefix() {
- _has_bits_[0] &= ~0x08000000u;
-}
-void SolverParameter::clear_snapshot_prefix() {
- snapshot_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_snapshot_prefix();
-}
-const ::std::string& SolverParameter::snapshot_prefix() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot_prefix)
- return snapshot_prefix_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void SolverParameter::set_snapshot_prefix(const ::std::string& value) {
- set_has_snapshot_prefix();
- snapshot_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot_prefix)
-}
-void SolverParameter::set_snapshot_prefix(const char* value) {
- set_has_snapshot_prefix();
- snapshot_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.snapshot_prefix)
-}
-void SolverParameter::set_snapshot_prefix(const char* value, size_t size) {
- set_has_snapshot_prefix();
- snapshot_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.snapshot_prefix)
-}
-::std::string* SolverParameter::mutable_snapshot_prefix() {
- set_has_snapshot_prefix();
- // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.snapshot_prefix)
- return snapshot_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* SolverParameter::release_snapshot_prefix() {
- // @@protoc_insertion_point(field_release:caffe.SolverParameter.snapshot_prefix)
- clear_has_snapshot_prefix();
- return snapshot_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void SolverParameter::set_allocated_snapshot_prefix(::std::string* snapshot_prefix) {
- if (snapshot_prefix != NULL) {
- set_has_snapshot_prefix();
- } else {
- clear_has_snapshot_prefix();
- }
- snapshot_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), snapshot_prefix);
- // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.snapshot_prefix)
-}
-
-// optional bool snapshot_diff = 16 [default = false];
-bool SolverParameter::has_snapshot_diff() const {
- return (_has_bits_[0] & 0x10000000u) != 0;
-}
-void SolverParameter::set_has_snapshot_diff() {
- _has_bits_[0] |= 0x10000000u;
-}
-void SolverParameter::clear_has_snapshot_diff() {
- _has_bits_[0] &= ~0x10000000u;
-}
-void SolverParameter::clear_snapshot_diff() {
- snapshot_diff_ = false;
- clear_has_snapshot_diff();
-}
-bool SolverParameter::snapshot_diff() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot_diff)
- return snapshot_diff_;
-}
-void SolverParameter::set_snapshot_diff(bool value) {
- set_has_snapshot_diff();
- snapshot_diff_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot_diff)
-}
-
-// optional .caffe.SolverParameter.SolverMode solver_mode = 17 [default = GPU];
-bool SolverParameter::has_solver_mode() const {
- return (_has_bits_[0] & 0x20000000u) != 0;
-}
-void SolverParameter::set_has_solver_mode() {
- _has_bits_[0] |= 0x20000000u;
-}
-void SolverParameter::clear_has_solver_mode() {
- _has_bits_[0] &= ~0x20000000u;
-}
-void SolverParameter::clear_solver_mode() {
- solver_mode_ = 1;
- clear_has_solver_mode();
-}
-::caffe::SolverParameter_SolverMode SolverParameter::solver_mode() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.solver_mode)
- return static_cast< ::caffe::SolverParameter_SolverMode >(solver_mode_);
-}
-void SolverParameter::set_solver_mode(::caffe::SolverParameter_SolverMode value) {
- assert(::caffe::SolverParameter_SolverMode_IsValid(value));
- set_has_solver_mode();
- solver_mode_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.solver_mode)
-}
-
-// optional int32 device_id = 18 [default = 0];
-bool SolverParameter::has_device_id() const {
- return (_has_bits_[0] & 0x40000000u) != 0;
-}
-void SolverParameter::set_has_device_id() {
- _has_bits_[0] |= 0x40000000u;
-}
-void SolverParameter::clear_has_device_id() {
- _has_bits_[0] &= ~0x40000000u;
-}
-void SolverParameter::clear_device_id() {
- device_id_ = 0;
- clear_has_device_id();
-}
-::google::protobuf::int32 SolverParameter::device_id() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.device_id)
- return device_id_;
-}
-void SolverParameter::set_device_id(::google::protobuf::int32 value) {
- set_has_device_id();
- device_id_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.device_id)
-}
-
-// optional int64 random_seed = 20 [default = -1];
-bool SolverParameter::has_random_seed() const {
- return (_has_bits_[0] & 0x80000000u) != 0;
-}
-void SolverParameter::set_has_random_seed() {
- _has_bits_[0] |= 0x80000000u;
-}
-void SolverParameter::clear_has_random_seed() {
- _has_bits_[0] &= ~0x80000000u;
-}
-void SolverParameter::clear_random_seed() {
- random_seed_ = GOOGLE_LONGLONG(-1);
- clear_has_random_seed();
-}
-::google::protobuf::int64 SolverParameter::random_seed() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.random_seed)
- return random_seed_;
-}
-void SolverParameter::set_random_seed(::google::protobuf::int64 value) {
- set_has_random_seed();
- random_seed_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.random_seed)
-}
-
-// optional .caffe.SolverParameter.SolverType solver_type = 30 [default = SGD];
-bool SolverParameter::has_solver_type() const {
- return (_has_bits_[1] & 0x00000001u) != 0;
-}
-void SolverParameter::set_has_solver_type() {
- _has_bits_[1] |= 0x00000001u;
-}
-void SolverParameter::clear_has_solver_type() {
- _has_bits_[1] &= ~0x00000001u;
-}
-void SolverParameter::clear_solver_type() {
- solver_type_ = 0;
- clear_has_solver_type();
-}
-::caffe::SolverParameter_SolverType SolverParameter::solver_type() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.solver_type)
- return static_cast< ::caffe::SolverParameter_SolverType >(solver_type_);
-}
-void SolverParameter::set_solver_type(::caffe::SolverParameter_SolverType value) {
- assert(::caffe::SolverParameter_SolverType_IsValid(value));
- set_has_solver_type();
- solver_type_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.solver_type)
-}
-
-// optional float delta = 31 [default = 1e-08];
-bool SolverParameter::has_delta() const {
- return (_has_bits_[1] & 0x00000002u) != 0;
-}
-void SolverParameter::set_has_delta() {
- _has_bits_[1] |= 0x00000002u;
-}
-void SolverParameter::clear_has_delta() {
- _has_bits_[1] &= ~0x00000002u;
-}
-void SolverParameter::clear_delta() {
- delta_ = 1e-08f;
- clear_has_delta();
-}
-float SolverParameter::delta() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.delta)
- return delta_;
-}
-void SolverParameter::set_delta(float value) {
- set_has_delta();
- delta_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.delta)
-}
-
-// optional bool debug_info = 23 [default = false];
-bool SolverParameter::has_debug_info() const {
- return (_has_bits_[1] & 0x00000004u) != 0;
-}
-void SolverParameter::set_has_debug_info() {
- _has_bits_[1] |= 0x00000004u;
-}
-void SolverParameter::clear_has_debug_info() {
- _has_bits_[1] &= ~0x00000004u;
-}
-void SolverParameter::clear_debug_info() {
- debug_info_ = false;
- clear_has_debug_info();
-}
-bool SolverParameter::debug_info() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.debug_info)
- return debug_info_;
-}
-void SolverParameter::set_debug_info(bool value) {
- set_has_debug_info();
- debug_info_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.debug_info)
-}
-
-// optional bool snapshot_after_train = 28 [default = true];
-bool SolverParameter::has_snapshot_after_train() const {
- return (_has_bits_[1] & 0x00000008u) != 0;
-}
-void SolverParameter::set_has_snapshot_after_train() {
- _has_bits_[1] |= 0x00000008u;
-}
-void SolverParameter::clear_has_snapshot_after_train() {
- _has_bits_[1] &= ~0x00000008u;
-}
-void SolverParameter::clear_snapshot_after_train() {
- snapshot_after_train_ = true;
- clear_has_snapshot_after_train();
-}
-bool SolverParameter::snapshot_after_train() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot_after_train)
- return snapshot_after_train_;
-}
-void SolverParameter::set_snapshot_after_train(bool value) {
- set_has_snapshot_after_train();
- snapshot_after_train_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot_after_train)
-}
-
-inline const SolverParameter* SolverParameter::internal_default_instance() {
- return &SolverParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int SolverState::kIterFieldNumber;
-const int SolverState::kLearnedNetFieldNumber;
-const int SolverState::kHistoryFieldNumber;
-const int SolverState::kCurrentStepFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-SolverState::SolverState()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.SolverState)
-}
-
-void SolverState::InitAsDefaultInstance() {
-}
-
-SolverState::SolverState(const SolverState& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.SolverState)
-}
-
-void SolverState::SharedCtor() {
- _cached_size_ = 0;
- learned_net_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- ::memset(&iter_, 0, reinterpret_cast<char*>(¤t_step_) -
- reinterpret_cast<char*>(&iter_) + sizeof(current_step_));
-}
-
-SolverState::~SolverState() {
- // @@protoc_insertion_point(destructor:caffe.SolverState)
- SharedDtor();
-}
-
-void SolverState::SharedDtor() {
- learned_net_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-
-void SolverState::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* SolverState::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return SolverState_descriptor_;
-}
-
-const SolverState& SolverState::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<SolverState> SolverState_default_instance_;
-
-SolverState* SolverState::New(::google::protobuf::Arena* arena) const {
- SolverState* n = new SolverState;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void SolverState::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.SolverState)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(SolverState, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<SolverState*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- if (_has_bits_[0 / 32] & 11u) {
- ZR_(iter_, current_step_);
- if (has_learned_net()) {
- learned_net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- }
-
-#undef ZR_HELPER_
-#undef ZR_
-
- history_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool SolverState::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.SolverState)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional int32 iter = 1;
- case 1: {
- if (tag == 8) {
- set_has_iter();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &iter_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(18)) goto parse_learned_net;
- break;
- }
-
- // optional string learned_net = 2;
- case 2: {
- if (tag == 18) {
- parse_learned_net:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_learned_net()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->learned_net().data(), this->learned_net().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.SolverState.learned_net");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(26)) goto parse_history;
- break;
- }
-
- // repeated .caffe.BlobProto history = 3;
- case 3: {
- if (tag == 26) {
- parse_history:
- DO_(input->IncrementRecursionDepth());
- parse_loop_history:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
- input, add_history()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(26)) goto parse_loop_history;
- input->UnsafeDecrementRecursionDepth();
- if (input->ExpectTag(32)) goto parse_current_step;
- break;
- }
-
- // optional int32 current_step = 4 [default = 0];
- case 4: {
- if (tag == 32) {
- parse_current_step:
- set_has_current_step();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, ¤t_step_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.SolverState)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.SolverState)
- return false;
-#undef DO_
-}
-
-void SolverState::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.SolverState)
- // optional int32 iter = 1;
- if (has_iter()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->iter(), output);
- }
-
- // optional string learned_net = 2;
- if (has_learned_net()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->learned_net().data(), this->learned_net().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.SolverState.learned_net");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 2, this->learned_net(), output);
- }
-
- // repeated .caffe.BlobProto history = 3;
- for (unsigned int i = 0, n = this->history_size(); i < n; i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 3, this->history(i), output);
- }
-
- // optional int32 current_step = 4 [default = 0];
- if (has_current_step()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->current_step(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.SolverState)
-}
-
-::google::protobuf::uint8* SolverState::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.SolverState)
- // optional int32 iter = 1;
- if (has_iter()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->iter(), target);
- }
-
- // optional string learned_net = 2;
- if (has_learned_net()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->learned_net().data(), this->learned_net().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.SolverState.learned_net");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 2, this->learned_net(), target);
- }
-
- // repeated .caffe.BlobProto history = 3;
- for (unsigned int i = 0, n = this->history_size(); i < n; i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 3, this->history(i), false, target);
- }
-
- // optional int32 current_step = 4 [default = 0];
- if (has_current_step()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->current_step(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.SolverState)
- return target;
-}
-
-size_t SolverState::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.SolverState)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 11u) {
- // optional int32 iter = 1;
- if (has_iter()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->iter());
- }
-
- // optional string learned_net = 2;
- if (has_learned_net()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->learned_net());
- }
-
- // optional int32 current_step = 4 [default = 0];
- if (has_current_step()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->current_step());
- }
-
- }
- // repeated .caffe.BlobProto history = 3;
- {
- unsigned int count = this->history_size();
- total_size += 1UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->history(i));
- }
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void SolverState::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.SolverState)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const SolverState* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const SolverState>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.SolverState)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.SolverState)
- UnsafeMergeFrom(*source);
- }
-}
-
-void SolverState::MergeFrom(const SolverState& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.SolverState)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void SolverState::UnsafeMergeFrom(const SolverState& from) {
- GOOGLE_DCHECK(&from != this);
- history_.MergeFrom(from.history_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_iter()) {
- set_iter(from.iter());
- }
- if (from.has_learned_net()) {
- set_has_learned_net();
- learned_net_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.learned_net_);
- }
- if (from.has_current_step()) {
- set_current_step(from.current_step());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void SolverState::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.SolverState)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void SolverState::CopyFrom(const SolverState& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.SolverState)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool SolverState::IsInitialized() const {
-
- return true;
-}
-
-void SolverState::Swap(SolverState* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void SolverState::InternalSwap(SolverState* other) {
- std::swap(iter_, other->iter_);
- learned_net_.Swap(&other->learned_net_);
- history_.UnsafeArenaSwap(&other->history_);
- std::swap(current_step_, other->current_step_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata SolverState::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = SolverState_descriptor_;
- metadata.reflection = SolverState_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// SolverState
-
-// optional int32 iter = 1;
-bool SolverState::has_iter() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void SolverState::set_has_iter() {
- _has_bits_[0] |= 0x00000001u;
-}
-void SolverState::clear_has_iter() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void SolverState::clear_iter() {
- iter_ = 0;
- clear_has_iter();
-}
-::google::protobuf::int32 SolverState::iter() const {
- // @@protoc_insertion_point(field_get:caffe.SolverState.iter)
- return iter_;
-}
-void SolverState::set_iter(::google::protobuf::int32 value) {
- set_has_iter();
- iter_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverState.iter)
-}
-
-// optional string learned_net = 2;
-bool SolverState::has_learned_net() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void SolverState::set_has_learned_net() {
- _has_bits_[0] |= 0x00000002u;
-}
-void SolverState::clear_has_learned_net() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void SolverState::clear_learned_net() {
- learned_net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_learned_net();
-}
-const ::std::string& SolverState::learned_net() const {
- // @@protoc_insertion_point(field_get:caffe.SolverState.learned_net)
- return learned_net_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void SolverState::set_learned_net(const ::std::string& value) {
- set_has_learned_net();
- learned_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.SolverState.learned_net)
-}
-void SolverState::set_learned_net(const char* value) {
- set_has_learned_net();
- learned_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.SolverState.learned_net)
-}
-void SolverState::set_learned_net(const char* value, size_t size) {
- set_has_learned_net();
- learned_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.SolverState.learned_net)
-}
-::std::string* SolverState::mutable_learned_net() {
- set_has_learned_net();
- // @@protoc_insertion_point(field_mutable:caffe.SolverState.learned_net)
- return learned_net_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* SolverState::release_learned_net() {
- // @@protoc_insertion_point(field_release:caffe.SolverState.learned_net)
- clear_has_learned_net();
- return learned_net_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void SolverState::set_allocated_learned_net(::std::string* learned_net) {
- if (learned_net != NULL) {
- set_has_learned_net();
- } else {
- clear_has_learned_net();
- }
- learned_net_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), learned_net);
- // @@protoc_insertion_point(field_set_allocated:caffe.SolverState.learned_net)
-}
-
-// repeated .caffe.BlobProto history = 3;
-int SolverState::history_size() const {
- return history_.size();
-}
-void SolverState::clear_history() {
- history_.Clear();
-}
-const ::caffe::BlobProto& SolverState::history(int index) const {
- // @@protoc_insertion_point(field_get:caffe.SolverState.history)
- return history_.Get(index);
-}
-::caffe::BlobProto* SolverState::mutable_history(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.SolverState.history)
- return history_.Mutable(index);
-}
-::caffe::BlobProto* SolverState::add_history() {
- // @@protoc_insertion_point(field_add:caffe.SolverState.history)
- return history_.Add();
-}
-::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
-SolverState::mutable_history() {
- // @@protoc_insertion_point(field_mutable_list:caffe.SolverState.history)
- return &history_;
-}
-const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
-SolverState::history() const {
- // @@protoc_insertion_point(field_list:caffe.SolverState.history)
- return history_;
-}
-
-// optional int32 current_step = 4 [default = 0];
-bool SolverState::has_current_step() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-void SolverState::set_has_current_step() {
- _has_bits_[0] |= 0x00000008u;
-}
-void SolverState::clear_has_current_step() {
- _has_bits_[0] &= ~0x00000008u;
-}
-void SolverState::clear_current_step() {
- current_step_ = 0;
- clear_has_current_step();
-}
-::google::protobuf::int32 SolverState::current_step() const {
- // @@protoc_insertion_point(field_get:caffe.SolverState.current_step)
- return current_step_;
-}
-void SolverState::set_current_step(::google::protobuf::int32 value) {
- set_has_current_step();
- current_step_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverState.current_step)
-}
-
-inline const SolverState* SolverState::internal_default_instance() {
- return &SolverState_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int NetState::kPhaseFieldNumber;
-const int NetState::kLevelFieldNumber;
-const int NetState::kStageFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-NetState::NetState()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.NetState)
-}
-
-void NetState::InitAsDefaultInstance() {
-}
-
-NetState::NetState(const NetState& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.NetState)
-}
-
-void NetState::SharedCtor() {
- _cached_size_ = 0;
- level_ = 0;
- phase_ = 1;
-}
-
-NetState::~NetState() {
- // @@protoc_insertion_point(destructor:caffe.NetState)
- SharedDtor();
-}
-
-void NetState::SharedDtor() {
-}
-
-void NetState::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* NetState::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return NetState_descriptor_;
-}
-
-const NetState& NetState::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<NetState> NetState_default_instance_;
-
-NetState* NetState::New(::google::protobuf::Arena* arena) const {
- NetState* n = new NetState;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void NetState::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.NetState)
- if (_has_bits_[0 / 32] & 3u) {
- phase_ = 1;
- level_ = 0;
- }
- stage_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool NetState::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.NetState)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional .caffe.Phase phase = 1 [default = TEST];
- case 1: {
- if (tag == 8) {
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::Phase_IsValid(value)) {
- set_phase(static_cast< ::caffe::Phase >(value));
- } else {
- mutable_unknown_fields()->AddVarint(1, value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_level;
- break;
- }
-
- // optional int32 level = 2 [default = 0];
- case 2: {
- if (tag == 16) {
- parse_level:
- set_has_level();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &level_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(26)) goto parse_stage;
- break;
- }
-
- // repeated string stage = 3;
- case 3: {
- if (tag == 26) {
- parse_stage:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->add_stage()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->stage(this->stage_size() - 1).data(),
- this->stage(this->stage_size() - 1).length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.NetState.stage");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(26)) goto parse_stage;
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.NetState)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.NetState)
- return false;
-#undef DO_
-}
-
-void NetState::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.NetState)
- // optional .caffe.Phase phase = 1 [default = TEST];
- if (has_phase()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 1, this->phase(), output);
- }
-
- // optional int32 level = 2 [default = 0];
- if (has_level()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->level(), output);
- }
-
- // repeated string stage = 3;
- for (int i = 0; i < this->stage_size(); i++) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->stage(i).data(), this->stage(i).length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.NetState.stage");
- ::google::protobuf::internal::WireFormatLite::WriteString(
- 3, this->stage(i), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.NetState)
-}
-
-::google::protobuf::uint8* NetState::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.NetState)
- // optional .caffe.Phase phase = 1 [default = TEST];
- if (has_phase()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 1, this->phase(), target);
- }
-
- // optional int32 level = 2 [default = 0];
- if (has_level()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->level(), target);
- }
-
- // repeated string stage = 3;
- for (int i = 0; i < this->stage_size(); i++) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->stage(i).data(), this->stage(i).length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.NetState.stage");
- target = ::google::protobuf::internal::WireFormatLite::
- WriteStringToArray(3, this->stage(i), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.NetState)
- return target;
-}
-
-size_t NetState::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.NetState)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 3u) {
- // optional .caffe.Phase phase = 1 [default = TEST];
- if (has_phase()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->phase());
- }
-
- // optional int32 level = 2 [default = 0];
- if (has_level()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->level());
- }
-
- }
- // repeated string stage = 3;
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->stage_size());
- for (int i = 0; i < this->stage_size(); i++) {
- total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
- this->stage(i));
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void NetState::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.NetState)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const NetState* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const NetState>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.NetState)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.NetState)
- UnsafeMergeFrom(*source);
- }
-}
-
-void NetState::MergeFrom(const NetState& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.NetState)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void NetState::UnsafeMergeFrom(const NetState& from) {
- GOOGLE_DCHECK(&from != this);
- stage_.UnsafeMergeFrom(from.stage_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_phase()) {
- set_phase(from.phase());
- }
- if (from.has_level()) {
- set_level(from.level());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void NetState::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.NetState)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void NetState::CopyFrom(const NetState& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.NetState)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool NetState::IsInitialized() const {
-
- return true;
-}
-
-void NetState::Swap(NetState* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void NetState::InternalSwap(NetState* other) {
- std::swap(phase_, other->phase_);
- std::swap(level_, other->level_);
- stage_.UnsafeArenaSwap(&other->stage_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata NetState::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = NetState_descriptor_;
- metadata.reflection = NetState_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// NetState
-
-// optional .caffe.Phase phase = 1 [default = TEST];
-bool NetState::has_phase() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void NetState::set_has_phase() {
- _has_bits_[0] |= 0x00000001u;
-}
-void NetState::clear_has_phase() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void NetState::clear_phase() {
- phase_ = 1;
- clear_has_phase();
-}
-::caffe::Phase NetState::phase() const {
- // @@protoc_insertion_point(field_get:caffe.NetState.phase)
- return static_cast< ::caffe::Phase >(phase_);
-}
-void NetState::set_phase(::caffe::Phase value) {
- assert(::caffe::Phase_IsValid(value));
- set_has_phase();
- phase_ = value;
- // @@protoc_insertion_point(field_set:caffe.NetState.phase)
-}
-
-// optional int32 level = 2 [default = 0];
-bool NetState::has_level() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void NetState::set_has_level() {
- _has_bits_[0] |= 0x00000002u;
-}
-void NetState::clear_has_level() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void NetState::clear_level() {
- level_ = 0;
- clear_has_level();
-}
-::google::protobuf::int32 NetState::level() const {
- // @@protoc_insertion_point(field_get:caffe.NetState.level)
- return level_;
-}
-void NetState::set_level(::google::protobuf::int32 value) {
- set_has_level();
- level_ = value;
- // @@protoc_insertion_point(field_set:caffe.NetState.level)
-}
-
-// repeated string stage = 3;
-int NetState::stage_size() const {
- return stage_.size();
-}
-void NetState::clear_stage() {
- stage_.Clear();
-}
-const ::std::string& NetState::stage(int index) const {
- // @@protoc_insertion_point(field_get:caffe.NetState.stage)
- return stage_.Get(index);
-}
-::std::string* NetState::mutable_stage(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.NetState.stage)
- return stage_.Mutable(index);
-}
-void NetState::set_stage(int index, const ::std::string& value) {
- // @@protoc_insertion_point(field_set:caffe.NetState.stage)
- stage_.Mutable(index)->assign(value);
-}
-void NetState::set_stage(int index, const char* value) {
- stage_.Mutable(index)->assign(value);
- // @@protoc_insertion_point(field_set_char:caffe.NetState.stage)
-}
-void NetState::set_stage(int index, const char* value, size_t size) {
- stage_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:caffe.NetState.stage)
-}
-::std::string* NetState::add_stage() {
- // @@protoc_insertion_point(field_add_mutable:caffe.NetState.stage)
- return stage_.Add();
-}
-void NetState::add_stage(const ::std::string& value) {
- stage_.Add()->assign(value);
- // @@protoc_insertion_point(field_add:caffe.NetState.stage)
-}
-void NetState::add_stage(const char* value) {
- stage_.Add()->assign(value);
- // @@protoc_insertion_point(field_add_char:caffe.NetState.stage)
-}
-void NetState::add_stage(const char* value, size_t size) {
- stage_.Add()->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_add_pointer:caffe.NetState.stage)
-}
-const ::google::protobuf::RepeatedPtrField< ::std::string>&
-NetState::stage() const {
- // @@protoc_insertion_point(field_list:caffe.NetState.stage)
- return stage_;
-}
-::google::protobuf::RepeatedPtrField< ::std::string>*
-NetState::mutable_stage() {
- // @@protoc_insertion_point(field_mutable_list:caffe.NetState.stage)
- return &stage_;
-}
-
-inline const NetState* NetState::internal_default_instance() {
- return &NetState_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int NetStateRule::kPhaseFieldNumber;
-const int NetStateRule::kMinLevelFieldNumber;
-const int NetStateRule::kMaxLevelFieldNumber;
-const int NetStateRule::kStageFieldNumber;
-const int NetStateRule::kNotStageFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-NetStateRule::NetStateRule()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.NetStateRule)
-}
-
-void NetStateRule::InitAsDefaultInstance() {
-}
-
-NetStateRule::NetStateRule(const NetStateRule& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.NetStateRule)
-}
-
-void NetStateRule::SharedCtor() {
- _cached_size_ = 0;
- ::memset(&phase_, 0, reinterpret_cast<char*>(&max_level_) -
- reinterpret_cast<char*>(&phase_) + sizeof(max_level_));
-}
-
-NetStateRule::~NetStateRule() {
- // @@protoc_insertion_point(destructor:caffe.NetStateRule)
- SharedDtor();
-}
-
-void NetStateRule::SharedDtor() {
-}
-
-void NetStateRule::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* NetStateRule::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return NetStateRule_descriptor_;
-}
-
-const NetStateRule& NetStateRule::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<NetStateRule> NetStateRule_default_instance_;
-
-NetStateRule* NetStateRule::New(::google::protobuf::Arena* arena) const {
- NetStateRule* n = new NetStateRule;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void NetStateRule::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.NetStateRule)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(NetStateRule, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<NetStateRule*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- ZR_(phase_, max_level_);
-
-#undef ZR_HELPER_
-#undef ZR_
-
- stage_.Clear();
- not_stage_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool NetStateRule::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.NetStateRule)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional .caffe.Phase phase = 1;
- case 1: {
- if (tag == 8) {
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::Phase_IsValid(value)) {
- set_phase(static_cast< ::caffe::Phase >(value));
- } else {
- mutable_unknown_fields()->AddVarint(1, value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_min_level;
- break;
- }
-
- // optional int32 min_level = 2;
- case 2: {
- if (tag == 16) {
- parse_min_level:
- set_has_min_level();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &min_level_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(24)) goto parse_max_level;
- break;
- }
-
- // optional int32 max_level = 3;
- case 3: {
- if (tag == 24) {
- parse_max_level:
- set_has_max_level();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &max_level_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(34)) goto parse_stage;
- break;
- }
-
- // repeated string stage = 4;
- case 4: {
- if (tag == 34) {
- parse_stage:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->add_stage()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->stage(this->stage_size() - 1).data(),
- this->stage(this->stage_size() - 1).length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.NetStateRule.stage");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(34)) goto parse_stage;
- if (input->ExpectTag(42)) goto parse_not_stage;
- break;
- }
-
- // repeated string not_stage = 5;
- case 5: {
- if (tag == 42) {
- parse_not_stage:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->add_not_stage()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->not_stage(this->not_stage_size() - 1).data(),
- this->not_stage(this->not_stage_size() - 1).length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.NetStateRule.not_stage");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(42)) goto parse_not_stage;
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.NetStateRule)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.NetStateRule)
- return false;
-#undef DO_
-}
-
-void NetStateRule::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.NetStateRule)
- // optional .caffe.Phase phase = 1;
- if (has_phase()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 1, this->phase(), output);
- }
-
- // optional int32 min_level = 2;
- if (has_min_level()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->min_level(), output);
- }
-
- // optional int32 max_level = 3;
- if (has_max_level()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->max_level(), output);
- }
-
- // repeated string stage = 4;
- for (int i = 0; i < this->stage_size(); i++) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->stage(i).data(), this->stage(i).length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.NetStateRule.stage");
- ::google::protobuf::internal::WireFormatLite::WriteString(
- 4, this->stage(i), output);
- }
-
- // repeated string not_stage = 5;
- for (int i = 0; i < this->not_stage_size(); i++) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->not_stage(i).data(), this->not_stage(i).length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.NetStateRule.not_stage");
- ::google::protobuf::internal::WireFormatLite::WriteString(
- 5, this->not_stage(i), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.NetStateRule)
-}
-
-::google::protobuf::uint8* NetStateRule::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.NetStateRule)
- // optional .caffe.Phase phase = 1;
- if (has_phase()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 1, this->phase(), target);
- }
-
- // optional int32 min_level = 2;
- if (has_min_level()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->min_level(), target);
- }
-
- // optional int32 max_level = 3;
- if (has_max_level()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->max_level(), target);
- }
-
- // repeated string stage = 4;
- for (int i = 0; i < this->stage_size(); i++) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->stage(i).data(), this->stage(i).length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.NetStateRule.stage");
- target = ::google::protobuf::internal::WireFormatLite::
- WriteStringToArray(4, this->stage(i), target);
- }
-
- // repeated string not_stage = 5;
- for (int i = 0; i < this->not_stage_size(); i++) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->not_stage(i).data(), this->not_stage(i).length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.NetStateRule.not_stage");
- target = ::google::protobuf::internal::WireFormatLite::
- WriteStringToArray(5, this->not_stage(i), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.NetStateRule)
- return target;
-}
-
-size_t NetStateRule::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.NetStateRule)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 7u) {
- // optional .caffe.Phase phase = 1;
- if (has_phase()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->phase());
- }
-
- // optional int32 min_level = 2;
- if (has_min_level()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->min_level());
- }
-
- // optional int32 max_level = 3;
- if (has_max_level()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->max_level());
- }
-
- }
- // repeated string stage = 4;
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->stage_size());
- for (int i = 0; i < this->stage_size(); i++) {
- total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
- this->stage(i));
- }
-
- // repeated string not_stage = 5;
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->not_stage_size());
- for (int i = 0; i < this->not_stage_size(); i++) {
- total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
- this->not_stage(i));
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void NetStateRule::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.NetStateRule)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const NetStateRule* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const NetStateRule>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.NetStateRule)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.NetStateRule)
- UnsafeMergeFrom(*source);
- }
-}
-
-void NetStateRule::MergeFrom(const NetStateRule& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.NetStateRule)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void NetStateRule::UnsafeMergeFrom(const NetStateRule& from) {
- GOOGLE_DCHECK(&from != this);
- stage_.UnsafeMergeFrom(from.stage_);
- not_stage_.UnsafeMergeFrom(from.not_stage_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_phase()) {
- set_phase(from.phase());
- }
- if (from.has_min_level()) {
- set_min_level(from.min_level());
- }
- if (from.has_max_level()) {
- set_max_level(from.max_level());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void NetStateRule::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.NetStateRule)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void NetStateRule::CopyFrom(const NetStateRule& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.NetStateRule)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool NetStateRule::IsInitialized() const {
-
- return true;
-}
-
-void NetStateRule::Swap(NetStateRule* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void NetStateRule::InternalSwap(NetStateRule* other) {
- std::swap(phase_, other->phase_);
- std::swap(min_level_, other->min_level_);
- std::swap(max_level_, other->max_level_);
- stage_.UnsafeArenaSwap(&other->stage_);
- not_stage_.UnsafeArenaSwap(&other->not_stage_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata NetStateRule::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = NetStateRule_descriptor_;
- metadata.reflection = NetStateRule_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// NetStateRule
-
-// optional .caffe.Phase phase = 1;
-bool NetStateRule::has_phase() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void NetStateRule::set_has_phase() {
- _has_bits_[0] |= 0x00000001u;
-}
-void NetStateRule::clear_has_phase() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void NetStateRule::clear_phase() {
- phase_ = 0;
- clear_has_phase();
-}
-::caffe::Phase NetStateRule::phase() const {
- // @@protoc_insertion_point(field_get:caffe.NetStateRule.phase)
- return static_cast< ::caffe::Phase >(phase_);
-}
-void NetStateRule::set_phase(::caffe::Phase value) {
- assert(::caffe::Phase_IsValid(value));
- set_has_phase();
- phase_ = value;
- // @@protoc_insertion_point(field_set:caffe.NetStateRule.phase)
-}
-
-// optional int32 min_level = 2;
-bool NetStateRule::has_min_level() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void NetStateRule::set_has_min_level() {
- _has_bits_[0] |= 0x00000002u;
-}
-void NetStateRule::clear_has_min_level() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void NetStateRule::clear_min_level() {
- min_level_ = 0;
- clear_has_min_level();
-}
-::google::protobuf::int32 NetStateRule::min_level() const {
- // @@protoc_insertion_point(field_get:caffe.NetStateRule.min_level)
- return min_level_;
-}
-void NetStateRule::set_min_level(::google::protobuf::int32 value) {
- set_has_min_level();
- min_level_ = value;
- // @@protoc_insertion_point(field_set:caffe.NetStateRule.min_level)
-}
-
-// optional int32 max_level = 3;
-bool NetStateRule::has_max_level() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void NetStateRule::set_has_max_level() {
- _has_bits_[0] |= 0x00000004u;
-}
-void NetStateRule::clear_has_max_level() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void NetStateRule::clear_max_level() {
- max_level_ = 0;
- clear_has_max_level();
-}
-::google::protobuf::int32 NetStateRule::max_level() const {
- // @@protoc_insertion_point(field_get:caffe.NetStateRule.max_level)
- return max_level_;
-}
-void NetStateRule::set_max_level(::google::protobuf::int32 value) {
- set_has_max_level();
- max_level_ = value;
- // @@protoc_insertion_point(field_set:caffe.NetStateRule.max_level)
-}
-
-// repeated string stage = 4;
-int NetStateRule::stage_size() const {
- return stage_.size();
-}
-void NetStateRule::clear_stage() {
- stage_.Clear();
-}
-const ::std::string& NetStateRule::stage(int index) const {
- // @@protoc_insertion_point(field_get:caffe.NetStateRule.stage)
- return stage_.Get(index);
-}
-::std::string* NetStateRule::mutable_stage(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.NetStateRule.stage)
- return stage_.Mutable(index);
-}
-void NetStateRule::set_stage(int index, const ::std::string& value) {
- // @@protoc_insertion_point(field_set:caffe.NetStateRule.stage)
- stage_.Mutable(index)->assign(value);
-}
-void NetStateRule::set_stage(int index, const char* value) {
- stage_.Mutable(index)->assign(value);
- // @@protoc_insertion_point(field_set_char:caffe.NetStateRule.stage)
-}
-void NetStateRule::set_stage(int index, const char* value, size_t size) {
- stage_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:caffe.NetStateRule.stage)
-}
-::std::string* NetStateRule::add_stage() {
- // @@protoc_insertion_point(field_add_mutable:caffe.NetStateRule.stage)
- return stage_.Add();
-}
-void NetStateRule::add_stage(const ::std::string& value) {
- stage_.Add()->assign(value);
- // @@protoc_insertion_point(field_add:caffe.NetStateRule.stage)
-}
-void NetStateRule::add_stage(const char* value) {
- stage_.Add()->assign(value);
- // @@protoc_insertion_point(field_add_char:caffe.NetStateRule.stage)
-}
-void NetStateRule::add_stage(const char* value, size_t size) {
- stage_.Add()->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_add_pointer:caffe.NetStateRule.stage)
-}
-const ::google::protobuf::RepeatedPtrField< ::std::string>&
-NetStateRule::stage() const {
- // @@protoc_insertion_point(field_list:caffe.NetStateRule.stage)
- return stage_;
-}
-::google::protobuf::RepeatedPtrField< ::std::string>*
-NetStateRule::mutable_stage() {
- // @@protoc_insertion_point(field_mutable_list:caffe.NetStateRule.stage)
- return &stage_;
-}
-
-// repeated string not_stage = 5;
-int NetStateRule::not_stage_size() const {
- return not_stage_.size();
-}
-void NetStateRule::clear_not_stage() {
- not_stage_.Clear();
-}
-const ::std::string& NetStateRule::not_stage(int index) const {
- // @@protoc_insertion_point(field_get:caffe.NetStateRule.not_stage)
- return not_stage_.Get(index);
-}
-::std::string* NetStateRule::mutable_not_stage(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.NetStateRule.not_stage)
- return not_stage_.Mutable(index);
-}
-void NetStateRule::set_not_stage(int index, const ::std::string& value) {
- // @@protoc_insertion_point(field_set:caffe.NetStateRule.not_stage)
- not_stage_.Mutable(index)->assign(value);
-}
-void NetStateRule::set_not_stage(int index, const char* value) {
- not_stage_.Mutable(index)->assign(value);
- // @@protoc_insertion_point(field_set_char:caffe.NetStateRule.not_stage)
-}
-void NetStateRule::set_not_stage(int index, const char* value, size_t size) {
- not_stage_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:caffe.NetStateRule.not_stage)
-}
-::std::string* NetStateRule::add_not_stage() {
- // @@protoc_insertion_point(field_add_mutable:caffe.NetStateRule.not_stage)
- return not_stage_.Add();
-}
-void NetStateRule::add_not_stage(const ::std::string& value) {
- not_stage_.Add()->assign(value);
- // @@protoc_insertion_point(field_add:caffe.NetStateRule.not_stage)
-}
-void NetStateRule::add_not_stage(const char* value) {
- not_stage_.Add()->assign(value);
- // @@protoc_insertion_point(field_add_char:caffe.NetStateRule.not_stage)
-}
-void NetStateRule::add_not_stage(const char* value, size_t size) {
- not_stage_.Add()->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_add_pointer:caffe.NetStateRule.not_stage)
-}
-const ::google::protobuf::RepeatedPtrField< ::std::string>&
-NetStateRule::not_stage() const {
- // @@protoc_insertion_point(field_list:caffe.NetStateRule.not_stage)
- return not_stage_;
-}
-::google::protobuf::RepeatedPtrField< ::std::string>*
-NetStateRule::mutable_not_stage() {
- // @@protoc_insertion_point(field_mutable_list:caffe.NetStateRule.not_stage)
- return ¬_stage_;
-}
-
-inline const NetStateRule* NetStateRule::internal_default_instance() {
- return &NetStateRule_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-const ::google::protobuf::EnumDescriptor* ParamSpec_DimCheckMode_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return ParamSpec_DimCheckMode_descriptor_;
-}
-bool ParamSpec_DimCheckMode_IsValid(int value) {
- switch (value) {
- case 0:
- case 1:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const ParamSpec_DimCheckMode ParamSpec::STRICT;
-const ParamSpec_DimCheckMode ParamSpec::PERMISSIVE;
-const ParamSpec_DimCheckMode ParamSpec::DimCheckMode_MIN;
-const ParamSpec_DimCheckMode ParamSpec::DimCheckMode_MAX;
-const int ParamSpec::DimCheckMode_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int ParamSpec::kNameFieldNumber;
-const int ParamSpec::kShareModeFieldNumber;
-const int ParamSpec::kLrMultFieldNumber;
-const int ParamSpec::kDecayMultFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-ParamSpec::ParamSpec()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.ParamSpec)
-}
-
-void ParamSpec::InitAsDefaultInstance() {
-}
-
-ParamSpec::ParamSpec(const ParamSpec& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.ParamSpec)
-}
-
-void ParamSpec::SharedCtor() {
- _cached_size_ = 0;
- name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- share_mode_ = 0;
- lr_mult_ = 1;
- decay_mult_ = 1;
-}
-
-ParamSpec::~ParamSpec() {
- // @@protoc_insertion_point(destructor:caffe.ParamSpec)
- SharedDtor();
-}
-
-void ParamSpec::SharedDtor() {
- name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-
-void ParamSpec::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* ParamSpec::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return ParamSpec_descriptor_;
-}
-
-const ParamSpec& ParamSpec::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<ParamSpec> ParamSpec_default_instance_;
-
-ParamSpec* ParamSpec::New(::google::protobuf::Arena* arena) const {
- ParamSpec* n = new ParamSpec;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void ParamSpec::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.ParamSpec)
- if (_has_bits_[0 / 32] & 15u) {
- if (has_name()) {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- share_mode_ = 0;
- lr_mult_ = 1;
- decay_mult_ = 1;
- }
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool ParamSpec::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.ParamSpec)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional string name = 1;
- case 1: {
- if (tag == 10) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_name()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->name().data(), this->name().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.ParamSpec.name");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_share_mode;
- break;
- }
-
- // optional .caffe.ParamSpec.DimCheckMode share_mode = 2;
- case 2: {
- if (tag == 16) {
- parse_share_mode:
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::ParamSpec_DimCheckMode_IsValid(value)) {
- set_share_mode(static_cast< ::caffe::ParamSpec_DimCheckMode >(value));
- } else {
- mutable_unknown_fields()->AddVarint(2, value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(29)) goto parse_lr_mult;
- break;
- }
-
- // optional float lr_mult = 3 [default = 1];
- case 3: {
- if (tag == 29) {
- parse_lr_mult:
- set_has_lr_mult();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &lr_mult_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(37)) goto parse_decay_mult;
- break;
- }
-
- // optional float decay_mult = 4 [default = 1];
- case 4: {
- if (tag == 37) {
- parse_decay_mult:
- set_has_decay_mult();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &decay_mult_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.ParamSpec)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.ParamSpec)
- return false;
-#undef DO_
-}
-
-void ParamSpec::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.ParamSpec)
- // optional string name = 1;
- if (has_name()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->name().data(), this->name().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.ParamSpec.name");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 1, this->name(), output);
- }
-
- // optional .caffe.ParamSpec.DimCheckMode share_mode = 2;
- if (has_share_mode()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 2, this->share_mode(), output);
- }
-
- // optional float lr_mult = 3 [default = 1];
- if (has_lr_mult()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->lr_mult(), output);
- }
-
- // optional float decay_mult = 4 [default = 1];
- if (has_decay_mult()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(4, this->decay_mult(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.ParamSpec)
-}
-
-::google::protobuf::uint8* ParamSpec::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.ParamSpec)
- // optional string name = 1;
- if (has_name()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->name().data(), this->name().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.ParamSpec.name");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 1, this->name(), target);
- }
-
- // optional .caffe.ParamSpec.DimCheckMode share_mode = 2;
- if (has_share_mode()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 2, this->share_mode(), target);
- }
-
- // optional float lr_mult = 3 [default = 1];
- if (has_lr_mult()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->lr_mult(), target);
- }
-
- // optional float decay_mult = 4 [default = 1];
- if (has_decay_mult()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(4, this->decay_mult(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.ParamSpec)
- return target;
-}
-
-size_t ParamSpec::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.ParamSpec)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 15u) {
- // optional string name = 1;
- if (has_name()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->name());
- }
-
- // optional .caffe.ParamSpec.DimCheckMode share_mode = 2;
- if (has_share_mode()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->share_mode());
- }
-
- // optional float lr_mult = 3 [default = 1];
- if (has_lr_mult()) {
- total_size += 1 + 4;
- }
-
- // optional float decay_mult = 4 [default = 1];
- if (has_decay_mult()) {
- total_size += 1 + 4;
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void ParamSpec::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.ParamSpec)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const ParamSpec* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const ParamSpec>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ParamSpec)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ParamSpec)
- UnsafeMergeFrom(*source);
- }
-}
-
-void ParamSpec::MergeFrom(const ParamSpec& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ParamSpec)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void ParamSpec::UnsafeMergeFrom(const ParamSpec& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_name()) {
- set_has_name();
- name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
- }
- if (from.has_share_mode()) {
- set_share_mode(from.share_mode());
- }
- if (from.has_lr_mult()) {
- set_lr_mult(from.lr_mult());
- }
- if (from.has_decay_mult()) {
- set_decay_mult(from.decay_mult());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void ParamSpec::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.ParamSpec)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void ParamSpec::CopyFrom(const ParamSpec& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ParamSpec)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool ParamSpec::IsInitialized() const {
-
- return true;
-}
-
-void ParamSpec::Swap(ParamSpec* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void ParamSpec::InternalSwap(ParamSpec* other) {
- name_.Swap(&other->name_);
- std::swap(share_mode_, other->share_mode_);
- std::swap(lr_mult_, other->lr_mult_);
- std::swap(decay_mult_, other->decay_mult_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata ParamSpec::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = ParamSpec_descriptor_;
- metadata.reflection = ParamSpec_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// ParamSpec
-
-// optional string name = 1;
-bool ParamSpec::has_name() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void ParamSpec::set_has_name() {
- _has_bits_[0] |= 0x00000001u;
-}
-void ParamSpec::clear_has_name() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void ParamSpec::clear_name() {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_name();
-}
-const ::std::string& ParamSpec::name() const {
- // @@protoc_insertion_point(field_get:caffe.ParamSpec.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void ParamSpec::set_name(const ::std::string& value) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.ParamSpec.name)
-}
-void ParamSpec::set_name(const char* value) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.ParamSpec.name)
-}
-void ParamSpec::set_name(const char* value, size_t size) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.ParamSpec.name)
-}
-::std::string* ParamSpec::mutable_name() {
- set_has_name();
- // @@protoc_insertion_point(field_mutable:caffe.ParamSpec.name)
- return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* ParamSpec::release_name() {
- // @@protoc_insertion_point(field_release:caffe.ParamSpec.name)
- clear_has_name();
- return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void ParamSpec::set_allocated_name(::std::string* name) {
- if (name != NULL) {
- set_has_name();
- } else {
- clear_has_name();
- }
- name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
- // @@protoc_insertion_point(field_set_allocated:caffe.ParamSpec.name)
-}
-
-// optional .caffe.ParamSpec.DimCheckMode share_mode = 2;
-bool ParamSpec::has_share_mode() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void ParamSpec::set_has_share_mode() {
- _has_bits_[0] |= 0x00000002u;
-}
-void ParamSpec::clear_has_share_mode() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void ParamSpec::clear_share_mode() {
- share_mode_ = 0;
- clear_has_share_mode();
-}
-::caffe::ParamSpec_DimCheckMode ParamSpec::share_mode() const {
- // @@protoc_insertion_point(field_get:caffe.ParamSpec.share_mode)
- return static_cast< ::caffe::ParamSpec_DimCheckMode >(share_mode_);
-}
-void ParamSpec::set_share_mode(::caffe::ParamSpec_DimCheckMode value) {
- assert(::caffe::ParamSpec_DimCheckMode_IsValid(value));
- set_has_share_mode();
- share_mode_ = value;
- // @@protoc_insertion_point(field_set:caffe.ParamSpec.share_mode)
-}
-
-// optional float lr_mult = 3 [default = 1];
-bool ParamSpec::has_lr_mult() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void ParamSpec::set_has_lr_mult() {
- _has_bits_[0] |= 0x00000004u;
-}
-void ParamSpec::clear_has_lr_mult() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void ParamSpec::clear_lr_mult() {
- lr_mult_ = 1;
- clear_has_lr_mult();
-}
-float ParamSpec::lr_mult() const {
- // @@protoc_insertion_point(field_get:caffe.ParamSpec.lr_mult)
- return lr_mult_;
-}
-void ParamSpec::set_lr_mult(float value) {
- set_has_lr_mult();
- lr_mult_ = value;
- // @@protoc_insertion_point(field_set:caffe.ParamSpec.lr_mult)
-}
-
-// optional float decay_mult = 4 [default = 1];
-bool ParamSpec::has_decay_mult() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-void ParamSpec::set_has_decay_mult() {
- _has_bits_[0] |= 0x00000008u;
-}
-void ParamSpec::clear_has_decay_mult() {
- _has_bits_[0] &= ~0x00000008u;
-}
-void ParamSpec::clear_decay_mult() {
- decay_mult_ = 1;
- clear_has_decay_mult();
-}
-float ParamSpec::decay_mult() const {
- // @@protoc_insertion_point(field_get:caffe.ParamSpec.decay_mult)
- return decay_mult_;
-}
-void ParamSpec::set_decay_mult(float value) {
- set_has_decay_mult();
- decay_mult_ = value;
- // @@protoc_insertion_point(field_set:caffe.ParamSpec.decay_mult)
-}
-
-inline const ParamSpec* ParamSpec::internal_default_instance() {
- return &ParamSpec_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int LayerParameter::kNameFieldNumber;
-const int LayerParameter::kTypeFieldNumber;
-const int LayerParameter::kBottomFieldNumber;
-const int LayerParameter::kTopFieldNumber;
-const int LayerParameter::kPhaseFieldNumber;
-const int LayerParameter::kLossWeightFieldNumber;
-const int LayerParameter::kParamFieldNumber;
-const int LayerParameter::kBlobsFieldNumber;
-const int LayerParameter::kPropagateDownFieldNumber;
-const int LayerParameter::kIncludeFieldNumber;
-const int LayerParameter::kExcludeFieldNumber;
-const int LayerParameter::kTransformParamFieldNumber;
-const int LayerParameter::kLossParamFieldNumber;
-const int LayerParameter::kAccuracyParamFieldNumber;
-const int LayerParameter::kArgmaxParamFieldNumber;
-const int LayerParameter::kConcatParamFieldNumber;
-const int LayerParameter::kContrastiveLossParamFieldNumber;
-const int LayerParameter::kConvolutionParamFieldNumber;
-const int LayerParameter::kCropParamFieldNumber;
-const int LayerParameter::kDataParamFieldNumber;
-const int LayerParameter::kDetectionOutputParamFieldNumber;
-const int LayerParameter::kDropoutParamFieldNumber;
-const int LayerParameter::kDummyDataParamFieldNumber;
-const int LayerParameter::kEltwiseParamFieldNumber;
-const int LayerParameter::kExpParamFieldNumber;
-const int LayerParameter::kFlattenParamFieldNumber;
-const int LayerParameter::kHdf5DataParamFieldNumber;
-const int LayerParameter::kHdf5OutputParamFieldNumber;
-const int LayerParameter::kHingeLossParamFieldNumber;
-const int LayerParameter::kImageDataParamFieldNumber;
-const int LayerParameter::kInfogainLossParamFieldNumber;
-const int LayerParameter::kInnerProductParamFieldNumber;
-const int LayerParameter::kLogParamFieldNumber;
-const int LayerParameter::kLrnParamFieldNumber;
-const int LayerParameter::kMemoryDataParamFieldNumber;
-const int LayerParameter::kMvnParamFieldNumber;
-const int LayerParameter::kNormalizeBboxParamFieldNumber;
-const int LayerParameter::kPermuteParamFieldNumber;
-const int LayerParameter::kPoolingParamFieldNumber;
-const int LayerParameter::kPowerParamFieldNumber;
-const int LayerParameter::kPreluParamFieldNumber;
-const int LayerParameter::kPriorBoxParamFieldNumber;
-const int LayerParameter::kPythonParamFieldNumber;
-const int LayerParameter::kReductionParamFieldNumber;
-const int LayerParameter::kReluParamFieldNumber;
-const int LayerParameter::kReshapeParamFieldNumber;
-const int LayerParameter::kSigmoidParamFieldNumber;
-const int LayerParameter::kSliceParamFieldNumber;
-const int LayerParameter::kSoftmaxParamFieldNumber;
-const int LayerParameter::kSppParamFieldNumber;
-const int LayerParameter::kTanhParamFieldNumber;
-const int LayerParameter::kThresholdParamFieldNumber;
-const int LayerParameter::kWindowDataParamFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-LayerParameter::LayerParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.LayerParameter)
-}
-
-void LayerParameter::InitAsDefaultInstance() {
- transform_param_ = const_cast< ::caffe::TransformationParameter*>(
- ::caffe::TransformationParameter::internal_default_instance());
- loss_param_ = const_cast< ::caffe::LossParameter*>(
- ::caffe::LossParameter::internal_default_instance());
- accuracy_param_ = const_cast< ::caffe::AccuracyParameter*>(
- ::caffe::AccuracyParameter::internal_default_instance());
- argmax_param_ = const_cast< ::caffe::ArgMaxParameter*>(
- ::caffe::ArgMaxParameter::internal_default_instance());
- concat_param_ = const_cast< ::caffe::ConcatParameter*>(
- ::caffe::ConcatParameter::internal_default_instance());
- contrastive_loss_param_ = const_cast< ::caffe::ContrastiveLossParameter*>(
- ::caffe::ContrastiveLossParameter::internal_default_instance());
- convolution_param_ = const_cast< ::caffe::ConvolutionParameter*>(
- ::caffe::ConvolutionParameter::internal_default_instance());
- crop_param_ = const_cast< ::caffe::CropParameter*>(
- ::caffe::CropParameter::internal_default_instance());
- data_param_ = const_cast< ::caffe::DataParameter*>(
- ::caffe::DataParameter::internal_default_instance());
- detection_output_param_ = const_cast< ::caffe::DetectionOutputParameter*>(
- ::caffe::DetectionOutputParameter::internal_default_instance());
- dropout_param_ = const_cast< ::caffe::DropoutParameter*>(
- ::caffe::DropoutParameter::internal_default_instance());
- dummy_data_param_ = const_cast< ::caffe::DummyDataParameter*>(
- ::caffe::DummyDataParameter::internal_default_instance());
- eltwise_param_ = const_cast< ::caffe::EltwiseParameter*>(
- ::caffe::EltwiseParameter::internal_default_instance());
- exp_param_ = const_cast< ::caffe::ExpParameter*>(
- ::caffe::ExpParameter::internal_default_instance());
- flatten_param_ = const_cast< ::caffe::FlattenParameter*>(
- ::caffe::FlattenParameter::internal_default_instance());
- hdf5_data_param_ = const_cast< ::caffe::HDF5DataParameter*>(
- ::caffe::HDF5DataParameter::internal_default_instance());
- hdf5_output_param_ = const_cast< ::caffe::HDF5OutputParameter*>(
- ::caffe::HDF5OutputParameter::internal_default_instance());
- hinge_loss_param_ = const_cast< ::caffe::HingeLossParameter*>(
- ::caffe::HingeLossParameter::internal_default_instance());
- image_data_param_ = const_cast< ::caffe::ImageDataParameter*>(
- ::caffe::ImageDataParameter::internal_default_instance());
- infogain_loss_param_ = const_cast< ::caffe::InfogainLossParameter*>(
- ::caffe::InfogainLossParameter::internal_default_instance());
- inner_product_param_ = const_cast< ::caffe::InnerProductParameter*>(
- ::caffe::InnerProductParameter::internal_default_instance());
- log_param_ = const_cast< ::caffe::LogParameter*>(
- ::caffe::LogParameter::internal_default_instance());
- lrn_param_ = const_cast< ::caffe::LRNParameter*>(
- ::caffe::LRNParameter::internal_default_instance());
- memory_data_param_ = const_cast< ::caffe::MemoryDataParameter*>(
- ::caffe::MemoryDataParameter::internal_default_instance());
- mvn_param_ = const_cast< ::caffe::MVNParameter*>(
- ::caffe::MVNParameter::internal_default_instance());
- normalize_bbox_param_ = const_cast< ::caffe::NormalizeBBoxParameter*>(
- ::caffe::NormalizeBBoxParameter::internal_default_instance());
- permute_param_ = const_cast< ::caffe::PermuteParameter*>(
- ::caffe::PermuteParameter::internal_default_instance());
- pooling_param_ = const_cast< ::caffe::PoolingParameter*>(
- ::caffe::PoolingParameter::internal_default_instance());
- power_param_ = const_cast< ::caffe::PowerParameter*>(
- ::caffe::PowerParameter::internal_default_instance());
- prelu_param_ = const_cast< ::caffe::PReLUParameter*>(
- ::caffe::PReLUParameter::internal_default_instance());
- prior_box_param_ = const_cast< ::caffe::PriorBoxParameter*>(
- ::caffe::PriorBoxParameter::internal_default_instance());
- python_param_ = const_cast< ::caffe::PythonParameter*>(
- ::caffe::PythonParameter::internal_default_instance());
- reduction_param_ = const_cast< ::caffe::ReductionParameter*>(
- ::caffe::ReductionParameter::internal_default_instance());
- relu_param_ = const_cast< ::caffe::ReLUParameter*>(
- ::caffe::ReLUParameter::internal_default_instance());
- reshape_param_ = const_cast< ::caffe::ReshapeParameter*>(
- ::caffe::ReshapeParameter::internal_default_instance());
- sigmoid_param_ = const_cast< ::caffe::SigmoidParameter*>(
- ::caffe::SigmoidParameter::internal_default_instance());
- slice_param_ = const_cast< ::caffe::SliceParameter*>(
- ::caffe::SliceParameter::internal_default_instance());
- softmax_param_ = const_cast< ::caffe::SoftmaxParameter*>(
- ::caffe::SoftmaxParameter::internal_default_instance());
- spp_param_ = const_cast< ::caffe::SPPParameter*>(
- ::caffe::SPPParameter::internal_default_instance());
- tanh_param_ = const_cast< ::caffe::TanHParameter*>(
- ::caffe::TanHParameter::internal_default_instance());
- threshold_param_ = const_cast< ::caffe::ThresholdParameter*>(
- ::caffe::ThresholdParameter::internal_default_instance());
- window_data_param_ = const_cast< ::caffe::WindowDataParameter*>(
- ::caffe::WindowDataParameter::internal_default_instance());
-}
-
-LayerParameter::LayerParameter(const LayerParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.LayerParameter)
-}
-
-void LayerParameter::SharedCtor() {
- name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- transform_param_ = NULL;
- loss_param_ = NULL;
- accuracy_param_ = NULL;
- argmax_param_ = NULL;
- concat_param_ = NULL;
- contrastive_loss_param_ = NULL;
- convolution_param_ = NULL;
- crop_param_ = NULL;
- data_param_ = NULL;
- detection_output_param_ = NULL;
- dropout_param_ = NULL;
- dummy_data_param_ = NULL;
- eltwise_param_ = NULL;
- exp_param_ = NULL;
- flatten_param_ = NULL;
- hdf5_data_param_ = NULL;
- hdf5_output_param_ = NULL;
- hinge_loss_param_ = NULL;
- image_data_param_ = NULL;
- infogain_loss_param_ = NULL;
- inner_product_param_ = NULL;
- log_param_ = NULL;
- lrn_param_ = NULL;
- memory_data_param_ = NULL;
- mvn_param_ = NULL;
- normalize_bbox_param_ = NULL;
- permute_param_ = NULL;
- pooling_param_ = NULL;
- power_param_ = NULL;
- prelu_param_ = NULL;
- prior_box_param_ = NULL;
- python_param_ = NULL;
- reduction_param_ = NULL;
- relu_param_ = NULL;
- reshape_param_ = NULL;
- sigmoid_param_ = NULL;
- slice_param_ = NULL;
- softmax_param_ = NULL;
- spp_param_ = NULL;
- tanh_param_ = NULL;
- threshold_param_ = NULL;
- window_data_param_ = NULL;
- phase_ = 0;
- _cached_size_ = 0;
-}
-
-LayerParameter::~LayerParameter() {
- // @@protoc_insertion_point(destructor:caffe.LayerParameter)
- SharedDtor();
-}
-
-void LayerParameter::SharedDtor() {
- name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- type_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- if (this != &LayerParameter_default_instance_.get()) {
- delete transform_param_;
- delete loss_param_;
- delete accuracy_param_;
- delete argmax_param_;
- delete concat_param_;
- delete contrastive_loss_param_;
- delete convolution_param_;
- delete crop_param_;
- delete data_param_;
- delete detection_output_param_;
- delete dropout_param_;
- delete dummy_data_param_;
- delete eltwise_param_;
- delete exp_param_;
- delete flatten_param_;
- delete hdf5_data_param_;
- delete hdf5_output_param_;
- delete hinge_loss_param_;
- delete image_data_param_;
- delete infogain_loss_param_;
- delete inner_product_param_;
- delete log_param_;
- delete lrn_param_;
- delete memory_data_param_;
- delete mvn_param_;
- delete normalize_bbox_param_;
- delete permute_param_;
- delete pooling_param_;
- delete power_param_;
- delete prelu_param_;
- delete prior_box_param_;
- delete python_param_;
- delete reduction_param_;
- delete relu_param_;
- delete reshape_param_;
- delete sigmoid_param_;
- delete slice_param_;
- delete softmax_param_;
- delete spp_param_;
- delete tanh_param_;
- delete threshold_param_;
- delete window_data_param_;
- }
-}
-
-void LayerParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* LayerParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return LayerParameter_descriptor_;
-}
-
-const LayerParameter& LayerParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<LayerParameter> LayerParameter_default_instance_;
-
-LayerParameter* LayerParameter::New(::google::protobuf::Arena* arena) const {
- LayerParameter* n = new LayerParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void LayerParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.LayerParameter)
- if (_has_bits_[0 / 32] & 19u) {
- if (has_name()) {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- if (has_type()) {
- type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- phase_ = 0;
- }
- if (_has_bits_[8 / 32] & 63488u) {
- if (has_transform_param()) {
- if (transform_param_ != NULL) transform_param_->::caffe::TransformationParameter::Clear();
- }
- if (has_loss_param()) {
- if (loss_param_ != NULL) loss_param_->::caffe::LossParameter::Clear();
- }
- if (has_accuracy_param()) {
- if (accuracy_param_ != NULL) accuracy_param_->::caffe::AccuracyParameter::Clear();
- }
- if (has_argmax_param()) {
- if (argmax_param_ != NULL) argmax_param_->::caffe::ArgMaxParameter::Clear();
- }
- if (has_concat_param()) {
- if (concat_param_ != NULL) concat_param_->::caffe::ConcatParameter::Clear();
- }
- }
- if (_has_bits_[16 / 32] & 16711680u) {
- if (has_contrastive_loss_param()) {
- if (contrastive_loss_param_ != NULL) contrastive_loss_param_->::caffe::ContrastiveLossParameter::Clear();
- }
- if (has_convolution_param()) {
- if (convolution_param_ != NULL) convolution_param_->::caffe::ConvolutionParameter::Clear();
- }
- if (has_crop_param()) {
- if (crop_param_ != NULL) crop_param_->::caffe::CropParameter::Clear();
- }
- if (has_data_param()) {
- if (data_param_ != NULL) data_param_->::caffe::DataParameter::Clear();
- }
- if (has_detection_output_param()) {
- if (detection_output_param_ != NULL) detection_output_param_->::caffe::DetectionOutputParameter::Clear();
- }
- if (has_dropout_param()) {
- if (dropout_param_ != NULL) dropout_param_->::caffe::DropoutParameter::Clear();
- }
- if (has_dummy_data_param()) {
- if (dummy_data_param_ != NULL) dummy_data_param_->::caffe::DummyDataParameter::Clear();
- }
- if (has_eltwise_param()) {
- if (eltwise_param_ != NULL) eltwise_param_->::caffe::EltwiseParameter::Clear();
- }
- }
- if (_has_bits_[24 / 32] & 4278190080u) {
- if (has_exp_param()) {
- if (exp_param_ != NULL) exp_param_->::caffe::ExpParameter::Clear();
- }
- if (has_flatten_param()) {
- if (flatten_param_ != NULL) flatten_param_->::caffe::FlattenParameter::Clear();
- }
- if (has_hdf5_data_param()) {
- if (hdf5_data_param_ != NULL) hdf5_data_param_->::caffe::HDF5DataParameter::Clear();
- }
- if (has_hdf5_output_param()) {
- if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear();
- }
- if (has_hinge_loss_param()) {
- if (hinge_loss_param_ != NULL) hinge_loss_param_->::caffe::HingeLossParameter::Clear();
- }
- if (has_image_data_param()) {
- if (image_data_param_ != NULL) image_data_param_->::caffe::ImageDataParameter::Clear();
- }
- if (has_infogain_loss_param()) {
- if (infogain_loss_param_ != NULL) infogain_loss_param_->::caffe::InfogainLossParameter::Clear();
- }
- if (has_inner_product_param()) {
- if (inner_product_param_ != NULL) inner_product_param_->::caffe::InnerProductParameter::Clear();
- }
- }
- if (_has_bits_[32 / 32] & 255u) {
- if (has_log_param()) {
- if (log_param_ != NULL) log_param_->::caffe::LogParameter::Clear();
- }
- if (has_lrn_param()) {
- if (lrn_param_ != NULL) lrn_param_->::caffe::LRNParameter::Clear();
- }
- if (has_memory_data_param()) {
- if (memory_data_param_ != NULL) memory_data_param_->::caffe::MemoryDataParameter::Clear();
- }
- if (has_mvn_param()) {
- if (mvn_param_ != NULL) mvn_param_->::caffe::MVNParameter::Clear();
- }
- if (has_normalize_bbox_param()) {
- if (normalize_bbox_param_ != NULL) normalize_bbox_param_->::caffe::NormalizeBBoxParameter::Clear();
- }
- if (has_permute_param()) {
- if (permute_param_ != NULL) permute_param_->::caffe::PermuteParameter::Clear();
- }
- if (has_pooling_param()) {
- if (pooling_param_ != NULL) pooling_param_->::caffe::PoolingParameter::Clear();
- }
- if (has_power_param()) {
- if (power_param_ != NULL) power_param_->::caffe::PowerParameter::Clear();
- }
- }
- if (_has_bits_[40 / 32] & 65280u) {
- if (has_prelu_param()) {
- if (prelu_param_ != NULL) prelu_param_->::caffe::PReLUParameter::Clear();
- }
- if (has_prior_box_param()) {
- if (prior_box_param_ != NULL) prior_box_param_->::caffe::PriorBoxParameter::Clear();
- }
- if (has_python_param()) {
- if (python_param_ != NULL) python_param_->::caffe::PythonParameter::Clear();
- }
- if (has_reduction_param()) {
- if (reduction_param_ != NULL) reduction_param_->::caffe::ReductionParameter::Clear();
- }
- if (has_relu_param()) {
- if (relu_param_ != NULL) relu_param_->::caffe::ReLUParameter::Clear();
- }
- if (has_reshape_param()) {
- if (reshape_param_ != NULL) reshape_param_->::caffe::ReshapeParameter::Clear();
- }
- if (has_sigmoid_param()) {
- if (sigmoid_param_ != NULL) sigmoid_param_->::caffe::SigmoidParameter::Clear();
- }
- if (has_slice_param()) {
- if (slice_param_ != NULL) slice_param_->::caffe::SliceParameter::Clear();
- }
- }
- if (_has_bits_[48 / 32] & 2031616u) {
- if (has_softmax_param()) {
- if (softmax_param_ != NULL) softmax_param_->::caffe::SoftmaxParameter::Clear();
- }
- if (has_spp_param()) {
- if (spp_param_ != NULL) spp_param_->::caffe::SPPParameter::Clear();
- }
- if (has_tanh_param()) {
- if (tanh_param_ != NULL) tanh_param_->::caffe::TanHParameter::Clear();
- }
- if (has_threshold_param()) {
- if (threshold_param_ != NULL) threshold_param_->::caffe::ThresholdParameter::Clear();
- }
- if (has_window_data_param()) {
- if (window_data_param_ != NULL) window_data_param_->::caffe::WindowDataParameter::Clear();
- }
- }
- bottom_.Clear();
- top_.Clear();
- loss_weight_.Clear();
- param_.Clear();
- blobs_.Clear();
- propagate_down_.Clear();
- include_.Clear();
- exclude_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool LayerParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.LayerParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional string name = 1;
- case 1: {
- if (tag == 10) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_name()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->name().data(), this->name().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.LayerParameter.name");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(18)) goto parse_type;
- break;
- }
-
- // optional string type = 2;
- case 2: {
- if (tag == 18) {
- parse_type:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_type()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->type().data(), this->type().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.LayerParameter.type");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(26)) goto parse_bottom;
- break;
- }
-
- // repeated string bottom = 3;
- case 3: {
- if (tag == 26) {
- parse_bottom:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->add_bottom()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->bottom(this->bottom_size() - 1).data(),
- this->bottom(this->bottom_size() - 1).length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.LayerParameter.bottom");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(26)) goto parse_bottom;
- if (input->ExpectTag(34)) goto parse_top;
- break;
- }
-
- // repeated string top = 4;
- case 4: {
- if (tag == 34) {
- parse_top:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->add_top()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->top(this->top_size() - 1).data(),
- this->top(this->top_size() - 1).length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.LayerParameter.top");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(34)) goto parse_top;
- if (input->ExpectTag(45)) goto parse_loss_weight;
- break;
- }
-
- // repeated float loss_weight = 5;
- case 5: {
- if (tag == 45) {
- parse_loss_weight:
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- 1, 45, input, this->mutable_loss_weight())));
- } else if (tag == 42) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, this->mutable_loss_weight())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(45)) goto parse_loss_weight;
- if (input->ExpectTag(50)) goto parse_param;
- break;
- }
-
- // repeated .caffe.ParamSpec param = 6;
- case 6: {
- if (tag == 50) {
- parse_param:
- DO_(input->IncrementRecursionDepth());
- parse_loop_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
- input, add_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(50)) goto parse_loop_param;
- if (input->ExpectTag(58)) goto parse_loop_blobs;
- input->UnsafeDecrementRecursionDepth();
- break;
- }
-
- // repeated .caffe.BlobProto blobs = 7;
- case 7: {
- if (tag == 58) {
- DO_(input->IncrementRecursionDepth());
- parse_loop_blobs:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
- input, add_blobs()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(58)) goto parse_loop_blobs;
- if (input->ExpectTag(66)) goto parse_loop_include;
- input->UnsafeDecrementRecursionDepth();
- break;
- }
-
- // repeated .caffe.NetStateRule include = 8;
- case 8: {
- if (tag == 66) {
- DO_(input->IncrementRecursionDepth());
- parse_loop_include:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
- input, add_include()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(66)) goto parse_loop_include;
- if (input->ExpectTag(74)) goto parse_loop_exclude;
- input->UnsafeDecrementRecursionDepth();
- break;
- }
-
- // repeated .caffe.NetStateRule exclude = 9;
- case 9: {
- if (tag == 74) {
- DO_(input->IncrementRecursionDepth());
- parse_loop_exclude:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
- input, add_exclude()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(74)) goto parse_loop_exclude;
- input->UnsafeDecrementRecursionDepth();
- if (input->ExpectTag(80)) goto parse_phase;
- break;
- }
-
- // optional .caffe.Phase phase = 10;
- case 10: {
- if (tag == 80) {
- parse_phase:
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::Phase_IsValid(value)) {
- set_phase(static_cast< ::caffe::Phase >(value));
- } else {
- mutable_unknown_fields()->AddVarint(10, value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(88)) goto parse_propagate_down;
- break;
- }
-
- // repeated bool propagate_down = 11;
- case 11: {
- if (tag == 88) {
- parse_propagate_down:
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- 1, 88, input, this->mutable_propagate_down())));
- } else if (tag == 90) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, this->mutable_propagate_down())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(88)) goto parse_propagate_down;
- if (input->ExpectTag(802)) goto parse_transform_param;
- break;
- }
-
- // optional .caffe.TransformationParameter transform_param = 100;
- case 100: {
- if (tag == 802) {
- parse_transform_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_transform_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(810)) goto parse_loss_param;
- break;
- }
-
- // optional .caffe.LossParameter loss_param = 101;
- case 101: {
- if (tag == 810) {
- parse_loss_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_loss_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(818)) goto parse_accuracy_param;
- break;
- }
-
- // optional .caffe.AccuracyParameter accuracy_param = 102;
- case 102: {
- if (tag == 818) {
- parse_accuracy_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_accuracy_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(826)) goto parse_argmax_param;
- break;
- }
-
- // optional .caffe.ArgMaxParameter argmax_param = 103;
- case 103: {
- if (tag == 826) {
- parse_argmax_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_argmax_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(834)) goto parse_concat_param;
- break;
- }
-
- // optional .caffe.ConcatParameter concat_param = 104;
- case 104: {
- if (tag == 834) {
- parse_concat_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_concat_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(842)) goto parse_contrastive_loss_param;
- break;
- }
-
- // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 105;
- case 105: {
- if (tag == 842) {
- parse_contrastive_loss_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_contrastive_loss_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(850)) goto parse_convolution_param;
- break;
- }
-
- // optional .caffe.ConvolutionParameter convolution_param = 106;
- case 106: {
- if (tag == 850) {
- parse_convolution_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_convolution_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(858)) goto parse_data_param;
- break;
- }
-
- // optional .caffe.DataParameter data_param = 107;
- case 107: {
- if (tag == 858) {
- parse_data_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_data_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(866)) goto parse_dropout_param;
- break;
- }
-
- // optional .caffe.DropoutParameter dropout_param = 108;
- case 108: {
- if (tag == 866) {
- parse_dropout_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_dropout_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(874)) goto parse_dummy_data_param;
- break;
- }
-
- // optional .caffe.DummyDataParameter dummy_data_param = 109;
- case 109: {
- if (tag == 874) {
- parse_dummy_data_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_dummy_data_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(882)) goto parse_eltwise_param;
- break;
- }
-
- // optional .caffe.EltwiseParameter eltwise_param = 110;
- case 110: {
- if (tag == 882) {
- parse_eltwise_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_eltwise_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(890)) goto parse_exp_param;
- break;
- }
-
- // optional .caffe.ExpParameter exp_param = 111;
- case 111: {
- if (tag == 890) {
- parse_exp_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_exp_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(898)) goto parse_hdf5_data_param;
- break;
- }
-
- // optional .caffe.HDF5DataParameter hdf5_data_param = 112;
- case 112: {
- if (tag == 898) {
- parse_hdf5_data_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_hdf5_data_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(906)) goto parse_hdf5_output_param;
- break;
- }
-
- // optional .caffe.HDF5OutputParameter hdf5_output_param = 113;
- case 113: {
- if (tag == 906) {
- parse_hdf5_output_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_hdf5_output_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(914)) goto parse_hinge_loss_param;
- break;
- }
-
- // optional .caffe.HingeLossParameter hinge_loss_param = 114;
- case 114: {
- if (tag == 914) {
- parse_hinge_loss_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_hinge_loss_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(922)) goto parse_image_data_param;
- break;
- }
-
- // optional .caffe.ImageDataParameter image_data_param = 115;
- case 115: {
- if (tag == 922) {
- parse_image_data_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_image_data_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(930)) goto parse_infogain_loss_param;
- break;
- }
-
- // optional .caffe.InfogainLossParameter infogain_loss_param = 116;
- case 116: {
- if (tag == 930) {
- parse_infogain_loss_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_infogain_loss_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(938)) goto parse_inner_product_param;
- break;
- }
-
- // optional .caffe.InnerProductParameter inner_product_param = 117;
- case 117: {
- if (tag == 938) {
- parse_inner_product_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_inner_product_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(946)) goto parse_lrn_param;
- break;
- }
-
- // optional .caffe.LRNParameter lrn_param = 118;
- case 118: {
- if (tag == 946) {
- parse_lrn_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_lrn_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(954)) goto parse_memory_data_param;
- break;
- }
-
- // optional .caffe.MemoryDataParameter memory_data_param = 119;
- case 119: {
- if (tag == 954) {
- parse_memory_data_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_memory_data_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(962)) goto parse_mvn_param;
- break;
- }
-
- // optional .caffe.MVNParameter mvn_param = 120;
- case 120: {
- if (tag == 962) {
- parse_mvn_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_mvn_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(970)) goto parse_pooling_param;
- break;
- }
-
- // optional .caffe.PoolingParameter pooling_param = 121;
- case 121: {
- if (tag == 970) {
- parse_pooling_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_pooling_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(978)) goto parse_power_param;
- break;
- }
-
- // optional .caffe.PowerParameter power_param = 122;
- case 122: {
- if (tag == 978) {
- parse_power_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_power_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(986)) goto parse_relu_param;
- break;
- }
-
- // optional .caffe.ReLUParameter relu_param = 123;
- case 123: {
- if (tag == 986) {
- parse_relu_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_relu_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(994)) goto parse_sigmoid_param;
- break;
- }
-
- // optional .caffe.SigmoidParameter sigmoid_param = 124;
- case 124: {
- if (tag == 994) {
- parse_sigmoid_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_sigmoid_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(1002)) goto parse_softmax_param;
- break;
- }
-
- // optional .caffe.SoftmaxParameter softmax_param = 125;
- case 125: {
- if (tag == 1002) {
- parse_softmax_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_softmax_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(1010)) goto parse_slice_param;
- break;
- }
-
- // optional .caffe.SliceParameter slice_param = 126;
- case 126: {
- if (tag == 1010) {
- parse_slice_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_slice_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(1018)) goto parse_tanh_param;
- break;
- }
-
- // optional .caffe.TanHParameter tanh_param = 127;
- case 127: {
- if (tag == 1018) {
- parse_tanh_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_tanh_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(1026)) goto parse_threshold_param;
- break;
- }
-
- // optional .caffe.ThresholdParameter threshold_param = 128;
- case 128: {
- if (tag == 1026) {
- parse_threshold_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_threshold_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(1034)) goto parse_window_data_param;
- break;
- }
-
- // optional .caffe.WindowDataParameter window_data_param = 129;
- case 129: {
- if (tag == 1034) {
- parse_window_data_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_window_data_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(1042)) goto parse_python_param;
- break;
- }
-
- // optional .caffe.PythonParameter python_param = 130;
- case 130: {
- if (tag == 1042) {
- parse_python_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_python_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(1050)) goto parse_prelu_param;
- break;
- }
-
- // optional .caffe.PReLUParameter prelu_param = 131;
- case 131: {
- if (tag == 1050) {
- parse_prelu_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_prelu_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(1058)) goto parse_spp_param;
- break;
- }
-
- // optional .caffe.SPPParameter spp_param = 132;
- case 132: {
- if (tag == 1058) {
- parse_spp_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_spp_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(1066)) goto parse_reshape_param;
- break;
- }
-
- // optional .caffe.ReshapeParameter reshape_param = 133;
- case 133: {
- if (tag == 1066) {
- parse_reshape_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_reshape_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(1074)) goto parse_log_param;
- break;
- }
-
- // optional .caffe.LogParameter log_param = 134;
- case 134: {
- if (tag == 1074) {
- parse_log_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_log_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(1082)) goto parse_flatten_param;
- break;
- }
-
- // optional .caffe.FlattenParameter flatten_param = 135;
- case 135: {
- if (tag == 1082) {
- parse_flatten_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_flatten_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(1090)) goto parse_reduction_param;
- break;
- }
-
- // optional .caffe.ReductionParameter reduction_param = 136;
- case 136: {
- if (tag == 1090) {
- parse_reduction_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_reduction_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(1098)) goto parse_crop_param;
- break;
- }
-
- // optional .caffe.CropParameter crop_param = 137;
- case 137: {
- if (tag == 1098) {
- parse_crop_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_crop_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(1106)) goto parse_permute_param;
- break;
- }
-
- // optional .caffe.PermuteParameter permute_param = 138;
- case 138: {
- if (tag == 1106) {
- parse_permute_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_permute_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(1114)) goto parse_normalize_bbox_param;
- break;
- }
-
- // optional .caffe.NormalizeBBoxParameter normalize_bbox_param = 139;
- case 139: {
- if (tag == 1114) {
- parse_normalize_bbox_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_normalize_bbox_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(1122)) goto parse_prior_box_param;
- break;
- }
-
- // optional .caffe.PriorBoxParameter prior_box_param = 140;
- case 140: {
- if (tag == 1122) {
- parse_prior_box_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_prior_box_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(1130)) goto parse_detection_output_param;
- break;
- }
-
- // optional .caffe.DetectionOutputParameter detection_output_param = 141;
- case 141: {
- if (tag == 1130) {
- parse_detection_output_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_detection_output_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.LayerParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.LayerParameter)
- return false;
-#undef DO_
-}
-
-void LayerParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.LayerParameter)
- // optional string name = 1;
- if (has_name()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->name().data(), this->name().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.LayerParameter.name");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 1, this->name(), output);
- }
-
- // optional string type = 2;
- if (has_type()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->type().data(), this->type().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.LayerParameter.type");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 2, this->type(), output);
- }
-
- // repeated string bottom = 3;
- for (int i = 0; i < this->bottom_size(); i++) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->bottom(i).data(), this->bottom(i).length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.LayerParameter.bottom");
- ::google::protobuf::internal::WireFormatLite::WriteString(
- 3, this->bottom(i), output);
- }
-
- // repeated string top = 4;
- for (int i = 0; i < this->top_size(); i++) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->top(i).data(), this->top(i).length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.LayerParameter.top");
- ::google::protobuf::internal::WireFormatLite::WriteString(
- 4, this->top(i), output);
- }
-
- // repeated float loss_weight = 5;
- for (int i = 0; i < this->loss_weight_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(
- 5, this->loss_weight(i), output);
- }
-
- // repeated .caffe.ParamSpec param = 6;
- for (unsigned int i = 0, n = this->param_size(); i < n; i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 6, this->param(i), output);
- }
-
- // repeated .caffe.BlobProto blobs = 7;
- for (unsigned int i = 0, n = this->blobs_size(); i < n; i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 7, this->blobs(i), output);
- }
-
- // repeated .caffe.NetStateRule include = 8;
- for (unsigned int i = 0, n = this->include_size(); i < n; i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 8, this->include(i), output);
- }
-
- // repeated .caffe.NetStateRule exclude = 9;
- for (unsigned int i = 0, n = this->exclude_size(); i < n; i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 9, this->exclude(i), output);
- }
-
- // optional .caffe.Phase phase = 10;
- if (has_phase()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 10, this->phase(), output);
- }
-
- // repeated bool propagate_down = 11;
- for (int i = 0; i < this->propagate_down_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(
- 11, this->propagate_down(i), output);
- }
-
- // optional .caffe.TransformationParameter transform_param = 100;
- if (has_transform_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 100, *this->transform_param_, output);
- }
-
- // optional .caffe.LossParameter loss_param = 101;
- if (has_loss_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 101, *this->loss_param_, output);
- }
-
- // optional .caffe.AccuracyParameter accuracy_param = 102;
- if (has_accuracy_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 102, *this->accuracy_param_, output);
- }
-
- // optional .caffe.ArgMaxParameter argmax_param = 103;
- if (has_argmax_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 103, *this->argmax_param_, output);
- }
-
- // optional .caffe.ConcatParameter concat_param = 104;
- if (has_concat_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 104, *this->concat_param_, output);
- }
-
- // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 105;
- if (has_contrastive_loss_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 105, *this->contrastive_loss_param_, output);
- }
-
- // optional .caffe.ConvolutionParameter convolution_param = 106;
- if (has_convolution_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 106, *this->convolution_param_, output);
- }
-
- // optional .caffe.DataParameter data_param = 107;
- if (has_data_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 107, *this->data_param_, output);
- }
-
- // optional .caffe.DropoutParameter dropout_param = 108;
- if (has_dropout_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 108, *this->dropout_param_, output);
- }
-
- // optional .caffe.DummyDataParameter dummy_data_param = 109;
- if (has_dummy_data_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 109, *this->dummy_data_param_, output);
- }
-
- // optional .caffe.EltwiseParameter eltwise_param = 110;
- if (has_eltwise_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 110, *this->eltwise_param_, output);
- }
-
- // optional .caffe.ExpParameter exp_param = 111;
- if (has_exp_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 111, *this->exp_param_, output);
- }
-
- // optional .caffe.HDF5DataParameter hdf5_data_param = 112;
- if (has_hdf5_data_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 112, *this->hdf5_data_param_, output);
- }
-
- // optional .caffe.HDF5OutputParameter hdf5_output_param = 113;
- if (has_hdf5_output_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 113, *this->hdf5_output_param_, output);
- }
-
- // optional .caffe.HingeLossParameter hinge_loss_param = 114;
- if (has_hinge_loss_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 114, *this->hinge_loss_param_, output);
- }
-
- // optional .caffe.ImageDataParameter image_data_param = 115;
- if (has_image_data_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 115, *this->image_data_param_, output);
- }
-
- // optional .caffe.InfogainLossParameter infogain_loss_param = 116;
- if (has_infogain_loss_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 116, *this->infogain_loss_param_, output);
- }
-
- // optional .caffe.InnerProductParameter inner_product_param = 117;
- if (has_inner_product_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 117, *this->inner_product_param_, output);
- }
-
- // optional .caffe.LRNParameter lrn_param = 118;
- if (has_lrn_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 118, *this->lrn_param_, output);
- }
-
- // optional .caffe.MemoryDataParameter memory_data_param = 119;
- if (has_memory_data_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 119, *this->memory_data_param_, output);
- }
-
- // optional .caffe.MVNParameter mvn_param = 120;
- if (has_mvn_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 120, *this->mvn_param_, output);
- }
-
- // optional .caffe.PoolingParameter pooling_param = 121;
- if (has_pooling_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 121, *this->pooling_param_, output);
- }
-
- // optional .caffe.PowerParameter power_param = 122;
- if (has_power_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 122, *this->power_param_, output);
- }
-
- // optional .caffe.ReLUParameter relu_param = 123;
- if (has_relu_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 123, *this->relu_param_, output);
- }
-
- // optional .caffe.SigmoidParameter sigmoid_param = 124;
- if (has_sigmoid_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 124, *this->sigmoid_param_, output);
- }
-
- // optional .caffe.SoftmaxParameter softmax_param = 125;
- if (has_softmax_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 125, *this->softmax_param_, output);
- }
-
- // optional .caffe.SliceParameter slice_param = 126;
- if (has_slice_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 126, *this->slice_param_, output);
- }
-
- // optional .caffe.TanHParameter tanh_param = 127;
- if (has_tanh_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 127, *this->tanh_param_, output);
- }
-
- // optional .caffe.ThresholdParameter threshold_param = 128;
- if (has_threshold_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 128, *this->threshold_param_, output);
- }
-
- // optional .caffe.WindowDataParameter window_data_param = 129;
- if (has_window_data_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 129, *this->window_data_param_, output);
- }
-
- // optional .caffe.PythonParameter python_param = 130;
- if (has_python_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 130, *this->python_param_, output);
- }
-
- // optional .caffe.PReLUParameter prelu_param = 131;
- if (has_prelu_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 131, *this->prelu_param_, output);
- }
-
- // optional .caffe.SPPParameter spp_param = 132;
- if (has_spp_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 132, *this->spp_param_, output);
- }
-
- // optional .caffe.ReshapeParameter reshape_param = 133;
- if (has_reshape_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 133, *this->reshape_param_, output);
- }
-
- // optional .caffe.LogParameter log_param = 134;
- if (has_log_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 134, *this->log_param_, output);
- }
-
- // optional .caffe.FlattenParameter flatten_param = 135;
- if (has_flatten_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 135, *this->flatten_param_, output);
- }
-
- // optional .caffe.ReductionParameter reduction_param = 136;
- if (has_reduction_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 136, *this->reduction_param_, output);
- }
-
- // optional .caffe.CropParameter crop_param = 137;
- if (has_crop_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 137, *this->crop_param_, output);
- }
-
- // optional .caffe.PermuteParameter permute_param = 138;
- if (has_permute_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 138, *this->permute_param_, output);
- }
-
- // optional .caffe.NormalizeBBoxParameter normalize_bbox_param = 139;
- if (has_normalize_bbox_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 139, *this->normalize_bbox_param_, output);
- }
-
- // optional .caffe.PriorBoxParameter prior_box_param = 140;
- if (has_prior_box_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 140, *this->prior_box_param_, output);
- }
-
- // optional .caffe.DetectionOutputParameter detection_output_param = 141;
- if (has_detection_output_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 141, *this->detection_output_param_, output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.LayerParameter)
-}
-
-::google::protobuf::uint8* LayerParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.LayerParameter)
- // optional string name = 1;
- if (has_name()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->name().data(), this->name().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.LayerParameter.name");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 1, this->name(), target);
- }
-
- // optional string type = 2;
- if (has_type()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->type().data(), this->type().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.LayerParameter.type");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 2, this->type(), target);
- }
-
- // repeated string bottom = 3;
- for (int i = 0; i < this->bottom_size(); i++) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->bottom(i).data(), this->bottom(i).length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.LayerParameter.bottom");
- target = ::google::protobuf::internal::WireFormatLite::
- WriteStringToArray(3, this->bottom(i), target);
- }
-
- // repeated string top = 4;
- for (int i = 0; i < this->top_size(); i++) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->top(i).data(), this->top(i).length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.LayerParameter.top");
- target = ::google::protobuf::internal::WireFormatLite::
- WriteStringToArray(4, this->top(i), target);
- }
-
- // repeated float loss_weight = 5;
- for (int i = 0; i < this->loss_weight_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteFloatToArray(5, this->loss_weight(i), target);
- }
-
- // repeated .caffe.ParamSpec param = 6;
- for (unsigned int i = 0, n = this->param_size(); i < n; i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 6, this->param(i), false, target);
- }
-
- // repeated .caffe.BlobProto blobs = 7;
- for (unsigned int i = 0, n = this->blobs_size(); i < n; i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 7, this->blobs(i), false, target);
- }
-
- // repeated .caffe.NetStateRule include = 8;
- for (unsigned int i = 0, n = this->include_size(); i < n; i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 8, this->include(i), false, target);
- }
-
- // repeated .caffe.NetStateRule exclude = 9;
- for (unsigned int i = 0, n = this->exclude_size(); i < n; i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 9, this->exclude(i), false, target);
- }
-
- // optional .caffe.Phase phase = 10;
- if (has_phase()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 10, this->phase(), target);
- }
-
- // repeated bool propagate_down = 11;
- for (int i = 0; i < this->propagate_down_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteBoolToArray(11, this->propagate_down(i), target);
- }
-
- // optional .caffe.TransformationParameter transform_param = 100;
- if (has_transform_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 100, *this->transform_param_, false, target);
- }
-
- // optional .caffe.LossParameter loss_param = 101;
- if (has_loss_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 101, *this->loss_param_, false, target);
- }
-
- // optional .caffe.AccuracyParameter accuracy_param = 102;
- if (has_accuracy_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 102, *this->accuracy_param_, false, target);
- }
-
- // optional .caffe.ArgMaxParameter argmax_param = 103;
- if (has_argmax_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 103, *this->argmax_param_, false, target);
- }
-
- // optional .caffe.ConcatParameter concat_param = 104;
- if (has_concat_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 104, *this->concat_param_, false, target);
- }
-
- // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 105;
- if (has_contrastive_loss_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 105, *this->contrastive_loss_param_, false, target);
- }
-
- // optional .caffe.ConvolutionParameter convolution_param = 106;
- if (has_convolution_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 106, *this->convolution_param_, false, target);
- }
-
- // optional .caffe.DataParameter data_param = 107;
- if (has_data_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 107, *this->data_param_, false, target);
- }
-
- // optional .caffe.DropoutParameter dropout_param = 108;
- if (has_dropout_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 108, *this->dropout_param_, false, target);
- }
-
- // optional .caffe.DummyDataParameter dummy_data_param = 109;
- if (has_dummy_data_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 109, *this->dummy_data_param_, false, target);
- }
-
- // optional .caffe.EltwiseParameter eltwise_param = 110;
- if (has_eltwise_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 110, *this->eltwise_param_, false, target);
- }
-
- // optional .caffe.ExpParameter exp_param = 111;
- if (has_exp_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 111, *this->exp_param_, false, target);
- }
-
- // optional .caffe.HDF5DataParameter hdf5_data_param = 112;
- if (has_hdf5_data_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 112, *this->hdf5_data_param_, false, target);
- }
-
- // optional .caffe.HDF5OutputParameter hdf5_output_param = 113;
- if (has_hdf5_output_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 113, *this->hdf5_output_param_, false, target);
- }
-
- // optional .caffe.HingeLossParameter hinge_loss_param = 114;
- if (has_hinge_loss_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 114, *this->hinge_loss_param_, false, target);
- }
-
- // optional .caffe.ImageDataParameter image_data_param = 115;
- if (has_image_data_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 115, *this->image_data_param_, false, target);
- }
-
- // optional .caffe.InfogainLossParameter infogain_loss_param = 116;
- if (has_infogain_loss_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 116, *this->infogain_loss_param_, false, target);
- }
-
- // optional .caffe.InnerProductParameter inner_product_param = 117;
- if (has_inner_product_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 117, *this->inner_product_param_, false, target);
- }
-
- // optional .caffe.LRNParameter lrn_param = 118;
- if (has_lrn_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 118, *this->lrn_param_, false, target);
- }
-
- // optional .caffe.MemoryDataParameter memory_data_param = 119;
- if (has_memory_data_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 119, *this->memory_data_param_, false, target);
- }
-
- // optional .caffe.MVNParameter mvn_param = 120;
- if (has_mvn_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 120, *this->mvn_param_, false, target);
- }
-
- // optional .caffe.PoolingParameter pooling_param = 121;
- if (has_pooling_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 121, *this->pooling_param_, false, target);
- }
-
- // optional .caffe.PowerParameter power_param = 122;
- if (has_power_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 122, *this->power_param_, false, target);
- }
-
- // optional .caffe.ReLUParameter relu_param = 123;
- if (has_relu_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 123, *this->relu_param_, false, target);
- }
-
- // optional .caffe.SigmoidParameter sigmoid_param = 124;
- if (has_sigmoid_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 124, *this->sigmoid_param_, false, target);
- }
-
- // optional .caffe.SoftmaxParameter softmax_param = 125;
- if (has_softmax_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 125, *this->softmax_param_, false, target);
- }
-
- // optional .caffe.SliceParameter slice_param = 126;
- if (has_slice_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 126, *this->slice_param_, false, target);
- }
-
- // optional .caffe.TanHParameter tanh_param = 127;
- if (has_tanh_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 127, *this->tanh_param_, false, target);
- }
-
- // optional .caffe.ThresholdParameter threshold_param = 128;
- if (has_threshold_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 128, *this->threshold_param_, false, target);
- }
-
- // optional .caffe.WindowDataParameter window_data_param = 129;
- if (has_window_data_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 129, *this->window_data_param_, false, target);
- }
-
- // optional .caffe.PythonParameter python_param = 130;
- if (has_python_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 130, *this->python_param_, false, target);
- }
-
- // optional .caffe.PReLUParameter prelu_param = 131;
- if (has_prelu_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 131, *this->prelu_param_, false, target);
- }
-
- // optional .caffe.SPPParameter spp_param = 132;
- if (has_spp_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 132, *this->spp_param_, false, target);
- }
-
- // optional .caffe.ReshapeParameter reshape_param = 133;
- if (has_reshape_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 133, *this->reshape_param_, false, target);
- }
-
- // optional .caffe.LogParameter log_param = 134;
- if (has_log_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 134, *this->log_param_, false, target);
- }
-
- // optional .caffe.FlattenParameter flatten_param = 135;
- if (has_flatten_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 135, *this->flatten_param_, false, target);
- }
-
- // optional .caffe.ReductionParameter reduction_param = 136;
- if (has_reduction_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 136, *this->reduction_param_, false, target);
- }
-
- // optional .caffe.CropParameter crop_param = 137;
- if (has_crop_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 137, *this->crop_param_, false, target);
- }
-
- // optional .caffe.PermuteParameter permute_param = 138;
- if (has_permute_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 138, *this->permute_param_, false, target);
- }
-
- // optional .caffe.NormalizeBBoxParameter normalize_bbox_param = 139;
- if (has_normalize_bbox_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 139, *this->normalize_bbox_param_, false, target);
- }
-
- // optional .caffe.PriorBoxParameter prior_box_param = 140;
- if (has_prior_box_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 140, *this->prior_box_param_, false, target);
- }
-
- // optional .caffe.DetectionOutputParameter detection_output_param = 141;
- if (has_detection_output_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 141, *this->detection_output_param_, false, target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.LayerParameter)
- return target;
-}
-
-size_t LayerParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.LayerParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 19u) {
- // optional string name = 1;
- if (has_name()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->name());
- }
-
- // optional string type = 2;
- if (has_type()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->type());
- }
-
- // optional .caffe.Phase phase = 10;
- if (has_phase()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->phase());
- }
-
- }
- if (_has_bits_[11 / 32] & 63488u) {
- // optional .caffe.TransformationParameter transform_param = 100;
- if (has_transform_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->transform_param_);
- }
-
- // optional .caffe.LossParameter loss_param = 101;
- if (has_loss_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->loss_param_);
- }
-
- // optional .caffe.AccuracyParameter accuracy_param = 102;
- if (has_accuracy_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->accuracy_param_);
- }
-
- // optional .caffe.ArgMaxParameter argmax_param = 103;
- if (has_argmax_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->argmax_param_);
- }
-
- // optional .caffe.ConcatParameter concat_param = 104;
- if (has_concat_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->concat_param_);
- }
-
- }
- if (_has_bits_[16 / 32] & 16711680u) {
- // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 105;
- if (has_contrastive_loss_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->contrastive_loss_param_);
- }
-
- // optional .caffe.ConvolutionParameter convolution_param = 106;
- if (has_convolution_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->convolution_param_);
- }
-
- // optional .caffe.CropParameter crop_param = 137;
- if (has_crop_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->crop_param_);
- }
-
- // optional .caffe.DataParameter data_param = 107;
- if (has_data_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->data_param_);
- }
-
- // optional .caffe.DetectionOutputParameter detection_output_param = 141;
- if (has_detection_output_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->detection_output_param_);
- }
-
- // optional .caffe.DropoutParameter dropout_param = 108;
- if (has_dropout_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->dropout_param_);
- }
-
- // optional .caffe.DummyDataParameter dummy_data_param = 109;
- if (has_dummy_data_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->dummy_data_param_);
- }
-
- // optional .caffe.EltwiseParameter eltwise_param = 110;
- if (has_eltwise_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->eltwise_param_);
- }
-
- }
- if (_has_bits_[24 / 32] & 4278190080u) {
- // optional .caffe.ExpParameter exp_param = 111;
- if (has_exp_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->exp_param_);
- }
-
- // optional .caffe.FlattenParameter flatten_param = 135;
- if (has_flatten_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->flatten_param_);
- }
-
- // optional .caffe.HDF5DataParameter hdf5_data_param = 112;
- if (has_hdf5_data_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->hdf5_data_param_);
- }
-
- // optional .caffe.HDF5OutputParameter hdf5_output_param = 113;
- if (has_hdf5_output_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->hdf5_output_param_);
- }
-
- // optional .caffe.HingeLossParameter hinge_loss_param = 114;
- if (has_hinge_loss_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->hinge_loss_param_);
- }
-
- // optional .caffe.ImageDataParameter image_data_param = 115;
- if (has_image_data_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->image_data_param_);
- }
-
- // optional .caffe.InfogainLossParameter infogain_loss_param = 116;
- if (has_infogain_loss_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->infogain_loss_param_);
- }
-
- // optional .caffe.InnerProductParameter inner_product_param = 117;
- if (has_inner_product_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->inner_product_param_);
- }
-
- }
- if (_has_bits_[32 / 32] & 255u) {
- // optional .caffe.LogParameter log_param = 134;
- if (has_log_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->log_param_);
- }
-
- // optional .caffe.LRNParameter lrn_param = 118;
- if (has_lrn_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->lrn_param_);
- }
-
- // optional .caffe.MemoryDataParameter memory_data_param = 119;
- if (has_memory_data_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->memory_data_param_);
- }
-
- // optional .caffe.MVNParameter mvn_param = 120;
- if (has_mvn_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->mvn_param_);
- }
-
- // optional .caffe.NormalizeBBoxParameter normalize_bbox_param = 139;
- if (has_normalize_bbox_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->normalize_bbox_param_);
- }
-
- // optional .caffe.PermuteParameter permute_param = 138;
- if (has_permute_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->permute_param_);
- }
-
- // optional .caffe.PoolingParameter pooling_param = 121;
- if (has_pooling_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->pooling_param_);
- }
-
- // optional .caffe.PowerParameter power_param = 122;
- if (has_power_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->power_param_);
- }
-
- }
- if (_has_bits_[40 / 32] & 65280u) {
- // optional .caffe.PReLUParameter prelu_param = 131;
- if (has_prelu_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->prelu_param_);
- }
-
- // optional .caffe.PriorBoxParameter prior_box_param = 140;
- if (has_prior_box_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->prior_box_param_);
- }
-
- // optional .caffe.PythonParameter python_param = 130;
- if (has_python_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->python_param_);
- }
-
- // optional .caffe.ReductionParameter reduction_param = 136;
- if (has_reduction_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->reduction_param_);
- }
-
- // optional .caffe.ReLUParameter relu_param = 123;
- if (has_relu_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->relu_param_);
- }
-
- // optional .caffe.ReshapeParameter reshape_param = 133;
- if (has_reshape_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->reshape_param_);
- }
-
- // optional .caffe.SigmoidParameter sigmoid_param = 124;
- if (has_sigmoid_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->sigmoid_param_);
- }
-
- // optional .caffe.SliceParameter slice_param = 126;
- if (has_slice_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->slice_param_);
- }
-
- }
- if (_has_bits_[48 / 32] & 2031616u) {
- // optional .caffe.SoftmaxParameter softmax_param = 125;
- if (has_softmax_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->softmax_param_);
- }
-
- // optional .caffe.SPPParameter spp_param = 132;
- if (has_spp_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->spp_param_);
- }
-
- // optional .caffe.TanHParameter tanh_param = 127;
- if (has_tanh_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->tanh_param_);
- }
-
- // optional .caffe.ThresholdParameter threshold_param = 128;
- if (has_threshold_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->threshold_param_);
- }
-
- // optional .caffe.WindowDataParameter window_data_param = 129;
- if (has_window_data_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->window_data_param_);
- }
-
- }
- // repeated string bottom = 3;
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->bottom_size());
- for (int i = 0; i < this->bottom_size(); i++) {
- total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
- this->bottom(i));
- }
-
- // repeated string top = 4;
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->top_size());
- for (int i = 0; i < this->top_size(); i++) {
- total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
- this->top(i));
- }
-
- // repeated float loss_weight = 5;
- {
- size_t data_size = 0;
- unsigned int count = this->loss_weight_size();
- data_size = 4UL * count;
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->loss_weight_size());
- total_size += data_size;
- }
-
- // repeated .caffe.ParamSpec param = 6;
- {
- unsigned int count = this->param_size();
- total_size += 1UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->param(i));
- }
- }
-
- // repeated .caffe.BlobProto blobs = 7;
- {
- unsigned int count = this->blobs_size();
- total_size += 1UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->blobs(i));
- }
- }
-
- // repeated bool propagate_down = 11;
- {
- size_t data_size = 0;
- unsigned int count = this->propagate_down_size();
- data_size = 1UL * count;
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->propagate_down_size());
- total_size += data_size;
- }
-
- // repeated .caffe.NetStateRule include = 8;
- {
- unsigned int count = this->include_size();
- total_size += 1UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->include(i));
- }
- }
-
- // repeated .caffe.NetStateRule exclude = 9;
- {
- unsigned int count = this->exclude_size();
- total_size += 1UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->exclude(i));
- }
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void LayerParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.LayerParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const LayerParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const LayerParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.LayerParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.LayerParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void LayerParameter::MergeFrom(const LayerParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.LayerParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void LayerParameter::UnsafeMergeFrom(const LayerParameter& from) {
- GOOGLE_DCHECK(&from != this);
- bottom_.UnsafeMergeFrom(from.bottom_);
- top_.UnsafeMergeFrom(from.top_);
- loss_weight_.UnsafeMergeFrom(from.loss_weight_);
- param_.MergeFrom(from.param_);
- blobs_.MergeFrom(from.blobs_);
- propagate_down_.UnsafeMergeFrom(from.propagate_down_);
- include_.MergeFrom(from.include_);
- exclude_.MergeFrom(from.exclude_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_name()) {
- set_has_name();
- name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
- }
- if (from.has_type()) {
- set_has_type();
- type_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_);
- }
- if (from.has_phase()) {
- set_phase(from.phase());
- }
- }
- if (from._has_bits_[11 / 32] & (0xffu << (11 % 32))) {
- if (from.has_transform_param()) {
- mutable_transform_param()->::caffe::TransformationParameter::MergeFrom(from.transform_param());
- }
- if (from.has_loss_param()) {
- mutable_loss_param()->::caffe::LossParameter::MergeFrom(from.loss_param());
- }
- if (from.has_accuracy_param()) {
- mutable_accuracy_param()->::caffe::AccuracyParameter::MergeFrom(from.accuracy_param());
- }
- if (from.has_argmax_param()) {
- mutable_argmax_param()->::caffe::ArgMaxParameter::MergeFrom(from.argmax_param());
- }
- if (from.has_concat_param()) {
- mutable_concat_param()->::caffe::ConcatParameter::MergeFrom(from.concat_param());
- }
- }
- if (from._has_bits_[16 / 32] & (0xffu << (16 % 32))) {
- if (from.has_contrastive_loss_param()) {
- mutable_contrastive_loss_param()->::caffe::ContrastiveLossParameter::MergeFrom(from.contrastive_loss_param());
- }
- if (from.has_convolution_param()) {
- mutable_convolution_param()->::caffe::ConvolutionParameter::MergeFrom(from.convolution_param());
- }
- if (from.has_crop_param()) {
- mutable_crop_param()->::caffe::CropParameter::MergeFrom(from.crop_param());
- }
- if (from.has_data_param()) {
- mutable_data_param()->::caffe::DataParameter::MergeFrom(from.data_param());
- }
- if (from.has_detection_output_param()) {
- mutable_detection_output_param()->::caffe::DetectionOutputParameter::MergeFrom(from.detection_output_param());
- }
- if (from.has_dropout_param()) {
- mutable_dropout_param()->::caffe::DropoutParameter::MergeFrom(from.dropout_param());
- }
- if (from.has_dummy_data_param()) {
- mutable_dummy_data_param()->::caffe::DummyDataParameter::MergeFrom(from.dummy_data_param());
- }
- if (from.has_eltwise_param()) {
- mutable_eltwise_param()->::caffe::EltwiseParameter::MergeFrom(from.eltwise_param());
- }
- }
- if (from._has_bits_[24 / 32] & (0xffu << (24 % 32))) {
- if (from.has_exp_param()) {
- mutable_exp_param()->::caffe::ExpParameter::MergeFrom(from.exp_param());
- }
- if (from.has_flatten_param()) {
- mutable_flatten_param()->::caffe::FlattenParameter::MergeFrom(from.flatten_param());
- }
- if (from.has_hdf5_data_param()) {
- mutable_hdf5_data_param()->::caffe::HDF5DataParameter::MergeFrom(from.hdf5_data_param());
- }
- if (from.has_hdf5_output_param()) {
- mutable_hdf5_output_param()->::caffe::HDF5OutputParameter::MergeFrom(from.hdf5_output_param());
- }
- if (from.has_hinge_loss_param()) {
- mutable_hinge_loss_param()->::caffe::HingeLossParameter::MergeFrom(from.hinge_loss_param());
- }
- if (from.has_image_data_param()) {
- mutable_image_data_param()->::caffe::ImageDataParameter::MergeFrom(from.image_data_param());
- }
- if (from.has_infogain_loss_param()) {
- mutable_infogain_loss_param()->::caffe::InfogainLossParameter::MergeFrom(from.infogain_loss_param());
- }
- if (from.has_inner_product_param()) {
- mutable_inner_product_param()->::caffe::InnerProductParameter::MergeFrom(from.inner_product_param());
- }
- }
- if (from._has_bits_[32 / 32] & (0xffu << (32 % 32))) {
- if (from.has_log_param()) {
- mutable_log_param()->::caffe::LogParameter::MergeFrom(from.log_param());
- }
- if (from.has_lrn_param()) {
- mutable_lrn_param()->::caffe::LRNParameter::MergeFrom(from.lrn_param());
- }
- if (from.has_memory_data_param()) {
- mutable_memory_data_param()->::caffe::MemoryDataParameter::MergeFrom(from.memory_data_param());
- }
- if (from.has_mvn_param()) {
- mutable_mvn_param()->::caffe::MVNParameter::MergeFrom(from.mvn_param());
- }
- if (from.has_normalize_bbox_param()) {
- mutable_normalize_bbox_param()->::caffe::NormalizeBBoxParameter::MergeFrom(from.normalize_bbox_param());
- }
- if (from.has_permute_param()) {
- mutable_permute_param()->::caffe::PermuteParameter::MergeFrom(from.permute_param());
- }
- if (from.has_pooling_param()) {
- mutable_pooling_param()->::caffe::PoolingParameter::MergeFrom(from.pooling_param());
- }
- if (from.has_power_param()) {
- mutable_power_param()->::caffe::PowerParameter::MergeFrom(from.power_param());
- }
- }
- if (from._has_bits_[40 / 32] & (0xffu << (40 % 32))) {
- if (from.has_prelu_param()) {
- mutable_prelu_param()->::caffe::PReLUParameter::MergeFrom(from.prelu_param());
- }
- if (from.has_prior_box_param()) {
- mutable_prior_box_param()->::caffe::PriorBoxParameter::MergeFrom(from.prior_box_param());
- }
- if (from.has_python_param()) {
- mutable_python_param()->::caffe::PythonParameter::MergeFrom(from.python_param());
- }
- if (from.has_reduction_param()) {
- mutable_reduction_param()->::caffe::ReductionParameter::MergeFrom(from.reduction_param());
- }
- if (from.has_relu_param()) {
- mutable_relu_param()->::caffe::ReLUParameter::MergeFrom(from.relu_param());
- }
- if (from.has_reshape_param()) {
- mutable_reshape_param()->::caffe::ReshapeParameter::MergeFrom(from.reshape_param());
- }
- if (from.has_sigmoid_param()) {
- mutable_sigmoid_param()->::caffe::SigmoidParameter::MergeFrom(from.sigmoid_param());
- }
- if (from.has_slice_param()) {
- mutable_slice_param()->::caffe::SliceParameter::MergeFrom(from.slice_param());
- }
- }
- if (from._has_bits_[48 / 32] & (0xffu << (48 % 32))) {
- if (from.has_softmax_param()) {
- mutable_softmax_param()->::caffe::SoftmaxParameter::MergeFrom(from.softmax_param());
- }
- if (from.has_spp_param()) {
- mutable_spp_param()->::caffe::SPPParameter::MergeFrom(from.spp_param());
- }
- if (from.has_tanh_param()) {
- mutable_tanh_param()->::caffe::TanHParameter::MergeFrom(from.tanh_param());
- }
- if (from.has_threshold_param()) {
- mutable_threshold_param()->::caffe::ThresholdParameter::MergeFrom(from.threshold_param());
- }
- if (from.has_window_data_param()) {
- mutable_window_data_param()->::caffe::WindowDataParameter::MergeFrom(from.window_data_param());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void LayerParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.LayerParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void LayerParameter::CopyFrom(const LayerParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.LayerParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool LayerParameter::IsInitialized() const {
-
- return true;
-}
-
-void LayerParameter::Swap(LayerParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void LayerParameter::InternalSwap(LayerParameter* other) {
- name_.Swap(&other->name_);
- type_.Swap(&other->type_);
- bottom_.UnsafeArenaSwap(&other->bottom_);
- top_.UnsafeArenaSwap(&other->top_);
- std::swap(phase_, other->phase_);
- loss_weight_.UnsafeArenaSwap(&other->loss_weight_);
- param_.UnsafeArenaSwap(&other->param_);
- blobs_.UnsafeArenaSwap(&other->blobs_);
- propagate_down_.UnsafeArenaSwap(&other->propagate_down_);
- include_.UnsafeArenaSwap(&other->include_);
- exclude_.UnsafeArenaSwap(&other->exclude_);
- std::swap(transform_param_, other->transform_param_);
- std::swap(loss_param_, other->loss_param_);
- std::swap(accuracy_param_, other->accuracy_param_);
- std::swap(argmax_param_, other->argmax_param_);
- std::swap(concat_param_, other->concat_param_);
- std::swap(contrastive_loss_param_, other->contrastive_loss_param_);
- std::swap(convolution_param_, other->convolution_param_);
- std::swap(crop_param_, other->crop_param_);
- std::swap(data_param_, other->data_param_);
- std::swap(detection_output_param_, other->detection_output_param_);
- std::swap(dropout_param_, other->dropout_param_);
- std::swap(dummy_data_param_, other->dummy_data_param_);
- std::swap(eltwise_param_, other->eltwise_param_);
- std::swap(exp_param_, other->exp_param_);
- std::swap(flatten_param_, other->flatten_param_);
- std::swap(hdf5_data_param_, other->hdf5_data_param_);
- std::swap(hdf5_output_param_, other->hdf5_output_param_);
- std::swap(hinge_loss_param_, other->hinge_loss_param_);
- std::swap(image_data_param_, other->image_data_param_);
- std::swap(infogain_loss_param_, other->infogain_loss_param_);
- std::swap(inner_product_param_, other->inner_product_param_);
- std::swap(log_param_, other->log_param_);
- std::swap(lrn_param_, other->lrn_param_);
- std::swap(memory_data_param_, other->memory_data_param_);
- std::swap(mvn_param_, other->mvn_param_);
- std::swap(normalize_bbox_param_, other->normalize_bbox_param_);
- std::swap(permute_param_, other->permute_param_);
- std::swap(pooling_param_, other->pooling_param_);
- std::swap(power_param_, other->power_param_);
- std::swap(prelu_param_, other->prelu_param_);
- std::swap(prior_box_param_, other->prior_box_param_);
- std::swap(python_param_, other->python_param_);
- std::swap(reduction_param_, other->reduction_param_);
- std::swap(relu_param_, other->relu_param_);
- std::swap(reshape_param_, other->reshape_param_);
- std::swap(sigmoid_param_, other->sigmoid_param_);
- std::swap(slice_param_, other->slice_param_);
- std::swap(softmax_param_, other->softmax_param_);
- std::swap(spp_param_, other->spp_param_);
- std::swap(tanh_param_, other->tanh_param_);
- std::swap(threshold_param_, other->threshold_param_);
- std::swap(window_data_param_, other->window_data_param_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- std::swap(_has_bits_[1], other->_has_bits_[1]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata LayerParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = LayerParameter_descriptor_;
- metadata.reflection = LayerParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// LayerParameter
-
-// optional string name = 1;
-bool LayerParameter::has_name() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void LayerParameter::set_has_name() {
- _has_bits_[0] |= 0x00000001u;
-}
-void LayerParameter::clear_has_name() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void LayerParameter::clear_name() {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_name();
-}
-const ::std::string& LayerParameter::name() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void LayerParameter::set_name(const ::std::string& value) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.LayerParameter.name)
-}
-void LayerParameter::set_name(const char* value) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.LayerParameter.name)
-}
-void LayerParameter::set_name(const char* value, size_t size) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.LayerParameter.name)
-}
-::std::string* LayerParameter::mutable_name() {
- set_has_name();
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.name)
- return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* LayerParameter::release_name() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.name)
- clear_has_name();
- return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void LayerParameter::set_allocated_name(::std::string* name) {
- if (name != NULL) {
- set_has_name();
- } else {
- clear_has_name();
- }
- name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.name)
-}
-
-// optional string type = 2;
-bool LayerParameter::has_type() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void LayerParameter::set_has_type() {
- _has_bits_[0] |= 0x00000002u;
-}
-void LayerParameter::clear_has_type() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void LayerParameter::clear_type() {
- type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_type();
-}
-const ::std::string& LayerParameter::type() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.type)
- return type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void LayerParameter::set_type(const ::std::string& value) {
- set_has_type();
- type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.LayerParameter.type)
-}
-void LayerParameter::set_type(const char* value) {
- set_has_type();
- type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.LayerParameter.type)
-}
-void LayerParameter::set_type(const char* value, size_t size) {
- set_has_type();
- type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.LayerParameter.type)
-}
-::std::string* LayerParameter::mutable_type() {
- set_has_type();
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.type)
- return type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* LayerParameter::release_type() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.type)
- clear_has_type();
- return type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void LayerParameter::set_allocated_type(::std::string* type) {
- if (type != NULL) {
- set_has_type();
- } else {
- clear_has_type();
- }
- type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type);
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.type)
-}
-
-// repeated string bottom = 3;
-int LayerParameter::bottom_size() const {
- return bottom_.size();
-}
-void LayerParameter::clear_bottom() {
- bottom_.Clear();
-}
-const ::std::string& LayerParameter::bottom(int index) const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.bottom)
- return bottom_.Get(index);
-}
-::std::string* LayerParameter::mutable_bottom(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.bottom)
- return bottom_.Mutable(index);
-}
-void LayerParameter::set_bottom(int index, const ::std::string& value) {
- // @@protoc_insertion_point(field_set:caffe.LayerParameter.bottom)
- bottom_.Mutable(index)->assign(value);
-}
-void LayerParameter::set_bottom(int index, const char* value) {
- bottom_.Mutable(index)->assign(value);
- // @@protoc_insertion_point(field_set_char:caffe.LayerParameter.bottom)
-}
-void LayerParameter::set_bottom(int index, const char* value, size_t size) {
- bottom_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:caffe.LayerParameter.bottom)
-}
-::std::string* LayerParameter::add_bottom() {
- // @@protoc_insertion_point(field_add_mutable:caffe.LayerParameter.bottom)
- return bottom_.Add();
-}
-void LayerParameter::add_bottom(const ::std::string& value) {
- bottom_.Add()->assign(value);
- // @@protoc_insertion_point(field_add:caffe.LayerParameter.bottom)
-}
-void LayerParameter::add_bottom(const char* value) {
- bottom_.Add()->assign(value);
- // @@protoc_insertion_point(field_add_char:caffe.LayerParameter.bottom)
-}
-void LayerParameter::add_bottom(const char* value, size_t size) {
- bottom_.Add()->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_add_pointer:caffe.LayerParameter.bottom)
-}
-const ::google::protobuf::RepeatedPtrField< ::std::string>&
-LayerParameter::bottom() const {
- // @@protoc_insertion_point(field_list:caffe.LayerParameter.bottom)
- return bottom_;
-}
-::google::protobuf::RepeatedPtrField< ::std::string>*
-LayerParameter::mutable_bottom() {
- // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.bottom)
- return &bottom_;
-}
-
-// repeated string top = 4;
-int LayerParameter::top_size() const {
- return top_.size();
-}
-void LayerParameter::clear_top() {
- top_.Clear();
-}
-const ::std::string& LayerParameter::top(int index) const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.top)
- return top_.Get(index);
-}
-::std::string* LayerParameter::mutable_top(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.top)
- return top_.Mutable(index);
-}
-void LayerParameter::set_top(int index, const ::std::string& value) {
- // @@protoc_insertion_point(field_set:caffe.LayerParameter.top)
- top_.Mutable(index)->assign(value);
-}
-void LayerParameter::set_top(int index, const char* value) {
- top_.Mutable(index)->assign(value);
- // @@protoc_insertion_point(field_set_char:caffe.LayerParameter.top)
-}
-void LayerParameter::set_top(int index, const char* value, size_t size) {
- top_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:caffe.LayerParameter.top)
-}
-::std::string* LayerParameter::add_top() {
- // @@protoc_insertion_point(field_add_mutable:caffe.LayerParameter.top)
- return top_.Add();
-}
-void LayerParameter::add_top(const ::std::string& value) {
- top_.Add()->assign(value);
- // @@protoc_insertion_point(field_add:caffe.LayerParameter.top)
-}
-void LayerParameter::add_top(const char* value) {
- top_.Add()->assign(value);
- // @@protoc_insertion_point(field_add_char:caffe.LayerParameter.top)
-}
-void LayerParameter::add_top(const char* value, size_t size) {
- top_.Add()->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_add_pointer:caffe.LayerParameter.top)
-}
-const ::google::protobuf::RepeatedPtrField< ::std::string>&
-LayerParameter::top() const {
- // @@protoc_insertion_point(field_list:caffe.LayerParameter.top)
- return top_;
-}
-::google::protobuf::RepeatedPtrField< ::std::string>*
-LayerParameter::mutable_top() {
- // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.top)
- return &top_;
-}
-
-// optional .caffe.Phase phase = 10;
-bool LayerParameter::has_phase() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-void LayerParameter::set_has_phase() {
- _has_bits_[0] |= 0x00000010u;
-}
-void LayerParameter::clear_has_phase() {
- _has_bits_[0] &= ~0x00000010u;
-}
-void LayerParameter::clear_phase() {
- phase_ = 0;
- clear_has_phase();
-}
-::caffe::Phase LayerParameter::phase() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.phase)
- return static_cast< ::caffe::Phase >(phase_);
-}
-void LayerParameter::set_phase(::caffe::Phase value) {
- assert(::caffe::Phase_IsValid(value));
- set_has_phase();
- phase_ = value;
- // @@protoc_insertion_point(field_set:caffe.LayerParameter.phase)
-}
-
-// repeated float loss_weight = 5;
-int LayerParameter::loss_weight_size() const {
- return loss_weight_.size();
-}
-void LayerParameter::clear_loss_weight() {
- loss_weight_.Clear();
-}
-float LayerParameter::loss_weight(int index) const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.loss_weight)
- return loss_weight_.Get(index);
-}
-void LayerParameter::set_loss_weight(int index, float value) {
- loss_weight_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.LayerParameter.loss_weight)
-}
-void LayerParameter::add_loss_weight(float value) {
- loss_weight_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.LayerParameter.loss_weight)
-}
-const ::google::protobuf::RepeatedField< float >&
-LayerParameter::loss_weight() const {
- // @@protoc_insertion_point(field_list:caffe.LayerParameter.loss_weight)
- return loss_weight_;
-}
-::google::protobuf::RepeatedField< float >*
-LayerParameter::mutable_loss_weight() {
- // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.loss_weight)
- return &loss_weight_;
-}
-
-// repeated .caffe.ParamSpec param = 6;
-int LayerParameter::param_size() const {
- return param_.size();
-}
-void LayerParameter::clear_param() {
- param_.Clear();
-}
-const ::caffe::ParamSpec& LayerParameter::param(int index) const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.param)
- return param_.Get(index);
-}
-::caffe::ParamSpec* LayerParameter::mutable_param(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.param)
- return param_.Mutable(index);
-}
-::caffe::ParamSpec* LayerParameter::add_param() {
- // @@protoc_insertion_point(field_add:caffe.LayerParameter.param)
- return param_.Add();
-}
-::google::protobuf::RepeatedPtrField< ::caffe::ParamSpec >*
-LayerParameter::mutable_param() {
- // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.param)
- return ¶m_;
-}
-const ::google::protobuf::RepeatedPtrField< ::caffe::ParamSpec >&
-LayerParameter::param() const {
- // @@protoc_insertion_point(field_list:caffe.LayerParameter.param)
- return param_;
-}
-
-// repeated .caffe.BlobProto blobs = 7;
-int LayerParameter::blobs_size() const {
- return blobs_.size();
-}
-void LayerParameter::clear_blobs() {
- blobs_.Clear();
-}
-const ::caffe::BlobProto& LayerParameter::blobs(int index) const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.blobs)
- return blobs_.Get(index);
-}
-::caffe::BlobProto* LayerParameter::mutable_blobs(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.blobs)
- return blobs_.Mutable(index);
-}
-::caffe::BlobProto* LayerParameter::add_blobs() {
- // @@protoc_insertion_point(field_add:caffe.LayerParameter.blobs)
- return blobs_.Add();
-}
-::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
-LayerParameter::mutable_blobs() {
- // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.blobs)
- return &blobs_;
-}
-const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
-LayerParameter::blobs() const {
- // @@protoc_insertion_point(field_list:caffe.LayerParameter.blobs)
- return blobs_;
-}
-
-// repeated bool propagate_down = 11;
-int LayerParameter::propagate_down_size() const {
- return propagate_down_.size();
-}
-void LayerParameter::clear_propagate_down() {
- propagate_down_.Clear();
-}
-bool LayerParameter::propagate_down(int index) const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.propagate_down)
- return propagate_down_.Get(index);
-}
-void LayerParameter::set_propagate_down(int index, bool value) {
- propagate_down_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.LayerParameter.propagate_down)
-}
-void LayerParameter::add_propagate_down(bool value) {
- propagate_down_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.LayerParameter.propagate_down)
-}
-const ::google::protobuf::RepeatedField< bool >&
-LayerParameter::propagate_down() const {
- // @@protoc_insertion_point(field_list:caffe.LayerParameter.propagate_down)
- return propagate_down_;
-}
-::google::protobuf::RepeatedField< bool >*
-LayerParameter::mutable_propagate_down() {
- // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.propagate_down)
- return &propagate_down_;
-}
-
-// repeated .caffe.NetStateRule include = 8;
-int LayerParameter::include_size() const {
- return include_.size();
-}
-void LayerParameter::clear_include() {
- include_.Clear();
-}
-const ::caffe::NetStateRule& LayerParameter::include(int index) const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.include)
- return include_.Get(index);
-}
-::caffe::NetStateRule* LayerParameter::mutable_include(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.include)
- return include_.Mutable(index);
-}
-::caffe::NetStateRule* LayerParameter::add_include() {
- // @@protoc_insertion_point(field_add:caffe.LayerParameter.include)
- return include_.Add();
-}
-::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >*
-LayerParameter::mutable_include() {
- // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.include)
- return &include_;
-}
-const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >&
-LayerParameter::include() const {
- // @@protoc_insertion_point(field_list:caffe.LayerParameter.include)
- return include_;
-}
-
-// repeated .caffe.NetStateRule exclude = 9;
-int LayerParameter::exclude_size() const {
- return exclude_.size();
-}
-void LayerParameter::clear_exclude() {
- exclude_.Clear();
-}
-const ::caffe::NetStateRule& LayerParameter::exclude(int index) const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.exclude)
- return exclude_.Get(index);
-}
-::caffe::NetStateRule* LayerParameter::mutable_exclude(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.exclude)
- return exclude_.Mutable(index);
-}
-::caffe::NetStateRule* LayerParameter::add_exclude() {
- // @@protoc_insertion_point(field_add:caffe.LayerParameter.exclude)
- return exclude_.Add();
-}
-::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >*
-LayerParameter::mutable_exclude() {
- // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.exclude)
- return &exclude_;
-}
-const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >&
-LayerParameter::exclude() const {
- // @@protoc_insertion_point(field_list:caffe.LayerParameter.exclude)
- return exclude_;
-}
-
-// optional .caffe.TransformationParameter transform_param = 100;
-bool LayerParameter::has_transform_param() const {
- return (_has_bits_[0] & 0x00000800u) != 0;
-}
-void LayerParameter::set_has_transform_param() {
- _has_bits_[0] |= 0x00000800u;
-}
-void LayerParameter::clear_has_transform_param() {
- _has_bits_[0] &= ~0x00000800u;
-}
-void LayerParameter::clear_transform_param() {
- if (transform_param_ != NULL) transform_param_->::caffe::TransformationParameter::Clear();
- clear_has_transform_param();
-}
-const ::caffe::TransformationParameter& LayerParameter::transform_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.transform_param)
- return transform_param_ != NULL ? *transform_param_
- : *::caffe::TransformationParameter::internal_default_instance();
-}
-::caffe::TransformationParameter* LayerParameter::mutable_transform_param() {
- set_has_transform_param();
- if (transform_param_ == NULL) {
- transform_param_ = new ::caffe::TransformationParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.transform_param)
- return transform_param_;
-}
-::caffe::TransformationParameter* LayerParameter::release_transform_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.transform_param)
- clear_has_transform_param();
- ::caffe::TransformationParameter* temp = transform_param_;
- transform_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_transform_param(::caffe::TransformationParameter* transform_param) {
- delete transform_param_;
- transform_param_ = transform_param;
- if (transform_param) {
- set_has_transform_param();
- } else {
- clear_has_transform_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.transform_param)
-}
-
-// optional .caffe.LossParameter loss_param = 101;
-bool LayerParameter::has_loss_param() const {
- return (_has_bits_[0] & 0x00001000u) != 0;
-}
-void LayerParameter::set_has_loss_param() {
- _has_bits_[0] |= 0x00001000u;
-}
-void LayerParameter::clear_has_loss_param() {
- _has_bits_[0] &= ~0x00001000u;
-}
-void LayerParameter::clear_loss_param() {
- if (loss_param_ != NULL) loss_param_->::caffe::LossParameter::Clear();
- clear_has_loss_param();
-}
-const ::caffe::LossParameter& LayerParameter::loss_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.loss_param)
- return loss_param_ != NULL ? *loss_param_
- : *::caffe::LossParameter::internal_default_instance();
-}
-::caffe::LossParameter* LayerParameter::mutable_loss_param() {
- set_has_loss_param();
- if (loss_param_ == NULL) {
- loss_param_ = new ::caffe::LossParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.loss_param)
- return loss_param_;
-}
-::caffe::LossParameter* LayerParameter::release_loss_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.loss_param)
- clear_has_loss_param();
- ::caffe::LossParameter* temp = loss_param_;
- loss_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_loss_param(::caffe::LossParameter* loss_param) {
- delete loss_param_;
- loss_param_ = loss_param;
- if (loss_param) {
- set_has_loss_param();
- } else {
- clear_has_loss_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.loss_param)
-}
-
-// optional .caffe.AccuracyParameter accuracy_param = 102;
-bool LayerParameter::has_accuracy_param() const {
- return (_has_bits_[0] & 0x00002000u) != 0;
-}
-void LayerParameter::set_has_accuracy_param() {
- _has_bits_[0] |= 0x00002000u;
-}
-void LayerParameter::clear_has_accuracy_param() {
- _has_bits_[0] &= ~0x00002000u;
-}
-void LayerParameter::clear_accuracy_param() {
- if (accuracy_param_ != NULL) accuracy_param_->::caffe::AccuracyParameter::Clear();
- clear_has_accuracy_param();
-}
-const ::caffe::AccuracyParameter& LayerParameter::accuracy_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.accuracy_param)
- return accuracy_param_ != NULL ? *accuracy_param_
- : *::caffe::AccuracyParameter::internal_default_instance();
-}
-::caffe::AccuracyParameter* LayerParameter::mutable_accuracy_param() {
- set_has_accuracy_param();
- if (accuracy_param_ == NULL) {
- accuracy_param_ = new ::caffe::AccuracyParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.accuracy_param)
- return accuracy_param_;
-}
-::caffe::AccuracyParameter* LayerParameter::release_accuracy_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.accuracy_param)
- clear_has_accuracy_param();
- ::caffe::AccuracyParameter* temp = accuracy_param_;
- accuracy_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_accuracy_param(::caffe::AccuracyParameter* accuracy_param) {
- delete accuracy_param_;
- accuracy_param_ = accuracy_param;
- if (accuracy_param) {
- set_has_accuracy_param();
- } else {
- clear_has_accuracy_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.accuracy_param)
-}
-
-// optional .caffe.ArgMaxParameter argmax_param = 103;
-bool LayerParameter::has_argmax_param() const {
- return (_has_bits_[0] & 0x00004000u) != 0;
-}
-void LayerParameter::set_has_argmax_param() {
- _has_bits_[0] |= 0x00004000u;
-}
-void LayerParameter::clear_has_argmax_param() {
- _has_bits_[0] &= ~0x00004000u;
-}
-void LayerParameter::clear_argmax_param() {
- if (argmax_param_ != NULL) argmax_param_->::caffe::ArgMaxParameter::Clear();
- clear_has_argmax_param();
-}
-const ::caffe::ArgMaxParameter& LayerParameter::argmax_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.argmax_param)
- return argmax_param_ != NULL ? *argmax_param_
- : *::caffe::ArgMaxParameter::internal_default_instance();
-}
-::caffe::ArgMaxParameter* LayerParameter::mutable_argmax_param() {
- set_has_argmax_param();
- if (argmax_param_ == NULL) {
- argmax_param_ = new ::caffe::ArgMaxParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.argmax_param)
- return argmax_param_;
-}
-::caffe::ArgMaxParameter* LayerParameter::release_argmax_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.argmax_param)
- clear_has_argmax_param();
- ::caffe::ArgMaxParameter* temp = argmax_param_;
- argmax_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_argmax_param(::caffe::ArgMaxParameter* argmax_param) {
- delete argmax_param_;
- argmax_param_ = argmax_param;
- if (argmax_param) {
- set_has_argmax_param();
- } else {
- clear_has_argmax_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.argmax_param)
-}
-
-// optional .caffe.ConcatParameter concat_param = 104;
-bool LayerParameter::has_concat_param() const {
- return (_has_bits_[0] & 0x00008000u) != 0;
-}
-void LayerParameter::set_has_concat_param() {
- _has_bits_[0] |= 0x00008000u;
-}
-void LayerParameter::clear_has_concat_param() {
- _has_bits_[0] &= ~0x00008000u;
-}
-void LayerParameter::clear_concat_param() {
- if (concat_param_ != NULL) concat_param_->::caffe::ConcatParameter::Clear();
- clear_has_concat_param();
-}
-const ::caffe::ConcatParameter& LayerParameter::concat_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.concat_param)
- return concat_param_ != NULL ? *concat_param_
- : *::caffe::ConcatParameter::internal_default_instance();
-}
-::caffe::ConcatParameter* LayerParameter::mutable_concat_param() {
- set_has_concat_param();
- if (concat_param_ == NULL) {
- concat_param_ = new ::caffe::ConcatParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.concat_param)
- return concat_param_;
-}
-::caffe::ConcatParameter* LayerParameter::release_concat_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.concat_param)
- clear_has_concat_param();
- ::caffe::ConcatParameter* temp = concat_param_;
- concat_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_concat_param(::caffe::ConcatParameter* concat_param) {
- delete concat_param_;
- concat_param_ = concat_param;
- if (concat_param) {
- set_has_concat_param();
- } else {
- clear_has_concat_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.concat_param)
-}
-
-// optional .caffe.ContrastiveLossParameter contrastive_loss_param = 105;
-bool LayerParameter::has_contrastive_loss_param() const {
- return (_has_bits_[0] & 0x00010000u) != 0;
-}
-void LayerParameter::set_has_contrastive_loss_param() {
- _has_bits_[0] |= 0x00010000u;
-}
-void LayerParameter::clear_has_contrastive_loss_param() {
- _has_bits_[0] &= ~0x00010000u;
-}
-void LayerParameter::clear_contrastive_loss_param() {
- if (contrastive_loss_param_ != NULL) contrastive_loss_param_->::caffe::ContrastiveLossParameter::Clear();
- clear_has_contrastive_loss_param();
-}
-const ::caffe::ContrastiveLossParameter& LayerParameter::contrastive_loss_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.contrastive_loss_param)
- return contrastive_loss_param_ != NULL ? *contrastive_loss_param_
- : *::caffe::ContrastiveLossParameter::internal_default_instance();
-}
-::caffe::ContrastiveLossParameter* LayerParameter::mutable_contrastive_loss_param() {
- set_has_contrastive_loss_param();
- if (contrastive_loss_param_ == NULL) {
- contrastive_loss_param_ = new ::caffe::ContrastiveLossParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.contrastive_loss_param)
- return contrastive_loss_param_;
-}
-::caffe::ContrastiveLossParameter* LayerParameter::release_contrastive_loss_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.contrastive_loss_param)
- clear_has_contrastive_loss_param();
- ::caffe::ContrastiveLossParameter* temp = contrastive_loss_param_;
- contrastive_loss_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_contrastive_loss_param(::caffe::ContrastiveLossParameter* contrastive_loss_param) {
- delete contrastive_loss_param_;
- contrastive_loss_param_ = contrastive_loss_param;
- if (contrastive_loss_param) {
- set_has_contrastive_loss_param();
- } else {
- clear_has_contrastive_loss_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.contrastive_loss_param)
-}
-
-// optional .caffe.ConvolutionParameter convolution_param = 106;
-bool LayerParameter::has_convolution_param() const {
- return (_has_bits_[0] & 0x00020000u) != 0;
-}
-void LayerParameter::set_has_convolution_param() {
- _has_bits_[0] |= 0x00020000u;
-}
-void LayerParameter::clear_has_convolution_param() {
- _has_bits_[0] &= ~0x00020000u;
-}
-void LayerParameter::clear_convolution_param() {
- if (convolution_param_ != NULL) convolution_param_->::caffe::ConvolutionParameter::Clear();
- clear_has_convolution_param();
-}
-const ::caffe::ConvolutionParameter& LayerParameter::convolution_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.convolution_param)
- return convolution_param_ != NULL ? *convolution_param_
- : *::caffe::ConvolutionParameter::internal_default_instance();
-}
-::caffe::ConvolutionParameter* LayerParameter::mutable_convolution_param() {
- set_has_convolution_param();
- if (convolution_param_ == NULL) {
- convolution_param_ = new ::caffe::ConvolutionParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.convolution_param)
- return convolution_param_;
-}
-::caffe::ConvolutionParameter* LayerParameter::release_convolution_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.convolution_param)
- clear_has_convolution_param();
- ::caffe::ConvolutionParameter* temp = convolution_param_;
- convolution_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_convolution_param(::caffe::ConvolutionParameter* convolution_param) {
- delete convolution_param_;
- convolution_param_ = convolution_param;
- if (convolution_param) {
- set_has_convolution_param();
- } else {
- clear_has_convolution_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.convolution_param)
-}
-
-// optional .caffe.CropParameter crop_param = 137;
-bool LayerParameter::has_crop_param() const {
- return (_has_bits_[0] & 0x00040000u) != 0;
-}
-void LayerParameter::set_has_crop_param() {
- _has_bits_[0] |= 0x00040000u;
-}
-void LayerParameter::clear_has_crop_param() {
- _has_bits_[0] &= ~0x00040000u;
-}
-void LayerParameter::clear_crop_param() {
- if (crop_param_ != NULL) crop_param_->::caffe::CropParameter::Clear();
- clear_has_crop_param();
-}
-const ::caffe::CropParameter& LayerParameter::crop_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.crop_param)
- return crop_param_ != NULL ? *crop_param_
- : *::caffe::CropParameter::internal_default_instance();
-}
-::caffe::CropParameter* LayerParameter::mutable_crop_param() {
- set_has_crop_param();
- if (crop_param_ == NULL) {
- crop_param_ = new ::caffe::CropParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.crop_param)
- return crop_param_;
-}
-::caffe::CropParameter* LayerParameter::release_crop_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.crop_param)
- clear_has_crop_param();
- ::caffe::CropParameter* temp = crop_param_;
- crop_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_crop_param(::caffe::CropParameter* crop_param) {
- delete crop_param_;
- crop_param_ = crop_param;
- if (crop_param) {
- set_has_crop_param();
- } else {
- clear_has_crop_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.crop_param)
-}
-
-// optional .caffe.DataParameter data_param = 107;
-bool LayerParameter::has_data_param() const {
- return (_has_bits_[0] & 0x00080000u) != 0;
-}
-void LayerParameter::set_has_data_param() {
- _has_bits_[0] |= 0x00080000u;
-}
-void LayerParameter::clear_has_data_param() {
- _has_bits_[0] &= ~0x00080000u;
-}
-void LayerParameter::clear_data_param() {
- if (data_param_ != NULL) data_param_->::caffe::DataParameter::Clear();
- clear_has_data_param();
-}
-const ::caffe::DataParameter& LayerParameter::data_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.data_param)
- return data_param_ != NULL ? *data_param_
- : *::caffe::DataParameter::internal_default_instance();
-}
-::caffe::DataParameter* LayerParameter::mutable_data_param() {
- set_has_data_param();
- if (data_param_ == NULL) {
- data_param_ = new ::caffe::DataParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.data_param)
- return data_param_;
-}
-::caffe::DataParameter* LayerParameter::release_data_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.data_param)
- clear_has_data_param();
- ::caffe::DataParameter* temp = data_param_;
- data_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_data_param(::caffe::DataParameter* data_param) {
- delete data_param_;
- data_param_ = data_param;
- if (data_param) {
- set_has_data_param();
- } else {
- clear_has_data_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.data_param)
-}
-
-// optional .caffe.DetectionOutputParameter detection_output_param = 141;
-bool LayerParameter::has_detection_output_param() const {
- return (_has_bits_[0] & 0x00100000u) != 0;
-}
-void LayerParameter::set_has_detection_output_param() {
- _has_bits_[0] |= 0x00100000u;
-}
-void LayerParameter::clear_has_detection_output_param() {
- _has_bits_[0] &= ~0x00100000u;
-}
-void LayerParameter::clear_detection_output_param() {
- if (detection_output_param_ != NULL) detection_output_param_->::caffe::DetectionOutputParameter::Clear();
- clear_has_detection_output_param();
-}
-const ::caffe::DetectionOutputParameter& LayerParameter::detection_output_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.detection_output_param)
- return detection_output_param_ != NULL ? *detection_output_param_
- : *::caffe::DetectionOutputParameter::internal_default_instance();
-}
-::caffe::DetectionOutputParameter* LayerParameter::mutable_detection_output_param() {
- set_has_detection_output_param();
- if (detection_output_param_ == NULL) {
- detection_output_param_ = new ::caffe::DetectionOutputParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.detection_output_param)
- return detection_output_param_;
-}
-::caffe::DetectionOutputParameter* LayerParameter::release_detection_output_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.detection_output_param)
- clear_has_detection_output_param();
- ::caffe::DetectionOutputParameter* temp = detection_output_param_;
- detection_output_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_detection_output_param(::caffe::DetectionOutputParameter* detection_output_param) {
- delete detection_output_param_;
- detection_output_param_ = detection_output_param;
- if (detection_output_param) {
- set_has_detection_output_param();
- } else {
- clear_has_detection_output_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.detection_output_param)
-}
-
-// optional .caffe.DropoutParameter dropout_param = 108;
-bool LayerParameter::has_dropout_param() const {
- return (_has_bits_[0] & 0x00200000u) != 0;
-}
-void LayerParameter::set_has_dropout_param() {
- _has_bits_[0] |= 0x00200000u;
-}
-void LayerParameter::clear_has_dropout_param() {
- _has_bits_[0] &= ~0x00200000u;
-}
-void LayerParameter::clear_dropout_param() {
- if (dropout_param_ != NULL) dropout_param_->::caffe::DropoutParameter::Clear();
- clear_has_dropout_param();
-}
-const ::caffe::DropoutParameter& LayerParameter::dropout_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.dropout_param)
- return dropout_param_ != NULL ? *dropout_param_
- : *::caffe::DropoutParameter::internal_default_instance();
-}
-::caffe::DropoutParameter* LayerParameter::mutable_dropout_param() {
- set_has_dropout_param();
- if (dropout_param_ == NULL) {
- dropout_param_ = new ::caffe::DropoutParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.dropout_param)
- return dropout_param_;
-}
-::caffe::DropoutParameter* LayerParameter::release_dropout_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.dropout_param)
- clear_has_dropout_param();
- ::caffe::DropoutParameter* temp = dropout_param_;
- dropout_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_dropout_param(::caffe::DropoutParameter* dropout_param) {
- delete dropout_param_;
- dropout_param_ = dropout_param;
- if (dropout_param) {
- set_has_dropout_param();
- } else {
- clear_has_dropout_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.dropout_param)
-}
-
-// optional .caffe.DummyDataParameter dummy_data_param = 109;
-bool LayerParameter::has_dummy_data_param() const {
- return (_has_bits_[0] & 0x00400000u) != 0;
-}
-void LayerParameter::set_has_dummy_data_param() {
- _has_bits_[0] |= 0x00400000u;
-}
-void LayerParameter::clear_has_dummy_data_param() {
- _has_bits_[0] &= ~0x00400000u;
-}
-void LayerParameter::clear_dummy_data_param() {
- if (dummy_data_param_ != NULL) dummy_data_param_->::caffe::DummyDataParameter::Clear();
- clear_has_dummy_data_param();
-}
-const ::caffe::DummyDataParameter& LayerParameter::dummy_data_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.dummy_data_param)
- return dummy_data_param_ != NULL ? *dummy_data_param_
- : *::caffe::DummyDataParameter::internal_default_instance();
-}
-::caffe::DummyDataParameter* LayerParameter::mutable_dummy_data_param() {
- set_has_dummy_data_param();
- if (dummy_data_param_ == NULL) {
- dummy_data_param_ = new ::caffe::DummyDataParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.dummy_data_param)
- return dummy_data_param_;
-}
-::caffe::DummyDataParameter* LayerParameter::release_dummy_data_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.dummy_data_param)
- clear_has_dummy_data_param();
- ::caffe::DummyDataParameter* temp = dummy_data_param_;
- dummy_data_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_dummy_data_param(::caffe::DummyDataParameter* dummy_data_param) {
- delete dummy_data_param_;
- dummy_data_param_ = dummy_data_param;
- if (dummy_data_param) {
- set_has_dummy_data_param();
- } else {
- clear_has_dummy_data_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.dummy_data_param)
-}
-
-// optional .caffe.EltwiseParameter eltwise_param = 110;
-bool LayerParameter::has_eltwise_param() const {
- return (_has_bits_[0] & 0x00800000u) != 0;
-}
-void LayerParameter::set_has_eltwise_param() {
- _has_bits_[0] |= 0x00800000u;
-}
-void LayerParameter::clear_has_eltwise_param() {
- _has_bits_[0] &= ~0x00800000u;
-}
-void LayerParameter::clear_eltwise_param() {
- if (eltwise_param_ != NULL) eltwise_param_->::caffe::EltwiseParameter::Clear();
- clear_has_eltwise_param();
-}
-const ::caffe::EltwiseParameter& LayerParameter::eltwise_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.eltwise_param)
- return eltwise_param_ != NULL ? *eltwise_param_
- : *::caffe::EltwiseParameter::internal_default_instance();
-}
-::caffe::EltwiseParameter* LayerParameter::mutable_eltwise_param() {
- set_has_eltwise_param();
- if (eltwise_param_ == NULL) {
- eltwise_param_ = new ::caffe::EltwiseParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.eltwise_param)
- return eltwise_param_;
-}
-::caffe::EltwiseParameter* LayerParameter::release_eltwise_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.eltwise_param)
- clear_has_eltwise_param();
- ::caffe::EltwiseParameter* temp = eltwise_param_;
- eltwise_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_eltwise_param(::caffe::EltwiseParameter* eltwise_param) {
- delete eltwise_param_;
- eltwise_param_ = eltwise_param;
- if (eltwise_param) {
- set_has_eltwise_param();
- } else {
- clear_has_eltwise_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.eltwise_param)
-}
-
-// optional .caffe.ExpParameter exp_param = 111;
-bool LayerParameter::has_exp_param() const {
- return (_has_bits_[0] & 0x01000000u) != 0;
-}
-void LayerParameter::set_has_exp_param() {
- _has_bits_[0] |= 0x01000000u;
-}
-void LayerParameter::clear_has_exp_param() {
- _has_bits_[0] &= ~0x01000000u;
-}
-void LayerParameter::clear_exp_param() {
- if (exp_param_ != NULL) exp_param_->::caffe::ExpParameter::Clear();
- clear_has_exp_param();
-}
-const ::caffe::ExpParameter& LayerParameter::exp_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.exp_param)
- return exp_param_ != NULL ? *exp_param_
- : *::caffe::ExpParameter::internal_default_instance();
-}
-::caffe::ExpParameter* LayerParameter::mutable_exp_param() {
- set_has_exp_param();
- if (exp_param_ == NULL) {
- exp_param_ = new ::caffe::ExpParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.exp_param)
- return exp_param_;
-}
-::caffe::ExpParameter* LayerParameter::release_exp_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.exp_param)
- clear_has_exp_param();
- ::caffe::ExpParameter* temp = exp_param_;
- exp_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_exp_param(::caffe::ExpParameter* exp_param) {
- delete exp_param_;
- exp_param_ = exp_param;
- if (exp_param) {
- set_has_exp_param();
- } else {
- clear_has_exp_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.exp_param)
-}
-
-// optional .caffe.FlattenParameter flatten_param = 135;
-bool LayerParameter::has_flatten_param() const {
- return (_has_bits_[0] & 0x02000000u) != 0;
-}
-void LayerParameter::set_has_flatten_param() {
- _has_bits_[0] |= 0x02000000u;
-}
-void LayerParameter::clear_has_flatten_param() {
- _has_bits_[0] &= ~0x02000000u;
-}
-void LayerParameter::clear_flatten_param() {
- if (flatten_param_ != NULL) flatten_param_->::caffe::FlattenParameter::Clear();
- clear_has_flatten_param();
-}
-const ::caffe::FlattenParameter& LayerParameter::flatten_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.flatten_param)
- return flatten_param_ != NULL ? *flatten_param_
- : *::caffe::FlattenParameter::internal_default_instance();
-}
-::caffe::FlattenParameter* LayerParameter::mutable_flatten_param() {
- set_has_flatten_param();
- if (flatten_param_ == NULL) {
- flatten_param_ = new ::caffe::FlattenParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.flatten_param)
- return flatten_param_;
-}
-::caffe::FlattenParameter* LayerParameter::release_flatten_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.flatten_param)
- clear_has_flatten_param();
- ::caffe::FlattenParameter* temp = flatten_param_;
- flatten_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_flatten_param(::caffe::FlattenParameter* flatten_param) {
- delete flatten_param_;
- flatten_param_ = flatten_param;
- if (flatten_param) {
- set_has_flatten_param();
- } else {
- clear_has_flatten_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.flatten_param)
-}
-
-// optional .caffe.HDF5DataParameter hdf5_data_param = 112;
-bool LayerParameter::has_hdf5_data_param() const {
- return (_has_bits_[0] & 0x04000000u) != 0;
-}
-void LayerParameter::set_has_hdf5_data_param() {
- _has_bits_[0] |= 0x04000000u;
-}
-void LayerParameter::clear_has_hdf5_data_param() {
- _has_bits_[0] &= ~0x04000000u;
-}
-void LayerParameter::clear_hdf5_data_param() {
- if (hdf5_data_param_ != NULL) hdf5_data_param_->::caffe::HDF5DataParameter::Clear();
- clear_has_hdf5_data_param();
-}
-const ::caffe::HDF5DataParameter& LayerParameter::hdf5_data_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.hdf5_data_param)
- return hdf5_data_param_ != NULL ? *hdf5_data_param_
- : *::caffe::HDF5DataParameter::internal_default_instance();
-}
-::caffe::HDF5DataParameter* LayerParameter::mutable_hdf5_data_param() {
- set_has_hdf5_data_param();
- if (hdf5_data_param_ == NULL) {
- hdf5_data_param_ = new ::caffe::HDF5DataParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.hdf5_data_param)
- return hdf5_data_param_;
-}
-::caffe::HDF5DataParameter* LayerParameter::release_hdf5_data_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.hdf5_data_param)
- clear_has_hdf5_data_param();
- ::caffe::HDF5DataParameter* temp = hdf5_data_param_;
- hdf5_data_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_hdf5_data_param(::caffe::HDF5DataParameter* hdf5_data_param) {
- delete hdf5_data_param_;
- hdf5_data_param_ = hdf5_data_param;
- if (hdf5_data_param) {
- set_has_hdf5_data_param();
- } else {
- clear_has_hdf5_data_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.hdf5_data_param)
-}
-
-// optional .caffe.HDF5OutputParameter hdf5_output_param = 113;
-bool LayerParameter::has_hdf5_output_param() const {
- return (_has_bits_[0] & 0x08000000u) != 0;
-}
-void LayerParameter::set_has_hdf5_output_param() {
- _has_bits_[0] |= 0x08000000u;
-}
-void LayerParameter::clear_has_hdf5_output_param() {
- _has_bits_[0] &= ~0x08000000u;
-}
-void LayerParameter::clear_hdf5_output_param() {
- if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear();
- clear_has_hdf5_output_param();
-}
-const ::caffe::HDF5OutputParameter& LayerParameter::hdf5_output_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.hdf5_output_param)
- return hdf5_output_param_ != NULL ? *hdf5_output_param_
- : *::caffe::HDF5OutputParameter::internal_default_instance();
-}
-::caffe::HDF5OutputParameter* LayerParameter::mutable_hdf5_output_param() {
- set_has_hdf5_output_param();
- if (hdf5_output_param_ == NULL) {
- hdf5_output_param_ = new ::caffe::HDF5OutputParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.hdf5_output_param)
- return hdf5_output_param_;
-}
-::caffe::HDF5OutputParameter* LayerParameter::release_hdf5_output_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.hdf5_output_param)
- clear_has_hdf5_output_param();
- ::caffe::HDF5OutputParameter* temp = hdf5_output_param_;
- hdf5_output_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param) {
- delete hdf5_output_param_;
- hdf5_output_param_ = hdf5_output_param;
- if (hdf5_output_param) {
- set_has_hdf5_output_param();
- } else {
- clear_has_hdf5_output_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.hdf5_output_param)
-}
-
-// optional .caffe.HingeLossParameter hinge_loss_param = 114;
-bool LayerParameter::has_hinge_loss_param() const {
- return (_has_bits_[0] & 0x10000000u) != 0;
-}
-void LayerParameter::set_has_hinge_loss_param() {
- _has_bits_[0] |= 0x10000000u;
-}
-void LayerParameter::clear_has_hinge_loss_param() {
- _has_bits_[0] &= ~0x10000000u;
-}
-void LayerParameter::clear_hinge_loss_param() {
- if (hinge_loss_param_ != NULL) hinge_loss_param_->::caffe::HingeLossParameter::Clear();
- clear_has_hinge_loss_param();
-}
-const ::caffe::HingeLossParameter& LayerParameter::hinge_loss_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.hinge_loss_param)
- return hinge_loss_param_ != NULL ? *hinge_loss_param_
- : *::caffe::HingeLossParameter::internal_default_instance();
-}
-::caffe::HingeLossParameter* LayerParameter::mutable_hinge_loss_param() {
- set_has_hinge_loss_param();
- if (hinge_loss_param_ == NULL) {
- hinge_loss_param_ = new ::caffe::HingeLossParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.hinge_loss_param)
- return hinge_loss_param_;
-}
-::caffe::HingeLossParameter* LayerParameter::release_hinge_loss_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.hinge_loss_param)
- clear_has_hinge_loss_param();
- ::caffe::HingeLossParameter* temp = hinge_loss_param_;
- hinge_loss_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_hinge_loss_param(::caffe::HingeLossParameter* hinge_loss_param) {
- delete hinge_loss_param_;
- hinge_loss_param_ = hinge_loss_param;
- if (hinge_loss_param) {
- set_has_hinge_loss_param();
- } else {
- clear_has_hinge_loss_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.hinge_loss_param)
-}
-
-// optional .caffe.ImageDataParameter image_data_param = 115;
-bool LayerParameter::has_image_data_param() const {
- return (_has_bits_[0] & 0x20000000u) != 0;
-}
-void LayerParameter::set_has_image_data_param() {
- _has_bits_[0] |= 0x20000000u;
-}
-void LayerParameter::clear_has_image_data_param() {
- _has_bits_[0] &= ~0x20000000u;
-}
-void LayerParameter::clear_image_data_param() {
- if (image_data_param_ != NULL) image_data_param_->::caffe::ImageDataParameter::Clear();
- clear_has_image_data_param();
-}
-const ::caffe::ImageDataParameter& LayerParameter::image_data_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.image_data_param)
- return image_data_param_ != NULL ? *image_data_param_
- : *::caffe::ImageDataParameter::internal_default_instance();
-}
-::caffe::ImageDataParameter* LayerParameter::mutable_image_data_param() {
- set_has_image_data_param();
- if (image_data_param_ == NULL) {
- image_data_param_ = new ::caffe::ImageDataParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.image_data_param)
- return image_data_param_;
-}
-::caffe::ImageDataParameter* LayerParameter::release_image_data_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.image_data_param)
- clear_has_image_data_param();
- ::caffe::ImageDataParameter* temp = image_data_param_;
- image_data_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_image_data_param(::caffe::ImageDataParameter* image_data_param) {
- delete image_data_param_;
- image_data_param_ = image_data_param;
- if (image_data_param) {
- set_has_image_data_param();
- } else {
- clear_has_image_data_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.image_data_param)
-}
-
-// optional .caffe.InfogainLossParameter infogain_loss_param = 116;
-bool LayerParameter::has_infogain_loss_param() const {
- return (_has_bits_[0] & 0x40000000u) != 0;
-}
-void LayerParameter::set_has_infogain_loss_param() {
- _has_bits_[0] |= 0x40000000u;
-}
-void LayerParameter::clear_has_infogain_loss_param() {
- _has_bits_[0] &= ~0x40000000u;
-}
-void LayerParameter::clear_infogain_loss_param() {
- if (infogain_loss_param_ != NULL) infogain_loss_param_->::caffe::InfogainLossParameter::Clear();
- clear_has_infogain_loss_param();
-}
-const ::caffe::InfogainLossParameter& LayerParameter::infogain_loss_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.infogain_loss_param)
- return infogain_loss_param_ != NULL ? *infogain_loss_param_
- : *::caffe::InfogainLossParameter::internal_default_instance();
-}
-::caffe::InfogainLossParameter* LayerParameter::mutable_infogain_loss_param() {
- set_has_infogain_loss_param();
- if (infogain_loss_param_ == NULL) {
- infogain_loss_param_ = new ::caffe::InfogainLossParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.infogain_loss_param)
- return infogain_loss_param_;
-}
-::caffe::InfogainLossParameter* LayerParameter::release_infogain_loss_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.infogain_loss_param)
- clear_has_infogain_loss_param();
- ::caffe::InfogainLossParameter* temp = infogain_loss_param_;
- infogain_loss_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_infogain_loss_param(::caffe::InfogainLossParameter* infogain_loss_param) {
- delete infogain_loss_param_;
- infogain_loss_param_ = infogain_loss_param;
- if (infogain_loss_param) {
- set_has_infogain_loss_param();
- } else {
- clear_has_infogain_loss_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.infogain_loss_param)
-}
-
-// optional .caffe.InnerProductParameter inner_product_param = 117;
-bool LayerParameter::has_inner_product_param() const {
- return (_has_bits_[0] & 0x80000000u) != 0;
-}
-void LayerParameter::set_has_inner_product_param() {
- _has_bits_[0] |= 0x80000000u;
-}
-void LayerParameter::clear_has_inner_product_param() {
- _has_bits_[0] &= ~0x80000000u;
-}
-void LayerParameter::clear_inner_product_param() {
- if (inner_product_param_ != NULL) inner_product_param_->::caffe::InnerProductParameter::Clear();
- clear_has_inner_product_param();
-}
-const ::caffe::InnerProductParameter& LayerParameter::inner_product_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.inner_product_param)
- return inner_product_param_ != NULL ? *inner_product_param_
- : *::caffe::InnerProductParameter::internal_default_instance();
-}
-::caffe::InnerProductParameter* LayerParameter::mutable_inner_product_param() {
- set_has_inner_product_param();
- if (inner_product_param_ == NULL) {
- inner_product_param_ = new ::caffe::InnerProductParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.inner_product_param)
- return inner_product_param_;
-}
-::caffe::InnerProductParameter* LayerParameter::release_inner_product_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.inner_product_param)
- clear_has_inner_product_param();
- ::caffe::InnerProductParameter* temp = inner_product_param_;
- inner_product_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_inner_product_param(::caffe::InnerProductParameter* inner_product_param) {
- delete inner_product_param_;
- inner_product_param_ = inner_product_param;
- if (inner_product_param) {
- set_has_inner_product_param();
- } else {
- clear_has_inner_product_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.inner_product_param)
-}
-
-// optional .caffe.LogParameter log_param = 134;
-bool LayerParameter::has_log_param() const {
- return (_has_bits_[1] & 0x00000001u) != 0;
-}
-void LayerParameter::set_has_log_param() {
- _has_bits_[1] |= 0x00000001u;
-}
-void LayerParameter::clear_has_log_param() {
- _has_bits_[1] &= ~0x00000001u;
-}
-void LayerParameter::clear_log_param() {
- if (log_param_ != NULL) log_param_->::caffe::LogParameter::Clear();
- clear_has_log_param();
-}
-const ::caffe::LogParameter& LayerParameter::log_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.log_param)
- return log_param_ != NULL ? *log_param_
- : *::caffe::LogParameter::internal_default_instance();
-}
-::caffe::LogParameter* LayerParameter::mutable_log_param() {
- set_has_log_param();
- if (log_param_ == NULL) {
- log_param_ = new ::caffe::LogParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.log_param)
- return log_param_;
-}
-::caffe::LogParameter* LayerParameter::release_log_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.log_param)
- clear_has_log_param();
- ::caffe::LogParameter* temp = log_param_;
- log_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_log_param(::caffe::LogParameter* log_param) {
- delete log_param_;
- log_param_ = log_param;
- if (log_param) {
- set_has_log_param();
- } else {
- clear_has_log_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.log_param)
-}
-
-// optional .caffe.LRNParameter lrn_param = 118;
-bool LayerParameter::has_lrn_param() const {
- return (_has_bits_[1] & 0x00000002u) != 0;
-}
-void LayerParameter::set_has_lrn_param() {
- _has_bits_[1] |= 0x00000002u;
-}
-void LayerParameter::clear_has_lrn_param() {
- _has_bits_[1] &= ~0x00000002u;
-}
-void LayerParameter::clear_lrn_param() {
- if (lrn_param_ != NULL) lrn_param_->::caffe::LRNParameter::Clear();
- clear_has_lrn_param();
-}
-const ::caffe::LRNParameter& LayerParameter::lrn_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.lrn_param)
- return lrn_param_ != NULL ? *lrn_param_
- : *::caffe::LRNParameter::internal_default_instance();
-}
-::caffe::LRNParameter* LayerParameter::mutable_lrn_param() {
- set_has_lrn_param();
- if (lrn_param_ == NULL) {
- lrn_param_ = new ::caffe::LRNParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.lrn_param)
- return lrn_param_;
-}
-::caffe::LRNParameter* LayerParameter::release_lrn_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.lrn_param)
- clear_has_lrn_param();
- ::caffe::LRNParameter* temp = lrn_param_;
- lrn_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_lrn_param(::caffe::LRNParameter* lrn_param) {
- delete lrn_param_;
- lrn_param_ = lrn_param;
- if (lrn_param) {
- set_has_lrn_param();
- } else {
- clear_has_lrn_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.lrn_param)
-}
-
-// optional .caffe.MemoryDataParameter memory_data_param = 119;
-bool LayerParameter::has_memory_data_param() const {
- return (_has_bits_[1] & 0x00000004u) != 0;
-}
-void LayerParameter::set_has_memory_data_param() {
- _has_bits_[1] |= 0x00000004u;
-}
-void LayerParameter::clear_has_memory_data_param() {
- _has_bits_[1] &= ~0x00000004u;
-}
-void LayerParameter::clear_memory_data_param() {
- if (memory_data_param_ != NULL) memory_data_param_->::caffe::MemoryDataParameter::Clear();
- clear_has_memory_data_param();
-}
-const ::caffe::MemoryDataParameter& LayerParameter::memory_data_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.memory_data_param)
- return memory_data_param_ != NULL ? *memory_data_param_
- : *::caffe::MemoryDataParameter::internal_default_instance();
-}
-::caffe::MemoryDataParameter* LayerParameter::mutable_memory_data_param() {
- set_has_memory_data_param();
- if (memory_data_param_ == NULL) {
- memory_data_param_ = new ::caffe::MemoryDataParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.memory_data_param)
- return memory_data_param_;
-}
-::caffe::MemoryDataParameter* LayerParameter::release_memory_data_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.memory_data_param)
- clear_has_memory_data_param();
- ::caffe::MemoryDataParameter* temp = memory_data_param_;
- memory_data_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_memory_data_param(::caffe::MemoryDataParameter* memory_data_param) {
- delete memory_data_param_;
- memory_data_param_ = memory_data_param;
- if (memory_data_param) {
- set_has_memory_data_param();
- } else {
- clear_has_memory_data_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.memory_data_param)
-}
-
-// optional .caffe.MVNParameter mvn_param = 120;
-bool LayerParameter::has_mvn_param() const {
- return (_has_bits_[1] & 0x00000008u) != 0;
-}
-void LayerParameter::set_has_mvn_param() {
- _has_bits_[1] |= 0x00000008u;
-}
-void LayerParameter::clear_has_mvn_param() {
- _has_bits_[1] &= ~0x00000008u;
-}
-void LayerParameter::clear_mvn_param() {
- if (mvn_param_ != NULL) mvn_param_->::caffe::MVNParameter::Clear();
- clear_has_mvn_param();
-}
-const ::caffe::MVNParameter& LayerParameter::mvn_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.mvn_param)
- return mvn_param_ != NULL ? *mvn_param_
- : *::caffe::MVNParameter::internal_default_instance();
-}
-::caffe::MVNParameter* LayerParameter::mutable_mvn_param() {
- set_has_mvn_param();
- if (mvn_param_ == NULL) {
- mvn_param_ = new ::caffe::MVNParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.mvn_param)
- return mvn_param_;
-}
-::caffe::MVNParameter* LayerParameter::release_mvn_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.mvn_param)
- clear_has_mvn_param();
- ::caffe::MVNParameter* temp = mvn_param_;
- mvn_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_mvn_param(::caffe::MVNParameter* mvn_param) {
- delete mvn_param_;
- mvn_param_ = mvn_param;
- if (mvn_param) {
- set_has_mvn_param();
- } else {
- clear_has_mvn_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.mvn_param)
-}
-
-// optional .caffe.NormalizeBBoxParameter normalize_bbox_param = 139;
-bool LayerParameter::has_normalize_bbox_param() const {
- return (_has_bits_[1] & 0x00000010u) != 0;
-}
-void LayerParameter::set_has_normalize_bbox_param() {
- _has_bits_[1] |= 0x00000010u;
-}
-void LayerParameter::clear_has_normalize_bbox_param() {
- _has_bits_[1] &= ~0x00000010u;
-}
-void LayerParameter::clear_normalize_bbox_param() {
- if (normalize_bbox_param_ != NULL) normalize_bbox_param_->::caffe::NormalizeBBoxParameter::Clear();
- clear_has_normalize_bbox_param();
-}
-const ::caffe::NormalizeBBoxParameter& LayerParameter::normalize_bbox_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.normalize_bbox_param)
- return normalize_bbox_param_ != NULL ? *normalize_bbox_param_
- : *::caffe::NormalizeBBoxParameter::internal_default_instance();
-}
-::caffe::NormalizeBBoxParameter* LayerParameter::mutable_normalize_bbox_param() {
- set_has_normalize_bbox_param();
- if (normalize_bbox_param_ == NULL) {
- normalize_bbox_param_ = new ::caffe::NormalizeBBoxParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.normalize_bbox_param)
- return normalize_bbox_param_;
-}
-::caffe::NormalizeBBoxParameter* LayerParameter::release_normalize_bbox_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.normalize_bbox_param)
- clear_has_normalize_bbox_param();
- ::caffe::NormalizeBBoxParameter* temp = normalize_bbox_param_;
- normalize_bbox_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_normalize_bbox_param(::caffe::NormalizeBBoxParameter* normalize_bbox_param) {
- delete normalize_bbox_param_;
- normalize_bbox_param_ = normalize_bbox_param;
- if (normalize_bbox_param) {
- set_has_normalize_bbox_param();
- } else {
- clear_has_normalize_bbox_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.normalize_bbox_param)
-}
-
-// optional .caffe.PermuteParameter permute_param = 138;
-bool LayerParameter::has_permute_param() const {
- return (_has_bits_[1] & 0x00000020u) != 0;
-}
-void LayerParameter::set_has_permute_param() {
- _has_bits_[1] |= 0x00000020u;
-}
-void LayerParameter::clear_has_permute_param() {
- _has_bits_[1] &= ~0x00000020u;
-}
-void LayerParameter::clear_permute_param() {
- if (permute_param_ != NULL) permute_param_->::caffe::PermuteParameter::Clear();
- clear_has_permute_param();
-}
-const ::caffe::PermuteParameter& LayerParameter::permute_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.permute_param)
- return permute_param_ != NULL ? *permute_param_
- : *::caffe::PermuteParameter::internal_default_instance();
-}
-::caffe::PermuteParameter* LayerParameter::mutable_permute_param() {
- set_has_permute_param();
- if (permute_param_ == NULL) {
- permute_param_ = new ::caffe::PermuteParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.permute_param)
- return permute_param_;
-}
-::caffe::PermuteParameter* LayerParameter::release_permute_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.permute_param)
- clear_has_permute_param();
- ::caffe::PermuteParameter* temp = permute_param_;
- permute_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_permute_param(::caffe::PermuteParameter* permute_param) {
- delete permute_param_;
- permute_param_ = permute_param;
- if (permute_param) {
- set_has_permute_param();
- } else {
- clear_has_permute_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.permute_param)
-}
-
-// optional .caffe.PoolingParameter pooling_param = 121;
-bool LayerParameter::has_pooling_param() const {
- return (_has_bits_[1] & 0x00000040u) != 0;
-}
-void LayerParameter::set_has_pooling_param() {
- _has_bits_[1] |= 0x00000040u;
-}
-void LayerParameter::clear_has_pooling_param() {
- _has_bits_[1] &= ~0x00000040u;
-}
-void LayerParameter::clear_pooling_param() {
- if (pooling_param_ != NULL) pooling_param_->::caffe::PoolingParameter::Clear();
- clear_has_pooling_param();
-}
-const ::caffe::PoolingParameter& LayerParameter::pooling_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.pooling_param)
- return pooling_param_ != NULL ? *pooling_param_
- : *::caffe::PoolingParameter::internal_default_instance();
-}
-::caffe::PoolingParameter* LayerParameter::mutable_pooling_param() {
- set_has_pooling_param();
- if (pooling_param_ == NULL) {
- pooling_param_ = new ::caffe::PoolingParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.pooling_param)
- return pooling_param_;
-}
-::caffe::PoolingParameter* LayerParameter::release_pooling_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.pooling_param)
- clear_has_pooling_param();
- ::caffe::PoolingParameter* temp = pooling_param_;
- pooling_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_pooling_param(::caffe::PoolingParameter* pooling_param) {
- delete pooling_param_;
- pooling_param_ = pooling_param;
- if (pooling_param) {
- set_has_pooling_param();
- } else {
- clear_has_pooling_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.pooling_param)
-}
-
-// optional .caffe.PowerParameter power_param = 122;
-bool LayerParameter::has_power_param() const {
- return (_has_bits_[1] & 0x00000080u) != 0;
-}
-void LayerParameter::set_has_power_param() {
- _has_bits_[1] |= 0x00000080u;
-}
-void LayerParameter::clear_has_power_param() {
- _has_bits_[1] &= ~0x00000080u;
-}
-void LayerParameter::clear_power_param() {
- if (power_param_ != NULL) power_param_->::caffe::PowerParameter::Clear();
- clear_has_power_param();
-}
-const ::caffe::PowerParameter& LayerParameter::power_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.power_param)
- return power_param_ != NULL ? *power_param_
- : *::caffe::PowerParameter::internal_default_instance();
-}
-::caffe::PowerParameter* LayerParameter::mutable_power_param() {
- set_has_power_param();
- if (power_param_ == NULL) {
- power_param_ = new ::caffe::PowerParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.power_param)
- return power_param_;
-}
-::caffe::PowerParameter* LayerParameter::release_power_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.power_param)
- clear_has_power_param();
- ::caffe::PowerParameter* temp = power_param_;
- power_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_power_param(::caffe::PowerParameter* power_param) {
- delete power_param_;
- power_param_ = power_param;
- if (power_param) {
- set_has_power_param();
- } else {
- clear_has_power_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.power_param)
-}
-
-// optional .caffe.PReLUParameter prelu_param = 131;
-bool LayerParameter::has_prelu_param() const {
- return (_has_bits_[1] & 0x00000100u) != 0;
-}
-void LayerParameter::set_has_prelu_param() {
- _has_bits_[1] |= 0x00000100u;
-}
-void LayerParameter::clear_has_prelu_param() {
- _has_bits_[1] &= ~0x00000100u;
-}
-void LayerParameter::clear_prelu_param() {
- if (prelu_param_ != NULL) prelu_param_->::caffe::PReLUParameter::Clear();
- clear_has_prelu_param();
-}
-const ::caffe::PReLUParameter& LayerParameter::prelu_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.prelu_param)
- return prelu_param_ != NULL ? *prelu_param_
- : *::caffe::PReLUParameter::internal_default_instance();
-}
-::caffe::PReLUParameter* LayerParameter::mutable_prelu_param() {
- set_has_prelu_param();
- if (prelu_param_ == NULL) {
- prelu_param_ = new ::caffe::PReLUParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.prelu_param)
- return prelu_param_;
-}
-::caffe::PReLUParameter* LayerParameter::release_prelu_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.prelu_param)
- clear_has_prelu_param();
- ::caffe::PReLUParameter* temp = prelu_param_;
- prelu_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_prelu_param(::caffe::PReLUParameter* prelu_param) {
- delete prelu_param_;
- prelu_param_ = prelu_param;
- if (prelu_param) {
- set_has_prelu_param();
- } else {
- clear_has_prelu_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.prelu_param)
-}
-
-// optional .caffe.PriorBoxParameter prior_box_param = 140;
-bool LayerParameter::has_prior_box_param() const {
- return (_has_bits_[1] & 0x00000200u) != 0;
-}
-void LayerParameter::set_has_prior_box_param() {
- _has_bits_[1] |= 0x00000200u;
-}
-void LayerParameter::clear_has_prior_box_param() {
- _has_bits_[1] &= ~0x00000200u;
-}
-void LayerParameter::clear_prior_box_param() {
- if (prior_box_param_ != NULL) prior_box_param_->::caffe::PriorBoxParameter::Clear();
- clear_has_prior_box_param();
-}
-const ::caffe::PriorBoxParameter& LayerParameter::prior_box_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.prior_box_param)
- return prior_box_param_ != NULL ? *prior_box_param_
- : *::caffe::PriorBoxParameter::internal_default_instance();
-}
-::caffe::PriorBoxParameter* LayerParameter::mutable_prior_box_param() {
- set_has_prior_box_param();
- if (prior_box_param_ == NULL) {
- prior_box_param_ = new ::caffe::PriorBoxParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.prior_box_param)
- return prior_box_param_;
-}
-::caffe::PriorBoxParameter* LayerParameter::release_prior_box_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.prior_box_param)
- clear_has_prior_box_param();
- ::caffe::PriorBoxParameter* temp = prior_box_param_;
- prior_box_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_prior_box_param(::caffe::PriorBoxParameter* prior_box_param) {
- delete prior_box_param_;
- prior_box_param_ = prior_box_param;
- if (prior_box_param) {
- set_has_prior_box_param();
- } else {
- clear_has_prior_box_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.prior_box_param)
-}
-
-// optional .caffe.PythonParameter python_param = 130;
-bool LayerParameter::has_python_param() const {
- return (_has_bits_[1] & 0x00000400u) != 0;
-}
-void LayerParameter::set_has_python_param() {
- _has_bits_[1] |= 0x00000400u;
-}
-void LayerParameter::clear_has_python_param() {
- _has_bits_[1] &= ~0x00000400u;
-}
-void LayerParameter::clear_python_param() {
- if (python_param_ != NULL) python_param_->::caffe::PythonParameter::Clear();
- clear_has_python_param();
-}
-const ::caffe::PythonParameter& LayerParameter::python_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.python_param)
- return python_param_ != NULL ? *python_param_
- : *::caffe::PythonParameter::internal_default_instance();
-}
-::caffe::PythonParameter* LayerParameter::mutable_python_param() {
- set_has_python_param();
- if (python_param_ == NULL) {
- python_param_ = new ::caffe::PythonParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.python_param)
- return python_param_;
-}
-::caffe::PythonParameter* LayerParameter::release_python_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.python_param)
- clear_has_python_param();
- ::caffe::PythonParameter* temp = python_param_;
- python_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_python_param(::caffe::PythonParameter* python_param) {
- delete python_param_;
- python_param_ = python_param;
- if (python_param) {
- set_has_python_param();
- } else {
- clear_has_python_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.python_param)
-}
-
-// optional .caffe.ReductionParameter reduction_param = 136;
-bool LayerParameter::has_reduction_param() const {
- return (_has_bits_[1] & 0x00000800u) != 0;
-}
-void LayerParameter::set_has_reduction_param() {
- _has_bits_[1] |= 0x00000800u;
-}
-void LayerParameter::clear_has_reduction_param() {
- _has_bits_[1] &= ~0x00000800u;
-}
-void LayerParameter::clear_reduction_param() {
- if (reduction_param_ != NULL) reduction_param_->::caffe::ReductionParameter::Clear();
- clear_has_reduction_param();
-}
-const ::caffe::ReductionParameter& LayerParameter::reduction_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.reduction_param)
- return reduction_param_ != NULL ? *reduction_param_
- : *::caffe::ReductionParameter::internal_default_instance();
-}
-::caffe::ReductionParameter* LayerParameter::mutable_reduction_param() {
- set_has_reduction_param();
- if (reduction_param_ == NULL) {
- reduction_param_ = new ::caffe::ReductionParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.reduction_param)
- return reduction_param_;
-}
-::caffe::ReductionParameter* LayerParameter::release_reduction_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.reduction_param)
- clear_has_reduction_param();
- ::caffe::ReductionParameter* temp = reduction_param_;
- reduction_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_reduction_param(::caffe::ReductionParameter* reduction_param) {
- delete reduction_param_;
- reduction_param_ = reduction_param;
- if (reduction_param) {
- set_has_reduction_param();
- } else {
- clear_has_reduction_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.reduction_param)
-}
-
-// optional .caffe.ReLUParameter relu_param = 123;
-bool LayerParameter::has_relu_param() const {
- return (_has_bits_[1] & 0x00001000u) != 0;
-}
-void LayerParameter::set_has_relu_param() {
- _has_bits_[1] |= 0x00001000u;
-}
-void LayerParameter::clear_has_relu_param() {
- _has_bits_[1] &= ~0x00001000u;
-}
-void LayerParameter::clear_relu_param() {
- if (relu_param_ != NULL) relu_param_->::caffe::ReLUParameter::Clear();
- clear_has_relu_param();
-}
-const ::caffe::ReLUParameter& LayerParameter::relu_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.relu_param)
- return relu_param_ != NULL ? *relu_param_
- : *::caffe::ReLUParameter::internal_default_instance();
-}
-::caffe::ReLUParameter* LayerParameter::mutable_relu_param() {
- set_has_relu_param();
- if (relu_param_ == NULL) {
- relu_param_ = new ::caffe::ReLUParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.relu_param)
- return relu_param_;
-}
-::caffe::ReLUParameter* LayerParameter::release_relu_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.relu_param)
- clear_has_relu_param();
- ::caffe::ReLUParameter* temp = relu_param_;
- relu_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_relu_param(::caffe::ReLUParameter* relu_param) {
- delete relu_param_;
- relu_param_ = relu_param;
- if (relu_param) {
- set_has_relu_param();
- } else {
- clear_has_relu_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.relu_param)
-}
-
-// optional .caffe.ReshapeParameter reshape_param = 133;
-bool LayerParameter::has_reshape_param() const {
- return (_has_bits_[1] & 0x00002000u) != 0;
-}
-void LayerParameter::set_has_reshape_param() {
- _has_bits_[1] |= 0x00002000u;
-}
-void LayerParameter::clear_has_reshape_param() {
- _has_bits_[1] &= ~0x00002000u;
-}
-void LayerParameter::clear_reshape_param() {
- if (reshape_param_ != NULL) reshape_param_->::caffe::ReshapeParameter::Clear();
- clear_has_reshape_param();
-}
-const ::caffe::ReshapeParameter& LayerParameter::reshape_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.reshape_param)
- return reshape_param_ != NULL ? *reshape_param_
- : *::caffe::ReshapeParameter::internal_default_instance();
-}
-::caffe::ReshapeParameter* LayerParameter::mutable_reshape_param() {
- set_has_reshape_param();
- if (reshape_param_ == NULL) {
- reshape_param_ = new ::caffe::ReshapeParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.reshape_param)
- return reshape_param_;
-}
-::caffe::ReshapeParameter* LayerParameter::release_reshape_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.reshape_param)
- clear_has_reshape_param();
- ::caffe::ReshapeParameter* temp = reshape_param_;
- reshape_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_reshape_param(::caffe::ReshapeParameter* reshape_param) {
- delete reshape_param_;
- reshape_param_ = reshape_param;
- if (reshape_param) {
- set_has_reshape_param();
- } else {
- clear_has_reshape_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.reshape_param)
-}
-
-// optional .caffe.SigmoidParameter sigmoid_param = 124;
-bool LayerParameter::has_sigmoid_param() const {
- return (_has_bits_[1] & 0x00004000u) != 0;
-}
-void LayerParameter::set_has_sigmoid_param() {
- _has_bits_[1] |= 0x00004000u;
-}
-void LayerParameter::clear_has_sigmoid_param() {
- _has_bits_[1] &= ~0x00004000u;
-}
-void LayerParameter::clear_sigmoid_param() {
- if (sigmoid_param_ != NULL) sigmoid_param_->::caffe::SigmoidParameter::Clear();
- clear_has_sigmoid_param();
-}
-const ::caffe::SigmoidParameter& LayerParameter::sigmoid_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.sigmoid_param)
- return sigmoid_param_ != NULL ? *sigmoid_param_
- : *::caffe::SigmoidParameter::internal_default_instance();
-}
-::caffe::SigmoidParameter* LayerParameter::mutable_sigmoid_param() {
- set_has_sigmoid_param();
- if (sigmoid_param_ == NULL) {
- sigmoid_param_ = new ::caffe::SigmoidParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.sigmoid_param)
- return sigmoid_param_;
-}
-::caffe::SigmoidParameter* LayerParameter::release_sigmoid_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.sigmoid_param)
- clear_has_sigmoid_param();
- ::caffe::SigmoidParameter* temp = sigmoid_param_;
- sigmoid_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_sigmoid_param(::caffe::SigmoidParameter* sigmoid_param) {
- delete sigmoid_param_;
- sigmoid_param_ = sigmoid_param;
- if (sigmoid_param) {
- set_has_sigmoid_param();
- } else {
- clear_has_sigmoid_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.sigmoid_param)
-}
-
-// optional .caffe.SliceParameter slice_param = 126;
-bool LayerParameter::has_slice_param() const {
- return (_has_bits_[1] & 0x00008000u) != 0;
-}
-void LayerParameter::set_has_slice_param() {
- _has_bits_[1] |= 0x00008000u;
-}
-void LayerParameter::clear_has_slice_param() {
- _has_bits_[1] &= ~0x00008000u;
-}
-void LayerParameter::clear_slice_param() {
- if (slice_param_ != NULL) slice_param_->::caffe::SliceParameter::Clear();
- clear_has_slice_param();
-}
-const ::caffe::SliceParameter& LayerParameter::slice_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.slice_param)
- return slice_param_ != NULL ? *slice_param_
- : *::caffe::SliceParameter::internal_default_instance();
-}
-::caffe::SliceParameter* LayerParameter::mutable_slice_param() {
- set_has_slice_param();
- if (slice_param_ == NULL) {
- slice_param_ = new ::caffe::SliceParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.slice_param)
- return slice_param_;
-}
-::caffe::SliceParameter* LayerParameter::release_slice_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.slice_param)
- clear_has_slice_param();
- ::caffe::SliceParameter* temp = slice_param_;
- slice_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_slice_param(::caffe::SliceParameter* slice_param) {
- delete slice_param_;
- slice_param_ = slice_param;
- if (slice_param) {
- set_has_slice_param();
- } else {
- clear_has_slice_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.slice_param)
-}
-
-// optional .caffe.SoftmaxParameter softmax_param = 125;
-bool LayerParameter::has_softmax_param() const {
- return (_has_bits_[1] & 0x00010000u) != 0;
-}
-void LayerParameter::set_has_softmax_param() {
- _has_bits_[1] |= 0x00010000u;
-}
-void LayerParameter::clear_has_softmax_param() {
- _has_bits_[1] &= ~0x00010000u;
-}
-void LayerParameter::clear_softmax_param() {
- if (softmax_param_ != NULL) softmax_param_->::caffe::SoftmaxParameter::Clear();
- clear_has_softmax_param();
-}
-const ::caffe::SoftmaxParameter& LayerParameter::softmax_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.softmax_param)
- return softmax_param_ != NULL ? *softmax_param_
- : *::caffe::SoftmaxParameter::internal_default_instance();
-}
-::caffe::SoftmaxParameter* LayerParameter::mutable_softmax_param() {
- set_has_softmax_param();
- if (softmax_param_ == NULL) {
- softmax_param_ = new ::caffe::SoftmaxParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.softmax_param)
- return softmax_param_;
-}
-::caffe::SoftmaxParameter* LayerParameter::release_softmax_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.softmax_param)
- clear_has_softmax_param();
- ::caffe::SoftmaxParameter* temp = softmax_param_;
- softmax_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_softmax_param(::caffe::SoftmaxParameter* softmax_param) {
- delete softmax_param_;
- softmax_param_ = softmax_param;
- if (softmax_param) {
- set_has_softmax_param();
- } else {
- clear_has_softmax_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.softmax_param)
-}
-
-// optional .caffe.SPPParameter spp_param = 132;
-bool LayerParameter::has_spp_param() const {
- return (_has_bits_[1] & 0x00020000u) != 0;
-}
-void LayerParameter::set_has_spp_param() {
- _has_bits_[1] |= 0x00020000u;
-}
-void LayerParameter::clear_has_spp_param() {
- _has_bits_[1] &= ~0x00020000u;
-}
-void LayerParameter::clear_spp_param() {
- if (spp_param_ != NULL) spp_param_->::caffe::SPPParameter::Clear();
- clear_has_spp_param();
-}
-const ::caffe::SPPParameter& LayerParameter::spp_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.spp_param)
- return spp_param_ != NULL ? *spp_param_
- : *::caffe::SPPParameter::internal_default_instance();
-}
-::caffe::SPPParameter* LayerParameter::mutable_spp_param() {
- set_has_spp_param();
- if (spp_param_ == NULL) {
- spp_param_ = new ::caffe::SPPParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.spp_param)
- return spp_param_;
-}
-::caffe::SPPParameter* LayerParameter::release_spp_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.spp_param)
- clear_has_spp_param();
- ::caffe::SPPParameter* temp = spp_param_;
- spp_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_spp_param(::caffe::SPPParameter* spp_param) {
- delete spp_param_;
- spp_param_ = spp_param;
- if (spp_param) {
- set_has_spp_param();
- } else {
- clear_has_spp_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.spp_param)
-}
-
-// optional .caffe.TanHParameter tanh_param = 127;
-bool LayerParameter::has_tanh_param() const {
- return (_has_bits_[1] & 0x00040000u) != 0;
-}
-void LayerParameter::set_has_tanh_param() {
- _has_bits_[1] |= 0x00040000u;
-}
-void LayerParameter::clear_has_tanh_param() {
- _has_bits_[1] &= ~0x00040000u;
-}
-void LayerParameter::clear_tanh_param() {
- if (tanh_param_ != NULL) tanh_param_->::caffe::TanHParameter::Clear();
- clear_has_tanh_param();
-}
-const ::caffe::TanHParameter& LayerParameter::tanh_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.tanh_param)
- return tanh_param_ != NULL ? *tanh_param_
- : *::caffe::TanHParameter::internal_default_instance();
-}
-::caffe::TanHParameter* LayerParameter::mutable_tanh_param() {
- set_has_tanh_param();
- if (tanh_param_ == NULL) {
- tanh_param_ = new ::caffe::TanHParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.tanh_param)
- return tanh_param_;
-}
-::caffe::TanHParameter* LayerParameter::release_tanh_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.tanh_param)
- clear_has_tanh_param();
- ::caffe::TanHParameter* temp = tanh_param_;
- tanh_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_tanh_param(::caffe::TanHParameter* tanh_param) {
- delete tanh_param_;
- tanh_param_ = tanh_param;
- if (tanh_param) {
- set_has_tanh_param();
- } else {
- clear_has_tanh_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.tanh_param)
-}
-
-// optional .caffe.ThresholdParameter threshold_param = 128;
-bool LayerParameter::has_threshold_param() const {
- return (_has_bits_[1] & 0x00080000u) != 0;
-}
-void LayerParameter::set_has_threshold_param() {
- _has_bits_[1] |= 0x00080000u;
-}
-void LayerParameter::clear_has_threshold_param() {
- _has_bits_[1] &= ~0x00080000u;
-}
-void LayerParameter::clear_threshold_param() {
- if (threshold_param_ != NULL) threshold_param_->::caffe::ThresholdParameter::Clear();
- clear_has_threshold_param();
-}
-const ::caffe::ThresholdParameter& LayerParameter::threshold_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.threshold_param)
- return threshold_param_ != NULL ? *threshold_param_
- : *::caffe::ThresholdParameter::internal_default_instance();
-}
-::caffe::ThresholdParameter* LayerParameter::mutable_threshold_param() {
- set_has_threshold_param();
- if (threshold_param_ == NULL) {
- threshold_param_ = new ::caffe::ThresholdParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.threshold_param)
- return threshold_param_;
-}
-::caffe::ThresholdParameter* LayerParameter::release_threshold_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.threshold_param)
- clear_has_threshold_param();
- ::caffe::ThresholdParameter* temp = threshold_param_;
- threshold_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_threshold_param(::caffe::ThresholdParameter* threshold_param) {
- delete threshold_param_;
- threshold_param_ = threshold_param;
- if (threshold_param) {
- set_has_threshold_param();
- } else {
- clear_has_threshold_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.threshold_param)
-}
-
-// optional .caffe.WindowDataParameter window_data_param = 129;
-bool LayerParameter::has_window_data_param() const {
- return (_has_bits_[1] & 0x00100000u) != 0;
-}
-void LayerParameter::set_has_window_data_param() {
- _has_bits_[1] |= 0x00100000u;
-}
-void LayerParameter::clear_has_window_data_param() {
- _has_bits_[1] &= ~0x00100000u;
-}
-void LayerParameter::clear_window_data_param() {
- if (window_data_param_ != NULL) window_data_param_->::caffe::WindowDataParameter::Clear();
- clear_has_window_data_param();
-}
-const ::caffe::WindowDataParameter& LayerParameter::window_data_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.window_data_param)
- return window_data_param_ != NULL ? *window_data_param_
- : *::caffe::WindowDataParameter::internal_default_instance();
-}
-::caffe::WindowDataParameter* LayerParameter::mutable_window_data_param() {
- set_has_window_data_param();
- if (window_data_param_ == NULL) {
- window_data_param_ = new ::caffe::WindowDataParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.window_data_param)
- return window_data_param_;
-}
-::caffe::WindowDataParameter* LayerParameter::release_window_data_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.window_data_param)
- clear_has_window_data_param();
- ::caffe::WindowDataParameter* temp = window_data_param_;
- window_data_param_ = NULL;
- return temp;
-}
-void LayerParameter::set_allocated_window_data_param(::caffe::WindowDataParameter* window_data_param) {
- delete window_data_param_;
- window_data_param_ = window_data_param;
- if (window_data_param) {
- set_has_window_data_param();
- } else {
- clear_has_window_data_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.window_data_param)
-}
-
-inline const LayerParameter* LayerParameter::internal_default_instance() {
- return &LayerParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int TransformationParameter::kScaleFieldNumber;
-const int TransformationParameter::kMirrorFieldNumber;
-const int TransformationParameter::kCropSizeFieldNumber;
-const int TransformationParameter::kMeanFileFieldNumber;
-const int TransformationParameter::kMeanValueFieldNumber;
-const int TransformationParameter::kForceColorFieldNumber;
-const int TransformationParameter::kForceGrayFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-TransformationParameter::TransformationParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.TransformationParameter)
-}
-
-void TransformationParameter::InitAsDefaultInstance() {
-}
-
-TransformationParameter::TransformationParameter(const TransformationParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.TransformationParameter)
-}
-
-void TransformationParameter::SharedCtor() {
- _cached_size_ = 0;
- mean_file_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- ::memset(&crop_size_, 0, reinterpret_cast<char*>(&force_gray_) -
- reinterpret_cast<char*>(&crop_size_) + sizeof(force_gray_));
- scale_ = 1;
-}
-
-TransformationParameter::~TransformationParameter() {
- // @@protoc_insertion_point(destructor:caffe.TransformationParameter)
- SharedDtor();
-}
-
-void TransformationParameter::SharedDtor() {
- mean_file_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-
-void TransformationParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* TransformationParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return TransformationParameter_descriptor_;
-}
-
-const TransformationParameter& TransformationParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<TransformationParameter> TransformationParameter_default_instance_;
-
-TransformationParameter* TransformationParameter::New(::google::protobuf::Arena* arena) const {
- TransformationParameter* n = new TransformationParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void TransformationParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.TransformationParameter)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(TransformationParameter, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<TransformationParameter*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- if (_has_bits_[0 / 32] & 111u) {
- ZR_(crop_size_, force_gray_);
- scale_ = 1;
- if (has_mean_file()) {
- mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- }
-
-#undef ZR_HELPER_
-#undef ZR_
-
- mean_value_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool TransformationParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.TransformationParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional float scale = 1 [default = 1];
- case 1: {
- if (tag == 13) {
- set_has_scale();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &scale_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_mirror;
- break;
- }
-
- // optional bool mirror = 2 [default = false];
- case 2: {
- if (tag == 16) {
- parse_mirror:
- set_has_mirror();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &mirror_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(24)) goto parse_crop_size;
- break;
- }
-
- // optional uint32 crop_size = 3 [default = 0];
- case 3: {
- if (tag == 24) {
- parse_crop_size:
- set_has_crop_size();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &crop_size_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(34)) goto parse_mean_file;
- break;
- }
-
- // optional string mean_file = 4;
- case 4: {
- if (tag == 34) {
- parse_mean_file:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_mean_file()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->mean_file().data(), this->mean_file().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.TransformationParameter.mean_file");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(45)) goto parse_mean_value;
- break;
- }
-
- // repeated float mean_value = 5;
- case 5: {
- if (tag == 45) {
- parse_mean_value:
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- 1, 45, input, this->mutable_mean_value())));
- } else if (tag == 42) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, this->mutable_mean_value())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(45)) goto parse_mean_value;
- if (input->ExpectTag(48)) goto parse_force_color;
- break;
- }
-
- // optional bool force_color = 6 [default = false];
- case 6: {
- if (tag == 48) {
- parse_force_color:
- set_has_force_color();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &force_color_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(56)) goto parse_force_gray;
- break;
- }
-
- // optional bool force_gray = 7 [default = false];
- case 7: {
- if (tag == 56) {
- parse_force_gray:
- set_has_force_gray();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &force_gray_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.TransformationParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.TransformationParameter)
- return false;
-#undef DO_
-}
-
-void TransformationParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.TransformationParameter)
- // optional float scale = 1 [default = 1];
- if (has_scale()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->scale(), output);
- }
-
- // optional bool mirror = 2 [default = false];
- if (has_mirror()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->mirror(), output);
- }
-
- // optional uint32 crop_size = 3 [default = 0];
- if (has_crop_size()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(3, this->crop_size(), output);
- }
-
- // optional string mean_file = 4;
- if (has_mean_file()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->mean_file().data(), this->mean_file().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.TransformationParameter.mean_file");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 4, this->mean_file(), output);
- }
-
- // repeated float mean_value = 5;
- for (int i = 0; i < this->mean_value_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(
- 5, this->mean_value(i), output);
- }
-
- // optional bool force_color = 6 [default = false];
- if (has_force_color()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(6, this->force_color(), output);
- }
-
- // optional bool force_gray = 7 [default = false];
- if (has_force_gray()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(7, this->force_gray(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.TransformationParameter)
-}
-
-::google::protobuf::uint8* TransformationParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.TransformationParameter)
- // optional float scale = 1 [default = 1];
- if (has_scale()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->scale(), target);
- }
-
- // optional bool mirror = 2 [default = false];
- if (has_mirror()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->mirror(), target);
- }
-
- // optional uint32 crop_size = 3 [default = 0];
- if (has_crop_size()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(3, this->crop_size(), target);
- }
-
- // optional string mean_file = 4;
- if (has_mean_file()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->mean_file().data(), this->mean_file().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.TransformationParameter.mean_file");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 4, this->mean_file(), target);
- }
-
- // repeated float mean_value = 5;
- for (int i = 0; i < this->mean_value_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteFloatToArray(5, this->mean_value(i), target);
- }
-
- // optional bool force_color = 6 [default = false];
- if (has_force_color()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(6, this->force_color(), target);
- }
-
- // optional bool force_gray = 7 [default = false];
- if (has_force_gray()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(7, this->force_gray(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.TransformationParameter)
- return target;
-}
-
-size_t TransformationParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.TransformationParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 111u) {
- // optional float scale = 1 [default = 1];
- if (has_scale()) {
- total_size += 1 + 4;
- }
-
- // optional bool mirror = 2 [default = false];
- if (has_mirror()) {
- total_size += 1 + 1;
- }
-
- // optional uint32 crop_size = 3 [default = 0];
- if (has_crop_size()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->crop_size());
- }
-
- // optional string mean_file = 4;
- if (has_mean_file()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->mean_file());
- }
-
- // optional bool force_color = 6 [default = false];
- if (has_force_color()) {
- total_size += 1 + 1;
- }
-
- // optional bool force_gray = 7 [default = false];
- if (has_force_gray()) {
- total_size += 1 + 1;
- }
-
- }
- // repeated float mean_value = 5;
- {
- size_t data_size = 0;
- unsigned int count = this->mean_value_size();
- data_size = 4UL * count;
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->mean_value_size());
- total_size += data_size;
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void TransformationParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.TransformationParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const TransformationParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const TransformationParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.TransformationParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.TransformationParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void TransformationParameter::MergeFrom(const TransformationParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.TransformationParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void TransformationParameter::UnsafeMergeFrom(const TransformationParameter& from) {
- GOOGLE_DCHECK(&from != this);
- mean_value_.UnsafeMergeFrom(from.mean_value_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_scale()) {
- set_scale(from.scale());
- }
- if (from.has_mirror()) {
- set_mirror(from.mirror());
- }
- if (from.has_crop_size()) {
- set_crop_size(from.crop_size());
- }
- if (from.has_mean_file()) {
- set_has_mean_file();
- mean_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.mean_file_);
- }
- if (from.has_force_color()) {
- set_force_color(from.force_color());
- }
- if (from.has_force_gray()) {
- set_force_gray(from.force_gray());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void TransformationParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.TransformationParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void TransformationParameter::CopyFrom(const TransformationParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.TransformationParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool TransformationParameter::IsInitialized() const {
-
- return true;
-}
-
-void TransformationParameter::Swap(TransformationParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void TransformationParameter::InternalSwap(TransformationParameter* other) {
- std::swap(scale_, other->scale_);
- std::swap(mirror_, other->mirror_);
- std::swap(crop_size_, other->crop_size_);
- mean_file_.Swap(&other->mean_file_);
- mean_value_.UnsafeArenaSwap(&other->mean_value_);
- std::swap(force_color_, other->force_color_);
- std::swap(force_gray_, other->force_gray_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata TransformationParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = TransformationParameter_descriptor_;
- metadata.reflection = TransformationParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// TransformationParameter
-
-// optional float scale = 1 [default = 1];
-bool TransformationParameter::has_scale() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void TransformationParameter::set_has_scale() {
- _has_bits_[0] |= 0x00000001u;
-}
-void TransformationParameter::clear_has_scale() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void TransformationParameter::clear_scale() {
- scale_ = 1;
- clear_has_scale();
-}
-float TransformationParameter::scale() const {
- // @@protoc_insertion_point(field_get:caffe.TransformationParameter.scale)
- return scale_;
-}
-void TransformationParameter::set_scale(float value) {
- set_has_scale();
- scale_ = value;
- // @@protoc_insertion_point(field_set:caffe.TransformationParameter.scale)
-}
-
-// optional bool mirror = 2 [default = false];
-bool TransformationParameter::has_mirror() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void TransformationParameter::set_has_mirror() {
- _has_bits_[0] |= 0x00000002u;
-}
-void TransformationParameter::clear_has_mirror() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void TransformationParameter::clear_mirror() {
- mirror_ = false;
- clear_has_mirror();
-}
-bool TransformationParameter::mirror() const {
- // @@protoc_insertion_point(field_get:caffe.TransformationParameter.mirror)
- return mirror_;
-}
-void TransformationParameter::set_mirror(bool value) {
- set_has_mirror();
- mirror_ = value;
- // @@protoc_insertion_point(field_set:caffe.TransformationParameter.mirror)
-}
-
-// optional uint32 crop_size = 3 [default = 0];
-bool TransformationParameter::has_crop_size() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void TransformationParameter::set_has_crop_size() {
- _has_bits_[0] |= 0x00000004u;
-}
-void TransformationParameter::clear_has_crop_size() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void TransformationParameter::clear_crop_size() {
- crop_size_ = 0u;
- clear_has_crop_size();
-}
-::google::protobuf::uint32 TransformationParameter::crop_size() const {
- // @@protoc_insertion_point(field_get:caffe.TransformationParameter.crop_size)
- return crop_size_;
-}
-void TransformationParameter::set_crop_size(::google::protobuf::uint32 value) {
- set_has_crop_size();
- crop_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.TransformationParameter.crop_size)
-}
-
-// optional string mean_file = 4;
-bool TransformationParameter::has_mean_file() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-void TransformationParameter::set_has_mean_file() {
- _has_bits_[0] |= 0x00000008u;
-}
-void TransformationParameter::clear_has_mean_file() {
- _has_bits_[0] &= ~0x00000008u;
-}
-void TransformationParameter::clear_mean_file() {
- mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_mean_file();
-}
-const ::std::string& TransformationParameter::mean_file() const {
- // @@protoc_insertion_point(field_get:caffe.TransformationParameter.mean_file)
- return mean_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void TransformationParameter::set_mean_file(const ::std::string& value) {
- set_has_mean_file();
- mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.TransformationParameter.mean_file)
-}
-void TransformationParameter::set_mean_file(const char* value) {
- set_has_mean_file();
- mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.TransformationParameter.mean_file)
-}
-void TransformationParameter::set_mean_file(const char* value, size_t size) {
- set_has_mean_file();
- mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.TransformationParameter.mean_file)
-}
-::std::string* TransformationParameter::mutable_mean_file() {
- set_has_mean_file();
- // @@protoc_insertion_point(field_mutable:caffe.TransformationParameter.mean_file)
- return mean_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* TransformationParameter::release_mean_file() {
- // @@protoc_insertion_point(field_release:caffe.TransformationParameter.mean_file)
- clear_has_mean_file();
- return mean_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void TransformationParameter::set_allocated_mean_file(::std::string* mean_file) {
- if (mean_file != NULL) {
- set_has_mean_file();
- } else {
- clear_has_mean_file();
- }
- mean_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), mean_file);
- // @@protoc_insertion_point(field_set_allocated:caffe.TransformationParameter.mean_file)
-}
-
-// repeated float mean_value = 5;
-int TransformationParameter::mean_value_size() const {
- return mean_value_.size();
-}
-void TransformationParameter::clear_mean_value() {
- mean_value_.Clear();
-}
-float TransformationParameter::mean_value(int index) const {
- // @@protoc_insertion_point(field_get:caffe.TransformationParameter.mean_value)
- return mean_value_.Get(index);
-}
-void TransformationParameter::set_mean_value(int index, float value) {
- mean_value_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.TransformationParameter.mean_value)
-}
-void TransformationParameter::add_mean_value(float value) {
- mean_value_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.TransformationParameter.mean_value)
-}
-const ::google::protobuf::RepeatedField< float >&
-TransformationParameter::mean_value() const {
- // @@protoc_insertion_point(field_list:caffe.TransformationParameter.mean_value)
- return mean_value_;
-}
-::google::protobuf::RepeatedField< float >*
-TransformationParameter::mutable_mean_value() {
- // @@protoc_insertion_point(field_mutable_list:caffe.TransformationParameter.mean_value)
- return &mean_value_;
-}
-
-// optional bool force_color = 6 [default = false];
-bool TransformationParameter::has_force_color() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-void TransformationParameter::set_has_force_color() {
- _has_bits_[0] |= 0x00000020u;
-}
-void TransformationParameter::clear_has_force_color() {
- _has_bits_[0] &= ~0x00000020u;
-}
-void TransformationParameter::clear_force_color() {
- force_color_ = false;
- clear_has_force_color();
-}
-bool TransformationParameter::force_color() const {
- // @@protoc_insertion_point(field_get:caffe.TransformationParameter.force_color)
- return force_color_;
-}
-void TransformationParameter::set_force_color(bool value) {
- set_has_force_color();
- force_color_ = value;
- // @@protoc_insertion_point(field_set:caffe.TransformationParameter.force_color)
-}
-
-// optional bool force_gray = 7 [default = false];
-bool TransformationParameter::has_force_gray() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-void TransformationParameter::set_has_force_gray() {
- _has_bits_[0] |= 0x00000040u;
-}
-void TransformationParameter::clear_has_force_gray() {
- _has_bits_[0] &= ~0x00000040u;
-}
-void TransformationParameter::clear_force_gray() {
- force_gray_ = false;
- clear_has_force_gray();
-}
-bool TransformationParameter::force_gray() const {
- // @@protoc_insertion_point(field_get:caffe.TransformationParameter.force_gray)
- return force_gray_;
-}
-void TransformationParameter::set_force_gray(bool value) {
- set_has_force_gray();
- force_gray_ = value;
- // @@protoc_insertion_point(field_set:caffe.TransformationParameter.force_gray)
-}
-
-inline const TransformationParameter* TransformationParameter::internal_default_instance() {
- return &TransformationParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int LossParameter::kIgnoreLabelFieldNumber;
-const int LossParameter::kNormalizeFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-LossParameter::LossParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.LossParameter)
-}
-
-void LossParameter::InitAsDefaultInstance() {
-}
-
-LossParameter::LossParameter(const LossParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.LossParameter)
-}
-
-void LossParameter::SharedCtor() {
- _cached_size_ = 0;
- ignore_label_ = 0;
- normalize_ = true;
-}
-
-LossParameter::~LossParameter() {
- // @@protoc_insertion_point(destructor:caffe.LossParameter)
- SharedDtor();
-}
-
-void LossParameter::SharedDtor() {
-}
-
-void LossParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* LossParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return LossParameter_descriptor_;
-}
-
-const LossParameter& LossParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<LossParameter> LossParameter_default_instance_;
-
-LossParameter* LossParameter::New(::google::protobuf::Arena* arena) const {
- LossParameter* n = new LossParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void LossParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.LossParameter)
- if (_has_bits_[0 / 32] & 3u) {
- ignore_label_ = 0;
- normalize_ = true;
- }
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool LossParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.LossParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional int32 ignore_label = 1;
- case 1: {
- if (tag == 8) {
- set_has_ignore_label();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &ignore_label_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_normalize;
- break;
- }
-
- // optional bool normalize = 2 [default = true];
- case 2: {
- if (tag == 16) {
- parse_normalize:
- set_has_normalize();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &normalize_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.LossParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.LossParameter)
- return false;
-#undef DO_
-}
-
-void LossParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.LossParameter)
- // optional int32 ignore_label = 1;
- if (has_ignore_label()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->ignore_label(), output);
- }
-
- // optional bool normalize = 2 [default = true];
- if (has_normalize()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->normalize(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.LossParameter)
-}
-
-::google::protobuf::uint8* LossParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.LossParameter)
- // optional int32 ignore_label = 1;
- if (has_ignore_label()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->ignore_label(), target);
- }
-
- // optional bool normalize = 2 [default = true];
- if (has_normalize()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->normalize(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.LossParameter)
- return target;
-}
-
-size_t LossParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.LossParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 3u) {
- // optional int32 ignore_label = 1;
- if (has_ignore_label()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->ignore_label());
- }
-
- // optional bool normalize = 2 [default = true];
- if (has_normalize()) {
- total_size += 1 + 1;
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void LossParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.LossParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const LossParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const LossParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.LossParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.LossParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void LossParameter::MergeFrom(const LossParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.LossParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void LossParameter::UnsafeMergeFrom(const LossParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_ignore_label()) {
- set_ignore_label(from.ignore_label());
- }
- if (from.has_normalize()) {
- set_normalize(from.normalize());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void LossParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.LossParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void LossParameter::CopyFrom(const LossParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.LossParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool LossParameter::IsInitialized() const {
-
- return true;
-}
-
-void LossParameter::Swap(LossParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void LossParameter::InternalSwap(LossParameter* other) {
- std::swap(ignore_label_, other->ignore_label_);
- std::swap(normalize_, other->normalize_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata LossParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = LossParameter_descriptor_;
- metadata.reflection = LossParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// LossParameter
-
-// optional int32 ignore_label = 1;
-bool LossParameter::has_ignore_label() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void LossParameter::set_has_ignore_label() {
- _has_bits_[0] |= 0x00000001u;
-}
-void LossParameter::clear_has_ignore_label() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void LossParameter::clear_ignore_label() {
- ignore_label_ = 0;
- clear_has_ignore_label();
-}
-::google::protobuf::int32 LossParameter::ignore_label() const {
- // @@protoc_insertion_point(field_get:caffe.LossParameter.ignore_label)
- return ignore_label_;
-}
-void LossParameter::set_ignore_label(::google::protobuf::int32 value) {
- set_has_ignore_label();
- ignore_label_ = value;
- // @@protoc_insertion_point(field_set:caffe.LossParameter.ignore_label)
-}
-
-// optional bool normalize = 2 [default = true];
-bool LossParameter::has_normalize() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void LossParameter::set_has_normalize() {
- _has_bits_[0] |= 0x00000002u;
-}
-void LossParameter::clear_has_normalize() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void LossParameter::clear_normalize() {
- normalize_ = true;
- clear_has_normalize();
-}
-bool LossParameter::normalize() const {
- // @@protoc_insertion_point(field_get:caffe.LossParameter.normalize)
- return normalize_;
-}
-void LossParameter::set_normalize(bool value) {
- set_has_normalize();
- normalize_ = value;
- // @@protoc_insertion_point(field_set:caffe.LossParameter.normalize)
-}
-
-inline const LossParameter* LossParameter::internal_default_instance() {
- return &LossParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int AccuracyParameter::kTopKFieldNumber;
-const int AccuracyParameter::kAxisFieldNumber;
-const int AccuracyParameter::kIgnoreLabelFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-AccuracyParameter::AccuracyParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.AccuracyParameter)
-}
-
-void AccuracyParameter::InitAsDefaultInstance() {
-}
-
-AccuracyParameter::AccuracyParameter(const AccuracyParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.AccuracyParameter)
-}
-
-void AccuracyParameter::SharedCtor() {
- _cached_size_ = 0;
- ignore_label_ = 0;
- top_k_ = 1u;
- axis_ = 1;
-}
-
-AccuracyParameter::~AccuracyParameter() {
- // @@protoc_insertion_point(destructor:caffe.AccuracyParameter)
- SharedDtor();
-}
-
-void AccuracyParameter::SharedDtor() {
-}
-
-void AccuracyParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* AccuracyParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return AccuracyParameter_descriptor_;
-}
-
-const AccuracyParameter& AccuracyParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<AccuracyParameter> AccuracyParameter_default_instance_;
-
-AccuracyParameter* AccuracyParameter::New(::google::protobuf::Arena* arena) const {
- AccuracyParameter* n = new AccuracyParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void AccuracyParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.AccuracyParameter)
- if (_has_bits_[0 / 32] & 7u) {
- top_k_ = 1u;
- axis_ = 1;
- ignore_label_ = 0;
- }
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool AccuracyParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.AccuracyParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional uint32 top_k = 1 [default = 1];
- case 1: {
- if (tag == 8) {
- set_has_top_k();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &top_k_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_axis;
- break;
- }
-
- // optional int32 axis = 2 [default = 1];
- case 2: {
- if (tag == 16) {
- parse_axis:
- set_has_axis();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &axis_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(24)) goto parse_ignore_label;
- break;
- }
-
- // optional int32 ignore_label = 3;
- case 3: {
- if (tag == 24) {
- parse_ignore_label:
- set_has_ignore_label();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &ignore_label_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.AccuracyParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.AccuracyParameter)
- return false;
-#undef DO_
-}
-
-void AccuracyParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.AccuracyParameter)
- // optional uint32 top_k = 1 [default = 1];
- if (has_top_k()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->top_k(), output);
- }
-
- // optional int32 axis = 2 [default = 1];
- if (has_axis()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->axis(), output);
- }
-
- // optional int32 ignore_label = 3;
- if (has_ignore_label()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->ignore_label(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.AccuracyParameter)
-}
-
-::google::protobuf::uint8* AccuracyParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.AccuracyParameter)
- // optional uint32 top_k = 1 [default = 1];
- if (has_top_k()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->top_k(), target);
- }
-
- // optional int32 axis = 2 [default = 1];
- if (has_axis()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->axis(), target);
- }
-
- // optional int32 ignore_label = 3;
- if (has_ignore_label()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->ignore_label(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.AccuracyParameter)
- return target;
-}
-
-size_t AccuracyParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.AccuracyParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 7u) {
- // optional uint32 top_k = 1 [default = 1];
- if (has_top_k()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->top_k());
- }
-
- // optional int32 axis = 2 [default = 1];
- if (has_axis()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->axis());
- }
-
- // optional int32 ignore_label = 3;
- if (has_ignore_label()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->ignore_label());
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void AccuracyParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.AccuracyParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const AccuracyParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const AccuracyParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.AccuracyParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.AccuracyParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void AccuracyParameter::MergeFrom(const AccuracyParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.AccuracyParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void AccuracyParameter::UnsafeMergeFrom(const AccuracyParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_top_k()) {
- set_top_k(from.top_k());
- }
- if (from.has_axis()) {
- set_axis(from.axis());
- }
- if (from.has_ignore_label()) {
- set_ignore_label(from.ignore_label());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void AccuracyParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.AccuracyParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void AccuracyParameter::CopyFrom(const AccuracyParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.AccuracyParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool AccuracyParameter::IsInitialized() const {
-
- return true;
-}
-
-void AccuracyParameter::Swap(AccuracyParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void AccuracyParameter::InternalSwap(AccuracyParameter* other) {
- std::swap(top_k_, other->top_k_);
- std::swap(axis_, other->axis_);
- std::swap(ignore_label_, other->ignore_label_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata AccuracyParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = AccuracyParameter_descriptor_;
- metadata.reflection = AccuracyParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// AccuracyParameter
-
-// optional uint32 top_k = 1 [default = 1];
-bool AccuracyParameter::has_top_k() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void AccuracyParameter::set_has_top_k() {
- _has_bits_[0] |= 0x00000001u;
-}
-void AccuracyParameter::clear_has_top_k() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void AccuracyParameter::clear_top_k() {
- top_k_ = 1u;
- clear_has_top_k();
-}
-::google::protobuf::uint32 AccuracyParameter::top_k() const {
- // @@protoc_insertion_point(field_get:caffe.AccuracyParameter.top_k)
- return top_k_;
-}
-void AccuracyParameter::set_top_k(::google::protobuf::uint32 value) {
- set_has_top_k();
- top_k_ = value;
- // @@protoc_insertion_point(field_set:caffe.AccuracyParameter.top_k)
-}
-
-// optional int32 axis = 2 [default = 1];
-bool AccuracyParameter::has_axis() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void AccuracyParameter::set_has_axis() {
- _has_bits_[0] |= 0x00000002u;
-}
-void AccuracyParameter::clear_has_axis() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void AccuracyParameter::clear_axis() {
- axis_ = 1;
- clear_has_axis();
-}
-::google::protobuf::int32 AccuracyParameter::axis() const {
- // @@protoc_insertion_point(field_get:caffe.AccuracyParameter.axis)
- return axis_;
-}
-void AccuracyParameter::set_axis(::google::protobuf::int32 value) {
- set_has_axis();
- axis_ = value;
- // @@protoc_insertion_point(field_set:caffe.AccuracyParameter.axis)
-}
-
-// optional int32 ignore_label = 3;
-bool AccuracyParameter::has_ignore_label() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void AccuracyParameter::set_has_ignore_label() {
- _has_bits_[0] |= 0x00000004u;
-}
-void AccuracyParameter::clear_has_ignore_label() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void AccuracyParameter::clear_ignore_label() {
- ignore_label_ = 0;
- clear_has_ignore_label();
-}
-::google::protobuf::int32 AccuracyParameter::ignore_label() const {
- // @@protoc_insertion_point(field_get:caffe.AccuracyParameter.ignore_label)
- return ignore_label_;
-}
-void AccuracyParameter::set_ignore_label(::google::protobuf::int32 value) {
- set_has_ignore_label();
- ignore_label_ = value;
- // @@protoc_insertion_point(field_set:caffe.AccuracyParameter.ignore_label)
-}
-
-inline const AccuracyParameter* AccuracyParameter::internal_default_instance() {
- return &AccuracyParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int ArgMaxParameter::kOutMaxValFieldNumber;
-const int ArgMaxParameter::kTopKFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-ArgMaxParameter::ArgMaxParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.ArgMaxParameter)
-}
-
-void ArgMaxParameter::InitAsDefaultInstance() {
-}
-
-ArgMaxParameter::ArgMaxParameter(const ArgMaxParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.ArgMaxParameter)
-}
-
-void ArgMaxParameter::SharedCtor() {
- _cached_size_ = 0;
- out_max_val_ = false;
- top_k_ = 1u;
-}
-
-ArgMaxParameter::~ArgMaxParameter() {
- // @@protoc_insertion_point(destructor:caffe.ArgMaxParameter)
- SharedDtor();
-}
-
-void ArgMaxParameter::SharedDtor() {
-}
-
-void ArgMaxParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* ArgMaxParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return ArgMaxParameter_descriptor_;
-}
-
-const ArgMaxParameter& ArgMaxParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<ArgMaxParameter> ArgMaxParameter_default_instance_;
-
-ArgMaxParameter* ArgMaxParameter::New(::google::protobuf::Arena* arena) const {
- ArgMaxParameter* n = new ArgMaxParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void ArgMaxParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.ArgMaxParameter)
- if (_has_bits_[0 / 32] & 3u) {
- out_max_val_ = false;
- top_k_ = 1u;
- }
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool ArgMaxParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.ArgMaxParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional bool out_max_val = 1 [default = false];
- case 1: {
- if (tag == 8) {
- set_has_out_max_val();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &out_max_val_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_top_k;
- break;
- }
-
- // optional uint32 top_k = 2 [default = 1];
- case 2: {
- if (tag == 16) {
- parse_top_k:
- set_has_top_k();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &top_k_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.ArgMaxParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.ArgMaxParameter)
- return false;
-#undef DO_
-}
-
-void ArgMaxParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.ArgMaxParameter)
- // optional bool out_max_val = 1 [default = false];
- if (has_out_max_val()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(1, this->out_max_val(), output);
- }
-
- // optional uint32 top_k = 2 [default = 1];
- if (has_top_k()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(2, this->top_k(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.ArgMaxParameter)
-}
-
-::google::protobuf::uint8* ArgMaxParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.ArgMaxParameter)
- // optional bool out_max_val = 1 [default = false];
- if (has_out_max_val()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->out_max_val(), target);
- }
-
- // optional uint32 top_k = 2 [default = 1];
- if (has_top_k()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(2, this->top_k(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.ArgMaxParameter)
- return target;
-}
-
-size_t ArgMaxParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.ArgMaxParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 3u) {
- // optional bool out_max_val = 1 [default = false];
- if (has_out_max_val()) {
- total_size += 1 + 1;
- }
-
- // optional uint32 top_k = 2 [default = 1];
- if (has_top_k()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->top_k());
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void ArgMaxParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.ArgMaxParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const ArgMaxParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const ArgMaxParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ArgMaxParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ArgMaxParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void ArgMaxParameter::MergeFrom(const ArgMaxParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ArgMaxParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void ArgMaxParameter::UnsafeMergeFrom(const ArgMaxParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_out_max_val()) {
- set_out_max_val(from.out_max_val());
- }
- if (from.has_top_k()) {
- set_top_k(from.top_k());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void ArgMaxParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.ArgMaxParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void ArgMaxParameter::CopyFrom(const ArgMaxParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ArgMaxParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool ArgMaxParameter::IsInitialized() const {
-
- return true;
-}
-
-void ArgMaxParameter::Swap(ArgMaxParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void ArgMaxParameter::InternalSwap(ArgMaxParameter* other) {
- std::swap(out_max_val_, other->out_max_val_);
- std::swap(top_k_, other->top_k_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata ArgMaxParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = ArgMaxParameter_descriptor_;
- metadata.reflection = ArgMaxParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// ArgMaxParameter
-
-// optional bool out_max_val = 1 [default = false];
-bool ArgMaxParameter::has_out_max_val() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void ArgMaxParameter::set_has_out_max_val() {
- _has_bits_[0] |= 0x00000001u;
-}
-void ArgMaxParameter::clear_has_out_max_val() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void ArgMaxParameter::clear_out_max_val() {
- out_max_val_ = false;
- clear_has_out_max_val();
-}
-bool ArgMaxParameter::out_max_val() const {
- // @@protoc_insertion_point(field_get:caffe.ArgMaxParameter.out_max_val)
- return out_max_val_;
-}
-void ArgMaxParameter::set_out_max_val(bool value) {
- set_has_out_max_val();
- out_max_val_ = value;
- // @@protoc_insertion_point(field_set:caffe.ArgMaxParameter.out_max_val)
-}
-
-// optional uint32 top_k = 2 [default = 1];
-bool ArgMaxParameter::has_top_k() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void ArgMaxParameter::set_has_top_k() {
- _has_bits_[0] |= 0x00000002u;
-}
-void ArgMaxParameter::clear_has_top_k() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void ArgMaxParameter::clear_top_k() {
- top_k_ = 1u;
- clear_has_top_k();
-}
-::google::protobuf::uint32 ArgMaxParameter::top_k() const {
- // @@protoc_insertion_point(field_get:caffe.ArgMaxParameter.top_k)
- return top_k_;
-}
-void ArgMaxParameter::set_top_k(::google::protobuf::uint32 value) {
- set_has_top_k();
- top_k_ = value;
- // @@protoc_insertion_point(field_set:caffe.ArgMaxParameter.top_k)
-}
-
-inline const ArgMaxParameter* ArgMaxParameter::internal_default_instance() {
- return &ArgMaxParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int ConcatParameter::kAxisFieldNumber;
-const int ConcatParameter::kConcatDimFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-ConcatParameter::ConcatParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.ConcatParameter)
-}
-
-void ConcatParameter::InitAsDefaultInstance() {
-}
-
-ConcatParameter::ConcatParameter(const ConcatParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.ConcatParameter)
-}
-
-void ConcatParameter::SharedCtor() {
- _cached_size_ = 0;
- axis_ = 1;
- concat_dim_ = 1u;
-}
-
-ConcatParameter::~ConcatParameter() {
- // @@protoc_insertion_point(destructor:caffe.ConcatParameter)
- SharedDtor();
-}
-
-void ConcatParameter::SharedDtor() {
-}
-
-void ConcatParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* ConcatParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return ConcatParameter_descriptor_;
-}
-
-const ConcatParameter& ConcatParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<ConcatParameter> ConcatParameter_default_instance_;
-
-ConcatParameter* ConcatParameter::New(::google::protobuf::Arena* arena) const {
- ConcatParameter* n = new ConcatParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void ConcatParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.ConcatParameter)
- if (_has_bits_[0 / 32] & 3u) {
- axis_ = 1;
- concat_dim_ = 1u;
- }
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool ConcatParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.ConcatParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional uint32 concat_dim = 1 [default = 1];
- case 1: {
- if (tag == 8) {
- set_has_concat_dim();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &concat_dim_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_axis;
- break;
- }
-
- // optional int32 axis = 2 [default = 1];
- case 2: {
- if (tag == 16) {
- parse_axis:
- set_has_axis();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &axis_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.ConcatParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.ConcatParameter)
- return false;
-#undef DO_
-}
-
-void ConcatParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.ConcatParameter)
- // optional uint32 concat_dim = 1 [default = 1];
- if (has_concat_dim()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->concat_dim(), output);
- }
-
- // optional int32 axis = 2 [default = 1];
- if (has_axis()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->axis(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.ConcatParameter)
-}
-
-::google::protobuf::uint8* ConcatParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.ConcatParameter)
- // optional uint32 concat_dim = 1 [default = 1];
- if (has_concat_dim()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->concat_dim(), target);
- }
-
- // optional int32 axis = 2 [default = 1];
- if (has_axis()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->axis(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.ConcatParameter)
- return target;
-}
-
-size_t ConcatParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.ConcatParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 3u) {
- // optional int32 axis = 2 [default = 1];
- if (has_axis()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->axis());
- }
-
- // optional uint32 concat_dim = 1 [default = 1];
- if (has_concat_dim()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->concat_dim());
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void ConcatParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.ConcatParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const ConcatParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const ConcatParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ConcatParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ConcatParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void ConcatParameter::MergeFrom(const ConcatParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ConcatParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void ConcatParameter::UnsafeMergeFrom(const ConcatParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_axis()) {
- set_axis(from.axis());
- }
- if (from.has_concat_dim()) {
- set_concat_dim(from.concat_dim());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void ConcatParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.ConcatParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void ConcatParameter::CopyFrom(const ConcatParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ConcatParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool ConcatParameter::IsInitialized() const {
-
- return true;
-}
-
-void ConcatParameter::Swap(ConcatParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void ConcatParameter::InternalSwap(ConcatParameter* other) {
- std::swap(axis_, other->axis_);
- std::swap(concat_dim_, other->concat_dim_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata ConcatParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = ConcatParameter_descriptor_;
- metadata.reflection = ConcatParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// ConcatParameter
-
-// optional int32 axis = 2 [default = 1];
-bool ConcatParameter::has_axis() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void ConcatParameter::set_has_axis() {
- _has_bits_[0] |= 0x00000001u;
-}
-void ConcatParameter::clear_has_axis() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void ConcatParameter::clear_axis() {
- axis_ = 1;
- clear_has_axis();
-}
-::google::protobuf::int32 ConcatParameter::axis() const {
- // @@protoc_insertion_point(field_get:caffe.ConcatParameter.axis)
- return axis_;
-}
-void ConcatParameter::set_axis(::google::protobuf::int32 value) {
- set_has_axis();
- axis_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConcatParameter.axis)
-}
-
-// optional uint32 concat_dim = 1 [default = 1];
-bool ConcatParameter::has_concat_dim() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void ConcatParameter::set_has_concat_dim() {
- _has_bits_[0] |= 0x00000002u;
-}
-void ConcatParameter::clear_has_concat_dim() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void ConcatParameter::clear_concat_dim() {
- concat_dim_ = 1u;
- clear_has_concat_dim();
-}
-::google::protobuf::uint32 ConcatParameter::concat_dim() const {
- // @@protoc_insertion_point(field_get:caffe.ConcatParameter.concat_dim)
- return concat_dim_;
-}
-void ConcatParameter::set_concat_dim(::google::protobuf::uint32 value) {
- set_has_concat_dim();
- concat_dim_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConcatParameter.concat_dim)
-}
-
-inline const ConcatParameter* ConcatParameter::internal_default_instance() {
- return &ConcatParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int ContrastiveLossParameter::kMarginFieldNumber;
-const int ContrastiveLossParameter::kLegacyVersionFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-ContrastiveLossParameter::ContrastiveLossParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.ContrastiveLossParameter)
-}
-
-void ContrastiveLossParameter::InitAsDefaultInstance() {
-}
-
-ContrastiveLossParameter::ContrastiveLossParameter(const ContrastiveLossParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.ContrastiveLossParameter)
-}
-
-void ContrastiveLossParameter::SharedCtor() {
- _cached_size_ = 0;
- legacy_version_ = false;
- margin_ = 1;
-}
-
-ContrastiveLossParameter::~ContrastiveLossParameter() {
- // @@protoc_insertion_point(destructor:caffe.ContrastiveLossParameter)
- SharedDtor();
-}
-
-void ContrastiveLossParameter::SharedDtor() {
-}
-
-void ContrastiveLossParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* ContrastiveLossParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return ContrastiveLossParameter_descriptor_;
-}
-
-const ContrastiveLossParameter& ContrastiveLossParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<ContrastiveLossParameter> ContrastiveLossParameter_default_instance_;
-
-ContrastiveLossParameter* ContrastiveLossParameter::New(::google::protobuf::Arena* arena) const {
- ContrastiveLossParameter* n = new ContrastiveLossParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void ContrastiveLossParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.ContrastiveLossParameter)
- if (_has_bits_[0 / 32] & 3u) {
- margin_ = 1;
- legacy_version_ = false;
- }
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool ContrastiveLossParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.ContrastiveLossParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional float margin = 1 [default = 1];
- case 1: {
- if (tag == 13) {
- set_has_margin();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &margin_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_legacy_version;
- break;
- }
-
- // optional bool legacy_version = 2 [default = false];
- case 2: {
- if (tag == 16) {
- parse_legacy_version:
- set_has_legacy_version();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &legacy_version_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.ContrastiveLossParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.ContrastiveLossParameter)
- return false;
-#undef DO_
-}
-
-void ContrastiveLossParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.ContrastiveLossParameter)
- // optional float margin = 1 [default = 1];
- if (has_margin()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->margin(), output);
- }
-
- // optional bool legacy_version = 2 [default = false];
- if (has_legacy_version()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->legacy_version(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.ContrastiveLossParameter)
-}
-
-::google::protobuf::uint8* ContrastiveLossParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.ContrastiveLossParameter)
- // optional float margin = 1 [default = 1];
- if (has_margin()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->margin(), target);
- }
-
- // optional bool legacy_version = 2 [default = false];
- if (has_legacy_version()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->legacy_version(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.ContrastiveLossParameter)
- return target;
-}
-
-size_t ContrastiveLossParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.ContrastiveLossParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 3u) {
- // optional float margin = 1 [default = 1];
- if (has_margin()) {
- total_size += 1 + 4;
- }
-
- // optional bool legacy_version = 2 [default = false];
- if (has_legacy_version()) {
- total_size += 1 + 1;
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void ContrastiveLossParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.ContrastiveLossParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const ContrastiveLossParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const ContrastiveLossParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ContrastiveLossParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ContrastiveLossParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void ContrastiveLossParameter::MergeFrom(const ContrastiveLossParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ContrastiveLossParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void ContrastiveLossParameter::UnsafeMergeFrom(const ContrastiveLossParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_margin()) {
- set_margin(from.margin());
- }
- if (from.has_legacy_version()) {
- set_legacy_version(from.legacy_version());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void ContrastiveLossParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.ContrastiveLossParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void ContrastiveLossParameter::CopyFrom(const ContrastiveLossParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ContrastiveLossParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool ContrastiveLossParameter::IsInitialized() const {
-
- return true;
-}
-
-void ContrastiveLossParameter::Swap(ContrastiveLossParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void ContrastiveLossParameter::InternalSwap(ContrastiveLossParameter* other) {
- std::swap(margin_, other->margin_);
- std::swap(legacy_version_, other->legacy_version_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata ContrastiveLossParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = ContrastiveLossParameter_descriptor_;
- metadata.reflection = ContrastiveLossParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// ContrastiveLossParameter
-
-// optional float margin = 1 [default = 1];
-bool ContrastiveLossParameter::has_margin() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void ContrastiveLossParameter::set_has_margin() {
- _has_bits_[0] |= 0x00000001u;
-}
-void ContrastiveLossParameter::clear_has_margin() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void ContrastiveLossParameter::clear_margin() {
- margin_ = 1;
- clear_has_margin();
-}
-float ContrastiveLossParameter::margin() const {
- // @@protoc_insertion_point(field_get:caffe.ContrastiveLossParameter.margin)
- return margin_;
-}
-void ContrastiveLossParameter::set_margin(float value) {
- set_has_margin();
- margin_ = value;
- // @@protoc_insertion_point(field_set:caffe.ContrastiveLossParameter.margin)
-}
-
-// optional bool legacy_version = 2 [default = false];
-bool ContrastiveLossParameter::has_legacy_version() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void ContrastiveLossParameter::set_has_legacy_version() {
- _has_bits_[0] |= 0x00000002u;
-}
-void ContrastiveLossParameter::clear_has_legacy_version() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void ContrastiveLossParameter::clear_legacy_version() {
- legacy_version_ = false;
- clear_has_legacy_version();
-}
-bool ContrastiveLossParameter::legacy_version() const {
- // @@protoc_insertion_point(field_get:caffe.ContrastiveLossParameter.legacy_version)
- return legacy_version_;
-}
-void ContrastiveLossParameter::set_legacy_version(bool value) {
- set_has_legacy_version();
- legacy_version_ = value;
- // @@protoc_insertion_point(field_set:caffe.ContrastiveLossParameter.legacy_version)
-}
-
-inline const ContrastiveLossParameter* ContrastiveLossParameter::internal_default_instance() {
- return &ContrastiveLossParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-const ::google::protobuf::EnumDescriptor* ConvolutionParameter_Engine_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return ConvolutionParameter_Engine_descriptor_;
-}
-bool ConvolutionParameter_Engine_IsValid(int value) {
- switch (value) {
- case 0:
- case 1:
- case 2:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const ConvolutionParameter_Engine ConvolutionParameter::DEFAULT;
-const ConvolutionParameter_Engine ConvolutionParameter::CAFFE;
-const ConvolutionParameter_Engine ConvolutionParameter::CUDNN;
-const ConvolutionParameter_Engine ConvolutionParameter::Engine_MIN;
-const ConvolutionParameter_Engine ConvolutionParameter::Engine_MAX;
-const int ConvolutionParameter::Engine_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int ConvolutionParameter::kNumOutputFieldNumber;
-const int ConvolutionParameter::kBiasTermFieldNumber;
-const int ConvolutionParameter::kPadFieldNumber;
-const int ConvolutionParameter::kPadHFieldNumber;
-const int ConvolutionParameter::kPadWFieldNumber;
-const int ConvolutionParameter::kKernelSizeFieldNumber;
-const int ConvolutionParameter::kKernelHFieldNumber;
-const int ConvolutionParameter::kKernelWFieldNumber;
-const int ConvolutionParameter::kGroupFieldNumber;
-const int ConvolutionParameter::kStrideFieldNumber;
-const int ConvolutionParameter::kStrideHFieldNumber;
-const int ConvolutionParameter::kStrideWFieldNumber;
-const int ConvolutionParameter::kWeightFillerFieldNumber;
-const int ConvolutionParameter::kBiasFillerFieldNumber;
-const int ConvolutionParameter::kEngineFieldNumber;
-const int ConvolutionParameter::kDilationHFieldNumber;
-const int ConvolutionParameter::kDilationWFieldNumber;
-const int ConvolutionParameter::kDilationFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-ConvolutionParameter::ConvolutionParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.ConvolutionParameter)
-}
-
-void ConvolutionParameter::InitAsDefaultInstance() {
- weight_filler_ = const_cast< ::caffe::FillerParameter*>(
- ::caffe::FillerParameter::internal_default_instance());
- bias_filler_ = const_cast< ::caffe::FillerParameter*>(
- ::caffe::FillerParameter::internal_default_instance());
-}
-
-ConvolutionParameter::ConvolutionParameter(const ConvolutionParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.ConvolutionParameter)
-}
-
-void ConvolutionParameter::SharedCtor() {
- _cached_size_ = 0;
- weight_filler_ = NULL;
- bias_filler_ = NULL;
- ::memset(&num_output_, 0, reinterpret_cast<char*>(&dilation_) -
- reinterpret_cast<char*>(&num_output_) + sizeof(dilation_));
- stride_ = 1u;
- bias_term_ = true;
- group_ = 1u;
-}
-
-ConvolutionParameter::~ConvolutionParameter() {
- // @@protoc_insertion_point(destructor:caffe.ConvolutionParameter)
- SharedDtor();
-}
-
-void ConvolutionParameter::SharedDtor() {
- if (this != &ConvolutionParameter_default_instance_.get()) {
- delete weight_filler_;
- delete bias_filler_;
- }
-}
-
-void ConvolutionParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* ConvolutionParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return ConvolutionParameter_descriptor_;
-}
-
-const ConvolutionParameter& ConvolutionParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<ConvolutionParameter> ConvolutionParameter_default_instance_;
-
-ConvolutionParameter* ConvolutionParameter::New(::google::protobuf::Arena* arena) const {
- ConvolutionParameter* n = new ConvolutionParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void ConvolutionParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.ConvolutionParameter)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(ConvolutionParameter, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<ConvolutionParameter*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- if (_has_bits_[0 / 32] & 255u) {
- ZR_(num_output_, kernel_w_);
- bias_term_ = true;
- }
- if (_has_bits_[8 / 32] & 65280u) {
- ZR_(stride_h_, dilation_h_);
- group_ = 1u;
- stride_ = 1u;
- if (has_weight_filler()) {
- if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear();
- }
- if (has_bias_filler()) {
- if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
- }
- }
- ZR_(dilation_w_, dilation_);
-
-#undef ZR_HELPER_
-#undef ZR_
-
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool ConvolutionParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.ConvolutionParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional uint32 num_output = 1;
- case 1: {
- if (tag == 8) {
- set_has_num_output();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &num_output_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_bias_term;
- break;
- }
-
- // optional bool bias_term = 2 [default = true];
- case 2: {
- if (tag == 16) {
- parse_bias_term:
- set_has_bias_term();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &bias_term_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(24)) goto parse_pad;
- break;
- }
-
- // optional uint32 pad = 3 [default = 0];
- case 3: {
- if (tag == 24) {
- parse_pad:
- set_has_pad();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &pad_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(32)) goto parse_kernel_size;
- break;
- }
-
- // optional uint32 kernel_size = 4;
- case 4: {
- if (tag == 32) {
- parse_kernel_size:
- set_has_kernel_size();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &kernel_size_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(40)) goto parse_group;
- break;
- }
-
- // optional uint32 group = 5 [default = 1];
- case 5: {
- if (tag == 40) {
- parse_group:
- set_has_group();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &group_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(48)) goto parse_stride;
- break;
- }
-
- // optional uint32 stride = 6 [default = 1];
- case 6: {
- if (tag == 48) {
- parse_stride:
- set_has_stride();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &stride_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(58)) goto parse_weight_filler;
- break;
- }
-
- // optional .caffe.FillerParameter weight_filler = 7;
- case 7: {
- if (tag == 58) {
- parse_weight_filler:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_weight_filler()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(66)) goto parse_bias_filler;
- break;
- }
-
- // optional .caffe.FillerParameter bias_filler = 8;
- case 8: {
- if (tag == 66) {
- parse_bias_filler:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_bias_filler()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(72)) goto parse_pad_h;
- break;
- }
-
- // optional uint32 pad_h = 9 [default = 0];
- case 9: {
- if (tag == 72) {
- parse_pad_h:
- set_has_pad_h();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &pad_h_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(80)) goto parse_pad_w;
- break;
- }
-
- // optional uint32 pad_w = 10 [default = 0];
- case 10: {
- if (tag == 80) {
- parse_pad_w:
- set_has_pad_w();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &pad_w_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(88)) goto parse_kernel_h;
- break;
- }
-
- // optional uint32 kernel_h = 11;
- case 11: {
- if (tag == 88) {
- parse_kernel_h:
- set_has_kernel_h();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &kernel_h_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(96)) goto parse_kernel_w;
- break;
- }
-
- // optional uint32 kernel_w = 12;
- case 12: {
- if (tag == 96) {
- parse_kernel_w:
- set_has_kernel_w();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &kernel_w_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(104)) goto parse_stride_h;
- break;
- }
-
- // optional uint32 stride_h = 13;
- case 13: {
- if (tag == 104) {
- parse_stride_h:
- set_has_stride_h();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &stride_h_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(112)) goto parse_stride_w;
- break;
- }
-
- // optional uint32 stride_w = 14;
- case 14: {
- if (tag == 112) {
- parse_stride_w:
- set_has_stride_w();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &stride_w_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(120)) goto parse_engine;
- break;
- }
-
- // optional .caffe.ConvolutionParameter.Engine engine = 15 [default = DEFAULT];
- case 15: {
- if (tag == 120) {
- parse_engine:
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::ConvolutionParameter_Engine_IsValid(value)) {
- set_engine(static_cast< ::caffe::ConvolutionParameter_Engine >(value));
- } else {
- mutable_unknown_fields()->AddVarint(15, value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(144)) goto parse_dilation_h;
- break;
- }
-
- // optional uint32 dilation_h = 18;
- case 18: {
- if (tag == 144) {
- parse_dilation_h:
- set_has_dilation_h();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &dilation_h_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(152)) goto parse_dilation_w;
- break;
- }
-
- // optional uint32 dilation_w = 19;
- case 19: {
- if (tag == 152) {
- parse_dilation_w:
- set_has_dilation_w();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &dilation_w_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(160)) goto parse_dilation;
- break;
- }
-
- // optional uint32 dilation = 20;
- case 20: {
- if (tag == 160) {
- parse_dilation:
- set_has_dilation();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &dilation_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.ConvolutionParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.ConvolutionParameter)
- return false;
-#undef DO_
-}
-
-void ConvolutionParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.ConvolutionParameter)
- // optional uint32 num_output = 1;
- if (has_num_output()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->num_output(), output);
- }
-
- // optional bool bias_term = 2 [default = true];
- if (has_bias_term()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->bias_term(), output);
- }
-
- // optional uint32 pad = 3 [default = 0];
- if (has_pad()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(3, this->pad(), output);
- }
-
- // optional uint32 kernel_size = 4;
- if (has_kernel_size()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(4, this->kernel_size(), output);
- }
-
- // optional uint32 group = 5 [default = 1];
- if (has_group()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(5, this->group(), output);
- }
-
- // optional uint32 stride = 6 [default = 1];
- if (has_stride()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(6, this->stride(), output);
- }
-
- // optional .caffe.FillerParameter weight_filler = 7;
- if (has_weight_filler()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 7, *this->weight_filler_, output);
- }
-
- // optional .caffe.FillerParameter bias_filler = 8;
- if (has_bias_filler()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 8, *this->bias_filler_, output);
- }
-
- // optional uint32 pad_h = 9 [default = 0];
- if (has_pad_h()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(9, this->pad_h(), output);
- }
-
- // optional uint32 pad_w = 10 [default = 0];
- if (has_pad_w()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(10, this->pad_w(), output);
- }
-
- // optional uint32 kernel_h = 11;
- if (has_kernel_h()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(11, this->kernel_h(), output);
- }
-
- // optional uint32 kernel_w = 12;
- if (has_kernel_w()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(12, this->kernel_w(), output);
- }
-
- // optional uint32 stride_h = 13;
- if (has_stride_h()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(13, this->stride_h(), output);
- }
-
- // optional uint32 stride_w = 14;
- if (has_stride_w()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(14, this->stride_w(), output);
- }
-
- // optional .caffe.ConvolutionParameter.Engine engine = 15 [default = DEFAULT];
- if (has_engine()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 15, this->engine(), output);
- }
-
- // optional uint32 dilation_h = 18;
- if (has_dilation_h()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(18, this->dilation_h(), output);
- }
-
- // optional uint32 dilation_w = 19;
- if (has_dilation_w()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(19, this->dilation_w(), output);
- }
-
- // optional uint32 dilation = 20;
- if (has_dilation()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(20, this->dilation(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.ConvolutionParameter)
-}
-
-::google::protobuf::uint8* ConvolutionParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.ConvolutionParameter)
- // optional uint32 num_output = 1;
- if (has_num_output()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->num_output(), target);
- }
-
- // optional bool bias_term = 2 [default = true];
- if (has_bias_term()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->bias_term(), target);
- }
-
- // optional uint32 pad = 3 [default = 0];
- if (has_pad()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(3, this->pad(), target);
- }
-
- // optional uint32 kernel_size = 4;
- if (has_kernel_size()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(4, this->kernel_size(), target);
- }
-
- // optional uint32 group = 5 [default = 1];
- if (has_group()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(5, this->group(), target);
- }
-
- // optional uint32 stride = 6 [default = 1];
- if (has_stride()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(6, this->stride(), target);
- }
-
- // optional .caffe.FillerParameter weight_filler = 7;
- if (has_weight_filler()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 7, *this->weight_filler_, false, target);
- }
-
- // optional .caffe.FillerParameter bias_filler = 8;
- if (has_bias_filler()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 8, *this->bias_filler_, false, target);
- }
-
- // optional uint32 pad_h = 9 [default = 0];
- if (has_pad_h()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(9, this->pad_h(), target);
- }
-
- // optional uint32 pad_w = 10 [default = 0];
- if (has_pad_w()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(10, this->pad_w(), target);
- }
-
- // optional uint32 kernel_h = 11;
- if (has_kernel_h()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(11, this->kernel_h(), target);
- }
-
- // optional uint32 kernel_w = 12;
- if (has_kernel_w()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(12, this->kernel_w(), target);
- }
-
- // optional uint32 stride_h = 13;
- if (has_stride_h()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(13, this->stride_h(), target);
- }
-
- // optional uint32 stride_w = 14;
- if (has_stride_w()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(14, this->stride_w(), target);
- }
-
- // optional .caffe.ConvolutionParameter.Engine engine = 15 [default = DEFAULT];
- if (has_engine()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 15, this->engine(), target);
- }
-
- // optional uint32 dilation_h = 18;
- if (has_dilation_h()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(18, this->dilation_h(), target);
- }
-
- // optional uint32 dilation_w = 19;
- if (has_dilation_w()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(19, this->dilation_w(), target);
- }
-
- // optional uint32 dilation = 20;
- if (has_dilation()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(20, this->dilation(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.ConvolutionParameter)
- return target;
-}
-
-size_t ConvolutionParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.ConvolutionParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 255u) {
- // optional uint32 num_output = 1;
- if (has_num_output()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->num_output());
- }
-
- // optional bool bias_term = 2 [default = true];
- if (has_bias_term()) {
- total_size += 1 + 1;
- }
-
- // optional uint32 pad = 3 [default = 0];
- if (has_pad()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->pad());
- }
-
- // optional uint32 pad_h = 9 [default = 0];
- if (has_pad_h()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->pad_h());
- }
-
- // optional uint32 pad_w = 10 [default = 0];
- if (has_pad_w()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->pad_w());
- }
-
- // optional uint32 kernel_size = 4;
- if (has_kernel_size()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->kernel_size());
- }
-
- // optional uint32 kernel_h = 11;
- if (has_kernel_h()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->kernel_h());
- }
-
- // optional uint32 kernel_w = 12;
- if (has_kernel_w()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->kernel_w());
- }
-
- }
- if (_has_bits_[8 / 32] & 65280u) {
- // optional uint32 group = 5 [default = 1];
- if (has_group()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->group());
- }
-
- // optional uint32 stride = 6 [default = 1];
- if (has_stride()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->stride());
- }
-
- // optional uint32 stride_h = 13;
- if (has_stride_h()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->stride_h());
- }
-
- // optional uint32 stride_w = 14;
- if (has_stride_w()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->stride_w());
- }
-
- // optional .caffe.FillerParameter weight_filler = 7;
- if (has_weight_filler()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->weight_filler_);
- }
-
- // optional .caffe.FillerParameter bias_filler = 8;
- if (has_bias_filler()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->bias_filler_);
- }
-
- // optional .caffe.ConvolutionParameter.Engine engine = 15 [default = DEFAULT];
- if (has_engine()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->engine());
- }
-
- // optional uint32 dilation_h = 18;
- if (has_dilation_h()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->dilation_h());
- }
-
- }
- if (_has_bits_[16 / 32] & 196608u) {
- // optional uint32 dilation_w = 19;
- if (has_dilation_w()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->dilation_w());
- }
-
- // optional uint32 dilation = 20;
- if (has_dilation()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->dilation());
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void ConvolutionParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.ConvolutionParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const ConvolutionParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const ConvolutionParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ConvolutionParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ConvolutionParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void ConvolutionParameter::MergeFrom(const ConvolutionParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ConvolutionParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void ConvolutionParameter::UnsafeMergeFrom(const ConvolutionParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_num_output()) {
- set_num_output(from.num_output());
- }
- if (from.has_bias_term()) {
- set_bias_term(from.bias_term());
- }
- if (from.has_pad()) {
- set_pad(from.pad());
- }
- if (from.has_pad_h()) {
- set_pad_h(from.pad_h());
- }
- if (from.has_pad_w()) {
- set_pad_w(from.pad_w());
- }
- if (from.has_kernel_size()) {
- set_kernel_size(from.kernel_size());
- }
- if (from.has_kernel_h()) {
- set_kernel_h(from.kernel_h());
- }
- if (from.has_kernel_w()) {
- set_kernel_w(from.kernel_w());
- }
- }
- if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) {
- if (from.has_group()) {
- set_group(from.group());
- }
- if (from.has_stride()) {
- set_stride(from.stride());
- }
- if (from.has_stride_h()) {
- set_stride_h(from.stride_h());
- }
- if (from.has_stride_w()) {
- set_stride_w(from.stride_w());
- }
- if (from.has_weight_filler()) {
- mutable_weight_filler()->::caffe::FillerParameter::MergeFrom(from.weight_filler());
- }
- if (from.has_bias_filler()) {
- mutable_bias_filler()->::caffe::FillerParameter::MergeFrom(from.bias_filler());
- }
- if (from.has_engine()) {
- set_engine(from.engine());
- }
- if (from.has_dilation_h()) {
- set_dilation_h(from.dilation_h());
- }
- }
- if (from._has_bits_[16 / 32] & (0xffu << (16 % 32))) {
- if (from.has_dilation_w()) {
- set_dilation_w(from.dilation_w());
- }
- if (from.has_dilation()) {
- set_dilation(from.dilation());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void ConvolutionParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.ConvolutionParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void ConvolutionParameter::CopyFrom(const ConvolutionParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ConvolutionParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool ConvolutionParameter::IsInitialized() const {
-
- return true;
-}
-
-void ConvolutionParameter::Swap(ConvolutionParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void ConvolutionParameter::InternalSwap(ConvolutionParameter* other) {
- std::swap(num_output_, other->num_output_);
- std::swap(bias_term_, other->bias_term_);
- std::swap(pad_, other->pad_);
- std::swap(pad_h_, other->pad_h_);
- std::swap(pad_w_, other->pad_w_);
- std::swap(kernel_size_, other->kernel_size_);
- std::swap(kernel_h_, other->kernel_h_);
- std::swap(kernel_w_, other->kernel_w_);
- std::swap(group_, other->group_);
- std::swap(stride_, other->stride_);
- std::swap(stride_h_, other->stride_h_);
- std::swap(stride_w_, other->stride_w_);
- std::swap(weight_filler_, other->weight_filler_);
- std::swap(bias_filler_, other->bias_filler_);
- std::swap(engine_, other->engine_);
- std::swap(dilation_h_, other->dilation_h_);
- std::swap(dilation_w_, other->dilation_w_);
- std::swap(dilation_, other->dilation_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata ConvolutionParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = ConvolutionParameter_descriptor_;
- metadata.reflection = ConvolutionParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// ConvolutionParameter
-
-// optional uint32 num_output = 1;
-bool ConvolutionParameter::has_num_output() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void ConvolutionParameter::set_has_num_output() {
- _has_bits_[0] |= 0x00000001u;
-}
-void ConvolutionParameter::clear_has_num_output() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void ConvolutionParameter::clear_num_output() {
- num_output_ = 0u;
- clear_has_num_output();
-}
-::google::protobuf::uint32 ConvolutionParameter::num_output() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.num_output)
- return num_output_;
-}
-void ConvolutionParameter::set_num_output(::google::protobuf::uint32 value) {
- set_has_num_output();
- num_output_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.num_output)
-}
-
-// optional bool bias_term = 2 [default = true];
-bool ConvolutionParameter::has_bias_term() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void ConvolutionParameter::set_has_bias_term() {
- _has_bits_[0] |= 0x00000002u;
-}
-void ConvolutionParameter::clear_has_bias_term() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void ConvolutionParameter::clear_bias_term() {
- bias_term_ = true;
- clear_has_bias_term();
-}
-bool ConvolutionParameter::bias_term() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.bias_term)
- return bias_term_;
-}
-void ConvolutionParameter::set_bias_term(bool value) {
- set_has_bias_term();
- bias_term_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.bias_term)
-}
-
-// optional uint32 pad = 3 [default = 0];
-bool ConvolutionParameter::has_pad() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void ConvolutionParameter::set_has_pad() {
- _has_bits_[0] |= 0x00000004u;
-}
-void ConvolutionParameter::clear_has_pad() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void ConvolutionParameter::clear_pad() {
- pad_ = 0u;
- clear_has_pad();
-}
-::google::protobuf::uint32 ConvolutionParameter::pad() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.pad)
- return pad_;
-}
-void ConvolutionParameter::set_pad(::google::protobuf::uint32 value) {
- set_has_pad();
- pad_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.pad)
-}
-
-// optional uint32 pad_h = 9 [default = 0];
-bool ConvolutionParameter::has_pad_h() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-void ConvolutionParameter::set_has_pad_h() {
- _has_bits_[0] |= 0x00000008u;
-}
-void ConvolutionParameter::clear_has_pad_h() {
- _has_bits_[0] &= ~0x00000008u;
-}
-void ConvolutionParameter::clear_pad_h() {
- pad_h_ = 0u;
- clear_has_pad_h();
-}
-::google::protobuf::uint32 ConvolutionParameter::pad_h() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.pad_h)
- return pad_h_;
-}
-void ConvolutionParameter::set_pad_h(::google::protobuf::uint32 value) {
- set_has_pad_h();
- pad_h_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.pad_h)
-}
-
-// optional uint32 pad_w = 10 [default = 0];
-bool ConvolutionParameter::has_pad_w() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-void ConvolutionParameter::set_has_pad_w() {
- _has_bits_[0] |= 0x00000010u;
-}
-void ConvolutionParameter::clear_has_pad_w() {
- _has_bits_[0] &= ~0x00000010u;
-}
-void ConvolutionParameter::clear_pad_w() {
- pad_w_ = 0u;
- clear_has_pad_w();
-}
-::google::protobuf::uint32 ConvolutionParameter::pad_w() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.pad_w)
- return pad_w_;
-}
-void ConvolutionParameter::set_pad_w(::google::protobuf::uint32 value) {
- set_has_pad_w();
- pad_w_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.pad_w)
-}
-
-// optional uint32 kernel_size = 4;
-bool ConvolutionParameter::has_kernel_size() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-void ConvolutionParameter::set_has_kernel_size() {
- _has_bits_[0] |= 0x00000020u;
-}
-void ConvolutionParameter::clear_has_kernel_size() {
- _has_bits_[0] &= ~0x00000020u;
-}
-void ConvolutionParameter::clear_kernel_size() {
- kernel_size_ = 0u;
- clear_has_kernel_size();
-}
-::google::protobuf::uint32 ConvolutionParameter::kernel_size() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.kernel_size)
- return kernel_size_;
-}
-void ConvolutionParameter::set_kernel_size(::google::protobuf::uint32 value) {
- set_has_kernel_size();
- kernel_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.kernel_size)
-}
-
-// optional uint32 kernel_h = 11;
-bool ConvolutionParameter::has_kernel_h() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-void ConvolutionParameter::set_has_kernel_h() {
- _has_bits_[0] |= 0x00000040u;
-}
-void ConvolutionParameter::clear_has_kernel_h() {
- _has_bits_[0] &= ~0x00000040u;
-}
-void ConvolutionParameter::clear_kernel_h() {
- kernel_h_ = 0u;
- clear_has_kernel_h();
-}
-::google::protobuf::uint32 ConvolutionParameter::kernel_h() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.kernel_h)
- return kernel_h_;
-}
-void ConvolutionParameter::set_kernel_h(::google::protobuf::uint32 value) {
- set_has_kernel_h();
- kernel_h_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.kernel_h)
-}
-
-// optional uint32 kernel_w = 12;
-bool ConvolutionParameter::has_kernel_w() const {
- return (_has_bits_[0] & 0x00000080u) != 0;
-}
-void ConvolutionParameter::set_has_kernel_w() {
- _has_bits_[0] |= 0x00000080u;
-}
-void ConvolutionParameter::clear_has_kernel_w() {
- _has_bits_[0] &= ~0x00000080u;
-}
-void ConvolutionParameter::clear_kernel_w() {
- kernel_w_ = 0u;
- clear_has_kernel_w();
-}
-::google::protobuf::uint32 ConvolutionParameter::kernel_w() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.kernel_w)
- return kernel_w_;
-}
-void ConvolutionParameter::set_kernel_w(::google::protobuf::uint32 value) {
- set_has_kernel_w();
- kernel_w_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.kernel_w)
-}
-
-// optional uint32 group = 5 [default = 1];
-bool ConvolutionParameter::has_group() const {
- return (_has_bits_[0] & 0x00000100u) != 0;
-}
-void ConvolutionParameter::set_has_group() {
- _has_bits_[0] |= 0x00000100u;
-}
-void ConvolutionParameter::clear_has_group() {
- _has_bits_[0] &= ~0x00000100u;
-}
-void ConvolutionParameter::clear_group() {
- group_ = 1u;
- clear_has_group();
-}
-::google::protobuf::uint32 ConvolutionParameter::group() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.group)
- return group_;
-}
-void ConvolutionParameter::set_group(::google::protobuf::uint32 value) {
- set_has_group();
- group_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.group)
-}
-
-// optional uint32 stride = 6 [default = 1];
-bool ConvolutionParameter::has_stride() const {
- return (_has_bits_[0] & 0x00000200u) != 0;
-}
-void ConvolutionParameter::set_has_stride() {
- _has_bits_[0] |= 0x00000200u;
-}
-void ConvolutionParameter::clear_has_stride() {
- _has_bits_[0] &= ~0x00000200u;
-}
-void ConvolutionParameter::clear_stride() {
- stride_ = 1u;
- clear_has_stride();
-}
-::google::protobuf::uint32 ConvolutionParameter::stride() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.stride)
- return stride_;
-}
-void ConvolutionParameter::set_stride(::google::protobuf::uint32 value) {
- set_has_stride();
- stride_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.stride)
-}
-
-// optional uint32 stride_h = 13;
-bool ConvolutionParameter::has_stride_h() const {
- return (_has_bits_[0] & 0x00000400u) != 0;
-}
-void ConvolutionParameter::set_has_stride_h() {
- _has_bits_[0] |= 0x00000400u;
-}
-void ConvolutionParameter::clear_has_stride_h() {
- _has_bits_[0] &= ~0x00000400u;
-}
-void ConvolutionParameter::clear_stride_h() {
- stride_h_ = 0u;
- clear_has_stride_h();
-}
-::google::protobuf::uint32 ConvolutionParameter::stride_h() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.stride_h)
- return stride_h_;
-}
-void ConvolutionParameter::set_stride_h(::google::protobuf::uint32 value) {
- set_has_stride_h();
- stride_h_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.stride_h)
-}
-
-// optional uint32 stride_w = 14;
-bool ConvolutionParameter::has_stride_w() const {
- return (_has_bits_[0] & 0x00000800u) != 0;
-}
-void ConvolutionParameter::set_has_stride_w() {
- _has_bits_[0] |= 0x00000800u;
-}
-void ConvolutionParameter::clear_has_stride_w() {
- _has_bits_[0] &= ~0x00000800u;
-}
-void ConvolutionParameter::clear_stride_w() {
- stride_w_ = 0u;
- clear_has_stride_w();
-}
-::google::protobuf::uint32 ConvolutionParameter::stride_w() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.stride_w)
- return stride_w_;
-}
-void ConvolutionParameter::set_stride_w(::google::protobuf::uint32 value) {
- set_has_stride_w();
- stride_w_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.stride_w)
-}
-
-// optional .caffe.FillerParameter weight_filler = 7;
-bool ConvolutionParameter::has_weight_filler() const {
- return (_has_bits_[0] & 0x00001000u) != 0;
-}
-void ConvolutionParameter::set_has_weight_filler() {
- _has_bits_[0] |= 0x00001000u;
-}
-void ConvolutionParameter::clear_has_weight_filler() {
- _has_bits_[0] &= ~0x00001000u;
-}
-void ConvolutionParameter::clear_weight_filler() {
- if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear();
- clear_has_weight_filler();
-}
-const ::caffe::FillerParameter& ConvolutionParameter::weight_filler() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.weight_filler)
- return weight_filler_ != NULL ? *weight_filler_
- : *::caffe::FillerParameter::internal_default_instance();
-}
-::caffe::FillerParameter* ConvolutionParameter::mutable_weight_filler() {
- set_has_weight_filler();
- if (weight_filler_ == NULL) {
- weight_filler_ = new ::caffe::FillerParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.ConvolutionParameter.weight_filler)
- return weight_filler_;
-}
-::caffe::FillerParameter* ConvolutionParameter::release_weight_filler() {
- // @@protoc_insertion_point(field_release:caffe.ConvolutionParameter.weight_filler)
- clear_has_weight_filler();
- ::caffe::FillerParameter* temp = weight_filler_;
- weight_filler_ = NULL;
- return temp;
-}
-void ConvolutionParameter::set_allocated_weight_filler(::caffe::FillerParameter* weight_filler) {
- delete weight_filler_;
- weight_filler_ = weight_filler;
- if (weight_filler) {
- set_has_weight_filler();
- } else {
- clear_has_weight_filler();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.ConvolutionParameter.weight_filler)
-}
-
-// optional .caffe.FillerParameter bias_filler = 8;
-bool ConvolutionParameter::has_bias_filler() const {
- return (_has_bits_[0] & 0x00002000u) != 0;
-}
-void ConvolutionParameter::set_has_bias_filler() {
- _has_bits_[0] |= 0x00002000u;
-}
-void ConvolutionParameter::clear_has_bias_filler() {
- _has_bits_[0] &= ~0x00002000u;
-}
-void ConvolutionParameter::clear_bias_filler() {
- if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
- clear_has_bias_filler();
-}
-const ::caffe::FillerParameter& ConvolutionParameter::bias_filler() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.bias_filler)
- return bias_filler_ != NULL ? *bias_filler_
- : *::caffe::FillerParameter::internal_default_instance();
-}
-::caffe::FillerParameter* ConvolutionParameter::mutable_bias_filler() {
- set_has_bias_filler();
- if (bias_filler_ == NULL) {
- bias_filler_ = new ::caffe::FillerParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.ConvolutionParameter.bias_filler)
- return bias_filler_;
-}
-::caffe::FillerParameter* ConvolutionParameter::release_bias_filler() {
- // @@protoc_insertion_point(field_release:caffe.ConvolutionParameter.bias_filler)
- clear_has_bias_filler();
- ::caffe::FillerParameter* temp = bias_filler_;
- bias_filler_ = NULL;
- return temp;
-}
-void ConvolutionParameter::set_allocated_bias_filler(::caffe::FillerParameter* bias_filler) {
- delete bias_filler_;
- bias_filler_ = bias_filler;
- if (bias_filler) {
- set_has_bias_filler();
- } else {
- clear_has_bias_filler();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.ConvolutionParameter.bias_filler)
-}
-
-// optional .caffe.ConvolutionParameter.Engine engine = 15 [default = DEFAULT];
-bool ConvolutionParameter::has_engine() const {
- return (_has_bits_[0] & 0x00004000u) != 0;
-}
-void ConvolutionParameter::set_has_engine() {
- _has_bits_[0] |= 0x00004000u;
-}
-void ConvolutionParameter::clear_has_engine() {
- _has_bits_[0] &= ~0x00004000u;
-}
-void ConvolutionParameter::clear_engine() {
- engine_ = 0;
- clear_has_engine();
-}
-::caffe::ConvolutionParameter_Engine ConvolutionParameter::engine() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.engine)
- return static_cast< ::caffe::ConvolutionParameter_Engine >(engine_);
-}
-void ConvolutionParameter::set_engine(::caffe::ConvolutionParameter_Engine value) {
- assert(::caffe::ConvolutionParameter_Engine_IsValid(value));
- set_has_engine();
- engine_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.engine)
-}
-
-// optional uint32 dilation_h = 18;
-bool ConvolutionParameter::has_dilation_h() const {
- return (_has_bits_[0] & 0x00008000u) != 0;
-}
-void ConvolutionParameter::set_has_dilation_h() {
- _has_bits_[0] |= 0x00008000u;
-}
-void ConvolutionParameter::clear_has_dilation_h() {
- _has_bits_[0] &= ~0x00008000u;
-}
-void ConvolutionParameter::clear_dilation_h() {
- dilation_h_ = 0u;
- clear_has_dilation_h();
-}
-::google::protobuf::uint32 ConvolutionParameter::dilation_h() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.dilation_h)
- return dilation_h_;
-}
-void ConvolutionParameter::set_dilation_h(::google::protobuf::uint32 value) {
- set_has_dilation_h();
- dilation_h_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.dilation_h)
-}
-
-// optional uint32 dilation_w = 19;
-bool ConvolutionParameter::has_dilation_w() const {
- return (_has_bits_[0] & 0x00010000u) != 0;
-}
-void ConvolutionParameter::set_has_dilation_w() {
- _has_bits_[0] |= 0x00010000u;
-}
-void ConvolutionParameter::clear_has_dilation_w() {
- _has_bits_[0] &= ~0x00010000u;
-}
-void ConvolutionParameter::clear_dilation_w() {
- dilation_w_ = 0u;
- clear_has_dilation_w();
-}
-::google::protobuf::uint32 ConvolutionParameter::dilation_w() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.dilation_w)
- return dilation_w_;
-}
-void ConvolutionParameter::set_dilation_w(::google::protobuf::uint32 value) {
- set_has_dilation_w();
- dilation_w_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.dilation_w)
-}
-
-// optional uint32 dilation = 20;
-bool ConvolutionParameter::has_dilation() const {
- return (_has_bits_[0] & 0x00020000u) != 0;
-}
-void ConvolutionParameter::set_has_dilation() {
- _has_bits_[0] |= 0x00020000u;
-}
-void ConvolutionParameter::clear_has_dilation() {
- _has_bits_[0] &= ~0x00020000u;
-}
-void ConvolutionParameter::clear_dilation() {
- dilation_ = 0u;
- clear_has_dilation();
-}
-::google::protobuf::uint32 ConvolutionParameter::dilation() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.dilation)
- return dilation_;
-}
-void ConvolutionParameter::set_dilation(::google::protobuf::uint32 value) {
- set_has_dilation();
- dilation_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.dilation)
-}
-
-inline const ConvolutionParameter* ConvolutionParameter::internal_default_instance() {
- return &ConvolutionParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-const ::google::protobuf::EnumDescriptor* DataParameter_DB_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return DataParameter_DB_descriptor_;
-}
-bool DataParameter_DB_IsValid(int value) {
- switch (value) {
- case 0:
- case 1:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const DataParameter_DB DataParameter::LEVELDB;
-const DataParameter_DB DataParameter::LMDB;
-const DataParameter_DB DataParameter::DB_MIN;
-const DataParameter_DB DataParameter::DB_MAX;
-const int DataParameter::DB_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int DataParameter::kSourceFieldNumber;
-const int DataParameter::kBatchSizeFieldNumber;
-const int DataParameter::kRandSkipFieldNumber;
-const int DataParameter::kBackendFieldNumber;
-const int DataParameter::kScaleFieldNumber;
-const int DataParameter::kMeanFileFieldNumber;
-const int DataParameter::kCropSizeFieldNumber;
-const int DataParameter::kMirrorFieldNumber;
-const int DataParameter::kForceEncodedColorFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-DataParameter::DataParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.DataParameter)
-}
-
-void DataParameter::InitAsDefaultInstance() {
-}
-
-DataParameter::DataParameter(const DataParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.DataParameter)
-}
-
-void DataParameter::SharedCtor() {
- _cached_size_ = 0;
- source_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- mean_file_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- ::memset(&batch_size_, 0, reinterpret_cast<char*>(&force_encoded_color_) -
- reinterpret_cast<char*>(&batch_size_) + sizeof(force_encoded_color_));
- scale_ = 1;
-}
-
-DataParameter::~DataParameter() {
- // @@protoc_insertion_point(destructor:caffe.DataParameter)
- SharedDtor();
-}
-
-void DataParameter::SharedDtor() {
- source_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- mean_file_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-
-void DataParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* DataParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return DataParameter_descriptor_;
-}
-
-const DataParameter& DataParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<DataParameter> DataParameter_default_instance_;
-
-DataParameter* DataParameter::New(::google::protobuf::Arena* arena) const {
- DataParameter* n = new DataParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void DataParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.DataParameter)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(DataParameter, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<DataParameter*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- if (_has_bits_[0 / 32] & 255u) {
- ZR_(batch_size_, mirror_);
- if (has_source()) {
- source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- scale_ = 1;
- if (has_mean_file()) {
- mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- }
- force_encoded_color_ = false;
-
-#undef ZR_HELPER_
-#undef ZR_
-
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool DataParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.DataParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional string source = 1;
- case 1: {
- if (tag == 10) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_source()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->source().data(), this->source().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.DataParameter.source");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(21)) goto parse_scale;
- break;
- }
-
- // optional float scale = 2 [default = 1];
- case 2: {
- if (tag == 21) {
- parse_scale:
- set_has_scale();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &scale_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(26)) goto parse_mean_file;
- break;
- }
-
- // optional string mean_file = 3;
- case 3: {
- if (tag == 26) {
- parse_mean_file:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_mean_file()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->mean_file().data(), this->mean_file().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.DataParameter.mean_file");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(32)) goto parse_batch_size;
- break;
- }
-
- // optional uint32 batch_size = 4;
- case 4: {
- if (tag == 32) {
- parse_batch_size:
- set_has_batch_size();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &batch_size_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(40)) goto parse_crop_size;
- break;
- }
-
- // optional uint32 crop_size = 5 [default = 0];
- case 5: {
- if (tag == 40) {
- parse_crop_size:
- set_has_crop_size();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &crop_size_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(48)) goto parse_mirror;
- break;
- }
-
- // optional bool mirror = 6 [default = false];
- case 6: {
- if (tag == 48) {
- parse_mirror:
- set_has_mirror();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &mirror_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(56)) goto parse_rand_skip;
- break;
- }
-
- // optional uint32 rand_skip = 7 [default = 0];
- case 7: {
- if (tag == 56) {
- parse_rand_skip:
- set_has_rand_skip();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &rand_skip_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(64)) goto parse_backend;
- break;
- }
-
- // optional .caffe.DataParameter.DB backend = 8 [default = LEVELDB];
- case 8: {
- if (tag == 64) {
- parse_backend:
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::DataParameter_DB_IsValid(value)) {
- set_backend(static_cast< ::caffe::DataParameter_DB >(value));
- } else {
- mutable_unknown_fields()->AddVarint(8, value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(72)) goto parse_force_encoded_color;
- break;
- }
-
- // optional bool force_encoded_color = 9 [default = false];
- case 9: {
- if (tag == 72) {
- parse_force_encoded_color:
- set_has_force_encoded_color();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &force_encoded_color_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.DataParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.DataParameter)
- return false;
-#undef DO_
-}
-
-void DataParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.DataParameter)
- // optional string source = 1;
- if (has_source()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->source().data(), this->source().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.DataParameter.source");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 1, this->source(), output);
- }
-
- // optional float scale = 2 [default = 1];
- if (has_scale()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->scale(), output);
- }
-
- // optional string mean_file = 3;
- if (has_mean_file()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->mean_file().data(), this->mean_file().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.DataParameter.mean_file");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 3, this->mean_file(), output);
- }
-
- // optional uint32 batch_size = 4;
- if (has_batch_size()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(4, this->batch_size(), output);
- }
-
- // optional uint32 crop_size = 5 [default = 0];
- if (has_crop_size()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(5, this->crop_size(), output);
- }
-
- // optional bool mirror = 6 [default = false];
- if (has_mirror()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(6, this->mirror(), output);
- }
-
- // optional uint32 rand_skip = 7 [default = 0];
- if (has_rand_skip()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(7, this->rand_skip(), output);
- }
-
- // optional .caffe.DataParameter.DB backend = 8 [default = LEVELDB];
- if (has_backend()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 8, this->backend(), output);
- }
-
- // optional bool force_encoded_color = 9 [default = false];
- if (has_force_encoded_color()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(9, this->force_encoded_color(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.DataParameter)
-}
-
-::google::protobuf::uint8* DataParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.DataParameter)
- // optional string source = 1;
- if (has_source()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->source().data(), this->source().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.DataParameter.source");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 1, this->source(), target);
- }
-
- // optional float scale = 2 [default = 1];
- if (has_scale()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->scale(), target);
- }
-
- // optional string mean_file = 3;
- if (has_mean_file()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->mean_file().data(), this->mean_file().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.DataParameter.mean_file");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 3, this->mean_file(), target);
- }
-
- // optional uint32 batch_size = 4;
- if (has_batch_size()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(4, this->batch_size(), target);
- }
-
- // optional uint32 crop_size = 5 [default = 0];
- if (has_crop_size()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(5, this->crop_size(), target);
- }
-
- // optional bool mirror = 6 [default = false];
- if (has_mirror()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(6, this->mirror(), target);
- }
-
- // optional uint32 rand_skip = 7 [default = 0];
- if (has_rand_skip()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(7, this->rand_skip(), target);
- }
-
- // optional .caffe.DataParameter.DB backend = 8 [default = LEVELDB];
- if (has_backend()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 8, this->backend(), target);
- }
-
- // optional bool force_encoded_color = 9 [default = false];
- if (has_force_encoded_color()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(9, this->force_encoded_color(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.DataParameter)
- return target;
-}
-
-size_t DataParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.DataParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 255u) {
- // optional string source = 1;
- if (has_source()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->source());
- }
-
- // optional uint32 batch_size = 4;
- if (has_batch_size()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->batch_size());
- }
-
- // optional uint32 rand_skip = 7 [default = 0];
- if (has_rand_skip()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->rand_skip());
- }
-
- // optional .caffe.DataParameter.DB backend = 8 [default = LEVELDB];
- if (has_backend()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->backend());
- }
-
- // optional float scale = 2 [default = 1];
- if (has_scale()) {
- total_size += 1 + 4;
- }
-
- // optional string mean_file = 3;
- if (has_mean_file()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->mean_file());
- }
-
- // optional uint32 crop_size = 5 [default = 0];
- if (has_crop_size()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->crop_size());
- }
-
- // optional bool mirror = 6 [default = false];
- if (has_mirror()) {
- total_size += 1 + 1;
- }
-
- }
- // optional bool force_encoded_color = 9 [default = false];
- if (has_force_encoded_color()) {
- total_size += 1 + 1;
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void DataParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.DataParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const DataParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const DataParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.DataParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.DataParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void DataParameter::MergeFrom(const DataParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.DataParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void DataParameter::UnsafeMergeFrom(const DataParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_source()) {
- set_has_source();
- source_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_);
- }
- if (from.has_batch_size()) {
- set_batch_size(from.batch_size());
- }
- if (from.has_rand_skip()) {
- set_rand_skip(from.rand_skip());
- }
- if (from.has_backend()) {
- set_backend(from.backend());
- }
- if (from.has_scale()) {
- set_scale(from.scale());
- }
- if (from.has_mean_file()) {
- set_has_mean_file();
- mean_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.mean_file_);
- }
- if (from.has_crop_size()) {
- set_crop_size(from.crop_size());
- }
- if (from.has_mirror()) {
- set_mirror(from.mirror());
- }
- }
- if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) {
- if (from.has_force_encoded_color()) {
- set_force_encoded_color(from.force_encoded_color());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void DataParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.DataParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void DataParameter::CopyFrom(const DataParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.DataParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool DataParameter::IsInitialized() const {
-
- return true;
-}
-
-void DataParameter::Swap(DataParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void DataParameter::InternalSwap(DataParameter* other) {
- source_.Swap(&other->source_);
- std::swap(batch_size_, other->batch_size_);
- std::swap(rand_skip_, other->rand_skip_);
- std::swap(backend_, other->backend_);
- std::swap(scale_, other->scale_);
- mean_file_.Swap(&other->mean_file_);
- std::swap(crop_size_, other->crop_size_);
- std::swap(mirror_, other->mirror_);
- std::swap(force_encoded_color_, other->force_encoded_color_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata DataParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = DataParameter_descriptor_;
- metadata.reflection = DataParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// DataParameter
-
-// optional string source = 1;
-bool DataParameter::has_source() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void DataParameter::set_has_source() {
- _has_bits_[0] |= 0x00000001u;
-}
-void DataParameter::clear_has_source() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void DataParameter::clear_source() {
- source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_source();
-}
-const ::std::string& DataParameter::source() const {
- // @@protoc_insertion_point(field_get:caffe.DataParameter.source)
- return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void DataParameter::set_source(const ::std::string& value) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.DataParameter.source)
-}
-void DataParameter::set_source(const char* value) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.DataParameter.source)
-}
-void DataParameter::set_source(const char* value, size_t size) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.DataParameter.source)
-}
-::std::string* DataParameter::mutable_source() {
- set_has_source();
- // @@protoc_insertion_point(field_mutable:caffe.DataParameter.source)
- return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* DataParameter::release_source() {
- // @@protoc_insertion_point(field_release:caffe.DataParameter.source)
- clear_has_source();
- return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void DataParameter::set_allocated_source(::std::string* source) {
- if (source != NULL) {
- set_has_source();
- } else {
- clear_has_source();
- }
- source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source);
- // @@protoc_insertion_point(field_set_allocated:caffe.DataParameter.source)
-}
-
-// optional uint32 batch_size = 4;
-bool DataParameter::has_batch_size() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void DataParameter::set_has_batch_size() {
- _has_bits_[0] |= 0x00000002u;
-}
-void DataParameter::clear_has_batch_size() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void DataParameter::clear_batch_size() {
- batch_size_ = 0u;
- clear_has_batch_size();
-}
-::google::protobuf::uint32 DataParameter::batch_size() const {
- // @@protoc_insertion_point(field_get:caffe.DataParameter.batch_size)
- return batch_size_;
-}
-void DataParameter::set_batch_size(::google::protobuf::uint32 value) {
- set_has_batch_size();
- batch_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.DataParameter.batch_size)
-}
-
-// optional uint32 rand_skip = 7 [default = 0];
-bool DataParameter::has_rand_skip() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void DataParameter::set_has_rand_skip() {
- _has_bits_[0] |= 0x00000004u;
-}
-void DataParameter::clear_has_rand_skip() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void DataParameter::clear_rand_skip() {
- rand_skip_ = 0u;
- clear_has_rand_skip();
-}
-::google::protobuf::uint32 DataParameter::rand_skip() const {
- // @@protoc_insertion_point(field_get:caffe.DataParameter.rand_skip)
- return rand_skip_;
-}
-void DataParameter::set_rand_skip(::google::protobuf::uint32 value) {
- set_has_rand_skip();
- rand_skip_ = value;
- // @@protoc_insertion_point(field_set:caffe.DataParameter.rand_skip)
-}
-
-// optional .caffe.DataParameter.DB backend = 8 [default = LEVELDB];
-bool DataParameter::has_backend() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-void DataParameter::set_has_backend() {
- _has_bits_[0] |= 0x00000008u;
-}
-void DataParameter::clear_has_backend() {
- _has_bits_[0] &= ~0x00000008u;
-}
-void DataParameter::clear_backend() {
- backend_ = 0;
- clear_has_backend();
-}
-::caffe::DataParameter_DB DataParameter::backend() const {
- // @@protoc_insertion_point(field_get:caffe.DataParameter.backend)
- return static_cast< ::caffe::DataParameter_DB >(backend_);
-}
-void DataParameter::set_backend(::caffe::DataParameter_DB value) {
- assert(::caffe::DataParameter_DB_IsValid(value));
- set_has_backend();
- backend_ = value;
- // @@protoc_insertion_point(field_set:caffe.DataParameter.backend)
-}
-
-// optional float scale = 2 [default = 1];
-bool DataParameter::has_scale() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-void DataParameter::set_has_scale() {
- _has_bits_[0] |= 0x00000010u;
-}
-void DataParameter::clear_has_scale() {
- _has_bits_[0] &= ~0x00000010u;
-}
-void DataParameter::clear_scale() {
- scale_ = 1;
- clear_has_scale();
-}
-float DataParameter::scale() const {
- // @@protoc_insertion_point(field_get:caffe.DataParameter.scale)
- return scale_;
-}
-void DataParameter::set_scale(float value) {
- set_has_scale();
- scale_ = value;
- // @@protoc_insertion_point(field_set:caffe.DataParameter.scale)
-}
-
-// optional string mean_file = 3;
-bool DataParameter::has_mean_file() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-void DataParameter::set_has_mean_file() {
- _has_bits_[0] |= 0x00000020u;
-}
-void DataParameter::clear_has_mean_file() {
- _has_bits_[0] &= ~0x00000020u;
-}
-void DataParameter::clear_mean_file() {
- mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_mean_file();
-}
-const ::std::string& DataParameter::mean_file() const {
- // @@protoc_insertion_point(field_get:caffe.DataParameter.mean_file)
- return mean_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void DataParameter::set_mean_file(const ::std::string& value) {
- set_has_mean_file();
- mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.DataParameter.mean_file)
-}
-void DataParameter::set_mean_file(const char* value) {
- set_has_mean_file();
- mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.DataParameter.mean_file)
-}
-void DataParameter::set_mean_file(const char* value, size_t size) {
- set_has_mean_file();
- mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.DataParameter.mean_file)
-}
-::std::string* DataParameter::mutable_mean_file() {
- set_has_mean_file();
- // @@protoc_insertion_point(field_mutable:caffe.DataParameter.mean_file)
- return mean_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* DataParameter::release_mean_file() {
- // @@protoc_insertion_point(field_release:caffe.DataParameter.mean_file)
- clear_has_mean_file();
- return mean_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void DataParameter::set_allocated_mean_file(::std::string* mean_file) {
- if (mean_file != NULL) {
- set_has_mean_file();
- } else {
- clear_has_mean_file();
- }
- mean_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), mean_file);
- // @@protoc_insertion_point(field_set_allocated:caffe.DataParameter.mean_file)
-}
-
-// optional uint32 crop_size = 5 [default = 0];
-bool DataParameter::has_crop_size() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-void DataParameter::set_has_crop_size() {
- _has_bits_[0] |= 0x00000040u;
-}
-void DataParameter::clear_has_crop_size() {
- _has_bits_[0] &= ~0x00000040u;
-}
-void DataParameter::clear_crop_size() {
- crop_size_ = 0u;
- clear_has_crop_size();
-}
-::google::protobuf::uint32 DataParameter::crop_size() const {
- // @@protoc_insertion_point(field_get:caffe.DataParameter.crop_size)
- return crop_size_;
-}
-void DataParameter::set_crop_size(::google::protobuf::uint32 value) {
- set_has_crop_size();
- crop_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.DataParameter.crop_size)
-}
-
-// optional bool mirror = 6 [default = false];
-bool DataParameter::has_mirror() const {
- return (_has_bits_[0] & 0x00000080u) != 0;
-}
-void DataParameter::set_has_mirror() {
- _has_bits_[0] |= 0x00000080u;
-}
-void DataParameter::clear_has_mirror() {
- _has_bits_[0] &= ~0x00000080u;
-}
-void DataParameter::clear_mirror() {
- mirror_ = false;
- clear_has_mirror();
-}
-bool DataParameter::mirror() const {
- // @@protoc_insertion_point(field_get:caffe.DataParameter.mirror)
- return mirror_;
-}
-void DataParameter::set_mirror(bool value) {
- set_has_mirror();
- mirror_ = value;
- // @@protoc_insertion_point(field_set:caffe.DataParameter.mirror)
-}
-
-// optional bool force_encoded_color = 9 [default = false];
-bool DataParameter::has_force_encoded_color() const {
- return (_has_bits_[0] & 0x00000100u) != 0;
-}
-void DataParameter::set_has_force_encoded_color() {
- _has_bits_[0] |= 0x00000100u;
-}
-void DataParameter::clear_has_force_encoded_color() {
- _has_bits_[0] &= ~0x00000100u;
-}
-void DataParameter::clear_force_encoded_color() {
- force_encoded_color_ = false;
- clear_has_force_encoded_color();
-}
-bool DataParameter::force_encoded_color() const {
- // @@protoc_insertion_point(field_get:caffe.DataParameter.force_encoded_color)
- return force_encoded_color_;
-}
-void DataParameter::set_force_encoded_color(bool value) {
- set_has_force_encoded_color();
- force_encoded_color_ = value;
- // @@protoc_insertion_point(field_set:caffe.DataParameter.force_encoded_color)
-}
-
-inline const DataParameter* DataParameter::internal_default_instance() {
- return &DataParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int DropoutParameter::kDropoutRatioFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-DropoutParameter::DropoutParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.DropoutParameter)
-}
-
-void DropoutParameter::InitAsDefaultInstance() {
-}
-
-DropoutParameter::DropoutParameter(const DropoutParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.DropoutParameter)
-}
-
-void DropoutParameter::SharedCtor() {
- _cached_size_ = 0;
- dropout_ratio_ = 0.5f;
-}
-
-DropoutParameter::~DropoutParameter() {
- // @@protoc_insertion_point(destructor:caffe.DropoutParameter)
- SharedDtor();
-}
-
-void DropoutParameter::SharedDtor() {
-}
-
-void DropoutParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* DropoutParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return DropoutParameter_descriptor_;
-}
-
-const DropoutParameter& DropoutParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<DropoutParameter> DropoutParameter_default_instance_;
-
-DropoutParameter* DropoutParameter::New(::google::protobuf::Arena* arena) const {
- DropoutParameter* n = new DropoutParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void DropoutParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.DropoutParameter)
- dropout_ratio_ = 0.5f;
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool DropoutParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.DropoutParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional float dropout_ratio = 1 [default = 0.5];
- case 1: {
- if (tag == 13) {
- set_has_dropout_ratio();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &dropout_ratio_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.DropoutParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.DropoutParameter)
- return false;
-#undef DO_
-}
-
-void DropoutParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.DropoutParameter)
- // optional float dropout_ratio = 1 [default = 0.5];
- if (has_dropout_ratio()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->dropout_ratio(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.DropoutParameter)
-}
-
-::google::protobuf::uint8* DropoutParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.DropoutParameter)
- // optional float dropout_ratio = 1 [default = 0.5];
- if (has_dropout_ratio()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->dropout_ratio(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.DropoutParameter)
- return target;
-}
-
-size_t DropoutParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.DropoutParameter)
- size_t total_size = 0;
-
- // optional float dropout_ratio = 1 [default = 0.5];
- if (has_dropout_ratio()) {
- total_size += 1 + 4;
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void DropoutParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.DropoutParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const DropoutParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const DropoutParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.DropoutParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.DropoutParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void DropoutParameter::MergeFrom(const DropoutParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.DropoutParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void DropoutParameter::UnsafeMergeFrom(const DropoutParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_dropout_ratio()) {
- set_dropout_ratio(from.dropout_ratio());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void DropoutParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.DropoutParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void DropoutParameter::CopyFrom(const DropoutParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.DropoutParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool DropoutParameter::IsInitialized() const {
-
- return true;
-}
-
-void DropoutParameter::Swap(DropoutParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void DropoutParameter::InternalSwap(DropoutParameter* other) {
- std::swap(dropout_ratio_, other->dropout_ratio_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata DropoutParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = DropoutParameter_descriptor_;
- metadata.reflection = DropoutParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// DropoutParameter
-
-// optional float dropout_ratio = 1 [default = 0.5];
-bool DropoutParameter::has_dropout_ratio() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void DropoutParameter::set_has_dropout_ratio() {
- _has_bits_[0] |= 0x00000001u;
-}
-void DropoutParameter::clear_has_dropout_ratio() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void DropoutParameter::clear_dropout_ratio() {
- dropout_ratio_ = 0.5f;
- clear_has_dropout_ratio();
-}
-float DropoutParameter::dropout_ratio() const {
- // @@protoc_insertion_point(field_get:caffe.DropoutParameter.dropout_ratio)
- return dropout_ratio_;
-}
-void DropoutParameter::set_dropout_ratio(float value) {
- set_has_dropout_ratio();
- dropout_ratio_ = value;
- // @@protoc_insertion_point(field_set:caffe.DropoutParameter.dropout_ratio)
-}
-
-inline const DropoutParameter* DropoutParameter::internal_default_instance() {
- return &DropoutParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int DummyDataParameter::kDataFillerFieldNumber;
-const int DummyDataParameter::kShapeFieldNumber;
-const int DummyDataParameter::kNumFieldNumber;
-const int DummyDataParameter::kChannelsFieldNumber;
-const int DummyDataParameter::kHeightFieldNumber;
-const int DummyDataParameter::kWidthFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-DummyDataParameter::DummyDataParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.DummyDataParameter)
-}
-
-void DummyDataParameter::InitAsDefaultInstance() {
-}
-
-DummyDataParameter::DummyDataParameter(const DummyDataParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.DummyDataParameter)
-}
-
-void DummyDataParameter::SharedCtor() {
- _cached_size_ = 0;
-}
-
-DummyDataParameter::~DummyDataParameter() {
- // @@protoc_insertion_point(destructor:caffe.DummyDataParameter)
- SharedDtor();
-}
-
-void DummyDataParameter::SharedDtor() {
-}
-
-void DummyDataParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* DummyDataParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return DummyDataParameter_descriptor_;
-}
-
-const DummyDataParameter& DummyDataParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<DummyDataParameter> DummyDataParameter_default_instance_;
-
-DummyDataParameter* DummyDataParameter::New(::google::protobuf::Arena* arena) const {
- DummyDataParameter* n = new DummyDataParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void DummyDataParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.DummyDataParameter)
- data_filler_.Clear();
- shape_.Clear();
- num_.Clear();
- channels_.Clear();
- height_.Clear();
- width_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool DummyDataParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.DummyDataParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // repeated .caffe.FillerParameter data_filler = 1;
- case 1: {
- if (tag == 10) {
- DO_(input->IncrementRecursionDepth());
- parse_loop_data_filler:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
- input, add_data_filler()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(10)) goto parse_loop_data_filler;
- input->UnsafeDecrementRecursionDepth();
- if (input->ExpectTag(16)) goto parse_num;
- break;
- }
-
- // repeated uint32 num = 2;
- case 2: {
- if (tag == 16) {
- parse_num:
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- 1, 16, input, this->mutable_num())));
- } else if (tag == 18) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, this->mutable_num())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_num;
- if (input->ExpectTag(24)) goto parse_channels;
- break;
- }
-
- // repeated uint32 channels = 3;
- case 3: {
- if (tag == 24) {
- parse_channels:
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- 1, 24, input, this->mutable_channels())));
- } else if (tag == 26) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, this->mutable_channels())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(24)) goto parse_channels;
- if (input->ExpectTag(32)) goto parse_height;
- break;
- }
-
- // repeated uint32 height = 4;
- case 4: {
- if (tag == 32) {
- parse_height:
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- 1, 32, input, this->mutable_height())));
- } else if (tag == 34) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, this->mutable_height())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(32)) goto parse_height;
- if (input->ExpectTag(40)) goto parse_width;
- break;
- }
-
- // repeated uint32 width = 5;
- case 5: {
- if (tag == 40) {
- parse_width:
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- 1, 40, input, this->mutable_width())));
- } else if (tag == 42) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, this->mutable_width())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(40)) goto parse_width;
- if (input->ExpectTag(50)) goto parse_shape;
- break;
- }
-
- // repeated .caffe.BlobShape shape = 6;
- case 6: {
- if (tag == 50) {
- parse_shape:
- DO_(input->IncrementRecursionDepth());
- parse_loop_shape:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
- input, add_shape()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(50)) goto parse_loop_shape;
- input->UnsafeDecrementRecursionDepth();
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.DummyDataParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.DummyDataParameter)
- return false;
-#undef DO_
-}
-
-void DummyDataParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.DummyDataParameter)
- // repeated .caffe.FillerParameter data_filler = 1;
- for (unsigned int i = 0, n = this->data_filler_size(); i < n; i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 1, this->data_filler(i), output);
- }
-
- // repeated uint32 num = 2;
- for (int i = 0; i < this->num_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(
- 2, this->num(i), output);
- }
-
- // repeated uint32 channels = 3;
- for (int i = 0; i < this->channels_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(
- 3, this->channels(i), output);
- }
-
- // repeated uint32 height = 4;
- for (int i = 0; i < this->height_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(
- 4, this->height(i), output);
- }
-
- // repeated uint32 width = 5;
- for (int i = 0; i < this->width_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(
- 5, this->width(i), output);
- }
-
- // repeated .caffe.BlobShape shape = 6;
- for (unsigned int i = 0, n = this->shape_size(); i < n; i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 6, this->shape(i), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.DummyDataParameter)
-}
-
-::google::protobuf::uint8* DummyDataParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.DummyDataParameter)
- // repeated .caffe.FillerParameter data_filler = 1;
- for (unsigned int i = 0, n = this->data_filler_size(); i < n; i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 1, this->data_filler(i), false, target);
- }
-
- // repeated uint32 num = 2;
- for (int i = 0; i < this->num_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteUInt32ToArray(2, this->num(i), target);
- }
-
- // repeated uint32 channels = 3;
- for (int i = 0; i < this->channels_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteUInt32ToArray(3, this->channels(i), target);
- }
-
- // repeated uint32 height = 4;
- for (int i = 0; i < this->height_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteUInt32ToArray(4, this->height(i), target);
- }
-
- // repeated uint32 width = 5;
- for (int i = 0; i < this->width_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteUInt32ToArray(5, this->width(i), target);
- }
-
- // repeated .caffe.BlobShape shape = 6;
- for (unsigned int i = 0, n = this->shape_size(); i < n; i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 6, this->shape(i), false, target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.DummyDataParameter)
- return target;
-}
-
-size_t DummyDataParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.DummyDataParameter)
- size_t total_size = 0;
-
- // repeated .caffe.FillerParameter data_filler = 1;
- {
- unsigned int count = this->data_filler_size();
- total_size += 1UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->data_filler(i));
- }
- }
-
- // repeated .caffe.BlobShape shape = 6;
- {
- unsigned int count = this->shape_size();
- total_size += 1UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->shape(i));
- }
- }
-
- // repeated uint32 num = 2;
- {
- size_t data_size = 0;
- unsigned int count = this->num_size();
- for (unsigned int i = 0; i < count; i++) {
- data_size += ::google::protobuf::internal::WireFormatLite::
- UInt32Size(this->num(i));
- }
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->num_size());
- total_size += data_size;
- }
-
- // repeated uint32 channels = 3;
- {
- size_t data_size = 0;
- unsigned int count = this->channels_size();
- for (unsigned int i = 0; i < count; i++) {
- data_size += ::google::protobuf::internal::WireFormatLite::
- UInt32Size(this->channels(i));
- }
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->channels_size());
- total_size += data_size;
- }
-
- // repeated uint32 height = 4;
- {
- size_t data_size = 0;
- unsigned int count = this->height_size();
- for (unsigned int i = 0; i < count; i++) {
- data_size += ::google::protobuf::internal::WireFormatLite::
- UInt32Size(this->height(i));
- }
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->height_size());
- total_size += data_size;
- }
-
- // repeated uint32 width = 5;
- {
- size_t data_size = 0;
- unsigned int count = this->width_size();
- for (unsigned int i = 0; i < count; i++) {
- data_size += ::google::protobuf::internal::WireFormatLite::
- UInt32Size(this->width(i));
- }
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->width_size());
- total_size += data_size;
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void DummyDataParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.DummyDataParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const DummyDataParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const DummyDataParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.DummyDataParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.DummyDataParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void DummyDataParameter::MergeFrom(const DummyDataParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.DummyDataParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void DummyDataParameter::UnsafeMergeFrom(const DummyDataParameter& from) {
- GOOGLE_DCHECK(&from != this);
- data_filler_.MergeFrom(from.data_filler_);
- shape_.MergeFrom(from.shape_);
- num_.UnsafeMergeFrom(from.num_);
- channels_.UnsafeMergeFrom(from.channels_);
- height_.UnsafeMergeFrom(from.height_);
- width_.UnsafeMergeFrom(from.width_);
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void DummyDataParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.DummyDataParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void DummyDataParameter::CopyFrom(const DummyDataParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.DummyDataParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool DummyDataParameter::IsInitialized() const {
-
- return true;
-}
-
-void DummyDataParameter::Swap(DummyDataParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void DummyDataParameter::InternalSwap(DummyDataParameter* other) {
- data_filler_.UnsafeArenaSwap(&other->data_filler_);
- shape_.UnsafeArenaSwap(&other->shape_);
- num_.UnsafeArenaSwap(&other->num_);
- channels_.UnsafeArenaSwap(&other->channels_);
- height_.UnsafeArenaSwap(&other->height_);
- width_.UnsafeArenaSwap(&other->width_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata DummyDataParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = DummyDataParameter_descriptor_;
- metadata.reflection = DummyDataParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// DummyDataParameter
-
-// repeated .caffe.FillerParameter data_filler = 1;
-int DummyDataParameter::data_filler_size() const {
- return data_filler_.size();
-}
-void DummyDataParameter::clear_data_filler() {
- data_filler_.Clear();
-}
-const ::caffe::FillerParameter& DummyDataParameter::data_filler(int index) const {
- // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.data_filler)
- return data_filler_.Get(index);
-}
-::caffe::FillerParameter* DummyDataParameter::mutable_data_filler(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.DummyDataParameter.data_filler)
- return data_filler_.Mutable(index);
-}
-::caffe::FillerParameter* DummyDataParameter::add_data_filler() {
- // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.data_filler)
- return data_filler_.Add();
-}
-::google::protobuf::RepeatedPtrField< ::caffe::FillerParameter >*
-DummyDataParameter::mutable_data_filler() {
- // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.data_filler)
- return &data_filler_;
-}
-const ::google::protobuf::RepeatedPtrField< ::caffe::FillerParameter >&
-DummyDataParameter::data_filler() const {
- // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.data_filler)
- return data_filler_;
-}
-
-// repeated .caffe.BlobShape shape = 6;
-int DummyDataParameter::shape_size() const {
- return shape_.size();
-}
-void DummyDataParameter::clear_shape() {
- shape_.Clear();
-}
-const ::caffe::BlobShape& DummyDataParameter::shape(int index) const {
- // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.shape)
- return shape_.Get(index);
-}
-::caffe::BlobShape* DummyDataParameter::mutable_shape(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.DummyDataParameter.shape)
- return shape_.Mutable(index);
-}
-::caffe::BlobShape* DummyDataParameter::add_shape() {
- // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.shape)
- return shape_.Add();
-}
-::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >*
-DummyDataParameter::mutable_shape() {
- // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.shape)
- return &shape_;
-}
-const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >&
-DummyDataParameter::shape() const {
- // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.shape)
- return shape_;
-}
-
-// repeated uint32 num = 2;
-int DummyDataParameter::num_size() const {
- return num_.size();
-}
-void DummyDataParameter::clear_num() {
- num_.Clear();
-}
-::google::protobuf::uint32 DummyDataParameter::num(int index) const {
- // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.num)
- return num_.Get(index);
-}
-void DummyDataParameter::set_num(int index, ::google::protobuf::uint32 value) {
- num_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.DummyDataParameter.num)
-}
-void DummyDataParameter::add_num(::google::protobuf::uint32 value) {
- num_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.num)
-}
-const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-DummyDataParameter::num() const {
- // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.num)
- return num_;
-}
-::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-DummyDataParameter::mutable_num() {
- // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.num)
- return &num_;
-}
-
-// repeated uint32 channels = 3;
-int DummyDataParameter::channels_size() const {
- return channels_.size();
-}
-void DummyDataParameter::clear_channels() {
- channels_.Clear();
-}
-::google::protobuf::uint32 DummyDataParameter::channels(int index) const {
- // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.channels)
- return channels_.Get(index);
-}
-void DummyDataParameter::set_channels(int index, ::google::protobuf::uint32 value) {
- channels_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.DummyDataParameter.channels)
-}
-void DummyDataParameter::add_channels(::google::protobuf::uint32 value) {
- channels_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.channels)
-}
-const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-DummyDataParameter::channels() const {
- // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.channels)
- return channels_;
-}
-::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-DummyDataParameter::mutable_channels() {
- // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.channels)
- return &channels_;
-}
-
-// repeated uint32 height = 4;
-int DummyDataParameter::height_size() const {
- return height_.size();
-}
-void DummyDataParameter::clear_height() {
- height_.Clear();
-}
-::google::protobuf::uint32 DummyDataParameter::height(int index) const {
- // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.height)
- return height_.Get(index);
-}
-void DummyDataParameter::set_height(int index, ::google::protobuf::uint32 value) {
- height_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.DummyDataParameter.height)
-}
-void DummyDataParameter::add_height(::google::protobuf::uint32 value) {
- height_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.height)
-}
-const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-DummyDataParameter::height() const {
- // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.height)
- return height_;
-}
-::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-DummyDataParameter::mutable_height() {
- // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.height)
- return &height_;
-}
-
-// repeated uint32 width = 5;
-int DummyDataParameter::width_size() const {
- return width_.size();
-}
-void DummyDataParameter::clear_width() {
- width_.Clear();
-}
-::google::protobuf::uint32 DummyDataParameter::width(int index) const {
- // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.width)
- return width_.Get(index);
-}
-void DummyDataParameter::set_width(int index, ::google::protobuf::uint32 value) {
- width_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.DummyDataParameter.width)
-}
-void DummyDataParameter::add_width(::google::protobuf::uint32 value) {
- width_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.width)
-}
-const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-DummyDataParameter::width() const {
- // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.width)
- return width_;
-}
-::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-DummyDataParameter::mutable_width() {
- // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.width)
- return &width_;
-}
-
-inline const DummyDataParameter* DummyDataParameter::internal_default_instance() {
- return &DummyDataParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-const ::google::protobuf::EnumDescriptor* EltwiseParameter_EltwiseOp_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return EltwiseParameter_EltwiseOp_descriptor_;
-}
-bool EltwiseParameter_EltwiseOp_IsValid(int value) {
- switch (value) {
- case 0:
- case 1:
- case 2:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const EltwiseParameter_EltwiseOp EltwiseParameter::PROD;
-const EltwiseParameter_EltwiseOp EltwiseParameter::SUM;
-const EltwiseParameter_EltwiseOp EltwiseParameter::MAX;
-const EltwiseParameter_EltwiseOp EltwiseParameter::EltwiseOp_MIN;
-const EltwiseParameter_EltwiseOp EltwiseParameter::EltwiseOp_MAX;
-const int EltwiseParameter::EltwiseOp_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int EltwiseParameter::kOperationFieldNumber;
-const int EltwiseParameter::kCoeffFieldNumber;
-const int EltwiseParameter::kStableProdGradFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-EltwiseParameter::EltwiseParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.EltwiseParameter)
-}
-
-void EltwiseParameter::InitAsDefaultInstance() {
-}
-
-EltwiseParameter::EltwiseParameter(const EltwiseParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.EltwiseParameter)
-}
-
-void EltwiseParameter::SharedCtor() {
- _cached_size_ = 0;
- operation_ = 1;
- stable_prod_grad_ = true;
-}
-
-EltwiseParameter::~EltwiseParameter() {
- // @@protoc_insertion_point(destructor:caffe.EltwiseParameter)
- SharedDtor();
-}
-
-void EltwiseParameter::SharedDtor() {
-}
-
-void EltwiseParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* EltwiseParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return EltwiseParameter_descriptor_;
-}
-
-const EltwiseParameter& EltwiseParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<EltwiseParameter> EltwiseParameter_default_instance_;
-
-EltwiseParameter* EltwiseParameter::New(::google::protobuf::Arena* arena) const {
- EltwiseParameter* n = new EltwiseParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void EltwiseParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.EltwiseParameter)
- if (_has_bits_[0 / 32] & 5u) {
- operation_ = 1;
- stable_prod_grad_ = true;
- }
- coeff_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool EltwiseParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.EltwiseParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional .caffe.EltwiseParameter.EltwiseOp operation = 1 [default = SUM];
- case 1: {
- if (tag == 8) {
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::EltwiseParameter_EltwiseOp_IsValid(value)) {
- set_operation(static_cast< ::caffe::EltwiseParameter_EltwiseOp >(value));
- } else {
- mutable_unknown_fields()->AddVarint(1, value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(21)) goto parse_coeff;
- break;
- }
-
- // repeated float coeff = 2;
- case 2: {
- if (tag == 21) {
- parse_coeff:
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- 1, 21, input, this->mutable_coeff())));
- } else if (tag == 18) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, this->mutable_coeff())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(21)) goto parse_coeff;
- if (input->ExpectTag(24)) goto parse_stable_prod_grad;
- break;
- }
-
- // optional bool stable_prod_grad = 3 [default = true];
- case 3: {
- if (tag == 24) {
- parse_stable_prod_grad:
- set_has_stable_prod_grad();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &stable_prod_grad_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.EltwiseParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.EltwiseParameter)
- return false;
-#undef DO_
-}
-
-void EltwiseParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.EltwiseParameter)
- // optional .caffe.EltwiseParameter.EltwiseOp operation = 1 [default = SUM];
- if (has_operation()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 1, this->operation(), output);
- }
-
- // repeated float coeff = 2;
- for (int i = 0; i < this->coeff_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(
- 2, this->coeff(i), output);
- }
-
- // optional bool stable_prod_grad = 3 [default = true];
- if (has_stable_prod_grad()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(3, this->stable_prod_grad(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.EltwiseParameter)
-}
-
-::google::protobuf::uint8* EltwiseParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.EltwiseParameter)
- // optional .caffe.EltwiseParameter.EltwiseOp operation = 1 [default = SUM];
- if (has_operation()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 1, this->operation(), target);
- }
-
- // repeated float coeff = 2;
- for (int i = 0; i < this->coeff_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteFloatToArray(2, this->coeff(i), target);
- }
-
- // optional bool stable_prod_grad = 3 [default = true];
- if (has_stable_prod_grad()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(3, this->stable_prod_grad(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.EltwiseParameter)
- return target;
-}
-
-size_t EltwiseParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.EltwiseParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 5u) {
- // optional .caffe.EltwiseParameter.EltwiseOp operation = 1 [default = SUM];
- if (has_operation()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->operation());
- }
-
- // optional bool stable_prod_grad = 3 [default = true];
- if (has_stable_prod_grad()) {
- total_size += 1 + 1;
- }
-
- }
- // repeated float coeff = 2;
- {
- size_t data_size = 0;
- unsigned int count = this->coeff_size();
- data_size = 4UL * count;
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->coeff_size());
- total_size += data_size;
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void EltwiseParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.EltwiseParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const EltwiseParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const EltwiseParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.EltwiseParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.EltwiseParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void EltwiseParameter::MergeFrom(const EltwiseParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.EltwiseParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void EltwiseParameter::UnsafeMergeFrom(const EltwiseParameter& from) {
- GOOGLE_DCHECK(&from != this);
- coeff_.UnsafeMergeFrom(from.coeff_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_operation()) {
- set_operation(from.operation());
- }
- if (from.has_stable_prod_grad()) {
- set_stable_prod_grad(from.stable_prod_grad());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void EltwiseParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.EltwiseParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void EltwiseParameter::CopyFrom(const EltwiseParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.EltwiseParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool EltwiseParameter::IsInitialized() const {
-
- return true;
-}
-
-void EltwiseParameter::Swap(EltwiseParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void EltwiseParameter::InternalSwap(EltwiseParameter* other) {
- std::swap(operation_, other->operation_);
- coeff_.UnsafeArenaSwap(&other->coeff_);
- std::swap(stable_prod_grad_, other->stable_prod_grad_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata EltwiseParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = EltwiseParameter_descriptor_;
- metadata.reflection = EltwiseParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// EltwiseParameter
-
-// optional .caffe.EltwiseParameter.EltwiseOp operation = 1 [default = SUM];
-bool EltwiseParameter::has_operation() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void EltwiseParameter::set_has_operation() {
- _has_bits_[0] |= 0x00000001u;
-}
-void EltwiseParameter::clear_has_operation() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void EltwiseParameter::clear_operation() {
- operation_ = 1;
- clear_has_operation();
-}
-::caffe::EltwiseParameter_EltwiseOp EltwiseParameter::operation() const {
- // @@protoc_insertion_point(field_get:caffe.EltwiseParameter.operation)
- return static_cast< ::caffe::EltwiseParameter_EltwiseOp >(operation_);
-}
-void EltwiseParameter::set_operation(::caffe::EltwiseParameter_EltwiseOp value) {
- assert(::caffe::EltwiseParameter_EltwiseOp_IsValid(value));
- set_has_operation();
- operation_ = value;
- // @@protoc_insertion_point(field_set:caffe.EltwiseParameter.operation)
-}
-
-// repeated float coeff = 2;
-int EltwiseParameter::coeff_size() const {
- return coeff_.size();
-}
-void EltwiseParameter::clear_coeff() {
- coeff_.Clear();
-}
-float EltwiseParameter::coeff(int index) const {
- // @@protoc_insertion_point(field_get:caffe.EltwiseParameter.coeff)
- return coeff_.Get(index);
-}
-void EltwiseParameter::set_coeff(int index, float value) {
- coeff_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.EltwiseParameter.coeff)
-}
-void EltwiseParameter::add_coeff(float value) {
- coeff_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.EltwiseParameter.coeff)
-}
-const ::google::protobuf::RepeatedField< float >&
-EltwiseParameter::coeff() const {
- // @@protoc_insertion_point(field_list:caffe.EltwiseParameter.coeff)
- return coeff_;
-}
-::google::protobuf::RepeatedField< float >*
-EltwiseParameter::mutable_coeff() {
- // @@protoc_insertion_point(field_mutable_list:caffe.EltwiseParameter.coeff)
- return &coeff_;
-}
-
-// optional bool stable_prod_grad = 3 [default = true];
-bool EltwiseParameter::has_stable_prod_grad() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void EltwiseParameter::set_has_stable_prod_grad() {
- _has_bits_[0] |= 0x00000004u;
-}
-void EltwiseParameter::clear_has_stable_prod_grad() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void EltwiseParameter::clear_stable_prod_grad() {
- stable_prod_grad_ = true;
- clear_has_stable_prod_grad();
-}
-bool EltwiseParameter::stable_prod_grad() const {
- // @@protoc_insertion_point(field_get:caffe.EltwiseParameter.stable_prod_grad)
- return stable_prod_grad_;
-}
-void EltwiseParameter::set_stable_prod_grad(bool value) {
- set_has_stable_prod_grad();
- stable_prod_grad_ = value;
- // @@protoc_insertion_point(field_set:caffe.EltwiseParameter.stable_prod_grad)
-}
-
-inline const EltwiseParameter* EltwiseParameter::internal_default_instance() {
- return &EltwiseParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int ExpParameter::kBaseFieldNumber;
-const int ExpParameter::kScaleFieldNumber;
-const int ExpParameter::kShiftFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-ExpParameter::ExpParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.ExpParameter)
-}
-
-void ExpParameter::InitAsDefaultInstance() {
-}
-
-ExpParameter::ExpParameter(const ExpParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.ExpParameter)
-}
-
-void ExpParameter::SharedCtor() {
- _cached_size_ = 0;
- shift_ = 0;
- base_ = -1;
- scale_ = 1;
-}
-
-ExpParameter::~ExpParameter() {
- // @@protoc_insertion_point(destructor:caffe.ExpParameter)
- SharedDtor();
-}
-
-void ExpParameter::SharedDtor() {
-}
-
-void ExpParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* ExpParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return ExpParameter_descriptor_;
-}
-
-const ExpParameter& ExpParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<ExpParameter> ExpParameter_default_instance_;
-
-ExpParameter* ExpParameter::New(::google::protobuf::Arena* arena) const {
- ExpParameter* n = new ExpParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void ExpParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.ExpParameter)
- if (_has_bits_[0 / 32] & 7u) {
- base_ = -1;
- scale_ = 1;
- shift_ = 0;
- }
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool ExpParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.ExpParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional float base = 1 [default = -1];
- case 1: {
- if (tag == 13) {
- set_has_base();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &base_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(21)) goto parse_scale;
- break;
- }
-
- // optional float scale = 2 [default = 1];
- case 2: {
- if (tag == 21) {
- parse_scale:
- set_has_scale();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &scale_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(29)) goto parse_shift;
- break;
- }
-
- // optional float shift = 3 [default = 0];
- case 3: {
- if (tag == 29) {
- parse_shift:
- set_has_shift();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &shift_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.ExpParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.ExpParameter)
- return false;
-#undef DO_
-}
-
-void ExpParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.ExpParameter)
- // optional float base = 1 [default = -1];
- if (has_base()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->base(), output);
- }
-
- // optional float scale = 2 [default = 1];
- if (has_scale()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->scale(), output);
- }
-
- // optional float shift = 3 [default = 0];
- if (has_shift()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->shift(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.ExpParameter)
-}
-
-::google::protobuf::uint8* ExpParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.ExpParameter)
- // optional float base = 1 [default = -1];
- if (has_base()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->base(), target);
- }
-
- // optional float scale = 2 [default = 1];
- if (has_scale()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->scale(), target);
- }
-
- // optional float shift = 3 [default = 0];
- if (has_shift()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->shift(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.ExpParameter)
- return target;
-}
-
-size_t ExpParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.ExpParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 7u) {
- // optional float base = 1 [default = -1];
- if (has_base()) {
- total_size += 1 + 4;
- }
-
- // optional float scale = 2 [default = 1];
- if (has_scale()) {
- total_size += 1 + 4;
- }
-
- // optional float shift = 3 [default = 0];
- if (has_shift()) {
- total_size += 1 + 4;
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void ExpParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.ExpParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const ExpParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const ExpParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ExpParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ExpParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void ExpParameter::MergeFrom(const ExpParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ExpParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void ExpParameter::UnsafeMergeFrom(const ExpParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_base()) {
- set_base(from.base());
- }
- if (from.has_scale()) {
- set_scale(from.scale());
- }
- if (from.has_shift()) {
- set_shift(from.shift());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void ExpParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.ExpParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void ExpParameter::CopyFrom(const ExpParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ExpParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool ExpParameter::IsInitialized() const {
-
- return true;
-}
-
-void ExpParameter::Swap(ExpParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void ExpParameter::InternalSwap(ExpParameter* other) {
- std::swap(base_, other->base_);
- std::swap(scale_, other->scale_);
- std::swap(shift_, other->shift_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata ExpParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = ExpParameter_descriptor_;
- metadata.reflection = ExpParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// ExpParameter
-
-// optional float base = 1 [default = -1];
-bool ExpParameter::has_base() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void ExpParameter::set_has_base() {
- _has_bits_[0] |= 0x00000001u;
-}
-void ExpParameter::clear_has_base() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void ExpParameter::clear_base() {
- base_ = -1;
- clear_has_base();
-}
-float ExpParameter::base() const {
- // @@protoc_insertion_point(field_get:caffe.ExpParameter.base)
- return base_;
-}
-void ExpParameter::set_base(float value) {
- set_has_base();
- base_ = value;
- // @@protoc_insertion_point(field_set:caffe.ExpParameter.base)
-}
-
-// optional float scale = 2 [default = 1];
-bool ExpParameter::has_scale() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void ExpParameter::set_has_scale() {
- _has_bits_[0] |= 0x00000002u;
-}
-void ExpParameter::clear_has_scale() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void ExpParameter::clear_scale() {
- scale_ = 1;
- clear_has_scale();
-}
-float ExpParameter::scale() const {
- // @@protoc_insertion_point(field_get:caffe.ExpParameter.scale)
- return scale_;
-}
-void ExpParameter::set_scale(float value) {
- set_has_scale();
- scale_ = value;
- // @@protoc_insertion_point(field_set:caffe.ExpParameter.scale)
-}
-
-// optional float shift = 3 [default = 0];
-bool ExpParameter::has_shift() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void ExpParameter::set_has_shift() {
- _has_bits_[0] |= 0x00000004u;
-}
-void ExpParameter::clear_has_shift() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void ExpParameter::clear_shift() {
- shift_ = 0;
- clear_has_shift();
-}
-float ExpParameter::shift() const {
- // @@protoc_insertion_point(field_get:caffe.ExpParameter.shift)
- return shift_;
-}
-void ExpParameter::set_shift(float value) {
- set_has_shift();
- shift_ = value;
- // @@protoc_insertion_point(field_set:caffe.ExpParameter.shift)
-}
-
-inline const ExpParameter* ExpParameter::internal_default_instance() {
- return &ExpParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int FlattenParameter::kAxisFieldNumber;
-const int FlattenParameter::kEndAxisFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-FlattenParameter::FlattenParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.FlattenParameter)
-}
-
-void FlattenParameter::InitAsDefaultInstance() {
-}
-
-FlattenParameter::FlattenParameter(const FlattenParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.FlattenParameter)
-}
-
-void FlattenParameter::SharedCtor() {
- _cached_size_ = 0;
- axis_ = 1;
- end_axis_ = -1;
-}
-
-FlattenParameter::~FlattenParameter() {
- // @@protoc_insertion_point(destructor:caffe.FlattenParameter)
- SharedDtor();
-}
-
-void FlattenParameter::SharedDtor() {
-}
-
-void FlattenParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* FlattenParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return FlattenParameter_descriptor_;
-}
-
-const FlattenParameter& FlattenParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<FlattenParameter> FlattenParameter_default_instance_;
-
-FlattenParameter* FlattenParameter::New(::google::protobuf::Arena* arena) const {
- FlattenParameter* n = new FlattenParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void FlattenParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.FlattenParameter)
- if (_has_bits_[0 / 32] & 3u) {
- axis_ = 1;
- end_axis_ = -1;
- }
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool FlattenParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.FlattenParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional int32 axis = 1 [default = 1];
- case 1: {
- if (tag == 8) {
- set_has_axis();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &axis_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_end_axis;
- break;
- }
-
- // optional int32 end_axis = 2 [default = -1];
- case 2: {
- if (tag == 16) {
- parse_end_axis:
- set_has_end_axis();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &end_axis_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.FlattenParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.FlattenParameter)
- return false;
-#undef DO_
-}
-
-void FlattenParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.FlattenParameter)
- // optional int32 axis = 1 [default = 1];
- if (has_axis()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->axis(), output);
- }
-
- // optional int32 end_axis = 2 [default = -1];
- if (has_end_axis()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->end_axis(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.FlattenParameter)
-}
-
-::google::protobuf::uint8* FlattenParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.FlattenParameter)
- // optional int32 axis = 1 [default = 1];
- if (has_axis()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->axis(), target);
- }
-
- // optional int32 end_axis = 2 [default = -1];
- if (has_end_axis()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->end_axis(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.FlattenParameter)
- return target;
-}
-
-size_t FlattenParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.FlattenParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 3u) {
- // optional int32 axis = 1 [default = 1];
- if (has_axis()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->axis());
- }
-
- // optional int32 end_axis = 2 [default = -1];
- if (has_end_axis()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->end_axis());
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void FlattenParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.FlattenParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const FlattenParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const FlattenParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.FlattenParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.FlattenParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void FlattenParameter::MergeFrom(const FlattenParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.FlattenParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void FlattenParameter::UnsafeMergeFrom(const FlattenParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_axis()) {
- set_axis(from.axis());
- }
- if (from.has_end_axis()) {
- set_end_axis(from.end_axis());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void FlattenParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.FlattenParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void FlattenParameter::CopyFrom(const FlattenParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.FlattenParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool FlattenParameter::IsInitialized() const {
-
- return true;
-}
-
-void FlattenParameter::Swap(FlattenParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void FlattenParameter::InternalSwap(FlattenParameter* other) {
- std::swap(axis_, other->axis_);
- std::swap(end_axis_, other->end_axis_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata FlattenParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = FlattenParameter_descriptor_;
- metadata.reflection = FlattenParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// FlattenParameter
-
-// optional int32 axis = 1 [default = 1];
-bool FlattenParameter::has_axis() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void FlattenParameter::set_has_axis() {
- _has_bits_[0] |= 0x00000001u;
-}
-void FlattenParameter::clear_has_axis() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void FlattenParameter::clear_axis() {
- axis_ = 1;
- clear_has_axis();
-}
-::google::protobuf::int32 FlattenParameter::axis() const {
- // @@protoc_insertion_point(field_get:caffe.FlattenParameter.axis)
- return axis_;
-}
-void FlattenParameter::set_axis(::google::protobuf::int32 value) {
- set_has_axis();
- axis_ = value;
- // @@protoc_insertion_point(field_set:caffe.FlattenParameter.axis)
-}
-
-// optional int32 end_axis = 2 [default = -1];
-bool FlattenParameter::has_end_axis() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void FlattenParameter::set_has_end_axis() {
- _has_bits_[0] |= 0x00000002u;
-}
-void FlattenParameter::clear_has_end_axis() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void FlattenParameter::clear_end_axis() {
- end_axis_ = -1;
- clear_has_end_axis();
-}
-::google::protobuf::int32 FlattenParameter::end_axis() const {
- // @@protoc_insertion_point(field_get:caffe.FlattenParameter.end_axis)
- return end_axis_;
-}
-void FlattenParameter::set_end_axis(::google::protobuf::int32 value) {
- set_has_end_axis();
- end_axis_ = value;
- // @@protoc_insertion_point(field_set:caffe.FlattenParameter.end_axis)
-}
-
-inline const FlattenParameter* FlattenParameter::internal_default_instance() {
- return &FlattenParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int HDF5DataParameter::kSourceFieldNumber;
-const int HDF5DataParameter::kBatchSizeFieldNumber;
-const int HDF5DataParameter::kShuffleFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-HDF5DataParameter::HDF5DataParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.HDF5DataParameter)
-}
-
-void HDF5DataParameter::InitAsDefaultInstance() {
-}
-
-HDF5DataParameter::HDF5DataParameter(const HDF5DataParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.HDF5DataParameter)
-}
-
-void HDF5DataParameter::SharedCtor() {
- _cached_size_ = 0;
- source_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- ::memset(&batch_size_, 0, reinterpret_cast<char*>(&shuffle_) -
- reinterpret_cast<char*>(&batch_size_) + sizeof(shuffle_));
-}
-
-HDF5DataParameter::~HDF5DataParameter() {
- // @@protoc_insertion_point(destructor:caffe.HDF5DataParameter)
- SharedDtor();
-}
-
-void HDF5DataParameter::SharedDtor() {
- source_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-
-void HDF5DataParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* HDF5DataParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return HDF5DataParameter_descriptor_;
-}
-
-const HDF5DataParameter& HDF5DataParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<HDF5DataParameter> HDF5DataParameter_default_instance_;
-
-HDF5DataParameter* HDF5DataParameter::New(::google::protobuf::Arena* arena) const {
- HDF5DataParameter* n = new HDF5DataParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void HDF5DataParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.HDF5DataParameter)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(HDF5DataParameter, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<HDF5DataParameter*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- if (_has_bits_[0 / 32] & 7u) {
- ZR_(batch_size_, shuffle_);
- if (has_source()) {
- source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- }
-
-#undef ZR_HELPER_
-#undef ZR_
-
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool HDF5DataParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.HDF5DataParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional string source = 1;
- case 1: {
- if (tag == 10) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_source()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->source().data(), this->source().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.HDF5DataParameter.source");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_batch_size;
- break;
- }
-
- // optional uint32 batch_size = 2;
- case 2: {
- if (tag == 16) {
- parse_batch_size:
- set_has_batch_size();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &batch_size_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(24)) goto parse_shuffle;
- break;
- }
-
- // optional bool shuffle = 3 [default = false];
- case 3: {
- if (tag == 24) {
- parse_shuffle:
- set_has_shuffle();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &shuffle_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.HDF5DataParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.HDF5DataParameter)
- return false;
-#undef DO_
-}
-
-void HDF5DataParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.HDF5DataParameter)
- // optional string source = 1;
- if (has_source()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->source().data(), this->source().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.HDF5DataParameter.source");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 1, this->source(), output);
- }
-
- // optional uint32 batch_size = 2;
- if (has_batch_size()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(2, this->batch_size(), output);
- }
-
- // optional bool shuffle = 3 [default = false];
- if (has_shuffle()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(3, this->shuffle(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.HDF5DataParameter)
-}
-
-::google::protobuf::uint8* HDF5DataParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.HDF5DataParameter)
- // optional string source = 1;
- if (has_source()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->source().data(), this->source().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.HDF5DataParameter.source");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 1, this->source(), target);
- }
-
- // optional uint32 batch_size = 2;
- if (has_batch_size()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(2, this->batch_size(), target);
- }
-
- // optional bool shuffle = 3 [default = false];
- if (has_shuffle()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(3, this->shuffle(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.HDF5DataParameter)
- return target;
-}
-
-size_t HDF5DataParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.HDF5DataParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 7u) {
- // optional string source = 1;
- if (has_source()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->source());
- }
-
- // optional uint32 batch_size = 2;
- if (has_batch_size()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->batch_size());
- }
-
- // optional bool shuffle = 3 [default = false];
- if (has_shuffle()) {
- total_size += 1 + 1;
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void HDF5DataParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.HDF5DataParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const HDF5DataParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const HDF5DataParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.HDF5DataParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.HDF5DataParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void HDF5DataParameter::MergeFrom(const HDF5DataParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.HDF5DataParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void HDF5DataParameter::UnsafeMergeFrom(const HDF5DataParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_source()) {
- set_has_source();
- source_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_);
- }
- if (from.has_batch_size()) {
- set_batch_size(from.batch_size());
- }
- if (from.has_shuffle()) {
- set_shuffle(from.shuffle());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void HDF5DataParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.HDF5DataParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void HDF5DataParameter::CopyFrom(const HDF5DataParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.HDF5DataParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool HDF5DataParameter::IsInitialized() const {
-
- return true;
-}
-
-void HDF5DataParameter::Swap(HDF5DataParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void HDF5DataParameter::InternalSwap(HDF5DataParameter* other) {
- source_.Swap(&other->source_);
- std::swap(batch_size_, other->batch_size_);
- std::swap(shuffle_, other->shuffle_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata HDF5DataParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = HDF5DataParameter_descriptor_;
- metadata.reflection = HDF5DataParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// HDF5DataParameter
-
-// optional string source = 1;
-bool HDF5DataParameter::has_source() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void HDF5DataParameter::set_has_source() {
- _has_bits_[0] |= 0x00000001u;
-}
-void HDF5DataParameter::clear_has_source() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void HDF5DataParameter::clear_source() {
- source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_source();
-}
-const ::std::string& HDF5DataParameter::source() const {
- // @@protoc_insertion_point(field_get:caffe.HDF5DataParameter.source)
- return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void HDF5DataParameter::set_source(const ::std::string& value) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.HDF5DataParameter.source)
-}
-void HDF5DataParameter::set_source(const char* value) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.HDF5DataParameter.source)
-}
-void HDF5DataParameter::set_source(const char* value, size_t size) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.HDF5DataParameter.source)
-}
-::std::string* HDF5DataParameter::mutable_source() {
- set_has_source();
- // @@protoc_insertion_point(field_mutable:caffe.HDF5DataParameter.source)
- return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* HDF5DataParameter::release_source() {
- // @@protoc_insertion_point(field_release:caffe.HDF5DataParameter.source)
- clear_has_source();
- return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void HDF5DataParameter::set_allocated_source(::std::string* source) {
- if (source != NULL) {
- set_has_source();
- } else {
- clear_has_source();
- }
- source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source);
- // @@protoc_insertion_point(field_set_allocated:caffe.HDF5DataParameter.source)
-}
-
-// optional uint32 batch_size = 2;
-bool HDF5DataParameter::has_batch_size() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void HDF5DataParameter::set_has_batch_size() {
- _has_bits_[0] |= 0x00000002u;
-}
-void HDF5DataParameter::clear_has_batch_size() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void HDF5DataParameter::clear_batch_size() {
- batch_size_ = 0u;
- clear_has_batch_size();
-}
-::google::protobuf::uint32 HDF5DataParameter::batch_size() const {
- // @@protoc_insertion_point(field_get:caffe.HDF5DataParameter.batch_size)
- return batch_size_;
-}
-void HDF5DataParameter::set_batch_size(::google::protobuf::uint32 value) {
- set_has_batch_size();
- batch_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.HDF5DataParameter.batch_size)
-}
-
-// optional bool shuffle = 3 [default = false];
-bool HDF5DataParameter::has_shuffle() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void HDF5DataParameter::set_has_shuffle() {
- _has_bits_[0] |= 0x00000004u;
-}
-void HDF5DataParameter::clear_has_shuffle() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void HDF5DataParameter::clear_shuffle() {
- shuffle_ = false;
- clear_has_shuffle();
-}
-bool HDF5DataParameter::shuffle() const {
- // @@protoc_insertion_point(field_get:caffe.HDF5DataParameter.shuffle)
- return shuffle_;
-}
-void HDF5DataParameter::set_shuffle(bool value) {
- set_has_shuffle();
- shuffle_ = value;
- // @@protoc_insertion_point(field_set:caffe.HDF5DataParameter.shuffle)
-}
-
-inline const HDF5DataParameter* HDF5DataParameter::internal_default_instance() {
- return &HDF5DataParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int HDF5OutputParameter::kFileNameFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-HDF5OutputParameter::HDF5OutputParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.HDF5OutputParameter)
-}
-
-void HDF5OutputParameter::InitAsDefaultInstance() {
-}
-
-HDF5OutputParameter::HDF5OutputParameter(const HDF5OutputParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.HDF5OutputParameter)
-}
-
-void HDF5OutputParameter::SharedCtor() {
- _cached_size_ = 0;
- file_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-
-HDF5OutputParameter::~HDF5OutputParameter() {
- // @@protoc_insertion_point(destructor:caffe.HDF5OutputParameter)
- SharedDtor();
-}
-
-void HDF5OutputParameter::SharedDtor() {
- file_name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-
-void HDF5OutputParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* HDF5OutputParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return HDF5OutputParameter_descriptor_;
-}
-
-const HDF5OutputParameter& HDF5OutputParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<HDF5OutputParameter> HDF5OutputParameter_default_instance_;
-
-HDF5OutputParameter* HDF5OutputParameter::New(::google::protobuf::Arena* arena) const {
- HDF5OutputParameter* n = new HDF5OutputParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void HDF5OutputParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.HDF5OutputParameter)
- if (has_file_name()) {
- file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool HDF5OutputParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.HDF5OutputParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional string file_name = 1;
- case 1: {
- if (tag == 10) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_file_name()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->file_name().data(), this->file_name().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.HDF5OutputParameter.file_name");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.HDF5OutputParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.HDF5OutputParameter)
- return false;
-#undef DO_
-}
-
-void HDF5OutputParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.HDF5OutputParameter)
- // optional string file_name = 1;
- if (has_file_name()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->file_name().data(), this->file_name().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.HDF5OutputParameter.file_name");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 1, this->file_name(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.HDF5OutputParameter)
-}
-
-::google::protobuf::uint8* HDF5OutputParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.HDF5OutputParameter)
- // optional string file_name = 1;
- if (has_file_name()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->file_name().data(), this->file_name().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.HDF5OutputParameter.file_name");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 1, this->file_name(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.HDF5OutputParameter)
- return target;
-}
-
-size_t HDF5OutputParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.HDF5OutputParameter)
- size_t total_size = 0;
-
- // optional string file_name = 1;
- if (has_file_name()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->file_name());
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void HDF5OutputParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.HDF5OutputParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const HDF5OutputParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const HDF5OutputParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.HDF5OutputParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.HDF5OutputParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void HDF5OutputParameter::MergeFrom(const HDF5OutputParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.HDF5OutputParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void HDF5OutputParameter::UnsafeMergeFrom(const HDF5OutputParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_file_name()) {
- set_has_file_name();
- file_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.file_name_);
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void HDF5OutputParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.HDF5OutputParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void HDF5OutputParameter::CopyFrom(const HDF5OutputParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.HDF5OutputParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool HDF5OutputParameter::IsInitialized() const {
-
- return true;
-}
-
-void HDF5OutputParameter::Swap(HDF5OutputParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void HDF5OutputParameter::InternalSwap(HDF5OutputParameter* other) {
- file_name_.Swap(&other->file_name_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata HDF5OutputParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = HDF5OutputParameter_descriptor_;
- metadata.reflection = HDF5OutputParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// HDF5OutputParameter
-
-// optional string file_name = 1;
-bool HDF5OutputParameter::has_file_name() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void HDF5OutputParameter::set_has_file_name() {
- _has_bits_[0] |= 0x00000001u;
-}
-void HDF5OutputParameter::clear_has_file_name() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void HDF5OutputParameter::clear_file_name() {
- file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_file_name();
-}
-const ::std::string& HDF5OutputParameter::file_name() const {
- // @@protoc_insertion_point(field_get:caffe.HDF5OutputParameter.file_name)
- return file_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void HDF5OutputParameter::set_file_name(const ::std::string& value) {
- set_has_file_name();
- file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.HDF5OutputParameter.file_name)
-}
-void HDF5OutputParameter::set_file_name(const char* value) {
- set_has_file_name();
- file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.HDF5OutputParameter.file_name)
-}
-void HDF5OutputParameter::set_file_name(const char* value, size_t size) {
- set_has_file_name();
- file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.HDF5OutputParameter.file_name)
-}
-::std::string* HDF5OutputParameter::mutable_file_name() {
- set_has_file_name();
- // @@protoc_insertion_point(field_mutable:caffe.HDF5OutputParameter.file_name)
- return file_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* HDF5OutputParameter::release_file_name() {
- // @@protoc_insertion_point(field_release:caffe.HDF5OutputParameter.file_name)
- clear_has_file_name();
- return file_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void HDF5OutputParameter::set_allocated_file_name(::std::string* file_name) {
- if (file_name != NULL) {
- set_has_file_name();
- } else {
- clear_has_file_name();
- }
- file_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), file_name);
- // @@protoc_insertion_point(field_set_allocated:caffe.HDF5OutputParameter.file_name)
-}
-
-inline const HDF5OutputParameter* HDF5OutputParameter::internal_default_instance() {
- return &HDF5OutputParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-const ::google::protobuf::EnumDescriptor* HingeLossParameter_Norm_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return HingeLossParameter_Norm_descriptor_;
-}
-bool HingeLossParameter_Norm_IsValid(int value) {
- switch (value) {
- case 1:
- case 2:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const HingeLossParameter_Norm HingeLossParameter::L1;
-const HingeLossParameter_Norm HingeLossParameter::L2;
-const HingeLossParameter_Norm HingeLossParameter::Norm_MIN;
-const HingeLossParameter_Norm HingeLossParameter::Norm_MAX;
-const int HingeLossParameter::Norm_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int HingeLossParameter::kNormFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-HingeLossParameter::HingeLossParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.HingeLossParameter)
-}
-
-void HingeLossParameter::InitAsDefaultInstance() {
-}
-
-HingeLossParameter::HingeLossParameter(const HingeLossParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.HingeLossParameter)
-}
-
-void HingeLossParameter::SharedCtor() {
- _cached_size_ = 0;
- norm_ = 1;
-}
-
-HingeLossParameter::~HingeLossParameter() {
- // @@protoc_insertion_point(destructor:caffe.HingeLossParameter)
- SharedDtor();
-}
-
-void HingeLossParameter::SharedDtor() {
-}
-
-void HingeLossParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* HingeLossParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return HingeLossParameter_descriptor_;
-}
-
-const HingeLossParameter& HingeLossParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<HingeLossParameter> HingeLossParameter_default_instance_;
-
-HingeLossParameter* HingeLossParameter::New(::google::protobuf::Arena* arena) const {
- HingeLossParameter* n = new HingeLossParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void HingeLossParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.HingeLossParameter)
- norm_ = 1;
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool HingeLossParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.HingeLossParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional .caffe.HingeLossParameter.Norm norm = 1 [default = L1];
- case 1: {
- if (tag == 8) {
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::HingeLossParameter_Norm_IsValid(value)) {
- set_norm(static_cast< ::caffe::HingeLossParameter_Norm >(value));
- } else {
- mutable_unknown_fields()->AddVarint(1, value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.HingeLossParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.HingeLossParameter)
- return false;
-#undef DO_
-}
-
-void HingeLossParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.HingeLossParameter)
- // optional .caffe.HingeLossParameter.Norm norm = 1 [default = L1];
- if (has_norm()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 1, this->norm(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.HingeLossParameter)
-}
-
-::google::protobuf::uint8* HingeLossParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.HingeLossParameter)
- // optional .caffe.HingeLossParameter.Norm norm = 1 [default = L1];
- if (has_norm()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 1, this->norm(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.HingeLossParameter)
- return target;
-}
-
-size_t HingeLossParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.HingeLossParameter)
- size_t total_size = 0;
-
- // optional .caffe.HingeLossParameter.Norm norm = 1 [default = L1];
- if (has_norm()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->norm());
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void HingeLossParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.HingeLossParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const HingeLossParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const HingeLossParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.HingeLossParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.HingeLossParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void HingeLossParameter::MergeFrom(const HingeLossParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.HingeLossParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void HingeLossParameter::UnsafeMergeFrom(const HingeLossParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_norm()) {
- set_norm(from.norm());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void HingeLossParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.HingeLossParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void HingeLossParameter::CopyFrom(const HingeLossParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.HingeLossParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool HingeLossParameter::IsInitialized() const {
-
- return true;
-}
-
-void HingeLossParameter::Swap(HingeLossParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void HingeLossParameter::InternalSwap(HingeLossParameter* other) {
- std::swap(norm_, other->norm_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata HingeLossParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = HingeLossParameter_descriptor_;
- metadata.reflection = HingeLossParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// HingeLossParameter
-
-// optional .caffe.HingeLossParameter.Norm norm = 1 [default = L1];
-bool HingeLossParameter::has_norm() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void HingeLossParameter::set_has_norm() {
- _has_bits_[0] |= 0x00000001u;
-}
-void HingeLossParameter::clear_has_norm() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void HingeLossParameter::clear_norm() {
- norm_ = 1;
- clear_has_norm();
-}
-::caffe::HingeLossParameter_Norm HingeLossParameter::norm() const {
- // @@protoc_insertion_point(field_get:caffe.HingeLossParameter.norm)
- return static_cast< ::caffe::HingeLossParameter_Norm >(norm_);
-}
-void HingeLossParameter::set_norm(::caffe::HingeLossParameter_Norm value) {
- assert(::caffe::HingeLossParameter_Norm_IsValid(value));
- set_has_norm();
- norm_ = value;
- // @@protoc_insertion_point(field_set:caffe.HingeLossParameter.norm)
-}
-
-inline const HingeLossParameter* HingeLossParameter::internal_default_instance() {
- return &HingeLossParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int ImageDataParameter::kSourceFieldNumber;
-const int ImageDataParameter::kBatchSizeFieldNumber;
-const int ImageDataParameter::kRandSkipFieldNumber;
-const int ImageDataParameter::kShuffleFieldNumber;
-const int ImageDataParameter::kNewHeightFieldNumber;
-const int ImageDataParameter::kNewWidthFieldNumber;
-const int ImageDataParameter::kIsColorFieldNumber;
-const int ImageDataParameter::kScaleFieldNumber;
-const int ImageDataParameter::kMeanFileFieldNumber;
-const int ImageDataParameter::kCropSizeFieldNumber;
-const int ImageDataParameter::kMirrorFieldNumber;
-const int ImageDataParameter::kRootFolderFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-ImageDataParameter::ImageDataParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.ImageDataParameter)
-}
-
-void ImageDataParameter::InitAsDefaultInstance() {
-}
-
-ImageDataParameter::ImageDataParameter(const ImageDataParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.ImageDataParameter)
-}
-
-void ImageDataParameter::SharedCtor() {
- _cached_size_ = 0;
- source_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- mean_file_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- root_folder_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- ::memset(&batch_size_, 0, reinterpret_cast<char*>(&crop_size_) -
- reinterpret_cast<char*>(&batch_size_) + sizeof(crop_size_));
- is_color_ = true;
- scale_ = 1;
-}
-
-ImageDataParameter::~ImageDataParameter() {
- // @@protoc_insertion_point(destructor:caffe.ImageDataParameter)
- SharedDtor();
-}
-
-void ImageDataParameter::SharedDtor() {
- source_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- mean_file_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- root_folder_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-
-void ImageDataParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* ImageDataParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return ImageDataParameter_descriptor_;
-}
-
-const ImageDataParameter& ImageDataParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<ImageDataParameter> ImageDataParameter_default_instance_;
-
-ImageDataParameter* ImageDataParameter::New(::google::protobuf::Arena* arena) const {
- ImageDataParameter* n = new ImageDataParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void ImageDataParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.ImageDataParameter)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(ImageDataParameter, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<ImageDataParameter*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- if (_has_bits_[0 / 32] & 255u) {
- ZR_(batch_size_, shuffle_);
- if (has_source()) {
- source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- is_color_ = true;
- scale_ = 1;
- }
- if (_has_bits_[8 / 32] & 3840u) {
- ZR_(mirror_, crop_size_);
- if (has_mean_file()) {
- mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- if (has_root_folder()) {
- root_folder_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- }
-
-#undef ZR_HELPER_
-#undef ZR_
-
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool ImageDataParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.ImageDataParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional string source = 1;
- case 1: {
- if (tag == 10) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_source()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->source().data(), this->source().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.ImageDataParameter.source");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(21)) goto parse_scale;
- break;
- }
-
- // optional float scale = 2 [default = 1];
- case 2: {
- if (tag == 21) {
- parse_scale:
- set_has_scale();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &scale_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(26)) goto parse_mean_file;
- break;
- }
-
- // optional string mean_file = 3;
- case 3: {
- if (tag == 26) {
- parse_mean_file:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_mean_file()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->mean_file().data(), this->mean_file().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.ImageDataParameter.mean_file");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(32)) goto parse_batch_size;
- break;
- }
-
- // optional uint32 batch_size = 4;
- case 4: {
- if (tag == 32) {
- parse_batch_size:
- set_has_batch_size();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &batch_size_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(40)) goto parse_crop_size;
- break;
- }
-
- // optional uint32 crop_size = 5 [default = 0];
- case 5: {
- if (tag == 40) {
- parse_crop_size:
- set_has_crop_size();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &crop_size_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(48)) goto parse_mirror;
- break;
- }
-
- // optional bool mirror = 6 [default = false];
- case 6: {
- if (tag == 48) {
- parse_mirror:
- set_has_mirror();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &mirror_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(56)) goto parse_rand_skip;
- break;
- }
-
- // optional uint32 rand_skip = 7 [default = 0];
- case 7: {
- if (tag == 56) {
- parse_rand_skip:
- set_has_rand_skip();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &rand_skip_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(64)) goto parse_shuffle;
- break;
- }
-
- // optional bool shuffle = 8 [default = false];
- case 8: {
- if (tag == 64) {
- parse_shuffle:
- set_has_shuffle();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &shuffle_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(72)) goto parse_new_height;
- break;
- }
-
- // optional uint32 new_height = 9 [default = 0];
- case 9: {
- if (tag == 72) {
- parse_new_height:
- set_has_new_height();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &new_height_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(80)) goto parse_new_width;
- break;
- }
-
- // optional uint32 new_width = 10 [default = 0];
- case 10: {
- if (tag == 80) {
- parse_new_width:
- set_has_new_width();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &new_width_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(88)) goto parse_is_color;
- break;
- }
-
- // optional bool is_color = 11 [default = true];
- case 11: {
- if (tag == 88) {
- parse_is_color:
- set_has_is_color();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &is_color_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(98)) goto parse_root_folder;
- break;
- }
-
- // optional string root_folder = 12 [default = ""];
- case 12: {
- if (tag == 98) {
- parse_root_folder:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_root_folder()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->root_folder().data(), this->root_folder().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.ImageDataParameter.root_folder");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.ImageDataParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.ImageDataParameter)
- return false;
-#undef DO_
-}
-
-void ImageDataParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.ImageDataParameter)
- // optional string source = 1;
- if (has_source()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->source().data(), this->source().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.ImageDataParameter.source");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 1, this->source(), output);
- }
-
- // optional float scale = 2 [default = 1];
- if (has_scale()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->scale(), output);
- }
-
- // optional string mean_file = 3;
- if (has_mean_file()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->mean_file().data(), this->mean_file().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.ImageDataParameter.mean_file");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 3, this->mean_file(), output);
- }
-
- // optional uint32 batch_size = 4;
- if (has_batch_size()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(4, this->batch_size(), output);
- }
-
- // optional uint32 crop_size = 5 [default = 0];
- if (has_crop_size()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(5, this->crop_size(), output);
- }
-
- // optional bool mirror = 6 [default = false];
- if (has_mirror()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(6, this->mirror(), output);
- }
-
- // optional uint32 rand_skip = 7 [default = 0];
- if (has_rand_skip()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(7, this->rand_skip(), output);
- }
-
- // optional bool shuffle = 8 [default = false];
- if (has_shuffle()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(8, this->shuffle(), output);
- }
-
- // optional uint32 new_height = 9 [default = 0];
- if (has_new_height()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(9, this->new_height(), output);
- }
-
- // optional uint32 new_width = 10 [default = 0];
- if (has_new_width()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(10, this->new_width(), output);
- }
-
- // optional bool is_color = 11 [default = true];
- if (has_is_color()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(11, this->is_color(), output);
- }
-
- // optional string root_folder = 12 [default = ""];
- if (has_root_folder()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->root_folder().data(), this->root_folder().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.ImageDataParameter.root_folder");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 12, this->root_folder(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.ImageDataParameter)
-}
-
-::google::protobuf::uint8* ImageDataParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.ImageDataParameter)
- // optional string source = 1;
- if (has_source()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->source().data(), this->source().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.ImageDataParameter.source");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 1, this->source(), target);
- }
-
- // optional float scale = 2 [default = 1];
- if (has_scale()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->scale(), target);
- }
-
- // optional string mean_file = 3;
- if (has_mean_file()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->mean_file().data(), this->mean_file().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.ImageDataParameter.mean_file");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 3, this->mean_file(), target);
- }
-
- // optional uint32 batch_size = 4;
- if (has_batch_size()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(4, this->batch_size(), target);
- }
-
- // optional uint32 crop_size = 5 [default = 0];
- if (has_crop_size()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(5, this->crop_size(), target);
- }
-
- // optional bool mirror = 6 [default = false];
- if (has_mirror()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(6, this->mirror(), target);
- }
-
- // optional uint32 rand_skip = 7 [default = 0];
- if (has_rand_skip()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(7, this->rand_skip(), target);
- }
-
- // optional bool shuffle = 8 [default = false];
- if (has_shuffle()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(8, this->shuffle(), target);
- }
-
- // optional uint32 new_height = 9 [default = 0];
- if (has_new_height()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(9, this->new_height(), target);
- }
-
- // optional uint32 new_width = 10 [default = 0];
- if (has_new_width()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(10, this->new_width(), target);
- }
-
- // optional bool is_color = 11 [default = true];
- if (has_is_color()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(11, this->is_color(), target);
- }
-
- // optional string root_folder = 12 [default = ""];
- if (has_root_folder()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->root_folder().data(), this->root_folder().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.ImageDataParameter.root_folder");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 12, this->root_folder(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.ImageDataParameter)
- return target;
-}
-
-size_t ImageDataParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.ImageDataParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 255u) {
- // optional string source = 1;
- if (has_source()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->source());
- }
-
- // optional uint32 batch_size = 4;
- if (has_batch_size()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->batch_size());
- }
-
- // optional uint32 rand_skip = 7 [default = 0];
- if (has_rand_skip()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->rand_skip());
- }
-
- // optional bool shuffle = 8 [default = false];
- if (has_shuffle()) {
- total_size += 1 + 1;
- }
-
- // optional uint32 new_height = 9 [default = 0];
- if (has_new_height()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->new_height());
- }
-
- // optional uint32 new_width = 10 [default = 0];
- if (has_new_width()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->new_width());
- }
-
- // optional bool is_color = 11 [default = true];
- if (has_is_color()) {
- total_size += 1 + 1;
- }
-
- // optional float scale = 2 [default = 1];
- if (has_scale()) {
- total_size += 1 + 4;
- }
-
- }
- if (_has_bits_[8 / 32] & 3840u) {
- // optional string mean_file = 3;
- if (has_mean_file()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->mean_file());
- }
-
- // optional uint32 crop_size = 5 [default = 0];
- if (has_crop_size()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->crop_size());
- }
-
- // optional bool mirror = 6 [default = false];
- if (has_mirror()) {
- total_size += 1 + 1;
- }
-
- // optional string root_folder = 12 [default = ""];
- if (has_root_folder()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->root_folder());
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void ImageDataParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.ImageDataParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const ImageDataParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const ImageDataParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ImageDataParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ImageDataParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void ImageDataParameter::MergeFrom(const ImageDataParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ImageDataParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void ImageDataParameter::UnsafeMergeFrom(const ImageDataParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_source()) {
- set_has_source();
- source_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_);
- }
- if (from.has_batch_size()) {
- set_batch_size(from.batch_size());
- }
- if (from.has_rand_skip()) {
- set_rand_skip(from.rand_skip());
- }
- if (from.has_shuffle()) {
- set_shuffle(from.shuffle());
- }
- if (from.has_new_height()) {
- set_new_height(from.new_height());
- }
- if (from.has_new_width()) {
- set_new_width(from.new_width());
- }
- if (from.has_is_color()) {
- set_is_color(from.is_color());
- }
- if (from.has_scale()) {
- set_scale(from.scale());
- }
- }
- if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) {
- if (from.has_mean_file()) {
- set_has_mean_file();
- mean_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.mean_file_);
- }
- if (from.has_crop_size()) {
- set_crop_size(from.crop_size());
- }
- if (from.has_mirror()) {
- set_mirror(from.mirror());
- }
- if (from.has_root_folder()) {
- set_has_root_folder();
- root_folder_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.root_folder_);
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void ImageDataParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.ImageDataParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void ImageDataParameter::CopyFrom(const ImageDataParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ImageDataParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool ImageDataParameter::IsInitialized() const {
-
- return true;
-}
-
-void ImageDataParameter::Swap(ImageDataParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void ImageDataParameter::InternalSwap(ImageDataParameter* other) {
- source_.Swap(&other->source_);
- std::swap(batch_size_, other->batch_size_);
- std::swap(rand_skip_, other->rand_skip_);
- std::swap(shuffle_, other->shuffle_);
- std::swap(new_height_, other->new_height_);
- std::swap(new_width_, other->new_width_);
- std::swap(is_color_, other->is_color_);
- std::swap(scale_, other->scale_);
- mean_file_.Swap(&other->mean_file_);
- std::swap(crop_size_, other->crop_size_);
- std::swap(mirror_, other->mirror_);
- root_folder_.Swap(&other->root_folder_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata ImageDataParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = ImageDataParameter_descriptor_;
- metadata.reflection = ImageDataParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// ImageDataParameter
-
-// optional string source = 1;
-bool ImageDataParameter::has_source() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void ImageDataParameter::set_has_source() {
- _has_bits_[0] |= 0x00000001u;
-}
-void ImageDataParameter::clear_has_source() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void ImageDataParameter::clear_source() {
- source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_source();
-}
-const ::std::string& ImageDataParameter::source() const {
- // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.source)
- return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void ImageDataParameter::set_source(const ::std::string& value) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.source)
-}
-void ImageDataParameter::set_source(const char* value) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.ImageDataParameter.source)
-}
-void ImageDataParameter::set_source(const char* value, size_t size) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.ImageDataParameter.source)
-}
-::std::string* ImageDataParameter::mutable_source() {
- set_has_source();
- // @@protoc_insertion_point(field_mutable:caffe.ImageDataParameter.source)
- return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* ImageDataParameter::release_source() {
- // @@protoc_insertion_point(field_release:caffe.ImageDataParameter.source)
- clear_has_source();
- return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void ImageDataParameter::set_allocated_source(::std::string* source) {
- if (source != NULL) {
- set_has_source();
- } else {
- clear_has_source();
- }
- source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source);
- // @@protoc_insertion_point(field_set_allocated:caffe.ImageDataParameter.source)
-}
-
-// optional uint32 batch_size = 4;
-bool ImageDataParameter::has_batch_size() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void ImageDataParameter::set_has_batch_size() {
- _has_bits_[0] |= 0x00000002u;
-}
-void ImageDataParameter::clear_has_batch_size() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void ImageDataParameter::clear_batch_size() {
- batch_size_ = 0u;
- clear_has_batch_size();
-}
-::google::protobuf::uint32 ImageDataParameter::batch_size() const {
- // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.batch_size)
- return batch_size_;
-}
-void ImageDataParameter::set_batch_size(::google::protobuf::uint32 value) {
- set_has_batch_size();
- batch_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.batch_size)
-}
-
-// optional uint32 rand_skip = 7 [default = 0];
-bool ImageDataParameter::has_rand_skip() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void ImageDataParameter::set_has_rand_skip() {
- _has_bits_[0] |= 0x00000004u;
-}
-void ImageDataParameter::clear_has_rand_skip() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void ImageDataParameter::clear_rand_skip() {
- rand_skip_ = 0u;
- clear_has_rand_skip();
-}
-::google::protobuf::uint32 ImageDataParameter::rand_skip() const {
- // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.rand_skip)
- return rand_skip_;
-}
-void ImageDataParameter::set_rand_skip(::google::protobuf::uint32 value) {
- set_has_rand_skip();
- rand_skip_ = value;
- // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.rand_skip)
-}
-
-// optional bool shuffle = 8 [default = false];
-bool ImageDataParameter::has_shuffle() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-void ImageDataParameter::set_has_shuffle() {
- _has_bits_[0] |= 0x00000008u;
-}
-void ImageDataParameter::clear_has_shuffle() {
- _has_bits_[0] &= ~0x00000008u;
-}
-void ImageDataParameter::clear_shuffle() {
- shuffle_ = false;
- clear_has_shuffle();
-}
-bool ImageDataParameter::shuffle() const {
- // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.shuffle)
- return shuffle_;
-}
-void ImageDataParameter::set_shuffle(bool value) {
- set_has_shuffle();
- shuffle_ = value;
- // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.shuffle)
-}
-
-// optional uint32 new_height = 9 [default = 0];
-bool ImageDataParameter::has_new_height() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-void ImageDataParameter::set_has_new_height() {
- _has_bits_[0] |= 0x00000010u;
-}
-void ImageDataParameter::clear_has_new_height() {
- _has_bits_[0] &= ~0x00000010u;
-}
-void ImageDataParameter::clear_new_height() {
- new_height_ = 0u;
- clear_has_new_height();
-}
-::google::protobuf::uint32 ImageDataParameter::new_height() const {
- // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.new_height)
- return new_height_;
-}
-void ImageDataParameter::set_new_height(::google::protobuf::uint32 value) {
- set_has_new_height();
- new_height_ = value;
- // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.new_height)
-}
-
-// optional uint32 new_width = 10 [default = 0];
-bool ImageDataParameter::has_new_width() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-void ImageDataParameter::set_has_new_width() {
- _has_bits_[0] |= 0x00000020u;
-}
-void ImageDataParameter::clear_has_new_width() {
- _has_bits_[0] &= ~0x00000020u;
-}
-void ImageDataParameter::clear_new_width() {
- new_width_ = 0u;
- clear_has_new_width();
-}
-::google::protobuf::uint32 ImageDataParameter::new_width() const {
- // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.new_width)
- return new_width_;
-}
-void ImageDataParameter::set_new_width(::google::protobuf::uint32 value) {
- set_has_new_width();
- new_width_ = value;
- // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.new_width)
-}
-
-// optional bool is_color = 11 [default = true];
-bool ImageDataParameter::has_is_color() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-void ImageDataParameter::set_has_is_color() {
- _has_bits_[0] |= 0x00000040u;
-}
-void ImageDataParameter::clear_has_is_color() {
- _has_bits_[0] &= ~0x00000040u;
-}
-void ImageDataParameter::clear_is_color() {
- is_color_ = true;
- clear_has_is_color();
-}
-bool ImageDataParameter::is_color() const {
- // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.is_color)
- return is_color_;
-}
-void ImageDataParameter::set_is_color(bool value) {
- set_has_is_color();
- is_color_ = value;
- // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.is_color)
-}
-
-// optional float scale = 2 [default = 1];
-bool ImageDataParameter::has_scale() const {
- return (_has_bits_[0] & 0x00000080u) != 0;
-}
-void ImageDataParameter::set_has_scale() {
- _has_bits_[0] |= 0x00000080u;
-}
-void ImageDataParameter::clear_has_scale() {
- _has_bits_[0] &= ~0x00000080u;
-}
-void ImageDataParameter::clear_scale() {
- scale_ = 1;
- clear_has_scale();
-}
-float ImageDataParameter::scale() const {
- // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.scale)
- return scale_;
-}
-void ImageDataParameter::set_scale(float value) {
- set_has_scale();
- scale_ = value;
- // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.scale)
-}
-
-// optional string mean_file = 3;
-bool ImageDataParameter::has_mean_file() const {
- return (_has_bits_[0] & 0x00000100u) != 0;
-}
-void ImageDataParameter::set_has_mean_file() {
- _has_bits_[0] |= 0x00000100u;
-}
-void ImageDataParameter::clear_has_mean_file() {
- _has_bits_[0] &= ~0x00000100u;
-}
-void ImageDataParameter::clear_mean_file() {
- mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_mean_file();
-}
-const ::std::string& ImageDataParameter::mean_file() const {
- // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.mean_file)
- return mean_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void ImageDataParameter::set_mean_file(const ::std::string& value) {
- set_has_mean_file();
- mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.mean_file)
-}
-void ImageDataParameter::set_mean_file(const char* value) {
- set_has_mean_file();
- mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.ImageDataParameter.mean_file)
-}
-void ImageDataParameter::set_mean_file(const char* value, size_t size) {
- set_has_mean_file();
- mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.ImageDataParameter.mean_file)
-}
-::std::string* ImageDataParameter::mutable_mean_file() {
- set_has_mean_file();
- // @@protoc_insertion_point(field_mutable:caffe.ImageDataParameter.mean_file)
- return mean_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* ImageDataParameter::release_mean_file() {
- // @@protoc_insertion_point(field_release:caffe.ImageDataParameter.mean_file)
- clear_has_mean_file();
- return mean_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void ImageDataParameter::set_allocated_mean_file(::std::string* mean_file) {
- if (mean_file != NULL) {
- set_has_mean_file();
- } else {
- clear_has_mean_file();
- }
- mean_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), mean_file);
- // @@protoc_insertion_point(field_set_allocated:caffe.ImageDataParameter.mean_file)
-}
-
-// optional uint32 crop_size = 5 [default = 0];
-bool ImageDataParameter::has_crop_size() const {
- return (_has_bits_[0] & 0x00000200u) != 0;
-}
-void ImageDataParameter::set_has_crop_size() {
- _has_bits_[0] |= 0x00000200u;
-}
-void ImageDataParameter::clear_has_crop_size() {
- _has_bits_[0] &= ~0x00000200u;
-}
-void ImageDataParameter::clear_crop_size() {
- crop_size_ = 0u;
- clear_has_crop_size();
-}
-::google::protobuf::uint32 ImageDataParameter::crop_size() const {
- // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.crop_size)
- return crop_size_;
-}
-void ImageDataParameter::set_crop_size(::google::protobuf::uint32 value) {
- set_has_crop_size();
- crop_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.crop_size)
-}
-
-// optional bool mirror = 6 [default = false];
-bool ImageDataParameter::has_mirror() const {
- return (_has_bits_[0] & 0x00000400u) != 0;
-}
-void ImageDataParameter::set_has_mirror() {
- _has_bits_[0] |= 0x00000400u;
-}
-void ImageDataParameter::clear_has_mirror() {
- _has_bits_[0] &= ~0x00000400u;
-}
-void ImageDataParameter::clear_mirror() {
- mirror_ = false;
- clear_has_mirror();
-}
-bool ImageDataParameter::mirror() const {
- // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.mirror)
- return mirror_;
-}
-void ImageDataParameter::set_mirror(bool value) {
- set_has_mirror();
- mirror_ = value;
- // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.mirror)
-}
-
-// optional string root_folder = 12 [default = ""];
-bool ImageDataParameter::has_root_folder() const {
- return (_has_bits_[0] & 0x00000800u) != 0;
-}
-void ImageDataParameter::set_has_root_folder() {
- _has_bits_[0] |= 0x00000800u;
-}
-void ImageDataParameter::clear_has_root_folder() {
- _has_bits_[0] &= ~0x00000800u;
-}
-void ImageDataParameter::clear_root_folder() {
- root_folder_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_root_folder();
-}
-const ::std::string& ImageDataParameter::root_folder() const {
- // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.root_folder)
- return root_folder_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void ImageDataParameter::set_root_folder(const ::std::string& value) {
- set_has_root_folder();
- root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.root_folder)
-}
-void ImageDataParameter::set_root_folder(const char* value) {
- set_has_root_folder();
- root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.ImageDataParameter.root_folder)
-}
-void ImageDataParameter::set_root_folder(const char* value, size_t size) {
- set_has_root_folder();
- root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.ImageDataParameter.root_folder)
-}
-::std::string* ImageDataParameter::mutable_root_folder() {
- set_has_root_folder();
- // @@protoc_insertion_point(field_mutable:caffe.ImageDataParameter.root_folder)
- return root_folder_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* ImageDataParameter::release_root_folder() {
- // @@protoc_insertion_point(field_release:caffe.ImageDataParameter.root_folder)
- clear_has_root_folder();
- return root_folder_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void ImageDataParameter::set_allocated_root_folder(::std::string* root_folder) {
- if (root_folder != NULL) {
- set_has_root_folder();
- } else {
- clear_has_root_folder();
- }
- root_folder_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), root_folder);
- // @@protoc_insertion_point(field_set_allocated:caffe.ImageDataParameter.root_folder)
-}
-
-inline const ImageDataParameter* ImageDataParameter::internal_default_instance() {
- return &ImageDataParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int InfogainLossParameter::kSourceFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-InfogainLossParameter::InfogainLossParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.InfogainLossParameter)
-}
-
-void InfogainLossParameter::InitAsDefaultInstance() {
-}
-
-InfogainLossParameter::InfogainLossParameter(const InfogainLossParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.InfogainLossParameter)
-}
-
-void InfogainLossParameter::SharedCtor() {
- _cached_size_ = 0;
- source_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-
-InfogainLossParameter::~InfogainLossParameter() {
- // @@protoc_insertion_point(destructor:caffe.InfogainLossParameter)
- SharedDtor();
-}
-
-void InfogainLossParameter::SharedDtor() {
- source_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-
-void InfogainLossParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* InfogainLossParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return InfogainLossParameter_descriptor_;
-}
-
-const InfogainLossParameter& InfogainLossParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<InfogainLossParameter> InfogainLossParameter_default_instance_;
-
-InfogainLossParameter* InfogainLossParameter::New(::google::protobuf::Arena* arena) const {
- InfogainLossParameter* n = new InfogainLossParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void InfogainLossParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.InfogainLossParameter)
- if (has_source()) {
- source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool InfogainLossParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.InfogainLossParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional string source = 1;
- case 1: {
- if (tag == 10) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_source()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->source().data(), this->source().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.InfogainLossParameter.source");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.InfogainLossParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.InfogainLossParameter)
- return false;
-#undef DO_
-}
-
-void InfogainLossParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.InfogainLossParameter)
- // optional string source = 1;
- if (has_source()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->source().data(), this->source().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.InfogainLossParameter.source");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 1, this->source(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.InfogainLossParameter)
-}
-
-::google::protobuf::uint8* InfogainLossParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.InfogainLossParameter)
- // optional string source = 1;
- if (has_source()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->source().data(), this->source().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.InfogainLossParameter.source");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 1, this->source(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.InfogainLossParameter)
- return target;
-}
-
-size_t InfogainLossParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.InfogainLossParameter)
- size_t total_size = 0;
-
- // optional string source = 1;
- if (has_source()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->source());
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void InfogainLossParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.InfogainLossParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const InfogainLossParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const InfogainLossParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.InfogainLossParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.InfogainLossParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void InfogainLossParameter::MergeFrom(const InfogainLossParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.InfogainLossParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void InfogainLossParameter::UnsafeMergeFrom(const InfogainLossParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_source()) {
- set_has_source();
- source_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_);
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void InfogainLossParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.InfogainLossParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void InfogainLossParameter::CopyFrom(const InfogainLossParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.InfogainLossParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool InfogainLossParameter::IsInitialized() const {
-
- return true;
-}
-
-void InfogainLossParameter::Swap(InfogainLossParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void InfogainLossParameter::InternalSwap(InfogainLossParameter* other) {
- source_.Swap(&other->source_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata InfogainLossParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = InfogainLossParameter_descriptor_;
- metadata.reflection = InfogainLossParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// InfogainLossParameter
-
-// optional string source = 1;
-bool InfogainLossParameter::has_source() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void InfogainLossParameter::set_has_source() {
- _has_bits_[0] |= 0x00000001u;
-}
-void InfogainLossParameter::clear_has_source() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void InfogainLossParameter::clear_source() {
- source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_source();
-}
-const ::std::string& InfogainLossParameter::source() const {
- // @@protoc_insertion_point(field_get:caffe.InfogainLossParameter.source)
- return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void InfogainLossParameter::set_source(const ::std::string& value) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.InfogainLossParameter.source)
-}
-void InfogainLossParameter::set_source(const char* value) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.InfogainLossParameter.source)
-}
-void InfogainLossParameter::set_source(const char* value, size_t size) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.InfogainLossParameter.source)
-}
-::std::string* InfogainLossParameter::mutable_source() {
- set_has_source();
- // @@protoc_insertion_point(field_mutable:caffe.InfogainLossParameter.source)
- return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* InfogainLossParameter::release_source() {
- // @@protoc_insertion_point(field_release:caffe.InfogainLossParameter.source)
- clear_has_source();
- return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void InfogainLossParameter::set_allocated_source(::std::string* source) {
- if (source != NULL) {
- set_has_source();
- } else {
- clear_has_source();
- }
- source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source);
- // @@protoc_insertion_point(field_set_allocated:caffe.InfogainLossParameter.source)
-}
-
-inline const InfogainLossParameter* InfogainLossParameter::internal_default_instance() {
- return &InfogainLossParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int InnerProductParameter::kNumOutputFieldNumber;
-const int InnerProductParameter::kBiasTermFieldNumber;
-const int InnerProductParameter::kWeightFillerFieldNumber;
-const int InnerProductParameter::kBiasFillerFieldNumber;
-const int InnerProductParameter::kAxisFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-InnerProductParameter::InnerProductParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.InnerProductParameter)
-}
-
-void InnerProductParameter::InitAsDefaultInstance() {
- weight_filler_ = const_cast< ::caffe::FillerParameter*>(
- ::caffe::FillerParameter::internal_default_instance());
- bias_filler_ = const_cast< ::caffe::FillerParameter*>(
- ::caffe::FillerParameter::internal_default_instance());
-}
-
-InnerProductParameter::InnerProductParameter(const InnerProductParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.InnerProductParameter)
-}
-
-void InnerProductParameter::SharedCtor() {
- _cached_size_ = 0;
- weight_filler_ = NULL;
- bias_filler_ = NULL;
- num_output_ = 0u;
- bias_term_ = true;
- axis_ = 1;
-}
-
-InnerProductParameter::~InnerProductParameter() {
- // @@protoc_insertion_point(destructor:caffe.InnerProductParameter)
- SharedDtor();
-}
-
-void InnerProductParameter::SharedDtor() {
- if (this != &InnerProductParameter_default_instance_.get()) {
- delete weight_filler_;
- delete bias_filler_;
- }
-}
-
-void InnerProductParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* InnerProductParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return InnerProductParameter_descriptor_;
-}
-
-const InnerProductParameter& InnerProductParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<InnerProductParameter> InnerProductParameter_default_instance_;
-
-InnerProductParameter* InnerProductParameter::New(::google::protobuf::Arena* arena) const {
- InnerProductParameter* n = new InnerProductParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void InnerProductParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.InnerProductParameter)
- if (_has_bits_[0 / 32] & 31u) {
- num_output_ = 0u;
- bias_term_ = true;
- if (has_weight_filler()) {
- if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear();
- }
- if (has_bias_filler()) {
- if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
- }
- axis_ = 1;
- }
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool InnerProductParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.InnerProductParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional uint32 num_output = 1;
- case 1: {
- if (tag == 8) {
- set_has_num_output();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &num_output_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_bias_term;
- break;
- }
-
- // optional bool bias_term = 2 [default = true];
- case 2: {
- if (tag == 16) {
- parse_bias_term:
- set_has_bias_term();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &bias_term_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(26)) goto parse_weight_filler;
- break;
- }
-
- // optional .caffe.FillerParameter weight_filler = 3;
- case 3: {
- if (tag == 26) {
- parse_weight_filler:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_weight_filler()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(34)) goto parse_bias_filler;
- break;
- }
-
- // optional .caffe.FillerParameter bias_filler = 4;
- case 4: {
- if (tag == 34) {
- parse_bias_filler:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_bias_filler()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(40)) goto parse_axis;
- break;
- }
-
- // optional int32 axis = 5 [default = 1];
- case 5: {
- if (tag == 40) {
- parse_axis:
- set_has_axis();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &axis_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.InnerProductParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.InnerProductParameter)
- return false;
-#undef DO_
-}
-
-void InnerProductParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.InnerProductParameter)
- // optional uint32 num_output = 1;
- if (has_num_output()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->num_output(), output);
- }
-
- // optional bool bias_term = 2 [default = true];
- if (has_bias_term()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->bias_term(), output);
- }
-
- // optional .caffe.FillerParameter weight_filler = 3;
- if (has_weight_filler()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 3, *this->weight_filler_, output);
- }
-
- // optional .caffe.FillerParameter bias_filler = 4;
- if (has_bias_filler()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 4, *this->bias_filler_, output);
- }
-
- // optional int32 axis = 5 [default = 1];
- if (has_axis()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(5, this->axis(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.InnerProductParameter)
-}
-
-::google::protobuf::uint8* InnerProductParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.InnerProductParameter)
- // optional uint32 num_output = 1;
- if (has_num_output()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->num_output(), target);
- }
-
- // optional bool bias_term = 2 [default = true];
- if (has_bias_term()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->bias_term(), target);
- }
-
- // optional .caffe.FillerParameter weight_filler = 3;
- if (has_weight_filler()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 3, *this->weight_filler_, false, target);
- }
-
- // optional .caffe.FillerParameter bias_filler = 4;
- if (has_bias_filler()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 4, *this->bias_filler_, false, target);
- }
-
- // optional int32 axis = 5 [default = 1];
- if (has_axis()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(5, this->axis(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.InnerProductParameter)
- return target;
-}
-
-size_t InnerProductParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.InnerProductParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 31u) {
- // optional uint32 num_output = 1;
- if (has_num_output()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->num_output());
- }
-
- // optional bool bias_term = 2 [default = true];
- if (has_bias_term()) {
- total_size += 1 + 1;
- }
-
- // optional .caffe.FillerParameter weight_filler = 3;
- if (has_weight_filler()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->weight_filler_);
- }
-
- // optional .caffe.FillerParameter bias_filler = 4;
- if (has_bias_filler()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->bias_filler_);
- }
-
- // optional int32 axis = 5 [default = 1];
- if (has_axis()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->axis());
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void InnerProductParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.InnerProductParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const InnerProductParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const InnerProductParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.InnerProductParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.InnerProductParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void InnerProductParameter::MergeFrom(const InnerProductParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.InnerProductParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void InnerProductParameter::UnsafeMergeFrom(const InnerProductParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_num_output()) {
- set_num_output(from.num_output());
- }
- if (from.has_bias_term()) {
- set_bias_term(from.bias_term());
- }
- if (from.has_weight_filler()) {
- mutable_weight_filler()->::caffe::FillerParameter::MergeFrom(from.weight_filler());
- }
- if (from.has_bias_filler()) {
- mutable_bias_filler()->::caffe::FillerParameter::MergeFrom(from.bias_filler());
- }
- if (from.has_axis()) {
- set_axis(from.axis());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void InnerProductParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.InnerProductParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void InnerProductParameter::CopyFrom(const InnerProductParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.InnerProductParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool InnerProductParameter::IsInitialized() const {
-
- return true;
-}
-
-void InnerProductParameter::Swap(InnerProductParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void InnerProductParameter::InternalSwap(InnerProductParameter* other) {
- std::swap(num_output_, other->num_output_);
- std::swap(bias_term_, other->bias_term_);
- std::swap(weight_filler_, other->weight_filler_);
- std::swap(bias_filler_, other->bias_filler_);
- std::swap(axis_, other->axis_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata InnerProductParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = InnerProductParameter_descriptor_;
- metadata.reflection = InnerProductParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// InnerProductParameter
-
-// optional uint32 num_output = 1;
-bool InnerProductParameter::has_num_output() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void InnerProductParameter::set_has_num_output() {
- _has_bits_[0] |= 0x00000001u;
-}
-void InnerProductParameter::clear_has_num_output() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void InnerProductParameter::clear_num_output() {
- num_output_ = 0u;
- clear_has_num_output();
-}
-::google::protobuf::uint32 InnerProductParameter::num_output() const {
- // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.num_output)
- return num_output_;
-}
-void InnerProductParameter::set_num_output(::google::protobuf::uint32 value) {
- set_has_num_output();
- num_output_ = value;
- // @@protoc_insertion_point(field_set:caffe.InnerProductParameter.num_output)
-}
-
-// optional bool bias_term = 2 [default = true];
-bool InnerProductParameter::has_bias_term() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void InnerProductParameter::set_has_bias_term() {
- _has_bits_[0] |= 0x00000002u;
-}
-void InnerProductParameter::clear_has_bias_term() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void InnerProductParameter::clear_bias_term() {
- bias_term_ = true;
- clear_has_bias_term();
-}
-bool InnerProductParameter::bias_term() const {
- // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.bias_term)
- return bias_term_;
-}
-void InnerProductParameter::set_bias_term(bool value) {
- set_has_bias_term();
- bias_term_ = value;
- // @@protoc_insertion_point(field_set:caffe.InnerProductParameter.bias_term)
-}
-
-// optional .caffe.FillerParameter weight_filler = 3;
-bool InnerProductParameter::has_weight_filler() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void InnerProductParameter::set_has_weight_filler() {
- _has_bits_[0] |= 0x00000004u;
-}
-void InnerProductParameter::clear_has_weight_filler() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void InnerProductParameter::clear_weight_filler() {
- if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear();
- clear_has_weight_filler();
-}
-const ::caffe::FillerParameter& InnerProductParameter::weight_filler() const {
- // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.weight_filler)
- return weight_filler_ != NULL ? *weight_filler_
- : *::caffe::FillerParameter::internal_default_instance();
-}
-::caffe::FillerParameter* InnerProductParameter::mutable_weight_filler() {
- set_has_weight_filler();
- if (weight_filler_ == NULL) {
- weight_filler_ = new ::caffe::FillerParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.InnerProductParameter.weight_filler)
- return weight_filler_;
-}
-::caffe::FillerParameter* InnerProductParameter::release_weight_filler() {
- // @@protoc_insertion_point(field_release:caffe.InnerProductParameter.weight_filler)
- clear_has_weight_filler();
- ::caffe::FillerParameter* temp = weight_filler_;
- weight_filler_ = NULL;
- return temp;
-}
-void InnerProductParameter::set_allocated_weight_filler(::caffe::FillerParameter* weight_filler) {
- delete weight_filler_;
- weight_filler_ = weight_filler;
- if (weight_filler) {
- set_has_weight_filler();
- } else {
- clear_has_weight_filler();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.InnerProductParameter.weight_filler)
-}
-
-// optional .caffe.FillerParameter bias_filler = 4;
-bool InnerProductParameter::has_bias_filler() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-void InnerProductParameter::set_has_bias_filler() {
- _has_bits_[0] |= 0x00000008u;
-}
-void InnerProductParameter::clear_has_bias_filler() {
- _has_bits_[0] &= ~0x00000008u;
-}
-void InnerProductParameter::clear_bias_filler() {
- if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
- clear_has_bias_filler();
-}
-const ::caffe::FillerParameter& InnerProductParameter::bias_filler() const {
- // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.bias_filler)
- return bias_filler_ != NULL ? *bias_filler_
- : *::caffe::FillerParameter::internal_default_instance();
-}
-::caffe::FillerParameter* InnerProductParameter::mutable_bias_filler() {
- set_has_bias_filler();
- if (bias_filler_ == NULL) {
- bias_filler_ = new ::caffe::FillerParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.InnerProductParameter.bias_filler)
- return bias_filler_;
-}
-::caffe::FillerParameter* InnerProductParameter::release_bias_filler() {
- // @@protoc_insertion_point(field_release:caffe.InnerProductParameter.bias_filler)
- clear_has_bias_filler();
- ::caffe::FillerParameter* temp = bias_filler_;
- bias_filler_ = NULL;
- return temp;
-}
-void InnerProductParameter::set_allocated_bias_filler(::caffe::FillerParameter* bias_filler) {
- delete bias_filler_;
- bias_filler_ = bias_filler;
- if (bias_filler) {
- set_has_bias_filler();
- } else {
- clear_has_bias_filler();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.InnerProductParameter.bias_filler)
-}
-
-// optional int32 axis = 5 [default = 1];
-bool InnerProductParameter::has_axis() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-void InnerProductParameter::set_has_axis() {
- _has_bits_[0] |= 0x00000010u;
-}
-void InnerProductParameter::clear_has_axis() {
- _has_bits_[0] &= ~0x00000010u;
-}
-void InnerProductParameter::clear_axis() {
- axis_ = 1;
- clear_has_axis();
-}
-::google::protobuf::int32 InnerProductParameter::axis() const {
- // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.axis)
- return axis_;
-}
-void InnerProductParameter::set_axis(::google::protobuf::int32 value) {
- set_has_axis();
- axis_ = value;
- // @@protoc_insertion_point(field_set:caffe.InnerProductParameter.axis)
-}
-
-inline const InnerProductParameter* InnerProductParameter::internal_default_instance() {
- return &InnerProductParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int LogParameter::kBaseFieldNumber;
-const int LogParameter::kScaleFieldNumber;
-const int LogParameter::kShiftFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-LogParameter::LogParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.LogParameter)
-}
-
-void LogParameter::InitAsDefaultInstance() {
-}
-
-LogParameter::LogParameter(const LogParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.LogParameter)
-}
-
-void LogParameter::SharedCtor() {
- _cached_size_ = 0;
- shift_ = 0;
- base_ = -1;
- scale_ = 1;
-}
-
-LogParameter::~LogParameter() {
- // @@protoc_insertion_point(destructor:caffe.LogParameter)
- SharedDtor();
-}
-
-void LogParameter::SharedDtor() {
-}
-
-void LogParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* LogParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return LogParameter_descriptor_;
-}
-
-const LogParameter& LogParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<LogParameter> LogParameter_default_instance_;
-
-LogParameter* LogParameter::New(::google::protobuf::Arena* arena) const {
- LogParameter* n = new LogParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void LogParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.LogParameter)
- if (_has_bits_[0 / 32] & 7u) {
- base_ = -1;
- scale_ = 1;
- shift_ = 0;
- }
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool LogParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.LogParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional float base = 1 [default = -1];
- case 1: {
- if (tag == 13) {
- set_has_base();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &base_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(21)) goto parse_scale;
- break;
- }
-
- // optional float scale = 2 [default = 1];
- case 2: {
- if (tag == 21) {
- parse_scale:
- set_has_scale();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &scale_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(29)) goto parse_shift;
- break;
- }
-
- // optional float shift = 3 [default = 0];
- case 3: {
- if (tag == 29) {
- parse_shift:
- set_has_shift();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &shift_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.LogParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.LogParameter)
- return false;
-#undef DO_
-}
-
-void LogParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.LogParameter)
- // optional float base = 1 [default = -1];
- if (has_base()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->base(), output);
- }
-
- // optional float scale = 2 [default = 1];
- if (has_scale()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->scale(), output);
- }
-
- // optional float shift = 3 [default = 0];
- if (has_shift()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->shift(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.LogParameter)
-}
-
-::google::protobuf::uint8* LogParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.LogParameter)
- // optional float base = 1 [default = -1];
- if (has_base()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->base(), target);
- }
-
- // optional float scale = 2 [default = 1];
- if (has_scale()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->scale(), target);
- }
-
- // optional float shift = 3 [default = 0];
- if (has_shift()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->shift(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.LogParameter)
- return target;
-}
-
-size_t LogParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.LogParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 7u) {
- // optional float base = 1 [default = -1];
- if (has_base()) {
- total_size += 1 + 4;
- }
-
- // optional float scale = 2 [default = 1];
- if (has_scale()) {
- total_size += 1 + 4;
- }
-
- // optional float shift = 3 [default = 0];
- if (has_shift()) {
- total_size += 1 + 4;
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void LogParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.LogParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const LogParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const LogParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.LogParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.LogParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void LogParameter::MergeFrom(const LogParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.LogParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void LogParameter::UnsafeMergeFrom(const LogParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_base()) {
- set_base(from.base());
- }
- if (from.has_scale()) {
- set_scale(from.scale());
- }
- if (from.has_shift()) {
- set_shift(from.shift());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void LogParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.LogParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void LogParameter::CopyFrom(const LogParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.LogParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool LogParameter::IsInitialized() const {
-
- return true;
-}
-
-void LogParameter::Swap(LogParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void LogParameter::InternalSwap(LogParameter* other) {
- std::swap(base_, other->base_);
- std::swap(scale_, other->scale_);
- std::swap(shift_, other->shift_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata LogParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = LogParameter_descriptor_;
- metadata.reflection = LogParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// LogParameter
-
-// optional float base = 1 [default = -1];
-bool LogParameter::has_base() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void LogParameter::set_has_base() {
- _has_bits_[0] |= 0x00000001u;
-}
-void LogParameter::clear_has_base() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void LogParameter::clear_base() {
- base_ = -1;
- clear_has_base();
-}
-float LogParameter::base() const {
- // @@protoc_insertion_point(field_get:caffe.LogParameter.base)
- return base_;
-}
-void LogParameter::set_base(float value) {
- set_has_base();
- base_ = value;
- // @@protoc_insertion_point(field_set:caffe.LogParameter.base)
-}
-
-// optional float scale = 2 [default = 1];
-bool LogParameter::has_scale() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void LogParameter::set_has_scale() {
- _has_bits_[0] |= 0x00000002u;
-}
-void LogParameter::clear_has_scale() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void LogParameter::clear_scale() {
- scale_ = 1;
- clear_has_scale();
-}
-float LogParameter::scale() const {
- // @@protoc_insertion_point(field_get:caffe.LogParameter.scale)
- return scale_;
-}
-void LogParameter::set_scale(float value) {
- set_has_scale();
- scale_ = value;
- // @@protoc_insertion_point(field_set:caffe.LogParameter.scale)
-}
-
-// optional float shift = 3 [default = 0];
-bool LogParameter::has_shift() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void LogParameter::set_has_shift() {
- _has_bits_[0] |= 0x00000004u;
-}
-void LogParameter::clear_has_shift() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void LogParameter::clear_shift() {
- shift_ = 0;
- clear_has_shift();
-}
-float LogParameter::shift() const {
- // @@protoc_insertion_point(field_get:caffe.LogParameter.shift)
- return shift_;
-}
-void LogParameter::set_shift(float value) {
- set_has_shift();
- shift_ = value;
- // @@protoc_insertion_point(field_set:caffe.LogParameter.shift)
-}
-
-inline const LogParameter* LogParameter::internal_default_instance() {
- return &LogParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-const ::google::protobuf::EnumDescriptor* LRNParameter_NormRegion_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return LRNParameter_NormRegion_descriptor_;
-}
-bool LRNParameter_NormRegion_IsValid(int value) {
- switch (value) {
- case 0:
- case 1:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const LRNParameter_NormRegion LRNParameter::ACROSS_CHANNELS;
-const LRNParameter_NormRegion LRNParameter::WITHIN_CHANNEL;
-const LRNParameter_NormRegion LRNParameter::NormRegion_MIN;
-const LRNParameter_NormRegion LRNParameter::NormRegion_MAX;
-const int LRNParameter::NormRegion_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int LRNParameter::kLocalSizeFieldNumber;
-const int LRNParameter::kAlphaFieldNumber;
-const int LRNParameter::kBetaFieldNumber;
-const int LRNParameter::kNormRegionFieldNumber;
-const int LRNParameter::kKFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-LRNParameter::LRNParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.LRNParameter)
-}
-
-void LRNParameter::InitAsDefaultInstance() {
-}
-
-LRNParameter::LRNParameter(const LRNParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.LRNParameter)
-}
-
-void LRNParameter::SharedCtor() {
- _cached_size_ = 0;
- norm_region_ = 0;
- local_size_ = 5u;
- alpha_ = 1;
- beta_ = 0.75f;
- k_ = 1;
-}
-
-LRNParameter::~LRNParameter() {
- // @@protoc_insertion_point(destructor:caffe.LRNParameter)
- SharedDtor();
-}
-
-void LRNParameter::SharedDtor() {
-}
-
-void LRNParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* LRNParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return LRNParameter_descriptor_;
-}
-
-const LRNParameter& LRNParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<LRNParameter> LRNParameter_default_instance_;
-
-LRNParameter* LRNParameter::New(::google::protobuf::Arena* arena) const {
- LRNParameter* n = new LRNParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void LRNParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.LRNParameter)
- if (_has_bits_[0 / 32] & 31u) {
- local_size_ = 5u;
- alpha_ = 1;
- beta_ = 0.75f;
- norm_region_ = 0;
- k_ = 1;
- }
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool LRNParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.LRNParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional uint32 local_size = 1 [default = 5];
- case 1: {
- if (tag == 8) {
- set_has_local_size();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &local_size_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(21)) goto parse_alpha;
- break;
- }
-
- // optional float alpha = 2 [default = 1];
- case 2: {
- if (tag == 21) {
- parse_alpha:
- set_has_alpha();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &alpha_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(29)) goto parse_beta;
- break;
- }
-
- // optional float beta = 3 [default = 0.75];
- case 3: {
- if (tag == 29) {
- parse_beta:
- set_has_beta();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &beta_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(32)) goto parse_norm_region;
- break;
- }
-
- // optional .caffe.LRNParameter.NormRegion norm_region = 4 [default = ACROSS_CHANNELS];
- case 4: {
- if (tag == 32) {
- parse_norm_region:
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::LRNParameter_NormRegion_IsValid(value)) {
- set_norm_region(static_cast< ::caffe::LRNParameter_NormRegion >(value));
- } else {
- mutable_unknown_fields()->AddVarint(4, value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(45)) goto parse_k;
- break;
- }
-
- // optional float k = 5 [default = 1];
- case 5: {
- if (tag == 45) {
- parse_k:
- set_has_k();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &k_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.LRNParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.LRNParameter)
- return false;
-#undef DO_
-}
-
-void LRNParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.LRNParameter)
- // optional uint32 local_size = 1 [default = 5];
- if (has_local_size()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->local_size(), output);
- }
-
- // optional float alpha = 2 [default = 1];
- if (has_alpha()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->alpha(), output);
- }
-
- // optional float beta = 3 [default = 0.75];
- if (has_beta()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->beta(), output);
- }
-
- // optional .caffe.LRNParameter.NormRegion norm_region = 4 [default = ACROSS_CHANNELS];
- if (has_norm_region()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 4, this->norm_region(), output);
- }
-
- // optional float k = 5 [default = 1];
- if (has_k()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(5, this->k(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.LRNParameter)
-}
-
-::google::protobuf::uint8* LRNParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.LRNParameter)
- // optional uint32 local_size = 1 [default = 5];
- if (has_local_size()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->local_size(), target);
- }
-
- // optional float alpha = 2 [default = 1];
- if (has_alpha()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->alpha(), target);
- }
-
- // optional float beta = 3 [default = 0.75];
- if (has_beta()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->beta(), target);
- }
-
- // optional .caffe.LRNParameter.NormRegion norm_region = 4 [default = ACROSS_CHANNELS];
- if (has_norm_region()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 4, this->norm_region(), target);
- }
-
- // optional float k = 5 [default = 1];
- if (has_k()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(5, this->k(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.LRNParameter)
- return target;
-}
-
-size_t LRNParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.LRNParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 31u) {
- // optional uint32 local_size = 1 [default = 5];
- if (has_local_size()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->local_size());
- }
-
- // optional float alpha = 2 [default = 1];
- if (has_alpha()) {
- total_size += 1 + 4;
- }
-
- // optional float beta = 3 [default = 0.75];
- if (has_beta()) {
- total_size += 1 + 4;
- }
-
- // optional .caffe.LRNParameter.NormRegion norm_region = 4 [default = ACROSS_CHANNELS];
- if (has_norm_region()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->norm_region());
- }
-
- // optional float k = 5 [default = 1];
- if (has_k()) {
- total_size += 1 + 4;
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void LRNParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.LRNParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const LRNParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const LRNParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.LRNParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.LRNParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void LRNParameter::MergeFrom(const LRNParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.LRNParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void LRNParameter::UnsafeMergeFrom(const LRNParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_local_size()) {
- set_local_size(from.local_size());
- }
- if (from.has_alpha()) {
- set_alpha(from.alpha());
- }
- if (from.has_beta()) {
- set_beta(from.beta());
- }
- if (from.has_norm_region()) {
- set_norm_region(from.norm_region());
- }
- if (from.has_k()) {
- set_k(from.k());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void LRNParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.LRNParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void LRNParameter::CopyFrom(const LRNParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.LRNParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool LRNParameter::IsInitialized() const {
-
- return true;
-}
-
-void LRNParameter::Swap(LRNParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void LRNParameter::InternalSwap(LRNParameter* other) {
- std::swap(local_size_, other->local_size_);
- std::swap(alpha_, other->alpha_);
- std::swap(beta_, other->beta_);
- std::swap(norm_region_, other->norm_region_);
- std::swap(k_, other->k_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata LRNParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = LRNParameter_descriptor_;
- metadata.reflection = LRNParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// LRNParameter
-
-// optional uint32 local_size = 1 [default = 5];
-bool LRNParameter::has_local_size() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void LRNParameter::set_has_local_size() {
- _has_bits_[0] |= 0x00000001u;
-}
-void LRNParameter::clear_has_local_size() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void LRNParameter::clear_local_size() {
- local_size_ = 5u;
- clear_has_local_size();
-}
-::google::protobuf::uint32 LRNParameter::local_size() const {
- // @@protoc_insertion_point(field_get:caffe.LRNParameter.local_size)
- return local_size_;
-}
-void LRNParameter::set_local_size(::google::protobuf::uint32 value) {
- set_has_local_size();
- local_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.LRNParameter.local_size)
-}
-
-// optional float alpha = 2 [default = 1];
-bool LRNParameter::has_alpha() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void LRNParameter::set_has_alpha() {
- _has_bits_[0] |= 0x00000002u;
-}
-void LRNParameter::clear_has_alpha() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void LRNParameter::clear_alpha() {
- alpha_ = 1;
- clear_has_alpha();
-}
-float LRNParameter::alpha() const {
- // @@protoc_insertion_point(field_get:caffe.LRNParameter.alpha)
- return alpha_;
-}
-void LRNParameter::set_alpha(float value) {
- set_has_alpha();
- alpha_ = value;
- // @@protoc_insertion_point(field_set:caffe.LRNParameter.alpha)
-}
-
-// optional float beta = 3 [default = 0.75];
-bool LRNParameter::has_beta() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void LRNParameter::set_has_beta() {
- _has_bits_[0] |= 0x00000004u;
-}
-void LRNParameter::clear_has_beta() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void LRNParameter::clear_beta() {
- beta_ = 0.75f;
- clear_has_beta();
-}
-float LRNParameter::beta() const {
- // @@protoc_insertion_point(field_get:caffe.LRNParameter.beta)
- return beta_;
-}
-void LRNParameter::set_beta(float value) {
- set_has_beta();
- beta_ = value;
- // @@protoc_insertion_point(field_set:caffe.LRNParameter.beta)
-}
-
-// optional .caffe.LRNParameter.NormRegion norm_region = 4 [default = ACROSS_CHANNELS];
-bool LRNParameter::has_norm_region() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-void LRNParameter::set_has_norm_region() {
- _has_bits_[0] |= 0x00000008u;
-}
-void LRNParameter::clear_has_norm_region() {
- _has_bits_[0] &= ~0x00000008u;
-}
-void LRNParameter::clear_norm_region() {
- norm_region_ = 0;
- clear_has_norm_region();
-}
-::caffe::LRNParameter_NormRegion LRNParameter::norm_region() const {
- // @@protoc_insertion_point(field_get:caffe.LRNParameter.norm_region)
- return static_cast< ::caffe::LRNParameter_NormRegion >(norm_region_);
-}
-void LRNParameter::set_norm_region(::caffe::LRNParameter_NormRegion value) {
- assert(::caffe::LRNParameter_NormRegion_IsValid(value));
- set_has_norm_region();
- norm_region_ = value;
- // @@protoc_insertion_point(field_set:caffe.LRNParameter.norm_region)
-}
-
-// optional float k = 5 [default = 1];
-bool LRNParameter::has_k() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-void LRNParameter::set_has_k() {
- _has_bits_[0] |= 0x00000010u;
-}
-void LRNParameter::clear_has_k() {
- _has_bits_[0] &= ~0x00000010u;
-}
-void LRNParameter::clear_k() {
- k_ = 1;
- clear_has_k();
-}
-float LRNParameter::k() const {
- // @@protoc_insertion_point(field_get:caffe.LRNParameter.k)
- return k_;
-}
-void LRNParameter::set_k(float value) {
- set_has_k();
- k_ = value;
- // @@protoc_insertion_point(field_set:caffe.LRNParameter.k)
-}
-
-inline const LRNParameter* LRNParameter::internal_default_instance() {
- return &LRNParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int MemoryDataParameter::kBatchSizeFieldNumber;
-const int MemoryDataParameter::kChannelsFieldNumber;
-const int MemoryDataParameter::kHeightFieldNumber;
-const int MemoryDataParameter::kWidthFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-MemoryDataParameter::MemoryDataParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.MemoryDataParameter)
-}
-
-void MemoryDataParameter::InitAsDefaultInstance() {
-}
-
-MemoryDataParameter::MemoryDataParameter(const MemoryDataParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.MemoryDataParameter)
-}
-
-void MemoryDataParameter::SharedCtor() {
- _cached_size_ = 0;
- ::memset(&batch_size_, 0, reinterpret_cast<char*>(&width_) -
- reinterpret_cast<char*>(&batch_size_) + sizeof(width_));
-}
-
-MemoryDataParameter::~MemoryDataParameter() {
- // @@protoc_insertion_point(destructor:caffe.MemoryDataParameter)
- SharedDtor();
-}
-
-void MemoryDataParameter::SharedDtor() {
-}
-
-void MemoryDataParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* MemoryDataParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return MemoryDataParameter_descriptor_;
-}
-
-const MemoryDataParameter& MemoryDataParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<MemoryDataParameter> MemoryDataParameter_default_instance_;
-
-MemoryDataParameter* MemoryDataParameter::New(::google::protobuf::Arena* arena) const {
- MemoryDataParameter* n = new MemoryDataParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void MemoryDataParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.MemoryDataParameter)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(MemoryDataParameter, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<MemoryDataParameter*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- ZR_(batch_size_, width_);
-
-#undef ZR_HELPER_
-#undef ZR_
-
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool MemoryDataParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.MemoryDataParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional uint32 batch_size = 1;
- case 1: {
- if (tag == 8) {
- set_has_batch_size();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &batch_size_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_channels;
- break;
- }
-
- // optional uint32 channels = 2;
- case 2: {
- if (tag == 16) {
- parse_channels:
- set_has_channels();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &channels_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(24)) goto parse_height;
- break;
- }
-
- // optional uint32 height = 3;
- case 3: {
- if (tag == 24) {
- parse_height:
- set_has_height();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &height_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(32)) goto parse_width;
- break;
- }
-
- // optional uint32 width = 4;
- case 4: {
- if (tag == 32) {
- parse_width:
- set_has_width();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &width_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.MemoryDataParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.MemoryDataParameter)
- return false;
-#undef DO_
-}
-
-void MemoryDataParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.MemoryDataParameter)
- // optional uint32 batch_size = 1;
- if (has_batch_size()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->batch_size(), output);
- }
-
- // optional uint32 channels = 2;
- if (has_channels()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(2, this->channels(), output);
- }
-
- // optional uint32 height = 3;
- if (has_height()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(3, this->height(), output);
- }
-
- // optional uint32 width = 4;
- if (has_width()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(4, this->width(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.MemoryDataParameter)
-}
-
-::google::protobuf::uint8* MemoryDataParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.MemoryDataParameter)
- // optional uint32 batch_size = 1;
- if (has_batch_size()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->batch_size(), target);
- }
-
- // optional uint32 channels = 2;
- if (has_channels()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(2, this->channels(), target);
- }
-
- // optional uint32 height = 3;
- if (has_height()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(3, this->height(), target);
- }
-
- // optional uint32 width = 4;
- if (has_width()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(4, this->width(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.MemoryDataParameter)
- return target;
-}
-
-size_t MemoryDataParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.MemoryDataParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 15u) {
- // optional uint32 batch_size = 1;
- if (has_batch_size()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->batch_size());
- }
-
- // optional uint32 channels = 2;
- if (has_channels()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->channels());
- }
-
- // optional uint32 height = 3;
- if (has_height()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->height());
- }
-
- // optional uint32 width = 4;
- if (has_width()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->width());
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void MemoryDataParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.MemoryDataParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const MemoryDataParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const MemoryDataParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.MemoryDataParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.MemoryDataParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void MemoryDataParameter::MergeFrom(const MemoryDataParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.MemoryDataParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void MemoryDataParameter::UnsafeMergeFrom(const MemoryDataParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_batch_size()) {
- set_batch_size(from.batch_size());
- }
- if (from.has_channels()) {
- set_channels(from.channels());
- }
- if (from.has_height()) {
- set_height(from.height());
- }
- if (from.has_width()) {
- set_width(from.width());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void MemoryDataParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.MemoryDataParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void MemoryDataParameter::CopyFrom(const MemoryDataParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.MemoryDataParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool MemoryDataParameter::IsInitialized() const {
-
- return true;
-}
-
-void MemoryDataParameter::Swap(MemoryDataParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void MemoryDataParameter::InternalSwap(MemoryDataParameter* other) {
- std::swap(batch_size_, other->batch_size_);
- std::swap(channels_, other->channels_);
- std::swap(height_, other->height_);
- std::swap(width_, other->width_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata MemoryDataParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = MemoryDataParameter_descriptor_;
- metadata.reflection = MemoryDataParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// MemoryDataParameter
-
-// optional uint32 batch_size = 1;
-bool MemoryDataParameter::has_batch_size() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void MemoryDataParameter::set_has_batch_size() {
- _has_bits_[0] |= 0x00000001u;
-}
-void MemoryDataParameter::clear_has_batch_size() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void MemoryDataParameter::clear_batch_size() {
- batch_size_ = 0u;
- clear_has_batch_size();
-}
-::google::protobuf::uint32 MemoryDataParameter::batch_size() const {
- // @@protoc_insertion_point(field_get:caffe.MemoryDataParameter.batch_size)
- return batch_size_;
-}
-void MemoryDataParameter::set_batch_size(::google::protobuf::uint32 value) {
- set_has_batch_size();
- batch_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.MemoryDataParameter.batch_size)
-}
-
-// optional uint32 channels = 2;
-bool MemoryDataParameter::has_channels() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void MemoryDataParameter::set_has_channels() {
- _has_bits_[0] |= 0x00000002u;
-}
-void MemoryDataParameter::clear_has_channels() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void MemoryDataParameter::clear_channels() {
- channels_ = 0u;
- clear_has_channels();
-}
-::google::protobuf::uint32 MemoryDataParameter::channels() const {
- // @@protoc_insertion_point(field_get:caffe.MemoryDataParameter.channels)
- return channels_;
-}
-void MemoryDataParameter::set_channels(::google::protobuf::uint32 value) {
- set_has_channels();
- channels_ = value;
- // @@protoc_insertion_point(field_set:caffe.MemoryDataParameter.channels)
-}
-
-// optional uint32 height = 3;
-bool MemoryDataParameter::has_height() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void MemoryDataParameter::set_has_height() {
- _has_bits_[0] |= 0x00000004u;
-}
-void MemoryDataParameter::clear_has_height() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void MemoryDataParameter::clear_height() {
- height_ = 0u;
- clear_has_height();
-}
-::google::protobuf::uint32 MemoryDataParameter::height() const {
- // @@protoc_insertion_point(field_get:caffe.MemoryDataParameter.height)
- return height_;
-}
-void MemoryDataParameter::set_height(::google::protobuf::uint32 value) {
- set_has_height();
- height_ = value;
- // @@protoc_insertion_point(field_set:caffe.MemoryDataParameter.height)
-}
-
-// optional uint32 width = 4;
-bool MemoryDataParameter::has_width() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-void MemoryDataParameter::set_has_width() {
- _has_bits_[0] |= 0x00000008u;
-}
-void MemoryDataParameter::clear_has_width() {
- _has_bits_[0] &= ~0x00000008u;
-}
-void MemoryDataParameter::clear_width() {
- width_ = 0u;
- clear_has_width();
-}
-::google::protobuf::uint32 MemoryDataParameter::width() const {
- // @@protoc_insertion_point(field_get:caffe.MemoryDataParameter.width)
- return width_;
-}
-void MemoryDataParameter::set_width(::google::protobuf::uint32 value) {
- set_has_width();
- width_ = value;
- // @@protoc_insertion_point(field_set:caffe.MemoryDataParameter.width)
-}
-
-inline const MemoryDataParameter* MemoryDataParameter::internal_default_instance() {
- return &MemoryDataParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int MVNParameter::kNormalizeVarianceFieldNumber;
-const int MVNParameter::kAcrossChannelsFieldNumber;
-const int MVNParameter::kEpsFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-MVNParameter::MVNParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.MVNParameter)
-}
-
-void MVNParameter::InitAsDefaultInstance() {
-}
-
-MVNParameter::MVNParameter(const MVNParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.MVNParameter)
-}
-
-void MVNParameter::SharedCtor() {
- _cached_size_ = 0;
- across_channels_ = false;
- normalize_variance_ = true;
- eps_ = 1e-09f;
-}
-
-MVNParameter::~MVNParameter() {
- // @@protoc_insertion_point(destructor:caffe.MVNParameter)
- SharedDtor();
-}
-
-void MVNParameter::SharedDtor() {
-}
-
-void MVNParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* MVNParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return MVNParameter_descriptor_;
-}
-
-const MVNParameter& MVNParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<MVNParameter> MVNParameter_default_instance_;
-
-MVNParameter* MVNParameter::New(::google::protobuf::Arena* arena) const {
- MVNParameter* n = new MVNParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void MVNParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.MVNParameter)
- if (_has_bits_[0 / 32] & 7u) {
- normalize_variance_ = true;
- across_channels_ = false;
- eps_ = 1e-09f;
- }
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool MVNParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.MVNParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional bool normalize_variance = 1 [default = true];
- case 1: {
- if (tag == 8) {
- set_has_normalize_variance();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &normalize_variance_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_across_channels;
- break;
- }
-
- // optional bool across_channels = 2 [default = false];
- case 2: {
- if (tag == 16) {
- parse_across_channels:
- set_has_across_channels();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &across_channels_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(29)) goto parse_eps;
- break;
- }
-
- // optional float eps = 3 [default = 1e-09];
- case 3: {
- if (tag == 29) {
- parse_eps:
- set_has_eps();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &eps_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.MVNParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.MVNParameter)
- return false;
-#undef DO_
-}
-
-void MVNParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.MVNParameter)
- // optional bool normalize_variance = 1 [default = true];
- if (has_normalize_variance()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(1, this->normalize_variance(), output);
- }
-
- // optional bool across_channels = 2 [default = false];
- if (has_across_channels()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->across_channels(), output);
- }
-
- // optional float eps = 3 [default = 1e-09];
- if (has_eps()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->eps(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.MVNParameter)
-}
-
-::google::protobuf::uint8* MVNParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.MVNParameter)
- // optional bool normalize_variance = 1 [default = true];
- if (has_normalize_variance()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->normalize_variance(), target);
- }
-
- // optional bool across_channels = 2 [default = false];
- if (has_across_channels()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->across_channels(), target);
- }
-
- // optional float eps = 3 [default = 1e-09];
- if (has_eps()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->eps(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.MVNParameter)
- return target;
-}
-
-size_t MVNParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.MVNParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 7u) {
- // optional bool normalize_variance = 1 [default = true];
- if (has_normalize_variance()) {
- total_size += 1 + 1;
- }
-
- // optional bool across_channels = 2 [default = false];
- if (has_across_channels()) {
- total_size += 1 + 1;
- }
-
- // optional float eps = 3 [default = 1e-09];
- if (has_eps()) {
- total_size += 1 + 4;
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void MVNParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.MVNParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const MVNParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const MVNParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.MVNParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.MVNParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void MVNParameter::MergeFrom(const MVNParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.MVNParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void MVNParameter::UnsafeMergeFrom(const MVNParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_normalize_variance()) {
- set_normalize_variance(from.normalize_variance());
- }
- if (from.has_across_channels()) {
- set_across_channels(from.across_channels());
- }
- if (from.has_eps()) {
- set_eps(from.eps());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void MVNParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.MVNParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void MVNParameter::CopyFrom(const MVNParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.MVNParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool MVNParameter::IsInitialized() const {
-
- return true;
-}
-
-void MVNParameter::Swap(MVNParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void MVNParameter::InternalSwap(MVNParameter* other) {
- std::swap(normalize_variance_, other->normalize_variance_);
- std::swap(across_channels_, other->across_channels_);
- std::swap(eps_, other->eps_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata MVNParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = MVNParameter_descriptor_;
- metadata.reflection = MVNParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// MVNParameter
-
-// optional bool normalize_variance = 1 [default = true];
-bool MVNParameter::has_normalize_variance() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void MVNParameter::set_has_normalize_variance() {
- _has_bits_[0] |= 0x00000001u;
-}
-void MVNParameter::clear_has_normalize_variance() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void MVNParameter::clear_normalize_variance() {
- normalize_variance_ = true;
- clear_has_normalize_variance();
-}
-bool MVNParameter::normalize_variance() const {
- // @@protoc_insertion_point(field_get:caffe.MVNParameter.normalize_variance)
- return normalize_variance_;
-}
-void MVNParameter::set_normalize_variance(bool value) {
- set_has_normalize_variance();
- normalize_variance_ = value;
- // @@protoc_insertion_point(field_set:caffe.MVNParameter.normalize_variance)
-}
-
-// optional bool across_channels = 2 [default = false];
-bool MVNParameter::has_across_channels() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void MVNParameter::set_has_across_channels() {
- _has_bits_[0] |= 0x00000002u;
-}
-void MVNParameter::clear_has_across_channels() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void MVNParameter::clear_across_channels() {
- across_channels_ = false;
- clear_has_across_channels();
-}
-bool MVNParameter::across_channels() const {
- // @@protoc_insertion_point(field_get:caffe.MVNParameter.across_channels)
- return across_channels_;
-}
-void MVNParameter::set_across_channels(bool value) {
- set_has_across_channels();
- across_channels_ = value;
- // @@protoc_insertion_point(field_set:caffe.MVNParameter.across_channels)
-}
-
-// optional float eps = 3 [default = 1e-09];
-bool MVNParameter::has_eps() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void MVNParameter::set_has_eps() {
- _has_bits_[0] |= 0x00000004u;
-}
-void MVNParameter::clear_has_eps() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void MVNParameter::clear_eps() {
- eps_ = 1e-09f;
- clear_has_eps();
-}
-float MVNParameter::eps() const {
- // @@protoc_insertion_point(field_get:caffe.MVNParameter.eps)
- return eps_;
-}
-void MVNParameter::set_eps(float value) {
- set_has_eps();
- eps_ = value;
- // @@protoc_insertion_point(field_set:caffe.MVNParameter.eps)
-}
-
-inline const MVNParameter* MVNParameter::internal_default_instance() {
- return &MVNParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-const ::google::protobuf::EnumDescriptor* PoolingParameter_PoolMethod_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return PoolingParameter_PoolMethod_descriptor_;
-}
-bool PoolingParameter_PoolMethod_IsValid(int value) {
- switch (value) {
- case 0:
- case 1:
- case 2:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const PoolingParameter_PoolMethod PoolingParameter::MAX;
-const PoolingParameter_PoolMethod PoolingParameter::AVE;
-const PoolingParameter_PoolMethod PoolingParameter::STOCHASTIC;
-const PoolingParameter_PoolMethod PoolingParameter::PoolMethod_MIN;
-const PoolingParameter_PoolMethod PoolingParameter::PoolMethod_MAX;
-const int PoolingParameter::PoolMethod_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-const ::google::protobuf::EnumDescriptor* PoolingParameter_Engine_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return PoolingParameter_Engine_descriptor_;
-}
-bool PoolingParameter_Engine_IsValid(int value) {
- switch (value) {
- case 0:
- case 1:
- case 2:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const PoolingParameter_Engine PoolingParameter::DEFAULT;
-const PoolingParameter_Engine PoolingParameter::CAFFE;
-const PoolingParameter_Engine PoolingParameter::CUDNN;
-const PoolingParameter_Engine PoolingParameter::Engine_MIN;
-const PoolingParameter_Engine PoolingParameter::Engine_MAX;
-const int PoolingParameter::Engine_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int PoolingParameter::kPoolFieldNumber;
-const int PoolingParameter::kPadFieldNumber;
-const int PoolingParameter::kPadHFieldNumber;
-const int PoolingParameter::kPadWFieldNumber;
-const int PoolingParameter::kKernelSizeFieldNumber;
-const int PoolingParameter::kKernelHFieldNumber;
-const int PoolingParameter::kKernelWFieldNumber;
-const int PoolingParameter::kStrideFieldNumber;
-const int PoolingParameter::kStrideHFieldNumber;
-const int PoolingParameter::kStrideWFieldNumber;
-const int PoolingParameter::kEngineFieldNumber;
-const int PoolingParameter::kGlobalPoolingFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-PoolingParameter::PoolingParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.PoolingParameter)
-}
-
-void PoolingParameter::InitAsDefaultInstance() {
-}
-
-PoolingParameter::PoolingParameter(const PoolingParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.PoolingParameter)
-}
-
-void PoolingParameter::SharedCtor() {
- _cached_size_ = 0;
- ::memset(&pool_, 0, reinterpret_cast<char*>(&global_pooling_) -
- reinterpret_cast<char*>(&pool_) + sizeof(global_pooling_));
- stride_ = 1u;
-}
-
-PoolingParameter::~PoolingParameter() {
- // @@protoc_insertion_point(destructor:caffe.PoolingParameter)
- SharedDtor();
-}
-
-void PoolingParameter::SharedDtor() {
-}
-
-void PoolingParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* PoolingParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return PoolingParameter_descriptor_;
-}
-
-const PoolingParameter& PoolingParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<PoolingParameter> PoolingParameter_default_instance_;
-
-PoolingParameter* PoolingParameter::New(::google::protobuf::Arena* arena) const {
- PoolingParameter* n = new PoolingParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void PoolingParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.PoolingParameter)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(PoolingParameter, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<PoolingParameter*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- if (_has_bits_[0 / 32] & 255u) {
- ZR_(pool_, kernel_w_);
- stride_ = 1u;
- }
- ZR_(stride_h_, global_pooling_);
-
-#undef ZR_HELPER_
-#undef ZR_
-
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool PoolingParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.PoolingParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional .caffe.PoolingParameter.PoolMethod pool = 1 [default = MAX];
- case 1: {
- if (tag == 8) {
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::PoolingParameter_PoolMethod_IsValid(value)) {
- set_pool(static_cast< ::caffe::PoolingParameter_PoolMethod >(value));
- } else {
- mutable_unknown_fields()->AddVarint(1, value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_kernel_size;
- break;
- }
-
- // optional uint32 kernel_size = 2;
- case 2: {
- if (tag == 16) {
- parse_kernel_size:
- set_has_kernel_size();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &kernel_size_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(24)) goto parse_stride;
- break;
- }
-
- // optional uint32 stride = 3 [default = 1];
- case 3: {
- if (tag == 24) {
- parse_stride:
- set_has_stride();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &stride_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(32)) goto parse_pad;
- break;
- }
-
- // optional uint32 pad = 4 [default = 0];
- case 4: {
- if (tag == 32) {
- parse_pad:
- set_has_pad();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &pad_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(40)) goto parse_kernel_h;
- break;
- }
-
- // optional uint32 kernel_h = 5;
- case 5: {
- if (tag == 40) {
- parse_kernel_h:
- set_has_kernel_h();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &kernel_h_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(48)) goto parse_kernel_w;
- break;
- }
-
- // optional uint32 kernel_w = 6;
- case 6: {
- if (tag == 48) {
- parse_kernel_w:
- set_has_kernel_w();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &kernel_w_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(56)) goto parse_stride_h;
- break;
- }
-
- // optional uint32 stride_h = 7;
- case 7: {
- if (tag == 56) {
- parse_stride_h:
- set_has_stride_h();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &stride_h_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(64)) goto parse_stride_w;
- break;
- }
-
- // optional uint32 stride_w = 8;
- case 8: {
- if (tag == 64) {
- parse_stride_w:
- set_has_stride_w();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &stride_w_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(72)) goto parse_pad_h;
- break;
- }
-
- // optional uint32 pad_h = 9 [default = 0];
- case 9: {
- if (tag == 72) {
- parse_pad_h:
- set_has_pad_h();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &pad_h_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(80)) goto parse_pad_w;
- break;
- }
-
- // optional uint32 pad_w = 10 [default = 0];
- case 10: {
- if (tag == 80) {
- parse_pad_w:
- set_has_pad_w();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &pad_w_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(88)) goto parse_engine;
- break;
- }
-
- // optional .caffe.PoolingParameter.Engine engine = 11 [default = DEFAULT];
- case 11: {
- if (tag == 88) {
- parse_engine:
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::PoolingParameter_Engine_IsValid(value)) {
- set_engine(static_cast< ::caffe::PoolingParameter_Engine >(value));
- } else {
- mutable_unknown_fields()->AddVarint(11, value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(96)) goto parse_global_pooling;
- break;
- }
-
- // optional bool global_pooling = 12 [default = false];
- case 12: {
- if (tag == 96) {
- parse_global_pooling:
- set_has_global_pooling();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &global_pooling_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.PoolingParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.PoolingParameter)
- return false;
-#undef DO_
-}
-
-void PoolingParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.PoolingParameter)
- // optional .caffe.PoolingParameter.PoolMethod pool = 1 [default = MAX];
- if (has_pool()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 1, this->pool(), output);
- }
-
- // optional uint32 kernel_size = 2;
- if (has_kernel_size()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(2, this->kernel_size(), output);
- }
-
- // optional uint32 stride = 3 [default = 1];
- if (has_stride()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(3, this->stride(), output);
- }
-
- // optional uint32 pad = 4 [default = 0];
- if (has_pad()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(4, this->pad(), output);
- }
-
- // optional uint32 kernel_h = 5;
- if (has_kernel_h()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(5, this->kernel_h(), output);
- }
-
- // optional uint32 kernel_w = 6;
- if (has_kernel_w()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(6, this->kernel_w(), output);
- }
-
- // optional uint32 stride_h = 7;
- if (has_stride_h()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(7, this->stride_h(), output);
- }
-
- // optional uint32 stride_w = 8;
- if (has_stride_w()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(8, this->stride_w(), output);
- }
-
- // optional uint32 pad_h = 9 [default = 0];
- if (has_pad_h()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(9, this->pad_h(), output);
- }
-
- // optional uint32 pad_w = 10 [default = 0];
- if (has_pad_w()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(10, this->pad_w(), output);
- }
-
- // optional .caffe.PoolingParameter.Engine engine = 11 [default = DEFAULT];
- if (has_engine()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 11, this->engine(), output);
- }
-
- // optional bool global_pooling = 12 [default = false];
- if (has_global_pooling()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(12, this->global_pooling(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.PoolingParameter)
-}
-
-::google::protobuf::uint8* PoolingParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.PoolingParameter)
- // optional .caffe.PoolingParameter.PoolMethod pool = 1 [default = MAX];
- if (has_pool()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 1, this->pool(), target);
- }
-
- // optional uint32 kernel_size = 2;
- if (has_kernel_size()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(2, this->kernel_size(), target);
- }
-
- // optional uint32 stride = 3 [default = 1];
- if (has_stride()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(3, this->stride(), target);
- }
-
- // optional uint32 pad = 4 [default = 0];
- if (has_pad()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(4, this->pad(), target);
- }
-
- // optional uint32 kernel_h = 5;
- if (has_kernel_h()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(5, this->kernel_h(), target);
- }
-
- // optional uint32 kernel_w = 6;
- if (has_kernel_w()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(6, this->kernel_w(), target);
- }
-
- // optional uint32 stride_h = 7;
- if (has_stride_h()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(7, this->stride_h(), target);
- }
-
- // optional uint32 stride_w = 8;
- if (has_stride_w()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(8, this->stride_w(), target);
- }
-
- // optional uint32 pad_h = 9 [default = 0];
- if (has_pad_h()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(9, this->pad_h(), target);
- }
-
- // optional uint32 pad_w = 10 [default = 0];
- if (has_pad_w()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(10, this->pad_w(), target);
- }
-
- // optional .caffe.PoolingParameter.Engine engine = 11 [default = DEFAULT];
- if (has_engine()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 11, this->engine(), target);
- }
-
- // optional bool global_pooling = 12 [default = false];
- if (has_global_pooling()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(12, this->global_pooling(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.PoolingParameter)
- return target;
-}
-
-size_t PoolingParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.PoolingParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 255u) {
- // optional .caffe.PoolingParameter.PoolMethod pool = 1 [default = MAX];
- if (has_pool()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->pool());
- }
-
- // optional uint32 pad = 4 [default = 0];
- if (has_pad()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->pad());
- }
-
- // optional uint32 pad_h = 9 [default = 0];
- if (has_pad_h()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->pad_h());
- }
-
- // optional uint32 pad_w = 10 [default = 0];
- if (has_pad_w()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->pad_w());
- }
-
- // optional uint32 kernel_size = 2;
- if (has_kernel_size()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->kernel_size());
- }
-
- // optional uint32 kernel_h = 5;
- if (has_kernel_h()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->kernel_h());
- }
-
- // optional uint32 kernel_w = 6;
- if (has_kernel_w()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->kernel_w());
- }
-
- // optional uint32 stride = 3 [default = 1];
- if (has_stride()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->stride());
- }
-
- }
- if (_has_bits_[8 / 32] & 3840u) {
- // optional uint32 stride_h = 7;
- if (has_stride_h()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->stride_h());
- }
-
- // optional uint32 stride_w = 8;
- if (has_stride_w()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->stride_w());
- }
-
- // optional .caffe.PoolingParameter.Engine engine = 11 [default = DEFAULT];
- if (has_engine()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->engine());
- }
-
- // optional bool global_pooling = 12 [default = false];
- if (has_global_pooling()) {
- total_size += 1 + 1;
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void PoolingParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.PoolingParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const PoolingParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const PoolingParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.PoolingParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.PoolingParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void PoolingParameter::MergeFrom(const PoolingParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.PoolingParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void PoolingParameter::UnsafeMergeFrom(const PoolingParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_pool()) {
- set_pool(from.pool());
- }
- if (from.has_pad()) {
- set_pad(from.pad());
- }
- if (from.has_pad_h()) {
- set_pad_h(from.pad_h());
- }
- if (from.has_pad_w()) {
- set_pad_w(from.pad_w());
- }
- if (from.has_kernel_size()) {
- set_kernel_size(from.kernel_size());
- }
- if (from.has_kernel_h()) {
- set_kernel_h(from.kernel_h());
- }
- if (from.has_kernel_w()) {
- set_kernel_w(from.kernel_w());
- }
- if (from.has_stride()) {
- set_stride(from.stride());
- }
- }
- if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) {
- if (from.has_stride_h()) {
- set_stride_h(from.stride_h());
- }
- if (from.has_stride_w()) {
- set_stride_w(from.stride_w());
- }
- if (from.has_engine()) {
- set_engine(from.engine());
- }
- if (from.has_global_pooling()) {
- set_global_pooling(from.global_pooling());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void PoolingParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.PoolingParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void PoolingParameter::CopyFrom(const PoolingParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.PoolingParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool PoolingParameter::IsInitialized() const {
-
- return true;
-}
-
-void PoolingParameter::Swap(PoolingParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void PoolingParameter::InternalSwap(PoolingParameter* other) {
- std::swap(pool_, other->pool_);
- std::swap(pad_, other->pad_);
- std::swap(pad_h_, other->pad_h_);
- std::swap(pad_w_, other->pad_w_);
- std::swap(kernel_size_, other->kernel_size_);
- std::swap(kernel_h_, other->kernel_h_);
- std::swap(kernel_w_, other->kernel_w_);
- std::swap(stride_, other->stride_);
- std::swap(stride_h_, other->stride_h_);
- std::swap(stride_w_, other->stride_w_);
- std::swap(engine_, other->engine_);
- std::swap(global_pooling_, other->global_pooling_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata PoolingParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = PoolingParameter_descriptor_;
- metadata.reflection = PoolingParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// PoolingParameter
-
-// optional .caffe.PoolingParameter.PoolMethod pool = 1 [default = MAX];
-bool PoolingParameter::has_pool() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void PoolingParameter::set_has_pool() {
- _has_bits_[0] |= 0x00000001u;
-}
-void PoolingParameter::clear_has_pool() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void PoolingParameter::clear_pool() {
- pool_ = 0;
- clear_has_pool();
-}
-::caffe::PoolingParameter_PoolMethod PoolingParameter::pool() const {
- // @@protoc_insertion_point(field_get:caffe.PoolingParameter.pool)
- return static_cast< ::caffe::PoolingParameter_PoolMethod >(pool_);
-}
-void PoolingParameter::set_pool(::caffe::PoolingParameter_PoolMethod value) {
- assert(::caffe::PoolingParameter_PoolMethod_IsValid(value));
- set_has_pool();
- pool_ = value;
- // @@protoc_insertion_point(field_set:caffe.PoolingParameter.pool)
-}
-
-// optional uint32 pad = 4 [default = 0];
-bool PoolingParameter::has_pad() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void PoolingParameter::set_has_pad() {
- _has_bits_[0] |= 0x00000002u;
-}
-void PoolingParameter::clear_has_pad() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void PoolingParameter::clear_pad() {
- pad_ = 0u;
- clear_has_pad();
-}
-::google::protobuf::uint32 PoolingParameter::pad() const {
- // @@protoc_insertion_point(field_get:caffe.PoolingParameter.pad)
- return pad_;
-}
-void PoolingParameter::set_pad(::google::protobuf::uint32 value) {
- set_has_pad();
- pad_ = value;
- // @@protoc_insertion_point(field_set:caffe.PoolingParameter.pad)
-}
-
-// optional uint32 pad_h = 9 [default = 0];
-bool PoolingParameter::has_pad_h() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void PoolingParameter::set_has_pad_h() {
- _has_bits_[0] |= 0x00000004u;
-}
-void PoolingParameter::clear_has_pad_h() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void PoolingParameter::clear_pad_h() {
- pad_h_ = 0u;
- clear_has_pad_h();
-}
-::google::protobuf::uint32 PoolingParameter::pad_h() const {
- // @@protoc_insertion_point(field_get:caffe.PoolingParameter.pad_h)
- return pad_h_;
-}
-void PoolingParameter::set_pad_h(::google::protobuf::uint32 value) {
- set_has_pad_h();
- pad_h_ = value;
- // @@protoc_insertion_point(field_set:caffe.PoolingParameter.pad_h)
-}
-
-// optional uint32 pad_w = 10 [default = 0];
-bool PoolingParameter::has_pad_w() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-void PoolingParameter::set_has_pad_w() {
- _has_bits_[0] |= 0x00000008u;
-}
-void PoolingParameter::clear_has_pad_w() {
- _has_bits_[0] &= ~0x00000008u;
-}
-void PoolingParameter::clear_pad_w() {
- pad_w_ = 0u;
- clear_has_pad_w();
-}
-::google::protobuf::uint32 PoolingParameter::pad_w() const {
- // @@protoc_insertion_point(field_get:caffe.PoolingParameter.pad_w)
- return pad_w_;
-}
-void PoolingParameter::set_pad_w(::google::protobuf::uint32 value) {
- set_has_pad_w();
- pad_w_ = value;
- // @@protoc_insertion_point(field_set:caffe.PoolingParameter.pad_w)
-}
-
-// optional uint32 kernel_size = 2;
-bool PoolingParameter::has_kernel_size() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-void PoolingParameter::set_has_kernel_size() {
- _has_bits_[0] |= 0x00000010u;
-}
-void PoolingParameter::clear_has_kernel_size() {
- _has_bits_[0] &= ~0x00000010u;
-}
-void PoolingParameter::clear_kernel_size() {
- kernel_size_ = 0u;
- clear_has_kernel_size();
-}
-::google::protobuf::uint32 PoolingParameter::kernel_size() const {
- // @@protoc_insertion_point(field_get:caffe.PoolingParameter.kernel_size)
- return kernel_size_;
-}
-void PoolingParameter::set_kernel_size(::google::protobuf::uint32 value) {
- set_has_kernel_size();
- kernel_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.PoolingParameter.kernel_size)
-}
-
-// optional uint32 kernel_h = 5;
-bool PoolingParameter::has_kernel_h() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-void PoolingParameter::set_has_kernel_h() {
- _has_bits_[0] |= 0x00000020u;
-}
-void PoolingParameter::clear_has_kernel_h() {
- _has_bits_[0] &= ~0x00000020u;
-}
-void PoolingParameter::clear_kernel_h() {
- kernel_h_ = 0u;
- clear_has_kernel_h();
-}
-::google::protobuf::uint32 PoolingParameter::kernel_h() const {
- // @@protoc_insertion_point(field_get:caffe.PoolingParameter.kernel_h)
- return kernel_h_;
-}
-void PoolingParameter::set_kernel_h(::google::protobuf::uint32 value) {
- set_has_kernel_h();
- kernel_h_ = value;
- // @@protoc_insertion_point(field_set:caffe.PoolingParameter.kernel_h)
-}
-
-// optional uint32 kernel_w = 6;
-bool PoolingParameter::has_kernel_w() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-void PoolingParameter::set_has_kernel_w() {
- _has_bits_[0] |= 0x00000040u;
-}
-void PoolingParameter::clear_has_kernel_w() {
- _has_bits_[0] &= ~0x00000040u;
-}
-void PoolingParameter::clear_kernel_w() {
- kernel_w_ = 0u;
- clear_has_kernel_w();
-}
-::google::protobuf::uint32 PoolingParameter::kernel_w() const {
- // @@protoc_insertion_point(field_get:caffe.PoolingParameter.kernel_w)
- return kernel_w_;
-}
-void PoolingParameter::set_kernel_w(::google::protobuf::uint32 value) {
- set_has_kernel_w();
- kernel_w_ = value;
- // @@protoc_insertion_point(field_set:caffe.PoolingParameter.kernel_w)
-}
-
-// optional uint32 stride = 3 [default = 1];
-bool PoolingParameter::has_stride() const {
- return (_has_bits_[0] & 0x00000080u) != 0;
-}
-void PoolingParameter::set_has_stride() {
- _has_bits_[0] |= 0x00000080u;
-}
-void PoolingParameter::clear_has_stride() {
- _has_bits_[0] &= ~0x00000080u;
-}
-void PoolingParameter::clear_stride() {
- stride_ = 1u;
- clear_has_stride();
-}
-::google::protobuf::uint32 PoolingParameter::stride() const {
- // @@protoc_insertion_point(field_get:caffe.PoolingParameter.stride)
- return stride_;
-}
-void PoolingParameter::set_stride(::google::protobuf::uint32 value) {
- set_has_stride();
- stride_ = value;
- // @@protoc_insertion_point(field_set:caffe.PoolingParameter.stride)
-}
-
-// optional uint32 stride_h = 7;
-bool PoolingParameter::has_stride_h() const {
- return (_has_bits_[0] & 0x00000100u) != 0;
-}
-void PoolingParameter::set_has_stride_h() {
- _has_bits_[0] |= 0x00000100u;
-}
-void PoolingParameter::clear_has_stride_h() {
- _has_bits_[0] &= ~0x00000100u;
-}
-void PoolingParameter::clear_stride_h() {
- stride_h_ = 0u;
- clear_has_stride_h();
-}
-::google::protobuf::uint32 PoolingParameter::stride_h() const {
- // @@protoc_insertion_point(field_get:caffe.PoolingParameter.stride_h)
- return stride_h_;
-}
-void PoolingParameter::set_stride_h(::google::protobuf::uint32 value) {
- set_has_stride_h();
- stride_h_ = value;
- // @@protoc_insertion_point(field_set:caffe.PoolingParameter.stride_h)
-}
-
-// optional uint32 stride_w = 8;
-bool PoolingParameter::has_stride_w() const {
- return (_has_bits_[0] & 0x00000200u) != 0;
-}
-void PoolingParameter::set_has_stride_w() {
- _has_bits_[0] |= 0x00000200u;
-}
-void PoolingParameter::clear_has_stride_w() {
- _has_bits_[0] &= ~0x00000200u;
-}
-void PoolingParameter::clear_stride_w() {
- stride_w_ = 0u;
- clear_has_stride_w();
-}
-::google::protobuf::uint32 PoolingParameter::stride_w() const {
- // @@protoc_insertion_point(field_get:caffe.PoolingParameter.stride_w)
- return stride_w_;
-}
-void PoolingParameter::set_stride_w(::google::protobuf::uint32 value) {
- set_has_stride_w();
- stride_w_ = value;
- // @@protoc_insertion_point(field_set:caffe.PoolingParameter.stride_w)
-}
-
-// optional .caffe.PoolingParameter.Engine engine = 11 [default = DEFAULT];
-bool PoolingParameter::has_engine() const {
- return (_has_bits_[0] & 0x00000400u) != 0;
-}
-void PoolingParameter::set_has_engine() {
- _has_bits_[0] |= 0x00000400u;
-}
-void PoolingParameter::clear_has_engine() {
- _has_bits_[0] &= ~0x00000400u;
-}
-void PoolingParameter::clear_engine() {
- engine_ = 0;
- clear_has_engine();
-}
-::caffe::PoolingParameter_Engine PoolingParameter::engine() const {
- // @@protoc_insertion_point(field_get:caffe.PoolingParameter.engine)
- return static_cast< ::caffe::PoolingParameter_Engine >(engine_);
-}
-void PoolingParameter::set_engine(::caffe::PoolingParameter_Engine value) {
- assert(::caffe::PoolingParameter_Engine_IsValid(value));
- set_has_engine();
- engine_ = value;
- // @@protoc_insertion_point(field_set:caffe.PoolingParameter.engine)
-}
-
-// optional bool global_pooling = 12 [default = false];
-bool PoolingParameter::has_global_pooling() const {
- return (_has_bits_[0] & 0x00000800u) != 0;
-}
-void PoolingParameter::set_has_global_pooling() {
- _has_bits_[0] |= 0x00000800u;
-}
-void PoolingParameter::clear_has_global_pooling() {
- _has_bits_[0] &= ~0x00000800u;
-}
-void PoolingParameter::clear_global_pooling() {
- global_pooling_ = false;
- clear_has_global_pooling();
-}
-bool PoolingParameter::global_pooling() const {
- // @@protoc_insertion_point(field_get:caffe.PoolingParameter.global_pooling)
- return global_pooling_;
-}
-void PoolingParameter::set_global_pooling(bool value) {
- set_has_global_pooling();
- global_pooling_ = value;
- // @@protoc_insertion_point(field_set:caffe.PoolingParameter.global_pooling)
-}
-
-inline const PoolingParameter* PoolingParameter::internal_default_instance() {
- return &PoolingParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int PowerParameter::kPowerFieldNumber;
-const int PowerParameter::kScaleFieldNumber;
-const int PowerParameter::kShiftFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-PowerParameter::PowerParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.PowerParameter)
-}
-
-void PowerParameter::InitAsDefaultInstance() {
-}
-
-PowerParameter::PowerParameter(const PowerParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.PowerParameter)
-}
-
-void PowerParameter::SharedCtor() {
- _cached_size_ = 0;
- shift_ = 0;
- power_ = 1;
- scale_ = 1;
-}
-
-PowerParameter::~PowerParameter() {
- // @@protoc_insertion_point(destructor:caffe.PowerParameter)
- SharedDtor();
-}
-
-void PowerParameter::SharedDtor() {
-}
-
-void PowerParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* PowerParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return PowerParameter_descriptor_;
-}
-
-const PowerParameter& PowerParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<PowerParameter> PowerParameter_default_instance_;
-
-PowerParameter* PowerParameter::New(::google::protobuf::Arena* arena) const {
- PowerParameter* n = new PowerParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void PowerParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.PowerParameter)
- if (_has_bits_[0 / 32] & 7u) {
- power_ = 1;
- scale_ = 1;
- shift_ = 0;
- }
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool PowerParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.PowerParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional float power = 1 [default = 1];
- case 1: {
- if (tag == 13) {
- set_has_power();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &power_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(21)) goto parse_scale;
- break;
- }
-
- // optional float scale = 2 [default = 1];
- case 2: {
- if (tag == 21) {
- parse_scale:
- set_has_scale();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &scale_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(29)) goto parse_shift;
- break;
- }
-
- // optional float shift = 3 [default = 0];
- case 3: {
- if (tag == 29) {
- parse_shift:
- set_has_shift();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &shift_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.PowerParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.PowerParameter)
- return false;
-#undef DO_
-}
-
-void PowerParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.PowerParameter)
- // optional float power = 1 [default = 1];
- if (has_power()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->power(), output);
- }
-
- // optional float scale = 2 [default = 1];
- if (has_scale()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->scale(), output);
- }
-
- // optional float shift = 3 [default = 0];
- if (has_shift()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->shift(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.PowerParameter)
-}
-
-::google::protobuf::uint8* PowerParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.PowerParameter)
- // optional float power = 1 [default = 1];
- if (has_power()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->power(), target);
- }
-
- // optional float scale = 2 [default = 1];
- if (has_scale()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->scale(), target);
- }
-
- // optional float shift = 3 [default = 0];
- if (has_shift()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->shift(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.PowerParameter)
- return target;
-}
-
-size_t PowerParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.PowerParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 7u) {
- // optional float power = 1 [default = 1];
- if (has_power()) {
- total_size += 1 + 4;
- }
-
- // optional float scale = 2 [default = 1];
- if (has_scale()) {
- total_size += 1 + 4;
- }
-
- // optional float shift = 3 [default = 0];
- if (has_shift()) {
- total_size += 1 + 4;
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void PowerParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.PowerParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const PowerParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const PowerParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.PowerParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.PowerParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void PowerParameter::MergeFrom(const PowerParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.PowerParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void PowerParameter::UnsafeMergeFrom(const PowerParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_power()) {
- set_power(from.power());
- }
- if (from.has_scale()) {
- set_scale(from.scale());
- }
- if (from.has_shift()) {
- set_shift(from.shift());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void PowerParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.PowerParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void PowerParameter::CopyFrom(const PowerParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.PowerParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool PowerParameter::IsInitialized() const {
-
- return true;
-}
-
-void PowerParameter::Swap(PowerParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void PowerParameter::InternalSwap(PowerParameter* other) {
- std::swap(power_, other->power_);
- std::swap(scale_, other->scale_);
- std::swap(shift_, other->shift_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata PowerParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = PowerParameter_descriptor_;
- metadata.reflection = PowerParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// PowerParameter
-
-// optional float power = 1 [default = 1];
-bool PowerParameter::has_power() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void PowerParameter::set_has_power() {
- _has_bits_[0] |= 0x00000001u;
-}
-void PowerParameter::clear_has_power() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void PowerParameter::clear_power() {
- power_ = 1;
- clear_has_power();
-}
-float PowerParameter::power() const {
- // @@protoc_insertion_point(field_get:caffe.PowerParameter.power)
- return power_;
-}
-void PowerParameter::set_power(float value) {
- set_has_power();
- power_ = value;
- // @@protoc_insertion_point(field_set:caffe.PowerParameter.power)
-}
-
-// optional float scale = 2 [default = 1];
-bool PowerParameter::has_scale() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void PowerParameter::set_has_scale() {
- _has_bits_[0] |= 0x00000002u;
-}
-void PowerParameter::clear_has_scale() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void PowerParameter::clear_scale() {
- scale_ = 1;
- clear_has_scale();
-}
-float PowerParameter::scale() const {
- // @@protoc_insertion_point(field_get:caffe.PowerParameter.scale)
- return scale_;
-}
-void PowerParameter::set_scale(float value) {
- set_has_scale();
- scale_ = value;
- // @@protoc_insertion_point(field_set:caffe.PowerParameter.scale)
-}
-
-// optional float shift = 3 [default = 0];
-bool PowerParameter::has_shift() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void PowerParameter::set_has_shift() {
- _has_bits_[0] |= 0x00000004u;
-}
-void PowerParameter::clear_has_shift() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void PowerParameter::clear_shift() {
- shift_ = 0;
- clear_has_shift();
-}
-float PowerParameter::shift() const {
- // @@protoc_insertion_point(field_get:caffe.PowerParameter.shift)
- return shift_;
-}
-void PowerParameter::set_shift(float value) {
- set_has_shift();
- shift_ = value;
- // @@protoc_insertion_point(field_set:caffe.PowerParameter.shift)
-}
-
-inline const PowerParameter* PowerParameter::internal_default_instance() {
- return &PowerParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int PythonParameter::kModuleFieldNumber;
-const int PythonParameter::kLayerFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-PythonParameter::PythonParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.PythonParameter)
-}
-
-void PythonParameter::InitAsDefaultInstance() {
-}
-
-PythonParameter::PythonParameter(const PythonParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.PythonParameter)
-}
-
-void PythonParameter::SharedCtor() {
- _cached_size_ = 0;
- module_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- layer_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-
-PythonParameter::~PythonParameter() {
- // @@protoc_insertion_point(destructor:caffe.PythonParameter)
- SharedDtor();
-}
-
-void PythonParameter::SharedDtor() {
- module_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- layer_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-
-void PythonParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* PythonParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return PythonParameter_descriptor_;
-}
-
-const PythonParameter& PythonParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<PythonParameter> PythonParameter_default_instance_;
-
-PythonParameter* PythonParameter::New(::google::protobuf::Arena* arena) const {
- PythonParameter* n = new PythonParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void PythonParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.PythonParameter)
- if (_has_bits_[0 / 32] & 3u) {
- if (has_module()) {
- module_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- if (has_layer()) {
- layer_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- }
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool PythonParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.PythonParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional string module = 1;
- case 1: {
- if (tag == 10) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_module()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->module().data(), this->module().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.PythonParameter.module");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(18)) goto parse_layer;
- break;
- }
-
- // optional string layer = 2;
- case 2: {
- if (tag == 18) {
- parse_layer:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_layer()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->layer().data(), this->layer().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.PythonParameter.layer");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.PythonParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.PythonParameter)
- return false;
-#undef DO_
-}
-
-void PythonParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.PythonParameter)
- // optional string module = 1;
- if (has_module()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->module().data(), this->module().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.PythonParameter.module");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 1, this->module(), output);
- }
-
- // optional string layer = 2;
- if (has_layer()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->layer().data(), this->layer().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.PythonParameter.layer");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 2, this->layer(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.PythonParameter)
-}
-
-::google::protobuf::uint8* PythonParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.PythonParameter)
- // optional string module = 1;
- if (has_module()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->module().data(), this->module().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.PythonParameter.module");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 1, this->module(), target);
- }
-
- // optional string layer = 2;
- if (has_layer()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->layer().data(), this->layer().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.PythonParameter.layer");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 2, this->layer(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.PythonParameter)
- return target;
-}
-
-size_t PythonParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.PythonParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 3u) {
- // optional string module = 1;
- if (has_module()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->module());
- }
-
- // optional string layer = 2;
- if (has_layer()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->layer());
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void PythonParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.PythonParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const PythonParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const PythonParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.PythonParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.PythonParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void PythonParameter::MergeFrom(const PythonParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.PythonParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void PythonParameter::UnsafeMergeFrom(const PythonParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_module()) {
- set_has_module();
- module_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.module_);
- }
- if (from.has_layer()) {
- set_has_layer();
- layer_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.layer_);
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void PythonParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.PythonParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void PythonParameter::CopyFrom(const PythonParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.PythonParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool PythonParameter::IsInitialized() const {
-
- return true;
-}
-
-void PythonParameter::Swap(PythonParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void PythonParameter::InternalSwap(PythonParameter* other) {
- module_.Swap(&other->module_);
- layer_.Swap(&other->layer_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata PythonParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = PythonParameter_descriptor_;
- metadata.reflection = PythonParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// PythonParameter
-
-// optional string module = 1;
-bool PythonParameter::has_module() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void PythonParameter::set_has_module() {
- _has_bits_[0] |= 0x00000001u;
-}
-void PythonParameter::clear_has_module() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void PythonParameter::clear_module() {
- module_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_module();
-}
-const ::std::string& PythonParameter::module() const {
- // @@protoc_insertion_point(field_get:caffe.PythonParameter.module)
- return module_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void PythonParameter::set_module(const ::std::string& value) {
- set_has_module();
- module_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.PythonParameter.module)
-}
-void PythonParameter::set_module(const char* value) {
- set_has_module();
- module_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.PythonParameter.module)
-}
-void PythonParameter::set_module(const char* value, size_t size) {
- set_has_module();
- module_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.PythonParameter.module)
-}
-::std::string* PythonParameter::mutable_module() {
- set_has_module();
- // @@protoc_insertion_point(field_mutable:caffe.PythonParameter.module)
- return module_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* PythonParameter::release_module() {
- // @@protoc_insertion_point(field_release:caffe.PythonParameter.module)
- clear_has_module();
- return module_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void PythonParameter::set_allocated_module(::std::string* module) {
- if (module != NULL) {
- set_has_module();
- } else {
- clear_has_module();
- }
- module_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), module);
- // @@protoc_insertion_point(field_set_allocated:caffe.PythonParameter.module)
-}
-
-// optional string layer = 2;
-bool PythonParameter::has_layer() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void PythonParameter::set_has_layer() {
- _has_bits_[0] |= 0x00000002u;
-}
-void PythonParameter::clear_has_layer() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void PythonParameter::clear_layer() {
- layer_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_layer();
-}
-const ::std::string& PythonParameter::layer() const {
- // @@protoc_insertion_point(field_get:caffe.PythonParameter.layer)
- return layer_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void PythonParameter::set_layer(const ::std::string& value) {
- set_has_layer();
- layer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.PythonParameter.layer)
-}
-void PythonParameter::set_layer(const char* value) {
- set_has_layer();
- layer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.PythonParameter.layer)
-}
-void PythonParameter::set_layer(const char* value, size_t size) {
- set_has_layer();
- layer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.PythonParameter.layer)
-}
-::std::string* PythonParameter::mutable_layer() {
- set_has_layer();
- // @@protoc_insertion_point(field_mutable:caffe.PythonParameter.layer)
- return layer_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* PythonParameter::release_layer() {
- // @@protoc_insertion_point(field_release:caffe.PythonParameter.layer)
- clear_has_layer();
- return layer_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void PythonParameter::set_allocated_layer(::std::string* layer) {
- if (layer != NULL) {
- set_has_layer();
- } else {
- clear_has_layer();
- }
- layer_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), layer);
- // @@protoc_insertion_point(field_set_allocated:caffe.PythonParameter.layer)
-}
-
-inline const PythonParameter* PythonParameter::internal_default_instance() {
- return &PythonParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-const ::google::protobuf::EnumDescriptor* ReductionParameter_ReductionOp_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return ReductionParameter_ReductionOp_descriptor_;
-}
-bool ReductionParameter_ReductionOp_IsValid(int value) {
- switch (value) {
- case 1:
- case 2:
- case 3:
- case 4:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const ReductionParameter_ReductionOp ReductionParameter::SUM;
-const ReductionParameter_ReductionOp ReductionParameter::ASUM;
-const ReductionParameter_ReductionOp ReductionParameter::SUMSQ;
-const ReductionParameter_ReductionOp ReductionParameter::MEAN;
-const ReductionParameter_ReductionOp ReductionParameter::ReductionOp_MIN;
-const ReductionParameter_ReductionOp ReductionParameter::ReductionOp_MAX;
-const int ReductionParameter::ReductionOp_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int ReductionParameter::kOperationFieldNumber;
-const int ReductionParameter::kAxisFieldNumber;
-const int ReductionParameter::kCoeffFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-ReductionParameter::ReductionParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.ReductionParameter)
-}
-
-void ReductionParameter::InitAsDefaultInstance() {
-}
-
-ReductionParameter::ReductionParameter(const ReductionParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.ReductionParameter)
-}
-
-void ReductionParameter::SharedCtor() {
- _cached_size_ = 0;
- axis_ = 0;
- operation_ = 1;
- coeff_ = 1;
-}
-
-ReductionParameter::~ReductionParameter() {
- // @@protoc_insertion_point(destructor:caffe.ReductionParameter)
- SharedDtor();
-}
-
-void ReductionParameter::SharedDtor() {
-}
-
-void ReductionParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* ReductionParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return ReductionParameter_descriptor_;
-}
-
-const ReductionParameter& ReductionParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<ReductionParameter> ReductionParameter_default_instance_;
-
-ReductionParameter* ReductionParameter::New(::google::protobuf::Arena* arena) const {
- ReductionParameter* n = new ReductionParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void ReductionParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.ReductionParameter)
- if (_has_bits_[0 / 32] & 7u) {
- operation_ = 1;
- axis_ = 0;
- coeff_ = 1;
- }
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool ReductionParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.ReductionParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional .caffe.ReductionParameter.ReductionOp operation = 1 [default = SUM];
- case 1: {
- if (tag == 8) {
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::ReductionParameter_ReductionOp_IsValid(value)) {
- set_operation(static_cast< ::caffe::ReductionParameter_ReductionOp >(value));
- } else {
- mutable_unknown_fields()->AddVarint(1, value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_axis;
- break;
- }
-
- // optional int32 axis = 2 [default = 0];
- case 2: {
- if (tag == 16) {
- parse_axis:
- set_has_axis();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &axis_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(29)) goto parse_coeff;
- break;
- }
-
- // optional float coeff = 3 [default = 1];
- case 3: {
- if (tag == 29) {
- parse_coeff:
- set_has_coeff();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &coeff_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.ReductionParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.ReductionParameter)
- return false;
-#undef DO_
-}
-
-void ReductionParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.ReductionParameter)
- // optional .caffe.ReductionParameter.ReductionOp operation = 1 [default = SUM];
- if (has_operation()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 1, this->operation(), output);
- }
-
- // optional int32 axis = 2 [default = 0];
- if (has_axis()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->axis(), output);
- }
-
- // optional float coeff = 3 [default = 1];
- if (has_coeff()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->coeff(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.ReductionParameter)
-}
-
-::google::protobuf::uint8* ReductionParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.ReductionParameter)
- // optional .caffe.ReductionParameter.ReductionOp operation = 1 [default = SUM];
- if (has_operation()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 1, this->operation(), target);
- }
-
- // optional int32 axis = 2 [default = 0];
- if (has_axis()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->axis(), target);
- }
-
- // optional float coeff = 3 [default = 1];
- if (has_coeff()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->coeff(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.ReductionParameter)
- return target;
-}
-
-size_t ReductionParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.ReductionParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 7u) {
- // optional .caffe.ReductionParameter.ReductionOp operation = 1 [default = SUM];
- if (has_operation()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->operation());
- }
-
- // optional int32 axis = 2 [default = 0];
- if (has_axis()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->axis());
- }
-
- // optional float coeff = 3 [default = 1];
- if (has_coeff()) {
- total_size += 1 + 4;
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void ReductionParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.ReductionParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const ReductionParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const ReductionParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ReductionParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ReductionParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void ReductionParameter::MergeFrom(const ReductionParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ReductionParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void ReductionParameter::UnsafeMergeFrom(const ReductionParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_operation()) {
- set_operation(from.operation());
- }
- if (from.has_axis()) {
- set_axis(from.axis());
- }
- if (from.has_coeff()) {
- set_coeff(from.coeff());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void ReductionParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.ReductionParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void ReductionParameter::CopyFrom(const ReductionParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ReductionParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool ReductionParameter::IsInitialized() const {
-
- return true;
-}
-
-void ReductionParameter::Swap(ReductionParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void ReductionParameter::InternalSwap(ReductionParameter* other) {
- std::swap(operation_, other->operation_);
- std::swap(axis_, other->axis_);
- std::swap(coeff_, other->coeff_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata ReductionParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = ReductionParameter_descriptor_;
- metadata.reflection = ReductionParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// ReductionParameter
-
-// optional .caffe.ReductionParameter.ReductionOp operation = 1 [default = SUM];
-bool ReductionParameter::has_operation() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void ReductionParameter::set_has_operation() {
- _has_bits_[0] |= 0x00000001u;
-}
-void ReductionParameter::clear_has_operation() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void ReductionParameter::clear_operation() {
- operation_ = 1;
- clear_has_operation();
-}
-::caffe::ReductionParameter_ReductionOp ReductionParameter::operation() const {
- // @@protoc_insertion_point(field_get:caffe.ReductionParameter.operation)
- return static_cast< ::caffe::ReductionParameter_ReductionOp >(operation_);
-}
-void ReductionParameter::set_operation(::caffe::ReductionParameter_ReductionOp value) {
- assert(::caffe::ReductionParameter_ReductionOp_IsValid(value));
- set_has_operation();
- operation_ = value;
- // @@protoc_insertion_point(field_set:caffe.ReductionParameter.operation)
-}
-
-// optional int32 axis = 2 [default = 0];
-bool ReductionParameter::has_axis() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void ReductionParameter::set_has_axis() {
- _has_bits_[0] |= 0x00000002u;
-}
-void ReductionParameter::clear_has_axis() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void ReductionParameter::clear_axis() {
- axis_ = 0;
- clear_has_axis();
-}
-::google::protobuf::int32 ReductionParameter::axis() const {
- // @@protoc_insertion_point(field_get:caffe.ReductionParameter.axis)
- return axis_;
-}
-void ReductionParameter::set_axis(::google::protobuf::int32 value) {
- set_has_axis();
- axis_ = value;
- // @@protoc_insertion_point(field_set:caffe.ReductionParameter.axis)
-}
-
-// optional float coeff = 3 [default = 1];
-bool ReductionParameter::has_coeff() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void ReductionParameter::set_has_coeff() {
- _has_bits_[0] |= 0x00000004u;
-}
-void ReductionParameter::clear_has_coeff() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void ReductionParameter::clear_coeff() {
- coeff_ = 1;
- clear_has_coeff();
-}
-float ReductionParameter::coeff() const {
- // @@protoc_insertion_point(field_get:caffe.ReductionParameter.coeff)
- return coeff_;
-}
-void ReductionParameter::set_coeff(float value) {
- set_has_coeff();
- coeff_ = value;
- // @@protoc_insertion_point(field_set:caffe.ReductionParameter.coeff)
-}
-
-inline const ReductionParameter* ReductionParameter::internal_default_instance() {
- return &ReductionParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-const ::google::protobuf::EnumDescriptor* ReLUParameter_Engine_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return ReLUParameter_Engine_descriptor_;
-}
-bool ReLUParameter_Engine_IsValid(int value) {
- switch (value) {
- case 0:
- case 1:
- case 2:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const ReLUParameter_Engine ReLUParameter::DEFAULT;
-const ReLUParameter_Engine ReLUParameter::CAFFE;
-const ReLUParameter_Engine ReLUParameter::CUDNN;
-const ReLUParameter_Engine ReLUParameter::Engine_MIN;
-const ReLUParameter_Engine ReLUParameter::Engine_MAX;
-const int ReLUParameter::Engine_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int ReLUParameter::kNegativeSlopeFieldNumber;
-const int ReLUParameter::kEngineFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-ReLUParameter::ReLUParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.ReLUParameter)
-}
-
-void ReLUParameter::InitAsDefaultInstance() {
-}
-
-ReLUParameter::ReLUParameter(const ReLUParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.ReLUParameter)
-}
-
-void ReLUParameter::SharedCtor() {
- _cached_size_ = 0;
- ::memset(&negative_slope_, 0, reinterpret_cast<char*>(&engine_) -
- reinterpret_cast<char*>(&negative_slope_) + sizeof(engine_));
-}
-
-ReLUParameter::~ReLUParameter() {
- // @@protoc_insertion_point(destructor:caffe.ReLUParameter)
- SharedDtor();
-}
-
-void ReLUParameter::SharedDtor() {
-}
-
-void ReLUParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* ReLUParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return ReLUParameter_descriptor_;
-}
-
-const ReLUParameter& ReLUParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<ReLUParameter> ReLUParameter_default_instance_;
-
-ReLUParameter* ReLUParameter::New(::google::protobuf::Arena* arena) const {
- ReLUParameter* n = new ReLUParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void ReLUParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.ReLUParameter)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(ReLUParameter, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<ReLUParameter*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- ZR_(negative_slope_, engine_);
-
-#undef ZR_HELPER_
-#undef ZR_
-
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool ReLUParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.ReLUParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional float negative_slope = 1 [default = 0];
- case 1: {
- if (tag == 13) {
- set_has_negative_slope();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &negative_slope_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_engine;
- break;
- }
-
- // optional .caffe.ReLUParameter.Engine engine = 2 [default = DEFAULT];
- case 2: {
- if (tag == 16) {
- parse_engine:
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::ReLUParameter_Engine_IsValid(value)) {
- set_engine(static_cast< ::caffe::ReLUParameter_Engine >(value));
- } else {
- mutable_unknown_fields()->AddVarint(2, value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.ReLUParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.ReLUParameter)
- return false;
-#undef DO_
-}
-
-void ReLUParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.ReLUParameter)
- // optional float negative_slope = 1 [default = 0];
- if (has_negative_slope()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->negative_slope(), output);
- }
-
- // optional .caffe.ReLUParameter.Engine engine = 2 [default = DEFAULT];
- if (has_engine()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 2, this->engine(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.ReLUParameter)
-}
-
-::google::protobuf::uint8* ReLUParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.ReLUParameter)
- // optional float negative_slope = 1 [default = 0];
- if (has_negative_slope()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->negative_slope(), target);
- }
-
- // optional .caffe.ReLUParameter.Engine engine = 2 [default = DEFAULT];
- if (has_engine()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 2, this->engine(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.ReLUParameter)
- return target;
-}
-
-size_t ReLUParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.ReLUParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 3u) {
- // optional float negative_slope = 1 [default = 0];
- if (has_negative_slope()) {
- total_size += 1 + 4;
- }
-
- // optional .caffe.ReLUParameter.Engine engine = 2 [default = DEFAULT];
- if (has_engine()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->engine());
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void ReLUParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.ReLUParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const ReLUParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const ReLUParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ReLUParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ReLUParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void ReLUParameter::MergeFrom(const ReLUParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ReLUParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void ReLUParameter::UnsafeMergeFrom(const ReLUParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_negative_slope()) {
- set_negative_slope(from.negative_slope());
- }
- if (from.has_engine()) {
- set_engine(from.engine());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void ReLUParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.ReLUParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void ReLUParameter::CopyFrom(const ReLUParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ReLUParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool ReLUParameter::IsInitialized() const {
-
- return true;
-}
-
-void ReLUParameter::Swap(ReLUParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void ReLUParameter::InternalSwap(ReLUParameter* other) {
- std::swap(negative_slope_, other->negative_slope_);
- std::swap(engine_, other->engine_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata ReLUParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = ReLUParameter_descriptor_;
- metadata.reflection = ReLUParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// ReLUParameter
-
-// optional float negative_slope = 1 [default = 0];
-bool ReLUParameter::has_negative_slope() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void ReLUParameter::set_has_negative_slope() {
- _has_bits_[0] |= 0x00000001u;
-}
-void ReLUParameter::clear_has_negative_slope() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void ReLUParameter::clear_negative_slope() {
- negative_slope_ = 0;
- clear_has_negative_slope();
-}
-float ReLUParameter::negative_slope() const {
- // @@protoc_insertion_point(field_get:caffe.ReLUParameter.negative_slope)
- return negative_slope_;
-}
-void ReLUParameter::set_negative_slope(float value) {
- set_has_negative_slope();
- negative_slope_ = value;
- // @@protoc_insertion_point(field_set:caffe.ReLUParameter.negative_slope)
-}
-
-// optional .caffe.ReLUParameter.Engine engine = 2 [default = DEFAULT];
-bool ReLUParameter::has_engine() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void ReLUParameter::set_has_engine() {
- _has_bits_[0] |= 0x00000002u;
-}
-void ReLUParameter::clear_has_engine() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void ReLUParameter::clear_engine() {
- engine_ = 0;
- clear_has_engine();
-}
-::caffe::ReLUParameter_Engine ReLUParameter::engine() const {
- // @@protoc_insertion_point(field_get:caffe.ReLUParameter.engine)
- return static_cast< ::caffe::ReLUParameter_Engine >(engine_);
-}
-void ReLUParameter::set_engine(::caffe::ReLUParameter_Engine value) {
- assert(::caffe::ReLUParameter_Engine_IsValid(value));
- set_has_engine();
- engine_ = value;
- // @@protoc_insertion_point(field_set:caffe.ReLUParameter.engine)
-}
-
-inline const ReLUParameter* ReLUParameter::internal_default_instance() {
- return &ReLUParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int ReshapeParameter::kShapeFieldNumber;
-const int ReshapeParameter::kAxisFieldNumber;
-const int ReshapeParameter::kNumAxesFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-ReshapeParameter::ReshapeParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.ReshapeParameter)
-}
-
-void ReshapeParameter::InitAsDefaultInstance() {
- shape_ = const_cast< ::caffe::BlobShape*>(
- ::caffe::BlobShape::internal_default_instance());
-}
-
-ReshapeParameter::ReshapeParameter(const ReshapeParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.ReshapeParameter)
-}
-
-void ReshapeParameter::SharedCtor() {
- _cached_size_ = 0;
- shape_ = NULL;
- axis_ = 0;
- num_axes_ = -1;
-}
-
-ReshapeParameter::~ReshapeParameter() {
- // @@protoc_insertion_point(destructor:caffe.ReshapeParameter)
- SharedDtor();
-}
-
-void ReshapeParameter::SharedDtor() {
- if (this != &ReshapeParameter_default_instance_.get()) {
- delete shape_;
- }
-}
-
-void ReshapeParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* ReshapeParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return ReshapeParameter_descriptor_;
-}
-
-const ReshapeParameter& ReshapeParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<ReshapeParameter> ReshapeParameter_default_instance_;
-
-ReshapeParameter* ReshapeParameter::New(::google::protobuf::Arena* arena) const {
- ReshapeParameter* n = new ReshapeParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void ReshapeParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.ReshapeParameter)
- if (_has_bits_[0 / 32] & 7u) {
- if (has_shape()) {
- if (shape_ != NULL) shape_->::caffe::BlobShape::Clear();
- }
- axis_ = 0;
- num_axes_ = -1;
- }
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool ReshapeParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.ReshapeParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional .caffe.BlobShape shape = 1;
- case 1: {
- if (tag == 10) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_shape()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_axis;
- break;
- }
-
- // optional int32 axis = 2 [default = 0];
- case 2: {
- if (tag == 16) {
- parse_axis:
- set_has_axis();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &axis_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(24)) goto parse_num_axes;
- break;
- }
-
- // optional int32 num_axes = 3 [default = -1];
- case 3: {
- if (tag == 24) {
- parse_num_axes:
- set_has_num_axes();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &num_axes_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.ReshapeParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.ReshapeParameter)
- return false;
-#undef DO_
-}
-
-void ReshapeParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.ReshapeParameter)
- // optional .caffe.BlobShape shape = 1;
- if (has_shape()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 1, *this->shape_, output);
- }
-
- // optional int32 axis = 2 [default = 0];
- if (has_axis()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->axis(), output);
- }
-
- // optional int32 num_axes = 3 [default = -1];
- if (has_num_axes()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->num_axes(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.ReshapeParameter)
-}
-
-::google::protobuf::uint8* ReshapeParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.ReshapeParameter)
- // optional .caffe.BlobShape shape = 1;
- if (has_shape()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 1, *this->shape_, false, target);
- }
-
- // optional int32 axis = 2 [default = 0];
- if (has_axis()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->axis(), target);
- }
-
- // optional int32 num_axes = 3 [default = -1];
- if (has_num_axes()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->num_axes(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.ReshapeParameter)
- return target;
-}
-
-size_t ReshapeParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.ReshapeParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 7u) {
- // optional .caffe.BlobShape shape = 1;
- if (has_shape()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->shape_);
- }
-
- // optional int32 axis = 2 [default = 0];
- if (has_axis()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->axis());
- }
-
- // optional int32 num_axes = 3 [default = -1];
- if (has_num_axes()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->num_axes());
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void ReshapeParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.ReshapeParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const ReshapeParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const ReshapeParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ReshapeParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ReshapeParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void ReshapeParameter::MergeFrom(const ReshapeParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ReshapeParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void ReshapeParameter::UnsafeMergeFrom(const ReshapeParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_shape()) {
- mutable_shape()->::caffe::BlobShape::MergeFrom(from.shape());
- }
- if (from.has_axis()) {
- set_axis(from.axis());
- }
- if (from.has_num_axes()) {
- set_num_axes(from.num_axes());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void ReshapeParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.ReshapeParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void ReshapeParameter::CopyFrom(const ReshapeParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ReshapeParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool ReshapeParameter::IsInitialized() const {
-
- return true;
-}
-
-void ReshapeParameter::Swap(ReshapeParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void ReshapeParameter::InternalSwap(ReshapeParameter* other) {
- std::swap(shape_, other->shape_);
- std::swap(axis_, other->axis_);
- std::swap(num_axes_, other->num_axes_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata ReshapeParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = ReshapeParameter_descriptor_;
- metadata.reflection = ReshapeParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// ReshapeParameter
-
-// optional .caffe.BlobShape shape = 1;
-bool ReshapeParameter::has_shape() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void ReshapeParameter::set_has_shape() {
- _has_bits_[0] |= 0x00000001u;
-}
-void ReshapeParameter::clear_has_shape() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void ReshapeParameter::clear_shape() {
- if (shape_ != NULL) shape_->::caffe::BlobShape::Clear();
- clear_has_shape();
-}
-const ::caffe::BlobShape& ReshapeParameter::shape() const {
- // @@protoc_insertion_point(field_get:caffe.ReshapeParameter.shape)
- return shape_ != NULL ? *shape_
- : *::caffe::BlobShape::internal_default_instance();
-}
-::caffe::BlobShape* ReshapeParameter::mutable_shape() {
- set_has_shape();
- if (shape_ == NULL) {
- shape_ = new ::caffe::BlobShape;
- }
- // @@protoc_insertion_point(field_mutable:caffe.ReshapeParameter.shape)
- return shape_;
-}
-::caffe::BlobShape* ReshapeParameter::release_shape() {
- // @@protoc_insertion_point(field_release:caffe.ReshapeParameter.shape)
- clear_has_shape();
- ::caffe::BlobShape* temp = shape_;
- shape_ = NULL;
- return temp;
-}
-void ReshapeParameter::set_allocated_shape(::caffe::BlobShape* shape) {
- delete shape_;
- shape_ = shape;
- if (shape) {
- set_has_shape();
- } else {
- clear_has_shape();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.ReshapeParameter.shape)
-}
-
-// optional int32 axis = 2 [default = 0];
-bool ReshapeParameter::has_axis() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void ReshapeParameter::set_has_axis() {
- _has_bits_[0] |= 0x00000002u;
-}
-void ReshapeParameter::clear_has_axis() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void ReshapeParameter::clear_axis() {
- axis_ = 0;
- clear_has_axis();
-}
-::google::protobuf::int32 ReshapeParameter::axis() const {
- // @@protoc_insertion_point(field_get:caffe.ReshapeParameter.axis)
- return axis_;
-}
-void ReshapeParameter::set_axis(::google::protobuf::int32 value) {
- set_has_axis();
- axis_ = value;
- // @@protoc_insertion_point(field_set:caffe.ReshapeParameter.axis)
-}
-
-// optional int32 num_axes = 3 [default = -1];
-bool ReshapeParameter::has_num_axes() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void ReshapeParameter::set_has_num_axes() {
- _has_bits_[0] |= 0x00000004u;
-}
-void ReshapeParameter::clear_has_num_axes() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void ReshapeParameter::clear_num_axes() {
- num_axes_ = -1;
- clear_has_num_axes();
-}
-::google::protobuf::int32 ReshapeParameter::num_axes() const {
- // @@protoc_insertion_point(field_get:caffe.ReshapeParameter.num_axes)
- return num_axes_;
-}
-void ReshapeParameter::set_num_axes(::google::protobuf::int32 value) {
- set_has_num_axes();
- num_axes_ = value;
- // @@protoc_insertion_point(field_set:caffe.ReshapeParameter.num_axes)
-}
-
-inline const ReshapeParameter* ReshapeParameter::internal_default_instance() {
- return &ReshapeParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-const ::google::protobuf::EnumDescriptor* SigmoidParameter_Engine_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return SigmoidParameter_Engine_descriptor_;
-}
-bool SigmoidParameter_Engine_IsValid(int value) {
- switch (value) {
- case 0:
- case 1:
- case 2:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const SigmoidParameter_Engine SigmoidParameter::DEFAULT;
-const SigmoidParameter_Engine SigmoidParameter::CAFFE;
-const SigmoidParameter_Engine SigmoidParameter::CUDNN;
-const SigmoidParameter_Engine SigmoidParameter::Engine_MIN;
-const SigmoidParameter_Engine SigmoidParameter::Engine_MAX;
-const int SigmoidParameter::Engine_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int SigmoidParameter::kEngineFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-SigmoidParameter::SigmoidParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.SigmoidParameter)
-}
-
-void SigmoidParameter::InitAsDefaultInstance() {
-}
-
-SigmoidParameter::SigmoidParameter(const SigmoidParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.SigmoidParameter)
-}
-
-void SigmoidParameter::SharedCtor() {
- _cached_size_ = 0;
- engine_ = 0;
-}
-
-SigmoidParameter::~SigmoidParameter() {
- // @@protoc_insertion_point(destructor:caffe.SigmoidParameter)
- SharedDtor();
-}
-
-void SigmoidParameter::SharedDtor() {
-}
-
-void SigmoidParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* SigmoidParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return SigmoidParameter_descriptor_;
-}
-
-const SigmoidParameter& SigmoidParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<SigmoidParameter> SigmoidParameter_default_instance_;
-
-SigmoidParameter* SigmoidParameter::New(::google::protobuf::Arena* arena) const {
- SigmoidParameter* n = new SigmoidParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void SigmoidParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.SigmoidParameter)
- engine_ = 0;
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool SigmoidParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.SigmoidParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional .caffe.SigmoidParameter.Engine engine = 1 [default = DEFAULT];
- case 1: {
- if (tag == 8) {
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::SigmoidParameter_Engine_IsValid(value)) {
- set_engine(static_cast< ::caffe::SigmoidParameter_Engine >(value));
- } else {
- mutable_unknown_fields()->AddVarint(1, value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.SigmoidParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.SigmoidParameter)
- return false;
-#undef DO_
-}
-
-void SigmoidParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.SigmoidParameter)
- // optional .caffe.SigmoidParameter.Engine engine = 1 [default = DEFAULT];
- if (has_engine()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 1, this->engine(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.SigmoidParameter)
-}
-
-::google::protobuf::uint8* SigmoidParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.SigmoidParameter)
- // optional .caffe.SigmoidParameter.Engine engine = 1 [default = DEFAULT];
- if (has_engine()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 1, this->engine(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.SigmoidParameter)
- return target;
-}
-
-size_t SigmoidParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.SigmoidParameter)
- size_t total_size = 0;
-
- // optional .caffe.SigmoidParameter.Engine engine = 1 [default = DEFAULT];
- if (has_engine()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->engine());
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void SigmoidParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.SigmoidParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const SigmoidParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const SigmoidParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.SigmoidParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.SigmoidParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void SigmoidParameter::MergeFrom(const SigmoidParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.SigmoidParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void SigmoidParameter::UnsafeMergeFrom(const SigmoidParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_engine()) {
- set_engine(from.engine());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void SigmoidParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.SigmoidParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void SigmoidParameter::CopyFrom(const SigmoidParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.SigmoidParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool SigmoidParameter::IsInitialized() const {
-
- return true;
-}
-
-void SigmoidParameter::Swap(SigmoidParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void SigmoidParameter::InternalSwap(SigmoidParameter* other) {
- std::swap(engine_, other->engine_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata SigmoidParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = SigmoidParameter_descriptor_;
- metadata.reflection = SigmoidParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// SigmoidParameter
-
-// optional .caffe.SigmoidParameter.Engine engine = 1 [default = DEFAULT];
-bool SigmoidParameter::has_engine() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void SigmoidParameter::set_has_engine() {
- _has_bits_[0] |= 0x00000001u;
-}
-void SigmoidParameter::clear_has_engine() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void SigmoidParameter::clear_engine() {
- engine_ = 0;
- clear_has_engine();
-}
-::caffe::SigmoidParameter_Engine SigmoidParameter::engine() const {
- // @@protoc_insertion_point(field_get:caffe.SigmoidParameter.engine)
- return static_cast< ::caffe::SigmoidParameter_Engine >(engine_);
-}
-void SigmoidParameter::set_engine(::caffe::SigmoidParameter_Engine value) {
- assert(::caffe::SigmoidParameter_Engine_IsValid(value));
- set_has_engine();
- engine_ = value;
- // @@protoc_insertion_point(field_set:caffe.SigmoidParameter.engine)
-}
-
-inline const SigmoidParameter* SigmoidParameter::internal_default_instance() {
- return &SigmoidParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int SliceParameter::kAxisFieldNumber;
-const int SliceParameter::kSlicePointFieldNumber;
-const int SliceParameter::kSliceDimFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-SliceParameter::SliceParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.SliceParameter)
-}
-
-void SliceParameter::InitAsDefaultInstance() {
-}
-
-SliceParameter::SliceParameter(const SliceParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.SliceParameter)
-}
-
-void SliceParameter::SharedCtor() {
- _cached_size_ = 0;
- axis_ = 1;
- slice_dim_ = 1u;
-}
-
-SliceParameter::~SliceParameter() {
- // @@protoc_insertion_point(destructor:caffe.SliceParameter)
- SharedDtor();
-}
-
-void SliceParameter::SharedDtor() {
-}
-
-void SliceParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* SliceParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return SliceParameter_descriptor_;
-}
-
-const SliceParameter& SliceParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<SliceParameter> SliceParameter_default_instance_;
-
-SliceParameter* SliceParameter::New(::google::protobuf::Arena* arena) const {
- SliceParameter* n = new SliceParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void SliceParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.SliceParameter)
- if (_has_bits_[0 / 32] & 5u) {
- axis_ = 1;
- slice_dim_ = 1u;
- }
- slice_point_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool SliceParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.SliceParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional uint32 slice_dim = 1 [default = 1];
- case 1: {
- if (tag == 8) {
- set_has_slice_dim();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &slice_dim_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_slice_point;
- break;
- }
-
- // repeated uint32 slice_point = 2;
- case 2: {
- if (tag == 16) {
- parse_slice_point:
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- 1, 16, input, this->mutable_slice_point())));
- } else if (tag == 18) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, this->mutable_slice_point())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_slice_point;
- if (input->ExpectTag(24)) goto parse_axis;
- break;
- }
-
- // optional int32 axis = 3 [default = 1];
- case 3: {
- if (tag == 24) {
- parse_axis:
- set_has_axis();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &axis_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.SliceParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.SliceParameter)
- return false;
-#undef DO_
-}
-
-void SliceParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.SliceParameter)
- // optional uint32 slice_dim = 1 [default = 1];
- if (has_slice_dim()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->slice_dim(), output);
- }
-
- // repeated uint32 slice_point = 2;
- for (int i = 0; i < this->slice_point_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(
- 2, this->slice_point(i), output);
- }
-
- // optional int32 axis = 3 [default = 1];
- if (has_axis()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->axis(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.SliceParameter)
-}
-
-::google::protobuf::uint8* SliceParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.SliceParameter)
- // optional uint32 slice_dim = 1 [default = 1];
- if (has_slice_dim()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->slice_dim(), target);
- }
-
- // repeated uint32 slice_point = 2;
- for (int i = 0; i < this->slice_point_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteUInt32ToArray(2, this->slice_point(i), target);
- }
-
- // optional int32 axis = 3 [default = 1];
- if (has_axis()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->axis(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.SliceParameter)
- return target;
-}
-
-size_t SliceParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.SliceParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 5u) {
- // optional int32 axis = 3 [default = 1];
- if (has_axis()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->axis());
- }
-
- // optional uint32 slice_dim = 1 [default = 1];
- if (has_slice_dim()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->slice_dim());
- }
-
- }
- // repeated uint32 slice_point = 2;
- {
- size_t data_size = 0;
- unsigned int count = this->slice_point_size();
- for (unsigned int i = 0; i < count; i++) {
- data_size += ::google::protobuf::internal::WireFormatLite::
- UInt32Size(this->slice_point(i));
- }
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->slice_point_size());
- total_size += data_size;
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void SliceParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.SliceParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const SliceParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const SliceParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.SliceParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.SliceParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void SliceParameter::MergeFrom(const SliceParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.SliceParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void SliceParameter::UnsafeMergeFrom(const SliceParameter& from) {
- GOOGLE_DCHECK(&from != this);
- slice_point_.UnsafeMergeFrom(from.slice_point_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_axis()) {
- set_axis(from.axis());
- }
- if (from.has_slice_dim()) {
- set_slice_dim(from.slice_dim());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void SliceParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.SliceParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void SliceParameter::CopyFrom(const SliceParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.SliceParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool SliceParameter::IsInitialized() const {
-
- return true;
-}
-
-void SliceParameter::Swap(SliceParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void SliceParameter::InternalSwap(SliceParameter* other) {
- std::swap(axis_, other->axis_);
- slice_point_.UnsafeArenaSwap(&other->slice_point_);
- std::swap(slice_dim_, other->slice_dim_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata SliceParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = SliceParameter_descriptor_;
- metadata.reflection = SliceParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// SliceParameter
-
-// optional int32 axis = 3 [default = 1];
-bool SliceParameter::has_axis() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void SliceParameter::set_has_axis() {
- _has_bits_[0] |= 0x00000001u;
-}
-void SliceParameter::clear_has_axis() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void SliceParameter::clear_axis() {
- axis_ = 1;
- clear_has_axis();
-}
-::google::protobuf::int32 SliceParameter::axis() const {
- // @@protoc_insertion_point(field_get:caffe.SliceParameter.axis)
- return axis_;
-}
-void SliceParameter::set_axis(::google::protobuf::int32 value) {
- set_has_axis();
- axis_ = value;
- // @@protoc_insertion_point(field_set:caffe.SliceParameter.axis)
-}
-
-// repeated uint32 slice_point = 2;
-int SliceParameter::slice_point_size() const {
- return slice_point_.size();
-}
-void SliceParameter::clear_slice_point() {
- slice_point_.Clear();
-}
-::google::protobuf::uint32 SliceParameter::slice_point(int index) const {
- // @@protoc_insertion_point(field_get:caffe.SliceParameter.slice_point)
- return slice_point_.Get(index);
-}
-void SliceParameter::set_slice_point(int index, ::google::protobuf::uint32 value) {
- slice_point_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.SliceParameter.slice_point)
-}
-void SliceParameter::add_slice_point(::google::protobuf::uint32 value) {
- slice_point_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.SliceParameter.slice_point)
-}
-const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-SliceParameter::slice_point() const {
- // @@protoc_insertion_point(field_list:caffe.SliceParameter.slice_point)
- return slice_point_;
-}
-::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-SliceParameter::mutable_slice_point() {
- // @@protoc_insertion_point(field_mutable_list:caffe.SliceParameter.slice_point)
- return &slice_point_;
-}
-
-// optional uint32 slice_dim = 1 [default = 1];
-bool SliceParameter::has_slice_dim() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void SliceParameter::set_has_slice_dim() {
- _has_bits_[0] |= 0x00000004u;
-}
-void SliceParameter::clear_has_slice_dim() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void SliceParameter::clear_slice_dim() {
- slice_dim_ = 1u;
- clear_has_slice_dim();
-}
-::google::protobuf::uint32 SliceParameter::slice_dim() const {
- // @@protoc_insertion_point(field_get:caffe.SliceParameter.slice_dim)
- return slice_dim_;
-}
-void SliceParameter::set_slice_dim(::google::protobuf::uint32 value) {
- set_has_slice_dim();
- slice_dim_ = value;
- // @@protoc_insertion_point(field_set:caffe.SliceParameter.slice_dim)
-}
-
-inline const SliceParameter* SliceParameter::internal_default_instance() {
- return &SliceParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-const ::google::protobuf::EnumDescriptor* SoftmaxParameter_Engine_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return SoftmaxParameter_Engine_descriptor_;
-}
-bool SoftmaxParameter_Engine_IsValid(int value) {
- switch (value) {
- case 0:
- case 1:
- case 2:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const SoftmaxParameter_Engine SoftmaxParameter::DEFAULT;
-const SoftmaxParameter_Engine SoftmaxParameter::CAFFE;
-const SoftmaxParameter_Engine SoftmaxParameter::CUDNN;
-const SoftmaxParameter_Engine SoftmaxParameter::Engine_MIN;
-const SoftmaxParameter_Engine SoftmaxParameter::Engine_MAX;
-const int SoftmaxParameter::Engine_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int SoftmaxParameter::kEngineFieldNumber;
-const int SoftmaxParameter::kAxisFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-SoftmaxParameter::SoftmaxParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.SoftmaxParameter)
-}
-
-void SoftmaxParameter::InitAsDefaultInstance() {
-}
-
-SoftmaxParameter::SoftmaxParameter(const SoftmaxParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.SoftmaxParameter)
-}
-
-void SoftmaxParameter::SharedCtor() {
- _cached_size_ = 0;
- engine_ = 0;
- axis_ = 1;
-}
-
-SoftmaxParameter::~SoftmaxParameter() {
- // @@protoc_insertion_point(destructor:caffe.SoftmaxParameter)
- SharedDtor();
-}
-
-void SoftmaxParameter::SharedDtor() {
-}
-
-void SoftmaxParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* SoftmaxParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return SoftmaxParameter_descriptor_;
-}
-
-const SoftmaxParameter& SoftmaxParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<SoftmaxParameter> SoftmaxParameter_default_instance_;
-
-SoftmaxParameter* SoftmaxParameter::New(::google::protobuf::Arena* arena) const {
- SoftmaxParameter* n = new SoftmaxParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void SoftmaxParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.SoftmaxParameter)
- if (_has_bits_[0 / 32] & 3u) {
- engine_ = 0;
- axis_ = 1;
- }
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool SoftmaxParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.SoftmaxParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional .caffe.SoftmaxParameter.Engine engine = 1 [default = DEFAULT];
- case 1: {
- if (tag == 8) {
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::SoftmaxParameter_Engine_IsValid(value)) {
- set_engine(static_cast< ::caffe::SoftmaxParameter_Engine >(value));
- } else {
- mutable_unknown_fields()->AddVarint(1, value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_axis;
- break;
- }
-
- // optional int32 axis = 2 [default = 1];
- case 2: {
- if (tag == 16) {
- parse_axis:
- set_has_axis();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &axis_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.SoftmaxParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.SoftmaxParameter)
- return false;
-#undef DO_
-}
-
-void SoftmaxParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.SoftmaxParameter)
- // optional .caffe.SoftmaxParameter.Engine engine = 1 [default = DEFAULT];
- if (has_engine()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 1, this->engine(), output);
- }
-
- // optional int32 axis = 2 [default = 1];
- if (has_axis()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->axis(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.SoftmaxParameter)
-}
-
-::google::protobuf::uint8* SoftmaxParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.SoftmaxParameter)
- // optional .caffe.SoftmaxParameter.Engine engine = 1 [default = DEFAULT];
- if (has_engine()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 1, this->engine(), target);
- }
-
- // optional int32 axis = 2 [default = 1];
- if (has_axis()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->axis(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.SoftmaxParameter)
- return target;
-}
-
-size_t SoftmaxParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.SoftmaxParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 3u) {
- // optional .caffe.SoftmaxParameter.Engine engine = 1 [default = DEFAULT];
- if (has_engine()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->engine());
- }
-
- // optional int32 axis = 2 [default = 1];
- if (has_axis()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->axis());
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void SoftmaxParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.SoftmaxParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const SoftmaxParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const SoftmaxParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.SoftmaxParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.SoftmaxParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void SoftmaxParameter::MergeFrom(const SoftmaxParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.SoftmaxParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void SoftmaxParameter::UnsafeMergeFrom(const SoftmaxParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_engine()) {
- set_engine(from.engine());
- }
- if (from.has_axis()) {
- set_axis(from.axis());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void SoftmaxParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.SoftmaxParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void SoftmaxParameter::CopyFrom(const SoftmaxParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.SoftmaxParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool SoftmaxParameter::IsInitialized() const {
-
- return true;
-}
-
-void SoftmaxParameter::Swap(SoftmaxParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void SoftmaxParameter::InternalSwap(SoftmaxParameter* other) {
- std::swap(engine_, other->engine_);
- std::swap(axis_, other->axis_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata SoftmaxParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = SoftmaxParameter_descriptor_;
- metadata.reflection = SoftmaxParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// SoftmaxParameter
-
-// optional .caffe.SoftmaxParameter.Engine engine = 1 [default = DEFAULT];
-bool SoftmaxParameter::has_engine() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void SoftmaxParameter::set_has_engine() {
- _has_bits_[0] |= 0x00000001u;
-}
-void SoftmaxParameter::clear_has_engine() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void SoftmaxParameter::clear_engine() {
- engine_ = 0;
- clear_has_engine();
-}
-::caffe::SoftmaxParameter_Engine SoftmaxParameter::engine() const {
- // @@protoc_insertion_point(field_get:caffe.SoftmaxParameter.engine)
- return static_cast< ::caffe::SoftmaxParameter_Engine >(engine_);
-}
-void SoftmaxParameter::set_engine(::caffe::SoftmaxParameter_Engine value) {
- assert(::caffe::SoftmaxParameter_Engine_IsValid(value));
- set_has_engine();
- engine_ = value;
- // @@protoc_insertion_point(field_set:caffe.SoftmaxParameter.engine)
-}
-
-// optional int32 axis = 2 [default = 1];
-bool SoftmaxParameter::has_axis() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void SoftmaxParameter::set_has_axis() {
- _has_bits_[0] |= 0x00000002u;
-}
-void SoftmaxParameter::clear_has_axis() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void SoftmaxParameter::clear_axis() {
- axis_ = 1;
- clear_has_axis();
-}
-::google::protobuf::int32 SoftmaxParameter::axis() const {
- // @@protoc_insertion_point(field_get:caffe.SoftmaxParameter.axis)
- return axis_;
-}
-void SoftmaxParameter::set_axis(::google::protobuf::int32 value) {
- set_has_axis();
- axis_ = value;
- // @@protoc_insertion_point(field_set:caffe.SoftmaxParameter.axis)
-}
-
-inline const SoftmaxParameter* SoftmaxParameter::internal_default_instance() {
- return &SoftmaxParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-const ::google::protobuf::EnumDescriptor* TanHParameter_Engine_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return TanHParameter_Engine_descriptor_;
-}
-bool TanHParameter_Engine_IsValid(int value) {
- switch (value) {
- case 0:
- case 1:
- case 2:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const TanHParameter_Engine TanHParameter::DEFAULT;
-const TanHParameter_Engine TanHParameter::CAFFE;
-const TanHParameter_Engine TanHParameter::CUDNN;
-const TanHParameter_Engine TanHParameter::Engine_MIN;
-const TanHParameter_Engine TanHParameter::Engine_MAX;
-const int TanHParameter::Engine_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int TanHParameter::kEngineFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-TanHParameter::TanHParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.TanHParameter)
-}
-
-void TanHParameter::InitAsDefaultInstance() {
-}
-
-TanHParameter::TanHParameter(const TanHParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.TanHParameter)
-}
-
-void TanHParameter::SharedCtor() {
- _cached_size_ = 0;
- engine_ = 0;
-}
-
-TanHParameter::~TanHParameter() {
- // @@protoc_insertion_point(destructor:caffe.TanHParameter)
- SharedDtor();
-}
-
-void TanHParameter::SharedDtor() {
-}
-
-void TanHParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* TanHParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return TanHParameter_descriptor_;
-}
-
-const TanHParameter& TanHParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<TanHParameter> TanHParameter_default_instance_;
-
-TanHParameter* TanHParameter::New(::google::protobuf::Arena* arena) const {
- TanHParameter* n = new TanHParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void TanHParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.TanHParameter)
- engine_ = 0;
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool TanHParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.TanHParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional .caffe.TanHParameter.Engine engine = 1 [default = DEFAULT];
- case 1: {
- if (tag == 8) {
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::TanHParameter_Engine_IsValid(value)) {
- set_engine(static_cast< ::caffe::TanHParameter_Engine >(value));
- } else {
- mutable_unknown_fields()->AddVarint(1, value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.TanHParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.TanHParameter)
- return false;
-#undef DO_
-}
-
-void TanHParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.TanHParameter)
- // optional .caffe.TanHParameter.Engine engine = 1 [default = DEFAULT];
- if (has_engine()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 1, this->engine(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.TanHParameter)
-}
-
-::google::protobuf::uint8* TanHParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.TanHParameter)
- // optional .caffe.TanHParameter.Engine engine = 1 [default = DEFAULT];
- if (has_engine()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 1, this->engine(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.TanHParameter)
- return target;
-}
-
-size_t TanHParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.TanHParameter)
- size_t total_size = 0;
-
- // optional .caffe.TanHParameter.Engine engine = 1 [default = DEFAULT];
- if (has_engine()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->engine());
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void TanHParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.TanHParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const TanHParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const TanHParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.TanHParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.TanHParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void TanHParameter::MergeFrom(const TanHParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.TanHParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void TanHParameter::UnsafeMergeFrom(const TanHParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_engine()) {
- set_engine(from.engine());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void TanHParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.TanHParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void TanHParameter::CopyFrom(const TanHParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.TanHParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool TanHParameter::IsInitialized() const {
-
- return true;
-}
-
-void TanHParameter::Swap(TanHParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void TanHParameter::InternalSwap(TanHParameter* other) {
- std::swap(engine_, other->engine_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata TanHParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = TanHParameter_descriptor_;
- metadata.reflection = TanHParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// TanHParameter
-
-// optional .caffe.TanHParameter.Engine engine = 1 [default = DEFAULT];
-bool TanHParameter::has_engine() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void TanHParameter::set_has_engine() {
- _has_bits_[0] |= 0x00000001u;
-}
-void TanHParameter::clear_has_engine() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void TanHParameter::clear_engine() {
- engine_ = 0;
- clear_has_engine();
-}
-::caffe::TanHParameter_Engine TanHParameter::engine() const {
- // @@protoc_insertion_point(field_get:caffe.TanHParameter.engine)
- return static_cast< ::caffe::TanHParameter_Engine >(engine_);
-}
-void TanHParameter::set_engine(::caffe::TanHParameter_Engine value) {
- assert(::caffe::TanHParameter_Engine_IsValid(value));
- set_has_engine();
- engine_ = value;
- // @@protoc_insertion_point(field_set:caffe.TanHParameter.engine)
-}
-
-inline const TanHParameter* TanHParameter::internal_default_instance() {
- return &TanHParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int ThresholdParameter::kThresholdFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-ThresholdParameter::ThresholdParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.ThresholdParameter)
-}
-
-void ThresholdParameter::InitAsDefaultInstance() {
-}
-
-ThresholdParameter::ThresholdParameter(const ThresholdParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.ThresholdParameter)
-}
-
-void ThresholdParameter::SharedCtor() {
- _cached_size_ = 0;
- threshold_ = 0;
-}
-
-ThresholdParameter::~ThresholdParameter() {
- // @@protoc_insertion_point(destructor:caffe.ThresholdParameter)
- SharedDtor();
-}
-
-void ThresholdParameter::SharedDtor() {
-}
-
-void ThresholdParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* ThresholdParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return ThresholdParameter_descriptor_;
-}
-
-const ThresholdParameter& ThresholdParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<ThresholdParameter> ThresholdParameter_default_instance_;
-
-ThresholdParameter* ThresholdParameter::New(::google::protobuf::Arena* arena) const {
- ThresholdParameter* n = new ThresholdParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void ThresholdParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.ThresholdParameter)
- threshold_ = 0;
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool ThresholdParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.ThresholdParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional float threshold = 1 [default = 0];
- case 1: {
- if (tag == 13) {
- set_has_threshold();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &threshold_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.ThresholdParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.ThresholdParameter)
- return false;
-#undef DO_
-}
-
-void ThresholdParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.ThresholdParameter)
- // optional float threshold = 1 [default = 0];
- if (has_threshold()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->threshold(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.ThresholdParameter)
-}
-
-::google::protobuf::uint8* ThresholdParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.ThresholdParameter)
- // optional float threshold = 1 [default = 0];
- if (has_threshold()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->threshold(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.ThresholdParameter)
- return target;
-}
-
-size_t ThresholdParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.ThresholdParameter)
- size_t total_size = 0;
-
- // optional float threshold = 1 [default = 0];
- if (has_threshold()) {
- total_size += 1 + 4;
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void ThresholdParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.ThresholdParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const ThresholdParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const ThresholdParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ThresholdParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ThresholdParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void ThresholdParameter::MergeFrom(const ThresholdParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ThresholdParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void ThresholdParameter::UnsafeMergeFrom(const ThresholdParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_threshold()) {
- set_threshold(from.threshold());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void ThresholdParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.ThresholdParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void ThresholdParameter::CopyFrom(const ThresholdParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ThresholdParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool ThresholdParameter::IsInitialized() const {
-
- return true;
-}
-
-void ThresholdParameter::Swap(ThresholdParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void ThresholdParameter::InternalSwap(ThresholdParameter* other) {
- std::swap(threshold_, other->threshold_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata ThresholdParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = ThresholdParameter_descriptor_;
- metadata.reflection = ThresholdParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// ThresholdParameter
-
-// optional float threshold = 1 [default = 0];
-bool ThresholdParameter::has_threshold() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void ThresholdParameter::set_has_threshold() {
- _has_bits_[0] |= 0x00000001u;
-}
-void ThresholdParameter::clear_has_threshold() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void ThresholdParameter::clear_threshold() {
- threshold_ = 0;
- clear_has_threshold();
-}
-float ThresholdParameter::threshold() const {
- // @@protoc_insertion_point(field_get:caffe.ThresholdParameter.threshold)
- return threshold_;
-}
-void ThresholdParameter::set_threshold(float value) {
- set_has_threshold();
- threshold_ = value;
- // @@protoc_insertion_point(field_set:caffe.ThresholdParameter.threshold)
-}
-
-inline const ThresholdParameter* ThresholdParameter::internal_default_instance() {
- return &ThresholdParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-::std::string* WindowDataParameter::_default_crop_mode_ = NULL;
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int WindowDataParameter::kSourceFieldNumber;
-const int WindowDataParameter::kScaleFieldNumber;
-const int WindowDataParameter::kMeanFileFieldNumber;
-const int WindowDataParameter::kBatchSizeFieldNumber;
-const int WindowDataParameter::kCropSizeFieldNumber;
-const int WindowDataParameter::kMirrorFieldNumber;
-const int WindowDataParameter::kFgThresholdFieldNumber;
-const int WindowDataParameter::kBgThresholdFieldNumber;
-const int WindowDataParameter::kFgFractionFieldNumber;
-const int WindowDataParameter::kContextPadFieldNumber;
-const int WindowDataParameter::kCropModeFieldNumber;
-const int WindowDataParameter::kCacheImagesFieldNumber;
-const int WindowDataParameter::kRootFolderFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-WindowDataParameter::WindowDataParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.WindowDataParameter)
-}
-
-void WindowDataParameter::InitAsDefaultInstance() {
-}
-
-WindowDataParameter::WindowDataParameter(const WindowDataParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.WindowDataParameter)
-}
-
-void WindowDataParameter::SharedCtor() {
- _cached_size_ = 0;
- source_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- mean_file_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- crop_mode_.UnsafeSetDefault(_default_crop_mode_);
- root_folder_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- ::memset(&batch_size_, 0, reinterpret_cast<char*>(&context_pad_) -
- reinterpret_cast<char*>(&batch_size_) + sizeof(context_pad_));
- scale_ = 1;
- fg_threshold_ = 0.5f;
- bg_threshold_ = 0.5f;
- fg_fraction_ = 0.25f;
-}
-
-WindowDataParameter::~WindowDataParameter() {
- // @@protoc_insertion_point(destructor:caffe.WindowDataParameter)
- SharedDtor();
-}
-
-void WindowDataParameter::SharedDtor() {
- source_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- mean_file_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- crop_mode_.DestroyNoArena(_default_crop_mode_);
- root_folder_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-
-void WindowDataParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* WindowDataParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return WindowDataParameter_descriptor_;
-}
-
-const WindowDataParameter& WindowDataParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<WindowDataParameter> WindowDataParameter_default_instance_;
-
-WindowDataParameter* WindowDataParameter::New(::google::protobuf::Arena* arena) const {
- WindowDataParameter* n = new WindowDataParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void WindowDataParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.WindowDataParameter)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(WindowDataParameter, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<WindowDataParameter*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- if (_has_bits_[0 / 32] & 255u) {
- ZR_(batch_size_, mirror_);
- if (has_source()) {
- source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- scale_ = 1;
- if (has_mean_file()) {
- mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- fg_threshold_ = 0.5f;
- bg_threshold_ = 0.5f;
- }
- if (_has_bits_[8 / 32] & 7936u) {
- ZR_(cache_images_, context_pad_);
- fg_fraction_ = 0.25f;
- if (has_crop_mode()) {
- crop_mode_.ClearToDefaultNoArena(_default_crop_mode_);
- }
- if (has_root_folder()) {
- root_folder_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- }
-
-#undef ZR_HELPER_
-#undef ZR_
-
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool WindowDataParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.WindowDataParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional string source = 1;
- case 1: {
- if (tag == 10) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_source()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->source().data(), this->source().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.WindowDataParameter.source");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(21)) goto parse_scale;
- break;
- }
-
- // optional float scale = 2 [default = 1];
- case 2: {
- if (tag == 21) {
- parse_scale:
- set_has_scale();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &scale_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(26)) goto parse_mean_file;
- break;
- }
-
- // optional string mean_file = 3;
- case 3: {
- if (tag == 26) {
- parse_mean_file:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_mean_file()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->mean_file().data(), this->mean_file().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.WindowDataParameter.mean_file");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(32)) goto parse_batch_size;
- break;
- }
-
- // optional uint32 batch_size = 4;
- case 4: {
- if (tag == 32) {
- parse_batch_size:
- set_has_batch_size();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &batch_size_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(40)) goto parse_crop_size;
- break;
- }
-
- // optional uint32 crop_size = 5 [default = 0];
- case 5: {
- if (tag == 40) {
- parse_crop_size:
- set_has_crop_size();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &crop_size_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(48)) goto parse_mirror;
- break;
- }
-
- // optional bool mirror = 6 [default = false];
- case 6: {
- if (tag == 48) {
- parse_mirror:
- set_has_mirror();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &mirror_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(61)) goto parse_fg_threshold;
- break;
- }
-
- // optional float fg_threshold = 7 [default = 0.5];
- case 7: {
- if (tag == 61) {
- parse_fg_threshold:
- set_has_fg_threshold();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &fg_threshold_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(69)) goto parse_bg_threshold;
- break;
- }
-
- // optional float bg_threshold = 8 [default = 0.5];
- case 8: {
- if (tag == 69) {
- parse_bg_threshold:
- set_has_bg_threshold();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &bg_threshold_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(77)) goto parse_fg_fraction;
- break;
- }
-
- // optional float fg_fraction = 9 [default = 0.25];
- case 9: {
- if (tag == 77) {
- parse_fg_fraction:
- set_has_fg_fraction();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &fg_fraction_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(80)) goto parse_context_pad;
- break;
- }
-
- // optional uint32 context_pad = 10 [default = 0];
- case 10: {
- if (tag == 80) {
- parse_context_pad:
- set_has_context_pad();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &context_pad_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(90)) goto parse_crop_mode;
- break;
- }
-
- // optional string crop_mode = 11 [default = "warp"];
- case 11: {
- if (tag == 90) {
- parse_crop_mode:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_crop_mode()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->crop_mode().data(), this->crop_mode().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.WindowDataParameter.crop_mode");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(96)) goto parse_cache_images;
- break;
- }
-
- // optional bool cache_images = 12 [default = false];
- case 12: {
- if (tag == 96) {
- parse_cache_images:
- set_has_cache_images();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &cache_images_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(106)) goto parse_root_folder;
- break;
- }
-
- // optional string root_folder = 13 [default = ""];
- case 13: {
- if (tag == 106) {
- parse_root_folder:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_root_folder()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->root_folder().data(), this->root_folder().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.WindowDataParameter.root_folder");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.WindowDataParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.WindowDataParameter)
- return false;
-#undef DO_
-}
-
-void WindowDataParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.WindowDataParameter)
- // optional string source = 1;
- if (has_source()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->source().data(), this->source().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.WindowDataParameter.source");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 1, this->source(), output);
- }
-
- // optional float scale = 2 [default = 1];
- if (has_scale()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->scale(), output);
- }
-
- // optional string mean_file = 3;
- if (has_mean_file()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->mean_file().data(), this->mean_file().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.WindowDataParameter.mean_file");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 3, this->mean_file(), output);
- }
-
- // optional uint32 batch_size = 4;
- if (has_batch_size()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(4, this->batch_size(), output);
- }
-
- // optional uint32 crop_size = 5 [default = 0];
- if (has_crop_size()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(5, this->crop_size(), output);
- }
-
- // optional bool mirror = 6 [default = false];
- if (has_mirror()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(6, this->mirror(), output);
- }
-
- // optional float fg_threshold = 7 [default = 0.5];
- if (has_fg_threshold()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(7, this->fg_threshold(), output);
- }
-
- // optional float bg_threshold = 8 [default = 0.5];
- if (has_bg_threshold()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(8, this->bg_threshold(), output);
- }
-
- // optional float fg_fraction = 9 [default = 0.25];
- if (has_fg_fraction()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(9, this->fg_fraction(), output);
- }
-
- // optional uint32 context_pad = 10 [default = 0];
- if (has_context_pad()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(10, this->context_pad(), output);
- }
-
- // optional string crop_mode = 11 [default = "warp"];
- if (has_crop_mode()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->crop_mode().data(), this->crop_mode().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.WindowDataParameter.crop_mode");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 11, this->crop_mode(), output);
- }
-
- // optional bool cache_images = 12 [default = false];
- if (has_cache_images()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(12, this->cache_images(), output);
- }
-
- // optional string root_folder = 13 [default = ""];
- if (has_root_folder()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->root_folder().data(), this->root_folder().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.WindowDataParameter.root_folder");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 13, this->root_folder(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.WindowDataParameter)
-}
-
-::google::protobuf::uint8* WindowDataParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.WindowDataParameter)
- // optional string source = 1;
- if (has_source()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->source().data(), this->source().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.WindowDataParameter.source");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 1, this->source(), target);
- }
-
- // optional float scale = 2 [default = 1];
- if (has_scale()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->scale(), target);
- }
-
- // optional string mean_file = 3;
- if (has_mean_file()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->mean_file().data(), this->mean_file().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.WindowDataParameter.mean_file");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 3, this->mean_file(), target);
- }
-
- // optional uint32 batch_size = 4;
- if (has_batch_size()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(4, this->batch_size(), target);
- }
-
- // optional uint32 crop_size = 5 [default = 0];
- if (has_crop_size()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(5, this->crop_size(), target);
- }
-
- // optional bool mirror = 6 [default = false];
- if (has_mirror()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(6, this->mirror(), target);
- }
-
- // optional float fg_threshold = 7 [default = 0.5];
- if (has_fg_threshold()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(7, this->fg_threshold(), target);
- }
-
- // optional float bg_threshold = 8 [default = 0.5];
- if (has_bg_threshold()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(8, this->bg_threshold(), target);
- }
-
- // optional float fg_fraction = 9 [default = 0.25];
- if (has_fg_fraction()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(9, this->fg_fraction(), target);
- }
-
- // optional uint32 context_pad = 10 [default = 0];
- if (has_context_pad()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(10, this->context_pad(), target);
- }
-
- // optional string crop_mode = 11 [default = "warp"];
- if (has_crop_mode()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->crop_mode().data(), this->crop_mode().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.WindowDataParameter.crop_mode");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 11, this->crop_mode(), target);
- }
-
- // optional bool cache_images = 12 [default = false];
- if (has_cache_images()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(12, this->cache_images(), target);
- }
-
- // optional string root_folder = 13 [default = ""];
- if (has_root_folder()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->root_folder().data(), this->root_folder().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.WindowDataParameter.root_folder");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 13, this->root_folder(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.WindowDataParameter)
- return target;
-}
-
-size_t WindowDataParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.WindowDataParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 255u) {
- // optional string source = 1;
- if (has_source()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->source());
- }
-
- // optional float scale = 2 [default = 1];
- if (has_scale()) {
- total_size += 1 + 4;
- }
-
- // optional string mean_file = 3;
- if (has_mean_file()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->mean_file());
- }
-
- // optional uint32 batch_size = 4;
- if (has_batch_size()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->batch_size());
- }
-
- // optional uint32 crop_size = 5 [default = 0];
- if (has_crop_size()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->crop_size());
- }
-
- // optional bool mirror = 6 [default = false];
- if (has_mirror()) {
- total_size += 1 + 1;
- }
-
- // optional float fg_threshold = 7 [default = 0.5];
- if (has_fg_threshold()) {
- total_size += 1 + 4;
- }
-
- // optional float bg_threshold = 8 [default = 0.5];
- if (has_bg_threshold()) {
- total_size += 1 + 4;
- }
-
- }
- if (_has_bits_[8 / 32] & 7936u) {
- // optional float fg_fraction = 9 [default = 0.25];
- if (has_fg_fraction()) {
- total_size += 1 + 4;
- }
-
- // optional uint32 context_pad = 10 [default = 0];
- if (has_context_pad()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->context_pad());
- }
-
- // optional string crop_mode = 11 [default = "warp"];
- if (has_crop_mode()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->crop_mode());
- }
-
- // optional bool cache_images = 12 [default = false];
- if (has_cache_images()) {
- total_size += 1 + 1;
- }
-
- // optional string root_folder = 13 [default = ""];
- if (has_root_folder()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->root_folder());
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void WindowDataParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.WindowDataParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const WindowDataParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const WindowDataParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.WindowDataParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.WindowDataParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void WindowDataParameter::MergeFrom(const WindowDataParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.WindowDataParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void WindowDataParameter::UnsafeMergeFrom(const WindowDataParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_source()) {
- set_has_source();
- source_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_);
- }
- if (from.has_scale()) {
- set_scale(from.scale());
- }
- if (from.has_mean_file()) {
- set_has_mean_file();
- mean_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.mean_file_);
- }
- if (from.has_batch_size()) {
- set_batch_size(from.batch_size());
- }
- if (from.has_crop_size()) {
- set_crop_size(from.crop_size());
- }
- if (from.has_mirror()) {
- set_mirror(from.mirror());
- }
- if (from.has_fg_threshold()) {
- set_fg_threshold(from.fg_threshold());
- }
- if (from.has_bg_threshold()) {
- set_bg_threshold(from.bg_threshold());
- }
- }
- if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) {
- if (from.has_fg_fraction()) {
- set_fg_fraction(from.fg_fraction());
- }
- if (from.has_context_pad()) {
- set_context_pad(from.context_pad());
- }
- if (from.has_crop_mode()) {
- set_has_crop_mode();
- crop_mode_.AssignWithDefault(_default_crop_mode_, from.crop_mode_);
- }
- if (from.has_cache_images()) {
- set_cache_images(from.cache_images());
- }
- if (from.has_root_folder()) {
- set_has_root_folder();
- root_folder_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.root_folder_);
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void WindowDataParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.WindowDataParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void WindowDataParameter::CopyFrom(const WindowDataParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.WindowDataParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool WindowDataParameter::IsInitialized() const {
-
- return true;
-}
-
-void WindowDataParameter::Swap(WindowDataParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void WindowDataParameter::InternalSwap(WindowDataParameter* other) {
- source_.Swap(&other->source_);
- std::swap(scale_, other->scale_);
- mean_file_.Swap(&other->mean_file_);
- std::swap(batch_size_, other->batch_size_);
- std::swap(crop_size_, other->crop_size_);
- std::swap(mirror_, other->mirror_);
- std::swap(fg_threshold_, other->fg_threshold_);
- std::swap(bg_threshold_, other->bg_threshold_);
- std::swap(fg_fraction_, other->fg_fraction_);
- std::swap(context_pad_, other->context_pad_);
- crop_mode_.Swap(&other->crop_mode_);
- std::swap(cache_images_, other->cache_images_);
- root_folder_.Swap(&other->root_folder_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata WindowDataParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = WindowDataParameter_descriptor_;
- metadata.reflection = WindowDataParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// WindowDataParameter
-
-// optional string source = 1;
-bool WindowDataParameter::has_source() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void WindowDataParameter::set_has_source() {
- _has_bits_[0] |= 0x00000001u;
-}
-void WindowDataParameter::clear_has_source() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void WindowDataParameter::clear_source() {
- source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_source();
-}
-const ::std::string& WindowDataParameter::source() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.source)
- return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void WindowDataParameter::set_source(const ::std::string& value) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.source)
-}
-void WindowDataParameter::set_source(const char* value) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.WindowDataParameter.source)
-}
-void WindowDataParameter::set_source(const char* value, size_t size) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.WindowDataParameter.source)
-}
-::std::string* WindowDataParameter::mutable_source() {
- set_has_source();
- // @@protoc_insertion_point(field_mutable:caffe.WindowDataParameter.source)
- return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* WindowDataParameter::release_source() {
- // @@protoc_insertion_point(field_release:caffe.WindowDataParameter.source)
- clear_has_source();
- return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void WindowDataParameter::set_allocated_source(::std::string* source) {
- if (source != NULL) {
- set_has_source();
- } else {
- clear_has_source();
- }
- source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source);
- // @@protoc_insertion_point(field_set_allocated:caffe.WindowDataParameter.source)
-}
-
-// optional float scale = 2 [default = 1];
-bool WindowDataParameter::has_scale() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void WindowDataParameter::set_has_scale() {
- _has_bits_[0] |= 0x00000002u;
-}
-void WindowDataParameter::clear_has_scale() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void WindowDataParameter::clear_scale() {
- scale_ = 1;
- clear_has_scale();
-}
-float WindowDataParameter::scale() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.scale)
- return scale_;
-}
-void WindowDataParameter::set_scale(float value) {
- set_has_scale();
- scale_ = value;
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.scale)
-}
-
-// optional string mean_file = 3;
-bool WindowDataParameter::has_mean_file() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void WindowDataParameter::set_has_mean_file() {
- _has_bits_[0] |= 0x00000004u;
-}
-void WindowDataParameter::clear_has_mean_file() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void WindowDataParameter::clear_mean_file() {
- mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_mean_file();
-}
-const ::std::string& WindowDataParameter::mean_file() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.mean_file)
- return mean_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void WindowDataParameter::set_mean_file(const ::std::string& value) {
- set_has_mean_file();
- mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.mean_file)
-}
-void WindowDataParameter::set_mean_file(const char* value) {
- set_has_mean_file();
- mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.WindowDataParameter.mean_file)
-}
-void WindowDataParameter::set_mean_file(const char* value, size_t size) {
- set_has_mean_file();
- mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.WindowDataParameter.mean_file)
-}
-::std::string* WindowDataParameter::mutable_mean_file() {
- set_has_mean_file();
- // @@protoc_insertion_point(field_mutable:caffe.WindowDataParameter.mean_file)
- return mean_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* WindowDataParameter::release_mean_file() {
- // @@protoc_insertion_point(field_release:caffe.WindowDataParameter.mean_file)
- clear_has_mean_file();
- return mean_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void WindowDataParameter::set_allocated_mean_file(::std::string* mean_file) {
- if (mean_file != NULL) {
- set_has_mean_file();
- } else {
- clear_has_mean_file();
- }
- mean_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), mean_file);
- // @@protoc_insertion_point(field_set_allocated:caffe.WindowDataParameter.mean_file)
-}
-
-// optional uint32 batch_size = 4;
-bool WindowDataParameter::has_batch_size() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-void WindowDataParameter::set_has_batch_size() {
- _has_bits_[0] |= 0x00000008u;
-}
-void WindowDataParameter::clear_has_batch_size() {
- _has_bits_[0] &= ~0x00000008u;
-}
-void WindowDataParameter::clear_batch_size() {
- batch_size_ = 0u;
- clear_has_batch_size();
-}
-::google::protobuf::uint32 WindowDataParameter::batch_size() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.batch_size)
- return batch_size_;
-}
-void WindowDataParameter::set_batch_size(::google::protobuf::uint32 value) {
- set_has_batch_size();
- batch_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.batch_size)
-}
-
-// optional uint32 crop_size = 5 [default = 0];
-bool WindowDataParameter::has_crop_size() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-void WindowDataParameter::set_has_crop_size() {
- _has_bits_[0] |= 0x00000010u;
-}
-void WindowDataParameter::clear_has_crop_size() {
- _has_bits_[0] &= ~0x00000010u;
-}
-void WindowDataParameter::clear_crop_size() {
- crop_size_ = 0u;
- clear_has_crop_size();
-}
-::google::protobuf::uint32 WindowDataParameter::crop_size() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.crop_size)
- return crop_size_;
-}
-void WindowDataParameter::set_crop_size(::google::protobuf::uint32 value) {
- set_has_crop_size();
- crop_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.crop_size)
-}
-
-// optional bool mirror = 6 [default = false];
-bool WindowDataParameter::has_mirror() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-void WindowDataParameter::set_has_mirror() {
- _has_bits_[0] |= 0x00000020u;
-}
-void WindowDataParameter::clear_has_mirror() {
- _has_bits_[0] &= ~0x00000020u;
-}
-void WindowDataParameter::clear_mirror() {
- mirror_ = false;
- clear_has_mirror();
-}
-bool WindowDataParameter::mirror() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.mirror)
- return mirror_;
-}
-void WindowDataParameter::set_mirror(bool value) {
- set_has_mirror();
- mirror_ = value;
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.mirror)
-}
-
-// optional float fg_threshold = 7 [default = 0.5];
-bool WindowDataParameter::has_fg_threshold() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-void WindowDataParameter::set_has_fg_threshold() {
- _has_bits_[0] |= 0x00000040u;
-}
-void WindowDataParameter::clear_has_fg_threshold() {
- _has_bits_[0] &= ~0x00000040u;
-}
-void WindowDataParameter::clear_fg_threshold() {
- fg_threshold_ = 0.5f;
- clear_has_fg_threshold();
-}
-float WindowDataParameter::fg_threshold() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.fg_threshold)
- return fg_threshold_;
-}
-void WindowDataParameter::set_fg_threshold(float value) {
- set_has_fg_threshold();
- fg_threshold_ = value;
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.fg_threshold)
-}
-
-// optional float bg_threshold = 8 [default = 0.5];
-bool WindowDataParameter::has_bg_threshold() const {
- return (_has_bits_[0] & 0x00000080u) != 0;
-}
-void WindowDataParameter::set_has_bg_threshold() {
- _has_bits_[0] |= 0x00000080u;
-}
-void WindowDataParameter::clear_has_bg_threshold() {
- _has_bits_[0] &= ~0x00000080u;
-}
-void WindowDataParameter::clear_bg_threshold() {
- bg_threshold_ = 0.5f;
- clear_has_bg_threshold();
-}
-float WindowDataParameter::bg_threshold() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.bg_threshold)
- return bg_threshold_;
-}
-void WindowDataParameter::set_bg_threshold(float value) {
- set_has_bg_threshold();
- bg_threshold_ = value;
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.bg_threshold)
-}
-
-// optional float fg_fraction = 9 [default = 0.25];
-bool WindowDataParameter::has_fg_fraction() const {
- return (_has_bits_[0] & 0x00000100u) != 0;
-}
-void WindowDataParameter::set_has_fg_fraction() {
- _has_bits_[0] |= 0x00000100u;
-}
-void WindowDataParameter::clear_has_fg_fraction() {
- _has_bits_[0] &= ~0x00000100u;
-}
-void WindowDataParameter::clear_fg_fraction() {
- fg_fraction_ = 0.25f;
- clear_has_fg_fraction();
-}
-float WindowDataParameter::fg_fraction() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.fg_fraction)
- return fg_fraction_;
-}
-void WindowDataParameter::set_fg_fraction(float value) {
- set_has_fg_fraction();
- fg_fraction_ = value;
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.fg_fraction)
-}
-
-// optional uint32 context_pad = 10 [default = 0];
-bool WindowDataParameter::has_context_pad() const {
- return (_has_bits_[0] & 0x00000200u) != 0;
-}
-void WindowDataParameter::set_has_context_pad() {
- _has_bits_[0] |= 0x00000200u;
-}
-void WindowDataParameter::clear_has_context_pad() {
- _has_bits_[0] &= ~0x00000200u;
-}
-void WindowDataParameter::clear_context_pad() {
- context_pad_ = 0u;
- clear_has_context_pad();
-}
-::google::protobuf::uint32 WindowDataParameter::context_pad() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.context_pad)
- return context_pad_;
-}
-void WindowDataParameter::set_context_pad(::google::protobuf::uint32 value) {
- set_has_context_pad();
- context_pad_ = value;
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.context_pad)
-}
-
-// optional string crop_mode = 11 [default = "warp"];
-bool WindowDataParameter::has_crop_mode() const {
- return (_has_bits_[0] & 0x00000400u) != 0;
-}
-void WindowDataParameter::set_has_crop_mode() {
- _has_bits_[0] |= 0x00000400u;
-}
-void WindowDataParameter::clear_has_crop_mode() {
- _has_bits_[0] &= ~0x00000400u;
-}
-void WindowDataParameter::clear_crop_mode() {
- crop_mode_.ClearToDefaultNoArena(_default_crop_mode_);
- clear_has_crop_mode();
-}
-const ::std::string& WindowDataParameter::crop_mode() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.crop_mode)
- return crop_mode_.GetNoArena(_default_crop_mode_);
-}
-void WindowDataParameter::set_crop_mode(const ::std::string& value) {
- set_has_crop_mode();
- crop_mode_.SetNoArena(_default_crop_mode_, value);
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.crop_mode)
-}
-void WindowDataParameter::set_crop_mode(const char* value) {
- set_has_crop_mode();
- crop_mode_.SetNoArena(_default_crop_mode_, ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.WindowDataParameter.crop_mode)
-}
-void WindowDataParameter::set_crop_mode(const char* value, size_t size) {
- set_has_crop_mode();
- crop_mode_.SetNoArena(_default_crop_mode_,
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.WindowDataParameter.crop_mode)
-}
-::std::string* WindowDataParameter::mutable_crop_mode() {
- set_has_crop_mode();
- // @@protoc_insertion_point(field_mutable:caffe.WindowDataParameter.crop_mode)
- return crop_mode_.MutableNoArena(_default_crop_mode_);
-}
-::std::string* WindowDataParameter::release_crop_mode() {
- // @@protoc_insertion_point(field_release:caffe.WindowDataParameter.crop_mode)
- clear_has_crop_mode();
- return crop_mode_.ReleaseNoArena(_default_crop_mode_);
-}
-void WindowDataParameter::set_allocated_crop_mode(::std::string* crop_mode) {
- if (crop_mode != NULL) {
- set_has_crop_mode();
- } else {
- clear_has_crop_mode();
- }
- crop_mode_.SetAllocatedNoArena(_default_crop_mode_, crop_mode);
- // @@protoc_insertion_point(field_set_allocated:caffe.WindowDataParameter.crop_mode)
-}
-
-// optional bool cache_images = 12 [default = false];
-bool WindowDataParameter::has_cache_images() const {
- return (_has_bits_[0] & 0x00000800u) != 0;
-}
-void WindowDataParameter::set_has_cache_images() {
- _has_bits_[0] |= 0x00000800u;
-}
-void WindowDataParameter::clear_has_cache_images() {
- _has_bits_[0] &= ~0x00000800u;
-}
-void WindowDataParameter::clear_cache_images() {
- cache_images_ = false;
- clear_has_cache_images();
-}
-bool WindowDataParameter::cache_images() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.cache_images)
- return cache_images_;
-}
-void WindowDataParameter::set_cache_images(bool value) {
- set_has_cache_images();
- cache_images_ = value;
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.cache_images)
-}
-
-// optional string root_folder = 13 [default = ""];
-bool WindowDataParameter::has_root_folder() const {
- return (_has_bits_[0] & 0x00001000u) != 0;
-}
-void WindowDataParameter::set_has_root_folder() {
- _has_bits_[0] |= 0x00001000u;
-}
-void WindowDataParameter::clear_has_root_folder() {
- _has_bits_[0] &= ~0x00001000u;
-}
-void WindowDataParameter::clear_root_folder() {
- root_folder_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_root_folder();
-}
-const ::std::string& WindowDataParameter::root_folder() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.root_folder)
- return root_folder_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void WindowDataParameter::set_root_folder(const ::std::string& value) {
- set_has_root_folder();
- root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.root_folder)
-}
-void WindowDataParameter::set_root_folder(const char* value) {
- set_has_root_folder();
- root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.WindowDataParameter.root_folder)
-}
-void WindowDataParameter::set_root_folder(const char* value, size_t size) {
- set_has_root_folder();
- root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.WindowDataParameter.root_folder)
-}
-::std::string* WindowDataParameter::mutable_root_folder() {
- set_has_root_folder();
- // @@protoc_insertion_point(field_mutable:caffe.WindowDataParameter.root_folder)
- return root_folder_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* WindowDataParameter::release_root_folder() {
- // @@protoc_insertion_point(field_release:caffe.WindowDataParameter.root_folder)
- clear_has_root_folder();
- return root_folder_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void WindowDataParameter::set_allocated_root_folder(::std::string* root_folder) {
- if (root_folder != NULL) {
- set_has_root_folder();
- } else {
- clear_has_root_folder();
- }
- root_folder_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), root_folder);
- // @@protoc_insertion_point(field_set_allocated:caffe.WindowDataParameter.root_folder)
-}
-
-inline const WindowDataParameter* WindowDataParameter::internal_default_instance() {
- return &WindowDataParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-const ::google::protobuf::EnumDescriptor* SPPParameter_PoolMethod_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return SPPParameter_PoolMethod_descriptor_;
-}
-bool SPPParameter_PoolMethod_IsValid(int value) {
- switch (value) {
- case 0:
- case 1:
- case 2:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const SPPParameter_PoolMethod SPPParameter::MAX;
-const SPPParameter_PoolMethod SPPParameter::AVE;
-const SPPParameter_PoolMethod SPPParameter::STOCHASTIC;
-const SPPParameter_PoolMethod SPPParameter::PoolMethod_MIN;
-const SPPParameter_PoolMethod SPPParameter::PoolMethod_MAX;
-const int SPPParameter::PoolMethod_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-const ::google::protobuf::EnumDescriptor* SPPParameter_Engine_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return SPPParameter_Engine_descriptor_;
-}
-bool SPPParameter_Engine_IsValid(int value) {
- switch (value) {
- case 0:
- case 1:
- case 2:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const SPPParameter_Engine SPPParameter::DEFAULT;
-const SPPParameter_Engine SPPParameter::CAFFE;
-const SPPParameter_Engine SPPParameter::CUDNN;
-const SPPParameter_Engine SPPParameter::Engine_MIN;
-const SPPParameter_Engine SPPParameter::Engine_MAX;
-const int SPPParameter::Engine_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int SPPParameter::kPyramidHeightFieldNumber;
-const int SPPParameter::kPoolFieldNumber;
-const int SPPParameter::kEngineFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-SPPParameter::SPPParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.SPPParameter)
-}
-
-void SPPParameter::InitAsDefaultInstance() {
-}
-
-SPPParameter::SPPParameter(const SPPParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.SPPParameter)
-}
-
-void SPPParameter::SharedCtor() {
- _cached_size_ = 0;
- ::memset(&pyramid_height_, 0, reinterpret_cast<char*>(&engine_) -
- reinterpret_cast<char*>(&pyramid_height_) + sizeof(engine_));
-}
-
-SPPParameter::~SPPParameter() {
- // @@protoc_insertion_point(destructor:caffe.SPPParameter)
- SharedDtor();
-}
-
-void SPPParameter::SharedDtor() {
-}
-
-void SPPParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* SPPParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return SPPParameter_descriptor_;
-}
-
-const SPPParameter& SPPParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<SPPParameter> SPPParameter_default_instance_;
-
-SPPParameter* SPPParameter::New(::google::protobuf::Arena* arena) const {
- SPPParameter* n = new SPPParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void SPPParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.SPPParameter)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(SPPParameter, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<SPPParameter*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- ZR_(pyramid_height_, engine_);
-
-#undef ZR_HELPER_
-#undef ZR_
-
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool SPPParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.SPPParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional uint32 pyramid_height = 1;
- case 1: {
- if (tag == 8) {
- set_has_pyramid_height();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &pyramid_height_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_pool;
- break;
- }
-
- // optional .caffe.SPPParameter.PoolMethod pool = 2 [default = MAX];
- case 2: {
- if (tag == 16) {
- parse_pool:
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::SPPParameter_PoolMethod_IsValid(value)) {
- set_pool(static_cast< ::caffe::SPPParameter_PoolMethod >(value));
- } else {
- mutable_unknown_fields()->AddVarint(2, value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(48)) goto parse_engine;
- break;
- }
-
- // optional .caffe.SPPParameter.Engine engine = 6 [default = DEFAULT];
- case 6: {
- if (tag == 48) {
- parse_engine:
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::SPPParameter_Engine_IsValid(value)) {
- set_engine(static_cast< ::caffe::SPPParameter_Engine >(value));
- } else {
- mutable_unknown_fields()->AddVarint(6, value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.SPPParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.SPPParameter)
- return false;
-#undef DO_
-}
-
-void SPPParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.SPPParameter)
- // optional uint32 pyramid_height = 1;
- if (has_pyramid_height()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->pyramid_height(), output);
- }
-
- // optional .caffe.SPPParameter.PoolMethod pool = 2 [default = MAX];
- if (has_pool()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 2, this->pool(), output);
- }
-
- // optional .caffe.SPPParameter.Engine engine = 6 [default = DEFAULT];
- if (has_engine()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 6, this->engine(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.SPPParameter)
-}
-
-::google::protobuf::uint8* SPPParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.SPPParameter)
- // optional uint32 pyramid_height = 1;
- if (has_pyramid_height()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->pyramid_height(), target);
- }
-
- // optional .caffe.SPPParameter.PoolMethod pool = 2 [default = MAX];
- if (has_pool()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 2, this->pool(), target);
- }
-
- // optional .caffe.SPPParameter.Engine engine = 6 [default = DEFAULT];
- if (has_engine()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 6, this->engine(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.SPPParameter)
- return target;
-}
-
-size_t SPPParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.SPPParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 7u) {
- // optional uint32 pyramid_height = 1;
- if (has_pyramid_height()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->pyramid_height());
- }
-
- // optional .caffe.SPPParameter.PoolMethod pool = 2 [default = MAX];
- if (has_pool()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->pool());
- }
-
- // optional .caffe.SPPParameter.Engine engine = 6 [default = DEFAULT];
- if (has_engine()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->engine());
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void SPPParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.SPPParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const SPPParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const SPPParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.SPPParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.SPPParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void SPPParameter::MergeFrom(const SPPParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.SPPParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void SPPParameter::UnsafeMergeFrom(const SPPParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_pyramid_height()) {
- set_pyramid_height(from.pyramid_height());
- }
- if (from.has_pool()) {
- set_pool(from.pool());
- }
- if (from.has_engine()) {
- set_engine(from.engine());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void SPPParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.SPPParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void SPPParameter::CopyFrom(const SPPParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.SPPParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool SPPParameter::IsInitialized() const {
-
- return true;
-}
-
-void SPPParameter::Swap(SPPParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void SPPParameter::InternalSwap(SPPParameter* other) {
- std::swap(pyramid_height_, other->pyramid_height_);
- std::swap(pool_, other->pool_);
- std::swap(engine_, other->engine_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata SPPParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = SPPParameter_descriptor_;
- metadata.reflection = SPPParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// SPPParameter
-
-// optional uint32 pyramid_height = 1;
-bool SPPParameter::has_pyramid_height() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void SPPParameter::set_has_pyramid_height() {
- _has_bits_[0] |= 0x00000001u;
-}
-void SPPParameter::clear_has_pyramid_height() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void SPPParameter::clear_pyramid_height() {
- pyramid_height_ = 0u;
- clear_has_pyramid_height();
-}
-::google::protobuf::uint32 SPPParameter::pyramid_height() const {
- // @@protoc_insertion_point(field_get:caffe.SPPParameter.pyramid_height)
- return pyramid_height_;
-}
-void SPPParameter::set_pyramid_height(::google::protobuf::uint32 value) {
- set_has_pyramid_height();
- pyramid_height_ = value;
- // @@protoc_insertion_point(field_set:caffe.SPPParameter.pyramid_height)
-}
-
-// optional .caffe.SPPParameter.PoolMethod pool = 2 [default = MAX];
-bool SPPParameter::has_pool() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void SPPParameter::set_has_pool() {
- _has_bits_[0] |= 0x00000002u;
-}
-void SPPParameter::clear_has_pool() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void SPPParameter::clear_pool() {
- pool_ = 0;
- clear_has_pool();
-}
-::caffe::SPPParameter_PoolMethod SPPParameter::pool() const {
- // @@protoc_insertion_point(field_get:caffe.SPPParameter.pool)
- return static_cast< ::caffe::SPPParameter_PoolMethod >(pool_);
-}
-void SPPParameter::set_pool(::caffe::SPPParameter_PoolMethod value) {
- assert(::caffe::SPPParameter_PoolMethod_IsValid(value));
- set_has_pool();
- pool_ = value;
- // @@protoc_insertion_point(field_set:caffe.SPPParameter.pool)
-}
-
-// optional .caffe.SPPParameter.Engine engine = 6 [default = DEFAULT];
-bool SPPParameter::has_engine() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void SPPParameter::set_has_engine() {
- _has_bits_[0] |= 0x00000004u;
-}
-void SPPParameter::clear_has_engine() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void SPPParameter::clear_engine() {
- engine_ = 0;
- clear_has_engine();
-}
-::caffe::SPPParameter_Engine SPPParameter::engine() const {
- // @@protoc_insertion_point(field_get:caffe.SPPParameter.engine)
- return static_cast< ::caffe::SPPParameter_Engine >(engine_);
-}
-void SPPParameter::set_engine(::caffe::SPPParameter_Engine value) {
- assert(::caffe::SPPParameter_Engine_IsValid(value));
- set_has_engine();
- engine_ = value;
- // @@protoc_insertion_point(field_set:caffe.SPPParameter.engine)
-}
-
-inline const SPPParameter* SPPParameter::internal_default_instance() {
- return &SPPParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-const ::google::protobuf::EnumDescriptor* V1LayerParameter_LayerType_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return V1LayerParameter_LayerType_descriptor_;
-}
-bool V1LayerParameter_LayerType_IsValid(int value) {
- switch (value) {
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- case 10:
- case 11:
- case 12:
- case 13:
- case 14:
- case 15:
- case 16:
- case 17:
- case 18:
- case 19:
- case 20:
- case 21:
- case 22:
- case 23:
- case 24:
- case 25:
- case 26:
- case 27:
- case 28:
- case 29:
- case 30:
- case 31:
- case 32:
- case 33:
- case 34:
- case 35:
- case 36:
- case 37:
- case 38:
- case 39:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const V1LayerParameter_LayerType V1LayerParameter::NONE;
-const V1LayerParameter_LayerType V1LayerParameter::ABSVAL;
-const V1LayerParameter_LayerType V1LayerParameter::ACCURACY;
-const V1LayerParameter_LayerType V1LayerParameter::ARGMAX;
-const V1LayerParameter_LayerType V1LayerParameter::BNLL;
-const V1LayerParameter_LayerType V1LayerParameter::CONCAT;
-const V1LayerParameter_LayerType V1LayerParameter::CONTRASTIVE_LOSS;
-const V1LayerParameter_LayerType V1LayerParameter::CONVOLUTION;
-const V1LayerParameter_LayerType V1LayerParameter::DATA;
-const V1LayerParameter_LayerType V1LayerParameter::DECONVOLUTION;
-const V1LayerParameter_LayerType V1LayerParameter::DROPOUT;
-const V1LayerParameter_LayerType V1LayerParameter::DUMMY_DATA;
-const V1LayerParameter_LayerType V1LayerParameter::EUCLIDEAN_LOSS;
-const V1LayerParameter_LayerType V1LayerParameter::ELTWISE;
-const V1LayerParameter_LayerType V1LayerParameter::EXP;
-const V1LayerParameter_LayerType V1LayerParameter::FLATTEN;
-const V1LayerParameter_LayerType V1LayerParameter::HDF5_DATA;
-const V1LayerParameter_LayerType V1LayerParameter::HDF5_OUTPUT;
-const V1LayerParameter_LayerType V1LayerParameter::HINGE_LOSS;
-const V1LayerParameter_LayerType V1LayerParameter::IM2COL;
-const V1LayerParameter_LayerType V1LayerParameter::IMAGE_DATA;
-const V1LayerParameter_LayerType V1LayerParameter::INFOGAIN_LOSS;
-const V1LayerParameter_LayerType V1LayerParameter::INNER_PRODUCT;
-const V1LayerParameter_LayerType V1LayerParameter::LRN;
-const V1LayerParameter_LayerType V1LayerParameter::MEMORY_DATA;
-const V1LayerParameter_LayerType V1LayerParameter::MULTINOMIAL_LOGISTIC_LOSS;
-const V1LayerParameter_LayerType V1LayerParameter::MVN;
-const V1LayerParameter_LayerType V1LayerParameter::POOLING;
-const V1LayerParameter_LayerType V1LayerParameter::POWER;
-const V1LayerParameter_LayerType V1LayerParameter::RELU;
-const V1LayerParameter_LayerType V1LayerParameter::SIGMOID;
-const V1LayerParameter_LayerType V1LayerParameter::SIGMOID_CROSS_ENTROPY_LOSS;
-const V1LayerParameter_LayerType V1LayerParameter::SILENCE;
-const V1LayerParameter_LayerType V1LayerParameter::SOFTMAX;
-const V1LayerParameter_LayerType V1LayerParameter::SOFTMAX_LOSS;
-const V1LayerParameter_LayerType V1LayerParameter::SPLIT;
-const V1LayerParameter_LayerType V1LayerParameter::SLICE;
-const V1LayerParameter_LayerType V1LayerParameter::TANH;
-const V1LayerParameter_LayerType V1LayerParameter::WINDOW_DATA;
-const V1LayerParameter_LayerType V1LayerParameter::THRESHOLD;
-const V1LayerParameter_LayerType V1LayerParameter::LayerType_MIN;
-const V1LayerParameter_LayerType V1LayerParameter::LayerType_MAX;
-const int V1LayerParameter::LayerType_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-const ::google::protobuf::EnumDescriptor* V1LayerParameter_DimCheckMode_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return V1LayerParameter_DimCheckMode_descriptor_;
-}
-bool V1LayerParameter_DimCheckMode_IsValid(int value) {
- switch (value) {
- case 0:
- case 1:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const V1LayerParameter_DimCheckMode V1LayerParameter::STRICT;
-const V1LayerParameter_DimCheckMode V1LayerParameter::PERMISSIVE;
-const V1LayerParameter_DimCheckMode V1LayerParameter::DimCheckMode_MIN;
-const V1LayerParameter_DimCheckMode V1LayerParameter::DimCheckMode_MAX;
-const int V1LayerParameter::DimCheckMode_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int V1LayerParameter::kBottomFieldNumber;
-const int V1LayerParameter::kTopFieldNumber;
-const int V1LayerParameter::kNameFieldNumber;
-const int V1LayerParameter::kIncludeFieldNumber;
-const int V1LayerParameter::kExcludeFieldNumber;
-const int V1LayerParameter::kTypeFieldNumber;
-const int V1LayerParameter::kBlobsFieldNumber;
-const int V1LayerParameter::kParamFieldNumber;
-const int V1LayerParameter::kBlobShareModeFieldNumber;
-const int V1LayerParameter::kBlobsLrFieldNumber;
-const int V1LayerParameter::kWeightDecayFieldNumber;
-const int V1LayerParameter::kLossWeightFieldNumber;
-const int V1LayerParameter::kAccuracyParamFieldNumber;
-const int V1LayerParameter::kArgmaxParamFieldNumber;
-const int V1LayerParameter::kConcatParamFieldNumber;
-const int V1LayerParameter::kContrastiveLossParamFieldNumber;
-const int V1LayerParameter::kConvolutionParamFieldNumber;
-const int V1LayerParameter::kDataParamFieldNumber;
-const int V1LayerParameter::kDropoutParamFieldNumber;
-const int V1LayerParameter::kDummyDataParamFieldNumber;
-const int V1LayerParameter::kEltwiseParamFieldNumber;
-const int V1LayerParameter::kExpParamFieldNumber;
-const int V1LayerParameter::kHdf5DataParamFieldNumber;
-const int V1LayerParameter::kHdf5OutputParamFieldNumber;
-const int V1LayerParameter::kHingeLossParamFieldNumber;
-const int V1LayerParameter::kImageDataParamFieldNumber;
-const int V1LayerParameter::kInfogainLossParamFieldNumber;
-const int V1LayerParameter::kInnerProductParamFieldNumber;
-const int V1LayerParameter::kLrnParamFieldNumber;
-const int V1LayerParameter::kMemoryDataParamFieldNumber;
-const int V1LayerParameter::kMvnParamFieldNumber;
-const int V1LayerParameter::kPoolingParamFieldNumber;
-const int V1LayerParameter::kPowerParamFieldNumber;
-const int V1LayerParameter::kReluParamFieldNumber;
-const int V1LayerParameter::kSigmoidParamFieldNumber;
-const int V1LayerParameter::kSoftmaxParamFieldNumber;
-const int V1LayerParameter::kSliceParamFieldNumber;
-const int V1LayerParameter::kTanhParamFieldNumber;
-const int V1LayerParameter::kThresholdParamFieldNumber;
-const int V1LayerParameter::kWindowDataParamFieldNumber;
-const int V1LayerParameter::kTransformParamFieldNumber;
-const int V1LayerParameter::kLossParamFieldNumber;
-const int V1LayerParameter::kLayerFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-V1LayerParameter::V1LayerParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.V1LayerParameter)
-}
-
-void V1LayerParameter::InitAsDefaultInstance() {
- accuracy_param_ = const_cast< ::caffe::AccuracyParameter*>(
- ::caffe::AccuracyParameter::internal_default_instance());
- argmax_param_ = const_cast< ::caffe::ArgMaxParameter*>(
- ::caffe::ArgMaxParameter::internal_default_instance());
- concat_param_ = const_cast< ::caffe::ConcatParameter*>(
- ::caffe::ConcatParameter::internal_default_instance());
- contrastive_loss_param_ = const_cast< ::caffe::ContrastiveLossParameter*>(
- ::caffe::ContrastiveLossParameter::internal_default_instance());
- convolution_param_ = const_cast< ::caffe::ConvolutionParameter*>(
- ::caffe::ConvolutionParameter::internal_default_instance());
- data_param_ = const_cast< ::caffe::DataParameter*>(
- ::caffe::DataParameter::internal_default_instance());
- dropout_param_ = const_cast< ::caffe::DropoutParameter*>(
- ::caffe::DropoutParameter::internal_default_instance());
- dummy_data_param_ = const_cast< ::caffe::DummyDataParameter*>(
- ::caffe::DummyDataParameter::internal_default_instance());
- eltwise_param_ = const_cast< ::caffe::EltwiseParameter*>(
- ::caffe::EltwiseParameter::internal_default_instance());
- exp_param_ = const_cast< ::caffe::ExpParameter*>(
- ::caffe::ExpParameter::internal_default_instance());
- hdf5_data_param_ = const_cast< ::caffe::HDF5DataParameter*>(
- ::caffe::HDF5DataParameter::internal_default_instance());
- hdf5_output_param_ = const_cast< ::caffe::HDF5OutputParameter*>(
- ::caffe::HDF5OutputParameter::internal_default_instance());
- hinge_loss_param_ = const_cast< ::caffe::HingeLossParameter*>(
- ::caffe::HingeLossParameter::internal_default_instance());
- image_data_param_ = const_cast< ::caffe::ImageDataParameter*>(
- ::caffe::ImageDataParameter::internal_default_instance());
- infogain_loss_param_ = const_cast< ::caffe::InfogainLossParameter*>(
- ::caffe::InfogainLossParameter::internal_default_instance());
- inner_product_param_ = const_cast< ::caffe::InnerProductParameter*>(
- ::caffe::InnerProductParameter::internal_default_instance());
- lrn_param_ = const_cast< ::caffe::LRNParameter*>(
- ::caffe::LRNParameter::internal_default_instance());
- memory_data_param_ = const_cast< ::caffe::MemoryDataParameter*>(
- ::caffe::MemoryDataParameter::internal_default_instance());
- mvn_param_ = const_cast< ::caffe::MVNParameter*>(
- ::caffe::MVNParameter::internal_default_instance());
- pooling_param_ = const_cast< ::caffe::PoolingParameter*>(
- ::caffe::PoolingParameter::internal_default_instance());
- power_param_ = const_cast< ::caffe::PowerParameter*>(
- ::caffe::PowerParameter::internal_default_instance());
- relu_param_ = const_cast< ::caffe::ReLUParameter*>(
- ::caffe::ReLUParameter::internal_default_instance());
- sigmoid_param_ = const_cast< ::caffe::SigmoidParameter*>(
- ::caffe::SigmoidParameter::internal_default_instance());
- softmax_param_ = const_cast< ::caffe::SoftmaxParameter*>(
- ::caffe::SoftmaxParameter::internal_default_instance());
- slice_param_ = const_cast< ::caffe::SliceParameter*>(
- ::caffe::SliceParameter::internal_default_instance());
- tanh_param_ = const_cast< ::caffe::TanHParameter*>(
- ::caffe::TanHParameter::internal_default_instance());
- threshold_param_ = const_cast< ::caffe::ThresholdParameter*>(
- ::caffe::ThresholdParameter::internal_default_instance());
- window_data_param_ = const_cast< ::caffe::WindowDataParameter*>(
- ::caffe::WindowDataParameter::internal_default_instance());
- transform_param_ = const_cast< ::caffe::TransformationParameter*>(
- ::caffe::TransformationParameter::internal_default_instance());
- loss_param_ = const_cast< ::caffe::LossParameter*>(
- ::caffe::LossParameter::internal_default_instance());
- layer_ = const_cast< ::caffe::V0LayerParameter*>(
- ::caffe::V0LayerParameter::internal_default_instance());
-}
-
-V1LayerParameter::V1LayerParameter(const V1LayerParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.V1LayerParameter)
-}
-
-void V1LayerParameter::SharedCtor() {
- name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- accuracy_param_ = NULL;
- argmax_param_ = NULL;
- concat_param_ = NULL;
- contrastive_loss_param_ = NULL;
- convolution_param_ = NULL;
- data_param_ = NULL;
- dropout_param_ = NULL;
- dummy_data_param_ = NULL;
- eltwise_param_ = NULL;
- exp_param_ = NULL;
- hdf5_data_param_ = NULL;
- hdf5_output_param_ = NULL;
- hinge_loss_param_ = NULL;
- image_data_param_ = NULL;
- infogain_loss_param_ = NULL;
- inner_product_param_ = NULL;
- lrn_param_ = NULL;
- memory_data_param_ = NULL;
- mvn_param_ = NULL;
- pooling_param_ = NULL;
- power_param_ = NULL;
- relu_param_ = NULL;
- sigmoid_param_ = NULL;
- softmax_param_ = NULL;
- slice_param_ = NULL;
- tanh_param_ = NULL;
- threshold_param_ = NULL;
- window_data_param_ = NULL;
- transform_param_ = NULL;
- loss_param_ = NULL;
- layer_ = NULL;
- type_ = 0;
- _cached_size_ = 0;
-}
-
-V1LayerParameter::~V1LayerParameter() {
- // @@protoc_insertion_point(destructor:caffe.V1LayerParameter)
- SharedDtor();
-}
-
-void V1LayerParameter::SharedDtor() {
- name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- if (this != &V1LayerParameter_default_instance_.get()) {
- delete accuracy_param_;
- delete argmax_param_;
- delete concat_param_;
- delete contrastive_loss_param_;
- delete convolution_param_;
- delete data_param_;
- delete dropout_param_;
- delete dummy_data_param_;
- delete eltwise_param_;
- delete exp_param_;
- delete hdf5_data_param_;
- delete hdf5_output_param_;
- delete hinge_loss_param_;
- delete image_data_param_;
- delete infogain_loss_param_;
- delete inner_product_param_;
- delete lrn_param_;
- delete memory_data_param_;
- delete mvn_param_;
- delete pooling_param_;
- delete power_param_;
- delete relu_param_;
- delete sigmoid_param_;
- delete softmax_param_;
- delete slice_param_;
- delete tanh_param_;
- delete threshold_param_;
- delete window_data_param_;
- delete transform_param_;
- delete loss_param_;
- delete layer_;
- }
-}
-
-void V1LayerParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* V1LayerParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return V1LayerParameter_descriptor_;
-}
-
-const V1LayerParameter& V1LayerParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<V1LayerParameter> V1LayerParameter_default_instance_;
-
-V1LayerParameter* V1LayerParameter::New(::google::protobuf::Arena* arena) const {
- V1LayerParameter* n = new V1LayerParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void V1LayerParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.V1LayerParameter)
- if (_has_bits_[0 / 32] & 36u) {
- if (has_name()) {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- type_ = 0;
- }
- if (_has_bits_[8 / 32] & 61440u) {
- if (has_accuracy_param()) {
- if (accuracy_param_ != NULL) accuracy_param_->::caffe::AccuracyParameter::Clear();
- }
- if (has_argmax_param()) {
- if (argmax_param_ != NULL) argmax_param_->::caffe::ArgMaxParameter::Clear();
- }
- if (has_concat_param()) {
- if (concat_param_ != NULL) concat_param_->::caffe::ConcatParameter::Clear();
- }
- if (has_contrastive_loss_param()) {
- if (contrastive_loss_param_ != NULL) contrastive_loss_param_->::caffe::ContrastiveLossParameter::Clear();
- }
- }
- if (_has_bits_[16 / 32] & 16711680u) {
- if (has_convolution_param()) {
- if (convolution_param_ != NULL) convolution_param_->::caffe::ConvolutionParameter::Clear();
- }
- if (has_data_param()) {
- if (data_param_ != NULL) data_param_->::caffe::DataParameter::Clear();
- }
- if (has_dropout_param()) {
- if (dropout_param_ != NULL) dropout_param_->::caffe::DropoutParameter::Clear();
- }
- if (has_dummy_data_param()) {
- if (dummy_data_param_ != NULL) dummy_data_param_->::caffe::DummyDataParameter::Clear();
- }
- if (has_eltwise_param()) {
- if (eltwise_param_ != NULL) eltwise_param_->::caffe::EltwiseParameter::Clear();
- }
- if (has_exp_param()) {
- if (exp_param_ != NULL) exp_param_->::caffe::ExpParameter::Clear();
- }
- if (has_hdf5_data_param()) {
- if (hdf5_data_param_ != NULL) hdf5_data_param_->::caffe::HDF5DataParameter::Clear();
- }
- if (has_hdf5_output_param()) {
- if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear();
- }
- }
- if (_has_bits_[24 / 32] & 4278190080u) {
- if (has_hinge_loss_param()) {
- if (hinge_loss_param_ != NULL) hinge_loss_param_->::caffe::HingeLossParameter::Clear();
- }
- if (has_image_data_param()) {
- if (image_data_param_ != NULL) image_data_param_->::caffe::ImageDataParameter::Clear();
- }
- if (has_infogain_loss_param()) {
- if (infogain_loss_param_ != NULL) infogain_loss_param_->::caffe::InfogainLossParameter::Clear();
- }
- if (has_inner_product_param()) {
- if (inner_product_param_ != NULL) inner_product_param_->::caffe::InnerProductParameter::Clear();
- }
- if (has_lrn_param()) {
- if (lrn_param_ != NULL) lrn_param_->::caffe::LRNParameter::Clear();
- }
- if (has_memory_data_param()) {
- if (memory_data_param_ != NULL) memory_data_param_->::caffe::MemoryDataParameter::Clear();
- }
- if (has_mvn_param()) {
- if (mvn_param_ != NULL) mvn_param_->::caffe::MVNParameter::Clear();
- }
- if (has_pooling_param()) {
- if (pooling_param_ != NULL) pooling_param_->::caffe::PoolingParameter::Clear();
- }
- }
- if (_has_bits_[32 / 32] & 255u) {
- if (has_power_param()) {
- if (power_param_ != NULL) power_param_->::caffe::PowerParameter::Clear();
- }
- if (has_relu_param()) {
- if (relu_param_ != NULL) relu_param_->::caffe::ReLUParameter::Clear();
- }
- if (has_sigmoid_param()) {
- if (sigmoid_param_ != NULL) sigmoid_param_->::caffe::SigmoidParameter::Clear();
- }
- if (has_softmax_param()) {
- if (softmax_param_ != NULL) softmax_param_->::caffe::SoftmaxParameter::Clear();
- }
- if (has_slice_param()) {
- if (slice_param_ != NULL) slice_param_->::caffe::SliceParameter::Clear();
- }
- if (has_tanh_param()) {
- if (tanh_param_ != NULL) tanh_param_->::caffe::TanHParameter::Clear();
- }
- if (has_threshold_param()) {
- if (threshold_param_ != NULL) threshold_param_->::caffe::ThresholdParameter::Clear();
- }
- if (has_window_data_param()) {
- if (window_data_param_ != NULL) window_data_param_->::caffe::WindowDataParameter::Clear();
- }
- }
- if (_has_bits_[40 / 32] & 1792u) {
- if (has_transform_param()) {
- if (transform_param_ != NULL) transform_param_->::caffe::TransformationParameter::Clear();
- }
- if (has_loss_param()) {
- if (loss_param_ != NULL) loss_param_->::caffe::LossParameter::Clear();
- }
- if (has_layer()) {
- if (layer_ != NULL) layer_->::caffe::V0LayerParameter::Clear();
- }
- }
- bottom_.Clear();
- top_.Clear();
- include_.Clear();
- exclude_.Clear();
- blobs_.Clear();
- param_.Clear();
- blob_share_mode_.Clear();
- blobs_lr_.Clear();
- weight_decay_.Clear();
- loss_weight_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool V1LayerParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.V1LayerParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional .caffe.V0LayerParameter layer = 1;
- case 1: {
- if (tag == 10) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_layer()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(18)) goto parse_bottom;
- break;
- }
-
- // repeated string bottom = 2;
- case 2: {
- if (tag == 18) {
- parse_bottom:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->add_bottom()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->bottom(this->bottom_size() - 1).data(),
- this->bottom(this->bottom_size() - 1).length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.V1LayerParameter.bottom");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(18)) goto parse_bottom;
- if (input->ExpectTag(26)) goto parse_top;
- break;
- }
-
- // repeated string top = 3;
- case 3: {
- if (tag == 26) {
- parse_top:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->add_top()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->top(this->top_size() - 1).data(),
- this->top(this->top_size() - 1).length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.V1LayerParameter.top");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(26)) goto parse_top;
- if (input->ExpectTag(34)) goto parse_name;
- break;
- }
-
- // optional string name = 4;
- case 4: {
- if (tag == 34) {
- parse_name:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_name()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->name().data(), this->name().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.V1LayerParameter.name");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(40)) goto parse_type;
- break;
- }
-
- // optional .caffe.V1LayerParameter.LayerType type = 5;
- case 5: {
- if (tag == 40) {
- parse_type:
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::V1LayerParameter_LayerType_IsValid(value)) {
- set_type(static_cast< ::caffe::V1LayerParameter_LayerType >(value));
- } else {
- mutable_unknown_fields()->AddVarint(5, value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(50)) goto parse_blobs;
- break;
- }
-
- // repeated .caffe.BlobProto blobs = 6;
- case 6: {
- if (tag == 50) {
- parse_blobs:
- DO_(input->IncrementRecursionDepth());
- parse_loop_blobs:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
- input, add_blobs()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(50)) goto parse_loop_blobs;
- input->UnsafeDecrementRecursionDepth();
- if (input->ExpectTag(61)) goto parse_blobs_lr;
- break;
- }
-
- // repeated float blobs_lr = 7;
- case 7: {
- if (tag == 61) {
- parse_blobs_lr:
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- 1, 61, input, this->mutable_blobs_lr())));
- } else if (tag == 58) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, this->mutable_blobs_lr())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(61)) goto parse_blobs_lr;
- if (input->ExpectTag(69)) goto parse_weight_decay;
- break;
- }
-
- // repeated float weight_decay = 8;
- case 8: {
- if (tag == 69) {
- parse_weight_decay:
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- 1, 69, input, this->mutable_weight_decay())));
- } else if (tag == 66) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, this->mutable_weight_decay())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(69)) goto parse_weight_decay;
- if (input->ExpectTag(74)) goto parse_concat_param;
- break;
- }
-
- // optional .caffe.ConcatParameter concat_param = 9;
- case 9: {
- if (tag == 74) {
- parse_concat_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_concat_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(82)) goto parse_convolution_param;
- break;
- }
-
- // optional .caffe.ConvolutionParameter convolution_param = 10;
- case 10: {
- if (tag == 82) {
- parse_convolution_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_convolution_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(90)) goto parse_data_param;
- break;
- }
-
- // optional .caffe.DataParameter data_param = 11;
- case 11: {
- if (tag == 90) {
- parse_data_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_data_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(98)) goto parse_dropout_param;
- break;
- }
-
- // optional .caffe.DropoutParameter dropout_param = 12;
- case 12: {
- if (tag == 98) {
- parse_dropout_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_dropout_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(106)) goto parse_hdf5_data_param;
- break;
- }
-
- // optional .caffe.HDF5DataParameter hdf5_data_param = 13;
- case 13: {
- if (tag == 106) {
- parse_hdf5_data_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_hdf5_data_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(114)) goto parse_hdf5_output_param;
- break;
- }
-
- // optional .caffe.HDF5OutputParameter hdf5_output_param = 14;
- case 14: {
- if (tag == 114) {
- parse_hdf5_output_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_hdf5_output_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(122)) goto parse_image_data_param;
- break;
- }
-
- // optional .caffe.ImageDataParameter image_data_param = 15;
- case 15: {
- if (tag == 122) {
- parse_image_data_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_image_data_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(130)) goto parse_infogain_loss_param;
- break;
- }
-
- // optional .caffe.InfogainLossParameter infogain_loss_param = 16;
- case 16: {
- if (tag == 130) {
- parse_infogain_loss_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_infogain_loss_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(138)) goto parse_inner_product_param;
- break;
- }
-
- // optional .caffe.InnerProductParameter inner_product_param = 17;
- case 17: {
- if (tag == 138) {
- parse_inner_product_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_inner_product_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(146)) goto parse_lrn_param;
- break;
- }
-
- // optional .caffe.LRNParameter lrn_param = 18;
- case 18: {
- if (tag == 146) {
- parse_lrn_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_lrn_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(154)) goto parse_pooling_param;
- break;
- }
-
- // optional .caffe.PoolingParameter pooling_param = 19;
- case 19: {
- if (tag == 154) {
- parse_pooling_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_pooling_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(162)) goto parse_window_data_param;
- break;
- }
-
- // optional .caffe.WindowDataParameter window_data_param = 20;
- case 20: {
- if (tag == 162) {
- parse_window_data_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_window_data_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(170)) goto parse_power_param;
- break;
- }
-
- // optional .caffe.PowerParameter power_param = 21;
- case 21: {
- if (tag == 170) {
- parse_power_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_power_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(178)) goto parse_memory_data_param;
- break;
- }
-
- // optional .caffe.MemoryDataParameter memory_data_param = 22;
- case 22: {
- if (tag == 178) {
- parse_memory_data_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_memory_data_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(186)) goto parse_argmax_param;
- break;
- }
-
- // optional .caffe.ArgMaxParameter argmax_param = 23;
- case 23: {
- if (tag == 186) {
- parse_argmax_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_argmax_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(194)) goto parse_eltwise_param;
- break;
- }
-
- // optional .caffe.EltwiseParameter eltwise_param = 24;
- case 24: {
- if (tag == 194) {
- parse_eltwise_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_eltwise_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(202)) goto parse_threshold_param;
- break;
- }
-
- // optional .caffe.ThresholdParameter threshold_param = 25;
- case 25: {
- if (tag == 202) {
- parse_threshold_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_threshold_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(210)) goto parse_dummy_data_param;
- break;
- }
-
- // optional .caffe.DummyDataParameter dummy_data_param = 26;
- case 26: {
- if (tag == 210) {
- parse_dummy_data_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_dummy_data_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(218)) goto parse_accuracy_param;
- break;
- }
-
- // optional .caffe.AccuracyParameter accuracy_param = 27;
- case 27: {
- if (tag == 218) {
- parse_accuracy_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_accuracy_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(234)) goto parse_hinge_loss_param;
- break;
- }
-
- // optional .caffe.HingeLossParameter hinge_loss_param = 29;
- case 29: {
- if (tag == 234) {
- parse_hinge_loss_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_hinge_loss_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(242)) goto parse_relu_param;
- break;
- }
-
- // optional .caffe.ReLUParameter relu_param = 30;
- case 30: {
- if (tag == 242) {
- parse_relu_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_relu_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(250)) goto parse_slice_param;
- break;
- }
-
- // optional .caffe.SliceParameter slice_param = 31;
- case 31: {
- if (tag == 250) {
- parse_slice_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_slice_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(258)) goto parse_include;
- break;
- }
-
- // repeated .caffe.NetStateRule include = 32;
- case 32: {
- if (tag == 258) {
- parse_include:
- DO_(input->IncrementRecursionDepth());
- parse_loop_include:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
- input, add_include()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(258)) goto parse_loop_include;
- if (input->ExpectTag(266)) goto parse_loop_exclude;
- input->UnsafeDecrementRecursionDepth();
- break;
- }
-
- // repeated .caffe.NetStateRule exclude = 33;
- case 33: {
- if (tag == 266) {
- DO_(input->IncrementRecursionDepth());
- parse_loop_exclude:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
- input, add_exclude()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(266)) goto parse_loop_exclude;
- input->UnsafeDecrementRecursionDepth();
- if (input->ExpectTag(274)) goto parse_mvn_param;
- break;
- }
-
- // optional .caffe.MVNParameter mvn_param = 34;
- case 34: {
- if (tag == 274) {
- parse_mvn_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_mvn_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(285)) goto parse_loss_weight;
- break;
- }
-
- // repeated float loss_weight = 35;
- case 35: {
- if (tag == 285) {
- parse_loss_weight:
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- 2, 285, input, this->mutable_loss_weight())));
- } else if (tag == 282) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, this->mutable_loss_weight())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(285)) goto parse_loss_weight;
- if (input->ExpectTag(290)) goto parse_transform_param;
- break;
- }
-
- // optional .caffe.TransformationParameter transform_param = 36;
- case 36: {
- if (tag == 290) {
- parse_transform_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_transform_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(298)) goto parse_tanh_param;
- break;
- }
-
- // optional .caffe.TanHParameter tanh_param = 37;
- case 37: {
- if (tag == 298) {
- parse_tanh_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_tanh_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(306)) goto parse_sigmoid_param;
- break;
- }
-
- // optional .caffe.SigmoidParameter sigmoid_param = 38;
- case 38: {
- if (tag == 306) {
- parse_sigmoid_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_sigmoid_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(314)) goto parse_softmax_param;
- break;
- }
-
- // optional .caffe.SoftmaxParameter softmax_param = 39;
- case 39: {
- if (tag == 314) {
- parse_softmax_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_softmax_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(322)) goto parse_contrastive_loss_param;
- break;
- }
-
- // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40;
- case 40: {
- if (tag == 322) {
- parse_contrastive_loss_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_contrastive_loss_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(330)) goto parse_exp_param;
- break;
- }
-
- // optional .caffe.ExpParameter exp_param = 41;
- case 41: {
- if (tag == 330) {
- parse_exp_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_exp_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(338)) goto parse_loss_param;
- break;
- }
-
- // optional .caffe.LossParameter loss_param = 42;
- case 42: {
- if (tag == 338) {
- parse_loss_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_loss_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(8010)) goto parse_param;
- break;
- }
-
- // repeated string param = 1001;
- case 1001: {
- if (tag == 8010) {
- parse_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->add_param()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->param(this->param_size() - 1).data(),
- this->param(this->param_size() - 1).length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.V1LayerParameter.param");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(8010)) goto parse_param;
- if (input->ExpectTag(8016)) goto parse_blob_share_mode;
- break;
- }
-
- // repeated .caffe.V1LayerParameter.DimCheckMode blob_share_mode = 1002;
- case 1002: {
- if (tag == 8016) {
- parse_blob_share_mode:
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::V1LayerParameter_DimCheckMode_IsValid(value)) {
- add_blob_share_mode(static_cast< ::caffe::V1LayerParameter_DimCheckMode >(value));
- } else {
- mutable_unknown_fields()->AddVarint(1002, value);
- }
- } else if (tag == 8018) {
- DO_((::google::protobuf::internal::WireFormat::ReadPackedEnumPreserveUnknowns(
- input,
- 1002,
- ::caffe::V1LayerParameter_DimCheckMode_IsValid,
- mutable_unknown_fields(),
- this->mutable_blob_share_mode())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(8016)) goto parse_blob_share_mode;
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.V1LayerParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.V1LayerParameter)
- return false;
-#undef DO_
-}
-
-void V1LayerParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.V1LayerParameter)
- // optional .caffe.V0LayerParameter layer = 1;
- if (has_layer()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 1, *this->layer_, output);
- }
-
- // repeated string bottom = 2;
- for (int i = 0; i < this->bottom_size(); i++) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->bottom(i).data(), this->bottom(i).length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.V1LayerParameter.bottom");
- ::google::protobuf::internal::WireFormatLite::WriteString(
- 2, this->bottom(i), output);
- }
-
- // repeated string top = 3;
- for (int i = 0; i < this->top_size(); i++) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->top(i).data(), this->top(i).length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.V1LayerParameter.top");
- ::google::protobuf::internal::WireFormatLite::WriteString(
- 3, this->top(i), output);
- }
-
- // optional string name = 4;
- if (has_name()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->name().data(), this->name().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.V1LayerParameter.name");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 4, this->name(), output);
- }
-
- // optional .caffe.V1LayerParameter.LayerType type = 5;
- if (has_type()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 5, this->type(), output);
- }
-
- // repeated .caffe.BlobProto blobs = 6;
- for (unsigned int i = 0, n = this->blobs_size(); i < n; i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 6, this->blobs(i), output);
- }
-
- // repeated float blobs_lr = 7;
- for (int i = 0; i < this->blobs_lr_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(
- 7, this->blobs_lr(i), output);
- }
-
- // repeated float weight_decay = 8;
- for (int i = 0; i < this->weight_decay_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(
- 8, this->weight_decay(i), output);
- }
-
- // optional .caffe.ConcatParameter concat_param = 9;
- if (has_concat_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 9, *this->concat_param_, output);
- }
-
- // optional .caffe.ConvolutionParameter convolution_param = 10;
- if (has_convolution_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 10, *this->convolution_param_, output);
- }
-
- // optional .caffe.DataParameter data_param = 11;
- if (has_data_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 11, *this->data_param_, output);
- }
-
- // optional .caffe.DropoutParameter dropout_param = 12;
- if (has_dropout_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 12, *this->dropout_param_, output);
- }
-
- // optional .caffe.HDF5DataParameter hdf5_data_param = 13;
- if (has_hdf5_data_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 13, *this->hdf5_data_param_, output);
- }
-
- // optional .caffe.HDF5OutputParameter hdf5_output_param = 14;
- if (has_hdf5_output_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 14, *this->hdf5_output_param_, output);
- }
-
- // optional .caffe.ImageDataParameter image_data_param = 15;
- if (has_image_data_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 15, *this->image_data_param_, output);
- }
-
- // optional .caffe.InfogainLossParameter infogain_loss_param = 16;
- if (has_infogain_loss_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 16, *this->infogain_loss_param_, output);
- }
-
- // optional .caffe.InnerProductParameter inner_product_param = 17;
- if (has_inner_product_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 17, *this->inner_product_param_, output);
- }
-
- // optional .caffe.LRNParameter lrn_param = 18;
- if (has_lrn_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 18, *this->lrn_param_, output);
- }
-
- // optional .caffe.PoolingParameter pooling_param = 19;
- if (has_pooling_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 19, *this->pooling_param_, output);
- }
-
- // optional .caffe.WindowDataParameter window_data_param = 20;
- if (has_window_data_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 20, *this->window_data_param_, output);
- }
-
- // optional .caffe.PowerParameter power_param = 21;
- if (has_power_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 21, *this->power_param_, output);
- }
-
- // optional .caffe.MemoryDataParameter memory_data_param = 22;
- if (has_memory_data_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 22, *this->memory_data_param_, output);
- }
-
- // optional .caffe.ArgMaxParameter argmax_param = 23;
- if (has_argmax_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 23, *this->argmax_param_, output);
- }
-
- // optional .caffe.EltwiseParameter eltwise_param = 24;
- if (has_eltwise_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 24, *this->eltwise_param_, output);
- }
-
- // optional .caffe.ThresholdParameter threshold_param = 25;
- if (has_threshold_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 25, *this->threshold_param_, output);
- }
-
- // optional .caffe.DummyDataParameter dummy_data_param = 26;
- if (has_dummy_data_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 26, *this->dummy_data_param_, output);
- }
-
- // optional .caffe.AccuracyParameter accuracy_param = 27;
- if (has_accuracy_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 27, *this->accuracy_param_, output);
- }
-
- // optional .caffe.HingeLossParameter hinge_loss_param = 29;
- if (has_hinge_loss_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 29, *this->hinge_loss_param_, output);
- }
-
- // optional .caffe.ReLUParameter relu_param = 30;
- if (has_relu_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 30, *this->relu_param_, output);
- }
-
- // optional .caffe.SliceParameter slice_param = 31;
- if (has_slice_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 31, *this->slice_param_, output);
- }
-
- // repeated .caffe.NetStateRule include = 32;
- for (unsigned int i = 0, n = this->include_size(); i < n; i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 32, this->include(i), output);
- }
-
- // repeated .caffe.NetStateRule exclude = 33;
- for (unsigned int i = 0, n = this->exclude_size(); i < n; i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 33, this->exclude(i), output);
- }
-
- // optional .caffe.MVNParameter mvn_param = 34;
- if (has_mvn_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 34, *this->mvn_param_, output);
- }
-
- // repeated float loss_weight = 35;
- for (int i = 0; i < this->loss_weight_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(
- 35, this->loss_weight(i), output);
- }
-
- // optional .caffe.TransformationParameter transform_param = 36;
- if (has_transform_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 36, *this->transform_param_, output);
- }
-
- // optional .caffe.TanHParameter tanh_param = 37;
- if (has_tanh_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 37, *this->tanh_param_, output);
- }
-
- // optional .caffe.SigmoidParameter sigmoid_param = 38;
- if (has_sigmoid_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 38, *this->sigmoid_param_, output);
- }
-
- // optional .caffe.SoftmaxParameter softmax_param = 39;
- if (has_softmax_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 39, *this->softmax_param_, output);
- }
-
- // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40;
- if (has_contrastive_loss_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 40, *this->contrastive_loss_param_, output);
- }
-
- // optional .caffe.ExpParameter exp_param = 41;
- if (has_exp_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 41, *this->exp_param_, output);
- }
-
- // optional .caffe.LossParameter loss_param = 42;
- if (has_loss_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 42, *this->loss_param_, output);
- }
-
- // repeated string param = 1001;
- for (int i = 0; i < this->param_size(); i++) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->param(i).data(), this->param(i).length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.V1LayerParameter.param");
- ::google::protobuf::internal::WireFormatLite::WriteString(
- 1001, this->param(i), output);
- }
-
- // repeated .caffe.V1LayerParameter.DimCheckMode blob_share_mode = 1002;
- for (int i = 0; i < this->blob_share_mode_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 1002, this->blob_share_mode(i), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.V1LayerParameter)
-}
-
-::google::protobuf::uint8* V1LayerParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.V1LayerParameter)
- // optional .caffe.V0LayerParameter layer = 1;
- if (has_layer()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 1, *this->layer_, false, target);
- }
-
- // repeated string bottom = 2;
- for (int i = 0; i < this->bottom_size(); i++) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->bottom(i).data(), this->bottom(i).length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.V1LayerParameter.bottom");
- target = ::google::protobuf::internal::WireFormatLite::
- WriteStringToArray(2, this->bottom(i), target);
- }
-
- // repeated string top = 3;
- for (int i = 0; i < this->top_size(); i++) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->top(i).data(), this->top(i).length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.V1LayerParameter.top");
- target = ::google::protobuf::internal::WireFormatLite::
- WriteStringToArray(3, this->top(i), target);
- }
-
- // optional string name = 4;
- if (has_name()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->name().data(), this->name().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.V1LayerParameter.name");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 4, this->name(), target);
- }
-
- // optional .caffe.V1LayerParameter.LayerType type = 5;
- if (has_type()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 5, this->type(), target);
- }
-
- // repeated .caffe.BlobProto blobs = 6;
- for (unsigned int i = 0, n = this->blobs_size(); i < n; i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 6, this->blobs(i), false, target);
- }
-
- // repeated float blobs_lr = 7;
- for (int i = 0; i < this->blobs_lr_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteFloatToArray(7, this->blobs_lr(i), target);
- }
-
- // repeated float weight_decay = 8;
- for (int i = 0; i < this->weight_decay_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteFloatToArray(8, this->weight_decay(i), target);
- }
-
- // optional .caffe.ConcatParameter concat_param = 9;
- if (has_concat_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 9, *this->concat_param_, false, target);
- }
-
- // optional .caffe.ConvolutionParameter convolution_param = 10;
- if (has_convolution_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 10, *this->convolution_param_, false, target);
- }
-
- // optional .caffe.DataParameter data_param = 11;
- if (has_data_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 11, *this->data_param_, false, target);
- }
-
- // optional .caffe.DropoutParameter dropout_param = 12;
- if (has_dropout_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 12, *this->dropout_param_, false, target);
- }
-
- // optional .caffe.HDF5DataParameter hdf5_data_param = 13;
- if (has_hdf5_data_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 13, *this->hdf5_data_param_, false, target);
- }
-
- // optional .caffe.HDF5OutputParameter hdf5_output_param = 14;
- if (has_hdf5_output_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 14, *this->hdf5_output_param_, false, target);
- }
-
- // optional .caffe.ImageDataParameter image_data_param = 15;
- if (has_image_data_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 15, *this->image_data_param_, false, target);
- }
-
- // optional .caffe.InfogainLossParameter infogain_loss_param = 16;
- if (has_infogain_loss_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 16, *this->infogain_loss_param_, false, target);
- }
-
- // optional .caffe.InnerProductParameter inner_product_param = 17;
- if (has_inner_product_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 17, *this->inner_product_param_, false, target);
- }
-
- // optional .caffe.LRNParameter lrn_param = 18;
- if (has_lrn_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 18, *this->lrn_param_, false, target);
- }
-
- // optional .caffe.PoolingParameter pooling_param = 19;
- if (has_pooling_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 19, *this->pooling_param_, false, target);
- }
-
- // optional .caffe.WindowDataParameter window_data_param = 20;
- if (has_window_data_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 20, *this->window_data_param_, false, target);
- }
-
- // optional .caffe.PowerParameter power_param = 21;
- if (has_power_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 21, *this->power_param_, false, target);
- }
-
- // optional .caffe.MemoryDataParameter memory_data_param = 22;
- if (has_memory_data_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 22, *this->memory_data_param_, false, target);
- }
-
- // optional .caffe.ArgMaxParameter argmax_param = 23;
- if (has_argmax_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 23, *this->argmax_param_, false, target);
- }
-
- // optional .caffe.EltwiseParameter eltwise_param = 24;
- if (has_eltwise_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 24, *this->eltwise_param_, false, target);
- }
-
- // optional .caffe.ThresholdParameter threshold_param = 25;
- if (has_threshold_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 25, *this->threshold_param_, false, target);
- }
-
- // optional .caffe.DummyDataParameter dummy_data_param = 26;
- if (has_dummy_data_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 26, *this->dummy_data_param_, false, target);
- }
-
- // optional .caffe.AccuracyParameter accuracy_param = 27;
- if (has_accuracy_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 27, *this->accuracy_param_, false, target);
- }
-
- // optional .caffe.HingeLossParameter hinge_loss_param = 29;
- if (has_hinge_loss_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 29, *this->hinge_loss_param_, false, target);
- }
-
- // optional .caffe.ReLUParameter relu_param = 30;
- if (has_relu_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 30, *this->relu_param_, false, target);
- }
-
- // optional .caffe.SliceParameter slice_param = 31;
- if (has_slice_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 31, *this->slice_param_, false, target);
- }
-
- // repeated .caffe.NetStateRule include = 32;
- for (unsigned int i = 0, n = this->include_size(); i < n; i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 32, this->include(i), false, target);
- }
-
- // repeated .caffe.NetStateRule exclude = 33;
- for (unsigned int i = 0, n = this->exclude_size(); i < n; i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 33, this->exclude(i), false, target);
- }
-
- // optional .caffe.MVNParameter mvn_param = 34;
- if (has_mvn_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 34, *this->mvn_param_, false, target);
- }
-
- // repeated float loss_weight = 35;
- for (int i = 0; i < this->loss_weight_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteFloatToArray(35, this->loss_weight(i), target);
- }
-
- // optional .caffe.TransformationParameter transform_param = 36;
- if (has_transform_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 36, *this->transform_param_, false, target);
- }
-
- // optional .caffe.TanHParameter tanh_param = 37;
- if (has_tanh_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 37, *this->tanh_param_, false, target);
- }
-
- // optional .caffe.SigmoidParameter sigmoid_param = 38;
- if (has_sigmoid_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 38, *this->sigmoid_param_, false, target);
- }
-
- // optional .caffe.SoftmaxParameter softmax_param = 39;
- if (has_softmax_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 39, *this->softmax_param_, false, target);
- }
-
- // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40;
- if (has_contrastive_loss_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 40, *this->contrastive_loss_param_, false, target);
- }
-
- // optional .caffe.ExpParameter exp_param = 41;
- if (has_exp_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 41, *this->exp_param_, false, target);
- }
-
- // optional .caffe.LossParameter loss_param = 42;
- if (has_loss_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 42, *this->loss_param_, false, target);
- }
-
- // repeated string param = 1001;
- for (int i = 0; i < this->param_size(); i++) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->param(i).data(), this->param(i).length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.V1LayerParameter.param");
- target = ::google::protobuf::internal::WireFormatLite::
- WriteStringToArray(1001, this->param(i), target);
- }
-
- // repeated .caffe.V1LayerParameter.DimCheckMode blob_share_mode = 1002;
- for (int i = 0; i < this->blob_share_mode_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 1002, this->blob_share_mode(i), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.V1LayerParameter)
- return target;
-}
-
-size_t V1LayerParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.V1LayerParameter)
- size_t total_size = 0;
-
- if (_has_bits_[2 / 32] & 36u) {
- // optional string name = 4;
- if (has_name()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->name());
- }
-
- // optional .caffe.V1LayerParameter.LayerType type = 5;
- if (has_type()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->type());
- }
-
- }
- if (_has_bits_[12 / 32] & 61440u) {
- // optional .caffe.AccuracyParameter accuracy_param = 27;
- if (has_accuracy_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->accuracy_param_);
- }
-
- // optional .caffe.ArgMaxParameter argmax_param = 23;
- if (has_argmax_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->argmax_param_);
- }
-
- // optional .caffe.ConcatParameter concat_param = 9;
- if (has_concat_param()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->concat_param_);
- }
-
- // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40;
- if (has_contrastive_loss_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->contrastive_loss_param_);
- }
-
- }
- if (_has_bits_[16 / 32] & 16711680u) {
- // optional .caffe.ConvolutionParameter convolution_param = 10;
- if (has_convolution_param()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->convolution_param_);
- }
-
- // optional .caffe.DataParameter data_param = 11;
- if (has_data_param()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->data_param_);
- }
-
- // optional .caffe.DropoutParameter dropout_param = 12;
- if (has_dropout_param()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->dropout_param_);
- }
-
- // optional .caffe.DummyDataParameter dummy_data_param = 26;
- if (has_dummy_data_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->dummy_data_param_);
- }
-
- // optional .caffe.EltwiseParameter eltwise_param = 24;
- if (has_eltwise_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->eltwise_param_);
- }
-
- // optional .caffe.ExpParameter exp_param = 41;
- if (has_exp_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->exp_param_);
- }
-
- // optional .caffe.HDF5DataParameter hdf5_data_param = 13;
- if (has_hdf5_data_param()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->hdf5_data_param_);
- }
-
- // optional .caffe.HDF5OutputParameter hdf5_output_param = 14;
- if (has_hdf5_output_param()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->hdf5_output_param_);
- }
-
- }
- if (_has_bits_[24 / 32] & 4278190080u) {
- // optional .caffe.HingeLossParameter hinge_loss_param = 29;
- if (has_hinge_loss_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->hinge_loss_param_);
- }
-
- // optional .caffe.ImageDataParameter image_data_param = 15;
- if (has_image_data_param()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->image_data_param_);
- }
-
- // optional .caffe.InfogainLossParameter infogain_loss_param = 16;
- if (has_infogain_loss_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->infogain_loss_param_);
- }
-
- // optional .caffe.InnerProductParameter inner_product_param = 17;
- if (has_inner_product_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->inner_product_param_);
- }
-
- // optional .caffe.LRNParameter lrn_param = 18;
- if (has_lrn_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->lrn_param_);
- }
-
- // optional .caffe.MemoryDataParameter memory_data_param = 22;
- if (has_memory_data_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->memory_data_param_);
- }
-
- // optional .caffe.MVNParameter mvn_param = 34;
- if (has_mvn_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->mvn_param_);
- }
-
- // optional .caffe.PoolingParameter pooling_param = 19;
- if (has_pooling_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->pooling_param_);
- }
-
- }
- if (_has_bits_[32 / 32] & 255u) {
- // optional .caffe.PowerParameter power_param = 21;
- if (has_power_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->power_param_);
- }
-
- // optional .caffe.ReLUParameter relu_param = 30;
- if (has_relu_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->relu_param_);
- }
-
- // optional .caffe.SigmoidParameter sigmoid_param = 38;
- if (has_sigmoid_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->sigmoid_param_);
- }
-
- // optional .caffe.SoftmaxParameter softmax_param = 39;
- if (has_softmax_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->softmax_param_);
- }
-
- // optional .caffe.SliceParameter slice_param = 31;
- if (has_slice_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->slice_param_);
- }
-
- // optional .caffe.TanHParameter tanh_param = 37;
- if (has_tanh_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->tanh_param_);
- }
-
- // optional .caffe.ThresholdParameter threshold_param = 25;
- if (has_threshold_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->threshold_param_);
- }
-
- // optional .caffe.WindowDataParameter window_data_param = 20;
- if (has_window_data_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->window_data_param_);
- }
-
- }
- if (_has_bits_[40 / 32] & 1792u) {
- // optional .caffe.TransformationParameter transform_param = 36;
- if (has_transform_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->transform_param_);
- }
-
- // optional .caffe.LossParameter loss_param = 42;
- if (has_loss_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->loss_param_);
- }
-
- // optional .caffe.V0LayerParameter layer = 1;
- if (has_layer()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->layer_);
- }
-
- }
- // repeated string bottom = 2;
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->bottom_size());
- for (int i = 0; i < this->bottom_size(); i++) {
- total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
- this->bottom(i));
- }
-
- // repeated string top = 3;
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->top_size());
- for (int i = 0; i < this->top_size(); i++) {
- total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
- this->top(i));
- }
-
- // repeated .caffe.NetStateRule include = 32;
- {
- unsigned int count = this->include_size();
- total_size += 2UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->include(i));
- }
- }
-
- // repeated .caffe.NetStateRule exclude = 33;
- {
- unsigned int count = this->exclude_size();
- total_size += 2UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->exclude(i));
- }
- }
-
- // repeated .caffe.BlobProto blobs = 6;
- {
- unsigned int count = this->blobs_size();
- total_size += 1UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->blobs(i));
- }
- }
-
- // repeated string param = 1001;
- total_size += 2 *
- ::google::protobuf::internal::FromIntSize(this->param_size());
- for (int i = 0; i < this->param_size(); i++) {
- total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
- this->param(i));
- }
-
- // repeated .caffe.V1LayerParameter.DimCheckMode blob_share_mode = 1002;
- {
- size_t data_size = 0;
- unsigned int count = this->blob_share_mode_size();for (unsigned int i = 0; i < count; i++) {
- data_size += ::google::protobuf::internal::WireFormatLite::EnumSize(
- this->blob_share_mode(i));
- }
- total_size += (2UL * count) + data_size;
- }
-
- // repeated float blobs_lr = 7;
- {
- size_t data_size = 0;
- unsigned int count = this->blobs_lr_size();
- data_size = 4UL * count;
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->blobs_lr_size());
- total_size += data_size;
- }
-
- // repeated float weight_decay = 8;
- {
- size_t data_size = 0;
- unsigned int count = this->weight_decay_size();
- data_size = 4UL * count;
- total_size += 1 *
- ::google::protobuf::internal::FromIntSize(this->weight_decay_size());
- total_size += data_size;
- }
-
- // repeated float loss_weight = 35;
- {
- size_t data_size = 0;
- unsigned int count = this->loss_weight_size();
- data_size = 4UL * count;
- total_size += 2 *
- ::google::protobuf::internal::FromIntSize(this->loss_weight_size());
- total_size += data_size;
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void V1LayerParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.V1LayerParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const V1LayerParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const V1LayerParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.V1LayerParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.V1LayerParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void V1LayerParameter::MergeFrom(const V1LayerParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.V1LayerParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void V1LayerParameter::UnsafeMergeFrom(const V1LayerParameter& from) {
- GOOGLE_DCHECK(&from != this);
- bottom_.UnsafeMergeFrom(from.bottom_);
- top_.UnsafeMergeFrom(from.top_);
- include_.MergeFrom(from.include_);
- exclude_.MergeFrom(from.exclude_);
- blobs_.MergeFrom(from.blobs_);
- param_.UnsafeMergeFrom(from.param_);
- blob_share_mode_.UnsafeMergeFrom(from.blob_share_mode_);
- blobs_lr_.UnsafeMergeFrom(from.blobs_lr_);
- weight_decay_.UnsafeMergeFrom(from.weight_decay_);
- loss_weight_.UnsafeMergeFrom(from.loss_weight_);
- if (from._has_bits_[2 / 32] & (0xffu << (2 % 32))) {
- if (from.has_name()) {
- set_has_name();
- name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
- }
- if (from.has_type()) {
- set_type(from.type());
- }
- }
- if (from._has_bits_[12 / 32] & (0xffu << (12 % 32))) {
- if (from.has_accuracy_param()) {
- mutable_accuracy_param()->::caffe::AccuracyParameter::MergeFrom(from.accuracy_param());
- }
- if (from.has_argmax_param()) {
- mutable_argmax_param()->::caffe::ArgMaxParameter::MergeFrom(from.argmax_param());
- }
- if (from.has_concat_param()) {
- mutable_concat_param()->::caffe::ConcatParameter::MergeFrom(from.concat_param());
- }
- if (from.has_contrastive_loss_param()) {
- mutable_contrastive_loss_param()->::caffe::ContrastiveLossParameter::MergeFrom(from.contrastive_loss_param());
- }
- }
- if (from._has_bits_[16 / 32] & (0xffu << (16 % 32))) {
- if (from.has_convolution_param()) {
- mutable_convolution_param()->::caffe::ConvolutionParameter::MergeFrom(from.convolution_param());
- }
- if (from.has_data_param()) {
- mutable_data_param()->::caffe::DataParameter::MergeFrom(from.data_param());
- }
- if (from.has_dropout_param()) {
- mutable_dropout_param()->::caffe::DropoutParameter::MergeFrom(from.dropout_param());
- }
- if (from.has_dummy_data_param()) {
- mutable_dummy_data_param()->::caffe::DummyDataParameter::MergeFrom(from.dummy_data_param());
- }
- if (from.has_eltwise_param()) {
- mutable_eltwise_param()->::caffe::EltwiseParameter::MergeFrom(from.eltwise_param());
- }
- if (from.has_exp_param()) {
- mutable_exp_param()->::caffe::ExpParameter::MergeFrom(from.exp_param());
- }
- if (from.has_hdf5_data_param()) {
- mutable_hdf5_data_param()->::caffe::HDF5DataParameter::MergeFrom(from.hdf5_data_param());
- }
- if (from.has_hdf5_output_param()) {
- mutable_hdf5_output_param()->::caffe::HDF5OutputParameter::MergeFrom(from.hdf5_output_param());
- }
- }
- if (from._has_bits_[24 / 32] & (0xffu << (24 % 32))) {
- if (from.has_hinge_loss_param()) {
- mutable_hinge_loss_param()->::caffe::HingeLossParameter::MergeFrom(from.hinge_loss_param());
- }
- if (from.has_image_data_param()) {
- mutable_image_data_param()->::caffe::ImageDataParameter::MergeFrom(from.image_data_param());
- }
- if (from.has_infogain_loss_param()) {
- mutable_infogain_loss_param()->::caffe::InfogainLossParameter::MergeFrom(from.infogain_loss_param());
- }
- if (from.has_inner_product_param()) {
- mutable_inner_product_param()->::caffe::InnerProductParameter::MergeFrom(from.inner_product_param());
- }
- if (from.has_lrn_param()) {
- mutable_lrn_param()->::caffe::LRNParameter::MergeFrom(from.lrn_param());
- }
- if (from.has_memory_data_param()) {
- mutable_memory_data_param()->::caffe::MemoryDataParameter::MergeFrom(from.memory_data_param());
- }
- if (from.has_mvn_param()) {
- mutable_mvn_param()->::caffe::MVNParameter::MergeFrom(from.mvn_param());
- }
- if (from.has_pooling_param()) {
- mutable_pooling_param()->::caffe::PoolingParameter::MergeFrom(from.pooling_param());
- }
- }
- if (from._has_bits_[32 / 32] & (0xffu << (32 % 32))) {
- if (from.has_power_param()) {
- mutable_power_param()->::caffe::PowerParameter::MergeFrom(from.power_param());
- }
- if (from.has_relu_param()) {
- mutable_relu_param()->::caffe::ReLUParameter::MergeFrom(from.relu_param());
- }
- if (from.has_sigmoid_param()) {
- mutable_sigmoid_param()->::caffe::SigmoidParameter::MergeFrom(from.sigmoid_param());
- }
- if (from.has_softmax_param()) {
- mutable_softmax_param()->::caffe::SoftmaxParameter::MergeFrom(from.softmax_param());
- }
- if (from.has_slice_param()) {
- mutable_slice_param()->::caffe::SliceParameter::MergeFrom(from.slice_param());
- }
- if (from.has_tanh_param()) {
- mutable_tanh_param()->::caffe::TanHParameter::MergeFrom(from.tanh_param());
- }
- if (from.has_threshold_param()) {
- mutable_threshold_param()->::caffe::ThresholdParameter::MergeFrom(from.threshold_param());
- }
- if (from.has_window_data_param()) {
- mutable_window_data_param()->::caffe::WindowDataParameter::MergeFrom(from.window_data_param());
- }
- }
- if (from._has_bits_[40 / 32] & (0xffu << (40 % 32))) {
- if (from.has_transform_param()) {
- mutable_transform_param()->::caffe::TransformationParameter::MergeFrom(from.transform_param());
- }
- if (from.has_loss_param()) {
- mutable_loss_param()->::caffe::LossParameter::MergeFrom(from.loss_param());
- }
- if (from.has_layer()) {
- mutable_layer()->::caffe::V0LayerParameter::MergeFrom(from.layer());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void V1LayerParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.V1LayerParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void V1LayerParameter::CopyFrom(const V1LayerParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.V1LayerParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool V1LayerParameter::IsInitialized() const {
-
- return true;
-}
-
-void V1LayerParameter::Swap(V1LayerParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void V1LayerParameter::InternalSwap(V1LayerParameter* other) {
- bottom_.UnsafeArenaSwap(&other->bottom_);
- top_.UnsafeArenaSwap(&other->top_);
- name_.Swap(&other->name_);
- include_.UnsafeArenaSwap(&other->include_);
- exclude_.UnsafeArenaSwap(&other->exclude_);
- std::swap(type_, other->type_);
- blobs_.UnsafeArenaSwap(&other->blobs_);
- param_.UnsafeArenaSwap(&other->param_);
- blob_share_mode_.UnsafeArenaSwap(&other->blob_share_mode_);
- blobs_lr_.UnsafeArenaSwap(&other->blobs_lr_);
- weight_decay_.UnsafeArenaSwap(&other->weight_decay_);
- loss_weight_.UnsafeArenaSwap(&other->loss_weight_);
- std::swap(accuracy_param_, other->accuracy_param_);
- std::swap(argmax_param_, other->argmax_param_);
- std::swap(concat_param_, other->concat_param_);
- std::swap(contrastive_loss_param_, other->contrastive_loss_param_);
- std::swap(convolution_param_, other->convolution_param_);
- std::swap(data_param_, other->data_param_);
- std::swap(dropout_param_, other->dropout_param_);
- std::swap(dummy_data_param_, other->dummy_data_param_);
- std::swap(eltwise_param_, other->eltwise_param_);
- std::swap(exp_param_, other->exp_param_);
- std::swap(hdf5_data_param_, other->hdf5_data_param_);
- std::swap(hdf5_output_param_, other->hdf5_output_param_);
- std::swap(hinge_loss_param_, other->hinge_loss_param_);
- std::swap(image_data_param_, other->image_data_param_);
- std::swap(infogain_loss_param_, other->infogain_loss_param_);
- std::swap(inner_product_param_, other->inner_product_param_);
- std::swap(lrn_param_, other->lrn_param_);
- std::swap(memory_data_param_, other->memory_data_param_);
- std::swap(mvn_param_, other->mvn_param_);
- std::swap(pooling_param_, other->pooling_param_);
- std::swap(power_param_, other->power_param_);
- std::swap(relu_param_, other->relu_param_);
- std::swap(sigmoid_param_, other->sigmoid_param_);
- std::swap(softmax_param_, other->softmax_param_);
- std::swap(slice_param_, other->slice_param_);
- std::swap(tanh_param_, other->tanh_param_);
- std::swap(threshold_param_, other->threshold_param_);
- std::swap(window_data_param_, other->window_data_param_);
- std::swap(transform_param_, other->transform_param_);
- std::swap(loss_param_, other->loss_param_);
- std::swap(layer_, other->layer_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- std::swap(_has_bits_[1], other->_has_bits_[1]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata V1LayerParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = V1LayerParameter_descriptor_;
- metadata.reflection = V1LayerParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// V1LayerParameter
-
-// repeated string bottom = 2;
-int V1LayerParameter::bottom_size() const {
- return bottom_.size();
-}
-void V1LayerParameter::clear_bottom() {
- bottom_.Clear();
-}
-const ::std::string& V1LayerParameter::bottom(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.bottom)
- return bottom_.Get(index);
-}
-::std::string* V1LayerParameter::mutable_bottom(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.bottom)
- return bottom_.Mutable(index);
-}
-void V1LayerParameter::set_bottom(int index, const ::std::string& value) {
- // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.bottom)
- bottom_.Mutable(index)->assign(value);
-}
-void V1LayerParameter::set_bottom(int index, const char* value) {
- bottom_.Mutable(index)->assign(value);
- // @@protoc_insertion_point(field_set_char:caffe.V1LayerParameter.bottom)
-}
-void V1LayerParameter::set_bottom(int index, const char* value, size_t size) {
- bottom_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:caffe.V1LayerParameter.bottom)
-}
-::std::string* V1LayerParameter::add_bottom() {
- // @@protoc_insertion_point(field_add_mutable:caffe.V1LayerParameter.bottom)
- return bottom_.Add();
-}
-void V1LayerParameter::add_bottom(const ::std::string& value) {
- bottom_.Add()->assign(value);
- // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.bottom)
-}
-void V1LayerParameter::add_bottom(const char* value) {
- bottom_.Add()->assign(value);
- // @@protoc_insertion_point(field_add_char:caffe.V1LayerParameter.bottom)
-}
-void V1LayerParameter::add_bottom(const char* value, size_t size) {
- bottom_.Add()->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_add_pointer:caffe.V1LayerParameter.bottom)
-}
-const ::google::protobuf::RepeatedPtrField< ::std::string>&
-V1LayerParameter::bottom() const {
- // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.bottom)
- return bottom_;
-}
-::google::protobuf::RepeatedPtrField< ::std::string>*
-V1LayerParameter::mutable_bottom() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.bottom)
- return &bottom_;
-}
-
-// repeated string top = 3;
-int V1LayerParameter::top_size() const {
- return top_.size();
-}
-void V1LayerParameter::clear_top() {
- top_.Clear();
-}
-const ::std::string& V1LayerParameter::top(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.top)
- return top_.Get(index);
-}
-::std::string* V1LayerParameter::mutable_top(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.top)
- return top_.Mutable(index);
-}
-void V1LayerParameter::set_top(int index, const ::std::string& value) {
- // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.top)
- top_.Mutable(index)->assign(value);
-}
-void V1LayerParameter::set_top(int index, const char* value) {
- top_.Mutable(index)->assign(value);
- // @@protoc_insertion_point(field_set_char:caffe.V1LayerParameter.top)
-}
-void V1LayerParameter::set_top(int index, const char* value, size_t size) {
- top_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:caffe.V1LayerParameter.top)
-}
-::std::string* V1LayerParameter::add_top() {
- // @@protoc_insertion_point(field_add_mutable:caffe.V1LayerParameter.top)
- return top_.Add();
-}
-void V1LayerParameter::add_top(const ::std::string& value) {
- top_.Add()->assign(value);
- // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.top)
-}
-void V1LayerParameter::add_top(const char* value) {
- top_.Add()->assign(value);
- // @@protoc_insertion_point(field_add_char:caffe.V1LayerParameter.top)
-}
-void V1LayerParameter::add_top(const char* value, size_t size) {
- top_.Add()->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_add_pointer:caffe.V1LayerParameter.top)
-}
-const ::google::protobuf::RepeatedPtrField< ::std::string>&
-V1LayerParameter::top() const {
- // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.top)
- return top_;
-}
-::google::protobuf::RepeatedPtrField< ::std::string>*
-V1LayerParameter::mutable_top() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.top)
- return &top_;
-}
-
-// optional string name = 4;
-bool V1LayerParameter::has_name() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void V1LayerParameter::set_has_name() {
- _has_bits_[0] |= 0x00000004u;
-}
-void V1LayerParameter::clear_has_name() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void V1LayerParameter::clear_name() {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_name();
-}
-const ::std::string& V1LayerParameter::name() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void V1LayerParameter::set_name(const ::std::string& value) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.name)
-}
-void V1LayerParameter::set_name(const char* value) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.V1LayerParameter.name)
-}
-void V1LayerParameter::set_name(const char* value, size_t size) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.V1LayerParameter.name)
-}
-::std::string* V1LayerParameter::mutable_name() {
- set_has_name();
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.name)
- return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* V1LayerParameter::release_name() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.name)
- clear_has_name();
- return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void V1LayerParameter::set_allocated_name(::std::string* name) {
- if (name != NULL) {
- set_has_name();
- } else {
- clear_has_name();
- }
- name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.name)
-}
-
-// repeated .caffe.NetStateRule include = 32;
-int V1LayerParameter::include_size() const {
- return include_.size();
-}
-void V1LayerParameter::clear_include() {
- include_.Clear();
-}
-const ::caffe::NetStateRule& V1LayerParameter::include(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.include)
- return include_.Get(index);
-}
-::caffe::NetStateRule* V1LayerParameter::mutable_include(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.include)
- return include_.Mutable(index);
-}
-::caffe::NetStateRule* V1LayerParameter::add_include() {
- // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.include)
- return include_.Add();
-}
-::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >*
-V1LayerParameter::mutable_include() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.include)
- return &include_;
-}
-const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >&
-V1LayerParameter::include() const {
- // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.include)
- return include_;
-}
-
-// repeated .caffe.NetStateRule exclude = 33;
-int V1LayerParameter::exclude_size() const {
- return exclude_.size();
-}
-void V1LayerParameter::clear_exclude() {
- exclude_.Clear();
-}
-const ::caffe::NetStateRule& V1LayerParameter::exclude(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.exclude)
- return exclude_.Get(index);
-}
-::caffe::NetStateRule* V1LayerParameter::mutable_exclude(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.exclude)
- return exclude_.Mutable(index);
-}
-::caffe::NetStateRule* V1LayerParameter::add_exclude() {
- // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.exclude)
- return exclude_.Add();
-}
-::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >*
-V1LayerParameter::mutable_exclude() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.exclude)
- return &exclude_;
-}
-const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >&
-V1LayerParameter::exclude() const {
- // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.exclude)
- return exclude_;
-}
-
-// optional .caffe.V1LayerParameter.LayerType type = 5;
-bool V1LayerParameter::has_type() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-void V1LayerParameter::set_has_type() {
- _has_bits_[0] |= 0x00000020u;
-}
-void V1LayerParameter::clear_has_type() {
- _has_bits_[0] &= ~0x00000020u;
-}
-void V1LayerParameter::clear_type() {
- type_ = 0;
- clear_has_type();
-}
-::caffe::V1LayerParameter_LayerType V1LayerParameter::type() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.type)
- return static_cast< ::caffe::V1LayerParameter_LayerType >(type_);
-}
-void V1LayerParameter::set_type(::caffe::V1LayerParameter_LayerType value) {
- assert(::caffe::V1LayerParameter_LayerType_IsValid(value));
- set_has_type();
- type_ = value;
- // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.type)
-}
-
-// repeated .caffe.BlobProto blobs = 6;
-int V1LayerParameter::blobs_size() const {
- return blobs_.size();
-}
-void V1LayerParameter::clear_blobs() {
- blobs_.Clear();
-}
-const ::caffe::BlobProto& V1LayerParameter::blobs(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.blobs)
- return blobs_.Get(index);
-}
-::caffe::BlobProto* V1LayerParameter::mutable_blobs(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.blobs)
- return blobs_.Mutable(index);
-}
-::caffe::BlobProto* V1LayerParameter::add_blobs() {
- // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.blobs)
- return blobs_.Add();
-}
-::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
-V1LayerParameter::mutable_blobs() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.blobs)
- return &blobs_;
-}
-const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
-V1LayerParameter::blobs() const {
- // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.blobs)
- return blobs_;
-}
-
-// repeated string param = 1001;
-int V1LayerParameter::param_size() const {
- return param_.size();
-}
-void V1LayerParameter::clear_param() {
- param_.Clear();
-}
-const ::std::string& V1LayerParameter::param(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.param)
- return param_.Get(index);
-}
-::std::string* V1LayerParameter::mutable_param(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.param)
- return param_.Mutable(index);
-}
-void V1LayerParameter::set_param(int index, const ::std::string& value) {
- // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.param)
- param_.Mutable(index)->assign(value);
-}
-void V1LayerParameter::set_param(int index, const char* value) {
- param_.Mutable(index)->assign(value);
- // @@protoc_insertion_point(field_set_char:caffe.V1LayerParameter.param)
-}
-void V1LayerParameter::set_param(int index, const char* value, size_t size) {
- param_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:caffe.V1LayerParameter.param)
-}
-::std::string* V1LayerParameter::add_param() {
- // @@protoc_insertion_point(field_add_mutable:caffe.V1LayerParameter.param)
- return param_.Add();
-}
-void V1LayerParameter::add_param(const ::std::string& value) {
- param_.Add()->assign(value);
- // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.param)
-}
-void V1LayerParameter::add_param(const char* value) {
- param_.Add()->assign(value);
- // @@protoc_insertion_point(field_add_char:caffe.V1LayerParameter.param)
-}
-void V1LayerParameter::add_param(const char* value, size_t size) {
- param_.Add()->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_add_pointer:caffe.V1LayerParameter.param)
-}
-const ::google::protobuf::RepeatedPtrField< ::std::string>&
-V1LayerParameter::param() const {
- // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.param)
- return param_;
-}
-::google::protobuf::RepeatedPtrField< ::std::string>*
-V1LayerParameter::mutable_param() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.param)
- return ¶m_;
-}
-
-// repeated .caffe.V1LayerParameter.DimCheckMode blob_share_mode = 1002;
-int V1LayerParameter::blob_share_mode_size() const {
- return blob_share_mode_.size();
-}
-void V1LayerParameter::clear_blob_share_mode() {
- blob_share_mode_.Clear();
-}
-::caffe::V1LayerParameter_DimCheckMode V1LayerParameter::blob_share_mode(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.blob_share_mode)
- return static_cast< ::caffe::V1LayerParameter_DimCheckMode >(blob_share_mode_.Get(index));
-}
-void V1LayerParameter::set_blob_share_mode(int index, ::caffe::V1LayerParameter_DimCheckMode value) {
- assert(::caffe::V1LayerParameter_DimCheckMode_IsValid(value));
- blob_share_mode_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.blob_share_mode)
-}
-void V1LayerParameter::add_blob_share_mode(::caffe::V1LayerParameter_DimCheckMode value) {
- assert(::caffe::V1LayerParameter_DimCheckMode_IsValid(value));
- blob_share_mode_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.blob_share_mode)
-}
-const ::google::protobuf::RepeatedField<int>&
-V1LayerParameter::blob_share_mode() const {
- // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.blob_share_mode)
- return blob_share_mode_;
-}
-::google::protobuf::RepeatedField<int>*
-V1LayerParameter::mutable_blob_share_mode() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.blob_share_mode)
- return &blob_share_mode_;
-}
-
-// repeated float blobs_lr = 7;
-int V1LayerParameter::blobs_lr_size() const {
- return blobs_lr_.size();
-}
-void V1LayerParameter::clear_blobs_lr() {
- blobs_lr_.Clear();
-}
-float V1LayerParameter::blobs_lr(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.blobs_lr)
- return blobs_lr_.Get(index);
-}
-void V1LayerParameter::set_blobs_lr(int index, float value) {
- blobs_lr_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.blobs_lr)
-}
-void V1LayerParameter::add_blobs_lr(float value) {
- blobs_lr_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.blobs_lr)
-}
-const ::google::protobuf::RepeatedField< float >&
-V1LayerParameter::blobs_lr() const {
- // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.blobs_lr)
- return blobs_lr_;
-}
-::google::protobuf::RepeatedField< float >*
-V1LayerParameter::mutable_blobs_lr() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.blobs_lr)
- return &blobs_lr_;
-}
-
-// repeated float weight_decay = 8;
-int V1LayerParameter::weight_decay_size() const {
- return weight_decay_.size();
-}
-void V1LayerParameter::clear_weight_decay() {
- weight_decay_.Clear();
-}
-float V1LayerParameter::weight_decay(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.weight_decay)
- return weight_decay_.Get(index);
-}
-void V1LayerParameter::set_weight_decay(int index, float value) {
- weight_decay_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.weight_decay)
-}
-void V1LayerParameter::add_weight_decay(float value) {
- weight_decay_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.weight_decay)
-}
-const ::google::protobuf::RepeatedField< float >&
-V1LayerParameter::weight_decay() const {
- // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.weight_decay)
- return weight_decay_;
-}
-::google::protobuf::RepeatedField< float >*
-V1LayerParameter::mutable_weight_decay() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.weight_decay)
- return &weight_decay_;
-}
-
-// repeated float loss_weight = 35;
-int V1LayerParameter::loss_weight_size() const {
- return loss_weight_.size();
-}
-void V1LayerParameter::clear_loss_weight() {
- loss_weight_.Clear();
-}
-float V1LayerParameter::loss_weight(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.loss_weight)
- return loss_weight_.Get(index);
-}
-void V1LayerParameter::set_loss_weight(int index, float value) {
- loss_weight_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.loss_weight)
-}
-void V1LayerParameter::add_loss_weight(float value) {
- loss_weight_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.loss_weight)
-}
-const ::google::protobuf::RepeatedField< float >&
-V1LayerParameter::loss_weight() const {
- // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.loss_weight)
- return loss_weight_;
-}
-::google::protobuf::RepeatedField< float >*
-V1LayerParameter::mutable_loss_weight() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.loss_weight)
- return &loss_weight_;
-}
-
-// optional .caffe.AccuracyParameter accuracy_param = 27;
-bool V1LayerParameter::has_accuracy_param() const {
- return (_has_bits_[0] & 0x00001000u) != 0;
-}
-void V1LayerParameter::set_has_accuracy_param() {
- _has_bits_[0] |= 0x00001000u;
-}
-void V1LayerParameter::clear_has_accuracy_param() {
- _has_bits_[0] &= ~0x00001000u;
-}
-void V1LayerParameter::clear_accuracy_param() {
- if (accuracy_param_ != NULL) accuracy_param_->::caffe::AccuracyParameter::Clear();
- clear_has_accuracy_param();
-}
-const ::caffe::AccuracyParameter& V1LayerParameter::accuracy_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.accuracy_param)
- return accuracy_param_ != NULL ? *accuracy_param_
- : *::caffe::AccuracyParameter::internal_default_instance();
-}
-::caffe::AccuracyParameter* V1LayerParameter::mutable_accuracy_param() {
- set_has_accuracy_param();
- if (accuracy_param_ == NULL) {
- accuracy_param_ = new ::caffe::AccuracyParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.accuracy_param)
- return accuracy_param_;
-}
-::caffe::AccuracyParameter* V1LayerParameter::release_accuracy_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.accuracy_param)
- clear_has_accuracy_param();
- ::caffe::AccuracyParameter* temp = accuracy_param_;
- accuracy_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_accuracy_param(::caffe::AccuracyParameter* accuracy_param) {
- delete accuracy_param_;
- accuracy_param_ = accuracy_param;
- if (accuracy_param) {
- set_has_accuracy_param();
- } else {
- clear_has_accuracy_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.accuracy_param)
-}
-
-// optional .caffe.ArgMaxParameter argmax_param = 23;
-bool V1LayerParameter::has_argmax_param() const {
- return (_has_bits_[0] & 0x00002000u) != 0;
-}
-void V1LayerParameter::set_has_argmax_param() {
- _has_bits_[0] |= 0x00002000u;
-}
-void V1LayerParameter::clear_has_argmax_param() {
- _has_bits_[0] &= ~0x00002000u;
-}
-void V1LayerParameter::clear_argmax_param() {
- if (argmax_param_ != NULL) argmax_param_->::caffe::ArgMaxParameter::Clear();
- clear_has_argmax_param();
-}
-const ::caffe::ArgMaxParameter& V1LayerParameter::argmax_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.argmax_param)
- return argmax_param_ != NULL ? *argmax_param_
- : *::caffe::ArgMaxParameter::internal_default_instance();
-}
-::caffe::ArgMaxParameter* V1LayerParameter::mutable_argmax_param() {
- set_has_argmax_param();
- if (argmax_param_ == NULL) {
- argmax_param_ = new ::caffe::ArgMaxParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.argmax_param)
- return argmax_param_;
-}
-::caffe::ArgMaxParameter* V1LayerParameter::release_argmax_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.argmax_param)
- clear_has_argmax_param();
- ::caffe::ArgMaxParameter* temp = argmax_param_;
- argmax_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_argmax_param(::caffe::ArgMaxParameter* argmax_param) {
- delete argmax_param_;
- argmax_param_ = argmax_param;
- if (argmax_param) {
- set_has_argmax_param();
- } else {
- clear_has_argmax_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.argmax_param)
-}
-
-// optional .caffe.ConcatParameter concat_param = 9;
-bool V1LayerParameter::has_concat_param() const {
- return (_has_bits_[0] & 0x00004000u) != 0;
-}
-void V1LayerParameter::set_has_concat_param() {
- _has_bits_[0] |= 0x00004000u;
-}
-void V1LayerParameter::clear_has_concat_param() {
- _has_bits_[0] &= ~0x00004000u;
-}
-void V1LayerParameter::clear_concat_param() {
- if (concat_param_ != NULL) concat_param_->::caffe::ConcatParameter::Clear();
- clear_has_concat_param();
-}
-const ::caffe::ConcatParameter& V1LayerParameter::concat_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.concat_param)
- return concat_param_ != NULL ? *concat_param_
- : *::caffe::ConcatParameter::internal_default_instance();
-}
-::caffe::ConcatParameter* V1LayerParameter::mutable_concat_param() {
- set_has_concat_param();
- if (concat_param_ == NULL) {
- concat_param_ = new ::caffe::ConcatParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.concat_param)
- return concat_param_;
-}
-::caffe::ConcatParameter* V1LayerParameter::release_concat_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.concat_param)
- clear_has_concat_param();
- ::caffe::ConcatParameter* temp = concat_param_;
- concat_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_concat_param(::caffe::ConcatParameter* concat_param) {
- delete concat_param_;
- concat_param_ = concat_param;
- if (concat_param) {
- set_has_concat_param();
- } else {
- clear_has_concat_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.concat_param)
-}
-
-// optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40;
-bool V1LayerParameter::has_contrastive_loss_param() const {
- return (_has_bits_[0] & 0x00008000u) != 0;
-}
-void V1LayerParameter::set_has_contrastive_loss_param() {
- _has_bits_[0] |= 0x00008000u;
-}
-void V1LayerParameter::clear_has_contrastive_loss_param() {
- _has_bits_[0] &= ~0x00008000u;
-}
-void V1LayerParameter::clear_contrastive_loss_param() {
- if (contrastive_loss_param_ != NULL) contrastive_loss_param_->::caffe::ContrastiveLossParameter::Clear();
- clear_has_contrastive_loss_param();
-}
-const ::caffe::ContrastiveLossParameter& V1LayerParameter::contrastive_loss_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.contrastive_loss_param)
- return contrastive_loss_param_ != NULL ? *contrastive_loss_param_
- : *::caffe::ContrastiveLossParameter::internal_default_instance();
-}
-::caffe::ContrastiveLossParameter* V1LayerParameter::mutable_contrastive_loss_param() {
- set_has_contrastive_loss_param();
- if (contrastive_loss_param_ == NULL) {
- contrastive_loss_param_ = new ::caffe::ContrastiveLossParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.contrastive_loss_param)
- return contrastive_loss_param_;
-}
-::caffe::ContrastiveLossParameter* V1LayerParameter::release_contrastive_loss_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.contrastive_loss_param)
- clear_has_contrastive_loss_param();
- ::caffe::ContrastiveLossParameter* temp = contrastive_loss_param_;
- contrastive_loss_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_contrastive_loss_param(::caffe::ContrastiveLossParameter* contrastive_loss_param) {
- delete contrastive_loss_param_;
- contrastive_loss_param_ = contrastive_loss_param;
- if (contrastive_loss_param) {
- set_has_contrastive_loss_param();
- } else {
- clear_has_contrastive_loss_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.contrastive_loss_param)
-}
-
-// optional .caffe.ConvolutionParameter convolution_param = 10;
-bool V1LayerParameter::has_convolution_param() const {
- return (_has_bits_[0] & 0x00010000u) != 0;
-}
-void V1LayerParameter::set_has_convolution_param() {
- _has_bits_[0] |= 0x00010000u;
-}
-void V1LayerParameter::clear_has_convolution_param() {
- _has_bits_[0] &= ~0x00010000u;
-}
-void V1LayerParameter::clear_convolution_param() {
- if (convolution_param_ != NULL) convolution_param_->::caffe::ConvolutionParameter::Clear();
- clear_has_convolution_param();
-}
-const ::caffe::ConvolutionParameter& V1LayerParameter::convolution_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.convolution_param)
- return convolution_param_ != NULL ? *convolution_param_
- : *::caffe::ConvolutionParameter::internal_default_instance();
-}
-::caffe::ConvolutionParameter* V1LayerParameter::mutable_convolution_param() {
- set_has_convolution_param();
- if (convolution_param_ == NULL) {
- convolution_param_ = new ::caffe::ConvolutionParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.convolution_param)
- return convolution_param_;
-}
-::caffe::ConvolutionParameter* V1LayerParameter::release_convolution_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.convolution_param)
- clear_has_convolution_param();
- ::caffe::ConvolutionParameter* temp = convolution_param_;
- convolution_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_convolution_param(::caffe::ConvolutionParameter* convolution_param) {
- delete convolution_param_;
- convolution_param_ = convolution_param;
- if (convolution_param) {
- set_has_convolution_param();
- } else {
- clear_has_convolution_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.convolution_param)
-}
-
-// optional .caffe.DataParameter data_param = 11;
-bool V1LayerParameter::has_data_param() const {
- return (_has_bits_[0] & 0x00020000u) != 0;
-}
-void V1LayerParameter::set_has_data_param() {
- _has_bits_[0] |= 0x00020000u;
-}
-void V1LayerParameter::clear_has_data_param() {
- _has_bits_[0] &= ~0x00020000u;
-}
-void V1LayerParameter::clear_data_param() {
- if (data_param_ != NULL) data_param_->::caffe::DataParameter::Clear();
- clear_has_data_param();
-}
-const ::caffe::DataParameter& V1LayerParameter::data_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.data_param)
- return data_param_ != NULL ? *data_param_
- : *::caffe::DataParameter::internal_default_instance();
-}
-::caffe::DataParameter* V1LayerParameter::mutable_data_param() {
- set_has_data_param();
- if (data_param_ == NULL) {
- data_param_ = new ::caffe::DataParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.data_param)
- return data_param_;
-}
-::caffe::DataParameter* V1LayerParameter::release_data_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.data_param)
- clear_has_data_param();
- ::caffe::DataParameter* temp = data_param_;
- data_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_data_param(::caffe::DataParameter* data_param) {
- delete data_param_;
- data_param_ = data_param;
- if (data_param) {
- set_has_data_param();
- } else {
- clear_has_data_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.data_param)
-}
-
-// optional .caffe.DropoutParameter dropout_param = 12;
-bool V1LayerParameter::has_dropout_param() const {
- return (_has_bits_[0] & 0x00040000u) != 0;
-}
-void V1LayerParameter::set_has_dropout_param() {
- _has_bits_[0] |= 0x00040000u;
-}
-void V1LayerParameter::clear_has_dropout_param() {
- _has_bits_[0] &= ~0x00040000u;
-}
-void V1LayerParameter::clear_dropout_param() {
- if (dropout_param_ != NULL) dropout_param_->::caffe::DropoutParameter::Clear();
- clear_has_dropout_param();
-}
-const ::caffe::DropoutParameter& V1LayerParameter::dropout_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.dropout_param)
- return dropout_param_ != NULL ? *dropout_param_
- : *::caffe::DropoutParameter::internal_default_instance();
-}
-::caffe::DropoutParameter* V1LayerParameter::mutable_dropout_param() {
- set_has_dropout_param();
- if (dropout_param_ == NULL) {
- dropout_param_ = new ::caffe::DropoutParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.dropout_param)
- return dropout_param_;
-}
-::caffe::DropoutParameter* V1LayerParameter::release_dropout_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.dropout_param)
- clear_has_dropout_param();
- ::caffe::DropoutParameter* temp = dropout_param_;
- dropout_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_dropout_param(::caffe::DropoutParameter* dropout_param) {
- delete dropout_param_;
- dropout_param_ = dropout_param;
- if (dropout_param) {
- set_has_dropout_param();
- } else {
- clear_has_dropout_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.dropout_param)
-}
-
-// optional .caffe.DummyDataParameter dummy_data_param = 26;
-bool V1LayerParameter::has_dummy_data_param() const {
- return (_has_bits_[0] & 0x00080000u) != 0;
-}
-void V1LayerParameter::set_has_dummy_data_param() {
- _has_bits_[0] |= 0x00080000u;
-}
-void V1LayerParameter::clear_has_dummy_data_param() {
- _has_bits_[0] &= ~0x00080000u;
-}
-void V1LayerParameter::clear_dummy_data_param() {
- if (dummy_data_param_ != NULL) dummy_data_param_->::caffe::DummyDataParameter::Clear();
- clear_has_dummy_data_param();
-}
-const ::caffe::DummyDataParameter& V1LayerParameter::dummy_data_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.dummy_data_param)
- return dummy_data_param_ != NULL ? *dummy_data_param_
- : *::caffe::DummyDataParameter::internal_default_instance();
-}
-::caffe::DummyDataParameter* V1LayerParameter::mutable_dummy_data_param() {
- set_has_dummy_data_param();
- if (dummy_data_param_ == NULL) {
- dummy_data_param_ = new ::caffe::DummyDataParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.dummy_data_param)
- return dummy_data_param_;
-}
-::caffe::DummyDataParameter* V1LayerParameter::release_dummy_data_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.dummy_data_param)
- clear_has_dummy_data_param();
- ::caffe::DummyDataParameter* temp = dummy_data_param_;
- dummy_data_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_dummy_data_param(::caffe::DummyDataParameter* dummy_data_param) {
- delete dummy_data_param_;
- dummy_data_param_ = dummy_data_param;
- if (dummy_data_param) {
- set_has_dummy_data_param();
- } else {
- clear_has_dummy_data_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.dummy_data_param)
-}
-
-// optional .caffe.EltwiseParameter eltwise_param = 24;
-bool V1LayerParameter::has_eltwise_param() const {
- return (_has_bits_[0] & 0x00100000u) != 0;
-}
-void V1LayerParameter::set_has_eltwise_param() {
- _has_bits_[0] |= 0x00100000u;
-}
-void V1LayerParameter::clear_has_eltwise_param() {
- _has_bits_[0] &= ~0x00100000u;
-}
-void V1LayerParameter::clear_eltwise_param() {
- if (eltwise_param_ != NULL) eltwise_param_->::caffe::EltwiseParameter::Clear();
- clear_has_eltwise_param();
-}
-const ::caffe::EltwiseParameter& V1LayerParameter::eltwise_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.eltwise_param)
- return eltwise_param_ != NULL ? *eltwise_param_
- : *::caffe::EltwiseParameter::internal_default_instance();
-}
-::caffe::EltwiseParameter* V1LayerParameter::mutable_eltwise_param() {
- set_has_eltwise_param();
- if (eltwise_param_ == NULL) {
- eltwise_param_ = new ::caffe::EltwiseParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.eltwise_param)
- return eltwise_param_;
-}
-::caffe::EltwiseParameter* V1LayerParameter::release_eltwise_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.eltwise_param)
- clear_has_eltwise_param();
- ::caffe::EltwiseParameter* temp = eltwise_param_;
- eltwise_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_eltwise_param(::caffe::EltwiseParameter* eltwise_param) {
- delete eltwise_param_;
- eltwise_param_ = eltwise_param;
- if (eltwise_param) {
- set_has_eltwise_param();
- } else {
- clear_has_eltwise_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.eltwise_param)
-}
-
-// optional .caffe.ExpParameter exp_param = 41;
-bool V1LayerParameter::has_exp_param() const {
- return (_has_bits_[0] & 0x00200000u) != 0;
-}
-void V1LayerParameter::set_has_exp_param() {
- _has_bits_[0] |= 0x00200000u;
-}
-void V1LayerParameter::clear_has_exp_param() {
- _has_bits_[0] &= ~0x00200000u;
-}
-void V1LayerParameter::clear_exp_param() {
- if (exp_param_ != NULL) exp_param_->::caffe::ExpParameter::Clear();
- clear_has_exp_param();
-}
-const ::caffe::ExpParameter& V1LayerParameter::exp_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.exp_param)
- return exp_param_ != NULL ? *exp_param_
- : *::caffe::ExpParameter::internal_default_instance();
-}
-::caffe::ExpParameter* V1LayerParameter::mutable_exp_param() {
- set_has_exp_param();
- if (exp_param_ == NULL) {
- exp_param_ = new ::caffe::ExpParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.exp_param)
- return exp_param_;
-}
-::caffe::ExpParameter* V1LayerParameter::release_exp_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.exp_param)
- clear_has_exp_param();
- ::caffe::ExpParameter* temp = exp_param_;
- exp_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_exp_param(::caffe::ExpParameter* exp_param) {
- delete exp_param_;
- exp_param_ = exp_param;
- if (exp_param) {
- set_has_exp_param();
- } else {
- clear_has_exp_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.exp_param)
-}
-
-// optional .caffe.HDF5DataParameter hdf5_data_param = 13;
-bool V1LayerParameter::has_hdf5_data_param() const {
- return (_has_bits_[0] & 0x00400000u) != 0;
-}
-void V1LayerParameter::set_has_hdf5_data_param() {
- _has_bits_[0] |= 0x00400000u;
-}
-void V1LayerParameter::clear_has_hdf5_data_param() {
- _has_bits_[0] &= ~0x00400000u;
-}
-void V1LayerParameter::clear_hdf5_data_param() {
- if (hdf5_data_param_ != NULL) hdf5_data_param_->::caffe::HDF5DataParameter::Clear();
- clear_has_hdf5_data_param();
-}
-const ::caffe::HDF5DataParameter& V1LayerParameter::hdf5_data_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.hdf5_data_param)
- return hdf5_data_param_ != NULL ? *hdf5_data_param_
- : *::caffe::HDF5DataParameter::internal_default_instance();
-}
-::caffe::HDF5DataParameter* V1LayerParameter::mutable_hdf5_data_param() {
- set_has_hdf5_data_param();
- if (hdf5_data_param_ == NULL) {
- hdf5_data_param_ = new ::caffe::HDF5DataParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.hdf5_data_param)
- return hdf5_data_param_;
-}
-::caffe::HDF5DataParameter* V1LayerParameter::release_hdf5_data_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.hdf5_data_param)
- clear_has_hdf5_data_param();
- ::caffe::HDF5DataParameter* temp = hdf5_data_param_;
- hdf5_data_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_hdf5_data_param(::caffe::HDF5DataParameter* hdf5_data_param) {
- delete hdf5_data_param_;
- hdf5_data_param_ = hdf5_data_param;
- if (hdf5_data_param) {
- set_has_hdf5_data_param();
- } else {
- clear_has_hdf5_data_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.hdf5_data_param)
-}
-
-// optional .caffe.HDF5OutputParameter hdf5_output_param = 14;
-bool V1LayerParameter::has_hdf5_output_param() const {
- return (_has_bits_[0] & 0x00800000u) != 0;
-}
-void V1LayerParameter::set_has_hdf5_output_param() {
- _has_bits_[0] |= 0x00800000u;
-}
-void V1LayerParameter::clear_has_hdf5_output_param() {
- _has_bits_[0] &= ~0x00800000u;
-}
-void V1LayerParameter::clear_hdf5_output_param() {
- if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear();
- clear_has_hdf5_output_param();
-}
-const ::caffe::HDF5OutputParameter& V1LayerParameter::hdf5_output_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.hdf5_output_param)
- return hdf5_output_param_ != NULL ? *hdf5_output_param_
- : *::caffe::HDF5OutputParameter::internal_default_instance();
-}
-::caffe::HDF5OutputParameter* V1LayerParameter::mutable_hdf5_output_param() {
- set_has_hdf5_output_param();
- if (hdf5_output_param_ == NULL) {
- hdf5_output_param_ = new ::caffe::HDF5OutputParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.hdf5_output_param)
- return hdf5_output_param_;
-}
-::caffe::HDF5OutputParameter* V1LayerParameter::release_hdf5_output_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.hdf5_output_param)
- clear_has_hdf5_output_param();
- ::caffe::HDF5OutputParameter* temp = hdf5_output_param_;
- hdf5_output_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param) {
- delete hdf5_output_param_;
- hdf5_output_param_ = hdf5_output_param;
- if (hdf5_output_param) {
- set_has_hdf5_output_param();
- } else {
- clear_has_hdf5_output_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.hdf5_output_param)
-}
-
-// optional .caffe.HingeLossParameter hinge_loss_param = 29;
-bool V1LayerParameter::has_hinge_loss_param() const {
- return (_has_bits_[0] & 0x01000000u) != 0;
-}
-void V1LayerParameter::set_has_hinge_loss_param() {
- _has_bits_[0] |= 0x01000000u;
-}
-void V1LayerParameter::clear_has_hinge_loss_param() {
- _has_bits_[0] &= ~0x01000000u;
-}
-void V1LayerParameter::clear_hinge_loss_param() {
- if (hinge_loss_param_ != NULL) hinge_loss_param_->::caffe::HingeLossParameter::Clear();
- clear_has_hinge_loss_param();
-}
-const ::caffe::HingeLossParameter& V1LayerParameter::hinge_loss_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.hinge_loss_param)
- return hinge_loss_param_ != NULL ? *hinge_loss_param_
- : *::caffe::HingeLossParameter::internal_default_instance();
-}
-::caffe::HingeLossParameter* V1LayerParameter::mutable_hinge_loss_param() {
- set_has_hinge_loss_param();
- if (hinge_loss_param_ == NULL) {
- hinge_loss_param_ = new ::caffe::HingeLossParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.hinge_loss_param)
- return hinge_loss_param_;
-}
-::caffe::HingeLossParameter* V1LayerParameter::release_hinge_loss_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.hinge_loss_param)
- clear_has_hinge_loss_param();
- ::caffe::HingeLossParameter* temp = hinge_loss_param_;
- hinge_loss_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_hinge_loss_param(::caffe::HingeLossParameter* hinge_loss_param) {
- delete hinge_loss_param_;
- hinge_loss_param_ = hinge_loss_param;
- if (hinge_loss_param) {
- set_has_hinge_loss_param();
- } else {
- clear_has_hinge_loss_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.hinge_loss_param)
-}
-
-// optional .caffe.ImageDataParameter image_data_param = 15;
-bool V1LayerParameter::has_image_data_param() const {
- return (_has_bits_[0] & 0x02000000u) != 0;
-}
-void V1LayerParameter::set_has_image_data_param() {
- _has_bits_[0] |= 0x02000000u;
-}
-void V1LayerParameter::clear_has_image_data_param() {
- _has_bits_[0] &= ~0x02000000u;
-}
-void V1LayerParameter::clear_image_data_param() {
- if (image_data_param_ != NULL) image_data_param_->::caffe::ImageDataParameter::Clear();
- clear_has_image_data_param();
-}
-const ::caffe::ImageDataParameter& V1LayerParameter::image_data_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.image_data_param)
- return image_data_param_ != NULL ? *image_data_param_
- : *::caffe::ImageDataParameter::internal_default_instance();
-}
-::caffe::ImageDataParameter* V1LayerParameter::mutable_image_data_param() {
- set_has_image_data_param();
- if (image_data_param_ == NULL) {
- image_data_param_ = new ::caffe::ImageDataParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.image_data_param)
- return image_data_param_;
-}
-::caffe::ImageDataParameter* V1LayerParameter::release_image_data_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.image_data_param)
- clear_has_image_data_param();
- ::caffe::ImageDataParameter* temp = image_data_param_;
- image_data_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_image_data_param(::caffe::ImageDataParameter* image_data_param) {
- delete image_data_param_;
- image_data_param_ = image_data_param;
- if (image_data_param) {
- set_has_image_data_param();
- } else {
- clear_has_image_data_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.image_data_param)
-}
-
-// optional .caffe.InfogainLossParameter infogain_loss_param = 16;
-bool V1LayerParameter::has_infogain_loss_param() const {
- return (_has_bits_[0] & 0x04000000u) != 0;
-}
-void V1LayerParameter::set_has_infogain_loss_param() {
- _has_bits_[0] |= 0x04000000u;
-}
-void V1LayerParameter::clear_has_infogain_loss_param() {
- _has_bits_[0] &= ~0x04000000u;
-}
-void V1LayerParameter::clear_infogain_loss_param() {
- if (infogain_loss_param_ != NULL) infogain_loss_param_->::caffe::InfogainLossParameter::Clear();
- clear_has_infogain_loss_param();
-}
-const ::caffe::InfogainLossParameter& V1LayerParameter::infogain_loss_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.infogain_loss_param)
- return infogain_loss_param_ != NULL ? *infogain_loss_param_
- : *::caffe::InfogainLossParameter::internal_default_instance();
-}
-::caffe::InfogainLossParameter* V1LayerParameter::mutable_infogain_loss_param() {
- set_has_infogain_loss_param();
- if (infogain_loss_param_ == NULL) {
- infogain_loss_param_ = new ::caffe::InfogainLossParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.infogain_loss_param)
- return infogain_loss_param_;
-}
-::caffe::InfogainLossParameter* V1LayerParameter::release_infogain_loss_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.infogain_loss_param)
- clear_has_infogain_loss_param();
- ::caffe::InfogainLossParameter* temp = infogain_loss_param_;
- infogain_loss_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_infogain_loss_param(::caffe::InfogainLossParameter* infogain_loss_param) {
- delete infogain_loss_param_;
- infogain_loss_param_ = infogain_loss_param;
- if (infogain_loss_param) {
- set_has_infogain_loss_param();
- } else {
- clear_has_infogain_loss_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.infogain_loss_param)
-}
-
-// optional .caffe.InnerProductParameter inner_product_param = 17;
-bool V1LayerParameter::has_inner_product_param() const {
- return (_has_bits_[0] & 0x08000000u) != 0;
-}
-void V1LayerParameter::set_has_inner_product_param() {
- _has_bits_[0] |= 0x08000000u;
-}
-void V1LayerParameter::clear_has_inner_product_param() {
- _has_bits_[0] &= ~0x08000000u;
-}
-void V1LayerParameter::clear_inner_product_param() {
- if (inner_product_param_ != NULL) inner_product_param_->::caffe::InnerProductParameter::Clear();
- clear_has_inner_product_param();
-}
-const ::caffe::InnerProductParameter& V1LayerParameter::inner_product_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.inner_product_param)
- return inner_product_param_ != NULL ? *inner_product_param_
- : *::caffe::InnerProductParameter::internal_default_instance();
-}
-::caffe::InnerProductParameter* V1LayerParameter::mutable_inner_product_param() {
- set_has_inner_product_param();
- if (inner_product_param_ == NULL) {
- inner_product_param_ = new ::caffe::InnerProductParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.inner_product_param)
- return inner_product_param_;
-}
-::caffe::InnerProductParameter* V1LayerParameter::release_inner_product_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.inner_product_param)
- clear_has_inner_product_param();
- ::caffe::InnerProductParameter* temp = inner_product_param_;
- inner_product_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_inner_product_param(::caffe::InnerProductParameter* inner_product_param) {
- delete inner_product_param_;
- inner_product_param_ = inner_product_param;
- if (inner_product_param) {
- set_has_inner_product_param();
- } else {
- clear_has_inner_product_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.inner_product_param)
-}
-
-// optional .caffe.LRNParameter lrn_param = 18;
-bool V1LayerParameter::has_lrn_param() const {
- return (_has_bits_[0] & 0x10000000u) != 0;
-}
-void V1LayerParameter::set_has_lrn_param() {
- _has_bits_[0] |= 0x10000000u;
-}
-void V1LayerParameter::clear_has_lrn_param() {
- _has_bits_[0] &= ~0x10000000u;
-}
-void V1LayerParameter::clear_lrn_param() {
- if (lrn_param_ != NULL) lrn_param_->::caffe::LRNParameter::Clear();
- clear_has_lrn_param();
-}
-const ::caffe::LRNParameter& V1LayerParameter::lrn_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.lrn_param)
- return lrn_param_ != NULL ? *lrn_param_
- : *::caffe::LRNParameter::internal_default_instance();
-}
-::caffe::LRNParameter* V1LayerParameter::mutable_lrn_param() {
- set_has_lrn_param();
- if (lrn_param_ == NULL) {
- lrn_param_ = new ::caffe::LRNParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.lrn_param)
- return lrn_param_;
-}
-::caffe::LRNParameter* V1LayerParameter::release_lrn_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.lrn_param)
- clear_has_lrn_param();
- ::caffe::LRNParameter* temp = lrn_param_;
- lrn_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_lrn_param(::caffe::LRNParameter* lrn_param) {
- delete lrn_param_;
- lrn_param_ = lrn_param;
- if (lrn_param) {
- set_has_lrn_param();
- } else {
- clear_has_lrn_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.lrn_param)
-}
-
-// optional .caffe.MemoryDataParameter memory_data_param = 22;
-bool V1LayerParameter::has_memory_data_param() const {
- return (_has_bits_[0] & 0x20000000u) != 0;
-}
-void V1LayerParameter::set_has_memory_data_param() {
- _has_bits_[0] |= 0x20000000u;
-}
-void V1LayerParameter::clear_has_memory_data_param() {
- _has_bits_[0] &= ~0x20000000u;
-}
-void V1LayerParameter::clear_memory_data_param() {
- if (memory_data_param_ != NULL) memory_data_param_->::caffe::MemoryDataParameter::Clear();
- clear_has_memory_data_param();
-}
-const ::caffe::MemoryDataParameter& V1LayerParameter::memory_data_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.memory_data_param)
- return memory_data_param_ != NULL ? *memory_data_param_
- : *::caffe::MemoryDataParameter::internal_default_instance();
-}
-::caffe::MemoryDataParameter* V1LayerParameter::mutable_memory_data_param() {
- set_has_memory_data_param();
- if (memory_data_param_ == NULL) {
- memory_data_param_ = new ::caffe::MemoryDataParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.memory_data_param)
- return memory_data_param_;
-}
-::caffe::MemoryDataParameter* V1LayerParameter::release_memory_data_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.memory_data_param)
- clear_has_memory_data_param();
- ::caffe::MemoryDataParameter* temp = memory_data_param_;
- memory_data_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_memory_data_param(::caffe::MemoryDataParameter* memory_data_param) {
- delete memory_data_param_;
- memory_data_param_ = memory_data_param;
- if (memory_data_param) {
- set_has_memory_data_param();
- } else {
- clear_has_memory_data_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.memory_data_param)
-}
-
-// optional .caffe.MVNParameter mvn_param = 34;
-bool V1LayerParameter::has_mvn_param() const {
- return (_has_bits_[0] & 0x40000000u) != 0;
-}
-void V1LayerParameter::set_has_mvn_param() {
- _has_bits_[0] |= 0x40000000u;
-}
-void V1LayerParameter::clear_has_mvn_param() {
- _has_bits_[0] &= ~0x40000000u;
-}
-void V1LayerParameter::clear_mvn_param() {
- if (mvn_param_ != NULL) mvn_param_->::caffe::MVNParameter::Clear();
- clear_has_mvn_param();
-}
-const ::caffe::MVNParameter& V1LayerParameter::mvn_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.mvn_param)
- return mvn_param_ != NULL ? *mvn_param_
- : *::caffe::MVNParameter::internal_default_instance();
-}
-::caffe::MVNParameter* V1LayerParameter::mutable_mvn_param() {
- set_has_mvn_param();
- if (mvn_param_ == NULL) {
- mvn_param_ = new ::caffe::MVNParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.mvn_param)
- return mvn_param_;
-}
-::caffe::MVNParameter* V1LayerParameter::release_mvn_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.mvn_param)
- clear_has_mvn_param();
- ::caffe::MVNParameter* temp = mvn_param_;
- mvn_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_mvn_param(::caffe::MVNParameter* mvn_param) {
- delete mvn_param_;
- mvn_param_ = mvn_param;
- if (mvn_param) {
- set_has_mvn_param();
- } else {
- clear_has_mvn_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.mvn_param)
-}
-
-// optional .caffe.PoolingParameter pooling_param = 19;
-bool V1LayerParameter::has_pooling_param() const {
- return (_has_bits_[0] & 0x80000000u) != 0;
-}
-void V1LayerParameter::set_has_pooling_param() {
- _has_bits_[0] |= 0x80000000u;
-}
-void V1LayerParameter::clear_has_pooling_param() {
- _has_bits_[0] &= ~0x80000000u;
-}
-void V1LayerParameter::clear_pooling_param() {
- if (pooling_param_ != NULL) pooling_param_->::caffe::PoolingParameter::Clear();
- clear_has_pooling_param();
-}
-const ::caffe::PoolingParameter& V1LayerParameter::pooling_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.pooling_param)
- return pooling_param_ != NULL ? *pooling_param_
- : *::caffe::PoolingParameter::internal_default_instance();
-}
-::caffe::PoolingParameter* V1LayerParameter::mutable_pooling_param() {
- set_has_pooling_param();
- if (pooling_param_ == NULL) {
- pooling_param_ = new ::caffe::PoolingParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.pooling_param)
- return pooling_param_;
-}
-::caffe::PoolingParameter* V1LayerParameter::release_pooling_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.pooling_param)
- clear_has_pooling_param();
- ::caffe::PoolingParameter* temp = pooling_param_;
- pooling_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_pooling_param(::caffe::PoolingParameter* pooling_param) {
- delete pooling_param_;
- pooling_param_ = pooling_param;
- if (pooling_param) {
- set_has_pooling_param();
- } else {
- clear_has_pooling_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.pooling_param)
-}
-
-// optional .caffe.PowerParameter power_param = 21;
-bool V1LayerParameter::has_power_param() const {
- return (_has_bits_[1] & 0x00000001u) != 0;
-}
-void V1LayerParameter::set_has_power_param() {
- _has_bits_[1] |= 0x00000001u;
-}
-void V1LayerParameter::clear_has_power_param() {
- _has_bits_[1] &= ~0x00000001u;
-}
-void V1LayerParameter::clear_power_param() {
- if (power_param_ != NULL) power_param_->::caffe::PowerParameter::Clear();
- clear_has_power_param();
-}
-const ::caffe::PowerParameter& V1LayerParameter::power_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.power_param)
- return power_param_ != NULL ? *power_param_
- : *::caffe::PowerParameter::internal_default_instance();
-}
-::caffe::PowerParameter* V1LayerParameter::mutable_power_param() {
- set_has_power_param();
- if (power_param_ == NULL) {
- power_param_ = new ::caffe::PowerParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.power_param)
- return power_param_;
-}
-::caffe::PowerParameter* V1LayerParameter::release_power_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.power_param)
- clear_has_power_param();
- ::caffe::PowerParameter* temp = power_param_;
- power_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_power_param(::caffe::PowerParameter* power_param) {
- delete power_param_;
- power_param_ = power_param;
- if (power_param) {
- set_has_power_param();
- } else {
- clear_has_power_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.power_param)
-}
-
-// optional .caffe.ReLUParameter relu_param = 30;
-bool V1LayerParameter::has_relu_param() const {
- return (_has_bits_[1] & 0x00000002u) != 0;
-}
-void V1LayerParameter::set_has_relu_param() {
- _has_bits_[1] |= 0x00000002u;
-}
-void V1LayerParameter::clear_has_relu_param() {
- _has_bits_[1] &= ~0x00000002u;
-}
-void V1LayerParameter::clear_relu_param() {
- if (relu_param_ != NULL) relu_param_->::caffe::ReLUParameter::Clear();
- clear_has_relu_param();
-}
-const ::caffe::ReLUParameter& V1LayerParameter::relu_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.relu_param)
- return relu_param_ != NULL ? *relu_param_
- : *::caffe::ReLUParameter::internal_default_instance();
-}
-::caffe::ReLUParameter* V1LayerParameter::mutable_relu_param() {
- set_has_relu_param();
- if (relu_param_ == NULL) {
- relu_param_ = new ::caffe::ReLUParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.relu_param)
- return relu_param_;
-}
-::caffe::ReLUParameter* V1LayerParameter::release_relu_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.relu_param)
- clear_has_relu_param();
- ::caffe::ReLUParameter* temp = relu_param_;
- relu_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_relu_param(::caffe::ReLUParameter* relu_param) {
- delete relu_param_;
- relu_param_ = relu_param;
- if (relu_param) {
- set_has_relu_param();
- } else {
- clear_has_relu_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.relu_param)
-}
-
-// optional .caffe.SigmoidParameter sigmoid_param = 38;
-bool V1LayerParameter::has_sigmoid_param() const {
- return (_has_bits_[1] & 0x00000004u) != 0;
-}
-void V1LayerParameter::set_has_sigmoid_param() {
- _has_bits_[1] |= 0x00000004u;
-}
-void V1LayerParameter::clear_has_sigmoid_param() {
- _has_bits_[1] &= ~0x00000004u;
-}
-void V1LayerParameter::clear_sigmoid_param() {
- if (sigmoid_param_ != NULL) sigmoid_param_->::caffe::SigmoidParameter::Clear();
- clear_has_sigmoid_param();
-}
-const ::caffe::SigmoidParameter& V1LayerParameter::sigmoid_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.sigmoid_param)
- return sigmoid_param_ != NULL ? *sigmoid_param_
- : *::caffe::SigmoidParameter::internal_default_instance();
-}
-::caffe::SigmoidParameter* V1LayerParameter::mutable_sigmoid_param() {
- set_has_sigmoid_param();
- if (sigmoid_param_ == NULL) {
- sigmoid_param_ = new ::caffe::SigmoidParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.sigmoid_param)
- return sigmoid_param_;
-}
-::caffe::SigmoidParameter* V1LayerParameter::release_sigmoid_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.sigmoid_param)
- clear_has_sigmoid_param();
- ::caffe::SigmoidParameter* temp = sigmoid_param_;
- sigmoid_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_sigmoid_param(::caffe::SigmoidParameter* sigmoid_param) {
- delete sigmoid_param_;
- sigmoid_param_ = sigmoid_param;
- if (sigmoid_param) {
- set_has_sigmoid_param();
- } else {
- clear_has_sigmoid_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.sigmoid_param)
-}
-
-// optional .caffe.SoftmaxParameter softmax_param = 39;
-bool V1LayerParameter::has_softmax_param() const {
- return (_has_bits_[1] & 0x00000008u) != 0;
-}
-void V1LayerParameter::set_has_softmax_param() {
- _has_bits_[1] |= 0x00000008u;
-}
-void V1LayerParameter::clear_has_softmax_param() {
- _has_bits_[1] &= ~0x00000008u;
-}
-void V1LayerParameter::clear_softmax_param() {
- if (softmax_param_ != NULL) softmax_param_->::caffe::SoftmaxParameter::Clear();
- clear_has_softmax_param();
-}
-const ::caffe::SoftmaxParameter& V1LayerParameter::softmax_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.softmax_param)
- return softmax_param_ != NULL ? *softmax_param_
- : *::caffe::SoftmaxParameter::internal_default_instance();
-}
-::caffe::SoftmaxParameter* V1LayerParameter::mutable_softmax_param() {
- set_has_softmax_param();
- if (softmax_param_ == NULL) {
- softmax_param_ = new ::caffe::SoftmaxParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.softmax_param)
- return softmax_param_;
-}
-::caffe::SoftmaxParameter* V1LayerParameter::release_softmax_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.softmax_param)
- clear_has_softmax_param();
- ::caffe::SoftmaxParameter* temp = softmax_param_;
- softmax_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_softmax_param(::caffe::SoftmaxParameter* softmax_param) {
- delete softmax_param_;
- softmax_param_ = softmax_param;
- if (softmax_param) {
- set_has_softmax_param();
- } else {
- clear_has_softmax_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.softmax_param)
-}
-
-// optional .caffe.SliceParameter slice_param = 31;
-bool V1LayerParameter::has_slice_param() const {
- return (_has_bits_[1] & 0x00000010u) != 0;
-}
-void V1LayerParameter::set_has_slice_param() {
- _has_bits_[1] |= 0x00000010u;
-}
-void V1LayerParameter::clear_has_slice_param() {
- _has_bits_[1] &= ~0x00000010u;
-}
-void V1LayerParameter::clear_slice_param() {
- if (slice_param_ != NULL) slice_param_->::caffe::SliceParameter::Clear();
- clear_has_slice_param();
-}
-const ::caffe::SliceParameter& V1LayerParameter::slice_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.slice_param)
- return slice_param_ != NULL ? *slice_param_
- : *::caffe::SliceParameter::internal_default_instance();
-}
-::caffe::SliceParameter* V1LayerParameter::mutable_slice_param() {
- set_has_slice_param();
- if (slice_param_ == NULL) {
- slice_param_ = new ::caffe::SliceParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.slice_param)
- return slice_param_;
-}
-::caffe::SliceParameter* V1LayerParameter::release_slice_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.slice_param)
- clear_has_slice_param();
- ::caffe::SliceParameter* temp = slice_param_;
- slice_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_slice_param(::caffe::SliceParameter* slice_param) {
- delete slice_param_;
- slice_param_ = slice_param;
- if (slice_param) {
- set_has_slice_param();
- } else {
- clear_has_slice_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.slice_param)
-}
-
-// optional .caffe.TanHParameter tanh_param = 37;
-bool V1LayerParameter::has_tanh_param() const {
- return (_has_bits_[1] & 0x00000020u) != 0;
-}
-void V1LayerParameter::set_has_tanh_param() {
- _has_bits_[1] |= 0x00000020u;
-}
-void V1LayerParameter::clear_has_tanh_param() {
- _has_bits_[1] &= ~0x00000020u;
-}
-void V1LayerParameter::clear_tanh_param() {
- if (tanh_param_ != NULL) tanh_param_->::caffe::TanHParameter::Clear();
- clear_has_tanh_param();
-}
-const ::caffe::TanHParameter& V1LayerParameter::tanh_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.tanh_param)
- return tanh_param_ != NULL ? *tanh_param_
- : *::caffe::TanHParameter::internal_default_instance();
-}
-::caffe::TanHParameter* V1LayerParameter::mutable_tanh_param() {
- set_has_tanh_param();
- if (tanh_param_ == NULL) {
- tanh_param_ = new ::caffe::TanHParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.tanh_param)
- return tanh_param_;
-}
-::caffe::TanHParameter* V1LayerParameter::release_tanh_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.tanh_param)
- clear_has_tanh_param();
- ::caffe::TanHParameter* temp = tanh_param_;
- tanh_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_tanh_param(::caffe::TanHParameter* tanh_param) {
- delete tanh_param_;
- tanh_param_ = tanh_param;
- if (tanh_param) {
- set_has_tanh_param();
- } else {
- clear_has_tanh_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.tanh_param)
-}
-
-// optional .caffe.ThresholdParameter threshold_param = 25;
-bool V1LayerParameter::has_threshold_param() const {
- return (_has_bits_[1] & 0x00000040u) != 0;
-}
-void V1LayerParameter::set_has_threshold_param() {
- _has_bits_[1] |= 0x00000040u;
-}
-void V1LayerParameter::clear_has_threshold_param() {
- _has_bits_[1] &= ~0x00000040u;
-}
-void V1LayerParameter::clear_threshold_param() {
- if (threshold_param_ != NULL) threshold_param_->::caffe::ThresholdParameter::Clear();
- clear_has_threshold_param();
-}
-const ::caffe::ThresholdParameter& V1LayerParameter::threshold_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.threshold_param)
- return threshold_param_ != NULL ? *threshold_param_
- : *::caffe::ThresholdParameter::internal_default_instance();
-}
-::caffe::ThresholdParameter* V1LayerParameter::mutable_threshold_param() {
- set_has_threshold_param();
- if (threshold_param_ == NULL) {
- threshold_param_ = new ::caffe::ThresholdParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.threshold_param)
- return threshold_param_;
-}
-::caffe::ThresholdParameter* V1LayerParameter::release_threshold_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.threshold_param)
- clear_has_threshold_param();
- ::caffe::ThresholdParameter* temp = threshold_param_;
- threshold_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_threshold_param(::caffe::ThresholdParameter* threshold_param) {
- delete threshold_param_;
- threshold_param_ = threshold_param;
- if (threshold_param) {
- set_has_threshold_param();
- } else {
- clear_has_threshold_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.threshold_param)
-}
-
-// optional .caffe.WindowDataParameter window_data_param = 20;
-bool V1LayerParameter::has_window_data_param() const {
- return (_has_bits_[1] & 0x00000080u) != 0;
-}
-void V1LayerParameter::set_has_window_data_param() {
- _has_bits_[1] |= 0x00000080u;
-}
-void V1LayerParameter::clear_has_window_data_param() {
- _has_bits_[1] &= ~0x00000080u;
-}
-void V1LayerParameter::clear_window_data_param() {
- if (window_data_param_ != NULL) window_data_param_->::caffe::WindowDataParameter::Clear();
- clear_has_window_data_param();
-}
-const ::caffe::WindowDataParameter& V1LayerParameter::window_data_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.window_data_param)
- return window_data_param_ != NULL ? *window_data_param_
- : *::caffe::WindowDataParameter::internal_default_instance();
-}
-::caffe::WindowDataParameter* V1LayerParameter::mutable_window_data_param() {
- set_has_window_data_param();
- if (window_data_param_ == NULL) {
- window_data_param_ = new ::caffe::WindowDataParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.window_data_param)
- return window_data_param_;
-}
-::caffe::WindowDataParameter* V1LayerParameter::release_window_data_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.window_data_param)
- clear_has_window_data_param();
- ::caffe::WindowDataParameter* temp = window_data_param_;
- window_data_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_window_data_param(::caffe::WindowDataParameter* window_data_param) {
- delete window_data_param_;
- window_data_param_ = window_data_param;
- if (window_data_param) {
- set_has_window_data_param();
- } else {
- clear_has_window_data_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.window_data_param)
-}
-
-// optional .caffe.TransformationParameter transform_param = 36;
-bool V1LayerParameter::has_transform_param() const {
- return (_has_bits_[1] & 0x00000100u) != 0;
-}
-void V1LayerParameter::set_has_transform_param() {
- _has_bits_[1] |= 0x00000100u;
-}
-void V1LayerParameter::clear_has_transform_param() {
- _has_bits_[1] &= ~0x00000100u;
-}
-void V1LayerParameter::clear_transform_param() {
- if (transform_param_ != NULL) transform_param_->::caffe::TransformationParameter::Clear();
- clear_has_transform_param();
-}
-const ::caffe::TransformationParameter& V1LayerParameter::transform_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.transform_param)
- return transform_param_ != NULL ? *transform_param_
- : *::caffe::TransformationParameter::internal_default_instance();
-}
-::caffe::TransformationParameter* V1LayerParameter::mutable_transform_param() {
- set_has_transform_param();
- if (transform_param_ == NULL) {
- transform_param_ = new ::caffe::TransformationParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.transform_param)
- return transform_param_;
-}
-::caffe::TransformationParameter* V1LayerParameter::release_transform_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.transform_param)
- clear_has_transform_param();
- ::caffe::TransformationParameter* temp = transform_param_;
- transform_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_transform_param(::caffe::TransformationParameter* transform_param) {
- delete transform_param_;
- transform_param_ = transform_param;
- if (transform_param) {
- set_has_transform_param();
- } else {
- clear_has_transform_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.transform_param)
-}
-
-// optional .caffe.LossParameter loss_param = 42;
-bool V1LayerParameter::has_loss_param() const {
- return (_has_bits_[1] & 0x00000200u) != 0;
-}
-void V1LayerParameter::set_has_loss_param() {
- _has_bits_[1] |= 0x00000200u;
-}
-void V1LayerParameter::clear_has_loss_param() {
- _has_bits_[1] &= ~0x00000200u;
-}
-void V1LayerParameter::clear_loss_param() {
- if (loss_param_ != NULL) loss_param_->::caffe::LossParameter::Clear();
- clear_has_loss_param();
-}
-const ::caffe::LossParameter& V1LayerParameter::loss_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.loss_param)
- return loss_param_ != NULL ? *loss_param_
- : *::caffe::LossParameter::internal_default_instance();
-}
-::caffe::LossParameter* V1LayerParameter::mutable_loss_param() {
- set_has_loss_param();
- if (loss_param_ == NULL) {
- loss_param_ = new ::caffe::LossParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.loss_param)
- return loss_param_;
-}
-::caffe::LossParameter* V1LayerParameter::release_loss_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.loss_param)
- clear_has_loss_param();
- ::caffe::LossParameter* temp = loss_param_;
- loss_param_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_loss_param(::caffe::LossParameter* loss_param) {
- delete loss_param_;
- loss_param_ = loss_param;
- if (loss_param) {
- set_has_loss_param();
- } else {
- clear_has_loss_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.loss_param)
-}
-
-// optional .caffe.V0LayerParameter layer = 1;
-bool V1LayerParameter::has_layer() const {
- return (_has_bits_[1] & 0x00000400u) != 0;
-}
-void V1LayerParameter::set_has_layer() {
- _has_bits_[1] |= 0x00000400u;
-}
-void V1LayerParameter::clear_has_layer() {
- _has_bits_[1] &= ~0x00000400u;
-}
-void V1LayerParameter::clear_layer() {
- if (layer_ != NULL) layer_->::caffe::V0LayerParameter::Clear();
- clear_has_layer();
-}
-const ::caffe::V0LayerParameter& V1LayerParameter::layer() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.layer)
- return layer_ != NULL ? *layer_
- : *::caffe::V0LayerParameter::internal_default_instance();
-}
-::caffe::V0LayerParameter* V1LayerParameter::mutable_layer() {
- set_has_layer();
- if (layer_ == NULL) {
- layer_ = new ::caffe::V0LayerParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.layer)
- return layer_;
-}
-::caffe::V0LayerParameter* V1LayerParameter::release_layer() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.layer)
- clear_has_layer();
- ::caffe::V0LayerParameter* temp = layer_;
- layer_ = NULL;
- return temp;
-}
-void V1LayerParameter::set_allocated_layer(::caffe::V0LayerParameter* layer) {
- delete layer_;
- layer_ = layer;
- if (layer) {
- set_has_layer();
- } else {
- clear_has_layer();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.layer)
-}
-
-inline const V1LayerParameter* V1LayerParameter::internal_default_instance() {
- return &V1LayerParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-const ::google::protobuf::EnumDescriptor* V0LayerParameter_PoolMethod_descriptor() {
- protobuf_AssignDescriptorsOnce();
- return V0LayerParameter_PoolMethod_descriptor_;
-}
-bool V0LayerParameter_PoolMethod_IsValid(int value) {
- switch (value) {
- case 0:
- case 1:
- case 2:
- return true;
- default:
- return false;
- }
-}
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const V0LayerParameter_PoolMethod V0LayerParameter::MAX;
-const V0LayerParameter_PoolMethod V0LayerParameter::AVE;
-const V0LayerParameter_PoolMethod V0LayerParameter::STOCHASTIC;
-const V0LayerParameter_PoolMethod V0LayerParameter::PoolMethod_MIN;
-const V0LayerParameter_PoolMethod V0LayerParameter::PoolMethod_MAX;
-const int V0LayerParameter::PoolMethod_ARRAYSIZE;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-::std::string* V0LayerParameter::_default_det_crop_mode_ = NULL;
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int V0LayerParameter::kNameFieldNumber;
-const int V0LayerParameter::kTypeFieldNumber;
-const int V0LayerParameter::kNumOutputFieldNumber;
-const int V0LayerParameter::kBiastermFieldNumber;
-const int V0LayerParameter::kWeightFillerFieldNumber;
-const int V0LayerParameter::kBiasFillerFieldNumber;
-const int V0LayerParameter::kPadFieldNumber;
-const int V0LayerParameter::kKernelsizeFieldNumber;
-const int V0LayerParameter::kGroupFieldNumber;
-const int V0LayerParameter::kStrideFieldNumber;
-const int V0LayerParameter::kPoolFieldNumber;
-const int V0LayerParameter::kDropoutRatioFieldNumber;
-const int V0LayerParameter::kLocalSizeFieldNumber;
-const int V0LayerParameter::kAlphaFieldNumber;
-const int V0LayerParameter::kBetaFieldNumber;
-const int V0LayerParameter::kKFieldNumber;
-const int V0LayerParameter::kSourceFieldNumber;
-const int V0LayerParameter::kScaleFieldNumber;
-const int V0LayerParameter::kMeanfileFieldNumber;
-const int V0LayerParameter::kBatchsizeFieldNumber;
-const int V0LayerParameter::kCropsizeFieldNumber;
-const int V0LayerParameter::kMirrorFieldNumber;
-const int V0LayerParameter::kBlobsFieldNumber;
-const int V0LayerParameter::kBlobsLrFieldNumber;
-const int V0LayerParameter::kWeightDecayFieldNumber;
-const int V0LayerParameter::kRandSkipFieldNumber;
-const int V0LayerParameter::kDetFgThresholdFieldNumber;
-const int V0LayerParameter::kDetBgThresholdFieldNumber;
-const int V0LayerParameter::kDetFgFractionFieldNumber;
-const int V0LayerParameter::kDetContextPadFieldNumber;
-const int V0LayerParameter::kDetCropModeFieldNumber;
-const int V0LayerParameter::kNewNumFieldNumber;
-const int V0LayerParameter::kNewChannelsFieldNumber;
-const int V0LayerParameter::kNewHeightFieldNumber;
-const int V0LayerParameter::kNewWidthFieldNumber;
-const int V0LayerParameter::kShuffleImagesFieldNumber;
-const int V0LayerParameter::kConcatDimFieldNumber;
-const int V0LayerParameter::kHdf5OutputParamFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-V0LayerParameter::V0LayerParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.V0LayerParameter)
-}
-
-void V0LayerParameter::InitAsDefaultInstance() {
- weight_filler_ = const_cast< ::caffe::FillerParameter*>(
- ::caffe::FillerParameter::internal_default_instance());
- bias_filler_ = const_cast< ::caffe::FillerParameter*>(
- ::caffe::FillerParameter::internal_default_instance());
- hdf5_output_param_ = const_cast< ::caffe::HDF5OutputParameter*>(
- ::caffe::HDF5OutputParameter::internal_default_instance());
-}
-
-V0LayerParameter::V0LayerParameter(const V0LayerParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.V0LayerParameter)
-}
-
-void V0LayerParameter::SharedCtor() {
- name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- source_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- meanfile_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- det_crop_mode_.UnsafeSetDefault(_default_det_crop_mode_);
- weight_filler_ = NULL;
- bias_filler_ = NULL;
- hdf5_output_param_ = NULL;
- ::memset(&num_output_, 0, reinterpret_cast<char*>(&new_width_) -
- reinterpret_cast<char*>(&num_output_) + sizeof(new_width_));
- concat_dim_ = 1u;
- biasterm_ = true;
- group_ = 1u;
- stride_ = 1u;
- dropout_ratio_ = 0.5f;
- local_size_ = 5u;
- alpha_ = 1;
- beta_ = 0.75f;
- k_ = 1;
- scale_ = 1;
- det_fg_threshold_ = 0.5f;
- det_bg_threshold_ = 0.5f;
- det_fg_fraction_ = 0.25f;
- _cached_size_ = 0;
-}
-
-V0LayerParameter::~V0LayerParameter() {
- // @@protoc_insertion_point(destructor:caffe.V0LayerParameter)
- SharedDtor();
-}
-
-void V0LayerParameter::SharedDtor() {
- name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- type_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- source_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- meanfile_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- det_crop_mode_.DestroyNoArena(_default_det_crop_mode_);
- if (this != &V0LayerParameter_default_instance_.get()) {
- delete weight_filler_;
- delete bias_filler_;
- delete hdf5_output_param_;
- }
-}
-
-void V0LayerParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* V0LayerParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return V0LayerParameter_descriptor_;
-}
-
-const V0LayerParameter& V0LayerParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<V0LayerParameter> V0LayerParameter_default_instance_;
-
-V0LayerParameter* V0LayerParameter::New(::google::protobuf::Arena* arena) const {
- V0LayerParameter* n = new V0LayerParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void V0LayerParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.V0LayerParameter)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(V0LayerParameter, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<V0LayerParameter*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- if (_has_bits_[0 / 32] & 255u) {
- ZR_(num_output_, kernelsize_);
- if (has_name()) {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- if (has_type()) {
- type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- biasterm_ = true;
- if (has_weight_filler()) {
- if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear();
- }
- if (has_bias_filler()) {
- if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
- }
- }
- if (_has_bits_[8 / 32] & 65280u) {
- group_ = 1u;
- stride_ = 1u;
- pool_ = 0;
- dropout_ratio_ = 0.5f;
- local_size_ = 5u;
- alpha_ = 1;
- beta_ = 0.75f;
- k_ = 1;
- }
- if (_has_bits_[16 / 32] & 4128768u) {
- ZR_(batchsize_, cropsize_);
- if (has_source()) {
- source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- scale_ = 1;
- if (has_meanfile()) {
- meanfile_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- }
- mirror_ = false;
- }
- if (_has_bits_[24 / 32] & 4261412864u) {
- ZR_(det_context_pad_, new_num_);
- rand_skip_ = 0u;
- det_fg_threshold_ = 0.5f;
- det_bg_threshold_ = 0.5f;
- det_fg_fraction_ = 0.25f;
- if (has_det_crop_mode()) {
- det_crop_mode_.ClearToDefaultNoArena(_default_det_crop_mode_);
- }
- }
- if (_has_bits_[32 / 32] & 63u) {
- ZR_(new_channels_, new_width_);
- shuffle_images_ = false;
- concat_dim_ = 1u;
- if (has_hdf5_output_param()) {
- if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear();
- }
- }
-
-#undef ZR_HELPER_
-#undef ZR_
-
- blobs_.Clear();
- blobs_lr_.Clear();
- weight_decay_.Clear();
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool V0LayerParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.V0LayerParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional string name = 1;
- case 1: {
- if (tag == 10) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_name()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->name().data(), this->name().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.V0LayerParameter.name");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(18)) goto parse_type;
- break;
- }
-
- // optional string type = 2;
- case 2: {
- if (tag == 18) {
- parse_type:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_type()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->type().data(), this->type().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.V0LayerParameter.type");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(24)) goto parse_num_output;
- break;
- }
-
- // optional uint32 num_output = 3;
- case 3: {
- if (tag == 24) {
- parse_num_output:
- set_has_num_output();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &num_output_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(32)) goto parse_biasterm;
- break;
- }
-
- // optional bool biasterm = 4 [default = true];
- case 4: {
- if (tag == 32) {
- parse_biasterm:
- set_has_biasterm();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &biasterm_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(42)) goto parse_weight_filler;
- break;
- }
-
- // optional .caffe.FillerParameter weight_filler = 5;
- case 5: {
- if (tag == 42) {
- parse_weight_filler:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_weight_filler()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(50)) goto parse_bias_filler;
- break;
- }
-
- // optional .caffe.FillerParameter bias_filler = 6;
- case 6: {
- if (tag == 50) {
- parse_bias_filler:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_bias_filler()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(56)) goto parse_pad;
- break;
- }
-
- // optional uint32 pad = 7 [default = 0];
- case 7: {
- if (tag == 56) {
- parse_pad:
- set_has_pad();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &pad_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(64)) goto parse_kernelsize;
- break;
- }
-
- // optional uint32 kernelsize = 8;
- case 8: {
- if (tag == 64) {
- parse_kernelsize:
- set_has_kernelsize();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &kernelsize_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(72)) goto parse_group;
- break;
- }
-
- // optional uint32 group = 9 [default = 1];
- case 9: {
- if (tag == 72) {
- parse_group:
- set_has_group();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &group_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(80)) goto parse_stride;
- break;
- }
-
- // optional uint32 stride = 10 [default = 1];
- case 10: {
- if (tag == 80) {
- parse_stride:
- set_has_stride();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &stride_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(88)) goto parse_pool;
- break;
- }
-
- // optional .caffe.V0LayerParameter.PoolMethod pool = 11 [default = MAX];
- case 11: {
- if (tag == 88) {
- parse_pool:
- int value;
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
- input, &value)));
- if (::caffe::V0LayerParameter_PoolMethod_IsValid(value)) {
- set_pool(static_cast< ::caffe::V0LayerParameter_PoolMethod >(value));
- } else {
- mutable_unknown_fields()->AddVarint(11, value);
- }
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(101)) goto parse_dropout_ratio;
- break;
- }
-
- // optional float dropout_ratio = 12 [default = 0.5];
- case 12: {
- if (tag == 101) {
- parse_dropout_ratio:
- set_has_dropout_ratio();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &dropout_ratio_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(104)) goto parse_local_size;
- break;
- }
-
- // optional uint32 local_size = 13 [default = 5];
- case 13: {
- if (tag == 104) {
- parse_local_size:
- set_has_local_size();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &local_size_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(117)) goto parse_alpha;
- break;
- }
-
- // optional float alpha = 14 [default = 1];
- case 14: {
- if (tag == 117) {
- parse_alpha:
- set_has_alpha();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &alpha_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(125)) goto parse_beta;
- break;
- }
-
- // optional float beta = 15 [default = 0.75];
- case 15: {
- if (tag == 125) {
- parse_beta:
- set_has_beta();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &beta_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(130)) goto parse_source;
- break;
- }
-
- // optional string source = 16;
- case 16: {
- if (tag == 130) {
- parse_source:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_source()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->source().data(), this->source().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.V0LayerParameter.source");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(141)) goto parse_scale;
- break;
- }
-
- // optional float scale = 17 [default = 1];
- case 17: {
- if (tag == 141) {
- parse_scale:
- set_has_scale();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &scale_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(146)) goto parse_meanfile;
- break;
- }
-
- // optional string meanfile = 18;
- case 18: {
- if (tag == 146) {
- parse_meanfile:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_meanfile()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->meanfile().data(), this->meanfile().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.V0LayerParameter.meanfile");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(152)) goto parse_batchsize;
- break;
- }
-
- // optional uint32 batchsize = 19;
- case 19: {
- if (tag == 152) {
- parse_batchsize:
- set_has_batchsize();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &batchsize_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(160)) goto parse_cropsize;
- break;
- }
-
- // optional uint32 cropsize = 20 [default = 0];
- case 20: {
- if (tag == 160) {
- parse_cropsize:
- set_has_cropsize();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &cropsize_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(168)) goto parse_mirror;
- break;
- }
-
- // optional bool mirror = 21 [default = false];
- case 21: {
- if (tag == 168) {
- parse_mirror:
- set_has_mirror();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &mirror_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(181)) goto parse_k;
- break;
- }
-
- // optional float k = 22 [default = 1];
- case 22: {
- if (tag == 181) {
- parse_k:
- set_has_k();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &k_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(402)) goto parse_blobs;
- break;
- }
-
- // repeated .caffe.BlobProto blobs = 50;
- case 50: {
- if (tag == 402) {
- parse_blobs:
- DO_(input->IncrementRecursionDepth());
- parse_loop_blobs:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
- input, add_blobs()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(402)) goto parse_loop_blobs;
- input->UnsafeDecrementRecursionDepth();
- if (input->ExpectTag(413)) goto parse_blobs_lr;
- break;
- }
-
- // repeated float blobs_lr = 51;
- case 51: {
- if (tag == 413) {
- parse_blobs_lr:
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- 2, 413, input, this->mutable_blobs_lr())));
- } else if (tag == 410) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, this->mutable_blobs_lr())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(413)) goto parse_blobs_lr;
- if (input->ExpectTag(421)) goto parse_weight_decay;
- break;
- }
-
- // repeated float weight_decay = 52;
- case 52: {
- if (tag == 421) {
- parse_weight_decay:
- DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- 2, 421, input, this->mutable_weight_decay())));
- } else if (tag == 418) {
- DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, this->mutable_weight_decay())));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(421)) goto parse_weight_decay;
- if (input->ExpectTag(424)) goto parse_rand_skip;
- break;
- }
-
- // optional uint32 rand_skip = 53 [default = 0];
- case 53: {
- if (tag == 424) {
- parse_rand_skip:
- set_has_rand_skip();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &rand_skip_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(437)) goto parse_det_fg_threshold;
- break;
- }
-
- // optional float det_fg_threshold = 54 [default = 0.5];
- case 54: {
- if (tag == 437) {
- parse_det_fg_threshold:
- set_has_det_fg_threshold();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &det_fg_threshold_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(445)) goto parse_det_bg_threshold;
- break;
- }
-
- // optional float det_bg_threshold = 55 [default = 0.5];
- case 55: {
- if (tag == 445) {
- parse_det_bg_threshold:
- set_has_det_bg_threshold();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &det_bg_threshold_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(453)) goto parse_det_fg_fraction;
- break;
- }
-
- // optional float det_fg_fraction = 56 [default = 0.25];
- case 56: {
- if (tag == 453) {
- parse_det_fg_fraction:
- set_has_det_fg_fraction();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &det_fg_fraction_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(464)) goto parse_det_context_pad;
- break;
- }
-
- // optional uint32 det_context_pad = 58 [default = 0];
- case 58: {
- if (tag == 464) {
- parse_det_context_pad:
- set_has_det_context_pad();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &det_context_pad_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(474)) goto parse_det_crop_mode;
- break;
- }
-
- // optional string det_crop_mode = 59 [default = "warp"];
- case 59: {
- if (tag == 474) {
- parse_det_crop_mode:
- DO_(::google::protobuf::internal::WireFormatLite::ReadString(
- input, this->mutable_det_crop_mode()));
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->det_crop_mode().data(), this->det_crop_mode().length(),
- ::google::protobuf::internal::WireFormat::PARSE,
- "caffe.V0LayerParameter.det_crop_mode");
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(480)) goto parse_new_num;
- break;
- }
-
- // optional int32 new_num = 60 [default = 0];
- case 60: {
- if (tag == 480) {
- parse_new_num:
- set_has_new_num();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &new_num_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(488)) goto parse_new_channels;
- break;
- }
-
- // optional int32 new_channels = 61 [default = 0];
- case 61: {
- if (tag == 488) {
- parse_new_channels:
- set_has_new_channels();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &new_channels_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(496)) goto parse_new_height;
- break;
- }
-
- // optional int32 new_height = 62 [default = 0];
- case 62: {
- if (tag == 496) {
- parse_new_height:
- set_has_new_height();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &new_height_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(504)) goto parse_new_width;
- break;
- }
-
- // optional int32 new_width = 63 [default = 0];
- case 63: {
- if (tag == 504) {
- parse_new_width:
- set_has_new_width();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &new_width_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(512)) goto parse_shuffle_images;
- break;
- }
-
- // optional bool shuffle_images = 64 [default = false];
- case 64: {
- if (tag == 512) {
- parse_shuffle_images:
- set_has_shuffle_images();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &shuffle_images_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(520)) goto parse_concat_dim;
- break;
- }
-
- // optional uint32 concat_dim = 65 [default = 1];
- case 65: {
- if (tag == 520) {
- parse_concat_dim:
- set_has_concat_dim();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
- input, &concat_dim_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(8010)) goto parse_hdf5_output_param;
- break;
- }
-
- // optional .caffe.HDF5OutputParameter hdf5_output_param = 1001;
- case 1001: {
- if (tag == 8010) {
- parse_hdf5_output_param:
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_hdf5_output_param()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.V0LayerParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.V0LayerParameter)
- return false;
-#undef DO_
-}
-
-void V0LayerParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.V0LayerParameter)
- // optional string name = 1;
- if (has_name()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->name().data(), this->name().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.V0LayerParameter.name");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 1, this->name(), output);
- }
-
- // optional string type = 2;
- if (has_type()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->type().data(), this->type().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.V0LayerParameter.type");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 2, this->type(), output);
- }
-
- // optional uint32 num_output = 3;
- if (has_num_output()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(3, this->num_output(), output);
- }
-
- // optional bool biasterm = 4 [default = true];
- if (has_biasterm()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(4, this->biasterm(), output);
- }
-
- // optional .caffe.FillerParameter weight_filler = 5;
- if (has_weight_filler()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 5, *this->weight_filler_, output);
- }
-
- // optional .caffe.FillerParameter bias_filler = 6;
- if (has_bias_filler()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 6, *this->bias_filler_, output);
- }
-
- // optional uint32 pad = 7 [default = 0];
- if (has_pad()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(7, this->pad(), output);
- }
-
- // optional uint32 kernelsize = 8;
- if (has_kernelsize()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(8, this->kernelsize(), output);
- }
-
- // optional uint32 group = 9 [default = 1];
- if (has_group()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(9, this->group(), output);
- }
-
- // optional uint32 stride = 10 [default = 1];
- if (has_stride()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(10, this->stride(), output);
- }
-
- // optional .caffe.V0LayerParameter.PoolMethod pool = 11 [default = MAX];
- if (has_pool()) {
- ::google::protobuf::internal::WireFormatLite::WriteEnum(
- 11, this->pool(), output);
- }
-
- // optional float dropout_ratio = 12 [default = 0.5];
- if (has_dropout_ratio()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(12, this->dropout_ratio(), output);
- }
-
- // optional uint32 local_size = 13 [default = 5];
- if (has_local_size()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(13, this->local_size(), output);
- }
-
- // optional float alpha = 14 [default = 1];
- if (has_alpha()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(14, this->alpha(), output);
- }
-
- // optional float beta = 15 [default = 0.75];
- if (has_beta()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(15, this->beta(), output);
- }
-
- // optional string source = 16;
- if (has_source()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->source().data(), this->source().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.V0LayerParameter.source");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 16, this->source(), output);
- }
-
- // optional float scale = 17 [default = 1];
- if (has_scale()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(17, this->scale(), output);
- }
-
- // optional string meanfile = 18;
- if (has_meanfile()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->meanfile().data(), this->meanfile().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.V0LayerParameter.meanfile");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 18, this->meanfile(), output);
- }
-
- // optional uint32 batchsize = 19;
- if (has_batchsize()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(19, this->batchsize(), output);
- }
-
- // optional uint32 cropsize = 20 [default = 0];
- if (has_cropsize()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(20, this->cropsize(), output);
- }
-
- // optional bool mirror = 21 [default = false];
- if (has_mirror()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(21, this->mirror(), output);
- }
-
- // optional float k = 22 [default = 1];
- if (has_k()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(22, this->k(), output);
- }
-
- // repeated .caffe.BlobProto blobs = 50;
- for (unsigned int i = 0, n = this->blobs_size(); i < n; i++) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 50, this->blobs(i), output);
- }
-
- // repeated float blobs_lr = 51;
- for (int i = 0; i < this->blobs_lr_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(
- 51, this->blobs_lr(i), output);
- }
-
- // repeated float weight_decay = 52;
- for (int i = 0; i < this->weight_decay_size(); i++) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(
- 52, this->weight_decay(i), output);
- }
-
- // optional uint32 rand_skip = 53 [default = 0];
- if (has_rand_skip()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(53, this->rand_skip(), output);
- }
-
- // optional float det_fg_threshold = 54 [default = 0.5];
- if (has_det_fg_threshold()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(54, this->det_fg_threshold(), output);
- }
-
- // optional float det_bg_threshold = 55 [default = 0.5];
- if (has_det_bg_threshold()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(55, this->det_bg_threshold(), output);
- }
-
- // optional float det_fg_fraction = 56 [default = 0.25];
- if (has_det_fg_fraction()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(56, this->det_fg_fraction(), output);
- }
-
- // optional uint32 det_context_pad = 58 [default = 0];
- if (has_det_context_pad()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(58, this->det_context_pad(), output);
- }
-
- // optional string det_crop_mode = 59 [default = "warp"];
- if (has_det_crop_mode()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->det_crop_mode().data(), this->det_crop_mode().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.V0LayerParameter.det_crop_mode");
- ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
- 59, this->det_crop_mode(), output);
- }
-
- // optional int32 new_num = 60 [default = 0];
- if (has_new_num()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(60, this->new_num(), output);
- }
-
- // optional int32 new_channels = 61 [default = 0];
- if (has_new_channels()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(61, this->new_channels(), output);
- }
-
- // optional int32 new_height = 62 [default = 0];
- if (has_new_height()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(62, this->new_height(), output);
- }
-
- // optional int32 new_width = 63 [default = 0];
- if (has_new_width()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(63, this->new_width(), output);
- }
-
- // optional bool shuffle_images = 64 [default = false];
- if (has_shuffle_images()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(64, this->shuffle_images(), output);
- }
-
- // optional uint32 concat_dim = 65 [default = 1];
- if (has_concat_dim()) {
- ::google::protobuf::internal::WireFormatLite::WriteUInt32(65, this->concat_dim(), output);
- }
-
- // optional .caffe.HDF5OutputParameter hdf5_output_param = 1001;
- if (has_hdf5_output_param()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 1001, *this->hdf5_output_param_, output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.V0LayerParameter)
-}
-
-::google::protobuf::uint8* V0LayerParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.V0LayerParameter)
- // optional string name = 1;
- if (has_name()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->name().data(), this->name().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.V0LayerParameter.name");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 1, this->name(), target);
- }
-
- // optional string type = 2;
- if (has_type()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->type().data(), this->type().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.V0LayerParameter.type");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 2, this->type(), target);
- }
-
- // optional uint32 num_output = 3;
- if (has_num_output()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(3, this->num_output(), target);
- }
-
- // optional bool biasterm = 4 [default = true];
- if (has_biasterm()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(4, this->biasterm(), target);
- }
-
- // optional .caffe.FillerParameter weight_filler = 5;
- if (has_weight_filler()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 5, *this->weight_filler_, false, target);
- }
-
- // optional .caffe.FillerParameter bias_filler = 6;
- if (has_bias_filler()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 6, *this->bias_filler_, false, target);
- }
-
- // optional uint32 pad = 7 [default = 0];
- if (has_pad()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(7, this->pad(), target);
- }
-
- // optional uint32 kernelsize = 8;
- if (has_kernelsize()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(8, this->kernelsize(), target);
- }
-
- // optional uint32 group = 9 [default = 1];
- if (has_group()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(9, this->group(), target);
- }
-
- // optional uint32 stride = 10 [default = 1];
- if (has_stride()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(10, this->stride(), target);
- }
-
- // optional .caffe.V0LayerParameter.PoolMethod pool = 11 [default = MAX];
- if (has_pool()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
- 11, this->pool(), target);
- }
-
- // optional float dropout_ratio = 12 [default = 0.5];
- if (has_dropout_ratio()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(12, this->dropout_ratio(), target);
- }
-
- // optional uint32 local_size = 13 [default = 5];
- if (has_local_size()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(13, this->local_size(), target);
- }
-
- // optional float alpha = 14 [default = 1];
- if (has_alpha()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(14, this->alpha(), target);
- }
-
- // optional float beta = 15 [default = 0.75];
- if (has_beta()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(15, this->beta(), target);
- }
-
- // optional string source = 16;
- if (has_source()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->source().data(), this->source().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.V0LayerParameter.source");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 16, this->source(), target);
- }
-
- // optional float scale = 17 [default = 1];
- if (has_scale()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(17, this->scale(), target);
- }
-
- // optional string meanfile = 18;
- if (has_meanfile()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->meanfile().data(), this->meanfile().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.V0LayerParameter.meanfile");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 18, this->meanfile(), target);
- }
-
- // optional uint32 batchsize = 19;
- if (has_batchsize()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(19, this->batchsize(), target);
- }
-
- // optional uint32 cropsize = 20 [default = 0];
- if (has_cropsize()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(20, this->cropsize(), target);
- }
-
- // optional bool mirror = 21 [default = false];
- if (has_mirror()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(21, this->mirror(), target);
- }
-
- // optional float k = 22 [default = 1];
- if (has_k()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(22, this->k(), target);
- }
-
- // repeated .caffe.BlobProto blobs = 50;
- for (unsigned int i = 0, n = this->blobs_size(); i < n; i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 50, this->blobs(i), false, target);
- }
-
- // repeated float blobs_lr = 51;
- for (int i = 0; i < this->blobs_lr_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteFloatToArray(51, this->blobs_lr(i), target);
- }
-
- // repeated float weight_decay = 52;
- for (int i = 0; i < this->weight_decay_size(); i++) {
- target = ::google::protobuf::internal::WireFormatLite::
- WriteFloatToArray(52, this->weight_decay(i), target);
- }
-
- // optional uint32 rand_skip = 53 [default = 0];
- if (has_rand_skip()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(53, this->rand_skip(), target);
- }
-
- // optional float det_fg_threshold = 54 [default = 0.5];
- if (has_det_fg_threshold()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(54, this->det_fg_threshold(), target);
- }
-
- // optional float det_bg_threshold = 55 [default = 0.5];
- if (has_det_bg_threshold()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(55, this->det_bg_threshold(), target);
- }
-
- // optional float det_fg_fraction = 56 [default = 0.25];
- if (has_det_fg_fraction()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(56, this->det_fg_fraction(), target);
- }
-
- // optional uint32 det_context_pad = 58 [default = 0];
- if (has_det_context_pad()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(58, this->det_context_pad(), target);
- }
-
- // optional string det_crop_mode = 59 [default = "warp"];
- if (has_det_crop_mode()) {
- ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
- this->det_crop_mode().data(), this->det_crop_mode().length(),
- ::google::protobuf::internal::WireFormat::SERIALIZE,
- "caffe.V0LayerParameter.det_crop_mode");
- target =
- ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
- 59, this->det_crop_mode(), target);
- }
-
- // optional int32 new_num = 60 [default = 0];
- if (has_new_num()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(60, this->new_num(), target);
- }
-
- // optional int32 new_channels = 61 [default = 0];
- if (has_new_channels()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(61, this->new_channels(), target);
- }
-
- // optional int32 new_height = 62 [default = 0];
- if (has_new_height()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(62, this->new_height(), target);
- }
-
- // optional int32 new_width = 63 [default = 0];
- if (has_new_width()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(63, this->new_width(), target);
- }
-
- // optional bool shuffle_images = 64 [default = false];
- if (has_shuffle_images()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(64, this->shuffle_images(), target);
- }
-
- // optional uint32 concat_dim = 65 [default = 1];
- if (has_concat_dim()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(65, this->concat_dim(), target);
- }
-
- // optional .caffe.HDF5OutputParameter hdf5_output_param = 1001;
- if (has_hdf5_output_param()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 1001, *this->hdf5_output_param_, false, target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.V0LayerParameter)
- return target;
-}
-
-size_t V0LayerParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.V0LayerParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 255u) {
- // optional string name = 1;
- if (has_name()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->name());
- }
-
- // optional string type = 2;
- if (has_type()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->type());
- }
-
- // optional uint32 num_output = 3;
- if (has_num_output()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->num_output());
- }
-
- // optional bool biasterm = 4 [default = true];
- if (has_biasterm()) {
- total_size += 1 + 1;
- }
-
- // optional .caffe.FillerParameter weight_filler = 5;
- if (has_weight_filler()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->weight_filler_);
- }
-
- // optional .caffe.FillerParameter bias_filler = 6;
- if (has_bias_filler()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->bias_filler_);
- }
-
- // optional uint32 pad = 7 [default = 0];
- if (has_pad()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->pad());
- }
-
- // optional uint32 kernelsize = 8;
- if (has_kernelsize()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->kernelsize());
- }
-
- }
- if (_has_bits_[8 / 32] & 65280u) {
- // optional uint32 group = 9 [default = 1];
- if (has_group()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->group());
- }
-
- // optional uint32 stride = 10 [default = 1];
- if (has_stride()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->stride());
- }
-
- // optional .caffe.V0LayerParameter.PoolMethod pool = 11 [default = MAX];
- if (has_pool()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::EnumSize(this->pool());
- }
-
- // optional float dropout_ratio = 12 [default = 0.5];
- if (has_dropout_ratio()) {
- total_size += 1 + 4;
- }
-
- // optional uint32 local_size = 13 [default = 5];
- if (has_local_size()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->local_size());
- }
-
- // optional float alpha = 14 [default = 1];
- if (has_alpha()) {
- total_size += 1 + 4;
- }
-
- // optional float beta = 15 [default = 0.75];
- if (has_beta()) {
- total_size += 1 + 4;
- }
-
- // optional float k = 22 [default = 1];
- if (has_k()) {
- total_size += 2 + 4;
- }
-
- }
- if (_has_bits_[16 / 32] & 4128768u) {
- // optional string source = 16;
- if (has_source()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->source());
- }
-
- // optional float scale = 17 [default = 1];
- if (has_scale()) {
- total_size += 2 + 4;
- }
-
- // optional string meanfile = 18;
- if (has_meanfile()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->meanfile());
- }
-
- // optional uint32 batchsize = 19;
- if (has_batchsize()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->batchsize());
- }
-
- // optional uint32 cropsize = 20 [default = 0];
- if (has_cropsize()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->cropsize());
- }
-
- // optional bool mirror = 21 [default = false];
- if (has_mirror()) {
- total_size += 2 + 1;
- }
-
- }
- if (_has_bits_[25 / 32] & 4261412864u) {
- // optional uint32 rand_skip = 53 [default = 0];
- if (has_rand_skip()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->rand_skip());
- }
-
- // optional float det_fg_threshold = 54 [default = 0.5];
- if (has_det_fg_threshold()) {
- total_size += 2 + 4;
- }
-
- // optional float det_bg_threshold = 55 [default = 0.5];
- if (has_det_bg_threshold()) {
- total_size += 2 + 4;
- }
-
- // optional float det_fg_fraction = 56 [default = 0.25];
- if (has_det_fg_fraction()) {
- total_size += 2 + 4;
- }
-
- // optional uint32 det_context_pad = 58 [default = 0];
- if (has_det_context_pad()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->det_context_pad());
- }
-
- // optional string det_crop_mode = 59 [default = "warp"];
- if (has_det_crop_mode()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::StringSize(
- this->det_crop_mode());
- }
-
- // optional int32 new_num = 60 [default = 0];
- if (has_new_num()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->new_num());
- }
-
- }
- if (_has_bits_[32 / 32] & 63u) {
- // optional int32 new_channels = 61 [default = 0];
- if (has_new_channels()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->new_channels());
- }
-
- // optional int32 new_height = 62 [default = 0];
- if (has_new_height()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->new_height());
- }
-
- // optional int32 new_width = 63 [default = 0];
- if (has_new_width()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->new_width());
- }
-
- // optional bool shuffle_images = 64 [default = false];
- if (has_shuffle_images()) {
- total_size += 2 + 1;
- }
-
- // optional uint32 concat_dim = 65 [default = 1];
- if (has_concat_dim()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::UInt32Size(
- this->concat_dim());
- }
-
- // optional .caffe.HDF5OutputParameter hdf5_output_param = 1001;
- if (has_hdf5_output_param()) {
- total_size += 2 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->hdf5_output_param_);
- }
-
- }
- // repeated .caffe.BlobProto blobs = 50;
- {
- unsigned int count = this->blobs_size();
- total_size += 2UL * count;
- for (unsigned int i = 0; i < count; i++) {
- total_size +=
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- this->blobs(i));
- }
- }
-
- // repeated float blobs_lr = 51;
- {
- size_t data_size = 0;
- unsigned int count = this->blobs_lr_size();
- data_size = 4UL * count;
- total_size += 2 *
- ::google::protobuf::internal::FromIntSize(this->blobs_lr_size());
- total_size += data_size;
- }
-
- // repeated float weight_decay = 52;
- {
- size_t data_size = 0;
- unsigned int count = this->weight_decay_size();
- data_size = 4UL * count;
- total_size += 2 *
- ::google::protobuf::internal::FromIntSize(this->weight_decay_size());
- total_size += data_size;
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void V0LayerParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.V0LayerParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const V0LayerParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const V0LayerParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.V0LayerParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.V0LayerParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void V0LayerParameter::MergeFrom(const V0LayerParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.V0LayerParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void V0LayerParameter::UnsafeMergeFrom(const V0LayerParameter& from) {
- GOOGLE_DCHECK(&from != this);
- blobs_.MergeFrom(from.blobs_);
- blobs_lr_.UnsafeMergeFrom(from.blobs_lr_);
- weight_decay_.UnsafeMergeFrom(from.weight_decay_);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_name()) {
- set_has_name();
- name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
- }
- if (from.has_type()) {
- set_has_type();
- type_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_);
- }
- if (from.has_num_output()) {
- set_num_output(from.num_output());
- }
- if (from.has_biasterm()) {
- set_biasterm(from.biasterm());
- }
- if (from.has_weight_filler()) {
- mutable_weight_filler()->::caffe::FillerParameter::MergeFrom(from.weight_filler());
- }
- if (from.has_bias_filler()) {
- mutable_bias_filler()->::caffe::FillerParameter::MergeFrom(from.bias_filler());
- }
- if (from.has_pad()) {
- set_pad(from.pad());
- }
- if (from.has_kernelsize()) {
- set_kernelsize(from.kernelsize());
- }
- }
- if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) {
- if (from.has_group()) {
- set_group(from.group());
- }
- if (from.has_stride()) {
- set_stride(from.stride());
- }
- if (from.has_pool()) {
- set_pool(from.pool());
- }
- if (from.has_dropout_ratio()) {
- set_dropout_ratio(from.dropout_ratio());
- }
- if (from.has_local_size()) {
- set_local_size(from.local_size());
- }
- if (from.has_alpha()) {
- set_alpha(from.alpha());
- }
- if (from.has_beta()) {
- set_beta(from.beta());
- }
- if (from.has_k()) {
- set_k(from.k());
- }
- }
- if (from._has_bits_[16 / 32] & (0xffu << (16 % 32))) {
- if (from.has_source()) {
- set_has_source();
- source_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_);
- }
- if (from.has_scale()) {
- set_scale(from.scale());
- }
- if (from.has_meanfile()) {
- set_has_meanfile();
- meanfile_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.meanfile_);
- }
- if (from.has_batchsize()) {
- set_batchsize(from.batchsize());
- }
- if (from.has_cropsize()) {
- set_cropsize(from.cropsize());
- }
- if (from.has_mirror()) {
- set_mirror(from.mirror());
- }
- }
- if (from._has_bits_[25 / 32] & (0xffu << (25 % 32))) {
- if (from.has_rand_skip()) {
- set_rand_skip(from.rand_skip());
- }
- if (from.has_det_fg_threshold()) {
- set_det_fg_threshold(from.det_fg_threshold());
- }
- if (from.has_det_bg_threshold()) {
- set_det_bg_threshold(from.det_bg_threshold());
- }
- if (from.has_det_fg_fraction()) {
- set_det_fg_fraction(from.det_fg_fraction());
- }
- if (from.has_det_context_pad()) {
- set_det_context_pad(from.det_context_pad());
- }
- if (from.has_det_crop_mode()) {
- set_has_det_crop_mode();
- det_crop_mode_.AssignWithDefault(_default_det_crop_mode_, from.det_crop_mode_);
- }
- if (from.has_new_num()) {
- set_new_num(from.new_num());
- }
- }
- if (from._has_bits_[32 / 32] & (0xffu << (32 % 32))) {
- if (from.has_new_channels()) {
- set_new_channels(from.new_channels());
- }
- if (from.has_new_height()) {
- set_new_height(from.new_height());
- }
- if (from.has_new_width()) {
- set_new_width(from.new_width());
- }
- if (from.has_shuffle_images()) {
- set_shuffle_images(from.shuffle_images());
- }
- if (from.has_concat_dim()) {
- set_concat_dim(from.concat_dim());
- }
- if (from.has_hdf5_output_param()) {
- mutable_hdf5_output_param()->::caffe::HDF5OutputParameter::MergeFrom(from.hdf5_output_param());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void V0LayerParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.V0LayerParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void V0LayerParameter::CopyFrom(const V0LayerParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.V0LayerParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool V0LayerParameter::IsInitialized() const {
-
- return true;
-}
-
-void V0LayerParameter::Swap(V0LayerParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void V0LayerParameter::InternalSwap(V0LayerParameter* other) {
- name_.Swap(&other->name_);
- type_.Swap(&other->type_);
- std::swap(num_output_, other->num_output_);
- std::swap(biasterm_, other->biasterm_);
- std::swap(weight_filler_, other->weight_filler_);
- std::swap(bias_filler_, other->bias_filler_);
- std::swap(pad_, other->pad_);
- std::swap(kernelsize_, other->kernelsize_);
- std::swap(group_, other->group_);
- std::swap(stride_, other->stride_);
- std::swap(pool_, other->pool_);
- std::swap(dropout_ratio_, other->dropout_ratio_);
- std::swap(local_size_, other->local_size_);
- std::swap(alpha_, other->alpha_);
- std::swap(beta_, other->beta_);
- std::swap(k_, other->k_);
- source_.Swap(&other->source_);
- std::swap(scale_, other->scale_);
- meanfile_.Swap(&other->meanfile_);
- std::swap(batchsize_, other->batchsize_);
- std::swap(cropsize_, other->cropsize_);
- std::swap(mirror_, other->mirror_);
- blobs_.UnsafeArenaSwap(&other->blobs_);
- blobs_lr_.UnsafeArenaSwap(&other->blobs_lr_);
- weight_decay_.UnsafeArenaSwap(&other->weight_decay_);
- std::swap(rand_skip_, other->rand_skip_);
- std::swap(det_fg_threshold_, other->det_fg_threshold_);
- std::swap(det_bg_threshold_, other->det_bg_threshold_);
- std::swap(det_fg_fraction_, other->det_fg_fraction_);
- std::swap(det_context_pad_, other->det_context_pad_);
- det_crop_mode_.Swap(&other->det_crop_mode_);
- std::swap(new_num_, other->new_num_);
- std::swap(new_channels_, other->new_channels_);
- std::swap(new_height_, other->new_height_);
- std::swap(new_width_, other->new_width_);
- std::swap(shuffle_images_, other->shuffle_images_);
- std::swap(concat_dim_, other->concat_dim_);
- std::swap(hdf5_output_param_, other->hdf5_output_param_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- std::swap(_has_bits_[1], other->_has_bits_[1]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata V0LayerParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = V0LayerParameter_descriptor_;
- metadata.reflection = V0LayerParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// V0LayerParameter
-
-// optional string name = 1;
-bool V0LayerParameter::has_name() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void V0LayerParameter::set_has_name() {
- _has_bits_[0] |= 0x00000001u;
-}
-void V0LayerParameter::clear_has_name() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void V0LayerParameter::clear_name() {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_name();
-}
-const ::std::string& V0LayerParameter::name() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void V0LayerParameter::set_name(const ::std::string& value) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.name)
-}
-void V0LayerParameter::set_name(const char* value) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.name)
-}
-void V0LayerParameter::set_name(const char* value, size_t size) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.name)
-}
-::std::string* V0LayerParameter::mutable_name() {
- set_has_name();
- // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.name)
- return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* V0LayerParameter::release_name() {
- // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.name)
- clear_has_name();
- return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void V0LayerParameter::set_allocated_name(::std::string* name) {
- if (name != NULL) {
- set_has_name();
- } else {
- clear_has_name();
- }
- name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
- // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.name)
-}
-
-// optional string type = 2;
-bool V0LayerParameter::has_type() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void V0LayerParameter::set_has_type() {
- _has_bits_[0] |= 0x00000002u;
-}
-void V0LayerParameter::clear_has_type() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void V0LayerParameter::clear_type() {
- type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_type();
-}
-const ::std::string& V0LayerParameter::type() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.type)
- return type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void V0LayerParameter::set_type(const ::std::string& value) {
- set_has_type();
- type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.type)
-}
-void V0LayerParameter::set_type(const char* value) {
- set_has_type();
- type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.type)
-}
-void V0LayerParameter::set_type(const char* value, size_t size) {
- set_has_type();
- type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.type)
-}
-::std::string* V0LayerParameter::mutable_type() {
- set_has_type();
- // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.type)
- return type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* V0LayerParameter::release_type() {
- // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.type)
- clear_has_type();
- return type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void V0LayerParameter::set_allocated_type(::std::string* type) {
- if (type != NULL) {
- set_has_type();
- } else {
- clear_has_type();
- }
- type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type);
- // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.type)
-}
-
-// optional uint32 num_output = 3;
-bool V0LayerParameter::has_num_output() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void V0LayerParameter::set_has_num_output() {
- _has_bits_[0] |= 0x00000004u;
-}
-void V0LayerParameter::clear_has_num_output() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void V0LayerParameter::clear_num_output() {
- num_output_ = 0u;
- clear_has_num_output();
-}
-::google::protobuf::uint32 V0LayerParameter::num_output() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.num_output)
- return num_output_;
-}
-void V0LayerParameter::set_num_output(::google::protobuf::uint32 value) {
- set_has_num_output();
- num_output_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.num_output)
-}
-
-// optional bool biasterm = 4 [default = true];
-bool V0LayerParameter::has_biasterm() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-void V0LayerParameter::set_has_biasterm() {
- _has_bits_[0] |= 0x00000008u;
-}
-void V0LayerParameter::clear_has_biasterm() {
- _has_bits_[0] &= ~0x00000008u;
-}
-void V0LayerParameter::clear_biasterm() {
- biasterm_ = true;
- clear_has_biasterm();
-}
-bool V0LayerParameter::biasterm() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.biasterm)
- return biasterm_;
-}
-void V0LayerParameter::set_biasterm(bool value) {
- set_has_biasterm();
- biasterm_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.biasterm)
-}
-
-// optional .caffe.FillerParameter weight_filler = 5;
-bool V0LayerParameter::has_weight_filler() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-void V0LayerParameter::set_has_weight_filler() {
- _has_bits_[0] |= 0x00000010u;
-}
-void V0LayerParameter::clear_has_weight_filler() {
- _has_bits_[0] &= ~0x00000010u;
-}
-void V0LayerParameter::clear_weight_filler() {
- if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear();
- clear_has_weight_filler();
-}
-const ::caffe::FillerParameter& V0LayerParameter::weight_filler() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.weight_filler)
- return weight_filler_ != NULL ? *weight_filler_
- : *::caffe::FillerParameter::internal_default_instance();
-}
-::caffe::FillerParameter* V0LayerParameter::mutable_weight_filler() {
- set_has_weight_filler();
- if (weight_filler_ == NULL) {
- weight_filler_ = new ::caffe::FillerParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.weight_filler)
- return weight_filler_;
-}
-::caffe::FillerParameter* V0LayerParameter::release_weight_filler() {
- // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.weight_filler)
- clear_has_weight_filler();
- ::caffe::FillerParameter* temp = weight_filler_;
- weight_filler_ = NULL;
- return temp;
-}
-void V0LayerParameter::set_allocated_weight_filler(::caffe::FillerParameter* weight_filler) {
- delete weight_filler_;
- weight_filler_ = weight_filler;
- if (weight_filler) {
- set_has_weight_filler();
- } else {
- clear_has_weight_filler();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.weight_filler)
-}
-
-// optional .caffe.FillerParameter bias_filler = 6;
-bool V0LayerParameter::has_bias_filler() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-void V0LayerParameter::set_has_bias_filler() {
- _has_bits_[0] |= 0x00000020u;
-}
-void V0LayerParameter::clear_has_bias_filler() {
- _has_bits_[0] &= ~0x00000020u;
-}
-void V0LayerParameter::clear_bias_filler() {
- if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
- clear_has_bias_filler();
-}
-const ::caffe::FillerParameter& V0LayerParameter::bias_filler() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.bias_filler)
- return bias_filler_ != NULL ? *bias_filler_
- : *::caffe::FillerParameter::internal_default_instance();
-}
-::caffe::FillerParameter* V0LayerParameter::mutable_bias_filler() {
- set_has_bias_filler();
- if (bias_filler_ == NULL) {
- bias_filler_ = new ::caffe::FillerParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.bias_filler)
- return bias_filler_;
-}
-::caffe::FillerParameter* V0LayerParameter::release_bias_filler() {
- // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.bias_filler)
- clear_has_bias_filler();
- ::caffe::FillerParameter* temp = bias_filler_;
- bias_filler_ = NULL;
- return temp;
-}
-void V0LayerParameter::set_allocated_bias_filler(::caffe::FillerParameter* bias_filler) {
- delete bias_filler_;
- bias_filler_ = bias_filler;
- if (bias_filler) {
- set_has_bias_filler();
- } else {
- clear_has_bias_filler();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.bias_filler)
-}
-
-// optional uint32 pad = 7 [default = 0];
-bool V0LayerParameter::has_pad() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-void V0LayerParameter::set_has_pad() {
- _has_bits_[0] |= 0x00000040u;
-}
-void V0LayerParameter::clear_has_pad() {
- _has_bits_[0] &= ~0x00000040u;
-}
-void V0LayerParameter::clear_pad() {
- pad_ = 0u;
- clear_has_pad();
-}
-::google::protobuf::uint32 V0LayerParameter::pad() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.pad)
- return pad_;
-}
-void V0LayerParameter::set_pad(::google::protobuf::uint32 value) {
- set_has_pad();
- pad_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.pad)
-}
-
-// optional uint32 kernelsize = 8;
-bool V0LayerParameter::has_kernelsize() const {
- return (_has_bits_[0] & 0x00000080u) != 0;
-}
-void V0LayerParameter::set_has_kernelsize() {
- _has_bits_[0] |= 0x00000080u;
-}
-void V0LayerParameter::clear_has_kernelsize() {
- _has_bits_[0] &= ~0x00000080u;
-}
-void V0LayerParameter::clear_kernelsize() {
- kernelsize_ = 0u;
- clear_has_kernelsize();
-}
-::google::protobuf::uint32 V0LayerParameter::kernelsize() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.kernelsize)
- return kernelsize_;
-}
-void V0LayerParameter::set_kernelsize(::google::protobuf::uint32 value) {
- set_has_kernelsize();
- kernelsize_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.kernelsize)
-}
-
-// optional uint32 group = 9 [default = 1];
-bool V0LayerParameter::has_group() const {
- return (_has_bits_[0] & 0x00000100u) != 0;
-}
-void V0LayerParameter::set_has_group() {
- _has_bits_[0] |= 0x00000100u;
-}
-void V0LayerParameter::clear_has_group() {
- _has_bits_[0] &= ~0x00000100u;
-}
-void V0LayerParameter::clear_group() {
- group_ = 1u;
- clear_has_group();
-}
-::google::protobuf::uint32 V0LayerParameter::group() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.group)
- return group_;
-}
-void V0LayerParameter::set_group(::google::protobuf::uint32 value) {
- set_has_group();
- group_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.group)
-}
-
-// optional uint32 stride = 10 [default = 1];
-bool V0LayerParameter::has_stride() const {
- return (_has_bits_[0] & 0x00000200u) != 0;
-}
-void V0LayerParameter::set_has_stride() {
- _has_bits_[0] |= 0x00000200u;
-}
-void V0LayerParameter::clear_has_stride() {
- _has_bits_[0] &= ~0x00000200u;
-}
-void V0LayerParameter::clear_stride() {
- stride_ = 1u;
- clear_has_stride();
-}
-::google::protobuf::uint32 V0LayerParameter::stride() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.stride)
- return stride_;
-}
-void V0LayerParameter::set_stride(::google::protobuf::uint32 value) {
- set_has_stride();
- stride_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.stride)
-}
-
-// optional .caffe.V0LayerParameter.PoolMethod pool = 11 [default = MAX];
-bool V0LayerParameter::has_pool() const {
- return (_has_bits_[0] & 0x00000400u) != 0;
-}
-void V0LayerParameter::set_has_pool() {
- _has_bits_[0] |= 0x00000400u;
-}
-void V0LayerParameter::clear_has_pool() {
- _has_bits_[0] &= ~0x00000400u;
-}
-void V0LayerParameter::clear_pool() {
- pool_ = 0;
- clear_has_pool();
-}
-::caffe::V0LayerParameter_PoolMethod V0LayerParameter::pool() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.pool)
- return static_cast< ::caffe::V0LayerParameter_PoolMethod >(pool_);
-}
-void V0LayerParameter::set_pool(::caffe::V0LayerParameter_PoolMethod value) {
- assert(::caffe::V0LayerParameter_PoolMethod_IsValid(value));
- set_has_pool();
- pool_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.pool)
-}
-
-// optional float dropout_ratio = 12 [default = 0.5];
-bool V0LayerParameter::has_dropout_ratio() const {
- return (_has_bits_[0] & 0x00000800u) != 0;
-}
-void V0LayerParameter::set_has_dropout_ratio() {
- _has_bits_[0] |= 0x00000800u;
-}
-void V0LayerParameter::clear_has_dropout_ratio() {
- _has_bits_[0] &= ~0x00000800u;
-}
-void V0LayerParameter::clear_dropout_ratio() {
- dropout_ratio_ = 0.5f;
- clear_has_dropout_ratio();
-}
-float V0LayerParameter::dropout_ratio() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.dropout_ratio)
- return dropout_ratio_;
-}
-void V0LayerParameter::set_dropout_ratio(float value) {
- set_has_dropout_ratio();
- dropout_ratio_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.dropout_ratio)
-}
-
-// optional uint32 local_size = 13 [default = 5];
-bool V0LayerParameter::has_local_size() const {
- return (_has_bits_[0] & 0x00001000u) != 0;
-}
-void V0LayerParameter::set_has_local_size() {
- _has_bits_[0] |= 0x00001000u;
-}
-void V0LayerParameter::clear_has_local_size() {
- _has_bits_[0] &= ~0x00001000u;
-}
-void V0LayerParameter::clear_local_size() {
- local_size_ = 5u;
- clear_has_local_size();
-}
-::google::protobuf::uint32 V0LayerParameter::local_size() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.local_size)
- return local_size_;
-}
-void V0LayerParameter::set_local_size(::google::protobuf::uint32 value) {
- set_has_local_size();
- local_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.local_size)
-}
-
-// optional float alpha = 14 [default = 1];
-bool V0LayerParameter::has_alpha() const {
- return (_has_bits_[0] & 0x00002000u) != 0;
-}
-void V0LayerParameter::set_has_alpha() {
- _has_bits_[0] |= 0x00002000u;
-}
-void V0LayerParameter::clear_has_alpha() {
- _has_bits_[0] &= ~0x00002000u;
-}
-void V0LayerParameter::clear_alpha() {
- alpha_ = 1;
- clear_has_alpha();
-}
-float V0LayerParameter::alpha() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.alpha)
- return alpha_;
-}
-void V0LayerParameter::set_alpha(float value) {
- set_has_alpha();
- alpha_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.alpha)
-}
-
-// optional float beta = 15 [default = 0.75];
-bool V0LayerParameter::has_beta() const {
- return (_has_bits_[0] & 0x00004000u) != 0;
-}
-void V0LayerParameter::set_has_beta() {
- _has_bits_[0] |= 0x00004000u;
-}
-void V0LayerParameter::clear_has_beta() {
- _has_bits_[0] &= ~0x00004000u;
-}
-void V0LayerParameter::clear_beta() {
- beta_ = 0.75f;
- clear_has_beta();
-}
-float V0LayerParameter::beta() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.beta)
- return beta_;
-}
-void V0LayerParameter::set_beta(float value) {
- set_has_beta();
- beta_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.beta)
-}
-
-// optional float k = 22 [default = 1];
-bool V0LayerParameter::has_k() const {
- return (_has_bits_[0] & 0x00008000u) != 0;
-}
-void V0LayerParameter::set_has_k() {
- _has_bits_[0] |= 0x00008000u;
-}
-void V0LayerParameter::clear_has_k() {
- _has_bits_[0] &= ~0x00008000u;
-}
-void V0LayerParameter::clear_k() {
- k_ = 1;
- clear_has_k();
-}
-float V0LayerParameter::k() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.k)
- return k_;
-}
-void V0LayerParameter::set_k(float value) {
- set_has_k();
- k_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.k)
-}
-
-// optional string source = 16;
-bool V0LayerParameter::has_source() const {
- return (_has_bits_[0] & 0x00010000u) != 0;
-}
-void V0LayerParameter::set_has_source() {
- _has_bits_[0] |= 0x00010000u;
-}
-void V0LayerParameter::clear_has_source() {
- _has_bits_[0] &= ~0x00010000u;
-}
-void V0LayerParameter::clear_source() {
- source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_source();
-}
-const ::std::string& V0LayerParameter::source() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.source)
- return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void V0LayerParameter::set_source(const ::std::string& value) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.source)
-}
-void V0LayerParameter::set_source(const char* value) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.source)
-}
-void V0LayerParameter::set_source(const char* value, size_t size) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.source)
-}
-::std::string* V0LayerParameter::mutable_source() {
- set_has_source();
- // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.source)
- return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* V0LayerParameter::release_source() {
- // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.source)
- clear_has_source();
- return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void V0LayerParameter::set_allocated_source(::std::string* source) {
- if (source != NULL) {
- set_has_source();
- } else {
- clear_has_source();
- }
- source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source);
- // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.source)
-}
-
-// optional float scale = 17 [default = 1];
-bool V0LayerParameter::has_scale() const {
- return (_has_bits_[0] & 0x00020000u) != 0;
-}
-void V0LayerParameter::set_has_scale() {
- _has_bits_[0] |= 0x00020000u;
-}
-void V0LayerParameter::clear_has_scale() {
- _has_bits_[0] &= ~0x00020000u;
-}
-void V0LayerParameter::clear_scale() {
- scale_ = 1;
- clear_has_scale();
-}
-float V0LayerParameter::scale() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.scale)
- return scale_;
-}
-void V0LayerParameter::set_scale(float value) {
- set_has_scale();
- scale_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.scale)
-}
-
-// optional string meanfile = 18;
-bool V0LayerParameter::has_meanfile() const {
- return (_has_bits_[0] & 0x00040000u) != 0;
-}
-void V0LayerParameter::set_has_meanfile() {
- _has_bits_[0] |= 0x00040000u;
-}
-void V0LayerParameter::clear_has_meanfile() {
- _has_bits_[0] &= ~0x00040000u;
-}
-void V0LayerParameter::clear_meanfile() {
- meanfile_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_meanfile();
-}
-const ::std::string& V0LayerParameter::meanfile() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.meanfile)
- return meanfile_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void V0LayerParameter::set_meanfile(const ::std::string& value) {
- set_has_meanfile();
- meanfile_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.meanfile)
-}
-void V0LayerParameter::set_meanfile(const char* value) {
- set_has_meanfile();
- meanfile_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.meanfile)
-}
-void V0LayerParameter::set_meanfile(const char* value, size_t size) {
- set_has_meanfile();
- meanfile_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.meanfile)
-}
-::std::string* V0LayerParameter::mutable_meanfile() {
- set_has_meanfile();
- // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.meanfile)
- return meanfile_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-::std::string* V0LayerParameter::release_meanfile() {
- // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.meanfile)
- clear_has_meanfile();
- return meanfile_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-void V0LayerParameter::set_allocated_meanfile(::std::string* meanfile) {
- if (meanfile != NULL) {
- set_has_meanfile();
- } else {
- clear_has_meanfile();
- }
- meanfile_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), meanfile);
- // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.meanfile)
-}
-
-// optional uint32 batchsize = 19;
-bool V0LayerParameter::has_batchsize() const {
- return (_has_bits_[0] & 0x00080000u) != 0;
-}
-void V0LayerParameter::set_has_batchsize() {
- _has_bits_[0] |= 0x00080000u;
-}
-void V0LayerParameter::clear_has_batchsize() {
- _has_bits_[0] &= ~0x00080000u;
-}
-void V0LayerParameter::clear_batchsize() {
- batchsize_ = 0u;
- clear_has_batchsize();
-}
-::google::protobuf::uint32 V0LayerParameter::batchsize() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.batchsize)
- return batchsize_;
-}
-void V0LayerParameter::set_batchsize(::google::protobuf::uint32 value) {
- set_has_batchsize();
- batchsize_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.batchsize)
-}
-
-// optional uint32 cropsize = 20 [default = 0];
-bool V0LayerParameter::has_cropsize() const {
- return (_has_bits_[0] & 0x00100000u) != 0;
-}
-void V0LayerParameter::set_has_cropsize() {
- _has_bits_[0] |= 0x00100000u;
-}
-void V0LayerParameter::clear_has_cropsize() {
- _has_bits_[0] &= ~0x00100000u;
-}
-void V0LayerParameter::clear_cropsize() {
- cropsize_ = 0u;
- clear_has_cropsize();
-}
-::google::protobuf::uint32 V0LayerParameter::cropsize() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.cropsize)
- return cropsize_;
-}
-void V0LayerParameter::set_cropsize(::google::protobuf::uint32 value) {
- set_has_cropsize();
- cropsize_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.cropsize)
-}
-
-// optional bool mirror = 21 [default = false];
-bool V0LayerParameter::has_mirror() const {
- return (_has_bits_[0] & 0x00200000u) != 0;
-}
-void V0LayerParameter::set_has_mirror() {
- _has_bits_[0] |= 0x00200000u;
-}
-void V0LayerParameter::clear_has_mirror() {
- _has_bits_[0] &= ~0x00200000u;
-}
-void V0LayerParameter::clear_mirror() {
- mirror_ = false;
- clear_has_mirror();
-}
-bool V0LayerParameter::mirror() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.mirror)
- return mirror_;
-}
-void V0LayerParameter::set_mirror(bool value) {
- set_has_mirror();
- mirror_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.mirror)
-}
-
-// repeated .caffe.BlobProto blobs = 50;
-int V0LayerParameter::blobs_size() const {
- return blobs_.size();
-}
-void V0LayerParameter::clear_blobs() {
- blobs_.Clear();
-}
-const ::caffe::BlobProto& V0LayerParameter::blobs(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.blobs)
- return blobs_.Get(index);
-}
-::caffe::BlobProto* V0LayerParameter::mutable_blobs(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.blobs)
- return blobs_.Mutable(index);
-}
-::caffe::BlobProto* V0LayerParameter::add_blobs() {
- // @@protoc_insertion_point(field_add:caffe.V0LayerParameter.blobs)
- return blobs_.Add();
-}
-::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
-V0LayerParameter::mutable_blobs() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V0LayerParameter.blobs)
- return &blobs_;
-}
-const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
-V0LayerParameter::blobs() const {
- // @@protoc_insertion_point(field_list:caffe.V0LayerParameter.blobs)
- return blobs_;
-}
-
-// repeated float blobs_lr = 51;
-int V0LayerParameter::blobs_lr_size() const {
- return blobs_lr_.size();
-}
-void V0LayerParameter::clear_blobs_lr() {
- blobs_lr_.Clear();
-}
-float V0LayerParameter::blobs_lr(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.blobs_lr)
- return blobs_lr_.Get(index);
-}
-void V0LayerParameter::set_blobs_lr(int index, float value) {
- blobs_lr_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.blobs_lr)
-}
-void V0LayerParameter::add_blobs_lr(float value) {
- blobs_lr_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.V0LayerParameter.blobs_lr)
-}
-const ::google::protobuf::RepeatedField< float >&
-V0LayerParameter::blobs_lr() const {
- // @@protoc_insertion_point(field_list:caffe.V0LayerParameter.blobs_lr)
- return blobs_lr_;
-}
-::google::protobuf::RepeatedField< float >*
-V0LayerParameter::mutable_blobs_lr() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V0LayerParameter.blobs_lr)
- return &blobs_lr_;
-}
-
-// repeated float weight_decay = 52;
-int V0LayerParameter::weight_decay_size() const {
- return weight_decay_.size();
-}
-void V0LayerParameter::clear_weight_decay() {
- weight_decay_.Clear();
-}
-float V0LayerParameter::weight_decay(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.weight_decay)
- return weight_decay_.Get(index);
-}
-void V0LayerParameter::set_weight_decay(int index, float value) {
- weight_decay_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.weight_decay)
-}
-void V0LayerParameter::add_weight_decay(float value) {
- weight_decay_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.V0LayerParameter.weight_decay)
-}
-const ::google::protobuf::RepeatedField< float >&
-V0LayerParameter::weight_decay() const {
- // @@protoc_insertion_point(field_list:caffe.V0LayerParameter.weight_decay)
- return weight_decay_;
-}
-::google::protobuf::RepeatedField< float >*
-V0LayerParameter::mutable_weight_decay() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V0LayerParameter.weight_decay)
- return &weight_decay_;
-}
-
-// optional uint32 rand_skip = 53 [default = 0];
-bool V0LayerParameter::has_rand_skip() const {
- return (_has_bits_[0] & 0x02000000u) != 0;
-}
-void V0LayerParameter::set_has_rand_skip() {
- _has_bits_[0] |= 0x02000000u;
-}
-void V0LayerParameter::clear_has_rand_skip() {
- _has_bits_[0] &= ~0x02000000u;
-}
-void V0LayerParameter::clear_rand_skip() {
- rand_skip_ = 0u;
- clear_has_rand_skip();
-}
-::google::protobuf::uint32 V0LayerParameter::rand_skip() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.rand_skip)
- return rand_skip_;
-}
-void V0LayerParameter::set_rand_skip(::google::protobuf::uint32 value) {
- set_has_rand_skip();
- rand_skip_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.rand_skip)
-}
-
-// optional float det_fg_threshold = 54 [default = 0.5];
-bool V0LayerParameter::has_det_fg_threshold() const {
- return (_has_bits_[0] & 0x04000000u) != 0;
-}
-void V0LayerParameter::set_has_det_fg_threshold() {
- _has_bits_[0] |= 0x04000000u;
-}
-void V0LayerParameter::clear_has_det_fg_threshold() {
- _has_bits_[0] &= ~0x04000000u;
-}
-void V0LayerParameter::clear_det_fg_threshold() {
- det_fg_threshold_ = 0.5f;
- clear_has_det_fg_threshold();
-}
-float V0LayerParameter::det_fg_threshold() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_fg_threshold)
- return det_fg_threshold_;
-}
-void V0LayerParameter::set_det_fg_threshold(float value) {
- set_has_det_fg_threshold();
- det_fg_threshold_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_fg_threshold)
-}
-
-// optional float det_bg_threshold = 55 [default = 0.5];
-bool V0LayerParameter::has_det_bg_threshold() const {
- return (_has_bits_[0] & 0x08000000u) != 0;
-}
-void V0LayerParameter::set_has_det_bg_threshold() {
- _has_bits_[0] |= 0x08000000u;
-}
-void V0LayerParameter::clear_has_det_bg_threshold() {
- _has_bits_[0] &= ~0x08000000u;
-}
-void V0LayerParameter::clear_det_bg_threshold() {
- det_bg_threshold_ = 0.5f;
- clear_has_det_bg_threshold();
-}
-float V0LayerParameter::det_bg_threshold() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_bg_threshold)
- return det_bg_threshold_;
-}
-void V0LayerParameter::set_det_bg_threshold(float value) {
- set_has_det_bg_threshold();
- det_bg_threshold_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_bg_threshold)
-}
-
-// optional float det_fg_fraction = 56 [default = 0.25];
-bool V0LayerParameter::has_det_fg_fraction() const {
- return (_has_bits_[0] & 0x10000000u) != 0;
-}
-void V0LayerParameter::set_has_det_fg_fraction() {
- _has_bits_[0] |= 0x10000000u;
-}
-void V0LayerParameter::clear_has_det_fg_fraction() {
- _has_bits_[0] &= ~0x10000000u;
-}
-void V0LayerParameter::clear_det_fg_fraction() {
- det_fg_fraction_ = 0.25f;
- clear_has_det_fg_fraction();
-}
-float V0LayerParameter::det_fg_fraction() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_fg_fraction)
- return det_fg_fraction_;
-}
-void V0LayerParameter::set_det_fg_fraction(float value) {
- set_has_det_fg_fraction();
- det_fg_fraction_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_fg_fraction)
-}
-
-// optional uint32 det_context_pad = 58 [default = 0];
-bool V0LayerParameter::has_det_context_pad() const {
- return (_has_bits_[0] & 0x20000000u) != 0;
-}
-void V0LayerParameter::set_has_det_context_pad() {
- _has_bits_[0] |= 0x20000000u;
-}
-void V0LayerParameter::clear_has_det_context_pad() {
- _has_bits_[0] &= ~0x20000000u;
-}
-void V0LayerParameter::clear_det_context_pad() {
- det_context_pad_ = 0u;
- clear_has_det_context_pad();
-}
-::google::protobuf::uint32 V0LayerParameter::det_context_pad() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_context_pad)
- return det_context_pad_;
-}
-void V0LayerParameter::set_det_context_pad(::google::protobuf::uint32 value) {
- set_has_det_context_pad();
- det_context_pad_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_context_pad)
-}
-
-// optional string det_crop_mode = 59 [default = "warp"];
-bool V0LayerParameter::has_det_crop_mode() const {
- return (_has_bits_[0] & 0x40000000u) != 0;
-}
-void V0LayerParameter::set_has_det_crop_mode() {
- _has_bits_[0] |= 0x40000000u;
-}
-void V0LayerParameter::clear_has_det_crop_mode() {
- _has_bits_[0] &= ~0x40000000u;
-}
-void V0LayerParameter::clear_det_crop_mode() {
- det_crop_mode_.ClearToDefaultNoArena(_default_det_crop_mode_);
- clear_has_det_crop_mode();
-}
-const ::std::string& V0LayerParameter::det_crop_mode() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_crop_mode)
- return det_crop_mode_.GetNoArena(_default_det_crop_mode_);
-}
-void V0LayerParameter::set_det_crop_mode(const ::std::string& value) {
- set_has_det_crop_mode();
- det_crop_mode_.SetNoArena(_default_det_crop_mode_, value);
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_crop_mode)
-}
-void V0LayerParameter::set_det_crop_mode(const char* value) {
- set_has_det_crop_mode();
- det_crop_mode_.SetNoArena(_default_det_crop_mode_, ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.det_crop_mode)
-}
-void V0LayerParameter::set_det_crop_mode(const char* value, size_t size) {
- set_has_det_crop_mode();
- det_crop_mode_.SetNoArena(_default_det_crop_mode_,
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.det_crop_mode)
-}
-::std::string* V0LayerParameter::mutable_det_crop_mode() {
- set_has_det_crop_mode();
- // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.det_crop_mode)
- return det_crop_mode_.MutableNoArena(_default_det_crop_mode_);
-}
-::std::string* V0LayerParameter::release_det_crop_mode() {
- // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.det_crop_mode)
- clear_has_det_crop_mode();
- return det_crop_mode_.ReleaseNoArena(_default_det_crop_mode_);
-}
-void V0LayerParameter::set_allocated_det_crop_mode(::std::string* det_crop_mode) {
- if (det_crop_mode != NULL) {
- set_has_det_crop_mode();
- } else {
- clear_has_det_crop_mode();
- }
- det_crop_mode_.SetAllocatedNoArena(_default_det_crop_mode_, det_crop_mode);
- // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.det_crop_mode)
-}
-
-// optional int32 new_num = 60 [default = 0];
-bool V0LayerParameter::has_new_num() const {
- return (_has_bits_[0] & 0x80000000u) != 0;
-}
-void V0LayerParameter::set_has_new_num() {
- _has_bits_[0] |= 0x80000000u;
-}
-void V0LayerParameter::clear_has_new_num() {
- _has_bits_[0] &= ~0x80000000u;
-}
-void V0LayerParameter::clear_new_num() {
- new_num_ = 0;
- clear_has_new_num();
-}
-::google::protobuf::int32 V0LayerParameter::new_num() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.new_num)
- return new_num_;
-}
-void V0LayerParameter::set_new_num(::google::protobuf::int32 value) {
- set_has_new_num();
- new_num_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.new_num)
-}
-
-// optional int32 new_channels = 61 [default = 0];
-bool V0LayerParameter::has_new_channels() const {
- return (_has_bits_[1] & 0x00000001u) != 0;
-}
-void V0LayerParameter::set_has_new_channels() {
- _has_bits_[1] |= 0x00000001u;
-}
-void V0LayerParameter::clear_has_new_channels() {
- _has_bits_[1] &= ~0x00000001u;
-}
-void V0LayerParameter::clear_new_channels() {
- new_channels_ = 0;
- clear_has_new_channels();
-}
-::google::protobuf::int32 V0LayerParameter::new_channels() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.new_channels)
- return new_channels_;
-}
-void V0LayerParameter::set_new_channels(::google::protobuf::int32 value) {
- set_has_new_channels();
- new_channels_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.new_channels)
-}
-
-// optional int32 new_height = 62 [default = 0];
-bool V0LayerParameter::has_new_height() const {
- return (_has_bits_[1] & 0x00000002u) != 0;
-}
-void V0LayerParameter::set_has_new_height() {
- _has_bits_[1] |= 0x00000002u;
-}
-void V0LayerParameter::clear_has_new_height() {
- _has_bits_[1] &= ~0x00000002u;
-}
-void V0LayerParameter::clear_new_height() {
- new_height_ = 0;
- clear_has_new_height();
-}
-::google::protobuf::int32 V0LayerParameter::new_height() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.new_height)
- return new_height_;
-}
-void V0LayerParameter::set_new_height(::google::protobuf::int32 value) {
- set_has_new_height();
- new_height_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.new_height)
-}
-
-// optional int32 new_width = 63 [default = 0];
-bool V0LayerParameter::has_new_width() const {
- return (_has_bits_[1] & 0x00000004u) != 0;
-}
-void V0LayerParameter::set_has_new_width() {
- _has_bits_[1] |= 0x00000004u;
-}
-void V0LayerParameter::clear_has_new_width() {
- _has_bits_[1] &= ~0x00000004u;
-}
-void V0LayerParameter::clear_new_width() {
- new_width_ = 0;
- clear_has_new_width();
-}
-::google::protobuf::int32 V0LayerParameter::new_width() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.new_width)
- return new_width_;
-}
-void V0LayerParameter::set_new_width(::google::protobuf::int32 value) {
- set_has_new_width();
- new_width_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.new_width)
-}
-
-// optional bool shuffle_images = 64 [default = false];
-bool V0LayerParameter::has_shuffle_images() const {
- return (_has_bits_[1] & 0x00000008u) != 0;
-}
-void V0LayerParameter::set_has_shuffle_images() {
- _has_bits_[1] |= 0x00000008u;
-}
-void V0LayerParameter::clear_has_shuffle_images() {
- _has_bits_[1] &= ~0x00000008u;
-}
-void V0LayerParameter::clear_shuffle_images() {
- shuffle_images_ = false;
- clear_has_shuffle_images();
-}
-bool V0LayerParameter::shuffle_images() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.shuffle_images)
- return shuffle_images_;
-}
-void V0LayerParameter::set_shuffle_images(bool value) {
- set_has_shuffle_images();
- shuffle_images_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.shuffle_images)
-}
-
-// optional uint32 concat_dim = 65 [default = 1];
-bool V0LayerParameter::has_concat_dim() const {
- return (_has_bits_[1] & 0x00000010u) != 0;
-}
-void V0LayerParameter::set_has_concat_dim() {
- _has_bits_[1] |= 0x00000010u;
-}
-void V0LayerParameter::clear_has_concat_dim() {
- _has_bits_[1] &= ~0x00000010u;
-}
-void V0LayerParameter::clear_concat_dim() {
- concat_dim_ = 1u;
- clear_has_concat_dim();
-}
-::google::protobuf::uint32 V0LayerParameter::concat_dim() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.concat_dim)
- return concat_dim_;
-}
-void V0LayerParameter::set_concat_dim(::google::protobuf::uint32 value) {
- set_has_concat_dim();
- concat_dim_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.concat_dim)
-}
-
-// optional .caffe.HDF5OutputParameter hdf5_output_param = 1001;
-bool V0LayerParameter::has_hdf5_output_param() const {
- return (_has_bits_[1] & 0x00000020u) != 0;
-}
-void V0LayerParameter::set_has_hdf5_output_param() {
- _has_bits_[1] |= 0x00000020u;
-}
-void V0LayerParameter::clear_has_hdf5_output_param() {
- _has_bits_[1] &= ~0x00000020u;
-}
-void V0LayerParameter::clear_hdf5_output_param() {
- if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear();
- clear_has_hdf5_output_param();
-}
-const ::caffe::HDF5OutputParameter& V0LayerParameter::hdf5_output_param() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.hdf5_output_param)
- return hdf5_output_param_ != NULL ? *hdf5_output_param_
- : *::caffe::HDF5OutputParameter::internal_default_instance();
-}
-::caffe::HDF5OutputParameter* V0LayerParameter::mutable_hdf5_output_param() {
- set_has_hdf5_output_param();
- if (hdf5_output_param_ == NULL) {
- hdf5_output_param_ = new ::caffe::HDF5OutputParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.hdf5_output_param)
- return hdf5_output_param_;
-}
-::caffe::HDF5OutputParameter* V0LayerParameter::release_hdf5_output_param() {
- // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.hdf5_output_param)
- clear_has_hdf5_output_param();
- ::caffe::HDF5OutputParameter* temp = hdf5_output_param_;
- hdf5_output_param_ = NULL;
- return temp;
-}
-void V0LayerParameter::set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param) {
- delete hdf5_output_param_;
- hdf5_output_param_ = hdf5_output_param;
- if (hdf5_output_param) {
- set_has_hdf5_output_param();
- } else {
- clear_has_hdf5_output_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.hdf5_output_param)
-}
-
-inline const V0LayerParameter* V0LayerParameter::internal_default_instance() {
- return &V0LayerParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int PReLUParameter::kFillerFieldNumber;
-const int PReLUParameter::kChannelSharedFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-PReLUParameter::PReLUParameter()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.PReLUParameter)
-}
-
-void PReLUParameter::InitAsDefaultInstance() {
- filler_ = const_cast< ::caffe::FillerParameter*>(
- ::caffe::FillerParameter::internal_default_instance());
-}
-
-PReLUParameter::PReLUParameter(const PReLUParameter& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.PReLUParameter)
-}
-
-void PReLUParameter::SharedCtor() {
- _cached_size_ = 0;
- filler_ = NULL;
- channel_shared_ = false;
-}
-
-PReLUParameter::~PReLUParameter() {
- // @@protoc_insertion_point(destructor:caffe.PReLUParameter)
- SharedDtor();
-}
-
-void PReLUParameter::SharedDtor() {
- if (this != &PReLUParameter_default_instance_.get()) {
- delete filler_;
- }
-}
-
-void PReLUParameter::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* PReLUParameter::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return PReLUParameter_descriptor_;
-}
-
-const PReLUParameter& PReLUParameter::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<PReLUParameter> PReLUParameter_default_instance_;
-
-PReLUParameter* PReLUParameter::New(::google::protobuf::Arena* arena) const {
- PReLUParameter* n = new PReLUParameter;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void PReLUParameter::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.PReLUParameter)
- if (_has_bits_[0 / 32] & 3u) {
- if (has_filler()) {
- if (filler_ != NULL) filler_->::caffe::FillerParameter::Clear();
- }
- channel_shared_ = false;
- }
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool PReLUParameter::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.PReLUParameter)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional .caffe.FillerParameter filler = 1;
- case 1: {
- if (tag == 10) {
- DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
- input, mutable_filler()));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(16)) goto parse_channel_shared;
- break;
- }
-
- // optional bool channel_shared = 2 [default = false];
- case 2: {
- if (tag == 16) {
- parse_channel_shared:
- set_has_channel_shared();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &channel_shared_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.PReLUParameter)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.PReLUParameter)
- return false;
-#undef DO_
-}
-
-void PReLUParameter::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.PReLUParameter)
- // optional .caffe.FillerParameter filler = 1;
- if (has_filler()) {
- ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
- 1, *this->filler_, output);
- }
-
- // optional bool channel_shared = 2 [default = false];
- if (has_channel_shared()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->channel_shared(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.PReLUParameter)
-}
-
-::google::protobuf::uint8* PReLUParameter::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.PReLUParameter)
- // optional .caffe.FillerParameter filler = 1;
- if (has_filler()) {
- target = ::google::protobuf::internal::WireFormatLite::
- InternalWriteMessageNoVirtualToArray(
- 1, *this->filler_, false, target);
- }
-
- // optional bool channel_shared = 2 [default = false];
- if (has_channel_shared()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->channel_shared(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.PReLUParameter)
- return target;
-}
-
-size_t PReLUParameter::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.PReLUParameter)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 3u) {
- // optional .caffe.FillerParameter filler = 1;
- if (has_filler()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
- *this->filler_);
- }
-
- // optional bool channel_shared = 2 [default = false];
- if (has_channel_shared()) {
- total_size += 1 + 1;
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void PReLUParameter::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.PReLUParameter)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const PReLUParameter* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const PReLUParameter>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.PReLUParameter)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.PReLUParameter)
- UnsafeMergeFrom(*source);
- }
-}
-
-void PReLUParameter::MergeFrom(const PReLUParameter& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.PReLUParameter)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void PReLUParameter::UnsafeMergeFrom(const PReLUParameter& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_filler()) {
- mutable_filler()->::caffe::FillerParameter::MergeFrom(from.filler());
- }
- if (from.has_channel_shared()) {
- set_channel_shared(from.channel_shared());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void PReLUParameter::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.PReLUParameter)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void PReLUParameter::CopyFrom(const PReLUParameter& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.PReLUParameter)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool PReLUParameter::IsInitialized() const {
-
- return true;
-}
-
-void PReLUParameter::Swap(PReLUParameter* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void PReLUParameter::InternalSwap(PReLUParameter* other) {
- std::swap(filler_, other->filler_);
- std::swap(channel_shared_, other->channel_shared_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata PReLUParameter::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = PReLUParameter_descriptor_;
- metadata.reflection = PReLUParameter_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// PReLUParameter
-
-// optional .caffe.FillerParameter filler = 1;
-bool PReLUParameter::has_filler() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void PReLUParameter::set_has_filler() {
- _has_bits_[0] |= 0x00000001u;
-}
-void PReLUParameter::clear_has_filler() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void PReLUParameter::clear_filler() {
- if (filler_ != NULL) filler_->::caffe::FillerParameter::Clear();
- clear_has_filler();
-}
-const ::caffe::FillerParameter& PReLUParameter::filler() const {
- // @@protoc_insertion_point(field_get:caffe.PReLUParameter.filler)
- return filler_ != NULL ? *filler_
- : *::caffe::FillerParameter::internal_default_instance();
-}
-::caffe::FillerParameter* PReLUParameter::mutable_filler() {
- set_has_filler();
- if (filler_ == NULL) {
- filler_ = new ::caffe::FillerParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.PReLUParameter.filler)
- return filler_;
-}
-::caffe::FillerParameter* PReLUParameter::release_filler() {
- // @@protoc_insertion_point(field_release:caffe.PReLUParameter.filler)
- clear_has_filler();
- ::caffe::FillerParameter* temp = filler_;
- filler_ = NULL;
- return temp;
-}
-void PReLUParameter::set_allocated_filler(::caffe::FillerParameter* filler) {
- delete filler_;
- filler_ = filler;
- if (filler) {
- set_has_filler();
- } else {
- clear_has_filler();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.PReLUParameter.filler)
-}
-
-// optional bool channel_shared = 2 [default = false];
-bool PReLUParameter::has_channel_shared() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void PReLUParameter::set_has_channel_shared() {
- _has_bits_[0] |= 0x00000002u;
-}
-void PReLUParameter::clear_has_channel_shared() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void PReLUParameter::clear_channel_shared() {
- channel_shared_ = false;
- clear_has_channel_shared();
-}
-bool PReLUParameter::channel_shared() const {
- // @@protoc_insertion_point(field_get:caffe.PReLUParameter.channel_shared)
- return channel_shared_;
-}
-void PReLUParameter::set_channel_shared(bool value) {
- set_has_channel_shared();
- channel_shared_ = value;
- // @@protoc_insertion_point(field_set:caffe.PReLUParameter.channel_shared)
-}
-
-inline const PReLUParameter* PReLUParameter::internal_default_instance() {
- return &PReLUParameter_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// ===================================================================
-
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int NormalizedBBox::kXminFieldNumber;
-const int NormalizedBBox::kYminFieldNumber;
-const int NormalizedBBox::kXmaxFieldNumber;
-const int NormalizedBBox::kYmaxFieldNumber;
-const int NormalizedBBox::kLabelFieldNumber;
-const int NormalizedBBox::kDifficultFieldNumber;
-const int NormalizedBBox::kScoreFieldNumber;
-const int NormalizedBBox::kSizeFieldNumber;
-#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-NormalizedBBox::NormalizedBBox()
- : ::google::protobuf::Message(), _internal_metadata_(NULL) {
- if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
- SharedCtor();
- // @@protoc_insertion_point(constructor:caffe.NormalizedBBox)
-}
-
-void NormalizedBBox::InitAsDefaultInstance() {
-}
-
-NormalizedBBox::NormalizedBBox(const NormalizedBBox& from)
- : ::google::protobuf::Message(),
- _internal_metadata_(NULL) {
- SharedCtor();
- UnsafeMergeFrom(from);
- // @@protoc_insertion_point(copy_constructor:caffe.NormalizedBBox)
-}
-
-void NormalizedBBox::SharedCtor() {
- _cached_size_ = 0;
- ::memset(&xmin_, 0, reinterpret_cast<char*>(&size_) -
- reinterpret_cast<char*>(&xmin_) + sizeof(size_));
-}
-
-NormalizedBBox::~NormalizedBBox() {
- // @@protoc_insertion_point(destructor:caffe.NormalizedBBox)
- SharedDtor();
-}
-
-void NormalizedBBox::SharedDtor() {
-}
-
-void NormalizedBBox::SetCachedSize(int size) const {
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* NormalizedBBox::descriptor() {
- protobuf_AssignDescriptorsOnce();
- return NormalizedBBox_descriptor_;
-}
-
-const NormalizedBBox& NormalizedBBox::default_instance() {
- protobuf_InitDefaults_caffe_2eproto();
- return *internal_default_instance();
-}
-
-::google::protobuf::internal::ExplicitlyConstructed<NormalizedBBox> NormalizedBBox_default_instance_;
-
-NormalizedBBox* NormalizedBBox::New(::google::protobuf::Arena* arena) const {
- NormalizedBBox* n = new NormalizedBBox;
- if (arena != NULL) {
- arena->Own(n);
- }
- return n;
-}
-
-void NormalizedBBox::Clear() {
-// @@protoc_insertion_point(message_clear_start:caffe.NormalizedBBox)
-#if defined(__clang__)
-#define ZR_HELPER_(f) \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
- __builtin_offsetof(NormalizedBBox, f) \
- _Pragma("clang diagnostic pop")
-#else
-#define ZR_HELPER_(f) reinterpret_cast<char*>(\
- &reinterpret_cast<NormalizedBBox*>(16)->f)
-#endif
-
-#define ZR_(first, last) do {\
- ::memset(&(first), 0,\
- ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
-} while (0)
-
- ZR_(xmin_, size_);
-
-#undef ZR_HELPER_
-#undef ZR_
-
- _has_bits_.Clear();
- if (_internal_metadata_.have_unknown_fields()) {
- mutable_unknown_fields()->Clear();
- }
-}
-
-bool NormalizedBBox::MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
- ::google::protobuf::uint32 tag;
- // @@protoc_insertion_point(parse_start:caffe.NormalizedBBox)
- for (;;) {
- ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
- tag = p.first;
- if (!p.second) goto handle_unusual;
- switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
- // optional float xmin = 1;
- case 1: {
- if (tag == 13) {
- set_has_xmin();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &xmin_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(21)) goto parse_ymin;
- break;
- }
-
- // optional float ymin = 2;
- case 2: {
- if (tag == 21) {
- parse_ymin:
- set_has_ymin();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &ymin_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(29)) goto parse_xmax;
- break;
- }
-
- // optional float xmax = 3;
- case 3: {
- if (tag == 29) {
- parse_xmax:
- set_has_xmax();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &xmax_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(37)) goto parse_ymax;
- break;
- }
-
- // optional float ymax = 4;
- case 4: {
- if (tag == 37) {
- parse_ymax:
- set_has_ymax();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &ymax_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(40)) goto parse_label;
- break;
- }
-
- // optional int32 label = 5;
- case 5: {
- if (tag == 40) {
- parse_label:
- set_has_label();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
- input, &label_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(48)) goto parse_difficult;
- break;
- }
-
- // optional bool difficult = 6;
- case 6: {
- if (tag == 48) {
- parse_difficult:
- set_has_difficult();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
- input, &difficult_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(61)) goto parse_score;
- break;
- }
-
- // optional float score = 7;
- case 7: {
- if (tag == 61) {
- parse_score:
- set_has_score();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &score_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectTag(69)) goto parse_size;
- break;
- }
-
- // optional float size = 8;
- case 8: {
- if (tag == 69) {
- parse_size:
- set_has_size();
- DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
- float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
- input, &size_)));
- } else {
- goto handle_unusual;
- }
- if (input->ExpectAtEnd()) goto success;
- break;
- }
-
- default: {
- handle_unusual:
- if (tag == 0 ||
- ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
- ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
- goto success;
- }
- DO_(::google::protobuf::internal::WireFormat::SkipField(
- input, tag, mutable_unknown_fields()));
- break;
- }
- }
- }
-success:
- // @@protoc_insertion_point(parse_success:caffe.NormalizedBBox)
- return true;
-failure:
- // @@protoc_insertion_point(parse_failure:caffe.NormalizedBBox)
- return false;
-#undef DO_
-}
-
-void NormalizedBBox::SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const {
- // @@protoc_insertion_point(serialize_start:caffe.NormalizedBBox)
- // optional float xmin = 1;
- if (has_xmin()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->xmin(), output);
- }
-
- // optional float ymin = 2;
- if (has_ymin()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->ymin(), output);
- }
-
- // optional float xmax = 3;
- if (has_xmax()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->xmax(), output);
- }
-
- // optional float ymax = 4;
- if (has_ymax()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(4, this->ymax(), output);
- }
-
- // optional int32 label = 5;
- if (has_label()) {
- ::google::protobuf::internal::WireFormatLite::WriteInt32(5, this->label(), output);
- }
-
- // optional bool difficult = 6;
- if (has_difficult()) {
- ::google::protobuf::internal::WireFormatLite::WriteBool(6, this->difficult(), output);
- }
-
- // optional float score = 7;
- if (has_score()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(7, this->score(), output);
- }
-
- // optional float size = 8;
- if (has_size()) {
- ::google::protobuf::internal::WireFormatLite::WriteFloat(8, this->size(), output);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
- unknown_fields(), output);
- }
- // @@protoc_insertion_point(serialize_end:caffe.NormalizedBBox)
-}
-
-::google::protobuf::uint8* NormalizedBBox::InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* target) const {
- (void)deterministic; // Unused
- // @@protoc_insertion_point(serialize_to_array_start:caffe.NormalizedBBox)
- // optional float xmin = 1;
- if (has_xmin()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->xmin(), target);
- }
-
- // optional float ymin = 2;
- if (has_ymin()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->ymin(), target);
- }
-
- // optional float xmax = 3;
- if (has_xmax()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->xmax(), target);
- }
-
- // optional float ymax = 4;
- if (has_ymax()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(4, this->ymax(), target);
- }
-
- // optional int32 label = 5;
- if (has_label()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(5, this->label(), target);
- }
-
- // optional bool difficult = 6;
- if (has_difficult()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(6, this->difficult(), target);
- }
-
- // optional float score = 7;
- if (has_score()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(7, this->score(), target);
- }
-
- // optional float size = 8;
- if (has_size()) {
- target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(8, this->size(), target);
- }
-
- if (_internal_metadata_.have_unknown_fields()) {
- target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
- unknown_fields(), target);
- }
- // @@protoc_insertion_point(serialize_to_array_end:caffe.NormalizedBBox)
- return target;
-}
-
-size_t NormalizedBBox::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:caffe.NormalizedBBox)
- size_t total_size = 0;
-
- if (_has_bits_[0 / 32] & 255u) {
- // optional float xmin = 1;
- if (has_xmin()) {
- total_size += 1 + 4;
- }
-
- // optional float ymin = 2;
- if (has_ymin()) {
- total_size += 1 + 4;
- }
-
- // optional float xmax = 3;
- if (has_xmax()) {
- total_size += 1 + 4;
- }
-
- // optional float ymax = 4;
- if (has_ymax()) {
- total_size += 1 + 4;
- }
-
- // optional int32 label = 5;
- if (has_label()) {
- total_size += 1 +
- ::google::protobuf::internal::WireFormatLite::Int32Size(
- this->label());
- }
-
- // optional bool difficult = 6;
- if (has_difficult()) {
- total_size += 1 + 1;
- }
-
- // optional float score = 7;
- if (has_score()) {
- total_size += 1 + 4;
- }
-
- // optional float size = 8;
- if (has_size()) {
- total_size += 1 + 4;
- }
-
- }
- if (_internal_metadata_.have_unknown_fields()) {
- total_size +=
- ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
- unknown_fields());
- }
- int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
- GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
- _cached_size_ = cached_size;
- GOOGLE_SAFE_CONCURRENT_WRITES_END();
- return total_size;
-}
-
-void NormalizedBBox::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:caffe.NormalizedBBox)
- if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
- const NormalizedBBox* source =
- ::google::protobuf::internal::DynamicCastToGenerated<const NormalizedBBox>(
- &from);
- if (source == NULL) {
- // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.NormalizedBBox)
- ::google::protobuf::internal::ReflectionOps::Merge(from, this);
- } else {
- // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.NormalizedBBox)
- UnsafeMergeFrom(*source);
- }
-}
-
-void NormalizedBBox::MergeFrom(const NormalizedBBox& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:caffe.NormalizedBBox)
- if (GOOGLE_PREDICT_TRUE(&from != this)) {
- UnsafeMergeFrom(from);
- } else {
- MergeFromFail(__LINE__);
- }
-}
-
-void NormalizedBBox::UnsafeMergeFrom(const NormalizedBBox& from) {
- GOOGLE_DCHECK(&from != this);
- if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
- if (from.has_xmin()) {
- set_xmin(from.xmin());
- }
- if (from.has_ymin()) {
- set_ymin(from.ymin());
- }
- if (from.has_xmax()) {
- set_xmax(from.xmax());
- }
- if (from.has_ymax()) {
- set_ymax(from.ymax());
- }
- if (from.has_label()) {
- set_label(from.label());
- }
- if (from.has_difficult()) {
- set_difficult(from.difficult());
- }
- if (from.has_score()) {
- set_score(from.score());
- }
- if (from.has_size()) {
- set_size(from.size());
- }
- }
- if (from._internal_metadata_.have_unknown_fields()) {
- ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
- from.unknown_fields(), &_internal_metadata_);
- }
-}
-
-void NormalizedBBox::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:caffe.NormalizedBBox)
- if (&from == this) return;
- Clear();
- MergeFrom(from);
-}
-
-void NormalizedBBox::CopyFrom(const NormalizedBBox& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:caffe.NormalizedBBox)
- if (&from == this) return;
- Clear();
- UnsafeMergeFrom(from);
-}
-
-bool NormalizedBBox::IsInitialized() const {
-
- return true;
-}
-
-void NormalizedBBox::Swap(NormalizedBBox* other) {
- if (other == this) return;
- InternalSwap(other);
-}
-void NormalizedBBox::InternalSwap(NormalizedBBox* other) {
- std::swap(xmin_, other->xmin_);
- std::swap(ymin_, other->ymin_);
- std::swap(xmax_, other->xmax_);
- std::swap(ymax_, other->ymax_);
- std::swap(label_, other->label_);
- std::swap(difficult_, other->difficult_);
- std::swap(score_, other->score_);
- std::swap(size_, other->size_);
- std::swap(_has_bits_[0], other->_has_bits_[0]);
- _internal_metadata_.Swap(&other->_internal_metadata_);
- std::swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata NormalizedBBox::GetMetadata() const {
- protobuf_AssignDescriptorsOnce();
- ::google::protobuf::Metadata metadata;
- metadata.descriptor = NormalizedBBox_descriptor_;
- metadata.reflection = NormalizedBBox_reflection_;
- return metadata;
-}
-
-#if PROTOBUF_INLINE_NOT_IN_HEADERS
-// NormalizedBBox
-
-// optional float xmin = 1;
-bool NormalizedBBox::has_xmin() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-void NormalizedBBox::set_has_xmin() {
- _has_bits_[0] |= 0x00000001u;
-}
-void NormalizedBBox::clear_has_xmin() {
- _has_bits_[0] &= ~0x00000001u;
-}
-void NormalizedBBox::clear_xmin() {
- xmin_ = 0;
- clear_has_xmin();
-}
-float NormalizedBBox::xmin() const {
- // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.xmin)
- return xmin_;
-}
-void NormalizedBBox::set_xmin(float value) {
- set_has_xmin();
- xmin_ = value;
- // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.xmin)
-}
-
-// optional float ymin = 2;
-bool NormalizedBBox::has_ymin() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-void NormalizedBBox::set_has_ymin() {
- _has_bits_[0] |= 0x00000002u;
-}
-void NormalizedBBox::clear_has_ymin() {
- _has_bits_[0] &= ~0x00000002u;
-}
-void NormalizedBBox::clear_ymin() {
- ymin_ = 0;
- clear_has_ymin();
-}
-float NormalizedBBox::ymin() const {
- // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.ymin)
- return ymin_;
-}
-void NormalizedBBox::set_ymin(float value) {
- set_has_ymin();
- ymin_ = value;
- // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.ymin)
-}
-
-// optional float xmax = 3;
-bool NormalizedBBox::has_xmax() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-void NormalizedBBox::set_has_xmax() {
- _has_bits_[0] |= 0x00000004u;
-}
-void NormalizedBBox::clear_has_xmax() {
- _has_bits_[0] &= ~0x00000004u;
-}
-void NormalizedBBox::clear_xmax() {
- xmax_ = 0;
- clear_has_xmax();
-}
-float NormalizedBBox::xmax() const {
- // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.xmax)
- return xmax_;
-}
-void NormalizedBBox::set_xmax(float value) {
- set_has_xmax();
- xmax_ = value;
- // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.xmax)
-}
-
-// optional float ymax = 4;
-bool NormalizedBBox::has_ymax() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-void NormalizedBBox::set_has_ymax() {
- _has_bits_[0] |= 0x00000008u;
-}
-void NormalizedBBox::clear_has_ymax() {
- _has_bits_[0] &= ~0x00000008u;
-}
-void NormalizedBBox::clear_ymax() {
- ymax_ = 0;
- clear_has_ymax();
-}
-float NormalizedBBox::ymax() const {
- // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.ymax)
- return ymax_;
-}
-void NormalizedBBox::set_ymax(float value) {
- set_has_ymax();
- ymax_ = value;
- // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.ymax)
-}
-
-// optional int32 label = 5;
-bool NormalizedBBox::has_label() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-void NormalizedBBox::set_has_label() {
- _has_bits_[0] |= 0x00000010u;
-}
-void NormalizedBBox::clear_has_label() {
- _has_bits_[0] &= ~0x00000010u;
-}
-void NormalizedBBox::clear_label() {
- label_ = 0;
- clear_has_label();
-}
-::google::protobuf::int32 NormalizedBBox::label() const {
- // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.label)
- return label_;
-}
-void NormalizedBBox::set_label(::google::protobuf::int32 value) {
- set_has_label();
- label_ = value;
- // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.label)
-}
-
-// optional bool difficult = 6;
-bool NormalizedBBox::has_difficult() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-void NormalizedBBox::set_has_difficult() {
- _has_bits_[0] |= 0x00000020u;
-}
-void NormalizedBBox::clear_has_difficult() {
- _has_bits_[0] &= ~0x00000020u;
-}
-void NormalizedBBox::clear_difficult() {
- difficult_ = false;
- clear_has_difficult();
-}
-bool NormalizedBBox::difficult() const {
- // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.difficult)
- return difficult_;
-}
-void NormalizedBBox::set_difficult(bool value) {
- set_has_difficult();
- difficult_ = value;
- // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.difficult)
-}
-
-// optional float score = 7;
-bool NormalizedBBox::has_score() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-void NormalizedBBox::set_has_score() {
- _has_bits_[0] |= 0x00000040u;
-}
-void NormalizedBBox::clear_has_score() {
- _has_bits_[0] &= ~0x00000040u;
-}
-void NormalizedBBox::clear_score() {
- score_ = 0;
- clear_has_score();
-}
-float NormalizedBBox::score() const {
- // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.score)
- return score_;
-}
-void NormalizedBBox::set_score(float value) {
- set_has_score();
- score_ = value;
- // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.score)
-}
-
-// optional float size = 8;
-bool NormalizedBBox::has_size() const {
- return (_has_bits_[0] & 0x00000080u) != 0;
-}
-void NormalizedBBox::set_has_size() {
- _has_bits_[0] |= 0x00000080u;
-}
-void NormalizedBBox::clear_has_size() {
- _has_bits_[0] &= ~0x00000080u;
-}
-void NormalizedBBox::clear_size() {
- size_ = 0;
- clear_has_size();
-}
-float NormalizedBBox::size() const {
- // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.size)
- return size_;
-}
-void NormalizedBBox::set_size(float value) {
- set_has_size();
- size_ = value;
- // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.size)
-}
-
-inline const NormalizedBBox* NormalizedBBox::internal_default_instance() {
- return &NormalizedBBox_default_instance_.get();
-}
-#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
-
-// @@protoc_insertion_point(namespace_scope)
-
-} // namespace caffe
-
-// @@protoc_insertion_point(global_scope)
diff --git a/contrib/modules/dnn/misc/caffe/caffe.pb.h b/contrib/modules/dnn/misc/caffe/caffe.pb.h
deleted file mode 100644
index 84ee770..0000000
--- a/contrib/modules/dnn/misc/caffe/caffe.pb.h
+++ /dev/null
@@ -1,24439 +0,0 @@
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: caffe.proto
-
-#ifndef PROTOBUF_caffe_2eproto__INCLUDED
-#define PROTOBUF_caffe_2eproto__INCLUDED
-
-#include <string>
-
-#include <google/protobuf/stubs/common.h>
-
-#if GOOGLE_PROTOBUF_VERSION < 3001000
-#error This file was generated by a newer version of protoc which is
-#error incompatible with your Protocol Buffer headers. Please update
-#error your headers.
-#endif
-#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
-#error This file was generated by an older version of protoc which is
-#error incompatible with your Protocol Buffer headers. Please
-#error regenerate this file with a newer version of protoc.
-#endif
-
-#include <google/protobuf/arena.h>
-#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_util.h>
-#include <google/protobuf/metadata.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/extension_set.h>
-#include <google/protobuf/generated_enum_reflection.h>
-#include <google/protobuf/unknown_field_set.h>
-// @@protoc_insertion_point(includes)
-
-namespace caffe {
-
-// Internal implementation detail -- do not call these.
-void protobuf_AddDesc_caffe_2eproto();
-void protobuf_InitDefaults_caffe_2eproto();
-void protobuf_AssignDesc_caffe_2eproto();
-void protobuf_ShutdownFile_caffe_2eproto();
-
-class AccuracyParameter;
-class ArgMaxParameter;
-class BlobProto;
-class BlobProtoVector;
-class BlobShape;
-class ConcatParameter;
-class ContrastiveLossParameter;
-class ConvolutionParameter;
-class CropParameter;
-class DataParameter;
-class Datum;
-class DetectionOutputParameter;
-class DropoutParameter;
-class DummyDataParameter;
-class EltwiseParameter;
-class ExpParameter;
-class FillerParameter;
-class FlattenParameter;
-class HDF5DataParameter;
-class HDF5OutputParameter;
-class HingeLossParameter;
-class ImageDataParameter;
-class InfogainLossParameter;
-class InnerProductParameter;
-class LRNParameter;
-class LayerParameter;
-class LogParameter;
-class LossParameter;
-class MVNParameter;
-class MemoryDataParameter;
-class NetParameter;
-class NetState;
-class NetStateRule;
-class NormalizeBBoxParameter;
-class NormalizedBBox;
-class PReLUParameter;
-class ParamSpec;
-class PermuteParameter;
-class PoolingParameter;
-class PowerParameter;
-class PriorBoxParameter;
-class PythonParameter;
-class ReLUParameter;
-class ReductionParameter;
-class ReshapeParameter;
-class SPPParameter;
-class SigmoidParameter;
-class SliceParameter;
-class SoftmaxParameter;
-class SolverParameter;
-class SolverState;
-class TanHParameter;
-class ThresholdParameter;
-class TransformationParameter;
-class V0LayerParameter;
-class V1LayerParameter;
-class WindowDataParameter;
-
-enum PriorBoxParameter_CodeType {
- PriorBoxParameter_CodeType_CORNER = 1,
- PriorBoxParameter_CodeType_CENTER_SIZE = 2
-};
-bool PriorBoxParameter_CodeType_IsValid(int value);
-const PriorBoxParameter_CodeType PriorBoxParameter_CodeType_CodeType_MIN = PriorBoxParameter_CodeType_CORNER;
-const PriorBoxParameter_CodeType PriorBoxParameter_CodeType_CodeType_MAX = PriorBoxParameter_CodeType_CENTER_SIZE;
-const int PriorBoxParameter_CodeType_CodeType_ARRAYSIZE = PriorBoxParameter_CodeType_CodeType_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* PriorBoxParameter_CodeType_descriptor();
-inline const ::std::string& PriorBoxParameter_CodeType_Name(PriorBoxParameter_CodeType value) {
- return ::google::protobuf::internal::NameOfEnum(
- PriorBoxParameter_CodeType_descriptor(), value);
-}
-inline bool PriorBoxParameter_CodeType_Parse(
- const ::std::string& name, PriorBoxParameter_CodeType* value) {
- return ::google::protobuf::internal::ParseNamedEnum<PriorBoxParameter_CodeType>(
- PriorBoxParameter_CodeType_descriptor(), name, value);
-}
-enum FillerParameter_VarianceNorm {
- FillerParameter_VarianceNorm_FAN_IN = 0,
- FillerParameter_VarianceNorm_FAN_OUT = 1,
- FillerParameter_VarianceNorm_AVERAGE = 2
-};
-bool FillerParameter_VarianceNorm_IsValid(int value);
-const FillerParameter_VarianceNorm FillerParameter_VarianceNorm_VarianceNorm_MIN = FillerParameter_VarianceNorm_FAN_IN;
-const FillerParameter_VarianceNorm FillerParameter_VarianceNorm_VarianceNorm_MAX = FillerParameter_VarianceNorm_AVERAGE;
-const int FillerParameter_VarianceNorm_VarianceNorm_ARRAYSIZE = FillerParameter_VarianceNorm_VarianceNorm_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* FillerParameter_VarianceNorm_descriptor();
-inline const ::std::string& FillerParameter_VarianceNorm_Name(FillerParameter_VarianceNorm value) {
- return ::google::protobuf::internal::NameOfEnum(
- FillerParameter_VarianceNorm_descriptor(), value);
-}
-inline bool FillerParameter_VarianceNorm_Parse(
- const ::std::string& name, FillerParameter_VarianceNorm* value) {
- return ::google::protobuf::internal::ParseNamedEnum<FillerParameter_VarianceNorm>(
- FillerParameter_VarianceNorm_descriptor(), name, value);
-}
-enum SolverParameter_SolverMode {
- SolverParameter_SolverMode_CPU = 0,
- SolverParameter_SolverMode_GPU = 1
-};
-bool SolverParameter_SolverMode_IsValid(int value);
-const SolverParameter_SolverMode SolverParameter_SolverMode_SolverMode_MIN = SolverParameter_SolverMode_CPU;
-const SolverParameter_SolverMode SolverParameter_SolverMode_SolverMode_MAX = SolverParameter_SolverMode_GPU;
-const int SolverParameter_SolverMode_SolverMode_ARRAYSIZE = SolverParameter_SolverMode_SolverMode_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* SolverParameter_SolverMode_descriptor();
-inline const ::std::string& SolverParameter_SolverMode_Name(SolverParameter_SolverMode value) {
- return ::google::protobuf::internal::NameOfEnum(
- SolverParameter_SolverMode_descriptor(), value);
-}
-inline bool SolverParameter_SolverMode_Parse(
- const ::std::string& name, SolverParameter_SolverMode* value) {
- return ::google::protobuf::internal::ParseNamedEnum<SolverParameter_SolverMode>(
- SolverParameter_SolverMode_descriptor(), name, value);
-}
-enum SolverParameter_SolverType {
- SolverParameter_SolverType_SGD = 0,
- SolverParameter_SolverType_NESTEROV = 1,
- SolverParameter_SolverType_ADAGRAD = 2
-};
-bool SolverParameter_SolverType_IsValid(int value);
-const SolverParameter_SolverType SolverParameter_SolverType_SolverType_MIN = SolverParameter_SolverType_SGD;
-const SolverParameter_SolverType SolverParameter_SolverType_SolverType_MAX = SolverParameter_SolverType_ADAGRAD;
-const int SolverParameter_SolverType_SolverType_ARRAYSIZE = SolverParameter_SolverType_SolverType_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* SolverParameter_SolverType_descriptor();
-inline const ::std::string& SolverParameter_SolverType_Name(SolverParameter_SolverType value) {
- return ::google::protobuf::internal::NameOfEnum(
- SolverParameter_SolverType_descriptor(), value);
-}
-inline bool SolverParameter_SolverType_Parse(
- const ::std::string& name, SolverParameter_SolverType* value) {
- return ::google::protobuf::internal::ParseNamedEnum<SolverParameter_SolverType>(
- SolverParameter_SolverType_descriptor(), name, value);
-}
-enum ParamSpec_DimCheckMode {
- ParamSpec_DimCheckMode_STRICT = 0,
- ParamSpec_DimCheckMode_PERMISSIVE = 1
-};
-bool ParamSpec_DimCheckMode_IsValid(int value);
-const ParamSpec_DimCheckMode ParamSpec_DimCheckMode_DimCheckMode_MIN = ParamSpec_DimCheckMode_STRICT;
-const ParamSpec_DimCheckMode ParamSpec_DimCheckMode_DimCheckMode_MAX = ParamSpec_DimCheckMode_PERMISSIVE;
-const int ParamSpec_DimCheckMode_DimCheckMode_ARRAYSIZE = ParamSpec_DimCheckMode_DimCheckMode_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* ParamSpec_DimCheckMode_descriptor();
-inline const ::std::string& ParamSpec_DimCheckMode_Name(ParamSpec_DimCheckMode value) {
- return ::google::protobuf::internal::NameOfEnum(
- ParamSpec_DimCheckMode_descriptor(), value);
-}
-inline bool ParamSpec_DimCheckMode_Parse(
- const ::std::string& name, ParamSpec_DimCheckMode* value) {
- return ::google::protobuf::internal::ParseNamedEnum<ParamSpec_DimCheckMode>(
- ParamSpec_DimCheckMode_descriptor(), name, value);
-}
-enum ConvolutionParameter_Engine {
- ConvolutionParameter_Engine_DEFAULT = 0,
- ConvolutionParameter_Engine_CAFFE = 1,
- ConvolutionParameter_Engine_CUDNN = 2
-};
-bool ConvolutionParameter_Engine_IsValid(int value);
-const ConvolutionParameter_Engine ConvolutionParameter_Engine_Engine_MIN = ConvolutionParameter_Engine_DEFAULT;
-const ConvolutionParameter_Engine ConvolutionParameter_Engine_Engine_MAX = ConvolutionParameter_Engine_CUDNN;
-const int ConvolutionParameter_Engine_Engine_ARRAYSIZE = ConvolutionParameter_Engine_Engine_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* ConvolutionParameter_Engine_descriptor();
-inline const ::std::string& ConvolutionParameter_Engine_Name(ConvolutionParameter_Engine value) {
- return ::google::protobuf::internal::NameOfEnum(
- ConvolutionParameter_Engine_descriptor(), value);
-}
-inline bool ConvolutionParameter_Engine_Parse(
- const ::std::string& name, ConvolutionParameter_Engine* value) {
- return ::google::protobuf::internal::ParseNamedEnum<ConvolutionParameter_Engine>(
- ConvolutionParameter_Engine_descriptor(), name, value);
-}
-enum DataParameter_DB {
- DataParameter_DB_LEVELDB = 0,
- DataParameter_DB_LMDB = 1
-};
-bool DataParameter_DB_IsValid(int value);
-const DataParameter_DB DataParameter_DB_DB_MIN = DataParameter_DB_LEVELDB;
-const DataParameter_DB DataParameter_DB_DB_MAX = DataParameter_DB_LMDB;
-const int DataParameter_DB_DB_ARRAYSIZE = DataParameter_DB_DB_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* DataParameter_DB_descriptor();
-inline const ::std::string& DataParameter_DB_Name(DataParameter_DB value) {
- return ::google::protobuf::internal::NameOfEnum(
- DataParameter_DB_descriptor(), value);
-}
-inline bool DataParameter_DB_Parse(
- const ::std::string& name, DataParameter_DB* value) {
- return ::google::protobuf::internal::ParseNamedEnum<DataParameter_DB>(
- DataParameter_DB_descriptor(), name, value);
-}
-enum EltwiseParameter_EltwiseOp {
- EltwiseParameter_EltwiseOp_PROD = 0,
- EltwiseParameter_EltwiseOp_SUM = 1,
- EltwiseParameter_EltwiseOp_MAX = 2
-};
-bool EltwiseParameter_EltwiseOp_IsValid(int value);
-const EltwiseParameter_EltwiseOp EltwiseParameter_EltwiseOp_EltwiseOp_MIN = EltwiseParameter_EltwiseOp_PROD;
-const EltwiseParameter_EltwiseOp EltwiseParameter_EltwiseOp_EltwiseOp_MAX = EltwiseParameter_EltwiseOp_MAX;
-const int EltwiseParameter_EltwiseOp_EltwiseOp_ARRAYSIZE = EltwiseParameter_EltwiseOp_EltwiseOp_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* EltwiseParameter_EltwiseOp_descriptor();
-inline const ::std::string& EltwiseParameter_EltwiseOp_Name(EltwiseParameter_EltwiseOp value) {
- return ::google::protobuf::internal::NameOfEnum(
- EltwiseParameter_EltwiseOp_descriptor(), value);
-}
-inline bool EltwiseParameter_EltwiseOp_Parse(
- const ::std::string& name, EltwiseParameter_EltwiseOp* value) {
- return ::google::protobuf::internal::ParseNamedEnum<EltwiseParameter_EltwiseOp>(
- EltwiseParameter_EltwiseOp_descriptor(), name, value);
-}
-enum HingeLossParameter_Norm {
- HingeLossParameter_Norm_L1 = 1,
- HingeLossParameter_Norm_L2 = 2
-};
-bool HingeLossParameter_Norm_IsValid(int value);
-const HingeLossParameter_Norm HingeLossParameter_Norm_Norm_MIN = HingeLossParameter_Norm_L1;
-const HingeLossParameter_Norm HingeLossParameter_Norm_Norm_MAX = HingeLossParameter_Norm_L2;
-const int HingeLossParameter_Norm_Norm_ARRAYSIZE = HingeLossParameter_Norm_Norm_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* HingeLossParameter_Norm_descriptor();
-inline const ::std::string& HingeLossParameter_Norm_Name(HingeLossParameter_Norm value) {
- return ::google::protobuf::internal::NameOfEnum(
- HingeLossParameter_Norm_descriptor(), value);
-}
-inline bool HingeLossParameter_Norm_Parse(
- const ::std::string& name, HingeLossParameter_Norm* value) {
- return ::google::protobuf::internal::ParseNamedEnum<HingeLossParameter_Norm>(
- HingeLossParameter_Norm_descriptor(), name, value);
-}
-enum LRNParameter_NormRegion {
- LRNParameter_NormRegion_ACROSS_CHANNELS = 0,
- LRNParameter_NormRegion_WITHIN_CHANNEL = 1
-};
-bool LRNParameter_NormRegion_IsValid(int value);
-const LRNParameter_NormRegion LRNParameter_NormRegion_NormRegion_MIN = LRNParameter_NormRegion_ACROSS_CHANNELS;
-const LRNParameter_NormRegion LRNParameter_NormRegion_NormRegion_MAX = LRNParameter_NormRegion_WITHIN_CHANNEL;
-const int LRNParameter_NormRegion_NormRegion_ARRAYSIZE = LRNParameter_NormRegion_NormRegion_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* LRNParameter_NormRegion_descriptor();
-inline const ::std::string& LRNParameter_NormRegion_Name(LRNParameter_NormRegion value) {
- return ::google::protobuf::internal::NameOfEnum(
- LRNParameter_NormRegion_descriptor(), value);
-}
-inline bool LRNParameter_NormRegion_Parse(
- const ::std::string& name, LRNParameter_NormRegion* value) {
- return ::google::protobuf::internal::ParseNamedEnum<LRNParameter_NormRegion>(
- LRNParameter_NormRegion_descriptor(), name, value);
-}
-enum PoolingParameter_PoolMethod {
- PoolingParameter_PoolMethod_MAX = 0,
- PoolingParameter_PoolMethod_AVE = 1,
- PoolingParameter_PoolMethod_STOCHASTIC = 2
-};
-bool PoolingParameter_PoolMethod_IsValid(int value);
-const PoolingParameter_PoolMethod PoolingParameter_PoolMethod_PoolMethod_MIN = PoolingParameter_PoolMethod_MAX;
-const PoolingParameter_PoolMethod PoolingParameter_PoolMethod_PoolMethod_MAX = PoolingParameter_PoolMethod_STOCHASTIC;
-const int PoolingParameter_PoolMethod_PoolMethod_ARRAYSIZE = PoolingParameter_PoolMethod_PoolMethod_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* PoolingParameter_PoolMethod_descriptor();
-inline const ::std::string& PoolingParameter_PoolMethod_Name(PoolingParameter_PoolMethod value) {
- return ::google::protobuf::internal::NameOfEnum(
- PoolingParameter_PoolMethod_descriptor(), value);
-}
-inline bool PoolingParameter_PoolMethod_Parse(
- const ::std::string& name, PoolingParameter_PoolMethod* value) {
- return ::google::protobuf::internal::ParseNamedEnum<PoolingParameter_PoolMethod>(
- PoolingParameter_PoolMethod_descriptor(), name, value);
-}
-enum PoolingParameter_Engine {
- PoolingParameter_Engine_DEFAULT = 0,
- PoolingParameter_Engine_CAFFE = 1,
- PoolingParameter_Engine_CUDNN = 2
-};
-bool PoolingParameter_Engine_IsValid(int value);
-const PoolingParameter_Engine PoolingParameter_Engine_Engine_MIN = PoolingParameter_Engine_DEFAULT;
-const PoolingParameter_Engine PoolingParameter_Engine_Engine_MAX = PoolingParameter_Engine_CUDNN;
-const int PoolingParameter_Engine_Engine_ARRAYSIZE = PoolingParameter_Engine_Engine_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* PoolingParameter_Engine_descriptor();
-inline const ::std::string& PoolingParameter_Engine_Name(PoolingParameter_Engine value) {
- return ::google::protobuf::internal::NameOfEnum(
- PoolingParameter_Engine_descriptor(), value);
-}
-inline bool PoolingParameter_Engine_Parse(
- const ::std::string& name, PoolingParameter_Engine* value) {
- return ::google::protobuf::internal::ParseNamedEnum<PoolingParameter_Engine>(
- PoolingParameter_Engine_descriptor(), name, value);
-}
-enum ReductionParameter_ReductionOp {
- ReductionParameter_ReductionOp_SUM = 1,
- ReductionParameter_ReductionOp_ASUM = 2,
- ReductionParameter_ReductionOp_SUMSQ = 3,
- ReductionParameter_ReductionOp_MEAN = 4
-};
-bool ReductionParameter_ReductionOp_IsValid(int value);
-const ReductionParameter_ReductionOp ReductionParameter_ReductionOp_ReductionOp_MIN = ReductionParameter_ReductionOp_SUM;
-const ReductionParameter_ReductionOp ReductionParameter_ReductionOp_ReductionOp_MAX = ReductionParameter_ReductionOp_MEAN;
-const int ReductionParameter_ReductionOp_ReductionOp_ARRAYSIZE = ReductionParameter_ReductionOp_ReductionOp_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* ReductionParameter_ReductionOp_descriptor();
-inline const ::std::string& ReductionParameter_ReductionOp_Name(ReductionParameter_ReductionOp value) {
- return ::google::protobuf::internal::NameOfEnum(
- ReductionParameter_ReductionOp_descriptor(), value);
-}
-inline bool ReductionParameter_ReductionOp_Parse(
- const ::std::string& name, ReductionParameter_ReductionOp* value) {
- return ::google::protobuf::internal::ParseNamedEnum<ReductionParameter_ReductionOp>(
- ReductionParameter_ReductionOp_descriptor(), name, value);
-}
-enum ReLUParameter_Engine {
- ReLUParameter_Engine_DEFAULT = 0,
- ReLUParameter_Engine_CAFFE = 1,
- ReLUParameter_Engine_CUDNN = 2
-};
-bool ReLUParameter_Engine_IsValid(int value);
-const ReLUParameter_Engine ReLUParameter_Engine_Engine_MIN = ReLUParameter_Engine_DEFAULT;
-const ReLUParameter_Engine ReLUParameter_Engine_Engine_MAX = ReLUParameter_Engine_CUDNN;
-const int ReLUParameter_Engine_Engine_ARRAYSIZE = ReLUParameter_Engine_Engine_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* ReLUParameter_Engine_descriptor();
-inline const ::std::string& ReLUParameter_Engine_Name(ReLUParameter_Engine value) {
- return ::google::protobuf::internal::NameOfEnum(
- ReLUParameter_Engine_descriptor(), value);
-}
-inline bool ReLUParameter_Engine_Parse(
- const ::std::string& name, ReLUParameter_Engine* value) {
- return ::google::protobuf::internal::ParseNamedEnum<ReLUParameter_Engine>(
- ReLUParameter_Engine_descriptor(), name, value);
-}
-enum SigmoidParameter_Engine {
- SigmoidParameter_Engine_DEFAULT = 0,
- SigmoidParameter_Engine_CAFFE = 1,
- SigmoidParameter_Engine_CUDNN = 2
-};
-bool SigmoidParameter_Engine_IsValid(int value);
-const SigmoidParameter_Engine SigmoidParameter_Engine_Engine_MIN = SigmoidParameter_Engine_DEFAULT;
-const SigmoidParameter_Engine SigmoidParameter_Engine_Engine_MAX = SigmoidParameter_Engine_CUDNN;
-const int SigmoidParameter_Engine_Engine_ARRAYSIZE = SigmoidParameter_Engine_Engine_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* SigmoidParameter_Engine_descriptor();
-inline const ::std::string& SigmoidParameter_Engine_Name(SigmoidParameter_Engine value) {
- return ::google::protobuf::internal::NameOfEnum(
- SigmoidParameter_Engine_descriptor(), value);
-}
-inline bool SigmoidParameter_Engine_Parse(
- const ::std::string& name, SigmoidParameter_Engine* value) {
- return ::google::protobuf::internal::ParseNamedEnum<SigmoidParameter_Engine>(
- SigmoidParameter_Engine_descriptor(), name, value);
-}
-enum SoftmaxParameter_Engine {
- SoftmaxParameter_Engine_DEFAULT = 0,
- SoftmaxParameter_Engine_CAFFE = 1,
- SoftmaxParameter_Engine_CUDNN = 2
-};
-bool SoftmaxParameter_Engine_IsValid(int value);
-const SoftmaxParameter_Engine SoftmaxParameter_Engine_Engine_MIN = SoftmaxParameter_Engine_DEFAULT;
-const SoftmaxParameter_Engine SoftmaxParameter_Engine_Engine_MAX = SoftmaxParameter_Engine_CUDNN;
-const int SoftmaxParameter_Engine_Engine_ARRAYSIZE = SoftmaxParameter_Engine_Engine_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* SoftmaxParameter_Engine_descriptor();
-inline const ::std::string& SoftmaxParameter_Engine_Name(SoftmaxParameter_Engine value) {
- return ::google::protobuf::internal::NameOfEnum(
- SoftmaxParameter_Engine_descriptor(), value);
-}
-inline bool SoftmaxParameter_Engine_Parse(
- const ::std::string& name, SoftmaxParameter_Engine* value) {
- return ::google::protobuf::internal::ParseNamedEnum<SoftmaxParameter_Engine>(
- SoftmaxParameter_Engine_descriptor(), name, value);
-}
-enum TanHParameter_Engine {
- TanHParameter_Engine_DEFAULT = 0,
- TanHParameter_Engine_CAFFE = 1,
- TanHParameter_Engine_CUDNN = 2
-};
-bool TanHParameter_Engine_IsValid(int value);
-const TanHParameter_Engine TanHParameter_Engine_Engine_MIN = TanHParameter_Engine_DEFAULT;
-const TanHParameter_Engine TanHParameter_Engine_Engine_MAX = TanHParameter_Engine_CUDNN;
-const int TanHParameter_Engine_Engine_ARRAYSIZE = TanHParameter_Engine_Engine_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* TanHParameter_Engine_descriptor();
-inline const ::std::string& TanHParameter_Engine_Name(TanHParameter_Engine value) {
- return ::google::protobuf::internal::NameOfEnum(
- TanHParameter_Engine_descriptor(), value);
-}
-inline bool TanHParameter_Engine_Parse(
- const ::std::string& name, TanHParameter_Engine* value) {
- return ::google::protobuf::internal::ParseNamedEnum<TanHParameter_Engine>(
- TanHParameter_Engine_descriptor(), name, value);
-}
-enum SPPParameter_PoolMethod {
- SPPParameter_PoolMethod_MAX = 0,
- SPPParameter_PoolMethod_AVE = 1,
- SPPParameter_PoolMethod_STOCHASTIC = 2
-};
-bool SPPParameter_PoolMethod_IsValid(int value);
-const SPPParameter_PoolMethod SPPParameter_PoolMethod_PoolMethod_MIN = SPPParameter_PoolMethod_MAX;
-const SPPParameter_PoolMethod SPPParameter_PoolMethod_PoolMethod_MAX = SPPParameter_PoolMethod_STOCHASTIC;
-const int SPPParameter_PoolMethod_PoolMethod_ARRAYSIZE = SPPParameter_PoolMethod_PoolMethod_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* SPPParameter_PoolMethod_descriptor();
-inline const ::std::string& SPPParameter_PoolMethod_Name(SPPParameter_PoolMethod value) {
- return ::google::protobuf::internal::NameOfEnum(
- SPPParameter_PoolMethod_descriptor(), value);
-}
-inline bool SPPParameter_PoolMethod_Parse(
- const ::std::string& name, SPPParameter_PoolMethod* value) {
- return ::google::protobuf::internal::ParseNamedEnum<SPPParameter_PoolMethod>(
- SPPParameter_PoolMethod_descriptor(), name, value);
-}
-enum SPPParameter_Engine {
- SPPParameter_Engine_DEFAULT = 0,
- SPPParameter_Engine_CAFFE = 1,
- SPPParameter_Engine_CUDNN = 2
-};
-bool SPPParameter_Engine_IsValid(int value);
-const SPPParameter_Engine SPPParameter_Engine_Engine_MIN = SPPParameter_Engine_DEFAULT;
-const SPPParameter_Engine SPPParameter_Engine_Engine_MAX = SPPParameter_Engine_CUDNN;
-const int SPPParameter_Engine_Engine_ARRAYSIZE = SPPParameter_Engine_Engine_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* SPPParameter_Engine_descriptor();
-inline const ::std::string& SPPParameter_Engine_Name(SPPParameter_Engine value) {
- return ::google::protobuf::internal::NameOfEnum(
- SPPParameter_Engine_descriptor(), value);
-}
-inline bool SPPParameter_Engine_Parse(
- const ::std::string& name, SPPParameter_Engine* value) {
- return ::google::protobuf::internal::ParseNamedEnum<SPPParameter_Engine>(
- SPPParameter_Engine_descriptor(), name, value);
-}
-enum V1LayerParameter_LayerType {
- V1LayerParameter_LayerType_NONE = 0,
- V1LayerParameter_LayerType_ABSVAL = 35,
- V1LayerParameter_LayerType_ACCURACY = 1,
- V1LayerParameter_LayerType_ARGMAX = 30,
- V1LayerParameter_LayerType_BNLL = 2,
- V1LayerParameter_LayerType_CONCAT = 3,
- V1LayerParameter_LayerType_CONTRASTIVE_LOSS = 37,
- V1LayerParameter_LayerType_CONVOLUTION = 4,
- V1LayerParameter_LayerType_DATA = 5,
- V1LayerParameter_LayerType_DECONVOLUTION = 39,
- V1LayerParameter_LayerType_DROPOUT = 6,
- V1LayerParameter_LayerType_DUMMY_DATA = 32,
- V1LayerParameter_LayerType_EUCLIDEAN_LOSS = 7,
- V1LayerParameter_LayerType_ELTWISE = 25,
- V1LayerParameter_LayerType_EXP = 38,
- V1LayerParameter_LayerType_FLATTEN = 8,
- V1LayerParameter_LayerType_HDF5_DATA = 9,
- V1LayerParameter_LayerType_HDF5_OUTPUT = 10,
- V1LayerParameter_LayerType_HINGE_LOSS = 28,
- V1LayerParameter_LayerType_IM2COL = 11,
- V1LayerParameter_LayerType_IMAGE_DATA = 12,
- V1LayerParameter_LayerType_INFOGAIN_LOSS = 13,
- V1LayerParameter_LayerType_INNER_PRODUCT = 14,
- V1LayerParameter_LayerType_LRN = 15,
- V1LayerParameter_LayerType_MEMORY_DATA = 29,
- V1LayerParameter_LayerType_MULTINOMIAL_LOGISTIC_LOSS = 16,
- V1LayerParameter_LayerType_MVN = 34,
- V1LayerParameter_LayerType_POOLING = 17,
- V1LayerParameter_LayerType_POWER = 26,
- V1LayerParameter_LayerType_RELU = 18,
- V1LayerParameter_LayerType_SIGMOID = 19,
- V1LayerParameter_LayerType_SIGMOID_CROSS_ENTROPY_LOSS = 27,
- V1LayerParameter_LayerType_SILENCE = 36,
- V1LayerParameter_LayerType_SOFTMAX = 20,
- V1LayerParameter_LayerType_SOFTMAX_LOSS = 21,
- V1LayerParameter_LayerType_SPLIT = 22,
- V1LayerParameter_LayerType_SLICE = 33,
- V1LayerParameter_LayerType_TANH = 23,
- V1LayerParameter_LayerType_WINDOW_DATA = 24,
- V1LayerParameter_LayerType_THRESHOLD = 31
-};
-bool V1LayerParameter_LayerType_IsValid(int value);
-const V1LayerParameter_LayerType V1LayerParameter_LayerType_LayerType_MIN = V1LayerParameter_LayerType_NONE;
-const V1LayerParameter_LayerType V1LayerParameter_LayerType_LayerType_MAX = V1LayerParameter_LayerType_DECONVOLUTION;
-const int V1LayerParameter_LayerType_LayerType_ARRAYSIZE = V1LayerParameter_LayerType_LayerType_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* V1LayerParameter_LayerType_descriptor();
-inline const ::std::string& V1LayerParameter_LayerType_Name(V1LayerParameter_LayerType value) {
- return ::google::protobuf::internal::NameOfEnum(
- V1LayerParameter_LayerType_descriptor(), value);
-}
-inline bool V1LayerParameter_LayerType_Parse(
- const ::std::string& name, V1LayerParameter_LayerType* value) {
- return ::google::protobuf::internal::ParseNamedEnum<V1LayerParameter_LayerType>(
- V1LayerParameter_LayerType_descriptor(), name, value);
-}
-enum V1LayerParameter_DimCheckMode {
- V1LayerParameter_DimCheckMode_STRICT = 0,
- V1LayerParameter_DimCheckMode_PERMISSIVE = 1
-};
-bool V1LayerParameter_DimCheckMode_IsValid(int value);
-const V1LayerParameter_DimCheckMode V1LayerParameter_DimCheckMode_DimCheckMode_MIN = V1LayerParameter_DimCheckMode_STRICT;
-const V1LayerParameter_DimCheckMode V1LayerParameter_DimCheckMode_DimCheckMode_MAX = V1LayerParameter_DimCheckMode_PERMISSIVE;
-const int V1LayerParameter_DimCheckMode_DimCheckMode_ARRAYSIZE = V1LayerParameter_DimCheckMode_DimCheckMode_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* V1LayerParameter_DimCheckMode_descriptor();
-inline const ::std::string& V1LayerParameter_DimCheckMode_Name(V1LayerParameter_DimCheckMode value) {
- return ::google::protobuf::internal::NameOfEnum(
- V1LayerParameter_DimCheckMode_descriptor(), value);
-}
-inline bool V1LayerParameter_DimCheckMode_Parse(
- const ::std::string& name, V1LayerParameter_DimCheckMode* value) {
- return ::google::protobuf::internal::ParseNamedEnum<V1LayerParameter_DimCheckMode>(
- V1LayerParameter_DimCheckMode_descriptor(), name, value);
-}
-enum V0LayerParameter_PoolMethod {
- V0LayerParameter_PoolMethod_MAX = 0,
- V0LayerParameter_PoolMethod_AVE = 1,
- V0LayerParameter_PoolMethod_STOCHASTIC = 2
-};
-bool V0LayerParameter_PoolMethod_IsValid(int value);
-const V0LayerParameter_PoolMethod V0LayerParameter_PoolMethod_PoolMethod_MIN = V0LayerParameter_PoolMethod_MAX;
-const V0LayerParameter_PoolMethod V0LayerParameter_PoolMethod_PoolMethod_MAX = V0LayerParameter_PoolMethod_STOCHASTIC;
-const int V0LayerParameter_PoolMethod_PoolMethod_ARRAYSIZE = V0LayerParameter_PoolMethod_PoolMethod_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* V0LayerParameter_PoolMethod_descriptor();
-inline const ::std::string& V0LayerParameter_PoolMethod_Name(V0LayerParameter_PoolMethod value) {
- return ::google::protobuf::internal::NameOfEnum(
- V0LayerParameter_PoolMethod_descriptor(), value);
-}
-inline bool V0LayerParameter_PoolMethod_Parse(
- const ::std::string& name, V0LayerParameter_PoolMethod* value) {
- return ::google::protobuf::internal::ParseNamedEnum<V0LayerParameter_PoolMethod>(
- V0LayerParameter_PoolMethod_descriptor(), name, value);
-}
-enum Phase {
- TRAIN = 0,
- TEST = 1
-};
-bool Phase_IsValid(int value);
-const Phase Phase_MIN = TRAIN;
-const Phase Phase_MAX = TEST;
-const int Phase_ARRAYSIZE = Phase_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* Phase_descriptor();
-inline const ::std::string& Phase_Name(Phase value) {
- return ::google::protobuf::internal::NameOfEnum(
- Phase_descriptor(), value);
-}
-inline bool Phase_Parse(
- const ::std::string& name, Phase* value) {
- return ::google::protobuf::internal::ParseNamedEnum<Phase>(
- Phase_descriptor(), name, value);
-}
-// ===================================================================
-
-class BlobShape : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.BlobShape) */ {
- public:
- BlobShape();
- virtual ~BlobShape();
-
- BlobShape(const BlobShape& from);
-
- inline BlobShape& operator=(const BlobShape& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const BlobShape& default_instance();
-
- static const BlobShape* internal_default_instance();
-
- void Swap(BlobShape* other);
-
- // implements Message ----------------------------------------------
-
- inline BlobShape* New() const { return New(NULL); }
-
- BlobShape* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const BlobShape& from);
- void MergeFrom(const BlobShape& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(BlobShape* other);
- void UnsafeMergeFrom(const BlobShape& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // repeated int64 dim = 1 [packed = true];
- int dim_size() const;
- void clear_dim();
- static const int kDimFieldNumber = 1;
- ::google::protobuf::int64 dim(int index) const;
- void set_dim(int index, ::google::protobuf::int64 value);
- void add_dim(::google::protobuf::int64 value);
- const ::google::protobuf::RepeatedField< ::google::protobuf::int64 >&
- dim() const;
- ::google::protobuf::RepeatedField< ::google::protobuf::int64 >*
- mutable_dim();
-
- // @@protoc_insertion_point(class_scope:caffe.BlobShape)
- private:
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::RepeatedField< ::google::protobuf::int64 > dim_;
- mutable int _dim_cached_byte_size_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<BlobShape> BlobShape_default_instance_;
-
-// -------------------------------------------------------------------
-
-class BlobProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.BlobProto) */ {
- public:
- BlobProto();
- virtual ~BlobProto();
-
- BlobProto(const BlobProto& from);
-
- inline BlobProto& operator=(const BlobProto& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const BlobProto& default_instance();
-
- static const BlobProto* internal_default_instance();
-
- void Swap(BlobProto* other);
-
- // implements Message ----------------------------------------------
-
- inline BlobProto* New() const { return New(NULL); }
-
- BlobProto* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const BlobProto& from);
- void MergeFrom(const BlobProto& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(BlobProto* other);
- void UnsafeMergeFrom(const BlobProto& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional .caffe.BlobShape shape = 7;
- bool has_shape() const;
- void clear_shape();
- static const int kShapeFieldNumber = 7;
- const ::caffe::BlobShape& shape() const;
- ::caffe::BlobShape* mutable_shape();
- ::caffe::BlobShape* release_shape();
- void set_allocated_shape(::caffe::BlobShape* shape);
-
- // repeated float data = 5 [packed = true];
- int data_size() const;
- void clear_data();
- static const int kDataFieldNumber = 5;
- float data(int index) const;
- void set_data(int index, float value);
- void add_data(float value);
- const ::google::protobuf::RepeatedField< float >&
- data() const;
- ::google::protobuf::RepeatedField< float >*
- mutable_data();
-
- // repeated float diff = 6 [packed = true];
- int diff_size() const;
- void clear_diff();
- static const int kDiffFieldNumber = 6;
- float diff(int index) const;
- void set_diff(int index, float value);
- void add_diff(float value);
- const ::google::protobuf::RepeatedField< float >&
- diff() const;
- ::google::protobuf::RepeatedField< float >*
- mutable_diff();
-
- // optional int32 num = 1 [default = 0];
- bool has_num() const;
- void clear_num();
- static const int kNumFieldNumber = 1;
- ::google::protobuf::int32 num() const;
- void set_num(::google::protobuf::int32 value);
-
- // optional int32 channels = 2 [default = 0];
- bool has_channels() const;
- void clear_channels();
- static const int kChannelsFieldNumber = 2;
- ::google::protobuf::int32 channels() const;
- void set_channels(::google::protobuf::int32 value);
-
- // optional int32 height = 3 [default = 0];
- bool has_height() const;
- void clear_height();
- static const int kHeightFieldNumber = 3;
- ::google::protobuf::int32 height() const;
- void set_height(::google::protobuf::int32 value);
-
- // optional int32 width = 4 [default = 0];
- bool has_width() const;
- void clear_width();
- static const int kWidthFieldNumber = 4;
- ::google::protobuf::int32 width() const;
- void set_width(::google::protobuf::int32 value);
-
- // @@protoc_insertion_point(class_scope:caffe.BlobProto)
- private:
- inline void set_has_shape();
- inline void clear_has_shape();
- inline void set_has_num();
- inline void clear_has_num();
- inline void set_has_channels();
- inline void clear_has_channels();
- inline void set_has_height();
- inline void clear_has_height();
- inline void set_has_width();
- inline void clear_has_width();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::RepeatedField< float > data_;
- mutable int _data_cached_byte_size_;
- ::google::protobuf::RepeatedField< float > diff_;
- mutable int _diff_cached_byte_size_;
- ::caffe::BlobShape* shape_;
- ::google::protobuf::int32 num_;
- ::google::protobuf::int32 channels_;
- ::google::protobuf::int32 height_;
- ::google::protobuf::int32 width_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<BlobProto> BlobProto_default_instance_;
-
-// -------------------------------------------------------------------
-
-class BlobProtoVector : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.BlobProtoVector) */ {
- public:
- BlobProtoVector();
- virtual ~BlobProtoVector();
-
- BlobProtoVector(const BlobProtoVector& from);
-
- inline BlobProtoVector& operator=(const BlobProtoVector& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const BlobProtoVector& default_instance();
-
- static const BlobProtoVector* internal_default_instance();
-
- void Swap(BlobProtoVector* other);
-
- // implements Message ----------------------------------------------
-
- inline BlobProtoVector* New() const { return New(NULL); }
-
- BlobProtoVector* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const BlobProtoVector& from);
- void MergeFrom(const BlobProtoVector& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(BlobProtoVector* other);
- void UnsafeMergeFrom(const BlobProtoVector& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // repeated .caffe.BlobProto blobs = 1;
- int blobs_size() const;
- void clear_blobs();
- static const int kBlobsFieldNumber = 1;
- const ::caffe::BlobProto& blobs(int index) const;
- ::caffe::BlobProto* mutable_blobs(int index);
- ::caffe::BlobProto* add_blobs();
- ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
- mutable_blobs();
- const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
- blobs() const;
-
- // @@protoc_insertion_point(class_scope:caffe.BlobProtoVector)
- private:
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto > blobs_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<BlobProtoVector> BlobProtoVector_default_instance_;
-
-// -------------------------------------------------------------------
-
-class CropParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.CropParameter) */ {
- public:
- CropParameter();
- virtual ~CropParameter();
-
- CropParameter(const CropParameter& from);
-
- inline CropParameter& operator=(const CropParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const CropParameter& default_instance();
-
- static const CropParameter* internal_default_instance();
-
- void Swap(CropParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline CropParameter* New() const { return New(NULL); }
-
- CropParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const CropParameter& from);
- void MergeFrom(const CropParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(CropParameter* other);
- void UnsafeMergeFrom(const CropParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional int32 axis = 1 [default = 2];
- bool has_axis() const;
- void clear_axis();
- static const int kAxisFieldNumber = 1;
- ::google::protobuf::int32 axis() const;
- void set_axis(::google::protobuf::int32 value);
-
- // repeated uint32 offset = 2;
- int offset_size() const;
- void clear_offset();
- static const int kOffsetFieldNumber = 2;
- ::google::protobuf::uint32 offset(int index) const;
- void set_offset(int index, ::google::protobuf::uint32 value);
- void add_offset(::google::protobuf::uint32 value);
- const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
- offset() const;
- ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
- mutable_offset();
-
- // @@protoc_insertion_point(class_scope:caffe.CropParameter)
- private:
- inline void set_has_axis();
- inline void clear_has_axis();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > offset_;
- ::google::protobuf::int32 axis_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<CropParameter> CropParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class PermuteParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.PermuteParameter) */ {
- public:
- PermuteParameter();
- virtual ~PermuteParameter();
-
- PermuteParameter(const PermuteParameter& from);
-
- inline PermuteParameter& operator=(const PermuteParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const PermuteParameter& default_instance();
-
- static const PermuteParameter* internal_default_instance();
-
- void Swap(PermuteParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline PermuteParameter* New() const { return New(NULL); }
-
- PermuteParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const PermuteParameter& from);
- void MergeFrom(const PermuteParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(PermuteParameter* other);
- void UnsafeMergeFrom(const PermuteParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // repeated uint32 order = 1;
- int order_size() const;
- void clear_order();
- static const int kOrderFieldNumber = 1;
- ::google::protobuf::uint32 order(int index) const;
- void set_order(int index, ::google::protobuf::uint32 value);
- void add_order(::google::protobuf::uint32 value);
- const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
- order() const;
- ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
- mutable_order();
-
- // @@protoc_insertion_point(class_scope:caffe.PermuteParameter)
- private:
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > order_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<PermuteParameter> PermuteParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class NormalizeBBoxParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.NormalizeBBoxParameter) */ {
- public:
- NormalizeBBoxParameter();
- virtual ~NormalizeBBoxParameter();
-
- NormalizeBBoxParameter(const NormalizeBBoxParameter& from);
-
- inline NormalizeBBoxParameter& operator=(const NormalizeBBoxParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const NormalizeBBoxParameter& default_instance();
-
- static const NormalizeBBoxParameter* internal_default_instance();
-
- void Swap(NormalizeBBoxParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline NormalizeBBoxParameter* New() const { return New(NULL); }
-
- NormalizeBBoxParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const NormalizeBBoxParameter& from);
- void MergeFrom(const NormalizeBBoxParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(NormalizeBBoxParameter* other);
- void UnsafeMergeFrom(const NormalizeBBoxParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional bool across_spatial = 1 [default = true];
- bool has_across_spatial() const;
- void clear_across_spatial();
- static const int kAcrossSpatialFieldNumber = 1;
- bool across_spatial() const;
- void set_across_spatial(bool value);
-
- // optional .caffe.FillerParameter scale_filler = 2;
- bool has_scale_filler() const;
- void clear_scale_filler();
- static const int kScaleFillerFieldNumber = 2;
- const ::caffe::FillerParameter& scale_filler() const;
- ::caffe::FillerParameter* mutable_scale_filler();
- ::caffe::FillerParameter* release_scale_filler();
- void set_allocated_scale_filler(::caffe::FillerParameter* scale_filler);
-
- // optional bool channel_shared = 3 [default = true];
- bool has_channel_shared() const;
- void clear_channel_shared();
- static const int kChannelSharedFieldNumber = 3;
- bool channel_shared() const;
- void set_channel_shared(bool value);
-
- // optional float eps = 4 [default = 1e-10];
- bool has_eps() const;
- void clear_eps();
- static const int kEpsFieldNumber = 4;
- float eps() const;
- void set_eps(float value);
-
- // @@protoc_insertion_point(class_scope:caffe.NormalizeBBoxParameter)
- private:
- inline void set_has_across_spatial();
- inline void clear_has_across_spatial();
- inline void set_has_scale_filler();
- inline void clear_has_scale_filler();
- inline void set_has_channel_shared();
- inline void clear_has_channel_shared();
- inline void set_has_eps();
- inline void clear_has_eps();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::caffe::FillerParameter* scale_filler_;
- bool across_spatial_;
- bool channel_shared_;
- float eps_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<NormalizeBBoxParameter> NormalizeBBoxParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class PriorBoxParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.PriorBoxParameter) */ {
- public:
- PriorBoxParameter();
- virtual ~PriorBoxParameter();
-
- PriorBoxParameter(const PriorBoxParameter& from);
-
- inline PriorBoxParameter& operator=(const PriorBoxParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const PriorBoxParameter& default_instance();
-
- static const PriorBoxParameter* internal_default_instance();
-
- void Swap(PriorBoxParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline PriorBoxParameter* New() const { return New(NULL); }
-
- PriorBoxParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const PriorBoxParameter& from);
- void MergeFrom(const PriorBoxParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(PriorBoxParameter* other);
- void UnsafeMergeFrom(const PriorBoxParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- typedef PriorBoxParameter_CodeType CodeType;
- static const CodeType CORNER =
- PriorBoxParameter_CodeType_CORNER;
- static const CodeType CENTER_SIZE =
- PriorBoxParameter_CodeType_CENTER_SIZE;
- static inline bool CodeType_IsValid(int value) {
- return PriorBoxParameter_CodeType_IsValid(value);
- }
- static const CodeType CodeType_MIN =
- PriorBoxParameter_CodeType_CodeType_MIN;
- static const CodeType CodeType_MAX =
- PriorBoxParameter_CodeType_CodeType_MAX;
- static const int CodeType_ARRAYSIZE =
- PriorBoxParameter_CodeType_CodeType_ARRAYSIZE;
- static inline const ::google::protobuf::EnumDescriptor*
- CodeType_descriptor() {
- return PriorBoxParameter_CodeType_descriptor();
- }
- static inline const ::std::string& CodeType_Name(CodeType value) {
- return PriorBoxParameter_CodeType_Name(value);
- }
- static inline bool CodeType_Parse(const ::std::string& name,
- CodeType* value) {
- return PriorBoxParameter_CodeType_Parse(name, value);
- }
-
- // accessors -------------------------------------------------------
-
- // optional float min_size = 1;
- bool has_min_size() const;
- void clear_min_size();
- static const int kMinSizeFieldNumber = 1;
- float min_size() const;
- void set_min_size(float value);
-
- // optional float max_size = 2;
- bool has_max_size() const;
- void clear_max_size();
- static const int kMaxSizeFieldNumber = 2;
- float max_size() const;
- void set_max_size(float value);
-
- // repeated float aspect_ratio = 3;
- int aspect_ratio_size() const;
- void clear_aspect_ratio();
- static const int kAspectRatioFieldNumber = 3;
- float aspect_ratio(int index) const;
- void set_aspect_ratio(int index, float value);
- void add_aspect_ratio(float value);
- const ::google::protobuf::RepeatedField< float >&
- aspect_ratio() const;
- ::google::protobuf::RepeatedField< float >*
- mutable_aspect_ratio();
-
- // optional bool flip = 4 [default = true];
- bool has_flip() const;
- void clear_flip();
- static const int kFlipFieldNumber = 4;
- bool flip() const;
- void set_flip(bool value);
-
- // optional bool clip = 5 [default = true];
- bool has_clip() const;
- void clear_clip();
- static const int kClipFieldNumber = 5;
- bool clip() const;
- void set_clip(bool value);
-
- // repeated float variance = 6;
- int variance_size() const;
- void clear_variance();
- static const int kVarianceFieldNumber = 6;
- float variance(int index) const;
- void set_variance(int index, float value);
- void add_variance(float value);
- const ::google::protobuf::RepeatedField< float >&
- variance() const;
- ::google::protobuf::RepeatedField< float >*
- mutable_variance();
-
- // @@protoc_insertion_point(class_scope:caffe.PriorBoxParameter)
- private:
- inline void set_has_min_size();
- inline void clear_has_min_size();
- inline void set_has_max_size();
- inline void clear_has_max_size();
- inline void set_has_flip();
- inline void clear_has_flip();
- inline void set_has_clip();
- inline void clear_has_clip();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::RepeatedField< float > aspect_ratio_;
- ::google::protobuf::RepeatedField< float > variance_;
- float min_size_;
- float max_size_;
- bool flip_;
- bool clip_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<PriorBoxParameter> PriorBoxParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class DetectionOutputParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.DetectionOutputParameter) */ {
- public:
- DetectionOutputParameter();
- virtual ~DetectionOutputParameter();
-
- DetectionOutputParameter(const DetectionOutputParameter& from);
-
- inline DetectionOutputParameter& operator=(const DetectionOutputParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const DetectionOutputParameter& default_instance();
-
- static const DetectionOutputParameter* internal_default_instance();
-
- void Swap(DetectionOutputParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline DetectionOutputParameter* New() const { return New(NULL); }
-
- DetectionOutputParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const DetectionOutputParameter& from);
- void MergeFrom(const DetectionOutputParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(DetectionOutputParameter* other);
- void UnsafeMergeFrom(const DetectionOutputParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional uint32 num_classes = 1;
- bool has_num_classes() const;
- void clear_num_classes();
- static const int kNumClassesFieldNumber = 1;
- ::google::protobuf::uint32 num_classes() const;
- void set_num_classes(::google::protobuf::uint32 value);
-
- // optional bool share_location = 2 [default = true];
- bool has_share_location() const;
- void clear_share_location();
- static const int kShareLocationFieldNumber = 2;
- bool share_location() const;
- void set_share_location(bool value);
-
- // optional int32 background_label_id = 3 [default = 0];
- bool has_background_label_id() const;
- void clear_background_label_id();
- static const int kBackgroundLabelIdFieldNumber = 3;
- ::google::protobuf::int32 background_label_id() const;
- void set_background_label_id(::google::protobuf::int32 value);
-
- // optional .caffe.PriorBoxParameter.CodeType code_type = 6 [default = CORNER];
- bool has_code_type() const;
- void clear_code_type();
- static const int kCodeTypeFieldNumber = 6;
- ::caffe::PriorBoxParameter_CodeType code_type() const;
- void set_code_type(::caffe::PriorBoxParameter_CodeType value);
-
- // optional bool variance_encoded_in_target = 8 [default = false];
- bool has_variance_encoded_in_target() const;
- void clear_variance_encoded_in_target();
- static const int kVarianceEncodedInTargetFieldNumber = 8;
- bool variance_encoded_in_target() const;
- void set_variance_encoded_in_target(bool value);
-
- // optional int32 keep_top_k = 7 [default = -1];
- bool has_keep_top_k() const;
- void clear_keep_top_k();
- static const int kKeepTopKFieldNumber = 7;
- ::google::protobuf::int32 keep_top_k() const;
- void set_keep_top_k(::google::protobuf::int32 value);
-
- // optional float confidence_threshold = 9;
- bool has_confidence_threshold() const;
- void clear_confidence_threshold();
- static const int kConfidenceThresholdFieldNumber = 9;
- float confidence_threshold() const;
- void set_confidence_threshold(float value);
-
- // optional float nms_threshold = 10 [default = 0.3];
- bool has_nms_threshold() const;
- void clear_nms_threshold();
- static const int kNmsThresholdFieldNumber = 10;
- float nms_threshold() const;
- void set_nms_threshold(float value);
-
- // optional int32 top_k = 11;
- bool has_top_k() const;
- void clear_top_k();
- static const int kTopKFieldNumber = 11;
- ::google::protobuf::int32 top_k() const;
- void set_top_k(::google::protobuf::int32 value);
-
- // @@protoc_insertion_point(class_scope:caffe.DetectionOutputParameter)
- private:
- inline void set_has_num_classes();
- inline void clear_has_num_classes();
- inline void set_has_share_location();
- inline void clear_has_share_location();
- inline void set_has_background_label_id();
- inline void clear_has_background_label_id();
- inline void set_has_code_type();
- inline void clear_has_code_type();
- inline void set_has_variance_encoded_in_target();
- inline void clear_has_variance_encoded_in_target();
- inline void set_has_keep_top_k();
- inline void clear_has_keep_top_k();
- inline void set_has_confidence_threshold();
- inline void clear_has_confidence_threshold();
- inline void set_has_nms_threshold();
- inline void clear_has_nms_threshold();
- inline void set_has_top_k();
- inline void clear_has_top_k();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::uint32 num_classes_;
- ::google::protobuf::int32 background_label_id_;
- bool variance_encoded_in_target_;
- float confidence_threshold_;
- ::google::protobuf::int32 top_k_;
- bool share_location_;
- int code_type_;
- ::google::protobuf::int32 keep_top_k_;
- float nms_threshold_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<DetectionOutputParameter> DetectionOutputParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class Datum : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.Datum) */ {
- public:
- Datum();
- virtual ~Datum();
-
- Datum(const Datum& from);
-
- inline Datum& operator=(const Datum& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const Datum& default_instance();
-
- static const Datum* internal_default_instance();
-
- void Swap(Datum* other);
-
- // implements Message ----------------------------------------------
-
- inline Datum* New() const { return New(NULL); }
-
- Datum* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const Datum& from);
- void MergeFrom(const Datum& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(Datum* other);
- void UnsafeMergeFrom(const Datum& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional int32 channels = 1;
- bool has_channels() const;
- void clear_channels();
- static const int kChannelsFieldNumber = 1;
- ::google::protobuf::int32 channels() const;
- void set_channels(::google::protobuf::int32 value);
-
- // optional int32 height = 2;
- bool has_height() const;
- void clear_height();
- static const int kHeightFieldNumber = 2;
- ::google::protobuf::int32 height() const;
- void set_height(::google::protobuf::int32 value);
-
- // optional int32 width = 3;
- bool has_width() const;
- void clear_width();
- static const int kWidthFieldNumber = 3;
- ::google::protobuf::int32 width() const;
- void set_width(::google::protobuf::int32 value);
-
- // optional bytes data = 4;
- bool has_data() const;
- void clear_data();
- static const int kDataFieldNumber = 4;
- const ::std::string& data() const;
- void set_data(const ::std::string& value);
- void set_data(const char* value);
- void set_data(const void* value, size_t size);
- ::std::string* mutable_data();
- ::std::string* release_data();
- void set_allocated_data(::std::string* data);
-
- // optional int32 label = 5;
- bool has_label() const;
- void clear_label();
- static const int kLabelFieldNumber = 5;
- ::google::protobuf::int32 label() const;
- void set_label(::google::protobuf::int32 value);
-
- // repeated float float_data = 6;
- int float_data_size() const;
- void clear_float_data();
- static const int kFloatDataFieldNumber = 6;
- float float_data(int index) const;
- void set_float_data(int index, float value);
- void add_float_data(float value);
- const ::google::protobuf::RepeatedField< float >&
- float_data() const;
- ::google::protobuf::RepeatedField< float >*
- mutable_float_data();
-
- // optional bool encoded = 7 [default = false];
- bool has_encoded() const;
- void clear_encoded();
- static const int kEncodedFieldNumber = 7;
- bool encoded() const;
- void set_encoded(bool value);
-
- // @@protoc_insertion_point(class_scope:caffe.Datum)
- private:
- inline void set_has_channels();
- inline void clear_has_channels();
- inline void set_has_height();
- inline void clear_has_height();
- inline void set_has_width();
- inline void clear_has_width();
- inline void set_has_data();
- inline void clear_has_data();
- inline void set_has_label();
- inline void clear_has_label();
- inline void set_has_encoded();
- inline void clear_has_encoded();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::RepeatedField< float > float_data_;
- ::google::protobuf::internal::ArenaStringPtr data_;
- ::google::protobuf::int32 channels_;
- ::google::protobuf::int32 height_;
- ::google::protobuf::int32 width_;
- ::google::protobuf::int32 label_;
- bool encoded_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<Datum> Datum_default_instance_;
-
-// -------------------------------------------------------------------
-
-class FillerParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.FillerParameter) */ {
- public:
- FillerParameter();
- virtual ~FillerParameter();
-
- FillerParameter(const FillerParameter& from);
-
- inline FillerParameter& operator=(const FillerParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const FillerParameter& default_instance();
-
- static const FillerParameter* internal_default_instance();
-
- void Swap(FillerParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline FillerParameter* New() const { return New(NULL); }
-
- FillerParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const FillerParameter& from);
- void MergeFrom(const FillerParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(FillerParameter* other);
- void UnsafeMergeFrom(const FillerParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- typedef FillerParameter_VarianceNorm VarianceNorm;
- static const VarianceNorm FAN_IN =
- FillerParameter_VarianceNorm_FAN_IN;
- static const VarianceNorm FAN_OUT =
- FillerParameter_VarianceNorm_FAN_OUT;
- static const VarianceNorm AVERAGE =
- FillerParameter_VarianceNorm_AVERAGE;
- static inline bool VarianceNorm_IsValid(int value) {
- return FillerParameter_VarianceNorm_IsValid(value);
- }
- static const VarianceNorm VarianceNorm_MIN =
- FillerParameter_VarianceNorm_VarianceNorm_MIN;
- static const VarianceNorm VarianceNorm_MAX =
- FillerParameter_VarianceNorm_VarianceNorm_MAX;
- static const int VarianceNorm_ARRAYSIZE =
- FillerParameter_VarianceNorm_VarianceNorm_ARRAYSIZE;
- static inline const ::google::protobuf::EnumDescriptor*
- VarianceNorm_descriptor() {
- return FillerParameter_VarianceNorm_descriptor();
- }
- static inline const ::std::string& VarianceNorm_Name(VarianceNorm value) {
- return FillerParameter_VarianceNorm_Name(value);
- }
- static inline bool VarianceNorm_Parse(const ::std::string& name,
- VarianceNorm* value) {
- return FillerParameter_VarianceNorm_Parse(name, value);
- }
-
- // accessors -------------------------------------------------------
-
- // optional string type = 1 [default = "constant"];
- bool has_type() const;
- void clear_type();
- static const int kTypeFieldNumber = 1;
- const ::std::string& type() const;
- void set_type(const ::std::string& value);
- void set_type(const char* value);
- void set_type(const char* value, size_t size);
- ::std::string* mutable_type();
- ::std::string* release_type();
- void set_allocated_type(::std::string* type);
-
- // optional float value = 2 [default = 0];
- bool has_value() const;
- void clear_value();
- static const int kValueFieldNumber = 2;
- float value() const;
- void set_value(float value);
-
- // optional float min = 3 [default = 0];
- bool has_min() const;
- void clear_min();
- static const int kMinFieldNumber = 3;
- float min() const;
- void set_min(float value);
-
- // optional float max = 4 [default = 1];
- bool has_max() const;
- void clear_max();
- static const int kMaxFieldNumber = 4;
- float max() const;
- void set_max(float value);
-
- // optional float mean = 5 [default = 0];
- bool has_mean() const;
- void clear_mean();
- static const int kMeanFieldNumber = 5;
- float mean() const;
- void set_mean(float value);
-
- // optional float std = 6 [default = 1];
- bool has_std() const;
- void clear_std();
- static const int kStdFieldNumber = 6;
- float std() const;
- void set_std(float value);
-
- // optional int32 sparse = 7 [default = -1];
- bool has_sparse() const;
- void clear_sparse();
- static const int kSparseFieldNumber = 7;
- ::google::protobuf::int32 sparse() const;
- void set_sparse(::google::protobuf::int32 value);
-
- // optional .caffe.FillerParameter.VarianceNorm variance_norm = 8 [default = FAN_IN];
- bool has_variance_norm() const;
- void clear_variance_norm();
- static const int kVarianceNormFieldNumber = 8;
- ::caffe::FillerParameter_VarianceNorm variance_norm() const;
- void set_variance_norm(::caffe::FillerParameter_VarianceNorm value);
-
- // @@protoc_insertion_point(class_scope:caffe.FillerParameter)
- private:
- inline void set_has_type();
- inline void clear_has_type();
- inline void set_has_value();
- inline void clear_has_value();
- inline void set_has_min();
- inline void clear_has_min();
- inline void set_has_max();
- inline void clear_has_max();
- inline void set_has_mean();
- inline void clear_has_mean();
- inline void set_has_std();
- inline void clear_has_std();
- inline void set_has_sparse();
- inline void clear_has_sparse();
- inline void set_has_variance_norm();
- inline void clear_has_variance_norm();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- static ::std::string* _default_type_;
- ::google::protobuf::internal::ArenaStringPtr type_;
- float value_;
- float min_;
- float mean_;
- int variance_norm_;
- ::google::protobuf::int32 sparse_;
- float max_;
- float std_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<FillerParameter> FillerParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class NetParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.NetParameter) */ {
- public:
- NetParameter();
- virtual ~NetParameter();
-
- NetParameter(const NetParameter& from);
-
- inline NetParameter& operator=(const NetParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const NetParameter& default_instance();
-
- static const NetParameter* internal_default_instance();
-
- void Swap(NetParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline NetParameter* New() const { return New(NULL); }
-
- NetParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const NetParameter& from);
- void MergeFrom(const NetParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(NetParameter* other);
- void UnsafeMergeFrom(const NetParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional string name = 1;
- bool has_name() const;
- void clear_name();
- static const int kNameFieldNumber = 1;
- const ::std::string& name() const;
- void set_name(const ::std::string& value);
- void set_name(const char* value);
- void set_name(const char* value, size_t size);
- ::std::string* mutable_name();
- ::std::string* release_name();
- void set_allocated_name(::std::string* name);
-
- // repeated string input = 3;
- int input_size() const;
- void clear_input();
- static const int kInputFieldNumber = 3;
- const ::std::string& input(int index) const;
- ::std::string* mutable_input(int index);
- void set_input(int index, const ::std::string& value);
- void set_input(int index, const char* value);
- void set_input(int index, const char* value, size_t size);
- ::std::string* add_input();
- void add_input(const ::std::string& value);
- void add_input(const char* value);
- void add_input(const char* value, size_t size);
- const ::google::protobuf::RepeatedPtrField< ::std::string>& input() const;
- ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_input();
-
- // repeated .caffe.BlobShape input_shape = 8;
- int input_shape_size() const;
- void clear_input_shape();
- static const int kInputShapeFieldNumber = 8;
- const ::caffe::BlobShape& input_shape(int index) const;
- ::caffe::BlobShape* mutable_input_shape(int index);
- ::caffe::BlobShape* add_input_shape();
- ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >*
- mutable_input_shape();
- const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >&
- input_shape() const;
-
- // repeated int32 input_dim = 4;
- int input_dim_size() const;
- void clear_input_dim();
- static const int kInputDimFieldNumber = 4;
- ::google::protobuf::int32 input_dim(int index) const;
- void set_input_dim(int index, ::google::protobuf::int32 value);
- void add_input_dim(::google::protobuf::int32 value);
- const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
- input_dim() const;
- ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
- mutable_input_dim();
-
- // optional bool force_backward = 5 [default = false];
- bool has_force_backward() const;
- void clear_force_backward();
- static const int kForceBackwardFieldNumber = 5;
- bool force_backward() const;
- void set_force_backward(bool value);
-
- // optional .caffe.NetState state = 6;
- bool has_state() const;
- void clear_state();
- static const int kStateFieldNumber = 6;
- const ::caffe::NetState& state() const;
- ::caffe::NetState* mutable_state();
- ::caffe::NetState* release_state();
- void set_allocated_state(::caffe::NetState* state);
-
- // optional bool debug_info = 7 [default = false];
- bool has_debug_info() const;
- void clear_debug_info();
- static const int kDebugInfoFieldNumber = 7;
- bool debug_info() const;
- void set_debug_info(bool value);
-
- // repeated .caffe.LayerParameter layer = 100;
- int layer_size() const;
- void clear_layer();
- static const int kLayerFieldNumber = 100;
- const ::caffe::LayerParameter& layer(int index) const;
- ::caffe::LayerParameter* mutable_layer(int index);
- ::caffe::LayerParameter* add_layer();
- ::google::protobuf::RepeatedPtrField< ::caffe::LayerParameter >*
- mutable_layer();
- const ::google::protobuf::RepeatedPtrField< ::caffe::LayerParameter >&
- layer() const;
-
- // repeated .caffe.V1LayerParameter layers = 2;
- int layers_size() const;
- void clear_layers();
- static const int kLayersFieldNumber = 2;
- const ::caffe::V1LayerParameter& layers(int index) const;
- ::caffe::V1LayerParameter* mutable_layers(int index);
- ::caffe::V1LayerParameter* add_layers();
- ::google::protobuf::RepeatedPtrField< ::caffe::V1LayerParameter >*
- mutable_layers();
- const ::google::protobuf::RepeatedPtrField< ::caffe::V1LayerParameter >&
- layers() const;
-
- // @@protoc_insertion_point(class_scope:caffe.NetParameter)
- private:
- inline void set_has_name();
- inline void clear_has_name();
- inline void set_has_force_backward();
- inline void clear_has_force_backward();
- inline void set_has_state();
- inline void clear_has_state();
- inline void set_has_debug_info();
- inline void clear_has_debug_info();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::RepeatedPtrField< ::std::string> input_;
- ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape > input_shape_;
- ::google::protobuf::RepeatedField< ::google::protobuf::int32 > input_dim_;
- ::google::protobuf::RepeatedPtrField< ::caffe::LayerParameter > layer_;
- ::google::protobuf::RepeatedPtrField< ::caffe::V1LayerParameter > layers_;
- ::google::protobuf::internal::ArenaStringPtr name_;
- ::caffe::NetState* state_;
- bool force_backward_;
- bool debug_info_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<NetParameter> NetParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class SolverParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.SolverParameter) */ {
- public:
- SolverParameter();
- virtual ~SolverParameter();
-
- SolverParameter(const SolverParameter& from);
-
- inline SolverParameter& operator=(const SolverParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const SolverParameter& default_instance();
-
- static const SolverParameter* internal_default_instance();
-
- void Swap(SolverParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline SolverParameter* New() const { return New(NULL); }
-
- SolverParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const SolverParameter& from);
- void MergeFrom(const SolverParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(SolverParameter* other);
- void UnsafeMergeFrom(const SolverParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- typedef SolverParameter_SolverMode SolverMode;
- static const SolverMode CPU =
- SolverParameter_SolverMode_CPU;
- static const SolverMode GPU =
- SolverParameter_SolverMode_GPU;
- static inline bool SolverMode_IsValid(int value) {
- return SolverParameter_SolverMode_IsValid(value);
- }
- static const SolverMode SolverMode_MIN =
- SolverParameter_SolverMode_SolverMode_MIN;
- static const SolverMode SolverMode_MAX =
- SolverParameter_SolverMode_SolverMode_MAX;
- static const int SolverMode_ARRAYSIZE =
- SolverParameter_SolverMode_SolverMode_ARRAYSIZE;
- static inline const ::google::protobuf::EnumDescriptor*
- SolverMode_descriptor() {
- return SolverParameter_SolverMode_descriptor();
- }
- static inline const ::std::string& SolverMode_Name(SolverMode value) {
- return SolverParameter_SolverMode_Name(value);
- }
- static inline bool SolverMode_Parse(const ::std::string& name,
- SolverMode* value) {
- return SolverParameter_SolverMode_Parse(name, value);
- }
-
- typedef SolverParameter_SolverType SolverType;
- static const SolverType SGD =
- SolverParameter_SolverType_SGD;
- static const SolverType NESTEROV =
- SolverParameter_SolverType_NESTEROV;
- static const SolverType ADAGRAD =
- SolverParameter_SolverType_ADAGRAD;
- static inline bool SolverType_IsValid(int value) {
- return SolverParameter_SolverType_IsValid(value);
- }
- static const SolverType SolverType_MIN =
- SolverParameter_SolverType_SolverType_MIN;
- static const SolverType SolverType_MAX =
- SolverParameter_SolverType_SolverType_MAX;
- static const int SolverType_ARRAYSIZE =
- SolverParameter_SolverType_SolverType_ARRAYSIZE;
- static inline const ::google::protobuf::EnumDescriptor*
- SolverType_descriptor() {
- return SolverParameter_SolverType_descriptor();
- }
- static inline const ::std::string& SolverType_Name(SolverType value) {
- return SolverParameter_SolverType_Name(value);
- }
- static inline bool SolverType_Parse(const ::std::string& name,
- SolverType* value) {
- return SolverParameter_SolverType_Parse(name, value);
- }
-
- // accessors -------------------------------------------------------
-
- // optional string net = 24;
- bool has_net() const;
- void clear_net();
- static const int kNetFieldNumber = 24;
- const ::std::string& net() const;
- void set_net(const ::std::string& value);
- void set_net(const char* value);
- void set_net(const char* value, size_t size);
- ::std::string* mutable_net();
- ::std::string* release_net();
- void set_allocated_net(::std::string* net);
-
- // optional .caffe.NetParameter net_param = 25;
- bool has_net_param() const;
- void clear_net_param();
- static const int kNetParamFieldNumber = 25;
- const ::caffe::NetParameter& net_param() const;
- ::caffe::NetParameter* mutable_net_param();
- ::caffe::NetParameter* release_net_param();
- void set_allocated_net_param(::caffe::NetParameter* net_param);
-
- // optional string train_net = 1;
- bool has_train_net() const;
- void clear_train_net();
- static const int kTrainNetFieldNumber = 1;
- const ::std::string& train_net() const;
- void set_train_net(const ::std::string& value);
- void set_train_net(const char* value);
- void set_train_net(const char* value, size_t size);
- ::std::string* mutable_train_net();
- ::std::string* release_train_net();
- void set_allocated_train_net(::std::string* train_net);
-
- // repeated string test_net = 2;
- int test_net_size() const;
- void clear_test_net();
- static const int kTestNetFieldNumber = 2;
- const ::std::string& test_net(int index) const;
- ::std::string* mutable_test_net(int index);
- void set_test_net(int index, const ::std::string& value);
- void set_test_net(int index, const char* value);
- void set_test_net(int index, const char* value, size_t size);
- ::std::string* add_test_net();
- void add_test_net(const ::std::string& value);
- void add_test_net(const char* value);
- void add_test_net(const char* value, size_t size);
- const ::google::protobuf::RepeatedPtrField< ::std::string>& test_net() const;
- ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_test_net();
-
- // optional .caffe.NetParameter train_net_param = 21;
- bool has_train_net_param() const;
- void clear_train_net_param();
- static const int kTrainNetParamFieldNumber = 21;
- const ::caffe::NetParameter& train_net_param() const;
- ::caffe::NetParameter* mutable_train_net_param();
- ::caffe::NetParameter* release_train_net_param();
- void set_allocated_train_net_param(::caffe::NetParameter* train_net_param);
-
- // repeated .caffe.NetParameter test_net_param = 22;
- int test_net_param_size() const;
- void clear_test_net_param();
- static const int kTestNetParamFieldNumber = 22;
- const ::caffe::NetParameter& test_net_param(int index) const;
- ::caffe::NetParameter* mutable_test_net_param(int index);
- ::caffe::NetParameter* add_test_net_param();
- ::google::protobuf::RepeatedPtrField< ::caffe::NetParameter >*
- mutable_test_net_param();
- const ::google::protobuf::RepeatedPtrField< ::caffe::NetParameter >&
- test_net_param() const;
-
- // optional .caffe.NetState train_state = 26;
- bool has_train_state() const;
- void clear_train_state();
- static const int kTrainStateFieldNumber = 26;
- const ::caffe::NetState& train_state() const;
- ::caffe::NetState* mutable_train_state();
- ::caffe::NetState* release_train_state();
- void set_allocated_train_state(::caffe::NetState* train_state);
-
- // repeated .caffe.NetState test_state = 27;
- int test_state_size() const;
- void clear_test_state();
- static const int kTestStateFieldNumber = 27;
- const ::caffe::NetState& test_state(int index) const;
- ::caffe::NetState* mutable_test_state(int index);
- ::caffe::NetState* add_test_state();
- ::google::protobuf::RepeatedPtrField< ::caffe::NetState >*
- mutable_test_state();
- const ::google::protobuf::RepeatedPtrField< ::caffe::NetState >&
- test_state() const;
-
- // repeated int32 test_iter = 3;
- int test_iter_size() const;
- void clear_test_iter();
- static const int kTestIterFieldNumber = 3;
- ::google::protobuf::int32 test_iter(int index) const;
- void set_test_iter(int index, ::google::protobuf::int32 value);
- void add_test_iter(::google::protobuf::int32 value);
- const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
- test_iter() const;
- ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
- mutable_test_iter();
-
- // optional int32 test_interval = 4 [default = 0];
- bool has_test_interval() const;
- void clear_test_interval();
- static const int kTestIntervalFieldNumber = 4;
- ::google::protobuf::int32 test_interval() const;
- void set_test_interval(::google::protobuf::int32 value);
-
- // optional bool test_compute_loss = 19 [default = false];
- bool has_test_compute_loss() const;
- void clear_test_compute_loss();
- static const int kTestComputeLossFieldNumber = 19;
- bool test_compute_loss() const;
- void set_test_compute_loss(bool value);
-
- // optional bool test_initialization = 32 [default = true];
- bool has_test_initialization() const;
- void clear_test_initialization();
- static const int kTestInitializationFieldNumber = 32;
- bool test_initialization() const;
- void set_test_initialization(bool value);
-
- // optional float base_lr = 5;
- bool has_base_lr() const;
- void clear_base_lr();
- static const int kBaseLrFieldNumber = 5;
- float base_lr() const;
- void set_base_lr(float value);
-
- // optional int32 display = 6;
- bool has_display() const;
- void clear_display();
- static const int kDisplayFieldNumber = 6;
- ::google::protobuf::int32 display() const;
- void set_display(::google::protobuf::int32 value);
-
- // optional int32 average_loss = 33 [default = 1];
- bool has_average_loss() const;
- void clear_average_loss();
- static const int kAverageLossFieldNumber = 33;
- ::google::protobuf::int32 average_loss() const;
- void set_average_loss(::google::protobuf::int32 value);
-
- // optional int32 max_iter = 7;
- bool has_max_iter() const;
- void clear_max_iter();
- static const int kMaxIterFieldNumber = 7;
- ::google::protobuf::int32 max_iter() const;
- void set_max_iter(::google::protobuf::int32 value);
-
- // optional int32 iter_size = 36 [default = 1];
- bool has_iter_size() const;
- void clear_iter_size();
- static const int kIterSizeFieldNumber = 36;
- ::google::protobuf::int32 iter_size() const;
- void set_iter_size(::google::protobuf::int32 value);
-
- // optional string lr_policy = 8;
- bool has_lr_policy() const;
- void clear_lr_policy();
- static const int kLrPolicyFieldNumber = 8;
- const ::std::string& lr_policy() const;
- void set_lr_policy(const ::std::string& value);
- void set_lr_policy(const char* value);
- void set_lr_policy(const char* value, size_t size);
- ::std::string* mutable_lr_policy();
- ::std::string* release_lr_policy();
- void set_allocated_lr_policy(::std::string* lr_policy);
-
- // optional float gamma = 9;
- bool has_gamma() const;
- void clear_gamma();
- static const int kGammaFieldNumber = 9;
- float gamma() const;
- void set_gamma(float value);
-
- // optional float power = 10;
- bool has_power() const;
- void clear_power();
- static const int kPowerFieldNumber = 10;
- float power() const;
- void set_power(float value);
-
- // optional float momentum = 11;
- bool has_momentum() const;
- void clear_momentum();
- static const int kMomentumFieldNumber = 11;
- float momentum() const;
- void set_momentum(float value);
-
- // optional float weight_decay = 12;
- bool has_weight_decay() const;
- void clear_weight_decay();
- static const int kWeightDecayFieldNumber = 12;
- float weight_decay() const;
- void set_weight_decay(float value);
-
- // optional string regularization_type = 29 [default = "L2"];
- bool has_regularization_type() const;
- void clear_regularization_type();
- static const int kRegularizationTypeFieldNumber = 29;
- const ::std::string& regularization_type() const;
- void set_regularization_type(const ::std::string& value);
- void set_regularization_type(const char* value);
- void set_regularization_type(const char* value, size_t size);
- ::std::string* mutable_regularization_type();
- ::std::string* release_regularization_type();
- void set_allocated_regularization_type(::std::string* regularization_type);
-
- // optional int32 stepsize = 13;
- bool has_stepsize() const;
- void clear_stepsize();
- static const int kStepsizeFieldNumber = 13;
- ::google::protobuf::int32 stepsize() const;
- void set_stepsize(::google::protobuf::int32 value);
-
- // repeated int32 stepvalue = 34;
- int stepvalue_size() const;
- void clear_stepvalue();
- static const int kStepvalueFieldNumber = 34;
- ::google::protobuf::int32 stepvalue(int index) const;
- void set_stepvalue(int index, ::google::protobuf::int32 value);
- void add_stepvalue(::google::protobuf::int32 value);
- const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
- stepvalue() const;
- ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
- mutable_stepvalue();
-
- // optional float clip_gradients = 35 [default = -1];
- bool has_clip_gradients() const;
- void clear_clip_gradients();
- static const int kClipGradientsFieldNumber = 35;
- float clip_gradients() const;
- void set_clip_gradients(float value);
-
- // optional int32 snapshot = 14 [default = 0];
- bool has_snapshot() const;
- void clear_snapshot();
- static const int kSnapshotFieldNumber = 14;
- ::google::protobuf::int32 snapshot() const;
- void set_snapshot(::google::protobuf::int32 value);
-
- // optional string snapshot_prefix = 15;
- bool has_snapshot_prefix() const;
- void clear_snapshot_prefix();
- static const int kSnapshotPrefixFieldNumber = 15;
- const ::std::string& snapshot_prefix() const;
- void set_snapshot_prefix(const ::std::string& value);
- void set_snapshot_prefix(const char* value);
- void set_snapshot_prefix(const char* value, size_t size);
- ::std::string* mutable_snapshot_prefix();
- ::std::string* release_snapshot_prefix();
- void set_allocated_snapshot_prefix(::std::string* snapshot_prefix);
-
- // optional bool snapshot_diff = 16 [default = false];
- bool has_snapshot_diff() const;
- void clear_snapshot_diff();
- static const int kSnapshotDiffFieldNumber = 16;
- bool snapshot_diff() const;
- void set_snapshot_diff(bool value);
-
- // optional .caffe.SolverParameter.SolverMode solver_mode = 17 [default = GPU];
- bool has_solver_mode() const;
- void clear_solver_mode();
- static const int kSolverModeFieldNumber = 17;
- ::caffe::SolverParameter_SolverMode solver_mode() const;
- void set_solver_mode(::caffe::SolverParameter_SolverMode value);
-
- // optional int32 device_id = 18 [default = 0];
- bool has_device_id() const;
- void clear_device_id();
- static const int kDeviceIdFieldNumber = 18;
- ::google::protobuf::int32 device_id() const;
- void set_device_id(::google::protobuf::int32 value);
-
- // optional int64 random_seed = 20 [default = -1];
- bool has_random_seed() const;
- void clear_random_seed();
- static const int kRandomSeedFieldNumber = 20;
- ::google::protobuf::int64 random_seed() const;
- void set_random_seed(::google::protobuf::int64 value);
-
- // optional .caffe.SolverParameter.SolverType solver_type = 30 [default = SGD];
- bool has_solver_type() const;
- void clear_solver_type();
- static const int kSolverTypeFieldNumber = 30;
- ::caffe::SolverParameter_SolverType solver_type() const;
- void set_solver_type(::caffe::SolverParameter_SolverType value);
-
- // optional float delta = 31 [default = 1e-08];
- bool has_delta() const;
- void clear_delta();
- static const int kDeltaFieldNumber = 31;
- float delta() const;
- void set_delta(float value);
-
- // optional bool debug_info = 23 [default = false];
- bool has_debug_info() const;
- void clear_debug_info();
- static const int kDebugInfoFieldNumber = 23;
- bool debug_info() const;
- void set_debug_info(bool value);
-
- // optional bool snapshot_after_train = 28 [default = true];
- bool has_snapshot_after_train() const;
- void clear_snapshot_after_train();
- static const int kSnapshotAfterTrainFieldNumber = 28;
- bool snapshot_after_train() const;
- void set_snapshot_after_train(bool value);
-
- // @@protoc_insertion_point(class_scope:caffe.SolverParameter)
- private:
- inline void set_has_net();
- inline void clear_has_net();
- inline void set_has_net_param();
- inline void clear_has_net_param();
- inline void set_has_train_net();
- inline void clear_has_train_net();
- inline void set_has_train_net_param();
- inline void clear_has_train_net_param();
- inline void set_has_train_state();
- inline void clear_has_train_state();
- inline void set_has_test_interval();
- inline void clear_has_test_interval();
- inline void set_has_test_compute_loss();
- inline void clear_has_test_compute_loss();
- inline void set_has_test_initialization();
- inline void clear_has_test_initialization();
- inline void set_has_base_lr();
- inline void clear_has_base_lr();
- inline void set_has_display();
- inline void clear_has_display();
- inline void set_has_average_loss();
- inline void clear_has_average_loss();
- inline void set_has_max_iter();
- inline void clear_has_max_iter();
- inline void set_has_iter_size();
- inline void clear_has_iter_size();
- inline void set_has_lr_policy();
- inline void clear_has_lr_policy();
- inline void set_has_gamma();
- inline void clear_has_gamma();
- inline void set_has_power();
- inline void clear_has_power();
- inline void set_has_momentum();
- inline void clear_has_momentum();
- inline void set_has_weight_decay();
- inline void clear_has_weight_decay();
- inline void set_has_regularization_type();
- inline void clear_has_regularization_type();
- inline void set_has_stepsize();
- inline void clear_has_stepsize();
- inline void set_has_clip_gradients();
- inline void clear_has_clip_gradients();
- inline void set_has_snapshot();
- inline void clear_has_snapshot();
- inline void set_has_snapshot_prefix();
- inline void clear_has_snapshot_prefix();
- inline void set_has_snapshot_diff();
- inline void clear_has_snapshot_diff();
- inline void set_has_solver_mode();
- inline void clear_has_solver_mode();
- inline void set_has_device_id();
- inline void clear_has_device_id();
- inline void set_has_random_seed();
- inline void clear_has_random_seed();
- inline void set_has_solver_type();
- inline void clear_has_solver_type();
- inline void set_has_delta();
- inline void clear_has_delta();
- inline void set_has_debug_info();
- inline void clear_has_debug_info();
- inline void set_has_snapshot_after_train();
- inline void clear_has_snapshot_after_train();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<2> _has_bits_;
- ::google::protobuf::RepeatedPtrField< ::std::string> test_net_;
- ::google::protobuf::RepeatedPtrField< ::caffe::NetParameter > test_net_param_;
- ::google::protobuf::RepeatedPtrField< ::caffe::NetState > test_state_;
- ::google::protobuf::RepeatedField< ::google::protobuf::int32 > test_iter_;
- ::google::protobuf::RepeatedField< ::google::protobuf::int32 > stepvalue_;
- ::google::protobuf::internal::ArenaStringPtr net_;
- ::google::protobuf::internal::ArenaStringPtr train_net_;
- ::google::protobuf::internal::ArenaStringPtr lr_policy_;
- static ::std::string* _default_regularization_type_;
- ::google::protobuf::internal::ArenaStringPtr regularization_type_;
- ::google::protobuf::internal::ArenaStringPtr snapshot_prefix_;
- ::caffe::NetParameter* net_param_;
- ::caffe::NetParameter* train_net_param_;
- ::caffe::NetState* train_state_;
- ::google::protobuf::int32 test_interval_;
- float base_lr_;
- ::google::protobuf::int32 display_;
- ::google::protobuf::int32 max_iter_;
- float gamma_;
- float power_;
- float momentum_;
- float weight_decay_;
- ::google::protobuf::int32 stepsize_;
- bool test_compute_loss_;
- bool snapshot_diff_;
- bool debug_info_;
- ::google::protobuf::int32 snapshot_;
- ::google::protobuf::int32 device_id_;
- int solver_type_;
- ::google::protobuf::int32 average_loss_;
- ::google::protobuf::int32 iter_size_;
- bool test_initialization_;
- bool snapshot_after_train_;
- float clip_gradients_;
- ::google::protobuf::int64 random_seed_;
- int solver_mode_;
- float delta_;
- mutable int _cached_size_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<SolverParameter> SolverParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class SolverState : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.SolverState) */ {
- public:
- SolverState();
- virtual ~SolverState();
-
- SolverState(const SolverState& from);
-
- inline SolverState& operator=(const SolverState& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const SolverState& default_instance();
-
- static const SolverState* internal_default_instance();
-
- void Swap(SolverState* other);
-
- // implements Message ----------------------------------------------
-
- inline SolverState* New() const { return New(NULL); }
-
- SolverState* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const SolverState& from);
- void MergeFrom(const SolverState& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(SolverState* other);
- void UnsafeMergeFrom(const SolverState& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional int32 iter = 1;
- bool has_iter() const;
- void clear_iter();
- static const int kIterFieldNumber = 1;
- ::google::protobuf::int32 iter() const;
- void set_iter(::google::protobuf::int32 value);
-
- // optional string learned_net = 2;
- bool has_learned_net() const;
- void clear_learned_net();
- static const int kLearnedNetFieldNumber = 2;
- const ::std::string& learned_net() const;
- void set_learned_net(const ::std::string& value);
- void set_learned_net(const char* value);
- void set_learned_net(const char* value, size_t size);
- ::std::string* mutable_learned_net();
- ::std::string* release_learned_net();
- void set_allocated_learned_net(::std::string* learned_net);
-
- // repeated .caffe.BlobProto history = 3;
- int history_size() const;
- void clear_history();
- static const int kHistoryFieldNumber = 3;
- const ::caffe::BlobProto& history(int index) const;
- ::caffe::BlobProto* mutable_history(int index);
- ::caffe::BlobProto* add_history();
- ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
- mutable_history();
- const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
- history() const;
-
- // optional int32 current_step = 4 [default = 0];
- bool has_current_step() const;
- void clear_current_step();
- static const int kCurrentStepFieldNumber = 4;
- ::google::protobuf::int32 current_step() const;
- void set_current_step(::google::protobuf::int32 value);
-
- // @@protoc_insertion_point(class_scope:caffe.SolverState)
- private:
- inline void set_has_iter();
- inline void clear_has_iter();
- inline void set_has_learned_net();
- inline void clear_has_learned_net();
- inline void set_has_current_step();
- inline void clear_has_current_step();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto > history_;
- ::google::protobuf::internal::ArenaStringPtr learned_net_;
- ::google::protobuf::int32 iter_;
- ::google::protobuf::int32 current_step_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<SolverState> SolverState_default_instance_;
-
-// -------------------------------------------------------------------
-
-class NetState : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.NetState) */ {
- public:
- NetState();
- virtual ~NetState();
-
- NetState(const NetState& from);
-
- inline NetState& operator=(const NetState& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const NetState& default_instance();
-
- static const NetState* internal_default_instance();
-
- void Swap(NetState* other);
-
- // implements Message ----------------------------------------------
-
- inline NetState* New() const { return New(NULL); }
-
- NetState* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const NetState& from);
- void MergeFrom(const NetState& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(NetState* other);
- void UnsafeMergeFrom(const NetState& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional .caffe.Phase phase = 1 [default = TEST];
- bool has_phase() const;
- void clear_phase();
- static const int kPhaseFieldNumber = 1;
- ::caffe::Phase phase() const;
- void set_phase(::caffe::Phase value);
-
- // optional int32 level = 2 [default = 0];
- bool has_level() const;
- void clear_level();
- static const int kLevelFieldNumber = 2;
- ::google::protobuf::int32 level() const;
- void set_level(::google::protobuf::int32 value);
-
- // repeated string stage = 3;
- int stage_size() const;
- void clear_stage();
- static const int kStageFieldNumber = 3;
- const ::std::string& stage(int index) const;
- ::std::string* mutable_stage(int index);
- void set_stage(int index, const ::std::string& value);
- void set_stage(int index, const char* value);
- void set_stage(int index, const char* value, size_t size);
- ::std::string* add_stage();
- void add_stage(const ::std::string& value);
- void add_stage(const char* value);
- void add_stage(const char* value, size_t size);
- const ::google::protobuf::RepeatedPtrField< ::std::string>& stage() const;
- ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_stage();
-
- // @@protoc_insertion_point(class_scope:caffe.NetState)
- private:
- inline void set_has_phase();
- inline void clear_has_phase();
- inline void set_has_level();
- inline void clear_has_level();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::RepeatedPtrField< ::std::string> stage_;
- ::google::protobuf::int32 level_;
- int phase_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<NetState> NetState_default_instance_;
-
-// -------------------------------------------------------------------
-
-class NetStateRule : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.NetStateRule) */ {
- public:
- NetStateRule();
- virtual ~NetStateRule();
-
- NetStateRule(const NetStateRule& from);
-
- inline NetStateRule& operator=(const NetStateRule& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const NetStateRule& default_instance();
-
- static const NetStateRule* internal_default_instance();
-
- void Swap(NetStateRule* other);
-
- // implements Message ----------------------------------------------
-
- inline NetStateRule* New() const { return New(NULL); }
-
- NetStateRule* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const NetStateRule& from);
- void MergeFrom(const NetStateRule& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(NetStateRule* other);
- void UnsafeMergeFrom(const NetStateRule& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional .caffe.Phase phase = 1;
- bool has_phase() const;
- void clear_phase();
- static const int kPhaseFieldNumber = 1;
- ::caffe::Phase phase() const;
- void set_phase(::caffe::Phase value);
-
- // optional int32 min_level = 2;
- bool has_min_level() const;
- void clear_min_level();
- static const int kMinLevelFieldNumber = 2;
- ::google::protobuf::int32 min_level() const;
- void set_min_level(::google::protobuf::int32 value);
-
- // optional int32 max_level = 3;
- bool has_max_level() const;
- void clear_max_level();
- static const int kMaxLevelFieldNumber = 3;
- ::google::protobuf::int32 max_level() const;
- void set_max_level(::google::protobuf::int32 value);
-
- // repeated string stage = 4;
- int stage_size() const;
- void clear_stage();
- static const int kStageFieldNumber = 4;
- const ::std::string& stage(int index) const;
- ::std::string* mutable_stage(int index);
- void set_stage(int index, const ::std::string& value);
- void set_stage(int index, const char* value);
- void set_stage(int index, const char* value, size_t size);
- ::std::string* add_stage();
- void add_stage(const ::std::string& value);
- void add_stage(const char* value);
- void add_stage(const char* value, size_t size);
- const ::google::protobuf::RepeatedPtrField< ::std::string>& stage() const;
- ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_stage();
-
- // repeated string not_stage = 5;
- int not_stage_size() const;
- void clear_not_stage();
- static const int kNotStageFieldNumber = 5;
- const ::std::string& not_stage(int index) const;
- ::std::string* mutable_not_stage(int index);
- void set_not_stage(int index, const ::std::string& value);
- void set_not_stage(int index, const char* value);
- void set_not_stage(int index, const char* value, size_t size);
- ::std::string* add_not_stage();
- void add_not_stage(const ::std::string& value);
- void add_not_stage(const char* value);
- void add_not_stage(const char* value, size_t size);
- const ::google::protobuf::RepeatedPtrField< ::std::string>& not_stage() const;
- ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_not_stage();
-
- // @@protoc_insertion_point(class_scope:caffe.NetStateRule)
- private:
- inline void set_has_phase();
- inline void clear_has_phase();
- inline void set_has_min_level();
- inline void clear_has_min_level();
- inline void set_has_max_level();
- inline void clear_has_max_level();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::RepeatedPtrField< ::std::string> stage_;
- ::google::protobuf::RepeatedPtrField< ::std::string> not_stage_;
- int phase_;
- ::google::protobuf::int32 min_level_;
- ::google::protobuf::int32 max_level_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<NetStateRule> NetStateRule_default_instance_;
-
-// -------------------------------------------------------------------
-
-class ParamSpec : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ParamSpec) */ {
- public:
- ParamSpec();
- virtual ~ParamSpec();
-
- ParamSpec(const ParamSpec& from);
-
- inline ParamSpec& operator=(const ParamSpec& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const ParamSpec& default_instance();
-
- static const ParamSpec* internal_default_instance();
-
- void Swap(ParamSpec* other);
-
- // implements Message ----------------------------------------------
-
- inline ParamSpec* New() const { return New(NULL); }
-
- ParamSpec* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const ParamSpec& from);
- void MergeFrom(const ParamSpec& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(ParamSpec* other);
- void UnsafeMergeFrom(const ParamSpec& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- typedef ParamSpec_DimCheckMode DimCheckMode;
- static const DimCheckMode STRICT =
- ParamSpec_DimCheckMode_STRICT;
- static const DimCheckMode PERMISSIVE =
- ParamSpec_DimCheckMode_PERMISSIVE;
- static inline bool DimCheckMode_IsValid(int value) {
- return ParamSpec_DimCheckMode_IsValid(value);
- }
- static const DimCheckMode DimCheckMode_MIN =
- ParamSpec_DimCheckMode_DimCheckMode_MIN;
- static const DimCheckMode DimCheckMode_MAX =
- ParamSpec_DimCheckMode_DimCheckMode_MAX;
- static const int DimCheckMode_ARRAYSIZE =
- ParamSpec_DimCheckMode_DimCheckMode_ARRAYSIZE;
- static inline const ::google::protobuf::EnumDescriptor*
- DimCheckMode_descriptor() {
- return ParamSpec_DimCheckMode_descriptor();
- }
- static inline const ::std::string& DimCheckMode_Name(DimCheckMode value) {
- return ParamSpec_DimCheckMode_Name(value);
- }
- static inline bool DimCheckMode_Parse(const ::std::string& name,
- DimCheckMode* value) {
- return ParamSpec_DimCheckMode_Parse(name, value);
- }
-
- // accessors -------------------------------------------------------
-
- // optional string name = 1;
- bool has_name() const;
- void clear_name();
- static const int kNameFieldNumber = 1;
- const ::std::string& name() const;
- void set_name(const ::std::string& value);
- void set_name(const char* value);
- void set_name(const char* value, size_t size);
- ::std::string* mutable_name();
- ::std::string* release_name();
- void set_allocated_name(::std::string* name);
-
- // optional .caffe.ParamSpec.DimCheckMode share_mode = 2;
- bool has_share_mode() const;
- void clear_share_mode();
- static const int kShareModeFieldNumber = 2;
- ::caffe::ParamSpec_DimCheckMode share_mode() const;
- void set_share_mode(::caffe::ParamSpec_DimCheckMode value);
-
- // optional float lr_mult = 3 [default = 1];
- bool has_lr_mult() const;
- void clear_lr_mult();
- static const int kLrMultFieldNumber = 3;
- float lr_mult() const;
- void set_lr_mult(float value);
-
- // optional float decay_mult = 4 [default = 1];
- bool has_decay_mult() const;
- void clear_decay_mult();
- static const int kDecayMultFieldNumber = 4;
- float decay_mult() const;
- void set_decay_mult(float value);
-
- // @@protoc_insertion_point(class_scope:caffe.ParamSpec)
- private:
- inline void set_has_name();
- inline void clear_has_name();
- inline void set_has_share_mode();
- inline void clear_has_share_mode();
- inline void set_has_lr_mult();
- inline void clear_has_lr_mult();
- inline void set_has_decay_mult();
- inline void clear_has_decay_mult();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::internal::ArenaStringPtr name_;
- int share_mode_;
- float lr_mult_;
- float decay_mult_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<ParamSpec> ParamSpec_default_instance_;
-
-// -------------------------------------------------------------------
-
-class LayerParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.LayerParameter) */ {
- public:
- LayerParameter();
- virtual ~LayerParameter();
-
- LayerParameter(const LayerParameter& from);
-
- inline LayerParameter& operator=(const LayerParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const LayerParameter& default_instance();
-
- static const LayerParameter* internal_default_instance();
-
- void Swap(LayerParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline LayerParameter* New() const { return New(NULL); }
-
- LayerParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const LayerParameter& from);
- void MergeFrom(const LayerParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(LayerParameter* other);
- void UnsafeMergeFrom(const LayerParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional string name = 1;
- bool has_name() const;
- void clear_name();
- static const int kNameFieldNumber = 1;
- const ::std::string& name() const;
- void set_name(const ::std::string& value);
- void set_name(const char* value);
- void set_name(const char* value, size_t size);
- ::std::string* mutable_name();
- ::std::string* release_name();
- void set_allocated_name(::std::string* name);
-
- // optional string type = 2;
- bool has_type() const;
- void clear_type();
- static const int kTypeFieldNumber = 2;
- const ::std::string& type() const;
- void set_type(const ::std::string& value);
- void set_type(const char* value);
- void set_type(const char* value, size_t size);
- ::std::string* mutable_type();
- ::std::string* release_type();
- void set_allocated_type(::std::string* type);
-
- // repeated string bottom = 3;
- int bottom_size() const;
- void clear_bottom();
- static const int kBottomFieldNumber = 3;
- const ::std::string& bottom(int index) const;
- ::std::string* mutable_bottom(int index);
- void set_bottom(int index, const ::std::string& value);
- void set_bottom(int index, const char* value);
- void set_bottom(int index, const char* value, size_t size);
- ::std::string* add_bottom();
- void add_bottom(const ::std::string& value);
- void add_bottom(const char* value);
- void add_bottom(const char* value, size_t size);
- const ::google::protobuf::RepeatedPtrField< ::std::string>& bottom() const;
- ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_bottom();
-
- // repeated string top = 4;
- int top_size() const;
- void clear_top();
- static const int kTopFieldNumber = 4;
- const ::std::string& top(int index) const;
- ::std::string* mutable_top(int index);
- void set_top(int index, const ::std::string& value);
- void set_top(int index, const char* value);
- void set_top(int index, const char* value, size_t size);
- ::std::string* add_top();
- void add_top(const ::std::string& value);
- void add_top(const char* value);
- void add_top(const char* value, size_t size);
- const ::google::protobuf::RepeatedPtrField< ::std::string>& top() const;
- ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_top();
-
- // optional .caffe.Phase phase = 10;
- bool has_phase() const;
- void clear_phase();
- static const int kPhaseFieldNumber = 10;
- ::caffe::Phase phase() const;
- void set_phase(::caffe::Phase value);
-
- // repeated float loss_weight = 5;
- int loss_weight_size() const;
- void clear_loss_weight();
- static const int kLossWeightFieldNumber = 5;
- float loss_weight(int index) const;
- void set_loss_weight(int index, float value);
- void add_loss_weight(float value);
- const ::google::protobuf::RepeatedField< float >&
- loss_weight() const;
- ::google::protobuf::RepeatedField< float >*
- mutable_loss_weight();
-
- // repeated .caffe.ParamSpec param = 6;
- int param_size() const;
- void clear_param();
- static const int kParamFieldNumber = 6;
- const ::caffe::ParamSpec& param(int index) const;
- ::caffe::ParamSpec* mutable_param(int index);
- ::caffe::ParamSpec* add_param();
- ::google::protobuf::RepeatedPtrField< ::caffe::ParamSpec >*
- mutable_param();
- const ::google::protobuf::RepeatedPtrField< ::caffe::ParamSpec >&
- param() const;
-
- // repeated .caffe.BlobProto blobs = 7;
- int blobs_size() const;
- void clear_blobs();
- static const int kBlobsFieldNumber = 7;
- const ::caffe::BlobProto& blobs(int index) const;
- ::caffe::BlobProto* mutable_blobs(int index);
- ::caffe::BlobProto* add_blobs();
- ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
- mutable_blobs();
- const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
- blobs() const;
-
- // repeated bool propagate_down = 11;
- int propagate_down_size() const;
- void clear_propagate_down();
- static const int kPropagateDownFieldNumber = 11;
- bool propagate_down(int index) const;
- void set_propagate_down(int index, bool value);
- void add_propagate_down(bool value);
- const ::google::protobuf::RepeatedField< bool >&
- propagate_down() const;
- ::google::protobuf::RepeatedField< bool >*
- mutable_propagate_down();
-
- // repeated .caffe.NetStateRule include = 8;
- int include_size() const;
- void clear_include();
- static const int kIncludeFieldNumber = 8;
- const ::caffe::NetStateRule& include(int index) const;
- ::caffe::NetStateRule* mutable_include(int index);
- ::caffe::NetStateRule* add_include();
- ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >*
- mutable_include();
- const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >&
- include() const;
-
- // repeated .caffe.NetStateRule exclude = 9;
- int exclude_size() const;
- void clear_exclude();
- static const int kExcludeFieldNumber = 9;
- const ::caffe::NetStateRule& exclude(int index) const;
- ::caffe::NetStateRule* mutable_exclude(int index);
- ::caffe::NetStateRule* add_exclude();
- ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >*
- mutable_exclude();
- const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >&
- exclude() const;
-
- // optional .caffe.TransformationParameter transform_param = 100;
- bool has_transform_param() const;
- void clear_transform_param();
- static const int kTransformParamFieldNumber = 100;
- const ::caffe::TransformationParameter& transform_param() const;
- ::caffe::TransformationParameter* mutable_transform_param();
- ::caffe::TransformationParameter* release_transform_param();
- void set_allocated_transform_param(::caffe::TransformationParameter* transform_param);
-
- // optional .caffe.LossParameter loss_param = 101;
- bool has_loss_param() const;
- void clear_loss_param();
- static const int kLossParamFieldNumber = 101;
- const ::caffe::LossParameter& loss_param() const;
- ::caffe::LossParameter* mutable_loss_param();
- ::caffe::LossParameter* release_loss_param();
- void set_allocated_loss_param(::caffe::LossParameter* loss_param);
-
- // optional .caffe.AccuracyParameter accuracy_param = 102;
- bool has_accuracy_param() const;
- void clear_accuracy_param();
- static const int kAccuracyParamFieldNumber = 102;
- const ::caffe::AccuracyParameter& accuracy_param() const;
- ::caffe::AccuracyParameter* mutable_accuracy_param();
- ::caffe::AccuracyParameter* release_accuracy_param();
- void set_allocated_accuracy_param(::caffe::AccuracyParameter* accuracy_param);
-
- // optional .caffe.ArgMaxParameter argmax_param = 103;
- bool has_argmax_param() const;
- void clear_argmax_param();
- static const int kArgmaxParamFieldNumber = 103;
- const ::caffe::ArgMaxParameter& argmax_param() const;
- ::caffe::ArgMaxParameter* mutable_argmax_param();
- ::caffe::ArgMaxParameter* release_argmax_param();
- void set_allocated_argmax_param(::caffe::ArgMaxParameter* argmax_param);
-
- // optional .caffe.ConcatParameter concat_param = 104;
- bool has_concat_param() const;
- void clear_concat_param();
- static const int kConcatParamFieldNumber = 104;
- const ::caffe::ConcatParameter& concat_param() const;
- ::caffe::ConcatParameter* mutable_concat_param();
- ::caffe::ConcatParameter* release_concat_param();
- void set_allocated_concat_param(::caffe::ConcatParameter* concat_param);
-
- // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 105;
- bool has_contrastive_loss_param() const;
- void clear_contrastive_loss_param();
- static const int kContrastiveLossParamFieldNumber = 105;
- const ::caffe::ContrastiveLossParameter& contrastive_loss_param() const;
- ::caffe::ContrastiveLossParameter* mutable_contrastive_loss_param();
- ::caffe::ContrastiveLossParameter* release_contrastive_loss_param();
- void set_allocated_contrastive_loss_param(::caffe::ContrastiveLossParameter* contrastive_loss_param);
-
- // optional .caffe.ConvolutionParameter convolution_param = 106;
- bool has_convolution_param() const;
- void clear_convolution_param();
- static const int kConvolutionParamFieldNumber = 106;
- const ::caffe::ConvolutionParameter& convolution_param() const;
- ::caffe::ConvolutionParameter* mutable_convolution_param();
- ::caffe::ConvolutionParameter* release_convolution_param();
- void set_allocated_convolution_param(::caffe::ConvolutionParameter* convolution_param);
-
- // optional .caffe.CropParameter crop_param = 137;
- bool has_crop_param() const;
- void clear_crop_param();
- static const int kCropParamFieldNumber = 137;
- const ::caffe::CropParameter& crop_param() const;
- ::caffe::CropParameter* mutable_crop_param();
- ::caffe::CropParameter* release_crop_param();
- void set_allocated_crop_param(::caffe::CropParameter* crop_param);
-
- // optional .caffe.DataParameter data_param = 107;
- bool has_data_param() const;
- void clear_data_param();
- static const int kDataParamFieldNumber = 107;
- const ::caffe::DataParameter& data_param() const;
- ::caffe::DataParameter* mutable_data_param();
- ::caffe::DataParameter* release_data_param();
- void set_allocated_data_param(::caffe::DataParameter* data_param);
-
- // optional .caffe.DetectionOutputParameter detection_output_param = 141;
- bool has_detection_output_param() const;
- void clear_detection_output_param();
- static const int kDetectionOutputParamFieldNumber = 141;
- const ::caffe::DetectionOutputParameter& detection_output_param() const;
- ::caffe::DetectionOutputParameter* mutable_detection_output_param();
- ::caffe::DetectionOutputParameter* release_detection_output_param();
- void set_allocated_detection_output_param(::caffe::DetectionOutputParameter* detection_output_param);
-
- // optional .caffe.DropoutParameter dropout_param = 108;
- bool has_dropout_param() const;
- void clear_dropout_param();
- static const int kDropoutParamFieldNumber = 108;
- const ::caffe::DropoutParameter& dropout_param() const;
- ::caffe::DropoutParameter* mutable_dropout_param();
- ::caffe::DropoutParameter* release_dropout_param();
- void set_allocated_dropout_param(::caffe::DropoutParameter* dropout_param);
-
- // optional .caffe.DummyDataParameter dummy_data_param = 109;
- bool has_dummy_data_param() const;
- void clear_dummy_data_param();
- static const int kDummyDataParamFieldNumber = 109;
- const ::caffe::DummyDataParameter& dummy_data_param() const;
- ::caffe::DummyDataParameter* mutable_dummy_data_param();
- ::caffe::DummyDataParameter* release_dummy_data_param();
- void set_allocated_dummy_data_param(::caffe::DummyDataParameter* dummy_data_param);
-
- // optional .caffe.EltwiseParameter eltwise_param = 110;
- bool has_eltwise_param() const;
- void clear_eltwise_param();
- static const int kEltwiseParamFieldNumber = 110;
- const ::caffe::EltwiseParameter& eltwise_param() const;
- ::caffe::EltwiseParameter* mutable_eltwise_param();
- ::caffe::EltwiseParameter* release_eltwise_param();
- void set_allocated_eltwise_param(::caffe::EltwiseParameter* eltwise_param);
-
- // optional .caffe.ExpParameter exp_param = 111;
- bool has_exp_param() const;
- void clear_exp_param();
- static const int kExpParamFieldNumber = 111;
- const ::caffe::ExpParameter& exp_param() const;
- ::caffe::ExpParameter* mutable_exp_param();
- ::caffe::ExpParameter* release_exp_param();
- void set_allocated_exp_param(::caffe::ExpParameter* exp_param);
-
- // optional .caffe.FlattenParameter flatten_param = 135;
- bool has_flatten_param() const;
- void clear_flatten_param();
- static const int kFlattenParamFieldNumber = 135;
- const ::caffe::FlattenParameter& flatten_param() const;
- ::caffe::FlattenParameter* mutable_flatten_param();
- ::caffe::FlattenParameter* release_flatten_param();
- void set_allocated_flatten_param(::caffe::FlattenParameter* flatten_param);
-
- // optional .caffe.HDF5DataParameter hdf5_data_param = 112;
- bool has_hdf5_data_param() const;
- void clear_hdf5_data_param();
- static const int kHdf5DataParamFieldNumber = 112;
- const ::caffe::HDF5DataParameter& hdf5_data_param() const;
- ::caffe::HDF5DataParameter* mutable_hdf5_data_param();
- ::caffe::HDF5DataParameter* release_hdf5_data_param();
- void set_allocated_hdf5_data_param(::caffe::HDF5DataParameter* hdf5_data_param);
-
- // optional .caffe.HDF5OutputParameter hdf5_output_param = 113;
- bool has_hdf5_output_param() const;
- void clear_hdf5_output_param();
- static const int kHdf5OutputParamFieldNumber = 113;
- const ::caffe::HDF5OutputParameter& hdf5_output_param() const;
- ::caffe::HDF5OutputParameter* mutable_hdf5_output_param();
- ::caffe::HDF5OutputParameter* release_hdf5_output_param();
- void set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param);
-
- // optional .caffe.HingeLossParameter hinge_loss_param = 114;
- bool has_hinge_loss_param() const;
- void clear_hinge_loss_param();
- static const int kHingeLossParamFieldNumber = 114;
- const ::caffe::HingeLossParameter& hinge_loss_param() const;
- ::caffe::HingeLossParameter* mutable_hinge_loss_param();
- ::caffe::HingeLossParameter* release_hinge_loss_param();
- void set_allocated_hinge_loss_param(::caffe::HingeLossParameter* hinge_loss_param);
-
- // optional .caffe.ImageDataParameter image_data_param = 115;
- bool has_image_data_param() const;
- void clear_image_data_param();
- static const int kImageDataParamFieldNumber = 115;
- const ::caffe::ImageDataParameter& image_data_param() const;
- ::caffe::ImageDataParameter* mutable_image_data_param();
- ::caffe::ImageDataParameter* release_image_data_param();
- void set_allocated_image_data_param(::caffe::ImageDataParameter* image_data_param);
-
- // optional .caffe.InfogainLossParameter infogain_loss_param = 116;
- bool has_infogain_loss_param() const;
- void clear_infogain_loss_param();
- static const int kInfogainLossParamFieldNumber = 116;
- const ::caffe::InfogainLossParameter& infogain_loss_param() const;
- ::caffe::InfogainLossParameter* mutable_infogain_loss_param();
- ::caffe::InfogainLossParameter* release_infogain_loss_param();
- void set_allocated_infogain_loss_param(::caffe::InfogainLossParameter* infogain_loss_param);
-
- // optional .caffe.InnerProductParameter inner_product_param = 117;
- bool has_inner_product_param() const;
- void clear_inner_product_param();
- static const int kInnerProductParamFieldNumber = 117;
- const ::caffe::InnerProductParameter& inner_product_param() const;
- ::caffe::InnerProductParameter* mutable_inner_product_param();
- ::caffe::InnerProductParameter* release_inner_product_param();
- void set_allocated_inner_product_param(::caffe::InnerProductParameter* inner_product_param);
-
- // optional .caffe.LogParameter log_param = 134;
- bool has_log_param() const;
- void clear_log_param();
- static const int kLogParamFieldNumber = 134;
- const ::caffe::LogParameter& log_param() const;
- ::caffe::LogParameter* mutable_log_param();
- ::caffe::LogParameter* release_log_param();
- void set_allocated_log_param(::caffe::LogParameter* log_param);
-
- // optional .caffe.LRNParameter lrn_param = 118;
- bool has_lrn_param() const;
- void clear_lrn_param();
- static const int kLrnParamFieldNumber = 118;
- const ::caffe::LRNParameter& lrn_param() const;
- ::caffe::LRNParameter* mutable_lrn_param();
- ::caffe::LRNParameter* release_lrn_param();
- void set_allocated_lrn_param(::caffe::LRNParameter* lrn_param);
-
- // optional .caffe.MemoryDataParameter memory_data_param = 119;
- bool has_memory_data_param() const;
- void clear_memory_data_param();
- static const int kMemoryDataParamFieldNumber = 119;
- const ::caffe::MemoryDataParameter& memory_data_param() const;
- ::caffe::MemoryDataParameter* mutable_memory_data_param();
- ::caffe::MemoryDataParameter* release_memory_data_param();
- void set_allocated_memory_data_param(::caffe::MemoryDataParameter* memory_data_param);
-
- // optional .caffe.MVNParameter mvn_param = 120;
- bool has_mvn_param() const;
- void clear_mvn_param();
- static const int kMvnParamFieldNumber = 120;
- const ::caffe::MVNParameter& mvn_param() const;
- ::caffe::MVNParameter* mutable_mvn_param();
- ::caffe::MVNParameter* release_mvn_param();
- void set_allocated_mvn_param(::caffe::MVNParameter* mvn_param);
-
- // optional .caffe.NormalizeBBoxParameter normalize_bbox_param = 139;
- bool has_normalize_bbox_param() const;
- void clear_normalize_bbox_param();
- static const int kNormalizeBboxParamFieldNumber = 139;
- const ::caffe::NormalizeBBoxParameter& normalize_bbox_param() const;
- ::caffe::NormalizeBBoxParameter* mutable_normalize_bbox_param();
- ::caffe::NormalizeBBoxParameter* release_normalize_bbox_param();
- void set_allocated_normalize_bbox_param(::caffe::NormalizeBBoxParameter* normalize_bbox_param);
-
- // optional .caffe.PermuteParameter permute_param = 138;
- bool has_permute_param() const;
- void clear_permute_param();
- static const int kPermuteParamFieldNumber = 138;
- const ::caffe::PermuteParameter& permute_param() const;
- ::caffe::PermuteParameter* mutable_permute_param();
- ::caffe::PermuteParameter* release_permute_param();
- void set_allocated_permute_param(::caffe::PermuteParameter* permute_param);
-
- // optional .caffe.PoolingParameter pooling_param = 121;
- bool has_pooling_param() const;
- void clear_pooling_param();
- static const int kPoolingParamFieldNumber = 121;
- const ::caffe::PoolingParameter& pooling_param() const;
- ::caffe::PoolingParameter* mutable_pooling_param();
- ::caffe::PoolingParameter* release_pooling_param();
- void set_allocated_pooling_param(::caffe::PoolingParameter* pooling_param);
-
- // optional .caffe.PowerParameter power_param = 122;
- bool has_power_param() const;
- void clear_power_param();
- static const int kPowerParamFieldNumber = 122;
- const ::caffe::PowerParameter& power_param() const;
- ::caffe::PowerParameter* mutable_power_param();
- ::caffe::PowerParameter* release_power_param();
- void set_allocated_power_param(::caffe::PowerParameter* power_param);
-
- // optional .caffe.PReLUParameter prelu_param = 131;
- bool has_prelu_param() const;
- void clear_prelu_param();
- static const int kPreluParamFieldNumber = 131;
- const ::caffe::PReLUParameter& prelu_param() const;
- ::caffe::PReLUParameter* mutable_prelu_param();
- ::caffe::PReLUParameter* release_prelu_param();
- void set_allocated_prelu_param(::caffe::PReLUParameter* prelu_param);
-
- // optional .caffe.PriorBoxParameter prior_box_param = 140;
- bool has_prior_box_param() const;
- void clear_prior_box_param();
- static const int kPriorBoxParamFieldNumber = 140;
- const ::caffe::PriorBoxParameter& prior_box_param() const;
- ::caffe::PriorBoxParameter* mutable_prior_box_param();
- ::caffe::PriorBoxParameter* release_prior_box_param();
- void set_allocated_prior_box_param(::caffe::PriorBoxParameter* prior_box_param);
-
- // optional .caffe.PythonParameter python_param = 130;
- bool has_python_param() const;
- void clear_python_param();
- static const int kPythonParamFieldNumber = 130;
- const ::caffe::PythonParameter& python_param() const;
- ::caffe::PythonParameter* mutable_python_param();
- ::caffe::PythonParameter* release_python_param();
- void set_allocated_python_param(::caffe::PythonParameter* python_param);
-
- // optional .caffe.ReductionParameter reduction_param = 136;
- bool has_reduction_param() const;
- void clear_reduction_param();
- static const int kReductionParamFieldNumber = 136;
- const ::caffe::ReductionParameter& reduction_param() const;
- ::caffe::ReductionParameter* mutable_reduction_param();
- ::caffe::ReductionParameter* release_reduction_param();
- void set_allocated_reduction_param(::caffe::ReductionParameter* reduction_param);
-
- // optional .caffe.ReLUParameter relu_param = 123;
- bool has_relu_param() const;
- void clear_relu_param();
- static const int kReluParamFieldNumber = 123;
- const ::caffe::ReLUParameter& relu_param() const;
- ::caffe::ReLUParameter* mutable_relu_param();
- ::caffe::ReLUParameter* release_relu_param();
- void set_allocated_relu_param(::caffe::ReLUParameter* relu_param);
-
- // optional .caffe.ReshapeParameter reshape_param = 133;
- bool has_reshape_param() const;
- void clear_reshape_param();
- static const int kReshapeParamFieldNumber = 133;
- const ::caffe::ReshapeParameter& reshape_param() const;
- ::caffe::ReshapeParameter* mutable_reshape_param();
- ::caffe::ReshapeParameter* release_reshape_param();
- void set_allocated_reshape_param(::caffe::ReshapeParameter* reshape_param);
-
- // optional .caffe.SigmoidParameter sigmoid_param = 124;
- bool has_sigmoid_param() const;
- void clear_sigmoid_param();
- static const int kSigmoidParamFieldNumber = 124;
- const ::caffe::SigmoidParameter& sigmoid_param() const;
- ::caffe::SigmoidParameter* mutable_sigmoid_param();
- ::caffe::SigmoidParameter* release_sigmoid_param();
- void set_allocated_sigmoid_param(::caffe::SigmoidParameter* sigmoid_param);
-
- // optional .caffe.SliceParameter slice_param = 126;
- bool has_slice_param() const;
- void clear_slice_param();
- static const int kSliceParamFieldNumber = 126;
- const ::caffe::SliceParameter& slice_param() const;
- ::caffe::SliceParameter* mutable_slice_param();
- ::caffe::SliceParameter* release_slice_param();
- void set_allocated_slice_param(::caffe::SliceParameter* slice_param);
-
- // optional .caffe.SoftmaxParameter softmax_param = 125;
- bool has_softmax_param() const;
- void clear_softmax_param();
- static const int kSoftmaxParamFieldNumber = 125;
- const ::caffe::SoftmaxParameter& softmax_param() const;
- ::caffe::SoftmaxParameter* mutable_softmax_param();
- ::caffe::SoftmaxParameter* release_softmax_param();
- void set_allocated_softmax_param(::caffe::SoftmaxParameter* softmax_param);
-
- // optional .caffe.SPPParameter spp_param = 132;
- bool has_spp_param() const;
- void clear_spp_param();
- static const int kSppParamFieldNumber = 132;
- const ::caffe::SPPParameter& spp_param() const;
- ::caffe::SPPParameter* mutable_spp_param();
- ::caffe::SPPParameter* release_spp_param();
- void set_allocated_spp_param(::caffe::SPPParameter* spp_param);
-
- // optional .caffe.TanHParameter tanh_param = 127;
- bool has_tanh_param() const;
- void clear_tanh_param();
- static const int kTanhParamFieldNumber = 127;
- const ::caffe::TanHParameter& tanh_param() const;
- ::caffe::TanHParameter* mutable_tanh_param();
- ::caffe::TanHParameter* release_tanh_param();
- void set_allocated_tanh_param(::caffe::TanHParameter* tanh_param);
-
- // optional .caffe.ThresholdParameter threshold_param = 128;
- bool has_threshold_param() const;
- void clear_threshold_param();
- static const int kThresholdParamFieldNumber = 128;
- const ::caffe::ThresholdParameter& threshold_param() const;
- ::caffe::ThresholdParameter* mutable_threshold_param();
- ::caffe::ThresholdParameter* release_threshold_param();
- void set_allocated_threshold_param(::caffe::ThresholdParameter* threshold_param);
-
- // optional .caffe.WindowDataParameter window_data_param = 129;
- bool has_window_data_param() const;
- void clear_window_data_param();
- static const int kWindowDataParamFieldNumber = 129;
- const ::caffe::WindowDataParameter& window_data_param() const;
- ::caffe::WindowDataParameter* mutable_window_data_param();
- ::caffe::WindowDataParameter* release_window_data_param();
- void set_allocated_window_data_param(::caffe::WindowDataParameter* window_data_param);
-
- // @@protoc_insertion_point(class_scope:caffe.LayerParameter)
- private:
- inline void set_has_name();
- inline void clear_has_name();
- inline void set_has_type();
- inline void clear_has_type();
- inline void set_has_phase();
- inline void clear_has_phase();
- inline void set_has_transform_param();
- inline void clear_has_transform_param();
- inline void set_has_loss_param();
- inline void clear_has_loss_param();
- inline void set_has_accuracy_param();
- inline void clear_has_accuracy_param();
- inline void set_has_argmax_param();
- inline void clear_has_argmax_param();
- inline void set_has_concat_param();
- inline void clear_has_concat_param();
- inline void set_has_contrastive_loss_param();
- inline void clear_has_contrastive_loss_param();
- inline void set_has_convolution_param();
- inline void clear_has_convolution_param();
- inline void set_has_crop_param();
- inline void clear_has_crop_param();
- inline void set_has_data_param();
- inline void clear_has_data_param();
- inline void set_has_detection_output_param();
- inline void clear_has_detection_output_param();
- inline void set_has_dropout_param();
- inline void clear_has_dropout_param();
- inline void set_has_dummy_data_param();
- inline void clear_has_dummy_data_param();
- inline void set_has_eltwise_param();
- inline void clear_has_eltwise_param();
- inline void set_has_exp_param();
- inline void clear_has_exp_param();
- inline void set_has_flatten_param();
- inline void clear_has_flatten_param();
- inline void set_has_hdf5_data_param();
- inline void clear_has_hdf5_data_param();
- inline void set_has_hdf5_output_param();
- inline void clear_has_hdf5_output_param();
- inline void set_has_hinge_loss_param();
- inline void clear_has_hinge_loss_param();
- inline void set_has_image_data_param();
- inline void clear_has_image_data_param();
- inline void set_has_infogain_loss_param();
- inline void clear_has_infogain_loss_param();
- inline void set_has_inner_product_param();
- inline void clear_has_inner_product_param();
- inline void set_has_log_param();
- inline void clear_has_log_param();
- inline void set_has_lrn_param();
- inline void clear_has_lrn_param();
- inline void set_has_memory_data_param();
- inline void clear_has_memory_data_param();
- inline void set_has_mvn_param();
- inline void clear_has_mvn_param();
- inline void set_has_normalize_bbox_param();
- inline void clear_has_normalize_bbox_param();
- inline void set_has_permute_param();
- inline void clear_has_permute_param();
- inline void set_has_pooling_param();
- inline void clear_has_pooling_param();
- inline void set_has_power_param();
- inline void clear_has_power_param();
- inline void set_has_prelu_param();
- inline void clear_has_prelu_param();
- inline void set_has_prior_box_param();
- inline void clear_has_prior_box_param();
- inline void set_has_python_param();
- inline void clear_has_python_param();
- inline void set_has_reduction_param();
- inline void clear_has_reduction_param();
- inline void set_has_relu_param();
- inline void clear_has_relu_param();
- inline void set_has_reshape_param();
- inline void clear_has_reshape_param();
- inline void set_has_sigmoid_param();
- inline void clear_has_sigmoid_param();
- inline void set_has_slice_param();
- inline void clear_has_slice_param();
- inline void set_has_softmax_param();
- inline void clear_has_softmax_param();
- inline void set_has_spp_param();
- inline void clear_has_spp_param();
- inline void set_has_tanh_param();
- inline void clear_has_tanh_param();
- inline void set_has_threshold_param();
- inline void clear_has_threshold_param();
- inline void set_has_window_data_param();
- inline void clear_has_window_data_param();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<2> _has_bits_;
- ::google::protobuf::RepeatedPtrField< ::std::string> bottom_;
- ::google::protobuf::RepeatedPtrField< ::std::string> top_;
- ::google::protobuf::RepeatedField< float > loss_weight_;
- ::google::protobuf::RepeatedPtrField< ::caffe::ParamSpec > param_;
- ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto > blobs_;
- ::google::protobuf::RepeatedField< bool > propagate_down_;
- ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule > include_;
- ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule > exclude_;
- ::google::protobuf::internal::ArenaStringPtr name_;
- ::google::protobuf::internal::ArenaStringPtr type_;
- ::caffe::TransformationParameter* transform_param_;
- ::caffe::LossParameter* loss_param_;
- ::caffe::AccuracyParameter* accuracy_param_;
- ::caffe::ArgMaxParameter* argmax_param_;
- ::caffe::ConcatParameter* concat_param_;
- ::caffe::ContrastiveLossParameter* contrastive_loss_param_;
- ::caffe::ConvolutionParameter* convolution_param_;
- ::caffe::CropParameter* crop_param_;
- ::caffe::DataParameter* data_param_;
- ::caffe::DetectionOutputParameter* detection_output_param_;
- ::caffe::DropoutParameter* dropout_param_;
- ::caffe::DummyDataParameter* dummy_data_param_;
- ::caffe::EltwiseParameter* eltwise_param_;
- ::caffe::ExpParameter* exp_param_;
- ::caffe::FlattenParameter* flatten_param_;
- ::caffe::HDF5DataParameter* hdf5_data_param_;
- ::caffe::HDF5OutputParameter* hdf5_output_param_;
- ::caffe::HingeLossParameter* hinge_loss_param_;
- ::caffe::ImageDataParameter* image_data_param_;
- ::caffe::InfogainLossParameter* infogain_loss_param_;
- ::caffe::InnerProductParameter* inner_product_param_;
- ::caffe::LogParameter* log_param_;
- ::caffe::LRNParameter* lrn_param_;
- ::caffe::MemoryDataParameter* memory_data_param_;
- ::caffe::MVNParameter* mvn_param_;
- ::caffe::NormalizeBBoxParameter* normalize_bbox_param_;
- ::caffe::PermuteParameter* permute_param_;
- ::caffe::PoolingParameter* pooling_param_;
- ::caffe::PowerParameter* power_param_;
- ::caffe::PReLUParameter* prelu_param_;
- ::caffe::PriorBoxParameter* prior_box_param_;
- ::caffe::PythonParameter* python_param_;
- ::caffe::ReductionParameter* reduction_param_;
- ::caffe::ReLUParameter* relu_param_;
- ::caffe::ReshapeParameter* reshape_param_;
- ::caffe::SigmoidParameter* sigmoid_param_;
- ::caffe::SliceParameter* slice_param_;
- ::caffe::SoftmaxParameter* softmax_param_;
- ::caffe::SPPParameter* spp_param_;
- ::caffe::TanHParameter* tanh_param_;
- ::caffe::ThresholdParameter* threshold_param_;
- ::caffe::WindowDataParameter* window_data_param_;
- int phase_;
- mutable int _cached_size_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<LayerParameter> LayerParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class TransformationParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.TransformationParameter) */ {
- public:
- TransformationParameter();
- virtual ~TransformationParameter();
-
- TransformationParameter(const TransformationParameter& from);
-
- inline TransformationParameter& operator=(const TransformationParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const TransformationParameter& default_instance();
-
- static const TransformationParameter* internal_default_instance();
-
- void Swap(TransformationParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline TransformationParameter* New() const { return New(NULL); }
-
- TransformationParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const TransformationParameter& from);
- void MergeFrom(const TransformationParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(TransformationParameter* other);
- void UnsafeMergeFrom(const TransformationParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional float scale = 1 [default = 1];
- bool has_scale() const;
- void clear_scale();
- static const int kScaleFieldNumber = 1;
- float scale() const;
- void set_scale(float value);
-
- // optional bool mirror = 2 [default = false];
- bool has_mirror() const;
- void clear_mirror();
- static const int kMirrorFieldNumber = 2;
- bool mirror() const;
- void set_mirror(bool value);
-
- // optional uint32 crop_size = 3 [default = 0];
- bool has_crop_size() const;
- void clear_crop_size();
- static const int kCropSizeFieldNumber = 3;
- ::google::protobuf::uint32 crop_size() const;
- void set_crop_size(::google::protobuf::uint32 value);
-
- // optional string mean_file = 4;
- bool has_mean_file() const;
- void clear_mean_file();
- static const int kMeanFileFieldNumber = 4;
- const ::std::string& mean_file() const;
- void set_mean_file(const ::std::string& value);
- void set_mean_file(const char* value);
- void set_mean_file(const char* value, size_t size);
- ::std::string* mutable_mean_file();
- ::std::string* release_mean_file();
- void set_allocated_mean_file(::std::string* mean_file);
-
- // repeated float mean_value = 5;
- int mean_value_size() const;
- void clear_mean_value();
- static const int kMeanValueFieldNumber = 5;
- float mean_value(int index) const;
- void set_mean_value(int index, float value);
- void add_mean_value(float value);
- const ::google::protobuf::RepeatedField< float >&
- mean_value() const;
- ::google::protobuf::RepeatedField< float >*
- mutable_mean_value();
-
- // optional bool force_color = 6 [default = false];
- bool has_force_color() const;
- void clear_force_color();
- static const int kForceColorFieldNumber = 6;
- bool force_color() const;
- void set_force_color(bool value);
-
- // optional bool force_gray = 7 [default = false];
- bool has_force_gray() const;
- void clear_force_gray();
- static const int kForceGrayFieldNumber = 7;
- bool force_gray() const;
- void set_force_gray(bool value);
-
- // @@protoc_insertion_point(class_scope:caffe.TransformationParameter)
- private:
- inline void set_has_scale();
- inline void clear_has_scale();
- inline void set_has_mirror();
- inline void clear_has_mirror();
- inline void set_has_crop_size();
- inline void clear_has_crop_size();
- inline void set_has_mean_file();
- inline void clear_has_mean_file();
- inline void set_has_force_color();
- inline void clear_has_force_color();
- inline void set_has_force_gray();
- inline void clear_has_force_gray();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::RepeatedField< float > mean_value_;
- ::google::protobuf::internal::ArenaStringPtr mean_file_;
- ::google::protobuf::uint32 crop_size_;
- bool mirror_;
- bool force_color_;
- bool force_gray_;
- float scale_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<TransformationParameter> TransformationParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class LossParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.LossParameter) */ {
- public:
- LossParameter();
- virtual ~LossParameter();
-
- LossParameter(const LossParameter& from);
-
- inline LossParameter& operator=(const LossParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const LossParameter& default_instance();
-
- static const LossParameter* internal_default_instance();
-
- void Swap(LossParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline LossParameter* New() const { return New(NULL); }
-
- LossParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const LossParameter& from);
- void MergeFrom(const LossParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(LossParameter* other);
- void UnsafeMergeFrom(const LossParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional int32 ignore_label = 1;
- bool has_ignore_label() const;
- void clear_ignore_label();
- static const int kIgnoreLabelFieldNumber = 1;
- ::google::protobuf::int32 ignore_label() const;
- void set_ignore_label(::google::protobuf::int32 value);
-
- // optional bool normalize = 2 [default = true];
- bool has_normalize() const;
- void clear_normalize();
- static const int kNormalizeFieldNumber = 2;
- bool normalize() const;
- void set_normalize(bool value);
-
- // @@protoc_insertion_point(class_scope:caffe.LossParameter)
- private:
- inline void set_has_ignore_label();
- inline void clear_has_ignore_label();
- inline void set_has_normalize();
- inline void clear_has_normalize();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::int32 ignore_label_;
- bool normalize_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<LossParameter> LossParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class AccuracyParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.AccuracyParameter) */ {
- public:
- AccuracyParameter();
- virtual ~AccuracyParameter();
-
- AccuracyParameter(const AccuracyParameter& from);
-
- inline AccuracyParameter& operator=(const AccuracyParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const AccuracyParameter& default_instance();
-
- static const AccuracyParameter* internal_default_instance();
-
- void Swap(AccuracyParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline AccuracyParameter* New() const { return New(NULL); }
-
- AccuracyParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const AccuracyParameter& from);
- void MergeFrom(const AccuracyParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(AccuracyParameter* other);
- void UnsafeMergeFrom(const AccuracyParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional uint32 top_k = 1 [default = 1];
- bool has_top_k() const;
- void clear_top_k();
- static const int kTopKFieldNumber = 1;
- ::google::protobuf::uint32 top_k() const;
- void set_top_k(::google::protobuf::uint32 value);
-
- // optional int32 axis = 2 [default = 1];
- bool has_axis() const;
- void clear_axis();
- static const int kAxisFieldNumber = 2;
- ::google::protobuf::int32 axis() const;
- void set_axis(::google::protobuf::int32 value);
-
- // optional int32 ignore_label = 3;
- bool has_ignore_label() const;
- void clear_ignore_label();
- static const int kIgnoreLabelFieldNumber = 3;
- ::google::protobuf::int32 ignore_label() const;
- void set_ignore_label(::google::protobuf::int32 value);
-
- // @@protoc_insertion_point(class_scope:caffe.AccuracyParameter)
- private:
- inline void set_has_top_k();
- inline void clear_has_top_k();
- inline void set_has_axis();
- inline void clear_has_axis();
- inline void set_has_ignore_label();
- inline void clear_has_ignore_label();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::int32 ignore_label_;
- ::google::protobuf::uint32 top_k_;
- ::google::protobuf::int32 axis_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<AccuracyParameter> AccuracyParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class ArgMaxParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ArgMaxParameter) */ {
- public:
- ArgMaxParameter();
- virtual ~ArgMaxParameter();
-
- ArgMaxParameter(const ArgMaxParameter& from);
-
- inline ArgMaxParameter& operator=(const ArgMaxParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const ArgMaxParameter& default_instance();
-
- static const ArgMaxParameter* internal_default_instance();
-
- void Swap(ArgMaxParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline ArgMaxParameter* New() const { return New(NULL); }
-
- ArgMaxParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const ArgMaxParameter& from);
- void MergeFrom(const ArgMaxParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(ArgMaxParameter* other);
- void UnsafeMergeFrom(const ArgMaxParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional bool out_max_val = 1 [default = false];
- bool has_out_max_val() const;
- void clear_out_max_val();
- static const int kOutMaxValFieldNumber = 1;
- bool out_max_val() const;
- void set_out_max_val(bool value);
-
- // optional uint32 top_k = 2 [default = 1];
- bool has_top_k() const;
- void clear_top_k();
- static const int kTopKFieldNumber = 2;
- ::google::protobuf::uint32 top_k() const;
- void set_top_k(::google::protobuf::uint32 value);
-
- // @@protoc_insertion_point(class_scope:caffe.ArgMaxParameter)
- private:
- inline void set_has_out_max_val();
- inline void clear_has_out_max_val();
- inline void set_has_top_k();
- inline void clear_has_top_k();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- bool out_max_val_;
- ::google::protobuf::uint32 top_k_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<ArgMaxParameter> ArgMaxParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class ConcatParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ConcatParameter) */ {
- public:
- ConcatParameter();
- virtual ~ConcatParameter();
-
- ConcatParameter(const ConcatParameter& from);
-
- inline ConcatParameter& operator=(const ConcatParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const ConcatParameter& default_instance();
-
- static const ConcatParameter* internal_default_instance();
-
- void Swap(ConcatParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline ConcatParameter* New() const { return New(NULL); }
-
- ConcatParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const ConcatParameter& from);
- void MergeFrom(const ConcatParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(ConcatParameter* other);
- void UnsafeMergeFrom(const ConcatParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional int32 axis = 2 [default = 1];
- bool has_axis() const;
- void clear_axis();
- static const int kAxisFieldNumber = 2;
- ::google::protobuf::int32 axis() const;
- void set_axis(::google::protobuf::int32 value);
-
- // optional uint32 concat_dim = 1 [default = 1];
- bool has_concat_dim() const;
- void clear_concat_dim();
- static const int kConcatDimFieldNumber = 1;
- ::google::protobuf::uint32 concat_dim() const;
- void set_concat_dim(::google::protobuf::uint32 value);
-
- // @@protoc_insertion_point(class_scope:caffe.ConcatParameter)
- private:
- inline void set_has_axis();
- inline void clear_has_axis();
- inline void set_has_concat_dim();
- inline void clear_has_concat_dim();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::int32 axis_;
- ::google::protobuf::uint32 concat_dim_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<ConcatParameter> ConcatParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class ContrastiveLossParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ContrastiveLossParameter) */ {
- public:
- ContrastiveLossParameter();
- virtual ~ContrastiveLossParameter();
-
- ContrastiveLossParameter(const ContrastiveLossParameter& from);
-
- inline ContrastiveLossParameter& operator=(const ContrastiveLossParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const ContrastiveLossParameter& default_instance();
-
- static const ContrastiveLossParameter* internal_default_instance();
-
- void Swap(ContrastiveLossParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline ContrastiveLossParameter* New() const { return New(NULL); }
-
- ContrastiveLossParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const ContrastiveLossParameter& from);
- void MergeFrom(const ContrastiveLossParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(ContrastiveLossParameter* other);
- void UnsafeMergeFrom(const ContrastiveLossParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional float margin = 1 [default = 1];
- bool has_margin() const;
- void clear_margin();
- static const int kMarginFieldNumber = 1;
- float margin() const;
- void set_margin(float value);
-
- // optional bool legacy_version = 2 [default = false];
- bool has_legacy_version() const;
- void clear_legacy_version();
- static const int kLegacyVersionFieldNumber = 2;
- bool legacy_version() const;
- void set_legacy_version(bool value);
-
- // @@protoc_insertion_point(class_scope:caffe.ContrastiveLossParameter)
- private:
- inline void set_has_margin();
- inline void clear_has_margin();
- inline void set_has_legacy_version();
- inline void clear_has_legacy_version();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- bool legacy_version_;
- float margin_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<ContrastiveLossParameter> ContrastiveLossParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class ConvolutionParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ConvolutionParameter) */ {
- public:
- ConvolutionParameter();
- virtual ~ConvolutionParameter();
-
- ConvolutionParameter(const ConvolutionParameter& from);
-
- inline ConvolutionParameter& operator=(const ConvolutionParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const ConvolutionParameter& default_instance();
-
- static const ConvolutionParameter* internal_default_instance();
-
- void Swap(ConvolutionParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline ConvolutionParameter* New() const { return New(NULL); }
-
- ConvolutionParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const ConvolutionParameter& from);
- void MergeFrom(const ConvolutionParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(ConvolutionParameter* other);
- void UnsafeMergeFrom(const ConvolutionParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- typedef ConvolutionParameter_Engine Engine;
- static const Engine DEFAULT =
- ConvolutionParameter_Engine_DEFAULT;
- static const Engine CAFFE =
- ConvolutionParameter_Engine_CAFFE;
- static const Engine CUDNN =
- ConvolutionParameter_Engine_CUDNN;
- static inline bool Engine_IsValid(int value) {
- return ConvolutionParameter_Engine_IsValid(value);
- }
- static const Engine Engine_MIN =
- ConvolutionParameter_Engine_Engine_MIN;
- static const Engine Engine_MAX =
- ConvolutionParameter_Engine_Engine_MAX;
- static const int Engine_ARRAYSIZE =
- ConvolutionParameter_Engine_Engine_ARRAYSIZE;
- static inline const ::google::protobuf::EnumDescriptor*
- Engine_descriptor() {
- return ConvolutionParameter_Engine_descriptor();
- }
- static inline const ::std::string& Engine_Name(Engine value) {
- return ConvolutionParameter_Engine_Name(value);
- }
- static inline bool Engine_Parse(const ::std::string& name,
- Engine* value) {
- return ConvolutionParameter_Engine_Parse(name, value);
- }
-
- // accessors -------------------------------------------------------
-
- // optional uint32 num_output = 1;
- bool has_num_output() const;
- void clear_num_output();
- static const int kNumOutputFieldNumber = 1;
- ::google::protobuf::uint32 num_output() const;
- void set_num_output(::google::protobuf::uint32 value);
-
- // optional bool bias_term = 2 [default = true];
- bool has_bias_term() const;
- void clear_bias_term();
- static const int kBiasTermFieldNumber = 2;
- bool bias_term() const;
- void set_bias_term(bool value);
-
- // optional uint32 pad = 3 [default = 0];
- bool has_pad() const;
- void clear_pad();
- static const int kPadFieldNumber = 3;
- ::google::protobuf::uint32 pad() const;
- void set_pad(::google::protobuf::uint32 value);
-
- // optional uint32 pad_h = 9 [default = 0];
- bool has_pad_h() const;
- void clear_pad_h();
- static const int kPadHFieldNumber = 9;
- ::google::protobuf::uint32 pad_h() const;
- void set_pad_h(::google::protobuf::uint32 value);
-
- // optional uint32 pad_w = 10 [default = 0];
- bool has_pad_w() const;
- void clear_pad_w();
- static const int kPadWFieldNumber = 10;
- ::google::protobuf::uint32 pad_w() const;
- void set_pad_w(::google::protobuf::uint32 value);
-
- // optional uint32 kernel_size = 4;
- bool has_kernel_size() const;
- void clear_kernel_size();
- static const int kKernelSizeFieldNumber = 4;
- ::google::protobuf::uint32 kernel_size() const;
- void set_kernel_size(::google::protobuf::uint32 value);
-
- // optional uint32 kernel_h = 11;
- bool has_kernel_h() const;
- void clear_kernel_h();
- static const int kKernelHFieldNumber = 11;
- ::google::protobuf::uint32 kernel_h() const;
- void set_kernel_h(::google::protobuf::uint32 value);
-
- // optional uint32 kernel_w = 12;
- bool has_kernel_w() const;
- void clear_kernel_w();
- static const int kKernelWFieldNumber = 12;
- ::google::protobuf::uint32 kernel_w() const;
- void set_kernel_w(::google::protobuf::uint32 value);
-
- // optional uint32 group = 5 [default = 1];
- bool has_group() const;
- void clear_group();
- static const int kGroupFieldNumber = 5;
- ::google::protobuf::uint32 group() const;
- void set_group(::google::protobuf::uint32 value);
-
- // optional uint32 stride = 6 [default = 1];
- bool has_stride() const;
- void clear_stride();
- static const int kStrideFieldNumber = 6;
- ::google::protobuf::uint32 stride() const;
- void set_stride(::google::protobuf::uint32 value);
-
- // optional uint32 stride_h = 13;
- bool has_stride_h() const;
- void clear_stride_h();
- static const int kStrideHFieldNumber = 13;
- ::google::protobuf::uint32 stride_h() const;
- void set_stride_h(::google::protobuf::uint32 value);
-
- // optional uint32 stride_w = 14;
- bool has_stride_w() const;
- void clear_stride_w();
- static const int kStrideWFieldNumber = 14;
- ::google::protobuf::uint32 stride_w() const;
- void set_stride_w(::google::protobuf::uint32 value);
-
- // optional .caffe.FillerParameter weight_filler = 7;
- bool has_weight_filler() const;
- void clear_weight_filler();
- static const int kWeightFillerFieldNumber = 7;
- const ::caffe::FillerParameter& weight_filler() const;
- ::caffe::FillerParameter* mutable_weight_filler();
- ::caffe::FillerParameter* release_weight_filler();
- void set_allocated_weight_filler(::caffe::FillerParameter* weight_filler);
-
- // optional .caffe.FillerParameter bias_filler = 8;
- bool has_bias_filler() const;
- void clear_bias_filler();
- static const int kBiasFillerFieldNumber = 8;
- const ::caffe::FillerParameter& bias_filler() const;
- ::caffe::FillerParameter* mutable_bias_filler();
- ::caffe::FillerParameter* release_bias_filler();
- void set_allocated_bias_filler(::caffe::FillerParameter* bias_filler);
-
- // optional .caffe.ConvolutionParameter.Engine engine = 15 [default = DEFAULT];
- bool has_engine() const;
- void clear_engine();
- static const int kEngineFieldNumber = 15;
- ::caffe::ConvolutionParameter_Engine engine() const;
- void set_engine(::caffe::ConvolutionParameter_Engine value);
-
- // optional uint32 dilation_h = 18;
- bool has_dilation_h() const;
- void clear_dilation_h();
- static const int kDilationHFieldNumber = 18;
- ::google::protobuf::uint32 dilation_h() const;
- void set_dilation_h(::google::protobuf::uint32 value);
-
- // optional uint32 dilation_w = 19;
- bool has_dilation_w() const;
- void clear_dilation_w();
- static const int kDilationWFieldNumber = 19;
- ::google::protobuf::uint32 dilation_w() const;
- void set_dilation_w(::google::protobuf::uint32 value);
-
- // optional uint32 dilation = 20;
- bool has_dilation() const;
- void clear_dilation();
- static const int kDilationFieldNumber = 20;
- ::google::protobuf::uint32 dilation() const;
- void set_dilation(::google::protobuf::uint32 value);
-
- // @@protoc_insertion_point(class_scope:caffe.ConvolutionParameter)
- private:
- inline void set_has_num_output();
- inline void clear_has_num_output();
- inline void set_has_bias_term();
- inline void clear_has_bias_term();
- inline void set_has_pad();
- inline void clear_has_pad();
- inline void set_has_pad_h();
- inline void clear_has_pad_h();
- inline void set_has_pad_w();
- inline void clear_has_pad_w();
- inline void set_has_kernel_size();
- inline void clear_has_kernel_size();
- inline void set_has_kernel_h();
- inline void clear_has_kernel_h();
- inline void set_has_kernel_w();
- inline void clear_has_kernel_w();
- inline void set_has_group();
- inline void clear_has_group();
- inline void set_has_stride();
- inline void clear_has_stride();
- inline void set_has_stride_h();
- inline void clear_has_stride_h();
- inline void set_has_stride_w();
- inline void clear_has_stride_w();
- inline void set_has_weight_filler();
- inline void clear_has_weight_filler();
- inline void set_has_bias_filler();
- inline void clear_has_bias_filler();
- inline void set_has_engine();
- inline void clear_has_engine();
- inline void set_has_dilation_h();
- inline void clear_has_dilation_h();
- inline void set_has_dilation_w();
- inline void clear_has_dilation_w();
- inline void set_has_dilation();
- inline void clear_has_dilation();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::caffe::FillerParameter* weight_filler_;
- ::caffe::FillerParameter* bias_filler_;
- ::google::protobuf::uint32 num_output_;
- ::google::protobuf::uint32 pad_;
- ::google::protobuf::uint32 pad_h_;
- ::google::protobuf::uint32 pad_w_;
- ::google::protobuf::uint32 kernel_size_;
- ::google::protobuf::uint32 kernel_h_;
- ::google::protobuf::uint32 kernel_w_;
- ::google::protobuf::uint32 stride_h_;
- ::google::protobuf::uint32 stride_w_;
- int engine_;
- ::google::protobuf::uint32 dilation_h_;
- ::google::protobuf::uint32 dilation_w_;
- ::google::protobuf::uint32 dilation_;
- ::google::protobuf::uint32 stride_;
- bool bias_term_;
- ::google::protobuf::uint32 group_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<ConvolutionParameter> ConvolutionParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class DataParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.DataParameter) */ {
- public:
- DataParameter();
- virtual ~DataParameter();
-
- DataParameter(const DataParameter& from);
-
- inline DataParameter& operator=(const DataParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const DataParameter& default_instance();
-
- static const DataParameter* internal_default_instance();
-
- void Swap(DataParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline DataParameter* New() const { return New(NULL); }
-
- DataParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const DataParameter& from);
- void MergeFrom(const DataParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(DataParameter* other);
- void UnsafeMergeFrom(const DataParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- typedef DataParameter_DB DB;
- static const DB LEVELDB =
- DataParameter_DB_LEVELDB;
- static const DB LMDB =
- DataParameter_DB_LMDB;
- static inline bool DB_IsValid(int value) {
- return DataParameter_DB_IsValid(value);
- }
- static const DB DB_MIN =
- DataParameter_DB_DB_MIN;
- static const DB DB_MAX =
- DataParameter_DB_DB_MAX;
- static const int DB_ARRAYSIZE =
- DataParameter_DB_DB_ARRAYSIZE;
- static inline const ::google::protobuf::EnumDescriptor*
- DB_descriptor() {
- return DataParameter_DB_descriptor();
- }
- static inline const ::std::string& DB_Name(DB value) {
- return DataParameter_DB_Name(value);
- }
- static inline bool DB_Parse(const ::std::string& name,
- DB* value) {
- return DataParameter_DB_Parse(name, value);
- }
-
- // accessors -------------------------------------------------------
-
- // optional string source = 1;
- bool has_source() const;
- void clear_source();
- static const int kSourceFieldNumber = 1;
- const ::std::string& source() const;
- void set_source(const ::std::string& value);
- void set_source(const char* value);
- void set_source(const char* value, size_t size);
- ::std::string* mutable_source();
- ::std::string* release_source();
- void set_allocated_source(::std::string* source);
-
- // optional uint32 batch_size = 4;
- bool has_batch_size() const;
- void clear_batch_size();
- static const int kBatchSizeFieldNumber = 4;
- ::google::protobuf::uint32 batch_size() const;
- void set_batch_size(::google::protobuf::uint32 value);
-
- // optional uint32 rand_skip = 7 [default = 0];
- bool has_rand_skip() const;
- void clear_rand_skip();
- static const int kRandSkipFieldNumber = 7;
- ::google::protobuf::uint32 rand_skip() const;
- void set_rand_skip(::google::protobuf::uint32 value);
-
- // optional .caffe.DataParameter.DB backend = 8 [default = LEVELDB];
- bool has_backend() const;
- void clear_backend();
- static const int kBackendFieldNumber = 8;
- ::caffe::DataParameter_DB backend() const;
- void set_backend(::caffe::DataParameter_DB value);
-
- // optional float scale = 2 [default = 1];
- bool has_scale() const;
- void clear_scale();
- static const int kScaleFieldNumber = 2;
- float scale() const;
- void set_scale(float value);
-
- // optional string mean_file = 3;
- bool has_mean_file() const;
- void clear_mean_file();
- static const int kMeanFileFieldNumber = 3;
- const ::std::string& mean_file() const;
- void set_mean_file(const ::std::string& value);
- void set_mean_file(const char* value);
- void set_mean_file(const char* value, size_t size);
- ::std::string* mutable_mean_file();
- ::std::string* release_mean_file();
- void set_allocated_mean_file(::std::string* mean_file);
-
- // optional uint32 crop_size = 5 [default = 0];
- bool has_crop_size() const;
- void clear_crop_size();
- static const int kCropSizeFieldNumber = 5;
- ::google::protobuf::uint32 crop_size() const;
- void set_crop_size(::google::protobuf::uint32 value);
-
- // optional bool mirror = 6 [default = false];
- bool has_mirror() const;
- void clear_mirror();
- static const int kMirrorFieldNumber = 6;
- bool mirror() const;
- void set_mirror(bool value);
-
- // optional bool force_encoded_color = 9 [default = false];
- bool has_force_encoded_color() const;
- void clear_force_encoded_color();
- static const int kForceEncodedColorFieldNumber = 9;
- bool force_encoded_color() const;
- void set_force_encoded_color(bool value);
-
- // @@protoc_insertion_point(class_scope:caffe.DataParameter)
- private:
- inline void set_has_source();
- inline void clear_has_source();
- inline void set_has_batch_size();
- inline void clear_has_batch_size();
- inline void set_has_rand_skip();
- inline void clear_has_rand_skip();
- inline void set_has_backend();
- inline void clear_has_backend();
- inline void set_has_scale();
- inline void clear_has_scale();
- inline void set_has_mean_file();
- inline void clear_has_mean_file();
- inline void set_has_crop_size();
- inline void clear_has_crop_size();
- inline void set_has_mirror();
- inline void clear_has_mirror();
- inline void set_has_force_encoded_color();
- inline void clear_has_force_encoded_color();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::internal::ArenaStringPtr source_;
- ::google::protobuf::internal::ArenaStringPtr mean_file_;
- ::google::protobuf::uint32 batch_size_;
- ::google::protobuf::uint32 rand_skip_;
- int backend_;
- ::google::protobuf::uint32 crop_size_;
- bool mirror_;
- bool force_encoded_color_;
- float scale_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<DataParameter> DataParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class DropoutParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.DropoutParameter) */ {
- public:
- DropoutParameter();
- virtual ~DropoutParameter();
-
- DropoutParameter(const DropoutParameter& from);
-
- inline DropoutParameter& operator=(const DropoutParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const DropoutParameter& default_instance();
-
- static const DropoutParameter* internal_default_instance();
-
- void Swap(DropoutParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline DropoutParameter* New() const { return New(NULL); }
-
- DropoutParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const DropoutParameter& from);
- void MergeFrom(const DropoutParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(DropoutParameter* other);
- void UnsafeMergeFrom(const DropoutParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional float dropout_ratio = 1 [default = 0.5];
- bool has_dropout_ratio() const;
- void clear_dropout_ratio();
- static const int kDropoutRatioFieldNumber = 1;
- float dropout_ratio() const;
- void set_dropout_ratio(float value);
-
- // @@protoc_insertion_point(class_scope:caffe.DropoutParameter)
- private:
- inline void set_has_dropout_ratio();
- inline void clear_has_dropout_ratio();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- float dropout_ratio_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<DropoutParameter> DropoutParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class DummyDataParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.DummyDataParameter) */ {
- public:
- DummyDataParameter();
- virtual ~DummyDataParameter();
-
- DummyDataParameter(const DummyDataParameter& from);
-
- inline DummyDataParameter& operator=(const DummyDataParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const DummyDataParameter& default_instance();
-
- static const DummyDataParameter* internal_default_instance();
-
- void Swap(DummyDataParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline DummyDataParameter* New() const { return New(NULL); }
-
- DummyDataParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const DummyDataParameter& from);
- void MergeFrom(const DummyDataParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(DummyDataParameter* other);
- void UnsafeMergeFrom(const DummyDataParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // repeated .caffe.FillerParameter data_filler = 1;
- int data_filler_size() const;
- void clear_data_filler();
- static const int kDataFillerFieldNumber = 1;
- const ::caffe::FillerParameter& data_filler(int index) const;
- ::caffe::FillerParameter* mutable_data_filler(int index);
- ::caffe::FillerParameter* add_data_filler();
- ::google::protobuf::RepeatedPtrField< ::caffe::FillerParameter >*
- mutable_data_filler();
- const ::google::protobuf::RepeatedPtrField< ::caffe::FillerParameter >&
- data_filler() const;
-
- // repeated .caffe.BlobShape shape = 6;
- int shape_size() const;
- void clear_shape();
- static const int kShapeFieldNumber = 6;
- const ::caffe::BlobShape& shape(int index) const;
- ::caffe::BlobShape* mutable_shape(int index);
- ::caffe::BlobShape* add_shape();
- ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >*
- mutable_shape();
- const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >&
- shape() const;
-
- // repeated uint32 num = 2;
- int num_size() const;
- void clear_num();
- static const int kNumFieldNumber = 2;
- ::google::protobuf::uint32 num(int index) const;
- void set_num(int index, ::google::protobuf::uint32 value);
- void add_num(::google::protobuf::uint32 value);
- const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
- num() const;
- ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
- mutable_num();
-
- // repeated uint32 channels = 3;
- int channels_size() const;
- void clear_channels();
- static const int kChannelsFieldNumber = 3;
- ::google::protobuf::uint32 channels(int index) const;
- void set_channels(int index, ::google::protobuf::uint32 value);
- void add_channels(::google::protobuf::uint32 value);
- const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
- channels() const;
- ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
- mutable_channels();
-
- // repeated uint32 height = 4;
- int height_size() const;
- void clear_height();
- static const int kHeightFieldNumber = 4;
- ::google::protobuf::uint32 height(int index) const;
- void set_height(int index, ::google::protobuf::uint32 value);
- void add_height(::google::protobuf::uint32 value);
- const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
- height() const;
- ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
- mutable_height();
-
- // repeated uint32 width = 5;
- int width_size() const;
- void clear_width();
- static const int kWidthFieldNumber = 5;
- ::google::protobuf::uint32 width(int index) const;
- void set_width(int index, ::google::protobuf::uint32 value);
- void add_width(::google::protobuf::uint32 value);
- const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
- width() const;
- ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
- mutable_width();
-
- // @@protoc_insertion_point(class_scope:caffe.DummyDataParameter)
- private:
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::RepeatedPtrField< ::caffe::FillerParameter > data_filler_;
- ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape > shape_;
- ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > num_;
- ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > channels_;
- ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > height_;
- ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > width_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<DummyDataParameter> DummyDataParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class EltwiseParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.EltwiseParameter) */ {
- public:
- EltwiseParameter();
- virtual ~EltwiseParameter();
-
- EltwiseParameter(const EltwiseParameter& from);
-
- inline EltwiseParameter& operator=(const EltwiseParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const EltwiseParameter& default_instance();
-
- static const EltwiseParameter* internal_default_instance();
-
- void Swap(EltwiseParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline EltwiseParameter* New() const { return New(NULL); }
-
- EltwiseParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const EltwiseParameter& from);
- void MergeFrom(const EltwiseParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(EltwiseParameter* other);
- void UnsafeMergeFrom(const EltwiseParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- typedef EltwiseParameter_EltwiseOp EltwiseOp;
- static const EltwiseOp PROD =
- EltwiseParameter_EltwiseOp_PROD;
- static const EltwiseOp SUM =
- EltwiseParameter_EltwiseOp_SUM;
- static const EltwiseOp MAX =
- EltwiseParameter_EltwiseOp_MAX;
- static inline bool EltwiseOp_IsValid(int value) {
- return EltwiseParameter_EltwiseOp_IsValid(value);
- }
- static const EltwiseOp EltwiseOp_MIN =
- EltwiseParameter_EltwiseOp_EltwiseOp_MIN;
- static const EltwiseOp EltwiseOp_MAX =
- EltwiseParameter_EltwiseOp_EltwiseOp_MAX;
- static const int EltwiseOp_ARRAYSIZE =
- EltwiseParameter_EltwiseOp_EltwiseOp_ARRAYSIZE;
- static inline const ::google::protobuf::EnumDescriptor*
- EltwiseOp_descriptor() {
- return EltwiseParameter_EltwiseOp_descriptor();
- }
- static inline const ::std::string& EltwiseOp_Name(EltwiseOp value) {
- return EltwiseParameter_EltwiseOp_Name(value);
- }
- static inline bool EltwiseOp_Parse(const ::std::string& name,
- EltwiseOp* value) {
- return EltwiseParameter_EltwiseOp_Parse(name, value);
- }
-
- // accessors -------------------------------------------------------
-
- // optional .caffe.EltwiseParameter.EltwiseOp operation = 1 [default = SUM];
- bool has_operation() const;
- void clear_operation();
- static const int kOperationFieldNumber = 1;
- ::caffe::EltwiseParameter_EltwiseOp operation() const;
- void set_operation(::caffe::EltwiseParameter_EltwiseOp value);
-
- // repeated float coeff = 2;
- int coeff_size() const;
- void clear_coeff();
- static const int kCoeffFieldNumber = 2;
- float coeff(int index) const;
- void set_coeff(int index, float value);
- void add_coeff(float value);
- const ::google::protobuf::RepeatedField< float >&
- coeff() const;
- ::google::protobuf::RepeatedField< float >*
- mutable_coeff();
-
- // optional bool stable_prod_grad = 3 [default = true];
- bool has_stable_prod_grad() const;
- void clear_stable_prod_grad();
- static const int kStableProdGradFieldNumber = 3;
- bool stable_prod_grad() const;
- void set_stable_prod_grad(bool value);
-
- // @@protoc_insertion_point(class_scope:caffe.EltwiseParameter)
- private:
- inline void set_has_operation();
- inline void clear_has_operation();
- inline void set_has_stable_prod_grad();
- inline void clear_has_stable_prod_grad();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::RepeatedField< float > coeff_;
- int operation_;
- bool stable_prod_grad_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<EltwiseParameter> EltwiseParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class ExpParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ExpParameter) */ {
- public:
- ExpParameter();
- virtual ~ExpParameter();
-
- ExpParameter(const ExpParameter& from);
-
- inline ExpParameter& operator=(const ExpParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const ExpParameter& default_instance();
-
- static const ExpParameter* internal_default_instance();
-
- void Swap(ExpParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline ExpParameter* New() const { return New(NULL); }
-
- ExpParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const ExpParameter& from);
- void MergeFrom(const ExpParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(ExpParameter* other);
- void UnsafeMergeFrom(const ExpParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional float base = 1 [default = -1];
- bool has_base() const;
- void clear_base();
- static const int kBaseFieldNumber = 1;
- float base() const;
- void set_base(float value);
-
- // optional float scale = 2 [default = 1];
- bool has_scale() const;
- void clear_scale();
- static const int kScaleFieldNumber = 2;
- float scale() const;
- void set_scale(float value);
-
- // optional float shift = 3 [default = 0];
- bool has_shift() const;
- void clear_shift();
- static const int kShiftFieldNumber = 3;
- float shift() const;
- void set_shift(float value);
-
- // @@protoc_insertion_point(class_scope:caffe.ExpParameter)
- private:
- inline void set_has_base();
- inline void clear_has_base();
- inline void set_has_scale();
- inline void clear_has_scale();
- inline void set_has_shift();
- inline void clear_has_shift();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- float shift_;
- float base_;
- float scale_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<ExpParameter> ExpParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class FlattenParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.FlattenParameter) */ {
- public:
- FlattenParameter();
- virtual ~FlattenParameter();
-
- FlattenParameter(const FlattenParameter& from);
-
- inline FlattenParameter& operator=(const FlattenParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const FlattenParameter& default_instance();
-
- static const FlattenParameter* internal_default_instance();
-
- void Swap(FlattenParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline FlattenParameter* New() const { return New(NULL); }
-
- FlattenParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const FlattenParameter& from);
- void MergeFrom(const FlattenParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(FlattenParameter* other);
- void UnsafeMergeFrom(const FlattenParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional int32 axis = 1 [default = 1];
- bool has_axis() const;
- void clear_axis();
- static const int kAxisFieldNumber = 1;
- ::google::protobuf::int32 axis() const;
- void set_axis(::google::protobuf::int32 value);
-
- // optional int32 end_axis = 2 [default = -1];
- bool has_end_axis() const;
- void clear_end_axis();
- static const int kEndAxisFieldNumber = 2;
- ::google::protobuf::int32 end_axis() const;
- void set_end_axis(::google::protobuf::int32 value);
-
- // @@protoc_insertion_point(class_scope:caffe.FlattenParameter)
- private:
- inline void set_has_axis();
- inline void clear_has_axis();
- inline void set_has_end_axis();
- inline void clear_has_end_axis();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::int32 axis_;
- ::google::protobuf::int32 end_axis_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<FlattenParameter> FlattenParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class HDF5DataParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.HDF5DataParameter) */ {
- public:
- HDF5DataParameter();
- virtual ~HDF5DataParameter();
-
- HDF5DataParameter(const HDF5DataParameter& from);
-
- inline HDF5DataParameter& operator=(const HDF5DataParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const HDF5DataParameter& default_instance();
-
- static const HDF5DataParameter* internal_default_instance();
-
- void Swap(HDF5DataParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline HDF5DataParameter* New() const { return New(NULL); }
-
- HDF5DataParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const HDF5DataParameter& from);
- void MergeFrom(const HDF5DataParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(HDF5DataParameter* other);
- void UnsafeMergeFrom(const HDF5DataParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional string source = 1;
- bool has_source() const;
- void clear_source();
- static const int kSourceFieldNumber = 1;
- const ::std::string& source() const;
- void set_source(const ::std::string& value);
- void set_source(const char* value);
- void set_source(const char* value, size_t size);
- ::std::string* mutable_source();
- ::std::string* release_source();
- void set_allocated_source(::std::string* source);
-
- // optional uint32 batch_size = 2;
- bool has_batch_size() const;
- void clear_batch_size();
- static const int kBatchSizeFieldNumber = 2;
- ::google::protobuf::uint32 batch_size() const;
- void set_batch_size(::google::protobuf::uint32 value);
-
- // optional bool shuffle = 3 [default = false];
- bool has_shuffle() const;
- void clear_shuffle();
- static const int kShuffleFieldNumber = 3;
- bool shuffle() const;
- void set_shuffle(bool value);
-
- // @@protoc_insertion_point(class_scope:caffe.HDF5DataParameter)
- private:
- inline void set_has_source();
- inline void clear_has_source();
- inline void set_has_batch_size();
- inline void clear_has_batch_size();
- inline void set_has_shuffle();
- inline void clear_has_shuffle();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::internal::ArenaStringPtr source_;
- ::google::protobuf::uint32 batch_size_;
- bool shuffle_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<HDF5DataParameter> HDF5DataParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class HDF5OutputParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.HDF5OutputParameter) */ {
- public:
- HDF5OutputParameter();
- virtual ~HDF5OutputParameter();
-
- HDF5OutputParameter(const HDF5OutputParameter& from);
-
- inline HDF5OutputParameter& operator=(const HDF5OutputParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const HDF5OutputParameter& default_instance();
-
- static const HDF5OutputParameter* internal_default_instance();
-
- void Swap(HDF5OutputParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline HDF5OutputParameter* New() const { return New(NULL); }
-
- HDF5OutputParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const HDF5OutputParameter& from);
- void MergeFrom(const HDF5OutputParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(HDF5OutputParameter* other);
- void UnsafeMergeFrom(const HDF5OutputParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional string file_name = 1;
- bool has_file_name() const;
- void clear_file_name();
- static const int kFileNameFieldNumber = 1;
- const ::std::string& file_name() const;
- void set_file_name(const ::std::string& value);
- void set_file_name(const char* value);
- void set_file_name(const char* value, size_t size);
- ::std::string* mutable_file_name();
- ::std::string* release_file_name();
- void set_allocated_file_name(::std::string* file_name);
-
- // @@protoc_insertion_point(class_scope:caffe.HDF5OutputParameter)
- private:
- inline void set_has_file_name();
- inline void clear_has_file_name();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::internal::ArenaStringPtr file_name_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<HDF5OutputParameter> HDF5OutputParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class HingeLossParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.HingeLossParameter) */ {
- public:
- HingeLossParameter();
- virtual ~HingeLossParameter();
-
- HingeLossParameter(const HingeLossParameter& from);
-
- inline HingeLossParameter& operator=(const HingeLossParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const HingeLossParameter& default_instance();
-
- static const HingeLossParameter* internal_default_instance();
-
- void Swap(HingeLossParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline HingeLossParameter* New() const { return New(NULL); }
-
- HingeLossParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const HingeLossParameter& from);
- void MergeFrom(const HingeLossParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(HingeLossParameter* other);
- void UnsafeMergeFrom(const HingeLossParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- typedef HingeLossParameter_Norm Norm;
- static const Norm L1 =
- HingeLossParameter_Norm_L1;
- static const Norm L2 =
- HingeLossParameter_Norm_L2;
- static inline bool Norm_IsValid(int value) {
- return HingeLossParameter_Norm_IsValid(value);
- }
- static const Norm Norm_MIN =
- HingeLossParameter_Norm_Norm_MIN;
- static const Norm Norm_MAX =
- HingeLossParameter_Norm_Norm_MAX;
- static const int Norm_ARRAYSIZE =
- HingeLossParameter_Norm_Norm_ARRAYSIZE;
- static inline const ::google::protobuf::EnumDescriptor*
- Norm_descriptor() {
- return HingeLossParameter_Norm_descriptor();
- }
- static inline const ::std::string& Norm_Name(Norm value) {
- return HingeLossParameter_Norm_Name(value);
- }
- static inline bool Norm_Parse(const ::std::string& name,
- Norm* value) {
- return HingeLossParameter_Norm_Parse(name, value);
- }
-
- // accessors -------------------------------------------------------
-
- // optional .caffe.HingeLossParameter.Norm norm = 1 [default = L1];
- bool has_norm() const;
- void clear_norm();
- static const int kNormFieldNumber = 1;
- ::caffe::HingeLossParameter_Norm norm() const;
- void set_norm(::caffe::HingeLossParameter_Norm value);
-
- // @@protoc_insertion_point(class_scope:caffe.HingeLossParameter)
- private:
- inline void set_has_norm();
- inline void clear_has_norm();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- int norm_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<HingeLossParameter> HingeLossParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class ImageDataParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ImageDataParameter) */ {
- public:
- ImageDataParameter();
- virtual ~ImageDataParameter();
-
- ImageDataParameter(const ImageDataParameter& from);
-
- inline ImageDataParameter& operator=(const ImageDataParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const ImageDataParameter& default_instance();
-
- static const ImageDataParameter* internal_default_instance();
-
- void Swap(ImageDataParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline ImageDataParameter* New() const { return New(NULL); }
-
- ImageDataParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const ImageDataParameter& from);
- void MergeFrom(const ImageDataParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(ImageDataParameter* other);
- void UnsafeMergeFrom(const ImageDataParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional string source = 1;
- bool has_source() const;
- void clear_source();
- static const int kSourceFieldNumber = 1;
- const ::std::string& source() const;
- void set_source(const ::std::string& value);
- void set_source(const char* value);
- void set_source(const char* value, size_t size);
- ::std::string* mutable_source();
- ::std::string* release_source();
- void set_allocated_source(::std::string* source);
-
- // optional uint32 batch_size = 4;
- bool has_batch_size() const;
- void clear_batch_size();
- static const int kBatchSizeFieldNumber = 4;
- ::google::protobuf::uint32 batch_size() const;
- void set_batch_size(::google::protobuf::uint32 value);
-
- // optional uint32 rand_skip = 7 [default = 0];
- bool has_rand_skip() const;
- void clear_rand_skip();
- static const int kRandSkipFieldNumber = 7;
- ::google::protobuf::uint32 rand_skip() const;
- void set_rand_skip(::google::protobuf::uint32 value);
-
- // optional bool shuffle = 8 [default = false];
- bool has_shuffle() const;
- void clear_shuffle();
- static const int kShuffleFieldNumber = 8;
- bool shuffle() const;
- void set_shuffle(bool value);
-
- // optional uint32 new_height = 9 [default = 0];
- bool has_new_height() const;
- void clear_new_height();
- static const int kNewHeightFieldNumber = 9;
- ::google::protobuf::uint32 new_height() const;
- void set_new_height(::google::protobuf::uint32 value);
-
- // optional uint32 new_width = 10 [default = 0];
- bool has_new_width() const;
- void clear_new_width();
- static const int kNewWidthFieldNumber = 10;
- ::google::protobuf::uint32 new_width() const;
- void set_new_width(::google::protobuf::uint32 value);
-
- // optional bool is_color = 11 [default = true];
- bool has_is_color() const;
- void clear_is_color();
- static const int kIsColorFieldNumber = 11;
- bool is_color() const;
- void set_is_color(bool value);
-
- // optional float scale = 2 [default = 1];
- bool has_scale() const;
- void clear_scale();
- static const int kScaleFieldNumber = 2;
- float scale() const;
- void set_scale(float value);
-
- // optional string mean_file = 3;
- bool has_mean_file() const;
- void clear_mean_file();
- static const int kMeanFileFieldNumber = 3;
- const ::std::string& mean_file() const;
- void set_mean_file(const ::std::string& value);
- void set_mean_file(const char* value);
- void set_mean_file(const char* value, size_t size);
- ::std::string* mutable_mean_file();
- ::std::string* release_mean_file();
- void set_allocated_mean_file(::std::string* mean_file);
-
- // optional uint32 crop_size = 5 [default = 0];
- bool has_crop_size() const;
- void clear_crop_size();
- static const int kCropSizeFieldNumber = 5;
- ::google::protobuf::uint32 crop_size() const;
- void set_crop_size(::google::protobuf::uint32 value);
-
- // optional bool mirror = 6 [default = false];
- bool has_mirror() const;
- void clear_mirror();
- static const int kMirrorFieldNumber = 6;
- bool mirror() const;
- void set_mirror(bool value);
-
- // optional string root_folder = 12 [default = ""];
- bool has_root_folder() const;
- void clear_root_folder();
- static const int kRootFolderFieldNumber = 12;
- const ::std::string& root_folder() const;
- void set_root_folder(const ::std::string& value);
- void set_root_folder(const char* value);
- void set_root_folder(const char* value, size_t size);
- ::std::string* mutable_root_folder();
- ::std::string* release_root_folder();
- void set_allocated_root_folder(::std::string* root_folder);
-
- // @@protoc_insertion_point(class_scope:caffe.ImageDataParameter)
- private:
- inline void set_has_source();
- inline void clear_has_source();
- inline void set_has_batch_size();
- inline void clear_has_batch_size();
- inline void set_has_rand_skip();
- inline void clear_has_rand_skip();
- inline void set_has_shuffle();
- inline void clear_has_shuffle();
- inline void set_has_new_height();
- inline void clear_has_new_height();
- inline void set_has_new_width();
- inline void clear_has_new_width();
- inline void set_has_is_color();
- inline void clear_has_is_color();
- inline void set_has_scale();
- inline void clear_has_scale();
- inline void set_has_mean_file();
- inline void clear_has_mean_file();
- inline void set_has_crop_size();
- inline void clear_has_crop_size();
- inline void set_has_mirror();
- inline void clear_has_mirror();
- inline void set_has_root_folder();
- inline void clear_has_root_folder();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::internal::ArenaStringPtr source_;
- ::google::protobuf::internal::ArenaStringPtr mean_file_;
- ::google::protobuf::internal::ArenaStringPtr root_folder_;
- ::google::protobuf::uint32 batch_size_;
- ::google::protobuf::uint32 rand_skip_;
- ::google::protobuf::uint32 new_height_;
- ::google::protobuf::uint32 new_width_;
- bool shuffle_;
- bool mirror_;
- ::google::protobuf::uint32 crop_size_;
- bool is_color_;
- float scale_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<ImageDataParameter> ImageDataParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class InfogainLossParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.InfogainLossParameter) */ {
- public:
- InfogainLossParameter();
- virtual ~InfogainLossParameter();
-
- InfogainLossParameter(const InfogainLossParameter& from);
-
- inline InfogainLossParameter& operator=(const InfogainLossParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const InfogainLossParameter& default_instance();
-
- static const InfogainLossParameter* internal_default_instance();
-
- void Swap(InfogainLossParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline InfogainLossParameter* New() const { return New(NULL); }
-
- InfogainLossParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const InfogainLossParameter& from);
- void MergeFrom(const InfogainLossParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(InfogainLossParameter* other);
- void UnsafeMergeFrom(const InfogainLossParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional string source = 1;
- bool has_source() const;
- void clear_source();
- static const int kSourceFieldNumber = 1;
- const ::std::string& source() const;
- void set_source(const ::std::string& value);
- void set_source(const char* value);
- void set_source(const char* value, size_t size);
- ::std::string* mutable_source();
- ::std::string* release_source();
- void set_allocated_source(::std::string* source);
-
- // @@protoc_insertion_point(class_scope:caffe.InfogainLossParameter)
- private:
- inline void set_has_source();
- inline void clear_has_source();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::internal::ArenaStringPtr source_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<InfogainLossParameter> InfogainLossParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class InnerProductParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.InnerProductParameter) */ {
- public:
- InnerProductParameter();
- virtual ~InnerProductParameter();
-
- InnerProductParameter(const InnerProductParameter& from);
-
- inline InnerProductParameter& operator=(const InnerProductParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const InnerProductParameter& default_instance();
-
- static const InnerProductParameter* internal_default_instance();
-
- void Swap(InnerProductParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline InnerProductParameter* New() const { return New(NULL); }
-
- InnerProductParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const InnerProductParameter& from);
- void MergeFrom(const InnerProductParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(InnerProductParameter* other);
- void UnsafeMergeFrom(const InnerProductParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional uint32 num_output = 1;
- bool has_num_output() const;
- void clear_num_output();
- static const int kNumOutputFieldNumber = 1;
- ::google::protobuf::uint32 num_output() const;
- void set_num_output(::google::protobuf::uint32 value);
-
- // optional bool bias_term = 2 [default = true];
- bool has_bias_term() const;
- void clear_bias_term();
- static const int kBiasTermFieldNumber = 2;
- bool bias_term() const;
- void set_bias_term(bool value);
-
- // optional .caffe.FillerParameter weight_filler = 3;
- bool has_weight_filler() const;
- void clear_weight_filler();
- static const int kWeightFillerFieldNumber = 3;
- const ::caffe::FillerParameter& weight_filler() const;
- ::caffe::FillerParameter* mutable_weight_filler();
- ::caffe::FillerParameter* release_weight_filler();
- void set_allocated_weight_filler(::caffe::FillerParameter* weight_filler);
-
- // optional .caffe.FillerParameter bias_filler = 4;
- bool has_bias_filler() const;
- void clear_bias_filler();
- static const int kBiasFillerFieldNumber = 4;
- const ::caffe::FillerParameter& bias_filler() const;
- ::caffe::FillerParameter* mutable_bias_filler();
- ::caffe::FillerParameter* release_bias_filler();
- void set_allocated_bias_filler(::caffe::FillerParameter* bias_filler);
-
- // optional int32 axis = 5 [default = 1];
- bool has_axis() const;
- void clear_axis();
- static const int kAxisFieldNumber = 5;
- ::google::protobuf::int32 axis() const;
- void set_axis(::google::protobuf::int32 value);
-
- // @@protoc_insertion_point(class_scope:caffe.InnerProductParameter)
- private:
- inline void set_has_num_output();
- inline void clear_has_num_output();
- inline void set_has_bias_term();
- inline void clear_has_bias_term();
- inline void set_has_weight_filler();
- inline void clear_has_weight_filler();
- inline void set_has_bias_filler();
- inline void clear_has_bias_filler();
- inline void set_has_axis();
- inline void clear_has_axis();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::caffe::FillerParameter* weight_filler_;
- ::caffe::FillerParameter* bias_filler_;
- ::google::protobuf::uint32 num_output_;
- bool bias_term_;
- ::google::protobuf::int32 axis_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<InnerProductParameter> InnerProductParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class LogParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.LogParameter) */ {
- public:
- LogParameter();
- virtual ~LogParameter();
-
- LogParameter(const LogParameter& from);
-
- inline LogParameter& operator=(const LogParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const LogParameter& default_instance();
-
- static const LogParameter* internal_default_instance();
-
- void Swap(LogParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline LogParameter* New() const { return New(NULL); }
-
- LogParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const LogParameter& from);
- void MergeFrom(const LogParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(LogParameter* other);
- void UnsafeMergeFrom(const LogParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional float base = 1 [default = -1];
- bool has_base() const;
- void clear_base();
- static const int kBaseFieldNumber = 1;
- float base() const;
- void set_base(float value);
-
- // optional float scale = 2 [default = 1];
- bool has_scale() const;
- void clear_scale();
- static const int kScaleFieldNumber = 2;
- float scale() const;
- void set_scale(float value);
-
- // optional float shift = 3 [default = 0];
- bool has_shift() const;
- void clear_shift();
- static const int kShiftFieldNumber = 3;
- float shift() const;
- void set_shift(float value);
-
- // @@protoc_insertion_point(class_scope:caffe.LogParameter)
- private:
- inline void set_has_base();
- inline void clear_has_base();
- inline void set_has_scale();
- inline void clear_has_scale();
- inline void set_has_shift();
- inline void clear_has_shift();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- float shift_;
- float base_;
- float scale_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<LogParameter> LogParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class LRNParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.LRNParameter) */ {
- public:
- LRNParameter();
- virtual ~LRNParameter();
-
- LRNParameter(const LRNParameter& from);
-
- inline LRNParameter& operator=(const LRNParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const LRNParameter& default_instance();
-
- static const LRNParameter* internal_default_instance();
-
- void Swap(LRNParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline LRNParameter* New() const { return New(NULL); }
-
- LRNParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const LRNParameter& from);
- void MergeFrom(const LRNParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(LRNParameter* other);
- void UnsafeMergeFrom(const LRNParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- typedef LRNParameter_NormRegion NormRegion;
- static const NormRegion ACROSS_CHANNELS =
- LRNParameter_NormRegion_ACROSS_CHANNELS;
- static const NormRegion WITHIN_CHANNEL =
- LRNParameter_NormRegion_WITHIN_CHANNEL;
- static inline bool NormRegion_IsValid(int value) {
- return LRNParameter_NormRegion_IsValid(value);
- }
- static const NormRegion NormRegion_MIN =
- LRNParameter_NormRegion_NormRegion_MIN;
- static const NormRegion NormRegion_MAX =
- LRNParameter_NormRegion_NormRegion_MAX;
- static const int NormRegion_ARRAYSIZE =
- LRNParameter_NormRegion_NormRegion_ARRAYSIZE;
- static inline const ::google::protobuf::EnumDescriptor*
- NormRegion_descriptor() {
- return LRNParameter_NormRegion_descriptor();
- }
- static inline const ::std::string& NormRegion_Name(NormRegion value) {
- return LRNParameter_NormRegion_Name(value);
- }
- static inline bool NormRegion_Parse(const ::std::string& name,
- NormRegion* value) {
- return LRNParameter_NormRegion_Parse(name, value);
- }
-
- // accessors -------------------------------------------------------
-
- // optional uint32 local_size = 1 [default = 5];
- bool has_local_size() const;
- void clear_local_size();
- static const int kLocalSizeFieldNumber = 1;
- ::google::protobuf::uint32 local_size() const;
- void set_local_size(::google::protobuf::uint32 value);
-
- // optional float alpha = 2 [default = 1];
- bool has_alpha() const;
- void clear_alpha();
- static const int kAlphaFieldNumber = 2;
- float alpha() const;
- void set_alpha(float value);
-
- // optional float beta = 3 [default = 0.75];
- bool has_beta() const;
- void clear_beta();
- static const int kBetaFieldNumber = 3;
- float beta() const;
- void set_beta(float value);
-
- // optional .caffe.LRNParameter.NormRegion norm_region = 4 [default = ACROSS_CHANNELS];
- bool has_norm_region() const;
- void clear_norm_region();
- static const int kNormRegionFieldNumber = 4;
- ::caffe::LRNParameter_NormRegion norm_region() const;
- void set_norm_region(::caffe::LRNParameter_NormRegion value);
-
- // optional float k = 5 [default = 1];
- bool has_k() const;
- void clear_k();
- static const int kKFieldNumber = 5;
- float k() const;
- void set_k(float value);
-
- // @@protoc_insertion_point(class_scope:caffe.LRNParameter)
- private:
- inline void set_has_local_size();
- inline void clear_has_local_size();
- inline void set_has_alpha();
- inline void clear_has_alpha();
- inline void set_has_beta();
- inline void clear_has_beta();
- inline void set_has_norm_region();
- inline void clear_has_norm_region();
- inline void set_has_k();
- inline void clear_has_k();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- int norm_region_;
- ::google::protobuf::uint32 local_size_;
- float alpha_;
- float beta_;
- float k_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<LRNParameter> LRNParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class MemoryDataParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.MemoryDataParameter) */ {
- public:
- MemoryDataParameter();
- virtual ~MemoryDataParameter();
-
- MemoryDataParameter(const MemoryDataParameter& from);
-
- inline MemoryDataParameter& operator=(const MemoryDataParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const MemoryDataParameter& default_instance();
-
- static const MemoryDataParameter* internal_default_instance();
-
- void Swap(MemoryDataParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline MemoryDataParameter* New() const { return New(NULL); }
-
- MemoryDataParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const MemoryDataParameter& from);
- void MergeFrom(const MemoryDataParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(MemoryDataParameter* other);
- void UnsafeMergeFrom(const MemoryDataParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional uint32 batch_size = 1;
- bool has_batch_size() const;
- void clear_batch_size();
- static const int kBatchSizeFieldNumber = 1;
- ::google::protobuf::uint32 batch_size() const;
- void set_batch_size(::google::protobuf::uint32 value);
-
- // optional uint32 channels = 2;
- bool has_channels() const;
- void clear_channels();
- static const int kChannelsFieldNumber = 2;
- ::google::protobuf::uint32 channels() const;
- void set_channels(::google::protobuf::uint32 value);
-
- // optional uint32 height = 3;
- bool has_height() const;
- void clear_height();
- static const int kHeightFieldNumber = 3;
- ::google::protobuf::uint32 height() const;
- void set_height(::google::protobuf::uint32 value);
-
- // optional uint32 width = 4;
- bool has_width() const;
- void clear_width();
- static const int kWidthFieldNumber = 4;
- ::google::protobuf::uint32 width() const;
- void set_width(::google::protobuf::uint32 value);
-
- // @@protoc_insertion_point(class_scope:caffe.MemoryDataParameter)
- private:
- inline void set_has_batch_size();
- inline void clear_has_batch_size();
- inline void set_has_channels();
- inline void clear_has_channels();
- inline void set_has_height();
- inline void clear_has_height();
- inline void set_has_width();
- inline void clear_has_width();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::uint32 batch_size_;
- ::google::protobuf::uint32 channels_;
- ::google::protobuf::uint32 height_;
- ::google::protobuf::uint32 width_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<MemoryDataParameter> MemoryDataParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class MVNParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.MVNParameter) */ {
- public:
- MVNParameter();
- virtual ~MVNParameter();
-
- MVNParameter(const MVNParameter& from);
-
- inline MVNParameter& operator=(const MVNParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const MVNParameter& default_instance();
-
- static const MVNParameter* internal_default_instance();
-
- void Swap(MVNParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline MVNParameter* New() const { return New(NULL); }
-
- MVNParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const MVNParameter& from);
- void MergeFrom(const MVNParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(MVNParameter* other);
- void UnsafeMergeFrom(const MVNParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional bool normalize_variance = 1 [default = true];
- bool has_normalize_variance() const;
- void clear_normalize_variance();
- static const int kNormalizeVarianceFieldNumber = 1;
- bool normalize_variance() const;
- void set_normalize_variance(bool value);
-
- // optional bool across_channels = 2 [default = false];
- bool has_across_channels() const;
- void clear_across_channels();
- static const int kAcrossChannelsFieldNumber = 2;
- bool across_channels() const;
- void set_across_channels(bool value);
-
- // optional float eps = 3 [default = 1e-09];
- bool has_eps() const;
- void clear_eps();
- static const int kEpsFieldNumber = 3;
- float eps() const;
- void set_eps(float value);
-
- // @@protoc_insertion_point(class_scope:caffe.MVNParameter)
- private:
- inline void set_has_normalize_variance();
- inline void clear_has_normalize_variance();
- inline void set_has_across_channels();
- inline void clear_has_across_channels();
- inline void set_has_eps();
- inline void clear_has_eps();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- bool across_channels_;
- bool normalize_variance_;
- float eps_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<MVNParameter> MVNParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class PoolingParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.PoolingParameter) */ {
- public:
- PoolingParameter();
- virtual ~PoolingParameter();
-
- PoolingParameter(const PoolingParameter& from);
-
- inline PoolingParameter& operator=(const PoolingParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const PoolingParameter& default_instance();
-
- static const PoolingParameter* internal_default_instance();
-
- void Swap(PoolingParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline PoolingParameter* New() const { return New(NULL); }
-
- PoolingParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const PoolingParameter& from);
- void MergeFrom(const PoolingParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(PoolingParameter* other);
- void UnsafeMergeFrom(const PoolingParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- typedef PoolingParameter_PoolMethod PoolMethod;
- static const PoolMethod MAX =
- PoolingParameter_PoolMethod_MAX;
- static const PoolMethod AVE =
- PoolingParameter_PoolMethod_AVE;
- static const PoolMethod STOCHASTIC =
- PoolingParameter_PoolMethod_STOCHASTIC;
- static inline bool PoolMethod_IsValid(int value) {
- return PoolingParameter_PoolMethod_IsValid(value);
- }
- static const PoolMethod PoolMethod_MIN =
- PoolingParameter_PoolMethod_PoolMethod_MIN;
- static const PoolMethod PoolMethod_MAX =
- PoolingParameter_PoolMethod_PoolMethod_MAX;
- static const int PoolMethod_ARRAYSIZE =
- PoolingParameter_PoolMethod_PoolMethod_ARRAYSIZE;
- static inline const ::google::protobuf::EnumDescriptor*
- PoolMethod_descriptor() {
- return PoolingParameter_PoolMethod_descriptor();
- }
- static inline const ::std::string& PoolMethod_Name(PoolMethod value) {
- return PoolingParameter_PoolMethod_Name(value);
- }
- static inline bool PoolMethod_Parse(const ::std::string& name,
- PoolMethod* value) {
- return PoolingParameter_PoolMethod_Parse(name, value);
- }
-
- typedef PoolingParameter_Engine Engine;
- static const Engine DEFAULT =
- PoolingParameter_Engine_DEFAULT;
- static const Engine CAFFE =
- PoolingParameter_Engine_CAFFE;
- static const Engine CUDNN =
- PoolingParameter_Engine_CUDNN;
- static inline bool Engine_IsValid(int value) {
- return PoolingParameter_Engine_IsValid(value);
- }
- static const Engine Engine_MIN =
- PoolingParameter_Engine_Engine_MIN;
- static const Engine Engine_MAX =
- PoolingParameter_Engine_Engine_MAX;
- static const int Engine_ARRAYSIZE =
- PoolingParameter_Engine_Engine_ARRAYSIZE;
- static inline const ::google::protobuf::EnumDescriptor*
- Engine_descriptor() {
- return PoolingParameter_Engine_descriptor();
- }
- static inline const ::std::string& Engine_Name(Engine value) {
- return PoolingParameter_Engine_Name(value);
- }
- static inline bool Engine_Parse(const ::std::string& name,
- Engine* value) {
- return PoolingParameter_Engine_Parse(name, value);
- }
-
- // accessors -------------------------------------------------------
-
- // optional .caffe.PoolingParameter.PoolMethod pool = 1 [default = MAX];
- bool has_pool() const;
- void clear_pool();
- static const int kPoolFieldNumber = 1;
- ::caffe::PoolingParameter_PoolMethod pool() const;
- void set_pool(::caffe::PoolingParameter_PoolMethod value);
-
- // optional uint32 pad = 4 [default = 0];
- bool has_pad() const;
- void clear_pad();
- static const int kPadFieldNumber = 4;
- ::google::protobuf::uint32 pad() const;
- void set_pad(::google::protobuf::uint32 value);
-
- // optional uint32 pad_h = 9 [default = 0];
- bool has_pad_h() const;
- void clear_pad_h();
- static const int kPadHFieldNumber = 9;
- ::google::protobuf::uint32 pad_h() const;
- void set_pad_h(::google::protobuf::uint32 value);
-
- // optional uint32 pad_w = 10 [default = 0];
- bool has_pad_w() const;
- void clear_pad_w();
- static const int kPadWFieldNumber = 10;
- ::google::protobuf::uint32 pad_w() const;
- void set_pad_w(::google::protobuf::uint32 value);
-
- // optional uint32 kernel_size = 2;
- bool has_kernel_size() const;
- void clear_kernel_size();
- static const int kKernelSizeFieldNumber = 2;
- ::google::protobuf::uint32 kernel_size() const;
- void set_kernel_size(::google::protobuf::uint32 value);
-
- // optional uint32 kernel_h = 5;
- bool has_kernel_h() const;
- void clear_kernel_h();
- static const int kKernelHFieldNumber = 5;
- ::google::protobuf::uint32 kernel_h() const;
- void set_kernel_h(::google::protobuf::uint32 value);
-
- // optional uint32 kernel_w = 6;
- bool has_kernel_w() const;
- void clear_kernel_w();
- static const int kKernelWFieldNumber = 6;
- ::google::protobuf::uint32 kernel_w() const;
- void set_kernel_w(::google::protobuf::uint32 value);
-
- // optional uint32 stride = 3 [default = 1];
- bool has_stride() const;
- void clear_stride();
- static const int kStrideFieldNumber = 3;
- ::google::protobuf::uint32 stride() const;
- void set_stride(::google::protobuf::uint32 value);
-
- // optional uint32 stride_h = 7;
- bool has_stride_h() const;
- void clear_stride_h();
- static const int kStrideHFieldNumber = 7;
- ::google::protobuf::uint32 stride_h() const;
- void set_stride_h(::google::protobuf::uint32 value);
-
- // optional uint32 stride_w = 8;
- bool has_stride_w() const;
- void clear_stride_w();
- static const int kStrideWFieldNumber = 8;
- ::google::protobuf::uint32 stride_w() const;
- void set_stride_w(::google::protobuf::uint32 value);
-
- // optional .caffe.PoolingParameter.Engine engine = 11 [default = DEFAULT];
- bool has_engine() const;
- void clear_engine();
- static const int kEngineFieldNumber = 11;
- ::caffe::PoolingParameter_Engine engine() const;
- void set_engine(::caffe::PoolingParameter_Engine value);
-
- // optional bool global_pooling = 12 [default = false];
- bool has_global_pooling() const;
- void clear_global_pooling();
- static const int kGlobalPoolingFieldNumber = 12;
- bool global_pooling() const;
- void set_global_pooling(bool value);
-
- // @@protoc_insertion_point(class_scope:caffe.PoolingParameter)
- private:
- inline void set_has_pool();
- inline void clear_has_pool();
- inline void set_has_pad();
- inline void clear_has_pad();
- inline void set_has_pad_h();
- inline void clear_has_pad_h();
- inline void set_has_pad_w();
- inline void clear_has_pad_w();
- inline void set_has_kernel_size();
- inline void clear_has_kernel_size();
- inline void set_has_kernel_h();
- inline void clear_has_kernel_h();
- inline void set_has_kernel_w();
- inline void clear_has_kernel_w();
- inline void set_has_stride();
- inline void clear_has_stride();
- inline void set_has_stride_h();
- inline void clear_has_stride_h();
- inline void set_has_stride_w();
- inline void clear_has_stride_w();
- inline void set_has_engine();
- inline void clear_has_engine();
- inline void set_has_global_pooling();
- inline void clear_has_global_pooling();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- int pool_;
- ::google::protobuf::uint32 pad_;
- ::google::protobuf::uint32 pad_h_;
- ::google::protobuf::uint32 pad_w_;
- ::google::protobuf::uint32 kernel_size_;
- ::google::protobuf::uint32 kernel_h_;
- ::google::protobuf::uint32 kernel_w_;
- ::google::protobuf::uint32 stride_h_;
- ::google::protobuf::uint32 stride_w_;
- int engine_;
- bool global_pooling_;
- ::google::protobuf::uint32 stride_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<PoolingParameter> PoolingParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class PowerParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.PowerParameter) */ {
- public:
- PowerParameter();
- virtual ~PowerParameter();
-
- PowerParameter(const PowerParameter& from);
-
- inline PowerParameter& operator=(const PowerParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const PowerParameter& default_instance();
-
- static const PowerParameter* internal_default_instance();
-
- void Swap(PowerParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline PowerParameter* New() const { return New(NULL); }
-
- PowerParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const PowerParameter& from);
- void MergeFrom(const PowerParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(PowerParameter* other);
- void UnsafeMergeFrom(const PowerParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional float power = 1 [default = 1];
- bool has_power() const;
- void clear_power();
- static const int kPowerFieldNumber = 1;
- float power() const;
- void set_power(float value);
-
- // optional float scale = 2 [default = 1];
- bool has_scale() const;
- void clear_scale();
- static const int kScaleFieldNumber = 2;
- float scale() const;
- void set_scale(float value);
-
- // optional float shift = 3 [default = 0];
- bool has_shift() const;
- void clear_shift();
- static const int kShiftFieldNumber = 3;
- float shift() const;
- void set_shift(float value);
-
- // @@protoc_insertion_point(class_scope:caffe.PowerParameter)
- private:
- inline void set_has_power();
- inline void clear_has_power();
- inline void set_has_scale();
- inline void clear_has_scale();
- inline void set_has_shift();
- inline void clear_has_shift();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- float shift_;
- float power_;
- float scale_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<PowerParameter> PowerParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class PythonParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.PythonParameter) */ {
- public:
- PythonParameter();
- virtual ~PythonParameter();
-
- PythonParameter(const PythonParameter& from);
-
- inline PythonParameter& operator=(const PythonParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const PythonParameter& default_instance();
-
- static const PythonParameter* internal_default_instance();
-
- void Swap(PythonParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline PythonParameter* New() const { return New(NULL); }
-
- PythonParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const PythonParameter& from);
- void MergeFrom(const PythonParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(PythonParameter* other);
- void UnsafeMergeFrom(const PythonParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional string module = 1;
- bool has_module() const;
- void clear_module();
- static const int kModuleFieldNumber = 1;
- const ::std::string& module() const;
- void set_module(const ::std::string& value);
- void set_module(const char* value);
- void set_module(const char* value, size_t size);
- ::std::string* mutable_module();
- ::std::string* release_module();
- void set_allocated_module(::std::string* module);
-
- // optional string layer = 2;
- bool has_layer() const;
- void clear_layer();
- static const int kLayerFieldNumber = 2;
- const ::std::string& layer() const;
- void set_layer(const ::std::string& value);
- void set_layer(const char* value);
- void set_layer(const char* value, size_t size);
- ::std::string* mutable_layer();
- ::std::string* release_layer();
- void set_allocated_layer(::std::string* layer);
-
- // @@protoc_insertion_point(class_scope:caffe.PythonParameter)
- private:
- inline void set_has_module();
- inline void clear_has_module();
- inline void set_has_layer();
- inline void clear_has_layer();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::internal::ArenaStringPtr module_;
- ::google::protobuf::internal::ArenaStringPtr layer_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<PythonParameter> PythonParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class ReductionParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ReductionParameter) */ {
- public:
- ReductionParameter();
- virtual ~ReductionParameter();
-
- ReductionParameter(const ReductionParameter& from);
-
- inline ReductionParameter& operator=(const ReductionParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const ReductionParameter& default_instance();
-
- static const ReductionParameter* internal_default_instance();
-
- void Swap(ReductionParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline ReductionParameter* New() const { return New(NULL); }
-
- ReductionParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const ReductionParameter& from);
- void MergeFrom(const ReductionParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(ReductionParameter* other);
- void UnsafeMergeFrom(const ReductionParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- typedef ReductionParameter_ReductionOp ReductionOp;
- static const ReductionOp SUM =
- ReductionParameter_ReductionOp_SUM;
- static const ReductionOp ASUM =
- ReductionParameter_ReductionOp_ASUM;
- static const ReductionOp SUMSQ =
- ReductionParameter_ReductionOp_SUMSQ;
- static const ReductionOp MEAN =
- ReductionParameter_ReductionOp_MEAN;
- static inline bool ReductionOp_IsValid(int value) {
- return ReductionParameter_ReductionOp_IsValid(value);
- }
- static const ReductionOp ReductionOp_MIN =
- ReductionParameter_ReductionOp_ReductionOp_MIN;
- static const ReductionOp ReductionOp_MAX =
- ReductionParameter_ReductionOp_ReductionOp_MAX;
- static const int ReductionOp_ARRAYSIZE =
- ReductionParameter_ReductionOp_ReductionOp_ARRAYSIZE;
- static inline const ::google::protobuf::EnumDescriptor*
- ReductionOp_descriptor() {
- return ReductionParameter_ReductionOp_descriptor();
- }
- static inline const ::std::string& ReductionOp_Name(ReductionOp value) {
- return ReductionParameter_ReductionOp_Name(value);
- }
- static inline bool ReductionOp_Parse(const ::std::string& name,
- ReductionOp* value) {
- return ReductionParameter_ReductionOp_Parse(name, value);
- }
-
- // accessors -------------------------------------------------------
-
- // optional .caffe.ReductionParameter.ReductionOp operation = 1 [default = SUM];
- bool has_operation() const;
- void clear_operation();
- static const int kOperationFieldNumber = 1;
- ::caffe::ReductionParameter_ReductionOp operation() const;
- void set_operation(::caffe::ReductionParameter_ReductionOp value);
-
- // optional int32 axis = 2 [default = 0];
- bool has_axis() const;
- void clear_axis();
- static const int kAxisFieldNumber = 2;
- ::google::protobuf::int32 axis() const;
- void set_axis(::google::protobuf::int32 value);
-
- // optional float coeff = 3 [default = 1];
- bool has_coeff() const;
- void clear_coeff();
- static const int kCoeffFieldNumber = 3;
- float coeff() const;
- void set_coeff(float value);
-
- // @@protoc_insertion_point(class_scope:caffe.ReductionParameter)
- private:
- inline void set_has_operation();
- inline void clear_has_operation();
- inline void set_has_axis();
- inline void clear_has_axis();
- inline void set_has_coeff();
- inline void clear_has_coeff();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::int32 axis_;
- int operation_;
- float coeff_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<ReductionParameter> ReductionParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class ReLUParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ReLUParameter) */ {
- public:
- ReLUParameter();
- virtual ~ReLUParameter();
-
- ReLUParameter(const ReLUParameter& from);
-
- inline ReLUParameter& operator=(const ReLUParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const ReLUParameter& default_instance();
-
- static const ReLUParameter* internal_default_instance();
-
- void Swap(ReLUParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline ReLUParameter* New() const { return New(NULL); }
-
- ReLUParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const ReLUParameter& from);
- void MergeFrom(const ReLUParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(ReLUParameter* other);
- void UnsafeMergeFrom(const ReLUParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- typedef ReLUParameter_Engine Engine;
- static const Engine DEFAULT =
- ReLUParameter_Engine_DEFAULT;
- static const Engine CAFFE =
- ReLUParameter_Engine_CAFFE;
- static const Engine CUDNN =
- ReLUParameter_Engine_CUDNN;
- static inline bool Engine_IsValid(int value) {
- return ReLUParameter_Engine_IsValid(value);
- }
- static const Engine Engine_MIN =
- ReLUParameter_Engine_Engine_MIN;
- static const Engine Engine_MAX =
- ReLUParameter_Engine_Engine_MAX;
- static const int Engine_ARRAYSIZE =
- ReLUParameter_Engine_Engine_ARRAYSIZE;
- static inline const ::google::protobuf::EnumDescriptor*
- Engine_descriptor() {
- return ReLUParameter_Engine_descriptor();
- }
- static inline const ::std::string& Engine_Name(Engine value) {
- return ReLUParameter_Engine_Name(value);
- }
- static inline bool Engine_Parse(const ::std::string& name,
- Engine* value) {
- return ReLUParameter_Engine_Parse(name, value);
- }
-
- // accessors -------------------------------------------------------
-
- // optional float negative_slope = 1 [default = 0];
- bool has_negative_slope() const;
- void clear_negative_slope();
- static const int kNegativeSlopeFieldNumber = 1;
- float negative_slope() const;
- void set_negative_slope(float value);
-
- // optional .caffe.ReLUParameter.Engine engine = 2 [default = DEFAULT];
- bool has_engine() const;
- void clear_engine();
- static const int kEngineFieldNumber = 2;
- ::caffe::ReLUParameter_Engine engine() const;
- void set_engine(::caffe::ReLUParameter_Engine value);
-
- // @@protoc_insertion_point(class_scope:caffe.ReLUParameter)
- private:
- inline void set_has_negative_slope();
- inline void clear_has_negative_slope();
- inline void set_has_engine();
- inline void clear_has_engine();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- float negative_slope_;
- int engine_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<ReLUParameter> ReLUParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class ReshapeParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ReshapeParameter) */ {
- public:
- ReshapeParameter();
- virtual ~ReshapeParameter();
-
- ReshapeParameter(const ReshapeParameter& from);
-
- inline ReshapeParameter& operator=(const ReshapeParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const ReshapeParameter& default_instance();
-
- static const ReshapeParameter* internal_default_instance();
-
- void Swap(ReshapeParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline ReshapeParameter* New() const { return New(NULL); }
-
- ReshapeParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const ReshapeParameter& from);
- void MergeFrom(const ReshapeParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(ReshapeParameter* other);
- void UnsafeMergeFrom(const ReshapeParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional .caffe.BlobShape shape = 1;
- bool has_shape() const;
- void clear_shape();
- static const int kShapeFieldNumber = 1;
- const ::caffe::BlobShape& shape() const;
- ::caffe::BlobShape* mutable_shape();
- ::caffe::BlobShape* release_shape();
- void set_allocated_shape(::caffe::BlobShape* shape);
-
- // optional int32 axis = 2 [default = 0];
- bool has_axis() const;
- void clear_axis();
- static const int kAxisFieldNumber = 2;
- ::google::protobuf::int32 axis() const;
- void set_axis(::google::protobuf::int32 value);
-
- // optional int32 num_axes = 3 [default = -1];
- bool has_num_axes() const;
- void clear_num_axes();
- static const int kNumAxesFieldNumber = 3;
- ::google::protobuf::int32 num_axes() const;
- void set_num_axes(::google::protobuf::int32 value);
-
- // @@protoc_insertion_point(class_scope:caffe.ReshapeParameter)
- private:
- inline void set_has_shape();
- inline void clear_has_shape();
- inline void set_has_axis();
- inline void clear_has_axis();
- inline void set_has_num_axes();
- inline void clear_has_num_axes();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::caffe::BlobShape* shape_;
- ::google::protobuf::int32 axis_;
- ::google::protobuf::int32 num_axes_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<ReshapeParameter> ReshapeParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class SigmoidParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.SigmoidParameter) */ {
- public:
- SigmoidParameter();
- virtual ~SigmoidParameter();
-
- SigmoidParameter(const SigmoidParameter& from);
-
- inline SigmoidParameter& operator=(const SigmoidParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const SigmoidParameter& default_instance();
-
- static const SigmoidParameter* internal_default_instance();
-
- void Swap(SigmoidParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline SigmoidParameter* New() const { return New(NULL); }
-
- SigmoidParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const SigmoidParameter& from);
- void MergeFrom(const SigmoidParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(SigmoidParameter* other);
- void UnsafeMergeFrom(const SigmoidParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- typedef SigmoidParameter_Engine Engine;
- static const Engine DEFAULT =
- SigmoidParameter_Engine_DEFAULT;
- static const Engine CAFFE =
- SigmoidParameter_Engine_CAFFE;
- static const Engine CUDNN =
- SigmoidParameter_Engine_CUDNN;
- static inline bool Engine_IsValid(int value) {
- return SigmoidParameter_Engine_IsValid(value);
- }
- static const Engine Engine_MIN =
- SigmoidParameter_Engine_Engine_MIN;
- static const Engine Engine_MAX =
- SigmoidParameter_Engine_Engine_MAX;
- static const int Engine_ARRAYSIZE =
- SigmoidParameter_Engine_Engine_ARRAYSIZE;
- static inline const ::google::protobuf::EnumDescriptor*
- Engine_descriptor() {
- return SigmoidParameter_Engine_descriptor();
- }
- static inline const ::std::string& Engine_Name(Engine value) {
- return SigmoidParameter_Engine_Name(value);
- }
- static inline bool Engine_Parse(const ::std::string& name,
- Engine* value) {
- return SigmoidParameter_Engine_Parse(name, value);
- }
-
- // accessors -------------------------------------------------------
-
- // optional .caffe.SigmoidParameter.Engine engine = 1 [default = DEFAULT];
- bool has_engine() const;
- void clear_engine();
- static const int kEngineFieldNumber = 1;
- ::caffe::SigmoidParameter_Engine engine() const;
- void set_engine(::caffe::SigmoidParameter_Engine value);
-
- // @@protoc_insertion_point(class_scope:caffe.SigmoidParameter)
- private:
- inline void set_has_engine();
- inline void clear_has_engine();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- int engine_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<SigmoidParameter> SigmoidParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class SliceParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.SliceParameter) */ {
- public:
- SliceParameter();
- virtual ~SliceParameter();
-
- SliceParameter(const SliceParameter& from);
-
- inline SliceParameter& operator=(const SliceParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const SliceParameter& default_instance();
-
- static const SliceParameter* internal_default_instance();
-
- void Swap(SliceParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline SliceParameter* New() const { return New(NULL); }
-
- SliceParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const SliceParameter& from);
- void MergeFrom(const SliceParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(SliceParameter* other);
- void UnsafeMergeFrom(const SliceParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional int32 axis = 3 [default = 1];
- bool has_axis() const;
- void clear_axis();
- static const int kAxisFieldNumber = 3;
- ::google::protobuf::int32 axis() const;
- void set_axis(::google::protobuf::int32 value);
-
- // repeated uint32 slice_point = 2;
- int slice_point_size() const;
- void clear_slice_point();
- static const int kSlicePointFieldNumber = 2;
- ::google::protobuf::uint32 slice_point(int index) const;
- void set_slice_point(int index, ::google::protobuf::uint32 value);
- void add_slice_point(::google::protobuf::uint32 value);
- const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
- slice_point() const;
- ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
- mutable_slice_point();
-
- // optional uint32 slice_dim = 1 [default = 1];
- bool has_slice_dim() const;
- void clear_slice_dim();
- static const int kSliceDimFieldNumber = 1;
- ::google::protobuf::uint32 slice_dim() const;
- void set_slice_dim(::google::protobuf::uint32 value);
-
- // @@protoc_insertion_point(class_scope:caffe.SliceParameter)
- private:
- inline void set_has_axis();
- inline void clear_has_axis();
- inline void set_has_slice_dim();
- inline void clear_has_slice_dim();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > slice_point_;
- ::google::protobuf::int32 axis_;
- ::google::protobuf::uint32 slice_dim_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<SliceParameter> SliceParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class SoftmaxParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.SoftmaxParameter) */ {
- public:
- SoftmaxParameter();
- virtual ~SoftmaxParameter();
-
- SoftmaxParameter(const SoftmaxParameter& from);
-
- inline SoftmaxParameter& operator=(const SoftmaxParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const SoftmaxParameter& default_instance();
-
- static const SoftmaxParameter* internal_default_instance();
-
- void Swap(SoftmaxParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline SoftmaxParameter* New() const { return New(NULL); }
-
- SoftmaxParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const SoftmaxParameter& from);
- void MergeFrom(const SoftmaxParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(SoftmaxParameter* other);
- void UnsafeMergeFrom(const SoftmaxParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- typedef SoftmaxParameter_Engine Engine;
- static const Engine DEFAULT =
- SoftmaxParameter_Engine_DEFAULT;
- static const Engine CAFFE =
- SoftmaxParameter_Engine_CAFFE;
- static const Engine CUDNN =
- SoftmaxParameter_Engine_CUDNN;
- static inline bool Engine_IsValid(int value) {
- return SoftmaxParameter_Engine_IsValid(value);
- }
- static const Engine Engine_MIN =
- SoftmaxParameter_Engine_Engine_MIN;
- static const Engine Engine_MAX =
- SoftmaxParameter_Engine_Engine_MAX;
- static const int Engine_ARRAYSIZE =
- SoftmaxParameter_Engine_Engine_ARRAYSIZE;
- static inline const ::google::protobuf::EnumDescriptor*
- Engine_descriptor() {
- return SoftmaxParameter_Engine_descriptor();
- }
- static inline const ::std::string& Engine_Name(Engine value) {
- return SoftmaxParameter_Engine_Name(value);
- }
- static inline bool Engine_Parse(const ::std::string& name,
- Engine* value) {
- return SoftmaxParameter_Engine_Parse(name, value);
- }
-
- // accessors -------------------------------------------------------
-
- // optional .caffe.SoftmaxParameter.Engine engine = 1 [default = DEFAULT];
- bool has_engine() const;
- void clear_engine();
- static const int kEngineFieldNumber = 1;
- ::caffe::SoftmaxParameter_Engine engine() const;
- void set_engine(::caffe::SoftmaxParameter_Engine value);
-
- // optional int32 axis = 2 [default = 1];
- bool has_axis() const;
- void clear_axis();
- static const int kAxisFieldNumber = 2;
- ::google::protobuf::int32 axis() const;
- void set_axis(::google::protobuf::int32 value);
-
- // @@protoc_insertion_point(class_scope:caffe.SoftmaxParameter)
- private:
- inline void set_has_engine();
- inline void clear_has_engine();
- inline void set_has_axis();
- inline void clear_has_axis();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- int engine_;
- ::google::protobuf::int32 axis_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<SoftmaxParameter> SoftmaxParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class TanHParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.TanHParameter) */ {
- public:
- TanHParameter();
- virtual ~TanHParameter();
-
- TanHParameter(const TanHParameter& from);
-
- inline TanHParameter& operator=(const TanHParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const TanHParameter& default_instance();
-
- static const TanHParameter* internal_default_instance();
-
- void Swap(TanHParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline TanHParameter* New() const { return New(NULL); }
-
- TanHParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const TanHParameter& from);
- void MergeFrom(const TanHParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(TanHParameter* other);
- void UnsafeMergeFrom(const TanHParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- typedef TanHParameter_Engine Engine;
- static const Engine DEFAULT =
- TanHParameter_Engine_DEFAULT;
- static const Engine CAFFE =
- TanHParameter_Engine_CAFFE;
- static const Engine CUDNN =
- TanHParameter_Engine_CUDNN;
- static inline bool Engine_IsValid(int value) {
- return TanHParameter_Engine_IsValid(value);
- }
- static const Engine Engine_MIN =
- TanHParameter_Engine_Engine_MIN;
- static const Engine Engine_MAX =
- TanHParameter_Engine_Engine_MAX;
- static const int Engine_ARRAYSIZE =
- TanHParameter_Engine_Engine_ARRAYSIZE;
- static inline const ::google::protobuf::EnumDescriptor*
- Engine_descriptor() {
- return TanHParameter_Engine_descriptor();
- }
- static inline const ::std::string& Engine_Name(Engine value) {
- return TanHParameter_Engine_Name(value);
- }
- static inline bool Engine_Parse(const ::std::string& name,
- Engine* value) {
- return TanHParameter_Engine_Parse(name, value);
- }
-
- // accessors -------------------------------------------------------
-
- // optional .caffe.TanHParameter.Engine engine = 1 [default = DEFAULT];
- bool has_engine() const;
- void clear_engine();
- static const int kEngineFieldNumber = 1;
- ::caffe::TanHParameter_Engine engine() const;
- void set_engine(::caffe::TanHParameter_Engine value);
-
- // @@protoc_insertion_point(class_scope:caffe.TanHParameter)
- private:
- inline void set_has_engine();
- inline void clear_has_engine();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- int engine_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<TanHParameter> TanHParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class ThresholdParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ThresholdParameter) */ {
- public:
- ThresholdParameter();
- virtual ~ThresholdParameter();
-
- ThresholdParameter(const ThresholdParameter& from);
-
- inline ThresholdParameter& operator=(const ThresholdParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const ThresholdParameter& default_instance();
-
- static const ThresholdParameter* internal_default_instance();
-
- void Swap(ThresholdParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline ThresholdParameter* New() const { return New(NULL); }
-
- ThresholdParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const ThresholdParameter& from);
- void MergeFrom(const ThresholdParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(ThresholdParameter* other);
- void UnsafeMergeFrom(const ThresholdParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional float threshold = 1 [default = 0];
- bool has_threshold() const;
- void clear_threshold();
- static const int kThresholdFieldNumber = 1;
- float threshold() const;
- void set_threshold(float value);
-
- // @@protoc_insertion_point(class_scope:caffe.ThresholdParameter)
- private:
- inline void set_has_threshold();
- inline void clear_has_threshold();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- float threshold_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<ThresholdParameter> ThresholdParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class WindowDataParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.WindowDataParameter) */ {
- public:
- WindowDataParameter();
- virtual ~WindowDataParameter();
-
- WindowDataParameter(const WindowDataParameter& from);
-
- inline WindowDataParameter& operator=(const WindowDataParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const WindowDataParameter& default_instance();
-
- static const WindowDataParameter* internal_default_instance();
-
- void Swap(WindowDataParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline WindowDataParameter* New() const { return New(NULL); }
-
- WindowDataParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const WindowDataParameter& from);
- void MergeFrom(const WindowDataParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(WindowDataParameter* other);
- void UnsafeMergeFrom(const WindowDataParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional string source = 1;
- bool has_source() const;
- void clear_source();
- static const int kSourceFieldNumber = 1;
- const ::std::string& source() const;
- void set_source(const ::std::string& value);
- void set_source(const char* value);
- void set_source(const char* value, size_t size);
- ::std::string* mutable_source();
- ::std::string* release_source();
- void set_allocated_source(::std::string* source);
-
- // optional float scale = 2 [default = 1];
- bool has_scale() const;
- void clear_scale();
- static const int kScaleFieldNumber = 2;
- float scale() const;
- void set_scale(float value);
-
- // optional string mean_file = 3;
- bool has_mean_file() const;
- void clear_mean_file();
- static const int kMeanFileFieldNumber = 3;
- const ::std::string& mean_file() const;
- void set_mean_file(const ::std::string& value);
- void set_mean_file(const char* value);
- void set_mean_file(const char* value, size_t size);
- ::std::string* mutable_mean_file();
- ::std::string* release_mean_file();
- void set_allocated_mean_file(::std::string* mean_file);
-
- // optional uint32 batch_size = 4;
- bool has_batch_size() const;
- void clear_batch_size();
- static const int kBatchSizeFieldNumber = 4;
- ::google::protobuf::uint32 batch_size() const;
- void set_batch_size(::google::protobuf::uint32 value);
-
- // optional uint32 crop_size = 5 [default = 0];
- bool has_crop_size() const;
- void clear_crop_size();
- static const int kCropSizeFieldNumber = 5;
- ::google::protobuf::uint32 crop_size() const;
- void set_crop_size(::google::protobuf::uint32 value);
-
- // optional bool mirror = 6 [default = false];
- bool has_mirror() const;
- void clear_mirror();
- static const int kMirrorFieldNumber = 6;
- bool mirror() const;
- void set_mirror(bool value);
-
- // optional float fg_threshold = 7 [default = 0.5];
- bool has_fg_threshold() const;
- void clear_fg_threshold();
- static const int kFgThresholdFieldNumber = 7;
- float fg_threshold() const;
- void set_fg_threshold(float value);
-
- // optional float bg_threshold = 8 [default = 0.5];
- bool has_bg_threshold() const;
- void clear_bg_threshold();
- static const int kBgThresholdFieldNumber = 8;
- float bg_threshold() const;
- void set_bg_threshold(float value);
-
- // optional float fg_fraction = 9 [default = 0.25];
- bool has_fg_fraction() const;
- void clear_fg_fraction();
- static const int kFgFractionFieldNumber = 9;
- float fg_fraction() const;
- void set_fg_fraction(float value);
-
- // optional uint32 context_pad = 10 [default = 0];
- bool has_context_pad() const;
- void clear_context_pad();
- static const int kContextPadFieldNumber = 10;
- ::google::protobuf::uint32 context_pad() const;
- void set_context_pad(::google::protobuf::uint32 value);
-
- // optional string crop_mode = 11 [default = "warp"];
- bool has_crop_mode() const;
- void clear_crop_mode();
- static const int kCropModeFieldNumber = 11;
- const ::std::string& crop_mode() const;
- void set_crop_mode(const ::std::string& value);
- void set_crop_mode(const char* value);
- void set_crop_mode(const char* value, size_t size);
- ::std::string* mutable_crop_mode();
- ::std::string* release_crop_mode();
- void set_allocated_crop_mode(::std::string* crop_mode);
-
- // optional bool cache_images = 12 [default = false];
- bool has_cache_images() const;
- void clear_cache_images();
- static const int kCacheImagesFieldNumber = 12;
- bool cache_images() const;
- void set_cache_images(bool value);
-
- // optional string root_folder = 13 [default = ""];
- bool has_root_folder() const;
- void clear_root_folder();
- static const int kRootFolderFieldNumber = 13;
- const ::std::string& root_folder() const;
- void set_root_folder(const ::std::string& value);
- void set_root_folder(const char* value);
- void set_root_folder(const char* value, size_t size);
- ::std::string* mutable_root_folder();
- ::std::string* release_root_folder();
- void set_allocated_root_folder(::std::string* root_folder);
-
- // @@protoc_insertion_point(class_scope:caffe.WindowDataParameter)
- private:
- inline void set_has_source();
- inline void clear_has_source();
- inline void set_has_scale();
- inline void clear_has_scale();
- inline void set_has_mean_file();
- inline void clear_has_mean_file();
- inline void set_has_batch_size();
- inline void clear_has_batch_size();
- inline void set_has_crop_size();
- inline void clear_has_crop_size();
- inline void set_has_mirror();
- inline void clear_has_mirror();
- inline void set_has_fg_threshold();
- inline void clear_has_fg_threshold();
- inline void set_has_bg_threshold();
- inline void clear_has_bg_threshold();
- inline void set_has_fg_fraction();
- inline void clear_has_fg_fraction();
- inline void set_has_context_pad();
- inline void clear_has_context_pad();
- inline void set_has_crop_mode();
- inline void clear_has_crop_mode();
- inline void set_has_cache_images();
- inline void clear_has_cache_images();
- inline void set_has_root_folder();
- inline void clear_has_root_folder();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::internal::ArenaStringPtr source_;
- ::google::protobuf::internal::ArenaStringPtr mean_file_;
- static ::std::string* _default_crop_mode_;
- ::google::protobuf::internal::ArenaStringPtr crop_mode_;
- ::google::protobuf::internal::ArenaStringPtr root_folder_;
- ::google::protobuf::uint32 batch_size_;
- ::google::protobuf::uint32 crop_size_;
- bool mirror_;
- bool cache_images_;
- ::google::protobuf::uint32 context_pad_;
- float scale_;
- float fg_threshold_;
- float bg_threshold_;
- float fg_fraction_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<WindowDataParameter> WindowDataParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class SPPParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.SPPParameter) */ {
- public:
- SPPParameter();
- virtual ~SPPParameter();
-
- SPPParameter(const SPPParameter& from);
-
- inline SPPParameter& operator=(const SPPParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const SPPParameter& default_instance();
-
- static const SPPParameter* internal_default_instance();
-
- void Swap(SPPParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline SPPParameter* New() const { return New(NULL); }
-
- SPPParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const SPPParameter& from);
- void MergeFrom(const SPPParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(SPPParameter* other);
- void UnsafeMergeFrom(const SPPParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- typedef SPPParameter_PoolMethod PoolMethod;
- static const PoolMethod MAX =
- SPPParameter_PoolMethod_MAX;
- static const PoolMethod AVE =
- SPPParameter_PoolMethod_AVE;
- static const PoolMethod STOCHASTIC =
- SPPParameter_PoolMethod_STOCHASTIC;
- static inline bool PoolMethod_IsValid(int value) {
- return SPPParameter_PoolMethod_IsValid(value);
- }
- static const PoolMethod PoolMethod_MIN =
- SPPParameter_PoolMethod_PoolMethod_MIN;
- static const PoolMethod PoolMethod_MAX =
- SPPParameter_PoolMethod_PoolMethod_MAX;
- static const int PoolMethod_ARRAYSIZE =
- SPPParameter_PoolMethod_PoolMethod_ARRAYSIZE;
- static inline const ::google::protobuf::EnumDescriptor*
- PoolMethod_descriptor() {
- return SPPParameter_PoolMethod_descriptor();
- }
- static inline const ::std::string& PoolMethod_Name(PoolMethod value) {
- return SPPParameter_PoolMethod_Name(value);
- }
- static inline bool PoolMethod_Parse(const ::std::string& name,
- PoolMethod* value) {
- return SPPParameter_PoolMethod_Parse(name, value);
- }
-
- typedef SPPParameter_Engine Engine;
- static const Engine DEFAULT =
- SPPParameter_Engine_DEFAULT;
- static const Engine CAFFE =
- SPPParameter_Engine_CAFFE;
- static const Engine CUDNN =
- SPPParameter_Engine_CUDNN;
- static inline bool Engine_IsValid(int value) {
- return SPPParameter_Engine_IsValid(value);
- }
- static const Engine Engine_MIN =
- SPPParameter_Engine_Engine_MIN;
- static const Engine Engine_MAX =
- SPPParameter_Engine_Engine_MAX;
- static const int Engine_ARRAYSIZE =
- SPPParameter_Engine_Engine_ARRAYSIZE;
- static inline const ::google::protobuf::EnumDescriptor*
- Engine_descriptor() {
- return SPPParameter_Engine_descriptor();
- }
- static inline const ::std::string& Engine_Name(Engine value) {
- return SPPParameter_Engine_Name(value);
- }
- static inline bool Engine_Parse(const ::std::string& name,
- Engine* value) {
- return SPPParameter_Engine_Parse(name, value);
- }
-
- // accessors -------------------------------------------------------
-
- // optional uint32 pyramid_height = 1;
- bool has_pyramid_height() const;
- void clear_pyramid_height();
- static const int kPyramidHeightFieldNumber = 1;
- ::google::protobuf::uint32 pyramid_height() const;
- void set_pyramid_height(::google::protobuf::uint32 value);
-
- // optional .caffe.SPPParameter.PoolMethod pool = 2 [default = MAX];
- bool has_pool() const;
- void clear_pool();
- static const int kPoolFieldNumber = 2;
- ::caffe::SPPParameter_PoolMethod pool() const;
- void set_pool(::caffe::SPPParameter_PoolMethod value);
-
- // optional .caffe.SPPParameter.Engine engine = 6 [default = DEFAULT];
- bool has_engine() const;
- void clear_engine();
- static const int kEngineFieldNumber = 6;
- ::caffe::SPPParameter_Engine engine() const;
- void set_engine(::caffe::SPPParameter_Engine value);
-
- // @@protoc_insertion_point(class_scope:caffe.SPPParameter)
- private:
- inline void set_has_pyramid_height();
- inline void clear_has_pyramid_height();
- inline void set_has_pool();
- inline void clear_has_pool();
- inline void set_has_engine();
- inline void clear_has_engine();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::google::protobuf::uint32 pyramid_height_;
- int pool_;
- int engine_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<SPPParameter> SPPParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class V1LayerParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.V1LayerParameter) */ {
- public:
- V1LayerParameter();
- virtual ~V1LayerParameter();
-
- V1LayerParameter(const V1LayerParameter& from);
-
- inline V1LayerParameter& operator=(const V1LayerParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const V1LayerParameter& default_instance();
-
- static const V1LayerParameter* internal_default_instance();
-
- void Swap(V1LayerParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline V1LayerParameter* New() const { return New(NULL); }
-
- V1LayerParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const V1LayerParameter& from);
- void MergeFrom(const V1LayerParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(V1LayerParameter* other);
- void UnsafeMergeFrom(const V1LayerParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- typedef V1LayerParameter_LayerType LayerType;
- static const LayerType NONE =
- V1LayerParameter_LayerType_NONE;
- static const LayerType ABSVAL =
- V1LayerParameter_LayerType_ABSVAL;
- static const LayerType ACCURACY =
- V1LayerParameter_LayerType_ACCURACY;
- static const LayerType ARGMAX =
- V1LayerParameter_LayerType_ARGMAX;
- static const LayerType BNLL =
- V1LayerParameter_LayerType_BNLL;
- static const LayerType CONCAT =
- V1LayerParameter_LayerType_CONCAT;
- static const LayerType CONTRASTIVE_LOSS =
- V1LayerParameter_LayerType_CONTRASTIVE_LOSS;
- static const LayerType CONVOLUTION =
- V1LayerParameter_LayerType_CONVOLUTION;
- static const LayerType DATA =
- V1LayerParameter_LayerType_DATA;
- static const LayerType DECONVOLUTION =
- V1LayerParameter_LayerType_DECONVOLUTION;
- static const LayerType DROPOUT =
- V1LayerParameter_LayerType_DROPOUT;
- static const LayerType DUMMY_DATA =
- V1LayerParameter_LayerType_DUMMY_DATA;
- static const LayerType EUCLIDEAN_LOSS =
- V1LayerParameter_LayerType_EUCLIDEAN_LOSS;
- static const LayerType ELTWISE =
- V1LayerParameter_LayerType_ELTWISE;
- static const LayerType EXP =
- V1LayerParameter_LayerType_EXP;
- static const LayerType FLATTEN =
- V1LayerParameter_LayerType_FLATTEN;
- static const LayerType HDF5_DATA =
- V1LayerParameter_LayerType_HDF5_DATA;
- static const LayerType HDF5_OUTPUT =
- V1LayerParameter_LayerType_HDF5_OUTPUT;
- static const LayerType HINGE_LOSS =
- V1LayerParameter_LayerType_HINGE_LOSS;
- static const LayerType IM2COL =
- V1LayerParameter_LayerType_IM2COL;
- static const LayerType IMAGE_DATA =
- V1LayerParameter_LayerType_IMAGE_DATA;
- static const LayerType INFOGAIN_LOSS =
- V1LayerParameter_LayerType_INFOGAIN_LOSS;
- static const LayerType INNER_PRODUCT =
- V1LayerParameter_LayerType_INNER_PRODUCT;
- static const LayerType LRN =
- V1LayerParameter_LayerType_LRN;
- static const LayerType MEMORY_DATA =
- V1LayerParameter_LayerType_MEMORY_DATA;
- static const LayerType MULTINOMIAL_LOGISTIC_LOSS =
- V1LayerParameter_LayerType_MULTINOMIAL_LOGISTIC_LOSS;
- static const LayerType MVN =
- V1LayerParameter_LayerType_MVN;
- static const LayerType POOLING =
- V1LayerParameter_LayerType_POOLING;
- static const LayerType POWER =
- V1LayerParameter_LayerType_POWER;
- static const LayerType RELU =
- V1LayerParameter_LayerType_RELU;
- static const LayerType SIGMOID =
- V1LayerParameter_LayerType_SIGMOID;
- static const LayerType SIGMOID_CROSS_ENTROPY_LOSS =
- V1LayerParameter_LayerType_SIGMOID_CROSS_ENTROPY_LOSS;
- static const LayerType SILENCE =
- V1LayerParameter_LayerType_SILENCE;
- static const LayerType SOFTMAX =
- V1LayerParameter_LayerType_SOFTMAX;
- static const LayerType SOFTMAX_LOSS =
- V1LayerParameter_LayerType_SOFTMAX_LOSS;
- static const LayerType SPLIT =
- V1LayerParameter_LayerType_SPLIT;
- static const LayerType SLICE =
- V1LayerParameter_LayerType_SLICE;
- static const LayerType TANH =
- V1LayerParameter_LayerType_TANH;
- static const LayerType WINDOW_DATA =
- V1LayerParameter_LayerType_WINDOW_DATA;
- static const LayerType THRESHOLD =
- V1LayerParameter_LayerType_THRESHOLD;
- static inline bool LayerType_IsValid(int value) {
- return V1LayerParameter_LayerType_IsValid(value);
- }
- static const LayerType LayerType_MIN =
- V1LayerParameter_LayerType_LayerType_MIN;
- static const LayerType LayerType_MAX =
- V1LayerParameter_LayerType_LayerType_MAX;
- static const int LayerType_ARRAYSIZE =
- V1LayerParameter_LayerType_LayerType_ARRAYSIZE;
- static inline const ::google::protobuf::EnumDescriptor*
- LayerType_descriptor() {
- return V1LayerParameter_LayerType_descriptor();
- }
- static inline const ::std::string& LayerType_Name(LayerType value) {
- return V1LayerParameter_LayerType_Name(value);
- }
- static inline bool LayerType_Parse(const ::std::string& name,
- LayerType* value) {
- return V1LayerParameter_LayerType_Parse(name, value);
- }
-
- typedef V1LayerParameter_DimCheckMode DimCheckMode;
- static const DimCheckMode STRICT =
- V1LayerParameter_DimCheckMode_STRICT;
- static const DimCheckMode PERMISSIVE =
- V1LayerParameter_DimCheckMode_PERMISSIVE;
- static inline bool DimCheckMode_IsValid(int value) {
- return V1LayerParameter_DimCheckMode_IsValid(value);
- }
- static const DimCheckMode DimCheckMode_MIN =
- V1LayerParameter_DimCheckMode_DimCheckMode_MIN;
- static const DimCheckMode DimCheckMode_MAX =
- V1LayerParameter_DimCheckMode_DimCheckMode_MAX;
- static const int DimCheckMode_ARRAYSIZE =
- V1LayerParameter_DimCheckMode_DimCheckMode_ARRAYSIZE;
- static inline const ::google::protobuf::EnumDescriptor*
- DimCheckMode_descriptor() {
- return V1LayerParameter_DimCheckMode_descriptor();
- }
- static inline const ::std::string& DimCheckMode_Name(DimCheckMode value) {
- return V1LayerParameter_DimCheckMode_Name(value);
- }
- static inline bool DimCheckMode_Parse(const ::std::string& name,
- DimCheckMode* value) {
- return V1LayerParameter_DimCheckMode_Parse(name, value);
- }
-
- // accessors -------------------------------------------------------
-
- // repeated string bottom = 2;
- int bottom_size() const;
- void clear_bottom();
- static const int kBottomFieldNumber = 2;
- const ::std::string& bottom(int index) const;
- ::std::string* mutable_bottom(int index);
- void set_bottom(int index, const ::std::string& value);
- void set_bottom(int index, const char* value);
- void set_bottom(int index, const char* value, size_t size);
- ::std::string* add_bottom();
- void add_bottom(const ::std::string& value);
- void add_bottom(const char* value);
- void add_bottom(const char* value, size_t size);
- const ::google::protobuf::RepeatedPtrField< ::std::string>& bottom() const;
- ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_bottom();
-
- // repeated string top = 3;
- int top_size() const;
- void clear_top();
- static const int kTopFieldNumber = 3;
- const ::std::string& top(int index) const;
- ::std::string* mutable_top(int index);
- void set_top(int index, const ::std::string& value);
- void set_top(int index, const char* value);
- void set_top(int index, const char* value, size_t size);
- ::std::string* add_top();
- void add_top(const ::std::string& value);
- void add_top(const char* value);
- void add_top(const char* value, size_t size);
- const ::google::protobuf::RepeatedPtrField< ::std::string>& top() const;
- ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_top();
-
- // optional string name = 4;
- bool has_name() const;
- void clear_name();
- static const int kNameFieldNumber = 4;
- const ::std::string& name() const;
- void set_name(const ::std::string& value);
- void set_name(const char* value);
- void set_name(const char* value, size_t size);
- ::std::string* mutable_name();
- ::std::string* release_name();
- void set_allocated_name(::std::string* name);
-
- // repeated .caffe.NetStateRule include = 32;
- int include_size() const;
- void clear_include();
- static const int kIncludeFieldNumber = 32;
- const ::caffe::NetStateRule& include(int index) const;
- ::caffe::NetStateRule* mutable_include(int index);
- ::caffe::NetStateRule* add_include();
- ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >*
- mutable_include();
- const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >&
- include() const;
-
- // repeated .caffe.NetStateRule exclude = 33;
- int exclude_size() const;
- void clear_exclude();
- static const int kExcludeFieldNumber = 33;
- const ::caffe::NetStateRule& exclude(int index) const;
- ::caffe::NetStateRule* mutable_exclude(int index);
- ::caffe::NetStateRule* add_exclude();
- ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >*
- mutable_exclude();
- const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >&
- exclude() const;
-
- // optional .caffe.V1LayerParameter.LayerType type = 5;
- bool has_type() const;
- void clear_type();
- static const int kTypeFieldNumber = 5;
- ::caffe::V1LayerParameter_LayerType type() const;
- void set_type(::caffe::V1LayerParameter_LayerType value);
-
- // repeated .caffe.BlobProto blobs = 6;
- int blobs_size() const;
- void clear_blobs();
- static const int kBlobsFieldNumber = 6;
- const ::caffe::BlobProto& blobs(int index) const;
- ::caffe::BlobProto* mutable_blobs(int index);
- ::caffe::BlobProto* add_blobs();
- ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
- mutable_blobs();
- const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
- blobs() const;
-
- // repeated string param = 1001;
- int param_size() const;
- void clear_param();
- static const int kParamFieldNumber = 1001;
- const ::std::string& param(int index) const;
- ::std::string* mutable_param(int index);
- void set_param(int index, const ::std::string& value);
- void set_param(int index, const char* value);
- void set_param(int index, const char* value, size_t size);
- ::std::string* add_param();
- void add_param(const ::std::string& value);
- void add_param(const char* value);
- void add_param(const char* value, size_t size);
- const ::google::protobuf::RepeatedPtrField< ::std::string>& param() const;
- ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_param();
-
- // repeated .caffe.V1LayerParameter.DimCheckMode blob_share_mode = 1002;
- int blob_share_mode_size() const;
- void clear_blob_share_mode();
- static const int kBlobShareModeFieldNumber = 1002;
- ::caffe::V1LayerParameter_DimCheckMode blob_share_mode(int index) const;
- void set_blob_share_mode(int index, ::caffe::V1LayerParameter_DimCheckMode value);
- void add_blob_share_mode(::caffe::V1LayerParameter_DimCheckMode value);
- const ::google::protobuf::RepeatedField<int>& blob_share_mode() const;
- ::google::protobuf::RepeatedField<int>* mutable_blob_share_mode();
-
- // repeated float blobs_lr = 7;
- int blobs_lr_size() const;
- void clear_blobs_lr();
- static const int kBlobsLrFieldNumber = 7;
- float blobs_lr(int index) const;
- void set_blobs_lr(int index, float value);
- void add_blobs_lr(float value);
- const ::google::protobuf::RepeatedField< float >&
- blobs_lr() const;
- ::google::protobuf::RepeatedField< float >*
- mutable_blobs_lr();
-
- // repeated float weight_decay = 8;
- int weight_decay_size() const;
- void clear_weight_decay();
- static const int kWeightDecayFieldNumber = 8;
- float weight_decay(int index) const;
- void set_weight_decay(int index, float value);
- void add_weight_decay(float value);
- const ::google::protobuf::RepeatedField< float >&
- weight_decay() const;
- ::google::protobuf::RepeatedField< float >*
- mutable_weight_decay();
-
- // repeated float loss_weight = 35;
- int loss_weight_size() const;
- void clear_loss_weight();
- static const int kLossWeightFieldNumber = 35;
- float loss_weight(int index) const;
- void set_loss_weight(int index, float value);
- void add_loss_weight(float value);
- const ::google::protobuf::RepeatedField< float >&
- loss_weight() const;
- ::google::protobuf::RepeatedField< float >*
- mutable_loss_weight();
-
- // optional .caffe.AccuracyParameter accuracy_param = 27;
- bool has_accuracy_param() const;
- void clear_accuracy_param();
- static const int kAccuracyParamFieldNumber = 27;
- const ::caffe::AccuracyParameter& accuracy_param() const;
- ::caffe::AccuracyParameter* mutable_accuracy_param();
- ::caffe::AccuracyParameter* release_accuracy_param();
- void set_allocated_accuracy_param(::caffe::AccuracyParameter* accuracy_param);
-
- // optional .caffe.ArgMaxParameter argmax_param = 23;
- bool has_argmax_param() const;
- void clear_argmax_param();
- static const int kArgmaxParamFieldNumber = 23;
- const ::caffe::ArgMaxParameter& argmax_param() const;
- ::caffe::ArgMaxParameter* mutable_argmax_param();
- ::caffe::ArgMaxParameter* release_argmax_param();
- void set_allocated_argmax_param(::caffe::ArgMaxParameter* argmax_param);
-
- // optional .caffe.ConcatParameter concat_param = 9;
- bool has_concat_param() const;
- void clear_concat_param();
- static const int kConcatParamFieldNumber = 9;
- const ::caffe::ConcatParameter& concat_param() const;
- ::caffe::ConcatParameter* mutable_concat_param();
- ::caffe::ConcatParameter* release_concat_param();
- void set_allocated_concat_param(::caffe::ConcatParameter* concat_param);
-
- // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40;
- bool has_contrastive_loss_param() const;
- void clear_contrastive_loss_param();
- static const int kContrastiveLossParamFieldNumber = 40;
- const ::caffe::ContrastiveLossParameter& contrastive_loss_param() const;
- ::caffe::ContrastiveLossParameter* mutable_contrastive_loss_param();
- ::caffe::ContrastiveLossParameter* release_contrastive_loss_param();
- void set_allocated_contrastive_loss_param(::caffe::ContrastiveLossParameter* contrastive_loss_param);
-
- // optional .caffe.ConvolutionParameter convolution_param = 10;
- bool has_convolution_param() const;
- void clear_convolution_param();
- static const int kConvolutionParamFieldNumber = 10;
- const ::caffe::ConvolutionParameter& convolution_param() const;
- ::caffe::ConvolutionParameter* mutable_convolution_param();
- ::caffe::ConvolutionParameter* release_convolution_param();
- void set_allocated_convolution_param(::caffe::ConvolutionParameter* convolution_param);
-
- // optional .caffe.DataParameter data_param = 11;
- bool has_data_param() const;
- void clear_data_param();
- static const int kDataParamFieldNumber = 11;
- const ::caffe::DataParameter& data_param() const;
- ::caffe::DataParameter* mutable_data_param();
- ::caffe::DataParameter* release_data_param();
- void set_allocated_data_param(::caffe::DataParameter* data_param);
-
- // optional .caffe.DropoutParameter dropout_param = 12;
- bool has_dropout_param() const;
- void clear_dropout_param();
- static const int kDropoutParamFieldNumber = 12;
- const ::caffe::DropoutParameter& dropout_param() const;
- ::caffe::DropoutParameter* mutable_dropout_param();
- ::caffe::DropoutParameter* release_dropout_param();
- void set_allocated_dropout_param(::caffe::DropoutParameter* dropout_param);
-
- // optional .caffe.DummyDataParameter dummy_data_param = 26;
- bool has_dummy_data_param() const;
- void clear_dummy_data_param();
- static const int kDummyDataParamFieldNumber = 26;
- const ::caffe::DummyDataParameter& dummy_data_param() const;
- ::caffe::DummyDataParameter* mutable_dummy_data_param();
- ::caffe::DummyDataParameter* release_dummy_data_param();
- void set_allocated_dummy_data_param(::caffe::DummyDataParameter* dummy_data_param);
-
- // optional .caffe.EltwiseParameter eltwise_param = 24;
- bool has_eltwise_param() const;
- void clear_eltwise_param();
- static const int kEltwiseParamFieldNumber = 24;
- const ::caffe::EltwiseParameter& eltwise_param() const;
- ::caffe::EltwiseParameter* mutable_eltwise_param();
- ::caffe::EltwiseParameter* release_eltwise_param();
- void set_allocated_eltwise_param(::caffe::EltwiseParameter* eltwise_param);
-
- // optional .caffe.ExpParameter exp_param = 41;
- bool has_exp_param() const;
- void clear_exp_param();
- static const int kExpParamFieldNumber = 41;
- const ::caffe::ExpParameter& exp_param() const;
- ::caffe::ExpParameter* mutable_exp_param();
- ::caffe::ExpParameter* release_exp_param();
- void set_allocated_exp_param(::caffe::ExpParameter* exp_param);
-
- // optional .caffe.HDF5DataParameter hdf5_data_param = 13;
- bool has_hdf5_data_param() const;
- void clear_hdf5_data_param();
- static const int kHdf5DataParamFieldNumber = 13;
- const ::caffe::HDF5DataParameter& hdf5_data_param() const;
- ::caffe::HDF5DataParameter* mutable_hdf5_data_param();
- ::caffe::HDF5DataParameter* release_hdf5_data_param();
- void set_allocated_hdf5_data_param(::caffe::HDF5DataParameter* hdf5_data_param);
-
- // optional .caffe.HDF5OutputParameter hdf5_output_param = 14;
- bool has_hdf5_output_param() const;
- void clear_hdf5_output_param();
- static const int kHdf5OutputParamFieldNumber = 14;
- const ::caffe::HDF5OutputParameter& hdf5_output_param() const;
- ::caffe::HDF5OutputParameter* mutable_hdf5_output_param();
- ::caffe::HDF5OutputParameter* release_hdf5_output_param();
- void set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param);
-
- // optional .caffe.HingeLossParameter hinge_loss_param = 29;
- bool has_hinge_loss_param() const;
- void clear_hinge_loss_param();
- static const int kHingeLossParamFieldNumber = 29;
- const ::caffe::HingeLossParameter& hinge_loss_param() const;
- ::caffe::HingeLossParameter* mutable_hinge_loss_param();
- ::caffe::HingeLossParameter* release_hinge_loss_param();
- void set_allocated_hinge_loss_param(::caffe::HingeLossParameter* hinge_loss_param);
-
- // optional .caffe.ImageDataParameter image_data_param = 15;
- bool has_image_data_param() const;
- void clear_image_data_param();
- static const int kImageDataParamFieldNumber = 15;
- const ::caffe::ImageDataParameter& image_data_param() const;
- ::caffe::ImageDataParameter* mutable_image_data_param();
- ::caffe::ImageDataParameter* release_image_data_param();
- void set_allocated_image_data_param(::caffe::ImageDataParameter* image_data_param);
-
- // optional .caffe.InfogainLossParameter infogain_loss_param = 16;
- bool has_infogain_loss_param() const;
- void clear_infogain_loss_param();
- static const int kInfogainLossParamFieldNumber = 16;
- const ::caffe::InfogainLossParameter& infogain_loss_param() const;
- ::caffe::InfogainLossParameter* mutable_infogain_loss_param();
- ::caffe::InfogainLossParameter* release_infogain_loss_param();
- void set_allocated_infogain_loss_param(::caffe::InfogainLossParameter* infogain_loss_param);
-
- // optional .caffe.InnerProductParameter inner_product_param = 17;
- bool has_inner_product_param() const;
- void clear_inner_product_param();
- static const int kInnerProductParamFieldNumber = 17;
- const ::caffe::InnerProductParameter& inner_product_param() const;
- ::caffe::InnerProductParameter* mutable_inner_product_param();
- ::caffe::InnerProductParameter* release_inner_product_param();
- void set_allocated_inner_product_param(::caffe::InnerProductParameter* inner_product_param);
-
- // optional .caffe.LRNParameter lrn_param = 18;
- bool has_lrn_param() const;
- void clear_lrn_param();
- static const int kLrnParamFieldNumber = 18;
- const ::caffe::LRNParameter& lrn_param() const;
- ::caffe::LRNParameter* mutable_lrn_param();
- ::caffe::LRNParameter* release_lrn_param();
- void set_allocated_lrn_param(::caffe::LRNParameter* lrn_param);
-
- // optional .caffe.MemoryDataParameter memory_data_param = 22;
- bool has_memory_data_param() const;
- void clear_memory_data_param();
- static const int kMemoryDataParamFieldNumber = 22;
- const ::caffe::MemoryDataParameter& memory_data_param() const;
- ::caffe::MemoryDataParameter* mutable_memory_data_param();
- ::caffe::MemoryDataParameter* release_memory_data_param();
- void set_allocated_memory_data_param(::caffe::MemoryDataParameter* memory_data_param);
-
- // optional .caffe.MVNParameter mvn_param = 34;
- bool has_mvn_param() const;
- void clear_mvn_param();
- static const int kMvnParamFieldNumber = 34;
- const ::caffe::MVNParameter& mvn_param() const;
- ::caffe::MVNParameter* mutable_mvn_param();
- ::caffe::MVNParameter* release_mvn_param();
- void set_allocated_mvn_param(::caffe::MVNParameter* mvn_param);
-
- // optional .caffe.PoolingParameter pooling_param = 19;
- bool has_pooling_param() const;
- void clear_pooling_param();
- static const int kPoolingParamFieldNumber = 19;
- const ::caffe::PoolingParameter& pooling_param() const;
- ::caffe::PoolingParameter* mutable_pooling_param();
- ::caffe::PoolingParameter* release_pooling_param();
- void set_allocated_pooling_param(::caffe::PoolingParameter* pooling_param);
-
- // optional .caffe.PowerParameter power_param = 21;
- bool has_power_param() const;
- void clear_power_param();
- static const int kPowerParamFieldNumber = 21;
- const ::caffe::PowerParameter& power_param() const;
- ::caffe::PowerParameter* mutable_power_param();
- ::caffe::PowerParameter* release_power_param();
- void set_allocated_power_param(::caffe::PowerParameter* power_param);
-
- // optional .caffe.ReLUParameter relu_param = 30;
- bool has_relu_param() const;
- void clear_relu_param();
- static const int kReluParamFieldNumber = 30;
- const ::caffe::ReLUParameter& relu_param() const;
- ::caffe::ReLUParameter* mutable_relu_param();
- ::caffe::ReLUParameter* release_relu_param();
- void set_allocated_relu_param(::caffe::ReLUParameter* relu_param);
-
- // optional .caffe.SigmoidParameter sigmoid_param = 38;
- bool has_sigmoid_param() const;
- void clear_sigmoid_param();
- static const int kSigmoidParamFieldNumber = 38;
- const ::caffe::SigmoidParameter& sigmoid_param() const;
- ::caffe::SigmoidParameter* mutable_sigmoid_param();
- ::caffe::SigmoidParameter* release_sigmoid_param();
- void set_allocated_sigmoid_param(::caffe::SigmoidParameter* sigmoid_param);
-
- // optional .caffe.SoftmaxParameter softmax_param = 39;
- bool has_softmax_param() const;
- void clear_softmax_param();
- static const int kSoftmaxParamFieldNumber = 39;
- const ::caffe::SoftmaxParameter& softmax_param() const;
- ::caffe::SoftmaxParameter* mutable_softmax_param();
- ::caffe::SoftmaxParameter* release_softmax_param();
- void set_allocated_softmax_param(::caffe::SoftmaxParameter* softmax_param);
-
- // optional .caffe.SliceParameter slice_param = 31;
- bool has_slice_param() const;
- void clear_slice_param();
- static const int kSliceParamFieldNumber = 31;
- const ::caffe::SliceParameter& slice_param() const;
- ::caffe::SliceParameter* mutable_slice_param();
- ::caffe::SliceParameter* release_slice_param();
- void set_allocated_slice_param(::caffe::SliceParameter* slice_param);
-
- // optional .caffe.TanHParameter tanh_param = 37;
- bool has_tanh_param() const;
- void clear_tanh_param();
- static const int kTanhParamFieldNumber = 37;
- const ::caffe::TanHParameter& tanh_param() const;
- ::caffe::TanHParameter* mutable_tanh_param();
- ::caffe::TanHParameter* release_tanh_param();
- void set_allocated_tanh_param(::caffe::TanHParameter* tanh_param);
-
- // optional .caffe.ThresholdParameter threshold_param = 25;
- bool has_threshold_param() const;
- void clear_threshold_param();
- static const int kThresholdParamFieldNumber = 25;
- const ::caffe::ThresholdParameter& threshold_param() const;
- ::caffe::ThresholdParameter* mutable_threshold_param();
- ::caffe::ThresholdParameter* release_threshold_param();
- void set_allocated_threshold_param(::caffe::ThresholdParameter* threshold_param);
-
- // optional .caffe.WindowDataParameter window_data_param = 20;
- bool has_window_data_param() const;
- void clear_window_data_param();
- static const int kWindowDataParamFieldNumber = 20;
- const ::caffe::WindowDataParameter& window_data_param() const;
- ::caffe::WindowDataParameter* mutable_window_data_param();
- ::caffe::WindowDataParameter* release_window_data_param();
- void set_allocated_window_data_param(::caffe::WindowDataParameter* window_data_param);
-
- // optional .caffe.TransformationParameter transform_param = 36;
- bool has_transform_param() const;
- void clear_transform_param();
- static const int kTransformParamFieldNumber = 36;
- const ::caffe::TransformationParameter& transform_param() const;
- ::caffe::TransformationParameter* mutable_transform_param();
- ::caffe::TransformationParameter* release_transform_param();
- void set_allocated_transform_param(::caffe::TransformationParameter* transform_param);
-
- // optional .caffe.LossParameter loss_param = 42;
- bool has_loss_param() const;
- void clear_loss_param();
- static const int kLossParamFieldNumber = 42;
- const ::caffe::LossParameter& loss_param() const;
- ::caffe::LossParameter* mutable_loss_param();
- ::caffe::LossParameter* release_loss_param();
- void set_allocated_loss_param(::caffe::LossParameter* loss_param);
-
- // optional .caffe.V0LayerParameter layer = 1;
- bool has_layer() const;
- void clear_layer();
- static const int kLayerFieldNumber = 1;
- const ::caffe::V0LayerParameter& layer() const;
- ::caffe::V0LayerParameter* mutable_layer();
- ::caffe::V0LayerParameter* release_layer();
- void set_allocated_layer(::caffe::V0LayerParameter* layer);
-
- // @@protoc_insertion_point(class_scope:caffe.V1LayerParameter)
- private:
- inline void set_has_name();
- inline void clear_has_name();
- inline void set_has_type();
- inline void clear_has_type();
- inline void set_has_accuracy_param();
- inline void clear_has_accuracy_param();
- inline void set_has_argmax_param();
- inline void clear_has_argmax_param();
- inline void set_has_concat_param();
- inline void clear_has_concat_param();
- inline void set_has_contrastive_loss_param();
- inline void clear_has_contrastive_loss_param();
- inline void set_has_convolution_param();
- inline void clear_has_convolution_param();
- inline void set_has_data_param();
- inline void clear_has_data_param();
- inline void set_has_dropout_param();
- inline void clear_has_dropout_param();
- inline void set_has_dummy_data_param();
- inline void clear_has_dummy_data_param();
- inline void set_has_eltwise_param();
- inline void clear_has_eltwise_param();
- inline void set_has_exp_param();
- inline void clear_has_exp_param();
- inline void set_has_hdf5_data_param();
- inline void clear_has_hdf5_data_param();
- inline void set_has_hdf5_output_param();
- inline void clear_has_hdf5_output_param();
- inline void set_has_hinge_loss_param();
- inline void clear_has_hinge_loss_param();
- inline void set_has_image_data_param();
- inline void clear_has_image_data_param();
- inline void set_has_infogain_loss_param();
- inline void clear_has_infogain_loss_param();
- inline void set_has_inner_product_param();
- inline void clear_has_inner_product_param();
- inline void set_has_lrn_param();
- inline void clear_has_lrn_param();
- inline void set_has_memory_data_param();
- inline void clear_has_memory_data_param();
- inline void set_has_mvn_param();
- inline void clear_has_mvn_param();
- inline void set_has_pooling_param();
- inline void clear_has_pooling_param();
- inline void set_has_power_param();
- inline void clear_has_power_param();
- inline void set_has_relu_param();
- inline void clear_has_relu_param();
- inline void set_has_sigmoid_param();
- inline void clear_has_sigmoid_param();
- inline void set_has_softmax_param();
- inline void clear_has_softmax_param();
- inline void set_has_slice_param();
- inline void clear_has_slice_param();
- inline void set_has_tanh_param();
- inline void clear_has_tanh_param();
- inline void set_has_threshold_param();
- inline void clear_has_threshold_param();
- inline void set_has_window_data_param();
- inline void clear_has_window_data_param();
- inline void set_has_transform_param();
- inline void clear_has_transform_param();
- inline void set_has_loss_param();
- inline void clear_has_loss_param();
- inline void set_has_layer();
- inline void clear_has_layer();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<2> _has_bits_;
- ::google::protobuf::RepeatedPtrField< ::std::string> bottom_;
- ::google::protobuf::RepeatedPtrField< ::std::string> top_;
- ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule > include_;
- ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule > exclude_;
- ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto > blobs_;
- ::google::protobuf::RepeatedPtrField< ::std::string> param_;
- ::google::protobuf::RepeatedField<int> blob_share_mode_;
- ::google::protobuf::RepeatedField< float > blobs_lr_;
- ::google::protobuf::RepeatedField< float > weight_decay_;
- ::google::protobuf::RepeatedField< float > loss_weight_;
- ::google::protobuf::internal::ArenaStringPtr name_;
- ::caffe::AccuracyParameter* accuracy_param_;
- ::caffe::ArgMaxParameter* argmax_param_;
- ::caffe::ConcatParameter* concat_param_;
- ::caffe::ContrastiveLossParameter* contrastive_loss_param_;
- ::caffe::ConvolutionParameter* convolution_param_;
- ::caffe::DataParameter* data_param_;
- ::caffe::DropoutParameter* dropout_param_;
- ::caffe::DummyDataParameter* dummy_data_param_;
- ::caffe::EltwiseParameter* eltwise_param_;
- ::caffe::ExpParameter* exp_param_;
- ::caffe::HDF5DataParameter* hdf5_data_param_;
- ::caffe::HDF5OutputParameter* hdf5_output_param_;
- ::caffe::HingeLossParameter* hinge_loss_param_;
- ::caffe::ImageDataParameter* image_data_param_;
- ::caffe::InfogainLossParameter* infogain_loss_param_;
- ::caffe::InnerProductParameter* inner_product_param_;
- ::caffe::LRNParameter* lrn_param_;
- ::caffe::MemoryDataParameter* memory_data_param_;
- ::caffe::MVNParameter* mvn_param_;
- ::caffe::PoolingParameter* pooling_param_;
- ::caffe::PowerParameter* power_param_;
- ::caffe::ReLUParameter* relu_param_;
- ::caffe::SigmoidParameter* sigmoid_param_;
- ::caffe::SoftmaxParameter* softmax_param_;
- ::caffe::SliceParameter* slice_param_;
- ::caffe::TanHParameter* tanh_param_;
- ::caffe::ThresholdParameter* threshold_param_;
- ::caffe::WindowDataParameter* window_data_param_;
- ::caffe::TransformationParameter* transform_param_;
- ::caffe::LossParameter* loss_param_;
- ::caffe::V0LayerParameter* layer_;
- int type_;
- mutable int _cached_size_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<V1LayerParameter> V1LayerParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class V0LayerParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.V0LayerParameter) */ {
- public:
- V0LayerParameter();
- virtual ~V0LayerParameter();
-
- V0LayerParameter(const V0LayerParameter& from);
-
- inline V0LayerParameter& operator=(const V0LayerParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const V0LayerParameter& default_instance();
-
- static const V0LayerParameter* internal_default_instance();
-
- void Swap(V0LayerParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline V0LayerParameter* New() const { return New(NULL); }
-
- V0LayerParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const V0LayerParameter& from);
- void MergeFrom(const V0LayerParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(V0LayerParameter* other);
- void UnsafeMergeFrom(const V0LayerParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- typedef V0LayerParameter_PoolMethod PoolMethod;
- static const PoolMethod MAX =
- V0LayerParameter_PoolMethod_MAX;
- static const PoolMethod AVE =
- V0LayerParameter_PoolMethod_AVE;
- static const PoolMethod STOCHASTIC =
- V0LayerParameter_PoolMethod_STOCHASTIC;
- static inline bool PoolMethod_IsValid(int value) {
- return V0LayerParameter_PoolMethod_IsValid(value);
- }
- static const PoolMethod PoolMethod_MIN =
- V0LayerParameter_PoolMethod_PoolMethod_MIN;
- static const PoolMethod PoolMethod_MAX =
- V0LayerParameter_PoolMethod_PoolMethod_MAX;
- static const int PoolMethod_ARRAYSIZE =
- V0LayerParameter_PoolMethod_PoolMethod_ARRAYSIZE;
- static inline const ::google::protobuf::EnumDescriptor*
- PoolMethod_descriptor() {
- return V0LayerParameter_PoolMethod_descriptor();
- }
- static inline const ::std::string& PoolMethod_Name(PoolMethod value) {
- return V0LayerParameter_PoolMethod_Name(value);
- }
- static inline bool PoolMethod_Parse(const ::std::string& name,
- PoolMethod* value) {
- return V0LayerParameter_PoolMethod_Parse(name, value);
- }
-
- // accessors -------------------------------------------------------
-
- // optional string name = 1;
- bool has_name() const;
- void clear_name();
- static const int kNameFieldNumber = 1;
- const ::std::string& name() const;
- void set_name(const ::std::string& value);
- void set_name(const char* value);
- void set_name(const char* value, size_t size);
- ::std::string* mutable_name();
- ::std::string* release_name();
- void set_allocated_name(::std::string* name);
-
- // optional string type = 2;
- bool has_type() const;
- void clear_type();
- static const int kTypeFieldNumber = 2;
- const ::std::string& type() const;
- void set_type(const ::std::string& value);
- void set_type(const char* value);
- void set_type(const char* value, size_t size);
- ::std::string* mutable_type();
- ::std::string* release_type();
- void set_allocated_type(::std::string* type);
-
- // optional uint32 num_output = 3;
- bool has_num_output() const;
- void clear_num_output();
- static const int kNumOutputFieldNumber = 3;
- ::google::protobuf::uint32 num_output() const;
- void set_num_output(::google::protobuf::uint32 value);
-
- // optional bool biasterm = 4 [default = true];
- bool has_biasterm() const;
- void clear_biasterm();
- static const int kBiastermFieldNumber = 4;
- bool biasterm() const;
- void set_biasterm(bool value);
-
- // optional .caffe.FillerParameter weight_filler = 5;
- bool has_weight_filler() const;
- void clear_weight_filler();
- static const int kWeightFillerFieldNumber = 5;
- const ::caffe::FillerParameter& weight_filler() const;
- ::caffe::FillerParameter* mutable_weight_filler();
- ::caffe::FillerParameter* release_weight_filler();
- void set_allocated_weight_filler(::caffe::FillerParameter* weight_filler);
-
- // optional .caffe.FillerParameter bias_filler = 6;
- bool has_bias_filler() const;
- void clear_bias_filler();
- static const int kBiasFillerFieldNumber = 6;
- const ::caffe::FillerParameter& bias_filler() const;
- ::caffe::FillerParameter* mutable_bias_filler();
- ::caffe::FillerParameter* release_bias_filler();
- void set_allocated_bias_filler(::caffe::FillerParameter* bias_filler);
-
- // optional uint32 pad = 7 [default = 0];
- bool has_pad() const;
- void clear_pad();
- static const int kPadFieldNumber = 7;
- ::google::protobuf::uint32 pad() const;
- void set_pad(::google::protobuf::uint32 value);
-
- // optional uint32 kernelsize = 8;
- bool has_kernelsize() const;
- void clear_kernelsize();
- static const int kKernelsizeFieldNumber = 8;
- ::google::protobuf::uint32 kernelsize() const;
- void set_kernelsize(::google::protobuf::uint32 value);
-
- // optional uint32 group = 9 [default = 1];
- bool has_group() const;
- void clear_group();
- static const int kGroupFieldNumber = 9;
- ::google::protobuf::uint32 group() const;
- void set_group(::google::protobuf::uint32 value);
-
- // optional uint32 stride = 10 [default = 1];
- bool has_stride() const;
- void clear_stride();
- static const int kStrideFieldNumber = 10;
- ::google::protobuf::uint32 stride() const;
- void set_stride(::google::protobuf::uint32 value);
-
- // optional .caffe.V0LayerParameter.PoolMethod pool = 11 [default = MAX];
- bool has_pool() const;
- void clear_pool();
- static const int kPoolFieldNumber = 11;
- ::caffe::V0LayerParameter_PoolMethod pool() const;
- void set_pool(::caffe::V0LayerParameter_PoolMethod value);
-
- // optional float dropout_ratio = 12 [default = 0.5];
- bool has_dropout_ratio() const;
- void clear_dropout_ratio();
- static const int kDropoutRatioFieldNumber = 12;
- float dropout_ratio() const;
- void set_dropout_ratio(float value);
-
- // optional uint32 local_size = 13 [default = 5];
- bool has_local_size() const;
- void clear_local_size();
- static const int kLocalSizeFieldNumber = 13;
- ::google::protobuf::uint32 local_size() const;
- void set_local_size(::google::protobuf::uint32 value);
-
- // optional float alpha = 14 [default = 1];
- bool has_alpha() const;
- void clear_alpha();
- static const int kAlphaFieldNumber = 14;
- float alpha() const;
- void set_alpha(float value);
-
- // optional float beta = 15 [default = 0.75];
- bool has_beta() const;
- void clear_beta();
- static const int kBetaFieldNumber = 15;
- float beta() const;
- void set_beta(float value);
-
- // optional float k = 22 [default = 1];
- bool has_k() const;
- void clear_k();
- static const int kKFieldNumber = 22;
- float k() const;
- void set_k(float value);
-
- // optional string source = 16;
- bool has_source() const;
- void clear_source();
- static const int kSourceFieldNumber = 16;
- const ::std::string& source() const;
- void set_source(const ::std::string& value);
- void set_source(const char* value);
- void set_source(const char* value, size_t size);
- ::std::string* mutable_source();
- ::std::string* release_source();
- void set_allocated_source(::std::string* source);
-
- // optional float scale = 17 [default = 1];
- bool has_scale() const;
- void clear_scale();
- static const int kScaleFieldNumber = 17;
- float scale() const;
- void set_scale(float value);
-
- // optional string meanfile = 18;
- bool has_meanfile() const;
- void clear_meanfile();
- static const int kMeanfileFieldNumber = 18;
- const ::std::string& meanfile() const;
- void set_meanfile(const ::std::string& value);
- void set_meanfile(const char* value);
- void set_meanfile(const char* value, size_t size);
- ::std::string* mutable_meanfile();
- ::std::string* release_meanfile();
- void set_allocated_meanfile(::std::string* meanfile);
-
- // optional uint32 batchsize = 19;
- bool has_batchsize() const;
- void clear_batchsize();
- static const int kBatchsizeFieldNumber = 19;
- ::google::protobuf::uint32 batchsize() const;
- void set_batchsize(::google::protobuf::uint32 value);
-
- // optional uint32 cropsize = 20 [default = 0];
- bool has_cropsize() const;
- void clear_cropsize();
- static const int kCropsizeFieldNumber = 20;
- ::google::protobuf::uint32 cropsize() const;
- void set_cropsize(::google::protobuf::uint32 value);
-
- // optional bool mirror = 21 [default = false];
- bool has_mirror() const;
- void clear_mirror();
- static const int kMirrorFieldNumber = 21;
- bool mirror() const;
- void set_mirror(bool value);
-
- // repeated .caffe.BlobProto blobs = 50;
- int blobs_size() const;
- void clear_blobs();
- static const int kBlobsFieldNumber = 50;
- const ::caffe::BlobProto& blobs(int index) const;
- ::caffe::BlobProto* mutable_blobs(int index);
- ::caffe::BlobProto* add_blobs();
- ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
- mutable_blobs();
- const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
- blobs() const;
-
- // repeated float blobs_lr = 51;
- int blobs_lr_size() const;
- void clear_blobs_lr();
- static const int kBlobsLrFieldNumber = 51;
- float blobs_lr(int index) const;
- void set_blobs_lr(int index, float value);
- void add_blobs_lr(float value);
- const ::google::protobuf::RepeatedField< float >&
- blobs_lr() const;
- ::google::protobuf::RepeatedField< float >*
- mutable_blobs_lr();
-
- // repeated float weight_decay = 52;
- int weight_decay_size() const;
- void clear_weight_decay();
- static const int kWeightDecayFieldNumber = 52;
- float weight_decay(int index) const;
- void set_weight_decay(int index, float value);
- void add_weight_decay(float value);
- const ::google::protobuf::RepeatedField< float >&
- weight_decay() const;
- ::google::protobuf::RepeatedField< float >*
- mutable_weight_decay();
-
- // optional uint32 rand_skip = 53 [default = 0];
- bool has_rand_skip() const;
- void clear_rand_skip();
- static const int kRandSkipFieldNumber = 53;
- ::google::protobuf::uint32 rand_skip() const;
- void set_rand_skip(::google::protobuf::uint32 value);
-
- // optional float det_fg_threshold = 54 [default = 0.5];
- bool has_det_fg_threshold() const;
- void clear_det_fg_threshold();
- static const int kDetFgThresholdFieldNumber = 54;
- float det_fg_threshold() const;
- void set_det_fg_threshold(float value);
-
- // optional float det_bg_threshold = 55 [default = 0.5];
- bool has_det_bg_threshold() const;
- void clear_det_bg_threshold();
- static const int kDetBgThresholdFieldNumber = 55;
- float det_bg_threshold() const;
- void set_det_bg_threshold(float value);
-
- // optional float det_fg_fraction = 56 [default = 0.25];
- bool has_det_fg_fraction() const;
- void clear_det_fg_fraction();
- static const int kDetFgFractionFieldNumber = 56;
- float det_fg_fraction() const;
- void set_det_fg_fraction(float value);
-
- // optional uint32 det_context_pad = 58 [default = 0];
- bool has_det_context_pad() const;
- void clear_det_context_pad();
- static const int kDetContextPadFieldNumber = 58;
- ::google::protobuf::uint32 det_context_pad() const;
- void set_det_context_pad(::google::protobuf::uint32 value);
-
- // optional string det_crop_mode = 59 [default = "warp"];
- bool has_det_crop_mode() const;
- void clear_det_crop_mode();
- static const int kDetCropModeFieldNumber = 59;
- const ::std::string& det_crop_mode() const;
- void set_det_crop_mode(const ::std::string& value);
- void set_det_crop_mode(const char* value);
- void set_det_crop_mode(const char* value, size_t size);
- ::std::string* mutable_det_crop_mode();
- ::std::string* release_det_crop_mode();
- void set_allocated_det_crop_mode(::std::string* det_crop_mode);
-
- // optional int32 new_num = 60 [default = 0];
- bool has_new_num() const;
- void clear_new_num();
- static const int kNewNumFieldNumber = 60;
- ::google::protobuf::int32 new_num() const;
- void set_new_num(::google::protobuf::int32 value);
-
- // optional int32 new_channels = 61 [default = 0];
- bool has_new_channels() const;
- void clear_new_channels();
- static const int kNewChannelsFieldNumber = 61;
- ::google::protobuf::int32 new_channels() const;
- void set_new_channels(::google::protobuf::int32 value);
-
- // optional int32 new_height = 62 [default = 0];
- bool has_new_height() const;
- void clear_new_height();
- static const int kNewHeightFieldNumber = 62;
- ::google::protobuf::int32 new_height() const;
- void set_new_height(::google::protobuf::int32 value);
-
- // optional int32 new_width = 63 [default = 0];
- bool has_new_width() const;
- void clear_new_width();
- static const int kNewWidthFieldNumber = 63;
- ::google::protobuf::int32 new_width() const;
- void set_new_width(::google::protobuf::int32 value);
-
- // optional bool shuffle_images = 64 [default = false];
- bool has_shuffle_images() const;
- void clear_shuffle_images();
- static const int kShuffleImagesFieldNumber = 64;
- bool shuffle_images() const;
- void set_shuffle_images(bool value);
-
- // optional uint32 concat_dim = 65 [default = 1];
- bool has_concat_dim() const;
- void clear_concat_dim();
- static const int kConcatDimFieldNumber = 65;
- ::google::protobuf::uint32 concat_dim() const;
- void set_concat_dim(::google::protobuf::uint32 value);
-
- // optional .caffe.HDF5OutputParameter hdf5_output_param = 1001;
- bool has_hdf5_output_param() const;
- void clear_hdf5_output_param();
- static const int kHdf5OutputParamFieldNumber = 1001;
- const ::caffe::HDF5OutputParameter& hdf5_output_param() const;
- ::caffe::HDF5OutputParameter* mutable_hdf5_output_param();
- ::caffe::HDF5OutputParameter* release_hdf5_output_param();
- void set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param);
-
- // @@protoc_insertion_point(class_scope:caffe.V0LayerParameter)
- private:
- inline void set_has_name();
- inline void clear_has_name();
- inline void set_has_type();
- inline void clear_has_type();
- inline void set_has_num_output();
- inline void clear_has_num_output();
- inline void set_has_biasterm();
- inline void clear_has_biasterm();
- inline void set_has_weight_filler();
- inline void clear_has_weight_filler();
- inline void set_has_bias_filler();
- inline void clear_has_bias_filler();
- inline void set_has_pad();
- inline void clear_has_pad();
- inline void set_has_kernelsize();
- inline void clear_has_kernelsize();
- inline void set_has_group();
- inline void clear_has_group();
- inline void set_has_stride();
- inline void clear_has_stride();
- inline void set_has_pool();
- inline void clear_has_pool();
- inline void set_has_dropout_ratio();
- inline void clear_has_dropout_ratio();
- inline void set_has_local_size();
- inline void clear_has_local_size();
- inline void set_has_alpha();
- inline void clear_has_alpha();
- inline void set_has_beta();
- inline void clear_has_beta();
- inline void set_has_k();
- inline void clear_has_k();
- inline void set_has_source();
- inline void clear_has_source();
- inline void set_has_scale();
- inline void clear_has_scale();
- inline void set_has_meanfile();
- inline void clear_has_meanfile();
- inline void set_has_batchsize();
- inline void clear_has_batchsize();
- inline void set_has_cropsize();
- inline void clear_has_cropsize();
- inline void set_has_mirror();
- inline void clear_has_mirror();
- inline void set_has_rand_skip();
- inline void clear_has_rand_skip();
- inline void set_has_det_fg_threshold();
- inline void clear_has_det_fg_threshold();
- inline void set_has_det_bg_threshold();
- inline void clear_has_det_bg_threshold();
- inline void set_has_det_fg_fraction();
- inline void clear_has_det_fg_fraction();
- inline void set_has_det_context_pad();
- inline void clear_has_det_context_pad();
- inline void set_has_det_crop_mode();
- inline void clear_has_det_crop_mode();
- inline void set_has_new_num();
- inline void clear_has_new_num();
- inline void set_has_new_channels();
- inline void clear_has_new_channels();
- inline void set_has_new_height();
- inline void clear_has_new_height();
- inline void set_has_new_width();
- inline void clear_has_new_width();
- inline void set_has_shuffle_images();
- inline void clear_has_shuffle_images();
- inline void set_has_concat_dim();
- inline void clear_has_concat_dim();
- inline void set_has_hdf5_output_param();
- inline void clear_has_hdf5_output_param();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<2> _has_bits_;
- ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto > blobs_;
- ::google::protobuf::RepeatedField< float > blobs_lr_;
- ::google::protobuf::RepeatedField< float > weight_decay_;
- ::google::protobuf::internal::ArenaStringPtr name_;
- ::google::protobuf::internal::ArenaStringPtr type_;
- ::google::protobuf::internal::ArenaStringPtr source_;
- ::google::protobuf::internal::ArenaStringPtr meanfile_;
- static ::std::string* _default_det_crop_mode_;
- ::google::protobuf::internal::ArenaStringPtr det_crop_mode_;
- ::caffe::FillerParameter* weight_filler_;
- ::caffe::FillerParameter* bias_filler_;
- ::caffe::HDF5OutputParameter* hdf5_output_param_;
- ::google::protobuf::uint32 num_output_;
- ::google::protobuf::uint32 pad_;
- ::google::protobuf::uint32 kernelsize_;
- int pool_;
- ::google::protobuf::uint32 batchsize_;
- ::google::protobuf::uint32 cropsize_;
- ::google::protobuf::uint32 rand_skip_;
- bool mirror_;
- bool shuffle_images_;
- ::google::protobuf::uint32 det_context_pad_;
- ::google::protobuf::int32 new_num_;
- ::google::protobuf::int32 new_channels_;
- ::google::protobuf::int32 new_height_;
- ::google::protobuf::int32 new_width_;
- ::google::protobuf::uint32 concat_dim_;
- bool biasterm_;
- ::google::protobuf::uint32 group_;
- ::google::protobuf::uint32 stride_;
- float dropout_ratio_;
- ::google::protobuf::uint32 local_size_;
- float alpha_;
- float beta_;
- float k_;
- float scale_;
- float det_fg_threshold_;
- float det_bg_threshold_;
- float det_fg_fraction_;
- mutable int _cached_size_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<V0LayerParameter> V0LayerParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class PReLUParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.PReLUParameter) */ {
- public:
- PReLUParameter();
- virtual ~PReLUParameter();
-
- PReLUParameter(const PReLUParameter& from);
-
- inline PReLUParameter& operator=(const PReLUParameter& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const PReLUParameter& default_instance();
-
- static const PReLUParameter* internal_default_instance();
-
- void Swap(PReLUParameter* other);
-
- // implements Message ----------------------------------------------
-
- inline PReLUParameter* New() const { return New(NULL); }
-
- PReLUParameter* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const PReLUParameter& from);
- void MergeFrom(const PReLUParameter& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(PReLUParameter* other);
- void UnsafeMergeFrom(const PReLUParameter& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional .caffe.FillerParameter filler = 1;
- bool has_filler() const;
- void clear_filler();
- static const int kFillerFieldNumber = 1;
- const ::caffe::FillerParameter& filler() const;
- ::caffe::FillerParameter* mutable_filler();
- ::caffe::FillerParameter* release_filler();
- void set_allocated_filler(::caffe::FillerParameter* filler);
-
- // optional bool channel_shared = 2 [default = false];
- bool has_channel_shared() const;
- void clear_channel_shared();
- static const int kChannelSharedFieldNumber = 2;
- bool channel_shared() const;
- void set_channel_shared(bool value);
-
- // @@protoc_insertion_point(class_scope:caffe.PReLUParameter)
- private:
- inline void set_has_filler();
- inline void clear_has_filler();
- inline void set_has_channel_shared();
- inline void clear_has_channel_shared();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- ::caffe::FillerParameter* filler_;
- bool channel_shared_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<PReLUParameter> PReLUParameter_default_instance_;
-
-// -------------------------------------------------------------------
-
-class NormalizedBBox : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.NormalizedBBox) */ {
- public:
- NormalizedBBox();
- virtual ~NormalizedBBox();
-
- NormalizedBBox(const NormalizedBBox& from);
-
- inline NormalizedBBox& operator=(const NormalizedBBox& from) {
- CopyFrom(from);
- return *this;
- }
-
- inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
- return _internal_metadata_.unknown_fields();
- }
-
- inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
- return _internal_metadata_.mutable_unknown_fields();
- }
-
- static const ::google::protobuf::Descriptor* descriptor();
- static const NormalizedBBox& default_instance();
-
- static const NormalizedBBox* internal_default_instance();
-
- void Swap(NormalizedBBox* other);
-
- // implements Message ----------------------------------------------
-
- inline NormalizedBBox* New() const { return New(NULL); }
-
- NormalizedBBox* New(::google::protobuf::Arena* arena) const;
- void CopyFrom(const ::google::protobuf::Message& from);
- void MergeFrom(const ::google::protobuf::Message& from);
- void CopyFrom(const NormalizedBBox& from);
- void MergeFrom(const NormalizedBBox& from);
- void Clear();
- bool IsInitialized() const;
-
- size_t ByteSizeLong() const;
- bool MergePartialFromCodedStream(
- ::google::protobuf::io::CodedInputStream* input);
- void SerializeWithCachedSizes(
- ::google::protobuf::io::CodedOutputStream* output) const;
- ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
- bool deterministic, ::google::protobuf::uint8* output) const;
- ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
- return InternalSerializeWithCachedSizesToArray(false, output);
- }
- int GetCachedSize() const { return _cached_size_; }
- private:
- void SharedCtor();
- void SharedDtor();
- void SetCachedSize(int size) const;
- void InternalSwap(NormalizedBBox* other);
- void UnsafeMergeFrom(const NormalizedBBox& from);
- private:
- inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
- return _internal_metadata_.arena();
- }
- inline void* MaybeArenaPtr() const {
- return _internal_metadata_.raw_arena_ptr();
- }
- public:
-
- ::google::protobuf::Metadata GetMetadata() const;
-
- // nested types ----------------------------------------------------
-
- // accessors -------------------------------------------------------
-
- // optional float xmin = 1;
- bool has_xmin() const;
- void clear_xmin();
- static const int kXminFieldNumber = 1;
- float xmin() const;
- void set_xmin(float value);
-
- // optional float ymin = 2;
- bool has_ymin() const;
- void clear_ymin();
- static const int kYminFieldNumber = 2;
- float ymin() const;
- void set_ymin(float value);
-
- // optional float xmax = 3;
- bool has_xmax() const;
- void clear_xmax();
- static const int kXmaxFieldNumber = 3;
- float xmax() const;
- void set_xmax(float value);
-
- // optional float ymax = 4;
- bool has_ymax() const;
- void clear_ymax();
- static const int kYmaxFieldNumber = 4;
- float ymax() const;
- void set_ymax(float value);
-
- // optional int32 label = 5;
- bool has_label() const;
- void clear_label();
- static const int kLabelFieldNumber = 5;
- ::google::protobuf::int32 label() const;
- void set_label(::google::protobuf::int32 value);
-
- // optional bool difficult = 6;
- bool has_difficult() const;
- void clear_difficult();
- static const int kDifficultFieldNumber = 6;
- bool difficult() const;
- void set_difficult(bool value);
-
- // optional float score = 7;
- bool has_score() const;
- void clear_score();
- static const int kScoreFieldNumber = 7;
- float score() const;
- void set_score(float value);
-
- // optional float size = 8;
- bool has_size() const;
- void clear_size();
- static const int kSizeFieldNumber = 8;
- float size() const;
- void set_size(float value);
-
- // @@protoc_insertion_point(class_scope:caffe.NormalizedBBox)
- private:
- inline void set_has_xmin();
- inline void clear_has_xmin();
- inline void set_has_ymin();
- inline void clear_has_ymin();
- inline void set_has_xmax();
- inline void clear_has_xmax();
- inline void set_has_ymax();
- inline void clear_has_ymax();
- inline void set_has_label();
- inline void clear_has_label();
- inline void set_has_difficult();
- inline void clear_has_difficult();
- inline void set_has_score();
- inline void clear_has_score();
- inline void set_has_size();
- inline void clear_has_size();
-
- ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
- ::google::protobuf::internal::HasBits<1> _has_bits_;
- mutable int _cached_size_;
- float xmin_;
- float ymin_;
- float xmax_;
- float ymax_;
- ::google::protobuf::int32 label_;
- bool difficult_;
- float score_;
- float size_;
- friend void protobuf_InitDefaults_caffe_2eproto_impl();
- friend void protobuf_AddDesc_caffe_2eproto_impl();
- friend void protobuf_AssignDesc_caffe_2eproto();
- friend void protobuf_ShutdownFile_caffe_2eproto();
-
- void InitAsDefaultInstance();
-};
-extern ::google::protobuf::internal::ExplicitlyConstructed<NormalizedBBox> NormalizedBBox_default_instance_;
-
-// ===================================================================
-
-
-// ===================================================================
-
-#if !PROTOBUF_INLINE_NOT_IN_HEADERS
-// BlobShape
-
-// repeated int64 dim = 1 [packed = true];
-inline int BlobShape::dim_size() const {
- return dim_.size();
-}
-inline void BlobShape::clear_dim() {
- dim_.Clear();
-}
-inline ::google::protobuf::int64 BlobShape::dim(int index) const {
- // @@protoc_insertion_point(field_get:caffe.BlobShape.dim)
- return dim_.Get(index);
-}
-inline void BlobShape::set_dim(int index, ::google::protobuf::int64 value) {
- dim_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.BlobShape.dim)
-}
-inline void BlobShape::add_dim(::google::protobuf::int64 value) {
- dim_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.BlobShape.dim)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::int64 >&
-BlobShape::dim() const {
- // @@protoc_insertion_point(field_list:caffe.BlobShape.dim)
- return dim_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::int64 >*
-BlobShape::mutable_dim() {
- // @@protoc_insertion_point(field_mutable_list:caffe.BlobShape.dim)
- return &dim_;
-}
-
-inline const BlobShape* BlobShape::internal_default_instance() {
- return &BlobShape_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// BlobProto
-
-// optional .caffe.BlobShape shape = 7;
-inline bool BlobProto::has_shape() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void BlobProto::set_has_shape() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void BlobProto::clear_has_shape() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void BlobProto::clear_shape() {
- if (shape_ != NULL) shape_->::caffe::BlobShape::Clear();
- clear_has_shape();
-}
-inline const ::caffe::BlobShape& BlobProto::shape() const {
- // @@protoc_insertion_point(field_get:caffe.BlobProto.shape)
- return shape_ != NULL ? *shape_
- : *::caffe::BlobShape::internal_default_instance();
-}
-inline ::caffe::BlobShape* BlobProto::mutable_shape() {
- set_has_shape();
- if (shape_ == NULL) {
- shape_ = new ::caffe::BlobShape;
- }
- // @@protoc_insertion_point(field_mutable:caffe.BlobProto.shape)
- return shape_;
-}
-inline ::caffe::BlobShape* BlobProto::release_shape() {
- // @@protoc_insertion_point(field_release:caffe.BlobProto.shape)
- clear_has_shape();
- ::caffe::BlobShape* temp = shape_;
- shape_ = NULL;
- return temp;
-}
-inline void BlobProto::set_allocated_shape(::caffe::BlobShape* shape) {
- delete shape_;
- shape_ = shape;
- if (shape) {
- set_has_shape();
- } else {
- clear_has_shape();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.BlobProto.shape)
-}
-
-// repeated float data = 5 [packed = true];
-inline int BlobProto::data_size() const {
- return data_.size();
-}
-inline void BlobProto::clear_data() {
- data_.Clear();
-}
-inline float BlobProto::data(int index) const {
- // @@protoc_insertion_point(field_get:caffe.BlobProto.data)
- return data_.Get(index);
-}
-inline void BlobProto::set_data(int index, float value) {
- data_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.BlobProto.data)
-}
-inline void BlobProto::add_data(float value) {
- data_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.BlobProto.data)
-}
-inline const ::google::protobuf::RepeatedField< float >&
-BlobProto::data() const {
- // @@protoc_insertion_point(field_list:caffe.BlobProto.data)
- return data_;
-}
-inline ::google::protobuf::RepeatedField< float >*
-BlobProto::mutable_data() {
- // @@protoc_insertion_point(field_mutable_list:caffe.BlobProto.data)
- return &data_;
-}
-
-// repeated float diff = 6 [packed = true];
-inline int BlobProto::diff_size() const {
- return diff_.size();
-}
-inline void BlobProto::clear_diff() {
- diff_.Clear();
-}
-inline float BlobProto::diff(int index) const {
- // @@protoc_insertion_point(field_get:caffe.BlobProto.diff)
- return diff_.Get(index);
-}
-inline void BlobProto::set_diff(int index, float value) {
- diff_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.BlobProto.diff)
-}
-inline void BlobProto::add_diff(float value) {
- diff_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.BlobProto.diff)
-}
-inline const ::google::protobuf::RepeatedField< float >&
-BlobProto::diff() const {
- // @@protoc_insertion_point(field_list:caffe.BlobProto.diff)
- return diff_;
-}
-inline ::google::protobuf::RepeatedField< float >*
-BlobProto::mutable_diff() {
- // @@protoc_insertion_point(field_mutable_list:caffe.BlobProto.diff)
- return &diff_;
-}
-
-// optional int32 num = 1 [default = 0];
-inline bool BlobProto::has_num() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void BlobProto::set_has_num() {
- _has_bits_[0] |= 0x00000008u;
-}
-inline void BlobProto::clear_has_num() {
- _has_bits_[0] &= ~0x00000008u;
-}
-inline void BlobProto::clear_num() {
- num_ = 0;
- clear_has_num();
-}
-inline ::google::protobuf::int32 BlobProto::num() const {
- // @@protoc_insertion_point(field_get:caffe.BlobProto.num)
- return num_;
-}
-inline void BlobProto::set_num(::google::protobuf::int32 value) {
- set_has_num();
- num_ = value;
- // @@protoc_insertion_point(field_set:caffe.BlobProto.num)
-}
-
-// optional int32 channels = 2 [default = 0];
-inline bool BlobProto::has_channels() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-inline void BlobProto::set_has_channels() {
- _has_bits_[0] |= 0x00000010u;
-}
-inline void BlobProto::clear_has_channels() {
- _has_bits_[0] &= ~0x00000010u;
-}
-inline void BlobProto::clear_channels() {
- channels_ = 0;
- clear_has_channels();
-}
-inline ::google::protobuf::int32 BlobProto::channels() const {
- // @@protoc_insertion_point(field_get:caffe.BlobProto.channels)
- return channels_;
-}
-inline void BlobProto::set_channels(::google::protobuf::int32 value) {
- set_has_channels();
- channels_ = value;
- // @@protoc_insertion_point(field_set:caffe.BlobProto.channels)
-}
-
-// optional int32 height = 3 [default = 0];
-inline bool BlobProto::has_height() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-inline void BlobProto::set_has_height() {
- _has_bits_[0] |= 0x00000020u;
-}
-inline void BlobProto::clear_has_height() {
- _has_bits_[0] &= ~0x00000020u;
-}
-inline void BlobProto::clear_height() {
- height_ = 0;
- clear_has_height();
-}
-inline ::google::protobuf::int32 BlobProto::height() const {
- // @@protoc_insertion_point(field_get:caffe.BlobProto.height)
- return height_;
-}
-inline void BlobProto::set_height(::google::protobuf::int32 value) {
- set_has_height();
- height_ = value;
- // @@protoc_insertion_point(field_set:caffe.BlobProto.height)
-}
-
-// optional int32 width = 4 [default = 0];
-inline bool BlobProto::has_width() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-inline void BlobProto::set_has_width() {
- _has_bits_[0] |= 0x00000040u;
-}
-inline void BlobProto::clear_has_width() {
- _has_bits_[0] &= ~0x00000040u;
-}
-inline void BlobProto::clear_width() {
- width_ = 0;
- clear_has_width();
-}
-inline ::google::protobuf::int32 BlobProto::width() const {
- // @@protoc_insertion_point(field_get:caffe.BlobProto.width)
- return width_;
-}
-inline void BlobProto::set_width(::google::protobuf::int32 value) {
- set_has_width();
- width_ = value;
- // @@protoc_insertion_point(field_set:caffe.BlobProto.width)
-}
-
-inline const BlobProto* BlobProto::internal_default_instance() {
- return &BlobProto_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// BlobProtoVector
-
-// repeated .caffe.BlobProto blobs = 1;
-inline int BlobProtoVector::blobs_size() const {
- return blobs_.size();
-}
-inline void BlobProtoVector::clear_blobs() {
- blobs_.Clear();
-}
-inline const ::caffe::BlobProto& BlobProtoVector::blobs(int index) const {
- // @@protoc_insertion_point(field_get:caffe.BlobProtoVector.blobs)
- return blobs_.Get(index);
-}
-inline ::caffe::BlobProto* BlobProtoVector::mutable_blobs(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.BlobProtoVector.blobs)
- return blobs_.Mutable(index);
-}
-inline ::caffe::BlobProto* BlobProtoVector::add_blobs() {
- // @@protoc_insertion_point(field_add:caffe.BlobProtoVector.blobs)
- return blobs_.Add();
-}
-inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
-BlobProtoVector::mutable_blobs() {
- // @@protoc_insertion_point(field_mutable_list:caffe.BlobProtoVector.blobs)
- return &blobs_;
-}
-inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
-BlobProtoVector::blobs() const {
- // @@protoc_insertion_point(field_list:caffe.BlobProtoVector.blobs)
- return blobs_;
-}
-
-inline const BlobProtoVector* BlobProtoVector::internal_default_instance() {
- return &BlobProtoVector_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// CropParameter
-
-// optional int32 axis = 1 [default = 2];
-inline bool CropParameter::has_axis() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void CropParameter::set_has_axis() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void CropParameter::clear_has_axis() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void CropParameter::clear_axis() {
- axis_ = 2;
- clear_has_axis();
-}
-inline ::google::protobuf::int32 CropParameter::axis() const {
- // @@protoc_insertion_point(field_get:caffe.CropParameter.axis)
- return axis_;
-}
-inline void CropParameter::set_axis(::google::protobuf::int32 value) {
- set_has_axis();
- axis_ = value;
- // @@protoc_insertion_point(field_set:caffe.CropParameter.axis)
-}
-
-// repeated uint32 offset = 2;
-inline int CropParameter::offset_size() const {
- return offset_.size();
-}
-inline void CropParameter::clear_offset() {
- offset_.Clear();
-}
-inline ::google::protobuf::uint32 CropParameter::offset(int index) const {
- // @@protoc_insertion_point(field_get:caffe.CropParameter.offset)
- return offset_.Get(index);
-}
-inline void CropParameter::set_offset(int index, ::google::protobuf::uint32 value) {
- offset_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.CropParameter.offset)
-}
-inline void CropParameter::add_offset(::google::protobuf::uint32 value) {
- offset_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.CropParameter.offset)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-CropParameter::offset() const {
- // @@protoc_insertion_point(field_list:caffe.CropParameter.offset)
- return offset_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-CropParameter::mutable_offset() {
- // @@protoc_insertion_point(field_mutable_list:caffe.CropParameter.offset)
- return &offset_;
-}
-
-inline const CropParameter* CropParameter::internal_default_instance() {
- return &CropParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// PermuteParameter
-
-// repeated uint32 order = 1;
-inline int PermuteParameter::order_size() const {
- return order_.size();
-}
-inline void PermuteParameter::clear_order() {
- order_.Clear();
-}
-inline ::google::protobuf::uint32 PermuteParameter::order(int index) const {
- // @@protoc_insertion_point(field_get:caffe.PermuteParameter.order)
- return order_.Get(index);
-}
-inline void PermuteParameter::set_order(int index, ::google::protobuf::uint32 value) {
- order_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.PermuteParameter.order)
-}
-inline void PermuteParameter::add_order(::google::protobuf::uint32 value) {
- order_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.PermuteParameter.order)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-PermuteParameter::order() const {
- // @@protoc_insertion_point(field_list:caffe.PermuteParameter.order)
- return order_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-PermuteParameter::mutable_order() {
- // @@protoc_insertion_point(field_mutable_list:caffe.PermuteParameter.order)
- return &order_;
-}
-
-inline const PermuteParameter* PermuteParameter::internal_default_instance() {
- return &PermuteParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// NormalizeBBoxParameter
-
-// optional bool across_spatial = 1 [default = true];
-inline bool NormalizeBBoxParameter::has_across_spatial() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void NormalizeBBoxParameter::set_has_across_spatial() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void NormalizeBBoxParameter::clear_has_across_spatial() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void NormalizeBBoxParameter::clear_across_spatial() {
- across_spatial_ = true;
- clear_has_across_spatial();
-}
-inline bool NormalizeBBoxParameter::across_spatial() const {
- // @@protoc_insertion_point(field_get:caffe.NormalizeBBoxParameter.across_spatial)
- return across_spatial_;
-}
-inline void NormalizeBBoxParameter::set_across_spatial(bool value) {
- set_has_across_spatial();
- across_spatial_ = value;
- // @@protoc_insertion_point(field_set:caffe.NormalizeBBoxParameter.across_spatial)
-}
-
-// optional .caffe.FillerParameter scale_filler = 2;
-inline bool NormalizeBBoxParameter::has_scale_filler() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void NormalizeBBoxParameter::set_has_scale_filler() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void NormalizeBBoxParameter::clear_has_scale_filler() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void NormalizeBBoxParameter::clear_scale_filler() {
- if (scale_filler_ != NULL) scale_filler_->::caffe::FillerParameter::Clear();
- clear_has_scale_filler();
-}
-inline const ::caffe::FillerParameter& NormalizeBBoxParameter::scale_filler() const {
- // @@protoc_insertion_point(field_get:caffe.NormalizeBBoxParameter.scale_filler)
- return scale_filler_ != NULL ? *scale_filler_
- : *::caffe::FillerParameter::internal_default_instance();
-}
-inline ::caffe::FillerParameter* NormalizeBBoxParameter::mutable_scale_filler() {
- set_has_scale_filler();
- if (scale_filler_ == NULL) {
- scale_filler_ = new ::caffe::FillerParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.NormalizeBBoxParameter.scale_filler)
- return scale_filler_;
-}
-inline ::caffe::FillerParameter* NormalizeBBoxParameter::release_scale_filler() {
- // @@protoc_insertion_point(field_release:caffe.NormalizeBBoxParameter.scale_filler)
- clear_has_scale_filler();
- ::caffe::FillerParameter* temp = scale_filler_;
- scale_filler_ = NULL;
- return temp;
-}
-inline void NormalizeBBoxParameter::set_allocated_scale_filler(::caffe::FillerParameter* scale_filler) {
- delete scale_filler_;
- scale_filler_ = scale_filler;
- if (scale_filler) {
- set_has_scale_filler();
- } else {
- clear_has_scale_filler();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.NormalizeBBoxParameter.scale_filler)
-}
-
-// optional bool channel_shared = 3 [default = true];
-inline bool NormalizeBBoxParameter::has_channel_shared() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void NormalizeBBoxParameter::set_has_channel_shared() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void NormalizeBBoxParameter::clear_has_channel_shared() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void NormalizeBBoxParameter::clear_channel_shared() {
- channel_shared_ = true;
- clear_has_channel_shared();
-}
-inline bool NormalizeBBoxParameter::channel_shared() const {
- // @@protoc_insertion_point(field_get:caffe.NormalizeBBoxParameter.channel_shared)
- return channel_shared_;
-}
-inline void NormalizeBBoxParameter::set_channel_shared(bool value) {
- set_has_channel_shared();
- channel_shared_ = value;
- // @@protoc_insertion_point(field_set:caffe.NormalizeBBoxParameter.channel_shared)
-}
-
-// optional float eps = 4 [default = 1e-10];
-inline bool NormalizeBBoxParameter::has_eps() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void NormalizeBBoxParameter::set_has_eps() {
- _has_bits_[0] |= 0x00000008u;
-}
-inline void NormalizeBBoxParameter::clear_has_eps() {
- _has_bits_[0] &= ~0x00000008u;
-}
-inline void NormalizeBBoxParameter::clear_eps() {
- eps_ = 1e-10f;
- clear_has_eps();
-}
-inline float NormalizeBBoxParameter::eps() const {
- // @@protoc_insertion_point(field_get:caffe.NormalizeBBoxParameter.eps)
- return eps_;
-}
-inline void NormalizeBBoxParameter::set_eps(float value) {
- set_has_eps();
- eps_ = value;
- // @@protoc_insertion_point(field_set:caffe.NormalizeBBoxParameter.eps)
-}
-
-inline const NormalizeBBoxParameter* NormalizeBBoxParameter::internal_default_instance() {
- return &NormalizeBBoxParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// PriorBoxParameter
-
-// optional float min_size = 1;
-inline bool PriorBoxParameter::has_min_size() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void PriorBoxParameter::set_has_min_size() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void PriorBoxParameter::clear_has_min_size() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void PriorBoxParameter::clear_min_size() {
- min_size_ = 0;
- clear_has_min_size();
-}
-inline float PriorBoxParameter::min_size() const {
- // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.min_size)
- return min_size_;
-}
-inline void PriorBoxParameter::set_min_size(float value) {
- set_has_min_size();
- min_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.min_size)
-}
-
-// optional float max_size = 2;
-inline bool PriorBoxParameter::has_max_size() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void PriorBoxParameter::set_has_max_size() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void PriorBoxParameter::clear_has_max_size() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void PriorBoxParameter::clear_max_size() {
- max_size_ = 0;
- clear_has_max_size();
-}
-inline float PriorBoxParameter::max_size() const {
- // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.max_size)
- return max_size_;
-}
-inline void PriorBoxParameter::set_max_size(float value) {
- set_has_max_size();
- max_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.max_size)
-}
-
-// repeated float aspect_ratio = 3;
-inline int PriorBoxParameter::aspect_ratio_size() const {
- return aspect_ratio_.size();
-}
-inline void PriorBoxParameter::clear_aspect_ratio() {
- aspect_ratio_.Clear();
-}
-inline float PriorBoxParameter::aspect_ratio(int index) const {
- // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.aspect_ratio)
- return aspect_ratio_.Get(index);
-}
-inline void PriorBoxParameter::set_aspect_ratio(int index, float value) {
- aspect_ratio_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.aspect_ratio)
-}
-inline void PriorBoxParameter::add_aspect_ratio(float value) {
- aspect_ratio_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.PriorBoxParameter.aspect_ratio)
-}
-inline const ::google::protobuf::RepeatedField< float >&
-PriorBoxParameter::aspect_ratio() const {
- // @@protoc_insertion_point(field_list:caffe.PriorBoxParameter.aspect_ratio)
- return aspect_ratio_;
-}
-inline ::google::protobuf::RepeatedField< float >*
-PriorBoxParameter::mutable_aspect_ratio() {
- // @@protoc_insertion_point(field_mutable_list:caffe.PriorBoxParameter.aspect_ratio)
- return &aspect_ratio_;
-}
-
-// optional bool flip = 4 [default = true];
-inline bool PriorBoxParameter::has_flip() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void PriorBoxParameter::set_has_flip() {
- _has_bits_[0] |= 0x00000008u;
-}
-inline void PriorBoxParameter::clear_has_flip() {
- _has_bits_[0] &= ~0x00000008u;
-}
-inline void PriorBoxParameter::clear_flip() {
- flip_ = true;
- clear_has_flip();
-}
-inline bool PriorBoxParameter::flip() const {
- // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.flip)
- return flip_;
-}
-inline void PriorBoxParameter::set_flip(bool value) {
- set_has_flip();
- flip_ = value;
- // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.flip)
-}
-
-// optional bool clip = 5 [default = true];
-inline bool PriorBoxParameter::has_clip() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-inline void PriorBoxParameter::set_has_clip() {
- _has_bits_[0] |= 0x00000010u;
-}
-inline void PriorBoxParameter::clear_has_clip() {
- _has_bits_[0] &= ~0x00000010u;
-}
-inline void PriorBoxParameter::clear_clip() {
- clip_ = true;
- clear_has_clip();
-}
-inline bool PriorBoxParameter::clip() const {
- // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.clip)
- return clip_;
-}
-inline void PriorBoxParameter::set_clip(bool value) {
- set_has_clip();
- clip_ = value;
- // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.clip)
-}
-
-// repeated float variance = 6;
-inline int PriorBoxParameter::variance_size() const {
- return variance_.size();
-}
-inline void PriorBoxParameter::clear_variance() {
- variance_.Clear();
-}
-inline float PriorBoxParameter::variance(int index) const {
- // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.variance)
- return variance_.Get(index);
-}
-inline void PriorBoxParameter::set_variance(int index, float value) {
- variance_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.variance)
-}
-inline void PriorBoxParameter::add_variance(float value) {
- variance_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.PriorBoxParameter.variance)
-}
-inline const ::google::protobuf::RepeatedField< float >&
-PriorBoxParameter::variance() const {
- // @@protoc_insertion_point(field_list:caffe.PriorBoxParameter.variance)
- return variance_;
-}
-inline ::google::protobuf::RepeatedField< float >*
-PriorBoxParameter::mutable_variance() {
- // @@protoc_insertion_point(field_mutable_list:caffe.PriorBoxParameter.variance)
- return &variance_;
-}
-
-inline const PriorBoxParameter* PriorBoxParameter::internal_default_instance() {
- return &PriorBoxParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// DetectionOutputParameter
-
-// optional uint32 num_classes = 1;
-inline bool DetectionOutputParameter::has_num_classes() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void DetectionOutputParameter::set_has_num_classes() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void DetectionOutputParameter::clear_has_num_classes() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void DetectionOutputParameter::clear_num_classes() {
- num_classes_ = 0u;
- clear_has_num_classes();
-}
-inline ::google::protobuf::uint32 DetectionOutputParameter::num_classes() const {
- // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.num_classes)
- return num_classes_;
-}
-inline void DetectionOutputParameter::set_num_classes(::google::protobuf::uint32 value) {
- set_has_num_classes();
- num_classes_ = value;
- // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.num_classes)
-}
-
-// optional bool share_location = 2 [default = true];
-inline bool DetectionOutputParameter::has_share_location() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void DetectionOutputParameter::set_has_share_location() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void DetectionOutputParameter::clear_has_share_location() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void DetectionOutputParameter::clear_share_location() {
- share_location_ = true;
- clear_has_share_location();
-}
-inline bool DetectionOutputParameter::share_location() const {
- // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.share_location)
- return share_location_;
-}
-inline void DetectionOutputParameter::set_share_location(bool value) {
- set_has_share_location();
- share_location_ = value;
- // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.share_location)
-}
-
-// optional int32 background_label_id = 3 [default = 0];
-inline bool DetectionOutputParameter::has_background_label_id() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void DetectionOutputParameter::set_has_background_label_id() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void DetectionOutputParameter::clear_has_background_label_id() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void DetectionOutputParameter::clear_background_label_id() {
- background_label_id_ = 0;
- clear_has_background_label_id();
-}
-inline ::google::protobuf::int32 DetectionOutputParameter::background_label_id() const {
- // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.background_label_id)
- return background_label_id_;
-}
-inline void DetectionOutputParameter::set_background_label_id(::google::protobuf::int32 value) {
- set_has_background_label_id();
- background_label_id_ = value;
- // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.background_label_id)
-}
-
-// optional .caffe.PriorBoxParameter.CodeType code_type = 6 [default = CORNER];
-inline bool DetectionOutputParameter::has_code_type() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void DetectionOutputParameter::set_has_code_type() {
- _has_bits_[0] |= 0x00000008u;
-}
-inline void DetectionOutputParameter::clear_has_code_type() {
- _has_bits_[0] &= ~0x00000008u;
-}
-inline void DetectionOutputParameter::clear_code_type() {
- code_type_ = 1;
- clear_has_code_type();
-}
-inline ::caffe::PriorBoxParameter_CodeType DetectionOutputParameter::code_type() const {
- // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.code_type)
- return static_cast< ::caffe::PriorBoxParameter_CodeType >(code_type_);
-}
-inline void DetectionOutputParameter::set_code_type(::caffe::PriorBoxParameter_CodeType value) {
- assert(::caffe::PriorBoxParameter_CodeType_IsValid(value));
- set_has_code_type();
- code_type_ = value;
- // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.code_type)
-}
-
-// optional bool variance_encoded_in_target = 8 [default = false];
-inline bool DetectionOutputParameter::has_variance_encoded_in_target() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-inline void DetectionOutputParameter::set_has_variance_encoded_in_target() {
- _has_bits_[0] |= 0x00000010u;
-}
-inline void DetectionOutputParameter::clear_has_variance_encoded_in_target() {
- _has_bits_[0] &= ~0x00000010u;
-}
-inline void DetectionOutputParameter::clear_variance_encoded_in_target() {
- variance_encoded_in_target_ = false;
- clear_has_variance_encoded_in_target();
-}
-inline bool DetectionOutputParameter::variance_encoded_in_target() const {
- // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.variance_encoded_in_target)
- return variance_encoded_in_target_;
-}
-inline void DetectionOutputParameter::set_variance_encoded_in_target(bool value) {
- set_has_variance_encoded_in_target();
- variance_encoded_in_target_ = value;
- // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.variance_encoded_in_target)
-}
-
-// optional int32 keep_top_k = 7 [default = -1];
-inline bool DetectionOutputParameter::has_keep_top_k() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-inline void DetectionOutputParameter::set_has_keep_top_k() {
- _has_bits_[0] |= 0x00000020u;
-}
-inline void DetectionOutputParameter::clear_has_keep_top_k() {
- _has_bits_[0] &= ~0x00000020u;
-}
-inline void DetectionOutputParameter::clear_keep_top_k() {
- keep_top_k_ = -1;
- clear_has_keep_top_k();
-}
-inline ::google::protobuf::int32 DetectionOutputParameter::keep_top_k() const {
- // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.keep_top_k)
- return keep_top_k_;
-}
-inline void DetectionOutputParameter::set_keep_top_k(::google::protobuf::int32 value) {
- set_has_keep_top_k();
- keep_top_k_ = value;
- // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.keep_top_k)
-}
-
-// optional float confidence_threshold = 9;
-inline bool DetectionOutputParameter::has_confidence_threshold() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-inline void DetectionOutputParameter::set_has_confidence_threshold() {
- _has_bits_[0] |= 0x00000040u;
-}
-inline void DetectionOutputParameter::clear_has_confidence_threshold() {
- _has_bits_[0] &= ~0x00000040u;
-}
-inline void DetectionOutputParameter::clear_confidence_threshold() {
- confidence_threshold_ = 0;
- clear_has_confidence_threshold();
-}
-inline float DetectionOutputParameter::confidence_threshold() const {
- // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.confidence_threshold)
- return confidence_threshold_;
-}
-inline void DetectionOutputParameter::set_confidence_threshold(float value) {
- set_has_confidence_threshold();
- confidence_threshold_ = value;
- // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.confidence_threshold)
-}
-
-// optional float nms_threshold = 10 [default = 0.3];
-inline bool DetectionOutputParameter::has_nms_threshold() const {
- return (_has_bits_[0] & 0x00000080u) != 0;
-}
-inline void DetectionOutputParameter::set_has_nms_threshold() {
- _has_bits_[0] |= 0x00000080u;
-}
-inline void DetectionOutputParameter::clear_has_nms_threshold() {
- _has_bits_[0] &= ~0x00000080u;
-}
-inline void DetectionOutputParameter::clear_nms_threshold() {
- nms_threshold_ = 0.3f;
- clear_has_nms_threshold();
-}
-inline float DetectionOutputParameter::nms_threshold() const {
- // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.nms_threshold)
- return nms_threshold_;
-}
-inline void DetectionOutputParameter::set_nms_threshold(float value) {
- set_has_nms_threshold();
- nms_threshold_ = value;
- // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.nms_threshold)
-}
-
-// optional int32 top_k = 11;
-inline bool DetectionOutputParameter::has_top_k() const {
- return (_has_bits_[0] & 0x00000100u) != 0;
-}
-inline void DetectionOutputParameter::set_has_top_k() {
- _has_bits_[0] |= 0x00000100u;
-}
-inline void DetectionOutputParameter::clear_has_top_k() {
- _has_bits_[0] &= ~0x00000100u;
-}
-inline void DetectionOutputParameter::clear_top_k() {
- top_k_ = 0;
- clear_has_top_k();
-}
-inline ::google::protobuf::int32 DetectionOutputParameter::top_k() const {
- // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.top_k)
- return top_k_;
-}
-inline void DetectionOutputParameter::set_top_k(::google::protobuf::int32 value) {
- set_has_top_k();
- top_k_ = value;
- // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.top_k)
-}
-
-inline const DetectionOutputParameter* DetectionOutputParameter::internal_default_instance() {
- return &DetectionOutputParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// Datum
-
-// optional int32 channels = 1;
-inline bool Datum::has_channels() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void Datum::set_has_channels() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void Datum::clear_has_channels() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void Datum::clear_channels() {
- channels_ = 0;
- clear_has_channels();
-}
-inline ::google::protobuf::int32 Datum::channels() const {
- // @@protoc_insertion_point(field_get:caffe.Datum.channels)
- return channels_;
-}
-inline void Datum::set_channels(::google::protobuf::int32 value) {
- set_has_channels();
- channels_ = value;
- // @@protoc_insertion_point(field_set:caffe.Datum.channels)
-}
-
-// optional int32 height = 2;
-inline bool Datum::has_height() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void Datum::set_has_height() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void Datum::clear_has_height() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void Datum::clear_height() {
- height_ = 0;
- clear_has_height();
-}
-inline ::google::protobuf::int32 Datum::height() const {
- // @@protoc_insertion_point(field_get:caffe.Datum.height)
- return height_;
-}
-inline void Datum::set_height(::google::protobuf::int32 value) {
- set_has_height();
- height_ = value;
- // @@protoc_insertion_point(field_set:caffe.Datum.height)
-}
-
-// optional int32 width = 3;
-inline bool Datum::has_width() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void Datum::set_has_width() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void Datum::clear_has_width() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void Datum::clear_width() {
- width_ = 0;
- clear_has_width();
-}
-inline ::google::protobuf::int32 Datum::width() const {
- // @@protoc_insertion_point(field_get:caffe.Datum.width)
- return width_;
-}
-inline void Datum::set_width(::google::protobuf::int32 value) {
- set_has_width();
- width_ = value;
- // @@protoc_insertion_point(field_set:caffe.Datum.width)
-}
-
-// optional bytes data = 4;
-inline bool Datum::has_data() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void Datum::set_has_data() {
- _has_bits_[0] |= 0x00000008u;
-}
-inline void Datum::clear_has_data() {
- _has_bits_[0] &= ~0x00000008u;
-}
-inline void Datum::clear_data() {
- data_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_data();
-}
-inline const ::std::string& Datum::data() const {
- // @@protoc_insertion_point(field_get:caffe.Datum.data)
- return data_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void Datum::set_data(const ::std::string& value) {
- set_has_data();
- data_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.Datum.data)
-}
-inline void Datum::set_data(const char* value) {
- set_has_data();
- data_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.Datum.data)
-}
-inline void Datum::set_data(const void* value, size_t size) {
- set_has_data();
- data_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.Datum.data)
-}
-inline ::std::string* Datum::mutable_data() {
- set_has_data();
- // @@protoc_insertion_point(field_mutable:caffe.Datum.data)
- return data_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* Datum::release_data() {
- // @@protoc_insertion_point(field_release:caffe.Datum.data)
- clear_has_data();
- return data_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void Datum::set_allocated_data(::std::string* data) {
- if (data != NULL) {
- set_has_data();
- } else {
- clear_has_data();
- }
- data_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), data);
- // @@protoc_insertion_point(field_set_allocated:caffe.Datum.data)
-}
-
-// optional int32 label = 5;
-inline bool Datum::has_label() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-inline void Datum::set_has_label() {
- _has_bits_[0] |= 0x00000010u;
-}
-inline void Datum::clear_has_label() {
- _has_bits_[0] &= ~0x00000010u;
-}
-inline void Datum::clear_label() {
- label_ = 0;
- clear_has_label();
-}
-inline ::google::protobuf::int32 Datum::label() const {
- // @@protoc_insertion_point(field_get:caffe.Datum.label)
- return label_;
-}
-inline void Datum::set_label(::google::protobuf::int32 value) {
- set_has_label();
- label_ = value;
- // @@protoc_insertion_point(field_set:caffe.Datum.label)
-}
-
-// repeated float float_data = 6;
-inline int Datum::float_data_size() const {
- return float_data_.size();
-}
-inline void Datum::clear_float_data() {
- float_data_.Clear();
-}
-inline float Datum::float_data(int index) const {
- // @@protoc_insertion_point(field_get:caffe.Datum.float_data)
- return float_data_.Get(index);
-}
-inline void Datum::set_float_data(int index, float value) {
- float_data_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.Datum.float_data)
-}
-inline void Datum::add_float_data(float value) {
- float_data_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.Datum.float_data)
-}
-inline const ::google::protobuf::RepeatedField< float >&
-Datum::float_data() const {
- // @@protoc_insertion_point(field_list:caffe.Datum.float_data)
- return float_data_;
-}
-inline ::google::protobuf::RepeatedField< float >*
-Datum::mutable_float_data() {
- // @@protoc_insertion_point(field_mutable_list:caffe.Datum.float_data)
- return &float_data_;
-}
-
-// optional bool encoded = 7 [default = false];
-inline bool Datum::has_encoded() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-inline void Datum::set_has_encoded() {
- _has_bits_[0] |= 0x00000040u;
-}
-inline void Datum::clear_has_encoded() {
- _has_bits_[0] &= ~0x00000040u;
-}
-inline void Datum::clear_encoded() {
- encoded_ = false;
- clear_has_encoded();
-}
-inline bool Datum::encoded() const {
- // @@protoc_insertion_point(field_get:caffe.Datum.encoded)
- return encoded_;
-}
-inline void Datum::set_encoded(bool value) {
- set_has_encoded();
- encoded_ = value;
- // @@protoc_insertion_point(field_set:caffe.Datum.encoded)
-}
-
-inline const Datum* Datum::internal_default_instance() {
- return &Datum_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// FillerParameter
-
-// optional string type = 1 [default = "constant"];
-inline bool FillerParameter::has_type() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void FillerParameter::set_has_type() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void FillerParameter::clear_has_type() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void FillerParameter::clear_type() {
- type_.ClearToDefaultNoArena(_default_type_);
- clear_has_type();
-}
-inline const ::std::string& FillerParameter::type() const {
- // @@protoc_insertion_point(field_get:caffe.FillerParameter.type)
- return type_.GetNoArena(_default_type_);
-}
-inline void FillerParameter::set_type(const ::std::string& value) {
- set_has_type();
- type_.SetNoArena(_default_type_, value);
- // @@protoc_insertion_point(field_set:caffe.FillerParameter.type)
-}
-inline void FillerParameter::set_type(const char* value) {
- set_has_type();
- type_.SetNoArena(_default_type_, ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.FillerParameter.type)
-}
-inline void FillerParameter::set_type(const char* value, size_t size) {
- set_has_type();
- type_.SetNoArena(_default_type_,
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.FillerParameter.type)
-}
-inline ::std::string* FillerParameter::mutable_type() {
- set_has_type();
- // @@protoc_insertion_point(field_mutable:caffe.FillerParameter.type)
- return type_.MutableNoArena(_default_type_);
-}
-inline ::std::string* FillerParameter::release_type() {
- // @@protoc_insertion_point(field_release:caffe.FillerParameter.type)
- clear_has_type();
- return type_.ReleaseNoArena(_default_type_);
-}
-inline void FillerParameter::set_allocated_type(::std::string* type) {
- if (type != NULL) {
- set_has_type();
- } else {
- clear_has_type();
- }
- type_.SetAllocatedNoArena(_default_type_, type);
- // @@protoc_insertion_point(field_set_allocated:caffe.FillerParameter.type)
-}
-
-// optional float value = 2 [default = 0];
-inline bool FillerParameter::has_value() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void FillerParameter::set_has_value() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void FillerParameter::clear_has_value() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void FillerParameter::clear_value() {
- value_ = 0;
- clear_has_value();
-}
-inline float FillerParameter::value() const {
- // @@protoc_insertion_point(field_get:caffe.FillerParameter.value)
- return value_;
-}
-inline void FillerParameter::set_value(float value) {
- set_has_value();
- value_ = value;
- // @@protoc_insertion_point(field_set:caffe.FillerParameter.value)
-}
-
-// optional float min = 3 [default = 0];
-inline bool FillerParameter::has_min() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void FillerParameter::set_has_min() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void FillerParameter::clear_has_min() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void FillerParameter::clear_min() {
- min_ = 0;
- clear_has_min();
-}
-inline float FillerParameter::min() const {
- // @@protoc_insertion_point(field_get:caffe.FillerParameter.min)
- return min_;
-}
-inline void FillerParameter::set_min(float value) {
- set_has_min();
- min_ = value;
- // @@protoc_insertion_point(field_set:caffe.FillerParameter.min)
-}
-
-// optional float max = 4 [default = 1];
-inline bool FillerParameter::has_max() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void FillerParameter::set_has_max() {
- _has_bits_[0] |= 0x00000008u;
-}
-inline void FillerParameter::clear_has_max() {
- _has_bits_[0] &= ~0x00000008u;
-}
-inline void FillerParameter::clear_max() {
- max_ = 1;
- clear_has_max();
-}
-inline float FillerParameter::max() const {
- // @@protoc_insertion_point(field_get:caffe.FillerParameter.max)
- return max_;
-}
-inline void FillerParameter::set_max(float value) {
- set_has_max();
- max_ = value;
- // @@protoc_insertion_point(field_set:caffe.FillerParameter.max)
-}
-
-// optional float mean = 5 [default = 0];
-inline bool FillerParameter::has_mean() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-inline void FillerParameter::set_has_mean() {
- _has_bits_[0] |= 0x00000010u;
-}
-inline void FillerParameter::clear_has_mean() {
- _has_bits_[0] &= ~0x00000010u;
-}
-inline void FillerParameter::clear_mean() {
- mean_ = 0;
- clear_has_mean();
-}
-inline float FillerParameter::mean() const {
- // @@protoc_insertion_point(field_get:caffe.FillerParameter.mean)
- return mean_;
-}
-inline void FillerParameter::set_mean(float value) {
- set_has_mean();
- mean_ = value;
- // @@protoc_insertion_point(field_set:caffe.FillerParameter.mean)
-}
-
-// optional float std = 6 [default = 1];
-inline bool FillerParameter::has_std() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-inline void FillerParameter::set_has_std() {
- _has_bits_[0] |= 0x00000020u;
-}
-inline void FillerParameter::clear_has_std() {
- _has_bits_[0] &= ~0x00000020u;
-}
-inline void FillerParameter::clear_std() {
- std_ = 1;
- clear_has_std();
-}
-inline float FillerParameter::std() const {
- // @@protoc_insertion_point(field_get:caffe.FillerParameter.std)
- return std_;
-}
-inline void FillerParameter::set_std(float value) {
- set_has_std();
- std_ = value;
- // @@protoc_insertion_point(field_set:caffe.FillerParameter.std)
-}
-
-// optional int32 sparse = 7 [default = -1];
-inline bool FillerParameter::has_sparse() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-inline void FillerParameter::set_has_sparse() {
- _has_bits_[0] |= 0x00000040u;
-}
-inline void FillerParameter::clear_has_sparse() {
- _has_bits_[0] &= ~0x00000040u;
-}
-inline void FillerParameter::clear_sparse() {
- sparse_ = -1;
- clear_has_sparse();
-}
-inline ::google::protobuf::int32 FillerParameter::sparse() const {
- // @@protoc_insertion_point(field_get:caffe.FillerParameter.sparse)
- return sparse_;
-}
-inline void FillerParameter::set_sparse(::google::protobuf::int32 value) {
- set_has_sparse();
- sparse_ = value;
- // @@protoc_insertion_point(field_set:caffe.FillerParameter.sparse)
-}
-
-// optional .caffe.FillerParameter.VarianceNorm variance_norm = 8 [default = FAN_IN];
-inline bool FillerParameter::has_variance_norm() const {
- return (_has_bits_[0] & 0x00000080u) != 0;
-}
-inline void FillerParameter::set_has_variance_norm() {
- _has_bits_[0] |= 0x00000080u;
-}
-inline void FillerParameter::clear_has_variance_norm() {
- _has_bits_[0] &= ~0x00000080u;
-}
-inline void FillerParameter::clear_variance_norm() {
- variance_norm_ = 0;
- clear_has_variance_norm();
-}
-inline ::caffe::FillerParameter_VarianceNorm FillerParameter::variance_norm() const {
- // @@protoc_insertion_point(field_get:caffe.FillerParameter.variance_norm)
- return static_cast< ::caffe::FillerParameter_VarianceNorm >(variance_norm_);
-}
-inline void FillerParameter::set_variance_norm(::caffe::FillerParameter_VarianceNorm value) {
- assert(::caffe::FillerParameter_VarianceNorm_IsValid(value));
- set_has_variance_norm();
- variance_norm_ = value;
- // @@protoc_insertion_point(field_set:caffe.FillerParameter.variance_norm)
-}
-
-inline const FillerParameter* FillerParameter::internal_default_instance() {
- return &FillerParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// NetParameter
-
-// optional string name = 1;
-inline bool NetParameter::has_name() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void NetParameter::set_has_name() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void NetParameter::clear_has_name() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void NetParameter::clear_name() {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_name();
-}
-inline const ::std::string& NetParameter::name() const {
- // @@protoc_insertion_point(field_get:caffe.NetParameter.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void NetParameter::set_name(const ::std::string& value) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.NetParameter.name)
-}
-inline void NetParameter::set_name(const char* value) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.NetParameter.name)
-}
-inline void NetParameter::set_name(const char* value, size_t size) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.NetParameter.name)
-}
-inline ::std::string* NetParameter::mutable_name() {
- set_has_name();
- // @@protoc_insertion_point(field_mutable:caffe.NetParameter.name)
- return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* NetParameter::release_name() {
- // @@protoc_insertion_point(field_release:caffe.NetParameter.name)
- clear_has_name();
- return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void NetParameter::set_allocated_name(::std::string* name) {
- if (name != NULL) {
- set_has_name();
- } else {
- clear_has_name();
- }
- name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
- // @@protoc_insertion_point(field_set_allocated:caffe.NetParameter.name)
-}
-
-// repeated string input = 3;
-inline int NetParameter::input_size() const {
- return input_.size();
-}
-inline void NetParameter::clear_input() {
- input_.Clear();
-}
-inline const ::std::string& NetParameter::input(int index) const {
- // @@protoc_insertion_point(field_get:caffe.NetParameter.input)
- return input_.Get(index);
-}
-inline ::std::string* NetParameter::mutable_input(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.NetParameter.input)
- return input_.Mutable(index);
-}
-inline void NetParameter::set_input(int index, const ::std::string& value) {
- // @@protoc_insertion_point(field_set:caffe.NetParameter.input)
- input_.Mutable(index)->assign(value);
-}
-inline void NetParameter::set_input(int index, const char* value) {
- input_.Mutable(index)->assign(value);
- // @@protoc_insertion_point(field_set_char:caffe.NetParameter.input)
-}
-inline void NetParameter::set_input(int index, const char* value, size_t size) {
- input_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:caffe.NetParameter.input)
-}
-inline ::std::string* NetParameter::add_input() {
- // @@protoc_insertion_point(field_add_mutable:caffe.NetParameter.input)
- return input_.Add();
-}
-inline void NetParameter::add_input(const ::std::string& value) {
- input_.Add()->assign(value);
- // @@protoc_insertion_point(field_add:caffe.NetParameter.input)
-}
-inline void NetParameter::add_input(const char* value) {
- input_.Add()->assign(value);
- // @@protoc_insertion_point(field_add_char:caffe.NetParameter.input)
-}
-inline void NetParameter::add_input(const char* value, size_t size) {
- input_.Add()->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_add_pointer:caffe.NetParameter.input)
-}
-inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
-NetParameter::input() const {
- // @@protoc_insertion_point(field_list:caffe.NetParameter.input)
- return input_;
-}
-inline ::google::protobuf::RepeatedPtrField< ::std::string>*
-NetParameter::mutable_input() {
- // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.input)
- return &input_;
-}
-
-// repeated .caffe.BlobShape input_shape = 8;
-inline int NetParameter::input_shape_size() const {
- return input_shape_.size();
-}
-inline void NetParameter::clear_input_shape() {
- input_shape_.Clear();
-}
-inline const ::caffe::BlobShape& NetParameter::input_shape(int index) const {
- // @@protoc_insertion_point(field_get:caffe.NetParameter.input_shape)
- return input_shape_.Get(index);
-}
-inline ::caffe::BlobShape* NetParameter::mutable_input_shape(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.NetParameter.input_shape)
- return input_shape_.Mutable(index);
-}
-inline ::caffe::BlobShape* NetParameter::add_input_shape() {
- // @@protoc_insertion_point(field_add:caffe.NetParameter.input_shape)
- return input_shape_.Add();
-}
-inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >*
-NetParameter::mutable_input_shape() {
- // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.input_shape)
- return &input_shape_;
-}
-inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >&
-NetParameter::input_shape() const {
- // @@protoc_insertion_point(field_list:caffe.NetParameter.input_shape)
- return input_shape_;
-}
-
-// repeated int32 input_dim = 4;
-inline int NetParameter::input_dim_size() const {
- return input_dim_.size();
-}
-inline void NetParameter::clear_input_dim() {
- input_dim_.Clear();
-}
-inline ::google::protobuf::int32 NetParameter::input_dim(int index) const {
- // @@protoc_insertion_point(field_get:caffe.NetParameter.input_dim)
- return input_dim_.Get(index);
-}
-inline void NetParameter::set_input_dim(int index, ::google::protobuf::int32 value) {
- input_dim_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.NetParameter.input_dim)
-}
-inline void NetParameter::add_input_dim(::google::protobuf::int32 value) {
- input_dim_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.NetParameter.input_dim)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
-NetParameter::input_dim() const {
- // @@protoc_insertion_point(field_list:caffe.NetParameter.input_dim)
- return input_dim_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
-NetParameter::mutable_input_dim() {
- // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.input_dim)
- return &input_dim_;
-}
-
-// optional bool force_backward = 5 [default = false];
-inline bool NetParameter::has_force_backward() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-inline void NetParameter::set_has_force_backward() {
- _has_bits_[0] |= 0x00000010u;
-}
-inline void NetParameter::clear_has_force_backward() {
- _has_bits_[0] &= ~0x00000010u;
-}
-inline void NetParameter::clear_force_backward() {
- force_backward_ = false;
- clear_has_force_backward();
-}
-inline bool NetParameter::force_backward() const {
- // @@protoc_insertion_point(field_get:caffe.NetParameter.force_backward)
- return force_backward_;
-}
-inline void NetParameter::set_force_backward(bool value) {
- set_has_force_backward();
- force_backward_ = value;
- // @@protoc_insertion_point(field_set:caffe.NetParameter.force_backward)
-}
-
-// optional .caffe.NetState state = 6;
-inline bool NetParameter::has_state() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-inline void NetParameter::set_has_state() {
- _has_bits_[0] |= 0x00000020u;
-}
-inline void NetParameter::clear_has_state() {
- _has_bits_[0] &= ~0x00000020u;
-}
-inline void NetParameter::clear_state() {
- if (state_ != NULL) state_->::caffe::NetState::Clear();
- clear_has_state();
-}
-inline const ::caffe::NetState& NetParameter::state() const {
- // @@protoc_insertion_point(field_get:caffe.NetParameter.state)
- return state_ != NULL ? *state_
- : *::caffe::NetState::internal_default_instance();
-}
-inline ::caffe::NetState* NetParameter::mutable_state() {
- set_has_state();
- if (state_ == NULL) {
- state_ = new ::caffe::NetState;
- }
- // @@protoc_insertion_point(field_mutable:caffe.NetParameter.state)
- return state_;
-}
-inline ::caffe::NetState* NetParameter::release_state() {
- // @@protoc_insertion_point(field_release:caffe.NetParameter.state)
- clear_has_state();
- ::caffe::NetState* temp = state_;
- state_ = NULL;
- return temp;
-}
-inline void NetParameter::set_allocated_state(::caffe::NetState* state) {
- delete state_;
- state_ = state;
- if (state) {
- set_has_state();
- } else {
- clear_has_state();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.NetParameter.state)
-}
-
-// optional bool debug_info = 7 [default = false];
-inline bool NetParameter::has_debug_info() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-inline void NetParameter::set_has_debug_info() {
- _has_bits_[0] |= 0x00000040u;
-}
-inline void NetParameter::clear_has_debug_info() {
- _has_bits_[0] &= ~0x00000040u;
-}
-inline void NetParameter::clear_debug_info() {
- debug_info_ = false;
- clear_has_debug_info();
-}
-inline bool NetParameter::debug_info() const {
- // @@protoc_insertion_point(field_get:caffe.NetParameter.debug_info)
- return debug_info_;
-}
-inline void NetParameter::set_debug_info(bool value) {
- set_has_debug_info();
- debug_info_ = value;
- // @@protoc_insertion_point(field_set:caffe.NetParameter.debug_info)
-}
-
-// repeated .caffe.LayerParameter layer = 100;
-inline int NetParameter::layer_size() const {
- return layer_.size();
-}
-inline void NetParameter::clear_layer() {
- layer_.Clear();
-}
-inline const ::caffe::LayerParameter& NetParameter::layer(int index) const {
- // @@protoc_insertion_point(field_get:caffe.NetParameter.layer)
- return layer_.Get(index);
-}
-inline ::caffe::LayerParameter* NetParameter::mutable_layer(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.NetParameter.layer)
- return layer_.Mutable(index);
-}
-inline ::caffe::LayerParameter* NetParameter::add_layer() {
- // @@protoc_insertion_point(field_add:caffe.NetParameter.layer)
- return layer_.Add();
-}
-inline ::google::protobuf::RepeatedPtrField< ::caffe::LayerParameter >*
-NetParameter::mutable_layer() {
- // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.layer)
- return &layer_;
-}
-inline const ::google::protobuf::RepeatedPtrField< ::caffe::LayerParameter >&
-NetParameter::layer() const {
- // @@protoc_insertion_point(field_list:caffe.NetParameter.layer)
- return layer_;
-}
-
-// repeated .caffe.V1LayerParameter layers = 2;
-inline int NetParameter::layers_size() const {
- return layers_.size();
-}
-inline void NetParameter::clear_layers() {
- layers_.Clear();
-}
-inline const ::caffe::V1LayerParameter& NetParameter::layers(int index) const {
- // @@protoc_insertion_point(field_get:caffe.NetParameter.layers)
- return layers_.Get(index);
-}
-inline ::caffe::V1LayerParameter* NetParameter::mutable_layers(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.NetParameter.layers)
- return layers_.Mutable(index);
-}
-inline ::caffe::V1LayerParameter* NetParameter::add_layers() {
- // @@protoc_insertion_point(field_add:caffe.NetParameter.layers)
- return layers_.Add();
-}
-inline ::google::protobuf::RepeatedPtrField< ::caffe::V1LayerParameter >*
-NetParameter::mutable_layers() {
- // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.layers)
- return &layers_;
-}
-inline const ::google::protobuf::RepeatedPtrField< ::caffe::V1LayerParameter >&
-NetParameter::layers() const {
- // @@protoc_insertion_point(field_list:caffe.NetParameter.layers)
- return layers_;
-}
-
-inline const NetParameter* NetParameter::internal_default_instance() {
- return &NetParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// SolverParameter
-
-// optional string net = 24;
-inline bool SolverParameter::has_net() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void SolverParameter::set_has_net() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void SolverParameter::clear_has_net() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void SolverParameter::clear_net() {
- net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_net();
-}
-inline const ::std::string& SolverParameter::net() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.net)
- return net_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void SolverParameter::set_net(const ::std::string& value) {
- set_has_net();
- net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.net)
-}
-inline void SolverParameter::set_net(const char* value) {
- set_has_net();
- net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.net)
-}
-inline void SolverParameter::set_net(const char* value, size_t size) {
- set_has_net();
- net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.net)
-}
-inline ::std::string* SolverParameter::mutable_net() {
- set_has_net();
- // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.net)
- return net_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* SolverParameter::release_net() {
- // @@protoc_insertion_point(field_release:caffe.SolverParameter.net)
- clear_has_net();
- return net_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void SolverParameter::set_allocated_net(::std::string* net) {
- if (net != NULL) {
- set_has_net();
- } else {
- clear_has_net();
- }
- net_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), net);
- // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.net)
-}
-
-// optional .caffe.NetParameter net_param = 25;
-inline bool SolverParameter::has_net_param() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void SolverParameter::set_has_net_param() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void SolverParameter::clear_has_net_param() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void SolverParameter::clear_net_param() {
- if (net_param_ != NULL) net_param_->::caffe::NetParameter::Clear();
- clear_has_net_param();
-}
-inline const ::caffe::NetParameter& SolverParameter::net_param() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.net_param)
- return net_param_ != NULL ? *net_param_
- : *::caffe::NetParameter::internal_default_instance();
-}
-inline ::caffe::NetParameter* SolverParameter::mutable_net_param() {
- set_has_net_param();
- if (net_param_ == NULL) {
- net_param_ = new ::caffe::NetParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.net_param)
- return net_param_;
-}
-inline ::caffe::NetParameter* SolverParameter::release_net_param() {
- // @@protoc_insertion_point(field_release:caffe.SolverParameter.net_param)
- clear_has_net_param();
- ::caffe::NetParameter* temp = net_param_;
- net_param_ = NULL;
- return temp;
-}
-inline void SolverParameter::set_allocated_net_param(::caffe::NetParameter* net_param) {
- delete net_param_;
- net_param_ = net_param;
- if (net_param) {
- set_has_net_param();
- } else {
- clear_has_net_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.net_param)
-}
-
-// optional string train_net = 1;
-inline bool SolverParameter::has_train_net() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void SolverParameter::set_has_train_net() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void SolverParameter::clear_has_train_net() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void SolverParameter::clear_train_net() {
- train_net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_train_net();
-}
-inline const ::std::string& SolverParameter::train_net() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.train_net)
- return train_net_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void SolverParameter::set_train_net(const ::std::string& value) {
- set_has_train_net();
- train_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.train_net)
-}
-inline void SolverParameter::set_train_net(const char* value) {
- set_has_train_net();
- train_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.train_net)
-}
-inline void SolverParameter::set_train_net(const char* value, size_t size) {
- set_has_train_net();
- train_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.train_net)
-}
-inline ::std::string* SolverParameter::mutable_train_net() {
- set_has_train_net();
- // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.train_net)
- return train_net_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* SolverParameter::release_train_net() {
- // @@protoc_insertion_point(field_release:caffe.SolverParameter.train_net)
- clear_has_train_net();
- return train_net_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void SolverParameter::set_allocated_train_net(::std::string* train_net) {
- if (train_net != NULL) {
- set_has_train_net();
- } else {
- clear_has_train_net();
- }
- train_net_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), train_net);
- // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.train_net)
-}
-
-// repeated string test_net = 2;
-inline int SolverParameter::test_net_size() const {
- return test_net_.size();
-}
-inline void SolverParameter::clear_test_net() {
- test_net_.Clear();
-}
-inline const ::std::string& SolverParameter::test_net(int index) const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_net)
- return test_net_.Get(index);
-}
-inline ::std::string* SolverParameter::mutable_test_net(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.test_net)
- return test_net_.Mutable(index);
-}
-inline void SolverParameter::set_test_net(int index, const ::std::string& value) {
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_net)
- test_net_.Mutable(index)->assign(value);
-}
-inline void SolverParameter::set_test_net(int index, const char* value) {
- test_net_.Mutable(index)->assign(value);
- // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.test_net)
-}
-inline void SolverParameter::set_test_net(int index, const char* value, size_t size) {
- test_net_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.test_net)
-}
-inline ::std::string* SolverParameter::add_test_net() {
- // @@protoc_insertion_point(field_add_mutable:caffe.SolverParameter.test_net)
- return test_net_.Add();
-}
-inline void SolverParameter::add_test_net(const ::std::string& value) {
- test_net_.Add()->assign(value);
- // @@protoc_insertion_point(field_add:caffe.SolverParameter.test_net)
-}
-inline void SolverParameter::add_test_net(const char* value) {
- test_net_.Add()->assign(value);
- // @@protoc_insertion_point(field_add_char:caffe.SolverParameter.test_net)
-}
-inline void SolverParameter::add_test_net(const char* value, size_t size) {
- test_net_.Add()->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_add_pointer:caffe.SolverParameter.test_net)
-}
-inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
-SolverParameter::test_net() const {
- // @@protoc_insertion_point(field_list:caffe.SolverParameter.test_net)
- return test_net_;
-}
-inline ::google::protobuf::RepeatedPtrField< ::std::string>*
-SolverParameter::mutable_test_net() {
- // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.test_net)
- return &test_net_;
-}
-
-// optional .caffe.NetParameter train_net_param = 21;
-inline bool SolverParameter::has_train_net_param() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-inline void SolverParameter::set_has_train_net_param() {
- _has_bits_[0] |= 0x00000010u;
-}
-inline void SolverParameter::clear_has_train_net_param() {
- _has_bits_[0] &= ~0x00000010u;
-}
-inline void SolverParameter::clear_train_net_param() {
- if (train_net_param_ != NULL) train_net_param_->::caffe::NetParameter::Clear();
- clear_has_train_net_param();
-}
-inline const ::caffe::NetParameter& SolverParameter::train_net_param() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.train_net_param)
- return train_net_param_ != NULL ? *train_net_param_
- : *::caffe::NetParameter::internal_default_instance();
-}
-inline ::caffe::NetParameter* SolverParameter::mutable_train_net_param() {
- set_has_train_net_param();
- if (train_net_param_ == NULL) {
- train_net_param_ = new ::caffe::NetParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.train_net_param)
- return train_net_param_;
-}
-inline ::caffe::NetParameter* SolverParameter::release_train_net_param() {
- // @@protoc_insertion_point(field_release:caffe.SolverParameter.train_net_param)
- clear_has_train_net_param();
- ::caffe::NetParameter* temp = train_net_param_;
- train_net_param_ = NULL;
- return temp;
-}
-inline void SolverParameter::set_allocated_train_net_param(::caffe::NetParameter* train_net_param) {
- delete train_net_param_;
- train_net_param_ = train_net_param;
- if (train_net_param) {
- set_has_train_net_param();
- } else {
- clear_has_train_net_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.train_net_param)
-}
-
-// repeated .caffe.NetParameter test_net_param = 22;
-inline int SolverParameter::test_net_param_size() const {
- return test_net_param_.size();
-}
-inline void SolverParameter::clear_test_net_param() {
- test_net_param_.Clear();
-}
-inline const ::caffe::NetParameter& SolverParameter::test_net_param(int index) const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_net_param)
- return test_net_param_.Get(index);
-}
-inline ::caffe::NetParameter* SolverParameter::mutable_test_net_param(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.test_net_param)
- return test_net_param_.Mutable(index);
-}
-inline ::caffe::NetParameter* SolverParameter::add_test_net_param() {
- // @@protoc_insertion_point(field_add:caffe.SolverParameter.test_net_param)
- return test_net_param_.Add();
-}
-inline ::google::protobuf::RepeatedPtrField< ::caffe::NetParameter >*
-SolverParameter::mutable_test_net_param() {
- // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.test_net_param)
- return &test_net_param_;
-}
-inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetParameter >&
-SolverParameter::test_net_param() const {
- // @@protoc_insertion_point(field_list:caffe.SolverParameter.test_net_param)
- return test_net_param_;
-}
-
-// optional .caffe.NetState train_state = 26;
-inline bool SolverParameter::has_train_state() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-inline void SolverParameter::set_has_train_state() {
- _has_bits_[0] |= 0x00000040u;
-}
-inline void SolverParameter::clear_has_train_state() {
- _has_bits_[0] &= ~0x00000040u;
-}
-inline void SolverParameter::clear_train_state() {
- if (train_state_ != NULL) train_state_->::caffe::NetState::Clear();
- clear_has_train_state();
-}
-inline const ::caffe::NetState& SolverParameter::train_state() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.train_state)
- return train_state_ != NULL ? *train_state_
- : *::caffe::NetState::internal_default_instance();
-}
-inline ::caffe::NetState* SolverParameter::mutable_train_state() {
- set_has_train_state();
- if (train_state_ == NULL) {
- train_state_ = new ::caffe::NetState;
- }
- // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.train_state)
- return train_state_;
-}
-inline ::caffe::NetState* SolverParameter::release_train_state() {
- // @@protoc_insertion_point(field_release:caffe.SolverParameter.train_state)
- clear_has_train_state();
- ::caffe::NetState* temp = train_state_;
- train_state_ = NULL;
- return temp;
-}
-inline void SolverParameter::set_allocated_train_state(::caffe::NetState* train_state) {
- delete train_state_;
- train_state_ = train_state;
- if (train_state) {
- set_has_train_state();
- } else {
- clear_has_train_state();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.train_state)
-}
-
-// repeated .caffe.NetState test_state = 27;
-inline int SolverParameter::test_state_size() const {
- return test_state_.size();
-}
-inline void SolverParameter::clear_test_state() {
- test_state_.Clear();
-}
-inline const ::caffe::NetState& SolverParameter::test_state(int index) const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_state)
- return test_state_.Get(index);
-}
-inline ::caffe::NetState* SolverParameter::mutable_test_state(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.test_state)
- return test_state_.Mutable(index);
-}
-inline ::caffe::NetState* SolverParameter::add_test_state() {
- // @@protoc_insertion_point(field_add:caffe.SolverParameter.test_state)
- return test_state_.Add();
-}
-inline ::google::protobuf::RepeatedPtrField< ::caffe::NetState >*
-SolverParameter::mutable_test_state() {
- // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.test_state)
- return &test_state_;
-}
-inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetState >&
-SolverParameter::test_state() const {
- // @@protoc_insertion_point(field_list:caffe.SolverParameter.test_state)
- return test_state_;
-}
-
-// repeated int32 test_iter = 3;
-inline int SolverParameter::test_iter_size() const {
- return test_iter_.size();
-}
-inline void SolverParameter::clear_test_iter() {
- test_iter_.Clear();
-}
-inline ::google::protobuf::int32 SolverParameter::test_iter(int index) const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_iter)
- return test_iter_.Get(index);
-}
-inline void SolverParameter::set_test_iter(int index, ::google::protobuf::int32 value) {
- test_iter_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_iter)
-}
-inline void SolverParameter::add_test_iter(::google::protobuf::int32 value) {
- test_iter_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.SolverParameter.test_iter)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
-SolverParameter::test_iter() const {
- // @@protoc_insertion_point(field_list:caffe.SolverParameter.test_iter)
- return test_iter_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
-SolverParameter::mutable_test_iter() {
- // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.test_iter)
- return &test_iter_;
-}
-
-// optional int32 test_interval = 4 [default = 0];
-inline bool SolverParameter::has_test_interval() const {
- return (_has_bits_[0] & 0x00000200u) != 0;
-}
-inline void SolverParameter::set_has_test_interval() {
- _has_bits_[0] |= 0x00000200u;
-}
-inline void SolverParameter::clear_has_test_interval() {
- _has_bits_[0] &= ~0x00000200u;
-}
-inline void SolverParameter::clear_test_interval() {
- test_interval_ = 0;
- clear_has_test_interval();
-}
-inline ::google::protobuf::int32 SolverParameter::test_interval() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_interval)
- return test_interval_;
-}
-inline void SolverParameter::set_test_interval(::google::protobuf::int32 value) {
- set_has_test_interval();
- test_interval_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_interval)
-}
-
-// optional bool test_compute_loss = 19 [default = false];
-inline bool SolverParameter::has_test_compute_loss() const {
- return (_has_bits_[0] & 0x00000400u) != 0;
-}
-inline void SolverParameter::set_has_test_compute_loss() {
- _has_bits_[0] |= 0x00000400u;
-}
-inline void SolverParameter::clear_has_test_compute_loss() {
- _has_bits_[0] &= ~0x00000400u;
-}
-inline void SolverParameter::clear_test_compute_loss() {
- test_compute_loss_ = false;
- clear_has_test_compute_loss();
-}
-inline bool SolverParameter::test_compute_loss() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_compute_loss)
- return test_compute_loss_;
-}
-inline void SolverParameter::set_test_compute_loss(bool value) {
- set_has_test_compute_loss();
- test_compute_loss_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_compute_loss)
-}
-
-// optional bool test_initialization = 32 [default = true];
-inline bool SolverParameter::has_test_initialization() const {
- return (_has_bits_[0] & 0x00000800u) != 0;
-}
-inline void SolverParameter::set_has_test_initialization() {
- _has_bits_[0] |= 0x00000800u;
-}
-inline void SolverParameter::clear_has_test_initialization() {
- _has_bits_[0] &= ~0x00000800u;
-}
-inline void SolverParameter::clear_test_initialization() {
- test_initialization_ = true;
- clear_has_test_initialization();
-}
-inline bool SolverParameter::test_initialization() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_initialization)
- return test_initialization_;
-}
-inline void SolverParameter::set_test_initialization(bool value) {
- set_has_test_initialization();
- test_initialization_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_initialization)
-}
-
-// optional float base_lr = 5;
-inline bool SolverParameter::has_base_lr() const {
- return (_has_bits_[0] & 0x00001000u) != 0;
-}
-inline void SolverParameter::set_has_base_lr() {
- _has_bits_[0] |= 0x00001000u;
-}
-inline void SolverParameter::clear_has_base_lr() {
- _has_bits_[0] &= ~0x00001000u;
-}
-inline void SolverParameter::clear_base_lr() {
- base_lr_ = 0;
- clear_has_base_lr();
-}
-inline float SolverParameter::base_lr() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.base_lr)
- return base_lr_;
-}
-inline void SolverParameter::set_base_lr(float value) {
- set_has_base_lr();
- base_lr_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.base_lr)
-}
-
-// optional int32 display = 6;
-inline bool SolverParameter::has_display() const {
- return (_has_bits_[0] & 0x00002000u) != 0;
-}
-inline void SolverParameter::set_has_display() {
- _has_bits_[0] |= 0x00002000u;
-}
-inline void SolverParameter::clear_has_display() {
- _has_bits_[0] &= ~0x00002000u;
-}
-inline void SolverParameter::clear_display() {
- display_ = 0;
- clear_has_display();
-}
-inline ::google::protobuf::int32 SolverParameter::display() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.display)
- return display_;
-}
-inline void SolverParameter::set_display(::google::protobuf::int32 value) {
- set_has_display();
- display_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.display)
-}
-
-// optional int32 average_loss = 33 [default = 1];
-inline bool SolverParameter::has_average_loss() const {
- return (_has_bits_[0] & 0x00004000u) != 0;
-}
-inline void SolverParameter::set_has_average_loss() {
- _has_bits_[0] |= 0x00004000u;
-}
-inline void SolverParameter::clear_has_average_loss() {
- _has_bits_[0] &= ~0x00004000u;
-}
-inline void SolverParameter::clear_average_loss() {
- average_loss_ = 1;
- clear_has_average_loss();
-}
-inline ::google::protobuf::int32 SolverParameter::average_loss() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.average_loss)
- return average_loss_;
-}
-inline void SolverParameter::set_average_loss(::google::protobuf::int32 value) {
- set_has_average_loss();
- average_loss_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.average_loss)
-}
-
-// optional int32 max_iter = 7;
-inline bool SolverParameter::has_max_iter() const {
- return (_has_bits_[0] & 0x00008000u) != 0;
-}
-inline void SolverParameter::set_has_max_iter() {
- _has_bits_[0] |= 0x00008000u;
-}
-inline void SolverParameter::clear_has_max_iter() {
- _has_bits_[0] &= ~0x00008000u;
-}
-inline void SolverParameter::clear_max_iter() {
- max_iter_ = 0;
- clear_has_max_iter();
-}
-inline ::google::protobuf::int32 SolverParameter::max_iter() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.max_iter)
- return max_iter_;
-}
-inline void SolverParameter::set_max_iter(::google::protobuf::int32 value) {
- set_has_max_iter();
- max_iter_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.max_iter)
-}
-
-// optional int32 iter_size = 36 [default = 1];
-inline bool SolverParameter::has_iter_size() const {
- return (_has_bits_[0] & 0x00010000u) != 0;
-}
-inline void SolverParameter::set_has_iter_size() {
- _has_bits_[0] |= 0x00010000u;
-}
-inline void SolverParameter::clear_has_iter_size() {
- _has_bits_[0] &= ~0x00010000u;
-}
-inline void SolverParameter::clear_iter_size() {
- iter_size_ = 1;
- clear_has_iter_size();
-}
-inline ::google::protobuf::int32 SolverParameter::iter_size() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.iter_size)
- return iter_size_;
-}
-inline void SolverParameter::set_iter_size(::google::protobuf::int32 value) {
- set_has_iter_size();
- iter_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.iter_size)
-}
-
-// optional string lr_policy = 8;
-inline bool SolverParameter::has_lr_policy() const {
- return (_has_bits_[0] & 0x00020000u) != 0;
-}
-inline void SolverParameter::set_has_lr_policy() {
- _has_bits_[0] |= 0x00020000u;
-}
-inline void SolverParameter::clear_has_lr_policy() {
- _has_bits_[0] &= ~0x00020000u;
-}
-inline void SolverParameter::clear_lr_policy() {
- lr_policy_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_lr_policy();
-}
-inline const ::std::string& SolverParameter::lr_policy() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.lr_policy)
- return lr_policy_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void SolverParameter::set_lr_policy(const ::std::string& value) {
- set_has_lr_policy();
- lr_policy_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.lr_policy)
-}
-inline void SolverParameter::set_lr_policy(const char* value) {
- set_has_lr_policy();
- lr_policy_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.lr_policy)
-}
-inline void SolverParameter::set_lr_policy(const char* value, size_t size) {
- set_has_lr_policy();
- lr_policy_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.lr_policy)
-}
-inline ::std::string* SolverParameter::mutable_lr_policy() {
- set_has_lr_policy();
- // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.lr_policy)
- return lr_policy_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* SolverParameter::release_lr_policy() {
- // @@protoc_insertion_point(field_release:caffe.SolverParameter.lr_policy)
- clear_has_lr_policy();
- return lr_policy_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void SolverParameter::set_allocated_lr_policy(::std::string* lr_policy) {
- if (lr_policy != NULL) {
- set_has_lr_policy();
- } else {
- clear_has_lr_policy();
- }
- lr_policy_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), lr_policy);
- // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.lr_policy)
-}
-
-// optional float gamma = 9;
-inline bool SolverParameter::has_gamma() const {
- return (_has_bits_[0] & 0x00040000u) != 0;
-}
-inline void SolverParameter::set_has_gamma() {
- _has_bits_[0] |= 0x00040000u;
-}
-inline void SolverParameter::clear_has_gamma() {
- _has_bits_[0] &= ~0x00040000u;
-}
-inline void SolverParameter::clear_gamma() {
- gamma_ = 0;
- clear_has_gamma();
-}
-inline float SolverParameter::gamma() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.gamma)
- return gamma_;
-}
-inline void SolverParameter::set_gamma(float value) {
- set_has_gamma();
- gamma_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.gamma)
-}
-
-// optional float power = 10;
-inline bool SolverParameter::has_power() const {
- return (_has_bits_[0] & 0x00080000u) != 0;
-}
-inline void SolverParameter::set_has_power() {
- _has_bits_[0] |= 0x00080000u;
-}
-inline void SolverParameter::clear_has_power() {
- _has_bits_[0] &= ~0x00080000u;
-}
-inline void SolverParameter::clear_power() {
- power_ = 0;
- clear_has_power();
-}
-inline float SolverParameter::power() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.power)
- return power_;
-}
-inline void SolverParameter::set_power(float value) {
- set_has_power();
- power_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.power)
-}
-
-// optional float momentum = 11;
-inline bool SolverParameter::has_momentum() const {
- return (_has_bits_[0] & 0x00100000u) != 0;
-}
-inline void SolverParameter::set_has_momentum() {
- _has_bits_[0] |= 0x00100000u;
-}
-inline void SolverParameter::clear_has_momentum() {
- _has_bits_[0] &= ~0x00100000u;
-}
-inline void SolverParameter::clear_momentum() {
- momentum_ = 0;
- clear_has_momentum();
-}
-inline float SolverParameter::momentum() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.momentum)
- return momentum_;
-}
-inline void SolverParameter::set_momentum(float value) {
- set_has_momentum();
- momentum_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.momentum)
-}
-
-// optional float weight_decay = 12;
-inline bool SolverParameter::has_weight_decay() const {
- return (_has_bits_[0] & 0x00200000u) != 0;
-}
-inline void SolverParameter::set_has_weight_decay() {
- _has_bits_[0] |= 0x00200000u;
-}
-inline void SolverParameter::clear_has_weight_decay() {
- _has_bits_[0] &= ~0x00200000u;
-}
-inline void SolverParameter::clear_weight_decay() {
- weight_decay_ = 0;
- clear_has_weight_decay();
-}
-inline float SolverParameter::weight_decay() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.weight_decay)
- return weight_decay_;
-}
-inline void SolverParameter::set_weight_decay(float value) {
- set_has_weight_decay();
- weight_decay_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.weight_decay)
-}
-
-// optional string regularization_type = 29 [default = "L2"];
-inline bool SolverParameter::has_regularization_type() const {
- return (_has_bits_[0] & 0x00400000u) != 0;
-}
-inline void SolverParameter::set_has_regularization_type() {
- _has_bits_[0] |= 0x00400000u;
-}
-inline void SolverParameter::clear_has_regularization_type() {
- _has_bits_[0] &= ~0x00400000u;
-}
-inline void SolverParameter::clear_regularization_type() {
- regularization_type_.ClearToDefaultNoArena(_default_regularization_type_);
- clear_has_regularization_type();
-}
-inline const ::std::string& SolverParameter::regularization_type() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.regularization_type)
- return regularization_type_.GetNoArena(_default_regularization_type_);
-}
-inline void SolverParameter::set_regularization_type(const ::std::string& value) {
- set_has_regularization_type();
- regularization_type_.SetNoArena(_default_regularization_type_, value);
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.regularization_type)
-}
-inline void SolverParameter::set_regularization_type(const char* value) {
- set_has_regularization_type();
- regularization_type_.SetNoArena(_default_regularization_type_, ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.regularization_type)
-}
-inline void SolverParameter::set_regularization_type(const char* value, size_t size) {
- set_has_regularization_type();
- regularization_type_.SetNoArena(_default_regularization_type_,
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.regularization_type)
-}
-inline ::std::string* SolverParameter::mutable_regularization_type() {
- set_has_regularization_type();
- // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.regularization_type)
- return regularization_type_.MutableNoArena(_default_regularization_type_);
-}
-inline ::std::string* SolverParameter::release_regularization_type() {
- // @@protoc_insertion_point(field_release:caffe.SolverParameter.regularization_type)
- clear_has_regularization_type();
- return regularization_type_.ReleaseNoArena(_default_regularization_type_);
-}
-inline void SolverParameter::set_allocated_regularization_type(::std::string* regularization_type) {
- if (regularization_type != NULL) {
- set_has_regularization_type();
- } else {
- clear_has_regularization_type();
- }
- regularization_type_.SetAllocatedNoArena(_default_regularization_type_, regularization_type);
- // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.regularization_type)
-}
-
-// optional int32 stepsize = 13;
-inline bool SolverParameter::has_stepsize() const {
- return (_has_bits_[0] & 0x00800000u) != 0;
-}
-inline void SolverParameter::set_has_stepsize() {
- _has_bits_[0] |= 0x00800000u;
-}
-inline void SolverParameter::clear_has_stepsize() {
- _has_bits_[0] &= ~0x00800000u;
-}
-inline void SolverParameter::clear_stepsize() {
- stepsize_ = 0;
- clear_has_stepsize();
-}
-inline ::google::protobuf::int32 SolverParameter::stepsize() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.stepsize)
- return stepsize_;
-}
-inline void SolverParameter::set_stepsize(::google::protobuf::int32 value) {
- set_has_stepsize();
- stepsize_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.stepsize)
-}
-
-// repeated int32 stepvalue = 34;
-inline int SolverParameter::stepvalue_size() const {
- return stepvalue_.size();
-}
-inline void SolverParameter::clear_stepvalue() {
- stepvalue_.Clear();
-}
-inline ::google::protobuf::int32 SolverParameter::stepvalue(int index) const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.stepvalue)
- return stepvalue_.Get(index);
-}
-inline void SolverParameter::set_stepvalue(int index, ::google::protobuf::int32 value) {
- stepvalue_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.stepvalue)
-}
-inline void SolverParameter::add_stepvalue(::google::protobuf::int32 value) {
- stepvalue_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.SolverParameter.stepvalue)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
-SolverParameter::stepvalue() const {
- // @@protoc_insertion_point(field_list:caffe.SolverParameter.stepvalue)
- return stepvalue_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
-SolverParameter::mutable_stepvalue() {
- // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.stepvalue)
- return &stepvalue_;
-}
-
-// optional float clip_gradients = 35 [default = -1];
-inline bool SolverParameter::has_clip_gradients() const {
- return (_has_bits_[0] & 0x02000000u) != 0;
-}
-inline void SolverParameter::set_has_clip_gradients() {
- _has_bits_[0] |= 0x02000000u;
-}
-inline void SolverParameter::clear_has_clip_gradients() {
- _has_bits_[0] &= ~0x02000000u;
-}
-inline void SolverParameter::clear_clip_gradients() {
- clip_gradients_ = -1;
- clear_has_clip_gradients();
-}
-inline float SolverParameter::clip_gradients() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.clip_gradients)
- return clip_gradients_;
-}
-inline void SolverParameter::set_clip_gradients(float value) {
- set_has_clip_gradients();
- clip_gradients_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.clip_gradients)
-}
-
-// optional int32 snapshot = 14 [default = 0];
-inline bool SolverParameter::has_snapshot() const {
- return (_has_bits_[0] & 0x04000000u) != 0;
-}
-inline void SolverParameter::set_has_snapshot() {
- _has_bits_[0] |= 0x04000000u;
-}
-inline void SolverParameter::clear_has_snapshot() {
- _has_bits_[0] &= ~0x04000000u;
-}
-inline void SolverParameter::clear_snapshot() {
- snapshot_ = 0;
- clear_has_snapshot();
-}
-inline ::google::protobuf::int32 SolverParameter::snapshot() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot)
- return snapshot_;
-}
-inline void SolverParameter::set_snapshot(::google::protobuf::int32 value) {
- set_has_snapshot();
- snapshot_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot)
-}
-
-// optional string snapshot_prefix = 15;
-inline bool SolverParameter::has_snapshot_prefix() const {
- return (_has_bits_[0] & 0x08000000u) != 0;
-}
-inline void SolverParameter::set_has_snapshot_prefix() {
- _has_bits_[0] |= 0x08000000u;
-}
-inline void SolverParameter::clear_has_snapshot_prefix() {
- _has_bits_[0] &= ~0x08000000u;
-}
-inline void SolverParameter::clear_snapshot_prefix() {
- snapshot_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_snapshot_prefix();
-}
-inline const ::std::string& SolverParameter::snapshot_prefix() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot_prefix)
- return snapshot_prefix_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void SolverParameter::set_snapshot_prefix(const ::std::string& value) {
- set_has_snapshot_prefix();
- snapshot_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot_prefix)
-}
-inline void SolverParameter::set_snapshot_prefix(const char* value) {
- set_has_snapshot_prefix();
- snapshot_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.snapshot_prefix)
-}
-inline void SolverParameter::set_snapshot_prefix(const char* value, size_t size) {
- set_has_snapshot_prefix();
- snapshot_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.snapshot_prefix)
-}
-inline ::std::string* SolverParameter::mutable_snapshot_prefix() {
- set_has_snapshot_prefix();
- // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.snapshot_prefix)
- return snapshot_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* SolverParameter::release_snapshot_prefix() {
- // @@protoc_insertion_point(field_release:caffe.SolverParameter.snapshot_prefix)
- clear_has_snapshot_prefix();
- return snapshot_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void SolverParameter::set_allocated_snapshot_prefix(::std::string* snapshot_prefix) {
- if (snapshot_prefix != NULL) {
- set_has_snapshot_prefix();
- } else {
- clear_has_snapshot_prefix();
- }
- snapshot_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), snapshot_prefix);
- // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.snapshot_prefix)
-}
-
-// optional bool snapshot_diff = 16 [default = false];
-inline bool SolverParameter::has_snapshot_diff() const {
- return (_has_bits_[0] & 0x10000000u) != 0;
-}
-inline void SolverParameter::set_has_snapshot_diff() {
- _has_bits_[0] |= 0x10000000u;
-}
-inline void SolverParameter::clear_has_snapshot_diff() {
- _has_bits_[0] &= ~0x10000000u;
-}
-inline void SolverParameter::clear_snapshot_diff() {
- snapshot_diff_ = false;
- clear_has_snapshot_diff();
-}
-inline bool SolverParameter::snapshot_diff() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot_diff)
- return snapshot_diff_;
-}
-inline void SolverParameter::set_snapshot_diff(bool value) {
- set_has_snapshot_diff();
- snapshot_diff_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot_diff)
-}
-
-// optional .caffe.SolverParameter.SolverMode solver_mode = 17 [default = GPU];
-inline bool SolverParameter::has_solver_mode() const {
- return (_has_bits_[0] & 0x20000000u) != 0;
-}
-inline void SolverParameter::set_has_solver_mode() {
- _has_bits_[0] |= 0x20000000u;
-}
-inline void SolverParameter::clear_has_solver_mode() {
- _has_bits_[0] &= ~0x20000000u;
-}
-inline void SolverParameter::clear_solver_mode() {
- solver_mode_ = 1;
- clear_has_solver_mode();
-}
-inline ::caffe::SolverParameter_SolverMode SolverParameter::solver_mode() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.solver_mode)
- return static_cast< ::caffe::SolverParameter_SolverMode >(solver_mode_);
-}
-inline void SolverParameter::set_solver_mode(::caffe::SolverParameter_SolverMode value) {
- assert(::caffe::SolverParameter_SolverMode_IsValid(value));
- set_has_solver_mode();
- solver_mode_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.solver_mode)
-}
-
-// optional int32 device_id = 18 [default = 0];
-inline bool SolverParameter::has_device_id() const {
- return (_has_bits_[0] & 0x40000000u) != 0;
-}
-inline void SolverParameter::set_has_device_id() {
- _has_bits_[0] |= 0x40000000u;
-}
-inline void SolverParameter::clear_has_device_id() {
- _has_bits_[0] &= ~0x40000000u;
-}
-inline void SolverParameter::clear_device_id() {
- device_id_ = 0;
- clear_has_device_id();
-}
-inline ::google::protobuf::int32 SolverParameter::device_id() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.device_id)
- return device_id_;
-}
-inline void SolverParameter::set_device_id(::google::protobuf::int32 value) {
- set_has_device_id();
- device_id_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.device_id)
-}
-
-// optional int64 random_seed = 20 [default = -1];
-inline bool SolverParameter::has_random_seed() const {
- return (_has_bits_[0] & 0x80000000u) != 0;
-}
-inline void SolverParameter::set_has_random_seed() {
- _has_bits_[0] |= 0x80000000u;
-}
-inline void SolverParameter::clear_has_random_seed() {
- _has_bits_[0] &= ~0x80000000u;
-}
-inline void SolverParameter::clear_random_seed() {
- random_seed_ = GOOGLE_LONGLONG(-1);
- clear_has_random_seed();
-}
-inline ::google::protobuf::int64 SolverParameter::random_seed() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.random_seed)
- return random_seed_;
-}
-inline void SolverParameter::set_random_seed(::google::protobuf::int64 value) {
- set_has_random_seed();
- random_seed_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.random_seed)
-}
-
-// optional .caffe.SolverParameter.SolverType solver_type = 30 [default = SGD];
-inline bool SolverParameter::has_solver_type() const {
- return (_has_bits_[1] & 0x00000001u) != 0;
-}
-inline void SolverParameter::set_has_solver_type() {
- _has_bits_[1] |= 0x00000001u;
-}
-inline void SolverParameter::clear_has_solver_type() {
- _has_bits_[1] &= ~0x00000001u;
-}
-inline void SolverParameter::clear_solver_type() {
- solver_type_ = 0;
- clear_has_solver_type();
-}
-inline ::caffe::SolverParameter_SolverType SolverParameter::solver_type() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.solver_type)
- return static_cast< ::caffe::SolverParameter_SolverType >(solver_type_);
-}
-inline void SolverParameter::set_solver_type(::caffe::SolverParameter_SolverType value) {
- assert(::caffe::SolverParameter_SolverType_IsValid(value));
- set_has_solver_type();
- solver_type_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.solver_type)
-}
-
-// optional float delta = 31 [default = 1e-08];
-inline bool SolverParameter::has_delta() const {
- return (_has_bits_[1] & 0x00000002u) != 0;
-}
-inline void SolverParameter::set_has_delta() {
- _has_bits_[1] |= 0x00000002u;
-}
-inline void SolverParameter::clear_has_delta() {
- _has_bits_[1] &= ~0x00000002u;
-}
-inline void SolverParameter::clear_delta() {
- delta_ = 1e-08f;
- clear_has_delta();
-}
-inline float SolverParameter::delta() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.delta)
- return delta_;
-}
-inline void SolverParameter::set_delta(float value) {
- set_has_delta();
- delta_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.delta)
-}
-
-// optional bool debug_info = 23 [default = false];
-inline bool SolverParameter::has_debug_info() const {
- return (_has_bits_[1] & 0x00000004u) != 0;
-}
-inline void SolverParameter::set_has_debug_info() {
- _has_bits_[1] |= 0x00000004u;
-}
-inline void SolverParameter::clear_has_debug_info() {
- _has_bits_[1] &= ~0x00000004u;
-}
-inline void SolverParameter::clear_debug_info() {
- debug_info_ = false;
- clear_has_debug_info();
-}
-inline bool SolverParameter::debug_info() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.debug_info)
- return debug_info_;
-}
-inline void SolverParameter::set_debug_info(bool value) {
- set_has_debug_info();
- debug_info_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.debug_info)
-}
-
-// optional bool snapshot_after_train = 28 [default = true];
-inline bool SolverParameter::has_snapshot_after_train() const {
- return (_has_bits_[1] & 0x00000008u) != 0;
-}
-inline void SolverParameter::set_has_snapshot_after_train() {
- _has_bits_[1] |= 0x00000008u;
-}
-inline void SolverParameter::clear_has_snapshot_after_train() {
- _has_bits_[1] &= ~0x00000008u;
-}
-inline void SolverParameter::clear_snapshot_after_train() {
- snapshot_after_train_ = true;
- clear_has_snapshot_after_train();
-}
-inline bool SolverParameter::snapshot_after_train() const {
- // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot_after_train)
- return snapshot_after_train_;
-}
-inline void SolverParameter::set_snapshot_after_train(bool value) {
- set_has_snapshot_after_train();
- snapshot_after_train_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot_after_train)
-}
-
-inline const SolverParameter* SolverParameter::internal_default_instance() {
- return &SolverParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// SolverState
-
-// optional int32 iter = 1;
-inline bool SolverState::has_iter() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void SolverState::set_has_iter() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void SolverState::clear_has_iter() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void SolverState::clear_iter() {
- iter_ = 0;
- clear_has_iter();
-}
-inline ::google::protobuf::int32 SolverState::iter() const {
- // @@protoc_insertion_point(field_get:caffe.SolverState.iter)
- return iter_;
-}
-inline void SolverState::set_iter(::google::protobuf::int32 value) {
- set_has_iter();
- iter_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverState.iter)
-}
-
-// optional string learned_net = 2;
-inline bool SolverState::has_learned_net() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void SolverState::set_has_learned_net() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void SolverState::clear_has_learned_net() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void SolverState::clear_learned_net() {
- learned_net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_learned_net();
-}
-inline const ::std::string& SolverState::learned_net() const {
- // @@protoc_insertion_point(field_get:caffe.SolverState.learned_net)
- return learned_net_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void SolverState::set_learned_net(const ::std::string& value) {
- set_has_learned_net();
- learned_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.SolverState.learned_net)
-}
-inline void SolverState::set_learned_net(const char* value) {
- set_has_learned_net();
- learned_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.SolverState.learned_net)
-}
-inline void SolverState::set_learned_net(const char* value, size_t size) {
- set_has_learned_net();
- learned_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.SolverState.learned_net)
-}
-inline ::std::string* SolverState::mutable_learned_net() {
- set_has_learned_net();
- // @@protoc_insertion_point(field_mutable:caffe.SolverState.learned_net)
- return learned_net_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* SolverState::release_learned_net() {
- // @@protoc_insertion_point(field_release:caffe.SolverState.learned_net)
- clear_has_learned_net();
- return learned_net_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void SolverState::set_allocated_learned_net(::std::string* learned_net) {
- if (learned_net != NULL) {
- set_has_learned_net();
- } else {
- clear_has_learned_net();
- }
- learned_net_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), learned_net);
- // @@protoc_insertion_point(field_set_allocated:caffe.SolverState.learned_net)
-}
-
-// repeated .caffe.BlobProto history = 3;
-inline int SolverState::history_size() const {
- return history_.size();
-}
-inline void SolverState::clear_history() {
- history_.Clear();
-}
-inline const ::caffe::BlobProto& SolverState::history(int index) const {
- // @@protoc_insertion_point(field_get:caffe.SolverState.history)
- return history_.Get(index);
-}
-inline ::caffe::BlobProto* SolverState::mutable_history(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.SolverState.history)
- return history_.Mutable(index);
-}
-inline ::caffe::BlobProto* SolverState::add_history() {
- // @@protoc_insertion_point(field_add:caffe.SolverState.history)
- return history_.Add();
-}
-inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
-SolverState::mutable_history() {
- // @@protoc_insertion_point(field_mutable_list:caffe.SolverState.history)
- return &history_;
-}
-inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
-SolverState::history() const {
- // @@protoc_insertion_point(field_list:caffe.SolverState.history)
- return history_;
-}
-
-// optional int32 current_step = 4 [default = 0];
-inline bool SolverState::has_current_step() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void SolverState::set_has_current_step() {
- _has_bits_[0] |= 0x00000008u;
-}
-inline void SolverState::clear_has_current_step() {
- _has_bits_[0] &= ~0x00000008u;
-}
-inline void SolverState::clear_current_step() {
- current_step_ = 0;
- clear_has_current_step();
-}
-inline ::google::protobuf::int32 SolverState::current_step() const {
- // @@protoc_insertion_point(field_get:caffe.SolverState.current_step)
- return current_step_;
-}
-inline void SolverState::set_current_step(::google::protobuf::int32 value) {
- set_has_current_step();
- current_step_ = value;
- // @@protoc_insertion_point(field_set:caffe.SolverState.current_step)
-}
-
-inline const SolverState* SolverState::internal_default_instance() {
- return &SolverState_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// NetState
-
-// optional .caffe.Phase phase = 1 [default = TEST];
-inline bool NetState::has_phase() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void NetState::set_has_phase() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void NetState::clear_has_phase() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void NetState::clear_phase() {
- phase_ = 1;
- clear_has_phase();
-}
-inline ::caffe::Phase NetState::phase() const {
- // @@protoc_insertion_point(field_get:caffe.NetState.phase)
- return static_cast< ::caffe::Phase >(phase_);
-}
-inline void NetState::set_phase(::caffe::Phase value) {
- assert(::caffe::Phase_IsValid(value));
- set_has_phase();
- phase_ = value;
- // @@protoc_insertion_point(field_set:caffe.NetState.phase)
-}
-
-// optional int32 level = 2 [default = 0];
-inline bool NetState::has_level() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void NetState::set_has_level() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void NetState::clear_has_level() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void NetState::clear_level() {
- level_ = 0;
- clear_has_level();
-}
-inline ::google::protobuf::int32 NetState::level() const {
- // @@protoc_insertion_point(field_get:caffe.NetState.level)
- return level_;
-}
-inline void NetState::set_level(::google::protobuf::int32 value) {
- set_has_level();
- level_ = value;
- // @@protoc_insertion_point(field_set:caffe.NetState.level)
-}
-
-// repeated string stage = 3;
-inline int NetState::stage_size() const {
- return stage_.size();
-}
-inline void NetState::clear_stage() {
- stage_.Clear();
-}
-inline const ::std::string& NetState::stage(int index) const {
- // @@protoc_insertion_point(field_get:caffe.NetState.stage)
- return stage_.Get(index);
-}
-inline ::std::string* NetState::mutable_stage(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.NetState.stage)
- return stage_.Mutable(index);
-}
-inline void NetState::set_stage(int index, const ::std::string& value) {
- // @@protoc_insertion_point(field_set:caffe.NetState.stage)
- stage_.Mutable(index)->assign(value);
-}
-inline void NetState::set_stage(int index, const char* value) {
- stage_.Mutable(index)->assign(value);
- // @@protoc_insertion_point(field_set_char:caffe.NetState.stage)
-}
-inline void NetState::set_stage(int index, const char* value, size_t size) {
- stage_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:caffe.NetState.stage)
-}
-inline ::std::string* NetState::add_stage() {
- // @@protoc_insertion_point(field_add_mutable:caffe.NetState.stage)
- return stage_.Add();
-}
-inline void NetState::add_stage(const ::std::string& value) {
- stage_.Add()->assign(value);
- // @@protoc_insertion_point(field_add:caffe.NetState.stage)
-}
-inline void NetState::add_stage(const char* value) {
- stage_.Add()->assign(value);
- // @@protoc_insertion_point(field_add_char:caffe.NetState.stage)
-}
-inline void NetState::add_stage(const char* value, size_t size) {
- stage_.Add()->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_add_pointer:caffe.NetState.stage)
-}
-inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
-NetState::stage() const {
- // @@protoc_insertion_point(field_list:caffe.NetState.stage)
- return stage_;
-}
-inline ::google::protobuf::RepeatedPtrField< ::std::string>*
-NetState::mutable_stage() {
- // @@protoc_insertion_point(field_mutable_list:caffe.NetState.stage)
- return &stage_;
-}
-
-inline const NetState* NetState::internal_default_instance() {
- return &NetState_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// NetStateRule
-
-// optional .caffe.Phase phase = 1;
-inline bool NetStateRule::has_phase() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void NetStateRule::set_has_phase() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void NetStateRule::clear_has_phase() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void NetStateRule::clear_phase() {
- phase_ = 0;
- clear_has_phase();
-}
-inline ::caffe::Phase NetStateRule::phase() const {
- // @@protoc_insertion_point(field_get:caffe.NetStateRule.phase)
- return static_cast< ::caffe::Phase >(phase_);
-}
-inline void NetStateRule::set_phase(::caffe::Phase value) {
- assert(::caffe::Phase_IsValid(value));
- set_has_phase();
- phase_ = value;
- // @@protoc_insertion_point(field_set:caffe.NetStateRule.phase)
-}
-
-// optional int32 min_level = 2;
-inline bool NetStateRule::has_min_level() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void NetStateRule::set_has_min_level() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void NetStateRule::clear_has_min_level() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void NetStateRule::clear_min_level() {
- min_level_ = 0;
- clear_has_min_level();
-}
-inline ::google::protobuf::int32 NetStateRule::min_level() const {
- // @@protoc_insertion_point(field_get:caffe.NetStateRule.min_level)
- return min_level_;
-}
-inline void NetStateRule::set_min_level(::google::protobuf::int32 value) {
- set_has_min_level();
- min_level_ = value;
- // @@protoc_insertion_point(field_set:caffe.NetStateRule.min_level)
-}
-
-// optional int32 max_level = 3;
-inline bool NetStateRule::has_max_level() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void NetStateRule::set_has_max_level() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void NetStateRule::clear_has_max_level() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void NetStateRule::clear_max_level() {
- max_level_ = 0;
- clear_has_max_level();
-}
-inline ::google::protobuf::int32 NetStateRule::max_level() const {
- // @@protoc_insertion_point(field_get:caffe.NetStateRule.max_level)
- return max_level_;
-}
-inline void NetStateRule::set_max_level(::google::protobuf::int32 value) {
- set_has_max_level();
- max_level_ = value;
- // @@protoc_insertion_point(field_set:caffe.NetStateRule.max_level)
-}
-
-// repeated string stage = 4;
-inline int NetStateRule::stage_size() const {
- return stage_.size();
-}
-inline void NetStateRule::clear_stage() {
- stage_.Clear();
-}
-inline const ::std::string& NetStateRule::stage(int index) const {
- // @@protoc_insertion_point(field_get:caffe.NetStateRule.stage)
- return stage_.Get(index);
-}
-inline ::std::string* NetStateRule::mutable_stage(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.NetStateRule.stage)
- return stage_.Mutable(index);
-}
-inline void NetStateRule::set_stage(int index, const ::std::string& value) {
- // @@protoc_insertion_point(field_set:caffe.NetStateRule.stage)
- stage_.Mutable(index)->assign(value);
-}
-inline void NetStateRule::set_stage(int index, const char* value) {
- stage_.Mutable(index)->assign(value);
- // @@protoc_insertion_point(field_set_char:caffe.NetStateRule.stage)
-}
-inline void NetStateRule::set_stage(int index, const char* value, size_t size) {
- stage_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:caffe.NetStateRule.stage)
-}
-inline ::std::string* NetStateRule::add_stage() {
- // @@protoc_insertion_point(field_add_mutable:caffe.NetStateRule.stage)
- return stage_.Add();
-}
-inline void NetStateRule::add_stage(const ::std::string& value) {
- stage_.Add()->assign(value);
- // @@protoc_insertion_point(field_add:caffe.NetStateRule.stage)
-}
-inline void NetStateRule::add_stage(const char* value) {
- stage_.Add()->assign(value);
- // @@protoc_insertion_point(field_add_char:caffe.NetStateRule.stage)
-}
-inline void NetStateRule::add_stage(const char* value, size_t size) {
- stage_.Add()->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_add_pointer:caffe.NetStateRule.stage)
-}
-inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
-NetStateRule::stage() const {
- // @@protoc_insertion_point(field_list:caffe.NetStateRule.stage)
- return stage_;
-}
-inline ::google::protobuf::RepeatedPtrField< ::std::string>*
-NetStateRule::mutable_stage() {
- // @@protoc_insertion_point(field_mutable_list:caffe.NetStateRule.stage)
- return &stage_;
-}
-
-// repeated string not_stage = 5;
-inline int NetStateRule::not_stage_size() const {
- return not_stage_.size();
-}
-inline void NetStateRule::clear_not_stage() {
- not_stage_.Clear();
-}
-inline const ::std::string& NetStateRule::not_stage(int index) const {
- // @@protoc_insertion_point(field_get:caffe.NetStateRule.not_stage)
- return not_stage_.Get(index);
-}
-inline ::std::string* NetStateRule::mutable_not_stage(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.NetStateRule.not_stage)
- return not_stage_.Mutable(index);
-}
-inline void NetStateRule::set_not_stage(int index, const ::std::string& value) {
- // @@protoc_insertion_point(field_set:caffe.NetStateRule.not_stage)
- not_stage_.Mutable(index)->assign(value);
-}
-inline void NetStateRule::set_not_stage(int index, const char* value) {
- not_stage_.Mutable(index)->assign(value);
- // @@protoc_insertion_point(field_set_char:caffe.NetStateRule.not_stage)
-}
-inline void NetStateRule::set_not_stage(int index, const char* value, size_t size) {
- not_stage_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:caffe.NetStateRule.not_stage)
-}
-inline ::std::string* NetStateRule::add_not_stage() {
- // @@protoc_insertion_point(field_add_mutable:caffe.NetStateRule.not_stage)
- return not_stage_.Add();
-}
-inline void NetStateRule::add_not_stage(const ::std::string& value) {
- not_stage_.Add()->assign(value);
- // @@protoc_insertion_point(field_add:caffe.NetStateRule.not_stage)
-}
-inline void NetStateRule::add_not_stage(const char* value) {
- not_stage_.Add()->assign(value);
- // @@protoc_insertion_point(field_add_char:caffe.NetStateRule.not_stage)
-}
-inline void NetStateRule::add_not_stage(const char* value, size_t size) {
- not_stage_.Add()->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_add_pointer:caffe.NetStateRule.not_stage)
-}
-inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
-NetStateRule::not_stage() const {
- // @@protoc_insertion_point(field_list:caffe.NetStateRule.not_stage)
- return not_stage_;
-}
-inline ::google::protobuf::RepeatedPtrField< ::std::string>*
-NetStateRule::mutable_not_stage() {
- // @@protoc_insertion_point(field_mutable_list:caffe.NetStateRule.not_stage)
- return ¬_stage_;
-}
-
-inline const NetStateRule* NetStateRule::internal_default_instance() {
- return &NetStateRule_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// ParamSpec
-
-// optional string name = 1;
-inline bool ParamSpec::has_name() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void ParamSpec::set_has_name() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void ParamSpec::clear_has_name() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void ParamSpec::clear_name() {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_name();
-}
-inline const ::std::string& ParamSpec::name() const {
- // @@protoc_insertion_point(field_get:caffe.ParamSpec.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void ParamSpec::set_name(const ::std::string& value) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.ParamSpec.name)
-}
-inline void ParamSpec::set_name(const char* value) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.ParamSpec.name)
-}
-inline void ParamSpec::set_name(const char* value, size_t size) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.ParamSpec.name)
-}
-inline ::std::string* ParamSpec::mutable_name() {
- set_has_name();
- // @@protoc_insertion_point(field_mutable:caffe.ParamSpec.name)
- return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* ParamSpec::release_name() {
- // @@protoc_insertion_point(field_release:caffe.ParamSpec.name)
- clear_has_name();
- return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void ParamSpec::set_allocated_name(::std::string* name) {
- if (name != NULL) {
- set_has_name();
- } else {
- clear_has_name();
- }
- name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
- // @@protoc_insertion_point(field_set_allocated:caffe.ParamSpec.name)
-}
-
-// optional .caffe.ParamSpec.DimCheckMode share_mode = 2;
-inline bool ParamSpec::has_share_mode() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void ParamSpec::set_has_share_mode() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void ParamSpec::clear_has_share_mode() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void ParamSpec::clear_share_mode() {
- share_mode_ = 0;
- clear_has_share_mode();
-}
-inline ::caffe::ParamSpec_DimCheckMode ParamSpec::share_mode() const {
- // @@protoc_insertion_point(field_get:caffe.ParamSpec.share_mode)
- return static_cast< ::caffe::ParamSpec_DimCheckMode >(share_mode_);
-}
-inline void ParamSpec::set_share_mode(::caffe::ParamSpec_DimCheckMode value) {
- assert(::caffe::ParamSpec_DimCheckMode_IsValid(value));
- set_has_share_mode();
- share_mode_ = value;
- // @@protoc_insertion_point(field_set:caffe.ParamSpec.share_mode)
-}
-
-// optional float lr_mult = 3 [default = 1];
-inline bool ParamSpec::has_lr_mult() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void ParamSpec::set_has_lr_mult() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void ParamSpec::clear_has_lr_mult() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void ParamSpec::clear_lr_mult() {
- lr_mult_ = 1;
- clear_has_lr_mult();
-}
-inline float ParamSpec::lr_mult() const {
- // @@protoc_insertion_point(field_get:caffe.ParamSpec.lr_mult)
- return lr_mult_;
-}
-inline void ParamSpec::set_lr_mult(float value) {
- set_has_lr_mult();
- lr_mult_ = value;
- // @@protoc_insertion_point(field_set:caffe.ParamSpec.lr_mult)
-}
-
-// optional float decay_mult = 4 [default = 1];
-inline bool ParamSpec::has_decay_mult() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void ParamSpec::set_has_decay_mult() {
- _has_bits_[0] |= 0x00000008u;
-}
-inline void ParamSpec::clear_has_decay_mult() {
- _has_bits_[0] &= ~0x00000008u;
-}
-inline void ParamSpec::clear_decay_mult() {
- decay_mult_ = 1;
- clear_has_decay_mult();
-}
-inline float ParamSpec::decay_mult() const {
- // @@protoc_insertion_point(field_get:caffe.ParamSpec.decay_mult)
- return decay_mult_;
-}
-inline void ParamSpec::set_decay_mult(float value) {
- set_has_decay_mult();
- decay_mult_ = value;
- // @@protoc_insertion_point(field_set:caffe.ParamSpec.decay_mult)
-}
-
-inline const ParamSpec* ParamSpec::internal_default_instance() {
- return &ParamSpec_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// LayerParameter
-
-// optional string name = 1;
-inline bool LayerParameter::has_name() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void LayerParameter::set_has_name() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void LayerParameter::clear_has_name() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void LayerParameter::clear_name() {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_name();
-}
-inline const ::std::string& LayerParameter::name() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void LayerParameter::set_name(const ::std::string& value) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.LayerParameter.name)
-}
-inline void LayerParameter::set_name(const char* value) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.LayerParameter.name)
-}
-inline void LayerParameter::set_name(const char* value, size_t size) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.LayerParameter.name)
-}
-inline ::std::string* LayerParameter::mutable_name() {
- set_has_name();
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.name)
- return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* LayerParameter::release_name() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.name)
- clear_has_name();
- return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void LayerParameter::set_allocated_name(::std::string* name) {
- if (name != NULL) {
- set_has_name();
- } else {
- clear_has_name();
- }
- name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.name)
-}
-
-// optional string type = 2;
-inline bool LayerParameter::has_type() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void LayerParameter::set_has_type() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void LayerParameter::clear_has_type() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void LayerParameter::clear_type() {
- type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_type();
-}
-inline const ::std::string& LayerParameter::type() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.type)
- return type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void LayerParameter::set_type(const ::std::string& value) {
- set_has_type();
- type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.LayerParameter.type)
-}
-inline void LayerParameter::set_type(const char* value) {
- set_has_type();
- type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.LayerParameter.type)
-}
-inline void LayerParameter::set_type(const char* value, size_t size) {
- set_has_type();
- type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.LayerParameter.type)
-}
-inline ::std::string* LayerParameter::mutable_type() {
- set_has_type();
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.type)
- return type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* LayerParameter::release_type() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.type)
- clear_has_type();
- return type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void LayerParameter::set_allocated_type(::std::string* type) {
- if (type != NULL) {
- set_has_type();
- } else {
- clear_has_type();
- }
- type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type);
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.type)
-}
-
-// repeated string bottom = 3;
-inline int LayerParameter::bottom_size() const {
- return bottom_.size();
-}
-inline void LayerParameter::clear_bottom() {
- bottom_.Clear();
-}
-inline const ::std::string& LayerParameter::bottom(int index) const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.bottom)
- return bottom_.Get(index);
-}
-inline ::std::string* LayerParameter::mutable_bottom(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.bottom)
- return bottom_.Mutable(index);
-}
-inline void LayerParameter::set_bottom(int index, const ::std::string& value) {
- // @@protoc_insertion_point(field_set:caffe.LayerParameter.bottom)
- bottom_.Mutable(index)->assign(value);
-}
-inline void LayerParameter::set_bottom(int index, const char* value) {
- bottom_.Mutable(index)->assign(value);
- // @@protoc_insertion_point(field_set_char:caffe.LayerParameter.bottom)
-}
-inline void LayerParameter::set_bottom(int index, const char* value, size_t size) {
- bottom_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:caffe.LayerParameter.bottom)
-}
-inline ::std::string* LayerParameter::add_bottom() {
- // @@protoc_insertion_point(field_add_mutable:caffe.LayerParameter.bottom)
- return bottom_.Add();
-}
-inline void LayerParameter::add_bottom(const ::std::string& value) {
- bottom_.Add()->assign(value);
- // @@protoc_insertion_point(field_add:caffe.LayerParameter.bottom)
-}
-inline void LayerParameter::add_bottom(const char* value) {
- bottom_.Add()->assign(value);
- // @@protoc_insertion_point(field_add_char:caffe.LayerParameter.bottom)
-}
-inline void LayerParameter::add_bottom(const char* value, size_t size) {
- bottom_.Add()->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_add_pointer:caffe.LayerParameter.bottom)
-}
-inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
-LayerParameter::bottom() const {
- // @@protoc_insertion_point(field_list:caffe.LayerParameter.bottom)
- return bottom_;
-}
-inline ::google::protobuf::RepeatedPtrField< ::std::string>*
-LayerParameter::mutable_bottom() {
- // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.bottom)
- return &bottom_;
-}
-
-// repeated string top = 4;
-inline int LayerParameter::top_size() const {
- return top_.size();
-}
-inline void LayerParameter::clear_top() {
- top_.Clear();
-}
-inline const ::std::string& LayerParameter::top(int index) const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.top)
- return top_.Get(index);
-}
-inline ::std::string* LayerParameter::mutable_top(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.top)
- return top_.Mutable(index);
-}
-inline void LayerParameter::set_top(int index, const ::std::string& value) {
- // @@protoc_insertion_point(field_set:caffe.LayerParameter.top)
- top_.Mutable(index)->assign(value);
-}
-inline void LayerParameter::set_top(int index, const char* value) {
- top_.Mutable(index)->assign(value);
- // @@protoc_insertion_point(field_set_char:caffe.LayerParameter.top)
-}
-inline void LayerParameter::set_top(int index, const char* value, size_t size) {
- top_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:caffe.LayerParameter.top)
-}
-inline ::std::string* LayerParameter::add_top() {
- // @@protoc_insertion_point(field_add_mutable:caffe.LayerParameter.top)
- return top_.Add();
-}
-inline void LayerParameter::add_top(const ::std::string& value) {
- top_.Add()->assign(value);
- // @@protoc_insertion_point(field_add:caffe.LayerParameter.top)
-}
-inline void LayerParameter::add_top(const char* value) {
- top_.Add()->assign(value);
- // @@protoc_insertion_point(field_add_char:caffe.LayerParameter.top)
-}
-inline void LayerParameter::add_top(const char* value, size_t size) {
- top_.Add()->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_add_pointer:caffe.LayerParameter.top)
-}
-inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
-LayerParameter::top() const {
- // @@protoc_insertion_point(field_list:caffe.LayerParameter.top)
- return top_;
-}
-inline ::google::protobuf::RepeatedPtrField< ::std::string>*
-LayerParameter::mutable_top() {
- // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.top)
- return &top_;
-}
-
-// optional .caffe.Phase phase = 10;
-inline bool LayerParameter::has_phase() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-inline void LayerParameter::set_has_phase() {
- _has_bits_[0] |= 0x00000010u;
-}
-inline void LayerParameter::clear_has_phase() {
- _has_bits_[0] &= ~0x00000010u;
-}
-inline void LayerParameter::clear_phase() {
- phase_ = 0;
- clear_has_phase();
-}
-inline ::caffe::Phase LayerParameter::phase() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.phase)
- return static_cast< ::caffe::Phase >(phase_);
-}
-inline void LayerParameter::set_phase(::caffe::Phase value) {
- assert(::caffe::Phase_IsValid(value));
- set_has_phase();
- phase_ = value;
- // @@protoc_insertion_point(field_set:caffe.LayerParameter.phase)
-}
-
-// repeated float loss_weight = 5;
-inline int LayerParameter::loss_weight_size() const {
- return loss_weight_.size();
-}
-inline void LayerParameter::clear_loss_weight() {
- loss_weight_.Clear();
-}
-inline float LayerParameter::loss_weight(int index) const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.loss_weight)
- return loss_weight_.Get(index);
-}
-inline void LayerParameter::set_loss_weight(int index, float value) {
- loss_weight_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.LayerParameter.loss_weight)
-}
-inline void LayerParameter::add_loss_weight(float value) {
- loss_weight_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.LayerParameter.loss_weight)
-}
-inline const ::google::protobuf::RepeatedField< float >&
-LayerParameter::loss_weight() const {
- // @@protoc_insertion_point(field_list:caffe.LayerParameter.loss_weight)
- return loss_weight_;
-}
-inline ::google::protobuf::RepeatedField< float >*
-LayerParameter::mutable_loss_weight() {
- // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.loss_weight)
- return &loss_weight_;
-}
-
-// repeated .caffe.ParamSpec param = 6;
-inline int LayerParameter::param_size() const {
- return param_.size();
-}
-inline void LayerParameter::clear_param() {
- param_.Clear();
-}
-inline const ::caffe::ParamSpec& LayerParameter::param(int index) const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.param)
- return param_.Get(index);
-}
-inline ::caffe::ParamSpec* LayerParameter::mutable_param(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.param)
- return param_.Mutable(index);
-}
-inline ::caffe::ParamSpec* LayerParameter::add_param() {
- // @@protoc_insertion_point(field_add:caffe.LayerParameter.param)
- return param_.Add();
-}
-inline ::google::protobuf::RepeatedPtrField< ::caffe::ParamSpec >*
-LayerParameter::mutable_param() {
- // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.param)
- return ¶m_;
-}
-inline const ::google::protobuf::RepeatedPtrField< ::caffe::ParamSpec >&
-LayerParameter::param() const {
- // @@protoc_insertion_point(field_list:caffe.LayerParameter.param)
- return param_;
-}
-
-// repeated .caffe.BlobProto blobs = 7;
-inline int LayerParameter::blobs_size() const {
- return blobs_.size();
-}
-inline void LayerParameter::clear_blobs() {
- blobs_.Clear();
-}
-inline const ::caffe::BlobProto& LayerParameter::blobs(int index) const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.blobs)
- return blobs_.Get(index);
-}
-inline ::caffe::BlobProto* LayerParameter::mutable_blobs(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.blobs)
- return blobs_.Mutable(index);
-}
-inline ::caffe::BlobProto* LayerParameter::add_blobs() {
- // @@protoc_insertion_point(field_add:caffe.LayerParameter.blobs)
- return blobs_.Add();
-}
-inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
-LayerParameter::mutable_blobs() {
- // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.blobs)
- return &blobs_;
-}
-inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
-LayerParameter::blobs() const {
- // @@protoc_insertion_point(field_list:caffe.LayerParameter.blobs)
- return blobs_;
-}
-
-// repeated bool propagate_down = 11;
-inline int LayerParameter::propagate_down_size() const {
- return propagate_down_.size();
-}
-inline void LayerParameter::clear_propagate_down() {
- propagate_down_.Clear();
-}
-inline bool LayerParameter::propagate_down(int index) const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.propagate_down)
- return propagate_down_.Get(index);
-}
-inline void LayerParameter::set_propagate_down(int index, bool value) {
- propagate_down_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.LayerParameter.propagate_down)
-}
-inline void LayerParameter::add_propagate_down(bool value) {
- propagate_down_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.LayerParameter.propagate_down)
-}
-inline const ::google::protobuf::RepeatedField< bool >&
-LayerParameter::propagate_down() const {
- // @@protoc_insertion_point(field_list:caffe.LayerParameter.propagate_down)
- return propagate_down_;
-}
-inline ::google::protobuf::RepeatedField< bool >*
-LayerParameter::mutable_propagate_down() {
- // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.propagate_down)
- return &propagate_down_;
-}
-
-// repeated .caffe.NetStateRule include = 8;
-inline int LayerParameter::include_size() const {
- return include_.size();
-}
-inline void LayerParameter::clear_include() {
- include_.Clear();
-}
-inline const ::caffe::NetStateRule& LayerParameter::include(int index) const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.include)
- return include_.Get(index);
-}
-inline ::caffe::NetStateRule* LayerParameter::mutable_include(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.include)
- return include_.Mutable(index);
-}
-inline ::caffe::NetStateRule* LayerParameter::add_include() {
- // @@protoc_insertion_point(field_add:caffe.LayerParameter.include)
- return include_.Add();
-}
-inline ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >*
-LayerParameter::mutable_include() {
- // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.include)
- return &include_;
-}
-inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >&
-LayerParameter::include() const {
- // @@protoc_insertion_point(field_list:caffe.LayerParameter.include)
- return include_;
-}
-
-// repeated .caffe.NetStateRule exclude = 9;
-inline int LayerParameter::exclude_size() const {
- return exclude_.size();
-}
-inline void LayerParameter::clear_exclude() {
- exclude_.Clear();
-}
-inline const ::caffe::NetStateRule& LayerParameter::exclude(int index) const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.exclude)
- return exclude_.Get(index);
-}
-inline ::caffe::NetStateRule* LayerParameter::mutable_exclude(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.exclude)
- return exclude_.Mutable(index);
-}
-inline ::caffe::NetStateRule* LayerParameter::add_exclude() {
- // @@protoc_insertion_point(field_add:caffe.LayerParameter.exclude)
- return exclude_.Add();
-}
-inline ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >*
-LayerParameter::mutable_exclude() {
- // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.exclude)
- return &exclude_;
-}
-inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >&
-LayerParameter::exclude() const {
- // @@protoc_insertion_point(field_list:caffe.LayerParameter.exclude)
- return exclude_;
-}
-
-// optional .caffe.TransformationParameter transform_param = 100;
-inline bool LayerParameter::has_transform_param() const {
- return (_has_bits_[0] & 0x00000800u) != 0;
-}
-inline void LayerParameter::set_has_transform_param() {
- _has_bits_[0] |= 0x00000800u;
-}
-inline void LayerParameter::clear_has_transform_param() {
- _has_bits_[0] &= ~0x00000800u;
-}
-inline void LayerParameter::clear_transform_param() {
- if (transform_param_ != NULL) transform_param_->::caffe::TransformationParameter::Clear();
- clear_has_transform_param();
-}
-inline const ::caffe::TransformationParameter& LayerParameter::transform_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.transform_param)
- return transform_param_ != NULL ? *transform_param_
- : *::caffe::TransformationParameter::internal_default_instance();
-}
-inline ::caffe::TransformationParameter* LayerParameter::mutable_transform_param() {
- set_has_transform_param();
- if (transform_param_ == NULL) {
- transform_param_ = new ::caffe::TransformationParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.transform_param)
- return transform_param_;
-}
-inline ::caffe::TransformationParameter* LayerParameter::release_transform_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.transform_param)
- clear_has_transform_param();
- ::caffe::TransformationParameter* temp = transform_param_;
- transform_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_transform_param(::caffe::TransformationParameter* transform_param) {
- delete transform_param_;
- transform_param_ = transform_param;
- if (transform_param) {
- set_has_transform_param();
- } else {
- clear_has_transform_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.transform_param)
-}
-
-// optional .caffe.LossParameter loss_param = 101;
-inline bool LayerParameter::has_loss_param() const {
- return (_has_bits_[0] & 0x00001000u) != 0;
-}
-inline void LayerParameter::set_has_loss_param() {
- _has_bits_[0] |= 0x00001000u;
-}
-inline void LayerParameter::clear_has_loss_param() {
- _has_bits_[0] &= ~0x00001000u;
-}
-inline void LayerParameter::clear_loss_param() {
- if (loss_param_ != NULL) loss_param_->::caffe::LossParameter::Clear();
- clear_has_loss_param();
-}
-inline const ::caffe::LossParameter& LayerParameter::loss_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.loss_param)
- return loss_param_ != NULL ? *loss_param_
- : *::caffe::LossParameter::internal_default_instance();
-}
-inline ::caffe::LossParameter* LayerParameter::mutable_loss_param() {
- set_has_loss_param();
- if (loss_param_ == NULL) {
- loss_param_ = new ::caffe::LossParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.loss_param)
- return loss_param_;
-}
-inline ::caffe::LossParameter* LayerParameter::release_loss_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.loss_param)
- clear_has_loss_param();
- ::caffe::LossParameter* temp = loss_param_;
- loss_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_loss_param(::caffe::LossParameter* loss_param) {
- delete loss_param_;
- loss_param_ = loss_param;
- if (loss_param) {
- set_has_loss_param();
- } else {
- clear_has_loss_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.loss_param)
-}
-
-// optional .caffe.AccuracyParameter accuracy_param = 102;
-inline bool LayerParameter::has_accuracy_param() const {
- return (_has_bits_[0] & 0x00002000u) != 0;
-}
-inline void LayerParameter::set_has_accuracy_param() {
- _has_bits_[0] |= 0x00002000u;
-}
-inline void LayerParameter::clear_has_accuracy_param() {
- _has_bits_[0] &= ~0x00002000u;
-}
-inline void LayerParameter::clear_accuracy_param() {
- if (accuracy_param_ != NULL) accuracy_param_->::caffe::AccuracyParameter::Clear();
- clear_has_accuracy_param();
-}
-inline const ::caffe::AccuracyParameter& LayerParameter::accuracy_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.accuracy_param)
- return accuracy_param_ != NULL ? *accuracy_param_
- : *::caffe::AccuracyParameter::internal_default_instance();
-}
-inline ::caffe::AccuracyParameter* LayerParameter::mutable_accuracy_param() {
- set_has_accuracy_param();
- if (accuracy_param_ == NULL) {
- accuracy_param_ = new ::caffe::AccuracyParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.accuracy_param)
- return accuracy_param_;
-}
-inline ::caffe::AccuracyParameter* LayerParameter::release_accuracy_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.accuracy_param)
- clear_has_accuracy_param();
- ::caffe::AccuracyParameter* temp = accuracy_param_;
- accuracy_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_accuracy_param(::caffe::AccuracyParameter* accuracy_param) {
- delete accuracy_param_;
- accuracy_param_ = accuracy_param;
- if (accuracy_param) {
- set_has_accuracy_param();
- } else {
- clear_has_accuracy_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.accuracy_param)
-}
-
-// optional .caffe.ArgMaxParameter argmax_param = 103;
-inline bool LayerParameter::has_argmax_param() const {
- return (_has_bits_[0] & 0x00004000u) != 0;
-}
-inline void LayerParameter::set_has_argmax_param() {
- _has_bits_[0] |= 0x00004000u;
-}
-inline void LayerParameter::clear_has_argmax_param() {
- _has_bits_[0] &= ~0x00004000u;
-}
-inline void LayerParameter::clear_argmax_param() {
- if (argmax_param_ != NULL) argmax_param_->::caffe::ArgMaxParameter::Clear();
- clear_has_argmax_param();
-}
-inline const ::caffe::ArgMaxParameter& LayerParameter::argmax_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.argmax_param)
- return argmax_param_ != NULL ? *argmax_param_
- : *::caffe::ArgMaxParameter::internal_default_instance();
-}
-inline ::caffe::ArgMaxParameter* LayerParameter::mutable_argmax_param() {
- set_has_argmax_param();
- if (argmax_param_ == NULL) {
- argmax_param_ = new ::caffe::ArgMaxParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.argmax_param)
- return argmax_param_;
-}
-inline ::caffe::ArgMaxParameter* LayerParameter::release_argmax_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.argmax_param)
- clear_has_argmax_param();
- ::caffe::ArgMaxParameter* temp = argmax_param_;
- argmax_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_argmax_param(::caffe::ArgMaxParameter* argmax_param) {
- delete argmax_param_;
- argmax_param_ = argmax_param;
- if (argmax_param) {
- set_has_argmax_param();
- } else {
- clear_has_argmax_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.argmax_param)
-}
-
-// optional .caffe.ConcatParameter concat_param = 104;
-inline bool LayerParameter::has_concat_param() const {
- return (_has_bits_[0] & 0x00008000u) != 0;
-}
-inline void LayerParameter::set_has_concat_param() {
- _has_bits_[0] |= 0x00008000u;
-}
-inline void LayerParameter::clear_has_concat_param() {
- _has_bits_[0] &= ~0x00008000u;
-}
-inline void LayerParameter::clear_concat_param() {
- if (concat_param_ != NULL) concat_param_->::caffe::ConcatParameter::Clear();
- clear_has_concat_param();
-}
-inline const ::caffe::ConcatParameter& LayerParameter::concat_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.concat_param)
- return concat_param_ != NULL ? *concat_param_
- : *::caffe::ConcatParameter::internal_default_instance();
-}
-inline ::caffe::ConcatParameter* LayerParameter::mutable_concat_param() {
- set_has_concat_param();
- if (concat_param_ == NULL) {
- concat_param_ = new ::caffe::ConcatParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.concat_param)
- return concat_param_;
-}
-inline ::caffe::ConcatParameter* LayerParameter::release_concat_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.concat_param)
- clear_has_concat_param();
- ::caffe::ConcatParameter* temp = concat_param_;
- concat_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_concat_param(::caffe::ConcatParameter* concat_param) {
- delete concat_param_;
- concat_param_ = concat_param;
- if (concat_param) {
- set_has_concat_param();
- } else {
- clear_has_concat_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.concat_param)
-}
-
-// optional .caffe.ContrastiveLossParameter contrastive_loss_param = 105;
-inline bool LayerParameter::has_contrastive_loss_param() const {
- return (_has_bits_[0] & 0x00010000u) != 0;
-}
-inline void LayerParameter::set_has_contrastive_loss_param() {
- _has_bits_[0] |= 0x00010000u;
-}
-inline void LayerParameter::clear_has_contrastive_loss_param() {
- _has_bits_[0] &= ~0x00010000u;
-}
-inline void LayerParameter::clear_contrastive_loss_param() {
- if (contrastive_loss_param_ != NULL) contrastive_loss_param_->::caffe::ContrastiveLossParameter::Clear();
- clear_has_contrastive_loss_param();
-}
-inline const ::caffe::ContrastiveLossParameter& LayerParameter::contrastive_loss_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.contrastive_loss_param)
- return contrastive_loss_param_ != NULL ? *contrastive_loss_param_
- : *::caffe::ContrastiveLossParameter::internal_default_instance();
-}
-inline ::caffe::ContrastiveLossParameter* LayerParameter::mutable_contrastive_loss_param() {
- set_has_contrastive_loss_param();
- if (contrastive_loss_param_ == NULL) {
- contrastive_loss_param_ = new ::caffe::ContrastiveLossParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.contrastive_loss_param)
- return contrastive_loss_param_;
-}
-inline ::caffe::ContrastiveLossParameter* LayerParameter::release_contrastive_loss_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.contrastive_loss_param)
- clear_has_contrastive_loss_param();
- ::caffe::ContrastiveLossParameter* temp = contrastive_loss_param_;
- contrastive_loss_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_contrastive_loss_param(::caffe::ContrastiveLossParameter* contrastive_loss_param) {
- delete contrastive_loss_param_;
- contrastive_loss_param_ = contrastive_loss_param;
- if (contrastive_loss_param) {
- set_has_contrastive_loss_param();
- } else {
- clear_has_contrastive_loss_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.contrastive_loss_param)
-}
-
-// optional .caffe.ConvolutionParameter convolution_param = 106;
-inline bool LayerParameter::has_convolution_param() const {
- return (_has_bits_[0] & 0x00020000u) != 0;
-}
-inline void LayerParameter::set_has_convolution_param() {
- _has_bits_[0] |= 0x00020000u;
-}
-inline void LayerParameter::clear_has_convolution_param() {
- _has_bits_[0] &= ~0x00020000u;
-}
-inline void LayerParameter::clear_convolution_param() {
- if (convolution_param_ != NULL) convolution_param_->::caffe::ConvolutionParameter::Clear();
- clear_has_convolution_param();
-}
-inline const ::caffe::ConvolutionParameter& LayerParameter::convolution_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.convolution_param)
- return convolution_param_ != NULL ? *convolution_param_
- : *::caffe::ConvolutionParameter::internal_default_instance();
-}
-inline ::caffe::ConvolutionParameter* LayerParameter::mutable_convolution_param() {
- set_has_convolution_param();
- if (convolution_param_ == NULL) {
- convolution_param_ = new ::caffe::ConvolutionParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.convolution_param)
- return convolution_param_;
-}
-inline ::caffe::ConvolutionParameter* LayerParameter::release_convolution_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.convolution_param)
- clear_has_convolution_param();
- ::caffe::ConvolutionParameter* temp = convolution_param_;
- convolution_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_convolution_param(::caffe::ConvolutionParameter* convolution_param) {
- delete convolution_param_;
- convolution_param_ = convolution_param;
- if (convolution_param) {
- set_has_convolution_param();
- } else {
- clear_has_convolution_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.convolution_param)
-}
-
-// optional .caffe.CropParameter crop_param = 137;
-inline bool LayerParameter::has_crop_param() const {
- return (_has_bits_[0] & 0x00040000u) != 0;
-}
-inline void LayerParameter::set_has_crop_param() {
- _has_bits_[0] |= 0x00040000u;
-}
-inline void LayerParameter::clear_has_crop_param() {
- _has_bits_[0] &= ~0x00040000u;
-}
-inline void LayerParameter::clear_crop_param() {
- if (crop_param_ != NULL) crop_param_->::caffe::CropParameter::Clear();
- clear_has_crop_param();
-}
-inline const ::caffe::CropParameter& LayerParameter::crop_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.crop_param)
- return crop_param_ != NULL ? *crop_param_
- : *::caffe::CropParameter::internal_default_instance();
-}
-inline ::caffe::CropParameter* LayerParameter::mutable_crop_param() {
- set_has_crop_param();
- if (crop_param_ == NULL) {
- crop_param_ = new ::caffe::CropParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.crop_param)
- return crop_param_;
-}
-inline ::caffe::CropParameter* LayerParameter::release_crop_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.crop_param)
- clear_has_crop_param();
- ::caffe::CropParameter* temp = crop_param_;
- crop_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_crop_param(::caffe::CropParameter* crop_param) {
- delete crop_param_;
- crop_param_ = crop_param;
- if (crop_param) {
- set_has_crop_param();
- } else {
- clear_has_crop_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.crop_param)
-}
-
-// optional .caffe.DataParameter data_param = 107;
-inline bool LayerParameter::has_data_param() const {
- return (_has_bits_[0] & 0x00080000u) != 0;
-}
-inline void LayerParameter::set_has_data_param() {
- _has_bits_[0] |= 0x00080000u;
-}
-inline void LayerParameter::clear_has_data_param() {
- _has_bits_[0] &= ~0x00080000u;
-}
-inline void LayerParameter::clear_data_param() {
- if (data_param_ != NULL) data_param_->::caffe::DataParameter::Clear();
- clear_has_data_param();
-}
-inline const ::caffe::DataParameter& LayerParameter::data_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.data_param)
- return data_param_ != NULL ? *data_param_
- : *::caffe::DataParameter::internal_default_instance();
-}
-inline ::caffe::DataParameter* LayerParameter::mutable_data_param() {
- set_has_data_param();
- if (data_param_ == NULL) {
- data_param_ = new ::caffe::DataParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.data_param)
- return data_param_;
-}
-inline ::caffe::DataParameter* LayerParameter::release_data_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.data_param)
- clear_has_data_param();
- ::caffe::DataParameter* temp = data_param_;
- data_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_data_param(::caffe::DataParameter* data_param) {
- delete data_param_;
- data_param_ = data_param;
- if (data_param) {
- set_has_data_param();
- } else {
- clear_has_data_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.data_param)
-}
-
-// optional .caffe.DetectionOutputParameter detection_output_param = 141;
-inline bool LayerParameter::has_detection_output_param() const {
- return (_has_bits_[0] & 0x00100000u) != 0;
-}
-inline void LayerParameter::set_has_detection_output_param() {
- _has_bits_[0] |= 0x00100000u;
-}
-inline void LayerParameter::clear_has_detection_output_param() {
- _has_bits_[0] &= ~0x00100000u;
-}
-inline void LayerParameter::clear_detection_output_param() {
- if (detection_output_param_ != NULL) detection_output_param_->::caffe::DetectionOutputParameter::Clear();
- clear_has_detection_output_param();
-}
-inline const ::caffe::DetectionOutputParameter& LayerParameter::detection_output_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.detection_output_param)
- return detection_output_param_ != NULL ? *detection_output_param_
- : *::caffe::DetectionOutputParameter::internal_default_instance();
-}
-inline ::caffe::DetectionOutputParameter* LayerParameter::mutable_detection_output_param() {
- set_has_detection_output_param();
- if (detection_output_param_ == NULL) {
- detection_output_param_ = new ::caffe::DetectionOutputParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.detection_output_param)
- return detection_output_param_;
-}
-inline ::caffe::DetectionOutputParameter* LayerParameter::release_detection_output_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.detection_output_param)
- clear_has_detection_output_param();
- ::caffe::DetectionOutputParameter* temp = detection_output_param_;
- detection_output_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_detection_output_param(::caffe::DetectionOutputParameter* detection_output_param) {
- delete detection_output_param_;
- detection_output_param_ = detection_output_param;
- if (detection_output_param) {
- set_has_detection_output_param();
- } else {
- clear_has_detection_output_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.detection_output_param)
-}
-
-// optional .caffe.DropoutParameter dropout_param = 108;
-inline bool LayerParameter::has_dropout_param() const {
- return (_has_bits_[0] & 0x00200000u) != 0;
-}
-inline void LayerParameter::set_has_dropout_param() {
- _has_bits_[0] |= 0x00200000u;
-}
-inline void LayerParameter::clear_has_dropout_param() {
- _has_bits_[0] &= ~0x00200000u;
-}
-inline void LayerParameter::clear_dropout_param() {
- if (dropout_param_ != NULL) dropout_param_->::caffe::DropoutParameter::Clear();
- clear_has_dropout_param();
-}
-inline const ::caffe::DropoutParameter& LayerParameter::dropout_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.dropout_param)
- return dropout_param_ != NULL ? *dropout_param_
- : *::caffe::DropoutParameter::internal_default_instance();
-}
-inline ::caffe::DropoutParameter* LayerParameter::mutable_dropout_param() {
- set_has_dropout_param();
- if (dropout_param_ == NULL) {
- dropout_param_ = new ::caffe::DropoutParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.dropout_param)
- return dropout_param_;
-}
-inline ::caffe::DropoutParameter* LayerParameter::release_dropout_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.dropout_param)
- clear_has_dropout_param();
- ::caffe::DropoutParameter* temp = dropout_param_;
- dropout_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_dropout_param(::caffe::DropoutParameter* dropout_param) {
- delete dropout_param_;
- dropout_param_ = dropout_param;
- if (dropout_param) {
- set_has_dropout_param();
- } else {
- clear_has_dropout_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.dropout_param)
-}
-
-// optional .caffe.DummyDataParameter dummy_data_param = 109;
-inline bool LayerParameter::has_dummy_data_param() const {
- return (_has_bits_[0] & 0x00400000u) != 0;
-}
-inline void LayerParameter::set_has_dummy_data_param() {
- _has_bits_[0] |= 0x00400000u;
-}
-inline void LayerParameter::clear_has_dummy_data_param() {
- _has_bits_[0] &= ~0x00400000u;
-}
-inline void LayerParameter::clear_dummy_data_param() {
- if (dummy_data_param_ != NULL) dummy_data_param_->::caffe::DummyDataParameter::Clear();
- clear_has_dummy_data_param();
-}
-inline const ::caffe::DummyDataParameter& LayerParameter::dummy_data_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.dummy_data_param)
- return dummy_data_param_ != NULL ? *dummy_data_param_
- : *::caffe::DummyDataParameter::internal_default_instance();
-}
-inline ::caffe::DummyDataParameter* LayerParameter::mutable_dummy_data_param() {
- set_has_dummy_data_param();
- if (dummy_data_param_ == NULL) {
- dummy_data_param_ = new ::caffe::DummyDataParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.dummy_data_param)
- return dummy_data_param_;
-}
-inline ::caffe::DummyDataParameter* LayerParameter::release_dummy_data_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.dummy_data_param)
- clear_has_dummy_data_param();
- ::caffe::DummyDataParameter* temp = dummy_data_param_;
- dummy_data_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_dummy_data_param(::caffe::DummyDataParameter* dummy_data_param) {
- delete dummy_data_param_;
- dummy_data_param_ = dummy_data_param;
- if (dummy_data_param) {
- set_has_dummy_data_param();
- } else {
- clear_has_dummy_data_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.dummy_data_param)
-}
-
-// optional .caffe.EltwiseParameter eltwise_param = 110;
-inline bool LayerParameter::has_eltwise_param() const {
- return (_has_bits_[0] & 0x00800000u) != 0;
-}
-inline void LayerParameter::set_has_eltwise_param() {
- _has_bits_[0] |= 0x00800000u;
-}
-inline void LayerParameter::clear_has_eltwise_param() {
- _has_bits_[0] &= ~0x00800000u;
-}
-inline void LayerParameter::clear_eltwise_param() {
- if (eltwise_param_ != NULL) eltwise_param_->::caffe::EltwiseParameter::Clear();
- clear_has_eltwise_param();
-}
-inline const ::caffe::EltwiseParameter& LayerParameter::eltwise_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.eltwise_param)
- return eltwise_param_ != NULL ? *eltwise_param_
- : *::caffe::EltwiseParameter::internal_default_instance();
-}
-inline ::caffe::EltwiseParameter* LayerParameter::mutable_eltwise_param() {
- set_has_eltwise_param();
- if (eltwise_param_ == NULL) {
- eltwise_param_ = new ::caffe::EltwiseParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.eltwise_param)
- return eltwise_param_;
-}
-inline ::caffe::EltwiseParameter* LayerParameter::release_eltwise_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.eltwise_param)
- clear_has_eltwise_param();
- ::caffe::EltwiseParameter* temp = eltwise_param_;
- eltwise_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_eltwise_param(::caffe::EltwiseParameter* eltwise_param) {
- delete eltwise_param_;
- eltwise_param_ = eltwise_param;
- if (eltwise_param) {
- set_has_eltwise_param();
- } else {
- clear_has_eltwise_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.eltwise_param)
-}
-
-// optional .caffe.ExpParameter exp_param = 111;
-inline bool LayerParameter::has_exp_param() const {
- return (_has_bits_[0] & 0x01000000u) != 0;
-}
-inline void LayerParameter::set_has_exp_param() {
- _has_bits_[0] |= 0x01000000u;
-}
-inline void LayerParameter::clear_has_exp_param() {
- _has_bits_[0] &= ~0x01000000u;
-}
-inline void LayerParameter::clear_exp_param() {
- if (exp_param_ != NULL) exp_param_->::caffe::ExpParameter::Clear();
- clear_has_exp_param();
-}
-inline const ::caffe::ExpParameter& LayerParameter::exp_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.exp_param)
- return exp_param_ != NULL ? *exp_param_
- : *::caffe::ExpParameter::internal_default_instance();
-}
-inline ::caffe::ExpParameter* LayerParameter::mutable_exp_param() {
- set_has_exp_param();
- if (exp_param_ == NULL) {
- exp_param_ = new ::caffe::ExpParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.exp_param)
- return exp_param_;
-}
-inline ::caffe::ExpParameter* LayerParameter::release_exp_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.exp_param)
- clear_has_exp_param();
- ::caffe::ExpParameter* temp = exp_param_;
- exp_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_exp_param(::caffe::ExpParameter* exp_param) {
- delete exp_param_;
- exp_param_ = exp_param;
- if (exp_param) {
- set_has_exp_param();
- } else {
- clear_has_exp_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.exp_param)
-}
-
-// optional .caffe.FlattenParameter flatten_param = 135;
-inline bool LayerParameter::has_flatten_param() const {
- return (_has_bits_[0] & 0x02000000u) != 0;
-}
-inline void LayerParameter::set_has_flatten_param() {
- _has_bits_[0] |= 0x02000000u;
-}
-inline void LayerParameter::clear_has_flatten_param() {
- _has_bits_[0] &= ~0x02000000u;
-}
-inline void LayerParameter::clear_flatten_param() {
- if (flatten_param_ != NULL) flatten_param_->::caffe::FlattenParameter::Clear();
- clear_has_flatten_param();
-}
-inline const ::caffe::FlattenParameter& LayerParameter::flatten_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.flatten_param)
- return flatten_param_ != NULL ? *flatten_param_
- : *::caffe::FlattenParameter::internal_default_instance();
-}
-inline ::caffe::FlattenParameter* LayerParameter::mutable_flatten_param() {
- set_has_flatten_param();
- if (flatten_param_ == NULL) {
- flatten_param_ = new ::caffe::FlattenParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.flatten_param)
- return flatten_param_;
-}
-inline ::caffe::FlattenParameter* LayerParameter::release_flatten_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.flatten_param)
- clear_has_flatten_param();
- ::caffe::FlattenParameter* temp = flatten_param_;
- flatten_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_flatten_param(::caffe::FlattenParameter* flatten_param) {
- delete flatten_param_;
- flatten_param_ = flatten_param;
- if (flatten_param) {
- set_has_flatten_param();
- } else {
- clear_has_flatten_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.flatten_param)
-}
-
-// optional .caffe.HDF5DataParameter hdf5_data_param = 112;
-inline bool LayerParameter::has_hdf5_data_param() const {
- return (_has_bits_[0] & 0x04000000u) != 0;
-}
-inline void LayerParameter::set_has_hdf5_data_param() {
- _has_bits_[0] |= 0x04000000u;
-}
-inline void LayerParameter::clear_has_hdf5_data_param() {
- _has_bits_[0] &= ~0x04000000u;
-}
-inline void LayerParameter::clear_hdf5_data_param() {
- if (hdf5_data_param_ != NULL) hdf5_data_param_->::caffe::HDF5DataParameter::Clear();
- clear_has_hdf5_data_param();
-}
-inline const ::caffe::HDF5DataParameter& LayerParameter::hdf5_data_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.hdf5_data_param)
- return hdf5_data_param_ != NULL ? *hdf5_data_param_
- : *::caffe::HDF5DataParameter::internal_default_instance();
-}
-inline ::caffe::HDF5DataParameter* LayerParameter::mutable_hdf5_data_param() {
- set_has_hdf5_data_param();
- if (hdf5_data_param_ == NULL) {
- hdf5_data_param_ = new ::caffe::HDF5DataParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.hdf5_data_param)
- return hdf5_data_param_;
-}
-inline ::caffe::HDF5DataParameter* LayerParameter::release_hdf5_data_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.hdf5_data_param)
- clear_has_hdf5_data_param();
- ::caffe::HDF5DataParameter* temp = hdf5_data_param_;
- hdf5_data_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_hdf5_data_param(::caffe::HDF5DataParameter* hdf5_data_param) {
- delete hdf5_data_param_;
- hdf5_data_param_ = hdf5_data_param;
- if (hdf5_data_param) {
- set_has_hdf5_data_param();
- } else {
- clear_has_hdf5_data_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.hdf5_data_param)
-}
-
-// optional .caffe.HDF5OutputParameter hdf5_output_param = 113;
-inline bool LayerParameter::has_hdf5_output_param() const {
- return (_has_bits_[0] & 0x08000000u) != 0;
-}
-inline void LayerParameter::set_has_hdf5_output_param() {
- _has_bits_[0] |= 0x08000000u;
-}
-inline void LayerParameter::clear_has_hdf5_output_param() {
- _has_bits_[0] &= ~0x08000000u;
-}
-inline void LayerParameter::clear_hdf5_output_param() {
- if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear();
- clear_has_hdf5_output_param();
-}
-inline const ::caffe::HDF5OutputParameter& LayerParameter::hdf5_output_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.hdf5_output_param)
- return hdf5_output_param_ != NULL ? *hdf5_output_param_
- : *::caffe::HDF5OutputParameter::internal_default_instance();
-}
-inline ::caffe::HDF5OutputParameter* LayerParameter::mutable_hdf5_output_param() {
- set_has_hdf5_output_param();
- if (hdf5_output_param_ == NULL) {
- hdf5_output_param_ = new ::caffe::HDF5OutputParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.hdf5_output_param)
- return hdf5_output_param_;
-}
-inline ::caffe::HDF5OutputParameter* LayerParameter::release_hdf5_output_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.hdf5_output_param)
- clear_has_hdf5_output_param();
- ::caffe::HDF5OutputParameter* temp = hdf5_output_param_;
- hdf5_output_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param) {
- delete hdf5_output_param_;
- hdf5_output_param_ = hdf5_output_param;
- if (hdf5_output_param) {
- set_has_hdf5_output_param();
- } else {
- clear_has_hdf5_output_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.hdf5_output_param)
-}
-
-// optional .caffe.HingeLossParameter hinge_loss_param = 114;
-inline bool LayerParameter::has_hinge_loss_param() const {
- return (_has_bits_[0] & 0x10000000u) != 0;
-}
-inline void LayerParameter::set_has_hinge_loss_param() {
- _has_bits_[0] |= 0x10000000u;
-}
-inline void LayerParameter::clear_has_hinge_loss_param() {
- _has_bits_[0] &= ~0x10000000u;
-}
-inline void LayerParameter::clear_hinge_loss_param() {
- if (hinge_loss_param_ != NULL) hinge_loss_param_->::caffe::HingeLossParameter::Clear();
- clear_has_hinge_loss_param();
-}
-inline const ::caffe::HingeLossParameter& LayerParameter::hinge_loss_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.hinge_loss_param)
- return hinge_loss_param_ != NULL ? *hinge_loss_param_
- : *::caffe::HingeLossParameter::internal_default_instance();
-}
-inline ::caffe::HingeLossParameter* LayerParameter::mutable_hinge_loss_param() {
- set_has_hinge_loss_param();
- if (hinge_loss_param_ == NULL) {
- hinge_loss_param_ = new ::caffe::HingeLossParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.hinge_loss_param)
- return hinge_loss_param_;
-}
-inline ::caffe::HingeLossParameter* LayerParameter::release_hinge_loss_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.hinge_loss_param)
- clear_has_hinge_loss_param();
- ::caffe::HingeLossParameter* temp = hinge_loss_param_;
- hinge_loss_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_hinge_loss_param(::caffe::HingeLossParameter* hinge_loss_param) {
- delete hinge_loss_param_;
- hinge_loss_param_ = hinge_loss_param;
- if (hinge_loss_param) {
- set_has_hinge_loss_param();
- } else {
- clear_has_hinge_loss_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.hinge_loss_param)
-}
-
-// optional .caffe.ImageDataParameter image_data_param = 115;
-inline bool LayerParameter::has_image_data_param() const {
- return (_has_bits_[0] & 0x20000000u) != 0;
-}
-inline void LayerParameter::set_has_image_data_param() {
- _has_bits_[0] |= 0x20000000u;
-}
-inline void LayerParameter::clear_has_image_data_param() {
- _has_bits_[0] &= ~0x20000000u;
-}
-inline void LayerParameter::clear_image_data_param() {
- if (image_data_param_ != NULL) image_data_param_->::caffe::ImageDataParameter::Clear();
- clear_has_image_data_param();
-}
-inline const ::caffe::ImageDataParameter& LayerParameter::image_data_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.image_data_param)
- return image_data_param_ != NULL ? *image_data_param_
- : *::caffe::ImageDataParameter::internal_default_instance();
-}
-inline ::caffe::ImageDataParameter* LayerParameter::mutable_image_data_param() {
- set_has_image_data_param();
- if (image_data_param_ == NULL) {
- image_data_param_ = new ::caffe::ImageDataParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.image_data_param)
- return image_data_param_;
-}
-inline ::caffe::ImageDataParameter* LayerParameter::release_image_data_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.image_data_param)
- clear_has_image_data_param();
- ::caffe::ImageDataParameter* temp = image_data_param_;
- image_data_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_image_data_param(::caffe::ImageDataParameter* image_data_param) {
- delete image_data_param_;
- image_data_param_ = image_data_param;
- if (image_data_param) {
- set_has_image_data_param();
- } else {
- clear_has_image_data_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.image_data_param)
-}
-
-// optional .caffe.InfogainLossParameter infogain_loss_param = 116;
-inline bool LayerParameter::has_infogain_loss_param() const {
- return (_has_bits_[0] & 0x40000000u) != 0;
-}
-inline void LayerParameter::set_has_infogain_loss_param() {
- _has_bits_[0] |= 0x40000000u;
-}
-inline void LayerParameter::clear_has_infogain_loss_param() {
- _has_bits_[0] &= ~0x40000000u;
-}
-inline void LayerParameter::clear_infogain_loss_param() {
- if (infogain_loss_param_ != NULL) infogain_loss_param_->::caffe::InfogainLossParameter::Clear();
- clear_has_infogain_loss_param();
-}
-inline const ::caffe::InfogainLossParameter& LayerParameter::infogain_loss_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.infogain_loss_param)
- return infogain_loss_param_ != NULL ? *infogain_loss_param_
- : *::caffe::InfogainLossParameter::internal_default_instance();
-}
-inline ::caffe::InfogainLossParameter* LayerParameter::mutable_infogain_loss_param() {
- set_has_infogain_loss_param();
- if (infogain_loss_param_ == NULL) {
- infogain_loss_param_ = new ::caffe::InfogainLossParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.infogain_loss_param)
- return infogain_loss_param_;
-}
-inline ::caffe::InfogainLossParameter* LayerParameter::release_infogain_loss_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.infogain_loss_param)
- clear_has_infogain_loss_param();
- ::caffe::InfogainLossParameter* temp = infogain_loss_param_;
- infogain_loss_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_infogain_loss_param(::caffe::InfogainLossParameter* infogain_loss_param) {
- delete infogain_loss_param_;
- infogain_loss_param_ = infogain_loss_param;
- if (infogain_loss_param) {
- set_has_infogain_loss_param();
- } else {
- clear_has_infogain_loss_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.infogain_loss_param)
-}
-
-// optional .caffe.InnerProductParameter inner_product_param = 117;
-inline bool LayerParameter::has_inner_product_param() const {
- return (_has_bits_[0] & 0x80000000u) != 0;
-}
-inline void LayerParameter::set_has_inner_product_param() {
- _has_bits_[0] |= 0x80000000u;
-}
-inline void LayerParameter::clear_has_inner_product_param() {
- _has_bits_[0] &= ~0x80000000u;
-}
-inline void LayerParameter::clear_inner_product_param() {
- if (inner_product_param_ != NULL) inner_product_param_->::caffe::InnerProductParameter::Clear();
- clear_has_inner_product_param();
-}
-inline const ::caffe::InnerProductParameter& LayerParameter::inner_product_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.inner_product_param)
- return inner_product_param_ != NULL ? *inner_product_param_
- : *::caffe::InnerProductParameter::internal_default_instance();
-}
-inline ::caffe::InnerProductParameter* LayerParameter::mutable_inner_product_param() {
- set_has_inner_product_param();
- if (inner_product_param_ == NULL) {
- inner_product_param_ = new ::caffe::InnerProductParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.inner_product_param)
- return inner_product_param_;
-}
-inline ::caffe::InnerProductParameter* LayerParameter::release_inner_product_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.inner_product_param)
- clear_has_inner_product_param();
- ::caffe::InnerProductParameter* temp = inner_product_param_;
- inner_product_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_inner_product_param(::caffe::InnerProductParameter* inner_product_param) {
- delete inner_product_param_;
- inner_product_param_ = inner_product_param;
- if (inner_product_param) {
- set_has_inner_product_param();
- } else {
- clear_has_inner_product_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.inner_product_param)
-}
-
-// optional .caffe.LogParameter log_param = 134;
-inline bool LayerParameter::has_log_param() const {
- return (_has_bits_[1] & 0x00000001u) != 0;
-}
-inline void LayerParameter::set_has_log_param() {
- _has_bits_[1] |= 0x00000001u;
-}
-inline void LayerParameter::clear_has_log_param() {
- _has_bits_[1] &= ~0x00000001u;
-}
-inline void LayerParameter::clear_log_param() {
- if (log_param_ != NULL) log_param_->::caffe::LogParameter::Clear();
- clear_has_log_param();
-}
-inline const ::caffe::LogParameter& LayerParameter::log_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.log_param)
- return log_param_ != NULL ? *log_param_
- : *::caffe::LogParameter::internal_default_instance();
-}
-inline ::caffe::LogParameter* LayerParameter::mutable_log_param() {
- set_has_log_param();
- if (log_param_ == NULL) {
- log_param_ = new ::caffe::LogParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.log_param)
- return log_param_;
-}
-inline ::caffe::LogParameter* LayerParameter::release_log_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.log_param)
- clear_has_log_param();
- ::caffe::LogParameter* temp = log_param_;
- log_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_log_param(::caffe::LogParameter* log_param) {
- delete log_param_;
- log_param_ = log_param;
- if (log_param) {
- set_has_log_param();
- } else {
- clear_has_log_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.log_param)
-}
-
-// optional .caffe.LRNParameter lrn_param = 118;
-inline bool LayerParameter::has_lrn_param() const {
- return (_has_bits_[1] & 0x00000002u) != 0;
-}
-inline void LayerParameter::set_has_lrn_param() {
- _has_bits_[1] |= 0x00000002u;
-}
-inline void LayerParameter::clear_has_lrn_param() {
- _has_bits_[1] &= ~0x00000002u;
-}
-inline void LayerParameter::clear_lrn_param() {
- if (lrn_param_ != NULL) lrn_param_->::caffe::LRNParameter::Clear();
- clear_has_lrn_param();
-}
-inline const ::caffe::LRNParameter& LayerParameter::lrn_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.lrn_param)
- return lrn_param_ != NULL ? *lrn_param_
- : *::caffe::LRNParameter::internal_default_instance();
-}
-inline ::caffe::LRNParameter* LayerParameter::mutable_lrn_param() {
- set_has_lrn_param();
- if (lrn_param_ == NULL) {
- lrn_param_ = new ::caffe::LRNParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.lrn_param)
- return lrn_param_;
-}
-inline ::caffe::LRNParameter* LayerParameter::release_lrn_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.lrn_param)
- clear_has_lrn_param();
- ::caffe::LRNParameter* temp = lrn_param_;
- lrn_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_lrn_param(::caffe::LRNParameter* lrn_param) {
- delete lrn_param_;
- lrn_param_ = lrn_param;
- if (lrn_param) {
- set_has_lrn_param();
- } else {
- clear_has_lrn_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.lrn_param)
-}
-
-// optional .caffe.MemoryDataParameter memory_data_param = 119;
-inline bool LayerParameter::has_memory_data_param() const {
- return (_has_bits_[1] & 0x00000004u) != 0;
-}
-inline void LayerParameter::set_has_memory_data_param() {
- _has_bits_[1] |= 0x00000004u;
-}
-inline void LayerParameter::clear_has_memory_data_param() {
- _has_bits_[1] &= ~0x00000004u;
-}
-inline void LayerParameter::clear_memory_data_param() {
- if (memory_data_param_ != NULL) memory_data_param_->::caffe::MemoryDataParameter::Clear();
- clear_has_memory_data_param();
-}
-inline const ::caffe::MemoryDataParameter& LayerParameter::memory_data_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.memory_data_param)
- return memory_data_param_ != NULL ? *memory_data_param_
- : *::caffe::MemoryDataParameter::internal_default_instance();
-}
-inline ::caffe::MemoryDataParameter* LayerParameter::mutable_memory_data_param() {
- set_has_memory_data_param();
- if (memory_data_param_ == NULL) {
- memory_data_param_ = new ::caffe::MemoryDataParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.memory_data_param)
- return memory_data_param_;
-}
-inline ::caffe::MemoryDataParameter* LayerParameter::release_memory_data_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.memory_data_param)
- clear_has_memory_data_param();
- ::caffe::MemoryDataParameter* temp = memory_data_param_;
- memory_data_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_memory_data_param(::caffe::MemoryDataParameter* memory_data_param) {
- delete memory_data_param_;
- memory_data_param_ = memory_data_param;
- if (memory_data_param) {
- set_has_memory_data_param();
- } else {
- clear_has_memory_data_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.memory_data_param)
-}
-
-// optional .caffe.MVNParameter mvn_param = 120;
-inline bool LayerParameter::has_mvn_param() const {
- return (_has_bits_[1] & 0x00000008u) != 0;
-}
-inline void LayerParameter::set_has_mvn_param() {
- _has_bits_[1] |= 0x00000008u;
-}
-inline void LayerParameter::clear_has_mvn_param() {
- _has_bits_[1] &= ~0x00000008u;
-}
-inline void LayerParameter::clear_mvn_param() {
- if (mvn_param_ != NULL) mvn_param_->::caffe::MVNParameter::Clear();
- clear_has_mvn_param();
-}
-inline const ::caffe::MVNParameter& LayerParameter::mvn_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.mvn_param)
- return mvn_param_ != NULL ? *mvn_param_
- : *::caffe::MVNParameter::internal_default_instance();
-}
-inline ::caffe::MVNParameter* LayerParameter::mutable_mvn_param() {
- set_has_mvn_param();
- if (mvn_param_ == NULL) {
- mvn_param_ = new ::caffe::MVNParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.mvn_param)
- return mvn_param_;
-}
-inline ::caffe::MVNParameter* LayerParameter::release_mvn_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.mvn_param)
- clear_has_mvn_param();
- ::caffe::MVNParameter* temp = mvn_param_;
- mvn_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_mvn_param(::caffe::MVNParameter* mvn_param) {
- delete mvn_param_;
- mvn_param_ = mvn_param;
- if (mvn_param) {
- set_has_mvn_param();
- } else {
- clear_has_mvn_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.mvn_param)
-}
-
-// optional .caffe.NormalizeBBoxParameter normalize_bbox_param = 139;
-inline bool LayerParameter::has_normalize_bbox_param() const {
- return (_has_bits_[1] & 0x00000010u) != 0;
-}
-inline void LayerParameter::set_has_normalize_bbox_param() {
- _has_bits_[1] |= 0x00000010u;
-}
-inline void LayerParameter::clear_has_normalize_bbox_param() {
- _has_bits_[1] &= ~0x00000010u;
-}
-inline void LayerParameter::clear_normalize_bbox_param() {
- if (normalize_bbox_param_ != NULL) normalize_bbox_param_->::caffe::NormalizeBBoxParameter::Clear();
- clear_has_normalize_bbox_param();
-}
-inline const ::caffe::NormalizeBBoxParameter& LayerParameter::normalize_bbox_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.normalize_bbox_param)
- return normalize_bbox_param_ != NULL ? *normalize_bbox_param_
- : *::caffe::NormalizeBBoxParameter::internal_default_instance();
-}
-inline ::caffe::NormalizeBBoxParameter* LayerParameter::mutable_normalize_bbox_param() {
- set_has_normalize_bbox_param();
- if (normalize_bbox_param_ == NULL) {
- normalize_bbox_param_ = new ::caffe::NormalizeBBoxParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.normalize_bbox_param)
- return normalize_bbox_param_;
-}
-inline ::caffe::NormalizeBBoxParameter* LayerParameter::release_normalize_bbox_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.normalize_bbox_param)
- clear_has_normalize_bbox_param();
- ::caffe::NormalizeBBoxParameter* temp = normalize_bbox_param_;
- normalize_bbox_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_normalize_bbox_param(::caffe::NormalizeBBoxParameter* normalize_bbox_param) {
- delete normalize_bbox_param_;
- normalize_bbox_param_ = normalize_bbox_param;
- if (normalize_bbox_param) {
- set_has_normalize_bbox_param();
- } else {
- clear_has_normalize_bbox_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.normalize_bbox_param)
-}
-
-// optional .caffe.PermuteParameter permute_param = 138;
-inline bool LayerParameter::has_permute_param() const {
- return (_has_bits_[1] & 0x00000020u) != 0;
-}
-inline void LayerParameter::set_has_permute_param() {
- _has_bits_[1] |= 0x00000020u;
-}
-inline void LayerParameter::clear_has_permute_param() {
- _has_bits_[1] &= ~0x00000020u;
-}
-inline void LayerParameter::clear_permute_param() {
- if (permute_param_ != NULL) permute_param_->::caffe::PermuteParameter::Clear();
- clear_has_permute_param();
-}
-inline const ::caffe::PermuteParameter& LayerParameter::permute_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.permute_param)
- return permute_param_ != NULL ? *permute_param_
- : *::caffe::PermuteParameter::internal_default_instance();
-}
-inline ::caffe::PermuteParameter* LayerParameter::mutable_permute_param() {
- set_has_permute_param();
- if (permute_param_ == NULL) {
- permute_param_ = new ::caffe::PermuteParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.permute_param)
- return permute_param_;
-}
-inline ::caffe::PermuteParameter* LayerParameter::release_permute_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.permute_param)
- clear_has_permute_param();
- ::caffe::PermuteParameter* temp = permute_param_;
- permute_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_permute_param(::caffe::PermuteParameter* permute_param) {
- delete permute_param_;
- permute_param_ = permute_param;
- if (permute_param) {
- set_has_permute_param();
- } else {
- clear_has_permute_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.permute_param)
-}
-
-// optional .caffe.PoolingParameter pooling_param = 121;
-inline bool LayerParameter::has_pooling_param() const {
- return (_has_bits_[1] & 0x00000040u) != 0;
-}
-inline void LayerParameter::set_has_pooling_param() {
- _has_bits_[1] |= 0x00000040u;
-}
-inline void LayerParameter::clear_has_pooling_param() {
- _has_bits_[1] &= ~0x00000040u;
-}
-inline void LayerParameter::clear_pooling_param() {
- if (pooling_param_ != NULL) pooling_param_->::caffe::PoolingParameter::Clear();
- clear_has_pooling_param();
-}
-inline const ::caffe::PoolingParameter& LayerParameter::pooling_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.pooling_param)
- return pooling_param_ != NULL ? *pooling_param_
- : *::caffe::PoolingParameter::internal_default_instance();
-}
-inline ::caffe::PoolingParameter* LayerParameter::mutable_pooling_param() {
- set_has_pooling_param();
- if (pooling_param_ == NULL) {
- pooling_param_ = new ::caffe::PoolingParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.pooling_param)
- return pooling_param_;
-}
-inline ::caffe::PoolingParameter* LayerParameter::release_pooling_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.pooling_param)
- clear_has_pooling_param();
- ::caffe::PoolingParameter* temp = pooling_param_;
- pooling_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_pooling_param(::caffe::PoolingParameter* pooling_param) {
- delete pooling_param_;
- pooling_param_ = pooling_param;
- if (pooling_param) {
- set_has_pooling_param();
- } else {
- clear_has_pooling_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.pooling_param)
-}
-
-// optional .caffe.PowerParameter power_param = 122;
-inline bool LayerParameter::has_power_param() const {
- return (_has_bits_[1] & 0x00000080u) != 0;
-}
-inline void LayerParameter::set_has_power_param() {
- _has_bits_[1] |= 0x00000080u;
-}
-inline void LayerParameter::clear_has_power_param() {
- _has_bits_[1] &= ~0x00000080u;
-}
-inline void LayerParameter::clear_power_param() {
- if (power_param_ != NULL) power_param_->::caffe::PowerParameter::Clear();
- clear_has_power_param();
-}
-inline const ::caffe::PowerParameter& LayerParameter::power_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.power_param)
- return power_param_ != NULL ? *power_param_
- : *::caffe::PowerParameter::internal_default_instance();
-}
-inline ::caffe::PowerParameter* LayerParameter::mutable_power_param() {
- set_has_power_param();
- if (power_param_ == NULL) {
- power_param_ = new ::caffe::PowerParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.power_param)
- return power_param_;
-}
-inline ::caffe::PowerParameter* LayerParameter::release_power_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.power_param)
- clear_has_power_param();
- ::caffe::PowerParameter* temp = power_param_;
- power_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_power_param(::caffe::PowerParameter* power_param) {
- delete power_param_;
- power_param_ = power_param;
- if (power_param) {
- set_has_power_param();
- } else {
- clear_has_power_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.power_param)
-}
-
-// optional .caffe.PReLUParameter prelu_param = 131;
-inline bool LayerParameter::has_prelu_param() const {
- return (_has_bits_[1] & 0x00000100u) != 0;
-}
-inline void LayerParameter::set_has_prelu_param() {
- _has_bits_[1] |= 0x00000100u;
-}
-inline void LayerParameter::clear_has_prelu_param() {
- _has_bits_[1] &= ~0x00000100u;
-}
-inline void LayerParameter::clear_prelu_param() {
- if (prelu_param_ != NULL) prelu_param_->::caffe::PReLUParameter::Clear();
- clear_has_prelu_param();
-}
-inline const ::caffe::PReLUParameter& LayerParameter::prelu_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.prelu_param)
- return prelu_param_ != NULL ? *prelu_param_
- : *::caffe::PReLUParameter::internal_default_instance();
-}
-inline ::caffe::PReLUParameter* LayerParameter::mutable_prelu_param() {
- set_has_prelu_param();
- if (prelu_param_ == NULL) {
- prelu_param_ = new ::caffe::PReLUParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.prelu_param)
- return prelu_param_;
-}
-inline ::caffe::PReLUParameter* LayerParameter::release_prelu_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.prelu_param)
- clear_has_prelu_param();
- ::caffe::PReLUParameter* temp = prelu_param_;
- prelu_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_prelu_param(::caffe::PReLUParameter* prelu_param) {
- delete prelu_param_;
- prelu_param_ = prelu_param;
- if (prelu_param) {
- set_has_prelu_param();
- } else {
- clear_has_prelu_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.prelu_param)
-}
-
-// optional .caffe.PriorBoxParameter prior_box_param = 140;
-inline bool LayerParameter::has_prior_box_param() const {
- return (_has_bits_[1] & 0x00000200u) != 0;
-}
-inline void LayerParameter::set_has_prior_box_param() {
- _has_bits_[1] |= 0x00000200u;
-}
-inline void LayerParameter::clear_has_prior_box_param() {
- _has_bits_[1] &= ~0x00000200u;
-}
-inline void LayerParameter::clear_prior_box_param() {
- if (prior_box_param_ != NULL) prior_box_param_->::caffe::PriorBoxParameter::Clear();
- clear_has_prior_box_param();
-}
-inline const ::caffe::PriorBoxParameter& LayerParameter::prior_box_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.prior_box_param)
- return prior_box_param_ != NULL ? *prior_box_param_
- : *::caffe::PriorBoxParameter::internal_default_instance();
-}
-inline ::caffe::PriorBoxParameter* LayerParameter::mutable_prior_box_param() {
- set_has_prior_box_param();
- if (prior_box_param_ == NULL) {
- prior_box_param_ = new ::caffe::PriorBoxParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.prior_box_param)
- return prior_box_param_;
-}
-inline ::caffe::PriorBoxParameter* LayerParameter::release_prior_box_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.prior_box_param)
- clear_has_prior_box_param();
- ::caffe::PriorBoxParameter* temp = prior_box_param_;
- prior_box_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_prior_box_param(::caffe::PriorBoxParameter* prior_box_param) {
- delete prior_box_param_;
- prior_box_param_ = prior_box_param;
- if (prior_box_param) {
- set_has_prior_box_param();
- } else {
- clear_has_prior_box_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.prior_box_param)
-}
-
-// optional .caffe.PythonParameter python_param = 130;
-inline bool LayerParameter::has_python_param() const {
- return (_has_bits_[1] & 0x00000400u) != 0;
-}
-inline void LayerParameter::set_has_python_param() {
- _has_bits_[1] |= 0x00000400u;
-}
-inline void LayerParameter::clear_has_python_param() {
- _has_bits_[1] &= ~0x00000400u;
-}
-inline void LayerParameter::clear_python_param() {
- if (python_param_ != NULL) python_param_->::caffe::PythonParameter::Clear();
- clear_has_python_param();
-}
-inline const ::caffe::PythonParameter& LayerParameter::python_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.python_param)
- return python_param_ != NULL ? *python_param_
- : *::caffe::PythonParameter::internal_default_instance();
-}
-inline ::caffe::PythonParameter* LayerParameter::mutable_python_param() {
- set_has_python_param();
- if (python_param_ == NULL) {
- python_param_ = new ::caffe::PythonParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.python_param)
- return python_param_;
-}
-inline ::caffe::PythonParameter* LayerParameter::release_python_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.python_param)
- clear_has_python_param();
- ::caffe::PythonParameter* temp = python_param_;
- python_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_python_param(::caffe::PythonParameter* python_param) {
- delete python_param_;
- python_param_ = python_param;
- if (python_param) {
- set_has_python_param();
- } else {
- clear_has_python_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.python_param)
-}
-
-// optional .caffe.ReductionParameter reduction_param = 136;
-inline bool LayerParameter::has_reduction_param() const {
- return (_has_bits_[1] & 0x00000800u) != 0;
-}
-inline void LayerParameter::set_has_reduction_param() {
- _has_bits_[1] |= 0x00000800u;
-}
-inline void LayerParameter::clear_has_reduction_param() {
- _has_bits_[1] &= ~0x00000800u;
-}
-inline void LayerParameter::clear_reduction_param() {
- if (reduction_param_ != NULL) reduction_param_->::caffe::ReductionParameter::Clear();
- clear_has_reduction_param();
-}
-inline const ::caffe::ReductionParameter& LayerParameter::reduction_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.reduction_param)
- return reduction_param_ != NULL ? *reduction_param_
- : *::caffe::ReductionParameter::internal_default_instance();
-}
-inline ::caffe::ReductionParameter* LayerParameter::mutable_reduction_param() {
- set_has_reduction_param();
- if (reduction_param_ == NULL) {
- reduction_param_ = new ::caffe::ReductionParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.reduction_param)
- return reduction_param_;
-}
-inline ::caffe::ReductionParameter* LayerParameter::release_reduction_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.reduction_param)
- clear_has_reduction_param();
- ::caffe::ReductionParameter* temp = reduction_param_;
- reduction_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_reduction_param(::caffe::ReductionParameter* reduction_param) {
- delete reduction_param_;
- reduction_param_ = reduction_param;
- if (reduction_param) {
- set_has_reduction_param();
- } else {
- clear_has_reduction_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.reduction_param)
-}
-
-// optional .caffe.ReLUParameter relu_param = 123;
-inline bool LayerParameter::has_relu_param() const {
- return (_has_bits_[1] & 0x00001000u) != 0;
-}
-inline void LayerParameter::set_has_relu_param() {
- _has_bits_[1] |= 0x00001000u;
-}
-inline void LayerParameter::clear_has_relu_param() {
- _has_bits_[1] &= ~0x00001000u;
-}
-inline void LayerParameter::clear_relu_param() {
- if (relu_param_ != NULL) relu_param_->::caffe::ReLUParameter::Clear();
- clear_has_relu_param();
-}
-inline const ::caffe::ReLUParameter& LayerParameter::relu_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.relu_param)
- return relu_param_ != NULL ? *relu_param_
- : *::caffe::ReLUParameter::internal_default_instance();
-}
-inline ::caffe::ReLUParameter* LayerParameter::mutable_relu_param() {
- set_has_relu_param();
- if (relu_param_ == NULL) {
- relu_param_ = new ::caffe::ReLUParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.relu_param)
- return relu_param_;
-}
-inline ::caffe::ReLUParameter* LayerParameter::release_relu_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.relu_param)
- clear_has_relu_param();
- ::caffe::ReLUParameter* temp = relu_param_;
- relu_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_relu_param(::caffe::ReLUParameter* relu_param) {
- delete relu_param_;
- relu_param_ = relu_param;
- if (relu_param) {
- set_has_relu_param();
- } else {
- clear_has_relu_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.relu_param)
-}
-
-// optional .caffe.ReshapeParameter reshape_param = 133;
-inline bool LayerParameter::has_reshape_param() const {
- return (_has_bits_[1] & 0x00002000u) != 0;
-}
-inline void LayerParameter::set_has_reshape_param() {
- _has_bits_[1] |= 0x00002000u;
-}
-inline void LayerParameter::clear_has_reshape_param() {
- _has_bits_[1] &= ~0x00002000u;
-}
-inline void LayerParameter::clear_reshape_param() {
- if (reshape_param_ != NULL) reshape_param_->::caffe::ReshapeParameter::Clear();
- clear_has_reshape_param();
-}
-inline const ::caffe::ReshapeParameter& LayerParameter::reshape_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.reshape_param)
- return reshape_param_ != NULL ? *reshape_param_
- : *::caffe::ReshapeParameter::internal_default_instance();
-}
-inline ::caffe::ReshapeParameter* LayerParameter::mutable_reshape_param() {
- set_has_reshape_param();
- if (reshape_param_ == NULL) {
- reshape_param_ = new ::caffe::ReshapeParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.reshape_param)
- return reshape_param_;
-}
-inline ::caffe::ReshapeParameter* LayerParameter::release_reshape_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.reshape_param)
- clear_has_reshape_param();
- ::caffe::ReshapeParameter* temp = reshape_param_;
- reshape_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_reshape_param(::caffe::ReshapeParameter* reshape_param) {
- delete reshape_param_;
- reshape_param_ = reshape_param;
- if (reshape_param) {
- set_has_reshape_param();
- } else {
- clear_has_reshape_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.reshape_param)
-}
-
-// optional .caffe.SigmoidParameter sigmoid_param = 124;
-inline bool LayerParameter::has_sigmoid_param() const {
- return (_has_bits_[1] & 0x00004000u) != 0;
-}
-inline void LayerParameter::set_has_sigmoid_param() {
- _has_bits_[1] |= 0x00004000u;
-}
-inline void LayerParameter::clear_has_sigmoid_param() {
- _has_bits_[1] &= ~0x00004000u;
-}
-inline void LayerParameter::clear_sigmoid_param() {
- if (sigmoid_param_ != NULL) sigmoid_param_->::caffe::SigmoidParameter::Clear();
- clear_has_sigmoid_param();
-}
-inline const ::caffe::SigmoidParameter& LayerParameter::sigmoid_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.sigmoid_param)
- return sigmoid_param_ != NULL ? *sigmoid_param_
- : *::caffe::SigmoidParameter::internal_default_instance();
-}
-inline ::caffe::SigmoidParameter* LayerParameter::mutable_sigmoid_param() {
- set_has_sigmoid_param();
- if (sigmoid_param_ == NULL) {
- sigmoid_param_ = new ::caffe::SigmoidParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.sigmoid_param)
- return sigmoid_param_;
-}
-inline ::caffe::SigmoidParameter* LayerParameter::release_sigmoid_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.sigmoid_param)
- clear_has_sigmoid_param();
- ::caffe::SigmoidParameter* temp = sigmoid_param_;
- sigmoid_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_sigmoid_param(::caffe::SigmoidParameter* sigmoid_param) {
- delete sigmoid_param_;
- sigmoid_param_ = sigmoid_param;
- if (sigmoid_param) {
- set_has_sigmoid_param();
- } else {
- clear_has_sigmoid_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.sigmoid_param)
-}
-
-// optional .caffe.SliceParameter slice_param = 126;
-inline bool LayerParameter::has_slice_param() const {
- return (_has_bits_[1] & 0x00008000u) != 0;
-}
-inline void LayerParameter::set_has_slice_param() {
- _has_bits_[1] |= 0x00008000u;
-}
-inline void LayerParameter::clear_has_slice_param() {
- _has_bits_[1] &= ~0x00008000u;
-}
-inline void LayerParameter::clear_slice_param() {
- if (slice_param_ != NULL) slice_param_->::caffe::SliceParameter::Clear();
- clear_has_slice_param();
-}
-inline const ::caffe::SliceParameter& LayerParameter::slice_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.slice_param)
- return slice_param_ != NULL ? *slice_param_
- : *::caffe::SliceParameter::internal_default_instance();
-}
-inline ::caffe::SliceParameter* LayerParameter::mutable_slice_param() {
- set_has_slice_param();
- if (slice_param_ == NULL) {
- slice_param_ = new ::caffe::SliceParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.slice_param)
- return slice_param_;
-}
-inline ::caffe::SliceParameter* LayerParameter::release_slice_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.slice_param)
- clear_has_slice_param();
- ::caffe::SliceParameter* temp = slice_param_;
- slice_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_slice_param(::caffe::SliceParameter* slice_param) {
- delete slice_param_;
- slice_param_ = slice_param;
- if (slice_param) {
- set_has_slice_param();
- } else {
- clear_has_slice_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.slice_param)
-}
-
-// optional .caffe.SoftmaxParameter softmax_param = 125;
-inline bool LayerParameter::has_softmax_param() const {
- return (_has_bits_[1] & 0x00010000u) != 0;
-}
-inline void LayerParameter::set_has_softmax_param() {
- _has_bits_[1] |= 0x00010000u;
-}
-inline void LayerParameter::clear_has_softmax_param() {
- _has_bits_[1] &= ~0x00010000u;
-}
-inline void LayerParameter::clear_softmax_param() {
- if (softmax_param_ != NULL) softmax_param_->::caffe::SoftmaxParameter::Clear();
- clear_has_softmax_param();
-}
-inline const ::caffe::SoftmaxParameter& LayerParameter::softmax_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.softmax_param)
- return softmax_param_ != NULL ? *softmax_param_
- : *::caffe::SoftmaxParameter::internal_default_instance();
-}
-inline ::caffe::SoftmaxParameter* LayerParameter::mutable_softmax_param() {
- set_has_softmax_param();
- if (softmax_param_ == NULL) {
- softmax_param_ = new ::caffe::SoftmaxParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.softmax_param)
- return softmax_param_;
-}
-inline ::caffe::SoftmaxParameter* LayerParameter::release_softmax_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.softmax_param)
- clear_has_softmax_param();
- ::caffe::SoftmaxParameter* temp = softmax_param_;
- softmax_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_softmax_param(::caffe::SoftmaxParameter* softmax_param) {
- delete softmax_param_;
- softmax_param_ = softmax_param;
- if (softmax_param) {
- set_has_softmax_param();
- } else {
- clear_has_softmax_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.softmax_param)
-}
-
-// optional .caffe.SPPParameter spp_param = 132;
-inline bool LayerParameter::has_spp_param() const {
- return (_has_bits_[1] & 0x00020000u) != 0;
-}
-inline void LayerParameter::set_has_spp_param() {
- _has_bits_[1] |= 0x00020000u;
-}
-inline void LayerParameter::clear_has_spp_param() {
- _has_bits_[1] &= ~0x00020000u;
-}
-inline void LayerParameter::clear_spp_param() {
- if (spp_param_ != NULL) spp_param_->::caffe::SPPParameter::Clear();
- clear_has_spp_param();
-}
-inline const ::caffe::SPPParameter& LayerParameter::spp_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.spp_param)
- return spp_param_ != NULL ? *spp_param_
- : *::caffe::SPPParameter::internal_default_instance();
-}
-inline ::caffe::SPPParameter* LayerParameter::mutable_spp_param() {
- set_has_spp_param();
- if (spp_param_ == NULL) {
- spp_param_ = new ::caffe::SPPParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.spp_param)
- return spp_param_;
-}
-inline ::caffe::SPPParameter* LayerParameter::release_spp_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.spp_param)
- clear_has_spp_param();
- ::caffe::SPPParameter* temp = spp_param_;
- spp_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_spp_param(::caffe::SPPParameter* spp_param) {
- delete spp_param_;
- spp_param_ = spp_param;
- if (spp_param) {
- set_has_spp_param();
- } else {
- clear_has_spp_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.spp_param)
-}
-
-// optional .caffe.TanHParameter tanh_param = 127;
-inline bool LayerParameter::has_tanh_param() const {
- return (_has_bits_[1] & 0x00040000u) != 0;
-}
-inline void LayerParameter::set_has_tanh_param() {
- _has_bits_[1] |= 0x00040000u;
-}
-inline void LayerParameter::clear_has_tanh_param() {
- _has_bits_[1] &= ~0x00040000u;
-}
-inline void LayerParameter::clear_tanh_param() {
- if (tanh_param_ != NULL) tanh_param_->::caffe::TanHParameter::Clear();
- clear_has_tanh_param();
-}
-inline const ::caffe::TanHParameter& LayerParameter::tanh_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.tanh_param)
- return tanh_param_ != NULL ? *tanh_param_
- : *::caffe::TanHParameter::internal_default_instance();
-}
-inline ::caffe::TanHParameter* LayerParameter::mutable_tanh_param() {
- set_has_tanh_param();
- if (tanh_param_ == NULL) {
- tanh_param_ = new ::caffe::TanHParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.tanh_param)
- return tanh_param_;
-}
-inline ::caffe::TanHParameter* LayerParameter::release_tanh_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.tanh_param)
- clear_has_tanh_param();
- ::caffe::TanHParameter* temp = tanh_param_;
- tanh_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_tanh_param(::caffe::TanHParameter* tanh_param) {
- delete tanh_param_;
- tanh_param_ = tanh_param;
- if (tanh_param) {
- set_has_tanh_param();
- } else {
- clear_has_tanh_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.tanh_param)
-}
-
-// optional .caffe.ThresholdParameter threshold_param = 128;
-inline bool LayerParameter::has_threshold_param() const {
- return (_has_bits_[1] & 0x00080000u) != 0;
-}
-inline void LayerParameter::set_has_threshold_param() {
- _has_bits_[1] |= 0x00080000u;
-}
-inline void LayerParameter::clear_has_threshold_param() {
- _has_bits_[1] &= ~0x00080000u;
-}
-inline void LayerParameter::clear_threshold_param() {
- if (threshold_param_ != NULL) threshold_param_->::caffe::ThresholdParameter::Clear();
- clear_has_threshold_param();
-}
-inline const ::caffe::ThresholdParameter& LayerParameter::threshold_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.threshold_param)
- return threshold_param_ != NULL ? *threshold_param_
- : *::caffe::ThresholdParameter::internal_default_instance();
-}
-inline ::caffe::ThresholdParameter* LayerParameter::mutable_threshold_param() {
- set_has_threshold_param();
- if (threshold_param_ == NULL) {
- threshold_param_ = new ::caffe::ThresholdParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.threshold_param)
- return threshold_param_;
-}
-inline ::caffe::ThresholdParameter* LayerParameter::release_threshold_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.threshold_param)
- clear_has_threshold_param();
- ::caffe::ThresholdParameter* temp = threshold_param_;
- threshold_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_threshold_param(::caffe::ThresholdParameter* threshold_param) {
- delete threshold_param_;
- threshold_param_ = threshold_param;
- if (threshold_param) {
- set_has_threshold_param();
- } else {
- clear_has_threshold_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.threshold_param)
-}
-
-// optional .caffe.WindowDataParameter window_data_param = 129;
-inline bool LayerParameter::has_window_data_param() const {
- return (_has_bits_[1] & 0x00100000u) != 0;
-}
-inline void LayerParameter::set_has_window_data_param() {
- _has_bits_[1] |= 0x00100000u;
-}
-inline void LayerParameter::clear_has_window_data_param() {
- _has_bits_[1] &= ~0x00100000u;
-}
-inline void LayerParameter::clear_window_data_param() {
- if (window_data_param_ != NULL) window_data_param_->::caffe::WindowDataParameter::Clear();
- clear_has_window_data_param();
-}
-inline const ::caffe::WindowDataParameter& LayerParameter::window_data_param() const {
- // @@protoc_insertion_point(field_get:caffe.LayerParameter.window_data_param)
- return window_data_param_ != NULL ? *window_data_param_
- : *::caffe::WindowDataParameter::internal_default_instance();
-}
-inline ::caffe::WindowDataParameter* LayerParameter::mutable_window_data_param() {
- set_has_window_data_param();
- if (window_data_param_ == NULL) {
- window_data_param_ = new ::caffe::WindowDataParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.window_data_param)
- return window_data_param_;
-}
-inline ::caffe::WindowDataParameter* LayerParameter::release_window_data_param() {
- // @@protoc_insertion_point(field_release:caffe.LayerParameter.window_data_param)
- clear_has_window_data_param();
- ::caffe::WindowDataParameter* temp = window_data_param_;
- window_data_param_ = NULL;
- return temp;
-}
-inline void LayerParameter::set_allocated_window_data_param(::caffe::WindowDataParameter* window_data_param) {
- delete window_data_param_;
- window_data_param_ = window_data_param;
- if (window_data_param) {
- set_has_window_data_param();
- } else {
- clear_has_window_data_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.window_data_param)
-}
-
-inline const LayerParameter* LayerParameter::internal_default_instance() {
- return &LayerParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// TransformationParameter
-
-// optional float scale = 1 [default = 1];
-inline bool TransformationParameter::has_scale() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void TransformationParameter::set_has_scale() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void TransformationParameter::clear_has_scale() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void TransformationParameter::clear_scale() {
- scale_ = 1;
- clear_has_scale();
-}
-inline float TransformationParameter::scale() const {
- // @@protoc_insertion_point(field_get:caffe.TransformationParameter.scale)
- return scale_;
-}
-inline void TransformationParameter::set_scale(float value) {
- set_has_scale();
- scale_ = value;
- // @@protoc_insertion_point(field_set:caffe.TransformationParameter.scale)
-}
-
-// optional bool mirror = 2 [default = false];
-inline bool TransformationParameter::has_mirror() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void TransformationParameter::set_has_mirror() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void TransformationParameter::clear_has_mirror() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void TransformationParameter::clear_mirror() {
- mirror_ = false;
- clear_has_mirror();
-}
-inline bool TransformationParameter::mirror() const {
- // @@protoc_insertion_point(field_get:caffe.TransformationParameter.mirror)
- return mirror_;
-}
-inline void TransformationParameter::set_mirror(bool value) {
- set_has_mirror();
- mirror_ = value;
- // @@protoc_insertion_point(field_set:caffe.TransformationParameter.mirror)
-}
-
-// optional uint32 crop_size = 3 [default = 0];
-inline bool TransformationParameter::has_crop_size() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void TransformationParameter::set_has_crop_size() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void TransformationParameter::clear_has_crop_size() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void TransformationParameter::clear_crop_size() {
- crop_size_ = 0u;
- clear_has_crop_size();
-}
-inline ::google::protobuf::uint32 TransformationParameter::crop_size() const {
- // @@protoc_insertion_point(field_get:caffe.TransformationParameter.crop_size)
- return crop_size_;
-}
-inline void TransformationParameter::set_crop_size(::google::protobuf::uint32 value) {
- set_has_crop_size();
- crop_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.TransformationParameter.crop_size)
-}
-
-// optional string mean_file = 4;
-inline bool TransformationParameter::has_mean_file() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void TransformationParameter::set_has_mean_file() {
- _has_bits_[0] |= 0x00000008u;
-}
-inline void TransformationParameter::clear_has_mean_file() {
- _has_bits_[0] &= ~0x00000008u;
-}
-inline void TransformationParameter::clear_mean_file() {
- mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_mean_file();
-}
-inline const ::std::string& TransformationParameter::mean_file() const {
- // @@protoc_insertion_point(field_get:caffe.TransformationParameter.mean_file)
- return mean_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void TransformationParameter::set_mean_file(const ::std::string& value) {
- set_has_mean_file();
- mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.TransformationParameter.mean_file)
-}
-inline void TransformationParameter::set_mean_file(const char* value) {
- set_has_mean_file();
- mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.TransformationParameter.mean_file)
-}
-inline void TransformationParameter::set_mean_file(const char* value, size_t size) {
- set_has_mean_file();
- mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.TransformationParameter.mean_file)
-}
-inline ::std::string* TransformationParameter::mutable_mean_file() {
- set_has_mean_file();
- // @@protoc_insertion_point(field_mutable:caffe.TransformationParameter.mean_file)
- return mean_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* TransformationParameter::release_mean_file() {
- // @@protoc_insertion_point(field_release:caffe.TransformationParameter.mean_file)
- clear_has_mean_file();
- return mean_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void TransformationParameter::set_allocated_mean_file(::std::string* mean_file) {
- if (mean_file != NULL) {
- set_has_mean_file();
- } else {
- clear_has_mean_file();
- }
- mean_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), mean_file);
- // @@protoc_insertion_point(field_set_allocated:caffe.TransformationParameter.mean_file)
-}
-
-// repeated float mean_value = 5;
-inline int TransformationParameter::mean_value_size() const {
- return mean_value_.size();
-}
-inline void TransformationParameter::clear_mean_value() {
- mean_value_.Clear();
-}
-inline float TransformationParameter::mean_value(int index) const {
- // @@protoc_insertion_point(field_get:caffe.TransformationParameter.mean_value)
- return mean_value_.Get(index);
-}
-inline void TransformationParameter::set_mean_value(int index, float value) {
- mean_value_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.TransformationParameter.mean_value)
-}
-inline void TransformationParameter::add_mean_value(float value) {
- mean_value_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.TransformationParameter.mean_value)
-}
-inline const ::google::protobuf::RepeatedField< float >&
-TransformationParameter::mean_value() const {
- // @@protoc_insertion_point(field_list:caffe.TransformationParameter.mean_value)
- return mean_value_;
-}
-inline ::google::protobuf::RepeatedField< float >*
-TransformationParameter::mutable_mean_value() {
- // @@protoc_insertion_point(field_mutable_list:caffe.TransformationParameter.mean_value)
- return &mean_value_;
-}
-
-// optional bool force_color = 6 [default = false];
-inline bool TransformationParameter::has_force_color() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-inline void TransformationParameter::set_has_force_color() {
- _has_bits_[0] |= 0x00000020u;
-}
-inline void TransformationParameter::clear_has_force_color() {
- _has_bits_[0] &= ~0x00000020u;
-}
-inline void TransformationParameter::clear_force_color() {
- force_color_ = false;
- clear_has_force_color();
-}
-inline bool TransformationParameter::force_color() const {
- // @@protoc_insertion_point(field_get:caffe.TransformationParameter.force_color)
- return force_color_;
-}
-inline void TransformationParameter::set_force_color(bool value) {
- set_has_force_color();
- force_color_ = value;
- // @@protoc_insertion_point(field_set:caffe.TransformationParameter.force_color)
-}
-
-// optional bool force_gray = 7 [default = false];
-inline bool TransformationParameter::has_force_gray() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-inline void TransformationParameter::set_has_force_gray() {
- _has_bits_[0] |= 0x00000040u;
-}
-inline void TransformationParameter::clear_has_force_gray() {
- _has_bits_[0] &= ~0x00000040u;
-}
-inline void TransformationParameter::clear_force_gray() {
- force_gray_ = false;
- clear_has_force_gray();
-}
-inline bool TransformationParameter::force_gray() const {
- // @@protoc_insertion_point(field_get:caffe.TransformationParameter.force_gray)
- return force_gray_;
-}
-inline void TransformationParameter::set_force_gray(bool value) {
- set_has_force_gray();
- force_gray_ = value;
- // @@protoc_insertion_point(field_set:caffe.TransformationParameter.force_gray)
-}
-
-inline const TransformationParameter* TransformationParameter::internal_default_instance() {
- return &TransformationParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// LossParameter
-
-// optional int32 ignore_label = 1;
-inline bool LossParameter::has_ignore_label() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void LossParameter::set_has_ignore_label() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void LossParameter::clear_has_ignore_label() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void LossParameter::clear_ignore_label() {
- ignore_label_ = 0;
- clear_has_ignore_label();
-}
-inline ::google::protobuf::int32 LossParameter::ignore_label() const {
- // @@protoc_insertion_point(field_get:caffe.LossParameter.ignore_label)
- return ignore_label_;
-}
-inline void LossParameter::set_ignore_label(::google::protobuf::int32 value) {
- set_has_ignore_label();
- ignore_label_ = value;
- // @@protoc_insertion_point(field_set:caffe.LossParameter.ignore_label)
-}
-
-// optional bool normalize = 2 [default = true];
-inline bool LossParameter::has_normalize() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void LossParameter::set_has_normalize() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void LossParameter::clear_has_normalize() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void LossParameter::clear_normalize() {
- normalize_ = true;
- clear_has_normalize();
-}
-inline bool LossParameter::normalize() const {
- // @@protoc_insertion_point(field_get:caffe.LossParameter.normalize)
- return normalize_;
-}
-inline void LossParameter::set_normalize(bool value) {
- set_has_normalize();
- normalize_ = value;
- // @@protoc_insertion_point(field_set:caffe.LossParameter.normalize)
-}
-
-inline const LossParameter* LossParameter::internal_default_instance() {
- return &LossParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// AccuracyParameter
-
-// optional uint32 top_k = 1 [default = 1];
-inline bool AccuracyParameter::has_top_k() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void AccuracyParameter::set_has_top_k() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void AccuracyParameter::clear_has_top_k() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void AccuracyParameter::clear_top_k() {
- top_k_ = 1u;
- clear_has_top_k();
-}
-inline ::google::protobuf::uint32 AccuracyParameter::top_k() const {
- // @@protoc_insertion_point(field_get:caffe.AccuracyParameter.top_k)
- return top_k_;
-}
-inline void AccuracyParameter::set_top_k(::google::protobuf::uint32 value) {
- set_has_top_k();
- top_k_ = value;
- // @@protoc_insertion_point(field_set:caffe.AccuracyParameter.top_k)
-}
-
-// optional int32 axis = 2 [default = 1];
-inline bool AccuracyParameter::has_axis() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void AccuracyParameter::set_has_axis() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void AccuracyParameter::clear_has_axis() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void AccuracyParameter::clear_axis() {
- axis_ = 1;
- clear_has_axis();
-}
-inline ::google::protobuf::int32 AccuracyParameter::axis() const {
- // @@protoc_insertion_point(field_get:caffe.AccuracyParameter.axis)
- return axis_;
-}
-inline void AccuracyParameter::set_axis(::google::protobuf::int32 value) {
- set_has_axis();
- axis_ = value;
- // @@protoc_insertion_point(field_set:caffe.AccuracyParameter.axis)
-}
-
-// optional int32 ignore_label = 3;
-inline bool AccuracyParameter::has_ignore_label() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void AccuracyParameter::set_has_ignore_label() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void AccuracyParameter::clear_has_ignore_label() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void AccuracyParameter::clear_ignore_label() {
- ignore_label_ = 0;
- clear_has_ignore_label();
-}
-inline ::google::protobuf::int32 AccuracyParameter::ignore_label() const {
- // @@protoc_insertion_point(field_get:caffe.AccuracyParameter.ignore_label)
- return ignore_label_;
-}
-inline void AccuracyParameter::set_ignore_label(::google::protobuf::int32 value) {
- set_has_ignore_label();
- ignore_label_ = value;
- // @@protoc_insertion_point(field_set:caffe.AccuracyParameter.ignore_label)
-}
-
-inline const AccuracyParameter* AccuracyParameter::internal_default_instance() {
- return &AccuracyParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// ArgMaxParameter
-
-// optional bool out_max_val = 1 [default = false];
-inline bool ArgMaxParameter::has_out_max_val() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void ArgMaxParameter::set_has_out_max_val() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void ArgMaxParameter::clear_has_out_max_val() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void ArgMaxParameter::clear_out_max_val() {
- out_max_val_ = false;
- clear_has_out_max_val();
-}
-inline bool ArgMaxParameter::out_max_val() const {
- // @@protoc_insertion_point(field_get:caffe.ArgMaxParameter.out_max_val)
- return out_max_val_;
-}
-inline void ArgMaxParameter::set_out_max_val(bool value) {
- set_has_out_max_val();
- out_max_val_ = value;
- // @@protoc_insertion_point(field_set:caffe.ArgMaxParameter.out_max_val)
-}
-
-// optional uint32 top_k = 2 [default = 1];
-inline bool ArgMaxParameter::has_top_k() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void ArgMaxParameter::set_has_top_k() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void ArgMaxParameter::clear_has_top_k() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void ArgMaxParameter::clear_top_k() {
- top_k_ = 1u;
- clear_has_top_k();
-}
-inline ::google::protobuf::uint32 ArgMaxParameter::top_k() const {
- // @@protoc_insertion_point(field_get:caffe.ArgMaxParameter.top_k)
- return top_k_;
-}
-inline void ArgMaxParameter::set_top_k(::google::protobuf::uint32 value) {
- set_has_top_k();
- top_k_ = value;
- // @@protoc_insertion_point(field_set:caffe.ArgMaxParameter.top_k)
-}
-
-inline const ArgMaxParameter* ArgMaxParameter::internal_default_instance() {
- return &ArgMaxParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// ConcatParameter
-
-// optional int32 axis = 2 [default = 1];
-inline bool ConcatParameter::has_axis() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void ConcatParameter::set_has_axis() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void ConcatParameter::clear_has_axis() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void ConcatParameter::clear_axis() {
- axis_ = 1;
- clear_has_axis();
-}
-inline ::google::protobuf::int32 ConcatParameter::axis() const {
- // @@protoc_insertion_point(field_get:caffe.ConcatParameter.axis)
- return axis_;
-}
-inline void ConcatParameter::set_axis(::google::protobuf::int32 value) {
- set_has_axis();
- axis_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConcatParameter.axis)
-}
-
-// optional uint32 concat_dim = 1 [default = 1];
-inline bool ConcatParameter::has_concat_dim() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void ConcatParameter::set_has_concat_dim() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void ConcatParameter::clear_has_concat_dim() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void ConcatParameter::clear_concat_dim() {
- concat_dim_ = 1u;
- clear_has_concat_dim();
-}
-inline ::google::protobuf::uint32 ConcatParameter::concat_dim() const {
- // @@protoc_insertion_point(field_get:caffe.ConcatParameter.concat_dim)
- return concat_dim_;
-}
-inline void ConcatParameter::set_concat_dim(::google::protobuf::uint32 value) {
- set_has_concat_dim();
- concat_dim_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConcatParameter.concat_dim)
-}
-
-inline const ConcatParameter* ConcatParameter::internal_default_instance() {
- return &ConcatParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// ContrastiveLossParameter
-
-// optional float margin = 1 [default = 1];
-inline bool ContrastiveLossParameter::has_margin() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void ContrastiveLossParameter::set_has_margin() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void ContrastiveLossParameter::clear_has_margin() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void ContrastiveLossParameter::clear_margin() {
- margin_ = 1;
- clear_has_margin();
-}
-inline float ContrastiveLossParameter::margin() const {
- // @@protoc_insertion_point(field_get:caffe.ContrastiveLossParameter.margin)
- return margin_;
-}
-inline void ContrastiveLossParameter::set_margin(float value) {
- set_has_margin();
- margin_ = value;
- // @@protoc_insertion_point(field_set:caffe.ContrastiveLossParameter.margin)
-}
-
-// optional bool legacy_version = 2 [default = false];
-inline bool ContrastiveLossParameter::has_legacy_version() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void ContrastiveLossParameter::set_has_legacy_version() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void ContrastiveLossParameter::clear_has_legacy_version() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void ContrastiveLossParameter::clear_legacy_version() {
- legacy_version_ = false;
- clear_has_legacy_version();
-}
-inline bool ContrastiveLossParameter::legacy_version() const {
- // @@protoc_insertion_point(field_get:caffe.ContrastiveLossParameter.legacy_version)
- return legacy_version_;
-}
-inline void ContrastiveLossParameter::set_legacy_version(bool value) {
- set_has_legacy_version();
- legacy_version_ = value;
- // @@protoc_insertion_point(field_set:caffe.ContrastiveLossParameter.legacy_version)
-}
-
-inline const ContrastiveLossParameter* ContrastiveLossParameter::internal_default_instance() {
- return &ContrastiveLossParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// ConvolutionParameter
-
-// optional uint32 num_output = 1;
-inline bool ConvolutionParameter::has_num_output() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void ConvolutionParameter::set_has_num_output() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void ConvolutionParameter::clear_has_num_output() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void ConvolutionParameter::clear_num_output() {
- num_output_ = 0u;
- clear_has_num_output();
-}
-inline ::google::protobuf::uint32 ConvolutionParameter::num_output() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.num_output)
- return num_output_;
-}
-inline void ConvolutionParameter::set_num_output(::google::protobuf::uint32 value) {
- set_has_num_output();
- num_output_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.num_output)
-}
-
-// optional bool bias_term = 2 [default = true];
-inline bool ConvolutionParameter::has_bias_term() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void ConvolutionParameter::set_has_bias_term() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void ConvolutionParameter::clear_has_bias_term() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void ConvolutionParameter::clear_bias_term() {
- bias_term_ = true;
- clear_has_bias_term();
-}
-inline bool ConvolutionParameter::bias_term() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.bias_term)
- return bias_term_;
-}
-inline void ConvolutionParameter::set_bias_term(bool value) {
- set_has_bias_term();
- bias_term_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.bias_term)
-}
-
-// optional uint32 pad = 3 [default = 0];
-inline bool ConvolutionParameter::has_pad() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void ConvolutionParameter::set_has_pad() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void ConvolutionParameter::clear_has_pad() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void ConvolutionParameter::clear_pad() {
- pad_ = 0u;
- clear_has_pad();
-}
-inline ::google::protobuf::uint32 ConvolutionParameter::pad() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.pad)
- return pad_;
-}
-inline void ConvolutionParameter::set_pad(::google::protobuf::uint32 value) {
- set_has_pad();
- pad_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.pad)
-}
-
-// optional uint32 pad_h = 9 [default = 0];
-inline bool ConvolutionParameter::has_pad_h() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void ConvolutionParameter::set_has_pad_h() {
- _has_bits_[0] |= 0x00000008u;
-}
-inline void ConvolutionParameter::clear_has_pad_h() {
- _has_bits_[0] &= ~0x00000008u;
-}
-inline void ConvolutionParameter::clear_pad_h() {
- pad_h_ = 0u;
- clear_has_pad_h();
-}
-inline ::google::protobuf::uint32 ConvolutionParameter::pad_h() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.pad_h)
- return pad_h_;
-}
-inline void ConvolutionParameter::set_pad_h(::google::protobuf::uint32 value) {
- set_has_pad_h();
- pad_h_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.pad_h)
-}
-
-// optional uint32 pad_w = 10 [default = 0];
-inline bool ConvolutionParameter::has_pad_w() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-inline void ConvolutionParameter::set_has_pad_w() {
- _has_bits_[0] |= 0x00000010u;
-}
-inline void ConvolutionParameter::clear_has_pad_w() {
- _has_bits_[0] &= ~0x00000010u;
-}
-inline void ConvolutionParameter::clear_pad_w() {
- pad_w_ = 0u;
- clear_has_pad_w();
-}
-inline ::google::protobuf::uint32 ConvolutionParameter::pad_w() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.pad_w)
- return pad_w_;
-}
-inline void ConvolutionParameter::set_pad_w(::google::protobuf::uint32 value) {
- set_has_pad_w();
- pad_w_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.pad_w)
-}
-
-// optional uint32 kernel_size = 4;
-inline bool ConvolutionParameter::has_kernel_size() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-inline void ConvolutionParameter::set_has_kernel_size() {
- _has_bits_[0] |= 0x00000020u;
-}
-inline void ConvolutionParameter::clear_has_kernel_size() {
- _has_bits_[0] &= ~0x00000020u;
-}
-inline void ConvolutionParameter::clear_kernel_size() {
- kernel_size_ = 0u;
- clear_has_kernel_size();
-}
-inline ::google::protobuf::uint32 ConvolutionParameter::kernel_size() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.kernel_size)
- return kernel_size_;
-}
-inline void ConvolutionParameter::set_kernel_size(::google::protobuf::uint32 value) {
- set_has_kernel_size();
- kernel_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.kernel_size)
-}
-
-// optional uint32 kernel_h = 11;
-inline bool ConvolutionParameter::has_kernel_h() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-inline void ConvolutionParameter::set_has_kernel_h() {
- _has_bits_[0] |= 0x00000040u;
-}
-inline void ConvolutionParameter::clear_has_kernel_h() {
- _has_bits_[0] &= ~0x00000040u;
-}
-inline void ConvolutionParameter::clear_kernel_h() {
- kernel_h_ = 0u;
- clear_has_kernel_h();
-}
-inline ::google::protobuf::uint32 ConvolutionParameter::kernel_h() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.kernel_h)
- return kernel_h_;
-}
-inline void ConvolutionParameter::set_kernel_h(::google::protobuf::uint32 value) {
- set_has_kernel_h();
- kernel_h_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.kernel_h)
-}
-
-// optional uint32 kernel_w = 12;
-inline bool ConvolutionParameter::has_kernel_w() const {
- return (_has_bits_[0] & 0x00000080u) != 0;
-}
-inline void ConvolutionParameter::set_has_kernel_w() {
- _has_bits_[0] |= 0x00000080u;
-}
-inline void ConvolutionParameter::clear_has_kernel_w() {
- _has_bits_[0] &= ~0x00000080u;
-}
-inline void ConvolutionParameter::clear_kernel_w() {
- kernel_w_ = 0u;
- clear_has_kernel_w();
-}
-inline ::google::protobuf::uint32 ConvolutionParameter::kernel_w() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.kernel_w)
- return kernel_w_;
-}
-inline void ConvolutionParameter::set_kernel_w(::google::protobuf::uint32 value) {
- set_has_kernel_w();
- kernel_w_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.kernel_w)
-}
-
-// optional uint32 group = 5 [default = 1];
-inline bool ConvolutionParameter::has_group() const {
- return (_has_bits_[0] & 0x00000100u) != 0;
-}
-inline void ConvolutionParameter::set_has_group() {
- _has_bits_[0] |= 0x00000100u;
-}
-inline void ConvolutionParameter::clear_has_group() {
- _has_bits_[0] &= ~0x00000100u;
-}
-inline void ConvolutionParameter::clear_group() {
- group_ = 1u;
- clear_has_group();
-}
-inline ::google::protobuf::uint32 ConvolutionParameter::group() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.group)
- return group_;
-}
-inline void ConvolutionParameter::set_group(::google::protobuf::uint32 value) {
- set_has_group();
- group_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.group)
-}
-
-// optional uint32 stride = 6 [default = 1];
-inline bool ConvolutionParameter::has_stride() const {
- return (_has_bits_[0] & 0x00000200u) != 0;
-}
-inline void ConvolutionParameter::set_has_stride() {
- _has_bits_[0] |= 0x00000200u;
-}
-inline void ConvolutionParameter::clear_has_stride() {
- _has_bits_[0] &= ~0x00000200u;
-}
-inline void ConvolutionParameter::clear_stride() {
- stride_ = 1u;
- clear_has_stride();
-}
-inline ::google::protobuf::uint32 ConvolutionParameter::stride() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.stride)
- return stride_;
-}
-inline void ConvolutionParameter::set_stride(::google::protobuf::uint32 value) {
- set_has_stride();
- stride_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.stride)
-}
-
-// optional uint32 stride_h = 13;
-inline bool ConvolutionParameter::has_stride_h() const {
- return (_has_bits_[0] & 0x00000400u) != 0;
-}
-inline void ConvolutionParameter::set_has_stride_h() {
- _has_bits_[0] |= 0x00000400u;
-}
-inline void ConvolutionParameter::clear_has_stride_h() {
- _has_bits_[0] &= ~0x00000400u;
-}
-inline void ConvolutionParameter::clear_stride_h() {
- stride_h_ = 0u;
- clear_has_stride_h();
-}
-inline ::google::protobuf::uint32 ConvolutionParameter::stride_h() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.stride_h)
- return stride_h_;
-}
-inline void ConvolutionParameter::set_stride_h(::google::protobuf::uint32 value) {
- set_has_stride_h();
- stride_h_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.stride_h)
-}
-
-// optional uint32 stride_w = 14;
-inline bool ConvolutionParameter::has_stride_w() const {
- return (_has_bits_[0] & 0x00000800u) != 0;
-}
-inline void ConvolutionParameter::set_has_stride_w() {
- _has_bits_[0] |= 0x00000800u;
-}
-inline void ConvolutionParameter::clear_has_stride_w() {
- _has_bits_[0] &= ~0x00000800u;
-}
-inline void ConvolutionParameter::clear_stride_w() {
- stride_w_ = 0u;
- clear_has_stride_w();
-}
-inline ::google::protobuf::uint32 ConvolutionParameter::stride_w() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.stride_w)
- return stride_w_;
-}
-inline void ConvolutionParameter::set_stride_w(::google::protobuf::uint32 value) {
- set_has_stride_w();
- stride_w_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.stride_w)
-}
-
-// optional .caffe.FillerParameter weight_filler = 7;
-inline bool ConvolutionParameter::has_weight_filler() const {
- return (_has_bits_[0] & 0x00001000u) != 0;
-}
-inline void ConvolutionParameter::set_has_weight_filler() {
- _has_bits_[0] |= 0x00001000u;
-}
-inline void ConvolutionParameter::clear_has_weight_filler() {
- _has_bits_[0] &= ~0x00001000u;
-}
-inline void ConvolutionParameter::clear_weight_filler() {
- if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear();
- clear_has_weight_filler();
-}
-inline const ::caffe::FillerParameter& ConvolutionParameter::weight_filler() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.weight_filler)
- return weight_filler_ != NULL ? *weight_filler_
- : *::caffe::FillerParameter::internal_default_instance();
-}
-inline ::caffe::FillerParameter* ConvolutionParameter::mutable_weight_filler() {
- set_has_weight_filler();
- if (weight_filler_ == NULL) {
- weight_filler_ = new ::caffe::FillerParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.ConvolutionParameter.weight_filler)
- return weight_filler_;
-}
-inline ::caffe::FillerParameter* ConvolutionParameter::release_weight_filler() {
- // @@protoc_insertion_point(field_release:caffe.ConvolutionParameter.weight_filler)
- clear_has_weight_filler();
- ::caffe::FillerParameter* temp = weight_filler_;
- weight_filler_ = NULL;
- return temp;
-}
-inline void ConvolutionParameter::set_allocated_weight_filler(::caffe::FillerParameter* weight_filler) {
- delete weight_filler_;
- weight_filler_ = weight_filler;
- if (weight_filler) {
- set_has_weight_filler();
- } else {
- clear_has_weight_filler();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.ConvolutionParameter.weight_filler)
-}
-
-// optional .caffe.FillerParameter bias_filler = 8;
-inline bool ConvolutionParameter::has_bias_filler() const {
- return (_has_bits_[0] & 0x00002000u) != 0;
-}
-inline void ConvolutionParameter::set_has_bias_filler() {
- _has_bits_[0] |= 0x00002000u;
-}
-inline void ConvolutionParameter::clear_has_bias_filler() {
- _has_bits_[0] &= ~0x00002000u;
-}
-inline void ConvolutionParameter::clear_bias_filler() {
- if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
- clear_has_bias_filler();
-}
-inline const ::caffe::FillerParameter& ConvolutionParameter::bias_filler() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.bias_filler)
- return bias_filler_ != NULL ? *bias_filler_
- : *::caffe::FillerParameter::internal_default_instance();
-}
-inline ::caffe::FillerParameter* ConvolutionParameter::mutable_bias_filler() {
- set_has_bias_filler();
- if (bias_filler_ == NULL) {
- bias_filler_ = new ::caffe::FillerParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.ConvolutionParameter.bias_filler)
- return bias_filler_;
-}
-inline ::caffe::FillerParameter* ConvolutionParameter::release_bias_filler() {
- // @@protoc_insertion_point(field_release:caffe.ConvolutionParameter.bias_filler)
- clear_has_bias_filler();
- ::caffe::FillerParameter* temp = bias_filler_;
- bias_filler_ = NULL;
- return temp;
-}
-inline void ConvolutionParameter::set_allocated_bias_filler(::caffe::FillerParameter* bias_filler) {
- delete bias_filler_;
- bias_filler_ = bias_filler;
- if (bias_filler) {
- set_has_bias_filler();
- } else {
- clear_has_bias_filler();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.ConvolutionParameter.bias_filler)
-}
-
-// optional .caffe.ConvolutionParameter.Engine engine = 15 [default = DEFAULT];
-inline bool ConvolutionParameter::has_engine() const {
- return (_has_bits_[0] & 0x00004000u) != 0;
-}
-inline void ConvolutionParameter::set_has_engine() {
- _has_bits_[0] |= 0x00004000u;
-}
-inline void ConvolutionParameter::clear_has_engine() {
- _has_bits_[0] &= ~0x00004000u;
-}
-inline void ConvolutionParameter::clear_engine() {
- engine_ = 0;
- clear_has_engine();
-}
-inline ::caffe::ConvolutionParameter_Engine ConvolutionParameter::engine() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.engine)
- return static_cast< ::caffe::ConvolutionParameter_Engine >(engine_);
-}
-inline void ConvolutionParameter::set_engine(::caffe::ConvolutionParameter_Engine value) {
- assert(::caffe::ConvolutionParameter_Engine_IsValid(value));
- set_has_engine();
- engine_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.engine)
-}
-
-// optional uint32 dilation_h = 18;
-inline bool ConvolutionParameter::has_dilation_h() const {
- return (_has_bits_[0] & 0x00008000u) != 0;
-}
-inline void ConvolutionParameter::set_has_dilation_h() {
- _has_bits_[0] |= 0x00008000u;
-}
-inline void ConvolutionParameter::clear_has_dilation_h() {
- _has_bits_[0] &= ~0x00008000u;
-}
-inline void ConvolutionParameter::clear_dilation_h() {
- dilation_h_ = 0u;
- clear_has_dilation_h();
-}
-inline ::google::protobuf::uint32 ConvolutionParameter::dilation_h() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.dilation_h)
- return dilation_h_;
-}
-inline void ConvolutionParameter::set_dilation_h(::google::protobuf::uint32 value) {
- set_has_dilation_h();
- dilation_h_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.dilation_h)
-}
-
-// optional uint32 dilation_w = 19;
-inline bool ConvolutionParameter::has_dilation_w() const {
- return (_has_bits_[0] & 0x00010000u) != 0;
-}
-inline void ConvolutionParameter::set_has_dilation_w() {
- _has_bits_[0] |= 0x00010000u;
-}
-inline void ConvolutionParameter::clear_has_dilation_w() {
- _has_bits_[0] &= ~0x00010000u;
-}
-inline void ConvolutionParameter::clear_dilation_w() {
- dilation_w_ = 0u;
- clear_has_dilation_w();
-}
-inline ::google::protobuf::uint32 ConvolutionParameter::dilation_w() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.dilation_w)
- return dilation_w_;
-}
-inline void ConvolutionParameter::set_dilation_w(::google::protobuf::uint32 value) {
- set_has_dilation_w();
- dilation_w_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.dilation_w)
-}
-
-// optional uint32 dilation = 20;
-inline bool ConvolutionParameter::has_dilation() const {
- return (_has_bits_[0] & 0x00020000u) != 0;
-}
-inline void ConvolutionParameter::set_has_dilation() {
- _has_bits_[0] |= 0x00020000u;
-}
-inline void ConvolutionParameter::clear_has_dilation() {
- _has_bits_[0] &= ~0x00020000u;
-}
-inline void ConvolutionParameter::clear_dilation() {
- dilation_ = 0u;
- clear_has_dilation();
-}
-inline ::google::protobuf::uint32 ConvolutionParameter::dilation() const {
- // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.dilation)
- return dilation_;
-}
-inline void ConvolutionParameter::set_dilation(::google::protobuf::uint32 value) {
- set_has_dilation();
- dilation_ = value;
- // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.dilation)
-}
-
-inline const ConvolutionParameter* ConvolutionParameter::internal_default_instance() {
- return &ConvolutionParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// DataParameter
-
-// optional string source = 1;
-inline bool DataParameter::has_source() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void DataParameter::set_has_source() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void DataParameter::clear_has_source() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void DataParameter::clear_source() {
- source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_source();
-}
-inline const ::std::string& DataParameter::source() const {
- // @@protoc_insertion_point(field_get:caffe.DataParameter.source)
- return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void DataParameter::set_source(const ::std::string& value) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.DataParameter.source)
-}
-inline void DataParameter::set_source(const char* value) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.DataParameter.source)
-}
-inline void DataParameter::set_source(const char* value, size_t size) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.DataParameter.source)
-}
-inline ::std::string* DataParameter::mutable_source() {
- set_has_source();
- // @@protoc_insertion_point(field_mutable:caffe.DataParameter.source)
- return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* DataParameter::release_source() {
- // @@protoc_insertion_point(field_release:caffe.DataParameter.source)
- clear_has_source();
- return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void DataParameter::set_allocated_source(::std::string* source) {
- if (source != NULL) {
- set_has_source();
- } else {
- clear_has_source();
- }
- source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source);
- // @@protoc_insertion_point(field_set_allocated:caffe.DataParameter.source)
-}
-
-// optional uint32 batch_size = 4;
-inline bool DataParameter::has_batch_size() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void DataParameter::set_has_batch_size() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void DataParameter::clear_has_batch_size() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void DataParameter::clear_batch_size() {
- batch_size_ = 0u;
- clear_has_batch_size();
-}
-inline ::google::protobuf::uint32 DataParameter::batch_size() const {
- // @@protoc_insertion_point(field_get:caffe.DataParameter.batch_size)
- return batch_size_;
-}
-inline void DataParameter::set_batch_size(::google::protobuf::uint32 value) {
- set_has_batch_size();
- batch_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.DataParameter.batch_size)
-}
-
-// optional uint32 rand_skip = 7 [default = 0];
-inline bool DataParameter::has_rand_skip() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void DataParameter::set_has_rand_skip() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void DataParameter::clear_has_rand_skip() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void DataParameter::clear_rand_skip() {
- rand_skip_ = 0u;
- clear_has_rand_skip();
-}
-inline ::google::protobuf::uint32 DataParameter::rand_skip() const {
- // @@protoc_insertion_point(field_get:caffe.DataParameter.rand_skip)
- return rand_skip_;
-}
-inline void DataParameter::set_rand_skip(::google::protobuf::uint32 value) {
- set_has_rand_skip();
- rand_skip_ = value;
- // @@protoc_insertion_point(field_set:caffe.DataParameter.rand_skip)
-}
-
-// optional .caffe.DataParameter.DB backend = 8 [default = LEVELDB];
-inline bool DataParameter::has_backend() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void DataParameter::set_has_backend() {
- _has_bits_[0] |= 0x00000008u;
-}
-inline void DataParameter::clear_has_backend() {
- _has_bits_[0] &= ~0x00000008u;
-}
-inline void DataParameter::clear_backend() {
- backend_ = 0;
- clear_has_backend();
-}
-inline ::caffe::DataParameter_DB DataParameter::backend() const {
- // @@protoc_insertion_point(field_get:caffe.DataParameter.backend)
- return static_cast< ::caffe::DataParameter_DB >(backend_);
-}
-inline void DataParameter::set_backend(::caffe::DataParameter_DB value) {
- assert(::caffe::DataParameter_DB_IsValid(value));
- set_has_backend();
- backend_ = value;
- // @@protoc_insertion_point(field_set:caffe.DataParameter.backend)
-}
-
-// optional float scale = 2 [default = 1];
-inline bool DataParameter::has_scale() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-inline void DataParameter::set_has_scale() {
- _has_bits_[0] |= 0x00000010u;
-}
-inline void DataParameter::clear_has_scale() {
- _has_bits_[0] &= ~0x00000010u;
-}
-inline void DataParameter::clear_scale() {
- scale_ = 1;
- clear_has_scale();
-}
-inline float DataParameter::scale() const {
- // @@protoc_insertion_point(field_get:caffe.DataParameter.scale)
- return scale_;
-}
-inline void DataParameter::set_scale(float value) {
- set_has_scale();
- scale_ = value;
- // @@protoc_insertion_point(field_set:caffe.DataParameter.scale)
-}
-
-// optional string mean_file = 3;
-inline bool DataParameter::has_mean_file() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-inline void DataParameter::set_has_mean_file() {
- _has_bits_[0] |= 0x00000020u;
-}
-inline void DataParameter::clear_has_mean_file() {
- _has_bits_[0] &= ~0x00000020u;
-}
-inline void DataParameter::clear_mean_file() {
- mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_mean_file();
-}
-inline const ::std::string& DataParameter::mean_file() const {
- // @@protoc_insertion_point(field_get:caffe.DataParameter.mean_file)
- return mean_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void DataParameter::set_mean_file(const ::std::string& value) {
- set_has_mean_file();
- mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.DataParameter.mean_file)
-}
-inline void DataParameter::set_mean_file(const char* value) {
- set_has_mean_file();
- mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.DataParameter.mean_file)
-}
-inline void DataParameter::set_mean_file(const char* value, size_t size) {
- set_has_mean_file();
- mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.DataParameter.mean_file)
-}
-inline ::std::string* DataParameter::mutable_mean_file() {
- set_has_mean_file();
- // @@protoc_insertion_point(field_mutable:caffe.DataParameter.mean_file)
- return mean_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* DataParameter::release_mean_file() {
- // @@protoc_insertion_point(field_release:caffe.DataParameter.mean_file)
- clear_has_mean_file();
- return mean_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void DataParameter::set_allocated_mean_file(::std::string* mean_file) {
- if (mean_file != NULL) {
- set_has_mean_file();
- } else {
- clear_has_mean_file();
- }
- mean_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), mean_file);
- // @@protoc_insertion_point(field_set_allocated:caffe.DataParameter.mean_file)
-}
-
-// optional uint32 crop_size = 5 [default = 0];
-inline bool DataParameter::has_crop_size() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-inline void DataParameter::set_has_crop_size() {
- _has_bits_[0] |= 0x00000040u;
-}
-inline void DataParameter::clear_has_crop_size() {
- _has_bits_[0] &= ~0x00000040u;
-}
-inline void DataParameter::clear_crop_size() {
- crop_size_ = 0u;
- clear_has_crop_size();
-}
-inline ::google::protobuf::uint32 DataParameter::crop_size() const {
- // @@protoc_insertion_point(field_get:caffe.DataParameter.crop_size)
- return crop_size_;
-}
-inline void DataParameter::set_crop_size(::google::protobuf::uint32 value) {
- set_has_crop_size();
- crop_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.DataParameter.crop_size)
-}
-
-// optional bool mirror = 6 [default = false];
-inline bool DataParameter::has_mirror() const {
- return (_has_bits_[0] & 0x00000080u) != 0;
-}
-inline void DataParameter::set_has_mirror() {
- _has_bits_[0] |= 0x00000080u;
-}
-inline void DataParameter::clear_has_mirror() {
- _has_bits_[0] &= ~0x00000080u;
-}
-inline void DataParameter::clear_mirror() {
- mirror_ = false;
- clear_has_mirror();
-}
-inline bool DataParameter::mirror() const {
- // @@protoc_insertion_point(field_get:caffe.DataParameter.mirror)
- return mirror_;
-}
-inline void DataParameter::set_mirror(bool value) {
- set_has_mirror();
- mirror_ = value;
- // @@protoc_insertion_point(field_set:caffe.DataParameter.mirror)
-}
-
-// optional bool force_encoded_color = 9 [default = false];
-inline bool DataParameter::has_force_encoded_color() const {
- return (_has_bits_[0] & 0x00000100u) != 0;
-}
-inline void DataParameter::set_has_force_encoded_color() {
- _has_bits_[0] |= 0x00000100u;
-}
-inline void DataParameter::clear_has_force_encoded_color() {
- _has_bits_[0] &= ~0x00000100u;
-}
-inline void DataParameter::clear_force_encoded_color() {
- force_encoded_color_ = false;
- clear_has_force_encoded_color();
-}
-inline bool DataParameter::force_encoded_color() const {
- // @@protoc_insertion_point(field_get:caffe.DataParameter.force_encoded_color)
- return force_encoded_color_;
-}
-inline void DataParameter::set_force_encoded_color(bool value) {
- set_has_force_encoded_color();
- force_encoded_color_ = value;
- // @@protoc_insertion_point(field_set:caffe.DataParameter.force_encoded_color)
-}
-
-inline const DataParameter* DataParameter::internal_default_instance() {
- return &DataParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// DropoutParameter
-
-// optional float dropout_ratio = 1 [default = 0.5];
-inline bool DropoutParameter::has_dropout_ratio() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void DropoutParameter::set_has_dropout_ratio() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void DropoutParameter::clear_has_dropout_ratio() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void DropoutParameter::clear_dropout_ratio() {
- dropout_ratio_ = 0.5f;
- clear_has_dropout_ratio();
-}
-inline float DropoutParameter::dropout_ratio() const {
- // @@protoc_insertion_point(field_get:caffe.DropoutParameter.dropout_ratio)
- return dropout_ratio_;
-}
-inline void DropoutParameter::set_dropout_ratio(float value) {
- set_has_dropout_ratio();
- dropout_ratio_ = value;
- // @@protoc_insertion_point(field_set:caffe.DropoutParameter.dropout_ratio)
-}
-
-inline const DropoutParameter* DropoutParameter::internal_default_instance() {
- return &DropoutParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// DummyDataParameter
-
-// repeated .caffe.FillerParameter data_filler = 1;
-inline int DummyDataParameter::data_filler_size() const {
- return data_filler_.size();
-}
-inline void DummyDataParameter::clear_data_filler() {
- data_filler_.Clear();
-}
-inline const ::caffe::FillerParameter& DummyDataParameter::data_filler(int index) const {
- // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.data_filler)
- return data_filler_.Get(index);
-}
-inline ::caffe::FillerParameter* DummyDataParameter::mutable_data_filler(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.DummyDataParameter.data_filler)
- return data_filler_.Mutable(index);
-}
-inline ::caffe::FillerParameter* DummyDataParameter::add_data_filler() {
- // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.data_filler)
- return data_filler_.Add();
-}
-inline ::google::protobuf::RepeatedPtrField< ::caffe::FillerParameter >*
-DummyDataParameter::mutable_data_filler() {
- // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.data_filler)
- return &data_filler_;
-}
-inline const ::google::protobuf::RepeatedPtrField< ::caffe::FillerParameter >&
-DummyDataParameter::data_filler() const {
- // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.data_filler)
- return data_filler_;
-}
-
-// repeated .caffe.BlobShape shape = 6;
-inline int DummyDataParameter::shape_size() const {
- return shape_.size();
-}
-inline void DummyDataParameter::clear_shape() {
- shape_.Clear();
-}
-inline const ::caffe::BlobShape& DummyDataParameter::shape(int index) const {
- // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.shape)
- return shape_.Get(index);
-}
-inline ::caffe::BlobShape* DummyDataParameter::mutable_shape(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.DummyDataParameter.shape)
- return shape_.Mutable(index);
-}
-inline ::caffe::BlobShape* DummyDataParameter::add_shape() {
- // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.shape)
- return shape_.Add();
-}
-inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >*
-DummyDataParameter::mutable_shape() {
- // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.shape)
- return &shape_;
-}
-inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >&
-DummyDataParameter::shape() const {
- // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.shape)
- return shape_;
-}
-
-// repeated uint32 num = 2;
-inline int DummyDataParameter::num_size() const {
- return num_.size();
-}
-inline void DummyDataParameter::clear_num() {
- num_.Clear();
-}
-inline ::google::protobuf::uint32 DummyDataParameter::num(int index) const {
- // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.num)
- return num_.Get(index);
-}
-inline void DummyDataParameter::set_num(int index, ::google::protobuf::uint32 value) {
- num_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.DummyDataParameter.num)
-}
-inline void DummyDataParameter::add_num(::google::protobuf::uint32 value) {
- num_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.num)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-DummyDataParameter::num() const {
- // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.num)
- return num_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-DummyDataParameter::mutable_num() {
- // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.num)
- return &num_;
-}
-
-// repeated uint32 channels = 3;
-inline int DummyDataParameter::channels_size() const {
- return channels_.size();
-}
-inline void DummyDataParameter::clear_channels() {
- channels_.Clear();
-}
-inline ::google::protobuf::uint32 DummyDataParameter::channels(int index) const {
- // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.channels)
- return channels_.Get(index);
-}
-inline void DummyDataParameter::set_channels(int index, ::google::protobuf::uint32 value) {
- channels_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.DummyDataParameter.channels)
-}
-inline void DummyDataParameter::add_channels(::google::protobuf::uint32 value) {
- channels_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.channels)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-DummyDataParameter::channels() const {
- // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.channels)
- return channels_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-DummyDataParameter::mutable_channels() {
- // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.channels)
- return &channels_;
-}
-
-// repeated uint32 height = 4;
-inline int DummyDataParameter::height_size() const {
- return height_.size();
-}
-inline void DummyDataParameter::clear_height() {
- height_.Clear();
-}
-inline ::google::protobuf::uint32 DummyDataParameter::height(int index) const {
- // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.height)
- return height_.Get(index);
-}
-inline void DummyDataParameter::set_height(int index, ::google::protobuf::uint32 value) {
- height_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.DummyDataParameter.height)
-}
-inline void DummyDataParameter::add_height(::google::protobuf::uint32 value) {
- height_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.height)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-DummyDataParameter::height() const {
- // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.height)
- return height_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-DummyDataParameter::mutable_height() {
- // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.height)
- return &height_;
-}
-
-// repeated uint32 width = 5;
-inline int DummyDataParameter::width_size() const {
- return width_.size();
-}
-inline void DummyDataParameter::clear_width() {
- width_.Clear();
-}
-inline ::google::protobuf::uint32 DummyDataParameter::width(int index) const {
- // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.width)
- return width_.Get(index);
-}
-inline void DummyDataParameter::set_width(int index, ::google::protobuf::uint32 value) {
- width_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.DummyDataParameter.width)
-}
-inline void DummyDataParameter::add_width(::google::protobuf::uint32 value) {
- width_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.width)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-DummyDataParameter::width() const {
- // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.width)
- return width_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-DummyDataParameter::mutable_width() {
- // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.width)
- return &width_;
-}
-
-inline const DummyDataParameter* DummyDataParameter::internal_default_instance() {
- return &DummyDataParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// EltwiseParameter
-
-// optional .caffe.EltwiseParameter.EltwiseOp operation = 1 [default = SUM];
-inline bool EltwiseParameter::has_operation() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void EltwiseParameter::set_has_operation() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void EltwiseParameter::clear_has_operation() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void EltwiseParameter::clear_operation() {
- operation_ = 1;
- clear_has_operation();
-}
-inline ::caffe::EltwiseParameter_EltwiseOp EltwiseParameter::operation() const {
- // @@protoc_insertion_point(field_get:caffe.EltwiseParameter.operation)
- return static_cast< ::caffe::EltwiseParameter_EltwiseOp >(operation_);
-}
-inline void EltwiseParameter::set_operation(::caffe::EltwiseParameter_EltwiseOp value) {
- assert(::caffe::EltwiseParameter_EltwiseOp_IsValid(value));
- set_has_operation();
- operation_ = value;
- // @@protoc_insertion_point(field_set:caffe.EltwiseParameter.operation)
-}
-
-// repeated float coeff = 2;
-inline int EltwiseParameter::coeff_size() const {
- return coeff_.size();
-}
-inline void EltwiseParameter::clear_coeff() {
- coeff_.Clear();
-}
-inline float EltwiseParameter::coeff(int index) const {
- // @@protoc_insertion_point(field_get:caffe.EltwiseParameter.coeff)
- return coeff_.Get(index);
-}
-inline void EltwiseParameter::set_coeff(int index, float value) {
- coeff_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.EltwiseParameter.coeff)
-}
-inline void EltwiseParameter::add_coeff(float value) {
- coeff_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.EltwiseParameter.coeff)
-}
-inline const ::google::protobuf::RepeatedField< float >&
-EltwiseParameter::coeff() const {
- // @@protoc_insertion_point(field_list:caffe.EltwiseParameter.coeff)
- return coeff_;
-}
-inline ::google::protobuf::RepeatedField< float >*
-EltwiseParameter::mutable_coeff() {
- // @@protoc_insertion_point(field_mutable_list:caffe.EltwiseParameter.coeff)
- return &coeff_;
-}
-
-// optional bool stable_prod_grad = 3 [default = true];
-inline bool EltwiseParameter::has_stable_prod_grad() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void EltwiseParameter::set_has_stable_prod_grad() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void EltwiseParameter::clear_has_stable_prod_grad() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void EltwiseParameter::clear_stable_prod_grad() {
- stable_prod_grad_ = true;
- clear_has_stable_prod_grad();
-}
-inline bool EltwiseParameter::stable_prod_grad() const {
- // @@protoc_insertion_point(field_get:caffe.EltwiseParameter.stable_prod_grad)
- return stable_prod_grad_;
-}
-inline void EltwiseParameter::set_stable_prod_grad(bool value) {
- set_has_stable_prod_grad();
- stable_prod_grad_ = value;
- // @@protoc_insertion_point(field_set:caffe.EltwiseParameter.stable_prod_grad)
-}
-
-inline const EltwiseParameter* EltwiseParameter::internal_default_instance() {
- return &EltwiseParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// ExpParameter
-
-// optional float base = 1 [default = -1];
-inline bool ExpParameter::has_base() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void ExpParameter::set_has_base() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void ExpParameter::clear_has_base() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void ExpParameter::clear_base() {
- base_ = -1;
- clear_has_base();
-}
-inline float ExpParameter::base() const {
- // @@protoc_insertion_point(field_get:caffe.ExpParameter.base)
- return base_;
-}
-inline void ExpParameter::set_base(float value) {
- set_has_base();
- base_ = value;
- // @@protoc_insertion_point(field_set:caffe.ExpParameter.base)
-}
-
-// optional float scale = 2 [default = 1];
-inline bool ExpParameter::has_scale() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void ExpParameter::set_has_scale() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void ExpParameter::clear_has_scale() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void ExpParameter::clear_scale() {
- scale_ = 1;
- clear_has_scale();
-}
-inline float ExpParameter::scale() const {
- // @@protoc_insertion_point(field_get:caffe.ExpParameter.scale)
- return scale_;
-}
-inline void ExpParameter::set_scale(float value) {
- set_has_scale();
- scale_ = value;
- // @@protoc_insertion_point(field_set:caffe.ExpParameter.scale)
-}
-
-// optional float shift = 3 [default = 0];
-inline bool ExpParameter::has_shift() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void ExpParameter::set_has_shift() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void ExpParameter::clear_has_shift() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void ExpParameter::clear_shift() {
- shift_ = 0;
- clear_has_shift();
-}
-inline float ExpParameter::shift() const {
- // @@protoc_insertion_point(field_get:caffe.ExpParameter.shift)
- return shift_;
-}
-inline void ExpParameter::set_shift(float value) {
- set_has_shift();
- shift_ = value;
- // @@protoc_insertion_point(field_set:caffe.ExpParameter.shift)
-}
-
-inline const ExpParameter* ExpParameter::internal_default_instance() {
- return &ExpParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// FlattenParameter
-
-// optional int32 axis = 1 [default = 1];
-inline bool FlattenParameter::has_axis() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void FlattenParameter::set_has_axis() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void FlattenParameter::clear_has_axis() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void FlattenParameter::clear_axis() {
- axis_ = 1;
- clear_has_axis();
-}
-inline ::google::protobuf::int32 FlattenParameter::axis() const {
- // @@protoc_insertion_point(field_get:caffe.FlattenParameter.axis)
- return axis_;
-}
-inline void FlattenParameter::set_axis(::google::protobuf::int32 value) {
- set_has_axis();
- axis_ = value;
- // @@protoc_insertion_point(field_set:caffe.FlattenParameter.axis)
-}
-
-// optional int32 end_axis = 2 [default = -1];
-inline bool FlattenParameter::has_end_axis() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void FlattenParameter::set_has_end_axis() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void FlattenParameter::clear_has_end_axis() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void FlattenParameter::clear_end_axis() {
- end_axis_ = -1;
- clear_has_end_axis();
-}
-inline ::google::protobuf::int32 FlattenParameter::end_axis() const {
- // @@protoc_insertion_point(field_get:caffe.FlattenParameter.end_axis)
- return end_axis_;
-}
-inline void FlattenParameter::set_end_axis(::google::protobuf::int32 value) {
- set_has_end_axis();
- end_axis_ = value;
- // @@protoc_insertion_point(field_set:caffe.FlattenParameter.end_axis)
-}
-
-inline const FlattenParameter* FlattenParameter::internal_default_instance() {
- return &FlattenParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// HDF5DataParameter
-
-// optional string source = 1;
-inline bool HDF5DataParameter::has_source() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void HDF5DataParameter::set_has_source() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void HDF5DataParameter::clear_has_source() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void HDF5DataParameter::clear_source() {
- source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_source();
-}
-inline const ::std::string& HDF5DataParameter::source() const {
- // @@protoc_insertion_point(field_get:caffe.HDF5DataParameter.source)
- return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void HDF5DataParameter::set_source(const ::std::string& value) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.HDF5DataParameter.source)
-}
-inline void HDF5DataParameter::set_source(const char* value) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.HDF5DataParameter.source)
-}
-inline void HDF5DataParameter::set_source(const char* value, size_t size) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.HDF5DataParameter.source)
-}
-inline ::std::string* HDF5DataParameter::mutable_source() {
- set_has_source();
- // @@protoc_insertion_point(field_mutable:caffe.HDF5DataParameter.source)
- return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* HDF5DataParameter::release_source() {
- // @@protoc_insertion_point(field_release:caffe.HDF5DataParameter.source)
- clear_has_source();
- return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void HDF5DataParameter::set_allocated_source(::std::string* source) {
- if (source != NULL) {
- set_has_source();
- } else {
- clear_has_source();
- }
- source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source);
- // @@protoc_insertion_point(field_set_allocated:caffe.HDF5DataParameter.source)
-}
-
-// optional uint32 batch_size = 2;
-inline bool HDF5DataParameter::has_batch_size() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void HDF5DataParameter::set_has_batch_size() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void HDF5DataParameter::clear_has_batch_size() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void HDF5DataParameter::clear_batch_size() {
- batch_size_ = 0u;
- clear_has_batch_size();
-}
-inline ::google::protobuf::uint32 HDF5DataParameter::batch_size() const {
- // @@protoc_insertion_point(field_get:caffe.HDF5DataParameter.batch_size)
- return batch_size_;
-}
-inline void HDF5DataParameter::set_batch_size(::google::protobuf::uint32 value) {
- set_has_batch_size();
- batch_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.HDF5DataParameter.batch_size)
-}
-
-// optional bool shuffle = 3 [default = false];
-inline bool HDF5DataParameter::has_shuffle() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void HDF5DataParameter::set_has_shuffle() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void HDF5DataParameter::clear_has_shuffle() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void HDF5DataParameter::clear_shuffle() {
- shuffle_ = false;
- clear_has_shuffle();
-}
-inline bool HDF5DataParameter::shuffle() const {
- // @@protoc_insertion_point(field_get:caffe.HDF5DataParameter.shuffle)
- return shuffle_;
-}
-inline void HDF5DataParameter::set_shuffle(bool value) {
- set_has_shuffle();
- shuffle_ = value;
- // @@protoc_insertion_point(field_set:caffe.HDF5DataParameter.shuffle)
-}
-
-inline const HDF5DataParameter* HDF5DataParameter::internal_default_instance() {
- return &HDF5DataParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// HDF5OutputParameter
-
-// optional string file_name = 1;
-inline bool HDF5OutputParameter::has_file_name() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void HDF5OutputParameter::set_has_file_name() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void HDF5OutputParameter::clear_has_file_name() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void HDF5OutputParameter::clear_file_name() {
- file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_file_name();
-}
-inline const ::std::string& HDF5OutputParameter::file_name() const {
- // @@protoc_insertion_point(field_get:caffe.HDF5OutputParameter.file_name)
- return file_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void HDF5OutputParameter::set_file_name(const ::std::string& value) {
- set_has_file_name();
- file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.HDF5OutputParameter.file_name)
-}
-inline void HDF5OutputParameter::set_file_name(const char* value) {
- set_has_file_name();
- file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.HDF5OutputParameter.file_name)
-}
-inline void HDF5OutputParameter::set_file_name(const char* value, size_t size) {
- set_has_file_name();
- file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.HDF5OutputParameter.file_name)
-}
-inline ::std::string* HDF5OutputParameter::mutable_file_name() {
- set_has_file_name();
- // @@protoc_insertion_point(field_mutable:caffe.HDF5OutputParameter.file_name)
- return file_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* HDF5OutputParameter::release_file_name() {
- // @@protoc_insertion_point(field_release:caffe.HDF5OutputParameter.file_name)
- clear_has_file_name();
- return file_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void HDF5OutputParameter::set_allocated_file_name(::std::string* file_name) {
- if (file_name != NULL) {
- set_has_file_name();
- } else {
- clear_has_file_name();
- }
- file_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), file_name);
- // @@protoc_insertion_point(field_set_allocated:caffe.HDF5OutputParameter.file_name)
-}
-
-inline const HDF5OutputParameter* HDF5OutputParameter::internal_default_instance() {
- return &HDF5OutputParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// HingeLossParameter
-
-// optional .caffe.HingeLossParameter.Norm norm = 1 [default = L1];
-inline bool HingeLossParameter::has_norm() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void HingeLossParameter::set_has_norm() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void HingeLossParameter::clear_has_norm() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void HingeLossParameter::clear_norm() {
- norm_ = 1;
- clear_has_norm();
-}
-inline ::caffe::HingeLossParameter_Norm HingeLossParameter::norm() const {
- // @@protoc_insertion_point(field_get:caffe.HingeLossParameter.norm)
- return static_cast< ::caffe::HingeLossParameter_Norm >(norm_);
-}
-inline void HingeLossParameter::set_norm(::caffe::HingeLossParameter_Norm value) {
- assert(::caffe::HingeLossParameter_Norm_IsValid(value));
- set_has_norm();
- norm_ = value;
- // @@protoc_insertion_point(field_set:caffe.HingeLossParameter.norm)
-}
-
-inline const HingeLossParameter* HingeLossParameter::internal_default_instance() {
- return &HingeLossParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// ImageDataParameter
-
-// optional string source = 1;
-inline bool ImageDataParameter::has_source() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void ImageDataParameter::set_has_source() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void ImageDataParameter::clear_has_source() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void ImageDataParameter::clear_source() {
- source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_source();
-}
-inline const ::std::string& ImageDataParameter::source() const {
- // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.source)
- return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void ImageDataParameter::set_source(const ::std::string& value) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.source)
-}
-inline void ImageDataParameter::set_source(const char* value) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.ImageDataParameter.source)
-}
-inline void ImageDataParameter::set_source(const char* value, size_t size) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.ImageDataParameter.source)
-}
-inline ::std::string* ImageDataParameter::mutable_source() {
- set_has_source();
- // @@protoc_insertion_point(field_mutable:caffe.ImageDataParameter.source)
- return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* ImageDataParameter::release_source() {
- // @@protoc_insertion_point(field_release:caffe.ImageDataParameter.source)
- clear_has_source();
- return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void ImageDataParameter::set_allocated_source(::std::string* source) {
- if (source != NULL) {
- set_has_source();
- } else {
- clear_has_source();
- }
- source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source);
- // @@protoc_insertion_point(field_set_allocated:caffe.ImageDataParameter.source)
-}
-
-// optional uint32 batch_size = 4;
-inline bool ImageDataParameter::has_batch_size() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void ImageDataParameter::set_has_batch_size() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void ImageDataParameter::clear_has_batch_size() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void ImageDataParameter::clear_batch_size() {
- batch_size_ = 0u;
- clear_has_batch_size();
-}
-inline ::google::protobuf::uint32 ImageDataParameter::batch_size() const {
- // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.batch_size)
- return batch_size_;
-}
-inline void ImageDataParameter::set_batch_size(::google::protobuf::uint32 value) {
- set_has_batch_size();
- batch_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.batch_size)
-}
-
-// optional uint32 rand_skip = 7 [default = 0];
-inline bool ImageDataParameter::has_rand_skip() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void ImageDataParameter::set_has_rand_skip() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void ImageDataParameter::clear_has_rand_skip() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void ImageDataParameter::clear_rand_skip() {
- rand_skip_ = 0u;
- clear_has_rand_skip();
-}
-inline ::google::protobuf::uint32 ImageDataParameter::rand_skip() const {
- // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.rand_skip)
- return rand_skip_;
-}
-inline void ImageDataParameter::set_rand_skip(::google::protobuf::uint32 value) {
- set_has_rand_skip();
- rand_skip_ = value;
- // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.rand_skip)
-}
-
-// optional bool shuffle = 8 [default = false];
-inline bool ImageDataParameter::has_shuffle() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void ImageDataParameter::set_has_shuffle() {
- _has_bits_[0] |= 0x00000008u;
-}
-inline void ImageDataParameter::clear_has_shuffle() {
- _has_bits_[0] &= ~0x00000008u;
-}
-inline void ImageDataParameter::clear_shuffle() {
- shuffle_ = false;
- clear_has_shuffle();
-}
-inline bool ImageDataParameter::shuffle() const {
- // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.shuffle)
- return shuffle_;
-}
-inline void ImageDataParameter::set_shuffle(bool value) {
- set_has_shuffle();
- shuffle_ = value;
- // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.shuffle)
-}
-
-// optional uint32 new_height = 9 [default = 0];
-inline bool ImageDataParameter::has_new_height() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-inline void ImageDataParameter::set_has_new_height() {
- _has_bits_[0] |= 0x00000010u;
-}
-inline void ImageDataParameter::clear_has_new_height() {
- _has_bits_[0] &= ~0x00000010u;
-}
-inline void ImageDataParameter::clear_new_height() {
- new_height_ = 0u;
- clear_has_new_height();
-}
-inline ::google::protobuf::uint32 ImageDataParameter::new_height() const {
- // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.new_height)
- return new_height_;
-}
-inline void ImageDataParameter::set_new_height(::google::protobuf::uint32 value) {
- set_has_new_height();
- new_height_ = value;
- // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.new_height)
-}
-
-// optional uint32 new_width = 10 [default = 0];
-inline bool ImageDataParameter::has_new_width() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-inline void ImageDataParameter::set_has_new_width() {
- _has_bits_[0] |= 0x00000020u;
-}
-inline void ImageDataParameter::clear_has_new_width() {
- _has_bits_[0] &= ~0x00000020u;
-}
-inline void ImageDataParameter::clear_new_width() {
- new_width_ = 0u;
- clear_has_new_width();
-}
-inline ::google::protobuf::uint32 ImageDataParameter::new_width() const {
- // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.new_width)
- return new_width_;
-}
-inline void ImageDataParameter::set_new_width(::google::protobuf::uint32 value) {
- set_has_new_width();
- new_width_ = value;
- // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.new_width)
-}
-
-// optional bool is_color = 11 [default = true];
-inline bool ImageDataParameter::has_is_color() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-inline void ImageDataParameter::set_has_is_color() {
- _has_bits_[0] |= 0x00000040u;
-}
-inline void ImageDataParameter::clear_has_is_color() {
- _has_bits_[0] &= ~0x00000040u;
-}
-inline void ImageDataParameter::clear_is_color() {
- is_color_ = true;
- clear_has_is_color();
-}
-inline bool ImageDataParameter::is_color() const {
- // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.is_color)
- return is_color_;
-}
-inline void ImageDataParameter::set_is_color(bool value) {
- set_has_is_color();
- is_color_ = value;
- // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.is_color)
-}
-
-// optional float scale = 2 [default = 1];
-inline bool ImageDataParameter::has_scale() const {
- return (_has_bits_[0] & 0x00000080u) != 0;
-}
-inline void ImageDataParameter::set_has_scale() {
- _has_bits_[0] |= 0x00000080u;
-}
-inline void ImageDataParameter::clear_has_scale() {
- _has_bits_[0] &= ~0x00000080u;
-}
-inline void ImageDataParameter::clear_scale() {
- scale_ = 1;
- clear_has_scale();
-}
-inline float ImageDataParameter::scale() const {
- // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.scale)
- return scale_;
-}
-inline void ImageDataParameter::set_scale(float value) {
- set_has_scale();
- scale_ = value;
- // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.scale)
-}
-
-// optional string mean_file = 3;
-inline bool ImageDataParameter::has_mean_file() const {
- return (_has_bits_[0] & 0x00000100u) != 0;
-}
-inline void ImageDataParameter::set_has_mean_file() {
- _has_bits_[0] |= 0x00000100u;
-}
-inline void ImageDataParameter::clear_has_mean_file() {
- _has_bits_[0] &= ~0x00000100u;
-}
-inline void ImageDataParameter::clear_mean_file() {
- mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_mean_file();
-}
-inline const ::std::string& ImageDataParameter::mean_file() const {
- // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.mean_file)
- return mean_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void ImageDataParameter::set_mean_file(const ::std::string& value) {
- set_has_mean_file();
- mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.mean_file)
-}
-inline void ImageDataParameter::set_mean_file(const char* value) {
- set_has_mean_file();
- mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.ImageDataParameter.mean_file)
-}
-inline void ImageDataParameter::set_mean_file(const char* value, size_t size) {
- set_has_mean_file();
- mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.ImageDataParameter.mean_file)
-}
-inline ::std::string* ImageDataParameter::mutable_mean_file() {
- set_has_mean_file();
- // @@protoc_insertion_point(field_mutable:caffe.ImageDataParameter.mean_file)
- return mean_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* ImageDataParameter::release_mean_file() {
- // @@protoc_insertion_point(field_release:caffe.ImageDataParameter.mean_file)
- clear_has_mean_file();
- return mean_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void ImageDataParameter::set_allocated_mean_file(::std::string* mean_file) {
- if (mean_file != NULL) {
- set_has_mean_file();
- } else {
- clear_has_mean_file();
- }
- mean_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), mean_file);
- // @@protoc_insertion_point(field_set_allocated:caffe.ImageDataParameter.mean_file)
-}
-
-// optional uint32 crop_size = 5 [default = 0];
-inline bool ImageDataParameter::has_crop_size() const {
- return (_has_bits_[0] & 0x00000200u) != 0;
-}
-inline void ImageDataParameter::set_has_crop_size() {
- _has_bits_[0] |= 0x00000200u;
-}
-inline void ImageDataParameter::clear_has_crop_size() {
- _has_bits_[0] &= ~0x00000200u;
-}
-inline void ImageDataParameter::clear_crop_size() {
- crop_size_ = 0u;
- clear_has_crop_size();
-}
-inline ::google::protobuf::uint32 ImageDataParameter::crop_size() const {
- // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.crop_size)
- return crop_size_;
-}
-inline void ImageDataParameter::set_crop_size(::google::protobuf::uint32 value) {
- set_has_crop_size();
- crop_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.crop_size)
-}
-
-// optional bool mirror = 6 [default = false];
-inline bool ImageDataParameter::has_mirror() const {
- return (_has_bits_[0] & 0x00000400u) != 0;
-}
-inline void ImageDataParameter::set_has_mirror() {
- _has_bits_[0] |= 0x00000400u;
-}
-inline void ImageDataParameter::clear_has_mirror() {
- _has_bits_[0] &= ~0x00000400u;
-}
-inline void ImageDataParameter::clear_mirror() {
- mirror_ = false;
- clear_has_mirror();
-}
-inline bool ImageDataParameter::mirror() const {
- // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.mirror)
- return mirror_;
-}
-inline void ImageDataParameter::set_mirror(bool value) {
- set_has_mirror();
- mirror_ = value;
- // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.mirror)
-}
-
-// optional string root_folder = 12 [default = ""];
-inline bool ImageDataParameter::has_root_folder() const {
- return (_has_bits_[0] & 0x00000800u) != 0;
-}
-inline void ImageDataParameter::set_has_root_folder() {
- _has_bits_[0] |= 0x00000800u;
-}
-inline void ImageDataParameter::clear_has_root_folder() {
- _has_bits_[0] &= ~0x00000800u;
-}
-inline void ImageDataParameter::clear_root_folder() {
- root_folder_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_root_folder();
-}
-inline const ::std::string& ImageDataParameter::root_folder() const {
- // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.root_folder)
- return root_folder_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void ImageDataParameter::set_root_folder(const ::std::string& value) {
- set_has_root_folder();
- root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.root_folder)
-}
-inline void ImageDataParameter::set_root_folder(const char* value) {
- set_has_root_folder();
- root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.ImageDataParameter.root_folder)
-}
-inline void ImageDataParameter::set_root_folder(const char* value, size_t size) {
- set_has_root_folder();
- root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.ImageDataParameter.root_folder)
-}
-inline ::std::string* ImageDataParameter::mutable_root_folder() {
- set_has_root_folder();
- // @@protoc_insertion_point(field_mutable:caffe.ImageDataParameter.root_folder)
- return root_folder_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* ImageDataParameter::release_root_folder() {
- // @@protoc_insertion_point(field_release:caffe.ImageDataParameter.root_folder)
- clear_has_root_folder();
- return root_folder_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void ImageDataParameter::set_allocated_root_folder(::std::string* root_folder) {
- if (root_folder != NULL) {
- set_has_root_folder();
- } else {
- clear_has_root_folder();
- }
- root_folder_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), root_folder);
- // @@protoc_insertion_point(field_set_allocated:caffe.ImageDataParameter.root_folder)
-}
-
-inline const ImageDataParameter* ImageDataParameter::internal_default_instance() {
- return &ImageDataParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// InfogainLossParameter
-
-// optional string source = 1;
-inline bool InfogainLossParameter::has_source() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void InfogainLossParameter::set_has_source() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void InfogainLossParameter::clear_has_source() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void InfogainLossParameter::clear_source() {
- source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_source();
-}
-inline const ::std::string& InfogainLossParameter::source() const {
- // @@protoc_insertion_point(field_get:caffe.InfogainLossParameter.source)
- return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void InfogainLossParameter::set_source(const ::std::string& value) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.InfogainLossParameter.source)
-}
-inline void InfogainLossParameter::set_source(const char* value) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.InfogainLossParameter.source)
-}
-inline void InfogainLossParameter::set_source(const char* value, size_t size) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.InfogainLossParameter.source)
-}
-inline ::std::string* InfogainLossParameter::mutable_source() {
- set_has_source();
- // @@protoc_insertion_point(field_mutable:caffe.InfogainLossParameter.source)
- return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* InfogainLossParameter::release_source() {
- // @@protoc_insertion_point(field_release:caffe.InfogainLossParameter.source)
- clear_has_source();
- return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void InfogainLossParameter::set_allocated_source(::std::string* source) {
- if (source != NULL) {
- set_has_source();
- } else {
- clear_has_source();
- }
- source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source);
- // @@protoc_insertion_point(field_set_allocated:caffe.InfogainLossParameter.source)
-}
-
-inline const InfogainLossParameter* InfogainLossParameter::internal_default_instance() {
- return &InfogainLossParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// InnerProductParameter
-
-// optional uint32 num_output = 1;
-inline bool InnerProductParameter::has_num_output() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void InnerProductParameter::set_has_num_output() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void InnerProductParameter::clear_has_num_output() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void InnerProductParameter::clear_num_output() {
- num_output_ = 0u;
- clear_has_num_output();
-}
-inline ::google::protobuf::uint32 InnerProductParameter::num_output() const {
- // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.num_output)
- return num_output_;
-}
-inline void InnerProductParameter::set_num_output(::google::protobuf::uint32 value) {
- set_has_num_output();
- num_output_ = value;
- // @@protoc_insertion_point(field_set:caffe.InnerProductParameter.num_output)
-}
-
-// optional bool bias_term = 2 [default = true];
-inline bool InnerProductParameter::has_bias_term() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void InnerProductParameter::set_has_bias_term() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void InnerProductParameter::clear_has_bias_term() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void InnerProductParameter::clear_bias_term() {
- bias_term_ = true;
- clear_has_bias_term();
-}
-inline bool InnerProductParameter::bias_term() const {
- // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.bias_term)
- return bias_term_;
-}
-inline void InnerProductParameter::set_bias_term(bool value) {
- set_has_bias_term();
- bias_term_ = value;
- // @@protoc_insertion_point(field_set:caffe.InnerProductParameter.bias_term)
-}
-
-// optional .caffe.FillerParameter weight_filler = 3;
-inline bool InnerProductParameter::has_weight_filler() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void InnerProductParameter::set_has_weight_filler() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void InnerProductParameter::clear_has_weight_filler() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void InnerProductParameter::clear_weight_filler() {
- if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear();
- clear_has_weight_filler();
-}
-inline const ::caffe::FillerParameter& InnerProductParameter::weight_filler() const {
- // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.weight_filler)
- return weight_filler_ != NULL ? *weight_filler_
- : *::caffe::FillerParameter::internal_default_instance();
-}
-inline ::caffe::FillerParameter* InnerProductParameter::mutable_weight_filler() {
- set_has_weight_filler();
- if (weight_filler_ == NULL) {
- weight_filler_ = new ::caffe::FillerParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.InnerProductParameter.weight_filler)
- return weight_filler_;
-}
-inline ::caffe::FillerParameter* InnerProductParameter::release_weight_filler() {
- // @@protoc_insertion_point(field_release:caffe.InnerProductParameter.weight_filler)
- clear_has_weight_filler();
- ::caffe::FillerParameter* temp = weight_filler_;
- weight_filler_ = NULL;
- return temp;
-}
-inline void InnerProductParameter::set_allocated_weight_filler(::caffe::FillerParameter* weight_filler) {
- delete weight_filler_;
- weight_filler_ = weight_filler;
- if (weight_filler) {
- set_has_weight_filler();
- } else {
- clear_has_weight_filler();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.InnerProductParameter.weight_filler)
-}
-
-// optional .caffe.FillerParameter bias_filler = 4;
-inline bool InnerProductParameter::has_bias_filler() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void InnerProductParameter::set_has_bias_filler() {
- _has_bits_[0] |= 0x00000008u;
-}
-inline void InnerProductParameter::clear_has_bias_filler() {
- _has_bits_[0] &= ~0x00000008u;
-}
-inline void InnerProductParameter::clear_bias_filler() {
- if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
- clear_has_bias_filler();
-}
-inline const ::caffe::FillerParameter& InnerProductParameter::bias_filler() const {
- // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.bias_filler)
- return bias_filler_ != NULL ? *bias_filler_
- : *::caffe::FillerParameter::internal_default_instance();
-}
-inline ::caffe::FillerParameter* InnerProductParameter::mutable_bias_filler() {
- set_has_bias_filler();
- if (bias_filler_ == NULL) {
- bias_filler_ = new ::caffe::FillerParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.InnerProductParameter.bias_filler)
- return bias_filler_;
-}
-inline ::caffe::FillerParameter* InnerProductParameter::release_bias_filler() {
- // @@protoc_insertion_point(field_release:caffe.InnerProductParameter.bias_filler)
- clear_has_bias_filler();
- ::caffe::FillerParameter* temp = bias_filler_;
- bias_filler_ = NULL;
- return temp;
-}
-inline void InnerProductParameter::set_allocated_bias_filler(::caffe::FillerParameter* bias_filler) {
- delete bias_filler_;
- bias_filler_ = bias_filler;
- if (bias_filler) {
- set_has_bias_filler();
- } else {
- clear_has_bias_filler();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.InnerProductParameter.bias_filler)
-}
-
-// optional int32 axis = 5 [default = 1];
-inline bool InnerProductParameter::has_axis() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-inline void InnerProductParameter::set_has_axis() {
- _has_bits_[0] |= 0x00000010u;
-}
-inline void InnerProductParameter::clear_has_axis() {
- _has_bits_[0] &= ~0x00000010u;
-}
-inline void InnerProductParameter::clear_axis() {
- axis_ = 1;
- clear_has_axis();
-}
-inline ::google::protobuf::int32 InnerProductParameter::axis() const {
- // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.axis)
- return axis_;
-}
-inline void InnerProductParameter::set_axis(::google::protobuf::int32 value) {
- set_has_axis();
- axis_ = value;
- // @@protoc_insertion_point(field_set:caffe.InnerProductParameter.axis)
-}
-
-inline const InnerProductParameter* InnerProductParameter::internal_default_instance() {
- return &InnerProductParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// LogParameter
-
-// optional float base = 1 [default = -1];
-inline bool LogParameter::has_base() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void LogParameter::set_has_base() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void LogParameter::clear_has_base() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void LogParameter::clear_base() {
- base_ = -1;
- clear_has_base();
-}
-inline float LogParameter::base() const {
- // @@protoc_insertion_point(field_get:caffe.LogParameter.base)
- return base_;
-}
-inline void LogParameter::set_base(float value) {
- set_has_base();
- base_ = value;
- // @@protoc_insertion_point(field_set:caffe.LogParameter.base)
-}
-
-// optional float scale = 2 [default = 1];
-inline bool LogParameter::has_scale() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void LogParameter::set_has_scale() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void LogParameter::clear_has_scale() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void LogParameter::clear_scale() {
- scale_ = 1;
- clear_has_scale();
-}
-inline float LogParameter::scale() const {
- // @@protoc_insertion_point(field_get:caffe.LogParameter.scale)
- return scale_;
-}
-inline void LogParameter::set_scale(float value) {
- set_has_scale();
- scale_ = value;
- // @@protoc_insertion_point(field_set:caffe.LogParameter.scale)
-}
-
-// optional float shift = 3 [default = 0];
-inline bool LogParameter::has_shift() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void LogParameter::set_has_shift() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void LogParameter::clear_has_shift() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void LogParameter::clear_shift() {
- shift_ = 0;
- clear_has_shift();
-}
-inline float LogParameter::shift() const {
- // @@protoc_insertion_point(field_get:caffe.LogParameter.shift)
- return shift_;
-}
-inline void LogParameter::set_shift(float value) {
- set_has_shift();
- shift_ = value;
- // @@protoc_insertion_point(field_set:caffe.LogParameter.shift)
-}
-
-inline const LogParameter* LogParameter::internal_default_instance() {
- return &LogParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// LRNParameter
-
-// optional uint32 local_size = 1 [default = 5];
-inline bool LRNParameter::has_local_size() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void LRNParameter::set_has_local_size() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void LRNParameter::clear_has_local_size() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void LRNParameter::clear_local_size() {
- local_size_ = 5u;
- clear_has_local_size();
-}
-inline ::google::protobuf::uint32 LRNParameter::local_size() const {
- // @@protoc_insertion_point(field_get:caffe.LRNParameter.local_size)
- return local_size_;
-}
-inline void LRNParameter::set_local_size(::google::protobuf::uint32 value) {
- set_has_local_size();
- local_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.LRNParameter.local_size)
-}
-
-// optional float alpha = 2 [default = 1];
-inline bool LRNParameter::has_alpha() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void LRNParameter::set_has_alpha() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void LRNParameter::clear_has_alpha() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void LRNParameter::clear_alpha() {
- alpha_ = 1;
- clear_has_alpha();
-}
-inline float LRNParameter::alpha() const {
- // @@protoc_insertion_point(field_get:caffe.LRNParameter.alpha)
- return alpha_;
-}
-inline void LRNParameter::set_alpha(float value) {
- set_has_alpha();
- alpha_ = value;
- // @@protoc_insertion_point(field_set:caffe.LRNParameter.alpha)
-}
-
-// optional float beta = 3 [default = 0.75];
-inline bool LRNParameter::has_beta() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void LRNParameter::set_has_beta() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void LRNParameter::clear_has_beta() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void LRNParameter::clear_beta() {
- beta_ = 0.75f;
- clear_has_beta();
-}
-inline float LRNParameter::beta() const {
- // @@protoc_insertion_point(field_get:caffe.LRNParameter.beta)
- return beta_;
-}
-inline void LRNParameter::set_beta(float value) {
- set_has_beta();
- beta_ = value;
- // @@protoc_insertion_point(field_set:caffe.LRNParameter.beta)
-}
-
-// optional .caffe.LRNParameter.NormRegion norm_region = 4 [default = ACROSS_CHANNELS];
-inline bool LRNParameter::has_norm_region() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void LRNParameter::set_has_norm_region() {
- _has_bits_[0] |= 0x00000008u;
-}
-inline void LRNParameter::clear_has_norm_region() {
- _has_bits_[0] &= ~0x00000008u;
-}
-inline void LRNParameter::clear_norm_region() {
- norm_region_ = 0;
- clear_has_norm_region();
-}
-inline ::caffe::LRNParameter_NormRegion LRNParameter::norm_region() const {
- // @@protoc_insertion_point(field_get:caffe.LRNParameter.norm_region)
- return static_cast< ::caffe::LRNParameter_NormRegion >(norm_region_);
-}
-inline void LRNParameter::set_norm_region(::caffe::LRNParameter_NormRegion value) {
- assert(::caffe::LRNParameter_NormRegion_IsValid(value));
- set_has_norm_region();
- norm_region_ = value;
- // @@protoc_insertion_point(field_set:caffe.LRNParameter.norm_region)
-}
-
-// optional float k = 5 [default = 1];
-inline bool LRNParameter::has_k() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-inline void LRNParameter::set_has_k() {
- _has_bits_[0] |= 0x00000010u;
-}
-inline void LRNParameter::clear_has_k() {
- _has_bits_[0] &= ~0x00000010u;
-}
-inline void LRNParameter::clear_k() {
- k_ = 1;
- clear_has_k();
-}
-inline float LRNParameter::k() const {
- // @@protoc_insertion_point(field_get:caffe.LRNParameter.k)
- return k_;
-}
-inline void LRNParameter::set_k(float value) {
- set_has_k();
- k_ = value;
- // @@protoc_insertion_point(field_set:caffe.LRNParameter.k)
-}
-
-inline const LRNParameter* LRNParameter::internal_default_instance() {
- return &LRNParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// MemoryDataParameter
-
-// optional uint32 batch_size = 1;
-inline bool MemoryDataParameter::has_batch_size() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void MemoryDataParameter::set_has_batch_size() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void MemoryDataParameter::clear_has_batch_size() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void MemoryDataParameter::clear_batch_size() {
- batch_size_ = 0u;
- clear_has_batch_size();
-}
-inline ::google::protobuf::uint32 MemoryDataParameter::batch_size() const {
- // @@protoc_insertion_point(field_get:caffe.MemoryDataParameter.batch_size)
- return batch_size_;
-}
-inline void MemoryDataParameter::set_batch_size(::google::protobuf::uint32 value) {
- set_has_batch_size();
- batch_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.MemoryDataParameter.batch_size)
-}
-
-// optional uint32 channels = 2;
-inline bool MemoryDataParameter::has_channels() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void MemoryDataParameter::set_has_channels() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void MemoryDataParameter::clear_has_channels() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void MemoryDataParameter::clear_channels() {
- channels_ = 0u;
- clear_has_channels();
-}
-inline ::google::protobuf::uint32 MemoryDataParameter::channels() const {
- // @@protoc_insertion_point(field_get:caffe.MemoryDataParameter.channels)
- return channels_;
-}
-inline void MemoryDataParameter::set_channels(::google::protobuf::uint32 value) {
- set_has_channels();
- channels_ = value;
- // @@protoc_insertion_point(field_set:caffe.MemoryDataParameter.channels)
-}
-
-// optional uint32 height = 3;
-inline bool MemoryDataParameter::has_height() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void MemoryDataParameter::set_has_height() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void MemoryDataParameter::clear_has_height() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void MemoryDataParameter::clear_height() {
- height_ = 0u;
- clear_has_height();
-}
-inline ::google::protobuf::uint32 MemoryDataParameter::height() const {
- // @@protoc_insertion_point(field_get:caffe.MemoryDataParameter.height)
- return height_;
-}
-inline void MemoryDataParameter::set_height(::google::protobuf::uint32 value) {
- set_has_height();
- height_ = value;
- // @@protoc_insertion_point(field_set:caffe.MemoryDataParameter.height)
-}
-
-// optional uint32 width = 4;
-inline bool MemoryDataParameter::has_width() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void MemoryDataParameter::set_has_width() {
- _has_bits_[0] |= 0x00000008u;
-}
-inline void MemoryDataParameter::clear_has_width() {
- _has_bits_[0] &= ~0x00000008u;
-}
-inline void MemoryDataParameter::clear_width() {
- width_ = 0u;
- clear_has_width();
-}
-inline ::google::protobuf::uint32 MemoryDataParameter::width() const {
- // @@protoc_insertion_point(field_get:caffe.MemoryDataParameter.width)
- return width_;
-}
-inline void MemoryDataParameter::set_width(::google::protobuf::uint32 value) {
- set_has_width();
- width_ = value;
- // @@protoc_insertion_point(field_set:caffe.MemoryDataParameter.width)
-}
-
-inline const MemoryDataParameter* MemoryDataParameter::internal_default_instance() {
- return &MemoryDataParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// MVNParameter
-
-// optional bool normalize_variance = 1 [default = true];
-inline bool MVNParameter::has_normalize_variance() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void MVNParameter::set_has_normalize_variance() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void MVNParameter::clear_has_normalize_variance() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void MVNParameter::clear_normalize_variance() {
- normalize_variance_ = true;
- clear_has_normalize_variance();
-}
-inline bool MVNParameter::normalize_variance() const {
- // @@protoc_insertion_point(field_get:caffe.MVNParameter.normalize_variance)
- return normalize_variance_;
-}
-inline void MVNParameter::set_normalize_variance(bool value) {
- set_has_normalize_variance();
- normalize_variance_ = value;
- // @@protoc_insertion_point(field_set:caffe.MVNParameter.normalize_variance)
-}
-
-// optional bool across_channels = 2 [default = false];
-inline bool MVNParameter::has_across_channels() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void MVNParameter::set_has_across_channels() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void MVNParameter::clear_has_across_channels() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void MVNParameter::clear_across_channels() {
- across_channels_ = false;
- clear_has_across_channels();
-}
-inline bool MVNParameter::across_channels() const {
- // @@protoc_insertion_point(field_get:caffe.MVNParameter.across_channels)
- return across_channels_;
-}
-inline void MVNParameter::set_across_channels(bool value) {
- set_has_across_channels();
- across_channels_ = value;
- // @@protoc_insertion_point(field_set:caffe.MVNParameter.across_channels)
-}
-
-// optional float eps = 3 [default = 1e-09];
-inline bool MVNParameter::has_eps() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void MVNParameter::set_has_eps() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void MVNParameter::clear_has_eps() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void MVNParameter::clear_eps() {
- eps_ = 1e-09f;
- clear_has_eps();
-}
-inline float MVNParameter::eps() const {
- // @@protoc_insertion_point(field_get:caffe.MVNParameter.eps)
- return eps_;
-}
-inline void MVNParameter::set_eps(float value) {
- set_has_eps();
- eps_ = value;
- // @@protoc_insertion_point(field_set:caffe.MVNParameter.eps)
-}
-
-inline const MVNParameter* MVNParameter::internal_default_instance() {
- return &MVNParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// PoolingParameter
-
-// optional .caffe.PoolingParameter.PoolMethod pool = 1 [default = MAX];
-inline bool PoolingParameter::has_pool() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void PoolingParameter::set_has_pool() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void PoolingParameter::clear_has_pool() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void PoolingParameter::clear_pool() {
- pool_ = 0;
- clear_has_pool();
-}
-inline ::caffe::PoolingParameter_PoolMethod PoolingParameter::pool() const {
- // @@protoc_insertion_point(field_get:caffe.PoolingParameter.pool)
- return static_cast< ::caffe::PoolingParameter_PoolMethod >(pool_);
-}
-inline void PoolingParameter::set_pool(::caffe::PoolingParameter_PoolMethod value) {
- assert(::caffe::PoolingParameter_PoolMethod_IsValid(value));
- set_has_pool();
- pool_ = value;
- // @@protoc_insertion_point(field_set:caffe.PoolingParameter.pool)
-}
-
-// optional uint32 pad = 4 [default = 0];
-inline bool PoolingParameter::has_pad() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void PoolingParameter::set_has_pad() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void PoolingParameter::clear_has_pad() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void PoolingParameter::clear_pad() {
- pad_ = 0u;
- clear_has_pad();
-}
-inline ::google::protobuf::uint32 PoolingParameter::pad() const {
- // @@protoc_insertion_point(field_get:caffe.PoolingParameter.pad)
- return pad_;
-}
-inline void PoolingParameter::set_pad(::google::protobuf::uint32 value) {
- set_has_pad();
- pad_ = value;
- // @@protoc_insertion_point(field_set:caffe.PoolingParameter.pad)
-}
-
-// optional uint32 pad_h = 9 [default = 0];
-inline bool PoolingParameter::has_pad_h() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void PoolingParameter::set_has_pad_h() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void PoolingParameter::clear_has_pad_h() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void PoolingParameter::clear_pad_h() {
- pad_h_ = 0u;
- clear_has_pad_h();
-}
-inline ::google::protobuf::uint32 PoolingParameter::pad_h() const {
- // @@protoc_insertion_point(field_get:caffe.PoolingParameter.pad_h)
- return pad_h_;
-}
-inline void PoolingParameter::set_pad_h(::google::protobuf::uint32 value) {
- set_has_pad_h();
- pad_h_ = value;
- // @@protoc_insertion_point(field_set:caffe.PoolingParameter.pad_h)
-}
-
-// optional uint32 pad_w = 10 [default = 0];
-inline bool PoolingParameter::has_pad_w() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void PoolingParameter::set_has_pad_w() {
- _has_bits_[0] |= 0x00000008u;
-}
-inline void PoolingParameter::clear_has_pad_w() {
- _has_bits_[0] &= ~0x00000008u;
-}
-inline void PoolingParameter::clear_pad_w() {
- pad_w_ = 0u;
- clear_has_pad_w();
-}
-inline ::google::protobuf::uint32 PoolingParameter::pad_w() const {
- // @@protoc_insertion_point(field_get:caffe.PoolingParameter.pad_w)
- return pad_w_;
-}
-inline void PoolingParameter::set_pad_w(::google::protobuf::uint32 value) {
- set_has_pad_w();
- pad_w_ = value;
- // @@protoc_insertion_point(field_set:caffe.PoolingParameter.pad_w)
-}
-
-// optional uint32 kernel_size = 2;
-inline bool PoolingParameter::has_kernel_size() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-inline void PoolingParameter::set_has_kernel_size() {
- _has_bits_[0] |= 0x00000010u;
-}
-inline void PoolingParameter::clear_has_kernel_size() {
- _has_bits_[0] &= ~0x00000010u;
-}
-inline void PoolingParameter::clear_kernel_size() {
- kernel_size_ = 0u;
- clear_has_kernel_size();
-}
-inline ::google::protobuf::uint32 PoolingParameter::kernel_size() const {
- // @@protoc_insertion_point(field_get:caffe.PoolingParameter.kernel_size)
- return kernel_size_;
-}
-inline void PoolingParameter::set_kernel_size(::google::protobuf::uint32 value) {
- set_has_kernel_size();
- kernel_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.PoolingParameter.kernel_size)
-}
-
-// optional uint32 kernel_h = 5;
-inline bool PoolingParameter::has_kernel_h() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-inline void PoolingParameter::set_has_kernel_h() {
- _has_bits_[0] |= 0x00000020u;
-}
-inline void PoolingParameter::clear_has_kernel_h() {
- _has_bits_[0] &= ~0x00000020u;
-}
-inline void PoolingParameter::clear_kernel_h() {
- kernel_h_ = 0u;
- clear_has_kernel_h();
-}
-inline ::google::protobuf::uint32 PoolingParameter::kernel_h() const {
- // @@protoc_insertion_point(field_get:caffe.PoolingParameter.kernel_h)
- return kernel_h_;
-}
-inline void PoolingParameter::set_kernel_h(::google::protobuf::uint32 value) {
- set_has_kernel_h();
- kernel_h_ = value;
- // @@protoc_insertion_point(field_set:caffe.PoolingParameter.kernel_h)
-}
-
-// optional uint32 kernel_w = 6;
-inline bool PoolingParameter::has_kernel_w() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-inline void PoolingParameter::set_has_kernel_w() {
- _has_bits_[0] |= 0x00000040u;
-}
-inline void PoolingParameter::clear_has_kernel_w() {
- _has_bits_[0] &= ~0x00000040u;
-}
-inline void PoolingParameter::clear_kernel_w() {
- kernel_w_ = 0u;
- clear_has_kernel_w();
-}
-inline ::google::protobuf::uint32 PoolingParameter::kernel_w() const {
- // @@protoc_insertion_point(field_get:caffe.PoolingParameter.kernel_w)
- return kernel_w_;
-}
-inline void PoolingParameter::set_kernel_w(::google::protobuf::uint32 value) {
- set_has_kernel_w();
- kernel_w_ = value;
- // @@protoc_insertion_point(field_set:caffe.PoolingParameter.kernel_w)
-}
-
-// optional uint32 stride = 3 [default = 1];
-inline bool PoolingParameter::has_stride() const {
- return (_has_bits_[0] & 0x00000080u) != 0;
-}
-inline void PoolingParameter::set_has_stride() {
- _has_bits_[0] |= 0x00000080u;
-}
-inline void PoolingParameter::clear_has_stride() {
- _has_bits_[0] &= ~0x00000080u;
-}
-inline void PoolingParameter::clear_stride() {
- stride_ = 1u;
- clear_has_stride();
-}
-inline ::google::protobuf::uint32 PoolingParameter::stride() const {
- // @@protoc_insertion_point(field_get:caffe.PoolingParameter.stride)
- return stride_;
-}
-inline void PoolingParameter::set_stride(::google::protobuf::uint32 value) {
- set_has_stride();
- stride_ = value;
- // @@protoc_insertion_point(field_set:caffe.PoolingParameter.stride)
-}
-
-// optional uint32 stride_h = 7;
-inline bool PoolingParameter::has_stride_h() const {
- return (_has_bits_[0] & 0x00000100u) != 0;
-}
-inline void PoolingParameter::set_has_stride_h() {
- _has_bits_[0] |= 0x00000100u;
-}
-inline void PoolingParameter::clear_has_stride_h() {
- _has_bits_[0] &= ~0x00000100u;
-}
-inline void PoolingParameter::clear_stride_h() {
- stride_h_ = 0u;
- clear_has_stride_h();
-}
-inline ::google::protobuf::uint32 PoolingParameter::stride_h() const {
- // @@protoc_insertion_point(field_get:caffe.PoolingParameter.stride_h)
- return stride_h_;
-}
-inline void PoolingParameter::set_stride_h(::google::protobuf::uint32 value) {
- set_has_stride_h();
- stride_h_ = value;
- // @@protoc_insertion_point(field_set:caffe.PoolingParameter.stride_h)
-}
-
-// optional uint32 stride_w = 8;
-inline bool PoolingParameter::has_stride_w() const {
- return (_has_bits_[0] & 0x00000200u) != 0;
-}
-inline void PoolingParameter::set_has_stride_w() {
- _has_bits_[0] |= 0x00000200u;
-}
-inline void PoolingParameter::clear_has_stride_w() {
- _has_bits_[0] &= ~0x00000200u;
-}
-inline void PoolingParameter::clear_stride_w() {
- stride_w_ = 0u;
- clear_has_stride_w();
-}
-inline ::google::protobuf::uint32 PoolingParameter::stride_w() const {
- // @@protoc_insertion_point(field_get:caffe.PoolingParameter.stride_w)
- return stride_w_;
-}
-inline void PoolingParameter::set_stride_w(::google::protobuf::uint32 value) {
- set_has_stride_w();
- stride_w_ = value;
- // @@protoc_insertion_point(field_set:caffe.PoolingParameter.stride_w)
-}
-
-// optional .caffe.PoolingParameter.Engine engine = 11 [default = DEFAULT];
-inline bool PoolingParameter::has_engine() const {
- return (_has_bits_[0] & 0x00000400u) != 0;
-}
-inline void PoolingParameter::set_has_engine() {
- _has_bits_[0] |= 0x00000400u;
-}
-inline void PoolingParameter::clear_has_engine() {
- _has_bits_[0] &= ~0x00000400u;
-}
-inline void PoolingParameter::clear_engine() {
- engine_ = 0;
- clear_has_engine();
-}
-inline ::caffe::PoolingParameter_Engine PoolingParameter::engine() const {
- // @@protoc_insertion_point(field_get:caffe.PoolingParameter.engine)
- return static_cast< ::caffe::PoolingParameter_Engine >(engine_);
-}
-inline void PoolingParameter::set_engine(::caffe::PoolingParameter_Engine value) {
- assert(::caffe::PoolingParameter_Engine_IsValid(value));
- set_has_engine();
- engine_ = value;
- // @@protoc_insertion_point(field_set:caffe.PoolingParameter.engine)
-}
-
-// optional bool global_pooling = 12 [default = false];
-inline bool PoolingParameter::has_global_pooling() const {
- return (_has_bits_[0] & 0x00000800u) != 0;
-}
-inline void PoolingParameter::set_has_global_pooling() {
- _has_bits_[0] |= 0x00000800u;
-}
-inline void PoolingParameter::clear_has_global_pooling() {
- _has_bits_[0] &= ~0x00000800u;
-}
-inline void PoolingParameter::clear_global_pooling() {
- global_pooling_ = false;
- clear_has_global_pooling();
-}
-inline bool PoolingParameter::global_pooling() const {
- // @@protoc_insertion_point(field_get:caffe.PoolingParameter.global_pooling)
- return global_pooling_;
-}
-inline void PoolingParameter::set_global_pooling(bool value) {
- set_has_global_pooling();
- global_pooling_ = value;
- // @@protoc_insertion_point(field_set:caffe.PoolingParameter.global_pooling)
-}
-
-inline const PoolingParameter* PoolingParameter::internal_default_instance() {
- return &PoolingParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// PowerParameter
-
-// optional float power = 1 [default = 1];
-inline bool PowerParameter::has_power() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void PowerParameter::set_has_power() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void PowerParameter::clear_has_power() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void PowerParameter::clear_power() {
- power_ = 1;
- clear_has_power();
-}
-inline float PowerParameter::power() const {
- // @@protoc_insertion_point(field_get:caffe.PowerParameter.power)
- return power_;
-}
-inline void PowerParameter::set_power(float value) {
- set_has_power();
- power_ = value;
- // @@protoc_insertion_point(field_set:caffe.PowerParameter.power)
-}
-
-// optional float scale = 2 [default = 1];
-inline bool PowerParameter::has_scale() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void PowerParameter::set_has_scale() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void PowerParameter::clear_has_scale() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void PowerParameter::clear_scale() {
- scale_ = 1;
- clear_has_scale();
-}
-inline float PowerParameter::scale() const {
- // @@protoc_insertion_point(field_get:caffe.PowerParameter.scale)
- return scale_;
-}
-inline void PowerParameter::set_scale(float value) {
- set_has_scale();
- scale_ = value;
- // @@protoc_insertion_point(field_set:caffe.PowerParameter.scale)
-}
-
-// optional float shift = 3 [default = 0];
-inline bool PowerParameter::has_shift() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void PowerParameter::set_has_shift() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void PowerParameter::clear_has_shift() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void PowerParameter::clear_shift() {
- shift_ = 0;
- clear_has_shift();
-}
-inline float PowerParameter::shift() const {
- // @@protoc_insertion_point(field_get:caffe.PowerParameter.shift)
- return shift_;
-}
-inline void PowerParameter::set_shift(float value) {
- set_has_shift();
- shift_ = value;
- // @@protoc_insertion_point(field_set:caffe.PowerParameter.shift)
-}
-
-inline const PowerParameter* PowerParameter::internal_default_instance() {
- return &PowerParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// PythonParameter
-
-// optional string module = 1;
-inline bool PythonParameter::has_module() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void PythonParameter::set_has_module() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void PythonParameter::clear_has_module() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void PythonParameter::clear_module() {
- module_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_module();
-}
-inline const ::std::string& PythonParameter::module() const {
- // @@protoc_insertion_point(field_get:caffe.PythonParameter.module)
- return module_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void PythonParameter::set_module(const ::std::string& value) {
- set_has_module();
- module_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.PythonParameter.module)
-}
-inline void PythonParameter::set_module(const char* value) {
- set_has_module();
- module_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.PythonParameter.module)
-}
-inline void PythonParameter::set_module(const char* value, size_t size) {
- set_has_module();
- module_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.PythonParameter.module)
-}
-inline ::std::string* PythonParameter::mutable_module() {
- set_has_module();
- // @@protoc_insertion_point(field_mutable:caffe.PythonParameter.module)
- return module_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* PythonParameter::release_module() {
- // @@protoc_insertion_point(field_release:caffe.PythonParameter.module)
- clear_has_module();
- return module_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void PythonParameter::set_allocated_module(::std::string* module) {
- if (module != NULL) {
- set_has_module();
- } else {
- clear_has_module();
- }
- module_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), module);
- // @@protoc_insertion_point(field_set_allocated:caffe.PythonParameter.module)
-}
-
-// optional string layer = 2;
-inline bool PythonParameter::has_layer() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void PythonParameter::set_has_layer() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void PythonParameter::clear_has_layer() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void PythonParameter::clear_layer() {
- layer_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_layer();
-}
-inline const ::std::string& PythonParameter::layer() const {
- // @@protoc_insertion_point(field_get:caffe.PythonParameter.layer)
- return layer_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void PythonParameter::set_layer(const ::std::string& value) {
- set_has_layer();
- layer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.PythonParameter.layer)
-}
-inline void PythonParameter::set_layer(const char* value) {
- set_has_layer();
- layer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.PythonParameter.layer)
-}
-inline void PythonParameter::set_layer(const char* value, size_t size) {
- set_has_layer();
- layer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.PythonParameter.layer)
-}
-inline ::std::string* PythonParameter::mutable_layer() {
- set_has_layer();
- // @@protoc_insertion_point(field_mutable:caffe.PythonParameter.layer)
- return layer_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* PythonParameter::release_layer() {
- // @@protoc_insertion_point(field_release:caffe.PythonParameter.layer)
- clear_has_layer();
- return layer_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void PythonParameter::set_allocated_layer(::std::string* layer) {
- if (layer != NULL) {
- set_has_layer();
- } else {
- clear_has_layer();
- }
- layer_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), layer);
- // @@protoc_insertion_point(field_set_allocated:caffe.PythonParameter.layer)
-}
-
-inline const PythonParameter* PythonParameter::internal_default_instance() {
- return &PythonParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// ReductionParameter
-
-// optional .caffe.ReductionParameter.ReductionOp operation = 1 [default = SUM];
-inline bool ReductionParameter::has_operation() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void ReductionParameter::set_has_operation() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void ReductionParameter::clear_has_operation() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void ReductionParameter::clear_operation() {
- operation_ = 1;
- clear_has_operation();
-}
-inline ::caffe::ReductionParameter_ReductionOp ReductionParameter::operation() const {
- // @@protoc_insertion_point(field_get:caffe.ReductionParameter.operation)
- return static_cast< ::caffe::ReductionParameter_ReductionOp >(operation_);
-}
-inline void ReductionParameter::set_operation(::caffe::ReductionParameter_ReductionOp value) {
- assert(::caffe::ReductionParameter_ReductionOp_IsValid(value));
- set_has_operation();
- operation_ = value;
- // @@protoc_insertion_point(field_set:caffe.ReductionParameter.operation)
-}
-
-// optional int32 axis = 2 [default = 0];
-inline bool ReductionParameter::has_axis() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void ReductionParameter::set_has_axis() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void ReductionParameter::clear_has_axis() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void ReductionParameter::clear_axis() {
- axis_ = 0;
- clear_has_axis();
-}
-inline ::google::protobuf::int32 ReductionParameter::axis() const {
- // @@protoc_insertion_point(field_get:caffe.ReductionParameter.axis)
- return axis_;
-}
-inline void ReductionParameter::set_axis(::google::protobuf::int32 value) {
- set_has_axis();
- axis_ = value;
- // @@protoc_insertion_point(field_set:caffe.ReductionParameter.axis)
-}
-
-// optional float coeff = 3 [default = 1];
-inline bool ReductionParameter::has_coeff() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void ReductionParameter::set_has_coeff() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void ReductionParameter::clear_has_coeff() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void ReductionParameter::clear_coeff() {
- coeff_ = 1;
- clear_has_coeff();
-}
-inline float ReductionParameter::coeff() const {
- // @@protoc_insertion_point(field_get:caffe.ReductionParameter.coeff)
- return coeff_;
-}
-inline void ReductionParameter::set_coeff(float value) {
- set_has_coeff();
- coeff_ = value;
- // @@protoc_insertion_point(field_set:caffe.ReductionParameter.coeff)
-}
-
-inline const ReductionParameter* ReductionParameter::internal_default_instance() {
- return &ReductionParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// ReLUParameter
-
-// optional float negative_slope = 1 [default = 0];
-inline bool ReLUParameter::has_negative_slope() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void ReLUParameter::set_has_negative_slope() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void ReLUParameter::clear_has_negative_slope() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void ReLUParameter::clear_negative_slope() {
- negative_slope_ = 0;
- clear_has_negative_slope();
-}
-inline float ReLUParameter::negative_slope() const {
- // @@protoc_insertion_point(field_get:caffe.ReLUParameter.negative_slope)
- return negative_slope_;
-}
-inline void ReLUParameter::set_negative_slope(float value) {
- set_has_negative_slope();
- negative_slope_ = value;
- // @@protoc_insertion_point(field_set:caffe.ReLUParameter.negative_slope)
-}
-
-// optional .caffe.ReLUParameter.Engine engine = 2 [default = DEFAULT];
-inline bool ReLUParameter::has_engine() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void ReLUParameter::set_has_engine() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void ReLUParameter::clear_has_engine() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void ReLUParameter::clear_engine() {
- engine_ = 0;
- clear_has_engine();
-}
-inline ::caffe::ReLUParameter_Engine ReLUParameter::engine() const {
- // @@protoc_insertion_point(field_get:caffe.ReLUParameter.engine)
- return static_cast< ::caffe::ReLUParameter_Engine >(engine_);
-}
-inline void ReLUParameter::set_engine(::caffe::ReLUParameter_Engine value) {
- assert(::caffe::ReLUParameter_Engine_IsValid(value));
- set_has_engine();
- engine_ = value;
- // @@protoc_insertion_point(field_set:caffe.ReLUParameter.engine)
-}
-
-inline const ReLUParameter* ReLUParameter::internal_default_instance() {
- return &ReLUParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// ReshapeParameter
-
-// optional .caffe.BlobShape shape = 1;
-inline bool ReshapeParameter::has_shape() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void ReshapeParameter::set_has_shape() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void ReshapeParameter::clear_has_shape() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void ReshapeParameter::clear_shape() {
- if (shape_ != NULL) shape_->::caffe::BlobShape::Clear();
- clear_has_shape();
-}
-inline const ::caffe::BlobShape& ReshapeParameter::shape() const {
- // @@protoc_insertion_point(field_get:caffe.ReshapeParameter.shape)
- return shape_ != NULL ? *shape_
- : *::caffe::BlobShape::internal_default_instance();
-}
-inline ::caffe::BlobShape* ReshapeParameter::mutable_shape() {
- set_has_shape();
- if (shape_ == NULL) {
- shape_ = new ::caffe::BlobShape;
- }
- // @@protoc_insertion_point(field_mutable:caffe.ReshapeParameter.shape)
- return shape_;
-}
-inline ::caffe::BlobShape* ReshapeParameter::release_shape() {
- // @@protoc_insertion_point(field_release:caffe.ReshapeParameter.shape)
- clear_has_shape();
- ::caffe::BlobShape* temp = shape_;
- shape_ = NULL;
- return temp;
-}
-inline void ReshapeParameter::set_allocated_shape(::caffe::BlobShape* shape) {
- delete shape_;
- shape_ = shape;
- if (shape) {
- set_has_shape();
- } else {
- clear_has_shape();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.ReshapeParameter.shape)
-}
-
-// optional int32 axis = 2 [default = 0];
-inline bool ReshapeParameter::has_axis() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void ReshapeParameter::set_has_axis() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void ReshapeParameter::clear_has_axis() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void ReshapeParameter::clear_axis() {
- axis_ = 0;
- clear_has_axis();
-}
-inline ::google::protobuf::int32 ReshapeParameter::axis() const {
- // @@protoc_insertion_point(field_get:caffe.ReshapeParameter.axis)
- return axis_;
-}
-inline void ReshapeParameter::set_axis(::google::protobuf::int32 value) {
- set_has_axis();
- axis_ = value;
- // @@protoc_insertion_point(field_set:caffe.ReshapeParameter.axis)
-}
-
-// optional int32 num_axes = 3 [default = -1];
-inline bool ReshapeParameter::has_num_axes() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void ReshapeParameter::set_has_num_axes() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void ReshapeParameter::clear_has_num_axes() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void ReshapeParameter::clear_num_axes() {
- num_axes_ = -1;
- clear_has_num_axes();
-}
-inline ::google::protobuf::int32 ReshapeParameter::num_axes() const {
- // @@protoc_insertion_point(field_get:caffe.ReshapeParameter.num_axes)
- return num_axes_;
-}
-inline void ReshapeParameter::set_num_axes(::google::protobuf::int32 value) {
- set_has_num_axes();
- num_axes_ = value;
- // @@protoc_insertion_point(field_set:caffe.ReshapeParameter.num_axes)
-}
-
-inline const ReshapeParameter* ReshapeParameter::internal_default_instance() {
- return &ReshapeParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// SigmoidParameter
-
-// optional .caffe.SigmoidParameter.Engine engine = 1 [default = DEFAULT];
-inline bool SigmoidParameter::has_engine() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void SigmoidParameter::set_has_engine() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void SigmoidParameter::clear_has_engine() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void SigmoidParameter::clear_engine() {
- engine_ = 0;
- clear_has_engine();
-}
-inline ::caffe::SigmoidParameter_Engine SigmoidParameter::engine() const {
- // @@protoc_insertion_point(field_get:caffe.SigmoidParameter.engine)
- return static_cast< ::caffe::SigmoidParameter_Engine >(engine_);
-}
-inline void SigmoidParameter::set_engine(::caffe::SigmoidParameter_Engine value) {
- assert(::caffe::SigmoidParameter_Engine_IsValid(value));
- set_has_engine();
- engine_ = value;
- // @@protoc_insertion_point(field_set:caffe.SigmoidParameter.engine)
-}
-
-inline const SigmoidParameter* SigmoidParameter::internal_default_instance() {
- return &SigmoidParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// SliceParameter
-
-// optional int32 axis = 3 [default = 1];
-inline bool SliceParameter::has_axis() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void SliceParameter::set_has_axis() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void SliceParameter::clear_has_axis() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void SliceParameter::clear_axis() {
- axis_ = 1;
- clear_has_axis();
-}
-inline ::google::protobuf::int32 SliceParameter::axis() const {
- // @@protoc_insertion_point(field_get:caffe.SliceParameter.axis)
- return axis_;
-}
-inline void SliceParameter::set_axis(::google::protobuf::int32 value) {
- set_has_axis();
- axis_ = value;
- // @@protoc_insertion_point(field_set:caffe.SliceParameter.axis)
-}
-
-// repeated uint32 slice_point = 2;
-inline int SliceParameter::slice_point_size() const {
- return slice_point_.size();
-}
-inline void SliceParameter::clear_slice_point() {
- slice_point_.Clear();
-}
-inline ::google::protobuf::uint32 SliceParameter::slice_point(int index) const {
- // @@protoc_insertion_point(field_get:caffe.SliceParameter.slice_point)
- return slice_point_.Get(index);
-}
-inline void SliceParameter::set_slice_point(int index, ::google::protobuf::uint32 value) {
- slice_point_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.SliceParameter.slice_point)
-}
-inline void SliceParameter::add_slice_point(::google::protobuf::uint32 value) {
- slice_point_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.SliceParameter.slice_point)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
-SliceParameter::slice_point() const {
- // @@protoc_insertion_point(field_list:caffe.SliceParameter.slice_point)
- return slice_point_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
-SliceParameter::mutable_slice_point() {
- // @@protoc_insertion_point(field_mutable_list:caffe.SliceParameter.slice_point)
- return &slice_point_;
-}
-
-// optional uint32 slice_dim = 1 [default = 1];
-inline bool SliceParameter::has_slice_dim() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void SliceParameter::set_has_slice_dim() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void SliceParameter::clear_has_slice_dim() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void SliceParameter::clear_slice_dim() {
- slice_dim_ = 1u;
- clear_has_slice_dim();
-}
-inline ::google::protobuf::uint32 SliceParameter::slice_dim() const {
- // @@protoc_insertion_point(field_get:caffe.SliceParameter.slice_dim)
- return slice_dim_;
-}
-inline void SliceParameter::set_slice_dim(::google::protobuf::uint32 value) {
- set_has_slice_dim();
- slice_dim_ = value;
- // @@protoc_insertion_point(field_set:caffe.SliceParameter.slice_dim)
-}
-
-inline const SliceParameter* SliceParameter::internal_default_instance() {
- return &SliceParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// SoftmaxParameter
-
-// optional .caffe.SoftmaxParameter.Engine engine = 1 [default = DEFAULT];
-inline bool SoftmaxParameter::has_engine() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void SoftmaxParameter::set_has_engine() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void SoftmaxParameter::clear_has_engine() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void SoftmaxParameter::clear_engine() {
- engine_ = 0;
- clear_has_engine();
-}
-inline ::caffe::SoftmaxParameter_Engine SoftmaxParameter::engine() const {
- // @@protoc_insertion_point(field_get:caffe.SoftmaxParameter.engine)
- return static_cast< ::caffe::SoftmaxParameter_Engine >(engine_);
-}
-inline void SoftmaxParameter::set_engine(::caffe::SoftmaxParameter_Engine value) {
- assert(::caffe::SoftmaxParameter_Engine_IsValid(value));
- set_has_engine();
- engine_ = value;
- // @@protoc_insertion_point(field_set:caffe.SoftmaxParameter.engine)
-}
-
-// optional int32 axis = 2 [default = 1];
-inline bool SoftmaxParameter::has_axis() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void SoftmaxParameter::set_has_axis() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void SoftmaxParameter::clear_has_axis() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void SoftmaxParameter::clear_axis() {
- axis_ = 1;
- clear_has_axis();
-}
-inline ::google::protobuf::int32 SoftmaxParameter::axis() const {
- // @@protoc_insertion_point(field_get:caffe.SoftmaxParameter.axis)
- return axis_;
-}
-inline void SoftmaxParameter::set_axis(::google::protobuf::int32 value) {
- set_has_axis();
- axis_ = value;
- // @@protoc_insertion_point(field_set:caffe.SoftmaxParameter.axis)
-}
-
-inline const SoftmaxParameter* SoftmaxParameter::internal_default_instance() {
- return &SoftmaxParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// TanHParameter
-
-// optional .caffe.TanHParameter.Engine engine = 1 [default = DEFAULT];
-inline bool TanHParameter::has_engine() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void TanHParameter::set_has_engine() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void TanHParameter::clear_has_engine() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void TanHParameter::clear_engine() {
- engine_ = 0;
- clear_has_engine();
-}
-inline ::caffe::TanHParameter_Engine TanHParameter::engine() const {
- // @@protoc_insertion_point(field_get:caffe.TanHParameter.engine)
- return static_cast< ::caffe::TanHParameter_Engine >(engine_);
-}
-inline void TanHParameter::set_engine(::caffe::TanHParameter_Engine value) {
- assert(::caffe::TanHParameter_Engine_IsValid(value));
- set_has_engine();
- engine_ = value;
- // @@protoc_insertion_point(field_set:caffe.TanHParameter.engine)
-}
-
-inline const TanHParameter* TanHParameter::internal_default_instance() {
- return &TanHParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// ThresholdParameter
-
-// optional float threshold = 1 [default = 0];
-inline bool ThresholdParameter::has_threshold() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void ThresholdParameter::set_has_threshold() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void ThresholdParameter::clear_has_threshold() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void ThresholdParameter::clear_threshold() {
- threshold_ = 0;
- clear_has_threshold();
-}
-inline float ThresholdParameter::threshold() const {
- // @@protoc_insertion_point(field_get:caffe.ThresholdParameter.threshold)
- return threshold_;
-}
-inline void ThresholdParameter::set_threshold(float value) {
- set_has_threshold();
- threshold_ = value;
- // @@protoc_insertion_point(field_set:caffe.ThresholdParameter.threshold)
-}
-
-inline const ThresholdParameter* ThresholdParameter::internal_default_instance() {
- return &ThresholdParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// WindowDataParameter
-
-// optional string source = 1;
-inline bool WindowDataParameter::has_source() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void WindowDataParameter::set_has_source() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void WindowDataParameter::clear_has_source() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void WindowDataParameter::clear_source() {
- source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_source();
-}
-inline const ::std::string& WindowDataParameter::source() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.source)
- return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void WindowDataParameter::set_source(const ::std::string& value) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.source)
-}
-inline void WindowDataParameter::set_source(const char* value) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.WindowDataParameter.source)
-}
-inline void WindowDataParameter::set_source(const char* value, size_t size) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.WindowDataParameter.source)
-}
-inline ::std::string* WindowDataParameter::mutable_source() {
- set_has_source();
- // @@protoc_insertion_point(field_mutable:caffe.WindowDataParameter.source)
- return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* WindowDataParameter::release_source() {
- // @@protoc_insertion_point(field_release:caffe.WindowDataParameter.source)
- clear_has_source();
- return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void WindowDataParameter::set_allocated_source(::std::string* source) {
- if (source != NULL) {
- set_has_source();
- } else {
- clear_has_source();
- }
- source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source);
- // @@protoc_insertion_point(field_set_allocated:caffe.WindowDataParameter.source)
-}
-
-// optional float scale = 2 [default = 1];
-inline bool WindowDataParameter::has_scale() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void WindowDataParameter::set_has_scale() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void WindowDataParameter::clear_has_scale() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void WindowDataParameter::clear_scale() {
- scale_ = 1;
- clear_has_scale();
-}
-inline float WindowDataParameter::scale() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.scale)
- return scale_;
-}
-inline void WindowDataParameter::set_scale(float value) {
- set_has_scale();
- scale_ = value;
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.scale)
-}
-
-// optional string mean_file = 3;
-inline bool WindowDataParameter::has_mean_file() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void WindowDataParameter::set_has_mean_file() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void WindowDataParameter::clear_has_mean_file() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void WindowDataParameter::clear_mean_file() {
- mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_mean_file();
-}
-inline const ::std::string& WindowDataParameter::mean_file() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.mean_file)
- return mean_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void WindowDataParameter::set_mean_file(const ::std::string& value) {
- set_has_mean_file();
- mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.mean_file)
-}
-inline void WindowDataParameter::set_mean_file(const char* value) {
- set_has_mean_file();
- mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.WindowDataParameter.mean_file)
-}
-inline void WindowDataParameter::set_mean_file(const char* value, size_t size) {
- set_has_mean_file();
- mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.WindowDataParameter.mean_file)
-}
-inline ::std::string* WindowDataParameter::mutable_mean_file() {
- set_has_mean_file();
- // @@protoc_insertion_point(field_mutable:caffe.WindowDataParameter.mean_file)
- return mean_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* WindowDataParameter::release_mean_file() {
- // @@protoc_insertion_point(field_release:caffe.WindowDataParameter.mean_file)
- clear_has_mean_file();
- return mean_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void WindowDataParameter::set_allocated_mean_file(::std::string* mean_file) {
- if (mean_file != NULL) {
- set_has_mean_file();
- } else {
- clear_has_mean_file();
- }
- mean_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), mean_file);
- // @@protoc_insertion_point(field_set_allocated:caffe.WindowDataParameter.mean_file)
-}
-
-// optional uint32 batch_size = 4;
-inline bool WindowDataParameter::has_batch_size() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void WindowDataParameter::set_has_batch_size() {
- _has_bits_[0] |= 0x00000008u;
-}
-inline void WindowDataParameter::clear_has_batch_size() {
- _has_bits_[0] &= ~0x00000008u;
-}
-inline void WindowDataParameter::clear_batch_size() {
- batch_size_ = 0u;
- clear_has_batch_size();
-}
-inline ::google::protobuf::uint32 WindowDataParameter::batch_size() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.batch_size)
- return batch_size_;
-}
-inline void WindowDataParameter::set_batch_size(::google::protobuf::uint32 value) {
- set_has_batch_size();
- batch_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.batch_size)
-}
-
-// optional uint32 crop_size = 5 [default = 0];
-inline bool WindowDataParameter::has_crop_size() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-inline void WindowDataParameter::set_has_crop_size() {
- _has_bits_[0] |= 0x00000010u;
-}
-inline void WindowDataParameter::clear_has_crop_size() {
- _has_bits_[0] &= ~0x00000010u;
-}
-inline void WindowDataParameter::clear_crop_size() {
- crop_size_ = 0u;
- clear_has_crop_size();
-}
-inline ::google::protobuf::uint32 WindowDataParameter::crop_size() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.crop_size)
- return crop_size_;
-}
-inline void WindowDataParameter::set_crop_size(::google::protobuf::uint32 value) {
- set_has_crop_size();
- crop_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.crop_size)
-}
-
-// optional bool mirror = 6 [default = false];
-inline bool WindowDataParameter::has_mirror() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-inline void WindowDataParameter::set_has_mirror() {
- _has_bits_[0] |= 0x00000020u;
-}
-inline void WindowDataParameter::clear_has_mirror() {
- _has_bits_[0] &= ~0x00000020u;
-}
-inline void WindowDataParameter::clear_mirror() {
- mirror_ = false;
- clear_has_mirror();
-}
-inline bool WindowDataParameter::mirror() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.mirror)
- return mirror_;
-}
-inline void WindowDataParameter::set_mirror(bool value) {
- set_has_mirror();
- mirror_ = value;
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.mirror)
-}
-
-// optional float fg_threshold = 7 [default = 0.5];
-inline bool WindowDataParameter::has_fg_threshold() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-inline void WindowDataParameter::set_has_fg_threshold() {
- _has_bits_[0] |= 0x00000040u;
-}
-inline void WindowDataParameter::clear_has_fg_threshold() {
- _has_bits_[0] &= ~0x00000040u;
-}
-inline void WindowDataParameter::clear_fg_threshold() {
- fg_threshold_ = 0.5f;
- clear_has_fg_threshold();
-}
-inline float WindowDataParameter::fg_threshold() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.fg_threshold)
- return fg_threshold_;
-}
-inline void WindowDataParameter::set_fg_threshold(float value) {
- set_has_fg_threshold();
- fg_threshold_ = value;
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.fg_threshold)
-}
-
-// optional float bg_threshold = 8 [default = 0.5];
-inline bool WindowDataParameter::has_bg_threshold() const {
- return (_has_bits_[0] & 0x00000080u) != 0;
-}
-inline void WindowDataParameter::set_has_bg_threshold() {
- _has_bits_[0] |= 0x00000080u;
-}
-inline void WindowDataParameter::clear_has_bg_threshold() {
- _has_bits_[0] &= ~0x00000080u;
-}
-inline void WindowDataParameter::clear_bg_threshold() {
- bg_threshold_ = 0.5f;
- clear_has_bg_threshold();
-}
-inline float WindowDataParameter::bg_threshold() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.bg_threshold)
- return bg_threshold_;
-}
-inline void WindowDataParameter::set_bg_threshold(float value) {
- set_has_bg_threshold();
- bg_threshold_ = value;
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.bg_threshold)
-}
-
-// optional float fg_fraction = 9 [default = 0.25];
-inline bool WindowDataParameter::has_fg_fraction() const {
- return (_has_bits_[0] & 0x00000100u) != 0;
-}
-inline void WindowDataParameter::set_has_fg_fraction() {
- _has_bits_[0] |= 0x00000100u;
-}
-inline void WindowDataParameter::clear_has_fg_fraction() {
- _has_bits_[0] &= ~0x00000100u;
-}
-inline void WindowDataParameter::clear_fg_fraction() {
- fg_fraction_ = 0.25f;
- clear_has_fg_fraction();
-}
-inline float WindowDataParameter::fg_fraction() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.fg_fraction)
- return fg_fraction_;
-}
-inline void WindowDataParameter::set_fg_fraction(float value) {
- set_has_fg_fraction();
- fg_fraction_ = value;
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.fg_fraction)
-}
-
-// optional uint32 context_pad = 10 [default = 0];
-inline bool WindowDataParameter::has_context_pad() const {
- return (_has_bits_[0] & 0x00000200u) != 0;
-}
-inline void WindowDataParameter::set_has_context_pad() {
- _has_bits_[0] |= 0x00000200u;
-}
-inline void WindowDataParameter::clear_has_context_pad() {
- _has_bits_[0] &= ~0x00000200u;
-}
-inline void WindowDataParameter::clear_context_pad() {
- context_pad_ = 0u;
- clear_has_context_pad();
-}
-inline ::google::protobuf::uint32 WindowDataParameter::context_pad() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.context_pad)
- return context_pad_;
-}
-inline void WindowDataParameter::set_context_pad(::google::protobuf::uint32 value) {
- set_has_context_pad();
- context_pad_ = value;
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.context_pad)
-}
-
-// optional string crop_mode = 11 [default = "warp"];
-inline bool WindowDataParameter::has_crop_mode() const {
- return (_has_bits_[0] & 0x00000400u) != 0;
-}
-inline void WindowDataParameter::set_has_crop_mode() {
- _has_bits_[0] |= 0x00000400u;
-}
-inline void WindowDataParameter::clear_has_crop_mode() {
- _has_bits_[0] &= ~0x00000400u;
-}
-inline void WindowDataParameter::clear_crop_mode() {
- crop_mode_.ClearToDefaultNoArena(_default_crop_mode_);
- clear_has_crop_mode();
-}
-inline const ::std::string& WindowDataParameter::crop_mode() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.crop_mode)
- return crop_mode_.GetNoArena(_default_crop_mode_);
-}
-inline void WindowDataParameter::set_crop_mode(const ::std::string& value) {
- set_has_crop_mode();
- crop_mode_.SetNoArena(_default_crop_mode_, value);
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.crop_mode)
-}
-inline void WindowDataParameter::set_crop_mode(const char* value) {
- set_has_crop_mode();
- crop_mode_.SetNoArena(_default_crop_mode_, ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.WindowDataParameter.crop_mode)
-}
-inline void WindowDataParameter::set_crop_mode(const char* value, size_t size) {
- set_has_crop_mode();
- crop_mode_.SetNoArena(_default_crop_mode_,
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.WindowDataParameter.crop_mode)
-}
-inline ::std::string* WindowDataParameter::mutable_crop_mode() {
- set_has_crop_mode();
- // @@protoc_insertion_point(field_mutable:caffe.WindowDataParameter.crop_mode)
- return crop_mode_.MutableNoArena(_default_crop_mode_);
-}
-inline ::std::string* WindowDataParameter::release_crop_mode() {
- // @@protoc_insertion_point(field_release:caffe.WindowDataParameter.crop_mode)
- clear_has_crop_mode();
- return crop_mode_.ReleaseNoArena(_default_crop_mode_);
-}
-inline void WindowDataParameter::set_allocated_crop_mode(::std::string* crop_mode) {
- if (crop_mode != NULL) {
- set_has_crop_mode();
- } else {
- clear_has_crop_mode();
- }
- crop_mode_.SetAllocatedNoArena(_default_crop_mode_, crop_mode);
- // @@protoc_insertion_point(field_set_allocated:caffe.WindowDataParameter.crop_mode)
-}
-
-// optional bool cache_images = 12 [default = false];
-inline bool WindowDataParameter::has_cache_images() const {
- return (_has_bits_[0] & 0x00000800u) != 0;
-}
-inline void WindowDataParameter::set_has_cache_images() {
- _has_bits_[0] |= 0x00000800u;
-}
-inline void WindowDataParameter::clear_has_cache_images() {
- _has_bits_[0] &= ~0x00000800u;
-}
-inline void WindowDataParameter::clear_cache_images() {
- cache_images_ = false;
- clear_has_cache_images();
-}
-inline bool WindowDataParameter::cache_images() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.cache_images)
- return cache_images_;
-}
-inline void WindowDataParameter::set_cache_images(bool value) {
- set_has_cache_images();
- cache_images_ = value;
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.cache_images)
-}
-
-// optional string root_folder = 13 [default = ""];
-inline bool WindowDataParameter::has_root_folder() const {
- return (_has_bits_[0] & 0x00001000u) != 0;
-}
-inline void WindowDataParameter::set_has_root_folder() {
- _has_bits_[0] |= 0x00001000u;
-}
-inline void WindowDataParameter::clear_has_root_folder() {
- _has_bits_[0] &= ~0x00001000u;
-}
-inline void WindowDataParameter::clear_root_folder() {
- root_folder_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_root_folder();
-}
-inline const ::std::string& WindowDataParameter::root_folder() const {
- // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.root_folder)
- return root_folder_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void WindowDataParameter::set_root_folder(const ::std::string& value) {
- set_has_root_folder();
- root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.root_folder)
-}
-inline void WindowDataParameter::set_root_folder(const char* value) {
- set_has_root_folder();
- root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.WindowDataParameter.root_folder)
-}
-inline void WindowDataParameter::set_root_folder(const char* value, size_t size) {
- set_has_root_folder();
- root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.WindowDataParameter.root_folder)
-}
-inline ::std::string* WindowDataParameter::mutable_root_folder() {
- set_has_root_folder();
- // @@protoc_insertion_point(field_mutable:caffe.WindowDataParameter.root_folder)
- return root_folder_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* WindowDataParameter::release_root_folder() {
- // @@protoc_insertion_point(field_release:caffe.WindowDataParameter.root_folder)
- clear_has_root_folder();
- return root_folder_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void WindowDataParameter::set_allocated_root_folder(::std::string* root_folder) {
- if (root_folder != NULL) {
- set_has_root_folder();
- } else {
- clear_has_root_folder();
- }
- root_folder_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), root_folder);
- // @@protoc_insertion_point(field_set_allocated:caffe.WindowDataParameter.root_folder)
-}
-
-inline const WindowDataParameter* WindowDataParameter::internal_default_instance() {
- return &WindowDataParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// SPPParameter
-
-// optional uint32 pyramid_height = 1;
-inline bool SPPParameter::has_pyramid_height() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void SPPParameter::set_has_pyramid_height() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void SPPParameter::clear_has_pyramid_height() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void SPPParameter::clear_pyramid_height() {
- pyramid_height_ = 0u;
- clear_has_pyramid_height();
-}
-inline ::google::protobuf::uint32 SPPParameter::pyramid_height() const {
- // @@protoc_insertion_point(field_get:caffe.SPPParameter.pyramid_height)
- return pyramid_height_;
-}
-inline void SPPParameter::set_pyramid_height(::google::protobuf::uint32 value) {
- set_has_pyramid_height();
- pyramid_height_ = value;
- // @@protoc_insertion_point(field_set:caffe.SPPParameter.pyramid_height)
-}
-
-// optional .caffe.SPPParameter.PoolMethod pool = 2 [default = MAX];
-inline bool SPPParameter::has_pool() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void SPPParameter::set_has_pool() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void SPPParameter::clear_has_pool() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void SPPParameter::clear_pool() {
- pool_ = 0;
- clear_has_pool();
-}
-inline ::caffe::SPPParameter_PoolMethod SPPParameter::pool() const {
- // @@protoc_insertion_point(field_get:caffe.SPPParameter.pool)
- return static_cast< ::caffe::SPPParameter_PoolMethod >(pool_);
-}
-inline void SPPParameter::set_pool(::caffe::SPPParameter_PoolMethod value) {
- assert(::caffe::SPPParameter_PoolMethod_IsValid(value));
- set_has_pool();
- pool_ = value;
- // @@protoc_insertion_point(field_set:caffe.SPPParameter.pool)
-}
-
-// optional .caffe.SPPParameter.Engine engine = 6 [default = DEFAULT];
-inline bool SPPParameter::has_engine() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void SPPParameter::set_has_engine() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void SPPParameter::clear_has_engine() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void SPPParameter::clear_engine() {
- engine_ = 0;
- clear_has_engine();
-}
-inline ::caffe::SPPParameter_Engine SPPParameter::engine() const {
- // @@protoc_insertion_point(field_get:caffe.SPPParameter.engine)
- return static_cast< ::caffe::SPPParameter_Engine >(engine_);
-}
-inline void SPPParameter::set_engine(::caffe::SPPParameter_Engine value) {
- assert(::caffe::SPPParameter_Engine_IsValid(value));
- set_has_engine();
- engine_ = value;
- // @@protoc_insertion_point(field_set:caffe.SPPParameter.engine)
-}
-
-inline const SPPParameter* SPPParameter::internal_default_instance() {
- return &SPPParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// V1LayerParameter
-
-// repeated string bottom = 2;
-inline int V1LayerParameter::bottom_size() const {
- return bottom_.size();
-}
-inline void V1LayerParameter::clear_bottom() {
- bottom_.Clear();
-}
-inline const ::std::string& V1LayerParameter::bottom(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.bottom)
- return bottom_.Get(index);
-}
-inline ::std::string* V1LayerParameter::mutable_bottom(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.bottom)
- return bottom_.Mutable(index);
-}
-inline void V1LayerParameter::set_bottom(int index, const ::std::string& value) {
- // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.bottom)
- bottom_.Mutable(index)->assign(value);
-}
-inline void V1LayerParameter::set_bottom(int index, const char* value) {
- bottom_.Mutable(index)->assign(value);
- // @@protoc_insertion_point(field_set_char:caffe.V1LayerParameter.bottom)
-}
-inline void V1LayerParameter::set_bottom(int index, const char* value, size_t size) {
- bottom_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:caffe.V1LayerParameter.bottom)
-}
-inline ::std::string* V1LayerParameter::add_bottom() {
- // @@protoc_insertion_point(field_add_mutable:caffe.V1LayerParameter.bottom)
- return bottom_.Add();
-}
-inline void V1LayerParameter::add_bottom(const ::std::string& value) {
- bottom_.Add()->assign(value);
- // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.bottom)
-}
-inline void V1LayerParameter::add_bottom(const char* value) {
- bottom_.Add()->assign(value);
- // @@protoc_insertion_point(field_add_char:caffe.V1LayerParameter.bottom)
-}
-inline void V1LayerParameter::add_bottom(const char* value, size_t size) {
- bottom_.Add()->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_add_pointer:caffe.V1LayerParameter.bottom)
-}
-inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
-V1LayerParameter::bottom() const {
- // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.bottom)
- return bottom_;
-}
-inline ::google::protobuf::RepeatedPtrField< ::std::string>*
-V1LayerParameter::mutable_bottom() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.bottom)
- return &bottom_;
-}
-
-// repeated string top = 3;
-inline int V1LayerParameter::top_size() const {
- return top_.size();
-}
-inline void V1LayerParameter::clear_top() {
- top_.Clear();
-}
-inline const ::std::string& V1LayerParameter::top(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.top)
- return top_.Get(index);
-}
-inline ::std::string* V1LayerParameter::mutable_top(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.top)
- return top_.Mutable(index);
-}
-inline void V1LayerParameter::set_top(int index, const ::std::string& value) {
- // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.top)
- top_.Mutable(index)->assign(value);
-}
-inline void V1LayerParameter::set_top(int index, const char* value) {
- top_.Mutable(index)->assign(value);
- // @@protoc_insertion_point(field_set_char:caffe.V1LayerParameter.top)
-}
-inline void V1LayerParameter::set_top(int index, const char* value, size_t size) {
- top_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:caffe.V1LayerParameter.top)
-}
-inline ::std::string* V1LayerParameter::add_top() {
- // @@protoc_insertion_point(field_add_mutable:caffe.V1LayerParameter.top)
- return top_.Add();
-}
-inline void V1LayerParameter::add_top(const ::std::string& value) {
- top_.Add()->assign(value);
- // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.top)
-}
-inline void V1LayerParameter::add_top(const char* value) {
- top_.Add()->assign(value);
- // @@protoc_insertion_point(field_add_char:caffe.V1LayerParameter.top)
-}
-inline void V1LayerParameter::add_top(const char* value, size_t size) {
- top_.Add()->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_add_pointer:caffe.V1LayerParameter.top)
-}
-inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
-V1LayerParameter::top() const {
- // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.top)
- return top_;
-}
-inline ::google::protobuf::RepeatedPtrField< ::std::string>*
-V1LayerParameter::mutable_top() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.top)
- return &top_;
-}
-
-// optional string name = 4;
-inline bool V1LayerParameter::has_name() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void V1LayerParameter::set_has_name() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void V1LayerParameter::clear_has_name() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void V1LayerParameter::clear_name() {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_name();
-}
-inline const ::std::string& V1LayerParameter::name() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void V1LayerParameter::set_name(const ::std::string& value) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.name)
-}
-inline void V1LayerParameter::set_name(const char* value) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.V1LayerParameter.name)
-}
-inline void V1LayerParameter::set_name(const char* value, size_t size) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.V1LayerParameter.name)
-}
-inline ::std::string* V1LayerParameter::mutable_name() {
- set_has_name();
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.name)
- return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* V1LayerParameter::release_name() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.name)
- clear_has_name();
- return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void V1LayerParameter::set_allocated_name(::std::string* name) {
- if (name != NULL) {
- set_has_name();
- } else {
- clear_has_name();
- }
- name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.name)
-}
-
-// repeated .caffe.NetStateRule include = 32;
-inline int V1LayerParameter::include_size() const {
- return include_.size();
-}
-inline void V1LayerParameter::clear_include() {
- include_.Clear();
-}
-inline const ::caffe::NetStateRule& V1LayerParameter::include(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.include)
- return include_.Get(index);
-}
-inline ::caffe::NetStateRule* V1LayerParameter::mutable_include(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.include)
- return include_.Mutable(index);
-}
-inline ::caffe::NetStateRule* V1LayerParameter::add_include() {
- // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.include)
- return include_.Add();
-}
-inline ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >*
-V1LayerParameter::mutable_include() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.include)
- return &include_;
-}
-inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >&
-V1LayerParameter::include() const {
- // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.include)
- return include_;
-}
-
-// repeated .caffe.NetStateRule exclude = 33;
-inline int V1LayerParameter::exclude_size() const {
- return exclude_.size();
-}
-inline void V1LayerParameter::clear_exclude() {
- exclude_.Clear();
-}
-inline const ::caffe::NetStateRule& V1LayerParameter::exclude(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.exclude)
- return exclude_.Get(index);
-}
-inline ::caffe::NetStateRule* V1LayerParameter::mutable_exclude(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.exclude)
- return exclude_.Mutable(index);
-}
-inline ::caffe::NetStateRule* V1LayerParameter::add_exclude() {
- // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.exclude)
- return exclude_.Add();
-}
-inline ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >*
-V1LayerParameter::mutable_exclude() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.exclude)
- return &exclude_;
-}
-inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >&
-V1LayerParameter::exclude() const {
- // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.exclude)
- return exclude_;
-}
-
-// optional .caffe.V1LayerParameter.LayerType type = 5;
-inline bool V1LayerParameter::has_type() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-inline void V1LayerParameter::set_has_type() {
- _has_bits_[0] |= 0x00000020u;
-}
-inline void V1LayerParameter::clear_has_type() {
- _has_bits_[0] &= ~0x00000020u;
-}
-inline void V1LayerParameter::clear_type() {
- type_ = 0;
- clear_has_type();
-}
-inline ::caffe::V1LayerParameter_LayerType V1LayerParameter::type() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.type)
- return static_cast< ::caffe::V1LayerParameter_LayerType >(type_);
-}
-inline void V1LayerParameter::set_type(::caffe::V1LayerParameter_LayerType value) {
- assert(::caffe::V1LayerParameter_LayerType_IsValid(value));
- set_has_type();
- type_ = value;
- // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.type)
-}
-
-// repeated .caffe.BlobProto blobs = 6;
-inline int V1LayerParameter::blobs_size() const {
- return blobs_.size();
-}
-inline void V1LayerParameter::clear_blobs() {
- blobs_.Clear();
-}
-inline const ::caffe::BlobProto& V1LayerParameter::blobs(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.blobs)
- return blobs_.Get(index);
-}
-inline ::caffe::BlobProto* V1LayerParameter::mutable_blobs(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.blobs)
- return blobs_.Mutable(index);
-}
-inline ::caffe::BlobProto* V1LayerParameter::add_blobs() {
- // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.blobs)
- return blobs_.Add();
-}
-inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
-V1LayerParameter::mutable_blobs() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.blobs)
- return &blobs_;
-}
-inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
-V1LayerParameter::blobs() const {
- // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.blobs)
- return blobs_;
-}
-
-// repeated string param = 1001;
-inline int V1LayerParameter::param_size() const {
- return param_.size();
-}
-inline void V1LayerParameter::clear_param() {
- param_.Clear();
-}
-inline const ::std::string& V1LayerParameter::param(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.param)
- return param_.Get(index);
-}
-inline ::std::string* V1LayerParameter::mutable_param(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.param)
- return param_.Mutable(index);
-}
-inline void V1LayerParameter::set_param(int index, const ::std::string& value) {
- // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.param)
- param_.Mutable(index)->assign(value);
-}
-inline void V1LayerParameter::set_param(int index, const char* value) {
- param_.Mutable(index)->assign(value);
- // @@protoc_insertion_point(field_set_char:caffe.V1LayerParameter.param)
-}
-inline void V1LayerParameter::set_param(int index, const char* value, size_t size) {
- param_.Mutable(index)->assign(
- reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_set_pointer:caffe.V1LayerParameter.param)
-}
-inline ::std::string* V1LayerParameter::add_param() {
- // @@protoc_insertion_point(field_add_mutable:caffe.V1LayerParameter.param)
- return param_.Add();
-}
-inline void V1LayerParameter::add_param(const ::std::string& value) {
- param_.Add()->assign(value);
- // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.param)
-}
-inline void V1LayerParameter::add_param(const char* value) {
- param_.Add()->assign(value);
- // @@protoc_insertion_point(field_add_char:caffe.V1LayerParameter.param)
-}
-inline void V1LayerParameter::add_param(const char* value, size_t size) {
- param_.Add()->assign(reinterpret_cast<const char*>(value), size);
- // @@protoc_insertion_point(field_add_pointer:caffe.V1LayerParameter.param)
-}
-inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
-V1LayerParameter::param() const {
- // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.param)
- return param_;
-}
-inline ::google::protobuf::RepeatedPtrField< ::std::string>*
-V1LayerParameter::mutable_param() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.param)
- return ¶m_;
-}
-
-// repeated .caffe.V1LayerParameter.DimCheckMode blob_share_mode = 1002;
-inline int V1LayerParameter::blob_share_mode_size() const {
- return blob_share_mode_.size();
-}
-inline void V1LayerParameter::clear_blob_share_mode() {
- blob_share_mode_.Clear();
-}
-inline ::caffe::V1LayerParameter_DimCheckMode V1LayerParameter::blob_share_mode(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.blob_share_mode)
- return static_cast< ::caffe::V1LayerParameter_DimCheckMode >(blob_share_mode_.Get(index));
-}
-inline void V1LayerParameter::set_blob_share_mode(int index, ::caffe::V1LayerParameter_DimCheckMode value) {
- assert(::caffe::V1LayerParameter_DimCheckMode_IsValid(value));
- blob_share_mode_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.blob_share_mode)
-}
-inline void V1LayerParameter::add_blob_share_mode(::caffe::V1LayerParameter_DimCheckMode value) {
- assert(::caffe::V1LayerParameter_DimCheckMode_IsValid(value));
- blob_share_mode_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.blob_share_mode)
-}
-inline const ::google::protobuf::RepeatedField<int>&
-V1LayerParameter::blob_share_mode() const {
- // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.blob_share_mode)
- return blob_share_mode_;
-}
-inline ::google::protobuf::RepeatedField<int>*
-V1LayerParameter::mutable_blob_share_mode() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.blob_share_mode)
- return &blob_share_mode_;
-}
-
-// repeated float blobs_lr = 7;
-inline int V1LayerParameter::blobs_lr_size() const {
- return blobs_lr_.size();
-}
-inline void V1LayerParameter::clear_blobs_lr() {
- blobs_lr_.Clear();
-}
-inline float V1LayerParameter::blobs_lr(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.blobs_lr)
- return blobs_lr_.Get(index);
-}
-inline void V1LayerParameter::set_blobs_lr(int index, float value) {
- blobs_lr_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.blobs_lr)
-}
-inline void V1LayerParameter::add_blobs_lr(float value) {
- blobs_lr_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.blobs_lr)
-}
-inline const ::google::protobuf::RepeatedField< float >&
-V1LayerParameter::blobs_lr() const {
- // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.blobs_lr)
- return blobs_lr_;
-}
-inline ::google::protobuf::RepeatedField< float >*
-V1LayerParameter::mutable_blobs_lr() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.blobs_lr)
- return &blobs_lr_;
-}
-
-// repeated float weight_decay = 8;
-inline int V1LayerParameter::weight_decay_size() const {
- return weight_decay_.size();
-}
-inline void V1LayerParameter::clear_weight_decay() {
- weight_decay_.Clear();
-}
-inline float V1LayerParameter::weight_decay(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.weight_decay)
- return weight_decay_.Get(index);
-}
-inline void V1LayerParameter::set_weight_decay(int index, float value) {
- weight_decay_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.weight_decay)
-}
-inline void V1LayerParameter::add_weight_decay(float value) {
- weight_decay_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.weight_decay)
-}
-inline const ::google::protobuf::RepeatedField< float >&
-V1LayerParameter::weight_decay() const {
- // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.weight_decay)
- return weight_decay_;
-}
-inline ::google::protobuf::RepeatedField< float >*
-V1LayerParameter::mutable_weight_decay() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.weight_decay)
- return &weight_decay_;
-}
-
-// repeated float loss_weight = 35;
-inline int V1LayerParameter::loss_weight_size() const {
- return loss_weight_.size();
-}
-inline void V1LayerParameter::clear_loss_weight() {
- loss_weight_.Clear();
-}
-inline float V1LayerParameter::loss_weight(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.loss_weight)
- return loss_weight_.Get(index);
-}
-inline void V1LayerParameter::set_loss_weight(int index, float value) {
- loss_weight_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.loss_weight)
-}
-inline void V1LayerParameter::add_loss_weight(float value) {
- loss_weight_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.loss_weight)
-}
-inline const ::google::protobuf::RepeatedField< float >&
-V1LayerParameter::loss_weight() const {
- // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.loss_weight)
- return loss_weight_;
-}
-inline ::google::protobuf::RepeatedField< float >*
-V1LayerParameter::mutable_loss_weight() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.loss_weight)
- return &loss_weight_;
-}
-
-// optional .caffe.AccuracyParameter accuracy_param = 27;
-inline bool V1LayerParameter::has_accuracy_param() const {
- return (_has_bits_[0] & 0x00001000u) != 0;
-}
-inline void V1LayerParameter::set_has_accuracy_param() {
- _has_bits_[0] |= 0x00001000u;
-}
-inline void V1LayerParameter::clear_has_accuracy_param() {
- _has_bits_[0] &= ~0x00001000u;
-}
-inline void V1LayerParameter::clear_accuracy_param() {
- if (accuracy_param_ != NULL) accuracy_param_->::caffe::AccuracyParameter::Clear();
- clear_has_accuracy_param();
-}
-inline const ::caffe::AccuracyParameter& V1LayerParameter::accuracy_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.accuracy_param)
- return accuracy_param_ != NULL ? *accuracy_param_
- : *::caffe::AccuracyParameter::internal_default_instance();
-}
-inline ::caffe::AccuracyParameter* V1LayerParameter::mutable_accuracy_param() {
- set_has_accuracy_param();
- if (accuracy_param_ == NULL) {
- accuracy_param_ = new ::caffe::AccuracyParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.accuracy_param)
- return accuracy_param_;
-}
-inline ::caffe::AccuracyParameter* V1LayerParameter::release_accuracy_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.accuracy_param)
- clear_has_accuracy_param();
- ::caffe::AccuracyParameter* temp = accuracy_param_;
- accuracy_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_accuracy_param(::caffe::AccuracyParameter* accuracy_param) {
- delete accuracy_param_;
- accuracy_param_ = accuracy_param;
- if (accuracy_param) {
- set_has_accuracy_param();
- } else {
- clear_has_accuracy_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.accuracy_param)
-}
-
-// optional .caffe.ArgMaxParameter argmax_param = 23;
-inline bool V1LayerParameter::has_argmax_param() const {
- return (_has_bits_[0] & 0x00002000u) != 0;
-}
-inline void V1LayerParameter::set_has_argmax_param() {
- _has_bits_[0] |= 0x00002000u;
-}
-inline void V1LayerParameter::clear_has_argmax_param() {
- _has_bits_[0] &= ~0x00002000u;
-}
-inline void V1LayerParameter::clear_argmax_param() {
- if (argmax_param_ != NULL) argmax_param_->::caffe::ArgMaxParameter::Clear();
- clear_has_argmax_param();
-}
-inline const ::caffe::ArgMaxParameter& V1LayerParameter::argmax_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.argmax_param)
- return argmax_param_ != NULL ? *argmax_param_
- : *::caffe::ArgMaxParameter::internal_default_instance();
-}
-inline ::caffe::ArgMaxParameter* V1LayerParameter::mutable_argmax_param() {
- set_has_argmax_param();
- if (argmax_param_ == NULL) {
- argmax_param_ = new ::caffe::ArgMaxParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.argmax_param)
- return argmax_param_;
-}
-inline ::caffe::ArgMaxParameter* V1LayerParameter::release_argmax_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.argmax_param)
- clear_has_argmax_param();
- ::caffe::ArgMaxParameter* temp = argmax_param_;
- argmax_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_argmax_param(::caffe::ArgMaxParameter* argmax_param) {
- delete argmax_param_;
- argmax_param_ = argmax_param;
- if (argmax_param) {
- set_has_argmax_param();
- } else {
- clear_has_argmax_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.argmax_param)
-}
-
-// optional .caffe.ConcatParameter concat_param = 9;
-inline bool V1LayerParameter::has_concat_param() const {
- return (_has_bits_[0] & 0x00004000u) != 0;
-}
-inline void V1LayerParameter::set_has_concat_param() {
- _has_bits_[0] |= 0x00004000u;
-}
-inline void V1LayerParameter::clear_has_concat_param() {
- _has_bits_[0] &= ~0x00004000u;
-}
-inline void V1LayerParameter::clear_concat_param() {
- if (concat_param_ != NULL) concat_param_->::caffe::ConcatParameter::Clear();
- clear_has_concat_param();
-}
-inline const ::caffe::ConcatParameter& V1LayerParameter::concat_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.concat_param)
- return concat_param_ != NULL ? *concat_param_
- : *::caffe::ConcatParameter::internal_default_instance();
-}
-inline ::caffe::ConcatParameter* V1LayerParameter::mutable_concat_param() {
- set_has_concat_param();
- if (concat_param_ == NULL) {
- concat_param_ = new ::caffe::ConcatParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.concat_param)
- return concat_param_;
-}
-inline ::caffe::ConcatParameter* V1LayerParameter::release_concat_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.concat_param)
- clear_has_concat_param();
- ::caffe::ConcatParameter* temp = concat_param_;
- concat_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_concat_param(::caffe::ConcatParameter* concat_param) {
- delete concat_param_;
- concat_param_ = concat_param;
- if (concat_param) {
- set_has_concat_param();
- } else {
- clear_has_concat_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.concat_param)
-}
-
-// optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40;
-inline bool V1LayerParameter::has_contrastive_loss_param() const {
- return (_has_bits_[0] & 0x00008000u) != 0;
-}
-inline void V1LayerParameter::set_has_contrastive_loss_param() {
- _has_bits_[0] |= 0x00008000u;
-}
-inline void V1LayerParameter::clear_has_contrastive_loss_param() {
- _has_bits_[0] &= ~0x00008000u;
-}
-inline void V1LayerParameter::clear_contrastive_loss_param() {
- if (contrastive_loss_param_ != NULL) contrastive_loss_param_->::caffe::ContrastiveLossParameter::Clear();
- clear_has_contrastive_loss_param();
-}
-inline const ::caffe::ContrastiveLossParameter& V1LayerParameter::contrastive_loss_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.contrastive_loss_param)
- return contrastive_loss_param_ != NULL ? *contrastive_loss_param_
- : *::caffe::ContrastiveLossParameter::internal_default_instance();
-}
-inline ::caffe::ContrastiveLossParameter* V1LayerParameter::mutable_contrastive_loss_param() {
- set_has_contrastive_loss_param();
- if (contrastive_loss_param_ == NULL) {
- contrastive_loss_param_ = new ::caffe::ContrastiveLossParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.contrastive_loss_param)
- return contrastive_loss_param_;
-}
-inline ::caffe::ContrastiveLossParameter* V1LayerParameter::release_contrastive_loss_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.contrastive_loss_param)
- clear_has_contrastive_loss_param();
- ::caffe::ContrastiveLossParameter* temp = contrastive_loss_param_;
- contrastive_loss_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_contrastive_loss_param(::caffe::ContrastiveLossParameter* contrastive_loss_param) {
- delete contrastive_loss_param_;
- contrastive_loss_param_ = contrastive_loss_param;
- if (contrastive_loss_param) {
- set_has_contrastive_loss_param();
- } else {
- clear_has_contrastive_loss_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.contrastive_loss_param)
-}
-
-// optional .caffe.ConvolutionParameter convolution_param = 10;
-inline bool V1LayerParameter::has_convolution_param() const {
- return (_has_bits_[0] & 0x00010000u) != 0;
-}
-inline void V1LayerParameter::set_has_convolution_param() {
- _has_bits_[0] |= 0x00010000u;
-}
-inline void V1LayerParameter::clear_has_convolution_param() {
- _has_bits_[0] &= ~0x00010000u;
-}
-inline void V1LayerParameter::clear_convolution_param() {
- if (convolution_param_ != NULL) convolution_param_->::caffe::ConvolutionParameter::Clear();
- clear_has_convolution_param();
-}
-inline const ::caffe::ConvolutionParameter& V1LayerParameter::convolution_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.convolution_param)
- return convolution_param_ != NULL ? *convolution_param_
- : *::caffe::ConvolutionParameter::internal_default_instance();
-}
-inline ::caffe::ConvolutionParameter* V1LayerParameter::mutable_convolution_param() {
- set_has_convolution_param();
- if (convolution_param_ == NULL) {
- convolution_param_ = new ::caffe::ConvolutionParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.convolution_param)
- return convolution_param_;
-}
-inline ::caffe::ConvolutionParameter* V1LayerParameter::release_convolution_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.convolution_param)
- clear_has_convolution_param();
- ::caffe::ConvolutionParameter* temp = convolution_param_;
- convolution_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_convolution_param(::caffe::ConvolutionParameter* convolution_param) {
- delete convolution_param_;
- convolution_param_ = convolution_param;
- if (convolution_param) {
- set_has_convolution_param();
- } else {
- clear_has_convolution_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.convolution_param)
-}
-
-// optional .caffe.DataParameter data_param = 11;
-inline bool V1LayerParameter::has_data_param() const {
- return (_has_bits_[0] & 0x00020000u) != 0;
-}
-inline void V1LayerParameter::set_has_data_param() {
- _has_bits_[0] |= 0x00020000u;
-}
-inline void V1LayerParameter::clear_has_data_param() {
- _has_bits_[0] &= ~0x00020000u;
-}
-inline void V1LayerParameter::clear_data_param() {
- if (data_param_ != NULL) data_param_->::caffe::DataParameter::Clear();
- clear_has_data_param();
-}
-inline const ::caffe::DataParameter& V1LayerParameter::data_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.data_param)
- return data_param_ != NULL ? *data_param_
- : *::caffe::DataParameter::internal_default_instance();
-}
-inline ::caffe::DataParameter* V1LayerParameter::mutable_data_param() {
- set_has_data_param();
- if (data_param_ == NULL) {
- data_param_ = new ::caffe::DataParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.data_param)
- return data_param_;
-}
-inline ::caffe::DataParameter* V1LayerParameter::release_data_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.data_param)
- clear_has_data_param();
- ::caffe::DataParameter* temp = data_param_;
- data_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_data_param(::caffe::DataParameter* data_param) {
- delete data_param_;
- data_param_ = data_param;
- if (data_param) {
- set_has_data_param();
- } else {
- clear_has_data_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.data_param)
-}
-
-// optional .caffe.DropoutParameter dropout_param = 12;
-inline bool V1LayerParameter::has_dropout_param() const {
- return (_has_bits_[0] & 0x00040000u) != 0;
-}
-inline void V1LayerParameter::set_has_dropout_param() {
- _has_bits_[0] |= 0x00040000u;
-}
-inline void V1LayerParameter::clear_has_dropout_param() {
- _has_bits_[0] &= ~0x00040000u;
-}
-inline void V1LayerParameter::clear_dropout_param() {
- if (dropout_param_ != NULL) dropout_param_->::caffe::DropoutParameter::Clear();
- clear_has_dropout_param();
-}
-inline const ::caffe::DropoutParameter& V1LayerParameter::dropout_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.dropout_param)
- return dropout_param_ != NULL ? *dropout_param_
- : *::caffe::DropoutParameter::internal_default_instance();
-}
-inline ::caffe::DropoutParameter* V1LayerParameter::mutable_dropout_param() {
- set_has_dropout_param();
- if (dropout_param_ == NULL) {
- dropout_param_ = new ::caffe::DropoutParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.dropout_param)
- return dropout_param_;
-}
-inline ::caffe::DropoutParameter* V1LayerParameter::release_dropout_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.dropout_param)
- clear_has_dropout_param();
- ::caffe::DropoutParameter* temp = dropout_param_;
- dropout_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_dropout_param(::caffe::DropoutParameter* dropout_param) {
- delete dropout_param_;
- dropout_param_ = dropout_param;
- if (dropout_param) {
- set_has_dropout_param();
- } else {
- clear_has_dropout_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.dropout_param)
-}
-
-// optional .caffe.DummyDataParameter dummy_data_param = 26;
-inline bool V1LayerParameter::has_dummy_data_param() const {
- return (_has_bits_[0] & 0x00080000u) != 0;
-}
-inline void V1LayerParameter::set_has_dummy_data_param() {
- _has_bits_[0] |= 0x00080000u;
-}
-inline void V1LayerParameter::clear_has_dummy_data_param() {
- _has_bits_[0] &= ~0x00080000u;
-}
-inline void V1LayerParameter::clear_dummy_data_param() {
- if (dummy_data_param_ != NULL) dummy_data_param_->::caffe::DummyDataParameter::Clear();
- clear_has_dummy_data_param();
-}
-inline const ::caffe::DummyDataParameter& V1LayerParameter::dummy_data_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.dummy_data_param)
- return dummy_data_param_ != NULL ? *dummy_data_param_
- : *::caffe::DummyDataParameter::internal_default_instance();
-}
-inline ::caffe::DummyDataParameter* V1LayerParameter::mutable_dummy_data_param() {
- set_has_dummy_data_param();
- if (dummy_data_param_ == NULL) {
- dummy_data_param_ = new ::caffe::DummyDataParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.dummy_data_param)
- return dummy_data_param_;
-}
-inline ::caffe::DummyDataParameter* V1LayerParameter::release_dummy_data_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.dummy_data_param)
- clear_has_dummy_data_param();
- ::caffe::DummyDataParameter* temp = dummy_data_param_;
- dummy_data_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_dummy_data_param(::caffe::DummyDataParameter* dummy_data_param) {
- delete dummy_data_param_;
- dummy_data_param_ = dummy_data_param;
- if (dummy_data_param) {
- set_has_dummy_data_param();
- } else {
- clear_has_dummy_data_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.dummy_data_param)
-}
-
-// optional .caffe.EltwiseParameter eltwise_param = 24;
-inline bool V1LayerParameter::has_eltwise_param() const {
- return (_has_bits_[0] & 0x00100000u) != 0;
-}
-inline void V1LayerParameter::set_has_eltwise_param() {
- _has_bits_[0] |= 0x00100000u;
-}
-inline void V1LayerParameter::clear_has_eltwise_param() {
- _has_bits_[0] &= ~0x00100000u;
-}
-inline void V1LayerParameter::clear_eltwise_param() {
- if (eltwise_param_ != NULL) eltwise_param_->::caffe::EltwiseParameter::Clear();
- clear_has_eltwise_param();
-}
-inline const ::caffe::EltwiseParameter& V1LayerParameter::eltwise_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.eltwise_param)
- return eltwise_param_ != NULL ? *eltwise_param_
- : *::caffe::EltwiseParameter::internal_default_instance();
-}
-inline ::caffe::EltwiseParameter* V1LayerParameter::mutable_eltwise_param() {
- set_has_eltwise_param();
- if (eltwise_param_ == NULL) {
- eltwise_param_ = new ::caffe::EltwiseParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.eltwise_param)
- return eltwise_param_;
-}
-inline ::caffe::EltwiseParameter* V1LayerParameter::release_eltwise_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.eltwise_param)
- clear_has_eltwise_param();
- ::caffe::EltwiseParameter* temp = eltwise_param_;
- eltwise_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_eltwise_param(::caffe::EltwiseParameter* eltwise_param) {
- delete eltwise_param_;
- eltwise_param_ = eltwise_param;
- if (eltwise_param) {
- set_has_eltwise_param();
- } else {
- clear_has_eltwise_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.eltwise_param)
-}
-
-// optional .caffe.ExpParameter exp_param = 41;
-inline bool V1LayerParameter::has_exp_param() const {
- return (_has_bits_[0] & 0x00200000u) != 0;
-}
-inline void V1LayerParameter::set_has_exp_param() {
- _has_bits_[0] |= 0x00200000u;
-}
-inline void V1LayerParameter::clear_has_exp_param() {
- _has_bits_[0] &= ~0x00200000u;
-}
-inline void V1LayerParameter::clear_exp_param() {
- if (exp_param_ != NULL) exp_param_->::caffe::ExpParameter::Clear();
- clear_has_exp_param();
-}
-inline const ::caffe::ExpParameter& V1LayerParameter::exp_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.exp_param)
- return exp_param_ != NULL ? *exp_param_
- : *::caffe::ExpParameter::internal_default_instance();
-}
-inline ::caffe::ExpParameter* V1LayerParameter::mutable_exp_param() {
- set_has_exp_param();
- if (exp_param_ == NULL) {
- exp_param_ = new ::caffe::ExpParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.exp_param)
- return exp_param_;
-}
-inline ::caffe::ExpParameter* V1LayerParameter::release_exp_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.exp_param)
- clear_has_exp_param();
- ::caffe::ExpParameter* temp = exp_param_;
- exp_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_exp_param(::caffe::ExpParameter* exp_param) {
- delete exp_param_;
- exp_param_ = exp_param;
- if (exp_param) {
- set_has_exp_param();
- } else {
- clear_has_exp_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.exp_param)
-}
-
-// optional .caffe.HDF5DataParameter hdf5_data_param = 13;
-inline bool V1LayerParameter::has_hdf5_data_param() const {
- return (_has_bits_[0] & 0x00400000u) != 0;
-}
-inline void V1LayerParameter::set_has_hdf5_data_param() {
- _has_bits_[0] |= 0x00400000u;
-}
-inline void V1LayerParameter::clear_has_hdf5_data_param() {
- _has_bits_[0] &= ~0x00400000u;
-}
-inline void V1LayerParameter::clear_hdf5_data_param() {
- if (hdf5_data_param_ != NULL) hdf5_data_param_->::caffe::HDF5DataParameter::Clear();
- clear_has_hdf5_data_param();
-}
-inline const ::caffe::HDF5DataParameter& V1LayerParameter::hdf5_data_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.hdf5_data_param)
- return hdf5_data_param_ != NULL ? *hdf5_data_param_
- : *::caffe::HDF5DataParameter::internal_default_instance();
-}
-inline ::caffe::HDF5DataParameter* V1LayerParameter::mutable_hdf5_data_param() {
- set_has_hdf5_data_param();
- if (hdf5_data_param_ == NULL) {
- hdf5_data_param_ = new ::caffe::HDF5DataParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.hdf5_data_param)
- return hdf5_data_param_;
-}
-inline ::caffe::HDF5DataParameter* V1LayerParameter::release_hdf5_data_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.hdf5_data_param)
- clear_has_hdf5_data_param();
- ::caffe::HDF5DataParameter* temp = hdf5_data_param_;
- hdf5_data_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_hdf5_data_param(::caffe::HDF5DataParameter* hdf5_data_param) {
- delete hdf5_data_param_;
- hdf5_data_param_ = hdf5_data_param;
- if (hdf5_data_param) {
- set_has_hdf5_data_param();
- } else {
- clear_has_hdf5_data_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.hdf5_data_param)
-}
-
-// optional .caffe.HDF5OutputParameter hdf5_output_param = 14;
-inline bool V1LayerParameter::has_hdf5_output_param() const {
- return (_has_bits_[0] & 0x00800000u) != 0;
-}
-inline void V1LayerParameter::set_has_hdf5_output_param() {
- _has_bits_[0] |= 0x00800000u;
-}
-inline void V1LayerParameter::clear_has_hdf5_output_param() {
- _has_bits_[0] &= ~0x00800000u;
-}
-inline void V1LayerParameter::clear_hdf5_output_param() {
- if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear();
- clear_has_hdf5_output_param();
-}
-inline const ::caffe::HDF5OutputParameter& V1LayerParameter::hdf5_output_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.hdf5_output_param)
- return hdf5_output_param_ != NULL ? *hdf5_output_param_
- : *::caffe::HDF5OutputParameter::internal_default_instance();
-}
-inline ::caffe::HDF5OutputParameter* V1LayerParameter::mutable_hdf5_output_param() {
- set_has_hdf5_output_param();
- if (hdf5_output_param_ == NULL) {
- hdf5_output_param_ = new ::caffe::HDF5OutputParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.hdf5_output_param)
- return hdf5_output_param_;
-}
-inline ::caffe::HDF5OutputParameter* V1LayerParameter::release_hdf5_output_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.hdf5_output_param)
- clear_has_hdf5_output_param();
- ::caffe::HDF5OutputParameter* temp = hdf5_output_param_;
- hdf5_output_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param) {
- delete hdf5_output_param_;
- hdf5_output_param_ = hdf5_output_param;
- if (hdf5_output_param) {
- set_has_hdf5_output_param();
- } else {
- clear_has_hdf5_output_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.hdf5_output_param)
-}
-
-// optional .caffe.HingeLossParameter hinge_loss_param = 29;
-inline bool V1LayerParameter::has_hinge_loss_param() const {
- return (_has_bits_[0] & 0x01000000u) != 0;
-}
-inline void V1LayerParameter::set_has_hinge_loss_param() {
- _has_bits_[0] |= 0x01000000u;
-}
-inline void V1LayerParameter::clear_has_hinge_loss_param() {
- _has_bits_[0] &= ~0x01000000u;
-}
-inline void V1LayerParameter::clear_hinge_loss_param() {
- if (hinge_loss_param_ != NULL) hinge_loss_param_->::caffe::HingeLossParameter::Clear();
- clear_has_hinge_loss_param();
-}
-inline const ::caffe::HingeLossParameter& V1LayerParameter::hinge_loss_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.hinge_loss_param)
- return hinge_loss_param_ != NULL ? *hinge_loss_param_
- : *::caffe::HingeLossParameter::internal_default_instance();
-}
-inline ::caffe::HingeLossParameter* V1LayerParameter::mutable_hinge_loss_param() {
- set_has_hinge_loss_param();
- if (hinge_loss_param_ == NULL) {
- hinge_loss_param_ = new ::caffe::HingeLossParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.hinge_loss_param)
- return hinge_loss_param_;
-}
-inline ::caffe::HingeLossParameter* V1LayerParameter::release_hinge_loss_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.hinge_loss_param)
- clear_has_hinge_loss_param();
- ::caffe::HingeLossParameter* temp = hinge_loss_param_;
- hinge_loss_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_hinge_loss_param(::caffe::HingeLossParameter* hinge_loss_param) {
- delete hinge_loss_param_;
- hinge_loss_param_ = hinge_loss_param;
- if (hinge_loss_param) {
- set_has_hinge_loss_param();
- } else {
- clear_has_hinge_loss_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.hinge_loss_param)
-}
-
-// optional .caffe.ImageDataParameter image_data_param = 15;
-inline bool V1LayerParameter::has_image_data_param() const {
- return (_has_bits_[0] & 0x02000000u) != 0;
-}
-inline void V1LayerParameter::set_has_image_data_param() {
- _has_bits_[0] |= 0x02000000u;
-}
-inline void V1LayerParameter::clear_has_image_data_param() {
- _has_bits_[0] &= ~0x02000000u;
-}
-inline void V1LayerParameter::clear_image_data_param() {
- if (image_data_param_ != NULL) image_data_param_->::caffe::ImageDataParameter::Clear();
- clear_has_image_data_param();
-}
-inline const ::caffe::ImageDataParameter& V1LayerParameter::image_data_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.image_data_param)
- return image_data_param_ != NULL ? *image_data_param_
- : *::caffe::ImageDataParameter::internal_default_instance();
-}
-inline ::caffe::ImageDataParameter* V1LayerParameter::mutable_image_data_param() {
- set_has_image_data_param();
- if (image_data_param_ == NULL) {
- image_data_param_ = new ::caffe::ImageDataParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.image_data_param)
- return image_data_param_;
-}
-inline ::caffe::ImageDataParameter* V1LayerParameter::release_image_data_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.image_data_param)
- clear_has_image_data_param();
- ::caffe::ImageDataParameter* temp = image_data_param_;
- image_data_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_image_data_param(::caffe::ImageDataParameter* image_data_param) {
- delete image_data_param_;
- image_data_param_ = image_data_param;
- if (image_data_param) {
- set_has_image_data_param();
- } else {
- clear_has_image_data_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.image_data_param)
-}
-
-// optional .caffe.InfogainLossParameter infogain_loss_param = 16;
-inline bool V1LayerParameter::has_infogain_loss_param() const {
- return (_has_bits_[0] & 0x04000000u) != 0;
-}
-inline void V1LayerParameter::set_has_infogain_loss_param() {
- _has_bits_[0] |= 0x04000000u;
-}
-inline void V1LayerParameter::clear_has_infogain_loss_param() {
- _has_bits_[0] &= ~0x04000000u;
-}
-inline void V1LayerParameter::clear_infogain_loss_param() {
- if (infogain_loss_param_ != NULL) infogain_loss_param_->::caffe::InfogainLossParameter::Clear();
- clear_has_infogain_loss_param();
-}
-inline const ::caffe::InfogainLossParameter& V1LayerParameter::infogain_loss_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.infogain_loss_param)
- return infogain_loss_param_ != NULL ? *infogain_loss_param_
- : *::caffe::InfogainLossParameter::internal_default_instance();
-}
-inline ::caffe::InfogainLossParameter* V1LayerParameter::mutable_infogain_loss_param() {
- set_has_infogain_loss_param();
- if (infogain_loss_param_ == NULL) {
- infogain_loss_param_ = new ::caffe::InfogainLossParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.infogain_loss_param)
- return infogain_loss_param_;
-}
-inline ::caffe::InfogainLossParameter* V1LayerParameter::release_infogain_loss_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.infogain_loss_param)
- clear_has_infogain_loss_param();
- ::caffe::InfogainLossParameter* temp = infogain_loss_param_;
- infogain_loss_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_infogain_loss_param(::caffe::InfogainLossParameter* infogain_loss_param) {
- delete infogain_loss_param_;
- infogain_loss_param_ = infogain_loss_param;
- if (infogain_loss_param) {
- set_has_infogain_loss_param();
- } else {
- clear_has_infogain_loss_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.infogain_loss_param)
-}
-
-// optional .caffe.InnerProductParameter inner_product_param = 17;
-inline bool V1LayerParameter::has_inner_product_param() const {
- return (_has_bits_[0] & 0x08000000u) != 0;
-}
-inline void V1LayerParameter::set_has_inner_product_param() {
- _has_bits_[0] |= 0x08000000u;
-}
-inline void V1LayerParameter::clear_has_inner_product_param() {
- _has_bits_[0] &= ~0x08000000u;
-}
-inline void V1LayerParameter::clear_inner_product_param() {
- if (inner_product_param_ != NULL) inner_product_param_->::caffe::InnerProductParameter::Clear();
- clear_has_inner_product_param();
-}
-inline const ::caffe::InnerProductParameter& V1LayerParameter::inner_product_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.inner_product_param)
- return inner_product_param_ != NULL ? *inner_product_param_
- : *::caffe::InnerProductParameter::internal_default_instance();
-}
-inline ::caffe::InnerProductParameter* V1LayerParameter::mutable_inner_product_param() {
- set_has_inner_product_param();
- if (inner_product_param_ == NULL) {
- inner_product_param_ = new ::caffe::InnerProductParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.inner_product_param)
- return inner_product_param_;
-}
-inline ::caffe::InnerProductParameter* V1LayerParameter::release_inner_product_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.inner_product_param)
- clear_has_inner_product_param();
- ::caffe::InnerProductParameter* temp = inner_product_param_;
- inner_product_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_inner_product_param(::caffe::InnerProductParameter* inner_product_param) {
- delete inner_product_param_;
- inner_product_param_ = inner_product_param;
- if (inner_product_param) {
- set_has_inner_product_param();
- } else {
- clear_has_inner_product_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.inner_product_param)
-}
-
-// optional .caffe.LRNParameter lrn_param = 18;
-inline bool V1LayerParameter::has_lrn_param() const {
- return (_has_bits_[0] & 0x10000000u) != 0;
-}
-inline void V1LayerParameter::set_has_lrn_param() {
- _has_bits_[0] |= 0x10000000u;
-}
-inline void V1LayerParameter::clear_has_lrn_param() {
- _has_bits_[0] &= ~0x10000000u;
-}
-inline void V1LayerParameter::clear_lrn_param() {
- if (lrn_param_ != NULL) lrn_param_->::caffe::LRNParameter::Clear();
- clear_has_lrn_param();
-}
-inline const ::caffe::LRNParameter& V1LayerParameter::lrn_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.lrn_param)
- return lrn_param_ != NULL ? *lrn_param_
- : *::caffe::LRNParameter::internal_default_instance();
-}
-inline ::caffe::LRNParameter* V1LayerParameter::mutable_lrn_param() {
- set_has_lrn_param();
- if (lrn_param_ == NULL) {
- lrn_param_ = new ::caffe::LRNParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.lrn_param)
- return lrn_param_;
-}
-inline ::caffe::LRNParameter* V1LayerParameter::release_lrn_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.lrn_param)
- clear_has_lrn_param();
- ::caffe::LRNParameter* temp = lrn_param_;
- lrn_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_lrn_param(::caffe::LRNParameter* lrn_param) {
- delete lrn_param_;
- lrn_param_ = lrn_param;
- if (lrn_param) {
- set_has_lrn_param();
- } else {
- clear_has_lrn_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.lrn_param)
-}
-
-// optional .caffe.MemoryDataParameter memory_data_param = 22;
-inline bool V1LayerParameter::has_memory_data_param() const {
- return (_has_bits_[0] & 0x20000000u) != 0;
-}
-inline void V1LayerParameter::set_has_memory_data_param() {
- _has_bits_[0] |= 0x20000000u;
-}
-inline void V1LayerParameter::clear_has_memory_data_param() {
- _has_bits_[0] &= ~0x20000000u;
-}
-inline void V1LayerParameter::clear_memory_data_param() {
- if (memory_data_param_ != NULL) memory_data_param_->::caffe::MemoryDataParameter::Clear();
- clear_has_memory_data_param();
-}
-inline const ::caffe::MemoryDataParameter& V1LayerParameter::memory_data_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.memory_data_param)
- return memory_data_param_ != NULL ? *memory_data_param_
- : *::caffe::MemoryDataParameter::internal_default_instance();
-}
-inline ::caffe::MemoryDataParameter* V1LayerParameter::mutable_memory_data_param() {
- set_has_memory_data_param();
- if (memory_data_param_ == NULL) {
- memory_data_param_ = new ::caffe::MemoryDataParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.memory_data_param)
- return memory_data_param_;
-}
-inline ::caffe::MemoryDataParameter* V1LayerParameter::release_memory_data_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.memory_data_param)
- clear_has_memory_data_param();
- ::caffe::MemoryDataParameter* temp = memory_data_param_;
- memory_data_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_memory_data_param(::caffe::MemoryDataParameter* memory_data_param) {
- delete memory_data_param_;
- memory_data_param_ = memory_data_param;
- if (memory_data_param) {
- set_has_memory_data_param();
- } else {
- clear_has_memory_data_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.memory_data_param)
-}
-
-// optional .caffe.MVNParameter mvn_param = 34;
-inline bool V1LayerParameter::has_mvn_param() const {
- return (_has_bits_[0] & 0x40000000u) != 0;
-}
-inline void V1LayerParameter::set_has_mvn_param() {
- _has_bits_[0] |= 0x40000000u;
-}
-inline void V1LayerParameter::clear_has_mvn_param() {
- _has_bits_[0] &= ~0x40000000u;
-}
-inline void V1LayerParameter::clear_mvn_param() {
- if (mvn_param_ != NULL) mvn_param_->::caffe::MVNParameter::Clear();
- clear_has_mvn_param();
-}
-inline const ::caffe::MVNParameter& V1LayerParameter::mvn_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.mvn_param)
- return mvn_param_ != NULL ? *mvn_param_
- : *::caffe::MVNParameter::internal_default_instance();
-}
-inline ::caffe::MVNParameter* V1LayerParameter::mutable_mvn_param() {
- set_has_mvn_param();
- if (mvn_param_ == NULL) {
- mvn_param_ = new ::caffe::MVNParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.mvn_param)
- return mvn_param_;
-}
-inline ::caffe::MVNParameter* V1LayerParameter::release_mvn_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.mvn_param)
- clear_has_mvn_param();
- ::caffe::MVNParameter* temp = mvn_param_;
- mvn_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_mvn_param(::caffe::MVNParameter* mvn_param) {
- delete mvn_param_;
- mvn_param_ = mvn_param;
- if (mvn_param) {
- set_has_mvn_param();
- } else {
- clear_has_mvn_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.mvn_param)
-}
-
-// optional .caffe.PoolingParameter pooling_param = 19;
-inline bool V1LayerParameter::has_pooling_param() const {
- return (_has_bits_[0] & 0x80000000u) != 0;
-}
-inline void V1LayerParameter::set_has_pooling_param() {
- _has_bits_[0] |= 0x80000000u;
-}
-inline void V1LayerParameter::clear_has_pooling_param() {
- _has_bits_[0] &= ~0x80000000u;
-}
-inline void V1LayerParameter::clear_pooling_param() {
- if (pooling_param_ != NULL) pooling_param_->::caffe::PoolingParameter::Clear();
- clear_has_pooling_param();
-}
-inline const ::caffe::PoolingParameter& V1LayerParameter::pooling_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.pooling_param)
- return pooling_param_ != NULL ? *pooling_param_
- : *::caffe::PoolingParameter::internal_default_instance();
-}
-inline ::caffe::PoolingParameter* V1LayerParameter::mutable_pooling_param() {
- set_has_pooling_param();
- if (pooling_param_ == NULL) {
- pooling_param_ = new ::caffe::PoolingParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.pooling_param)
- return pooling_param_;
-}
-inline ::caffe::PoolingParameter* V1LayerParameter::release_pooling_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.pooling_param)
- clear_has_pooling_param();
- ::caffe::PoolingParameter* temp = pooling_param_;
- pooling_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_pooling_param(::caffe::PoolingParameter* pooling_param) {
- delete pooling_param_;
- pooling_param_ = pooling_param;
- if (pooling_param) {
- set_has_pooling_param();
- } else {
- clear_has_pooling_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.pooling_param)
-}
-
-// optional .caffe.PowerParameter power_param = 21;
-inline bool V1LayerParameter::has_power_param() const {
- return (_has_bits_[1] & 0x00000001u) != 0;
-}
-inline void V1LayerParameter::set_has_power_param() {
- _has_bits_[1] |= 0x00000001u;
-}
-inline void V1LayerParameter::clear_has_power_param() {
- _has_bits_[1] &= ~0x00000001u;
-}
-inline void V1LayerParameter::clear_power_param() {
- if (power_param_ != NULL) power_param_->::caffe::PowerParameter::Clear();
- clear_has_power_param();
-}
-inline const ::caffe::PowerParameter& V1LayerParameter::power_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.power_param)
- return power_param_ != NULL ? *power_param_
- : *::caffe::PowerParameter::internal_default_instance();
-}
-inline ::caffe::PowerParameter* V1LayerParameter::mutable_power_param() {
- set_has_power_param();
- if (power_param_ == NULL) {
- power_param_ = new ::caffe::PowerParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.power_param)
- return power_param_;
-}
-inline ::caffe::PowerParameter* V1LayerParameter::release_power_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.power_param)
- clear_has_power_param();
- ::caffe::PowerParameter* temp = power_param_;
- power_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_power_param(::caffe::PowerParameter* power_param) {
- delete power_param_;
- power_param_ = power_param;
- if (power_param) {
- set_has_power_param();
- } else {
- clear_has_power_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.power_param)
-}
-
-// optional .caffe.ReLUParameter relu_param = 30;
-inline bool V1LayerParameter::has_relu_param() const {
- return (_has_bits_[1] & 0x00000002u) != 0;
-}
-inline void V1LayerParameter::set_has_relu_param() {
- _has_bits_[1] |= 0x00000002u;
-}
-inline void V1LayerParameter::clear_has_relu_param() {
- _has_bits_[1] &= ~0x00000002u;
-}
-inline void V1LayerParameter::clear_relu_param() {
- if (relu_param_ != NULL) relu_param_->::caffe::ReLUParameter::Clear();
- clear_has_relu_param();
-}
-inline const ::caffe::ReLUParameter& V1LayerParameter::relu_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.relu_param)
- return relu_param_ != NULL ? *relu_param_
- : *::caffe::ReLUParameter::internal_default_instance();
-}
-inline ::caffe::ReLUParameter* V1LayerParameter::mutable_relu_param() {
- set_has_relu_param();
- if (relu_param_ == NULL) {
- relu_param_ = new ::caffe::ReLUParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.relu_param)
- return relu_param_;
-}
-inline ::caffe::ReLUParameter* V1LayerParameter::release_relu_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.relu_param)
- clear_has_relu_param();
- ::caffe::ReLUParameter* temp = relu_param_;
- relu_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_relu_param(::caffe::ReLUParameter* relu_param) {
- delete relu_param_;
- relu_param_ = relu_param;
- if (relu_param) {
- set_has_relu_param();
- } else {
- clear_has_relu_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.relu_param)
-}
-
-// optional .caffe.SigmoidParameter sigmoid_param = 38;
-inline bool V1LayerParameter::has_sigmoid_param() const {
- return (_has_bits_[1] & 0x00000004u) != 0;
-}
-inline void V1LayerParameter::set_has_sigmoid_param() {
- _has_bits_[1] |= 0x00000004u;
-}
-inline void V1LayerParameter::clear_has_sigmoid_param() {
- _has_bits_[1] &= ~0x00000004u;
-}
-inline void V1LayerParameter::clear_sigmoid_param() {
- if (sigmoid_param_ != NULL) sigmoid_param_->::caffe::SigmoidParameter::Clear();
- clear_has_sigmoid_param();
-}
-inline const ::caffe::SigmoidParameter& V1LayerParameter::sigmoid_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.sigmoid_param)
- return sigmoid_param_ != NULL ? *sigmoid_param_
- : *::caffe::SigmoidParameter::internal_default_instance();
-}
-inline ::caffe::SigmoidParameter* V1LayerParameter::mutable_sigmoid_param() {
- set_has_sigmoid_param();
- if (sigmoid_param_ == NULL) {
- sigmoid_param_ = new ::caffe::SigmoidParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.sigmoid_param)
- return sigmoid_param_;
-}
-inline ::caffe::SigmoidParameter* V1LayerParameter::release_sigmoid_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.sigmoid_param)
- clear_has_sigmoid_param();
- ::caffe::SigmoidParameter* temp = sigmoid_param_;
- sigmoid_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_sigmoid_param(::caffe::SigmoidParameter* sigmoid_param) {
- delete sigmoid_param_;
- sigmoid_param_ = sigmoid_param;
- if (sigmoid_param) {
- set_has_sigmoid_param();
- } else {
- clear_has_sigmoid_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.sigmoid_param)
-}
-
-// optional .caffe.SoftmaxParameter softmax_param = 39;
-inline bool V1LayerParameter::has_softmax_param() const {
- return (_has_bits_[1] & 0x00000008u) != 0;
-}
-inline void V1LayerParameter::set_has_softmax_param() {
- _has_bits_[1] |= 0x00000008u;
-}
-inline void V1LayerParameter::clear_has_softmax_param() {
- _has_bits_[1] &= ~0x00000008u;
-}
-inline void V1LayerParameter::clear_softmax_param() {
- if (softmax_param_ != NULL) softmax_param_->::caffe::SoftmaxParameter::Clear();
- clear_has_softmax_param();
-}
-inline const ::caffe::SoftmaxParameter& V1LayerParameter::softmax_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.softmax_param)
- return softmax_param_ != NULL ? *softmax_param_
- : *::caffe::SoftmaxParameter::internal_default_instance();
-}
-inline ::caffe::SoftmaxParameter* V1LayerParameter::mutable_softmax_param() {
- set_has_softmax_param();
- if (softmax_param_ == NULL) {
- softmax_param_ = new ::caffe::SoftmaxParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.softmax_param)
- return softmax_param_;
-}
-inline ::caffe::SoftmaxParameter* V1LayerParameter::release_softmax_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.softmax_param)
- clear_has_softmax_param();
- ::caffe::SoftmaxParameter* temp = softmax_param_;
- softmax_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_softmax_param(::caffe::SoftmaxParameter* softmax_param) {
- delete softmax_param_;
- softmax_param_ = softmax_param;
- if (softmax_param) {
- set_has_softmax_param();
- } else {
- clear_has_softmax_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.softmax_param)
-}
-
-// optional .caffe.SliceParameter slice_param = 31;
-inline bool V1LayerParameter::has_slice_param() const {
- return (_has_bits_[1] & 0x00000010u) != 0;
-}
-inline void V1LayerParameter::set_has_slice_param() {
- _has_bits_[1] |= 0x00000010u;
-}
-inline void V1LayerParameter::clear_has_slice_param() {
- _has_bits_[1] &= ~0x00000010u;
-}
-inline void V1LayerParameter::clear_slice_param() {
- if (slice_param_ != NULL) slice_param_->::caffe::SliceParameter::Clear();
- clear_has_slice_param();
-}
-inline const ::caffe::SliceParameter& V1LayerParameter::slice_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.slice_param)
- return slice_param_ != NULL ? *slice_param_
- : *::caffe::SliceParameter::internal_default_instance();
-}
-inline ::caffe::SliceParameter* V1LayerParameter::mutable_slice_param() {
- set_has_slice_param();
- if (slice_param_ == NULL) {
- slice_param_ = new ::caffe::SliceParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.slice_param)
- return slice_param_;
-}
-inline ::caffe::SliceParameter* V1LayerParameter::release_slice_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.slice_param)
- clear_has_slice_param();
- ::caffe::SliceParameter* temp = slice_param_;
- slice_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_slice_param(::caffe::SliceParameter* slice_param) {
- delete slice_param_;
- slice_param_ = slice_param;
- if (slice_param) {
- set_has_slice_param();
- } else {
- clear_has_slice_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.slice_param)
-}
-
-// optional .caffe.TanHParameter tanh_param = 37;
-inline bool V1LayerParameter::has_tanh_param() const {
- return (_has_bits_[1] & 0x00000020u) != 0;
-}
-inline void V1LayerParameter::set_has_tanh_param() {
- _has_bits_[1] |= 0x00000020u;
-}
-inline void V1LayerParameter::clear_has_tanh_param() {
- _has_bits_[1] &= ~0x00000020u;
-}
-inline void V1LayerParameter::clear_tanh_param() {
- if (tanh_param_ != NULL) tanh_param_->::caffe::TanHParameter::Clear();
- clear_has_tanh_param();
-}
-inline const ::caffe::TanHParameter& V1LayerParameter::tanh_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.tanh_param)
- return tanh_param_ != NULL ? *tanh_param_
- : *::caffe::TanHParameter::internal_default_instance();
-}
-inline ::caffe::TanHParameter* V1LayerParameter::mutable_tanh_param() {
- set_has_tanh_param();
- if (tanh_param_ == NULL) {
- tanh_param_ = new ::caffe::TanHParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.tanh_param)
- return tanh_param_;
-}
-inline ::caffe::TanHParameter* V1LayerParameter::release_tanh_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.tanh_param)
- clear_has_tanh_param();
- ::caffe::TanHParameter* temp = tanh_param_;
- tanh_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_tanh_param(::caffe::TanHParameter* tanh_param) {
- delete tanh_param_;
- tanh_param_ = tanh_param;
- if (tanh_param) {
- set_has_tanh_param();
- } else {
- clear_has_tanh_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.tanh_param)
-}
-
-// optional .caffe.ThresholdParameter threshold_param = 25;
-inline bool V1LayerParameter::has_threshold_param() const {
- return (_has_bits_[1] & 0x00000040u) != 0;
-}
-inline void V1LayerParameter::set_has_threshold_param() {
- _has_bits_[1] |= 0x00000040u;
-}
-inline void V1LayerParameter::clear_has_threshold_param() {
- _has_bits_[1] &= ~0x00000040u;
-}
-inline void V1LayerParameter::clear_threshold_param() {
- if (threshold_param_ != NULL) threshold_param_->::caffe::ThresholdParameter::Clear();
- clear_has_threshold_param();
-}
-inline const ::caffe::ThresholdParameter& V1LayerParameter::threshold_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.threshold_param)
- return threshold_param_ != NULL ? *threshold_param_
- : *::caffe::ThresholdParameter::internal_default_instance();
-}
-inline ::caffe::ThresholdParameter* V1LayerParameter::mutable_threshold_param() {
- set_has_threshold_param();
- if (threshold_param_ == NULL) {
- threshold_param_ = new ::caffe::ThresholdParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.threshold_param)
- return threshold_param_;
-}
-inline ::caffe::ThresholdParameter* V1LayerParameter::release_threshold_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.threshold_param)
- clear_has_threshold_param();
- ::caffe::ThresholdParameter* temp = threshold_param_;
- threshold_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_threshold_param(::caffe::ThresholdParameter* threshold_param) {
- delete threshold_param_;
- threshold_param_ = threshold_param;
- if (threshold_param) {
- set_has_threshold_param();
- } else {
- clear_has_threshold_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.threshold_param)
-}
-
-// optional .caffe.WindowDataParameter window_data_param = 20;
-inline bool V1LayerParameter::has_window_data_param() const {
- return (_has_bits_[1] & 0x00000080u) != 0;
-}
-inline void V1LayerParameter::set_has_window_data_param() {
- _has_bits_[1] |= 0x00000080u;
-}
-inline void V1LayerParameter::clear_has_window_data_param() {
- _has_bits_[1] &= ~0x00000080u;
-}
-inline void V1LayerParameter::clear_window_data_param() {
- if (window_data_param_ != NULL) window_data_param_->::caffe::WindowDataParameter::Clear();
- clear_has_window_data_param();
-}
-inline const ::caffe::WindowDataParameter& V1LayerParameter::window_data_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.window_data_param)
- return window_data_param_ != NULL ? *window_data_param_
- : *::caffe::WindowDataParameter::internal_default_instance();
-}
-inline ::caffe::WindowDataParameter* V1LayerParameter::mutable_window_data_param() {
- set_has_window_data_param();
- if (window_data_param_ == NULL) {
- window_data_param_ = new ::caffe::WindowDataParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.window_data_param)
- return window_data_param_;
-}
-inline ::caffe::WindowDataParameter* V1LayerParameter::release_window_data_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.window_data_param)
- clear_has_window_data_param();
- ::caffe::WindowDataParameter* temp = window_data_param_;
- window_data_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_window_data_param(::caffe::WindowDataParameter* window_data_param) {
- delete window_data_param_;
- window_data_param_ = window_data_param;
- if (window_data_param) {
- set_has_window_data_param();
- } else {
- clear_has_window_data_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.window_data_param)
-}
-
-// optional .caffe.TransformationParameter transform_param = 36;
-inline bool V1LayerParameter::has_transform_param() const {
- return (_has_bits_[1] & 0x00000100u) != 0;
-}
-inline void V1LayerParameter::set_has_transform_param() {
- _has_bits_[1] |= 0x00000100u;
-}
-inline void V1LayerParameter::clear_has_transform_param() {
- _has_bits_[1] &= ~0x00000100u;
-}
-inline void V1LayerParameter::clear_transform_param() {
- if (transform_param_ != NULL) transform_param_->::caffe::TransformationParameter::Clear();
- clear_has_transform_param();
-}
-inline const ::caffe::TransformationParameter& V1LayerParameter::transform_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.transform_param)
- return transform_param_ != NULL ? *transform_param_
- : *::caffe::TransformationParameter::internal_default_instance();
-}
-inline ::caffe::TransformationParameter* V1LayerParameter::mutable_transform_param() {
- set_has_transform_param();
- if (transform_param_ == NULL) {
- transform_param_ = new ::caffe::TransformationParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.transform_param)
- return transform_param_;
-}
-inline ::caffe::TransformationParameter* V1LayerParameter::release_transform_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.transform_param)
- clear_has_transform_param();
- ::caffe::TransformationParameter* temp = transform_param_;
- transform_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_transform_param(::caffe::TransformationParameter* transform_param) {
- delete transform_param_;
- transform_param_ = transform_param;
- if (transform_param) {
- set_has_transform_param();
- } else {
- clear_has_transform_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.transform_param)
-}
-
-// optional .caffe.LossParameter loss_param = 42;
-inline bool V1LayerParameter::has_loss_param() const {
- return (_has_bits_[1] & 0x00000200u) != 0;
-}
-inline void V1LayerParameter::set_has_loss_param() {
- _has_bits_[1] |= 0x00000200u;
-}
-inline void V1LayerParameter::clear_has_loss_param() {
- _has_bits_[1] &= ~0x00000200u;
-}
-inline void V1LayerParameter::clear_loss_param() {
- if (loss_param_ != NULL) loss_param_->::caffe::LossParameter::Clear();
- clear_has_loss_param();
-}
-inline const ::caffe::LossParameter& V1LayerParameter::loss_param() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.loss_param)
- return loss_param_ != NULL ? *loss_param_
- : *::caffe::LossParameter::internal_default_instance();
-}
-inline ::caffe::LossParameter* V1LayerParameter::mutable_loss_param() {
- set_has_loss_param();
- if (loss_param_ == NULL) {
- loss_param_ = new ::caffe::LossParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.loss_param)
- return loss_param_;
-}
-inline ::caffe::LossParameter* V1LayerParameter::release_loss_param() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.loss_param)
- clear_has_loss_param();
- ::caffe::LossParameter* temp = loss_param_;
- loss_param_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_loss_param(::caffe::LossParameter* loss_param) {
- delete loss_param_;
- loss_param_ = loss_param;
- if (loss_param) {
- set_has_loss_param();
- } else {
- clear_has_loss_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.loss_param)
-}
-
-// optional .caffe.V0LayerParameter layer = 1;
-inline bool V1LayerParameter::has_layer() const {
- return (_has_bits_[1] & 0x00000400u) != 0;
-}
-inline void V1LayerParameter::set_has_layer() {
- _has_bits_[1] |= 0x00000400u;
-}
-inline void V1LayerParameter::clear_has_layer() {
- _has_bits_[1] &= ~0x00000400u;
-}
-inline void V1LayerParameter::clear_layer() {
- if (layer_ != NULL) layer_->::caffe::V0LayerParameter::Clear();
- clear_has_layer();
-}
-inline const ::caffe::V0LayerParameter& V1LayerParameter::layer() const {
- // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.layer)
- return layer_ != NULL ? *layer_
- : *::caffe::V0LayerParameter::internal_default_instance();
-}
-inline ::caffe::V0LayerParameter* V1LayerParameter::mutable_layer() {
- set_has_layer();
- if (layer_ == NULL) {
- layer_ = new ::caffe::V0LayerParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.layer)
- return layer_;
-}
-inline ::caffe::V0LayerParameter* V1LayerParameter::release_layer() {
- // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.layer)
- clear_has_layer();
- ::caffe::V0LayerParameter* temp = layer_;
- layer_ = NULL;
- return temp;
-}
-inline void V1LayerParameter::set_allocated_layer(::caffe::V0LayerParameter* layer) {
- delete layer_;
- layer_ = layer;
- if (layer) {
- set_has_layer();
- } else {
- clear_has_layer();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.layer)
-}
-
-inline const V1LayerParameter* V1LayerParameter::internal_default_instance() {
- return &V1LayerParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// V0LayerParameter
-
-// optional string name = 1;
-inline bool V0LayerParameter::has_name() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void V0LayerParameter::set_has_name() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void V0LayerParameter::clear_has_name() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void V0LayerParameter::clear_name() {
- name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_name();
-}
-inline const ::std::string& V0LayerParameter::name() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.name)
- return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void V0LayerParameter::set_name(const ::std::string& value) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.name)
-}
-inline void V0LayerParameter::set_name(const char* value) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.name)
-}
-inline void V0LayerParameter::set_name(const char* value, size_t size) {
- set_has_name();
- name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.name)
-}
-inline ::std::string* V0LayerParameter::mutable_name() {
- set_has_name();
- // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.name)
- return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* V0LayerParameter::release_name() {
- // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.name)
- clear_has_name();
- return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void V0LayerParameter::set_allocated_name(::std::string* name) {
- if (name != NULL) {
- set_has_name();
- } else {
- clear_has_name();
- }
- name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
- // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.name)
-}
-
-// optional string type = 2;
-inline bool V0LayerParameter::has_type() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void V0LayerParameter::set_has_type() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void V0LayerParameter::clear_has_type() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void V0LayerParameter::clear_type() {
- type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_type();
-}
-inline const ::std::string& V0LayerParameter::type() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.type)
- return type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void V0LayerParameter::set_type(const ::std::string& value) {
- set_has_type();
- type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.type)
-}
-inline void V0LayerParameter::set_type(const char* value) {
- set_has_type();
- type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.type)
-}
-inline void V0LayerParameter::set_type(const char* value, size_t size) {
- set_has_type();
- type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.type)
-}
-inline ::std::string* V0LayerParameter::mutable_type() {
- set_has_type();
- // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.type)
- return type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* V0LayerParameter::release_type() {
- // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.type)
- clear_has_type();
- return type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void V0LayerParameter::set_allocated_type(::std::string* type) {
- if (type != NULL) {
- set_has_type();
- } else {
- clear_has_type();
- }
- type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type);
- // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.type)
-}
-
-// optional uint32 num_output = 3;
-inline bool V0LayerParameter::has_num_output() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void V0LayerParameter::set_has_num_output() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void V0LayerParameter::clear_has_num_output() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void V0LayerParameter::clear_num_output() {
- num_output_ = 0u;
- clear_has_num_output();
-}
-inline ::google::protobuf::uint32 V0LayerParameter::num_output() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.num_output)
- return num_output_;
-}
-inline void V0LayerParameter::set_num_output(::google::protobuf::uint32 value) {
- set_has_num_output();
- num_output_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.num_output)
-}
-
-// optional bool biasterm = 4 [default = true];
-inline bool V0LayerParameter::has_biasterm() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void V0LayerParameter::set_has_biasterm() {
- _has_bits_[0] |= 0x00000008u;
-}
-inline void V0LayerParameter::clear_has_biasterm() {
- _has_bits_[0] &= ~0x00000008u;
-}
-inline void V0LayerParameter::clear_biasterm() {
- biasterm_ = true;
- clear_has_biasterm();
-}
-inline bool V0LayerParameter::biasterm() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.biasterm)
- return biasterm_;
-}
-inline void V0LayerParameter::set_biasterm(bool value) {
- set_has_biasterm();
- biasterm_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.biasterm)
-}
-
-// optional .caffe.FillerParameter weight_filler = 5;
-inline bool V0LayerParameter::has_weight_filler() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-inline void V0LayerParameter::set_has_weight_filler() {
- _has_bits_[0] |= 0x00000010u;
-}
-inline void V0LayerParameter::clear_has_weight_filler() {
- _has_bits_[0] &= ~0x00000010u;
-}
-inline void V0LayerParameter::clear_weight_filler() {
- if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear();
- clear_has_weight_filler();
-}
-inline const ::caffe::FillerParameter& V0LayerParameter::weight_filler() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.weight_filler)
- return weight_filler_ != NULL ? *weight_filler_
- : *::caffe::FillerParameter::internal_default_instance();
-}
-inline ::caffe::FillerParameter* V0LayerParameter::mutable_weight_filler() {
- set_has_weight_filler();
- if (weight_filler_ == NULL) {
- weight_filler_ = new ::caffe::FillerParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.weight_filler)
- return weight_filler_;
-}
-inline ::caffe::FillerParameter* V0LayerParameter::release_weight_filler() {
- // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.weight_filler)
- clear_has_weight_filler();
- ::caffe::FillerParameter* temp = weight_filler_;
- weight_filler_ = NULL;
- return temp;
-}
-inline void V0LayerParameter::set_allocated_weight_filler(::caffe::FillerParameter* weight_filler) {
- delete weight_filler_;
- weight_filler_ = weight_filler;
- if (weight_filler) {
- set_has_weight_filler();
- } else {
- clear_has_weight_filler();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.weight_filler)
-}
-
-// optional .caffe.FillerParameter bias_filler = 6;
-inline bool V0LayerParameter::has_bias_filler() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-inline void V0LayerParameter::set_has_bias_filler() {
- _has_bits_[0] |= 0x00000020u;
-}
-inline void V0LayerParameter::clear_has_bias_filler() {
- _has_bits_[0] &= ~0x00000020u;
-}
-inline void V0LayerParameter::clear_bias_filler() {
- if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
- clear_has_bias_filler();
-}
-inline const ::caffe::FillerParameter& V0LayerParameter::bias_filler() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.bias_filler)
- return bias_filler_ != NULL ? *bias_filler_
- : *::caffe::FillerParameter::internal_default_instance();
-}
-inline ::caffe::FillerParameter* V0LayerParameter::mutable_bias_filler() {
- set_has_bias_filler();
- if (bias_filler_ == NULL) {
- bias_filler_ = new ::caffe::FillerParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.bias_filler)
- return bias_filler_;
-}
-inline ::caffe::FillerParameter* V0LayerParameter::release_bias_filler() {
- // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.bias_filler)
- clear_has_bias_filler();
- ::caffe::FillerParameter* temp = bias_filler_;
- bias_filler_ = NULL;
- return temp;
-}
-inline void V0LayerParameter::set_allocated_bias_filler(::caffe::FillerParameter* bias_filler) {
- delete bias_filler_;
- bias_filler_ = bias_filler;
- if (bias_filler) {
- set_has_bias_filler();
- } else {
- clear_has_bias_filler();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.bias_filler)
-}
-
-// optional uint32 pad = 7 [default = 0];
-inline bool V0LayerParameter::has_pad() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-inline void V0LayerParameter::set_has_pad() {
- _has_bits_[0] |= 0x00000040u;
-}
-inline void V0LayerParameter::clear_has_pad() {
- _has_bits_[0] &= ~0x00000040u;
-}
-inline void V0LayerParameter::clear_pad() {
- pad_ = 0u;
- clear_has_pad();
-}
-inline ::google::protobuf::uint32 V0LayerParameter::pad() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.pad)
- return pad_;
-}
-inline void V0LayerParameter::set_pad(::google::protobuf::uint32 value) {
- set_has_pad();
- pad_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.pad)
-}
-
-// optional uint32 kernelsize = 8;
-inline bool V0LayerParameter::has_kernelsize() const {
- return (_has_bits_[0] & 0x00000080u) != 0;
-}
-inline void V0LayerParameter::set_has_kernelsize() {
- _has_bits_[0] |= 0x00000080u;
-}
-inline void V0LayerParameter::clear_has_kernelsize() {
- _has_bits_[0] &= ~0x00000080u;
-}
-inline void V0LayerParameter::clear_kernelsize() {
- kernelsize_ = 0u;
- clear_has_kernelsize();
-}
-inline ::google::protobuf::uint32 V0LayerParameter::kernelsize() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.kernelsize)
- return kernelsize_;
-}
-inline void V0LayerParameter::set_kernelsize(::google::protobuf::uint32 value) {
- set_has_kernelsize();
- kernelsize_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.kernelsize)
-}
-
-// optional uint32 group = 9 [default = 1];
-inline bool V0LayerParameter::has_group() const {
- return (_has_bits_[0] & 0x00000100u) != 0;
-}
-inline void V0LayerParameter::set_has_group() {
- _has_bits_[0] |= 0x00000100u;
-}
-inline void V0LayerParameter::clear_has_group() {
- _has_bits_[0] &= ~0x00000100u;
-}
-inline void V0LayerParameter::clear_group() {
- group_ = 1u;
- clear_has_group();
-}
-inline ::google::protobuf::uint32 V0LayerParameter::group() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.group)
- return group_;
-}
-inline void V0LayerParameter::set_group(::google::protobuf::uint32 value) {
- set_has_group();
- group_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.group)
-}
-
-// optional uint32 stride = 10 [default = 1];
-inline bool V0LayerParameter::has_stride() const {
- return (_has_bits_[0] & 0x00000200u) != 0;
-}
-inline void V0LayerParameter::set_has_stride() {
- _has_bits_[0] |= 0x00000200u;
-}
-inline void V0LayerParameter::clear_has_stride() {
- _has_bits_[0] &= ~0x00000200u;
-}
-inline void V0LayerParameter::clear_stride() {
- stride_ = 1u;
- clear_has_stride();
-}
-inline ::google::protobuf::uint32 V0LayerParameter::stride() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.stride)
- return stride_;
-}
-inline void V0LayerParameter::set_stride(::google::protobuf::uint32 value) {
- set_has_stride();
- stride_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.stride)
-}
-
-// optional .caffe.V0LayerParameter.PoolMethod pool = 11 [default = MAX];
-inline bool V0LayerParameter::has_pool() const {
- return (_has_bits_[0] & 0x00000400u) != 0;
-}
-inline void V0LayerParameter::set_has_pool() {
- _has_bits_[0] |= 0x00000400u;
-}
-inline void V0LayerParameter::clear_has_pool() {
- _has_bits_[0] &= ~0x00000400u;
-}
-inline void V0LayerParameter::clear_pool() {
- pool_ = 0;
- clear_has_pool();
-}
-inline ::caffe::V0LayerParameter_PoolMethod V0LayerParameter::pool() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.pool)
- return static_cast< ::caffe::V0LayerParameter_PoolMethod >(pool_);
-}
-inline void V0LayerParameter::set_pool(::caffe::V0LayerParameter_PoolMethod value) {
- assert(::caffe::V0LayerParameter_PoolMethod_IsValid(value));
- set_has_pool();
- pool_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.pool)
-}
-
-// optional float dropout_ratio = 12 [default = 0.5];
-inline bool V0LayerParameter::has_dropout_ratio() const {
- return (_has_bits_[0] & 0x00000800u) != 0;
-}
-inline void V0LayerParameter::set_has_dropout_ratio() {
- _has_bits_[0] |= 0x00000800u;
-}
-inline void V0LayerParameter::clear_has_dropout_ratio() {
- _has_bits_[0] &= ~0x00000800u;
-}
-inline void V0LayerParameter::clear_dropout_ratio() {
- dropout_ratio_ = 0.5f;
- clear_has_dropout_ratio();
-}
-inline float V0LayerParameter::dropout_ratio() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.dropout_ratio)
- return dropout_ratio_;
-}
-inline void V0LayerParameter::set_dropout_ratio(float value) {
- set_has_dropout_ratio();
- dropout_ratio_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.dropout_ratio)
-}
-
-// optional uint32 local_size = 13 [default = 5];
-inline bool V0LayerParameter::has_local_size() const {
- return (_has_bits_[0] & 0x00001000u) != 0;
-}
-inline void V0LayerParameter::set_has_local_size() {
- _has_bits_[0] |= 0x00001000u;
-}
-inline void V0LayerParameter::clear_has_local_size() {
- _has_bits_[0] &= ~0x00001000u;
-}
-inline void V0LayerParameter::clear_local_size() {
- local_size_ = 5u;
- clear_has_local_size();
-}
-inline ::google::protobuf::uint32 V0LayerParameter::local_size() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.local_size)
- return local_size_;
-}
-inline void V0LayerParameter::set_local_size(::google::protobuf::uint32 value) {
- set_has_local_size();
- local_size_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.local_size)
-}
-
-// optional float alpha = 14 [default = 1];
-inline bool V0LayerParameter::has_alpha() const {
- return (_has_bits_[0] & 0x00002000u) != 0;
-}
-inline void V0LayerParameter::set_has_alpha() {
- _has_bits_[0] |= 0x00002000u;
-}
-inline void V0LayerParameter::clear_has_alpha() {
- _has_bits_[0] &= ~0x00002000u;
-}
-inline void V0LayerParameter::clear_alpha() {
- alpha_ = 1;
- clear_has_alpha();
-}
-inline float V0LayerParameter::alpha() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.alpha)
- return alpha_;
-}
-inline void V0LayerParameter::set_alpha(float value) {
- set_has_alpha();
- alpha_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.alpha)
-}
-
-// optional float beta = 15 [default = 0.75];
-inline bool V0LayerParameter::has_beta() const {
- return (_has_bits_[0] & 0x00004000u) != 0;
-}
-inline void V0LayerParameter::set_has_beta() {
- _has_bits_[0] |= 0x00004000u;
-}
-inline void V0LayerParameter::clear_has_beta() {
- _has_bits_[0] &= ~0x00004000u;
-}
-inline void V0LayerParameter::clear_beta() {
- beta_ = 0.75f;
- clear_has_beta();
-}
-inline float V0LayerParameter::beta() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.beta)
- return beta_;
-}
-inline void V0LayerParameter::set_beta(float value) {
- set_has_beta();
- beta_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.beta)
-}
-
-// optional float k = 22 [default = 1];
-inline bool V0LayerParameter::has_k() const {
- return (_has_bits_[0] & 0x00008000u) != 0;
-}
-inline void V0LayerParameter::set_has_k() {
- _has_bits_[0] |= 0x00008000u;
-}
-inline void V0LayerParameter::clear_has_k() {
- _has_bits_[0] &= ~0x00008000u;
-}
-inline void V0LayerParameter::clear_k() {
- k_ = 1;
- clear_has_k();
-}
-inline float V0LayerParameter::k() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.k)
- return k_;
-}
-inline void V0LayerParameter::set_k(float value) {
- set_has_k();
- k_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.k)
-}
-
-// optional string source = 16;
-inline bool V0LayerParameter::has_source() const {
- return (_has_bits_[0] & 0x00010000u) != 0;
-}
-inline void V0LayerParameter::set_has_source() {
- _has_bits_[0] |= 0x00010000u;
-}
-inline void V0LayerParameter::clear_has_source() {
- _has_bits_[0] &= ~0x00010000u;
-}
-inline void V0LayerParameter::clear_source() {
- source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_source();
-}
-inline const ::std::string& V0LayerParameter::source() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.source)
- return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void V0LayerParameter::set_source(const ::std::string& value) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.source)
-}
-inline void V0LayerParameter::set_source(const char* value) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.source)
-}
-inline void V0LayerParameter::set_source(const char* value, size_t size) {
- set_has_source();
- source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.source)
-}
-inline ::std::string* V0LayerParameter::mutable_source() {
- set_has_source();
- // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.source)
- return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* V0LayerParameter::release_source() {
- // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.source)
- clear_has_source();
- return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void V0LayerParameter::set_allocated_source(::std::string* source) {
- if (source != NULL) {
- set_has_source();
- } else {
- clear_has_source();
- }
- source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source);
- // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.source)
-}
-
-// optional float scale = 17 [default = 1];
-inline bool V0LayerParameter::has_scale() const {
- return (_has_bits_[0] & 0x00020000u) != 0;
-}
-inline void V0LayerParameter::set_has_scale() {
- _has_bits_[0] |= 0x00020000u;
-}
-inline void V0LayerParameter::clear_has_scale() {
- _has_bits_[0] &= ~0x00020000u;
-}
-inline void V0LayerParameter::clear_scale() {
- scale_ = 1;
- clear_has_scale();
-}
-inline float V0LayerParameter::scale() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.scale)
- return scale_;
-}
-inline void V0LayerParameter::set_scale(float value) {
- set_has_scale();
- scale_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.scale)
-}
-
-// optional string meanfile = 18;
-inline bool V0LayerParameter::has_meanfile() const {
- return (_has_bits_[0] & 0x00040000u) != 0;
-}
-inline void V0LayerParameter::set_has_meanfile() {
- _has_bits_[0] |= 0x00040000u;
-}
-inline void V0LayerParameter::clear_has_meanfile() {
- _has_bits_[0] &= ~0x00040000u;
-}
-inline void V0LayerParameter::clear_meanfile() {
- meanfile_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
- clear_has_meanfile();
-}
-inline const ::std::string& V0LayerParameter::meanfile() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.meanfile)
- return meanfile_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void V0LayerParameter::set_meanfile(const ::std::string& value) {
- set_has_meanfile();
- meanfile_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.meanfile)
-}
-inline void V0LayerParameter::set_meanfile(const char* value) {
- set_has_meanfile();
- meanfile_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.meanfile)
-}
-inline void V0LayerParameter::set_meanfile(const char* value, size_t size) {
- set_has_meanfile();
- meanfile_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.meanfile)
-}
-inline ::std::string* V0LayerParameter::mutable_meanfile() {
- set_has_meanfile();
- // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.meanfile)
- return meanfile_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* V0LayerParameter::release_meanfile() {
- // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.meanfile)
- clear_has_meanfile();
- return meanfile_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void V0LayerParameter::set_allocated_meanfile(::std::string* meanfile) {
- if (meanfile != NULL) {
- set_has_meanfile();
- } else {
- clear_has_meanfile();
- }
- meanfile_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), meanfile);
- // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.meanfile)
-}
-
-// optional uint32 batchsize = 19;
-inline bool V0LayerParameter::has_batchsize() const {
- return (_has_bits_[0] & 0x00080000u) != 0;
-}
-inline void V0LayerParameter::set_has_batchsize() {
- _has_bits_[0] |= 0x00080000u;
-}
-inline void V0LayerParameter::clear_has_batchsize() {
- _has_bits_[0] &= ~0x00080000u;
-}
-inline void V0LayerParameter::clear_batchsize() {
- batchsize_ = 0u;
- clear_has_batchsize();
-}
-inline ::google::protobuf::uint32 V0LayerParameter::batchsize() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.batchsize)
- return batchsize_;
-}
-inline void V0LayerParameter::set_batchsize(::google::protobuf::uint32 value) {
- set_has_batchsize();
- batchsize_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.batchsize)
-}
-
-// optional uint32 cropsize = 20 [default = 0];
-inline bool V0LayerParameter::has_cropsize() const {
- return (_has_bits_[0] & 0x00100000u) != 0;
-}
-inline void V0LayerParameter::set_has_cropsize() {
- _has_bits_[0] |= 0x00100000u;
-}
-inline void V0LayerParameter::clear_has_cropsize() {
- _has_bits_[0] &= ~0x00100000u;
-}
-inline void V0LayerParameter::clear_cropsize() {
- cropsize_ = 0u;
- clear_has_cropsize();
-}
-inline ::google::protobuf::uint32 V0LayerParameter::cropsize() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.cropsize)
- return cropsize_;
-}
-inline void V0LayerParameter::set_cropsize(::google::protobuf::uint32 value) {
- set_has_cropsize();
- cropsize_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.cropsize)
-}
-
-// optional bool mirror = 21 [default = false];
-inline bool V0LayerParameter::has_mirror() const {
- return (_has_bits_[0] & 0x00200000u) != 0;
-}
-inline void V0LayerParameter::set_has_mirror() {
- _has_bits_[0] |= 0x00200000u;
-}
-inline void V0LayerParameter::clear_has_mirror() {
- _has_bits_[0] &= ~0x00200000u;
-}
-inline void V0LayerParameter::clear_mirror() {
- mirror_ = false;
- clear_has_mirror();
-}
-inline bool V0LayerParameter::mirror() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.mirror)
- return mirror_;
-}
-inline void V0LayerParameter::set_mirror(bool value) {
- set_has_mirror();
- mirror_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.mirror)
-}
-
-// repeated .caffe.BlobProto blobs = 50;
-inline int V0LayerParameter::blobs_size() const {
- return blobs_.size();
-}
-inline void V0LayerParameter::clear_blobs() {
- blobs_.Clear();
-}
-inline const ::caffe::BlobProto& V0LayerParameter::blobs(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.blobs)
- return blobs_.Get(index);
-}
-inline ::caffe::BlobProto* V0LayerParameter::mutable_blobs(int index) {
- // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.blobs)
- return blobs_.Mutable(index);
-}
-inline ::caffe::BlobProto* V0LayerParameter::add_blobs() {
- // @@protoc_insertion_point(field_add:caffe.V0LayerParameter.blobs)
- return blobs_.Add();
-}
-inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
-V0LayerParameter::mutable_blobs() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V0LayerParameter.blobs)
- return &blobs_;
-}
-inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
-V0LayerParameter::blobs() const {
- // @@protoc_insertion_point(field_list:caffe.V0LayerParameter.blobs)
- return blobs_;
-}
-
-// repeated float blobs_lr = 51;
-inline int V0LayerParameter::blobs_lr_size() const {
- return blobs_lr_.size();
-}
-inline void V0LayerParameter::clear_blobs_lr() {
- blobs_lr_.Clear();
-}
-inline float V0LayerParameter::blobs_lr(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.blobs_lr)
- return blobs_lr_.Get(index);
-}
-inline void V0LayerParameter::set_blobs_lr(int index, float value) {
- blobs_lr_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.blobs_lr)
-}
-inline void V0LayerParameter::add_blobs_lr(float value) {
- blobs_lr_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.V0LayerParameter.blobs_lr)
-}
-inline const ::google::protobuf::RepeatedField< float >&
-V0LayerParameter::blobs_lr() const {
- // @@protoc_insertion_point(field_list:caffe.V0LayerParameter.blobs_lr)
- return blobs_lr_;
-}
-inline ::google::protobuf::RepeatedField< float >*
-V0LayerParameter::mutable_blobs_lr() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V0LayerParameter.blobs_lr)
- return &blobs_lr_;
-}
-
-// repeated float weight_decay = 52;
-inline int V0LayerParameter::weight_decay_size() const {
- return weight_decay_.size();
-}
-inline void V0LayerParameter::clear_weight_decay() {
- weight_decay_.Clear();
-}
-inline float V0LayerParameter::weight_decay(int index) const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.weight_decay)
- return weight_decay_.Get(index);
-}
-inline void V0LayerParameter::set_weight_decay(int index, float value) {
- weight_decay_.Set(index, value);
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.weight_decay)
-}
-inline void V0LayerParameter::add_weight_decay(float value) {
- weight_decay_.Add(value);
- // @@protoc_insertion_point(field_add:caffe.V0LayerParameter.weight_decay)
-}
-inline const ::google::protobuf::RepeatedField< float >&
-V0LayerParameter::weight_decay() const {
- // @@protoc_insertion_point(field_list:caffe.V0LayerParameter.weight_decay)
- return weight_decay_;
-}
-inline ::google::protobuf::RepeatedField< float >*
-V0LayerParameter::mutable_weight_decay() {
- // @@protoc_insertion_point(field_mutable_list:caffe.V0LayerParameter.weight_decay)
- return &weight_decay_;
-}
-
-// optional uint32 rand_skip = 53 [default = 0];
-inline bool V0LayerParameter::has_rand_skip() const {
- return (_has_bits_[0] & 0x02000000u) != 0;
-}
-inline void V0LayerParameter::set_has_rand_skip() {
- _has_bits_[0] |= 0x02000000u;
-}
-inline void V0LayerParameter::clear_has_rand_skip() {
- _has_bits_[0] &= ~0x02000000u;
-}
-inline void V0LayerParameter::clear_rand_skip() {
- rand_skip_ = 0u;
- clear_has_rand_skip();
-}
-inline ::google::protobuf::uint32 V0LayerParameter::rand_skip() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.rand_skip)
- return rand_skip_;
-}
-inline void V0LayerParameter::set_rand_skip(::google::protobuf::uint32 value) {
- set_has_rand_skip();
- rand_skip_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.rand_skip)
-}
-
-// optional float det_fg_threshold = 54 [default = 0.5];
-inline bool V0LayerParameter::has_det_fg_threshold() const {
- return (_has_bits_[0] & 0x04000000u) != 0;
-}
-inline void V0LayerParameter::set_has_det_fg_threshold() {
- _has_bits_[0] |= 0x04000000u;
-}
-inline void V0LayerParameter::clear_has_det_fg_threshold() {
- _has_bits_[0] &= ~0x04000000u;
-}
-inline void V0LayerParameter::clear_det_fg_threshold() {
- det_fg_threshold_ = 0.5f;
- clear_has_det_fg_threshold();
-}
-inline float V0LayerParameter::det_fg_threshold() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_fg_threshold)
- return det_fg_threshold_;
-}
-inline void V0LayerParameter::set_det_fg_threshold(float value) {
- set_has_det_fg_threshold();
- det_fg_threshold_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_fg_threshold)
-}
-
-// optional float det_bg_threshold = 55 [default = 0.5];
-inline bool V0LayerParameter::has_det_bg_threshold() const {
- return (_has_bits_[0] & 0x08000000u) != 0;
-}
-inline void V0LayerParameter::set_has_det_bg_threshold() {
- _has_bits_[0] |= 0x08000000u;
-}
-inline void V0LayerParameter::clear_has_det_bg_threshold() {
- _has_bits_[0] &= ~0x08000000u;
-}
-inline void V0LayerParameter::clear_det_bg_threshold() {
- det_bg_threshold_ = 0.5f;
- clear_has_det_bg_threshold();
-}
-inline float V0LayerParameter::det_bg_threshold() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_bg_threshold)
- return det_bg_threshold_;
-}
-inline void V0LayerParameter::set_det_bg_threshold(float value) {
- set_has_det_bg_threshold();
- det_bg_threshold_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_bg_threshold)
-}
-
-// optional float det_fg_fraction = 56 [default = 0.25];
-inline bool V0LayerParameter::has_det_fg_fraction() const {
- return (_has_bits_[0] & 0x10000000u) != 0;
-}
-inline void V0LayerParameter::set_has_det_fg_fraction() {
- _has_bits_[0] |= 0x10000000u;
-}
-inline void V0LayerParameter::clear_has_det_fg_fraction() {
- _has_bits_[0] &= ~0x10000000u;
-}
-inline void V0LayerParameter::clear_det_fg_fraction() {
- det_fg_fraction_ = 0.25f;
- clear_has_det_fg_fraction();
-}
-inline float V0LayerParameter::det_fg_fraction() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_fg_fraction)
- return det_fg_fraction_;
-}
-inline void V0LayerParameter::set_det_fg_fraction(float value) {
- set_has_det_fg_fraction();
- det_fg_fraction_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_fg_fraction)
-}
-
-// optional uint32 det_context_pad = 58 [default = 0];
-inline bool V0LayerParameter::has_det_context_pad() const {
- return (_has_bits_[0] & 0x20000000u) != 0;
-}
-inline void V0LayerParameter::set_has_det_context_pad() {
- _has_bits_[0] |= 0x20000000u;
-}
-inline void V0LayerParameter::clear_has_det_context_pad() {
- _has_bits_[0] &= ~0x20000000u;
-}
-inline void V0LayerParameter::clear_det_context_pad() {
- det_context_pad_ = 0u;
- clear_has_det_context_pad();
-}
-inline ::google::protobuf::uint32 V0LayerParameter::det_context_pad() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_context_pad)
- return det_context_pad_;
-}
-inline void V0LayerParameter::set_det_context_pad(::google::protobuf::uint32 value) {
- set_has_det_context_pad();
- det_context_pad_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_context_pad)
-}
-
-// optional string det_crop_mode = 59 [default = "warp"];
-inline bool V0LayerParameter::has_det_crop_mode() const {
- return (_has_bits_[0] & 0x40000000u) != 0;
-}
-inline void V0LayerParameter::set_has_det_crop_mode() {
- _has_bits_[0] |= 0x40000000u;
-}
-inline void V0LayerParameter::clear_has_det_crop_mode() {
- _has_bits_[0] &= ~0x40000000u;
-}
-inline void V0LayerParameter::clear_det_crop_mode() {
- det_crop_mode_.ClearToDefaultNoArena(_default_det_crop_mode_);
- clear_has_det_crop_mode();
-}
-inline const ::std::string& V0LayerParameter::det_crop_mode() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_crop_mode)
- return det_crop_mode_.GetNoArena(_default_det_crop_mode_);
-}
-inline void V0LayerParameter::set_det_crop_mode(const ::std::string& value) {
- set_has_det_crop_mode();
- det_crop_mode_.SetNoArena(_default_det_crop_mode_, value);
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_crop_mode)
-}
-inline void V0LayerParameter::set_det_crop_mode(const char* value) {
- set_has_det_crop_mode();
- det_crop_mode_.SetNoArena(_default_det_crop_mode_, ::std::string(value));
- // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.det_crop_mode)
-}
-inline void V0LayerParameter::set_det_crop_mode(const char* value, size_t size) {
- set_has_det_crop_mode();
- det_crop_mode_.SetNoArena(_default_det_crop_mode_,
- ::std::string(reinterpret_cast<const char*>(value), size));
- // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.det_crop_mode)
-}
-inline ::std::string* V0LayerParameter::mutable_det_crop_mode() {
- set_has_det_crop_mode();
- // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.det_crop_mode)
- return det_crop_mode_.MutableNoArena(_default_det_crop_mode_);
-}
-inline ::std::string* V0LayerParameter::release_det_crop_mode() {
- // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.det_crop_mode)
- clear_has_det_crop_mode();
- return det_crop_mode_.ReleaseNoArena(_default_det_crop_mode_);
-}
-inline void V0LayerParameter::set_allocated_det_crop_mode(::std::string* det_crop_mode) {
- if (det_crop_mode != NULL) {
- set_has_det_crop_mode();
- } else {
- clear_has_det_crop_mode();
- }
- det_crop_mode_.SetAllocatedNoArena(_default_det_crop_mode_, det_crop_mode);
- // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.det_crop_mode)
-}
-
-// optional int32 new_num = 60 [default = 0];
-inline bool V0LayerParameter::has_new_num() const {
- return (_has_bits_[0] & 0x80000000u) != 0;
-}
-inline void V0LayerParameter::set_has_new_num() {
- _has_bits_[0] |= 0x80000000u;
-}
-inline void V0LayerParameter::clear_has_new_num() {
- _has_bits_[0] &= ~0x80000000u;
-}
-inline void V0LayerParameter::clear_new_num() {
- new_num_ = 0;
- clear_has_new_num();
-}
-inline ::google::protobuf::int32 V0LayerParameter::new_num() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.new_num)
- return new_num_;
-}
-inline void V0LayerParameter::set_new_num(::google::protobuf::int32 value) {
- set_has_new_num();
- new_num_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.new_num)
-}
-
-// optional int32 new_channels = 61 [default = 0];
-inline bool V0LayerParameter::has_new_channels() const {
- return (_has_bits_[1] & 0x00000001u) != 0;
-}
-inline void V0LayerParameter::set_has_new_channels() {
- _has_bits_[1] |= 0x00000001u;
-}
-inline void V0LayerParameter::clear_has_new_channels() {
- _has_bits_[1] &= ~0x00000001u;
-}
-inline void V0LayerParameter::clear_new_channels() {
- new_channels_ = 0;
- clear_has_new_channels();
-}
-inline ::google::protobuf::int32 V0LayerParameter::new_channels() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.new_channels)
- return new_channels_;
-}
-inline void V0LayerParameter::set_new_channels(::google::protobuf::int32 value) {
- set_has_new_channels();
- new_channels_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.new_channels)
-}
-
-// optional int32 new_height = 62 [default = 0];
-inline bool V0LayerParameter::has_new_height() const {
- return (_has_bits_[1] & 0x00000002u) != 0;
-}
-inline void V0LayerParameter::set_has_new_height() {
- _has_bits_[1] |= 0x00000002u;
-}
-inline void V0LayerParameter::clear_has_new_height() {
- _has_bits_[1] &= ~0x00000002u;
-}
-inline void V0LayerParameter::clear_new_height() {
- new_height_ = 0;
- clear_has_new_height();
-}
-inline ::google::protobuf::int32 V0LayerParameter::new_height() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.new_height)
- return new_height_;
-}
-inline void V0LayerParameter::set_new_height(::google::protobuf::int32 value) {
- set_has_new_height();
- new_height_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.new_height)
-}
-
-// optional int32 new_width = 63 [default = 0];
-inline bool V0LayerParameter::has_new_width() const {
- return (_has_bits_[1] & 0x00000004u) != 0;
-}
-inline void V0LayerParameter::set_has_new_width() {
- _has_bits_[1] |= 0x00000004u;
-}
-inline void V0LayerParameter::clear_has_new_width() {
- _has_bits_[1] &= ~0x00000004u;
-}
-inline void V0LayerParameter::clear_new_width() {
- new_width_ = 0;
- clear_has_new_width();
-}
-inline ::google::protobuf::int32 V0LayerParameter::new_width() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.new_width)
- return new_width_;
-}
-inline void V0LayerParameter::set_new_width(::google::protobuf::int32 value) {
- set_has_new_width();
- new_width_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.new_width)
-}
-
-// optional bool shuffle_images = 64 [default = false];
-inline bool V0LayerParameter::has_shuffle_images() const {
- return (_has_bits_[1] & 0x00000008u) != 0;
-}
-inline void V0LayerParameter::set_has_shuffle_images() {
- _has_bits_[1] |= 0x00000008u;
-}
-inline void V0LayerParameter::clear_has_shuffle_images() {
- _has_bits_[1] &= ~0x00000008u;
-}
-inline void V0LayerParameter::clear_shuffle_images() {
- shuffle_images_ = false;
- clear_has_shuffle_images();
-}
-inline bool V0LayerParameter::shuffle_images() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.shuffle_images)
- return shuffle_images_;
-}
-inline void V0LayerParameter::set_shuffle_images(bool value) {
- set_has_shuffle_images();
- shuffle_images_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.shuffle_images)
-}
-
-// optional uint32 concat_dim = 65 [default = 1];
-inline bool V0LayerParameter::has_concat_dim() const {
- return (_has_bits_[1] & 0x00000010u) != 0;
-}
-inline void V0LayerParameter::set_has_concat_dim() {
- _has_bits_[1] |= 0x00000010u;
-}
-inline void V0LayerParameter::clear_has_concat_dim() {
- _has_bits_[1] &= ~0x00000010u;
-}
-inline void V0LayerParameter::clear_concat_dim() {
- concat_dim_ = 1u;
- clear_has_concat_dim();
-}
-inline ::google::protobuf::uint32 V0LayerParameter::concat_dim() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.concat_dim)
- return concat_dim_;
-}
-inline void V0LayerParameter::set_concat_dim(::google::protobuf::uint32 value) {
- set_has_concat_dim();
- concat_dim_ = value;
- // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.concat_dim)
-}
-
-// optional .caffe.HDF5OutputParameter hdf5_output_param = 1001;
-inline bool V0LayerParameter::has_hdf5_output_param() const {
- return (_has_bits_[1] & 0x00000020u) != 0;
-}
-inline void V0LayerParameter::set_has_hdf5_output_param() {
- _has_bits_[1] |= 0x00000020u;
-}
-inline void V0LayerParameter::clear_has_hdf5_output_param() {
- _has_bits_[1] &= ~0x00000020u;
-}
-inline void V0LayerParameter::clear_hdf5_output_param() {
- if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear();
- clear_has_hdf5_output_param();
-}
-inline const ::caffe::HDF5OutputParameter& V0LayerParameter::hdf5_output_param() const {
- // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.hdf5_output_param)
- return hdf5_output_param_ != NULL ? *hdf5_output_param_
- : *::caffe::HDF5OutputParameter::internal_default_instance();
-}
-inline ::caffe::HDF5OutputParameter* V0LayerParameter::mutable_hdf5_output_param() {
- set_has_hdf5_output_param();
- if (hdf5_output_param_ == NULL) {
- hdf5_output_param_ = new ::caffe::HDF5OutputParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.hdf5_output_param)
- return hdf5_output_param_;
-}
-inline ::caffe::HDF5OutputParameter* V0LayerParameter::release_hdf5_output_param() {
- // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.hdf5_output_param)
- clear_has_hdf5_output_param();
- ::caffe::HDF5OutputParameter* temp = hdf5_output_param_;
- hdf5_output_param_ = NULL;
- return temp;
-}
-inline void V0LayerParameter::set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param) {
- delete hdf5_output_param_;
- hdf5_output_param_ = hdf5_output_param;
- if (hdf5_output_param) {
- set_has_hdf5_output_param();
- } else {
- clear_has_hdf5_output_param();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.hdf5_output_param)
-}
-
-inline const V0LayerParameter* V0LayerParameter::internal_default_instance() {
- return &V0LayerParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// PReLUParameter
-
-// optional .caffe.FillerParameter filler = 1;
-inline bool PReLUParameter::has_filler() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void PReLUParameter::set_has_filler() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void PReLUParameter::clear_has_filler() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void PReLUParameter::clear_filler() {
- if (filler_ != NULL) filler_->::caffe::FillerParameter::Clear();
- clear_has_filler();
-}
-inline const ::caffe::FillerParameter& PReLUParameter::filler() const {
- // @@protoc_insertion_point(field_get:caffe.PReLUParameter.filler)
- return filler_ != NULL ? *filler_
- : *::caffe::FillerParameter::internal_default_instance();
-}
-inline ::caffe::FillerParameter* PReLUParameter::mutable_filler() {
- set_has_filler();
- if (filler_ == NULL) {
- filler_ = new ::caffe::FillerParameter;
- }
- // @@protoc_insertion_point(field_mutable:caffe.PReLUParameter.filler)
- return filler_;
-}
-inline ::caffe::FillerParameter* PReLUParameter::release_filler() {
- // @@protoc_insertion_point(field_release:caffe.PReLUParameter.filler)
- clear_has_filler();
- ::caffe::FillerParameter* temp = filler_;
- filler_ = NULL;
- return temp;
-}
-inline void PReLUParameter::set_allocated_filler(::caffe::FillerParameter* filler) {
- delete filler_;
- filler_ = filler;
- if (filler) {
- set_has_filler();
- } else {
- clear_has_filler();
- }
- // @@protoc_insertion_point(field_set_allocated:caffe.PReLUParameter.filler)
-}
-
-// optional bool channel_shared = 2 [default = false];
-inline bool PReLUParameter::has_channel_shared() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void PReLUParameter::set_has_channel_shared() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void PReLUParameter::clear_has_channel_shared() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void PReLUParameter::clear_channel_shared() {
- channel_shared_ = false;
- clear_has_channel_shared();
-}
-inline bool PReLUParameter::channel_shared() const {
- // @@protoc_insertion_point(field_get:caffe.PReLUParameter.channel_shared)
- return channel_shared_;
-}
-inline void PReLUParameter::set_channel_shared(bool value) {
- set_has_channel_shared();
- channel_shared_ = value;
- // @@protoc_insertion_point(field_set:caffe.PReLUParameter.channel_shared)
-}
-
-inline const PReLUParameter* PReLUParameter::internal_default_instance() {
- return &PReLUParameter_default_instance_.get();
-}
-// -------------------------------------------------------------------
-
-// NormalizedBBox
-
-// optional float xmin = 1;
-inline bool NormalizedBBox::has_xmin() const {
- return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void NormalizedBBox::set_has_xmin() {
- _has_bits_[0] |= 0x00000001u;
-}
-inline void NormalizedBBox::clear_has_xmin() {
- _has_bits_[0] &= ~0x00000001u;
-}
-inline void NormalizedBBox::clear_xmin() {
- xmin_ = 0;
- clear_has_xmin();
-}
-inline float NormalizedBBox::xmin() const {
- // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.xmin)
- return xmin_;
-}
-inline void NormalizedBBox::set_xmin(float value) {
- set_has_xmin();
- xmin_ = value;
- // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.xmin)
-}
-
-// optional float ymin = 2;
-inline bool NormalizedBBox::has_ymin() const {
- return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void NormalizedBBox::set_has_ymin() {
- _has_bits_[0] |= 0x00000002u;
-}
-inline void NormalizedBBox::clear_has_ymin() {
- _has_bits_[0] &= ~0x00000002u;
-}
-inline void NormalizedBBox::clear_ymin() {
- ymin_ = 0;
- clear_has_ymin();
-}
-inline float NormalizedBBox::ymin() const {
- // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.ymin)
- return ymin_;
-}
-inline void NormalizedBBox::set_ymin(float value) {
- set_has_ymin();
- ymin_ = value;
- // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.ymin)
-}
-
-// optional float xmax = 3;
-inline bool NormalizedBBox::has_xmax() const {
- return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void NormalizedBBox::set_has_xmax() {
- _has_bits_[0] |= 0x00000004u;
-}
-inline void NormalizedBBox::clear_has_xmax() {
- _has_bits_[0] &= ~0x00000004u;
-}
-inline void NormalizedBBox::clear_xmax() {
- xmax_ = 0;
- clear_has_xmax();
-}
-inline float NormalizedBBox::xmax() const {
- // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.xmax)
- return xmax_;
-}
-inline void NormalizedBBox::set_xmax(float value) {
- set_has_xmax();
- xmax_ = value;
- // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.xmax)
-}
-
-// optional float ymax = 4;
-inline bool NormalizedBBox::has_ymax() const {
- return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void NormalizedBBox::set_has_ymax() {
- _has_bits_[0] |= 0x00000008u;
-}
-inline void NormalizedBBox::clear_has_ymax() {
- _has_bits_[0] &= ~0x00000008u;
-}
-inline void NormalizedBBox::clear_ymax() {
- ymax_ = 0;
- clear_has_ymax();
-}
-inline float NormalizedBBox::ymax() const {
- // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.ymax)
- return ymax_;
-}
-inline void NormalizedBBox::set_ymax(float value) {
- set_has_ymax();
- ymax_ = value;
- // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.ymax)
-}
-
-// optional int32 label = 5;
-inline bool NormalizedBBox::has_label() const {
- return (_has_bits_[0] & 0x00000010u) != 0;
-}
-inline void NormalizedBBox::set_has_label() {
- _has_bits_[0] |= 0x00000010u;
-}
-inline void NormalizedBBox::clear_has_label() {
- _has_bits_[0] &= ~0x00000010u;
-}
-inline void NormalizedBBox::clear_label() {
- label_ = 0;
- clear_has_label();
-}
-inline ::google::protobuf::int32 NormalizedBBox::label() const {
- // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.label)
- return label_;
-}
-inline void NormalizedBBox::set_label(::google::protobuf::int32 value) {
- set_has_label();
- label_ = value;
- // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.label)
-}
-
-// optional bool difficult = 6;
-inline bool NormalizedBBox::has_difficult() const {
- return (_has_bits_[0] & 0x00000020u) != 0;
-}
-inline void NormalizedBBox::set_has_difficult() {
- _has_bits_[0] |= 0x00000020u;
-}
-inline void NormalizedBBox::clear_has_difficult() {
- _has_bits_[0] &= ~0x00000020u;
-}
-inline void NormalizedBBox::clear_difficult() {
- difficult_ = false;
- clear_has_difficult();
-}
-inline bool NormalizedBBox::difficult() const {
- // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.difficult)
- return difficult_;
-}
-inline void NormalizedBBox::set_difficult(bool value) {
- set_has_difficult();
- difficult_ = value;
- // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.difficult)
-}
-
-// optional float score = 7;
-inline bool NormalizedBBox::has_score() const {
- return (_has_bits_[0] & 0x00000040u) != 0;
-}
-inline void NormalizedBBox::set_has_score() {
- _has_bits_[0] |= 0x00000040u;
-}
-inline void NormalizedBBox::clear_has_score() {
- _has_bits_[0] &= ~0x00000040u;
-}
-inline void NormalizedBBox::clear_score() {
- score_ = 0;
- clear_has_score();
-}
-inline float NormalizedBBox::score() const {
- // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.score)
- return score_;
-}
-inline void NormalizedBBox::set_score(float value) {
- set_has_score();
- score_ = value;
- // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.score)
-}
-
-// optional float size = 8;
-inline bool NormalizedBBox::has_size() const {
- return (_has_bits_[0] & 0x00000080u) != 0;
-}
-inline void NormalizedBBox::set_has_size() {
- _has_bits_[0] |= 0x00000080u;
-}
-inline void NormalizedBBox::clear_has_size() {
- _has_bits_[0] &= ~0x00000080u;
-}
-inline void NormalizedBBox::clear_size() {
- size_ = 0;
- clear_has_size();
-}
-inline float NormalizedBBox::size() const {
- // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.size)
- return size_;
-}
-inline void NormalizedBBox::set_size(float value) {
- set_has_size();
- size_ = value;
- // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.size)
-}
-
-inline const NormalizedBBox* NormalizedBBox::internal_default_instance() {
- return &NormalizedBBox_default_instance_.get();
-}
-#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-// -------------------------------------------------------------------
-
-
-// @@protoc_insertion_point(namespace_scope)
-
-} // namespace caffe
-
-#ifndef SWIG
-namespace google {
-namespace protobuf {
-
-template <> struct is_proto_enum< ::caffe::PriorBoxParameter_CodeType> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::caffe::PriorBoxParameter_CodeType>() {
- return ::caffe::PriorBoxParameter_CodeType_descriptor();
-}
-template <> struct is_proto_enum< ::caffe::FillerParameter_VarianceNorm> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::caffe::FillerParameter_VarianceNorm>() {
- return ::caffe::FillerParameter_VarianceNorm_descriptor();
-}
-template <> struct is_proto_enum< ::caffe::SolverParameter_SolverMode> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::caffe::SolverParameter_SolverMode>() {
- return ::caffe::SolverParameter_SolverMode_descriptor();
-}
-template <> struct is_proto_enum< ::caffe::SolverParameter_SolverType> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::caffe::SolverParameter_SolverType>() {
- return ::caffe::SolverParameter_SolverType_descriptor();
-}
-template <> struct is_proto_enum< ::caffe::ParamSpec_DimCheckMode> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::caffe::ParamSpec_DimCheckMode>() {
- return ::caffe::ParamSpec_DimCheckMode_descriptor();
-}
-template <> struct is_proto_enum< ::caffe::ConvolutionParameter_Engine> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::caffe::ConvolutionParameter_Engine>() {
- return ::caffe::ConvolutionParameter_Engine_descriptor();
-}
-template <> struct is_proto_enum< ::caffe::DataParameter_DB> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::caffe::DataParameter_DB>() {
- return ::caffe::DataParameter_DB_descriptor();
-}
-template <> struct is_proto_enum< ::caffe::EltwiseParameter_EltwiseOp> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::caffe::EltwiseParameter_EltwiseOp>() {
- return ::caffe::EltwiseParameter_EltwiseOp_descriptor();
-}
-template <> struct is_proto_enum< ::caffe::HingeLossParameter_Norm> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::caffe::HingeLossParameter_Norm>() {
- return ::caffe::HingeLossParameter_Norm_descriptor();
-}
-template <> struct is_proto_enum< ::caffe::LRNParameter_NormRegion> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::caffe::LRNParameter_NormRegion>() {
- return ::caffe::LRNParameter_NormRegion_descriptor();
-}
-template <> struct is_proto_enum< ::caffe::PoolingParameter_PoolMethod> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::caffe::PoolingParameter_PoolMethod>() {
- return ::caffe::PoolingParameter_PoolMethod_descriptor();
-}
-template <> struct is_proto_enum< ::caffe::PoolingParameter_Engine> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::caffe::PoolingParameter_Engine>() {
- return ::caffe::PoolingParameter_Engine_descriptor();
-}
-template <> struct is_proto_enum< ::caffe::ReductionParameter_ReductionOp> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::caffe::ReductionParameter_ReductionOp>() {
- return ::caffe::ReductionParameter_ReductionOp_descriptor();
-}
-template <> struct is_proto_enum< ::caffe::ReLUParameter_Engine> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::caffe::ReLUParameter_Engine>() {
- return ::caffe::ReLUParameter_Engine_descriptor();
-}
-template <> struct is_proto_enum< ::caffe::SigmoidParameter_Engine> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::caffe::SigmoidParameter_Engine>() {
- return ::caffe::SigmoidParameter_Engine_descriptor();
-}
-template <> struct is_proto_enum< ::caffe::SoftmaxParameter_Engine> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::caffe::SoftmaxParameter_Engine>() {
- return ::caffe::SoftmaxParameter_Engine_descriptor();
-}
-template <> struct is_proto_enum< ::caffe::TanHParameter_Engine> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::caffe::TanHParameter_Engine>() {
- return ::caffe::TanHParameter_Engine_descriptor();
-}
-template <> struct is_proto_enum< ::caffe::SPPParameter_PoolMethod> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::caffe::SPPParameter_PoolMethod>() {
- return ::caffe::SPPParameter_PoolMethod_descriptor();
-}
-template <> struct is_proto_enum< ::caffe::SPPParameter_Engine> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::caffe::SPPParameter_Engine>() {
- return ::caffe::SPPParameter_Engine_descriptor();
-}
-template <> struct is_proto_enum< ::caffe::V1LayerParameter_LayerType> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::caffe::V1LayerParameter_LayerType>() {
- return ::caffe::V1LayerParameter_LayerType_descriptor();
-}
-template <> struct is_proto_enum< ::caffe::V1LayerParameter_DimCheckMode> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::caffe::V1LayerParameter_DimCheckMode>() {
- return ::caffe::V1LayerParameter_DimCheckMode_descriptor();
-}
-template <> struct is_proto_enum< ::caffe::V0LayerParameter_PoolMethod> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::caffe::V0LayerParameter_PoolMethod>() {
- return ::caffe::V0LayerParameter_PoolMethod_descriptor();
-}
-template <> struct is_proto_enum< ::caffe::Phase> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::caffe::Phase>() {
- return ::caffe::Phase_descriptor();
-}
-
-} // namespace protobuf
-} // namespace google
-#endif // SWIG
-
-// @@protoc_insertion_point(global_scope)
-
-#endif // PROTOBUF_caffe_2eproto__INCLUDED
diff --git a/contrib/modules/dnn/misc/python/pyopencv_dnn.hpp b/contrib/modules/dnn/misc/python/pyopencv_dnn.hpp
deleted file mode 100644
index 06661de..0000000
--- a/contrib/modules/dnn/misc/python/pyopencv_dnn.hpp
+++ /dev/null
@@ -1,108 +0,0 @@
-#ifdef HAVE_OPENCV_DNN
-typedef dnn::DictValue LayerId;
-typedef std::vector<cv::dnn::Blob> vector_Blob;
-
-template<>
-bool pyopencv_to(PyObject *o, dnn::Blob &blob, const char *name);
-
-template<> struct pyopencvVecConverter<dnn::Blob>
-{
- static bool to(PyObject* obj, std::vector<dnn::Blob>& value, const ArgInfo info)
- {
- if (PyArray_Check(obj))
- {
- value.resize(1);
- return pyopencv_to(obj, value[0], info.name);
- }
-
- return pyopencv_to_generic_vec(obj, value, info);
- }
-
- static PyObject* from(const std::vector<dnn::Blob>& value)
- {
- return pyopencv_from_generic_vec(value);
- }
-};
-
-template<>
-bool pyopencv_to(PyObject *o, std::vector<dnn::Blob> &blobs, const char *name) //required for Layer::blobs RW
-{
- return pyopencvVecConverter<dnn::Blob>::to(o, blobs, ArgInfo(name, false));
-}
-
-template<>
-bool pyopencv_to(PyObject *o, dnn::Blob &blob, const char *name)
-{
- Mat &dst = blob.matRef();
- if (!pyopencv_to(o, dst, name))
- return false;
-
- if (PyArray_Check(o)) //try fix channels
- {
- PyArrayObject* oarr = (PyArrayObject*) o;
-
- if (PyArray_NDIM(oarr) == dst.dims)
- return true;
-
- int ndims = PyArray_NDIM(oarr);
- std::vector<int> shape(ndims);
- const npy_intp* _sizes = PyArray_DIMS(oarr);
- for (int i = 0; i < ndims; i++)
- shape[i] = (int)_sizes[i];
-
- dst = dst.reshape(1, ndims, &shape[0]);
- }
-
- return true;
-}
-
-template<>
-PyObject *pyopencv_from(const dnn::Blob &blob)
-{
- return pyopencv_from(blob.matRefConst());
-}
-
-template<>
-bool pyopencv_to(PyObject *o, dnn::DictValue &dv, const char *name)
-{
- (void)name;
- if (!o || o == Py_None)
- return true; //Current state will be used
- else if (PyLong_Check(o))
- {
- dv = dnn::DictValue((int64)PyLong_AsLongLong(o));
- return true;
- }
- else if (PyFloat_Check(o))
- {
- dv = dnn::DictValue(PyFloat_AS_DOUBLE(o));
- return true;
- }
- else if (PyString_Check(o))
- {
- dv = dnn::DictValue(String(PyString_AsString(o)));
- return true;
- }
- else
- return false;
-}
-
-template<>
-bool pyopencv_to(PyObject *o, dnn::BlobShape &shape, const char *name)
-{
- std::vector<int> data;
- if (!pyopencv_to_generic_vec(o, data, ArgInfo(name, false)))
- return false;
-
- shape = data.size() ? dnn::BlobShape((int)data.size(), &data[0]) : dnn::BlobShape::empty();
- return true;
-}
-
-template<>
-PyObject *pyopencv_from(const dnn::BlobShape &shape)
-{
- std::vector<int> data(shape.ptr(), shape.ptr() + shape.dims());
- return pyopencv_from_generic_vec(data);
-}
-
-#endif
\ No newline at end of file
diff --git a/contrib/modules/dnn/perf/perf_convolution.cpp b/contrib/modules/dnn/perf/perf_convolution.cpp
deleted file mode 100644
index 17fda01..0000000
--- a/contrib/modules/dnn/perf/perf_convolution.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-#include "perf_precomp.hpp"
-
-namespace cvtest
-{
-
-using std::tr1::tuple;
-using std::tr1::get;
-using std::tr1::make_tuple;
-using std::make_pair;
-using namespace perf;
-using namespace testing;
-using namespace cv;
-using namespace cv::dnn;
-
-enum {STRIDE_OFF = 1, STRIDE_ON = 2};
-CV_ENUM(StrideSize, STRIDE_OFF, STRIDE_ON);
-
-enum {GROUP_OFF = 1, GROUP_2 = 2};
-CV_ENUM(GroupSize, GROUP_OFF, GROUP_2);
-
-//Squared Size
-#define SSZ(n) cv::Size(n, n)
-
-typedef std::pair<BlobShape, int> InpShapeNumOut;
-typedef tuple<Size, InpShapeNumOut, GroupSize, StrideSize> ConvParam; //kernel_size, inp shape, groups, stride
-typedef TestBaseWithParam<ConvParam> ConvolutionPerfTest;
-
-PERF_TEST_P( ConvolutionPerfTest, perf, Combine(
- Values(Size(1, 1), Size(3, 3), Size(5, 5), Size(11, 11)),
- Values(make_pair(BlobShape(1, 4, 224, 224), 64),
- make_pair(BlobShape(1, 64, 112, 122), 128),
- make_pair(BlobShape(1, 256, 28, 28), 512)),
- GroupSize::all(),
- StrideSize::all())
-)
-{
- RNG rng(0);
-
- ConvParam params = GetParam();
- int ksz = get<0>(params).width;
- BlobShape inpShape = get<1>(params).first;
- int outCn = get<1>(params).second;
- int groups = get<2>(params);
- int stride = (ksz >= 11) ? 4 : (int)get<3>(params);
-
- int inpCn = inpShape[1];
- Blob wgtBlob(BlobShape(outCn, inpCn/groups, ksz, ksz)), biasBlob(BlobShape(outCn, 1, 1, 1));
- Blob inpBlob(inpShape);
- rng.fill(biasBlob.matRef(), RNG::UNIFORM, -1, +1);
- rng.fill(wgtBlob.matRef(), RNG::UNIFORM, -1, +1);
- rng.fill(inpBlob.matRef(), RNG::UNIFORM, -1, +1);
-
- LayerParams lp;
- lp.set("num_output", outCn);
- lp.set("group", groups);
- lp.set("stride", stride);
- lp.set("kernel_size", ksz);
- lp.blobs.reserve(2);
- lp.blobs.push_back(wgtBlob);
- lp.blobs.push_back(biasBlob);
-
- std::vector<Blob*> inpBlobs(1, &inpBlob);
- std::vector<Blob> outBlobs;
-
- cv::setNumThreads(cv::getNumberOfCPUs());
-
- Ptr<Layer> layer = cv::dnn::LayerFactory::createLayerInstance("Convolution", lp);
- layer->allocate(inpBlobs, outBlobs);
-
- declare.in(inpBlob.matRef(), wgtBlob.matRef(), WARMUP_RNG).out(outBlobs[0].matRef()).tbb_threads(cv::getNumThreads());
-
- TEST_CYCLE_N(10)
- {
- layer->forward(inpBlobs, outBlobs);
- }
-
- SANITY_CHECK_NOTHING();
-}
-
-}
\ No newline at end of file
diff --git a/contrib/modules/dnn/perf/perf_main.cpp b/contrib/modules/dnn/perf/perf_main.cpp
deleted file mode 100644
index 1798020..0000000
--- a/contrib/modules/dnn/perf/perf_main.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "perf_precomp.hpp"
-
-CV_PERF_TEST_MAIN(dnn)
diff --git a/contrib/modules/dnn/samples/.gitignore b/contrib/modules/dnn/samples/.gitignore
deleted file mode 100644
index be71866..0000000
--- a/contrib/modules/dnn/samples/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.caffemodel
diff --git a/contrib/modules/dnn/samples/VGG_VOC0712_SSD_300x300_iter_60000.prototxt b/contrib/modules/dnn/samples/VGG_VOC0712_SSD_300x300_iter_60000.prototxt
deleted file mode 100644
index 19156c7..0000000
--- a/contrib/modules/dnn/samples/VGG_VOC0712_SSD_300x300_iter_60000.prototxt
+++ /dev/null
@@ -1,1547 +0,0 @@
-name: "VGG_VOC0712_SSD_300x300_deploy"
-input: "data"
-input_dim: 1
-input_dim: 3
-input_dim: 300
-input_dim: 300
-layer {
- name: "conv1_1"
- type: "Convolution"
- bottom: "data"
- top: "conv1_1"
- param {
- lr_mult: 0
- decay_mult: 0
- }
- param {
- lr_mult: 0
- decay_mult: 0
- }
- convolution_param {
- num_output: 64
- pad: 1
- kernel_size: 3
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "relu1_1"
- type: "ReLU"
- bottom: "conv1_1"
- top: "conv1_1"
-}
-layer {
- name: "conv1_2"
- type: "Convolution"
- bottom: "conv1_1"
- top: "conv1_2"
- param {
- lr_mult: 0
- decay_mult: 0
- }
- param {
- lr_mult: 0
- decay_mult: 0
- }
- convolution_param {
- num_output: 64
- pad: 1
- kernel_size: 3
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "relu1_2"
- type: "ReLU"
- bottom: "conv1_2"
- top: "conv1_2"
-}
-layer {
- name: "pool1"
- type: "Pooling"
- bottom: "conv1_2"
- top: "pool1"
- pooling_param {
- pool: MAX
- kernel_size: 2
- stride: 2
- }
-}
-layer {
- name: "conv2_1"
- type: "Convolution"
- bottom: "pool1"
- top: "conv2_1"
- param {
- lr_mult: 0
- decay_mult: 0
- }
- param {
- lr_mult: 0
- decay_mult: 0
- }
- convolution_param {
- num_output: 128
- pad: 1
- kernel_size: 3
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "relu2_1"
- type: "ReLU"
- bottom: "conv2_1"
- top: "conv2_1"
-}
-layer {
- name: "conv2_2"
- type: "Convolution"
- bottom: "conv2_1"
- top: "conv2_2"
- param {
- lr_mult: 0
- decay_mult: 0
- }
- param {
- lr_mult: 0
- decay_mult: 0
- }
- convolution_param {
- num_output: 128
- pad: 1
- kernel_size: 3
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "relu2_2"
- type: "ReLU"
- bottom: "conv2_2"
- top: "conv2_2"
-}
-layer {
- name: "pool2"
- type: "Pooling"
- bottom: "conv2_2"
- top: "pool2"
- pooling_param {
- pool: MAX
- kernel_size: 2
- stride: 2
- }
-}
-layer {
- name: "conv3_1"
- type: "Convolution"
- bottom: "pool2"
- top: "conv3_1"
- 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"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "relu3_1"
- type: "ReLU"
- bottom: "conv3_1"
- top: "conv3_1"
-}
-layer {
- name: "conv3_2"
- type: "Convolution"
- bottom: "conv3_1"
- top: "conv3_2"
- 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"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "relu3_2"
- type: "ReLU"
- bottom: "conv3_2"
- top: "conv3_2"
-}
-layer {
- name: "conv3_3"
- type: "Convolution"
- bottom: "conv3_2"
- top: "conv3_3"
- 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"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "relu3_3"
- type: "ReLU"
- bottom: "conv3_3"
- top: "conv3_3"
-}
-layer {
- name: "pool3"
- type: "Pooling"
- bottom: "conv3_3"
- top: "pool3"
- pooling_param {
- pool: MAX
- kernel_size: 2
- stride: 2
- }
-}
-layer {
- name: "conv4_1"
- type: "Convolution"
- bottom: "pool3"
- top: "conv4_1"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 512
- pad: 1
- kernel_size: 3
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "relu4_1"
- type: "ReLU"
- bottom: "conv4_1"
- top: "conv4_1"
-}
-layer {
- name: "conv4_2"
- type: "Convolution"
- bottom: "conv4_1"
- top: "conv4_2"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 512
- pad: 1
- kernel_size: 3
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "relu4_2"
- type: "ReLU"
- bottom: "conv4_2"
- top: "conv4_2"
-}
-layer {
- name: "conv4_3"
- type: "Convolution"
- bottom: "conv4_2"
- top: "conv4_3"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 512
- pad: 1
- kernel_size: 3
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "relu4_3"
- type: "ReLU"
- bottom: "conv4_3"
- top: "conv4_3"
-}
-layer {
- name: "pool4"
- type: "Pooling"
- bottom: "conv4_3"
- top: "pool4"
- pooling_param {
- pool: MAX
- kernel_size: 2
- stride: 2
- }
-}
-layer {
- name: "conv5_1"
- type: "Convolution"
- bottom: "pool4"
- top: "conv5_1"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 512
- pad: 1
- kernel_size: 3
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "relu5_1"
- type: "ReLU"
- bottom: "conv5_1"
- top: "conv5_1"
-}
-layer {
- name: "conv5_2"
- type: "Convolution"
- bottom: "conv5_1"
- top: "conv5_2"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 512
- pad: 1
- kernel_size: 3
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "relu5_2"
- type: "ReLU"
- bottom: "conv5_2"
- top: "conv5_2"
-}
-layer {
- name: "conv5_3"
- type: "Convolution"
- bottom: "conv5_2"
- top: "conv5_3"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 512
- pad: 1
- kernel_size: 3
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "relu5_3"
- type: "ReLU"
- bottom: "conv5_3"
- top: "conv5_3"
-}
-layer {
- name: "pool5"
- type: "Pooling"
- bottom: "conv5_3"
- top: "pool5"
- pooling_param {
- pool: MAX
- kernel_size: 3
- stride: 1
- pad: 1
- }
-}
-layer {
- name: "fc6"
- type: "Convolution"
- bottom: "pool5"
- top: "fc6"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 1024
- pad: 6
- kernel_size: 3
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- dilation: 6
- }
-}
-layer {
- name: "relu6"
- type: "ReLU"
- bottom: "fc6"
- top: "fc6"
-}
-layer {
- name: "fc7"
- type: "Convolution"
- bottom: "fc6"
- top: "fc7"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 1024
- kernel_size: 1
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "relu7"
- type: "ReLU"
- bottom: "fc7"
- top: "fc7"
-}
-layer {
- name: "conv6_1"
- type: "Convolution"
- bottom: "fc7"
- top: "conv6_1"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 256
- pad: 0
- kernel_size: 1
- stride: 1
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "conv6_1_relu"
- type: "ReLU"
- bottom: "conv6_1"
- top: "conv6_1"
-}
-layer {
- name: "conv6_2"
- type: "Convolution"
- bottom: "conv6_1"
- top: "conv6_2"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 512
- pad: 1
- kernel_size: 3
- stride: 2
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "conv6_2_relu"
- type: "ReLU"
- bottom: "conv6_2"
- top: "conv6_2"
-}
-layer {
- name: "conv7_1"
- type: "Convolution"
- bottom: "conv6_2"
- top: "conv7_1"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 128
- pad: 0
- kernel_size: 1
- stride: 1
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "conv7_1_relu"
- type: "ReLU"
- bottom: "conv7_1"
- top: "conv7_1"
-}
-layer {
- name: "conv7_2"
- type: "Convolution"
- bottom: "conv7_1"
- top: "conv7_2"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 256
- pad: 1
- kernel_size: 3
- stride: 2
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "conv7_2_relu"
- type: "ReLU"
- bottom: "conv7_2"
- top: "conv7_2"
-}
-layer {
- name: "conv8_1"
- type: "Convolution"
- bottom: "conv7_2"
- top: "conv8_1"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 128
- pad: 0
- kernel_size: 1
- stride: 1
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "conv8_1_relu"
- type: "ReLU"
- bottom: "conv8_1"
- top: "conv8_1"
-}
-layer {
- name: "conv8_2"
- type: "Convolution"
- bottom: "conv8_1"
- top: "conv8_2"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 256
- pad: 1
- kernel_size: 3
- stride: 2
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "conv8_2_relu"
- type: "ReLU"
- bottom: "conv8_2"
- top: "conv8_2"
-}
-layer {
- name: "pool6"
- type: "Pooling"
- bottom: "conv8_2"
- top: "pool6"
- pooling_param {
- pool: AVE
- global_pooling: true
- }
-}
-layer {
- name: "conv4_3_norm"
- type: "NormalizeBBox"
- bottom: "conv4_3"
- top: "conv4_3_norm"
- normalize_bbox_param {
- across_spatial: false
- scale_filler {
- type: "constant"
- value: 20
- }
- channel_shared: false
- }
-}
-layer {
- name: "conv4_3_norm_mbox_loc"
- type: "Convolution"
- bottom: "conv4_3_norm"
- top: "conv4_3_norm_mbox_loc"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 12
- pad: 1
- kernel_size: 3
- stride: 1
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "conv4_3_norm_mbox_loc_perm"
- type: "Permute"
- bottom: "conv4_3_norm_mbox_loc"
- top: "conv4_3_norm_mbox_loc_perm"
- permute_param {
- order: 0
- order: 2
- order: 3
- order: 1
- }
-}
-layer {
- name: "conv4_3_norm_mbox_loc_flat"
- type: "Flatten"
- bottom: "conv4_3_norm_mbox_loc_perm"
- top: "conv4_3_norm_mbox_loc_flat"
- flatten_param {
- axis: 1
- }
-}
-layer {
- name: "conv4_3_norm_mbox_conf"
- type: "Convolution"
- bottom: "conv4_3_norm"
- top: "conv4_3_norm_mbox_conf"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 63
- pad: 1
- kernel_size: 3
- stride: 1
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "conv4_3_norm_mbox_conf_perm"
- type: "Permute"
- bottom: "conv4_3_norm_mbox_conf"
- top: "conv4_3_norm_mbox_conf_perm"
- permute_param {
- order: 0
- order: 2
- order: 3
- order: 1
- }
-}
-layer {
- name: "conv4_3_norm_mbox_conf_flat"
- type: "Flatten"
- bottom: "conv4_3_norm_mbox_conf_perm"
- top: "conv4_3_norm_mbox_conf_flat"
- flatten_param {
- axis: 1
- }
-}
-layer {
- name: "conv4_3_norm_mbox_priorbox"
- type: "PriorBox"
- bottom: "conv4_3_norm"
- bottom: "data"
- top: "conv4_3_norm_mbox_priorbox"
- prior_box_param {
- min_size: 30.0
- aspect_ratio: 2
- flip: true
- clip: true
- variance: 0.1
- variance: 0.1
- variance: 0.2
- variance: 0.2
- }
-}
-layer {
- name: "fc7_mbox_loc"
- type: "Convolution"
- bottom: "fc7"
- top: "fc7_mbox_loc"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 24
- pad: 1
- kernel_size: 3
- stride: 1
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "fc7_mbox_loc_perm"
- type: "Permute"
- bottom: "fc7_mbox_loc"
- top: "fc7_mbox_loc_perm"
- permute_param {
- order: 0
- order: 2
- order: 3
- order: 1
- }
-}
-layer {
- name: "fc7_mbox_loc_flat"
- type: "Flatten"
- bottom: "fc7_mbox_loc_perm"
- top: "fc7_mbox_loc_flat"
- flatten_param {
- axis: 1
- }
-}
-layer {
- name: "fc7_mbox_conf"
- type: "Convolution"
- bottom: "fc7"
- top: "fc7_mbox_conf"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 126
- pad: 1
- kernel_size: 3
- stride: 1
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "fc7_mbox_conf_perm"
- type: "Permute"
- bottom: "fc7_mbox_conf"
- top: "fc7_mbox_conf_perm"
- permute_param {
- order: 0
- order: 2
- order: 3
- order: 1
- }
-}
-layer {
- name: "fc7_mbox_conf_flat"
- type: "Flatten"
- bottom: "fc7_mbox_conf_perm"
- top: "fc7_mbox_conf_flat"
- flatten_param {
- axis: 1
- }
-}
-layer {
- name: "fc7_mbox_priorbox"
- type: "PriorBox"
- bottom: "fc7"
- bottom: "data"
- top: "fc7_mbox_priorbox"
- prior_box_param {
- min_size: 60.0
- max_size: 114.0
- aspect_ratio: 2
- aspect_ratio: 3
- flip: true
- clip: true
- variance: 0.1
- variance: 0.1
- variance: 0.2
- variance: 0.2
- }
-}
-layer {
- name: "conv6_2_mbox_loc"
- type: "Convolution"
- bottom: "conv6_2"
- top: "conv6_2_mbox_loc"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 24
- pad: 1
- kernel_size: 3
- stride: 1
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "conv6_2_mbox_loc_perm"
- type: "Permute"
- bottom: "conv6_2_mbox_loc"
- top: "conv6_2_mbox_loc_perm"
- permute_param {
- order: 0
- order: 2
- order: 3
- order: 1
- }
-}
-layer {
- name: "conv6_2_mbox_loc_flat"
- type: "Flatten"
- bottom: "conv6_2_mbox_loc_perm"
- top: "conv6_2_mbox_loc_flat"
- flatten_param {
- axis: 1
- }
-}
-layer {
- name: "conv6_2_mbox_conf"
- type: "Convolution"
- bottom: "conv6_2"
- top: "conv6_2_mbox_conf"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 126
- pad: 1
- kernel_size: 3
- stride: 1
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "conv6_2_mbox_conf_perm"
- type: "Permute"
- bottom: "conv6_2_mbox_conf"
- top: "conv6_2_mbox_conf_perm"
- permute_param {
- order: 0
- order: 2
- order: 3
- order: 1
- }
-}
-layer {
- name: "conv6_2_mbox_conf_flat"
- type: "Flatten"
- bottom: "conv6_2_mbox_conf_perm"
- top: "conv6_2_mbox_conf_flat"
- flatten_param {
- axis: 1
- }
-}
-layer {
- name: "conv6_2_mbox_priorbox"
- type: "PriorBox"
- bottom: "conv6_2"
- bottom: "data"
- top: "conv6_2_mbox_priorbox"
- prior_box_param {
- min_size: 114.0
- max_size: 168.0
- aspect_ratio: 2
- aspect_ratio: 3
- flip: true
- clip: true
- variance: 0.1
- variance: 0.1
- variance: 0.2
- variance: 0.2
- }
-}
-layer {
- name: "conv7_2_mbox_loc"
- type: "Convolution"
- bottom: "conv7_2"
- top: "conv7_2_mbox_loc"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 24
- pad: 1
- kernel_size: 3
- stride: 1
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "conv7_2_mbox_loc_perm"
- type: "Permute"
- bottom: "conv7_2_mbox_loc"
- top: "conv7_2_mbox_loc_perm"
- permute_param {
- order: 0
- order: 2
- order: 3
- order: 1
- }
-}
-layer {
- name: "conv7_2_mbox_loc_flat"
- type: "Flatten"
- bottom: "conv7_2_mbox_loc_perm"
- top: "conv7_2_mbox_loc_flat"
- flatten_param {
- axis: 1
- }
-}
-layer {
- name: "conv7_2_mbox_conf"
- type: "Convolution"
- bottom: "conv7_2"
- top: "conv7_2_mbox_conf"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 126
- pad: 1
- kernel_size: 3
- stride: 1
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "conv7_2_mbox_conf_perm"
- type: "Permute"
- bottom: "conv7_2_mbox_conf"
- top: "conv7_2_mbox_conf_perm"
- permute_param {
- order: 0
- order: 2
- order: 3
- order: 1
- }
-}
-layer {
- name: "conv7_2_mbox_conf_flat"
- type: "Flatten"
- bottom: "conv7_2_mbox_conf_perm"
- top: "conv7_2_mbox_conf_flat"
- flatten_param {
- axis: 1
- }
-}
-layer {
- name: "conv7_2_mbox_priorbox"
- type: "PriorBox"
- bottom: "conv7_2"
- bottom: "data"
- top: "conv7_2_mbox_priorbox"
- prior_box_param {
- min_size: 168.0
- max_size: 222.0
- aspect_ratio: 2
- aspect_ratio: 3
- flip: true
- clip: true
- variance: 0.1
- variance: 0.1
- variance: 0.2
- variance: 0.2
- }
-}
-layer {
- name: "conv8_2_mbox_loc"
- type: "Convolution"
- bottom: "conv8_2"
- top: "conv8_2_mbox_loc"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 24
- pad: 1
- kernel_size: 3
- stride: 1
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "conv8_2_mbox_loc_perm"
- type: "Permute"
- bottom: "conv8_2_mbox_loc"
- top: "conv8_2_mbox_loc_perm"
- permute_param {
- order: 0
- order: 2
- order: 3
- order: 1
- }
-}
-layer {
- name: "conv8_2_mbox_loc_flat"
- type: "Flatten"
- bottom: "conv8_2_mbox_loc_perm"
- top: "conv8_2_mbox_loc_flat"
- flatten_param {
- axis: 1
- }
-}
-layer {
- name: "conv8_2_mbox_conf"
- type: "Convolution"
- bottom: "conv8_2"
- top: "conv8_2_mbox_conf"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 126
- pad: 1
- kernel_size: 3
- stride: 1
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "conv8_2_mbox_conf_perm"
- type: "Permute"
- bottom: "conv8_2_mbox_conf"
- top: "conv8_2_mbox_conf_perm"
- permute_param {
- order: 0
- order: 2
- order: 3
- order: 1
- }
-}
-layer {
- name: "conv8_2_mbox_conf_flat"
- type: "Flatten"
- bottom: "conv8_2_mbox_conf_perm"
- top: "conv8_2_mbox_conf_flat"
- flatten_param {
- axis: 1
- }
-}
-layer {
- name: "conv8_2_mbox_priorbox"
- type: "PriorBox"
- bottom: "conv8_2"
- bottom: "data"
- top: "conv8_2_mbox_priorbox"
- prior_box_param {
- min_size: 222.0
- max_size: 276.0
- aspect_ratio: 2
- aspect_ratio: 3
- flip: true
- clip: true
- variance: 0.1
- variance: 0.1
- variance: 0.2
- variance: 0.2
- }
-}
-layer {
- name: "pool6_mbox_loc"
- type: "Convolution"
- bottom: "pool6"
- top: "pool6_mbox_loc"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 24
- pad: 1
- kernel_size: 3
- stride: 1
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "pool6_mbox_loc_perm"
- type: "Permute"
- bottom: "pool6_mbox_loc"
- top: "pool6_mbox_loc_perm"
- permute_param {
- order: 0
- order: 2
- order: 3
- order: 1
- }
-}
-layer {
- name: "pool6_mbox_loc_flat"
- type: "Flatten"
- bottom: "pool6_mbox_loc_perm"
- top: "pool6_mbox_loc_flat"
- flatten_param {
- axis: 1
- }
-}
-layer {
- name: "pool6_mbox_conf"
- type: "Convolution"
- bottom: "pool6"
- top: "pool6_mbox_conf"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- convolution_param {
- num_output: 126
- pad: 1
- kernel_size: 3
- stride: 1
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
-}
-layer {
- name: "pool6_mbox_conf_perm"
- type: "Permute"
- bottom: "pool6_mbox_conf"
- top: "pool6_mbox_conf_perm"
- permute_param {
- order: 0
- order: 2
- order: 3
- order: 1
- }
-}
-layer {
- name: "pool6_mbox_conf_flat"
- type: "Flatten"
- bottom: "pool6_mbox_conf_perm"
- top: "pool6_mbox_conf_flat"
- flatten_param {
- axis: 1
- }
-}
-layer {
- name: "pool6_mbox_priorbox"
- type: "PriorBox"
- bottom: "pool6"
- bottom: "data"
- top: "pool6_mbox_priorbox"
- prior_box_param {
- min_size: 276.0
- max_size: 330.0
- aspect_ratio: 2
- aspect_ratio: 3
- flip: true
- clip: true
- variance: 0.1
- variance: 0.1
- variance: 0.2
- variance: 0.2
- }
-}
-layer {
- name: "mbox_loc"
- type: "Concat"
- bottom: "conv4_3_norm_mbox_loc_flat"
- bottom: "fc7_mbox_loc_flat"
- bottom: "conv6_2_mbox_loc_flat"
- bottom: "conv7_2_mbox_loc_flat"
- bottom: "conv8_2_mbox_loc_flat"
- bottom: "pool6_mbox_loc_flat"
- top: "mbox_loc"
- concat_param {
- axis: 1
- }
-}
-layer {
- name: "mbox_conf"
- type: "Concat"
- bottom: "conv4_3_norm_mbox_conf_flat"
- bottom: "fc7_mbox_conf_flat"
- bottom: "conv6_2_mbox_conf_flat"
- bottom: "conv7_2_mbox_conf_flat"
- bottom: "conv8_2_mbox_conf_flat"
- bottom: "pool6_mbox_conf_flat"
- top: "mbox_conf"
- concat_param {
- axis: 1
- }
-}
-layer {
- name: "mbox_priorbox"
- type: "Concat"
- bottom: "conv4_3_norm_mbox_priorbox"
- bottom: "fc7_mbox_priorbox"
- bottom: "conv6_2_mbox_priorbox"
- bottom: "conv7_2_mbox_priorbox"
- bottom: "conv8_2_mbox_priorbox"
- bottom: "pool6_mbox_priorbox"
- top: "mbox_priorbox"
- concat_param {
- axis: 2
- }
-}
-layer {
- name: "mbox_conf_reshape"
- type: "Reshape"
- bottom: "mbox_conf"
- top: "mbox_conf_reshape"
- reshape_param {
- shape {
- dim: 0
- dim: -1
- dim: 21
- }
- }
-}
-layer {
- name: "mbox_conf_softmax"
- type: "Softmax"
- bottom: "mbox_conf_reshape"
- top: "mbox_conf_softmax"
- softmax_param {
- axis: 2
- }
-}
-layer {
- name: "mbox_conf_flatten"
- type: "Flatten"
- bottom: "mbox_conf_softmax"
- top: "mbox_conf_flatten"
- flatten_param {
- axis: 1
- }
-}
-layer {
- name: "detection_out"
- type: "DetectionOutput"
- bottom: "mbox_loc"
- bottom: "mbox_conf_flatten"
- bottom: "mbox_priorbox"
- top: "detection_out"
- include {
- phase: TEST
- }
- detection_output_param {
- num_classes: 21
- share_location: true
- background_label_id: 0
- nms_threshold: 0.45
- top_k: 400
- code_type: CENTER_SIZE
- keep_top_k: 200
- confidence_threshold: 0.01
- }
-}
-
diff --git a/contrib/modules/dnn/samples/caffe_googlenet.cpp b/contrib/modules/dnn/samples/caffe_googlenet.cpp
deleted file mode 100644
index ddd5d8b..0000000
--- a/contrib/modules/dnn/samples/caffe_googlenet.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/**M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include <opencv2/dnn.hpp>
-#include <opencv2/imgproc.hpp>
-#include <opencv2/highgui.hpp>
-using namespace cv;
-using namespace cv::dnn;
-
-#include <fstream>
-#include <iostream>
-#include <cstdlib>
-using namespace std;
-
-/* Find best class for the blob (i. e. class with maximal probability) */
-void getMaxClass(dnn::Blob &probBlob, int *classId, double *classProb)
-{
- Mat probMat = probBlob.matRefConst().reshape(1, 1); //reshape the blob to 1x1000 matrix
- Point classNumber;
-
- minMaxLoc(probMat, NULL, classProb, NULL, &classNumber);
- *classId = classNumber.x;
-}
-
-std::vector<String> readClassNames(const char *filename = "synset_words.txt")
-{
- std::vector<String> classNames;
-
- std::ifstream fp(filename);
- if (!fp.is_open())
- {
- std::cerr << "File with classes labels not found: " << filename << std::endl;
- exit(-1);
- }
-
- std::string name;
- while (!fp.eof())
- {
- std::getline(fp, name);
- if (name.length())
- classNames.push_back( name.substr(name.find(' ')+1) );
- }
-
- fp.close();
- return classNames;
-}
-
-int main(int argc, char **argv)
-{
- cv::dnn::initModule(); //Required if OpenCV is built as static libs
-
- String modelTxt = "bvlc_googlenet.prototxt";
- String modelBin = "bvlc_googlenet.caffemodel";
- String imageFile = (argc > 1) ? argv[1] : "space_shuttle.jpg";
-
- //! [Read and initialize network]
- Net net = dnn::readNetFromCaffe(modelTxt, modelBin);
- //! [Read and initialize network]
-
- //! [Check that network was read successfully]
- if (net.empty())
- {
- std::cerr << "Can't load network by using the following files: " << std::endl;
- std::cerr << "prototxt: " << modelTxt << std::endl;
- std::cerr << "caffemodel: " << modelBin << std::endl;
- std::cerr << "bvlc_googlenet.caffemodel can be downloaded here:" << std::endl;
- std::cerr << "http://dl.caffe.berkeleyvision.org/bvlc_googlenet.caffemodel" << std::endl;
- exit(-1);
- }
- //! [Check that network was read successfully]
-
- //! [Prepare blob]
- Mat img = imread(imageFile);
- if (img.empty())
- {
- std::cerr << "Can't read image from the file: " << imageFile << std::endl;
- exit(-1);
- }
-
- resize(img, img, Size(224, 224)); //GoogLeNet accepts only 224x224 RGB-images
- dnn::Blob inputBlob = dnn::Blob::fromImages(img); //Convert Mat to dnn::Blob batch of images
- //! [Prepare blob]
-
- //! [Set input blob]
- net.setBlob(".data", inputBlob); //set the network input
- //! [Set input blob]
-
- //! [Make forward pass]
- net.forward(); //compute output
- //! [Make forward pass]
-
- //! [Gather output]
- dnn::Blob prob = net.getBlob("prob"); //gather output of "prob" layer
-
- int classId;
- double classProb;
- getMaxClass(prob, &classId, &classProb);//find the best class
- //! [Gather output]
-
- //! [Print results]
- std::vector<String> classNames = readClassNames();
- std::cout << "Best class: #" << classId << " '" << classNames.at(classId) << "'" << std::endl;
- std::cout << "Probability: " << classProb * 100 << "%" << std::endl;
- //! [Print results]
-
- return 0;
-} //main
diff --git a/contrib/modules/dnn/samples/fcn_semsegm.cpp b/contrib/modules/dnn/samples/fcn_semsegm.cpp
deleted file mode 100755
index bdeb75c..0000000
--- a/contrib/modules/dnn/samples/fcn_semsegm.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-#include <opencv2/dnn.hpp>
-#include <opencv2/imgproc.hpp>
-#include <opencv2/highgui.hpp>
-#include <opencv2/core/ocl.hpp>
-using namespace cv;
-using namespace cv::dnn;
-
-#include <fstream>
-#include <iostream>
-#include <cstdlib>
-using namespace std;
-
-static const string fcnType = "fcn8s";
-
-static vector<cv::Vec3b> readColors(const string &filename = "pascal-classes.txt")
-{
- vector<cv::Vec3b> colors;
-
- ifstream fp(filename.c_str());
- if (!fp.is_open())
- {
- cerr << "File with colors not found: " << filename << endl;
- exit(-1);
- }
-
- string line;
- while (!fp.eof())
- {
- getline(fp, line);
- if (line.length())
- {
- stringstream ss(line);
-
- string name; ss >> name;
- int temp;
- cv::Vec3b color;
- ss >> temp; color[0] = temp;
- ss >> temp; color[1] = temp;
- ss >> temp; color[2] = temp;
- colors.push_back(color);
- }
- }
-
- fp.close();
- return colors;
-}
-
-static void colorizeSegmentation(dnn::Blob &score, const vector<cv::Vec3b> &colors, cv::Mat &segm)
-{
- const int rows = score.rows();
- const int cols = score.cols();
- const int chns = score.channels();
-
- cv::Mat maxCl(rows, cols, CV_8UC1);
- cv::Mat maxVal(rows, cols, CV_32FC1);
- for (int ch = 0; ch < chns; ch++)
- {
- for (int row = 0; row < rows; row++)
- {
- const float *ptrScore = score.ptrf(0, ch, row);
- uchar *ptrMaxCl = maxCl.ptr<uchar>(row);
- float *ptrMaxVal = maxVal.ptr<float>(row);
- for (int col = 0; col < cols; col++)
- {
- if (ptrScore[col] > ptrMaxVal[col])
- {
- ptrMaxVal[col] = ptrScore[col];
- ptrMaxCl[col] = ch;
- }
- }
- }
- }
-
- segm.create(rows, cols, CV_8UC3);
- for (int row = 0; row < rows; row++)
- {
- const uchar *ptrMaxCl = maxCl.ptr<uchar>(row);
- cv::Vec3b *ptrSegm = segm.ptr<cv::Vec3b>(row);
- for (int col = 0; col < cols; col++)
- {
- ptrSegm[col] = colors[ptrMaxCl[col]];
- }
- }
-
-}
-
-int main(int argc, char **argv)
-{
- cv::dnn::initModule(); //Required if OpenCV is built as static libs
- cv::ocl::setUseOpenCL(false); //OpenCL switcher
-
- String modelTxt = fcnType + "-heavy-pascal.prototxt";
- String modelBin = fcnType + "-heavy-pascal.caffemodel";
- String imageFile = (argc > 1) ? argv[1] : "rgb.jpg";
-
- vector<cv::Vec3b> colors = readColors();
-
- //! [Create the importer of Caffe model]
- Ptr<dnn::Importer> importer;
- try //Try to import Caffe GoogleNet model
- {
- importer = dnn::createCaffeImporter(modelTxt, modelBin);
- }
- catch (const cv::Exception &err) //Importer can throw errors, we will catch them
- {
- cerr << err.msg << endl;
- }
- //! [Create the importer of Caffe model]
-
- if (!importer)
- {
- cerr << "Can't load network by using the following files: " << endl;
- cerr << "prototxt: " << modelTxt << endl;
- cerr << "caffemodel: " << modelBin << endl;
- cerr << fcnType << "-heavy-pascal.caffemodel can be downloaded here:" << endl;
- cerr << "http://dl.caffe.berkeleyvision.org/" << fcnType << "-heavy-pascal.caffemodel" << endl;
- exit(-1);
- }
-
- //! [Initialize network]
- dnn::Net net;
- importer->populateNet(net);
- importer.release(); //We don't need importer anymore
- //! [Initialize network]
-
- //! [Prepare blob]
- Mat img = imread(imageFile);
- if (img.empty())
- {
- cerr << "Can't read image from the file: " << imageFile << endl;
- exit(-1);
- }
-
- resize(img, img, Size(500, 500)); //FCN accepts 500x500 RGB-images
- dnn::Blob inputBlob = dnn::Blob::fromImages(img); //Convert Mat to dnn::Blob batch of images
- //! [Prepare blob]
-
- //! [Set input blob]
- net.setBlob(".data", inputBlob); //set the network input
- //! [Set input blob]
-
- //! [Make forward pass]
- double t = (double)cv::getTickCount();
- net.forward(); //compute output
- t = (double)cv::getTickCount() - t;
- printf("processing time: %.1fms\n", t*1000./getTickFrequency());
- //! [Make forward pass]
-
- //! [Gather output]
- dnn::Blob score = net.getBlob("score");
-
- cv::Mat colorize;
- colorizeSegmentation(score, colors, colorize);
- cv::Mat show;
- cv::addWeighted(img, 0.4, colorize, 0.6, 0.0, show);
- cv::imshow("show", show);
- cv::waitKey(0);
- return 0;
-} //main
diff --git a/contrib/modules/dnn/samples/googlenet_python.py b/contrib/modules/dnn/samples/googlenet_python.py
deleted file mode 100644
index 53ccdc5..0000000
--- a/contrib/modules/dnn/samples/googlenet_python.py
+++ /dev/null
@@ -1,34 +0,0 @@
-from __future__ import print_function
-import numpy as np
-import cv2
-from cv2 import dnn
-import timeit
-
-def prepare_image(img):
- img = cv2.resize(img, (224, 224))
- #convert interleaved image (RGBRGB) to planar(RRGGBB)
- blob = np.moveaxis(img, 2, 0)
- blob = np.reshape(blob.astype(np.float32), (-1, 3, 224, 224))
- return blob
-
-def timeit_forward(net):
- print("OpenCL:", cv2.ocl.useOpenCL())
- print("Runtime:", timeit.timeit(lambda: net.forward(), number=10))
-
-def get_class_list():
- with open('synset_words.txt', 'rt') as f:
- return [ x[x.find(" ") + 1 :] for x in f ]
-
-blob = prepare_image(cv2.imread('space_shuttle.jpg'))
-print("Input:", blob.shape, blob.dtype)
-
-cv2.ocl.setUseOpenCL(True) #Disable OCL if you want
-net = dnn.readNetFromCaffe('bvlc_googlenet.prototxt', 'bvlc_googlenet.caffemodel')
-net.setBlob(".data", blob)
-net.forward()
-#timeit_forward(net) #Uncomment to check performance
-
-prob = net.getBlob("prob")
-print("Output:", prob.shape, prob.dtype)
-classes = get_class_list()
-print("Best match", classes[prob.argmax()])
\ No newline at end of file
diff --git a/contrib/modules/dnn/samples/ssd_object_detection.cpp b/contrib/modules/dnn/samples/ssd_object_detection.cpp
deleted file mode 100644
index ec01d8f..0000000
--- a/contrib/modules/dnn/samples/ssd_object_detection.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-#include <opencv2/dnn.hpp>
-#include <opencv2/imgproc.hpp>
-#include <opencv2/highgui.hpp>
-using namespace cv;
-using namespace cv::dnn;
-
-#include <fstream>
-#include <iostream>
-#include <cstdlib>
-using namespace std;
-
-const size_t width = 300;
-const size_t height = 300;
-
-Mat getMean(const size_t& imageHeight, const size_t& imageWidth)
-{
- Mat mean;
-
- const int meanValues[3] = {104, 117, 123};
- vector<Mat> meanChannels;
- for(size_t i = 0; i < 3; i++)
- {
- Mat channel(imageHeight, imageWidth, CV_32F, Scalar(meanValues[i]));
- meanChannels.push_back(channel);
- }
- cv::merge(meanChannels, mean);
- return mean;
-}
-
-Mat preprocess(const Mat& frame)
-{
- Mat preprocessed;
- frame.convertTo(preprocessed, CV_32FC3);
- resize(preprocessed, preprocessed, Size(width, height)); //SSD accepts 300x300 RGB-images
-
- Mat mean = getMean(width, height);
- cv::subtract(preprocessed, mean, preprocessed);
-
- return preprocessed;
-}
-
-const char* about = "This sample uses Single-Shot Detector "
- "(https://arxiv.org/abs/1512.02325)"
- "to detect objects on image\n"; // TODO: link
-
-const char* params
- = "{ help | false | print usage }"
- "{ proto | | model configuration }"
- "{ model | | model weights }"
- "{ image | | image for detection }"
- "{ min_confidence | 0.5 | min confidence }";
-
-int main(int argc, char** argv)
-{
- cv::CommandLineParser parser(argc, argv, params);
-
- if (parser.get<bool>("help"))
- {
- std::cout << about << std::endl;
- parser.printMessage();
- return 0;
- }
-
- cv::dnn::initModule(); //Required if OpenCV is built as static libs
-
- String modelConfiguration = parser.get<string>("proto");
- String modelBinary = parser.get<string>("model");
-
- //! [Create the importer of Caffe model]
- Ptr<dnn::Importer> importer;
-
- // Import Caffe SSD model
- try
- {
- importer = dnn::createCaffeImporter(modelConfiguration, modelBinary);
- }
- catch (const cv::Exception &err) //Importer can throw errors, we will catch them
- {
- cerr << err.msg << endl;
- }
- //! [Create the importer of Caffe model]
-
- if (!importer)
- {
- cerr << "Can't load network by using the following files: " << endl;
- cerr << "prototxt: " << modelConfiguration << endl;
- cerr << "caffemodel: " << modelBinary << endl;
- cerr << "Models can be downloaded here:" << endl;
- cerr << "https://github.com/weiliu89/caffe/tree/ssd#models" << endl;
- exit(-1);
- }
-
- //! [Initialize network]
- dnn::Net net;
- importer->populateNet(net);
- importer.release(); //We don't need importer anymore
- //! [Initialize network]
-
- cv::Mat frame = cv::imread(parser.get<string>("image"), -1);
-
- //! [Prepare blob]
- Mat preprocessedFrame = preprocess(frame);
-
- dnn::Blob inputBlob = dnn::Blob::fromImages(preprocessedFrame); //Convert Mat to dnn::Blob image
- //! [Prepare blob]
-
- //! [Set input blob]
- net.setBlob(".data", inputBlob); //set the network input
- //! [Set input blob]
-
- //! [Make forward pass]
- net.forward(); //compute output
- //! [Make forward pass]
-
- //! [Gather output]
- dnn::Blob detection = net.getBlob("detection_out");
- Mat detectionMat(detection.rows(), detection.cols(), CV_32F, detection.ptrf());
-
- float confidenceThreshold = parser.get<float>("min_confidence");
- for(int i = 0; i < detectionMat.rows; i++)
- {
- float confidence = detectionMat.at<float>(i, 2);
-
- if(confidence > confidenceThreshold)
- {
- size_t objectClass = detectionMat.at<float>(i, 1);
-
- float xLeftBottom = detectionMat.at<float>(i, 3) * frame.cols;
- float yLeftBottom = detectionMat.at<float>(i, 4) * frame.rows;
- float xRightTop = detectionMat.at<float>(i, 5) * frame.cols;
- float yRightTop = detectionMat.at<float>(i, 6) * frame.rows;
-
- std::cout << "Class: " << objectClass << std::endl;
- std::cout << "Confidence: " << confidence << std::endl;
-
- std::cout << " " << xLeftBottom
- << " " << yLeftBottom
- << " " << xRightTop
- << " " << yRightTop << std::endl;
-
- Rect object(xLeftBottom, yLeftBottom,
- xRightTop - xLeftBottom,
- yRightTop - yLeftBottom);
-
- rectangle(frame, object, Scalar(0, 255, 0));
- }
- }
-
- imshow("detections", frame);
- waitKey();
-
- return 0;
-} // main
diff --git a/contrib/modules/dnn/samples/tf_inception.cpp b/contrib/modules/dnn/samples/tf_inception.cpp
deleted file mode 100644
index e3b6e9c..0000000
--- a/contrib/modules/dnn/samples/tf_inception.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-// This file is part of OpenCV project.
-// It is subject to the license terms in the LICENSE file found in the top-level directory
-// of this distribution and at http://opencv.org/license.html.
-
-// Copyright (C) 2016, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-
-/*
-Sample of using OpenCV dnn module with Tensorflow Inception model.
-*/
-
-#include <opencv2/dnn.hpp>
-#include <opencv2/imgproc.hpp>
-#include <opencv2/highgui.hpp>
-using namespace cv;
-using namespace cv::dnn;
-
-#include <fstream>
-#include <iostream>
-#include <cstdlib>
-using namespace std;
-
-const String keys =
- "{help h || Sample app for loading Inception TensorFlow model. "
- "The model and class names list can be downloaded here: "
- "https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip }"
- "{model m |tensorflow_inception_graph.pb| path to TensorFlow .pb model file }"
- "{image i || path to image file }"
- "{i_blob | .input | input blob name) }"
- "{o_blob | softmax2 | output blob name) }"
- "{c_names c | imagenet_comp_graph_label_strings.txt | path to file with classnames for class id }"
- "{result r || path to save output blob (optional, binary format, NCHW order) }"
- ;
-
-void getMaxClass(dnn::Blob &probBlob, int *classId, double *classProb);
-std::vector<String> readClassNames(const char *filename);
-
-int main(int argc, char **argv)
-{
- cv::CommandLineParser parser(argc, argv, keys);
-
- if (parser.has("help"))
- {
- parser.printMessage();
- return 0;
- }
-
- String modelFile = parser.get<String>("model");
- String imageFile = parser.get<String>("image");
- String inBlobName = parser.get<String>("i_blob");
- String outBlobName = parser.get<String>("o_blob");
-
- if (!parser.check())
- {
- parser.printErrors();
- return 0;
- }
-
- String classNamesFile = parser.get<String>("c_names");
- String resultFile = parser.get<String>("result");
-
- //! [Create the importer of TensorFlow model]
- Ptr<dnn::Importer> importer;
- try //Try to import TensorFlow AlexNet model
- {
- importer = dnn::createTensorflowImporter(modelFile);
- }
- catch (const cv::Exception &err) //Importer can throw errors, we will catch them
- {
- std::cerr << err.msg << std::endl;
- }
- //! [Create the importer of Caffe model]
-
- if (!importer)
- {
- std::cerr << "Can't load network by using the mode file: " << std::endl;
- std::cerr << modelFile << std::endl;
- exit(-1);
- }
-
- //! [Initialize network]
- dnn::Net net;
- importer->populateNet(net);
- importer.release(); //We don't need importer anymore
- //! [Initialize network]
-
- //! [Prepare blob]
- Mat img = imread(imageFile);
- if (img.empty())
- {
- std::cerr << "Can't read image from the file: " << imageFile << std::endl;
- exit(-1);
- }
-
- cv::Size inputImgSize = cv::Size(224, 224);
-
- if (inputImgSize != img.size())
- resize(img, img, inputImgSize); //Resize image to input size
-
- cv::cvtColor(img, img, cv::COLOR_BGR2RGB);
-
- dnn::Blob inputBlob = dnn::Blob::fromImages(img); //Convert Mat to dnn::Blob image batch
- //! [Prepare blob]
-
- //! [Set input blob]
- net.setBlob(inBlobName, inputBlob); //set the network input
- //! [Set input blob]
-
- cv::TickMeter tm;
- tm.start();
-
- //! [Make forward pass]
- net.forward(); //compute output
- //! [Make forward pass]
-
- tm.stop();
-
- //! [Gather output]
- dnn::Blob prob = net.getBlob(outBlobName); //gather output of "prob" layer
-
- Mat& result = prob.matRef();
-
- BlobShape shape = prob.shape();
-
- if (!resultFile.empty()) {
- CV_Assert(result.isContinuous());
-
- ofstream fout(resultFile.c_str(), ios::out | ios::binary);
- fout.write((char*)result.data, result.total() * sizeof(float));
- fout.close();
- }
-
- std::cout << "Output blob shape " << shape << std::endl;
- std::cout << "Inference time, ms: " << tm.getTimeMilli() << std::endl;
-
- if (!classNamesFile.empty()) {
- std::vector<String> classNames = readClassNames(classNamesFile.c_str());
-
- int classId;
- double classProb;
- getMaxClass(prob, &classId, &classProb);//find the best class
-
- //! [Print results]
- std::cout << "Best class: #" << classId << " '" << classNames.at(classId) << "'" << std::endl;
- std::cout << "Probability: " << classProb * 100 << "%" << std::endl;
- }
- return 0;
-} //main
-
-
-/* Find best class for the blob (i. e. class with maximal probability) */
-void getMaxClass(dnn::Blob &probBlob, int *classId, double *classProb)
-{
- Mat probMat = probBlob.matRefConst().reshape(1, 1); //reshape the blob to 1x1000 matrix
- Point classNumber;
-
- minMaxLoc(probMat, NULL, classProb, NULL, &classNumber);
- *classId = classNumber.x;
-}
-
-std::vector<String> readClassNames(const char *filename)
-{
- std::vector<String> classNames;
-
- std::ifstream fp(filename);
- if (!fp.is_open())
- {
- std::cerr << "File with classes labels not found: " << filename << std::endl;
- exit(-1);
- }
-
- std::string name;
- while (!fp.eof())
- {
- std::getline(fp, name);
- if (name.length())
- classNames.push_back( name );
- }
-
- fp.close();
- return classNames;
-}
diff --git a/contrib/modules/dnn/src/blob.cpp b/contrib/modules/dnn/src/blob.cpp
deleted file mode 100644
index 9dc0d97..0000000
--- a/contrib/modules/dnn/src/blob.cpp
+++ /dev/null
@@ -1,421 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-#include <opencv2/dnn/shape_utils.hpp>
-
-namespace cv
-{
-namespace dnn
-{
-
-Blob::Blob()
-{
- CV_DNN_UMAT_ONLY(state = UNINITIALIZED);
-}
-
-Blob::Blob(const BlobShape &shape, int type, int allocFlags)
-{
- CV_DNN_UMAT_ONLY(state = UNINITIALIZED);
- this->create(shape, type, allocFlags);
-}
-
-Blob::Blob(InputArray data)
-{
-#ifndef CV_DNN_UMAT
- m = data.getMat();
-#else
- if (data.isUMat())
- {
- um = data.getUMat();
- state = HEAD_AT_UMAT;
- }
- else
- {
- m = data.getMat();
- state = HEAD_AT_MAT;
- }
-#endif
-}
-
-void Blob::create(const BlobShape &shape, int type, int allocFlags)
-{
-#ifndef CV_DNN_UMAT
- CV_Assert(allocFlags & ALLOC_MAT);
- m.create(shape.dims(), shape.ptr(), type);
-#else
- CV_Assert(allocFlags & ALLOC_MAT || allocFlags & ALLOC_UMAT);
-
- if (allocFlags & ALLOC_MAT)
- m.create(shape.dims(), shape.ptr(), type);
- if (allocFlags & ALLOC_UMAT)
- um.create(shape.dims(), shape.ptr(), type);
-
- if (state == UNINITIALIZED)
- {
- if (allocFlags & ALLOC_MAT && allocFlags & ALLOC_UMAT)
- state = SYNCED;
- else if (allocFlags & ALLOC_MAT)
- state = HEAD_AT_MAT;
- else
- state = HEAD_AT_UMAT;
- }
-#endif
-}
-
-void Blob::fill(InputArray in)
-{
-#ifdef CV_DNN_UMAT
- CV_Assert(in.isMat() || in.isUMat());
- if (in.isMat())
- {
- m = in.getMat();
- state = HEAD_AT_MAT;
- }
- else
- {
- um = in.getUMat();
- state = HEAD_AT_UMAT;
- }
-#else
- CV_Assert(in.isMat());
- m = in.getMat();
-#endif
-}
-
-static inline int getMatChannels(const Mat &mat)
-{
- return (mat.dims <= 2) ? mat.channels() : mat.size[0];
-}
-
-static BlobShape getBlobShape(std::vector<Mat> &vmat, int requestedCn = -1)
-{
- BlobShape shape(BlobShape::all(4));
- int cnSum = 0, matCn;
-
- CV_Assert(vmat.size() > 0);
-
- for (size_t i = 0; i < vmat.size(); i++)
- {
- Mat &mat = vmat[i];
- CV_Assert(!mat.empty());
- CV_Assert((mat.dims == 3 && mat.channels() == 1) || mat.dims <= 2);
-
- matCn = getMatChannels(mat);
- cnSum += getMatChannels(mat);
-
- if (i == 0)
- {
- shape[-1] = mat.cols;
- shape[-2] = mat.rows;
- shape[-3] = (requestedCn <= 0) ? matCn : requestedCn;
- }
- else
- {
- if (mat.cols != shape[-1] || mat.rows != shape[-2])
- CV_Error(Error::StsError, "Each Mat.size() must be equal");
-
- if (requestedCn <= 0 && matCn != shape[-3])
- CV_Error(Error::StsError, "Each Mat.chnannels() (or number of planes) must be equal");
- }
- }
-
- if (cnSum % shape[-3] != 0)
- CV_Error(Error::StsError, "Total number of channels in vector is not a multiple of requsted channel number");
-
- shape[0] = cnSum / shape[-3];
- return shape;
-}
-
-static std::vector<Mat> extractMatVector(InputArray in)
-{
- if (in.isMat() || in.isUMat())
- {
- return std::vector<Mat>(1, in.getMat());
- }
- else if (in.isMatVector())
- {
- return *static_cast<const std::vector<Mat>*>(in.getObj());
- }
- else if (in.isUMatVector())
- {
- std::vector<Mat> vmat;
- in.getMatVector(vmat);
- return vmat;
- }
- else
- {
- CV_Assert(in.isMat() || in.isMatVector() || in.isUMat() || in.isUMatVector());
- return std::vector<Mat>();
- }
-}
-
-void Blob::batchFromImages(InputArray image, int dstCn)
-{
- CV_Assert(dstCn == -1 || dstCn > 0);
- std::vector<Mat> inMats = extractMatVector(image);
- BlobShape dstShape = getBlobShape(inMats, dstCn);
-
- int dtype = CV_32F;
- this->create(dstShape, dtype, ALLOC_MAT);
- uchar *dstPtr = this->matRef().ptr();
- int elemSize = CV_ELEM_SIZE(dtype);
-
- std::vector<Mat> wrapBuf(dstShape[-3]);
- for (size_t i = 0; i < inMats.size(); i++)
- {
- Mat inMat = inMats[i];
-
- if (inMat.dims <= 2)
- {
- inMat.convertTo(inMat, dtype);
-
- wrapBuf.resize(0);
- for (int cn = 0; cn < inMat.channels(); cn++)
- {
- wrapBuf.push_back(Mat(inMat.rows, inMat.cols, dtype, dstPtr));
- dstPtr += elemSize * inMat.total();
- }
-
- cv::split(inMat, wrapBuf);
- }
- else
- {
- inMat.convertTo(Mat(inMat.dims, inMat.size, dtype, dstPtr), dtype);
- dstPtr += elemSize * inMat.total();
- }
- }
-}
-
-Blob Blob::fromImages(InputArray image, int dstCn)
-{
- Blob res;
- res.batchFromImages(image, dstCn);
- return res;
-}
-
-void Blob::fill(const BlobShape &shape, int type, void *data, bool deepCopy)
-{
- if (deepCopy)
- {
- create(shape, type);
- memcpy(ptr(), data, this->total() * CV_ELEM_SIZE(type));
- }
- else
- {
- m = Mat(shape.dims(), shape.ptr(), type, data);
- }
- CV_DNN_UMAT_ONLY(state = HEAD_AT_MAT);
-}
-
-void Blob::setTo(InputArray value, int allocFlags)
-{
-#ifdef CV_DNN_UMAT
- if (allocFlags == -1)
- {
- if (state == HEAD_AT_UMAT)
- um.setTo(value);
- else if (state == HEAD_AT_MAT)
- m.setTo(value);
- else //SYNCED or UNINITIALIZED
- {
- um.setTo(value);
- m.setTo(value);
-
- if (state == UNINITIALIZED)
- state = SYNCED;
- }
- }
- else if (allocFlags == ALLOC_BOTH)
- {
- m.setTo(value);
- um.setTo(value);
- state = SYNCED;
- }
- else if (allocFlags == ALLOC_MAT)
- {
- matRef().setTo(value);
- }
- else if (allocFlags == ALLOC_UMAT)
- {
- umatRef().setTo(value);
- }
- else
- {
- CV_Error(Error::StsBadArg, "allocFlags sholud be -1 or one of Blob::AllocFlag values");
- }
-#else
- m.setTo(value);
-#endif
-}
-
-void Blob::updateMat(bool syncData) const
-{
-#ifdef CV_DNN_UMAT
- if (state == UNINITIALIZED || state == SYNCED || state == HEAD_AT_MAT)
- {
- return;
- }
- else if (state == HEAD_AT_UMAT)
- {
- if (syncData)
- um.copyTo(m);
- else
- m.create(dims(), sizes(), type());
- state = SYNCED;
- }
- else
- {
- CV_Error(Error::StsInternal, "");
- }
-#else
- (void)syncData;
-#endif
-}
-
-void Blob::updateUMat(bool syncData) const
-{
-#ifdef CV_DNN_UMAT
- if (state == UNINITIALIZED || state == SYNCED || state == HEAD_AT_UMAT)
- {
- return;
- }
- else if (state == HEAD_AT_MAT)
- {
- if (syncData)
- m.copyTo(um);
- else
- um.create(dims(), sizes(), type());
- }
- else
- {
- CV_Error(Error::StsInternal, "");
- }
-#else
- (void)syncData;
-#endif
-}
-
-void Blob::sync() const
-{
- updateMat();
- updateUMat();
-}
-
-Vec4i Blob::shape4() const
-{
- return Vec4i(num(), channels(), rows(), cols());
-}
-
-//BlobShape
-
-std::ostream &operator<< (std::ostream &stream, const BlobShape &shape)
-{
- stream << "[";
-
- for (int i = 0; i < shape.dims() - 1; i++)
- stream << shape[i] << ", ";
- if (shape.dims() > 0)
- stream << shape[-1];
-
- return stream << "]";
-}
-
-BlobShape computeShapeByReshapeMask(const BlobShape &srcShape, const BlobShape &maskShape, Range srcRange /*= Range::all()*/)
-{
- if (srcRange == Range::all())
- srcRange = Range(0, srcShape.dims());
- else
- {
- int sz = srcRange.size();
- srcRange.start = srcShape.canonicalAxis(srcRange.start);
- srcRange.end = (srcRange.end == INT_MAX) ? srcShape.dims() : srcRange.start + sz;
- }
-
- CV_Assert(0 <= srcRange.start && srcRange.start <= srcRange.end && srcRange.end <= srcShape.dims());
- BlobShape dstShape(srcShape.dims() - srcRange.size() + maskShape.dims(), (const int*)NULL);
-
- std::copy(srcShape.ptr(), srcShape.ptr() + srcRange.start, dstShape.ptr());
- std::copy(srcShape.ptr() + srcRange.end, srcShape.ptr() + srcShape.dims(), dstShape.ptr() + srcRange.start + maskShape.dims());
-
- int inferDim = -1;
- for (int i = 0; i < maskShape.dims(); i++)
- {
- if (maskShape[i] > 0)
- {
- dstShape[srcRange.start + i] = maskShape[i];
- }
- else if (maskShape[i] == 0)
- {
- if (srcRange.start + i >= srcShape.dims())
- CV_Error(Error::StsBadArg, format("Copy dim[%d] (which has zero size) is out of the source shape bounds", srcRange.start + i));
- dstShape[srcRange.start + i] = srcShape[srcRange.start + i];
- }
- else if (maskShape[i] == -1)
- {
- if (inferDim != -1)
- CV_Error(Error::StsAssert, "Duplicate of inferred dim (which is denoted by -1)");
- inferDim = srcRange.start + i;
- dstShape[inferDim] = 1;
- }
- else
- CV_Error(Error::StsBadArg, "maskShape[i] >= -1");
- }
-
- if (inferDim != -1)
- {
- ptrdiff_t srcTotal = srcShape.total();
- ptrdiff_t dstTotal = dstShape.total();
- if (srcTotal % dstTotal != 0)
- CV_Error(Error::StsBackTrace, "Can't infer a dim denoted by -1");
-
- dstShape[inferDim] = (int)(srcTotal / dstTotal);
- }
- else
- {
- CV_Assert(srcShape.total() == dstShape.total());
- }
-
- return dstShape;
-}
-
-}
-}
diff --git a/contrib/modules/dnn/src/caffe/caffe.proto b/contrib/modules/dnn/src/caffe/caffe.proto
deleted file mode 100644
index f769fd0..0000000
--- a/contrib/modules/dnn/src/caffe/caffe.proto
+++ /dev/null
@@ -1,1267 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//COPYRIGHT
-//
-//All contributions by the University of California:
-//Copyright (c) 2014, The Regents of the University of California (Regents)
-//All rights reserved.
-//
-//All other contributions:
-//Copyright (c) 2014, the respective contributors
-//All rights reserved.
-//
-//Caffe uses a shared copyright model: each contributor holds copyright over
-//their contributions to Caffe. The project versioning records all such
-//contribution and copyright details. If a contributor wants to further mark
-//their specific copyright on a particular contribution, they should indicate
-//their copyright solely in the commit message of the change when it is
-//committed.
-//
-//LICENSE
-//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions are met:
-//
-//1. Redistributions of source code must retain the above copyright notice, this
-// list of conditions and the following disclaimer.
-//2. Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-//ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-//DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-//ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-//(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-//ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-//(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-//CONTRIBUTION AGREEMENT
-//
-//By contributing to the BVLC/caffe repository through pull-request, comment,
-//or otherwise, the contributor releases their content to the
-//license and copyright terms herein.
-//
-//M*/
-
-syntax = "proto2";
-
-package caffe;
-
-// Specifies the shape (dimensions) of a Blob.
-message BlobShape {
- repeated int64 dim = 1 [packed = true];
-}
-
-message BlobProto {
- optional BlobShape shape = 7;
- repeated float data = 5 [packed = true];
- repeated float diff = 6 [packed = true];
-
- // 4D dimensions -- deprecated. Use "shape" instead.
- optional int32 num = 1 [default = 0];
- optional int32 channels = 2 [default = 0];
- optional int32 height = 3 [default = 0];
- optional int32 width = 4 [default = 0];
-}
-
-// The BlobProtoVector is simply a way to pass multiple blobproto instances
-// around.
-message BlobProtoVector {
- repeated BlobProto blobs = 1;
-}
-
-message CropParameter {
- // To crop, elements of the first bottom are selected to fit the dimensions
- // of the second, reference bottom. The crop is configured by
- // - the crop `axis` to pick the dimensions for cropping
- // - the crop `offset` to set the shift for all/each dimension
- // to align the cropped bottom with the reference bottom.
- // All dimensions up to but excluding `axis` are preserved, while
- // the dimensions including and trailing `axis` are cropped.
- // If only one `offset` is set, then all dimensions are offset by this amount.
- // Otherwise, the number of offsets must equal the number of cropped axes to
- // shift the crop in each dimension accordingly.
- // Note: standard dimensions are N,C,H,W so the default is a spatial crop,
- // and `axis` may be negative to index from the end (e.g., -1 for the last
- // axis).
- optional int32 axis = 1 [default = 2];
- repeated uint32 offset = 2;
-}
-
-message PermuteParameter {
- // The new orders of the axes of data. Notice it should be with
- // in the same range as the input data, and it starts from 0.
- // Do not provide repeated order.
- repeated uint32 order = 1;
-}
-
-// Message that stores parameters used by NormalizeBBoxLayer
-message NormalizeBBoxParameter {
- optional bool across_spatial = 1 [default = true];
- // Initial value of scale. Default is 1.0 for all
- optional FillerParameter scale_filler = 2;
- // Whether or not scale parameters are shared across channels.
- optional bool channel_shared = 3 [default = true];
- // Epsilon for not dividing by zero while normalizing variance
- optional float eps = 4 [default = 1e-10];
-}
-
-// Message that store parameters used by PriorBoxLayer
-message PriorBoxParameter {
- // Encode/decode type.
- enum CodeType {
- CORNER = 1;
- CENTER_SIZE = 2;
- }
- // Minimum box size (in pixels). Required!
- optional float min_size = 1;
- // Maximum box size (in pixels). Required!
- optional float max_size = 2;
- // Various of aspect ratios. Duplicate ratios will be ignored.
- // If none is provided, we use default ratio 1.
- repeated float aspect_ratio = 3;
- // If true, will flip each aspect ratio.
- // For example, if there is aspect ratio "r",
- // we will generate aspect ratio "1.0/r" as well.
- optional bool flip = 4 [default = true];
- // If true, will clip the prior so that it is within [0, 1]
- optional bool clip = 5 [default = true];
- // Variance for adjusting the prior bboxes.
- repeated float variance = 6;
-}
-
-// Message that store parameters used by DetectionOutputLayer
-message DetectionOutputParameter {
- // Number of classes to be predicted. Required!
- optional uint32 num_classes = 1;
- // If true, bounding box are shared among different classes.
- optional bool share_location = 2 [default = true];
- // Background label id. If there is no background class,
- // set it as -1.
- optional int32 background_label_id = 3 [default = 0];
- // Type of coding method for bbox.
- optional PriorBoxParameter.CodeType code_type = 6 [default = CORNER];
- // If true, variance is encoded in target; otherwise we need to adjust the
- // predicted offset accordingly.
- optional bool variance_encoded_in_target = 8 [default = false];
- // Number of total bboxes to be kept per image after nms step.
- // -1 means keeping all bboxes after nms step.
- optional int32 keep_top_k = 7 [default = -1];
- // Only consider detections whose confidences are larger than a threshold.
- // If not provided, consider all boxes.
- optional float confidence_threshold = 9;
- // Parameters used for non maximum suppression.
- // Threshold to be used in nms.
- optional float nms_threshold = 10 [default = 0.3];
- // Maximum number of results to be kept.
- optional int32 top_k = 11;
-}
-
-message Datum {
- optional int32 channels = 1;
- optional int32 height = 2;
- optional int32 width = 3;
- // the actual image data, in bytes
- optional bytes data = 4;
- optional int32 label = 5;
- // Optionally, the datum could also hold float data.
- repeated float float_data = 6;
- // If true data contains an encoded image that need to be decoded
- optional bool encoded = 7 [default = false];
-}
-
-message FillerParameter {
- // The filler type.
- optional string type = 1 [default = 'constant'];
- optional float value = 2 [default = 0]; // the value in constant filler
- optional float min = 3 [default = 0]; // the min value in uniform filler
- optional float max = 4 [default = 1]; // the max value in uniform filler
- optional float mean = 5 [default = 0]; // the mean value in Gaussian filler
- optional float std = 6 [default = 1]; // the std value in Gaussian filler
- // The expected number of non-zero output weights for a given input in
- // Gaussian filler -- the default -1 means don't perform sparsification.
- optional int32 sparse = 7 [default = -1];
- // Normalize the filler variance by fan_in, fan_out, or their average.
- // Applies to 'xavier' and 'msra' fillers.
- enum VarianceNorm {
- FAN_IN = 0;
- FAN_OUT = 1;
- AVERAGE = 2;
- }
- optional VarianceNorm variance_norm = 8 [default = FAN_IN];
-}
-
-message NetParameter {
- optional string name = 1; // consider giving the network a name
- // The input blobs to the network.
- repeated string input = 3;
- // The shape of the input blobs.
- repeated BlobShape input_shape = 8;
-
- // 4D input dimensions -- deprecated. Use "shape" instead.
- // If specified, for each input blob there should be four
- // values specifying the num, channels, height and width of the input blob.
- // Thus, there should be a total of (4 * #input) numbers.
- repeated int32 input_dim = 4;
-
- // Whether the network will force every layer to carry out backward operation.
- // If set False, then whether to carry out backward is determined
- // automatically according to the net structure and learning rates.
- optional bool force_backward = 5 [default = false];
- // The current "state" of the network, including the phase, level, and stage.
- // Some layers may be included/excluded depending on this state and the states
- // specified in the layers' include and exclude fields.
- optional NetState state = 6;
-
- // Print debugging information about results while running Net::Forward,
- // Net::Backward, and Net::Update.
- optional bool debug_info = 7 [default = false];
-
- // The layers that make up the net. Each of their configurations, including
- // connectivity and behavior, is specified as a LayerParameter.
- repeated LayerParameter layer = 100; // ID 100 so layers are printed last.
-
- // DEPRECATED: use 'layer' instead.
- repeated V1LayerParameter layers = 2;
-}
-
-// NOTE
-// Update the next available ID when you add a new SolverParameter field.
-//
-// SolverParameter next available ID: 37 (last added: iter_size)
-message SolverParameter {
- //////////////////////////////////////////////////////////////////////////////
- // Specifying the train and test networks
- //
- // Exactly one train net must be specified using one of the following fields:
- // train_net_param, train_net, net_param, net
- // One or more test nets may be specified using any of the following fields:
- // test_net_param, test_net, net_param, net
- // If more than one test net field is specified (e.g., both net and
- // test_net are specified), they will be evaluated in the field order given
- // above: (1) test_net_param, (2) test_net, (3) net_param/net.
- // A test_iter must be specified for each test_net.
- // A test_level and/or a test_stage may also be specified for each test_net.
- //////////////////////////////////////////////////////////////////////////////
-
- // Proto filename for the train net, possibly combined with one or more
- // test nets.
- optional string net = 24;
- // Inline train net param, possibly combined with one or more test nets.
- optional NetParameter net_param = 25;
-
- optional string train_net = 1; // Proto filename for the train net.
- repeated string test_net = 2; // Proto filenames for the test nets.
- optional NetParameter train_net_param = 21; // Inline train net params.
- repeated NetParameter test_net_param = 22; // Inline test net params.
-
- // The states for the train/test nets. Must be unspecified or
- // specified once per net.
- //
- // By default, all states will have solver = true;
- // train_state will have phase = TRAIN,
- // and all test_state's will have phase = TEST.
- // Other defaults are set according to the NetState defaults.
- optional NetState train_state = 26;
- repeated NetState test_state = 27;
-
- // The number of iterations for each test net.
- repeated int32 test_iter = 3;
-
- // The number of iterations between two testing phases.
- optional int32 test_interval = 4 [default = 0];
- optional bool test_compute_loss = 19 [default = false];
- // If true, run an initial test pass before the first iteration,
- // ensuring memory availability and printing the starting value of the loss.
- optional bool test_initialization = 32 [default = true];
- optional float base_lr = 5; // The base learning rate
- // the number of iterations between displaying info. If display = 0, no info
- // will be displayed.
- optional int32 display = 6;
- // Display the loss averaged over the last average_loss iterations
- optional int32 average_loss = 33 [default = 1];
- optional int32 max_iter = 7; // the maximum number of iterations
- // accumulate gradients over `iter_size` x `batch_size` instances
- optional int32 iter_size = 36 [default = 1];
- optional string lr_policy = 8; // The learning rate decay policy.
- optional float gamma = 9; // The parameter to compute the learning rate.
- optional float power = 10; // The parameter to compute the learning rate.
- optional float momentum = 11; // The momentum value.
- optional float weight_decay = 12; // The weight decay.
- // regularization types supported: L1 and L2
- // controlled by weight_decay
- optional string regularization_type = 29 [default = "L2"];
- // the stepsize for learning rate policy "step"
- optional int32 stepsize = 13;
- // the stepsize for learning rate policy "multistep"
- repeated int32 stepvalue = 34;
-
- // Set clip_gradients to >= 0 to clip parameter gradients to that L2 norm,
- // whenever their actual L2 norm is larger.
- optional float clip_gradients = 35 [default = -1];
-
- optional int32 snapshot = 14 [default = 0]; // The snapshot interval
- optional string snapshot_prefix = 15; // The prefix for the snapshot.
- // whether to snapshot diff in the results or not. Snapshotting diff will help
- // debugging but the final protocol buffer size will be much larger.
- optional bool snapshot_diff = 16 [default = false];
- // the mode solver will use: 0 for CPU and 1 for GPU. Use GPU in default.
- enum SolverMode {
- CPU = 0;
- GPU = 1;
- }
- optional SolverMode solver_mode = 17 [default = GPU];
- // the device_id will that be used in GPU mode. Use device_id = 0 in default.
- optional int32 device_id = 18 [default = 0];
- // If non-negative, the seed with which the Solver will initialize the Caffe
- // random number generator -- useful for reproducible results. Otherwise,
- // (and by default) initialize using a seed derived from the system clock.
- optional int64 random_seed = 20 [default = -1];
-
- // Solver type
- enum SolverType {
- SGD = 0;
- NESTEROV = 1;
- ADAGRAD = 2;
- }
- optional SolverType solver_type = 30 [default = SGD];
- // numerical stability for AdaGrad
- optional float delta = 31 [default = 1e-8];
-
- // If true, print information about the state of the net that may help with
- // debugging learning problems.
- optional bool debug_info = 23 [default = false];
-
- // If false, don't save a snapshot after training finishes.
- optional bool snapshot_after_train = 28 [default = true];
-}
-
-// A message that stores the solver snapshots
-message SolverState {
- optional int32 iter = 1; // The current iteration
- optional string learned_net = 2; // The file that stores the learned net.
- repeated BlobProto history = 3; // The history for sgd solvers
- optional int32 current_step = 4 [default = 0]; // The current step for learning rate
-}
-
-enum Phase {
- TRAIN = 0;
- TEST = 1;
-}
-
-message NetState {
- optional Phase phase = 1 [default = TEST];
- optional int32 level = 2 [default = 0];
- repeated string stage = 3;
-}
-
-message NetStateRule {
- // Set phase to require the NetState have a particular phase (TRAIN or TEST)
- // to meet this rule.
- optional Phase phase = 1;
-
- // Set the minimum and/or maximum levels in which the layer should be used.
- // Leave undefined to meet the rule regardless of level.
- optional int32 min_level = 2;
- optional int32 max_level = 3;
-
- // Customizable sets of stages to include or exclude.
- // The net must have ALL of the specified stages and NONE of the specified
- // "not_stage"s to meet the rule.
- // (Use multiple NetStateRules to specify conjunctions of stages.)
- repeated string stage = 4;
- repeated string not_stage = 5;
-}
-
-// Specifies training parameters (multipliers on global learning constants,
-// and the name and other settings used for weight sharing).
-message ParamSpec {
- // The names of the parameter blobs -- useful for sharing parameters among
- // layers, but never required otherwise. To share a parameter between two
- // layers, give it a (non-empty) name.
- optional string name = 1;
-
- // Whether to require shared weights to have the same shape, or just the same
- // count -- defaults to STRICT if unspecified.
- optional DimCheckMode share_mode = 2;
- enum DimCheckMode {
- // STRICT (default) requires that num, channels, height, width each match.
- STRICT = 0;
- // PERMISSIVE requires only the count (num*channels*height*width) to match.
- PERMISSIVE = 1;
- }
-
- // The multiplier on the global learning rate for this parameter.
- optional float lr_mult = 3 [default = 1.0];
-
- // The multiplier on the global weight decay for this parameter.
- optional float decay_mult = 4 [default = 1.0];
-}
-
-// NOTE
-// Update the next available ID when you add a new LayerParameter field.
-//
-// LayerParameter next available layer-specific ID: 142 (last added: detection_output_param)
-message LayerParameter {
- optional string name = 1; // the layer name
- optional string type = 2; // the layer type
- repeated string bottom = 3; // the name of each bottom blob
- repeated string top = 4; // the name of each top blob
-
- // The train / test phase for computation.
- optional Phase phase = 10;
-
- // The amount of weight to assign each top blob in the objective.
- // Each layer assigns a default value, usually of either 0 or 1,
- // to each top blob.
- repeated float loss_weight = 5;
-
- // Specifies training parameters (multipliers on global learning constants,
- // and the name and other settings used for weight sharing).
- repeated ParamSpec param = 6;
-
- // The blobs containing the numeric parameters of the layer.
- repeated BlobProto blobs = 7;
-
- // Specifies on which bottoms the backpropagation should be skipped.
- // The size must be either 0 or equal to the number of bottoms.
- repeated bool propagate_down = 11;
-
- // Rules controlling whether and when a layer is included in the network,
- // based on the current NetState. You may specify a non-zero number of rules
- // to include OR exclude, but not both. If no include or exclude rules are
- // specified, the layer is always included. If the current NetState meets
- // ANY (i.e., one or more) of the specified rules, the layer is
- // included/excluded.
- repeated NetStateRule include = 8;
- repeated NetStateRule exclude = 9;
-
- // Parameters for data pre-processing.
- optional TransformationParameter transform_param = 100;
-
- // Parameters shared by loss layers.
- optional LossParameter loss_param = 101;
-
- // Layer type-specific parameters.
- //
- // Note: certain layers may have more than one computational engine
- // for their implementation. These layers include an Engine type and
- // engine parameter for selecting the implementation.
- // The default for the engine is set by the ENGINE switch at compile-time.
- optional AccuracyParameter accuracy_param = 102;
- optional ArgMaxParameter argmax_param = 103;
- optional ConcatParameter concat_param = 104;
- optional ContrastiveLossParameter contrastive_loss_param = 105;
- optional ConvolutionParameter convolution_param = 106;
- optional CropParameter crop_param = 137;
- optional DataParameter data_param = 107;
- optional DetectionOutputParameter detection_output_param = 141;
- optional DropoutParameter dropout_param = 108;
- optional DummyDataParameter dummy_data_param = 109;
- optional EltwiseParameter eltwise_param = 110;
- optional ExpParameter exp_param = 111;
- optional FlattenParameter flatten_param = 135;
- optional HDF5DataParameter hdf5_data_param = 112;
- optional HDF5OutputParameter hdf5_output_param = 113;
- optional HingeLossParameter hinge_loss_param = 114;
- optional ImageDataParameter image_data_param = 115;
- optional InfogainLossParameter infogain_loss_param = 116;
- optional InnerProductParameter inner_product_param = 117;
- optional LogParameter log_param = 134;
- optional LRNParameter lrn_param = 118;
- optional MemoryDataParameter memory_data_param = 119;
- optional MVNParameter mvn_param = 120;
- optional NormalizeBBoxParameter normalize_bbox_param = 139;
- optional PermuteParameter permute_param = 138;
- optional PoolingParameter pooling_param = 121;
- optional PowerParameter power_param = 122;
- optional PReLUParameter prelu_param = 131;
- optional PriorBoxParameter prior_box_param = 140;
- optional PythonParameter python_param = 130;
- optional ReductionParameter reduction_param = 136;
- optional ReLUParameter relu_param = 123;
- optional ReshapeParameter reshape_param = 133;
- optional SigmoidParameter sigmoid_param = 124;
- optional SliceParameter slice_param = 126;
- optional SoftmaxParameter softmax_param = 125;
- optional SPPParameter spp_param = 132;
- optional TanHParameter tanh_param = 127;
- optional ThresholdParameter threshold_param = 128;
- optional WindowDataParameter window_data_param = 129;
-}
-
-// Message that stores parameters used to apply transformation
-// to the data layer's data
-message TransformationParameter {
- // For data pre-processing, we can do simple scaling and subtracting the
- // data mean, if provided. Note that the mean subtraction is always carried
- // out before scaling.
- optional float scale = 1 [default = 1];
- // Specify if we want to randomly mirror data.
- optional bool mirror = 2 [default = false];
- // Specify if we would like to randomly crop an image.
- optional uint32 crop_size = 3 [default = 0];
- // mean_file and mean_value cannot be specified at the same time
- optional string mean_file = 4;
- // if specified can be repeated once (would substract it from all the channels)
- // or can be repeated the same number of times as channels
- // (would subtract them from the corresponding channel)
- repeated float mean_value = 5;
- // Force the decoded image to have 3 color channels.
- optional bool force_color = 6 [default = false];
- // Force the decoded image to have 1 color channels.
- optional bool force_gray = 7 [default = false];
-}
-
-// Message that stores parameters shared by loss layers
-message LossParameter {
- // If specified, ignore instances with the given label.
- optional int32 ignore_label = 1;
- // If true, normalize each batch across all instances (including spatial
- // dimesions, but not ignored instances); else, divide by batch size only.
- optional bool normalize = 2 [default = true];
-}
-
-// Messages that store parameters used by individual layer types follow, in
-// alphabetical order.
-
-message AccuracyParameter {
- // When computing accuracy, count as correct by comparing the true label to
- // the top k scoring classes. By default, only compare to the top scoring
- // class (i.e. argmax).
- optional uint32 top_k = 1 [default = 1];
-
- // The "label" axis of the prediction blob, whose argmax corresponds to the
- // predicted label -- may be negative to index from the end (e.g., -1 for the
- // last axis). For example, if axis == 1 and the predictions are
- // (N x C x H x W), the label blob is expected to contain N*H*W ground truth
- // labels with integer values in {0, 1, ..., C-1}.
- optional int32 axis = 2 [default = 1];
-
- // If specified, ignore instances with the given label.
- optional int32 ignore_label = 3;
-}
-
-message ArgMaxParameter {
- // If true produce pairs (argmax, maxval)
- optional bool out_max_val = 1 [default = false];
- optional uint32 top_k = 2 [default = 1];
-}
-
-message ConcatParameter {
- // The axis along which to concatenate -- may be negative to index from the
- // end (e.g., -1 for the last axis). Other axes must have the
- // same dimension for all the bottom blobs.
- // By default, ConcatLayer concatenates blobs along the "channels" axis (1).
- optional int32 axis = 2 [default = 1];
-
- // DEPRECATED: alias for "axis" -- does not support negative indexing.
- optional uint32 concat_dim = 1 [default = 1];
-}
-
-message ContrastiveLossParameter {
- // margin for dissimilar pair
- optional float margin = 1 [default = 1.0];
- // The first implementation of this cost did not exactly match the cost of
- // Hadsell et al 2006 -- using (margin - d^2) instead of (margin - d)^2.
- // legacy_version = false (the default) uses (margin - d)^2 as proposed in the
- // Hadsell paper. New models should probably use this version.
- // legacy_version = true uses (margin - d^2). This is kept to support /
- // reproduce existing models and results
- optional bool legacy_version = 2 [default = false];
-}
-
-message ConvolutionParameter {
- optional uint32 num_output = 1; // The number of outputs for the layer
- optional bool bias_term = 2 [default = true]; // whether to have bias terms
- // Pad, kernel size, and stride are all given as a single value for equal
- // dimensions in height and width or as Y, X pairs.
- optional uint32 pad = 3 [default = 0]; // The padding size (equal in Y, X)
- optional uint32 pad_h = 9 [default = 0]; // The padding height
- optional uint32 pad_w = 10 [default = 0]; // The padding width
- optional uint32 kernel_size = 4; // The kernel size (square)
- optional uint32 kernel_h = 11; // The kernel height
- optional uint32 kernel_w = 12; // The kernel width
- optional uint32 group = 5 [default = 1]; // The group size for group conv
- optional uint32 stride = 6 [default = 1]; // The stride (equal in Y, X)
- optional uint32 stride_h = 13; // The stride height
- optional uint32 stride_w = 14; // The stride width
- optional FillerParameter weight_filler = 7; // The filler for the weight
- optional FillerParameter bias_filler = 8; // The filler for the bias
- enum Engine {
- DEFAULT = 0;
- CAFFE = 1;
- CUDNN = 2;
- }
- optional Engine engine = 15 [default = DEFAULT];
- // Factor used to dilate the kernel, (implicitly) zero-filling the resulting
- // holes. (Kernel dilation is sometimes referred to by its use in the
- // algorithme a trous from Holschneider et al. 1987.)
- optional uint32 dilation_h = 18; // The dilation height
- optional uint32 dilation_w = 19; // The dilation width
- optional uint32 dilation = 20; // The dilation; defaults to 1
-}
-
-message DataParameter {
- enum DB {
- LEVELDB = 0;
- LMDB = 1;
- }
- // Specify the data source.
- optional string source = 1;
- // Specify the batch size.
- optional uint32 batch_size = 4;
- // The rand_skip variable is for the data layer to skip a few data points
- // to avoid all asynchronous sgd clients to start at the same point. The skip
- // point would be set as rand_skip * rand(0,1). Note that rand_skip should not
- // be larger than the number of keys in the database.
- optional uint32 rand_skip = 7 [default = 0];
- optional DB backend = 8 [default = LEVELDB];
- // DEPRECATED. See TransformationParameter. For data pre-processing, we can do
- // simple scaling and subtracting the data mean, if provided. Note that the
- // mean subtraction is always carried out before scaling.
- optional float scale = 2 [default = 1];
- optional string mean_file = 3;
- // DEPRECATED. See TransformationParameter. Specify if we would like to randomly
- // crop an image.
- optional uint32 crop_size = 5 [default = 0];
- // DEPRECATED. See TransformationParameter. Specify if we want to randomly mirror
- // data.
- optional bool mirror = 6 [default = false];
- // Force the encoded image to have 3 color channels
- optional bool force_encoded_color = 9 [default = false];
-}
-
-message DropoutParameter {
- optional float dropout_ratio = 1 [default = 0.5]; // dropout ratio
-}
-
-// DummyDataLayer fills any number of arbitrarily shaped blobs with random
-// (or constant) data generated by "Fillers" (see "message FillerParameter").
-message DummyDataParameter {
- // This layer produces N >= 1 top blobs. DummyDataParameter must specify 1 or N
- // shape fields, and 0, 1 or N data_fillers.
- //
- // If 0 data_fillers are specified, ConstantFiller with a value of 0 is used.
- // If 1 data_filler is specified, it is applied to all top blobs. If N are
- // specified, the ith is applied to the ith top blob.
- repeated FillerParameter data_filler = 1;
- repeated BlobShape shape = 6;
-
- // 4D dimensions -- deprecated. Use "shape" instead.
- repeated uint32 num = 2;
- repeated uint32 channels = 3;
- repeated uint32 height = 4;
- repeated uint32 width = 5;
-}
-
-message EltwiseParameter {
- enum EltwiseOp {
- PROD = 0;
- SUM = 1;
- MAX = 2;
- }
- optional EltwiseOp operation = 1 [default = SUM]; // element-wise operation
- repeated float coeff = 2; // blob-wise coefficient for SUM operation
-
- // Whether to use an asymptotically slower (for >2 inputs) but stabler method
- // of computing the gradient for the PROD operation. (No effect for SUM op.)
- optional bool stable_prod_grad = 3 [default = true];
-}
-
-message ExpParameter {
- // ExpLayer computes outputs y = base ^ (shift + scale * x), for base > 0.
- // Or if base is set to the default (-1), base is set to e,
- // so y = exp(shift + scale * x).
- optional float base = 1 [default = -1.0];
- optional float scale = 2 [default = 1.0];
- optional float shift = 3 [default = 0.0];
-}
-
-/// Message that stores parameters used by FlattenLayer
-message FlattenParameter {
- // The first axis to flatten: all preceding axes are retained in the output.
- // May be negative to index from the end (e.g., -1 for the last axis).
- optional int32 axis = 1 [default = 1];
-
- // The last axis to flatten: all following axes are retained in the output.
- // May be negative to index from the end (e.g., the default -1 for the last
- // axis).
- optional int32 end_axis = 2 [default = -1];
-}
-
-// Message that stores parameters used by HDF5DataLayer
-message HDF5DataParameter {
- // Specify the data source.
- optional string source = 1;
- // Specify the batch size.
- optional uint32 batch_size = 2;
-
- // Specify whether to shuffle the data.
- // If shuffle == true, the ordering of the HDF5 files is shuffled,
- // and the ordering of data within any given HDF5 file is shuffled,
- // but data between different files are not interleaved; all of a file's
- // data are output (in a random order) before moving onto another file.
- optional bool shuffle = 3 [default = false];
-}
-
-message HDF5OutputParameter {
- optional string file_name = 1;
-}
-
-message HingeLossParameter {
- enum Norm {
- L1 = 1;
- L2 = 2;
- }
- // Specify the Norm to use L1 or L2
- optional Norm norm = 1 [default = L1];
-}
-
-message ImageDataParameter {
- // Specify the data source.
- optional string source = 1;
- // Specify the batch size.
- optional uint32 batch_size = 4;
- // The rand_skip variable is for the data layer to skip a few data points
- // to avoid all asynchronous sgd clients to start at the same point. The skip
- // point would be set as rand_skip * rand(0,1). Note that rand_skip should not
- // be larger than the number of keys in the database.
- optional uint32 rand_skip = 7 [default = 0];
- // Whether or not ImageLayer should shuffle the list of files at every epoch.
- optional bool shuffle = 8 [default = false];
- // It will also resize images if new_height or new_width are not zero.
- optional uint32 new_height = 9 [default = 0];
- optional uint32 new_width = 10 [default = 0];
- // Specify if the images are color or gray
- optional bool is_color = 11 [default = true];
- // DEPRECATED. See TransformationParameter. For data pre-processing, we can do
- // simple scaling and subtracting the data mean, if provided. Note that the
- // mean subtraction is always carried out before scaling.
- optional float scale = 2 [default = 1];
- optional string mean_file = 3;
- // DEPRECATED. See TransformationParameter. Specify if we would like to randomly
- // crop an image.
- optional uint32 crop_size = 5 [default = 0];
- // DEPRECATED. See TransformationParameter. Specify if we want to randomly mirror
- // data.
- optional bool mirror = 6 [default = false];
- optional string root_folder = 12 [default = ""];
-}
-
-message InfogainLossParameter {
- // Specify the infogain matrix source.
- optional string source = 1;
-}
-
-message InnerProductParameter {
- optional uint32 num_output = 1; // The number of outputs for the layer
- optional bool bias_term = 2 [default = true]; // whether to have bias terms
- optional FillerParameter weight_filler = 3; // The filler for the weight
- optional FillerParameter bias_filler = 4; // The filler for the bias
-
- // The first axis to be lumped into a single inner product computation;
- // all preceding axes are retained in the output.
- // May be negative to index from the end (e.g., -1 for the last axis).
- optional int32 axis = 5 [default = 1];
-}
-
-// Message that stores parameters used by LogLayer
-message LogParameter {
- // LogLayer computes outputs y = log_base(shift + scale * x), for base > 0.
- // Or if base is set to the default (-1), base is set to e,
- // so y = ln(shift + scale * x) = log_e(shift + scale * x)
- optional float base = 1 [default = -1.0];
- optional float scale = 2 [default = 1.0];
- optional float shift = 3 [default = 0.0];
-}
-
-// Message that stores parameters used by LRNLayer
-message LRNParameter {
- optional uint32 local_size = 1 [default = 5];
- optional float alpha = 2 [default = 1.];
- optional float beta = 3 [default = 0.75];
- enum NormRegion {
- ACROSS_CHANNELS = 0;
- WITHIN_CHANNEL = 1;
- }
- optional NormRegion norm_region = 4 [default = ACROSS_CHANNELS];
- optional float k = 5 [default = 1.];
-}
-
-message MemoryDataParameter {
- optional uint32 batch_size = 1;
- optional uint32 channels = 2;
- optional uint32 height = 3;
- optional uint32 width = 4;
-}
-
-message MVNParameter {
- // This parameter can be set to false to normalize mean only
- optional bool normalize_variance = 1 [default = true];
-
- // This parameter can be set to true to perform DNN-like MVN
- optional bool across_channels = 2 [default = false];
-
- // Epsilon for not dividing by zero while normalizing variance
- optional float eps = 3 [default = 1e-9];
-}
-
-message PoolingParameter {
- enum PoolMethod {
- MAX = 0;
- AVE = 1;
- STOCHASTIC = 2;
- }
- optional PoolMethod pool = 1 [default = MAX]; // The pooling method
- // Pad, kernel size, and stride are all given as a single value for equal
- // dimensions in height and width or as Y, X pairs.
- optional uint32 pad = 4 [default = 0]; // The padding size (equal in Y, X)
- optional uint32 pad_h = 9 [default = 0]; // The padding height
- optional uint32 pad_w = 10 [default = 0]; // The padding width
- optional uint32 kernel_size = 2; // The kernel size (square)
- optional uint32 kernel_h = 5; // The kernel height
- optional uint32 kernel_w = 6; // The kernel width
- optional uint32 stride = 3 [default = 1]; // The stride (equal in Y, X)
- optional uint32 stride_h = 7; // The stride height
- optional uint32 stride_w = 8; // The stride width
- enum Engine {
- DEFAULT = 0;
- CAFFE = 1;
- CUDNN = 2;
- }
- optional Engine engine = 11 [default = DEFAULT];
- // If global_pooling then it will pool over the size of the bottom by doing
- // kernel_h = bottom->height and kernel_w = bottom->width
- optional bool global_pooling = 12 [default = false];
-}
-
-message PowerParameter {
- // PowerLayer computes outputs y = (shift + scale * x) ^ power.
- optional float power = 1 [default = 1.0];
- optional float scale = 2 [default = 1.0];
- optional float shift = 3 [default = 0.0];
-}
-
-message PythonParameter {
- optional string module = 1;
- optional string layer = 2;
-}
-
-// Message that stores parameters used by ReductionLayer
-message ReductionParameter {
- enum ReductionOp {
- SUM = 1;
- ASUM = 2;
- SUMSQ = 3;
- MEAN = 4;
- }
-
- optional ReductionOp operation = 1 [default = SUM]; // reduction operation
-
- // The first axis to reduce to a scalar -- may be negative to index from the
- // end (e.g., -1 for the last axis).
- // (Currently, only reduction along ALL "tail" axes is supported; reduction
- // of axis M through N, where N < num_axes - 1, is unsupported.)
- // Suppose we have an n-axis bottom Blob with shape:
- // (d0, d1, d2, ..., d(m-1), dm, d(m+1), ..., d(n-1)).
- // If axis == m, the output Blob will have shape
- // (d0, d1, d2, ..., d(m-1)),
- // and the ReductionOp operation is performed (d0 * d1 * d2 * ... * d(m-1))
- // times, each including (dm * d(m+1) * ... * d(n-1)) individual data.
- // If axis == 0 (the default), the output Blob always has the empty shape
- // (count 1), performing reduction across the entire input --
- // often useful for creating new loss functions.
- optional int32 axis = 2 [default = 0];
-
- optional float coeff = 3 [default = 1.0]; // coefficient for output
-}
-
-// Message that stores parameters used by ReLULayer
-message ReLUParameter {
- // Allow non-zero slope for negative inputs to speed up optimization
- // Described in:
- // Maas, A. L., Hannun, A. Y., & Ng, A. Y. (2013). Rectifier nonlinearities
- // improve neural network acoustic models. In ICML Workshop on Deep Learning
- // for Audio, Speech, and Language Processing.
- optional float negative_slope = 1 [default = 0];
- enum Engine {
- DEFAULT = 0;
- CAFFE = 1;
- CUDNN = 2;
- }
- optional Engine engine = 2 [default = DEFAULT];
-}
-
-message ReshapeParameter {
- // Specify the output dimensions. If some of the dimensions are set to 0,
- // the corresponding dimension from the bottom layer is used (unchanged).
- // Exactly one dimension may be set to -1, in which case its value is
- // inferred from the count of the bottom blob and the remaining dimensions.
- // For example, suppose we want to reshape a 2D blob "input" with shape 2 x 8:
- //
- // layer {
- // type: "Reshape" bottom: "input" top: "output"
- // reshape_param { ... }
- // }
- //
- // If "input" is 2D with shape 2 x 8, then the following reshape_param
- // specifications are all equivalent, producing a 3D blob "output" with shape
- // 2 x 2 x 4:
- //
- // reshape_param { shape { dim: 2 dim: 2 dim: 4 } }
- // reshape_param { shape { dim: 0 dim: 2 dim: 4 } }
- // reshape_param { shape { dim: 0 dim: 2 dim: -1 } }
- // reshape_param { shape { dim: -1 dim: 0 dim: 2 } }
- //
- optional BlobShape shape = 1;
-
- // axis and num_axes control the portion of the bottom blob's shape that are
- // replaced by (included in) the reshape. By default (axis == 0 and
- // num_axes == -1), the entire bottom blob shape is included in the reshape,
- // and hence the shape field must specify the entire output shape.
- //
- // axis may be non-zero to retain some portion of the beginning of the input
- // shape (and may be negative to index from the end; e.g., -1 to begin the
- // reshape after the last axis, including nothing in the reshape,
- // -2 to include only the last axis, etc.).
- //
- // For example, suppose "input" is a 2D blob with shape 2 x 8.
- // Then the following ReshapeLayer specifications are all equivalent,
- // producing a blob "output" with shape 2 x 2 x 4:
- //
- // reshape_param { shape { dim: 2 dim: 2 dim: 4 } }
- // reshape_param { shape { dim: 2 dim: 4 } axis: 1 }
- // reshape_param { shape { dim: 2 dim: 4 } axis: -3 }
- //
- // num_axes specifies the extent of the reshape.
- // If num_axes >= 0 (and axis >= 0), the reshape will be performed only on
- // input axes in the range [axis, axis+num_axes].
- // num_axes may also be -1, the default, to include all remaining axes
- // (starting from axis).
- //
- // For example, suppose "input" is a 2D blob with shape 2 x 8.
- // Then the following ReshapeLayer specifications are equivalent,
- // producing a blob "output" with shape 1 x 2 x 8.
- //
- // reshape_param { shape { dim: 1 dim: 2 dim: 8 } }
- // reshape_param { shape { dim: 1 dim: 2 } num_axes: 1 }
- // reshape_param { shape { dim: 1 } num_axes: 0 }
- //
- // On the other hand, these would produce output blob shape 2 x 1 x 8:
- //
- // reshape_param { shape { dim: 2 dim: 1 dim: 8 } }
- // reshape_param { shape { dim: 1 } axis: 1 num_axes: 0 }
- //
- optional int32 axis = 2 [default = 0];
- optional int32 num_axes = 3 [default = -1];
-}
-
-message SigmoidParameter {
- enum Engine {
- DEFAULT = 0;
- CAFFE = 1;
- CUDNN = 2;
- }
- optional Engine engine = 1 [default = DEFAULT];
-}
-
-message SliceParameter {
- // The axis along which to slice -- may be negative to index from the end
- // (e.g., -1 for the last axis).
- // By default, SliceLayer concatenates blobs along the "channels" axis (1).
- optional int32 axis = 3 [default = 1];
- repeated uint32 slice_point = 2;
-
- // DEPRECATED: alias for "axis" -- does not support negative indexing.
- optional uint32 slice_dim = 1 [default = 1];
-}
-
-// Message that stores parameters used by SoftmaxLayer, SoftmaxWithLossLayer
-message SoftmaxParameter {
- enum Engine {
- DEFAULT = 0;
- CAFFE = 1;
- CUDNN = 2;
- }
- optional Engine engine = 1 [default = DEFAULT];
-
- // The axis along which to perform the softmax -- may be negative to index
- // from the end (e.g., -1 for the last axis).
- // Any other axes will be evaluated as independent softmaxes.
- optional int32 axis = 2 [default = 1];
-}
-
-message TanHParameter {
- enum Engine {
- DEFAULT = 0;
- CAFFE = 1;
- CUDNN = 2;
- }
- optional Engine engine = 1 [default = DEFAULT];
-}
-
-message ThresholdParameter {
- optional float threshold = 1 [default = 0]; // Strictly positive values
-}
-
-message WindowDataParameter {
- // Specify the data source.
- optional string source = 1;
- // For data pre-processing, we can do simple scaling and subtracting the
- // data mean, if provided. Note that the mean subtraction is always carried
- // out before scaling.
- optional float scale = 2 [default = 1];
- optional string mean_file = 3;
- // Specify the batch size.
- optional uint32 batch_size = 4;
- // Specify if we would like to randomly crop an image.
- optional uint32 crop_size = 5 [default = 0];
- // Specify if we want to randomly mirror data.
- optional bool mirror = 6 [default = false];
- // Foreground (object) overlap threshold
- optional float fg_threshold = 7 [default = 0.5];
- // Background (non-object) overlap threshold
- optional float bg_threshold = 8 [default = 0.5];
- // Fraction of batch that should be foreground objects
- optional float fg_fraction = 9 [default = 0.25];
- // Amount of contextual padding to add around a window
- // (used only by the window_data_layer)
- optional uint32 context_pad = 10 [default = 0];
- // Mode for cropping out a detection window
- // warp: cropped window is warped to a fixed size and aspect ratio
- // square: the tightest square around the window is cropped
- optional string crop_mode = 11 [default = "warp"];
- // cache_images: will load all images in memory for faster access
- optional bool cache_images = 12 [default = false];
- // append root_folder to locate images
- optional string root_folder = 13 [default = ""];
-}
-
-message SPPParameter {
- enum PoolMethod {
- MAX = 0;
- AVE = 1;
- STOCHASTIC = 2;
- }
- optional uint32 pyramid_height = 1;
- optional PoolMethod pool = 2 [default = MAX]; // The pooling method
- enum Engine {
- DEFAULT = 0;
- CAFFE = 1;
- CUDNN = 2;
- }
- optional Engine engine = 6 [default = DEFAULT];
-}
-
-// DEPRECATED: use LayerParameter.
-message V1LayerParameter {
- repeated string bottom = 2;
- repeated string top = 3;
- optional string name = 4;
- repeated NetStateRule include = 32;
- repeated NetStateRule exclude = 33;
- enum LayerType {
- NONE = 0;
- ABSVAL = 35;
- ACCURACY = 1;
- ARGMAX = 30;
- BNLL = 2;
- CONCAT = 3;
- CONTRASTIVE_LOSS = 37;
- CONVOLUTION = 4;
- DATA = 5;
- DECONVOLUTION = 39;
- DROPOUT = 6;
- DUMMY_DATA = 32;
- EUCLIDEAN_LOSS = 7;
- ELTWISE = 25;
- EXP = 38;
- FLATTEN = 8;
- HDF5_DATA = 9;
- HDF5_OUTPUT = 10;
- HINGE_LOSS = 28;
- IM2COL = 11;
- IMAGE_DATA = 12;
- INFOGAIN_LOSS = 13;
- INNER_PRODUCT = 14;
- LRN = 15;
- MEMORY_DATA = 29;
- MULTINOMIAL_LOGISTIC_LOSS = 16;
- MVN = 34;
- POOLING = 17;
- POWER = 26;
- RELU = 18;
- SIGMOID = 19;
- SIGMOID_CROSS_ENTROPY_LOSS = 27;
- SILENCE = 36;
- SOFTMAX = 20;
- SOFTMAX_LOSS = 21;
- SPLIT = 22;
- SLICE = 33;
- TANH = 23;
- WINDOW_DATA = 24;
- THRESHOLD = 31;
- }
- optional LayerType type = 5;
- repeated BlobProto blobs = 6;
- repeated string param = 1001;
- repeated DimCheckMode blob_share_mode = 1002;
- enum DimCheckMode {
- STRICT = 0;
- PERMISSIVE = 1;
- }
- repeated float blobs_lr = 7;
- repeated float weight_decay = 8;
- repeated float loss_weight = 35;
- optional AccuracyParameter accuracy_param = 27;
- optional ArgMaxParameter argmax_param = 23;
- optional ConcatParameter concat_param = 9;
- optional ContrastiveLossParameter contrastive_loss_param = 40;
- optional ConvolutionParameter convolution_param = 10;
- optional DataParameter data_param = 11;
- optional DropoutParameter dropout_param = 12;
- optional DummyDataParameter dummy_data_param = 26;
- optional EltwiseParameter eltwise_param = 24;
- optional ExpParameter exp_param = 41;
- optional HDF5DataParameter hdf5_data_param = 13;
- optional HDF5OutputParameter hdf5_output_param = 14;
- optional HingeLossParameter hinge_loss_param = 29;
- optional ImageDataParameter image_data_param = 15;
- optional InfogainLossParameter infogain_loss_param = 16;
- optional InnerProductParameter inner_product_param = 17;
- optional LRNParameter lrn_param = 18;
- optional MemoryDataParameter memory_data_param = 22;
- optional MVNParameter mvn_param = 34;
- optional PoolingParameter pooling_param = 19;
- optional PowerParameter power_param = 21;
- optional ReLUParameter relu_param = 30;
- optional SigmoidParameter sigmoid_param = 38;
- optional SoftmaxParameter softmax_param = 39;
- optional SliceParameter slice_param = 31;
- optional TanHParameter tanh_param = 37;
- optional ThresholdParameter threshold_param = 25;
- optional WindowDataParameter window_data_param = 20;
- optional TransformationParameter transform_param = 36;
- optional LossParameter loss_param = 42;
- optional V0LayerParameter layer = 1;
-}
-
-// DEPRECATED: V0LayerParameter is the old way of specifying layer parameters
-// in Caffe. We keep this message type around for legacy support.
-message V0LayerParameter {
- optional string name = 1; // the layer name
- optional string type = 2; // the string to specify the layer type
-
- // Parameters to specify layers with inner products.
- optional uint32 num_output = 3; // The number of outputs for the layer
- optional bool biasterm = 4 [default = true]; // whether to have bias terms
- optional FillerParameter weight_filler = 5; // The filler for the weight
- optional FillerParameter bias_filler = 6; // The filler for the bias
-
- optional uint32 pad = 7 [default = 0]; // The padding size
- optional uint32 kernelsize = 8; // The kernel size
- optional uint32 group = 9 [default = 1]; // The group size for group conv
- optional uint32 stride = 10 [default = 1]; // The stride
- enum PoolMethod {
- MAX = 0;
- AVE = 1;
- STOCHASTIC = 2;
- }
- optional PoolMethod pool = 11 [default = MAX]; // The pooling method
- optional float dropout_ratio = 12 [default = 0.5]; // dropout ratio
-
- optional uint32 local_size = 13 [default = 5]; // for local response norm
- optional float alpha = 14 [default = 1.]; // for local response norm
- optional float beta = 15 [default = 0.75]; // for local response norm
- optional float k = 22 [default = 1.];
-
- // For data layers, specify the data source
- optional string source = 16;
- // For data pre-processing, we can do simple scaling and subtracting the
- // data mean, if provided. Note that the mean subtraction is always carried
- // out before scaling.
- optional float scale = 17 [default = 1];
- optional string meanfile = 18;
- // For data layers, specify the batch size.
- optional uint32 batchsize = 19;
- // For data layers, specify if we would like to randomly crop an image.
- optional uint32 cropsize = 20 [default = 0];
- // For data layers, specify if we want to randomly mirror data.
- optional bool mirror = 21 [default = false];
-
- // The blobs containing the numeric parameters of the layer
- repeated BlobProto blobs = 50;
- // The ratio that is multiplied on the global learning rate. If you want to
- // set the learning ratio for one blob, you need to set it for all blobs.
- repeated float blobs_lr = 51;
- // The weight decay that is multiplied on the global weight decay.
- repeated float weight_decay = 52;
-
- // The rand_skip variable is for the data layer to skip a few data points
- // to avoid all asynchronous sgd clients to start at the same point. The skip
- // point would be set as rand_skip * rand(0,1). Note that rand_skip should not
- // be larger than the number of keys in the database.
- optional uint32 rand_skip = 53 [default = 0];
-
- // Fields related to detection (det_*)
- // foreground (object) overlap threshold
- optional float det_fg_threshold = 54 [default = 0.5];
- // background (non-object) overlap threshold
- optional float det_bg_threshold = 55 [default = 0.5];
- // Fraction of batch that should be foreground objects
- optional float det_fg_fraction = 56 [default = 0.25];
-
- // optional bool OBSOLETE_can_clobber = 57 [default = true];
-
- // Amount of contextual padding to add around a window
- // (used only by the window_data_layer)
- optional uint32 det_context_pad = 58 [default = 0];
-
- // Mode for cropping out a detection window
- // warp: cropped window is warped to a fixed size and aspect ratio
- // square: the tightest square around the window is cropped
- optional string det_crop_mode = 59 [default = "warp"];
-
- // For ReshapeLayer, one needs to specify the new dimensions.
- optional int32 new_num = 60 [default = 0];
- optional int32 new_channels = 61 [default = 0];
- optional int32 new_height = 62 [default = 0];
- optional int32 new_width = 63 [default = 0];
-
- // Whether or not ImageLayer should shuffle the list of files at every epoch.
- // It will also resize images if new_height or new_width are not zero.
- optional bool shuffle_images = 64 [default = false];
-
- // For ConcatLayer, one needs to specify the dimension for concatenation, and
- // the other dimensions must be the same for all the bottom blobs.
- // By default it will concatenate blobs along the channels dimension.
- optional uint32 concat_dim = 65 [default = 1];
-
- optional HDF5OutputParameter hdf5_output_param = 1001;
-}
-
-message PReLUParameter {
- // Parametric ReLU described in K. He et al, Delving Deep into Rectifiers:
- // Surpassing Human-Level Performance on ImageNet Classification, 2015.
-
- // Initial value of a_i. Default is a_i=0.25 for all i.
- optional FillerParameter filler = 1;
- // Whether or not slope paramters are shared across channels.
- optional bool channel_shared = 2 [default = false];
-}
-
-// The normalized bounding box [0, 1] w.r.t. the input image size.
-message NormalizedBBox {
- optional float xmin = 1;
- optional float ymin = 2;
- optional float xmax = 3;
- optional float ymax = 4;
- optional int32 label = 5;
- optional bool difficult = 6;
- optional float score = 7;
- optional float size = 8;
-}
diff --git a/contrib/modules/dnn/src/caffe/caffe_importer.cpp b/contrib/modules/dnn/src/caffe/caffe_importer.cpp
deleted file mode 100644
index 5f66393..0000000
--- a/contrib/modules/dnn/src/caffe/caffe_importer.cpp
+++ /dev/null
@@ -1,391 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-using namespace cv;
-using namespace cv::dnn;
-
-#if HAVE_PROTOBUF
-#include "caffe.pb.h"
-
-#include <iostream>
-#include <fstream>
-#include <sstream>
-#include <algorithm>
-#include <google/protobuf/message.h>
-#include <google/protobuf/text_format.h>
-#include <google/protobuf/io/zero_copy_stream_impl.h>
-#include "caffe_io.hpp"
-
-using ::google::protobuf::RepeatedField;
-using ::google::protobuf::RepeatedPtrField;
-using ::google::protobuf::Message;
-using ::google::protobuf::Descriptor;
-using ::google::protobuf::FieldDescriptor;
-using ::google::protobuf::Reflection;
-
-namespace
-{
-
-template<typename T>
-static cv::String toString(const T &v)
-{
- std::ostringstream ss;
- ss << v;
- return ss.str();
-}
-
-class CaffeImporter : public Importer
-{
- caffe::NetParameter net;
- caffe::NetParameter netBinary;
-
-public:
-
- CaffeImporter(const char *pototxt, const char *caffeModel)
- {
- ReadNetParamsFromTextFileOrDie(pototxt, &net);
-
- if (caffeModel && caffeModel[0])
- ReadNetParamsFromBinaryFileOrDie(caffeModel, &netBinary);
- }
-
- void addParam(const Message &msg, const FieldDescriptor *field, cv::dnn::LayerParams ¶ms)
- {
- const Reflection *refl = msg.GetReflection();
- int type = field->cpp_type();
- bool isRepeated = field->is_repeated();
- const std::string &name = field->name();
-
- #define SET_UP_FILED(getter, arrayConstr, gtype) \
- if (isRepeated) { \
- const RepeatedField<gtype> &v = refl->GetRepeatedField<gtype>(msg, field); \
- params.set(name, DictValue::arrayConstr(v.begin(), (int)v.size())); \
- } \
- else { \
- params.set(name, refl->getter(msg, field)); \
- }
-
- switch (type)
- {
- case FieldDescriptor::CPPTYPE_INT32:
- SET_UP_FILED(GetInt32, arrayInt, ::google::protobuf::int32);
- break;
- case FieldDescriptor::CPPTYPE_UINT32:
- SET_UP_FILED(GetUInt32, arrayInt, ::google::protobuf::uint32);
- break;
- case FieldDescriptor::CPPTYPE_INT64:
- SET_UP_FILED(GetInt32, arrayInt, ::google::protobuf::int64);
- break;
- case FieldDescriptor::CPPTYPE_UINT64:
- SET_UP_FILED(GetUInt32, arrayInt, ::google::protobuf::uint64);
- break;
- case FieldDescriptor::CPPTYPE_BOOL:
- SET_UP_FILED(GetBool, arrayInt, bool);
- break;
- case FieldDescriptor::CPPTYPE_DOUBLE:
- SET_UP_FILED(GetDouble, arrayReal, double);
- break;
- case FieldDescriptor::CPPTYPE_FLOAT:
- SET_UP_FILED(GetFloat, arrayReal, float);
- break;
- case FieldDescriptor::CPPTYPE_STRING:
- if (isRepeated) {
- const RepeatedPtrField<std::string> &v = refl->GetRepeatedPtrField<std::string>(msg, field);
- params.set(name, DictValue::arrayString(v.begin(), (int)v.size()));
- }
- else {
- params.set(name, refl->GetString(msg, field));
- }
- break;
- case FieldDescriptor::CPPTYPE_ENUM:
- if (isRepeated) {
- int size = refl->FieldSize(msg, field);
- std::vector<cv::String> buf(size);
- for (int i = 0; i < size; i++)
- buf[i] = refl->GetRepeatedEnum(msg, field, i)->name();
- params.set(name, DictValue::arrayString(buf.begin(), size));
- }
- else {
- params.set(name, refl->GetEnum(msg, field)->name());
- }
- break;
- default:
- CV_Error(Error::StsError, "Unknown type \"" + String(field->type_name()) + "\" in prototxt");
- break;
- }
- }
-
- inline static bool ends_with_param(const std::string &str)
- {
- static const std::string _param("_param");
- return (str.size() >= _param.size()) && str.compare(str.size() - _param.size(), _param.size(), _param) == 0;
- }
-
- void extractLayerParams(const Message &msg, cv::dnn::LayerParams ¶ms, bool isInternal = false)
- {
- const Descriptor *msgDesc = msg.GetDescriptor();
- const Reflection *msgRefl = msg.GetReflection();
-
- for (int fieldId = 0; fieldId < msgDesc->field_count(); fieldId++)
- {
- const FieldDescriptor *fd = msgDesc->field(fieldId);
-
- if (!isInternal && !ends_with_param(fd->name()))
- continue;
-
- bool hasData = fd->is_required() ||
- (fd->is_optional() && msgRefl->HasField(msg, fd)) ||
- (fd->is_repeated() && msgRefl->FieldSize(msg, fd) > 0);
- if (!hasData)
- continue;
-
- if (fd->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE)
- {
- if (fd->is_repeated()) //Extract only first item!
- extractLayerParams(msgRefl->GetRepeatedMessage(msg, fd, 0), params, true);
- else
- extractLayerParams(msgRefl->GetMessage(msg, fd), params, true);
- }
- else
- {
- addParam(msg, fd, params);
- }
- }
- }
-
- BlobShape blobShapeFromProto(const caffe::BlobProto &pbBlob)
- {
- if (pbBlob.has_num() || pbBlob.has_channels() || pbBlob.has_height() || pbBlob.has_width())
- {
- return BlobShape(pbBlob.num(), pbBlob.channels(), pbBlob.height(), pbBlob.width());
- }
- else if (pbBlob.has_shape())
- {
- const caffe::BlobShape &_shape = pbBlob.shape();
- BlobShape shape = BlobShape::all(_shape.dim_size());
-
- for (int i = 0; i < _shape.dim_size(); i++)
- shape[i] = (int)_shape.dim(i);
-
- return shape;
- }
- else
- {
- CV_Error(Error::StsError, "Unknown shape of input blob");
- return BlobShape();
- }
- }
-
- void blobFromProto(const caffe::BlobProto &pbBlob, cv::dnn::Blob &dstBlob)
- {
- BlobShape shape = blobShapeFromProto(pbBlob);
-
- dstBlob.create(shape, CV_32F);
- CV_Assert(pbBlob.data_size() == (int)dstBlob.matRefConst().total());
-
- CV_DbgAssert(pbBlob.GetDescriptor()->FindFieldByLowercaseName("data")->cpp_type() == FieldDescriptor::CPPTYPE_FLOAT);
- float *dstData = dstBlob.matRef().ptr<float>();
-
- for (int i = 0; i < pbBlob.data_size(); i++)
- dstData[i] = pbBlob.data(i);
- }
-
- void extractBinaryLayerParms(const caffe::LayerParameter& layer, LayerParams& layerParams)
- {
- const std::string &name = layer.name();
-
- int li;
- for (li = 0; li != netBinary.layer_size(); li++)
- {
- if (netBinary.layer(li).name() == name)
- break;
- }
-
- if (li == netBinary.layer_size() || netBinary.layer(li).blobs_size() == 0)
- return;
-
- const caffe::LayerParameter &binLayer = netBinary.layer(li);
- layerParams.blobs.resize(binLayer.blobs_size());
- for (int bi = 0; bi < binLayer.blobs_size(); bi++)
- {
- blobFromProto(binLayer.blobs(bi), layerParams.blobs[bi]);
- }
- }
-
- struct BlobNote
- {
- BlobNote(const std::string &_name, int _layerId, int _outNum) :
- name(_name.c_str()), layerId(_layerId), outNum(_outNum) {}
-
- const char *name;
- int layerId, outNum;
- };
-
- std::vector<BlobNote> addedBlobs;
- std::map<String, int> layerCounter;
-
- void populateNet(Net dstNet)
- {
- int layersSize = net.layer_size();
- layerCounter.clear();
- addedBlobs.clear();
- addedBlobs.reserve(layersSize + 1);
-
- //setup input layer names
- {
- std::vector<String> netInputs(net.input_size());
- for (int inNum = 0; inNum < net.input_size(); inNum++)
- {
- addedBlobs.push_back(BlobNote(net.input(inNum), 0, inNum));
- netInputs[inNum] = net.input(inNum);
- }
- dstNet.setNetInputs(netInputs);
- }
-
- for (int li = 0; li < layersSize; li++)
- {
- const caffe::LayerParameter &layer = net.layer(li);
- String name = layer.name();
- String type = layer.type();
- LayerParams layerParams;
-
- extractLayerParams(layer, layerParams);
- extractBinaryLayerParms(layer, layerParams);
-
- int repetitions = layerCounter[name]++;
- if (repetitions)
- name += String("_") + toString(repetitions);
-
- int id = dstNet.addLayer(name, type, layerParams);
-
- for (int inNum = 0; inNum < layer.bottom_size(); inNum++)
- addInput(layer.bottom(inNum), id, inNum, dstNet);
-
- for (int outNum = 0; outNum < layer.top_size(); outNum++)
- addOutput(layer, id, outNum);
- }
-
- addedBlobs.clear();
- }
-
- void addOutput(const caffe::LayerParameter &layer, int layerId, int outNum)
- {
- const std::string &name = layer.top(outNum);
-
- bool haveDups = false;
- for (int idx = (int)addedBlobs.size() - 1; idx >= 0; idx--)
- {
- if (addedBlobs[idx].name == name)
- {
- haveDups = true;
- break;
- }
- }
-
- if (haveDups)
- {
- bool isInplace = layer.bottom_size() > outNum && layer.bottom(outNum) == name;
- if (!isInplace)
- CV_Error(Error::StsBadArg, "Duplicate blobs produced by multiple sources");
- }
-
- addedBlobs.push_back(BlobNote(name, layerId, outNum));
- }
-
- void addInput(const std::string &name, int layerId, int inNum, Net &dstNet)
- {
- int idx;
- for (idx = (int)addedBlobs.size() - 1; idx >= 0; idx--)
- {
- if (addedBlobs[idx].name == name)
- break;
- }
-
- if (idx < 0)
- {
- CV_Error(Error::StsObjectNotFound, "Can't find output blob \"" + name + "\"");
- return;
- }
-
- dstNet.connect(addedBlobs[idx].layerId, addedBlobs[idx].outNum, layerId, inNum);
- }
-
- ~CaffeImporter()
- {
-
- }
-
-};
-
-}
-
-Ptr<Importer> cv::dnn::createCaffeImporter(const String &prototxt, const String &caffeModel)
-{
- return Ptr<Importer>(new CaffeImporter(prototxt.c_str(), caffeModel.c_str()));
-}
-
-#else //HAVE_PROTOBUF
-
-Ptr<Importer> cv::dnn::createCaffeImporter(const String&, const String&)
-{
- CV_Error(cv::Error::StsNotImplemented, "libprotobuf required to import data from Caffe models");
- return Ptr<Importer>();
-}
-
-#endif //HAVE_PROTOBUF
-
-Net cv::dnn::readNetFromCaffe(const String &prototxt, const String &caffeModel /*= String()*/)
-{
- Ptr<Importer> caffeImporter;
- try
- {
- caffeImporter = createCaffeImporter(prototxt, caffeModel);
- }
- catch(...)
- {
- }
-
- Net net;
- if (caffeImporter)
- caffeImporter->populateNet(net);
- return net;
-}
diff --git a/contrib/modules/dnn/src/caffe/caffe_io.cpp b/contrib/modules/dnn/src/caffe/caffe_io.cpp
deleted file mode 100644
index 986271c..0000000
--- a/contrib/modules/dnn/src/caffe/caffe_io.cpp
+++ /dev/null
@@ -1,1115 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//COPYRIGHT
-//
-//All contributions by the University of California:
-//Copyright (c) 2014, The Regents of the University of California (Regents)
-//All rights reserved.
-//
-//All other contributions:
-//Copyright (c) 2014, the respective contributors
-//All rights reserved.
-//
-//Caffe uses a shared copyright model: each contributor holds copyright over
-//their contributions to Caffe. The project versioning records all such
-//contribution and copyright details. If a contributor wants to further mark
-//their specific copyright on a particular contribution, they should indicate
-//their copyright solely in the commit message of the change when it is
-//committed.
-//
-//LICENSE
-//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions are met:
-//
-//1. Redistributions of source code must retain the above copyright notice, this
-// list of conditions and the following disclaimer.
-//2. Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-//ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-//DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-//ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-//(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-//ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-//(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-//CONTRIBUTION AGREEMENT
-//
-//By contributing to the BVLC/caffe repository through pull-request, comment,
-//or otherwise, the contributor releases their content to the
-//license and copyright terms herein.
-//
-//M*/
-
-#if HAVE_PROTOBUF
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/zero_copy_stream_impl.h>
-#include <google/protobuf/text_format.h>
-
-#include <opencv2/core.hpp>
-
-#include <map>
-#include <string>
-#include <fstream>
-#include <vector>
-
-#include "caffe.pb.h"
-#include "caffe_io.hpp"
-#include "glog_emulator.hpp"
-
-namespace cv {
-namespace dnn {
-
-using std::string;
-using std::map;
-using namespace caffe;
-using namespace ::google::protobuf;
-using namespace ::google::protobuf::io;
-
-// Return true iff the net is not the current version.
-bool NetNeedsUpgrade(const NetParameter& net_param);
-
-// Return true iff any layer contains parameters specified using
-// deprecated V0LayerParameter.
-bool NetNeedsV0ToV1Upgrade(const NetParameter& net_param);
-
-// Perform all necessary transformations to upgrade a V0NetParameter into a
-// NetParameter (including upgrading padding layers and LayerParameters).
-bool UpgradeV0Net(const NetParameter& v0_net_param, NetParameter* net_param);
-
-// Upgrade NetParameter with padding layers to pad-aware conv layers.
-// For any padding layer, remove it and put its pad parameter in any layers
-// taking its top blob as input.
-// Error if any of these above layers are not-conv layers.
-void UpgradeV0PaddingLayers(const NetParameter& param,
- NetParameter* param_upgraded_pad);
-
-// Upgrade a single V0LayerConnection to the V1LayerParameter format.
-bool UpgradeV0LayerParameter(const V1LayerParameter& v0_layer_connection,
- V1LayerParameter* layer_param);
-
-V1LayerParameter_LayerType UpgradeV0LayerType(const string& type);
-
-// Return true iff any layer contains deprecated data transformation parameters.
-bool NetNeedsDataUpgrade(const NetParameter& net_param);
-
-// Perform all necessary transformations to upgrade old transformation fields
-// into a TransformationParameter.
-void UpgradeNetDataTransformation(NetParameter* net_param);
-
-// Return true iff the Net contains any layers specified as V1LayerParameters.
-bool NetNeedsV1ToV2Upgrade(const NetParameter& net_param);
-
-// Perform all necessary transformations to upgrade a NetParameter with
-// deprecated V1LayerParameters.
-bool UpgradeV1Net(const NetParameter& v1_net_param, NetParameter* net_param);
-
-bool UpgradeV1LayerParameter(const V1LayerParameter& v1_layer_param,
- LayerParameter* layer_param);
-
-const char* UpgradeV1LayerType(const V1LayerParameter_LayerType type);
-
-// Check for deprecations and upgrade the NetParameter as needed.
-bool UpgradeNetAsNeeded(const string& param_file, NetParameter* param);
-
-
-bool NetNeedsUpgrade(const NetParameter& net_param) {
- return NetNeedsV0ToV1Upgrade(net_param) || NetNeedsV1ToV2Upgrade(net_param);
-}
-
-bool NetNeedsV0ToV1Upgrade(const NetParameter& net_param) {
- for (int i = 0; i < net_param.layers_size(); ++i) {
- if (net_param.layers(i).has_layer()) {
- return true;
- }
- }
- return false;
-}
-
-bool NetNeedsV1ToV2Upgrade(const NetParameter& net_param) {
- return net_param.layers_size() > 0;
-}
-
-bool UpgradeV0Net(const NetParameter& v0_net_param_padding_layers,
- NetParameter* net_param) {
- // First upgrade padding layers to padded conv layers.
- NetParameter v0_net_param;
- UpgradeV0PaddingLayers(v0_net_param_padding_layers, &v0_net_param);
- // Now upgrade layer parameters.
- bool is_fully_compatible = true;
- net_param->Clear();
- if (v0_net_param.has_name()) {
- net_param->set_name(v0_net_param.name());
- }
- for (int i = 0; i < v0_net_param.layers_size(); ++i) {
- is_fully_compatible &= UpgradeV0LayerParameter(v0_net_param.layers(i),
- net_param->add_layers());
- }
- for (int i = 0; i < v0_net_param.input_size(); ++i) {
- net_param->add_input(v0_net_param.input(i));
- }
- for (int i = 0; i < v0_net_param.input_dim_size(); ++i) {
- net_param->add_input_dim(v0_net_param.input_dim(i));
- }
- if (v0_net_param.has_force_backward()) {
- net_param->set_force_backward(v0_net_param.force_backward());
- }
- return is_fully_compatible;
-}
-
-void UpgradeV0PaddingLayers(const NetParameter& param,
- NetParameter* param_upgraded_pad) {
- // Copy everything other than the layers from the original param.
- param_upgraded_pad->Clear();
- param_upgraded_pad->CopyFrom(param);
- param_upgraded_pad->clear_layers();
- // Figure out which layer each bottom blob comes from.
- map<string, int> blob_name_to_last_top_idx;
- for (int i = 0; i < param.input_size(); ++i) {
- const string& blob_name = param.input(i);
- blob_name_to_last_top_idx[blob_name] = -1;
- }
- for (int i = 0; i < param.layers_size(); ++i) {
- const V1LayerParameter& layer_connection = param.layers(i);
- const V0LayerParameter& layer_param = layer_connection.layer();
- // Add the layer to the new net, unless it's a padding layer.
- if (layer_param.type() != "padding") {
- param_upgraded_pad->add_layers()->CopyFrom(layer_connection);
- }
- for (int j = 0; j < layer_connection.bottom_size(); ++j) {
- const string& blob_name = layer_connection.bottom(j);
- if (blob_name_to_last_top_idx.find(blob_name) ==
- blob_name_to_last_top_idx.end()) {
- LOG(FATAL) << "Unknown blob input " << blob_name << " to layer " << j;
- }
- const int top_idx = blob_name_to_last_top_idx[blob_name];
- if (top_idx == -1) {
- continue;
- }
- const V1LayerParameter& source_layer = param.layers(top_idx);
- if (source_layer.layer().type() == "padding") {
- // This layer has a padding layer as input -- check that it is a conv
- // layer or a pooling layer and takes only one input. Also check that
- // the padding layer input has only one input and one output. Other
- // cases have undefined behavior in Caffe.
- CHECK((layer_param.type() == "conv") || (layer_param.type() == "pool"))
- << "Padding layer input to "
- "non-convolutional / non-pooling layer type "
- << layer_param.type();
- CHECK_EQ(layer_connection.bottom_size(), 1)
- << "Conv Layer takes a single blob as input.";
- CHECK_EQ(source_layer.bottom_size(), 1)
- << "Padding Layer takes a single blob as input.";
- CHECK_EQ(source_layer.top_size(), 1)
- << "Padding Layer produces a single blob as output.";
- int layer_index = param_upgraded_pad->layers_size() - 1;
- param_upgraded_pad->mutable_layers(layer_index)->mutable_layer()
- ->set_pad(source_layer.layer().pad());
- param_upgraded_pad->mutable_layers(layer_index)
- ->set_bottom(j, source_layer.bottom(0));
- }
- }
- for (int j = 0; j < layer_connection.top_size(); ++j) {
- const string& blob_name = layer_connection.top(j);
- blob_name_to_last_top_idx[blob_name] = i;
- }
- }
-}
-
-bool UpgradeV0LayerParameter(const V1LayerParameter& v0_layer_connection,
- V1LayerParameter* layer_param) {
- bool is_fully_compatible = true;
- layer_param->Clear();
- for (int i = 0; i < v0_layer_connection.bottom_size(); ++i) {
- layer_param->add_bottom(v0_layer_connection.bottom(i));
- }
- for (int i = 0; i < v0_layer_connection.top_size(); ++i) {
- layer_param->add_top(v0_layer_connection.top(i));
- }
- if (v0_layer_connection.has_layer()) {
- const V0LayerParameter& v0_layer_param = v0_layer_connection.layer();
- if (v0_layer_param.has_name()) {
- layer_param->set_name(v0_layer_param.name());
- }
- const string& type = v0_layer_param.type();
- if (v0_layer_param.has_type()) {
- layer_param->set_type(UpgradeV0LayerType(type));
- }
- for (int i = 0; i < v0_layer_param.blobs_size(); ++i) {
- layer_param->add_blobs()->CopyFrom(v0_layer_param.blobs(i));
- }
- for (int i = 0; i < v0_layer_param.blobs_lr_size(); ++i) {
- layer_param->add_blobs_lr(v0_layer_param.blobs_lr(i));
- }
- for (int i = 0; i < v0_layer_param.weight_decay_size(); ++i) {
- layer_param->add_weight_decay(v0_layer_param.weight_decay(i));
- }
- if (v0_layer_param.has_num_output()) {
- if (type == "conv") {
- layer_param->mutable_convolution_param()->set_num_output(
- v0_layer_param.num_output());
- } else if (type == "innerproduct") {
- layer_param->mutable_inner_product_param()->set_num_output(
- v0_layer_param.num_output());
- } else {
- LOG(ERROR) << "Unknown parameter num_output for layer type " << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_biasterm()) {
- if (type == "conv") {
- layer_param->mutable_convolution_param()->set_bias_term(
- v0_layer_param.biasterm());
- } else if (type == "innerproduct") {
- layer_param->mutable_inner_product_param()->set_bias_term(
- v0_layer_param.biasterm());
- } else {
- LOG(ERROR) << "Unknown parameter biasterm for layer type " << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_weight_filler()) {
- if (type == "conv") {
- layer_param->mutable_convolution_param()->
- mutable_weight_filler()->CopyFrom(v0_layer_param.weight_filler());
- } else if (type == "innerproduct") {
- layer_param->mutable_inner_product_param()->
- mutable_weight_filler()->CopyFrom(v0_layer_param.weight_filler());
- } else {
- LOG(ERROR) << "Unknown parameter weight_filler for layer type " << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_bias_filler()) {
- if (type == "conv") {
- layer_param->mutable_convolution_param()->
- mutable_bias_filler()->CopyFrom(v0_layer_param.bias_filler());
- } else if (type == "innerproduct") {
- layer_param->mutable_inner_product_param()->
- mutable_bias_filler()->CopyFrom(v0_layer_param.bias_filler());
- } else {
- LOG(ERROR) << "Unknown parameter bias_filler for layer type " << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_pad()) {
- if (type == "conv") {
- layer_param->mutable_convolution_param()->set_pad(v0_layer_param.pad());
- } else if (type == "pool") {
- layer_param->mutable_pooling_param()->set_pad(v0_layer_param.pad());
- } else {
- LOG(ERROR) << "Unknown parameter pad for layer type " << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_kernelsize()) {
- if (type == "conv") {
- layer_param->mutable_convolution_param()->set_kernel_size(
- v0_layer_param.kernelsize());
- } else if (type == "pool") {
- layer_param->mutable_pooling_param()->set_kernel_size(
- v0_layer_param.kernelsize());
- } else {
- LOG(ERROR) << "Unknown parameter kernelsize for layer type " << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_group()) {
- if (type == "conv") {
- layer_param->mutable_convolution_param()->set_group(
- v0_layer_param.group());
- } else {
- LOG(ERROR) << "Unknown parameter group for layer type " << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_stride()) {
- if (type == "conv") {
- layer_param->mutable_convolution_param()->set_stride(
- v0_layer_param.stride());
- } else if (type == "pool") {
- layer_param->mutable_pooling_param()->set_stride(
- v0_layer_param.stride());
- } else {
- LOG(ERROR) << "Unknown parameter stride for layer type " << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_pool()) {
- if (type == "pool") {
- V0LayerParameter_PoolMethod pool = v0_layer_param.pool();
- switch (pool) {
- case V0LayerParameter_PoolMethod_MAX:
- layer_param->mutable_pooling_param()->set_pool(
- PoolingParameter_PoolMethod_MAX);
- break;
- case V0LayerParameter_PoolMethod_AVE:
- layer_param->mutable_pooling_param()->set_pool(
- PoolingParameter_PoolMethod_AVE);
- break;
- case V0LayerParameter_PoolMethod_STOCHASTIC:
- layer_param->mutable_pooling_param()->set_pool(
- PoolingParameter_PoolMethod_STOCHASTIC);
- break;
- default:
- LOG(ERROR) << "Unknown pool method " << pool;
- is_fully_compatible = false;
- }
- } else {
- LOG(ERROR) << "Unknown parameter pool for layer type " << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_dropout_ratio()) {
- if (type == "dropout") {
- layer_param->mutable_dropout_param()->set_dropout_ratio(
- v0_layer_param.dropout_ratio());
- } else {
- LOG(ERROR) << "Unknown parameter dropout_ratio for layer type " << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_local_size()) {
- if (type == "lrn") {
- layer_param->mutable_lrn_param()->set_local_size(
- v0_layer_param.local_size());
- } else {
- LOG(ERROR) << "Unknown parameter local_size for layer type " << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_alpha()) {
- if (type == "lrn") {
- layer_param->mutable_lrn_param()->set_alpha(v0_layer_param.alpha());
- } else {
- LOG(ERROR) << "Unknown parameter alpha for layer type " << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_beta()) {
- if (type == "lrn") {
- layer_param->mutable_lrn_param()->set_beta(v0_layer_param.beta());
- } else {
- LOG(ERROR) << "Unknown parameter beta for layer type " << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_k()) {
- if (type == "lrn") {
- layer_param->mutable_lrn_param()->set_k(v0_layer_param.k());
- } else {
- LOG(ERROR) << "Unknown parameter k for layer type " << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_source()) {
- if (type == "data") {
- layer_param->mutable_data_param()->set_source(v0_layer_param.source());
- } else if (type == "hdf5_data") {
- layer_param->mutable_hdf5_data_param()->set_source(
- v0_layer_param.source());
- } else if (type == "images") {
- layer_param->mutable_image_data_param()->set_source(
- v0_layer_param.source());
- } else if (type == "window_data") {
- layer_param->mutable_window_data_param()->set_source(
- v0_layer_param.source());
- } else if (type == "infogain_loss") {
- layer_param->mutable_infogain_loss_param()->set_source(
- v0_layer_param.source());
- } else {
- LOG(ERROR) << "Unknown parameter source for layer type " << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_scale()) {
- layer_param->mutable_transform_param()->
- set_scale(v0_layer_param.scale());
- }
- if (v0_layer_param.has_meanfile()) {
- layer_param->mutable_transform_param()->
- set_mean_file(v0_layer_param.meanfile());
- }
- if (v0_layer_param.has_batchsize()) {
- if (type == "data") {
- layer_param->mutable_data_param()->set_batch_size(
- v0_layer_param.batchsize());
- } else if (type == "hdf5_data") {
- layer_param->mutable_hdf5_data_param()->set_batch_size(
- v0_layer_param.batchsize());
- } else if (type == "images") {
- layer_param->mutable_image_data_param()->set_batch_size(
- v0_layer_param.batchsize());
- } else if (type == "window_data") {
- layer_param->mutable_window_data_param()->set_batch_size(
- v0_layer_param.batchsize());
- } else {
- LOG(ERROR) << "Unknown parameter batchsize for layer type " << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_cropsize()) {
- layer_param->mutable_transform_param()->
- set_crop_size(v0_layer_param.cropsize());
- }
- if (v0_layer_param.has_mirror()) {
- layer_param->mutable_transform_param()->
- set_mirror(v0_layer_param.mirror());
- }
- if (v0_layer_param.has_rand_skip()) {
- if (type == "data") {
- layer_param->mutable_data_param()->set_rand_skip(
- v0_layer_param.rand_skip());
- } else if (type == "images") {
- layer_param->mutable_image_data_param()->set_rand_skip(
- v0_layer_param.rand_skip());
- } else {
- LOG(ERROR) << "Unknown parameter rand_skip for layer type " << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_shuffle_images()) {
- if (type == "images") {
- layer_param->mutable_image_data_param()->set_shuffle(
- v0_layer_param.shuffle_images());
- } else {
- LOG(ERROR) << "Unknown parameter shuffle for layer type " << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_new_height()) {
- if (type == "images") {
- layer_param->mutable_image_data_param()->set_new_height(
- v0_layer_param.new_height());
- } else {
- LOG(ERROR) << "Unknown parameter new_height for layer type " << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_new_width()) {
- if (type == "images") {
- layer_param->mutable_image_data_param()->set_new_width(
- v0_layer_param.new_width());
- } else {
- LOG(ERROR) << "Unknown parameter new_width for layer type " << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_concat_dim()) {
- if (type == "concat") {
- layer_param->mutable_concat_param()->set_concat_dim(
- v0_layer_param.concat_dim());
- } else {
- LOG(ERROR) << "Unknown parameter concat_dim for layer type " << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_det_fg_threshold()) {
- if (type == "window_data") {
- layer_param->mutable_window_data_param()->set_fg_threshold(
- v0_layer_param.det_fg_threshold());
- } else {
- LOG(ERROR) << "Unknown parameter det_fg_threshold for layer type "
- << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_det_bg_threshold()) {
- if (type == "window_data") {
- layer_param->mutable_window_data_param()->set_bg_threshold(
- v0_layer_param.det_bg_threshold());
- } else {
- LOG(ERROR) << "Unknown parameter det_bg_threshold for layer type "
- << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_det_fg_fraction()) {
- if (type == "window_data") {
- layer_param->mutable_window_data_param()->set_fg_fraction(
- v0_layer_param.det_fg_fraction());
- } else {
- LOG(ERROR) << "Unknown parameter det_fg_fraction for layer type "
- << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_det_context_pad()) {
- if (type == "window_data") {
- layer_param->mutable_window_data_param()->set_context_pad(
- v0_layer_param.det_context_pad());
- } else {
- LOG(ERROR) << "Unknown parameter det_context_pad for layer type "
- << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_det_crop_mode()) {
- if (type == "window_data") {
- layer_param->mutable_window_data_param()->set_crop_mode(
- v0_layer_param.det_crop_mode());
- } else {
- LOG(ERROR) << "Unknown parameter det_crop_mode for layer type "
- << type;
- is_fully_compatible = false;
- }
- }
- if (v0_layer_param.has_hdf5_output_param()) {
- if (type == "hdf5_output") {
- layer_param->mutable_hdf5_output_param()->CopyFrom(
- v0_layer_param.hdf5_output_param());
- } else {
- LOG(ERROR) << "Unknown parameter hdf5_output_param for layer type "
- << type;
- is_fully_compatible = false;
- }
- }
- }
- return is_fully_compatible;
-}
-
-V1LayerParameter_LayerType UpgradeV0LayerType(const string& type) {
- if (type == "accuracy") {
- return V1LayerParameter_LayerType_ACCURACY;
- } else if (type == "bnll") {
- return V1LayerParameter_LayerType_BNLL;
- } else if (type == "concat") {
- return V1LayerParameter_LayerType_CONCAT;
- } else if (type == "conv") {
- return V1LayerParameter_LayerType_CONVOLUTION;
- } else if (type == "data") {
- return V1LayerParameter_LayerType_DATA;
- } else if (type == "dropout") {
- return V1LayerParameter_LayerType_DROPOUT;
- } else if (type == "euclidean_loss") {
- return V1LayerParameter_LayerType_EUCLIDEAN_LOSS;
- } else if (type == "flatten") {
- return V1LayerParameter_LayerType_FLATTEN;
- } else if (type == "hdf5_data") {
- return V1LayerParameter_LayerType_HDF5_DATA;
- } else if (type == "hdf5_output") {
- return V1LayerParameter_LayerType_HDF5_OUTPUT;
- } else if (type == "im2col") {
- return V1LayerParameter_LayerType_IM2COL;
- } else if (type == "images") {
- return V1LayerParameter_LayerType_IMAGE_DATA;
- } else if (type == "infogain_loss") {
- return V1LayerParameter_LayerType_INFOGAIN_LOSS;
- } else if (type == "innerproduct") {
- return V1LayerParameter_LayerType_INNER_PRODUCT;
- } else if (type == "lrn") {
- return V1LayerParameter_LayerType_LRN;
- } else if (type == "multinomial_logistic_loss") {
- return V1LayerParameter_LayerType_MULTINOMIAL_LOGISTIC_LOSS;
- } else if (type == "pool") {
- return V1LayerParameter_LayerType_POOLING;
- } else if (type == "relu") {
- return V1LayerParameter_LayerType_RELU;
- } else if (type == "sigmoid") {
- return V1LayerParameter_LayerType_SIGMOID;
- } else if (type == "softmax") {
- return V1LayerParameter_LayerType_SOFTMAX;
- } else if (type == "softmax_loss") {
- return V1LayerParameter_LayerType_SOFTMAX_LOSS;
- } else if (type == "split") {
- return V1LayerParameter_LayerType_SPLIT;
- } else if (type == "tanh") {
- return V1LayerParameter_LayerType_TANH;
- } else if (type == "window_data") {
- return V1LayerParameter_LayerType_WINDOW_DATA;
- } else {
- LOG(FATAL) << "Unknown layer name: " << type;
- return V1LayerParameter_LayerType_NONE;
- }
-}
-
-bool NetNeedsDataUpgrade(const NetParameter& net_param) {
- for (int i = 0; i < net_param.layers_size(); ++i) {
- if (net_param.layers(i).type() == V1LayerParameter_LayerType_DATA) {
- DataParameter layer_param = net_param.layers(i).data_param();
- if (layer_param.has_scale()) { return true; }
- if (layer_param.has_mean_file()) { return true; }
- if (layer_param.has_crop_size()) { return true; }
- if (layer_param.has_mirror()) { return true; }
- }
- if (net_param.layers(i).type() == V1LayerParameter_LayerType_IMAGE_DATA) {
- ImageDataParameter layer_param = net_param.layers(i).image_data_param();
- if (layer_param.has_scale()) { return true; }
- if (layer_param.has_mean_file()) { return true; }
- if (layer_param.has_crop_size()) { return true; }
- if (layer_param.has_mirror()) { return true; }
- }
- if (net_param.layers(i).type() == V1LayerParameter_LayerType_WINDOW_DATA) {
- WindowDataParameter layer_param = net_param.layers(i).window_data_param();
- if (layer_param.has_scale()) { return true; }
- if (layer_param.has_mean_file()) { return true; }
- if (layer_param.has_crop_size()) { return true; }
- if (layer_param.has_mirror()) { return true; }
- }
- }
- return false;
-}
-
-#define CONVERT_LAYER_TRANSFORM_PARAM(TYPE, Name, param_name) \
- do { \
- if (net_param->layers(i).type() == V1LayerParameter_LayerType_##TYPE) { \
- Name##Parameter* layer_param = \
- net_param->mutable_layers(i)->mutable_##param_name##_param(); \
- TransformationParameter* transform_param = \
- net_param->mutable_layers(i)->mutable_transform_param(); \
- if (layer_param->has_scale()) { \
- transform_param->set_scale(layer_param->scale()); \
- layer_param->clear_scale(); \
- } \
- if (layer_param->has_mean_file()) { \
- transform_param->set_mean_file(layer_param->mean_file()); \
- layer_param->clear_mean_file(); \
- } \
- if (layer_param->has_crop_size()) { \
- transform_param->set_crop_size(layer_param->crop_size()); \
- layer_param->clear_crop_size(); \
- } \
- if (layer_param->has_mirror()) { \
- transform_param->set_mirror(layer_param->mirror()); \
- layer_param->clear_mirror(); \
- } \
- } \
- } while (0)
-
-void UpgradeNetDataTransformation(NetParameter* net_param) {
- for (int i = 0; i < net_param->layers_size(); ++i) {
- CONVERT_LAYER_TRANSFORM_PARAM(DATA, Data, data);
- CONVERT_LAYER_TRANSFORM_PARAM(IMAGE_DATA, ImageData, image_data);
- CONVERT_LAYER_TRANSFORM_PARAM(WINDOW_DATA, WindowData, window_data);
- }
-}
-
-bool UpgradeNetAsNeeded(const string& param_file, NetParameter* param) {
- bool success = true;
- if (NetNeedsV0ToV1Upgrade(*param)) {
- // NetParameter was specified using the old style (V0LayerParameter); try to
- // upgrade it.
- LOG(ERROR) << "Attempting to upgrade input file specified using deprecated "
- << "V0LayerParameter: " << param_file;
- NetParameter original_param(*param);
- if (!UpgradeV0Net(original_param, param)) {
- success = false;
- LOG(ERROR) << "Warning: had one or more problems upgrading "
- << "V0NetParameter to NetParameter (see above); continuing anyway.";
- } else {
- LOG(INFO) << "Successfully upgraded file specified using deprecated "
- << "V0LayerParameter";
- }
- LOG(ERROR) << "Note that future Caffe releases will not support "
- << "V0NetParameter; use ./build/tools/upgrade_net_proto_text for "
- << "prototxt and ./build/tools/upgrade_net_proto_binary for model "
- << "weights upgrade this and any other net protos to the new format.";
- }
- // NetParameter uses old style data transformation fields; try to upgrade it.
- if (NetNeedsDataUpgrade(*param)) {
- LOG(ERROR) << "Attempting to upgrade input file specified using deprecated "
- << "transformation parameters: " << param_file;
- UpgradeNetDataTransformation(param);
- LOG(INFO) << "Successfully upgraded file specified using deprecated "
- << "data transformation parameters.";
- LOG(ERROR) << "Note that future Caffe releases will only support "
- << "transform_param messages for transformation fields.";
- }
- if (NetNeedsV1ToV2Upgrade(*param)) {
- LOG(ERROR) << "Attempting to upgrade input file specified using deprecated "
- << "V1LayerParameter: " << param_file;
- NetParameter original_param(*param);
- if (!UpgradeV1Net(original_param, param)) {
- success = false;
- LOG(ERROR) << "Warning: had one or more problems upgrading "
- << "V1LayerParameter (see above); continuing anyway.";
- } else {
- LOG(INFO) << "Successfully upgraded file specified using deprecated "
- << "V1LayerParameter";
- }
- }
- return success;
-}
-
-bool UpgradeV1Net(const NetParameter& v1_net_param, NetParameter* net_param) {
- bool is_fully_compatible = true;
- if (v1_net_param.layer_size() > 0) {
- LOG(ERROR) << "Input NetParameter to be upgraded already specifies 'layer' "
- << "fields; these will be ignored for the upgrade.";
- is_fully_compatible = false;
- }
- net_param->CopyFrom(v1_net_param);
- net_param->clear_layers();
- net_param->clear_layer();
- for (int i = 0; i < v1_net_param.layers_size(); ++i) {
- if (!UpgradeV1LayerParameter(v1_net_param.layers(i),
- net_param->add_layer())) {
- LOG(ERROR) << "Upgrade of input layer " << i << " failed.";
- is_fully_compatible = false;
- }
- }
- return is_fully_compatible;
-}
-
-bool UpgradeV1LayerParameter(const V1LayerParameter& v1_layer_param,
- LayerParameter* layer_param) {
- layer_param->Clear();
- bool is_fully_compatible = true;
- for (int i = 0; i < v1_layer_param.bottom_size(); ++i) {
- layer_param->add_bottom(v1_layer_param.bottom(i));
- }
- for (int i = 0; i < v1_layer_param.top_size(); ++i) {
- layer_param->add_top(v1_layer_param.top(i));
- }
- if (v1_layer_param.has_name()) {
- layer_param->set_name(v1_layer_param.name());
- }
- for (int i = 0; i < v1_layer_param.include_size(); ++i) {
- layer_param->add_include()->CopyFrom(v1_layer_param.include(i));
- }
- for (int i = 0; i < v1_layer_param.exclude_size(); ++i) {
- layer_param->add_exclude()->CopyFrom(v1_layer_param.exclude(i));
- }
- if (v1_layer_param.has_type()) {
- layer_param->set_type(UpgradeV1LayerType(v1_layer_param.type()));
- }
- for (int i = 0; i < v1_layer_param.blobs_size(); ++i) {
- layer_param->add_blobs()->CopyFrom(v1_layer_param.blobs(i));
- }
- for (int i = 0; i < v1_layer_param.param_size(); ++i) {
- while (layer_param->param_size() <= i) { layer_param->add_param(); }
- layer_param->mutable_param(i)->set_name(v1_layer_param.param(i));
- }
- ParamSpec_DimCheckMode mode;
- for (int i = 0; i < v1_layer_param.blob_share_mode_size(); ++i) {
- while (layer_param->param_size() <= i) { layer_param->add_param(); }
- switch (v1_layer_param.blob_share_mode(i)) {
- case V1LayerParameter_DimCheckMode_STRICT:
- mode = ParamSpec_DimCheckMode_STRICT;
- break;
- case V1LayerParameter_DimCheckMode_PERMISSIVE:
- mode = ParamSpec_DimCheckMode_PERMISSIVE;
- break;
- default:
- LOG(FATAL) << "Unknown blob_share_mode: "
- << v1_layer_param.blob_share_mode(i);
- break;
- }
- layer_param->mutable_param(i)->set_share_mode(mode);
- }
- for (int i = 0; i < v1_layer_param.blobs_lr_size(); ++i) {
- while (layer_param->param_size() <= i) { layer_param->add_param(); }
- layer_param->mutable_param(i)->set_lr_mult(v1_layer_param.blobs_lr(i));
- }
- for (int i = 0; i < v1_layer_param.weight_decay_size(); ++i) {
- while (layer_param->param_size() <= i) { layer_param->add_param(); }
- layer_param->mutable_param(i)->set_decay_mult(
- v1_layer_param.weight_decay(i));
- }
- for (int i = 0; i < v1_layer_param.loss_weight_size(); ++i) {
- layer_param->add_loss_weight(v1_layer_param.loss_weight(i));
- }
- if (v1_layer_param.has_accuracy_param()) {
- layer_param->mutable_accuracy_param()->CopyFrom(
- v1_layer_param.accuracy_param());
- }
- if (v1_layer_param.has_argmax_param()) {
- layer_param->mutable_argmax_param()->CopyFrom(
- v1_layer_param.argmax_param());
- }
- if (v1_layer_param.has_concat_param()) {
- layer_param->mutable_concat_param()->CopyFrom(
- v1_layer_param.concat_param());
- }
- if (v1_layer_param.has_contrastive_loss_param()) {
- layer_param->mutable_contrastive_loss_param()->CopyFrom(
- v1_layer_param.contrastive_loss_param());
- }
- if (v1_layer_param.has_convolution_param()) {
- layer_param->mutable_convolution_param()->CopyFrom(
- v1_layer_param.convolution_param());
- }
- if (v1_layer_param.has_data_param()) {
- layer_param->mutable_data_param()->CopyFrom(
- v1_layer_param.data_param());
- }
- if (v1_layer_param.has_dropout_param()) {
- layer_param->mutable_dropout_param()->CopyFrom(
- v1_layer_param.dropout_param());
- }
- if (v1_layer_param.has_dummy_data_param()) {
- layer_param->mutable_dummy_data_param()->CopyFrom(
- v1_layer_param.dummy_data_param());
- }
- if (v1_layer_param.has_eltwise_param()) {
- layer_param->mutable_eltwise_param()->CopyFrom(
- v1_layer_param.eltwise_param());
- }
- if (v1_layer_param.has_exp_param()) {
- layer_param->mutable_exp_param()->CopyFrom(
- v1_layer_param.exp_param());
- }
- if (v1_layer_param.has_hdf5_data_param()) {
- layer_param->mutable_hdf5_data_param()->CopyFrom(
- v1_layer_param.hdf5_data_param());
- }
- if (v1_layer_param.has_hdf5_output_param()) {
- layer_param->mutable_hdf5_output_param()->CopyFrom(
- v1_layer_param.hdf5_output_param());
- }
- if (v1_layer_param.has_hinge_loss_param()) {
- layer_param->mutable_hinge_loss_param()->CopyFrom(
- v1_layer_param.hinge_loss_param());
- }
- if (v1_layer_param.has_image_data_param()) {
- layer_param->mutable_image_data_param()->CopyFrom(
- v1_layer_param.image_data_param());
- }
- if (v1_layer_param.has_infogain_loss_param()) {
- layer_param->mutable_infogain_loss_param()->CopyFrom(
- v1_layer_param.infogain_loss_param());
- }
- if (v1_layer_param.has_inner_product_param()) {
- layer_param->mutable_inner_product_param()->CopyFrom(
- v1_layer_param.inner_product_param());
- }
- if (v1_layer_param.has_lrn_param()) {
- layer_param->mutable_lrn_param()->CopyFrom(
- v1_layer_param.lrn_param());
- }
- if (v1_layer_param.has_memory_data_param()) {
- layer_param->mutable_memory_data_param()->CopyFrom(
- v1_layer_param.memory_data_param());
- }
- if (v1_layer_param.has_mvn_param()) {
- layer_param->mutable_mvn_param()->CopyFrom(
- v1_layer_param.mvn_param());
- }
- if (v1_layer_param.has_pooling_param()) {
- layer_param->mutable_pooling_param()->CopyFrom(
- v1_layer_param.pooling_param());
- }
- if (v1_layer_param.has_power_param()) {
- layer_param->mutable_power_param()->CopyFrom(
- v1_layer_param.power_param());
- }
- if (v1_layer_param.has_relu_param()) {
- layer_param->mutable_relu_param()->CopyFrom(
- v1_layer_param.relu_param());
- }
- if (v1_layer_param.has_sigmoid_param()) {
- layer_param->mutable_sigmoid_param()->CopyFrom(
- v1_layer_param.sigmoid_param());
- }
- if (v1_layer_param.has_softmax_param()) {
- layer_param->mutable_softmax_param()->CopyFrom(
- v1_layer_param.softmax_param());
- }
- if (v1_layer_param.has_slice_param()) {
- layer_param->mutable_slice_param()->CopyFrom(
- v1_layer_param.slice_param());
- }
- if (v1_layer_param.has_tanh_param()) {
- layer_param->mutable_tanh_param()->CopyFrom(
- v1_layer_param.tanh_param());
- }
- if (v1_layer_param.has_threshold_param()) {
- layer_param->mutable_threshold_param()->CopyFrom(
- v1_layer_param.threshold_param());
- }
- if (v1_layer_param.has_window_data_param()) {
- layer_param->mutable_window_data_param()->CopyFrom(
- v1_layer_param.window_data_param());
- }
- if (v1_layer_param.has_transform_param()) {
- layer_param->mutable_transform_param()->CopyFrom(
- v1_layer_param.transform_param());
- }
- if (v1_layer_param.has_loss_param()) {
- layer_param->mutable_loss_param()->CopyFrom(
- v1_layer_param.loss_param());
- }
- if (v1_layer_param.has_layer()) {
- LOG(ERROR) << "Input NetParameter has V0 layer -- ignoring.";
- is_fully_compatible = false;
- }
- return is_fully_compatible;
-}
-
-const char* UpgradeV1LayerType(const V1LayerParameter_LayerType type) {
- switch (type) {
- case V1LayerParameter_LayerType_NONE:
- return "";
- case V1LayerParameter_LayerType_ABSVAL:
- return "AbsVal";
- case V1LayerParameter_LayerType_ACCURACY:
- return "Accuracy";
- case V1LayerParameter_LayerType_ARGMAX:
- return "ArgMax";
- case V1LayerParameter_LayerType_BNLL:
- return "BNLL";
- case V1LayerParameter_LayerType_CONCAT:
- return "Concat";
- case V1LayerParameter_LayerType_CONTRASTIVE_LOSS:
- return "ContrastiveLoss";
- case V1LayerParameter_LayerType_CONVOLUTION:
- return "Convolution";
- case V1LayerParameter_LayerType_DECONVOLUTION:
- return "Deconvolution";
- case V1LayerParameter_LayerType_DATA:
- return "Data";
- case V1LayerParameter_LayerType_DROPOUT:
- return "Dropout";
- case V1LayerParameter_LayerType_DUMMY_DATA:
- return "DummyData";
- case V1LayerParameter_LayerType_EUCLIDEAN_LOSS:
- return "EuclideanLoss";
- case V1LayerParameter_LayerType_ELTWISE:
- return "Eltwise";
- case V1LayerParameter_LayerType_EXP:
- return "Exp";
- case V1LayerParameter_LayerType_FLATTEN:
- return "Flatten";
- case V1LayerParameter_LayerType_HDF5_DATA:
- return "HDF5Data";
- case V1LayerParameter_LayerType_HDF5_OUTPUT:
- return "HDF5Output";
- case V1LayerParameter_LayerType_HINGE_LOSS:
- return "HingeLoss";
- case V1LayerParameter_LayerType_IM2COL:
- return "Im2col";
- case V1LayerParameter_LayerType_IMAGE_DATA:
- return "ImageData";
- case V1LayerParameter_LayerType_INFOGAIN_LOSS:
- return "InfogainLoss";
- case V1LayerParameter_LayerType_INNER_PRODUCT:
- return "InnerProduct";
- case V1LayerParameter_LayerType_LRN:
- return "LRN";
- case V1LayerParameter_LayerType_MEMORY_DATA:
- return "MemoryData";
- case V1LayerParameter_LayerType_MULTINOMIAL_LOGISTIC_LOSS:
- return "MultinomialLogisticLoss";
- case V1LayerParameter_LayerType_MVN:
- return "MVN";
- case V1LayerParameter_LayerType_POOLING:
- return "Pooling";
- case V1LayerParameter_LayerType_POWER:
- return "Power";
- case V1LayerParameter_LayerType_RELU:
- return "ReLU";
- case V1LayerParameter_LayerType_SIGMOID:
- return "Sigmoid";
- case V1LayerParameter_LayerType_SIGMOID_CROSS_ENTROPY_LOSS:
- return "SigmoidCrossEntropyLoss";
- case V1LayerParameter_LayerType_SILENCE:
- return "Silence";
- case V1LayerParameter_LayerType_SOFTMAX:
- return "Softmax";
- case V1LayerParameter_LayerType_SOFTMAX_LOSS:
- return "SoftmaxWithLoss";
- case V1LayerParameter_LayerType_SPLIT:
- return "Split";
- case V1LayerParameter_LayerType_SLICE:
- return "Slice";
- case V1LayerParameter_LayerType_TANH:
- return "TanH";
- case V1LayerParameter_LayerType_WINDOW_DATA:
- return "WindowData";
- case V1LayerParameter_LayerType_THRESHOLD:
- return "Threshold";
- default:
- LOG(FATAL) << "Unknown V1LayerParameter layer type: " << type;
- return "";
- }
-}
-
-const int kProtoReadBytesLimit = INT_MAX; // Max size of 2 GB minus 1 byte.
-
-bool ReadProtoFromTextFile(const char* filename, Message* proto) {
- std::ifstream fs(filename, std::ifstream::in);
- CHECK(fs.is_open()) << "Can't open \"" << filename << "\"";
- IstreamInputStream input(&fs);
- bool success = google::protobuf::TextFormat::Parse(&input, proto);
- fs.close();
- return success;
-}
-
-bool ReadProtoFromBinaryFile(const char* filename, Message* proto) {
- std::ifstream fs(filename, std::ifstream::in | std::ifstream::binary);
- CHECK(fs.is_open()) << "Can't open \"" << filename << "\"";
- ZeroCopyInputStream* raw_input = new IstreamInputStream(&fs);
- CodedInputStream* coded_input = new CodedInputStream(raw_input);
- coded_input->SetTotalBytesLimit(kProtoReadBytesLimit, 536870912);
-
- bool success = proto->ParseFromCodedStream(coded_input);
-
- delete coded_input;
- delete raw_input;
- fs.close();
- return success;
-}
-
-void ReadNetParamsFromTextFileOrDie(const char* param_file,
- NetParameter* param) {
- CHECK(ReadProtoFromTextFile(param_file, param))
- << "Failed to parse NetParameter file: " << param_file;
- UpgradeNetAsNeeded(param_file, param);
-}
-
-void ReadNetParamsFromBinaryFileOrDie(const char* param_file,
- NetParameter* param) {
- CHECK(ReadProtoFromBinaryFile(param_file, param))
- << "Failed to parse NetParameter file: " << param_file;
- UpgradeNetAsNeeded(param_file, param);
-}
-
-}
-}
-#endif
diff --git a/contrib/modules/dnn/src/caffe/caffe_io.hpp b/contrib/modules/dnn/src/caffe/caffe_io.hpp
deleted file mode 100644
index fa16612..0000000
--- a/contrib/modules/dnn/src/caffe/caffe_io.hpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//COPYRIGHT
-//
-//All contributions by the University of California:
-//Copyright (c) 2014, The Regents of the University of California (Regents)
-//All rights reserved.
-//
-//All other contributions:
-//Copyright (c) 2014, the respective contributors
-//All rights reserved.
-//
-//Caffe uses a shared copyright model: each contributor holds copyright over
-//their contributions to Caffe. The project versioning records all such
-//contribution and copyright details. If a contributor wants to further mark
-//their specific copyright on a particular contribution, they should indicate
-//their copyright solely in the commit message of the change when it is
-//committed.
-//
-//LICENSE
-//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions are met:
-//
-//1. Redistributions of source code must retain the above copyright notice, this
-// list of conditions and the following disclaimer.
-//2. Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-//ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-//DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-//ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-//(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-//ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-//(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-//CONTRIBUTION AGREEMENT
-//
-//By contributing to the BVLC/caffe repository through pull-request, comment,
-//or otherwise, the contributor releases their content to the
-//license and copyright terms herein.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_CAFFE_IO_HPP__
-#define __OPENCV_DNN_CAFFE_IO_HPP__
-#if HAVE_PROTOBUF
-
-#include "caffe.pb.h"
-
-namespace cv {
-namespace dnn {
-
-// Read parameters from a file into a NetParameter proto message.
-void ReadNetParamsFromTextFileOrDie(const char* param_file,
- caffe::NetParameter* param);
-void ReadNetParamsFromBinaryFileOrDie(const char* param_file,
- caffe::NetParameter* param);
-
-}
-}
-#endif
-#endif
diff --git a/contrib/modules/dnn/src/caffe/glog_emulator.hpp b/contrib/modules/dnn/src/caffe/glog_emulator.hpp
deleted file mode 100644
index 5f674e4..0000000
--- a/contrib/modules/dnn/src/caffe/glog_emulator.hpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_CAFFE_GLOG_EMULATOR_HPP__
-#define __OPENCV_DNN_CAFFE_GLOG_EMULATOR_HPP__
-#include <cstdlib>
-#include <iostream>
-#include <sstream>
-#include <opencv2/core.hpp>
-
-#define CHECK(cond) for(cv::dnn::GLogWrapper _logger(__FILE__, CV_Func, __LINE__, "CHECK", #cond, cond); _logger.exit(); _logger.check()) _logger.stream()
-#define CHECK_EQ(a, b) for(cv::dnn::GLogWrapper _logger(__FILE__, CV_Func, __LINE__, "CHECK", #a"="#b, ((a) == (b))); _logger.exit(); _logger.check()) _logger.stream()
-#define LOG(TYPE) for(cv::dnn::GLogWrapper _logger(__FILE__, CV_Func, __LINE__, #TYPE); _logger.exit(); _logger.check()) _logger.stream()
-
-namespace cv
-{
-namespace dnn
-{
-
-class GLogWrapper
-{
- const char *file, *func, *type, *cond_str;
- int line;
- bool cond_staus, exit_loop;
- std::stringstream sstream;
-
-public:
-
- GLogWrapper(const char *_file, const char *_func, int _line,
- const char *_type,
- const char *_cond_str = NULL, bool _cond_status = true
- ) :
- file(_file), func(_func), type(_type), cond_str(_cond_str),
- line(_line), cond_staus(_cond_status), exit_loop(true) {}
-
- std::iostream &stream()
- {
- return sstream;
- }
-
- bool exit()
- {
- return exit_loop;
- }
-
- void check()
- {
- exit_loop = false;
-
- if (cond_str && !cond_staus)
- {
- cv::error(cv::Error::StsError, "FAILED: " + String(cond_str) + ". " + sstream.str(), func, file, line);
- }
- else if (!cond_str && strcmp(type, "CHECK"))
- {
- if (!std::strcmp(type, "INFO"))
- std::cout << sstream.str() << std::endl;
- else
- std::cerr << sstream.str() << std::endl;
- }
- }
-};
-
-}
-}
-#endif
diff --git a/contrib/modules/dnn/src/caffe/layer_loaders.cpp b/contrib/modules/dnn/src/caffe/layer_loaders.cpp
deleted file mode 100644
index 40a7e56..0000000
--- a/contrib/modules/dnn/src/caffe/layer_loaders.cpp
+++ /dev/null
@@ -1,304 +0,0 @@
-#include "../precomp.hpp"
-#include "layer_loaders.hpp"
-#include <opencv2/dnn/shape_utils.hpp>
-#include <climits>
-#include "layers/layers_common.hpp"
-
-namespace cv
-{
-namespace dnn
-{
-
-//Layers
-
-//Convolution and Deconvolution
-static void initConvDeconvLayerFromCaffe(Ptr<BaseConvolutionLayer> l, LayerParams ¶ms)
-{
- l->setParamsFrom(params);
- getConvolutionKernelParams(params, l->kernel.height, l->kernel.width, l->pad.height,
- l->pad.width, l->stride.height, l->stride.width, l->dilation.height,
- l->dilation.width, l->padMode);
-
- bool bias = params.get<bool>("bias_term", true);
- int numOutput = params.get<int>("num_output");
- int group = params.get<int>("group", 1);
-
- CV_Assert(numOutput % group == 0);
- CV_Assert((bias && l->blobs.size() == 2) || (!bias && l->blobs.size() == 1));
-}
-
-template<>
-Ptr<Layer> createLayerFromCaffe<ConvolutionLayer>(LayerParams ¶ms)
-{
- Ptr<BaseConvolutionLayer> l = ConvolutionLayer::create();
- initConvDeconvLayerFromCaffe(l, params);
- return Ptr<Layer>(l);
-}
-
-template<>
-Ptr<Layer> createLayerFromCaffe<DeconvolutionLayer>(LayerParams ¶ms)
-{
- Ptr<BaseConvolutionLayer> l = DeconvolutionLayer::create();
- initConvDeconvLayerFromCaffe(l, params);
- return Ptr<Layer>(l);
-}
-
-template<>
-Ptr<Layer> createLayerFromCaffe<PoolingLayer>(LayerParams ¶ms)
-{
- int type = PoolingLayer::MAX;
- Size kernel, stride, pad;
- bool globalPooling;
- cv::String padMode;
-
- if (params.has("pool"))
- {
- String pool = params.get<String>("pool").toLowerCase();
- if (pool == "max")
- type = PoolingLayer::MAX;
- else if (pool == "ave")
- type = PoolingLayer::AVE;
- else if (pool == "stochastic")
- type = PoolingLayer::STOCHASTIC;
- else
- CV_Error(Error::StsBadArg, "Unknown pooling type \"" + pool + "\"");
- }
-
- getPoolingKernelParams(params, kernel.height, kernel.width, globalPooling,
- pad.height, pad.width, stride.height, stride.width, padMode);
- //getCaffeConvParams(params, kernel, pad, stride);
-
- if (!globalPooling)
- return Ptr<Layer>(PoolingLayer::create(type, kernel, stride, pad, padMode));
- else
- return Ptr<Layer>(PoolingLayer::createGlobal(type));
-}
-
-template<>
-Ptr<Layer> createLayerFromCaffe<SoftmaxLayer>(LayerParams ¶ms)
-{
- int axis = params.get<int>("axis", 1);
- return Ptr<Layer>(SoftmaxLayer::create(axis));
-}
-
-template<> //InnerProduct specialization
-Ptr<Layer> createLayerFromCaffe<InnerProductLayer>(LayerParams ¶ms)
-{
- const std::vector<Blob> &blobs = params.blobs;
- CV_Assert(1 <= blobs.size() && blobs.size() <= 2);
-
- int numOutputs = params.get<int>("num_output");
- int innerSize = (int)blobs[0].total() / numOutputs;
- bool bias = params.get<bool>("bias_term", true);
- int axis = params.get<int>("axis", 1);
-
- CV_Assert(blobs[0].dims() >= 2 && (size_t)(innerSize * numOutputs) == blobs[0].total());
- CV_Assert(!bias || (blobs.size() == 2 && (size_t)numOutputs == blobs[1].total()));
-
- Ptr<InnerProductLayer> l = InnerProductLayer::create(axis);
- l->setParamsFrom(params);
- l->blobs[0].reshape(Shape(numOutputs, innerSize));
- if (bias)
- l->blobs[1].reshape(Shape(1, numOutputs));
-
- return Ptr<Layer>(l);
-}
-
-template<> //LRNLayer specialization
-Ptr<Layer> createLayerFromCaffe<LRNLayer>(LayerParams& params)
-{
- int type = -1;
- String nrmType = params.get<String>("norm_region", "ACROSS_CHANNELS");
- if (nrmType == "ACROSS_CHANNELS")
- type = LRNLayer::CHANNEL_NRM;
- else if (nrmType == "WITHIN_CHANNEL")
- type = LRNLayer::SPATIAL_NRM;
- else
- CV_Error(Error::StsBadArg, "Unknown region type \"" + nrmType + "\"");
-
- int size = params.get<int>("local_size", 5);
- if (size % 2 != 1 || size <= 0)
- CV_Error(Error::StsBadArg, "LRN layer supports only positive odd values for local_size");
-
- double alpha = params.get<double>("alpha", 1);
- double beta = params.get<double>("beta", 0.75);
- double bias = params.get<double>("bias", 1);
- bool normBySize = params.get<bool>("norm_by_size", true);
-
- return Ptr<Layer>(LRNLayer::create(type, size, alpha, beta, bias, normBySize));
-}
-
-template<>
-Ptr<Layer> createLayerFromCaffe<MVNLayer>(LayerParams ¶ms)
-{
- return Ptr<Layer>(MVNLayer::create(
- params.get<bool>("normalize_variance", true),
- params.get<bool>("across_channels", false),
- params.get<double>("eps", 1e-9)
- ));
-}
-
-/* Reshape layers */
-
-template<>
-Ptr<Layer> createLayerFromCaffe<ReshapeLayer>(LayerParams ¶ms)
-{
- int axis = params.get<int>("axis", 0);
- int numAxes = params.get<int>("num_axes", -1);
- bool enableReordering = params.get<bool>("reorder_dims", false);
- CV_Assert(numAxes >= -1);
- Range applyingRange = (numAxes == -1) ? Range(axis, INT_MAX) : Range(axis, axis + numAxes);
-
- Shape newShape;
- if (params.has("dim"))
- {
- const DictValue ¶mShape = params.get("dim");
- newShape = Shape::all(paramShape.size());
- for (int i = 0; i < paramShape.size(); i++)
- newShape[i] = paramShape.get<int>(i);
- }
- else
- newShape = Shape::all(0);
-
- return Ptr<Layer>(ReshapeLayer::create(newShape, applyingRange, enableReordering));
-}
-
-template<>
-Ptr<Layer> createLayerFromCaffe<ConcatLayer>(LayerParams& params)
-{
- return Ptr<Layer>(ConcatLayer::create(params.get<int>("axis", 1)));
-}
-
-template<>
-Ptr<Layer> createLayerFromCaffe<SplitLayer>(LayerParams ¶ms)
-{
- int outputsCount;
-
- //TODO: maybe "top_count" param is useless because it can be determined by output connections number
- if (params.has("top_count"))
- {
- outputsCount = params.get<int>("top_count");
- CV_Assert(outputsCount >= 0);
- }
- else
- {
- outputsCount = -1;
- }
-
- return Ptr<Layer>(SplitLayer::create(outputsCount));
-}
-
-template<>
-Ptr<Layer> createLayerFromCaffe<SliceLayer>(LayerParams& params)
-{
- int axis = params.get<int>("axis", 1);
-
- if (!params.has("slice_point"))
- {
- return Ptr<Layer>(SliceLayer::create(axis));
- }
- else
- {
- const DictValue &indicesValue = params.get("slice_point");
- std::vector<int> sliceIndices(indicesValue.size());
- for (int i = 0; i < indicesValue.size(); i++)
- sliceIndices[i] = indicesValue.get<int>(i);
-
- return Ptr<Layer>(SliceLayer::create(axis, sliceIndices));
- }
-}
-
-/* Activation layers */
-
-template <typename ActivationLayer> //Intended for parameters-free activations
-Ptr<Layer> createLayerFromCaffe(LayerParams&)
-{
- return Ptr<Layer>(ActivationLayer::create());
-}
-
-template<> //ReLU specialization
-Ptr<Layer> createLayerFromCaffe<ReLULayer>(LayerParams& params)
-{
- float negative_slope = params.get<float>("negative_slope", 0.f);
- return Ptr<Layer>(ReLULayer::create(negative_slope));
-}
-
-template<> //Power specialization
-Ptr<Layer> createLayerFromCaffe<PowerLayer>(LayerParams& params)
-{
- float power = params.get<float>("power", 1.0f);
- float scale = params.get<float>("scale", 1.0f);
- float shift = params.get<float>("shift", 0.0f);
- return Ptr<Layer>(PowerLayer::create(power, scale, shift));
-}
-
-template<> //CropLayer specialization
-Ptr<Layer> createLayerFromCaffe<CropLayer>(LayerParams& params)
-{
- int start_axis = params.get<int>("axis", 2);
- DictValue *paramOffset = params.ptr("offset");
-
- std::vector<int> offset;
- if (paramOffset)
- {
- for (int i = 0; i < paramOffset->size(); i++)
- offset.push_back(paramOffset->get<int>(i));
- }
-
- return Ptr<Layer>(CropLayer::create(start_axis, offset));
-}
-
-template<> //Power specialization
-Ptr<Layer> createLayerFromCaffe<EltwiseLayer>(LayerParams& params)
-{
- EltwiseLayer::EltwiseOp op = EltwiseLayer::SUM;
- if (params.has("operation"))
- {
- String operation = params.get<String>("operation").toLowerCase();
- if (operation == "prod")
- op = EltwiseLayer::PROD;
- else if (operation == "sum")
- op = EltwiseLayer::SUM;
- else if (operation == "max")
- op = EltwiseLayer::MAX;
- else
- CV_Error(cv::Error::StsBadArg, "Unknown operaticon type \"" + operation + "\"");
- }
-
- std::vector<int> coeffs;
- if (params.has("coeff"))
- {
- DictValue paramCoeff = params.get("coeff");
- coeffs.resize(paramCoeff.size(), 1);
- for (int i = 0; i < paramCoeff.size(); i++)
- {
- coeffs[i] = paramCoeff.get<int>(i);
- }
- }
- return Ptr<Layer>(EltwiseLayer::create(op, coeffs));
-}
-
-//Explicit instantiation
-template Ptr<Layer> createLayerFromCaffe<ConvolutionLayer>(LayerParams&);
-template Ptr<Layer> createLayerFromCaffe<DeconvolutionLayer>(LayerParams&);
-template Ptr<Layer> createLayerFromCaffe<SoftmaxLayer>(LayerParams&);
-template Ptr<Layer> createLayerFromCaffe<InnerProductLayer>(LayerParams&);
-template Ptr<Layer> createLayerFromCaffe<LRNLayer>(LayerParams&);
-template Ptr<Layer> createLayerFromCaffe<MVNLayer>(LayerParams&);
-
-template Ptr<Layer> createLayerFromCaffe<ConcatLayer>(LayerParams&);
-template Ptr<Layer> createLayerFromCaffe<SliceLayer>(LayerParams&);
-template Ptr<Layer> createLayerFromCaffe<SplitLayer>(LayerParams&);
-
-template Ptr<Layer> createLayerFromCaffe<ReLULayer>(LayerParams&);
-template Ptr<Layer> createLayerFromCaffe<SigmoidLayer>(LayerParams&);
-template Ptr<Layer> createLayerFromCaffe<TanHLayer>(LayerParams&);
-template Ptr<Layer> createLayerFromCaffe<AbsLayer>(LayerParams&);
-template Ptr<Layer> createLayerFromCaffe<BNLLLayer>(LayerParams&);
-template Ptr<Layer> createLayerFromCaffe<PowerLayer>(LayerParams&);
-
-template Ptr<Layer> createLayerFromCaffe<CropLayer>(LayerParams&);
-template Ptr<Layer> createLayerFromCaffe<EltwiseLayer>(LayerParams&);
-
-}
-}
diff --git a/contrib/modules/dnn/src/caffe/layer_loaders.hpp b/contrib/modules/dnn/src/caffe/layer_loaders.hpp
deleted file mode 100644
index 617691c..0000000
--- a/contrib/modules/dnn/src/caffe/layer_loaders.hpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_CAFFE_LAYER_LOADERS_HPP__
-#define __OPENCV_DNN_CAFFE_LAYER_LOADERS_HPP__
-
-#include <opencv2/dnn/all_layers.hpp>
-
-namespace cv
-{
-namespace dnn
-{
-
-//Common template for Caffe layer loaders
-template <typename PublicLayer>
-Ptr<Layer> createLayerFromCaffe(LayerParams&);
-
-Ptr<Layer> createFlattenLayerFromCaffe(LayerParams&);
-
-}
-}
-#endif
\ No newline at end of file
diff --git a/contrib/modules/dnn/src/dnn.cpp b/contrib/modules/dnn/src/dnn.cpp
deleted file mode 100644
index 5c00927..0000000
--- a/contrib/modules/dnn/src/dnn.cpp
+++ /dev/null
@@ -1,711 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-#include <set>
-#include <algorithm>
-#include <iostream>
-#include <sstream>
-#include <iterator>
-
-using namespace cv;
-using namespace cv::dnn;
-
-using std::vector;
-using std::map;
-using std::make_pair;
-using std::set;
-
-namespace cv
-{
-namespace dnn
-{
-
-template<typename T>
-static String toString(const T &v)
-{
- std::ostringstream ss;
- ss << v;
- return ss.str();
-}
-
-struct LayerPin
-{
- int lid;
- int oid;
-
- LayerPin(int layerId = -1, int outputId = -1)
- : lid(layerId), oid(outputId) {}
-
- bool valid() const
- {
- return (lid >= 0 && oid >= 0);
- }
-
- bool equal(const LayerPin &r) const
- {
- return (lid == r.lid && oid == r.oid);
- }
-};
-
-struct LayerData
-{
- LayerData() {}
- LayerData(int _id, const String &_name, const String &_type, LayerParams &_params)
- : id(_id), name(_name), type(_type), params(_params)
- {
- //add logging info
- params.name = name;
- params.type = type;
- }
-
- int id;
- String name;
- String type;
- LayerParams params;
-
- std::vector<LayerPin> inputBlobsId;
- std::set<int> inputLayersId;
- std::set<int> requiredOutputs;
-
- Ptr<Layer> layerInstance;
- std::vector<Blob> outputBlobs;
- std::vector<Blob*> inputBlobs;
-
- int flag;
-
- Ptr<Layer> getLayerInstance()
- {
- if (layerInstance)
- return layerInstance;
-
- layerInstance = LayerFactory::createLayerInstance(type, params);
- if (!layerInstance)
- {
- CV_Error(Error::StsError, "Can't create layer \"" + name + "\" of type \"" + type + "\"");
- }
-
- return layerInstance;
- }
-};
-
-//fake layer containing network input blobs
-struct DataLayer : public Layer
-{
- void allocate(const std::vector<Blob*>&, std::vector<Blob>&) {}
- void forward(std::vector<Blob*>&, std::vector<Blob>&) {}
-
- int outputNameToIndex(String tgtName)
- {
- int idx = (int)(std::find(outNames.begin(), outNames.end(), tgtName) - outNames.begin());
- return (idx < (int)outNames.size()) ? idx : -1;
- }
-
- void setNames(const std::vector<String> &names)
- {
- outNames.assign(names.begin(), names.end());
- }
-
-private:
- std::vector<String> outNames;
-};
-
-struct Net::Impl
-{
- Impl()
- {
- //allocate fake net input layer
- netInputLayer = Ptr<DataLayer>(new DataLayer());
- LayerData &inpl = layers.insert( make_pair(0, LayerData()) ).first->second;
- inpl.id = 0;
- inpl.name = "_input";
- inpl.type = "__NetInputLayer__";
- inpl.layerInstance = netInputLayer;
- layerNameToId.insert(std::make_pair(inpl.name, inpl.id));
-
- lastLayerId = 1;
- netWasAllocated = false;
- }
-
- Ptr<DataLayer> netInputLayer;
- std::vector<int> netOutputs;
-
- typedef std::map<int, LayerData> MapIdToLayerData;
- std::map<int, LayerData> layers;
- std::map<String, int> layerNameToId;
-
- int lastLayerId;
-
- bool netWasAllocated;
-
- void setUpNet()
- {
- if (!netWasAllocated)
- {
- allocateLayers();
- computeNetOutputLayers();
-
- netWasAllocated = true;
- }
- }
-
- int getLayerId(const String &layerName)
- {
- std::map<String, int>::iterator it = layerNameToId.find(layerName);
- return (it != layerNameToId.end()) ? it->second : -1;
- }
-
- int getLayerId(int id)
- {
- MapIdToLayerData::iterator it = layers.find(id);
- return (it != layers.end()) ? id : -1;
- }
-
- int getLayerId(DictValue &layerDesc)
- {
- if (layerDesc.isInt())
- return getLayerId(layerDesc.get<int>());
- else if (layerDesc.isString())
- return getLayerId(layerDesc.get<String>());
-
- CV_Assert(layerDesc.isInt() || layerDesc.isString());
- return -1;
- }
-
- String getLayerName(int id)
- {
- MapIdToLayerData::iterator it = layers.find(id);
- return (it != layers.end()) ? it->second.name : "(unknown layer)";
- }
-
- LayerData& getLayerData(int id)
- {
- MapIdToLayerData::iterator it = layers.find(id);
-
- if (it == layers.end())
- CV_Error(Error::StsObjectNotFound, format("Layer with requested id=%d not found", id));
-
- return it->second;
- }
-
- LayerData& getLayerData(const String &layerName)
- {
- int id = getLayerId(layerName);
-
- if (id < 0)
- CV_Error(Error::StsError, "Requsted layer \"" + layerName + "\" not found");
-
- return getLayerData(id);
- }
-
- LayerData& getLayerData(const DictValue &layerDesc)
- {
- if (layerDesc.isInt())
- return getLayerData(layerDesc.get<int>());
- else if (layerDesc.isString())
- return getLayerData(layerDesc.get<String>());
-
- CV_Assert(layerDesc.isInt() || layerDesc.isString());
- return *((LayerData*)NULL);
- }
-
- static void addLayerInput(LayerData &ld, int inNum, LayerPin from)
- {
- if ((int)ld.inputBlobsId.size() <= inNum)
- {
- ld.inputBlobsId.resize(inNum + 1);
- }
- else
- {
- LayerPin storedFrom = ld.inputBlobsId[inNum];
- if (storedFrom.valid() && !storedFrom.equal(from))
- CV_Error(Error::StsError, "Input #" + toString(inNum) + "of layer \"" + ld.name + "\" already was connected");
- }
-
- ld.inputBlobsId[inNum] = from;
- }
-
- static void splitPin(const String &pinAlias, String &layerName, String &outName)
- {
- size_t delimPos = pinAlias.find('.');
- layerName = pinAlias.substr(0, delimPos);
- outName = (delimPos == String::npos) ? String() : pinAlias.substr(delimPos + 1);
- }
-
- int resolvePinOutputName(LayerData &ld, const String &outName, bool isOutPin)
- {
- if (outName.empty())
- return 0;
-
- if (std::isdigit(outName[0]))
- {
- char *lastChar;
- long inum = std::strtol(outName.c_str(), &lastChar, 10);
-
- if (*lastChar == 0)
- {
- CV_Assert(inum == (int)inum);
- return (int)inum;
- }
- }
-
- if (isOutPin)
- return ld.getLayerInstance()->outputNameToIndex(outName);
- else
- return ld.getLayerInstance()->inputNameToIndex(outName);
- }
-
- LayerPin getPinByAlias(const String &pinAlias, bool isOutPin = true)
- {
- LayerPin pin;
- String layerName, outName;
- splitPin(pinAlias, layerName, outName);
-
- pin.lid = (layerName.empty()) ? 0 : getLayerId(layerName);
-
- if (pin.lid >= 0)
- pin.oid = resolvePinOutputName(getLayerData(pin.lid), outName, isOutPin);
-
- return pin;
- }
-
- void connect(int outLayerId, int outNum, int inLayerId, int inNum)
- {
- LayerData &ldOut = getLayerData(outLayerId);
- LayerData &ldInp = getLayerData(inLayerId);
-
- addLayerInput(ldInp, inNum, LayerPin(outLayerId, outNum));
- ldOut.requiredOutputs.insert(outNum);
- }
-
- void computeNetOutputLayers()
- {
- netOutputs.clear();
-
- MapIdToLayerData::iterator it;
- for (it = layers.begin(); it != layers.end(); it++)
- {
- int lid = it->first;
- LayerData &ld = it->second;
-
- if (ld.requiredOutputs.size() == 0)
- netOutputs.push_back(lid);
- }
-
- #ifndef NDEBUG
- std::cout << "\nNet Outputs(" << netOutputs.size() << "):\n";
- for (size_t i = 0; i < netOutputs.size(); i++)
- std::cout << layers[netOutputs[i]].name << "\n";
- #endif
- }
-
- #define CV_RETHROW_ERROR(err, newmsg)\
- cv::error(err.code, newmsg, err.func.c_str(), err.file.c_str(), err.line)
-
- void allocateLayer(int lid)
- {
- LayerData &ld = layers[lid];
-
- //already allocated
- if (ld.flag)
- return;
-
- //determine parent layers
- for (size_t i = 0; i < ld.inputBlobsId.size(); i++)
- ld.inputLayersId.insert(ld.inputBlobsId[i].lid);
-
- //allocate parents
- for (set<int>::iterator i = ld.inputLayersId.begin(); i != ld.inputLayersId.end(); i++)
- allocateLayer(*i);
-
- //bind inputs
- ld.inputBlobs.resize(ld.inputBlobsId.size());
- for (size_t i = 0; i < ld.inputBlobsId.size(); i++)
- {
- LayerPin from = ld.inputBlobsId[i];
- CV_Assert(from.valid());
- CV_DbgAssert(layers.count(from.lid) && (int)layers[from.lid].outputBlobs.size() > from.oid);
- ld.inputBlobs[i] = &layers[from.lid].outputBlobs[from.oid];
- }
-
- //allocate layer
- ld.outputBlobs.resize(std::max((size_t)1, ld.requiredOutputs.size())); //layer produce at least one output blob
- try
- {
- Ptr<Layer> layerPtr = ld.getLayerInstance();
- layerPtr->allocate(ld.inputBlobs, ld.outputBlobs);
- }
- catch (const cv::Exception &err)
- {
- CV_RETHROW_ERROR(err, format("The following error occured while making allocate() for layer \"%s\": %s", ld.name.c_str(), err.err.c_str()));
- }
-
- ld.flag = 1;
- }
-
- void allocateLayers()
- {
- MapIdToLayerData::iterator it;
- for (it = layers.begin(); it != layers.end(); it++)
- it->second.flag = 0;
-
- for (it = layers.begin(); it != layers.end(); it++)
- {
- int lid = it->first;
- allocateLayer(lid);
- }
- }
-
- void forwardLayer(LayerData &ld, bool clearFlags = true)
- {
- if (clearFlags)
- {
- MapIdToLayerData::iterator it;
- for (it = layers.begin(); it != layers.end(); it++)
- it->second.flag = 0;
- }
-
- //already was forwarded
- if (ld.flag)
- return;
-
- //forward parents
- for (set<int>::iterator i = ld.inputLayersId.begin(); i != ld.inputLayersId.end(); i++)
- {
- forwardLayer(layers[*i], false);
- }
-
- //forward itself
- try
- {
- ld.layerInstance->forward(ld.inputBlobs, ld.outputBlobs);
- }
- catch (const cv::Exception &err)
- {
- CV_RETHROW_ERROR(err, format("The following error occured while making forward() for layer \"%s\": %s", ld.name.c_str(), err.err.c_str()));
- }
-
- ld.flag = 1;
- }
-
- void forwardAll()
- {
- MapIdToLayerData::iterator it;
- for (it = layers.begin(); it != layers.end(); it++)
- it->second.flag = 0;
-
- for (it = layers.begin(); it != layers.end(); it++)
- forwardLayer(it->second, false);
- }
-};
-
-Net::Net() : impl(new Net::Impl)
-{
-}
-
-Net::~Net()
-{
-}
-
-int Net::addLayer(const String &name, const String &type, LayerParams ¶ms)
-{
- if (name.find('.') != String::npos)
- {
- CV_Error(Error::StsBadArg, "Added layer name \"" + name + "\" must not contain dot symbol");
- return -1;
- }
-
- if (impl->getLayerId(name) >= 0)
- {
- CV_Error(Error::StsBadArg, "Layer \"" + name + "\" already into net");
- return -1;
- }
-
- int id = ++impl->lastLayerId;
- impl->layerNameToId.insert(std::make_pair(name, id));
- impl->layers.insert(std::make_pair(id, LayerData(id, name, type, params)));
-
- return id;
-}
-
-int Net::addLayerToPrev(const String &name, const String &type, LayerParams ¶ms)
-{
- int prvLid = impl->lastLayerId;
- int newLid = this->addLayer(name, type, params);
- this->connect(prvLid, 0, newLid, 0);
- return newLid;
-}
-
-void Net::connect(int outLayerId, int outNum, int inpLayerId, int inpNum)
-{
- impl->connect(outLayerId, outNum, inpLayerId, inpNum);
-}
-
-void Net::connect(String _outPin, String _inPin)
-{
- LayerPin outPin = impl->getPinByAlias(_outPin);
- LayerPin inpPin = impl->getPinByAlias(_inPin);
-
- CV_Assert(outPin.valid() && inpPin.valid());
-
- impl->connect(outPin.lid, outPin.oid, inpPin.lid, inpPin.oid);
-}
-
-void Net::allocate()
-{
- impl->setUpNet();
-}
-
-void Net::forward(LayerId toLayer)
-{
- impl->setUpNet();
-
- if (toLayer.isString() && toLayer.get<String>().empty())
- impl->forwardAll();
- else
- impl->forwardLayer(impl->getLayerData(toLayer));
-}
-
-void Net::setNetInputs(const std::vector<String> &inputBlobNames)
-{
- impl->netInputLayer->setNames(inputBlobNames);
-}
-
-void Net::setBlob(String outputName, const Blob &blob)
-{
- LayerPin pin = impl->getPinByAlias(outputName);
- if (!pin.valid())
- CV_Error(Error::StsObjectNotFound, "Requested blob \"" + outputName + "\" not found");
-
- LayerData &ld = impl->layers[pin.lid];
- ld.outputBlobs.resize( std::max(pin.oid+1, (int)ld.requiredOutputs.size()) );
- ld.outputBlobs[pin.oid] = blob;
-}
-
-Blob Net::getBlob(String outputName)
-{
- LayerPin pin = impl->getPinByAlias(outputName);
- if (!pin.valid())
- CV_Error(Error::StsObjectNotFound, "Requested blob \"" + outputName + "\" not found");
-
- LayerData &ld = impl->layers[pin.lid];
- if ((size_t)pin.oid >= ld.outputBlobs.size())
- {
- CV_Error(Error::StsOutOfRange, "Layer \"" + ld.name + "\" produce only " + toString(ld.outputBlobs.size()) +
- " outputs, the #" + toString(pin.oid) + " was requsted");
- }
- return ld.outputBlobs[pin.oid];
-}
-
-Blob Net::getParam(LayerId layer, int numParam)
-{
- LayerData &ld = impl->getLayerData(layer);
-
- std::vector<Blob> &layerBlobs = ld.layerInstance->blobs;
- CV_Assert(numParam < (int)layerBlobs.size());
- return layerBlobs[numParam];
-}
-
-void Net::setParam(LayerId layer, int numParam, const Blob &blob)
-{
- LayerData &ld = impl->getLayerData(layer);
-
- std::vector<Blob> &layerBlobs = ld.layerInstance->blobs;
- CV_Assert(numParam < (int)layerBlobs.size());
- //we don't make strong checks, use this function carefully
- layerBlobs[numParam] = blob;
-}
-
-int Net::getLayerId(const String &layer)
-{
- return impl->getLayerId(layer);
-}
-
-void Net::deleteLayer(LayerId)
-{
- CV_Error(Error::StsNotImplemented, "");
-}
-
-Ptr<Layer> Net::getLayer(LayerId layerId)
-{
- LayerData &ld = impl->getLayerData(layerId);
- if (!ld.layerInstance)
- CV_Error(Error::StsNullPtr, format("Requseted layer \"%s\" was not initialized", ld.name.c_str()));
- return ld.layerInstance;
-}
-
-std::vector<String> Net::getLayerNames() const
-{
- std::vector<String> res;
- res.reserve(impl->layers.size());
-
- Impl::MapIdToLayerData::iterator it;
- for (it = impl->layers.begin(); it != impl->layers.end(); it++)
- {
- if (it->second.id) //skip Data layer
- res.push_back(it->second.name);
- }
-
- return res;
-}
-
-bool Net::empty() const
-{
- return impl->layers.size() <= 1; //first layer is default Data layer
-}
-
-//////////////////////////////////////////////////////////////////////////
-
-Importer::~Importer() {}
-
-Layer::Layer() {}
-
-Layer::Layer(const LayerParams ¶ms)
- : blobs(params.blobs), name(params.name), type(params.type)
-{
-
-}
-
-void Layer::setParamsFrom(const LayerParams ¶ms)
-{
- blobs = params.blobs;
- name = params.name;
- type = params.type;
-}
-
-int Layer::inputNameToIndex(String)
-{
- return -1;
-}
-
-int Layer::outputNameToIndex(String)
-{
- return -1;
-}
-
-template <typename T>
-static void vecToPVec(const std::vector<T> &v, std::vector<T*> &pv)
-{
- pv.resize(v.size());
- for (size_t i = 0; i < v.size(); i++)
- pv[i] = const_cast<T*>(&v[i]);
-}
-
-void Layer::allocate(const std::vector<Blob> &inputs, std::vector<Blob> &outputs)
-{
- std::vector<Blob*> inputsp;
- vecToPVec(inputs, inputsp);
- this->allocate(inputsp, outputs);
-}
-
-std::vector<Blob> Layer::allocate(const std::vector<Blob> &inputs)
-{
- std::vector<Blob> outputs;
- this->allocate(inputs, outputs);
- return outputs;
-}
-
-void Layer::forward(const std::vector<Blob> &inputs, std::vector<Blob> &outputs)
-{
- std::vector<Blob*> inputsp;
- vecToPVec(inputs, inputsp);
- this->forward(inputsp, outputs);
-}
-
-void Layer::run(const std::vector<Blob> &inputs, std::vector<Blob> &outputs)
-{
- std::vector<Blob*> inputsp;
- vecToPVec(inputs, inputsp);
- this->allocate(inputsp, outputs);
- this->forward(inputsp, outputs);
-}
-
-Layer::~Layer() {}
-
-//////////////////////////////////////////////////////////////////////////
-
-struct LayerFactory::Impl : public std::map<String, LayerFactory::Constuctor>
-{
-};
-
-Ptr<LayerFactory::Impl> LayerFactory::impl ()
-{
- // allocate on first use
- static Ptr<LayerFactory::Impl> impl_(new LayerFactory::Impl());
- return impl_;
-}
-
-void LayerFactory::registerLayer(const String &_type, Constuctor constructor)
-{
- String type = _type.toLowerCase();
- Impl::iterator it = impl()->find(type);
-
- if (it != impl()->end() && it->second != constructor)
- {
- CV_Error(cv::Error::StsBadArg, "Layer \"" + type + "\" already was registered");
- }
-
- impl()->insert(std::make_pair(type, constructor));
-}
-
-void LayerFactory::unregisterLayer(const String &_type)
-{
- String type = _type.toLowerCase();
- impl()->erase(type);
-}
-
-Ptr<Layer> LayerFactory::createLayerInstance(const String &_type, LayerParams& params)
-{
- String type = _type.toLowerCase();
- Impl::const_iterator it = LayerFactory::impl()->find(type);
-
- if (it != impl()->end())
- {
- return it->second(params);
- }
- else
- {
- return Ptr<Layer>(); //NULL
- }
-}
-
-}
-}
diff --git a/contrib/modules/dnn/src/init.cpp b/contrib/modules/dnn/src/init.cpp
deleted file mode 100644
index 5b675bd..0000000
--- a/contrib/modules/dnn/src/init.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-#include "caffe/layer_loaders.hpp"
-#include "layers/blank_layer.hpp"
-
-#include "layers/crop_layer.hpp"
-#include "layers/eltwise_layer.hpp"
-#include "layers/flatten_layer.hpp"
-#include "layers/permute_layer.hpp"
-#include "layers/prior_box_layer.hpp"
-#include "layers/detection_output_layer.hpp"
-#include "layers/normalize_bbox_layer.hpp"
-#include "layers/shift_layer.hpp"
-
-namespace cv
-{
-namespace dnn
-{
-
-struct AutoInitializer
-{
- bool status;
-
- AutoInitializer() : status(false)
- {
- cv::dnn::initModule();
- }
-};
-
-static AutoInitializer init;
-
-void initModule()
-{
- if (init.status)
- return;
-
- REG_RUNTIME_LAYER_FUNC(Slice, createLayerFromCaffe<SliceLayer>);
- REG_RUNTIME_LAYER_FUNC(Split, createLayerFromCaffe<SplitLayer>);
- REG_RUNTIME_LAYER_FUNC(Concat, createLayerFromCaffe<ConcatLayer>);
- REG_RUNTIME_LAYER_FUNC(Reshape, createLayerFromCaffe<ReshapeLayer>);
- REG_RUNTIME_LAYER_CLASS(Flatten, FlattenLayer);
-
- REG_RUNTIME_LAYER_FUNC(Convolution, createLayerFromCaffe<ConvolutionLayer>);
- REG_RUNTIME_LAYER_FUNC(Deconvolution, createLayerFromCaffe<DeconvolutionLayer>);
- REG_RUNTIME_LAYER_FUNC(Pooling, createLayerFromCaffe<PoolingLayer>);
- REG_RUNTIME_LAYER_FUNC(LRN, createLayerFromCaffe<LRNLayer>);
- REG_RUNTIME_LAYER_FUNC(InnerProduct, createLayerFromCaffe<InnerProductLayer>);
- REG_RUNTIME_LAYER_FUNC(Softmax, createLayerFromCaffe<SoftmaxLayer>);
- REG_RUNTIME_LAYER_FUNC(MVN, createLayerFromCaffe<MVNLayer>);
-
- REG_RUNTIME_LAYER_FUNC(ReLU, createLayerFromCaffe<ReLULayer>);
- REG_RUNTIME_LAYER_FUNC(Sigmoid, createLayerFromCaffe<SigmoidLayer>);
- REG_RUNTIME_LAYER_FUNC(TanH, createLayerFromCaffe<TanHLayer>);
- REG_RUNTIME_LAYER_FUNC(BNLL, createLayerFromCaffe<BNLLLayer>);
- REG_RUNTIME_LAYER_FUNC(AbsVal, createLayerFromCaffe<AbsLayer>);
- REG_RUNTIME_LAYER_FUNC(Power, createLayerFromCaffe<PowerLayer>);
- REG_RUNTIME_LAYER_CLASS(Dropout, BlankLayer);
- REG_RUNTIME_LAYER_CLASS(Identity, BlankLayer);
-
- REG_RUNTIME_LAYER_FUNC(Crop, createLayerFromCaffe<CropLayer>);
- REG_RUNTIME_LAYER_FUNC(Eltwise, createLayerFromCaffe<EltwiseLayer>);
- REG_RUNTIME_LAYER_CLASS(Permute, PermuteLayer);
- REG_RUNTIME_LAYER_CLASS(PriorBox, PriorBoxLayer);
- REG_RUNTIME_LAYER_CLASS(DetectionOutput, DetectionOutputLayer);
- REG_RUNTIME_LAYER_CLASS(NormalizeBBox, NormalizeBBoxLayer);
- REG_RUNTIME_LAYER_CLASS(Shift, ShiftLayer);
-
- init.status = true;
-}
-
-}
-}
diff --git a/contrib/modules/dnn/src/layers/blank_layer.hpp b/contrib/modules/dnn/src/layers/blank_layer.hpp
deleted file mode 100644
index 6d93f27..0000000
--- a/contrib/modules/dnn/src/layers/blank_layer.hpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_LAYERS_BLANK_LAYER_HPP__
-#define __OPENCV_DNN_LAYERS_BLANK_LAYER_HPP__
-#include "../precomp.hpp"
-
-namespace cv
-{
-namespace dnn
-{
- class BlankLayer : public Layer
- {
- public:
-
- BlankLayer(LayerParams&)
- {
-
- }
-
- void allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
- {
- outputs.resize(inputs.size());
- for (size_t i = 0; i < inputs.size(); i++)
- outputs[i].shareFrom(*inputs[i]);
- }
-
- void forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
- {
- for (size_t i = 0; i < inputs.size(); i++)
- outputs[i] = *inputs[i];
- }
- };
-}
-}
-#endif
diff --git a/contrib/modules/dnn/src/layers/concat_layer.cpp b/contrib/modules/dnn/src/layers/concat_layer.cpp
deleted file mode 100644
index 61341fe..0000000
--- a/contrib/modules/dnn/src/layers/concat_layer.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "../precomp.hpp"
-#include "layers_common.hpp"
-#include "concat_layer.hpp"
-#include <opencv2/core/ocl.hpp>
-
-namespace cv
-{
-namespace dnn
-{
-
-ConcatLayerImpl::ConcatLayerImpl(int axis_ /*= 1*/)
-{
- axis = axis_;
-}
-
-void ConcatLayerImpl::allocate(const std::vector<Blob *> &inputs, std::vector<Blob> &outputs)
-{
- CV_Assert(inputs.size() > 0);
-
- BlobShape refShape = inputs[0]->shape();
- axisIdx = inputs[0]->canonicalAxis(axis);
-
- int axisSum = 0;
- useOpenCL = false;
- for (size_t i = 0; i < inputs.size(); i++)
- {
- BlobShape curShape = inputs[i]->shape();
-
- CV_Assert(curShape.dims() == refShape.dims() && inputs[i]->type() == inputs[0]->type());
- for (int curAxis = 0; curAxis < refShape.dims(); curAxis++)
- {
- if (curAxis != axisIdx && refShape[curAxis] != curShape[curAxis])
- CV_Error(Error::StsBadSize, "Inconsitent shape for ConcatLayer");
- }
-
- axisSum += curShape[axisIdx];
- useOpenCL |= inputs[i]->getState() == Blob::HEAD_AT_MAT;
- }
-
- refShape[axisIdx] = axisSum;
- useOpenCL &= ocl::useOpenCL();
- int allocFlags = (useOpenCL) ? Blob::ALLOC_UMAT : Blob::ALLOC_MAT;
-
- outputs.resize(1);
- outputs[0].create(refShape, inputs[0]->type(), allocFlags);
-}
-
-
-void ConcatLayerImpl::forward(std::vector<Blob *> &inputs, std::vector<Blob> &outputs)
-{
- #ifdef HAVE_OPENCL
- if (useOpenCL)
- forward_<UMat>(inputs, outputs);
- else
- #endif
- forward_<Mat>(inputs, outputs);
-}
-
-template<typename XMat>
-void ConcatLayerImpl::forward_(std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- XMat& outMat = outputs[0].getRef<XMat>();
- std::vector<Range> ranges(outputs[0].dims(), Range::all());
-
- ranges[axisIdx].start = 0;
- for (size_t i = 0; i < inputs.size(); i++)
- {
- ranges[axisIdx].end = ranges[axisIdx].start + inputs[i]->size(axisIdx);
- inputs[i]->getRefConst<XMat>().copyTo(outMat(&ranges[0]));
- ranges[axisIdx].start = ranges[axisIdx].end;
- }
-}
-
-Ptr<ConcatLayer> ConcatLayer::create(int axis)
-{
- return Ptr<ConcatLayer>(new ConcatLayerImpl(axis));
-}
-
-}
-}
diff --git a/contrib/modules/dnn/src/layers/concat_layer.hpp b/contrib/modules/dnn/src/layers/concat_layer.hpp
deleted file mode 100644
index 86f2083..0000000
--- a/contrib/modules/dnn/src/layers/concat_layer.hpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_LAYERS_CONCAT_LAYER_HPP__
-#define __OPENCV_DNN_LAYERS_CONCAT_LAYER_HPP__
-#include "../precomp.hpp"
-#include <opencv2/dnn/all_layers.hpp>
-
-namespace cv
-{
-namespace dnn
-{
-
-class ConcatLayerImpl : public ConcatLayer
-{
- bool useOpenCL;
- int axisIdx;
-
- template<typename XMat>
- void forward_(std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
-
-public:
- ConcatLayerImpl(int axis_ = 1);
-
- void allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
-
- void forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
-};
-
-}
-}
-#endif
diff --git a/contrib/modules/dnn/src/layers/convolution_layer.cpp b/contrib/modules/dnn/src/layers/convolution_layer.cpp
deleted file mode 100644
index d10df01..0000000
--- a/contrib/modules/dnn/src/layers/convolution_layer.cpp
+++ /dev/null
@@ -1,352 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "../precomp.hpp"
-#include <opencv2/core/ocl.hpp>
-#include "layers_common.hpp"
-#include "convolution_layer.hpp"
-#include "op_im2col.hpp"
-#include "op_blas.hpp"
-#include <opencv2/dnn/shape_utils.hpp>
-#include <iostream>
-
-namespace cv
-{
-namespace dnn
-{
-
-ConvolutionLayerImpl::ConvolutionLayerImpl()
-{
- tryUseOpenCL = false; //true;
- numOutput = -1;
- group = -1;
-
- #if HAVE_CBLAS
- if (getBlasThreads() != cv::getThreadNum())
- {
- setBlasThreads(cv::getThreadNum());
- }
- #endif
-}
-
-void ConvolutionLayerImpl::init()
-{
- CV_Assert(1 <= blobs.size() && blobs.size() <= 2);
-
- bias = (blobs.size() >= 2);
- numOutput = blobs[0].num();
-
- CV_Assert(blobs[0].dims() == 4 && blobs[0].cols() == kernel.width && blobs[0].rows() == kernel.height);
- CV_Assert(!bias || blobs[1].total() == (size_t)blobs[0].num());
-
- //TODO: dilation in OCL mode
- useOpenCL = ocl::useOpenCL() && tryUseOpenCL && dilation == Size(1, 1);
-}
-
-void ConvolutionLayerImpl::allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- init();
-
- CV_Assert(inputs.size() > 0);
- const Blob &input = *inputs[0];
- CV_Assert(input.dims() == 4 && (input.type() == CV_32F || input.type() == CV_64F));
- computeInpOutShape(input);
-
- group = inpCn / blobs[0].channels();
- CV_Assert(inpCn % group == 0 && outCn % group == 0);
- CV_Assert(blobs[0].num() == outCn && blobs[0].channels() == inpCn / group);
-
- outGroupCn = outCn / group;
- inpGroupCn = inpCn / group;
- ksize = inpGroupCn * kernel.height * kernel.width;
-
- for (size_t i = 0; i < inputs.size(); i++)
- {
- CV_Assert(inputs[i]->type() == input.type());
- CV_Assert(inputs[i]->dims() == 4 && inputs[i]->channels() == input.channels());
- CV_Assert(inputs[i]->rows() == input.rows() && inputs[i]->cols() == input.cols());
- }
-
- int allocFlags = useOpenCL ? Blob::ALLOC_UMAT : Blob::ALLOC_MAT;
-
- if (!is1x1())
- {
- colBlob.create(Shape(ksize, outH * outW), input.type(), allocFlags);
- }
-
- if (bias)
- {
- biasOnesBlob.create(Shape(1, topH * topW), input.type(), allocFlags);
- biasOnesBlob.setTo(1);
- }
-
- outputs.resize(inputs.size());
- for (size_t i = 0; i < inputs.size(); i++)
- {
- outputs[i].create(Shape(inputs[i]->num(), topCn, topH, topW), input.type(), allocFlags);
- }
-}
-
-bool ConvolutionLayerImpl::is1x1() const
-{
- return (kernel.height == 1 && kernel.width == 1) &&
- (stride.height == 1 && stride.width == 1) &&
- (dilation.height == 1 && dilation.width == 1);
-}
-
-template<typename XMat>
-void ConvolutionLayerImpl::forward_(std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- XMat weightsMat = reshaped(blobs[0].getRefConst<XMat>(), Shape(outCn, ksize));
- XMat biasesMat = (bias) ? reshaped(blobs[1].getRefConst<XMat>(), Shape(outCn, 1)) : XMat();
-
- for (size_t ii = 0; ii < outputs.size(); ii++)
- {
- int numImg = inputs[ii]->size(0);
- XMat inpMat = inputs[ii]->getRefConst<XMat>();
- XMat outMat = reshaped(outputs[ii].getRef<XMat>(), Shape(numImg*group*outGroupCn, outH*outW));
-
- for (int n = 0; n < numImg; n++)
- {
- for (int g = 0; g < group; g++)
- {
- XMat colMat, curInp = slice(inpMat, n, _Range(g * inpGroupCn, inpGroupCn));
- im2col(curInp, colMat);
-
- _Range kerRange(g * outGroupCn, outGroupCn);
- XMat kerMat = weightsMat.rowRange(kerRange);
-
- _Range outRange((g + n * group) * outGroupCn, outGroupCn);
- XMat dstMat = outMat.rowRange(outRange);
-
- dnn::gemm(kerMat, colMat, 1, dstMat, 0);
-
- if (bias)
- {
- dnn::gemm(biasesMat.rowRange(kerRange), biasOnesBlob.getRefConst<XMat>(), 1, dstMat, 1);
- }
- }
- }
- }
-}
-
-void ConvolutionLayerImpl::forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- if (!useOpenCL)
- forward_<Mat>(inputs, outputs);
- else
- forward_<UMat>(inputs, outputs);
-}
-
-void ConvolutionLayerImpl::im2col(const UMat &srcImg, UMat &dstCol)
-{
- if (is1x1())
- {
- dstCol = reshaped(srcImg, Shape(ksize, outH*outW));
- return;
- }
-#ifdef HAVE_OPENCL
- CV_Assert(im2col_ocl(srcImg, inpGroupCn, inpH, inpW, kernel.height, kernel.width, pad.height, pad.width, stride.height, stride.width, dilation.height, dilation.width, this->colBlob.umatRef()));
- dstCol = this->colBlob.umatRefConst();
-#else
- CV_Error(Error::StsInternal, "");
- dstCol = srcImg; //supress warning
-#endif
-}
-
-void ConvolutionLayerImpl::im2col(const Mat &srcImg, Mat &dstCol)
-{
- if (is1x1())
- {
- dstCol = reshaped(srcImg, Shape(ksize, outH*outW));
- return;
- }
-
- Mat &colMat = colBlob.matRef();
- if (srcImg.type() == CV_32F)
- im2col_CpuPBody<float>::run(srcImg.ptr<float>(), inpGroupCn, inpH, inpW, kernel.height,
- kernel.width, pad.height, pad.width, stride.height, stride.width,
- dilation.height, dilation.width, outH, outW, colMat.ptr<float>());
- if (srcImg.type() == CV_64F)
- im2col_CpuPBody<double>::run(srcImg.ptr<double>(), inpGroupCn, inpH, inpW, kernel.height,
- kernel.width, pad.height, pad.width, stride.height, stride.width,
- dilation.height, dilation.width, outH, outW, colMat.ptr<double>());
-
- dstCol = colMat;
-}
-
-void ConvolutionLayerImpl::computeInpOutShape(const Blob &input)
-{
- inpH = input.rows();
- inpW = input.cols();
- inpCn = input.channels();
- outCn = numOutput;
-
- if (padMode.empty())
- {
- outH = (inpH + 2 * pad.height - (dilation.height * (kernel.height - 1) + 1)) / stride.height + 1;
- outW = (inpW + 2 * pad.width - (dilation.width * (kernel.width - 1) + 1)) / stride.width + 1;
- }
- else
- {
- getConvPoolOutParams(inpH, inpW, kernel, stride, pad, padMode, outH, outW);
- }
-
- topH = outH; topW = outW; topCn = outCn;
-}
-
-//Deconvolution
-
-DeConvolutionLayerImpl::DeConvolutionLayerImpl()
-{
-
-}
-
-void DeConvolutionLayerImpl::computeInpOutShape(const Blob &inpBlob)
-{
- outH = inpBlob.rows();
- outW = inpBlob.cols();
- outCn = inpBlob.channels();
-
- inpH = stride.height * (outH - 1) + kernel.height - 2 * pad.height;
- inpW = stride.width * (outW - 1) + kernel.width - 2 * pad.width;
- inpCn = numOutput;
-
- topH = inpH; topW = inpW; topCn = inpCn;
-}
-
-void DeConvolutionLayerImpl::forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- if (!useOpenCL)
- forward_<Mat>(inputs, outputs);
- else
- forward_<UMat>(inputs, outputs);
-}
-
-template<typename XMat>
-void DeConvolutionLayerImpl::forward_(std::vector<Blob *> &inputs, std::vector<Blob> &outputs)
-{
- XMat weightsMat = reshaped(blobs[0].getRefConst<XMat>(), Shape(outCn, ksize));
- XMat biasesMat = (bias) ? reshaped(blobs[1].getRefConst<XMat>(), Shape(outCn, 1)) : XMat();
-
- for (size_t ii = 0; ii < outputs.size(); ii++)
- {
- int numImg = inputs[ii]->size(0);
- XMat convBlob = reshaped(inputs[ii]->getRefConst<XMat>(), Shape(numImg*outCn, outH*outW));
- XMat decnBlob = reshaped(outputs[ii].getRef<XMat>(), Shape(numImg*inpCn, inpH*inpW));
-
- for (int n = 0; n < numImg; n++)
- {
- for (int g = 0; g < group; g++)
- {
- XMat dstMat = decnBlob.rowRange(_Range((g + n * group) * inpGroupCn, inpGroupCn));
- XMat &colMat = (is1x1()) ? dstMat : colBlob.getRef<XMat>();
-
- XMat convMat = convBlob.rowRange(_Range((g + n * group) * outGroupCn, outGroupCn));
- XMat wghtMat = weightsMat.rowRange(_Range(g * outGroupCn, outGroupCn));
-
- dnn::gemm(wghtMat, convMat, 1, colMat, 0, GEMM_1_T);
-
- if (!is1x1())
- col2im(colMat, dstMat);
-
- if (bias)
- {
- XMat curBiasMat = biasesMat.rowRange(_Range(g * outGroupCn, outGroupCn));
- dnn::gemm(curBiasMat, biasOnesBlob.getRefConst<XMat>(), 1, dstMat, 1);
- }
- }
- }
- }
-}
-
-void DeConvolutionLayerImpl::col2im(const Mat &colMat, Mat &dstImg)
-{
- if (is1x1())
- {
- dstImg = colMat;
- return;
- }
- if (dstImg.type() == CV_32F)
- col2im_CpuPBody<float>::run(colMat.ptr<float>(), inpGroupCn, inpH, inpW, kernel.height, kernel.width, pad.height, pad.width, stride.height, stride.width, dstImg.ptr<float>());
- if (dstImg.type() == CV_64F)
- col2im_CpuPBody<double>::run(colMat.ptr<double>(), inpGroupCn, inpH, inpW, kernel.height, kernel.width, pad.height, pad.width, stride.height, stride.width, dstImg.ptr<double>());
-}
-
-void DeConvolutionLayerImpl::col2im(const UMat &colMat, UMat &dstImg)
-{
- if (is1x1())
- {
- dstImg = colMat;
- return;
- }
-#ifdef HAVE_OPENCL
- CV_Assert(col2im_ocl(colMat, inpGroupCn, inpH, inpW, kernel.height, kernel.width, pad.height, pad.width, stride.height, stride.width, dstImg));
-#else
- CV_Error(Error::StsInternal, "");
- dstImg = colMat;
-#endif
-}
-
-//Initializers
-
-Ptr<BaseConvolutionLayer> ConvolutionLayer::create(Size kernel, Size stride, Size pad, Size dilation)
-{
- ConvolutionLayerImpl *l = new ConvolutionLayerImpl();
- l->kernel = kernel;
- l->pad = pad;
- l->stride = stride;
- l->dilation = dilation;
- return Ptr<BaseConvolutionLayer>(l);
-}
-
-Ptr<BaseConvolutionLayer> DeconvolutionLayer::create(Size kernel, Size stride, Size pad, Size dilation)
-{
- DeConvolutionLayerImpl *l = new DeConvolutionLayerImpl();
- l->kernel = kernel;
- l->pad = pad;
- l->stride = stride;
- l->dilation = dilation;
- return Ptr<BaseConvolutionLayer>(l);
-}
-
-}
-}
diff --git a/contrib/modules/dnn/src/layers/convolution_layer.hpp b/contrib/modules/dnn/src/layers/convolution_layer.hpp
deleted file mode 100644
index 3b59bb6..0000000
--- a/contrib/modules/dnn/src/layers/convolution_layer.hpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_LAYERS_CONVOLUTION_LAYER_HPP__
-#define __OPENCV_DNN_LAYERS_CONVOLUTION_LAYER_HPP__
-#include "../precomp.hpp"
-#include <opencv2/dnn/all_layers.hpp>
-
-namespace cv
-{
-namespace dnn
-{
-
-//TODO: simultaneously convolution and bias addition for cache optimization
-class ConvolutionLayerImpl : public ConvolutionLayer
-{
-public:
-
- ConvolutionLayerImpl();
- virtual void allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
- virtual void forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
- virtual void init();
-
-protected:
- int numOutput, group;
- int inpH, inpW, inpCn;
- int outH, outW, outCn;
- int topH, topW, topCn; //switched between inp/out on deconv/conv
- int inpGroupCn, outGroupCn;
- int ksize;
-
- bool bias;
- bool tryUseOpenCL, useOpenCL;
-
- Blob colBlob, biasOnesBlob;
-
- bool is1x1() const;
- virtual void computeInpOutShape(const Blob &inpBlob);
-
- template<typename XMat>
- void forward_(std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
- void im2col(const Mat &srcImg, Mat &dstCol);
- void im2col(const UMat &srcImg, UMat &dstCol);
-};
-
-class DeConvolutionLayerImpl : public ConvolutionLayerImpl
-{
-public:
- DeConvolutionLayerImpl();
- virtual void forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
-
-protected:
-
- virtual void computeInpOutShape(const Blob &inpBlob);
-
- template<typename XMat>
- void forward_(std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
- void col2im(const Mat &colMat, Mat &dstImg);
- void col2im(const UMat &colMat, UMat &dstImg);
-};
-
-//Importers
-Ptr<Layer> createConvolutionLayerFromCaffe(LayerParams ¶ms);
-Ptr<Layer> createDeconvolutionLayerFromCaffe(LayerParams ¶ms);
-
-}
-}
-
-#endif
diff --git a/contrib/modules/dnn/src/layers/crop_layer.cpp b/contrib/modules/dnn/src/layers/crop_layer.cpp
deleted file mode 100755
index 06f6f75..0000000
--- a/contrib/modules/dnn/src/layers/crop_layer.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "../precomp.hpp"
-#include "layers_common.hpp"
-#include "crop_layer.hpp"
-
-namespace cv
-{
-namespace dnn
-{
-
-CropLayerImpl::CropLayerImpl(int start_axis_, const std::vector<int> &offset_)
-{
- startAxis = start_axis_;
- offset = offset_;
-}
-
-void CropLayerImpl::allocate(const std::vector<Blob *> &inputs, std::vector<Blob> &outputs)
-{
- CV_Assert(2 == inputs.size());
-
- const Blob &inpBlob = *inputs[0];
- const Blob &inpSzBlob = *inputs[1];
-
- int start_axis = inpBlob.canonicalAxis(startAxis);
- int dims = inpBlob.dims();
-
- std::vector<int> offset_final(dims, 0);
- if (offset.size() == 1)
- {
- for (int i = start_axis; i < dims; i++)
- offset_final[i] = offset[0];
- }
- else if (offset.size() > 1)
- {
- if ((int)offset.size() != dims - start_axis)
- CV_Error(Error::StsBadArg, "number of offset values specified must be equal to the number of dimensions following axis.");
-
- for (int i = start_axis; i < dims; i++)
- offset_final[i] = offset[i - start_axis];
- }
-
- BlobShape dstShape = inpBlob.shape();
- crop_ranges.resize(dims, Range::all());
- for (int i = start_axis; i < dims; i++)
- {
- dstShape[i] = inpSzBlob.size(i);
-
- if (!offset.empty()) //normal case
- {
- if (offset_final[i] < 0 || offset_final[i] + inpSzBlob.size(i) > inpBlob.size(i))
- CV_Error(Error::StsBadArg, "invalid crop parameters");
-
- crop_ranges[i] = Range(offset_final[i], offset_final[i] + inpSzBlob.size(i));
- }
- else //detect offset automatically so that cropped image is center of original one
- {
- if (inpSzBlob.size(i) > inpBlob.size(i))
- CV_Error(Error::StsBadArg, "invalid output blob size");
-
- int cur_crop = (inpBlob.size(i) - inpSzBlob.size(i)) / 2;
- crop_ranges[i] = Range(cur_crop, cur_crop + inpSzBlob.size(i));
- }
- }
-
- outputs.resize(1);
- outputs[0].create(dstShape);
-}
-
-void CropLayerImpl::forward(std::vector<Blob *> &inputs, std::vector<Blob> &outputs)
-{
- Blob &input = *inputs[0];
- Blob &output = outputs[0];
-
- #ifdef HAVE_OPENCL
- if (input.getState() == Blob::HEAD_AT_UMAT)
- input.umatRefConst()(&crop_ranges[0]).copyTo(output.umatRef());
- else
- #endif
- input.matRefConst()(&crop_ranges[0]).copyTo(output.matRef());
-}
-
-Ptr<CropLayer> CropLayer::create(int start_axis, const std::vector<int> &offset)
-{
- return Ptr<CropLayer>(new CropLayerImpl(start_axis, offset));
-}
-
-}
-}
diff --git a/contrib/modules/dnn/src/layers/crop_layer.hpp b/contrib/modules/dnn/src/layers/crop_layer.hpp
deleted file mode 100755
index bc8789b..0000000
--- a/contrib/modules/dnn/src/layers/crop_layer.hpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_LAYERS_CROP_LAYER_HPP__
-#define __OPENCV_DNN_LAYERS_CROP_LAYER_HPP__
-#include "../precomp.hpp"
-#include <opencv2/dnn/all_layers.hpp>
-
-namespace cv
-{
-namespace dnn
-{
- class CropLayerImpl : public CropLayer
- {
- std::vector<Range> crop_ranges;
-
- public:
- CropLayerImpl(int start_axis, const std::vector<int> &offset);
- void allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
- void forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
- };
-}
-}
-#endif
diff --git a/contrib/modules/dnn/src/layers/detection_output_layer.cpp b/contrib/modules/dnn/src/layers/detection_output_layer.cpp
deleted file mode 100644
index 00002db..0000000
--- a/contrib/modules/dnn/src/layers/detection_output_layer.cpp
+++ /dev/null
@@ -1,750 +0,0 @@
-/*M ///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "../precomp.hpp"
-#include "layers_common.hpp"
-#include "detection_output_layer.hpp"
-#include <float.h>
-#include <string>
-
-namespace cv
-{
-namespace dnn
-{
-
-namespace util
-{
-template <typename T>
-std::string to_string(T value)
-{
- std::ostringstream stream;
- stream << value;
- return stream.str();
-}
-
-template <typename T>
-void make_error(const std::string& message1, const T& message2)
-{
- std::string error(message1);
- error += std::string(util::to_string<int>(message2));
- CV_Error(Error::StsBadArg, error.c_str());
-}
-
-template <typename T>
-bool SortScorePairDescend(const std::pair<float, T>& pair1,
- const std::pair<float, T>& pair2)
-{
- return pair1.first > pair2.first;
-}
-}
-
-const std::string DetectionOutputLayer::_layerName = std::string("DetectionOutput");
-
-bool DetectionOutputLayer::getParameterDict(const LayerParams ¶ms,
- const std::string ¶meterName,
- DictValue& result)
-{
- if (!params.has(parameterName))
- {
- return false;
- }
-
- result = params.get(parameterName);
- return true;
-}
-
-template<typename T>
-T DetectionOutputLayer::getParameter(const LayerParams ¶ms,
- const std::string ¶meterName,
- const size_t &idx,
- const bool required,
- const T& defaultValue)
-{
- DictValue dictValue;
- bool success = getParameterDict(params, parameterName, dictValue);
- if(!success)
- {
- if(required)
- {
- std::string message = _layerName;
- message += " layer parameter does not contain ";
- message += parameterName;
- message += " parameter.";
- CV_Error(Error::StsBadArg, message);
- }
- else
- {
- return defaultValue;
- }
- }
- return dictValue.get<T>(idx);
-}
-
-void DetectionOutputLayer::getCodeType(LayerParams ¶ms)
-{
- String codeTypeString = params.get<String>("code_type").toLowerCase();
- if (codeTypeString == "corner")
- _codeType = caffe::PriorBoxParameter_CodeType_CORNER;
- else if (codeTypeString == "center_size")
- _codeType = caffe::PriorBoxParameter_CodeType_CENTER_SIZE;
- else
- _codeType = caffe::PriorBoxParameter_CodeType_CORNER;
-}
-
-DetectionOutputLayer::DetectionOutputLayer(LayerParams ¶ms) : Layer(params)
-{
- _numClasses = getParameter<unsigned>(params, "num_classes");
- _shareLocation = getParameter<bool>(params, "share_location");
- _numLocClasses = _shareLocation ? 1 : _numClasses;
- _backgroundLabelId = getParameter<int>(params, "background_label_id");
- _varianceEncodedInTarget = getParameter<bool>(params, "variance_encoded_in_target", 0, false, false);
- _keepTopK = getParameter<int>(params, "keep_top_k");
- _confidenceThreshold = getParameter<float>(params, "confidence_threshold", 0, false, -FLT_MAX);
- _topK = getParameter<int>(params, "top_k", 0, false, -1);
-
- getCodeType(params);
-
- // Parameters used in nms.
- _nmsThreshold = getParameter<float>(params, "nms_threshold");
- CV_Assert(_nmsThreshold > 0.);
-}
-
-void DetectionOutputLayer::checkInputs(const std::vector<Blob*> &inputs)
-{
- for (size_t i = 1; i < inputs.size(); i++)
- {
- for (size_t j = 0; j < _numAxes; j++)
- {
- CV_Assert(inputs[i]->shape()[j] == inputs[0]->shape()[j]);
- }
- }
-}
-
-void DetectionOutputLayer::allocate(const std::vector<Blob*> &inputs,
- std::vector<Blob> &outputs)
-{
- CV_Assert(inputs.size() > 0);
- CV_Assert(inputs[0]->num() == inputs[1]->num());
- _num = inputs[0]->num();
-
- _numPriors = inputs[2]->rows() / 4;
- CV_Assert((_numPriors * _numLocClasses * 4) == inputs[0]->channels());
- CV_Assert(int(_numPriors * _numClasses) == inputs[1]->channels());
-
- // num() and channels() are 1.
- // Since the number of bboxes to be kept is unknown before nms, we manually
- // set it to (fake) 1.
- // Each row is a 7 dimension std::vector, which stores
- // [image_id, label, confidence, xmin, ymin, xmax, ymax]
- BlobShape outputShape = BlobShape(1, 1, 1, 7);
- outputs[0].create(BlobShape(outputShape));
-}
-
-void DetectionOutputLayer::forward(std::vector<Blob*> &inputs,
- std::vector<Blob> &outputs)
-{
- const float* locationData = inputs[0]->ptrf();
- const float* confidenceData = inputs[1]->ptrf();
- const float* priorData = inputs[2]->ptrf();
-
- // Retrieve all location predictions.
- std::vector<LabelBBox> allLocationPredictions;
- GetLocPredictions(locationData, _num, _numPriors, _numLocClasses,
- _shareLocation, &allLocationPredictions);
-
- // Retrieve all confidences.
- std::vector<std::map<int, std::vector<float> > > allConfidenceScores;
- GetConfidenceScores(confidenceData, _num, _numPriors, _numClasses,
- &allConfidenceScores);
-
- // Retrieve all prior bboxes. It is same within a batch since we assume all
- // images in a batch are of same dimension.
- std::vector<caffe::NormalizedBBox> priorBBoxes;
- std::vector<std::vector<float> > priorVariances;
- GetPriorBBoxes(priorData, _numPriors, &priorBBoxes, &priorVariances);
-
- // Decode all loc predictions to bboxes.
- std::vector<LabelBBox> allDecodedBBoxes;
- DecodeBBoxesAll(allLocationPredictions, priorBBoxes, priorVariances, _num,
- _shareLocation, _numLocClasses, _backgroundLabelId,
- _codeType, _varianceEncodedInTarget, &allDecodedBBoxes);
-
- int numKept = 0;
- std::vector<std::map<int, std::vector<int> > > allIndices;
- for (int i = 0; i < _num; ++i)
- {
- const LabelBBox& decodeBBoxes = allDecodedBBoxes[i];
- const std::map<int, std::vector<float> >& confidenceScores =
- allConfidenceScores[i];
- std::map<int, std::vector<int> > indices;
- int numDetections = 0;
- for (int c = 0; c < (int)_numClasses; ++c)
- {
- if (c == _backgroundLabelId)
- {
- // Ignore background class.
- continue;
- }
- if (confidenceScores.find(c) == confidenceScores.end())
- {
- // Something bad happened if there are no predictions for current label.
- util::make_error<int>("Could not find confidence predictions for label ", c);
- }
-
- const std::vector<float>& scores = confidenceScores.find(c)->second;
- int label = _shareLocation ? -1 : c;
- if (decodeBBoxes.find(label) == decodeBBoxes.end())
- {
- // Something bad happened if there are no predictions for current label.
- util::make_error<int>("Could not find location predictions for label ", label);
- continue;
- }
- const std::vector<caffe::NormalizedBBox>& bboxes =
- decodeBBoxes.find(label)->second;
- ApplyNMSFast(bboxes, scores, _confidenceThreshold, _nmsThreshold,
- _topK, &(indices[c]));
- numDetections += indices[c].size();
- }
- if (_keepTopK > -1 && numDetections > _keepTopK)
- {
- std::vector<std::pair<float, std::pair<int, int> > > scoreIndexPairs;
- for (std::map<int, std::vector<int> >::iterator it = indices.begin();
- it != indices.end(); ++it)
- {
- int label = it->first;
- const std::vector<int>& labelIndices = it->second;
- if (confidenceScores.find(label) == confidenceScores.end())
- {
- // Something bad happened for current label.
- util::make_error<int>("Could not find location predictions for label ", label);
- continue;
- }
- const std::vector<float>& scores = confidenceScores.find(label)->second;
- for (size_t j = 0; j < labelIndices.size(); ++j)
- {
- size_t idx = labelIndices[j];
- CV_Assert(idx < scores.size());
- scoreIndexPairs.push_back(
- std::make_pair(scores[idx], std::make_pair(label, idx)));
- }
- }
- // Keep outputs k results per image.
- std::sort(scoreIndexPairs.begin(), scoreIndexPairs.end(),
- util::SortScorePairDescend<std::pair<int, int> >);
- scoreIndexPairs.resize(_keepTopK);
- // Store the new indices.
- std::map<int, std::vector<int> > newIndices;
- for (size_t j = 0; j < scoreIndexPairs.size(); ++j)
- {
- int label = scoreIndexPairs[j].second.first;
- int idx = scoreIndexPairs[j].second.second;
- newIndices[label].push_back(idx);
- }
- allIndices.push_back(newIndices);
- numKept += _keepTopK;
- }
- else
- {
- allIndices.push_back(indices);
- numKept += numDetections;
- }
- }
-
- if (numKept == 0)
- {
- CV_ErrorNoReturn(Error::StsError, "Couldn't find any detections");
- return;
- }
- std::vector<int> outputsShape(2, 1);
- outputsShape.push_back(numKept);
- outputsShape.push_back(7);
- outputs[0].create(outputsShape);
- float* outputsData = outputs[0].ptrf();
-
- int count = 0;
- for (int i = 0; i < _num; ++i)
- {
- const std::map<int, std::vector<float> >& confidenceScores =
- allConfidenceScores[i];
- const LabelBBox& decodeBBoxes = allDecodedBBoxes[i];
- for (std::map<int, std::vector<int> >::iterator it = allIndices[i].begin();
- it != allIndices[i].end(); ++it)
- {
- int label = it->first;
- if (confidenceScores.find(label) == confidenceScores.end())
- {
- // Something bad happened if there are no predictions for current label.
- util::make_error<int>("Could not find confidence predictions for label ", label);
- continue;
- }
- const std::vector<float>& scores = confidenceScores.find(label)->second;
- int locLabel = _shareLocation ? -1 : label;
- if (decodeBBoxes.find(locLabel) == decodeBBoxes.end())
- {
- // Something bad happened if there are no predictions for current label.
- util::make_error<int>("Could not find location predictions for label ", locLabel);
- continue;
- }
- const std::vector<caffe::NormalizedBBox>& bboxes =
- decodeBBoxes.find(locLabel)->second;
- std::vector<int>& indices = it->second;
-
- for (size_t j = 0; j < indices.size(); ++j)
- {
- int idx = indices[j];
- outputsData[count * 7] = i;
- outputsData[count * 7 + 1] = label;
- outputsData[count * 7 + 2] = scores[idx];
- caffe::NormalizedBBox clipBBox;
- ClipBBox(bboxes[idx], &clipBBox);
- outputsData[count * 7 + 3] = clipBBox.xmin();
- outputsData[count * 7 + 4] = clipBBox.ymin();
- outputsData[count * 7 + 5] = clipBBox.xmax();
- outputsData[count * 7 + 6] = clipBBox.ymax();
-
- ++count;
- }
- }
- }
-}
-
-float DetectionOutputLayer::BBoxSize(const caffe::NormalizedBBox& bbox,
- const bool normalized)
-{
- if (bbox.xmax() < bbox.xmin() || bbox.ymax() < bbox.ymin())
- {
- // If bbox is invalid (e.g. xmax < xmin or ymax < ymin), return 0.
- return 0;
- }
- else
- {
- if (bbox.has_size())
- {
- return bbox.size();
- }
- else
- {
- float width = bbox.xmax() - bbox.xmin();
- float height = bbox.ymax() - bbox.ymin();
- if (normalized)
- {
- return width * height;
- }
- else
- {
- // If bbox is not within range [0, 1].
- return (width + 1) * (height + 1);
- }
- }
- }
-}
-
-void DetectionOutputLayer::ClipBBox(const caffe::NormalizedBBox& bbox,
- caffe::NormalizedBBox* clipBBox)
-{
- clipBBox->set_xmin(std::max(std::min(bbox.xmin(), 1.f), 0.f));
- clipBBox->set_ymin(std::max(std::min(bbox.ymin(), 1.f), 0.f));
- clipBBox->set_xmax(std::max(std::min(bbox.xmax(), 1.f), 0.f));
- clipBBox->set_ymax(std::max(std::min(bbox.ymax(), 1.f), 0.f));
- clipBBox->clear_size();
- clipBBox->set_size(BBoxSize(*clipBBox));
- clipBBox->set_difficult(bbox.difficult());
-}
-
-void DetectionOutputLayer::DecodeBBox(
- const caffe::NormalizedBBox& priorBBox, const std::vector<float>& priorVariance,
- const CodeType codeType, const bool varianceEncodedInTarget,
- const caffe::NormalizedBBox& bbox, caffe::NormalizedBBox* decodeBBox)
-{
- if (codeType == caffe::PriorBoxParameter_CodeType_CORNER)
- {
- if (varianceEncodedInTarget)
- {
- // variance is encoded in target, we simply need to add the offset
- // predictions.
- decodeBBox->set_xmin(priorBBox.xmin() + bbox.xmin());
- decodeBBox->set_ymin(priorBBox.ymin() + bbox.ymin());
- decodeBBox->set_xmax(priorBBox.xmax() + bbox.xmax());
- decodeBBox->set_ymax(priorBBox.ymax() + bbox.ymax());
- }
- else
- {
- // variance is encoded in bbox, we need to scale the offset accordingly.
- decodeBBox->set_xmin(
- priorBBox.xmin() + priorVariance[0] * bbox.xmin());
- decodeBBox->set_ymin(
- priorBBox.ymin() + priorVariance[1] * bbox.ymin());
- decodeBBox->set_xmax(
- priorBBox.xmax() + priorVariance[2] * bbox.xmax());
- decodeBBox->set_ymax(
- priorBBox.ymax() + priorVariance[3] * bbox.ymax());
- }
- }
- else
- if (codeType == caffe::PriorBoxParameter_CodeType_CENTER_SIZE)
- {
- float priorWidth = priorBBox.xmax() - priorBBox.xmin();
- CV_Assert(priorWidth > 0);
-
- float priorHeight = priorBBox.ymax() - priorBBox.ymin();
- CV_Assert(priorHeight > 0);
-
- float priorCenterX = (priorBBox.xmin() + priorBBox.xmax()) / 2.;
- float priorCenterY = (priorBBox.ymin() + priorBBox.ymax()) / 2.;
-
- float decodeBBoxCenterX, decodeBBoxCenterY;
- float decodeBBoxWidth, decodeBBoxHeight;
- if (varianceEncodedInTarget)
- {
- // variance is encoded in target, we simply need to retore the offset
- // predictions.
- decodeBBoxCenterX = bbox.xmin() * priorWidth + priorCenterX;
- decodeBBoxCenterY = bbox.ymin() * priorHeight + priorCenterY;
- decodeBBoxWidth = exp(bbox.xmax()) * priorWidth;
- decodeBBoxHeight = exp(bbox.ymax()) * priorHeight;
- }
- else
- {
- // variance is encoded in bbox, we need to scale the offset accordingly.
- decodeBBoxCenterX =
- priorVariance[0] * bbox.xmin() * priorWidth + priorCenterX;
- decodeBBoxCenterY =
- priorVariance[1] * bbox.ymin() * priorHeight + priorCenterY;
- decodeBBoxWidth =
- exp(priorVariance[2] * bbox.xmax()) * priorWidth;
- decodeBBoxHeight =
- exp(priorVariance[3] * bbox.ymax()) * priorHeight;
- }
-
- decodeBBox->set_xmin(decodeBBoxCenterX - decodeBBoxWidth / 2.);
- decodeBBox->set_ymin(decodeBBoxCenterY - decodeBBoxHeight / 2.);
- decodeBBox->set_xmax(decodeBBoxCenterX + decodeBBoxWidth / 2.);
- decodeBBox->set_ymax(decodeBBoxCenterY + decodeBBoxHeight / 2.);
- }
- else
- {
- CV_Error(Error::StsBadArg, "Unknown LocLossType.");
- }
- float bboxSize = BBoxSize(*decodeBBox);
- decodeBBox->set_size(bboxSize);
-}
-
-void DetectionOutputLayer::DecodeBBoxes(
- const std::vector<caffe::NormalizedBBox>& priorBBoxes,
- const std::vector<std::vector<float> >& priorVariances,
- const CodeType codeType, const bool varianceEncodedInTarget,
- const std::vector<caffe::NormalizedBBox>& bboxes,
- std::vector<caffe::NormalizedBBox>* decodeBBoxes)
-{
- CV_Assert(priorBBoxes.size() == priorVariances.size());
- CV_Assert(priorBBoxes.size() == bboxes.size());
- int numBBoxes = priorBBoxes.size();
- if (numBBoxes >= 1)
- {
- CV_Assert(priorVariances[0].size() == 4);
- }
- decodeBBoxes->clear();
- for (int i = 0; i < numBBoxes; ++i)
- {
- caffe::NormalizedBBox decodeBBox;
- DecodeBBox(priorBBoxes[i], priorVariances[i], codeType,
- varianceEncodedInTarget, bboxes[i], &decodeBBox);
- decodeBBoxes->push_back(decodeBBox);
- }
-}
-
-void DetectionOutputLayer::DecodeBBoxesAll(
- const std::vector<LabelBBox>& allLocPreds,
- const std::vector<caffe::NormalizedBBox>& priorBBoxes,
- const std::vector<std::vector<float> >& priorVariances,
- const size_t num, const bool shareLocation,
- const int numLocClasses, const int backgroundLabelId,
- const CodeType codeType, const bool varianceEncodedInTarget,
- std::vector<LabelBBox>* allDecodeBBoxes)
-{
- CV_Assert(allLocPreds.size() == num);
- allDecodeBBoxes->clear();
- allDecodeBBoxes->resize(num);
- for (size_t i = 0; i < num; ++i)
- {
- // Decode predictions into bboxes.
- LabelBBox& decodeBBoxes = (*allDecodeBBoxes)[i];
- for (int c = 0; c < numLocClasses; ++c)
- {
- int label = shareLocation ? -1 : c;
- if (label == backgroundLabelId)
- {
- // Ignore background class.
- continue;
- }
- if (allLocPreds[i].find(label) == allLocPreds[i].end())
- {
- // Something bad happened if there are no predictions for current label.
- util::make_error<int>("Could not find location predictions for label ", label);
- }
- const std::vector<caffe::NormalizedBBox>& labelLocPreds =
- allLocPreds[i].find(label)->second;
- DecodeBBoxes(priorBBoxes, priorVariances,
- codeType, varianceEncodedInTarget,
- labelLocPreds, &(decodeBBoxes[label]));
- }
- }
-}
-
-void DetectionOutputLayer::GetPriorBBoxes(const float* priorData, const int& numPriors,
- std::vector<caffe::NormalizedBBox>* priorBBoxes,
- std::vector<std::vector<float> >* priorVariances)
-{
- priorBBoxes->clear();
- priorVariances->clear();
- for (int i = 0; i < numPriors; ++i)
- {
- int startIdx = i * 4;
- caffe::NormalizedBBox bbox;
- bbox.set_xmin(priorData[startIdx]);
- bbox.set_ymin(priorData[startIdx + 1]);
- bbox.set_xmax(priorData[startIdx + 2]);
- bbox.set_ymax(priorData[startIdx + 3]);
- float bboxSize = BBoxSize(bbox);
- bbox.set_size(bboxSize);
- priorBBoxes->push_back(bbox);
- }
-
- for (int i = 0; i < numPriors; ++i)
- {
- int startIdx = (numPriors + i) * 4;
- std::vector<float> var;
- for (int j = 0; j < 4; ++j)
- {
- var.push_back(priorData[startIdx + j]);
- }
- priorVariances->push_back(var);
- }
-}
-
-void DetectionOutputLayer::ScaleBBox(const caffe::NormalizedBBox& bbox,
- const int height, const int width,
- caffe::NormalizedBBox* scaleBBox)
-{
- scaleBBox->set_xmin(bbox.xmin() * width);
- scaleBBox->set_ymin(bbox.ymin() * height);
- scaleBBox->set_xmax(bbox.xmax() * width);
- scaleBBox->set_ymax(bbox.ymax() * height);
- scaleBBox->clear_size();
- bool normalized = !(width > 1 || height > 1);
- scaleBBox->set_size(BBoxSize(*scaleBBox, normalized));
- scaleBBox->set_difficult(bbox.difficult());
-}
-
-
-void DetectionOutputLayer::GetLocPredictions(
- const float* locData, const int num,
- const int numPredsPerClass, const int numLocClasses,
- const bool shareLocation, std::vector<LabelBBox>* locPreds)
-{
- locPreds->clear();
- if (shareLocation)
- {
- CV_Assert(numLocClasses == 1);
- }
- locPreds->resize(num);
- for (int i = 0; i < num; ++i)
- {
- LabelBBox& labelBBox = (*locPreds)[i];
- for (int p = 0; p < numPredsPerClass; ++p)
- {
- int startIdx = p * numLocClasses * 4;
- for (int c = 0; c < numLocClasses; ++c)
- {
- int label = shareLocation ? -1 : c;
- if (labelBBox.find(label) == labelBBox.end())
- {
- labelBBox[label].resize(numPredsPerClass);
- }
- labelBBox[label][p].set_xmin(locData[startIdx + c * 4]);
- labelBBox[label][p].set_ymin(locData[startIdx + c * 4 + 1]);
- labelBBox[label][p].set_xmax(locData[startIdx + c * 4 + 2]);
- labelBBox[label][p].set_ymax(locData[startIdx + c * 4 + 3]);
- }
- }
- locData += numPredsPerClass * numLocClasses * 4;
- }
-}
-
-void DetectionOutputLayer::GetConfidenceScores(
- const float* confData, const int num,
- const int numPredsPerClass, const int numClasses,
- std::vector<std::map<int, std::vector<float> > >* confPreds)
-{
- confPreds->clear();
- confPreds->resize(num);
- for (int i = 0; i < num; ++i)
- {
- std::map<int, std::vector<float> >& labelScores = (*confPreds)[i];
- for (int p = 0; p < numPredsPerClass; ++p)
- {
- int startIdx = p * numClasses;
- for (int c = 0; c < numClasses; ++c)
- {
- labelScores[c].push_back(confData[startIdx + c]);
- }
- }
- confData += numPredsPerClass * numClasses;
- }
-}
-
-void DetectionOutputLayer::ApplyNMSFast(const std::vector<caffe::NormalizedBBox>& bboxes,
- const std::vector<float>& scores,
- const float score_threshold,
- const float nms_threshold, const int top_k,
- std::vector<int>* indices)
-{
- // Sanity check.
- CV_Assert(bboxes.size() == scores.size());
-
- // Get top_k scores (with corresponding indices).
- std::vector<std::pair<float, int> > score_index_vec;
- GetMaxScoreIndex(scores, score_threshold, top_k, &score_index_vec);
-
- // Do nms.
- indices->clear();
- while (score_index_vec.size() != 0)
- {
- const int idx = score_index_vec.front().second;
- bool keep = true;
- for (size_t k = 0; k < indices->size(); ++k)
- {
- if (keep)
- {
- const int kept_idx = (*indices)[k];
- float overlap = JaccardOverlap(bboxes[idx], bboxes[kept_idx]);
- keep = overlap <= nms_threshold;
- }
- else
- {
- break;
- }
- }
- if (keep)
- {
- indices->push_back(idx);
- }
- score_index_vec.erase(score_index_vec.begin());
- }
-}
-
-
-void DetectionOutputLayer::GetMaxScoreIndex(
- const std::vector<float>& scores, const float threshold,const int top_k,
- std::vector<std::pair<float, int> >* score_index_vec)
-{
- // Generate index score pairs.
- for (size_t i = 0; i < scores.size(); ++i)
- {
- if (scores[i] > threshold)
- {
- score_index_vec->push_back(std::make_pair(scores[i], i));
- }
- }
-
- // Sort the score pair according to the scores in descending order
- std::stable_sort(score_index_vec->begin(), score_index_vec->end(),
- util::SortScorePairDescend<int>);
-
- // Keep top_k scores if needed.
- if (top_k > -1 && top_k < (int)score_index_vec->size())
- {
- score_index_vec->resize(top_k);
- }
-}
-
-void DetectionOutputLayer::IntersectBBox(const caffe::NormalizedBBox& bbox1,
- const caffe::NormalizedBBox& bbox2,
- caffe::NormalizedBBox* intersect_bbox) {
- if (bbox2.xmin() > bbox1.xmax() || bbox2.xmax() < bbox1.xmin() ||
- bbox2.ymin() > bbox1.ymax() || bbox2.ymax() < bbox1.ymin())
- {
- // Return [0, 0, 0, 0] if there is no intersection.
- intersect_bbox->set_xmin(0);
- intersect_bbox->set_ymin(0);
- intersect_bbox->set_xmax(0);
- intersect_bbox->set_ymax(0);
- }
- else
- {
- intersect_bbox->set_xmin(std::max(bbox1.xmin(), bbox2.xmin()));
- intersect_bbox->set_ymin(std::max(bbox1.ymin(), bbox2.ymin()));
- intersect_bbox->set_xmax(std::min(bbox1.xmax(), bbox2.xmax()));
- intersect_bbox->set_ymax(std::min(bbox1.ymax(), bbox2.ymax()));
- }
-}
-
-float DetectionOutputLayer::JaccardOverlap(const caffe::NormalizedBBox& bbox1,
- const caffe::NormalizedBBox& bbox2,
- const bool normalized) {
- caffe::NormalizedBBox intersect_bbox;
- IntersectBBox(bbox1, bbox2, &intersect_bbox);
- float intersect_width, intersect_height;
- if (normalized)
- {
- intersect_width = intersect_bbox.xmax() - intersect_bbox.xmin();
- intersect_height = intersect_bbox.ymax() - intersect_bbox.ymin();
- }
- else
- {
- intersect_width = intersect_bbox.xmax() - intersect_bbox.xmin() + 1;
- intersect_height = intersect_bbox.ymax() - intersect_bbox.ymin() + 1;
- }
- if (intersect_width > 0 && intersect_height > 0)
- {
- float intersect_size = intersect_width * intersect_height;
- float bbox1_size = BBoxSize(bbox1);
- float bbox2_size = BBoxSize(bbox2);
- return intersect_size / (bbox1_size + bbox2_size - intersect_size);
- }
- else
- {
- return 0.;
- }
-}
-
-}
-}
diff --git a/contrib/modules/dnn/src/layers/detection_output_layer.hpp b/contrib/modules/dnn/src/layers/detection_output_layer.hpp
deleted file mode 100644
index 0b28d69..0000000
--- a/contrib/modules/dnn/src/layers/detection_output_layer.hpp
+++ /dev/null
@@ -1,226 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_LAYERS_DETECTION_OUTPUT_LAYER_HPP__
-#define __OPENCV_DNN_LAYERS_DETECTION_OUTPUT_LAYER_HPP__
-
-#include "../precomp.hpp"
-#include "caffe.pb.h"
-
-namespace cv
-{
-namespace dnn
-{
-class DetectionOutputLayer : public Layer
-{
- unsigned _numClasses;
- bool _shareLocation;
- int _numLocClasses;
-
- int _backgroundLabelId;
-
- typedef caffe::PriorBoxParameter_CodeType CodeType;
- CodeType _codeType;
-
- bool _varianceEncodedInTarget;
- int _keepTopK;
- float _confidenceThreshold;
-
- int _num;
- int _numPriors;
-
- float _nmsThreshold;
- int _topK;
-
- static const size_t _numAxes = 4;
- static const std::string _layerName;
-
-public:
- DetectionOutputLayer(LayerParams ¶ms);
- void allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
- void forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
-
- void checkInputs(const std::vector<Blob*> &inputs);
- void getCodeType(LayerParams ¶ms);
-
- template<typename T>
- T getParameter(const LayerParams ¶ms,
- const std::string ¶meterName,
- const size_t &idx = 0,
- const bool required = true,
- const T& defaultValue = T());
-
- bool getParameterDict(const LayerParams ¶ms,
- const std::string ¶meterName,
- DictValue& result);
-
- typedef std::map<int, std::vector<caffe::NormalizedBBox> > LabelBBox;
-
- // Clip the caffe::NormalizedBBox such that the range for each corner is [0, 1].
- void ClipBBox(const caffe::NormalizedBBox& bbox, caffe::NormalizedBBox* clip_bbox);
-
- // Decode a bbox according to a prior bbox.
- void DecodeBBox(const caffe::NormalizedBBox& prior_bbox,
- const std::vector<float>& prior_variance, const CodeType code_type,
- const bool variance_encoded_in_target, const caffe::NormalizedBBox& bbox,
- caffe::NormalizedBBox* decode_bbox);
-
- // Decode a set of bboxes according to a set of prior bboxes.
- void DecodeBBoxes(const std::vector<caffe::NormalizedBBox>& prior_bboxes,
- const std::vector<std::vector<float> >& prior_variances,
- const CodeType code_type, const bool variance_encoded_in_target,
- const std::vector<caffe::NormalizedBBox>& bboxes,
- std::vector<caffe::NormalizedBBox>* decode_bboxes);
-
- // Decode all bboxes in a batch.
- void DecodeBBoxesAll(const std::vector<LabelBBox>& all_loc_pred,
- const std::vector<caffe::NormalizedBBox>& prior_bboxes,
- const std::vector<std::vector<float> >& prior_variances,
- const size_t num, const bool share_location,
- const int num_loc_classes, const int background_label_id,
- const CodeType code_type, const bool variance_encoded_in_target,
- std::vector<LabelBBox>* all_decode_bboxes);
-
- // Get prior bounding boxes from prior_data.
- // prior_data: 1 x 2 x num_priors * 4 x 1 blob.
- // num_priors: number of priors.
- // prior_bboxes: stores all the prior bboxes in the format of caffe::NormalizedBBox.
- // prior_variances: stores all the variances needed by prior bboxes.
- void GetPriorBBoxes(const float* priorData, const int& numPriors,
- std::vector<caffe::NormalizedBBox>* priorBBoxes,
- std::vector<std::vector<float> >* priorVariances);
-
- // Scale the caffe::NormalizedBBox w.r.t. height and width.
- void ScaleBBox(const caffe::NormalizedBBox& bbox, const int height, const int width,
- caffe::NormalizedBBox* scale_bbox);
-
- // Do non maximum suppression given bboxes and scores.
- // Inspired by Piotr Dollar's NMS implementation in EdgeBox.
- // https://goo.gl/jV3JYS
- // bboxes: a set of bounding boxes.
- // scores: a set of corresponding confidences.
- // score_threshold: a threshold used to filter detection results.
- // nms_threshold: a threshold used in non maximum suppression.
- // top_k: if not -1, keep at most top_k picked indices.
- // indices: the kept indices of bboxes after nms.
- void ApplyNMSFast(const std::vector<caffe::NormalizedBBox>& bboxes,
- const std::vector<float>& scores, const float score_threshold,
- const float nms_threshold, const int top_k, std::vector<int>* indices);
-
-
- // Do non maximum suppression given bboxes and scores.
- // bboxes: a set of bounding boxes.
- // scores: a set of corresponding confidences.
- // threshold: the threshold used in non maximu suppression.
- // top_k: if not -1, keep at most top_k picked indices.
- // reuse_overlaps: if true, use and update overlaps; otherwise, always
- // compute overlap.
- // overlaps: a temp place to optionally store the overlaps between pairs of
- // bboxes if reuse_overlaps is true.
- // indices: the kept indices of bboxes after nms.
- void ApplyNMS(const std::vector<caffe::NormalizedBBox>& bboxes,
- const std::vector<float>& scores,
- const float threshold, const int top_k, const bool reuse_overlaps,
- std::map<int, std::map<int, float> >* overlaps, std::vector<int>* indices);
-
- void ApplyNMS(const bool* overlapped, const int num, std::vector<int>* indices);
-
- // Get confidence predictions from conf_data.
- // conf_data: num x num_preds_per_class * num_classes blob.
- // num: the number of images.
- // num_preds_per_class: number of predictions per class.
- // num_classes: number of classes.
- // conf_preds: stores the confidence prediction, where each item contains
- // confidence prediction for an image.
- void GetConfidenceScores(const float* conf_data, const int num,
- const int num_preds_per_class, const int num_classes,
- std::vector<std::map<int, std::vector<float> > >* conf_scores);
-
- // Get confidence predictions from conf_data.
- // conf_data: num x num_preds_per_class * num_classes blob.
- // num: the number of images.
- // num_preds_per_class: number of predictions per class.
- // num_classes: number of classes.
- // class_major: if true, data layout is
- // num x num_classes x num_preds_per_class; otherwise, data layerout is
- // num x num_preds_per_class * num_classes.
- // conf_preds: stores the confidence prediction, where each item contains
- // confidence prediction for an image.
- void GetConfidenceScores(const float* conf_data, const int num,
- const int num_preds_per_class, const int num_classes,
- const bool class_major,
- std::vector<std::map<int, std::vector<float> > >* conf_scores);
-
- // Get location predictions from loc_data.
- // loc_data: num x num_preds_per_class * num_loc_classes * 4 blob.
- // num: the number of images.
- // num_preds_per_class: number of predictions per class.
- // num_loc_classes: number of location classes. It is 1 if share_location is
- // true; and is equal to number of classes needed to predict otherwise.
- // share_location: if true, all classes share the same location prediction.
- // loc_preds: stores the location prediction, where each item contains
- // location prediction for an image.
- void GetLocPredictions(const float* loc_data, const int num,
- const int num_preds_per_class, const int num_loc_classes,
- const bool share_location, std::vector<LabelBBox>* loc_preds);
-
- // Get max scores with corresponding indices.
- // scores: a set of scores.
- // threshold: only consider scores higher than the threshold.
- // top_k: if -1, keep all; otherwise, keep at most top_k.
- // score_index_vec: store the sorted (score, index) pair.
- void GetMaxScoreIndex(const std::vector<float>& scores, const float threshold,
- const int top_k, std::vector<std::pair<float, int> >* score_index_vec);
-
- // Compute the jaccard (intersection over union IoU) overlap between two bboxes.
- float JaccardOverlap(const caffe::NormalizedBBox& bbox1, const caffe::NormalizedBBox& bbox2,
- const bool normalized = true);
-
- // Compute the intersection between two bboxes.
- void IntersectBBox(const caffe::NormalizedBBox& bbox1, const caffe::NormalizedBBox& bbox2,
- caffe::NormalizedBBox* intersect_bbox);
-
- // Compute bbox size.
- float BBoxSize(const caffe::NormalizedBBox& bbox, const bool normalized = true);
-};
-}
-}
-#endif
diff --git a/contrib/modules/dnn/src/layers/elementwise_layers.cpp b/contrib/modules/dnn/src/layers/elementwise_layers.cpp
deleted file mode 100644
index 6ed7558..0000000
--- a/contrib/modules/dnn/src/layers/elementwise_layers.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-#include "../precomp.hpp"
-#include "elementwise_layers.hpp"
-
-namespace cv
-{
-namespace dnn
-{
-
-#define ACTIVATION_CREATOR_FOR(_Layer, _Functor, ...) \
-Ptr<_Layer> _Layer::create() { \
- return return Ptr<_Layer>( new ElementWiseLayer<_Functor>(_Functor()) ); }
-
-
-Ptr<ReLULayer> ReLULayer::create(double negativeSlope)
-{
- return Ptr<ReLULayer>(new ElementWiseLayer<ReLUFunctor>(ReLUFunctor(negativeSlope)));
-}
-
-Ptr<TanHLayer> TanHLayer::create()
-{
- return Ptr<TanHLayer>(new ElementWiseLayer<TanHFunctor>());
-}
-
-Ptr<SigmoidLayer> SigmoidLayer::create()
-{
- return Ptr<SigmoidLayer>(new ElementWiseLayer<SigmoidFunctor>());
-}
-
-Ptr<AbsLayer> AbsLayer::create()
-{
- return Ptr<AbsLayer>(new ElementWiseLayer<AbsValFunctor>());
-}
-
-Ptr<BNLLLayer> BNLLLayer::create()
-{
- return Ptr<BNLLLayer>(new ElementWiseLayer<BNLLFunctor>());
-}
-
-Ptr<PowerLayer> PowerLayer::create(double power /*= 1*/, double scale /*= 1*/, double shift /*= 0*/)
-{
- const PowerFunctor f(power, scale, shift);
- return Ptr<PowerLayer>(new ElementWiseLayer<PowerFunctor>(f));
-}
-
-}
-}
\ No newline at end of file
diff --git a/contrib/modules/dnn/src/layers/elementwise_layers.hpp b/contrib/modules/dnn/src/layers/elementwise_layers.hpp
deleted file mode 100644
index 2f67f0a..0000000
--- a/contrib/modules/dnn/src/layers/elementwise_layers.hpp
+++ /dev/null
@@ -1,318 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_LAYERS_ELEMENTWISE_LAYERS_HPP__
-#define __OPENCV_DNN_LAYERS_ELEMENTWISE_LAYERS_HPP__
-#include "../precomp.hpp"
-#include "layers_common.hpp"
-#include <cmath>
-#include <opencv2/dnn/all_layers.hpp>
-#include <opencv2/core/ocl.hpp>
-#ifdef HAVE_OPENCL
-#include "modules/dnn/opencl_kernels_dnn.hpp"
-#endif
-
-namespace cv
-{
-namespace dnn
-{
-
-using std::abs;
-using std::exp;
-using std::tanh;
-using std::pow;
-
-template<typename Func>
-class ElementWiseLayer : public Func::Layer
-{
- bool useOpenCL;
- Func func;
-
- template<typename Dtype>
- class PBody : public cv::ParallelLoopBody
- {
- Func &func;
- Dtype *data;
- public:
-
- PBody(Mat &mat, Func &func_) :
- func(func_), data(mat.ptr<Dtype>())
- {}
-
- void operator()(const Range &r) const
- {
- for (int i = r.start; i < r.end; i++)
- data[i] = func(data[i]);
- }
- };
-
-public:
-
- ElementWiseLayer() {}
- ElementWiseLayer(const Func &f) : func(f) {}
-
- void allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
- {
- useOpenCL = ocl::useOpenCL();
-
- outputs.resize(inputs.size());
- for (size_t i = 0; i < inputs.size(); i++)
- {
- outputs[i].shareFrom(*inputs[i]); //no data copy
-
- //hotfix: shareFrom doesn't provide properly Mat/UMat switching
- if (useOpenCL)
- outputs[i].umatRef() = inputs[i]->umatRefConst();
- else
- outputs[i].matRef() = inputs[i]->matRefConst();
- }
- }
-
- void forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
- {
- #ifdef HAVE_OPENCL
- if (useOpenCL)
- forwardOCL(inputs, outputs);
- else
- #endif
- forwardCPU(inputs, outputs);
- }
-
- #ifdef HAVE_OPENCL
- void forwardOCL(std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
- {
- size_t wgSize = ocl::Device::getDefault().maxWorkGroupSize();
-
- for (size_t i = 0; i < inputs.size(); i++)
- {
- const UMat &src = inputs[i]->umatRefConst();
- UMat &dst = outputs[i].umatRef();
- CV_Assert(src.isContinuous() && dst.isContinuous() && !src.offset && !dst.offset);
-
- ocl::Kernel ker;
- CV_Assert(func.initKernel(ker, src));
- ker.set(0, (int)src.total());
- ker.set(1, ocl::KernelArg::PtrReadOnly(src));
- ker.set(2, ocl::KernelArg::PtrWriteOnly(dst));
-
- size_t gSize = src.total();
- CV_Assert(ker.run(1, &gSize, &wgSize, true));
- }
- }
- #endif
-
- void forwardCPU(std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
- {
- for (size_t i = 0; i < inputs.size(); i++)
- {
- const Mat &src = inputs[i]->matRefConst();
- Mat &dst = outputs[i].matRef();
- CV_Assert(src.ptr() == dst.ptr() && src.isContinuous());
-
- Range sizeRange = Range(0, dst.total());
- if (dst.type() == CV_32F)
- {
- cv::parallel_for_(sizeRange, PBody<float>(dst, func));
- }
- else if (dst.type() == CV_64F)
- {
- cv::parallel_for_(sizeRange, PBody<double>(dst, func));
- }
- else
- {
- CV_Error(Error::StsNotImplemented, "Only CV_32F and CV_64F blobs are supported");
- }
- }
- }
-};
-
-#ifdef HAVE_OPENCL
-static String oclGetTMacro(const UMat &m)
-{
- return String("-DT=") + ocl::typeToStr(m.type()) + String(" ");
-}
-#endif
-
-struct ReLUFunctor
-{
- typedef ReLULayer Layer;
-
- double slope;
-
- ReLUFunctor(double slope_)
- : slope(slope_) {}
-
- template<typename TFloat>
- inline TFloat operator()(TFloat x) const
- {
- return (x >= (TFloat)0) ? x : (TFloat)slope * x;
- }
-
- #ifdef HAVE_OPENCL
- bool initKernel(ocl::Kernel &ker, const UMat &src) const
- {
- const char *buildoptSlope = (slope == 0) ? "-DRELU_NO_SLOPE" : "";
- String buildopt = oclGetTMacro(src) + buildoptSlope;
-
- if (!ker.create("ReLUForward", ocl::dnn::activations_oclsrc, buildopt))
- return false;
-
- if (slope != 0)
- ker.set(3, (float)slope);
-
- return true;
- }
- #endif
-};
-
-struct TanHFunctor
-{
- typedef TanHLayer Layer;
-
- template<typename TFloat>
- inline TFloat operator()(TFloat x) const
- {
- return tanh(x);
- }
-
- #ifdef HAVE_OPENCL
- bool initKernel(ocl::Kernel &ker, const UMat &src) const
- {
- if (!ker.create("TanHForward", ocl::dnn::activations_oclsrc, oclGetTMacro(src)))
- return false;
- return true;
- }
- #endif
-};
-
-struct SigmoidFunctor
-{
- typedef SigmoidLayer Layer;
-
- template<typename TFloat>
- inline TFloat operator()(TFloat x) const
- {
- return (TFloat)1 / ((TFloat)1 + exp(-x));
- }
-
- #ifdef HAVE_OPENCL
- bool initKernel(ocl::Kernel &ker, const UMat &src) const
- {
- if (!ker.create("SigmoidForward", ocl::dnn::activations_oclsrc, oclGetTMacro(src)))
- return false;
- return true;
- }
- #endif
-};
-
-struct AbsValFunctor
-{
- typedef AbsLayer Layer;
-
- template<typename TFloat>
- inline TFloat operator()(TFloat x) const
- {
- return abs(x);
- }
-
- #ifdef HAVE_OPENCL
- bool initKernel(ocl::Kernel &ker, const UMat &src) const
- {
- if (!ker.create("AbsValForward", ocl::dnn::activations_oclsrc, oclGetTMacro(src)))
- return false;
- return true;
- }
- #endif
-};
-
-struct BNLLFunctor
-{
- typedef BNLLLayer Layer;
-
- template<typename TFloat>
- inline TFloat operator()(TFloat x) const
- {
- return log((TFloat)1 + exp(-abs(x)));
- }
-
- #ifdef HAVE_OPENCL
- bool initKernel(ocl::Kernel &ker, const UMat &src) const
- {
- if (!ker.create("BNLLForward", ocl::dnn::activations_oclsrc, oclGetTMacro(src)))
- return false;
- return true;
- }
- #endif
-};
-
-struct PowerFunctor
-{
- typedef PowerLayer Layer;
-
- double power, scale, shift;
-
- PowerFunctor(double power_, double scale_ = 1, double shift_ = 0)
- : power(power_), scale(scale_), shift(shift_) {}
-
- template<typename TFloat>
- inline TFloat operator()(TFloat x) const
- {
- return pow((TFloat)shift + (TFloat)scale * x, (TFloat)power);
- }
-
- #ifdef HAVE_OPENCL
- bool initKernel(ocl::Kernel &ker, const UMat &src) const
- {
- if (!ker.create("PowForward", ocl::dnn::activations_oclsrc, oclGetTMacro(src)))
- return false;
-
- ker.set(3, (float)power);
- ker.set(4, (float)scale);
- ker.set(5, (float)shift);
-
- return true;
- }
- #endif
-};
-
-}
-}
-#endif
diff --git a/contrib/modules/dnn/src/layers/eltwise_layer.cpp b/contrib/modules/dnn/src/layers/eltwise_layer.cpp
deleted file mode 100755
index ecd09e7..0000000
--- a/contrib/modules/dnn/src/layers/eltwise_layer.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "../precomp.hpp"
-#include "layers_common.hpp"
-#include "eltwise_layer.hpp"
-
-namespace cv
-{
-namespace dnn
-{
- EltwiseLayerImpl::EltwiseLayerImpl(EltwiseOp op_, const std::vector<int> &coeffs_)
- {
- op = op_;
- coeffs = coeffs_;
- }
-
- void EltwiseLayerImpl::allocate(const std::vector<Blob *> &inputs, std::vector<Blob> &outputs)
- {
- CV_Assert(2 <= inputs.size());
- CV_Assert(coeffs.size() == 0 || coeffs.size() == inputs.size());
- CV_Assert(op == SUM || coeffs.size() == 0);
-
- const BlobShape &shape0 = inputs[0]->shape();
- for (size_t i = 1; i < inputs.size(); ++i)
- {
- CV_Assert(shape0 == inputs[i]->shape());
- }
- outputs.resize(1);
- outputs[0].create(shape0);
- }
-
- void EltwiseLayerImpl::forward(std::vector<Blob *> &inputs, std::vector<Blob> &outputs)
- {
- switch (op)
- {
- case SUM:
- {
- CV_Assert(coeffs.size() == 0 || coeffs.size() == inputs.size());
- Mat& output = outputs[0].matRef();
- output.setTo(0.);
- if (0 < coeffs.size())
- {
- for (size_t i = 0; i < inputs.size(); i++)
- {
- output += inputs[i]->matRefConst() * coeffs[i];
- }
- }
- else
- {
- for (size_t i = 0; i < inputs.size(); i++)
- {
- output += inputs[i]->matRefConst();
- }
- }
- }
- break;
- case PROD:
- {
- Mat& output = outputs[0].matRef();
- output.setTo(1.);
- for (size_t i = 0; i < inputs.size(); i++)
- {
- output = output.mul(inputs[i]->matRefConst());
- }
- }
- break;
- case MAX:
- {
- Mat& output = outputs[0].matRef();
- cv::max(inputs[0]->matRefConst(), inputs[1]->matRefConst(), output);
- for (size_t i = 2; i < inputs.size(); i++)
- {
- cv::max(output, inputs[i]->matRefConst(), output);
- }
- }
- break;
- default:
- CV_Assert(0);
- break;
- };
- }
-
- Ptr<EltwiseLayer> EltwiseLayer::create(EltwiseOp op, const std::vector<int> &coeffs)
- {
- return Ptr<EltwiseLayer>(new EltwiseLayerImpl(op, coeffs));
- }
-}
-}
diff --git a/contrib/modules/dnn/src/layers/eltwise_layer.hpp b/contrib/modules/dnn/src/layers/eltwise_layer.hpp
deleted file mode 100755
index c67575c..0000000
--- a/contrib/modules/dnn/src/layers/eltwise_layer.hpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_LAYERS_ELTWISE_LAYER_HPP__
-#define __OPENCV_DNN_LAYERS_ELTWISE_LAYER_HPP__
-#include "../precomp.hpp"
-#include <opencv2/dnn/all_layers.hpp>
-
-namespace cv
-{
-namespace dnn
-{
- class EltwiseLayerImpl : public EltwiseLayer
- {
- EltwiseOp op;
- std::vector<int> coeffs;
- public:
- EltwiseLayerImpl(EltwiseOp op, const std::vector<int> &coeffs);
- void allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
- void forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
- };
-}
-}
-#endif
diff --git a/contrib/modules/dnn/src/layers/flatten_layer.cpp b/contrib/modules/dnn/src/layers/flatten_layer.cpp
deleted file mode 100644
index dc80703..0000000
--- a/contrib/modules/dnn/src/layers/flatten_layer.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "../precomp.hpp"
-#include "layers_common.hpp"
-#include "flatten_layer.hpp"
-#include <float.h>
-#include <algorithm>
-
-namespace cv
-{
-namespace dnn
-{
-
-FlattenLayer::FlattenLayer(LayerParams ¶ms) : Layer(params)
-{
- _startAxis = params.get<int>("axis", 1);
- _endAxis = params.get<int>("end_axis", -1);
-}
-
-void FlattenLayer::checkInputs(const std::vector<Blob*> &inputs)
-{
- CV_Assert(inputs.size() > 0);
- for (size_t i = 1; i < inputs.size(); i++)
- {
- for (size_t j = 0; j < _numAxes; j++)
- {
- CV_Assert(inputs[i]->shape()[j] == inputs[0]->shape()[j]);
- }
- }
-}
-
-void FlattenLayer::allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- checkInputs(inputs);
-
- _numAxes = inputs[0]->dims();
- _endAxis = inputs[0]->canonicalAxis(_endAxis);
- CV_Assert(_startAxis >= 0);
- CV_Assert(_endAxis >= _startAxis && _endAxis < (int)_numAxes);
-
- size_t flattenedDimensionSize = 1;
- for (int i = _startAxis; i <= _endAxis; i++)
- {
- flattenedDimensionSize *= inputs[0]->size(i);
- }
-
- std::vector<int> outputShapeVec;
- for (int i = 0; i < _startAxis; i++)
- {
- outputShapeVec.push_back(inputs[0]->size(i));
- }
- outputShapeVec.push_back(flattenedDimensionSize);
- for (size_t i = _endAxis + 1; i < _numAxes; i++)
- {
- outputShapeVec.push_back(inputs[0]->size(i));
- }
- CV_Assert(outputShapeVec.size() <= 4);
-
- resultShape = BlobShape(outputShapeVec);
-
- for (size_t i = 0; i < inputs.size(); i++)
- {
- //in-place
- outputs[i].shareFrom(*inputs[i]);
- outputs[i].reshape(resultShape);
- }
-}
-
-void FlattenLayer::forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- for (size_t j = 0; j < inputs.size(); j++)
- {
- outputs[j].shareFrom(*inputs[j]);
- outputs[j].reshape(resultShape);
- }
-}
-}
-}
diff --git a/contrib/modules/dnn/src/layers/flatten_layer.hpp b/contrib/modules/dnn/src/layers/flatten_layer.hpp
deleted file mode 100644
index 1aab0eb..0000000
--- a/contrib/modules/dnn/src/layers/flatten_layer.hpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_LAYERS_FLATTEN_LAYER_HPP__
-#define __OPENCV_DNN_LAYERS_FLATTEN_LAYER_HPP__
-#include "../precomp.hpp"
-
-namespace cv
-{
-namespace dnn
-{
-class FlattenLayer : public Layer
-{
- int _startAxis;
- int _endAxis;
- size_t _numAxes;
-
- BlobShape resultShape;
-
-public:
- FlattenLayer(LayerParams ¶ms);
- void allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
- void forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
-
- void checkInputs(const std::vector<Blob*> &inputs);
-};
-}
-}
-#endif
diff --git a/contrib/modules/dnn/src/layers/fully_connected_layer.cpp b/contrib/modules/dnn/src/layers/fully_connected_layer.cpp
deleted file mode 100644
index bb58027..0000000
--- a/contrib/modules/dnn/src/layers/fully_connected_layer.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "../precomp.hpp"
-#include "layers_common.hpp"
-#include "fully_connected_layer.hpp"
-#include "op_blas.hpp"
-#include <opencv2/dnn/shape_utils.hpp>
-#include <opencv2/core/ocl.hpp>
-
-namespace cv
-{
-namespace dnn
-{
-
-FullyConnectedLayerImpl::FullyConnectedLayerImpl(int axis_)
-{
- axis = axis_;
-}
-
-void FullyConnectedLayerImpl::allocate(const std::vector<Blob*> &input, std::vector<Blob> &output)
-{
- CV_Assert(input.size() > 0);
- CV_Assert(1 <= blobs.size() && blobs.size() <= 2);
- CV_Assert(blobs[0].dims() == 2);
-
- bias = (blobs.size() >= 1);
- axisCan = input[0]->canonicalAxis(axis);
- dtype = input[0]->type();
- numOutput = blobs[0].size(0);
- innerSize = blobs[0].size(1);
- outerSize = input[0]->total(0, axisCan);
-
- CV_Assert((size_t)innerSize == input[0]->total(axisCan));
- CV_Assert(!bias || (size_t)numOutput == blobs[1].total());
-
- useOpenCL = ocl::useOpenCL();
- int allocFlags = useOpenCL ? Blob::ALLOC_UMAT : Blob::ALLOC_UMAT;
-
- biasOnesBlob.create(Shape(outerSize, 1), dtype, allocFlags);
- biasOnesBlob.setTo(1);
-
- output.resize(input.size());
- for (size_t i = 0; i < input.size(); i++)
- {
- CV_Assert(i == 0 || (input[i]->equalShape(*input[0]) && input[i]->type() == dtype));
- Shape outShape = Shape(outerSize, numOutput);
- output[i].create(outShape, dtype, allocFlags);
- }
-}
-
-void FullyConnectedLayerImpl::forward(std::vector<Blob*> &input, std::vector<Blob> &output)
-{
- #ifdef HAVE_OPENCL
- if (useOpenCL)
- forward_<UMat>(input, output);
- else
- #endif
- forward_<Mat>(input, output);
-}
-
-template<typename XMat>
-void FullyConnectedLayerImpl::forward_(std::vector<Blob *> &input, std::vector<Blob> &output)
-{
- const XMat &weight = blobs[0].getRefConst<XMat>();
- const XMat *biasMat = NULL, *biasOnesMat = NULL;
- if (bias)
- {
- biasOnesMat = &biasOnesBlob.getRefConst<XMat>();
- biasMat = &blobs[1].getRefConst<XMat>();
- }
-
- for (size_t i = 0; i < input.size(); i++)
- {
- const XMat srcMat = reshaped(input[i]->getRefConst<XMat>(), Shape(outerSize, innerSize));
- XMat dstMat = reshaped(output[i].getRef<XMat>(), Shape(outerSize, numOutput));
- dnn::gemm(srcMat, weight, 1, dstMat, 0, GEMM_2_T);
-
- if (bias)
- dnn::gemm(*biasOnesMat, *biasMat, 1, dstMat, 1);
- }
-}
-
-
-Ptr<InnerProductLayer> InnerProductLayer::create(int axis)
-{
- return Ptr<InnerProductLayer>(new FullyConnectedLayerImpl(axis));
-}
-
-}
-}
diff --git a/contrib/modules/dnn/src/layers/fully_connected_layer.hpp b/contrib/modules/dnn/src/layers/fully_connected_layer.hpp
deleted file mode 100644
index 0cf5940..0000000
--- a/contrib/modules/dnn/src/layers/fully_connected_layer.hpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_LAYERS_FULLY_CONNECTED_LAYER_HPP__
-#define __OPENCV_DNN_LAYERS_FULLY_CONNECTED_LAYER_HPP__
-#include "../precomp.hpp"
-#include <opencv2/dnn/all_layers.hpp>
-
-namespace cv
-{
-namespace dnn
-{
-
-class FullyConnectedLayerImpl : public InnerProductLayer
-{
- int axisCan, dtype;
- int numOutput, innerSize, outerSize;
- bool bias, useOpenCL;
- Blob biasOnesBlob;
-
- template<typename XMat>
- void forward_(std::vector<Blob*> &input, std::vector<Blob> &output);
-
-public:
-
- FullyConnectedLayerImpl(int axisCan = 1);
- void allocate(const std::vector<Blob*> &input, std::vector<Blob> &output);
- void forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
-};
-
-}
-}
-#endif
diff --git a/contrib/modules/dnn/src/layers/layers_common.cpp b/contrib/modules/dnn/src/layers/layers_common.cpp
deleted file mode 100644
index c1f586a..0000000
--- a/contrib/modules/dnn/src/layers/layers_common.cpp
+++ /dev/null
@@ -1,192 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "layers_common.hpp"
-
-namespace cv
-{
-namespace dnn
-{
-
-namespace util
-{
-
-std::string makeName(const std::string& str1, const std::string& str2)
-{
- return str1 + str2;
-}
-
-bool getParameter(LayerParams ¶ms, const std::string& nameBase, const std::string& nameAll, int ¶meterH, int ¶meterW, bool hasDefault = false, const int& defaultValue = 0)
-{
- std::string nameH = makeName(nameBase, std::string("_h"));
- std::string nameW = makeName(nameBase, std::string("_w"));
- std::string nameAll_ = nameAll;
- if(nameAll_ == "")
- {
- nameAll_ = nameBase;
- }
-
- if (params.has(nameH) && params.has(nameW))
- {
- parameterH = params.get<int>(nameH);
- parameterW = params.get<int>(nameW);
- return true;
- }
- else
- {
- if (params.has(nameAll_))
- {
- parameterH = parameterW = params.get<int>(nameAll_);
- return true;
- }
- else
- {
- if(hasDefault)
- {
- parameterH = parameterW = defaultValue;
- return true;
- }
- else
- {
- return false;
- }
- }
- }
-}
-
-void getKernelSize(LayerParams ¶ms, int &kernelH, int &kernelW)
-{
- if(!util::getParameter(params, "kernel", "kernel_size", kernelH, kernelW))
- {
- CV_Error(cv::Error::StsBadArg, "kernel_size (or kernel_h and kernel_w) not specified");
- }
-
- CV_Assert(kernelH > 0 && kernelW > 0);
-}
-
-void getStrideAndPadding(LayerParams ¶ms, int &padH, int &padW, int &strideH, int &strideW, cv::String& padMode)
-{
- util::getParameter(params, "pad", "pad", padH, padW, true, 0);
- util::getParameter(params, "stride", "stride", strideH, strideW, true, 1);
-
- padMode = "";
- if (params.has("pad_mode"))
- {
- padMode = params.get<String>("pad_mode");
- }
-
- CV_Assert(padH >= 0 && padW >= 0 && strideH > 0 && strideW > 0);
-}
-}
-
-
-void getPoolingKernelParams(LayerParams ¶ms, int &kernelH, int &kernelW, bool &globalPooling,
- int &padH, int &padW, int &strideH, int &strideW, cv::String &padMode)
-{
- util::getStrideAndPadding(params, padH, padW, strideH, strideW, padMode);
-
- globalPooling = params.has("global_pooling");
-
- if (globalPooling)
- {
- if(params.has("kernel_h") || params.has("kernel_w") || params.has("kernel_size"))
- {
- CV_Error(cv::Error::StsBadArg, "In global_pooling mode, kernel_size (or kernel_h and kernel_w) cannot be specified");
- }
- if(padH != 0 || padW != 0 || strideH != 1 || strideW != 1)
- {
- CV_Error(cv::Error::StsBadArg, "In global_pooling mode, pad_h and pad_w must be = 0, and stride_h and stride_w must be = 1");
- }
- }
- else
- {
- util::getKernelSize(params, kernelH, kernelW);
- }
-}
-
-void getConvolutionKernelParams(LayerParams ¶ms, int &kernelH, int &kernelW, int &padH, int &padW,
- int &strideH, int &strideW, int &dilationH, int &dilationW, cv::String &padMode)
-{
- util::getKernelSize(params, kernelH, kernelW);
- util::getStrideAndPadding(params, padH, padW, strideH, strideW, padMode);
-
- util::getParameter(params, "dilation", "dilation", dilationH, dilationW, true, 1);
-
- CV_Assert(dilationH > 0 && dilationW > 0);
-}
-
-// From TensorFlow code:
-// Total padding on rows and cols is
-// Pr = (R' - 1) * S + Kr - R
-// Pc = (C' - 1) * S + Kc - C
-// where (R', C') are output dimensions, (R, C) are input dimensions, S
-// is stride, (Kr, Kc) are filter dimensions.
-// We pad Pr/2 on the left and Pr - Pr/2 on the right, Pc/2 on the top
-// and Pc - Pc/2 on the bottom. When Pr or Pc is odd, this means
-// we pad more on the right and bottom than on the top and left.
-void getConvPoolOutParams(const int inputH, const int inputW, const cv::Size &kernel,
- const cv::Size &stride, cv::Size& pad, const cv::String &padMode,
- int &outH, int &outW)
-{
- if (padMode == "VALID")
- {
- outH = (inputH - kernel.height + stride.height) / stride.height;
- outW = (inputW - kernel.width + stride.width) / stride.width;
- pad = cv::Size(0,0);
- }
- else if (padMode == "SAME")
- {
- outH = (inputH - 1 + stride.height) / stride.height;
- outW = (inputW - 1 + stride.width) / stride.width;
- int Ph = std::max(0, (outH - 1) * stride.height + kernel.height - inputH);
- int Pw = std::max(0, (outW - 1) * stride.width + kernel.width - inputW);
- // For odd values of total padding, add more padding at the 'right'
- // side of the given dimension.
- pad = cv::Size(Pw / 2, Ph / 2);
- }
- else
- {
- CV_Error(Error::StsError, "Unsupported padding mode");
- }
-}
-
-}
-}
diff --git a/contrib/modules/dnn/src/layers/layers_common.hpp b/contrib/modules/dnn/src/layers/layers_common.hpp
deleted file mode 100644
index b27afaf..0000000
--- a/contrib/modules/dnn/src/layers/layers_common.hpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_LAYERS_LAYERS_COMMON_HPP__
-#define __OPENCV_DNN_LAYERS_LAYERS_COMMON_HPP__
-#include <opencv2/dnn.hpp>
-#include "op_blas.hpp"
-#include "op_im2col.hpp"
-
-namespace cv
-{
-namespace dnn
-{
-
-void getConvolutionKernelParams(LayerParams ¶ms, int &kernelH, int &kernelW, int &padH, int &padW,
- int &strideH, int &strideW, int &dilationH, int &dilationW, cv::String& padMode);
-
-void getPoolingKernelParams(LayerParams ¶ms, int &kernelH, int &kernelW, bool &globalPooling,
- int &padH, int &padW, int &strideH, int &strideW, cv::String& padMode);
-
-void getConvPoolOutParams(const int inputH, const int inputW, const cv::Size& kernel,
- const cv::Size& stride, cv::Size &pad, const cv::String& padMode,
- int &outH, int &outW);
-}
-}
-
-#endif
diff --git a/contrib/modules/dnn/src/layers/lrn_layer.cpp b/contrib/modules/dnn/src/layers/lrn_layer.cpp
deleted file mode 100644
index e2c0ec7..0000000
--- a/contrib/modules/dnn/src/layers/lrn_layer.cpp
+++ /dev/null
@@ -1,260 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "../precomp.hpp"
-#include "layers_common.hpp"
-#include "lrn_layer.hpp"
-#include "modules/dnn/opencl_kernels_dnn.hpp"
-#include <opencv2/imgproc.hpp>
-#include <opencv2/core/ocl.hpp>
-#include <opencv2/dnn/shape_utils.hpp>
-#include <algorithm>
-
-namespace cv
-{
-namespace dnn
-{
-
-LRNLayerImpl::LRNLayerImpl(int type_, int size_, double alpha_, double beta_, double bias_, bool normBySize_)
-{
- type = type_;
- size = size_;
- alpha = alpha_;
- beta = beta_;
- bias = bias_;
- normBySize = normBySize_;
-}
-
-void LRNLayerImpl::allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- CV_Assert(inputs.size() == 1 && inputs[0]->dims() == 4);
- CV_Assert(type == CHANNEL_NRM || type == SPATIAL_NRM);
- useOpenCL = cv::ocl::useOpenCL();
-
- if (type == SPATIAL_NRM && !useOpenCL)
- buf.create(inputs[0]->shape().slice(2), inputs[0]->type(), Blob::ALLOC_MAT);
- if (type == CHANNEL_NRM && useOpenCL)
- buf.create(inputs[0]->shape().slice(2), inputs[0]->type(), Blob::ALLOC_UMAT);
-
- outputs.resize(1);
- outputs[0].create(inputs[0]->shape(), inputs[0]->type());
-}
-
-void LRNLayerImpl::forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- Blob &src = *inputs[0];
- Blob &dst = outputs[0];
-
- switch (type)
- {
- case CHANNEL_NRM:
- channelNoramlization(src, dst);
- break;
- case SPATIAL_NRM:
- spatialNormalization(src, dst);
- break;
- default:
- CV_Error(Error::StsNotImplemented, "Unimplemented mode of LRN layer");
- break;
- }
-}
-
-template<typename XMat>
-static XMat getPlane(XMat &m, int n, int cn)
-{
- return reshaped(slice(m, n, cn), BlobShape::like(m).slice(2));
-}
-
-void LRNLayerImpl::channelNoramlization(Blob &src, Blob &dst)
-{
- if (!useOpenCL)
- channelNoramlization_<Mat>(src, dst);
- else
- {
- //channelNoramlization_ocl(src.getRefConst<UMat>(), dst.getRef<UMat>()); //consumes a lot of memory
- channelNoramlization_<UMat>(src, dst);
- }
-}
-
-template<typename XMat>
-void LRNLayerImpl::channelNoramlization_(Blob &srcBlob, Blob &dstBlob)
-{
- int num = srcBlob.num();
- int channels = srcBlob.channels();
- int ksize = (size - 1) / 2;
- int sizeNormFactor = normBySize ? size : 1;
-
- XMat srcMat = srcBlob.getRefConst<XMat>();
- XMat dstMat = dstBlob.getRef<XMat>();
-
- for (int n = 0; n < num; n++)
- {
- XMat accum = getPlane(dstMat, n, channels-1); //trick for memory saving
- accum.setTo(0);
-
- for (int cn = 0; cn < std::min(ksize, channels); cn++)
- cv::accumulateSquare(getPlane(srcMat, n, cn), accum);
-
- for (int cn = 0; cn < channels; cn++)
- {
- if (cn + ksize < channels)
- {
- cv::accumulateSquare(getPlane(srcMat, n, cn + ksize), accum);
- }
-
- if (cn - ksize - 1 >= 0)
- {
- //subtractSquare
- XMat left = getPlane(srcMat, n, cn - ksize - 1);
- cv::pow(left, 2, left);
- cv::subtract(accum, left, accum);
- }
-
- XMat dst = getPlane(dstMat, n, cn);
- accum.convertTo(dst, dst.type(), alpha/sizeNormFactor, bias);
- cv::pow(dst, beta, dst);
- cv::divide(getPlane(srcMat, n, cn), dst, dst);
- }
- }
-}
-
-bool LRNLayerImpl::channelNoramlization_ocl(const UMat &src, UMat &dst)
-{
-#ifdef HAVE_OPENCL
- if (src.offset != 0 || dst.offset != 0) //TODO: add offset
- return false;
-
- String buildOpts = String("-DT=") + ocl::typeToStr(src.type());
-
- ocl::Kernel kerScale("LRNFillScale", ocl::dnn::lrn_oclsrc, buildOpts);
- if (kerScale.empty())
- return false;
-
- ocl::Kernel kerOutput("LRNComputeOutput", ocl::dnn::lrn_oclsrc, buildOpts);
- if (kerOutput.empty())
- return false;
-
- Shape shape = Shape::like(src);
- int ksize = (size - 1) / 2;
- int sizeNormFactor = normBySize ? size : 1;
- // TODO: add bias
- size_t wgSize = ocl::Device::getDefault().maxWorkGroupSize();
- UMat &scaleBuf = buf.umatRef();
-
- size_t nthreads = (size_t)(shape.total() / shape[1]);
- kerScale.args((int)nthreads,
- ocl::KernelArg::PtrReadOnly(src), shape[0], shape[1], shape[2], shape[3],
- size, (float)(alpha/sizeNormFactor), (float)ksize, ocl::KernelArg::PtrWriteOnly(scaleBuf));
- if (!kerScale.run(1, &nthreads, &wgSize, true))
- return false;
-
- nthreads = (size_t)shape.total();
- kerOutput.args((int)nthreads,
- ocl::KernelArg::PtrReadOnly(src), ocl::KernelArg::PtrReadOnly(scaleBuf),
- -beta, ocl::KernelArg::PtrWriteOnly(dst) );
- if (!kerOutput.run(1, &nthreads, &wgSize, true))
- return false;
-
- return true;
-#else
- (void)src;
- (void)dst;
- return false;
-#endif
-}
-
-void LRNLayerImpl::spatialNormalization(Blob &src, Blob &dst)
-{
- if (!useOpenCL)
- spatialNormalization_<Mat>(src, dst);
- else
- spatialNormalization_<UMat>(src, dst);
-}
-
-//TODO: fix cv::boxFilter with BORDER_ISOLATED flag in CPU mode
-template<>
-void LRNLayerImpl::sqrBoxFilter_<Mat>(const Mat &src, Mat &dst)
-{
- Mat srcRawWrapper(src.rows, src.cols, src.type(), src.data, src.step[0]);
- cv::sqrBoxFilter(srcRawWrapper, dst, dst.depth(), Size(size, size), Point(-1, -1), false, BORDER_CONSTANT);
-}
-
-template<>
-void LRNLayerImpl::sqrBoxFilter_<UMat>(const UMat &src, UMat &dst)
-{
- cv::sqrBoxFilter(src, dst, dst.depth(), Size(size, size), Point(-1, -1), false, BORDER_CONSTANT | BORDER_ISOLATED);
-}
-
-template<typename XMat>
-void LRNLayerImpl::spatialNormalization_(Blob &srcBlob, Blob &dstBlob)
-{
- int num = srcBlob.num();
- int channels = srcBlob.channels();
- int sizeNormFactor = normBySize ? size*size : 1;
-
- XMat srcMat = srcBlob.getRefConst<XMat>();
- XMat dstMat = dstBlob.getRef<XMat>();
-
- for (int n = 0; n < num; n++)
- {
- for (int cn = 0; cn < channels; cn++)
- {
- XMat src = getPlane(srcMat, n, cn);
- XMat dst = getPlane(dstMat, n, cn);
-
- sqrBoxFilter_(src, dst);
-
- dst.convertTo(dst, dst.type(), alpha/sizeNormFactor, bias);
- cv::pow(dst, beta, dst);
- cv::divide(src, dst, dst);
- }
- }
-}
-
-
-Ptr<LRNLayer> LRNLayer::create(int type, int size, double alpha, double beta, double bias,
- bool normBySize)
-{
- return Ptr<LRNLayer>(new LRNLayerImpl(type, size, alpha, beta, bias, normBySize));
-}
-
-}
-}
diff --git a/contrib/modules/dnn/src/layers/lrn_layer.hpp b/contrib/modules/dnn/src/layers/lrn_layer.hpp
deleted file mode 100644
index c9017b0..0000000
--- a/contrib/modules/dnn/src/layers/lrn_layer.hpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_LAYERS_LRN_LAYER_HPP__
-#define __OPENCV_DNN_LAYERS_LRN_LAYER_HPP__
-#include "../precomp.hpp"
-#include <opencv2/dnn/all_layers.hpp>
-
-namespace cv
-{
-namespace dnn
-{
-
-class LRNLayerImpl : public LRNLayer
-{
- bool useOpenCL;
- Blob buf;
-
- void channelNoramlization(Blob &src, Blob &dst);
- template<typename XMat>
- void channelNoramlization_(Blob &src, Blob &dst);
- bool channelNoramlization_ocl(const UMat &src, UMat &dst);
-
- void spatialNormalization(Blob &src, Blob &dst);
- template<typename XMat>
- void spatialNormalization_(Blob &src, Blob &dst);
- template<typename XMat>
- void sqrBoxFilter_(const XMat &src, XMat &dst);
-
-public:
-
- LRNLayerImpl(int type = CHANNEL_NRM, int size = 5, double alpha = 1, double beta = 0.75, double bias = 1,
- bool normBySize = true);
- void allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
- void forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
-};
-
-}
-}
-
-#endif
diff --git a/contrib/modules/dnn/src/layers/mvn_layer.cpp b/contrib/modules/dnn/src/layers/mvn_layer.cpp
deleted file mode 100644
index 36c48c4..0000000
--- a/contrib/modules/dnn/src/layers/mvn_layer.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "../precomp.hpp"
-#include "layers_common.hpp"
-#include "mvn_layer.hpp"
-#include <opencv2/dnn/shape_utils.hpp>
-
-namespace cv
-{
-namespace dnn
-{
-
-MVNLayerImpl::MVNLayerImpl(bool normVariance_, bool acrossChannels_, double eps_)
-{
- normVariance = normVariance_;
- acrossChannels = acrossChannels_;
- eps = eps_;
-}
-
-void MVNLayerImpl::allocate(const std::vector<Blob *> &inputs, std::vector<Blob> &outputs)
-{
- outputs.resize(inputs.size());
- for (size_t i = 0; i < inputs.size(); i++)
- {
- CV_Assert(!acrossChannels || inputs[i]->dims() >= 2);
- outputs[i].create(inputs[i]->shape(), inputs[i]->type());
- }
-}
-
-void MVNLayerImpl::forward(std::vector<Blob *> &inputs, std::vector<Blob> &outputs)
-{
- for (size_t inpIdx = 0; inpIdx < inputs.size(); inpIdx++)
- {
- Blob &inpBlob = *inputs[inpIdx];
- Blob &outBlob = outputs[inpIdx];
-
- int splitDim = (acrossChannels) ? 1 : 2;
- Shape workSize((int)inpBlob.total(0, splitDim), (int)inpBlob.total(splitDim));
- Mat inpMat = reshaped(inpBlob.matRefConst(), workSize);
- Mat outMat = reshaped(outBlob.matRef(), workSize);
-
- Scalar mean, dev;
- for (int i = 0; i < workSize[0]; i++)
- {
- Mat inpRow = inpMat.row(i);
- Mat outRow = outMat.row(i);
-
- cv::meanStdDev(inpRow, mean, (normVariance) ? dev : noArray());
- double alpha = (normVariance) ? 1/(eps + dev[0]) : 1;
- inpRow.convertTo(outRow, outRow.type(), alpha, -mean[0] * alpha);
- }
- }
-}
-
-
-Ptr<MVNLayer> MVNLayer::create(bool normVariance, bool acrossChannels, double eps)
-{
- return Ptr<MVNLayer>(new MVNLayerImpl(normVariance, acrossChannels, eps));
-}
-
-}
-}
diff --git a/contrib/modules/dnn/src/layers/mvn_layer.hpp b/contrib/modules/dnn/src/layers/mvn_layer.hpp
deleted file mode 100644
index 80b8954..0000000
--- a/contrib/modules/dnn/src/layers/mvn_layer.hpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_LAYERS_MVN_LAYER_HPP__
-#define __OPENCV_DNN_LAYERS_MVN_LAYER_HPP__
-#include "../precomp.hpp"
-#include <opencv2/dnn/all_layers.hpp>
-
-namespace cv
-{
-namespace dnn
-{
-
-class MVNLayerImpl : public MVNLayer
-{
-public:
-
- MVNLayerImpl(bool normVariance_ = true, bool acrossChannels_ = false, double eps_ = 1e-9);
- void allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
- void forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
-};
-
-}
-}
-#endif
diff --git a/contrib/modules/dnn/src/layers/normalize_bbox_layer.cpp b/contrib/modules/dnn/src/layers/normalize_bbox_layer.cpp
deleted file mode 100644
index 926465b..0000000
--- a/contrib/modules/dnn/src/layers/normalize_bbox_layer.cpp
+++ /dev/null
@@ -1,201 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "../precomp.hpp"
-#include "layers_common.hpp"
-#include "normalize_bbox_layer.hpp"
-#include "op_blas.hpp"
-
-#include <float.h>
-#include <algorithm>
-
-namespace cv
-{
-namespace dnn
-{
-
-const std::string NormalizeBBoxLayer::_layerName = std::string("NormalizeBBox");
-
-bool NormalizeBBoxLayer::getParameterDict(const LayerParams ¶ms,
- const std::string ¶meterName,
- DictValue& result)
-{
- if (!params.has(parameterName))
- {
- return false;
- }
-
- result = params.get(parameterName);
- return true;
-}
-
-template<typename T>
-T NormalizeBBoxLayer::getParameter(const LayerParams ¶ms,
- const std::string ¶meterName,
- const size_t &idx,
- const bool required,
- const T& defaultValue)
-{
- DictValue dictValue;
- bool success = getParameterDict(params, parameterName, dictValue);
- if(!success)
- {
- if(required)
- {
- std::string message = _layerName;
- message += " layer parameter does not contain ";
- message += parameterName;
- message += " parameter.";
- CV_Error(Error::StsBadArg, message);
- }
- else
- {
- return defaultValue;
- }
- }
- return dictValue.get<T>(idx);
-}
-
-NormalizeBBoxLayer::NormalizeBBoxLayer(LayerParams ¶ms) : Layer(params)
-{
- _eps = getParameter<float>(params, "eps", 0, false, 1e-10f);
- _across_spatial = getParameter<bool>(params, "across_spatial");
- _channel_shared = getParameter<bool>(params, "channel_shared");
-}
-
-void NormalizeBBoxLayer::checkInputs(const std::vector<Blob*> &inputs)
-{
- CV_Assert(inputs.size() > 0);
- for (size_t i = 1; i < inputs.size(); i++)
- {
- for (size_t j = 0; j < _numAxes; j++)
- {
- CV_Assert(inputs[i]->shape()[j] == inputs[0]->shape()[j]);
- }
- }
- CV_Assert(inputs[0]->dims() > 2);
-}
-
-void NormalizeBBoxLayer::allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- checkInputs(inputs);
-
- _num = inputs[0]->num();
- _channels = inputs[0]->shape()[1];
- _rows = inputs[0]->shape()[2];
- _cols = inputs[0]->shape()[3];
-
- _channelSize = _rows * _cols;
- _imageSize = _channelSize * _channels;
-
- _buffer = Mat(_channels, _channelSize, CV_32F);
-
- _sumChannelMultiplier = Mat(_channels, 1, CV_32F, Scalar(1.0));
- _sumSpatialMultiplier = Mat(1, _channelSize, CV_32F, Scalar(1.0));
-
- _scale = blobs[0];
-
- for(size_t i = 0; i < inputs.size(); i++)
- {
- outputs[i].create(BlobShape(inputs[0]->shape()));
- }
-}
-
-void NormalizeBBoxLayer::forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- Mat zeroBuffer(_channels, _channelSize, CV_32F, Scalar(0));
- Mat absDiff;
-
- for (size_t j = 0; j < inputs.size(); j++)
- {
- for (size_t n = 0; n < _num; ++n)
- {
- Mat src = Mat(_channels, _channelSize, CV_32F, inputs[j]->ptrf(n));
- Mat dst = Mat(_channels, _channelSize, CV_32F, outputs[j].ptrf(n));
-
- _buffer = src.mul(src);
-
- if (_across_spatial)
- {
- absdiff(_buffer, zeroBuffer, absDiff);
-
- // add eps to avoid overflow
- double absSum = sum(absDiff)[0] + _eps;
-
- float norm = sqrt(absSum);
- dst = src / norm;
- }
- else
- {
- Mat norm(_channelSize, 1, _buffer.type()); // 1 x _channelSize
-
- // (_channels x_channelSize)T * _channels x 1 -> _channelSize x 1
- gemmCPU(_buffer, _sumChannelMultiplier, 1, norm, 0, GEMM_1_T);
-
- // compute norm
- pow(norm, 0.5f, norm);
-
- // scale the layer
- // _channels x 1 * (_channelSize x 1)T -> _channels x _channelSize
- gemmCPU(_sumChannelMultiplier, norm, 1, _buffer, 0, GEMM_2_T);
-
- dst = src / _buffer;
- }
-
- // scale the output
- if (_channel_shared)
- {
- // _scale: 1 x 1
- dst *= _scale.matRefConst().at<float>(0, 0);
- }
- else
- {
- // _scale: _channels x 1
- // _channels x 1 * 1 x _channelSize -> _channels x _channelSize
- gemmCPU(_scale.matRefConst(), _sumSpatialMultiplier, 1, _buffer, 0);
-
- dst = dst.mul(_buffer);
- }
- }
- }
-}
-}
-}
diff --git a/contrib/modules/dnn/src/layers/normalize_bbox_layer.hpp b/contrib/modules/dnn/src/layers/normalize_bbox_layer.hpp
deleted file mode 100644
index 825a0f8..0000000
--- a/contrib/modules/dnn/src/layers/normalize_bbox_layer.hpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_LAYERS_NORMALIZEBBOX_LAYER_HPP__
-#define __OPENCV_DNN_LAYERS_NORMALIZEBBOX_LAYER_HPP__
-#include "../precomp.hpp"
-
-namespace cv
-{
-namespace dnn
-{
-class NormalizeBBoxLayer : public Layer
-{
- Mat _buffer;
-
- Mat _sumChannelMultiplier;
- Mat _sumSpatialMultiplier;
-
- Blob _scale;
-
- float _eps;
- bool _across_spatial;
- bool _channel_shared;
-
- size_t _num;
- size_t _channels;
- size_t _rows;
- size_t _cols;
-
- size_t _channelSize;
- size_t _imageSize;
-
- static const size_t _numAxes = 4;
- static const std::string _layerName;
-
-public:
- NormalizeBBoxLayer(LayerParams ¶ms);
- void allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
- void forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
-
- void checkInputs(const std::vector<Blob*> &inputs);
-
- template<typename T>
- T getParameter(const LayerParams ¶ms,
- const std::string ¶meterName,
- const size_t &idx = 0,
- const bool required = true,
- const T& defaultValue = T());
-
- bool getParameterDict(const LayerParams ¶ms,
- const std::string ¶meterName,
- DictValue& result);
-};
-}
-}
-#endif
diff --git a/contrib/modules/dnn/src/layers/op_blas.cpp b/contrib/modules/dnn/src/layers/op_blas.cpp
deleted file mode 100644
index 5f7f446..0000000
--- a/contrib/modules/dnn/src/layers/op_blas.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-#include "op_blas.hpp"
-
-#ifdef HAVE_LAPACK
-#include "opencv_lapack.h"
-#endif
-
-#include <iostream>
-
-namespace cv
-{
-namespace dnn
-{
-
-void gemm(InputArray A, InputArray B, double alpha, InputOutputArray C, double beta, int flags)
-{
- if (C.isMat())
- gemmCPU(A.getMat(), B.getMat(), alpha, C.getMatRef(), beta, flags);
- else
- {
- cv::gemm(A, B, alpha, (beta == 0) ? noArray() : C, beta, C, flags);
- }
-}
-
-inline void SwapRowCols(const Mat &A, int &rows, int &cols, bool isTrans)
-{
- CV_DbgAssert(A.dims == 2);
- rows = (isTrans) ? A.cols : A.rows;
- cols = (isTrans) ? A.rows : A.cols;
-}
-
-
-class GEMMInvoker : public ParallelLoopBody
-{
-public:
- GEMMInvoker(const Mat* _a, const Mat* _b, double _alpha, Mat* _c, double _beta)
- {
- a = _a;
- b = _b;
- c = _c;
- alpha = _alpha;
- beta = _beta;
- }
-
- void operator()(const Range& range) const
- {
- int mmax = a->rows;
- int nmax = range.end - range.start;
- int kmax = a->cols;
- int m, n, k;
- AutoBuffer<float> buf(nmax);
- float* ptr = buf;
- if( mmax %2 != 0 )
- memset(ptr, 0, nmax*sizeof(ptr[0]));
-
- for( m = 0; m < mmax; m += 2 )
- {
- float* dst0 = c->ptr<float>(m) + range.start;
- float* dst1 = m+1 < mmax ? c->ptr<float>(m+1) + range.start : ptr;
- const float* aptr0 = a->ptr<float>(m);
- const float* aptr1 = m+1 < mmax ? a->ptr<float>(m+1) : aptr0;
-
- if( beta != 1 )
- {
- if( beta == 0 )
- for( n = 0; n < nmax; n++ )
- {
- dst0[n] = 0.f;
- dst1[n] = 0.f;
- }
- else
- for( n = 0; n < nmax; n++ )
- {
- dst0[n] *= (float)beta;
- dst1[n] *= (float)beta;
- }
- }
-
- for( k = 0; k < kmax; k++ )
- {
- float alpha0 = (float)(alpha*aptr0[k]);
- float alpha1 = (float)(alpha*aptr1[k]);
- const float* bptr = b->ptr<float>(k) + range.start;
-
- for( n = 0; n < nmax; n++ )
- {
- float d0 = dst0[n] + alpha0*bptr[n];
- float d1 = dst1[n] + alpha1*bptr[n];
- dst0[n] = d0;
- dst1[n] = d1;
- }
- }
- }
- }
-
- const Mat *a, *b;
- Mat* c;
- double alpha, beta;
-};
-
-void gemmCPU(const Mat &A, const Mat &B, double alpha, Mat &C, double beta, int flags /*= 0*/)
-{
- #ifdef HAVE_LAPACK
- bool transA = static_cast<bool>(flags & GEMM_1_T);
- bool transB = static_cast<bool>(flags & GEMM_2_T);
- bool transC = static_cast<bool>(flags & GEMM_3_T);
-
- int Arows, Acols, Brows, Bcols, Crows, Ccols;
- SwapRowCols(A, Arows, Acols, transA);
- SwapRowCols(B, Brows, Bcols, transB);
- SwapRowCols(C, Crows, Ccols, transC);
-
- CV_Assert(!(flags & GEMM_3_T));
- CV_Assert(Acols == Brows && Arows == Crows && Bcols == Ccols);
- CV_Assert(A.isContinuous() && B.isContinuous() && C.isContinuous());
- CV_Assert(A.type() == B.type() && B.type() == C.type());
- CV_Assert(A.data != C.data && B.data != C.data);
-
- if (C.type() == CV_32F)
- {
- cblas_sgemm(CblasRowMajor, transA ? CblasTrans : CblasNoTrans, transB ? CblasTrans : CblasNoTrans,
- Arows, Bcols, Acols,
- (float)alpha, A.ptr<float>(), A.cols,
- B.ptr<float>(), B.cols,
- (float)beta, C.ptr<float>(), C.cols);
- }
- else if (C.type() == CV_64F)
- {
- //TODO: Should be tested
- cblas_dgemm(CblasRowMajor, transA ? CblasTrans : CblasNoTrans, transB ? CblasTrans : CblasNoTrans,
- Arows, Bcols, Acols,
- alpha, A.ptr<double>(), A.cols,
- B.ptr<double>(), B.cols,
- beta, C.ptr<double>(), C.cols);
- }
- else
- {
- CV_Error(Error::BadDepth, "Only floating point types are supported");
- }
- #else
- if( C.type() == CV_32F && flags == 0 )
- {
- GEMMInvoker invoker(&A, &B, alpha, &C, beta);
- double granularity = 10000000./((double)A.rows*A.cols);
- parallel_for_(Range(0, B.cols), invoker, granularity);
- }
- else
- cv::gemm(A, B, alpha, C, beta, C, flags);
- #endif
-}
-
-int getBlasThreads()
-{
- #ifdef OPENBLAS_VERSION
- return openblas_get_num_threads();
- #else
- return 1;
- #endif
-}
-
-void setBlasThreads(int numThreads)
-{
- #ifdef OPENBLAS_VERSION
- openblas_set_num_threads(numThreads);
- goto_set_num_threads(numThreads);
- #else
- (void)numThreads; //suppress compilers' warning
- #endif
-}
-
-}
-}
diff --git a/contrib/modules/dnn/src/layers/op_blas.hpp b/contrib/modules/dnn/src/layers/op_blas.hpp
deleted file mode 100644
index 55c70d8..0000000
--- a/contrib/modules/dnn/src/layers/op_blas.hpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_LAYERS_OP_BLAS_HPP__
-#define __OPENCV_DNN_LAYERS_OP_BLAS_HPP__
-#include "../precomp.hpp"
-
-namespace cv
-{
-namespace dnn
-{
- int getBlasThreads();
-
- void setBlasThreads(int numThreads);
-
- void gemm(InputArray A, InputArray B, double alpha, InputOutputArray C, double beta, int flags = 0);
-
- void gemmCPU(const Mat &A, const Mat &B, double alpha, Mat &C, double beta, int flags = 0);
-}
-}
-#endif
\ No newline at end of file
diff --git a/contrib/modules/dnn/src/layers/op_im2col.cpp b/contrib/modules/dnn/src/layers/op_im2col.cpp
deleted file mode 100644
index 4adeec7..0000000
--- a/contrib/modules/dnn/src/layers/op_im2col.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "../precomp.hpp"
-#include <opencv2/core/ocl.hpp>
-#include "opencl_kernels_dnn.hpp"
-#include "op_im2col.hpp"
-#include "opencl_kernels_dnn.hpp"
-
-namespace cv
-{
-namespace dnn
-{
-
-#ifdef HAVE_OPENCL
-
-bool im2col_ocl(const UMat &img,
- int channels, int height, int width,
- int kernel_h, int kernel_w,
- int pad_h, int pad_w,
- int stride_h, int stride_w,
- int dilation_h, int dilation_w,
- UMat &col)
-{
- //TODO
- CV_Assert(dilation_h == 1 && dilation_w == 1);
-
- int height_col = (height + 2 * pad_h - kernel_h) / stride_h + 1;
- int width_col = (width + 2 * pad_w - kernel_w) / stride_w + 1;
- int channels_col = channels * kernel_h * kernel_w;
- int esz = img.elemSize();
-
- CV_Assert(img.isContinuous() && col.isContinuous());
- CV_Assert(img.total() == (size_t)channels * height * width);
- CV_Assert(col.total() == (size_t)channels_col * height_col * width_col);
-
- ocl::Kernel ker("im2col", ocl::dnn::im2col_oclsrc, String("-DT=") + ocl::typeToStr(img.type()));
- if (ker.empty())
- return false;
-
- ker.args(ocl::KernelArg::PtrReadOnly(img), (int)img.offset/esz,
- channels, height, width,
- kernel_h, kernel_w, pad_h, pad_w, stride_h, stride_w,
- height_col, width_col,
- ocl::KernelArg::PtrWriteOnly(col), (int)col.offset/esz
- );
-
- size_t localSize = ocl::Device::getDefault().maxWorkGroupSize();
- size_t globalSize = (size_t)channels * height_col * width_col;
- return ker.run(1, &globalSize, &localSize, true);
-}
-
-bool col2im_ocl(const UMat &col,
- int channels, int height, int width,
- int kernel_h, int kernel_w,
- int pad_h, int pad_w,
- int stride_h, int stride_w,
- UMat &img)
-{
- int height_col = (height + 2 * pad_h - kernel_h) / stride_h + 1;
- int width_col = (width + 2 * pad_w - kernel_w) / stride_w + 1;
- int channels_col = channels * kernel_h * kernel_w;
- int esz = img.elemSize();
-
- CV_Assert(img.isContinuous() && col.isContinuous());
- CV_Assert(img.total() == (size_t)channels * height * width);
- CV_Assert(col.total() == (size_t)channels_col * height_col * width_col);
-
- ocl::Kernel ker("col2im", ocl::dnn::col2im_oclsrc, String("-DT=") + ocl::typeToStr(col.type()));
- if (ker.empty())
- return false;
-
- ker.args((int)img.total(),
- ocl::KernelArg::PtrReadOnly(col), (int)col.offset/esz,
- height, width, channels,
- kernel_h, kernel_w,
- pad_h, pad_w,
- stride_h, stride_w,
- height_col, width_col,
- ocl::KernelArg::PtrWriteOnly(img), (int)img.offset/esz);
-
- size_t localSize = ocl::Device::getDefault().maxWorkGroupSize();
- size_t globalSize = img.total();
- return ker.run(1, &globalSize, &localSize, true);
-}
-
-#endif
-}
-}
-
-namespace cv
-{
-namespace dnn
-{
-
-#ifdef HAVE_OPENCL
-void im2col_ocl(UMat &img,
- int channels, int height, int width,
- int kernel_h, int kernel_w,
- int pad_h, int pad_w,
- int stride_h, int stride_w,
- int height_out, int width_out,
- UMat &col)
-{
- int h_out = height_out;
- int w_out = width_out;
-
- CV_Assert(img.isContinuous() && col.isContinuous());
- CV_Assert(img.total() == (size_t)channels * height * width);
- CV_Assert(col.total() == (size_t)channels * kernel_h * kernel_w * h_out * w_out);
-
- ocl::Kernel im2col_ker("im2col", ocl::dnn::im2col_oclsrc);
- CV_Assert(!im2col_ker.empty());
-
- im2col_ker.args(ocl::KernelArg::PtrReadOnly(img), (int)img.offset,
- channels, height, width,
- kernel_h, kernel_w, pad_h, pad_w, stride_h, stride_w,
- h_out, w_out,
- ocl::KernelArg::PtrWriteOnly(col), (int)col.offset
- );
-
- size_t localSize = ocl::Device::getDefault().maxWorkGroupSize();
- size_t globalSize = (size_t)channels * h_out * w_out;
-
- CV_Assert(im2col_ker.run(1, &globalSize, &localSize, true));
-}
-#endif // HAVE_OPENCL
-
-}
-}
diff --git a/contrib/modules/dnn/src/layers/op_im2col.hpp b/contrib/modules/dnn/src/layers/op_im2col.hpp
deleted file mode 100644
index b41c684..0000000
--- a/contrib/modules/dnn/src/layers/op_im2col.hpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_LAYERS_IM2COL_HPP__
-#define __OPENCV_DNN_LAYERS_IM2COL_HPP__
-#include <opencv2/core.hpp>
-#include <cstdlib>
-
-namespace cv
-{
-namespace dnn
-{
-
-template <typename Dtype>
-class im2col_CpuPBody : public cv::ParallelLoopBody
-{
- const Dtype* data_im;
- int channels, height, width;
- int kernel_h, kernel_w;
- int pad_h, pad_w;
- int stride_h, stride_w;
- int dilation_h, dilation_w;
- Dtype* data_col;
- int height_col, width_col, channels_col;
-
- im2col_CpuPBody() {}
-public:
-
- static void run(const Dtype* data_im,
- int channels, int height, int width,
- int kernel_h, int kernel_w,
- int pad_h, int pad_w,
- int stride_h, int stride_w,
- int dilation_h, int dilation_w,
- int height_col, int width_col,
- Dtype* data_col)
- {
- im2col_CpuPBody<Dtype> t;
-
- t.data_im = data_im;
- t.data_col = data_col;
- t.channels = channels; t.height = height; t.width = width;
- t.kernel_h = kernel_h; t.kernel_w = kernel_w;
- t.pad_h = pad_h; t.pad_w = pad_w;
- t.stride_h = stride_h; t.stride_w = stride_w;
- t.dilation_h = dilation_h; t.dilation_w = dilation_w;
-
- t.height_col = height_col;
- t.width_col = width_col;
- t.channels_col = channels * kernel_h * kernel_w;
-
- cv::parallel_for_(Range(0, t.channels_col), t);
- }
-
- virtual void operator ()(const Range &r) const
- {
- for (int c = r.start; c < r.end; ++c)
- {
- int w_offset = c % kernel_w;
- int h_offset = (c / kernel_w) % kernel_h;
- int c_im = c / kernel_h / kernel_w;
- for (int h = 0; h < height_col; ++h)
- {
- for (int w = 0; w < width_col; ++w)
- {
- int h_pad = h * stride_h - pad_h + h_offset * dilation_h;
- int w_pad = w * stride_w - pad_w + w_offset * dilation_w;
- if (h_pad >= 0 && h_pad < height && w_pad >= 0 && w_pad < width)
- data_col[(c * height_col + h) * width_col + w] =
- data_im[(c_im * height + h_pad) * width + w_pad];
- else
- data_col[(c * height_col + h) * width_col + w] = 0;
- }
- }
- }
- }
-};
-
-template <typename Dtype>
-class col2im_CpuPBody : public cv::ParallelLoopBody
-{
- const Dtype* data_col;
- int channels, height, width;
- int kernel_h, kernel_w;
- int pad_h, pad_w;
- int stride_h, stride_w;
- Dtype* data_im;
- int height_col, width_col;
-
- col2im_CpuPBody() {}
-
-public:
-
- static void run(const Dtype* data_col,
- int channels, int height, int width,
- int kernel_h, int kernel_w,
- int pad_h, int pad_w,
- int stride_h, int stride_w,
- Dtype* data_im)
- {
- //TODO: single-threaded version switch
-
- col2im_CpuPBody t;
- t.data_col = data_col;
- t.data_im = data_im;
- t.channels = channels; t.height = height; t.width = width;
- t.kernel_h = kernel_h; t.kernel_w = kernel_w;
- t.pad_h = pad_h; t.pad_w = pad_w;
- t.stride_h = stride_h; t.stride_w = stride_w;
- t.height_col = (height + 2 * pad_h - kernel_h) / stride_h + 1;
- t.width_col = (width + 2 * pad_w - kernel_w) / stride_w + 1;
- int img_total = channels * height * width;
-
- cv::parallel_for_(Range(0, img_total), t);
- }
-
- virtual void operator ()(const Range &r) const
- {
- for (int index = r.start; index < r.end; index++)
- {
- Dtype val = 0;
- int w = index % width + pad_w;
- int h = (index / width) % height + pad_h;
- int c = index / (width * height);
-
- // compute the start and end of the output
- int w_col_start = (w < kernel_w) ? 0 : (w - kernel_w) / stride_w + 1;
- int w_col_end = std::min(w / stride_w + 1, width_col);
- int h_col_start = (h < kernel_h) ? 0 : (h - kernel_h) / stride_h + 1;
- int h_col_end = std::min(h / stride_h + 1, height_col);
-
- // equivalent implementation
- int offset =
- (c * kernel_h * kernel_w + h * kernel_w + w) * height_col * width_col;
- int coeff_h_col = (1 - stride_h * kernel_w * height_col) * width_col;
- int coeff_w_col = (1 - stride_w * height_col * width_col);
- for (int h_col = h_col_start; h_col < h_col_end; ++h_col) {
- for (int w_col = w_col_start; w_col < w_col_end; ++w_col) {
- val += data_col[offset + h_col * coeff_h_col + w_col * coeff_w_col];
- }
- }
- data_im[index] = val;
- }
- }
-};
-
-//single-threaded version
-template <typename Dtype>
-void col2im_cpu(const Dtype* data_col,
- int channels, int height, int width,
- int kernel_h, int kernel_w,
- int pad_h, int pad_w,
- int stride_h, int stride_w,
- int dilation_h, int dilation_w,
- Dtype* data_im)
-{
- int height_col = (height + 2 * pad_h - (dilation_h * (kernel_h - 1) + 1)) / stride_h + 1;
- int width_col = (width + 2 * pad_w - (dilation_w * (kernel_w - 1) + 1)) / stride_w + 1;
- int channels_col = channels * kernel_h * kernel_w;
-
- std::memset(data_im, 0, height * width * channels * sizeof(Dtype));
-
- for (int c = 0; c < channels_col; ++c)
- {
- int w_offset = c % kernel_w;
- int h_offset = (c / kernel_w) % kernel_h;
- int c_im = c / kernel_h / kernel_w;
-
- for (int h = 0; h < height_col; ++h)
- {
- for (int w = 0; w < width_col; ++w)
- {
- int h_pad = h * stride_h - pad_h + h_offset * dilation_h;
- int w_pad = w * stride_w - pad_w + w_offset * dilation_w;
-
- if (h_pad >= 0 && h_pad < height && w_pad >= 0 && w_pad < width)
- data_im[(c_im * height + h_pad) * width + w_pad] +=
- data_col[(c * height_col + h) * width_col + w];
- }
- }
- }
-}
-
-#ifdef HAVE_OPENCL
-bool im2col_ocl(const UMat &img,
- int channels, int height, int width,
- int kernel_h, int kernel_w,
- int pad_h, int pad_w,
- int stride_h, int stride_w,
- int dilation_h, int dilation_w,
- UMat &col);
-
-bool col2im_ocl(const UMat &col,
- int channels, int height, int width,
- int kernel_h, int kernel_w,
- int pad_h, int pad_w,
- int stride_h, int stride_w,
- UMat &img);
-#endif
-
-}
-}
-
-#endif
diff --git a/contrib/modules/dnn/src/layers/permute_layer.cpp b/contrib/modules/dnn/src/layers/permute_layer.cpp
deleted file mode 100644
index 41c8399..0000000
--- a/contrib/modules/dnn/src/layers/permute_layer.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "../precomp.hpp"
-#include "layers_common.hpp"
-#include "permute_layer.hpp"
-#include <float.h>
-#include <algorithm>
-
-namespace cv
-{
-namespace dnn
-{
-void PermuteLayer::checkCurrentOrder(int currentOrder)
-{
- if(currentOrder < 0 || currentOrder > 3)
- {
- CV_Error(
- Error::StsBadArg,
- "Orders of dimensions in Permute layer parameter"
- "must be in [0...3] interval");
- }
-
- if(std::find(_order.begin(), _order.end(), currentOrder) != _order.end())
- {
- CV_Error(Error::StsBadArg,
- "Permute layer parameter contains duplicated orders.");
- }
-}
-
-void PermuteLayer::checkNeedForPermutation()
-{
- _needsPermute = false;
- for (size_t i = 0; i < _numAxes; ++i)
- {
- if (_order[i] != i)
- {
- _needsPermute = true;
- break;
- }
- }
-}
-
-PermuteLayer::PermuteLayer(LayerParams ¶ms) : Layer(params)
-{
- if (!params.has("order"))
- {
- _needsPermute = false;
- return;
- }
-
- DictValue paramOrder = params.get("order");
- if(paramOrder.size() > 4)
- {
- CV_Error(
- Error::StsBadArg,
- "Too many (> 4) orders of dimensions in Permute layer");
- }
-
- _numAxes = paramOrder.size();
-
- for (size_t i = 0; i < _numAxes; i++)
- {
- int currentOrder = paramOrder.get<int>(i);
- checkCurrentOrder(currentOrder);
- _order.push_back(currentOrder);
- }
-
- checkNeedForPermutation();
-}
-
-void PermuteLayer::computeStrides()
-{
- _oldStride.resize(_numAxes);
- _newStride.resize(_numAxes);
-
- _oldStride[_numAxes - 1] = 1;
- _newStride[_numAxes - 1] = 1;
-
- for(int i = _numAxes - 2; i >= 0; i--)
- {
- _oldStride[i] = _oldStride[i + 1] * _oldDimensionSize[i + 1];
- _newStride[i] = _newStride[i + 1] * _newDimensionSize[i + 1];
- }
-
- _count = _oldStride[0] * _oldDimensionSize[0];
-}
-
-void PermuteLayer::allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- if(!_needsPermute)
- {
- return;
- }
-
- CV_Assert(inputs.size() > 0);
- CV_Assert((int)_numAxes == inputs[0]->shape().dims());
-
- outputs.resize(inputs.size());
-
- _oldDimensionSize = inputs[0]->shape();
- for (size_t i = 0; i < _numAxes; i++)
- {
- _newDimensionSize[i] = _oldDimensionSize[_order[i]];
- }
-
- for (size_t i = 0; i < inputs.size(); i++)
- {
- CV_Assert(inputs[i]->rows() == _oldDimensionSize[2] && inputs[i]->cols() == _oldDimensionSize[3]);
- outputs[i].create(BlobShape(_newDimensionSize));
- }
-
- computeStrides();
-}
-
-void PermuteLayer::forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- if(!_needsPermute)
- {
- for (size_t j = 0; j < inputs.size(); j++)
- {
- outputs[j].matRef() = inputs[j]->matRef();
- }
- return;
- }
-
- for (size_t k = 0; k < inputs.size(); k++)
- {
- float *srcData = inputs[k]->ptrf();
- float *dstData = outputs[k].ptrf();
-
- for (size_t i = 0; i < _count; ++i)
- {
- int oldPosition = 0;
- int newPosition = i;
-
- for (size_t j = 0; j < _numAxes; ++j)
- {
- oldPosition += (newPosition / _newStride[j]) * _oldStride[_order[j]];
- newPosition %= _newStride[j];
- }
- dstData[i] = srcData[oldPosition];
- }
- }
-}
-}
-}
diff --git a/contrib/modules/dnn/src/layers/permute_layer.hpp b/contrib/modules/dnn/src/layers/permute_layer.hpp
deleted file mode 100644
index cc51c60..0000000
--- a/contrib/modules/dnn/src/layers/permute_layer.hpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_LAYERS_PERMUTE_LAYER_HPP__
-#define __OPENCV_DNN_LAYERS_PERMUTE_LAYER_HPP__
-#include "../precomp.hpp"
-
-namespace cv
-{
-namespace dnn
-{
-class PermuteLayer : public Layer
-{
- size_t _count;
- std::vector<size_t> _order;
-
- BlobShape _oldDimensionSize;
- BlobShape _newDimensionSize;
-
- std::vector<size_t> _oldStride;
- std::vector<size_t> _newStride;
- bool _needsPermute;
-
- size_t _numAxes;
-
- void checkCurrentOrder(int currentOrder);
- void checkNeedForPermutation();
- void computeStrides();
-
-public:
- PermuteLayer(LayerParams ¶ms);
- void allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
- void forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
-};
-}
-}
-#endif
diff --git a/contrib/modules/dnn/src/layers/pooling_layer.cpp b/contrib/modules/dnn/src/layers/pooling_layer.cpp
deleted file mode 100644
index 2e18450..0000000
--- a/contrib/modules/dnn/src/layers/pooling_layer.cpp
+++ /dev/null
@@ -1,295 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "../precomp.hpp"
-#include "layers_common.hpp"
-#include "pooling_layer.hpp"
-#include "opencl_kernels_dnn.hpp"
-#include <float.h>
-#include <algorithm>
-#include <opencv2/core/ocl.hpp>
-using std::max;
-using std::min;
-
-namespace cv
-{
-namespace dnn
-{
-//TODO: add ceil_mode param
-
-PoolingLayerImpl::PoolingLayerImpl()
-{
- globalPooling = false;
-}
-
-PoolingLayerImpl::PoolingLayerImpl(int type_, Size kernel_, Size stride_, Size pad_, const String &padMode_)
-{
- globalPooling = false;
- type = type_;
- kernel = kernel_;
- pad = pad_;
- stride = stride_;
- padMode = padMode_;
-}
-
-void PoolingLayerImpl::allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- CV_Assert(inputs.size() > 0);
-
- inp = inputs[0]->size2();
-
- if(globalPooling)
- {
- kernel = inp;
- }
-
- computeOutputShape(inp);
-
- useOpenCL = ocl::useOpenCL();
-
- outputs.resize(inputs.size());
- for (size_t i = 0; i < inputs.size(); i++)
- {
- CV_Assert(inputs[i]->rows() == inp.height && inputs[i]->cols() == inp.width);
- outputs[i].create(BlobShape(inputs[i]->num(), inputs[i]->channels(), out.height, out.width));
- }
-}
-
-void PoolingLayerImpl::forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- for (size_t ii = 0; ii < inputs.size(); ii++)
- {
- switch (type)
- {
- case MAX:
- maxPooling(*inputs[ii], outputs[ii]);
- break;
- case AVE:
- avePooling(*inputs[ii], outputs[ii]);
- break;
- default:
- CV_Error(Error::StsNotImplemented, "Not implemented");
- break;
- }
- }
-}
-
-void PoolingLayerImpl::maxPooling(Blob &src, Blob &dst)
-{
- if (!useOpenCL)
- maxPooling_cpu(src, dst);
- else
- {
- CV_Assert(maxPooling_ocl(src, dst));
- }
-}
-
-bool PoolingLayerImpl::maxPooling_ocl(Blob &src, Blob &dst)
-{
- return pooling_ocl("MaxPoolForward", src, dst);
-}
-
-void PoolingLayerImpl::avePooling(Blob &src, Blob &dst)
-{
- if (!useOpenCL)
- avePooling_cpu(src, dst);
- else
- {
- CV_Assert(avePooling_ocl(src, dst));
- }
-}
-
-bool PoolingLayerImpl::avePooling_ocl(Blob &src, Blob &dst)
-{
- return pooling_ocl("AvePoolForward", src, dst);
-}
-
-void PoolingLayerImpl::maxPooling_cpu(Blob &src, Blob &dst)
-{
- CV_DbgAssert(dst.rows() == out.height && dst.cols() == out.width);
-
- for (int n = 0; n < src.num(); ++n)
- {
- for (int c = 0; c < src.channels(); ++c)
- {
- const float *srcData = src.ptrf(n, c);
- float *dstData = dst.ptrf(n, c);
-
- for (int ph = 0; ph < out.height; ++ph)
- {
- for (int pw = 0; pw < out.width; ++pw)
- {
- int hstart = ph * stride.height - pad.height;
- int wstart = pw * stride.width - pad.width;
- int hend = min(hstart + kernel.height, inp.height);
- int wend = min(wstart + kernel.width, inp.width);
- hstart = max(hstart, 0);
- wstart = max(wstart, 0);
- const int poolIndex = ph * out.width + pw;
- float max_val = -FLT_MAX;
-
- for (int h = hstart; h < hend; ++h)
- for (int w = wstart; w < wend; ++w)
- {
- const int index = h * inp.width + w;
- if (srcData[index] > max_val)
- max_val = srcData[index];
- }
-
- dstData[poolIndex] = max_val;
- }
- }
- }
- }
-}
-
-
-#ifdef HAVE_OPENCL
-bool PoolingLayerImpl::pooling_ocl(const char *kname, const Blob &src, Blob &dst, Blob *mask)
-{
- const UMat &srcMat = src.umatRefConst();
- UMat &dstMat = dst.umatRef();
- CV_Assert(mask == NULL && srcMat.offset == 0 && dstMat.offset == 0);
-
- ocl::Kernel ker(kname, ocl::dnn::pooling_oclsrc, String("-DT=") + ocl::typeToStr(src.type()));
- if (ker.empty())
- return false;
-
- BlobShape s = src.shape();
- size_t nthreads = dst.total();
- ker.args((int)nthreads,
- ocl::KernelArg::PtrReadOnly(srcMat), s[0], s[1], s[2], s[3],
- out.height, out.width, kernel.height, kernel.width,
- stride.height, stride.width, pad.height, pad.width,
- ocl::KernelArg::PtrWriteOnly(dstMat));
-
- size_t wgSize = ocl::Device::getDefault().maxWorkGroupSize();
- if (!ker.run(1, &nthreads, &wgSize, true))
- return false;
-
- return true;
-}
-#else
-bool PoolingLayerImpl::pooling_ocl(const char*, const Blob&, Blob&, Blob*)
-{
- return false;
-}
-#endif
-
-void PoolingLayerImpl::avePooling_cpu(Blob &src, Blob &dst)
-{
- for (int n = 0; n < src.num(); ++n)
- {
- for (int c = 0; c < src.channels(); ++c)
- {
- const float *srcData = src.ptrf(n, c);
- float *dstData = dst.ptrf(n, c);
-
- for (int ph = 0; ph < out.height; ++ph)
- {
- for (int pw = 0; pw < out.width; ++pw)
- {
- int hstart = ph * stride.height - pad.height;
- int wstart = pw * stride.width - pad.width;
- int hend = min(hstart + kernel.height, inp.height + pad.height);
- int wend = min(wstart + kernel.width, inp.width + pad.width);
- int poolSize = (hend - hstart) * (wend - wstart);
- hstart = max(hstart, 0);
- wstart = max(wstart, 0);
- hend = min(hend, inp.height);
- wend = min(wend, inp.width);
-
- dstData[ph * out.width + pw] = 0.f;
-
- for (int h = hstart; h < hend; ++h)
- for (int w = wstart; w < wend; ++w)
- dstData[ph * out.width + pw] += srcData[h * inp.width + w];
-
- dstData[ph * out.width + pw] /= poolSize;
- }
- }
- }
- }
-}
-
-void PoolingLayerImpl::computeOutputShape(Size inpSz)
-{
- if (padMode.empty()) {
- //Yeah, something strange Caffe scheme-)
- out.height = static_cast<int>(ceil(static_cast<float>(inpSz.height + 2 * pad.height -
- kernel.height) / stride.height)) + 1;
- out.width = static_cast<int>(ceil(static_cast<float>(inpSz.width + 2 * pad.width -
- kernel.width) / stride.width)) + 1;
-
- if (pad.height || pad.width)
- {
- // If we have padding, ensure that the last pooling starts strictly
- // inside the image (instead of at the padding); otherwise clip the last.
- if ((out.height - 1) * stride.height >= inpSz.height + pad.height)
- --out.height;
- if ((out.width - 1) * stride.width >= inpSz.width + pad.width)
- --out.width;
- CV_Assert((out.height - 1) * stride.height < inpSz.height + pad.height);
- CV_Assert((out.width - 1) * stride.width < inpSz.width + pad.width);
- }
- }
- else
- {
- getConvPoolOutParams(inpSz.height, inpSz.width, kernel, stride, pad,
- padMode, out.height, out.width);
- }
-}
-
-Ptr<PoolingLayer> PoolingLayer::create(int type, Size kernel, Size stride, Size pad,
- const String& padMode)
-{
- return Ptr<PoolingLayer>(new PoolingLayerImpl(type, kernel, stride, pad, padMode));
-}
-
-Ptr<PoolingLayer> PoolingLayer::createGlobal(int type)
-{
- Ptr<PoolingLayer> l = PoolingLayer::create(type);
- l->globalPooling = true;
- return l;
-}
-
-}
-}
diff --git a/contrib/modules/dnn/src/layers/pooling_layer.hpp b/contrib/modules/dnn/src/layers/pooling_layer.hpp
deleted file mode 100644
index c5723cd..0000000
--- a/contrib/modules/dnn/src/layers/pooling_layer.hpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_LAYERS_POOLING_LAYER_HPP__
-#define __OPENCV_DNN_LAYERS_POOLING_LAYER_HPP__
-#include "../precomp.hpp"
-#include <opencv2/dnn/all_layers.hpp>
-
-namespace cv
-{
-namespace dnn
-{
-
-class PoolingLayerImpl : public PoolingLayer
-{
- bool useOpenCL;
- Size inp, out;
-
- void computeOutputShape(Size inpSz);
-
- bool pooling_ocl(const char *kname, const Blob &src, Blob &dst, Blob *mask = NULL);
-
- void maxPooling(Blob &src, Blob &dst);
- void maxPooling_cpu(Blob &src, Blob &dst);
- bool maxPooling_ocl(Blob &src, Blob &dst);
-
- void avePooling(Blob &src, Blob &dst);
- void avePooling_cpu(Blob &src, Blob &dst);
- bool avePooling_ocl(Blob &src, Blob &dst);
-
-public:
-
- PoolingLayerImpl();
- PoolingLayerImpl(int type, Size kernel, Size stride, Size pad, const String& padMode);
-
- void allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
- void forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
-};
-
-}
-}
-
-#endif
diff --git a/contrib/modules/dnn/src/layers/prior_box_layer.cpp b/contrib/modules/dnn/src/layers/prior_box_layer.cpp
deleted file mode 100644
index a5343a4..0000000
--- a/contrib/modules/dnn/src/layers/prior_box_layer.cpp
+++ /dev/null
@@ -1,307 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "../precomp.hpp"
-#include "layers_common.hpp"
-#include "prior_box_layer.hpp"
-#include <float.h>
-#include <algorithm>
-#include <cmath>
-
-namespace cv
-{
-namespace dnn
-{
-
-const std::string PriorBoxLayer::_layerName = std::string("PriorBox");
-
-bool PriorBoxLayer::getParameterDict(const LayerParams ¶ms,
- const std::string ¶meterName,
- DictValue& result)
-{
- if (!params.has(parameterName))
- {
- return false;
- }
-
- result = params.get(parameterName);
- return true;
-}
-
-template<typename T>
-T PriorBoxLayer::getParameter(const LayerParams ¶ms,
- const std::string ¶meterName,
- const size_t &idx,
- const bool required,
- const T& defaultValue)
-{
- DictValue dictValue;
- bool success = getParameterDict(params, parameterName, dictValue);
- if(!success)
- {
- if(required)
- {
- std::string message = _layerName;
- message += " layer parameter does not contain ";
- message += parameterName;
- message += " parameter.";
- CV_Error(Error::StsBadArg, message);
- }
- else
- {
- return defaultValue;
- }
- }
- return dictValue.get<T>(idx);
-}
-
-void PriorBoxLayer::getAspectRatios(const LayerParams ¶ms)
-{
- DictValue aspectRatioParameter;
- bool aspectRatioRetieved = getParameterDict(params, "aspect_ratio", aspectRatioParameter);
- CV_Assert(aspectRatioRetieved);
-
- for (int i = 0; i < aspectRatioParameter.size(); ++i)
- {
- float aspectRatio = aspectRatioParameter.get<float>(i);
- bool alreadyExists = false;
-
- for (size_t j = 0; j < _aspectRatios.size(); ++j)
- {
- if (fabs(aspectRatio - _aspectRatios[j]) < 1e-6)
- {
- alreadyExists = true;
- break;
- }
- }
- if (!alreadyExists)
- {
- _aspectRatios.push_back(aspectRatio);
- if (_flip)
- {
- _aspectRatios.push_back(1./aspectRatio);
- }
- }
- }
-}
-
-void PriorBoxLayer::getVariance(const LayerParams ¶ms)
-{
- DictValue varianceParameter;
- bool varianceParameterRetrieved = getParameterDict(params, "variance", varianceParameter);
- CV_Assert(varianceParameterRetrieved);
-
- int varianceSize = varianceParameter.size();
- if (varianceSize > 1)
- {
- // Must and only provide 4 variance.
- CV_Assert(varianceSize == 4);
-
- for (int i = 0; i < varianceSize; ++i)
- {
- float variance = varianceParameter.get<float>(i);
- CV_Assert(variance > 0);
- _variance.push_back(variance);
- }
- }
- else
- {
- if (varianceSize == 1)
- {
- float variance = varianceParameter.get<float>(0);
- CV_Assert(variance > 0);
- _variance.push_back(variance);
- }
- else
- {
- // Set default to 0.1.
- _variance.push_back(0.1f);
- }
- }
-}
-
-PriorBoxLayer::PriorBoxLayer(LayerParams ¶ms) : Layer(params)
-{
- _minSize = getParameter<unsigned>(params, "min_size");
- CV_Assert(_minSize > 0);
-
- _flip = getParameter<bool>(params, "flip");
- _clip = getParameter<bool>(params, "clip");
-
- _aspectRatios.clear();
- _aspectRatios.push_back(1.);
-
- getAspectRatios(params);
- getVariance(params);
-
- _numPriors = _aspectRatios.size();
-
- _maxSize = -1;
- if (params.has("max_size"))
- {
- _maxSize = params.get("max_size").get<float>(0);
- CV_Assert(_maxSize > _minSize);
-
- _numPriors += 1;
- }
-}
-
-void PriorBoxLayer::allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- CV_Assert(inputs.size() == 2);
-
- _layerWidth = inputs[0]->cols();
- _layerHeight = inputs[0]->rows();
-
- _imageWidth = inputs[1]->cols();
- _imageHeight = inputs[1]->rows();
-
- _stepX = static_cast<float>(_imageWidth) / _layerWidth;
- _stepY = static_cast<float>(_imageHeight) / _layerHeight;
-
- // Since all images in a batch has same height and width, we only need to
- // generate one set of priors which can be shared across all images.
- size_t outNum = 1;
- // 2 channels. First channel stores the mean of each prior coordinate.
- // Second channel stores the variance of each prior coordinate.
- size_t outChannels = 2;
- _outChannelSize = _layerHeight * _layerWidth * _numPriors * 4;
-
- outputs[0].create(BlobShape(outNum, outChannels, _outChannelSize));
- outputs[0].matRef() = 0;
-}
-
-void PriorBoxLayer::forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- (void)inputs; // to suppress unused parameter warning
-
- float* outputPtr = outputs[0].ptrf();
-
- // first prior: aspect_ratio = 1, size = min_size
- int idx = 0;
- for (size_t h = 0; h < _layerHeight; ++h)
- {
- for (size_t w = 0; w < _layerWidth; ++w)
- {
- _boxWidth = _boxHeight = _minSize;
-
- float center_x = (w + 0.5) * _stepX;
- float center_y = (h + 0.5) * _stepY;
- // xmin
- outputPtr[idx++] = (center_x - _boxWidth / 2.) / _imageWidth;
- // ymin
- outputPtr[idx++] = (center_y - _boxHeight / 2.) / _imageHeight;
- // xmax
- outputPtr[idx++] = (center_x + _boxWidth / 2.) / _imageWidth;
- // ymax
- outputPtr[idx++] = (center_y + _boxHeight / 2.) / _imageHeight;
-
- if (_maxSize > 0)
- {
- // second prior: aspect_ratio = 1, size = sqrt(min_size * max_size)
- _boxWidth = _boxHeight = sqrt(_minSize * _maxSize);
- // xmin
- outputPtr[idx++] = (center_x - _boxWidth / 2.) / _imageWidth;
- // ymin
- outputPtr[idx++] = (center_y - _boxHeight / 2.) / _imageHeight;
- // xmax
- outputPtr[idx++] = (center_x + _boxWidth / 2.) / _imageWidth;
- // ymax
- outputPtr[idx++] = (center_y + _boxHeight / 2.) / _imageHeight;
- }
-
- // rest of priors
- for (size_t r = 0; r < _aspectRatios.size(); ++r)
- {
- float ar = _aspectRatios[r];
- if (fabs(ar - 1.) < 1e-6)
- {
- continue;
- }
- _boxWidth = _minSize * sqrt(ar);
- _boxHeight = _minSize / sqrt(ar);
- // xmin
- outputPtr[idx++] = (center_x - _boxWidth / 2.) / _imageWidth;
- // ymin
- outputPtr[idx++] = (center_y - _boxHeight / 2.) / _imageHeight;
- // xmax
- outputPtr[idx++] = (center_x + _boxWidth / 2.) / _imageWidth;
- // ymax
- outputPtr[idx++] = (center_y + _boxHeight / 2.) / _imageHeight;
- }
- }
- }
- // clip the prior's coordidate such that it is within [0, 1]
- if (_clip)
- {
- for (size_t d = 0; d < _outChannelSize; ++d)
- {
- outputPtr[d] = std::min<float>(std::max<float>(outputPtr[d], 0.), 1.);
- }
- }
- // set the variance.
- outputPtr = outputs[0].ptrf(0, 1);
- if(_variance.size() == 1)
- {
- Mat secondChannel(outputs[0].rows(), outputs[0].cols(), CV_32F, outputPtr);
- secondChannel.setTo(Scalar(_variance[0]));
- }
- else
- {
- int count = 0;
- for (size_t h = 0; h < _layerHeight; ++h)
- {
- for (size_t w = 0; w < _layerWidth; ++w)
- {
- for (size_t i = 0; i < _numPriors; ++i)
- {
- for (int j = 0; j < 4; ++j)
- {
- outputPtr[count] = _variance[j];
- ++count;
- }
- }
- }
- }
- }
-}
-}
-}
diff --git a/contrib/modules/dnn/src/layers/prior_box_layer.hpp b/contrib/modules/dnn/src/layers/prior_box_layer.hpp
deleted file mode 100644
index e398aa1..0000000
--- a/contrib/modules/dnn/src/layers/prior_box_layer.hpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_LAYERS_PRIOR_BOX_LAYER_HPP__
-#define __OPENCV_DNN_LAYERS_PRIOR_BOX_LAYER_HPP__
-#include "../precomp.hpp"
-
-namespace cv
-{
-namespace dnn
-{
-class PriorBoxLayer : public Layer
-{
- size_t _layerWidth;
- size_t _layerHeight;
-
- size_t _imageWidth;
- size_t _imageHeight;
-
- size_t _outChannelSize;
-
- float _stepX;
- float _stepY;
-
- float _minSize;
- float _maxSize;
-
- float _boxWidth;
- float _boxHeight;
-
- std::vector<float> _aspectRatios;
- std::vector<float> _variance;
-
- bool _flip;
- bool _clip;
-
- size_t _numPriors;
-
- static const size_t _numAxes = 4;
- static const std::string _layerName;
-
-public:
- PriorBoxLayer(LayerParams ¶ms);
- void allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
- void forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
-
- template<typename T>
- T getParameter(const LayerParams ¶ms,
- const std::string ¶meterName,
- const size_t &idx = 0,
- const bool required = true,
- const T& defaultValue = T());
-
- bool getParameterDict(const LayerParams ¶ms,
- const std::string ¶meterName,
- DictValue& result);
-
- void getAspectRatios(const LayerParams ¶ms);
- void getVariance(const LayerParams ¶ms);
-};
-}
-}
-#endif
diff --git a/contrib/modules/dnn/src/layers/recurrent_layers.cpp b/contrib/modules/dnn/src/layers/recurrent_layers.cpp
deleted file mode 100644
index 65545fe..0000000
--- a/contrib/modules/dnn/src/layers/recurrent_layers.cpp
+++ /dev/null
@@ -1,442 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "../precomp.hpp"
-#include "recurrent_layers.hpp"
-#include "op_blas.hpp"
-#include <iostream>
-#include <cmath>
-#include <opencv2/dnn/shape_utils.hpp>
-
-namespace cv
-{
-namespace dnn
-{
-
-template<typename Dtype>
-static void tanh(const Mat &src, Mat &dst)
-{
- MatConstIterator_<Dtype> itSrc = src.begin<Dtype>();
- MatIterator_<Dtype> itDst = dst.begin<Dtype>();
-
- for (; itSrc != src.end<Dtype>(); itSrc++, itDst++)
- *itDst = std::tanh(*itSrc);
-}
-
-//TODO: make utils method
-static void tanh(const Mat &src, Mat &dst)
-{
- dst.create(src.dims, (const int*)src.size, src.type());
-
- if (src.type() == CV_32F)
- tanh<float>(src, dst);
- else if (src.type() == CV_64F)
- tanh<double>(src, dst);
- else
- CV_Error(Error::StsUnsupportedFormat, "Function supports only floating point types");
-}
-
-static void sigmoid(const Mat &src, Mat &dst)
-{
- cv::exp(-src, dst);
- cv::pow(1 + dst, -1, dst);
-}
-
-class LSTMLayerImpl : public LSTMLayer
-{
- int numOut, numTimeStamps, numSamples, numInp;
- Mat hInternal, cInternal;
- Mat gates, dummyOnes;
- int dtype;
- bool allocated;
-
- Shape outTailShape; //shape of single output sample
- Shape outTsMatShape, outTsShape; //shape of N output samples
- Shape outResShape; //shape of T timestamps and N output samples
-
- bool useTimestampDim;
- bool produceCellOutput;
-
-public:
-
- LSTMLayerImpl()
- {
- type = "LSTM";
- useTimestampDim = true;
- produceCellOutput = false;
- allocated = false;
- outTailShape = Shape::empty();
- }
-
- void setUseTimstampsDim(bool use)
- {
- CV_Assert(!allocated);
- useTimestampDim = use;
- }
-
- void setProduceCellOutput(bool produce)
- {
- CV_Assert(!allocated);
- produceCellOutput = produce;
- }
-
- void setC(const Blob &C)
- {
- CV_Assert(cInternal.empty() || C.total() == cInternal.total());
- if (!cInternal.empty())
- C.reshaped(Shape::like(cInternal)).matRefConst().copyTo(cInternal);
- else
- C.matRefConst().copyTo(cInternal);
- }
-
- void setH(const Blob &H)
- {
- CV_Assert(hInternal.empty() || H.total() == hInternal.total());
- if (!hInternal.empty())
- H.reshaped(Shape::like(hInternal)).matRefConst().copyTo(hInternal);
- else
- H.matRefConst().copyTo(hInternal);
- }
-
- Blob getC() const
- {
- CV_Assert(!cInternal.empty());
-
- //TODO: add convinient Mat -> Blob constructor
- Blob res(outTsShape, cInternal.type());
- res.fill(res.shape(), res.type(), cInternal.data);
- return res;
- }
-
- Blob getH() const
- {
- CV_Assert(!hInternal.empty());
-
- Blob res(outTsShape, hInternal.type());
- res.fill(res.shape(), res.type(), hInternal.data);
- return res;
- }
-
- void setOutShape(const Shape &outTailShape_)
- {
- CV_Assert(!allocated || outTailShape_.total() == outTailShape.total());
- outTailShape = outTailShape_;
- }
-
- void setWeights(const Blob &Wh, const Blob &Wx, const Blob &bias)
- {
- CV_Assert(Wh.dims() == 2 && Wx.dims() == 2);
- CV_Assert(Wh.size(0) == Wx.size(0));
- CV_Assert(Wh.size(0) == 4*Wh.size(1));
- CV_Assert(Wh.size(0) == (int)bias.total());
- CV_Assert(Wh.type() == Wx.type() && Wx.type() == bias.type());
-
- blobs.resize(3);
- blobs[0] = Wh;
- blobs[1] = Wx;
- blobs[2] = bias;
- blobs[2].reshape(Shape(1, (int)bias.total()));
- }
-
- void allocate(const std::vector<Blob*> &input, std::vector<Blob> &output)
- {
- CV_Assert(blobs.size() == 3);
- CV_Assert(input.size() == 1);
-
- Blob &Wh = blobs[0], &Wx = blobs[1];
- numOut = Wh.size(1);
- numInp = Wx.size(1);
-
- if (!outTailShape.isEmpty())
- CV_Assert(outTailShape.total() == numOut);
- else
- outTailShape = Shape(numOut);
-
- if (useTimestampDim)
- {
- CV_Assert(input[0]->dims() >= 2 && (int)input[0]->total(2) == numInp);
- numTimeStamps = input[0]->size(0);
- numSamples = input[0]->size(1);
- outResShape = Shape(numTimeStamps, numSamples) + outTailShape;
- }
- else
- {
- CV_Assert(input[0]->dims() >= 1 && (int)input[0]->total(1) == numInp);
- numTimeStamps = 1;
- numSamples = input[0]->size(0);
- outResShape = Shape(numSamples) + outTailShape;
- }
- outTsMatShape = Shape(numSamples, numOut);
- outTsShape = Shape(numSamples) + outTailShape;
-
- dtype = input[0]->type();
- CV_Assert(dtype == CV_32F || dtype == CV_64F);
- CV_Assert(Wh.type() == dtype);
-
- output.resize( (produceCellOutput) ? 2 : 1 );
- output[0].create(outResShape, dtype);
- if (produceCellOutput)
- output[1].create(outResShape, dtype);
-
- if (hInternal.empty())
- {
- hInternal.create(outTsMatShape.dims(), outTsMatShape.ptr(), dtype);
- hInternal.setTo(0);
- }
- else
- {
- CV_Assert((int)hInternal.total() == numSamples*numOut);
- hInternal = hInternal.reshape(1, outTsMatShape.dims(), outTsMatShape.ptr());
- }
-
- if (cInternal.empty())
- {
- cInternal.create(outTsMatShape.dims(), outTsMatShape.ptr(), dtype);
- cInternal.setTo(0);
- }
- else
- {
- CV_Assert((int)cInternal.total() == numSamples*numOut);
- cInternal = cInternal.reshape(1, outTsMatShape.dims(), outTsMatShape.ptr());
- }
-
- gates.create(numSamples, 4*numOut, dtype);
-
- dummyOnes.create(numSamples, 1, dtype);
- dummyOnes.setTo(1);
-
- allocated = true;
- }
-
- void forward(std::vector<Blob*> &input, std::vector<Blob> &output)
- {
- const Mat &Wh = blobs[0].getRefConst<Mat>();
- const Mat &Wx = blobs[1].getRefConst<Mat>();
- const Mat &bias = blobs[2].getRefConst<Mat>();
-
- int numSamplesTotal = numTimeStamps*numSamples;
- Mat xTs = reshaped(input[0]->getRefConst<Mat>(), Shape(numSamplesTotal, numInp));
-
- Shape outMatShape(numSamplesTotal, numOut);
- Mat hOutTs = reshaped(output[0].getRef<Mat>(), outMatShape);
- Mat cOutTs = (produceCellOutput) ? reshaped(output[1].getRef<Mat>(), outMatShape) : Mat();
-
- for (int ts = 0; ts < numTimeStamps; ts++)
- {
- Range curRowRange(ts*numSamples, (ts + 1)*numSamples);
- Mat xCurr = xTs.rowRange(curRowRange);
-
- dnn::gemm(xCurr, Wx, 1, gates, 0, GEMM_2_T); // Wx * x_t
- dnn::gemm(hInternal, Wh, 1, gates, 1, GEMM_2_T); //+Wh * h_{t-1}
- dnn::gemm(dummyOnes, bias, 1, gates, 1); //+b
-
- Mat getesIFO = gates.colRange(0, 3*numOut);
- Mat gateI = gates.colRange(0*numOut, 1*numOut);
- Mat gateF = gates.colRange(1*numOut, 2*numOut);
- Mat gateO = gates.colRange(2*numOut, 3*numOut);
- Mat gateG = gates.colRange(3*numOut, 4*numOut);
-
- sigmoid(getesIFO, getesIFO);
- tanh(gateG, gateG);
-
- //compute c_t
- cv::multiply(gateF, cInternal, gateF); // f_t (*) c_{t-1}
- cv::multiply(gateI, gateG, gateI); // i_t (*) g_t
- cv::add(gateF, gateI, cInternal); // c_t = f_t (*) c_{t-1} + i_t (*) g_t
-
- //compute h_t
- tanh(cInternal, hInternal);
- cv::multiply(gateO, hInternal, hInternal);
-
- //save results in output blobs
- hInternal.copyTo(hOutTs.rowRange(curRowRange));
- if (produceCellOutput)
- cInternal.copyTo(cOutTs.rowRange(curRowRange));
- }
- }
-};
-
-Ptr<LSTMLayer> LSTMLayer::create()
-{
- return Ptr<LSTMLayer>(new LSTMLayerImpl());
-}
-
-void LSTMLayer::forward(std::vector<Blob*>&, std::vector<Blob>&)
-{
- CV_Error(Error::StsInternal, "This function should be unreached");
-}
-
-int LSTMLayer::inputNameToIndex(String inputName)
-{
- if (inputName.toLowerCase() == "x")
- return 0;
- return -1;
-}
-
-int LSTMLayer::outputNameToIndex(String outputName)
-{
- if (outputName.toLowerCase() == "h")
- return 0;
- else if (outputName.toLowerCase() == "c")
- return 1;
- return -1;
-}
-
-
-class RNNLayerImpl : public RNNLayer
-{
- int numX, numH, numO;
- int numSamples, numTimestamps, numSamplesTotal;
- int dtype;
- Mat Whh, Wxh, bh;
- Mat Who, bo;
- Mat hCurr, hPrev, dummyBiasOnes;
- bool produceH;
-
-public:
-
- RNNLayerImpl()
- {
- type = "RNN";
- produceH = false;
- }
-
- void setProduceHiddenOutput(bool produce = false)
- {
- produceH = produce;
- }
-
- void setWeights(const Blob &W_xh, const Blob &b_h, const Blob &W_hh, const Blob &W_ho, const Blob &b_o)
- {
- CV_Assert(W_hh.dims() == 2 && W_xh.dims() == 2);
- CV_Assert(W_hh.size(0) == W_xh.size(0) && W_hh.size(0) == W_hh.size(1) && (int)b_h.total() == W_xh.size(0));
- CV_Assert(W_ho.size(0) == (int)b_o.total());
- CV_Assert(W_ho.size(1) == W_hh.size(1));
-
- blobs.resize(5);
- blobs[0] = W_xh;
- blobs[1] = b_h;
- blobs[2] = W_hh;
- blobs[3] = W_ho;
- blobs[4] = b_o;
- }
-
- void allocate(const std::vector<Blob*> &input, std::vector<Blob> &output)
- {
- CV_Assert(input.size() >= 1 && input.size() <= 2);
-
- Wxh = blobs[0].matRefConst();
- bh = blobs[1].matRefConst();
- Whh = blobs[2].matRefConst();
- Who = blobs[3].matRefConst();
- bo = blobs[4].matRefConst();
-
- numH = Wxh.rows;
- numX = Wxh.cols;
- numO = Who.rows;
-
- CV_Assert(input[0]->dims() >= 2);
- CV_Assert((int)input[0]->total(2) == numX);
- CV_Assert(input[0]->type() == CV_32F || input[0]->type() == CV_64F);
- dtype = input[0]->type();
- numTimestamps = input[0]->size(0);
- numSamples = input[0]->size(1);
- numSamplesTotal = numTimestamps * numSamples;
-
- hCurr.create(numSamples, numH, dtype);
- hPrev.create(numSamples, numH, dtype);
- hPrev.setTo(0);
-
- dummyBiasOnes.create(numSamples, 1, dtype);
- dummyBiasOnes.setTo(1);
- bh = bh.reshape(1, 1); //is 1 x numH Mat
- bo = bo.reshape(1, 1); //is 1 x numO Mat
-
- reshapeOutput(output);
- }
-
- void reshapeOutput(std::vector<Blob> &output)
- {
- output.resize((produceH) ? 2 : 1);
- output[0].create(Shape(numTimestamps, numSamples, numO), dtype);
- if (produceH)
- output[1].create(Shape(numTimestamps, numSamples, numH), dtype);
- }
-
- void forward(std::vector<Blob*> &input, std::vector<Blob> &output)
- {
- Mat xTs = reshaped(input[0]->getRefConst<Mat>(), Shape(numSamplesTotal, numX));
- Mat oTs = reshaped(output[0].getRef<Mat>(), Shape(numSamplesTotal, numO));
- Mat hTs = (produceH) ? reshaped(output[1].getRef<Mat>(), Shape(numSamplesTotal, numH)) : Mat();
-
- for (int ts = 0; ts < numTimestamps; ts++)
- {
- Range curRowRange = Range(ts * numSamples, (ts + 1) * numSamples);
- Mat xCurr = xTs.rowRange(curRowRange);
-
- dnn::gemm(hPrev, Whh, 1, hCurr, 0, GEMM_2_T); // W_{hh} * h_{prev}
- dnn::gemm(xCurr, Wxh, 1, hCurr, 1, GEMM_2_T); //+W_{xh} * x_{curr}
- dnn::gemm(dummyBiasOnes, bh, 1, hCurr, 1); //+bh
- tanh(hCurr, hPrev);
-
- Mat oCurr = oTs.rowRange(curRowRange);
- dnn::gemm(hPrev, Who, 1, oCurr, 0, GEMM_2_T); // W_{ho} * h_{prev}
- dnn::gemm(dummyBiasOnes, bo, 1, oCurr, 1); //+b_o
- tanh(oCurr, oCurr);
-
- if (produceH)
- hPrev.copyTo(hTs.rowRange(curRowRange));
- }
- }
-};
-
-void RNNLayer::forward(std::vector<Blob*>&, std::vector<Blob>&)
-{
- CV_Error(Error::StsInternal, "This function should be unreached");
-}
-
-CV_EXPORTS_W Ptr<RNNLayer> RNNLayer::create()
-{
- return Ptr<RNNLayer>(new RNNLayerImpl());
-}
-
-}
-}
diff --git a/contrib/modules/dnn/src/layers/recurrent_layers.hpp b/contrib/modules/dnn/src/layers/recurrent_layers.hpp
deleted file mode 100644
index 5445121..0000000
--- a/contrib/modules/dnn/src/layers/recurrent_layers.hpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_LAYERS_RECURRENT_LAYERS_HPP__
-#define __OPENCV_DNN_LAYERS_RECURRENT_LAYERS_HPP__
-#include "../precomp.hpp"
-#include <opencv2/dnn/all_layers.hpp>
-
-namespace cv
-{
-namespace dnn
-{
-
-}
-}
-#endif
\ No newline at end of file
diff --git a/contrib/modules/dnn/src/layers/reshape_layer.cpp b/contrib/modules/dnn/src/layers/reshape_layer.cpp
deleted file mode 100644
index 6bc9ebc..0000000
--- a/contrib/modules/dnn/src/layers/reshape_layer.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "../precomp.hpp"
-#include "layers_common.hpp"
-#include "reshape_layer.hpp"
-#include <opencv2/dnn/shape_utils.hpp>
-
-namespace cv
-{
-namespace dnn
-{
-
-ReshapeLayerImpl::ReshapeLayerImpl(const BlobShape &newShape_, Range applyingRange_, bool enableReordering_) :
- enableReordering(enableReordering_)
-{
- newShapeDesc = newShape_;
- newShapeRange = applyingRange_;
-}
-
-void ReshapeLayerImpl::allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- outputs.resize(inputs.size());
- outShapes.resize(inputs.size());
-
- for (size_t i = 0; i < inputs.size(); i++)
- {
- outShapes[i] = computeShapeByReshapeMask(inputs[i]->shape(), newShapeDesc, newShapeRange);
- outputs[i].shareFrom(*inputs[i]);
- outputs[i].reshape(outShapes[i]);
- }
-}
-
-void ReshapeLayerImpl::forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- for (size_t i = 0; i < outputs.size(); i++)
- {
- Blob& srcBlob = *inputs[i];
- BlobShape inputShape = inputs[i]->shape();
- bool channelsReduced = inputShape.dims() > outShapes[i].dims() ||
- (inputShape.dims() == 4 && inputShape[1] > outShapes[i][1]);
- bool performReordering = enableReordering && inputShape.dims() == 4 && channelsReduced;
-
- if (performReordering)
- {
- Blob reordered_blob(inputShape, inputs[i]->type());
-
- float *dstData = reordered_blob.matRef().ptr<float>();
- const float *srcData = srcBlob.matRefConst().ptr<float>();
-
- int num = inputShape[0], channels = inputShape[1], height = inputShape[2], width = inputShape[3];
- int total = num*channels*height*width;
- for(int i_n = 0; i_n < num; i_n++) {
- for(int i_c = 0; i_c < channels; i_c++) {
- for(int i_h = 0; i_h < height; i_h++) {
- for(int i_w = 0; i_w < width; i_w++) {
- int src_i = channels*height*width*i_n + height*width*i_c + width*i_h + i_w;
- int dst_i = channels*height*width*i_n + i_c + channels*width*i_h + channels*i_w;
-
- CV_Assert(dst_i < total);
- CV_Assert(src_i < total);
-
- dstData[dst_i] = srcData[src_i];
- }
- }
- }
- }
-
- srcBlob = reordered_blob;
- }
-
- outputs[i].shareFrom(srcBlob);
- outputs[i].reshape(outShapes[i]);
- }
-}
-
-Ptr<ReshapeLayer> ReshapeLayer::create(const BlobShape &newShape, Range applyingRange /*= Range::all()*/,
- bool enableReordering /*= false*/)
-{
- return Ptr<ReshapeLayer>(new ReshapeLayerImpl(newShape, applyingRange, enableReordering));
-}
-
-
-}
-}
diff --git a/contrib/modules/dnn/src/layers/reshape_layer.hpp b/contrib/modules/dnn/src/layers/reshape_layer.hpp
deleted file mode 100644
index 10718b8..0000000
--- a/contrib/modules/dnn/src/layers/reshape_layer.hpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_LAYERS_RESHAPE_LAYER_HPP__
-#define __OPENCV_DNN_LAYERS_RESHAPE_LAYER_HPP__
-#include "../precomp.hpp"
-#include <opencv2/dnn/all_layers.hpp>
-
-namespace cv
-{
-namespace dnn
-{
-
-class ReshapeLayerImpl : public ReshapeLayer
-{
- std::vector<BlobShape> outShapes;
- bool enableReordering;
-
-public:
- ReshapeLayerImpl(const BlobShape &newShape_, Range applyingRange_, bool enableReordering_);
-
- void allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
-
- void forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
-};
-
-Ptr<Layer> createFlattenLayer(LayerParams&);
-
-}
-}
-
-#endif
diff --git a/contrib/modules/dnn/src/layers/shift_layer.cpp b/contrib/modules/dnn/src/layers/shift_layer.cpp
deleted file mode 100644
index 98bfdfc..0000000
--- a/contrib/modules/dnn/src/layers/shift_layer.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-// This file is part of OpenCV project.
-// It is subject to the license terms in the LICENSE file found in the top-level directory
-// of this distribution and at http://opencv.org/license.html.
-
-// Copyright (C) 2016, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-
-/*
-Implementation of shift layer, which adds up const values to blob.
-*/
-
-#include "../precomp.hpp"
-#include "shift_layer.hpp"
-#include "op_blas.hpp"
-
-namespace cv
-{
-namespace dnn
-{
-
-class ShiftLayerImpl {
-public:
- static Ptr<ShiftLayerImpl> create(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs,
- const std::vector<Blob>& blobs);
-
- virtual ~ShiftLayerImpl() {}
-
- virtual void forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs, const std::vector<Blob>& blobs) = 0;
-
-protected:
- ShiftLayerImpl() {}
- virtual void allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs, const std::vector<Blob>& blobs) = 0;
-};
-
-namespace {
-
-class ShiftChannelsLayerImpl : public ShiftLayerImpl {
-public:
- virtual void forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs, const std::vector<Blob>& blobs) {
- for (size_t ii = 0; ii < outputs.size(); ii++)
- {
- Blob &inpBlob = *inputs[ii];
- Blob &outBlob = outputs[ii];
-
- inpBlob.matRef().copyTo(outBlob.matRef());
-
- for (int n = 0; n < inpBlob.num(); n++)
- {
- Mat dstMat(inpBlob.channels(), inpBlob.rows() * inpBlob.cols(),
- outBlob.type(), outBlob.ptr(n));
- dnn::gemm(blobs[0].matRefConst(), biasOnesMat, 1, dstMat, 1); //TODO: gemv
- }
- }
- }
-
-protected:
- virtual void allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs, const std::vector<Blob>& blobs) {
- CV_Assert(inputs.size() > 0);
-
- const Blob &inpBlob = *inputs[0];
- CV_Assert(inpBlob.dims() == 4 && inpBlob.type() == CV_32F);
- const Blob &biasBlob = blobs[0];
- CV_Assert(biasBlob.total() == (size_t)inpBlob.channels());
-
- outputs.resize(inputs.size());
- for (size_t i = 0; i < inputs.size(); i++)
- {
- CV_Assert(inputs[i]->type() == inpBlob.type());
- CV_Assert(inputs[i]->dims() == 4 && inputs[i]->channels() == inpBlob.channels());
-
- outputs[i].shareFrom(*inputs[i]);
- }
-
- biasOnesMat = Mat::ones(1, inpBlob.rows() * inpBlob.cols(), inpBlob.type());
- }
-
-private:
- Mat biasOnesMat;
-};
-
-
-class ShiftElementsLayerImpl : public ShiftLayerImpl {
-public:
- virtual void forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs, const std::vector<Blob>& blobs) {
- for (size_t ii = 0; ii < outputs.size(); ii++)
- {
- Blob &inpBlob = *inputs[ii];
- Blob &outBlob = outputs[ii];
-
- outBlob.matRef() = inpBlob.matRef() + blobs[0].matRefConst();
- }
- }
-
-protected:
- virtual void allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs, const std::vector<Blob>& blobs) {
- CV_Assert(inputs.size() > 0);
-
- const Blob &inpBlob = *inputs[0];
- CV_Assert(inpBlob.type() == CV_32F);
- const Blob &biasBlob = blobs[0];
- CV_Assert(biasBlob.dims() == inpBlob.dims());
-
- outputs.resize(inputs.size());
- for (size_t i = 0; i < inputs.size(); i++)
- {
- CV_Assert(inputs[i]->type() == inpBlob.type());
- CV_Assert(inputs[i]->dims() == inpBlob.dims());
-
- outputs[i].shareFrom(*inputs[i]);
- }
- }
-};
-
-}
-
-Ptr<ShiftLayerImpl> ShiftLayerImpl::create(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs,
- const std::vector<Blob>& blobs) {
- Ptr<ShiftLayerImpl> impl;
-
- CV_Assert(inputs.size() > 0);
- CV_Assert(blobs.size() > 0);
-
- if(inputs[0]->dims() == blobs[0].dims())
- impl = Ptr<ShiftLayerImpl>(new ShiftElementsLayerImpl);
- else
- impl = Ptr<ShiftLayerImpl>(new ShiftChannelsLayerImpl);
-
- impl->allocate(inputs, outputs, blobs);
- return impl;
-}
-
-ShiftLayer::ShiftLayer(LayerParams ¶ms) : Layer(params)
-{
- CV_Assert(blobs.size() == 1);
-
- #ifdef HAVE_LAPACK
- {
- if (getBlasThreads() != cv::getThreadNum())
- {
- setBlasThreads(cv::getThreadNum());
- }
- }
- #endif
-}
-
-void ShiftLayer::allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- impl = ShiftLayerImpl::create(inputs, outputs, blobs);
-}
-
-void ShiftLayer::forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- impl->forward(inputs, outputs, blobs);
-}
-
-}
-}
diff --git a/contrib/modules/dnn/src/layers/shift_layer.hpp b/contrib/modules/dnn/src/layers/shift_layer.hpp
deleted file mode 100644
index 1d1c70a..0000000
--- a/contrib/modules/dnn/src/layers/shift_layer.hpp
+++ /dev/null
@@ -1,36 +0,0 @@
-// This file is part of OpenCV project.
-// It is subject to the license terms in the LICENSE file found in the top-level directory
-// of this distribution and at http://opencv.org/license.html.
-
-// Copyright (C) 2016, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-
-/*
-Declaration of shift layer, which adds up const values to blob.
-*/
-
-#ifndef __OPENCV_DNN_LAYERS_SHIFT_LAYER_HPP__
-#define __OPENCV_DNN_LAYERS_SHIFT_LAYER_HPP__
-#include "../precomp.hpp"
-
-namespace cv
-{
-namespace dnn
-{
-
-class ShiftLayerImpl;
-
-class ShiftLayer : public Layer
-{
- cv::Ptr<ShiftLayerImpl> impl;
-
-public:
- ShiftLayer() {}
- ShiftLayer(LayerParams ¶ms);
- void allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
- void forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
-};
-
-}
-}
-#endif
diff --git a/contrib/modules/dnn/src/layers/slice_layer.cpp b/contrib/modules/dnn/src/layers/slice_layer.cpp
deleted file mode 100644
index 01dc27f..0000000
--- a/contrib/modules/dnn/src/layers/slice_layer.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "../precomp.hpp"
-#include "layers_common.hpp"
-#include "slice_layer.hpp"
-#include <opencv2/core/ocl.hpp>
-#include <opencv2/dnn/shape_utils.hpp>
-
-namespace cv
-{
-namespace dnn
-{
-
-SliceLayerImpl::SliceLayerImpl(int axis_ /*= 1*/)
-{
- axis = axis_;
-}
-
-SliceLayerImpl::SliceLayerImpl(int axis_, const std::vector<int> &sliceIndices_)
-{
- axis = axis_;
- sliceIndices = sliceIndices_;
-}
-
-void SliceLayerImpl::allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- CV_Assert(inputs.size() == 1);
-
- const Blob &inpBlob = *inputs[0];
- useOpenCL = ocl::useOpenCL() && inpBlob.getState() == Blob::HEAD_AT_UMAT;
-
- axisIdx = inpBlob.canonicalAxis(axis);
- int axisSize = inpBlob.size(axisIdx);
- BlobShape inpShape = inpBlob.shape();
- int allocFlags = useOpenCL ? Blob::ALLOC_UMAT : Blob::ALLOC_MAT;
-
- if (sliceIndices.size()) //divide blob with respect to passed parameters
- {
- std::vector<int> outAxisSize;
- int prevSlice = 0;
-
- for (size_t i = 0; i < sliceIndices.size(); i++)
- {
- if (!(prevSlice < sliceIndices[i] && sliceIndices[i] < axisSize))
- CV_Error(Error::StsBadArg, "Slice indices should be positive, increased and don't exceed size of sliced dimension");
-
- outAxisSize.push_back(sliceIndices[i] - prevSlice);
- prevSlice = sliceIndices[i];
- }
- outAxisSize.push_back(axisSize - prevSlice);
-
- outputs.resize(outAxisSize.size());
- for (size_t i = 0; i < outAxisSize.size(); i++)
- {
- inpShape[axisIdx] = outAxisSize[i];
- outputs[i].create(inpShape, inpBlob.type(), allocFlags);
- }
- }
- else //divide blob with respect to count of output blobs
- {
- CV_Assert(outputs.size() > 0 && axisSize % outputs.size() == 0);
- int outAxisSize = axisSize / (int)outputs.size();
-
- for (size_t i = 0; i < outputs.size(); i++)
- {
- inpShape[axisIdx] = outAxisSize;
- outputs[i].create(inpShape, inpBlob.type(), allocFlags);
- }
- }
-}
-
-void SliceLayerImpl::forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- #ifdef HAVE_OPENCL
- if (useOpenCL)
- forward_<UMat>(inputs, outputs);
- else
- #endif
- forward_<Mat>(inputs, outputs);
-}
-
-template<typename XMat>
-void SliceLayerImpl::forward_(std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- const XMat& inpMat = inputs[0]->getRefConst<XMat>();
- std::vector<Range> ranges(inputs[0]->dims(), Range::all());
-
- ranges[axisIdx].start = 0;
- for (size_t i = 0; i < outputs.size(); i++)
- {
- ranges[axisIdx].end = ranges[axisIdx].start + outputs[i].size(axisIdx);
- inpMat(&ranges[0]).copyTo(outputs[i].getRef<XMat>());
- ranges[axisIdx].start = ranges[axisIdx].end;
- }
-}
-
-Ptr<SliceLayer> SliceLayer::create(int axis)
-{
- return Ptr<SliceLayer>(new SliceLayerImpl(axis));
-}
-
-Ptr<SliceLayer> SliceLayer::create(int axis, const std::vector<int> &sliceIndices)
-{
- return Ptr<SliceLayer>(new SliceLayerImpl(axis, sliceIndices));
-}
-
-}
-}
diff --git a/contrib/modules/dnn/src/layers/slice_layer.hpp b/contrib/modules/dnn/src/layers/slice_layer.hpp
deleted file mode 100644
index 4f7cbb3..0000000
--- a/contrib/modules/dnn/src/layers/slice_layer.hpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_LAYERS_SLICE_LAYER_HPP__
-#define __OPENCV_DNN_LAYERS_SLICE_LAYER_HPP__
-#include "../precomp.hpp"
-#include <opencv2/dnn/all_layers.hpp>
-
-namespace cv
-{
-namespace dnn
-{
-
-class SliceLayerImpl : public SliceLayer
-{
- bool useOpenCL;
- int axisIdx;
-
- template<typename XMat>
- void forward_(std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
-
-public:
- SliceLayerImpl(int axis_ = 1);
- SliceLayerImpl(int axis_, const std::vector<int> &sliceIndices_);
-
- void allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
-
- void forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
-};
-
-}
-}
-#endif
diff --git a/contrib/modules/dnn/src/layers/softmax_layer.cpp b/contrib/modules/dnn/src/layers/softmax_layer.cpp
deleted file mode 100644
index 576ed4d..0000000
--- a/contrib/modules/dnn/src/layers/softmax_layer.cpp
+++ /dev/null
@@ -1,224 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "../precomp.hpp"
-#include "layers_common.hpp"
-#include "softmax_layer.hpp"
-#include <opencv2/core/ocl.hpp>
-#include "modules/dnn/opencl_kernels_dnn.hpp"
-#include <algorithm>
-#include <stdlib.h>
-using std::max;
-
-namespace cv
-{
-namespace dnn
-{
-
-SoftMaxLayerImpl::SoftMaxLayerImpl(int axis)
-{
- axisRaw = axis;
-}
-
-void SoftMaxLayerImpl::allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- CV_Assert(inputs.size() == 1);
- axis = inputs[0]->canonicalAxis(axisRaw);
-
- useOpenCL = ocl::useOpenCL();
-
- BlobShape shape = inputs[0]->shape();
- outerSize = shape.total(0, axis);
- channels = shape[axis];
- innerSize = shape.total(axis + 1);
-
- int allocFlag = (useOpenCL) ? Blob::ALLOC_UMAT : Blob::ALLOC_MAT;
- shape[axis] = 1;
- buf.create(shape, inputs[0]->type(), allocFlag);
-
- outputs.resize(1);
- outputs[0].create(inputs[0]->shape(), inputs[0]->type(), allocFlag);
-}
-
-void SoftMaxLayerImpl::forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- Blob &src = *inputs[0];
- Blob &dst = outputs[0];
-
- if (!useOpenCL)
- forward_cpu(src, dst);
- else
- {
- CV_Assert(forward_ocl(src, dst));
- }
-}
-
-#ifdef HAVE_OPENCL
-bool SoftMaxLayerImpl::forward_ocl(Blob &src, Blob &dst)
-{
- const UMat &srcMat = src.umatRefConst();
- UMat &dstMat = dst.umatRef();
- srcMat.copyTo(dstMat);
- UMat &bufMat = buf.umatRef();
- CV_Assert(dstMat.offset == 0);
-
- String buildOpts = String("-DT=") + ocl::typeToStr(src.type());
- ocl::Kernel kmax, ksub, ksum, kdiv;
-
- if (!kmax.create("kernel_channel_max", ocl::dnn::softmax_oclsrc, buildOpts))
- return false;
-
- if (!ksub.create("kernel_channel_subtract", ocl::dnn::softmax_oclsrc, buildOpts))
- return false;
-
- if (!ksum.create("kernel_channel_sum", ocl::dnn::softmax_oclsrc, buildOpts))
- return false;
-
- if (!kdiv.create("kernel_channel_div", ocl::dnn::softmax_oclsrc, buildOpts))
- return false;
-
- size_t wgSize = ocl::Device::getDefault().maxWorkGroupSize();
- size_t bufSize = buf.total();
- size_t totalSize = src.total();
-
- kmax.args((int)outerSize, (int)channels, (int)innerSize,
- ocl::KernelArg::PtrReadOnly(dstMat), ocl::KernelArg::PtrReadWrite(bufMat));
- if (!kmax.run(1, &bufSize, &wgSize, true))
- return false;
-
- ksub.args((int)totalSize, (int)outerSize, (int)channels, (int)innerSize,
- ocl::KernelArg::PtrReadOnly(bufMat), ocl::KernelArg::PtrReadWrite(dstMat));
- if (!ksub.run(1, &totalSize, &wgSize, true))
- return false;
-
- cv::exp(dstMat, dstMat);
-
- ksum.args((int)outerSize, (int)channels, (int)innerSize,
- ocl::KernelArg::PtrReadOnly(dstMat), ocl::KernelArg::PtrReadWrite(bufMat));
- if (!ksum.run(1, &bufSize, &wgSize, true))
- return false;
-
- kdiv.args((int)totalSize, (int)outerSize, (int)channels, (int)innerSize,
- ocl::KernelArg::PtrReadOnly(bufMat), ocl::KernelArg::PtrReadWrite(dstMat));
- if (!kdiv.run(1, &totalSize, &wgSize, true))
- return false;
-
- return true;
-}
-#else
-bool SoftMaxLayerImpl::forward_ocl(Blob&, Blob&)
-{
- return false;
-}
-#endif
-
-void SoftMaxLayerImpl::forward_cpu(Blob &src, Blob &dst)
-{
- CV_Assert(src.type() == CV_32F);
-
- float *srcPtr = src.ptrf();
- float *dstPtr = dst.ptrf();
- float *bufPtr = buf.ptrf();
-
- size_t outerStep = src.total(axis);
- size_t cnStep = src.total(axis + 1);
-
- //compute max along axis
- for (size_t outerDim = 0; outerDim < outerSize; outerDim++)
- {
- size_t srcOffset = outerDim * outerStep;
- size_t bufOffset = outerDim * cnStep;
-
- memcpy(bufPtr + bufOffset, srcPtr + srcOffset, innerSize * sizeof(float));
-
- for (size_t cnDim = 1; cnDim < channels; cnDim++)
- {
- for (size_t i = 0; i < innerSize; i++)
- bufPtr[bufOffset + i] = std::max(bufPtr[bufOffset + i], srcPtr[srcOffset + cnDim * cnStep + i]);
- }
- }
-
- //subtract max
- for (size_t outerDim = 0; outerDim < outerSize; outerDim++)
- {
- size_t srcOffset = outerDim * outerStep;
- size_t bufOffset = outerDim * cnStep;
-
- for (size_t cnDim = 0; cnDim < channels; cnDim++)
- {
- for (size_t i = 0; i < innerSize; i++)
- dstPtr[srcOffset + cnDim * cnStep + i] = srcPtr[srcOffset + cnDim * cnStep + i] - bufPtr[bufOffset + i];
- }
- }
-
- cv::exp(dst.matRef(), dst.matRef());
-
- for (size_t outerDim = 0; outerDim < outerSize; outerDim++)
- {
- size_t srcOffset = outerDim * outerStep;
- size_t bufOffset = outerDim * cnStep;
-
- //sum exp along axis
- for (size_t i = 0; i < innerSize; i++)
- bufPtr[bufOffset + i] = 0.f;
-
- for (size_t cnDim = 0; cnDim < channels; cnDim++)
- {
- for (size_t i = 0; i < innerSize; i++)
- bufPtr[bufOffset + i] += dstPtr[srcOffset + cnDim * cnStep + i];
- }
-
- //divide by computed sum
- for (size_t cnDim = 0; cnDim < channels; cnDim++)
- {
- for (size_t i = 0; i < innerSize; i++)
- dstPtr[srcOffset + cnDim * cnStep + i] /= bufPtr[bufOffset + i];
- }
- }
-}
-
-Ptr<SoftmaxLayer> SoftmaxLayer::create(int axis)
-{
- return Ptr<SoftmaxLayer>(new SoftMaxLayerImpl(axis));
-}
-
-}
-}
diff --git a/contrib/modules/dnn/src/layers/softmax_layer.hpp b/contrib/modules/dnn/src/layers/softmax_layer.hpp
deleted file mode 100644
index fad97dd..0000000
--- a/contrib/modules/dnn/src/layers/softmax_layer.hpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_LAYERS_SOFTMAX_LAYER_HPP__
-#define __OPENCV_DNN_LAYERS_SOFTMAX_LAYER_HPP__
-#include "../precomp.hpp"
-#include <opencv2/dnn/all_layers.hpp>
-
-namespace cv
-{
-namespace dnn
-{
-
-class SoftMaxLayerImpl : public SoftmaxLayer
-{
- int axis, axisRaw;
- Blob buf;
- bool useOpenCL;
- size_t outerSize, channels, innerSize;
-
-
- bool forward_ocl(Blob &src, Blob &dst);
- void forward_cpu(Blob &src, Blob &dst);
-
-public:
-
- SoftMaxLayerImpl(int axis = 1);
- void allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
- void forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
-};
-
-}
-}
-#endif
diff --git a/contrib/modules/dnn/src/layers/split_layer.cpp b/contrib/modules/dnn/src/layers/split_layer.cpp
deleted file mode 100644
index cd3a507..0000000
--- a/contrib/modules/dnn/src/layers/split_layer.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "../precomp.hpp"
-#include "layers_common.hpp"
-#include "split_layer.hpp"
-#include <opencv2/core/ocl.hpp>
-
-namespace cv
-{
-namespace dnn
-{
-
-SplitLayerImpl::SplitLayerImpl(int outputsCount_ /*= -1*/)
-{
- outputsCount = outputsCount_;
-}
-
-void SplitLayerImpl::allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- CV_Assert(inputs.size() == 1);
- useOpenCL = ocl::useOpenCL() && inputs[0]->getState() == Blob::HEAD_AT_UMAT;
- int allocFlags = useOpenCL ? Blob::ALLOC_UMAT : Blob::ALLOC_MAT;
-
- if (outputsCount >= 0)
- outputs.resize(outputsCount);
-
- for (size_t i = 0; i < outputs.size(); i++)
- outputs[i].create(inputs[0]->shape(), inputs[0]->type(), allocFlags);
-}
-
-void SplitLayerImpl::forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs)
-{
- for (size_t i = 0; i < outputs.size(); i++)
- {
- if (useOpenCL)
- inputs[0]->umatRefConst().copyTo(outputs[i].umatRef());
- else
- inputs[0]->matRefConst().copyTo(outputs[i].matRef());
- }
-}
-
-
-Ptr<SplitLayer> SplitLayer::create(int outputsCount)
-{
- return Ptr<SplitLayer>(new SplitLayerImpl(outputsCount));
-}
-
-}
-}
diff --git a/contrib/modules/dnn/src/layers/split_layer.hpp b/contrib/modules/dnn/src/layers/split_layer.hpp
deleted file mode 100644
index 124cb12..0000000
--- a/contrib/modules/dnn/src/layers/split_layer.hpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_LAYERS_SPLIT_LAYER_HPP__
-#define __OPENCV_DNN_LAYERS_SPLIT_LAYER_HPP__
-#include "../precomp.hpp"
-#include <opencv2/dnn/all_layers.hpp>
-
-namespace cv
-{
-namespace dnn
-{
-
-class SplitLayerImpl : public SplitLayer
-{
- bool useOpenCL;
-
-public:
- SplitLayerImpl(int outputsCount_ = -1);
-
- void allocate(const std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
-
- void forward(std::vector<Blob*> &inputs, std::vector<Blob> &outputs);
-};
-
-}
-}
-#endif
diff --git a/contrib/modules/dnn/src/opencl/activations.cl b/contrib/modules/dnn/src/opencl/activations.cl
deleted file mode 100644
index 58da4db..0000000
--- a/contrib/modules/dnn/src/opencl/activations.cl
+++ /dev/null
@@ -1,44 +0,0 @@
-__kernel void ReLUForward(const int count, __global const T* in, __global T* out
-#ifndef RELU_NO_SLOPE
-, T negative_slope
-#endif
-) {
- int index = get_global_id(0);
- if(index < count)
-#ifndef RELU_NO_SLOPE
- out[index] = in[index] > 0 ? in[index] : in[index] * negative_slope;
-#else
- out[index] = in[index] > 0 ? in[index] : 0;
-#endif
-}
-
-__kernel void TanHForward(const int count, __global T* in, __global T* out) {
- int index = get_global_id(0);
- if(index < count)
- out[index] = tanh(in[index]);
-}
-
-__kernel void SigmoidForward(const int count, __global const T* in, __global T* out) {
- int index = get_global_id(0);
- if(index < count)
- out[index] = 1. / (1. + exp(-in[index]));
-}
-
-__kernel void BNLLForward(const int n, __global const T* in, __global T* out) {
- int index = get_global_id(0);
- if (index < n) {
- out[index] = in[index] > 0 ? in[index] + log(1. + exp(-in[index])) : log(1. + exp(in[index]));
- }
-}
-
-__kernel void AbsValForward(const int n, __global const T* in, __global T* out) {
- int index = get_global_id(0);
- if (index < n)
- out[index] = fabs(in[index]);
-}
-
-__kernel void PowForward(const int n, __global const T* in, __global T* out, const T power, const T scale, const T shift) {
- int index = get_global_id(0);
- if (index < n)
- out[index] = pow(shift + scale * in[index], power);
-}
\ No newline at end of file
diff --git a/contrib/modules/dnn/src/opencl/pooling.cl b/contrib/modules/dnn/src/opencl/pooling.cl
deleted file mode 100644
index aeb70bc..0000000
--- a/contrib/modules/dnn/src/opencl/pooling.cl
+++ /dev/null
@@ -1,94 +0,0 @@
-/*************************************************************************************
- * Copyright (c) 2015, Advanced Micro Devices, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation and/or
- * other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
- * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- **************************************************************************************/
-
-__kernel void MaxPoolForward(const int nthreads, __global T* bottom_data, const int num, const int channels, const int height, const int width, const int pooled_height, const int pooled_width, const int kernel_h, const int kernel_w, const int stride_h, const int stride_w, const int pad_h, const int pad_w, __global T* top_data
-#ifdef MASK
- , __global int* mask, __global T* top_mask
-#endif
-) {
- int index = get_global_id(0);
- int tmp = get_global_size(0);
- for(index; index < nthreads; index += tmp) {
- int pw = index % pooled_width;
- int ph = (index / pooled_width) % pooled_height;
- int c = (index / pooled_width / pooled_height) % channels;
- int n = index / pooled_width / pooled_height / channels;
- int hstart = ph * stride_h - pad_h;
- int wstart = pw * stride_w - pad_w;
- const int hend = min(hstart + kernel_h, height);
- const int wend = min(wstart + kernel_w, width);
- hstart = max(hstart, 0);
- wstart = max(wstart, 0);
- T maxval = -FLT_MAX;
- int maxidx = -1;
- bottom_data =
- bottom_data + (n * channels + c) * height * width;
- for (int h = hstart; h < hend; ++h) {
- for (int w = wstart; w < wend; ++w) {
- if (bottom_data[h * width + w] > maxval) {
- maxidx = h * width + w;
- maxval = bottom_data[maxidx];
- }
- }
- }
- top_data[index] = maxval;
-#ifdef MASK
- if (mask) {
- mask[index] = maxidx;
- } else {
- top_mask[index] = maxidx;
- }
-#endif
- }
-}
-
-__kernel void AvePoolForward(const int nthreads, __global T* bottom_data, const int num, const int channels, const int height, const int width, const int pooled_height, const int pooled_width, const int kernel_h, const int kernel_w, const int stride_h, const int stride_w, const int pad_h, const int pad_w,__global T* top_data) {
- int index = get_global_id(0);
- int tmp = get_global_size(0);
- for(index; index < nthreads; index+=tmp) {
- int pw = index % pooled_width;
- int ph = (index / pooled_width) % pooled_height;
- int c = (index / pooled_width / pooled_height) % channels;
- int n = index / pooled_width / pooled_height / channels; int hstart = ph * stride_h - pad_h; int wstart = pw * stride_w - pad_w;
- int hend = min(hstart + kernel_h, height + pad_h);
- int wend = min(wstart + kernel_w, width + pad_w);
- const int pool_size = (hend - hstart) * (wend - wstart);
- hstart = max(hstart, 0);
- wstart = max(wstart, 0);
- hend = min(hend, height);
- wend = min(wend, width);
- T aveval = 0;
- bottom_data =
- bottom_data + (n * channels + c) * height * width;
- for (int h = hstart; h < hend; ++h) {
- for (int w = wstart; w < wend; ++w) {
- aveval += bottom_data[h * width + w];
- }
- }
- top_data[index] = aveval / pool_size;
- }
-
-}
diff --git a/contrib/modules/dnn/src/precomp.hpp b/contrib/modules/dnn/src/precomp.hpp
deleted file mode 100644
index 6932bc8..0000000
--- a/contrib/modules/dnn/src/precomp.hpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include <opencv2/core.hpp>
-#include "cvconfig.h"
-#include <opencv2/dnn.hpp>
diff --git a/contrib/modules/dnn/src/tensorflow/tf_importer.cpp b/contrib/modules/dnn/src/tensorflow/tf_importer.cpp
deleted file mode 100644
index 6caccef..0000000
--- a/contrib/modules/dnn/src/tensorflow/tf_importer.cpp
+++ /dev/null
@@ -1,749 +0,0 @@
-// This file is part of OpenCV project.
-// It is subject to the license terms in the LICENSE file found in the top-level directory
-// of this distribution and at http://opencv.org/license.html.
-
-// Copyright (C) 2016, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-
-/*
-Implementation of Tensorflow models parser
-*/
-
-#include "precomp.hpp"
-using namespace cv;
-using namespace cv::dnn;
-
-#if HAVE_PROTOBUF
-#include "graph.pb.h"
-
-#include <iostream>
-#include <fstream>
-#include <algorithm>
-#include <string>
-#include <google/protobuf/message.h>
-#include <google/protobuf/text_format.h>
-#include <google/protobuf/io/zero_copy_stream_impl.h>
-#include "tf_io.hpp"
-
-using ::google::protobuf::RepeatedField;
-using ::google::protobuf::RepeatedPtrField;
-using ::google::protobuf::Message;
-using ::google::protobuf::Descriptor;
-using ::google::protobuf::FieldDescriptor;
-using ::google::protobuf::Reflection;
-
-namespace
-{
-
-static int toNCHW[] = {0, 2, 3, 1};
-
-typedef std::vector<std::pair<String, int> > StrIntVector;
-
-struct Pin
-{
- Pin(const std::string &_name, int _blobIndex = 0) :
- name(_name), blobIndex(_blobIndex) {}
-
- Pin() :
- name(""), blobIndex(-1) {}
-
- std::string name;
- int blobIndex;
-};
-
-BlobShape blobShapeFromTensor(const tensorflow::TensorProto &tensor)
-{
- if (tensor.has_tensor_shape())
- {
- const tensorflow::TensorShapeProto &_shape = tensor.tensor_shape();
- BlobShape shape = BlobShape::all(_shape.dim_size());
-
- for (int i = 0; i < _shape.dim_size(); i++)
- shape[i] = (int)_shape.dim(i).size();
-
- return shape;
- }
- else
- {
- CV_Error(Error::StsError, "Unknown shape of input tensor");
- return BlobShape();
- }
-}
-
-template <typename T>
-void parseTensor(const tensorflow::TensorProto &tensor, Blob &dstBlob)
-{
- BlobShape shape = blobShapeFromTensor(tensor);
-
- if (shape.dims() == 4)
- {
- // REORDER blob NHWC to NCHW
- swap(shape[2], shape[3]); // NHCW
- swap(shape[1], shape[2]); // NCHW
- }
-
- dstBlob.create(shape, CV_32F);
-
- int size = tensor.tensor_content().size() / sizeof(T);
- CV_Assert(size == (int)dstBlob.matRefConst().total());
-
- float *dstData = dstBlob.matRef().ptr<float>();
- const T *data = reinterpret_cast<const T*>(tensor.tensor_content().c_str());
-
- if (shape.dims() == 4)
- {
- int num = shape[0], channels = shape[1], height = shape[2], width = shape[3];
- int total = num*channels*height*width;
- for(int i_n = 0; i_n < shape[0]; i_n++) {
- for(int i_c = 0; i_c < shape[1]; i_c++) {
- for(int i_h = 0; i_h < shape[2]; i_h++) {
- for(int i_w = 0; i_w < shape[3]; i_w++) {
- int dst_i = channels*height*width*i_n + height*width*i_c + width*i_h + i_w;
- int src_i = channels*height*width*i_n + i_c + channels*width*i_h + channels*i_w;
-
- CV_Assert(dst_i < total);
- CV_Assert(src_i < total);
-
- dstData[dst_i] = data[src_i];
- }
- }
- }
- }
- } else {
- for (int i = 0; i < size; i++)
- dstData[i] = data[i];
- }
-}
-
-void blobFromTensor(const tensorflow::TensorProto &tensor, Blob &dstBlob)
-{
- switch (tensor.dtype()) {
- case tensorflow::DT_FLOAT:
- parseTensor<float>(tensor, dstBlob);
- break;
- case tensorflow::DT_DOUBLE:
- parseTensor<double>(tensor, dstBlob);
- break;
- default:
- CV_Error(Error::StsError, "Tensor's data type is not supported");
- break;
- }
-}
-
-void printList(const tensorflow::AttrValue::ListValue &val)
-{
- std::cout << "(";
- for (int i = 0; i < val.i_size(); i++)
- std::cout << " " << val.i(i);
- std::cout << " )";
-}
-
-void printTensorShape(const tensorflow::TensorShapeProto &shape)
-{
- std::cout << "[ ";
- for (int d = 0; d < shape.dim_size(); d++)
- std::cout << shape.dim(d).name() <<
- ":" << shape.dim(d).size() << " ";
- std::cout << "]";
-}
-
-void printTensor(const tensorflow::TensorProto &tensor)
-{
- printTensorShape(tensor.tensor_shape());
-
- if (tensor.tensor_content().empty())
- return;
-
- switch (tensor.dtype())
- {
- case 1: // float
- {
- const float *data = reinterpret_cast<const float*>(tensor.tensor_content().c_str());
- int size = tensor.tensor_content().size() / sizeof(float);
- for (int i = 0; i < std::min(10, size); i++)
- std::cout << " " << data[i];
- if (size > 10)
- std::cout << " ... " << size - 10 << " more";
- break;
- }
- case 3: // int32
- {
- const int *data = reinterpret_cast<const int*>(tensor.tensor_content().c_str());
- int size = tensor.tensor_content().size() / sizeof(int);
- for (int i = 0; i < std::min(10, size); i++)
- std::cout << " " << data[i];
- if (size > 10)
- std::cout << " ... " << size - 10 << " more";
- break;
- }
- default:
- CV_Error(Error::StsError, "Tensor type is not supported");
- break;
- }
-}
-
-void printLayerAttr(const tensorflow::NodeDef &layer)
-{
- std::cout << std::endl << layer.name() << ":" << layer.op();
- for (int ii = 0; ii < layer.input_size(); ii++)
- std::cout << "(" << layer.input(ii) << ")";
- std::cout << std::endl;
- google::protobuf::Map<std::string, tensorflow::AttrValue> attr
- = layer.attr();
- for (google::protobuf::Map<std::string, tensorflow::AttrValue>::const_iterator ai = attr.begin();
- ai != attr.end(); ++ai)
- {
- std::cout << ai->first << ":";
- if (ai->first == "dtype" || ai->first == "T")
- std::cout << ai->second.i();
- else if (ai->first == "padding")
- std::cout << ai->second.s();
- else if (ai->first == "transpose_a" || ai->first == "transpose_b")
- std::cout << ai->second.b();
- // else if (ai->first == "shape")
- // printTensorShape(ai->second.shape());
- else if (ai->first == "strides" || ai->first == "ksize")
- printList(ai->second.list());
- else
- printTensor(ai->second.tensor());
- std::cout << std::endl;
- }
-}
-
-bool hasLayerAttr(const tensorflow::NodeDef &layer, const std::string &name)
-{
- google::protobuf::Map<std::string, tensorflow::AttrValue> attr = layer.attr();
- return attr.find(name) != attr.end();
-}
-
-const tensorflow::AttrValue& getLayerAttr(const tensorflow::NodeDef &layer, const std::string &name)
-{
- return layer.attr().at(name);
-}
-
-void setStrides(LayerParams &layerParams, const tensorflow::NodeDef &layer)
-{
- if (hasLayerAttr(layer, "strides"))
- {
- const tensorflow::AttrValue& val = getLayerAttr(layer, "strides");
- if (val.list().i_size() != 4 ||
- val.list().i(0) != 1 || val.list().i(3) != 1)
- CV_Error(Error::StsError, "Unsupported strides");
- layerParams.set("stride_h", static_cast<int>(val.list().i(1)));
- layerParams.set("stride_w", static_cast<int>(val.list().i(2)));
- }
-}
-
-DictValue parseDims(const tensorflow::TensorProto &tensor) {
- BlobShape shape = blobShapeFromTensor(tensor);
-
- CV_Assert(tensor.dtype() == tensorflow::DT_INT32);
- CV_Assert(shape.dims() == 1);
-
- int size = tensor.tensor_content().size() / sizeof(int);
- const int *data = reinterpret_cast<const int*>(tensor.tensor_content().c_str());
- // TODO: add reordering shape if dims == 4
- return DictValue::arrayInt(data, size);
-}
-
-void setKSize(LayerParams &layerParams, const tensorflow::NodeDef &layer)
-{
- if (hasLayerAttr(layer, "ksize"))
- {
- const tensorflow::AttrValue& val = getLayerAttr(layer, "ksize");
- if (val.list().i_size() != 4 ||
- val.list().i(0) != 1 || val.list().i(3) != 1)
- CV_Error(Error::StsError, "Unsupported ksize");
- layerParams.set("kernel_h", static_cast<int>(val.list().i(1)));
- layerParams.set("kernel_w", static_cast<int>(val.list().i(2)));
- }
- else
- {
- layerParams.set("kernel_h", 1);
- layerParams.set("kernel_w", 1);
- }
-}
-
-void setPadding(LayerParams &layerParams, const tensorflow::NodeDef &layer)
-{
- if (hasLayerAttr(layer, "padding"))
- layerParams.set("pad_mode", getLayerAttr(layer, "padding").s());
-}
-
-void RemoveIdentityOps(tensorflow::GraphDef& net) {
- typedef std::map<String, String> IdentityOpsMap;
- IdentityOpsMap identity_ops;
-
- std::vector<int> identity_ops_idx;
-
- int layersCount = net.node_size();
- for (int li = 0; li < layersCount; li++)
- {
- const tensorflow::NodeDef &layer = net.node(li);
- String type = layer.op();
-
- if (type == "Identity") {
- identity_ops_idx.push_back(li);
- identity_ops[layer.name()] = layer.input(0);
- }
- }
-
- for (int li = 0; li < layersCount; li++)
- {
- tensorflow::NodeDef* layer = net.mutable_node(li);
- for (int input_id = 0; input_id < layer->input_size(); input_id++) {
- String input_op_name = layer->input(input_id);
- IdentityOpsMap::iterator it = identity_ops.find(input_op_name);
-
- if (it != identity_ops.end()) {
- layer->set_input(input_id, it->second);
- }
- }
- }
-
- std::sort(identity_ops_idx.begin(), identity_ops_idx.end());
-
- int removed_nodes = 0;
- for(size_t i = 0; i < identity_ops_idx.size(); i++) {
- int start_id = identity_ops_idx[i] - removed_nodes;
- net.mutable_node()->DeleteSubrange(start_id, 1);
- removed_nodes++;
- }
-}
-
-Pin parsePin(const std::string &name)
-{
- Pin pin(name);
-
- size_t delimiter_pos = name.find_first_of(":");
- if (delimiter_pos != std::string::npos)
- {
- pin.name = name.substr(0, delimiter_pos);
- std::istringstream(name.substr(delimiter_pos + 1)) >> pin.blobIndex;
- }
-
- return pin;
-}
-
-StrIntVector getNextLayers(const tensorflow::GraphDef& net, const String& layer_name, const String& type = "")
-{
- StrIntVector layers;
-
- for (int li = 0; li < net.node_size(); li++)
- {
- const tensorflow::NodeDef& layer = net.node(li);
- for (int input_id = 0; input_id < layer.input_size(); input_id++) {
- String input_op_name = parsePin(layer.input(input_id)).name;
- bool type_ok = type.empty() ? true : type == layer.op();
- if (input_op_name == layer_name && type_ok)
- layers.push_back(std::make_pair(layer.name(), li));
- }
- }
-
- return layers;
-}
-
-void ExcludeLayer(tensorflow::GraphDef& net, const int layer_index, const int input_blob_index, bool remove_from_net = true) {
- String layer_name = net.node(layer_index).name();
- StrIntVector layers = getNextLayers(net, layer_name);
-
- String removed_layer_input = net.node(layer_index).input(input_blob_index);
-
- for (size_t i = 0; i < layers.size(); i++)
- {
- tensorflow::NodeDef* layer = net.mutable_node(layers[i].second);
- for (int input_id = 0; input_id < layer->input_size(); input_id++) {
- String input_op_name = layer->input(input_id);
-
- if (input_op_name == layer_name) {
- layer->set_input(input_id, removed_layer_input);
- }
- }
- }
-
- if (remove_from_net)
- net.mutable_node()->DeleteSubrange(layer_index, 1);
-}
-
-class TFImporter : public Importer {
-public:
- TFImporter(const char *model);
- void populateNet(Net dstNet);
- ~TFImporter() {}
-
-private:
- void kernelFromTensor(const tensorflow::TensorProto &tensor, Blob &dstBlob);
-
- void connect(const std::map<String, int>& layers_name_id_map, Net& network, const Pin& outPin,
- const int input_layer_id, const int input_blob_id);
- void connectToAllBlobs(const std::map<String, int>& layer_id, Net& network, const Pin& outPin,
- const int input_layer_id, const int input_blobs_count);
- const tensorflow::TensorProto& getConstBlob(const tensorflow::NodeDef &layer, std::map<String, int> const_layers,
- int input_blob_index = -1, int* actual_inp_blob_idx = 0);
-
-
- tensorflow::GraphDef net;
-};
-
-TFImporter::TFImporter(const char *model)
-{
- if (model && model[0])
- ReadTFNetParamsFromBinaryFileOrDie(model, &net);
-}
-
-void TFImporter::kernelFromTensor(const tensorflow::TensorProto &tensor, Blob &dstBlob)
-{
- BlobShape shape = blobShapeFromTensor(tensor);
-
- // TODO: other blob types
- CV_Assert(tensor.dtype() == tensorflow::DT_FLOAT);
- CV_Assert(shape.dims() == 4);
-
- // REORDER kernel HWIO to OIHW
- swap(shape[0], shape[2]); // IWHO
- swap(shape[1], shape[3]); // IOHW
- swap(shape[0], shape[1]); // OIHW
-
- dstBlob.create(shape, CV_32F);
-
- int size = tensor.tensor_content().size() / sizeof(float);
- CV_Assert(size == (int)dstBlob.matRefConst().total());
-
- float *dstData = dstBlob.matRef().ptr<float>();
- const float *data = reinterpret_cast<const float*>(tensor.tensor_content().c_str());
-
- int out_c = shape[0], input_c = shape[1], height = shape[2], width = shape[3];
- int total = out_c*input_c*height*width;
- for(int i_oc = 0; i_oc < out_c; i_oc++) {
- for(int i_ic = 0; i_ic < input_c; i_ic++) {
- for(int i_h = 0; i_h < height; i_h++) {
- for(int i_w = 0; i_w < width; i_w++) {
- int dst_i = input_c*height*width*i_oc + height*width*i_ic + width*i_h + i_w;
- int src_i = out_c*input_c*width*i_h + out_c*input_c*i_w + out_c*i_ic + i_oc;
- CV_Assert(dst_i < total);
- CV_Assert(src_i < total);
- dstData[dst_i] = data[src_i];
- }
- }
- }
- }
-}
-
-void TFImporter::connect(const std::map<String, int>& layers_name_id_map, Net& network, const Pin& outPin,
- const int input_layer_id, const int input_blob_id)
-{
- std::map<String, int>::const_iterator it = layers_name_id_map.find(outPin.name);
- if (it == layers_name_id_map.end())
- CV_Error(Error::StsError, "Input layer not found: " + outPin.name);
- network.connect(it->second, outPin.blobIndex, input_layer_id, input_blob_id);
-}
-
-void TFImporter::connectToAllBlobs(const std::map<String, int>& layer_id, Net& network, const Pin& outPin,
- const int input_layer_id, const int input_blobs_count)
-{
- for (int input_blob_id = 0; input_blob_id < input_blobs_count; input_blob_id++)
- connect(layer_id, network, outPin, input_layer_id, input_blob_id);
-}
-
-const tensorflow::TensorProto& TFImporter::getConstBlob(const tensorflow::NodeDef &layer, std::map<String, int> const_layers,
- int input_blob_index, int* actual_inp_blob_idx) {
- if (input_blob_index == -1) {
- for(int i = 0; i < layer.input_size(); i++) {
- Pin input = parsePin(layer.input(i));
- if (const_layers.find(input.name) != const_layers.end()) {
- if (input_blob_index != -1)
- CV_Error(Error::StsError, "More than one input is Const op");
-
- input_blob_index = i;
- }
- }
- }
-
- if (input_blob_index == -1)
- CV_Error(Error::StsError, "Const input blob for weights not found");
-
- Pin kernel_inp = parsePin(layer.input(input_blob_index));
- if (const_layers.find(kernel_inp.name) == const_layers.end())
- CV_Error(Error::StsError, "Const kernel input not found");
- if (kernel_inp.blobIndex != 0)
- CV_Error(Error::StsError, "Unsupported kernel input");
-
- if(actual_inp_blob_idx) {
- *actual_inp_blob_idx = input_blob_index;
- }
-
- return net.node(const_layers.at(kernel_inp.name)).attr().at("value").tensor();
-}
-
-
-void TFImporter::populateNet(Net dstNet)
-{
- RemoveIdentityOps(net);
-
- std::map<int, String> layers_to_ignore;
-
- int layersSize = net.node_size();
-
- // find all Const layers for params
- std::map<String, int> value_id;
- for (int li = 0; li < layersSize; li++)
- {
- const tensorflow::NodeDef &layer = net.node(li);
- String name = layer.name();
- String type = layer.op();
-
- if (type != "Const")
- continue; // only Const parameters are supported
-
- if (layer.attr().find("value") != layer.attr().end())
- {
- value_id.insert(std::make_pair(name, li));
- }
-
- layers_to_ignore[li] = name;
- }
-
- std::map<String, int> layer_id;
-
- for (int li = 0; li < layersSize; li++)
- {
- const tensorflow::NodeDef &layer = net.node(li);
- String name = layer.name();
- String type = layer.op();
- LayerParams layerParams;
-
- if(layers_to_ignore.find(li) != layers_to_ignore.end())
- continue;
-
- if (type == "Conv2D")
- {
- layerParams.set("bias_term", false);
- layerParams.blobs.resize(1);
-
- StrIntVector next_layers = getNextLayers(net, name, "BiasAdd");
- if (next_layers.size() == 1) {
- layerParams.set("bias_term", true);
- layerParams.blobs.resize(2);
-
- int weights_layer_index = next_layers[0].second;
-
- blobFromTensor(getConstBlob(net.node(weights_layer_index), value_id), layerParams.blobs[1]);
- ExcludeLayer(net, weights_layer_index, 0, false);
- layers_to_ignore[weights_layer_index] = next_layers[0].first;
- }
-
- kernelFromTensor(getConstBlob(layer, value_id), layerParams.blobs[0]);
- BlobShape kshape = layerParams.blobs[0].shape();
- layerParams.set("kernel_h", kshape[2]);
- layerParams.set("kernel_w", kshape[3]);
- layerParams.set("num_output", kshape[0]);
-
- setStrides(layerParams, layer);
- setPadding(layerParams, layer);
-
- int id = dstNet.addLayer(name, "Convolution", layerParams);
- layer_id[name] = id;
-
- // one input only
- connect(layer_id, dstNet, parsePin(layer.input(0)), id, 0);
- }
- else if (type == "BiasAdd" || type == "Add")
- {
- layerParams.blobs.resize(1);
- blobFromTensor(getConstBlob(layer, value_id), layerParams.blobs[0]);
-
- int id = dstNet.addLayer(name, "Shift", layerParams);
- layer_id[name] = id;
-
- // one input only
- connect(layer_id, dstNet, parsePin(layer.input(0)), id, 0);
- }
- else if (type == "Identity")
- {
- int id = dstNet.addLayer(name, "Identity", layerParams);
- layer_id[name] = id;
-
- connectToAllBlobs(layer_id, dstNet, parsePin(layer.input(0)), id, layer.input_size());
- }
- else if (type == "MatMul")
- {
- CV_Assert(layer.input_size() == 2);
-
- layerParams.set("axis", 0);
- layerParams.set("bias_term", false);
- layerParams.blobs.resize(1);
-
- StrIntVector next_layers = getNextLayers(net, name, "BiasAdd");
- if (next_layers.size() == 1) {
- layerParams.set("bias_term", true);
- layerParams.blobs.resize(2);
-
- int weights_layer_index = next_layers[0].second;
- blobFromTensor(getConstBlob(net.node(weights_layer_index), value_id), layerParams.blobs[1]);
- ExcludeLayer(net, weights_layer_index, 0, false);
- layers_to_ignore[weights_layer_index] = next_layers[0].first;
- }
-
- int kernel_blob_index = -1;
- blobFromTensor(getConstBlob(layer, value_id, -1, &kernel_blob_index), layerParams.blobs[0]);
-
- if (kernel_blob_index == 1) { // In this case output is computed by x*W formula - W should be transposed
- Mat data = layerParams.blobs[0].matRef().t();
- BlobShape shape(data.rows, data.cols);
- layerParams.blobs[0].fill(shape, layerParams.blobs[0].type(), data.data);
- }
-
- BlobShape kshape = layerParams.blobs[0].shape();
- layerParams.set("num_output", kshape[0]);
-
- int id = dstNet.addLayer(name, "InnerProduct", layerParams);
- layer_id[name] = id;
-
- // one input only
- int input_blob_index = kernel_blob_index == 0 ? 1 : 0;
- connect(layer_id, dstNet, parsePin(layer.input(input_blob_index)), id, 0);
- }
- else if (type == "Reshape")
- {
- layerParams.set("dim", parseDims(getConstBlob(layer, value_id, 1)));
- layerParams.set("reorder_dims", true);
-
- int id = dstNet.addLayer(name, "Reshape", layerParams);
- layer_id[name] = id;
-
- // one input only
- connect(layer_id, dstNet, parsePin(layer.input(0)), id, 0);
- }
- else if (type == "Const")
- {
- }
- else if (type == "Softmax")
- {
- layerParams.set("axis", -1);
- int id = dstNet.addLayer(name, "Softmax", layerParams);
- layer_id[name] = id;
-
- connectToAllBlobs(layer_id, dstNet, parsePin(layer.input(0)), id, layer.input_size());
- }
- else if (type == "LRN")
- {
- if(hasLayerAttr(layer, "alpha")) {
- layerParams.set("alpha", getLayerAttr(layer, "alpha").f());
- }
- if(hasLayerAttr(layer, "beta")) {
- layerParams.set("beta", getLayerAttr(layer, "beta").f());
- }
- if(hasLayerAttr(layer, "depth_radius")) {
- int radius = (int)getLayerAttr(layer, "depth_radius").i();
- layerParams.set("local_size", 2*radius + 1);
- }
- if(hasLayerAttr(layer, "bias")) {
- layerParams.set("bias", getLayerAttr(layer, "bias").f());
- }
- layerParams.set("norm_sz", false);
-
- int id = dstNet.addLayer(name, "LRN", layerParams);
- layer_id[name] = id;
-
- connectToAllBlobs(layer_id, dstNet, parsePin(layer.input(0)), id, layer.input_size());
- }
- else if (type == "Concat")
- {
- int axis = getConstBlob(layer, value_id, 0).int_val().Get(0);
- layerParams.set("axis", toNCHW[axis]);
-
- int id = dstNet.addLayer(name, "Concat", layerParams);
- layer_id[name] = id;
-
- // input(0) is concat_dim
- for (int ii = 1; ii < layer.input_size(); ii++)
- {
- Pin inp = parsePin(layer.input(ii));
- if (layer_id.find(inp.name) == layer_id.end())
- CV_Error(Error::StsError, "Input layer not found: " + inp.name);
- dstNet.connect(layer_id.at(inp.name), inp.blobIndex, id, ii - 1);
- }
- }
- else if (type == "Relu")
- {
- int id = dstNet.addLayer(name, "ReLU", layerParams);
- layer_id[name] = id;
-
- connectToAllBlobs(layer_id, dstNet, parsePin(layer.input(0)), id, layer.input_size());
- }
- else if (type == "MaxPool")
- {
- layerParams.set("pool", "max");
-
- setKSize(layerParams, layer);
- setStrides(layerParams, layer);
- setPadding(layerParams, layer);
-
- int id = dstNet.addLayer(name, "Pooling", layerParams);
- layer_id[name] = id;
-
- connectToAllBlobs(layer_id, dstNet, parsePin(layer.input(0)), id, layer.input_size());
- }
- else if (type == "AvgPool")
- {
- layerParams.set("pool", "ave");
-
- setKSize(layerParams, layer);
- setStrides(layerParams, layer);
- setPadding(layerParams, layer);
-
- int id = dstNet.addLayer(name, "Pooling", layerParams);
- layer_id[name] = id;
-
- connectToAllBlobs(layer_id, dstNet, parsePin(layer.input(0)), id, layer.input_size());
- }
- else if (type == "Placeholder")
- {
- std::vector<String> netInputs(1);
- netInputs[0] = name;
- layer_id[name] = 0;
- dstNet.setNetInputs(netInputs);
- }
- else if (type == "Split") {
- // TODO: determing axis index remapping by input dimensions order of input blob
- // TODO: slicing input may be Const op
- // TODO: slicing kernels for convolutions - in current implenmentation it is impossible
- // TODO: add parsing num of slices parameter
- CV_Assert(layer.input_size() == 2);
- // num_split
- // 1st blob is dims tensor
- layerParams.set("slice_point", DictValue::arrayReal((double*)0, 0));
-
- int axis = getConstBlob(layer, value_id, 0).int_val().Get(0);
- layerParams.set("axis", toNCHW[axis]);
-
- int id = dstNet.addLayer(name, "Slice", layerParams);
- layer_id[name] = id;
-
- // one input only
- connect(layer_id, dstNet, parsePin(layer.input(1)), id, 0);
- }
- else
- {
- printLayerAttr(layer);
- CV_Error_(Error::StsError, ("Unknown layer type %s in op %s", type.c_str(), name.c_str()));
- }
- }
-}
-
-} // namespace
-
-Ptr<Importer> cv::dnn::createTensorflowImporter(const String &model)
-{
- return Ptr<Importer>(new TFImporter(model.c_str()));
-}
-
-#else //HAVE_PROTOBUF
-
-Ptr<Importer> cv::dnn::createTensorflowImporter(const String&)
-{
- CV_Error(cv::Error::StsNotImplemented, "libprotobuf required to import data from TensorFlow models");
- return Ptr<Importer>();
-}
-
-#endif //HAVE_PROTOBUF
diff --git a/contrib/modules/dnn/src/tensorflow/tf_io.cpp b/contrib/modules/dnn/src/tensorflow/tf_io.cpp
deleted file mode 100644
index fafe3cf..0000000
--- a/contrib/modules/dnn/src/tensorflow/tf_io.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-// This file is part of OpenCV project.
-// It is subject to the license terms in the LICENSE file found in the top-level directory
-// of this distribution and at http://opencv.org/license.html.
-
-// Copyright (C) 2016, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-
-/*
-Implementation of various functions which are related to Tensorflow models reading.
-*/
-
-#if HAVE_PROTOBUF
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/zero_copy_stream_impl.h>
-#include <google/protobuf/text_format.h>
-
-#include <opencv2/core.hpp>
-
-#include <map>
-#include <string>
-#include <fstream>
-#include <vector>
-
-#include "graph.pb.h"
-#include "tf_io.hpp"
-#include "../caffe/glog_emulator.hpp"
-
-namespace cv {
-namespace dnn {
-
-using std::string;
-using std::map;
-using namespace tensorflow;
-using namespace ::google::protobuf;
-using namespace ::google::protobuf::io;
-
-const int kProtoReadBytesLimit = INT_MAX; // Max size of 2 GB minus 1 byte.
-
-// TODO: remove Caffe duplicate
-bool ReadProtoFromBinaryFileTF(const char* filename, Message* proto) {
- std::ifstream fs(filename, std::ifstream::in | std::ifstream::binary);
- CHECK(fs.is_open()) << "Can't open \"" << filename << "\"";
- ZeroCopyInputStream* raw_input = new IstreamInputStream(&fs);
- CodedInputStream* coded_input = new CodedInputStream(raw_input);
- coded_input->SetTotalBytesLimit(kProtoReadBytesLimit, 536870912);
-
- bool success = proto->ParseFromCodedStream(coded_input);
-
- delete coded_input;
- delete raw_input;
- fs.close();
- return success;
-}
-
-void ReadTFNetParamsFromBinaryFileOrDie(const char* param_file,
- tensorflow::GraphDef* param) {
- CHECK(ReadProtoFromBinaryFileTF(param_file, param))
- << "Failed to parse GraphDef file: " << param_file;
-}
-
-}
-}
-#endif
diff --git a/contrib/modules/dnn/src/tensorflow/tf_io.hpp b/contrib/modules/dnn/src/tensorflow/tf_io.hpp
deleted file mode 100644
index db9612f..0000000
--- a/contrib/modules/dnn/src/tensorflow/tf_io.hpp
+++ /dev/null
@@ -1,29 +0,0 @@
-// This file is part of OpenCV project.
-// It is subject to the license terms in the LICENSE file found in the top-level directory
-// of this distribution and at http://opencv.org/license.html.
-
-// Copyright (C) 2016, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-
-/*
-Declaration of various functions which are related to Tensorflow models reading.
-*/
-
-#ifndef __OPENCV_DNN_TF_IO_HPP__
-#define __OPENCV_DNN_TF_IO_HPP__
-#if HAVE_PROTOBUF
-
-#include "graph.pb.h"
-
-namespace cv {
-namespace dnn {
-
-// Read parameters from a file into a GraphDef proto message.
-void ReadTFNetParamsFromBinaryFileOrDie(const char* param_file,
- tensorflow::GraphDef* param);
-
-}
-}
-
-#endif
-#endif
diff --git a/contrib/modules/dnn/src/torch/THDiskFile.cpp b/contrib/modules/dnn/src/torch/THDiskFile.cpp
deleted file mode 100644
index 06f8b85..0000000
--- a/contrib/modules/dnn/src/torch/THDiskFile.cpp
+++ /dev/null
@@ -1,611 +0,0 @@
-#if defined(ENABLE_TORCH_IMPORTER) && ENABLE_TORCH_IMPORTER
-#include "THGeneral.h"
-#include "THDiskFile.h"
-#include "THFilePrivate.h"
-
-extern "C"
-{
-
-typedef struct THDiskFile__
-{
- THFile file;
-
- FILE *handle;
- char *name;
- int isNativeEncoding;
-
-} THDiskFile;
-
-static int THDiskFile_isOpened(THFile *self)
-{
- THDiskFile *dfself = (THDiskFile*)self;
- return (dfself->handle != NULL);
-}
-
-const char *THDiskFile_name(THFile *self)
-{
- THDiskFile *dfself = (THDiskFile*)self;
- return dfself->name;
-}
-
-/* workaround mac osx lion ***insane*** fread bug */
-#ifdef __APPLE__
-size_t fread__(void *ptr, size_t size, size_t nitems, FILE *stream)
-{
- size_t nread = 0;
- while(!feof(stream) && !ferror(stream) && (nread < nitems))
- nread += fread((char*)ptr+nread*size, size, THMin(2147483648/size, nitems-nread), stream);
- return nread;
-}
-#else
-#define fread__ fread
-#endif
-
-#define READ_WRITE_METHODS(TYPE, TYPEC, ASCII_READ_ELEM, ASCII_WRITE_ELEM) \
- static long THDiskFile_read##TYPEC(THFile *self, TYPE *data, long n) \
- { \
- THDiskFile *dfself = (THDiskFile*)(self); \
- long nread = 0L; \
- \
- THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file"); \
- THArgCheck(dfself->file.isReadable, 1, "attempt to read in a write-only file"); \
- \
- if(dfself->file.isBinary) \
- { \
- nread = fread__(data, sizeof(TYPE), n, dfself->handle); \
- if(!dfself->isNativeEncoding && (sizeof(TYPE) > 1) && (nread > 0)) \
- THDiskFile_reverseMemory(data, data, sizeof(TYPE), nread); \
- } \
- else \
- { \
- long i; \
- for(i = 0; i < n; i++) \
- { \
- ASCII_READ_ELEM; /* increment here result and break if wrong */ \
- } \
- if(dfself->file.isAutoSpacing && (n > 0)) \
- { \
- int c = fgetc(dfself->handle); \
- if( (c != '\n') && (c != EOF) ) \
- ungetc(c, dfself->handle); \
- } \
- } \
- \
- if(nread != n) \
- { \
- dfself->file.hasError = 1; /* shouldn't we put hasError to 0 all the time ? */ \
- if(!dfself->file.isQuiet) \
- THError("read error: read %d blocks instead of %d", nread, n); \
- } \
- \
- return nread; \
- } \
- \
- static long THDiskFile_write##TYPEC(THFile *self, TYPE *data, long n) \
- { \
- THDiskFile *dfself = (THDiskFile*)(self); \
- long nwrite = 0L; \
- \
- THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file"); \
- THArgCheck(dfself->file.isWritable, 1, "attempt to write in a read-only file"); \
- \
- if(dfself->file.isBinary) \
- { \
- if(dfself->isNativeEncoding) \
- { \
- nwrite = fwrite(data, sizeof(TYPE), n, dfself->handle); \
- } \
- else \
- { \
- if(sizeof(TYPE) > 1) \
- { \
- char *buffer = (char*)THAlloc(sizeof(TYPE)*n); \
- THDiskFile_reverseMemory(buffer, data, sizeof(TYPE), n); \
- nwrite = fwrite(buffer, sizeof(TYPE), n, dfself->handle); \
- THFree(buffer); \
- } \
- else \
- nwrite = fwrite(data, sizeof(TYPE), n, dfself->handle); \
- } \
- } \
- else \
- { \
- long i; \
- for(i = 0; i < n; i++) \
- { \
- ASCII_WRITE_ELEM; \
- if( dfself->file.isAutoSpacing && (i < n-1) ) \
- fprintf(dfself->handle, " "); \
- } \
- if(dfself->file.isAutoSpacing && (n > 0)) \
- fprintf(dfself->handle, "\n"); \
- } \
- \
- if(nwrite != n) \
- { \
- dfself->file.hasError = 1; \
- if(!dfself->file.isQuiet) \
- THError("write error: wrote %d blocks instead of %d", nwrite, n); \
- } \
- \
- return nwrite; \
-}
-
-static int THDiskFile_mode(const char *mode, int *isReadable, int *isWritable)
-{
- *isReadable = 0;
- *isWritable = 0;
- if(strlen(mode) == 1)
- {
- if(*mode == 'r')
- {
- *isReadable = 1;
- return 1;
- }
- else if(*mode == 'w')
- {
- *isWritable = 1;
- return 1;
- }
- }
- else if(strlen(mode) == 2)
- {
- if(mode[0] == 'r' && mode[1] == 'w')
- {
- *isReadable = 1;
- *isWritable = 1;
- return 1;
- }
- }
- return 0;
-}
-
-static void THDiskFile_synchronize(THFile *self)
-{
- THDiskFile *dfself = (THDiskFile*)(self);
- THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
- fflush(dfself->handle);
-}
-
-static void THDiskFile_seek(THFile *self, long position)
-{
- THDiskFile *dfself = (THDiskFile*)(self);
-
- THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
- THArgCheck(position >= 0, 2, "position must be positive");
-
- if(fseek(dfself->handle, position, SEEK_SET) < 0)
- {
- dfself->file.hasError = 1;
- if(!dfself->file.isQuiet)
- THError("unable to seek at position %d", position);
- }
-}
-
-static void THDiskFile_seekEnd(THFile *self)
-{
- THDiskFile *dfself = (THDiskFile*)(self);
-
- THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
-
- if(fseek(dfself->handle, 0L, SEEK_END) < 0)
- {
- dfself->file.hasError = 1;
- if(!dfself->file.isQuiet)
- THError("unable to seek at end of file");
- }
-}
-
-static long THDiskFile_position(THFile *self)
-{
- THDiskFile *dfself = (THDiskFile*)(self);
- THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
- return ftell(dfself->handle);
-}
-
-static void THDiskFile_close(THFile *self)
-{
- THDiskFile *dfself = (THDiskFile*)(self);
- THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
- fclose(dfself->handle);
- dfself->handle = NULL;
-}
-
-/* Little and Big Endian */
-
-static void THDiskFile_reverseMemory(void *dst, const void *src, long blockSize, long numBlocks)
-{
- if(blockSize != 1)
- {
- long halfBlockSize = blockSize/2;
- char *charSrc = (char*)src;
- char *charDst = (char*)dst;
- long b, i;
- for(b = 0; b < numBlocks; b++)
- {
- for(i = 0; i < halfBlockSize; i++)
- {
- char z = charSrc[i];
- charDst[i] = charSrc[blockSize-1-i];
- charDst[blockSize-1-i] = z;
- }
- charSrc += blockSize;
- charDst += blockSize;
- }
- }
-}
-
-int THDiskFile_isLittleEndianCPU(void)
-{
- int x = 7;
- char *ptr = (char *)&x;
-
- if(ptr[0] == 0)
- return 0;
- else
- return 1;
-}
-
-int THDiskFile_isBigEndianCPU(void)
-{
- return(!THDiskFile_isLittleEndianCPU());
-}
-
-void THDiskFile_nativeEndianEncoding(THFile *self)
-{
- THDiskFile *dfself = (THDiskFile*)(self);
- THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
- dfself->isNativeEncoding = 1;
-}
-
-void THDiskFile_littleEndianEncoding(THFile *self)
-{
- THDiskFile *dfself = (THDiskFile*)(self);
- THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
- dfself->isNativeEncoding = THDiskFile_isLittleEndianCPU();
-}
-
-void THDiskFile_bigEndianEncoding(THFile *self)
-{
- THDiskFile *dfself = (THDiskFile*)(self);
- THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
- dfself->isNativeEncoding = !THDiskFile_isLittleEndianCPU();
-}
-
-/* End of Little and Big Endian Stuff */
-
-static void THDiskFile_free(THFile *self)
-{
- THDiskFile *dfself = (THDiskFile*)(self);
- if(dfself->handle)
- fclose(dfself->handle);
- THFree(dfself->name);
- THFree(dfself);
-}
-
-/* READ_WRITE_METHODS(int, Bool, */
-/* int value = 0; int ret = fscanf(file->handle, "%d", &value); array[i] = (value ? 1 : 0); if(ret <= 0) break; else result++, */
-/* int value = (array[i] ? 1 : 0); nElemWritten = fprintf(file->handle, "%d", value), */
-/* true) */
-
-/* Note that we do a trick */
-READ_WRITE_METHODS(unsigned char, Byte,
- nread = fread(data, 1, n, dfself->handle); break,
- nwrite = fwrite(data, 1, n, dfself->handle); break)
-
-READ_WRITE_METHODS(char, Char,
- nread = fread(data, 1, n, dfself->handle); break,
- nwrite = fwrite(data, 1, n, dfself->handle); break)
-
-READ_WRITE_METHODS(short, Short,
- int ret = fscanf(dfself->handle, "%hd", &data[i]); if(ret <= 0) break; else nread++,
- int ret = fprintf(dfself->handle, "%hd", data[i]); if(ret <= 0) break; else nwrite++)
-
-READ_WRITE_METHODS(int, Int,
- int ret = fscanf(dfself->handle, "%d", &data[i]); if(ret <= 0) break; else nread++,
- int ret = fprintf(dfself->handle, "%d", data[i]); if(ret <= 0) break; else nwrite++)
-
-READ_WRITE_METHODS(long, Long,
- int ret = fscanf(dfself->handle, "%ld", &data[i]); if(ret <= 0) break; else nread++,
- int ret = fprintf(dfself->handle, "%ld", data[i]); if(ret <= 0) break; else nwrite++)
-
-READ_WRITE_METHODS(float, Float,
- int ret = fscanf(dfself->handle, "%g", &data[i]); if(ret <= 0) break; else nread++,
- int ret = fprintf(dfself->handle, "%.9g", data[i]); if(ret <= 0) break; else nwrite++)
-
-READ_WRITE_METHODS(double, Double,
- int ret = fscanf(dfself->handle, "%lg", &data[i]); if(ret <= 0) break; else nread++,
- int ret = fprintf(dfself->handle, "%.17g", data[i]); if(ret <= 0) break; else nwrite++)
-
-static long THDiskFile_readString(THFile *self, const char *format, char **str_)
-{
- THDiskFile *dfself = (THDiskFile*)(self);
- THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
- THArgCheck(dfself->file.isReadable, 1, "attempt to read in a write-only file");
- THArgCheck((strlen(format) >= 2 ? (format[0] == '*') && (format[1] == 'a' || format[1] == 'l') : 0), 2, "format must be '*a' or '*l'");
-
-/* note: the string won't survive long, as it is copied into lua */
-/* so 1024 is not that big... */
-#define TBRS_BSZ 1024L
-
- if(format[1] == 'a')
- {
- char *p = (char*)THAlloc(TBRS_BSZ);
- long total = TBRS_BSZ;
- long pos = 0L;
-
- for (;;)
- {
- if(total-pos == 0) /* we need more space! */
- {
- total += TBRS_BSZ;
- p = (char*)THRealloc(p, total);
- }
- pos += fread(p+pos, 1, total-pos, dfself->handle);
- if (pos < total) /* eof? */
- {
- if(pos == 0L)
- {
- THFree(p);
- dfself->file.hasError = 1;
- if(!dfself->file.isQuiet)
- THError("read error: read 0 blocks instead of 1");
-
- *str_ = NULL;
- return 0;
- }
- *str_ = p;
- return pos;
- }
- }
- }
- else
- {
- char *p = (char*)THAlloc(TBRS_BSZ);
- long total = TBRS_BSZ;
- long pos = 0L;
- long size;
-
- for (;;)
- {
- if(total-pos <= 1) /* we can only write '\0' in there! */
- {
- total += TBRS_BSZ;
- p = (char*)THRealloc(p, total);
- }
- if (fgets(p+pos, total-pos, dfself->handle) == NULL) /* eof? */
- {
- if(pos == 0L)
- {
- THFree(p);
- dfself->file.hasError = 1;
- if(!dfself->file.isQuiet)
- THError("read error: read 0 blocks instead of 1");
-
- *str_ = NULL;
- return 0;
- }
- *str_ = p;
- return pos;
- }
- size = strlen(p+pos);
- if (size == 0L || (p+pos)[size-1] != '\n')
- {
- pos += size;
- }
- else
- {
- pos += size-1L; /* do not include `eol' */
- *str_ = p;
- return pos;
- }
- }
- }
-
- *str_ = NULL;
- return 0;
-}
-
-
-static long THDiskFile_writeString(THFile *self, const char *str, long size)
-{
- THDiskFile *dfself = (THDiskFile*)(self);
- long nwrite;
-
- THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
- THArgCheck(dfself->file.isWritable, 1, "attempt to write in a read-only file");
-
- nwrite = fwrite(str, 1, size, dfself->handle);
- if(nwrite != size)
- {
- dfself->file.hasError = 1;
- if(!dfself->file.isQuiet)
- THError("write error: wrote %ld blocks instead of %ld", nwrite, size);
- }
-
- return nwrite;
-}
-
-THFile *THDiskFile_new(const char *name, const char *mode, int isQuiet)
-{
- static struct THFileVTable vtable = {
- THDiskFile_isOpened,
-
- THDiskFile_readByte,
- THDiskFile_readChar,
- THDiskFile_readShort,
- THDiskFile_readInt,
- THDiskFile_readLong,
- THDiskFile_readFloat,
- THDiskFile_readDouble,
- THDiskFile_readString,
-
- THDiskFile_writeByte,
- THDiskFile_writeChar,
- THDiskFile_writeShort,
- THDiskFile_writeInt,
- THDiskFile_writeLong,
- THDiskFile_writeFloat,
- THDiskFile_writeDouble,
- THDiskFile_writeString,
-
- THDiskFile_synchronize,
- THDiskFile_seek,
- THDiskFile_seekEnd,
- THDiskFile_position,
- THDiskFile_close,
- THDiskFile_free
- };
-
- int isReadable;
- int isWritable;
- FILE *handle;
- THDiskFile *self;
-
- THArgCheck(THDiskFile_mode(mode, &isReadable, &isWritable), 2, "file mode should be 'r','w' or 'rw'");
-
- if( isReadable && isWritable )
- {
- handle = fopen(name, "r+b");
- if(!handle)
- {
- handle = fopen(name, "wb");
- if(handle)
- {
- fclose(handle);
- handle = fopen(name, "r+b");
- }
- }
- }
- else
- handle = fopen(name, (isReadable ? "rb" : "wb"));
-
- if(!handle)
- {
- if(isQuiet)
- return 0;
- else
- THError("cannot open <%s> in mode %c%c", name, (isReadable ? 'r' : ' '), (isWritable ? 'w' : ' '));
- }
-
- self = (THDiskFile*)THAlloc(sizeof(THDiskFile));
-
- self->handle = handle;
- self->name = (char*)THAlloc(strlen(name)+1);
- strcpy(self->name, name);
- self->isNativeEncoding = 1;
-
- self->file.vtable = &vtable;
- self->file.isQuiet = isQuiet;
- self->file.isReadable = isReadable;
- self->file.isWritable = isWritable;
- self->file.isBinary = 0;
- self->file.isAutoSpacing = 1;
- self->file.hasError = 0;
-
- return (THFile*)self;
-}
-
-/* PipeFile */
-
-static int THPipeFile_mode(const char *mode, int *isReadable, int *isWritable)
-{
- *isReadable = 0;
- *isWritable = 0;
- if(strlen(mode) == 1)
- {
- if(*mode == 'r')
- {
- *isReadable = 1;
- return 1;
- }
- else if(*mode == 'w')
- {
- *isWritable = 1;
- return 1;
- }
- }
- return 0;
-}
-
-static void THPipeFile_free(THFile *self)
-{
- THDiskFile *dfself = (THDiskFile*)(self);
- if(dfself->handle)
- pclose(dfself->handle);
- THFree(dfself->name);
- THFree(dfself);
-}
-
-THFile *THPipeFile_new(const char *name, const char *mode, int isQuiet)
-{
- static struct THFileVTable vtable = {
- THDiskFile_isOpened,
-
- THDiskFile_readByte,
- THDiskFile_readChar,
- THDiskFile_readShort,
- THDiskFile_readInt,
- THDiskFile_readLong,
- THDiskFile_readFloat,
- THDiskFile_readDouble,
- THDiskFile_readString,
-
- THDiskFile_writeByte,
- THDiskFile_writeChar,
- THDiskFile_writeShort,
- THDiskFile_writeInt,
- THDiskFile_writeLong,
- THDiskFile_writeFloat,
- THDiskFile_writeDouble,
- THDiskFile_writeString,
-
- THDiskFile_synchronize,
- THDiskFile_seek,
- THDiskFile_seekEnd,
- THDiskFile_position,
- THDiskFile_close,
- THPipeFile_free
- };
-
- int isReadable;
- int isWritable;
- FILE *handle;
- THDiskFile *self;
-
- THArgCheck(THPipeFile_mode(mode, &isReadable, &isWritable), 2, "file mode should be 'r','w'");
-
-#ifdef _WIN32
- handle = popen(name, (isReadable ? "rb" : "wb"));
-#else
- handle = popen(name, (isReadable ? "r" : "w"));
-#endif
-
- if(!handle)
- {
- if(isQuiet)
- return 0;
- else
- THError("cannot open <%s> in mode %c%c", name, (isReadable ? 'r' : ' '), (isWritable ? 'w' : ' '));
- }
-
- self = (THDiskFile*)THAlloc(sizeof(THDiskFile));
-
- self->handle = handle;
- self->name = (char*)THAlloc(strlen(name)+1);
- strcpy(self->name, name);
- self->isNativeEncoding = 1;
-
- self->file.vtable = &vtable;
- self->file.isQuiet = isQuiet;
- self->file.isReadable = isReadable;
- self->file.isWritable = isWritable;
- self->file.isBinary = 0;
- self->file.isAutoSpacing = 1;
- self->file.hasError = 0;
-
- return (THFile*)self;
-}
-
-}
-#endif
diff --git a/contrib/modules/dnn/src/torch/THDiskFile.h b/contrib/modules/dnn/src/torch/THDiskFile.h
deleted file mode 100644
index f7c93c2..0000000
--- a/contrib/modules/dnn/src/torch/THDiskFile.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef TH_DISK_FILE_INC
-#define TH_DISK_FILE_INC
-
-#include "THFile.h"
-
-TH_API THFile *THDiskFile_new(const char *name, const char *mode, int isQuiet);
-TH_API THFile *THPipeFile_new(const char *name, const char *mode, int isQuiet);
-
-TH_API const char *THDiskFile_name(THFile *self);
-
-TH_API int THDiskFile_isLittleEndianCPU(void);
-TH_API int THDiskFile_isBigEndianCPU(void);
-TH_API void THDiskFile_nativeEndianEncoding(THFile *self);
-TH_API void THDiskFile_littleEndianEncoding(THFile *self);
-TH_API void THDiskFile_bigEndianEncoding(THFile *self);
-
-#endif
diff --git a/contrib/modules/dnn/src/torch/THFile.cpp b/contrib/modules/dnn/src/torch/THFile.cpp
deleted file mode 100644
index 148f179..0000000
--- a/contrib/modules/dnn/src/torch/THFile.cpp
+++ /dev/null
@@ -1,163 +0,0 @@
-#if defined(ENABLE_TORCH_IMPORTER) && ENABLE_TORCH_IMPORTER
-#include "THFile.h"
-#include "THFilePrivate.h"
-
-extern "C"
-{
-
-#define IMPLEMENT_THFILE_RW(TYPEC, TYPE) \
- long THFile_read##TYPEC##Raw(THFile *self, TYPE *data, long n) \
- { \
- return (*self->vtable->read##TYPEC)(self, data, n); \
- } \
- \
- long THFile_write##TYPEC##Raw(THFile *self, TYPE *data, long n) \
- { \
- return (*self->vtable->write##TYPEC)(self, data, n); \
- }
-
-IMPLEMENT_THFILE_RW(Byte, unsigned char)
-IMPLEMENT_THFILE_RW(Char, char)
-IMPLEMENT_THFILE_RW(Short, short)
-IMPLEMENT_THFILE_RW(Int, int)
-IMPLEMENT_THFILE_RW(Long, long)
-IMPLEMENT_THFILE_RW(Float, float)
-IMPLEMENT_THFILE_RW(Double, double)
-
-long THFile_readStringRaw(THFile *self, const char *format, char **str_)
-{
- return self->vtable->readString(self, format, str_);
-}
-
-long THFile_writeStringRaw(THFile *self, const char *str, long size)
-{
- return self->vtable->writeString(self, str, size);
-}
-
-void THFile_synchronize(THFile *self)
-{
- self->vtable->synchronize(self);
-}
-
-void THFile_seek(THFile *self, long position)
-{
- self->vtable->seek(self, position);
-}
-
-void THFile_seekEnd(THFile *self)
-{
- self->vtable->seekEnd(self);
-}
-
-long THFile_position(THFile *self)
-{
- return self->vtable->position(self);
-}
-
-void THFile_close(THFile *self)
-{
- self->vtable->close(self);
-}
-
-void THFile_free(THFile *self)
-{
- self->vtable->free(self);
-}
-
-int THFile_isOpened(THFile *self)
-{
- return self->vtable->isOpened(self);
-}
-
-#define IMPLEMENT_THFILE_FLAGS(FLAG) \
- int THFile_##FLAG(THFile *self) \
- { \
- return self->FLAG; \
- }
-
-IMPLEMENT_THFILE_FLAGS(isQuiet)
-IMPLEMENT_THFILE_FLAGS(isReadable)
-IMPLEMENT_THFILE_FLAGS(isWritable)
-IMPLEMENT_THFILE_FLAGS(isBinary)
-IMPLEMENT_THFILE_FLAGS(isAutoSpacing)
-IMPLEMENT_THFILE_FLAGS(hasError)
-
-void THFile_binary(THFile *self)
-{
- self->isBinary = 1;
-}
-
-void THFile_ascii(THFile *self)
-{
- self->isBinary = 0;
-}
-
-void THFile_autoSpacing(THFile *self)
-{
- self->isAutoSpacing = 1;
-}
-
-void THFile_noAutoSpacing(THFile *self)
-{
- self->isAutoSpacing = 0;
-}
-
-void THFile_quiet(THFile *self)
-{
- self->isQuiet = 1;
-}
-
-void THFile_pedantic(THFile *self)
-{
- self->isQuiet = 0;
-}
-
-void THFile_clearError(THFile *self)
-{
- self->hasError = 0;
-}
-
-#define IMPLEMENT_THFILE_SCALAR(TYPEC, TYPE) \
- TYPE THFile_read##TYPEC##Scalar(THFile *self) \
- { \
- TYPE scalar; \
- THFile_read##TYPEC##Raw(self, &scalar, 1); \
- return scalar; \
- } \
- \
- void THFile_write##TYPEC##Scalar(THFile *self, TYPE scalar) \
- { \
- THFile_write##TYPEC##Raw(self, &scalar, 1); \
- }
-
-IMPLEMENT_THFILE_SCALAR(Byte, unsigned char)
-IMPLEMENT_THFILE_SCALAR(Char, char)
-IMPLEMENT_THFILE_SCALAR(Short, short)
-IMPLEMENT_THFILE_SCALAR(Int, int)
-IMPLEMENT_THFILE_SCALAR(Long, long)
-IMPLEMENT_THFILE_SCALAR(Float, float)
-IMPLEMENT_THFILE_SCALAR(Double, double)
-
-/*
-#define IMPLEMENT_THFILE_STORAGE(TYPEC, TYPE) \
- long THFile_read##TYPEC(THFile *self, TH##TYPEC##Storage *storage) \
- { \
- return THFile_read##TYPEC##Raw(self, storage->data, storage->size); \
- } \
- \
- long THFile_write##TYPEC(THFile *self, TH##TYPEC##Storage *storage) \
- { \
- return THFile_write##TYPEC##Raw(self, storage->data, storage->size); \
- }
-
-IMPLEMENT_THFILE_STORAGE(Byte, unsigned char)
-IMPLEMENT_THFILE_STORAGE(Char, char)
-IMPLEMENT_THFILE_STORAGE(Short, short)
-IMPLEMENT_THFILE_STORAGE(Int, int)
-IMPLEMENT_THFILE_STORAGE(Long, long)
-IMPLEMENT_THFILE_STORAGE(Float, float)
-IMPLEMENT_THFILE_STORAGE(Double, double)
-*/
-
-}
-#endif
diff --git a/contrib/modules/dnn/src/torch/THFile.h b/contrib/modules/dnn/src/torch/THFile.h
deleted file mode 100644
index 3fac5cc..0000000
--- a/contrib/modules/dnn/src/torch/THFile.h
+++ /dev/null
@@ -1,87 +0,0 @@
-#ifndef TH_FILE_INC
-#define TH_FILE_INC
-
-//#include "THStorage.h"
-#include "THGeneral.h"
-
-typedef struct THFile__ THFile;
-
-TH_API int THFile_isOpened(THFile *self);
-TH_API int THFile_isQuiet(THFile *self);
-TH_API int THFile_isReadable(THFile *self);
-TH_API int THFile_isWritable(THFile *self);
-TH_API int THFile_isBinary(THFile *self);
-TH_API int THFile_isAutoSpacing(THFile *self);
-TH_API int THFile_hasError(THFile *self);
-
-TH_API void THFile_binary(THFile *self);
-TH_API void THFile_ascii(THFile *self);
-TH_API void THFile_autoSpacing(THFile *self);
-TH_API void THFile_noAutoSpacing(THFile *self);
-TH_API void THFile_quiet(THFile *self);
-TH_API void THFile_pedantic(THFile *self);
-TH_API void THFile_clearError(THFile *self);
-
-/* scalar */
-TH_API unsigned char THFile_readByteScalar(THFile *self);
-TH_API char THFile_readCharScalar(THFile *self);
-TH_API short THFile_readShortScalar(THFile *self);
-TH_API int THFile_readIntScalar(THFile *self);
-TH_API long THFile_readLongScalar(THFile *self);
-TH_API float THFile_readFloatScalar(THFile *self);
-TH_API double THFile_readDoubleScalar(THFile *self);
-
-TH_API void THFile_writeByteScalar(THFile *self, unsigned char scalar);
-TH_API void THFile_writeCharScalar(THFile *self, char scalar);
-TH_API void THFile_writeShortScalar(THFile *self, short scalar);
-TH_API void THFile_writeIntScalar(THFile *self, int scalar);
-TH_API void THFile_writeLongScalar(THFile *self, long scalar);
-TH_API void THFile_writeFloatScalar(THFile *self, float scalar);
-TH_API void THFile_writeDoubleScalar(THFile *self, double scalar);
-
-/* storage */
-/*
-TH_API long THFile_readByte(THFile *self, THByteStorage *storage);
-TH_API long THFile_readChar(THFile *self, THCharStorage *storage);
-TH_API long THFile_readShort(THFile *self, THShortStorage *storage);
-TH_API long THFile_readInt(THFile *self, THIntStorage *storage);
-TH_API long THFile_readLong(THFile *self, THLongStorage *storage);
-TH_API long THFile_readFloat(THFile *self, THFloatStorage *storage);
-TH_API long THFile_readDouble(THFile *self, THDoubleStorage *storage);
-
-TH_API long THFile_writeByte(THFile *self, THByteStorage *storage);
-TH_API long THFile_writeChar(THFile *self, THCharStorage *storage);
-TH_API long THFile_writeShort(THFile *self, THShortStorage *storage);
-TH_API long THFile_writeInt(THFile *self, THIntStorage *storage);
-TH_API long THFile_writeLong(THFile *self, THLongStorage *storage);
-TH_API long THFile_writeFloat(THFile *self, THFloatStorage *storage);
-TH_API long THFile_writeDouble(THFile *self, THDoubleStorage *storage);
-*/
-
-/* raw */
-TH_API long THFile_readByteRaw(THFile *self, unsigned char *data, long n);
-TH_API long THFile_readCharRaw(THFile *self, char *data, long n);
-TH_API long THFile_readShortRaw(THFile *self, short *data, long n);
-TH_API long THFile_readIntRaw(THFile *self, int *data, long n);
-TH_API long THFile_readLongRaw(THFile *self, long *data, long n);
-TH_API long THFile_readFloatRaw(THFile *self, float *data, long n);
-TH_API long THFile_readDoubleRaw(THFile *self, double *data, long n);
-TH_API long THFile_readStringRaw(THFile *self, const char *format, char **str_); /* you must deallocate str_ */
-
-TH_API long THFile_writeByteRaw(THFile *self, unsigned char *data, long n);
-TH_API long THFile_writeCharRaw(THFile *self, char *data, long n);
-TH_API long THFile_writeShortRaw(THFile *self, short *data, long n);
-TH_API long THFile_writeIntRaw(THFile *self, int *data, long n);
-TH_API long THFile_writeLongRaw(THFile *self, long *data, long n);
-TH_API long THFile_writeFloatRaw(THFile *self, float *data, long n);
-TH_API long THFile_writeDoubleRaw(THFile *self, double *data, long n);
-TH_API long THFile_writeStringRaw(THFile *self, const char *str, long size);
-
-TH_API void THFile_synchronize(THFile *self);
-TH_API void THFile_seek(THFile *self, long position);
-TH_API void THFile_seekEnd(THFile *self);
-TH_API long THFile_position(THFile *self);
-TH_API void THFile_close(THFile *self);
-TH_API void THFile_free(THFile *self);
-
-#endif
diff --git a/contrib/modules/dnn/src/torch/THFilePrivate.h b/contrib/modules/dnn/src/torch/THFilePrivate.h
deleted file mode 100644
index 9097fb9..0000000
--- a/contrib/modules/dnn/src/torch/THFilePrivate.h
+++ /dev/null
@@ -1,43 +0,0 @@
-struct THFile__
-{
- struct THFileVTable *vtable;
-
- int isQuiet;
- int isReadable;
- int isWritable;
- int isBinary;
- int isAutoSpacing;
- int hasError;
-};
-
-/* virtual table definition */
-
-struct THFileVTable
-{
- int (*isOpened)(THFile *self);
-
- long (*readByte)(THFile *self, unsigned char *data, long n);
- long (*readChar)(THFile *self, char *data, long n);
- long (*readShort)(THFile *self, short *data, long n);
- long (*readInt)(THFile *self, int *data, long n);
- long (*readLong)(THFile *self, long *data, long n);
- long (*readFloat)(THFile *self, float *data, long n);
- long (*readDouble)(THFile *self, double *data, long n);
- long (*readString)(THFile *self, const char *format, char **str_);
-
- long (*writeByte)(THFile *self, unsigned char *data, long n);
- long (*writeChar)(THFile *self, char *data, long n);
- long (*writeShort)(THFile *self, short *data, long n);
- long (*writeInt)(THFile *self, int *data, long n);
- long (*writeLong)(THFile *self, long *data, long n);
- long (*writeFloat)(THFile *self, float *data, long n);
- long (*writeDouble)(THFile *self, double *data, long n);
- long (*writeString)(THFile *self, const char *str, long size);
-
- void (*synchronize)(THFile *self);
- void (*seek)(THFile *self, long position);
- void (*seekEnd)(THFile *self);
- long (*position)(THFile *self);
- void (*close)(THFile *self);
- void (*free)(THFile *self);
-};
diff --git a/contrib/modules/dnn/src/torch/THGeneral.cpp b/contrib/modules/dnn/src/torch/THGeneral.cpp
deleted file mode 100644
index dc56e36..0000000
--- a/contrib/modules/dnn/src/torch/THGeneral.cpp
+++ /dev/null
@@ -1,255 +0,0 @@
-#if defined(ENABLE_TORCH_IMPORTER) && ENABLE_TORCH_IMPORTER
-#include "THGeneral.h"
-#include <opencv2/core.hpp>
-
-extern "C"
-{
-
-#ifndef TH_HAVE_THREAD
-#define __thread
-#endif
-
-#if defined(TH_DISABLE_HEAP_TRACKING)
-#elif (defined(__unix) || defined(_WIN32))
-#include <malloc.h>
-#elif defined(__APPLE__)
-#include <malloc/malloc.h>
-#endif
-
-/* Torch Error Handling */
-static void defaultTorchErrorHandlerFunction(const char *msg, void*)
-{
- CV_Error(cv::Error::StsError, cv::String("Torch Error: ") + msg);
-}
-
-static __thread void (*torchErrorHandlerFunction)(const char *msg, void *data) = defaultTorchErrorHandlerFunction;
-static __thread void *torchErrorHandlerData;
-
-void _THError(const char *file, const int line, const char *fmt, ...)
-{
- char msg[2048];
- va_list args;
-
- /* vasprintf not standard */
- /* vsnprintf: how to handle if does not exists? */
- va_start(args, fmt);
- int n = vsnprintf(msg, 2048, fmt, args);
- va_end(args);
-
- if(n < 2048) {
- snprintf(msg + n, 2048 - n, " at %s:%d", file, line);
- }
-
- (*torchErrorHandlerFunction)(msg, torchErrorHandlerData);
-}
-
-void _THAssertionFailed(const char *file, const int line, const char *exp, const char *fmt, ...) {
- char msg[1024];
- va_list args;
- va_start(args, fmt);
- vsnprintf(msg, 1024, fmt, args);
- va_end(args);
- _THError(file, line, "Assertion `%s' failed. %s", exp, msg);
-}
-
-void THSetErrorHandler( void (*torchErrorHandlerFunction_)(const char *msg, void *data), void *data )
-{
- if(torchErrorHandlerFunction_)
- torchErrorHandlerFunction = torchErrorHandlerFunction_;
- else
- torchErrorHandlerFunction = defaultTorchErrorHandlerFunction;
- torchErrorHandlerData = data;
-}
-
-/* Torch Arg Checking Handling */
-static void defaultTorchArgErrorHandlerFunction(int argNumber, const char *msg, void*)
-{
- if(msg)
- CV_Error(cv::Error::StsError, cv::format("Torch invalid argument %d: %s", argNumber, msg));
- else
- CV_Error(cv::Error::StsError, cv::format("Invalid argument %d", argNumber));
-}
-
-static __thread void (*torchArgErrorHandlerFunction)(int argNumber, const char *msg, void *data) = defaultTorchArgErrorHandlerFunction;
-static __thread void *torchArgErrorHandlerData;
-
-void _THArgCheck(const char *file, int line, int condition, int argNumber, const char *fmt, ...)
-{
- if(!condition) {
- char msg[2048];
- va_list args;
-
- /* vasprintf not standard */
- /* vsnprintf: how to handle if does not exists? */
- va_start(args, fmt);
- int n = vsnprintf(msg, 2048, fmt, args);
- va_end(args);
-
- if(n < 2048) {
- snprintf(msg + n, 2048 - n, " at %s:%d", file, line);
- }
-
- (*torchArgErrorHandlerFunction)(argNumber, msg, torchArgErrorHandlerData);
- }
-}
-
-void THSetArgErrorHandler( void (*torchArgErrorHandlerFunction_)(int argNumber, const char *msg, void *data), void *data )
-{
- if(torchArgErrorHandlerFunction_)
- torchArgErrorHandlerFunction = torchArgErrorHandlerFunction_;
- else
- torchArgErrorHandlerFunction = defaultTorchArgErrorHandlerFunction;
- torchArgErrorHandlerData = data;
-}
-
-static __thread void (*torchGCFunction)(void *data) = NULL;
-static __thread void *torchGCData;
-static __thread long torchHeapSize = 0;
-static __thread long torchHeapSizeSoftMax = 300000000; // 300MB, adjusted upward dynamically
-
-/* Optional hook for integrating with a garbage-collected frontend.
- *
- * If torch is running with a garbage-collected frontend (e.g. Lua),
- * the GC isn't aware of TH-allocated memory so may not know when it
- * needs to run. These hooks trigger the GC to run in two cases:
- *
- * (1) When a memory allocation (malloc, realloc, ...) fails
- * (2) When the total TH-allocated memory hits a dynamically-adjusted
- * soft maximum.
- */
-void THSetGCHandler( void (*torchGCFunction_)(void *data), void *data )
-{
- torchGCFunction = torchGCFunction_;
- torchGCData = data;
-}
-
-static long getAllocSize(void *ptr) {
-#if defined(TH_DISABLE_HEAP_TRACKING)
- return 0;
-#elif defined(__unix)
- return malloc_usable_size(ptr);
-#elif defined(__APPLE__)
- return malloc_size(ptr);
-#elif defined(_WIN32)
- return _msize(ptr);
-#else
- return 0;
-#endif
-}
-
-/* (1) if the torch-allocated heap size exceeds the soft max, run GC
- * (2) if post-GC heap size exceeds 80% of the soft max, increase the
- * soft max by 40%
- */
-static void maybeTriggerGC() {
- if(torchGCFunction && torchHeapSize > torchHeapSizeSoftMax) {
- torchGCFunction(torchGCData);
- if(torchHeapSize > torchHeapSizeSoftMax * 0.8) {
- torchHeapSizeSoftMax = torchHeapSizeSoftMax * 1.4;
- }
- }
-}
-
-// hooks into the TH heap tracking
-void THHeapUpdate(long size) {
- torchHeapSize += size;
- if (size > 0)
- maybeTriggerGC();
-}
-
-static void* THAllocInternal(long size)
-{
- void *ptr;
-
- if (size > 5120)
- {
-#if (defined(__unix) || defined(__APPLE__)) && (!defined(DISABLE_POSIX_MEMALIGN))
- if (posix_memalign(&ptr, 64, size) != 0)
- ptr = NULL;
-/*
-#elif defined(_WIN32)
- ptr = _aligned_malloc(size, 64);
-*/
-#else
- ptr = malloc(size);
-#endif
- }
- else
- {
- ptr = malloc(size);
- }
-
- THHeapUpdate(getAllocSize(ptr));
- return ptr;
-}
-
-void* THAlloc(long size)
-{
- void *ptr;
-
- if(size < 0)
- THError("$ Torch: invalid memory size -- maybe an overflow?");
-
- if(size == 0)
- return NULL;
-
- ptr = THAllocInternal(size);
-
- if(!ptr && torchGCFunction) {
- torchGCFunction(torchGCData);
- ptr = THAllocInternal(size);
- }
-
- if(!ptr)
- THError("$ Torch: not enough memory: you tried to allocate %dGB. Buy new RAM!", size/1073741824);
-
- return ptr;
-}
-
-void* THRealloc(void *ptr, long size)
-{
- if(!ptr)
- return(THAlloc(size));
-
- if(size == 0)
- {
- THFree(ptr);
- return NULL;
- }
-
- if(size < 0)
- THError("$ Torch: invalid memory size -- maybe an overflow?");
-
- THHeapUpdate(-getAllocSize(ptr));
- void *newptr = realloc(ptr, size);
-
- if(!newptr && torchGCFunction) {
- torchGCFunction(torchGCData);
- newptr = realloc(ptr, size);
- }
- THHeapUpdate(getAllocSize(newptr ? newptr : ptr));
-
- if(!newptr)
- THError("$ Torch: not enough memory: you tried to reallocate %dGB. Buy new RAM!", size/1073741824);
-
- return newptr;
-}
-
-void THFree(void *ptr)
-{
- THHeapUpdate(-getAllocSize(ptr));
- free(ptr);
-}
-
-double THLog1p(const double x)
-{
-#if (defined(_MSC_VER) || defined(__MINGW32__))
- volatile double y = 1 + x;
- return log(y) - ((y-1)-x)/y ; /* cancels errors with IEEE arithmetic */
-#else
- return log1p(x);
-#endif
-}
-
-}
-#endif
diff --git a/contrib/modules/dnn/src/torch/THGeneral.h b/contrib/modules/dnn/src/torch/THGeneral.h
deleted file mode 100644
index 8d33ede..0000000
--- a/contrib/modules/dnn/src/torch/THGeneral.h
+++ /dev/null
@@ -1,89 +0,0 @@
-#ifndef TH_GENERAL_INC
-#define TH_GENERAL_INC
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <math.h>
-#include <limits.h>
-#include <float.h>
-#include <time.h>
-#include <string.h>
-
-#ifdef __cplusplus
-# define TH_EXTERNC extern "C"
-#else
-# define TH_EXTERNC extern
-#endif
-
-#define TH_API TH_EXTERNC
-
-#define THInf DBL_MAX
-
-//#define TH_INLINE @TH_INLINE@
-
-#ifndef __cplusplus
-//#define inline @TH_INLINE@
-#endif
-
-#ifndef M_PI
-# define M_PI 3.14159265358979323846
-#endif
-
-TH_API double THLog1p(const double x);
-TH_API void _THError(const char *file, const int line, const char *fmt, ...);
-TH_API void _THAssertionFailed(const char *file, const int line, const char *exp, const char *fmt, ...);
-TH_API void THSetErrorHandler( void (*torchErrorHandlerFunction)(const char *msg, void *data), void *data );
-TH_API void _THArgCheck(const char *file, int line, int condition, int argNumber, const char *fmt, ...);
-TH_API void THSetArgErrorHandler( void (*torchArgErrorHandlerFunction)(int argNumber, const char *msg, void *data), void *data );
-TH_API void* THAlloc(long size);
-TH_API void* THRealloc(void *ptr, long size);
-TH_API void THFree(void *ptr);
-TH_API void THSetGCHandler( void (*torchGCHandlerFunction)(void *data), void *data );
-// this hook should only be called by custom allocator functions
-TH_API void THHeapUpdate(long size);
-
-#define THError(...) _THError(__FILE__, __LINE__, __VA_ARGS__)
-#define THArgCheck(...) _THArgCheck(__FILE__, __LINE__, __VA_ARGS__)
-#define THAssert(exp) \
-do { \
- if (!(exp)) { \
- _THAssertionFailed(__FILE__, __LINE__, #exp, ""); \
- } \
-} while(0)
-#define THAssertMsg(exp, ...) \
-do { \
- if (!(exp)) { \
- _THAssertionFailed(__FILE__, __LINE__, #exp, __VA_ARGS__); \
- } \
-} while(0)
-
-#define TH_CONCAT_STRING_2(x,y) TH_CONCAT_STRING_2_EXPAND(x,y)
-#define TH_CONCAT_STRING_2_EXPAND(x,y) #x #y
-
-#define TH_CONCAT_STRING_3(x,y,z) TH_CONCAT_STRING_3_EXPAND(x,y,z)
-#define TH_CONCAT_STRING_3_EXPAND(x,y,z) #x #y #z
-
-#define TH_CONCAT_STRING_4(x,y,z,w) TH_CONCAT_STRING_4_EXPAND(x,y,z,w)
-#define TH_CONCAT_STRING_4_EXPAND(x,y,z,w) #x #y #z #w
-
-#define TH_CONCAT_2(x,y) TH_CONCAT_2_EXPAND(x,y)
-#define TH_CONCAT_2_EXPAND(x,y) x ## y
-
-#define TH_CONCAT_3(x,y,z) TH_CONCAT_3_EXPAND(x,y,z)
-#define TH_CONCAT_3_EXPAND(x,y,z) x ## y ## z
-
-#define TH_CONCAT_4_EXPAND(x,y,z,w) x ## y ## z ## w
-#define TH_CONCAT_4(x,y,z,w) TH_CONCAT_4_EXPAND(x,y,z,w)
-
-#define THMin(X, Y) ((X) < (Y) ? (X) : (Y))
-#define THMax(X, Y) ((X) > (Y) ? (X) : (Y))
-
-#if (defined(_MSC_VER) || defined(__MINGW32__))
-# define log1p(x) THLog1p(x)
-#define snprintf _snprintf
-#define popen _popen
-#define pclose _pclose
-#endif
-
-#endif
diff --git a/contrib/modules/dnn/src/torch/torch_importer.cpp b/contrib/modules/dnn/src/torch/torch_importer.cpp
deleted file mode 100644
index f11028f..0000000
--- a/contrib/modules/dnn/src/torch/torch_importer.cpp
+++ /dev/null
@@ -1,726 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "../precomp.hpp"
-#include <limits>
-#include <set>
-#include <map>
-#include <algorithm>
-#include <iostream>
-
-namespace cv {
-namespace dnn {
-
-#if defined(ENABLE_TORCH_IMPORTER) && ENABLE_TORCH_IMPORTER
-#include "THDiskFile.h"
-
-#ifdef NDEBUG
-static bool dbgPrint = false;
-#else
-static bool dbgPrint = true;
-#endif
-
-enum LuaType
-{
- TYPE_NIL = 0,
- TYPE_NUMBER = 1,
- TYPE_STRING = 2,
- TYPE_TABLE = 3,
- TYPE_TORCH = 4,
- TYPE_BOOLEAN = 5,
- TYPE_FUNCTION = 6,
- TYPE_RECUR_FUNCTION = 8,
- LEGACY_TYPE_RECUR_FUNCTION = 7
-};
-
-template<typename T>
-static String toString(const T &v)
-{
- std::ostringstream ss;
- ss << v;
- return ss.str();
-}
-
-static inline bool startsWith(const String &str, const char *substr)
-{
- return str.find(substr) == 0;
-}
-
-static inline bool endsWith(const String &str, const char *substr)
-{
- return str.rfind(substr) == str.length() - strlen(substr);
-}
-
-struct TorchImporter : public ::cv::dnn::Importer
-{
- Net net;
-
- THFile *file;
- std::set<int> readedIndexes;
- std::map<int, Mat> storages;
- std::map<int, Blob> tensors;
-
- struct Module
- {
- String thName, apiType;
- dnn::LayerParams params;
- std::vector<Module*> modules;
-
- Module(const String &_thName, const String &_apiType = String())
- : thName(_thName), apiType(_apiType) {}
-
- ~Module()
- {
- for (size_t i = 0; i < modules.size(); i++)
- delete modules[i];
- }
- };
-
- Module *rootModule;
- Module *curModule;
- int moduleCounter;
-
- TorchImporter(String filename, bool isBinary)
- {
- rootModule = curModule = NULL;
- moduleCounter = 0;
-
- file = THDiskFile_new(filename.c_str(), "r", 0);
- CV_Assert(file && THFile_isOpened(file));
-
- if (isBinary)
- THFile_binary(file);
- else
- THFile_ascii(file);
- }
-
- /* Simple readers */
-
- inline int readInt()
- {
- return THFile_readIntScalar(file);
- }
-
- inline long readLong()
- {
- return THFile_readLongScalar(file);
- }
-
- inline bool readBool()
- {
- return readInt() != 0;
- }
-
- inline double readDouble()
- {
- return THFile_readDoubleScalar(file);
- }
-
- inline String readString()
- {
- int size = THFile_readIntScalar(file);
- String str(size, '\0');
- THFile_readCharRaw(file, const_cast<char*>(str.c_str()), size);
- return str;
- }
-
- inline String readTorchClassName()
- {
- String version = readString();
- return startsWith(version, "V ") ? readString() : version;
- }
-
- inline void readFunction()
- {
- readString();
- readObject();
- }
-
- void readTable(int index = -1)
- {
- index = (index < 0) ? readInt() : index;
-
- if (readedIndexes.count(index))
- return;
-
- readedIndexes.insert(index);
-
- int size = readInt();
- for (int i = 0; i < size; i++)
- {
- readObject(); //key
- readObject(); //value
- }
- }
-
- /* Special readers */
-
- static inline int parseTorchType(const String &str, const char *suffix, const char *prefix = "torch.")
- {
- if (startsWith(str, prefix) && endsWith(str, suffix))
- {
- String typeStr = str.substr(strlen(prefix), str.length() - strlen(prefix) - strlen(suffix));
-
- if (typeStr == "Double")
- return CV_64F;
- else if (typeStr == "Float")
- return CV_32F;
- else if (typeStr == "Byte")
- return CV_8U;
- else if (typeStr == "Char")
- return CV_8S;
- else if (typeStr == "Short")
- return CV_16S;
- else if (typeStr == "Int")
- return CV_32S;
- else if (typeStr == "Long") //Carefully! CV_64S type coded as CV_USRTYPE1
- return CV_USRTYPE1;
- else
- CV_Error(Error::StsNotImplemented, "Unknown type \"" + typeStr + "\" of torch class \"" + str + "\"");
- }
-
- return -1;
- }
-
- static int parseTensorType(const String &className)
- {
- return parseTorchType(className, "Tensor");
- }
-
- static int parseStorageType(const String &className)
- {
- return parseTorchType(className, "Storage");
- }
-
- void readTorchStorage(int index, int type = -1)
- {
- long size = readLong();
- Mat storageMat(1, size, (type != CV_USRTYPE1) ? type : CV_64F); //handle LongStorage as CV_64F Mat
-
- switch (type)
- {
- case CV_32F:
- THFile_readFloatRaw(file, (float*)storageMat.data, size);
- break;
- case CV_64F:
- THFile_readDoubleRaw(file, (double*)storageMat.data, size);
- break;
- case CV_8S:
- case CV_8U:
- THFile_readByteRaw(file, (uchar*)storageMat.data, size);
- break;
- case CV_16S:
- case CV_16U:
- THFile_readShortRaw(file, (short*)storageMat.data, size);
- break;
- case CV_32S:
- THFile_readIntRaw(file, (int*)storageMat.data, size);
- break;
- case CV_USRTYPE1:
- {
- double *buf = storageMat.ptr<double>();
- THFile_readLongRaw(file, (long*)buf, size);
-
- for (size_t i = (size_t)size; i-- > 0; )
- buf[i] = ((long*)buf)[i];
- }
- break;
- default:
- CV_Error(Error::StsInternal, "");
- break;
- }
-
- storages.insert(std::make_pair(index, storageMat));
- }
-
- void readTorchTable(Dict &scalarParams, std::map<String, Blob> &tensorParams)
- {
- int luaType = readInt();
- int index = readInt();
-
- CV_Assert(luaType == TYPE_TABLE && readedIndexes.count(index) == 0);
- readedIndexes.insert(index);
-
- long fpos;
- int numPairs = readInt();
-
- for (int i = 0; i < numPairs; i++)
- {
- fpos = THFile_position(file);
- int ktype = readInt();
-
- if (ktype != TYPE_STRING) //skip non-string fileds
- {
- THFile_seek(file, fpos);
- readObject(); //key
- readObject(); //value
- continue;
- }
-
- String key = readString();
- if (dbgPrint)
- std::cout << i << "th key: " << key << "\n";
-
- fpos = THFile_position(file);
- int vtype = readInt();
-
- if (vtype == TYPE_TORCH)
- {
- int index = readInt();
- readTorchObject(index);
-
- if (tensors.count(index)) //tensor was readed
- {
- tensorParams.insert(std::make_pair(key, tensors[index]));
- }
- else if (storages.count(index)) //storage was readed
- {
- Mat &matStorage = storages[index];
- Mat matCasted;
- matStorage.convertTo(matCasted, CV_64F);
-
- DictValue scalar = DictValue::arrayReal(matCasted.ptr<double>(), matCasted.total());
- scalarParams.set(key, scalar);
- }
- }
- else if (vtype == TYPE_NUMBER)
- {
- scalarParams.set(key, readDouble());
- }
- else if (vtype == TYPE_STRING)
- {
- scalarParams.set(key, readString());
- }
- else if (vtype == TYPE_BOOLEAN)
- {
- scalarParams.set(key, readBool());
- }
- else
- {
- THFile_seek(file, fpos);
- readObject();
- }
- }
-
- //Debug output
- if (dbgPrint)
- {
- std::cout << "scalarParams:\n";
- std::cout << scalarParams;
-
- std::cout << "#" << tensorParams.size() << " tensorParams:\n";
- std::map<String,Blob>::const_iterator it;
- for (it = tensorParams.begin(); it != tensorParams.end(); it++)
- std::cout << it->first << ": Tensor " << it->second.shape() << "\n";
- }
- }
-
- void readTorchTensor(int indexTensor, int typeTensor)
- {
- int ndims = readInt();
- AutoBuffer<long, 4> sizes(ndims);
- AutoBuffer<long, 4> steps(ndims);
- THFile_readLongRaw(file, sizes, ndims);
- THFile_readLongRaw(file, steps, ndims);
- long offset = readLong() - 1;
-
- //read Storage
- int typeidx = readInt();
- CV_Assert(typeidx == TYPE_TORCH || (typeidx == TYPE_NIL && ndims == 0));
-
- if (typeidx == TYPE_NIL)
- {
- tensors.insert(std::make_pair(indexTensor, Blob()));
- return;
- }
-
- int indexStorage = readInt();
- if (readedIndexes.count(indexStorage) == 0)
- {
- int typeStorage = parseStorageType(readTorchClassName());
- CV_Assert(typeStorage >= 0 && typeTensor == typeStorage);
- readTorchStorage(indexStorage, typeStorage);
- }
-
- //small check
- size_t requireElems = (size_t)offset + (size_t)steps[0] * (size_t)sizes[0];
- size_t storageElems = storages[indexStorage].total();
- if (requireElems > storageElems)
- CV_Error(Error::StsBadSize, "Storage has insufficent number of elemements for requested Tensor");
-
- //convert sizes
- AutoBuffer<int, 4> isizes(ndims);
- AutoBuffer<size_t, 4> ssteps(ndims);
- for (int i = ndims - 1; i >= 0; i--)
- {
- isizes[i] = (int)sizes[i];
- ssteps[i] = (size_t)steps[i] * CV_ELEM_SIZE(typeTensor);
- }
-
- //allocate Blob
- Mat srcMat(ndims, (int*)isizes, typeTensor , storages[indexStorage].ptr() + offset, (size_t*)ssteps);
- //int dstType = (typeTensor == CV_64F) ? CV_64F : CV_32F;
- int dstType = CV_32F;
-
- Blob blob;
- blob.create(BlobShape(ndims, isizes), dstType);
- srcMat.convertTo(blob.matRef(), dstType);
-
- tensors.insert(std::make_pair(indexTensor, blob));
- }
-
- static bool isNNClass(const String &className, String &nnName)
- {
- const char *prefixes[] = {"nn.", "cunn.", "cudnn.", "fbcunn.", NULL};
-
- for (int i = 0; prefixes[i]; i++)
- {
- if (startsWith(className, prefixes[i]))
- {
- nnName = className.substr(strlen(prefixes[i]));
- return true;
- }
- }
-
- return false;
- }
-
- static void convertTorchKernelsParams(const Dict &torchParams, cv::dnn::LayerParams &layerParams)
- {
- layerParams.set("kernel_h", torchParams.get<int>("kH"));
- layerParams.set("kernel_w", torchParams.get<int>("kW"));
- layerParams.set("stride_h", torchParams.get<int>("dH"));
- layerParams.set("stride_w", torchParams.get<int>("dW"));
- layerParams.set("pad_h", torchParams.get<int>("padH", 0));
- layerParams.set("pad_w", torchParams.get<int>("padW", 0));
- }
-
- void readTorchObject(int index)
- {
- if(readedIndexes.count(index))
- {
- if(!storages.count(index) && !tensors.count(index))
- CV_Error(Error::StsNotImplemented, "Objects which have multiple references are not supported");
- else
- return;
- }
-
- String className = readTorchClassName();
- String nnName;
-
- if (dbgPrint)
- std::cout << "Class: " << className << std::endl;
-
- int type;
- if ( (type = parseTensorType(className)) >= 0 ) //is Tensor
- {
- readTorchTensor(index, type);
- }
- else if ( (type = parseStorageType(className)) >= 0 ) //is Storage
- {
- readTorchStorage(index, type);
- }
- else if (isNNClass(className, nnName))
- {
- Dict scalarParams;
- std::map<String, Blob> tensorParams;
-
- Module *newModule = new Module(nnName);
- cv::dnn::LayerParams &layerParams = newModule->params;
-
- if (nnName == "Sequential" || nnName == "Parallel" || nnName == "Concat")
- {
- Module *parentModule = curModule;
- curModule->modules.push_back(newModule);
- curModule = newModule;
- readTorchTable(scalarParams, tensorParams);
- curModule = parentModule;
-
- if (nnName == "Parallel")
- {
- layerParams.set("inputDimension", scalarParams.get<int>("inputDimension"));
- layerParams.set("outputDimension", scalarParams.get<int>("outputDimension"));
- }
- if (nnName == "Concat")
- {
- layerParams.set("dimension", scalarParams.get<int>("dimension"));
- }
- }
- else if (nnName == "SpatialConvolution")
- {
- newModule->apiType = "Convolution";
- readTorchTable(scalarParams, tensorParams);
-
- CV_Assert(tensorParams.count("weight"));
- layerParams.blobs.push_back(tensorParams["weight"]);
-
- bool bias = tensorParams.count("bias") != 0;
- layerParams.set("bias_term", bias);
- if (bias)
- layerParams.blobs.push_back(tensorParams["bias"]);
-
- layerParams.set("num_output", scalarParams.get<int>("nOutputPlane"));
- convertTorchKernelsParams(scalarParams, layerParams);
-
- curModule->modules.push_back(newModule);
- }
- else if (nnName == "SpatialMaxPooling" || nnName == "SpatialAveragePooling")
- {
- newModule->apiType = "Pooling";
- readTorchTable(scalarParams, tensorParams);
-
- if (nnName == "SpatialMaxPooling")
- layerParams.set("pool", "MAX");
- if (nnName == "SpatialAveragePooling")
- layerParams.set("pool", "AVE");
- convertTorchKernelsParams(scalarParams, layerParams);
-
- curModule->modules.push_back(newModule);
- }
- else if (nnName == "Linear")
- {
- newModule->apiType = "InnerProduct";
- readTorchTable(scalarParams, tensorParams);
-
- CV_Assert(tensorParams.count("weight"));
- Blob weightBlob = tensorParams["weight"];
- layerParams.blobs.push_back(weightBlob);
-
- bool bias = tensorParams.count("bias") != 0;
- if (bias)
- layerParams.blobs.push_back(tensorParams["bias"]);
- layerParams.set("bias_term", bias);
-
- layerParams.set("num_output", weightBlob.size(0));
- curModule->modules.push_back(newModule);
- }
- else if (nnName == "Reshape")
- {
- newModule->apiType = "Reshape";
-
- readTorchTable(scalarParams, tensorParams);
- CV_Assert(scalarParams.has("size"));
-
- DictValue dimParam = scalarParams.get("size");
- layerParams.set("dim", dimParam);
-
- if (scalarParams.has("batchMode") && scalarParams.get<bool>("batchMode"))
- layerParams.set("axis", 1);
-
- curModule->modules.push_back(newModule);
- }
- else if (nnName == "ReLU")
- {
- curModule->modules.push_back(new Module(nnName, "ReLU"));
- readObject();
- }
- else if (nnName == "Tanh")
- {
- curModule->modules.push_back(new Module(nnName, "TanH"));
- readObject();
- }
- else if (nnName == "Sigmoid")
- {
- curModule->modules.push_back(new Module(nnName, "Sigmoid"));
- readObject();
- }
- else
- {
- delete newModule;
- CV_Error(Error::StsNotImplemented, "Unknown nn class \"" + className + "\"");
- readObject();
- }
- }
- else
- {
- CV_Error(Error::StsNotImplemented, "Unsupported Torch class \"" + className + "\"");
- }
-
- readedIndexes.insert(index);
- }
-
- void readObject()
- {
- int typeidx = readInt();
-
- if (typeidx == TYPE_TORCH)
- {
- int index = readInt();
- readTorchObject(index);
- readedIndexes.insert(index);
- }
- else if (typeidx == TYPE_NIL)
- return;
- else if (typeidx == TYPE_NUMBER)
- readDouble();
- else if (typeidx == TYPE_BOOLEAN)
- readBool();
- else if (typeidx == TYPE_STRING)
- readString();
- else if (typeidx == TYPE_TABLE)
- readTable();
- else
- CV_Error(Error::StsNotImplemented, "Unsupported Lua type");
- }
-
- inline String generateLayerName(const String &label = String())
- {
- return "l" + toString(++this->moduleCounter) + "_" + label;
- }
-
- int fill(Module *module, int prevLayerId = 0, int prevOutNum = 0)
- {
- if (module == NULL)
- return prevLayerId;
-
- if (module->apiType.length())
- {
- int newLayerId = this->net.addLayer(generateLayerName(module->apiType), module->apiType, module->params);
- net.connect(prevLayerId, prevOutNum, newLayerId, 0);
- return newLayerId;
- }
- else
- {
- if (module->thName == "Sequential")
- {
- for (size_t i = 0; i < module->modules.size(); i++)
- {
- prevLayerId = fill(module->modules[i], prevLayerId, prevOutNum);
- prevOutNum = 0;
- }
- return prevLayerId;
- }
- else if (module->thName == "Concat")
- {
- int newId, splitId, mergeId;
- LayerParams mergeParams, splitParams;
- mergeParams.set("axis", module->params.get<int>("dimension") - 1);
-
- splitId = net.addLayer(generateLayerName("torchSplit"), "Split", splitParams);
- mergeId = net.addLayer(generateLayerName("torchMerge"), "Concat", mergeParams);
- net.connect(prevLayerId, prevOutNum, splitId, 0);
-
- for (int i = 0; i < (int)module->modules.size(); i++)
- {
- newId = fill(module->modules[i], splitId, i);
- net.connect(newId, 0, mergeId, i);
- }
-
- return mergeId;
- }
- else if (module->thName == "Parallel")
- {
- int newId, splitId, mergeId, reshapeId;
-
- LayerParams splitParams, mergeParams, reshapeParams;
- splitParams.set("axis", module->params.get<int>("inputDimension") - 1);
- mergeParams.set("axis", module->params.get<int>("outputDimension") - 1);
- reshapeParams.set("axis", splitParams.get<int>("axis"));
- reshapeParams.set("num_axes", 1);
-
- splitId = net.addLayer(generateLayerName("torchSplit"), "Slice", splitParams);
- mergeId = net.addLayer(generateLayerName("torchMerge"), "Concat", mergeParams);
- reshapeId = net.addLayer(generateLayerName("torchReshape"), "Reshape", reshapeParams);
- net.connect(prevLayerId, prevOutNum, splitId, 0);
-
- for (int i = 0; i < (int)module->modules.size(); i++)
- {
- net.connect(splitId, i, reshapeId, i);
- newId = fill(module->modules[i], reshapeId, i);
- net.connect(newId, 0, mergeId, i);
- }
-
- return mergeId;
- }
- }
-
- CV_Error(Error::StsInternal, "Unexpected torch container: " + module->thName);
- return -1;
- }
-
- void populateNet(Net net)
- {
- if (rootModule == NULL)
- {
- rootModule = new Module("Sequential");
- curModule = rootModule;
-
- THFile_seek(file, 0);
- readObject();
- }
-
- this->net = net;
- fill(rootModule);
- }
-};
-
-Ptr<Importer> createTorchImporter(const String &filename, bool isBinary)
-{
- return Ptr<Importer>(new TorchImporter(filename, isBinary));
-}
-
-
-Blob readTorchBlob(const String &filename, bool isBinary)
-{
- Ptr<TorchImporter> importer(new TorchImporter(filename, isBinary));
- importer->readObject();
- CV_Assert(importer->tensors.size() == 1);
-
- return importer->tensors.begin()->second;
-}
-
-#else //ENABLE_TORCH_IMPORTER
-
-Ptr<Importer> createTorchImporter(const String&, bool)
-{
- CV_Error(Error::StsNotImplemented, "Module was build without Torch importer");
- return Ptr<Importer>();
-}
-
-Blob readTorchBlob(const String&, bool)
-{
- CV_Error(Error::StsNotImplemented, "Module was build without Torch importer");
- return Blob();
-}
-
-#endif //ENABLE_TORCH_IMPORTER
-}
-}
diff --git a/contrib/modules/dnn/test/npy_blob.hpp b/contrib/modules/dnn/test/npy_blob.hpp
deleted file mode 100644
index 7c99101..0000000
--- a/contrib/modules/dnn/test/npy_blob.hpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_DNN_TEST_NPY_BLOB_HPP__
-#define __OPENCV_DNN_TEST_NPY_BLOB_HPP__
-#include "test_precomp.hpp"
-#include "cnpy.h"
-
-inline cv::dnn::Blob blobFromNPY(const cv::String &path)
-{
- cnpy::NpyArray npyBlob = cnpy::npy_load(path.c_str());
- cv::dnn::BlobShape shape((int)npyBlob.shape.size(), (int*)&npyBlob.shape[0]);
-
- cv::dnn::Blob blob(shape);
- blob.fill(shape, CV_32F, npyBlob.data);
-
- npyBlob.destruct();
- return blob;
-}
-
-inline void saveBlobToNPY(cv::dnn::Blob &blob, const cv::String &path)
-{
- cv::dnn::BlobShape shape = blob.shape();
- cnpy::npy_save(path.c_str(), blob.ptrf(), (unsigned*)&shape[0], shape.dims());
-}
-
-#endif
diff --git a/contrib/modules/dnn/test/test_alexnet.cpp b/contrib/modules/dnn/test/test_alexnet.cpp
deleted file mode 100644
index b0abb17..0000000
--- a/contrib/modules/dnn/test/test_alexnet.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#if defined(ENABLE_CAFFE_MODEL_TESTS) && defined(ENABLE_CAFFE_ALEXNET_TEST) //AlexNet is disabled now
-#include "test_precomp.hpp"
-#include "npy_blob.hpp"
-
-namespace cvtest
-{
-
-using namespace cv;
-using namespace cv::dnn;
-
-template<typename TString>
-static std::string _tf(TString filename)
-{
- return (getOpenCVExtraDir() + "/dnn/") + filename;
-}
-
-TEST(Reproducibility_AlexNet, Accuracy)
-{
- Net net;
- {
- Ptr<Importer> importer = createCaffeImporter(_tf("bvlc_alexnet.prototxt"), _tf("bvlc_alexnet.caffemodel"));
- ASSERT_TRUE(importer != NULL);
- importer->populateNet(net);
- }
-
- std::vector<Mat> inpMats;
- inpMats.push_back( imread(_tf("alexnet_0.png")) );
- inpMats.push_back( imread(_tf("alexnet_1.png")) );
- ASSERT_TRUE(!inpMats[0].empty() && !inpMats[1].empty());
-
- net.setBlob(".data", Blob(inpMats));
- net.forward();
-
- Blob out = net.getBlob("prob");
- Blob ref = blobFromNPY(_tf("alexnet.npy"));
- normAssert(ref, out, "prob");
-}
-
-}
-#endif
diff --git a/contrib/modules/dnn/test/test_caffe_importer.cpp b/contrib/modules/dnn/test/test_caffe_importer.cpp
deleted file mode 100644
index 4983b8c..0000000
--- a/contrib/modules/dnn/test/test_caffe_importer.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-
-namespace cvtest
-{
-
-using namespace cv;
-using namespace cv::dnn;
-
-template<typename TString>
-static std::string _tf(TString filename)
-{
- return (getOpenCVExtraDir() + "/dnn/") + filename;
-}
-
-TEST(Test_Caffe, read_gtsrb)
-{
- Net net;
- {
- Ptr<Importer> importer = createCaffeImporter(_tf("gtsrb.prototxt"), "");
- ASSERT_TRUE(importer != NULL);
- importer->populateNet(net);
- }
-}
-
-TEST(Test_Caffe, read_googlenet)
-{
- Net net;
- {
- Ptr<Importer> importer = createCaffeImporter(_tf("bvlc_googlenet.prototxt"), "");
- ASSERT_TRUE(importer != NULL);
- importer->populateNet(net);
- }
-}
-
-}
diff --git a/contrib/modules/dnn/test/test_common.hpp b/contrib/modules/dnn/test/test_common.hpp
deleted file mode 100644
index b9a4ee1..0000000
--- a/contrib/modules/dnn/test/test_common.hpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_TEST_COMMON_HPP__
-#define __OPENCV_TEST_COMMON_HPP__
-
-inline const std::string &getOpenCVExtraDir()
-{
- return cvtest::TS::ptr()->get_data_path();
-}
-
-inline void normAssert(cv::InputArray ref, cv::InputArray test, const char *comment = "")
-{
- double normL1 = cvtest::norm(ref, test, cv::NORM_L1) / ref.getMat().total();
- EXPECT_LE(normL1, 0.0001) << comment;
-
- double normInf = cvtest::norm(ref, test, cv::NORM_INF);
- EXPECT_LE(normInf, 0.001) << comment;
-}
-
-inline void normAssert(cv::dnn::Blob &ref, cv::dnn::Blob &test, const char *comment = "")
-{
- ASSERT_EQ(ref.shape(), test.shape()) << comment;
- normAssert(ref.matRefConst(), test.matRefConst(), comment);
-}
-
-#endif
diff --git a/contrib/modules/dnn/test/test_googlenet.cpp b/contrib/modules/dnn/test/test_googlenet.cpp
deleted file mode 100644
index 6adf321..0000000
--- a/contrib/modules/dnn/test/test_googlenet.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#if defined(ENABLE_CAFFE_MODEL_TESTS)
-#include "test_precomp.hpp"
-#include "npy_blob.hpp"
-#include <opencv2/core/ocl.hpp>
-#include <opencv2/ts/ocl_test.hpp>
-
-namespace cvtest
-{
-
-using namespace cv;
-using namespace cv::dnn;
-
-template<typename TString>
-static std::string _tf(TString filename)
-{
- return (getOpenCVExtraDir() + "/dnn/") + filename;
-}
-
-static void launchGoogleNetTest()
-{
- Net net;
- {
- Ptr<Importer> importer = createCaffeImporter(_tf("bvlc_googlenet.prototxt"), _tf("bvlc_googlenet.caffemodel"));
- ASSERT_TRUE(importer != NULL);
- importer->populateNet(net);
- }
-
- std::vector<Mat> inpMats;
- inpMats.push_back( imread(_tf("googlenet_0.jpg")) );
- inpMats.push_back( imread(_tf("googlenet_1.jpg")) );
- ASSERT_TRUE(!inpMats[0].empty() && !inpMats[1].empty());
-
- net.setBlob(".data", Blob::fromImages(inpMats));
- net.forward();
-
- Blob out = net.getBlob("prob");
- Blob ref = blobFromNPY(_tf("googlenet_prob.npy"));
- normAssert(out, ref);
-}
-
-TEST(Reproducibility_GoogLeNet, Accuracy)
-{
- OCL_OFF(launchGoogleNetTest());
-}
-
-OCL_TEST(Reproducibility_GoogLeNet, Accuracy)
-{
- OCL_ON(launchGoogleNetTest());
- OCL_OFF();
-}
-
-}
-#endif
diff --git a/contrib/modules/dnn/test/test_layers.cpp b/contrib/modules/dnn/test/test_layers.cpp
deleted file mode 100644
index 6680de3..0000000
--- a/contrib/modules/dnn/test/test_layers.cpp
+++ /dev/null
@@ -1,396 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-#include <opencv2/core/ocl.hpp>
-#include <iostream>
-#include "npy_blob.hpp"
-#include <opencv2/dnn/all_layers.hpp>
-#include <opencv2/ts/ocl_test.hpp>
-
-namespace cvtest
-{
-
-using namespace cv;
-using namespace cv::dnn;
-
-template<typename TString>
-static String _tf(TString filename)
-{
- return (getOpenCVExtraDir() + "/dnn/layers/") + filename;
-}
-
-
-enum RunLayerMode
-{
- ALLOC_ONLY = 1,
- FORWARD_ONLY = 2,
- ALLOC_AND_FORWARD = ALLOC_ONLY | FORWARD_ONLY
-};
-
-typedef Ptr<std::vector<Blob*> > PtrToVecPtrBlob;
-
-PtrToVecPtrBlob
-runLayer(Ptr<Layer> layer, std::vector<Blob> &inpBlobs, std::vector<Blob> &outBlobs, int mode = ALLOC_AND_FORWARD)
-{
- PtrToVecPtrBlob inpPtrs(new std::vector<Blob*>());
- inpPtrs->reserve(inpBlobs.size());
- for (size_t i = 0; i < inpBlobs.size(); i++)
- inpPtrs->push_back(&inpBlobs[i]);
-
- if (mode & ALLOC_ONLY) layer->allocate(*inpPtrs, outBlobs);
- if (mode & FORWARD_ONLY) layer->forward(*inpPtrs, outBlobs);
-
- return inpPtrs;
-}
-
-
-void testLayerUsingCaffeModels(String basename, bool useCaffeModel = false, bool useCommonInputBlob = true)
-{
- String prototxt = _tf(basename + ".prototxt");
- String caffemodel = _tf(basename + ".caffemodel");
-
- String inpfile = (useCommonInputBlob) ? _tf("blob.npy") : _tf(basename + ".input.npy");
- String outfile = _tf(basename + ".npy");
-
- cv::setNumThreads(cv::getNumberOfCPUs());
-
- Net net;
- {
- Ptr<Importer> importer = createCaffeImporter(prototxt, (useCaffeModel) ? caffemodel : String());
- ASSERT_TRUE(importer != NULL);
- importer->populateNet(net);
- }
-
- Blob inp = blobFromNPY(inpfile);
- Blob ref = blobFromNPY(outfile);
-
- net.setBlob(".input", inp);
- net.forward();
- Blob out = net.getBlob("output");
-
- normAssert(ref, out);
-}
-
-TEST(Layer_Test_Softmax, Accuracy)
-{
- OCL_OFF(testLayerUsingCaffeModels("layer_softmax"));
-}
-OCL_TEST(Layer_Test_Softmax, Accuracy)
-{
- OCL_ON(testLayerUsingCaffeModels("layer_softmax"));
- OCL_OFF();
-}
-
-TEST(Layer_Test_LRN_spatial, Accuracy)
-{
- OCL_OFF(testLayerUsingCaffeModels("layer_lrn_spatial"));
-}
-OCL_TEST(Layer_Test_LRN_spatial, Accuracy)
-{
- OCL_ON(testLayerUsingCaffeModels("layer_lrn_spatial"));
- OCL_OFF();
-}
-
-TEST(Layer_Test_LRN_channels, Accuracy)
-{
- OCL_OFF(testLayerUsingCaffeModels("layer_lrn_channels"));
-}
-OCL_TEST(Layer_Test_LRN_channels, Accuracy)
-{
- OCL_ON(testLayerUsingCaffeModels("layer_lrn_channels"));
- OCL_OFF();
-}
-
-TEST(Layer_Test_Convolution, Accuracy)
-{
- OCL_OFF(testLayerUsingCaffeModels("layer_convolution", true));
-}
-OCL_TEST(Layer_Test_Convolution, Accuracy)
-{
- OCL_ON(testLayerUsingCaffeModels("layer_convolution", true));
- OCL_OFF();
-}
-
-TEST(Layer_Test_DeConvolution, Accuracy)
-{
- OCL_OFF(testLayerUsingCaffeModels("layer_deconvolution", true, false));
-}
-OCL_TEST(Layer_Test_DeConvolution, Accuracy)
-{
- OCL_ON(testLayerUsingCaffeModels("layer_deconvolution", true, false););
- OCL_OFF();
-}
-
-TEST(Layer_Test_InnerProduct, Accuracy)
-{
- OCL_OFF(testLayerUsingCaffeModels("layer_inner_product", true));
-}
-OCL_TEST(Layer_Test_InnerProduct, Accuracy)
-{
- OCL_ON(testLayerUsingCaffeModels("layer_inner_product", true));
- OCL_OFF();
-}
-
-TEST(Layer_Test_Pooling_max, Accuracy)
-{
- OCL_OFF(testLayerUsingCaffeModels("layer_pooling_max"));
- OCL_ON();
-}
-OCL_TEST(Layer_Test_Pooling_max, Accuracy)
-{
- OCL_ON(testLayerUsingCaffeModels("layer_pooling_max"));
- OCL_OFF();
-}
-
-TEST(Layer_Test_Pooling_ave, Accuracy)
-{
- OCL_OFF(testLayerUsingCaffeModels("layer_pooling_ave"));
- OCL_ON();
-}
-OCL_TEST(Layer_Test_Pooling_ave, Accuracy)
-{
- OCL_ON(testLayerUsingCaffeModels("layer_pooling_ave"));
- OCL_OFF();
-}
-
-TEST(Layer_Test_MVN, Accuracy)
-{
- OCL_OFF(testLayerUsingCaffeModels("layer_mvn"));
-}
-
-TEST(Layer_Test_Reshape, squeeze)
-{
- LayerParams params;
- params.set("axis", 2);
- params.set("num_axes", 1);
-
- Blob inp(BlobShape(4, 3, 1, 2));
- std::vector<Blob*> inpVec(1, &inp);
- std::vector<Blob> outVec;
-
- Ptr<Layer> rl = LayerFactory::createLayerInstance("Reshape", params);
- rl->allocate(inpVec, outVec);
- rl->forward(inpVec, outVec);
-
- EXPECT_EQ(outVec[0].shape(), BlobShape(4, 3, 2));
-}
-
-//template<typename XMat>
-//static void test_Layer_Concat()
-//{
-// Matx21f a(1.f, 1.f), b(2.f, 2.f), c(3.f, 3.f);
-// std::vector<Blob> res(1), src = { Blob(XMat(a)), Blob(XMat(b)), Blob(XMat(c)) };
-// Blob ref(XMat(Matx23f(1.f, 2.f, 3.f, 1.f, 2.f, 3.f)));
-//
-// runLayer(ConcatLayer::create(1), src, res);
-// normAssert(ref, res[0]);
-//}
-//TEST(Layer_Concat, Accuracy)
-//{
-// OCL_OFF(test_Layer_Concat<Mat>());
-//}
-//OCL_TEST(Layer_Concat, Accuracy)
-//{
-// OCL_ON(test_Layer_Concat<Mat>());
-// OCL_OFF();
-//}
-
-template<typename XMat>
-void test_Reshape_Split_Slice_layers()
-{
- Net net;
- {
- Ptr<Importer> importer = createCaffeImporter(_tf("reshape_and_slice_routines.prototxt"));
- ASSERT_TRUE(importer != NULL);
- importer->populateNet(net);
- }
-
- Blob input(BlobShape(6, 12));
- RNG rng(0);
- rng.fill(input.getRef<XMat>(), RNG::UNIFORM, -1, 1);
-
- net.setBlob(".input", input);
- net.forward();
- Blob output = net.getBlob("output");
-
- normAssert(input, output);
-}
-TEST(Layer_Test_Reshape_Split_Slice, Accuracy)
-{
- OCL_OFF(test_Reshape_Split_Slice_layers<Mat>());
-}
-OCL_TEST(Layer_Test_Reshape_Split_Slice, Accuracy)
-{
- OCL_ON(test_Reshape_Split_Slice_layers<UMat>());
- OCL_OFF();
-}
-
-class Layer_LSTM_Test : public ::testing::Test
-{
-public:
- int numInp, numOut;
- Blob Wh, Wx, b;
- Ptr<LSTMLayer> layer;
- std::vector<Blob> inputs, outputs;
-
- Layer_LSTM_Test() {}
-
- void init(const BlobShape &inpShape_, const BlobShape &outShape_)
- {
- numInp = inpShape_.total();
- numOut = outShape_.total();
-
- Wh = Blob(BlobShape(4 * numOut, numOut));
- Wx = Blob(BlobShape(4 * numOut, numInp));
- b = Blob(BlobShape(4 * numOut, 1));
-
- layer = LSTMLayer::create();
- layer->setWeights(Wh, Wx, b);
- layer->setOutShape(outShape_);
- }
-};
-
-TEST_F(Layer_LSTM_Test, get_set_test)
-{
- BlobShape TN(4);
- BlobShape inpShape(5, 3, 2), inpResShape = TN + inpShape;
- BlobShape outShape(3, 1, 2), outResShape = TN + outShape;
-
- init(inpShape, outShape);
- layer->setProduceCellOutput(true);
- layer->setUseTimstampsDim(false);
- layer->setOutShape(outShape);
-
- layer->setC(Blob(outResShape));
- layer->setH(Blob(outResShape));
-
- inputs.push_back(Blob(inpResShape));
- runLayer(layer, inputs, outputs);
-
- EXPECT_EQ(2u, outputs.size());
- EXPECT_EQ(outResShape, outputs[0].shape());
- EXPECT_EQ(outResShape, outputs[1].shape());
-
- EXPECT_EQ(outResShape, layer->getC().shape());
- EXPECT_EQ(outResShape, layer->getH().shape());
-
- EXPECT_EQ(0, layer->inputNameToIndex("x"));
- EXPECT_EQ(0, layer->outputNameToIndex("h"));
- EXPECT_EQ(1, layer->outputNameToIndex("c"));
-}
-
-TEST(Layer_LSTM_Test_Accuracy_with_, CaffeRecurrent)
-{
- Ptr<LSTMLayer> layer = LSTMLayer::create();
-
- Blob Wx = blobFromNPY(_tf("lstm.prototxt.w_0.npy"));
- Blob Wh = blobFromNPY(_tf("lstm.prototxt.w_2.npy"));
- Blob b = blobFromNPY(_tf("lstm.prototxt.w_1.npy"));
- layer->setWeights(Wh, Wx, b);
-
- Blob inp = blobFromNPY(_tf("recurrent.input.npy"));
- std::vector<Blob> inputs(1, inp), outputs;
- runLayer(layer, inputs, outputs);
-
- Blob h_t_reference = blobFromNPY(_tf("lstm.prototxt.h_1.npy"));
- normAssert(h_t_reference, outputs[0]);
-}
-
-TEST(Layer_RNN_Test_Accuracy_with_, CaffeRecurrent)
-{
- Ptr<RNNLayer> layer = RNNLayer::create();
-
- layer->setWeights(
- blobFromNPY(_tf("rnn.prototxt.w_0.npy")),
- blobFromNPY(_tf("rnn.prototxt.w_1.npy")),
- blobFromNPY(_tf("rnn.prototxt.w_2.npy")),
- blobFromNPY(_tf("rnn.prototxt.w_3.npy")),
- blobFromNPY(_tf("rnn.prototxt.w_4.npy")) );
-
- std::vector<Blob> output, input(1, blobFromNPY(_tf("recurrent.input.npy")));
- runLayer(layer, input, output);
-
- Blob h_ref = blobFromNPY(_tf("rnn.prototxt.h_1.npy"));
- normAssert(h_ref, output[0]);
-}
-
-
-class Layer_RNN_Test : public ::testing::Test
-{
-public:
- int nX, nH, nO, nT, nS;
- Blob Whh, Wxh, bh, Who, bo;
- Ptr<RNNLayer> layer;
-
- std::vector<Blob> inputs, outputs;
-
- Layer_RNN_Test()
- {
- nT = 3;
- nS = 5;
- nX = 31;
- nH = 64;
- nO = 100;
-
- Whh = Blob(BlobShape(nH, nH));
- Wxh = Blob(BlobShape(nH, nX));
- bh = Blob(BlobShape(nH, 1));
- Who = Blob(BlobShape(nO, nH));
- bo = Blob(BlobShape(nO, 1));
-
- layer = RNNLayer::create();
- layer->setProduceHiddenOutput(true);
- layer->setWeights(Wxh, bh, Whh, Who, bo);
- }
-};
-
-TEST_F(Layer_RNN_Test, get_set_test)
-{
- inputs.push_back(Blob(BlobShape(nT, nS, 1, nX)));
- runLayer(layer, inputs, outputs);
-
- EXPECT_EQ(outputs.size(), 2u);
- EXPECT_EQ(outputs[0].shape(), BlobShape(nT, nS, nO));
- EXPECT_EQ(outputs[1].shape(), BlobShape(nT, nS, nH));
-}
-
-}
diff --git a/contrib/modules/dnn/test/test_main.cpp b/contrib/modules/dnn/test/test_main.cpp
deleted file mode 100644
index 42917f2..0000000
--- a/contrib/modules/dnn/test/test_main.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "test_precomp.hpp"
-
-CV_TEST_MAIN("")
-
-namespace cvtest
-{
-
-using namespace cv;
-using namespace cv::dnn;
-
-TEST(BlobShape_SimpleConstr, Regression)
-{
- BlobShape sd;
-
- BlobShape s1(0);
- EXPECT_EQ(s1.dims(), 1);
- EXPECT_EQ(s1[0], 0);
-
- BlobShape s2(0, 0);
- EXPECT_EQ(s2.dims(), 2);
- EXPECT_EQ(s2[0], 0);
- EXPECT_EQ(s2[1], 0);
-}
-
-TEST(BlobShape_EmptyFill, Regression)
-{
- BlobShape s(10, (int*)NULL);
- EXPECT_EQ(s.dims(), 10);
-}
-
-}
diff --git a/contrib/modules/dnn/test/test_tf_importer.cpp b/contrib/modules/dnn/test/test_tf_importer.cpp
deleted file mode 100644
index 9f5d086..0000000
--- a/contrib/modules/dnn/test/test_tf_importer.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-// This file is part of OpenCV project.
-// It is subject to the license terms in the LICENSE file found in the top-level directory
-// of this distribution and at http://opencv.org/license.html.
-
-// Copyright (C) 2016, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-
-/*
-Test for Tensorflow models loading
-*/
-
-#include "test_precomp.hpp"
-
-namespace cvtest
-{
-
-using namespace cv;
-using namespace cv::dnn;
-
-template<typename TString>
-static std::string _tf(TString filename)
-{
- return (getOpenCVExtraDir() + "/dnn/") + filename;
-}
-
-TEST(Test_TensorFlow, read_inception)
-{
- Net net;
- {
- Ptr<Importer> importer = createTensorflowImporter(_tf("tensorflow_inception_graph.pb"));
- ASSERT_TRUE(importer != NULL);
- importer->populateNet(net);
- }
-
- Mat sample = imread(_tf("grace_hopper.jpg"));
- ASSERT_TRUE(!sample.empty());
- Mat input;
- resize(sample, input, Size(224, 224));
- input -= 128; // mean sub
-
- std::vector<Mat> inpMats;
- inpMats.push_back(input);
-
- net.setBlob("_input.input", Blob(inpMats));
- net.forward();
-
- Blob out = net.getBlob("output");
- std::cout << out.dims() << std::endl;
-}
-
-}
diff --git a/contrib/modules/dnn/test/test_torch_importer.cpp b/contrib/modules/dnn/test/test_torch_importer.cpp
deleted file mode 100644
index 0f45ab3..0000000
--- a/contrib/modules/dnn/test/test_torch_importer.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#if defined(ENABLE_TORCH_IMPORTER) && ENABLE_TORCH_IMPORTER
-#if defined(ENABLE_TORCH_TESTS) && ENABLE_TORCH_TESTS
-#include "test_precomp.hpp"
-
-namespace cvtest
-{
-
-using namespace std;
-using namespace testing;
-using namespace cv;
-using namespace cv::dnn;
-
-template<typename TStr>
-static std::string _tf(TStr filename)
-{
- return (getOpenCVExtraDir() + "/dnn/torch/") + filename;
-}
-
-TEST(Torch_Importer, simple_read)
-{
- Net net;
- Ptr<Importer> importer;
-
- ASSERT_NO_THROW( importer = createTorchImporter(_tf("net_simple_net.txt"), false) );
- ASSERT_TRUE( importer != NULL );
- importer->populateNet(net);
-}
-
-static void runTorchNet(String prefix, String outLayerName, bool isBinary)
-{
- String suffix = (isBinary) ? ".dat" : ".txt";
-
- Net net;
- Ptr<Importer> importer = createTorchImporter(_tf(prefix + "_net" + suffix), isBinary);
- ASSERT_TRUE(importer != NULL);
- importer->populateNet(net);
-
- Blob inp, outRef;
- ASSERT_NO_THROW( inp = readTorchBlob(_tf(prefix + "_input" + suffix), isBinary) );
- ASSERT_NO_THROW( outRef = readTorchBlob(_tf(prefix + "_output" + suffix), isBinary) );
-
- net.setBlob(".0", inp);
- net.forward();
- Blob out = net.getBlob(outLayerName);
-
- normAssert(outRef, out);
-}
-
-TEST(Torch_Importer, run_convolution)
-{
- runTorchNet("net_conv", "l1_Convolution", false);
-}
-
-TEST(Torch_Importer, run_pool_max)
-{
- runTorchNet("net_pool_max", "l1_Pooling", false);
-}
-
-TEST(Torch_Importer, run_pool_ave)
-{
- runTorchNet("net_pool_ave", "l1_Pooling", false);
-}
-
-TEST(Torch_Importer, run_reshape)
-{
- runTorchNet("net_reshape", "l1_Reshape", false);
- runTorchNet("net_reshape_batch", "l1_Reshape", false);
-}
-
-TEST(Torch_Importer, run_linear)
-{
- runTorchNet("net_linear_2d", "l1_InnerProduct", false);
-}
-
-TEST(Torch_Importer, run_paralel)
-{
- runTorchNet("net_parallel", "l2_torchMerge", false);
-}
-
-TEST(Torch_Importer, run_concat)
-{
- runTorchNet("net_concat", "l2_torchMerge", false);
-}
-
-}
-#endif
-#endif
diff --git a/contrib/modules/dnn/testdata/dnn/.gitignore b/contrib/modules/dnn/testdata/dnn/.gitignore
deleted file mode 100644
index be71866..0000000
--- a/contrib/modules/dnn/testdata/dnn/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.caffemodel
diff --git a/contrib/modules/dnn/testdata/dnn/layers/layer_convolution.prototxt b/contrib/modules/dnn/testdata/dnn/layers/layer_convolution.prototxt
deleted file mode 100644
index 979d343..0000000
--- a/contrib/modules/dnn/testdata/dnn/layers/layer_convolution.prototxt
+++ /dev/null
@@ -1,39 +0,0 @@
-name: "test_Convolution"
-input: "input"
-
-input_dim: 2
-input_dim: 6
-input_dim: 75
-input_dim: 113
-
-layer {
- type: "Convolution"
-
- convolution_param
- {
- group: 3
- num_output: 12
-
- pad_h: 0
- pad_w: 1
- kernel_h: 4
- kernel_w: 5
- stride_h: 2
- stride_w: 3
-
- weight_filler{
- type: 'uniform'
- min: -1
- max: 1
- }
- bias_filler {
- type: 'uniform'
- min: -1
- max: 1
- }
- }
-
- name: "output"
- bottom: "input"
- top: "output"
-}
\ No newline at end of file
diff --git a/contrib/modules/dnn/testdata/dnn/layers/layer_deconvolution.prototxt b/contrib/modules/dnn/testdata/dnn/layers/layer_deconvolution.prototxt
deleted file mode 100644
index eb69b6a..0000000
--- a/contrib/modules/dnn/testdata/dnn/layers/layer_deconvolution.prototxt
+++ /dev/null
@@ -1,39 +0,0 @@
-name: "test_Convolution"
-input: "input"
-
-input_dim: 2
-input_dim: 12
-input_dim: 36
-input_dim: 37
-
-layer {
- type: "Deconvolution"
-
- convolution_param
- {
- group: 3
- num_output: 12
-
- pad_h: 0
- pad_w: 1
- kernel_h: 4
- kernel_w: 5
- stride_h: 2
- stride_w: 3
-
- weight_filler{
- type: 'uniform'
- min: -1
- max: 1
- }
- bias_filler {
- type: 'uniform'
- min: -1
- max: 1
- }
- }
-
- name: "output"
- bottom: "input"
- top: "output"
-}
\ No newline at end of file
diff --git a/contrib/modules/dnn/testdata/dnn/layers/layer_inner_product.prototxt b/contrib/modules/dnn/testdata/dnn/layers/layer_inner_product.prototxt
deleted file mode 100644
index 4599925..0000000
--- a/contrib/modules/dnn/testdata/dnn/layers/layer_inner_product.prototxt
+++ /dev/null
@@ -1,32 +0,0 @@
-name: "test_InnerProduct"
-input: "input"
-
-input_dim: 2
-input_dim: 6
-input_dim: 75
-input_dim: 113
-
-layer {
- type: "InnerProduct"
-
- inner_product_param
- {
- axis: 3
- num_output: 2
-
- weight_filler{
- type: 'uniform'
- min: -1
- max: 1
- }
- bias_filler {
- type: 'uniform'
- min: -1
- max: 1
- }
- }
-
- name: "output"
- bottom: "input"
- top: "output"
-}
\ No newline at end of file
diff --git a/contrib/modules/dnn/testdata/dnn/layers/layer_lrn_channels.prototxt b/contrib/modules/dnn/testdata/dnn/layers/layer_lrn_channels.prototxt
deleted file mode 100644
index a8ec041..0000000
--- a/contrib/modules/dnn/testdata/dnn/layers/layer_lrn_channels.prototxt
+++ /dev/null
@@ -1,21 +0,0 @@
-name: "test_LRN_channels"
-input: "input"
-
-input_dim: 2
-input_dim: 6
-input_dim: 75
-input_dim: 113
-
-layer {
- type: "LRN"
- lrn_param {
- norm_region: ACROSS_CHANNELS;
- local_size: 5
- alpha: 1.1
- beta: 0.75
- }
-
- name: "output"
- bottom: "input"
- top: "output"
-}
diff --git a/contrib/modules/dnn/testdata/dnn/layers/layer_lrn_spatial.prototxt b/contrib/modules/dnn/testdata/dnn/layers/layer_lrn_spatial.prototxt
deleted file mode 100644
index df88afb..0000000
--- a/contrib/modules/dnn/testdata/dnn/layers/layer_lrn_spatial.prototxt
+++ /dev/null
@@ -1,22 +0,0 @@
-name: "test_LRN_spatial"
-input: "input"
-
-input_dim: 2
-input_dim: 6
-input_dim: 75
-input_dim: 113
-
-layer {
- type: "LRN"
-
- lrn_param {
- norm_region: WITHIN_CHANNEL;
- local_size: 5
- alpha: 0.9
- beta: 0.75
- }
-
- name: "output"
- bottom: "input"
- top: "output"
-}
diff --git a/contrib/modules/dnn/testdata/dnn/layers/layer_mvn.prototxt b/contrib/modules/dnn/testdata/dnn/layers/layer_mvn.prototxt
deleted file mode 100644
index 6753695..0000000
--- a/contrib/modules/dnn/testdata/dnn/layers/layer_mvn.prototxt
+++ /dev/null
@@ -1,21 +0,0 @@
-name: "test_MVN_channels"
-input: "input"
-
-input_dim: 2
-input_dim: 6
-input_dim: 75
-input_dim: 113
-
-layer {
- type: "MVN"
-
- mvn_param {
- eps: 0.1
- across_channels: false
- normalize_variance: true
- }
-
- name: "output"
- bottom: "input"
- top: "output"
-}
diff --git a/contrib/modules/dnn/testdata/dnn/layers/layer_pooling_ave.prototxt b/contrib/modules/dnn/testdata/dnn/layers/layer_pooling_ave.prototxt
deleted file mode 100644
index 95cff9a..0000000
--- a/contrib/modules/dnn/testdata/dnn/layers/layer_pooling_ave.prototxt
+++ /dev/null
@@ -1,26 +0,0 @@
-name: "test_Pooling_max"
-input: "input"
-
-input_dim: 2
-input_dim: 6
-input_dim: 75
-input_dim: 113
-
-layer {
- type: "Pooling"
-
- pooling_param
- {
- pool: AVE
- pad_h: 2
- pad_w: 1
- kernel_h: 3
- kernel_w: 5
- stride_h: 2
- stride_w: 1
- }
-
- name: "output"
- bottom: "input"
- top: "output"
-}
\ No newline at end of file
diff --git a/contrib/modules/dnn/testdata/dnn/layers/layer_pooling_max.prototxt b/contrib/modules/dnn/testdata/dnn/layers/layer_pooling_max.prototxt
deleted file mode 100644
index 5c4f415..0000000
--- a/contrib/modules/dnn/testdata/dnn/layers/layer_pooling_max.prototxt
+++ /dev/null
@@ -1,26 +0,0 @@
-name: "test_Pooling_max"
-input: "input"
-
-input_dim: 2
-input_dim: 6
-input_dim: 75
-input_dim: 113
-
-layer {
- type: "Pooling"
-
- pooling_param
- {
- pool: MAX
- pad_h: 2
- pad_w: 1
- kernel_h: 3
- kernel_w: 5
- stride_h: 2
- stride_w: 1
- }
-
- name: "output"
- bottom: "input"
- top: "output"
-}
\ No newline at end of file
diff --git a/contrib/modules/dnn/testdata/dnn/layers/layer_softmax.prototxt b/contrib/modules/dnn/testdata/dnn/layers/layer_softmax.prototxt
deleted file mode 100644
index 3a717a4..0000000
--- a/contrib/modules/dnn/testdata/dnn/layers/layer_softmax.prototxt
+++ /dev/null
@@ -1,15 +0,0 @@
-name: "test_Softmax"
-input: "input"
-
-input_dim: 2
-input_dim: 6
-input_dim: 75
-input_dim: 113
-
-layer {
- type: "Softmax"
-
- name: "output"
- bottom: "input"
- top: "output"
-}
\ No newline at end of file
diff --git a/contrib/modules/dnn/testdata/dnn/layers/reshape_and_slice_routines.prototxt b/contrib/modules/dnn/testdata/dnn/layers/reshape_and_slice_routines.prototxt
deleted file mode 100644
index 9d02133..0000000
--- a/contrib/modules/dnn/testdata/dnn/layers/reshape_and_slice_routines.prototxt
+++ /dev/null
@@ -1,77 +0,0 @@
-name: "test_reshape_splice_split"
-input: "input"
-
-layer{
- type: "Split"
- name: "dummy_split"
- bottom: "input"
- top: "dummy_split_0"
- top: "dummy_split_1"
-}
-layer{
- type: "Slice"
- name: "dummy_slice_0"
- bottom: "dummy_split_0"
- slice_param{
- slice_point: 1
- slice_point: 2
- }
- top: "dummy_slice_0_0"
- top: "dummy_slice_0_1"
- top: "dummy_slice_0_2"
-}
-layer{
- type: "Slice"
- name: "dummy_slice_1"
- bottom: "dummy_split_1"
- slice_param{
- slice_point: 1
- slice_point: 2
- }
- top: "dummy_slice_1_0"
- top: "dummy_slice_1_1"
- top: "dummy_slice_1_2"
-}
-layer{
- type: "Sigmoid"
- name: "alter_sliced_split"
- bottom: "dummy_slice_1_2"
- top: "dummy_slice_1_2"
-}
-layer{
- type: "Concat"
- name: "dummy_concat"
- bottom: "dummy_slice_0_0"
- bottom: "dummy_slice_1_1"
- bottom: "dummy_slice_0_2"
- top: "dummy_concat"
-}
-layer{
- type: "Reshape"
- name: "dummy_reshape"
- bottom: "dummy_concat"
- reshape_param{
- shape{
- dim: 0
- dim: 1
- dim: 1
- dim: -1
- dim: 1
- }
- axis: 1
- num_axes: 1
- }
- top: "dummy_reshape"
-}
-layer{
- type: "Flatten"
- name: "dummy_reshape_undo"
- bottom: "dummy_reshape"
- top: "dummy_reshape_undo"
-}
-layer{
- type: "Split"
- name: "output"
- bottom: "dummy_reshape_undo"
- top: "output"
-}
\ No newline at end of file
diff --git a/contrib/modules/dnn/testdata/dnn/layers/run.py b/contrib/modules/dnn/testdata/dnn/layers/run.py
deleted file mode 100644
index 23d4117..0000000
--- a/contrib/modules/dnn/testdata/dnn/layers/run.py
+++ /dev/null
@@ -1,45 +0,0 @@
-# coding: utf-8
-
-import sys, os, glob
-
-CAFFE_ROOT = "/home/vitaliy/opencv/caffe/"
-sys.path.insert(0, CAFFE_ROOT + 'python')
-
-import numpy as np
-import caffe
-#import cv2
-
-def get_cafe_output(inp_blob, proto_name, caffemodel_name):
- caffe.set_mode_cpu()
- net = caffe.Net(proto_name, caffe.TEST)
-
- #net.blobs['input'].reshape(*inp_blob.shape)
- net.blobs['input'].data[...] = inp_blob
-
- net.forward()
- out_blob = net.blobs['output'].data[...];
-
- if net.params.get('output'):
- print "Params count:", len(net.params['output'])
- net.save(caffemodel_name)
-
- return out_blob
-
-if __name__ == '__main__':
- proto_filenames = glob.glob("layer_*.prototxt")
-
- for proto_filename in proto_filenames:
- proto_filename = os.path.basename(proto_filename)
- proto_basename = os.path.splitext(proto_filename)[0]
- cfmod_basename = proto_basename + ".caffemodel"
- npy_filename = proto_basename + ".npy"
-
- inp_blob_name = proto_basename + ".input.npy"
- inp_blob = np.load(inp_blob_name) if os.path.exists(inp_blob_name) else np.load('blob.npy')
-
- print "\nGenerate data for:"
- print cfmod_basename, inp_blob.shape
-
- out_blob = get_cafe_output(inp_blob, proto_filename, cfmod_basename)
- print out_blob.shape
- np.save(npy_filename, out_blob)
diff --git a/contrib/modules/dnn/testdata/dnn/torch/torch_gen_test_data.lua b/contrib/modules/dnn/testdata/dnn/torch/torch_gen_test_data.lua
deleted file mode 100644
index ae25caa..0000000
--- a/contrib/modules/dnn/testdata/dnn/torch/torch_gen_test_data.lua
+++ /dev/null
@@ -1,67 +0,0 @@
-import 'nn'
-
-function fill_net(net)
- if net.modules then
- for i = 1, #net.modules do
- fill_net(net.modules[i])
- end
- end
- if net.weight then
- net.weight = torch.rand(net.weight:size())
- end
- if net.bias then
- net.bias = torch.rand(net.bias:size())
- end
-end
-
-function save(net, input, label)
- fill_net(net)
- output = net:forward(input)
-
- --torch.save(label .. '_net.dat', net)
- torch.save(label .. '_net.txt', net, 'ascii')
- --torch.save(label .. '_input.dat', input)
- torch.save(label .. '_input.txt', input, 'ascii')
- --torch.save(label .. '_output.dat', output)
- torch.save(label .. '_output.txt', output, 'ascii')
-end
-
-local net_simple = nn.Sequential()
-net_simple:add(nn.ReLU())
-net_simple:add(nn.SpatialConvolution(3,64, 11,7, 3,4, 3,2))
-net_simple:add(nn.SpatialMaxPooling(4,5, 3,2, 1,2))
-net_simple:add(nn.Sigmoid())
-save(net_simple, torch.Tensor(2, 3, 25, 35), 'net_simple')
-
-local net_pool_max = nn.Sequential()
-net_pool_max:add(nn.SpatialMaxPooling(4,5, 3,2, 1,2):ceil()) --TODO: add ceil and floor modes
-save(net_pool_max, torch.rand(2, 3, 50, 30), 'net_pool_max')
-
-local net_pool_ave = nn.Sequential()
-net_pool_ave:add(nn.SpatialAveragePooling(4,5, 2,1, 1,2))
-save(net_pool_ave, torch.rand(2, 3, 50, 30), 'net_pool_ave')
-
-local net_conv = nn.Sequential()
-net_conv:add(nn.SpatialConvolution(3,64, 11,7, 3,4, 3,2))
-save(net_conv, torch.rand(1, 3, 50, 60), 'net_conv')
-
-local net_reshape = nn.Sequential()
-net_reshape:add(nn.Reshape(5, 4, 3, 2))
-save(net_reshape, torch.rand(2, 3, 4, 5), 'net_reshape')
-
-local net_reshape_batch = nn.Sequential()
-net_reshape_batch:add(nn.Reshape(5, 4, 3, true))
-save(net_reshape_batch, torch.rand(2, 3, 4, 5), 'net_reshape_batch')
-
-save(nn.Linear(7, 3), torch.rand(13, 7), 'net_linear_2d')
-
-local net_parallel = nn.Parallel(4, 2)
-net_parallel:add(nn.Sigmoid())
-net_parallel:add(nn.Tanh())
-save(net_parallel, torch.rand(2, 6, 4, 2), 'net_parallel')
-
-local net_concat = nn.Concat(2)
-net_concat:add(nn.ReLU())
-net_concat:add(nn.Tanh())
-net_concat:add(nn.Sigmoid())
-save(net_concat, torch.rand(2, 6, 4, 3) - 0.5, 'net_concat')
diff --git a/contrib/modules/dnn/testdata/dnn/torch/torch_nn_echo.lua b/contrib/modules/dnn/testdata/dnn/torch/torch_nn_echo.lua
deleted file mode 100644
index 46c2583..0000000
--- a/contrib/modules/dnn/testdata/dnn/torch/torch_nn_echo.lua
+++ /dev/null
@@ -1,2 +0,0 @@
-require 'nn'
-print("nn module exists!")
\ No newline at end of file
diff --git a/contrib/modules/dnn/tutorials/images/build_1.png b/contrib/modules/dnn/tutorials/images/build_1.png
deleted file mode 100644
index 855159e..0000000
Binary files a/contrib/modules/dnn/tutorials/images/build_1.png and /dev/null differ
diff --git a/contrib/modules/dnn/tutorials/images/build_2.png b/contrib/modules/dnn/tutorials/images/build_2.png
deleted file mode 100644
index 6741e8a..0000000
Binary files a/contrib/modules/dnn/tutorials/images/build_2.png and /dev/null differ
diff --git a/contrib/modules/dnn/tutorials/images/build_3.png b/contrib/modules/dnn/tutorials/images/build_3.png
deleted file mode 100644
index 102d6e3..0000000
Binary files a/contrib/modules/dnn/tutorials/images/build_3.png and /dev/null differ
diff --git a/contrib/modules/dnn/tutorials/images/build_4.png b/contrib/modules/dnn/tutorials/images/build_4.png
deleted file mode 100644
index 3ad4df8..0000000
Binary files a/contrib/modules/dnn/tutorials/images/build_4.png and /dev/null differ
diff --git a/contrib/modules/dnn/tutorials/images/build_5.png b/contrib/modules/dnn/tutorials/images/build_5.png
deleted file mode 100644
index bd187c6..0000000
Binary files a/contrib/modules/dnn/tutorials/images/build_5.png and /dev/null differ
diff --git a/contrib/modules/dnn/tutorials/tutorial_dnn_build.markdown b/contrib/modules/dnn/tutorials/tutorial_dnn_build.markdown
deleted file mode 100644
index 36f0fec..0000000
--- a/contrib/modules/dnn/tutorials/tutorial_dnn_build.markdown
+++ /dev/null
@@ -1,68 +0,0 @@
-Build opencv_contrib with dnn module {#tutorial_dnn_build}
-====================================
-
-Introduction
-------------
-opencv_dnn module is placed in the secondary [opencv_contrib](https://github.com/opencv/opencv_contrib) repository,
-which isn't distributed in binary form, therefore you need to build it manually.
-
-To do this you need to have installed: [CMake](http://www.cmake.org/download), git, and build system (*gcc* with *make* for Linux or *MS Visual Studio* for Windows)
-
-Steps
------
--# Make any directory, for example **opencv_root**
-
--# Clone [opencv](https://github.com/opencv/opencv) and [opencv_contrib](https://github.com/opencv/opencv_contrib) repos to the **opencv_root**.
- You can do it in terminal like here:
- at code
-cd opencv_root
-git clone https://github.com/opencv/opencv
-git clone https://github.com/opencv/opencv_contrib
- at endcode
-
--# Run [CMake-gui] and set source and build directories:
-
- - Set source code directory to **opencv_root**/opencv;
-
- - Set binaries directory, for example, to **opencv_root**/build_opencv.
- This directory will contain built libraries.
- 
-
--# Configure opencv:
- - press *Configure*;
- - choose the preferred project generator (Makefiles for Linux, MS Visual Studio for Windows);
- - also you can set many opencv build options, for more details see @ref tutorial_linux_install.
- 
-
--# In the appeared list of build parameters find parameter `OPENCV_EXTRA_MODULES_PATH` and set it to the **opencv_root**/opencv_contrib.
- 
-
--# *Configure* the project again, and set build options of dnn module:
-
- - `BUILD_opencv_dnn` parameter must exist and be checked.
-
- - dnn module covers waste part of [Caffe](http://caffe.berkeleyvision.org) framework functionality.
- However, to load Caffe networks libprotobuf is required.
- You you can uncheck `BUILD_LIBPROTOBUF_FROM_SOURCES` flag to try use protobuf installed in your system.
- Elsewise libpotobuf will be built from opencv sources.
-
- - You can additionally check `opencv_dnn_BUILD_TORCH_IMPORTER` parameter to build [Torch7](http://torch.ch/) importer.
- It allows you to use networks, generated by [Torch7.nn](https://github.com/torch/nn/blob/master/README.md/) module.
- 
-
--# Press *Configure* and *Generate*.
- 
-
--# Build the generated project:
- - If Makefiles generator on Unix was used, run the following in terminal:
- @code
- cd opencv_root/build_opencv
- make all
- @endcode
- - If MS Visual Studio generator was used, then open OpenCV.sln from **opencv_root**/build_opencv folder in the Visual Studio,
- and build it by choosing **Build** -> **Build Solution** menu or using **F7** short-cut.
-
--# Now you can build own program by using libraries were built into **opencv_root**/build_opencv/lib.
- See the following tutorials to learn how to create a program using OpenCV:
- - @ref tutorial_windows_install
- - @ref tutorial_linux_gcc_cmake
\ No newline at end of file
diff --git a/contrib/modules/dnn/tutorials/tutorial_dnn_googlenet.markdown b/contrib/modules/dnn/tutorials/tutorial_dnn_googlenet.markdown
deleted file mode 100644
index 1eaaf25..0000000
--- a/contrib/modules/dnn/tutorials/tutorial_dnn_googlenet.markdown
+++ /dev/null
@@ -1,66 +0,0 @@
-Load Caffe framework models {#tutorial_dnn_googlenet}
-===========================
-
-Introduction
-------------
-
-In this tutorial you will learn how to use opencv_dnn module for image classification by using
-GoogLeNet trained network from [Caffe model zoo](http://caffe.berkeleyvision.org/model_zoo.html).
-
-We will demonstrate results of this example on the following picture.
-
-
-Source Code
------------
-
-We will be using snippets from the example application, that can be downloaded [here](https://github.com/ludv1x/opencv_contrib/blob/master/modules/dnn/samples/caffe_googlenet.cpp).
-
- at include dnn/samples/caffe_googlenet.cpp
-
-Explanation
------------
-
--# Firstly, download GoogLeNet model files:
- [bvlc_googlenet.prototxt ](https://raw.githubusercontent.com/ludv1x/opencv_contrib/master/modules/dnn/samples/bvlc_googlenet.prototxt) and
- [bvlc_googlenet.caffemodel](http://dl.caffe.berkeleyvision.org/bvlc_googlenet.caffemodel)
-
- Also you need file with names of [ILSVRC2012](http://image-net.org/challenges/LSVRC/2012/browse-synsets) classes:
- [synset_words.txt](https://raw.githubusercontent.com/ludv1x/opencv_contrib/master/modules/dnn/samples/synset_words.txt).
-
- Put these files into working dir of this program example.
-
--# Read and initialize network using path to .prototxt and .caffemodel files
- @snippet dnn/samples/caffe_googlenet.cpp Read and initialize network
-
--# Check that network was read successfully
- @snippet dnn/samples/caffe_googlenet.cpp Check that network was read successfully
-
--# Read input image and convert to the blob, acceptable by GoogleNet
- @snippet dnn/samples/caffe_googlenet.cpp Prepare blob
- Firstly, we resize the image and change its channel sequence order.
-
- Now image is actually a 3-dimensional array with 224x224x3 shape.
-
- Next, we convert the image to 4-dimensional blob (so-called batch) with 1x3x224x224 shape by using special cv::dnn::Blob::fromImages constructor.
-
--# Pass the blob to the network
- @snippet dnn/samples/caffe_googlenet.cpp Set input blob
- In bvlc_googlenet.prototxt the network input blob named as "data", therefore this blob labeled as ".data" in opencv_dnn API.
-
- Other blobs labeled as "name_of_layer.name_of_layer_output".
-
--# Make forward pass
- @snippet dnn/samples/caffe_googlenet.cpp Make forward pass
- During the forward pass output of each network layer is computed, but in this example we need output from "prob" layer only.
-
--# Determine the best class
- @snippet dnn/samples/caffe_googlenet.cpp Gather output
- We put the output of "prob" layer, which contain probabilities for each of 1000 ILSVRC2012 image classes, to the `prob` blob.
- And find the index of element with maximal value in this one. This index correspond to the class of the image.
-
--# Print results
- @snippet dnn/samples/caffe_googlenet.cpp Print results
- For our image we get:
-> Best class: #812 'space shuttle'
->
-> Probability: 99.6378%
\ No newline at end of file
diff --git a/contrib/modules/dnn_modern/CMakeLists.txt b/contrib/modules/dnn_modern/CMakeLists.txt
new file mode 100644
index 0000000..79b64b1
--- /dev/null
+++ b/contrib/modules/dnn_modern/CMakeLists.txt
@@ -0,0 +1,174 @@
+set(the_description "Modern Deep Learning module")
+
+if(${CMAKE_VERSION} VERSION_LESS 3.2)
+ message(STATUS "Module opencv_dnn_modern disabled because CMake version is less than 3.2")
+ ocv_module_disable(dnn_modern)
+ return()
+endif()
+
+cmake_policy(SET CMP0028 OLD)
+
+# Using cmake scripts and modules
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
+
+# ----------------------------------------------------------------------------
+# MODULE REQUIREMENTS
+# ----------------------------------------------------------------------------
+
+set(TINY_DNN_CPP_PATH "${OpenCV_BINARY_DIR}/3rdparty/tinydnn")
+set(TINY_DNN_CPP_ROOT "${TINY_DNN_CPP_PATH}/tiny-dnn-1.0.0a3")
+ocv_download(FILENAME "v1.0.0a3.tar.gz"
+ HASH "adb1c512e09ca2c7a6faef36f9c53e59"
+ URL
+ "${OPENCV_TINY_DNN_URL}"
+ "$ENV{OPENCV_TINY_DNN_URL}"
+ "https://github.com/tiny-dnn/tiny-dnn/archive/"
+ DESTINATION_DIR "${TINY_DNN_CPP_PATH}"
+ STATUS TINY_DNN_DOWNLOAD_SUCCESS
+ ID "tiny-dnn"
+ UNPACK RELATIVE_URL)
+
+if(NOT TINY_DNN_DOWNLOAD_SUCCESS)
+ message(STATUS "Failed to download tiny-dnn sources")
+endif()
+
+find_package(TinyDNN QUIET)
+
+include(CheckCXXCompilerFlag)
+CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
+
+if(NOT TinyDNN_FOUND)
+ message(STATUS "Module opencv_dnn_modern disabled because tiny-dnn was not found")
+ ocv_module_disable(dnn_modern)
+ return()
+elseif(NOT COMPILER_SUPPORTS_CXX11)
+ message(STATUS "Module opencv_dnn_modern disabled because your compiler does not support C++11")
+ ocv_module_disable(dnn_modern)
+ return()
+elseif(APPLE_FRAMEWORK OR ANDROID)
+ message(STATUS "Module opencv_dnn_modern disabled because you are not under Linux or Win")
+ ocv_module_disable(dnn_modern)
+ return()
+endif()
+
+# ----------------------------------------------------------------------------
+# OPTIMIZATION OPTIONS
+# ----------------------------------------------------------------------------
+
+option(TINYDNN_USE_SSE "Build tiny-dnn with SSE library support" ON)
+option(TINYDNN_USE_AVX "Build tiny-dnn with AVX library support" ON)
+option(TINYDNN_USE_TBB "Build tiny-dnn with TBB library support" OFF)
+option(TINYDNN_USE_OMP "Build tiny-dnn with OMP library support" OFF)
+option(TINYDNN_USE_NNPACK "Build tiny-dnn with NNPACK library support" OFF)
+
+if(TINYDNN_USE_TBB AND HAVE_TBB)
+ add_definitions(-DCNN_USE_TBB)
+elseif(NOT TINYDNN_USE_TBB AND
+ TINYDNN_USE_OMP AND HAVE_OPENMP)
+ add_definitions(-DCNN_USE_OMP)
+endif()
+
+if(TINYDNN_USE_NNPACK)
+ find_package(NNPACK REQUIRED)
+ add_definitions(-DCNN_USE_NNPACK)
+ include_directories(SYSTEM ${NNPACK_INCLUDE_DIR})
+ include_directories(SYSTEM ${NNPACK_INCLUDE_DIR}/../third-party/pthreadpool/include)
+ list(APPEND REQUIRED_LIBRARIES ${NNPACK_LIB})
+endif()
+
+# we need to disable seializer unless we import cereal and we gonna use caffe converter
+add_definitions(-DCNN_NO_SERIALIZATION -DCNN_USE_CAFFE_CONVERTER)
+
+# NOTE: In case that proto files already exist,
+# this is not needed anymore.
+find_package(Protobuf QUIET)
+
+if(DEFINED PROTOBUF_PROTOC_EXECUTABLE AND EXISTS ${PROTOBUF_PROTOC_EXECUTABLE})
+ execute_process(COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} caffe.proto --cpp_out=./
+ WORKING_DIRECTORY ${TINYDNN_INCLUDE_DIRS}/tiny_dnn/io/caffe)
+else()
+ message(STATUS "The protocol buffer compiler is not found (PROTOBUF_PROTOC_EXECUTABLE='${PROTOBUF_PROTOC_EXECUTABLE}')")
+ ocv_module_disable(dnn_modern)
+ return()
+endif()
+
+list(APPEND REQUIRED_LIBRARIES ${PROTOBUF_LIBRARIES})
+include_directories(SYSTEM ${PROTOBUF_INCLUDE_DIRS})
+
+####
+# Setup the compiler options
+
+# set c++ standard to c++11.
+# Note: not working on CMake 2.8. We assume that user has
+# a compiler with C++11 support.
+
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
+# Unix
+if(CMAKE_COMPILER_IS_GNUCXX OR MINGW OR
+ CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ include(CheckCXXCompilerFlag)
+ check_cxx_compiler_flag("-msse3" COMPILER_HAS_SSE_FLAG)
+ check_cxx_compiler_flag("-mavx" COMPILER_HAS_AVX_FLAG)
+ check_cxx_compiler_flag("-mavx2" COMPILER_HAS_AVX2_FLAG)
+ check_cxx_compiler_flag("-mfma" COMPILER_HAS_AVX2_FLAG)
+
+ # set Streaming SIMD Extension (SSE) instructions
+ if(USE_SSE AND COMPILER_HAS_SSE_FLAG)
+ add_definitions(-DCNN_USE_SSE)
+ set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -msse3")
+ endif(USE_SSE AND COMPILER_HAS_SSE_FLAG)
+ # set Advanced Vector Extensions (AVX)
+ if(USE_AVX AND COMPILER_HAS_AVX_FLAG)
+ add_definitions(-DCNN_USE_AVX)
+ set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -mavx")
+ endif(USE_AVX AND COMPILER_HAS_AVX_FLAG)
+ # set Advanced Vector Extensions 2 (AVX2)
+ if(USE_AVX2 AND COMPILER_HAS_AVX2_FLAG)
+ add_definitions(-DCNN_USE_AVX2)
+ set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -mavx2 -mfma -march=core-avx2")
+ endif(USE_AVX2 AND COMPILER_HAS_AVX2_FLAG)
+
+ # include extra flags to the compiler
+ # TODO: add info about those flags.
+ set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wall -Wpedantic -Wno-narrowing")
+ set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -O3")
+ set(EXTRA_C_FLAGS_DEBUG "${EXTRA_C_FLAGS_DEBUG} -g3 -pthread")
+elseif(MSVC)
+ if(USE_SSE)
+ add_definitions(-DCNN_USE_SSE)
+ set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} /arch:SSE2")
+ endif(USE_SSE)
+ if(USE_AVX)
+ add_definitions(-DCNN_USE_AVX)
+ set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} /arch:AVX")
+ endif(USE_AVX)
+ if(USE_AVX2)
+ add_definitions(-DCNN_USE_AVX2)
+ set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} /arch:AVX2")
+ endif(USE_AVX2)
+ # include specific flags for release and debug modes.
+ set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE}
+ /Ox /Oi /Ot /Oy /GL /fp:fast /GS-")
+ set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG")
+ set(EXTRA_C_FLAGS_DEBUG "${EXTRA_C_FLAGS_DEBUG}")
+ set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} /W4 /bigobj")
+ # this is fine
+ add_definitions(-D _CRT_SECURE_NO_WARNINGS)
+ add_definitions(-D _SCL_SECURE_NO_WARNINGS)
+ add_definitions(-D NO_STRICT)
+ # prolly powerless with header-only project
+ set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} /MP")
+endif()
+
+# ----------------------------------------------------------------------------
+# DNN-MODERN MODULE
+# ----------------------------------------------------------------------------
+
+ocv_define_module(dnn_modern opencv_core opencv_imgproc WRAP python)
+ocv_target_link_libraries(${the_module} ${REQUIRED_LIBRARIES})
+ocv_target_include_directories(${the_module} ${TINYDNN_INCLUDE_DIRS})
+ocv_warnings_disable(CMAKE_CXX_FLAGS
+ -Wnon-virtual-dtor -Wunused-parameter -Wshadow -Wundef
+ /wd4265 /wd4100 /wd4458 /wd4244 /wd4456)
diff --git a/contrib/modules/dnn_modern/README.md b/contrib/modules/dnn_modern/README.md
new file mode 100644
index 0000000..6588734
--- /dev/null
+++ b/contrib/modules/dnn_modern/README.md
@@ -0,0 +1,50 @@
+Modern Deep Learning Module
+===========================
+
+The module is wrapper to [tiny-dnn](https://github.com/tiny-dnn/tiny-dnn),
+a header only, dependency-free deep learning framework in C++11.
+
+Installation
+------------
+
+**Required Dependencies**
+ - System under Unix or Windows
+ - C++11 compiler
+ - tiny-dnn headers
+ - protoc compiler (part of the [protobuf](https://developers.google.com/protocol-buffers/docs/overview) library)
+
+**How to install tiny-dnn?**
+ CMake will try to download a certain version of tiny-dnn which was tested to build with OpenCV.
+ If the latest version is needed, location of the tiny-dnn folder can be specified manually:
+
+- Download tiny-dnn project somewhere in your system
+```
+ cd /opt
+ git clone https://github.com/tiny-dnn/tiny-dnn.git
+```
+
+- Run your OpenCV CMake pointing to your tiny-dnn headers location
+```
+ cd /opt/opencv/build
+ cmake -DTINYDNN_ROOT=/opt/tiny-dnn ..
+ make -j4
+```
+
+**Extra**
+
+ You can enable some optimizations just for tiny-dnn backend
+
+ cmake -DTINYDNN_USE_SSE=ON ..
+ cmake -DTINYDNN_USE_AVX=ON ..
+
+ Use third-party multithreading libs: TBB or OMP.
+
+ cmake -DTINYDNN_USE_TBB=ON .. // then disable OMP
+ cmake -DTINYDNN_USE_OMP=ON .. // then disable TBB
+
+ NNPACK: Acceleration package for neural networks on multi-core CPUs.<br />
+ Check project site for installation: [https://github.com/Maratyszcza/NNPACK](https://github.com/Maratyszcza/NNPACK)
+
+ cmake -DTINYDNN_USE_NNPACK=ON .. // not supported yet for Caffe loader
+
+See detailed module API documentation in http://docs.opencv.org/trunk/d1/df7/group__dnn__modern.html
diff --git a/contrib/modules/dnn_modern/cmake/FindNNPACK.cmake b/contrib/modules/dnn_modern/cmake/FindNNPACK.cmake
new file mode 100644
index 0000000..c296de6
--- /dev/null
+++ b/contrib/modules/dnn_modern/cmake/FindNNPACK.cmake
@@ -0,0 +1,54 @@
+SET(NNPACK_INCLUDE_SEARCH_PATHS
+ /usr/include
+ /usr/local/include
+ /opt/NNPACK/include
+ $ENV{NNPACK_ROOT}
+ $ENV{NNPACK_ROOT}/include
+)
+
+SET(NNPACK_LIB_SEARCH_PATHS
+ /lib/
+ /lib64/
+ /usr/lib
+ /usr/lib64
+ /usr/local/lib
+ /usr/local/lib64
+ /opt/NNPACK/lib
+ $ENV{NNPACK_ROOT}
+ $ENV{NNPACK_ROOT}/lib
+ )
+
+FIND_PATH(NNPACK_INCLUDE_DIR NAMES nnpack.h PATHS ${NNPACK_INCLUDE_SEARCH_PATHS})
+FIND_LIBRARY(NNPACK_LIB NAMES nnpack PATHS ${NNPACK_LIB_SEARCH_PATHS})
+
+SET(NNPACK_FOUND ON)
+
+# Check include files
+IF(NOT NNPACK_INCLUDE_DIR)
+ SET(NNPACK_FOUND OFF)
+ MESSAGE(STATUS "Could not find NNPACK include. Turning NNPACK_FOUND off")
+ENDIF()
+
+# Check libraries
+IF(NOT NNPACK_LIB)
+ SET(NNPACK_FOUND OFF)
+ MESSAGE(STATUS "Could not find NNPACK lib. Turning NNPACK_FOUND off")
+ENDIF()
+
+IF (NNPACK_FOUND)
+ add_definitions(-DUSE_NNPACK)
+ IF (NOT NNPACK_FIND_QUIETLY)
+ MESSAGE(STATUS "Found NNPACK libraries: ${NNPACK_LIB}")
+ MESSAGE(STATUS "Found NNPACK include: ${NNPACK_INCLUDE_DIR}")
+ ENDIF (NOT NNPACK_FIND_QUIETLY)
+ELSE (NNPACK_FOUND)
+ IF (NNPACK_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "Could not find NNPACK")
+ ENDIF (NNPACK_FIND_REQUIRED)
+ENDIF (NNPACK_FOUND)
+
+MARK_AS_ADVANCED(
+ NNPACK_INCLUDE_DIR
+ NNPACK_LIB
+ NNPACK
+)
diff --git a/contrib/modules/dnn_modern/cmake/FindTinyDNN.cmake b/contrib/modules/dnn_modern/cmake/FindTinyDNN.cmake
new file mode 100644
index 0000000..ac4dcaa
--- /dev/null
+++ b/contrib/modules/dnn_modern/cmake/FindTinyDNN.cmake
@@ -0,0 +1,47 @@
+# Locate the tiny-dnn library.
+#
+# Defines the following variables:
+#
+# TinyDNN_FOUND - TRUE if the tiny-dnn headers are found
+# TINYDNN_INCLUDE_DIRS - The path to tiny-dnn headers
+#
+# Accepts the following variables as input:
+#
+# TinyDNN_ROOT - (as a CMake or environment variable)
+# The root directory of the tiny-dnn install prefix
+
+message(STATUS "Looking for tiny_dnn.h")
+
+set(TINYDNN_INCLUDE_SEARCH_PATHS
+ /usr/include/tiny_dnn
+ /usr/local/include/tiny_dnn
+ /opt/tiny_dnn
+ $ENV{TINYDNN_ROOT}
+ ${TINYDNN_ROOT}
+ ${TINYDNN_ROOT}/tiny_dnn
+ ${TINY_DNN_CPP_ROOT}
+)
+
+find_path(TINYDNN_INCLUDE_DIR
+ NAMES tiny_dnn/tiny_dnn.h
+ HINTS ${TINYDNN_INCLUDE_SEARCH_PATHS}
+)
+
+# handle the QUIETLY and REQUIRED arguments and set TinyDNN_FOUND to TRUE if
+# all listed variables are TRUE
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(TinyDNN
+ FOUND_VAR TinyDNN_FOUND
+ REQUIRED_VARS TINYDNN_INCLUDE_DIR)
+
+if(TinyDNN_FOUND)
+ set(TINYDNN_INCLUDE_DIRS ${TINYDNN_INCLUDE_DIR})
+ message(STATUS "Looking for tiny_dnn.h - found")
+ message(STATUS "Found tiny-dnn in: ${TINYDNN_INCLUDE_DIRS}")
+else()
+ message(STATUS "Looking for tiny_dnn.h - not found")
+endif()
+
+mark_as_advanced(
+ TINYDNN_INCLUDE_DIRS
+)
diff --git a/contrib/modules/dnn_modern/include/opencv2/dnn_modern.hpp b/contrib/modules/dnn_modern/include/opencv2/dnn_modern.hpp
new file mode 100644
index 0000000..3359890
--- /dev/null
+++ b/contrib/modules/dnn_modern/include/opencv2/dnn_modern.hpp
@@ -0,0 +1,106 @@
+/*
+ By downloading, copying, installing or using the software you agree to this license.
+ If you do not agree to this license, do not download, install,
+ copy or use the software.
+
+
+ License Agreement
+ For Open Source Computer Vision Library
+ (3-clause BSD License)
+
+ Copyright (C) 2000-2016, Intel Corporation, all rights reserved.
+ Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved.
+ Copyright (C) 2009-2016, NVIDIA Corporation, all rights reserved.
+ Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved.
+ Copyright (C) 2015-2016, OpenCV Foundation, all rights reserved.
+ Copyright (C) 2015-2016, Itseez Inc., all rights reserved.
+ Third party copyrights are property of their respective owners.
+
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the names of the copyright holders nor the names of the contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ This software is provided by the copyright holders and contributors "as is" and
+ any express or implied warranties, including, but not limited to, the implied
+ warranties of merchantability and fitness for a particular purpose are disclaimed.
+ In no event shall copyright holders or contributors be liable for any direct,
+ indirect, incidental, special, exemplary, or consequential damages
+ (including, but not limited to, procurement of substitute goods or services;
+ loss of use, data, or profits; or business interruption) however caused
+ and on any theory of liability, whether in contract, strict liability,
+ or tort (including negligence or otherwise) arising in any way out of
+ the use of this software, even if advised of the possibility of such damage.
+ */
+
+#ifndef __OPENCV_DNN_M_HPP__
+#define __OPENCV_DNN_M_HPP__
+
+#include "opencv2/core.hpp"
+
+/** @defgroup dnn_modern Deep Learning Modern Module
+ * This module is based on the [tiny-dnn](https://github.com/tiny-dnn/tiny-dnn) framework.
+ * The module uses tiny-dnn to load and run pre-trained Caffe models.
+ * tiny-dnn's converter only supports single input/single output network without branches.
+*/
+
+
+namespace cv {
+namespace dnn2 {
+
+//! @addtogroup dnn_modern
+//! @{
+
+/** @brief Base class for tiny-dnn converter.
+ */
+class CV_EXPORTS_W BaseConverter
+{
+public:
+ virtual ~BaseConverter() {};
+
+ /**
+ @brief Evaluates single model output on single model input.
+ @param image input image.
+ @param results output form model.
+ */
+ CV_WRAP virtual void eval(InputArray image, std::vector<float>& results) = 0;
+};
+
+/** @brief Class implementing the CaffeConverter.
+
+Implementation of tiny-dnn Caffe converter.
+Loads a pretrained Caffe model. Only support simple sequential models.
+
+ */
+class CV_EXPORTS_W CaffeConverter : public BaseConverter {
+ public:
+
+ /**
+ @brief Creates a CaffeConverter object.
+
+ @param model_file path to the prototxt file.
+ @param trained_file path to the caffemodel file.
+ @param mean_file path to binaryproto file.
+ */
+ CV_WRAP static Ptr<CaffeConverter> create(const String& model_file,
+ const String& trained_file,
+ const String& mean_file = String());
+
+ CV_WRAP virtual void eval(InputArray image, CV_OUT std::vector<float>& results) = 0;
+};
+
+//! @}
+} // namespace dnn2
+} // namespace cv
+#endif
+
+/* End of file. */
diff --git a/contrib/modules/dnn_modern/samples/simple_test.cpp b/contrib/modules/dnn_modern/samples/simple_test.cpp
new file mode 100644
index 0000000..965a2af
--- /dev/null
+++ b/contrib/modules/dnn_modern/samples/simple_test.cpp
@@ -0,0 +1,93 @@
+#include <opencv2/dnn_modern.hpp>
+#include <opencv2/imgcodecs.hpp>
+
+#include <iostream>
+#include <fstream>
+
+
+using namespace std;
+using namespace cv;
+using namespace cv::dnn2;
+
+static void help() {
+ cout
+ << "\n----------------------------------------------------------------------------\n"
+ << " This program shows how to import a Caffe model using the \n"
+ << " OpenCV Modern Deep Learning module (DNN2).\n"
+ << " Usage:\n"
+ << " example_dnn_modern_simple_test <model_file> <trained_file> <mean_file>\n"
+ << " <label_file> <image_file>\n"
+ << " where: model_file is the path to the *.prototxt\n"
+ << " trained_file is the path to the *.caffemodel\n"
+ << " mean_file is the path to the *.binaryproto\n"
+ << " label_file is the path to the labels file\n"
+ << " image_file is the path to the image to evaluate\n"
+ << "----------------------------------------------------------------------------\n\n"
+ << endl;
+}
+
+vector<string> get_label_list(const string& label_file);
+void print_n_labels(const vector<string>& labels,
+ const vector<float_t>& result,
+ const int top_n);
+
+vector<string> get_label_list(const string& label_file) {
+ string line;
+ ifstream ifs(label_file.c_str());
+
+ if (ifs.fail() || ifs.bad()) {
+ throw runtime_error("failed to open:" + label_file);
+ }
+
+ vector<string> lines;
+ while (getline(ifs, line)) lines.push_back(line);
+
+ return lines;
+}
+
+void print_n_labels(const vector<string>& labels,
+ const vector<float_t>& result,
+ const int top_n) {
+ vector<float_t> sorted(result.begin(), result.end());
+
+ partial_sort(sorted.begin(), sorted.begin()+top_n, sorted.end(), greater<float_t>());
+
+ for (int i = 0; i < top_n; i++) {
+ size_t idx = distance(result.begin(), find(result.begin(), result.end(), sorted[i]));
+ cout << labels[idx] << "," << sorted[i] << endl;
+ }
+}
+
+int main(int argc, char* argv[]) {
+
+ if (argc < 6) {
+ help();
+ exit(0);
+ }
+
+ int arg_channel = 1;
+ string model_file = argv[arg_channel++];
+ string trained_file = argv[arg_channel++];
+ string mean_file = argv[arg_channel++];
+ string label_file = argv[arg_channel++];
+ string img_file = argv[arg_channel++];
+
+ // load Caffe model
+ Ptr<CaffeConverter> caffe_ptr = CaffeConverter::create(
+ model_file, trained_file, mean_file);
+
+ // load input image
+ cv::Mat img = cv::imread(img_file, -1);
+
+ // inference !
+ vector<float_t> scores;
+ caffe_ptr->eval(img, scores);
+
+ // retrieve n labels
+ const int n = 5;
+ vector<string> labels = get_label_list(label_file);
+
+ print_n_labels(labels, scores, n);
+
+ return 0;
+}
diff --git a/contrib/modules/dnn_modern/src/caffe_converter.cpp b/contrib/modules/dnn_modern/src/caffe_converter.cpp
new file mode 100644
index 0000000..b876289
--- /dev/null
+++ b/contrib/modules/dnn_modern/src/caffe_converter.cpp
@@ -0,0 +1,204 @@
+/*
+ By downloading, copying, installing or using the software you agree to this license.
+ If you do not agree to this license, do not download, install,
+ copy or use the software.
+
+
+ License Agreement
+ For Open Source Computer Vision Library
+ (3-clause BSD License)
+
+ Copyright (C) 2000-2016, Intel Corporation, all rights reserved.
+ Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved.
+ Copyright (C) 2009-2016, NVIDIA Corporation, all rights reserved.
+ Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved.
+ Copyright (C) 2015-2016, OpenCV Foundation, all rights reserved.
+ Copyright (C) 2015-2016, Itseez Inc., all rights reserved.
+ Third party copyrights are property of their respective owners.
+
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the names of the copyright holders nor the names of the contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ This software is provided by the copyright holders and contributors "as is" and
+ any express or implied warranties, including, but not limited to, the implied
+ warranties of merchantability and fitness for a particular purpose are disclaimed.
+ In no event shall copyright holders or contributors be liable for any direct,
+ indirect, incidental, special, exemplary, or consequential damages
+ (including, but not limited to, procurement of substitute goods or services;
+ loss of use, data, or profits; or business interruption) however caused
+ and on any theory of liability, whether in contract, strict liability,
+ or tort (including negligence or otherwise) arising in any way out of
+ the use of this software, even if advised of the possibility of such damage.
+ */
+
+#include "precomp.hpp"
+#include <opencv2/imgproc.hpp>
+
+#include <tiny_dnn/tiny_dnn.h>
+#include <tiny_dnn/io/caffe/caffe.pb.cc>
+
+using namespace tiny_dnn;
+using namespace tiny_dnn::activation;
+using namespace std;
+
+namespace cv {
+namespace dnn2 {
+
+/*
+ !CaffeConverter Implementation
+ */
+class CaffeConverter_Impl : public CaffeConverter {
+ public:
+ explicit CaffeConverter_Impl(const String& model_file,
+ const String& trained_file,
+ const String& mean_file) {
+ net_ = create_net_from_caffe_prototxt(model_file);
+ reload_weight_from_caffe_protobinary(trained_file, net_.get());
+
+ const size_t width = (*net_)[0]->in_data_shape()[0].width_;
+ const size_t height = (*net_)[0]->in_data_shape()[0].height_;
+
+ mean_ = compute_mean(mean_file, width, height);
+ }
+
+ ~CaffeConverter_Impl() {}
+
+ virtual void eval(InputArray image, std::vector<float>& results);
+
+ private:
+ Mat compute_mean(const string& mean_file, const size_t width,
+ const size_t height);
+
+ ColorConversionCodes get_cvt_codes(const int src_channels,
+ const int dst_channels);
+
+ void preprocess(const Mat& img, const Mat& mean,
+ const int num_channels, const Size& geometry,
+ vector<Mat>* input_channels);
+
+ Mat mean_;
+ std::shared_ptr<network<sequential>> net_;
+};
+
+Mat
+CaffeConverter_Impl::compute_mean(const string& mean_file,
+ const size_t width,
+ const size_t height) {
+ caffe::BlobProto blob;
+ ::detail::read_proto_from_binary(mean_file, &blob);
+
+ vector<Mat> channels;
+ auto data = blob.mutable_data()->mutable_data();
+
+ const size_t offset = blob.height() * blob.width();
+
+ for (int i = 0; i < blob.channels(); i++, data += offset) {
+ channels.emplace_back(blob.height(), blob.width(), CV_32FC1, data);
+ }
+
+ Mat meanChannel;
+ merge(channels, meanChannel);
+
+ return Mat(Size(width, height), meanChannel.type(), mean(meanChannel));
+}
+
+ColorConversionCodes
+CaffeConverter_Impl::get_cvt_codes(const int src_channels,
+ const int dst_channels) {
+ assert(src_channels != dst_channels);
+
+ if (dst_channels == 3) {
+ return src_channels == 1 ? COLOR_GRAY2BGR : COLOR_BGRA2BGR;
+ } else if (dst_channels == 1) {
+ return src_channels == 3 ? COLOR_BGR2GRAY : COLOR_BGRA2GRAY;
+ } else {
+ throw runtime_error("unsupported color code");
+ }
+}
+
+void CaffeConverter_Impl::preprocess(const Mat& img,
+ const Mat& mean,
+ const int num_channels,
+ const Size& geometry,
+ vector<Mat>* input_channels) {
+ Mat sample;
+
+ // convert color
+ if (img.channels() != num_channels) {
+ cvtColor(img, sample,
+ get_cvt_codes(img.channels(), num_channels));
+ } else {
+ sample = img;
+ }
+
+ // resize
+ Mat sample_resized;
+ resize(sample, sample_resized, geometry);
+
+ Mat sample_float;
+ sample_resized.convertTo(sample_float,
+ num_channels == 3 ? CV_32FC3 : CV_32FC1);
+
+ // subtract mean
+ if (mean.size().width > 0) {
+ Mat sample_normalized;
+ subtract(sample_float, mean, sample_normalized);
+ split(sample_normalized, *input_channels);
+ }
+ else {
+ split(sample_float, *input_channels);
+ }
+}
+
+void CaffeConverter_Impl::eval(InputArray image,
+ std::vector<float>& results) {
+ const Mat img = image.getMat();
+
+ const size_t channels = (*net_)[0]->in_data_shape()[0].depth_;
+ const size_t width = (*net_)[0]->in_data_shape()[0].width_;
+ const size_t height = (*net_)[0]->in_data_shape()[0].height_;
+
+ vector<Mat> input_channels;
+ vector<float> inputvec(width*height*channels);
+
+ for (size_t i = 0; i < channels; i++) {
+ input_channels.emplace_back(height, width, CV_32FC1,
+ &inputvec[width*height*i]);
+ }
+
+ // subtract mean from input
+ preprocess(img, mean_, 3, Size(width, height), &input_channels);
+
+ const vector<tiny_dnn::float_t> vec(inputvec.begin(), inputvec.end());
+
+ // perform inderence
+ auto result = net_->predict(vec);
+
+ // allocate output
+ results.clear();
+ results.reserve(result.size());
+
+ for (size_t i = 0; i < result.size(); i++) {
+ results.push_back(result[i]);
+ }
+}
+
+Ptr<CaffeConverter> CaffeConverter::create(const String& model_file,
+ const String& trained_file,
+ const String& mean_file) {
+ return makePtr<CaffeConverter_Impl>(model_file, trained_file, mean_file);
+}
+
+} // namespace dnn2
+} // namespace cv
diff --git a/contrib/modules/dnn_modern/src/dnn_modern_init.cpp b/contrib/modules/dnn_modern/src/dnn_modern_init.cpp
new file mode 100644
index 0000000..441ec43
--- /dev/null
+++ b/contrib/modules/dnn_modern/src/dnn_modern_init.cpp
@@ -0,0 +1,47 @@
+/*
+ By downloading, copying, installing or using the software you agree to this license.
+ If you do not agree to this license, do not download, install,
+ copy or use the software.
+
+
+ License Agreement
+ For Open Source Computer Vision Library
+ (3-clause BSD License)
+
+ Copyright (C) 2000-2016, Intel Corporation, all rights reserved.
+ Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved.
+ Copyright (C) 2009-2016, NVIDIA Corporation, all rights reserved.
+ Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved.
+ Copyright (C) 2015-2016, OpenCV Foundation, all rights reserved.
+ Copyright (C) 2015-2016, Itseez Inc., all rights reserved.
+ Third party copyrights are property of their respective owners.
+
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the names of the copyright holders nor the names of the contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ This software is provided by the copyright holders and contributors "as is" and
+ any express or implied warranties, including, but not limited to, the implied
+ warranties of merchantability and fitness for a particular purpose are disclaimed.
+ In no event shall copyright holders or contributors be liable for any direct,
+ indirect, incidental, special, exemplary, or consequential damages
+ (including, but not limited to, procurement of substitute goods or services;
+ loss of use, data, or profits; or business interruption) however caused
+ and on any theory of liability, whether in contract, strict liability,
+ or tort (including negligence or otherwise) arising in any way out of
+ the use of this software, even if advised of the possibility of such damage.
+ */
+
+#include "precomp.hpp"
+
+//#include <tiny_cnn/tiny_cnn.h>
diff --git a/contrib/modules/dnn_modern/src/precomp.hpp b/contrib/modules/dnn_modern/src/precomp.hpp
new file mode 100644
index 0000000..8ac69e2
--- /dev/null
+++ b/contrib/modules/dnn_modern/src/precomp.hpp
@@ -0,0 +1,50 @@
+/*
+ By downloading, copying, installing or using the software you agree to this license.
+ If you do not agree to this license, do not download, install,
+ copy or use the software.
+
+
+ License Agreement
+ For Open Source Computer Vision Library
+ (3-clause BSD License)
+
+ Copyright (C) 2000-2016, Intel Corporation, all rights reserved.
+ Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved.
+ Copyright (C) 2009-2016, NVIDIA Corporation, all rights reserved.
+ Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved.
+ Copyright (C) 2015-2016, OpenCV Foundation, all rights reserved.
+ Copyright (C) 2015-2016, Itseez Inc., all rights reserved.
+ Third party copyrights are property of their respective owners.
+
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the names of the copyright holders nor the names of the contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ This software is provided by the copyright holders and contributors "as is" and
+ any express or implied warranties, including, but not limited to, the implied
+ warranties of merchantability and fitness for a particular purpose are disclaimed.
+ In no event shall copyright holders or contributors be liable for any direct,
+ indirect, incidental, special, exemplary, or consequential damages
+ (including, but not limited to, procurement of substitute goods or services;
+ loss of use, data, or profits; or business interruption) however caused
+ and on any theory of liability, whether in contract, strict liability,
+ or tort (including negligence or otherwise) arising in any way out of
+ the use of this software, even if advised of the possibility of such damage.
+ */
+
+#ifndef __OPENCV_PRECOMP_H__
+#define __OPENCV_PRECOMP_H__
+
+#include "opencv2/dnn_modern.hpp"
+
+#endif
diff --git a/contrib/modules/dpm/include/opencv2/dpm.hpp b/contrib/modules/dpm/include/opencv2/dpm.hpp
index 387a311..ab604ab 100644
--- a/contrib/modules/dpm/include/opencv2/dpm.hpp
+++ b/contrib/modules/dpm/include/opencv2/dpm.hpp
@@ -96,6 +96,9 @@ namespace cv
namespace dpm
{
+//! @addtogroup dpm
+//! @{
+
/** @brief This is a C++ abstract class, it provides external user API to work with DPM.
*/
class CV_EXPORTS_W DPMDetector
@@ -142,6 +145,8 @@ public:
virtual ~DPMDetector(){}
};
+//! @}
+
} // namespace dpm
} // namespace cv
diff --git a/contrib/modules/dpm/src/precomp.cpp b/contrib/modules/dpm/src/precomp.cpp
deleted file mode 100644
index ca7dd44..0000000
--- a/contrib/modules/dpm/src/precomp.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2015, Itseez Inc, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Itseez Inc or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-/* End of file. */
diff --git a/contrib/modules/face/include/opencv2/face.hpp b/contrib/modules/face/include/opencv2/face.hpp
index a90a1da..52fe975 100644
--- a/contrib/modules/face/include/opencv2/face.hpp
+++ b/contrib/modules/face/include/opencv2/face.hpp
@@ -113,7 +113,7 @@ int num_components = 10;
double threshold = 10.0;
// Then if you want to have a cv::FaceRecognizer with a confidence threshold,
// create the concrete implementation with the appropiate parameters:
-Ptr<FaceRecognizer> model = createEigenFaceRecognizer(num_components, threshold);
+Ptr<FaceRecognizer> model = EigenFaceRecognizer::create(num_components, threshold);
@endcode
Sometimes it's impossible to train the model, just to experiment with threshold values. Thanks to
@@ -148,7 +148,7 @@ FaceRecognizer:
@code
// Create a FaceRecognizer:
-Ptr<FaceRecognizer> model = createEigenFaceRecognizer();
+Ptr<FaceRecognizer> model = EigenFaceRecognizer::create();
// And here's how to get its name:
String name = model->name();
@endcode
@@ -192,7 +192,7 @@ public:
// Create a new Fisherfaces model and retain all available Fisherfaces,
// this is the most common usage of this specific FaceRecognizer:
//
- Ptr<FaceRecognizer> model = createFisherFaceRecognizer();
+ Ptr<FaceRecognizer> model = FisherFaceRecognizer::create();
@endcode
And finally train it on the given dataset (the face images and labels):
@@ -223,7 +223,7 @@ public:
// Create a new LBPH model (it can be updated) and use the default parameters,
// this is the most common usage of this specific FaceRecognizer:
//
- Ptr<FaceRecognizer> model = createLBPHFaceRecognizer();
+ Ptr<FaceRecognizer> model = LBPHFaceRecognizer::create();
// This is the common interface to train all of the available cv::FaceRecognizer
// implementations:
//
@@ -241,7 +241,7 @@ public:
// with the new features extracted from newImages!
@endcode
- Calling update on an Eigenfaces model (see createEigenFaceRecognizer), which doesn't support
+ Calling update on an Eigenfaces model (see EigenFaceRecognizer::create), which doesn't support
updating, will throw an error similar to:
@code
@@ -318,7 +318,7 @@ public:
The suffix const means that prediction does not affect the internal model state, so the method can
be safely called from within different threads.
*/
- CV_WRAP virtual void save(const String& filename) const;
+ CV_WRAP virtual void write(const String& filename) const;
/** @brief Loads a FaceRecognizer and its model state.
@@ -327,16 +327,19 @@ public:
FaceRecognizer::load(FileStorage& fs) in turn gets called by
FaceRecognizer::load(const String& filename), to ease saving a model.
*/
- CV_WRAP virtual void load(const String& filename);
+ CV_WRAP virtual void read(const String& filename);
/** @overload
Saves this model to a given FileStorage.
@param fs The FileStorage to store this FaceRecognizer to.
*/
- virtual void save(FileStorage& fs) const = 0;
+ virtual void write(FileStorage& fs) const = 0;
/** @overload */
- virtual void load(const FileStorage& fs) = 0;
+ virtual void read(const FileNode& fn) = 0;
+
+ /** @overload */
+ virtual bool empty() const = 0;
/** @brief Sets string info for the specified model's label.
diff --git a/contrib/modules/face/include/opencv2/face/bif.hpp b/contrib/modules/face/include/opencv2/face/bif.hpp
index c22c28c..d4f0ec5 100644
--- a/contrib/modules/face/include/opencv2/face/bif.hpp
+++ b/contrib/modules/face/include/opencv2/face/bif.hpp
@@ -68,14 +68,14 @@ public:
*/
CV_WRAP virtual void compute(InputArray image,
OutputArray features) const = 0;
-};
-/**
- * @param num_bands The number of filter bands (<=8) used for computing BIF.
- * @param num_rotations The number of image rotations for computing BIF.
- * @returns Object for computing BIF.
- */
-CV_EXPORTS_W cv::Ptr<BIF> createBIF(int num_bands = 8, int num_rotations = 12);
+ /**
+ * @param num_bands The number of filter bands (<=8) used for computing BIF.
+ * @param num_rotations The number of image rotations for computing BIF.
+ * @returns Object for computing BIF.
+ */
+ CV_WRAP static Ptr<BIF> create(int num_bands = 8, int num_rotations = 12);
+};
} // namespace cv
} // namespace face
diff --git a/contrib/modules/face/include/opencv2/face/facerec.hpp b/contrib/modules/face/include/opencv2/face/facerec.hpp
index 40f62f1..6680c43 100644
--- a/contrib/modules/face/include/opencv2/face/facerec.hpp
+++ b/contrib/modules/face/include/opencv2/face/facerec.hpp
@@ -21,82 +21,107 @@ class CV_EXPORTS_W BasicFaceRecognizer : public FaceRecognizer
{
public:
/** @see setNumComponents */
- CV_WRAP virtual int getNumComponents() const = 0;
+ CV_WRAP int getNumComponents() const;
/** @copybrief getNumComponents @see getNumComponents */
- CV_WRAP virtual void setNumComponents(int val) = 0;
+ CV_WRAP void setNumComponents(int val);
/** @see setThreshold */
- CV_WRAP virtual double getThreshold() const = 0;
+ CV_WRAP double getThreshold() const;
/** @copybrief getThreshold @see getThreshold */
- CV_WRAP virtual void setThreshold(double val) = 0;
- CV_WRAP virtual std::vector<cv::Mat> getProjections() const = 0;
- CV_WRAP virtual cv::Mat getLabels() const = 0;
- CV_WRAP virtual cv::Mat getEigenValues() const = 0;
- CV_WRAP virtual cv::Mat getEigenVectors() const = 0;
- CV_WRAP virtual cv::Mat getMean() const = 0;
+ CV_WRAP void setThreshold(double val);
+ CV_WRAP std::vector<cv::Mat> getProjections() const;
+ CV_WRAP cv::Mat getLabels() const;
+ CV_WRAP cv::Mat getEigenValues() const;
+ CV_WRAP cv::Mat getEigenVectors() const;
+ CV_WRAP cv::Mat getMean() const;
+
+ virtual void read(const FileNode& fn);
+ virtual void write(FileStorage& fs) const;
+ virtual bool empty() const;
+
+ using FaceRecognizer::read;
+ using FaceRecognizer::write;
+
+protected:
+ int _num_components;
+ double _threshold;
+ std::vector<Mat> _projections;
+ Mat _labels;
+ Mat _eigenvectors;
+ Mat _eigenvalues;
+ Mat _mean;
+};
+
+class CV_EXPORTS_W EigenFaceRecognizer : public BasicFaceRecognizer
+{
+public:
+ /**
+ @param num_components The number of components (read: Eigenfaces) kept for this Principal
+ Component Analysis. As a hint: There's no rule how many components (read: Eigenfaces) should be
+ kept for good reconstruction capabilities. It is based on your input data, so experiment with the
+ number. Keeping 80 components should almost always be sufficient.
+ @param threshold The threshold applied in the prediction.
+
+ ### Notes:
+
+ - Training and prediction must be done on grayscale images, use cvtColor to convert between the
+ color spaces.
+ - **THE EIGENFACES METHOD MAKES THE ASSUMPTION, THAT THE TRAINING AND TEST IMAGES ARE OF EQUAL
+ SIZE.** (caps-lock, because I got so many mails asking for this). You have to make sure your
+ input data has the correct shape, else a meaningful exception is thrown. Use resize to resize
+ the images.
+ - This model does not support updating.
+
+ ### Model internal data:
+
+ - num_components see EigenFaceRecognizer::create.
+ - threshold see EigenFaceRecognizer::create.
+ - eigenvalues The eigenvalues for this Principal Component Analysis (ordered descending).
+ - eigenvectors The eigenvectors for this Principal Component Analysis (ordered by their
+ eigenvalue).
+ - mean The sample mean calculated from the training data.
+ - projections The projections of the training data.
+ - labels The threshold applied in the prediction. If the distance to the nearest neighbor is
+ larger than the threshold, this method returns -1.
+ */
+ CV_WRAP static Ptr<EigenFaceRecognizer> create(int num_components = 0, double threshold = DBL_MAX);
+};
+
+class CV_EXPORTS_W FisherFaceRecognizer : public BasicFaceRecognizer
+{
+public:
+ /**
+ @param num_components The number of components (read: Fisherfaces) kept for this Linear
+ Discriminant Analysis with the Fisherfaces criterion. It's useful to keep all components, that
+ means the number of your classes c (read: subjects, persons you want to recognize). If you leave
+ this at the default (0) or set it to a value less-equal 0 or greater (c-1), it will be set to the
+ correct number (c-1) automatically.
+ @param threshold The threshold applied in the prediction. If the distance to the nearest neighbor
+ is larger than the threshold, this method returns -1.
+
+ ### Notes:
+
+ - Training and prediction must be done on grayscale images, use cvtColor to convert between the
+ color spaces.
+ - **THE FISHERFACES METHOD MAKES THE ASSUMPTION, THAT THE TRAINING AND TEST IMAGES ARE OF EQUAL
+ SIZE.** (caps-lock, because I got so many mails asking for this). You have to make sure your
+ input data has the correct shape, else a meaningful exception is thrown. Use resize to resize
+ the images.
+ - This model does not support updating.
+
+ ### Model internal data:
+
+ - num_components see FisherFaceRecognizer::create.
+ - threshold see FisherFaceRecognizer::create.
+ - eigenvalues The eigenvalues for this Linear Discriminant Analysis (ordered descending).
+ - eigenvectors The eigenvectors for this Linear Discriminant Analysis (ordered by their
+ eigenvalue).
+ - mean The sample mean calculated from the training data.
+ - projections The projections of the training data.
+ - labels The labels corresponding to the projections.
+ */
+ CV_WRAP static Ptr<FisherFaceRecognizer> create(int num_components = 0, double threshold = DBL_MAX);
};
-/**
- at param num_components The number of components (read: Eigenfaces) kept for this Principal
-Component Analysis. As a hint: There's no rule how many components (read: Eigenfaces) should be
-kept for good reconstruction capabilities. It is based on your input data, so experiment with the
-number. Keeping 80 components should almost always be sufficient.
- at param threshold The threshold applied in the prediction.
-
-### Notes:
-
-- Training and prediction must be done on grayscale images, use cvtColor to convert between the
- color spaces.
-- **THE EIGENFACES METHOD MAKES THE ASSUMPTION, THAT THE TRAINING AND TEST IMAGES ARE OF EQUAL
- SIZE.** (caps-lock, because I got so many mails asking for this). You have to make sure your
- input data has the correct shape, else a meaningful exception is thrown. Use resize to resize
- the images.
-- This model does not support updating.
-
-### Model internal data:
-
-- num_components see createEigenFaceRecognizer.
-- threshold see createEigenFaceRecognizer.
-- eigenvalues The eigenvalues for this Principal Component Analysis (ordered descending).
-- eigenvectors The eigenvectors for this Principal Component Analysis (ordered by their
- eigenvalue).
-- mean The sample mean calculated from the training data.
-- projections The projections of the training data.
-- labels The threshold applied in the prediction. If the distance to the nearest neighbor is
- larger than the threshold, this method returns -1.
- */
-CV_EXPORTS_W Ptr<BasicFaceRecognizer> createEigenFaceRecognizer(int num_components = 0, double threshold = DBL_MAX);
-
-/**
- at param num_components The number of components (read: Fisherfaces) kept for this Linear
-Discriminant Analysis with the Fisherfaces criterion. It's useful to keep all components, that
-means the number of your classes c (read: subjects, persons you want to recognize). If you leave
-this at the default (0) or set it to a value less-equal 0 or greater (c-1), it will be set to the
-correct number (c-1) automatically.
- at param threshold The threshold applied in the prediction. If the distance to the nearest neighbor
-is larger than the threshold, this method returns -1.
-
-### Notes:
-
-- Training and prediction must be done on grayscale images, use cvtColor to convert between the
- color spaces.
-- **THE FISHERFACES METHOD MAKES THE ASSUMPTION, THAT THE TRAINING AND TEST IMAGES ARE OF EQUAL
- SIZE.** (caps-lock, because I got so many mails asking for this). You have to make sure your
- input data has the correct shape, else a meaningful exception is thrown. Use resize to resize
- the images.
-- This model does not support updating.
-
-### Model internal data:
-
-- num_components see createFisherFaceRecognizer.
-- threshold see createFisherFaceRecognizer.
-- eigenvalues The eigenvalues for this Linear Discriminant Analysis (ordered descending).
-- eigenvectors The eigenvectors for this Linear Discriminant Analysis (ordered by their
- eigenvalue).
-- mean The sample mean calculated from the training data.
-- projections The projections of the training data.
-- labels The labels corresponding to the projections.
- */
-CV_EXPORTS_W Ptr<BasicFaceRecognizer> createFisherFaceRecognizer(int num_components = 0, double threshold = DBL_MAX);
class CV_EXPORTS_W LBPHFaceRecognizer : public FaceRecognizer
{
@@ -123,41 +148,41 @@ public:
CV_WRAP virtual void setThreshold(double val) = 0;
CV_WRAP virtual std::vector<cv::Mat> getHistograms() const = 0;
CV_WRAP virtual cv::Mat getLabels() const = 0;
-};
-/**
- at param radius The radius used for building the Circular Local Binary Pattern. The greater the
-radius, the
- at param neighbors The number of sample points to build a Circular Local Binary Pattern from. An
-appropriate value is to use `8` sample points. Keep in mind: the more sample points you include,
-the higher the computational cost.
- at param grid_x The number of cells in the horizontal direction, 8 is a common value used in
-publications. The more cells, the finer the grid, the higher the dimensionality of the resulting
-feature vector.
- at param grid_y The number of cells in the vertical direction, 8 is a common value used in
-publications. The more cells, the finer the grid, the higher the dimensionality of the resulting
-feature vector.
- at param threshold The threshold applied in the prediction. If the distance to the nearest neighbor
-is larger than the threshold, this method returns -1.
-
-### Notes:
-
-- The Circular Local Binary Patterns (used in training and prediction) expect the data given as
- grayscale images, use cvtColor to convert between the color spaces.
-- This model supports updating.
-
-### Model internal data:
-
-- radius see createLBPHFaceRecognizer.
-- neighbors see createLBPHFaceRecognizer.
-- grid_x see createLBPHFaceRecognizer.
-- grid_y see createLBPHFaceRecognizer.
-- threshold see createLBPHFaceRecognizer.
-- histograms Local Binary Patterns Histograms calculated from the given training data (empty if
- none was given).
-- labels Labels corresponding to the calculated Local Binary Patterns Histograms.
- */
-CV_EXPORTS_W Ptr<LBPHFaceRecognizer> createLBPHFaceRecognizer(int radius=1, int neighbors=8, int grid_x=8, int grid_y=8, double threshold = DBL_MAX);
+ /**
+ @param radius The radius used for building the Circular Local Binary Pattern. The greater the
+ radius, the
+ @param neighbors The number of sample points to build a Circular Local Binary Pattern from. An
+ appropriate value is to use `8` sample points. Keep in mind: the more sample points you include,
+ the higher the computational cost.
+ @param grid_x The number of cells in the horizontal direction, 8 is a common value used in
+ publications. The more cells, the finer the grid, the higher the dimensionality of the resulting
+ feature vector.
+ @param grid_y The number of cells in the vertical direction, 8 is a common value used in
+ publications. The more cells, the finer the grid, the higher the dimensionality of the resulting
+ feature vector.
+ @param threshold The threshold applied in the prediction. If the distance to the nearest neighbor
+ is larger than the threshold, this method returns -1.
+
+ ### Notes:
+
+ - The Circular Local Binary Patterns (used in training and prediction) expect the data given as
+ grayscale images, use cvtColor to convert between the color spaces.
+ - This model supports updating.
+
+ ### Model internal data:
+
+ - radius see LBPHFaceRecognizer::create.
+ - neighbors see LBPHFaceRecognizer::create.
+ - grid_x see LLBPHFaceRecognizer::create.
+ - grid_y see LBPHFaceRecognizer::create.
+ - threshold see LBPHFaceRecognizer::create.
+ - histograms Local Binary Patterns Histograms calculated from the given training data (empty if
+ none was given).
+ - labels Labels corresponding to the calculated Local Binary Patterns Histograms.
+ */
+ CV_WRAP static Ptr<LBPHFaceRecognizer> create(int radius=1, int neighbors=8, int grid_x=8, int grid_y=8, double threshold = DBL_MAX);
+};
//! @}
diff --git a/contrib/modules/face/samples/facerec_demo.cpp b/contrib/modules/face/samples/facerec_demo.cpp
index 26ad177..a155255 100644
--- a/contrib/modules/face/samples/facerec_demo.cpp
+++ b/contrib/modules/face/samples/facerec_demo.cpp
@@ -121,14 +121,14 @@ int main(int argc, const char *argv[]) {
// 10 principal components (read Eigenfaces), then call
// the factory method like this:
//
- // cv::createEigenFaceRecognizer(10);
+ // EigenFaceRecognizer::create(10);
//
// If you want to create a FaceRecognizer with a
// confidennce threshold, call it with:
//
- // cv::createEigenFaceRecognizer(10, 123.0);
+ // EigenFaceRecognizer::create(10, 123.0);
//
- Ptr<BasicFaceRecognizer> model = createEigenFaceRecognizer();
+ Ptr<EigenFaceRecognizer> model = EigenFaceRecognizer::create();
for( int i = 0; i < nlabels; i++ )
model->setLabelInfo(i, labelsInfo[i]);
model->train(images, labels);
diff --git a/contrib/modules/face/samples/facerec_eigenfaces.cpp b/contrib/modules/face/samples/facerec_eigenfaces.cpp
index 0c41fda..487c507 100755
--- a/contrib/modules/face/samples/facerec_eigenfaces.cpp
+++ b/contrib/modules/face/samples/facerec_eigenfaces.cpp
@@ -115,19 +115,19 @@ int main(int argc, const char *argv[]) {
// 10 principal components (read Eigenfaces), then call
// the factory method like this:
//
- // cv::createEigenFaceRecognizer(10);
+ // EigenFaceRecognizer::create(10);
//
// If you want to create a FaceRecognizer with a
// confidence threshold (e.g. 123.0), call it with:
//
- // cv::createEigenFaceRecognizer(10, 123.0);
+ // EigenFaceRecognizer::create(10, 123.0);
//
// If you want to use _all_ Eigenfaces and have a threshold,
// then call the method like this:
//
- // cv::createEigenFaceRecognizer(0, 123.0);
+ // EigenFaceRecognizer::create(0, 123.0);
//
- Ptr<BasicFaceRecognizer> model = createEigenFaceRecognizer();
+ Ptr<EigenFaceRecognizer> model = EigenFaceRecognizer::create();
model->train(images, labels);
// The following line predicts the label of a given
// test image:
diff --git a/contrib/modules/face/samples/facerec_fisherfaces.cpp b/contrib/modules/face/samples/facerec_fisherfaces.cpp
index d679ffc..0aff91c 100755
--- a/contrib/modules/face/samples/facerec_fisherfaces.cpp
+++ b/contrib/modules/face/samples/facerec_fisherfaces.cpp
@@ -114,7 +114,7 @@ int main(int argc, const char *argv[]) {
// If you just want to keep 10 Fisherfaces, then call
// the factory method like this:
//
- // cv::createFisherFaceRecognizer(10);
+ // FisherFaceRecognizer::create(10);
//
// However it is not useful to discard Fisherfaces! Please
// always try to use _all_ available Fisherfaces for
@@ -124,9 +124,9 @@ int main(int argc, const char *argv[]) {
// confidence threshold (e.g. 123.0) and use _all_
// Fisherfaces, then call it with:
//
- // cv::createFisherFaceRecognizer(0, 123.0);
+ // FisherFaceRecognizer::create(0, 123.0);
//
- Ptr<BasicFaceRecognizer> model = createFisherFaceRecognizer();
+ Ptr<FisherFaceRecognizer> model = FisherFaceRecognizer::create();
model->train(images, labels);
// The following line predicts the label of a given
// test image:
diff --git a/contrib/modules/face/samples/facerec_lbph.cpp b/contrib/modules/face/samples/facerec_lbph.cpp
index abfed0d..ca648eb 100755
--- a/contrib/modules/face/samples/facerec_lbph.cpp
+++ b/contrib/modules/face/samples/facerec_lbph.cpp
@@ -97,13 +97,13 @@ int main(int argc, const char *argv[]) {
// So if you want a LBPH FaceRecognizer using a radius of
// 2 and 16 neighbors, call the factory method with:
//
- // cv::createLBPHFaceRecognizer(2, 16);
+ // cv::face::LBPHFaceRecognizer::create(2, 16);
//
// And if you want a threshold (e.g. 123.0) call it with its default values:
//
- // cv::createLBPHFaceRecognizer(1,8,8,8,123.0)
+ // cv::face::LBPHFaceRecognizer::create(1,8,8,8,123.0)
//
- Ptr<LBPHFaceRecognizer> model = createLBPHFaceRecognizer();
+ Ptr<LBPHFaceRecognizer> model = LBPHFaceRecognizer::create();
model->train(images, labels);
// The following line predicts the label of a given
// test image:
diff --git a/contrib/modules/face/samples/facerec_save_load.cpp b/contrib/modules/face/samples/facerec_save_load.cpp
index 8488f54..4f42f18 100755
--- a/contrib/modules/face/samples/facerec_save_load.cpp
+++ b/contrib/modules/face/samples/facerec_save_load.cpp
@@ -115,19 +115,19 @@ int main(int argc, const char *argv[]) {
// 10 principal components (read Eigenfaces), then call
// the factory method like this:
//
- // cv::createEigenFaceRecognizer(10);
+ // cv::face::EigenFaceRecognizer::create(10);
//
// If you want to create a FaceRecognizer with a
// confidence threshold (e.g. 123.0), call it with:
//
- // cv::createEigenFaceRecognizer(10, 123.0);
+ // cv::face::EigenFaceRecognizer::create(10, 123.0);
//
// If you want to use _all_ Eigenfaces and have a threshold,
// then call the method like this:
//
- // cv::createEigenFaceRecognizer(0, 123.0);
+ // cv::face::EigenFaceRecognizer::create(0, 123.0);
//
- Ptr<BasicFaceRecognizer> model0 = createEigenFaceRecognizer();
+ Ptr<EigenFaceRecognizer> model0 = EigenFaceRecognizer::create();
model0->train(images, labels);
// save the model to eigenfaces_at.yaml
model0->save("eigenfaces_at.yml");
@@ -135,8 +135,7 @@ int main(int argc, const char *argv[]) {
//
// Now create a new Eigenfaces Recognizer
//
- Ptr<BasicFaceRecognizer> model1 = createEigenFaceRecognizer();
- model1->load("eigenfaces_at.yml");
+ Ptr<EigenFaceRecognizer> model1 = Algorithm::load<EigenFaceRecognizer>("eigenfaces_at.yml");
// The following line predicts the label of a given
// test image:
int predictedLabel = model1->predict(testSample);
diff --git a/contrib/modules/face/samples/facerec_video.cpp b/contrib/modules/face/samples/facerec_video.cpp
index 0154fb6..0db826e 100755
--- a/contrib/modules/face/samples/facerec_video.cpp
+++ b/contrib/modules/face/samples/facerec_video.cpp
@@ -79,7 +79,7 @@ int main(int argc, const char *argv[]) {
int im_width = images[0].cols;
int im_height = images[0].rows;
// Create a FaceRecognizer and train it on the given images:
- Ptr<BasicFaceRecognizer> model = createFisherFaceRecognizer();
+ Ptr<FisherFaceRecognizer> model = FisherFaceRecognizer::create();
model->train(images, labels);
// That's it for learning the Face Recognition model. You now
// need to create the classifier for the task of Face Detection.
diff --git a/contrib/modules/face/src/bif.cpp b/contrib/modules/face/src/bif.cpp
index 090ceae..d35786d 100644
--- a/contrib/modules/face/src/bif.cpp
+++ b/contrib/modules/face/src/bif.cpp
@@ -216,6 +216,6 @@ void BIFImpl::computeUnit(int unit_idx, const cv::Mat &img,
} // namespace
-cv::Ptr<cv::face::BIF> cv::face::createBIF(int num_bands, int num_rotations) {
+cv::Ptr<cv::face::BIF> cv::face::BIF::create(int num_bands, int num_rotations) {
return cv::Ptr<cv::face::BIF>(new BIFImpl(num_bands, num_rotations));
}
diff --git a/contrib/modules/face/src/eigen_faces.cpp b/contrib/modules/face/src/eigen_faces.cpp
index 9ea5d82..2d832b4 100644
--- a/contrib/modules/face/src/eigen_faces.cpp
+++ b/contrib/modules/face/src/eigen_faces.cpp
@@ -16,7 +16,8 @@
* See <http://www.opensource.org/licenses/bsd-license>
*/
#include "precomp.hpp"
-#include "face_basic.hpp"
+#include <opencv2/face.hpp>
+#include "face_utils.hpp"
#include <set>
#include <limits>
#include <iostream>
@@ -28,14 +29,17 @@ namespace face
// Turk, M., and Pentland, A. "Eigenfaces for recognition.". Journal of
// Cognitive Neuroscience 3 (1991), 71–86.
-class Eigenfaces : public BasicFaceRecognizerImpl
+class Eigenfaces : public EigenFaceRecognizer
{
public:
// Initializes an empty Eigenfaces model.
Eigenfaces(int num_components = 0, double threshold = DBL_MAX)
- : BasicFaceRecognizerImpl(num_components, threshold)
- {}
+ //: BasicFaceRecognizerImpl(num_components, threshold)
+ {
+ _num_components = num_components;
+ _threshold = threshold;
+ }
// Computes an Eigenfaces model with images in src and corresponding labels
// in labels.
@@ -122,7 +126,7 @@ void Eigenfaces::predict(InputArray _src, Ptr<PredictCollector> collector) const
}
}
-Ptr<BasicFaceRecognizer> createEigenFaceRecognizer(int num_components, double threshold)
+Ptr<EigenFaceRecognizer> EigenFaceRecognizer::create(int num_components, double threshold)
{
return makePtr<Eigenfaces>(num_components, threshold);
}
diff --git a/contrib/modules/face/src/face_basic.cpp b/contrib/modules/face/src/face_basic.cpp
new file mode 100644
index 0000000..b0d38d0
--- /dev/null
+++ b/contrib/modules/face/src/face_basic.cpp
@@ -0,0 +1,97 @@
+#include "opencv2/face.hpp"
+#include "face_utils.hpp"
+#include "precomp.hpp"
+
+using namespace cv;
+using namespace face;
+
+int BasicFaceRecognizer::getNumComponents() const
+{
+ return _num_components;
+}
+
+void BasicFaceRecognizer::setNumComponents(int val)
+{
+ _num_components = val;
+}
+
+double BasicFaceRecognizer::getThreshold() const
+{
+ return _threshold;
+}
+
+void BasicFaceRecognizer::setThreshold(double val)
+{
+ _threshold = val;
+}
+
+std::vector<cv::Mat> BasicFaceRecognizer::getProjections() const
+{
+ return _projections;
+}
+
+cv::Mat BasicFaceRecognizer::getLabels() const
+{
+ return _labels;
+}
+
+cv::Mat BasicFaceRecognizer::getEigenValues() const
+{
+ return _eigenvalues;
+}
+
+cv::Mat BasicFaceRecognizer::getEigenVectors() const
+{
+ return _eigenvectors;
+}
+
+cv::Mat BasicFaceRecognizer::getMean() const
+{
+ return _mean;
+}
+
+void BasicFaceRecognizer::read(const FileNode& fs)
+{
+ //read matrices
+ fs["threshold"] >> _threshold;
+ fs["num_components"] >> _num_components;
+ fs["mean"] >> _mean;
+ fs["eigenvalues"] >> _eigenvalues;
+ fs["eigenvectors"] >> _eigenvectors;
+ // read sequences
+ readFileNodeList(fs["projections"], _projections);
+ fs["labels"] >> _labels;
+ const FileNode& fn = fs["labelsInfo"];
+ if (fn.type() == FileNode::SEQ)
+ {
+ _labelsInfo.clear();
+ for (FileNodeIterator it = fn.begin(); it != fn.end();)
+ {
+ LabelInfo item;
+ it >> item;
+ _labelsInfo.insert(std::make_pair(item.label, item.value));
+ }
+ }
+}
+
+void BasicFaceRecognizer::write(FileStorage& fs) const
+{
+ // write matrices
+ fs << "threshold" << _threshold;
+ fs << "num_components" << _num_components;
+ fs << "mean" << _mean;
+ fs << "eigenvalues" << _eigenvalues;
+ fs << "eigenvectors" << _eigenvectors;
+ // write sequences
+ writeFileNodeList(fs, "projections", _projections);
+ fs << "labels" << _labels;
+ fs << "labelsInfo" << "[";
+ for (std::map<int, String>::const_iterator it = _labelsInfo.begin(); it != _labelsInfo.end(); it++)
+ fs << LabelInfo(it->first, it->second);
+ fs << "]";
+}
+
+bool BasicFaceRecognizer::empty() const
+{
+ return (_labels.empty());
+}
diff --git a/contrib/modules/face/src/face_basic.hpp b/contrib/modules/face/src/face_basic.hpp
deleted file mode 100644
index ce9be82..0000000
--- a/contrib/modules/face/src/face_basic.hpp
+++ /dev/null
@@ -1,175 +0,0 @@
-#ifndef __OPENCV_FACE_BASIC_HPP
-#define __OPENCV_FACE_BASIC_HPP
-
-#include "opencv2/face.hpp"
-#include "precomp.hpp"
-
-#include <set>
-#include <limits>
-#include <iostream>
-
-using namespace cv;
-
-// Reads a sequence from a FileNode::SEQ with type _Tp into a result vector.
-template<typename _Tp>
-inline void readFileNodeList(const FileNode& fn, std::vector<_Tp>& result) {
- if (fn.type() == FileNode::SEQ) {
- for (FileNodeIterator it = fn.begin(); it != fn.end();) {
- _Tp item;
- it >> item;
- result.push_back(item);
- }
- }
-}
-
-// Writes the a list of given items to a cv::FileStorage.
-template<typename _Tp>
-inline void writeFileNodeList(FileStorage& fs, const String& name,
- const std::vector<_Tp>& items) {
- // typedefs
- typedef typename std::vector<_Tp>::const_iterator constVecIterator;
- // write the elements in item to fs
- fs << name << "[";
- for (constVecIterator it = items.begin(); it != items.end(); ++it) {
- fs << *it;
- }
- fs << "]";
-}
-
-inline Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double beta=0) {
- // make sure the input data is a vector of matrices or vector of vector
- if(src.kind() != _InputArray::STD_VECTOR_MAT && src.kind() != _InputArray::STD_VECTOR_VECTOR) {
- String error_message = "The data is expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >).";
- CV_Error(Error::StsBadArg, error_message);
- }
- // number of samples
- size_t n = src.total();
- // return empty matrix if no matrices given
- if(n == 0)
- return Mat();
- // dimensionality of (reshaped) samples
- size_t d = src.getMat(0).total();
- // create data matrix
- Mat data((int)n, (int)d, rtype);
- // now copy data
- for(unsigned int i = 0; i < n; i++) {
- // make sure data can be reshaped, throw exception if not!
- if(src.getMat(i).total() != d) {
- String error_message = format("Wrong number of elements in matrix #%d! Expected %d was %d.", i, d, src.getMat(i).total());
- CV_Error(Error::StsBadArg, error_message);
- }
- // get a hold of the current row
- Mat xi = data.row(i);
- // make reshape happy by cloning for non-continuous matrices
- if(src.getMat(i).isContinuous()) {
- src.getMat(i).reshape(1, 1).convertTo(xi, rtype, alpha, beta);
- } else {
- src.getMat(i).clone().reshape(1, 1).convertTo(xi, rtype, alpha, beta);
- }
- }
- return data;
-}
-
-// Utility structure to load/save face label info (a pair of int and string) via FileStorage
-struct LabelInfo
-{
- LabelInfo():label(-1), value("") {}
- LabelInfo(int _label, const String &_value): label(_label), value(_value) {}
- int label;
- String value;
- void write(cv::FileStorage& fs) const
- {
- fs << "{" << "label" << label << "value" << value << "}";
- }
- void read(const cv::FileNode& node)
- {
- label = (int)node["label"];
- value = (String)node["value"];
- }
- std::ostream& operator<<(std::ostream& out)
- {
- out << "{ label = " << label << ", " << "value = " << value.c_str() << "}";
- return out;
- }
-};
-
-inline void write(cv::FileStorage& fs, const String&, const LabelInfo& x)
-{
- x.write(fs);
-}
-
-inline void read(const cv::FileNode& node, LabelInfo& x, const LabelInfo& default_value = LabelInfo())
-{
- if(node.empty())
- x = default_value;
- else
- x.read(node);
-}
-
-
-class BasicFaceRecognizerImpl : public cv::face::BasicFaceRecognizer
-{
-public:
- BasicFaceRecognizerImpl(int num_components = 0, double threshold = DBL_MAX)
- : _num_components(num_components), _threshold(threshold)
- {}
-
- void load(const FileStorage& fs)
- {
- //read matrices
- fs["num_components"] >> _num_components;
- fs["mean"] >> _mean;
- fs["eigenvalues"] >> _eigenvalues;
- fs["eigenvectors"] >> _eigenvectors;
- // read sequences
- readFileNodeList(fs["projections"], _projections);
- fs["labels"] >> _labels;
- const FileNode& fn = fs["labelsInfo"];
- if (fn.type() == FileNode::SEQ)
- {
- _labelsInfo.clear();
- for (FileNodeIterator it = fn.begin(); it != fn.end();)
- {
- LabelInfo item;
- it >> item;
- _labelsInfo.insert(std::make_pair(item.label, item.value));
- }
- }
- }
-
- void save(FileStorage& fs) const
- {
- // write matrices
- fs << "num_components" << _num_components;
- fs << "mean" << _mean;
- fs << "eigenvalues" << _eigenvalues;
- fs << "eigenvectors" << _eigenvectors;
- // write sequences
- writeFileNodeList(fs, "projections", _projections);
- fs << "labels" << _labels;
- fs << "labelsInfo" << "[";
- for (std::map<int, String>::const_iterator it = _labelsInfo.begin(); it != _labelsInfo.end(); it++)
- fs << LabelInfo(it->first, it->second);
- fs << "]";
- }
-
- CV_IMPL_PROPERTY(int, NumComponents, _num_components)
- CV_IMPL_PROPERTY(double, Threshold, _threshold)
- CV_IMPL_PROPERTY_RO(std::vector<cv::Mat>, Projections, _projections)
- CV_IMPL_PROPERTY_RO(cv::Mat, Labels, _labels)
- CV_IMPL_PROPERTY_RO(cv::Mat, EigenValues, _eigenvalues)
- CV_IMPL_PROPERTY_RO(cv::Mat, EigenVectors, _eigenvectors)
- CV_IMPL_PROPERTY_RO(cv::Mat, Mean, _mean)
-
-protected:
- int _num_components;
- double _threshold;
- std::vector<Mat> _projections;
- Mat _labels;
- Mat _eigenvectors;
- Mat _eigenvalues;
- Mat _mean;
-};
-
-#endif // __OPENCV_FACE_BASIC_HPP
-
diff --git a/contrib/modules/face/src/face_utils.hpp b/contrib/modules/face/src/face_utils.hpp
new file mode 100644
index 0000000..35f8594
--- /dev/null
+++ b/contrib/modules/face/src/face_utils.hpp
@@ -0,0 +1,108 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#ifndef __OPENCV_FACE_UTILS_HPP
+#define __OPENCV_FACE_UTILS_HPP
+
+#include "precomp.hpp"
+
+using namespace cv;
+
+inline Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double beta=0) {
+ // make sure the input data is a vector of matrices or vector of vector
+ if(src.kind() != _InputArray::STD_VECTOR_MAT && src.kind() != _InputArray::STD_VECTOR_VECTOR) {
+ String error_message = "The data is expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >).";
+ CV_Error(Error::StsBadArg, error_message);
+ }
+ // number of samples
+ size_t n = src.total();
+ // return empty matrix if no matrices given
+ if(n == 0)
+ return Mat();
+ // dimensionality of (reshaped) samples
+ size_t d = src.getMat(0).total();
+ // create data matrix
+ Mat data((int)n, (int)d, rtype);
+ // now copy data
+ for(unsigned int i = 0; i < n; i++) {
+ // make sure data can be reshaped, throw exception if not!
+ if(src.getMat(i).total() != d) {
+ String error_message = format("Wrong number of elements in matrix #%d! Expected %d was %d.", i, d, src.getMat(i).total());
+ CV_Error(Error::StsBadArg, error_message);
+ }
+ // get a hold of the current row
+ Mat xi = data.row(i);
+ // make reshape happy by cloning for non-continuous matrices
+ if(src.getMat(i).isContinuous()) {
+ src.getMat(i).reshape(1, 1).convertTo(xi, rtype, alpha, beta);
+ } else {
+ src.getMat(i).clone().reshape(1, 1).convertTo(xi, rtype, alpha, beta);
+ }
+ }
+ return data;
+}
+
+// Reads a sequence from a FileNode::SEQ with type _Tp into a result vector.
+template<typename _Tp>
+inline void readFileNodeList(const FileNode& fn, std::vector<_Tp>& result) {
+ if (fn.type() == FileNode::SEQ) {
+ for (FileNodeIterator it = fn.begin(); it != fn.end();) {
+ _Tp item;
+ it >> item;
+ result.push_back(item);
+ }
+ }
+}
+
+// Writes the a list of given items to a cv::FileStorage.
+template<typename _Tp>
+inline void writeFileNodeList(FileStorage& fs, const String& name,
+ const std::vector<_Tp>& items) {
+ // typedefs
+ typedef typename std::vector<_Tp>::const_iterator constVecIterator;
+ // write the elements in item to fs
+ fs << name << "[";
+ for (constVecIterator it = items.begin(); it != items.end(); ++it) {
+ fs << *it;
+ }
+ fs << "]";
+}
+
+// Utility structure to load/save face label info (a pair of int and string) via FileStorage
+struct LabelInfo
+{
+ LabelInfo():label(-1), value("") {}
+ LabelInfo(int _label, const String &_value): label(_label), value(_value) {}
+ int label;
+ String value;
+ void write(cv::FileStorage& fs) const
+ {
+ fs << "{" << "label" << label << "value" << value << "}";
+ }
+ void read(const cv::FileNode& node)
+ {
+ label = (int)node["label"];
+ value = (String)node["value"];
+ }
+ std::ostream& operator<<(std::ostream& out)
+ {
+ out << "{ label = " << label << ", " << "value = " << value.c_str() << "}";
+ return out;
+ }
+};
+
+inline void write(cv::FileStorage& fs, const String&, const LabelInfo& x)
+{
+ x.write(fs);
+}
+
+inline void read(const cv::FileNode& node, LabelInfo& x, const LabelInfo& default_value = LabelInfo())
+{
+ if(node.empty())
+ x = default_value;
+ else
+ x.read(node);
+}
+
+#endif
diff --git a/contrib/modules/face/src/facerec.cpp b/contrib/modules/face/src/facerec.cpp
index 1b1d639..cb4bd65 100644
--- a/contrib/modules/face/src/facerec.cpp
+++ b/contrib/modules/face/src/facerec.cpp
@@ -54,21 +54,21 @@ void FaceRecognizer::update(InputArrayOfArrays src, InputArray labels)
CV_Error(Error::StsNotImplemented, error_msg);
}
-void FaceRecognizer::load(const String &filename)
+void FaceRecognizer::read(const String &filename)
{
FileStorage fs(filename, FileStorage::READ);
if (!fs.isOpened())
CV_Error(Error::StsError, "File can't be opened for reading!");
- this->load(fs);
+ this->read(fs.root());
fs.release();
}
-void FaceRecognizer::save(const String &filename) const
+void FaceRecognizer::write(const String &filename) const
{
FileStorage fs(filename, FileStorage::WRITE);
if (!fs.isOpened())
CV_Error(Error::StsError, "File can't be opened for writing!");
- this->save(fs);
+ this->write(fs);
fs.release();
}
diff --git a/contrib/modules/face/src/fisher_faces.cpp b/contrib/modules/face/src/fisher_faces.cpp
index a43fa43..fe635c6 100644
--- a/contrib/modules/face/src/fisher_faces.cpp
+++ b/contrib/modules/face/src/fisher_faces.cpp
@@ -16,7 +16,8 @@
* See <http://www.opensource.org/licenses/bsd-license>
*/
#include "precomp.hpp"
-#include "face_basic.hpp"
+#include <opencv2/face.hpp>
+#include "face_utils.hpp"
namespace cv { namespace face {
@@ -24,13 +25,16 @@ namespace cv { namespace face {
// faces: Recognition using class specific linear projection.". IEEE
// Transactions on Pattern Analysis and Machine Intelligence 19, 7 (1997),
// 711–720.
-class Fisherfaces: public BasicFaceRecognizerImpl
+class Fisherfaces: public FisherFaceRecognizer
{
public:
// Initializes an empty Fisherfaces model.
Fisherfaces(int num_components = 0, double threshold = DBL_MAX)
- : BasicFaceRecognizerImpl(num_components, threshold)
- { }
+ //: BasicFaceRecognizer(num_components, threshold)
+ {
+ _num_components = num_components;
+ _threshold = threshold;
+ }
// Computes a Fisherfaces model with images in src and corresponding labels
// in labels.
@@ -142,7 +146,7 @@ void Fisherfaces::predict(InputArray _src, Ptr<PredictCollector> collector) cons
}
}
-Ptr<BasicFaceRecognizer> createFisherFaceRecognizer(int num_components, double threshold)
+Ptr<FisherFaceRecognizer> FisherFaceRecognizer::create(int num_components, double threshold)
{
return makePtr<Fisherfaces>(num_components, threshold);
}
diff --git a/contrib/modules/face/src/lbph_faces.cpp b/contrib/modules/face/src/lbph_faces.cpp
index f73f060..11e129c 100644
--- a/contrib/modules/face/src/lbph_faces.cpp
+++ b/contrib/modules/face/src/lbph_faces.cpp
@@ -17,7 +17,7 @@
*/
#include "precomp.hpp"
#include "opencv2/face.hpp"
-#include "face_basic.hpp"
+#include "face_utils.hpp"
namespace cv { namespace face {
@@ -46,8 +46,8 @@ private:
public:
- using FaceRecognizer::save;
- using FaceRecognizer::load;
+ using FaceRecognizer::read;
+ using FaceRecognizer::write;
// Initializes this LBPH Model. The current implementation is rather fixed
// as it uses the Extended Local Binary Patterns per default.
@@ -94,11 +94,15 @@ public:
// Send all predict results to caller side for custom result handling
void predict(InputArray src, Ptr<PredictCollector> collector) const;
- // See FaceRecognizer::load.
- void load(const FileStorage& fs);
+ // See FaceRecognizer::write.
+ void read(const FileNode& fn);
// See FaceRecognizer::save.
- void save(FileStorage& fs) const;
+ void write(FileStorage& fs) const;
+
+ bool empty() const {
+ return (_labels.empty());
+ }
CV_IMPL_PROPERTY(int, GridX, _grid_x)
CV_IMPL_PROPERTY(int, GridY, _grid_y)
@@ -110,7 +114,8 @@ public:
};
-void LBPH::load(const FileStorage& fs) {
+void LBPH::read(const FileNode& fs) {
+ fs["threshold"] >> _threshold;
fs["radius"] >> _radius;
fs["neighbors"] >> _neighbors;
fs["grid_x"] >> _grid_x;
@@ -132,7 +137,8 @@ void LBPH::load(const FileStorage& fs) {
}
// See FaceRecognizer::save.
-void LBPH::save(FileStorage& fs) const {
+void LBPH::write(FileStorage& fs) const {
+ fs << "threshold" << _threshold;
fs << "radius" << _radius;
fs << "neighbors" << _neighbors;
fs << "grid_x" << _grid_x;
@@ -407,11 +413,10 @@ void LBPH::predict(InputArray _src, Ptr<PredictCollector> collector) const {
}
}
-Ptr<LBPHFaceRecognizer> createLBPHFaceRecognizer(int radius, int neighbors,
+Ptr<LBPHFaceRecognizer> LBPHFaceRecognizer::create(int radius, int neighbors,
int grid_x, int grid_y, double threshold)
{
return makePtr<LBPH>(radius, neighbors, grid_x, grid_y, threshold);
}
-
}}
diff --git a/contrib/modules/face/src/precomp.hpp b/contrib/modules/face/src/precomp.hpp
index cde365d..01215ce 100644
--- a/contrib/modules/face/src/precomp.hpp
+++ b/contrib/modules/face/src/precomp.hpp
@@ -49,10 +49,8 @@
#include "opencv2/core/private.hpp"
#include "opencv2/core/persistence.hpp"
#include <map>
-#include <iostream>
#include <set>
#include <limits>
-#include <iostream>
#endif
diff --git a/contrib/modules/face/test/test_bif.cpp b/contrib/modules/face/test/test_bif.cpp
index 521d2ce..6228b55 100644
--- a/contrib/modules/face/test/test_bif.cpp
+++ b/contrib/modules/face/test/test_bif.cpp
@@ -40,27 +40,27 @@ the use of this software, even if advised of the possibility of such damage.
TEST(CV_Face_BIF, can_create_default) {
cv::Ptr<cv::face::BIF> bif;
- EXPECT_NO_THROW(bif = cv::face::createBIF());
+ EXPECT_NO_THROW(bif = cv::face::BIF::create());
EXPECT_FALSE(bif.empty());
}
TEST(CV_Face_BIF, fails_when_zero_bands) {
- EXPECT_ANY_THROW(cv::face::createBIF(0));
+ EXPECT_ANY_THROW(cv::face::BIF::create(0));
}
TEST(CV_Face_BIF, fails_when_too_many_bands) {
- EXPECT_ANY_THROW(cv::face::createBIF(9));
+ EXPECT_ANY_THROW(cv::face::BIF::create(9));
}
TEST(CV_Face_BIF, fails_when_zero_rotations) {
- EXPECT_ANY_THROW(cv::face::createBIF(8, 0));
+ EXPECT_ANY_THROW(cv::face::BIF::create(8, 0));
}
TEST(CV_Face_BIF, can_compute) {
cv::Mat image(60, 60, CV_32F);
cv::theRNG().fill(image, cv::RNG::UNIFORM, -1, 1);
- cv::Ptr<cv::face::BIF> bif = cv::face::createBIF();
+ cv::Ptr<cv::face::BIF> bif = cv::face::BIF::create();
cv::Mat fea;
EXPECT_NO_THROW(bif->compute(image, fea));
EXPECT_EQ(cv::Size(1, 13188), fea.size());
diff --git a/contrib/modules/face/tutorials/face_tutorial.markdown b/contrib/modules/face/tutorials/face_tutorial.markdown
index 0cae7ab..c1d0817 100644
--- a/contrib/modules/face/tutorials/face_tutorial.markdown
+++ b/contrib/modules/face/tutorials/face_tutorial.markdown
@@ -23,9 +23,9 @@ publications, because a lot of people asked for.
The currently available algorithms are:
-- Eigenfaces (see createEigenFaceRecognizer)
-- Fisherfaces (see createFisherFaceRecognizer)
-- Local Binary Patterns Histograms (see createLBPHFaceRecognizer)
+- Eigenfaces (see EigenFaceRecognizer::create)
+- Fisherfaces (see FisherFaceRecognizer::create)
+- Local Binary Patterns Histograms (see LBPHFaceRecognizer::create)
You don't need to copy and paste the source code examples from this page, because they are available
in the src folder coming with this documentation. If you have built OpenCV with the samples turned
diff --git a/contrib/modules/freetype/CMakeLists.txt b/contrib/modules/freetype/CMakeLists.txt
index 47e2f01..f188dc3 100644
--- a/contrib/modules/freetype/CMakeLists.txt
+++ b/contrib/modules/freetype/CMakeLists.txt
@@ -1,4 +1,7 @@
set(the_description "FreeType module. It enables to draw strings with outlines and mono-bitmaps/gray-bitmaps.")
+if(APPLE_FRAMEWORK)
+ ocv_module_disable(freetype)
+endif()
if(PKG_CONFIG_FOUND)
pkg_search_module(FREETYPE freetype2)
@@ -19,7 +22,8 @@ endif()
if( FREETYPE_FOUND AND HARFBUZZ_FOUND )
- ocv_define_module(freetype opencv_core opencv_imgproc PRIVATE_REQUIRED ${freetype2_LIBRARIES} ${harfbuzz_LIBRARIES} WRAP python)
+ ocv_define_module(freetype opencv_core opencv_imgproc WRAP python)
+ ocv_target_link_libraries(${the_module} ${FREETYPE_LIBRARIES} ${HARFBUZZ_LIBRARIES})
ocv_include_directories( ${FREETYPE_INCLUDE_DIRS} ${HARFBUZZ_INCLUDE_DIRS} )
else()
ocv_module_disable(freetype)
diff --git a/contrib/modules/freetype/include/opencv2/freetype.hpp b/contrib/modules/freetype/include/opencv2/freetype.hpp
index c0920e4..6e41ec7 100644
--- a/contrib/modules/freetype/include/opencv2/freetype.hpp
+++ b/contrib/modules/freetype/include/opencv2/freetype.hpp
@@ -115,7 +115,67 @@ The function putText renders the specified text string in the image. Symbols tha
int thickness, int line_type, bool bottomLeftOrigin
) = 0;
+/** @brief Calculates the width and height of a text string.
+
+The function getTextSize calculates and returns the approximate size of a box that contains the specified text.
+That is, the following code renders some text, the tight box surrounding it, and the baseline: :
+ at code
+ String text = "Funny text inside the box";
+ int fontHeight = 60;
+ int thickness = -1;
+ int linestyle = 8;
+
+ Mat img(600, 800, CV_8UC3, Scalar::all(0));
+
+ int baseline=0;
+
+ cv::Ptr<cv::freetype::FreeType2> ft2;
+ ft2 = cv::freetype::createFreeType2();
+ ft2->loadFontData( "./mplus-1p-regular.ttf", 0 );
+
+ Size textSize = ft2->getTextSize(text,
+ fontHeight,
+ thickness,
+ &baseline);
+
+ if(thickness > 0){
+ baseline += thickness;
+ }
+
+ // center the text
+ Point textOrg((img.cols - textSize.width) / 2,
+ (img.rows + textSize.height) / 2);
+
+ // draw the box
+ rectangle(img, textOrg + Point(0, baseline),
+ textOrg + Point(textSize.width, -textSize.height),
+ Scalar(0,255,0),1,8);
+
+ // ... and the baseline first
+ line(img, textOrg + Point(0, thickness),
+ textOrg + Point(textSize.width, thickness),
+ Scalar(0, 0, 255),1,8);
+
+ // then put the text itself
+ ft2->putText(img, text, textOrg, fontHeight,
+ Scalar::all(255), thickness, linestyle, true );
+ at endcode
+
+ at param text Input text string.
+ at param fontHeight Drawing font size by pixel unit.
+ at param thickness Thickness of lines used to render the text. See putText for details.
+ at param[out] baseLine y-coordinate of the baseline relative to the bottom-most text
+point.
+ at return The size of a box that contains the specified text.
+
+ at see cv::putText
+ */
+CV_WRAP virtual Size getTextSize(const String& text,
+ int fontHeight, int thickness,
+ CV_OUT int* baseLine) = 0;
+
};
+
/** @brief Create FreeType2 Instance
The function createFreeType2 create instance to draw UTF-8 strings.
@@ -123,7 +183,7 @@ The function createFreeType2 create instance to draw UTF-8 strings.
*/
CV_EXPORTS_W Ptr<FreeType2> createFreeType2();
-//! @]
+//! @}
} } // namespace freetype
#endif
diff --git a/contrib/modules/freetype/src/freetype.cpp b/contrib/modules/freetype/src/freetype.cpp
index 6444d6f..c129761 100644
--- a/contrib/modules/freetype/src/freetype.cpp
+++ b/contrib/modules/freetype/src/freetype.cpp
@@ -50,6 +50,8 @@
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_OUTLINE_H
+#include FT_IMAGE_H
+#include FT_BBOX_H
#include <hb.h>
#include <hb-ft.h>
@@ -71,25 +73,36 @@ public:
int fontHeight, Scalar color,
int thickness, int line_type, bool bottomLeftOrigin
);
+ Size getTextSize(
+ const String& text, int fontHeight, int thickness,
+ CV_OUT int* baseLine
+ );
private:
FT_Library mLibrary;
FT_Face mFace;
FT_Outline_Funcs mFn;
- Point mOrg;
- int mLine_type;
- int mThickness;
- int mHeight;
- Scalar mColor;
bool mIsFaceAvailable;
- String mText;
int mCtoL;
hb_font_t *mHb_font;
- void putTextBitmapMono ( InputOutputArray _img);
- void putTextBitmapBlend( InputOutputArray _img);
- void putTextOutline ( InputOutputArray _img);
+ void putTextBitmapMono(
+ InputOutputArray img, const String& text, Point org,
+ int fontHeight, Scalar color,
+ int thickness, int line_type, bool bottomLeftOrigin
+ );
+ void putTextBitmapBlend(
+ InputOutputArray img, const String& text, Point org,
+ int fontHeight, Scalar color,
+ int thickness, int line_type, bool bottomLeftOrigin
+ );
+ void putTextOutline(
+ InputOutputArray img, const String& text, Point org,
+ int fontHeight, Scalar color,
+ int thickness, int line_type, bool bottomLeftOrigin
+ );
+
static int mvFn( const FT_Vector *to, void * user);
static int lnFn( const FT_Vector *to, void * user);
@@ -172,7 +185,7 @@ void FreeType2Impl::setSplitNumber(int num ){
void FreeType2Impl::putText(
InputOutputArray _img, const String& _text, Point _org,
int _fontHeight, Scalar _color,
- int _thickness, int _line_type, bool bottomLeftOrigin
+ int _thickness, int _line_type, bool _bottomLeftOrigin
)
{
CV_Assert( mIsFaceAvailable == true );
@@ -184,11 +197,16 @@ void FreeType2Impl::putText(
CV_Assert( ( _line_type == CV_AA) ||
( _line_type == 4 ) ||
( _line_type == 8 ) );
+ CV_Assert( _fontHeight >= 0 );
if ( _text.empty() )
{
return;
}
+ if ( _fontHeight == 0 )
+ {
+ return;
+ }
if( _line_type == CV_AA && _img.depth() != CV_8U ){
_line_type = 8;
@@ -196,48 +214,48 @@ void FreeType2Impl::putText(
CV_Assert(!FT_Set_Pixel_Sizes( mFace, _fontHeight, _fontHeight ));
- mThickness = _thickness;
- mLine_type = _line_type;
- mColor = _color;
- mHeight = _fontHeight;
- mText = _text;
- mOrg = _org;
-
- if( !bottomLeftOrigin ) {
- mOrg.y += mHeight;
- }
-
- if( mThickness < 0 ) // CV_FILLED
+ if( _thickness < 0 ) // CV_FILLED
{
- if ( mLine_type == CV_AA ) {
- putTextBitmapBlend(_img);
+ if ( _line_type == CV_AA ) {
+ putTextBitmapBlend( _img, _text, _org, _fontHeight, _color,
+ _thickness, _line_type, _bottomLeftOrigin );
}else{
- putTextBitmapMono (_img);
+ putTextBitmapMono( _img, _text, _org, _fontHeight, _color,
+ _thickness, _line_type, _bottomLeftOrigin );
}
}else{
- putTextOutline(_img);
+ putTextOutline( _img, _text, _org, _fontHeight, _color,
+ _thickness, _line_type, _bottomLeftOrigin );
}
}
-void FreeType2Impl::putTextOutline(InputOutputArray _img)
+void FreeType2Impl::putTextOutline(
+ InputOutputArray _img, const String& _text, Point _org,
+ int _fontHeight, Scalar _color,
+ int _thickness, int _line_type, bool _bottomLeftOrigin )
{
hb_buffer_t *hb_buffer = hb_buffer_create ();
CV_Assert( hb_buffer != NULL );
unsigned int textLen;
hb_buffer_guess_segment_properties (hb_buffer);
- hb_buffer_add_utf8 (hb_buffer, mText.c_str(), -1, 0, -1);
+ hb_buffer_add_utf8 (hb_buffer, _text.c_str(), -1, 0, -1);
+
hb_glyph_info_t *info =
hb_buffer_get_glyph_infos(hb_buffer,&textLen );
CV_Assert( info != NULL );
+
hb_shape (mHb_font, hb_buffer, NULL, 0);
- mOrg.y -= mHeight;
+ if( _bottomLeftOrigin == true ){
+ _org.y -= _fontHeight;
+ }
+
PathUserData *userData = new PathUserData( _img );
- userData->mColor = mColor;
+ userData->mColor = _color;
userData->mCtoL = mCtoL;
- userData->mThickness = mThickness;
- userData->mLine_type = mLine_type;
+ userData->mThickness = _thickness;
+ userData->mLine_type = _line_type;
for( unsigned int i = 0 ; i < textLen ; i ++ ){
CV_Assert(!FT_Load_Glyph(mFace, info[i].codepoint, 0 ));
@@ -255,8 +273,8 @@ void FreeType2Impl::putTextOutline(InputOutputArray _img)
cOutlineOffset );
// Move
FT_Outline_Translate(&outline,
- (FT_Pos)(mOrg.x << 6),
- (FT_Pos)((mOrg.y + mHeight) << 6) );
+ (FT_Pos)(_org.x << 6),
+ (FT_Pos)( (_org.y + _fontHeight) << 6) );
// Draw
CV_Assert( !FT_Outline_Decompose(&outline, &mFn, (void*)userData) );
@@ -264,33 +282,45 @@ void FreeType2Impl::putTextOutline(InputOutputArray _img)
// Draw (Last Path)
mvFn( NULL, (void*)userData );
- mOrg.x += ( mFace->glyph->advance.x ) >> 6;
- mOrg.y += ( mFace->glyph->advance.y ) >> 6;
+ _org.x += ( mFace->glyph->advance.x ) >> 6;
+ _org.y += ( mFace->glyph->advance.y ) >> 6;
}
delete userData;
hb_buffer_destroy (hb_buffer);
}
-void FreeType2Impl::putTextBitmapMono(InputOutputArray _img)
+void FreeType2Impl::putTextBitmapMono(
+ InputOutputArray _img, const String& _text, Point _org,
+ int _fontHeight, Scalar _color,
+ int _thickness, int _line_type, bool _bottomLeftOrigin )
{
+ CV_Assert( _thickness < 0 );
+ CV_Assert( _line_type == 4 || _line_type == 8);
+
Mat dst = _img.getMat();
hb_buffer_t *hb_buffer = hb_buffer_create ();
CV_Assert( hb_buffer != NULL );
unsigned int textLen;
hb_buffer_guess_segment_properties (hb_buffer);
- hb_buffer_add_utf8 (hb_buffer, mText.c_str(), -1, 0, -1);
+ hb_buffer_add_utf8 (hb_buffer, _text.c_str(), -1, 0, -1);
hb_glyph_info_t *info =
hb_buffer_get_glyph_infos(hb_buffer,&textLen );
CV_Assert( info != NULL );
+
hb_shape (mHb_font, hb_buffer, NULL, 0);
+ _org.y += _fontHeight;
+ if( _bottomLeftOrigin == true ){
+ _org.y -= _fontHeight;
+ }
+
for( unsigned int i = 0 ; i < textLen ; i ++ ){
CV_Assert( !FT_Load_Glyph(mFace, info[i].codepoint, 0 ) );
CV_Assert( !FT_Render_Glyph( mFace->glyph, FT_RENDER_MODE_MONO ) );
FT_Bitmap *bmp = &(mFace->glyph->bitmap);
- Point gPos = mOrg;
+ Point gPos = _org;
gPos.y -= ( mFace->glyph->metrics.horiBearingY >> 6) ;
gPos.x += ( mFace->glyph->metrics.horiBearingX >> 6) ;
@@ -319,41 +349,52 @@ void FreeType2Impl::putTextBitmapMono(InputOutputArray _img)
if ( ( (cl >> bit) & 0x01 ) == 1 ) {
cv::Vec3b* ptr = dst.ptr<cv::Vec3b>( gPos.y + row, gPos.x + col * 8 + (7 - bit) );
- (*ptr)[0] = mColor[0];
- (*ptr)[1] = mColor[1];
- (*ptr)[2] = mColor[2];
+ (*ptr)[0] = _color[0];
+ (*ptr)[1] = _color[1];
+ (*ptr)[2] = _color[2];
}
}
}
}
- mOrg.x += ( mFace->glyph->advance.x ) >> 6;
- mOrg.y += ( mFace->glyph->advance.y ) >> 6;
+ _org.x += ( mFace->glyph->advance.x ) >> 6;
+ _org.y += ( mFace->glyph->advance.y ) >> 6;
}
hb_buffer_destroy (hb_buffer);
}
-void FreeType2Impl::putTextBitmapBlend(InputOutputArray _img)
+void FreeType2Impl::putTextBitmapBlend(
+ InputOutputArray _img, const String& _text, Point _org,
+ int _fontHeight, Scalar _color,
+ int _thickness, int _line_type, bool _bottomLeftOrigin )
{
+ CV_Assert( _thickness < 0 );
+ CV_Assert( _line_type == 16 );
+
Mat dst = _img.getMat();
hb_buffer_t *hb_buffer = hb_buffer_create ();
CV_Assert( hb_buffer != NULL );
unsigned int textLen;
hb_buffer_guess_segment_properties (hb_buffer);
- hb_buffer_add_utf8 (hb_buffer, mText.c_str(), -1, 0, -1);
+ hb_buffer_add_utf8 (hb_buffer, _text.c_str(), -1, 0, -1);
hb_glyph_info_t *info =
hb_buffer_get_glyph_infos(hb_buffer,&textLen );
CV_Assert( info != NULL );
hb_shape (mHb_font, hb_buffer, NULL, 0);
+ _org.y += _fontHeight;
+ if( _bottomLeftOrigin == true ){
+ _org.y -= _fontHeight;
+ }
+
for( unsigned int i = 0 ; i < textLen ; i ++ ){
CV_Assert( !FT_Load_Glyph(mFace, info[i].codepoint, 0 ) );
CV_Assert( !FT_Render_Glyph( mFace->glyph, FT_RENDER_MODE_NORMAL ) );
FT_Bitmap *bmp = &(mFace->glyph->bitmap);
- Point gPos = mOrg;
+ Point gPos = _org;
gPos.y -= ( mFace->glyph->metrics.horiBearingY >> 6) ;
gPos.x += ( mFace->glyph->metrics.horiBearingX >> 6) ;
@@ -382,15 +423,119 @@ void FreeType2Impl::putTextBitmapBlend(InputOutputArray _img)
cv::Vec3b* ptr = dst.ptr<cv::Vec3b>( gPos.y + row , gPos.x + col);
double blendAlpha = (double ) cl / 255.0;
- (*ptr)[0] = (double) mColor[0] * blendAlpha + (*ptr)[0] * (1.0 - blendAlpha );
- (*ptr)[1] = (double) mColor[1] * blendAlpha + (*ptr)[1] * (1.0 - blendAlpha );
- (*ptr)[2] = (double) mColor[2] * blendAlpha + (*ptr)[2] * (1.0 - blendAlpha );
+ (*ptr)[0] = (double) _color[0] * blendAlpha + (*ptr)[0] * (1.0 - blendAlpha );
+ (*ptr)[1] = (double) _color[1] * blendAlpha + (*ptr)[1] * (1.0 - blendAlpha );
+ (*ptr)[2] = (double) _color[2] * blendAlpha + (*ptr)[2] * (1.0 - blendAlpha );
}
}
- mOrg.x += ( mFace->glyph->advance.x ) >> 6;
- mOrg.y += ( mFace->glyph->advance.y ) >> 6;
+ _org.x += ( mFace->glyph->advance.x ) >> 6;
+ _org.y += ( mFace->glyph->advance.y ) >> 6;
+ }
+ hb_buffer_destroy (hb_buffer);
+}
+
+Size FreeType2Impl::getTextSize(
+ const String& _text,
+ int _fontHeight,
+ int _thickness,
+ CV_OUT int* _baseLine)
+{
+ if ( _text.empty() )
+ {
+ return Size(0,0);
+ }
+
+ CV_Assert( _fontHeight >= 0 ) ;
+ if ( _fontHeight == 0 )
+ {
+ return Size(0,0);
+ }
+
+ CV_Assert(!FT_Set_Pixel_Sizes( mFace, _fontHeight, _fontHeight ));
+
+ hb_buffer_t *hb_buffer = hb_buffer_create ();
+ CV_Assert( hb_buffer != NULL );
+ Point _org(0,0);
+
+ unsigned int textLen;
+ hb_buffer_guess_segment_properties (hb_buffer);
+ hb_buffer_add_utf8 (hb_buffer, _text.c_str(), -1, 0, -1);
+ hb_glyph_info_t *info =
+ hb_buffer_get_glyph_infos(hb_buffer,&textLen );
+ CV_Assert( info != NULL );
+ hb_shape (mHb_font, hb_buffer, NULL, 0);
+
+ _org.y -= _fontHeight;
+ int xMin = INT_MAX, xMax = INT_MIN;
+ int yMin = INT_MAX, yMax = INT_MIN;
+
+ for( unsigned int i = 0 ; i < textLen ; i ++ ){
+ CV_Assert(!FT_Load_Glyph(mFace, info[i].codepoint, 0 ));
+
+ FT_GlyphSlot slot = mFace->glyph;
+ FT_Outline outline = slot->outline;
+ FT_BBox bbox ;
+
+ // Flip
+ FT_Matrix mtx = { 1 << 16 , 0 , 0 , -(1 << 16) };
+ FT_Outline_Transform(&outline, &mtx);
+
+ // Move
+ FT_Outline_Translate(&outline,
+ cOutlineOffset,
+ cOutlineOffset );
+
+ // Move
+ FT_Outline_Translate(&outline,
+ (FT_Pos)(_org.x << 6 ),
+ (FT_Pos)((_org.y + _fontHeight) << 6 ) );
+
+ CV_Assert( !FT_Outline_Get_BBox( &outline, &bbox ) );
+
+ // If codepoint is space(0x20), it has no glyph.
+ // A dummy boundary box is needed when last code is space.
+ if(
+ (bbox.xMin == 0 ) && (bbox.xMax == 0 ) &&
+ (bbox.yMin == 0 ) && (bbox.yMax == 0 )
+ ){
+ bbox.xMin = (_org.x << 6);
+ bbox.xMax = (_org.x << 6 ) + ( mFace->glyph->advance.x );
+ bbox.yMin = yMin;
+ bbox.yMax = yMax;
+
+ bbox.xMin += cOutlineOffset;
+ bbox.xMax += cOutlineOffset;
+ bbox.yMin += cOutlineOffset;
+ bbox.yMax += cOutlineOffset;
+ }
+
+ xMin = cv::min ( xMin, ftd(bbox.xMin) );
+ xMax = cv::max ( xMax, ftd(bbox.xMax) );
+ yMin = cv::min ( yMin, ftd(bbox.yMin) );
+ yMax = cv::max ( yMax, ftd(bbox.yMax) );
+
+ _org.x += ( mFace->glyph->advance.x ) >> 6;
+ _org.y += ( mFace->glyph->advance.y ) >> 6;
}
+
hb_buffer_destroy (hb_buffer);
+
+ int width = xMax - xMin ;
+ int height = -yMin ;
+
+ if ( _thickness > 0 ) {
+ width = cvRound(width + _thickness * 2);
+ height = cvRound(height + _thickness * 1);
+ }else{
+ width = cvRound(width + 1);
+ height = cvRound(height + 1);
+ }
+
+ if ( _baseLine ) {
+ *_baseLine = yMax;
+ }
+
+ return Size( width, height );
}
int FreeType2Impl::mvFn( const FT_Vector *to, void * user)
diff --git a/contrib/modules/fuzzy/doc/fuzzy.bib b/contrib/modules/fuzzy/doc/fuzzy.bib
index cc3cc67..064d340 100644
--- a/contrib/modules/fuzzy/doc/fuzzy.bib
+++ b/contrib/modules/fuzzy/doc/fuzzy.bib
@@ -10,13 +10,69 @@
}
@article{Perf:rec,
- title={Image Reconstruction by means of F-transform},
+ title={Image Reconstruction by means of {F}-transform},
author={Perfilieva, Irina and Vla{\v{s}}{\'a}nek, Pavel},
journal={Knowledge-Based Systems},
- keywords = {myown},
volume={70},
pages={55--63},
year={2014},
doi = {10.1016/j.knosys.2014.04.007},
publisher={Elsevier}
}
+
+ at article{Vlas:FT,
+ title={The F-transform in Terms of Image Processing Tools},
+ author={Vla{\v{s}}{\'a}nek, Pavel and Perfilieva, Irina},
+ journal={Journal of Fuzzy Set Valued Analysis},
+ volume={2016},
+ number={1},
+ pages={54--62},
+ year={2016}
+}
+
+ at article{MSLP:cod-decod,
+ title={An image coding/decoding method based on direct and inverse fuzzy transforms},
+ author={Di Martino, Ferdinando and Loia, Vincenzo and Perfilieva, Irina and Sessa, Salvatore},
+ journal={International Journal of Approximate Reasoning},
+ volume={48},
+ number={1},
+ pages={110--131},
+ year={2008},
+ publisher={Elsevier}
+}
+
+ at article{Fusion:AFS12,
+ title={Advanced F-transform-based image fusion},
+ author={Vajgl, Marek and Perfilieva, Irina and Hod'{\'a}kov{\'a}, Petra},
+ journal={Advances in Fuzzy Systems},
+ volume={2012},
+ pages={4},
+ year={2012},
+ publisher={Hindawi Publishing Corp.}
+}
+
+ at incollection{IPMU2012,
+ title={$F^1$-transform edge detector inspired by canny’s algorithm},
+ author={Perfilieva, Irina and Hod'{\'a}kov{\'a}, Petra and Hurtík, Petr},
+ booktitle={Advances on Computational Intelligence},
+ pages={230--239},
+ year={2012},
+ publisher={Springer}
+}
+
+ at article{perfilieva2014differentiation,
+ title={Differentiation by the {F}-transform and application to edge detection},
+ author={Perfilieva, Irina and Hod{\'a}kov{\'a}, Petra and Hurt{\'\i}k, Petr},
+ journal={Fuzzy Sets and Systems},
+ year={2014},
+ publisher={Elsevier}
+}
+
+ at inproceedings{vlavsanek2015patch,
+ title={Patch based inpainting method based on the F1-transform},
+ author={Vla{\v{s}}{\'a}nek, Pavel and Perfilieva, Irina},
+ booktitle={Soft Computing and Pattern Recognition (SoCPaR), 2015 7th International Conference of},
+ pages={235--240},
+ year={2015},
+ organization={IEEE}
+}
\ No newline at end of file
diff --git a/contrib/modules/fuzzy/include/opencv2/fuzzy.hpp b/contrib/modules/fuzzy/include/opencv2/fuzzy.hpp
index 8a532c0..d660cc3 100644
--- a/contrib/modules/fuzzy/include/opencv2/fuzzy.hpp
+++ b/contrib/modules/fuzzy/include/opencv2/fuzzy.hpp
@@ -44,21 +44,26 @@
#include "opencv2/fuzzy/types.hpp"
#include "opencv2/fuzzy/fuzzy_F0_math.hpp"
+#include "opencv2/fuzzy/fuzzy_F1_math.hpp"
#include "opencv2/fuzzy/fuzzy_image.hpp"
/**
@defgroup fuzzy Image processing based on fuzzy mathematics
-Namespace for all functions is **ft**. The module brings implementation of the last image processing algorithms based on fuzzy mathematics.
+Namespace for all functions is `ft`. The module brings implementation of the last image processing algorithms based on fuzzy mathematics. Method are named based on the pattern `FT`_degree_dimension`_`method.
@{
- @defgroup f0_math Math with F0-transfrom support
+ @defgroup f0_math Math with F0-transform support
-Fuzzy transform (F-transform) of the 0th degree transform whole image to a vector of its components. These components are used in latter computation.
+Fuzzy transform (\f$F^0\f$-transform) of the 0th degree transforms whole image to a matrix of its components. These components are used in latter computation where each of them represents average color of certain subarea.
+
+ @defgroup f1_math Math with F1-transform support
+
+Fuzzy transform (\f$F^1\f$-transform) of the 1th degree transforms whole image to a matrix of its components. Each component is polynomial of the 1th degree carrying information about average color and average gradient of certain subarea.
@defgroup f_image Fuzzy image processing
-Image proceesing based on F-transform is fast to process and easy to understand.
+Image proceesing based on fuzzy mathematics namely F-transform.
@}
*/
diff --git a/contrib/modules/fuzzy/include/opencv2/fuzzy/fuzzy_F0_math.hpp b/contrib/modules/fuzzy/include/opencv2/fuzzy/fuzzy_F0_math.hpp
index 5b24157..7beeb9b 100644
--- a/contrib/modules/fuzzy/include/opencv2/fuzzy/fuzzy_F0_math.hpp
+++ b/contrib/modules/fuzzy/include/opencv2/fuzzy/fuzzy_F0_math.hpp
@@ -53,74 +53,67 @@ namespace ft
//! @addtogroup f0_math
//! @{
- /** @brief Computes components of the array using direct F0-transform.
+ /** @brief Computes components of the array using direct \f$F^0\f$-transform.
@param matrix Input array.
- @param kernel Kernel used for processing. Function **createKernel** can be used.
- @param components Output 32-bit array for the components.
+ @param kernel Kernel used for processing. Function `ft::createKernel` can be used.
+ @param components Output 32-bit float array for the components.
@param mask Mask can be used for unwanted area marking.
The function computes components using predefined kernel and mask.
-
- @note
- F-transform technique is described in paper @cite Perf:FT.
- */
- CV_EXPORTS_AS(FT02D_components1) void FT02D_components(InputArray matrix, InputArray kernel, OutputArray components, InputArray mask);
-
- /** @brief Computes components of the array using direct F0-transform.
- @param matrix Input array.
- @param kernel Kernel used for processing. Function **createKernel** can be used.
- @param components Output 32-bit array for the components.
-
- The function computes components using predefined kernel.
-
- @note
- F-transform technique is described in paper @cite Perf:FT.
*/
- CV_EXPORTS_W void FT02D_components(InputArray matrix, InputArray kernel, OutputArray components);
+ CV_EXPORTS_W void FT02D_components(InputArray matrix, InputArray kernel, OutputArray components, InputArray mask = noArray());
- /** @brief Computes inverse F0-transfrom.
- @param components Input 32-bit single channel array for the components.
- @param kernel Kernel used for processing. Function **createKernel** can be used.
- @param output Output 32-bit array.
+ /** @brief Computes inverse \f$F^0\f$-transfrom.
+ @param components Input 32-bit float single channel array for the components.
+ @param kernel Kernel used for processing. Function `ft::createKernel` can be used.
+ @param output Output 32-bit float array.
@param width Width of the output array.
@param height Height of the output array.
- @note
- F-transform technique is described in paper @cite Perf:FT.
+ Computation of inverse F-transform.
*/
CV_EXPORTS_W void FT02D_inverseFT(InputArray components, InputArray kernel, OutputArray output, int width, int height);
- /** @brief Computes F0-transfrom and inverse F0-transfrom at once.
+ /** @brief Computes \f$F^0\f$-transfrom and inverse \f$F^0\f$-transfrom at once.
@param matrix Input matrix.
- @param kernel Kernel used for processing. Function **createKernel** can be used.
- @param output Output 32-bit array.
+ @param kernel Kernel used for processing. Function `ft::createKernel` can be used.
+ @param output Output 32-bit float array.
@param mask Mask used for unwanted area marking.
- This function computes F-transfrom and inverse F-transfotm in one step. It is fully sufficient and optimized for **Mat**.
- */
- CV_EXPORTS_AS(FT02D_process1) void FT02D_process(InputArray matrix, InputArray kernel, OutputArray output, InputArray mask);
-
- /** @brief Computes F0-transfrom and inverse F0-transfrom at once.
- @param matrix Input matrix.
- @param kernel Kernel used for processing. Function **createKernel** can be used.
- @param output Output 32-bit array.
-
- This function computes F-transfrom and inverse F-transfotm in one step. It is fully sufficient and optimized for **Mat**.
+ This function computes F-transfrom and inverse F-transfotm in one step. It is fully sufficient and optimized for `cv::Mat`.
*/
- CV_EXPORTS_W void FT02D_process(InputArray matrix, InputArray kernel, OutputArray output);
+ CV_EXPORTS_W void FT02D_process(InputArray matrix, InputArray kernel, OutputArray output, InputArray mask = noArray());
- /** @brief Computes F0-transfrom and inverse F0-transfrom at once and return state.
+ /** @brief Computes \f$F^0\f$-transfrom and inverse \f$F^0\f$-transfrom at once and return state.
@param matrix Input matrix.
- @param kernel Kernel used for processing. Function **createKernel** can be used.
- @param output Output 32-bit array.
+ @param kernel Kernel used for processing. Function `ft::createKernel` can be used.
+ @param output Output 32-bit float array.
@param mask Mask used for unwanted area marking.
@param maskOutput Mask after one iteration.
- @param firstStop If **true** function returns -1 when first problem appears. In case of **false**, the process is completed and summation of all problems returned.
+ @param firstStop If **true** function returns -1 when first problem appears. In case of `false` the process is completed and summation of all problems returned.
- This function computes iteration of F-transfrom and inverse F-transfotm and handle image and mask change. The function is used in *inpaint* function.
+ This function computes iteration of F-transfrom and inverse F-transfotm and handle image and mask change. The function is used in `ft::inpaint` function.
*/
CV_EXPORTS_W int FT02D_iteration(InputArray matrix, InputArray kernel, OutputArray output, InputArray mask, OutputArray maskOutput, bool firstStop);
+ /** @brief Sligtly less accurate version of \f$F^0\f$-transfrom computation optimized for higher speed. The methods counts with linear basic function.
+ @param matrix Input 3 channels matrix.
+ @param radius Radius of the `ft::LINEAR` basic function.
+ @param output Output array.
+
+ This function computes F-transfrom and inverse F-transfotm using linear basic function in one step. It is ~10 times faster than `ft::FT02D_process` method.
+ */
+ CV_EXPORTS_W void FT02D_FL_process(InputArray matrix, const int radius, OutputArray output);
+
+ /** @brief Sligtly less accurate version of \f$F^0\f$-transfrom computation optimized for higher speed. The methods counts with linear basic function.
+ @param matrix Input 3 channels matrix.
+ @param radius Radius of the `ft::LINEAR` basic function.
+ @param output Output array.
+
+ This function computes F-transfrom and inverse F-transfotm using linear basic function in one step. It is ~9 times faster then `ft::FT02D_process` method and more accurate than `ft::FT02D_FL_process` method.
+ */
+ CV_EXPORTS_W void FT02D_FL_process_float(InputArray matrix, const int radius, OutputArray output);
+
//! @}
}
}
diff --git a/contrib/modules/fuzzy/include/opencv2/fuzzy/fuzzy_F1_math.hpp b/contrib/modules/fuzzy/include/opencv2/fuzzy/fuzzy_F1_math.hpp
new file mode 100644
index 0000000..3320e67
--- /dev/null
+++ b/contrib/modules/fuzzy/include/opencv2/fuzzy/fuzzy_F1_math.hpp
@@ -0,0 +1,124 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2015, University of Ostrava, Institute for Research and Applications of Fuzzy Modeling,
+// Pavel Vlasanek, all rights reserved. Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#ifndef __OPENCV_FUZZY_F1_MATH_H__
+#define __OPENCV_FUZZY_F1_MATH_H__
+
+#include "opencv2/fuzzy/types.hpp"
+#include "opencv2/core.hpp"
+
+namespace cv
+{
+
+namespace ft
+{
+ //! @addtogroup f1_math
+ //! @{
+
+ /** @brief Computes components of the array using direct \f$F^1\f$-transform.
+ @param matrix Input array.
+ @param kernel Kernel used for processing. Function `ft::createKernel` can be used.
+ @param components Output 32-bit float array for the components.
+
+ The function computes linear components using predefined kernel.
+ */
+ CV_EXPORTS_W void FT12D_components(InputArray matrix, InputArray kernel, OutputArray components);
+
+ /** @brief Computes elements of \f$F^1\f$-transform components.
+ @param matrix Input array.
+ @param kernel Kernel used for processing. Function `ft::createKernel` can be used.
+ @param c00 Elements represent average color.
+ @param c10 Elements represent average vertical gradient.
+ @param c01 Elements represent average horizontal gradient.
+ @param components Output 32-bit float array for the components.
+ @param mask Mask can be used for unwanted area marking.
+
+ The function computes components and its elements using predefined kernel and mask.
+ */
+ CV_EXPORTS_W void FT12D_polynomial(InputArray matrix, InputArray kernel, OutputArray c00, OutputArray c10, OutputArray c01, OutputArray components, InputArray mask = noArray());
+
+ /** @brief Creates vertical matrix for \f$F^1\f$-transform computation.
+ @param radius Radius of the basic function.
+ @param matrix The vertical matrix.
+ @param chn Number of channels.
+
+ The function creates helper vertical matrix for \f$F^1\f$-transfrom processing. It is used for gradient computation.
+ */
+ CV_EXPORTS_W void FT12D_createPolynomMatrixVertical(int radius, OutputArray matrix, const int chn);
+
+ /** @brief Creates horizontal matrix for \f$F^1\f$-transform computation.
+ @param radius Radius of the basic function.
+ @param matrix The horizontal matrix.
+ @param chn Number of channels.
+
+ The function creates helper horizontal matrix for \f$F^1\f$-transfrom processing. It is used for gradient computation.
+ */
+ CV_EXPORTS_W void FT12D_createPolynomMatrixHorizontal(int radius, OutputArray matrix, const int chn);
+
+ /** @brief Computes \f$F^1\f$-transfrom and inverse \f$F^1\f$-transfrom at once.
+ @param matrix Input matrix.
+ @param kernel Kernel used for processing. Function `ft::createKernel` can be used.
+ @param output Output 32-bit float array.
+ @param mask Mask used for unwanted area marking.
+
+ This function computes \f$F^1\f$-transfrom and inverse \f$F^1\f$-transfotm in one step. It is fully sufficient and optimized for `cv::Mat`.
+
+ @note
+ F-transform technique of first degreee is described in paper @cite Vlas:FT.
+ */
+ CV_EXPORTS_W void FT12D_process(InputArray matrix, InputArray kernel, OutputArray output, InputArray mask = noArray());
+
+ /** @brief Computes inverse \f$F^1\f$-transfrom.
+ @param components Input 32-bit float single channel array for the components.
+ @param kernel Kernel used for processing. The same kernel as for components computation must be used.
+ @param output Output 32-bit float array.
+ @param width Width of the output array.
+ @param height Height of the output array.
+
+ Computation of inverse \f$F^1\f$-transform.
+ */
+ CV_EXPORTS_W void FT12D_inverseFT(InputArray components, InputArray kernel, OutputArray output, int width, int height);
+
+ //! @}
+}
+}
+
+#endif // __OPENCV_FUZZY_F1_MATH_H__
diff --git a/contrib/modules/fuzzy/include/opencv2/fuzzy/fuzzy_image.hpp b/contrib/modules/fuzzy/include/opencv2/fuzzy/fuzzy_image.hpp
index e5287a9..9c9eeff 100644
--- a/contrib/modules/fuzzy/include/opencv2/fuzzy/fuzzy_image.hpp
+++ b/contrib/modules/fuzzy/include/opencv2/fuzzy/fuzzy_image.hpp
@@ -56,7 +56,7 @@ namespace ft
/** @brief Creates kernel from basic functions.
@param A Basic function used in axis **x**.
@param B Basic function used in axis **y**.
- @param kernel Final 32-b kernel derived from **A** and **B**.
+ @param kernel Final 32-bit kernel derived from **A** and **B**.
@param chn Number of kernel channels.
The function creates kernel usable for latter fuzzy image processing.
@@ -67,7 +67,7 @@ namespace ft
@param function Function type could be one of the following:
- **LINEAR** Linear basic function.
@param radius Radius of the basic function.
- @param kernel Final 32-b kernel.
+ @param kernel Final 32-bit kernel.
@param chn Number of kernel channels.
The function creates kernel from predefined functions.
@@ -80,11 +80,11 @@ namespace ft
@param output Output 32-bit image.
@param radius Radius of the basic function.
@param function Function type could be one of the following:
- - **LINEAR** Linear basic function.
+ - `ft::LINEAR` Linear basic function.
@param algorithm Algorithm could be one of the following:
- - **ONE_STEP** One step algorithm.
- - **MULTI_STEP** Algorithm automaticaly increasing radius of the basic function.
- - **ITERATIVE** Iterative algorithm running in more steps using partial computations.
+ - `ft::ONE_STEP` One step algorithm.
+ - `ft::MULTI_STEP` This algorithm automaticaly increases radius of the basic function.
+ - `ft::ITERATIVE` Iterative algorithm running in more steps using partial computations.
This function provides inpainting technique based on the fuzzy mathematic.
diff --git a/contrib/modules/fuzzy/include/opencv2/fuzzy/types.hpp b/contrib/modules/fuzzy/include/opencv2/fuzzy/types.hpp
index ec831e6..22e0a01 100644
--- a/contrib/modules/fuzzy/include/opencv2/fuzzy/types.hpp
+++ b/contrib/modules/fuzzy/include/opencv2/fuzzy/types.hpp
@@ -52,15 +52,15 @@ namespace ft
enum
{
- LINEAR = 1,
- SINUS = 2
+ LINEAR = 1, //!< linear (triangular) shape
+ SINUS = 2 //!< sinusoidal shape
};
enum
{
- ONE_STEP = 1,
- MULTI_STEP = 2,
- ITERATIVE = 3
+ ONE_STEP = 1, //!< processing in one step
+ MULTI_STEP = 2, //!< processing in multiple step
+ ITERATIVE = 3 //!< processing in several iterations
};
//! @}
diff --git a/contrib/modules/fuzzy/samples/fuzzy_inpainting.cpp b/contrib/modules/fuzzy/samples/fuzzy_inpainting.cpp
index 1ee4fb3..ec4d1f6 100644
--- a/contrib/modules/fuzzy/samples/fuzzy_inpainting.cpp
+++ b/contrib/modules/fuzzy/samples/fuzzy_inpainting.cpp
@@ -38,9 +38,9 @@ int main(void)
Mat I = imread("input.png");
// Various masks
- Mat mask1 = imread("mask1.png");
- Mat mask2 = imread("mask2.png");
- Mat mask3 = imread("mask3.png");
+ Mat mask1 = imread("mask1.png", IMREAD_GRAYSCALE);
+ Mat mask2 = imread("mask2.png", IMREAD_GRAYSCALE);
+ Mat mask3 = imread("mask3.png", IMREAD_GRAYSCALE);
// Apply the damage
Mat input1, input2, input3;
diff --git a/contrib/modules/fuzzy/src/fuzzy_F0_math.cpp b/contrib/modules/fuzzy/src/fuzzy_F0_math.cpp
index 892bcbe..3842fe8 100644
--- a/contrib/modules/fuzzy/src/fuzzy_F0_math.cpp
+++ b/contrib/modules/fuzzy/src/fuzzy_F0_math.cpp
@@ -43,9 +43,278 @@
using namespace cv;
+void ft::FT02D_FL_process(InputArray matrix, const int radius, OutputArray output)
+{
+ CV_Assert(matrix.channels() == 3);
+
+ int borderPadding = 2 * radius + 1;
+ Mat imagePadded;
+
+ copyMakeBorder(matrix, imagePadded, radius, borderPadding, radius, borderPadding, BORDER_CONSTANT, Scalar(0));
+
+ Mat channel[3];
+ split(imagePadded, channel);
+
+ uchar *im_r = channel[2].data;
+ uchar *im_g = channel[1].data;
+ uchar *im_b = channel[0].data;
+
+ int width = imagePadded.cols;
+ int height = imagePadded.rows;
+ int n_width = width / radius + 1;
+ int n_height = height / radius + 1;
+
+ std::vector<uchar> c_r(n_width * n_height);
+ std::vector<uchar> c_g(n_width * n_height);
+ std::vector<uchar> c_b(n_width * n_height);
+
+ int sum_r, sum_g, sum_b, num, c_wei;
+ int c_pos, pos, pos2, wy;
+ int cy = 0;
+ float num_f;
+
+ std::vector<int> wei(radius + 1);
+
+ for (int i = 0; i <= radius; i++)
+ {
+ wei[i] = radius - i;
+ }
+
+ for (int y = radius; y < height - radius; y += radius)
+ {
+ c_pos = cy;
+
+ for (int x = radius; x < width - radius; x += radius)
+ {
+ num = sum_r = sum_g = sum_b = 0;
+
+ for (int y1 = y - radius; y1 <= y + radius; y1++)
+ {
+ pos = y1 * width;
+ wy = wei[abs(y1 - y)];
+
+ for (int x1 = x - radius; x1 <= x + radius; x1++)
+ {
+ c_wei = wei[abs(x1 - x)] * wy;
+ pos2 = pos + x1;
+ sum_r += im_r[pos2] * c_wei;
+ sum_g += im_g[pos2] * c_wei;
+ sum_b += im_b[pos2] * c_wei;
+ num += c_wei;
+ }
+ }
+
+ num_f = 1.0f / (float)num;
+
+ c_r[c_pos] = (uchar)cvRound(sum_r * num_f);
+ c_g[c_pos] = (uchar)cvRound(sum_g * num_f);
+ c_b[c_pos] = (uchar)cvRound(sum_b * num_f);
+
+ c_pos++;
+ }
+
+ cy += n_width;
+ }
+
+ int p1, p2, p3, p4, yw, w1, w2, w3, w4, lx, ly, lx1, ly1, pos_iFT;
+ float num_iFT;
+
+ int output_height = matrix.rows();
+ int output_width = matrix.cols();
+
+ uchar *img_r = new uchar[output_height * output_width];
+ uchar *img_g = new uchar[output_height * output_width];
+ uchar *img_b = new uchar[output_height * output_width];
+
+ for (int y = 0; y < output_height; y++)
+ {
+ ly1 = (y % radius);
+ ly = radius - ly1;
+ yw = y / radius * n_width;
+ pos_iFT = y * output_width;
+
+ for (int x = 0; x < output_width; x++)
+ {
+ lx1 = (x % radius);
+ lx = radius - lx1;
+
+ p1 = x / radius + yw;
+ p2 = p1 + 1;
+ p3 = p1 + n_width;
+ p4 = p3 + 1;
+
+ w1 = lx * ly;
+ w2 = lx1 * ly;
+ w3 = lx * ly1;
+ w4 = lx1 * ly1;
+
+ num_iFT = 1.0f / (float)(w1 + w2 + w3 + w4);
+
+ img_r[pos_iFT] = (uchar)((c_r[p1] * w1 + c_r[p2] * w2 + c_r[p3] * w3 + c_r[p4] * w4) * num_iFT);
+ img_g[pos_iFT] = (uchar)((c_g[p1] * w1 + c_g[p2] * w2 + c_g[p3] * w3 + c_g[p4] * w4) * num_iFT);
+ img_b[pos_iFT] = (uchar)((c_b[p1] * w1 + c_b[p2] * w2 + c_b[p3] * w3 + c_b[p4] * w4) * num_iFT);
+
+ pos_iFT++;
+ }
+ }
+
+ Mat compR(output_height, output_width, CV_8UC1, img_r);
+ Mat compG(output_height, output_width, CV_8UC1, img_g);
+ Mat compB(output_height, output_width, CV_8UC1, img_b);
+
+ std::vector<Mat> oComp;
+
+ oComp.push_back(compB);
+ oComp.push_back(compG);
+ oComp.push_back(compR);
+
+ merge(oComp, output);
+}
+
+void ft::FT02D_FL_process_float(InputArray matrix, const int radius, OutputArray output)
+{
+ CV_Assert(matrix.channels() == 3);
+
+ int borderPadding = 2 * radius + 1;
+ Mat imagePadded;
+
+ copyMakeBorder(matrix, imagePadded, radius, borderPadding, radius, borderPadding, BORDER_CONSTANT, Scalar(0));
+
+ Mat channel[3];
+ split(imagePadded, channel);
+
+ uchar *im_r = channel[2].data;
+ uchar *im_g = channel[1].data;
+ uchar *im_b = channel[0].data;
+
+ int width = imagePadded.cols;
+ int height = imagePadded.rows;
+ int n_width = width / radius + 1;
+ int n_height = height / radius + 1;
+
+ std::vector<float> c_r(n_width * n_height);
+ std::vector<float> c_g(n_width * n_height);
+ std::vector<float> c_b(n_width * n_height);
+
+ int sum_r, sum_g, sum_b, num, c_wei;
+ int c_pos, pos, pos2, wy;
+ int cy = 0;
+ float num_f;
+
+ std::vector<int> wei(radius + 1);
+
+ for (int i = 0; i <= radius; i++)
+ {
+ wei[i] = radius - i;
+ }
+
+ for (int y = radius; y < height - radius; y += radius)
+ {
+ c_pos = cy;
+
+ for (int x = radius; x < width - radius; x += radius)
+ {
+ num = sum_r = sum_g = sum_b = 0;
+
+ for (int y1 = y - radius; y1 <= y + radius; y1++)
+ {
+ pos = y1 * width;
+ wy = wei[abs(y1 - y)];
+
+ for (int x1 = x - radius; x1 <= x + radius; x1++)
+ {
+ c_wei = wei[abs(x1 - x)] * wy;
+ pos2 = pos + x1;
+ sum_r += im_r[pos2] * c_wei;
+ sum_g += im_g[pos2] * c_wei;
+ sum_b += im_b[pos2] * c_wei;
+ num += c_wei;
+ }
+ }
+
+ num_f = 1.0f / (float)num;
+
+ c_r[c_pos] = sum_r * num_f;
+ c_g[c_pos] = sum_g * num_f;
+ c_b[c_pos] = sum_b * num_f;
+
+ c_pos++;
+ }
+
+ cy += n_width;
+ }
+
+ int p1, p2, p3, p4, yw, w1, w2, w3, w4, lx, ly, lx1, ly1, pos_iFT;
+ float num_iFT;
+
+ int output_height = matrix.rows();
+ int output_width = matrix.cols();
+
+ float *img_r = new float[output_height * output_width];
+ float *img_g = new float[output_height * output_width];
+ float *img_b = new float[output_height * output_width];
+
+ for (int y = 0; y < output_height; y++)
+ {
+ ly1 = (y % radius);
+ ly = radius - ly1;
+ yw = y / radius * n_width;
+ pos_iFT = y * output_width;
+
+ for (int x = 0; x < output_width; x++)
+ {
+ lx1 = (x % radius);
+ lx = radius - lx1;
+
+ p1 = x / radius + yw;
+ p2 = p1 + 1;
+ p3 = p1 + n_width;
+ p4 = p3 + 1;
+
+ w1 = lx * ly;
+ w2 = lx1 * ly;
+ w3 = lx * ly1;
+ w4 = lx1 * ly1;
+
+ num_iFT = 1.0f / (float)(w1 + w2 + w3 + w4);
+
+ img_r[pos_iFT] = (c_r[p1] * w1 + c_r[p2] * w2 + c_r[p3] * w3 + c_r[p4] * w4) * num_iFT;
+ img_g[pos_iFT] = (c_g[p1] * w1 + c_g[p2] * w2 + c_g[p3] * w3 + c_g[p4] * w4) * num_iFT;
+ img_b[pos_iFT] = (c_b[p1] * w1 + c_b[p2] * w2 + c_b[p3] * w3 + c_b[p4] * w4) * num_iFT;
+
+ pos_iFT++;
+ }
+ }
+
+ Mat compR(output_height, output_width, CV_32FC1, img_r);
+ Mat compG(output_height, output_width, CV_32FC1, img_g);
+ Mat compB(output_height, output_width, CV_32FC1, img_b);
+
+ std::vector<Mat> oComp;
+
+ oComp.push_back(compB);
+ oComp.push_back(compG);
+ oComp.push_back(compR);
+
+ merge(oComp, output);
+}
+
void ft::FT02D_components(InputArray matrix, InputArray kernel, OutputArray components, InputArray mask)
{
- CV_Assert(matrix.channels() == kernel.channels() && mask.channels() == 1);
+ CV_Assert(matrix.channels() == kernel.channels());
+
+ Mat inputMask;
+
+ if (mask.getMat().empty())
+ {
+ inputMask = Mat::ones(matrix.size(), CV_8U);
+ }
+ else
+ {
+ CV_Assert(mask.channels() == 1);
+
+ inputMask = mask.getMat();
+ }
int radiusX = (kernel.cols() - 1) / 2;
int radiusY = (kernel.rows() - 1) / 2;
@@ -56,7 +325,7 @@ void ft::FT02D_components(InputArray matrix, InputArray kernel, OutputArray comp
Mat maskPadded;
copyMakeBorder(matrix, matrixPadded, radiusY, kernel.rows(), radiusX, kernel.cols(), BORDER_CONSTANT, Scalar(0));
- copyMakeBorder(mask, maskPadded, radiusY, kernel.rows(), radiusX, kernel.cols(), BORDER_CONSTANT, Scalar(0));
+ copyMakeBorder(inputMask, maskPadded, radiusY, kernel.rows(), radiusX, kernel.cols(), BORDER_CONSTANT, Scalar(0));
components.create(Bn, An, CV_MAKETYPE(CV_32F, matrix.channels()));
@@ -87,13 +356,6 @@ void ft::FT02D_components(InputArray matrix, InputArray kernel, OutputArray comp
}
}
-void ft::FT02D_components(InputArray matrix, InputArray kernel, OutputArray components)
-{
- Mat mask = Mat::ones(matrix.size(), CV_8U);
-
- ft::FT02D_components(matrix, kernel, components, mask);
-}
-
void ft::FT02D_inverseFT(InputArray components, InputArray kernel, OutputArray output, int width, int height)
{
CV_Assert(components.channels() == 1 && kernel.channels() == 1);
@@ -130,16 +392,22 @@ void ft::FT02D_inverseFT(InputArray components, InputArray kernel, OutputArray o
outputZeroes(Rect(radiusX, radiusY, width, height)).copyTo(output);
}
-void ft::FT02D_process(InputArray matrix, InputArray kernel, OutputArray output)
+void ft::FT02D_process(InputArray matrix, InputArray kernel, OutputArray output, InputArray mask)
{
- Mat mask = Mat::ones(matrix.size(), CV_8U);
+ CV_Assert(matrix.channels() == kernel.channels());
- ft::FT02D_process(matrix, kernel, output, mask);
-}
+ Mat inputMask;
-void ft::FT02D_process(InputArray matrix, InputArray kernel, OutputArray output, InputArray mask)
-{
- CV_Assert(matrix.channels() == kernel.channels() && mask.channels() == 1);
+ if (mask.getMat().empty())
+ {
+ inputMask = Mat::ones(matrix.size(), CV_8U);
+ }
+ else
+ {
+ CV_Assert(mask.channels() == 1);
+
+ inputMask = mask.getMat();
+ }
int radiusX = (kernel.cols() - 1) / 2;
int radiusY = (kernel.rows() - 1) / 2;
@@ -156,7 +424,7 @@ void ft::FT02D_process(InputArray matrix, InputArray kernel, OutputArray output,
Mat outputZeroes(outputHeightPadded, outputWidthPadded, output.type(), Scalar(0));
copyMakeBorder(matrix, matrixPadded, radiusY, kernel.rows(), radiusX, kernel.cols(), BORDER_CONSTANT, Scalar(0));
- copyMakeBorder(mask, maskPadded, radiusY, kernel.rows(), radiusX, kernel.cols(), BORDER_CONSTANT, Scalar(0));
+ copyMakeBorder(inputMask, maskPadded, radiusY, kernel.rows(), radiusX, kernel.cols(), BORDER_CONSTANT, Scalar(0));
for (int i = 0; i < An; i++)
{
diff --git a/contrib/modules/fuzzy/src/fuzzy_F1_math.cpp b/contrib/modules/fuzzy/src/fuzzy_F1_math.cpp
new file mode 100644
index 0000000..8a5c8f5
--- /dev/null
+++ b/contrib/modules/fuzzy/src/fuzzy_F1_math.cpp
@@ -0,0 +1,305 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2015, University of Ostrava, Institute for Research and Applications of Fuzzy Modeling,
+// Pavel Vlasanek, all rights reserved. Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "precomp.hpp"
+
+using namespace cv;
+
+void ft::FT12D_components(InputArray matrix, InputArray kernel, OutputArray components)
+{
+ Mat c00, c10, c01;
+
+ FT12D_polynomial(matrix, kernel, c00, c10, c01, components);
+}
+
+void ft::FT12D_polynomial(InputArray matrix, InputArray kernel, OutputArray c00, OutputArray c10, OutputArray c01, OutputArray components, InputArray mask)
+{
+ CV_Assert(matrix.channels() == 1 && kernel.channels() == 1);
+
+ Mat inputMask;
+
+ if (mask.getMat().empty())
+ {
+ inputMask = Mat::ones(matrix.size(), CV_8U);
+ }
+ else
+ {
+ CV_Assert(mask.channels() == 1);
+
+ inputMask = mask.getMat();
+ }
+
+ int radiusX = (kernel.cols() - 1) / 2;
+ int radiusY = (kernel.rows() - 1) / 2;
+ int An = matrix.cols() / radiusX + 1;
+ int Bn = matrix.rows() / radiusY + 1;
+
+ Mat matrixPadded, maskPadded;
+ copyMakeBorder(matrix, matrixPadded, radiusY, kernel.rows(), radiusX, kernel.cols(), BORDER_ISOLATED, Scalar(0));
+ copyMakeBorder(inputMask, maskPadded, radiusY, kernel.rows(), radiusX, kernel.cols(), BORDER_ISOLATED, Scalar(0));
+
+ c00.create(Bn, An, CV_32F);
+ c10.create(Bn, An, CV_32F);
+ c01.create(Bn, An, CV_32F);
+ components.create(Bn * kernel.rows(), An * kernel.cols(), CV_32F);
+
+ Mat c00Mat = c00.getMat();
+ Mat c10Mat = c10.getMat();
+ Mat c01Mat = c01.getMat();
+ Mat componentsMat = components.getMat();
+
+ Mat vecX, vecY;
+ FT12D_createPolynomMatrixVertical(radiusX, vecX, 1);
+ FT12D_createPolynomMatrixHorizontal(radiusY, vecY, 1);
+
+ for (int i = 0; i < An; i++)
+ {
+ for (int o = 0; o < Bn; o++)
+ {
+ int centerX = (i * radiusX) + radiusX;
+ int centerY = (o * radiusY) + radiusY;
+ Rect area(centerX - radiusX, centerY - radiusY, kernel.cols(), kernel.rows());
+
+ Mat roiImage(matrixPadded, area);
+ Mat roiMask(maskPadded, area);
+
+ Mat kernelMasked;
+ kernel.copyTo(kernelMasked, roiMask);
+
+ Mat numerator00, numerator10, numerator01;
+ multiply(roiImage, kernelMasked, numerator00, 1, CV_32F);
+ multiply(numerator00, vecX, numerator10, 1, CV_32F);
+ multiply(numerator00, vecY, numerator01, 1, CV_32F);
+
+ Mat denominator00, denominator10, denominator01;
+ denominator00 = kernelMasked;
+ multiply(vecX.mul(vecX), kernelMasked, denominator10, 1, CV_32F);
+ multiply(vecY.mul(vecY), kernelMasked, denominator01, 1, CV_32F);
+
+ Scalar c00sum, c10sum, c01sum;
+ divide(sum(numerator00), sum(denominator00), c00sum, 1, CV_32F);
+ divide(sum(numerator10), sum(denominator10), c10sum, 1, CV_32F);
+ divide(sum(numerator01), sum(denominator01), c01sum, 1, CV_32F);
+
+ c00Mat.row(o).col(i) = c00sum;
+ c10Mat.row(o).col(i) = c10sum;
+ c01Mat.row(o).col(i) = c01sum;
+
+ Mat vecXMasked, vecYMasked;
+ vecX.copyTo(vecXMasked, roiMask);
+ vecY.copyTo(vecYMasked, roiMask);
+
+ Mat updatedC10, updatedC01;
+ multiply(c10sum, vecXMasked, updatedC10, 1, CV_32F);
+ multiply(c01sum, vecYMasked, updatedC01, 1, CV_32F);
+
+ Mat component(componentsMat, Rect(i * kernelMasked.cols, o * kernelMasked.rows, kernelMasked.cols, kernelMasked.rows));
+ add(updatedC01, updatedC10, component);
+ add(component, c00sum, component);
+ }
+ }
+}
+
+void ft::FT12D_createPolynomMatrixVertical(int radius, OutputArray matrix, const int chn)
+{
+ int dimension = radius * 2 + 1;
+
+ std::vector<Mat> channels;
+ Mat oneChannel(dimension, dimension, CV_16SC1, Scalar(0));
+
+ for (int i = 0; i < radius; i++)
+ {
+ oneChannel.col(i) = i - radius;
+ oneChannel.col(dimension - 1 - i) = radius - i;
+ }
+
+ for (int i = 0; i < chn; i++)
+ {
+ channels.push_back(oneChannel);
+ }
+
+ merge(channels, matrix);
+}
+
+void ft::FT12D_createPolynomMatrixHorizontal(int radius, OutputArray matrix, const int chn)
+{
+ int dimension = radius * 2 + 1;
+
+ std::vector<Mat> channels;
+ Mat oneChannel(dimension, dimension, CV_16SC1, Scalar(0));
+
+ for (int i = 0; i < radius; i++)
+ {
+ oneChannel.row(i) = i - radius;
+ oneChannel.row(dimension - 1 - i) = radius - i;
+ }
+
+ for (int i = 0; i < chn; i++)
+ {
+ channels.push_back(oneChannel);
+ }
+
+ merge(channels, matrix);
+}
+
+void ft::FT12D_inverseFT(InputArray components, InputArray kernel, OutputArray output, int width, int height)
+{
+ CV_Assert(components.channels() == 1 && kernel.channels() == 1);
+
+ Mat componentsMat = components.getMat();
+
+ int radiusX = (kernel.cols() - 1) / 2;
+ int radiusY = (kernel.rows() - 1) / 2;
+ int outputWidthPadded = radiusX + width + kernel.cols();
+ int outputHeightPadded = radiusY + height + kernel.rows();
+
+ output.create(height, width, CV_32F);
+
+ Mat outputZeroes(outputHeightPadded, outputWidthPadded, CV_32F, Scalar(0));
+
+ for (int i = 0; i < componentsMat.cols / kernel.cols(); i++)
+ {
+ for (int o = 0; o < componentsMat.rows / kernel.rows(); o++)
+ {
+ int centerX = (i * radiusX) + radiusX;
+ int centerY = (o * radiusY) + radiusY;
+ Rect area(centerX - radiusX, centerY - radiusY, kernel.cols(), kernel.rows());
+
+ Mat component(componentsMat, Rect(i * kernel.cols(), o * kernel.rows(), kernel.cols(), kernel.rows()));
+
+ Mat inverse;
+ multiply(kernel, component, inverse, 1, CV_32F);
+
+ Mat roiOutput(outputZeroes, area);
+ add(roiOutput, inverse, roiOutput);
+ }
+ }
+
+ outputZeroes(Rect(radiusX, radiusY, width, height)).copyTo(output);
+}
+
+void ft::FT12D_process(InputArray matrix, InputArray kernel, OutputArray output, InputArray mask)
+{
+ CV_Assert(matrix.channels() == kernel.channels());
+
+ Mat inputMask;
+
+ if (mask.getMat().empty())
+ {
+ inputMask = Mat::ones(matrix.size(), CV_8U);
+ }
+ else
+ {
+ CV_Assert(mask.channels() == 1);
+
+ inputMask = mask.getMat();
+ }
+
+ Mat matrixPadded;
+ Mat maskPadded;
+
+ int radiusX = (kernel.cols() - 1) / 2;
+ int radiusY = (kernel.rows() - 1) / 2;
+ int An = matrix.cols() / radiusX + 1;
+ int Bn = matrix.rows() / radiusY + 1;
+ int outputWidthPadded = radiusX + matrix.cols() + kernel.cols();
+ int outputHeightPadded = radiusY + matrix.rows() + kernel.rows();
+
+ output.create(matrix.size(), CV_MAKETYPE(CV_32F, matrix.channels()));
+
+ Mat outputZeroes(outputHeightPadded, outputWidthPadded, output.type(), Scalar(0));
+
+ copyMakeBorder(matrix, matrixPadded, radiusY, kernel.rows(), radiusX, kernel.cols(), BORDER_CONSTANT, Scalar(0));
+ copyMakeBorder(inputMask, maskPadded, radiusY, kernel.rows(), radiusX, kernel.cols(), BORDER_CONSTANT, Scalar(0));
+
+ Mat vecX;
+ Mat vecY;
+
+ ft::FT12D_createPolynomMatrixVertical(radiusX, vecX, matrix.channels());
+ ft::FT12D_createPolynomMatrixHorizontal(radiusY, vecY, matrix.channels());
+
+ for (int i = 0; i < An; i++)
+ {
+ for (int o = 0; o < Bn; o++)
+ {
+ int centerX = (i * radiusX) + radiusX;
+ int centerY = (o * radiusY) + radiusY;
+ Rect area(centerX - radiusX, centerY - radiusY, kernel.cols(), kernel.rows());
+
+ Mat roiImage(matrixPadded, area);
+ Mat roiMask(maskPadded, area);
+ Mat kernelMasked;
+
+ kernel.copyTo(kernelMasked, roiMask);
+
+ Mat numerator00, numerator10, numerator01;
+ multiply(roiImage, kernelMasked, numerator00, 1, CV_32F);
+ multiply(numerator00, vecX, numerator10, 1, CV_32F);
+ multiply(numerator00, vecY, numerator01, 1, CV_32F);
+
+ Mat denominator00, denominator10, denominator01;
+ denominator00 = kernelMasked;
+ multiply(vecX.mul(vecX), kernelMasked, denominator10, 1, CV_32F);
+ multiply(vecY.mul(vecY), kernelMasked, denominator01, 1, CV_32F);
+
+ Scalar c00, c10, c01;
+ divide(sum(numerator00), sum(denominator00), c00, 1, CV_32F);
+ divide(sum(numerator10), sum(denominator10), c10, 1, CV_32F);
+ divide(sum(numerator01), sum(denominator01), c01, 1, CV_32F);
+
+ Mat component, updatedC10, updatedC01;
+
+ multiply(c10, vecX, updatedC10, 1, CV_32F);
+ multiply(c01, vecY, updatedC01, 1, CV_32F);
+
+ add(updatedC01, updatedC10, component);
+ add(component, c00, component);
+
+ Mat inverse;
+ multiply(kernel, component, inverse, 1, CV_32F);
+
+ Mat roiOutput(outputZeroes, area);
+ add(roiOutput, inverse, roiOutput);
+ }
+ }
+
+ outputZeroes(Rect(radiusX, radiusY, matrix.cols(), matrix.rows())).copyTo(output);
+}
diff --git a/contrib/modules/fuzzy/src/fuzzy_image.cpp b/contrib/modules/fuzzy/src/fuzzy_image.cpp
index c443a70..3c7d0bc 100644
--- a/contrib/modules/fuzzy/src/fuzzy_image.cpp
+++ b/contrib/modules/fuzzy/src/fuzzy_image.cpp
@@ -47,7 +47,7 @@ void ft::createKernel(InputArray A, InputArray B, OutputArray kernel, const int
{
Mat AMat = A.getMat();
Mat BMat = B.getMat();
- Mat kernelOneChannel = AMat * BMat;
+ Mat kernelOneChannel = BMat * AMat;
std::vector<Mat> channels;
for (int i = 0; i < chn; i++)
diff --git a/contrib/modules/fuzzy/test/test_f0.cpp b/contrib/modules/fuzzy/test/test_f0.cpp
index e9ff61b..c4ab36b 100644
--- a/contrib/modules/fuzzy/test/test_f0.cpp
+++ b/contrib/modules/fuzzy/test/test_f0.cpp
@@ -96,6 +96,54 @@ TEST(fuzzy_f0, components)
TEST(fuzzy_f0, inversion)
{
+ float arDemandedO[16][16] =
+ {
+ { 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
+ { 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
+ { 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
+ { 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
+ { 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
+ { 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
+ { 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
+ { 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
+ { 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
+ { 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
+ { 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
+ { 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
+ { 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
+ { 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
+ { 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 },
+ { 0, 1.25, 2.5, 18.125, 33.75, 57, 80.25, 103.625, 127, 150.375, 173.75, 197.25, 220.75, 236.5, 252.25, 253.625 }
+ };
+ Mat demandedO = Mat(16, 16, CV_32F, arDemandedO);
+
+ float arComp[9][9] =
+ {
+ { 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
+ { 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
+ { 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
+ { 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
+ { 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
+ { 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
+ { 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
+ { 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
+ { 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 }
+ };
+ Mat comp = Mat(9, 9, CV_32F, arComp);
+
+ Mat kernel;
+ ft::createKernel(ft::LINEAR, 2, kernel, 1);
+
+ Mat O;
+ ft::FT02D_inverseFT(comp, kernel, O, 16, 16);
+
+ double n1 = cvtest::norm(demandedO, O, NORM_INF);
+
+ EXPECT_DOUBLE_EQ(n1, 0);
+}
+
+TEST(fuzzy_f0, process)
+{
float arI[16][16] =
{
{ 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
@@ -138,27 +186,49 @@ TEST(fuzzy_f0, inversion)
};
Mat demandedO = Mat(16, 16, CV_32F, arDemandedO);
- float arComp[9][9] =
- {
- { 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
- { 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
- { 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
- { 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
- { 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
- { 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
- { 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
- { 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 },
- { 0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255 }
- };
- Mat comp = Mat(9, 9, CV_32F, arComp);
-
Mat kernel;
ft::createKernel(ft::LINEAR, 2, kernel, 1);
Mat O;
- ft::FT02D_inverseFT(comp, kernel, O, 16, 16);
+ ft::FT02D_process(I, kernel, O);
double n1 = cvtest::norm(demandedO, O, NORM_INF);
EXPECT_DOUBLE_EQ(n1, 0);
+}
+
+TEST(fuzzy_f0, FL_process)
+{
+ string folder = string(cvtest::TS::ptr()->get_data_path()) + "fuzzy/";
+ Mat orig = imread(folder + "orig.png");
+ Mat exp5 = imread(folder + "exp5.png");
+
+ EXPECT_TRUE(!orig.empty() && !exp5.empty());
+
+ Mat res5;
+ ft::FT02D_FL_process(orig, 5, res5);
+
+ res5.convertTo(res5, CV_8UC3);
+
+ double n1 = cvtest::norm(exp5, res5, NORM_INF);
+
+ EXPECT_LE(n1, 1);
+}
+
+TEST(fuzzy_f0, FL_process_float)
+{
+ string folder = string(cvtest::TS::ptr()->get_data_path()) + "fuzzy/";
+ Mat orig = imread(folder + "orig.png");
+ Mat exp6 = imread(folder + "exp6.png");
+
+ EXPECT_TRUE(!orig.empty() && !exp6.empty());
+
+ Mat res6;
+ ft::FT02D_FL_process_float(orig, 5, res6);
+
+ res6.convertTo(res6, CV_8UC3);
+
+ double n1 = cvtest::norm(exp6, res6, NORM_INF);
+
+ EXPECT_LE(n1, 1);
}
\ No newline at end of file
diff --git a/contrib/modules/fuzzy/test/test_f1.cpp b/contrib/modules/fuzzy/test/test_f1.cpp
new file mode 100644
index 0000000..cc85dab
--- /dev/null
+++ b/contrib/modules/fuzzy/test/test_f1.cpp
@@ -0,0 +1,399 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2015, University of Ostrava, Institute for Research and Applications of Fuzzy Modeling,
+// Pavel Vlasanek, all rights reserved. Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "test_precomp.hpp"
+
+#include <string>
+
+using namespace std;
+using namespace cv;
+
+TEST(fuzzy_f1, elements)
+{
+ float arI[16][16] =
+ {
+ {0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
+ {0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
+ {0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
+ {0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
+ {0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
+ {0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
+ {0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
+ {0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
+ {0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
+ {0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
+ {0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
+ {0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
+ {0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
+ {0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
+ {0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255},
+ {0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255}
+ };
+ Mat I = Mat(16, 16, CV_32F, arI);
+
+ float arDemandedC00[9][9] =
+ {
+ {0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255},
+ {0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255},
+ {0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255},
+ {0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255},
+ {0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255},
+ {0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255},
+ {0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255},
+ {0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255},
+ {0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255}
+ };
+ Mat demandedC00 = Mat(9, 9, CV_32F, arDemandedC00);
+
+ float arDemandedC10[9][9] =
+ {
+ {0, 5, 23.5, 23.5, 23, 23.5, 23.5, 5.5, -255},
+ {0, 5, 23.5, 23.5, 23, 23.5, 23.5, 5.5, -255},
+ {0, 5, 23.5, 23.5, 23, 23.5, 23.5, 5.5, -255},
+ {0, 5, 23.5, 23.5, 23, 23.5, 23.5, 5.5, -255},
+ {0, 5, 23.5, 23.5, 23, 23.5, 23.5, 5.5, -255},
+ {0, 5, 23.5, 23.5, 23, 23.5, 23.5, 5.5, -255},
+ {0, 5, 23.5, 23.5, 23, 23.5, 23.5, 5.5, -255},
+ {0, 5, 23.5, 23.5, 23, 23.5, 23.5, 5.5, -255},
+ {0, 5, 23.5, 23.5, 23, 23.5, 23.5, 5.5, -255}
+ };
+ Mat demandedC10 = Mat(9, 9, CV_32F, arDemandedC10);
+
+ float arDemandedC01[9][9] =
+ {
+ {0, 2.5, 33.75, 80.25, 127, 173.75, 220.75, 252.25, 255},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, -2.5, -33.75, -80.25, -127, -173.75, -220.75, -252.25, -255}
+ };
+ Mat demandedC01 = Mat(9, 9, CV_32F, arDemandedC01);
+
+ float arDemandedComp[45][45] =
+ {
+ {0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255},
+ {0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -5, 0, 5, 10, 15, 20.5, 44, 67.5, 91, 114.5, 113.5, 137, 160.5, 184, 207.5, 208, 231, 254, 277, 300, 300.5, 324, 347.5, 371, 394.5, 394.5, 418, 441.5, 465, 488.5, 493.5, 499, 504.5, 510, 252.25, 1020, 765, 255, 255, 255},
+ {0, 0, 0, 0, 0, -2.5, 2.5, 7.5, 12.5, 17.5, 54.25, 77.75, 101.25, 124.75, 148.25, 193.75, 217.25, 240.75, 264.25, 287.75, 335, 358, 381, 404, 427, 474.25, 497.75, 521.25, 544.75, 568.25, 615.25, 638.75, 662.25, 685.75, 709.25, 745.75, 751.25, 756.75, 762.25, 252.25, 1275, 1020, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255},
+ {0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255},
+ {0, 0, 0, 0, 0, -2.5, 2.5, 7.5, 12.5, 17.5, 54.25, 77.75, 101.25, 124.75, 148.25, 193.75, 217.25, 240.75, 264.25, 287.75, 335, 358, 381, 404, 427, 474.25, 497.75, 521.25, 544.75, 568.25, 615.25, 638.75, 662.25, 685.75, 709.25, 745.75, 751.25, 756.75, 762.25, 252.25, 1275, 1020, 255, 255, 255},
+ {0, 0, 0, 0, 0, -5, 0, 5, 10, 15, 20.5, 44, 67.5, 91, 114.5, 113.5, 137, 160.5, 184, 207.5, 208, 231, 254, 277, 300, 300.5, 324, 347.5, 371, 394.5, 394.5, 418, 441.5, 465, 488.5, 493.5, 499, 504.5, 510, 252.25, 1020, 765, 255, 255, 255},
+ {0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255},
+ {0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255},
+ {0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255}
+ };
+ Mat demandedComp = Mat(45, 45, CV_32F, arDemandedComp);
+
+ Mat kernel;
+ ft::createKernel(ft::LINEAR, 2, kernel, 1);
+
+ Mat c00, c10, c01, f1comp;
+ ft::FT12D_polynomial(I, kernel, c00, c10, c01, f1comp);
+
+ double n1 = cvtest::norm(demandedC00, c00, NORM_INF);
+ double n2 = cvtest::norm(demandedC10, c10, NORM_INF);
+ double n3 = cvtest::norm(demandedC01, c01, NORM_INF);
+ double n4 = cvtest::norm(demandedComp, f1comp, NORM_INF);
+
+ EXPECT_DOUBLE_EQ(n1 + n2 + n3 + n4, 0);
+}
+
+TEST(fuzzy_f1, components)
+{
+ float arI[16][16] =
+ {
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 }
+ };
+ Mat I = Mat(16, 16, CV_32F, arI);
+
+ float arDemandedComp[45][45] =
+ {
+ { 0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -5, 0, 5, 10, 15, 20.5, 44, 67.5, 91, 114.5, 113.5, 137, 160.5, 184, 207.5, 208, 231, 254, 277, 300, 300.5, 324, 347.5, 371, 394.5, 394.5, 418, 441.5, 465, 488.5, 493.5, 499, 504.5, 510, 252.25, 1020, 765, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -2.5, 2.5, 7.5, 12.5, 17.5, 54.25, 77.75, 101.25, 124.75, 148.25, 193.75, 217.25, 240.75, 264.25, 287.75, 335, 358, 381, 404, 427, 474.25, 497.75, 521.25, 544.75, 568.25, 615.25, 638.75, 662.25, 685.75, 709.25, 745.75, 751.25, 756.75, 762.25, 252.25, 1275, 1020, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -2.5, 2.5, 7.5, 12.5, 17.5, 54.25, 77.75, 101.25, 124.75, 148.25, 193.75, 217.25, 240.75, 264.25, 287.75, 335, 358, 381, 404, 427, 474.25, 497.75, 521.25, 544.75, 568.25, 615.25, 638.75, 662.25, 685.75, 709.25, 745.75, 751.25, 756.75, 762.25, 252.25, 1275, 1020, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -5, 0, 5, 10, 15, 20.5, 44, 67.5, 91, 114.5, 113.5, 137, 160.5, 184, 207.5, 208, 231, 254, 277, 300, 300.5, 324, 347.5, 371, 394.5, 394.5, 418, 441.5, 465, 488.5, 493.5, 499, 504.5, 510, 252.25, 1020, 765, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255 }
+ };
+ Mat demandedComp = Mat(45, 45, CV_32F, arDemandedComp);
+
+ Mat kernel;
+ ft::createKernel(ft::LINEAR, 2, kernel, 1);
+
+ Mat f1comp;
+ ft::FT12D_components(I, kernel, f1comp);
+
+ double n1 = cvtest::norm(demandedComp, f1comp, NORM_INF);
+
+ EXPECT_DOUBLE_EQ(n1, 0);
+}
+
+TEST(fuzzy_f1, process)
+{
+ float arI[16][16] =
+ {
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 },
+ { 0, 0, 0, 10, 34, 57, 80, 104, 127, 150, 174, 197, 221, 244, 255, 255 }
+ };
+ Mat I = Mat(16, 16, CV_32F, arI);
+
+ float arDemandedO[16][16] =
+ {
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -0.625, 3.75, 17.9375, 50.625, 85.5, 120.375, 155.6875, 190.5, 225.3125, 260.625, 295.875, 331.125, 363.75, 378.375, 510.6875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -0.625, 3.75, 17.9375, 50.625, 85.5, 120.375, 155.6875, 190.5, 225.3125, 260.625, 295.875, 331.125, 363.75, 378.375, 510.6875 }
+ };
+ Mat demandedO = Mat(16, 16, CV_32F, arDemandedO);
+
+ Mat kernel;
+ ft::createKernel(ft::LINEAR, 2, kernel, 1);
+
+ Mat O;
+ ft::FT12D_process(I, kernel, O);
+
+ double n1 = cvtest::norm(demandedO, O, NORM_INF);
+
+ EXPECT_DOUBLE_EQ(n1, 0);
+}
+
+TEST(fuzzy_f1, inversion)
+{
+ float arDemandedO[16][16] =
+ {
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -0.625, 3.75, 17.9375, 50.625, 85.5, 120.375, 155.6875, 190.5, 225.3125, 260.625, 295.875, 331.125, 363.75, 378.375, 510.6875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -1.25, 2.5, 8.875, 33.75, 57, 80.25, 103.875, 127, 150.125, 173.75, 197.25, 220.75, 245.5, 252.25, 383.875 },
+ { 0, -0.625, 3.75, 17.9375, 50.625, 85.5, 120.375, 155.6875, 190.5, 225.3125, 260.625, 295.875, 331.125, 363.75, 378.375, 510.6875 }
+ };
+ Mat demandedO = Mat(16, 16, CV_32F, arDemandedO);
+
+ float arComp[45][45] =
+ {
+ { 0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -5, 0, 5, 10, 15, 20.5, 44, 67.5, 91, 114.5, 113.5, 137, 160.5, 184, 207.5, 208, 231, 254, 277, 300, 300.5, 324, 347.5, 371, 394.5, 394.5, 418, 441.5, 465, 488.5, 493.5, 499, 504.5, 510, 252.25, 1020, 765, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -2.5, 2.5, 7.5, 12.5, 17.5, 54.25, 77.75, 101.25, 124.75, 148.25, 193.75, 217.25, 240.75, 264.25, 287.75, 335, 358, 381, 404, 427, 474.25, 497.75, 521.25, 544.75, 568.25, 615.25, 638.75, 662.25, 685.75, 709.25, 745.75, 751.25, 756.75, 762.25, 252.25, 1275, 1020, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -7.5, -2.5, 2.5, 7.5, 12.5, -13.25, 10.25, 33.75, 57.25, 80.75, 33.25, 56.75, 80.25, 103.75, 127.25, 81, 104, 127, 150, 173, 126.75, 150.25, 173.75, 197.25, 220.75, 173.75, 197.25, 220.75, 244.25, 267.75, 241.25, 246.75, 252.25, 257.75, 252.25, 765, 510, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -2.5, 2.5, 7.5, 12.5, 17.5, 54.25, 77.75, 101.25, 124.75, 148.25, 193.75, 217.25, 240.75, 264.25, 287.75, 335, 358, 381, 404, 427, 474.25, 497.75, 521.25, 544.75, 568.25, 615.25, 638.75, 662.25, 685.75, 709.25, 745.75, 751.25, 756.75, 762.25, 252.25, 1275, 1020, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, -5, 0, 5, 10, 15, 20.5, 44, 67.5, 91, 114.5, 113.5, 137, 160.5, 184, 207.5, 208, 231, 254, 277, 300, 300.5, 324, 347.5, 371, 394.5, 394.5, 418, 441.5, 465, 488.5, 493.5, 499, 504.5, 510, 252.25, 1020, 765, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255 },
+ { 0, 0, 0, 0, 0, 2.5, 2.5, 2.5, 2.5, 2.5, 33.75, 33.75, 33.75, 33.75, 33.75, 80.25, 80.25, 80.25, 80.25, 80.25, 127, 127, 127, 127, 127, 173.75, 173.75, 173.75, 173.75, 173.75, 220.75, 220.75, 220.75, 220.75, 220.75, 252.25, 252.25, 252.25, 252.25, 252.25, 255, 255, 255, 255, 255 }
+ };
+ Mat comp = Mat(45, 45, CV_32F, arComp);
+
+ Mat kernel;
+ ft::createKernel(ft::LINEAR, 2, kernel, 1);
+
+ Mat O;
+ ft::FT12D_inverseFT(comp, kernel, O, 16, 16);
+
+ double n1 = cvtest::norm(demandedO, O, NORM_INF);
+
+ EXPECT_DOUBLE_EQ(n1, 0);
+}
diff --git a/contrib/modules/fuzzy/test/test_image.cpp b/contrib/modules/fuzzy/test/test_image.cpp
index fd22e47..cf393e8 100644
--- a/contrib/modules/fuzzy/test/test_image.cpp
+++ b/contrib/modules/fuzzy/test/test_image.cpp
@@ -102,11 +102,11 @@ TEST(fuzzy_image, kernel)
Mat kernel1;
ft::createKernel(ft::LINEAR, 2, kernel1, 1);
- Mat vector1 = (Mat_<float>(5, 1) << 0, 0.5, 1, 0.5, 0);
- Mat vector2 = (Mat_<float>(1, 5) << 0, 0.5, 1, 0.5, 0);
+ Mat vectorA = (Mat_<float>(1, 5) << 0, 0.5, 1, 0.5, 0);
+ Mat vectorB = (Mat_<float>(5, 1) << 0, 0.5, 1, 0.5, 0);
Mat kernel2;
- ft::createKernel(vector1, vector2, kernel2, 1);
+ ft::createKernel(vectorA, vectorB, kernel2, 1);
double diff = cvtest::norm(kernel1, kernel2, NORM_INF);
diff --git a/contrib/modules/fuzzy/tutorials/filtering/filtering.markdown b/contrib/modules/fuzzy/tutorials/filtering/filtering.markdown
new file mode 100644
index 0000000..9203f4d
--- /dev/null
+++ b/contrib/modules/fuzzy/tutorials/filtering/filtering.markdown
@@ -0,0 +1,60 @@
+Filtering using F-transform {#tutorial_fuzzy_filtering}
+=============
+
+Goal
+====
+This tutorial demonstrates to you how to use F-transform for image filtering. You will see:
+
+- basic theory behind,
+- illustration of different settings.
+
+Fuzzy transform application
+====
+As I shown in previous tutorial, F-transform is a tool of fuzzy mathematics highly usable in image processing. Let me rewrite the formula using kernel \f$g\f$ introduced before as well:
+
+\f[
+ F^0_{kl}=\frac{\sum_{x=0}^{2h+1}\sum_{y=0}^{2h+1} \iota_{kl}(x,y) g(x,y)}{\sum_{x=0}^{2h+1}\sum_{y=0}^{2h+1} g(x,y)},
+\f]
+
+where \f$\iota_{kl} \subset I\f$ centered to pixel \f$(k \cdot h,l \cdot h)\f$ and \f$g\f$ is a kernel. More details can be found in related papers.
+
+Code
+====
+ at include fuzzy/samples/fuzzy_filtering.cpp
+
+Explanation
+====
+Image filtering changes input in a defined way to enhance or simply change some concrete feature. Let me demonstrate some simple blur.
+
+As a first step, we load input image.
+
+ at code{.cpp}
+ // Input image
+ Mat I = imread("input.png");
+ at endcode
+
+Following the F-transform formula, we must specify a kernel.
+
+ at code{.cpp}
+ // Kernel cretion
+ Mat kernel1, kernel2;
+
+ ft::createKernel(ft::LINEAR, 3, kernel1, 3);
+ ft::createKernel(ft::LINEAR, 100, kernel2, 3);
+ at endcode
+
+> So now, we have two kernels that differ in `radius`. Bigger radius leads to bigger blur.
+
+The filtering itself is applied as shown below.
+
+ at code{.cpp}
+ // Filtering
+ Mat output1, output2;
+
+ ft::filter(I, kernel1, output1);
+ ft::filter(I, kernel2, output2);
+ at endcode
+
+Output images look as follows.
+
+
\ No newline at end of file
diff --git a/contrib/modules/fuzzy/tutorials/filtering/images/fuzzy_filt_output.jpg b/contrib/modules/fuzzy/tutorials/filtering/images/fuzzy_filt_output.jpg
new file mode 100644
index 0000000..de4fddc
Binary files /dev/null and b/contrib/modules/fuzzy/tutorials/filtering/images/fuzzy_filt_output.jpg differ
diff --git a/contrib/modules/fuzzy/tutorials/fuzzy.markdown b/contrib/modules/fuzzy/tutorials/fuzzy.markdown
new file mode 100644
index 0000000..2de1d9e
--- /dev/null
+++ b/contrib/modules/fuzzy/tutorials/fuzzy.markdown
@@ -0,0 +1,26 @@
+Fuzzy image processing tutorials {#tutorial_fuzzy}
+=============================================================
+
+- @subpage tutorial_fuzzy_theory
+
+ _Compatibility:_ \> OpenCV 3.2.0
+
+ _Author:_ Pavel Vlasanek
+
+ You will learn basics about fuzzy mathematics namely F-transform of certain degree.
+
+- @subpage tutorial_fuzzy_inpainting
+
+ _Compatibility:_ \> OpenCV 3.2.0
+
+ _Author:_ Pavel Vlasanek
+
+ You will learn how to use fuzzy mathematics in task of image inpainting.
+
+- @subpage tutorial_fuzzy_filtering
+
+ _Compatibility:_ \> OpenCV 3.2.0
+
+ _Author:_ Pavel Vlasanek
+
+ You will learn how to use fuzzy mathematics in task of image filtering.
\ No newline at end of file
diff --git a/contrib/modules/fuzzy/tutorials/inpainting/images/fuzzy_inp_input.jpg b/contrib/modules/fuzzy/tutorials/inpainting/images/fuzzy_inp_input.jpg
new file mode 100644
index 0000000..02367ee
Binary files /dev/null and b/contrib/modules/fuzzy/tutorials/inpainting/images/fuzzy_inp_input.jpg differ
diff --git a/contrib/modules/fuzzy/tutorials/inpainting/images/fuzzy_inp_output.jpg b/contrib/modules/fuzzy/tutorials/inpainting/images/fuzzy_inp_output.jpg
new file mode 100644
index 0000000..8bc088e
Binary files /dev/null and b/contrib/modules/fuzzy/tutorials/inpainting/images/fuzzy_inp_output.jpg differ
diff --git a/contrib/modules/fuzzy/tutorials/inpainting/inpainting.markdown b/contrib/modules/fuzzy/tutorials/inpainting/inpainting.markdown
new file mode 100644
index 0000000..12cddf1
--- /dev/null
+++ b/contrib/modules/fuzzy/tutorials/inpainting/inpainting.markdown
@@ -0,0 +1,104 @@
+Inpainting using F-transform {#tutorial_fuzzy_inpainting}
+=============
+
+Goal
+====
+In this tutorial, you will learn how image inpainting using F-transform works. It consists in:
+
+- basic theory behind,
+- three different algorithms.
+
+Introduction
+====
+The goal of this tutorial is to show that the inverse F-transform can be used for image reconstruction. By the image reconstruction, we mean a reconstruction of a corrupted image where corruption is everything that the original image does not include. It can be noise, text, scratch, etc. Proposal is to solve the problem of reconstruction with the help of an approximation technique. This means that we will be looking for an approximating image which is close to the given one and at the sa [...]
+
+Fuzzy transform application
+====
+As I shown in previous tutorial, F-transform is a tool of fuzzy mathematics highly usable in image processing. Let me rewrite the formula using kernel \f$g\f$ introduced before as well:
+
+\f[
+ F^0_{kl}=\frac{\sum_{x=0}^{2h+1}\sum_{y=0}^{2h+1} \iota_{kl}(x,y) g(x,y)}{\sum_{x=0}^{2h+1}\sum_{y=0}^{2h+1} g(x,y)},
+\f]
+
+where \f$\iota_{kl} \subset I\f$ centered to pixel \f$(k \cdot h,l \cdot h)\f$ and \f$g\f$ is a kernel. For purpose of image processing, a binary mask \f$S\f$ is used such as
+
+\f[
+ g^s_{kl} = g \circ s_{kl}
+\f]
+
+where \f$s_{k,l} \subset S\f$. Subarea \f$s\f$ of mask \f$S\f$ corresponds with subarea \f$\iota\f$ of image \f$I\f$. Operator \f$\circ\f$ is element-wise matrix multiplication (Hadamard product). Formula is updated to
+
+\f[
+ F^0_{kl}=\frac{\sum_{x=0}^{2h+1}\sum_{y=0}^{2h+1} \iota_{kl}(x,y) g^s(x,y)}{\sum_{x=0}^{2h+1}\sum_{y=0}^{2h+1} g^s(x,y)}.
+\f]
+
+More details can be found in related papers.
+
+Code
+====
+
+ at include fuzzy/samples/fuzzy_inpainting.cpp
+
+Explanation
+====
+The sample below demonstrates the usage of image inpainting. Three artificial images are created using the same input and three different type of corruption. In the real life usage, the input image will be already presented but here we created it by ourselves.
+
+First of all, we must load our image and three masks used for artificial damage creation.
+
+ at code{.cpp}
+ // Input image
+ Mat I = imread("input.png");
+
+ // Various masks
+ Mat mask1 = imread("mask1.png", IMREAD_GRAYSCALE);
+ Mat mask2 = imread("mask2.png", IMREAD_GRAYSCALE);
+ Mat mask3 = imread("mask3.png", IMREAD_GRAYSCALE);
+ at endcode
+
+> See that mask must be loaded as `IMREAD_GRAYSCALE`.
+
+In the next step, the masks are used for damaging our input image.
+
+ at code{.cpp}
+ // Apply the damage
+ Mat input1, input2, input3;
+
+ I.copyTo(input1, mask1);
+ I.copyTo(input2, mask2);
+ I.copyTo(input3, mask3);
+ at endcode
+
+Using the masks, we applied three different kind of corruption on the same input image. Here is the result.
+
+
+
+> Do not forget that in real life usage, images `input1`, `input2` and `input3` are created naturaly and used as the input directly.
+
+Declaration of output images follows. In the following lines, the method of inpainting is applied. Let me explain three different algorithms one by one.
+
+First of them is `ONE_STEP`.
+
+ at code{.cpp}
+ ft::inpaint(input1, mask1, output1, 2, ft::LINEAR, ft::ONE_STEP);
+ at endcode
+
+The `ONE_STEP` algorithm simply compute direct F-transform ignoring damaged parts using kernel with radius `2` (as specified in the method calling). Inverse F-transform fill up the missing area using values from the components nearby. It is up to you to choose radius which is big enough.
+
+Second is `MULTI_STEP`.
+
+ at code{.cpp}
+ ft::inpaint(input2, mask2, output2, 2, ft::LINEAR, ft::MULTI_STEP);
+ ft::inpaint(input3, mask3, output3, 2, ft::LINEAR, ft::MULTI_STEP);
+ at endcode
+
+`MULTI_STEP` algorithm works in the same way but defined radius (`2` in this case) is automatically increased if it is found insufficient. If you want to fill up the hole and you are not sure how big radius you need, you can choose `MULTI_STEP` and let the computer decide. The lowest possible will be found.
+
+Last one is `ITERATIVE`.
+
+ at code{.cpp}
+ ft::inpaint(input3, mask3, output4, 2, ft::LINEAR, ft::ITERATIVE);
+ at endcode
+
+Best choice in majority of cases is `ITERATIVE`. This way of processing use small radius of basic functions for small kind of damage and higher ones for bigger holes.
+
+
diff --git a/contrib/modules/fuzzy/tutorials/theory/images/fuzzy_BF_view.jpg b/contrib/modules/fuzzy/tutorials/theory/images/fuzzy_BF_view.jpg
new file mode 100644
index 0000000..850bb2d
Binary files /dev/null and b/contrib/modules/fuzzy/tutorials/theory/images/fuzzy_BF_view.jpg differ
diff --git a/contrib/modules/fuzzy/tutorials/theory/images/fuzzy_pixel_view.jpg b/contrib/modules/fuzzy/tutorials/theory/images/fuzzy_pixel_view.jpg
new file mode 100644
index 0000000..2d3c277
Binary files /dev/null and b/contrib/modules/fuzzy/tutorials/theory/images/fuzzy_pixel_view.jpg differ
diff --git a/contrib/modules/fuzzy/tutorials/theory/theory.markdown b/contrib/modules/fuzzy/tutorials/theory/theory.markdown
new file mode 100644
index 0000000..a3bc5f8
--- /dev/null
+++ b/contrib/modules/fuzzy/tutorials/theory/theory.markdown
@@ -0,0 +1,85 @@
+F-transform theory {#tutorial_fuzzy_theory}
+=============
+
+Goal
+====
+In this tutorial, the basic concept of fuzzy transform is presented. You will learn:
+
+- mathematic background,
+- how to apply concept of fuzziness to image processing.
+
+The presented explanation demands knowledge of basic math. All related papers are cited and mostly accessible on https://www.researchgate.net/.
+
+Introduction
+====
+In the last years, the theory of F-transforms has been intensively developed in many directions. In image processing, it has had successful applications in image compression and reduction, image fusion, edge detection and image reconstruction @cite Perf:FT @cite MSLP:cod-decod @cite Fusion:AFS12 @cite IPMU2012 @cite Perf:rec @cite vlavsanek2015patch. The F-transform is a technique that places a continuous/discrete function in correspondence with a finite vector of its F-transform compone [...]
+
+Let me introduce F-transform of a 2D grayscale image \f$I\f$ that is considered as a function \f$I:[0,M]\times [0,N]\to [0,255]\f$ where \f$[0,M]=\{0,1,2,\ldots,M\}; [0,N]=\{0,1,2,\ldots,N\}\f$. It is assumed that the image is defined at points (pixels) that belong to the set \f$P\f$, where \f$P=\{(x,y)\mid x=0,1,\ldots, M;y=0,1,\ldots, N\}\f$.
+
+Let \f$A_0, \dots ,A_m\f$ and \f$B_0, \dots ,B_n\f$ be basic functions, \f$A_0, \dots ,A_m : [0,M] \to [0, 1]\f$ be fuzzy partition of \f$[0,M]\f$ and \f$B_0, \dots ,B_n :[0,N]\to [0, 1]\f$ be fuzzy partition of \f$[0,N]\f$. Assume that the set of pixels \f$P\f$ is _sufficiently dense with respect to the chosen partitions_. This means that for all \f$k\in{0,\dots, m}(\exists x\in [0,M]) \ A_k(x)>0\f$, and for all \f$l\in{0,\dots, n}(\exists y\in [0,N])\ B_l(y)>0\f$.
+
+\f$F^0\f$-transform
+====
+We say that the \f$m\times n\f$-matrix of real numbers \f$F^0_{mn}[I] = (F^0_{kl})\f$ is called _the (discrete) F-transform_ of \f$I\f$ with respect to \f$\{A_0, \dots,A_m\}\f$ and \f$\{B_0, \dots,B_n\}\f$ if for all \f$k=0,\dots,m,\ l=0,\dots,n\f$:
+
+\f[
+ F^0_{kl}=\frac{\sum_{y=0}^{N}\sum_{x=0}^{M} I(x,y)A_k(x)B_l(y)}{\sum_{y=0}^{N}\sum_{x=0}^{M} A_k(x)B_l(y)}.
+\f]
+
+The coefficients \f$F^0_{kl}\f$ are called _components_ of the \f$F^0\f$-transform.
+
+\f$F^1\f$-transform
+====
+\f$F^1\f$-transform has been presented in @cite perfilieva2014differentiation. We say that matrix \f$F^1_{mn}[I] = (F^1_{kl}), k=0,\ldots, m, l=0,\ldots, n\f$, is the \f$F^1\f$-transform of \f$I\f$ with respect to \f$\{A_k\times B_l\mid k=0,\ldots, m, l=0,\ldots, n\}\f$, and \f$F^1_{kl}\f$ is the corresponding \f$F^1\f$-transform component.
+
+The \f$F^1\f$-transform components of \f$I\f$ are linear polynomials in the form
+
+\f[
+ F^1_{kl}(x,y)= c^{00}_{kl} + c^{10}_{kl}(x-x_k) + c^{01}_{kl}(y-y_l),
+\f]
+
+where the coefficients are given by
+
+\f[
+ c_{kl}^{00} =\frac{\sum_{y=0}^{N}\sum_{x=0}^{M} I(x,y)A_k(x)B_l(y)}{\sum_{y=0}^{N}\sum_{x=0}^{M} A_k(x)B_l(y)}, \\
+ c_{kl}^{10} =\frac{\sum_{y=0}^{N}\sum_{x=0}^{M} I(x,y)(x - x_k)A_k(x)B_l(y)}{\sum_{y=0}^{N}\sum_{x=0}^{M} (x - x_k)^2A_k(x)B_l(y)}, \\
+ c_{kl}^{01} =\frac{\sum_{y=0}^{N}\sum_{x=0}^{M} I(x,y)(y - y_l)A_k(x)B_l(y)}{\sum_{y=0}^{N}\sum_{x=0}^{M} (y - y_l)^2A_k(x)B_l(y)}.
+\f]
+
+Application to image processing
+====
+The technique of F-transforms uses two steps: _direct and inverse_. The direct step is described in the previous section whereas the inverse is as follows
+
+\f[
+ O(x,y)=\sum_{k=0}^{m}\sum_{l=0}^{n} F^d_{kl}A_k(x)B_l(y),
+\f]
+
+where \f$O\f$ is the output (reconstructed) image and \f$d\f$ is F-transform degree. In fact, the algorithm computes the F-transform components of the input image \f$I\f$ and spreads the components afterwards to the size of \f$I\f$. For details see @cite Perf:rec. Application to image processing is possible to take from two different views.
+
+From pixel point of view
+----
+The pixels are processed one by one in a way that appropriate basic functions are found for each of them. It will be exactly four, two in each direction. We need some helper structure in the memory for collecting their values. The values will be used in the nominator of the related fuzzy component. Implementation of this approach uses keyword `FL` as __fast__ processing (because of more optimizations) and __linear basic function__.
+
+
+
+From fuzzy component point of view
+----
+In this way, image is divided to the regular areas. Each area is processed separately using kernel window. This approach benefits from easy to understand, matrix based processing with straight forward parallelization.
+
+
+
+This approach uses kernel \f$g\f$. Let us show linear case with radius \f$h = 2\f$ as an example.
+
+\f[
+ A = (0, 0.5, 1, 0.5, 0) \\
+ B^T = (0, 0.5, 1, 0.5, 0) \\
+ g = AB^T=\left(
+ \begin{array}{ccccc}
+ 0 & 0 & 0 & 0 & 0 \\
+ 0 & 0.25 & 0.5 & 0.25 & 0 \\
+ 0 & 0.5 & 1 & 0.5 & 0 \\
+ 0 & 0.25 & 0.5 & 0.25 & 0 \\
+ 0 & 0 & 0 & 0 & 0 \\
+ \end{array}
+ \right)
+\f]
diff --git a/contrib/modules/hdf/CMakeLists.txt b/contrib/modules/hdf/CMakeLists.txt
index b6bfa49..2a1ae68 100644
--- a/contrib/modules/hdf/CMakeLists.txt
+++ b/contrib/modules/hdf/CMakeLists.txt
@@ -31,6 +31,5 @@ ocv_warnings_disable(CMAKE_CXX_FLAGS -Winvalid-offsetof)
set(the_description "Hierarchical Data Format I/O")
ocv_define_module(hdf opencv_core WRAP python)
-
-include_directories(${HDF5_INCLUDE_DIRS})
-target_link_libraries(opencv_hdf ${HDF5_LIBRARIES})
+ocv_target_link_libraries(${the_module} ${HDF5_LIBRARIES})
+ocv_include_directories(${HDF5_INCLUDE_DIRS})
diff --git a/contrib/modules/img_hash/CMakeLists.txt b/contrib/modules/img_hash/CMakeLists.txt
new file mode 100644
index 0000000..3e2effa
--- /dev/null
+++ b/contrib/modules/img_hash/CMakeLists.txt
@@ -0,0 +1,3 @@
+set(the_description "Image hash algorithms")
+set(OPENCV_MODULE_IS_PART_OF_WORLD OFF)
+ocv_define_module(img_hash opencv_imgproc opencv_core WRAP java python)
diff --git a/contrib/modules/img_hash/README.md b/contrib/modules/img_hash/README.md
new file mode 100644
index 0000000..1ee2b73
--- /dev/null
+++ b/contrib/modules/img_hash/README.md
@@ -0,0 +1,5 @@
+Image Hashing algorithms
+========================
+
+This module is intended to port the algorithms from PHash library and implement other image hash
+algorithm do not exist in PHash library yet.
diff --git a/contrib/modules/img_hash/doc/attack_performance.JPG b/contrib/modules/img_hash/doc/attack_performance.JPG
new file mode 100644
index 0000000..a2429dd
Binary files /dev/null and b/contrib/modules/img_hash/doc/attack_performance.JPG differ
diff --git a/contrib/modules/img_hash/doc/hash_comparison_chart.JPG b/contrib/modules/img_hash/doc/hash_comparison_chart.JPG
new file mode 100644
index 0000000..1cd99d1
Binary files /dev/null and b/contrib/modules/img_hash/doc/hash_comparison_chart.JPG differ
diff --git a/contrib/modules/img_hash/doc/hash_computation_chart.JPG b/contrib/modules/img_hash/doc/hash_computation_chart.JPG
new file mode 100644
index 0000000..5945c22
Binary files /dev/null and b/contrib/modules/img_hash/doc/hash_computation_chart.JPG differ
diff --git a/contrib/modules/img_hash/doc/img_hash.bib b/contrib/modules/img_hash/doc/img_hash.bib
new file mode 100644
index 0000000..34cb0c5
--- /dev/null
+++ b/contrib/modules/img_hash/doc/img_hash.bib
@@ -0,0 +1,23 @@
+ at misc{lookslikeit,
+ author={Krawetz, Neal},
+ title={Looks Like It},
+ url={http://www.hackerfactor.com/blog/?/archives/432-Looks-Like-It.html}
+}
+
+ at article{tang2012perceptual,
+ title={Perceptual hashing for color images using invariant moments},
+ author={Tang, Zhenjun and Dai, Yumin and Zhang, Xianquan},
+ journal={Appl. Math},
+ volume={6},
+ number={2S},
+ pages={643S--650S},
+ year={2012},
+ url={http://www.phash.org/docs/pubs/thesis_zauner.pdf}
+}
+
+ at article{zauner2010implementation,
+ title={Implementation and benchmarking of perceptual image hash functions},
+ author={Zauner, Christoph},
+ year={2010},
+ publisher={na}
+}
diff --git a/contrib/modules/img_hash/include/opencv2/img_hash.hpp b/contrib/modules/img_hash/include/opencv2/img_hash.hpp
new file mode 100644
index 0000000..5e7a928
--- /dev/null
+++ b/contrib/modules/img_hash/include/opencv2/img_hash.hpp
@@ -0,0 +1,78 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#ifndef OPENCV_IMG_HASH_H
+#define OPENCV_IMG_HASH_H
+
+#include "opencv2/img_hash/average_hash.hpp"
+#include "opencv2/img_hash/block_mean_hash.hpp"
+#include "opencv2/img_hash/color_moment_hash.hpp"
+#include "opencv2/img_hash/marr_hildreth_hash.hpp"
+#include "opencv2/img_hash/phash.hpp"
+#include "opencv2/img_hash/radial_variance_hash.hpp"
+
+/**
+ at defgroup img_hash The module brings implementations of different image hashing algorithms.
+
+Provide algorithms to extract the hash of images and fast way to figure out most similar images in
+huge data set.
+
+Namespace for all functions is cv::img_hash.
+
+### Supported Algorithms
+
+- Average hash (also called Different hash)
+- PHash (also called Perceptual hash)
+- Marr Hildreth Hash
+- Radial Variance Hash
+- Block Mean Hash (modes 0 and 1)
+- Color Moment Hash (this is the one and only hash algorithm resist to rotation attack(-90~90 degree))
+
+You can study more about image hashing from following paper and websites:
+
+- "Implementation and benchmarking of perceptual image hash functions" @cite zauner2010implementation
+- "Looks Like It" @cite lookslikeit
+
+### Code Example
+
+ at include samples/hash_samples.cpp
+
+### Performance under different attacks
+
+
+
+### Speed comparison with PHash library (100 images from ukbench)
+
+
+
+
+As you can see, hash computation speed of img_hash module outperform [PHash library](http://www.phash.org/) a lot.
+
+PS : I do not list out the comparison of Average hash, PHash and Color Moment hash, because I cannot
+find them in PHash.
+
+### Motivation
+
+Collects useful image hash algorithms into opencv, so we do not need to rewrite them by ourselves
+again and again or rely on another 3rd party library(ex : PHash library). BOVW or correlation
+matching are good and robust, but they are very slow compare with image hash, if you need to deal
+with large scale CBIR(content based image retrieval) problem, image hash is a more reasonable
+solution.
+
+### More info
+
+You can learn more about img_hash modules from following links, these links show you how to find
+similar image from ukbench dataset, provide thorough benchmark of different attacks(contrast, blur,
+noise(gaussion,pepper and salt), jpeg compression, watermark, resize).
+
+* [Introduction to image hash module of opencv](http://qtandopencv.blogspot.my/2016/06/introduction-to-image-hash-module-of.html)
+* [Speed up image hashing of opencv(img_hash) and introduce color moment hash](http://qtandopencv.blogspot.my/2016/06/speed-up-image-hashing-of-opencvimghash.html)
+
+### Contributors
+
+Tham Ngap Wei, thamngapwei at gmail.com
+
+*/
+
+#endif // OPENCV_IMG_HASH_H
diff --git a/contrib/modules/img_hash/include/opencv2/img_hash/average_hash.hpp b/contrib/modules/img_hash/include/opencv2/img_hash/average_hash.hpp
new file mode 100644
index 0000000..1204441
--- /dev/null
+++ b/contrib/modules/img_hash/include/opencv2/img_hash/average_hash.hpp
@@ -0,0 +1,39 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#ifndef OPENCV_AVERAGE_HASH_HPP
+#define OPENCV_AVERAGE_HASH_HPP
+
+#include "img_hash_base.hpp"
+
+namespace cv {
+namespace img_hash {
+
+//! @addtogroup img_hash
+//! @{
+
+/** @brief Computes average hash value of the input image
+
+This is a fast image hashing algorithm, but only work on simple case. For more details, please
+refer to @cite lookslikeit
+*/
+class CV_EXPORTS_W AverageHash : public ImgHashBase
+{
+public:
+ CV_WRAP static Ptr<AverageHash> create();
+protected:
+ AverageHash() {}
+};
+
+/** @brief Calculates img_hash::AverageHash in one call
+ at param inputArr input image want to compute hash value, type should be CV_8UC4, CV_8UC3 or CV_8UC1.
+ at param outputArr Hash value of input, it will contain 16 hex decimal number, return type is CV_8U
+*/
+CV_EXPORTS_W void averageHash(cv::InputArray inputArr, cv::OutputArray outputArr);
+
+//! @}
+
+}} // cv::img_hash::
+
+#endif // OPENCV_AVERAGE_HASH_HPP
diff --git a/contrib/modules/img_hash/include/opencv2/img_hash/block_mean_hash.hpp b/contrib/modules/img_hash/include/opencv2/img_hash/block_mean_hash.hpp
new file mode 100644
index 0000000..65d0a03
--- /dev/null
+++ b/contrib/modules/img_hash/include/opencv2/img_hash/block_mean_hash.hpp
@@ -0,0 +1,52 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#ifndef OPENCV_BLOCK_MEAN_HASH_HPP
+#define OPENCV_BLOCK_MEAN_HASH_HPP
+
+#include "img_hash_base.hpp"
+
+namespace cv {
+namespace img_hash {
+
+//! @addtogroup img_hash
+//! @{
+
+enum BlockMeanHashMode
+{
+ BLOCK_MEAN_HASH_MODE_0 = 0, //!< use fewer block and generate 16*16/8 uchar hash value
+ BLOCK_MEAN_HASH_MODE_1 = 1, //!< use block blocks(step sizes/2), generate 31*31/8 + 1 uchar hash value
+};
+
+/** @brief Image hash based on block mean.
+
+See @cite zauner2010implementation for details.
+*/
+class CV_EXPORTS_W BlockMeanHash : public ImgHashBase
+{
+public:
+ /** @brief Create BlockMeanHash object
+ @param mode
+ */
+ CV_WRAP void setMode(int mode);
+ CV_WRAP std::vector<double> getMean() const;
+ CV_WRAP static Ptr<BlockMeanHash> create(int mode = BLOCK_MEAN_HASH_MODE_0);
+protected:
+ BlockMeanHash() {}
+};
+
+/** @brief Computes block mean hash of the input image
+ @param inputArr input image want to compute hash value, type should be CV_8UC4, CV_8UC3 or CV_8UC1.
+ @param outputArr Hash value of input, it will contain 16 hex decimal number, return type is CV_8U
+ @param mode
+*/
+CV_EXPORTS_W void blockMeanHash(cv::InputArray inputArr,
+ cv::OutputArray outputArr,
+ int mode = BLOCK_MEAN_HASH_MODE_0);
+
+//! @}
+
+}} // cv::img_hash::
+
+#endif // OPENCV_BLOCK_MEAN_HASH_HPP
diff --git a/contrib/modules/img_hash/include/opencv2/img_hash/color_moment_hash.hpp b/contrib/modules/img_hash/include/opencv2/img_hash/color_moment_hash.hpp
new file mode 100644
index 0000000..d0a820b
--- /dev/null
+++ b/contrib/modules/img_hash/include/opencv2/img_hash/color_moment_hash.hpp
@@ -0,0 +1,41 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#ifndef OPENCV_COLOR_MOMENT_HASH_HPP
+#define OPENCV_COLOR_MOMENT_HASH_HPP
+
+#include "img_hash_base.hpp"
+
+namespace cv {
+namespace img_hash {
+
+//! @addtogroup img_hash
+//! @{
+
+/** @brief Image hash based on color moments.
+
+See @cite tang2012perceptual for details.
+*/
+class CV_EXPORTS_W ColorMomentHash : public ImgHashBase
+{
+public:
+ CV_WRAP static Ptr<ColorMomentHash> create();
+protected:
+ ColorMomentHash() {}
+};
+
+/** @brief Computes color moment hash of the input, the algorithm
+ is come from the paper "Perceptual Hashing for Color Images
+ Using Invariant Moments"
+ @param inputArr input image want to compute hash value,
+ type should be CV_8UC4, CV_8UC3 or CV_8UC1.
+ @param outputArr 42 hash values with type CV_64F(double)
+ */
+CV_EXPORTS_W void colorMomentHash(cv::InputArray inputArr, cv::OutputArray outputArr);
+
+//! @}
+
+}} // cv::img_hash::
+
+#endif // OPENCV_COLOR_MOMENT_HASH_HPP
diff --git a/contrib/modules/img_hash/include/opencv2/img_hash/img_hash_base.hpp b/contrib/modules/img_hash/include/opencv2/img_hash/img_hash_base.hpp
new file mode 100644
index 0000000..f0cc451
--- /dev/null
+++ b/contrib/modules/img_hash/include/opencv2/img_hash/img_hash_base.hpp
@@ -0,0 +1,46 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#ifndef OPENCV_IMG_HASH_BASE_HPP
+#define OPENCV_IMG_HASH_BASE_HPP
+
+#include "opencv2/core.hpp"
+
+namespace cv {
+namespace img_hash {
+
+//! @addtogroup img_hash
+//! @{
+
+/** @brief The base class for image hash algorithms
+ */
+class CV_EXPORTS_W ImgHashBase : public Algorithm
+{
+public:
+ class ImgHashImpl;
+
+ ~ImgHashBase();
+ /** @brief Computes hash of the input image
+ @param inputArr input image want to compute hash value
+ @param outputArr hash of the image
+ */
+ CV_WRAP void compute(cv::InputArray inputArr, cv::OutputArray outputArr);
+ /** @brief Compare the hash value between inOne and inTwo
+ @param hashOne Hash value one
+ @param hashTwo Hash value two
+ @return value indicate similarity between inOne and inTwo, the meaning
+ of the value vary from algorithms to algorithms
+ */
+ CV_WRAP double compare(cv::InputArray hashOne, cv::InputArray hashTwo) const;
+protected:
+ ImgHashBase();
+protected:
+ Ptr<ImgHashImpl> pImpl;
+};
+
+//! @}
+
+} } // cv::img_hash::
+
+#endif // OPENCV_IMG_HASH_BASE_HPP
diff --git a/contrib/modules/img_hash/include/opencv2/img_hash/marr_hildreth_hash.hpp b/contrib/modules/img_hash/include/opencv2/img_hash/marr_hildreth_hash.hpp
new file mode 100644
index 0000000..a9b04f9
--- /dev/null
+++ b/contrib/modules/img_hash/include/opencv2/img_hash/marr_hildreth_hash.hpp
@@ -0,0 +1,64 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#ifndef OPENCV_MARR_HILDRETH_HASH_HPP
+#define OPENCV_MARR_HILDRETH_HASH_HPP
+
+#include "img_hash_base.hpp"
+
+namespace cv {
+namespace img_hash {
+
+//! @addtogroup img_hash
+//! @{
+
+/** @brief Marr-Hildreth Operator Based Hash, slowest but more discriminative.
+
+See @cite zauner2010implementation for details.
+*/
+class CV_EXPORTS_W MarrHildrethHash : public ImgHashBase
+{
+public:
+ /**
+ * @brief self explain
+ */
+ CV_WRAP float getAlpha() const;
+
+ /**
+ * @brief self explain
+ */
+ CV_WRAP float getScale() const;
+
+ /** @brief Set Mh kernel parameters
+ @param alpha int scale factor for marr wavelet (default=2).
+ @param scale int level of scale factor (default = 1)
+ */
+ CV_WRAP void setKernelParam(float alpha, float scale);
+
+ /**
+ @param alpha int scale factor for marr wavelet (default=2).
+ @param scale int level of scale factor (default = 1)
+ */
+ CV_WRAP static Ptr<MarrHildrethHash> create(float alpha = 2.0f, float scale = 1.0f);
+protected:
+ MarrHildrethHash() {}
+};
+
+/** @brief Computes average hash value of the input image
+ @param inputArr input image want to compute hash value,
+ type should be CV_8UC4, CV_8UC3, CV_8UC1.
+ @param outputArr Hash value of input, it will contain 16 hex
+ decimal number, return type is CV_8U
+ @param alpha int scale factor for marr wavelet (default=2).
+ @param scale int level of scale factor (default = 1)
+*/
+CV_EXPORTS_W void marrHildrethHash(cv::InputArray inputArr,
+ cv::OutputArray outputArr,
+ float alpha = 2.0f, float scale = 1.0f);
+
+//! @}
+
+}} // cv::img_hash::
+
+#endif // OPENCV_MARR_HILDRETH_HASH_HPP
diff --git a/contrib/modules/img_hash/include/opencv2/img_hash/phash.hpp b/contrib/modules/img_hash/include/opencv2/img_hash/phash.hpp
new file mode 100644
index 0000000..d57cd6f
--- /dev/null
+++ b/contrib/modules/img_hash/include/opencv2/img_hash/phash.hpp
@@ -0,0 +1,41 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#ifndef OPENCV_PHASH_HPP
+#define OPENCV_PHASH_HPP
+
+#include "img_hash_base.hpp"
+
+namespace cv {
+namespace img_hash {
+
+//! @addtogroup img_hash
+//! @{
+
+/** @brief pHash
+
+Slower than average_hash, but tolerant of minor modifications
+
+This algorithm can combat more variation than averageHash, for more details please refer to @cite lookslikeit
+*/
+class CV_EXPORTS_W PHash : public ImgHashBase
+{
+public:
+ CV_WRAP static Ptr<PHash> create();
+protected:
+ PHash() {}
+};
+
+/** @brief Computes pHash value of the input image
+ @param inputArr input image want to compute hash value,
+ type should be CV_8UC4, CV_8UC3, CV_8UC1.
+ @param outputArr Hash value of input, it will contain 8 uchar value
+*/
+CV_EXPORTS_W void pHash(cv::InputArray inputArr, cv::OutputArray outputArr);
+
+//! @}
+
+} } // cv::img_hash::
+
+#endif // OPENCV_PHASH_HPP
diff --git a/contrib/modules/img_hash/include/opencv2/img_hash/radial_variance_hash.hpp b/contrib/modules/img_hash/include/opencv2/img_hash/radial_variance_hash.hpp
new file mode 100644
index 0000000..455f285
--- /dev/null
+++ b/contrib/modules/img_hash/include/opencv2/img_hash/radial_variance_hash.hpp
@@ -0,0 +1,58 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#ifndef OPENCV_RADIAL_VARIANCE_HASH_HPP
+#define OPENCV_RADIAL_VARIANCE_HASH_HPP
+
+#include "img_hash_base.hpp"
+
+namespace cv {
+namespace img_hash {
+
+//! @addtogroup img_hash
+//! @{
+
+
+/** @brief Image hash based on Radon transform.
+
+See @cite tang2012perceptual for details.
+*/
+class CV_EXPORTS_W RadialVarianceHash : public ImgHashBase
+{
+public:
+ CV_WRAP static Ptr<RadialVarianceHash> create(double sigma = 1, int numOfAngleLine = 180);
+
+ CV_WRAP int getNumOfAngleLine() const;
+ CV_WRAP double getSigma() const;
+
+ CV_WRAP void setNumOfAngleLine(int value);
+ CV_WRAP void setSigma(double value);
+
+ // internals
+ std::vector<double> getFeatures();
+ cv::Mat getHash();
+ Mat getPixPerLine(Mat const &input);
+ Mat getProjection();
+protected:
+ RadialVarianceHash() {}
+};
+
+/** @brief Computes radial variance hash of the input image
+ @param inputArr input image want to compute hash value,
+ type should be CV_8UC4, CV_8UC3, CV_8UC1.
+ @param outputArr Hash value of input
+ @param sigma Gaussian kernel standard deviation
+ @param numOfAngleLine The number of angles to consider
+ */
+CV_EXPORTS_W void radialVarianceHash(cv::InputArray inputArr,
+ cv::OutputArray outputArr,
+ double sigma = 1,
+ int numOfAngleLine = 180);
+
+
+//! @}
+
+}} // cv::img_hash::
+
+#endif // OPENCV_RADIAL_VARIANCE_HASH_HPP
diff --git a/contrib/modules/img_hash/samples/hash_samples.cpp b/contrib/modules/img_hash/samples/hash_samples.cpp
new file mode 100644
index 0000000..561f1ed
--- /dev/null
+++ b/contrib/modules/img_hash/samples/hash_samples.cpp
@@ -0,0 +1,53 @@
+#include "opencv2/core.hpp"
+#include "opencv2/core/ocl.hpp"
+#include "opencv2/highgui.hpp"
+#include "opencv2/img_hash.hpp"
+
+#include <iostream>
+
+using namespace cv;
+using namespace cv::img_hash;
+using namespace std;
+
+template <typename T>
+inline void test_one(const std::string &title, const Mat &a, const Mat &b)
+{
+ cout << "=== " << title << " ===" << endl;
+ TickMeter tick;
+ Mat hashA, hashB;
+ Ptr<ImgHashBase> func;
+ func = T::create();
+
+ tick.reset(); tick.start();
+ func->compute(a, hashA);
+ tick.stop();
+ cout << "compute1: " << tick.getTimeMilli() << " ms" << endl;
+
+ tick.reset(); tick.start();
+ func->compute(b, hashB);
+ tick.stop();
+ cout << "compute2: " << tick.getTimeMilli() << " ms" << endl;
+
+ cout << "compare: " << func->compare(hashA, hashB) << endl << endl;;
+}
+
+int main(int argc, char **argv)
+{
+ if (argc != 3)
+ {
+ cerr << "must input the path of input image and target image. ex : hash_samples lena.jpg lena2.jpg" << endl;
+ return -1;
+ }
+ ocl::setUseOpenCL(false);
+
+ Mat input = imread(argv[1]);
+ Mat target = imread(argv[2]);
+
+ test_one<AverageHash>("AverageHash", input, target);
+ test_one<PHash>("PHash", input, target);
+ test_one<MarrHildrethHash>("MarrHildrethHash", input, target);
+ test_one<RadialVarianceHash>("RadialVarianceHash", input, target);
+ test_one<BlockMeanHash>("BlockMeanHash", input, target);
+
+ return 0;
+}
diff --git a/contrib/modules/img_hash/src/average_hash.cpp b/contrib/modules/img_hash/src/average_hash.cpp
new file mode 100644
index 0000000..142b089
--- /dev/null
+++ b/contrib/modules/img_hash/src/average_hash.cpp
@@ -0,0 +1,86 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "precomp.hpp"
+
+using namespace cv;
+using namespace std;
+using namespace img_hash;
+
+namespace {
+
+class AverageHashImpl : public ImgHashBase::ImgHashImpl
+{
+private:
+ cv::Mat bitsImg;
+ cv::Mat grayImg;
+ cv::Mat resizeImg;
+
+public:
+
+ virtual void compute(cv::InputArray inputArr, cv::OutputArray outputArr)
+ {
+ cv::Mat const input = inputArr.getMat();
+ CV_Assert(input.type() == CV_8UC4 ||
+ input.type() == CV_8UC3 ||
+ input.type() == CV_8U);
+
+ cv::resize(input, resizeImg, cv::Size(8,8));
+ if(input.type() == CV_8UC3)
+ {
+ cv::cvtColor(resizeImg, grayImg, CV_BGR2GRAY);
+ }
+ else if(input.type() == CV_8UC4)
+ {
+ cv::cvtColor(resizeImg, grayImg, CV_BGRA2GRAY);
+ }
+ else
+ {
+ grayImg = resizeImg;
+ }
+
+ uchar const imgMean = static_cast<uchar>(cvRound(cv::mean(grayImg)[0]));
+ cv::compare(grayImg, imgMean, bitsImg, CMP_GT);
+ bitsImg /= 255;
+ outputArr.create(1, 8, CV_8U);
+ cv::Mat hash = outputArr.getMat();
+ uchar *hash_ptr = hash.ptr<uchar>(0);
+ uchar const *bits_ptr = bitsImg.ptr<uchar>(0);
+ std::bitset<8> bits;
+ for(size_t i = 0, j = 0; i != bitsImg.total(); ++j)
+ {
+ for(size_t k = 0; k != 8; ++k)
+ {
+ //avoid warning C4800, casting do not work
+ bits[k] = bits_ptr[i++] != 0;
+ }
+ hash_ptr[j] = static_cast<uchar>(bits.to_ulong());
+ }
+ }
+
+ virtual double compare(cv::InputArray hashOne, cv::InputArray hashTwo) const
+ {
+ return norm(hashOne, hashTwo, NORM_HAMMING);
+ }
+};
+
+} // namespace::
+
+//==================================================================================================
+
+namespace cv { namespace img_hash {
+
+Ptr<AverageHash> AverageHash::create()
+{
+ Ptr<AverageHash> res(new AverageHash());
+ res->pImpl = makePtr<AverageHashImpl>();
+ return res;
+}
+
+void averageHash(cv::InputArray inputArr, cv::OutputArray outputArr)
+{
+ AverageHashImpl().compute(inputArr, outputArr);
+}
+
+}} // cv::img_hash::
diff --git a/contrib/modules/img_hash/src/block_mean_hash.cpp b/contrib/modules/img_hash/src/block_mean_hash.cpp
new file mode 100644
index 0000000..e60b1e6
--- /dev/null
+++ b/contrib/modules/img_hash/src/block_mean_hash.cpp
@@ -0,0 +1,167 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "precomp.hpp"
+
+using namespace cv;
+using namespace cv::img_hash;
+using namespace std;
+
+namespace {
+
+enum
+{
+ imgWidth = 256,
+ imgHeight = 256,
+ blockWidth = 16,
+ blockHeigth = 16,
+ blockPerCol = imgHeight / blockHeigth,
+ blockPerRow = imgWidth / blockWidth,
+ rowSize = imgHeight - blockHeigth,
+ colSize = imgWidth - blockWidth
+};
+
+class BlockMeanHashImpl : public ImgHashBase::ImgHashImpl
+{
+public:
+ BlockMeanHashImpl(int mode)
+ {
+ setMode(mode);
+ }
+
+ ~BlockMeanHashImpl() {}
+
+ virtual void compute(cv::InputArray inputArr, cv::OutputArray outputArr)
+ {
+ cv::Mat const input = inputArr.getMat();
+ CV_Assert(input.type() == CV_8UC4 ||
+ input.type() == CV_8UC3 ||
+ input.type() == CV_8U);
+
+ cv::resize(input, resizeImg_, cv::Size(imgWidth,imgHeight));
+ if(input.type() == CV_8UC3)
+ {
+ cv::cvtColor(resizeImg_, grayImg_, CV_BGR2GRAY);
+ }
+ else if(input.type() == CV_8UC4)
+ {
+ cv::cvtColor(resizeImg_, grayImg_, CV_BGRA2GRAY);
+ }
+ else
+ {
+ grayImg_ = resizeImg_;
+ }
+
+ int pixColStep = blockWidth;
+ int pixRowStep = blockHeigth;
+ int numOfBlocks = 0;
+ switch(mode_)
+ {
+ case BLOCK_MEAN_HASH_MODE_0:
+ {
+ numOfBlocks = blockPerCol * blockPerRow;
+ break;
+ }
+ case BLOCK_MEAN_HASH_MODE_1:
+ {
+ pixColStep /= 2;
+ pixRowStep /= 2;
+ numOfBlocks = (blockPerCol*2-1) * (blockPerRow*2-1);
+ break;
+ }
+ default:
+ break;
+ }
+
+ mean_.resize(numOfBlocks);
+ findMean(pixRowStep, pixColStep);
+ outputArr.create(1, numOfBlocks/8 + numOfBlocks % 8, CV_8U);
+ cv::Mat hash = outputArr.getMat();
+ createHash(hash);
+ }
+
+ virtual double compare(cv::InputArray hashOne, cv::InputArray hashTwo) const
+ {
+ return norm(hashOne, hashTwo, NORM_HAMMING);
+ }
+
+ void setMode(int mode)
+ {
+ CV_Assert(mode == BLOCK_MEAN_HASH_MODE_0 || mode == BLOCK_MEAN_HASH_MODE_1);
+ mode_ = mode;
+ }
+
+ void createHash(cv::Mat &hash)
+ {
+ double const median = cv::mean(grayImg_)[0];
+ uchar *hashPtr = hash.ptr<uchar>(0);
+ std::bitset<8> bits = 0;
+ for(size_t i = 0; i < mean_.size(); ++i)
+ {
+ size_t const residual = i%8;
+ bits[residual] = mean_[i] < median ? 0 : 1;
+ if(residual == 7)
+ {
+ *hashPtr = static_cast<uchar>(bits.to_ulong());
+ ++hashPtr;
+ }else if(i == mean_.size() - 1)
+ {
+ *hashPtr = bits[residual];
+ }
+ }
+ }
+ void findMean(int pixRowStep, int pixColStep)
+ {
+ size_t blockIdx = 0;
+ for(int row = 0; row <= rowSize; row += pixRowStep)
+ {
+ for(int col = 0; col <= colSize; col += pixColStep)
+ {
+ mean_[blockIdx++] = cv::mean(grayImg_(cv::Rect(col, row, blockWidth, blockHeigth)))[0];
+ }
+ }
+ }
+
+ cv::Mat grayImg_;
+ std::vector<double> mean_;
+ int mode_;
+ cv::Mat resizeImg_;
+};
+
+inline BlockMeanHashImpl *getLocalImpl(ImgHashBase::ImgHashImpl *ptr)
+{
+ BlockMeanHashImpl * impl = static_cast<BlockMeanHashImpl*>(ptr);
+ CV_Assert(impl);
+ return impl;
+}
+
+}
+
+//==================================================================================================
+
+namespace cv { namespace img_hash {
+
+Ptr<BlockMeanHash> BlockMeanHash::create(int mode)
+{
+ Ptr<BlockMeanHash> res(new BlockMeanHash);
+ res->pImpl = makePtr<BlockMeanHashImpl>(mode);
+ return res;
+}
+
+void BlockMeanHash::setMode(int mode)
+{
+ getLocalImpl(pImpl)->setMode(mode);
+}
+
+std::vector<double> BlockMeanHash::getMean() const
+{
+ return getLocalImpl(pImpl)->mean_;
+}
+
+void blockMeanHash(cv::InputArray inputArr, cv::OutputArray outputArr, int mode)
+{
+ BlockMeanHashImpl(mode).compute(inputArr, outputArr);
+}
+
+}} // cv::img_hash::
diff --git a/contrib/modules/img_hash/src/color_moment_hash.cpp b/contrib/modules/img_hash/src/color_moment_hash.cpp
new file mode 100644
index 0000000..006f40e
--- /dev/null
+++ b/contrib/modules/img_hash/src/color_moment_hash.cpp
@@ -0,0 +1,95 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "precomp.hpp"
+
+using namespace cv;
+using namespace cv::img_hash;
+using namespace std;
+
+namespace {
+
+class ColorMomentHashImpl : public ImgHashBase::ImgHashImpl
+{
+public:
+ ~ColorMomentHashImpl() {}
+
+ virtual void compute(cv::InputArray inputArr, cv::OutputArray outputArr)
+ {
+ cv::Mat const input = inputArr.getMat();
+ CV_Assert(input.type() == CV_8UC4 ||
+ input.type() == CV_8UC3 ||
+ input.type() == CV_8U);
+
+ if(input.type() == CV_8UC3)
+ {
+ colorImg_ = input;
+ }
+ else if(input.type() == CV_8UC4)
+ {
+ cv::cvtColor(input, colorImg_, CV_BGRA2BGR);
+ }
+ else
+ {
+ cv::cvtColor(input, colorImg_, CV_GRAY2BGR);
+ }
+
+ cv::resize(colorImg_, resizeImg_, cv::Size(512,512), 0, 0,
+ INTER_CUBIC);
+ cv::GaussianBlur(resizeImg_, blurImg_, cv::Size(3,3), 0, 0);
+
+ cv::cvtColor(blurImg_, colorSpace_, CV_BGR2HSV);
+ cv::split(colorSpace_, channels_);
+ outputArr.create(1, 42, CV_64F);
+ cv::Mat hash = outputArr.getMat();
+ hash.setTo(0);
+ computeMoments(hash.ptr<double>(0));
+
+ cv::cvtColor(blurImg_, colorSpace_, CV_BGR2YCrCb);
+ cv::split(colorSpace_, channels_);
+ computeMoments(hash.ptr<double>(0) + 21);
+ }
+
+ virtual double compare(cv::InputArray hashOne, cv::InputArray hashTwo) const
+ {
+ return norm(hashOne, hashTwo, NORM_L2) * 10000;
+ }
+
+private:
+ void computeMoments(double *inout)
+ {
+ for(size_t i = 0; i != channels_.size(); ++i)
+ {
+ cv::HuMoments(cv::moments(channels_[i]), inout);
+ inout += 7;
+ }
+ }
+
+private:
+ cv::Mat blurImg_;
+ cv::Mat colorImg_;
+ std::vector<cv::Mat> channels_;
+ cv::Mat colorSpace_;
+ cv::Mat resizeImg_;
+};
+
+}
+
+//==================================================================================================
+
+namespace cv { namespace img_hash {
+
+Ptr<ColorMomentHash> ColorMomentHash::create()
+{
+ Ptr<ColorMomentHash> res(new ColorMomentHash);
+ res->pImpl = makePtr<ColorMomentHashImpl>();
+ return res;
+}
+
+void colorMomentHash(cv::InputArray inputArr, cv::OutputArray outputArr)
+{
+ ColorMomentHashImpl().compute(inputArr, outputArr);
+}
+
+} } // cv::img_hash::
diff --git a/contrib/modules/img_hash/src/img_hash_base.cpp b/contrib/modules/img_hash/src/img_hash_base.cpp
new file mode 100644
index 0000000..2a5b633
--- /dev/null
+++ b/contrib/modules/img_hash/src/img_hash_base.cpp
@@ -0,0 +1,28 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "precomp.hpp"
+
+namespace cv {
+namespace img_hash{
+
+ImgHashBase::ImgHashBase()
+{
+}
+
+ImgHashBase::~ImgHashBase()
+{
+}
+
+void ImgHashBase::compute(cv::InputArray inputArr, cv::OutputArray outputArr)
+{
+ pImpl->compute(inputArr, outputArr);
+}
+
+double ImgHashBase::compare(cv::InputArray hashOne, cv::InputArray hashTwo) const
+{
+ return pImpl->compare(hashOne, hashTwo);
+}
+
+} } // cv::img_hash::
diff --git a/contrib/modules/img_hash/src/marr_hildreth_hash.cpp b/contrib/modules/img_hash/src/marr_hildreth_hash.cpp
new file mode 100644
index 0000000..54a6e85
--- /dev/null
+++ b/contrib/modules/img_hash/src/marr_hildreth_hash.cpp
@@ -0,0 +1,212 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "precomp.hpp"
+
+using namespace cv;
+using namespace cv::img_hash;
+using namespace std;
+
+namespace {
+
+void getMHKernel(float alpha, float level, cv::Mat &kernel)
+{
+ int const sigma = static_cast<int>(4*std::pow(alpha,level));
+
+ float const ratio = std::pow(alpha, -level);
+ kernel.create(2*sigma+1, 2*sigma+1, CV_32F);
+ for(int row = 0; row != kernel.rows; ++row)
+ {
+ float const ydiff = static_cast<float>(row - sigma);
+ float const ypos = ratio * ydiff;
+ float const yposPow2 = ypos * ypos;
+ float *kPtr = kernel.ptr<float>(row);
+ for(int col = 0; col != kernel.cols; ++col)
+ {
+ float const xpos = ratio * static_cast<float>((col - sigma));
+ float const a = xpos * xpos + yposPow2;
+ kPtr[col] = (2-a)*std::exp(a/2);
+ }
+ }
+}
+
+void fillBlocks(cv::Mat const &freImg, cv::Mat &blocks)
+{
+ //TODO : use forEach may provide better speed, however,
+ //it is quite tedious to apply without lambda
+ blocks.setTo(0);
+ for(int row = 0; row != blocks.rows; ++row)
+ {
+ float *bptr = blocks.ptr<float>(row);
+ int const rOffset = row*16;
+ for(int col = 0; col != blocks.cols; ++col)
+ {
+ cv::Rect const roi(rOffset,col*16,16,16);
+ bptr[col] =
+ static_cast<float>(cv::sum(freImg(roi))[0]);
+ }
+ }
+}
+
+void createHash(cv::Mat const &blocks, cv::Mat &hash)
+{
+ int hash_index = 0;
+ int bit_index = 0;
+ uchar hashbyte = 0;
+ uchar *hashPtr = hash.ptr<uchar>(0);
+ for (int row=0; row < 29; row += 4)
+ {
+ for (int col=0; col < 29; col += 4)
+ {
+ cv::Rect const roi(col,row,3,3);
+ cv::Mat const blockROI = blocks(roi);
+ float const avg =
+ static_cast<float>(cv::sum(blockROI)[0]/9.0);
+ for(int i = 0; i != blockROI.rows; ++i)
+ {
+ float const *bptr = blockROI.ptr<float>(i);
+ for(int j = 0; j != blockROI.cols; ++j)
+ {
+ hashbyte <<= 1;
+ if (bptr[j] > avg)
+ {
+ hashbyte |= 0x01;
+ }
+ ++bit_index;
+ if ((bit_index%8) == 0)
+ {
+ hash_index = (bit_index/8) - 1;
+ hashPtr[hash_index] = hashbyte;
+ hashbyte = 0x00;
+ }
+ }
+ }
+ }
+ }
+}
+
+class MarrHildrethHashImpl : public ImgHashBase::ImgHashImpl
+{
+public:
+
+ MarrHildrethHashImpl(float alpha = 2.0f, float scale = 1.0f) : alphaVal(alpha), scaleVal(scale)
+ {
+ getMHKernel(alphaVal, scaleVal, mhKernel);
+ blocks.create(31,31, CV_32F);
+ }
+
+ ~MarrHildrethHashImpl() { }
+
+ virtual void compute(cv::InputArray inputArr, cv::OutputArray outputArr)
+ {
+ cv::Mat const input = inputArr.getMat();
+ CV_Assert(input.type() == CV_8UC4 ||
+ input.type() == CV_8UC3 ||
+ input.type() == CV_8U);
+
+ if(input.type() == CV_8UC3)
+ {
+ cv::cvtColor(input, grayImg, CV_BGR2GRAY);
+ }
+ else if(input.type() == CV_8UC4)
+ {
+ cv::cvtColor(input, grayImg, CV_BGRA2GRAY);
+ }
+ else
+ {
+ grayImg = input;
+ }
+ //pHash use Canny-deritch filter to blur the image
+ cv::GaussianBlur(grayImg, blurImg, cv::Size(7, 7), 0);
+ cv::resize(blurImg, resizeImg, cv::Size(512, 512), 0, 0, INTER_CUBIC);
+ cv::equalizeHist(resizeImg, equalizeImg);
+
+ //extract frequency info by mh kernel
+ cv::filter2D(equalizeImg, freImg, CV_32F, mhKernel);
+ fillBlocks(freImg, blocks);
+
+ outputArr.create(1, 72, CV_8U);
+ cv::Mat hash = outputArr.getMat();
+ createHash(blocks, hash);
+ }
+
+ virtual double compare(cv::InputArray hashOne, cv::InputArray hashTwo) const
+ {
+ return norm(hashOne, hashTwo, NORM_HAMMING);
+ }
+
+ float getAlpha() const
+ {
+ return alphaVal;
+ }
+
+ float getScale() const
+ {
+ return scaleVal;
+ }
+
+ void setKernelParam(float alpha, float scale)
+ {
+ alphaVal = alpha;
+ scaleVal = scale;
+ getMHKernel(alphaVal, scaleVal, mhKernel);
+ }
+
+friend class MarrHildrethHash;
+
+private:
+ float alphaVal;
+ cv::Mat blocks;
+ cv::Mat blurImg;
+ cv::Mat equalizeImg;
+ cv::Mat freImg; //frequency response image
+ cv::Mat grayImg;
+ cv::Mat mhKernel;
+ cv::Mat resizeImg;
+ float scaleVal;
+};
+
+inline MarrHildrethHashImpl *getLocalImpl(ImgHashBase::ImgHashImpl *ptr)
+{
+ MarrHildrethHashImpl * impl = static_cast<MarrHildrethHashImpl*>(ptr);
+ CV_Assert(impl);
+ return impl;
+}
+
+}
+
+//==================================================================================================
+
+namespace cv { namespace img_hash {
+
+float MarrHildrethHash::getAlpha() const
+{
+ return getLocalImpl(pImpl)->getAlpha();
+}
+
+float MarrHildrethHash::getScale() const
+{
+ return getLocalImpl(pImpl)->getScale();
+}
+
+void MarrHildrethHash::setKernelParam(float alpha, float scale)
+{
+ getLocalImpl(pImpl)->setKernelParam(alpha, scale);
+}
+
+Ptr<MarrHildrethHash> MarrHildrethHash::create(float alpha, float scale)
+{
+ Ptr<MarrHildrethHash> res(new MarrHildrethHash);
+ res->pImpl = makePtr<MarrHildrethHashImpl>(alpha, scale);
+ return res;
+}
+
+void marrHildrethHash(cv::InputArray inputArr,
+ cv::OutputArray outputArr,
+ float alpha, float scale)
+{
+ MarrHildrethHashImpl(alpha, scale).compute(inputArr, outputArr);
+}
+
+} } // cv::img_hash::
diff --git a/contrib/modules/img_hash/src/phash.cpp b/contrib/modules/img_hash/src/phash.cpp
new file mode 100644
index 0000000..6ee8662
--- /dev/null
+++ b/contrib/modules/img_hash/src/phash.cpp
@@ -0,0 +1,93 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "precomp.hpp"
+
+using namespace cv;
+using namespace cv::img_hash;
+using namespace std;
+
+namespace {
+
+class PHashImpl : public ImgHashBase::ImgHashImpl
+{
+public:
+ virtual void compute(cv::InputArray inputArr, cv::OutputArray outputArr)
+ {
+ cv::Mat const input = inputArr.getMat();
+ CV_Assert(input.type() == CV_8UC4 ||
+ input.type() == CV_8UC3 ||
+ input.type() == CV_8U);
+
+ cv::resize(input, resizeImg, cv::Size(32,32));
+ if(input.type() == CV_8UC3)
+ {
+ cv::cvtColor(resizeImg, grayImg, CV_BGR2GRAY);
+ }
+ else if(input.type() == CV_8UC4)
+ {
+ cv::cvtColor(resizeImg, grayImg, CV_BGRA2GRAY);
+ }
+ else
+ {
+ grayImg = resizeImg;
+ }
+
+ grayImg.convertTo(grayFImg, CV_32F);
+ cv::dct(grayFImg, dctImg);
+ dctImg(cv::Rect(0, 0, 8, 8)).copyTo(topLeftDCT);
+ topLeftDCT.at<float>(0, 0) = 0;
+ float const imgMean = static_cast<float>(cv::mean(topLeftDCT)[0]);
+
+ cv::compare(topLeftDCT, imgMean, bitsImg, CMP_GT);
+ bitsImg /= 255;
+ outputArr.create(1, 8, CV_8U);
+ cv::Mat hash = outputArr.getMat();
+ uchar *hash_ptr = hash.ptr<uchar>(0);
+ uchar const *bits_ptr = bitsImg.ptr<uchar>(0);
+ std::bitset<8> bits;
+ for(size_t i = 0, j = 0; i != bitsImg.total(); ++j)
+ {
+ for(size_t k = 0; k != 8; ++k)
+ {
+ //avoid warning C4800, casting do not work
+ bits[k] = bits_ptr[i++] != 0;
+ }
+ hash_ptr[j] = static_cast<uchar>(bits.to_ulong());
+ }
+ }
+
+ virtual double compare(cv::InputArray hashOne, cv::InputArray hashTwo) const
+ {
+ return norm(hashOne, hashTwo, NORM_HAMMING);
+ }
+
+private:
+ cv::Mat bitsImg;
+ cv::Mat dctImg;
+ cv::Mat grayFImg;
+ cv::Mat grayImg;
+ cv::Mat resizeImg;
+ cv::Mat topLeftDCT;
+};
+
+} // namespace::
+
+//==================================================================================================
+
+namespace cv { namespace img_hash {
+
+Ptr<PHash> PHash::create()
+{
+ Ptr<PHash> res(new PHash);
+ res->pImpl = makePtr<PHashImpl>();
+ return res;
+}
+
+void pHash(cv::InputArray inputArr, cv::OutputArray outputArr)
+{
+ PHashImpl().compute(inputArr, outputArr);
+}
+
+} } // cv::img_hash::
diff --git a/contrib/modules/img_hash/src/precomp.hpp b/contrib/modules/img_hash/src/precomp.hpp
new file mode 100644
index 0000000..24bb816
--- /dev/null
+++ b/contrib/modules/img_hash/src/precomp.hpp
@@ -0,0 +1,29 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#ifndef OPENCV_IMG_HASH_PRECOMP_H
+#define OPENCV_IMG_HASH_PRECOMP_H
+
+#include "opencv2/core.hpp"
+#include "opencv2/core/base.hpp"
+#include "opencv2/imgproc.hpp"
+#include "opencv2/imgproc/types_c.h"
+#include "opencv2/img_hash.hpp"
+
+#include <bitset>
+#include <iostream>
+
+namespace cv{ namespace img_hash {
+
+class ImgHashBase::ImgHashImpl
+{
+public:
+ virtual void compute(cv::InputArray inputArr, cv::OutputArray outputArr) = 0;
+ virtual double compare(cv::InputArray hashOne, cv::InputArray hashTwo) const = 0;
+ virtual ~ImgHashImpl() {}
+};
+
+}} // cv::img_hash::
+
+#endif // OPENCV_IMG_HASH_PRECOMP_H
diff --git a/contrib/modules/img_hash/src/radial_variance_hash.cpp b/contrib/modules/img_hash/src/radial_variance_hash.cpp
new file mode 100644
index 0000000..1265abc
--- /dev/null
+++ b/contrib/modules/img_hash/src/radial_variance_hash.cpp
@@ -0,0 +1,361 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "precomp.hpp"
+
+using namespace cv;
+using namespace cv::img_hash;
+using namespace std;
+
+namespace {
+
+enum
+{
+ hashSize = 40,
+};
+
+inline float roundingFactor(float val)
+{
+ return val >= 0 ? 0.5f : -0.5f;
+}
+
+inline int createOffSet(int length)
+{
+ float const center = static_cast<float>(length/2);
+ return static_cast<int>(std::floor(center + roundingFactor(center)));
+}
+
+class RadialVarianceHashImpl : public ImgHashBase::ImgHashImpl
+{
+public:
+ cv::Mat blurImg_;
+ std::vector<double> features_;
+ cv::Mat grayImg_;
+ int numOfAngelLine_;
+ cv::Mat pixPerLine_;
+ cv::Mat projections_;
+ double sigma_;
+
+ RadialVarianceHashImpl(double sigma, int numOfAngleLine)
+ : numOfAngelLine_(numOfAngleLine), sigma_(sigma)
+ {
+ }
+
+ ~RadialVarianceHashImpl() {}
+
+ virtual void compute(cv::InputArray inputArr, cv::OutputArray outputArr)
+ {
+ cv::Mat const input = inputArr.getMat();
+ CV_Assert(input.type() == CV_8UC4 ||
+ input.type() == CV_8UC3 ||
+ input.type() == CV_8U);
+
+ if(input.type() == CV_8UC3)
+ {
+ cv::cvtColor(input, grayImg_, CV_BGR2GRAY);
+ }
+ else if(input.type() == CV_8UC4)
+ {
+ cv::cvtColor(input, grayImg_, CV_BGRA2GRAY);
+ }
+ else
+ {
+ grayImg_ = input;
+ }
+
+ cv::GaussianBlur(grayImg_, blurImg_, cv::Size(0,0), sigma_, sigma_);
+ radialProjections(blurImg_);
+ findFeatureVector();
+ outputArr.create(1, hashSize, CV_8U);
+ cv::Mat hash = outputArr.getMat();
+ hashCalculate(hash);
+ }
+
+ virtual double compare(cv::InputArray hashOne, cv::InputArray hashTwo) const
+ {
+ cv::Mat const hashOneF = hashOne.getMat();
+ cv::Mat const hashTwoF = hashTwo.getMat();
+ CV_Assert(hashOneF.cols == hashSize && hashOneF.cols == hashTwoF.cols);
+
+ float bufferOne[hashSize];
+ cv::Mat hashFloatOne(1, hashSize, CV_32F, bufferOne);
+ hashOneF.convertTo(hashFloatOne, CV_32F);
+
+ float bufferTwo[hashSize];
+ cv::Mat hashFloatTwo(1, hashSize, CV_32F, bufferTwo);
+ hashTwoF.convertTo(hashFloatTwo, CV_32F);
+
+ int const pixNum = hashFloatOne.rows * hashFloatOne.cols;
+ cv::Scalar hOneMean, hOneStd, hTwoMean, hTwoStd;
+ cv::meanStdDev(hashFloatOne, hOneMean, hOneStd);
+ cv::meanStdDev(hashFloatTwo, hTwoMean, hTwoStd);
+
+ // Compute covariance and correlation coefficient
+ hashFloatOne -= hOneMean;
+ hashFloatTwo -= hTwoMean;
+ double max = std::numeric_limits<double>::min();
+ for(int i = 0; i != hashSize; ++i)
+ {
+ double const covar = (hashFloatOne).dot(hashFloatTwo) / pixNum;
+ double const corre = covar / (hOneStd[0] * hTwoStd[0] + 1e-20);
+ max = std::max(corre, max);
+ //move last value to first position, first value to second position,
+ //second value to third position and so on
+ float const preValue = bufferTwo[hashSize-1];
+ std::copy_backward(bufferTwo, bufferTwo + hashSize - 1, bufferTwo + hashSize);
+ bufferTwo[0] = preValue;
+ }
+
+ //return peak correlation coefficient
+ return max;
+ }
+
+ int getNumOfAngleLine() const
+ {
+ return numOfAngelLine_;
+ }
+ double getSigma() const
+ {
+ return sigma_;
+ }
+
+ void setNumOfAngleLine(int value)
+ {
+ CV_Assert(value > 0);
+ numOfAngelLine_ = value;
+ }
+ void setSigma(double value)
+ {
+ CV_Assert(value >= 1.0);
+ sigma_ = value;
+ }
+
+ void afterHalfProjections(cv::Mat const &input, int D, int xOff, int yOff)
+ {
+ int *pplPtr = pixPerLine_.ptr<int>(0);
+ int const init = 3*numOfAngelLine_/4;
+ for(int k = init, j = 0; k < numOfAngelLine_; ++k, j += 2)
+ {
+ float const theta = k*3.14159f/numOfAngelLine_;
+ float const alpha = std::tan(theta);
+ uchar *projDown = projections_.ptr<uchar>(k);
+ uchar *projUp = projections_.ptr<uchar>(k-j);
+ for(int x = 0; x < D; ++x)
+ {
+ float const y = alpha*(x-xOff);
+ int const yd = static_cast<int>(std::floor(y + roundingFactor(y)));
+ if((yd + yOff >= 0)&&(yd + yOff < input.rows) && (x < input.cols))
+ {
+ projDown[x] = input.at<uchar>(yd+yOff, x);
+ pplPtr[k] += 1;
+ }
+ if ((yOff - yd >= 0)&&(yOff - yd < input.cols)&&
+ (2*yOff - x >= 0)&&(2*yOff- x < input.rows)&&
+ (k != init))
+ {
+ projUp[x] =
+ input.at<uchar>(-(x-yOff)+yOff, -yd+yOff);
+ pplPtr[k-j] += 1;
+ }
+ }
+ }
+ }
+
+ void findFeatureVector()
+ {
+ features_.resize(numOfAngelLine_);
+ double sum = 0.0;
+ double sumSqd = 0.0;
+ int const *pplPtr = pixPerLine_.ptr<int>(0);
+ for(int k=0; k < numOfAngelLine_; ++k)
+ {
+ double lineSum = 0.0;
+ double lineSumSqd = 0.0;
+ //original implementation of pHash may generate zero pixNum, this
+ //will cause NaN value and make the features become less discriminative
+ //to avoid this problem, I add a small value--0.00001
+ double const pixNum = pplPtr[k] + 0.00001;
+ double const pixNumPow2 = pixNum * pixNum;
+ uchar const *projPtr = projections_.ptr<uchar>(k);
+ for(int i = 0; i < projections_.cols; ++i)
+ {
+ double const value = projPtr[i];
+ lineSum += value;
+ lineSumSqd += value * value;
+ }
+ features_[k] = (lineSumSqd/pixNum) -
+ (lineSum*lineSum)/(pixNumPow2);
+ sum += features_[k];
+ sumSqd += features_[k]*features_[k];
+ }
+ double const numOfALPow2 = numOfAngelLine_ * numOfAngelLine_;
+ double const mean = sum/numOfAngelLine_;
+ double const var = std::sqrt((sumSqd/numOfAngelLine_) - (sum*sum)/(numOfALPow2));
+ for(int i = 0; i < numOfAngelLine_; ++i)
+ {
+ features_[i] = (features_[i] - mean)/var;
+ }
+ }
+
+ void firstHalfProjections(cv::Mat const &input, int D, int xOff, int yOff)
+ {
+ int *pplPtr = pixPerLine_.ptr<int>(0);
+ for(int k = 0; k < numOfAngelLine_/4+1; ++k)
+ {
+ float const theta = k*3.14159f/numOfAngelLine_;
+ float const alpha = std::tan(theta);
+ uchar *projOne = projections_.ptr<uchar>(k);
+ uchar *projTwo = projections_.ptr<uchar>(numOfAngelLine_/2-k);
+ for(int x = 0; x < D; ++x)
+ {
+ float const y = alpha*(x-xOff);
+ int const yd = static_cast<int>(std::floor(y + roundingFactor(y)));
+ if((yd + yOff >= 0)&&(yd + yOff < input.rows) && (x < input.cols))
+ {
+ projOne[x] = input.at<uchar>(yd+yOff, x);
+ pplPtr[k] += 1;
+ }
+ if((yd + xOff >= 0) && (yd + xOff < input.cols) &&
+ (k != numOfAngelLine_/4) && (x < input.rows))
+ {
+ projTwo[x] =
+ input.at<uchar>(x, yd+xOff);
+ pplPtr[numOfAngelLine_/2-k] += 1;
+ }
+ }
+ }
+ }
+
+ void hashCalculate(cv::Mat &hash)
+ {
+ double temp[hashSize];
+ double max = 0;
+ double min = 0;
+ size_t const featureSize = features_.size();
+ //constexpr is a better choice
+ double const sqrtTwo = 1.4142135623730950488016887242097;
+ for(int k = 0; k < hash.cols; ++k)
+ {
+ double sum = 0;
+ for(size_t n = 0; n < featureSize; ++n)
+ {
+ sum += features_[n]*std::cos((3.14159*(2*n+1)*k)/(2*featureSize));
+ }
+ temp[k] = k == 0 ? sum/std::sqrt(featureSize) :
+ sum*sqrtTwo/std::sqrt(featureSize);
+ if(temp[k] > max)
+ {
+ max = temp[k];
+ }
+ else if(temp[k] < min)
+ {
+ min = temp[k];
+ }
+ }
+
+ double const range = max - min;
+ if(range != 0)
+ {
+ //std::transform is a better choice if lambda supported
+ uchar *hashPtr = hash.ptr<uchar>(0);
+ for(int i = 0; i < hash.cols; ++i)
+ {
+ hashPtr[i] = static_cast<uchar>((255*(temp[i] - min)/range));
+ }
+ }
+ else
+ {
+ hash = 0;
+ }
+ }
+
+ void radialProjections(cv::Mat const &input)
+ {
+ int const D = (input.cols > input.rows) ? input.cols : input.rows;
+ //Different with PHash, this part reverse the row size and col size,
+ //because cv::Mat is row major but not column major
+ projections_.create(numOfAngelLine_, D, CV_8U);
+ projections_ = 0;
+ pixPerLine_.create(1, numOfAngelLine_, CV_32S);
+ pixPerLine_ = 0;
+ int const xOff = createOffSet(input.cols);
+ int const yOff = createOffSet(input.rows);
+
+ firstHalfProjections(input, D, xOff, yOff);
+ afterHalfProjections(input, D, xOff, yOff);
+ }
+};
+
+inline RadialVarianceHashImpl *getLocalImpl(ImgHashBase::ImgHashImpl *ptr)
+{
+ RadialVarianceHashImpl * impl = static_cast<RadialVarianceHashImpl*>(ptr);
+ CV_Assert(impl);
+ return impl;
+}
+
+} // namespace::
+
+//==================================================================================================
+
+namespace cv { namespace img_hash {
+
+Ptr<RadialVarianceHash> RadialVarianceHash::create(double sigma, int numOfAngleLine)
+{
+ Ptr<RadialVarianceHash> res(new RadialVarianceHash);
+ res->pImpl = makePtr<RadialVarianceHashImpl>(sigma, numOfAngleLine);
+ return res;
+}
+
+int RadialVarianceHash::getNumOfAngleLine() const
+{
+ return getLocalImpl(pImpl)->getNumOfAngleLine();
+}
+
+double RadialVarianceHash::getSigma() const
+{
+ return getLocalImpl(pImpl)->getSigma();
+}
+
+void RadialVarianceHash::setNumOfAngleLine(int value)
+{
+ getLocalImpl(pImpl)->setNumOfAngleLine(value);
+}
+
+void RadialVarianceHash::setSigma(double value)
+{
+ getLocalImpl(pImpl)->setSigma(value);
+}
+
+std::vector<double> RadialVarianceHash::getFeatures()
+{
+ getLocalImpl(pImpl)->findFeatureVector();
+ return getLocalImpl(pImpl)->features_;
+}
+
+cv::Mat RadialVarianceHash::getHash()
+{
+ cv::Mat hash;
+ getLocalImpl(pImpl)->hashCalculate(hash);
+ return hash;
+}
+
+Mat RadialVarianceHash::getPixPerLine(Mat const &input)
+{
+ getLocalImpl(pImpl)->radialProjections(input);
+ return getLocalImpl(pImpl)->pixPerLine_;
+}
+
+Mat RadialVarianceHash::getProjection()
+{
+ return getLocalImpl(pImpl)->projections_;
+}
+
+void radialVarianceHash(cv::InputArray inputArr,
+ cv::OutputArray outputArr,
+ double sigma, int numOfAngleLine)
+{
+ RadialVarianceHashImpl(sigma, numOfAngleLine).compute(inputArr, outputArr);
+}
+
+}} // cv::img_hash::
diff --git a/contrib/modules/img_hash/test/test_average_hash.cpp b/contrib/modules/img_hash/test/test_average_hash.cpp
new file mode 100644
index 0000000..146dfb9
--- /dev/null
+++ b/contrib/modules/img_hash/test/test_average_hash.cpp
@@ -0,0 +1,58 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "test_precomp.hpp"
+
+#include <bitset>
+
+using namespace cv;
+
+class CV_AverageHashTest : public cvtest::BaseTest
+{
+public:
+ CV_AverageHashTest();
+ ~CV_AverageHashTest();
+protected:
+ void run(int /* idx */);
+};
+
+CV_AverageHashTest::CV_AverageHashTest(){}
+CV_AverageHashTest::~CV_AverageHashTest(){}
+
+void CV_AverageHashTest::run(int )
+{
+ cv::Mat const input = (cv::Mat_<uchar>(8, 8) <<
+ 1, 5, 4, 6, 3, 2, 7, 8,
+ 2, 4, 8, 9, 2, 1, 4, 3,
+ 3, 4, 5, 7, 9, 8, 7, 6,
+ 1, 2, 3, 4, 5, 6, 7, 8,
+ 8, 7, 2, 3, 6, 4, 5, 1,
+ 3, 4, 1, 2, 9, 8, 4, 2,
+ 6, 7, 8, 9, 7, 4, 3, 2,
+ 8, 7, 6, 5, 4, 3, 2, 1);
+ cv::Mat hash;
+ cv::img_hash::averageHash(input, hash);
+ bool const expectResult[] =
+ {
+ 0,0,0,1,0,0,1,1,
+ 0,0,1,1,0,0,0,0,
+ 0,0,0,1,1,1,1,1,
+ 0,0,0,0,0,1,1,1,
+ 1,1,0,0,1,0,0,0,
+ 0,0,0,0,1,1,0,0,
+ 1,1,1,1,1,0,0,0,
+ 1,1,1,0,0,0,0,0
+ };
+ uchar const *hashPtr = hash.ptr<uchar>(0);
+ for(int i = 0; i != hash.cols; ++i)
+ {
+ std::bitset<8> const bits = hashPtr[i];
+ for(int j = 0; j != 8; ++j)
+ {
+ EXPECT_EQ(bits[j], expectResult[i*8+j]);
+ }
+ }
+}
+
+TEST(average_hash_test, accuracy) { CV_AverageHashTest test; test.safe_run(); }
diff --git a/contrib/modules/img_hash/test/test_block_mean_hash.cpp b/contrib/modules/img_hash/test/test_block_mean_hash.cpp
new file mode 100644
index 0000000..c23872a
--- /dev/null
+++ b/contrib/modules/img_hash/test/test_block_mean_hash.cpp
@@ -0,0 +1,212 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "test_precomp.hpp"
+
+#include <bitset>
+
+using namespace cv;
+using namespace cv::img_hash;
+
+/**
+ *The expected results of this test case are come from the Phash library,
+ *I use it as golden model
+ */
+class CV_BlockMeanHashTest : public cvtest::BaseTest
+{
+public:
+ CV_BlockMeanHashTest();
+protected:
+ void run(int /* idx */);
+
+ void testMeanMode0();
+ void testMeanMode1();
+ void testHashMode0();
+ void testHashMode1();
+
+ cv::Mat input;
+ cv::Mat hash;
+ Ptr<cv::img_hash::BlockMeanHash> bmh;
+};
+
+CV_BlockMeanHashTest::CV_BlockMeanHashTest()
+{
+ input.create(256, 256, CV_8U);
+ for(int row = 0; row != input.rows; ++row)
+ {
+ uchar value = static_cast<uchar>(row);
+ for(int col = 0; col != input.cols; ++col)
+ {
+ input.at<uchar>(row, col) = value++;
+ }
+ }
+ bmh = BlockMeanHash::create(BLOCK_MEAN_HASH_MODE_0);
+}
+
+void CV_BlockMeanHashTest::testMeanMode0()
+{
+ std::vector<double> const &features = bmh->getMean();
+ double const expectResult[] =
+ {15,31,47,63,79,95,111,127,143,159,175,191,207,223,239,135,
+ 31,47,63,79,95,111,127,143,159,175,191,207,223,239,135,15,
+ 47,63,79,95,111,127,143,159,175,191,207,223,239,135,15,31,
+ 63,79,95,111,127,143,159,175,191,207,223,239,135,15,31,47,
+ 79,95,111,127,143,159,175,191,207,223,239,135,15,31,47,63,
+ 95,111,127,143,159,175,191,207,223,239,135,15,31,47,63,79,
+ 111,127,143,159,175,191,207,223,239,135,15,31,47,63,79,95,
+ 127,143,159,175,191,207,223,239,135,15,31,47,63,79,95,111,
+ 143,159,175,191,207,223,239,135,15,31,47,63,79,95,111,127,
+ 159,175,191,207,223,239,135,15,31,47,63,79,95,111,127,143,
+ 175,191,207,223,239,135,15,31,47,63,79,95,111,127,143,159,
+ 191,207,223,239,135,15,31,47,63,79,95,111,127,143,159,175,
+ 207,223,239,135,15,31,47,63,79,95,111,127,143,159,175,191,
+ 223,239,135,15,31,47,63,79,95,111,127,143,159,175,191,207,
+ 239,135,15,31,47,63,79,95,111,127,143,159,175,191,207,223,
+ 135,15,31,47,63,79,95,111,127,143,159,175,191,207,223,239,};
+ for(size_t i = 0; i != features.size(); ++i)
+ {
+ ASSERT_NEAR(features[i], expectResult[i], 0.0001);
+ }
+}
+
+void CV_BlockMeanHashTest::testMeanMode1()
+{
+ std::vector<double> const &features = bmh->getMean();
+ double const expectResult[] =
+ {15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,
+ 23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,
+ 31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,
+ 39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,
+ 47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,
+ 55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,
+ 63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,
+ 71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,
+ 79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,
+ 87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,
+ 95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,
+ 103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,
+ 111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,
+ 119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,
+ 127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,
+ 135,143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,
+ 143,151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,
+ 151,159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,
+ 159,167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,
+ 167,175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,
+ 175,183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,
+ 183,191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,
+ 191,199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,
+ 199,207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,
+ 207,215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,
+ 215,223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,
+ 223,231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,
+ 231,239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,
+ 239,219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,
+ 219,135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,
+ 135,43,15,23,31,39,47,55,63,71,79,87,95,103,111,119,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,};
+ for(size_t i = 0; i != features.size(); ++i)
+ {
+ ASSERT_NEAR(features[i], expectResult[i], 0.0001);
+ }
+}
+
+void CV_BlockMeanHashTest::testHashMode0()
+{
+ bool const expectResult[] =
+ {0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,
+ 0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,
+ 0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,
+ 0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,
+ 0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,
+ 0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,
+ 0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,
+ 0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,
+ 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,
+ 1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,
+ 1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,
+ 1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,
+ 1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,
+ 1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,
+ 1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,
+ 1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
+ };
+
+ for(int i = 0; i != hash.cols; ++i)
+ {
+ std::bitset<8> const bits = hash.at<uchar>(0, i);
+ for(size_t j = 0; j != bits.size(); ++j)
+ {
+ EXPECT_EQ(expectResult[i*8+j], bits[j]);
+ }
+ }
+}
+
+void CV_BlockMeanHashTest::testHashMode1()
+{
+ bool const expectResult[] =
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ };
+
+ for(int i = 0; i != hash.cols; ++i)
+ {
+ std::bitset<8> const bits = hash.at<uchar>(0, i);
+ if(i != hash.cols-1)
+ {
+ for(size_t j = 0; j != bits.size(); ++j)
+ {
+ EXPECT_EQ(expectResult[i*8+j], bits[j]);
+ }
+ }
+ else
+ {
+ //when mode == 1, there will be 961 block mean
+ //that is why we only check one bit at here
+ EXPECT_EQ(expectResult[i*8], bits[0]);
+ }
+ }
+}
+
+void CV_BlockMeanHashTest::run(int)
+{
+ bmh->compute(input, hash);
+ testMeanMode0();
+ testHashMode0();
+
+ bmh->setMode(BLOCK_MEAN_HASH_MODE_1);
+ bmh->compute(input, hash);
+ testMeanMode1();
+ testHashMode1();
+}
+
+TEST(block_mean_hash_test, accuracy) { CV_BlockMeanHashTest test; test.safe_run(); }
diff --git a/contrib/modules/img_hash/test/test_main.cpp b/contrib/modules/img_hash/test/test_main.cpp
new file mode 100644
index 0000000..556b026
--- /dev/null
+++ b/contrib/modules/img_hash/test/test_main.cpp
@@ -0,0 +1,7 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "test_precomp.hpp"
+
+CV_TEST_MAIN("cv")
diff --git a/contrib/modules/img_hash/test/test_marr_hildreth_hash.cpp b/contrib/modules/img_hash/test/test_marr_hildreth_hash.cpp
new file mode 100644
index 0000000..f20e795
--- /dev/null
+++ b/contrib/modules/img_hash/test/test_marr_hildreth_hash.cpp
@@ -0,0 +1,60 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "test_precomp.hpp"
+
+using namespace cv;
+
+class CV_MarrHildrethTest : public cvtest::BaseTest
+{
+public:
+ CV_MarrHildrethTest();
+ ~CV_MarrHildrethTest();
+protected:
+ void run(int /* idx */);
+};
+
+CV_MarrHildrethTest::CV_MarrHildrethTest(){}
+CV_MarrHildrethTest::~CV_MarrHildrethTest(){}
+
+void CV_MarrHildrethTest::run(int )
+{
+ cv::Mat_<uchar> input(512,512);
+ int val = 0;
+ for(int row = 0; row != input.rows; ++row)
+ {
+ for(int col = 0; col != input.cols; ++col)
+ {
+ input.at<uchar>(row, col) = val % 256;
+ ++val;
+ }
+ }
+
+ cv::Mat hash;
+ cv::img_hash::marrHildrethHash(input, hash);
+ uchar const expectResult[] =
+ {
+ 252, 126, 63, 31, 143, 199, 227, 241,
+ 248, 252, 126, 63, 31, 143, 199, 227,
+ 241, 248, 252, 126, 63, 31, 143, 199,
+ 227, 241, 248, 252, 126, 63, 31, 143,
+ 199, 227, 241, 248, 31, 143, 199, 227,
+ 241, 248, 252, 126, 63, 252, 126, 63,
+ 31, 143, 199, 227, 241, 248, 252, 126,
+ 63, 31, 143, 199, 227, 241, 248, 252,
+ 126, 63, 31, 143, 199, 227, 241, 248
+ };
+ uchar const *hashPtr = hash.ptr<uchar>(0);
+ for(int i = 0; i != 72; ++i)
+ {
+ if(hashPtr[i] != expectResult[i])
+ {
+ ts->printf(cvtest::TS::LOG, "Wrong hash value \n");
+ ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
+ return;
+ }
+ }
+}
+
+TEST(marr_hildreth_test, accuracy) { CV_MarrHildrethTest test; test.safe_run(); }
diff --git a/contrib/modules/img_hash/test/test_phash.cpp b/contrib/modules/img_hash/test/test_phash.cpp
new file mode 100644
index 0000000..43ed962
--- /dev/null
+++ b/contrib/modules/img_hash/test/test_phash.cpp
@@ -0,0 +1,58 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "test_precomp.hpp"
+
+#include <bitset>
+
+using namespace cv;
+
+class CV_PHashTest : public cvtest::BaseTest
+{
+public:
+ CV_PHashTest();
+ ~CV_PHashTest();
+protected:
+ void run(int /* idx */);
+};
+
+CV_PHashTest::CV_PHashTest(){}
+CV_PHashTest::~CV_PHashTest(){}
+
+void CV_PHashTest::run(int )
+{
+ cv::Mat input(32, 32, CV_8U);
+ cv::Mat hash;
+
+ uchar value = 0;
+ uchar *inPtr = input.ptr<uchar>(0);
+ for(size_t i = 0; i != 32*32; ++i)
+ {
+ inPtr[i] = value++;
+ }
+
+ cv::img_hash::pHash(input, hash);
+ bool const expectResult[] =
+ {
+ 1,0,1,1,1,1,1,1,
+ 0,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,
+ 0,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,
+ 0,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,
+ 0,1,1,1,1,1,1,1,
+ };
+ uchar const *hashPtr = hash.ptr<uchar>(0);
+ for(int i = 0; i != hash.cols; ++i)
+ {
+ std::bitset<8> const bits = hashPtr[i];
+ for(int j = 0; j != 8; ++j)
+ {
+ EXPECT_EQ(bits[j], expectResult[i*8+j]);
+ }
+ }
+}
+
+TEST(average_phash_test, accuracy) { CV_PHashTest test; test.safe_run(); }
diff --git a/contrib/modules/img_hash/test/test_precomp.hpp b/contrib/modules/img_hash/test/test_precomp.hpp
new file mode 100644
index 0000000..c4ea217
--- /dev/null
+++ b/contrib/modules/img_hash/test/test_precomp.hpp
@@ -0,0 +1,20 @@
+#ifdef __GNUC__
+# pragma GCC diagnostic ignored "-Wmissing-declarations"
+# if defined __clang__ || defined __APPLE__
+# pragma GCC diagnostic ignored "-Wmissing-prototypes"
+# pragma GCC diagnostic ignored "-Wextra"
+# endif
+#endif
+
+#ifndef __OPENCV_TEST_PRECOMP_HPP__
+#define __OPENCV_TEST_PRECOMP_HPP__
+
+#include <iostream>
+#include "opencv2/ts.hpp"
+#include "opencv2/img_hash.hpp"
+#include "opencv2/imgproc.hpp"
+#include "opencv2/core/cvdef.h"
+#include "opencv2/core.hpp"
+#include "opencv2/highgui.hpp"
+
+#endif
diff --git a/contrib/modules/img_hash/test/test_radial_variance_hash.cpp b/contrib/modules/img_hash/test/test_radial_variance_hash.cpp
new file mode 100644
index 0000000..d4b5d7b
--- /dev/null
+++ b/contrib/modules/img_hash/test/test_radial_variance_hash.cpp
@@ -0,0 +1,150 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "test_precomp.hpp"
+
+using namespace cv;
+using namespace cv::img_hash;
+
+
+/**
+ *The expected results of this test case are come from the phash library,
+ *I use it as golden model
+ */
+class CV_RadialVarianceHashTest : public cvtest::BaseTest
+{
+public:
+ CV_RadialVarianceHashTest();
+protected:
+ void run(int /* idx */);
+
+ //this test case do not use the original "golden data"
+ //of pHash library, I add a small value to nb_pixels in
+ //the function "ph_feature_vector" to avoid NaN value
+ void testComputeHash();
+ void testFeatures();
+ void testHash();
+ void testPixPerLine();
+ void testProjection();
+
+ cv::Mat input;
+ Ptr<cv::img_hash::RadialVarianceHash> rvh;
+};
+
+CV_RadialVarianceHashTest::CV_RadialVarianceHashTest()
+{
+ input.create(8, 8, CV_8U);
+ uchar *inPtr = input.ptr<uchar>(0);
+ for(size_t i = 0; i != input.total(); ++i)
+ {
+ inPtr[i] = static_cast<uchar>(i);
+ }
+ rvh = RadialVarianceHash::create(1, 10);
+}
+
+void CV_RadialVarianceHashTest::testComputeHash()
+{
+ cv::Mat hashOne(1, 40, CV_8U);
+ uchar buffer[] =
+ {
+ 52, 41, 49, 64, 40, 67, 76, 71, 69,
+ 55, 58, 68, 72, 78, 63, 73, 66, 77,
+ 60, 57, 48, 59, 62, 74, 70, 47, 46,
+ 51, 45, 44, 42, 61, 54, 75, 50, 79,
+ 65, 43, 53, 56
+ };
+ cv::Mat hashTwo(1, 40, CV_8U, buffer);
+ for(uchar i = 0; i != 40; ++i)
+ {
+ hashOne.at<uchar>(0, i) = i;
+ }
+
+ double const actual = rvh->compare(hashOne, hashTwo);
+ ASSERT_NEAR(0.481051, actual, 0.0001);
+}
+
+void CV_RadialVarianceHashTest::testFeatures()
+{
+ std::vector<double> const &features = rvh->getFeatures();
+ double const expectResult[] =
+ {-1.35784,-0.42703,0.908487,-1.39327,1.17313,
+ 1.47515,-0.0156121,0.774335,-0.116755,-1.02059};
+ for(size_t i = 0; i != features.size(); ++i)
+ {
+ ASSERT_NEAR(features[i], expectResult[i], 0.0001);
+ }
+}
+
+void CV_RadialVarianceHashTest::testHash()
+{
+ cv::Mat const hash = rvh->getHash();
+ uchar const expectResult[] =
+ {
+ 127, 92, 0, 158, 101,
+ 88, 14, 136, 227, 160,
+ 127, 94, 27, 118, 240,
+ 166, 153, 96, 254, 162,
+ 127, 162, 255, 96, 153,
+ 166, 240, 118, 27, 94,
+ 127, 160, 227, 136, 14,
+ 88, 101, 158, 0, 92
+ };
+ for(int i = 0; i != hash.cols; ++i)
+ {
+ EXPECT_EQ(hash.at<uchar>(0, i), expectResult[i]);
+ }
+}
+
+void CV_RadialVarianceHashTest::testPixPerLine()
+{
+ cv::Mat const pixPerLine = rvh->getPixPerLine(input);
+ uchar const expectResult[] =
+ {
+ 8,8,8,0,8,15,7,5,8,8,
+ };
+ bool const equal =
+ std::equal(expectResult, expectResult + pixPerLine.total(),
+ pixPerLine.ptr<int>(0));
+ if(equal == false)
+ {
+ ts->printf(cvtest::TS::LOG, "Wrong pixel per line value \n");
+ ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
+ }
+}
+
+void CV_RadialVarianceHashTest::testProjection()
+{
+ cv::Mat const proj = rvh->getProjection();
+ uchar const expectResult[] =
+ {
+ 32, 33, 34, 35, 36, 37, 38, 39,
+ 16, 17, 18, 27, 36, 37, 46, 47,
+ 0, 9, 18, 19, 36, 45, 46, 55,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 2, 10, 18, 27, 36, 44, 53, 61,
+ 4, 59, 51, 44, 36, 29, 22, 14,
+ 0, 58, 51, 43, 36, 30, 22, 15,
+ 0, 0, 58, 43, 36, 21, 6, 0,
+ 56, 49, 42, 43, 36, 21, 22, 15,
+ 40, 41, 42, 35, 36, 29, 22, 23
+ };
+ bool const equal =
+ std::equal(expectResult, expectResult + proj.total(),
+ proj.ptr<uchar>(0));
+ if(equal == false)
+ {
+ ts->printf(cvtest::TS::LOG, "Wrong projection value \n");
+ ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
+ }
+}
+
+void CV_RadialVarianceHashTest::run(int)
+{
+ testPixPerLine();
+ testProjection();
+ testFeatures();
+ testComputeHash();
+}
+
+TEST(radial_variance_hash_test, accuracy) { CV_RadialVarianceHashTest test; test.safe_run(); }
diff --git a/contrib/modules/line_descriptor/CMakeLists.txt b/contrib/modules/line_descriptor/CMakeLists.txt
index d0b0b4b..0c18edf 100644
--- a/contrib/modules/line_descriptor/CMakeLists.txt
+++ b/contrib/modules/line_descriptor/CMakeLists.txt
@@ -1,2 +1,2 @@
set(the_description "Line descriptor")
-ocv_define_module(line_descriptor opencv_features2d opencv_imgproc opencv_highgui WRAP python)
+ocv_define_module(line_descriptor opencv_imgproc OPTIONAL opencv_features2d WRAP python)
diff --git a/contrib/modules/line_descriptor/include/opencv2/line_descriptor/descriptor.hpp b/contrib/modules/line_descriptor/include/opencv2/line_descriptor/descriptor.hpp
index 9f2c639..df439f3 100644
--- a/contrib/modules/line_descriptor/include/opencv2/line_descriptor/descriptor.hpp
+++ b/contrib/modules/line_descriptor/include/opencv2/line_descriptor/descriptor.hpp
@@ -56,10 +56,7 @@
#include <iostream>
#include "opencv2/core/utility.hpp"
-//#include "opencv2/core/private.hpp"
#include <opencv2/imgproc.hpp>
-#include <opencv2/features2d.hpp>
-#include <opencv2/highgui.hpp>
#include "opencv2/core.hpp"
/* define data types */
@@ -750,10 +747,7 @@ class CV_EXPORTS BinaryDescriptor : public Algorithm
/* check parameters */
if( n < 0 || k < 0 || k > n || p <= 0.0 || p >= 1.0 )
- {
- std::cout << "nfa: wrong n, k or p values." << std::endl;
- exit( 0 );
- }
+ CV_Error(Error::StsBadArg, "nfa: wrong n, k or p values.\n");
/* trivial cases */
if( n == 0 || k == 0 )
return -logNT;
diff --git a/contrib/modules/line_descriptor/perf/perf_precomp.hpp b/contrib/modules/line_descriptor/perf/perf_precomp.hpp
index 1a3fd95..445b70b 100644
--- a/contrib/modules/line_descriptor/perf/perf_precomp.hpp
+++ b/contrib/modules/line_descriptor/perf/perf_precomp.hpp
@@ -53,7 +53,6 @@
#include "opencv2/ts.hpp"
#include "opencv2/highgui.hpp"
-#include "opencv2/features2d.hpp"
#include "opencv2/line_descriptor.hpp"
#ifdef GTEST_CREATE_SHARED_LIBRARY
diff --git a/contrib/modules/line_descriptor/samples/compute_descriptors.cpp b/contrib/modules/line_descriptor/samples/compute_descriptors.cpp
index d2bdef4..6800430 100644
--- a/contrib/modules/line_descriptor/samples/compute_descriptors.cpp
+++ b/contrib/modules/line_descriptor/samples/compute_descriptors.cpp
@@ -39,15 +39,16 @@
//
//M*/
-#include <opencv2/line_descriptor.hpp>
+#include <iostream>
+
+#ifdef HAVE_OPENCV_FEATURES2D
+#include <opencv2/line_descriptor.hpp>
#include "opencv2/core/utility.hpp"
#include <opencv2/imgproc.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/highgui.hpp>
-#include <iostream>
-
using namespace cv;
using namespace cv::line_descriptor;
@@ -98,4 +99,12 @@ int main( int argc, char** argv )
}
+#else
+
+int main()
+{
+ std::cerr << "OpenCV was built without features2d module" << std::endl;
+ return 0;
+}
+#endif // HAVE_OPENCV_FEATURES2D
diff --git a/contrib/modules/line_descriptor/samples/knn_matching.cpp b/contrib/modules/line_descriptor/samples/knn_matching.cpp
index a59b6ca..f239922 100644
--- a/contrib/modules/line_descriptor/samples/knn_matching.cpp
+++ b/contrib/modules/line_descriptor/samples/knn_matching.cpp
@@ -39,14 +39,16 @@
//
//M*/
-#include <opencv2/line_descriptor.hpp>
+#include <iostream>
+#ifdef HAVE_OPENCV_FEATURES2D
+
+#include <opencv2/line_descriptor.hpp>
#include "opencv2/core/utility.hpp"
#include <opencv2/imgproc.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/highgui.hpp>
-#include <iostream>
#include <vector>
#include <time.h>
@@ -194,4 +196,12 @@ int main( int argc, char** argv )
}
+#else
+
+int main()
+{
+ std::cerr << "OpenCV was built without features2d module" << std::endl;
+ return 0;
+}
+#endif // HAVE_OPENCV_FEATURES2D
diff --git a/contrib/modules/line_descriptor/samples/lines_extraction.cpp b/contrib/modules/line_descriptor/samples/lines_extraction.cpp
index 03b0124..d76327f 100644
--- a/contrib/modules/line_descriptor/samples/lines_extraction.cpp
+++ b/contrib/modules/line_descriptor/samples/lines_extraction.cpp
@@ -39,15 +39,16 @@
//
//M*/
-#include <opencv2/line_descriptor.hpp>
+#include <iostream>
+
+#ifdef HAVE_OPENCV_FEATURES2D
+#include <opencv2/line_descriptor.hpp>
#include "opencv2/core/utility.hpp"
#include <opencv2/imgproc.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/highgui.hpp>
-#include <iostream>
-
using namespace cv;
using namespace cv::line_descriptor;
using namespace std;
@@ -121,3 +122,13 @@ int main( int argc, char** argv )
imshow( "Lines", output );
waitKey();
}
+
+#else
+
+int main()
+{
+ std::cerr << "OpenCV was built without features2d module" << std::endl;
+ return 0;
+}
+
+#endif // HAVE_OPENCV_FEATURES2D
diff --git a/contrib/modules/line_descriptor/samples/lsd_lines_extraction.cpp b/contrib/modules/line_descriptor/samples/lsd_lines_extraction.cpp
index 4c1923e..6a0c266 100644
--- a/contrib/modules/line_descriptor/samples/lsd_lines_extraction.cpp
+++ b/contrib/modules/line_descriptor/samples/lsd_lines_extraction.cpp
@@ -39,15 +39,16 @@
//
//M*/
-#include <opencv2/line_descriptor.hpp>
+#include <iostream>
+
+#ifdef HAVE_OPENCV_FEATURES2D
+#include <opencv2/line_descriptor.hpp>
#include "opencv2/core/utility.hpp"
#include <opencv2/imgproc.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/highgui.hpp>
-#include <iostream>
-
using namespace cv;
using namespace cv::line_descriptor;
using namespace std;
@@ -121,3 +122,13 @@ int main( int argc, char** argv )
imshow( "LSD lines", output );
waitKey();
}
+
+#else
+
+int main()
+{
+ std::cerr << "OpenCV was built without features2d module" << std::endl;
+ return 0;
+}
+
+#endif // HAVE_OPENCV_FEATURES2D
diff --git a/contrib/modules/line_descriptor/samples/matching.cpp b/contrib/modules/line_descriptor/samples/matching.cpp
index 6eb669c..7a571a8 100644
--- a/contrib/modules/line_descriptor/samples/matching.cpp
+++ b/contrib/modules/line_descriptor/samples/matching.cpp
@@ -39,15 +39,16 @@
//
//M*/
-#include <opencv2/line_descriptor.hpp>
+#include <iostream>
+
+#ifdef HAVE_OPENCV_FEATURES2D
+#include <opencv2/line_descriptor.hpp>
#include "opencv2/core/utility.hpp"
#include <opencv2/imgproc.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/highgui.hpp>
-#include <iostream>
-
#define MATCHES_DIST_THRESHOLD 25
using namespace cv;
@@ -207,3 +208,12 @@ int main( int argc, char** argv )
}
+#else
+
+int main()
+{
+ std::cerr << "OpenCV was built without features2d module" << std::endl;
+ return 0;
+}
+
+#endif // HAVE_OPENCV_FEATURES2D
diff --git a/contrib/modules/line_descriptor/samples/radius_matching.cpp b/contrib/modules/line_descriptor/samples/radius_matching.cpp
index 7d43b84..0ec8bca 100644
--- a/contrib/modules/line_descriptor/samples/radius_matching.cpp
+++ b/contrib/modules/line_descriptor/samples/radius_matching.cpp
@@ -39,6 +39,10 @@
//
//M*/
+#include <iostream>
+
+#ifdef HAVE_OPENCV_FEATURES2D
+
#include <opencv2/line_descriptor.hpp>
#include "opencv2/core/utility.hpp"
@@ -46,7 +50,6 @@
#include <opencv2/features2d.hpp>
#include <opencv2/highgui.hpp>
-#include <iostream>
#include <vector>
using namespace cv;
@@ -140,3 +143,13 @@ int main( int argc, char** argv )
}
}
+
+#else
+
+int main()
+{
+ std::cerr << "OpenCV was built without features2d module" << std::endl;
+ return 0;
+}
+
+#endif // HAVE_OPENCV_FEATURES2D
diff --git a/contrib/modules/line_descriptor/src/precomp.hpp b/contrib/modules/line_descriptor/src/precomp.hpp
index 189fba2..5dcf167 100644
--- a/contrib/modules/line_descriptor/src/precomp.hpp
+++ b/contrib/modules/line_descriptor/src/precomp.hpp
@@ -46,14 +46,14 @@
#pragma warning( disable : 4267 )
#endif
+#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
+#endif
#include <algorithm>
#include "opencv2/core/utility.hpp"
#include "opencv2/core/private.hpp"
#include <opencv2/imgproc.hpp>
-#include <opencv2/features2d.hpp>
-#include <opencv2/highgui.hpp>
#include "opencv2/core.hpp"
#include <iostream>
diff --git a/contrib/modules/line_descriptor/test/test_precomp.hpp b/contrib/modules/line_descriptor/test/test_precomp.hpp
index c066366..bd42ca8 100644
--- a/contrib/modules/line_descriptor/test/test_precomp.hpp
+++ b/contrib/modules/line_descriptor/test/test_precomp.hpp
@@ -11,7 +11,6 @@
#include "opencv2/ts.hpp"
#include "opencv2/imgproc.hpp"
-#include "opencv2/features2d.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/line_descriptor.hpp"
#include <opencv2/core.hpp>
diff --git a/contrib/modules/matlab/CMakeLists.txt b/contrib/modules/matlab/CMakeLists.txt
index 30e7ddb..698644f 100644
--- a/contrib/modules/matlab/CMakeLists.txt
+++ b/contrib/modules/matlab/CMakeLists.txt
@@ -26,14 +26,31 @@
# ----------------------------------------------------------------------------
# Architecture checks
# ----------------------------------------------------------------------------
-# make sure we're on a supported architecture with Matlab and python installed
+# make sure we're on a supported architecture with Matlab and Python (with jinja2) installed
if(APPLE_FRAMEWORK OR ANDROID OR NOT MATLAB_FOUND)
ocv_module_disable(matlab)
- return()
-elseif (NOT PYTHON_DEFAULT_AVAILABLE)
+elseif(NOT PYTHON_DEFAULT_AVAILABLE)
message(WARNING "A required dependency of the matlab module (Python) was not found. Disabling Matlab bindings...")
ocv_module_disable(matlab)
- return()
+endif()
+
+if(NOT DEFINED HAVE_PYTHON_JINJA2)
+ # Bindings generator requires Jinja2 python package
+ execute_process(COMMAND "${PYTHON_DEFAULT_EXECUTABLE}" -c "import jinja2; print(jinja2.__version__)"
+ RESULT_VARIABLE _result
+ OUTPUT_VARIABLE _jinja2_version
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ if(NOT _result EQUAL 0)
+ set(HAVE_PYTHON_JINJA2 0 CACHE INTERNAL "")
+ else()
+ message(STATUS "Python Jinja version: ${_jinja2_version}")
+ set(HAVE_PYTHON_JINJA2 1 CACHE INTERNAL "")
+ endif()
+endif()
+if(NOT HAVE_PYTHON_JINJA2)
+ message(WARNING "A required dependency of the matlab module (Python Jinja2 package) was not found (installation command: \"pip install jinja2\"). Disabling Matlab bindings...")
+ ocv_module_disable(matlab)
endif()
@@ -93,7 +110,6 @@ ocv_add_module(matlab BINDINGS
opencv_calib opencv_calib3d
opencv_stitching opencv_superres
opencv_xfeatures2d
- opencv_hal
)
# get the commit information
@@ -101,7 +117,6 @@ execute_process(COMMAND git log -1 --pretty=%H OUTPUT_VARIABLE GIT_COMMIT ERROR_
string(REGEX REPLACE "(\r?\n)+$" "" GIT_COMMIT "${GIT_COMMIT}")
# set the path to the C++ header and doc parser, and template engine
-set(JINJA2_PATH ${CMAKE_SOURCE_DIR}/3rdparty)
set(HDR_PARSER_PATH ${CMAKE_SOURCE_DIR}/modules/python/src2)
# set mex compiler options
@@ -157,7 +172,6 @@ if (NOT MEX_WORKS)
execute_process(
COMMAND ${PYTHON_DEFAULT_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/generator/gen_matlab.py
- --jinja2 ${JINJA2_PATH}
--hdrparser ${HDR_PARSER_PATH}
--extra "test=${CMAKE_CURRENT_SOURCE_DIR}/test/test_generator.hpp"
--outdir ${CMAKE_BINARY_DIR}/junk
@@ -216,7 +230,6 @@ add_custom_command(
OUTPUT ${GENERATE_PROXY}
COMMAND ${PYTHON_DEFAULT_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/generator/gen_matlab.py
- --jinja2 ${JINJA2_PATH}
--hdrparser ${HDR_PARSER_PATH}
--moduleroot ${CMAKE_SOURCE_DIR}/modules ${OPENCV_EXTRA_MODULES_PATH}
--modules ${opencv_modules}
@@ -224,7 +237,6 @@ add_custom_command(
--outdir ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${PYTHON_DEFAULT_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/generator/build_info.py
- --jinja2 ${JINJA2_PATH}
--os ${CMAKE_SYSTEM}
--arch ${ARCH} ${CMAKE_SYSTEM_PROCESSOR}
--compiler ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}
@@ -238,7 +250,6 @@ add_custom_command(
--outdir ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${PYTHON_DEFAULT_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/generator/cvmex.py
- --jinja2 ${JINJA2_PATH}
--opts="${MEX_OPTS}"
--include_dirs="${MEX_INCLUDE_DIRS}"
--lib_dir="${MEX_LIB_DIR}"
@@ -301,7 +312,6 @@ install(CODE
"execute_process(
COMMAND ${PYTHON_DEFAULT_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/generator/cvmex.py
- --jinja2 ${JINJA2_PATH}
--opts=${MEX_OPTS}
--include_dirs=-I${CMAKE_INSTALL_PREFIX}/${OPENCV_INCLUDE_INSTALL_PATH}
--lib_dir=-L${CMAKE_INSTALL_PREFIX}/${OPENCV_LIB_INSTALL_PATH}
diff --git a/contrib/modules/matlab/generator/build_info.py b/contrib/modules/matlab/generator/build_info.py
index 1340d9f..9000f73 100644
--- a/contrib/modules/matlab/generator/build_info.py
+++ b/contrib/modules/matlab/generator/build_info.py
@@ -25,7 +25,7 @@ def substitute(build, output_dir):
if __name__ == "__main__":
"""
- Usage: python build_info.py --jinja2 /path/to/jinja2/engine
+ Usage: python build_info.py
--os os_version_string
--arch [bitness processor]
--compiler [id version]
@@ -50,7 +50,6 @@ if __name__ == "__main__":
import sys, re, os, time
from argparse import ArgumentParser
parser = ArgumentParser()
- parser.add_argument('--jinja2')
parser.add_argument('--os')
parser.add_argument('--arch', nargs=2)
parser.add_argument('--compiler', nargs='+')
@@ -65,9 +64,6 @@ if __name__ == "__main__":
parser.add_argument('--outdir')
build = parser.parse_args()
- # add jinja to the path
- sys.path.append(build.jinja2)
-
from filters import *
from jinja2 import Environment, FileSystemLoader
diff --git a/contrib/modules/matlab/generator/cvmex.py b/contrib/modules/matlab/generator/cvmex.py
index 731d30a..9282832 100644
--- a/contrib/modules/matlab/generator/cvmex.py
+++ b/contrib/modules/matlab/generator/cvmex.py
@@ -26,7 +26,7 @@ def substitute(cv, output_dir):
if __name__ == "__main__":
"""
- Usage: python cvmex.py --jinja2 /path/to/jinja2/engine
+ Usage: python cvmex.py
--opts [-list -of -opts]
--include_dirs [-list -of -opencv_include_directories]
--lib_dir opencv_lib_directory
@@ -44,7 +44,6 @@ if __name__ == "__main__":
import sys, re, os, time
from argparse import ArgumentParser
parser = ArgumentParser()
- parser.add_argument('--jinja2')
parser.add_argument('--opts')
parser.add_argument('--include_dirs')
parser.add_argument('--lib_dir')
@@ -53,9 +52,6 @@ if __name__ == "__main__":
parser.add_argument('--outdir')
cv = parser.parse_args()
- # add jinja to the path
- sys.path.append(cv.jinja2)
-
from filters import *
from jinja2 import Environment, FileSystemLoader
diff --git a/contrib/modules/matlab/generator/gen_matlab.py b/contrib/modules/matlab/generator/gen_matlab.py
index 218505a..513b300 100644
--- a/contrib/modules/matlab/generator/gen_matlab.py
+++ b/contrib/modules/matlab/generator/gen_matlab.py
@@ -129,7 +129,7 @@ class MatlabWrapperGenerator(object):
if __name__ == "__main__":
"""
- Usage: python gen_matlab.py --jinja2 /path/to/jinja2/engine
+ Usage: python gen_matlab.py
--hdrparser /path/to/hdr_parser/dir
--moduleroot [ /path/to/opencv/modules /path/to/opencv_contrib/modules etc ]
--modules [core imgproc objdetect etc]
@@ -145,8 +145,6 @@ if __name__ == "__main__":
definitions
gen_matlab.py requires the following inputs:
- --jinja2 the path to the Jinja2 templating engine
- e.g. ${CMAKE_SOURCE_DIR}/3rdparty
--hdrparser the path to the header parser directory
(opencv/modules/python/src2)
--moduleroot (optional) paths to the opencv directories containing the modules
@@ -165,7 +163,6 @@ if __name__ == "__main__":
# parse the input options
from argparse import ArgumentParser
parser = ArgumentParser()
- parser.add_argument('--jinja2')
parser.add_argument('--hdrparser')
parser.add_argument('--moduleroot', nargs='*', default=[], required=False)
parser.add_argument('--modules', nargs='*', default=[], required=False)
@@ -174,7 +171,6 @@ if __name__ == "__main__":
args = parser.parse_args()
# add the hdr_parser module to the path
- sys.path.append(args.jinja2)
sys.path.append(args.hdrparser)
# create the generator
diff --git a/contrib/modules/matlab/include/opencv2/matlab/bridge.hpp b/contrib/modules/matlab/include/opencv2/matlab/bridge.hpp
index e622fe9..be4ff68 100644
--- a/contrib/modules/matlab/include/opencv2/matlab/bridge.hpp
+++ b/contrib/modules/matlab/include/opencv2/matlab/bridge.hpp
@@ -95,7 +95,7 @@ typedef cv::Ptr<TonemapDrago> Ptr_TonemapDrago;
typedef cv::Ptr<TonemapDurand> Ptr_TonemapDurand;
typedef cv::Ptr<TonemapMantiuk> Ptr_TonemapMantiuk;
typedef cv::Ptr<TonemapReinhard> Ptr_TonemapReinhard;
-
+typedef cv::Ptr<float> Ptr_float;
// ----------------------------------------------------------------------------
// PREDECLARATIONS
@@ -522,6 +522,11 @@ public:
Bridge& operator=(const Ptr_TonemapReinhard& ) { return *this; }
Ptr_TonemapReinhard toPtrTonemapReinhard() { return Ptr_TonemapReinhard(); }
operator Ptr_TonemapReinhard() { return toPtrTonemapReinhard(); }
+
+ // --------------------------- Ptr_float ----------------------
+ Bridge& operator=(const Ptr_float& ) { return *this; }
+ Ptr_float toPtrFloat() { return Ptr_float(); }
+ operator Ptr_float() { return toPtrFloat(); }
}; // class Bridge
diff --git a/contrib/modules/optflow/CMakeLists.txt b/contrib/modules/optflow/CMakeLists.txt
index 41029bc..8cd4e10 100644
--- a/contrib/modules/optflow/CMakeLists.txt
+++ b/contrib/modules/optflow/CMakeLists.txt
@@ -1,2 +1,2 @@
set(the_description "Optical Flow Algorithms")
-ocv_define_module(optflow opencv_core opencv_imgproc opencv_video opencv_highgui opencv_ximgproc WRAP python)
+ocv_define_module(optflow opencv_core opencv_imgproc opencv_video opencv_ximgproc opencv_imgcodecs WRAP python)
diff --git a/contrib/modules/optflow/include/opencv2/optflow/sparse_matching_gpc.hpp b/contrib/modules/optflow/include/opencv2/optflow/sparse_matching_gpc.hpp
index 3127710..dd948b6 100644
--- a/contrib/modules/optflow/include/opencv2/optflow/sparse_matching_gpc.hpp
+++ b/contrib/modules/optflow/include/opencv2/optflow/sparse_matching_gpc.hpp
@@ -52,7 +52,6 @@ the use of this software, even if advised of the possibility of such damage.
#define __OPENCV_OPTFLOW_SPARSE_MATCHING_GPC_HPP__
#include "opencv2/core.hpp"
-#include "opencv2/core/hal/intrin.hpp"
#include "opencv2/imgproc.hpp"
namespace cv
diff --git a/contrib/modules/optflow/perf/opencl/perf_dis_optflow.cpp b/contrib/modules/optflow/perf/opencl/perf_dis_optflow.cpp
new file mode 100644
index 0000000..251129d
--- /dev/null
+++ b/contrib/modules/optflow/perf/opencl/perf_dis_optflow.cpp
@@ -0,0 +1,113 @@
+/*
+ * By downloading, copying, installing or using the software you agree to this license.
+ * If you do not agree to this license, do not download, install,
+ * copy or use the software.
+ *
+ *
+ * License Agreement
+ * For Open Source Computer Vision Library
+ * (3 - clause BSD License)
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met :
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and / or other materials provided with the distribution.
+ *
+ * * Neither the names of the copyright holders nor the names of the contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * This software is provided by the copyright holders and contributors "as is" and
+ * any express or implied warranties, including, but not limited to, the implied
+ * warranties of merchantability and fitness for a particular purpose are disclaimed.
+ * In no event shall copyright holders or contributors be liable for any direct,
+ * indirect, incidental, special, exemplary, or consequential damages
+ * (including, but not limited to, procurement of substitute goods or services;
+ * loss of use, data, or profits; or business interruption) however caused
+ * and on any theory of liability, whether in contract, strict liability,
+ * or tort(including negligence or otherwise) arising in any way out of
+ * the use of this software, even if advised of the possibility of such damage.
+ */
+
+#include "../perf_precomp.hpp"
+#include "opencv2/ts/ocl_perf.hpp"
+
+using std::tr1::tuple;
+using std::tr1::get;
+using namespace perf;
+using namespace testing;
+using namespace cv;
+using namespace cv::optflow;
+
+#ifdef HAVE_OPENCL
+
+namespace cvtest {
+namespace ocl {
+
+void MakeArtificialExample(UMat &dst_frame1, UMat &dst_frame2);
+
+typedef tuple<String, Size> DISParams;
+typedef TestBaseWithParam<DISParams> DenseOpticalFlow_DIS;
+
+OCL_PERF_TEST_P(DenseOpticalFlow_DIS, perf,
+ Combine(Values("PRESET_ULTRAFAST", "PRESET_FAST", "PRESET_MEDIUM"), Values(szVGA, sz720p, sz1080p)))
+{
+ DISParams params = GetParam();
+
+ // use strings to print preset names in the perf test results:
+ String preset_string = get<0>(params);
+ int preset = DISOpticalFlow::PRESET_FAST;
+ if (preset_string == "PRESET_ULTRAFAST")
+ preset = DISOpticalFlow::PRESET_ULTRAFAST;
+ else if (preset_string == "PRESET_FAST")
+ preset = DISOpticalFlow::PRESET_FAST;
+ else if (preset_string == "PRESET_MEDIUM")
+ preset = DISOpticalFlow::PRESET_MEDIUM;
+ Size sz = get<1>(params);
+
+ UMat frame1(sz, CV_8U);
+ UMat frame2(sz, CV_8U);
+ UMat flow;
+
+ MakeArtificialExample(frame1, frame2);
+
+ Ptr<DenseOpticalFlow> algo = createOptFlow_DIS(preset);
+
+ OCL_TEST_CYCLE_N(10)
+ {
+ algo->calc(frame1, frame2, flow);
+ }
+
+ SANITY_CHECK_NOTHING();
+}
+
+void MakeArtificialExample(UMat &dst_frame1, UMat &dst_frame2)
+{
+ int src_scale = 2;
+ int OF_scale = 6;
+ double sigma = dst_frame1.cols / 300;
+
+ UMat tmp(Size(dst_frame1.cols / (1 << src_scale), dst_frame1.rows / (1 << src_scale)), CV_8U);
+ randu(tmp, 0, 255);
+ resize(tmp, dst_frame1, dst_frame1.size(), 0.0, 0.0, INTER_LINEAR);
+ resize(tmp, dst_frame2, dst_frame2.size(), 0.0, 0.0, INTER_LINEAR);
+
+ Mat displacement_field(Size(dst_frame1.cols / (1 << OF_scale), dst_frame1.rows / (1 << OF_scale)),
+ CV_32FC2);
+ randn(displacement_field, 0.0, sigma);
+ resize(displacement_field, displacement_field, dst_frame2.size(), 0.0, 0.0, INTER_CUBIC);
+ for (int i = 0; i < displacement_field.rows; i++)
+ for (int j = 0; j < displacement_field.cols; j++)
+ displacement_field.at<Vec2f>(i, j) += Vec2f((float)j, (float)i);
+
+ remap(dst_frame2, dst_frame2, displacement_field, Mat(), INTER_LINEAR, BORDER_REPLICATE);
+}
+
+} } // namespace cvtest::ocl
+
+#endif // HAVE_OPENCL
diff --git a/contrib/modules/optflow/perf/perf_disflow.cpp b/contrib/modules/optflow/perf/perf_disflow.cpp
index 12a6203..5826c06 100644
--- a/contrib/modules/optflow/perf/perf_disflow.cpp
+++ b/contrib/modules/optflow/perf/perf_disflow.cpp
@@ -86,12 +86,12 @@ void MakeArtificialExample(Mat &dst_frame1, Mat &dst_frame2)
int OF_scale = 6;
double sigma = dst_frame1.cols / 300;
- Mat tmp(Size(dst_frame1.cols / (int)pow(2, src_scale), dst_frame1.rows / (int)pow(2, src_scale)), CV_8U);
+ Mat tmp(Size(dst_frame1.cols / (1 << src_scale), dst_frame1.rows / (1 << src_scale)), CV_8U);
randu(tmp, 0, 255);
resize(tmp, dst_frame1, dst_frame1.size(), 0.0, 0.0, INTER_LINEAR);
resize(tmp, dst_frame2, dst_frame2.size(), 0.0, 0.0, INTER_LINEAR);
- Mat displacement_field(Size(dst_frame1.cols / (int)pow(2, OF_scale), dst_frame1.rows / (int)pow(2, OF_scale)),
+ Mat displacement_field(Size(dst_frame1.cols / (1 << OF_scale), dst_frame1.rows / (1 << OF_scale)),
CV_32FC2);
randn(displacement_field, 0.0, sigma);
resize(displacement_field, displacement_field, dst_frame2.size(), 0.0, 0.0, INTER_CUBIC);
diff --git a/contrib/modules/optflow/samples/dis_opticalflow.cpp b/contrib/modules/optflow/samples/dis_opticalflow.cpp
new file mode 100644
index 0000000..1d4037c
--- /dev/null
+++ b/contrib/modules/optflow/samples/dis_opticalflow.cpp
@@ -0,0 +1,74 @@
+
+#include "opencv2/core/utility.hpp"
+#include "opencv2/highgui.hpp"
+#include "opencv2/imgproc.hpp"
+#include "opencv2/optflow.hpp"
+
+using namespace std;
+using namespace cv;
+using namespace optflow;
+
+static void help()
+{
+ printf("Usage: dis_optflow <video_file>\n");
+}
+
+int main(int argc, char **argv)
+{
+ VideoCapture cap;
+
+ if (argc < 2)
+ {
+ help();
+ exit(1);
+ }
+
+ cap.open(argv[1]);
+ if(!cap.isOpened())
+ {
+ printf("ERROR: Cannot open file %s\n", argv[1]);
+ return -1;
+ }
+
+ Mat prevgray, gray, rgb, frame;
+ Mat flow, flow_uv[2];
+ Mat mag, ang;
+ Mat hsv_split[3], hsv;
+ char ret;
+
+ namedWindow("flow", 1);
+ namedWindow("orig", 1);
+
+ Ptr<DenseOpticalFlow> algorithm = createOptFlow_DIS(DISOpticalFlow::PRESET_MEDIUM);
+
+ while(true)
+ {
+ cap >> frame;
+ if (frame.empty())
+ break;
+
+ cvtColor(frame, gray, COLOR_BGR2GRAY);
+
+ if (!prevgray.empty())
+ {
+ algorithm->calc(prevgray, gray, flow);
+ split(flow, flow_uv);
+ multiply(flow_uv[1], -1, flow_uv[1]);
+ cartToPolar(flow_uv[0], flow_uv[1], mag, ang, true);
+ normalize(mag, mag, 0, 1, NORM_MINMAX);
+ hsv_split[0] = ang;
+ hsv_split[1] = mag;
+ hsv_split[2] = Mat::ones(ang.size(), ang.type());
+ merge(hsv_split, 3, hsv);
+ cvtColor(hsv, rgb, COLOR_HSV2BGR);
+ imshow("flow", rgb);
+ imshow("orig", frame);
+ }
+
+ if ((ret = (char)waitKey(20)) > 0)
+ break;
+ std::swap(prevgray, gray);
+ }
+
+ return 0;
+}
diff --git a/contrib/modules/optflow/samples/gpc_evaluate.cpp b/contrib/modules/optflow/samples/gpc_evaluate.cpp
index 7a53e8f..f787103 100644
--- a/contrib/modules/optflow/samples/gpc_evaluate.cpp
+++ b/contrib/modules/optflow/samples/gpc_evaluate.cpp
@@ -114,6 +114,7 @@ int main( int argc, const char **argv )
std::cout << "Found " << corr.size() << " matches." << std::endl;
std::cout << "Time: " << meter.getTimeSec() << " sec." << std::endl;
double error = 0;
+ int totalCorrectFlowVectors = 0;
Mat dispErr = Mat::zeros( from.size(), CV_32FC3 );
dispErr = Scalar( 0, 0, 1 );
Mat disp = Mat::zeros( from.size(), CV_32FC3 );
@@ -123,13 +124,22 @@ int main( int argc, const char **argv )
{
const Point2f a = corr[i].first;
const Point2f b = corr[i].second;
- const Point2f c = a + gt.at< Point2f >( corr[i].first.y, corr[i].first.x );
- error += normL2( b - c );
+ const Point2f gtDisplacement = gt.at< Point2f >( corr[i].first.y, corr[i].first.x );
+
+ // Check that flow vector is correct
+ if (!cvIsNaN(gtDisplacement.x) && !cvIsNaN(gtDisplacement.y) && gtDisplacement.x < 1e9 && gtDisplacement.y < 1e9)
+ {
+ const Point2f c = a + gtDisplacement;
+ error += normL2( b - c );
+ circle( dispErr, a, 3, getFlowColor( b - c, false, 32 ), -1 );
+ ++totalCorrectFlowVectors;
+ }
+
circle( disp, a, 3, getFlowColor( b - a ), -1 );
- circle( dispErr, a, 3, getFlowColor( b - c, false, 32 ), -1 );
}
- error /= corr.size();
+ if (totalCorrectFlowVectors)
+ error /= totalCorrectFlowVectors;
std::cout << "Average endpoint error: " << error << " px." << std::endl;
diff --git a/contrib/modules/optflow/samples/motempl.py b/contrib/modules/optflow/samples/motempl.py
index 88fedf4..c1bbaaa 100755
--- a/contrib/modules/optflow/samples/motempl.py
+++ b/contrib/modules/optflow/samples/motempl.py
@@ -37,7 +37,8 @@ if __name__ == '__main__':
sys.exit(1)
ret, frame = cam.read()
if ret == False:
- break
+ print("could not read from " + str(video_src) + " !\n")
+ sys.exit(1)
h, w = frame.shape[:2]
prev_frame = frame.copy()
motion_history = np.zeros((h, w), np.float32)
@@ -45,6 +46,8 @@ if __name__ == '__main__':
hsv[:,:,1] = 255
while True:
ret, frame = cam.read()
+ if ret == False:
+ break
frame_diff = cv2.absdiff(frame, prev_frame)
gray_diff = cv2.cvtColor(frame_diff, cv2.COLOR_BGR2GRAY)
thrs = cv2.getTrackbarPos('threshold', 'motempl')
diff --git a/contrib/modules/optflow/src/deepflow.cpp b/contrib/modules/optflow/src/deepflow.cpp
index a813e5a..61b5101 100644
--- a/contrib/modules/optflow/src/deepflow.cpp
+++ b/contrib/modules/optflow/src/deepflow.cpp
@@ -41,7 +41,6 @@
//M*/
#include "precomp.hpp"
-#include <opencv2/highgui.hpp>
namespace cv
{
@@ -98,8 +97,7 @@ std::vector<Mat> OpticalFlowDeepFlow::buildPyramid( const Mat& src )
std::vector<Mat> pyramid;
pyramid.push_back(src);
Mat prev = pyramid[0];
- int i = 0;
- while ( i < this->maxLayers )
+ for( int i = 0; i < this->maxLayers; ++i)
{
Mat next; //TODO: filtering at each level?
Size nextSize((int) (prev.cols * downscaleFactor + 0.5f),
diff --git a/contrib/modules/optflow/src/dis_flow.cpp b/contrib/modules/optflow/src/dis_flow.cpp
index 3980a46..5b7f82c 100644
--- a/contrib/modules/optflow/src/dis_flow.cpp
+++ b/contrib/modules/optflow/src/dis_flow.cpp
@@ -40,8 +40,9 @@
//
//M*/
-#include "opencv2/core/hal/intrin.hpp"
#include "precomp.hpp"
+#include "opencl_kernels_optflow.hpp"
+
using namespace std;
#define EPS 0.001F
#define INF 1E+10F
@@ -166,6 +167,50 @@ class DISOpticalFlowImpl : public DISOpticalFlow
Mat &src_Sy, Mat &_I0, Mat &_I1);
void operator()(const Range &range) const;
};
+
+#ifdef HAVE_OPENCL
+ vector<UMat> u_I0s; //!< Gaussian pyramid for the current frame
+ vector<UMat> u_I1s; //!< Gaussian pyramid for the next frame
+ vector<UMat> u_I1s_ext; //!< I1s with borders
+
+ vector<UMat> u_I0xs; //!< Gaussian pyramid for the x gradient of the current frame
+ vector<UMat> u_I0ys; //!< Gaussian pyramid for the y gradient of the current frame
+
+ vector<UMat> u_Ux; //!< x component of the flow vectors
+ vector<UMat> u_Uy; //!< y component of the flow vectors
+
+ vector<UMat> u_initial_Ux; //!< x component of the initial flow field, if one was passed as an input
+ vector<UMat> u_initial_Uy; //!< y component of the initial flow field, if one was passed as an input
+
+ UMat u_U; //!< a buffer for the merged flow
+
+ UMat u_Sx; //!< intermediate sparse flow representation (x component)
+ UMat u_Sy; //!< intermediate sparse flow representation (y component)
+
+ /* Structure tensor components: */
+ UMat u_I0xx_buf; //!< sum of squares of x gradient values
+ UMat u_I0yy_buf; //!< sum of squares of y gradient values
+ UMat u_I0xy_buf; //!< sum of x and y gradient products
+
+ /* Extra buffers that are useful if patch mean-normalization is used: */
+ UMat u_I0x_buf; //!< sum of x gradient values
+ UMat u_I0y_buf; //!< sum of y gradient values
+
+ /* Auxiliary buffers used in structure tensor computation: */
+ UMat u_I0xx_buf_aux;
+ UMat u_I0yy_buf_aux;
+ UMat u_I0xy_buf_aux;
+ UMat u_I0x_buf_aux;
+ UMat u_I0y_buf_aux;
+
+ bool ocl_precomputeStructureTensor(UMat &dst_I0xx, UMat &dst_I0yy, UMat &dst_I0xy,
+ UMat &dst_I0x, UMat &dst_I0y, UMat &I0x, UMat &I0y);
+ void ocl_prepareBuffers(UMat &I0, UMat &I1, UMat &flow, bool use_flow);
+ bool ocl_calc(InputArray I0, InputArray I1, InputOutputArray flow);
+ bool ocl_Densification(UMat &dst_Ux, UMat &dst_Uy, UMat &src_Sx, UMat &src_Sy, UMat &_I0, UMat &_I1);
+ bool ocl_PatchInverseSearch(UMat &src_Ux, UMat &src_Uy,
+ UMat &I0, UMat &I1, UMat &I0x, UMat &I0y, int num_iter, int pyr_level);
+#endif
};
DISOpticalFlowImpl::DISOpticalFlowImpl()
@@ -1004,6 +1049,319 @@ void DISOpticalFlowImpl::Densification_ParBody::operator()(const Range &range) c
#undef UPDATE_SPARSE_J_COORDINATES
}
+#ifdef HAVE_OPENCL
+bool DISOpticalFlowImpl::ocl_PatchInverseSearch(UMat &src_Ux, UMat &src_Uy,
+ UMat &I0, UMat &I1, UMat &I0x, UMat &I0y, int num_iter, int pyr_level)
+{
+ size_t globalSize[] = {(size_t)ws, (size_t)hs};
+ size_t localSize[] = {16, 16};
+ int idx;
+ int num_inner_iter = (int)floor(grad_descent_iter / (float)num_iter);
+
+ for (int iter = 0; iter < num_iter; iter++)
+ {
+ if (iter == 0)
+ {
+ ocl::Kernel k1("dis_patch_inverse_search_fwd_1", ocl::optflow::dis_flow_oclsrc);
+ size_t global_sz[] = {(size_t)hs * 8};
+ size_t local_sz[] = {8};
+ idx = 0;
+
+ idx = k1.set(idx, ocl::KernelArg::PtrReadOnly(src_Ux));
+ idx = k1.set(idx, ocl::KernelArg::PtrReadOnly(src_Uy));
+ idx = k1.set(idx, ocl::KernelArg::PtrReadOnly(I0));
+ idx = k1.set(idx, ocl::KernelArg::PtrReadOnly(I1));
+ idx = k1.set(idx, (int)border_size);
+ idx = k1.set(idx, (int)patch_size);
+ idx = k1.set(idx, (int)patch_stride);
+ idx = k1.set(idx, (int)w);
+ idx = k1.set(idx, (int)h);
+ idx = k1.set(idx, (int)ws);
+ idx = k1.set(idx, (int)hs);
+ idx = k1.set(idx, (int)pyr_level);
+ idx = k1.set(idx, ocl::KernelArg::PtrWriteOnly(u_Sx));
+ idx = k1.set(idx, ocl::KernelArg::PtrWriteOnly(u_Sy));
+ if (!k1.run(1, global_sz, local_sz, false))
+ return false;
+
+ ocl::Kernel k2("dis_patch_inverse_search_fwd_2", ocl::optflow::dis_flow_oclsrc);
+ idx = 0;
+
+ idx = k2.set(idx, ocl::KernelArg::PtrReadOnly(src_Ux));
+ idx = k2.set(idx, ocl::KernelArg::PtrReadOnly(src_Uy));
+ idx = k2.set(idx, ocl::KernelArg::PtrReadOnly(I0));
+ idx = k2.set(idx, ocl::KernelArg::PtrReadOnly(I1));
+ idx = k2.set(idx, ocl::KernelArg::PtrReadOnly(I0x));
+ idx = k2.set(idx, ocl::KernelArg::PtrReadOnly(I0y));
+ idx = k2.set(idx, ocl::KernelArg::PtrReadOnly(u_I0xx_buf));
+ idx = k2.set(idx, ocl::KernelArg::PtrReadOnly(u_I0yy_buf));
+ idx = k2.set(idx, ocl::KernelArg::PtrReadOnly(u_I0xy_buf));
+ idx = k2.set(idx, ocl::KernelArg::PtrReadOnly(u_I0x_buf));
+ idx = k2.set(idx, ocl::KernelArg::PtrReadOnly(u_I0y_buf));
+ idx = k2.set(idx, (int)border_size);
+ idx = k2.set(idx, (int)patch_size);
+ idx = k2.set(idx, (int)patch_stride);
+ idx = k2.set(idx, (int)w);
+ idx = k2.set(idx, (int)h);
+ idx = k2.set(idx, (int)ws);
+ idx = k2.set(idx, (int)hs);
+ idx = k2.set(idx, (int)num_inner_iter);
+ idx = k2.set(idx, (int)pyr_level);
+ idx = k2.set(idx, ocl::KernelArg::PtrReadWrite(u_Sx));
+ idx = k2.set(idx, ocl::KernelArg::PtrReadWrite(u_Sy));
+ if (!k2.run(2, globalSize, localSize, false))
+ return false;
+ }
+ else
+ {
+ ocl::Kernel k3("dis_patch_inverse_search_bwd_1", ocl::optflow::dis_flow_oclsrc);
+ size_t global_sz[] = {(size_t)hs * 8};
+ size_t local_sz[] = {8};
+ idx = 0;
+
+ idx = k3.set(idx, ocl::KernelArg::PtrReadOnly(I0));
+ idx = k3.set(idx, ocl::KernelArg::PtrReadOnly(I1));
+ idx = k3.set(idx, (int)border_size);
+ idx = k3.set(idx, (int)patch_size);
+ idx = k3.set(idx, (int)patch_stride);
+ idx = k3.set(idx, (int)w);
+ idx = k3.set(idx, (int)h);
+ idx = k3.set(idx, (int)ws);
+ idx = k3.set(idx, (int)hs);
+ idx = k3.set(idx, (int)pyr_level);
+ idx = k3.set(idx, ocl::KernelArg::PtrReadWrite(u_Sx));
+ idx = k3.set(idx, ocl::KernelArg::PtrReadWrite(u_Sy));
+ if (!k3.run(1, global_sz, local_sz, false))
+ return false;
+
+ ocl::Kernel k4("dis_patch_inverse_search_bwd_2", ocl::optflow::dis_flow_oclsrc);
+ idx = 0;
+
+ idx = k4.set(idx, ocl::KernelArg::PtrReadOnly(I0));
+ idx = k4.set(idx, ocl::KernelArg::PtrReadOnly(I1));
+ idx = k4.set(idx, ocl::KernelArg::PtrReadOnly(I0x));
+ idx = k4.set(idx, ocl::KernelArg::PtrReadOnly(I0y));
+ idx = k4.set(idx, ocl::KernelArg::PtrReadOnly(u_I0xx_buf));
+ idx = k4.set(idx, ocl::KernelArg::PtrReadOnly(u_I0yy_buf));
+ idx = k4.set(idx, ocl::KernelArg::PtrReadOnly(u_I0xy_buf));
+ idx = k4.set(idx, ocl::KernelArg::PtrReadOnly(u_I0x_buf));
+ idx = k4.set(idx, ocl::KernelArg::PtrReadOnly(u_I0y_buf));
+ idx = k4.set(idx, (int)border_size);
+ idx = k4.set(idx, (int)patch_size);
+ idx = k4.set(idx, (int)patch_stride);
+ idx = k4.set(idx, (int)w);
+ idx = k4.set(idx, (int)h);
+ idx = k4.set(idx, (int)ws);
+ idx = k4.set(idx, (int)hs);
+ idx = k4.set(idx, (int)num_inner_iter);
+ idx = k4.set(idx, ocl::KernelArg::PtrReadWrite(u_Sx));
+ idx = k4.set(idx, ocl::KernelArg::PtrReadWrite(u_Sy));
+ if (!k4.run(2, globalSize, localSize, false))
+ return false;
+ }
+ }
+ return true;
+}
+
+bool DISOpticalFlowImpl::ocl_Densification(UMat &dst_Ux, UMat &dst_Uy, UMat &src_Sx, UMat &src_Sy, UMat &_I0, UMat &_I1)
+{
+ size_t globalSize[] = {(size_t)w, (size_t)h};
+ size_t localSize[] = {16, 16};
+
+ ocl::Kernel kernel("dis_densification", ocl::optflow::dis_flow_oclsrc);
+ kernel.args(ocl::KernelArg::PtrReadOnly(src_Sx),
+ ocl::KernelArg::PtrReadOnly(src_Sy),
+ ocl::KernelArg::PtrReadOnly(_I0),
+ ocl::KernelArg::PtrReadOnly(_I1),
+ (int)patch_size, (int)patch_stride,
+ (int)w, (int)h, (int)ws,
+ ocl::KernelArg::PtrWriteOnly(dst_Ux),
+ ocl::KernelArg::PtrWriteOnly(dst_Uy));
+ return kernel.run(2, globalSize, localSize, false);
+}
+
+void DISOpticalFlowImpl::ocl_prepareBuffers(UMat &I0, UMat &I1, UMat &flow, bool use_flow)
+{
+ u_I0s.resize(coarsest_scale + 1);
+ u_I1s.resize(coarsest_scale + 1);
+ u_I1s_ext.resize(coarsest_scale + 1);
+ u_I0xs.resize(coarsest_scale + 1);
+ u_I0ys.resize(coarsest_scale + 1);
+ u_Ux.resize(coarsest_scale + 1);
+ u_Uy.resize(coarsest_scale + 1);
+
+ vector<UMat> flow_uv(2);
+ if (use_flow)
+ {
+ split(flow, flow_uv);
+ u_initial_Ux.resize(coarsest_scale + 1);
+ u_initial_Uy.resize(coarsest_scale + 1);
+ }
+
+ int fraction = 1;
+ int cur_rows = 0, cur_cols = 0;
+
+ for (int i = 0; i <= coarsest_scale; i++)
+ {
+ /* Avoid initializing the pyramid levels above the finest scale, as they won't be used anyway */
+ if (i == finest_scale)
+ {
+ cur_rows = I0.rows / fraction;
+ cur_cols = I0.cols / fraction;
+ u_I0s[i].create(cur_rows, cur_cols, CV_8UC1);
+ resize(I0, u_I0s[i], u_I0s[i].size(), 0.0, 0.0, INTER_AREA);
+ u_I1s[i].create(cur_rows, cur_cols, CV_8UC1);
+ resize(I1, u_I1s[i], u_I1s[i].size(), 0.0, 0.0, INTER_AREA);
+
+ /* These buffers are reused in each scale so we initialize them once on the finest scale: */
+ u_Sx.create(cur_rows / patch_stride, cur_cols / patch_stride, CV_32FC1);
+ u_Sy.create(cur_rows / patch_stride, cur_cols / patch_stride, CV_32FC1);
+ u_I0xx_buf.create(cur_rows / patch_stride, cur_cols / patch_stride, CV_32FC1);
+ u_I0yy_buf.create(cur_rows / patch_stride, cur_cols / patch_stride, CV_32FC1);
+ u_I0xy_buf.create(cur_rows / patch_stride, cur_cols / patch_stride, CV_32FC1);
+ u_I0x_buf.create(cur_rows / patch_stride, cur_cols / patch_stride, CV_32FC1);
+ u_I0y_buf.create(cur_rows / patch_stride, cur_cols / patch_stride, CV_32FC1);
+
+ u_I0xx_buf_aux.create(cur_rows, cur_cols / patch_stride, CV_32FC1);
+ u_I0yy_buf_aux.create(cur_rows, cur_cols / patch_stride, CV_32FC1);
+ u_I0xy_buf_aux.create(cur_rows, cur_cols / patch_stride, CV_32FC1);
+ u_I0x_buf_aux.create(cur_rows, cur_cols / patch_stride, CV_32FC1);
+ u_I0y_buf_aux.create(cur_rows, cur_cols / patch_stride, CV_32FC1);
+
+ u_U.create(cur_rows, cur_cols, CV_32FC2);
+ }
+ else if (i > finest_scale)
+ {
+ cur_rows = u_I0s[i - 1].rows / 2;
+ cur_cols = u_I0s[i - 1].cols / 2;
+ u_I0s[i].create(cur_rows, cur_cols, CV_8UC1);
+ resize(u_I0s[i - 1], u_I0s[i], u_I0s[i].size(), 0.0, 0.0, INTER_AREA);
+ u_I1s[i].create(cur_rows, cur_cols, CV_8UC1);
+ resize(u_I1s[i - 1], u_I1s[i], u_I1s[i].size(), 0.0, 0.0, INTER_AREA);
+ }
+
+ if (i >= finest_scale)
+ {
+ u_I1s_ext[i].create(cur_rows + 2 * border_size, cur_cols + 2 * border_size, CV_8UC1);
+ copyMakeBorder(u_I1s[i], u_I1s_ext[i], border_size, border_size, border_size, border_size, BORDER_REPLICATE);
+ u_I0xs[i].create(cur_rows, cur_cols, CV_16SC1);
+ u_I0ys[i].create(cur_rows, cur_cols, CV_16SC1);
+ spatialGradient(u_I0s[i], u_I0xs[i], u_I0ys[i]);
+ u_Ux[i].create(cur_rows, cur_cols, CV_32FC1);
+ u_Uy[i].create(cur_rows, cur_cols, CV_32FC1);
+ variational_refinement_processors[i]->setAlpha(variational_refinement_alpha);
+ variational_refinement_processors[i]->setDelta(variational_refinement_delta);
+ variational_refinement_processors[i]->setGamma(variational_refinement_gamma);
+ variational_refinement_processors[i]->setSorIterations(5);
+ variational_refinement_processors[i]->setFixedPointIterations(variational_refinement_iter);
+
+ if (use_flow)
+ {
+ resize(flow_uv[0], u_initial_Ux[i], Size(cur_cols, cur_rows));
+ divide(u_initial_Ux[i], static_cast<float>(fraction), u_initial_Ux[i]);
+ resize(flow_uv[1], u_initial_Uy[i], Size(cur_cols, cur_rows));
+ divide(u_initial_Uy[i], static_cast<float>(fraction), u_initial_Uy[i]);
+ }
+ }
+
+ fraction *= 2;
+ }
+}
+
+bool DISOpticalFlowImpl::ocl_precomputeStructureTensor(UMat &dst_I0xx, UMat &dst_I0yy, UMat &dst_I0xy,
+ UMat &dst_I0x, UMat &dst_I0y, UMat &I0x, UMat &I0y)
+{
+ size_t globalSizeX[] = {(size_t)h};
+ size_t localSizeX[] = {16};
+
+ ocl::Kernel kernelX("dis_precomputeStructureTensor_hor", ocl::optflow::dis_flow_oclsrc);
+ kernelX.args(ocl::KernelArg::PtrReadOnly(I0x),
+ ocl::KernelArg::PtrReadOnly(I0y),
+ (int)patch_size, (int)patch_stride,
+ (int)w, (int)h, (int)ws,
+ ocl::KernelArg::PtrWriteOnly(u_I0xx_buf_aux),
+ ocl::KernelArg::PtrWriteOnly(u_I0yy_buf_aux),
+ ocl::KernelArg::PtrWriteOnly(u_I0xy_buf_aux),
+ ocl::KernelArg::PtrWriteOnly(u_I0x_buf_aux),
+ ocl::KernelArg::PtrWriteOnly(u_I0y_buf_aux));
+ if (!kernelX.run(1, globalSizeX, localSizeX, false))
+ return false;
+
+ size_t globalSizeY[] = {(size_t)ws};
+ size_t localSizeY[] = {16};
+
+ ocl::Kernel kernelY("dis_precomputeStructureTensor_ver", ocl::optflow::dis_flow_oclsrc);
+ kernelY.args(ocl::KernelArg::PtrReadOnly(u_I0xx_buf_aux),
+ ocl::KernelArg::PtrReadOnly(u_I0yy_buf_aux),
+ ocl::KernelArg::PtrReadOnly(u_I0xy_buf_aux),
+ ocl::KernelArg::PtrReadOnly(u_I0x_buf_aux),
+ ocl::KernelArg::PtrReadOnly(u_I0y_buf_aux),
+ (int)patch_size, (int)patch_stride,
+ (int)w, (int)h, (int)ws,
+ ocl::KernelArg::PtrWriteOnly(dst_I0xx),
+ ocl::KernelArg::PtrWriteOnly(dst_I0yy),
+ ocl::KernelArg::PtrWriteOnly(dst_I0xy),
+ ocl::KernelArg::PtrWriteOnly(dst_I0x),
+ ocl::KernelArg::PtrWriteOnly(dst_I0y));
+ return kernelY.run(1, globalSizeY, localSizeY, false);
+}
+
+bool DISOpticalFlowImpl::ocl_calc(InputArray I0, InputArray I1, InputOutputArray flow)
+{
+ UMat I0Mat = I0.getUMat();
+ UMat I1Mat = I1.getUMat();
+ bool use_input_flow = false;
+ if (flow.sameSize(I0) && flow.depth() == CV_32F && flow.channels() == 2)
+ use_input_flow = true;
+ else
+ flow.create(I1Mat.size(), CV_32FC2);
+ UMat &u_flowMat = flow.getUMatRef();
+ coarsest_scale = (int)(log((2 * I0Mat.cols) / (4.0 * patch_size)) / log(2.0) + 0.5) - 1;
+
+ ocl_prepareBuffers(I0Mat, I1Mat, u_flowMat, use_input_flow);
+ u_Ux[coarsest_scale].setTo(0.0f);
+ u_Uy[coarsest_scale].setTo(0.0f);
+
+ for (int i = coarsest_scale; i >= finest_scale; i--)
+ {
+ w = u_I0s[i].cols;
+ h = u_I0s[i].rows;
+ ws = 1 + (w - patch_size) / patch_stride;
+ hs = 1 + (h - patch_size) / patch_stride;
+
+ if (!ocl_precomputeStructureTensor(u_I0xx_buf, u_I0yy_buf, u_I0xy_buf,
+ u_I0x_buf, u_I0y_buf, u_I0xs[i], u_I0ys[i]))
+ return false;
+
+ if (!ocl_PatchInverseSearch(u_Ux[i], u_Uy[i], u_I0s[i], u_I1s_ext[i], u_I0xs[i], u_I0ys[i], 2, i))
+ return false;
+
+ if (!ocl_Densification(u_Ux[i], u_Uy[i], u_Sx, u_Sy, u_I0s[i], u_I1s[i]))
+ return false;
+
+ if (variational_refinement_iter > 0)
+ variational_refinement_processors[i]->calcUV(u_I0s[i], u_I1s[i],
+ u_Ux[i].getMat(ACCESS_WRITE), u_Uy[i].getMat(ACCESS_WRITE));
+
+ if (i > finest_scale)
+ {
+ resize(u_Ux[i], u_Ux[i - 1], u_Ux[i - 1].size());
+ resize(u_Uy[i], u_Uy[i - 1], u_Uy[i - 1].size());
+ multiply(u_Ux[i - 1], 2, u_Ux[i - 1]);
+ multiply(u_Uy[i - 1], 2, u_Uy[i - 1]);
+ }
+ }
+ vector<UMat> uxy(2);
+ uxy[0] = u_Ux[finest_scale];
+ uxy[1] = u_Uy[finest_scale];
+ merge(uxy, u_U);
+ resize(u_U, u_flowMat, u_flowMat.size());
+ multiply(u_flowMat, 1 << finest_scale, u_flowMat);
+
+ return true;
+}
+#endif
+
void DISOpticalFlowImpl::calc(InputArray I0, InputArray I1, InputOutputArray flow)
{
CV_Assert(!I0.empty() && I0.depth() == CV_8U && I0.channels() == 1);
@@ -1012,6 +1370,10 @@ void DISOpticalFlowImpl::calc(InputArray I0, InputArray I1, InputOutputArray flo
CV_Assert(I0.isContinuous());
CV_Assert(I1.isContinuous());
+ CV_OCL_RUN(ocl::Device::getDefault().isIntel() && flow.isUMat() &&
+ (patch_size == 8) && (use_spatial_propagation == true),
+ ocl_calc(I0, I1, flow));
+
Mat I0Mat = I0.getMat();
Mat I1Mat = I1.getMat();
bool use_input_flow = false;
@@ -1019,7 +1381,7 @@ void DISOpticalFlowImpl::calc(InputArray I0, InputArray I1, InputOutputArray flo
use_input_flow = true;
else
flow.create(I1Mat.size(), CV_32FC2);
- Mat &flowMat = flow.getMatRef();
+ Mat flowMat = flow.getMat();
coarsest_scale = (int)(log((2 * I0Mat.cols) / (4.0 * patch_size)) / log(2.0) + 0.5) - 1;
int num_stripes = getNumThreads();
@@ -1088,6 +1450,25 @@ void DISOpticalFlowImpl::collectGarbage()
I0yy_buf_aux.release();
I0xy_buf_aux.release();
+#ifdef HAVE_OPENCL
+ u_I0s.clear();
+ u_I1s.clear();
+ u_I1s_ext.clear();
+ u_I0xs.clear();
+ u_I0ys.clear();
+ u_Ux.clear();
+ u_Uy.clear();
+ u_U.release();
+ u_Sx.release();
+ u_Sy.release();
+ u_I0xx_buf.release();
+ u_I0yy_buf.release();
+ u_I0xy_buf.release();
+ u_I0xx_buf_aux.release();
+ u_I0yy_buf_aux.release();
+ u_I0xy_buf_aux.release();
+#endif
+
for (int i = finest_scale; i <= coarsest_scale; i++)
variational_refinement_processors[i]->collectGarbage();
variational_refinement_processors.clear();
diff --git a/contrib/modules/optflow/src/interfaces.cpp b/contrib/modules/optflow/src/interfaces.cpp
index d2830eb..4d9a1ce 100644
--- a/contrib/modules/optflow/src/interfaces.cpp
+++ b/contrib/modules/optflow/src/interfaces.cpp
@@ -42,7 +42,6 @@
#include "precomp.hpp"
#include "opencv2/core.hpp"
-#include "opencv2/highgui.hpp"
#include "opencv2/video.hpp"
#include "opencv2/optflow.hpp"
diff --git a/contrib/modules/optflow/src/opencl/dis_flow.cl b/contrib/modules/optflow/src/opencl/dis_flow.cl
new file mode 100644
index 0000000..54c642d
--- /dev/null
+++ b/contrib/modules/optflow/src/opencl/dis_flow.cl
@@ -0,0 +1,522 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#define EPS 0.001f
+#define INF 1E+10F
+
+__kernel void dis_precomputeStructureTensor_hor(__global const short *I0x,
+ __global const short *I0y,
+ int patch_size, int patch_stride,
+ int w, int h, int ws,
+ __global float *I0xx_aux_ptr,
+ __global float *I0yy_aux_ptr,
+ __global float *I0xy_aux_ptr,
+ __global float *I0x_aux_ptr,
+ __global float *I0y_aux_ptr)
+{
+
+ int i = get_global_id(0);
+
+ if (i >= h) return;
+
+ const __global short *x_row = I0x + i * w;
+ const __global short *y_row = I0y + i * w;
+
+ float sum_xx = 0.0f, sum_yy = 0.0f, sum_xy = 0.0f, sum_x = 0.0f, sum_y = 0.0f;
+ float8 x_vec = convert_float8(vload8(0, x_row));
+ float8 y_vec = convert_float8(vload8(0, y_row));
+ sum_xx = dot(x_vec.lo, x_vec.lo) + dot(x_vec.hi, x_vec.hi);
+ sum_yy = dot(y_vec.lo, y_vec.lo) + dot(y_vec.hi, y_vec.hi);
+ sum_xy = dot(x_vec.lo, y_vec.lo) + dot(x_vec.hi, y_vec.hi);
+ sum_x = dot(x_vec.lo, 1.0f) + dot(x_vec.hi, 1.0f);
+ sum_y = dot(y_vec.lo, 1.0f) + dot(y_vec.hi, 1.0f);
+
+ I0xx_aux_ptr[i * ws] = sum_xx;
+ I0yy_aux_ptr[i * ws] = sum_yy;
+ I0xy_aux_ptr[i * ws] = sum_xy;
+ I0x_aux_ptr[i * ws] = sum_x;
+ I0y_aux_ptr[i * ws] = sum_y;
+
+ int js = 1;
+ for (int j = patch_size; j < w; j++)
+ {
+ short x_val1 = x_row[j];
+ short x_val2 = x_row[j - patch_size];
+ short y_val1 = y_row[j];
+ short y_val2 = y_row[j - patch_size];
+ sum_xx += (x_val1 * x_val1 - x_val2 * x_val2);
+ sum_yy += (y_val1 * y_val1 - y_val2 * y_val2);
+ sum_xy += (x_val1 * y_val1 - x_val2 * y_val2);
+ sum_x += (x_val1 - x_val2);
+ sum_y += (y_val1 - y_val2);
+ if ((j - patch_size + 1) % patch_stride == 0)
+ {
+ int index = i * ws + js;
+ I0xx_aux_ptr[index] = sum_xx;
+ I0yy_aux_ptr[index] = sum_yy;
+ I0xy_aux_ptr[index] = sum_xy;
+ I0x_aux_ptr[index] = sum_x;
+ I0y_aux_ptr[index] = sum_y;
+ js++;
+ }
+ }
+}
+
+__kernel void dis_precomputeStructureTensor_ver(__global const float *I0xx_aux_ptr,
+ __global const float *I0yy_aux_ptr,
+ __global const float *I0xy_aux_ptr,
+ __global const float *I0x_aux_ptr,
+ __global const float *I0y_aux_ptr,
+ int patch_size, int patch_stride,
+ int w, int h, int ws,
+ __global float *I0xx_ptr,
+ __global float *I0yy_ptr,
+ __global float *I0xy_ptr,
+ __global float *I0x_ptr,
+ __global float *I0y_ptr)
+{
+ int j = get_global_id(0);
+
+ if (j >= ws) return;
+
+ float sum_xx, sum_yy, sum_xy, sum_x, sum_y;
+ sum_xx = sum_yy = sum_xy = sum_x = sum_y = 0.0f;
+
+ for (int i = 0; i < patch_size; i++)
+ {
+ sum_xx += I0xx_aux_ptr[i * ws + j];
+ sum_yy += I0yy_aux_ptr[i * ws + j];
+ sum_xy += I0xy_aux_ptr[i * ws + j];
+ sum_x += I0x_aux_ptr[i * ws + j];
+ sum_y += I0y_aux_ptr[i * ws + j];
+ }
+ I0xx_ptr[j] = sum_xx;
+ I0yy_ptr[j] = sum_yy;
+ I0xy_ptr[j] = sum_xy;
+ I0x_ptr[j] = sum_x;
+ I0y_ptr[j] = sum_y;
+
+ int is = 1;
+ for (int i = patch_size; i < h; i++)
+ {
+ sum_xx += (I0xx_aux_ptr[i * ws + j] - I0xx_aux_ptr[(i - patch_size) * ws + j]);
+ sum_yy += (I0yy_aux_ptr[i * ws + j] - I0yy_aux_ptr[(i - patch_size) * ws + j]);
+ sum_xy += (I0xy_aux_ptr[i * ws + j] - I0xy_aux_ptr[(i - patch_size) * ws + j]);
+ sum_x += (I0x_aux_ptr[i * ws + j] - I0x_aux_ptr[(i - patch_size) * ws + j]);
+ sum_y += (I0y_aux_ptr[i * ws + j] - I0y_aux_ptr[(i - patch_size) * ws + j]);
+
+ if ((i - patch_size + 1) % patch_stride == 0)
+ {
+ I0xx_ptr[is * ws + j] = sum_xx;
+ I0yy_ptr[is * ws + j] = sum_yy;
+ I0xy_ptr[is * ws + j] = sum_xy;
+ I0x_ptr[is * ws + j] = sum_x;
+ I0y_ptr[is * ws + j] = sum_y;
+ is++;
+ }
+ }
+}
+
+__kernel void dis_densification(__global const float *sx, __global const float *sy,
+ __global const uchar *i0, __global const uchar *i1,
+ int psz, int pstr,
+ int w, int h, int ws,
+ __global float *ux, __global float *uy)
+{
+ int x = get_global_id(0);
+ int y = get_global_id(1);
+ int i, j;
+
+ if (x >= w || y >= h) return;
+
+ int start_is, end_is;
+ int start_js, end_js;
+
+ end_is = min(y / pstr, (h - psz) / pstr);
+ start_is = max(0, y - psz + pstr) / pstr;
+ start_is = min(start_is, end_is);
+
+ end_js = min(x / pstr, (w - psz) / pstr);
+ start_js = max(0, x - psz + pstr) / pstr;
+ start_js = min(start_js, end_js);
+
+ float coef, sum_coef = 0.0f;
+ float sum_Ux = 0.0f;
+ float sum_Uy = 0.0f;
+
+ int i_l, i_u;
+ int j_l, j_u;
+ float i_m, j_m, diff;
+
+ i = y;
+ j = x;
+
+ /* Iterate through all the patches that overlap the current location (i,j) */
+ for (int is = start_is; is <= end_is; is++)
+ for (int js = start_js; js <= end_js; js++)
+ {
+ float sx_val = sx[is * ws + js];
+ float sy_val = sy[is * ws + js];
+ uchar2 i1_vec1, i1_vec2;
+
+ j_m = min(max(j + sx_val, 0.0f), w - 1.0f - EPS);
+ i_m = min(max(i + sy_val, 0.0f), h - 1.0f - EPS);
+ j_l = (int)j_m;
+ j_u = j_l + 1;
+ i_l = (int)i_m;
+ i_u = i_l + 1;
+ i1_vec1 = vload2(0, i1 + i_u * w + j_l);
+ i1_vec2 = vload2(0, i1 + i_l * w + j_l);
+ diff = (j_m - j_l) * (i_m - i_l) * i1_vec1.y +
+ (j_u - j_m) * (i_m - i_l) * i1_vec1.x +
+ (j_m - j_l) * (i_u - i_m) * i1_vec2.y +
+ (j_u - j_m) * (i_u - i_m) * i1_vec2.x - i0[i * w + j];
+ coef = 1 / max(1.0f, fabs(diff));
+ sum_Ux += coef * sx_val;
+ sum_Uy += coef * sy_val;
+ sum_coef += coef;
+ }
+
+ ux[i * w + j] = sum_Ux / sum_coef;
+ uy[i * w + j] = sum_Uy / sum_coef;
+}
+
+#define INIT_BILINEAR_WEIGHTS(Ux, Uy) \
+ i_I1 = min(max(i + Uy + bsz, i_lower_limit), i_upper_limit); \
+ j_I1 = min(max(j + Ux + bsz, j_lower_limit), j_upper_limit); \
+ \
+ w11 = (i_I1 - floor(i_I1)) * (j_I1 - floor(j_I1)); \
+ w10 = (i_I1 - floor(i_I1)) * (floor(j_I1) + 1 - j_I1); \
+ w01 = (floor(i_I1) + 1 - i_I1) * (j_I1 - floor(j_I1)); \
+ w00 = (floor(i_I1) + 1 - i_I1) * (floor(j_I1) + 1 - j_I1);
+
+float computeSSDMeanNorm(const __global uchar *I0_ptr, const __global uchar *I1_ptr,
+ int I0_stride, int I1_stride,
+ float w00, float w01, float w10, float w11, int patch_sz, int i)
+{
+ float sum_diff = 0.0f, sum_diff_sq = 0.0f;
+ int n = patch_sz * patch_sz;
+
+ uchar8 I1_vec1, I1_vec2, I0_vec;
+ uchar I1_val1, I1_val2;
+
+ I0_vec = vload8(0, I0_ptr + i * I0_stride);
+ I1_vec1 = vload8(0, I1_ptr + i * I1_stride);
+ I1_vec2 = vload8(0, I1_ptr + (i + 1) * I1_stride);
+ I1_val1 = I1_ptr[i * I1_stride + 8];
+ I1_val2 = I1_ptr[(i + 1) * I1_stride + 8];
+
+ float8 vec = w00 * convert_float8(I1_vec1) + w01 * convert_float8((uchar8)(I1_vec1.s123, I1_vec1.s4567, I1_val1)) +
+ w10 * convert_float8(I1_vec2) + w11 * convert_float8((uchar8)(I1_vec2.s123, I1_vec2.s4567, I1_val2)) -
+ convert_float8(I0_vec);
+
+ sum_diff = (dot(vec.lo, 1.0) + dot(vec.hi, 1.0));
+ sum_diff_sq = (dot(vec.lo, vec.lo) + dot(vec.hi, vec.hi));
+
+ sum_diff = sub_group_reduce_add(sum_diff);
+ sum_diff_sq = sub_group_reduce_add(sum_diff_sq);
+
+ return sum_diff_sq - sum_diff * sum_diff / n;
+}
+
+__kernel void dis_patch_inverse_search_fwd_1(__global const float *Ux_ptr, __global const float *Uy_ptr,
+ __global const uchar *I0_ptr, __global const uchar *I1_ptr,
+ int border_size, int patch_size, int patch_stride,
+ int w, int h, int ws, int hs, int pyr_level,
+ __global float *Sx_ptr, __global float *Sy_ptr)
+{
+ int id = get_global_id(0);
+ int is = id / 8;
+ if (id >= (hs * 8)) return;
+
+ int i = is * patch_stride;
+ int j = 0;
+ int psz = patch_size;
+ int psz2 = psz / 2;
+ int w_ext = w + 2 * border_size;
+ int bsz = border_size;
+
+ float i_lower_limit = bsz - psz + 1.0f;
+ float i_upper_limit = bsz + h - 1.0f;
+ float j_lower_limit = bsz - psz + 1.0f;
+ float j_upper_limit = bsz + w - 1.0f;
+ float i_I1, j_I1, w00, w01, w10, w11;
+
+ float prev_Ux = Ux_ptr[(i + psz2) * w + j + psz2];
+ float prev_Uy = Uy_ptr[(i + psz2) * w + j + psz2];
+ Sx_ptr[is * ws] = prev_Ux;
+ Sy_ptr[is * ws] = prev_Uy;
+ j += patch_stride;
+
+ int sid = get_sub_group_local_id();
+ for (int js = 1; js < ws; js++, j += patch_stride)
+ {
+ float min_SSD, cur_SSD;
+ float Ux = Ux_ptr[(i + psz2) * w + j + psz2];
+ float Uy = Uy_ptr[(i + psz2) * w + j + psz2];
+
+ INIT_BILINEAR_WEIGHTS(Ux, Uy);
+ min_SSD = computeSSDMeanNorm(I0_ptr + i * w + j, I1_ptr + (int)i_I1 * w_ext + (int)j_I1,
+ w, w_ext, w00, w01, w10, w11, psz, sid);
+
+ INIT_BILINEAR_WEIGHTS(prev_Ux, prev_Uy);
+ cur_SSD = computeSSDMeanNorm(I0_ptr + i * w + j, I1_ptr + (int)i_I1 * w_ext + (int)j_I1,
+ w, w_ext, w00, w01, w10, w11, psz, sid);
+ if (cur_SSD < min_SSD)
+ {
+ Ux = prev_Ux;
+ Uy = prev_Uy;
+ }
+
+ prev_Ux = Ux;
+ prev_Uy = Uy;
+ Sx_ptr[is * ws + js] = Ux;
+ Sy_ptr[is * ws + js] = Uy;
+ }
+}
+
+float3 processPatchMeanNorm(const __global uchar *I0_ptr, const __global uchar *I1_ptr,
+ const __global short *I0x_ptr, const __global short *I0y_ptr,
+ int I0_stride, int I1_stride, float w00, float w01, float w10,
+ float w11, int patch_sz, float x_grad_sum, float y_grad_sum)
+{
+ float sum_diff = 0.0, sum_diff_sq = 0.0;
+ float sum_I0x_mul = 0.0, sum_I0y_mul = 0.0;
+ int n = patch_sz * patch_sz;
+ uchar8 I1_vec1, I1_vec2;
+ uchar I1_val1, I1_val2;
+
+ for (int i = 0; i < 8; i++)
+ {
+ uchar8 I0_vec = vload8(0, I0_ptr + i * I0_stride);
+
+ I1_vec1 = (i == 0) ? vload8(0, I1_ptr + i * I1_stride) : I1_vec2;
+ I1_vec2 = vload8(0, I1_ptr + (i + 1) * I1_stride);
+ I1_val1 = (i == 0) ? I1_ptr[i * I1_stride + patch_sz] : I1_val2;
+ I1_val2 = I1_ptr[(i + 1) * I1_stride + patch_sz];
+
+ float8 vec = w00 * convert_float8(I1_vec1) + w01 * convert_float8((uchar8)(I1_vec1.s123, I1_vec1.s4567, I1_val1)) +
+ w10 * convert_float8(I1_vec2) + w11 * convert_float8((uchar8)(I1_vec2.s123, I1_vec2.s4567, I1_val2)) -
+ convert_float8(I0_vec);
+
+ sum_diff += (dot(vec.lo, 1.0) + dot(vec.hi, 1.0));
+ sum_diff_sq += (dot(vec.lo, vec.lo) + dot(vec.hi, vec.hi));
+
+ short8 I0x_vec = vload8(0, I0x_ptr + i * I0_stride);
+ short8 I0y_vec = vload8(0, I0y_ptr + i * I0_stride);
+
+ sum_I0x_mul += dot(vec.lo, convert_float4(I0x_vec.lo));
+ sum_I0x_mul += dot(vec.hi, convert_float4(I0x_vec.hi));
+ sum_I0y_mul += dot(vec.lo, convert_float4(I0y_vec.lo));
+ sum_I0y_mul += dot(vec.hi, convert_float4(I0y_vec.hi));
+ }
+
+ float dst_dUx = sum_I0x_mul - sum_diff * x_grad_sum / n;
+ float dst_dUy = sum_I0y_mul - sum_diff * y_grad_sum / n;
+ float SSD = sum_diff_sq - sum_diff * sum_diff / n;
+
+ return (float3)(SSD, dst_dUx, dst_dUy);
+}
+
+__kernel void dis_patch_inverse_search_fwd_2(__global const float *Ux_ptr, __global const float *Uy_ptr,
+ __global const uchar *I0_ptr, __global const uchar *I1_ptr,
+ __global const short *I0x_ptr, __global const short *I0y_ptr,
+ __global const float *xx_ptr, __global const float *yy_ptr,
+ __global const float *xy_ptr,
+ __global const float *x_ptr, __global const float *y_ptr,
+ int border_size, int patch_size, int patch_stride,
+ int w, int h, int ws, int hs, int num_inner_iter, int pyr_level,
+ __global float *Sx_ptr, __global float *Sy_ptr)
+{
+ int js = get_global_id(0);
+ int is = get_global_id(1);
+ int i = is * patch_stride;
+ int j = js * patch_stride;
+ int psz = patch_size;
+ int psz2 = psz / 2;
+ int w_ext = w + 2 * border_size;
+ int bsz = border_size;
+ int index = is * ws + js;
+
+ if (js >= ws || is >= hs) return;
+
+ float Ux = Sx_ptr[index];
+ float Uy = Sy_ptr[index];
+ float cur_Ux = Ux;
+ float cur_Uy = Uy;
+ float cur_xx = xx_ptr[index];
+ float cur_yy = yy_ptr[index];
+ float cur_xy = xy_ptr[index];
+ float detH = cur_xx * cur_yy - cur_xy * cur_xy;
+
+ if (fabs(detH) < EPS) detH = EPS;
+
+ float invH11 = cur_yy / detH;
+ float invH12 = -cur_xy / detH;
+ float invH22 = cur_xx / detH;
+ float prev_SSD = INF, SSD;
+ float x_grad_sum = x_ptr[index];
+ float y_grad_sum = y_ptr[index];
+
+ float i_lower_limit = bsz - psz + 1.0f;
+ float i_upper_limit = bsz + h - 1.0f;
+ float j_lower_limit = bsz - psz + 1.0f;
+ float j_upper_limit = bsz + w - 1.0f;
+ float dUx, dUy, i_I1, j_I1, w00, w01, w10, w11, dx, dy;
+ float3 res;
+
+ for (int t = 0; t < num_inner_iter; t++)
+ {
+ INIT_BILINEAR_WEIGHTS(cur_Ux, cur_Uy);
+ res = processPatchMeanNorm(I0_ptr + i * w + j,
+ I1_ptr + (int)i_I1 * w_ext + (int)j_I1, I0x_ptr + i * w + j,
+ I0y_ptr + i * w + j, w, w_ext, w00, w01, w10, w11, psz,
+ x_grad_sum, y_grad_sum);
+
+ SSD = res.x;
+ dUx = res.y;
+ dUy = res.z;
+ dx = invH11 * dUx + invH12 * dUy;
+ dy = invH12 * dUx + invH22 * dUy;
+
+ cur_Ux -= dx;
+ cur_Uy -= dy;
+
+ if (SSD >= prev_SSD)
+ break;
+ prev_SSD = SSD;
+ }
+
+ float2 vec = (float2)(cur_Ux - Ux, cur_Uy - Uy);
+ if (dot(vec, vec) <= (float)(psz * psz))
+ {
+ Sx_ptr[index] = cur_Ux;
+ Sy_ptr[index] = cur_Uy;
+ }
+}
+
+__kernel void dis_patch_inverse_search_bwd_1(__global const uchar *I0_ptr, __global const uchar *I1_ptr,
+ int border_size, int patch_size, int patch_stride,
+ int w, int h, int ws, int hs, int pyr_level,
+ __global float *Sx_ptr, __global float *Sy_ptr)
+{
+ int id = get_global_id(0);
+ int is = id / 8;
+ if (id >= (hs * 8)) return;
+
+ is = (hs - 1 - is);
+ int i = is * patch_stride;
+ int j = (ws - 2) * patch_stride;
+ int psz = patch_size;
+ int psz2 = psz / 2;
+ int w_ext = w + 2 * border_size;
+ int bsz = border_size;
+
+ float i_lower_limit = bsz - psz + 1.0f;
+ float i_upper_limit = bsz + h - 1.0f;
+ float j_lower_limit = bsz - psz + 1.0f;
+ float j_upper_limit = bsz + w - 1.0f;
+ float i_I1, j_I1, w00, w01, w10, w11;
+
+ int sid = get_sub_group_local_id();
+ for (int js = (ws - 2); js > -1; js--, j -= patch_stride)
+ {
+ float min_SSD, cur_SSD;
+ float2 Ux = vload2(0, Sx_ptr + is * ws + js);
+ float2 Uy = vload2(0, Sy_ptr + is * ws + js);
+
+ INIT_BILINEAR_WEIGHTS(Ux.x, Uy.x);
+ min_SSD = computeSSDMeanNorm(I0_ptr + i * w + j, I1_ptr + (int)i_I1 * w_ext + (int)j_I1,
+ w, w_ext, w00, w01, w10, w11, psz, sid);
+
+ INIT_BILINEAR_WEIGHTS(Ux.y, Uy.y);
+ cur_SSD = computeSSDMeanNorm(I0_ptr + i * w + j, I1_ptr + (int)i_I1 * w_ext + (int)j_I1,
+ w, w_ext, w00, w01, w10, w11, psz, sid);
+ if (cur_SSD < min_SSD)
+ {
+ Sx_ptr[is * ws + js] = Ux.y;
+ Sy_ptr[is * ws + js] = Uy.y;
+ }
+ }
+}
+
+__kernel void dis_patch_inverse_search_bwd_2(__global const uchar *I0_ptr, __global const uchar *I1_ptr,
+ __global const short *I0x_ptr, __global const short *I0y_ptr,
+ __global const float *xx_ptr, __global const float *yy_ptr,
+ __global const float *xy_ptr,
+ __global const float *x_ptr, __global const float *y_ptr,
+ int border_size, int patch_size, int patch_stride,
+ int w, int h, int ws, int hs, int num_inner_iter,
+ __global float *Sx_ptr, __global float *Sy_ptr)
+{
+ int js = get_global_id(0);
+ int is = get_global_id(1);
+ if (js >= ws || is >= hs) return;
+
+ js = (ws - 1 - js);
+ is = (hs - 1 - is);
+
+ int j = js * patch_stride;
+ int i = is * patch_stride;
+ int psz = patch_size;
+ int psz2 = psz / 2;
+ int w_ext = w + 2 * border_size;
+ int bsz = border_size;
+ int index = is * ws + js;
+
+ float Ux = Sx_ptr[index];
+ float Uy = Sy_ptr[index];
+ float cur_Ux = Ux;
+ float cur_Uy = Uy;
+ float cur_xx = xx_ptr[index];
+ float cur_yy = yy_ptr[index];
+ float cur_xy = xy_ptr[index];
+ float detH = cur_xx * cur_yy - cur_xy * cur_xy;
+
+ if (fabs(detH) < EPS) detH = EPS;
+
+ float invH11 = cur_yy / detH;
+ float invH12 = -cur_xy / detH;
+ float invH22 = cur_xx / detH;
+ float prev_SSD = INF, SSD;
+ float x_grad_sum = x_ptr[index];
+ float y_grad_sum = y_ptr[index];
+
+ float i_lower_limit = bsz - psz + 1.0f;
+ float i_upper_limit = bsz + h - 1.0f;
+ float j_lower_limit = bsz - psz + 1.0f;
+ float j_upper_limit = bsz + w - 1.0f;
+ float dUx, dUy, i_I1, j_I1, w00, w01, w10, w11, dx, dy;
+ float3 res;
+
+ for (int t = 0; t < num_inner_iter; t++)
+ {
+ INIT_BILINEAR_WEIGHTS(cur_Ux, cur_Uy);
+ res = processPatchMeanNorm(I0_ptr + i * w + j,
+ I1_ptr + (int)i_I1 * w_ext + (int)j_I1, I0x_ptr + i * w + j,
+ I0y_ptr + i * w + j, w, w_ext, w00, w01, w10, w11, psz,
+ x_grad_sum, y_grad_sum);
+
+ SSD = res.x;
+ dUx = res.y;
+ dUy = res.z;
+ dx = invH11 * dUx + invH12 * dUy;
+ dy = invH12 * dUx + invH22 * dUy;
+
+ cur_Ux -= dx;
+ cur_Uy -= dy;
+
+ if (SSD >= prev_SSD)
+ break;
+ prev_SSD = SSD;
+ }
+
+ float2 vec = (float2)(cur_Ux - Ux, cur_Uy - Uy);
+ if ((dot(vec, vec)) <= (float)(psz * psz))
+ {
+ Sx_ptr[index] = cur_Ux;
+ Sy_ptr[index] = cur_Uy;
+ }
+}
+
diff --git a/contrib/modules/optflow/src/precomp.hpp b/contrib/modules/optflow/src/precomp.hpp
index 5770069..c3461b3 100644
--- a/contrib/modules/optflow/src/precomp.hpp
+++ b/contrib/modules/optflow/src/precomp.hpp
@@ -45,6 +45,8 @@ the use of this software, even if advised of the possibility of such damage.
#include <opencv2/optflow.hpp>
#include <opencv2/video.hpp>
#include <opencv2/imgproc.hpp>
+#include "opencv2/core/utility.hpp"
+#include "opencv2/core/private.hpp"
#include "opencv2/core/ocl.hpp"
#include <algorithm>
diff --git a/contrib/modules/optflow/src/sparse_matching_gpc.cpp b/contrib/modules/optflow/src/sparse_matching_gpc.cpp
index 649308a..343b116 100644
--- a/contrib/modules/optflow/src/sparse_matching_gpc.cpp
+++ b/contrib/modules/optflow/src/sparse_matching_gpc.cpp
@@ -43,9 +43,10 @@
#include "opencv2/core/core_c.h"
#include "opencv2/core/private.hpp"
#include "opencv2/flann/miniflann.hpp"
-#include "opencv2/highgui.hpp"
+#include "opencv2/imgcodecs.hpp"
#include "precomp.hpp"
#include "opencl_kernels_optflow.hpp"
+#include "opencv2/core/hal/intrin.hpp"
/* Disable "from double to float" and "from size_t to int" warnings.
* Fixing these would make the code look ugly by introducing explicit cast all around.
@@ -569,7 +570,7 @@ bool GPCTree::trainNode( size_t nodeId, SIter begin, SIter end, unsigned depth )
localBestScore = score;
else
{
- const double beta = simulatedAnnealingTemperatureCoef * std::sqrt( i ) / ( nSamples * ( scoreGainPos + scoreGainNeg ) );
+ const double beta = simulatedAnnealingTemperatureCoef * std::sqrt( static_cast<float>(i) ) / ( nSamples * ( scoreGainPos + scoreGainNeg ) );
if ( rng.uniform( 0.0, 1.0 ) > std::exp( -beta * ( localBestScore - score) ) )
coef[pos] = randomModification;
}
@@ -728,6 +729,9 @@ Ptr< GPCTrainingSamples > GPCTrainingSamples::create( InputArrayOfArrays imagesF
void GPCDetails::dropOutliers( std::vector< std::pair< Point2i, Point2i > > &corr )
{
+ if ( corr.size() == 0 )
+ return;
+
std::vector< float > mag( corr.size() );
for ( size_t i = 0; i < corr.size(); ++i )
diff --git a/contrib/modules/optflow/test/ocl/test_dis.cpp b/contrib/modules/optflow/test/ocl/test_dis.cpp
new file mode 100644
index 0000000..5c847cd
--- /dev/null
+++ b/contrib/modules/optflow/test/ocl/test_dis.cpp
@@ -0,0 +1,100 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// Intel License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of Intel Corporation may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "../test_precomp.hpp"
+#include "opencv2/ts/ocl_test.hpp"
+
+#ifdef HAVE_OPENCL
+
+using namespace cv;
+using namespace optflow;
+
+namespace cvtest {
+namespace ocl {
+
+PARAM_TEST_CASE(OCL_DenseOpticalFlow_DIS, int)
+{
+ int preset;
+
+ virtual void SetUp()
+ {
+ preset = GET_PARAM(0);
+ }
+};
+
+OCL_TEST_P(OCL_DenseOpticalFlow_DIS, Mat)
+{
+ Mat frame1, frame2, GT;
+
+ frame1 = imread(TS::ptr()->get_data_path() + "optflow/RubberWhale1.png");
+ frame2 = imread(TS::ptr()->get_data_path() + "optflow/RubberWhale2.png");
+
+ CV_Assert(!frame1.empty() && !frame2.empty());
+
+ cvtColor(frame1, frame1, COLOR_BGR2GRAY);
+ cvtColor(frame2, frame2, COLOR_BGR2GRAY);
+
+ Ptr<DenseOpticalFlow> algo;
+
+ // iterate over presets:
+ for (int i = 0; i < test_loop_times; i++)
+ {
+ Mat flow;
+ UMat ocl_flow;
+
+ algo = createOptFlow_DIS(preset);
+ OCL_OFF(algo->calc(frame1, frame2, flow));
+ OCL_ON(algo->calc(frame1, frame2, ocl_flow));
+ ASSERT_EQ(flow.rows, ocl_flow.rows);
+ ASSERT_EQ(flow.cols, ocl_flow.cols);
+
+ EXPECT_MAT_SIMILAR(flow, ocl_flow, 6e-3);
+ }
+}
+
+OCL_INSTANTIATE_TEST_CASE_P(Contrib, OCL_DenseOpticalFlow_DIS,
+ Values(DISOpticalFlow::PRESET_ULTRAFAST,
+ DISOpticalFlow::PRESET_FAST,
+ DISOpticalFlow::PRESET_MEDIUM));
+
+} } // namespace cvtest::ocl
+
+#endif // HAVE_OPENCL
diff --git a/contrib/modules/optflow/test/test_OF_reproducibility.cpp b/contrib/modules/optflow/test/test_OF_reproducibility.cpp
index 0cdbd50..7b99055 100644
--- a/contrib/modules/optflow/test/test_OF_reproducibility.cpp
+++ b/contrib/modules/optflow/test/test_OF_reproducibility.cpp
@@ -100,8 +100,8 @@ TEST_P(DenseOpticalFlow_DIS, MultithreadReproducibility)
// resulting flow should be within the frame bounds:
double min_val, max_val;
minMaxLoc(resMultiThread, &min_val, &max_val);
- EXPECT_LE(abs(min_val), sqrt(size.height * size.height + size.width * size.width));
- EXPECT_LE(abs(max_val), sqrt(size.height * size.height + size.width * size.width));
+ EXPECT_LE(abs(min_val), sqrt( static_cast<double>(size.height * size.height + size.width * size.width)) );
+ EXPECT_LE(abs(max_val), sqrt( static_cast<double>(size.height * size.height + size.width * size.width)) );
}
}
@@ -151,8 +151,8 @@ TEST_P(DenseOpticalFlow_VariationalRefinement, MultithreadReproducibility)
// resulting flow should be within the frame bounds:
double min_val, max_val;
minMaxLoc(resMultiThread, &min_val, &max_val);
- EXPECT_LE(abs(min_val), sqrt(size.height * size.height + size.width * size.width));
- EXPECT_LE(abs(max_val), sqrt(size.height * size.height + size.width * size.width));
+ EXPECT_LE(abs(min_val), sqrt( static_cast<double>(size.height * size.height + size.width * size.width)) );
+ EXPECT_LE(abs(max_val), sqrt( static_cast<double>(size.height * size.height + size.width * size.width)) );
}
}
diff --git a/contrib/modules/phase_unwrapping/CMakeLists.txt b/contrib/modules/phase_unwrapping/CMakeLists.txt
index 6ba8923..906e86a 100644
--- a/contrib/modules/phase_unwrapping/CMakeLists.txt
+++ b/contrib/modules/phase_unwrapping/CMakeLists.txt
@@ -1,2 +1,2 @@
set(the_description "Phase Unwrapping API")
-ocv_define_module(phase_unwrapping opencv_core opencv_calib3d opencv_imgproc opencv_highgui opencv_features2d opencv_rgbd WRAP python java)
+ocv_define_module(phase_unwrapping opencv_core opencv_imgproc WRAP python java)
diff --git a/contrib/modules/phase_unwrapping/test/test_precomp.hpp b/contrib/modules/phase_unwrapping/test/test_precomp.hpp
index 6819def..16f5ce1 100644
--- a/contrib/modules/phase_unwrapping/test/test_precomp.hpp
+++ b/contrib/modules/phase_unwrapping/test/test_precomp.hpp
@@ -11,7 +11,6 @@
#include "opencv2/ts.hpp"
#include "opencv2/phase_unwrapping.hpp"
-#include <opencv2/rgbd.hpp>
#include <iostream>
#endif
diff --git a/contrib/modules/plot/CMakeLists.txt b/contrib/modules/plot/CMakeLists.txt
index 1c879fe..e95f110 100644
--- a/contrib/modules/plot/CMakeLists.txt
+++ b/contrib/modules/plot/CMakeLists.txt
@@ -1,2 +1,2 @@
set(the_description "Plot function for Mat data.")
-ocv_define_module(plot opencv_core opencv_highgui WRAP python)
+ocv_define_module(plot opencv_core opencv_imgproc WRAP python)
diff --git a/contrib/modules/plot/src/plot.cpp b/contrib/modules/plot/src/plot.cpp
index 60e8549..dcfc8c5 100644
--- a/contrib/modules/plot/src/plot.cpp
+++ b/contrib/modules/plot/src/plot.cpp
@@ -62,17 +62,9 @@ namespace cv
Mat _plotData = plotData.getMat();
//if the matrix is not Nx1 or 1xN
if(_plotData.cols > 1 && _plotData.rows > 1)
- {
- std::cout << "ERROR: Plot data must be a 1xN or Nx1 matrix." << std::endl;
- exit(0);
- }
+ CV_Error(Error::StsBadArg, "ERROR: Plot data must be a 1xN or Nx1 matrix.\n");
- //if the matrix type is not CV_64F
- if(_plotData.type() != CV_64F)
- {
- std::cout << "ERROR: Plot data type must be double (CV_64F)." << std::endl;
- exit(0);
- }
+ CV_Assert(_plotData.type() == CV_64F);
//in case we have a row matrix than needs to be transposed
if(_plotData.cols > _plotData.rows)
@@ -98,17 +90,9 @@ namespace cv
Mat _plotDataY = plotDataY_.getMat();
//f the matrix is not Nx1 or 1xN
if((_plotDataX.cols > 1 && _plotDataX.rows > 1) || (_plotDataY.cols > 1 && _plotDataY.rows > 1))
- {
- std::cout << "ERROR: Plot data must be a 1xN or Nx1 matrix." << std::endl;
- exit(0);
- }
+ CV_Error(Error::StsBadArg, "ERROR: Plot data must be a 1xN or Nx1 matrix.\n");
- //if the matrix type is not CV_64F
- if(_plotDataX.type() != CV_64F || _plotDataY.type() != CV_64F)
- {
- std::cout << "ERROR: Plot data type must be double (CV_64F)." << std::endl;
- exit(0);
- }
+ CV_Assert(_plotDataX.type() == CV_64F && _plotDataY.type() == CV_64F);
//in case we have a row matrix than needs to be transposed
if(_plotDataX.cols > _plotDataX.rows)
diff --git a/contrib/modules/plot/src/precomp.cpp b/contrib/modules/plot/src/precomp.cpp
deleted file mode 100644
index 1f92d92..0000000
--- a/contrib/modules/plot/src/precomp.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-//################################################################################
-//
-// Created by Nuno Moutinho
-//
-//################################################################################
-
-#include "precomp.hpp"
-
-/* End of file. */
diff --git a/contrib/modules/reg/include/opencv2/reg/map.hpp b/contrib/modules/reg/include/opencv2/reg/map.hpp
index 26b29e3..a885a28 100644
--- a/contrib/modules/reg/include/opencv2/reg/map.hpp
+++ b/contrib/modules/reg/include/opencv2/reg/map.hpp
@@ -121,13 +121,13 @@ namespace reg {
The class is only used to define the common interface for any possible map.
*/
-class CV_EXPORTS Map
+class CV_EXPORTS_W Map
{
public:
/*!
* Virtual destructor
*/
- virtual ~Map(void);
+ virtual ~Map();
/*!
* Warps image to a new coordinate frame. The calculation is img2(x)=img1(T^{-1}(x)), as we
@@ -136,7 +136,7 @@ public:
* \param[in] img1 Original image
* \param[out] img2 Warped image
*/
- virtual void warp(const cv::Mat& img1, cv::Mat& img2) const;
+ CV_WRAP virtual void warp(InputArray img1, OutputArray img2) const;
/*!
* Warps image to a new coordinate frame. The calculation is img2(x)=img1(T(x)), so in fact
@@ -145,27 +145,27 @@ public:
* \param[in] img1 Original image
* \param[out] img2 Warped image
*/
- virtual void inverseWarp(const cv::Mat& img1, cv::Mat& img2) const = 0;
+ CV_WRAP virtual void inverseWarp(InputArray img1, OutputArray img2) const = 0;
/*!
* Calculates the inverse map
* \return Inverse map
*/
- virtual cv::Ptr<Map> inverseMap(void) const = 0;
+ CV_WRAP virtual cv::Ptr<Map> inverseMap() const = 0;
/*!
* Changes the map composing the current transformation with the one provided in the call.
* The order is first the current transformation, then the input argument.
* \param[in] map Transformation to compose with.
*/
- virtual void compose(const Map& map) = 0;
+ CV_WRAP virtual void compose(cv::Ptr<Map> map) = 0;
/*!
* Scales the map by a given factor as if the coordinates system is expanded/compressed
* by that factor.
* \param[in] factor Expansion if bigger than one, compression if smaller than one
*/
- virtual void scale(double factor) = 0;
+ CV_WRAP virtual void scale(double factor) = 0;
};
//! @}
diff --git a/contrib/modules/reg/include/opencv2/reg/mapaffine.hpp b/contrib/modules/reg/include/opencv2/reg/mapaffine.hpp
index 1c91326..868b661 100644
--- a/contrib/modules/reg/include/opencv2/reg/mapaffine.hpp
+++ b/contrib/modules/reg/include/opencv2/reg/mapaffine.hpp
@@ -49,33 +49,33 @@ namespace reg {
/*!
* Defines an affine transformation
*/
-class CV_EXPORTS MapAffine : public Map
+class CV_EXPORTS_W MapAffine : public Map
{
public:
/*!
* Default constructor builds an identity map
*/
- MapAffine(void);
+ CV_WRAP MapAffine();
/*!
* Constructor providing explicit values
* \param[in] linTr Linear part of the affine transformation
* \param[in] shift Displacement part of the affine transformation
*/
- MapAffine(const cv::Matx<double, 2, 2>& linTr, const cv::Vec<double, 2>& shift);
+ CV_WRAP MapAffine(InputArray linTr, InputArray shift);
/*!
* Destructor
*/
- ~MapAffine(void);
+ ~MapAffine();
- void inverseWarp(const cv::Mat& img1, cv::Mat& img2) const;
+ CV_WRAP void inverseWarp(InputArray img1, OutputArray img2) const;
- cv::Ptr<Map> inverseMap(void) const;
+ CV_WRAP cv::Ptr<Map> inverseMap() const;
- void compose(const Map& map);
+ CV_WRAP void compose(cv::Ptr<Map> map);
- void scale(double factor);
+ CV_WRAP void scale(double factor);
/*!
* Return linear part of the affine transformation
@@ -85,6 +85,10 @@ public:
return linTr_;
}
+ CV_WRAP void getLinTr(OutputArray linTr) const {
+ Mat(linTr_).copyTo(linTr);
+ }
+
/*!
* Return displacement part of the affine transformation
* \return Displacement part of the affine transformation
@@ -93,6 +97,10 @@ public:
return shift_;
}
+ CV_WRAP void getShift(OutputArray shift) const {
+ Mat(shift_).copyTo(shift);
+ }
+
private:
cv::Matx<double, 2, 2> linTr_;
cv::Vec<double, 2> shift_;
diff --git a/contrib/modules/reg/include/opencv2/reg/mapper.hpp b/contrib/modules/reg/include/opencv2/reg/mapper.hpp
index 8abadd1..2c2862d 100644
--- a/contrib/modules/reg/include/opencv2/reg/mapper.hpp
+++ b/contrib/modules/reg/include/opencv2/reg/mapper.hpp
@@ -47,11 +47,11 @@ namespace reg {
//! @addtogroup reg
//! @{
-/** @brief Base class for modelling an algorithm for calculating a
+/** @brief Base class for modelling an algorithm for calculating a map
The class is only used to define the common interface for any possible mapping algorithm.
*/
-class CV_EXPORTS Mapper
+class CV_EXPORTS_W Mapper
{
public:
virtual ~Mapper(void) {}
@@ -60,16 +60,16 @@ public:
* Calculate mapping between two images
* \param[in] img1 Reference image
* \param[in] img2 Warped image
- * \param[in,out] res Map from img1 to img2, stored in a smart pointer. If present as input,
- * it is an initial rough estimation that the mapper will try to refine.
+ * \param[in] If present, it is an initial rough estimation that the mapper will try to refine.
+ * \return Map from img1 to img2, stored in a smart pointer.
*/
- virtual void calculate(const cv::Mat& img1, const cv::Mat& img2, cv::Ptr<Map>& res) const = 0;
+ CV_WRAP virtual cv::Ptr<Map> calculate(InputArray img1, InputArray img2, cv::Ptr<Map> init = cv::Ptr<Map>()) const = 0;
/*
* Returns a map compatible with the Mapper class
* \return Pointer to identity Map
*/
- virtual cv::Ptr<Map> getMap(void) const = 0;
+ CV_WRAP virtual cv::Ptr<Map> getMap() const = 0;
protected:
/*
diff --git a/contrib/modules/reg/include/opencv2/reg/mappergradaffine.hpp b/contrib/modules/reg/include/opencv2/reg/mappergradaffine.hpp
index 08d5397..8b0d7b4 100644
--- a/contrib/modules/reg/include/opencv2/reg/mappergradaffine.hpp
+++ b/contrib/modules/reg/include/opencv2/reg/mappergradaffine.hpp
@@ -49,15 +49,15 @@ namespace reg {
/*!
* Mapper for affine motion
*/
-class CV_EXPORTS MapperGradAffine: public Mapper
+class CV_EXPORTS_W MapperGradAffine: public Mapper
{
public:
- MapperGradAffine(void);
+ CV_WRAP MapperGradAffine();
~MapperGradAffine(void);
- virtual void calculate(const cv::Mat& img1, const cv::Mat& img2, cv::Ptr<Map>& res) const;
+ CV_WRAP virtual cv::Ptr<Map> calculate(InputArray img1, InputArray img2, cv::Ptr<Map> init = cv::Ptr<Map>()) const;
- cv::Ptr<Map> getMap(void) const;
+ CV_WRAP cv::Ptr<Map> getMap() const;
};
//! @}
diff --git a/contrib/modules/reg/include/opencv2/reg/mappergradeuclid.hpp b/contrib/modules/reg/include/opencv2/reg/mappergradeuclid.hpp
index 29c49cb..c41a5f7 100644
--- a/contrib/modules/reg/include/opencv2/reg/mappergradeuclid.hpp
+++ b/contrib/modules/reg/include/opencv2/reg/mappergradeuclid.hpp
@@ -49,15 +49,15 @@ namespace reg {
/*!
* Mapper for euclidean motion: rotation plus shift
*/
-class CV_EXPORTS MapperGradEuclid: public Mapper
+class CV_EXPORTS_W MapperGradEuclid: public Mapper
{
public:
- MapperGradEuclid(void);
- ~MapperGradEuclid(void);
+ CV_WRAP MapperGradEuclid();
+ ~MapperGradEuclid();
- virtual void calculate(const cv::Mat& img1, const cv::Mat& img2, cv::Ptr<Map>& res) const;
+ CV_WRAP virtual cv::Ptr<Map> calculate(InputArray img1, InputArray img2, cv::Ptr<Map> init = cv::Ptr<Map>()) const;
- cv::Ptr<Map> getMap(void) const;
+ CV_WRAP cv::Ptr<Map> getMap() const;
};
//! @}
diff --git a/contrib/modules/reg/include/opencv2/reg/mappergradproj.hpp b/contrib/modules/reg/include/opencv2/reg/mappergradproj.hpp
index f1721e8..5d83fc4 100644
--- a/contrib/modules/reg/include/opencv2/reg/mappergradproj.hpp
+++ b/contrib/modules/reg/include/opencv2/reg/mappergradproj.hpp
@@ -49,15 +49,15 @@ namespace reg {
/*!
* Gradient mapper for a projective transformation
*/
-class CV_EXPORTS MapperGradProj: public Mapper
+class CV_EXPORTS_W MapperGradProj: public Mapper
{
public:
- MapperGradProj(void);
- ~MapperGradProj(void);
+ CV_WRAP MapperGradProj();
+ ~MapperGradProj();
- virtual void calculate(const cv::Mat& img1, const cv::Mat& img2, cv::Ptr<Map>& res) const;
+ CV_WRAP virtual cv::Ptr<Map> calculate(InputArray img1, InputArray img2, cv::Ptr<Map> init = cv::Ptr<Map>()) const;
- cv::Ptr<Map> getMap(void) const;
+ CV_WRAP cv::Ptr<Map> getMap() const;
};
//! @}
diff --git a/contrib/modules/reg/include/opencv2/reg/mappergradshift.hpp b/contrib/modules/reg/include/opencv2/reg/mappergradshift.hpp
index a9f75b3..3a36427 100644
--- a/contrib/modules/reg/include/opencv2/reg/mappergradshift.hpp
+++ b/contrib/modules/reg/include/opencv2/reg/mappergradshift.hpp
@@ -49,15 +49,15 @@ namespace reg {
/*!
* Gradient mapper for a translation
*/
-class CV_EXPORTS MapperGradShift: public Mapper
+class CV_EXPORTS_W MapperGradShift: public Mapper
{
public:
- MapperGradShift(void);
- virtual ~MapperGradShift(void);
+ CV_WRAP MapperGradShift();
+ virtual ~MapperGradShift();
- virtual void calculate(const cv::Mat& img1, const cv::Mat& img2, cv::Ptr<Map>& res) const;
+ CV_WRAP virtual cv::Ptr<Map> calculate(InputArray img1, InputArray img2, cv::Ptr<Map> init = cv::Ptr<Map>()) const;
- cv::Ptr<Map> getMap(void) const;
+ CV_WRAP cv::Ptr<Map> getMap() const;
};
//! @}
diff --git a/contrib/modules/reg/include/opencv2/reg/mappergradsimilar.hpp b/contrib/modules/reg/include/opencv2/reg/mappergradsimilar.hpp
index ea45ab9..6382180 100644
--- a/contrib/modules/reg/include/opencv2/reg/mappergradsimilar.hpp
+++ b/contrib/modules/reg/include/opencv2/reg/mappergradsimilar.hpp
@@ -49,15 +49,15 @@ namespace reg {
/*!
* Calculates a similarity transformation between to images (scale, rotation, and shift)
*/
-class CV_EXPORTS MapperGradSimilar: public Mapper
+class CV_EXPORTS_W MapperGradSimilar: public Mapper
{
public:
- MapperGradSimilar(void);
- ~MapperGradSimilar(void);
+ CV_WRAP MapperGradSimilar();
+ ~MapperGradSimilar();
- virtual void calculate(const cv::Mat& img1, const cv::Mat& img2, cv::Ptr<Map>& res) const;
+ CV_WRAP virtual cv::Ptr<Map> calculate(InputArray img1, InputArray img2, cv::Ptr<Map> init = cv::Ptr<Map>()) const;
- cv::Ptr<Map> getMap(void) const;
+ CV_WRAP cv::Ptr<Map> getMap() const;
};
//! @}
diff --git a/contrib/modules/reg/include/opencv2/reg/mapperpyramid.hpp b/contrib/modules/reg/include/opencv2/reg/mapperpyramid.hpp
index 33440bd..f9fbd01 100644
--- a/contrib/modules/reg/include/opencv2/reg/mapperpyramid.hpp
+++ b/contrib/modules/reg/include/opencv2/reg/mapperpyramid.hpp
@@ -39,7 +39,9 @@
#define MAPPERPYRAMID_H_
#include "mapper.hpp"
-
+#include "mapaffine.hpp"
+#include "mapprojec.hpp"
+#include "mapshift.hpp"
namespace cv {
namespace reg {
@@ -50,27 +52,52 @@ namespace reg {
/*!
* Calculates a map using a gaussian pyramid
*/
-class CV_EXPORTS MapperPyramid: public Mapper
+class CV_EXPORTS_W MapperPyramid: public Mapper
{
public:
/*
* Constructor
* \param[in] baseMapper Base mapper used for the refinements
*/
- MapperPyramid(const Mapper& baseMapper);
+ CV_WRAP MapperPyramid(Ptr<Mapper> baseMapper);
- void calculate(const cv::Mat& img1, const cv::Mat& img2, cv::Ptr<Map>& res) const;
+ CV_WRAP virtual cv::Ptr<Map> calculate(InputArray img1, InputArray img2, cv::Ptr<Map> init = cv::Ptr<Map>()) const;
- cv::Ptr<Map> getMap(void) const;
+ CV_WRAP cv::Ptr<Map> getMap() const;
- unsigned numLev_; /*!< Number of levels of the pyramid */
- unsigned numIterPerScale_; /*!< Number of iterations at a given scale of the pyramid */
+ CV_PROP_RW int numLev_; /*!< Number of levels of the pyramid */
+ CV_PROP_RW int numIterPerScale_; /*!< Number of iterations at a given scale of the pyramid */
private:
MapperPyramid& operator=(const MapperPyramid&);
const Mapper& baseMapper_; /*!< Mapper used in inner level */
};
+/*!
+ * Converts a pointer to a Map returned by MapperPyramid::calculate into the specified Map pointer type
+ */
+class CV_EXPORTS_W MapTypeCaster
+{
+public:
+ CV_WRAP static Ptr<MapAffine> toAffine(Ptr<Map> sourceMap)
+ {
+ MapAffine& affineMap = dynamic_cast<MapAffine&>(*sourceMap);
+ return Ptr<MapAffine>(new MapAffine(affineMap));
+ }
+
+ CV_WRAP static Ptr<MapShift> toShift(Ptr<Map> sourceMap)
+ {
+ MapShift& shiftMap = dynamic_cast<MapShift&>(*sourceMap);
+ return Ptr<MapShift>(new MapShift(shiftMap));
+ }
+
+ CV_WRAP static Ptr<MapProjec> toProjec(Ptr<Map> sourceMap)
+ {
+ MapProjec& projecMap = dynamic_cast<MapProjec&>(*sourceMap);
+ return Ptr<MapProjec>(new MapProjec(projecMap));
+ }
+};
+
//! @}
}} // namespace cv::reg
diff --git a/contrib/modules/reg/include/opencv2/reg/mapprojec.hpp b/contrib/modules/reg/include/opencv2/reg/mapprojec.hpp
index 57ef146..5802a74 100644
--- a/contrib/modules/reg/include/opencv2/reg/mapprojec.hpp
+++ b/contrib/modules/reg/include/opencv2/reg/mapprojec.hpp
@@ -50,32 +50,32 @@ namespace reg {
/*!
* Defines an transformation that consists on a projective transformation
*/
-class CV_EXPORTS MapProjec : public Map
+class CV_EXPORTS_W MapProjec : public Map
{
public:
/*!
* Default constructor builds an identity map
*/
- MapProjec(void);
+ CV_WRAP MapProjec();
/*!
* Constructor providing explicit values
* \param[in] projTr Projective transformation
*/
- MapProjec(const cv::Matx<double, 3, 3>& projTr);
+ CV_WRAP MapProjec(InputArray projTr);
/*!
* Destructor
*/
- ~MapProjec(void);
+ ~MapProjec();
- void inverseWarp(const cv::Mat& img1, cv::Mat& img2) const;
+ CV_WRAP void inverseWarp(InputArray img1, OutputArray img2) const;
- cv::Ptr<Map> inverseMap(void) const;
+ CV_WRAP cv::Ptr<Map> inverseMap() const;
- void compose(const Map& map);
+ CV_WRAP void compose(cv::Ptr<Map> map);
- void scale(double factor);
+ CV_WRAP void scale(double factor);
/*!
* Returns projection matrix
@@ -85,10 +85,14 @@ public:
return projTr_;
}
+ CV_WRAP void getProjTr(OutputArray projTr) const {
+ Mat(projTr_).copyTo(projTr);
+ }
+
/*!
* Normalizes object's homography
*/
- void normalize(void) {
+ CV_WRAP void normalize() {
double z = 1./projTr_(2, 2);
for(size_t v_i = 0; v_i < sizeof(projTr_.val)/sizeof(projTr_.val[0]); ++v_i)
projTr_.val[v_i] *= z;
diff --git a/contrib/modules/reg/include/opencv2/reg/mapshift.hpp b/contrib/modules/reg/include/opencv2/reg/mapshift.hpp
index e5f54a4..c711944 100644
--- a/contrib/modules/reg/include/opencv2/reg/mapshift.hpp
+++ b/contrib/modules/reg/include/opencv2/reg/mapshift.hpp
@@ -50,32 +50,33 @@ namespace reg {
/*!
* Defines an transformation that consists on a simple displacement
*/
-class CV_EXPORTS MapShift : public Map
+class CV_EXPORTS_W MapShift : public Map
{
public:
/*!
* Default constructor builds an identity map
*/
- MapShift(void);
+ CV_WRAP MapShift();
/*!
* Constructor providing explicit values
* \param[in] shift Displacement
*/
- MapShift(const cv::Vec<double, 2>& shift);
+
+ CV_WRAP MapShift(InputArray shift);
/*!
* Destructor
*/
- ~MapShift(void);
+ ~MapShift();
- void inverseWarp(const cv::Mat& img1, cv::Mat& img2) const;
+ CV_WRAP void inverseWarp(InputArray img1, OutputArray img2) const;
- cv::Ptr<Map> inverseMap(void) const;
+ CV_WRAP cv::Ptr<Map> inverseMap() const;
- void compose(const Map& map);
+ CV_WRAP void compose(cv::Ptr<Map> map);
- void scale(double factor);
+ CV_WRAP void scale(double factor);
/*!
* Return displacement
@@ -85,6 +86,10 @@ public:
return shift_;
}
+ CV_WRAP void getShift(OutputArray shift) const {
+ Mat(shift_).copyTo(shift);
+ }
+
private:
cv::Vec<double, 2> shift_; /*< Displacement */
};
diff --git a/contrib/modules/reg/perf/perf_precomp.cpp b/contrib/modules/reg/perf/perf_precomp.cpp
deleted file mode 100644
index 9de21b1..0000000
--- a/contrib/modules/reg/perf/perf_precomp.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Copyright (C) 2013, Alfonso Sanchez-Beato, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "perf_precomp.hpp"
diff --git a/contrib/modules/reg/perf/perf_reg.cpp b/contrib/modules/reg/perf/perf_reg.cpp
index 3622f4b..c0e2ce9 100644
--- a/contrib/modules/reg/perf/perf_reg.cpp
+++ b/contrib/modules/reg/perf/perf_reg.cpp
@@ -72,10 +72,9 @@ Vec<double, 2> perfShift(const Mat& img1)
mapTest.warp(img1, img2);
// Register
- MapperGradShift mapper;
+ Ptr<MapperGradShift> mapper = makePtr<MapperGradShift>();
MapperPyramid mappPyr(mapper);
- Ptr<Map> mapPtr;
- mappPyr.calculate(img1, img2, mapPtr);
+ Ptr<Map> mapPtr = mappPyr.calculate(img1, img2);
MapShift* mapShift = dynamic_cast<MapShift*>(mapPtr.get());
return mapShift->getShift();
@@ -96,10 +95,9 @@ Matx<double, 2, 6> perfEuclidean(const Mat& img1)
mapTest.warp(img1, img2);
// Register
- MapperGradEuclid mapper;
+ Ptr<MapperGradEuclid> mapper = makePtr<MapperGradEuclid>();
MapperPyramid mappPyr(mapper);
- Ptr<Map> mapPtr;
- mappPyr.calculate(img1, img2, mapPtr);
+ Ptr<Map> mapPtr = mappPyr.calculate(img1, img2);
MapAffine* mapAff = dynamic_cast<MapAffine*>(mapPtr.get());
Matx<double, 2, 2> resLinTr = mapAff->getLinTr();
@@ -127,10 +125,9 @@ Matx<double, 2, 6> perfSimilarity(const Mat& img1)
mapTest.warp(img1, img2);
// Register
- MapperGradSimilar mapper;
+ Ptr<MapperGradSimilar> mapper = makePtr<MapperGradSimilar>();
MapperPyramid mappPyr(mapper);
- Ptr<Map> mapPtr;
- mappPyr.calculate(img1, img2, mapPtr);
+ Ptr<Map> mapPtr = mappPyr.calculate(img1, img2);
MapAffine* mapAff = dynamic_cast<MapAffine*>(mapPtr.get());
Matx<double, 2, 2> resLinTr = mapAff->getLinTr();
@@ -154,10 +151,9 @@ Matx<double, 2, 6> perfAffine(const Mat& img1)
mapTest.warp(img1, img2);
// Register
- MapperGradAffine mapper;
+ Ptr<MapperGradAffine> mapper = makePtr<MapperGradAffine>();
MapperPyramid mappPyr(mapper);
- Ptr<Map> mapPtr;
- mappPyr.calculate(img1, img2, mapPtr);
+ Ptr<Map> mapPtr = mappPyr.calculate(img1, img2);
MapAffine* mapAff = dynamic_cast<MapAffine*>(mapPtr.get());
Matx<double, 2, 2> resLinTr = mapAff->getLinTr();
@@ -179,10 +175,9 @@ Matx<double, 3, 3> perfProjective(const Mat& img1)
mapTest.warp(img1, img2);
// Register
- MapperGradProj mapper;
+ Ptr<MapperGradProj> mapper = makePtr<MapperGradProj>();
MapperPyramid mappPyr(mapper);
- Ptr<Map> mapPtr;
- mappPyr.calculate(img1, img2, mapPtr);
+ Ptr<Map> mapPtr = mappPyr.calculate(img1, img2);
MapProjec* mapProj = dynamic_cast<MapProjec*>(mapPtr.get());
mapProj->normalize();
diff --git a/contrib/modules/reg/samples/map_test.cpp b/contrib/modules/reg/samples/map_test.cpp
index 3e8846d..c59ce96 100644
--- a/contrib/modules/reg/samples/map_test.cpp
+++ b/contrib/modules/reg/samples/map_test.cpp
@@ -36,12 +36,9 @@
//M*/
#include <iostream>
-#define _USE_MATH_DEFINES
-#include <cmath>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp> // OpenCV window I/O
#include <opencv2/imgproc.hpp> // OpenCV image transformations
-#include <opencv2/imgproc.hpp>
#include <opencv2/imgproc/types_c.h>
#include <opencv2/imgcodecs/imgcodecs_c.h>
#include <opencv2/highgui/highgui_c.h>
@@ -102,10 +99,9 @@ static void testShift(const Mat& img1)
showDifference(img1, img2, DIFF_IM);
// Register
- MapperGradShift mapper;
+ Ptr<MapperGradShift> mapper = makePtr<MapperGradShift>();
MapperPyramid mappPyr(mapper);
- Ptr<Map> mapPtr;
- mappPyr.calculate(img1, img2, mapPtr);
+ Ptr<Map> mapPtr = mappPyr.calculate(img1, img2);
// Print result
MapShift* mapShift = dynamic_cast<MapShift*>(mapPtr.get());
@@ -138,10 +134,9 @@ static void testEuclidean(const Mat& img1)
showDifference(img1, img2, DIFF_IM);
// Register
- MapperGradEuclid mapper;
+ Ptr<MapperGradEuclid> mapper = makePtr<MapperGradEuclid>();
MapperPyramid mappPyr(mapper);
- Ptr<Map> mapPtr;
- mappPyr.calculate(img1, img2, mapPtr);
+ Ptr<Map> mapPtr = mappPyr.calculate(img1, img2);
// Print result
MapAffine* mapAff = dynamic_cast<MapAffine*>(mapPtr.get());
@@ -177,10 +172,9 @@ static void testSimilarity(const Mat& img1)
showDifference(img1, img2, DIFF_IM);
// Register
- MapperGradSimilar mapper;
+ Ptr<MapperGradSimilar> mapper = makePtr<MapperGradSimilar>();
MapperPyramid mappPyr(mapper);
- Ptr<Map> mapPtr;
- mappPyr.calculate(img1, img2, mapPtr);
+ Ptr<Map> mapPtr = mappPyr.calculate(img1, img2);
// Print result
MapAffine* mapAff = dynamic_cast<MapAffine*>(mapPtr.get());
@@ -212,10 +206,9 @@ static void testAffine(const Mat& img1)
showDifference(img1, img2, DIFF_IM);
// Register
- MapperGradAffine mapper;
+ Ptr<MapperGradAffine> mapper = makePtr<MapperGradAffine>();
MapperPyramid mappPyr(mapper);
- Ptr<Map> mapPtr;
- mappPyr.calculate(img1, img2, mapPtr);
+ Ptr<Map> mapPtr = mappPyr.calculate(img1, img2);
// Print result
MapAffine* mapAff = dynamic_cast<MapAffine*>(mapPtr.get());
@@ -246,10 +239,9 @@ static void testProjective(const Mat& img1)
showDifference(img1, img2, DIFF_IM);
// Register
- MapperGradProj mapper;
+ Ptr<MapperGradProj> mapper = makePtr<MapperGradProj>();
MapperPyramid mappPyr(mapper);
- Ptr<Map> mapPtr;
- mappPyr.calculate(img1, img2, mapPtr);
+ Ptr<Map> mapPtr = mappPyr.calculate(img1, img2);
// Print result
MapProjec* mapProj = dynamic_cast<MapProjec*>(mapPtr.get());
@@ -350,7 +342,7 @@ static void calcHomographyFeature(const Mat& image1, const Mat& image2)
warpPerspective(image2, result, Hinv, image1.size());
cout << "--- Feature method\n" << H << endl;
-
+
Mat imf1, resf;
image1.convertTo(imf1, CV_64FC3);
result.convertTo(resf, CV_64FC3);
@@ -362,10 +354,9 @@ static void calcHomographyPixel(const Mat& img1, const Mat& img2)
static const char* diffpixel = "Difference pixel registered";
// Register using pixel differences
- MapperGradProj mapper;
+ Ptr<MapperGradProj> mapper = makePtr<MapperGradProj>();
MapperPyramid mappPyr(mapper);
- Ptr<Map> mapPtr;
- mappPyr.calculate(img1, img2, mapPtr);
+ Ptr<Map> mapPtr = mappPyr.calculate(img1, img2);
// Print result
MapProjec* mapProj = dynamic_cast<MapProjec*>(mapPtr.get());
@@ -401,7 +392,7 @@ static void comparePixelVsFeature(const Mat& img1_8b, const Mat& img2_8b)
int main(void)
{
- Mat img1;
+ Mat img1;
img1 = imread("home.png", CV_LOAD_IMAGE_UNCHANGED);
if(!img1.data) {
cout << "Could not open or find file" << endl;
diff --git a/contrib/modules/reg/samples/reg_shift.py b/contrib/modules/reg/samples/reg_shift.py
new file mode 100755
index 0000000..8ee4154
--- /dev/null
+++ b/contrib/modules/reg/samples/reg_shift.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+
+import cv2
+import numpy as np
+import sys
+
+img1 = cv2.imread(sys.argv[1])
+img1 = img1.astype(np.float32)
+shift = np.array([5., 5.])
+mapTest = cv2.reg.MapShift(shift)
+
+img2 = mapTest.warp(img1)
+
+mapper = cv2.reg.MapperGradShift()
+mappPyr = cv2.reg.MapperPyramid(mapper)
+
+resMap = mappPyr.calculate(img1, img2)
+mapShift = cv2.reg.MapTypeCaster_toShift(resMap)
+
+print(mapShift.getShift())
diff --git a/contrib/modules/reg/src/map.cpp b/contrib/modules/reg/src/map.cpp
index aff9700..58f8727 100644
--- a/contrib/modules/reg/src/map.cpp
+++ b/contrib/modules/reg/src/map.cpp
@@ -44,12 +44,12 @@ namespace reg {
////////////////////////////////////////////////////////////////////////////////////////////////////
-Map::~Map(void)
+Map::~Map()
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void Map::warp(const Mat& img1, Mat& img2) const
+void Map::warp(InputArray img1, OutputArray img2) const
{
Ptr<Map> invMap(inverseMap());
invMap->inverseWarp(img1, img2);
diff --git a/contrib/modules/reg/src/mapaffine.cpp b/contrib/modules/reg/src/mapaffine.cpp
index 781ec24..7bdc221 100644
--- a/contrib/modules/reg/src/mapaffine.cpp
+++ b/contrib/modules/reg/src/mapaffine.cpp
@@ -45,25 +45,26 @@ namespace reg {
////////////////////////////////////////////////////////////////////////////////////////////////////
-MapAffine::MapAffine(void)
+MapAffine::MapAffine()
: linTr_(Matx<double, 2, 2>::eye()), shift_()
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-MapAffine::MapAffine(const Matx<double, 2, 2>& linTr, const Vec<double, 2>& shift)
- : linTr_(linTr), shift_(shift)
+MapAffine::MapAffine(InputArray linTr, InputArray shift)
+ : linTr_(linTr.getMat()), shift_(shift.getMat())
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-MapAffine::~MapAffine(void)
+MapAffine::~MapAffine()
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void MapAffine::inverseWarp(const Mat& img1, Mat& img2) const
+void MapAffine::inverseWarp(InputArray _img1, OutputArray img2) const
{
+ Mat img1 = _img1.getMat();
// Rows and columns in destination
Mat dest_r, dest_c;
dest_r.create(img1.size(), CV_32FC1);
@@ -93,10 +94,10 @@ Ptr<Map> MapAffine::inverseMap(void) const
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void MapAffine::compose(const Map& map)
+void MapAffine::compose(cv::Ptr<Map> map)
{
// Composition of affine transformations T and T' is (T o T') = A'Ax + A'b + b'
- const MapAffine& mapAff = static_cast<const MapAffine&>(map);
+ const MapAffine& mapAff = static_cast<const MapAffine&>(*map);
Matx<double, 2, 2> compMat = mapAff.getLinTr()*linTr_;
Vec<double, 2> compShift = mapAff.getLinTr()*shift_ + mapAff.getShift();
linTr_ = compMat;
diff --git a/contrib/modules/reg/src/mapper.cpp b/contrib/modules/reg/src/mapper.cpp
index e338c6c..a2eb4f2 100644
--- a/contrib/modules/reg/src/mapper.cpp
+++ b/contrib/modules/reg/src/mapper.cpp
@@ -59,28 +59,45 @@ void Mapper::gradient(const Mat& img1, const Mat& img2, Mat& Ix, Mat& Iy, Mat& I
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void Mapper::grid(const Mat& img, Mat& grid_r, Mat& grid_c) const
+
+template<typename _Tp>
+void fillGridMatrices(const Mat img, Mat grid_r, Mat grid_c)
{
- // Matrices with reference frame coordinates
- grid_r.create(img.size(), img.type());
- grid_c.create(img.size(), img.type());
if(img.channels() == 1) {
for(int r_i = 0; r_i < img.rows; ++r_i) {
for(int c_i = 0; c_i < img.cols; ++c_i) {
- grid_r.at<double>(r_i, c_i) = r_i;
- grid_c.at<double>(r_i, c_i) = c_i;
+ grid_r.at<_Tp>(r_i, c_i) = (_Tp)r_i;
+ grid_c.at<_Tp>(r_i, c_i) = (_Tp)c_i;
}
}
} else {
- Vec3d ones(1., 1., 1.);
+ Vec<_Tp, 3> ones((_Tp)1, (_Tp)1, (_Tp)1);
for(int r_i = 0; r_i < img.rows; ++r_i) {
for(int c_i = 0; c_i < img.cols; ++c_i) {
- grid_r.at<Vec3d>(r_i, c_i) = r_i*ones;
- grid_c.at<Vec3d>(r_i, c_i) = c_i*ones;
+ grid_r.at< Vec<_Tp, 3> >(r_i, c_i) = (_Tp)r_i*ones;
+ grid_c.at< Vec<_Tp, 3> >(r_i, c_i) = (_Tp)c_i*ones;
}
}
}
}
+void Mapper::grid(const Mat& img, Mat& grid_r, Mat& grid_c) const
+{
+ CV_DbgAssert(img.channels() == 1 || img.channels() == 3);
+
+ // Matrices with reference frame coordinates
+ grid_r.create(img.size(), img.type());
+ grid_c.create(img.size(), img.type());
+
+ if(img.depth() == CV_8U)
+ fillGridMatrices<uchar>(img, grid_r, grid_c);
+ if(img.depth() == CV_16U)
+ fillGridMatrices<ushort>(img, grid_r, grid_c);
+ else if(img.depth() == CV_32F)
+ fillGridMatrices<float>(img, grid_r, grid_c);
+ else if(img.depth() == CV_64F)
+ fillGridMatrices<double>(img, grid_r, grid_c);
+}
+
}} // namespace cv::reg
diff --git a/contrib/modules/reg/src/mappergradaffine.cpp b/contrib/modules/reg/src/mappergradaffine.cpp
index fd698c4..77b5377 100644
--- a/contrib/modules/reg/src/mappergradaffine.cpp
+++ b/contrib/modules/reg/src/mappergradaffine.cpp
@@ -44,21 +44,21 @@ namespace reg {
////////////////////////////////////////////////////////////////////////////////////////////////////
-MapperGradAffine::MapperGradAffine(void)
+MapperGradAffine::MapperGradAffine()
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-MapperGradAffine::~MapperGradAffine(void)
+MapperGradAffine::~MapperGradAffine()
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void MapperGradAffine::calculate(
- const cv::Mat& img1, const cv::Mat& image2, cv::Ptr<Map>& res) const
+cv::Ptr<Map> MapperGradAffine::calculate(InputArray _img1, InputArray image2, cv::Ptr<Map> init) const
{
+ Mat img1 = _img1.getMat();
Mat gradx, grady, imgDiff;
Mat img2;
@@ -66,11 +66,11 @@ void MapperGradAffine::calculate(
CV_DbgAssert(img1.channels() == image2.channels());
CV_DbgAssert(img1.channels() == 1 || img1.channels() == 3);
- if(!res.empty()) {
+ if(!init.empty()) {
// We have initial values for the registration: we move img2 to that initial reference
- res->inverseWarp(image2, img2);
+ init->inverseWarp(image2, img2);
} else {
- img2 = image2;
+ img2 = image2.getMat();
}
// Get gradient in all channels
@@ -145,16 +145,19 @@ void MapperGradAffine::calculate(
Matx<double, 2, 2> linTr(k(0) + 1., k(1), k(3), k(4) + 1.);
Vec<double, 2> shift(k(2), k(5));
- if(res.empty()) {
- res = Ptr<Map>(new MapAffine(linTr, shift));
+ if(init.empty()) {
+ return Ptr<Map>(new MapAffine(linTr, shift));
} else {
- MapAffine newTr(linTr, shift);
- res->compose(newTr);
+ Ptr<MapAffine> newTr(new MapAffine(linTr, shift));
+ MapAffine* initPtr = dynamic_cast<MapAffine*>(init.get());
+ Ptr<MapAffine> oldTr(new MapAffine(initPtr->getLinTr(), initPtr->getShift()));
+ oldTr->compose(newTr);
+ return oldTr;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-cv::Ptr<Map> MapperGradAffine::getMap(void) const
+cv::Ptr<Map> MapperGradAffine::getMap() const
{
return cv::Ptr<Map>(new MapAffine());
}
diff --git a/contrib/modules/reg/src/mappergradeuclid.cpp b/contrib/modules/reg/src/mappergradeuclid.cpp
index 26557cb..2f126af 100644
--- a/contrib/modules/reg/src/mappergradeuclid.cpp
+++ b/contrib/modules/reg/src/mappergradeuclid.cpp
@@ -44,21 +44,22 @@ namespace reg {
////////////////////////////////////////////////////////////////////////////////////////////////////
-MapperGradEuclid::MapperGradEuclid(void)
+MapperGradEuclid::MapperGradEuclid()
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-MapperGradEuclid::~MapperGradEuclid(void)
+MapperGradEuclid::~MapperGradEuclid()
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void MapperGradEuclid::calculate(
- const cv::Mat& img1, const cv::Mat& image2, cv::Ptr<Map>& res) const
+cv::Ptr<Map> MapperGradEuclid::calculate(
+ InputArray _img1, InputArray image2, cv::Ptr<Map> init) const
{
+ Mat img1 = _img1.getMat();
Mat gradx, grady, imgDiff;
Mat img2;
@@ -66,11 +67,11 @@ void MapperGradEuclid::calculate(
CV_DbgAssert(img1.channels() == image2.channels());
CV_DbgAssert(img1.channels() == 1 || img1.channels() == 3);
- if(!res.empty()) {
+ if(!init.empty()) {
// We have initial values for the registration: we move img2 to that initial reference
- res->inverseWarp(image2, img2);
+ init->inverseWarp(image2, img2);
} else {
- img2 = image2;
+ img2 = image2.getMat();
}
// Matrices with reference frame coordinates
@@ -111,16 +112,19 @@ void MapperGradEuclid::calculate(
Matx<double, 2, 2> linTr(cosT, -sinT, sinT, cosT);
Vec<double, 2> shift(k(0), k(1));
- if(res.empty()) {
- res = Ptr<Map>(new MapAffine(linTr, shift));
+ if(init.empty()) {
+ return Ptr<Map>(new MapAffine(linTr, shift));
} else {
- MapAffine newTr(linTr, shift);
- res->compose(newTr);
+ Ptr<MapAffine> newTr(new MapAffine(linTr, shift));
+ MapAffine* initPtr = dynamic_cast<MapAffine*>(init.get());
+ Ptr<MapAffine> oldTr(new MapAffine(initPtr->getLinTr(), initPtr->getShift()));
+ oldTr->compose(newTr);
+ return oldTr;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-cv::Ptr<Map> MapperGradEuclid::getMap(void) const
+cv::Ptr<Map> MapperGradEuclid::getMap() const
{
return cv::Ptr<Map>(new MapAffine());
}
diff --git a/contrib/modules/reg/src/mappergradproj.cpp b/contrib/modules/reg/src/mappergradproj.cpp
index f0c9b5e..f1a0f4b 100644
--- a/contrib/modules/reg/src/mappergradproj.cpp
+++ b/contrib/modules/reg/src/mappergradproj.cpp
@@ -44,21 +44,22 @@ namespace reg {
////////////////////////////////////////////////////////////////////////////////////////////////////
-MapperGradProj::MapperGradProj(void)
+MapperGradProj::MapperGradProj()
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-MapperGradProj::~MapperGradProj(void)
+MapperGradProj::~MapperGradProj()
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void MapperGradProj::calculate(
- const cv::Mat& img1, const cv::Mat& image2, cv::Ptr<Map>& res) const
+cv::Ptr<Map> MapperGradProj::calculate(
+ InputArray _img1, InputArray image2, cv::Ptr<Map> init) const
{
+ Mat img1 = _img1.getMat();
Mat gradx, grady, imgDiff;
Mat img2;
@@ -66,11 +67,11 @@ void MapperGradProj::calculate(
CV_DbgAssert(img1.channels() == image2.channels());
CV_DbgAssert(img1.channels() == 1 || img1.channels() == 3);
- if(!res.empty()) {
+ if(!init.empty()) {
// We have initial values for the registration: we move img2 to that initial reference
- res->inverseWarp(image2, img2);
+ init->inverseWarp(image2, img2);
} else {
- img2 = image2;
+ img2 = image2.getMat();
}
// Get gradient in all channels
@@ -195,16 +196,19 @@ void MapperGradProj::calculate(
Vec<double, 8> k = A.inv(DECOMP_CHOLESKY)*b;
Matx<double, 3, 3> H(k(0) + 1., k(1), k(2), k(3), k(4) + 1., k(5), k(6), k(7), 1.);
- if(res.empty()) {
- res = Ptr<Map>(new MapProjec(H));
+ if(init.empty()) {
+ return Ptr<Map>(new MapProjec(H));
} else {
- MapProjec newTr(H);
- res->compose(newTr);
+ Ptr<MapProjec> newTr(new MapProjec(H));
+ MapProjec* initPtr = dynamic_cast<MapProjec*>(init.get());
+ Ptr<MapProjec> oldTr(new MapProjec(initPtr->getProjTr()));
+ oldTr->compose(newTr);
+ return oldTr;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-cv::Ptr<Map> MapperGradProj::getMap(void) const
+cv::Ptr<Map> MapperGradProj::getMap() const
{
return cv::Ptr<Map>(new MapProjec());
}
diff --git a/contrib/modules/reg/src/mappergradshift.cpp b/contrib/modules/reg/src/mappergradshift.cpp
index 517a373..d77fb3c 100644
--- a/contrib/modules/reg/src/mappergradshift.cpp
+++ b/contrib/modules/reg/src/mappergradshift.cpp
@@ -44,31 +44,32 @@ namespace reg {
////////////////////////////////////////////////////////////////////////////////////////////////////
-MapperGradShift::MapperGradShift(void)
+MapperGradShift::MapperGradShift()
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-MapperGradShift::~MapperGradShift(void)
+MapperGradShift::~MapperGradShift()
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void MapperGradShift::calculate(
- const cv::Mat& img1, const cv::Mat& image2, cv::Ptr<Map>& res) const
+cv::Ptr<Map> MapperGradShift::calculate(
+ InputArray _img1, InputArray image2, cv::Ptr<Map> init) const
{
+ Mat img1 = _img1.getMat();
Mat gradx, grady, imgDiff;
Mat img2;
CV_DbgAssert(img1.size() == image2.size());
- if(!res.empty()) {
+ if(!init.empty()) {
// We have initial values for the registration: we move img2 to that initial reference
- res->inverseWarp(image2, img2);
+ init->inverseWarp(image2, img2);
} else {
- img2 = image2;
+ img2 = image2.getMat();
}
// Get gradient in all channels
@@ -92,16 +93,19 @@ void MapperGradShift::calculate(
// Calculate shift. We use Cholesky decomposition, as A is symmetric.
Vec<double, 2> shift = A.inv(DECOMP_CHOLESKY)*b;
- if(res.empty()) {
- res = Ptr<Map>(new MapShift(shift));
+ if(init.empty()) {
+ return Ptr<Map>(new MapShift(shift));
} else {
- MapShift newTr(shift);
- res->compose(newTr);
+ Ptr<MapShift> newTr(new MapShift(shift));
+ MapShift* initPtr = dynamic_cast<MapShift*>(init.get());
+ Ptr<MapShift> oldTr(new MapShift(initPtr->getShift()));
+ oldTr->compose(newTr);
+ return oldTr;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-cv::Ptr<Map> MapperGradShift::getMap(void) const
+cv::Ptr<Map> MapperGradShift::getMap() const
{
return cv::Ptr<Map>(new MapShift());
}
diff --git a/contrib/modules/reg/src/mappergradsimilar.cpp b/contrib/modules/reg/src/mappergradsimilar.cpp
index 0b7a615..1a40190 100644
--- a/contrib/modules/reg/src/mappergradsimilar.cpp
+++ b/contrib/modules/reg/src/mappergradsimilar.cpp
@@ -44,21 +44,22 @@ namespace reg {
////////////////////////////////////////////////////////////////////////////////////////////////////
-MapperGradSimilar::MapperGradSimilar(void)
+MapperGradSimilar::MapperGradSimilar()
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-MapperGradSimilar::~MapperGradSimilar(void)
+MapperGradSimilar::~MapperGradSimilar()
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void MapperGradSimilar::calculate(
- const cv::Mat& img1, const cv::Mat& image2, cv::Ptr<Map>& res) const
+cv::Ptr<Map> MapperGradSimilar::calculate(
+ InputArray _img1, InputArray image2, cv::Ptr<Map> init) const
{
+ Mat img1 = _img1.getMat();
Mat gradx, grady, imgDiff;
Mat img2;
@@ -66,11 +67,11 @@ void MapperGradSimilar::calculate(
CV_DbgAssert(img1.channels() == image2.channels());
CV_DbgAssert(img1.channels() == 1 || img1.channels() == 3);
- if(!res.empty()) {
+ if(!init.empty()) {
// We have initial values for the registration: we move img2 to that initial reference
- res->inverseWarp(image2, img2);
+ init->inverseWarp(image2, img2);
} else {
- img2 = image2;
+ img2 = image2.getMat();
}
// Get gradient in all channels
@@ -126,16 +127,19 @@ void MapperGradSimilar::calculate(
Matx<double, 2, 2> linTr(k(0) + 1., k(1), -k(1), k(0) + 1.);
Vec<double, 2> shift(k(2), k(3));
- if(res.empty()) {
- res = Ptr<Map>(new MapAffine(linTr, shift));
+ if(init.empty()) {
+ return Ptr<Map>(new MapAffine(linTr, shift));
} else {
- MapAffine newTr(linTr, shift);
- res->compose(newTr);
+ Ptr<MapAffine> newTr(new MapAffine(linTr, shift));
+ MapAffine* initPtr = dynamic_cast<MapAffine*>(init.get());
+ Ptr<MapAffine> oldTr(new MapAffine(initPtr->getLinTr(), initPtr->getShift()));
+ oldTr->compose(newTr);
+ return oldTr;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-cv::Ptr<Map> MapperGradSimilar::getMap(void) const
+cv::Ptr<Map> MapperGradSimilar::getMap() const
{
return cv::Ptr<Map>(new MapAffine());
}
diff --git a/contrib/modules/reg/src/mapperpyramid.cpp b/contrib/modules/reg/src/mapperpyramid.cpp
index 88c4018..4ec40be 100644
--- a/contrib/modules/reg/src/mapperpyramid.cpp
+++ b/contrib/modules/reg/src/mapperpyramid.cpp
@@ -48,22 +48,23 @@ namespace reg {
////////////////////////////////////////////////////////////////////////////////////////////////////
-MapperPyramid::MapperPyramid(const Mapper& baseMapper)
- : numLev_(3), numIterPerScale_(3), baseMapper_(baseMapper)
+MapperPyramid::MapperPyramid(Ptr<Mapper> baseMapper)
+ : numLev_(3), numIterPerScale_(3), baseMapper_(*baseMapper)
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void MapperPyramid::calculate(const Mat& img1, const Mat& image2, Ptr<Map>& res) const
+Ptr<Map> MapperPyramid::calculate(InputArray _img1, InputArray image2, Ptr<Map> init) const
{
+ Mat img1 = _img1.getMat();
Mat img2;
- if(!res.empty()) {
+ if(!init.empty()) {
// We have initial values for the registration: we move img2 to that initial reference
- res->inverseWarp(image2, img2);
+ init->inverseWarp(image2, img2);
} else {
- res = baseMapper_.getMap();
- img2 = image2;
+ init = baseMapper_.getMap();
+ img2 = image2.getMat();
}
cv::Ptr<Map> ident = baseMapper_.getMap();
@@ -72,29 +73,30 @@ void MapperPyramid::calculate(const Mat& img1, const Mat& image2, Ptr<Map>& res)
vector<Mat> pyrIm1(numLev_), pyrIm2(numLev_);
pyrIm1[0] = img1;
pyrIm2[0] = img2;
- for(size_t im_i = 1; im_i < numLev_; ++im_i) {
+ for(int im_i = 1; im_i < numLev_; ++im_i) {
pyrDown(pyrIm1[im_i - 1], pyrIm1[im_i]);
pyrDown(pyrIm2[im_i - 1], pyrIm2[im_i]);
}
Mat currRef, currImg;
- for(size_t lv_i = 0; lv_i < numLev_; ++lv_i) {
+ for(int lv_i = 0; lv_i < numLev_; ++lv_i) {
currRef = pyrIm1[numLev_ - 1 - lv_i];
currImg = pyrIm2[numLev_ - 1 - lv_i];
// Scale the transformation as we are incresing the resolution in each iteration
if(lv_i != 0) {
ident->scale(2.);
}
- for(size_t it_i = 0; it_i < numIterPerScale_; ++it_i) {
- baseMapper_.calculate(currRef, currImg, ident);
+ for(int it_i = 0; it_i < numIterPerScale_; ++it_i) {
+ ident = baseMapper_.calculate(currRef, currImg, ident);
}
}
- res->compose(*ident.get());
+ init->compose(ident);
+ return init;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-cv::Ptr<Map> MapperPyramid::getMap(void) const
+cv::Ptr<Map> MapperPyramid::getMap() const
{
return cv::Ptr<Map>();
}
diff --git a/contrib/modules/reg/src/mapprojec.cpp b/contrib/modules/reg/src/mapprojec.cpp
index 7d5becf..86a3759 100644
--- a/contrib/modules/reg/src/mapprojec.cpp
+++ b/contrib/modules/reg/src/mapprojec.cpp
@@ -45,25 +45,26 @@ namespace reg {
////////////////////////////////////////////////////////////////////////////////////////////////////
-MapProjec::MapProjec(void)
+MapProjec::MapProjec()
: projTr_(Matx<double, 3, 3>::eye())
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-MapProjec::MapProjec(const Matx<double, 3, 3>& projTr)
- : projTr_(projTr)
+MapProjec::MapProjec(InputArray projTr)
+ : projTr_(projTr.getMat())
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-MapProjec::~MapProjec(void)
+MapProjec::~MapProjec()
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void MapProjec::inverseWarp(const Mat& img1, Mat& img2) const
+void MapProjec::inverseWarp(InputArray _img1, OutputArray img2) const
{
+ Mat img1 = _img1.getMat();
// Rows and columns in destination
Mat dest_r, dest_c;
dest_r.create(img1.size(), CV_32FC1);
@@ -95,10 +96,10 @@ Ptr<Map> MapProjec::inverseMap(void) const
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void MapProjec::compose(const Map& map)
+void MapProjec::compose(Ptr<Map> map)
{
// Composition of homographies H and H' is (H o H') = H'*H
- const MapProjec& mapProj = static_cast<const MapProjec&>(map);
+ const MapProjec& mapProj = static_cast<const MapProjec&>(*map);
Matx<double, 3, 3> compProjTr = mapProj.getProjTr()*projTr_;
projTr_ = compProjTr;
}
diff --git a/contrib/modules/reg/src/mapshift.cpp b/contrib/modules/reg/src/mapshift.cpp
index 81262e8..9952eb9 100644
--- a/contrib/modules/reg/src/mapshift.cpp
+++ b/contrib/modules/reg/src/mapshift.cpp
@@ -46,23 +46,26 @@ namespace reg {
////////////////////////////////////////////////////////////////////////////////////////////////////
-MapShift::MapShift(void) : shift_()
+MapShift::MapShift() : shift_()
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-MapShift::MapShift(const Vec<double, 2>& shift) : shift_(shift)
+MapShift::MapShift(InputArray shift)
{
+ Mat shiftMat = shift.getMat();
+ shiftMat.copyTo(shift_);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-MapShift::~MapShift(void)
+MapShift::~MapShift()
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void MapShift::inverseWarp(const Mat& img1, Mat& img2) const
+void MapShift::inverseWarp(InputArray _img1, OutputArray img2) const
{
+ Mat img1 = _img1.getMat();
// Rows and columns in destination
Mat dest_r, dest_c;
dest_r.create(img1.size(), CV_32FC1);
@@ -91,10 +94,10 @@ Ptr<Map> MapShift::inverseMap(void) const
}
////////////////////////////////////////////////////////////////////////////////////////////////////
-void MapShift::compose(const Map& map)
+void MapShift::compose(cv::Ptr<Map> map)
{
// Composition of transformations T and T' is (T o T') = b + b'
- const MapShift& mapShift = static_cast<const MapShift&>(map);
+ const MapShift& mapShift = static_cast<const MapShift&>(*map);
shift_ += mapShift.getShift();
}
diff --git a/contrib/modules/reg/src/precomp.cpp b/contrib/modules/reg/src/precomp.cpp
deleted file mode 100644
index 50a932c..0000000
--- a/contrib/modules/reg/src/precomp.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-// Copyright (C) 2013, Alfonso Sanchez-Beato, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-
-#include "precomp.hpp"
diff --git a/contrib/modules/reg/test/test_precomp.cpp b/contrib/modules/reg/test/test_precomp.cpp
deleted file mode 100644
index d2133d4..0000000
--- a/contrib/modules/reg/test/test_precomp.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Copyright (C) 2013, Alfonso Sanchez-Beato, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
diff --git a/contrib/modules/reg/test/test_reg.cpp b/contrib/modules/reg/test/test_reg.cpp
index 44b19d8..cae7e7f 100644
--- a/contrib/modules/reg/test/test_reg.cpp
+++ b/contrib/modules/reg/test/test_reg.cpp
@@ -59,11 +59,13 @@ using namespace std;
using namespace cv;
using namespace cv::reg;
+#define REG_DEBUG_OUTPUT 0
+
class RegTest : public testing::Test
{
public:
- void loadImage();
+ void loadImage(int dstDataType = CV_32FC3);
void testShift();
void testEuclidean();
@@ -84,20 +86,20 @@ void RegTest::testShift()
mapTest.warp(img1, img2);
// Register
- MapperGradShift mapper;
+ Ptr<Mapper> mapper = makePtr<MapperGradShift>();
MapperPyramid mappPyr(mapper);
- Ptr<Map> mapPtr;
- mappPyr.calculate(img1, img2, mapPtr);
+ Ptr<Map> mapPtr = mappPyr.calculate(img1, img2);
// Print result
- MapShift* mapShift = dynamic_cast<MapShift*>(mapPtr.get());
+ Ptr<MapShift> mapShift = MapTypeCaster::toShift(mapPtr);
+#if REG_DEBUG_OUTPUT
cout << endl << "--- Testing shift mapper ---" << endl;
cout << Mat(shift) << endl;
cout << Mat(mapShift->getShift()) << endl;
-
+#endif
// Check accuracy
Ptr<Map> mapInv(mapShift->inverseMap());
- mapTest.compose(*mapInv.get());
+ mapTest.compose(mapInv);
double shNorm = norm(mapTest.getShift());
EXPECT_LE(shNorm, 0.1);
}
@@ -116,22 +118,22 @@ void RegTest::testEuclidean()
mapTest.warp(img1, img2);
// Register
- MapperGradEuclid mapper;
+ Ptr<Mapper> mapper = makePtr<MapperGradEuclid>();
MapperPyramid mappPyr(mapper);
- Ptr<Map> mapPtr;
- mappPyr.calculate(img1, img2, mapPtr);
+ Ptr<Map> mapPtr = mappPyr.calculate(img1, img2);
// Print result
- MapAffine* mapAff = dynamic_cast<MapAffine*>(mapPtr.get());
+ Ptr<MapAffine> mapAff = MapTypeCaster::toAffine(mapPtr);
+#if REG_DEBUG_OUTPUT
cout << endl << "--- Testing Euclidean mapper ---" << endl;
cout << Mat(linTr) << endl;
cout << Mat(shift) << endl;
cout << Mat(mapAff->getLinTr()) << endl;
cout << Mat(mapAff->getShift()) << endl;
-
+#endif
// Check accuracy
Ptr<Map> mapInv(mapAff->inverseMap());
- mapTest.compose(*mapInv.get());
+ mapTest.compose(mapInv);
double shNorm = norm(mapTest.getShift());
EXPECT_LE(shNorm, 0.1);
double linTrNorm = norm(mapTest.getLinTr());
@@ -154,22 +156,23 @@ void RegTest::testSimilarity()
mapTest.warp(img1, img2);
// Register
- MapperGradSimilar mapper;
+ Ptr<Mapper> mapper = makePtr<MapperGradSimilar>();
MapperPyramid mappPyr(mapper);
- Ptr<Map> mapPtr;
- mappPyr.calculate(img1, img2, mapPtr);
+ Ptr<Map> mapPtr = mappPyr.calculate(img1, img2);
// Print result
- MapAffine* mapAff = dynamic_cast<MapAffine*>(mapPtr.get());
+ Ptr<MapAffine> mapAff = MapTypeCaster::toAffine(mapPtr);
+#if REG_DEBUG_OUTPUT
cout << endl << "--- Testing similarity mapper ---" << endl;
cout << Mat(linTr) << endl;
cout << Mat(shift) << endl;
cout << Mat(mapAff->getLinTr()) << endl;
cout << Mat(mapAff->getShift()) << endl;
+#endif
// Check accuracy
Ptr<Map> mapInv(mapAff->inverseMap());
- mapTest.compose(*mapInv.get());
+ mapTest.compose(mapInv);
double shNorm = norm(mapTest.getShift());
EXPECT_LE(shNorm, 0.1);
double linTrNorm = norm(mapTest.getLinTr());
@@ -188,22 +191,23 @@ void RegTest::testAffine()
mapTest.warp(img1, img2);
// Register
- MapperGradAffine mapper;
+ Ptr<Mapper> mapper = makePtr<MapperGradAffine>();
MapperPyramid mappPyr(mapper);
- Ptr<Map> mapPtr;
- mappPyr.calculate(img1, img2, mapPtr);
+ Ptr<Map> mapPtr = mappPyr.calculate(img1, img2);
// Print result
- MapAffine* mapAff = dynamic_cast<MapAffine*>(mapPtr.get());
+ Ptr<MapAffine> mapAff = MapTypeCaster::toAffine(mapPtr);
+#if REG_DEBUG_OUTPUT
cout << endl << "--- Testing affine mapper ---" << endl;
cout << Mat(linTr) << endl;
cout << Mat(shift) << endl;
cout << Mat(mapAff->getLinTr()) << endl;
cout << Mat(mapAff->getShift()) << endl;
+#endif
// Check accuracy
Ptr<Map> mapInv(mapAff->inverseMap());
- mapTest.compose(*mapInv.get());
+ mapTest.compose(mapInv);
double shNorm = norm(mapTest.getShift());
EXPECT_LE(shNorm, 0.1);
double linTrNorm = norm(mapTest.getLinTr());
@@ -222,34 +226,34 @@ void RegTest::testProjective()
mapTest.warp(img1, img2);
// Register
- MapperGradProj mapper;
+ Ptr<Mapper> mapper = makePtr<MapperGradProj>();
MapperPyramid mappPyr(mapper);
- Ptr<Map> mapPtr;
- mappPyr.calculate(img1, img2, mapPtr);
+ Ptr<Map> mapPtr = mappPyr.calculate(img1, img2);
// Print result
- MapProjec* mapProj = dynamic_cast<MapProjec*>(mapPtr.get());
+ Ptr<MapProjec> mapProj = MapTypeCaster::toProjec(mapPtr);
mapProj->normalize();
+#if REG_DEBUG_OUTPUT
cout << endl << "--- Testing projective transformation mapper ---" << endl;
cout << Mat(projTr) << endl;
cout << Mat(mapProj->getProjTr()) << endl;
+#endif
// Check accuracy
Ptr<Map> mapInv(mapProj->inverseMap());
- mapTest.compose(*mapInv.get());
+ mapTest.compose(mapInv);
double projNorm = norm(mapTest.getProjTr());
EXPECT_LE(projNorm, sqrt(3.) + 0.01);
EXPECT_GE(projNorm, sqrt(3.) - 0.01);
}
-void RegTest::loadImage()
+void RegTest::loadImage(int dstDataType)
{
const string imageName = cvtest::TS::ptr()->get_data_path() + "reg/home.png";
img1 = imread(imageName, -1);
- ASSERT_TRUE(img1.data != 0);
- // Convert to double, 3 channels
- img1.convertTo(img1, CV_64FC3);
+ ASSERT_TRUE(!img1.empty());
+ img1.convertTo(img1, dstDataType);
}
@@ -282,3 +286,15 @@ TEST_F(RegTest, projective)
loadImage();
testProjective();
}
+
+TEST_F(RegTest, projective_dt64fc3)
+{
+ loadImage(CV_64FC3);
+ testProjective();
+}
+
+TEST_F(RegTest, projective_dt64fc1)
+{
+ loadImage(CV_64FC1);
+ testProjective();
+}
diff --git a/contrib/modules/rgbd/CMakeLists.txt b/contrib/modules/rgbd/CMakeLists.txt
index f7c6b17..f2e022f 100644
--- a/contrib/modules/rgbd/CMakeLists.txt
+++ b/contrib/modules/rgbd/CMakeLists.txt
@@ -1,3 +1,2 @@
set(the_description "RGBD algorithms")
-ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef)
-ocv_define_module(rgbd opencv_core opencv_calib3d opencv_highgui opencv_imgproc WRAP python)
+ocv_define_module(rgbd opencv_core opencv_calib3d opencv_imgproc WRAP python)
diff --git a/contrib/modules/rgbd/include/opencv2/rgbd.hpp b/contrib/modules/rgbd/include/opencv2/rgbd.hpp
index b25bd3d..e245044 100644
--- a/contrib/modules/rgbd/include/opencv2/rgbd.hpp
+++ b/contrib/modules/rgbd/include/opencv2/rgbd.hpp
@@ -334,7 +334,7 @@ namespace rgbd
* depth of `K` if `depth` is of depth CV_U
* @param mask the mask of the points to consider (can be empty)
*/
- CV_EXPORTS
+ CV_EXPORTS_W
void
depthTo3d(InputArray depth, InputArray K, OutputArray points3d, InputArray mask = noArray());
@@ -1026,10 +1026,10 @@ namespace rgbd
* @param warpedDepth The warped depth.
* @param warpedMask The warped mask.
*/
- CV_EXPORTS
+ CV_EXPORTS_W
void
warpFrame(const Mat& image, const Mat& depth, const Mat& mask, const Mat& Rt, const Mat& cameraMatrix,
- const Mat& distCoeff, Mat& warpedImage, Mat* warpedDepth = 0, Mat* warpedMask = 0);
+ const Mat& distCoeff, OutputArray warpedImage, OutputArray warpedDepth = noArray(), OutputArray warpedMask = noArray());
// TODO Depth interpolation
// Curvature
diff --git a/contrib/modules/rgbd/include/opencv2/rgbd/linemod.hpp b/contrib/modules/rgbd/include/opencv2/rgbd/linemod.hpp
index ac56291..9982aa0 100644
--- a/contrib/modules/rgbd/include/opencv2/rgbd/linemod.hpp
+++ b/contrib/modules/rgbd/include/opencv2/rgbd/linemod.hpp
@@ -60,14 +60,14 @@ namespace linemod {
/**
* \brief Discriminant feature described by its location and label.
*/
-struct CV_EXPORTS Feature
+struct CV_EXPORTS_W_SIMPLE Feature
{
- int x; ///< x offset
- int y; ///< y offset
- int label; ///< Quantization
+ CV_PROP_RW int x; ///< x offset
+ CV_PROP_RW int y; ///< y offset
+ CV_PROP_RW int label; ///< Quantization
- Feature() : x(0), y(0), label(0) {}
- Feature(int x, int y, int label);
+ CV_WRAP Feature() : x(0), y(0), label(0) {}
+ CV_WRAP Feature(int x, int y, int label);
void read(const FileNode& fn);
void write(FileStorage& fs) const;
@@ -75,12 +75,12 @@ struct CV_EXPORTS Feature
inline Feature::Feature(int _x, int _y, int _label) : x(_x), y(_y), label(_label) {}
-struct CV_EXPORTS Template
+struct CV_EXPORTS_W_SIMPLE Template
{
- int width;
- int height;
- int pyramid_level;
- std::vector<Feature> features;
+ CV_PROP int width;
+ CV_PROP int height;
+ CV_PROP int pyramid_level;
+ CV_PROP std::vector<Feature> features;
void read(const FileNode& fn);
void write(FileStorage& fs) const;
@@ -89,7 +89,7 @@ struct CV_EXPORTS Template
/**
* \brief Represents a modality operating over an image pyramid.
*/
-class QuantizedPyramid
+class CV_EXPORTS_W QuantizedPyramid
{
public:
// Virtual destructor
@@ -101,21 +101,21 @@ public:
* \param[out] dst The destination 8-bit image. For each pixel at most one bit is set,
* representing its classification.
*/
- virtual void quantize(Mat& dst) const =0;
+ CV_WRAP virtual void quantize(CV_OUT Mat& dst) const =0;
/**
* \brief Extract most discriminant features at current pyramid level to form a new template.
*
* \param[out] templ The new template.
*/
- virtual bool extractTemplate(Template& templ) const =0;
+ CV_WRAP virtual bool extractTemplate(CV_OUT Template& templ) const =0;
/**
* \brief Go to the next pyramid level.
*
* \todo Allow pyramid scale factor other than 2
*/
- virtual void pyrDown() =0;
+ CV_WRAP virtual void pyrDown() =0;
protected:
/// Candidate feature with a score
@@ -153,7 +153,7 @@ inline QuantizedPyramid::Candidate::Candidate(int x, int y, int label, float _sc
*
* \todo Max response, to allow optimization of summing (255/MAX) features as uint8
*/
-class CV_EXPORTS Modality
+class CV_EXPORTS_W Modality
{
public:
// Virtual destructor
@@ -166,15 +166,15 @@ public:
* \param[in] mask Optional mask. If not empty, unmasked pixels are set to zero
* in quantized image and cannot be extracted as features.
*/
- Ptr<QuantizedPyramid> process(const Mat& src,
+ CV_WRAP Ptr<QuantizedPyramid> process(const Mat& src,
const Mat& mask = Mat()) const
{
return processImpl(src, mask);
}
- virtual String name() const =0;
+ CV_WRAP virtual String name() const =0;
- virtual void read(const FileNode& fn) =0;
+ CV_WRAP virtual void read(const FileNode& fn) =0;
virtual void write(FileStorage& fs) const =0;
/**
@@ -184,12 +184,12 @@ public:
* - "ColorGradient"
* - "DepthNormal"
*/
- static Ptr<Modality> create(const String& modality_type);
+ CV_WRAP static Ptr<Modality> create(const String& modality_type);
/**
* \brief Load a modality from file.
*/
- static Ptr<Modality> create(const FileNode& fn);
+ CV_WRAP static Ptr<Modality> create(const FileNode& fn);
protected:
// Indirection is because process() has a default parameter.
@@ -274,18 +274,18 @@ protected:
/**
* \brief Debug function to colormap a quantized image for viewing.
*/
-void colormap(const Mat& quantized, Mat& dst);
+CV_EXPORTS_W void colormap(const Mat& quantized, CV_OUT Mat& dst);
/**
* \brief Represents a successful template match.
*/
-struct CV_EXPORTS Match
+struct CV_EXPORTS_W_SIMPLE Match
{
- Match()
+ CV_WRAP Match()
{
}
- Match(int x, int y, float similarity, const String& class_id, int template_id);
+ CV_WRAP Match(int x, int y, float similarity, const String& class_id, int template_id);
/// Sort matches with high similarity to the front
bool operator<(const Match& rhs) const
@@ -302,11 +302,11 @@ struct CV_EXPORTS Match
return x == rhs.x && y == rhs.y && similarity == rhs.similarity && class_id == rhs.class_id;
}
- int x;
- int y;
- float similarity;
- String class_id;
- int template_id;
+ CV_PROP_RW int x;
+ CV_PROP_RW int y;
+ CV_PROP_RW float similarity;
+ CV_PROP_RW String class_id;
+ CV_PROP_RW int template_id;
};
inline
@@ -318,13 +318,13 @@ Match::Match(int _x, int _y, float _similarity, const String& _class_id, int _te
* \brief Object detector using the LINE template matching algorithm with any set of
* modalities.
*/
-class CV_EXPORTS Detector
+class CV_EXPORTS_W Detector
{
public:
/**
* \brief Empty constructor, initialize with read().
*/
- Detector();
+ CV_WRAP Detector();
/**
* \brief Constructor.
@@ -333,7 +333,7 @@ public:
* \param T_pyramid Value of the sampling step T at each pyramid level. The
* number of pyramid levels is T_pyramid.size().
*/
- Detector(const std::vector< Ptr<Modality> >& modalities, const std::vector<int>& T_pyramid);
+ CV_WRAP Detector(const std::vector< Ptr<Modality> >& modalities, const std::vector<int>& T_pyramid);
/**
* \brief Detect objects by template matching.
@@ -350,7 +350,7 @@ public:
* the same size as sources. Each element must be
* empty or the same size as its corresponding source.
*/
- void match(const std::vector<Mat>& sources, float threshold, std::vector<Match>& matches,
+ CV_WRAP void match(const std::vector<Mat>& sources, float threshold, CV_OUT std::vector<Match>& matches,
const std::vector<String>& class_ids = std::vector<String>(),
OutputArrayOfArrays quantized_images = noArray(),
const std::vector<Mat>& masks = std::vector<Mat>()) const;
@@ -365,13 +365,13 @@ public:
*
* \return Template ID, or -1 if failed to extract a valid template.
*/
- int addTemplate(const std::vector<Mat>& sources, const String& class_id,
- const Mat& object_mask, Rect* bounding_box = NULL);
+ CV_WRAP int addTemplate(const std::vector<Mat>& sources, const String& class_id,
+ const Mat& object_mask, CV_OUT Rect* bounding_box = NULL);
/**
* \brief Add a new object template computed by external means.
*/
- int addSyntheticTemplate(const std::vector<Template>& templates, const String& class_id);
+ CV_WRAP int addSyntheticTemplate(const std::vector<Template>& templates, const String& class_id);
/**
* \brief Get the modalities used by this detector.
@@ -379,17 +379,17 @@ public:
* You are not permitted to add/remove modalities, but you may dynamic_cast them to
* tweak parameters.
*/
- const std::vector< Ptr<Modality> >& getModalities() const { return modalities; }
+ CV_WRAP const std::vector< Ptr<Modality> >& getModalities() const { return modalities; }
/**
* \brief Get sampling step T at pyramid_level.
*/
- int getT(int pyramid_level) const { return T_at_level[pyramid_level]; }
+ CV_WRAP int getT(int pyramid_level) const { return T_at_level[pyramid_level]; }
/**
* \brief Get number of pyramid levels used by this detector.
*/
- int pyramidLevels() const { return pyramid_levels; }
+ CV_WRAP int pyramidLevels() const { return pyramid_levels; }
/**
* \brief Get the template pyramid identified by template_id.
@@ -397,23 +397,23 @@ public:
* For example, with 2 modalities (Gradient, Normal) and two pyramid levels
* (L0, L1), the order is (GradientL0, NormalL0, GradientL1, NormalL1).
*/
- const std::vector<Template>& getTemplates(const String& class_id, int template_id) const;
+ CV_WRAP const std::vector<Template>& getTemplates(const String& class_id, int template_id) const;
- int numTemplates() const;
- int numTemplates(const String& class_id) const;
- int numClasses() const { return static_cast<int>(class_templates.size()); }
+ CV_WRAP int numTemplates() const;
+ CV_WRAP int numTemplates(const String& class_id) const;
+ CV_WRAP int numClasses() const { return static_cast<int>(class_templates.size()); }
- std::vector<String> classIds() const;
+ CV_WRAP std::vector<String> classIds() const;
- void read(const FileNode& fn);
+ CV_WRAP void read(const FileNode& fn);
void write(FileStorage& fs) const;
String readClass(const FileNode& fn, const String &class_id_override = "");
void writeClass(const String& class_id, FileStorage& fs) const;
- void readClasses(const std::vector<String>& class_ids,
+ CV_WRAP void readClasses(const std::vector<String>& class_ids,
const String& format = "templates_%s.yml.gz");
- void writeClasses(const String& format = "templates_%s.yml.gz") const;
+ CV_WRAP void writeClasses(const String& format = "templates_%s.yml.gz") const;
protected:
std::vector< Ptr<Modality> > modalities;
@@ -440,7 +440,7 @@ protected:
*
* Default parameter settings suitable for VGA images.
*/
-CV_EXPORTS Ptr<Detector> getDefaultLINE();
+CV_EXPORTS_W Ptr<linemod::Detector> getDefaultLINE();
/**
* \brief Factory function for detector using LINE-MOD algorithm with color gradients
@@ -448,7 +448,7 @@ CV_EXPORTS Ptr<Detector> getDefaultLINE();
*
* Default parameter settings suitable for VGA images.
*/
-CV_EXPORTS Ptr<Detector> getDefaultLINEMOD();
+CV_EXPORTS_W Ptr<linemod::Detector> getDefaultLINEMOD();
//! @}
diff --git a/contrib/modules/rgbd/misc/python/pyopencv_linemod.hpp b/contrib/modules/rgbd/misc/python/pyopencv_linemod.hpp
new file mode 100644
index 0000000..5438892
--- /dev/null
+++ b/contrib/modules/rgbd/misc/python/pyopencv_linemod.hpp
@@ -0,0 +1,46 @@
+#ifdef HAVE_OPENCV_RGBD
+#include "opencv2/core/saturate.hpp"
+
+template<> struct pyopencvVecConverter<linemod::Match>
+{
+ static bool to(PyObject* obj, std::vector<linemod::Match>& value, const ArgInfo info)
+ {
+ return pyopencv_to_generic_vec(obj, value, info);
+ }
+
+ static PyObject* from(const std::vector<linemod::Match>& value)
+ {
+ return pyopencv_from_generic_vec(value);
+ }
+};
+
+template<> struct pyopencvVecConverter<linemod::Template>
+{
+ static bool to(PyObject* obj, std::vector<linemod::Template>& value, const ArgInfo info)
+ {
+ return pyopencv_to_generic_vec(obj, value, info);
+ }
+
+ static PyObject* from(const std::vector<linemod::Template>& value)
+ {
+ return pyopencv_from_generic_vec(value);
+ }
+};
+
+template<> struct pyopencvVecConverter<Ptr<linemod::Modality> >
+{
+ static bool to(PyObject* obj, std::vector<Ptr<linemod::Modality> >& value, const ArgInfo info)
+ {
+ return pyopencv_to_generic_vec(obj, value, info);
+ }
+
+ static PyObject* from(const std::vector<Ptr<linemod::Modality> >& value)
+ {
+ return pyopencv_from_generic_vec(value);
+ }
+};
+
+typedef std::vector<linemod::Match> vector_Match;
+typedef std::vector<linemod::Template> vector_Template;
+typedef std::vector<Ptr<linemod::Modality> > vector_Ptr_Modality;
+#endif
diff --git a/contrib/modules/rgbd/src/depth_to_3d.cpp b/contrib/modules/rgbd/src/depth_to_3d.cpp
index bcea271..cdcc4ea 100644
--- a/contrib/modules/rgbd/src/depth_to_3d.cpp
+++ b/contrib/modules/rgbd/src/depth_to_3d.cpp
@@ -232,14 +232,8 @@ namespace rgbd
depth.type() == CV_64FC1 || depth.type() == CV_32FC1 || depth.type() == CV_16UC1 || depth.type() == CV_16SC1);
CV_Assert(mask.empty() || mask.channels() == 1);
- // TODO figure out what to do when types are different: convert or reject ?
cv::Mat K_new;
- if ((depth.depth() == CV_32F || depth.depth() == CV_64F) && depth.depth() != K.depth())
- {
- K.convertTo(K_new, depth.depth());
- }
- else
- K_new = K;
+ K.convertTo(K_new, depth.depth() == CV_64F ? CV_64F : CV_32F); // issue #1021
// Create 3D points in one go.
if (!mask.empty())
diff --git a/contrib/modules/rgbd/src/odometry.cpp b/contrib/modules/rgbd/src/odometry.cpp
index 17b3dd3..1e46b25 100644
--- a/contrib/modules/rgbd/src/odometry.cpp
+++ b/contrib/modules/rgbd/src/odometry.cpp
@@ -49,8 +49,8 @@ namespace rgbd
enum
{
- RGBD_ODOMETRY = 1,
- ICP_ODOMETRY = 2,
+ RGBD_ODOMETRY = 1,
+ ICP_ODOMETRY = 2,
MERGED_ODOMETRY = RGBD_ODOMETRY + ICP_ODOMETRY
};
@@ -436,7 +436,7 @@ void computeProjectiveMatrix(const Mat& ksi, Mat& Rt)
eigen2cv(g, Rt);
#else
- // TODO: check computeProjectiveMatrix when there is not eigen library,
+ // TODO: check computeProjectiveMatrix when there is not eigen library,
// because it gives less accurate pose of the camera
Rt = Mat::eye(4, 4, CV_64FC1);
@@ -462,7 +462,7 @@ void computeCorresps(const Mat& K, const Mat& K_inv, const Mat& Rt,
CV_Assert(Rt.type() == CV_64FC1);
Mat corresps(depth1.size(), CV_16SC2, Scalar::all(-1));
-
+
Rect r(0, 0, depth1.cols, depth1.rows);
Mat Kt = Rt(Rect(3,0,1,3)).clone();
Kt = K * Kt;
@@ -486,7 +486,7 @@ void computeCorresps(const Mat& K, const Mat& K_inv, const Mat& Rt,
KRK_inv3_u1[u1] = (float)(KRK_inv_ptr[3] * u1);
KRK_inv6_u1[u1] = (float)(KRK_inv_ptr[6] * u1);
}
-
+
for(int v1 = 0; v1 < depth1.rows; v1++)
{
KRK_inv1_v1_plus_KRK_inv2[v1] = (float)(KRK_inv_ptr[1] * v1 + KRK_inv_ptr[2]);
@@ -506,16 +506,16 @@ void computeCorresps(const Mat& K, const Mat& K_inv, const Mat& Rt,
if(mask1_row[u1])
{
CV_DbgAssert(!cvIsNaN(d1));
- float transformed_d1 = static_cast<float>(d1 * (KRK_inv6_u1[u1] + KRK_inv7_v1_plus_KRK_inv8[v1]) +
+ float transformed_d1 = static_cast<float>(d1 * (KRK_inv6_u1[u1] + KRK_inv7_v1_plus_KRK_inv8[v1]) +
Kt_ptr[2]);
if(transformed_d1 > 0)
{
float transformed_d1_inv = 1.f / transformed_d1;
- int u0 = cvRound(transformed_d1_inv * (d1 * (KRK_inv0_u1[u1] + KRK_inv1_v1_plus_KRK_inv2[v1]) +
+ int u0 = cvRound(transformed_d1_inv * (d1 * (KRK_inv0_u1[u1] + KRK_inv1_v1_plus_KRK_inv2[v1]) +
Kt_ptr[0]));
- int v0 = cvRound(transformed_d1_inv * (d1 * (KRK_inv3_u1[u1] + KRK_inv4_v1_plus_KRK_inv5[v1]) +
+ int v0 = cvRound(transformed_d1_inv * (d1 * (KRK_inv3_u1[u1] + KRK_inv4_v1_plus_KRK_inv5[v1]) +
Kt_ptr[1]));
-
+
if(r.contains(Point(u0,v0)))
{
float d0 = depth0.at<float>(v0,u0);
@@ -527,7 +527,7 @@ void computeCorresps(const Mat& K, const Mat& K_inv, const Mat& Rt,
{
int exist_u1 = c[0], exist_v1 = c[1];
- float exist_d1 = (float)(depth1.at<float>(exist_v1,exist_u1) *
+ float exist_d1 = (float)(depth1.at<float>(exist_v1,exist_u1) *
(KRK_inv6_u1[exist_u1] + KRK_inv7_v1_plus_KRK_inv8[exist_v1]) + Kt_ptr[2]);
if(transformed_d1 > exist_d1)
@@ -631,7 +631,7 @@ void calcICPEquationCoeffsTranslation(double* C, const Point3f& /*p0*/, const Ve
typedef
void (*CalcICPEquationCoeffsPtr)(double*, const Point3f&, const Vec3f&);
-static
+static
void calcRgbdLsmMatrices(const Mat& image0, const Mat& cloud0, const Mat& Rt,
const Mat& image1, const Mat& dI_dx1, const Mat& dI_dy1,
const Mat& corresps, double fx, double fy, double sobelScaleIn,
@@ -657,8 +657,8 @@ void calcRgbdLsmMatrices(const Mat& image0, const Mat& cloud0, const Mat& Rt,
const Vec4i& c = corresps_ptr[correspIndex];
int u0 = c[0], v0 = c[1];
int u1 = c[2], v1 = c[3];
-
- diffs_ptr[correspIndex] = static_cast<float>(static_cast<int>(image0.at<uchar>(v0,u0)) -
+
+ diffs_ptr[correspIndex] = static_cast<float>(static_cast<int>(image0.at<uchar>(v0,u0)) -
static_cast<int>(image1.at<uchar>(v1,u1)));
sigma += diffs_ptr[correspIndex] * diffs_ptr[correspIndex];
}
@@ -697,8 +697,8 @@ void calcRgbdLsmMatrices(const Mat& image0, const Mat& cloud0, const Mat& Rt,
AtB_ptr[y] += A_ptr[y] * w * diffs_ptr[correspIndex];
}
- }
-
+ }
+
for(int y = 0; y < transformDim; y++)
for(int x = y+1; x < transformDim; x++)
AtA.at<double>(x,y) = AtA.at<double>(y,x);
@@ -790,16 +790,16 @@ bool solveSystem(const Mat& AtA, const Mat& AtB, double detThreshold, Mat& x)
return true;
}
-static
+static
bool testDeltaTransformation(const Mat& deltaRt, double maxTranslation, double maxRotation)
{
double translation = norm(deltaRt(Rect(3, 0, 1, 3)));
-
+
Mat rvec;
Rodrigues(deltaRt(Rect(0,0,3,3)), rvec);
-
+
double rotation = norm(rvec) * 180. / CV_PI;
-
+
return translation <= maxTranslation && rotation <= maxRotation;
}
@@ -920,9 +920,9 @@ bool RGBDICPOdometryImpl(Mat& Rt, const Mat& initRt,
isOk = true;
}
}
-
+
Rt = resultRt;
-
+
if(isOk)
{
Mat deltaRt;
@@ -941,24 +941,25 @@ template<class ImageElemType>
static void
warpFrameImpl(const Mat& image, const Mat& depth, const Mat& mask,
const Mat& Rt, const Mat& cameraMatrix, const Mat& distCoeff,
- Mat& warpedImage, Mat* warpedDepth, Mat* warpedMask)
+ OutputArray _warpedImage, OutputArray warpedDepth, OutputArray warpedMask)
{
CV_Assert(image.size() == depth.size());
-
+
Mat cloud;
depthTo3d(depth, cameraMatrix, cloud);
-
+
std::vector<Point2f> points2d;
Mat transformedCloud;
perspectiveTransform(cloud, transformedCloud, Rt);
projectPoints(transformedCloud.reshape(3, 1), Mat::eye(3, 3, CV_64FC1), Mat::zeros(3, 1, CV_64FC1), cameraMatrix,
distCoeff, points2d);
- warpedImage = Mat(image.size(), image.type(), Scalar::all(0));
+ _warpedImage.create(image.size(), image.type());
+ Mat warpedImage = _warpedImage.getMat();
Mat zBuffer(image.size(), CV_32FC1, std::numeric_limits<float>::max());
const Rect rect = Rect(0, 0, image.cols, image.rows);
-
+
for (int y = 0; y < image.rows; y++)
{
//const Point3f* cloud_row = cloud.ptr<Point3f>(y);
@@ -978,13 +979,13 @@ warpFrameImpl(const Mat& image, const Mat& depth, const Mat& mask,
}
}
- if(warpedMask)
- *warpedMask = zBuffer != std::numeric_limits<float>::max();
+ if(warpedMask.needed())
+ Mat(zBuffer != std::numeric_limits<float>::max()).copyTo(warpedMask);
- if(warpedDepth)
+ if(warpedDepth.needed())
{
zBuffer.setTo(std::numeric_limits<float>::quiet_NaN(), zBuffer == std::numeric_limits<float>::max());
- *warpedDepth = zBuffer;
+ zBuffer.copyTo(warpedDepth);
}
}
@@ -1406,7 +1407,7 @@ bool RgbdICPOdometry::computeImpl(const Ptr<OdometryFrame>& srcFrame, const Ptr<
void
warpFrame(const Mat& image, const Mat& depth, const Mat& mask,
const Mat& Rt, const Mat& cameraMatrix, const Mat& distCoeff,
- Mat& warpedImage, Mat* warpedDepth, Mat* warpedMask)
+ OutputArray warpedImage, OutputArray warpedDepth, OutputArray warpedMask)
{
if(image.type() == CV_8UC1)
warpFrameImpl<uchar>(image, depth, mask, Rt, cameraMatrix, distCoeff, warpedImage, warpedDepth, warpedMask);
diff --git a/contrib/modules/rgbd/test/test_precomp.cpp b/contrib/modules/rgbd/test/test_precomp.cpp
deleted file mode 100644
index 5956e13..0000000
--- a/contrib/modules/rgbd/test/test_precomp.cpp
+++ /dev/null
@@ -1 +0,0 @@
-#include "test_precomp.hpp"
diff --git a/contrib/modules/saliency/CMakeLists.txt b/contrib/modules/saliency/CMakeLists.txt
index 1d0d40e..f9bbffc 100644
--- a/contrib/modules/saliency/CMakeLists.txt
+++ b/contrib/modules/saliency/CMakeLists.txt
@@ -3,8 +3,7 @@ if(CV_ICC AND NOT MSVC)
endif()
set(the_description "Saliency API")
-set(OPENCV_MODULE_IS_PART_OF_WORLD OFF)
-ocv_define_module(saliency opencv_imgproc opencv_highgui opencv_features2d WRAP python)
+ocv_define_module(saliency opencv_imgproc opencv_features2d WRAP python)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Woverloaded-virtual)
diff --git a/contrib/modules/saliency/include/opencv2/saliency/saliencySpecializedClasses.hpp b/contrib/modules/saliency/include/opencv2/saliency/saliencySpecializedClasses.hpp
index 2088035..df4b331 100644
--- a/contrib/modules/saliency/include/opencv2/saliency/saliencySpecializedClasses.hpp
+++ b/contrib/modules/saliency/include/opencv2/saliency/saliencySpecializedClasses.hpp
@@ -297,7 +297,7 @@ public:
computeSaliencyImpl function). The bigger value these scores are, it is more likely to be an
object window.
*/
- std::vector<float> getobjectnessValues();
+ CV_WRAP std::vector<float> getobjectnessValues();
/** @brief This is a utility function that allows to set the correct path from which the algorithm will load
the trained model.
diff --git a/contrib/modules/saliency/src/BING/CmFile.cpp b/contrib/modules/saliency/src/BING/CmFile.cpp
index 2c9ba9d..c65ae70 100644
--- a/contrib/modules/saliency/src/BING/CmFile.cpp
+++ b/contrib/modules/saliency/src/BING/CmFile.cpp
@@ -39,7 +39,7 @@
//
//M*/
-#include "precomp.hpp"
+#include "../precomp.hpp"
#include "CmFile.hpp"
namespace cv
diff --git a/contrib/modules/saliency/src/BING/CmShow.cpp b/contrib/modules/saliency/src/BING/CmShow.cpp
index 838ccb9..25b54c6 100644
--- a/contrib/modules/saliency/src/BING/CmShow.cpp
+++ b/contrib/modules/saliency/src/BING/CmShow.cpp
@@ -39,10 +39,10 @@
//
//M*/
-#include "precomp.hpp"
+#include "../precomp.hpp"
#include "CmShow.hpp"
#include "opencv2/core.hpp"
-#include <opencv2/highgui.hpp>
+// #include <opencv2/highgui.hpp>
typedef std::pair<int, int> CostiIdx;
@@ -51,7 +51,7 @@ namespace cv
namespace saliency
{
-Mat CmShow::HistBins( CMat& color3f, CMat& val, CStr& title, bool descendShow, CMat &with )
+Mat CmShow::HistBins( CMat& color3f, CMat& val, bool descendShow, CMat &with )
{
// Prepare data
int H = 300, spaceH = 6, barH = 10, n = color3f.cols;
@@ -98,7 +98,6 @@ Mat CmShow::HistBins( CMat& color3f, CMat& val, CStr& title, bool descendShow, C
x += binW[idx];
}
- imshow( String( title.c_str() ), showImg3b );
return showImg3b;
}
diff --git a/contrib/modules/saliency/src/BING/CmShow.hpp b/contrib/modules/saliency/src/BING/CmShow.hpp
index a15561c..d14aa30 100644
--- a/contrib/modules/saliency/src/BING/CmShow.hpp
+++ b/contrib/modules/saliency/src/BING/CmShow.hpp
@@ -51,7 +51,7 @@ namespace saliency
class CmShow
{
public:
- static cv::Mat HistBins( CMat& color3f, CMat& val, CStr& title, bool descendShow = false, CMat &with = cv::Mat() );
+ static cv::Mat HistBins( CMat& color3f, CMat& val, bool descendShow = false, CMat &with = cv::Mat() );
static void showTinyMat( CStr &title, CMat &m );
static inline void SaveShow( CMat& img, CStr& title );
};
diff --git a/contrib/modules/saliency/src/BING/FilterTIG.cpp b/contrib/modules/saliency/src/BING/FilterTIG.cpp
index d9796bc..0720618 100644
--- a/contrib/modules/saliency/src/BING/FilterTIG.cpp
+++ b/contrib/modules/saliency/src/BING/FilterTIG.cpp
@@ -39,7 +39,7 @@
//
//M*/
-#include "precomp.hpp"
+#include "../precomp.hpp"
#include "CmShow.hpp"
namespace cv
diff --git a/contrib/modules/saliency/src/BING/ValStructVec.cpp b/contrib/modules/saliency/src/BING/ValStructVec.cpp
index 097c9be..8343ced 100644
--- a/contrib/modules/saliency/src/BING/ValStructVec.cpp
+++ b/contrib/modules/saliency/src/BING/ValStructVec.cpp
@@ -39,7 +39,7 @@
//
//M*/
-#include "precomp.hpp"
+#include "../precomp.hpp"
namespace cv
{
diff --git a/contrib/modules/saliency/src/BING/objectnessBING.cpp b/contrib/modules/saliency/src/BING/objectnessBING.cpp
index cd3019b..6e83a09 100644
--- a/contrib/modules/saliency/src/BING/objectnessBING.cpp
+++ b/contrib/modules/saliency/src/BING/objectnessBING.cpp
@@ -39,7 +39,7 @@
//
//M*/
-#include "precomp.hpp"
+#include "../precomp.hpp"
#include "BING/kyheader.hpp"
#include "CmTimer.hpp"
diff --git a/contrib/modules/sfm/CMakeLists.txt b/contrib/modules/sfm/CMakeLists.txt
index 83f0e4d..7576892 100644
--- a/contrib/modules/sfm/CMakeLists.txt
+++ b/contrib/modules/sfm/CMakeLists.txt
@@ -2,14 +2,14 @@ set(the_description "SFM algorithms")
### LIBMV LIGHT EXTERNAL DEPENDENCIES ###
-
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
find_package(Gflags QUIET)
find_package(Ceres QUIET)
if(NOT Ceres_FOUND) # Looks like Ceres find glog on the own, so separate search isn't necessary
find_package(Glog QUIET)
endif()
-if((gflags_FOUND OR GFLAGS_FOUND) AND (glog_FOUND OR GLOG_FOUND))
+if((gflags_FOUND OR GFLAGS_FOUND OR GFLAGS_INCLUDE_DIRS) AND (glog_FOUND OR GLOG_FOUND OR GLOG_INCLUDE_DIRS))
set(_fname "${CMAKE_CURRENT_BINARY_DIR}/test_sfm_deps.cpp")
file(WRITE "${_fname}" "#include <glog/logging.h>\n#include <gflags/gflags.h>\nint main() { (void)(0); return 0; }\n")
try_compile(SFM_DEPS_OK "${CMAKE_BINARY_DIR}" "${_fname}"
diff --git a/contrib/modules/sfm/cmake/FindGflags.cmake b/contrib/modules/sfm/cmake/FindGflags.cmake
index aaaf43f..d3b45da 100644
--- a/contrib/modules/sfm/cmake/FindGflags.cmake
+++ b/contrib/modules/sfm/cmake/FindGflags.cmake
@@ -129,7 +129,11 @@ endmacro(GFLAGS_REPORT_NOT_FOUND)
macro(GFLAGS_CHECK_VARS_DEFINED)
foreach(CHECK_VAR ${ARGN})
if (NOT DEFINED ${CHECK_VAR})
- message(FATAL_ERROR "Ceres Bug: ${CHECK_VAR} is not defined.")
+ if(NOT Gflags_FIND_REQUIRED)
+ gflags_report_not_found("Ceres Bug: ${CHECK_VAR} is not defined.")
+ else()
+ message(FATAL_ERROR "Ceres Bug: ${CHECK_VAR} is not defined.")
+ endif()
endif()
endforeach()
endmacro(GFLAGS_CHECK_VARS_DEFINED)
@@ -283,7 +287,8 @@ if (NOT DEFINED GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION
set(GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION TRUE)
endif()
-if (GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION)
+# Wrap into function because gflags_report_not_found() uses "return" statement
+function(__find_exported_gflags)
# Try to find an exported CMake configuration for gflags, as generated by
# gflags versions >= 2.1.
#
@@ -384,9 +389,19 @@ if (GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION)
if (FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION)
message(STATUS "Detected gflags version: ${gflags_VERSION}")
- #set(GFLAGS_FOUND ${gflags_FOUND})
- #set(GFLAGS_INCLUDE_DIR ${gflags_INCLUDE_DIR})
- #set(GFLAGS_LIBRARY ${gflags_LIBRARIES})
+ if(NOT DEFINED GFLAGS_FOUND AND DEFINED gflags_FOUND)
+ set(GFLAGS_FOUND ${gflags_FOUND})
+ endif()
+ if(NOT DEFINED GFLAGS_INCLUDE_DIR AND DEFINED gflags_INCLUDE_DIR)
+ set(GFLAGS_INCLUDE_DIR ${gflags_INCLUDE_DIR})
+ endif()
+ if(NOT DEFINED GFLAGS_LIBRARY AND DEFINED gflags_LIBRARIES)
+ set(GFLAGS_LIBRARY ${gflags_LIBRARIES})
+ endif()
+
+ if(NOT DEFINED GFLAGS_INCLUDE_DIR)
+ gflags_report_not_found("GFLAGS_INCLUDE_DIR is missing")
+ endif()
# gflags does not export the namespace in their CMake configuration, so
# use our function to determine what it should be, as it can be either
@@ -403,9 +418,18 @@ if (GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION)
"version: ${gflags_VERSION} exported here: ${gflags_DIR} using CMake.")
endif (NOT GFLAGS_NAMESPACE)
else (FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION)
- message(STATUS "Failed to find an installed/exported CMake configuration "
+ gflags_report_not_found("Failed to find an installed/exported CMake configuration "
"for gflags, will perform search for installed gflags components.")
endif (FOUND_INSTALLED_GFLAGS_CMAKE_CONFIGURATION)
+
+ set(GFLAGS_FOUND "${GFLAGS_FOUND}" PARENT_SCOPE)
+ set(GFLAGS_INCLUDE_DIR "${GFLAGS_INCLUDE_DIR}" PARENT_SCOPE)
+ set(GFLAGS_LIBRARY "${GFLAGS_LIBRARY}" PARENT_SCOPE)
+ set(GFLAGS_NAMESPACE "${GFLAGS_NAMESPACE}" PARENT_SCOPE)
+endfunction()
+
+if (GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION)
+ __find_exported_gflags()
endif(GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION)
if (NOT GFLAGS_FOUND)
diff --git a/contrib/modules/sfm/include/opencv2/sfm/reconstruct.hpp b/contrib/modules/sfm/include/opencv2/sfm/reconstruct.hpp
index 2c1267d..d11b622 100644
--- a/contrib/modules/sfm/include/opencv2/sfm/reconstruct.hpp
+++ b/contrib/modules/sfm/include/opencv2/sfm/reconstruct.hpp
@@ -108,7 +108,7 @@ reconstruct(InputArrayOfArrays points2d, OutputArray Rs, OutputArray Ts, InputOu
*/
CV_EXPORTS
void
-reconstruct(const std::vector<std::string> images, OutputArray Ps, OutputArray points3d,
+reconstruct(const std::vector<String> images, OutputArray Ps, OutputArray points3d,
InputOutputArray K, bool is_projective = false);
/** @brief Reconstruct 3d points from 2d images while performing autocalibration.
@@ -128,7 +128,7 @@ reconstruct(const std::vector<std::string> images, OutputArray Ps, OutputArray p
*/
CV_EXPORTS
void
-reconstruct(const std::vector<std::string> images, OutputArray Rs, OutputArray Ts,
+reconstruct(const std::vector<String> images, OutputArray Rs, OutputArray Ts,
InputOutputArray K, OutputArray points3d, bool is_projective = false);
#endif /* CV_DOXYGEN || CERES_FOUND */
diff --git a/contrib/modules/sfm/include/opencv2/sfm/simple_pipeline.hpp b/contrib/modules/sfm/include/opencv2/sfm/simple_pipeline.hpp
index 79e96e5..d882fa8 100644
--- a/contrib/modules/sfm/include/opencv2/sfm/simple_pipeline.hpp
+++ b/contrib/modules/sfm/include/opencv2/sfm/simple_pipeline.hpp
@@ -166,8 +166,8 @@ public:
virtual void run(InputArrayOfArrays points2d, InputOutputArray K, OutputArray Rs,
OutputArray Ts, OutputArray points3d) = 0;
- virtual void run(const std::vector<std::string> &images) = 0;
- virtual void run(const std::vector<std::string> &images, InputOutputArray K, OutputArray Rs,
+ virtual void run(const std::vector<String> &images) = 0;
+ virtual void run(const std::vector<String> &images, InputOutputArray K, OutputArray Rs,
OutputArray Ts, OutputArray points3d) = 0;
CV_WRAP virtual double getError() const = 0;
@@ -219,7 +219,7 @@ public:
- The images must be ordered as they were an image sequence. Additionally, each frame should be as close as posible to the previous and posterior.
- For now DAISY features are used in order to compute the 2d points tracks and it only works for 3-4 images.
*/
- virtual void run(const std::vector<std::string> &images) = 0;
+ virtual void run(const std::vector<String> &images) = 0;
/** @brief Calls the pipeline in order to perform Eclidean reconstruction.
@param images a vector of string with the images paths.
@@ -232,7 +232,7 @@ public:
- The images must be ordered as they were an image sequence. Additionally, each frame should be as close as posible to the previous and posterior.
- For now DAISY features are used in order to compute the 2d points tracks and it only works for 3-4 images.
*/
- virtual void run(const std::vector<std::string> &images, InputOutputArray K, OutputArray Rs,
+ virtual void run(const std::vector<String> &images, InputOutputArray K, OutputArray Rs,
OutputArray Ts, OutputArray points3d) = 0;
/** @brief Returns the computed reprojection error.
diff --git a/contrib/modules/sfm/samples/match_reconstruct.cpp b/contrib/modules/sfm/samples/match_reconstruct.cpp
new file mode 100644
index 0000000..11972ac
--- /dev/null
+++ b/contrib/modules/sfm/samples/match_reconstruct.cpp
@@ -0,0 +1,165 @@
+#include <opencv2/sfm.hpp>
+#include <opencv2/viz.hpp>
+#include <opencv2/calib3d.hpp>
+#include <opencv2/core.hpp>
+
+#include <iostream>
+#include <fstream>
+#include <string>
+
+using namespace std;
+using namespace cv;
+using namespace cv::sfm;
+
+const String keys =
+"{help h usage ? help | | Help message }"
+"{f | 1428 | focal value }"
+"{x | 640 | cx is the image principal point x coordinates in pixels. }"
+"{y | 480 | cy is the image principal point y coordinates in pixels. }"
+"{@arg1 | | empty = simulate data saved in myMatchdata.yml}";
+
+
+int main (int argc,char **argv)
+{
+ CommandLineParser parser(argc, argv, keys);
+
+ if (parser.has("help"))
+ {
+ parser.printMessage();
+ return 0;
+ }
+ String nomFic = parser.get<String>(0);
+ vector<Mat> pt2d1;
+ vector<Mat> pt3d1;
+ Matx33d K = Matx33d( 1428, 0, 640, 0, 1428, 480, 0, 0, 1);
+ if (parser.has("f"))
+ {
+ K(0, 0) = parser.get<double>("f");
+ K(1, 1) = K(0, 0);
+ }
+ if (parser.has("x"))
+ {
+ K(0, 2) = parser.get<double>("x");
+ }
+ if (parser.has("y"))
+ {
+ K(1, 2) = parser.get<double>("y");
+ }
+ if (nomFic.length() == 0)
+ {
+ pt2d1.push_back((Mat_<double>(1, 216) << 1028.8265208422474, 630.75473327994234, 1029.9623410162367, 628.67047008772204, 1033.8855507029073, 621.47126573077719, 1040.2650684237346, 609.76466439182002, 1048.4800533196403, 594.6899271796392, 1057.67755340346, 577.81224590213685, 1066.8749263994853, 560.93479783444945, 1075.089582891565, 545.86066325288073, 1081.4687057168005, 534.15478655886807, 1085.3916118364564, 526.95613925626117, 1028.8265208422474, 630.75473327994234, 1042.62 [...]
+ pt2d1.push_back((Mat_<double>(1, 216) << 1067.8928935365691, 683.58145840030193, 1068.4581827905051, 681.10599202818446, 1071.882360816011, 673.41459952541288, 1077.8853119590685, 661.16770635223315, 1085.8867161323376, 645.56367742058092, 1095.0583596138767, 628.22462933245185, 1104.4226038828747, 611.0007252018562, 1112.9805870843823, 595.7267800366983, 1119.8434591346158, 583.9821639253181, 1124.339246882791, 576.90376658902449, 1067.8928935365691, 683.58145840030193, 1081.715 [...]
+ pt2d1.push_back((Mat_<double>(1, 216) << 1106.5208711485714, 741.50000049355288, 1106.4689494686579, 738.58802914804187, 1109.3501259102466, 730.34841486744574, 1114.939395472757, 717.50083145458598, 1122.7004345574444, 701.30948584821124, 1131.8323058505634, 683.45951438933207, 1141.3637728209014, 665.85274339228056, 1150.2798129066516, 650.35860912193448, 1157.654291765783, 638.57201851568459, 1162.7613665256426, 631.62736960308541, 1106.5208711485714, 741.50000049355288, 1120. [...]
+ pt2d1.push_back((Mat_<double>(1, 216) << 1144.6799579195197, 804.85899215438599, 1143.9597472311048, 801.45615222480399, 1146.2503200861136, 792.60170439960677, 1151.386286071991, 779.08209481052711, 1158.8789841666487, 762.23526759569415, 1167.957314892026, 743.81648237240574, 1177.657733666761, 725.78466435057828, 1186.9489788693654, 710.04721863137911, 1194.8661499864766, 698.21586121499172, 1200.6267024845697, 691.42197303837008, 1144.6799579195197, 804.85899215438599, 1158.5 [...]
+
+ for (int i = 0; i<pt2d1.size(); i++)
+ pt2d1[i] = pt2d1[i].reshape(1, 108).t();
+ FileStorage fs("myMatchdata.yml",FileStorage::WRITE);
+ fs<<"ptTrack"<<pt2d1;
+ }
+ else
+ {
+ FileStorage fs("myMatchdata.yml", FileStorage::READ);
+ if (fs.isOpened())
+ {
+ if (!fs["ptTrack"].empty())
+ {
+ fs["ptTrack"]>>pt2d1;
+ }
+ else
+ {
+ cout<<"node ptTrack not found!\n";
+ return 0;
+ }
+ }
+ else
+ {
+ cout << "File not found!\n";
+ return 0;
+ }
+
+ }
+ vector<Mat> Rs_est1, ts_est1;
+ Mat Kr(K);
+ reconstruct(pt2d1, Rs_est1, ts_est1, Kr, pt3d1, true);
+
+ // Print output
+
+ cout << "\n----------------------------\n" << endl;
+ cout << "Reconstruction: " << endl;
+ cout << "============================" << endl;
+ cout << "Estimated 3D points: " << pt3d1.size() << endl;
+ cout << "Estimated cameras: " << Rs_est1.size() << endl;
+ cout << "Refined intrinsics: " << endl << K << endl << endl;
+ vector<Mat> pt3d2;
+ vector<Mat> Rs_est2, ts_est2;
+ if (nomFic == "")
+ {
+ vector<Mat> pt2d2(pt2d1.size());
+ for (int i = 0; i<pt2d2.size(); i++)
+ pt2d2[i] = pt2d1[i] / 2 - 50;
+ reconstruct(pt2d2, Rs_est2, ts_est2, Kr, pt3d2, true);
+ }
+
+ cout << "3D Visualization: " << endl;
+ cout << "============================" << endl;
+ /// Create 3D windows
+ viz::Viz3d window("Coordinate Frame");
+ window.setWindowSize(Size(500, 500));
+ window.setWindowPosition(Point(150, 150));
+ window.setBackgroundColor(); // black by default
+// Create the pointcloud
+ cout << "Recovering points ... ";
+// recover estimated points3d
+ vector<Vec3f> point_cloud_est;
+ vector<Vec3b> color;
+ for (int i = 0; i < pt3d1.size(); ++i)
+ {
+ point_cloud_est.push_back(Vec3f(pt3d1[i]));
+ color.push_back(Vec3b(0, 255, 0));
+ }
+ for (int i = 0; i < pt3d2.size(); ++i)
+ {
+ point_cloud_est.push_back(Vec3f(pt3d2[i]));
+ color.push_back(Vec3b(255, 0, 0));
+ }
+ cout << "[DONE]" << endl;
+ /// Recovering cameras
+ cout << "Recovering cameras ... ";
+ vector<Affine3d> path;
+ for (size_t i = 0; i < Rs_est1.size(); ++i)
+ path.push_back(Affine3d(Rs_est1[i], ts_est1[i]));
+ for (size_t i = 0; i < Rs_est2.size(); ++i)
+ path.push_back(Affine3d(Rs_est2[i], ts_est2[i]));
+ cout << "[DONE]" << endl;
+ /// Add the pointcloud
+ if (point_cloud_est.size() > 0)
+ {
+ cout << "Rendering points ... ";
+ viz::WCloud cloud_widget(point_cloud_est, color);
+ window.showWidget("point_cloud", cloud_widget);
+ cout << "[DONE]" << endl;
+ }
+ else
+ {
+ cout << "Cannot render points: Empty pointcloud" << endl;
+ }
+ /// Add cameras
+ if (path.size() > 0)
+ {
+ cout << "Rendering Cameras ... ";
+ window.showWidget("cameras_frames_and_lines", viz::WTrajectory(path, viz::WTrajectory::BOTH, 0.1, viz::Color::green()));
+ window.showWidget("cameras_frustums", viz::WTrajectoryFrustums(path, K, 0.1, viz::Color::yellow()));
+ window.setViewerPose(path[0]);
+ cout << "[DONE]" << endl;
+ }
+ else
+ {
+ cout << "Cannot render the cameras: Empty path" << endl;
+ }
+
+ /// Wait for key 'q' to close the window
+ cout << endl << "Press 'q' to close each windows ... " << endl;
+ window.spin();
+ return 0;
+}
\ No newline at end of file
diff --git a/contrib/modules/sfm/samples/scene_reconstruction.cpp b/contrib/modules/sfm/samples/scene_reconstruction.cpp
index 3f95667..95f86d4 100644
--- a/contrib/modules/sfm/samples/scene_reconstruction.cpp
+++ b/contrib/modules/sfm/samples/scene_reconstruction.cpp
@@ -5,7 +5,6 @@
#include <iostream>
#include <fstream>
-#include <string>
using namespace std;
using namespace cv;
@@ -29,7 +28,7 @@ static void help() {
}
-int getdir(const string _filename, vector<string> &files)
+int getdir(const string _filename, vector<String> &files)
{
ifstream myfile(_filename.c_str());
if (!myfile.is_open()) {
@@ -57,7 +56,7 @@ int main(int argc, char* argv[])
// Parse the image paths
- vector<string> images_paths;
+ vector<String> images_paths;
getdir( argv[1], images_paths );
diff --git a/contrib/modules/sfm/samples/trajectory_reconstruccion.cpp b/contrib/modules/sfm/samples/trajectory_reconstruccion.cpp
index 5c3dc70..487625d 100644
--- a/contrib/modules/sfm/samples/trajectory_reconstruccion.cpp
+++ b/contrib/modules/sfm/samples/trajectory_reconstruccion.cpp
@@ -4,7 +4,6 @@
#include <iostream>
#include <fstream>
-#include <string>
using namespace std;
using namespace cv;
@@ -52,7 +51,7 @@ static void help() {
*/
void
-parser_2D_tracks(const string &_filename, std::vector<Mat> &points2d )
+parser_2D_tracks(const String &_filename, std::vector<Mat> &points2d )
{
ifstream myfile(_filename.c_str());
@@ -213,7 +212,7 @@ int main(int argc, char** argv)
viz::WCube cube_widget(Point3f(0.1,0.1,0.0), Point3f(0.0,0.0,-0.1), true, viz::Color::blue());
cube_widget.setRenderingProperty(viz::LINE_WIDTH, 2.0);
- window_est.showWidget("Cube"+string(buffer), cube_widget, point_pose);
+ window_est.showWidget("Cube"+String(buffer), cube_widget, point_pose);
}
Affine3d cam_pose = path_est[idx];
diff --git a/contrib/modules/sfm/src/libmv_capi.h b/contrib/modules/sfm/src/libmv_capi.h
index e48c6b8..3ad5c23 100644
--- a/contrib/modules/sfm/src/libmv_capi.h
+++ b/contrib/modules/sfm/src/libmv_capi.h
@@ -88,10 +88,13 @@ struct libmv_Reconstruction {
void libmv_initLogging(const char* argv0) {
// Make it so FATAL messages are always print into console.
char severity_fatal[32];
+ static int initLog=0;
snprintf(severity_fatal, sizeof(severity_fatal), "%d",
GLOG_FATAL);
- InitGoogleLogging(argv0);
+ if (!initLog)
+ InitGoogleLogging(argv0);
+ initLog=1;
SetCommandLineOption("logtostderr", "1");
SetCommandLineOption("v", "0");
SetCommandLineOption("stderrthreshold", severity_fatal);
diff --git a/contrib/modules/sfm/src/libmv_light/libmv/logging/logging.h b/contrib/modules/sfm/src/libmv_light/libmv/logging/logging.h
index 776d9d5..fa091c0 100644
--- a/contrib/modules/sfm/src/libmv_light/libmv/logging/logging.h
+++ b/contrib/modules/sfm/src/libmv_light/libmv/logging/logging.h
@@ -23,6 +23,11 @@
#include <glog/logging.h>
+
+#if defined _MSC_VER && _MSC_VER < 1900
+# define snprintf _snprintf
+#endif
+
#define LG LOG(INFO)
#define V0 LOG(INFO)
#define V1 LOG(INFO)
diff --git a/contrib/modules/sfm/src/libmv_light/libmv/simple_pipeline/pipeline.cc b/contrib/modules/sfm/src/libmv_light/libmv/simple_pipeline/pipeline.cc
index 6c8592b..29b0edd 100644
--- a/contrib/modules/sfm/src/libmv_light/libmv/simple_pipeline/pipeline.cc
+++ b/contrib/modules/sfm/src/libmv_light/libmv/simple_pipeline/pipeline.cc
@@ -30,10 +30,6 @@
#include "libmv/simple_pipeline/tracks.h"
#include "libmv/simple_pipeline/camera_intrinsics.h"
-#ifdef _MSC_VER
-# define snprintf _snprintf
-#endif
-
namespace libmv {
namespace {
diff --git a/contrib/modules/sfm/src/reconstruct.cpp b/contrib/modules/sfm/src/reconstruct.cpp
index 1d40f23..254678a 100644
--- a/contrib/modules/sfm/src/reconstruct.cpp
+++ b/contrib/modules/sfm/src/reconstruct.cpp
@@ -152,6 +152,7 @@ namespace sfm
else
{
// TODO: implement me
+ CV_Error(Error::StsNotImplemented, "Affine reconstruction not yet implemented");
}
}
@@ -180,13 +181,14 @@ namespace sfm
else
{
// TODO: implement me
+ CV_Error(Error::StsNotImplemented, "Affine reconstruction not yet implemented");
}
}
void
- reconstruct(const std::vector<std::string> images, OutputArray Ps, OutputArray points3d,
+ reconstruct(const std::vector<cv::String> images, OutputArray Ps, OutputArray points3d,
InputOutputArray K, bool is_projective)
{
const int nviews = static_cast<int>(images.size());
@@ -223,13 +225,14 @@ namespace sfm
else
{
// TODO: implement me
+ CV_Error(Error::StsNotImplemented, "Affine reconstruction not yet implemented");
}
}
void
- reconstruct(const std::vector<std::string> images, OutputArray Rs, OutputArray Ts,
+ reconstruct(const std::vector<cv::String> images, OutputArray Rs, OutputArray Ts,
InputOutputArray K, OutputArray points3d, bool is_projective)
{
const int nviews = static_cast<int>(images.size());
@@ -239,7 +242,7 @@ namespace sfm
if ( is_projective )
{
- reconstruct_(images, Rs, Ts, K, points3d, false);
+ reconstruct_(images, Rs, Ts, K, points3d);
}
@@ -248,6 +251,7 @@ namespace sfm
else
{
// TODO: implement me
+ CV_Error(Error::StsNotImplemented, "Affine reconstruction not yet implemented");
}
}
diff --git a/contrib/modules/sfm/src/simple_pipeline.cpp b/contrib/modules/sfm/src/simple_pipeline.cpp
index 0694057..e7711ae 100644
--- a/contrib/modules/sfm/src/simple_pipeline.cpp
+++ b/contrib/modules/sfm/src/simple_pipeline.cpp
@@ -116,19 +116,21 @@ parser_2D_tracks( const libmv::Matches &matches, libmv::Tracks &tracks )
*/
libmv_Reconstruction *libmv_solveReconstructionImpl(
- const std::vector<std::string> &images,
+ const std::vector<String> &images,
const libmv_CameraIntrinsicsOptions* libmv_camera_intrinsics_options,
libmv_ReconstructionOptions* libmv_reconstruction_options)
{
Ptr<Feature2D> edetector = ORB::create(10000);
Ptr<Feature2D> edescriber = xfeatures2d::DAISY::create();
//Ptr<Feature2D> edescriber = xfeatures2d::LATCH::create(64, true, 4);
-
+ std::vector<std::string> sImages;
+ for (int i=0;i<images.size();i++)
+ sImages.push_back(images[i].c_str());
cout << "Initialize nViewMatcher ... ";
libmv::correspondence::nRobustViewMatching nViewMatcher(edetector, edescriber);
cout << "OK" << endl << "Performing Cross Matching ... ";
- nViewMatcher.computeCrossMatch(images); cout << "OK" << endl;
+ nViewMatcher.computeCrossMatch(sImages); cout << "OK" << endl;
// Building tracks
libmv::Tracks tracks;
@@ -196,7 +198,7 @@ public:
/* Run the pipeline given a set of images
*/
- virtual void run(const std::vector <std::string> &images)
+ virtual void run(const std::vector <String> &images)
{
// Set libmv logs level
libmv_initLogging("");
@@ -217,7 +219,7 @@ public:
}
- virtual void run(const std::vector <string> &images, InputOutputArray K, OutputArray Rs,
+ virtual void run(const std::vector <String> &images, InputOutputArray K, OutputArray Rs,
OutputArray Ts, OutputArray points3d)
{
// Run the pipeline
diff --git a/contrib/modules/sfm/test/test_common.cpp b/contrib/modules/sfm/test/test_common.cpp
index 19e9105..31742f1 100644
--- a/contrib/modules/sfm/test/test_common.cpp
+++ b/contrib/modules/sfm/test/test_common.cpp
@@ -86,11 +86,8 @@ parser_2D_tracks(const string &_filename, std::vector<Mat> &points2d )
ifstream myfile(_filename.c_str());
if (!myfile.is_open())
- {
- cout << "Unable to read file: " << _filename << endl;
- exit(0);
-
- } else {
+ CV_Error(cv::Error::StsError, string("Unable to read file: ") + _filename + "\n");
+ else {
double x, y;
string line_str;
diff --git a/contrib/modules/sfm/tutorials/sfm_installation/sfm_installation.markdown b/contrib/modules/sfm/tutorials/sfm_installation/sfm_installation.markdown
index 7b7d5df..b450f6e 100644
--- a/contrib/modules/sfm/tutorials/sfm_installation/sfm_installation.markdown
+++ b/contrib/modules/sfm/tutorials/sfm_installation/sfm_installation.markdown
@@ -7,11 +7,10 @@ Dependencies
The Structure from Motion module depends on some open source libraries.
- [Eigen](http://eigen.tuxfamily.org) 3.2.2 or later. \b Required
- - [GLog](http://code.google.com/p/google-glog) 0.3.1 or later. \b Required
- - [GFlags](http://code.google.com/p/gflags). \b Required
+ - [GLog](https://github.com/google/glog) 0.3.1 or later. \b Required
+ - [GFlags]( https://github.com/gflags). \b Required
- [Ceres Solver](http://ceres-solver.org). Needed by the reconstruction API in order to solve part of the Bundle Adjustment plus the points Intersect. If Ceres Solver is not installed on your system, the reconstruction funcionality will be disabled. \b Recommended
- at note The module is only available for Linux/GNU systems.
Installation
diff --git a/contrib/modules/stereo/CMakeLists.txt b/contrib/modules/stereo/CMakeLists.txt
index ccc078d..97297e8 100644
--- a/contrib/modules/stereo/CMakeLists.txt
+++ b/contrib/modules/stereo/CMakeLists.txt
@@ -1,2 +1,2 @@
set(the_description "Stereo Correspondence")
-ocv_define_module(stereo opencv_imgproc opencv_features2d opencv_core opencv_highgui opencv_calib3d)
+ocv_define_module(stereo opencv_imgproc opencv_features2d opencv_core opencv_calib3d)
diff --git a/contrib/modules/stereo/src/precomp.hpp b/contrib/modules/stereo/src/precomp.hpp
index cbb1ffd..3e36b4d 100644
--- a/contrib/modules/stereo/src/precomp.hpp
+++ b/contrib/modules/stereo/src/precomp.hpp
@@ -49,7 +49,6 @@
#include "opencv2/core/utility.hpp"
#include "opencv2/core/private.hpp"
#include "opencv2/core/cvdef.h"
-#include "opencv2/highgui.hpp"
#include "opencv2/calib3d.hpp"
#include <algorithm>
diff --git a/contrib/modules/structured_light/CMakeLists.txt b/contrib/modules/structured_light/CMakeLists.txt
index 556a29d..ca06f1a 100644
--- a/contrib/modules/structured_light/CMakeLists.txt
+++ b/contrib/modules/structured_light/CMakeLists.txt
@@ -1,2 +1,2 @@
set(the_description "Structured Light API")
-ocv_define_module(structured_light opencv_core opencv_calib3d opencv_imgproc opencv_highgui opencv_features2d opencv_rgbd opencv_phase_unwrapping OPTIONAL opencv_viz WRAP python java)
+ocv_define_module(structured_light opencv_core opencv_imgproc opencv_calib3d opencv_phase_unwrapping OPTIONAL opencv_viz WRAP python java)
diff --git a/contrib/modules/structured_light/include/opencv2/structured_light/sinusoidalpattern.hpp b/contrib/modules/structured_light/include/opencv2/structured_light/sinusoidalpattern.hpp
index c4549f5..61a45d6 100644
--- a/contrib/modules/structured_light/include/opencv2/structured_light/sinusoidalpattern.hpp
+++ b/contrib/modules/structured_light/include/opencv2/structured_light/sinusoidalpattern.hpp
@@ -148,4 +148,4 @@ public:
//! @}
}
}
-#endif
\ No newline at end of file
+#endif
diff --git a/contrib/modules/structured_light/samples/projectorcalibration.cpp b/contrib/modules/structured_light/samples/projectorcalibration.cpp
index d5bfb55..77b6e20 100644
--- a/contrib/modules/structured_light/samples/projectorcalibration.cpp
+++ b/contrib/modules/structured_light/samples/projectorcalibration.cpp
@@ -477,7 +477,7 @@ void normalize( const Mat &pts, const int& dim, Mat& normpts, Mat &T )
averagedist = averagedist+(float)norm(ptstmp);
}
averagedist = averagedist / normpts.cols;
- scale = (float)(sqrt(dim) / averagedist);
+ scale = (float)(sqrt(static_cast<float>(dim)) / averagedist);
normpts = normpts * scale;
diff --git a/contrib/modules/structured_light/src/graycodepattern.cpp b/contrib/modules/structured_light/src/graycodepattern.cpp
index ff56a02..dceaec9 100644
--- a/contrib/modules/structured_light/src/graycodepattern.cpp
+++ b/contrib/modules/structured_light/src/graycodepattern.cpp
@@ -367,8 +367,8 @@ void GrayCodePattern_Impl::getImagesForShadowMasks( InputOutputArray blackImage,
Mat& blackImage_ = *( Mat* ) blackImage.getObj();
Mat& whiteImage_ = *( Mat* ) whiteImage.getObj();
- blackImage_ = Mat( params.height, params.width, CV_8UC3, Scalar( 0, 0, 0 ) );
- whiteImage_ = Mat( params.height, params.width, CV_8UC3, Scalar( 255, 255, 255 ) );
+ blackImage_ = Mat( params.height, params.width, CV_8U, Scalar( 0 ) );
+ whiteImage_ = Mat( params.height, params.width, CV_8U, Scalar( 255 ) );
}
// For a (x,y) pixel of the camera returns the corresponding projector's pixel
diff --git a/contrib/modules/structured_light/src/sinusoidalpattern.cpp b/contrib/modules/structured_light/src/sinusoidalpattern.cpp
index bc26b20..28ee08f 100644
--- a/contrib/modules/structured_light/src/sinusoidalpattern.cpp
+++ b/contrib/modules/structured_light/src/sinusoidalpattern.cpp
@@ -200,12 +200,12 @@ bool SinusoidalPatternProfilometry_Impl::generate( OutputArrayOfArrays pattern )
if( params.horizontal )
{
period = params.height / params.nbrOfPeriods;
- nbrOfMarkersOnOneRow = (int)floor((params.width - firstMarkerOffset) / m);
+ nbrOfMarkersOnOneRow = (int)floor(static_cast<float>((params.width - firstMarkerOffset) / m));
}
else
{
period = params.width / params.nbrOfPeriods;
- nbrOfMarkersOnOneRow = (int)floor((params.height - firstMarkerOffset) / m);
+ nbrOfMarkersOnOneRow = (int)floor(static_cast<float>((params.height - firstMarkerOffset) / m));
}
frequency = (float) 1 / period;
diff --git a/contrib/modules/structured_light/test/test_plane.cpp b/contrib/modules/structured_light/test/test_plane.cpp
index 36f5b84..6514b57 100644
--- a/contrib/modules/structured_light/test/test_plane.cpp
+++ b/contrib/modules/structured_light/test/test_plane.cpp
@@ -40,9 +40,8 @@
//M*/
#include "test_precomp.hpp"
-#include <opencv2/rgbd.hpp>
#include <opencv2/core.hpp>
-#include <opencv2/highgui.hpp>
+#include <opencv2/imgcodecs.hpp>
#include <opencv2/calib3d.hpp>
#include <opencv2/imgproc.hpp>
diff --git a/contrib/modules/structured_light/test/test_precomp.hpp b/contrib/modules/structured_light/test/test_precomp.hpp
index 4ae6738..7a09e19 100644
--- a/contrib/modules/structured_light/test/test_precomp.hpp
+++ b/contrib/modules/structured_light/test/test_precomp.hpp
@@ -11,7 +11,6 @@
#include "opencv2/ts.hpp"
#include "opencv2/structured_light.hpp"
-#include <opencv2/rgbd.hpp>
#include <iostream>
-#endif
\ No newline at end of file
+#endif
diff --git a/contrib/modules/surface_matching/include/opencv2/surface_matching/icp.hpp b/contrib/modules/surface_matching/include/opencv2/surface_matching/icp.hpp
index d894702..123120a 100644
--- a/contrib/modules/surface_matching/include/opencv2/surface_matching/icp.hpp
+++ b/contrib/modules/surface_matching/include/opencv2/surface_matching/icp.hpp
@@ -77,17 +77,17 @@ namespace ppf_match_3d
* 5. Linearization of Point-to-Plane metric by Kok Lim Low:
* https://www.comp.nus.edu.sg/~lowkl/publications/lowk_point-to-plane_icp_techrep.pdf
*/
-class CV_EXPORTS ICP
+class CV_EXPORTS_W ICP
{
public:
- enum ICP_SAMPLING_TYPE
+ CV_WRAP enum
{
- ICP_SAMPLING_TYPE_UNIFORM,
- ICP_SAMPLING_TYPE_GELFAND
+ ICP_SAMPLING_TYPE_UNIFORM = 0,
+ ICP_SAMPLING_TYPE_GELFAND = 1
};
- ICP()
+ CV_WRAP ICP()
{
m_tolerance = 0.005f;
m_rejectionScale = 2.5f;
@@ -114,7 +114,7 @@ public:
applied. Leave it as 0.
* @param [in] numMaxCorr Currently this parameter is ignored and only PickyICP is applied. Leave it as 1.
*/
- ICP(const int iterations, const float tolerence=0.05, const float rejectionScale=2.5, const int numLevels=6, const ICP_SAMPLING_TYPE sampleType = ICP_SAMPLING_TYPE_UNIFORM, const int numMaxCorr=1)
+ CV_WRAP ICP(const int iterations, const float tolerence = 0.05f, const float rejectionScale = 2.5f, const int numLevels = 6, const int sampleType = ICP::ICP_SAMPLING_TYPE_UNIFORM, const int numMaxCorr = 1)
{
m_tolerance = tolerence;
m_numNeighborsCorr = numMaxCorr;
@@ -136,7 +136,7 @@ public:
*
* \details It is assumed that the model is registered on the scene. Scene remains static, while the model transforms. The output poses transform the models onto the scene. Because of the point to plane minimization, the scene is expected to have the normals available. Expected to have the normals (Nx6).
*/
- int registerModelToScene(const Mat& srcPC, const Mat& dstPC, double& residual, double pose[16]);
+ CV_WRAP int registerModelToScene(const Mat& srcPC, const Mat& dstPC, CV_OUT double& residual, CV_OUT Matx44d& pose);
/**
* \brief Perform registration with multiple initial poses
diff --git a/contrib/modules/surface_matching/include/opencv2/surface_matching/ppf_helpers.hpp b/contrib/modules/surface_matching/include/opencv2/surface_matching/ppf_helpers.hpp
index 6f3cb77..a1a2ba5 100644
--- a/contrib/modules/surface_matching/include/opencv2/surface_matching/ppf_helpers.hpp
+++ b/contrib/modules/surface_matching/include/opencv2/surface_matching/ppf_helpers.hpp
@@ -89,7 +89,7 @@ Mat samplePCUniformInd(Mat PC, int sampleStep, std::vector<int>& indices);
* @param [in] zrange Z components (min and max) of the bounding box of the model
* @param [in] sample_step_relative The point cloud is sampled such that all points
* have a certain minimum distance. This minimum distance is determined relatively using
- * the parameter sample_step_relative.
+ * the parameter sample_step_relative.
* @param [in] weightByCenter The contribution of the quantized data points can be weighted
* by the distance to the origin. This parameter enables/disables the use of weighting.
* @return Sampled point cloud
@@ -125,7 +125,7 @@ Mat transPCCoeff(Mat pc, float scale, float Cx, float Cy, float Cz, float MinVal
* @param [in] Pose 4x4 pose matrix, but linearized in row-major form.
* @return Transformed point cloud
*/
-CV_EXPORTS Mat transformPCPose(Mat pc, double Pose[16]);
+CV_EXPORTS Mat transformPCPose(Mat pc, const double Pose[16]);
/**
* Generate a random 4x4 pose matrix
@@ -135,7 +135,7 @@ CV_EXPORTS void getRandomPose(double Pose[16]);
/**
* Adds a uniform noise in the given scale to the input point cloud
- * @param [in] pc Input point cloud (CV_32F family).
+ * @param [in] pc Input point cloud (CV_32F family).
* @param [in] scale Input scale of the noise. The larger the scale, the more noisy the output
*/
CV_EXPORTS Mat addNoisePC(Mat pc, double scale);
@@ -148,13 +148,13 @@ CV_EXPORTS Mat addNoisePC(Mat pc, double scale);
* If PCNormals is provided to be an Nx6 matrix, then no new allocation
* is made, instead the existing memory is overwritten.
* @param [in] PC Input point cloud to compute the normals for.
- * @param [in] PCNormals Output point cloud
+ * @param [out] PCNormals Output point cloud
* @param [in] NumNeighbors Number of neighbors to take into account in a local region
* @param [in] FlipViewpoint Should normals be flipped to a viewing direction?
* @param [in] viewpoint
* @return Returns 0 on success
*/
-CV_EXPORTS int computeNormalsPC3d(const Mat& PC, Mat& PCNormals, const int NumNeighbors, const bool FlipViewpoint, const double viewpoint[3]);
+CV_EXPORTS_W int computeNormalsPC3d(const Mat& PC, CV_OUT Mat& PCNormals, const int NumNeighbors, const bool FlipViewpoint, const Vec3d& viewpoint);
//! @}
diff --git a/contrib/modules/surface_matching/include/opencv2/surface_matching/ppf_match_3d.hpp b/contrib/modules/surface_matching/include/opencv2/surface_matching/ppf_match_3d.hpp
index ffc8615..c72ef7b 100644
--- a/contrib/modules/surface_matching/include/opencv2/surface_matching/ppf_match_3d.hpp
+++ b/contrib/modules/surface_matching/include/opencv2/surface_matching/ppf_match_3d.hpp
@@ -148,7 +148,7 @@ protected:
double angle_step, angle_step_radians, distance_step;
double sampling_step_relative, angle_step_relative, distance_step_relative;
Mat sampled_pc, ppf;
- int num_ref_points, ppf_step;
+ int num_ref_points;
hashtable_int* hash_table;
THash* hash_nodes;
@@ -166,7 +166,7 @@ private:
bool matchPose(const Pose3D& sourcePose, const Pose3D& targetPose);
- void clusterPoses(std::vector<Pose3DPtr> poseList, int numPoses, std::vector<Pose3DPtr> &finalPoses);
+ void clusterPoses(std::vector<Pose3DPtr>& poseList, int numPoses, std::vector<Pose3DPtr> &finalPoses);
bool trained;
};
diff --git a/contrib/modules/surface_matching/samples/ppf_icp.py b/contrib/modules/surface_matching/samples/ppf_icp.py
new file mode 100644
index 0000000..6a68e52
--- /dev/null
+++ b/contrib/modules/surface_matching/samples/ppf_icp.py
@@ -0,0 +1,52 @@
+import cv2
+import numpy as np
+
+def rotation(theta):
+ tx, ty, tz = theta
+
+ Rx = np.array([[1, 0, 0], [0, np.cos(tx), -np.sin(tx)], [0, np.sin(tx), np.cos(tx)]])
+ Ry = np.array([[np.cos(ty), 0, -np.sin(ty)], [0, 1, 0], [np.sin(ty), 0, np.cos(ty)]])
+ Rz = np.array([[np.cos(tz), -np.sin(tz), 0], [np.sin(tz), np.cos(tz), 0], [0, 0, 1]])
+
+ return np.dot(Rx, np.dot(Ry, Rz))
+
+width = 20
+height = 10
+max_deg = np.pi / 12
+
+cloud, rotated_cloud = [None]*3, [None]*3
+retval, residual, pose = [None]*3, [None]*3, [None]*3
+noise = np.random.normal(0.0, 0.1, height * width * 3).reshape((-1, 3))
+noise2 = np.random.normal(0.0, 1.0, height * width)
+
+x, y = np.meshgrid(
+ range(-width/2, width/2),
+ range(-height/2, height/2),
+ sparse=False, indexing='xy'
+)
+z = np.zeros((height, width))
+
+cloud[0] = np.dstack((x, y, z)).reshape((-1, 3)).astype(np.float32)
+cloud[1] = noise.astype(np.float32) + cloud[0]
+cloud[2] = cloud[1]
+cloud[2][:, 2] += noise2.astype(np.float32)
+
+R = rotation([
+ 0, #np.random.uniform(-max_deg, max_deg),
+ np.random.uniform(-max_deg, max_deg),
+ 0, #np.random.uniform(-max_deg, max_deg)
+])
+t = np.zeros((3, 1))
+Rt = np.vstack((
+ np.hstack((R, t)),
+ np.array([0, 0, 0, 1])
+)).astype(np.float32)
+
+icp = cv2.ppf_match_3d.ICP(100)
+
+I = np.eye(4)
+print("Unaligned error:\t%.6f" % np.linalg.norm(I - Rt))
+for i in range(3):
+ rotated_cloud[i] = np.matmul(Rt[0:3,0:3], cloud[i].T).T + Rt[:3,3].T
+ retval[i], residual[i], pose[i] = icp.registerModelToScene(rotated_cloud[i], cloud[i])
+ print("ICP error:\t\t%.6f" % np.linalg.norm(I - np.matmul(pose[0], Rt)))
diff --git a/contrib/modules/surface_matching/samples/ppf_normal_computation.cpp b/contrib/modules/surface_matching/samples/ppf_normal_computation.cpp
index d629605..7ecaf2f 100644
--- a/contrib/modules/surface_matching/samples/ppf_normal_computation.cpp
+++ b/contrib/modules/surface_matching/samples/ppf_normal_computation.cpp
@@ -65,7 +65,7 @@ int main(int argc, char** argv)
cv::ppf_match_3d::loadPLYSimple(modelFileName.c_str(), 1).copyTo(points);
cout << "Computing normals\n";
- double viewpoint[3] = { 0.0, 0.0, 0.0 };
+ cv::Vec3d viewpoint(0, 0, 0);
cv::ppf_match_3d::computeNormalsPC3d(points, pointsAndNormals, 6, false, viewpoint);
std::cout << "Writing points\n";
diff --git a/contrib/modules/surface_matching/src/c_utils.hpp b/contrib/modules/surface_matching/src/c_utils.hpp
index c3f4e22..6ef2026 100644
--- a/contrib/modules/surface_matching/src/c_utils.hpp
+++ b/contrib/modules/surface_matching/src/c_utils.hpp
@@ -83,11 +83,15 @@ static inline void TCross(const double a[], const double b[], double c[])
c[2] = (a[0])*(b[1])-(a[1])*(b[0]);
}
-static inline double TAngle3(const double a[3], const double b[3])
+static inline double TAngle3Normalized(const double a[3], const double b[3])
{
- double c[3];
- TCross(a,b,c);
- return (atan2(TNorm3(c), TDot3(a, b)));
+ /*
+ angle = atan2(a dot b, |a x b|) # Bertram (accidental mistake)
+ angle = atan2(|a x b|, a dot b) # Tolga Birdal (correction)
+ angle = acos(a dot b) # Hamdi Sahloul (simplification, a & b are normalized)
+ */
+
+ return acos(TDot3(a, b));
}
static inline void matrixProduct33(double *A, double *B, double *R)
diff --git a/contrib/modules/surface_matching/src/icp.cpp b/contrib/modules/surface_matching/src/icp.cpp
index 615f93d..805cc00 100644
--- a/contrib/modules/surface_matching/src/icp.cpp
+++ b/contrib/modules/surface_matching/src/icp.cpp
@@ -50,7 +50,7 @@ static void subtractColumns(Mat srcPC, double mean[3])
for (int i=0; i<height; i++)
{
- float *row = (float*)(&srcPC.data[i*srcPC.step]);
+ float *row = srcPC.ptr<float>(i);
{
row[0]-=(float)mean[0];
row[1]-=(float)mean[1];
@@ -68,7 +68,7 @@ static void computeMeanCols(Mat srcPC, double mean[3])
for (int i=0; i<height; i++)
{
- const float *row = (float*)(&srcPC.data[i*srcPC.step]);
+ const float *row = srcPC.ptr<float>(i);
{
mean1 += (double)row[0];
mean2 += (double)row[1];
@@ -100,7 +100,7 @@ static double computeDistToOrigin(Mat srcPC)
for (int i=0; i<height; i++)
{
- const float *row = (float*)(&srcPC.data[i*srcPC.step]);
+ const float *row = srcPC.ptr<float>(i);
dist += sqrt(row[0]*row[0]+row[1]*row[1]+row[2]*row[2]);
}
@@ -203,11 +203,11 @@ static void minimizePointToPlaneMetric(Mat Src, Mat Dst, Mat& X)
#endif
for (int i=0; i<Src.rows; i++)
{
- const double *srcPt = (double*)&Src.data[i*Src.step];
- const double *dstPt = (double*)&Dst.data[i*Dst.step];
+ const double *srcPt = Src.ptr<double>(i);
+ const double *dstPt = Dst.ptr<double>(i);
const double *normals = &dstPt[3];
- double *bVal = (double*)&b.data[i*b.step];
- double *aRow = (double*)&A.data[i*A.step];
+ double *bVal = b.ptr<double>(i);
+ double *aRow = A.ptr<double>(i);
const double sub[3]={dstPt[0]-srcPt[0], dstPt[1]-srcPt[1], dstPt[2]-srcPt[2]};
@@ -293,7 +293,7 @@ static hashtable_int* getHashtable(int* data, size_t length, int numMaxElement)
}
// source point clouds are assumed to contain their normals
-int ICP::registerModelToScene(const Mat& srcPC, const Mat& dstPC, double& residual, double pose[16])
+int ICP::registerModelToScene(const Mat& srcPC, const Mat& dstPC, double& residual, Matx44d& pose)
{
int n = srcPC.rows;
@@ -320,9 +320,8 @@ int ICP::registerModelToScene(const Mat& srcPC, const Mat& dstPC, double& residu
Mat dstPC0 = dstTemp;
// initialize pose
- matrixIdentity(4, pose);
+ matrixIdentity(4, pose.val);
- void* flann = indexPCFlann(dstPC0);
Mat M = Mat::eye(4,4,CV_64F);
double tempResidual = 0;
@@ -339,21 +338,17 @@ int ICP::registerModelToScene(const Mat& srcPC, const Mat& dstPC, double& residu
const int MaxIterationsPyr = cvRound((double)m_maxIterations/(level+1));
// Obtain the sampled point clouds for this level: Also rotates the normals
- Mat srcPCT = transformPCPose(srcPC0, pose);
+ Mat srcPCT = transformPCPose(srcPC0, pose.val);
const int sampleStep = cvRound((double)n/(double)numSamples);
- std::vector<int> srcSampleInd;
+ srcPCT = samplePCUniform(srcPCT, sampleStep);
/*
- Note by Tolga Birdal
- Downsample the model point clouds. If more optimization is required,
- one could also downsample the scene points, but I think this might
- decrease the accuracy. That's why I won't be implementing it at this
- moment.
-
- Also note that you have to compute a KD-tree for each level.
+ Tolga Birdal thinks that downsampling the scene points might decrease the accuracy.
+ Hamdi Sahloul, however, noticed that accuracy increased (pose residual decreased slightly).
*/
- srcPCT = samplePCUniformInd(srcPCT, sampleStep, srcSampleInd);
+ Mat dstPCS = samplePCUniform(dstPC0, sampleStep);
+ void* flann = indexPCFlann(dstPCS);
double fval_old=9999999999;
double fval_perc=0;
@@ -382,13 +377,13 @@ int ICP::registerModelToScene(const Mat& srcPC, const Mat& dstPC, double& residu
while ( (!(fval_perc<(1+TolP) && fval_perc>(1-TolP))) && i<MaxIterationsPyr)
{
- size_t di=0, selInd = 0;
+ uint di=0, selInd = 0;
queryPCFlann(flann, Src_Moved, Indices, Distances);
for (di=0; di<numElSrc; di++)
{
- newI[di] = (int)di;
+ newI[di] = di;
newJ[di] = indices[di];
}
@@ -416,7 +411,7 @@ int ICP::registerModelToScene(const Mat& srcPC, const Mat& dstPC, double& residu
// is assigned to the same model point m_j, then select p_i that corresponds
// to the minimum distance
- hashtable_int* duplicateTable = getHashtable(newJ, numElSrc, dstPC0.rows);
+ hashtable_int* duplicateTable = getHashtable(newJ, numElSrc, dstPCS.rows);
for (di=0; di<duplicateTable->size; di++)
{
@@ -452,20 +447,20 @@ int ICP::registerModelToScene(const Mat& srcPC, const Mat& dstPC, double& residu
hashtableDestroy(duplicateTable);
- if (selInd)
+ if (selInd >= 6)
{
- Mat Src_Match = Mat((int)selInd, srcPCT.cols, CV_64F);
- Mat Dst_Match = Mat((int)selInd, srcPCT.cols, CV_64F);
+ Mat Src_Match = Mat(selInd, srcPCT.cols, CV_64F);
+ Mat Dst_Match = Mat(selInd, srcPCT.cols, CV_64F);
for (di=0; di<selInd; di++)
{
const int indModel = indicesModel[di];
const int indScene = indicesScene[di];
- const float *srcPt = (float*)&srcPCT.data[indModel*srcPCT.step];
- const float *dstPt = (float*)&dstPC0.data[indScene*dstPC0.step];
- double *srcMatchPt = (double*)&Src_Match.data[di*Src_Match.step];
- double *dstMatchPt = (double*)&Dst_Match.data[di*Dst_Match.step];
+ const float *srcPt = srcPCT.ptr<float>(indModel);
+ const float *dstPt = dstPCS.ptr<float>(indScene);
+ double *srcMatchPt = Src_Match.ptr<double>(di);
+ double *dstMatchPt = Dst_Match.ptr<double>(di);
int ci=0;
for (ci=0; ci<srcPCT.cols; ci++)
@@ -500,11 +495,11 @@ int ICP::registerModelToScene(const Mat& srcPC, const Mat& dstPC, double& residu
}
double TempPose[16];
- matrixProduct44(PoseX, pose, TempPose);
+ matrixProduct44(PoseX, pose.val, TempPose);
// no need to copy the last 4 rows
for (int c=0; c<12; c++)
- pose[c] = TempPose[c];
+ pose.val[c] = TempPose[c];
residual = tempResidual;
@@ -516,36 +511,39 @@ int ICP::registerModelToScene(const Mat& srcPC, const Mat& dstPC, double& residu
delete[] indices;
tempResidual = fval_min;
+ destroyFlann(flann);
}
// Pose(1:3, 4) = Pose(1:3, 4)./scale;
- pose[3] = pose[3]/scale + meanAvg[0];
- pose[7] = pose[7]/scale + meanAvg[1];
- pose[11] = pose[11]/scale + meanAvg[2];
+ pose.val[3] = pose.val[3]/scale + meanAvg[0];
+ pose.val[7] = pose.val[7]/scale + meanAvg[1];
+ pose.val[11] = pose.val[11]/scale + meanAvg[2];
// In MATLAB this would be : Pose(1:3, 4) = Pose(1:3, 4)./scale + meanAvg' - Pose(1:3, 1:3)*meanAvg';
double Rpose[9], Cpose[3];
- poseToR(pose, Rpose);
+ poseToR(pose.val, Rpose);
matrixProduct331(Rpose, meanAvg, Cpose);
- pose[3] -= Cpose[0];
- pose[7] -= Cpose[1];
- pose[11] -= Cpose[2];
+ pose.val[3] -= Cpose[0];
+ pose.val[7] -= Cpose[1];
+ pose.val[11] -= Cpose[2];
residual = tempResidual;
- destroyFlann(flann);
return 0;
}
// source point clouds are assumed to contain their normals
int ICP::registerModelToScene(const Mat& srcPC, const Mat& dstPC, std::vector<Pose3DPtr>& poses)
{
- for (size_t i=0; i<poses.size(); i++)
+ #if defined _OPENMP
+ #pragma omp parallel for
+ #endif
+ for (int i=0; i<(int)poses.size(); i++)
{
- double poseICP[16]={0};
+ Matx44d poseICP = Matx44d::eye();
Mat srcTemp = transformPCPose(srcPC, poses[i]->pose);
registerModelToScene(srcTemp, dstPC, poses[i]->residual, poseICP);
- poses[i]->appendPose(poseICP);
+ poses[i]->appendPose(poseICP.val);
}
return 0;
}
diff --git a/contrib/modules/surface_matching/src/ppf_helpers.cpp b/contrib/modules/surface_matching/src/ppf_helpers.cpp
index 2a538f4..ceba476 100644
--- a/contrib/modules/surface_matching/src/ppf_helpers.cpp
+++ b/contrib/modules/surface_matching/src/ppf_helpers.cpp
@@ -86,7 +86,7 @@ Mat loadPLYSimple(const char* fileName, int withNormals)
for (int i = 0; i < numVertices; i++)
{
- float* data = (float*)(&cloud.data[i*cloud.step[0]]);
+ float* data = cloud.ptr<float>(i);
if (withNormals)
{
ifs >> data[0] >> data[1] >> data[2] >> data[3] >> data[4] >> data[5];
@@ -114,12 +114,8 @@ void writePLY(Mat PC, const char* FileName)
{
std::ofstream outFile( FileName );
- if ( !outFile )
- {
- //cerr << "Error opening output file: " << FileName << "!" << endl;
- printf("Error opening output file: %s!\n", FileName);
- exit( 1 );
- }
+ if ( !outFile.is_open() )
+ CV_Error(Error::StsError, String("Error opening output file: ") + String(FileName) + "\n");
////
// Header
@@ -148,7 +144,7 @@ void writePLY(Mat PC, const char* FileName)
for ( int pi = 0; pi < pointNum; ++pi )
{
- const float* point = (float*)(&PC.data[ pi*PC.step ]);
+ const float* point = PC.ptr<float>(pi);
outFile << point[0] << " "<<point[1]<<" "<<point[2];
@@ -167,12 +163,8 @@ void writePLYVisibleNormals(Mat PC, const char* FileName)
{
std::ofstream outFile(FileName);
- if (!outFile)
- {
- //cerr << "Error opening output file: " << FileName << "!" << endl;
- printf("Error opening output file: %s!\n", FileName);
- exit(1);
- }
+ if (!outFile.is_open())
+ CV_Error(Error::StsError, String("Error opening output file: ") + String(FileName) + "\n");
////
// Header
@@ -202,7 +194,7 @@ void writePLYVisibleNormals(Mat PC, const char* FileName)
for (int pi = 0; pi < pointNum; ++pi)
{
- const float* point = (float*)(&PC.data[pi*PC.step]);
+ const float* point = PC.ptr<float>(pi);
outFile << point[0] << " " << point[1] << " " << point[2];
@@ -295,7 +287,7 @@ Mat samplePCByQuantization(Mat pc, float xrange[2], float yrange[2], float zrang
//#pragma omp parallel for
for (int i=0; i<pc.rows; i++)
{
- const float* point = (float*)(&pc.data[i * pc.step]);
+ const float* point = pc.ptr<float>(i);
// quantize a point
const int xCell =(int) ((float)numSamplesDim*(point[0]-xrange[0])/xr);
@@ -342,7 +334,7 @@ Mat samplePCByQuantization(Mat pc, float xrange[2], float yrange[2], float zrang
for (int j=0; j<cn; j++)
{
const int ptInd = curCell[j];
- float* point = (float*)(&pc.data[ptInd * pc.step]);
+ float* point = pc.ptr<float>(ptInd);
const double dx = point[0]-xc;
const double dy = point[1]-yc;
const double dz = point[2]-zc;
@@ -380,7 +372,7 @@ Mat samplePCByQuantization(Mat pc, float xrange[2], float yrange[2], float zrang
for (int j=0; j<cn; j++)
{
const int ptInd = curCell[j];
- float* point = (float*)(&pc.data[ptInd * pc.step]);
+ float* point = pc.ptr<float>(ptInd);
px += (double)point[0];
py += (double)point[1];
@@ -399,7 +391,7 @@ Mat samplePCByQuantization(Mat pc, float xrange[2], float yrange[2], float zrang
}
- float *pcData = (float*)(&pcSampled.data[c*pcSampled.step[0]]);
+ float *pcData = pcSampled.ptr<float>(c);
pcData[0]=(float)px;
pcData[1]=(float)py;
pcData[2]=(float)pz;
@@ -530,7 +522,7 @@ Mat transPCCoeff(Mat pc, float scale, float Cx, float Cy, float Cz, float MinVal
return pcn;
}
-Mat transformPCPose(Mat pc, double Pose[16])
+Mat transformPCPose(Mat pc, const double Pose[16])
{
Mat pct = Mat(pc.rows, pc.cols, CV_32F);
@@ -542,8 +534,8 @@ Mat transformPCPose(Mat pc, double Pose[16])
#endif
for (int i=0; i<pc.rows; i++)
{
- const float *pcData = (float*)(&pc.data[i*pc.step]);
- float *pcDataT = (float*)(&pct.data[i*pct.step]);
+ const float *pcData = pc.ptr<float>(i);
+ float *pcDataT = pct.ptr<float>(i);
const float *n1 = &pcData[3];
float *nT = &pcDataT[3];
@@ -720,7 +712,7 @@ void meanCovLocalPCInd(const float* pc, const int* Indices, const int ws, const
}
-CV_EXPORTS int computeNormalsPC3d(const Mat& PC, Mat& PCNormals, const int NumNeighbors, const bool FlipViewpoint, const double viewpoint[3])
+CV_EXPORTS int computeNormalsPC3d(const Mat& PC, Mat& PCNormals, const int NumNeighbors, const bool FlipViewpoint, const Vec3d& viewpoint)
{
int i;
@@ -738,7 +730,7 @@ CV_EXPORTS int computeNormalsPC3d(const Mat& PC, Mat& PCNormals, const int NumNe
for (i=0; i<PC.rows; i++)
{
- const float* src = (float*)(&PC.data[i*PC.step]);
+ const float* src = PC.ptr<float>(i);
float* dst = (float*)(&dataset[i*3]);
dst[0] = src[0];
@@ -763,7 +755,7 @@ CV_EXPORTS int computeNormalsPC3d(const Mat& PC, Mat& PCNormals, const int NumNe
{
double C[3][3], mu[4];
const float* pci = &dataset[i*3];
- float* pcr = (float*)(&PCNormals.data[i*PCNormals.step]);
+ float* pcr = PCNormals.ptr<float>(i);
double nr[3];
int* indLocal = &indices[i*NumNeighbors];
diff --git a/contrib/modules/surface_matching/src/ppf_match_3d.cpp b/contrib/modules/surface_matching/src/ppf_match_3d.cpp
index 18f7efe..258ce6a 100644
--- a/contrib/modules/surface_matching/src/ppf_match_3d.cpp
+++ b/contrib/modules/surface_matching/src/ppf_match_3d.cpp
@@ -41,7 +41,7 @@
#include "precomp.hpp"
#include "hash_murmur.hpp"
-namespace cv
+namespace cv
{
namespace ppf_match_3d
{
@@ -129,6 +129,9 @@ PPF3DDetector::PPF3DDetector()
angle_step = angle_step_radians;
trained = false;
+ hash_table = NULL;
+ hash_nodes = NULL;
+
setSearchParams();
}
@@ -142,6 +145,9 @@ PPF3DDetector::PPF3DDetector(const double RelativeSamplingStep, const double Rel
angle_step = angle_step_radians;
trained = false;
+ hash_table = NULL;
+ hash_nodes = NULL;
+
setSearchParams();
}
@@ -191,20 +197,9 @@ void PPF3DDetector::computePPFFeatures(const double p1[4], const double n1[4],
return ;
}
- /*
- Tolga Birdal's note:
- Issues of numerical stability is of concern here.
- Bertram's suggestion: atan2(a dot b, |axb|)
- My correction :
- I guess it should be: angle = atan2(norm(cross(a,b)), dot(a,b))
- The macro is implemented accordingly.
- TAngle3 actually outputs in range [0, pi] as
- Bertram suggests
- */
-
- f[0] = TAngle3(n1, d);
- f[1] = TAngle3(n2, d);
- f[2] = TAngle3(n1, n2);
+ f[0] = TAngle3Normalized(n1, d);
+ f[1] = TAngle3Normalized(n2, d);
+ f[2] = TAngle3Normalized(n1, n2);
}
void PPF3DDetector::clearTrainingModels()
@@ -252,8 +247,6 @@ void PPF3DDetector::trainModel(const Mat &PC)
int numPPF = sampled.rows*sampled.rows;
ppf = Mat(numPPF, PPF_LENGTH, CV_32FC1);
- int ppfStep = (int)ppf.step;
- int sampledStep = (int)sampled.step;
// TODO: Maybe I could sample 1/5th of them here. Check the performance later.
int numRefPoints = sampled.rows;
@@ -268,7 +261,7 @@ void PPF3DDetector::trainModel(const Mat &PC)
// since this is just a training part.
for (int i=0; i<numRefPoints; i++)
{
- float* f1 = (float*)(&sampled.data[i * sampledStep]);
+ float* f1 = sampled.ptr<float>(i);
const double p1[4] = {f1[0], f1[1], f1[2], 0};
const double n1[4] = {f1[3], f1[4], f1[5], 0};
@@ -278,7 +271,7 @@ void PPF3DDetector::trainModel(const Mat &PC)
// cannnot compute the ppf with myself
if (i!=j)
{
- float* f2 = (float*)(&sampled.data[j * sampledStep]);
+ float* f2 = sampled.ptr<float>(j);
const double p2[4] = {f2[0], f2[1], f2[2], 0};
const double n2[4] = {f2[3], f2[4], f2[5], 0};
@@ -286,8 +279,7 @@ void PPF3DDetector::trainModel(const Mat &PC)
computePPFFeatures(p1, n1, p2, n2, f);
KeyType hashValue = hashPPF(f, angle_step_radians, distanceStep);
double alpha = computeAlpha(p1, n1, p2);
- unsigned int corrInd = i*numRefPoints+j;
- unsigned int ppfInd = corrInd*ppfStep;
+ unsigned int ppfInd = i*numRefPoints+j;
THash* hashNode = &hash_nodes[i*numRefPoints+j];
hashNode->id = hashValue;
@@ -296,7 +288,7 @@ void PPF3DDetector::trainModel(const Mat &PC)
hashtableInsertHashed(hashTable, hashValue, (void*)hashNode);
- float* ppfRow = (float*)(&(ppf.data[ ppfInd ]));
+ float* ppfRow = ppf.ptr<float>(ppfInd);
ppfRow[0] = (float)f[0];
ppfRow[1] = (float)f[1];
ppfRow[2] = (float)f[2];
@@ -309,7 +301,6 @@ void PPF3DDetector::trainModel(const Mat &PC)
angle_step = angle_step_radians;
distance_step = distanceStep;
hash_table = hashTable;
- ppf_step = ppfStep;
num_ref_points = numRefPoints;
sampled_pc = sampled;
trained = true;
@@ -331,7 +322,7 @@ bool PPF3DDetector::matchPose(const Pose3D& sourcePose, const Pose3D& targetPose
return (phi<this->rotation_threshold && dNorm < this->position_threshold);
}
-void PPF3DDetector::clusterPoses(std::vector<Pose3DPtr> poseList, int numPoses, std::vector<Pose3DPtr> &finalPoses)
+void PPF3DDetector::clusterPoses(std::vector<Pose3DPtr>& poseList, int numPoses, std::vector<Pose3DPtr> &finalPoses)
{
std::vector<PoseCluster3DPtr> poseClusters;
@@ -513,7 +504,7 @@ void PPF3DDetector::match(const Mat& pc, std::vector<Pose3DPtr>& results, const
unsigned int refIndMax = 0, alphaIndMax = 0;
unsigned int maxVotes = 0;
- float* f1 = (float*)(&sampled.data[i * sampled.step]);
+ float* f1 = sampled.ptr<float>(i);
const double p1[4] = {f1[0], f1[1], f1[2], 0};
const double n1[4] = {f1[3], f1[4], f1[5], 0};
double *row2, *row3, tsg[3]={0}, Rsg[9]={0}, RInv[9]={0};
@@ -532,7 +523,7 @@ void PPF3DDetector::match(const Mat& pc, std::vector<Pose3DPtr>& results, const
{
if (i!=j)
{
- float* f2 = (float*)(&sampled.data[j * sampled.step]);
+ float* f2 = sampled.ptr<float>(j);
const double p2[4] = {f2[0], f2[1], f2[2], 0};
const double n2[4] = {f2[3], f2[4], f2[5], 0};
double p2t[4], alpha_scene;
@@ -565,7 +556,7 @@ void PPF3DDetector::match(const Mat& pc, std::vector<Pose3DPtr>& results, const
THash* tData = (THash*) node->data;
int corrI = (int)tData->i;
int ppfInd = (int)tData->ppfInd;
- float* ppfCorrScene = (float*)(&ppf.data[ppfInd]);
+ float* ppfCorrScene = ppf.ptr<float>(ppfInd);
double alpha_model = (double)ppfCorrScene[PPF_LENGTH-1];
double alpha = alpha_model - alpha_scene;
@@ -620,7 +611,7 @@ void PPF3DDetector::match(const Mat& pc, std::vector<Pose3DPtr>& results, const
};
// TODO : Compute pose
- const float* fMax = (float*)(&sampled_pc.data[refIndMax * sampled_pc.step]);
+ const float* fMax = sampled_pc.ptr<float>(refIndMax);
const double pMax[4] = {fMax[0], fMax[1], fMax[2], 1};
const double nMax[4] = {fMax[3], fMax[4], fMax[5], 1};
@@ -649,7 +640,12 @@ void PPF3DDetector::match(const Mat& pc, std::vector<Pose3DPtr>& results, const
Pose3DPtr pose(new Pose3D(alpha, refIndMax, maxVotes));
pose->updatePose(rawPose);
- poseList.push_back(pose);
+ #if defined (_OPENMP)
+ #pragma omp critical
+ #endif
+ {
+ poseList.push_back(pose);
+ }
#if defined (_OPENMP)
free(accumulator);
diff --git a/contrib/modules/text/CMakeLists.txt b/contrib/modules/text/CMakeLists.txt
index 7ec4d24..98a332b 100644
--- a/contrib/modules/text/CMakeLists.txt
+++ b/contrib/modules/text/CMakeLists.txt
@@ -1,5 +1,5 @@
set(the_description "Text Detection and Recognition")
-ocv_define_module(text opencv_ml opencv_imgproc opencv_core opencv_features2d OPTIONAL opencv_highgui WRAP python)
+ocv_define_module(text opencv_ml opencv_imgproc opencv_core opencv_features2d OPTIONAL opencv_highgui WRAP python java)
if(NOT CMAKE_CROSSCOMPILING OR OPENCV_FIND_TESSERACT)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
diff --git a/contrib/modules/text/README.md b/contrib/modules/text/README.md
index bbbad11..488518a 100644
--- a/contrib/modules/text/README.md
+++ b/contrib/modules/text/README.md
@@ -12,7 +12,7 @@ Here are instructions on how to install Tesseract on your machine (Linux or Mac;
Tesseract installation instruction (Linux, Mac)
-----------------------------------------------
-0. Linux users may try to install tesseract-3.03-rc1 (or later) and leptonica-1.70 (or later) with the corresponding developement packages using their package manager. Mac users may try brew. The instructions below are for those who wants to build tesseract from source.
+0. Linux users may try to install tesseract-3.03-rc1 (or later) and leptonica-1.70 (or later) with the corresponding development packages using their package manager. Mac users may try brew. The instructions below are for those who wants to build tesseract from source.
1. download leptonica 1.70 tarball (helper image processing library, used by tesseract. Later versions might work too):
http://www.leptonica.com/download.html
@@ -33,9 +33,9 @@ mkdir build && cd build
../configure --with-extra-includes=/usr/local --with-extra-libraries=/usr/local
make && sudo make install
-tessract will be installed to /usr/local.
+Tesseract will be installed to /usr/local.
-3. download the pre-trained classifier data for english language:
+3. download the pre-trained classifier data for English language:
https://code.google.com/p/tesseract-ocr/downloads/detail?name=eng.traineddata.gz
unzip it (gzip -d eng.traineddata.gz) and copy to /usr/local/share/tessdata.
diff --git a/contrib/modules/text/doc/text.bib b/contrib/modules/text/doc/text.bib
new file mode 100644
index 0000000..64a8f4a
--- /dev/null
+++ b/contrib/modules/text/doc/text.bib
@@ -0,0 +1,34 @@
+ at inproceedings{Neumann12,
+ title={Scene Text Localization and Recognition},
+ author={Neumann and L., Matas and J.},
+ journal={ Computer Vision and Pattern Recognition (CVPR), 2012 IEEE Conference on},
+ pages={3538--3545},
+ year={2012},
+ organization={IEEE}
+}
+ at inproceedings{Neumann11,
+ author = {Lukáš Neumann and Jiří Matas},
+ title = {Text localization in real-world images using efficiently pruned exhaustive search},
+ booktitle = {in Document Analysis and Recognition, 2011 International Conference on. IEEE, 2011},
+ year = {},
+ pages = {687--691}
+}
+ at inproceedings{Gomez13,
+ author = {G\'{o}mez, Llu\'{\i}s and Karatzas, Dimosthenis},
+ title={Multi-script Text Extraction from Natural Scenes},
+ booktitle = {Proceedings of the 2013 12th International Conference on Document Analysis and Recognition},
+ series = {ICDAR '13},
+ year = {2013},
+ isbn = {978-0-7695-4999-6},
+ pages = {467--471},
+ publisher = {IEEE Computer Society}
+ }
+ at article{Gomez14,
+ author = {Lluis Gomez i Bigorda and
+ Dimosthenis Karatzas},
+ title = {A Fast Hierarchical Method for Multi-script and Arbitrary Oriented
+ Scene Text Extraction},
+ journal = {CoRR},
+ volume = {abs/1407.7504},
+ year = {2014},
+}
\ No newline at end of file
diff --git a/contrib/modules/text/include/opencv2/text.hpp b/contrib/modules/text/include/opencv2/text.hpp
index 945194a..cea49c6 100644
--- a/contrib/modules/text/include/opencv2/text.hpp
+++ b/contrib/modules/text/include/opencv2/text.hpp
@@ -54,7 +54,7 @@ Class-specific Extremal Regions for Scene Text Detection
--------------------------------------------------------
The scene text detection algorithm described below has been initially proposed by Lukás Neumann &
-Jiri Matas [Neumann12]. The main idea behind Class-specific Extremal Regions is similar to the MSER
+Jiri Matas @cite Neumann11. The main idea behind Class-specific Extremal Regions is similar to the MSER
in that suitable Extremal Regions (ERs) are selected from the whole component tree of the image.
However, this technique differs from MSER in that selection of suitable ERs is done by a sequential
classifier trained for character detection, i.e. dropping the stability requirement of MSERs and
@@ -66,12 +66,12 @@ hierarchy by their inclusion relation:

-The component tree may conatain a huge number of regions even for a very simple image as shown in
+The component tree may contain a huge number of regions even for a very simple image as shown in
the previous image. This number can easily reach the order of 1 x 10\^6 regions for an average 1
Megapixel image. In order to efficiently select suitable regions among all the ERs the algorithm
make use of a sequential classifier with two differentiated stages.
-In the first stage incrementally computable descriptors (area, perimeter, bounding box, and euler
+In the first stage incrementally computable descriptors (area, perimeter, bounding box, and Euler's
number) are computed (in O(1)) for each region r and used as features for a classifier which
estimates the class-conditional probability p(r|character). Only the ERs which correspond to local
maximum of the probability p(r|character) are selected (if their probability is above a global limit
@@ -87,9 +87,9 @@ order to increase the character localization recall.
After the ER filtering is done on each input channel, character candidates must be grouped in
high-level text blocks (i.e. words, text lines, paragraphs, ...). The opencv_text module implements
-two different grouping algorithms: the Exhaustive Search algorithm proposed in [Neumann11] for
+two different grouping algorithms: the Exhaustive Search algorithm proposed in @cite Neumann12 for
grouping horizontally aligned text, and the method proposed by Lluis Gomez and Dimosthenis Karatzas
-in [Gomez13][Gomez14] for grouping arbitrary oriented text (see erGrouping).
+in @cite Gomez13 @cite Gomez14 for grouping arbitrary oriented text (see erGrouping).
To see the text detector at work, have a look at the textdetection demo:
<https://github.com/opencv/opencv_contrib/blob/master/modules/text/samples/textdetection.cpp>
diff --git a/contrib/modules/text/include/opencv2/text/erfilter.hpp b/contrib/modules/text/include/opencv2/text/erfilter.hpp
index af983c6..c9bac2b 100644
--- a/contrib/modules/text/include/opencv2/text/erfilter.hpp
+++ b/contrib/modules/text/include/opencv2/text/erfilter.hpp
@@ -78,7 +78,7 @@ public:
//! incrementally computable features
int area;
int perimeter;
- int euler; //!< euler number
+ int euler; //!< Euler's number
Rect rect;
double raw_moments[2]; //!< order 1 raw moments to derive the centroid
double central_moments[3]; //!< order 2 central moments to construct the covariance matrix
@@ -105,13 +105,13 @@ public:
ERStat* next;
ERStat* prev;
- //! wenever the regions is a local maxima of the probability
+ //! whenever the regions is a local maxima of the probability
bool local_maxima;
ERStat* max_probability_ancestor;
ERStat* min_probability_ancestor;
};
-/** @brief Base class for 1st and 2nd stages of Neumann and Matas scene text detection algorithm [Neumann12]. :
+/** @brief Base class for 1st and 2nd stages of Neumann and Matas scene text detection algorithm @cite Neumann12. :
Extracts the component tree (if needed) and filter the extremal regions (ER's) by using a given classifier.
*/
@@ -163,40 +163,17 @@ public:
};
-/*!
- Create an Extremal Region Filter for the 1st stage classifier of N&M algorithm
- Neumann L., Matas J.: Real-Time Scene Text Localization and Recognition, CVPR 2012
-
- The component tree of the image is extracted by a threshold increased step by step
- from 0 to 255, incrementally computable descriptors (aspect_ratio, compactness,
- number of holes, and number of horizontal crossings) are computed for each ER
- and used as features for a classifier which estimates the class-conditional
- probability P(er|character). The value of P(er|character) is tracked using the inclusion
- relation of ER across all thresholds and only the ERs which correspond to local maximum
- of the probability P(er|character) are selected (if the local maximum of the
- probability is above a global limit pmin and the difference between local maximum and
- local minimum is greater than minProbabilityDiff).
-
- @param cb – Callback with the classifier. Default classifier can be implicitly load with function
- loadClassifierNM1(), e.g. from file in samples/cpp/trained_classifierNM1.xml
- @param thresholdDelta – Threshold step in subsequent thresholds when extracting the component tree
- @param minArea – The minimum area (% of image size) allowed for retreived ER’s
- @param maxArea – The maximum area (% of image size) allowed for retreived ER’s
- @param minProbability – The minimum probability P(er|character) allowed for retreived ER’s
- @param nonMaxSuppression – Whenever non-maximum suppression is done over the branch probabilities
- @param minProbabilityDiff – The minimum probability difference between local maxima and local minima ERs
-*/
-
-/** @brief Create an Extremal Region Filter for the 1st stage classifier of N&M algorithm [Neumann12].
+
+/** @brief Create an Extremal Region Filter for the 1st stage classifier of N&M algorithm @cite Neumann12.
@param cb : Callback with the classifier. Default classifier can be implicitly load with function
loadClassifierNM1, e.g. from file in samples/cpp/trained_classifierNM1.xml
@param thresholdDelta : Threshold step in subsequent thresholds when extracting the component tree
@param minArea : The minimum area (% of image size) allowed for retreived ER's
- at param minArea : The maximum area (% of image size) allowed for retreived ER's
+ at param maxArea : The maximum area (% of image size) allowed for retreived ER's
@param minProbability : The minimum probability P(er|character) allowed for retreived ER's
@param nonMaxSuppression : Whenever non-maximum suppression is done over the branch probabilities
- at param minProbability : The minimum probability difference between local maxima and local minima ERs
+ at param minProbabilityDiff : The minimum probability difference between local maxima and local minima ERs
The component tree of the image is extracted by a threshold increased step by step from 0 to 255,
incrementally computable descriptors (aspect_ratio, compactness, number of holes, and number of
@@ -213,7 +190,7 @@ CV_EXPORTS_W Ptr<ERFilter> createERFilterNM1(const Ptr<ERFilter::Callback>& cb,
bool nonMaxSuppression = true,
float minProbabilityDiff = (float)0.1);
-/** @brief Create an Extremal Region Filter for the 2nd stage classifier of N&M algorithm [Neumann12].
+/** @brief Create an Extremal Region Filter for the 2nd stage classifier of N&M algorithm @cite Neumann12.
@param cb : Callback with the classifier. Default classifier can be implicitly load with function
loadClassifierNM2, e.g. from file in samples/cpp/trained_classifierNM2.xml
@@ -227,6 +204,24 @@ features: hole area ratio, convex hull ratio, and number of outer inflexion poin
CV_EXPORTS_W Ptr<ERFilter> createERFilterNM2(const Ptr<ERFilter::Callback>& cb,
float minProbability = (float)0.3);
+/** @brief Reads an Extremal Region Filter for the 1st stage classifier of N&M algorithm
+ from the provided path e.g. /path/to/cpp/trained_classifierNM1.xml
+
+ at overload
+ */
+CV_EXPORTS_W Ptr<ERFilter> createERFilterNM1(const String& filename,
+ int thresholdDelta = 1, float minArea = (float)0.00025,
+ float maxArea = (float)0.13, float minProbability = (float)0.4,
+ bool nonMaxSuppression = true,
+ float minProbabilityDiff = (float)0.1);
+
+/** @brief Reads an Extremal Region Filter for the 2nd stage classifier of N&M algorithm
+ from the provided path e.g. /path/to/cpp/trained_classifierNM2.xml
+
+ at overload
+ */
+CV_EXPORTS_W Ptr<ERFilter> createERFilterNM2(const String& filename,
+ float minProbability = (float)0.3);
/** @brief Allow to implicitly load the default classifier when creating an ERFilter object.
@@ -250,7 +245,7 @@ enum { ERFILTER_NM_RGBLGrad,
ERFILTER_NM_IHSGrad
};
-/** @brief Compute the different channels to be processed independently in the N&M algorithm [Neumann12].
+/** @brief Compute the different channels to be processed independently in the N&M algorithm @cite Neumann12.
@param _src Source image. Must be RGB CV_8UC3.
@@ -271,7 +266,7 @@ CV_EXPORTS_W void computeNMChannels(InputArray _src, CV_OUT OutputArrayOfArrays
//! text::erGrouping operation modes
enum erGrouping_Modes {
- /** Exhaustive Search algorithm proposed in [Neumann11] for grouping horizontally aligned text.
+ /** Exhaustive Search algorithm proposed in @cite Neumann11 for grouping horizontally aligned text.
The algorithm models a verification function for all the possible ER sequences. The
verification fuction for ER pairs consists in a set of threshold-based pairwise rules which
compare measurements of two regions (height ratio, centroid angle, and region distance). The
@@ -282,7 +277,7 @@ enum erGrouping_Modes {
consistent.
*/
ERGROUPING_ORIENTATION_HORIZ,
- /** Text grouping method proposed in [Gomez13][Gomez14] for grouping arbitrary oriented text. Regions
+ /** Text grouping method proposed in @cite Gomez13 @cite Gomez14 for grouping arbitrary oriented text. Regions
are agglomerated by Single Linkage Clustering in a weighted feature space that combines proximity
(x,y coordinates) and similarity measures (color, size, gradient magnitude, stroke width, etc.).
SLC provides a dendrogram where each node represents a text group hypothesis. Then the algorithm
@@ -299,7 +294,7 @@ enum erGrouping_Modes {
@param channels Vector of single channel images CV_8UC1 from wich the regions were extracted.
- at param regions Vector of ER's retreived from the ERFilter algorithm from each channel.
+ at param regions Vector of ER's retrieved from the ERFilter algorithm from each channel.
@param groups The output of the algorithm is stored in this parameter as set of lists of indexes to
provided regions.
@@ -335,7 +330,7 @@ CV_EXPORTS_W void erGrouping(InputArray image, InputArray channel,
@param image Source image CV_8UC1 from which the MSERs where extracted.
- at param contours Intput vector with all the contours (vector\<Point\>).
+ at param contours Input vector with all the contours (vector\<Point\>).
@param regions Output where the ERStat regions are stored.
@@ -353,6 +348,24 @@ CV_EXPORTS void MSERsToERStats(InputArray image, std::vector<std::vector<Point>
// Utility funtion for scripting
CV_EXPORTS_W void detectRegions(InputArray image, const Ptr<ERFilter>& er_filter1, const Ptr<ERFilter>& er_filter2, CV_OUT std::vector< std::vector<Point> >& regions);
+
+/** @brief Extracts text regions from image.
+
+ at param image Source image where text blocks needs to be extracted from. Should be CV_8UC3 (color).
+ at param er_filter1 Extremal Region Filter for the 1st stage classifier of N&M algorithm @cite Neumann12
+ at param er_filter2 Extremal Region Filter for the 2nd stage classifier of N&M algorithm @cite Neumann12
+ at param groups_rects Output list of rectangle blocks with text
+ at param method Grouping method (see text::erGrouping_Modes). Can be one of ERGROUPING_ORIENTATION_HORIZ, ERGROUPING_ORIENTATION_ANY.
+ at param filename The XML or YAML file with the classifier model (e.g. samples/trained_classifier_erGrouping.xml). Only to use when grouping method is ERGROUPING_ORIENTATION_ANY.
+ at param minProbability The minimum probability for accepting a group. Only to use when grouping method is ERGROUPING_ORIENTATION_ANY.
+
+
+ */
+CV_EXPORTS_W void detectRegions(InputArray image, const Ptr<ERFilter>& er_filter1, const Ptr<ERFilter>& er_filter2, CV_OUT std::vector<Rect> &groups_rects,
+ int method = ERGROUPING_ORIENTATION_HORIZ,
+ const String& filename = String(),
+ float minProbability = (float)0.5);
+
//! @}
}
diff --git a/contrib/modules/text/include/opencv2/text/ocr.hpp b/contrib/modules/text/include/opencv2/text/ocr.hpp
index 1261046..1ba37f0 100644
--- a/contrib/modules/text/include/opencv2/text/ocr.hpp
+++ b/contrib/modules/text/include/opencv2/text/ocr.hpp
@@ -61,6 +61,31 @@ enum
OCR_LEVEL_TEXTLINE
};
+//! Tesseract.PageSegMode Enumeration
+enum page_seg_mode
+{
+ PSM_OSD_ONLY,
+ PSM_AUTO_OSD,
+ PSM_AUTO_ONLY,
+ PSM_AUTO,
+ PSM_SINGLE_COLUMN,
+ PSM_SINGLE_BLOCK_VERT_TEXT,
+ PSM_SINGLE_BLOCK,
+ PSM_SINGLE_LINE,
+ PSM_SINGLE_WORD,
+ PSM_CIRCLE_WORD,
+ PSM_SINGLE_CHAR
+};
+
+//! Tesseract.OcrEngineMode Enumeration
+enum ocr_engine_mode
+{
+ OEM_TESSERACT_ONLY,
+ OEM_CUBE_ONLY,
+ OEM_TESSERACT_CUBE_COMBINED,
+ OEM_DEFAULT
+};
+
//base class BaseOCR declares a common API that would be used in a typical text recognition scenario
class CV_EXPORTS_W BaseOCR
{
@@ -103,7 +128,7 @@ public:
recognition of individual text elements found (e.g. words or text lines).
@param component_confidences If provided the method will output a list of confidence values
for the recognition of individual text elements found (e.g. words or text lines).
- @param component_level OCR_LEVEL_WORD (by default), or OCR_LEVEL_TEXT_LINE.
+ @param component_level OCR_LEVEL_WORD (by default), or OCR_LEVEL_TEXTLINE.
*/
virtual void run(Mat& image, std::string& output_text, std::vector<Rect>* component_rects=NULL,
std::vector<std::string>* component_texts=NULL, std::vector<float>* component_confidences=NULL,
@@ -128,7 +153,7 @@ public:
@param language an ISO 639-3 code or NULL will default to "eng".
@param char_whitelist specifies the list of characters used for recognition. NULL defaults to
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".
- @param oem tesseract-ocr offers different OCR Engine Modes (OEM), by deffault
+ @param oem tesseract-ocr offers different OCR Engine Modes (OEM), by default
tesseract::OEM_DEFAULT is used. See the tesseract-ocr API documentation for other possible
values.
@param psmode tesseract-ocr offers different Page Segmentation Modes (PSM) tesseract::PSM_AUTO
@@ -136,7 +161,7 @@ public:
possible values.
*/
CV_WRAP static Ptr<OCRTesseract> create(const char* datapath=NULL, const char* language=NULL,
- const char* char_whitelist=NULL, int oem=3, int psmode=3);
+ const char* char_whitelist=NULL, int oem=OEM_DEFAULT, int psmode=PSM_AUTO);
};
@@ -147,6 +172,13 @@ enum decoder_mode
OCR_DECODER_VITERBI = 0 // Other algorithms may be added
};
+/* OCR classifier type*/
+enum classifier_type
+{
+ OCR_KNN_CLASSIFIER = 0,
+ OCR_CNN_CLASSIFIER = 1
+};
+
/** @brief OCRHMMDecoder class provides an interface for OCR using Hidden Markov Models.
@note
@@ -163,7 +195,7 @@ public:
This way it hides the feature extractor and the classifier itself, so developers can write
their own OCR code.
- The default character classifier and feature extractor can be loaded using the utility funtion
+ The default character classifier and feature extractor can be loaded using the utility function
loadOCRHMMClassifierNM and KNN model provided in
<https://github.com/opencv/opencv_contrib/blob/master/modules/text/samples/OCRHMM_knn_model_data.xml.gz>.
*/
@@ -257,23 +289,38 @@ public:
(<http://en.wikipedia.org/wiki/Viterbi_algorithm>).
*/
static Ptr<OCRHMMDecoder> create(const Ptr<OCRHMMDecoder::ClassifierCallback> classifier,// The character classifier with built in feature extractor
- const std::string& vocabulary, // The language vocabulary (chars when ascii english text)
+ const std::string& vocabulary, // The language vocabulary (chars when ASCII English text)
// size() must be equal to the number of classes
InputArray transition_probabilities_table, // Table with transition probabilities between character pairs
- // cols == rows == vocabulari.size()
+ // cols == rows == vocabulary.size()
InputArray emission_probabilities_table, // Table with observation emission probabilities
- // cols == rows == vocabulari.size()
+ // cols == rows == vocabulary.size()
decoder_mode mode = OCR_DECODER_VITERBI); // HMM Decoding algorithm (only Viterbi for the moment)
CV_WRAP static Ptr<OCRHMMDecoder> create(const Ptr<OCRHMMDecoder::ClassifierCallback> classifier,// The character classifier with built in feature extractor
- const String& vocabulary, // The language vocabulary (chars when ascii english text)
+ const String& vocabulary, // The language vocabulary (chars when ASCII English text)
// size() must be equal to the number of classes
InputArray transition_probabilities_table, // Table with transition probabilities between character pairs
- // cols == rows == vocabulari.size()
+ // cols == rows == vocabulary.size()
InputArray emission_probabilities_table, // Table with observation emission probabilities
- // cols == rows == vocabulari.size()
+ // cols == rows == vocabulary.size()
int mode = OCR_DECODER_VITERBI); // HMM Decoding algorithm (only Viterbi for the moment)
+ /** @brief Creates an instance of the OCRHMMDecoder class. Loads and initializes HMMDecoder from the specified path
+
+ @overload
+ */
+ CV_WRAP static Ptr<OCRHMMDecoder> create(const String& filename,
+
+ const String& vocabulary, // The language vocabulary (chars when ASCII English text)
+ // size() must be equal to the number of classes
+ InputArray transition_probabilities_table, // Table with transition probabilities between character pairs
+ // cols == rows == vocabulary.size()
+ InputArray emission_probabilities_table, // Table with observation emission probabilities
+ // cols == rows == vocabulary.size()
+ int mode = OCR_DECODER_VITERBI, // HMM Decoding algorithm (only Viterbi for the moment)
+
+ int classifier = OCR_KNN_CLASSIFIER); // The character classifier type
protected:
Ptr<OCRHMMDecoder::ClassifierCallback> classifier;
@@ -293,6 +340,8 @@ fixed size, while retaining the centroid and aspect ratio, in order to extract a
based on gradient orientations along the chain-code of its perimeter. Then, the region is classified
using a KNN model trained with synthetic data of rendered characters with different standard font
types.
+
+ at deprecated loadOCRHMMClassifier instead
*/
CV_EXPORTS_W Ptr<OCRHMMDecoder::ClassifierCallback> loadOCRHMMClassifierNM(const String& filename);
@@ -305,14 +354,24 @@ The CNN default classifier is based in the scene text recognition method propose
Andrew NG in [Coates11a]. The character classifier consists in a Single Layer Convolutional Neural Network and
a linear classifier. It is applied to the input image in a sliding window fashion, providing a set of recognitions
at each window location.
+
+ at deprecated use loadOCRHMMClassifier instead
*/
CV_EXPORTS_W Ptr<OCRHMMDecoder::ClassifierCallback> loadOCRHMMClassifierCNN(const String& filename);
+/** @brief Allow to implicitly load the default character classifier when creating an OCRHMMDecoder object.
+
+ @param filename The XML or YAML file with the classifier model (e.g. OCRBeamSearch_CNN_model_data.xml.gz)
+
+ @param classifier Can be one of classifier_type enum values.
+
+ */
+CV_EXPORTS_W Ptr<OCRHMMDecoder::ClassifierCallback> loadOCRHMMClassifier(const String& filename, int classifier);
//! @}
/** @brief Utility function to create a tailored language model transitions table from a given list of words (lexicon).
*
- * @param vocabulary The language vocabulary (chars when ascii english text).
+ * @param vocabulary The language vocabulary (chars when ASCII English text).
*
* @param lexicon The list of words that are expected to be found in a particular image.
*
@@ -407,7 +466,7 @@ public:
@param classifier The character classifier with built in feature extractor.
- @param vocabulary The language vocabulary (chars when ascii english text). vocabulary.size()
+ @param vocabulary The language vocabulary (chars when ASCII English text). vocabulary.size()
must be equal to the number of classes of the classifier.
@param transition_probabilities_table Table with transition probabilities between character
@@ -422,25 +481,39 @@ public:
@param beam_size Size of the beam in Beam Search algorithm.
*/
static Ptr<OCRBeamSearchDecoder> create(const Ptr<OCRBeamSearchDecoder::ClassifierCallback> classifier,// The character classifier with built in feature extractor
- const std::string& vocabulary, // The language vocabulary (chars when ascii english text)
+ const std::string& vocabulary, // The language vocabulary (chars when ASCII English text)
// size() must be equal to the number of classes
InputArray transition_probabilities_table, // Table with transition probabilities between character pairs
- // cols == rows == vocabulari.size()
+ // cols == rows == vocabulary.size()
InputArray emission_probabilities_table, // Table with observation emission probabilities
- // cols == rows == vocabulari.size()
+ // cols == rows == vocabulary.size()
decoder_mode mode = OCR_DECODER_VITERBI, // HMM Decoding algorithm (only Viterbi for the moment)
int beam_size = 500); // Size of the beam in Beam Search algorithm
CV_WRAP static Ptr<OCRBeamSearchDecoder> create(const Ptr<OCRBeamSearchDecoder::ClassifierCallback> classifier, // The character classifier with built in feature extractor
- const String& vocabulary, // The language vocabulary (chars when ascii english text)
+ const String& vocabulary, // The language vocabulary (chars when ASCII English text)
// size() must be equal to the number of classes
InputArray transition_probabilities_table, // Table with transition probabilities between character pairs
- // cols == rows == vocabulari.size()
+ // cols == rows == vocabulary.size()
InputArray emission_probabilities_table, // Table with observation emission probabilities
- // cols == rows == vocabulari.size()
+ // cols == rows == vocabulary.size()
int mode = OCR_DECODER_VITERBI, // HMM Decoding algorithm (only Viterbi for the moment)
int beam_size = 500); // Size of the beam in Beam Search algorithm
+ /** @brief Creates an instance of the OCRBeamSearchDecoder class. Initializes HMMDecoder from the specified path.
+
+ @overload
+
+ */
+ CV_WRAP static Ptr<OCRBeamSearchDecoder> create(const String& filename, // The character classifier file
+ const String& vocabulary, // The language vocabulary (chars when ASCII English text)
+ // size() must be equal to the number of classes
+ InputArray transition_probabilities_table, // Table with transition probabilities between character pairs
+ // cols == rows == vocabulary.size()
+ InputArray emission_probabilities_table, // Table with observation emission probabilities
+ // cols == rows == vocabulary.size()
+ int mode = OCR_DECODER_VITERBI, // HMM Decoding algorithm (only Viterbi for the moment)
+ int beam_size = 500);
protected:
Ptr<OCRBeamSearchDecoder::ClassifierCallback> classifier;
diff --git a/contrib/modules/text/samples/character_recognition.cpp b/contrib/modules/text/samples/character_recognition.cpp
index 019c71c..6fcb29b 100644
--- a/contrib/modules/text/samples/character_recognition.cpp
+++ b/contrib/modules/text/samples/character_recognition.cpp
@@ -37,7 +37,7 @@ int main(int argc, char* argv[])
return(0);
}
- string vocabulary = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; // must have the same order as the clasifier output classes
+ string vocabulary = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; // must have the same order as the classifier output classes
Ptr<OCRHMMDecoder::ClassifierCallback> ocr = loadOCRHMMClassifierCNN("OCRBeamSearch_CNN_model_data.xml.gz");
diff --git a/contrib/modules/text/samples/cropped_word_recognition.cpp b/contrib/modules/text/samples/cropped_word_recognition.cpp
index 32e3570..e33b24d 100644
--- a/contrib/modules/text/samples/cropped_word_recognition.cpp
+++ b/contrib/modules/text/samples/cropped_word_recognition.cpp
@@ -36,7 +36,7 @@ int main(int argc, char* argv[])
return(0);
}
- string vocabulary = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; // must have the same order as the clasifier output classes
+ string vocabulary = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; // must have the same order as the classifier output classes
vector<string> lexicon; // a list of words expected to be found on the input image
lexicon.push_back(string("abb"));
lexicon.push_back(string("riser"));
@@ -53,7 +53,7 @@ int main(int argc, char* argv[])
createOCRHMMTransitionsTable(vocabulary,lexicon,transition_p);
// An alternative would be to load the default generic language model
- // (created from ispell 42869 english words list)
+ // (created from ispell 42869 English words list)
/*Mat transition_p;
string filename = "OCRHMM_transitions_table.xml";
FileStorage fs(filename, FileStorage::READ);
diff --git a/contrib/modules/text/samples/end_to_end_recognition.cpp b/contrib/modules/text/samples/end_to_end_recognition.cpp
index c69d78b..1b07906 100644
--- a/contrib/modules/text/samples/end_to_end_recognition.cpp
+++ b/contrib/modules/text/samples/end_to_end_recognition.cpp
@@ -20,7 +20,7 @@ using namespace std;
using namespace cv;
using namespace cv::text;
-//Calculate edit distance netween two words
+//Calculate edit distance between two words
size_t edit_distance(const string& A, const string& B);
size_t min(size_t x, size_t y, size_t z);
bool isRepetitive(const string& s);
@@ -136,7 +136,7 @@ int main(int argc, char* argv[])
ocr->run(group_img, output, &boxes, &words, &confidences, OCR_LEVEL_WORD);
output.erase(remove(output.begin(), output.end(), '\n'), output.end());
- //cout << "OCR output = \"" << output << "\" lenght = " << output.size() << endl;
+ //cout << "OCR output = \"" << output << "\" length = " << output.size() << endl;
if (output.size() < 3)
continue;
@@ -164,7 +164,7 @@ int main(int argc, char* argv[])
cout << "TIME_OCR = " << ((double)getTickCount() - t_r)*1000/getTickFrequency() << endl;
- /* Recognition evaluation with (approximate) hungarian matching and edit distances */
+ /* Recognition evaluation with (approximate) Hungarian matching and edit distances */
if(argc>2)
{
diff --git a/contrib/modules/text/samples/segmented_word_recognition.cpp b/contrib/modules/text/samples/segmented_word_recognition.cpp
index d3b50d2..18b1026 100644
--- a/contrib/modules/text/samples/segmented_word_recognition.cpp
+++ b/contrib/modules/text/samples/segmented_word_recognition.cpp
@@ -54,7 +54,7 @@ int main(int argc, char* argv[]) {
else
image.copyTo(mask);
- // be sure the mask is a binry image
+ // be sure the mask is a binary image
cvtColor(mask, mask, COLOR_BGR2GRAY);
threshold(mask, mask, 128., 255, THRESH_BINARY);
diff --git a/contrib/modules/text/samples/textdetection.py b/contrib/modules/text/samples/textdetection.py
index 1da2833..1f265ae 100644
--- a/contrib/modules/text/samples/textdetection.py
+++ b/contrib/modules/text/samples/textdetection.py
@@ -44,7 +44,7 @@ for channel in channels:
regions = cv2.text.detectRegions(channel,er1,er2)
rects = cv2.text.erGrouping(img,channel,[r.tolist() for r in regions])
- #rects = cv2.text.erGrouping(img,gray,[x.tolist() for x in regions], cv2.text.ERGROUPING_ORIENTATION_ANY,'../../GSoC2014/opencv_contrib/modules/text/samples/trained_classifier_erGrouping.xml',0.5)
+ #rects = cv2.text.erGrouping(img,channel,[x.tolist() for x in regions], cv2.text.ERGROUPING_ORIENTATION_ANY,'../../GSoC2014/opencv_contrib/modules/text/samples/trained_classifier_erGrouping.xml',0.5)
#Visualization
for r in range(0,np.shape(rects)[0]):
diff --git a/contrib/modules/text/samples/webcam_demo.cpp b/contrib/modules/text/samples/webcam_demo.cpp
index 6f8d95e..6071b3c 100644
--- a/contrib/modules/text/samples/webcam_demo.cpp
+++ b/contrib/modules/text/samples/webcam_demo.cpp
@@ -290,7 +290,7 @@ int main(int argc, char* argv[])
{
outputs[i].erase(remove(outputs[i].begin(), outputs[i].end(), '\n'), outputs[i].end());
- //cout << "OCR output = \"" << outputs[i] << "\" lenght = " << outputs[i].size() << endl;
+ //cout << "OCR output = \"" << outputs[i] << "\" length = " << outputs[i].size() << endl;
if (outputs[i].size() < 3)
continue;
diff --git a/contrib/modules/text/src/erfilter.cpp b/contrib/modules/text/src/erfilter.cpp
index f438c75..8bb14de 100644
--- a/contrib/modules/text/src/erfilter.cpp
+++ b/contrib/modules/text/src/erfilter.cpp
@@ -51,7 +51,9 @@
typedef int int_fast32_t;
#else
#ifndef INT32_MAX
+ #ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS
+ #endif
#include <stdint.h>
#endif
#endif
@@ -105,7 +107,7 @@ ERStat::ERStat(int init_level, int init_pixel, int init_x, int init_y) : pixel(i
// derivative classes
-// the classe implementing the interface for the 1st and 2nd stages of Neumann and Matas algorithm
+// the classes implementing the interface for the 1st and 2nd stages of Neumann and Matas algorithm
class CV_EXPORTS ERFilterNM : public ERFilter
{
public:
@@ -275,11 +277,11 @@ void ERFilterNM::er_tree_extract( InputArray image )
// the component stack
vector<ERStat*> er_stack;
- // the quads for euler number calculation
+ // the quads for Euler's number calculation
// quads[2][2] and quads[2][3] are never used.
- // The four lowest bits in each quads[i][j] correspond to the 2x2 binary patterns
- // Q_1, Q_2, Q_3 in the Neumann and Matas CVPR 2012 paper
- // (see in page 4 at the end of first column).
+ // The four lowest bits in each quads[i][j] correspond to the 2x2 binary patterns
+ // Q_1, Q_2, Q_3 in the Neumann and Matas CVPR 2012 paper
+ // (see in page 4 at the end of first column).
// Q_1 and Q_2 have four patterns, while Q_3 has only two.
const int quads[3][4] =
{
@@ -334,7 +336,7 @@ void ERFilterNM::er_tree_extract( InputArray image )
default: if (y > 0) neighbour_pixel = current_pixel - width; break;
}
- // if neighbour is not accessible, mark it accessible and retreive its grey-level value
+ // if neighbour is not accessible, mark it accessible and retrieve its grey-level value
if ( !accessible_pixel_mask[neighbour_pixel] && (neighbour_pixel != current_pixel) )
{
@@ -375,14 +377,14 @@ void ERFilterNM::er_tree_extract( InputArray image )
}
}
- } // else neigbor was already accessible
+ } // else neighbour was already accessible
if (push_new_component) continue;
// once here we can add the current pixel to the component at the top of the stack
// but first we find how many of its neighbours are part of the region boundary (needed for
- // perimeter and crossings calc.) and the increment in quads counts for euler number calc.
+ // perimeter and crossings calc.) and the increment in quads counts for Euler's number calc.
int non_boundary_neighbours = 0;
int non_boundary_neighbours_horiz = 0;
@@ -799,7 +801,7 @@ ERStat* ERFilterNM::er_tree_filter ( InputArray image, ERStat * stat, ERStat *pa
vector<Point> contour_poly;
vector<Vec4i> hierarchy;
findContours( region, contours, hierarchy, RETR_TREE, CHAIN_APPROX_NONE, Point(0, 0) );
- //TODO check epsilon parameter of approxPolyDP (set empirically) : we want more precission
+ //TODO check epsilon parameter of approxPolyDP (set empirically) : we want more precision
// if the region is very small because otherwise we'll loose all the convexities
approxPolyDP( Mat(contours[0]), contour_poly, (float)min(rect.width,rect.height)/17, true );
@@ -1087,9 +1089,9 @@ double ERClassifierNM2::eval(const ERStat& stat)
default classifier can be implicitly load with function loadClassifierNM1()
from file in samples/cpp/trained_classifierNM1.xml
\param thresholdDelta Threshold step in subsequent thresholds when extracting the component tree
- \param minArea The minimum area (% of image size) allowed for retreived ER's
- \param minArea The maximum area (% of image size) allowed for retreived ER's
- \param minProbability The minimum probability P(er|character) allowed for retreived ER's
+ \param minArea The minimum area (% of image size) allowed for retrieved ER's
+ \param minArea The maximum area (% of image size) allowed for retrieved ER's
+ \param minProbability The minimum probability P(er|character) allowed for retrieved ER's
\param nonMaxSuppression Whenever non-maximum suppression is done over the branch probabilities
\param minProbability The minimum probability difference between local maxima and local minima ERs
*/
@@ -1143,6 +1145,17 @@ Ptr<ERFilter> createERFilterNM2(const Ptr<ERFilter::Callback>& cb, float minProb
return (Ptr<ERFilter>)filter;
}
+Ptr<ERFilter> createERFilterNM1(const String& filename, int _thresholdDelta,
+ float _minArea, float _maxArea, float _minProbability,
+ bool _nonMaxSuppression, float _minProbabilityDiff) {
+ return createERFilterNM1(loadClassifierNM1(filename), _thresholdDelta, _minArea, _maxArea, _minProbability, _nonMaxSuppression, _minProbabilityDiff);
+
+}
+
+Ptr<ERFilter> createERFilterNM2(const String& filename, float _minProbability) {
+ return createERFilterNM2(loadClassifierNM2(filename), _minProbability);
+}
+
/*!
Allow to implicitly load the default classifier when creating an ERFilter object.
The function takes as parameter the XML or YAML file with the classifier model
@@ -1209,12 +1222,12 @@ void get_gradient_magnitude(Mat& _grey_img, Mat& _gradient_magnitude)
/*!
- Compute the diferent channels to be processed independently in the N&M algorithm
+ Compute the different channels to be processed independently in the N&M algorithm
Neumann L., Matas J.: Real-Time Scene Text Localization and Recognition, CVPR 2012
In N&M algorithm, the combination of intensity (I), hue (H), saturation (S), and gradient
- magnitude channels (Grad) are used in order to obatin high localization recall.
- This implementation also the alternative combination of red (R), grren (G), blue (B),
+ magnitude channels (Grad) are used in order to obtain high localization recall.
+ This implementation also the alternative combination of red (R), green (G), blue (B),
lightness (L), and gradient magnitude (Grad).
\param _src Source image. Must be RGB CV_8UC3.
@@ -1952,7 +1965,7 @@ public:
static void generate_dendrogram(double * const Z, cluster_result & Z2, const int_fast32_t N)
{
// The array "nodes" is a union-find data structure for the cluster
- // identites (only needed for unsorted cluster_result input).
+ // identities (only needed for unsorted cluster_result input).
union_find nodes;
stable_sort(Z2[0], Z2[N-1]);
nodes.init(N);
@@ -2183,11 +2196,11 @@ struct HCluster{
vector<int> elements; // elements (contour ID)
int nfa; // the number of false alarms for this merge
float dist; // distance of the merge
- float dist_ext; // distamce where this merge will merge with another
+ float dist_ext; // distance where this merge will merge with another
long double volume; // volume of the bounding sphere (or bounding box)
long double volume_ext; // volume of the sphere(or box) + envolvent empty space
vector<vector<float> > points; // nD points in this cluster
- bool max_meaningful; // is this merge max meaningul ?
+ bool max_meaningful; // is this merge max meaningful ?
vector<int> max_in_branch; // otherwise which merges are the max_meaningful in this branch
int min_nfa_in_branch; // min nfa detected within the chilhood
int node1;
@@ -2272,7 +2285,7 @@ void MaxMeaningfulClustering::build_merge_info(double *Z, double *X, int N, int
vector< vector<int> > *meaningful_clusters)
{
- // walk the whole dendogram
+ // walk the whole dendrogram
for (int i=0; i<(N-1)*4; i=i+4)
{
HCluster cluster;
@@ -2951,7 +2964,7 @@ static float extract_features(Mat &grey, Mat& channel, vector<ERStat> ®ions,
f.convex_hull_ratio = (float)contourArea(hull)/contourArea(contours0[0]);
vector<Vec4i> cx;
vector<int> hull_idx;
- //TODO check epsilon parameter of approxPolyDP (set empirically) : we want more precission
+ //TODO check epsilon parameter of approxPolyDP (set empirically) : we want more precision
// if the region is very small because otherwise we'll loose all the convexities
approxPolyDP( Mat(contours0[0]), contours0[0], (float)min(rrect.size.width,rrect.size.height)/17, true );
convexHull(contours0[0],hull_idx,false,false);
@@ -2994,7 +3007,7 @@ static float extract_features(Mat &grey, Mat& channel, vector<ERStat> ®ions,
\param _image Original RGB image from wich the regions were extracted.
\param _src Vector of sinle channel images CV_8UC1 from wich the regions were extracted.
- \param regions Vector of ER's retreived from the ERFilter algorithm from each channel
+ \param regions Vector of ER's retrieved from the ERFilter algorithm from each channel
\param groups The output of the algorithm are stored in this parameter as list of indexes to provided regions.
\param text_boxes The output of the algorithm are stored in this parameter as list of rectangles.
\param filename The XML or YAML file with the classifier model (e.g. trained_classifier_erGrouping.xml)
@@ -3145,7 +3158,7 @@ struct line_estimates
};
// distanceLinesEstimates
-// Calculates the distance between two line estimates defined as the largest
+// Calculates the distance between two line estimates defined as the largest
// normalized vertical difference of their top/bottom lines at their boundary points
// out float distance
float distanceLinesEstimates(line_estimates &a, line_estimates &b);
@@ -3315,7 +3328,7 @@ void fitLineOLS(Point p1, Point p2, Point p3, float &a0, float &a1)
a1=(float)(3*sumxy-sumx*sumy) / (3*sumx2-sumx*sumx);
}
-// Fit line from three points using (heutistic) Least-Median of Squares
+// Fit line from three points using (heuristic) Least-Median of Squares
// out a0 is the intercept
// out a1 is the slope
// returns the error of the single point that doesn't fit the line
@@ -3326,7 +3339,7 @@ float fitLineLMS(Point p1, Point p2, Point p3, float &a0, float &a1)
a1 = 0;
//Least-Median of Squares does not make sense with only three points
- //becuse any line passing by two of them has median_error = 0
+ //because any line passing by two of them has median_error = 0
//So we'll take the one with smaller slope
float l_a0, l_a1, best_slope=FLT_MAX, err=0;
@@ -3717,7 +3730,7 @@ bool sort_couples (Vec3i i,Vec3i j) { return (i[0]<j[0]); }
\param _img Original RGB image from wich the regions were extracted.
\param _src Vector of sinle channel images CV_8UC1 from wich the regions were extracted.
- \param regions Vector of ER's retreived from the ERFilter algorithm from each channel
+ \param regions Vector of ER's retrieved from the ERFilter algorithm from each channel
\param out_groups The output of the algorithm are stored in this parameter as list of indexes to provided regions.
\param out_boxes The output of the algorithm are stored in this parameter as list of rectangles.
\param do_feedback Whenever the grouping algorithm uses a feedback loop to recover missing regions in a line.
@@ -3810,7 +3823,7 @@ void erGroupingNM(InputArray _img, InputArrayOfArrays _src, vector< vector<ERSta
{
for (size_t j=i+1; j<valid_pairs.size(); j++)
{
- // check colinearity rules
+ // check collinearity rules
region_triplet valid_triplet(Vec2i(0,0),Vec2i(0,0),Vec2i(0,0));
if (isValidTriplet(regions, valid_pairs[i],valid_pairs[j], valid_triplet))
{
@@ -3878,7 +3891,7 @@ void erGroupingNM(InputArray _img, InputArrayOfArrays _src, vector< vector<ERSta
if (do_feedback_loop)
{
- //Feedback loop of detected lines to region extraction ... tries to recover missmatches in the region decomposition step by extracting regions in the neighbourhood of a valid sequence and checking if they are consistent with its line estimates
+ //Feedback loop of detected lines to region extraction ... tries to recover mismatches in the region decomposition step by extracting regions in the neighbourhood of a valid sequence and checking if they are consistent with its line estimates
Ptr<ERFilter> er_filter = createERFilterNM1(loadDummyClassifier(),1,0.005f,0.3f,0.f,false);
for (int i=0; i<(int)valid_sequences.size(); i++)
{
@@ -4159,7 +4172,7 @@ void MSERsToERStats(InputArray image, vector<vector<Point> > &contours, vector<v
}
}
-// Utility funtion for scripting
+// Utility function for scripting
void detectRegions(InputArray image, const Ptr<ERFilter>& er_filter1, const Ptr<ERFilter>& er_filter2, CV_OUT vector< vector<Point> >& regions)
{
// assert correct image type
@@ -4206,5 +4219,41 @@ void detectRegions(InputArray image, const Ptr<ERFilter>& er_filter1, const Ptr<
}
}
+
+void detectRegions(InputArray image, const Ptr<ERFilter>& er_filter1, const Ptr<ERFilter>& er_filter2,
+ CV_OUT std::vector<Rect> &groups_rects,
+ int method,
+ const String& filename,
+ float minProbability)
+{
+ // assert correct image type
+ CV_Assert( image.type() == CV_8UC3 );
+
+ CV_Assert( !er_filter1.empty() );
+ CV_Assert( !er_filter2.empty() );
+
+ // Extract channels to be processed individually
+ vector<Mat> channels;
+
+ Mat grey;
+ cvtColor(image,grey,COLOR_RGB2GRAY);
+
+ // here we are only using grey channel
+ channels.push_back(grey);
+ channels.push_back(255-grey);
+
+ vector<vector<ERStat> > regions(channels.size());
+
+ // Apply the default cascade classifier to each independent channel (could be done in parallel)
+ for (int c=0; c<(int)channels.size(); c++)
+ {
+ er_filter1->run(channels[c], regions[c]);
+ er_filter2->run(channels[c], regions[c]);
+ }
+ // Detect character groups
+ vector< vector<Vec2i> > nm_region_groups;
+ erGrouping(image, channels, regions, nm_region_groups, groups_rects, method, filename, minProbability);
+}
+
}
}
diff --git a/contrib/modules/text/src/ocr_beamsearch_decoder.cpp b/contrib/modules/text/src/ocr_beamsearch_decoder.cpp
index 41be856..b746e4b 100644
--- a/contrib/modules/text/src/ocr_beamsearch_decoder.cpp
+++ b/contrib/modules/text/src/ocr_beamsearch_decoder.cpp
@@ -144,7 +144,7 @@ struct beamSearch_node {
double score;
vector<int> segmentation;
bool expanded;
- // TODO calculating score of its childs would be much faster if we store the last column
+ // TODO calculating score of its child would be much faster if we store the last column
// of their "root" path.
};
@@ -231,7 +231,7 @@ public:
// TODO if input is a text line (not a word) we may need to split into words here!
- // do sliding window classification along a croped word image
+ // do sliding window classification along a cropped word image
classifier->eval(src, recognition_probabilities, oversegmentation);
// if the number of oversegmentation points found is less than 2 we can not do nothing!!
@@ -499,7 +499,7 @@ Ptr<OCRBeamSearchDecoder> OCRBeamSearchDecoder::create( Ptr<OCRBeamSearchDecoder
return makePtr<OCRBeamSearchDecoderImpl>(_classifier, _vocabulary, transition_p, emission_p, _mode, _beam_size);
}
-CV_EXPORTS_W Ptr<OCRBeamSearchDecoder> OCRBeamSearchDecoder::create(Ptr<OCRBeamSearchDecoder::ClassifierCallback> _classifier,
+Ptr<OCRBeamSearchDecoder> OCRBeamSearchDecoder::create(Ptr<OCRBeamSearchDecoder::ClassifierCallback> _classifier,
const String& _vocabulary,
InputArray transition_p,
InputArray emission_p,
@@ -509,8 +509,17 @@ CV_EXPORTS_W Ptr<OCRBeamSearchDecoder> OCRBeamSearchDecoder::create(Ptr<OCRBeamS
return makePtr<OCRBeamSearchDecoderImpl>(_classifier, _vocabulary, transition_p, emission_p, (decoder_mode)_mode, _beam_size);
}
+Ptr<OCRBeamSearchDecoder> OCRBeamSearchDecoder::create(const String& _filename,
+ const String& _vocabulary,
+ InputArray transition_p,
+ InputArray emission_p,
+ int _mode,
+ int _beam_size)
+{
+ return makePtr<OCRBeamSearchDecoderImpl>(loadOCRBeamSearchClassifierCNN(_filename), _vocabulary, transition_p, emission_p, (decoder_mode)_mode, _beam_size);
+}
-class CV_EXPORTS OCRBeamSearchClassifierCNN : public OCRBeamSearchDecoder::ClassifierCallback
+class OCRBeamSearchClassifierCNN : public OCRBeamSearchDecoder::ClassifierCallback
{
public:
//constructor
@@ -566,7 +575,7 @@ OCRBeamSearchClassifierCNN::OCRBeamSearchClassifierCNN (const string& filename)
nr_feature = weights.rows;
nr_class = weights.cols;
- patch_size = (int)sqrt((float)kernels.cols);
+ patch_size = cvRound(sqrt((float)kernels.cols));
window_size = 4*patch_size;
step_size = 4;
quad_size = 12;
@@ -602,8 +611,12 @@ void OCRBeamSearchClassifierCNN::eval( InputArray _src, vector< vector<double> >
Mat tmp;
Mat img;
+ int sz = src.cols - window_size;
+ int sz_window_quad = window_size - quad_size;
+ int sz_half_quad = (int)(quad_size/2-1);
+ int sz_quad_patch = quad_size - patch_size;
// begin sliding window loop foreach detection window
- for (int x_c=0; x_c<=src.cols-window_size; x_c=x_c+step_size)
+ for (int x_c = 0; x_c <= sz; x_c += step_size)
{
img = src(Rect(Point(x_c,0),Size(window_size,window_size)));
@@ -613,21 +626,21 @@ void OCRBeamSearchClassifierCNN::eval( InputArray _src, vector< vector<double> >
int quad_id = 1;
- for (int q_x=0; q_x<=window_size-quad_size; q_x=q_x+(quad_size/2-1))
+
+ for (int q_x = 0; q_x <= sz_window_quad; q_x += sz_half_quad)
{
- for (int q_y=0; q_y<=window_size-quad_size; q_y=q_y+(quad_size/2-1))
+ for (int q_y = 0; q_y <= sz_window_quad; q_y += sz_half_quad)
{
Rect quad_rect = Rect(q_x,q_y,quad_size,quad_size);
quad = img(quad_rect);
//start sliding window (8x8) in each tile and store the patch as row in data_pool
- for (int w_x=0; w_x<=quad_size-patch_size; w_x++)
+ for (int w_x = 0; w_x <= sz_quad_patch; w_x++)
{
- for (int w_y=0; w_y<=quad_size-patch_size; w_y++)
+ for (int w_y = 0; w_y <= sz_quad_patch; w_y++)
{
- quad(Rect(w_x,w_y,patch_size,patch_size)).copyTo(tmp);
+ quad(Rect(w_x,w_y,patch_size,patch_size)).convertTo(tmp, CV_64F);
tmp = tmp.reshape(0,1);
- tmp.convertTo(tmp, CV_64F);
normalizeAndZCA(tmp);
vector<double> patch;
tmp.copyTo(patch);
@@ -657,6 +670,7 @@ void OCRBeamSearchClassifierCNN::eval( InputArray _src, vector< vector<double> >
}
}
+
//do dot product of each normalized and whitened patch
//each pool is averaged and this yields a representation of 9xD
Mat feature = Mat::zeros(9,kernels.rows,CV_64FC1);
diff --git a/contrib/modules/text/src/ocr_hmm_decoder.cpp b/contrib/modules/text/src/ocr_hmm_decoder.cpp
index e436749..c0e9af4 100644
--- a/contrib/modules/text/src/ocr_hmm_decoder.cpp
+++ b/contrib/modules/text/src/ocr_hmm_decoder.cpp
@@ -90,7 +90,7 @@ void OCRHMMDecoder::run(Mat& image, Mat& mask, string& output_text, vector<Rect>
component_confidences->clear();
}
-CV_WRAP String OCRHMMDecoder::run(InputArray image, int min_confidence, int component_level)
+String OCRHMMDecoder::run(InputArray image, int min_confidence, int component_level)
{
std::string output1;
std::string output2;
@@ -109,7 +109,7 @@ CV_WRAP String OCRHMMDecoder::run(InputArray image, int min_confidence, int comp
return String(output2);
}
-CV_WRAP cv::String OCRHMMDecoder::run(InputArray image, InputArray mask, int min_confidence, int component_level)
+cv::String OCRHMMDecoder::run(InputArray image, InputArray mask, int min_confidence, int component_level)
{
std::string output1;
std::string output2;
@@ -684,8 +684,17 @@ Ptr<OCRHMMDecoder> OCRHMMDecoder::create( Ptr<OCRHMMDecoder::ClassifierCallback>
return makePtr<OCRHMMDecoderImpl>(_classifier, _vocabulary, transition_p, emission_p, (decoder_mode)_mode);
}
+Ptr<OCRHMMDecoder> OCRHMMDecoder::create( const String& _filename,
+ const String& _vocabulary,
+ InputArray transition_p,
+ InputArray emission_p,
+ int _mode,
+ int _classifier)
+{
+ return makePtr<OCRHMMDecoderImpl>(loadOCRHMMClassifier(_filename, _classifier), _vocabulary, transition_p, emission_p, (decoder_mode)_mode);
+}
-class CV_EXPORTS OCRHMMClassifierKNN : public OCRHMMDecoder::ClassifierCallback
+class OCRHMMClassifierKNN : public OCRHMMDecoder::ClassifierCallback
{
public:
//constructor
@@ -916,6 +925,22 @@ void OCRHMMClassifierKNN::eval( InputArray _mask, vector<int>& out_class, vector
}
+Ptr<OCRHMMDecoder::ClassifierCallback> loadOCRHMMClassifier(const String& _filename, int _classifier)
+
+{
+ Ptr<OCRHMMDecoder::ClassifierCallback> pt;
+ switch(_classifier) {
+ case OCR_KNN_CLASSIFIER:
+ pt = loadOCRHMMClassifierNM(_filename);
+ break;
+ case OCR_CNN_CLASSIFIER:
+ pt = loadOCRHMMClassifierCNN(_filename);
+ default:
+ CV_Error(Error::StsBadArg, "Specified HMM classifier is not supported!");
+ break;
+ }
+ return pt;
+}
Ptr<OCRHMMDecoder::ClassifierCallback> loadOCRHMMClassifierNM(const String& filename)
@@ -923,7 +948,7 @@ Ptr<OCRHMMDecoder::ClassifierCallback> loadOCRHMMClassifierNM(const String& file
return makePtr<OCRHMMClassifierKNN>(std::string(filename));
}
-class CV_EXPORTS OCRHMMClassifierCNN : public OCRHMMDecoder::ClassifierCallback
+class OCRHMMClassifierCNN : public OCRHMMDecoder::ClassifierCallback
{
public:
//constructor
@@ -982,7 +1007,7 @@ OCRHMMClassifierCNN::OCRHMMClassifierCNN (const string& filename)
nr_feature = weights.rows;
nr_class = weights.cols;
- patch_size = (int)sqrt((float)kernels.cols);
+ patch_size = cvRound(sqrt((float)kernels.cols));
// algorithm internal parameters
window_size = 32;
num_quads = 25;
@@ -1017,21 +1042,23 @@ void OCRHMMClassifierCNN::eval( InputArray _src, vector<int>& out_class, vector<
int quad_id = 1;
- for (int q_x=0; q_x<=window_size-quad_size; q_x=q_x+(int)(quad_size/2-1))
+ int sz_window_quad = window_size - quad_size;
+ int sz_half_quad = (int)(quad_size/2-1);
+ int sz_quad_patch = quad_size - patch_size;
+ for (int q_x=0; q_x <= sz_window_quad; q_x += sz_half_quad)
{
- for (int q_y=0; q_y<=window_size-quad_size; q_y=q_y+(int)(quad_size/2-1))
+ for (int q_y=0; q_y <= sz_window_quad; q_y += sz_half_quad)
{
Rect quad_rect = Rect(q_x,q_y,quad_size,quad_size);
quad = img(quad_rect);
//start sliding window (8x8) in each tile and store the patch as row in data_pool
- for (int w_x=0; w_x<=quad_size-patch_size; w_x++)
+ for (int w_x = 0; w_x <= sz_quad_patch; w_x++)
{
- for (int w_y=0; w_y<=quad_size-patch_size; w_y++)
+ for (int w_y = 0; w_y <= sz_quad_patch; w_y++)
{
- quad(Rect(w_x,w_y,patch_size,patch_size)).copyTo(tmp);
+ quad(Rect(w_x,w_y,patch_size,patch_size)).convertTo(tmp, CV_64F);
tmp = tmp.reshape(0,1);
- tmp.convertTo(tmp, CV_64F);
normalizeAndZCA(tmp);
vector<double> patch;
tmp.copyTo(patch);
diff --git a/contrib/modules/tracking/CMakeLists.txt b/contrib/modules/tracking/CMakeLists.txt
index a8b3183..6fa88af 100644
--- a/contrib/modules/tracking/CMakeLists.txt
+++ b/contrib/modules/tracking/CMakeLists.txt
@@ -1,2 +1,3 @@
set(the_description "Tracking API")
-ocv_define_module(tracking opencv_imgproc opencv_core opencv_video opencv_highgui opencv_dnn opencv_plot OPTIONAL opencv_datasets WRAP python)
\ No newline at end of file
+ocv_define_module(tracking opencv_imgproc opencv_core opencv_video opencv_plot OPTIONAL opencv_dnn opencv_datasets WRAP java python)
+ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-shadow /wd4458)
diff --git a/contrib/modules/tracking/include/opencv2/tracking/tldDataset.hpp b/contrib/modules/tracking/include/opencv2/tracking/tldDataset.hpp
index d31919a..a874255 100644
--- a/contrib/modules/tracking/include/opencv2/tracking/tldDataset.hpp
+++ b/contrib/modules/tracking/include/opencv2/tracking/tldDataset.hpp
@@ -42,15 +42,15 @@
#ifndef OPENCV_TLD_DATASET
#define OPENCV_TLD_DATASET
-#include "opencv2/highgui.hpp"
+#include "opencv2/core.hpp"
namespace cv
{
namespace tld
{
CV_EXPORTS cv::Rect2d tld_InitDataset(int videoInd, const char* rootPath = "TLD_dataset", int datasetInd = 0);
- CV_EXPORTS cv::Mat tld_getNextDatasetFrame();
+ CV_EXPORTS cv::String tld_getNextDatasetFrame();
}
}
-#endif
\ No newline at end of file
+#endif
diff --git a/contrib/modules/tracking/include/opencv2/tracking/tracker.hpp b/contrib/modules/tracking/include/opencv2/tracking/tracker.hpp
index 3b32033..c69ca5b 100644
--- a/contrib/modules/tracking/include/opencv2/tracking/tracker.hpp
+++ b/contrib/modules/tracking/include/opencv2/tracking/tracker.hpp
@@ -47,12 +47,6 @@
#include "feature.hpp"
#include "onlineMIL.hpp"
#include "onlineBoosting.hpp"
-#include <iostream>
-
-
-#define BOILERPLATE_CODE(name,classname) \
- static Ptr<classname> createTracker(const classname::Params ¶meters=classname::Params());\
- virtual ~classname(){};
/*
* Partially based on:
@@ -539,7 +533,7 @@ class CV_EXPORTS_W Tracker : public virtual Algorithm
@return True if initialization went succesfully, false otherwise
*/
- CV_WRAP bool init( const Mat& image, const Rect2d& boundingBox );
+ CV_WRAP bool init( InputArray image, const Rect2d& boundingBox );
/** @brief Update the tracker, find the new most likely bounding box for the target
@param image The current frame
@@ -550,26 +544,11 @@ class CV_EXPORTS_W Tracker : public virtual Algorithm
current frame. Note, that latter *does not* imply that tracker has failed, maybe target is indeed
missing from the frame (say, out of sight)
*/
- CV_WRAP bool update( const Mat& image, CV_OUT Rect2d& boundingBox );
-
- /** @brief Creates a tracker by its name.
- @param trackerType Tracker type
-
- The following detector types are supported:
-
- - "MIL" -- TrackerMIL
- - "BOOSTING" -- TrackerBoosting
- */
- CV_WRAP static Ptr<Tracker> create( const String& trackerType );
+ CV_WRAP bool update( InputArray image, CV_OUT Rect2d& boundingBox );
virtual void read( const FileNode& fn )=0;
virtual void write( FileStorage& fs ) const=0;
- Ptr<TrackerModel> getModel()
- {
- return model;
- }
-
protected:
virtual bool initImpl( const Mat& image, const Rect2d& boundingBox ) = 0;
@@ -1083,7 +1062,7 @@ based on @cite MIL .
Original code can be found here <http://vision.ucsd.edu/~bbabenko/project_miltrack.shtml>
*/
-class CV_EXPORTS TrackerMIL : public Tracker
+class CV_EXPORTS_W TrackerMIL : public Tracker
{
public:
struct CV_EXPORTS Params
@@ -1105,7 +1084,11 @@ class CV_EXPORTS TrackerMIL : public Tracker
/** @brief Constructor
@param parameters MIL parameters TrackerMIL::Params
*/
- BOILERPLATE_CODE("MIL",TrackerMIL);
+ static Ptr<TrackerMIL> create(const TrackerMIL::Params ¶meters);
+
+ CV_WRAP static Ptr<TrackerMIL> create();
+
+ virtual ~TrackerMIL() {}
};
/** @brief This is a real-time object tracking based on a novel on-line version of the AdaBoost algorithm.
@@ -1113,7 +1096,7 @@ class CV_EXPORTS TrackerMIL : public Tracker
The classifier uses the surrounding background as negative examples in update step to avoid the
drifting problem. The implementation is based on @cite OLB .
*/
-class CV_EXPORTS TrackerBoosting : public Tracker
+class CV_EXPORTS_W TrackerBoosting : public Tracker
{
public:
struct CV_EXPORTS Params
@@ -1138,7 +1121,11 @@ class CV_EXPORTS TrackerBoosting : public Tracker
/** @brief Constructor
@param parameters BOOSTING parameters TrackerBoosting::Params
*/
- BOILERPLATE_CODE("BOOSTING",TrackerBoosting);
+ static Ptr<TrackerBoosting> create(const TrackerBoosting::Params ¶meters);
+
+ CV_WRAP static Ptr<TrackerBoosting> create();
+
+ virtual ~TrackerBoosting() {}
};
/** @brief Median Flow tracker implementation.
@@ -1151,14 +1138,21 @@ by authors to outperform MIL). During the implementation period the code at
<http://www.aonsquared.co.uk/node/5>, the courtesy of the author Arthur Amarra, was used for the
reference purpose.
*/
-class CV_EXPORTS TrackerMedianFlow : public Tracker
+class CV_EXPORTS_W TrackerMedianFlow : public Tracker
{
public:
struct CV_EXPORTS Params
{
- Params();
- int pointsInGrid; //!<square root of number of keypoints used; increase it to trade
- //!<accurateness for speed; default value is sensible and recommended
+ Params(); //!<default constructor
+ //!<note that the default values of parameters are recommended for most of use cases
+ int pointsInGrid; //!<square root of number of keypoints used; increase it to trade
+ //!<accurateness for speed
+ cv::Size winSize; //!<window size parameter for Lucas-Kanade optical flow
+ int maxLevel; //!<maximal pyramid level number for Lucas-Kanade optical flow
+ TermCriteria termCriteria; //!<termination criteria for Lucas-Kanade optical flow
+ cv::Size winSizeNCC; //!<window size around a point for normalized cross-correlation check
+ double maxMedianLengthOfDisplacementDifference; //!<criterion for loosing the tracked object
+
void read( const FileNode& /*fn*/ );
void write( FileStorage& /*fs*/ ) const;
};
@@ -1166,7 +1160,11 @@ class CV_EXPORTS TrackerMedianFlow : public Tracker
/** @brief Constructor
@param parameters Median Flow parameters TrackerMedianFlow::Params
*/
- BOILERPLATE_CODE("MEDIANFLOW",TrackerMedianFlow);
+ static Ptr<TrackerMedianFlow> create(const TrackerMedianFlow::Params ¶meters);
+
+ CV_WRAP static Ptr<TrackerMedianFlow> create();
+
+ virtual ~TrackerMedianFlow() {}
};
/** @brief TLD is a novel tracking framework that explicitly decomposes the long-term tracking task into
@@ -1180,7 +1178,7 @@ The Median Flow algorithm (see cv::TrackerMedianFlow) was chosen as a tracking c
implementation, following authors. Tracker is supposed to be able to handle rapid motions, partial
occlusions, object absence etc.
*/
-class CV_EXPORTS TrackerTLD : public Tracker
+class CV_EXPORTS_W TrackerTLD : public Tracker
{
public:
struct CV_EXPORTS Params
@@ -1193,7 +1191,11 @@ class CV_EXPORTS TrackerTLD : public Tracker
/** @brief Constructor
@param parameters TLD parameters TrackerTLD::Params
*/
- BOILERPLATE_CODE("TLD",TrackerTLD);
+ static Ptr<TrackerTLD> create(const TrackerTLD::Params ¶meters);
+
+ CV_WRAP static Ptr<TrackerTLD> create();
+
+ virtual ~TrackerTLD() {}
};
/** @brief KCF is a novel tracking framework that utilizes properties of circulant matrix to enhance the processing speed.
@@ -1202,7 +1204,7 @@ class CV_EXPORTS TrackerTLD : public Tracker
* as well as the matlab implementation. For more information about KCF with color-names features, please refer to
* <http://www.cvl.isy.liu.se/research/objrec/visualtracking/colvistrack/index.html>.
*/
-class CV_EXPORTS TrackerKCF : public Tracker
+class CV_EXPORTS_W TrackerKCF : public Tracker
{
public:
/**
@@ -1212,9 +1214,9 @@ public:
- "CN" -- Color-names feature
*/
enum MODE {
- GRAY = (1u << 0),
- CN = (1u << 1),
- CUSTOM = (1u << 2)
+ GRAY = (1 << 0),
+ CN = (1 << 1),
+ CUSTOM = (1 << 2)
};
struct CV_EXPORTS Params
@@ -1234,6 +1236,7 @@ public:
*/
void write(FileStorage& /*fs*/) const;
+ double detect_thresh; //!< detection confidence threshold
double sigma; //!< gaussian kernel bandwidth
double lambda; //!< regularization
double interp_factor; //!< linear interpolation factor for adaptation
@@ -1245,16 +1248,20 @@ public:
bool compress_feature; //!< activate the pca method to compress the features
int max_patch_size; //!< threshold for the ROI size
int compressed_size; //!< feature size after compression
- unsigned int desc_pca; //!< compressed descriptors of TrackerKCF::MODE
- unsigned int desc_npca; //!< non-compressed descriptors of TrackerKCF::MODE
+ int desc_pca; //!< compressed descriptors of TrackerKCF::MODE
+ int desc_npca; //!< non-compressed descriptors of TrackerKCF::MODE
};
- virtual void setFeatureExtractor(void(*)(const Mat, const Rect, Mat&), bool pca_func = false);
+ virtual void setFeatureExtractor(void(*)(const Mat, const Rect, Mat&), bool pca_func = false) = 0;
/** @brief Constructor
@param parameters KCF parameters TrackerKCF::Params
*/
- BOILERPLATE_CODE("KCF", TrackerKCF);
+ static Ptr<TrackerKCF> create(const TrackerKCF::Params ¶meters);
+
+ CV_WRAP static Ptr<TrackerKCF> create();
+
+ virtual ~TrackerKCF() {}
};
/** @brief GOTURN (@cite GOTURN) is kind of trackers based on Convolutional Neural Networks (CNN). While taking all advantages of CNN trackers,
@@ -1270,7 +1277,7 @@ public:
* <https://github.com/Auron-X/GOTURN_Training_Toolkit>
* GOTURN architecture goturn.prototxt and trained model goturn.caffemodel are accessible on opencv_extra GitHub repository.
*/
-class CV_EXPORTS TrackerGOTURN : public Tracker
+class CV_EXPORTS_W TrackerGOTURN : public Tracker
{
public:
struct CV_EXPORTS Params
@@ -1283,7 +1290,11 @@ public:
/** @brief Constructor
@param parameters GOTURN parameters TrackerGOTURN::Params
*/
- BOILERPLATE_CODE("GOTURN", TrackerGOTURN);
+ static Ptr<TrackerGOTURN> create(const TrackerGOTURN::Params ¶meters);
+
+ CV_WRAP static Ptr<TrackerGOTURN> create();
+
+ virtual ~TrackerGOTURN() {}
};
/************************************ MultiTracker Class ---By Laksono Kurnianggoro---) ************************************/
@@ -1291,16 +1302,14 @@ public:
* The MultiTracker is naive implementation of multiple object tracking.
* It process the tracked objects independently without any optimization accross the tracked objects.
*/
-class CV_EXPORTS_W MultiTracker
+class CV_EXPORTS_W MultiTracker : public Algorithm
{
public:
/**
* \brief Constructor.
- * In the case of trackerType is given, it will be set as the default algorithm for all trackers.
- * @param trackerType the name of the tracker algorithm to be used
*/
- CV_WRAP MultiTracker(const String& trackerType = "");
+ CV_WRAP MultiTracker();
/**
* \brief Destructor
@@ -1309,96 +1318,53 @@ public:
/**
* \brief Add a new object to be tracked.
- * The defaultAlgorithm will be used the newly added tracker.
+ *
+ * @param newTracker tracking algorithm to be used
* @param image input image
* @param boundingBox a rectangle represents ROI of the tracked object
*/
- CV_WRAP bool add(const Mat& image, const Rect2d& boundingBox);
-
- /**
- * \brief Add a new object to be tracked.
- * @param trackerType the name of the tracker algorithm to be used
- * @param image input image
- * @param boundingBox a rectangle represents ROI of the tracked object
- */
- CV_WRAP bool add(const String& trackerType, const Mat& image, const Rect2d& boundingBox);
+ CV_WRAP bool add(Ptr<Tracker> newTracker, InputArray image, const Rect2d& boundingBox);
/**
* \brief Add a set of objects to be tracked.
- * @param trackerType the name of the tracker algorithm to be used
+ * @param newTrackers list of tracking algorithms to be used
* @param image input image
* @param boundingBox list of the tracked objects
*/
- CV_WRAP bool add(const String& trackerType, const Mat& image, std::vector<Rect2d> boundingBox);
+ bool add(std::vector<Ptr<Tracker> > newTrackers, InputArray image, std::vector<Rect2d> boundingBox);
/**
- * \brief Add a set of objects to be tracked using the defaultAlgorithm tracker.
+ * \brief Update the current tracking status.
+ * The result will be saved in the internal storage.
* @param image input image
- * @param boundingBox list of the tracked objects
*/
- CV_WRAP bool add(const Mat& image, std::vector<Rect2d> boundingBox);
+ bool update(InputArray image);
/**
* \brief Update the current tracking status.
- * The result will be saved in the internal storage.
* @param image input image
+ * @param boundingBox the tracking result, represent a list of ROIs of the tracked objects.
*/
- bool update(const Mat& image);
+ CV_WRAP bool update(InputArray image, CV_OUT std::vector<Rect2d> & boundingBox);
- //!< storage for the tracked objects, each object corresponds to one tracker algorithm.
- std::vector<Rect2d> objects;
+ /**
+ * \brief Returns a reference to a storage for the tracked objects, each object corresponds to one tracker algorithm
+ */
+ CV_WRAP const std::vector<Rect2d>& getObjects() const;
/**
- * \brief Update the current tracking status.
- * @param image input image
- * @param boundingBox the tracking result, represent a list of ROIs of the tracked objects.
+ * \brief Returns a pointer to a new instance of MultiTracker
*/
- CV_WRAP bool update(const Mat& image, CV_OUT std::vector<Rect2d> & boundingBox);
+ CV_WRAP static Ptr<MultiTracker> create();
protected:
//!< storage for the tracker algorithms.
std::vector< Ptr<Tracker> > trackerList;
- //!< default algorithm for the tracking method.
- String defaultAlgorithm;
-};
-
-class ROISelector {
-public:
- Rect2d select(Mat img, bool fromCenter = true);
- Rect2d select(const cv::String& windowName, Mat img, bool showCrossair = true, bool fromCenter = true);
- void select(const cv::String& windowName, Mat img, std::vector<Rect2d> & boundingBox, bool fromCenter = true);
-
- struct handlerT{
- // basic parameters
- bool isDrawing;
- Rect2d box;
- Mat image;
-
- // parameters for drawing from the center
- bool drawFromCenter;
- Point2f center;
-
- // initializer list
- handlerT() : isDrawing(false), drawFromCenter(true) {};
- }selectorParams;
-
- // to store the tracked objects
- std::vector<handlerT> objects;
-
-private:
- static void mouseHandler(int event, int x, int y, int flags, void *param);
- void opencv_mouse_callback(int event, int x, int y, int, void *param);
-
- // save the keypressed characted
- int key;
+ //!< storage for the tracked objects, each object corresponds to one tracker algorithm.
+ std::vector<Rect2d> objects;
};
-Rect2d CV_EXPORTS_W selectROI(Mat img, bool fromCenter = true);
-Rect2d CV_EXPORTS_W selectROI(const cv::String& windowName, Mat img, bool showCrossair = true, bool fromCenter = true);
-void CV_EXPORTS_W selectROI(const cv::String& windowName, Mat img, std::vector<Rect2d> & boundingBox, bool fromCenter = true);
-
-
/************************************ Multi-Tracker Classes ---By Tyan Vladimir---************************************/
/** @brief Base abstract class for the long-term Multi Object Trackers:
@@ -1418,11 +1384,11 @@ public:
/** @brief Add a new target to a tracking-list and initialize the tracker with a know bounding box that surrounding the target
@param image The initial frame
@param boundingBox The initial boundig box of target
- @param tracker_algorithm_name Multi-tracker algorithm name
+ @param tracker_algorithm Multi-tracker algorithm
@return True if new target initialization went succesfully, false otherwise
*/
- bool addTarget(const Mat& image, const Rect2d& boundingBox, String tracker_algorithm_name);
+ bool addTarget(InputArray image, const Rect2d& boundingBox, Ptr<Tracker> tracker_algorithm);
/** @brief Update all trackers from the tracking-list, find a new most likely bounding boxes for the targets
@param image The current frame
@@ -1431,7 +1397,7 @@ public:
current frame. Note, that latter *does not* imply that tracker has failed, maybe target is indeed
missing from the frame (say, out of sight)
*/
- bool update(const Mat& image);
+ bool update(InputArray image);
/** @brief Current number of targets in tracking-list
*/
@@ -1475,7 +1441,7 @@ public:
current frame. Note, that latter *does not* imply that tracker has failed, maybe target is indeed
missing from the frame (say, out of sight)
*/
- bool update_opt(const Mat& image);
+ bool update_opt(InputArray image);
};
//! @}
diff --git a/contrib/modules/tracking/perf/perf_Tracker.cpp b/contrib/modules/tracking/perf/perf_Tracker.cpp
index 0a3d96f..e64b506 100644
--- a/contrib/modules/tracking/perf/perf_Tracker.cpp
+++ b/contrib/modules/tracking/perf/perf_Tracker.cpp
@@ -155,7 +155,7 @@ PERF_TEST_P(tracking, mil, testing::Combine(TESTSET_NAMES, SEGMENTS))
bool initialized = false;
vector<Rect> bbs;
- Ptr<Tracker> tracker = Tracker::create( "MIL" );
+ Ptr<Tracker> tracker = TrackerMIL::create();
string folder = TRACKING_DIR + "/" + video + "/" + FOLDER_IMG;
int numSegments = ( sizeof ( SEGMENTS)/sizeof(int) );
int endFrame = 0;
@@ -226,7 +226,7 @@ PERF_TEST_P(tracking, boosting, testing::Combine(TESTSET_NAMES, SEGMENTS))
bool initialized = false;
vector<Rect> bbs;
- Ptr<Tracker> tracker = Tracker::create( "BOOSTING" );
+ Ptr<Tracker> tracker = TrackerBoosting::create();
string folder = TRACKING_DIR + "/" + video + "/" + FOLDER_IMG;
int numSegments = ( sizeof ( SEGMENTS)/sizeof(int) );
int endFrame = 0;
@@ -296,7 +296,7 @@ PERF_TEST_P(tracking, tld, testing::Combine(TESTSET_NAMES, SEGMENTS))
bool initialized = false;
vector<Rect> bbs;
- Ptr<Tracker> tracker = Tracker::create( "TLD" );
+ Ptr<Tracker> tracker = TrackerTLD::create();
string folder = TRACKING_DIR + "/" + video + "/" + FOLDER_IMG;
int numSegments = ( sizeof ( SEGMENTS)/sizeof(int) );
int endFrame = 0;
@@ -366,7 +366,7 @@ PERF_TEST_P(tracking, GOTURN, testing::Combine(TESTSET_NAMES, SEGMENTS))
bool initialized = false;
vector<Rect> bbs;
- Ptr<Tracker> tracker = Tracker::create("GOTURN");
+ Ptr<Tracker> tracker = TrackerGOTURN::create();
string folder = TRACKING_DIR + "/" + video + "/" + FOLDER_IMG;
int numSegments = (sizeof(SEGMENTS) / sizeof(int));
int endFrame = 0;
diff --git a/contrib/modules/tracking/samples/benchmark.cpp b/contrib/modules/tracking/samples/benchmark.cpp
index 16e4956..5616829 100644
--- a/contrib/modules/tracking/samples/benchmark.cpp
+++ b/contrib/modules/tracking/samples/benchmark.cpp
@@ -3,6 +3,7 @@
#include "opencv2/tracking.hpp"
#include "opencv2/videoio.hpp"
#include "opencv2/plot.hpp"
+#include "samples_utility.hpp"
#include <fstream>
#include <iomanip>
#include <iostream>
@@ -75,10 +76,11 @@ const int LTRC_COUNT = 100;
struct AlgoWrap
{
AlgoWrap(const string &name_)
- : tracker(Tracker::create(name_)), lastState(NotFound), name(name_), color(getNextColor()),
+ : lastState(NotFound), name(name_), color(getNextColor()),
numTotal(0), numResponse(0), numPresent(0), numCorrect_0(0), numCorrect_0_5(0),
timeTotal(0), auc(LTRC_COUNT + 1, 0)
{
+ tracker = createTrackerByName(name);
}
enum State
diff --git a/contrib/modules/tracking/samples/goturnTracker.cpp b/contrib/modules/tracking/samples/goturnTracker.cpp
index 389771e..bce8ded 100644
--- a/contrib/modules/tracking/samples/goturnTracker.cpp
+++ b/contrib/modules/tracking/samples/goturnTracker.cpp
@@ -45,6 +45,9 @@
//1 - Train you own GOTURN model using <https://github.com/Auron-X/GOTURN_Training_Toolkit>
//2 - Download pretrained caffemodel from <https://github.com/opencv/opencv_extra>
+#include "opencv2/opencv_modules.hpp"
+#if defined(HAVE_OPENCV_DNN) && defined(HAVE_OPENCV_DATASETS)
+
#include "opencv2/datasets/track_alov.hpp"
#include <opencv2/core/utility.hpp>
#include <opencv2/tracking.hpp>
@@ -65,8 +68,8 @@ static bool startSelection = false;
Rect2d boundingBox;
static const char* keys =
-{ "{@dataset_path |true| Dataset path }"
-"{@dataset_id |1| Dataset ID }"
+{ "{@dataset_path || Dataset path }"
+ "{@dataset_id |1| Dataset ID }"
};
static void onMouse(int event, int x, int y, int, void*)
@@ -137,16 +140,21 @@ int main(int argc, char *argv[])
setMouseCallback("GOTURN Tracking", onMouse, 0);
//Create GOTURN tracker
- Ptr<Tracker> tracker = Tracker::create("GOTURN");
+ Ptr<Tracker> tracker = TrackerGOTURN::create();
//Load and init full ALOV300++ dataset with a given datasetID, as alternative you can use loadAnnotatedOnly(..)
//to load only frames with labled ground truth ~ every 5-th frame
Ptr<cv::datasets::TRACK_alov> dataset = TRACK_alov::create();
dataset->load(datasetRootPath);
dataset->initDataset(datasetID);
-
//Read first frame
dataset->getNextFrame(frame);
+ if (frame.empty())
+ {
+ cout << "invalid dataset: " << datasetRootPath << endl;
+ return -2;
+ }
+
frame.copyTo(image);
rectangle(image, boundingBox, Scalar(255, 0, 0), 2, 1);
imshow("GOTURN Tracking", image);
@@ -215,3 +223,11 @@ int main(int argc, char *argv[])
return 0;
}
+
+#else // ! HAVE_OPENCV_DNN && HAVE_OPENCV_DATASETS
+#include <opencv2/core.hpp>
+int main() {
+ CV_Error(cv::Error::StsNotImplemented , "this sample needs to be built with opencv_datasets and opencv_dnn !");
+ return -1;
+}
+#endif
diff --git a/contrib/modules/tracking/samples/kcf.cpp b/contrib/modules/tracking/samples/kcf.cpp
index 3aad38e..f40a3c5 100644
--- a/contrib/modules/tracking/samples/kcf.cpp
+++ b/contrib/modules/tracking/samples/kcf.cpp
@@ -13,29 +13,11 @@
#include <opencv2/highgui.hpp>
#include <iostream>
#include <cstring>
+#include "samples_utility.hpp"
using namespace std;
using namespace cv;
-class BoxExtractor {
-public:
- Rect2d extract(Mat img);
- Rect2d extract(const std::string& windowName, Mat img, bool showCrossair = true);
-
- struct handlerT{
- bool isDrawing;
- Rect2d box;
- Mat image;
-
- // initializer list
- handlerT(): isDrawing(false) {};
- }params;
-
-private:
- static void mouseHandler(int event, int x, int y, int flags, void *param);
- void opencv_mouse_callback( int event, int x, int y, int , void *param );
-};
-
int main( int argc, char** argv ){
// show help
if(argc<2){
@@ -48,11 +30,8 @@ int main( int argc, char** argv ){
return 0;
}
- // ROI selector
- BoxExtractor box;
-
// create the tracker
- Ptr<Tracker> tracker = Tracker::create( "KCF" );
+ Ptr<Tracker> tracker = TrackerKCF::create();
// set input video
std::string video = argv[1];
@@ -62,7 +41,7 @@ int main( int argc, char** argv ){
// get bounding box
cap >> frame;
- Rect2d roi=box.extract("tracker",frame);
+ Rect2d roi= selectROI("tracker", frame, true, false);
//quit if ROI was not selected
if(roi.width==0 || roi.height==0)
@@ -82,7 +61,13 @@ int main( int argc, char** argv ){
break;
// update the tracking result
- tracker->update(frame,roi);
+ bool isfound = tracker->update(frame,roi);
+ if(!isfound)
+ {
+ cout << "The target has been lost...\n";
+ waitKey(0);
+ return 0;
+ }
// draw the tracked object
rectangle( frame, roi, Scalar( 255, 0, 0 ), 2, 1 );
@@ -95,100 +80,3 @@ int main( int argc, char** argv ){
}
}
-
-void BoxExtractor::mouseHandler(int event, int x, int y, int flags, void *param){
- BoxExtractor *self =static_cast<BoxExtractor*>(param);
- self->opencv_mouse_callback(event,x,y,flags,param);
-}
-
-void BoxExtractor::opencv_mouse_callback( int event, int x, int y, int , void *param ){
- handlerT * data = (handlerT*)param;
- switch( event ){
- // update the selected bounding box
- case EVENT_MOUSEMOVE:
- if( data->isDrawing ){
- data->box.width = x-data->box.x;
- data->box.height = y-data->box.y;
- }
- break;
-
- // start to select the bounding box
- case EVENT_LBUTTONDOWN:
- data->isDrawing = true;
- data->box = cvRect( x, y, 0, 0 );
- break;
-
- // cleaning up the selected bounding box
- case EVENT_LBUTTONUP:
- data->isDrawing = false;
- if( data->box.width < 0 ){
- data->box.x += data->box.width;
- data->box.width *= -1;
- }
- if( data->box.height < 0 ){
- data->box.y += data->box.height;
- data->box.height *= -1;
- }
- break;
- }
-}
-
-Rect2d BoxExtractor::extract(Mat img){
- return extract("Bounding Box Extractor", img);
-}
-
-Rect2d BoxExtractor::extract(const std::string& windowName, Mat img, bool showCrossair){
-
- int key=0;
-
- // show the image and give feedback to user
- imshow(windowName,img);
- printf("Select an object to track and then press SPACE/BACKSPACE/ENTER button!\n");
-
- // copy the data, rectangle should be drawn in the fresh image
- params.image=img.clone();
-
- // select the object
- setMouseCallback( windowName, mouseHandler, (void *)¶ms );
-
- // end selection process on SPACE (32) BACKSPACE (27) or ENTER (13)
- while(!(key==32 || key==27 || key==13)){
- // draw the selected object
- rectangle(
- params.image,
- params.box,
- Scalar(255,0,0),2,1
- );
-
- // draw cross air in the middle of bounding box
- if(showCrossair){
- // horizontal line
- line(
- params.image,
- Point((int)params.box.x,(int)(params.box.y+params.box.height/2)),
- Point((int)(params.box.x+params.box.width),(int)(params.box.y+params.box.height/2)),
- Scalar(255,0,0),2,1
- );
-
- // vertical line
- line(
- params.image,
- Point((int)(params.box.x+params.box.width/2),(int)params.box.y),
- Point((int)(params.box.x+params.box.width/2),(int)(params.box.y+params.box.height)),
- Scalar(255,0,0),2,1
- );
- }
-
- // show the image bouding box
- imshow(windowName,params.image);
-
- // reset the image
- params.image=img.clone();
-
- //get keyboard event
- key=waitKey(1);
- }
-
-
- return params.box;
-}
diff --git a/contrib/modules/tracking/samples/multiTracker_dataset.cpp b/contrib/modules/tracking/samples/multiTracker_dataset.cpp
index 2826b19..622a69a 100644
--- a/contrib/modules/tracking/samples/multiTracker_dataset.cpp
+++ b/contrib/modules/tracking/samples/multiTracker_dataset.cpp
@@ -48,6 +48,7 @@
#include <opencv2/tracking.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
+#include "samples_utility.hpp"
#include <iostream>
using namespace std;
@@ -184,7 +185,7 @@ int main(int argc, char *argv[])
//Initialize the tracker and add targets
for (int i = 0; i < (int)boundingBoxes.size(); i++)
{
- if (!mt.addTarget(frame, boundingBoxes[i], tracker_algorithm))
+ if (!mt.addTarget(frame, boundingBoxes[i], createTrackerByName(tracker_algorithm)))
{
cout << "Trackers Init Error!!!";
return 0;
@@ -234,6 +235,7 @@ int main(int argc, char *argv[])
}
#else // ! HAVE_OPENCV_DATASETS
+#include <opencv2/core.hpp>
int main() {
CV_Error(cv::Error::StsNotImplemented , "this sample needs to be built with opencv_datasets !");
return -1;
diff --git a/contrib/modules/tracking/samples/multitracker.cpp b/contrib/modules/tracking/samples/multitracker.cpp
index fe6bdf9..b1481d9 100644
--- a/contrib/modules/tracking/samples/multitracker.cpp
+++ b/contrib/modules/tracking/samples/multitracker.cpp
@@ -24,6 +24,7 @@
#include <iostream>
#include <cstring>
#include <ctime>
+#include "samples_utility.hpp"
#ifdef HAVE_OPENCV
#include <opencv2/flann.hpp>
@@ -61,38 +62,46 @@ int main( int argc, char** argv ){
// for showing the speed
double fps;
- std::string text;
+ String text;
char buffer [50];
// set the default tracking algorithm
- std::string trackingAlg = "KCF";
+ String trackingAlg = "KCF";
// set the tracking algorithm from parameter
if(argc>2)
trackingAlg = argv[2];
// create the tracker
- MultiTracker trackers(trackingAlg);
+ MultiTracker trackers;
// container of the tracked objects
+ vector<Rect> ROIs;
vector<Rect2d> objects;
// set input video
- std::string video = argv[1];
+ String video = argv[1];
VideoCapture cap(video);
Mat frame;
// get bounding box
cap >> frame;
- selectROI("tracker",frame,objects);
+ selectROIs("tracker",frame,ROIs);
//quit when the tracked object(s) is not provided
if(objects.size()<1)
return 0;
+ std::vector<Ptr<Tracker> > algorithms;
+ for (size_t i = 0; i < ROIs.size(); i++)
+ {
+ algorithms.push_back(createTrackerByName(trackingAlg));
+ objects.push_back(ROIs[i]);
+ }
+
// initialize the tracker
- trackers.add(frame,objects);
+ trackers.add(algorithms,frame,objects);
// do the tracking
printf(GREEN "Start the tracking process, press ESC to quit.\n" RESET);
@@ -127,8 +136,8 @@ int main( int argc, char** argv ){
#endif
// draw the tracked object
- for(unsigned i=0;i<trackers.objects.size();i++)
- rectangle( frame, trackers.objects[i], Scalar( 255, 0, 0 ), 2, 1 );
+ for(unsigned i=0;i<trackers.getObjects().size();i++)
+ rectangle( frame, trackers.getObjects()[i], Scalar( 255, 0, 0 ), 2, 1 );
// draw the processing speed
sprintf (buffer, "speed: %.0f fps", fps);
diff --git a/contrib/modules/tracking/samples/multitracker.py b/contrib/modules/tracking/samples/multitracker.py
index 59b962e..52cf524 100644
--- a/contrib/modules/tracking/samples/multitracker.py
+++ b/contrib/modules/tracking/samples/multitracker.py
@@ -1,25 +1,37 @@
import numpy as np
import cv2
+import sys
+
+if len(sys.argv) != 2:
+ print('Input video name is missing')
+ exit()
+
+print('Select 3 tracking targets')
cv2.namedWindow("tracking")
-camera = cv2.VideoCapture("E:/code/opencv/samples/data/768x576.avi")
-tracker = cv2.MultiTracker("MIL")
-bbox1 = (638.0,230.0,56.0,101.0)
-bbox2 = (240.0,210.0,60.0,104.0)
-bbox3 = (486.0,149.0,54.0,83.0)
+camera = cv2.VideoCapture(sys.argv[1])
+tracker = cv2.MultiTracker_create()
init_once = False
+ok, image=camera.read()
+if not ok:
+ print('Failed to read video')
+ exit()
+
+bbox1 = cv2.selectROI('tracking', image)
+bbox2 = cv2.selectROI('tracking', image)
+bbox3 = cv2.selectROI('tracking', image)
+
while camera.isOpened():
ok, image=camera.read()
if not ok:
- print 'no image read'
+ print 'no image to read'
break
if not init_once:
- # add a list of boxes:
- ok = tracker.add(image, (bbox1,bbox2))
- # or add single box:
- ok = tracker.add(image, bbox3)
+ ok = tracker.add(cv2.TrackerMIL_create(), image, bbox1)
+ ok = tracker.add(cv2.TrackerMIL_create(), image, bbox2)
+ ok = tracker.add(cv2.TrackerMIL_create(), image, bbox3)
init_once = True
ok, boxes = tracker.update(image)
@@ -30,6 +42,6 @@ while camera.isOpened():
p2 = (int(newbox[0] + newbox[2]), int(newbox[1] + newbox[3]))
cv2.rectangle(image, p1, p2, (200,0,0))
- cv2.imshow("tracking", image)
- k = cv2.waitKey(1) & 0xff
+ cv2.imshow('tracking', image)
+ k = cv2.waitKey(1)
if k == 27 : break # esc pressed
diff --git a/contrib/modules/tracking/samples/samples_utility.hpp b/contrib/modules/tracking/samples/samples_utility.hpp
new file mode 100644
index 0000000..e7b658e
--- /dev/null
+++ b/contrib/modules/tracking/samples/samples_utility.hpp
@@ -0,0 +1,28 @@
+#ifndef _SAMPLES_UTILITY_HPP_
+#define _SAMPLES_UTILITY_HPP_
+
+#include <opencv2/tracking.hpp>
+
+inline cv::Ptr<cv::Tracker> createTrackerByName(cv::String name)
+{
+ cv::Ptr<cv::Tracker> tracker;
+
+ if (name == "KCF")
+ tracker = cv::TrackerKCF::create();
+ else if (name == "TLD")
+ tracker = cv::TrackerTLD::create();
+ else if (name == "BOOSTING")
+ tracker = cv::TrackerBoosting::create();
+ else if (name == "MEDIAN_FLOW")
+ tracker = cv::TrackerMedianFlow::create();
+ else if (name == "MIL")
+ tracker = cv::TrackerMIL::create();
+ else if (name == "GOTURN")
+ tracker = cv::TrackerGOTURN::create();
+ else
+ CV_Error(cv::Error::StsBadArg, "Invalid tracking algorithm name\n");
+
+ return tracker;
+}
+
+#endif
diff --git a/contrib/modules/tracking/samples/tracker.cpp b/contrib/modules/tracking/samples/tracker.cpp
index 3a12959..98d0177 100644
--- a/contrib/modules/tracking/samples/tracker.cpp
+++ b/contrib/modules/tracking/samples/tracker.cpp
@@ -4,56 +4,17 @@
#include <opencv2/highgui.hpp>
#include <iostream>
#include <cstring>
+#include "samples_utility.hpp"
using namespace std;
using namespace cv;
-static Mat image;
-static Rect2d boundingBox;
-static bool paused;
-static bool selectObject = false;
-static bool startSelection = false;
-
static const char* keys =
{ "{@tracker_algorithm | | Tracker algorithm }"
"{@video_name | | video name }"
- "{@start_frame |0| Start frame }"
+ "{@start_frame |0| Start frame }"
"{@bounding_frame |0,0,0,0| Initial bounding frame}"};
-static void onMouse( int event, int x, int y, int, void* )
-{
- if( !selectObject )
- {
- switch ( event )
- {
- case EVENT_LBUTTONDOWN:
- //set origin of the bounding box
- startSelection = true;
- boundingBox.x = x;
- boundingBox.y = y;
- break;
- case EVENT_LBUTTONUP:
- //sei with and height of the bounding box
- boundingBox.width = std::abs( x - boundingBox.x );
- boundingBox.height = std::abs( y - boundingBox.y );
- paused = false;
- selectObject = true;
- break;
- case EVENT_MOUSEMOVE:
-
- if( startSelection && !selectObject )
- {
- //draw the bounding box
- Mat currentFrame;
- image.copyTo( currentFrame );
- rectangle( currentFrame, Point((int) boundingBox.x, (int)boundingBox.y ), Point( x, y ), Scalar( 255, 0, 0 ), 2, 1 );
- imshow( "Tracking API", currentFrame );
- }
- break;
- }
- }
-}
-
static void help()
{
cout << "\nThis example shows the functionality of \"Long-term optical tracking API\""
@@ -124,12 +85,14 @@ int main( int argc, char** argv ){
}
Mat frame;
- paused = true;
namedWindow( "Tracking API", 1 );
- setMouseCallback( "Tracking API", onMouse, 0 );
+
+ Mat image;
+ Rect2d boundingBox;
+ bool paused = false;
//instantiates the specific Tracker
- Ptr<Tracker> tracker = Tracker::create( tracker_algorithm );
+ Ptr<Tracker> tracker = createTrackerByName(tracker_algorithm);
if( tracker == NULL )
{
cout << "***Error in the instantiation of the tracker...***\n";
@@ -140,8 +103,6 @@ int main( int argc, char** argv ){
cap >> frame;
frame.copyTo( image );
if(initBoxWasGivenInCommandLine){
- selectObject=true;
- paused=false;
boundingBox.x = coords[0];
boundingBox.y = coords[1];
boundingBox.width = std::abs( coords[2] - coords[0] );
@@ -149,6 +110,9 @@ int main( int argc, char** argv ){
printf("bounding box with vertices (%d,%d) and (%d,%d) was given in command line\n",coords[0],coords[1],coords[2],coords[3]);
rectangle( image, boundingBox, Scalar( 255, 0, 0 ), 2, 1 );
}
+ else
+ boundingBox = selectROI("Tracking API", image);
+
imshow( "Tracking API", image );
bool initialized = false;
@@ -166,7 +130,7 @@ int main( int argc, char** argv ){
frame.copyTo( image );
}
- if( !initialized && selectObject )
+ if( !initialized )
{
//initializes the tracker
if( !tracker->init( frame, boundingBox ) )
@@ -193,7 +157,6 @@ int main( int argc, char** argv ){
break;
if( c == 'p' )
paused = !paused;
-
}
return 0;
diff --git a/contrib/modules/tracking/samples/tracker.py b/contrib/modules/tracking/samples/tracker.py
index eb86fe6..fdc425d 100644
--- a/contrib/modules/tracking/samples/tracker.py
+++ b/contrib/modules/tracking/samples/tracker.py
@@ -1,16 +1,25 @@
import numpy as np
import cv2
+import sys
+
+if len(sys.argv) != 2:
+ print('Input video name is missing')
+ exit()
cv2.namedWindow("tracking")
-camera = cv2.VideoCapture("E:/code/opencv/samples/data/768x576.avi")
-bbox = (638.0,230.0,56.0,101.0)
-tracker = cv2.Tracker_create("MIL")
+camera = cv2.VideoCapture(sys.argv[1])
+ok, image=camera.read()
+if not ok:
+ print('Failed to read video')
+ exit()
+bbox = cv2.selectROI("tracking", image)
+tracker = cv2.TrackerMIL_create()
init_once = False
while camera.isOpened():
ok, image=camera.read()
if not ok:
- print 'no image read'
+ print 'no image to read'
break
if not init_once:
@@ -27,4 +36,4 @@ while camera.isOpened():
cv2.imshow("tracking", image)
k = cv2.waitKey(1) & 0xff
- if k == 27 : break # esc pressed
\ No newline at end of file
+ if k == 27 : break # esc pressed
diff --git a/contrib/modules/tracking/samples/tracker_dataset.cpp b/contrib/modules/tracking/samples/tracker_dataset.cpp
index 8b7832a..24d3dfc 100644
--- a/contrib/modules/tracking/samples/tracker_dataset.cpp
+++ b/contrib/modules/tracking/samples/tracker_dataset.cpp
@@ -53,6 +53,7 @@
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
+#include "samples_utility.hpp"
#include <iostream>
@@ -143,7 +144,7 @@ int main(int argc, char *argv[])
setMouseCallback("Tracking API", onMouse, 0);
//Create Tracker
- Ptr<Tracker> tracker = Tracker::create(tracker_algorithm);
+ Ptr<Tracker> tracker = createTrackerByName(tracker_algorithm);
if (tracker == NULL)
{
cout << "***Error in the instantiation of the tracker...***\n";
@@ -234,6 +235,7 @@ int main(int argc, char *argv[])
#else // ! HAVE_OPENCV_DATASETS
+#include <opencv2/core.hpp>
int main() {
CV_Error(cv::Error::StsNotImplemented , "this sample needs to be built with opencv_datasets !");
return -1;
diff --git a/contrib/modules/tracking/samples/tutorial_customizing_cn_tracker.cpp b/contrib/modules/tracking/samples/tutorial_customizing_cn_tracker.cpp
index 3131be3..14259df 100644
--- a/contrib/modules/tracking/samples/tutorial_customizing_cn_tracker.cpp
+++ b/contrib/modules/tracking/samples/tutorial_customizing_cn_tracker.cpp
@@ -4,6 +4,7 @@
#include <opencv2/highgui.hpp>
#include <iostream>
#include <cstring>
+#include "samples_utility.hpp"
using namespace std;
using namespace cv;
@@ -37,7 +38,7 @@ int main( int argc, char** argv ){
// create a tracker object
//! [create]
- Ptr<TrackerKCF> tracker = TrackerKCF::createTracker(param);
+ Ptr<TrackerKCF> tracker = TrackerKCF::create(param);
//! [create]
//! [setextractor]
diff --git a/contrib/modules/tracking/samples/tutorial_introduction_to_tracker.cpp b/contrib/modules/tracking/samples/tutorial_introduction_to_tracker.cpp
index d9907fa..e092c7d 100644
--- a/contrib/modules/tracking/samples/tutorial_introduction_to_tracker.cpp
+++ b/contrib/modules/tracking/samples/tutorial_introduction_to_tracker.cpp
@@ -30,7 +30,7 @@ int main( int argc, char** argv ){
// create a tracker object
//! [create]
- Ptr<Tracker> tracker = Tracker::create( "KCF" );
+ Ptr<Tracker> tracker = TrackerKCF::create();
//! [create]
// set input video
diff --git a/contrib/modules/tracking/samples/tutorial_multitracker.cpp b/contrib/modules/tracking/samples/tutorial_multitracker.cpp
index 0d14c20..0c6e9b3 100644
--- a/contrib/modules/tracking/samples/tutorial_multitracker.cpp
+++ b/contrib/modules/tracking/samples/tutorial_multitracker.cpp
@@ -14,6 +14,7 @@
#include <iostream>
#include <cstring>
#include <ctime>
+#include "samples_utility.hpp"
using namespace std;
using namespace cv;
@@ -39,7 +40,7 @@ int main( int argc, char** argv ){
// create the tracker
//! [create]
- MultiTracker trackers(trackingAlg);
+ MultiTracker trackers;
//! [create]
// container of the tracked objects
@@ -56,7 +57,8 @@ int main( int argc, char** argv ){
// get bounding box
cap >> frame;
//! [selectmulti]
- selectROI("tracker",frame,objects);
+ vector<Rect> ROIs;
+ selectROIs("tracker",frame,ROIs);
//! [selectmulti]
//quit when the tracked object(s) is not provided
@@ -65,7 +67,14 @@ int main( int argc, char** argv ){
// initialize the tracker
//! [init]
- trackers.add(frame,objects);
+ std::vector<Ptr<Tracker> > algorithms;
+ for (size_t i = 0; i < objects.size(); i++)
+ {
+ algorithms.push_back(createTrackerByName(trackingAlg));
+ objects.push_back(ROIs[i]);
+ }
+
+ trackers.add(algorithms,frame,objects);
//! [init]
// do the tracking
@@ -85,8 +94,8 @@ int main( int argc, char** argv ){
//! [result]
// draw the tracked object
- for(unsigned i=0;i<trackers.objects.size();i++)
- rectangle( frame, trackers.objects[i], Scalar( 255, 0, 0 ), 2, 1 );
+ for(unsigned i=0;i<trackers.getObjects().size();i++)
+ rectangle( frame, trackers.getObjects()[i], Scalar( 255, 0, 0 ), 2, 1 );
//! [result]
// show image with the tracked object
diff --git a/contrib/modules/tracking/src/gtrTracker.cpp b/contrib/modules/tracking/src/gtrTracker.cpp
index 58debfd..1d9e061 100644
--- a/contrib/modules/tracking/src/gtrTracker.cpp
+++ b/contrib/modules/tracking/src/gtrTracker.cpp
@@ -38,7 +38,7 @@
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
-
+#include "opencv2/opencv_modules.hpp"
#include "gtrTracker.hpp"
@@ -52,11 +52,22 @@ void TrackerGOTURN::Params::read(const cv::FileNode& /*fn*/){}
void TrackerGOTURN::Params::write(cv::FileStorage& /*fs*/) const {}
-Ptr<TrackerGOTURN> TrackerGOTURN::createTracker(const TrackerGOTURN::Params ¶meters)
+Ptr<TrackerGOTURN> TrackerGOTURN::create(const TrackerGOTURN::Params ¶meters)
{
+#ifdef HAVE_OPENCV_DNN
return Ptr<gtr::TrackerGOTURNImpl>(new gtr::TrackerGOTURNImpl(parameters));
+#else
+ (void)(parameters);
+ CV_ErrorNoReturn(cv::Error::StsNotImplemented , "to use GOTURN, the tracking module needs to be built with opencv_dnn !");
+#endif
+}
+Ptr<TrackerGOTURN> TrackerGOTURN::create()
+{
+ return TrackerGOTURN::create(TrackerGOTURN::Params());
}
+
+#ifdef HAVE_OPENCV_DNN
namespace gtr
{
@@ -158,19 +169,13 @@ bool TrackerGOTURNImpl::updateImpl(const Mat& image, Rect2d& boundingBox)
searchPatch = searchPatch - 128;
//Convert to Float type
- targetPatch.convertTo(targetPatch, CV_32F);
- searchPatch.convertTo(searchPatch, CV_32F);
+ Mat targetBlob = dnn::blobFromImage(targetPatch);
+ Mat searchBlob = dnn::blobFromImage(searchPatch);
- dnn::Blob targetBlob = dnn::Blob(targetPatch);
- dnn::Blob searchBlob = dnn::Blob(searchPatch);
+ net.setInput(targetBlob, ".data1");
+ net.setInput(searchBlob, ".data2");
- net.setBlob(".data1", targetBlob);
- net.setBlob(".data2", searchBlob);
-
- net.forward();
- dnn::Blob res = net.getBlob("scale");
-
- Mat resMat = res.matRefConst().reshape(1, 1);
+ Mat resMat = net.forward("scale").reshape(1, 1);
curBB.x = targetPatchRect.x + (resMat.at<float>(0) * targetPatchRect.width / INPUT_SIZE) - targetPatchRect.width;
curBB.y = targetPatchRect.y + (resMat.at<float>(1) * targetPatchRect.height / INPUT_SIZE) - targetPatchRect.height;
@@ -183,9 +188,11 @@ bool TrackerGOTURNImpl::updateImpl(const Mat& image, Rect2d& boundingBox)
//Set new model image and BB from current frame
((TrackerGOTURNModel*)static_cast<TrackerModel*>(model))->setImage(curFrame);
((TrackerGOTURNModel*)static_cast<TrackerModel*>(model))->setBoudingBox(curBB);
+
return true;
}
}
+#endif // OPENCV_HAVE_DNN
}
diff --git a/contrib/modules/tracking/src/gtrTracker.hpp b/contrib/modules/tracking/src/gtrTracker.hpp
index 34f2c48..21ae3d9 100644
--- a/contrib/modules/tracking/src/gtrTracker.hpp
+++ b/contrib/modules/tracking/src/gtrTracker.hpp
@@ -45,11 +45,15 @@
#include "precomp.hpp"
#include "opencv2/video/tracking.hpp"
-#include "opencv2/dnn.hpp"
#include "gtrUtils.hpp"
#include "opencv2/imgproc.hpp"
-#include<algorithm>
-#include<limits.h>
+
+#include <algorithm>
+#include <limits.h>
+
+#include "opencv2/opencv_modules.hpp"
+#ifdef HAVE_OPENCV_DNN
+#include "opencv2/dnn.hpp"
namespace cv
{
@@ -72,5 +76,5 @@ public:
}
}
-
+#endif
#endif
diff --git a/contrib/modules/tracking/src/gtrUtils.cpp b/contrib/modules/tracking/src/gtrUtils.cpp
index 0df1197..e80dda1 100644
--- a/contrib/modules/tracking/src/gtrUtils.cpp
+++ b/contrib/modules/tracking/src/gtrUtils.cpp
@@ -58,7 +58,7 @@ double generateRandomLaplacian(double b, double m)
return m - b*log(n);
}
-Rect2f anno2rect(vector<Point2f> annoBB)
+Rect2f anno2rect(std::vector<Point2f> annoBB)
{
Rect2f rectBB;
rectBB.x = min(annoBB[0].x, annoBB[1].x);
@@ -69,9 +69,9 @@ Rect2f anno2rect(vector<Point2f> annoBB)
return rectBB;
}
-vector <TrainingSample> gatherFrameSamples(Mat prevFrame, Mat currFrame, Rect2f prevBB, Rect2f currBB)
+std::vector <TrainingSample> gatherFrameSamples(Mat prevFrame, Mat currFrame, Rect2f prevBB, Rect2f currBB)
{
- vector <TrainingSample> trainingSamples;
+ std::vector <TrainingSample> trainingSamples;
Point2f currCenter, prevCenter;
Rect2f targetPatchRect, searchPatchRect;
Mat targetPatch, searchPatch;
diff --git a/contrib/modules/tracking/src/gtrUtils.hpp b/contrib/modules/tracking/src/gtrUtils.hpp
index 8f388be..fedf26f 100644
--- a/contrib/modules/tracking/src/gtrUtils.hpp
+++ b/contrib/modules/tracking/src/gtrUtils.hpp
@@ -3,8 +3,6 @@
#include "precomp.hpp"
#include <vector>
-#include "opencv2/highgui.hpp"
-#include <opencv2/datasets/track_alov.hpp>
namespace cv
{
@@ -50,10 +48,10 @@ struct TrainingSample
double generateRandomLaplacian(double b, double m);
//Convert ALOV300++ anno coordinates to Rectangle BB
-Rect2f anno2rect(vector<Point2f> annoBB);
+Rect2f anno2rect(std::vector<Point2f> annoBB);
//Gather samples from random video frame
-vector <TrainingSample> gatherFrameSamples(Mat prevFrame, Mat currFrame, Rect2f prevBB, Rect2f currBB);
+std::vector <TrainingSample> gatherFrameSamples(Mat prevFrame, Mat currFrame, Rect2f prevBB, Rect2f currBB);
}
}
diff --git a/contrib/modules/tracking/src/multiTracker.cpp b/contrib/modules/tracking/src/multiTracker.cpp
index 7966061..33b6914 100644
--- a/contrib/modules/tracking/src/multiTracker.cpp
+++ b/contrib/modules/tracking/src/multiTracker.cpp
@@ -44,9 +44,9 @@
namespace cv
{
//Multitracker
- bool MultiTracker_Alt::addTarget(const Mat& image, const Rect2d& boundingBox, String tracker_algorithm_name)
+ bool MultiTracker_Alt::addTarget(InputArray image, const Rect2d& boundingBox, Ptr<Tracker> tracker_algorithm)
{
- Ptr<Tracker> tracker = Tracker::create(tracker_algorithm_name);
+ Ptr<Tracker> tracker = tracker_algorithm;
if (tracker == NULL)
return false;
@@ -73,7 +73,7 @@ namespace cv
return true;
}
- bool MultiTracker_Alt::update(const Mat& image)
+ bool MultiTracker_Alt::update(InputArray image)
{
for (int i = 0; i < (int)trackers.size(); i++)
if (!trackers[i]->update(image, boundingBoxes[i]))
@@ -84,8 +84,9 @@ namespace cv
//Multitracker TLD
/*Optimized update method for TLD Multitracker */
- bool MultiTrackerTLD::update_opt(const Mat& image)
+ bool MultiTrackerTLD::update_opt(InputArray _image)
{
+ Mat image = _image.getMat();
//Get parameters from first object
//TLD Tracker data extraction
Tracker* trackerPtr = trackers[0];
@@ -99,7 +100,7 @@ namespace cv
cvtColor(image, image_gray, COLOR_BGR2GRAY);
if (scale > 1.0)
- resize(image_gray, imageForDetector, Size(cvRound(image.cols*scale), cvRound(image.rows*scale)), 0, 0, tld::DOWNSCALE_MODE);
+ resize(image_gray, imageForDetector, Size(cvRound(image_gray.cols*scale), cvRound(image_gray.rows*scale)), 0, 0, tld::DOWNSCALE_MODE);
else
imageForDetector = image_gray;
GaussianBlur(imageForDetector, image_blurred, tld::GaussBlurKernelSize, 0.0);
@@ -653,4 +654,4 @@ namespace cv
}
#endif
-}
\ No newline at end of file
+}
diff --git a/contrib/modules/tracking/src/multiTracker_alt.cpp b/contrib/modules/tracking/src/multiTracker_alt.cpp
index 99722a7..7497479 100644
--- a/contrib/modules/tracking/src/multiTracker_alt.cpp
+++ b/contrib/modules/tracking/src/multiTracker_alt.cpp
@@ -44,29 +44,15 @@
namespace cv {
// constructor
- MultiTracker::MultiTracker(const String& trackerType):defaultAlgorithm(trackerType){};
+ MultiTracker::MultiTracker(){};
// destructor
MultiTracker::~MultiTracker(){};
- // add an object to be tracked, defaultAlgorithm is used
- bool MultiTracker::add(const Mat& image, const Rect2d& boundingBox){
- // quit if defaultAlgorithm has not been configured
- if(defaultAlgorithm==""){
- printf("Default algorithm was not defined!\n");
- return false;
- }
-
- // add a new tracked object
- return add(defaultAlgorithm.c_str(), image, boundingBox);
- };
-
// add a new tracked object
- bool MultiTracker::add( const String& trackerType, const Mat& image, const Rect2d& boundingBox ){
- // declare a new tracker
- Ptr<Tracker> newTracker = Tracker::create( trackerType );
-
- // add the created tracker algorithm to the trackers list
+ bool MultiTracker::add( Ptr<Tracker> newTracker, InputArray image, const Rect2d& boundingBox )
+ {
+ // add the tracker algorithm to the trackers list
trackerList.push_back(newTracker);
// add the ROI to the bounding box list
@@ -77,13 +63,13 @@ namespace cv {
};
// add a set of objects to be tracked
- bool MultiTracker::add(const String& trackerType, const Mat& image, std::vector<Rect2d> boundingBox){
+ bool MultiTracker::add(std::vector<Ptr<Tracker> > newTrackers, InputArray image, std::vector<Rect2d> boundingBox){
// status of the tracker addition
bool stat=false;
// add tracker for all input objects
for(unsigned i =0;i<boundingBox.size();i++){
- stat=add(trackerType,image,boundingBox[i]);
+ stat=add(newTrackers[i],image,boundingBox[i]);
if(!stat)break;
}
@@ -91,30 +77,32 @@ namespace cv {
return stat;
};
- // add a set of object to be tracked, defaultAlgorithm is used.
- bool MultiTracker::add(const Mat& image, std::vector<Rect2d> boundingBox){
- // quit if defaultAlgorithm has not been configured
- if(defaultAlgorithm==""){
- printf("Default algorithm was not defined!\n");
- return false;
- }
-
- return add(defaultAlgorithm.c_str(), image, boundingBox);
- };
-
// update position of the tracked objects, the result is stored in internal storage
- bool MultiTracker::update( const Mat& image){
+ bool MultiTracker::update(InputArray image)
+ {
+ bool status = true;
for(unsigned i=0;i< trackerList.size(); i++){
- trackerList[i]->update(image, objects[i]);
+ status &= trackerList[i]->update(image, objects[i]);
}
- return true;
+ return status;
};
// update position of the tracked objects, the result is copied to external variable
- bool MultiTracker::update( const Mat& image, std::vector<Rect2d> & boundingBox ){
- update(image);
+ bool MultiTracker::update(InputArray image, std::vector<Rect2d> & boundingBox )
+ {
+ bool status = update(image);
boundingBox=objects;
- return true;
+ return status;
};
-} /* namespace cv */
\ No newline at end of file
+ const std::vector<Rect2d>& MultiTracker::getObjects() const
+ {
+ return objects;
+ }
+
+ Ptr<MultiTracker> MultiTracker::create()
+ {
+ return makePtr<MultiTracker>();
+ }
+
+} /* namespace cv */
diff --git a/contrib/modules/tracking/src/roiSelector.cpp b/contrib/modules/tracking/src/roiSelector.cpp
deleted file mode 100644
index a1a7e6e..0000000
--- a/contrib/modules/tracking/src/roiSelector.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
- //
- // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
- //
- // By downloading, copying, installing or using the software you agree to this license.
- // If you do not agree to this license, do not download, install,
- // copy or use the software.
- //
- //
- // License Agreement
- // For Open Source Computer Vision Library
- //
- // Copyright (C) 2013, OpenCV Foundation, all rights reserved.
- // Third party copyrights are property of their respective owners.
- //
- // Redistribution and use in source and binary forms, with or without modification,
- // are permitted provided that the following conditions are met:
- //
- // * Redistribution's of source code must retain the above copyright notice,
- // this list of conditions and the following disclaimer.
- //
- // * Redistribution's in binary form must reproduce the above copyright notice,
- // this list of conditions and the following disclaimer in the documentation
- // and/or other materials provided with the distribution.
- //
- // * The name of the copyright holders may not be used to endorse or promote products
- // derived from this software without specific prior written permission.
- //
- // This software is provided by the copyright holders and contributors "as is" and
- // any express or implied warranties, including, but not limited to, the implied
- // warranties of merchantability and fitness for a particular purpose are disclaimed.
- // In no event shall the Intel Corporation or contributors be liable for any direct,
- // indirect, incidental, special, exemplary, or consequential damages
- // (including, but not limited to, procurement of substitute goods or services;
- // loss of use, data, or profits; or business interruption) however caused
- // and on any theory of liability, whether in contract, strict liability,
- // or tort (including negligence or otherwise) arising in any way out of
- // the use of this software, even if advised of the possibility of such damage.
- //
- //M*/
-
-#include "precomp.hpp"
-
-namespace cv {
- void ROISelector::mouseHandler(int event, int x, int y, int flags, void *param){
- ROISelector *self =static_cast<ROISelector*>(param);
- self->opencv_mouse_callback(event,x,y,flags,param);
- }
-
- void ROISelector::opencv_mouse_callback( int event, int x, int y, int , void *param ){
- handlerT * data = (handlerT*)param;
- switch( event ){
- // update the selected bounding box
- case EVENT_MOUSEMOVE:
- if( data->isDrawing ){
- if(data->drawFromCenter){
- data->box.width = 2*(x-data->center.x)/*data->box.x*/;
- data->box.height = 2*(y-data->center.y)/*data->box.y*/;
- data->box.x = data->center.x-data->box.width/2.0;
- data->box.y = data->center.y-data->box.height/2.0;
- }else{
- data->box.width = x-data->box.x;
- data->box.height = y-data->box.y;
- }
- }
- break;
-
- // start to select the bounding box
- case EVENT_LBUTTONDOWN:
- data->isDrawing = true;
- data->box = cvRect( x, y, 0, 0 );
- data->center = Point2f((float)x,(float)y);
- break;
-
- // cleaning up the selected bounding box
- case EVENT_LBUTTONUP:
- data->isDrawing = false;
- if( data->box.width < 0 ){
- data->box.x += data->box.width;
- data->box.width *= -1;
- }
- if( data->box.height < 0 ){
- data->box.y += data->box.height;
- data->box.height *= -1;
- }
- break;
- }
- }
-
- Rect2d ROISelector::select(Mat img, bool fromCenter){
- return select("ROI selector", img, fromCenter);
- }
-
- Rect2d ROISelector::select(const cv::String& windowName, Mat img, bool showCrossair, bool fromCenter){
-
- key=0;
-
- // set the drawing mode
- selectorParams.drawFromCenter = fromCenter;
-
- // show the image and give feedback to user
- imshow(windowName,img);
-
- // copy the data, rectangle should be drawn in the fresh image
- selectorParams.image=img.clone();
-
- // select the object
- setMouseCallback( windowName, mouseHandler, (void *)&selectorParams );
-
- // end selection process on SPACE (32) ESC (27) or ENTER (13)
- while(!(key==32 || key==27 || key==13)){
- // draw the selected object
- rectangle(
- selectorParams.image,
- selectorParams.box,
- Scalar(255,0,0),2,1
- );
-
- // draw cross air in the middle of bounding box
- if(showCrossair){
- // horizontal line
- line(
- selectorParams.image,
- Point((int)selectorParams.box.x,(int)(selectorParams.box.y+selectorParams.box.height/2)),
- Point((int)(selectorParams.box.x+selectorParams.box.width),(int)(selectorParams.box.y+selectorParams.box.height/2)),
- Scalar(255,0,0),2,1
- );
-
- // vertical line
- line(
- selectorParams.image,
- Point((int)(selectorParams.box.x+selectorParams.box.width/2),(int)selectorParams.box.y),
- Point((int)(selectorParams.box.x+selectorParams.box.width/2),(int)(selectorParams.box.y+selectorParams.box.height)),
- Scalar(255,0,0),2,1
- );
- }
-
- // show the image bouding box
- imshow(windowName,selectorParams.image);
-
- // reset the image
- selectorParams.image=img.clone();
-
- //get keyboard event, extract lower 8 bits for scancode comparison
- key=waitKey(1) & 0xFF;
- }
-
-
- return selectorParams.box;
- }
-
- void ROISelector::select(const cv::String& windowName, Mat img, std::vector<Rect2d> & boundingBox, bool fromCenter){
- std::vector<Rect2d> box;
- Rect2d temp;
- key=0;
-
- // show notice to user
- printf("Select an object to track and then press SPACE or ENTER button!\n" );
- printf("Finish the selection process by pressing ESC button!\n" );
-
- // while key is not ESC (27)
- for(;;) {
- temp=select(windowName, img, true, fromCenter);
- if(key==27) break;
- if(temp.width>0 && temp.height>0)
- box.push_back(temp);
- }
- boundingBox=box;
- }
-
- ROISelector _selector;
- Rect2d selectROI(Mat img, bool fromCenter){
- return _selector.select("ROI selector", img, true, fromCenter);
- };
-
- Rect2d selectROI(const cv::String& windowName, Mat img, bool showCrossair, bool fromCenter){
- printf("Select an object to track and then press SPACE or ENTER button!\n" );
- return _selector.select(windowName,img, showCrossair, fromCenter);
- };
-
- void selectROI(const cv::String& windowName, Mat img, std::vector<Rect2d> & boundingBox, bool fromCenter){
- return _selector.select(windowName, img, boundingBox, fromCenter);
- }
-
-} /* namespace cv */
diff --git a/contrib/modules/tracking/src/tldDataset.cpp b/contrib/modules/tracking/src/tldDataset.cpp
index 9ddbeed..97b2964 100644
--- a/contrib/modules/tracking/src/tldDataset.cpp
+++ b/contrib/modules/tracking/src/tldDataset.cpp
@@ -159,7 +159,7 @@ namespace cv
return cv::Rect2d(x, y, w, h);
}
- cv::Mat tld_getNextDatasetFrame()
+ cv::String tld_getNextDatasetFrame()
{
char fullPath[100];
char numStr[10];
@@ -178,8 +178,8 @@ namespace cv
else strcat(fullPath, ".jpg");
frameNum++;
- return cv::imread(fullPath);
+ return fullPath;
}
}
-}
\ No newline at end of file
+}
diff --git a/contrib/modules/tracking/src/tldTracker.cpp b/contrib/modules/tracking/src/tldTracker.cpp
index 05585e1..ee8d385 100644
--- a/contrib/modules/tracking/src/tldTracker.cpp
+++ b/contrib/modules/tracking/src/tldTracker.cpp
@@ -52,10 +52,14 @@ namespace cv
void TrackerTLD::Params::write(cv::FileStorage& /*fs*/) const {}
-Ptr<TrackerTLD> TrackerTLD::createTracker(const TrackerTLD::Params ¶meters)
+Ptr<TrackerTLD> TrackerTLD::create(const TrackerTLD::Params ¶meters)
{
return Ptr<tld::TrackerTLDImpl>(new tld::TrackerTLDImpl(parameters));
}
+Ptr<TrackerTLD> TrackerTLD::create()
+{
+ return Ptr<tld::TrackerTLDImpl>(new tld::TrackerTLDImpl());
+}
namespace tld
{
diff --git a/contrib/modules/tracking/src/tldTracker.hpp b/contrib/modules/tracking/src/tldTracker.hpp
index 4a5610d..5e544bb 100644
--- a/contrib/modules/tracking/src/tldTracker.hpp
+++ b/contrib/modules/tracking/src/tldTracker.hpp
@@ -98,7 +98,7 @@ public:
TrackerProxyImpl(Tparams params = Tparams()) :params_(params){}
bool init(const Mat& image, const Rect2d& boundingBox)
{
- trackerPtr = T::createTracker();
+ trackerPtr = T::create();
return trackerPtr->init(image, boundingBox);
}
bool update(const Mat& image, Rect2d& boundingBox)
@@ -122,6 +122,11 @@ public:
void read(const FileNode& fn);
void write(FileStorage& fs) const;
+ Ptr<TrackerModel> getModel()
+ {
+ return model;
+ }
+
class Pexpert
{
public:
@@ -166,4 +171,4 @@ public:
}
}
-#endif
\ No newline at end of file
+#endif
diff --git a/contrib/modules/tracking/src/tldUtils.cpp b/contrib/modules/tracking/src/tldUtils.cpp
index 5b03c70..0792e72 100644
--- a/contrib/modules/tracking/src/tldUtils.cpp
+++ b/contrib/modules/tracking/src/tldUtils.cpp
@@ -49,34 +49,6 @@ namespace tld
//Debug functions and variables
Rect2d etalon(14.0, 110.0, 20.0, 20.0);
-void drawWithRects(const Mat& img, std::vector<Rect2d>& blackOnes, Rect2d whiteOne)
-{
- Mat image;
- img.copyTo(image);
- if( whiteOne.width >= 0 )
- rectangle( image, whiteOne, 255, 1, 1 );
- for( int i = 0; i < (int)blackOnes.size(); i++ )
- rectangle( image, blackOnes[i], 0, 1, 1 );
- imshow("img", image);
-}
-void drawWithRects(const Mat& img, std::vector<Rect2d>& blackOnes, std::vector<Rect2d>& whiteOnes, String filename)
-{
- Mat image;
- static int frameCounter = 1;
- img.copyTo(image);
- for( int i = 0; i < (int)whiteOnes.size(); i++ )
- rectangle( image, whiteOnes[i], 255, 1, 1 );
- for( int i = 0; i < (int)blackOnes.size(); i++ )
- rectangle( image, blackOnes[i], 0, 1, 1 );
- imshow("img", image);
- if( filename.length() > 0 )
- {
- char inbuf[100];
- sprintf(inbuf, "%s%d.jpg", filename.c_str(), frameCounter);
- imwrite(inbuf, image);
- frameCounter++;
- }
-}
void myassert(const Mat& img)
{
int count = 0;
diff --git a/contrib/modules/tracking/src/tldUtils.hpp b/contrib/modules/tracking/src/tldUtils.hpp
index 9473ac9..e609006 100644
--- a/contrib/modules/tracking/src/tldUtils.hpp
+++ b/contrib/modules/tracking/src/tldUtils.hpp
@@ -2,7 +2,6 @@
#define OPENCV_TLD_UTILS
#include "precomp.hpp"
-#include "opencv2/highgui.hpp"
namespace cv
{
@@ -35,8 +34,6 @@ namespace cv
void myassert(const Mat& img);
void printPatch(const Mat_<uchar>& standardPatch);
std::string type2str(const Mat& mat);
- void drawWithRects(const Mat& img, std::vector<Rect2d>& blackOnes, Rect2d whiteOne = Rect2d(-1.0, -1.0, -1.0, -1.0));
- void drawWithRects(const Mat& img, std::vector<Rect2d>& blackOnes, std::vector<Rect2d>& whiteOnes, String fileName = "");
//aux functions and variables
template<typename T> inline T CLIP(T x, T a, T b){ return std::min(std::max(x, a), b); }
@@ -59,4 +56,4 @@ namespace cv
}
}
-#endif
\ No newline at end of file
+#endif
diff --git a/contrib/modules/tracking/src/tracker.cpp b/contrib/modules/tracking/src/tracker.cpp
index 8127f2a..216acb2 100644
--- a/contrib/modules/tracking/src/tracker.cpp
+++ b/contrib/modules/tracking/src/tracker.cpp
@@ -41,12 +41,6 @@
#include "precomp.hpp"
-#undef BOILERPLATE_CODE
-#define BOILERPLATE_CODE(name,classname)\
- if(trackerType==name){\
- return classname::createTracker();\
- }
-
namespace cv
{
@@ -58,7 +52,7 @@ Tracker::~Tracker()
{
}
-bool Tracker::init( const Mat& image, const Rect2d& boundingBox )
+bool Tracker::init( InputArray image, const Rect2d& boundingBox )
{
if( isInit )
@@ -73,7 +67,7 @@ bool Tracker::init( const Mat& image, const Rect2d& boundingBox )
featureSet = Ptr<TrackerFeatureSet>( new TrackerFeatureSet() );
model = Ptr<TrackerModel>();
- bool initTracker = initImpl( image, boundingBox );
+ bool initTracker = initImpl( image.getMat(), boundingBox );
//check if the model component is initialized
if( model == 0 )
@@ -90,7 +84,7 @@ bool Tracker::init( const Mat& image, const Rect2d& boundingBox )
return initTracker;
}
-bool Tracker::update( const Mat& image, Rect2d& boundingBox )
+bool Tracker::update( InputArray image, Rect2d& boundingBox )
{
if( !isInit )
@@ -101,18 +95,7 @@ bool Tracker::update( const Mat& image, Rect2d& boundingBox )
if( image.empty() )
return false;
- return updateImpl( image, boundingBox );
-}
-
-Ptr<Tracker> Tracker::create( const String& trackerType )
-{
- BOILERPLATE_CODE("MIL",TrackerMIL);
- BOILERPLATE_CODE("BOOSTING",TrackerBoosting);
- BOILERPLATE_CODE("MEDIANFLOW",TrackerMedianFlow);
- BOILERPLATE_CODE("TLD",TrackerTLD);
- BOILERPLATE_CODE("KCF",TrackerKCF);
- BOILERPLATE_CODE("GOTURN", TrackerGOTURN);
- return Ptr<Tracker>();
+ return updateImpl( image.getMat(), boundingBox );
}
} /* namespace cv */
diff --git a/contrib/modules/tracking/src/trackerBoosting.cpp b/contrib/modules/tracking/src/trackerBoosting.cpp
index 071bc29..e1d6b4c 100644
--- a/contrib/modules/tracking/src/trackerBoosting.cpp
+++ b/contrib/modules/tracking/src/trackerBoosting.cpp
@@ -97,9 +97,12 @@ void TrackerBoosting::Params::write( cv::FileStorage& fs ) const
/*
* Constructor
*/
-Ptr<TrackerBoosting> TrackerBoosting::createTracker(const TrackerBoosting::Params ¶meters){
+Ptr<TrackerBoosting> TrackerBoosting::create(const TrackerBoosting::Params ¶meters){
return Ptr<TrackerBoostingImpl>(new TrackerBoostingImpl(parameters));
}
+Ptr<TrackerBoosting> TrackerBoosting::create(){
+ return Ptr<TrackerBoostingImpl>(new TrackerBoostingImpl());
+}
TrackerBoostingImpl::TrackerBoostingImpl( const TrackerBoostingImpl::Params ¶meters ) :
params( parameters )
{
diff --git a/contrib/modules/tracking/src/trackerKCF.cpp b/contrib/modules/tracking/src/trackerKCF.cpp
index 5ccc3f4..bfa2874 100644
--- a/contrib/modules/tracking/src/trackerKCF.cpp
+++ b/contrib/modules/tracking/src/trackerKCF.cpp
@@ -160,9 +160,12 @@ namespace cv{
/*
* Constructor
*/
- Ptr<TrackerKCF> TrackerKCF::createTracker(const TrackerKCF::Params ¶meters){
+ Ptr<TrackerKCF> TrackerKCF::create(const TrackerKCF::Params ¶meters){
return Ptr<TrackerKCFImpl>(new TrackerKCFImpl(parameters));
}
+ Ptr<TrackerKCF> TrackerKCF::create(){
+ return Ptr<TrackerKCFImpl>(new TrackerKCFImpl());
+ }
TrackerKCFImpl::TrackerKCFImpl( const TrackerKCF::Params ¶meters ) :
params( parameters )
{
@@ -188,7 +191,7 @@ namespace cv{
* - creating a gaussian response for the training ground-truth
* - perform FFT to the gaussian response
*/
- bool TrackerKCFImpl::initImpl( const Mat& /*image*/, const Rect2d& boundingBox ){
+ bool TrackerKCFImpl::initImpl( const Mat& image, const Rect2d& boundingBox ){
frame=0;
roi = boundingBox;
@@ -220,8 +223,8 @@ namespace cv{
// create gaussian response
y=Mat::zeros((int)roi.height,(int)roi.width,CV_64F);
- for(unsigned i=0;i<roi.height;i++){
- for(unsigned j=0;j<roi.width;j++){
+ for(unsigned i=0;i<(unsigned)roi.height;i++){
+ for(unsigned j=0;j<(unsigned)roi.width;j++){
y.at<double>(i,j)=(i-roi.height/2+1)*(i-roi.height/2+1)+(j-roi.width/2+1)*(j-roi.width/2+1);
}
}
@@ -256,7 +259,11 @@ namespace cv{
|| use_custom_extractor_npca
);
- // TODO: return true only if roi inside the image
+ //return true only if roi has intersection with the image
+ if((roi & Rect2d(0,0, resizeImage ? image.cols / 2 : image.cols,
+ resizeImage ? image.rows / 2 : image.rows)) == Rect2d())
+ return false;
+
return true;
}
@@ -334,6 +341,10 @@ namespace cv{
// extract the maximum response
minMaxLoc( response, &minVal, &maxVal, &minLoc, &maxLoc );
+ if (maxVal < params.detect_thresh)
+ {
+ return false;
+ }
roi.x+=(maxLoc.x-roi.width/2+1);
roi.y+=(maxLoc.y-roi.height/2+1);
}
@@ -576,11 +587,8 @@ namespace cv{
Rect region=_roi;
// return false if roi is outside the image
- if((_roi.x+_roi.width<0)
- ||(_roi.y+_roi.height<0)
- ||(_roi.x>=img.cols)
- ||(_roi.y>=img.rows)
- )return false;
+ if((roi & Rect2d(0,0, img.cols, img.rows)) == Rect2d() )
+ return false;
// extract patch inside the image
if(_roi.x<0){region.x=0;region.width+=_roi.x;}
@@ -817,6 +825,7 @@ namespace cv{
* Parameters
*/
TrackerKCF::Params::Params(){
+ detect_thresh = 0.5;
sigma=0.2;
lambda=0.01;
interp_factor=0.075;
@@ -834,10 +843,67 @@ namespace cv{
pca_learning_rate=0.15;
}
- void TrackerKCF::Params::read( const cv::FileNode& /*fn*/ ){}
+ void TrackerKCF::Params::read( const cv::FileNode& fn ){
+ *this = TrackerKCF::Params();
+
+ if (!fn["detect_thresh"].empty())
+ fn["detect_thresh"] >> detect_thresh;
+
+ if (!fn["sigma"].empty())
+ fn["sigma"] >> sigma;
+
+ if (!fn["lambda"].empty())
+ fn["lambda"] >> lambda;
+
+ if (!fn["interp_factor"].empty())
+ fn["interp_factor"] >> interp_factor;
- void TrackerKCF::Params::write( cv::FileStorage& /*fs*/ ) const{}
+ if (!fn["output_sigma_factor"].empty())
+ fn["output_sigma_factor"] >> output_sigma_factor;
- void TrackerKCF::setFeatureExtractor(void (*)(const Mat, const Rect, Mat&), bool ){};
+ if (!fn["resize"].empty())
+ fn["resize"] >> resize;
+ if (!fn["max_patch_size"].empty())
+ fn["max_patch_size"] >> max_patch_size;
+
+ if (!fn["split_coeff"].empty())
+ fn["split_coeff"] >> split_coeff;
+
+ if (!fn["wrap_kernel"].empty())
+ fn["wrap_kernel"] >> wrap_kernel;
+
+
+ if (!fn["desc_npca"].empty())
+ fn["desc_npca"] >> desc_npca;
+
+ if (!fn["desc_pca"].empty())
+ fn["desc_pca"] >> desc_pca;
+
+ if (!fn["compress_feature"].empty())
+ fn["compress_feature"] >> compress_feature;
+
+ if (!fn["compressed_size"].empty())
+ fn["compressed_size"] >> compressed_size;
+
+ if (!fn["pca_learning_rate"].empty())
+ fn["pca_learning_rate"] >> pca_learning_rate;
+ }
+
+ void TrackerKCF::Params::write( cv::FileStorage& fs ) const{
+ fs << "detect_thresh" << detect_thresh;
+ fs << "sigma" << sigma;
+ fs << "lambda" << lambda;
+ fs << "interp_factor" << interp_factor;
+ fs << "output_sigma_factor" << output_sigma_factor;
+ fs << "resize" << resize;
+ fs << "max_patch_size" << max_patch_size;
+ fs << "split_coeff" << split_coeff;
+ fs << "wrap_kernel" << wrap_kernel;
+ fs << "desc_npca" << desc_npca;
+ fs << "desc_pca" << desc_pca;
+ fs << "compress_feature" << compress_feature;
+ fs << "compressed_size" << compressed_size;
+ fs << "pca_learning_rate" << pca_learning_rate;
+ }
} /* namespace cv */
diff --git a/contrib/modules/tracking/src/trackerMIL.cpp b/contrib/modules/tracking/src/trackerMIL.cpp
index b45faca..9b08f82 100644
--- a/contrib/modules/tracking/src/trackerMIL.cpp
+++ b/contrib/modules/tracking/src/trackerMIL.cpp
@@ -105,9 +105,12 @@ void TrackerMIL::Params::write( cv::FileStorage& fs ) const
/*
* Constructor
*/
-Ptr<TrackerMIL> TrackerMIL::createTracker(const TrackerMIL::Params ¶meters){
+Ptr<TrackerMIL> TrackerMIL::create(const TrackerMIL::Params ¶meters){
return Ptr<TrackerMILImpl>(new TrackerMILImpl(parameters));
}
+Ptr<TrackerMIL> TrackerMIL::create(){
+ return Ptr<TrackerMILImpl>(new TrackerMILImpl());
+}
TrackerMILImpl::TrackerMILImpl( const TrackerMIL::Params ¶meters ) :
params( parameters )
{
diff --git a/contrib/modules/tracking/src/trackerMedianFlow.cpp b/contrib/modules/tracking/src/trackerMedianFlow.cpp
index f24fc3b..3b9243d 100644
--- a/contrib/modules/tracking/src/trackerMedianFlow.cpp
+++ b/contrib/modules/tracking/src/trackerMedianFlow.cpp
@@ -45,16 +45,15 @@
#include <algorithm>
#include <limits.h>
-namespace cv
+namespace
{
+using namespace cv;
-#undef ALEX_DEBUG
-#ifdef ALEX_DEBUG
-#define dfprintf(x) fprintf x
+#undef MEDIAN_FLOW_TRACKER_DEBUG_LOGS
+#ifdef MEDIAN_FLOW_TRACKER_DEBUG_LOGS
#define dprintf(x) printf x
#else
-#define dfprintf(x)
-#define dprintf(x)
+#define dprintf(x) do{} while(false)
#endif
/*
@@ -70,78 +69,79 @@ namespace cv
* FIXME:
* when patch is cut from image to compute NCC, there can be problem with size
* optimize (allocation<-->reallocation)
- * optimize (remove vector.erase() calls)
- * bring "out" all the parameters to TrackerMedianFlow::Param
*/
class TrackerMedianFlowImpl : public TrackerMedianFlow{
- public:
- TrackerMedianFlowImpl(TrackerMedianFlow::Params paramsIn):termcrit(TermCriteria::COUNT|TermCriteria::EPS,20,0.3){params=paramsIn;isInit=false;}
- void read( const FileNode& fn );
- void write( FileStorage& fs ) const;
- private:
- bool initImpl( const Mat& image, const Rect2d& boundingBox );
- bool updateImpl( const Mat& image, Rect2d& boundingBox );
- bool medianFlowImpl(Mat oldImage,Mat newImage,Rect2d& oldBox);
- Rect2d vote(const std::vector<Point2f>& oldPoints,const std::vector<Point2f>& newPoints,const Rect2d& oldRect,Point2f& mD);
- //FIXME: this can be optimized: current method uses sort->select approach, there are O(n) selection algo for median; besides
- //it makes copy all the time
- template<typename T>
- T getMedian( std::vector<T>& values,int size=-1);
- float dist(Point2f p1,Point2f p2);
- std::string type2str(int type);
- void computeStatistics(std::vector<float>& data,int size=-1);
- void check_FB(const Mat& oldImage,const Mat& newImage,
- const std::vector<Point2f>& oldPoints,const std::vector<Point2f>& newPoints,std::vector<bool>& status);
- void check_NCC(const Mat& oldImage,const Mat& newImage,
- const std::vector<Point2f>& oldPoints,const std::vector<Point2f>& newPoints,std::vector<bool>& status);
- inline double l2distance(Point2f p1,Point2f p2);
-
- TrackerMedianFlow::Params params;
- TermCriteria termcrit;
+public:
+ TrackerMedianFlowImpl(TrackerMedianFlow::Params paramsIn = TrackerMedianFlow::Params()) {params=paramsIn;isInit=false;}
+ void read( const FileNode& fn );
+ void write( FileStorage& fs ) const;
+private:
+ bool initImpl( const Mat& image, const Rect2d& boundingBox );
+ bool updateImpl( const Mat& image, Rect2d& boundingBox );
+ bool medianFlowImpl(Mat oldImage,Mat newImage,Rect2d& oldBox);
+ Rect2d vote(const std::vector<Point2f>& oldPoints,const std::vector<Point2f>& newPoints,const Rect2d& oldRect,Point2f& mD);
+ float dist(Point2f p1,Point2f p2);
+ std::string type2str(int type);
+ void computeStatistics(std::vector<float>& data,int size=-1);
+ void check_FB(const std::vector<Mat>& oldImagePyr,const std::vector<Mat>& newImagePyr,
+ const std::vector<Point2f>& oldPoints,const std::vector<Point2f>& newPoints,std::vector<bool>& status);
+ void check_NCC(const Mat& oldImage,const Mat& newImage,
+ const std::vector<Point2f>& oldPoints,const std::vector<Point2f>& newPoints,std::vector<bool>& status);
+
+ TrackerMedianFlow::Params params;
};
-class TrackerMedianFlowModel : public TrackerModel{
- public:
- TrackerMedianFlowModel(TrackerMedianFlow::Params /*params*/){}
- Rect2d getBoundingBox(){return boundingBox_;}
- void setBoudingBox(Rect2d boundingBox){boundingBox_=boundingBox;}
- Mat getImage(){return image_;}
- void setImage(const Mat& image){image.copyTo(image_);}
- protected:
- Rect2d boundingBox_;
- Mat image_;
- void modelEstimationImpl( const std::vector<Mat>& /*responses*/ ){}
- void modelUpdateImpl(){}
-};
+template<typename T>
+T getMedian( const std::vector<T>& values );
-/*
- * Parameters
- */
-TrackerMedianFlow::Params::Params(){
- pointsInGrid=10;
-}
+template<typename T>
+T getMedianAndDoPartition( std::vector<T>& values );
-void TrackerMedianFlow::Params::read( const cv::FileNode& fn ){
- pointsInGrid=fn["pointsInGrid"];
-}
+Mat getPatch(Mat image, Size patch_size, Point2f patch_center)
+{
+ Mat patch;
+ Point2i roi_strat_corner(cvRound(patch_center.x - patch_size.width / 2.),
+ cvRound(patch_center.y - patch_size.height / 2.));
-void TrackerMedianFlow::Params::write( cv::FileStorage& fs ) const{
- fs << "pointsInGrid" << pointsInGrid;
+ Rect2i patch_rect(roi_strat_corner, patch_size);
+
+ if(patch_rect == (patch_rect & Rect2i(0, 0, image.cols, image.rows)))
+ {
+ patch = image(patch_rect);
+ }
+ else
+ {
+ getRectSubPix(image, patch_size,
+ Point2f((float)(patch_rect.x + patch_size.width / 2.),
+ (float)(patch_rect.y + patch_size.height / 2.)), patch);
+ }
+
+ return patch;
}
+class TrackerMedianFlowModel : public TrackerModel{
+public:
+ TrackerMedianFlowModel(TrackerMedianFlow::Params /*params*/){}
+ Rect2d getBoundingBox(){return boundingBox_;}
+ void setBoudingBox(Rect2d boundingBox){boundingBox_=boundingBox;}
+ Mat getImage(){return image_;}
+ void setImage(const Mat& image){image.copyTo(image_);}
+protected:
+ Rect2d boundingBox_;
+ Mat image_;
+ void modelEstimationImpl( const std::vector<Mat>& /*responses*/ ){}
+ void modelUpdateImpl(){}
+};
+
void TrackerMedianFlowImpl::read( const cv::FileNode& fn )
{
- params.read( fn );
+ params.read( fn );
}
void TrackerMedianFlowImpl::write( cv::FileStorage& fs ) const
{
- params.write( fs );
-}
-
-Ptr<TrackerMedianFlow> TrackerMedianFlow::createTracker(const TrackerMedianFlow::Params ¶meters){
- return Ptr<TrackerMedianFlowImpl>(new TrackerMedianFlowImpl(parameters));
+ params.write( fs );
}
bool TrackerMedianFlowImpl::initImpl( const Mat& image, const Rect2d& boundingBox ){
@@ -164,28 +164,39 @@ bool TrackerMedianFlowImpl::updateImpl( const Mat& image, Rect2d& boundingBox ){
return true;
}
-std::string TrackerMedianFlowImpl::type2str(int type) {
- std::string r;
+template<typename T>
+size_t filterPointsInVectors(std::vector<T>& status, std::vector<Point2f>& vec1, std::vector<Point2f>& vec2, T goodValue)
+{
+ CV_DbgAssert(status.size() == vec1.size() && status.size() == vec2.size());
+
+ size_t first_bad_idx = 0;
+ while(first_bad_idx < status.size())
+ {
+ if(status[first_bad_idx] != goodValue)
+ break;
+ first_bad_idx++;
+ }
- uchar depth = type & CV_MAT_DEPTH_MASK;
- uchar chans = (uchar)(1 + (type >> CV_CN_SHIFT));
+ if (first_bad_idx >= status.size())
+ return first_bad_idx;
- switch ( depth ) {
- case CV_8U: r = "8U"; break;
- case CV_8S: r = "8S"; break;
- case CV_16U: r = "16U"; break;
- case CV_16S: r = "16S"; break;
- case CV_32S: r = "32S"; break;
- case CV_32F: r = "32F"; break;
- case CV_64F: r = "64F"; break;
- default: r = "User"; break;
- }
+ for(size_t i = first_bad_idx + 1; i < status.size(); i++)
+ {
+ if (status[i] != goodValue)
+ continue;
- r += "C";
- r += (chans+'0');
+ status[first_bad_idx] = goodValue;
+ vec1[first_bad_idx] = vec1[i];
+ vec2[first_bad_idx] = vec2[i];
+ first_bad_idx++;
+ }
+ vec1.erase(vec1.begin() + first_bad_idx, vec1.end());
+ vec2.erase(vec2.begin() + first_bad_idx, vec2.end());
+ status.erase(status.begin() + first_bad_idx, status.end());
- return r;
+ return first_bad_idx;
}
+
bool TrackerMedianFlowImpl::medianFlowImpl(Mat oldImage,Mat newImage,Rect2d& oldBox){
std::vector<Point2f> pointsToTrackOld,pointsToTrackNew;
@@ -203,51 +214,76 @@ bool TrackerMedianFlowImpl::medianFlowImpl(Mat oldImage,Mat newImage,Rect2d& old
//"open ended" grid
for(int i=0;i<params.pointsInGrid;i++){
for(int j=0;j<params.pointsInGrid;j++){
- pointsToTrackOld.push_back(
+ pointsToTrackOld.push_back(
Point2f((float)(oldBox.x+((1.0*oldBox.width)/params.pointsInGrid)*j+.5*oldBox.width/params.pointsInGrid),
- (float)(oldBox.y+((1.0*oldBox.height)/params.pointsInGrid)*i+.5*oldBox.height/params.pointsInGrid)));
+ (float)(oldBox.y+((1.0*oldBox.height)/params.pointsInGrid)*i+.5*oldBox.height/params.pointsInGrid)));
}
}
std::vector<uchar> status(pointsToTrackOld.size());
std::vector<float> errors(pointsToTrackOld.size());
- calcOpticalFlowPyrLK(oldImage_gray, newImage_gray,pointsToTrackOld,pointsToTrackNew,status,errors,Size(3,3),5,termcrit,0);
+
+ std::vector<Mat> oldImagePyr;
+ buildOpticalFlowPyramid(oldImage_gray, oldImagePyr, params.winSize, params.maxLevel, false);
+
+ std::vector<Mat> newImagePyr;
+ buildOpticalFlowPyramid(newImage_gray, newImagePyr, params.winSize, params.maxLevel, false);
+
+ calcOpticalFlowPyrLK(oldImagePyr,newImagePyr,pointsToTrackOld,pointsToTrackNew,status,errors,
+ params.winSize, params.maxLevel, params.termCriteria, 0);
+
+ CV_Assert(pointsToTrackNew.size() == pointsToTrackOld.size());
+ CV_Assert(status.size() == pointsToTrackOld.size());
dprintf(("\t%d after LK forward\n",(int)pointsToTrackOld.size()));
- std::vector<Point2f> di;
- for(int i=0;i<(int)pointsToTrackOld.size();i++){
- if(status[i]==1){
- di.push_back(pointsToTrackNew[i]-pointsToTrackOld[i]);
- }
+ size_t num_good_points_after_optical_flow = filterPointsInVectors(status, pointsToTrackOld, pointsToTrackNew, (uchar)1);
+
+ dprintf(("\t num_good_points_after_optical_flow = %d\n",num_good_points_after_optical_flow));
+
+ if (num_good_points_after_optical_flow == 0) {
+ return false;
}
- std::vector<bool> filter_status;
- check_FB(oldImage_gray,newImage_gray,pointsToTrackOld,pointsToTrackNew,filter_status);
- check_NCC(oldImage_gray,newImage_gray,pointsToTrackOld,pointsToTrackNew,filter_status);
+ CV_Assert(pointsToTrackOld.size() == num_good_points_after_optical_flow);
+ CV_Assert(pointsToTrackNew.size() == num_good_points_after_optical_flow);
+
+ dprintf(("\t%d after LK forward after removing points with bad status\n",(int)pointsToTrackOld.size()));
+
+ std::vector<bool> filter_status(pointsToTrackOld.size(), true);
+ check_FB(oldImagePyr, newImagePyr, pointsToTrackOld, pointsToTrackNew, filter_status);
+ check_NCC(oldImage_gray, newImage_gray, pointsToTrackOld, pointsToTrackNew, filter_status);
// filter
- for(int i=0;i<(int)pointsToTrackOld.size();i++){
- if(!filter_status[i]){
- pointsToTrackOld.erase(pointsToTrackOld.begin()+i);
- pointsToTrackNew.erase(pointsToTrackNew.begin()+i);
- filter_status.erase(filter_status.begin()+i);
- i--;
- }
+ size_t num_good_points_after_filtering = filterPointsInVectors(filter_status, pointsToTrackOld, pointsToTrackNew, true);
+
+ dprintf(("\t num_good_points_after_filtering = %d\n",num_good_points_after_filtering));
+
+ if(num_good_points_after_filtering == 0){
+ return false;
}
+
+ CV_Assert(pointsToTrackOld.size() == num_good_points_after_filtering);
+ CV_Assert(pointsToTrackNew.size() == num_good_points_after_filtering);
+
dprintf(("\t%d after LK backward\n",(int)pointsToTrackOld.size()));
- if(pointsToTrackOld.size()==0 || di.size()==0){
- return false;
+ std::vector<Point2f> di(pointsToTrackOld.size());
+ for(size_t i=0; i<pointsToTrackOld.size(); i++){
+ di[i] = pointsToTrackNew[i]-pointsToTrackOld[i];
}
+
Point2f mDisplacement;
oldBox=vote(pointsToTrackOld,pointsToTrackNew,oldBox,mDisplacement);
- std::vector<double> displacements;
- for(int i=0;i<(int)di.size();i++){
+ std::vector<float> displacements;
+ for(size_t i=0;i<di.size();i++){
di[i]-=mDisplacement;
- displacements.push_back(sqrt(di[i].ddot(di[i])));
+ displacements.push_back((float)sqrt(di[i].ddot(di[i])));
}
- if(getMedian(displacements,(int)displacements.size())>10){
+ float median_displacements = getMedianAndDoPartition(displacements);
+ dprintf(("\tmedian of length of difference of displacements = %f\n", median_displacements));
+ if(median_displacements > params.maxMedianLengthOfDisplacementDifference){
+ dprintf(("\tmedian flow tracker returns false due to big median length of difference between displacements\n"));
return false;
}
@@ -255,77 +291,52 @@ bool TrackerMedianFlowImpl::medianFlowImpl(Mat oldImage,Mat newImage,Rect2d& old
}
Rect2d TrackerMedianFlowImpl::vote(const std::vector<Point2f>& oldPoints,const std::vector<Point2f>& newPoints,const Rect2d& oldRect,Point2f& mD){
- static int iteration=0;//FIXME -- we don't want this static var in final release
Rect2d newRect;
Point2d newCenter(oldRect.x+oldRect.width/2.0,oldRect.y+oldRect.height/2.0);
- int n=(int)oldPoints.size();
- std::vector<double> buf(std::max(n*(n-1)/2,3),0.0);
+ const size_t n=oldPoints.size();
- if(oldPoints.size()==1){
+ if (n==1) {
newRect.x=oldRect.x+newPoints[0].x-oldPoints[0].x;
newRect.y=oldRect.y+newPoints[0].y-oldPoints[0].y;
newRect.width=oldRect.width;
newRect.height=oldRect.height;
+ mD.x = newPoints[0].x-oldPoints[0].x;
+ mD.y = newPoints[0].y-oldPoints[0].y;
return newRect;
}
- double xshift=0,yshift=0;
- for(int i=0;i<n;i++){ buf[i]=newPoints[i].x-oldPoints[i].x; }
- xshift=getMedian(buf,n);
+ float xshift=0,yshift=0;
+ std::vector<float> buf_for_location(n, 0.);
+ for(size_t i=0;i<n;i++){ buf_for_location[i]=newPoints[i].x-oldPoints[i].x; }
+ xshift=getMedianAndDoPartition(buf_for_location);
newCenter.x+=xshift;
- for(int i=0;i<n;i++){ buf[i]=newPoints[i].y-oldPoints[i].y; }
- yshift=getMedian(buf,n);
+ for(size_t i=0;i<n;i++){ buf_for_location[i]=newPoints[i].y-oldPoints[i].y; }
+ yshift=getMedianAndDoPartition(buf_for_location);
newCenter.y+=yshift;
mD=Point2f((float)xshift,(float)yshift);
- if(oldPoints.size()==1){
- newRect.x=newCenter.x-oldRect.width/2.0;
- newRect.y=newCenter.y-oldRect.height/2.0;
- newRect.width=oldRect.width;
- newRect.height=oldRect.height;
- return newRect;
- }
-
- double nd,od;
- for(int i=0,ctr=0;i<n;i++){
- for(int j=0;j<i;j++){
- nd=l2distance(newPoints[i],newPoints[j]);
- od=l2distance(oldPoints[i],oldPoints[j]);
- buf[ctr]=(od==0.0)?0.0:(nd/od);
+ std::vector<double> buf_for_scale(n*(n-1)/2, 0.0);
+ for(size_t i=0,ctr=0;i<n;i++){
+ for(size_t j=0;j<i;j++){
+ double nd=norm(newPoints[i] - newPoints[j]);
+ double od=norm(oldPoints[i] - oldPoints[j]);
+ buf_for_scale[ctr]=(od==0.0)?0.0:(nd/od);
ctr++;
}
}
- double scale=getMedian(buf,n*(n-1)/2);
- dprintf(("iter %d %f %f %f\n",iteration,xshift,yshift,scale));
+ double scale=getMedianAndDoPartition(buf_for_scale);
+ dprintf(("xshift, yshift, scale = %f %f %f\n",xshift,yshift,scale));
newRect.x=newCenter.x-scale*oldRect.width/2.0;
newRect.y=newCenter.y-scale*oldRect.height/2.0;
newRect.width=scale*oldRect.width;
newRect.height=scale*oldRect.height;
- /*if(newRect.x<=0){
- exit(0);
- }*/
dprintf(("rect old [%f %f %f %f]\n",oldRect.x,oldRect.y,oldRect.width,oldRect.height));
dprintf(("rect [%f %f %f %f]\n",newRect.x,newRect.y,newRect.width,newRect.height));
- iteration++;
return newRect;
}
-template<typename T>
-T TrackerMedianFlowImpl::getMedian(std::vector<T>& values,int size){
- if(size==-1){
- size=(int)values.size();
- }
- std::vector<T> copy(values.begin(),values.begin()+size);
- std::sort(copy.begin(),copy.end());
- if(size%2==0){
- return (copy[size/2-1]+copy[size/2])/((T)2.0);
- }else{
- return copy[(size-1)/2];
- }
-}
-
void TrackerMedianFlowImpl::computeStatistics(std::vector<float>& data,int size){
int binnum=10;
if(size==-1){
@@ -340,56 +351,142 @@ void TrackerMedianFlowImpl::computeStatistics(std::vector<float>& data,int size)
dprintf(("[%4f,%4f] -- %4d\n",mini+(maxi-mini)/binnum*i,mini+(maxi-mini)/binnum*(i+1),bins[i]));
}
}
-double TrackerMedianFlowImpl::l2distance(Point2f p1,Point2f p2){
- double dx=p1.x-p2.x, dy=p1.y-p2.y;
- return sqrt(dx*dx+dy*dy);
-}
-void TrackerMedianFlowImpl::check_FB(const Mat& oldImage,const Mat& newImage,
- const std::vector<Point2f>& oldPoints,const std::vector<Point2f>& newPoints,std::vector<bool>& status){
- if(status.size()==0){
+void TrackerMedianFlowImpl::check_FB(const std::vector<Mat>& oldImagePyr, const std::vector<Mat>& newImagePyr,
+ const std::vector<Point2f>& oldPoints, const std::vector<Point2f>& newPoints, std::vector<bool>& status){
+
+ if(status.empty()) {
status=std::vector<bool>(oldPoints.size(),true);
}
std::vector<uchar> LKstatus(oldPoints.size());
std::vector<float> errors(oldPoints.size());
- std::vector<double> FBerror(oldPoints.size());
+ std::vector<float> FBerror(oldPoints.size());
std::vector<Point2f> pointsToTrackReprojection;
- calcOpticalFlowPyrLK(newImage, oldImage,newPoints,pointsToTrackReprojection,LKstatus,errors,Size(3,3),5,termcrit,0);
+ calcOpticalFlowPyrLK(newImagePyr, oldImagePyr,newPoints,pointsToTrackReprojection,LKstatus,errors,
+ params.winSize, params.maxLevel, params.termCriteria, 0);
- for(int i=0;i<(int)oldPoints.size();i++){
- FBerror[i]=l2distance(oldPoints[i],pointsToTrackReprojection[i]);
+ for(size_t i=0;i<oldPoints.size();i++){
+ FBerror[i]=(float)norm(oldPoints[i]-pointsToTrackReprojection[i]);
}
- double FBerrorMedian=getMedian(FBerror);
+ float FBerrorMedian=getMedian(FBerror);
dprintf(("point median=%f\n",FBerrorMedian));
dprintf(("FBerrorMedian=%f\n",FBerrorMedian));
- for(int i=0;i<(int)oldPoints.size();i++){
- status[i]=(FBerror[i]<FBerrorMedian);
+ for(size_t i=0;i<oldPoints.size();i++){
+ status[i]=status[i] && (FBerror[i] <= FBerrorMedian);
}
}
void TrackerMedianFlowImpl::check_NCC(const Mat& oldImage,const Mat& newImage,
- const std::vector<Point2f>& oldPoints,const std::vector<Point2f>& newPoints,std::vector<bool>& status){
+ const std::vector<Point2f>& oldPoints,const std::vector<Point2f>& newPoints,std::vector<bool>& status){
std::vector<float> NCC(oldPoints.size(),0.0);
- Size patch(30,30);
Mat p1,p2;
- for (int i = 0; i < (int)oldPoints.size(); i++) {
- getRectSubPix( oldImage, patch, oldPoints[i],p1);
- getRectSubPix( newImage, patch, newPoints[i],p2);
+ for (size_t i = 0; i < oldPoints.size(); i++) {
+ p1 = getPatch(oldImage, params.winSizeNCC, oldPoints[i]);
+ p2 = getPatch(newImage, params.winSizeNCC, newPoints[i]);
- const int N=900;
+ const int patch_area=params.winSizeNCC.area();
double s1=sum(p1)(0),s2=sum(p2)(0);
double n1=norm(p1),n2=norm(p2);
double prod=p1.dot(p2);
- double sq1=sqrt(n1*n1-s1*s1/N),sq2=sqrt(n2*n2-s2*s2/N);
- double ares=(sq2==0)?sq1/abs(sq1):(prod-s1*s2/N)/sq1/sq2;
-
- NCC[i] = (float)ares;
- }
- float median = getMedian(NCC);
- for(int i = 0; i < (int)oldPoints.size(); i++) {
- status[i] = status[i] && (NCC[i]>median);
- }
+ double sq1=sqrt(n1*n1-s1*s1/patch_area),sq2=sqrt(n2*n2-s2*s2/patch_area);
+ double ares=(sq2==0)?sq1/abs(sq1):(prod-s1*s2/patch_area)/sq1/sq2;
+
+ NCC[i] = (float)ares;
+ }
+ float median = getMedian(NCC);
+ for(size_t i = 0; i < oldPoints.size(); i++) {
+ status[i] = status[i] && (NCC[i] >= median);
+ }
+}
+
+template<typename T>
+T getMedian(const std::vector<T>& values)
+{
+ std::vector<T> copy(values);
+ return getMedianAndDoPartition(copy);
+}
+
+template<typename T>
+T getMedianAndDoPartition(std::vector<T>& values)
+{
+ size_t size = values.size();
+ if(size%2==0)
+ {
+ std::nth_element(values.begin(), values.begin() + size/2-1, values.end());
+ T firstMedian = values[size/2-1];
+
+ std::nth_element(values.begin(), values.begin() + size/2, values.end());
+ T secondMedian = values[size/2];
+
+ return (firstMedian + secondMedian) / (T)2;
+ }
+ else
+ {
+ size_t medianIndex = (size - 1) / 2;
+ std::nth_element(values.begin(), values.begin() + medianIndex, values.end());
+
+ return values[medianIndex];
+ }
+}
+
+} /* anonymous namespace */
+
+namespace cv
+{
+/*
+ * Parameters
+ */
+TrackerMedianFlow::Params::Params() {
+ pointsInGrid=10;
+ winSize = Size(3,3);
+ maxLevel = 5;
+ termCriteria = TermCriteria(TermCriteria::COUNT|TermCriteria::EPS,20,0.3);
+ winSizeNCC = Size(30,30);
+ maxMedianLengthOfDisplacementDifference = 10;
+}
+
+void TrackerMedianFlow::Params::read( const cv::FileNode& fn ){
+ *this = TrackerMedianFlow::Params();
+
+ if (!fn["winSize"].empty())
+ fn["winSize"] >> winSize;
+
+ if(!fn["winSizeNCC"].empty())
+ fn["winSizeNCC"] >> winSizeNCC;
+
+ if(!fn["pointsInGrid"].empty())
+ fn["pointsInGrid"] >> pointsInGrid;
+
+ if(!fn["maxLevel"].empty())
+ fn["maxLevel"] >> maxLevel;
+
+ if(!fn["maxMedianLengthOfDisplacementDifference"].empty())
+ fn["maxMedianLengthOfDisplacementDifference"] >> maxMedianLengthOfDisplacementDifference;
+
+ if(!fn["termCriteria_maxCount"].empty())
+ fn["termCriteria_maxCount"] >> termCriteria.maxCount;
+
+ if(!fn["termCriteria_epsilon"].empty())
+ fn["termCriteria_epsilon"] >> termCriteria.epsilon;
}
+
+void TrackerMedianFlow::Params::write( cv::FileStorage& fs ) const{
+ fs << "pointsInGrid" << pointsInGrid;
+ fs << "winSize" << winSize;
+ fs << "maxLevel" << maxLevel;
+ fs << "termCriteria_maxCount" << termCriteria.maxCount;
+ fs << "termCriteria_epsilon" << termCriteria.epsilon;
+ fs << "winSizeNCC" << winSizeNCC;
+ fs << "maxMedianLengthOfDisplacementDifference" << maxMedianLengthOfDisplacementDifference;
+}
+
+Ptr<TrackerMedianFlow> TrackerMedianFlow::create(const TrackerMedianFlow::Params ¶meters){
+ return Ptr<TrackerMedianFlowImpl>(new TrackerMedianFlowImpl(parameters));
+}
+Ptr<TrackerMedianFlow> TrackerMedianFlow::create(){
+ return Ptr<TrackerMedianFlowImpl>(new TrackerMedianFlowImpl());
+}
+
} /* namespace cv */
diff --git a/contrib/modules/tracking/test/test_aukf.cpp b/contrib/modules/tracking/test/test_aukf.cpp
index 4afe223..4879344 100644
--- a/contrib/modules/tracking/test/test_aukf.cpp
+++ b/contrib/modules/tracking/test/test_aukf.cpp
@@ -204,7 +204,7 @@ TEST(AUKF, br_landing_point)
ASSERT_NEAR(landing_coordinate, landing_y, abs_error);
}
-TEST(AUKF, br_mean_squared_error)
+TEST(DISABLED_AUKF, DISABLED_br_mean_squared_error)
{
const double velocity_treshold = 0.004;
const double state_treshold = 0.04;
@@ -344,7 +344,7 @@ public:
}
};
-TEST(AUKF, ungm_mean_squared_error)
+TEST(AUKF, DISABLED_ungm_mean_squared_error)
{
const double alpha = 1.5;
diff --git a/contrib/modules/tracking/test/test_trackerOPE.cpp b/contrib/modules/tracking/test/test_trackerOPE.cpp
deleted file mode 100644
index 09be4f8..0000000
--- a/contrib/modules/tracking/test/test_trackerOPE.cpp
+++ /dev/null
@@ -1,443 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
- //
- // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
- //
- // By downloading, copying, installing or using the software you agree to this license.
- // If you do not agree to this license, do not download, install,
- // copy or use the software.
- //
- //
- // License Agreement
- // For Open Source Computer Vision Library
- //
- // Copyright (C) 2013, OpenCV Foundation, all rights reserved.
- // Third party copyrights are property of their respective owners.
- //
- // Redistribution and use in source and binary forms, with or without modification,
- // are permitted provided that the following conditions are met:
- //
- // * Redistribution's of source code must retain the above copyright notice,
- // this list of conditions and the following disclaimer.
- //
- // * Redistribution's in binary form must reproduce the above copyright notice,
- // this list of conditions and the following disclaimer in the documentation
- // and/or other materials provided with the distribution.
- //
- // * The name of the copyright holders may not be used to endorse or promote products
- // derived from this software without specific prior written permission.
- //
- // This software is provided by the copyright holders and contributors "as is" and
- // any express or implied warranties, including, but not limited to, the implied
- // warranties of merchantability and fitness for a particular purpose are disclaimed.
- // In no event shall the Intel Corporation or contributors be liable for any direct,
- // indirect, incidental, special, exemplary, or consequential damages
- // (including, but not limited to, procurement of substitute goods or services;
- // loss of use, data, or profits; or business interruption) however caused
- // and on any theory of liability, whether in contract, strict liability,
- // or tort (including negligence or otherwise) arising in any way out of
- // the use of this software, even if advised of the possibility of such damage.
- //
- //M*/
-
-#include "test_precomp.hpp"
-#include "opencv2/tracking.hpp"
-#include <fstream>
-
-using namespace cv;
-using namespace testing;
-using namespace std;
-
-#define PARAM_TEST_CASE(name, ...) struct name : testing::TestWithParam< std::tr1::tuple< __VA_ARGS__ > >
-#define GET_PARAM(k) std::tr1::get< k >(GetParam())
-#define TESTSET_NAMES testing::Values("david","dudek","faceocc2")
-#define LOCATION_ERROR_THRESHOLD testing::Values(0, 10, 20, 30, 40, 50)
-#define OVERLAP_THRESHOLD testing::Values(0, 0.2, 0.4, 0.6, 0.8, 1)
-
-const string TRACKING_DIR = "tracking";
-const string FOLDER_IMG = "data";
-
-/*
- * The Evaluation Methodologies are partially based on:
- * ====================================================================================================================
- * [OTB] Y. Wu, J. Lim, and M.-H. Yang, "Online object tracking: A benchmark," in Computer Vision and Pattern Recognition (CVPR), 2013
- *
- */
-
-//Robustness Evaluation, see [OTB] chapter 4. OPE One Pass Evaluation
-class TrackerOPETest
-{
- public:
- enum
- {
- DISTANCE = 1, // test trackers based on euclidean distance
- OVERLAP = 2 // test trackers based on the overlapping ratio
- };
-
- TrackerOPETest( Ptr<Tracker> _tracker, int _testType, string _video, float _threshold );
- virtual ~TrackerOPETest();
- virtual void run();
- string getRatioSucc() const;
-
- protected:
- void checkDataTest();
-
- void distanceTest();
- void overlapTest();
-
- Ptr<Tracker> tracker;
- int testType;
- string video;
- std::vector<Rect> bbs;
- int startFrame;
- string suffix;
- string prefix;
- float threshold;
- float ratioSucc;
-
- private:
- float calcDistance( Rect a, Rect b );
- float calcOverlap( Rect a, Rect b );
- std::vector<std::string> splitString( std::string s, std::string delimiter );
-
-};
-
-TrackerOPETest::TrackerOPETest( Ptr<Tracker> _tracker, int _testType, string _video, float _threshold ) :
- tracker( _tracker ),
- testType( _testType ),
- video( _video ),
- threshold( _threshold )
-{
- startFrame = 1;
- ratioSucc = 0;
-}
-
-TrackerOPETest::~TrackerOPETest()
-{
-
-}
-
-string TrackerOPETest::getRatioSucc() const
-{
- stringstream ratio;
- ratio << ratioSucc;
- return ratio.str();
-}
-
-std::vector<std::string> TrackerOPETest::splitString( std::string s, std::string delimiter )
-{
- std::vector<string> token;
- size_t pos = 0;
- while ( ( pos = s.find( delimiter ) ) != std::string::npos )
- {
- token.push_back( s.substr( 0, pos ) );
- s.erase( 0, pos + delimiter.length() );
- }
- token.push_back( s );
- return token;
-}
-
-float TrackerOPETest::calcDistance( Rect a, Rect b )
-{
- Point2f p_a( (float)(a.x + a.width / 2), (float)(a.y + a.height / 2) );
- Point2f p_b( (float)(b.x + b.width / 2), (float)(b.y + b.height / 2) );
- return sqrt( pow( p_a.x - p_b.x, 2 ) + pow( p_a.y - p_b.y, 2 ) );
-}
-
-float TrackerOPETest::calcOverlap( Rect a, Rect b )
-{
- float aArea = (float)(a.width * a.height);
- float bArea = (float)(b.width * b.height);
-
- if( aArea < bArea )
- {
- a.x -= ( b.width - a.width ) / 2;
- a.y -= ( b.height - a.height ) / 2;
- a.width = b.width;
- a.height = b.height;
- }
- else
- {
- b.x -= ( a.width - b.width ) / 2;
- b.y -= ( a.height - b.height ) / 2;
- b.width = a.width;
- b.height = a.height;
- }
-
- Rect rectIntersection = a & b;
- Rect rectUnion = a | b;
- float iArea = (float)(rectIntersection.width * rectIntersection.height);
- float uArea = (float)(rectUnion.width * rectUnion.height);
- float overlap = iArea / uArea;
- return overlap;
-}
-
-void TrackerOPETest::distanceTest()
-{
- Mat frame;
- bool initialized = false;
-
- Rect currentBBi = bbs.at( 0 );
- Rect2d currentBB(currentBBi);
- float sumDistance = 0;
- int frameCounter = 0;
- int frameCounterSucc = 0;
- string folder = cvtest::TS::ptr()->get_data_path() + "/" + TRACKING_DIR + "/" + video + "/" + FOLDER_IMG;
-
- VideoCapture c;
- c.open( cvtest::TS::ptr()->get_data_path() + "/" + TRACKING_DIR + "/" + video + "/" + FOLDER_IMG + "/" + video + ".webm" );
- c.set( CAP_PROP_POS_FRAMES, startFrame );
- for ( ;; )
- {
- c >> frame;
-
- if( frame.empty() )
- {
- break;
- }
- if( !initialized )
- {
- if( !tracker->init( frame, currentBB ) )
- {
- FAIL()<< "Could not initialize tracker" << endl;
- return;
- }
- initialized = true;
- }
- else if( initialized )
- {
- if( frameCounter >= (int) bbs.size() )
- break;
- tracker->update( frame, currentBB );
- }
- float curDistance = calcDistance( currentBB, bbs.at( frameCounter ) );
- if( curDistance <= threshold )
- frameCounterSucc++;
- sumDistance += curDistance;
- frameCounter++;
- }
-
- float distance = sumDistance / frameCounter;
- ratioSucc = (float) frameCounterSucc / (float) frameCounter;
-
- if( distance > threshold )
- {
- FAIL()<< "Incorrect distance: curr = " << distance << ", max = " << threshold << endl;
- return;
- }
-
-}
-
-void TrackerOPETest::overlapTest()
-{
- Mat frame;
- bool initialized = false;
- Rect currentBBi = bbs.at( 0 );
- Rect2d currentBB(currentBBi);
- float sumOverlap = 0;
- string folder = cvtest::TS::ptr()->get_data_path() + TRACKING_DIR + "/" + video + "/" + FOLDER_IMG;
-
- int frameCounter = 0;
- int frameCounterSucc = 0;
-
- VideoCapture c;
- c.open( cvtest::TS::ptr()->get_data_path() + "/" + TRACKING_DIR + "/" + video + "/" + FOLDER_IMG + "/" + video + ".webm" );
- c.set( CAP_PROP_POS_FRAMES, startFrame );
-
- for ( ;; )
- {
- c >> frame;
- if( frame.empty() )
- {
- break;
- }
-
- if( !initialized )
- {
- if( !tracker->init( frame, currentBB ) )
- {
- FAIL()<< "Could not initialize tracker" << endl;
- return;
- }
- initialized = true;
- }
- else if( initialized )
- {
- if( frameCounter >= (int) bbs.size() )
- break;
- tracker->update( frame, currentBB );
- }
- float curOverlap = calcOverlap( currentBB, bbs.at( frameCounter ) );
- if( curOverlap >= threshold )
- frameCounterSucc++;
-
- sumOverlap += curOverlap;
- frameCounter++;
- }
-
- float overlap = sumOverlap / frameCounter;
- ratioSucc = (float) frameCounterSucc / (float) frameCounter;
-
- if( overlap < threshold )
- {
- FAIL()<< "Incorrect overlap: curr = " << overlap << ", min = " << threshold << endl;
- return;
- }
-}
-
-void TrackerOPETest::checkDataTest()
-{
- string gtFile = cvtest::TS::ptr()->get_data_path() + TRACKING_DIR + "/" + video + "/gt.txt";
-
- ifstream gt;
- //open the ground truth
- gt.open( gtFile.c_str() );
- if( !gt.is_open() )
- {
- FAIL()<< "Ground truth file " << gtFile << " can not be read" << endl;
- }
- string line;
- int bbCounter = 0;
- while ( getline( gt, line ) )
- {
- vector<string> tokens = splitString( line, "," );
- Rect bb( atoi( tokens.at( 0 ).c_str() ), atoi( tokens.at( 1 ).c_str() ), atoi( tokens.at( 2 ).c_str() ), atoi( tokens.at( 3 ).c_str() ) );
- if( tokens.size() != 4 )
- {
- FAIL()<< "Incorrect ground truth file";
- }
- bbs.push_back( bb );
- bbCounter++;
- }
-
- FileStorage fs;
- fs.open( cvtest::TS::ptr()->get_data_path() + TRACKING_DIR + "/" + video + "/" + video + ".yml", FileStorage::READ );
- fs["start"] >> startFrame;
- fs["prefix"] >> prefix;
- fs["suffix"] >> suffix;
- fs.release();
-
-}
-
-void TrackerOPETest::run()
-{
- srand( 1 );
-
- SCOPED_TRACE( "A" );
-
- if( !tracker )
- {
- FAIL()<< "Error in the instantiation of the tracker" << endl;
- return;
- }
-
- checkDataTest();
-
- //check for failure
- if( ::testing::Test::HasFatalFailure() )
- return;
-
- if( testType == DISTANCE )
- {
- distanceTest();
- }
- else if( testType == OVERLAP )
- {
- overlapTest();
- }
- else
- {
- FAIL()<< "Test type unknown" << endl;
- return;
- }
-
-}
-
-/****************************************************************************************\
-* Tests registrations *
- \****************************************************************************************/
-
-//[TESTDATA] [LOCATION ERROR THRESHOLD]
-PARAM_TEST_CASE(OPE_Distance, string, float)
-{
- string dataset;
- float threshold;
- virtual void SetUp()
- {
- dataset = GET_PARAM(0);
- threshold = GET_PARAM(1);
- }
-};
-
-//[TESTDATA] [OVERLAP THRESHOLD]
-PARAM_TEST_CASE(OPE_Overlap, string, float)
-{
- string dataset;
- float threshold;
- virtual void SetUp()
- {
- dataset = GET_PARAM(0);
- threshold = GET_PARAM(1);
- }
-};
-
-TEST_P(OPE_Distance, MIL)
-{
- TrackerOPETest test( Tracker::create( "MIL" ), TrackerOPETest::DISTANCE, dataset, threshold );
- test.run();
- RecordProperty( "ratioSuccess", test.getRatioSucc() );
-}
-
-TEST_P(OPE_Overlap, MIL)
-{
- TrackerOPETest test( Tracker::create( "MIL" ), TrackerOPETest::OVERLAP, dataset, threshold );
- test.run();
- RecordProperty( "ratioSuccess", test.getRatioSucc() );
-}
-
-TEST_P(OPE_Distance, Boosting)
-{
- TrackerOPETest test( Tracker::create( "BOOSTING" ), TrackerOPETest::DISTANCE, dataset, threshold );
- test.run();
- RecordProperty( "ratioSuccess", test.getRatioSucc() );
-}
-
-TEST_P(OPE_Overlap, Boosting)
-{
- TrackerOPETest test( Tracker::create( "BOOSTING" ), TrackerOPETest::OVERLAP, dataset, threshold );
- test.run();
- RecordProperty( "ratioSuccess", test.getRatioSucc() );
-}
-
-TEST_P(OPE_Distance, TLD)
-{
- TrackerOPETest test( Tracker::create( "TLD" ), TrackerOPETest::DISTANCE, dataset, threshold );
- test.run();
- RecordProperty( "ratioSuccess", test.getRatioSucc() );
-}
-
-TEST_P(OPE_Overlap, TLD)
-{
- TrackerOPETest test( Tracker::create( "TLD" ), TrackerOPETest::OVERLAP, dataset, threshold );
- test.run();
- RecordProperty( "ratioSuccess", test.getRatioSucc() );
-}
-
-TEST_P(OPE_Distance, GOTURN)
-{
- TrackerOPETest test(Tracker::create("GOTURN"), TrackerOPETest::DISTANCE, dataset, threshold);
- test.run();
- RecordProperty("ratioSuccess", test.getRatioSucc());
-}
-
-TEST_P(OPE_Overlap, GOTURN)
-{
- TrackerOPETest test(Tracker::create("GOTURN"), TrackerOPETest::OVERLAP, dataset, threshold);
- test.run();
- RecordProperty("ratioSuccess", test.getRatioSucc());
-}
-
-INSTANTIATE_TEST_CASE_P( Tracking, OPE_Distance, testing::Combine( TESTSET_NAMES, LOCATION_ERROR_THRESHOLD ) );
-
-INSTANTIATE_TEST_CASE_P( Tracking, OPE_Overlap, testing::Combine( TESTSET_NAMES, OVERLAP_THRESHOLD ) );
-
-/* End of file. */
diff --git a/contrib/modules/tracking/test/test_trackerParametersIO.cpp b/contrib/modules/tracking/test/test_trackerParametersIO.cpp
new file mode 100644
index 0000000..f385f17
--- /dev/null
+++ b/contrib/modules/tracking/test/test_trackerParametersIO.cpp
@@ -0,0 +1,127 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "test_precomp.hpp"
+#include "opencv2/tracking.hpp"
+
+using namespace cv;
+
+TEST(MEDIAN_FLOW_Parameters, IO)
+{
+ TrackerMedianFlow::Params parameters;
+
+ parameters.maxLevel = 10;
+ parameters.maxMedianLengthOfDisplacementDifference = 11;
+ parameters.pointsInGrid = 12;
+ parameters.winSize = Size(6, 5);
+ parameters.winSizeNCC = Size(41, 40);
+ parameters.termCriteria.maxCount = 100;
+ parameters.termCriteria.epsilon = 0.1;
+
+ FileStorage fsWriter("parameters.xml", FileStorage::WRITE + FileStorage::MEMORY);
+ parameters.write(fsWriter);
+
+ String serializedParameters = fsWriter.releaseAndGetString();
+
+ FileStorage fsReader(serializedParameters, FileStorage::READ + FileStorage::MEMORY);
+
+ TrackerMedianFlow::Params readParameters;
+ readParameters.read(fsReader.root());
+
+ ASSERT_EQ(parameters.maxLevel, readParameters.maxLevel);
+ ASSERT_EQ(parameters.maxMedianLengthOfDisplacementDifference,
+ readParameters.maxMedianLengthOfDisplacementDifference);
+ ASSERT_EQ(parameters.pointsInGrid, readParameters.pointsInGrid);
+ ASSERT_EQ(parameters.winSize, readParameters.winSize);
+ ASSERT_EQ(parameters.winSizeNCC, readParameters.winSizeNCC);
+ ASSERT_EQ(parameters.termCriteria.epsilon, readParameters.termCriteria.epsilon);
+ ASSERT_EQ(parameters.termCriteria.maxCount, readParameters.termCriteria.maxCount);
+}
+
+
+TEST(MEDIAN_FLOW_Parameters, Default_Value_If_Absent)
+{
+ TrackerMedianFlow::Params defaultParameters;
+
+ FileStorage fsReader(String("%YAML 1.0"), FileStorage::READ + FileStorage::MEMORY);
+
+ TrackerMedianFlow::Params readParameters;
+ readParameters.read(fsReader.root());
+
+ ASSERT_EQ(defaultParameters.maxLevel, readParameters.maxLevel);
+ ASSERT_EQ(defaultParameters.maxMedianLengthOfDisplacementDifference,
+ readParameters.maxMedianLengthOfDisplacementDifference);
+ ASSERT_EQ(defaultParameters.pointsInGrid, readParameters.pointsInGrid);
+ ASSERT_EQ(defaultParameters.winSize, readParameters.winSize);
+ ASSERT_EQ(defaultParameters.winSizeNCC, readParameters.winSizeNCC);
+ ASSERT_EQ(defaultParameters.termCriteria.epsilon, readParameters.termCriteria.epsilon);
+ ASSERT_EQ(defaultParameters.termCriteria.maxCount, readParameters.termCriteria.maxCount);
+}
+
+TEST(KCF_Parameters, IO)
+{
+ TrackerKCF::Params parameters;
+
+ parameters.sigma = 0.3;
+ parameters.lambda = 0.02;
+ parameters.interp_factor = 0.08;
+ parameters.output_sigma_factor = 1.0/ 32.0;
+ parameters.resize=false;
+ parameters.max_patch_size=90*90;
+ parameters.split_coeff=false;
+ parameters.wrap_kernel=true;
+ parameters.desc_npca = TrackerKCF::CN;
+ parameters.desc_pca = TrackerKCF::GRAY;
+ parameters.compress_feature=false;
+ parameters.compressed_size=3;
+ parameters.pca_learning_rate=0.2;
+
+ FileStorage fsWriter("parameters.xml", FileStorage::WRITE + FileStorage::MEMORY);
+ parameters.write(fsWriter);
+
+ String serializedParameters = fsWriter.releaseAndGetString();
+
+ FileStorage fsReader(serializedParameters, FileStorage::READ + FileStorage::MEMORY);
+
+ TrackerKCF::Params readParameters;
+ readParameters.read(fsReader.root());
+
+ ASSERT_DOUBLE_EQ(parameters.sigma, readParameters.sigma);
+ ASSERT_DOUBLE_EQ(parameters.lambda, readParameters.lambda);
+ ASSERT_DOUBLE_EQ(parameters.interp_factor, readParameters.interp_factor);
+ ASSERT_DOUBLE_EQ(parameters.output_sigma_factor, readParameters.output_sigma_factor);
+ ASSERT_EQ(parameters.resize, readParameters.resize);
+ ASSERT_EQ(parameters.max_patch_size, readParameters.max_patch_size);
+ ASSERT_EQ(parameters.split_coeff, readParameters.split_coeff);
+ ASSERT_EQ(parameters.wrap_kernel, readParameters.wrap_kernel);
+ ASSERT_EQ(parameters.desc_npca, readParameters.desc_npca);
+ ASSERT_EQ(parameters.desc_pca, readParameters.desc_pca);
+ ASSERT_EQ(parameters.compress_feature, readParameters.compress_feature);
+ ASSERT_EQ(parameters.compressed_size, readParameters.compressed_size);
+ ASSERT_DOUBLE_EQ(parameters.pca_learning_rate, readParameters.pca_learning_rate);
+}
+
+TEST(KCF_Parameters, Default_Value_If_Absent)
+{
+ TrackerKCF::Params defaultParameters;
+
+ FileStorage fsReader(String("%YAML 1.0"), FileStorage::READ + FileStorage::MEMORY);
+
+ TrackerKCF::Params readParameters;
+ readParameters.read(fsReader.root());
+
+ ASSERT_DOUBLE_EQ(defaultParameters.sigma, readParameters.sigma);
+ ASSERT_DOUBLE_EQ(defaultParameters.lambda, readParameters.lambda);
+ ASSERT_DOUBLE_EQ(defaultParameters.interp_factor, readParameters.interp_factor);
+ ASSERT_DOUBLE_EQ(defaultParameters.output_sigma_factor, readParameters.output_sigma_factor);
+ ASSERT_EQ(defaultParameters.resize, readParameters.resize);
+ ASSERT_EQ(defaultParameters.max_patch_size, readParameters.max_patch_size);
+ ASSERT_EQ(defaultParameters.split_coeff, readParameters.split_coeff);
+ ASSERT_EQ(defaultParameters.wrap_kernel, readParameters.wrap_kernel);
+ ASSERT_EQ(defaultParameters.desc_npca, readParameters.desc_npca);
+ ASSERT_EQ(defaultParameters.desc_pca, readParameters.desc_pca);
+ ASSERT_EQ(defaultParameters.compress_feature, readParameters.compress_feature);
+ ASSERT_EQ(defaultParameters.compressed_size, readParameters.compressed_size);
+ ASSERT_DOUBLE_EQ(defaultParameters.pca_learning_rate, readParameters.pca_learning_rate);
+}
diff --git a/contrib/modules/tracking/test/test_trackerSRE.cpp b/contrib/modules/tracking/test/test_trackerSRE.cpp
deleted file mode 100644
index c50437b..0000000
--- a/contrib/modules/tracking/test/test_trackerSRE.cpp
+++ /dev/null
@@ -1,550 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
- //
- // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
- //
- // By downloading, copying, installing or using the software you agree to this license.
- // If you do not agree to this license, do not download, install,
- // copy or use the software.
- //
- //
- // License Agreement
- // For Open Source Computer Vision Library
- //
- // Copyright (C) 2013, OpenCV Foundation, all rights reserved.
- // Third party copyrights are property of their respective owners.
- //
- // Redistribution and use in source and binary forms, with or without modification,
- // are permitted provided that the following conditions are met:
- //
- // * Redistribution's of source code must retain the above copyright notice,
- // this list of conditions and the following disclaimer.
- //
- // * Redistribution's in binary form must reproduce the above copyright notice,
- // this list of conditions and the following disclaimer in the documentation
- // and/or other materials provided with the distribution.
- //
- // * The name of the copyright holders may not be used to endorse or promote products
- // derived from this software without specific prior written permission.
- //
- // This software is provided by the copyright holders and contributors "as is" and
- // any express or implied warranties, including, but not limited to, the implied
- // warranties of merchantability and fitness for a particular purpose are disclaimed.
- // In no event shall the Intel Corporation or contributors be liable for any direct,
- // indirect, incidental, special, exemplary, or consequential damages
- // (including, but not limited to, procurement of substitute goods or services;
- // loss of use, data, or profits; or business interruption) however caused
- // and on any theory of liability, whether in contract, strict liability,
- // or tort (including negligence or otherwise) arising in any way out of
- // the use of this software, even if advised of the possibility of such damage.
- //
- //M*/
-
-#include "test_precomp.hpp"
-#include "opencv2/tracking.hpp"
-#include <fstream>
-
-using namespace cv;
-using namespace testing;
-using namespace std;
-
-#define PARAM_TEST_CASE(name, ...) struct name : testing::TestWithParam< std::tr1::tuple< __VA_ARGS__ > >
-#define GET_PARAM(k) std::tr1::get< k >(GetParam())
-#define TESTSET_NAMES testing::Values("david","dudek","faceocc2")
-#define LOCATION_ERROR_THRESHOLD testing::Values(0, 10, 20, 30, 40, 50)
-#define OVERLAP_THRESHOLD testing::Values(0, 0.2, 0.4, 0.6, 0.8, 1)
-
-#define SPATIAL_SHIFTS testing::Values(1, 2, 3, 4, 5, 6, 7, 8, 9, 10 , 11, 12)
-
-const string TRACKING_DIR = "tracking";
-const string FOLDER_IMG = "data";
-
-/*
- * The Evaluation Methodologies are partially based on:
- * ====================================================================================================================
- * [OTB] Y. Wu, J. Lim, and M.-H. Yang, "Online object tracking: A benchmark," in Computer Vision and Pattern Recognition (CVPR), 2013
- *
- */
-
-//Robustness Evaluation, see [OTB] chapter 4. SRE Spatial robustness evaluation
-class TrackerSRETest
-{
- public:
- enum
- {
- DISTANCE = 1, // test trackers based on euclidean distance
- OVERLAP = 2 // test trackers based on the overlapping ratio
- };
-
- TrackerSRETest( const Ptr<Tracker> _tracker, int _testType, string _video, int _shift, float _threshold );
- virtual ~TrackerSRETest();
- virtual void run();
- string getRatioSucc() const;
-
- protected:
- void checkDataTest();
-
- void distanceTest();
- void overlapTest();
-
- Ptr<Tracker> tracker;
- int testType;
- string video;
- std::vector<Rect> bbs;
- int startFrame;
- string suffix;
- string prefix;
- float threshold;
- int shift;
- float ratioSucc;
-
- private:
- float calcDistance( Rect a, Rect b );
- float calcOverlap( Rect a, Rect b );
- std::vector<std::string> splitString( std::string s, std::string delimiter );
-
-};
-
-TrackerSRETest::TrackerSRETest( const Ptr<Tracker> _tracker, int _testType, string _video, int _shift, float _threshold ) :
- tracker( _tracker ),
- testType( _testType ),
- video( _video ),
- threshold( _threshold ),
- shift( _shift )
-{
- startFrame = 1;
- ratioSucc = 0;
-}
-
-TrackerSRETest::~TrackerSRETest()
-{
-
-}
-
-string TrackerSRETest::getRatioSucc() const
-{
- stringstream ratio;
- ratio << ratioSucc;
- return ratio.str();
-}
-
-std::vector<std::string> TrackerSRETest::splitString( std::string s, std::string delimiter )
-{
- std::vector<string> token;
- size_t pos = 0;
- while ( ( pos = s.find( delimiter ) ) != std::string::npos )
- {
- token.push_back( s.substr( 0, pos ) );
- s.erase( 0, pos + delimiter.length() );
- }
- token.push_back( s );
- return token;
-}
-
-float TrackerSRETest::calcDistance( Rect a, Rect b )
-{
- Point2f p_a( (float)(a.x + a.width / 2), (float)(a.y + a.height / 2) );
- Point2f p_b( (float)(b.x + b.width / 2), (float)(b.y + b.height / 2) );
- return sqrt( pow( p_a.x - p_b.x, 2 ) + pow( p_a.y - p_b.y, 2 ) );
-}
-
-float TrackerSRETest::calcOverlap( Rect a, Rect b )
-{
- float aArea = (float)(a.width * a.height);
- float bArea = (float)(b.width * b.height);
-
- if( aArea < bArea )
- {
- a.x -= ( b.width - a.width ) / 2;
- a.y -= ( b.height - a.height ) / 2;
- a.width = b.width;
- a.height = b.height;
- }
- else
- {
- b.x -= ( a.width - b.width ) / 2;
- b.y -= ( a.height - b.height ) / 2;
- b.width = a.width;
- b.height = a.height;
- }
-
- Rect rectIntersection = a & b;
- Rect rectUnion = a | b;
- float iArea = (float)(rectIntersection.width * rectIntersection.height);
- float uArea = (float)(rectUnion.width * rectUnion.height);
- float overlap = iArea / uArea;
- return overlap;
-}
-
-void TrackerSRETest::distanceTest()
-{
- Mat frame;
- bool initialized = false;
-
- Rect currentBBi = bbs.at( 0 );
- Rect2d currentBB(currentBBi);
- float sumDistance = 0;
- int frameCounter = 0;
- int frameCounterSucc = 0;
- string folder = cvtest::TS::ptr()->get_data_path() + TRACKING_DIR + "/" + video + "/" + FOLDER_IMG;
-
- VideoCapture c;
- c.open( cvtest::TS::ptr()->get_data_path() + "/" + TRACKING_DIR + "/" + video + "/" + FOLDER_IMG + "/" + video + ".webm" );
- c.set( CAP_PROP_POS_FRAMES, startFrame );
-
- for ( ;; )
- {
- c >> frame;
- if( frame.empty() )
- {
- break;
- }
- if( !initialized )
- {
- if( !tracker->init( frame, currentBB ) )
- {
- FAIL()<< "Could not initialize tracker" << endl;
- return;
- }
- initialized = true;
- }
- else if( initialized )
- {
- if( frameCounter >= (int) bbs.size() )
- break;
- tracker->update( frame, currentBB );
- }
-
- float curDistance = calcDistance( currentBB, bbs.at( frameCounter ) );
- if( curDistance <= threshold )
- frameCounterSucc++;
- sumDistance += curDistance;
- frameCounter++;
- }
-
- float distance = sumDistance / frameCounter;
- ratioSucc = (float) frameCounterSucc / (float) frameCounter;
-
- if( distance > threshold )
- {
- FAIL()<< "Incorrect distance: curr = " << distance << ", max = " << threshold << endl;
- return;
- }
-
-}
-
-void TrackerSRETest::overlapTest()
-{
- Mat frame;
- bool initialized = false;
- Rect currentBBi = bbs.at( 0 );
- Rect2d currentBB(currentBBi);
- float sumOverlap = 0;
- string folder = cvtest::TS::ptr()->get_data_path() + TRACKING_DIR + "/" + video + "/" + FOLDER_IMG;
-
- int frameCounter = 0;
- int frameCounterSucc = 0;
-
- VideoCapture c;
- c.open( cvtest::TS::ptr()->get_data_path() + "/" + TRACKING_DIR + "/" + video + "/" + FOLDER_IMG + "/" + video + ".webm" );
- c.set( CAP_PROP_POS_FRAMES, startFrame );
-
- for ( ;; )
- {
- c >> frame;
- if( frame.empty() )
- {
- break;
- }
-
- if( !initialized )
- {
- if( !tracker->init( frame, currentBB ) )
- {
- FAIL()<< "Could not initialize tracker" << endl;
- return;
- }
- initialized = true;
- }
- else if( initialized )
- {
- if( frameCounter >= (int) bbs.size() )
- break;
- tracker->update( frame, currentBB );
- }
- float curOverlap = calcOverlap( currentBB, bbs.at( frameCounter ) );
- if( curOverlap >= threshold )
- frameCounterSucc++;
-
- sumOverlap += curOverlap;
- frameCounter++;
- }
-
- float overlap = sumOverlap / frameCounter;
- ratioSucc = (float) frameCounterSucc / (float) frameCounter;
-
- if( overlap < threshold )
- {
- FAIL()<< "Incorrect overlap: curr = " << overlap << ", min = " << threshold << endl;
- return;
- }
-}
-
-void TrackerSRETest::checkDataTest()
-{
- string gtFile = cvtest::TS::ptr()->get_data_path() + TRACKING_DIR + "/" + video + "/gt.txt";
-
- ifstream gt;
- //open the ground truth
- gt.open( gtFile.c_str() );
- if( !gt.is_open() )
- {
- FAIL()<< "Ground truth file " << gtFile << " can not be read" << endl;
- }
- string line;
- int bbCounter = 0;
- while ( getline( gt, line ) )
- {
- vector<string> tokens = splitString( line, "," );
- Rect bb( atoi( tokens.at( 0 ).c_str() ), atoi( tokens.at( 1 ).c_str() ), atoi( tokens.at( 2 ).c_str() ), atoi( tokens.at( 3 ).c_str() ) );
- if( tokens.size() != 4 )
- {
- FAIL()<< "Incorrect ground truth file";
- }
-
- //apply the shift
- if( bbCounter == 0 )
- {
- Point center( bb.x + ( bb.width / 2 ), bb.y + ( bb.height / 2 ) );
-
- int xLimit = bb.x + bb.width - 1;
- int yLimit = bb.y + bb.height - 1;
-
- int h = 0;
- int w = 0;
- float ratio = 1.0;
-
- switch ( shift )
- {
- case 1:
- //center shift left
- bb.x = bb.x - (int)ceil( 0.1 * bb.width );
- break;
- case 2:
- //center shift right
- bb.x = bb.x + (int)ceil( 0.1 * bb.width );
- break;
- case 3:
- //center shift up
- bb.y = bb.y - (int)ceil( 0.1 * bb.height );
- break;
- case 4:
- //center shift down
- bb.y = bb.y + (int)ceil( 0.1 * bb.height );
- break;
- case 5:
- //corner shift top-left
- bb.x = (int)cvRound( bb.x - 0.1 * bb.width );
- bb.y = (int)cvRound( bb.y - 0.1 * bb.height );
-
- bb.width = xLimit - bb.x + 1;
- bb.height = yLimit - bb.y + 1;
- break;
- case 6:
- //corner shift top-right
- xLimit = (int)cvRound( xLimit + 0.1 * bb.width );
-
- bb.y = (int)cvRound( bb.y - 0.1 * bb.height );
- bb.width = xLimit - bb.x + 1;
- bb.height = yLimit - bb.y + 1;
- break;
- case 7:
- //corner shift bottom-left
- bb.x = (int)cvRound( bb.x - 0.1 * bb.width );
- yLimit = (int)cvRound( yLimit + 0.1 * bb.height );
-
- bb.width = xLimit - bb.x + 1;
- bb.height = yLimit - bb.y + 1;
- break;
- case 8:
- //corner shift bottom-right
- xLimit = (int)cvRound( xLimit + 0.1 * bb.width );
- yLimit = (int)cvRound( yLimit + 0.1 * bb.height );
-
- bb.width = xLimit - bb.x + 1;
- bb.height = yLimit - bb.y + 1;
- break;
- case 9:
- //scale 0.8
- ratio = 0.8f;
- w = (int)(ratio * bb.width);
- h = (int)(ratio * bb.height);
-
- bb = Rect( center.x - ( w / 2 ), center.y - ( h / 2 ), w, h );
- break;
- case 10:
- //scale 0.9
- ratio = 0.9f;
- w = (int)(ratio * bb.width);
- h = (int)(ratio * bb.height);
-
- bb = Rect( center.x - ( w / 2 ), center.y - ( h / 2 ), w, h );
- break;
- case 11:
- //scale 1.1
- ratio = 1.1f;
- w = (int)(ratio * bb.width);
- h = (int)(ratio * bb.height);
-
- bb = Rect( center.x - ( w / 2 ), center.y - ( h / 2 ), w, h );
- break;
- case 12:
- //scale 1.2
- ratio = 1.2f;
- w = (int)(ratio * bb.width);
- h = (int)(ratio * bb.height);
-
- bb = Rect( center.x - ( w / 2 ), center.y - ( h / 2 ), w, h );
- break;
- default:
- break;
- }
- }
- bbs.push_back( bb );
- bbCounter++;
- }
-
- FileStorage fs;
- fs.open( cvtest::TS::ptr()->get_data_path() + TRACKING_DIR + "/" + video + "/" + video + ".yml", FileStorage::READ );
- fs["start"] >> startFrame;
- fs["prefix"] >> prefix;
- fs["suffix"] >> suffix;
- fs.release();
-
-}
-
-void TrackerSRETest::run()
-{
- srand( 1 );
- SCOPED_TRACE( "A" );
-
- if( !tracker )
- {
- FAIL()<< "Error in the instantiation of the tracker" << endl;
- return;
- }
-
- checkDataTest();
-
- //check for failure
- if( ::testing::Test::HasFatalFailure() )
- return;
-
- if( testType == DISTANCE )
- {
- distanceTest();
- }
- else if( testType == OVERLAP )
- {
- overlapTest();
- }
- else
- {
- FAIL()<< "Test type unknown" << endl;
- return;
- }
-
-}
-
-/****************************************************************************************\
-* Tests registrations *
- \****************************************************************************************/
-
-//[TESTDATA] [#SHIFT] [LOCATION ERROR THRESHOLD]
-PARAM_TEST_CASE(SRE_Distance, string, int, float)
-{
- string dataset;
- int shift;
- float threshold;
- virtual void SetUp()
- {
- dataset = GET_PARAM(0);
- shift = GET_PARAM(1);
- threshold = GET_PARAM(2);
- }
-};
-
-//[TESTDATA] [#SHIFT] [OVERLAP THRESHOLD]
-PARAM_TEST_CASE(SRE_Overlap, string, int, float)
-{
- string dataset;
- int shift;
- float threshold;
- virtual void SetUp()
- {
- dataset = GET_PARAM(0);
- shift = GET_PARAM(1);
- threshold = GET_PARAM(2);
- }
-};
-
-TEST_P(SRE_Distance, MIL)
-{
- TrackerSRETest test( Tracker::create( "MIL" ), TrackerSRETest::DISTANCE, dataset, shift, threshold );
- test.run();
- RecordProperty( "ratioSuccess", test.getRatioSucc() );
-}
-
-TEST_P(SRE_Overlap, MIL)
-{
- TrackerSRETest test( Tracker::create( "MIL" ), TrackerSRETest::OVERLAP, dataset, shift, threshold );
- test.run();
- RecordProperty( "ratioSuccess", test.getRatioSucc() );
-}
-
-TEST_P(SRE_Distance, Boosting)
-{
- TrackerSRETest test( Tracker::create( "BOOSTING" ), TrackerSRETest::DISTANCE, dataset, shift, threshold );
- test.run();
- RecordProperty( "ratioSuccess", test.getRatioSucc() );
-}
-
-TEST_P(SRE_Overlap, Boosting)
-{
- TrackerSRETest test( Tracker::create( "BOOSTING" ), TrackerSRETest::OVERLAP, dataset, shift, threshold );
- test.run();
- RecordProperty( "ratioSuccess", test.getRatioSucc() );
-}
-
-TEST_P(SRE_Distance, TLD)
-{
- TrackerSRETest test( Tracker::create( "TLD" ), TrackerSRETest::DISTANCE, dataset, shift, threshold );
- test.run();
- RecordProperty( "ratioSuccess", test.getRatioSucc() );
-}
-
-TEST_P(SRE_Overlap, TLD)
-{
- TrackerSRETest test( Tracker::create( "TLD" ), TrackerSRETest::OVERLAP, dataset, shift, threshold );
- test.run();
- RecordProperty( "ratioSuccess", test.getRatioSucc() );
-}
-
-TEST_P(SRE_Distance, GOTURN)
-{
- TrackerSRETest test(Tracker::create("GOTURN"), TrackerSRETest::DISTANCE, dataset, shift, threshold);
- test.run();
- RecordProperty("ratioSuccess", test.getRatioSucc());
-}
-
-TEST_P(SRE_Overlap, GOTURN)
-{
- TrackerSRETest test(Tracker::create("GOTURN"), TrackerSRETest::OVERLAP, dataset, shift, threshold);
- test.run();
- RecordProperty("ratioSuccess", test.getRatioSucc());
-}
-
-INSTANTIATE_TEST_CASE_P( Tracking, SRE_Distance, testing::Combine( TESTSET_NAMES, SPATIAL_SHIFTS, LOCATION_ERROR_THRESHOLD ) );
-
-INSTANTIATE_TEST_CASE_P( Tracking, SRE_Overlap, testing::Combine( TESTSET_NAMES, SPATIAL_SHIFTS, OVERLAP_THRESHOLD ) );
-
-/* End of file. */
diff --git a/contrib/modules/tracking/test/test_trackerTRE.cpp b/contrib/modules/tracking/test/test_trackerTRE.cpp
deleted file mode 100644
index d771ff1..0000000
--- a/contrib/modules/tracking/test/test_trackerTRE.cpp
+++ /dev/null
@@ -1,520 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
- //
- // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
- //
- // By downloading, copying, installing or using the software you agree to this license.
- // If you do not agree to this license, do not download, install,
- // copy or use the software.
- //
- //
- // License Agreement
- // For Open Source Computer Vision Library
- //
- // Copyright (C) 2013, OpenCV Foundation, all rights reserved.
- // Third party copyrights are property of their respective owners.
- //
- // Redistribution and use in source and binary forms, with or without modification,
- // are permitted provided that the following conditions are met:
- //
- // * Redistribution's of source code must retain the above copyright notice,
- // this list of conditions and the following disclaimer.
- //
- // * Redistribution's in binary form must reproduce the above copyright notice,
- // this list of conditions and the following disclaimer in the documentation
- // and/or other materials provided with the distribution.
- //
- // * The name of the copyright holders may not be used to endorse or promote products
- // derived from this software without specific prior written permission.
- //
- // This software is provided by the copyright holders and contributors "as is" and
- // any express or implied warranties, including, but not limited to, the implied
- // warranties of merchantability and fitness for a particular purpose are disclaimed.
- // In no event shall the Intel Corporation or contributors be liable for any direct,
- // indirect, incidental, special, exemplary, or consequential damages
- // (including, but not limited to, procurement of substitute goods or services;
- // loss of use, data, or profits; or business interruption) however caused
- // and on any theory of liability, whether in contract, strict liability,
- // or tort (including negligence or otherwise) arising in any way out of
- // the use of this software, even if advised of the possibility of such damage.
- //
- //M*/
-
-#include "test_precomp.hpp"
-#include "opencv2/tracking.hpp"
-#include <fstream>
-#include <algorithm>
-
-using namespace cv;
-using namespace testing;
-using namespace std;
-
-#define PARAM_TEST_CASE(name, ...) struct name : testing::TestWithParam< std::tr1::tuple< __VA_ARGS__ > >
-#define GET_PARAM(k) std::tr1::get< k >(GetParam())
-#define TESTSET_NAMES testing::Values("david","dudek","faceocc2")
-#define LOCATION_ERROR_THRESHOLD testing::Values(0, 10, 20, 30, 40, 50)
-#define OVERLAP_THRESHOLD testing::Values(0, 0.2, 0.4, 0.6, 0.8, 1)
-//Fixed sampling on the images sequence
-#define SEGMENTS testing::Values(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
-
-const string TRACKING_DIR = "tracking";
-const string FOLDER_IMG = "data";
-const string FOLDER_OMIT_INIT = "initOmit";
-
-/*
- * The Evaluation Methodologies are partially based on:
- * ====================================================================================================================
- * [OTB] Y. Wu, J. Lim, and M.-H. Yang, "Online object tracking: A benchmark," in Computer Vision and Pattern Recognition (CVPR), 2013
- *
- */
-
-//Robustness Evaluation, see [OTB] chapter 4. temporal robustness evaluation
-//each sequence is partitioned into 10 (fixed) segments, slight change respect to [OTB]
-class TrackerTRETest
-{
- public:
- enum
- {
- DISTANCE = 1, // test trackers based on euclidean distance
- OVERLAP = 2 // test trackers based on the overlapping ratio
- };
-
- TrackerTRETest( const Ptr<Tracker> _tracker, int _testType, string _video, float _threshold, int _segmentIdx );
- virtual ~TrackerTRETest();
- virtual void run();
- string getRatioSucc() const;
-
- protected:
- void checkDataTest();
-
- void distanceTest();
- void overlapTest();
-
- Ptr<Tracker> tracker;
- int testType;
- string video;
- std::vector<Rect> bbs;
- int gtStartFrame;
- int startFrame;
- int endFrame;
- string suffix;
- string prefix;
- float threshold;
- int segmentIdx;
- vector<int> validSequence;
- float ratioSucc;
-
- private:
- float calcDistance( Rect a, Rect b );
- float calcOverlap( Rect a, Rect b );
- std::vector<std::string> splitString( std::string s, std::string delimiter );
-
-};
-
-TrackerTRETest::TrackerTRETest( const Ptr<Tracker> _tracker, int _testType, string _video, float _threshold, int _segmentIdx ) :
- tracker( _tracker ),
- testType( _testType ),
- video( _video ),
- threshold( _threshold ),
- segmentIdx( _segmentIdx )
-{
- startFrame = 1;
- endFrame = 1;
- gtStartFrame = 1;
- ratioSucc = 0;
-}
-
-TrackerTRETest::~TrackerTRETest()
-{
-
-}
-
-string TrackerTRETest::getRatioSucc() const
-{
- stringstream ratio;
- ratio << ratioSucc;
- return ratio.str();
-}
-
-std::vector<std::string> TrackerTRETest::splitString( std::string s, std::string delimiter )
-{
- std::vector<string> token;
- size_t pos = 0;
- while ( ( pos = s.find( delimiter ) ) != std::string::npos )
- {
- token.push_back( s.substr( 0, pos ) );
- s.erase( 0, pos + delimiter.length() );
- }
- token.push_back( s );
- return token;
-}
-
-float TrackerTRETest::calcDistance( Rect a, Rect b )
-{
- Point2f p_a( (float)(a.x + a.width / 2), (float)(a.y + a.height / 2) );
- Point2f p_b( (float)(b.x + b.width / 2), (float)(b.y + b.height / 2) );
- return sqrt( pow( p_a.x - p_b.x, 2 ) + pow( p_a.y - p_b.y, 2 ) );
-}
-
-float TrackerTRETest::calcOverlap( Rect a, Rect b )
-{
- float aArea = (float)(a.width * a.height);
- float bArea = (float)(b.width * b.height);
-
- if( aArea < bArea )
- {
- a.x -= ( b.width - a.width ) / 2;
- a.y -= ( b.height - a.height ) / 2;
- a.width = b.width;
- a.height = b.height;
- }
- else
- {
- b.x -= ( a.width - b.width ) / 2;
- b.y -= ( a.height - b.height ) / 2;
- b.width = a.width;
- b.height = a.height;
- }
-
- Rect rectIntersection = a & b;
- Rect rectUnion = a | b;
- float iArea = (float)(rectIntersection.width * rectIntersection.height);
- float uArea = (float)(rectUnion.width * rectUnion.height);
- float overlap = iArea / uArea;
- return overlap;
-}
-
-void TrackerTRETest::distanceTest()
-{
- Mat frame;
- bool initialized = false;
-
- int fc = ( startFrame - gtStartFrame );
-
- Rect currentBBi = bbs.at( fc );
- Rect2d currentBB(currentBBi);
- float sumDistance = 0;
- string folder = cvtest::TS::ptr()->get_data_path() + TRACKING_DIR + "/" + video + "/" + FOLDER_IMG;
-
- int frameTotal = 0;
- int frameTotalSucc = 0;
-
- VideoCapture c;
- c.open( cvtest::TS::ptr()->get_data_path() + "/" + TRACKING_DIR + "/" + video + "/" + FOLDER_IMG + "/" + video + ".webm" );
- c.set( CAP_PROP_POS_FRAMES, startFrame );
-
- for ( int frameCounter = startFrame; frameCounter < endFrame; frameCounter++ )
- {
- c >> frame;
- if( frame.empty() )
- {
- break;
- }
- if( !initialized )
- {
- if( !tracker->init( frame, currentBB ) )
- {
- FAIL()<< "Could not initialize tracker" << endl;
- return;
- }
- initialized = true;
- }
- else if( initialized )
- {
- if( frameCounter >= (int) bbs.size() )
- break;
- tracker->update( frame, currentBB );
- }
-
- float curDistance = calcDistance( currentBB, bbs.at( fc ) );
- if( curDistance <= threshold )
- frameTotalSucc++;
- sumDistance += curDistance;
-
- fc++;
- frameTotal++;
- }
-
- float distance = sumDistance / ( fc - ( startFrame - gtStartFrame ) );
- ratioSucc = (float) frameTotalSucc / (float) frameTotal;
-
- if( distance > threshold )
- {
- FAIL()<< "Incorrect distance: curr = " << distance << ", min = " << threshold << endl;
- return;
- }
-
-}
-
-void TrackerTRETest::overlapTest()
-{
- Mat frame;
- bool initialized = false;
-
- int fc = ( startFrame - gtStartFrame );
- Rect currentBBi = bbs.at( fc );
- Rect2d currentBB(currentBBi);
- float sumOverlap = 0;
- string folder = cvtest::TS::ptr()->get_data_path() + TRACKING_DIR + "/" + video + "/" + FOLDER_IMG;
-
- int frameTotal = 0;
- int frameTotalSucc = 0;
-
- VideoCapture c;
- c.open( cvtest::TS::ptr()->get_data_path() + "/" + TRACKING_DIR + "/" + video + "/" + FOLDER_IMG + "/" + video + ".webm" );
- c.set( CAP_PROP_POS_FRAMES, startFrame );
-
- for ( int frameCounter = startFrame; frameCounter < endFrame; frameCounter++ )
- {
- c >> frame;
- if( frame.empty() )
- {
- break;
- }
-
- if( !initialized )
- {
- if( !tracker->init( frame, currentBB ) )
- {
- FAIL()<< "Could not initialize tracker" << endl;
- return;
- }
- initialized = true;
- }
- else if( initialized )
- {
- if( frameCounter >= (int) bbs.size() )
- break;
- tracker->update( frame, currentBB );
- }
- float curOverlap = calcOverlap( currentBB, bbs.at( fc ) );
- if( curOverlap >= threshold )
- frameTotalSucc++;
-
- sumOverlap += curOverlap;
- frameTotal++;
- fc++;
- }
-
- float overlap = sumOverlap / ( fc - ( startFrame - gtStartFrame ) );
- ratioSucc = (float) frameTotalSucc / (float) frameTotal;
-
- if( overlap < threshold )
- {
- FAIL()<< "Incorrect overlap: curr = " << overlap << ", min = " << threshold << endl;
- return;
- }
-}
-
-void TrackerTRETest::checkDataTest()
-{
-
- FileStorage fs;
- fs.open( cvtest::TS::ptr()->get_data_path() + TRACKING_DIR + "/" + video + "/" + video + ".yml", FileStorage::READ );
- fs["start"] >> startFrame;
- fs["prefix"] >> prefix;
- fs["suffix"] >> suffix;
- fs.release();
-
- string gtFile = cvtest::TS::ptr()->get_data_path() + TRACKING_DIR + "/" + video + "/gt.txt";
- ifstream gt;
- //open the ground truth
- gt.open( gtFile.c_str() );
- if( !gt.is_open() )
- {
- FAIL()<< "Ground truth file " << gtFile << " can not be read" << endl;
- }
- string line;
- int bbCounter = 0;
- while ( getline( gt, line ) )
- {
- bbCounter++;
- }
- gt.close();
-
- int seqLength = bbCounter;
- for ( int i = startFrame; i < seqLength; i++ )
- {
- validSequence.push_back( i );
- }
-
- //exclude from the images sequence, the frames where the target is occluded or out of view
- string omitFile = cvtest::TS::ptr()->get_data_path() + TRACKING_DIR + "/" + video + "/" + FOLDER_OMIT_INIT + "/" + video + ".txt";
- ifstream omit;
- omit.open( omitFile.c_str() );
- if( omit.is_open() )
- {
- string omitLine;
- while ( getline( omit, omitLine ) )
- {
- vector<string> tokens = splitString( omitLine, " " );
- int s_start = atoi( tokens.at( 0 ).c_str() );
- int s_end = atoi( tokens.at( 1 ).c_str() );
- for ( int k = s_start; k <= s_end; k++ )
- {
- std::vector<int>::iterator position = std::find( validSequence.begin(), validSequence.end(), k );
- if( position != validSequence.end() )
- validSequence.erase( position );
- }
- }
- }
- omit.close();
- gtStartFrame = startFrame;
- //compute the start and the and for each segment
- int segmentLength = sizeof ( SEGMENTS)/sizeof(int);
- int numFrame = (int)(validSequence.size() / segmentLength);
- startFrame += ( segmentIdx - 1 ) * numFrame;
- endFrame = startFrame + numFrame;
-
- ifstream gt2;
- //open the ground truth
- gt2.open( gtFile.c_str() );
- if( !gt2.is_open() )
- {
- FAIL()<< "Ground truth file " << gtFile << " can not be read" << endl;
- }
- string line2;
- int bbCounter2 = 0;
- while ( getline( gt2, line2 ) )
- {
- vector<string> tokens = splitString( line2, "," );
- Rect bb( atoi( tokens.at( 0 ).c_str() ), atoi( tokens.at( 1 ).c_str() ), atoi( tokens.at( 2 ).c_str() ), atoi( tokens.at( 3 ).c_str() ) );
- if( tokens.size() != 4 )
- {
- FAIL()<< "Incorrect ground truth file";
- }
-
- bbs.push_back( bb );
- bbCounter2++;
- }
- gt2.close();
-
- if( segmentIdx == ( sizeof ( SEGMENTS)/sizeof(int) ) )
- endFrame = (int)bbs.size();
-}
-
-void TrackerTRETest::run()
-{
- srand( 1 );
- SCOPED_TRACE( "A" );
-
- if( !tracker )
- {
- FAIL()<< "Error in the instantiation of the tracker" << endl;
- return;
- }
-
- checkDataTest();
-
- //check for failure
- if( ::testing::Test::HasFatalFailure() )
- return;
-
- if( testType == DISTANCE )
- {
- distanceTest();
- }
- else if( testType == OVERLAP )
- {
- overlapTest();
- }
- else
- {
- FAIL()<< "Test type unknown" << endl;
- return;
- }
-
-}
-
-/****************************************************************************************\
-* Tests registrations *
- \****************************************************************************************/
-
-//[TESTDATA] [#SEGMENT] [LOCATION ERROR THRESHOLD]
-PARAM_TEST_CASE(TRE_Distance, string, int, float)
-{
- int segment;
- string dataset;
- float threshold;
- virtual void SetUp()
- {
- dataset = GET_PARAM(0);
- segment = GET_PARAM(1);
- threshold = GET_PARAM(2);
- }
-};
-
-//[TESTDATA] [#SEGMENT] [OVERLAP THRESHOLD]
-PARAM_TEST_CASE(TRE_Overlap, string, int, float)
-{
- int segment;
- string dataset;
- float threshold;
- virtual void SetUp()
- {
- dataset = GET_PARAM(0);
- segment = GET_PARAM(1);
- threshold = GET_PARAM(2);
- }
-};
-
-TEST_P(TRE_Distance, MIL)
-{
- TrackerTRETest test( Tracker::create( "MIL" ), TrackerTRETest::DISTANCE, dataset, threshold, segment );
- test.run();
- RecordProperty( "ratioSuccess", test.getRatioSucc() );
-}
-
-TEST_P(TRE_Overlap, MIL)
-{
- TrackerTRETest test( Tracker::create( "MIL" ), TrackerTRETest::OVERLAP, dataset, threshold, segment );
- test.run();
- RecordProperty( "ratioSuccess", test.getRatioSucc() );
-}
-
-TEST_P(TRE_Distance, Boosting)
-{
- TrackerTRETest test( Tracker::create( "BOOSTING" ), TrackerTRETest::DISTANCE, dataset, threshold, segment );
- test.run();
- RecordProperty( "ratioSuccess", test.getRatioSucc() );
-}
-
-TEST_P(TRE_Overlap, Boosting)
-{
- TrackerTRETest test( Tracker::create( "BOOSTING" ), TrackerTRETest::OVERLAP, dataset, threshold, segment );
- test.run();
- RecordProperty( "ratioSuccess", test.getRatioSucc() );
-}
-
-TEST_P(TRE_Distance, TLD)
-{
- TrackerTRETest test( Tracker::create( "TLD" ), TrackerTRETest::DISTANCE, dataset, threshold, segment );
- test.run();
- RecordProperty( "ratioSuccess", test.getRatioSucc() );
-}
-
-TEST_P(TRE_Overlap, TLD)
-{
- TrackerTRETest test( Tracker::create( "TLD" ), TrackerTRETest::OVERLAP, dataset, threshold, segment );
- test.run();
- RecordProperty( "ratioSuccess", test.getRatioSucc() );
-}
-
-TEST_P(TRE_Distance, GOTURN)
-{
- TrackerTRETest test(Tracker::create("GOTURN"), TrackerTRETest::DISTANCE, dataset, threshold, segment);
- test.run();
- RecordProperty("ratioSuccess", test.getRatioSucc());
-}
-
-TEST_P(TRE_Overlap, GOTURN)
-{
- TrackerTRETest test(Tracker::create("GOTURN"), TrackerTRETest::OVERLAP, dataset, threshold, segment);
- test.run();
- RecordProperty("ratioSuccess", test.getRatioSucc());
-}
-
-INSTANTIATE_TEST_CASE_P( Tracking, TRE_Distance, testing::Combine( TESTSET_NAMES, SEGMENTS, LOCATION_ERROR_THRESHOLD ) );
-
-INSTANTIATE_TEST_CASE_P( Tracking, TRE_Overlap, testing::Combine( TESTSET_NAMES, SEGMENTS, OVERLAP_THRESHOLD ) );
-
-/* End of file. */
diff --git a/contrib/modules/tracking/test/test_trackers.cpp b/contrib/modules/tracking/test/test_trackers.cpp
new file mode 100644
index 0000000..60788a6
--- /dev/null
+++ b/contrib/modules/tracking/test/test_trackers.cpp
@@ -0,0 +1,541 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+ //
+ // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+ //
+ // By downloading, copying, installing or using the software you agree to this license.
+ // If you do not agree to this license, do not download, install,
+ // copy or use the software.
+ //
+ //
+ // License Agreement
+ // For Open Source Computer Vision Library
+ //
+ // Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+ // Third party copyrights are property of their respective owners.
+ //
+ // Redistribution and use in source and binary forms, with or without modification,
+ // are permitted provided that the following conditions are met:
+ //
+ // * Redistribution's of source code must retain the above copyright notice,
+ // this list of conditions and the following disclaimer.
+ //
+ // * Redistribution's in binary form must reproduce the above copyright notice,
+ // this list of conditions and the following disclaimer in the documentation
+ // and/or other materials provided with the distribution.
+ //
+ // * The name of the copyright holders may not be used to endorse or promote products
+ // derived from this software without specific prior written permission.
+ //
+ // This software is provided by the copyright holders and contributors "as is" and
+ // any express or implied warranties, including, but not limited to, the implied
+ // warranties of merchantability and fitness for a particular purpose are disclaimed.
+ // In no event shall the Intel Corporation or contributors be liable for any direct,
+ // indirect, incidental, special, exemplary, or consequential damages
+ // (including, but not limited to, procurement of substitute goods or services;
+ // loss of use, data, or profits; or business interruption) however caused
+ // and on any theory of liability, whether in contract, strict liability,
+ // or tort (including negligence or otherwise) arising in any way out of
+ // the use of this software, even if advised of the possibility of such damage.
+ //
+ //M*/
+
+#include "test_precomp.hpp"
+#include "opencv2/tracking.hpp"
+#include <fstream>
+
+using namespace cv;
+using namespace testing;
+using namespace std;
+
+#define PARAM_TEST_CASE(name, ...) struct name : testing::TestWithParam< std::tr1::tuple< __VA_ARGS__ > >
+#define GET_PARAM(k) std::tr1::get< k >(GetParam())
+#define TESTSET_NAMES testing::Values("david","dudek","faceocc2")
+
+const string TRACKING_DIR = "tracking";
+const string FOLDER_IMG = "data";
+const string FOLDER_OMIT_INIT = "initOmit";
+
+/*
+ * The Evaluation Methodologies are partially based on:
+ * ====================================================================================================================
+ * [OTB] Y. Wu, J. Lim, and M.-H. Yang, "Online object tracking: A benchmark," in Computer Vision and Pattern Recognition (CVPR), 2013
+ *
+ */
+
+enum BBTransformations
+{
+ NoTransform = 0,
+ CenterShiftLeft = 1,
+ CenterShiftRight = 2,
+ CenterShiftUp = 3,
+ CenterShiftDown = 4,
+ CornerShiftTopLeft = 5,
+ CornerShiftTopRight = 6,
+ CornerShiftBottomLeft = 7,
+ CornerShiftBottomRight = 8,
+ Scale_0_8 = 9,
+ Scale_0_9 = 10,
+ Scale_1_1 = 11,
+ Scale_1_2 = 12
+};
+
+class TrackerTest
+{
+ public:
+
+ TrackerTest(Ptr<Tracker> _tracker, string _video, float _distanceThreshold,
+ float _overlapThreshold, int _shift = NoTransform, int _segmentIdx = 1, int _numSegments = 10 );
+ virtual ~TrackerTest();
+ virtual void run();
+
+ protected:
+ void checkDataTest();
+
+ void distanceAndOvrerlapTest();
+
+ Ptr<Tracker> tracker;
+ string video;
+ std::vector<Rect> bbs;
+ int startFrame;
+ string suffix;
+ string prefix;
+ float overlapThreshold;
+ float distanceThreshold;
+ int segmentIdx;
+ int shift;
+ int numSegments;
+
+ int gtStartFrame;
+ int endFrame;
+ vector<int> validSequence;
+
+ private:
+ float calcDistance( Rect a, Rect b );
+ float calcOverlap( Rect a, Rect b );
+ Rect applyShift(Rect bb);
+ std::vector<std::string> splitString( std::string s, std::string delimiter );
+
+};
+
+TrackerTest::TrackerTest(Ptr<Tracker> _tracker, string _video, float _distanceThreshold,
+ float _overlapThreshold, int _shift, int _segmentIdx, int _numSegments ) :
+ tracker( _tracker ),
+ video( _video ),
+ overlapThreshold( _overlapThreshold ),
+ distanceThreshold( _distanceThreshold ),
+ segmentIdx(_segmentIdx),
+ shift(_shift),
+ numSegments(_numSegments)
+{
+}
+
+TrackerTest::~TrackerTest()
+{
+
+}
+
+std::vector<std::string> TrackerTest::splitString( std::string s, std::string delimiter )
+{
+ std::vector<string> token;
+ size_t pos = 0;
+ while ( ( pos = s.find( delimiter ) ) != std::string::npos )
+ {
+ token.push_back( s.substr( 0, pos ) );
+ s.erase( 0, pos + delimiter.length() );
+ }
+ token.push_back( s );
+ return token;
+}
+
+float TrackerTest::calcDistance( Rect a, Rect b )
+{
+ Point2f p_a( (float)(a.x + a.width / 2), (float)(a.y + a.height / 2) );
+ Point2f p_b( (float)(b.x + b.width / 2), (float)(b.y + b.height / 2) );
+ return sqrt( pow( p_a.x - p_b.x, 2 ) + pow( p_a.y - p_b.y, 2 ) );
+}
+
+float TrackerTest::calcOverlap( Rect a, Rect b )
+{
+ float rectIntersectionArea = (float)(a & b).area();
+ return rectIntersectionArea / (a.area() + b.area() - rectIntersectionArea);
+}
+
+Rect TrackerTest::applyShift(Rect bb)
+{
+ Point center( bb.x + ( bb.width / 2 ), bb.y + ( bb.height / 2 ) );
+
+ int xLimit = bb.x + bb.width - 1;
+ int yLimit = bb.y + bb.height - 1;
+
+ int h = 0;
+ int w = 0;
+ float ratio = 1.0;
+
+ switch ( shift )
+ {
+ case CenterShiftLeft:
+ bb.x = bb.x - (int)ceil( 0.1 * bb.width );
+ break;
+ case CenterShiftRight:
+ bb.x = bb.x + (int)ceil( 0.1 * bb.width );
+ break;
+ case CenterShiftUp:
+ bb.y = bb.y - (int)ceil( 0.1 * bb.height );
+ break;
+ case CenterShiftDown:
+ bb.y = bb.y + (int)ceil( 0.1 * bb.height );
+ break;
+ case CornerShiftTopLeft:
+ bb.x = (int)cvRound( bb.x - 0.1 * bb.width );
+ bb.y = (int)cvRound( bb.y - 0.1 * bb.height );
+
+ bb.width = xLimit - bb.x + 1;
+ bb.height = yLimit - bb.y + 1;
+ break;
+ case CornerShiftTopRight:
+ xLimit = (int)cvRound( xLimit + 0.1 * bb.width );
+
+ bb.y = (int)cvRound( bb.y - 0.1 * bb.height );
+ bb.width = xLimit - bb.x + 1;
+ bb.height = yLimit - bb.y + 1;
+ break;
+ case CornerShiftBottomLeft:
+ bb.x = (int)cvRound( bb.x - 0.1 * bb.width );
+ yLimit = (int)cvRound( yLimit + 0.1 * bb.height );
+
+ bb.width = xLimit - bb.x + 1;
+ bb.height = yLimit - bb.y + 1;
+ break;
+ case CornerShiftBottomRight:
+ xLimit = (int)cvRound( xLimit + 0.1 * bb.width );
+ yLimit = (int)cvRound( yLimit + 0.1 * bb.height );
+
+ bb.width = xLimit - bb.x + 1;
+ bb.height = yLimit - bb.y + 1;
+ break;
+ case Scale_0_8:
+ ratio = 0.8f;
+ w = (int)(ratio * bb.width);
+ h = (int)(ratio * bb.height);
+
+ bb = Rect( center.x - ( w / 2 ), center.y - ( h / 2 ), w, h );
+ break;
+ case Scale_0_9:
+ ratio = 0.9f;
+ w = (int)(ratio * bb.width);
+ h = (int)(ratio * bb.height);
+
+ bb = Rect( center.x - ( w / 2 ), center.y - ( h / 2 ), w, h );
+ break;
+ case 11:
+ //scale 1.1
+ ratio = 1.1f;
+ w = (int)(ratio * bb.width);
+ h = (int)(ratio * bb.height);
+
+ bb = Rect( center.x - ( w / 2 ), center.y - ( h / 2 ), w, h );
+ break;
+ case 12:
+ //scale 1.2
+ ratio = 1.2f;
+ w = (int)(ratio * bb.width);
+ h = (int)(ratio * bb.height);
+
+ bb = Rect( center.x - ( w / 2 ), center.y - ( h / 2 ), w, h );
+ break;
+ default:
+ break;
+ }
+
+ return bb;
+}
+
+void TrackerTest::distanceAndOvrerlapTest()
+{
+ Mat frame;
+ bool initialized = false;
+
+ int fc = ( startFrame - gtStartFrame );
+
+ bbs.at( fc ) = applyShift(bbs.at( fc ));
+ Rect currentBBi = bbs.at( fc );
+ Rect2d currentBB(currentBBi);
+ float sumDistance = 0;
+ float sumOverlap = 0;
+
+ string folder = cvtest::TS::ptr()->get_data_path() + "/" + TRACKING_DIR + "/" + video + "/" + FOLDER_IMG;
+
+ VideoCapture c;
+ c.open( folder + "/" + video + ".webm" );
+ c.set( CAP_PROP_POS_FRAMES, startFrame );
+
+ for ( int frameCounter = startFrame; frameCounter < endFrame; frameCounter++ )
+ {
+ c >> frame;
+
+ if( frame.empty() )
+ {
+ break;
+ }
+ if( !initialized )
+ {
+ if( !tracker->init( frame, currentBB ) )
+ {
+ FAIL()<< "Could not initialize tracker" << endl;
+ return;
+ }
+ initialized = true;
+ }
+ else if( initialized )
+ {
+ if( frameCounter >= (int) bbs.size() )
+ break;
+ tracker->update( frame, currentBB );
+ }
+ float curDistance = calcDistance( currentBB, bbs.at( fc ) );
+ float curOverlap = calcOverlap( currentBB, bbs.at( fc ) );
+
+ sumDistance += curDistance;
+ sumOverlap += curOverlap;
+ fc++;
+ }
+
+ float meanDistance = sumDistance / (endFrame - startFrame);
+ float meanOverlap = sumOverlap / (endFrame - startFrame);
+
+ if( meanDistance > distanceThreshold )
+ {
+ FAIL()<< "Incorrect distance: curr = " << meanDistance << ", max = " << distanceThreshold << endl;
+ return;
+ }
+
+ if( meanOverlap < overlapThreshold )
+ {
+ FAIL()<< "Incorrect overlap: curr = " << meanOverlap << ", min = " << overlapThreshold << endl;
+ return;
+ }
+}
+
+void TrackerTest::checkDataTest()
+{
+
+ FileStorage fs;
+ fs.open( cvtest::TS::ptr()->get_data_path() + TRACKING_DIR + "/" + video + "/" + video + ".yml", FileStorage::READ );
+ fs["start"] >> startFrame;
+ fs["prefix"] >> prefix;
+ fs["suffix"] >> suffix;
+ fs.release();
+
+ string gtFile = cvtest::TS::ptr()->get_data_path() + TRACKING_DIR + "/" + video + "/gt.txt";
+ ifstream gt;
+ //open the ground truth
+ gt.open( gtFile.c_str() );
+ if( !gt.is_open() )
+ {
+ FAIL()<< "Ground truth file " << gtFile << " can not be read" << endl;
+ }
+ string line;
+ int bbCounter = 0;
+ while ( getline( gt, line ) )
+ {
+ bbCounter++;
+ }
+ gt.close();
+
+ int seqLength = bbCounter;
+ for ( int i = startFrame; i < seqLength; i++ )
+ {
+ validSequence.push_back( i );
+ }
+
+ //exclude from the images sequence, the frames where the target is occluded or out of view
+ string omitFile = cvtest::TS::ptr()->get_data_path() + TRACKING_DIR + "/" + video + "/" + FOLDER_OMIT_INIT + "/" + video + ".txt";
+ ifstream omit;
+ omit.open( omitFile.c_str() );
+ if( omit.is_open() )
+ {
+ string omitLine;
+ while ( getline( omit, omitLine ) )
+ {
+ vector<string> tokens = splitString( omitLine, " " );
+ int s_start = atoi( tokens.at( 0 ).c_str() );
+ int s_end = atoi( tokens.at( 1 ).c_str() );
+ for ( int k = s_start; k <= s_end; k++ )
+ {
+ std::vector<int>::iterator position = std::find( validSequence.begin(), validSequence.end(), k );
+ if( position != validSequence.end() )
+ validSequence.erase( position );
+ }
+ }
+ }
+ omit.close();
+ gtStartFrame = startFrame;
+ //compute the start and the and for each segment
+ int numFrame = (int)(validSequence.size() / numSegments);
+ startFrame += ( segmentIdx - 1 ) * numFrame;
+ endFrame = startFrame + numFrame;
+
+ ifstream gt2;
+ //open the ground truth
+ gt2.open( gtFile.c_str() );
+ if( !gt2.is_open() )
+ {
+ FAIL()<< "Ground truth file " << gtFile << " can not be read" << endl;
+ }
+ string line2;
+ int bbCounter2 = 0;
+ while ( getline( gt2, line2 ) )
+ {
+ vector<string> tokens = splitString( line2, "," );
+ Rect bb( atoi( tokens.at( 0 ).c_str() ), atoi( tokens.at( 1 ).c_str() ), atoi( tokens.at( 2 ).c_str() ), atoi( tokens.at( 3 ).c_str() ) );
+ if( tokens.size() != 4 )
+ {
+ FAIL()<< "Incorrect ground truth file";
+ }
+
+ bbs.push_back( bb );
+ bbCounter2++;
+ }
+ gt2.close();
+
+ if( segmentIdx == numSegments )
+ endFrame = (int)bbs.size();
+}
+
+void TrackerTest::run()
+{
+ srand( 1 );
+
+ SCOPED_TRACE( "A" );
+
+ if( !tracker )
+ {
+ FAIL()<< "Error in the instantiation of the tracker" << endl;
+ return;
+ }
+
+ checkDataTest();
+
+ //check for failure
+ if( ::testing::Test::HasFatalFailure() )
+ return;
+
+ distanceAndOvrerlapTest();
+}
+
+/****************************************************************************************\
+* Tests registrations *
+ \****************************************************************************************/
+
+//[TESTDATA]
+PARAM_TEST_CASE(DistanceAndOverlap, string)
+{
+ string dataset;
+ virtual void SetUp()
+ {
+ dataset = GET_PARAM(0);
+ }
+};
+
+TEST_P(DistanceAndOverlap, MedianFlow)
+{
+ TrackerTest test( TrackerMedianFlow::create(), dataset, 35, .5f, NoTransform, 1, 1);
+ test.run();
+}
+
+TEST_P(DistanceAndOverlap, MIL)
+{
+ TrackerTest test( TrackerMIL::create(), dataset, 30, .65f, NoTransform);
+ test.run();
+}
+
+TEST_P(DistanceAndOverlap, Boosting)
+{
+ TrackerTest test( TrackerBoosting::create(), dataset, 70, .7f, NoTransform);
+ test.run();
+}
+
+TEST_P(DistanceAndOverlap, KCF)
+{
+ TrackerTest test( TrackerKCF::create(), dataset, 20, .35f, NoTransform, 5);
+ test.run();
+}
+
+TEST_P(DistanceAndOverlap, DISABLED_TLD)
+{
+ TrackerTest test( TrackerTLD::create(), dataset, 60, .4f, NoTransform);
+ test.run();
+}
+/***************************************************************************************/
+//Tests with shifted initial window
+TEST_P(DistanceAndOverlap, Shifted_Data_MedianFlow)
+{
+ TrackerTest test( TrackerMedianFlow::create(), dataset, 80, .2f, CenterShiftLeft, 1, 1);
+ test.run();
+}
+
+TEST_P(DistanceAndOverlap, Shifted_Data_MIL)
+{
+ TrackerTest test( TrackerMIL::create(), dataset, 30, .6f, CenterShiftLeft);
+ test.run();
+}
+
+TEST_P(DistanceAndOverlap, Shifted_Data_Boosting)
+{
+ TrackerTest test( TrackerBoosting::create(), dataset, 80, .65f, CenterShiftLeft);
+ test.run();
+}
+
+TEST_P(DistanceAndOverlap, Shifted_Data_KCF)
+{
+ TrackerTest test( TrackerKCF::create(), dataset, 20, .4f, CenterShiftLeft, 5);
+ test.run();
+}
+
+TEST_P(DistanceAndOverlap, DISABLED_Shifted_Data_TLD)
+{
+ TrackerTest test( TrackerTLD::create(), dataset, 120, .2f, CenterShiftLeft);
+ test.run();
+}
+/***************************************************************************************/
+//Tests with scaled initial window
+TEST_P(DistanceAndOverlap, Scaled_Data_MedianFlow)
+{
+ TrackerTest test( TrackerMedianFlow::create(), dataset, 25, .5f, Scale_1_1, 1, 1);
+ test.run();
+}
+
+TEST_P(DistanceAndOverlap, Scaled_Data_MIL)
+{
+ TrackerTest test( TrackerMIL::create(), dataset, 30, .7f, Scale_1_1);
+ test.run();
+}
+
+TEST_P(DistanceAndOverlap, Scaled_Data_Boosting)
+{
+ TrackerTest test( TrackerBoosting::create(), dataset, 80, .7f, Scale_1_1);
+ test.run();
+}
+
+TEST_P(DistanceAndOverlap, Scaled_Data_KCF)
+{
+ TrackerTest test( TrackerKCF::create(), dataset, 20, .4f, Scale_1_1, 5);
+ test.run();
+}
+
+TEST_P(DistanceAndOverlap, DISABLED_Scaled_Data_TLD)
+{
+ TrackerTest test( TrackerTLD::create(), dataset, 120, .45f, Scale_1_1);
+ test.run();
+}
+
+
+TEST_P(DistanceAndOverlap, DISABLED_GOTURN)
+{
+ TrackerTest test(TrackerGOTURN::create(), dataset, 0, 100, NoTransform);
+ test.run();
+}
+
+INSTANTIATE_TEST_CASE_P( Tracking, DistanceAndOverlap, TESTSET_NAMES);
+
+/* End of file. */
diff --git a/contrib/modules/tracking/test/test_ukf.cpp b/contrib/modules/tracking/test/test_ukf.cpp
index b2a0758..921ab25 100644
--- a/contrib/modules/tracking/test/test_ukf.cpp
+++ b/contrib/modules/tracking/test/test_ukf.cpp
@@ -204,7 +204,7 @@ TEST(UKF, br_landing_point)
ASSERT_NEAR(landing_coordinate, landing_y, abs_error);
}
-TEST(UKF, br_mean_squared_error)
+TEST(UKF, DISABLED_br_mean_squared_error)
{
const double velocity_treshold = 0.09;
const double state_treshold = 0.9;
@@ -343,7 +343,7 @@ public:
}
};
-TEST(UKF, ungm_mean_squared_error)
+TEST(UKF, DISABLED_ungm_mean_squared_error)
{
const double alpha = 1.5;
const double beta = 2.0;
diff --git a/contrib/modules/tracking/tutorials/tutorial_introduction_to_tracker.markdown b/contrib/modules/tracking/tutorials/tutorial_introduction_to_tracker.markdown
index 9e2b6eb..5da2ab9 100644
--- a/contrib/modules/tracking/tutorials/tutorial_introduction_to_tracker.markdown
+++ b/contrib/modules/tracking/tutorials/tutorial_introduction_to_tracker.markdown
@@ -59,7 +59,6 @@ Explanation
Using this function, you can select the bounding box of the tracked object using a GUI.
With default parameters, the selection is started from the center of the box and a middle cross will be shown.
- See @ref cv::selectROI for more detailed information.
-# **Initializing the tracker object**
diff --git a/contrib/modules/tracking/tutorials/tutorial_multitracker.markdown b/contrib/modules/tracking/tutorials/tutorial_multitracker.markdown
index 4bc3e3c..f9c7605 100644
--- a/contrib/modules/tracking/tutorials/tutorial_multitracker.markdown
+++ b/contrib/modules/tracking/tutorials/tutorial_multitracker.markdown
@@ -28,9 +28,8 @@ Explanation
@snippet tracking/samples/tutorial_multitracker.cpp selectmulti
- You can use @ref cv::selectROI to select multiple objects with
+ You can use selectROI to select multiple objects with
the result stored in a vector of @ref cv::Rect2d as shown in the code.
- You can also use another kind of selection scheme, please refer to @ref cv::selectROI for detailed information.
-# **Adding the tracked object to MultiTracker**
diff --git a/contrib/modules/ximgproc/CMakeLists.txt b/contrib/modules/ximgproc/CMakeLists.txt
index 91ed65e..6e163ca 100644
--- a/contrib/modules/ximgproc/CMakeLists.txt
+++ b/contrib/modules/ximgproc/CMakeLists.txt
@@ -1,5 +1,2 @@
set(the_description "Extended image processing module. It includes edge-aware filters and etc.")
-set(OPENCV_MODULE_IS_PART_OF_WORLD OFF)
-ocv_define_module(ximgproc opencv_imgproc opencv_core opencv_highgui opencv_calib3d WRAP python)
-
-target_link_libraries(opencv_ximgproc)
+ocv_define_module(ximgproc opencv_core opencv_imgproc opencv_calib3d opencv_imgcodecs WRAP python)
diff --git a/contrib/modules/ximgproc/doc/pics/superpixels_slic.png b/contrib/modules/ximgproc/doc/pics/superpixels_slic.png
index 7718c5d..5c5f39e 100644
Binary files a/contrib/modules/ximgproc/doc/pics/superpixels_slic.png and b/contrib/modules/ximgproc/doc/pics/superpixels_slic.png differ
diff --git a/contrib/modules/ximgproc/doc/ximgproc.bib b/contrib/modules/ximgproc/doc/ximgproc.bib
index 08bcbc4..819c8b3 100644
--- a/contrib/modules/ximgproc/doc/ximgproc.bib
+++ b/contrib/modules/ximgproc/doc/ximgproc.bib
@@ -160,6 +160,22 @@
keywords = {Superpixels, segmentation, clustering, k-means}
}
+ at InProceedings{Liu_2017_IEEE,
+ author = {Liu, Yong-Jin and Yu, Cheng-Chi and Yu, Min-Jing and He, Ying},
+ title = {Intrinsic Manifold SLIC: A Simple and Efficient Method for Computing Content-Sensitive Superpixels},
+ journal = {IEEE Transactions on Pattern Analysis and Machine Intelligence},
+ issue_date = {March 2017},
+ volume = {PP},
+ month = {mar},
+ year = {2017},
+ issue = {99},
+ url = {https://doi.org/10.1109/TPAMI.2017.2686857},
+ doi = {10.1109/TPAMI.2017.2686857},
+ publisher = {IEEE Computer Society},
+ address = {Washington, DC, USA},
+ keywords = {Superpixels, segmentation, image manifold, centroidal Voronoi tessellation, geodesic distance}
+}
+
@InProceedings{LiCVPR2015LSC,
author = {Li, Zhengqin and Chen, Jiansheng},
title = {Superpixel Segmentation Using Linear Spectral Clustering},
@@ -206,3 +222,40 @@
pages={191--196},
year={1997}
}
+
+ at book{Niblack1985,
+ title={An introduction to digital image processing},
+ author={Niblack, Wayne},
+ year={1985},
+ publisher={Strandberg Publishing Company}
+}
+
+ at inproceedings{Sauvola1997,
+ title={Adaptive document binarization},
+ author={Sauvola, Jaakko and Seppanen, Tapio and Haapakoski, Sami and Pietikainen, Matti},
+ booktitle={Document Analysis and Recognition, 1997., Proceedings of the Fourth International Conference on},
+ volume={1},
+ pages={147--152},
+ year={1997},
+ organization={IEEE}
+}
+
+ at article{Wolf2004,
+ title={Extraction and recognition of artificial text in multimedia documents},
+ author={Wolf, Christian and Jolion, J-M},
+ journal={Pattern Analysis \& Applications},
+ volume={6},
+ number={4},
+ pages={309--326},
+ year={2004},
+ publisher={Springer}
+}
+
+ at inproceedings{Khurshid2009,
+ title={Comparison of Niblack inspired Binarization methods for ancient documents},
+ author={Khurshid, Khurram and Siddiqi, Imran and Faure, Claudie and Vincent, Nicole},
+ booktitle={IS\&T/SPIE Electronic Imaging},
+ pages={72470U--72470U},
+ year={2009},
+ organization={International Society for Optics and Photonics}
+}
diff --git a/contrib/modules/ximgproc/include/opencv2/ximgproc.hpp b/contrib/modules/ximgproc/include/opencv2/ximgproc.hpp
index 7616a40..7fdaae3 100644
--- a/contrib/modules/ximgproc/include/opencv2/ximgproc.hpp
+++ b/contrib/modules/ximgproc/include/opencv2/ximgproc.hpp
@@ -79,10 +79,21 @@ enum ThinningTypes{
THINNING_GUOHALL = 1 // Thinning technique of Guo-Hall
};
+/**
+* @brief Specifies the binarization method to use in cv::ximgproc::niBlackThreshold
+*/
+enum LocalBinarizationMethods{
+ BINARIZATION_NIBLACK = 0, //!< Classic Niblack binarization. See @cite Niblack1985 .
+ BINARIZATION_SAUVOLA = 1, //!< Sauvola's technique. See @cite Sauvola1997 .
+ BINARIZATION_WOLF = 2, //!< Wolf's technique. See @cite Wolf2004 .
+ BINARIZATION_NICK = 3 //!< NICK technique. See @cite Khurshid2009 .
+};
+
//! @addtogroup ximgproc
//! @{
-/** @brief Applies Niblack thresholding to input image.
+/** @brief Performs thresholding on input images using Niblack's technique or some of the
+popular variations it inspired.
The function transforms a grayscale image to a binary image according to the formulae:
- **THRESH_BINARY**
@@ -91,8 +102,9 @@ The function transforms a grayscale image to a binary image according to the for
\f[dst(x,y) = \fork{0}{if \(src(x,y) > T(x,y)\)}{\texttt{maxValue}}{otherwise}\f]
where \f$T(x,y)\f$ is a threshold calculated individually for each pixel.
-The threshold value \f$T(x, y)\f$ is the mean minus \f$ delta \f$ times standard deviation
-of \f$\texttt{blockSize} \times\texttt{blockSize}\f$ neighborhood of \f$(x, y)\f$.
+The threshold value \f$T(x, y)\f$ is determined based on the binarization method chosen. For
+classic Niblack, it is the mean minus \f$ k \f$ times standard deviation of
+\f$\texttt{blockSize} \times\texttt{blockSize}\f$ neighborhood of \f$(x, y)\f$.
The function can't process the image in-place.
@@ -103,14 +115,17 @@ used with the THRESH_BINARY and THRESH_BINARY_INV thresholding types.
@param type Thresholding type, see cv::ThresholdTypes.
@param blockSize Size of a pixel neighborhood that is used to calculate a threshold value
for the pixel: 3, 5, 7, and so on.
- at param delta Constant multiplied with the standard deviation and subtracted from the mean.
-Normally, it is taken to be a real number between 0 and 1.
+ at param k The user-adjustable parameter used by Niblack and inspired techniques. For Niblack, this is
+normally a value between 0 and 1 that is multiplied with the standard deviation and subtracted from
+the mean.
+ at param binarizationMethod Binarization method to use. By default, Niblack's technique is used.
+Other techniques can be specified, see cv::ximgproc::LocalBinarizationMethods.
@sa threshold, adaptiveThreshold
*/
CV_EXPORTS_W void niBlackThreshold( InputArray _src, OutputArray _dst,
double maxValue, int type,
- int blockSize, double delta );
+ int blockSize, double k, int binarizationMethod = BINARIZATION_NIBLACK );
/** @brief Applies a binary blob thinning operation, to achieve a skeletization of the input image.
@@ -118,10 +133,31 @@ The function transforms a binary blob image into a skeletized form using the tec
@param src Source 8-bit single-channel image, containing binary blobs, with blobs having 255 pixel values.
@param dst Destination image of the same size and the same type as src. The function can work in-place.
- at param thinningType Value that defines which thinning algorithm should be used. See cv::ThinningTypes
+ at param thinningType Value that defines which thinning algorithm should be used. See cv::ximgproc::ThinningTypes
*/
CV_EXPORTS_W void thinning( InputArray src, OutputArray dst, int thinningType = THINNING_ZHANGSUEN);
+/** @brief Performs anisotropic diffusian on an image.
+
+ The function applies Perona-Malik anisotropic diffusion to an image. This is the solution to the partial differential equation:
+
+ \f[{\frac {\partial I}{\partial t}}={\mathrm {div}}\left(c(x,y,t)\nabla I\right)=\nabla c\cdot \nabla I+c(x,y,t)\Delta I\f]
+
+ Suggested functions for c(x,y,t) are:
+
+ \f[c\left(\|\nabla I\|\right)=e^{{-\left(\|\nabla I\|/K\right)^{2}}}\f]
+
+ or
+
+ \f[ c\left(\|\nabla I\|\right)={\frac {1}{1+\left({\frac {\|\nabla I\|}{K}}\right)^{2}}} \f]
+
+ @param src Grayscale Source image.
+ @param dst Destination image of the same size and the same number of channels as src .
+ @param alpha The amount of time to step forward by on each iteration (normally, it's between 0 and 1).
+ @param K sensitivity to the edges
+ @param niters The number of iterations
+*/
+CV_EXPORTS_W void anisotropicDiffusion(InputArray src, OutputArray dst, float alpha, float K, int niters );
//! @}
diff --git a/contrib/modules/ximgproc/include/opencv2/ximgproc/paillou_filter.hpp b/contrib/modules/ximgproc/include/opencv2/ximgproc/paillou_filter.hpp
index f7feee3..03754a1 100644
--- a/contrib/modules/ximgproc/include/opencv2/ximgproc/paillou_filter.hpp
+++ b/contrib/modules/ximgproc/include/opencv2/ximgproc/paillou_filter.hpp
@@ -51,8 +51,8 @@ namespace ximgproc {
*
* For more details about this implementation, please see @cite paillou1997detecting
*
-* @param op Source 8-bit or 16bit image, 1-channel or 3-channel image.
-* @param _dst result CV_32F image with same numeber of channel than op.
+* @param op Source CV_8U(S) or CV_16U(S), 1-channel or 3-channels image.
+* @param _dst result CV_32F image with same number of channel than op.
* @param omega double see paper
* @param alpha double see paper
*
diff --git a/contrib/modules/ximgproc/include/opencv2/ximgproc/segmentation.hpp b/contrib/modules/ximgproc/include/opencv2/ximgproc/segmentation.hpp
index 02d28bf..19d032b 100644
--- a/contrib/modules/ximgproc/include/opencv2/ximgproc/segmentation.hpp
+++ b/contrib/modules/ximgproc/include/opencv2/ximgproc/segmentation.hpp
@@ -236,7 +236,7 @@ namespace cv {
/** @brief Based on all images, graph segmentations and stragies, computes all possible rects and return them
@param rects The list of rects. The first ones are more relevents than the lasts ones.
*/
- CV_WRAP virtual void process(std::vector<Rect>& rects) = 0;
+ CV_WRAP virtual void process(CV_OUT std::vector<Rect>& rects) = 0;
};
/** @brief Create a new SelectiveSearchSegmentation class.
diff --git a/contrib/modules/ximgproc/include/opencv2/ximgproc/slic.hpp b/contrib/modules/ximgproc/include/opencv2/ximgproc/slic.hpp
index 64fc45c..c0050c9 100644
--- a/contrib/modules/ximgproc/include/opencv2/ximgproc/slic.hpp
+++ b/contrib/modules/ximgproc/include/opencv2/ximgproc/slic.hpp
@@ -61,6 +61,8 @@ namespace ximgproc
//! @addtogroup ximgproc_superpixel
//! @{
+ enum SLIC { SLIC = 100, SLICO = 101, MSLIC = 102 };
+
/** @brief Class implementing the SLIC (Simple Linear Iterative Clustering) superpixels
algorithm described in @cite Achanta2012.
@@ -68,7 +70,9 @@ SLIC (Simple Linear Iterative Clustering) clusters pixels using pixel channels a
to efficiently generate compact, nearly uniform superpixels. The simplicity of approach makes it
extremely easy to use a lone parameter specifies the number of superpixels and the efficiency of
the algorithm makes it very practical.
-
+Several optimizations are available for SLIC class:
+SLICO stands for "Zero parameter SLIC" and it is an optimization of baseline SLIC descibed in @cite Achanta2012.
+MSLIC stands for "Manifold SLIC" and it is an optimization of baseline SLIC described in @cite Liu_2017_IEEE.
*/
class CV_EXPORTS_W SuperpixelSLIC : public Algorithm
@@ -134,26 +138,25 @@ public:
};
-/** @brief Class implementing the SLIC (Simple Linear Iterative Clustering) superpixels
+/** @brief Initialize a SuperpixelSLIC object
@param image Image to segment
@param algorithm Chooses the algorithm variant to use:
-SLIC segments image using a desired region_size, and in addition
-SLICO will choose an adaptive compactness factor.
+SLIC segments image using a desired region_size, and in addition SLICO will optimize using adaptive compactness factor,
+while MSLIC will optimize using manifold methods resulting in more content-sensitive superpixels.
@param region_size Chooses an average superpixel size measured in pixels
@param ruler Chooses the enforcement of superpixel smoothness factor of superpixel
The function initializes a SuperpixelSLIC object for the input image. It sets the parameters of choosed
superpixel algorithm, which are: region_size and ruler. It preallocate some buffers for future
-computing iterations over the given image. An example of SLIC versus SLICO is ilustrated in the
-following picture.
+computing iterations over the given image. For enanched results it is recommended for color images to
+preprocess image with little gaussian blur using a small 3 x 3 kernel and additional conversion into
+CieLAB color space. An example of SLIC versus SLICO and MSLIC is ilustrated in the following picture.

*/
- enum SLIC { SLIC = 100, SLICO = 101 };
-
CV_EXPORTS_W Ptr<SuperpixelSLIC> createSuperpixelSLIC( InputArray image, int algorithm = SLICO,
int region_size = 10, float ruler = 10.0f );
diff --git a/contrib/modules/ximgproc/include/opencv2/ximgproc/structured_edge_detection.hpp b/contrib/modules/ximgproc/include/opencv2/ximgproc/structured_edge_detection.hpp
index db6e906..b0eb777 100644
--- a/contrib/modules/ximgproc/include/opencv2/ximgproc/structured_edge_detection.hpp
+++ b/contrib/modules/ximgproc/include/opencv2/ximgproc/structured_edge_detection.hpp
@@ -102,11 +102,31 @@ public:
The algorithm underlies this function is much more robust to texture presence, than common
approaches, e.g. Sobel
- @param src source image (RGB, float, in [0;1]) to detect edges
- @param dst destination image (grayscale, float, in [0;1]) where edges are drawn
+ @param _src source image (RGB, float, in [0;1]) to detect edges
+ @param _dst destination image (grayscale, float, in [0;1]) where edges are drawn
@sa Sobel, Canny
*/
- CV_WRAP virtual void detectEdges(const Mat &src, CV_OUT Mat &dst) const = 0;
+ CV_WRAP virtual void detectEdges(cv::InputArray _src, cv::OutputArray _dst) const = 0;
+
+ /** @brief The function computes orientation from edge image.
+
+ @param _src edge image.
+ @param _dst orientation image.
+ */
+ CV_WRAP virtual void computeOrientation(cv::InputArray _src, cv::OutputArray _dst) const = 0;
+
+
+ /** @brief The function edgenms in edge image and suppress edges where edge is stronger in orthogonal direction.
+
+ @param edge_image edge image from detectEdges function.
+ @param orientation_image orientation image from computeOrientation function.
+ @param _dst suppressed image (grayscale, float, in [0;1])
+ @param r radius for NMS suppression.
+ @param s radius for boundary suppression.
+ @param m multiplier for conservative suppression.
+ @param isParallel enables/disables parallel computing.
+ */
+ CV_WRAP virtual void edgesNms(cv::InputArray edge_image, cv::InputArray orientation_image, cv::OutputArray _dst, int r = 2, int s = 0, float m = 1, bool isParallel = true) const = 0;
};
/*!
diff --git a/contrib/modules/ximgproc/include/opencv2/ximgproc/weighted_median_filter.hpp b/contrib/modules/ximgproc/include/opencv2/ximgproc/weighted_median_filter.hpp
index 30a169c..d3da29e 100644
--- a/contrib/modules/ximgproc/include/opencv2/ximgproc/weighted_median_filter.hpp
+++ b/contrib/modules/ximgproc/include/opencv2/ximgproc/weighted_median_filter.hpp
@@ -63,12 +63,12 @@ namespace ximgproc
*/
enum WMFWeightType
{
- WMF_EXP, //!< \f$exp(-|I1-I2|^2/(2*sigma^2))\f$
- WMF_IV1, //!< \f$(|I1-I2|+sigma)^-1\f$
- WMF_IV2, //!< \f$(|I1-I2|^2+sigma^2)^-1\f$
- WMF_COS, //!< \f$dot(I1,I2)/(|I1|*|I2|)\f$
- WMF_JAC, //!< \f$(min(r1,r2)+min(g1,g2)+min(b1,b2))/(max(r1,r2)+max(g1,g2)+max(b1,b2))\f$
- WMF_OFF //!< unweighted
+ WMF_EXP = 1 , //!< \f$exp(-|I1-I2|^2/(2*sigma^2))\f$
+ WMF_IV1 = 1 << 1, //!< \f$(|I1-I2|+sigma)^-1\f$
+ WMF_IV2 = 1 << 2, //!< \f$(|I1-I2|^2+sigma^2)^-1\f$
+ WMF_COS = 1 << 3, //!< \f$dot(I1,I2)/(|I1|*|I2|)\f$
+ WMF_JAC = 1 << 4, //!< \f$(min(r1,r2)+min(g1,g2)+min(b1,b2))/(max(r1,r2)+max(g1,g2)+max(b1,b2))\f$
+ WMF_OFF = 1 << 5 //!< unweighted
};
/**
@@ -87,7 +87,8 @@ enum WMFWeightType
*
* @sa medianBlur, jointBilateralFilter
*/
-CV_EXPORTS void weightedMedianFilter(InputArray joint, InputArray src, OutputArray dst, int r, double sigma=25.5, WMFWeightType weightType=WMF_EXP, Mat mask=Mat());
+CV_EXPORTS_W void weightedMedianFilter(InputArray joint, InputArray src, OutputArray dst,
+ int r, double sigma = 25.5, int weightType = WMF_EXP, InputArray mask = noArray());
}
}
diff --git a/contrib/modules/ximgproc/samples/filterdemo.cpp b/contrib/modules/ximgproc/samples/filterdemo.cpp
new file mode 100644
index 0000000..e375a8a
--- /dev/null
+++ b/contrib/modules/ximgproc/samples/filterdemo.cpp
@@ -0,0 +1,105 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "opencv2/core/utility.hpp"
+#include "opencv2/imgproc.hpp"
+#include "opencv2/imgcodecs.hpp"
+#include "opencv2/highgui.hpp"
+#include "opencv2/ximgproc.hpp"
+
+#include <stdio.h>
+
+using namespace cv;
+using namespace std;
+
+int main( int argc, const char** argv)
+{
+ float alpha = 1.0f;
+ float sigma = 0.02f;
+ int rows0 = 480;
+ int niters = 10;
+ Mat frame, src, dst;
+
+ const char* window_name = "Anisodiff : Exponential Flux";
+
+ VideoCapture cap;
+ if( argc > 1 )
+ cap.open(argv[1]);
+ else
+ cap.open(0);
+
+ if (!cap.isOpened())
+ {
+ printf("Cannot initialize video capturing\n");
+ return 0;
+ }
+
+ // Create a window
+ namedWindow(window_name, 1);
+
+ // create a toolbar
+ createTrackbar("No. of time steps", window_name, &niters, 30, 0);
+
+ for(;;)
+ {
+ cap >> frame;
+ if( frame.empty() )
+ break;
+
+ if( frame.rows <= rows0 )
+ src = frame;
+ else
+ resize(frame, src, Size(cvRound(480.*frame.cols/frame.rows), 480));
+
+ float t = (float)getTickCount();
+ ximgproc::anisotropicDiffusion(src, dst, alpha, sigma, niters);
+ t = (float)getTickCount() - t;
+ printf("time: %.1fms\n", t*1000./getTickFrequency());
+ imshow(window_name, dst);
+
+ // Wait for a key stroke; the same function arranges events processing
+ char c = (char)waitKey(30);
+ if(c >= 0)
+ break;
+ }
+
+ return 0;
+}
diff --git a/contrib/modules/ximgproc/samples/niblack_thresholding.cpp b/contrib/modules/ximgproc/samples/niblack_thresholding.cpp
index 495cfff..8dafdf9 100644
--- a/contrib/modules/ximgproc/samples/niblack_thresholding.cpp
+++ b/contrib/modules/ximgproc/samples/niblack_thresholding.cpp
@@ -16,6 +16,7 @@ Mat_<uchar> src;
int k_ = 8;
int blockSize_ = 11;
int type_ = THRESH_BINARY;
+int method_ = BINARIZATION_NIBLACK;
void on_trackbar(int, void*);
@@ -34,6 +35,7 @@ int main(int argc, char** argv)
namedWindow("Niblack", WINDOW_AUTOSIZE);
createTrackbar("k", "Niblack", &k_, 20, on_trackbar);
createTrackbar("blockSize", "Niblack", &blockSize_, 30, on_trackbar);
+ createTrackbar("method", "Niblack", &method_, 3, on_trackbar);
createTrackbar("threshType", "Niblack", &type_, 4, on_trackbar);
on_trackbar(0, 0);
waitKey(0);
@@ -47,7 +49,8 @@ void on_trackbar(int, void*)
int blockSize = 2*(blockSize_ >= 1 ? blockSize_ : 1) + 1; // 3,5,7,...,61
int type = type_; // THRESH_BINARY, THRESH_BINARY_INV,
// THRESH_TRUNC, THRESH_TOZERO, THRESH_TOZERO_INV
+ int method = method_; //BINARIZATION_NIBLACK, BINARIZATION_SAUVOLA, BINARIZATION_WOLF, BINARIZATION_NICK
Mat dst;
- niBlackThreshold(src, dst, 255, type, blockSize, k);
+ niBlackThreshold(src, dst, 255, type, blockSize, k, method);
imshow("Niblack", dst);
}
diff --git a/contrib/modules/ximgproc/samples/paillou_demo.cpp b/contrib/modules/ximgproc/samples/paillou_demo.cpp
index bcbb9ee..a8b773d 100644
--- a/contrib/modules/ximgproc/samples/paillou_demo.cpp
+++ b/contrib/modules/ximgproc/samples/paillou_demo.cpp
@@ -47,8 +47,8 @@ using namespace cv::ximgproc;
using namespace std;
int aa = 100, ww = 10;
-Mat dx, dy;
-UMat img;
+
+Ptr<Mat> img;
const char* window_name = "Gradient Modulus";
static void DisplayImage(Mat x,string s)
@@ -77,8 +77,8 @@ static void PaillouFilter(int, void*)
Mat dst;
double a=aa/100.0,w=ww/100.0;
Mat rx,ry;
- GradientPaillouX(img,rx,a,w);
- GradientPaillouY(img,ry,a,w);
+ GradientPaillouX(*img.get(),rx,a,w);
+ GradientPaillouY(*img.get(),ry,a,w);
DisplayImage(rx, "Gx");
DisplayImage(ry, "Gy");
add(rx.mul(rx),ry.mul(ry),dst);
@@ -89,13 +89,15 @@ static void PaillouFilter(int, void*)
int main(int argc, char* argv[])
{
- if (argc==2)
- imread(argv[1]).copyTo(img);
- if (img.empty())
+ Mat *m=new Mat;
+ if (argc == 2)
+ *m = imread(argv[1]);
+ if (m->empty())
{
cout << "File not found or empty image\n";
}
- imshow("Original",img);
+ img = Ptr<Mat>(m);
+ imshow("Original",*img.get());
namedWindow( window_name, WINDOW_AUTOSIZE );
/// Create a Trackbar for user to enter threshold
diff --git a/contrib/modules/ximgproc/samples/selectivesearchsegmentation_demo.py b/contrib/modules/ximgproc/samples/selectivesearchsegmentation_demo.py
new file mode 100644
index 0000000..9a2ead9
--- /dev/null
+++ b/contrib/modules/ximgproc/samples/selectivesearchsegmentation_demo.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+
+'''
+A program demonstrating the use and capabilities of a particular image segmentation algorithm described
+in Jasper R. R. Uijlings, Koen E. A. van de Sande, Theo Gevers, Arnold W. M. Smeulders:
+ "Selective Search for Object Recognition"
+International Journal of Computer Vision, Volume 104 (2), page 154-171, 2013
+Usage:
+ ./selectivesearchsegmentation_demo.py input_image (single|fast|quality)
+Use "a" to display less rects, 'd' to display more rects, "q" to quit.
+'''
+
+import cv2
+import sys
+
+if __name__ == '__main__':
+ img = cv2.imread(sys.argv[1])
+
+ cv2.setUseOptimized(True)
+ cv2.setNumThreads(8)
+
+ gs = cv2.ximgproc.segmentation.createSelectiveSearchSegmentation()
+ gs.setBaseImage(img)
+
+ if (sys.argv[2][0] == 's'):
+ gs.switchToSingleStrategy()
+
+ elif (sys.argv[2][0] == 'f'):
+ gs.switchToSelectiveSearchFast()
+
+ elif (sys.argv[2][0] == 'q'):
+ gs.switchToSelectiveSearchQuality()
+ else:
+ print(__doc__)
+ sys.exit(1)
+
+ rects = gs.process()
+ nb_rects = 10
+
+ while True:
+ wimg = img.copy()
+
+ for i in range(len(rects)):
+ if (i < nb_rects):
+ x, y, w, h = rects[i]
+ cv2.rectangle(wimg, (x, y), (x+w, y+h), (0, 255, 0), 1, cv2.LINE_AA)
+
+ cv2.imshow("Output", wimg);
+ c = cv2.waitKey()
+
+ if (c == 100):
+ nb_rects += 10
+
+ elif (c == 97 and nb_rects > 10):
+ nb_rects -= 10
+
+ elif (c == 113):
+ break
+
+ cv2.destroyAllWindows()
diff --git a/contrib/modules/ximgproc/samples/slic.cpp b/contrib/modules/ximgproc/samples/slic.cpp
index 637cbf2..c49d9ce 100644
--- a/contrib/modules/ximgproc/samples/slic.cpp
+++ b/contrib/modules/ximgproc/samples/slic.cpp
@@ -19,7 +19,7 @@ static const char* keys =
"{h help | | help menu}"
"{c camera |0| camera id}"
"{i image | | image file}"
- "{a algorithm |1| SLIC(0),SLICO(1)}"
+ "{a algorithm |1| SLIC(0),SLICO(1),MSLIC(2)}"
;
int main(int argc, char** argv)
@@ -63,7 +63,7 @@ int main(int argc, char** argv)
}
namedWindow(window_name, 0);
- createTrackbar("Algorithm", window_name, &algorithm, 1, 0);
+ createTrackbar("Algorithm", window_name, &algorithm, 2, 0);
createTrackbar("Region size", window_name, ®ion_size, 200, 0);
createTrackbar("Ruler", window_name, &ruler, 100, 0);
createTrackbar("Connectivity", window_name, &min_element_size, 100, 0);
diff --git a/contrib/modules/ximgproc/samples/structured_edge_detection.cpp b/contrib/modules/ximgproc/samples/structured_edge_detection.cpp
index 98eeefc..631a3ce 100644
--- a/contrib/modules/ximgproc/samples/structured_edge_detection.cpp
+++ b/contrib/modules/ximgproc/samples/structured_edge_detection.cpp
@@ -59,10 +59,20 @@ int main( int argc, const char** argv )
createStructuredEdgeDetection(modelFilename);
pDollar->detectEdges(image, edges);
+ // computes orientation from edge map
+ Mat orientation_map;
+ pDollar->computeOrientation(edges, orientation_map);
+
+ // suppress edges
+ Mat edge_nms;
+ pDollar->edgesNms(edges, orientation_map, edge_nms, 2, 0, 1, true);
+
if ( outFilename.size() == 0 )
{
namedWindow("edges", 1);
imshow("edges", edges);
+ namedWindow("edges nms", 1);
+ imshow("edges nms", edge_nms);
waitKey(0);
}
else
diff --git a/contrib/modules/ximgproc/samples/thinning.cpp b/contrib/modules/ximgproc/samples/thinning.cpp
index 7adabb7..b6201bc 100644
--- a/contrib/modules/ximgproc/samples/thinning.cpp
+++ b/contrib/modules/ximgproc/samples/thinning.cpp
@@ -11,6 +11,7 @@ using namespace cv;
int main()
{
Mat img = imread("opencv-logo.png", IMREAD_COLOR);
+ resize(img, img, Size(), 0.5, 0.5);
/// Threshold the input image
Mat img_grayscale, img_binary;
@@ -19,8 +20,8 @@ int main()
/// Apply thinning to get a skeleton
Mat img_thinning_ZS, img_thinning_GH;
- //ximgproc::thinning(img_binary, img_thinning_ZS, THINNING_ZHANGSUEN);
- //ximgproc::thinning(img_binary, img_thinning_GH, THINNING_GUOHALL);
+ ximgproc::thinning(img_binary, img_thinning_ZS, ximgproc::THINNING_ZHANGSUEN);
+ ximgproc::thinning(img_binary, img_thinning_GH, ximgproc::THINNING_GUOHALL);
/// Make 3 channel images from thinning result
Mat result_ZS(img.rows, img.cols, CV_8UC3), result_GH(img.rows, img.cols, CV_8UC3);
diff --git a/contrib/modules/ximgproc/src/anisodiff.cpp b/contrib/modules/ximgproc/src/anisodiff.cpp
new file mode 100644
index 0000000..370482b
--- /dev/null
+++ b/contrib/modules/ximgproc/src/anisodiff.cpp
@@ -0,0 +1,293 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+/* the reference code has been contributed by Chris Sav */
+
+#include "precomp.hpp"
+#include "opencv2/core/hal/intrin.hpp"
+#include "opencl_kernels_ximgproc.hpp"
+
+namespace cv {
+namespace ximgproc {
+
+#if CV_SIMD128
+inline void v_expand_s(const v_uint8x16& a, v_int16x8& b, v_int16x8& c)
+{
+ v_uint16x8 t0, t1;
+ v_expand(a, t0, t1);
+ b = v_reinterpret_as_s16(t0);
+ c = v_reinterpret_as_s16(t1);
+}
+
+inline void v_expand_f32(const v_int16x8& a, v_float32x4& b, v_float32x4& c)
+{
+ v_int32x4 t0, t1;
+ v_expand(a, t0, t1);
+ b = v_cvt_f32(t0);
+ c = v_cvt_f32(t1);
+}
+
+inline v_uint8x16 v_finalize_pix_ch(const v_int16x8& c0, const v_int16x8& c1,
+ const v_float32x4& s0, const v_float32x4& s1,
+ const v_float32x4& s2, const v_float32x4& s3,
+ const v_float32x4& alpha)
+{
+ v_float32x4 f0, f1, f2, f3;
+ v_expand_f32(c0, f0, f1);
+ v_expand_f32(c1, f2, f3);
+
+ v_int16x8 d0 = v_pack(v_round(s0*alpha + f0), v_round(s1*alpha + f1));
+ v_int16x8 d1 = v_pack(v_round(s2*alpha + f2), v_round(s3*alpha + f3));
+
+ return v_pack_u(d0, d1);
+}
+#endif
+
+class ADBody : public ParallelLoopBody
+{
+public:
+ ADBody(const Mat* src_, Mat* dst_, const float* exptab, float alpha)
+ {
+ src = src_;
+ dst = dst_;
+ exptab_ = exptab;
+ alpha_ = alpha;
+ }
+
+ void operator()(const Range& range) const
+ {
+ const int cn = 3;
+ int cols = src->cols;
+ int step = (int)src->step;
+ int tab[] = { -cn, cn, -step-cn, -step, -step+cn, step-cn, step, step+cn };
+ float alpha = alpha_;
+ const float* exptab = exptab_;
+
+ for( int i = range.start; i < range.end; i++ )
+ {
+ const uchar* psrc0 = src->ptr<uchar>(i);
+ uchar* pdst = dst->ptr<uchar>(i);
+ int j = 0;
+
+#if CV_SIMD128
+ v_float32x4 v_alpha = v_setall_f32(alpha);
+ for( ; j <= cols - 16; j += 16 )
+ {
+ v_uint8x16 c0, c1, c2;
+ v_load_deinterleave(psrc0 + j*3, c0, c1, c2);
+ v_int16x8 c00, c01, c10, c11, c20, c21;
+
+ v_expand_s(c0, c00, c01);
+ v_expand_s(c1, c10, c11);
+ v_expand_s(c2, c20, c21);
+
+ v_float32x4 s00 = v_setzero_f32(), s01 = s00, s02 = s00, s03 = s00;
+ v_float32x4 s10 = v_setzero_f32(), s11 = s00, s12 = s00, s13 = s00;
+ v_float32x4 s20 = v_setzero_f32(), s21 = s00, s22 = s00, s23 = s00;
+ v_float32x4 fd0, fd1, fd2, fd3;
+
+ for( int k = 0; k < 8; k++ )
+ {
+ const uchar* psrc1 = psrc0 + j*3 + tab[k];
+ v_uint8x16 p0, p1, p2;
+ v_int16x8 p00, p01, p10, p11, p20, p21;
+ v_load_deinterleave(psrc1, p0, p1, p2);
+
+ v_expand_s(p0, p00, p01);
+ v_expand_s(p1, p10, p11);
+ v_expand_s(p2, p20, p21);
+
+ v_int16x8 d00 = p00 - c00, d01 = p01 - c01;
+ v_int16x8 d10 = p10 - c10, d11 = p11 - c11;
+ v_int16x8 d20 = p20 - c20, d21 = p21 - c21;
+
+ v_uint16x8 n0 = v_abs(d00) + v_abs(d10) + v_abs(d20);
+ v_uint16x8 n1 = v_abs(d01) + v_abs(d11) + v_abs(d21);
+
+ ushort CV_DECL_ALIGNED(16) nbuf[16];
+ v_store(nbuf, n0);
+ v_store(nbuf + 8, n1);
+
+ v_float32x4 w0(exptab[nbuf[0]], exptab[nbuf[1]], exptab[nbuf[2]], exptab[nbuf[3]]);
+ v_float32x4 w1(exptab[nbuf[4]], exptab[nbuf[5]], exptab[nbuf[6]], exptab[nbuf[7]]);
+ v_float32x4 w2(exptab[nbuf[8]], exptab[nbuf[9]], exptab[nbuf[10]], exptab[nbuf[11]]);
+ v_float32x4 w3(exptab[nbuf[12]], exptab[nbuf[13]], exptab[nbuf[14]], exptab[nbuf[15]]);
+
+ v_expand_f32(d00, fd0, fd1);
+ v_expand_f32(d01, fd2, fd3);
+ s00 += fd0*w0; s01 += fd1*w1; s02 += fd2*w2; s03 += fd3*w3;
+ v_expand_f32(d10, fd0, fd1);
+ v_expand_f32(d11, fd2, fd3);
+ s10 += fd0*w0; s11 += fd1*w1; s12 += fd2*w2; s13 += fd3*w3;
+ v_expand_f32(d20, fd0, fd1);
+ v_expand_f32(d21, fd2, fd3);
+ s20 += fd0*w0; s21 += fd1*w1; s22 += fd2*w2; s23 += fd3*w3;
+ }
+
+ c0 = v_finalize_pix_ch(c00, c01, s00, s01, s02, s03, v_alpha);
+ c1 = v_finalize_pix_ch(c10, c11, s10, s11, s12, s13, v_alpha);
+ c2 = v_finalize_pix_ch(c20, c21, s20, s21, s22, s23, v_alpha);
+ v_store_interleave(pdst + j*3, c0, c1, c2);
+ }
+ j *= 3;
+#endif
+
+ for( ; j < cols*cn; j += cn )
+ {
+ int c0 = psrc0[j], c1 = psrc0[j+1], c2 = psrc0[j+2];
+ float s0 = 0.f, s1 = 0.f, s2 = 0.f;
+ for( int k = 0; k < 8; k++ )
+ {
+ const uchar* psrc1 = psrc0 + j + tab[k];
+ int delta0 = psrc1[0] - c0;
+ int delta1 = psrc1[1] - c1;
+ int delta2 = psrc1[2] - c2;
+ int nabla = std::abs(delta0) + std::abs(delta1) + std::abs(delta2);
+ float w = exptab[nabla];
+ s0 += delta0*w;
+ s1 += delta1*w;
+ s2 += delta2*w;
+ }
+ pdst[j] = saturate_cast<uchar>(c0 + alpha*s0);
+ pdst[j+1] = saturate_cast<uchar>(c1 + alpha*s1);
+ pdst[j+2] = saturate_cast<uchar>(c2 + alpha*s2);
+ }
+ }
+ }
+
+ const Mat* src;
+ Mat* dst;
+ const float* exptab_;
+ float alpha_;
+};
+
+#ifdef HAVE_OPENCL
+static bool ocl_anisotropicDiffusion(InputArray src_, OutputArray dst_,
+ float alpha, int niters,
+ const std::vector<float>& exptab)
+{
+ UMat src0 = src_.getUMat(), dst0 = dst_.getUMat();
+ int type = src0.type();
+ int rows = src0.rows, cols = src0.cols;
+
+ ocl::Kernel k("anisodiff", ocl::ximgproc::anisodiff_oclsrc, "");
+ if (k.empty())
+ return false;
+
+ UMat temp0x(rows + 2, cols + 2, type);
+ UMat temp1x(rows + 2, cols + 2, type);
+ UMat temp0(temp0x, Rect(1, 1, cols, rows));
+ UMat temp1(temp1x, Rect(1, 1, cols, rows));
+
+ int tabsz = (int)exptab.size();
+ UMat uexptab = Mat(1, tabsz, CV_32F, (void*)&exptab[0]).getUMat(ACCESS_READ);
+
+ for (int t = 0; t < niters; t++)
+ {
+ UMat src = temp0, dst = t == niters-1 ? dst0 : temp1;
+ copyMakeBorder(t == 0 ? src0 : src, temp0x, 1, 1, 1, 1, BORDER_REPLICATE);
+
+ k.args(ocl::KernelArg::ReadOnlyNoSize(src), ocl::KernelArg::WriteOnly(dst),
+ ocl::KernelArg::PtrReadOnly(uexptab), alpha);
+
+ size_t globalsize[] = { (size_t)cols, (size_t)rows };
+ if(!k.run(2, globalsize, NULL, true))
+ return false;
+
+ std::swap(temp0, temp1);
+ std::swap(temp0x, temp1x);
+ }
+ return true;
+}
+#endif
+
+void anisotropicDiffusion(InputArray src_, OutputArray dst_, float alpha, float K, int niters )
+{
+ if( niters == 0 )
+ {
+ src_.copyTo(dst_);
+ return;
+ }
+
+ int type = src_.type();
+ CV_Assert(src_.dims() == 2 && type == CV_8UC3);
+ CV_Assert(K != 0);
+ CV_Assert(alpha > 0);
+ CV_Assert(niters >= 0);
+
+ const int cn = 3;
+ float sigma = K * cn * 255.f;
+ float isigma2 = 1 / (sigma * sigma);
+ std::vector<float> exptab_(255*3);
+ float* exptab = &exptab_[0];
+
+ for( int k = 0; k < 255*3; k++ )
+ exptab[k] = std::exp(-k*k*isigma2);
+
+ dst_.create(src_.size(), type);
+
+ CV_OCL_RUN(dst_.isUMat(),
+ ocl_anisotropicDiffusion(src_, dst_, alpha, niters, exptab_));
+
+ Mat src0 = src_.getMat();
+ int rows = src0.rows, cols = src0.cols;
+
+ Mat dst0 = dst_.getMat();
+ Mat temp0x(rows + 2, cols + 2, type);
+ Mat temp1x(rows + 2, cols + 2, type);
+ Mat temp0(temp0x, Rect(1, 1, cols, rows));
+ Mat temp1(temp1x, Rect(1, 1, cols, rows));
+
+ for (int t = 0; t < niters; t++)
+ {
+ Mat src = temp0, dst = t == niters-1 ? dst0 : temp1;
+ copyMakeBorder(t == 0 ? src0 : src, temp0x, 1, 1, 1, 1, BORDER_REPLICATE);
+
+ ADBody body(&src, &dst, exptab, alpha);
+ parallel_for_(Range(0, rows), body, 8);
+
+ std::swap(temp0, temp1);
+ std::swap(temp0x, temp1x);
+ }
+}
+
+}
+}
diff --git a/contrib/modules/ximgproc/src/bilateral_texture_filter.cpp b/contrib/modules/ximgproc/src/bilateral_texture_filter.cpp
index 5be6c0a..2a37dc9 100644
--- a/contrib/modules/ximgproc/src/bilateral_texture_filter.cpp
+++ b/contrib/modules/ximgproc/src/bilateral_texture_filter.cpp
@@ -63,7 +63,7 @@ namespace ximgproc
if (sigmaAlpha < 0)
sigmaAlpha = 5. * fr;
if (sigmaAvg < 0)
- sigmaAvg = 0.05 * sqrt(src.channels());
+ sigmaAvg = 0.05 * sqrt(static_cast<float>(src.channels()));
Mat I;
src.copyTo(I);
diff --git a/contrib/modules/ximgproc/src/deriche_filter.cpp b/contrib/modules/ximgproc/src/deriche_filter.cpp
index a2495e6..98821cd 100644
--- a/contrib/modules/ximgproc/src/deriche_filter.cpp
+++ b/contrib/modules/ximgproc/src/deriche_filter.cpp
@@ -34,7 +34,6 @@
* the use of this software, even if advised of the possibility of such damage.
*/
#include "precomp.hpp"
-#include "opencv2/highgui.hpp"
#include <math.h>
#include <vector>
#include <iostream>
diff --git a/contrib/modules/ximgproc/src/disparity_filters.cpp b/contrib/modules/ximgproc/src/disparity_filters.cpp
index 77eb6ac..84f4498 100644
--- a/contrib/modules/ximgproc/src/disparity_filters.cpp
+++ b/contrib/modules/ximgproc/src/disparity_filters.cpp
@@ -2,26 +2,26 @@
* By downloading, copying, installing or using the software you agree to this license.
* If you do not agree to this license, do not download, install,
* copy or use the software.
- *
- *
+ *
+ *
* License Agreement
* For Open Source Computer Vision Library
* (3 - clause BSD License)
- *
+ *
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met :
- *
+ *
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
- *
+ *
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and / or other materials provided with the distribution.
- *
+ *
* * Neither the names of the copyright holders nor the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
+ *
* This software is provided by the copyright holders and contributors "as is" and
* any express or implied warranties, including, but not limited to, the implied
* warranties of merchantability and fitness for a particular purpose are disclaimed.
@@ -36,7 +36,7 @@
#include "precomp.hpp"
#include "opencv2/ximgproc/disparity_filter.hpp"
-#include "opencv2/highgui.hpp"
+#include "opencv2/imgcodecs.hpp"
#include <math.h>
#include <vector>
diff --git a/contrib/modules/ximgproc/src/fast_line_detector.cpp b/contrib/modules/ximgproc/src/fast_line_detector.cpp
index 625e14e..ffd7a58 100644
--- a/contrib/modules/ximgproc/src/fast_line_detector.cpp
+++ b/contrib/modules/ximgproc/src/fast_line_detector.cpp
@@ -182,10 +182,10 @@ void FastLineDetectorImpl::drawSegments(InputOutputArray _image, InputArray line
getAngle(seg);
double ang = (double)seg.angle;
Point2i p1;
- p1.x = (int)round(seg.x2 - gap*cos(arrow_angle * CV_PI / 180.0 + ang));
- p1.y = (int)round(seg.y2 - gap*sin(arrow_angle * CV_PI / 180.0 + ang));
+ p1.x = cvRound(seg.x2 - gap*cos(arrow_angle * CV_PI / 180.0 + ang));
+ p1.y = cvRound(seg.y2 - gap*sin(arrow_angle * CV_PI / 180.0 + ang));
pointInboardTest(_image.getMatRef(), p1);
- line(_image.getMatRef(), Point((int)round(seg.x2), (int)round(seg.y2)), p1, Scalar(0,0,255), 1);
+ line(_image.getMatRef(), Point(cvRound(seg.x2), cvRound(seg.y2)), p1, Scalar(0,0,255), 1);
}
}
}
@@ -717,14 +717,14 @@ void FastLineDetectorImpl::drawSegment(Mat& mat, const SEGMENT& seg, Scalar bgr,
double arrow_angle = 30.0;
Point2i p1;
- p1.x = (int)round(seg.x2 - gap*cos(arrow_angle * CV_PI / 180.0 + ang));
- p1.y = (int)round(seg.y2 - gap*sin(arrow_angle * CV_PI / 180.0 + ang));
+ p1.x = cvRound(seg.x2 - gap*cos(arrow_angle * CV_PI / 180.0 + ang));
+ p1.y = cvRound(seg.y2 - gap*sin(arrow_angle * CV_PI / 180.0 + ang));
pointInboardTest(mat, p1);
- line(mat, Point((int)round(seg.x1), (int)round(seg.y1)),
- Point((int)round(seg.x2), (int)round(seg.y2)), bgr, thickness, 1);
+ line(mat, Point(cvRound(seg.x1), cvRound(seg.y1)),
+ Point(cvRound(seg.x2), cvRound(seg.y2)), bgr, thickness, 1);
if(directed)
- line(mat, Point((int)round(seg.x2), (int)round(seg.y2)), p1, bgr, thickness, 1);
+ line(mat, Point(cvRound(seg.x2), cvRound(seg.y2)), p1, bgr, thickness, 1);
}
} // namespace cv
} // namespace ximgproc
diff --git a/contrib/modules/ximgproc/src/lsc.cpp b/contrib/modules/ximgproc/src/lsc.cpp
index 1575406..60a7178 100644
--- a/contrib/modules/ximgproc/src/lsc.cpp
+++ b/contrib/modules/ximgproc/src/lsc.cpp
@@ -768,22 +768,25 @@ inline void SuperpixelLSCImpl::PostEnforceLabelConnectivity( int threshold )
double W = W1 + W2;
- for ( int b = 0; b < m_nr_channels; b++ )
+ if ( (Label1 > 0) && (Label2 > 0) )
{
- centerC1[b][Label2] = float((W2*centerC1[b][Label2] + W1*centerC1[b][Label1]) / W);
- centerC2[b][Label2] = float((W2*centerC2[b][Label2] + W1*centerC2[b][Label1]) / W);
- }
- centerX1[Label2] = float((W2*centerX1[Label2] + W1*centerX1[Label1]) / W);
- centerX2[Label2] = float((W2*centerX2[Label2] + W1*centerX2[Label1]) / W);
- centerY1[Label2] = float((W2*centerY1[Label2] + W1*centerY1[Label1]) / W);
- centerY2[Label2] = float((W2*centerY2[Label2] + W1*centerY2[Label1]) / W);
+ for ( int b = 0; b < m_nr_channels; b++ )
+ {
+ centerC1[b][Label2] = float((W2*centerC1[b][Label2] + W1*centerC1[b][Label1]) / W);
+ centerC2[b][Label2] = float((W2*centerC2[b][Label2] + W1*centerC2[b][Label1]) / W);
+ }
+ centerX1[Label2] = float((W2*centerX1[Label2] + W1*centerX1[Label1]) / W);
+ centerX2[Label2] = float((W2*centerX2[Label2] + W1*centerX2[Label1]) / W);
+ centerY1[Label2] = float((W2*centerY1[Label2] + W1*centerY1[Label1]) / W);
+ centerY2[Label2] = float((W2*centerY2[Label2] + W1*centerY2[Label1]) / W);
- centerW[Label2] = (float)W;
- for( size_t i = 0; i < (*S).xLoc.size(); i++ )
- {
- int x = (*S).xLoc[i];
- int y = (*S).yLoc[i];
- m_klabels.at<int>(y,x) = Label2;
+ centerW[Label2] = (float)W;
+ for( size_t i = 0; i < (*S).xLoc.size(); i++ )
+ {
+ int x = (*S).xLoc[i];
+ int y = (*S).yLoc[i];
+ m_klabels.at<int>(y,x) = Label2;
+ }
}
vector<Superpixel>::iterator Stmp;
@@ -793,8 +796,23 @@ inline void SuperpixelLSCImpl::PostEnforceLabelConnectivity( int threshold )
Size[Label2] = Size[Label1] + Size[Label2];
if( Size[Label2] >= threshold )
{
- Sarray.erase( S );
- Sarray.erase( Stmp );
+ if( S == Stmp )
+ {
+ // erasing only one should be sufficient when the iterators are the same
+ // (maybe the case S == Stmp is not even possible?)
+ Sarray.erase( S );
+ }
+ else if( S < Stmp )
+ {
+ // erase the latter element first, so the other iterator is not invalidated
+ Sarray.erase( Stmp );
+ Sarray.erase( S );
+ }
+ else
+ {
+ Sarray.erase( S );
+ Sarray.erase( Stmp );
+ }
}
else
{
@@ -1165,7 +1183,7 @@ inline void SuperpixelLSCImpl::GetFeatureSpace()
}
// compute m_W normalization array
- m_W = Mat( m_height, m_width, CV_32F );
+ m_W = Mat( m_height, m_width, CV_32F, 0.0f );
parallel_for_( Range(0, m_width), FeatureSpaceWeights( m_chvec, &m_W,
sigmaX1, sigmaX2, sigmaY1, sigmaY2, sigmaC1, sigmaC2,
m_nr_channels, m_chvec_max, m_dist_coeff, m_color_coeff,
@@ -1742,10 +1760,6 @@ inline void SuperpixelLSCImpl::PerformLSC( const int& itrnum )
¢erC1, ¢erC2, m_nr_channels, m_chvec_max,
m_dist_coeff, m_color_coeff, m_stepx, m_stepy ) );
- // parallel reduce structure
- FeatureCenterDists fcd( m_chvec, m_W, m_klabels, m_nr_channels, m_chvec_max,
- m_dist_coeff, m_color_coeff, m_stepx, m_stepy, m_numlabels );
-
// K-Means
for( int itr = 0; itr < itrnum; itr++ )
{
@@ -1759,6 +1773,10 @@ inline void SuperpixelLSCImpl::PerformLSC( const int& itrnum )
m_nr_channels, m_chvec_max, m_dist_coeff, m_color_coeff,
m_stepx, m_stepy ) );
+ // parallel reduce structure
+ FeatureCenterDists fcd( m_chvec, m_W, m_klabels, m_nr_channels, m_chvec_max,
+ m_dist_coeff, m_color_coeff, m_stepx, m_stepy, m_numlabels );
+
// accumulate center distances
parallel_reduce( BlockedRange(0, m_width), fcd );
diff --git a/contrib/modules/ximgproc/src/niblack_thresholding.cpp b/contrib/modules/ximgproc/src/niblack_thresholding.cpp
index f2ee962..58716f3 100644
--- a/contrib/modules/ximgproc/src/niblack_thresholding.cpp
+++ b/contrib/modules/ximgproc/src/niblack_thresholding.cpp
@@ -47,12 +47,15 @@ namespace cv {
namespace ximgproc {
void niBlackThreshold( InputArray _src, OutputArray _dst, double maxValue,
- int type, int blockSize, double delta )
+ int type, int blockSize, double k, int binarizationMethod )
{
// Input grayscale image
Mat src = _src.getMat();
CV_Assert(src.channels() == 1);
CV_Assert(blockSize % 2 == 1 && blockSize > 1);
+ if (binarizationMethod == BINARIZATION_SAUVOLA) {
+ CV_Assert(src.depth() == CV_8U);
+ }
type &= THRESH_MASK;
// Compute local threshold (T = mean + k * stddev)
@@ -61,13 +64,35 @@ void niBlackThreshold( InputArray _src, OutputArray _dst, double maxValue,
Mat thresh;
{
// note that: Var[X] = E[X^2] - E[X]^2
- Mat mean, sqmean, stddev;
+ Mat mean, sqmean, variance, stddev, sqrtVarianceMeanSum;
+ double srcMin, stddevMax;
boxFilter(src, mean, CV_32F, Size(blockSize, blockSize),
Point(-1,-1), true, BORDER_REPLICATE);
sqrBoxFilter(src, sqmean, CV_32F, Size(blockSize, blockSize),
Point(-1,-1), true, BORDER_REPLICATE);
- sqrt(sqmean - mean.mul(mean), stddev);
- thresh = mean + stddev * static_cast<float>(delta);
+ variance = sqmean - mean.mul(mean);
+ sqrt(variance, stddev);
+ switch (binarizationMethod)
+ {
+ case BINARIZATION_NIBLACK:
+ thresh = mean + stddev * static_cast<float>(k);
+ break;
+ case BINARIZATION_SAUVOLA:
+ thresh = mean.mul(1. + static_cast<float>(k) * (stddev / 128.0 - 1.));
+ break;
+ case BINARIZATION_WOLF:
+ minMaxIdx(src, &srcMin);
+ minMaxIdx(stddev, NULL, &stddevMax);
+ thresh = mean - static_cast<float>(k) * (mean - srcMin - stddev.mul(mean - srcMin) / stddevMax);
+ break;
+ case BINARIZATION_NICK:
+ sqrt(variance + sqmean, sqrtVarianceMeanSum);
+ thresh = mean + static_cast<float>(k) * sqrtVarianceMeanSum;
+ break;
+ default:
+ CV_Error( CV_StsBadArg, "Unknown binarization method" );
+ break;
+ }
thresh.convertTo(thresh, src.depth());
}
diff --git a/contrib/modules/ximgproc/src/opencl/anisodiff.cl b/contrib/modules/ximgproc/src/opencl/anisodiff.cl
new file mode 100644
index 0000000..be72ed7
--- /dev/null
+++ b/contrib/modules/ximgproc/src/opencl/anisodiff.cl
@@ -0,0 +1,39 @@
+__kernel void anisodiff(__global const uchar * srcptr, int srcstep, int srcoffset,
+ __global uchar * dstptr, int dststep, int dstoffset,
+ int rows, int cols, __constant float* exptab, float alpha)
+{
+ int x = get_global_id(0);
+ int y = get_global_id(1);
+
+ if( x < cols && y < rows )
+ {
+ int yofs = y*dststep + x*3;
+ int xofs = y*srcstep + x*3;
+ float4 s = 0.f;
+
+ float4 c = (float4)(srcptr[xofs], srcptr[xofs+1], srcptr[xofs+2], 0.f);
+ float4 delta, adelta;
+ float w;
+
+ #define UPDATE_SUM(xofs1) \
+ delta = (float4)(srcptr[xofs + xofs1], srcptr[xofs + xofs1 + 1], srcptr[xofs + xofs1 + 2], 0.f) - c; \
+ adelta = fabs(delta); \
+ w = exptab[convert_int(adelta.x + adelta.y + adelta.z)]; \
+ s += delta*w
+
+ UPDATE_SUM(3);
+ UPDATE_SUM(-3);
+ UPDATE_SUM(-srcstep-3);
+ UPDATE_SUM(-srcstep);
+ UPDATE_SUM(-srcstep+3);
+ UPDATE_SUM(srcstep-3);
+ UPDATE_SUM(srcstep);
+ UPDATE_SUM(srcstep+3);
+
+ s = s*alpha + c;
+ uchar4 d = convert_uchar4_sat(convert_int4_rte(s));
+ dstptr[yofs] = d.x;
+ dstptr[yofs+1] = d.y;
+ dstptr[yofs+2] = d.z;
+ }
+}
diff --git a/contrib/modules/ximgproc/src/paillou_filter.cpp b/contrib/modules/ximgproc/src/paillou_filter.cpp
index a821580..59701de 100644
--- a/contrib/modules/ximgproc/src/paillou_filter.cpp
+++ b/contrib/modules/ximgproc/src/paillou_filter.cpp
@@ -1,17 +1,132 @@
+/*
+* By downloading, copying, installing or using the software you agree to this license.
+* If you do not agree to this license, do not download, install,
+* copy or use the software.
+*
+*
+* License Agreement
+* For Open Source Computer Vision Library
+* (3 - clause BSD License)
+*
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met :
+*
+* * Redistributions of source code must retain the above copyright notice,
+* this list of conditions and the following disclaimer.
+*
+* * Redistributions in binary form must reproduce the above copyright notice,
+* this list of conditions and the following disclaimer in the documentation
+* and / or other materials provided with the distribution.
+*
+* * Neither the names of the copyright holders nor the names of the contributors
+* may be used to endorse or promote products derived from this software
+* without specific prior written permission.
+*
+* This software is provided by the copyright holders and contributors "as is" and
+* any express or implied warranties, including, but not limited to, the implied
+* warranties of merchantability and fitness for a particular purpose are disclaimed.
+* In no event shall copyright holders or contributors be liable for any direct,
+* indirect, incidental, special, exemplary, or consequential damages
+* (including, but not limited to, procurement of substitute goods or services;
+* loss of use, data, or profits; or business interruption) however caused
+* and on any theory of liability, whether in contract, strict liability,
+* or tort(including negligence or otherwise) arising in any way out of
+* the use of this software, even if advised of the possibility of such damage.
+*/
#include "precomp.hpp"
-#include "opencv2/highgui.hpp"
#include <math.h>
#include <vector>
#include <iostream>
-namespace cv {
-namespace ximgproc {
-
/*
If you use this code please cite this @cite paillou1997detecting
Detecting step edges in noisy SAR images: a new linear operator IEEE Transactions on Geoscience and Remote Sensing (Volume:35 , Issue: 1 ) 1997
+Equation xx pyyy mean equation xx at page yyy in previous paper
*/
+namespace cv {
+namespace ximgproc {
+
+template<typename T> static void
+VerticalIIRFilter(Mat &img, Mat &dst, const Range &range, double a,double w)
+{
+ float *f2;
+ int tailleSequence = (img.rows>img.cols) ? img.rows : img.cols;
+ Mat matYp(1, tailleSequence, CV_64FC1), matYm(1, tailleSequence, CV_64FC1);
+ double *yp = matYp.ptr<double>(0), *ym = matYm.ptr<double>(0);
+ int rows = img.rows, cols = img.cols;
+
+ // Equation 12 p193
+ double b1 = -2 * exp(-a)*cosh(w);
+ double a1 = 2 * exp(-a)*cosh(w) - exp(-2 * a) - 1;
+ double b2 = exp(-2 * a);
+ for (int j = range.start; j < range.end; j++)
+ {
+ // Equation 26 p194
+ T *c1 = (T *)img.ptr(0) + j;
+ f2 = dst.ptr<float>(0) + j;
+ double border = *c1;
+ yp[0] = *c1;
+ c1 += cols;
+ yp[1] = *c1 - b1*yp[0] - b2*border;
+ c1 += cols;
+ for (int i = 2; i < rows; i++, c1 += cols)
+ yp[i] = *c1 - b1*yp[i - 1] - b2*yp[i - 2];
+ // Equation 27 p194
+ c1 = (T *)img.ptr(rows - 1) + j;
+ border = *c1;
+ ym[rows - 1] = *c1;
+ c1 -= cols;
+ ym[rows - 2] = *c1 - b1*ym[rows - 1];
+ c1 -= cols;
+ for (int i = rows - 3; i >= 0; i--, c1 -= cols)
+ ym[i] = *c1 - b1*ym[i + 1] - b2*ym[i + 2];
+ // Equation 25 p193
+ for (int i = 0; i < rows; i++, f2 += cols)
+ *f2 = (float)(a1*(ym[i] - yp[i]));
+ }
+}
+
+template<typename T> static void
+HorizontalIIRFilter(Mat &img, Mat &dst, const Range &range, double a, double w)
+{
+ int tailleSequence = (img.rows>img.cols) ? img.rows : img.cols;
+ Mat matYp(1, tailleSequence, CV_64FC1), matYm(1, tailleSequence, CV_64FC1);
+ double *yp = matYp.ptr<double>(0), *ym = matYm.ptr<double>(0);
+ int cols = img.cols;
+ float *f2;
+
+ // Equation 12 p193
+ double b1 = -2 * exp(-a)*cosh(w);
+ double a1 = 2 * exp(-a)*cosh(w) - exp(-2 * a) - 1;
+ double b2 = exp(-2 * a);
+
+ for (int i = range.start; i<range.end; i++)
+ {
+ // Equation 26 p194
+ T *c1 = img.ptr<T>(i);
+ double border = *c1;
+ yp[0] = *c1;
+ c1++;
+ yp[1] = *c1 - b1*yp[0] - b2*border;
+ c1++;
+ for (int j = 2; j<cols; j++, c1++)
+ yp[j] = *c1 - b1*yp[j - 1] - b2*yp[j - 2];
+ // Equation 27 p194
+ c1 = img.ptr<T>(i) + cols - 1;
+ border = *c1;
+ ym[cols - 1] = *c1;
+ c1--;
+ ym[cols - 2] = *c1 - b1*ym[cols - 1];
+ c1--;
+ for (int j = cols - 3; j >= 0; j--, c1--)
+ ym[j] = *c1 - b1*ym[j + 1] - b2*ym[j + 2];
+ // Equation 25 p193
+ f2 = dst.ptr<float>(i);
+ for (int j = 0; j<cols; j++, f2++)
+ *f2 = (float)(a1*(ym[j] - yp[j]));
+ }
+}
class ParallelGradientPaillouYCols: public ParallelLoopBody
{
@@ -36,98 +151,19 @@ public:
CV_Assert(dst.depth()==CV_32FC1);
if (verbose)
std::cout << getThreadNum()<<"# :Start from row " << range.start << " to " << range.end-1<<" ("<<range.end-range.start<<" loops)" << std::endl;
- float *f2;
- int tailleSequence=(img.rows>img.cols)?img.rows:img.cols;
- Mat matYp(1,tailleSequence,CV_64FC1), matYm(1,tailleSequence,CV_64FC1);
- double *yp=matYp.ptr<double>(0), *ym=matYm.ptr<double>(0);
- int rows=img.rows,cols=img.cols;
-
- // Equation 12 p193
- double b1=-2*exp(-a)*cosh(w);
- double a1=2*exp(-a)*cosh(w)-exp(-2*a)-1;
- double b2=exp(-2*a);
switch(img.depth()){
- case CV_8U :
- for (int j=range.start;j<range.end;j++)
- {
- // Equation 26 p194
- uchar *c1 = img.ptr(0)+j;
- f2 = dst.ptr<float>(0)+j;
- double border=*c1;
- yp[0] = *c1 ;
- c1+=cols;
- yp[1] = *c1 - b1*yp[0]-b2*border;
- c1+=cols;
- for (int i=2;i<rows;i++,c1+=cols)
- yp[i] = *c1-b1*yp[i-1]-b2*yp[i-2];
- // Equation 27 p194
- c1 = img.ptr(rows-1)+j;
- border=*c1;
- ym[rows - 1] = *c1;
- c1 -= cols;
- ym[rows-2] =*c1 - b1*ym[rows-1];
- c1 -= cols;
- for (int i=rows-3;i>=0;i--,c1-=cols)
- ym[i]=*c1-b1*ym[i+1]-b2*ym[i+2];
- // Equation 25 p193
- for (int i=0;i<rows;i++,f2+=cols)
- *f2 = (float)(a1*(ym[i]-yp[i]));
- }
+ case CV_8U:
+ VerticalIIRFilter<uchar>(img, dst, range, a, w);
+ break;
+ case CV_8S:
+ VerticalIIRFilter<char>(img, dst, range, a, w);
break;
case CV_16S :
- for (int j = range.start; j<range.end; j++)
- {
- // Equation 26 p194
- short *c1 = img.ptr<short>(0) + j;
- f2 = dst.ptr<float>(0) + j;
- double border = *c1;
- yp[0] = *c1;
- c1 += cols;
- yp[1] = *c1 - b1*yp[0] - b2*border;
- c1 += cols;
- for (int i = 2; i<rows; i++, c1 += cols)
- yp[i] = *c1 - b1*yp[i - 1] - b2*yp[i - 2];
- // Equation 27 p194
- c1 = img.ptr<short>(rows - 1) + j;
- border = *c1;
- ym[rows - 1] = *c1;
- c1 -= cols;
- ym[rows - 2] = *c1 - b1*ym[rows - 1];
- c1 -= cols;
- for (int i = rows - 3; i >= 0; i--, c1 -= cols)
- ym[i] = *c1 - b1*ym[i + 1] - b2*ym[i + 2];
- // Equation 25 p193
- for (int i = 0; i<rows; i++, f2 += cols)
- *f2 = (float)(a1*(ym[i] - yp[i]));
- }
- break;
+ VerticalIIRFilter<short>(img, dst, range, a, w);
+ break;
case CV_16U :
- for (int j = range.start; j<range.end; j++)
- {
- // Equation 26 p194
- ushort *c1 = img.ptr<ushort>(0) + j;
- f2 = dst.ptr<float>(0) + j;
- double border = *c1;
- yp[0] = *c1;
- c1 += cols;
- yp[1] = *c1 - b1*yp[0] - b2*border;
- c1 += cols;
- for (int i = 2; i<rows; i++, c1 += cols)
- yp[i] = *c1 - b1*yp[i - 1] - b2*yp[i - 2];
- // Equation 27 p194
- c1 = img.ptr<ushort>(rows - 1) + j;
- border = *c1;
- ym[rows - 1] = *c1;
- c1 -= cols;
- ym[rows - 2] = *c1 - b1*ym[rows - 1];
- c1 -= cols;
- for (int i = rows - 3; i >= 0; i--, c1 -= cols)
- ym[i] = *c1 - b1*ym[i + 1] - b2*ym[i + 2];
- // Equation 25 p193
- for (int i = 0; i<rows; i++, f2 += cols)
- *f2 = (float)(a1*(ym[i] - yp[i]));
- }
+ VerticalIIRFilter<short>(img, dst, range, a, w);
break;
default :
return ;
@@ -301,125 +337,20 @@ public:
{
if (verbose)
std::cout << getThreadNum()<<"# :Start from row " << range.start << " to " << range.end-1<<" ("<<range.end-range.start<<" loops)" << std::endl;
- float *f2;
- int tailleSequence = (img.rows>img.cols) ? img.rows : img.cols;
- Mat matYp(1,tailleSequence,CV_64FC1), matYm(1,tailleSequence,CV_64FC1);
- double *yp=matYp.ptr<double>(0), *ym=matYm.ptr<double>(0);
- int cols = img.cols;
// Equation 12 p193
- double b1 = -2 * exp(-a)*cosh(w);
- double a1 = 2 * exp(-a)*cosh(w) - exp(-2 * a) - 1;
- double b2 = exp(-2 * a);
-
switch(img.depth()){
case CV_8U :
- for (int i = range.start; i<range.end; i++)
- {
- // Equation 26 p194
- uchar *c1 = img.ptr(i);
- double border = *c1;
- yp[0] = *c1;
- c1++;
- yp[1] = *c1 - b1*yp[0] - b2*border;
- c1++;
- for (int j = 2; j<cols; j++, c1++)
- yp[j] = *c1 - b1*yp[j - 1] - b2*yp[j - 2];
- // Equation 27 p194
- c1 = img.ptr(i)+cols-1;
- border = *c1;
- ym[cols - 1] = *c1;
- c1--;
- ym[cols - 2] = *c1 - b1*ym[cols - 1];
- c1--;
- for (int j = cols - 3; j >= 0; j--, c1--)
- ym[j] = *c1 - b1*ym[j + 1] - b2*ym[j + 2];
- // Equation 25 p193
- f2 = im1.ptr<float>(i);
- for (int j = 0; j<cols; j++, f2 ++)
- *f2 = (float)(a1*(ym[j] - yp[j]));
- }
+ HorizontalIIRFilter<uchar>(img,im1,range,a,w);
break;
case CV_8S :
- for (int i = range.start; i<range.end; i++)
- {
- // Equation 26 p194
- char *c1 = img.ptr<char>(i);
- double border = *c1;
- yp[0] = *c1;
- c1++;
- yp[1] = *c1 - b1*yp[0] - b2*border;
- c1++;
- for (int j = 2; j<cols; j++, c1++)
- yp[j] = *c1 - b1*yp[j - 1] - b2*yp[j - 2];
- // Equation 27 p194
- c1 = img.ptr<char>(i)+cols-1;
- border = *c1;
- ym[cols - 1] = *c1;
- c1--;
- ym[cols - 2] = *c1 - b1*ym[cols - 1];
- c1--;
- for (int j = cols - 3; j >= 0; j--, c1--)
- ym[j] = *c1 - b1*ym[j + 1] - b2*ym[j + 2];
- // Equation 25 p193
- f2 = im1.ptr<float>(i);
- for (int j = 0; j<cols; j++, f2 ++)
- *f2 = (float)(a1*(ym[j] - yp[j]));
- }
+ HorizontalIIRFilter<char>(img, im1, range, a, w);
break;
case CV_16S :
- for (int i = range.start; i<range.end; i++)
- {
- // Equation 26 p194
- short *c1 = img.ptr<short>(i);
- f2 = im1.ptr<float>(i);
- double border = *c1;
- yp[0] = *c1;
- c1++;
- yp[1] = *c1 - b1*yp[0] - b2*border;
- c1++;
- for (int j = 2; j<cols; j++, c1++)
- yp[j] = *c1 - b1*yp[j - 1] - b2*yp[j - 2];
- // Equation 27 p194
- c1 = img.ptr<short>(i) + cols - 1;
- border = *c1;
- ym[cols - 1] = *c1;
- c1--;
- ym[cols - 2] = *c1 - b1*ym[cols - 1];
- c1--;
- for (int j = cols - 3; j >= 0; j--, c1--)
- ym[j] = *c1 - b1*ym[j + 1] - b2*ym[j + 2];
- // Equation 25 p193
- for (int j = 0; j<cols; j++, f2++)
- *f2 = (float)(a1*(ym[i] - yp[i]));
- }
+ HorizontalIIRFilter<short>(img, im1, range, a, w);
break;
case CV_16U :
- for (int i = range.start; i<range.end; i++)
- {
- // Equation 26 p194
- ushort *c1 = img.ptr<ushort>(i);
- f2 = im1.ptr<float>(i);
- double border = *c1;
- yp[0] = *c1;
- c1++;
- yp[1] = *c1 - b1*yp[0] - b2*border;
- c1++;
- for (int j = 2; j<cols; j++, c1++)
- yp[j] = *c1 - b1*yp[j - 1] - b2*yp[j - 2];
- // Equation 27 p194
- c1 = img.ptr<ushort>(i) + cols - 1;
- border = *c1;
- ym[cols - 1] = *c1;
- c1--;
- ym[cols - 2] = *c1 - b1*ym[cols - 1];
- c1--;
- for (int j = cols - 3; j >= 0; j--, c1--)
- ym[j] = *c1 - b1*ym[j + 1] - b2*ym[j + 2];
- // Equation 25 p193
- for (int j = 0; j<cols; j++, f2++)
- *f2 = (float)(a1*(ym[i] - yp[i]));
- }
+ HorizontalIIRFilter<ushort>(img, im1, range, a, w);
break;
default :
return ;
@@ -432,53 +363,38 @@ public:
void GradientPaillouY(InputArray _op, OutputArray _dst, double alpha, double omega)
{
- Mat tmp(_op.size(),CV_32FC(_op.channels()));
- _dst.create( _op.size(),CV_32FC(tmp.channels()) );
- cv::Mat opSrc = _op.getMat();
std::vector<Mat> planSrc;
- split(opSrc,planSrc);
+ split(_op,planSrc);
std::vector<Mat> planTmp;
- split(tmp,planTmp);
std::vector<Mat> planDst;
- split(_dst,planDst);
- for (int i = 0; i < static_cast<int>(planSrc.size()); i++)
+ for (int i = 0; i <static_cast<int>(planSrc.size()); i++)
{
- if (planSrc[i].isContinuous() && planTmp[i].isContinuous() && planDst[i].isContinuous())
- {
- ParallelGradientPaillouYCols x(planSrc[i],planTmp[i],alpha,omega);
- parallel_for_(Range(0,opSrc.cols), x,getNumThreads());
- ParallelGradientPaillouYRows xr(planTmp[i],planDst[i],alpha,omega);
- parallel_for_(Range(0,opSrc.rows), xr,getNumThreads());
-
- }
- else
- std::cout << "PB";
+ planTmp.push_back(Mat(_op.size(), CV_32FC1));
+ planDst.push_back(Mat(_op.size(), CV_32FC1));
+ CV_Assert(planSrc[i].isContinuous() && planTmp[i].isContinuous() && planDst[i].isContinuous());
+ ParallelGradientPaillouYCols x(planSrc[i],planTmp[i],alpha,omega);
+ parallel_for_(Range(0, planSrc[i].cols), x,getNumThreads());
+ ParallelGradientPaillouYRows xr(planTmp[i],planDst[i],alpha,omega);
+ parallel_for_(Range(0, planTmp[i].rows), xr,getNumThreads());
}
merge(planDst,_dst);
}
void GradientPaillouX(InputArray _op, OutputArray _dst, double alpha, double omega)
{
- Mat tmp(_op.size(),CV_32FC(_op.channels()));
- _dst.create( _op.size(),CV_32FC(tmp.channels()) );
- Mat opSrc = _op.getMat();
std::vector<Mat> planSrc;
- split(opSrc,planSrc);
+ split(_op,planSrc);
std::vector<Mat> planTmp;
- split(tmp,planTmp);
std::vector<Mat> planDst;
- split(_dst,planDst);
- for (int i = 0; i < static_cast<int>(planSrc.size()); i++)
+ for (int i = 0; i <static_cast<int>(planSrc.size()); i++)
{
- if (planSrc[i].isContinuous() && planTmp[i].isContinuous() && planDst[i].isContinuous())
- {
- ParallelGradientPaillouXRows x(planSrc[i],planTmp[i],alpha,omega);
- parallel_for_(Range(0,opSrc.rows), x,getNumThreads());
- ParallelGradientPaillouXCols xr(planTmp[i],planDst[i],alpha,omega);
- parallel_for_(Range(0,opSrc.cols), xr,getNumThreads());
- }
- else
- std::cout << "PB";
+ planTmp.push_back(Mat(_op.size(), CV_32FC1));
+ planDst.push_back(Mat(_op.size(), CV_32FC1));
+ CV_Assert(planSrc[i].isContinuous() && planTmp[i].isContinuous() && planDst[i].isContinuous());
+ ParallelGradientPaillouXRows x(planSrc[i],planTmp[i],alpha,omega);
+ parallel_for_(Range(0, planSrc[i].rows), x,getNumThreads());
+ ParallelGradientPaillouXCols xr(planTmp[i],planDst[i],alpha,omega);
+ parallel_for_(Range(0, planTmp[i].cols), xr,getNumThreads());
}
merge(planDst,_dst);
}
diff --git a/contrib/modules/ximgproc/src/rolling_guidance_filter.cpp b/contrib/modules/ximgproc/src/rolling_guidance_filter.cpp
index 0786ea0..7e6d267 100644
--- a/contrib/modules/ximgproc/src/rolling_guidance_filter.cpp
+++ b/contrib/modules/ximgproc/src/rolling_guidance_filter.cpp
@@ -36,7 +36,6 @@
#include "precomp.hpp"
#include <opencv2/ximgproc.hpp>
-#include <opencv2/highgui.hpp>
namespace cv
{
diff --git a/contrib/modules/ximgproc/src/selectivesearchsegmentation.cpp b/contrib/modules/ximgproc/src/selectivesearchsegmentation.cpp
index cfcc7c0..e8c6443 100644
--- a/contrib/modules/ximgproc/src/selectivesearchsegmentation.cpp
+++ b/contrib/modules/ximgproc/src/selectivesearchsegmentation.cpp
@@ -39,7 +39,6 @@ the use of this software, even if advised of the possibility of such damage.
********************************************************************************/
#include "precomp.hpp"
-#include "opencv2/highgui.hpp"
#include "opencv2/ximgproc/segmentation.hpp"
#include <iostream>
@@ -143,7 +142,7 @@ namespace cv {
Mat regions = regions_.getMat();
sizes = sizes_.getMat();
- if (image_id != -1 && last_image_id != image_id) {
+ if (image_id == -1 || last_image_id != image_id) {
std::vector<Mat> img_planes;
split(img, img_planes);
@@ -508,7 +507,7 @@ namespace cv {
Mat regions = regions_.getMat();
sizes = sizes_.getMat();
- if (image_id != -1 && last_image_id != image_id) {
+ if (image_id == -1 || last_image_id != image_id) {
std::vector<Mat> img_planes;
split(img, img_planes);
diff --git a/contrib/modules/ximgproc/src/slic.cpp b/contrib/modules/ximgproc/src/slic.cpp
index 4f955fd..d57a6d7 100644
--- a/contrib/modules/ximgproc/src/slic.cpp
+++ b/contrib/modules/ximgproc/src/slic.cpp
@@ -1,11 +1,16 @@
/*********************************************************************
* Software License Agreement (BSD License)
*
- * Copyright (c) 2013
+ * SLIC, SLICO Copyright (c) 2013
* Radhakrishna Achanta
* email : Radhakrishna [dot] Achanta [at] epfl [dot] ch
* web : http://ivrl.epfl.ch/people/achanta
*
+ * MSLIC Copyright (c) 2016, 2017
+ * Yong-Jin Liu
+ * email : liuyongjin [at] tsinghua [dot] edu [dot] cn
+ * web : http://47.89.51.189/liuyj
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -44,6 +49,12 @@
Aurelien Lucchi, Pascal Fua, and Sabine Süsstrunk, EPFL Technical
Report no. 149300, June 2010.
+ "Intrinsic Manifold SLIC: A Simple and Efficient Method for Computing
+ Content-Sensitive Superpixels"
+ Yong-Jin Liu, Cheng-Chi Yu, Min-Jing Yu, Ying He,
+ IEEE Transactions on Pattern Analysis and Machine Intelligence,
+ March 2017, Issue 99.
+
OpenCV port by: Cristian Balint <cristian dot balint at gmail dot com>
*/
@@ -99,6 +110,19 @@ protected:
// compactness
float m_ruler;
+ // ratio (MSLIC)
+ float m_ratio;
+
+ // split (MSLIC)
+ float m_split;
+
+ // current iter
+ int m_cur_iter;
+
+ // current iter
+ int m_iterations;
+
+
private:
// labels no
@@ -120,6 +144,12 @@ private:
// seeds storage
vector< vector<float> > m_kseeds;
+ // adaptive k (MSLIC)
+ vector<float> m_adaptk;
+
+ // merge threshold (MSLIC)
+ float m_merge;
+
// initialization
inline void initialize();
@@ -140,6 +170,13 @@ private:
// SLICO
inline void PerformSLICO( const int& num_iterations );
+
+ // MSLIC
+ inline void PerformMSLIC( const int& num_iterations );
+
+ // MSLIC
+ inline void SuperpixelSplit();
+
};
CV_EXPORTS Ptr<SuperpixelSLIC> createSuperpixelSLIC( InputArray image, int algorithm, int region_size, float ruler )
@@ -221,7 +258,8 @@ void SuperpixelSLICImpl::initialize()
if( m_algorithm == SLICO )
GetChSeedsK();
- else if( m_algorithm == SLIC )
+ else if( ( m_algorithm == SLIC ) ||
+ ( m_algorithm == MSLIC ) )
GetChSeedsS();
else
CV_Error( Error::StsInternal, "No such algorithm" );
@@ -232,14 +270,24 @@ void SuperpixelSLICImpl::initialize()
// perturb seeds given edges
if ( perturbseeds ) PerturbSeeds( edgemag );
+ if( m_algorithm == MSLIC )
+ {
+ m_merge = 4.0f;
+ m_adaptk.resize( m_numlabels, 1.0f );
+ }
}
void SuperpixelSLICImpl::iterate( int num_iterations )
{
+ // store total iterations
+ m_iterations = num_iterations;
+
if( m_algorithm == SLICO )
PerformSLICO( num_iterations );
else if( m_algorithm == SLIC )
PerformSLIC( num_iterations );
+ else if( m_algorithm == MSLIC )
+ PerformMSLIC( num_iterations );
else
CV_Error( Error::StsInternal, "No such algorithm" );
@@ -316,6 +364,13 @@ void SuperpixelSLICImpl::enforceLabelConnectivity( int min_element_size )
if ( min_element_size == 0 ) return;
CV_Assert( min_element_size >= 0 && min_element_size <= 100 );
+ vector<float> adaptk( m_numlabels, 1.0f );
+
+ if( m_algorithm == MSLIC )
+ {
+ adaptk.clear();
+ }
+
const int dx4[4] = { -1, 0, 1, 0 };
const int dy4[4] = { 0, -1, 0, 1 };
@@ -331,6 +386,20 @@ void SuperpixelSLICImpl::enforceLabelConnectivity( int min_element_size )
vector<int> xvec(sz);
vector<int> yvec(sz);
+ // MSLIC
+ int currentlabel;
+ float diffch = 0.0f;
+ vector<float> adjch;
+ vector<float> curch;
+ map<int,int> hashtable;
+
+ if( m_algorithm == MSLIC )
+ {
+ hashtable[-1] = 0;
+ adjch.resize( m_nr_channels, 0 );
+ curch.resize( m_nr_channels, 0 );
+ }
+
//adjacent label
int adjlabel = 0;
@@ -346,6 +415,7 @@ void SuperpixelSLICImpl::enforceLabelConnectivity( int min_element_size )
//--------------------
xvec[0] = k;
yvec[0] = j;
+ currentlabel = m_klabels.at<int>(j,k);
//-------------------------------------------------------
// Quickly find an adjacent label for use later if needed
//-------------------------------------------------------
@@ -355,9 +425,33 @@ void SuperpixelSLICImpl::enforceLabelConnectivity( int min_element_size )
int y = yvec[0] + dy4[n];
if( (x >= 0 && x < m_width) && (y >= 0 && y < m_height) )
{
- if(nlabels.at<int>(y,x) != INT_MAX)
- adjlabel = nlabels.at<int>(y,x);
+ if( nlabels.at<int>(y,x) != INT_MAX )
+ {
+ adjlabel = nlabels.at<int>(y,x);
+ if( m_algorithm == MSLIC )
+ {
+ for( int b = 0; b < m_nr_channels; b++ )
+ {
+ adjch[b] = m_kseeds[b][m_klabels.at<int>(y,x)];
+ }
+ }
+ }
+ }
+ }
+
+ if( m_algorithm == MSLIC )
+ {
+ float ssumch = 0.0f;
+ for( int b = 0; b < m_nr_channels; b++ )
+ {
+ curch[b] = m_kseeds[b][m_klabels.at<int>(j,k)];
+ // squared distance
+ float diff = curch[b] - adjch[b];
+ ssumch += diff * diff;
}
+ // L2 distance with adj
+ diffch = sqrt( ssumch );
+ adaptk.push_back( m_adaptk[currentlabel] );
}
int count(1);
@@ -379,20 +473,74 @@ void SuperpixelSLICImpl::enforceLabelConnectivity( int min_element_size )
count++;
}
}
-
}
}
- //-------------------------------------------------------
- // If segment size is less then a limit, assign an
- // adjacent label found before, and decrement label count.
- //-------------------------------------------------------
- if(count <= min_sp_sz)
+ // MSLIC only
+ if( m_algorithm == MSLIC )
{
- for( int c = 0; c < count; c++ )
- {
- nlabels.at<int>(yvec[c],xvec[c]) = adjlabel;
- }
- label--;
+ if ( m_cur_iter < m_iterations - 1 )
+ {
+ hashtable[label] = count;
+ //-------------------------------------------------------
+ // If segment size is less then a limit, or is very similar
+ // to it's neighbour assign adjacent label found before,
+ // and decrement label count.
+ //-------------------------------------------------------
+ if( ( count <= min_sp_sz ) ||
+ (
+ ( diffch < m_merge ) &&
+ ( hashtable[adjlabel] + hashtable[(int)adaptk.size()-1]
+ <= 3 * m_region_size * m_region_size )
+ )
+ )
+ {
+ if( ( diffch < m_merge) &&
+ ( hashtable[adjlabel] + hashtable[(int)adaptk.size()-1]
+ <= 3 * m_region_size * m_region_size )
+ )
+ {
+ adaptk[adjlabel] = min( 2.0f, float(adaptk[adjlabel] + adaptk[(int)adaptk.size()-1]) );
+ hashtable[adjlabel] += hashtable[(int)adaptk.size()-1];
+ }
+
+ for( int c = 0; c < count; c++ )
+ {
+ nlabels.at<int>(yvec[c],xvec[c]) = adjlabel;
+ }
+
+ label--;
+ adaptk.pop_back();
+ }
+ } else
+ {
+ //-------------------------------------------------------
+ // If segment size is less then a limit, assign an
+ // adjacent label found before, and decrement label count.
+ //-------------------------------------------------------
+ if( count <= min_sp_sz )
+ {
+ for( int c = 0; c < count; c++ )
+ {
+ nlabels.at<int>(yvec[c],xvec[c]) = adjlabel;
+ }
+ label--;
+ }
+ }
+ // SLIC or SLICO
+ } else
+ {
+ //-------------------------------------------------------
+ // If segment size is less then a limit, assign an
+ // adjacent label found before, and decrement label count.
+ //-------------------------------------------------------
+ if( count <= min_sp_sz )
+ {
+ for( int c = 0; c < count; c++ )
+ {
+ nlabels.at<int>(yvec[c],xvec[c]) = adjlabel;
+ }
+ label--;
+ }
}
label++;
}
@@ -401,6 +549,9 @@ void SuperpixelSLICImpl::enforceLabelConnectivity( int min_element_size )
// replace old
m_klabels = nlabels;
m_numlabels = label;
+
+ m_adaptk.clear();
+ m_adaptk = adaptk;
}
/*
@@ -696,7 +847,7 @@ struct SeedNormInvoker : ParallelLoopBody
if( clustersize->at(k) <= 0 ) clustersize->at(k) = 1;
for ( int b = 0; b < nr_channels; b++ )
- kseeds->at(b)[k] = sigma->at(b)[k] / float(clustersize->at(k));;
+ kseeds->at(b)[k] = sigma->at(b)[k] / float(clustersize->at(k));
kseedsx->at(k) = sigmax->at(k) / float(clustersize->at(k));
kseedsy->at(k) = sigmay->at(k) / float(clustersize->at(k));
@@ -732,17 +883,6 @@ struct SeedsCenters
clustersize.assign(numlabels, 0);
}
- void ClearArrays( )
- {
- // refill with zero all arrays
- for( int b = 0; b < nr_channels; b++ )
- fill(sigma[b].begin(), sigma[b].end(), 0.0f);
-
- fill(sigmax.begin(), sigmax.end(), 0.0f);
- fill(sigmay.begin(), sigmay.end(), 0.0f);
- fill(clustersize.begin(), clustersize.end(), 0);
- }
-
SeedsCenters( const SeedsCenters& counter, Split )
{
*this = counter;
@@ -1006,10 +1146,7 @@ inline void SuperpixelSLICImpl::PerformSLICO( const int& itrnum )
// this is the variable value of M, just start with 10
vector<float> maxxy( m_numlabels, FLT_MIN );
// note: this is different from how usual SLIC/LKM works
- float xywt = float(m_region_size*m_region_size);
-
- // parallel reduce structure
- SeedsCenters sc( m_chvec, m_klabels, m_numlabels, m_nr_channels );
+ const float xywt = float(m_region_size*m_region_size);
for( int itr = 0; itr < itrnum; itr++ )
{
@@ -1051,6 +1188,9 @@ inline void SuperpixelSLICImpl::PerformSLICO( const int& itrnum )
// Recalculate the centroid and store in the seed values
//-----------------------------------------------------------------
+ // parallel reduce structure
+ SeedsCenters sc( m_chvec, m_klabels, m_numlabels, m_nr_channels );
+
// accumulate center distances
parallel_reduce( BlockedRange(0, m_width), sc );
@@ -1058,8 +1198,6 @@ inline void SuperpixelSLICImpl::PerformSLICO( const int& itrnum )
parallel_for_( Range(0, m_numlabels), SeedNormInvoker( &m_kseeds, &sc.sigma,
&sc.clustersize, &sc.sigmax, &sc.sigmay, &m_kseedsx, &m_kseedsy, m_nr_channels ) );
- // refill arrays
- sc.ClearArrays();
}
}
@@ -1190,30 +1328,80 @@ struct SLICGrowInvoker : ParallelLoopBody
*/
inline void SuperpixelSLICImpl::PerformSLIC( const int& itrnum )
{
+ Mat distvec( m_height, m_width, CV_32F );
+
+ const float xywt = (m_region_size/m_ruler)*(m_region_size/m_ruler);
+
+ for( int itr = 0; itr < itrnum; itr++ )
+ {
+ distvec.setTo(FLT_MAX);
+ for( int n = 0; n < m_numlabels; n++ )
+ {
+ int y1 = max(0, (int) m_kseedsy[n] - m_region_size);
+ int y2 = min(m_height, (int) m_kseedsy[n] + m_region_size);
+ int x1 = max(0, (int) m_kseedsx[n] - m_region_size);
+ int x2 = min((int) m_width,(int) m_kseedsx[n] + m_region_size);
+
+ parallel_for_( Range(y1, y2), SLICGrowInvoker( &m_chvec, &distvec,
+ &m_klabels, m_kseedsx[n], m_kseedsy[n], xywt, &m_kseeds,
+ x1, x2, m_nr_channels, n ) );
+ }
+
+ //-----------------------------------------------------------------
+ // Recalculate the centroid and store in the seed values
+ //-----------------------------------------------------------------
+ // instead of reassigning memory on each iteration, just reset.
+
+ // parallel reduce structure
+ SeedsCenters sc( m_chvec, m_klabels, m_numlabels, m_nr_channels );
+
+ // accumulate center distances
+ parallel_reduce( BlockedRange(0, m_width), sc );
+
+ // normalize centers
+ parallel_for_( Range(0, m_numlabels), SeedNormInvoker( &m_kseeds, &sc.sigma,
+ &sc.clustersize, &sc.sigmax, &sc.sigmay, &m_kseedsx, &m_kseedsy, m_nr_channels ) );
+
+ }
+}
+
+/*
+ * PerformSuperpixelMSLIC
+ *
+ *
+ */
+inline void SuperpixelSLICImpl::PerformMSLIC( const int& itrnum )
+{
vector< vector<float> > sigma(m_nr_channels);
for( int b = 0; b < m_nr_channels; b++ )
sigma[b].resize(m_numlabels, 0);
- vector<float> sigmax(m_numlabels, 0);
- vector<float> sigmay(m_numlabels, 0);
- vector<int> clustersize(m_numlabels, 0);
-
Mat distvec( m_height, m_width, CV_32F );
- float xywt = (m_region_size/m_ruler)*(m_region_size/m_ruler);
+ const float xywt = (m_region_size/m_ruler)*(m_region_size/m_ruler);
- // parallel reduce structure
- SeedsCenters sc( m_chvec, m_klabels, m_numlabels, m_nr_channels );
+ int offset = m_region_size;
+
+ // from paper
+ m_split = 4.0f;
+ m_ratio = 5.0f;
for( int itr = 0; itr < itrnum; itr++ )
{
+ m_cur_iter = itr;
+
distvec.setTo(FLT_MAX);
for( int n = 0; n < m_numlabels; n++ )
{
- int y1 = max(0, (int) m_kseedsy[n] - m_region_size);
- int y2 = min(m_height, (int) m_kseedsy[n] + m_region_size);
- int x1 = max(0, (int) m_kseedsx[n] - m_region_size);
- int x2 = min((int) m_width,(int) m_kseedsx[n] + m_region_size);
+ if ( m_adaptk[n] < 1.0f )
+ offset = int(m_region_size * m_adaptk[n]);
+ else
+ offset = int(m_region_size * m_adaptk[n]);
+
+ int y1 = max(0, (int) m_kseedsy[n] - offset);
+ int y2 = min(m_height, (int) m_kseedsy[n] + offset);
+ int x1 = max(0, (int) m_kseedsx[n] - offset);
+ int x2 = min(m_width, (int) m_kseedsx[n] + offset);
parallel_for_( Range(y1, y2), SLICGrowInvoker( &m_chvec, &distvec,
&m_klabels, m_kseedsx[n], m_kseedsy[n], xywt, &m_kseeds,
@@ -1225,17 +1413,368 @@ inline void SuperpixelSLICImpl::PerformSLIC( const int& itrnum )
//-----------------------------------------------------------------
// instead of reassigning memory on each iteration, just reset.
+ // parallel reduce structure
+ SeedsCenters sc( m_chvec, m_klabels, m_numlabels, m_nr_channels );
+
// accumulate center distances
parallel_reduce( BlockedRange(0, m_width), sc );
// normalize centers
- parallel_for_( Range(0, m_numlabels), SeedNormInvoker( &m_kseeds, &sigma,
- &clustersize, &sigmax, &sigmay, &m_kseedsx, &m_kseedsy, m_nr_channels ) );
+ parallel_for_( Range(0, m_numlabels), SeedNormInvoker( &m_kseeds, &sc.sigma,
+ &sc.clustersize, &sc.sigmax, &sc.sigmay, &m_kseedsx, &m_kseedsy, m_nr_channels ) );
+
+ // 13% as in original paper
+ enforceLabelConnectivity( 13 );
+ SuperpixelSplit();
+ }
+}
+
+inline void SuperpixelSLICImpl::SuperpixelSplit()
+{
+ Mat klabels = m_klabels.clone();
+
+ // parallel reduce structure
+ SeedsCenters msc( m_chvec, m_klabels, m_numlabels, m_nr_channels );
+
+ // accumulate center distances
+ parallel_reduce( BlockedRange(0, m_width), msc );
+
+ const float invwt = 1.0f / ( (m_region_size/m_ruler)*(m_region_size/m_ruler) );
+ const float sqrt_invwt = sqrt(invwt);
+
+ if ( m_cur_iter < m_iterations - 2 )
+ {
+ vector<float> avglabs( m_numlabels, 0 );
+ for( int y = 0; y < m_height - 1; y++ )
+ {
+ for( int x = 0; x < m_width - 1; x++ )
+ {
+ if ( klabels.at<int>( y, x ) == klabels.at<int>( y+1, x ) &&
+ klabels.at<int>( y, x ) == klabels.at<int>( y, x+1 ) )
+ {
+ float x1 = 1, y1 = 0;
+ float x2 = 0, y2 = 1;
+
+ vector<float> ch1(m_nr_channels);
+ vector<float> ch2(m_nr_channels);
+
+ switch ( m_chvec.at(0).depth() )
+ {
+ case CV_8U:
+ for( int c = 0; c < m_nr_channels; c++ )
+ {
+ ch1[c] = float( m_chvec[c].at<uchar>( y+1, x )
+ - m_chvec[c].at<uchar>( y, x ) );
+ ch2[c] = float( m_chvec[c].at<uchar>( y, x+1 )
+ - m_chvec[c].at<uchar>( y, x ) );
+
+ ch1[c] /= sqrt_invwt;
+ ch2[c] /= sqrt_invwt;
+ }
+ break;
+
+ case CV_8S:
+ for( int c = 0; c < m_nr_channels; c++ )
+ {
+ ch1[c] = float( m_chvec[c].at<char>( y+1, x )
+ - m_chvec[c].at<char>( y, x ) );
+ ch2[c] = float( m_chvec[c].at<char>( y, x+1 )
+ - m_chvec[c].at<char>( y, x ) );
+
+ ch1[c] /= sqrt_invwt;
+ ch2[c] /= sqrt_invwt;
+ }
+ break;
+
+ case CV_16U:
+ for( int c = 0; c < m_nr_channels; c++ )
+ {
+ ch1[c] = float( m_chvec[c].at<ushort>( y+1, x )
+ - m_chvec[c].at<ushort>( y, x ) );
+ ch2[c] = float( m_chvec[c].at<ushort>( y, x+1 )
+ - m_chvec[c].at<ushort>( y, x ) );
+
+ ch1[c] /= sqrt_invwt;
+ ch2[c] /= sqrt_invwt;
+ }
+ break;
+
+ case CV_16S:
+ for( int c = 0; c < m_nr_channels; c++ )
+ {
+ ch1[c] = float( m_chvec[c].at<short>( y+1, x )
+ - m_chvec[c].at<short>( y, x ) );
+ ch2[c] = float( m_chvec[c].at<short>( y, x+1 )
+ - m_chvec[c].at<short>( y, x ) );
+
+ ch1[c] /= sqrt_invwt;
+ ch2[c] /= sqrt_invwt;
+ }
+ break;
+
+ case CV_32S:
+ for( int c = 0; c < m_nr_channels; c++ )
+ {
+ ch1[c] = float( m_chvec[c].at<int>( y+1, x )
+ - m_chvec[c].at<int>( y, x ) );
+ ch2[c] = float( m_chvec[c].at<int>( y, x+1 )
+ - m_chvec[c].at<int>( y, x ) );
+
+ ch1[c] /= sqrt_invwt;
+ ch2[c] /= sqrt_invwt;
+ }
+ break;
+
+ case CV_32F:
+ for( int c = 0; c < m_nr_channels; c++ )
+ {
+ ch1[c] = m_chvec[c].at<float>( y+1, x )
+ - m_chvec[c].at<float>( y, x );
+ ch2[c] = m_chvec[c].at<float>( y, x+1 )
+ - m_chvec[c].at<float>( y, x );
+
+ ch1[c] /= sqrt_invwt;
+ ch2[c] /= sqrt_invwt;
+ }
+ break;
+
+ case CV_64F:
+ for( int c = 0; c < m_nr_channels; c++ )
+ {
+ ch1[c] = float( m_chvec[c].at<double>( y+1, x )
+ - m_chvec[c].at<double>( y, x ) );
+ ch2[c] = float( m_chvec[c].at<double>( y, x+1 )
+ - m_chvec[c].at<double>( y, x ) );
+
+ ch1[c] /= sqrt_invwt;
+ ch2[c] /= sqrt_invwt;
+ }
+ break;
+
+ default:
+ CV_Error( Error::StsInternal, "Invalid matrix depth" );
+ break;
+ }
+ float ch11sqsum = 0.0f;
+ float ch12sqsum = 0.0f;
+ float ch22sqsum = 0.0f;
+ for( int c = 0; c < m_nr_channels; c++ )
+ {
+ ch11sqsum += ch1[c]*ch1[c];
+ ch12sqsum += ch1[c]*ch2[c];
+ ch22sqsum += ch2[c]*ch2[c];
+ }
+
+ // adjacent metric for N channels
+ avglabs[ klabels.at<int>(y,x) ]
+ += sqrt( (x1*x1 + y1*y1 + ch11sqsum) * (x2*x2 + y2*y2 + ch22sqsum)
+ - (x1*x2 + y1*y2 + ch12sqsum) * (x1*x2 + y1*y2 + ch12sqsum) );
+ }
+ }
+ }
+ for ( int i = 0; i < m_numlabels; i++ )
+ {
+ avglabs[i] /= m_region_size * m_region_size;
+ }
+
+ m_kseedsx.clear();
+ m_kseedsy.clear();
+ m_kseedsx.resize( m_numlabels, 0 );
+ m_kseedsy.resize( m_numlabels, 0 );
+ for( int c = 0; c < m_nr_channels; c++ )
+ {
+ m_kseeds[c].clear();
+ m_kseeds[c].resize( m_numlabels, 0 );
+ }
+
+ for( int k = 0; k < m_numlabels; k++ )
+ {
+ m_kseedsx[k] = msc.sigmax[k] / msc.clustersize[k];
+ m_kseedsy[k] = msc.sigmay[k] / msc.clustersize[k];
+ for( int c = 0; c < m_nr_channels; c++ )
+ m_kseeds[c][k] = msc.sigma[c][k] / msc.clustersize[k];
+ }
+
+ for( int k = 0; k < m_numlabels; k++ )
+ {
+ int xindex = 0, yindex = 0;
+ if ( ( m_adaptk[k] <= 0.5f ) ||
+ ( avglabs[k] < (m_split * m_ratio) ) )
+ {
+ m_kseedsx[k] = msc.sigmax[k] / msc.clustersize[k];
+ m_kseedsy[k] = msc.sigmay[k] / msc.clustersize[k];
+ for( int c = 0; c < m_nr_channels; c++ )
+ m_kseeds[c][k] = msc.sigma[c][k] / msc.clustersize[k];
+
+ m_adaptk[k] = sqrt( m_ratio / avglabs[k] );
+ m_adaptk[k] = max( 0.5f, m_adaptk[k] );
+ m_adaptk[k] = min( 2.0f, m_adaptk[k] );
+ }
+ // if segment size is too large
+ // split it and calculate four new seeds
+ else
+ {
+ xindex = (int)( msc.sigmax[k] / msc.clustersize[k] );
+ yindex = (int)( msc.sigmay[k] / msc.clustersize[k] );
+ m_adaptk[k] = max( 0.5f, m_adaptk[k] / 2 );
+
+ const float minadaptk = min( 1.0f, m_adaptk[k] ) * m_region_size / 2;
+
+ int x1 = (int)( xindex - minadaptk );
+ int x2 = (int)( xindex + minadaptk );
+ int x3 = (int)( xindex - minadaptk );
+ int x4 = (int)( xindex + minadaptk );
+
+ int y1 = (int)( yindex + minadaptk );
+ int y2 = (int)( yindex + minadaptk );
+ int y3 = (int)( yindex - minadaptk );
+ int y4 = (int)( yindex - minadaptk );
+
+ if ( x1 < 0 ) x1 = 0;
+ if ( x2 >= m_width ) x2 = m_width - 1;
+ if ( x3 < 0 ) x3 = 0;
+ if ( x4 >= m_width ) x4 = m_width - 1;
+ if ( y1 >= m_height ) y1 = m_height - 1;
+ if ( y2 >= m_height ) y2 = m_height - 1;
+ if ( y3 < 0 ) y3 = 0;
+ if ( y4 < 0 ) y4 = 0;
+
+ m_kseedsx[k] = (float)x1;
+ m_kseedsy[k] = (float)y1;
+ for( int c = 0; c < m_nr_channels; c++ )
+ {
+ switch ( m_chvec[c].depth() )
+ {
+ case CV_8U:
+ m_kseeds[c][k] = m_chvec[c].at<uchar>(y1,x1);
+ break;
+
+ case CV_8S:
+ m_kseeds[c][k] = m_chvec[c].at<char>(y1,x1);
+ break;
+
+ case CV_16U:
+ m_kseeds[c][k] = m_chvec[c].at<ushort>(y1,x1);
+ break;
+
+ case CV_16S:
+ m_kseeds[c][k] = m_chvec[c].at<short>(y1,x1);
+ break;
+
+ case CV_32S:
+ m_kseeds[c][k] = float(m_chvec[c].at<int>(y1,x1));
+ break;
- // refill arrays
- sc.ClearArrays();
+ case CV_32F:
+ m_kseeds[c][k] = m_chvec[c].at<float>(y1,x1);
+ break;
+
+ case CV_64F:
+ m_kseeds[c][k] = float(m_chvec[c].at<double>(y1,x1));
+ break;
+
+ default:
+ CV_Error( Error::StsInternal, "Invalid matrix depth" );
+ break;
+ }
+ }
+
+ m_kseedsx.push_back( (float)x2 );
+ m_kseedsx.push_back( (float)x3 );
+ m_kseedsx.push_back( (float)x4 );
+ m_kseedsy.push_back( (float)y2 );
+ m_kseedsy.push_back( (float)y3 );
+ m_kseedsy.push_back( (float)y4 );
+
+ for( int c = 0; c < m_nr_channels; c++ )
+ {
+ switch ( m_chvec[c].depth() )
+ {
+ case CV_8U:
+ m_kseeds[c].push_back( m_chvec[c].at<uchar>(y2,x2) );
+ m_kseeds[c].push_back( m_chvec[c].at<uchar>(y3,x3) );
+ m_kseeds[c].push_back( m_chvec[c].at<uchar>(y4,x4) );
+ break;
+
+ case CV_8S:
+ m_kseeds[c].push_back( m_chvec[c].at<char>(y2,x2) );
+ m_kseeds[c].push_back( m_chvec[c].at<char>(y3,x3) );
+ m_kseeds[c].push_back( m_chvec[c].at<char>(y4,x4) );
+ break;
+
+ case CV_16U:
+ m_kseeds[c].push_back( m_chvec[c].at<ushort>(y2,x2) );
+ m_kseeds[c].push_back( m_chvec[c].at<ushort>(y3,x3) );
+ m_kseeds[c].push_back( m_chvec[c].at<ushort>(y4,x4) );
+ break;
+
+ case CV_16S:
+ m_kseeds[c].push_back( m_chvec[c].at<short>(y2,x2) );
+ m_kseeds[c].push_back( m_chvec[c].at<short>(y3,x3) );
+ m_kseeds[c].push_back( m_chvec[c].at<short>(y4,x4) );
+ break;
+
+ case CV_32S:
+ m_kseeds[c].push_back( float(m_chvec[c].at<int>(y2,x2)) );
+ m_kseeds[c].push_back( float(m_chvec[c].at<int>(y3,x3)) );
+ m_kseeds[c].push_back( float(m_chvec[c].at<int>(y4,x4)) );
+ break;
+
+ case CV_32F:
+ m_kseeds[c].push_back( m_chvec[c].at<float>(y2,x2) );
+ m_kseeds[c].push_back( m_chvec[c].at<float>(y3,x3) );
+ m_kseeds[c].push_back( m_chvec[c].at<float>(y4,x4) );
+ break;
+
+ case CV_64F:
+ m_kseeds[c].push_back( float(m_chvec[c].at<double>(y2,x2)) );
+ m_kseeds[c].push_back( float(m_chvec[c].at<double>(y3,x3)) );
+ m_kseeds[c].push_back( float(m_chvec[c].at<double>(y4,x4)) );
+ break;
+
+ default:
+ CV_Error( Error::StsInternal, "Invalid matrix depth" );
+ break;
+ }
+ }
+ m_adaptk.push_back( m_adaptk[k] );
+ m_adaptk.push_back( m_adaptk[k] );
+ m_adaptk.push_back( m_adaptk[k] );
+ msc.clustersize.push_back( 1 );
+ msc.clustersize.push_back( 1 );
+ msc.clustersize.push_back( 1 );
+ }
+ }
}
+ else
+ {
+ m_kseedsx.clear();
+ m_kseedsy.clear();
+ m_kseedsx.resize( m_numlabels, 0 );
+ m_kseedsy.resize( m_numlabels, 0 );
+ for( int c = 0; c < m_nr_channels; c++ )
+ {
+ m_kseeds[c].clear();
+ m_kseeds[c].resize( m_numlabels, 0 );
+ }
+
+ for( int k = 0; k < m_numlabels; k++ )
+ {
+ m_kseedsx[k] = msc.sigmax[k] / msc.clustersize[k];
+ m_kseedsy[k] = msc.sigmay[k] / msc.clustersize[k];
+ for( int c = 0; c < m_nr_channels; c++ )
+ m_kseeds[c][k] = msc.sigma[c][k] / msc.clustersize[k];
+ }
+ }
+
+ m_klabels.release();
+ m_klabels = klabels.clone();
+
+ // re-update amount of labels
+ m_numlabels = (int)m_kseeds[0].size();
+
}
+
} // namespace ximgproc
} // namespace cv
diff --git a/contrib/modules/ximgproc/src/structured_edge_detection.cpp b/contrib/modules/ximgproc/src/structured_edge_detection.cpp
index ef8acff..fa0851e 100644
--- a/contrib/modules/ximgproc/src/structured_edge_detection.cpp
+++ b/contrib/modules/ximgproc/src/structured_edge_detection.cpp
@@ -235,7 +235,6 @@ static void gradientHist(const cv::Mat &src, cv::Mat &magnitude, cv::Mat &histog
magnitude /= imsmooth( magnitude, gnrmRad )
+ 0.01*cv::Mat::ones( magnitude.size(), magnitude.type() );
- int pHistSize = histogram.cols*histogram.channels() - 1;
for (int i = 0; i < phase.rows; ++i)
{
const float *pPhase = phase.ptr<float>(i);
@@ -245,13 +244,92 @@ static void gradientHist(const cv::Mat &src, cv::Mat &magnitude, cv::Mat &histog
for (int j = 0; j < phase.cols; ++j)
{
- int index = cvRound((j/pSize + pPhase[j])*nBins);
- index = std::max(0, std::min(index, pHistSize));
+ int angle = cvRound(pPhase[j]*nBins);
+ if(angle >= nBins)
+ {
+ angle = 0;
+ }
+ const int index = (j/pSize)*nBins + angle;
pHist[index] += pMagn[j] / CV_SQR(pSize);
}
}
}
+/*!
+ * The class parallelizing the edgenms algorithm.
+ *
+ * \param E : edge image
+ * \param O : orientation image
+ * \param dst : destination image
+ * \param r : radius for NMS suppression
+ * \param s : radius for boundary suppression
+ * \param m : multiplier for conservative suppression
+ */
+class NmsInvoker : public cv::ParallelLoopBody
+{
+
+private:
+ const cv::Mat &E;
+ const cv::Mat &O;
+ cv::Mat &dst;
+ const int r;
+ const float m;
+
+public:
+ NmsInvoker(const cv::Mat &_E, const cv::Mat &_O, cv::Mat &_dst, const int _r, const float _m)
+ : E(_E), O(_O), dst(_dst), r(_r), m(_m)
+ {
+ }
+
+ void operator()(const cv::Range &range) const
+ {
+ for (int x = range.start; x < range.end; x++)
+ {
+ const float *e_ptr = E.ptr<float>(x);
+ const float *o_ptr = O.ptr<float>(x);
+ float *dst_ptr = dst.ptr<float>(x);
+ for (int y=0; y < E.cols; y++)
+ {
+ float e = e_ptr[y];
+ dst_ptr[y] = e;
+ if (!e) continue;
+ e *= m;
+ float coso = cos(o_ptr[y]);
+ float sino = sin(o_ptr[y]);
+ for (int d=-r; d<=r; d++)
+ {
+ if (d)
+ {
+ float xdcos = x+d*coso;
+ float ydsin = y+d*sino;
+ xdcos = xdcos < 0 ? 0 : (xdcos > E.rows - 1.001f ? E.rows - 1.001f : xdcos);
+ ydsin = ydsin < 0 ? 0 : (ydsin > E.cols - 1.001f ? E.cols - 1.001f : ydsin);
+ int x0 = (int)xdcos;
+ int y0 = (int)ydsin;
+ int x1 = x0 + 1;
+ int y1 = y0 + 1;
+ float dx0 = xdcos - x0;
+ float dy0 = ydsin - y0;
+ float dx1 = 1 - dx0;
+ float dy1 = 1 - dy0;
+ float e0 = E.at<float>(x0, y0) * dx1 * dy1 +
+ E.at<float>(x1, y0) * dx0 * dy1 +
+ E.at<float>(x0, y1) * dx1 * dy0 +
+ E.at<float>(x1, y1) * dx0 * dy0;
+
+ if(e < e0)
+ {
+ dst_ptr[y] = 0;
+ break;
+ }
+ }
+ }
+
+ }
+ }
+ }
+};
+
/********************* RFFeatureGetter class *********************/
namespace cv
@@ -442,21 +520,23 @@ public:
/*!
* The function detects edges in src and draw them to dst
*
- * \param src : source image (RGB, float, in [0;1]) to detect edges
- * \param dst : destination image (grayscale, float, in [0;1])
+ * \param _src : source image (RGB, float, in [0;1]) to detect edges
+ * \param _dst : destination image (grayscale, float, in [0;1])
* where edges are drawn
*/
- void detectEdges(const cv::Mat &src, cv::Mat &dst) const
+ void detectEdges(cv::InputArray _src, cv::OutputArray _dst) const
{
- CV_Assert( src.type() == CV_32FC3 );
+ CV_Assert( _src.type() == CV_32FC3 );
- dst.create( src.size(), cv::DataType<float>::type );
+ _dst.createSameSize( _src, cv::DataType<float>::type );
+ _dst.setTo(0);
+ Mat dst = _dst.getMat();
int padding = ( __rf.options.patchSize
- __rf.options.patchInnerSize )/2;
cv::Mat nSrc;
- copyMakeBorder( src, nSrc, padding, padding,
+ copyMakeBorder( _src, nSrc, padding, padding,
padding, padding, BORDER_REFLECT );
NChannelsMat features;
@@ -469,6 +549,101 @@ public:
predictEdges( features, dst );
}
+ /*!
+ * The function computes orientation from edge image.
+ *
+ * \param src : edge image.
+ * \param dst : orientation image.
+ * \param r : filter radius.
+ */
+ void computeOrientation(cv::InputArray _src, cv::OutputArray _dst) const
+ {
+ CV_Assert( _src.type() == CV_32FC1 );
+
+ cv::Mat Oxx, Oxy, Oyy;
+
+ _dst.createSameSize( _src, _src.type() );
+ _dst.setTo(0);
+
+ Mat src = _src.getMat();
+ cv::Mat E_conv = imsmooth(src, __rf.options.gradientNormalizationRadius);
+
+ Sobel(E_conv, Oxx, -1, 2, 0);
+ Sobel(E_conv, Oxy, -1, 1, 1);
+ Sobel(E_conv, Oyy, -1, 0, 2);
+
+ Mat dst = _dst.getMat();
+ float *o = dst.ptr<float>();
+ float *oxx = Oxx.ptr<float>();
+ float *oxy = Oxy.ptr<float>();
+ float *oyy = Oyy.ptr<float>();
+ for (int i = 0; i < dst.rows * dst.cols; i++)
+ {
+ int xysign = -((oxy[i] > 0) - (oxy[i] < 0));
+ o[i] = (atan((oyy[i] * xysign / (oxx[i] + 1e-5))) > 0) ? (float) fmod(
+ atan((oyy[i] * xysign / (oxx[i] + 1e-5))), CV_PI) : (float) fmod(
+ atan((oyy[i] * xysign / (oxx[i] + 1e-5))) + CV_PI, CV_PI);
+ }
+ }
+
+ /*!
+ * The function suppress edges where edge is stronger in orthogonal direction
+ * \param edge_image : edge image from detectEdges function.
+ * \param orientation_image : orientation image from computeOrientation function.
+ * \param _dst : suppressed image (grayscale, float, in [0;1])
+ * \param r : radius for NMS suppression.
+ * \param s : radius for boundary suppression.
+ * \param m : multiplier for conservative suppression.
+ * \param isParallel: enables/disables parallel computing.
+ */
+ void edgesNms(cv::InputArray edge_image, cv::InputArray orientation_image, cv::OutputArray _dst, int r, int s, float m, bool isParallel) const
+ {
+ CV_Assert(edge_image.type() == CV_32FC1);
+ CV_Assert(orientation_image.type() == CV_32FC1);
+
+ cv::Mat E = edge_image.getMat();
+ cv::Mat O = orientation_image.getMat();
+ cv::Mat E_t = E.t();
+ cv::Mat O_t = O.t();
+
+ cv::Mat dst = _dst.getMat();
+ dst.create(E.cols, E.rows, E.type());
+ dst.setTo(0);
+
+ cv::Range sizeRange = cv::Range(0, E_t.rows);
+ NmsInvoker body = NmsInvoker(E_t, O_t, dst, r, m);
+ if (isParallel)
+ {
+ cv::parallel_for_(sizeRange, body);
+ } else
+ {
+ body(sizeRange);
+ }
+
+ s = s > E_t.rows / 2 ? E_t.rows / 2 : s;
+ s = s > E_t.cols / 2 ? E_t.cols / 2 : s;
+ for (int x=0; x<s; x++)
+ {
+ for (int y=0; y<E_t.cols; y++)
+ {
+ dst.at<float>(x, y) *= x / (float)s;
+ dst.at<float>(E_t.rows-1-x, y) *= x / (float)s;
+ }
+ }
+
+ for (int x=0; x < E_t.rows; x++)
+ {
+ for (int y=0; y < s; y++)
+ {
+ dst.at<float>(x, y) *= y / (float)s;
+ dst.at<float>(x, E_t.cols-1-y) *= y / (float)s;
+ }
+ }
+ transpose(dst, dst);
+ dst.copyTo(_dst);
+ }
+
+
protected:
/*!
* Private method used by process method. The function
diff --git a/contrib/modules/ximgproc/src/weighted_median_filter.cpp b/contrib/modules/ximgproc/src/weighted_median_filter.cpp
index 358959c..d438fb9 100644
--- a/contrib/modules/ximgproc/src/weighted_median_filter.cpp
+++ b/contrib/modules/ximgproc/src/weighted_median_filter.cpp
@@ -231,7 +231,7 @@ inline void updateBCB(int &num,int *f,int *b,int i,int v)
* If F is 3-channel, perform k-means clustering
* If F is 1-channel, only perform type-casting
***************************************************************/
-void featureIndexing(Mat &F, float **&wMap, int &nF, float sigmaI, WMFWeightType weightType){
+void featureIndexing(Mat &F, float **&wMap, int &nF, float sigmaI, int weightType){
// Configuration and Declaration
Mat FNew;
int cols = F.cols, rows = F.rows;
@@ -493,7 +493,7 @@ Mat filterCore(Mat &I, Mat &F, float **wMap, int r=20, int nF=256, int nI=256, M
// Move cut-point to the left
if(balanceWeight >= 0)
{
- for(;balanceWeight >= 0 && curMedianVal; curMedianVal--)
+ for(;balanceWeight >= 0 && curMedianVal > 0; curMedianVal--)
{
float curWeight = 0;
int *nextHist = H[curMedianVal];
@@ -539,8 +539,13 @@ Mat filterCore(Mat &I, Mat &F, float **wMap, int r=20, int nF=256, int nI=256, M
}
// Weighted median is found and written to the output image
- if(balanceWeight<0)outImg.ptr<int>(y,x)[0] = curMedianVal+1;
- else outImg.ptr<int>(y,x)[0] = curMedianVal;
+ if(curMedianVal != -1)
+ {
+ if(balanceWeight < 0)
+ outImg.ptr<int>(y,x)[0] = curMedianVal+1;
+ else
+ outImg.ptr<int>(y,x)[0] = curMedianVal;
+ }
// Update joint-histogram and BCB when local window is shifted.
int fval,gval,*curHist;
@@ -636,7 +641,7 @@ namespace cv
{
namespace ximgproc
{
-void weightedMedianFilter(InputArray joint, InputArray src, OutputArray dst, int r, double sigma, WMFWeightType weightType, Mat mask)
+void weightedMedianFilter(InputArray joint, InputArray src, OutputArray dst, int r, double sigma, int weightType, InputArray mask)
{
CV_Assert(!src.empty());
CV_Assert(r > 0 && sigma > 0);
@@ -697,7 +702,7 @@ void weightedMedianFilter(InputArray joint, InputArray src, OutputArray dst, int
//Filtering - Joint-Histogram Framework
for(int i=0; i<(int)Is.size(); i++)
{
- Is[i] = filterCore(Is[i], F, wMap, r, nF,nI,mask);
+ Is[i] = filterCore(Is[i], F, wMap, r, nF, nI, mask.getMat());
}
float2D_release(wMap);
diff --git a/contrib/modules/ximgproc/test/test_anisodiff.cpp b/contrib/modules/ximgproc/test/test_anisodiff.cpp
new file mode 100644
index 0000000..813bf30
--- /dev/null
+++ b/contrib/modules/ximgproc/test/test_anisodiff.cpp
@@ -0,0 +1,25 @@
+#include "test_precomp.hpp"
+
+using namespace cv;
+using namespace std;
+
+TEST(ximgproc_AnisotropicDiffusion, regression)
+{
+ string folder = string(cvtest::TS::ptr()->get_data_path()) + "cv/shared/";
+ string original_path = folder + "fruits.png";
+
+ Mat original = imread(original_path, IMREAD_COLOR);
+
+ ASSERT_FALSE(original.empty()) << "Could not load input image " << original_path;
+ ASSERT_EQ(3, original.channels()) << "Load color input image " << original_path;
+
+ Mat result;
+ float alpha = 1.0f;
+ float K = 0.02f;
+ int niters = 10;
+ ximgproc::anisotropicDiffusion(original, result, alpha, K, niters);
+
+ double adiff_psnr = cvtest::PSNR(original, result);
+ //printf("psnr=%.2f\n", adiff_psnr);
+ ASSERT_GT(adiff_psnr, 25.0);
+}
diff --git a/contrib/modules/ximgproc/test/test_rolling_guidance_filter.cpp b/contrib/modules/ximgproc/test/test_rolling_guidance_filter.cpp
index a29f9c4..f175118 100644
--- a/contrib/modules/ximgproc/test/test_rolling_guidance_filter.cpp
+++ b/contrib/modules/ximgproc/test/test_rolling_guidance_filter.cpp
@@ -53,11 +53,8 @@ static std::string getOpenCVExtraDir()
static void checkSimilarity(InputArray src, InputArray ref)
{
- double normInf = cvtest::norm(src, ref, NORM_INF);
- double normL2 = cvtest::norm(src, ref, NORM_L2) / (src.total()*src.channels());
-
- EXPECT_LE(normInf, 1.0);
- EXPECT_LE(normL2, 1.0 / 16);
+ // Doesn't work with bilateral filter: EXPECT_LE(cvtest::norm(src, ref, NORM_INF), 1.0);
+ EXPECT_LE(cvtest::norm(src, ref, NORM_L2 | NORM_RELATIVE), 1e-3);
}
static Mat convertTypeAndSize(Mat src, int dstType, Size dstSize)
diff --git a/contrib/modules/ximgproc/test/test_weighted_median_filter.cpp b/contrib/modules/ximgproc/test/test_weighted_median_filter.cpp
index 9dea51f..69a6530 100644
--- a/contrib/modules/ximgproc/test/test_weighted_median_filter.cpp
+++ b/contrib/modules/ximgproc/test/test_weighted_median_filter.cpp
@@ -102,6 +102,16 @@ TEST(WeightedMedianFilterTest, ReferenceAccuracy)
EXPECT_LE(cvtest::norm(res, ref, NORM_L2), totalMaxError);
}
+TEST(WeightedMedianFilterTest, mask_zeros_no_crash)
+{
+ Mat img = imread(getDataDir() + "cv/ximgproc/sources/01.png");
+ Mat mask = Mat::zeros(img.size(), CV_8U);
+ Mat filtered;
+ weightedMedianFilter(img, img, filtered, 3, 20, WMF_EXP, mask);
+
+ EXPECT_EQ(cv::norm(img, filtered, NORM_INF), 0.0);
+}
+
INSTANTIATE_TEST_CASE_P(TypicalSET, WeightedMedianFilterTest, Combine(Values(szODD, szQVGA), Values(WMF_EXP, WMF_IV2, WMF_OFF)));
}
diff --git a/contrib/modules/xobjdetect/CMakeLists.txt b/contrib/modules/xobjdetect/CMakeLists.txt
index 567909b..1727a42 100644
--- a/contrib/modules/xobjdetect/CMakeLists.txt
+++ b/contrib/modules/xobjdetect/CMakeLists.txt
@@ -1,5 +1,5 @@
set(the_description "Object detection algorithms")
-ocv_define_module(xobjdetect opencv_core opencv_imgproc opencv_highgui opencv_objdetect WRAP python)
-if (NOT APPLE_FRAMEWORK)
- add_subdirectory(tools)
+ocv_define_module(xobjdetect opencv_core opencv_imgproc opencv_objdetect opencv_imgcodecs WRAP python)
+if (BUILD_opencv_apps AND NOT APPLE_FRAMEWORK)
+ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools ${CMAKE_CURRENT_BINARY_DIR}/tools)
endif()
diff --git a/contrib/modules/xobjdetect/include/opencv2/xobjdetect.hpp b/contrib/modules/xobjdetect/include/opencv2/xobjdetect.hpp
index 45038ab..13dde11 100644
--- a/contrib/modules/xobjdetect/include/opencv2/xobjdetect.hpp
+++ b/contrib/modules/xobjdetect/include/opencv2/xobjdetect.hpp
@@ -43,7 +43,6 @@ the use of this software, even if advised of the possibility of such damage.
#define __OPENCV_XOBJDETECT_XOBJDETECT_HPP__
#include <opencv2/core.hpp>
-#include <opencv2/highgui.hpp>
#include <vector>
#include <string>
diff --git a/contrib/modules/xobjdetect/src/precomp.hpp b/contrib/modules/xobjdetect/src/precomp.hpp
index daf8f61..968374a 100644
--- a/contrib/modules/xobjdetect/src/precomp.hpp
+++ b/contrib/modules/xobjdetect/src/precomp.hpp
@@ -53,7 +53,6 @@ the use of this software, even if advised of the possibility of such damage.
#include <opencv2/imgproc/types_c.h>
#include <opencv2/core.hpp>
-#include <opencv2/highgui.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgcodecs/imgcodecs_c.h>
diff --git a/contrib/modules/xobjdetect/src/wbdetector.hpp b/contrib/modules/xobjdetect/src/wbdetector.hpp
index 86247ea..631a423 100644
--- a/contrib/modules/xobjdetect/src/wbdetector.hpp
+++ b/contrib/modules/xobjdetect/src/wbdetector.hpp
@@ -43,7 +43,6 @@ the use of this software, even if advised of the possibility of such damage.
#define __OPENCV_XOBJDETECT_DETECTOR_HPP__
#include <opencv2/core.hpp>
-#include <opencv2/highgui.hpp>
#include <vector>
#include <string>
#include "precomp.hpp"
diff --git a/contrib/modules/xobjdetect/tools/waldboost_detector/waldboost_detector.cpp b/contrib/modules/xobjdetect/tools/waldboost_detector/waldboost_detector.cpp
index 490cdd5..6f196bf 100644
--- a/contrib/modules/xobjdetect/tools/waldboost_detector/waldboost_detector.cpp
+++ b/contrib/modules/xobjdetect/tools/waldboost_detector/waldboost_detector.cpp
@@ -1,6 +1,7 @@
-#include <opencv2/xobjdetect.hpp>
-#include <opencv2/imgcodecs/imgcodecs_c.h>
-#include <opencv2/imgproc.hpp>
+#include "opencv2/xobjdetect.hpp"
+#include "opencv2/imgcodecs.hpp"
+#include "opencv2/imgcodecs/imgcodecs_c.h"
+#include "opencv2/imgproc.hpp"
#include <iostream>
#include <cstdio>
using namespace std;
diff --git a/contrib/modules/xphoto/CMakeLists.txt b/contrib/modules/xphoto/CMakeLists.txt
index 44a1e8a..3e550a3 100644
--- a/contrib/modules/xphoto/CMakeLists.txt
+++ b/contrib/modules/xphoto/CMakeLists.txt
@@ -1,2 +1,2 @@
set(the_description "Addon to basic photo module")
-ocv_define_module(xphoto opencv_core opencv_imgproc OPTIONAL opencv_photo opencv_highgui opencv_photo WRAP python)
+ocv_define_module(xphoto opencv_core opencv_imgproc WRAP python)
diff --git a/contrib/modules/xphoto/src/annf.hpp b/contrib/modules/xphoto/src/annf.hpp
index aa1b07b..1534fa5 100644
--- a/contrib/modules/xphoto/src/annf.hpp
+++ b/contrib/modules/xphoto/src/annf.hpp
@@ -128,11 +128,19 @@ KDTree(const cv::Mat &img, const int _leafNumber, const int _zeroThresh)
leafNumber(_leafNumber), zeroThresh(_zeroThresh)
///////////////////////////////////////////////////
{
- CV_Assert( img.isContinuous() );
+ int imgch = img.channels();
+ CV_Assert( img.isContinuous() && imgch <= cn);
+
+ for(size_t i = 0; i < img.total(); i++)
+ {
+ cv::Vec<Tp, cn> v = cv::Vec<Tp, cn>::all((Tp)0);
+ for (int c = 0; c < imgch; c++)
+ {
+ v[c] = *((Tp*)(img.data) + i*imgch + c);
+ }
+ data.push_back(v);
+ }
- std::copy( (cv::Vec <Tp, cn> *) img.data,
- (cv::Vec <Tp, cn> *) img.data + img.total(),
- std::back_inserter(data) );
generate_seq( std::back_inserter(idx), 0, int(data.size()) );
std::fill_n( std::back_inserter(nodes),
int(data.size()), cv::Point2i(0, 0) );
diff --git a/contrib/modules/xphoto/src/bm3d_denoising_invoker_commons.hpp b/contrib/modules/xphoto/src/bm3d_denoising_invoker_commons.hpp
index 65ecaf4..b4f51b1 100644
--- a/contrib/modules/xphoto/src/bm3d_denoising_invoker_commons.hpp
+++ b/contrib/modules/xphoto/src/bm3d_denoising_invoker_commons.hpp
@@ -89,7 +89,7 @@ inline static void hardThreshold2D(T *dst, T *thrMap, const int &templateWindowS
{
for (int i = 1; i < templateWindowSizeSq; ++i)
{
- if (std::abs(dst[i] < thrMap[i]))
+ if (std::abs(dst[i]) < thrMap[i])
dst[i] = 0;
}
}
diff --git a/contrib/modules/xphoto/test/test_precomp.hpp b/contrib/modules/xphoto/test/test_precomp.hpp
index 5cd8e80..fe59eee 100644
--- a/contrib/modules/xphoto/test/test_precomp.hpp
+++ b/contrib/modules/xphoto/test/test_precomp.hpp
@@ -13,7 +13,6 @@
#include "opencv2/imgproc.hpp"
#include "opencv2/imgproc/types_c.h"
#include "opencv2/highgui.hpp"
-#include "opencv2/photo.hpp"
#include "opencv2/xphoto.hpp"
#include "opencv2/ts.hpp"
diff --git a/data/haarcascades/haarcascade_frontalcatface.xml b/data/haarcascades/haarcascade_frontalcatface.xml
index 67893dc..1c38a8b 100755
--- a/data/haarcascades/haarcascade_frontalcatface.xml
+++ b/data/haarcascades/haarcascade_frontalcatface.xml
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<!----------------------------------------------------------------------------
+<!--
A frontal cat face detector using the basic set of Haar features, i.e.
horizontal and vertical features but not diagonal features.
@@ -73,7 +73,7 @@
| SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Back to
| Top
//////////////////////////////////////////////////////////////////////////
- ---------------------------------------------------------------------------->
+ -->
<opencv_storage>
<cascade>
<stageType>BOOST</stageType>
diff --git a/data/haarcascades/haarcascade_frontalcatface_extended.xml b/data/haarcascades/haarcascade_frontalcatface_extended.xml
index ccee995..892d5cb 100755
--- a/data/haarcascades/haarcascade_frontalcatface_extended.xml
+++ b/data/haarcascades/haarcascade_frontalcatface_extended.xml
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<!----------------------------------------------------------------------------
+<!--
A frontal cat face detector using the full set of Haar features, i.e.
horizontal, vertical, and diagonal features.
@@ -73,7 +73,7 @@
| SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Back to
| Top
//////////////////////////////////////////////////////////////////////////
- ---------------------------------------------------------------------------->
+ -->
<opencv_storage>
<cascade>
<stageType>BOOST</stageType>
diff --git a/data/haarcascades/haarcascade_smile.xml b/data/haarcascades/haarcascade_smile.xml
index 569db99..bbdd896 100644
--- a/data/haarcascades/haarcascade_smile.xml
+++ b/data/haarcascades/haarcascade_smile.xml
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<!----------------------------------------------------------------------------
+<!--
Smile detector
Contributed by Oscar Deniz Suarez
More information can be found at http://visilab.etsii.uclm.es/personas/oscar/oscar.html
@@ -43,7 +43,7 @@
| Top
//////////////////////////////////////////////////////////////////////////
------------------------------------------------------------------------->
+-->
<opencv_storage>
<cascade type_id="opencv-cascade-classifier"><stageType>BOOST</stageType>
<featureType>HAAR</featureType>
diff --git a/data/haarcascades_cuda/haarcascade_smile.xml b/data/haarcascades_cuda/haarcascade_smile.xml
index b002bf9..c48ba5f 100644
--- a/data/haarcascades_cuda/haarcascade_smile.xml
+++ b/data/haarcascades_cuda/haarcascade_smile.xml
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<!----------------------------------------------------------------------------
+<!--
Smile detector
Contributed by Oscar Deniz Suarez
More information can be found at http://visilab.etsii.uclm.es/personas/oscar/oscar.html
@@ -43,7 +43,7 @@
| Top
//////////////////////////////////////////////////////////////////////////
------------------------------------------------------------------------->
+-->
<opencv_storage>
<!-- Automatically converted from data/classifier, window size = 36x18 -->
<SmileDetector type_id="opencv-haar-classifier">
diff --git a/data/lbpcascades/lbpcascade_frontalcatface.xml b/data/lbpcascades/lbpcascade_frontalcatface.xml
index 3b4b1bf..8fcaa61 100644
--- a/data/lbpcascades/lbpcascade_frontalcatface.xml
+++ b/data/lbpcascades/lbpcascade_frontalcatface.xml
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<!----------------------------------------------------------------------------
+<!--
A frontal cat face detector using LBP features.
Contributed by Joseph Howse (josephhowse at nummist.com).
@@ -72,7 +72,7 @@
| SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Back to
| Top
//////////////////////////////////////////////////////////////////////////
- ---------------------------------------------------------------------------->
+-->
<opencv_storage>
<cascade>
<stageType>BOOST</stageType>
diff --git a/data/lbpcascades/lbpcascade_frontalface_improved.xml b/data/lbpcascades/lbpcascade_frontalface_improved.xml
new file mode 100644
index 0000000..77eb0f6
--- /dev/null
+++ b/data/lbpcascades/lbpcascade_frontalface_improved.xml
@@ -0,0 +1,1469 @@
+<?xml version="1.0"?>
+<!--
+//////////////////////////////////////////////////////////////////////////
+| Contributors License Agreement
+| IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+| By downloading, copying, installing or using the software you agree
+| to this license. If you do not agree to this license, do not download,
+| install, copy or use the software.
+|
+| Copyright (c) 2017, Puttemans Steven, Can Ergun and Toon Goedeme
+| (KU Leuven, EAVISE Research Group, Jan Pieter De Nayerlaan 5,
+| Sint-Katelijne-Waver, Belgium).
+| All rights reserved.
+|
+| Redistribution and use in source and binary forms, with or without
+| modification, are permitted provided that the following conditions are
+| met:
+|
+| * Redistributions of source code must retain the above copyright
+| notice, this list of conditions and the following disclaimer.
+| * Redistributions in binary form must reproduce the above
+| copyright notice, this list of conditions and the following
+| disclaimer in the documentation and/or other materials provided
+| with the distribution.
+| * The name of Contributor may not used to endorse or promote products
+| derived from this software without specific prior written permission.
+|
+| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+| CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+| PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+| PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+| LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+| NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+| SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//////////////////////////////////////////////////////////////////////////
+
+=====================================================================
+Improving Open Source Face Detection by Combining an Adapted Cascade
+Classification Pipeline and Active Learning
+=====================================================================
+by Puttemans Steven, Can Ergun and Toon Goedeme (KU Leuven, EAVISE, Belgium)
+
+This model is the best performing IterativeHardPositives+ frontal face detection model
+used in the research paper presented at VISAPP2017, Porto, Portugal.
+
+RESEARCHERS:
+If you are using the improved face detection model or involved ideas please cite
+this paper (available at http://eavise.be/publications_lirias.php):
+
+ at InProceedings{PuttemansVISAPP2017,
+ author = "Puttemans Steven, Can Ergun and Toon Goedeme",
+ title = "Improving Open Source Face Detection by Combining an Adapted Cascade Classification Pipeline and Active Learning"
+ booktitle = "12th International Conference on Computer Vision Theory and Applications"
+ year = "2017",
+ month = "February"
+}
+
+COMMERCIAL:
+If you have any commercial interest in this work please contact
+steven.puttemans at kuleuven.be or toon.goedeme at kuleuven.be
+-->
+
+<opencv_storage>
+<cascade>
+ <stageType>BOOST</stageType>
+ <featureType>LBP</featureType>
+ <height>45</height>
+ <width>45</width>
+ <stageParams>
+ <boostType>GAB</boostType>
+ <minHitRate>9.9500000476837158e-001</minHitRate>
+ <maxFalseAlarm>5.0000000000000000e-001</maxFalseAlarm>
+ <weightTrimRate>9.4999999999999996e-001</weightTrimRate>
+ <maxDepth>1</maxDepth>
+ <maxWeakCount>100</maxWeakCount></stageParams>
+ <featureParams>
+ <maxCatCount>256</maxCatCount>
+ <featSize>1</featSize></featureParams>
+ <stageNum>19</stageNum>
+ <stages>
+ <!-- stage 0 -->
+ <_>
+ <maxWeakCount>6</maxWeakCount>
+ <stageThreshold>-4.1617846488952637e+000</stageThreshold>
+ <weakClassifiers>
+ <_>
+ <internalNodes>
+ 0 -1 26 -1 -1 -17409 -1 -1 -1 -1 -1</internalNodes>
+ <leafValues>
+ -9.9726462364196777e-001 -3.8938775658607483e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 18 -1 -1 -21569 -20545 -1 -1 -20545 -1</internalNodes>
+ <leafValues>
+ -9.8648911714553833e-001 -2.5386649370193481e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 30 -21569 -16449 1006578219 -20801 -16449 -1 -21585 -1</internalNodes>
+ <leafValues>
+ -9.6436238288879395e-001 -1.4039695262908936e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 54 -1 -1 -16402 -4370 -1 -1 -1053010 -4456466</internalNodes>
+ <leafValues>
+ -8.4081345796585083e-001 3.8321062922477722e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 29 -184747280 -705314819 1326353 1364574079 -131073 -5
+ 2147481147 -1</internalNodes>
+ <leafValues>
+ -8.1084597110748291e-001 4.3495711684226990e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 89 -142618625 -4097 -37269 -20933 872350430 -268476417
+ 1207894255 2139032115</internalNodes>
+ <leafValues>
+ -7.3140043020248413e-001 4.3799084424972534e-001</leafValues></_></weakClassifiers></_>
+ <!-- stage 1 -->
+ <_>
+ <maxWeakCount>6</maxWeakCount>
+ <stageThreshold>-4.0652265548706055e+000</stageThreshold>
+ <weakClassifiers>
+ <_>
+ <internalNodes>
+ 0 -1 19 -1 -1 -17409 -1 -1 -1 -1 -1</internalNodes>
+ <leafValues>
+ -9.9727255105972290e-001 -7.2050148248672485e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 38 -1 1073741823 -1 -1 -1 -1 -1 -1</internalNodes>
+ <leafValues>
+ -9.8717331886291504e-001 -5.3031939268112183e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 28 -16385 -1 -21569 -20545 -1 -1 -21569 -1</internalNodes>
+ <leafValues>
+ -9.3442338705062866e-001 6.5213099122047424e-002</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 112 -2097153 -1 -1 -1 -1 -8193 -1 -35467</internalNodes>
+ <leafValues>
+ -7.9567342996597290e-001 4.2883640527725220e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 48 -134239573 -16465 58663467 -1079022929 -1073758273
+ -81937 -8412501 -404766817</internalNodes>
+ <leafValues>
+ -7.1264797449111938e-001 4.1050794720649719e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 66 -17047555 -1099008003 2147479551 -1090584581 -69633
+ -1342177281 -1090650121 -1472692240</internalNodes>
+ <leafValues>
+ -7.6119172573089600e-001 4.2042696475982666e-001</leafValues></_></weakClassifiers></_>
+ <!-- stage 2 -->
+ <_>
+ <maxWeakCount>7</maxWeakCount>
+ <stageThreshold>-4.6904473304748535e+000</stageThreshold>
+ <weakClassifiers>
+ <_>
+ <internalNodes>
+ 0 -1 12 -1 -1 -17409 -1 -1 -1 -1 -1</internalNodes>
+ <leafValues>
+ -9.9725550413131714e-001 -8.3142280578613281e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 31 -1 -168429569 -1 -1 -1 -1 -1 -1</internalNodes>
+ <leafValues>
+ -9.8183268308639526e-001 -3.6373397707939148e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 38 -1 1073741759 -1 -1 -1 -1 -1 -1</internalNodes>
+ <leafValues>
+ -9.1890293359756470e-001 7.8322596848011017e-002</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 27 -17409 -2097153 -134372726 -21873 -65 -536870913
+ -161109 -4215889</internalNodes>
+ <leafValues>
+ -8.0752444267272949e-001 1.9565649330615997e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 46 -469779457 -286371842 -33619971 -212993 -1 -41943049
+ -134217731 -1346863620</internalNodes>
+ <leafValues>
+ -6.9232726097106934e-001 3.8141927123069763e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 125 -1896950780 -1964839052 -9 707723004 -34078727
+ -1074266122 -536872969 -262145</internalNodes>
+ <leafValues>
+ -8.1760478019714355e-001 3.4172961115837097e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 80 -402657501 654311423 -419533278 -452984853
+ 1979676215 -1208090625 -167772569 -524289</internalNodes>
+ <leafValues>
+ -6.3433408737182617e-001 4.3154156208038330e-001</leafValues></_></weakClassifiers></_>
+ <!-- stage 3 -->
+ <_>
+ <maxWeakCount>8</maxWeakCount>
+ <stageThreshold>-4.2590322494506836e+000</stageThreshold>
+ <weakClassifiers>
+ <_>
+ <internalNodes>
+ 0 -1 42 -1 -655361 -1 -1 -1 -1 -1 -1</internalNodes>
+ <leafValues>
+ -9.9715477228164673e-001 -8.6178696155548096e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 40 -1 -705300491 -1 -1 -1 -1 -1 -1</internalNodes>
+ <leafValues>
+ -9.8356908559799194e-001 -5.7423096895217896e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 43 -65 872413111 -2049 -1 -1 -1 -1 -1</internalNodes>
+ <leafValues>
+ -9.2525935173034668e-001 -1.3835857808589935e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 111 -1 -5242881 -1 -524289 -4194305 -1 -1 -43148</internalNodes>
+ <leafValues>
+ -7.8076487779617310e-001 1.8362471461296082e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 25 -145227841 868203194 -1627394049 935050171
+ 2147483647 1006600191 -268439637 1002437615</internalNodes>
+ <leafValues>
+ -7.2554033994674683e-001 3.3393219113349915e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 116 -214961408 50592514 -2128 1072162674 -1077940293
+ -1084489966 -134219854 -1074790401</internalNodes>
+ <leafValues>
+ -6.1547595262527466e-001 3.9214438199996948e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 3 -294987948 -1124421633 -73729 -268435841 -33654928
+ 2122317823 -268599297 -33554945</internalNodes>
+ <leafValues>
+ -6.4863425493240356e-001 3.8784855604171753e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 22 -525585 -26738821 -17895690 1123482236 1996455758
+ -8519849 -252182980 -461898753</internalNodes>
+ <leafValues>
+ -5.5464369058609009e-001 4.4275921583175659e-001</leafValues></_></weakClassifiers></_>
+ <!-- stage 4 -->
+ <_>
+ <maxWeakCount>8</maxWeakCount>
+ <stageThreshold>-4.0009465217590332e+000</stageThreshold>
+ <weakClassifiers>
+ <_>
+ <internalNodes>
+ 0 -1 82 -1 -1 -1 -1 -33685505 -1 -1 -1</internalNodes>
+ <leafValues>
+ -9.9707120656967163e-001 -8.9196771383285522e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 84 -1 -1 -1 -1 2147446783 -1 -1 -1</internalNodes>
+ <leafValues>
+ -9.8670446872711182e-001 -7.5064390897750854e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 79 -1 -1 -262145 -1 -252379137 -1 -1 -1</internalNodes>
+ <leafValues>
+ -8.9446705579757690e-001 7.0268943905830383e-002</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 61 -1 -8201 -1 -2097153 -16777217 -513 -16777217
+ -1162149889</internalNodes>
+ <leafValues>
+ -7.2166109085083008e-001 2.9786801338195801e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 30 -21569 -1069121 1006578211 -134238545 -16450
+ -268599297 -21617 -14680097</internalNodes>
+ <leafValues>
+ -6.2449234724044800e-001 3.8551881909370422e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 75 -268701913 -1999962377 1995165474 -453316822
+ 1744684853 -2063597697 -134226057 -50336769</internalNodes>
+ <leafValues>
+ -5.5207914113998413e-001 4.2211884260177612e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 21 -352321825 -526489 -420020626 -486605074 1155483470
+ -110104705 -587840772 -25428801</internalNodes>
+ <leafValues>
+ -5.3324747085571289e-001 4.4535955786705017e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 103 70270772 2012790229 -16810020 -245764 -1208090635
+ -753667 -1073741828 -1363662420</internalNodes>
+ <leafValues>
+ -6.4402890205383301e-001 3.8995954394340515e-001</leafValues></_></weakClassifiers></_>
+ <!-- stage 5 -->
+ <_>
+ <maxWeakCount>8</maxWeakCount>
+ <stageThreshold>-4.6897511482238770e+000</stageThreshold>
+ <weakClassifiers>
+ <_>
+ <internalNodes>
+ 0 -1 97 -1 -1 -1 -1 -524289 -524289 -1 -1</internalNodes>
+ <leafValues>
+ -9.9684870243072510e-001 -8.8232177495956421e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 84 -1 -1 -1 -1 2147438591 -1 -1 -1</internalNodes>
+ <leafValues>
+ -9.8677414655685425e-001 -7.8965580463409424e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 113 -1 -1 -1 -1 -1048577 -262149 -1048577 -35339</internalNodes>
+ <leafValues>
+ -9.2621946334838867e-001 -2.9984828829765320e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 33 -2249 867434291 -32769 -33562753 -1 -1073758209
+ -4165 -1</internalNodes>
+ <leafValues>
+ -7.2429555654525757e-001 2.2348840534687042e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 98 1659068671 -142606337 587132538 -67108993 577718271
+ -294921 -134479873 -129</internalNodes>
+ <leafValues>
+ -5.5495566129684448e-001 3.5419258475303650e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 100 -268441813 788267007 -286265494 -486576145 -8920251
+ 2138505075 -151652570 -2050</internalNodes>
+ <leafValues>
+ -5.3362584114074707e-001 3.9479774236679077e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 51 -1368387212 -537102978 -98305 -163843 1065109500
+ -16777217 -67321939 -1141359619</internalNodes>
+ <leafValues>
+ -5.6162708997726440e-001 3.8008108735084534e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 127 -268435550 1781120906 -251658720 -143130698
+ -1048605 -1887436825 1979700688 -1008730125</internalNodes>
+ <leafValues>
+ -5.1167154312133789e-001 4.0678605437278748e-001</leafValues></_></weakClassifiers></_>
+ <!-- stage 6 -->
+ <_>
+ <maxWeakCount>10</maxWeakCount>
+ <stageThreshold>-4.2179841995239258e+000</stageThreshold>
+ <weakClassifiers>
+ <_>
+ <internalNodes>
+ 0 -1 97 -1 -1 -1 -1 -524289 -524289 -1 -1</internalNodes>
+ <leafValues>
+ -9.9685418605804443e-001 -8.8037383556365967e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 90 -1 -1 -1 -1 -8912897 -524297 -8912897 -1</internalNodes>
+ <leafValues>
+ -9.7972750663757324e-001 -5.7626229524612427e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 96 -1 -1 -1 -1 -1 -65 -1 -2249</internalNodes>
+ <leafValues>
+ -9.0239793062210083e-001 -1.7454113066196442e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 71 -1 -4097 -1 -513 -16777217 -268468483 -16797697
+ -1430589697</internalNodes>
+ <leafValues>
+ -7.4346423149108887e-001 9.4165161252021790e-002</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 37 1364588304 -581845274 -536936460 -3 -308936705
+ -1074331649 -4196865 -134225953</internalNodes>
+ <leafValues>
+ -6.8877440690994263e-001 2.7647304534912109e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 117 -37765187 -540675 -3 -327753 -1082458115 -65537
+ 1071611901 536827253</internalNodes>
+ <leafValues>
+ -5.7555085420608521e-001 3.4339720010757446e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 85 -269490650 -1561395522 -1343312090 -857083986
+ -1073750223 -369098755 -50856110 -2065</internalNodes>
+ <leafValues>
+ -5.4036927223205566e-001 4.0065473318099976e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 4 -425668880 -34427164 1879048177 -269570140 790740912
+ -196740 2138535839 -536918145</internalNodes>
+ <leafValues>
+ -4.8439365625381470e-001 4.4630467891693115e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 92 74726960 -1246482434 -1 -246017 -1078607916
+ -1073947163 -1644231687 -1359211496</internalNodes>
+ <leafValues>
+ -5.6686979532241821e-001 3.6671569943428040e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 11 -135274809 -1158173459 -353176850 540195262
+ 2139086600 2071977814 -546898600 -96272673</internalNodes>
+ <leafValues>
+ -5.1499199867248535e-001 4.0788397192955017e-001</leafValues></_></weakClassifiers></_>
+ <!-- stage 7 -->
+ <_>
+ <maxWeakCount>9</maxWeakCount>
+ <stageThreshold>-4.0345416069030762e+000</stageThreshold>
+ <weakClassifiers>
+ <_>
+ <internalNodes>
+ 0 -1 78 -1 -1 -1 -1 -8912897 -1 -8912897 -1</internalNodes>
+ <leafValues>
+ -9.9573624134063721e-001 -8.5452395677566528e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 93 -1 -1 -1 -1 -148635649 -524297 -8912897 -1</internalNodes>
+ <leafValues>
+ -9.7307401895523071e-001 -5.2884924411773682e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 77 -1 -8209 -1 -257 -772734977 -1 -201850881 -1</internalNodes>
+ <leafValues>
+ -8.6225658655166626e-001 4.3712578713893890e-002</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 68 -570427393 -16649 -69633 -131073 -536944677 -1 -8737
+ -1435828225</internalNodes>
+ <leafValues>
+ -6.8078064918518066e-001 2.5120577216148376e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 50 -1179697 -34082849 -3278356 -37429266 -1048578
+ -555753474 -1015551096 -37489685</internalNodes>
+ <leafValues>
+ -6.1699724197387695e-001 3.0963841080665588e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 129 -1931606992 -17548804 -16842753 -1075021827
+ 1073667572 -81921 -1611073620 -1415047752</internalNodes>
+ <leafValues>
+ -6.0499197244644165e-001 3.0735063552856445e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 136 -269754813 1761591286 -1073811523 2130378623 -17580
+ -1082294665 -159514800 -1026883840</internalNodes>
+ <leafValues>
+ -5.6772041320800781e-001 3.5023149847984314e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 65 2016561683 1528827871 -10258447 960184191 125476830
+ -8511618 -1078239365 187648611</internalNodes>
+ <leafValues>
+ -5.5894804000854492e-001 3.4856522083282471e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 13 -207423502 -333902 2013200231 -202348848 1042454451
+ -16393 1073117139 2004162321</internalNodes>
+ <leafValues>
+ -5.7197356224060059e-001 3.2818377017974854e-001</leafValues></_></weakClassifiers></_>
+ <!-- stage 8 -->
+ <_>
+ <maxWeakCount>9</maxWeakCount>
+ <stageThreshold>-3.4892759323120117e+000</stageThreshold>
+ <weakClassifiers>
+ <_>
+ <internalNodes>
+ 0 -1 78 -1 -1 -1 -1 -8912897 -1 -8912897 -1</internalNodes>
+ <leafValues>
+ -9.8917990922927856e-001 -7.3812037706375122e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 93 -1 -1 -1 -1 -148635649 -524297 -8912897 -1</internalNodes>
+ <leafValues>
+ -9.3414896726608276e-001 -2.6945295929908752e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 83 -1 -524289 -1 -1048577 1879011071 -32769 -524289
+ -3178753</internalNodes>
+ <leafValues>
+ -7.6891708374023438e-001 5.2568886429071426e-002</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 9 -352329729 -17891329 -16810117 -486871042 -688128841
+ -1358954675 -16777218 -219217968</internalNodes>
+ <leafValues>
+ -6.2337344884872437e-001 2.5143685936927795e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 130 -2157 -1548812374 -1343233440 -418381854 -953155613
+ -836960513 -713571200 -709888014</internalNodes>
+ <leafValues>
+ -4.7277018427848816e-001 3.9616456627845764e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 121 -1094717701 -67240065 -65857 -32899 -5783756
+ -136446081 -134285352 -2003298884</internalNodes>
+ <leafValues>
+ -5.1766264438629150e-001 3.5814732313156128e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 23 -218830160 -119671186 5505075 1241491391 -1594469
+ -2097185 2004828075 -67649541</internalNodes>
+ <leafValues>
+ -6.5394639968872070e-001 3.0377501249313354e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 115 -551814749 2099511088 -1090732551 -2045546512
+ -1086341441 1059848178 800042912 252705994</internalNodes>
+ <leafValues>
+ -5.2584588527679443e-001 3.3847147226333618e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 99 -272651477 578776766 -285233490 -889225217
+ 2147448656 377454463 2012701952 -68157761</internalNodes>
+ <leafValues>
+ -6.1836904287338257e-001 2.8922611474990845e-001</leafValues></_></weakClassifiers></_>
+ <!-- stage 9 -->
+ <_>
+ <maxWeakCount>9</maxWeakCount>
+ <stageThreshold>-3.0220029354095459e+000</stageThreshold>
+ <weakClassifiers>
+ <_>
+ <internalNodes>
+ 0 -1 36 -1 -570425345 -1 -570425345 -1 -50331649 -6291457 -1</internalNodes>
+ <leafValues>
+ -9.7703826427459717e-001 -6.2527233362197876e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 124 -1430602241 -33619969 -1 -3 -1074003969 -1073758209
+ -1073741825 -1073768705</internalNodes>
+ <leafValues>
+ -8.9538317918777466e-001 -3.1887885928153992e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 88 -1 -268439625 -65601 -268439569 -393809 -270532609
+ -42076889 -288361721</internalNodes>
+ <leafValues>
+ -6.8733429908752441e-001 1.2978810071945190e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 132 -755049252 2042563807 1795096575 465121071
+ -1090585188 -20609 -1459691784 539672495</internalNodes>
+ <leafValues>
+ -5.7038843631744385e-001 3.0220884084701538e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 20 -94377762 -25702678 1694167798 -231224662 1079955016
+ -346144140 2029995743 -536918961</internalNodes>
+ <leafValues>
+ -5.3204691410064697e-001 3.4054222702980042e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 47 2143026943 -285278225 -3 -612438281 -16403 -131074
+ -1 -1430749256</internalNodes>
+ <leafValues>
+ -4.6176829934120178e-001 4.1114711761474609e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 74 203424336 -25378820 -35667973 1073360894 -1912815660
+ -573444 -356583491 -1365235056</internalNodes>
+ <leafValues>
+ -4.9911966919898987e-001 3.5335537791252136e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 6 -1056773 -1508430 -558153 -102747408 2133997491
+ -269043865 2004842231 -8947721</internalNodes>
+ <leafValues>
+ -4.0219521522521973e-001 4.3947893381118774e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 70 -880809694 -1070282769 -1363162108 -838881281
+ -680395161 -2064124929 -34244753 1173880701</internalNodes>
+ <leafValues>
+ -5.3891533613204956e-001 3.2062566280364990e-001</leafValues></_></weakClassifiers></_>
+ <!-- stage 10 -->
+ <_>
+ <maxWeakCount>8</maxWeakCount>
+ <stageThreshold>-2.5489892959594727e+000</stageThreshold>
+ <weakClassifiers>
+ <_>
+ <internalNodes>
+ 0 -1 39 -1 -572522497 -8519681 -570425345 -4195329 -50333249
+ -1 -1</internalNodes>
+ <leafValues>
+ -9.4647216796875000e-001 -3.3662387728691101e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 124 -1430735362 -33619971 -8201 -3 -1677983745
+ -1073762817 -1074003969 -1142979329</internalNodes>
+ <leafValues>
+ -8.0300611257553101e-001 -3.8466516882181168e-002</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 91 -67113217 -524289 -671482265 -786461 1677132031
+ -268473345 -68005889 -70291765</internalNodes>
+ <leafValues>
+ -5.8367580175399780e-001 2.6507318019866943e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 17 -277872641 -553910292 -268435458 -16843010
+ 1542420439 -1342178311 -143132940 -2834</internalNodes>
+ <leafValues>
+ -4.6897178888320923e-001 3.7864661216735840e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 137 -1312789 -290527285 -286326862 -5505280 -1712335966
+ -2045979188 1165423617 -709363723</internalNodes>
+ <leafValues>
+ -4.6382644772529602e-001 3.6114525794982910e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 106 1355856590 -109445156 -96665606 2066939898
+ 1356084692 1549031917 -30146561 -16581701</internalNodes>
+ <leafValues>
+ -6.3095021247863770e-001 2.9294869303703308e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 104 -335555328 118529 1860167712 -810680357 -33558656
+ -1368391795 -402663552 -1343225921</internalNodes>
+ <leafValues>
+ -5.9658926725387573e-001 2.7228885889053345e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 76 217581168 -538349634 1062631419 1039868926
+ -1090707460 -2228359 -1078042693 -1147128518</internalNodes>
+ <leafValues>
+ -4.5812287926673889e-001 3.7063929438591003e-001</leafValues></_></weakClassifiers></_>
+ <!-- stage 11 -->
+ <_>
+ <maxWeakCount>9</maxWeakCount>
+ <stageThreshold>-2.5802578926086426e+000</stageThreshold>
+ <weakClassifiers>
+ <_>
+ <internalNodes>
+ 0 -1 35 -513 -706873891 -270541825 1564475391 -120602625
+ -118490145 -3162113 -1025</internalNodes>
+ <leafValues>
+ -8.9068460464477539e-001 -1.6470588743686676e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 41 -1025 872144563 -2105361 -1078076417 -1048577
+ -1145061461 -87557413 -1375993973</internalNodes>
+ <leafValues>
+ -7.1808964014053345e-001 2.2022204473614693e-002</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 95 -42467849 967946223 -811601986 1030598351
+ -1212430676 270856533 -1392539508 147705039</internalNodes>
+ <leafValues>
+ -4.9424821138381958e-001 3.0048963427543640e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 10 -218116370 -637284625 -87373174 -521998782
+ -805355450 -615023745 -814267322 -12069282</internalNodes>
+ <leafValues>
+ -5.5306458473205566e-001 2.9137542843818665e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 105 -275849241 -527897 -11052049 -69756067 -15794193
+ -1141376839 -564771 -287095455</internalNodes>
+ <leafValues>
+ -4.6759819984436035e-001 3.6638516187667847e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 24 -1900898096 -18985228 -44056577 -24675 -1074880639
+ -283998 796335613 -1079041957</internalNodes>
+ <leafValues>
+ -4.2737138271331787e-001 3.9243003726005554e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 139 -555790844 410735094 -32106513 406822863 -897632192
+ -912830145 -117771560 -1204027649</internalNodes>
+ <leafValues>
+ -4.1896930336952209e-001 3.6744937300682068e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 0 -1884822366 -1406613148 1135342180 -1979127580
+ -68174862 246469804 1001386992 -708885872</internalNodes>
+ <leafValues>
+ -5.7093089818954468e-001 2.9880744218826294e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 45 -469053950 1439068142 2117758841 2004671078
+ 207931006 1265321675 970353931 1541343047</internalNodes>
+ <leafValues>
+ -6.0491901636123657e-001 2.4652053415775299e-001</leafValues></_></weakClassifiers></_>
+ <!-- stage 12 -->
+ <_>
+ <maxWeakCount>9</maxWeakCount>
+ <stageThreshold>-2.2425732612609863e+000</stageThreshold>
+ <weakClassifiers>
+ <_>
+ <internalNodes>
+ 0 -1 58 1481987157 282547485 -14952129 421131223 -391065352
+ -24212488 -100094241 -1157907473</internalNodes>
+ <leafValues>
+ -8.2822084426879883e-001 -2.1619293093681335e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 126 -134217889 -543174305 -75497474 -16851650 -6685738
+ -75834693 -2097200 -262146</internalNodes>
+ <leafValues>
+ -5.4628932476043701e-001 2.7662658691406250e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 133 -220728227 -604288517 -661662214 413104863
+ -627323700 -251915415 -626200872 -1157958657</internalNodes>
+ <leafValues>
+ -4.1643124818801880e-001 4.1700571775436401e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 2 -186664033 -44236961 -1630262774 -65163606 -103237330
+ -3083265 -1003729 2053105955</internalNodes>
+ <leafValues>
+ -5.4847818613052368e-001 2.9710745811462402e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 62 -256115886 -237611873 -620250696 387061799
+ 1437882671 274878849 -8684449 1494294023</internalNodes>
+ <leafValues>
+ -4.6202757954597473e-001 3.3915829658508301e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 1 -309400577 -275864640 -1056864869 1737132756
+ -272385089 1609671419 1740601343 1261376789</internalNodes>
+ <leafValues>
+ -4.6158722043037415e-001 3.3939516544342041e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 102 818197248 -196324552 286970589 -573270699
+ -1174099579 -662077381 -1165157895 -1626859296</internalNodes>
+ <leafValues>
+ -4.6193107962608337e-001 3.2456985116004944e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 69 -1042550357 14675409 1367955200 -841482753
+ 1642443255 8774277 1941304147 1099949563</internalNodes>
+ <leafValues>
+ -4.9091196060180664e-001 3.3870378136634827e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 72 -639654997 1375720439 -2129542805 1614801090
+ -626787937 -5779294 1488699183 -525406458</internalNodes>
+ <leafValues>
+ -4.9073097109794617e-001 3.0637946724891663e-001</leafValues></_></weakClassifiers></_>
+ <!-- stage 13 -->
+ <_>
+ <maxWeakCount>9</maxWeakCount>
+ <stageThreshold>-1.2258235216140747e+000</stageThreshold>
+ <weakClassifiers>
+ <_>
+ <internalNodes>
+ 0 -1 118 302046707 -16744240 1360106207 -543735387
+ 1025700851 -1079408512 1796961263 -6334981</internalNodes>
+ <leafValues>
+ -6.1358314752578735e-001 2.3539231717586517e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 5 -144765953 -116448726 -653851877 1934829856 722021887
+ 856564834 1933919231 -540838029</internalNodes>
+ <leafValues>
+ -5.1209545135498047e-001 3.2506987452507019e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 140 -170132825 -1438923874 1879300370 -1689337194
+ -695606496 285911565 -1044188928 -154210028</internalNodes>
+ <leafValues>
+ -5.1769560575485229e-001 3.2290914654731750e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 131 -140776261 -355516414 822178224 -1039743806
+ -1012208926 134887424 1438876097 -908591660</internalNodes>
+ <leafValues>
+ -5.0321841239929199e-001 3.0263835191726685e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 64 -2137211696 -1634281249 1464325973 498569935
+ -1580152080 -2001687927 721783561 265096035</internalNodes>
+ <leafValues>
+ -4.6532225608825684e-001 3.4638473391532898e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 101 -255073589 -211824417 -972195129 -1063415417
+ 1937994261 1363165220 -754733105 1967602541</internalNodes>
+ <leafValues>
+ -4.9611270427703857e-001 3.3260712027549744e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 81 -548146862 -655567194 -2062466596 1164562721
+ 416408236 -1591631712 -83637777 975344427</internalNodes>
+ <leafValues>
+ -4.9862930178642273e-001 3.2003280520439148e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 55 -731904652 2147179896 2147442687 2112830847 -65604
+ -131073 -42139667 -1074907393</internalNodes>
+ <leafValues>
+ -3.6636069416999817e-001 4.5651626586914063e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 67 1885036886 571985932 -1784930633 724431327
+ 1940422257 -1085746880 964888398 731867951</internalNodes>
+ <leafValues>
+ -5.2619713544845581e-001 3.2635414600372314e-001</leafValues></_></weakClassifiers></_>
+ <!-- stage 14 -->
+ <_>
+ <maxWeakCount>9</maxWeakCount>
+ <stageThreshold>-1.3604533672332764e+000</stageThreshold>
+ <weakClassifiers>
+ <_>
+ <internalNodes>
+ 0 -1 8 -287609985 -965585953 -2146397793 -492129894
+ -729029645 -544619901 -645693256 -6565484</internalNodes>
+ <leafValues>
+ -4.5212322473526001e-001 3.8910505175590515e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 122 -102903523 -145031013 536899675 688195859
+ -645291520 -1165359094 -905565928 171608223</internalNodes>
+ <leafValues>
+ -4.9594074487686157e-001 3.4109055995941162e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 134 -790640459 487931983 1778450522 1036604041
+ -904752984 -954040118 -2134707506 304866043</internalNodes>
+ <leafValues>
+ -4.1148442029953003e-001 3.9666590094566345e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 141 -303829117 1726939070 922189815 -827983123
+ 1567883042 1324809852 292710260 -942678754</internalNodes>
+ <leafValues>
+ -3.5154473781585693e-001 4.8011952638626099e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 59 -161295376 -159215460 -1858041315 2140644499
+ -2009065472 -133804007 -2003265301 1263206851</internalNodes>
+ <leafValues>
+ -4.2808216810226440e-001 3.9841541647911072e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 34 -264248081 -667846464 1342624856 1381160835
+ -2104716852 1342865409 -266612310 -165954877</internalNodes>
+ <leafValues>
+ -4.3293288350105286e-001 4.0339657664299011e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 32 -1600388464 -40369901 285344639 1394344275
+ -255680312 -100532214 -1031663944 -7471079</internalNodes>
+ <leafValues>
+ -4.1385015845298767e-001 4.5087572932243347e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 15 1368521651 280207469 35779199 -105983261 1208124819
+ -565870452 -1144024288 -591535344</internalNodes>
+ <leafValues>
+ -4.2956474423408508e-001 4.2176279425621033e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 109 1623607527 -661513115 -1073217263 -2142994420
+ -1339883309 -89816956 436308899 1426178059</internalNodes>
+ <leafValues>
+ -4.7764992713928223e-001 3.7551075220108032e-001</leafValues></_></weakClassifiers></_>
+ <!-- stage 15 -->
+ <_>
+ <maxWeakCount>9</maxWeakCount>
+ <stageThreshold>-4.2518746852874756e-001</stageThreshold>
+ <weakClassifiers>
+ <_>
+ <internalNodes>
+ 0 -1 135 -116728032 -1154420809 -1350582273 746061691
+ -1073758277 2138570623 2113797566 -138674182</internalNodes>
+ <leafValues>
+ -1.7125381529331207e-001 6.5421247482299805e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 63 -453112432 -1795354691 -1342242964 494112553
+ 209458404 -2114697500 1316830362 259213855</internalNodes>
+ <leafValues>
+ -3.9870172739028931e-001 4.5807033777236938e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 52 -268172036 294715533 268575185 486785157 -1065303920
+ -360185856 -2147476808 134777113</internalNodes>
+ <leafValues>
+ -5.3581339120864868e-001 3.5815808176994324e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 86 -301996882 -345718921 1877946252 -940720129
+ -58737369 -721944585 -92954835 -530449</internalNodes>
+ <leafValues>
+ -3.9938014745712280e-001 4.9603295326232910e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 14 -853281886 -756895766 2130706352 -9519120
+ -1921059862 394133373 2138453959 -538200841</internalNodes>
+ <leafValues>
+ -4.0230083465576172e-001 4.9537116289138794e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 128 -2133448688 -641138493 1078022185 294060066
+ -327122776 -2130640896 -2147466247 -1910634326</internalNodes>
+ <leafValues>
+ -5.8290809392929077e-001 3.4102553129196167e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 53 587265978 -2071658479 1108361221 -578448765
+ -1811905899 -2008965119 33900729 762301595</internalNodes>
+ <leafValues>
+ -4.5518967509269714e-001 4.7242793440818787e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 138 -1022189373 -2139094976 16658 -1069445120
+ -1073555454 -1073577856 1096068 -978351488</internalNodes>
+ <leafValues>
+ -4.7530207037925720e-001 4.3885371088981628e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 7 -395352441 -1073541103 -1056964605 1053186 269111298
+ -2012184576 1611208714 -360415095</internalNodes>
+ <leafValues>
+ -5.0448113679885864e-001 4.1588482260704041e-001</leafValues></_></weakClassifiers></_>
+ <!-- stage 16 -->
+ <_>
+ <maxWeakCount>7</maxWeakCount>
+ <stageThreshold>2.7163455262780190e-002</stageThreshold>
+ <weakClassifiers>
+ <_>
+ <internalNodes>
+ 0 -1 49 783189748 -137429026 -257 709557994 2130460236
+ -196611 -9580 585428708</internalNodes>
+ <leafValues>
+ -2.0454545319080353e-001 7.9608374834060669e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 108 1284360448 1057423155 1592696573 -852672655
+ 1547382714 -1642594369 125705358 797134398</internalNodes>
+ <leafValues>
+ -3.6474677920341492e-001 6.0925579071044922e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 94 1347680270 -527720448 1091567712 1073745933
+ -1073180671 0 285745154 -511192438</internalNodes>
+ <leafValues>
+ -4.6406838297843933e-001 5.5626088380813599e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 73 1705780944 -145486260 -115909 -281793505 -418072663
+ -1681064068 1877454127 -1912330993</internalNodes>
+ <leafValues>
+ -4.7043186426162720e-001 5.8430361747741699e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 110 -2118142016 339509033 -285260567 1417764573
+ 68144392 -468879483 -2033291636 231451911</internalNodes>
+ <leafValues>
+ -4.8700931668281555e-001 5.4639810323715210e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 119 -1888051818 489996135 -65539 849536890 2146716845
+ -1107542088 -1275615746 -1119617586</internalNodes>
+ <leafValues>
+ -4.3356490135192871e-001 6.5175366401672363e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 44 -1879021438 336830528 1073766659 1477541961 8560696
+ -1207369568 8462472 1493893448</internalNodes>
+ <leafValues>
+ -5.4343086481094360e-001 5.2777874469757080e-001</leafValues></_></weakClassifiers></_>
+ <!-- stage 17 -->
+ <_>
+ <maxWeakCount>7</maxWeakCount>
+ <stageThreshold>4.9174150824546814e-001</stageThreshold>
+ <weakClassifiers>
+ <_>
+ <internalNodes>
+ 0 -1 57 644098 15758324 1995964260 -463011882 893285175
+ 83156983 2004317989 16021237</internalNodes>
+ <leafValues>
+ -1.7073170840740204e-001 9.0782123804092407e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 123 268632845 -2147450864 -2143240192 -2147401728
+ 8523937 -1878523840 16777416 616824984</internalNodes>
+ <leafValues>
+ -4.8744434118270874e-001 7.3311311006546021e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 120 -2110735872 803880886 989739810 1673281312 91564930
+ -277454958 997709514 -581366443</internalNodes>
+ <leafValues>
+ -4.0291741490364075e-001 8.2450771331787109e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 87 941753434 -1067128905 788512753 -1074450460
+ 779101657 -1346552460 938805167 -2050424642</internalNodes>
+ <leafValues>
+ -3.6246949434280396e-001 8.7103593349456787e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 60 208 1645217920 130 538263552 33595552 -1475870592
+ 16783361 1375993867</internalNodes>
+ <leafValues>
+ -6.1472141742706299e-001 5.9707164764404297e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 114 1860423179 1034692624 -285213187 -986681712
+ 1576755092 -1408205463 -127714 -1246035687</internalNodes>
+ <leafValues>
+ -4.5621752738952637e-001 8.9482426643371582e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 107 33555004 -1861746688 1073807361 -754909184
+ 645922856 8388608 134250648 419635458</internalNodes>
+ <leafValues>
+ -5.2466005086898804e-001 7.1834069490432739e-001</leafValues></_></weakClassifiers></_>
+ <!-- stage 18 -->
+ <_>
+ <maxWeakCount>2</maxWeakCount>
+ <stageThreshold>1.9084988832473755e+000</stageThreshold>
+ <weakClassifiers>
+ <_>
+ <internalNodes>
+ 0 -1 16 536064 131072 -20971516 524288 576 1048577 0 40960</internalNodes>
+ <leafValues>
+ -8.0000001192092896e-001 9.8018401861190796e-001</leafValues></_>
+ <_>
+ <internalNodes>
+ 0 -1 56 67108864 0 4096 1074003968 8192 536870912 4 262144</internalNodes>
+ <leafValues>
+ -9.6610915660858154e-001 9.2831486463546753e-001</leafValues></_></weakClassifiers></_></stages>
+ <features>
+ <_>
+ <rect>
+ 0 0 1 1</rect></_>
+ <_>
+ <rect>
+ 0 0 3 2</rect></_>
+ <_>
+ <rect>
+ 0 1 13 6</rect></_>
+ <_>
+ <rect>
+ 0 2 3 14</rect></_>
+ <_>
+ <rect>
+ 0 2 4 2</rect></_>
+ <_>
+ <rect>
+ 0 6 2 3</rect></_>
+ <_>
+ <rect>
+ 0 6 3 2</rect></_>
+ <_>
+ <rect>
+ 0 16 1 3</rect></_>
+ <_>
+ <rect>
+ 0 20 3 3</rect></_>
+ <_>
+ <rect>
+ 0 22 2 3</rect></_>
+ <_>
+ <rect>
+ 0 28 4 4</rect></_>
+ <_>
+ <rect>
+ 0 35 2 3</rect></_>
+ <_>
+ <rect>
+ 1 0 14 7</rect></_>
+ <_>
+ <rect>
+ 1 5 3 2</rect></_>
+ <_>
+ <rect>
+ 1 6 2 1</rect></_>
+ <_>
+ <rect>
+ 1 14 10 9</rect></_>
+ <_>
+ <rect>
+ 1 21 4 4</rect></_>
+ <_>
+ <rect>
+ 1 23 4 2</rect></_>
+ <_>
+ <rect>
+ 2 0 13 7</rect></_>
+ <_>
+ <rect>
+ 2 0 14 7</rect></_>
+ <_>
+ <rect>
+ 2 33 5 4</rect></_>
+ <_>
+ <rect>
+ 2 36 4 3</rect></_>
+ <_>
+ <rect>
+ 2 39 3 2</rect></_>
+ <_>
+ <rect>
+ 3 1 13 11</rect></_>
+ <_>
+ <rect>
+ 3 2 3 2</rect></_>
+ <_>
+ <rect>
+ 4 0 7 8</rect></_>
+ <_>
+ <rect>
+ 4 0 13 7</rect></_>
+ <_>
+ <rect>
+ 5 0 12 6</rect></_>
+ <_>
+ <rect>
+ 5 0 13 7</rect></_>
+ <_>
+ <rect>
+ 5 1 10 13</rect></_>
+ <_>
+ <rect>
+ 5 1 12 7</rect></_>
+ <_>
+ <rect>
+ 5 2 7 13</rect></_>
+ <_>
+ <rect>
+ 5 4 2 1</rect></_>
+ <_>
+ <rect>
+ 5 8 7 4</rect></_>
+ <_>
+ <rect>
+ 5 39 3 2</rect></_>
+ <_>
+ <rect>
+ 6 3 5 2</rect></_>
+ <_>
+ <rect>
+ 6 3 6 2</rect></_>
+ <_>
+ <rect>
+ 6 5 4 12</rect></_>
+ <_>
+ <rect>
+ 6 9 6 3</rect></_>
+ <_>
+ <rect>
+ 7 3 5 2</rect></_>
+ <_>
+ <rect>
+ 7 3 6 13</rect></_>
+ <_>
+ <rect>
+ 7 5 6 4</rect></_>
+ <_>
+ <rect>
+ 7 7 6 10</rect></_>
+ <_>
+ <rect>
+ 7 8 6 4</rect></_>
+ <_>
+ <rect>
+ 7 32 5 4</rect></_>
+ <_>
+ <rect>
+ 7 33 5 4</rect></_>
+ <_>
+ <rect>
+ 8 0 1 1</rect></_>
+ <_>
+ <rect>
+ 8 0 2 1</rect></_>
+ <_>
+ <rect>
+ 8 2 10 7</rect></_>
+ <_>
+ <rect>
+ 9 0 6 2</rect></_>
+ <_>
+ <rect>
+ 9 2 9 3</rect></_>
+ <_>
+ <rect>
+ 9 4 1 1</rect></_>
+ <_>
+ <rect>
+ 9 6 2 1</rect></_>
+ <_>
+ <rect>
+ 9 28 6 4</rect></_>
+ <_>
+ <rect>
+ 10 0 9 3</rect></_>
+ <_>
+ <rect>
+ 10 3 1 1</rect></_>
+ <_>
+ <rect>
+ 10 10 11 11</rect></_>
+ <_>
+ <rect>
+ 10 15 4 3</rect></_>
+ <_>
+ <rect>
+ 11 4 2 1</rect></_>
+ <_>
+ <rect>
+ 11 27 4 3</rect></_>
+ <_>
+ <rect>
+ 11 36 8 2</rect></_>
+ <_>
+ <rect>
+ 12 0 2 2</rect></_>
+ <_>
+ <rect>
+ 12 23 4 3</rect></_>
+ <_>
+ <rect>
+ 12 25 4 3</rect></_>
+ <_>
+ <rect>
+ 12 29 5 3</rect></_>
+ <_>
+ <rect>
+ 12 33 3 4</rect></_>
+ <_>
+ <rect>
+ 13 0 2 2</rect></_>
+ <_>
+ <rect>
+ 13 36 8 3</rect></_>
+ <_>
+ <rect>
+ 14 0 2 2</rect></_>
+ <_>
+ <rect>
+ 15 15 2 2</rect></_>
+ <_>
+ <rect>
+ 16 13 3 4</rect></_>
+ <_>
+ <rect>
+ 17 0 1 3</rect></_>
+ <_>
+ <rect>
+ 17 1 3 3</rect></_>
+ <_>
+ <rect>
+ 17 31 5 3</rect></_>
+ <_>
+ <rect>
+ 17 35 3 1</rect></_>
+ <_>
+ <rect>
+ 18 13 2 3</rect></_>
+ <_>
+ <rect>
+ 18 39 2 1</rect></_>
+ <_>
+ <rect>
+ 19 0 7 15</rect></_>
+ <_>
+ <rect>
+ 19 2 7 2</rect></_>
+ <_>
+ <rect>
+ 19 3 7 13</rect></_>
+ <_>
+ <rect>
+ 19 14 2 2</rect></_>
+ <_>
+ <rect>
+ 19 24 7 4</rect></_>
+ <_>
+ <rect>
+ 20 1 6 13</rect></_>
+ <_>
+ <rect>
+ 20 8 7 3</rect></_>
+ <_>
+ <rect>
+ 20 9 7 3</rect></_>
+ <_>
+ <rect>
+ 20 13 1 1</rect></_>
+ <_>
+ <rect>
+ 20 14 2 3</rect></_>
+ <_>
+ <rect>
+ 20 30 3 2</rect></_>
+ <_>
+ <rect>
+ 21 0 3 4</rect></_>
+ <_>
+ <rect>
+ 21 0 6 8</rect></_>
+ <_>
+ <rect>
+ 21 3 6 2</rect></_>
+ <_>
+ <rect>
+ 21 6 6 4</rect></_>
+ <_>
+ <rect>
+ 21 37 2 1</rect></_>
+ <_>
+ <rect>
+ 22 3 6 2</rect></_>
+ <_>
+ <rect>
+ 22 13 1 2</rect></_>
+ <_>
+ <rect>
+ 22 22 4 3</rect></_>
+ <_>
+ <rect>
+ 23 0 2 3</rect></_>
+ <_>
+ <rect>
+ 23 3 6 2</rect></_>
+ <_>
+ <rect>
+ 23 9 5 4</rect></_>
+ <_>
+ <rect>
+ 23 11 1 1</rect></_>
+ <_>
+ <rect>
+ 23 15 1 1</rect></_>
+ <_>
+ <rect>
+ 23 16 3 2</rect></_>
+ <_>
+ <rect>
+ 23 35 2 1</rect></_>
+ <_>
+ <rect>
+ 23 36 1 1</rect></_>
+ <_>
+ <rect>
+ 23 39 6 2</rect></_>
+ <_>
+ <rect>
+ 24 0 2 3</rect></_>
+ <_>
+ <rect>
+ 24 8 6 11</rect></_>
+ <_>
+ <rect>
+ 24 28 2 2</rect></_>
+ <_>
+ <rect>
+ 24 33 4 4</rect></_>
+ <_>
+ <rect>
+ 25 16 4 3</rect></_>
+ <_>
+ <rect>
+ 25 31 5 3</rect></_>
+ <_>
+ <rect>
+ 26 0 1 2</rect></_>
+ <_>
+ <rect>
+ 26 0 2 2</rect></_>
+ <_>
+ <rect>
+ 26 0 3 2</rect></_>
+ <_>
+ <rect>
+ 26 24 4 4</rect></_>
+ <_>
+ <rect>
+ 27 30 4 5</rect></_>
+ <_>
+ <rect>
+ 27 36 5 3</rect></_>
+ <_>
+ <rect>
+ 28 0 2 2</rect></_>
+ <_>
+ <rect>
+ 28 4 2 1</rect></_>
+ <_>
+ <rect>
+ 28 21 2 5</rect></_>
+ <_>
+ <rect>
+ 29 8 2 1</rect></_>
+ <_>
+ <rect>
+ 33 0 2 1</rect></_>
+ <_>
+ <rect>
+ 33 0 4 2</rect></_>
+ <_>
+ <rect>
+ 33 0 4 6</rect></_>
+ <_>
+ <rect>
+ 33 3 1 1</rect></_>
+ <_>
+ <rect>
+ 33 6 4 12</rect></_>
+ <_>
+ <rect>
+ 33 21 4 2</rect></_>
+ <_>
+ <rect>
+ 33 36 4 3</rect></_>
+ <_>
+ <rect>
+ 35 1 2 2</rect></_>
+ <_>
+ <rect>
+ 36 5 1 1</rect></_>
+ <_>
+ <rect>
+ 36 29 3 4</rect></_>
+ <_>
+ <rect>
+ 36 39 2 2</rect></_>
+ <_>
+ <rect>
+ 37 5 2 2</rect></_>
+ <_>
+ <rect>
+ 38 6 2 1</rect></_>
+ <_>
+ <rect>
+ 38 6 2 2</rect></_>
+ <_>
+ <rect>
+ 39 1 2 12</rect></_>
+ <_>
+ <rect>
+ 39 24 1 2</rect></_>
+ <_>
+ <rect>
+ 39 36 2 2</rect></_>
+ <_>
+ <rect>
+ 40 39 1 2</rect></_>
+ <_>
+ <rect>
+ 42 4 1 1</rect></_>
+ <_>
+ <rect>
+ 42 20 1 2</rect></_>
+ <_>
+ <rect>
+ 42 29 1 2</rect></_></features></cascade>
+</opencv_storage>
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index f956cde..4243409 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -24,7 +24,7 @@ if(HAVE_DOC_GENERATOR)
endforeach()
ocv_list_sort(BASE_MODULES)
ocv_list_sort(EXTRA_MODULES)
- set(FIXED_ORDER_MODULES core imgproc imgcodecs videoio highgui video calib3d features2d objdetect ml flann photo stitching)
+ set(FIXED_ORDER_MODULES core imgproc imgcodecs videoio highgui video calib3d features2d objdetect dnn ml flann photo stitching)
list(REMOVE_ITEM BASE_MODULES ${FIXED_ORDER_MODULES})
set(BASE_MODULES ${FIXED_ORDER_MODULES} ${BASE_MODULES})
endif(HAVE_DOC_GENERATOR)
diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in
index 2e4ac70..dd8d325 100644
--- a/doc/Doxyfile.in
+++ b/doc/Doxyfile.in
@@ -41,7 +41,7 @@ ALIASES += next_tutorial{1}="**Next Tutorial:** \ref \1 \n"
ALIASES += youtube{1}="@htmlonly[block]<div align='center'><iframe title='my title' width='560' height='349' src='http://www.youtube.com/embed/\1?rel=0' frameborder='0' align='middle' allowfullscreen></iframe></div>@endhtmlonly"
TCL_SUBST =
OPTIMIZE_OUTPUT_FOR_C = NO
-OPTIMIZE_OUTPUT_JAVA = YES
+OPTIMIZE_OUTPUT_JAVA = NO
OPTIMIZE_FOR_FORTRAN = NO
OPTIMIZE_OUTPUT_VHDL = NO
EXTENSION_MAPPING =
@@ -106,7 +106,7 @@ FILE_PATTERNS =
RECURSIVE = YES
EXCLUDE =
EXCLUDE_SYMLINKS = NO
-EXCLUDE_PATTERNS = *.inl.hpp *.impl.hpp *_detail.hpp */cudev/**/detail/*.hpp
+EXCLUDE_PATTERNS = *.inl.hpp *.impl.hpp *_detail.hpp */cudev/**/detail/*.hpp *.m
EXCLUDE_SYMBOLS = cv::DataType<*> int void
EXAMPLE_PATH = @CMAKE_DOXYGEN_EXAMPLE_PATH@
EXAMPLE_PATTERNS = *
@@ -174,7 +174,7 @@ FORMULA_FONTSIZE = 14
FORMULA_TRANSPARENT = YES
USE_MATHJAX = YES
MATHJAX_FORMAT = HTML-CSS
-MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
+MATHJAX_RELPATH = http://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0
MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols
MATHJAX_CODEFILE = @CMAKE_CURRENT_SOURCE_DIR@/mymath.js
SEARCHENGINE = YES
@@ -251,7 +251,7 @@ PREDEFINED = __cplusplus=1 \
CV_DEFAULT(x)=" = x" \
CV_NEON=1 \
CV_SSE2=1 \
- FLANN_DEPRECATED=
+ CV_DEPRECATED=
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
TAGFILES =
diff --git a/doc/DoxygenLayout.xml b/doc/DoxygenLayout.xml
index 149f36f..b267571 100644
--- a/doc/DoxygenLayout.xml
+++ b/doc/DoxygenLayout.xml
@@ -17,7 +17,6 @@
<tab type="globals" visible="yes" title="Global objects" intro=""/>
</tab>
<tab type="examples" visible="yes" title="" intro=""/>
- <tab type="user" url="/3.0-last-rst" title="Sphinx Documentation"/>
</navindex>
<!-- Layout definition for a class page -->
diff --git a/doc/footer.html b/doc/footer.html
index c636144..a0b4d5c 100644
--- a/doc/footer.html
+++ b/doc/footer.html
@@ -67,7 +67,7 @@ $("h2").each(function() {
$smallerHeadings = $(this).nextUntil("h2").filter("h3").add($(this).nextUntil("h2").find("h3"));
if ($smallerHeadings.length) {
$smallerHeadings.each(function() {
- var $elements = $(this).nextUntil("h3").filter("div.newInnerHTML");
+ var $elements = $(this).nextUntil("h2,h3").filter("div.newInnerHTML");
buttonsToAdd($elements, $(this), "h3");
});
} else {
diff --git a/doc/opencv.bib b/doc/opencv.bib
index 29a2ae4..f4bb251 100644
--- a/doc/opencv.bib
+++ b/doc/opencv.bib
@@ -897,3 +897,10 @@
year={2010},
publisher={Springer}
}
+ at INPROCEEDINGS{Ke17,
+ author = {Ke, Tong and Roumeliotis, Stergios},
+ title = {An Efficient Algebraic Solution to the Perspective-Three-Point Problem},
+ booktitle = {Computer Vision and Pattern Recognition (CVPR), 2017 IEEE Conference on},
+ year = {2017},
+ organization = {IEEE}
+}
diff --git a/doc/pattern_tools/gen_pattern.py b/doc/pattern_tools/gen_pattern.py
index 85b3ea4..a846a03 100755
--- a/doc/pattern_tools/gen_pattern.py
+++ b/doc/pattern_tools/gen_pattern.py
@@ -38,7 +38,7 @@ class PatternMaker:
r = spacing / self.radius_rate
for x in range(1,self.cols+1):
for y in range(1,self.rows+1):
- dot = SVG("circle", cx=x * spacing, cy=y * spacing, r=r, fill="black")
+ dot = SVG("circle", cx=x * spacing, cy=y * spacing, r=r, fill="black", stroke="none")
self.g.append(dot)
def makeACirclesPattern(self):
@@ -46,7 +46,7 @@ class PatternMaker:
r = spacing / self.radius_rate
for i in range(0,self.rows):
for j in range(0,self.cols):
- dot = SVG("circle", cx= ((j*2 + i%2)*spacing) + spacing, cy=self.height - (i * spacing + spacing), r=r, fill="black")
+ dot = SVG("circle", cx= ((j*2 + i%2)*spacing) + spacing, cy=self.height - (i * spacing + spacing), r=r, fill="black", stroke="none")
self.g.append(dot)
def makeCheckerboardPattern(self):
@@ -56,7 +56,7 @@ class PatternMaker:
for x in range(0,self.cols):
for y in range(0,self.rows):
if x%2 == y%2:
- square = SVG("rect", x=x * spacing + xspacing, y=y * spacing + yspacing, width=spacing, height=spacing, fill="black")
+ square = SVG("rect", x=x * spacing + xspacing, y=y * spacing + yspacing, width=spacing, height=spacing, fill="black", stroke="none")
self.g.append(square)
def save(self):
@@ -70,9 +70,9 @@ def main():
opts, args = getopt.getopt(sys.argv[1:], "Ho:c:r:T:u:s:R:w:h:a:", ["help","output=","columns=","rows=",
"type=","units=","square_size=","radius_rate=",
"page_width=","page_height=", "page_size="])
- except getopt.error, msg:
- print msg
- print "for help use --help"
+ except getopt.error as msg:
+ print(msg)
+ print("for help use --help")
sys.exit(2)
output = "out.svg"
columns = 8
@@ -89,7 +89,7 @@ def main():
# process options
for o, a in opts:
if o in ("-H", "--help"):
- print __doc__
+ print(__doc__)
sys.exit(0)
elif o in ("-r", "--rows"):
rows = int(a)
diff --git a/doc/pattern_tools/svgfig.py b/doc/pattern_tools/svgfig.py
index c690c9f..5e1b1df 100755
--- a/doc/pattern_tools/svgfig.py
+++ b/doc/pattern_tools/svgfig.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# svgfig.py copyright (C) 2008 Jim Pivarski <jpivarski at gmail.com>
#
# This program is free software; you can redistribute it and/or
@@ -21,6 +19,15 @@
import re, codecs, os, platform, copy, itertools, math, cmath, random, sys, copy
_epsilon = 1e-5
+if sys.version_info >= (3,0):
+ long = int
+ basestring = (str,bytes)
+
+# Fix Python 2.x.
+try:
+ UNICODE_EXISTS = bool(type(unicode))
+except NameError:
+ unicode = lambda s: str(s)
if re.search("windows", platform.system(), re.I):
try:
@@ -49,20 +56,21 @@ def rgb(r, g, b, maximum=1.):
max(0, min(b*255./maximum, 255)))
def attr_preprocess(attr):
+ attrCopy = attr.copy()
for name in attr.keys():
name_colon = re.sub("__", ":", name)
if name_colon != name:
- attr[name_colon] = attr[name]
- del attr[name]
+ attrCopy[name_colon] = attrCopy[name]
+ del attrCopy[name]
name = name_colon
name_dash = re.sub("_", "-", name)
if name_dash != name:
- attr[name_dash] = attr[name]
- del attr[name]
+ attrCopy[name_dash] = attrCopy[name]
+ del attrCopy[name]
name = name_dash
- return attr
+ return attrCopy
class SVG:
@@ -128,7 +136,7 @@ class SVG:
"""
def __init__(self, *t_sub, **attr):
if len(t_sub) == 0:
- raise TypeError, "SVG element must have a t (SVG type)"
+ raise TypeError( "SVG element must have a t (SVG type)")
# first argument is t (SVG type)
self.t = t_sub[0]
@@ -262,7 +270,7 @@ class SVG:
Returns a breadth-first generator over the SVG. If depth_limit
is a number, stop recursion at that depth."""
- raise NotImplementedError, "Got an algorithm for breadth-first searching a tree without effectively copying the tree?"
+ raise NotImplementedError( "Got an algorithm for breadth-first searching a tree without effectively copying the tree?")
def __iter__(self):
return self.depth_first()
@@ -558,7 +566,7 @@ def canvas_outline(*sub, **attr):
svg = canvas(*sub, **attr)
match = re.match(r"[, \t]*([0-9e.+\-]+)[, \t]+([0-9e.+\-]+)[, \t]+([0-9e.+\-]+)[, \t]+([0-9e.+\-]+)[, \t]*", svg["viewBox"])
if match is None:
- raise ValueError, "canvas viewBox is incorrectly formatted"
+ raise ValueError( "canvas viewBox is incorrectly formatted")
x, y, width, height = [float(x) for x in match.groups()]
svg.prepend(SVG("rect", x=x, y=y, width=width, height=height, stroke="none", fill="cornsilk"))
svg.append(SVG("rect", x=x, y=y, width=width, height=height, stroke="black", fill="none"))
@@ -675,7 +683,7 @@ def totrans(expr, vars=("x", "y"), globals=None, locals=None):
return output
else:
- raise TypeError, "must be a function of 2 or 1 variables"
+ raise TypeError( "must be a function of 2 or 1 variables")
if len(vars) == 2:
g = math.__dict__
@@ -696,7 +704,7 @@ def totrans(expr, vars=("x", "y"), globals=None, locals=None):
return output2
else:
- raise TypeError, "vars must have 2 or 1 elements"
+ raise TypeError( "vars must have 2 or 1 elements")
def window(xmin, xmax, ymin, ymax, x=0, y=0, width=100, height=100,
@@ -735,10 +743,10 @@ def window(xmin, xmax, ymin, ymax, x=0, y=0, width=100, height=100,
iy2 = ymax
if xlogbase is not None and (ix1 <= 0. or ix2 <= 0.):
- raise ValueError, "x range incompatible with log scaling: (%g, %g)" % (ix1, ix2)
+ raise ValueError ("x range incompatible with log scaling: (%g, %g)" % (ix1, ix2))
if ylogbase is not None and (iy1 <= 0. or iy2 <= 0.):
- raise ValueError, "y range incompatible with log scaling: (%g, %g)" % (iy1, iy2)
+ raise ValueError ("y range incompatible with log scaling: (%g, %g)" % (iy1, iy2))
def maybelog(t, it1, it2, ot1, ot2, logbase):
if t <= 0.:
@@ -813,7 +821,7 @@ class Fig:
self.trans = kwds["trans"]; del kwds["trans"]
if len(kwds) != 0:
- raise TypeError, "Fig() got unexpected keyword arguments %s" % kwds.keys()
+ raise TypeError ("Fig() got unexpected keyword arguments %s" % kwds.keys())
def SVG(self, trans=None):
"""Apply the transformation "trans" and return an SVG object.
@@ -931,7 +939,7 @@ class Plot:
self.text_attr = kwds["text_attr"]; del kwds["text_attr"]
self.axis_attr = kwds["axis_attr"]; del kwds["axis_attr"]
if len(kwds) != 0:
- raise TypeError, "Plot() got unexpected keyword arguments %s" % kwds.keys()
+ raise TypeError ("Plot() got unexpected keyword arguments %s" % kwds.keys())
def SVG(self, trans=None):
"""Apply the transformation "trans" and return an SVG object."""
@@ -1039,7 +1047,7 @@ class Frame:
self.axis_attr.update(kwds["axis_attr"]); del kwds["axis_attr"]
if len(kwds) != 0:
- raise TypeError, "Frame() got unexpected keyword arguments %s" % kwds.keys()
+ raise TypeError( "Frame() got unexpected keyword arguments %s" % kwds.keys())
def SVG(self):
"""Apply the window transformation and return an SVG object."""
@@ -1101,7 +1109,7 @@ class Frame:
def pathtoPath(svg):
"""Converts SVG("path", d="...") into Path(d=[...])."""
if not isinstance(svg, SVG) or svg.t != "path":
- raise TypeError, "Only SVG <path /> objects can be converted into Paths"
+ raise TypeError ("Only SVG <path /> objects can be converted into Paths")
attr = dict(svg.attr)
d = attr["d"]
del attr["d"]
@@ -1235,7 +1243,7 @@ class Path:
errstring = "Path command \"%s\" requires a number at index %d" % (command, index)
num1, index, pathdata = self.parse_number(index, pathdata)
if num1 is None:
- raise ValueError, errstring
+ raise ValueError ( errstring)
while num1 is not None:
output.append((command, num1))
@@ -1248,11 +1256,11 @@ class Path:
num2, index, pathdata = self.parse_number(index, pathdata)
if num1 is None:
- raise ValueError, errstring
+ raise ValueError ( errstring)
while num1 is not None:
if num2 is None:
- raise ValueError, errstring
+ raise ValueError ( errstring)
output.append((command, num1, num2, False))
num1, index, pathdata = self.parse_number(index, pathdata)
@@ -1267,11 +1275,11 @@ class Path:
num4, index, pathdata = self.parse_number(index, pathdata)
if num1 is None:
- raise ValueError, errstring
+ raise ValueError ( errstring )
while num1 is not None:
if num2 is None or num3 is None or num4 is None:
- raise ValueError, errstring
+ raise ValueError (errstring)
output.append((command, num1, num2, False, num3, num4, False))
num1, index, pathdata = self.parse_number(index, pathdata)
@@ -1290,11 +1298,11 @@ class Path:
num6, index, pathdata = self.parse_number(index, pathdata)
if num1 is None:
- raise ValueError, errstring
+ raise ValueError(errstring)
while num1 is not None:
if num2 is None or num3 is None or num4 is None or num5 is None or num6 is None:
- raise ValueError, errstring
+ raise ValueError(errstring)
output.append((command, num1, num2, False, num3, num4, False, num5, num6, False))
@@ -1317,11 +1325,11 @@ class Path:
num7, index, pathdata = self.parse_number(index, pathdata)
if num1 is None:
- raise ValueError, errstring
+ raise ValueError(errstring)
while num1 is not None:
if num2 is None or num3 is None or num4 is None or num5 is None or num6 is None or num7 is None:
- raise ValueError, errstring
+ raise ValueError(errstring)
output.append((command, num1, num2, False, num3, num4, num5, num6, num7, False))
@@ -1344,7 +1352,7 @@ class Path:
output = []
for datum in self.d:
if not isinstance(datum, (tuple, list)):
- raise TypeError, "pathdata elements must be tuples/lists"
+ raise TypeError("pathdata elements must be tuples/lists")
command = datum[0]
@@ -1722,7 +1730,7 @@ class Curve:
try:
# the best way to keep all the information while sampling is to make a linked list
if not (self.low < self.high):
- raise ValueError, "low must be less than high"
+ raise ValueError("low must be less than high")
low, high = self.Sample(float(self.low)), self.Sample(float(self.high))
low.link(None, high)
high.link(low, None)
@@ -1913,10 +1921,10 @@ class Poly:
vx[i], vy[i] = 0., 0.
else:
- raise ValueError, "mode must be \"lines\", \"bezier\", \"velocity\", \"foreback\", \"smooth\", or an abbreviation"
+ raise ValueError("mode must be \"lines\", \"bezier\", \"velocity\", \"foreback\", \"smooth\", or an abbreviation")
d = []
- indexes = range(len(self.d))
+ indexes = list(range(len(self.d)))
if self.loop and len(self.d) > 0:
indexes.append(0)
@@ -2220,7 +2228,7 @@ class Line(Curve):
defs.append(make_marker(self.arrow_start, "arrow_start"))
line.attr["marker-start"] = "url(#%s)" % self.arrow_start
else:
- raise TypeError, "arrow_start must be False/None or an id string for the new marker"
+ raise TypeError("arrow_start must be False/None or an id string for the new marker")
if self.arrow_end != False and self.arrow_end is not None:
if isinstance(self.arrow_end, SVG):
@@ -2230,7 +2238,7 @@ class Line(Curve):
defs.append(make_marker(self.arrow_end, "arrow_end"))
line.attr["marker-end"] = "url(#%s)" % self.arrow_end
else:
- raise TypeError, "arrow_end must be False/None or an id string for the new marker"
+ raise TypeError("arrow_end must be False/None or an id string for the new marker")
return SVG("g", defs, line)
@@ -2316,7 +2324,7 @@ class LineGlobal:
defs.append(make_marker(self.arrow_start, "arrow_start"))
line.attr["marker-start"] = "url(#%s)" % self.arrow_start
else:
- raise TypeError, "arrow_start must be False/None or an id string for the new marker"
+ raise TypeError("arrow_start must be False/None or an id string for the new marker")
if self.arrow_end != False and self.arrow_end is not None:
if isinstance(self.arrow_end, SVG):
@@ -2326,7 +2334,7 @@ class LineGlobal:
defs.append(make_marker(self.arrow_end, "arrow_end"))
line.attr["marker-end"] = "url(#%s)" % self.arrow_end
else:
- raise TypeError, "arrow_end must be False/None or an id string for the new marker"
+ raise TypeError("arrow_end must be False/None or an id string for the new marker")
return SVG("g", defs, line)
@@ -2681,7 +2689,7 @@ class Ticks:
elif isinstance(self.arrow_start, basestring):
defs.append(make_marker(self.arrow_start, "arrow_start"))
else:
- raise TypeError, "arrow_start must be False/None or an id string for the new marker"
+ raise TypeError("arrow_start must be False/None or an id string for the new marker")
if self.arrow_end != False and self.arrow_end is not None:
if isinstance(self.arrow_end, SVG):
@@ -2689,7 +2697,7 @@ class Ticks:
elif isinstance(self.arrow_end, basestring):
defs.append(make_marker(self.arrow_end, "arrow_end"))
else:
- raise TypeError, "arrow_end must be False/None or an id string for the new marker"
+ raise TypeError("arrow_end must be False/None or an id string for the new marker")
output.append(defs)
@@ -2757,7 +2765,7 @@ class Ticks:
format = self.labels
else:
- raise TypeError, "labels must be None/False, True, a format string, or a number->string function"
+ raise TypeError("labels must be None/False, True, a format string, or a number->string function")
# Now for the ticks
ticks = self.ticks
@@ -2793,7 +2801,7 @@ class Ticks:
return ticks, []
else:
- raise TypeError, "miniticks must be None/False, True, a number of desired miniticks, or a list of numbers"
+ raise TypeError("miniticks must be None/False, True, a number of desired miniticks, or a list of numbers")
# Cases 3 & 4: ticks is iterable
elif getattr(ticks, "__iter__", False):
@@ -2830,10 +2838,10 @@ class Ticks:
return ticks, []
else:
- raise TypeError, "miniticks must be None/False, True, a number of desired miniticks, or a list of numbers"
+ raise TypeError("miniticks must be None/False, True, a number of desired miniticks, or a list of numbers")
else:
- raise TypeError, "ticks must be None/False, a number of desired ticks, a list of numbers, or a dictionary of explicit markers"
+ raise TypeError("ticks must be None/False, a number of desired ticks, a list of numbers, or a dictionary of explicit markers")
def compute_ticks(self, N, format):
"""Return less than -N or exactly N optimal linear ticks.
@@ -2841,9 +2849,9 @@ class Ticks:
Normally only used internally.
"""
if self.low >= self.high:
- raise ValueError, "low must be less than high"
+ raise ValueError("low must be less than high")
if N == 1:
- raise ValueError, "N can be 0 or >1 to specify the exact number of ticks or negative to specify a maximum"
+ raise ValueError("N can be 0 or >1 to specify the exact number of ticks or negative to specify a maximum")
eps = _epsilon * (self.high - self.low)
@@ -2948,7 +2956,7 @@ class Ticks:
original_ticks.sort()
if self.low > original_ticks[0] + _epsilon or self.high < original_ticks[-1] - _epsilon:
- raise ValueError, "original_ticks {%g...%g} extend beyond [%g, %g]" % (original_ticks[0], original_ticks[-1], self.low, self.high)
+ raise ValueError("original_ticks {%g...%g} extend beyond [%g, %g]" % (original_ticks[0], original_ticks[-1], self.low, self.high))
granularities = []
for i in range(len(original_ticks)-1):
@@ -2975,9 +2983,9 @@ class Ticks:
Normally only used internally.
"""
if self.low >= self.high:
- raise ValueError, "low must be less than high"
+ raise ValueError("low must be less than high")
if N == 1:
- raise ValueError, "N can be 0 or >1 to specify the exact number of ticks or negative to specify a maximum"
+ raise ValueError("N can be 0 or >1 to specify the exact number of ticks or negative to specify a maximum")
eps = _epsilon * (self.high - self.low)
@@ -3032,7 +3040,7 @@ class Ticks:
Normally only used internally.
"""
if self.low >= self.high:
- raise ValueError, "low must be less than high"
+ raise ValueError("low must be less than high")
lowN = math.floor(math.log(self.low, base))
highN = math.ceil(math.log(self.high, base))
@@ -3166,7 +3174,7 @@ class LineAxis(Line, Ticks):
def interpret(self):
if self.exclude is not None and not (isinstance(self.exclude, (tuple, list)) and len(self.exclude) == 2 and
isinstance(self.exclude[0], (int, long, float)) and isinstance(self.exclude[1], (int, long, float))):
- raise TypeError, "exclude must either be None or (low, high)"
+ raise TypeError("exclude must either be None or (low, high)")
ticks, miniticks = Ticks.interpret(self)
if self.exclude is None:
diff --git a/doc/py_tutorials/py_calib3d/py_calibration/py_calibration.markdown b/doc/py_tutorials/py_calib3d/py_calibration/py_calibration.markdown
index 1e22ced..3e7a401 100644
--- a/doc/py_tutorials/py_calib3d/py_calibration/py_calibration.markdown
+++ b/doc/py_tutorials/py_calib3d/py_calibration/py_calibration.markdown
@@ -218,7 +218,7 @@ for i in xrange(len(objpoints)):
error = cv2.norm(imgpoints[i], imgpoints2, cv2.NORM_L2)/len(imgpoints2)
mean_error += error
-print "total error: ", mean_error/len(objpoints)
+print( "total error: {}".format(mean_error/len(objpoints)) )
@endcode
Additional Resources
--------------------
diff --git a/doc/py_tutorials/py_calib3d/py_epipolar_geometry/py_epipolar_geometry.markdown b/doc/py_tutorials/py_calib3d/py_epipolar_geometry/py_epipolar_geometry.markdown
index 0b63515..432773d 100644
--- a/doc/py_tutorials/py_calib3d/py_epipolar_geometry/py_epipolar_geometry.markdown
+++ b/doc/py_tutorials/py_calib3d/py_epipolar_geometry/py_epipolar_geometry.markdown
@@ -86,7 +86,7 @@ kp1, des1 = sift.detectAndCompute(img1,None)
kp2, des2 = sift.detectAndCompute(img2,None)
# FLANN parameters
-FLANN_INDEX_KDTREE = 0
+FLANN_INDEX_KDTREE = 1
index_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5)
search_params = dict(checks=50)
diff --git a/doc/py_tutorials/py_core/py_basic_ops/py_basic_ops.markdown b/doc/py_tutorials/py_core/py_basic_ops/py_basic_ops.markdown
index 19992fc..1305d8a 100644
--- a/doc/py_tutorials/py_core/py_basic_ops/py_basic_ops.markdown
+++ b/doc/py_tutorials/py_core/py_basic_ops/py_basic_ops.markdown
@@ -8,7 +8,7 @@ Learn to:
- Access pixel values and modify them
- Access image properties
-- Setting Region of Image (ROI)
+- Setting Region of Interest (ROI)
- Splitting and Merging images
Almost all the operations in this section is mainly related to Numpy rather than OpenCV. A good
@@ -30,18 +30,18 @@ You can access a pixel value by its row and column coordinates. For BGR image, i
of Blue, Green, Red values. For grayscale image, just corresponding intensity is returned.
@code{.py}
>>> px = img[100,100]
->>> print px
+>>> print( px )
[157 166 200]
# accessing only blue pixel
>>> blue = img[100,100,0]
->>> print blue
+>>> print( blue )
157
@endcode
You can modify the pixel values the same way.
@code{.py}
>>> img[100,100] = [255,255,255]
->>> print img[100,100]
+>>> print( img[100,100] )
[255 255 255]
@endcode
@@ -76,7 +76,7 @@ etc.
Shape of image is accessed by img.shape. It returns a tuple of number of rows, columns and channels
(if image is color):
@code{.py}
->>> print img.shape
+>>> print( img.shape )
(342, 548, 3)
@endcode
@@ -85,12 +85,12 @@ good method to check if loaded image is grayscale or color image.
Total number of pixels is accessed by `img.size`:
@code{.py}
->>> print img.size
+>>> print( img.size )
562248
@endcode
Image datatype is obtained by \`img.dtype\`:
@code{.py}
->>> print img.dtype
+>>> print( img.dtype )
uint8
@endcode
diff --git a/doc/py_tutorials/py_core/py_image_arithmetics/py_image_arithmetics.markdown b/doc/py_tutorials/py_core/py_image_arithmetics/py_image_arithmetics.markdown
index 8995c93..10bcd18 100644
--- a/doc/py_tutorials/py_core/py_image_arithmetics/py_image_arithmetics.markdown
+++ b/doc/py_tutorials/py_core/py_image_arithmetics/py_image_arithmetics.markdown
@@ -23,10 +23,10 @@ For example, consider below sample:
>>> x = np.uint8([250])
>>> y = np.uint8([10])
->>> print cv2.add(x,y) # 250+10 = 260 => 255
+>>> print( cv2.add(x,y) ) # 250+10 = 260 => 255
[[255]]
->>> print x+y # 250+10 = 260 % 256 = 4
+>>> print( x+y ) # 250+10 = 260 % 256 = 4
[4]
@endcode
It will be more visible when you add two images. OpenCV function will provide a better result. So
diff --git a/doc/py_tutorials/py_core/py_optimization/py_optimization.markdown b/doc/py_tutorials/py_core/py_optimization/py_optimization.markdown
index c0a0da4..2c3878b 100644
--- a/doc/py_tutorials/py_core/py_optimization/py_optimization.markdown
+++ b/doc/py_tutorials/py_core/py_optimization/py_optimization.markdown
@@ -44,7 +44,7 @@ for i in xrange(5,49,2):
img1 = cv2.medianBlur(img1,i)
e2 = cv2.getTickCount()
t = (e2 - e1)/cv2.getTickFrequency()
-print t
+print( t )
# Result I got is 0.521107655 seconds
@endcode
diff --git a/doc/py_tutorials/py_feature2d/py_brief/py_brief.markdown b/doc/py_tutorials/py_feature2d/py_brief/py_brief.markdown
index 57e284c..4daf09d 100644
--- a/doc/py_tutorials/py_feature2d/py_brief/py_brief.markdown
+++ b/doc/py_tutorials/py_feature2d/py_brief/py_brief.markdown
@@ -69,8 +69,8 @@ kp = star.detect(img,None)
# compute the descriptors with BRIEF
kp, des = brief.compute(img, kp)
-print brief.descriptorSize()
-print des.shape
+print( brief.descriptorSize() )
+print( des.shape )
@endcode
The function brief.getDescriptorSize() gives the \f$n_d\f$ size used in bytes. By default it is 32. Next one
is matching, which will be done in another chapter.
diff --git a/doc/py_tutorials/py_feature2d/py_fast/py_fast.markdown b/doc/py_tutorials/py_feature2d/py_fast/py_fast.markdown
index e30107e..590c1e3 100644
--- a/doc/py_tutorials/py_feature2d/py_fast/py_fast.markdown
+++ b/doc/py_tutorials/py_feature2d/py_fast/py_fast.markdown
@@ -108,10 +108,10 @@ kp = fast.detect(img,None)
img2 = cv2.drawKeypoints(img, kp, None, color=(255,0,0))
# Print all default params
-print "Threshold: ", fast.getThreshold()
-print "nonmaxSuppression: ", fast.getNonmaxSuppression()
-print "neighborhood: ", fast.getType()
-print "Total Keypoints with nonmaxSuppression: ", len(kp)
+print( "Threshold: {}".format(fast.getThreshold()) )
+print( "nonmaxSuppression:{}".format(fast.getNonmaxSuppression()) )
+print( "neighborhood: {}".format(fast.getType()) )
+print( "Total Keypoints with nonmaxSuppression: {}".format(len(kp)) )
cv2.imwrite('fast_true.png',img2)
@@ -119,7 +119,7 @@ cv2.imwrite('fast_true.png',img2)
fast.setNonmaxSuppression(0)
kp = fast.detect(img,None)
-print "Total Keypoints without nonmaxSuppression: ", len(kp)
+print( "Total Keypoints without nonmaxSuppression: {}".format(len(kp)) )
img3 = cv2.drawKeypoints(img, kp, None, color=(255,0,0))
diff --git a/doc/py_tutorials/py_feature2d/py_feature_homography/py_feature_homography.markdown b/doc/py_tutorials/py_feature2d/py_feature_homography/py_feature_homography.markdown
index 4f5efa4..20b2d2e 100644
--- a/doc/py_tutorials/py_feature2d/py_feature_homography/py_feature_homography.markdown
+++ b/doc/py_tutorials/py_feature2d/py_feature_homography/py_feature_homography.markdown
@@ -50,7 +50,7 @@ sift = cv2.xfeatures2d.SIFT_create()
kp1, des1 = sift.detectAndCompute(img1,None)
kp2, des2 = sift.detectAndCompute(img2,None)
-FLANN_INDEX_KDTREE = 0
+FLANN_INDEX_KDTREE = 1
index_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5)
search_params = dict(checks = 50)
@@ -85,7 +85,7 @@ if len(good)>MIN_MATCH_COUNT:
img2 = cv2.polylines(img2,[np.int32(dst)],True,255,3, cv2.LINE_AA)
else:
- print "Not enough matches are found - %d/%d" % (len(good),MIN_MATCH_COUNT)
+ print( "Not enough matches are found - {}/{}".format(len(good), MIN_MATCH_COUNT) )
matchesMask = None
@endcode
Finally we draw our inliers (if successfully found the object) or matching keypoints (if failed).
diff --git a/doc/py_tutorials/py_feature2d/py_features_meaning/py_features_meaning.markdown b/doc/py_tutorials/py_feature2d/py_features_meaning/py_features_meaning.markdown
index 166ffba..3aa00b7 100644
--- a/doc/py_tutorials/py_feature2d/py_features_meaning/py_features_meaning.markdown
+++ b/doc/py_tutorials/py_feature2d/py_features_meaning/py_features_meaning.markdown
@@ -10,7 +10,7 @@ corners are important etc.
Explanation
-----------
-Most of you will have played the jigsaw puzzle games. You get a lot of small pieces of a images,
+Most of you will have played the jigsaw puzzle games. You get a lot of small pieces of an image,
where you need to assemble them correctly to form a big real image. **The question is, how you do
it?** What about the projecting the same theory to a computer program so that computer can play
jigsaw puzzles? If the computer can play jigsaw puzzles, why can't we give a lot of real-life images
diff --git a/doc/py_tutorials/py_feature2d/py_matcher/py_matcher.markdown b/doc/py_tutorials/py_feature2d/py_matcher/py_matcher.markdown
index a37d579..a047154 100644
--- a/doc/py_tutorials/py_feature2d/py_matcher/py_matcher.markdown
+++ b/doc/py_tutorials/py_feature2d/py_matcher/py_matcher.markdown
@@ -148,11 +148,13 @@ its related parameters etc. First one is IndexParams. For various algorithms, th
passed is explained in FLANN docs. As a summary, for algorithms like SIFT, SURF etc. you can pass
following:
@code{.py}
+FLANN_INDEX_KDTREE = 1
index_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5)
@endcode
While using ORB, you can pass the following. The commented values are recommended as per the docs,
but it didn't provide required results in some cases. Other values worked fine.:
@code{.py}
+FLANN_INDEX_LSH = 6
index_params= dict(algorithm = FLANN_INDEX_LSH,
table_number = 6, # 12
key_size = 12, # 20
@@ -179,7 +181,7 @@ kp1, des1 = sift.detectAndCompute(img1,None)
kp2, des2 = sift.detectAndCompute(img2,None)
# FLANN parameters
-FLANN_INDEX_KDTREE = 0
+FLANN_INDEX_KDTREE = 1
index_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5)
search_params = dict(checks=50) # or pass empty dictionary
diff --git a/doc/py_tutorials/py_feature2d/py_surf_intro/py_surf_intro.markdown b/doc/py_tutorials/py_feature2d/py_surf_intro/py_surf_intro.markdown
index 7d5bd93..dab2add 100644
--- a/doc/py_tutorials/py_feature2d/py_surf_intro/py_surf_intro.markdown
+++ b/doc/py_tutorials/py_feature2d/py_surf_intro/py_surf_intro.markdown
@@ -92,7 +92,7 @@ examples are shown in Python terminal since it is just same as SIFT only.
While matching, we may need all those features, but not now. So we increase the Hessian Threshold.
@code{.py}
# Check present Hessian threshold
->>> print surf.getHessianThreshold()
+>>> print( surf.getHessianThreshold() )
400.0
# We set it to some 50000. Remember, it is just for representing in picture.
@@ -102,7 +102,7 @@ While matching, we may need all those features, but not now. So we increase the
# Again compute keypoints and check its number.
>>> kp, des = surf.detectAndCompute(img,None)
->>> print len(kp)
+>>> print( len(kp) )
47
@endcode
It is less than 50. Let's draw it on the image.
@@ -119,7 +119,7 @@ on wings of butterfly. You can test it with other images.
Now I want to apply U-SURF, so that it won't find the orientation.
@code{.py}
# Check upright flag, if it False, set it to True
->>> print surf.getUpright()
+>>> print( surf.getUpright() )
False
>>> surf.setUpright(True)
@@ -139,7 +139,7 @@ etc, this is better.
Finally we check the descriptor size and change it to 128 if it is only 64-dim.
@code{.py}
# Find size of descriptor
->>> print surf.descriptorSize()
+>>> print( surf.descriptorSize() )
64
# That means flag, "extended" is False.
@@ -149,9 +149,9 @@ Finally we check the descriptor size and change it to 128 if it is only 64-dim.
# So we make it to True to get 128-dim descriptors.
>>> surf.extended = True
>>> kp, des = surf.detectAndCompute(img,None)
->>> print surf.descriptorSize()
+>>> print( surf.descriptorSize() )
128
->>> print des.shape
+>>> print( des.shape )
(47, 128)
@endcode
Remaining part is matching which we will do in another chapter.
diff --git a/doc/py_tutorials/py_gui/py_image_display/py_image_display.markdown b/doc/py_tutorials/py_gui/py_image_display/py_image_display.markdown
index b032622..c286a3f 100644
--- a/doc/py_tutorials/py_gui/py_image_display/py_image_display.markdown
+++ b/doc/py_tutorials/py_gui/py_image_display/py_image_display.markdown
@@ -36,7 +36,7 @@ img = cv2.imread('messi5.jpg',0)
**warning**
-Even if the image path is wrong, it won't throw any error, but print img will give you None
+Even if the image path is wrong, it won't throw any error, but `print img` will give you `None`
### Display an image
@@ -109,8 +109,8 @@ elif k == ord('s'): # wait for 's' key to save and exit
**warning**
-If you are using a 64-bit machine, you will have to modify k = cv2.waitKey(0) line as follows :
-k = cv2.waitKey(0) & 0xFF
+If you are using a 64-bit machine, you will have to modify `k = cv2.waitKey(0)` line as follows :
+`k = cv2.waitKey(0) & 0xFF`
Using Matplotlib
----------------
diff --git a/doc/py_tutorials/py_gui/py_mouse_handling/py_mouse_handling.markdown b/doc/py_tutorials/py_gui/py_mouse_handling/py_mouse_handling.markdown
index 3862b49..53529c7 100644
--- a/doc/py_tutorials/py_gui/py_mouse_handling/py_mouse_handling.markdown
+++ b/doc/py_tutorials/py_gui/py_mouse_handling/py_mouse_handling.markdown
@@ -21,7 +21,7 @@ in Python terminal:
@code{.py}
import cv2
events = [i for i in dir(cv2) if 'EVENT' in i]
-print events
+print( events )
@endcode
Creating mouse callback function has a specific format which is same everywhere. It differs only in
what the function does. So our mouse callback function does one thing, it draws a circle where we
diff --git a/doc/py_tutorials/py_gui/py_video_display/py_video_display.markdown b/doc/py_tutorials/py_gui/py_video_display/py_video_display.markdown
index 7275488..a65f513 100644
--- a/doc/py_tutorials/py_gui/py_video_display/py_video_display.markdown
+++ b/doc/py_tutorials/py_gui/py_video_display/py_video_display.markdown
@@ -42,22 +42,22 @@ while(True):
cap.release()
cv2.destroyAllWindows()
@endcode
-cap.read() returns a bool (True/False). If frame is read correctly, it will be True. So you can
+`cap.read()` returns a bool (`True`/`False`). If frame is read correctly, it will be `True`. So you can
check end of the video by checking this return value.
Sometimes, cap may not have initialized the capture. In that case, this code shows error. You can
-check whether it is initialized or not by the method **cap.isOpened()**. If it is True, OK.
+check whether it is initialized or not by the method **cap.isOpened()**. If it is `True`, OK.
Otherwise open it using **cap.open()**.
You can also access some of the features of this video using **cap.get(propId)** method where propId
is a number from 0 to 18. Each number denotes a property of the video (if it is applicable to that
-video) and full details can be seen here: cv::VideoCapture::get() .
+video) and full details can be seen here: cv::VideoCapture::get().
Some of these values can be modified using **cap.set(propId, value)**. Value is the new value you
want.
-For example, I can check the frame width and height by cap.get(3) and cap.get(4). It gives me
-640x480 by default. But I want to modify it to 320x240. Just use ret = cap.set(3,320) and
-ret = cap.set(4,240).
+For example, I can check the frame width and height by `cap.get(cv2.CAP_PROP_FRAME_WIDTH)` and `cap.get(cv2.CAP_PROP_FRAME_HEIGHT)`. It gives me
+640x480 by default. But I want to modify it to 320x240. Just use `ret = cap.set(cv2.CAP_PROP_FRAME_WIDTH,320)` and
+`ret = cap.set(cv2.CAP_PROP_FRAME_HEIGHT,240)`.
@note If you are getting error, make sure camera is working fine using any other camera application
(like Cheese in Linux).
@@ -66,7 +66,7 @@ Playing Video from file
-----------------------
It is same as capturing from Camera, just change camera index with video file name. Also while
-displaying the frame, use appropriate time for cv2.waitKey(). If it is too less, video will be very
+displaying the frame, use appropriate time for `cv2.waitKey()`. If it is too less, video will be very
fast and if it is too high, video will be slow (Well, that is how you can display videos in slow
motion). 25 milliseconds will be OK in normal cases.
@code{.py}
@@ -95,12 +95,12 @@ Saving a Video
--------------
So we capture a video, process it frame-by-frame and we want to save that video. For images, it is
-very simple, just use cv2.imwrite(). Here a little more work is required.
+very simple, just use `cv2.imwrite()`. Here a little more work is required.
This time we create a **VideoWriter** object. We should specify the output file name (eg:
output.avi). Then we should specify the **FourCC** code (details in next paragraph). Then number of
frames per second (fps) and frame size should be passed. And last one is **isColor** flag. If it is
-True, encoder expect color frame, otherwise it works with grayscale frame.
+`True`, encoder expect color frame, otherwise it works with grayscale frame.
[FourCC](http://en.wikipedia.org/wiki/FourCC) is a 4-byte code used to specify the video codec. The
list of available codes can be found in [fourcc.org](http://www.fourcc.org/codecs.php). It is
@@ -109,10 +109,10 @@ platform dependent. Following codecs works fine for me.
- In Fedora: DIVX, XVID, MJPG, X264, WMV1, WMV2. (XVID is more preferable. MJPG results in high
size video. X264 gives very small size video)
- In Windows: DIVX (More to be tested and added)
-- In OSX : *(I don't have access to OSX. Can some one fill this?)*
+- In OSX: MJPG (.mp4), DIVX (.avi), X264 (.mkv).
-FourCC code is passed as cv2.VideoWriter_fourcc('M','J','P','G') or
-cv2.VideoWriter_fourcc(\*'MJPG') for MJPG.
+FourCC code is passed as `cv2.VideoWriter_fourcc('M','J','P','G')` or
+`cv2.VideoWriter_fourcc(*'MJPG')` for MJPG.
Below code capture from a Camera, flip every frame in vertical direction and saves it.
@code{.py}
diff --git a/doc/py_tutorials/py_imgproc/py_colorspaces/py_colorspaces.markdown b/doc/py_tutorials/py_imgproc/py_colorspaces/py_colorspaces.markdown
index 8fbd8dc..b0fa725 100644
--- a/doc/py_tutorials/py_imgproc/py_colorspaces/py_colorspaces.markdown
+++ b/doc/py_tutorials/py_imgproc/py_colorspaces/py_colorspaces.markdown
@@ -24,7 +24,7 @@ commands in your Python terminal :
@code{.py}
>>> import cv2
>>> flags = [i for i in dir(cv2) if i.startswith('COLOR_')]
->>> print flags
+>>> print( flags )
@endcode
@note For HSV, Hue range is [0,179], Saturation range is [0,255] and Value range is [0,255].
Different softwares use different scales. So if you are comparing OpenCV values with them, you need
@@ -96,7 +96,7 @@ terminal:
@code{.py}
>>> green = np.uint8([[[0,255,0 ]]])
>>> hsv_green = cv2.cvtColor(green,cv2.COLOR_BGR2HSV)
->>> print hsv_green
+>>> print( hsv_green )
[[[ 60 255 255]]]
@endcode
Now you take [H-10, 100,100] and [H+10, 255, 255] as lower bound and upper bound respectively. Apart
diff --git a/doc/py_tutorials/py_imgproc/py_contours/py_contour_features/py_contour_features.markdown b/doc/py_tutorials/py_imgproc/py_contours/py_contour_features/py_contour_features.markdown
index 237725e..32243b0 100644
--- a/doc/py_tutorials/py_imgproc/py_contours/py_contour_features/py_contour_features.markdown
+++ b/doc/py_tutorials/py_imgproc/py_contours/py_contour_features/py_contour_features.markdown
@@ -27,7 +27,7 @@ im2,contours,hierarchy = cv2.findContours(thresh, 1, 2)
cnt = contours[0]
M = cv2.moments(cnt)
-print M
+print( M )
@endcode
From this moments, you can extract useful data like area, centroid etc. Centroid is given by the
relations, \f$C_x = \frac{M_{10}}{M_{00}}\f$ and \f$C_y = \frac{M_{01}}{M_{00}}\f$. This can be done as
diff --git a/doc/py_tutorials/py_imgproc/py_contours/py_contours_begin/py_contours_begin.markdown b/doc/py_tutorials/py_imgproc/py_contours/py_contours_begin/py_contours_begin.markdown
index 62a892d..a3e3928 100644
--- a/doc/py_tutorials/py_imgproc/py_contours/py_contours_begin/py_contours_begin.markdown
+++ b/doc/py_tutorials/py_imgproc/py_contours/py_contours_begin/py_contours_begin.markdown
@@ -17,8 +17,7 @@ detection and recognition.
- For better accuracy, use binary images. So before finding contours, apply threshold or canny
edge detection.
-- findContours function modifies the source image. So if you want source image even after
- finding contours, already store it to some other variables.
+- Since OpenCV 3.2, findContours() no longer modifies the source image but returns a modified image as the first of three return parameters.
- In OpenCV, finding contours is like finding white object from black background. So remember,
object to be found should be white and background should be black.
@@ -28,12 +27,12 @@ import numpy as np
import cv2
im = cv2.imread('test.jpg')
-imgray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)
-ret,thresh = cv2.threshold(imgray,127,255,0)
-im2, contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
+imgray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
+ret, thresh = cv2.threshold(imgray, 127, 255, 0)
+im2, contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
@endcode
See, there are three arguments in **cv2.findContours()** function, first one is source image, second
-is contour retrieval mode, third is contour approximation method. And it outputs the contours and
+is contour retrieval mode, third is contour approximation method. And it outputs a modified image, the contours and
hierarchy. contours is a Python list of all the contours in the image. Each individual contour is a
Numpy array of (x,y) coordinates of boundary points of the object.
@@ -49,15 +48,15 @@ contours which should be passed as a Python list, third argument is index of con
drawing individual contour. To draw all contours, pass -1) and remaining arguments are color,
thickness etc.
-To draw all the contours in an image:
+* To draw all the contours in an image:
@code{.py}
cv2.drawContours(img, contours, -1, (0,255,0), 3)
@endcode
-To draw an individual contour, say 4th contour:
+* To draw an individual contour, say 4th contour:
@code{.py}
cv2.drawContours(img, contours, 3, (0,255,0), 3)
@endcode
-But most of the time, below method will be useful:
+* But most of the time, below method will be useful:
@code{.py}
cnt = contours[4]
cv2.drawContours(img, [cnt], 0, (0,255,0), 3)
diff --git a/doc/py_tutorials/py_imgproc/py_contours/py_contours_hierarchy/py_contours_hierarchy.markdown b/doc/py_tutorials/py_imgproc/py_contours/py_contours_hierarchy/py_contours_hierarchy.markdown
index 2f137f5..424469a 100644
--- a/doc/py_tutorials/py_imgproc/py_contours/py_contours_hierarchy/py_contours_hierarchy.markdown
+++ b/doc/py_tutorials/py_imgproc/py_contours/py_contours_hierarchy/py_contours_hierarchy.markdown
@@ -99,7 +99,7 @@ will have their corresponding values. Just check it yourself and verify it.
Below is the result I got, and each row is hierarchy details of corresponding contour. For eg, first
row corresponds to contour 0. Next contour is contour 1. So Next = 1. There is no previous contour,
-so Previous = 0. And the remaining two, as told before, it is -1.
+so Previous = -1. And the remaining two, as told before, it is -1.
@code{.py}
>>> hierarchy
array([[[ 1, -1, -1, -1],
@@ -195,7 +195,7 @@ Take contour-0 : It is in hierarchy-0. Next contour in same hierarchy is contour
contours. Child is contour-1. And no parent. So array is [7,-1,1,-1].
Take contour-2 : It is in hierarchy-1. No contour in same level. No previous one. Child is
-contour-2. Parent is contour-0. So array is [-1,-1,2,0].
+contour-3. Parent is contour-1. So array is [-1,-1,3,1].
And remaining, try yourself. Below is the full answer:
@code{.py}
diff --git a/doc/py_tutorials/py_imgproc/py_contours/py_contours_more_functions/py_contours_more_functions.markdown b/doc/py_tutorials/py_imgproc/py_contours/py_contours_more_functions/py_contours_more_functions.markdown
index 2a96cb0..81b4a74 100644
--- a/doc/py_tutorials/py_imgproc/py_contours/py_contours_more_functions/py_contours_more_functions.markdown
+++ b/doc/py_tutorials/py_imgproc/py_contours/py_contours_more_functions/py_contours_more_functions.markdown
@@ -99,7 +99,7 @@ im2,contours,hierarchy = cv2.findContours(thresh2,2,1)
cnt2 = contours[0]
ret = cv2.matchShapes(cnt1,cnt2,1,0.0)
-print ret
+print( ret )
@endcode
I tried matching shapes with different shapes given below:
diff --git a/doc/py_tutorials/py_imgproc/py_histograms/py_histogram_begins/py_histogram_begins.markdown b/doc/py_tutorials/py_imgproc/py_histograms/py_histogram_begins/py_histogram_begins.markdown
index 540b090..7d7eaac 100644
--- a/doc/py_tutorials/py_imgproc/py_histograms/py_histogram_begins/py_histogram_begins.markdown
+++ b/doc/py_tutorials/py_imgproc/py_histograms/py_histogram_begins/py_histogram_begins.markdown
@@ -46,7 +46,7 @@ histograms](http://docs.opencv.org/doc/tutorials/imgproc/histograms/histogram_ca
So what you do is simply split the whole histogram to 16 sub-parts and value of each sub-part is the
sum of all pixel count in it. This each sub-part is called "BIN". In first case, number of bins
-where 256 (one for each pixel) while in second case, it is only 16. BINS is represented by the term
+were 256 (one for each pixel) while in second case, it is only 16. BINS is represented by the term
**histSize** in OpenCV docs.
**DIMS** : It is the number of parameters for which we collect the data. In this case, we collect
diff --git a/doc/py_tutorials/py_imgproc/py_histograms/py_histogram_equalization/py_histogram_equalization.markdown b/doc/py_tutorials/py_imgproc/py_histograms/py_histogram_equalization/py_histogram_equalization.markdown
index 8498a65..933014d 100644
--- a/doc/py_tutorials/py_imgproc/py_histograms/py_histogram_equalization/py_histogram_equalization.markdown
+++ b/doc/py_tutorials/py_imgproc/py_histograms/py_histogram_equalization/py_histogram_equalization.markdown
@@ -35,7 +35,7 @@ img = cv2.imread('wiki.jpg',0)
hist,bins = np.histogram(img.flatten(),256,[0,256])
cdf = hist.cumsum()
-cdf_normalized = cdf * hist.max()/ cdf.max()
+cdf_normalized = cdf * float(hist.max()) / cdf.max()
plt.plot(cdf_normalized, color = 'b')
plt.hist(img.flatten(),256,[0,256], color = 'r')
diff --git a/doc/py_tutorials/py_imgproc/py_houghlines/py_houghlines.markdown b/doc/py_tutorials/py_imgproc/py_houghlines/py_houghlines.markdown
index 5b569ed..f42d6ad 100644
--- a/doc/py_tutorials/py_imgproc/py_houghlines/py_houghlines.markdown
+++ b/doc/py_tutorials/py_imgproc/py_houghlines/py_houghlines.markdown
@@ -5,36 +5,36 @@ Goal
----
In this chapter,
- - We will understand the concept of Hough Tranform.
- - We will see how to use it detect lines in an image.
- - We will see following functions: **cv2.HoughLines()**, **cv2.HoughLinesP()**
+ - We will understand the concept of the Hough Transform.
+ - We will see how to use it to detect lines in an image.
+ - We will see the following functions: **cv2.HoughLines()**, **cv2.HoughLinesP()**
Theory
------
-Hough Transform is a popular technique to detect any shape, if you can represent that shape in
+The Hough Transform is a popular technique to detect any shape, if you can represent that shape in a
mathematical form. It can detect the shape even if it is broken or distorted a little bit. We will
see how it works for a line.
-A line can be represented as \f$y = mx+c\f$ or in parametric form, as
-\f$\rho = x \cos \theta + y \sin \theta\f$ where \f$\rho\f$ is the perpendicular distance from origin to the
-line, and \f$\theta\f$ is the angle formed by this perpendicular line and horizontal axis measured in
-counter-clockwise ( That direction varies on how you represent the coordinate system. This
-representation is used in OpenCV). Check below image:
+A line can be represented as \f$y = mx+c\f$ or in a parametric form, as
+\f$\rho = x \cos \theta + y \sin \theta\f$ where \f$\rho\f$ is the perpendicular distance from the origin to the
+line, and \f$\theta\f$ is the angle formed by this perpendicular line and the horizontal axis measured in
+counter-clockwise (That direction varies on how you represent the coordinate system. This
+representation is used in OpenCV). Check the image below:

-So if line is passing below the origin, it will have a positive rho and angle less than 180. If it
-is going above the origin, instead of taking angle greater than 180, angle is taken less than 180,
+So if the line is passing below the origin, it will have a positive rho and an angle less than 180. If it
+is going above the origin, instead of taking an angle greater than 180, the angle is taken less than 180,
and rho is taken negative. Any vertical line will have 0 degree and horizontal lines will have 90
degree.
-Now let's see how Hough Transform works for lines. Any line can be represented in these two terms,
-\f$(\rho, \theta)\f$. So first it creates a 2D array or accumulator (to hold values of two parameters)
+Now let's see how the Hough Transform works for lines. Any line can be represented in these two terms,
+\f$(\rho, \theta)\f$. So first it creates a 2D array or accumulator (to hold the values of the two parameters)
and it is set to 0 initially. Let rows denote the \f$\rho\f$ and columns denote the \f$\theta\f$. Size of
-array depends on the accuracy you need. Suppose you want the accuracy of angles to be 1 degree, you
+array depends on the accuracy you need. Suppose you want the accuracy of angles to be 1 degree, you will
need 180 columns. For \f$\rho\f$, the maximum distance possible is the diagonal length of the image. So
-taking one pixel accuracy, number of rows can be diagonal length of the image.
+taking one pixel accuracy, the number of rows can be the diagonal length of the image.
Consider a 100x100 image with a horizontal line at the middle. Take the first point of the line. You
know its (x,y) values. Now in the line equation, put the values \f$\theta = 0,1,2,....,180\f$ and check
@@ -42,57 +42,34 @@ the \f$\rho\f$ you get. For every \f$(\rho, \theta)\f$ pair, you increment value
in its corresponding \f$(\rho, \theta)\f$ cells. So now in accumulator, the cell (50,90) = 1 along with
some other cells.
-Now take the second point on the line. Do the same as above. Increment the the values in the cells
+Now take the second point on the line. Do the same as above. Increment the values in the cells
corresponding to `(rho, theta)` you got. This time, the cell (50,90) = 2. What you actually
do is voting the \f$(\rho, \theta)\f$ values. You continue this process for every point on the line. At
each point, the cell (50,90) will be incremented or voted up, while other cells may or may not be
voted up. This way, at the end, the cell (50,90) will have maximum votes. So if you search the
accumulator for maximum votes, you get the value (50,90) which says, there is a line in this image
-at distance 50 from origin and at angle 90 degrees. It is well shown in below animation (Image
+at a distance 50 from the origin and at angle 90 degrees. It is well shown in the below animation (Image
Courtesy: [Amos Storkey](http://homepages.inf.ed.ac.uk/amos/hough.html) )

-This is how hough transform for lines works. It is simple, and may be you can implement it using
+This is how hough transform works for lines. It is simple, and may be you can implement it using
Numpy on your own. Below is an image which shows the accumulator. Bright spots at some locations
-denotes they are the parameters of possible lines in the image. (Image courtesy: [Wikipedia](http://en.wikipedia.org/wiki/Hough_transform))
+denote they are the parameters of possible lines in the image. (Image courtesy: [Wikipedia](http://en.wikipedia.org/wiki/Hough_transform) )

Hough Transform in OpenCV
=========================
-Everything explained above is encapsulated in the OpenCV function, \*\*cv2.HoughLines()\*\*. It simply returns an array of :math:(rho,
+Everything explained above is encapsulated in the OpenCV function, **cv2.HoughLines()**. It simply returns an array of :math:(rho,
theta)\` values. \f$\rho\f$ is measured in pixels and \f$\theta\f$ is measured in radians. First parameter,
-Input image should be a binary image, so apply threshold or use canny edge detection before finding
+Input image should be a binary image, so apply threshold or use canny edge detection before
applying hough transform. Second and third parameters are \f$\rho\f$ and \f$\theta\f$ accuracies
-respectively. Fourth argument is the threshold, which means minimum vote it should get for it to be
-considered as a line. Remember, number of votes depend upon number of points on the line. So it
+respectively. Fourth argument is the threshold, which means the minimum vote it should get to be
+considered as a line. Remember, number of votes depends upon the number of points on the line. So it
represents the minimum length of line that should be detected.
- at code{.py}
-import cv2
-import numpy as np
-
-img = cv2.imread('sudoku.png')
-gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
-edges = cv2.Canny(gray,50,150,apertureSize = 3)
-
-lines = cv2.HoughLines(edges,1,np.pi/180,200)
-for line in lines:
- rho,theta = line[0]
- a = np.cos(theta)
- b = np.sin(theta)
- x0 = a*rho
- y0 = b*rho
- x1 = int(x0 + 1000*(-b))
- y1 = int(y0 + 1000*(a))
- x2 = int(x0 - 1000*(-b))
- y2 = int(y0 - 1000*(a))
-
- cv2.line(img,(x1,y1),(x2,y2),(0,0,255),2)
-
-cv2.imwrite('houghlines3.jpg',img)
- at endcode
+ at include hough_line_transform.py
Check the results below:

@@ -101,36 +78,23 @@ Probabilistic Hough Transform
-----------------------------
In the hough transform, you can see that even for a line with two arguments, it takes a lot of
-computation. Probabilistic Hough Transform is an optimization of Hough Transform we saw. It doesn't
-take all the points into consideration, instead take only a random subset of points and that is
-sufficient for line detection. Just we have to decrease the threshold. See below image which compare
-Hough Transform and Probabilistic Hough Transform in hough space. (Image Courtesy : [Franck
-Bettinger's home page](http://phdfb1.free.fr/robot/mscthesis/node14.html)
+computation. Probabilistic Hough Transform is an optimization of the Hough Transform we saw. It doesn't
+take all the points into consideration. Instead, it takes only a random subset of points which is
+sufficient for line detection. Just we have to decrease the threshold. See image below which compares
+Hough Transform and Probabilistic Hough Transform in Hough space. (Image Courtesy :
+[Franck Bettinger's home page](http://phdfb1.free.fr/robot/mscthesis/node14.html) )

OpenCV implementation is based on Robust Detection of Lines Using the Progressive Probabilistic
-Hough Transform by Matas, J. and Galambos, C. and Kittler, J.V.. The function used is
+Hough Transform by Matas, J. and Galambos, C. and Kittler, J.V. @cite Matas00. The function used is
**cv2.HoughLinesP()**. It has two new arguments.
- **minLineLength** - Minimum length of line. Line segments shorter than this are rejected.
-- **maxLineGap** - Maximum allowed gap between line segments to treat them as single line.
+- **maxLineGap** - Maximum allowed gap between line segments to treat them as a single line.
Best thing is that, it directly returns the two endpoints of lines. In previous case, you got only
the parameters of lines, and you had to find all the points. Here, everything is direct and simple.
- at code{.py}
-import cv2
-import numpy as np
-
-img = cv2.imread('sudoku.png')
-gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
-edges = cv2.Canny(gray,50,150,apertureSize = 3)
-lines = cv2.HoughLinesP(edges,1,np.pi/180,100,minLineLength=100,maxLineGap=10)
-for line in lines:
- x1,y1,x2,y2 = line[0]
- cv2.line(img,(x1,y1),(x2,y2),(0,255,0),2)
-
-cv2.imwrite('houghlines5.jpg',img)
- at endcode
+ at include probabilistic_hough_line_transform.py
See the results below:

diff --git a/doc/py_tutorials/py_imgproc/py_thresholding/py_thresholding.markdown b/doc/py_tutorials/py_imgproc/py_thresholding/py_thresholding.markdown
index 5fc6240..0f4b790 100644
--- a/doc/py_tutorials/py_imgproc/py_thresholding/py_thresholding.markdown
+++ b/doc/py_tutorials/py_imgproc/py_thresholding/py_thresholding.markdown
@@ -218,7 +218,7 @@ for i in xrange(1,256):
# find otsu's threshold value with OpenCV function
ret, otsu = cv2.threshold(blur,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
-print thresh,ret
+print( "{} {}".format(thresh,ret) )
@endcode
*(Some of the functions may be new here, but we will cover them in coming chapters)*
diff --git a/doc/py_tutorials/py_imgproc/py_transforms/py_fourier_transform/py_fourier_transform.markdown b/doc/py_tutorials/py_imgproc/py_transforms/py_fourier_transform/py_fourier_transform.markdown
index b100e65..1c503c0 100644
--- a/doc/py_tutorials/py_imgproc/py_transforms/py_fourier_transform/py_fourier_transform.markdown
+++ b/doc/py_tutorials/py_imgproc/py_transforms/py_fourier_transform/py_fourier_transform.markdown
@@ -186,12 +186,12 @@ using IPython magic command %timeit.
@code{.py}
In [16]: img = cv2.imread('messi5.jpg',0)
In [17]: rows,cols = img.shape
-In [18]: print rows,cols
+In [18]: print("{} {}".format(rows,cols))
342 548
In [19]: nrows = cv2.getOptimalDFTSize(rows)
In [20]: ncols = cv2.getOptimalDFTSize(cols)
-In [21]: print nrows, ncols
+In [21]: print("{} {}".format(nrows,ncols))
360 576
@endcode
See, the size (342,548) is modified to (360, 576). Now let's pad it with zeros (for OpenCV) and find
diff --git a/doc/py_tutorials/py_ml/py_knn/py_knn_opencv/py_knn_opencv.markdown b/doc/py_tutorials/py_ml/py_knn/py_knn_opencv/py_knn_opencv.markdown
index c58658d..2c06b1a 100644
--- a/doc/py_tutorials/py_ml/py_knn/py_knn_opencv/py_knn_opencv.markdown
+++ b/doc/py_tutorials/py_ml/py_knn/py_knn_opencv/py_knn_opencv.markdown
@@ -51,7 +51,7 @@ ret,result,neighbours,dist = knn.findNearest(test,k=5)
matches = result==test_labels
correct = np.count_nonzero(matches)
accuracy = correct*100.0/result.size
-print accuracy
+print( accuracy )
@endcode
So our basic OCR app is ready. This particular example gave me an accuracy of 91%. One option
improve accuracy is to add more data for training, especially the wrong ones. So instead of finding
@@ -64,7 +64,7 @@ np.savez('knn_data.npz',train=train, train_labels=train_labels)
# Now load the data
with np.load('knn_data.npz') as data:
- print data.files
+ print( data.files )
train = data['train']
train_labels = data['train_labels']
@endcode
@@ -109,7 +109,7 @@ ret, result, neighbours, dist = knn.findNearest(testData, k=5)
correct = np.count_nonzero(result == labels)
accuracy = correct*100.0/10000
-print accuracy
+print( accuracy )
@endcode
It gives me an accuracy of 93.22%. Again, if you want to increase accuracy, you can iteratively add
error data in each level.
diff --git a/doc/py_tutorials/py_ml/py_knn/py_knn_understanding/py_knn_understanding.markdown b/doc/py_tutorials/py_ml/py_knn/py_knn_understanding/py_knn_understanding.markdown
index 5eae4b2..a9c36c4 100644
--- a/doc/py_tutorials/py_ml/py_knn/py_knn_understanding/py_knn_understanding.markdown
+++ b/doc/py_tutorials/py_ml/py_knn/py_knn_understanding/py_knn_understanding.markdown
@@ -118,9 +118,9 @@ knn = cv2.ml.KNearest_create()
knn.train(trainData, cv2.ml.ROW_SAMPLE, responses)
ret, results, neighbours ,dist = knn.findNearest(newcomer, 3)
-print "result: ", results,"\n"
-print "neighbours: ", neighbours,"\n"
-print "distance: ", dist
+print( "result: {}\n".format(results) )
+print( "neighbours: {}\n".format(neighbours) )
+print( "distance: {}\n".format(dist) )
plt.show()
@endcode
diff --git a/doc/py_tutorials/py_ml/py_svm/py_svm_opencv/py_svm_opencv.markdown b/doc/py_tutorials/py_ml/py_svm/py_svm_opencv/py_svm_opencv.markdown
index b9ee47d..dd034e9 100644
--- a/doc/py_tutorials/py_ml/py_svm/py_svm_opencv/py_svm_opencv.markdown
+++ b/doc/py_tutorials/py_ml/py_svm/py_svm_opencv/py_svm_opencv.markdown
@@ -17,16 +17,9 @@ vectors.
Here, before finding the HOG, we deskew the image using its second order moments. So we first define
a function **deskew()** which takes a digit image and deskew it. Below is the deskew() function:
- at code{.py}
-def deskew(img):
- m = cv2.moments(img)
- if abs(m['mu02']) < 1e-2:
- return img.copy()
- skew = m['mu11']/m['mu02']
- M = np.float32([[1, skew, -0.5*SZ*skew], [0, 1, 0]])
- img = cv2.warpAffine(img,M,(SZ, SZ),flags=affine_flags)
- return img
- at endcode
+
+ at snippet samples/python/tutorial_code/ml/py_svm_opencv/hogsvm.py deskew
+
Below image shows above deskew function applied to an image of zero. Left image is the original
image and right image is the deskewed image.
@@ -38,91 +31,15 @@ gradient is quantized to 16 integer values. Divide this image to four sub-square
sub-square, calculate the histogram of direction (16 bins) weighted with their magnitude. So each
sub-square gives you a vector containing 16 values. Four such vectors (of four sub-squares) together
gives us a feature vector containing 64 values. This is the feature vector we use to train our data.
- at code{.py}
-def hog(img):
- gx = cv2.Sobel(img, cv2.CV_32F, 1, 0)
- gy = cv2.Sobel(img, cv2.CV_32F, 0, 1)
- mag, ang = cv2.cartToPolar(gx, gy)
-
- # quantizing binvalues in (0...16)
- bins = np.int32(bin_n*ang/(2*np.pi))
-
- # Divide to 4 sub-squares
- bin_cells = bins[:10,:10], bins[10:,:10], bins[:10,10:], bins[10:,10:]
- mag_cells = mag[:10,:10], mag[10:,:10], mag[:10,10:], mag[10:,10:]
- hists = [np.bincount(b.ravel(), m.ravel(), bin_n) for b, m in zip(bin_cells, mag_cells)]
- hist = np.hstack(hists)
- return hist
- at endcode
+
+ at snippet samples/python/tutorial_code/ml/py_svm_opencv/hogsvm.py hog
+
Finally, as in the previous case, we start by splitting our big dataset into individual cells. For
every digit, 250 cells are reserved for training data and remaining 250 data is reserved for
-testing. Full code is given below:
- at code{.py}
-import cv2
-import numpy as np
-
-SZ=20
-bin_n = 16 # Number of bins
-
-
-affine_flags = cv2.WARP_INVERSE_MAP|cv2.INTER_LINEAR
-
-def deskew(img):
- m = cv2.moments(img)
- if abs(m['mu02']) < 1e-2:
- return img.copy()
- skew = m['mu11']/m['mu02']
- M = np.float32([[1, skew, -0.5*SZ*skew], [0, 1, 0]])
- img = cv2.warpAffine(img,M,(SZ, SZ),flags=affine_flags)
- return img
-
-def hog(img):
- gx = cv2.Sobel(img, cv2.CV_32F, 1, 0)
- gy = cv2.Sobel(img, cv2.CV_32F, 0, 1)
- mag, ang = cv2.cartToPolar(gx, gy)
- bins = np.int32(bin_n*ang/(2*np.pi)) # quantizing binvalues in (0...16)
- bin_cells = bins[:10,:10], bins[10:,:10], bins[:10,10:], bins[10:,10:]
- mag_cells = mag[:10,:10], mag[10:,:10], mag[:10,10:], mag[10:,10:]
- hists = [np.bincount(b.ravel(), m.ravel(), bin_n) for b, m in zip(bin_cells, mag_cells)]
- hist = np.hstack(hists) # hist is a 64 bit vector
- return hist
-
-img = cv2.imread('digits.png',0)
-
-cells = [np.hsplit(row,100) for row in np.vsplit(img,50)]
-
-# First half is trainData, remaining is testData
-train_cells = [ i[:50] for i in cells ]
-test_cells = [ i[50:] for i in cells]
-
-###### Now training ########################
-
-deskewed = [map(deskew,row) for row in train_cells]
-hogdata = [map(hog,row) for row in deskewed]
-trainData = np.float32(hogdata).reshape(-1,64)
-responses = np.float32(np.repeat(np.arange(10),250)[:,np.newaxis])
-
-svm = cv2.ml.SVM_create()
-svm.setKernel(cv2.ml.SVM_LINEAR)
-svm.setType(cv2.ml.SVM_C_SVC)
-svm.setC(2.67)
-svm.setGamma(5.383)
-
-svm.train(trainData, cv2.ml.ROW_SAMPLE, responses)
-svm.save('svm_data.dat')
-
-###### Now testing ########################
-
-deskewed = [map(deskew,row) for row in test_cells]
-hogdata = [map(hog,row) for row in deskewed]
-testData = np.float32(hogdata).reshape(-1,bin_n*4)
-result = svm.predict(testData)
-
-####### Check Accuracy ########################
-mask = result==responses
-correct = np.count_nonzero(mask)
-print correct*100.0/result.size
- at endcode
+testing. Full code is given below, you also can download it from [here](https://github.com/opencv/opencv/tree/master/samples/python/tutorial_code/ml/py_svm_opencv/hogsvm.py):
+
+ at include samples/python/tutorial_code/ml/py_svm_opencv/hogsvm.py
+
This particular technique gave me nearly 94% accuracy. You can try different values for various
parameters of SVM to check if higher accuracy is possible. Or you can read technical papers on this
area and try to implement them.
diff --git a/doc/py_tutorials/py_setup/py_setup_in_fedora/py_setup_in_fedora.markdown b/doc/py_tutorials/py_setup/py_setup_in_fedora/py_setup_in_fedora.markdown
index da65dd4..a538cb4 100644
--- a/doc/py_tutorials/py_setup/py_setup_in_fedora/py_setup_in_fedora.markdown
+++ b/doc/py_tutorials/py_setup/py_setup_in_fedora/py_setup_in_fedora.markdown
@@ -30,7 +30,7 @@ $ yum install numpy opencv*
Open Python IDLE (or IPython) and type following codes in Python terminal.
@code{.py}
>>> import cv2
->>> print cv2.__version__
+>>> print( cv2.__version__ )
@endcode
If the results are printed out without any errors, congratulations !!! You have installed
OpenCV-Python successfully.
@@ -41,7 +41,7 @@ version of OpenCV always. For example, at the time of writing this tutorial, yum
contain much better support. Also, there may be chance of problems with camera support, video
playback etc depending upon the drivers, ffmpeg, gstreamer packages present etc.
-So my personnel preference is next method, i.e. compiling from source. Also at some point of time,
+So my personal preference is next method, i.e. compiling from source. Also at some point in time,
if you want to contribute to OpenCV, you will need this.
Installing OpenCV from source
@@ -102,13 +102,10 @@ yum install eigen3-devel
@endcode
If you want to build **documentation** ( *Yes, you can create offline version of OpenCV's complete
official documentation in your system in HTML with full search facility so that you need not access
-internet always if any question, and it is quite FAST!!!* ), you need to install **Sphinx** (a
-documentation generation tool) and **pdflatex** (if you want to create a PDF version of it). ( Also
-while configuring installation with CMake, don't forget to pass -D BUILD_DOCS=ON. More details
-below.)
+internet always if any question, and it is quite FAST!!!* ), you need to install **Doxygen** (a
+documentation generation tool).
@code{.sh}
-yum install python-sphinx
-yum install texlive
+yum install doxygen
@endcode
### Downloading OpenCV
@@ -174,6 +171,7 @@ setup you got, make sure that following fields are filled (below is the some imp
configuration I got). These fields should be filled appropriately in your system also. Otherwise
some problem has happened. So check if you have correctly performed above steps.
@code{.sh}
+...
-- GUI:
-- GTK+ 2.x: YES (ver 2.24.19)
-- GThread : YES (ver 2.36.3)
@@ -205,15 +203,7 @@ some problem has happened. So check if you have correctly performed above steps.
-- numpy: /usr/lib/python2.7/site-packages/numpy/core/include (ver 1.7.1)
-- packages path: lib/python2.7/site-packages
--- Documentation:
--- Build Documentation: YES
--- Sphinx: /usr/bin/sphinx-build (ver 1.1.3)
--- PdfLaTeX compiler: /usr/bin/pdflatex
---
--- Tests and samples:
--- Tests: NO
--- Performance tests: NO
--- C/C++ Examples: NO
+...
@endcode
Many other flags and settings are there. It is left for you for further exploration.
@@ -228,7 +218,7 @@ Installation is over. All files are installed in /usr/local/ folder. But to use
should be able to find OpenCV module. You have two options for that.
-# **Move the module to any folder in Python Path** : Python path can be found out by entering
- import sys;print sys.path in Python terminal. It will print out many locations. Move
+ `import sys; print(sys.path)` in Python terminal. It will print out many locations. Move
/usr/local/lib/python2.7/site-packages/cv2.so to any of this folder. For example,
@code{.sh}
su mv /usr/local/lib/python2.7/site-packages/cv2.so /usr/lib/python2.7/site-packages
@@ -244,10 +234,9 @@ Thus OpenCV installation is finished. Open a terminal and try import cv2.
To build the documentation, just enter following commands:
@code{.sh}
-make docs
-make html_docs
+make doxygen
@endcode
-Then open opencv/build/doc/_html/index.html and bookmark it in the browser.
+Then open opencv/build/doc/doxygen/html/index.html and bookmark it in the browser.
Additional Resources
--------------------
diff --git a/doc/py_tutorials/py_setup/py_setup_in_windows/py_setup_in_windows.markdown b/doc/py_tutorials/py_setup/py_setup_in_windows/py_setup_in_windows.markdown
index 3ff4e82..f971192 100644
--- a/doc/py_tutorials/py_setup/py_setup_in_windows/py_setup_in_windows.markdown
+++ b/doc/py_tutorials/py_setup/py_setup_in_windows/py_setup_in_windows.markdown
@@ -15,15 +15,15 @@ Installing OpenCV from prebuilt binaries
-# Below Python packages are to be downloaded and installed to their default locations.
- -# [Python-2.7.x](http://python.org/ftp/python/2.7.5/python-2.7.5.msi).
+ -# [Python-2.7.x](http://www.python.org/ftp/python/2.7.13/python-2.7.13.msi).
- -# [Numpy](http://sourceforge.net/projects/numpy/files/NumPy/1.7.1/numpy-1.7.1-win32-superpack-python2.7.exe/download).
+ -# [Numpy](https://sourceforge.net/projects/numpy/files/NumPy/1.10.2/numpy-1.10.2-win32-superpack-python2.7.exe/download).
- -# [Matplotlib](https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.3.0/matplotlib-1.3.0.win32-py2.7.exe) (*Matplotlib is optional, but recommended since we use it a lot in our tutorials*).
+ -# [Matplotlib](https://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.5.0/windows/matplotlib-1.5.0.win32-py2.7.exe/download) (*Matplotlib is optional, but recommended since we use it a lot in our tutorials*).
-# Install all packages into their default locations. Python will be installed to `C:/Python27/`.
--# After installation, open Python IDLE. Enter import numpy and make sure Numpy is working fine.
+-# After installation, open Python IDLE. Enter **import numpy** and make sure Numpy is working fine.
-# Download latest OpenCV release from [sourceforge
site](http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.4.6/OpenCV-2.4.6.0.exe/download)
@@ -36,7 +36,7 @@ Installing OpenCV from prebuilt binaries
-# Open Python IDLE and type following codes in Python terminal.
@code
>>> import cv2
- >>> print cv2.__version__
+ >>> print( cv2.__version__ )
@endcode
If the results are printed out without any errors, congratulations !!! You have installed
diff --git a/doc/tutorials/calib3d/camera_calibration_square_chess/camera_calibration_square_chess.markdown b/doc/tutorials/calib3d/camera_calibration_square_chess/camera_calibration_square_chess.markdown
index 2cf9d9a..bf1eadc 100644
--- a/doc/tutorials/calib3d/camera_calibration_square_chess/camera_calibration_square_chess.markdown
+++ b/doc/tutorials/calib3d/camera_calibration_square_chess/camera_calibration_square_chess.markdown
@@ -5,7 +5,7 @@ The goal of this tutorial is to learn how to calibrate a camera given a set of c
*Test data*: use images in your data/chess folder.
-- Compile opencv with samples by setting BUILD_EXAMPLES to ON in cmake configuration.
+- Compile OpenCV with samples by setting BUILD_EXAMPLES to ON in cmake configuration.
- Go to bin folder and use imagelist_creator to create an XML/YAML list of your images.
@@ -14,32 +14,32 @@ The goal of this tutorial is to learn how to calibrate a camera given a set of c
Pose estimation
---------------
-Now, let us write a code that detects a chessboard in a new image and finds its distance from the
-camera. You can apply the same method to any object with known 3D geometry that you can detect in an
+Now, let us write code that detects a chessboard in an image and finds its distance from the
+camera. You can apply this method to any object with known 3D geometry; which you detect in an
image.
*Test data*: use chess_test\*.jpg images from your data folder.
-- Create an empty console project. Load a test image: :
+- Create an empty console project. Load a test image :
Mat img = imread(argv[1], IMREAD_GRAYSCALE);
-- Detect a chessboard in this image using findChessboard function. :
+- Detect a chessboard in this image using findChessboard function :
bool found = findChessboardCorners( img, boardSize, ptvec, CALIB_CB_ADAPTIVE_THRESH );
- Now, write a function that generates a vector\<Point3f\> array of 3d coordinates of a chessboard
in any coordinate system. For simplicity, let us choose a system such that one of the chessboard
- corners is in the origin and the board is in the plane *z = 0*.
+ corners is in the origin and the board is in the plane *z = 0*
-- Read camera parameters from XML/YAML file: :
+- Read camera parameters from XML/YAML file :
- FileStorage fs(filename, FileStorage::READ);
+ FileStorage fs( filename, FileStorage::READ );
Mat intrinsics, distortion;
fs["camera_matrix"] >> intrinsics;
fs["distortion_coefficients"] >> distortion;
-- Now we are ready to find chessboard pose by running \`solvePnP\`: :
+- Now we are ready to find a chessboard pose by running \`solvePnP\` :
vector<Point3f> boardPoints;
// fill the array
@@ -51,4 +51,5 @@ image.
- Calculate reprojection error like it is done in calibration sample (see
opencv/samples/cpp/calibration.cpp, function computeReprojectionErrors).
-Question: how to calculate the distance from the camera origin to any of the corners?
+Question: how would you calculate distance from the camera origin to any one of the corners?
+Answer: As our image lies in a 3D space, firstly we would calculate the relative camera pose. This would give us 3D to 2D correspondences. Next, we can apply a simple L2 norm to calculate distance between any point (end point for corners).
diff --git a/doc/tutorials/calib3d/table_of_content_calib3d.markdown b/doc/tutorials/calib3d/table_of_content_calib3d.markdown
index 50e9d12..882721b 100644
--- a/doc/tutorials/calib3d/table_of_content_calib3d.markdown
+++ b/doc/tutorials/calib3d/table_of_content_calib3d.markdown
@@ -1,8 +1,7 @@
Camera calibration and 3D reconstruction (calib3d module) {#tutorial_table_of_content_calib3d}
==========================================================
-Although we got most of our images in a 2D format they do come from a 3D world. Here you will learn
-how to find out from the 2D images information about the 3D world.
+Although we get most of our images in a 2D format they do come from a 3D world. Here you will learn how to find out 3D world information from 2D images.
- @subpage tutorial_camera_calibration_square_chess
diff --git a/doc/tutorials/core/basic_linear_transform/basic_linear_transform.markdown b/doc/tutorials/core/basic_linear_transform/basic_linear_transform.markdown
index bb0ffd8..a035199 100644
--- a/doc/tutorials/core/basic_linear_transform/basic_linear_transform.markdown
+++ b/doc/tutorials/core/basic_linear_transform/basic_linear_transform.markdown
@@ -10,6 +10,7 @@ In this tutorial you will learn how to:
- Initialize a matrix with zeros
- Learn what @ref cv::saturate_cast does and why it is useful
- Get some cool info about pixel transformations
+- Improve the brightness of an image on a practical example
Theory
------
@@ -53,87 +54,29 @@ Code
----
- The following code performs the operation \f$g(i,j) = \alpha \cdot f(i,j) + \beta\f$ :
- at code{.cpp}
-#include <opencv2/opencv.hpp>
-#include <iostream>
-
-using namespace cv;
-
-double alpha; /*< Simple contrast control */
-int beta; /*< Simple brightness control */
-
-int main( int argc, char** argv )
-{
- /// Read image given by user
- Mat image = imread( argv[1] );
- Mat new_image = Mat::zeros( image.size(), image.type() );
-
- /// Initialize values
- std::cout<<" Basic Linear Transforms "<<std::endl;
- std::cout<<"-------------------------"<<std::endl;
- std::cout<<"* Enter the alpha value [1.0-3.0]: ";std::cin>>alpha;
- std::cout<<"* Enter the beta value [0-100]: "; std::cin>>beta;
-
- /// Do the operation new_image(i,j) = alpha*image(i,j) + beta
- for( int y = 0; y < image.rows; y++ ) {
- for( int x = 0; x < image.cols; x++ ) {
- for( int c = 0; c < 3; c++ ) {
- new_image.at<Vec3b>(y,x)[c] =
- saturate_cast<uchar>( alpha*( image.at<Vec3b>(y,x)[c] ) + beta );
- }
- }
- }
-
- /// Create Windows
- namedWindow("Original Image", 1);
- namedWindow("New Image", 1);
-
- /// Show stuff
- imshow("Original Image", image);
- imshow("New Image", new_image);
-
- /// Wait until user press some key
- waitKey();
- return 0;
-}
- at endcode
+ at include BasicLinearTransforms.cpp
Explanation
-----------
-# We begin by creating parameters to save \f$\alpha\f$ and \f$\beta\f$ to be entered by the user:
- @code{.cpp}
- double alpha;
- int beta;
- @endcode
+ @snippet BasicLinearTransforms.cpp basic-linear-transform-parameters
+
-# We load an image using @ref cv::imread and save it in a Mat object:
- @code{.cpp}
- Mat image = imread( argv[1] );
- @endcode
+ @snippet BasicLinearTransforms.cpp basic-linear-transform-load
-# Now, since we will make some transformations to this image, we need a new Mat object to store
it. Also, we want this to have the following features:
- Initial pixel values equal to zero
- Same size and type as the original image
- @code{.cpp}
- Mat new_image = Mat::zeros( image.size(), image.type() );
- @endcode
+ @snippet BasicLinearTransforms.cpp basic-linear-transform-output
We observe that @ref cv::Mat::zeros returns a Matlab-style zero initializer based on
*image.size()* and *image.type()*
-# Now, to perform the operation \f$g(i,j) = \alpha \cdot f(i,j) + \beta\f$ we will access to each
pixel in image. Since we are operating with BGR images, we will have three values per pixel (B,
G and R), so we will also access them separately. Here is the piece of code:
- @code{.cpp}
- for( int y = 0; y < image.rows; y++ ) {
- for( int x = 0; x < image.cols; x++ ) {
- for( int c = 0; c < 3; c++ ) {
- new_image.at<Vec3b>(y,x)[c] =
- saturate_cast<uchar>( alpha*( image.at<Vec3b>(y,x)[c] ) + beta );
- }
- }
- }
- @endcode
+ @snippet BasicLinearTransforms.cpp basic-linear-transform-operation
Notice the following:
- To access each pixel in the images we are using this syntax: *image.at\<Vec3b\>(y,x)[c]*
where *y* is the row, *x* is the column and *c* is R, G or B (0, 1 or 2).
@@ -142,15 +85,7 @@ Explanation
values are valid.
-# Finally, we create windows and show the images, the usual way.
- @code{.cpp}
- namedWindow("Original Image", 1);
- namedWindow("New Image", 1);
-
- imshow("Original Image", image);
- imshow("New Image", new_image);
-
- waitKey(0);
- @endcode
+ @snippet BasicLinearTransforms.cpp basic-linear-transform-display
@note
Instead of using the **for** loops to access each pixel, we could have simply used this command:
@@ -176,3 +111,89 @@ Result
- We get this:

+
+Practical example
+----
+
+In this paragraph, we will put into practice what we have learned to correct an underexposed image by adjusting the brightness
+and the contrast of the image. We will also see another technique to correct the brightness of an image called
+gamma correction.
+
+### Brightness and contrast adjustments
+
+Increasing (/ decreasing) the \f$\beta\f$ value will add (/ subtract) a constant value to every pixel. Pixel values outside of the [0 ; 255]
+range will be saturated (i.e. a pixel value higher (/ lesser) than 255 (/ 0) will be clamp to 255 (/ 0)).
+
+
+
+The histogram represents for each color level the number of pixels with that color level. A dark image will have many pixels with
+low color value and thus the histogram will present a peak in his left part. When adding a constant bias, the histogram is shifted to the
+right as we have added a constant bias to all the pixels.
+
+The \f$\alpha\f$ parameter will modify how the levels spread. If \f$ \alpha < 1 \f$, the color levels will be compressed and the result
+will be an image with less contrast.
+
+
+
+Note that these histograms have been obtained using the Brightness-Contrast tool in the Gimp software. The brightness tool should be
+identical to the \f$\beta\f$ bias parameters but the contrast tool seems to differ to the \f$\alpha\f$ gain where the output range
+seems to be centered with Gimp (as you can notice in the previous histogram).
+
+It can occur that playing with the \f$\beta\f$ bias will improve the brightness but in the same time the image will appear with a
+slight veil as the contrast will be reduced. The \f$\alpha\f$ gain can be used to diminue this effect but due to the saturation,
+we will lose some details in the original bright regions.
+
+### Gamma correction
+
+[Gamma correction](https://en.wikipedia.org/wiki/Gamma_correction) can be used to correct the brightness of an image by using a non
+linear transformation between the input values and the mapped output values:
+
+\f[O = \left( \frac{I}{255} \right)^{\gamma} \times 255\f]
+
+As this relation is non linear, the effect will not be the same for all the pixels and will depend to their original value.
+
+
+
+When \f$ \gamma < 1 \f$, the original dark regions will be brighter and the histogram will be shifted to the right whereas it will
+be the opposite with \f$ \gamma > 1 \f$.
+
+### Correct an underexposed image
+
+The following image has been corrected with: \f$ \alpha = 1.3 \f$ and \f$ \beta = 40 \f$.
+
+![By Visem (Own work) [CC BY-SA 3.0], via Wikimedia Commons](images/Basic_Linear_Transform_Tutorial_linear_transform_correction.jpg)
+
+The overall brightness has been improved but you can notice that the clouds are now greatly saturated due to the numerical saturation
+of the implementation used ([highlight clipping](https://en.wikipedia.org/wiki/Clipping_(photography)) in photography).
+
+The following image has been corrected with: \f$ \gamma = 0.4 \f$.
+
+![By Visem (Own work) [CC BY-SA 3.0], via Wikimedia Commons](images/Basic_Linear_Transform_Tutorial_gamma_correction.jpg)
+
+The gamma correction should tend to add less saturation effect as the mapping is non linear and there is no numerical saturation possible as in the previous method.
+
+
+
+The previous figure compares the histograms for the three images (the y-ranges are not the same between the three histograms).
+You can notice that most of the pixel values are in the lower part of the histogram for the original image. After \f$ \alpha \f$,
+\f$ \beta \f$ correction, we can observe a big peak at 255 due to the saturation as well as a shift in the right.
+After gamma correction, the histogram is shifted to the right but the pixels in the dark regions are more shifted
+(see the gamma curves [figure](Basic_Linear_Transform_Tutorial_gamma.png)) than those in the bright regions.
+
+In this tutorial, you have seen two simple methods to adjust the contrast and the brightness of an image. **They are basic techniques
+and are not intended to be used as a replacement of a raster graphics editor!**
+
+### Code
+
+Code for the tutorial is [here](https://github.com/opencv/opencv/blob/master/samples/cpp/tutorial_code/ImgProc/changing_contrast_brightness_image/changing_contrast_brightness_image.cpp).
+Code for the gamma correction:
+
+ at snippet changing_contrast_brightness_image.cpp changing-contrast-brightness-gamma-correction
+
+A look-up table is used to improve the performance of the computation as only 256 values needs to be calculated once.
+
+### Additional resources
+
+- [Gamma correction in graphics rendering](https://learnopengl.com/#!Advanced-Lighting/Gamma-Correction)
+- [Gamma correction and images displayed on CRT monitors](http://www.graphics.cornell.edu/~westin/gamma/gamma.html)
+- [Digital exposure techniques](http://www.cambridgeincolour.com/tutorials/digital-exposure-techniques.htm)
diff --git a/doc/tutorials/core/basic_linear_transform/images/Basic_Linear_Transform_Tutorial_gamma.png b/doc/tutorials/core/basic_linear_transform/images/Basic_Linear_Transform_Tutorial_gamma.png
new file mode 100644
index 0000000..50cd586
Binary files /dev/null and b/doc/tutorials/core/basic_linear_transform/images/Basic_Linear_Transform_Tutorial_gamma.png differ
diff --git a/doc/tutorials/core/basic_linear_transform/images/Basic_Linear_Transform_Tutorial_gamma_correction.jpg b/doc/tutorials/core/basic_linear_transform/images/Basic_Linear_Transform_Tutorial_gamma_correction.jpg
new file mode 100644
index 0000000..7ade82d
Binary files /dev/null and b/doc/tutorials/core/basic_linear_transform/images/Basic_Linear_Transform_Tutorial_gamma_correction.jpg differ
diff --git a/doc/tutorials/core/basic_linear_transform/images/Basic_Linear_Transform_Tutorial_hist_alpha.png b/doc/tutorials/core/basic_linear_transform/images/Basic_Linear_Transform_Tutorial_hist_alpha.png
new file mode 100644
index 0000000..21185a1
Binary files /dev/null and b/doc/tutorials/core/basic_linear_transform/images/Basic_Linear_Transform_Tutorial_hist_alpha.png differ
diff --git a/doc/tutorials/core/basic_linear_transform/images/Basic_Linear_Transform_Tutorial_hist_beta.png b/doc/tutorials/core/basic_linear_transform/images/Basic_Linear_Transform_Tutorial_hist_beta.png
new file mode 100644
index 0000000..d8ef844
Binary files /dev/null and b/doc/tutorials/core/basic_linear_transform/images/Basic_Linear_Transform_Tutorial_hist_beta.png differ
diff --git a/doc/tutorials/core/basic_linear_transform/images/Basic_Linear_Transform_Tutorial_histogram_compare.png b/doc/tutorials/core/basic_linear_transform/images/Basic_Linear_Transform_Tutorial_histogram_compare.png
new file mode 100644
index 0000000..c2494dc
Binary files /dev/null and b/doc/tutorials/core/basic_linear_transform/images/Basic_Linear_Transform_Tutorial_histogram_compare.png differ
diff --git a/doc/tutorials/core/basic_linear_transform/images/Basic_Linear_Transform_Tutorial_linear_transform_correction.jpg b/doc/tutorials/core/basic_linear_transform/images/Basic_Linear_Transform_Tutorial_linear_transform_correction.jpg
new file mode 100644
index 0000000..2cad655
Binary files /dev/null and b/doc/tutorials/core/basic_linear_transform/images/Basic_Linear_Transform_Tutorial_linear_transform_correction.jpg differ
diff --git a/doc/tutorials/core/how_to_scan_images/how_to_scan_images.markdown b/doc/tutorials/core/how_to_scan_images/how_to_scan_images.markdown
index 409ebdb..bb9c648 100644
--- a/doc/tutorials/core/how_to_scan_images/how_to_scan_images.markdown
+++ b/doc/tutorials/core/how_to_scan_images/how_to_scan_images.markdown
@@ -46,7 +46,7 @@ Its strength lies that we do not need to make the calculation, we just need to r
Our test case program (and the sample presented here) will do the following: read in a console line
argument image (that may be either color or gray scale - console line argument too) and apply the
-reduction with the given console line argument integer value. In OpenCV, at the moment they are
+reduction with the given console line argument integer value. In OpenCV, at the moment there are
three major ways of going through an image pixel by pixel. To make things a little more interesting
will make the scanning for each image using all of these methods, and print out how long it took.
@@ -78,11 +78,11 @@ cout << "Times passed in seconds: " << t << endl;
@endcode
@anchor tutorial_how_to_scan_images_storing
-How the image matrix is stored in the memory?
----------------------------------------------
+How is the image matrix stored in memory?
+-----------------------------------------
As you could already read in my @ref tutorial_mat_the_basic_image_container tutorial the size of the matrix
-depends of the color system used. More accurately, it depends from the number of channels used. In
+depends on the color system used. More accurately, it depends from the number of channels used. In
case of a gray scale image we have something like:

@@ -107,14 +107,14 @@ Therefore, the most efficient method we can recommend for making the assignment
@snippet how_to_scan_images.cpp scan-c
Here we basically just acquire a pointer to the start of each row and go through it until it ends.
-In the special case that the matrix is stored in a continues manner we only need to request the
+In the special case that the matrix is stored in a continuous manner we only need to request the
pointer a single time and go all the way to the end. We need to look out for color images: we have
three channels so we need to pass through three times more items in each row.
There's another way of this. The *data* data member of a *Mat* object returns the pointer to the
first row, first column. If this pointer is null you have no valid input in that object. Checking
this is the simplest method to check if your image loading was a success. In case the storage is
-continues we can use this to go through the whole data pointer. In case of a gray scale image this
+continuous we can use this to go through the whole data pointer. In case of a gray scale image this
would look like:
@code{.cpp}
uchar* p = I.data;
@@ -150,7 +150,7 @@ On-the-fly address calculation with reference returning
The final method isn't recommended for scanning. It was made to acquire or modify somehow random
elements in the image. Its basic usage is to specify the row and column number of the item you want
to access. During our earlier scanning methods you could already observe that is important through
-what type we are looking at the image. It's no different here as you need manually to specify what
+what type we are looking at the image. It's no different here as you need to manually specify what
type to use at the automatic lookup. You can observe this in case of the gray scale images for the
following source code (the usage of the + @ref cv::at() function):
@@ -164,7 +164,7 @@ nice output message of this on the standard error output stream. Compared to the
release mode the only difference in using this is that for every element of the image you'll get a
new row pointer for what we use the C operator[] to acquire the column element.
-If you need to multiple lookups using this method for an image it may be troublesome and time
+If you need to do multiple lookups using this method for an image it may be troublesome and time
consuming to enter the type and the at keyword for each of the accesses. To solve this problem
OpenCV has a @ref cv::Mat_ data type. It's the same as Mat with the extra need that at definition
you need to specify the data type through what to look at the data matrix, however in return you can
@@ -177,10 +177,10 @@ to write for the lazy programmer trick.
The Core Function
-----------------
-This is a bonus method of achieving lookup table modification in an image. Because in image
-processing it's quite common that you want to replace all of a given image value to some other value
-OpenCV has a function that makes the modification without the need from you to write the scanning of
-the image. We use the @ref cv::LUT() function of the core module. First we build a Mat type of the
+This is a bonus method of achieving lookup table modification in an image. In image
+processing it's quite common that you want to modify all of a given image values to some other value.
+OpenCV provides a function for modifying image values, without the need to write the scanning logic
+of the image. We use the @ref cv::LUT() function of the core module. First we build a Mat type of the
lookup table:
@snippet how_to_scan_images.cpp table-init
@@ -192,8 +192,8 @@ Finally call the function (I is our input image and J the output one):
Performance Difference
----------------------
-For the best result compile the program and run it on your own speed. For showing off better the
-differences I've used a quite large (2560 X 1600) image. The performance presented here are for
+For the best result compile the program and run it on your own speed. To make the differences more
+clear, I've used a quite large (2560 X 1600) image. The performance presented here are for
color images. For a more accurate value I've averaged the value I got from the call of the function
for hundred times.
@@ -205,7 +205,7 @@ On-The-Fly RA | 93.7878 milliseconds
LUT function | 32.5759 milliseconds
We can conclude a couple of things. If possible, use the already made functions of OpenCV (instead
-reinventing these). The fastest method turns out to be the LUT function. This is because the OpenCV
+of reinventing these). The fastest method turns out to be the LUT function. This is because the OpenCV
library is multi-thread enabled via Intel Threaded Building Blocks. However, if you need to write a
simple image scan prefer the pointer method. The iterator is a safer bet, however quite slower.
Using the on-the-fly reference access method for full image scan is the most costly in debug mode.
diff --git a/doc/tutorials/core/how_to_use_OpenCV_parallel_for_/how_to_use_OpenCV_parallel_for_.markdown b/doc/tutorials/core/how_to_use_OpenCV_parallel_for_/how_to_use_OpenCV_parallel_for_.markdown
new file mode 100644
index 0000000..f37b81e
--- /dev/null
+++ b/doc/tutorials/core/how_to_use_OpenCV_parallel_for_/how_to_use_OpenCV_parallel_for_.markdown
@@ -0,0 +1,188 @@
+How to use the OpenCV parallel_for_ to parallelize your code {#tutorial_how_to_use_OpenCV_parallel_for_}
+==================================================================
+
+Goal
+----
+
+The goal of this tutorial is to show you how to use the OpenCV `parallel_for_` framework to easily
+parallelize your code. To illustrate the concept, we will write a program to draw a Mandelbrot set
+exploiting almost all the CPU load available.
+The full tutorial code is [here](https://github.com/opencv/opencv/blob/master/samples/cpp/tutorial_code/core/how_to_use_OpenCV_parallel_for_/how_to_use_OpenCV_parallel_for_.cpp).
+If you want more information about multithreading, you will have to refer to a reference book or course as this tutorial is intended
+to remain simple.
+
+Precondition
+----
+
+The first precondition is to have OpenCV built with a parallel framework.
+In OpenCV 3.2, the following parallel frameworks are available in that order:
+1. Intel Threading Building Blocks (3rdparty library, should be explicitly enabled)
+2. C= Parallel C/C++ Programming Language Extension (3rdparty library, should be explicitly enabled)
+3. OpenMP (integrated to compiler, should be explicitly enabled)
+4. APPLE GCD (system wide, used automatically (APPLE only))
+5. Windows RT concurrency (system wide, used automatically (Windows RT only))
+6. Windows concurrency (part of runtime, used automatically (Windows only - MSVC++ >= 10))
+7. Pthreads (if available)
+
+As you can see, several parallel frameworks can be used in the OpenCV library. Some parallel libraries
+are third party libraries and have to be explictly built and enabled in CMake (e.g. TBB, C=), others are
+automatically available with the platform (e.g. APPLE GCD) but chances are that you should be enable to
+have access to a parallel framework either directly or by enabling the option in CMake and rebuild the library.
+
+The second (weak) precondition is more related to the task you want to achieve as not all computations
+are suitable / can be adatapted to be run in a parallel way. To remain simple, tasks that can be splitted
+into multiple elementary operations with no memory dependency (no possible race condition) are easily
+parallelizable. Computer vision processing are often easily parallelizable as most of the time the processing of
+one pixel does not depend to the state of other pixels.
+
+Simple example: drawing a Mandelbrot set
+----
+
+We will use the example of drawing a Mandelbrot set to show how from a regular sequential code you can easily adapt
+the code to parallize the computation.
+
+Theory
+-----------
+
+The Mandelbrot set definition has been named in tribute to the mathematician Benoit Mandelbrot by the mathematician
+Adrien Douady. It has been famous outside of the mathematics field as the image representation is an example of a
+class of fractals, a mathematical set that exhibits a repeating pattern displayed at every scale (even more, a
+Mandelbrot set is self-similar as the whole shape can be repeatedly seen at different scale). For a more in-depth
+introduction, you can look at the corresponding [Wikipedia article](https://en.wikipedia.org/wiki/Mandelbrot_set).
+Here, we will just introduce the formula to draw the Mandelbrot set (from the mentioned Wikipedia article).
+
+> The Mandelbrot set is the set of values of \f$ c \f$ in the complex plane for which the orbit of 0 under iteration
+> of the quadratic map
+> \f[\begin{cases} z_0 = 0 \\ z_{n+1} = z_n^2 + c \end{cases}\f]
+> remains bounded.
+> That is, a complex number \f$ c \f$ is part of the Mandelbrot set if, when starting with \f$ z_0 = 0 \f$ and applying
+> the iteration repeatedly, the absolute value of \f$ z_n \f$ remains bounded however large \f$ n \f$ gets.
+> This can also be represented as
+> \f[\limsup_{n\to\infty}|z_{n+1}|\leqslant2\f]
+
+Pseudocode
+-----------
+
+A simple algorithm to generate a representation of the Mandelbrot set is called the
+["escape time algorithm"](https://en.wikipedia.org/wiki/Mandelbrot_set#Escape_time_algorithm).
+For each pixel in the rendered image, we test using the recurrence relation if the complex number is bounded or not
+under a maximum number of iterations. Pixels that do not belong to the Mandelbrot set will escape quickly whereas
+we assume that the pixel is in the set after a fixed maximum number of iterations. A high value of iterations will
+produce a more detailed image but the computation time will increase accordingly. We use the number of iterations
+needed to "escape" to depict the pixel value in the image.
+
+```
+For each pixel (Px, Py) on the screen, do:
+{
+ x0 = scaled x coordinate of pixel (scaled to lie in the Mandelbrot X scale (-2, 1))
+ y0 = scaled y coordinate of pixel (scaled to lie in the Mandelbrot Y scale (-1, 1))
+ x = 0.0
+ y = 0.0
+ iteration = 0
+ max_iteration = 1000
+ while (x*x + y*y < 2*2 AND iteration < max_iteration) {
+ xtemp = x*x - y*y + x0
+ y = 2*x*y + y0
+ x = xtemp
+ iteration = iteration + 1
+ }
+ color = palette[iteration]
+ plot(Px, Py, color)
+}
+```
+
+To relate between the pseudocode and the theory, we have:
+* \f$ z = x + iy \f$
+* \f$ z^2 = x^2 + i2xy - y^2 \f$
+* \f$ c = x_0 + iy_0 \f$
+
+
+
+On this figure, we recall that the real part of a complex number is on the x-axis and the imaginary part on the y-axis.
+You can see that the whole shape can be repeatedly visible if we zoom at particular locations.
+
+Implementation
+-----------
+
+Escape time algorithm implementation
+--------------------------
+
+ at snippet how_to_use_OpenCV_parallel_for_.cpp mandelbrot-escape-time-algorithm
+
+Here, we used the [`std::complex`](http://en.cppreference.com/w/cpp/numeric/complex) template class to represent a
+complex number. This function performs the test to check if the pixel is in set or not and returns the "escaped" iteration.
+
+Sequential Mandelbrot implementation
+--------------------------
+
+ at snippet how_to_use_OpenCV_parallel_for_.cpp mandelbrot-sequential
+
+In this implementation, we sequentially iterate over the pixels in the rendered image to perform the test to check if the
+pixel is likely to belong to the Mandelbrot set or not.
+
+Another thing to do is to transform the pixel coordinate into the Mandelbrot set space with:
+
+ at snippet how_to_use_OpenCV_parallel_for_.cpp mandelbrot-transformation
+
+Finally, to assign the grayscale value to the pixels, we use the following rule:
+* a pixel is black if it reaches the maximum number of iterations (pixel is assumed to be in the Mandelbrot set),
+* otherwise we assign a grayscale value depending on the escaped iteration and scaled to fit the grayscale range.
+
+ at snippet how_to_use_OpenCV_parallel_for_.cpp mandelbrot-grayscale-value
+
+Using a linear scale transformation is not enough to perceive the grayscale variation. To overcome this, we will boost
+the perception by using a square root scale transformation (borrowed from Jeremy D. Frens in his
+[blog post](http://www.programming-during-recess.net/2016/06/26/color-schemes-for-mandelbrot-sets/)):
+\f$ f \left( x \right) = \sqrt{\frac{x}{\text{maxIter}}} \times 255 \f$
+
+
+
+The green curve corresponds to a simple linear scale transformation, the blue one to a square root scale transformation
+and you can observe how the lowest values will be boosted when looking at the slope at these positions.
+
+Parallel Mandelbrot implementation
+--------------------------
+
+When looking at the sequential implementation, we can notice that each pixel is computed independently. To optimize the
+computation, we can perform multiple pixel calculations in parallel, by exploiting the multi-core architecture of modern
+processor. To achieve this easily, we will use the OpenCV @ref cv::parallel_for_ framework.
+
+ at snippet how_to_use_OpenCV_parallel_for_.cpp mandelbrot-parallel
+
+The first thing is to declare a custom class that inherits from @ref cv::ParallelLoopBody and to override the
+`virtual void operator ()(const cv::Range& range) const`.
+
+The range in the `operator ()` represents the subset of pixels that will be treated by an individual thread.
+This splitting is done automatically to distribute equally the computation load. We have to convert the pixel index coordinate
+to a 2D `[row, col]` coordinate. Also note that we have to keep a reference on the mat image to be able to modify in-place
+the image.
+
+The parallel execution is called with:
+
+ at snippet how_to_use_OpenCV_parallel_for_.cpp mandelbrot-parallel-call
+
+Here, the range represents the total number of operations to be executed, so the total number of pixels in the image.
+To set the number of threads, you can use: @ref cv::setNumThreads. You can also specify the number of splitting using the
+nstripes parameter in @ref cv::parallel_for_. For instance, if your processor has 4 threads, setting `cv::setNumThreads(2)`
+or setting `nstripes=2` should be the same as by default it will use all the processor threads available but will split the
+workload only on two threads.
+
+ at note
+C++ 11 standard allows to simplify the parallel implementation by get rid of the `ParallelMandelbrot` class and replacing it with lambda expression:
+
+ at snippet how_to_use_OpenCV_parallel_for_.cpp mandelbrot-parallel-call-cxx11
+
+Results
+-----------
+
+You can find the full tutorial code [here](https://github.com/opencv/opencv/blob/master/samples/cpp/tutorial_code/core/how_to_use_OpenCV_parallel_for_/how_to_use_OpenCV_parallel_for_.cpp).
+The performance of the parallel implementation depends of the type of CPU you have. For instance, on 4 cores / 8 threads
+CPU, you can expect a speed-up of around 6.9X. There are many factors to explain why we do not achieve a speed-up of almost 8X.
+Main reasons should be mostly due to:
+* the overhead to create and manage the threads,
+* background processes running in parallel,
+* the difference between 4 hardware cores with 2 logical threads for each core and 8 hardware cores.
+
+The resulting image produced by the tutorial code (you can modify the code to use more iterations and assign a pixel color
+depending on the escaped iteration and using a color palette to get more aesthetic images):
+
diff --git a/doc/tutorials/core/how_to_use_OpenCV_parallel_for_/images/how_to_use_OpenCV_parallel_for_640px-Mandelset_hires.png b/doc/tutorials/core/how_to_use_OpenCV_parallel_for_/images/how_to_use_OpenCV_parallel_for_640px-Mandelset_hires.png
new file mode 100644
index 0000000..2b63916
Binary files /dev/null and b/doc/tutorials/core/how_to_use_OpenCV_parallel_for_/images/how_to_use_OpenCV_parallel_for_640px-Mandelset_hires.png differ
diff --git a/doc/tutorials/core/how_to_use_OpenCV_parallel_for_/images/how_to_use_OpenCV_parallel_for_Mandelbrot.png b/doc/tutorials/core/how_to_use_OpenCV_parallel_for_/images/how_to_use_OpenCV_parallel_for_Mandelbrot.png
new file mode 100644
index 0000000..40eb579
Binary files /dev/null and b/doc/tutorials/core/how_to_use_OpenCV_parallel_for_/images/how_to_use_OpenCV_parallel_for_Mandelbrot.png differ
diff --git a/doc/tutorials/core/how_to_use_OpenCV_parallel_for_/images/how_to_use_OpenCV_parallel_for_sqrt_scale_transformation.png b/doc/tutorials/core/how_to_use_OpenCV_parallel_for_/images/how_to_use_OpenCV_parallel_for_sqrt_scale_transformation.png
new file mode 100644
index 0000000..00b727f
Binary files /dev/null and b/doc/tutorials/core/how_to_use_OpenCV_parallel_for_/images/how_to_use_OpenCV_parallel_for_sqrt_scale_transformation.png differ
diff --git a/doc/tutorials/core/mat_operations.markdown b/doc/tutorials/core/mat_operations.markdown
index 15a9869..3733d7d 100644
--- a/doc/tutorials/core/mat_operations.markdown
+++ b/doc/tutorials/core/mat_operations.markdown
@@ -14,7 +14,7 @@ Load an image from a file:
If you read a jpg file, a 3 channel image is created by default. If you need a grayscale image, use:
@code{.cpp}
- Mat img = imread(filename, 0);
+ Mat img = imread(filename, IMREAD_GRAYSCALE);
@endcode
@note format of the file is determined by its content (first few bytes) Save an image to a file:
diff --git a/doc/tutorials/core/mat_the_basic_image_container/mat_the_basic_image_container.markdown b/doc/tutorials/core/mat_the_basic_image_container/mat_the_basic_image_container.markdown
index 9e290b8..637e4bc 100644
--- a/doc/tutorials/core/mat_the_basic_image_container/mat_the_basic_image_container.markdown
+++ b/doc/tutorials/core/mat_the_basic_image_container/mat_the_basic_image_container.markdown
@@ -192,10 +192,12 @@ object in multiple ways:

-- For small matrices you may use comma separated initializers:
+- For small matrices you may use comma separated initializers or initializer lists (C++11 support is required in the last case):
@snippet mat_the_basic_image_container.cpp comma
+ @snippet mat_the_basic_image_container.cpp list
+

- Create a new header for an existing *Mat* object and @ref cv::Mat::clone or @ref cv::Mat::copyTo it.
diff --git a/doc/tutorials/core/table_of_content_core.markdown b/doc/tutorials/core/table_of_content_core.markdown
index 70d9c81..2b9afb8 100644
--- a/doc/tutorials/core/table_of_content_core.markdown
+++ b/doc/tutorials/core/table_of_content_core.markdown
@@ -106,3 +106,10 @@ understanding how to manipulate the images on a pixel level.
*Author:* Elena Gvozdeva
You will see how to use the IPP Async with OpenCV.
+
+
+- @subpage tutorial_how_to_use_OpenCV_parallel_for_
+
+ *Compatibility:* \>= OpenCV 2.4.3
+
+ You will see how to use the OpenCV parallel_for_ to easily parallelize your code.
diff --git a/doc/tutorials/dnn/dnn_googlenet/dnn_googlenet.markdown b/doc/tutorials/dnn/dnn_googlenet/dnn_googlenet.markdown
new file mode 100644
index 0000000..83fef32
--- /dev/null
+++ b/doc/tutorials/dnn/dnn_googlenet/dnn_googlenet.markdown
@@ -0,0 +1,66 @@
+Load Caffe framework models {#tutorial_dnn_googlenet}
+===========================
+
+Introduction
+------------
+
+In this tutorial you will learn how to use opencv_dnn module for image classification by using
+GoogLeNet trained network from [Caffe model zoo](http://caffe.berkeleyvision.org/model_zoo.html).
+
+We will demonstrate results of this example on the following picture.
+
+
+Source Code
+-----------
+
+We will be using snippets from the example application, that can be downloaded [here](https://github.com/opencv/opencv/blob/master/samples/dnn/caffe_googlenet.cpp).
+
+ at include dnn/caffe_googlenet.cpp
+
+Explanation
+-----------
+
+-# Firstly, download GoogLeNet model files:
+ [bvlc_googlenet.prototxt ](https://raw.githubusercontent.com/opencv/opencv/master/samples/data/dnn/bvlc_googlenet.prototxt) and
+ [bvlc_googlenet.caffemodel](http://dl.caffe.berkeleyvision.org/bvlc_googlenet.caffemodel)
+
+ Also you need file with names of [ILSVRC2012](http://image-net.org/challenges/LSVRC/2012/browse-synsets) classes:
+ [synset_words.txt](https://raw.githubusercontent.com/opencv/opencv/master/samples/data/dnn/synset_words.txt).
+
+ Put these files into working dir of this program example.
+
+-# Read and initialize network using path to .prototxt and .caffemodel files
+ @snippet dnn/caffe_googlenet.cpp Read and initialize network
+
+-# Check that network was read successfully
+ @snippet dnn/caffe_googlenet.cpp Check that network was read successfully
+
+-# Read input image and convert to the blob, acceptable by GoogleNet
+ @snippet dnn/caffe_googlenet.cpp Prepare blob
+ Firstly, we resize the image and change its channel sequence order.
+
+ Now image is actually a 3-dimensional array with 224x224x3 shape.
+
+ Next, we convert the image to 4-dimensional blob (so-called batch) with 1x3x224x224 shape by using special cv::dnn::blobFromImages constructor.
+
+-# Pass the blob to the network
+ @snippet dnn/caffe_googlenet.cpp Set input blob
+ In bvlc_googlenet.prototxt the network input blob named as "data", therefore this blob labeled as ".data" in opencv_dnn API.
+
+ Other blobs labeled as "name_of_layer.name_of_layer_output".
+
+-# Make forward pass
+ @snippet dnn/caffe_googlenet.cpp Make forward pass
+ During the forward pass output of each network layer is computed, but in this example we need output from "prob" layer only.
+
+-# Determine the best class
+ @snippet dnn/caffe_googlenet.cpp Gather output
+ We put the output of "prob" layer, which contain probabilities for each of 1000 ILSVRC2012 image classes, to the `prob` blob.
+ And find the index of element with maximal value in this one. This index correspond to the class of the image.
+
+-# Print results
+ @snippet dnn/caffe_googlenet.cpp Print results
+ For our image we get:
+> Best class: #812 'space shuttle'
+>
+> Probability: 99.6378%
diff --git a/doc/tutorials/dnn/dnn_halide/dnn_halide.markdown b/doc/tutorials/dnn/dnn_halide/dnn_halide.markdown
new file mode 100644
index 0000000..a373a7f
--- /dev/null
+++ b/doc/tutorials/dnn/dnn_halide/dnn_halide.markdown
@@ -0,0 +1,130 @@
+# How to enable Halide backend for improve efficiency {#tutorial_dnn_halide}
+
+## Introduction
+This tutorial guidelines how to run your models in OpenCV deep learning module
+using Halide language backend. Halide is an open-source project that let us
+write image processing algorithms in well-readable format, schedule computations
+according to specific device and evaluate it with a quite good efficiency.
+
+An official website of the Halide project: http://halide-lang.org/.
+
+## Efficiency comparison
+Measured on Intel® Core™ i7-6700K CPU @ 4.00GHz x 8.
+
+Single image forward pass (in milliseconds):
+
+| Architecture | MKL backend | Halide backend | Speed Up ratio |
+|-----------------:|------------:|---------------:|---------------:|
+| AlexNet | 16.55 | 22.38 | x0.73 |
+| ResNet-50 | 63.69 | 73.91 | x0.86 |
+| SqueezeNet v1.1 | 10.11 | 8.21 | x1.23 |
+| Inception-5h | 35.38 | 37.06 | x0.95 |
+| ENet @ 3x512x256 | 82.26 | 41.21 | x1.99 |
+
+Scheduling directives might be found @ [opencv_extra/testdata/dnn](https://github.com/opencv/opencv_extra/tree/master/testdata/dnn).
+
+## Requirements
+### LLVM compiler
+
+ at note LLVM compilation might take a long time.
+
+- Download LLVM source code from http://releases.llvm.org/4.0.0/llvm-4.0.0.src.tar.xz.
+Unpack it. Let **llvm_root** is a root directory of source code.
+
+- Create directory **llvm_root**/tools/clang
+
+- Download Clang with the same version as LLVM. In our case it will be from
+http://releases.llvm.org/4.0.0/cfe-4.0.0.src.tar.xz. Unpack it into
+**llvm_root**/tools/clang. Note that it should be a root for Clang source code.
+
+- Build LLVM on Linux
+ at code
+cd llvm_root
+mkdir build && cd build
+cmake -DLLVM_ENABLE_TERMINFO=OFF -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_ENABLE_ASSERTIONS=ON -DCMAKE_BUILD_TYPE=Release ..
+make -j4
+ at endcode
+
+- Build LLVM on Windows (Developer Command Prompt)
+ at code
+mkdir \\path-to-llvm-build\\ && cd \\path-to-llvm-build\\
+cmake.exe -DLLVM_ENABLE_TERMINFO=OFF -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_ASSERTIONS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=\\path-to-llvm-install\\ -G "Visual Studio 14 Win64" \\path-to-llvm-src\\
+MSBuild.exe /m:4 /t:Build /p:Configuration=Release .\\INSTALL.vcxproj
+ at endcode
+
+ at note `\\path-to-llvm-build\\` and `\\path-to-llvm-install\\` are different directories.
+
+### Halide language.
+
+- Download source code from GitHub repository, https://github.com/halide/Halide
+or using git. The root directory will be a **halide_root**.
+ at code
+git clone https://github.com/halide/Halide.git
+ at endcode
+
+- Build Halide on Linux
+ at code
+cd halide_root
+mkdir build && cd build
+cmake -DLLVM_DIR=llvm_root/build/lib/cmake/llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_VERSION=40 -DWITH_TESTS=OFF -DWITH_APPS=OFF -DWITH_TUTORIALS=OFF ..
+make -j4
+ at endcode
+
+- Build Halide on Windows (Developer Command Prompt)
+ at code
+cd halide_root
+mkdir build && cd build
+cmake.exe -DLLVM_DIR=\\path-to-llvm-install\\lib\\cmake\\llvm -DLLVM_VERSION=40 -DWITH_TESTS=OFF -DWITH_APPS=OFF -DWITH_TUTORIALS=OFF -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 14 Win64" ..
+MSBuild.exe /m:4 /t:Build /p:Configuration=Release .\\ALL_BUILD.vcxproj
+ at endcode
+
+## Build OpenCV with Halide backend
+When you build OpenCV add the following configuration flags:
+
+- `WITH_HALIDE` - enable Halide linkage
+
+- `HALIDE_ROOT_DIR` - path to Halide build directory
+
+## Sample
+
+ at include dnn/squeezenet_halide.cpp
+
+## Explanation
+Download Caffe model from SqueezeNet repository: [train_val.prototxt](https://github.com/DeepScale/SqueezeNet/blob/master/SqueezeNet_v1.1/train_val.prototxt) and [squeezenet_v1.1.caffemodel](https://github.com/DeepScale/SqueezeNet/blob/master/SqueezeNet_v1.1/squeezenet_v1.1.caffemodel).
+
+Also you need file with names of [ILSVRC2012](http://image-net.org/challenges/LSVRC/2012/browse-synsets) classes:
+[synset_words.txt](https://raw.githubusercontent.com/opencv/opencv/master/samples/data/dnn/synset_words.txt).
+
+Put these files into working dir of this program example.
+
+-# Read and initialize network using path to .prototxt and .caffemodel files
+ at snippet dnn/squeezenet_halide.cpp Read and initialize network
+
+-# Check that network was read successfully
+ at snippet dnn/squeezenet_halide.cpp Check that network was read successfully
+
+-# Read input image and convert to the 4-dimensional blob, acceptable by SqueezeNet v1.1
+ at snippet dnn/squeezenet_halide.cpp Prepare blob
+
+-# Pass the blob to the network
+ at snippet dnn/squeezenet_halide.cpp Set input blob
+
+-# Enable Halide backend for layers where it is implemented
+ at snippet dnn/squeezenet_halide.cpp Enable Halide backend
+
+-# Make forward pass
+ at snippet dnn/squeezenet_halide.cpp Make forward pass
+Remember that the first forward pass after initialization require quite more
+time that the next ones. It's because of runtime compilation of Halide pipelines
+at the first invocation.
+
+-# Determine the best class
+ at snippet dnn/squeezenet_halide.cpp Determine the best class
+
+-# Print results
+ at snippet dnn/squeezenet_halide.cpp Print results
+For our image we get:
+
+> Best class: #812 'space shuttle'
+>
+> Probability: 97.9812%
diff --git a/doc/tutorials/dnn/dnn_halide_scheduling/dnn_halide_scheduling.markdown b/doc/tutorials/dnn/dnn_halide_scheduling/dnn_halide_scheduling.markdown
new file mode 100644
index 0000000..a43ab63
--- /dev/null
+++ b/doc/tutorials/dnn/dnn_halide_scheduling/dnn_halide_scheduling.markdown
@@ -0,0 +1,82 @@
+# How to schedule your network for Halide backend {#tutorial_dnn_halide_scheduling}
+
+## Introduction
+Halide code is the same for every device we use. But for achieving the satisfied
+efficiency we should schedule computations properly. In this tutorial we describe
+the ways to schedule your networks using Halide backend in OpenCV deep learning module.
+
+For better understanding of Halide scheduling you might want to read tutorials @ http://halide-lang.org/tutorials.
+
+If it's your first meeting with Halide in OpenCV, we recommend to start from @ref tutorial_dnn_halide.
+
+## Configuration files
+You can schedule computations of Halide pipeline by writing textual configuration files.
+It means that you can easily vectorize, parallelize and manage loops order of
+layers computation. Pass path to file with scheduling directives for specific
+device into ```cv::dnn::Net::setHalideScheduler``` before the first ```cv::dnn::Net::forward``` call.
+
+Scheduling configuration files represented as YAML files where each node is a
+scheduled function or a scheduling directive.
+ at code
+relu1:
+ reorder: [x, c, y]
+ split: { y: 2, c: 8 }
+ parallel: [yo, co]
+ unroll: yi
+ vectorize: { x: 4 }
+conv1_constant_exterior:
+ compute_at: { relu1: yi }
+ at endcode
+
+Considered use variables `n` for batch dimension, `c` for channels,
+`y` for rows and `x` for columns. For variables after split are used names
+with the same prefix but `o` and `i` suffixes for outer and inner variables
+correspondingly. In example, for variable `x` in range `[0, 10)` directive
+`split: { x: 2 }` gives new ones `xo` in range `[0, 5)` and `xi` in range `[0, 2)`.
+Variable name `x` is no longer available in the same scheduling node.
+
+You can find scheduling examples at [opencv_extra/testdata/dnn](https://github.com/opencv/opencv_extra/tree/master/testdata/dnn)
+and use it for schedule your networks.
+
+## Layers fusing
+Thanks to layers fusing we can schedule only the top layers of fused sets.
+Because for every output value we use the fused formula.
+In example, if you have three layers Convolution + Scale + ReLU one by one,
+ at code
+conv(x, y, c, n) = sum(...) + bias(c);
+scale(x, y, c, n) = conv(x, y, c, n) * weights(c);
+relu(x, y, c, n) = max(scale(x, y, c, n), 0);
+ at endcode
+
+fused function is something like
+ at code
+relu(x, y, c, n) = max((sum(...) + bias(c)) * weights(c), 0);
+ at endcode
+
+So only function called `relu` require scheduling.
+
+## Scheduling patterns
+Sometimes networks built using blocked structure that means some layer are
+identical or quite similar. If you want to apply the same scheduling for
+different layers accurate to tiling or vectorization factors, define scheduling
+patterns in section `patterns` at the beginning of scheduling file.
+Also, your patters may use some parametric variables.
+ at code
+# At the beginning of the file
+patterns:
+ fully_connected:
+ split: { c: c_split }
+ fuse: { src: [x, y, co], dst: block }
+ parallel: block
+ vectorize: { ci: c_split }
+# Somewhere below
+fc8:
+ pattern: fully_connected
+ params: { c_split: 8 }
+ at endcode
+
+## Automatic scheduling
+You can let DNN to schedule layers automatically. Just skip call of ```cv::dnn::Net::setHalideScheduler```. Sometimes it might be even more efficient than manual scheduling.
+But if specific layers require be scheduled manually, you would be able to
+mix both manual and automatic scheduling ways. Write scheduling file
+and skip layers that you want to be scheduled automatically.
diff --git a/contrib/modules/dnn/samples/space_shuttle.jpg b/doc/tutorials/dnn/images/space_shuttle.jpg
similarity index 100%
rename from contrib/modules/dnn/samples/space_shuttle.jpg
rename to doc/tutorials/dnn/images/space_shuttle.jpg
diff --git a/doc/tutorials/dnn/table_of_content_dnn.markdown b/doc/tutorials/dnn/table_of_content_dnn.markdown
new file mode 100644
index 0000000..6931317
--- /dev/null
+++ b/doc/tutorials/dnn/table_of_content_dnn.markdown
@@ -0,0 +1,26 @@
+Deep Neural Networks (dnn module) {#tutorial_table_of_content_dnn}
+=====================================
+
+- @subpage tutorial_dnn_googlenet
+
+ *Compatibility:* \> OpenCV 3.3
+
+ *Author:* Vitaliy Lyudvichenko
+
+ In this tutorial you will learn how to use opencv_dnn module for image classification by using GoogLeNet trained network from Caffe model zoo.
+
+- @subpage tutorial_dnn_halide
+
+ *Compatibility:* \> OpenCV 3.3
+
+ *Author:* Dmitry Kurtaev
+
+ This tutorial guidelines how to run your models in OpenCV deep learning module using Halide language backend
+
+- @subpage tutorial_dnn_halide_scheduling
+
+ *Compatibility:* \> OpenCV 3.3
+
+ *Author:* Dmitry Kurtaev
+
+ In this tutorial we describe the ways to schedule your networks using Halide backend in OpenCV deep learning module.
\ No newline at end of file
diff --git a/doc/tutorials/features2d/trackingmotion/harris_detector/harris_detector.markdown b/doc/tutorials/features2d/trackingmotion/harris_detector/harris_detector.markdown
index a36f219..b1b8b67 100644
--- a/doc/tutorials/features2d/trackingmotion/harris_detector/harris_detector.markdown
+++ b/doc/tutorials/features2d/trackingmotion/harris_detector/harris_detector.markdown
@@ -43,7 +43,7 @@ In this tutorial we will study the *corner* features, specifically.
- Let's look for corners. Since corners represents a variation in the gradient in the image, we
will look for this "variation".
- Consider a grayscale image \f$I\f$. We are going to sweep a window \f$w(x,y)\f$ (with displacements \f$u\f$
- in the x direction and \f$v\f$ in the right direction) \f$I\f$ and will calculate the variation of
+ in the x direction and \f$v\f$ in the y direction) \f$I\f$ and will calculate the variation of
intensity.
\f[E(u,v) = \sum _{x,y} w(x,y)[ I(x+u,y+v) - I(x,y)]^{2}\f]
diff --git a/doc/tutorials/gpu/gpu-basics-similarity/gpu_basics_similarity.markdown b/doc/tutorials/gpu/gpu-basics-similarity/gpu_basics_similarity.markdown
index b229896..6dd8194 100644
--- a/doc/tutorials/gpu/gpu-basics-similarity/gpu_basics_similarity.markdown
+++ b/doc/tutorials/gpu/gpu-basics-similarity/gpu_basics_similarity.markdown
@@ -6,14 +6,14 @@ Goal
----
In the @ref tutorial_video_input_psnr_ssim tutorial I already presented the PSNR and SSIM methods for checking
-the similarity between the two images. And as you could see there performing these takes quite some
-time, especially in the case of the SSIM. However, if the performance numbers of an OpenCV
+the similarity between the two images. And as you could see, the execution process takes quite some
+time , especially in the case of the SSIM. However, if the performance numbers of an OpenCV
implementation for the CPU do not satisfy you and you happen to have an NVidia CUDA GPU device in
-your system all is not lost. You may try to port or write your algorithm for the video card.
+your system, all is not lost. You may try to port or write your owm algorithm for the video card.
This tutorial will give a good grasp on how to approach coding by using the GPU module of OpenCV. As
a prerequisite you should already know how to handle the core, highgui and imgproc modules. So, our
-goals are:
+main goals are:
- What's different compared to the CPU?
- Create the GPU code for the PSNR and SSIM
@@ -22,8 +22,8 @@ goals are:
The source code
---------------
-You may also find the source code and these video file in the
-`samples/cpp/tutorial_code/gpu/gpu-basics-similarity/gpu-basics-similarity` folder of the OpenCV
+You may also find the source code and the video file in the
+`samples/cpp/tutorial_code/gpu/gpu-basics-similarity/gpu-basics-similarity` directory of the OpenCV
source library or download it from [here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/gpu/gpu-basics-similarity/gpu-basics-similarity.cpp).
The full source code is quite long (due to the controlling of the application via the command line
arguments and performance measurement). Therefore, to avoid cluttering up these sections with those
@@ -37,7 +37,7 @@ better).
@snippet samples/cpp/tutorial_code/gpu/gpu-basics-similarity/gpu-basics-similarity.cpp psnr
@snippet samples/cpp/tutorial_code/gpu/gpu-basics-similarity/gpu-basics-similarity.cpp getpsnropt
-The SSIM returns the MSSIM of the images. This is too a float number between zero and one (higher is
+The SSIM returns the MSSIM of the images. This is too a floating point number between zero and one (higher is
better), however we have one for each channel. Therefore, we return a *Scalar* OpenCV data
structure:
@@ -49,13 +49,13 @@ structure:
How to do it? - The GPU
-----------------------
-Now as you can see we have three types of functions for each operation. One for the CPU and two for
+As see above, we have three types of functions for each operation. One for the CPU and two for
the GPU. The reason I made two for the GPU is too illustrate that often simple porting your CPU to
GPU will actually make it slower. If you want some performance gain you will need to remember a few
-rules, whose I'm going to detail later on.
+rules, for which I will go into detail later on.
The development of the GPU module was made so that it resembles as much as possible its CPU
-counterpart. This is to make porting easy. The first thing you need to do before writing any code is
+counterpart. This makes the porting process easier. The first thing you need to do before writing any code is
to link the GPU module to your project, and include the header file for the module. All the
functions and data structures of the GPU are in a *gpu* sub namespace of the *cv* namespace. You may
add this to the default one via the *use namespace* keyword, or mark it everywhere explicitly via
@@ -64,25 +64,25 @@ the cv:: to avoid confusion. I'll do the later.
#include <opencv2/gpu.hpp> // GPU structures and methods
@endcode
-GPU stands for "graphics processing unit". It was originally build to render graphical
+GPU stands for "graphics processing unit". It was originally built to render graphical
scenes. These scenes somehow build on a lot of data. Nevertheless, these aren't all dependent one
from another in a sequential way and as it is possible a parallel processing of them. Due to this a
GPU will contain multiple smaller processing units. These aren't the state of the art processors and
on a one on one test with a CPU it will fall behind. However, its strength lies in its numbers. In
the last years there has been an increasing trend to harvest these massive parallel powers of the
-GPU in non-graphical scene rendering too. This gave birth to the general-purpose computation on
+GPU in non-graphical scenes; rendering as well. This gave birth to the general-purpose computation on
graphics processing units (GPGPU).
The GPU has its own memory. When you read data from the hard drive with OpenCV into a *Mat* object
that takes place in your systems memory. The CPU works somehow directly on this (via its cache),
-however the GPU cannot. He has too transferred the information he will use for calculations from the
-system memory to its own. This is done via an upload process and takes time. In the end the result
-will have to be downloaded back to your system memory for your CPU to see it and use it. Porting
+however the GPU cannot. It has to transfer the information required for calculations from the
+system memory to its own. This is done via an upload process and is time consuming. In the end the result
+will have to be downloaded back to your system memory for your CPU to see and use it. Porting
small functions to GPU is not recommended as the upload/download time will be larger than the amount
you gain by a parallel execution.
Mat objects are stored only in the system memory (or the CPU cache). For getting an OpenCV matrix to
-the GPU you'll need to use its GPU counterpart @ref cv::cuda::GpuMat . It works similar to the Mat with a
+the GPU you'll need to use its GPU counterpart @ref cv::cuda::GpuMat. It works similar to the Mat with a
2D only limitation and no reference returning for its functions (cannot mix GPU references with CPU
ones). To upload a Mat object to the GPU you need to call the upload function after creating an
instance of the class. To download you may use simple assignment to a Mat object or use the download
@@ -103,17 +103,17 @@ with the source code.
Another thing to keep in mind is that not for all channel numbers you can make efficient algorithms
on the GPU. Generally, I found that the input images for the GPU images need to be either one or
four channel ones and one of the char or float type for the item sizes. No double support on the
-GPU, sorry. Passing other types of objects for some functions will result in an exception thrown,
+GPU, sorry. Passing other types of objects for some functions will result in an exception throw,
and an error message on the error output. The documentation details in most of the places the types
accepted for the inputs. If you have three channel images as an input you can do two things: either
-adds a new channel (and use char elements) or split up the image and call the function for each
-image. The first one isn't really recommended as you waste memory.
+add a new channel (and use char elements) or split up the image and call the function for each
+image. The first one isn't really recommended as this wastes memory.
-For some functions, where the position of the elements (neighbor items) doesn't matter quick
-solution is to just reshape it into a single channel image. This is the case for the PSNR
+For some functions, where the position of the elements (neighbor items) doesn't matter, the quick
+solution is to reshape it into a single channel image. This is the case for the PSNR
implementation where for the *absdiff* method the value of the neighbors is not important. However,
for the *GaussianBlur* this isn't an option and such need to use the split method for the SSIM. With
-this knowledge you can already make a GPU viable code (like mine GPU one) and run it. You'll be
+this knowledge you can make a GPU viable code (like mine GPU one) and run it. You'll be
surprised to see that it might turn out slower than your CPU implementation.
Optimization
@@ -147,15 +147,15 @@ introduce asynchronous OpenCV GPU calls too with the help of the @ref cv::cuda::
Now you access these local parameters as: *b.gI1*, *b.buf* and so on. The GpuMat will only
reallocate itself on a new call if the new matrix size is different from the previous one.
--# Avoid unnecessary function data transfers. Any small data transfer will be significant one once
- you go to the GPU. Therefore, if possible make all calculations in-place (in other words do not
+-# Avoid unnecessary function data transfers. Any small data transfer will be significant once
+ you go to the GPU. Therefore, if possible, make all calculations in-place (in other words do not
create new memory objects - for reasons explained at the previous point). For example, although
expressing arithmetical operations may be easier to express in one line formulas, it will be
slower. In case of the SSIM at one point I need to calculate:
@code{.cpp}
b.t1 = 2 * b.mu1_mu2 + C1;
@endcode
- Although the upper call will succeed observe that there is a hidden data transfer present.
+ Although the upper call will succeed, observe that there is a hidden data transfer present.
Before it makes the addition it needs to store somewhere the multiplication. Therefore, it will
create a local matrix in the background, add to that the *C1* value and finally assign that to
*t1*. To avoid this we use the gpu functions, instead of the arithmetic operators:
@@ -163,17 +163,17 @@ introduce asynchronous OpenCV GPU calls too with the help of the @ref cv::cuda::
gpu::multiply(b.mu1_mu2, 2, b.t1); //b.t1 = 2 * b.mu1_mu2 + C1;
gpu::add(b.t1, C1, b.t1);
@endcode
--# Use asynchronous calls (the @ref cv::cuda::Stream ). By default whenever you call a gpu function
+-# Use asynchronous calls (the @ref cv::cuda::Stream ). By default whenever you call a GPU function
it will wait for the call to finish and return with the result afterwards. However, it is
- possible to make asynchronous calls, meaning it will call for the operation execution, make the
+ possible to make asynchronous calls, meaning it will call for the operation execution, making the
costly data allocations for the algorithm and return back right away. Now you can call another
- function if you wish to do so. For the MSSIM this is a small optimization point. In our default
- implementation we split up the image into channels and call then for each channel the gpu
+ function, if you wish. For the MSSIM this is a small optimization point. In our default
+ implementation we split up the image into channels and call them for each channel the GPU
functions. A small degree of parallelization is possible with the stream. By using a stream we
can make the data allocation, upload operations while the GPU is already executing a given
- method. For example we need to upload two images. We queue these one after another and call
- already the function that processes it. The functions will wait for the upload to finish,
- however while that happens makes the output buffer allocations for the function to be executed
+ method. For example, we need to upload two images. We queue these one after another and call
+ the function that processes it. The functions will wait for the upload to finish,
+ however while this happens it makes the output buffer allocations for the function to be executed
next.
@code{.cpp}
gpu::Stream stream;
@@ -187,7 +187,7 @@ introduce asynchronous OpenCV GPU calls too with the help of the @ref cv::cuda::
Result and conclusion
---------------------
-On an Intel P8700 laptop CPU paired with a low end NVidia GT220M here are the performance numbers:
+On an Intel P8700 laptop CPU paired with a low end NVidia GT220M, here are the performance numbers:
@code
Time of PSNR CPU (averaged for 10 runs): 41.4122 milliseconds. With result of: 19.2506
Time of PSNR GPU (averaged for 10 runs): 158.977 milliseconds. With result of: 19.2506
diff --git a/doc/tutorials/gpu/gpu-thrust-interop/gpu_thrust_interop.markdown b/doc/tutorials/gpu/gpu-thrust-interop/gpu_thrust_interop.markdown
index 64f763b..0332808 100644
--- a/doc/tutorials/gpu/gpu-thrust-interop/gpu_thrust_interop.markdown
+++ b/doc/tutorials/gpu/gpu-thrust-interop/gpu_thrust_interop.markdown
@@ -1,4 +1,4 @@
-Using a cv::cuda::GpuMat with thrust
+Using a cv::cuda::GpuMat with thrust {#tutorial_gpu_thrust_interop}
===========================================
Goal
@@ -67,4 +67,4 @@ Next we will determine how many values are greater than 0 by using thrust::count
@snippet samples/cpp/tutorial_code/gpu/gpu-thrust-interop/main.cu pred_greater
We will use those results to create an output buffer for storing the copied values, we will then use copy_if with the same predicate to populate the output buffer.
-Lastly we will download the values into a CPU mat for viewing.
\ No newline at end of file
+Lastly we will download the values into a CPU mat for viewing.
diff --git a/doc/tutorials/gpu/table_of_content_gpu.markdown b/doc/tutorials/gpu/table_of_content_gpu.markdown
index fe4e2c8..163f5e3 100644
--- a/doc/tutorials/gpu/table_of_content_gpu.markdown
+++ b/doc/tutorials/gpu/table_of_content_gpu.markdown
@@ -13,3 +13,10 @@ run the OpenCV algorithms.
This will give a good grasp on how to approach coding on the GPU module, once you already know
how to handle the other modules. As a test case it will port the similarity methods from the
tutorial @ref tutorial_video_input_psnr_ssim to the GPU.
+
+- @subpage tutorial_gpu_thrust_interop
+
+ *Compatibility:* \>= OpenCV 3.0
+
+ This tutorial will show you how to wrap a GpuMat into a thrust iterator in order to be able to
+ use the functions in the thrust library.
diff --git a/doc/tutorials/highgui/trackbar/trackbar.markdown b/doc/tutorials/highgui/trackbar/trackbar.markdown
index b39572c..1389871 100644
--- a/doc/tutorials/highgui/trackbar/trackbar.markdown
+++ b/doc/tutorials/highgui/trackbar/trackbar.markdown
@@ -68,7 +68,7 @@ Result

- As a manner of practice, you can also add two trackbars for the program made in
- @ref tutorial_basic_linear_transform. One trackbar to set \f$\alpha\f$ and another for \f$\beta\f$. The output might
+ @ref tutorial_basic_linear_transform. One trackbar to set \f$\alpha\f$ and another for set \f$\beta\f$. The output might
look like:

diff --git a/doc/tutorials/imgproc/erosion_dilatation/erosion_dilatation.markdown b/doc/tutorials/imgproc/erosion_dilatation/erosion_dilatation.markdown
index 947bd6f..515e6b2 100644
--- a/doc/tutorials/imgproc/erosion_dilatation/erosion_dilatation.markdown
+++ b/doc/tutorials/imgproc/erosion_dilatation/erosion_dilatation.markdown
@@ -6,12 +6,12 @@ Goal
In this tutorial you will learn how to:
-- Apply two very common morphology operators: Dilation and Erosion. For this purpose, you will use
+- Apply two very common morphological operators: Erosion and Dilation. For this purpose, you will use
the following OpenCV functions:
- @ref cv::erode
- @ref cv::dilate
-Cool Theory
+Interesting fact
-----------
@note The explanation below belongs to the book **Learning OpenCV** by Bradski and Kaehler.
@@ -21,7 +21,7 @@ Morphological Operations
- In short: A set of operations that process images based on shapes. Morphological operations
apply a *structuring element* to an input image and generate an output image.
-- The most basic morphological operations are two: Erosion and Dilation. They have a wide array of
+- The most basic morphological operations are: Erosion and Dilation. They have a wide array of
uses, i.e. :
- Removing noise
- Isolation of individual elements and joining disparate elements in an image.
@@ -32,19 +32,19 @@ Morphological Operations
### Dilation
-- This operations consists of convoluting an image \f$A\f$ with some kernel (\f$B\f$), which can have any
+- This operations consists of convolving an image \f$A\f$ with some kernel (\f$B\f$), which can have any
shape or size, usually a square or circle.
- The kernel \f$B\f$ has a defined *anchor point*, usually being the center of the kernel.
- As the kernel \f$B\f$ is scanned over the image, we compute the maximal pixel value overlapped by
\f$B\f$ and replace the image pixel in the anchor point position with that maximal value. As you can
deduce, this maximizing operation causes bright regions within an image to "grow" (therefore the
- name *dilation*). Take as an example the image above. Applying dilation we can get:
+ name *dilation*). Take the above image as an example. Applying dilation we can get:

The background (bright) dilates around the black regions of the letter.
-To better grasp the idea and avoid possible confusion, in this another example we have inverted the original
+To better grasp the idea and avoid possible confusion, in this other example we have inverted the original
image such as the object in white is now the letter. We have performed two dilatations with a rectangular
structuring element of size `3x3`.
@@ -54,8 +54,8 @@ The dilatation makes the object in white bigger.
### Erosion
-- This operation is the sister of dilation. What this does is to compute a local minimum over the
- area of the kernel.
+- This operation is the sister of dilation. It computes a local minimum over the
+ area of given kernel.
- As the kernel \f$B\f$ is scanned over the image, we compute the minimal pixel value overlapped by
\f$B\f$ and replace the image pixel under the anchor point with that minimal value.
- Analagously to the example for dilation, we can apply the erosion operator to the original image
@@ -64,7 +64,7 @@ The dilatation makes the object in white bigger.

-In the same manner, the corresponding image resulting of the erosion operation on the inverted original image (two erosions
+In similar manner, the corresponding image results by applying erosion operation on the inverted original image (two erosions
with a rectangular structuring element of size `3x3`):

@@ -74,14 +74,14 @@ The erosion makes the object in white smaller.
Code
----
-This tutorial code's is shown lines below. You can also download it from
+This tutorial's code is shown below. You can also download it
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ImgProc/Morphology_1.cpp)
@include samples/cpp/tutorial_code/ImgProc/Morphology_1.cpp
Explanation
-----------
--# Most of the stuff shown is known by you (if you have any doubt, please refer to the tutorials in
+-# Most of the material shown here is trivial (if you have any doubt, please refer to the tutorials in
previous sections). Let's check the general structure of the program:
- Load an image (can be BGR or grayscale)
@@ -118,8 +118,8 @@ Explanation
- That is all. We are ready to perform the erosion of our image.
@note Additionally, there is another parameter that allows you to perform multiple erosions
-(iterations) at once. We are not using it in this simple tutorial, though. You can check out the
-Reference for more details.
+(iterations) at once. However, We haven't used it in this simple tutorial. You can check out the
+reference for more details.
-# **dilation:**
diff --git a/doc/tutorials/imgproc/histograms/template_matching/template_matching.markdown b/doc/tutorials/imgproc/histograms/template_matching/template_matching.markdown
index 1dc3ca8..1189923 100644
--- a/doc/tutorials/imgproc/histograms/template_matching/template_matching.markdown
+++ b/doc/tutorials/imgproc/histograms/template_matching/template_matching.markdown
@@ -1,14 +1,17 @@
Template Matching {#tutorial_template_matching}
=================
+ at prev_tutorial{tutorial_back_projection}
+ at next_tutorial{tutorial_find_contours}
+
Goal
----
In this tutorial you will learn how to:
-- Use the OpenCV function @ref cv::matchTemplate to search for matches between an image patch and
+- Use the OpenCV function **matchTemplate()** to search for matches between an image patch and
an input image
-- Use the OpenCV function @ref cv::minMaxLoc to find the maximum and minimum values (as well as
+- Use the OpenCV function **minMaxLoc()** to find the maximum and minimum values (as well as
their positions) in a given array.
Theory
@@ -42,7 +45,7 @@ that should be used to find the match.
- By **sliding**, we mean moving the patch one pixel at a time (left to right, up to down). At
each location, a metric is calculated so it represents how "good" or "bad" the match at that
location is (or how similar the patch is to that particular area of the source image).
-- For each location of **T** over **I**, you *store* the metric in the *result matrix* **(R)**.
+- For each location of **T** over **I**, you *store* the metric in the *result matrix* **R**.
Each location \f$(x,y)\f$ in **R** contains the match metric:

@@ -51,9 +54,8 @@ that should be used to find the match.
The brightest locations indicate the highest matches. As you can see, the location marked by the
red circle is probably the one with the highest value, so that location (the rectangle formed by
that point as a corner and width and height equal to the patch image) is considered the match.
-
-- In practice, we use the function @ref cv::minMaxLoc to locate the highest value (or lower,
- depending of the type of matching method) in the *R* matrix.
+- In practice, we locate the highest value (or lower, depending of the type of matching method) in
+ the *R* matrix, using the function **minMaxLoc()**
### How does the mask work?
- If masking is needed for the match, three components are required:
@@ -81,7 +83,7 @@ that should be used to find the match.
### Which are the matching methods available in OpenCV?
-Good question. OpenCV implements Template matching in the function @ref cv::matchTemplate . The
+Good question. OpenCV implements Template matching in the function **matchTemplate()**. The
available methods are 6:
-# **method=CV_TM_SQDIFF**
@@ -117,119 +119,176 @@ Code
- **What does this program do?**
- Loads an input image, an image patch (*template*), and optionally a mask
- - Perform a template matching procedure by using the OpenCV function @ref cv::matchTemplate
+ - Perform a template matching procedure by using the OpenCV function **matchTemplate()**
with any of the 6 matching methods described before. The user can choose the method by
entering its selection in the Trackbar. If a mask is supplied, it will only be used for
the methods that support masking
- Normalize the output of the matching procedure
- Localize the location with higher matching probability
- Draw a rectangle around the area corresponding to the highest match
+
+ at add_toggle_cpp
+
- **Downloadable code**: Click
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp)
- **Code at glance:**
@include samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp
+ at end_toggle
+
+ at add_toggle_java
+
+- **Downloadable code**: Click
+ [here](https://github.com/opencv/opencv/tree/master/samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java)
+- **Code at glance:**
+ @include samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java
+
+ at end_toggle
+
+ at add_toggle_python
+
+- **Downloadable code**: Click
+ [here](https://github.com/opencv/opencv/tree/master/samples/python/tutorial_code/imgProc/match_template/match_template.py)
+- **Code at glance:**
+ @include samples/python/tutorial_code/imgProc/match_template/match_template.py
+
+ at end_toggle
+
Explanation
-----------
--# Declare some global variables, such as the image, template and result matrices, as well as the
+- Declare some global variables, such as the image, template and result matrices, as well as the
match method and the window names:
- @code{.cpp}
- Mat img; Mat templ; Mat result;
- char* image_window = "Source Image";
- char* result_window = "Result window";
-
- int match_method;
- int max_Trackbar = 5;
- @endcode
--# Load the source image, template, and optionally, if supported for the matching method, a mask:
- @code{.cpp}
- bool method_accepts_mask = (CV_TM_SQDIFF == match_method || match_method == CV_TM_CCORR_NORMED);
- if (use_mask && method_accepts_mask)
- { matchTemplate( img, templ, result, match_method, mask); }
- else
- { matchTemplate( img, templ, result, match_method); }
-
- @endcode
--# Create the windows to show the results:
- @code{.cpp}
- namedWindow( image_window, WINDOW_AUTOSIZE );
- namedWindow( result_window, WINDOW_AUTOSIZE );
- @endcode
--# Create the Trackbar to enter the kind of matching method to be used. When a change is detected
- the callback function **MatchingMethod** is called.
- @code{.cpp}
- char* trackbar_label = "Method: \n 0: SQDIFF \n 1: SQDIFF NORMED \n 2: TM CCORR \n 3: TM CCORR NORMED \n 4: TM COEFF \n 5: TM COEFF NORMED";
- createTrackbar( trackbar_label, image_window, &match_method, max_Trackbar, MatchingMethod );
- @endcode
--# Wait until user exits the program.
- @code{.cpp}
- waitKey(0);
- return 0;
- @endcode
--# Let's check out the callback function. First, it makes a copy of the source image:
- @code{.cpp}
- Mat img_display;
- img.copyTo( img_display );
- @endcode
--# Next, it creates the result matrix that will store the matching results for each template
- location. Observe in detail the size of the result matrix (which matches all possible locations
- for it)
- @code{.cpp}
- int result_cols = img.cols - templ.cols + 1;
- int result_rows = img.rows - templ.rows + 1;
-
- result.create( result_rows, result_cols, CV_32FC1 );
- @endcode
--# Perform the template matching operation:
- @code{.cpp}
- bool method_accepts_mask = (CV_TM_SQDIFF == match_method || match_method == CV_TM_CCORR_NORMED);
- if (use_mask && method_accepts_mask)
- { matchTemplate( img, templ, result, match_method, mask); }
- else
- { matchTemplate( img, templ, result, match_method); }
- @endcode
- the arguments are naturally the input image **I**, the template **T**, the result **R**, the
- match_method (given by the Trackbar), and optionally the mask image **M**
-
--# We normalize the results:
- @code{.cpp}
- normalize( result, result, 0, 1, NORM_MINMAX, -1, Mat() );
- @endcode
--# We localize the minimum and maximum values in the result matrix **R** by using @ref
- cv::minMaxLoc .
- @code{.cpp}
- double minVal; double maxVal; Point minLoc; Point maxLoc;
- Point matchLoc;
-
- minMaxLoc( result, &minVal, &maxVal, &minLoc, &maxLoc, Mat() );
- @endcode
- the function calls as arguments:
-
- - **result:** The source array
- - **&minVal** and **&maxVal:** Variables to save the minimum and maximum values in **result**
- - **&minLoc** and **&maxLoc:** The Point locations of the minimum and maximum values in the
- array.
- - **Mat():** Optional mask
-
--# For the first two methods ( TM_SQDIFF and MT_SQDIFF_NORMED ) the best match are the lowest
+
+ @add_toggle_cpp
+ @snippet samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp declare
+ @end_toggle
+
+ @add_toggle_java
+ @snippet samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java declare
+ @end_toggle
+
+ @add_toggle_python
+ @snippet samples/python/tutorial_code/imgProc/match_template/match_template.py global_variables
+ @end_toggle
+
+- Load the source image, template, and optionally, if supported for the matching method, a mask:
+
+ @add_toggle_cpp
+ @snippet samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp load_image
+ @end_toggle
+
+ @add_toggle_java
+ @snippet samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java load_image
+ @end_toggle
+
+ @add_toggle_python
+ @snippet samples/python/tutorial_code/imgProc/match_template/match_template.py load_image
+ @end_toggle
+
+- Create the Trackbar to enter the kind of matching method to be used. When a change is detected
+ the callback function is called.
+
+ @add_toggle_cpp
+ @snippet samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp create_trackbar
+ @end_toggle
+
+ @add_toggle_java
+ @snippet samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java create_trackbar
+ @end_toggle
+
+ @add_toggle_python
+ @snippet samples/python/tutorial_code/imgProc/match_template/match_template.py create_trackbar
+ @end_toggle
+
+- Let's check out the callback function. First, it makes a copy of the source image:
+
+ @add_toggle_cpp
+ @snippet samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp copy_source
+ @end_toggle
+
+ @add_toggle_java
+ @snippet samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java copy_source
+ @end_toggle
+
+ @add_toggle_python
+ @snippet samples/python/tutorial_code/imgProc/match_template/match_template.py copy_source
+ @end_toggle
+
+- Perform the template matching operation. The arguments are naturally the input image **I**,
+ the template **T**, the result **R** and the match_method (given by the Trackbar),
+ and optionally the mask image **M**.
+
+ @add_toggle_cpp
+ @snippet samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp match_template
+ @end_toggle
+
+ @add_toggle_java
+ @snippet samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java match_template
+ @end_toggle
+
+ @add_toggle_python
+ @snippet samples/python/tutorial_code/imgProc/match_template/match_template.py match_template
+ @end_toggle
+
+- We normalize the results:
+
+ @add_toggle_cpp
+ @snippet samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp normalize
+ @end_toggle
+
+ @add_toggle_java
+ @snippet samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java normalize
+ @end_toggle
+
+ @add_toggle_python
+ @snippet samples/python/tutorial_code/imgProc/match_template/match_template.py normalize
+ @end_toggle
+
+- We localize the minimum and maximum values in the result matrix **R** by using **minMaxLoc()**.
+
+ @add_toggle_cpp
+ @snippet samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp best_match
+ @end_toggle
+
+ @add_toggle_java
+ @snippet samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java best_match
+ @end_toggle
+
+ @add_toggle_python
+ @snippet samples/python/tutorial_code/imgProc/match_template/match_template.py best_match
+ @end_toggle
+
+- For the first two methods ( TM_SQDIFF and MT_SQDIFF_NORMED ) the best match are the lowest
values. For all the others, higher values represent better matches. So, we save the
corresponding value in the **matchLoc** variable:
- @code{.cpp}
- if( match_method == TM_SQDIFF || match_method == TM_SQDIFF_NORMED )
- { matchLoc = minLoc; }
- else
- { matchLoc = maxLoc; }
- @endcode
--# Display the source image and the result matrix. Draw a rectangle around the highest possible
+
+ @add_toggle_cpp
+ @snippet samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp match_loc
+ @end_toggle
+
+ @add_toggle_java
+ @snippet samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java match_loc
+ @end_toggle
+
+ @add_toggle_python
+ @snippet samples/python/tutorial_code/imgProc/match_template/match_template.py match_loc
+ @end_toggle
+
+- Display the source image and the result matrix. Draw a rectangle around the highest possible
matching area:
- @code{.cpp}
- rectangle( img_display, matchLoc, Point( matchLoc.x + templ.cols , matchLoc.y + templ.rows ), Scalar::all(0), 2, 8, 0 );
- rectangle( result, matchLoc, Point( matchLoc.x + templ.cols , matchLoc.y + templ.rows ), Scalar::all(0), 2, 8, 0 );
- imshow( image_window, img_display );
- imshow( result_window, result );
- @endcode
+ @add_toggle_cpp
+ @snippet samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp imshow
+ @end_toggle
+
+ @add_toggle_java
+ @snippet samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java imshow
+ @end_toggle
+
+ @add_toggle_python
+ @snippet samples/python/tutorial_code/imgProc/match_template/match_template.py imshow
+ @end_toggle
Results
-------
diff --git a/doc/tutorials/imgproc/hitOrMiss/hitOrMiss.markdown b/doc/tutorials/imgproc/hitOrMiss/hitOrMiss.markdown
new file mode 100644
index 0000000..085e7c2
--- /dev/null
+++ b/doc/tutorials/imgproc/hitOrMiss/hitOrMiss.markdown
@@ -0,0 +1,60 @@
+Hit-or-Miss {#tutorial_hitOrMiss}
+=================================
+
+Goal
+----
+
+In this tutorial you will learn how to find a given configuration or pattern in a binary image by using the Hit-or-Miss transform (also known as Hit-and-Miss transform).
+This transform is also the basis of more advanced morphological operations such as thinning or pruning.
+
+We will use the OpenCV function @ref cv::morphologyEx.
+
+
+
+Hit-or-Miss theory
+-------------------
+
+Morphological operators process images based on their shape. These operators apply one or more *structuring elements* to an input image to obtain the output image.
+The two basic morphological operations are the *erosion* and the *dilation*. The combination of these two operations generate advanced morphological transformations such as *opening*, *closing*, or *top-hat* transform.
+To know more about these and other basic morphological operations refer to previous tutorials @ref tutorial_erosion_dilatation "here" and @ref tutorial_opening_closing_hats "here".
+
+The Hit-or-Miss transformation is useful to find patterns in binary images. In particular, it finds those pixels whose neighbourhood matches the shape of a first structuring element \f$B_1\f$
+while not matching the shape of a second structuring element \f$B_2\f$ at the same time. Mathematically, the operation applied to an image \f$A\f$ can be expressed as follows:
+\f[
+ A\circledast B = (A\ominus B_1) \cap (A^c\ominus B_2)
+\f]
+
+Therefore, the hit-or-miss operation comprises three steps:
+ 1. Erode image \f$A\f$ with structuring element \f$B_1\f$.
+ 2. Erode the complement of image \f$A\f$ (\f$A^c\f$) with structuring element \f$B_2\f$.
+ 3. AND results from step 1 and step 2.
+
+The structuring elements \f$B_1\f$ and \f$B_2\f$ can be combined into a single element \f$B\f$. Let's see an example:
+
+
+In this case, we are looking for a pattern in which the central pixel belongs to the background while the north, south, east, and west pixels belong to the foreground. The rest of pixels in the neighbourhood can be of any kind, we don't care about them. Now, let's apply this kernel to an input image:
+
+
+
+
+You can see that the pattern is found in just one location within the image.
+
+
+Code
+----
+
+The code corresponding to the previous example is shown below. You can also download it from
+[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ImgProc/HitMiss.cpp)
+ at include samples/cpp/tutorial_code/ImgProc/HitMiss.cpp
+
+As you can see, it is as simple as using the function @ref cv::morphologyEx with the operation type @ref cv::MORPH_HITMISS and the chosen kernel.
+
+Other examples
+--------------
+
+Here you can find the output results of applying different kernels to the same input image used before:
+
+
+
+
+Now try your own patterns!
diff --git a/doc/tutorials/imgproc/hitOrMiss/images/hitmiss_example2.png b/doc/tutorials/imgproc/hitOrMiss/images/hitmiss_example2.png
new file mode 100644
index 0000000..c4e0efb
Binary files /dev/null and b/doc/tutorials/imgproc/hitOrMiss/images/hitmiss_example2.png differ
diff --git a/doc/tutorials/imgproc/hitOrMiss/images/hitmiss_example3.png b/doc/tutorials/imgproc/hitOrMiss/images/hitmiss_example3.png
new file mode 100644
index 0000000..dc97275
Binary files /dev/null and b/doc/tutorials/imgproc/hitOrMiss/images/hitmiss_example3.png differ
diff --git a/doc/tutorials/imgproc/hitOrMiss/images/hitmiss_input.png b/doc/tutorials/imgproc/hitOrMiss/images/hitmiss_input.png
new file mode 100644
index 0000000..fec726f
Binary files /dev/null and b/doc/tutorials/imgproc/hitOrMiss/images/hitmiss_input.png differ
diff --git a/doc/tutorials/imgproc/hitOrMiss/images/hitmiss_kernels.png b/doc/tutorials/imgproc/hitOrMiss/images/hitmiss_kernels.png
new file mode 100644
index 0000000..cdf5e73
Binary files /dev/null and b/doc/tutorials/imgproc/hitOrMiss/images/hitmiss_kernels.png differ
diff --git a/doc/tutorials/imgproc/hitOrMiss/images/hitmiss_output.png b/doc/tutorials/imgproc/hitOrMiss/images/hitmiss_output.png
new file mode 100644
index 0000000..b7b8163
Binary files /dev/null and b/doc/tutorials/imgproc/hitOrMiss/images/hitmiss_output.png differ
diff --git a/doc/tutorials/imgproc/imgtrans/canny_detector/canny_detector.markdown b/doc/tutorials/imgproc/imgtrans/canny_detector/canny_detector.markdown
index f9f2a2a..7954241 100644
--- a/doc/tutorials/imgproc/imgtrans/canny_detector/canny_detector.markdown
+++ b/doc/tutorials/imgproc/imgtrans/canny_detector/canny_detector.markdown
@@ -68,7 +68,7 @@ Code
-# **What does this program do?**
- Asks the user to enter a numerical value to set the lower threshold for our *Canny Edge
- Detector* (by means of a Trackbar)
+ Detector* (by means of a Trackbar).
- Applies the *Canny Detector* and generates a **mask** (bright lines representing the edges
on a black background).
- Applies the mask obtained on the original image and display it in a window.
@@ -85,19 +85,19 @@ Explanation
Note the following:
- -# We establish a ratio of lower:upper threshold of 3:1 (with the variable *ratio*)
+ -# We establish a ratio of lower:upper threshold of 3:1 (with the variable *ratio*).
-# We set the kernel size of \f$3\f$ (for the Sobel operations to be performed internally by the
- Canny function)
+ Canny function).
-# We set a maximum value for the lower Threshold of \f$100\f$.
-# Loads the source image:
@snippet cpp/tutorial_code/ImgTrans/CannyDetector_Demo.cpp load
--# Create a matrix of the same type and size of *src* (to be *dst*)
+-# Create a matrix of the same type and size of *src* (to be *dst*):
@snippet cpp/tutorial_code/ImgTrans/CannyDetector_Demo.cpp create_mat
--# Convert the image to grayscale (using the function @ref cv::cvtColor :
+-# Convert the image to grayscale (using the function @ref cv::cvtColor ):
@snippet cpp/tutorial_code/ImgTrans/CannyDetector_Demo.cpp convert_to_gray
--# Create a window to display the results
+-# Create a window to display the results:
@snippet cpp/tutorial_code/ImgTrans/CannyDetector_Demo.cpp create_window
-# Create a Trackbar for the user to enter the lower threshold for our Canny detector:
@snippet cpp/tutorial_code/ImgTrans/CannyDetector_Demo.cpp create_trackbar
diff --git a/doc/tutorials/imgproc/imgtrans/filter_2d/filter_2d.markdown b/doc/tutorials/imgproc/imgtrans/filter_2d/filter_2d.markdown
index a091464..5021556 100644
--- a/doc/tutorials/imgproc/imgtrans/filter_2d/filter_2d.markdown
+++ b/doc/tutorials/imgproc/imgtrans/filter_2d/filter_2d.markdown
@@ -20,8 +20,8 @@ In a very general sense, convolution is an operation between every part of an im
### What is a kernel?
-A kernel is essentially a fixed size array of numerical coefficeints along with an *anchor point* in
-that array, which is tipically located at the center.
+A kernel is essentially a fixed size array of numerical coefficients along with an *anchor point* in
+that array, which is typically located at the center.

diff --git a/doc/tutorials/imgproc/imgtrans/hough_circle/hough_circle.markdown b/doc/tutorials/imgproc/imgtrans/hough_circle/hough_circle.markdown
index 9f39519..36c03cd 100644
--- a/doc/tutorials/imgproc/imgtrans/hough_circle/hough_circle.markdown
+++ b/doc/tutorials/imgproc/imgtrans/hough_circle/hough_circle.markdown
@@ -66,7 +66,7 @@ Explanation
- *min_dist = gray.rows/16*: Minimum distance between detected centers.
- *param_1 = 200*: Upper threshold for the internal Canny edge detector.
- *param_2* = 100\*: Threshold for center detection.
- - *min_radius = 0*: Minimum radio to be detected. If unknown, put zero as default.
+ - *min_radius = 0*: Minimum radius to be detected. If unknown, put zero as default.
- *max_radius = 0*: Maximum radius to be detected. If unknown, put zero as default.
-# Draw the detected circles:
diff --git a/doc/tutorials/imgproc/imgtrans/warp_affine/warp_affine.markdown b/doc/tutorials/imgproc/imgtrans/warp_affine/warp_affine.markdown
index 934e8db..6ad4cfc 100644
--- a/doc/tutorials/imgproc/imgtrans/warp_affine/warp_affine.markdown
+++ b/doc/tutorials/imgproc/imgtrans/warp_affine/warp_affine.markdown
@@ -14,9 +14,9 @@ Theory
### What is an Affine Transformation?
--# It is any transformation that can be expressed in the form of a *matrix multiplication* (linear
+-# A transformation that can be expressed in the form of a *matrix multiplication* (linear
transformation) followed by a *vector addition* (translation).
--# From the above, We can use an Affine Transformation to express:
+-# From the above, we can use an Affine Transformation to express:
-# Rotations (linear transformation)
-# Translations (vector addition)
@@ -25,7 +25,7 @@ Theory
you can see that, in essence, an Affine Transformation represents a **relation** between two
images.
--# The usual way to represent an Affine Transform is by using a \f$2 \times 3\f$ matrix.
+-# The usual way to represent an Affine Transformation is by using a \f$2 \times 3\f$ matrix.
\f[
A = \begin{bmatrix}
@@ -49,7 +49,7 @@ Theory
\f]
Considering that we want to transform a 2D vector \f$X = \begin{bmatrix}x \\ y\end{bmatrix}\f$ by
- using \f$A\f$ and \f$B\f$, we can do it equivalently with:
+ using \f$A\f$ and \f$B\f$, we can do the same with:
\f$T = A \cdot \begin{bmatrix}x \\ y\end{bmatrix} + B\f$ or \f$T = M \cdot [x, y, 1]^{T}\f$
@@ -60,35 +60,35 @@ Theory
### How do we get an Affine Transformation?
--# Excellent question. We mentioned that an Affine Transformation is basically a **relation**
+-# We mentioned that an Affine Transformation is basically a **relation**
between two images. The information about this relation can come, roughly, in two ways:
- -# We know both \f$X\f$ and T and we also know that they are related. Then our job is to find \f$M\f$
+ -# We know both \f$X\f$ and T and we also know that they are related. Then our task is to find \f$M\f$
-# We know \f$M\f$ and \f$X\f$. To obtain \f$T\f$ we only need to apply \f$T = M \cdot X\f$. Our information
for \f$M\f$ may be explicit (i.e. have the 2-by-3 matrix) or it can come as a geometric relation
between points.
--# Let's explain a little bit better (b). Since \f$M\f$ relates 02 images, we can analyze the simplest
+-# Let's explain this in a better way (b). Since \f$M\f$ relates 2 images, we can analyze the simplest
case in which it relates three points in both images. Look at the figure below:

the points 1, 2 and 3 (forming a triangle in image 1) are mapped into image 2, still forming a
triangle, but now they have changed notoriously. If we find the Affine Transformation with these
- 3 points (you can choose them as you like), then we can apply this found relation to the whole
- pixels in the image.
+ 3 points (you can choose them as you like), then we can apply this found relation to all the
+ pixels in an image.
Code
----
-# **What does this program do?**
- Loads an image
- - Applies an Affine Transform to the image. This Transform is obtained from the relation
+ - Applies an Affine Transform to the image. This transform is obtained from the relation
between three points. We use the function @ref cv::warpAffine for that purpose.
- Applies a Rotation to the image after being transformed. This rotation is with respect to
the image center
- Waits until the user exits the program
--# The tutorial code's is shown lines below. You can also download it from
+-# The tutorial's code is shown below. You can also download it here
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/ImgTrans/Geometric_Transforms_Demo.cpp)
@include samples/cpp/tutorial_code/ImgTrans/Geometric_Transforms_Demo.cpp
@@ -113,10 +113,10 @@ Explanation
@code{.cpp}
warp_dst = Mat::zeros( src.rows, src.cols, src.type() );
@endcode
--# **Affine Transform:** As we explained lines above, we need two sets of 3 points to derive the
- affine transform relation. Take a look:
+-# **Affine Transform:** As we explained in lines above, we need two sets of 3 points to derive the
+ affine transform relation. Have a look:
@code{.cpp}
- srcTri[0] = Point2f( 0,0 );
+ srcTri[0] = Point2f( 0, 0 );
srcTri[1] = Point2f( src.cols - 1, 0 );
srcTri[2] = Point2f( 0, src.rows - 1 );
@@ -124,7 +124,7 @@ Explanation
dstTri[1] = Point2f( src.cols*0.85, src.rows*0.25 );
dstTri[2] = Point2f( src.cols*0.15, src.rows*0.7 );
@endcode
- You may want to draw the points to make a better idea of how they change. Their locations are
+ You may want to draw these points to get a better idea on how they change. Their locations are
approximately the same as the ones depicted in the example figure (in the Theory section). You
may note that the size and orientation of the triangle defined by the 3 points change.
@@ -133,9 +133,9 @@ Explanation
@code{.cpp}
warp_mat = getAffineTransform( srcTri, dstTri );
@endcode
- We get as an output a \f$2 \times 3\f$ matrix (in this case **warp_mat**)
+ We get a \f$2 \times 3\f$ matrix as an output (in this case **warp_mat**)
--# We apply the Affine Transform just found to the src image
+-# We then apply the Affine Transform just found to the src image
@code{.cpp}
warpAffine( src, warp_dst, warp_mat, warp_dst.size() );
@endcode
diff --git a/doc/tutorials/imgproc/table_of_content_imgproc.markdown b/doc/tutorials/imgproc/table_of_content_imgproc.markdown
index 486c644..42dd4ce 100644
--- a/doc/tutorials/imgproc/table_of_content_imgproc.markdown
+++ b/doc/tutorials/imgproc/table_of_content_imgproc.markdown
@@ -27,13 +27,21 @@ In this section you will learn about the image processing (manipulation) functio
Here we investigate different morphology operators
+- @subpage tutorial_hitOrMiss
+
+ *Compatibility:* \> OpenCV 2.4
+
+ *Author:* Lorena García
+
+ Learn how to find patterns in binary images using the Hit-or-Miss operation
+
- @subpage tutorial_moprh_lines_detection
*Compatibility:* \> OpenCV 2.0
*Author:* Theodore Tsesmelis
- Here we will show how we can use different morphology operators to extract horizontal and vertical lines
+ Here we will show how we can use different morphological operators to extract horizontal and vertical lines
- @subpage tutorial_pyramids
@@ -49,7 +57,7 @@ In this section you will learn about the image processing (manipulation) functio
*Author:* Ana Huamán
- After so much processing, it is time to decide which pixels stay!
+ After so much processing, it is time to decide which pixels stay
- @subpage tutorial_threshold_inRange
@@ -73,7 +81,7 @@ In this section you will learn about the image processing (manipulation) functio
*Author:* Ana Huamán
- Where we learn how to pad our images!
+ Where we learn how to pad our images
- @subpage tutorial_sobel_derivatives
@@ -81,7 +89,7 @@ In this section you will learn about the image processing (manipulation) functio
*Author:* Ana Huamán
- Where we learn how to calculate gradients and use them to detect edges!
+ Where we learn how to calculate gradients and use them to detect edges
- @subpage tutorial_laplace_operator
@@ -89,7 +97,7 @@ In this section you will learn about the image processing (manipulation) functio
*Author:* Ana Huamán
- Where we learn about the *Laplace* operator and how to detect edges with it.
+ Where we learn about the *Laplace* operator and how to detect edges with it
- @subpage tutorial_canny_detector
@@ -97,7 +105,7 @@ In this section you will learn about the image processing (manipulation) functio
*Author:* Ana Huamán
- Where we learn a sophisticated alternative to detect edges.
+ Where we learn a sophisticated alternative to detect edges
- @subpage tutorial_hough_lines
@@ -165,6 +173,8 @@ In this section you will learn about the image processing (manipulation) functio
- @subpage tutorial_template_matching
+ *Languages:* C++, Java, Python
+
*Compatibility:* \> OpenCV 2.0
*Author:* Ana Huamán
@@ -185,7 +195,7 @@ In this section you will learn about the image processing (manipulation) functio
*Author:* Ana Huamán
- Where we learn how to get hull contours and draw them!
+ Where we learn how to get hull contours and draw them
- @subpage tutorial_bounding_rects_circles
@@ -193,7 +203,7 @@ In this section you will learn about the image processing (manipulation) functio
*Author:* Ana Huamán
- Where we learn how to obtain bounding boxes and circles for our contours.
+ Where we learn how to obtain bounding boxes and circles for our contours
- @subpage tutorial_bounding_rotated_ellipses
@@ -201,7 +211,7 @@ In this section you will learn about the image processing (manipulation) functio
*Author:* Ana Huamán
- Where we learn how to obtain rotated bounding boxes and ellipses for our contours.
+ Where we learn how to obtain rotated bounding boxes and ellipses for our contours
- @subpage tutorial_moments
@@ -225,4 +235,4 @@ In this section you will learn about the image processing (manipulation) functio
*Author:* Theodore Tsesmelis
- Where we learn to segment objects using Laplacian filtering, the Distance Transformation and the Watershed algorithm.
\ No newline at end of file
+ Where we learn to segment objects using Laplacian filtering, the Distance Transformation and the Watershed algorithm.
diff --git a/doc/tutorials/introduction/biicode/images/bii_lena.png b/doc/tutorials/introduction/biicode/images/bii_lena.png
deleted file mode 100644
index 387f9db..0000000
Binary files a/doc/tutorials/introduction/biicode/images/bii_lena.png and /dev/null differ
diff --git a/doc/tutorials/introduction/building_tegra_cuda/building_tegra_cuda.markdown b/doc/tutorials/introduction/building_tegra_cuda/building_tegra_cuda.markdown
index 9c384a0..a1e8396 100644
--- a/doc/tutorials/introduction/building_tegra_cuda/building_tegra_cuda.markdown
+++ b/doc/tutorials/introduction/building_tegra_cuda/building_tegra_cuda.markdown
@@ -29,7 +29,7 @@ Getting the Source Code {#tutorial_building_tegra_cuda_getting_the_code}
There are two (2) ways to get the OpenCV source code:
-* Direct download from the [OpenCV downloads](http://opencv.org/downloads.html) page
+* Direct download from the [OpenCV downloads](http://opencv.org/releases.html) page
* Cloning the git repositories hosted on [GitHub](https://github.com/opencv)
For this guide, the focus is on using the git repositories. This is because the 3.1.0 version of OpenCV will not build with CUDA 8.0 without applying a few small upstream changes from the git repository.
diff --git a/doc/tutorials/introduction/java_eclipse/java_eclipse.markdown b/doc/tutorials/introduction/java_eclipse/java_eclipse.markdown
index 56116f6..89316de 100644
--- a/doc/tutorials/introduction/java_eclipse/java_eclipse.markdown
+++ b/doc/tutorials/introduction/java_eclipse/java_eclipse.markdown
@@ -10,7 +10,7 @@ less mistakes. Here we go.
Configuring Eclipse
-------------------
-First, obtain a fresh release of OpenCV [from download page](http://opencv.org/downloads.html) and
+First, obtain a fresh release of OpenCV [from download page](http://opencv.org/releases.html) and
extract it under a simple location like `C:\OpenCV-2.4.6\`. I am using version 2.4.6, but the steps
are more or less the same for other versions.
diff --git a/doc/tutorials/introduction/linux_install/linux_install.markdown b/doc/tutorials/introduction/linux_install/linux_install.markdown
index dfbdd4c..9f691c2 100644
--- a/doc/tutorials/introduction/linux_install/linux_install.markdown
+++ b/doc/tutorials/introduction/linux_install/linux_install.markdown
@@ -1,7 +1,7 @@
Installation in Linux {#tutorial_linux_install}
=====================
-These steps have been tested for Ubuntu 10.04 but should work with other distros as well.
+The following steps have been tested for Ubuntu 10.04 but should work with other distros as well.
Required Packages
-----------------
@@ -33,13 +33,13 @@ repository](https://github.com/opencv/opencv.git).
### Getting the Latest Stable OpenCV Version
-- Go to our [downloads page](http://opencv.org/downloads.html).
+- Go to our [downloads page](http://opencv.org/releases.html).
- Download the source archive and unpack it.
### Getting the Cutting-edge OpenCV from the Git Repository
Launch Git client and clone [OpenCV repository](http://github.com/opencv/opencv). If you need
-modules from [OpenCV contrib repository](http://github.com/opencv/opencv_contrib) then clone it too.
+modules from [OpenCV contrib repository](http://github.com/opencv/opencv_contrib) then clone it as well.
For example
@code{.bash}
@@ -97,21 +97,21 @@ Building OpenCV from Source Using CMake
- It is useful also to unset BUILD_EXAMPLES, BUILD_TESTS, BUILD_PERF_TESTS - as they all
will be statically linked with OpenCV and can take a lot of memory.
--# Build. From build directory execute make, recomend to do it in several threads
+-# Build. From build directory execute *make*, it is recommended to do this in several threads
For example
@code{.bash}
make -j7 # runs 7 jobs in parallel
@endcode
-# [optional] Building documents. Enter \<cmake_build_dir/doc/\> and run make with target
- "html_docs"
+ "doxygen"
For example
@code{.bash}
cd ~/opencv/build/doc/
- make -j7 html_docs
+ make -j7 doxygen
@endcode
--# To install libraries, from build directory execute
+-# To install libraries, execute the following command from build directory
@code{.bash}
sudo make install
@endcode
@@ -134,6 +134,6 @@ Building OpenCV from Source Using CMake
@note
If the size of the created library is a critical issue (like in case of an Android build) you
- can use the install/strip command to get the smallest size as possible. The *stripped* version
+ can use the install/strip command to get the smallest size possible. The *stripped* version
appears to be twice as small. However, we do not recommend using this unless those extra
megabytes do really matter.
diff --git a/doc/tutorials/introduction/load_save_image/load_save_image.markdown b/doc/tutorials/introduction/load_save_image/load_save_image.markdown
index b85c681..aa5965d 100644
--- a/doc/tutorials/introduction/load_save_image/load_save_image.markdown
+++ b/doc/tutorials/introduction/load_save_image/load_save_image.markdown
@@ -28,7 +28,7 @@ int main( int argc, char** argv )
char* imageName = argv[1];
Mat image;
- image = imread( imageName, 1 );
+ image = imread( imageName, IMREAD_COLOR );
if( argc != 2 || !image.data )
{
diff --git a/doc/tutorials/introduction/windows_install/images/MiktexInstall.png b/doc/tutorials/introduction/windows_install/images/MiktexInstall.png
deleted file mode 100644
index 193a403..0000000
Binary files a/doc/tutorials/introduction/windows_install/images/MiktexInstall.png and /dev/null differ
diff --git a/doc/tutorials/introduction/windows_install/images/Sphinx_Install.png b/doc/tutorials/introduction/windows_install/images/Sphinx_Install.png
deleted file mode 100644
index da2e06c..0000000
Binary files a/doc/tutorials/introduction/windows_install/images/Sphinx_Install.png and /dev/null differ
diff --git a/doc/tutorials/introduction/windows_install/images/WindowsBuildDoc.png b/doc/tutorials/introduction/windows_install/images/WindowsBuildDoc.png
deleted file mode 100644
index 18cad03..0000000
Binary files a/doc/tutorials/introduction/windows_install/images/WindowsBuildDoc.png and /dev/null differ
diff --git a/doc/tutorials/introduction/windows_install/images/cmsdstartwindows.jpg b/doc/tutorials/introduction/windows_install/images/cmsdstartwindows.jpg
deleted file mode 100644
index e0d9530..0000000
Binary files a/doc/tutorials/introduction/windows_install/images/cmsdstartwindows.jpg and /dev/null differ
diff --git a/doc/tutorials/introduction/windows_install/windows_install.markdown b/doc/tutorials/introduction/windows_install/windows_install.markdown
index 179f430..d4b48fa 100644
--- a/doc/tutorials/introduction/windows_install/windows_install.markdown
+++ b/doc/tutorials/introduction/windows_install/windows_install.markdown
@@ -8,7 +8,7 @@ best to help you out.
@note To use the OpenCV library you have two options: @ref tutorial_windows_install_prebuilt or
@ref tutorial_windows_install_build. While the first one is easier to complete, it only works if you are coding
-with the latest Microsoft Visual Studio IDE and doesn't take advantage of the most advanced
+with the latest Microsoft Visual Studio IDE and do not take advantage of the most advanced
technologies we integrate into our library. .. _Windows_Install_Prebuild:
Installation by Using the Pre-built Libraries {#tutorial_windows_install_prebuilt}
@@ -67,14 +67,14 @@ of them, you need to download and install them on your system.
- [Numpy](http://numpy.scipy.org/) is a scientific computing package for Python. Required for the *Python interface*.
- [Intel Threading Building Blocks (*TBB*)](http://threadingbuildingblocks.org/file.php?fid=77) is used inside OpenCV for parallel code
snippets. Using this will make sure that the OpenCV library will take advantage of all the cores
- you have in your systems CPU.
+ you have in your system's CPU.
- [Intel Integrated Performance Primitives (*IPP*)](http://software.intel.com/en-us/articles/intel-ipp/) may be used to improve the performance
of color conversion, Haar training and DFT functions of the OpenCV library. Watch out, since
- this isn't a free service.
+ this is not a free service.
- [Intel IPP Asynchronous C/C++](http://software.intel.com/en-us/intel-ipp-preview) is currently focused delivering Intel Graphics
support for advanced image processing and computer vision functions.
- OpenCV offers a somewhat fancier and more useful graphical user interface, than the default one
- by using the [Qt framework](http://qt.nokia.com/downloads). For a quick overview of what this has to offer look into the
+ by using the [Qt framework](http://qt.nokia.com/downloads). For a quick overview of what this has to offer, look into the
documentations *highgui* module, under the *Qt New Functions* section. Version 4.6 or later of
the framework is required.
- [Eigen](http://eigen.tuxfamily.org/index.php?title=Main_Page#Download) is a C++ template library for linear algebra.
@@ -83,16 +83,13 @@ of them, you need to download and install them on your system.
more of our algorithms to work on the GPUs is a constant effort of the OpenCV team.
- [OpenEXR](http://www.openexr.com/downloads.html) source files are required for the library to work with this high dynamic range (HDR)
image file format.
-- The OpenNI Framework contains a set of open source APIs that provide support for natural interaction with devices via methods such as voice command recognition, hand gestures and body
+- The OpenNI Framework contains a set of open source APIs that provide support for natural interaction with devices via methods such as voice command recognition, hand gestures, and body
motion tracking. Prebuilt binaries can be found [here](http://structure.io/openni). The source code of [OpenNI](https://github.com/OpenNI/OpenNI) and [OpenNI2](https://github.com/OpenNI/OpenNI2) are also available on Github.
-- [Miktex]( http://miktex.org/2.9/setup) is the best [TEX](https://secure.wikimedia.org/wikipedia/en/wiki/TeX) implementation on
- the Windows OS. It is required to build the *OpenCV documentation*.
-- [Sphinx](http://sphinx.pocoo.org/) is a python documentation generator and is the tool that will actually create the
- *OpenCV documentation*. This on its own requires a couple of tools installed, We will cover this
- in depth at the @ref tutorial_windows_install_sphinx "How to Install Sphinx" section.
+- [Doxygen](http://www.stack.nl/~dimitri/doxygen/) is a documentation generator and is the tool that will actually create the
+ *OpenCV documentation*.
Now we will describe the steps to follow for a full build (using all the above frameworks, tools and
-libraries). If you do not need the support for some of these you can just freely skip this section.
+libraries). If you do not need the support for some of these, you can just freely skip this section.
### Building the library
@@ -105,60 +102,34 @@ libraries). If you do not need the support for some of these you can just freely
which you need only to unpack to get access to the console version of Git. Supposing that for
some of us it could be quite enough.
-# Install [TortoiseGit](http://code.google.com/p/tortoisegit/wiki/Download). Choose the 32 or 64 bit version according to the type of OS you work in.
- While installing, locate your msysgit (if it doesn't do that automatically). Follow the
+ While installing, locate your msysgit (if it does not do that automatically). Follow the
wizard -- the default options are OK for the most part.
-# Choose a directory in your file system, where you will download the OpenCV libraries to. I
- recommend creating a new one that has short path and no special charachters in it, for example
- `D:/OpenCV`. For this tutorial I'll suggest you do so. If you use your own path and know, what
- you're doing -- it's OK.
+ recommend creating a new one that has short path and no special characters in it, for example
+ `D:/OpenCV`. For this tutorial, I will suggest you do so. If you use your own path and know, what
+ you are doing -- it is OK.
-# Clone the repository to the selected directory. After clicking *Clone* button, a window will
appear where you can select from what repository you want to download source files
(<https://github.com/opencv/opencv.git>) and to what directory (`D:/OpenCV`).
-# Push the OK button and be patient as the repository is quite a heavy download. It will take
some time depending on your Internet connection.
--# In this section I will cover installing the 3rd party libraries.
+-# In this section, I will cover installing the 3rd party libraries.
-# Download the [Python libraries](http://www.python.org/downloads/) and install it with the default options. You will need a
couple other python extensions. Luckily installing all these may be automated by a nice tool
called [Setuptools](http://pypi.python.org/pypi/setuptools#downloads). Download and install
again.
- @anchor tutorial_windows_install_sphinx
- -# Installing Sphinx is easy once you have installed *Setuptools*. This contains a little
- application that will automatically connect to the python databases and download the latest
- version of many python scripts. Start up a command window (enter *cmd* into the windows
- start menu and press enter) and use the *CD* command to navigate to your Python folders
- Script sub-folder. Here just pass to the *easy_install.exe* as argument the name of the
- program you want to install. Add the *sphinx* argument.
-
- 
-
- 
-
- @note
- The *CD* navigation command works only inside a drive. For example if you are somewhere in the
- *C:* drive you cannot use it this to go to another drive (like for example *D:*). To do so you
- first need to change drives letters. For this simply enter the command *D:*. Then you can use
- the *CD* to navigate to specific folder inside the drive. Bonus tip: you can clear the screen by
- using the *CLS* command.
-
- This will also install its prerequisites [Jinja2](http://jinja.pocoo.org/docs/) and
- [Pygments](http://pygments.org/).
-# The easiest way to install Numpy is to just download its binaries from the [sourceforge page](http://sourceforge.net/projects/numpy/files/NumPy/).
Make sure your download and install
exactly the binary for your python version (so for version `2.7`).
- -# Download the [Miktex](http://miktex.org/2.9/setup) and install it. Again just follow the wizard. At the fourth step make
- sure you select for the *"Install missing packages on-the-fly"* the *Yes* option, as you can
- see on the image below. Again this will take quite some time so be patient.
-
- 
-# For the [Intel Threading Building Blocks (*TBB*)](http://threadingbuildingblocks.org/file.php?fid=77)
download the source files and extract
it inside a directory on your system. For example let there be `D:/OpenCV/dep`. For installing
the [Intel Integrated Performance Primitives (*IPP*)](http://software.intel.com/en-us/articles/intel-ipp/)
the story is the same. For
- exctracting the archives I recommend using the [7-Zip](http://www.7-zip.org/) application.
+ extracting the archives, I recommend using the [7-Zip](http://www.7-zip.org/) application.

@@ -203,7 +174,7 @@ libraries). If you do not need the support for some of these you can just freely
@code{.bash}
nmake
@endcode
- After this set the Qt enviroment variables using the following command on Windows 7:
+ After this set the Qt environment variables using the following command on Windows 7:
@code{.bash}
setx -m QTDIR D:/OpenCV/dep/qt/qt-everywhere-opensource-src-4.7.3
@endcode
@@ -238,8 +209,8 @@ libraries). If you do not need the support for some of these you can just freely
Select all the packages you want to use and press again the *Configure* button. For an easier
overview of the build options make sure the *Grouped* option under the binary directory
selection is turned on. For some of the packages CMake may not find all of the required files or
- directories. In case of these CMake will throw an error in its output window (located at the
- bottom of the GUI) and set its field values, to not found constants. For example:
+ directories. In case of these, CMake will throw an error in its output window (located at the
+ bottom of the GUI) and set its field values to not found constants. For example:

@@ -258,27 +229,27 @@ libraries). If you do not need the support for some of these you can just freely
Furthermore, you need to select what part of OpenCV you want to build.
- *BUILD_DOCS* -\> It creates two projects for building the documentation of OpenCV (there
- will be a separate project for building the HTML and the PDF files). Note that these aren't
+ will be a separate project for building the HTML and the PDF files). Note that these are not
built together with the solution. You need to make an explicit build project command on
these to do so.
- *BUILD_EXAMPLES* -\> OpenCV comes with many example applications from which you may learn
most of the libraries capabilities. This will also come handy to easily try out if OpenCV is
fully functional on your computer.
- *BUILD_PACKAGE* -\> Prior to version 2.3 with this you could build a project that will
- build an OpenCV installer. With this you can easily install your OpenCV flavor on other
- systems. For the latest source files of OpenCV it generates a new project that simply
- creates zip archive with OpenCV sources.
+ build an OpenCV installer. With this, you can easily install your OpenCV flavor on other
+ systems. For the latest source files of OpenCV, it generates a new project that simply
+ creates a zip archive with OpenCV sources.
- *BUILD_SHARED_LIBS* -\> With this you can control to build DLL files (when turned on) or
static library files (\*.lib) otherwise.
- *BUILD_TESTS* -\> Each module of OpenCV has a test project assigned to it. Building these
test projects is also a good way to try out, that the modules work just as expected on your
system too.
- *BUILD_PERF_TESTS* -\> There are also performance tests for many OpenCV functions. If
- you're concerned about performance, build them and run.
+ you are concerned about performance, build them and run.
- *BUILD_opencv_python* -\> Self-explanatory. Create the binaries to use OpenCV from the
Python language.
- Press again the *Configure* button and ensure no errors are reported. If this is the case you
+ Press again the *Configure* button and ensure no errors are reported. If this is the case, you
can tell CMake to create the project files by pushing the *Generate* button. Go to the build
directory and open the created **OpenCV** solution. Depending on just how much of the above
options you have selected the solution may contain quite a lot of projects so be tolerant on the
@@ -287,19 +258,16 @@ libraries). If you do not need the support for some of these you can just freely

- In the end you can observe the built binary files inside the bin directory:
+ In the end, you can observe the built binary files inside the bin directory:

- For the documentation you need to explicitly issue the build commands on the *doc* project for
- the PDF files and on the *doc_html* for the HTML ones. Each of these will call *Sphinx* to do
- all the hard work. You can find the generated documentation inside the `Build/Doc/_html` for the
- HTML pages and within the `Build/Doc` the PDF manuals.
-
- 
+ For the documentation, you need to explicitly issue the build commands on the *doxygen* project for
+ the HTML documentation. It will call *Doxygen* to do
+ all the hard work. You can find the generated documentation inside the `build/doc/doxygen/html`.
To collect the header and the binary files, that you will use during your own projects, into a
- separate directory (simillary to how the pre-built binaries ship) you need to explicitely build
+ separate directory (similarly to how the pre-built binaries ship) you need to explicitly build
the *Install* project.

@@ -310,32 +278,34 @@ libraries). If you do not need the support for some of these you can just freely
To test your build just go into the `Build/bin/Debug` or `Build/bin/Release` directory and start
a couple of applications like the *contours.exe*. If they run, you are done. Otherwise,
something definitely went awfully wrong. In this case you should contact us at our [Q&A forum](http://answers.opencv.org/).
- If everything is okay the *contours.exe* output should resemble the following image (if
+ If everything is okay, the *contours.exe* output should resemble the following image (if
built with Qt support):

@note
- If you use the GPU module (CUDA libraries) make sure you also upgrade to the latest drivers of
+ If you use the GPU module (CUDA libraries), make sure you also upgrade to the latest drivers of
your GPU. Error messages containing invalid entries in (or cannot find) the nvcuda.dll are
caused mostly by old video card drivers. For testing the GPU (if built) run the
*performance_gpu.exe* sample application.
-Set the OpenCV enviroment variable and add it to the systems path {#tutorial_windows_install_path}
+Set the OpenCV environment variable and add it to the systems path {#tutorial_windows_install_path}
=================================================================
-First we set an enviroment variable to make easier our work. This will hold the build directory of
+First we set an environment variable to make easier our work. This will hold the build directory of
our OpenCV library that we use in our projects. Start up a command window and enter:
@code
- setx -m OPENCV_DIR D:\OpenCV\Build\x86\vc10 (suggested for Visual Studio 2010 - 32 bit Windows)
- setx -m OPENCV_DIR D:\OpenCV\Build\x64\vc10 (suggested for Visual Studio 2010 - 64 bit Windows)
-
setx -m OPENCV_DIR D:\OpenCV\Build\x86\vc11 (suggested for Visual Studio 2012 - 32 bit Windows)
setx -m OPENCV_DIR D:\OpenCV\Build\x64\vc11 (suggested for Visual Studio 2012 - 64 bit Windows)
+
+ setx -m OPENCV_DIR D:\OpenCV\Build\x86\vc12 (suggested for Visual Studio 2013 - 32 bit Windows)
+ setx -m OPENCV_DIR D:\OpenCV\Build\x64\vc12 (suggested for Visual Studio 2013 - 64 bit Windows)
+
+ setx -m OPENCV_DIR D:\OpenCV\Build\x64\vc14 (suggested for Visual Studio 2015 - 64 bit Windows)
@endcode
Here the directory is where you have your OpenCV binaries (*extracted* or *built*). You can have
different platform (e.g. x64 instead of x86) or compiler type, so substitute appropriate value.
-Inside this you should have two folders called *lib* and *bin*. The -m should be added if you wish
+Inside this, you should have two folders called *lib* and *bin*. The -m should be added if you wish
to make the settings computer wise, instead of user wise.
If you built static libraries then you are done. Otherwise, you need to add the *bin* folders path
@@ -346,7 +316,7 @@ However, to do this the operating system needs to know where they are. The syste
a list of folders where DLLs can be found. Add the OpenCV library path to this and the OS will know
where to look if he ever needs the OpenCV binaries. Otherwise, you will need to copy the used DLLs
right beside the applications executable file (*exe*) for the OS to find it, which is highly
-unpleasent if you work on many projects. To do this start up again the [PathEditor](http://www.redfernplace.com/software-projects/patheditor/) and add the
+unpleasant if you work on many projects. To do this start up again the [PathEditor](http://www.redfernplace.com/software-projects/patheditor/) and add the
following new entry (right click in the application to bring up the menu):
@code
%OPENCV_DIR%\bin
@@ -357,7 +327,7 @@ following new entry (right click in the application to bring up the menu):

Save it to the registry and you are done. If you ever change the location of your build directories
-or want to try out your applicaton with a different build all you will need to do is to update the
+or want to try out your application with a different build, all you will need to do is to update the
OPENCV_DIR variable via the *setx* command inside a command window.
Now you can continue reading the tutorials with the @ref tutorial_windows_visual_studio_Opencv section.
diff --git a/doc/tutorials/introduction/windows_visual_studio_Opencv/windows_visual_studio_Opencv.markdown b/doc/tutorials/introduction/windows_visual_studio_Opencv/windows_visual_studio_Opencv.markdown
index 3be7f5b..2c9d190 100644
--- a/doc/tutorials/introduction/windows_visual_studio_Opencv/windows_visual_studio_Opencv.markdown
+++ b/doc/tutorials/introduction/windows_visual_studio_Opencv/windows_visual_studio_Opencv.markdown
@@ -11,7 +11,7 @@ header files plus binaries and you have set the environment variables as describ
The OpenCV libraries, distributed by us, on the Microsoft Windows operating system are in a
Dynamic Linked Libraries (*DLL*). These have the advantage that all the content of the
-library are loaded only at runtime, on demand, and that countless programs may use the same library
+library is loaded only at runtime, on demand, and that countless programs may use the same library
file. This means that if you have ten applications using the OpenCV library, no need to have around
a version for each one of them. Of course you need to have the *dll* of the OpenCV on all systems
where you want to run your application.
@@ -42,9 +42,9 @@ To build an application with OpenCV you need to do two things:
extension libraries. The good part is that at runtime only the *DLL* is required.
To pass on all this information to the Visual Studio IDE you can either do it globally (so all your
-future projects will get these information) or locally (so only for you current project). The
+future projects will get this information) or locally (so only for you current project). The
advantage of the global one is that you only need to do it once; however, it may be undesirable to
-clump all your projects all the time with all these information. In case of the global one how you
+clump all your projects all the time with all this information. In case of the global one how you
do it depends on the Microsoft Visual Studio you use. There is a **2008 and previous versions** and
a **2010 way** of doing it. Inside the global section of this tutorial I'll show what the main
differences are.
@@ -53,7 +53,7 @@ The base item of a project in Visual Studio is a solution. A solution may contai
Projects are the building blocks of an application. Every project will realize something and you
will have a main project in which you can put together this project puzzle. In case of the many
simple applications (like many of the tutorials will be) you do not need to break down the
-application into modules. In these cases your main project will be the only existing one. Now go
+application into modules. In these cases, your main project will be the only existing one. Now go
create a new solution inside Visual studio by going through the File --\> New --\> Project menu
selection. Choose *Win32 Console Application* as type. Enter its name and select the path where to
create it. Then in the upcoming dialog make sure you create an empty project.
@@ -91,7 +91,7 @@ projects with custom rules that I do not use it. Go the C++ groups General entry
*"Additional Include Directories"* add the path to your OpenCV include. If you don't have *"C/C++"*
group, you should add any .c/.cpp file to the project.
@code{.bash}
-\f$(OPENCV_DIR)\..\..\include
+$(OPENCV_DIR)\..\..\include
@endcode

@@ -152,7 +152,7 @@ them.

-You can find your property sheets inside your projects directory. At this point it is a wise
+You can find your property sheets inside your projects directory. At this point, it is a wise
decision to back them up into some special directory, to always have them at hand in the future,
whenever you create an OpenCV project. Note that for Visual Studio 2010 the file extension is
*props*, while for 2008 this is *vsprops*.
@@ -167,7 +167,7 @@ entry inside the Property Manager to easily add the OpenCV build rules.
The *global* method
-------------------
-In case you find to troublesome to add the property pages to each and every one of your projects you
+In case you find it too troublesome to add the property pages to each and every one of your projects you
can also add this rules to a *"global property page"*. However, this applies only to the additional
include and library directories. The name of the libraries to use you still need to specify manually
by using for instance: a Property page.
@@ -202,10 +202,11 @@ current working directory is the projects directory, while otherwise it is the f
application file currently is (so usually your build directory). Moreover, in case of starting from
the *IDE* the console window will not close once finished. It will wait for a keystroke of yours.
-This is important to remember when you code inside the code open and save commands. You're resources
+This is important to remember when you code inside the code open and save commands. Your resources
will be saved ( and queried for at opening!!!) relatively to your working directory. This is unless
-you give a full, explicit path as parameter for the I/O functions. In the code above we open [this
-OpenCV logo](https://github.com/opencv/opencv/tree/master/samples/data/opencv-logo.png). Before starting up the application make sure you place
+you give a full, explicit path as a parameter for the I/O functions. In the code above we open [this
+OpenCV logo](https://github.com/opencv/opencv/tree/master/samples/data/opencv-logo.png). Before starting up the application,
+make sure you place
the image file in your current working directory. Modify the image file name inside the code to try
it out on other images too. Run it and voil á:
@@ -214,8 +215,8 @@ it out on other images too. Run it and voil á:
Command line arguments with Visual Studio
-----------------------------------------
-Throughout some of our future tutorials you'll see that the programs main input method will be by
-giving a runtime argument. To do this you can just start up a commmand windows (cmd + Enter in the
+Throughout some of our future tutorials, you'll see that the programs main input method will be by
+giving a runtime argument. To do this you can just start up a command windows (cmd + Enter in the
start menu), navigate to your executable file and start it with an argument. So for example in case
of my upper project this would look like:
@code{.bash}
@@ -232,5 +233,5 @@ cumbersome task. Luckily, in the Visual Studio there is a menu to automate all t

Specify here the name of the inputs and while you start your application from the Visual Studio
-enviroment you have automatic argument passing. In the next introductionary tutorial you'll see an
+environment you have automatic argument passing. In the next introductory tutorial you'll see an
in-depth explanation of the upper source code: @ref tutorial_display_image.
diff --git a/doc/tutorials/objdetect/cascade_classifier/cascade_classifier.markdown b/doc/tutorials/objdetect/cascade_classifier/cascade_classifier.markdown
index 6589a1c..53ed36e 100644
--- a/doc/tutorials/objdetect/cascade_classifier/cascade_classifier.markdown
+++ b/doc/tutorials/objdetect/cascade_classifier/cascade_classifier.markdown
@@ -19,8 +19,6 @@ Code
This tutorial code's is shown lines below. You can also download it from
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/objectDetection/objectDetection.cpp)
-. The second version (using LBP for face detection) can be [found
-here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/objectDetection/objectDetection2.cpp)
@include samples/cpp/tutorial_code/objectDetection/objectDetection.cpp
Explanation
@@ -34,8 +32,8 @@ Result

- Remember to copy the files *haarcascade_frontalface_alt.xml* and
- *haarcascade_eye_tree_eyeglasses.xml* in your current directory. They are located in
+ Be sure the program will find the path of files *haarcascade_frontalface_alt.xml* and
+ *haarcascade_eye_tree_eyeglasses.xml*. They are located in
*opencv/data/haarcascades*
-# This is the result of using the file *lbpcascade_frontalface.xml* (LBP trained) for the face
diff --git a/doc/tutorials/tutorials.markdown b/doc/tutorials/tutorials.markdown
index 1f1a7e9..59bab9a 100644
--- a/doc/tutorials/tutorials.markdown
+++ b/doc/tutorials/tutorials.markdown
@@ -2,7 +2,7 @@ OpenCV Tutorials {#tutorial_root}
================
The following links describe a set of basic OpenCV tutorials. All the source code mentioned here is
-provided as part of the OpenCV regular releases, so check before you start copy & pasting the code.
+provided as part of the OpenCV regular releases, so check before you start copying & pasting the code.
The list of tutorials below is automatically generated from reST files located in our GIT
repository.
@@ -10,12 +10,12 @@ As always, we would be happy to hear your comments and receive your contribution
- @subpage tutorial_table_of_content_introduction
- You will learn how to setup OpenCV on your computer!
+ You will learn how to setup OpenCV on your computer
- @subpage tutorial_table_of_content_core
Here you will learn
- the about the basic building blocks of the library. A must read and know for understanding how
+ the about the basic building blocks of this library. A must read for understanding how
to manipulate the images on a pixel level.
- @subpage tutorial_table_of_content_imgproc
@@ -25,7 +25,7 @@ As always, we would be happy to hear your comments and receive your contribution
- @subpage tutorial_table_of_content_highgui
- This section contains valuable tutorials about how to use the
+ This section contains valuable tutorials on how to use the
built-in graphical user interface of the library.
- @subpage tutorial_table_of_content_imgcodecs
@@ -38,9 +38,9 @@ As always, we would be happy to hear your comments and receive your contribution
- @subpage tutorial_table_of_content_calib3d
- Although we got
- most of our images in a 2D format they do come from a 3D world. Here you will learn how to find
- out from the 2D images information about the 3D world.
+ Although
+ most of our images are in a 2D format they do come from a 3D world. Here you will learn how to find
+ out 3D world information from 2D images.
- @subpage tutorial_table_of_content_features2d
@@ -49,14 +49,18 @@ As always, we would be happy to hear your comments and receive your contribution
- @subpage tutorial_table_of_content_video
- Look here in order
- to find algorithms usable on your video streams like: motion extraction, feature tracking and
+ Here you will find
+ algorithms usable on your video streams like motion extraction, feature tracking and
foreground extractions.
- @subpage tutorial_table_of_content_objdetect
Ever wondered
- how your digital camera detects peoples and faces? Look here to find out!
+ how your digital camera detects people's faces? Look here to find out!
+
+- @subpage tutorial_table_of_content_dnn
+
+ These tutorials show how to use dnn module effectively.
- @subpage tutorial_table_of_content_ml
@@ -75,7 +79,7 @@ As always, we would be happy to hear your comments and receive your contribution
- @subpage tutorial_table_of_content_gpu
Squeeze out every
- little computation power from your system by using the power of your video card to run the
+ little computational power from your system by utilizing the power of your video card to run the
OpenCV algorithms.
- @subpage tutorial_table_of_content_ios
diff --git a/modules/calib3d/include/opencv2/calib3d.hpp b/modules/calib3d/include/opencv2/calib3d.hpp
index 362e81f..343ca95 100644
--- a/modules/calib3d/include/opencv2/calib3d.hpp
+++ b/modules/calib3d/include/opencv2/calib3d.hpp
@@ -236,8 +236,9 @@ enum { SOLVEPNP_ITERATIVE = 0,
SOLVEPNP_EPNP = 1, //!< EPnP: Efficient Perspective-n-Point Camera Pose Estimation @cite lepetit2009epnp
SOLVEPNP_P3P = 2, //!< Complete Solution Classification for the Perspective-Three-Point Problem @cite gao2003complete
SOLVEPNP_DLS = 3, //!< A Direct Least-Squares (DLS) Method for PnP @cite hesch2011direct
- SOLVEPNP_UPNP = 4 //!< Exhaustive Linearization for Robust Camera Pose and Focal Length Estimation @cite penate2013exhaustive
-
+ SOLVEPNP_UPNP = 4, //!< Exhaustive Linearization for Robust Camera Pose and Focal Length Estimation @cite penate2013exhaustive
+ SOLVEPNP_AP3P = 5, //!< An Efficient Algebraic Solution to the Perspective-Three-Point Problem @cite Ke17
+ SOLVEPNP_MAX_COUNT //!< Used for count
};
enum { CALIB_CB_ADAPTIVE_THRESH = 1,
@@ -268,6 +269,7 @@ enum { CALIB_USE_INTRINSIC_GUESS = 0x00001,
CALIB_TILTED_MODEL = 0x40000,
CALIB_FIX_TAUX_TAUY = 0x80000,
CALIB_USE_QR = 0x100000, //!< use QR instead of SVD decomposition for solving. Faster but potentially less precise
+ CALIB_FIX_TANGENT_DIST = 0x200000,
// only for stereo
CALIB_FIX_INTRINSIC = 0x00100,
CALIB_SAME_FOCAL_LENGTH = 0x00200,
@@ -534,10 +536,10 @@ where N is the number of points. vector\<Point2f\> can be also passed here.
\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ of
4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are
assumed.
- at param rvec Output rotation vector (see Rodrigues ) that, together with tvec , brings points from
+ at param rvec Output rotation vector (see @ref Rodrigues ) that, together with tvec , brings points from
the model coordinate system to the camera coordinate system.
@param tvec Output translation vector.
- at param useExtrinsicGuess Parameter used for SOLVEPNP_ITERATIVE. If true (1), the function uses
+ at param useExtrinsicGuess Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
the provided rvec and tvec values as initial approximations of the rotation and translation
vectors, respectively, and further optimizes them.
@param flags Method for solving a PnP problem:
@@ -546,17 +548,23 @@ this case the function finds such a pose that minimizes reprojection error, that
of squared distances between the observed projections imagePoints and the projected (using
projectPoints ) objectPoints .
- **SOLVEPNP_P3P** Method is based on the paper of X.S. Gao, X.-R. Hou, J. Tang, H.-F. Chang
-"Complete Solution Classification for the Perspective-Three-Point Problem". In this case the
-function requires exactly four object and image points.
+"Complete Solution Classification for the Perspective-Three-Point Problem" (@cite gao2003complete).
+In this case the function requires exactly four object and image points.
+- **SOLVEPNP_AP3P** Method is based on the paper of T. Ke, S. Roumeliotis
+"An Efficient Algebraic Solution to the Perspective-Three-Point Problem" (@cite Ke17).
+In this case the function requires exactly four object and image points.
- **SOLVEPNP_EPNP** Method has been introduced by F.Moreno-Noguer, V.Lepetit and P.Fua in the
-paper "EPnP: Efficient Perspective-n-Point Camera Pose Estimation".
+paper "EPnP: Efficient Perspective-n-Point Camera Pose Estimation" (@cite lepetit2009epnp).
- **SOLVEPNP_DLS** Method is based on the paper of Joel A. Hesch and Stergios I. Roumeliotis.
-"A Direct Least-Squares (DLS) Method for PnP".
+"A Direct Least-Squares (DLS) Method for PnP" (@cite hesch2011direct).
- **SOLVEPNP_UPNP** Method is based on the paper of A.Penate-Sanchez, J.Andrade-Cetto,
F.Moreno-Noguer. "Exhaustive Linearization for Robust Camera Pose and Focal Length
-Estimation". In this case the function also estimates the parameters \f$f_x\f$ and \f$f_y\f$
+Estimation" (@cite penate2013exhaustive). In this case the function also estimates the parameters \f$f_x\f$ and \f$f_y\f$
assuming that both have the same value. Then the cameraMatrix is updated with the estimated
focal length.
+- **SOLVEPNP_AP3P** Method is based on the paper of Tong Ke and Stergios I. Roumeliotis.
+"An Efficient Algebraic Solution to the Perspective-Three-Point Problem". In this case the
+function requires exactly four object and image points.
The function estimates the object pose given a set of object points, their corresponding image
projections, as well as the camera matrix and the distortion coefficients.
@@ -575,8 +583,11 @@ projections, as well as the camera matrix and the distortion coefficients.
it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
- The methods **SOLVEPNP_DLS** and **SOLVEPNP_UPNP** cannot be used as the current implementations are
- unstable and sometimes give completly wrong results. If you pass one of these two flags,
- **SOLVEPNP_EPNP** method will be used instead.
+ unstable and sometimes give completly wrong results. If you pass one of these two
+ flags, **SOLVEPNP_EPNP** method will be used instead.
+ - The minimum number of points is 4. In the case of **SOLVEPNP_P3P** and **SOLVEPNP_AP3P**
+ methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
+ of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
*/
CV_EXPORTS_W bool solvePnP( InputArray objectPoints, InputArray imagePoints,
InputArray cameraMatrix, InputArray distCoeffs,
@@ -617,6 +628,13 @@ makes the function resistant to outliers.
@note
- An example of how to use solvePNPRansac for object detection can be found at
opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
+ - The default method used to estimate the camera pose for the Minimal Sample Sets step
+ is #SOLVEPNP_EPNP. Exceptions are:
+ - if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
+ - if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
+ - The method used to estimate the camera pose using all the inliers is defined by the
+ flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case,
+ the method #SOLVEPNP_EPNP will be used instead.
*/
CV_EXPORTS_W bool solvePnPRansac( InputArray objectPoints, InputArray imagePoints,
InputArray cameraMatrix, InputArray distCoeffs,
@@ -624,6 +642,33 @@ CV_EXPORTS_W bool solvePnPRansac( InputArray objectPoints, InputArray imagePoint
bool useExtrinsicGuess = false, int iterationsCount = 100,
float reprojectionError = 8.0, double confidence = 0.99,
OutputArray inliers = noArray(), int flags = SOLVEPNP_ITERATIVE );
+/** @brief Finds an object pose from 3 3D-2D point correspondences.
+
+ at param objectPoints Array of object points in the object coordinate space, 3x3 1-channel or
+1x3/3x1 3-channel. vector\<Point3f\> can be also passed here.
+ at param imagePoints Array of corresponding image points, 3x2 1-channel or 1x3/3x1 2-channel.
+ vector\<Point2f\> can be also passed here.
+ at param cameraMatrix Input camera matrix \f$A = \vecthreethree{fx}{0}{cx}{0}{fy}{cy}{0}{0}{1}\f$ .
+ at param distCoeffs Input vector of distortion coefficients
+\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ of
+4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are
+assumed.
+ at param rvecs Output rotation vectors (see Rodrigues ) that, together with tvecs , brings points from
+the model coordinate system to the camera coordinate system. A P3P problem has up to 4 solutions.
+ at param tvecs Output translation vectors.
+ at param flags Method for solving a P3P problem:
+- **SOLVEPNP_P3P** Method is based on the paper of X.S. Gao, X.-R. Hou, J. Tang, H.-F. Chang
+"Complete Solution Classification for the Perspective-Three-Point Problem".
+- **SOLVEPNP_AP3P** Method is based on the paper of Tong Ke and Stergios I. Roumeliotis.
+"An Efficient Algebraic Solution to the Perspective-Three-Point Problem".
+
+The function estimates the object pose given 3 object points, their corresponding image
+projections, as well as the camera matrix and the distortion coefficients.
+ */
+CV_EXPORTS_W int solveP3P( InputArray objectPoints, InputArray imagePoints,
+ InputArray cameraMatrix, InputArray distCoeffs,
+ OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs,
+ int flags );
/** @brief Finds an initial camera matrix from 3D-2D point correspondences.
@@ -651,11 +696,11 @@ CV_EXPORTS_W Mat initCameraMatrix2D( InputArrayOfArrays objectPoints,
( patternSize = cvSize(points_per_row,points_per_colum) = cvSize(columns,rows) ).
@param corners Output array of detected corners.
@param flags Various operation flags that can be zero or a combination of the following values:
-- **CV_CALIB_CB_ADAPTIVE_THRESH** Use adaptive thresholding to convert the image to black
+- **CALIB_CB_ADAPTIVE_THRESH** Use adaptive thresholding to convert the image to black
and white, rather than a fixed threshold level (computed from the average image brightness).
-- **CV_CALIB_CB_NORMALIZE_IMAGE** Normalize the image gamma with equalizeHist before
+- **CALIB_CB_NORMALIZE_IMAGE** Normalize the image gamma with equalizeHist before
applying fixed or adaptive thresholding.
-- **CV_CALIB_CB_FILTER_QUADS** Use additional criteria (like contour area, perimeter,
+- **CALIB_CB_FILTER_QUADS** Use additional criteria (like contour area, perimeter,
square-like shape) to filter out false quads extracted at the contour retrieval stage.
- **CALIB_CB_FAST_CHECK** Run a fast check on the image that looks for chessboard corners,
and shortcut the call if none is found. This can drastically speed up the call in the
@@ -714,6 +759,30 @@ found, or as colored corners connected with lines if the board was found.
CV_EXPORTS_W void drawChessboardCorners( InputOutputArray image, Size patternSize,
InputArray corners, bool patternWasFound );
+struct CV_EXPORTS_W_SIMPLE CirclesGridFinderParameters
+{
+ CV_WRAP CirclesGridFinderParameters();
+ CV_PROP_RW cv::Size2f densityNeighborhoodSize;
+ CV_PROP_RW float minDensity;
+ CV_PROP_RW int kmeansAttempts;
+ CV_PROP_RW int minDistanceToAddKeypoint;
+ CV_PROP_RW int keypointScale;
+ CV_PROP_RW float minGraphConfidence;
+ CV_PROP_RW float vertexGain;
+ CV_PROP_RW float vertexPenalty;
+ CV_PROP_RW float existingVertexGain;
+ CV_PROP_RW float edgeGain;
+ CV_PROP_RW float edgePenalty;
+ CV_PROP_RW float convexHullFactor;
+ CV_PROP_RW float minRNGEdgeSwitchDist;
+
+ enum GridType
+ {
+ SYMMETRIC_GRID, ASYMMETRIC_GRID
+ };
+ GridType gridType;
+};
+
/** @brief Finds centers in the grid of circles.
@param image grid view of input circles; it must be an 8-bit grayscale or color image.
@@ -726,6 +795,7 @@ CV_EXPORTS_W void drawChessboardCorners( InputOutputArray image, Size patternSiz
- **CALIB_CB_CLUSTERING** uses a special algorithm for grid detection. It is more robust to
perspective distortions but much more sensitive to background clutter.
@param blobDetector feature detector that finds blobs like dark circles on light background.
+ at param parameters struct for finding circles in a grid pattern.
The function attempts to determine whether the input image contains a grid of circles. If it is, the
function locates centers of the circles. The function returns a non-zero value if all of the centers
@@ -746,6 +816,12 @@ Sample usage of detecting and drawing the centers of circles: :
the board to make the detection more robust in various environments.
*/
CV_EXPORTS_W bool findCirclesGrid( InputArray image, Size patternSize,
+ OutputArray centers, int flags,
+ const Ptr<FeatureDetector> &blobDetector,
+ CirclesGridFinderParameters parameters);
+
+/** @overload */
+CV_EXPORTS_W bool findCirclesGrid( InputArray image, Size patternSize,
OutputArray centers, int flags = CALIB_CB_SYMMETRIC_GRID,
const Ptr<FeatureDetector> &blobDetector = SimpleBlobDetector::create());
@@ -769,7 +845,7 @@ together.
@param imageSize Size of the image used only to initialize the intrinsic camera matrix.
@param cameraMatrix Output 3x3 floating-point camera matrix
\f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ . If CV\_CALIB\_USE\_INTRINSIC\_GUESS
-and/or CV_CALIB_FIX_ASPECT_RATIO are specified, some or all of fx, fy, cx, cy must be
+and/or CALIB_FIX_ASPECT_RATIO are specified, some or all of fx, fy, cx, cy must be
initialized before calling the function.
@param distCoeffs Output vector of distortion coefficients
\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ of
@@ -789,24 +865,24 @@ space, that is, a real position of the calibration pattern in the k-th pattern v
\f$R_i, T_i\f$ are concatenated 1x3 vectors.
@param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
@param flags Different flags that may be zero or a combination of the following values:
-- **CV_CALIB_USE_INTRINSIC_GUESS** cameraMatrix contains valid initial values of
+- **CALIB_USE_INTRINSIC_GUESS** cameraMatrix contains valid initial values of
fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
center ( imageSize is used), and focal distances are computed in a least-squares fashion.
Note, that if intrinsic parameters are known, there is no need to use this function just to
estimate extrinsic parameters. Use solvePnP instead.
-- **CV_CALIB_FIX_PRINCIPAL_POINT** The principal point is not changed during the global
+- **CALIB_FIX_PRINCIPAL_POINT** The principal point is not changed during the global
optimization. It stays at the center or at a different location specified when
-CV_CALIB_USE_INTRINSIC_GUESS is set too.
-- **CV_CALIB_FIX_ASPECT_RATIO** The functions considers only fy as a free parameter. The
+CALIB_USE_INTRINSIC_GUESS is set too.
+- **CALIB_FIX_ASPECT_RATIO** The functions considers only fy as a free parameter. The
ratio fx/fy stays the same as in the input cameraMatrix . When
-CV_CALIB_USE_INTRINSIC_GUESS is not set, the actual input values of fx and fy are
+CALIB_USE_INTRINSIC_GUESS is not set, the actual input values of fx and fy are
ignored, only their ratio is computed and used further.
-- **CV_CALIB_ZERO_TANGENT_DIST** Tangential distortion coefficients \f$(p_1, p_2)\f$ are set
+- **CALIB_ZERO_TANGENT_DIST** Tangential distortion coefficients \f$(p_1, p_2)\f$ are set
to zeros and stay zero.
-- **CV_CALIB_FIX_K1,...,CV_CALIB_FIX_K6** The corresponding radial distortion
-coefficient is not changed during the optimization. If CV_CALIB_USE_INTRINSIC_GUESS is
+- **CALIB_FIX_K1,...,CALIB_FIX_K6** The corresponding radial distortion
+coefficient is not changed during the optimization. If CALIB_USE_INTRINSIC_GUESS is
set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
-- **CV_CALIB_RATIONAL_MODEL** Coefficients k4, k5, and k6 are enabled. To provide the
+- **CALIB_RATIONAL_MODEL** Coefficients k4, k5, and k6 are enabled. To provide the
backward compatibility, this extra flag should be explicitly specified to make the
calibration function use the rational model and return 8 coefficients. If the flag is not
set, the function computes and returns only 5 distortion coefficients.
@@ -815,14 +891,14 @@ backward compatibility, this extra flag should be explicitly specified to make t
calibration function use the thin prism model and return 12 coefficients. If the flag is not
set, the function computes and returns only 5 distortion coefficients.
- **CALIB_FIX_S1_S2_S3_S4** The thin prism distortion coefficients are not changed during
-the optimization. If CV_CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
+the optimization. If CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
supplied distCoeffs matrix is used. Otherwise, it is set to 0.
- **CALIB_TILTED_MODEL** Coefficients tauX and tauY are enabled. To provide the
backward compatibility, this extra flag should be explicitly specified to make the
calibration function use the tilted sensor model and return 14 coefficients. If the flag is not
set, the function computes and returns only 5 distortion coefficients.
- **CALIB_FIX_TAUX_TAUY** The coefficients of the tilted sensor model are not changed during
-the optimization. If CV_CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
+the optimization. If CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
supplied distCoeffs matrix is used. Otherwise, it is set to 0.
@param criteria Termination criteria for the iterative optimization algorithm.
@@ -834,7 +910,7 @@ points and their corresponding 2D projections in each view must be specified. Th
by using an object with a known geometry and easily detectable feature points. Such an object is
called a calibration rig or calibration pattern, and OpenCV has built-in support for a chessboard as
a calibration rig (see findChessboardCorners ). Currently, initialization of intrinsic parameters
-(when CV_CALIB_USE_INTRINSIC_GUESS is not set) is only implemented for planar calibration
+(when CALIB_USE_INTRINSIC_GUESS is not set) is only implemented for planar calibration
patterns (where Z-coordinates of the object points must be all zeros). 3D calibration rigs can also
be used as long as initial cameraMatrix is provided.
@@ -842,7 +918,7 @@ The algorithm performs the following steps:
- Compute the initial intrinsic parameters (the option only available for planar calibration
patterns) or read them from the input parameters. The distortion coefficients are all set to
- zeros initially unless some of CV_CALIB_FIX_K? are specified.
+ zeros initially unless some of CALIB_FIX_K? are specified.
- Estimate the initial camera pose as if the intrinsic parameters have been already known. This is
done using solvePnP .
@@ -922,8 +998,8 @@ observed by the first camera.
observed by the second camera.
@param cameraMatrix1 Input/output first camera matrix:
\f$\vecthreethree{f_x^{(j)}}{0}{c_x^{(j)}}{0}{f_y^{(j)}}{c_y^{(j)}}{0}{0}{1}\f$ , \f$j = 0,\, 1\f$ . If
-any of CV_CALIB_USE_INTRINSIC_GUESS , CV_CALIB_FIX_ASPECT_RATIO ,
-CV_CALIB_FIX_INTRINSIC , or CV_CALIB_FIX_FOCAL_LENGTH are specified, some or all of the
+any of CALIB_USE_INTRINSIC_GUESS , CALIB_FIX_ASPECT_RATIO ,
+CALIB_FIX_INTRINSIC , or CALIB_FIX_FOCAL_LENGTH are specified, some or all of the
matrix components must be initialized. See the flags description for details.
@param distCoeffs1 Input/output vector of distortion coefficients
\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ of
@@ -937,21 +1013,21 @@ is similar to distCoeffs1 .
@param E Output essential matrix.
@param F Output fundamental matrix.
@param flags Different flags that may be zero or a combination of the following values:
-- **CV_CALIB_FIX_INTRINSIC** Fix cameraMatrix? and distCoeffs? so that only R, T, E , and F
+- **CALIB_FIX_INTRINSIC** Fix cameraMatrix? and distCoeffs? so that only R, T, E , and F
matrices are estimated.
-- **CV_CALIB_USE_INTRINSIC_GUESS** Optimize some or all of the intrinsic parameters
+- **CALIB_USE_INTRINSIC_GUESS** Optimize some or all of the intrinsic parameters
according to the specified flags. Initial values are provided by the user.
-- **CV_CALIB_FIX_PRINCIPAL_POINT** Fix the principal points during the optimization.
-- **CV_CALIB_FIX_FOCAL_LENGTH** Fix \f$f^{(j)}_x\f$ and \f$f^{(j)}_y\f$ .
-- **CV_CALIB_FIX_ASPECT_RATIO** Optimize \f$f^{(j)}_y\f$ . Fix the ratio \f$f^{(j)}_x/f^{(j)}_y\f$
+- **CALIB_FIX_PRINCIPAL_POINT** Fix the principal points during the optimization.
+- **CALIB_FIX_FOCAL_LENGTH** Fix \f$f^{(j)}_x\f$ and \f$f^{(j)}_y\f$ .
+- **CALIB_FIX_ASPECT_RATIO** Optimize \f$f^{(j)}_y\f$ . Fix the ratio \f$f^{(j)}_x/f^{(j)}_y\f$
.
-- **CV_CALIB_SAME_FOCAL_LENGTH** Enforce \f$f^{(0)}_x=f^{(1)}_x\f$ and \f$f^{(0)}_y=f^{(1)}_y\f$ .
-- **CV_CALIB_ZERO_TANGENT_DIST** Set tangential distortion coefficients for each camera to
+- **CALIB_SAME_FOCAL_LENGTH** Enforce \f$f^{(0)}_x=f^{(1)}_x\f$ and \f$f^{(0)}_y=f^{(1)}_y\f$ .
+- **CALIB_ZERO_TANGENT_DIST** Set tangential distortion coefficients for each camera to
zeros and fix there.
-- **CV_CALIB_FIX_K1,...,CV_CALIB_FIX_K6** Do not change the corresponding radial
-distortion coefficient during the optimization. If CV_CALIB_USE_INTRINSIC_GUESS is set,
+- **CALIB_FIX_K1,...,CALIB_FIX_K6** Do not change the corresponding radial
+distortion coefficient during the optimization. If CALIB_USE_INTRINSIC_GUESS is set,
the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
-- **CV_CALIB_RATIONAL_MODEL** Enable coefficients k4, k5, and k6. To provide the backward
+- **CALIB_RATIONAL_MODEL** Enable coefficients k4, k5, and k6. To provide the backward
compatibility, this extra flag should be explicitly specified to make the calibration
function use the rational model and return 8 coefficients. If the flag is not set, the
function computes and returns only 5 distortion coefficients.
@@ -960,14 +1036,14 @@ backward compatibility, this extra flag should be explicitly specified to make t
calibration function use the thin prism model and return 12 coefficients. If the flag is not
set, the function computes and returns only 5 distortion coefficients.
- **CALIB_FIX_S1_S2_S3_S4** The thin prism distortion coefficients are not changed during
-the optimization. If CV_CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
+the optimization. If CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
supplied distCoeffs matrix is used. Otherwise, it is set to 0.
- **CALIB_TILTED_MODEL** Coefficients tauX and tauY are enabled. To provide the
backward compatibility, this extra flag should be explicitly specified to make the
calibration function use the tilted sensor model and return 14 coefficients. If the flag is not
set, the function computes and returns only 5 distortion coefficients.
- **CALIB_FIX_TAUX_TAUY** The coefficients of the tilted sensor model are not changed during
-the optimization. If CV_CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
+the optimization. If CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
supplied distCoeffs matrix is used. Otherwise, it is set to 0.
@param criteria Termination criteria for the iterative optimization algorithm.
@@ -979,8 +1055,8 @@ This means that, given ( \f$R_1\f$,\f$T_1\f$ ), it should be possible to compute
need to know the position and orientation of the second camera relative to the first camera. This is
what the described function does. It computes ( \f$R\f$,\f$T\f$ ) so that:
-\f[R_2=R*R_1
-T_2=R*T_1 + T,\f]
+\f[R_2=R*R_1\f]
+\f[T_2=R*T_1 + T,\f]
Optionally, it computes the essential matrix E:
@@ -995,10 +1071,10 @@ Besides the stereo-related information, the function can also perform a full cal
two cameras. However, due to the high dimensionality of the parameter space and noise in the input
data, the function can diverge from the correct solution. If the intrinsic parameters can be
estimated with high accuracy for each of the cameras individually (for example, using
-calibrateCamera ), you are recommended to do so and then pass CV_CALIB_FIX_INTRINSIC flag to the
+calibrateCamera ), you are recommended to do so and then pass CALIB_FIX_INTRINSIC flag to the
function along with the computed intrinsic parameters. Otherwise, if all the parameters are
estimated at once, it makes sense to restrict some parameters, for example, pass
-CV_CALIB_SAME_FOCAL_LENGTH and CV_CALIB_ZERO_TANGENT_DIST flags, which is usually a
+CALIB_SAME_FOCAL_LENGTH and CALIB_ZERO_TANGENT_DIST flags, which is usually a
reasonable assumption.
Similarly to calibrateCamera , the function minimizes the total re-projection error for all the
@@ -1030,7 +1106,7 @@ camera.
@param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
camera.
@param Q Output \f$4 \times 4\f$ disparity-to-depth mapping matrix (see reprojectImageTo3D ).
- at param flags Operation flags that may be zero or CV_CALIB_ZERO_DISPARITY . If the flag is set,
+ at param flags Operation flags that may be zero or CALIB_ZERO_DISPARITY . If the flag is set,
the function makes the principal points of each camera have the same pixel coordinates in the
rectified views. And if the flag is not set, the function may still shift the images in the
horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
@@ -1069,7 +1145,7 @@ coordinates. The function distinguishes the following two cases:
\f[\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x*f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\f]
where \f$T_x\f$ is a horizontal shift between the cameras and \f$cx_1=cx_2\f$ if
- CV_CALIB_ZERO_DISPARITY is set.
+ CALIB_ZERO_DISPARITY is set.
- **Vertical stereo**: the first and the second camera views are shifted relative to each other
mainly in vertical direction (and probably a bit in the horizontal direction too). The epipolar
@@ -1433,6 +1509,28 @@ CV_EXPORTS_W int recoverPose( InputArray E, InputArray points1, InputArray point
double focal = 1.0, Point2d pp = Point2d(0, 0),
InputOutputArray mask = noArray() );
+/** @overload
+ at param E The input essential matrix.
+ at param points1 Array of N 2D points from the first image. The point coordinates should be
+floating-point (single or double precision).
+ at param points2 Array of the second image points of the same size and format as points1.
+ at param cameraMatrix Camera matrix \f$K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ .
+Note that this function assumes that points1 and points2 are feature points from cameras with the
+same camera matrix.
+ at param R Recovered relative rotation.
+ at param t Recoverd relative translation.
+ at param distanceThresh threshold distance which is used to filter out far away points (i.e. infinite points).
+ at param mask Input/output mask for inliers in points1 and points2.
+: If it is not empty, then it marks inliers in points1 and points2 for then given essential
+matrix E. Only these inliers will be used to recover pose. In the output mask only inliers
+which pass the cheirality check.
+ at param triangulatedPoints 3d points which were reconstructed by triangulation.
+ */
+
+CV_EXPORTS_W int recoverPose( InputArray E, InputArray points1, InputArray points2,
+ InputArray cameraMatrix, OutputArray R, OutputArray t, double distanceThresh, InputOutputArray mask = noArray(),
+ OutputArray triangulatedPoints = noArray());
+
/** @brief For points in an image of a stereo pair, computes the corresponding epilines in the other image.
@param points Input points. \f$N \times 1\f$ or \f$1 \times N\f$ matrix of type CV_32FC2 or
@@ -1809,7 +1907,8 @@ public:
{
MODE_SGBM = 0,
MODE_HH = 1,
- MODE_SGBM_3WAY = 2
+ MODE_SGBM_3WAY = 2,
+ MODE_HH4 = 3
};
CV_WRAP virtual int getPreFilterCap() const = 0;
@@ -1864,7 +1963,7 @@ public:
set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
to a custom value.
*/
- CV_WRAP static Ptr<StereoSGBM> create(int minDisparity, int numDisparities, int blockSize,
+ CV_WRAP static Ptr<StereoSGBM> create(int minDisparity = 0, int numDisparities = 16, int blockSize = 3,
int P1 = 0, int P2 = 0, int disp12MaxDiff = 0,
int preFilterCap = 0, int uniquenessRatio = 0,
int speckleWindowSize = 0, int speckleRange = 0,
@@ -2068,7 +2167,7 @@ optimization. It stays at the center or at a different location specified when C
@param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
camera.
@param Q Output \f$4 \times 4\f$ disparity-to-depth mapping matrix (see reprojectImageTo3D ).
- @param flags Operation flags that may be zero or CV_CALIB_ZERO_DISPARITY . If the flag is set,
+ @param flags Operation flags that may be zero or CALIB_ZERO_DISPARITY . If the flag is set,
the function makes the principal points of each camera have the same pixel coordinates in the
rectified views. And if the flag is not set, the function may still shift the images in the
horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
@@ -2094,7 +2193,7 @@ optimization. It stays at the center or at a different location specified when C
observed by the second camera.
@param K1 Input/output first camera matrix:
\f$\vecthreethree{f_x^{(j)}}{0}{c_x^{(j)}}{0}{f_y^{(j)}}{c_y^{(j)}}{0}{0}{1}\f$ , \f$j = 0,\, 1\f$ . If
- any of fisheye::CALIB_USE_INTRINSIC_GUESS , fisheye::CV_CALIB_FIX_INTRINSIC are specified,
+ any of fisheye::CALIB_USE_INTRINSIC_GUESS , fisheye::CALIB_FIX_INTRINSIC are specified,
some or all of the matrix components must be initialized.
@param D1 Input/output vector of distortion coefficients \f$(k_1, k_2, k_3, k_4)\f$ of 4 elements.
@param K2 Input/output second camera matrix. The parameter is similar to K1 .
@@ -2104,7 +2203,7 @@ optimization. It stays at the center or at a different location specified when C
@param R Output rotation matrix between the 1st and the 2nd camera coordinate systems.
@param T Output translation vector between the coordinate systems of the cameras.
@param flags Different flags that may be zero or a combination of the following values:
- - **fisheye::CV_CALIB_FIX_INTRINSIC** Fix K1, K2? and D1, D2? so that only R, T matrices
+ - **fisheye::CALIB_FIX_INTRINSIC** Fix K1, K2? and D1, D2? so that only R, T matrices
are estimated.
- **fisheye::CALIB_USE_INTRINSIC_GUESS** K1, K2 contains valid initial values of
fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
diff --git a/modules/calib3d/misc/java/gen_dict.json b/modules/calib3d/misc/java/gen_dict.json
new file mode 100644
index 0000000..0e35196
--- /dev/null
+++ b/modules/calib3d/misc/java/gen_dict.json
@@ -0,0 +1,42 @@
+{
+ "class_ignore_list": [
+ "CirclesGridFinderParameters"
+ ],
+ "missing_consts" : {
+ "Calib3d": {
+ "public" : [
+ ["CALIB_USE_INTRINSIC_GUESS", "1"],
+ ["CALIB_RECOMPUTE_EXTRINSIC", "2"],
+ ["CALIB_CHECK_COND", "4"],
+ ["CALIB_FIX_SKEW", "8"],
+ ["CALIB_FIX_K1", "16"],
+ ["CALIB_FIX_K2", "32"],
+ ["CALIB_FIX_K3", "64"],
+ ["CALIB_FIX_K4", "128"],
+ ["CALIB_FIX_INTRINSIC", "256"]
+ ]
+ }
+ },
+ "func_arg_fix" : {
+ "findFundamentalMat" : { "points1" : {"ctype" : "vector_Point2f"},
+ "points2" : {"ctype" : "vector_Point2f"} },
+ "cornerSubPix" : { "corners" : {"ctype" : "vector_Point2f"} },
+ "findHomography" : { "srcPoints" : {"ctype" : "vector_Point2f"},
+ "dstPoints" : {"ctype" : "vector_Point2f"} },
+ "solvePnP" : { "objectPoints" : {"ctype" : "vector_Point3f"},
+ "imagePoints" : {"ctype" : "vector_Point2f"},
+ "distCoeffs" : {"ctype" : "vector_double" } },
+ "solvePnPRansac" : { "objectPoints" : {"ctype" : "vector_Point3f"},
+ "imagePoints" : {"ctype" : "vector_Point2f"},
+ "distCoeffs" : {"ctype" : "vector_double" } },
+ "undistortPoints" : { "src" : {"ctype" : "vector_Point2f"},
+ "dst" : {"ctype" : "vector_Point2f"} },
+ "projectPoints" : { "objectPoints" : {"ctype" : "vector_Point3f"},
+ "imagePoints" : {"ctype" : "vector_Point2f"},
+ "distCoeffs" : {"ctype" : "vector_double" } },
+ "initCameraMatrix2D" : { "objectPoints" : {"ctype" : "vector_vector_Point3f"},
+ "imagePoints" : {"ctype" : "vector_vector_Point2f"} },
+ "findChessboardCorners" : { "corners" : {"ctype" : "vector_Point2f"} },
+ "drawChessboardCorners" : { "corners" : {"ctype" : "vector_Point2f"} }
+ }
+}
diff --git a/modules/calib3d/misc/java/test/Calib3dTest.java b/modules/calib3d/misc/java/test/Calib3dTest.java
index add668f..67193d9 100644
--- a/modules/calib3d/misc/java/test/Calib3dTest.java
+++ b/modules/calib3d/misc/java/test/Calib3dTest.java
@@ -499,7 +499,7 @@ public class Calib3dTest extends OpenCVTestCase {
}
public void testSolvePnPListOfPoint3ListOfPointMatMatMatMat() {
- Mat intrinsics = Mat.eye(3, 3, CvType.CV_32F);
+ Mat intrinsics = Mat.eye(3, 3, CvType.CV_64F);
intrinsics.put(0, 0, 400);
intrinsics.put(1, 1, 400);
intrinsics.put(0, 2, 640 / 2);
diff --git a/modules/calib3d/perf/perf_stereosgbm.cpp b/modules/calib3d/perf/perf_stereosgbm.cpp
index 8dc7162..4b54c2c 100644
--- a/modules/calib3d/perf/perf_stereosgbm.cpp
+++ b/modules/calib3d/perf/perf_stereosgbm.cpp
@@ -11,7 +11,7 @@
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met :
*
- * *Redistributions of source code must retain the above copyright notice,
+ * * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
@@ -38,20 +38,20 @@
namespace cvtest
{
-
-using std::tr1::tuple;
-using std::tr1::get;
using namespace perf;
using namespace testing;
-using namespace cv;
-void MakeArtificialExample(RNG rng, Mat& dst_left_view, Mat& dst_view);
+static void MakeArtificialExample(RNG rng, Mat& dst_left_view, Mat& dst_view);
-CV_ENUM(SGBMModes, StereoSGBM::MODE_SGBM, StereoSGBM::MODE_SGBM_3WAY);
+CV_ENUM(SGBMModes, StereoSGBM::MODE_SGBM, StereoSGBM::MODE_SGBM_3WAY, StereoSGBM::MODE_HH4);
typedef tuple<Size, int, SGBMModes> SGBMParams;
typedef TestBaseWithParam<SGBMParams> TestStereoCorresp;
+#ifndef _DEBUG
PERF_TEST_P( TestStereoCorresp, SGBM, Combine(Values(Size(1280,720),Size(640,480)), Values(256,128), SGBMModes::all()) )
+#else
+PERF_TEST_P( TestStereoCorresp, DISABLED_TooLongInDebug_SGBM, Combine(Values(Size(1280,720),Size(640,480)), Values(256,128), SGBMModes::all()) )
+#endif
{
RNG rng(0);
diff --git a/modules/calib3d/src/ap3p.cpp b/modules/calib3d/src/ap3p.cpp
new file mode 100644
index 0000000..6aa771d
--- /dev/null
+++ b/modules/calib3d/src/ap3p.cpp
@@ -0,0 +1,418 @@
+#include "ap3p.h"
+
+#include <cmath>
+#include <complex>
+#if defined (_MSC_VER) && (_MSC_VER <= 1700)
+static inline double cbrt(double x) { return (double)cv::cubeRoot((float)x); };
+#endif
+
+using namespace std;
+
+namespace {
+void solveQuartic(const double *factors, double *realRoots) {
+ const double &a4 = factors[0];
+ const double &a3 = factors[1];
+ const double &a2 = factors[2];
+ const double &a1 = factors[3];
+ const double &a0 = factors[4];
+
+ double a4_2 = a4 * a4;
+ double a3_2 = a3 * a3;
+ double a4_3 = a4_2 * a4;
+ double a2a4 = a2 * a4;
+
+ double p4 = (8 * a2a4 - 3 * a3_2) / (8 * a4_2);
+ double q4 = (a3_2 * a3 - 4 * a2a4 * a3 + 8 * a1 * a4_2) / (8 * a4_3);
+ double r4 = (256 * a0 * a4_3 - 3 * (a3_2 * a3_2) - 64 * a1 * a3 * a4_2 + 16 * a2a4 * a3_2) / (256 * (a4_3 * a4));
+
+ double p3 = ((p4 * p4) / 12 + r4) / 3; // /=-3
+ double q3 = (72 * r4 * p4 - 2 * p4 * p4 * p4 - 27 * q4 * q4) / 432; // /=2
+
+ double t; // *=2
+ complex<double> w;
+ if (q3 >= 0)
+ w = -sqrt(static_cast<complex<double> >(q3 * q3 - p3 * p3 * p3)) - q3;
+ else
+ w = sqrt(static_cast<complex<double> >(q3 * q3 - p3 * p3 * p3)) - q3;
+ if (w.imag() == 0.0) {
+ w.real(cbrt(w.real()));
+ t = 2.0 * (w.real() + p3 / w.real());
+ } else {
+ w = pow(w, 1.0 / 3);
+ t = 4.0 * w.real();
+ }
+
+ complex<double> sqrt_2m = sqrt(static_cast<complex<double> >(-2 * p4 / 3 + t));
+ double B_4A = -a3 / (4 * a4);
+ double complex1 = 4 * p4 / 3 + t;
+ complex<double> complex2 = 2 * q4 / sqrt_2m;
+ double sqrt_2m_rh = sqrt_2m.real() / 2;
+ double sqrt1 = sqrt(-(complex1 + complex2)).real() / 2;
+ realRoots[0] = B_4A + sqrt_2m_rh + sqrt1;
+ realRoots[1] = B_4A + sqrt_2m_rh - sqrt1;
+ double sqrt2 = sqrt(-(complex1 - complex2)).real() / 2;
+ realRoots[2] = B_4A - sqrt_2m_rh + sqrt2;
+ realRoots[3] = B_4A - sqrt_2m_rh - sqrt2;
+}
+
+void polishQuarticRoots(const double *coeffs, double *roots) {
+ const int iterations = 2;
+ for (int i = 0; i < iterations; ++i) {
+ for (int j = 0; j < 4; ++j) {
+ double error =
+ (((coeffs[0] * roots[j] + coeffs[1]) * roots[j] + coeffs[2]) * roots[j] + coeffs[3]) * roots[j] +
+ coeffs[4];
+ double
+ derivative =
+ ((4 * coeffs[0] * roots[j] + 3 * coeffs[1]) * roots[j] + 2 * coeffs[2]) * roots[j] + coeffs[3];
+ roots[j] -= error / derivative;
+ }
+ }
+}
+
+inline void vect_cross(const double *a, const double *b, double *result) {
+ result[0] = a[1] * b[2] - a[2] * b[1];
+ result[1] = -(a[0] * b[2] - a[2] * b[0]);
+ result[2] = a[0] * b[1] - a[1] * b[0];
+}
+
+inline double vect_dot(const double *a, const double *b) {
+ return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
+}
+
+inline double vect_norm(const double *a) {
+ return sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]);
+}
+
+inline void vect_scale(const double s, const double *a, double *result) {
+ result[0] = a[0] * s;
+ result[1] = a[1] * s;
+ result[2] = a[2] * s;
+}
+
+inline void vect_sub(const double *a, const double *b, double *result) {
+ result[0] = a[0] - b[0];
+ result[1] = a[1] - b[1];
+ result[2] = a[2] - b[2];
+}
+
+inline void vect_divide(const double *a, const double d, double *result) {
+ result[0] = a[0] / d;
+ result[1] = a[1] / d;
+ result[2] = a[2] / d;
+}
+
+inline void mat_mult(const double a[3][3], const double b[3][3], double result[3][3]) {
+ result[0][0] = a[0][0] * b[0][0] + a[0][1] * b[1][0] + a[0][2] * b[2][0];
+ result[0][1] = a[0][0] * b[0][1] + a[0][1] * b[1][1] + a[0][2] * b[2][1];
+ result[0][2] = a[0][0] * b[0][2] + a[0][1] * b[1][2] + a[0][2] * b[2][2];
+
+ result[1][0] = a[1][0] * b[0][0] + a[1][1] * b[1][0] + a[1][2] * b[2][0];
+ result[1][1] = a[1][0] * b[0][1] + a[1][1] * b[1][1] + a[1][2] * b[2][1];
+ result[1][2] = a[1][0] * b[0][2] + a[1][1] * b[1][2] + a[1][2] * b[2][2];
+
+ result[2][0] = a[2][0] * b[0][0] + a[2][1] * b[1][0] + a[2][2] * b[2][0];
+ result[2][1] = a[2][0] * b[0][1] + a[2][1] * b[1][1] + a[2][2] * b[2][1];
+ result[2][2] = a[2][0] * b[0][2] + a[2][1] * b[1][2] + a[2][2] * b[2][2];
+}
+}
+
+namespace cv {
+void ap3p::init_inverse_parameters() {
+ inv_fx = 1. / fx;
+ inv_fy = 1. / fy;
+ cx_fx = cx / fx;
+ cy_fy = cy / fy;
+}
+
+ap3p::ap3p(cv::Mat cameraMatrix) {
+ if (cameraMatrix.depth() == CV_32F)
+ init_camera_parameters<float>(cameraMatrix);
+ else
+ init_camera_parameters<double>(cameraMatrix);
+ init_inverse_parameters();
+}
+
+ap3p::ap3p(double _fx, double _fy, double _cx, double _cy) {
+ fx = _fx;
+ fy = _fy;
+ cx = _cx;
+ cy = _cy;
+ init_inverse_parameters();
+}
+
+// This algorithm is from "Tong Ke, Stergios Roumeliotis, An Efficient Algebraic Solution to the Perspective-Three-Point Problem" (Accepted by CVPR 2017)
+// See https://arxiv.org/pdf/1701.08237.pdf
+// featureVectors: The 3 bearing measurements (normalized) stored as column vectors
+// worldPoints: The positions of the 3 feature points stored as column vectors
+// solutionsR: 4 possible solutions of rotation matrix of the world w.r.t the camera frame
+// solutionsT: 4 possible solutions of translation of the world origin w.r.t the camera frame
+int ap3p::computePoses(const double featureVectors[3][3],
+ const double worldPoints[3][3],
+ double solutionsR[4][3][3],
+ double solutionsT[4][3]) {
+
+ //world point vectors
+ double w1[3] = {worldPoints[0][0], worldPoints[1][0], worldPoints[2][0]};
+ double w2[3] = {worldPoints[0][1], worldPoints[1][1], worldPoints[2][1]};
+ double w3[3] = {worldPoints[0][2], worldPoints[1][2], worldPoints[2][2]};
+ // k1
+ double u0[3];
+ vect_sub(w1, w2, u0);
+
+ double nu0 = vect_norm(u0);
+ double k1[3];
+ vect_divide(u0, nu0, k1);
+ // bi
+ double b1[3] = {featureVectors[0][0], featureVectors[1][0], featureVectors[2][0]};
+ double b2[3] = {featureVectors[0][1], featureVectors[1][1], featureVectors[2][1]};
+ double b3[3] = {featureVectors[0][2], featureVectors[1][2], featureVectors[2][2]};
+ // k3,tz
+ double k3[3];
+ vect_cross(b1, b2, k3);
+ double nk3 = vect_norm(k3);
+ vect_divide(k3, nk3, k3);
+
+ double tz[3];
+ vect_cross(b1, k3, tz);
+ // ui,vi
+ double v1[3];
+ vect_cross(b1, b3, v1);
+ double v2[3];
+ vect_cross(b2, b3, v2);
+
+ double u1[3];
+ vect_sub(w1, w3, u1);
+ // coefficients related terms
+ double u1k1 = vect_dot(u1, k1);
+ double k3b3 = vect_dot(k3, b3);
+ // f1i
+ double f11 = k3b3;
+ double f13 = vect_dot(k3, v1);
+ double f15 = -u1k1 * f11;
+ //delta
+ double nl[3];
+ vect_cross(u1, k1, nl);
+ double delta = vect_norm(nl);
+ vect_divide(nl, delta, nl);
+ f11 *= delta;
+ f13 *= delta;
+ // f2i
+ double u2k1 = u1k1 - nu0;
+ double f21 = vect_dot(tz, v2);
+ double f22 = nk3 * k3b3;
+ double f23 = vect_dot(k3, v2);
+ double f24 = u2k1 * f22;
+ double f25 = -u2k1 * f21;
+ f21 *= delta;
+ f22 *= delta;
+ f23 *= delta;
+ double g1 = f13 * f22;
+ double g2 = f13 * f25 - f15 * f23;
+ double g3 = f11 * f23 - f13 * f21;
+ double g4 = -f13 * f24;
+ double g5 = f11 * f22;
+ double g6 = f11 * f25 - f15 * f21;
+ double g7 = -f15 * f24;
+ double coeffs[5] = {g5 * g5 + g1 * g1 + g3 * g3,
+ 2 * (g5 * g6 + g1 * g2 + g3 * g4),
+ g6 * g6 + 2 * g5 * g7 + g2 * g2 + g4 * g4 - g1 * g1 - g3 * g3,
+ 2 * (g6 * g7 - g1 * g2 - g3 * g4),
+ g7 * g7 - g2 * g2 - g4 * g4};
+ double s[4];
+ solveQuartic(coeffs, s);
+ polishQuarticRoots(coeffs, s);
+
+ double temp[3];
+ vect_cross(k1, nl, temp);
+
+ double Ck1nl[3][3] =
+ {{k1[0], nl[0], temp[0]},
+ {k1[1], nl[1], temp[1]},
+ {k1[2], nl[2], temp[2]}};
+
+ double Cb1k3tzT[3][3] =
+ {{b1[0], b1[1], b1[2]},
+ {k3[0], k3[1], k3[2]},
+ {tz[0], tz[1], tz[2]}};
+
+ double b3p[3];
+ vect_scale((delta / k3b3), b3, b3p);
+
+ int nb_solutions = 0;
+ for (int i = 0; i < 4; ++i) {
+ double ctheta1p = s[i];
+ if (abs(ctheta1p) > 1)
+ continue;
+ double stheta1p = sqrt(1 - ctheta1p * ctheta1p);
+ stheta1p = (k3b3 > 0) ? stheta1p : -stheta1p;
+ double ctheta3 = g1 * ctheta1p + g2;
+ double stheta3 = g3 * ctheta1p + g4;
+ double ntheta3 = stheta1p / ((g5 * ctheta1p + g6) * ctheta1p + g7);
+ ctheta3 *= ntheta3;
+ stheta3 *= ntheta3;
+
+ double C13[3][3] =
+ {{ctheta3, 0, -stheta3},
+ {stheta1p * stheta3, ctheta1p, stheta1p * ctheta3},
+ {ctheta1p * stheta3, -stheta1p, ctheta1p * ctheta3}};
+
+ double temp_matrix[3][3];
+ double R[3][3];
+ mat_mult(Ck1nl, C13, temp_matrix);
+ mat_mult(temp_matrix, Cb1k3tzT, R);
+
+ // R' * p3
+ double rp3[3] =
+ {w3[0] * R[0][0] + w3[1] * R[1][0] + w3[2] * R[2][0],
+ w3[0] * R[0][1] + w3[1] * R[1][1] + w3[2] * R[2][1],
+ w3[0] * R[0][2] + w3[1] * R[1][2] + w3[2] * R[2][2]};
+
+ double pxstheta1p[3];
+ vect_scale(stheta1p, b3p, pxstheta1p);
+
+ vect_sub(pxstheta1p, rp3, solutionsT[nb_solutions]);
+
+ solutionsR[nb_solutions][0][0] = R[0][0];
+ solutionsR[nb_solutions][1][0] = R[0][1];
+ solutionsR[nb_solutions][2][0] = R[0][2];
+ solutionsR[nb_solutions][0][1] = R[1][0];
+ solutionsR[nb_solutions][1][1] = R[1][1];
+ solutionsR[nb_solutions][2][1] = R[1][2];
+ solutionsR[nb_solutions][0][2] = R[2][0];
+ solutionsR[nb_solutions][1][2] = R[2][1];
+ solutionsR[nb_solutions][2][2] = R[2][2];
+
+ nb_solutions++;
+ }
+
+ return nb_solutions;
+}
+
+bool ap3p::solve(cv::Mat &R, cv::Mat &tvec, const cv::Mat &opoints, const cv::Mat &ipoints) {
+ CV_INSTRUMENT_REGION()
+
+ double rotation_matrix[3][3], translation[3];
+ std::vector<double> points;
+ if (opoints.depth() == ipoints.depth()) {
+ if (opoints.depth() == CV_32F)
+ extract_points<cv::Point3f, cv::Point2f>(opoints, ipoints, points);
+ else
+ extract_points<cv::Point3d, cv::Point2d>(opoints, ipoints, points);
+ } else if (opoints.depth() == CV_32F)
+ extract_points<cv::Point3f, cv::Point2d>(opoints, ipoints, points);
+ else
+ extract_points<cv::Point3d, cv::Point2f>(opoints, ipoints, points);
+
+ bool result = solve(rotation_matrix, translation, points[0], points[1], points[2], points[3], points[4], points[5],
+ points[6], points[7], points[8], points[9], points[10], points[11], points[12], points[13],
+ points[14],
+ points[15], points[16], points[17], points[18], points[19]);
+ cv::Mat(3, 1, CV_64F, translation).copyTo(tvec);
+ cv::Mat(3, 3, CV_64F, rotation_matrix).copyTo(R);
+ return result;
+}
+
+int ap3p::solve(std::vector<cv::Mat> &Rs, std::vector<cv::Mat> &tvecs, const cv::Mat &opoints, const cv::Mat &ipoints) {
+ CV_INSTRUMENT_REGION()
+
+ double rotation_matrix[4][3][3], translation[4][3];
+ std::vector<double> points;
+ if (opoints.depth() == ipoints.depth()) {
+ if (opoints.depth() == CV_32F)
+ extract_points<cv::Point3f, cv::Point2f>(opoints, ipoints, points);
+ else
+ extract_points<cv::Point3d, cv::Point2d>(opoints, ipoints, points);
+ } else if (opoints.depth() == CV_32F)
+ extract_points<cv::Point3f, cv::Point2d>(opoints, ipoints, points);
+ else
+ extract_points<cv::Point3d, cv::Point2f>(opoints, ipoints, points);
+
+ int solutions = solve(rotation_matrix, translation,
+ points[0], points[1], points[2], points[3], points[4],
+ points[5], points[6], points[7], points[8], points[9],
+ points[10], points[11], points[12], points[13], points[14]);
+
+ for (int i = 0; i < solutions; i++) {
+ cv::Mat R, tvec;
+ cv::Mat(3, 1, CV_64F, translation[i]).copyTo(tvec);
+ cv::Mat(3, 3, CV_64F, rotation_matrix[i]).copyTo(R);
+
+ Rs.push_back(R);
+ tvecs.push_back(tvec);
+ }
+
+ return solutions;
+}
+
+bool
+ap3p::solve(double R[3][3], double t[3], double mu0, double mv0, double X0, double Y0, double Z0, double mu1,
+ double mv1,
+ double X1, double Y1, double Z1, double mu2, double mv2, double X2, double Y2, double Z2, double mu3,
+ double mv3, double X3, double Y3, double Z3) {
+ double Rs[4][3][3], ts[4][3];
+
+ int n = solve(Rs, ts, mu0, mv0, X0, Y0, Z0, mu1, mv1, X1, Y1, Z1, mu2, mv2, X2, Y2, Z2);
+ if (n == 0)
+ return false;
+
+ int ns = 0;
+ double min_reproj = 0;
+ for (int i = 0; i < n; i++) {
+ double X3p = Rs[i][0][0] * X3 + Rs[i][0][1] * Y3 + Rs[i][0][2] * Z3 + ts[i][0];
+ double Y3p = Rs[i][1][0] * X3 + Rs[i][1][1] * Y3 + Rs[i][1][2] * Z3 + ts[i][1];
+ double Z3p = Rs[i][2][0] * X3 + Rs[i][2][1] * Y3 + Rs[i][2][2] * Z3 + ts[i][2];
+ double mu3p = cx + fx * X3p / Z3p;
+ double mv3p = cy + fy * Y3p / Z3p;
+ double reproj = (mu3p - mu3) * (mu3p - mu3) + (mv3p - mv3) * (mv3p - mv3);
+ if (i == 0 || min_reproj > reproj) {
+ ns = i;
+ min_reproj = reproj;
+ }
+ }
+
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < 3; j++)
+ R[i][j] = Rs[ns][i][j];
+ t[i] = ts[ns][i];
+ }
+
+ return true;
+}
+
+int ap3p::solve(double R[4][3][3], double t[4][3], double mu0, double mv0, double X0, double Y0, double Z0, double mu1,
+ double mv1, double X1, double Y1, double Z1, double mu2, double mv2, double X2, double Y2, double Z2) {
+ double mk0, mk1, mk2;
+ double norm;
+
+ mu0 = inv_fx * mu0 - cx_fx;
+ mv0 = inv_fy * mv0 - cy_fy;
+ norm = sqrt(mu0 * mu0 + mv0 * mv0 + 1);
+ mk0 = 1. / norm;
+ mu0 *= mk0;
+ mv0 *= mk0;
+
+ mu1 = inv_fx * mu1 - cx_fx;
+ mv1 = inv_fy * mv1 - cy_fy;
+ norm = sqrt(mu1 * mu1 + mv1 * mv1 + 1);
+ mk1 = 1. / norm;
+ mu1 *= mk1;
+ mv1 *= mk1;
+
+ mu2 = inv_fx * mu2 - cx_fx;
+ mv2 = inv_fy * mv2 - cy_fy;
+ norm = sqrt(mu2 * mu2 + mv2 * mv2 + 1);
+ mk2 = 1. / norm;
+ mu2 *= mk2;
+ mv2 *= mk2;
+
+ double featureVectors[3][3] = {{mu0, mu1, mu2},
+ {mv0, mv1, mv2},
+ {mk0, mk1, mk2}};
+ double worldPoints[3][3] = {{X0, X1, X2},
+ {Y0, Y1, Y2},
+ {Z0, Z1, Z2}};
+
+ return computePoses(featureVectors, worldPoints, R, t);
+}
+}
diff --git a/modules/calib3d/src/ap3p.h b/modules/calib3d/src/ap3p.h
new file mode 100644
index 0000000..df44198
--- /dev/null
+++ b/modules/calib3d/src/ap3p.h
@@ -0,0 +1,67 @@
+#ifndef P3P_P3P_H
+#define P3P_P3P_H
+
+#include "precomp.hpp"
+
+namespace cv {
+class ap3p {
+private:
+ template<typename T>
+ void init_camera_parameters(const cv::Mat &cameraMatrix) {
+ cx = cameraMatrix.at<T>(0, 2);
+ cy = cameraMatrix.at<T>(1, 2);
+ fx = cameraMatrix.at<T>(0, 0);
+ fy = cameraMatrix.at<T>(1, 1);
+ }
+
+ template<typename OpointType, typename IpointType>
+ void extract_points(const cv::Mat &opoints, const cv::Mat &ipoints, std::vector<double> &points) {
+ points.clear();
+ int npoints = std::max(opoints.checkVector(3, CV_32F), opoints.checkVector(3, CV_64F));
+ points.resize(5*npoints);
+ for (int i = 0; i < npoints; i++) {
+ points[i * 5] = ipoints.at<IpointType>(i).x * fx + cx;
+ points[i * 5 + 1] = ipoints.at<IpointType>(i).y * fy + cy;
+ points[i * 5 + 2] = opoints.at<OpointType>(i).x;
+ points[i * 5 + 3] = opoints.at<OpointType>(i).y;
+ points[i * 5 + 4] = opoints.at<OpointType>(i).z;
+ }
+ }
+
+ void init_inverse_parameters();
+
+ double fx, fy, cx, cy;
+ double inv_fx, inv_fy, cx_fx, cy_fy;
+public:
+ ap3p() : fx(0), fy(0), cx(0), cy(0), inv_fx(0), inv_fy(0), cx_fx(0), cy_fy(0) {}
+
+ ap3p(double fx, double fy, double cx, double cy);
+
+ ap3p(cv::Mat cameraMatrix);
+
+ bool solve(cv::Mat &R, cv::Mat &tvec, const cv::Mat &opoints, const cv::Mat &ipoints);
+ int solve(std::vector<cv::Mat> &Rs, std::vector<cv::Mat> &tvecs, const cv::Mat &opoints, const cv::Mat &ipoints);
+
+ int solve(double R[4][3][3], double t[4][3],
+ double mu0, double mv0, double X0, double Y0, double Z0,
+ double mu1, double mv1, double X1, double Y1, double Z1,
+ double mu2, double mv2, double X2, double Y2, double Z2);
+
+ bool solve(double R[3][3], double t[3],
+ double mu0, double mv0, double X0, double Y0, double Z0,
+ double mu1, double mv1, double X1, double Y1, double Z1,
+ double mu2, double mv2, double X2, double Y2, double Z2,
+ double mu3, double mv3, double X3, double Y3, double Z3);
+
+ // This algorithm is from "Tong Ke, Stergios Roumeliotis, An Efficient Algebraic Solution to the Perspective-Three-Point Problem" (Accepted by CVPR 2017)
+ // See https://arxiv.org/pdf/1701.08237.pdf
+ // featureVectors: 3 bearing measurements (normalized) stored as column vectors
+ // worldPoints: Positions of the 3 feature points stored as column vectors
+ // solutionsR: 4 possible solutions of rotation matrix of the world w.r.t the camera frame
+ // solutionsT: 4 possible solutions of translation of the world origin w.r.t the camera frame
+ int computePoses(const double featureVectors[3][3], const double worldPoints[3][3], double solutionsR[4][3][3],
+ double solutionsT[4][3]);
+
+};
+}
+#endif //P3P_P3P_H
diff --git a/modules/calib3d/src/calibinit.cpp b/modules/calib3d/src/calibinit.cpp
index 2e9f07a..c93415c 100644
--- a/modules/calib3d/src/calibinit.cpp
+++ b/modules/calib3d/src/calibinit.cpp
@@ -442,7 +442,7 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size,
Mat img = cvarrToMat((CvMat*)arr).clone();
- if( img.depth() != CV_8U || (img.channels() != 1 && img.channels() != 3) )
+ if( img.depth() != CV_8U || (img.channels() != 1 && img.channels() != 3 && img.channels() != 4) )
CV_Error( CV_StsUnsupportedFormat, "Only 8-bit grayscale or color images are supported" );
if( pattern_size.width <= 2 || pattern_size.height <= 2 )
@@ -1836,7 +1836,9 @@ icvGenerateQuads( CvCBQuad **out_quads, CvCBCorner **out_corners,
assert( src_contour->total == 4 );
for( i = 0; i < 4; i++ )
{
- CvPoint2D32f pt = cvPointTo32f(*(CvPoint*)cvGetSeqElem(src_contour, i));
+ CvPoint * onePoint = (CvPoint*)cvGetSeqElem(src_contour, i);
+ CV_Assert(onePoint != NULL);
+ CvPoint2D32f pt = cvPointTo32f(*onePoint);
CvCBCorner* corner = &(*out_corners)[quad_count*4 + i];
memset( corner, 0, sizeof(*corner) );
@@ -2093,7 +2095,8 @@ void cv::drawChessboardCorners( InputOutputArray _image, Size patternSize,
}
bool cv::findCirclesGrid( InputArray _image, Size patternSize,
- OutputArray _centers, int flags, const Ptr<FeatureDetector> &blobDetector )
+ OutputArray _centers, int flags, const Ptr<FeatureDetector> &blobDetector,
+ CirclesGridFinderParameters parameters)
{
CV_INSTRUMENT_REGION()
@@ -2120,13 +2123,6 @@ bool cv::findCirclesGrid( InputArray _image, Size patternSize,
return !centers.empty();
}
- CirclesGridFinderParameters parameters;
- parameters.vertexPenalty = -0.6f;
- parameters.vertexGain = 1;
- parameters.existingVertexGain = 10000;
- parameters.edgeGain = 1;
- parameters.edgePenalty = -0.6f;
-
if(flags & CALIB_CB_ASYMMETRIC_GRID)
parameters.gridType = CirclesGridFinderParameters::ASYMMETRIC_GRID;
if(flags & CALIB_CB_SYMMETRIC_GRID)
@@ -2192,4 +2188,10 @@ bool cv::findCirclesGrid( InputArray _image, Size patternSize,
return false;
}
+bool cv::findCirclesGrid( InputArray _image, Size patternSize,
+ OutputArray _centers, int flags, const Ptr<FeatureDetector> &blobDetector)
+{
+ return cv::findCirclesGrid(_image, patternSize, _centers, flags, blobDetector, CirclesGridFinderParameters());
+}
+
/* End of file. */
diff --git a/modules/calib3d/src/calibration.cpp b/modules/calib3d/src/calibration.cpp
index b90e71c..3156928 100644
--- a/modules/calib3d/src/calibration.cpp
+++ b/modules/calib3d/src/calibration.cpp
@@ -252,7 +252,7 @@ CV_IMPL int cvRodrigues2( const CvMat* src, CvMat* dst, CvMat* jacobian )
{
int depth, elem_size;
int i, k;
- double J[27];
+ double J[27] = {0};
CvMat matJ = cvMat( 3, 9, CV_64F, J );
if( !CV_IS_MAT(src) )
@@ -1189,7 +1189,7 @@ CV_IMPL void cvInitIntrinsicParams2D( const CvMat* objectPoints,
int i, j, pos, nimages, ni = 0;
double a[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 1 };
- double H[9], f[2];
+ double H[9] = {0}, f[2] = {0};
CvMat _a = cvMat( 3, 3, CV_64F, a );
CvMat matH = cvMat( 3, 3, CV_64F, H );
CvMat _f = cvMat( 2, 1, CV_64F, f );
@@ -1319,7 +1319,7 @@ static double cvCalibrateCamera2Internal( const CvMat* objectPoints,
(npoints->rows != 1 && npoints->cols != 1) )
CV_Error( CV_StsUnsupportedFormat,
"the array of point counters must be 1-dimensional integer vector" );
- if(flags & CV_CALIB_TILTED_MODEL)
+ if(flags & CALIB_TILTED_MODEL)
{
//when the tilted sensor model is used the distortion coefficients matrix must have 14 parameters
if (distCoeffs->cols*distCoeffs->rows != 14)
@@ -1328,7 +1328,7 @@ static double cvCalibrateCamera2Internal( const CvMat* objectPoints,
else
{
//when the thin prism model is used the distortion coefficients matrix must have 12 parameters
- if(flags & CV_CALIB_THIN_PRISM_MODEL)
+ if(flags & CALIB_THIN_PRISM_MODEL)
if (distCoeffs->cols*distCoeffs->rows != 12)
CV_Error( CV_StsBadArg, "Thin prism model must have 12 parameters in the distortion matrix" );
}
@@ -1498,24 +1498,28 @@ static double cvCalibrateCamera2Internal( const CvMat* objectPoints,
if(flags & CALIB_FIX_ASPECT_RATIO)
mask[0] = 0;
- if( flags & CV_CALIB_FIX_FOCAL_LENGTH )
+ if( flags & CALIB_FIX_FOCAL_LENGTH )
mask[0] = mask[1] = 0;
- if( flags & CV_CALIB_FIX_PRINCIPAL_POINT )
+ if( flags & CALIB_FIX_PRINCIPAL_POINT )
mask[2] = mask[3] = 0;
- if( flags & CV_CALIB_ZERO_TANGENT_DIST )
+ if( flags & CALIB_ZERO_TANGENT_DIST )
{
param[6] = param[7] = 0;
mask[6] = mask[7] = 0;
}
if( !(flags & CALIB_RATIONAL_MODEL) )
flags |= CALIB_FIX_K4 + CALIB_FIX_K5 + CALIB_FIX_K6;
- if( !(flags & CV_CALIB_THIN_PRISM_MODEL))
+ if( !(flags & CALIB_THIN_PRISM_MODEL))
flags |= CALIB_FIX_S1_S2_S3_S4;
- if( !(flags & CV_CALIB_TILTED_MODEL))
+ if( !(flags & CALIB_TILTED_MODEL))
flags |= CALIB_FIX_TAUX_TAUY;
mask[ 4] = !(flags & CALIB_FIX_K1);
mask[ 5] = !(flags & CALIB_FIX_K2);
+ if( flags & CALIB_FIX_TANGENT_DIST )
+ {
+ mask[6] = mask[7] = 0;
+ }
mask[ 8] = !(flags & CALIB_FIX_K3);
mask[ 9] = !(flags & CALIB_FIX_K4);
mask[10] = !(flags & CALIB_FIX_K5);
@@ -1727,7 +1731,7 @@ void cvCalibrationMatrixValues( const CvMat *calibMatr, CvSize imgSize,
if(!CV_IS_MAT(calibMatr))
CV_Error(CV_StsUnsupportedFormat, "Input parameters must be a matrices!");
- double dummy;
+ double dummy = .0;
Point2d pp;
cv::calibrationMatrixValues(cvarrToMat(calibMatr), imgSize, apertureWidth, apertureHeight,
fovx ? *fovx : dummy,
@@ -1817,39 +1821,39 @@ double cvStereoCalibrate( const CvMat* _objectPoints, const CvMat* _imagePoints1
cvConvert( points, imagePoints[k] );
cvReshape( imagePoints[k], imagePoints[k], 2, 1 );
- if( flags & (CV_CALIB_FIX_INTRINSIC|CV_CALIB_USE_INTRINSIC_GUESS|
- CV_CALIB_FIX_ASPECT_RATIO|CV_CALIB_FIX_FOCAL_LENGTH) )
+ if( flags & (CALIB_FIX_INTRINSIC|CALIB_USE_INTRINSIC_GUESS|
+ CALIB_FIX_ASPECT_RATIO|CALIB_FIX_FOCAL_LENGTH) )
cvConvert( cameraMatrix, &K[k] );
- if( flags & (CV_CALIB_FIX_INTRINSIC|CV_CALIB_USE_INTRINSIC_GUESS|
- CV_CALIB_FIX_K1|CV_CALIB_FIX_K2|CV_CALIB_FIX_K3|CV_CALIB_FIX_K4|CV_CALIB_FIX_K5|CV_CALIB_FIX_K6) )
+ if( flags & (CALIB_FIX_INTRINSIC|CALIB_USE_INTRINSIC_GUESS|
+ CALIB_FIX_K1|CALIB_FIX_K2|CALIB_FIX_K3|CALIB_FIX_K4|CALIB_FIX_K5|CALIB_FIX_K6) )
{
CvMat tdist = cvMat( distCoeffs->rows, distCoeffs->cols,
CV_MAKETYPE(CV_64F,CV_MAT_CN(distCoeffs->type)), Dist[k].data.db );
cvConvert( distCoeffs, &tdist );
}
- if( !(flags & (CV_CALIB_FIX_INTRINSIC|CV_CALIB_USE_INTRINSIC_GUESS)))
+ if( !(flags & (CALIB_FIX_INTRINSIC|CALIB_USE_INTRINSIC_GUESS)))
{
cvCalibrateCamera2( objectPoints, imagePoints[k],
npoints, imageSize, &K[k], &Dist[k], NULL, NULL, flags );
}
}
- if( flags & CV_CALIB_SAME_FOCAL_LENGTH )
+ if( flags & CALIB_SAME_FOCAL_LENGTH )
{
static const int avg_idx[] = { 0, 4, 2, 5, -1 };
for( k = 0; avg_idx[k] >= 0; k++ )
A[0][avg_idx[k]] = A[1][avg_idx[k]] = (A[0][avg_idx[k]] + A[1][avg_idx[k]])*0.5;
}
- if( flags & CV_CALIB_FIX_ASPECT_RATIO )
+ if( flags & CALIB_FIX_ASPECT_RATIO )
{
for( k = 0; k < 2; k++ )
aspectRatio[k] = A[k][0]/A[k][4];
}
- recomputeIntrinsics = (flags & CV_CALIB_FIX_INTRINSIC) == 0;
+ recomputeIntrinsics = (flags & CALIB_FIX_INTRINSIC) == 0;
err.reset(cvCreateMat( maxPoints*2, 1, CV_64F ));
Je.reset(cvCreateMat( maxPoints*2, 6, CV_64F ));
@@ -1873,40 +1877,40 @@ double cvStereoCalibrate( const CvMat* _objectPoints, const CvMat* _imagePoints1
if( recomputeIntrinsics )
{
uchar* imask = solver.mask->data.ptr + nparams - NINTRINSIC*2;
- if( !(flags & CV_CALIB_RATIONAL_MODEL) )
- flags |= CV_CALIB_FIX_K4 | CV_CALIB_FIX_K5 | CV_CALIB_FIX_K6;
- if( !(flags & CV_CALIB_THIN_PRISM_MODEL) )
- flags |= CV_CALIB_FIX_S1_S2_S3_S4;
- if( !(flags & CV_CALIB_TILTED_MODEL) )
- flags |= CV_CALIB_FIX_TAUX_TAUY;
- if( flags & CV_CALIB_FIX_ASPECT_RATIO )
+ if( !(flags & CALIB_RATIONAL_MODEL) )
+ flags |= CALIB_FIX_K4 | CALIB_FIX_K5 | CALIB_FIX_K6;
+ if( !(flags & CALIB_THIN_PRISM_MODEL) )
+ flags |= CALIB_FIX_S1_S2_S3_S4;
+ if( !(flags & CALIB_TILTED_MODEL) )
+ flags |= CALIB_FIX_TAUX_TAUY;
+ if( flags & CALIB_FIX_ASPECT_RATIO )
imask[0] = imask[NINTRINSIC] = 0;
- if( flags & CV_CALIB_FIX_FOCAL_LENGTH )
+ if( flags & CALIB_FIX_FOCAL_LENGTH )
imask[0] = imask[1] = imask[NINTRINSIC] = imask[NINTRINSIC+1] = 0;
- if( flags & CV_CALIB_FIX_PRINCIPAL_POINT )
+ if( flags & CALIB_FIX_PRINCIPAL_POINT )
imask[2] = imask[3] = imask[NINTRINSIC+2] = imask[NINTRINSIC+3] = 0;
- if( flags & CV_CALIB_ZERO_TANGENT_DIST )
+ if( flags & CALIB_ZERO_TANGENT_DIST )
imask[6] = imask[7] = imask[NINTRINSIC+6] = imask[NINTRINSIC+7] = 0;
- if( flags & CV_CALIB_FIX_K1 )
+ if( flags & CALIB_FIX_K1 )
imask[4] = imask[NINTRINSIC+4] = 0;
- if( flags & CV_CALIB_FIX_K2 )
+ if( flags & CALIB_FIX_K2 )
imask[5] = imask[NINTRINSIC+5] = 0;
- if( flags & CV_CALIB_FIX_K3 )
+ if( flags & CALIB_FIX_K3 )
imask[8] = imask[NINTRINSIC+8] = 0;
- if( flags & CV_CALIB_FIX_K4 )
+ if( flags & CALIB_FIX_K4 )
imask[9] = imask[NINTRINSIC+9] = 0;
- if( flags & CV_CALIB_FIX_K5 )
+ if( flags & CALIB_FIX_K5 )
imask[10] = imask[NINTRINSIC+10] = 0;
- if( flags & CV_CALIB_FIX_K6 )
+ if( flags & CALIB_FIX_K6 )
imask[11] = imask[NINTRINSIC+11] = 0;
- if( flags & CV_CALIB_FIX_S1_S2_S3_S4 )
+ if( flags & CALIB_FIX_S1_S2_S3_S4 )
{
imask[12] = imask[NINTRINSIC+12] = 0;
imask[13] = imask[NINTRINSIC+13] = 0;
imask[14] = imask[NINTRINSIC+14] = 0;
imask[15] = imask[NINTRINSIC+15] = 0;
}
- if( flags & CV_CALIB_FIX_TAUX_TAUY )
+ if( flags & CALIB_FIX_TAUX_TAUY )
{
imask[16] = imask[NINTRINSIC+16] = 0;
imask[17] = imask[NINTRINSIC+17] = 0;
@@ -1977,7 +1981,7 @@ double cvStereoCalibrate( const CvMat* _objectPoints, const CvMat* _imagePoints1
for( k = 0; k < 2; k++ )
{
double* iparam = solver.param->data.db + (nimages+1)*6 + k*NINTRINSIC;
- if( flags & CV_CALIB_ZERO_TANGENT_DIST )
+ if( flags & CALIB_ZERO_TANGENT_DIST )
dk[k][2] = dk[k][3] = 0;
iparam[0] = A[k][0]; iparam[1] = A[k][4]; iparam[2] = A[k][2]; iparam[3] = A[k][5];
iparam[4] = dk[k][0]; iparam[5] = dk[k][1]; iparam[6] = dk[k][2];
@@ -2027,14 +2031,14 @@ double cvStereoCalibrate( const CvMat* _objectPoints, const CvMat* _imagePoints1
dpdf = &dpdf_hdr;
dpdc = &dpdc_hdr;
dpdk = &dpdk_hdr;
- if( flags & CV_CALIB_SAME_FOCAL_LENGTH )
+ if( flags & CALIB_SAME_FOCAL_LENGTH )
{
iparam[NINTRINSIC] = iparam[0];
iparam[NINTRINSIC+1] = iparam[1];
ipparam[NINTRINSIC] = ipparam[0];
ipparam[NINTRINSIC+1] = ipparam[1];
}
- if( flags & CV_CALIB_FIX_ASPECT_RATIO )
+ if( flags & CALIB_FIX_ASPECT_RATIO )
{
iparam[0] = iparam[1]*aspectRatio[0];
iparam[NINTRINSIC] = iparam[NINTRINSIC+1]*aspectRatio[1];
@@ -2096,7 +2100,7 @@ double cvStereoCalibrate( const CvMat* _objectPoints, const CvMat* _imagePoints1
if( JtJ || JtErr )
cvProjectPoints2( &objpt_i, &om[k], &T[k], &K[k], &Dist[k],
&tmpimagePoints, dpdrot, dpdt, dpdf, dpdc, dpdk,
- (flags & CV_CALIB_FIX_ASPECT_RATIO) ? aspectRatio[k] : 0);
+ (flags & CALIB_FIX_ASPECT_RATIO) ? aspectRatio[k] : 0);
else
cvProjectPoints2( &objpt_i, &om[k], &T[k], &K[k], &Dist[k], &tmpimagePoints );
cvSub( &tmpimagePoints, &imgpt_i[k], &tmpimagePoints );
@@ -2277,7 +2281,7 @@ void cvStereoRectify( const CvMat* _cameraMatrix1, const CvMat* _cameraMatrix2,
CvMat* matQ, int flags, double alpha, CvSize newImgSize,
CvRect* roi1, CvRect* roi2 )
{
- double _om[3], _t[3], _uu[3]={0,0,0}, _r_r[3][3], _pp[3][4];
+ double _om[3], _t[3] = {0}, _uu[3]={0,0,0}, _r_r[3][3], _pp[3][4];
double _ww[3], _wr[3][3], _z[3] = {0,0,0}, _ri[3][3];
cv::Rect_<float> inner1, inner2, outer1, outer2;
@@ -2372,7 +2376,7 @@ void cvStereoRectify( const CvMat* _cameraMatrix1, const CvMat* _cameraMatrix2,
// For simplicity, set the principal points for both cameras to be the average
// of the two principal points (either one of or both x- and y- coordinates)
- if( flags & CV_CALIB_ZERO_DISPARITY )
+ if( flags & CALIB_ZERO_DISPARITY )
{
cc_new[0].x = cc_new[1].x = (cc_new[0].x + cc_new[1].x)*0.5;
cc_new[0].y = cc_new[1].y = (cc_new[0].y + cc_new[1].y)*0.5;
@@ -2570,7 +2574,7 @@ CV_IMPL int cvStereoRectifyUncalibrated(
int i, j, npoints;
double cx, cy;
- double u[9], v[9], w[9], f[9], h1[9], h2[9], h0[9], e2[3];
+ double u[9], v[9], w[9], f[9], h1[9], h2[9], h0[9], e2[3] = {0};
CvMat E2 = cvMat( 3, 1, CV_64F, e2 );
CvMat U = cvMat( 3, 3, CV_64F, u );
CvMat V = cvMat( 3, 3, CV_64F, v );
@@ -2718,7 +2722,7 @@ CV_IMPL int cvStereoRectifyUncalibrated(
cvPerspectiveTransform( _m1, _m1, &H0 );
cvPerspectiveTransform( _m2, _m2, &H2 );
CvMat A = cvMat( 1, npoints, CV_64FC3, lines1 ), BxBy, B;
- double x[3];
+ double x[3] = {0};
CvMat X = cvMat( 3, 1, CV_64F, x );
cvConvertPointsHomogeneous( _m1, &A );
cvReshape( &A, &A, 1, npoints );
@@ -2776,15 +2780,16 @@ void cv::reprojectImageTo3D( InputArray _disparity,
Mat _3dImage = __3dImage.getMat();
const double bigZ = 10000.;
- double q[4][4];
- Mat _Q(4, 4, CV_64F, q);
+ Matx44d _Q;
Q.convertTo(_Q, CV_64F);
int x, cols = disparity.cols;
CV_Assert( cols >= 0 );
- std::vector<float> _sbuf(cols+1), _dbuf(cols*3+1);
- float* sbuf = &_sbuf[0], *dbuf = &_dbuf[0];
+ std::vector<float> _sbuf(cols);
+ std::vector<Vec3f> _dbuf(cols);
+ float* sbuf = &_sbuf[0];
+ Vec3f* dbuf = &_dbuf[0];
double minDisparity = FLT_MAX;
// NOTE: here we quietly assume that at least one pixel in the disparity map is not defined.
@@ -2794,9 +2799,8 @@ void cv::reprojectImageTo3D( InputArray _disparity,
for( int y = 0; y < disparity.rows; y++ )
{
- float *sptr = sbuf, *dptr = dbuf;
- double qx = q[0][1]*y + q[0][3], qy = q[1][1]*y + q[1][3];
- double qz = q[2][1]*y + q[2][3], qw = q[3][1]*y + q[3][3];
+ float* sptr = sbuf;
+ Vec3f* dptr = dbuf;
if( stype == CV_8UC1 )
{
@@ -2817,42 +2821,36 @@ void cv::reprojectImageTo3D( InputArray _disparity,
sptr[x] = (float)sptr0[x];
}
else
- sptr = (float*)disparity.ptr<float>(y);
+ sptr = disparity.ptr<float>(y);
if( dtype == CV_32FC3 )
- dptr = _3dImage.ptr<float>(y);
+ dptr = _3dImage.ptr<Vec3f>(y);
- for( x = 0; x < cols; x++, qx += q[0][0], qy += q[1][0], qz += q[2][0], qw += q[3][0] )
+ for( x = 0; x < cols; x++)
{
double d = sptr[x];
- double iW = 1./(qw + q[3][2]*d);
- double X = (qx + q[0][2]*d)*iW;
- double Y = (qy + q[1][2]*d)*iW;
- double Z = (qz + q[2][2]*d)*iW;
- if( fabs(d-minDisparity) <= FLT_EPSILON )
- Z = bigZ;
+ Vec4d homg_pt = _Q*Vec4d(x, y, d, 1.0);
+ dptr[x] = Vec3d(homg_pt.val);
+ dptr[x] /= homg_pt[3];
- dptr[x*3] = (float)X;
- dptr[x*3+1] = (float)Y;
- dptr[x*3+2] = (float)Z;
+ if( fabs(d-minDisparity) <= FLT_EPSILON )
+ dptr[x][2] = bigZ;
}
if( dtype == CV_16SC3 )
{
- short* dptr0 = _3dImage.ptr<short>(y);
- for( x = 0; x < cols*3; x++ )
+ Vec3s* dptr0 = _3dImage.ptr<Vec3s>(y);
+ for( x = 0; x < cols; x++ )
{
- int ival = cvRound(dptr[x]);
- dptr0[x] = cv::saturate_cast<short>(ival);
+ dptr0[x] = dptr[x];
}
}
else if( dtype == CV_32SC3 )
{
- int* dptr0 = _3dImage.ptr<int>(y);
- for( x = 0; x < cols*3; x++ )
+ Vec3i* dptr0 = _3dImage.ptr<Vec3i>(y);
+ for( x = 0; x < cols; x++ )
{
- int ival = cvRound(dptr[x]);
- dptr0[x] = ival;
+ dptr0[x] = dptr[x];
}
}
}
diff --git a/modules/calib3d/src/circlesgrid.cpp b/modules/calib3d/src/circlesgrid.cpp
index 2038e52..315e7f3 100644
--- a/modules/calib3d/src/circlesgrid.cpp
+++ b/modules/calib3d/src/circlesgrid.cpp
@@ -46,6 +46,7 @@
//#define DEBUG_CIRCLES
#ifdef DEBUG_CIRCLES
+# include <iostream>
# include "opencv2/opencv_modules.hpp"
# ifdef HAVE_OPENCV_HIGHGUI
# include "opencv2/highgui.hpp"
@@ -289,7 +290,7 @@ void CirclesGridClusterFinder::findOutsideCorners(const std::vector<cv::Point2f>
#ifdef DEBUG_CIRCLES
drawPoints(outsideCorners, cornersImage, 2, Scalar(128));
- imshow("corners", outsideCornersImage);
+ imshow("corners", cornersImage);
#endif
}
@@ -417,7 +418,7 @@ void CirclesGridClusterFinder::parsePatternPoints(const std::vector<cv::Point2f>
if(distsbuf[0] > maxRectifiedDistance)
{
#ifdef DEBUG_CIRCLES
- cout << "Pattern not detected: too large rectified distance" << endl;
+ std::cout << "Pattern not detected: too large rectified distance" << std::endl;
#endif
centers.clear();
return;
@@ -551,11 +552,11 @@ CirclesGridFinderParameters::CirclesGridFinderParameters()
keypointScale = 1;
minGraphConfidence = 9;
- vertexGain = 2;
- vertexPenalty = -5;
+ vertexGain = 1;
+ vertexPenalty = -0.6f;
edgeGain = 1;
- edgePenalty = -5;
- existingVertexGain = 0;
+ edgePenalty = -0.6f;
+ existingVertexGain = 10000;
minRNGEdgeSwitchDist = 5.f;
gridType = SYMMETRIC_GRID;
@@ -839,7 +840,11 @@ Mat CirclesGridFinder::rectifyGrid(Size detectedGridSize, const std::vector<Poin
//Mat H = findHomography( Mat( corners ), Mat( dstPoints ) );
if (H.empty())
+ {
H = Mat::zeros(3, 3, CV_64FC1);
+ warpedKeypoints.clear();
+ return H;
+ }
std::vector<Point2f> srcKeypoints;
for (size_t i = 0; i < keypoints.size(); i++)
@@ -1531,7 +1536,7 @@ void CirclesGridFinder::getCornerSegments(const std::vector<std::vector<size_t>
if (!isClockwise)
{
#ifdef DEBUG_CIRCLES
- cout << "Corners are counterclockwise" << endl;
+ std::cout << "Corners are counterclockwise" << std::endl;
#endif
std::reverse(segments.begin(), segments.end());
std::reverse(cornerIndices.begin(), cornerIndices.end());
diff --git a/modules/calib3d/src/circlesgrid.hpp b/modules/calib3d/src/circlesgrid.hpp
index fd13892..8f55f6c 100644
--- a/modules/calib3d/src/circlesgrid.hpp
+++ b/modules/calib3d/src/circlesgrid.hpp
@@ -119,35 +119,11 @@ struct Path
}
};
-struct CirclesGridFinderParameters
-{
- CirclesGridFinderParameters();
- cv::Size2f densityNeighborhoodSize;
- float minDensity;
- int kmeansAttempts;
- int minDistanceToAddKeypoint;
- int keypointScale;
- float minGraphConfidence;
- float vertexGain;
- float vertexPenalty;
- float existingVertexGain;
- float edgeGain;
- float edgePenalty;
- float convexHullFactor;
- float minRNGEdgeSwitchDist;
-
- enum GridType
- {
- SYMMETRIC_GRID, ASYMMETRIC_GRID
- };
- GridType gridType;
-};
-
class CirclesGridFinder
{
public:
CirclesGridFinder(cv::Size patternSize, const std::vector<cv::Point2f> &testKeypoints,
- const CirclesGridFinderParameters ¶meters = CirclesGridFinderParameters());
+ const cv::CirclesGridFinderParameters ¶meters = cv::CirclesGridFinderParameters());
bool findHoles();
static cv::Mat rectifyGrid(cv::Size detectedGridSize, const std::vector<cv::Point2f>& centers, const std::vector<
cv::Point2f> &keypoint, std::vector<cv::Point2f> &warpedKeypoints);
@@ -211,7 +187,7 @@ private:
std::vector<std::vector<size_t> > *smallHoles;
const cv::Size_<size_t> patternSize;
- CirclesGridFinderParameters parameters;
+ cv::CirclesGridFinderParameters parameters;
CirclesGridFinder& operator=(const CirclesGridFinder&);
CirclesGridFinder(const CirclesGridFinder&);
diff --git a/modules/calib3d/src/compat_ptsetreg.cpp b/modules/calib3d/src/compat_ptsetreg.cpp
index 774129e..6e67000 100644
--- a/modules/calib3d/src/compat_ptsetreg.cpp
+++ b/modules/calib3d/src/compat_ptsetreg.cpp
@@ -313,11 +313,7 @@ void CvLevMarq::step()
if( !err )
completeSymm( _JtJN, completeSymmFlag );
-#if 1
_JtJN.diag() *= 1. + lambda;
-#else
- _JtJN.diag() += lambda;
-#endif
solve(_JtJN, _JtErr, nonzero_param, solveMethod);
int j = 0;
diff --git a/modules/calib3d/src/dls.h b/modules/calib3d/src/dls.h
index 4b1f6f4..f03bee4 100644
--- a/modules/calib3d/src/dls.h
+++ b/modules/calib3d/src/dls.h
@@ -720,7 +720,7 @@ private:
public:
EigenvalueDecomposition()
- : n(0) { }
+ : n(0), cdivr(0), cdivi(0), d(0), e(0), ort(0), V(0), H(0) {}
// Initializes & computes the Eigenvalue Decomposition for a general matrix
// given in src. This function is a port of the EigenvalueSolver in JAMA,
diff --git a/modules/calib3d/src/epnp.cpp b/modules/calib3d/src/epnp.cpp
index ec7dfe0..a173b88 100644
--- a/modules/calib3d/src/epnp.cpp
+++ b/modules/calib3d/src/epnp.cpp
@@ -60,7 +60,7 @@ void epnp::choose_control_points(void)
// Take C1, C2, and C3 from PCA on the reference points:
CvMat * PW0 = cvCreateMat(number_of_correspondences, 3, CV_64F);
- double pw0tpw0[3 * 3], dc[3], uct[3 * 3];
+ double pw0tpw0[3 * 3], dc[3] = {0}, uct[3 * 3] = {0};
CvMat PW0tPW0 = cvMat(3, 3, CV_64F, pw0tpw0);
CvMat DC = cvMat(3, 1, CV_64F, dc);
CvMat UCt = cvMat(3, 3, CV_64F, uct);
@@ -240,7 +240,7 @@ void epnp::estimate_R_and_t(double R[3][3], double t[3])
pw0[j] /= number_of_correspondences;
}
- double abt[3 * 3], abt_d[3], abt_u[3 * 3], abt_v[3 * 3];
+ double abt[3 * 3] = {0}, abt_d[3], abt_u[3 * 3], abt_v[3 * 3];
CvMat ABt = cvMat(3, 3, CV_64F, abt);
CvMat ABt_D = cvMat(3, 1, CV_64F, abt_d);
CvMat ABt_U = cvMat(3, 3, CV_64F, abt_u);
@@ -332,7 +332,7 @@ double epnp::reprojection_error(const double R[3][3], const double t[3])
void epnp::find_betas_approx_1(const CvMat * L_6x10, const CvMat * Rho,
double * betas)
{
- double l_6x4[6 * 4], b4[4];
+ double l_6x4[6 * 4], b4[4] = {0};
CvMat L_6x4 = cvMat(6, 4, CV_64F, l_6x4);
CvMat B4 = cvMat(4, 1, CV_64F, b4);
@@ -364,7 +364,7 @@ void epnp::find_betas_approx_1(const CvMat * L_6x10, const CvMat * Rho,
void epnp::find_betas_approx_2(const CvMat * L_6x10, const CvMat * Rho,
double * betas)
{
- double l_6x3[6 * 3], b3[3];
+ double l_6x3[6 * 3], b3[3] = {0};
CvMat L_6x3 = cvMat(6, 3, CV_64F, l_6x3);
CvMat B3 = cvMat(3, 1, CV_64F, b3);
@@ -396,7 +396,7 @@ void epnp::find_betas_approx_2(const CvMat * L_6x10, const CvMat * Rho,
void epnp::find_betas_approx_3(const CvMat * L_6x10, const CvMat * Rho,
double * betas)
{
- double l_6x5[6 * 5], b5[5];
+ double l_6x5[6 * 5], b5[5] = {0};
CvMat L_6x5 = cvMat(6, 5, CV_64F, l_6x5);
CvMat B5 = cvMat(5, 1, CV_64F, b5);
@@ -506,7 +506,7 @@ void epnp::gauss_newton(const CvMat * L_6x10, const CvMat * Rho, double betas[4]
{
const int iterations_number = 5;
- double a[6*4], b[6], x[4];
+ double a[6*4], b[6], x[4] = {0};
CvMat A = cvMat(6, 4, CV_64F, a);
CvMat B = cvMat(6, 1, CV_64F, b);
CvMat X = cvMat(4, 1, CV_64F, x);
@@ -525,6 +525,8 @@ void epnp::qr_solve(CvMat * A, CvMat * b, CvMat * X)
{
const int nr = A->rows;
const int nc = A->cols;
+ if (nc <= 0 || nr <= 0)
+ return;
if (max_nr != 0 && max_nr < nr)
{
diff --git a/modules/calib3d/src/fisheye.cpp b/modules/calib3d/src/fisheye.cpp
index df68cf1..efd7f65 100644
--- a/modules/calib3d/src/fisheye.cpp
+++ b/modules/calib3d/src/fisheye.cpp
@@ -42,6 +42,7 @@
#include "precomp.hpp"
#include "fisheye.hpp"
+#include <limits>
namespace cv { namespace
{
@@ -378,9 +379,9 @@ void cv::fisheye::undistortPoints( InputArray distorted, OutputArray undistorted
double theta_d = sqrt(pw[0]*pw[0] + pw[1]*pw[1]);
- // the current camera model is only valid up to 180° FOV
+ // the current camera model is only valid up to 180 FOV
// for larger FOV the loop below does not converge
- // clip values so we still get plausible results for super fisheye images > 180°
+ // clip values so we still get plausible results for super fisheye images > 180 grad
theta_d = min(max(-CV_PI/2., theta_d), CV_PI/2.);
if (theta_d > 1e-8)
@@ -548,19 +549,6 @@ void cv::fisheye::estimateNewCameraMatrixForUndistortRectify(InputArray K, Input
pptr[6] = Vec2d(0, h);
pptr[7] = Vec2d(0, h/2);
-#if 0
- const int N = 10;
- cv::Mat points(1, N * 4, CV_64FC2);
- Vec2d* pptr = points.ptr<Vec2d>();
- for(int i = 0, k = 0; i < 10; ++i)
- {
- pptr[k++] = Vec2d(w/2, 0) - Vec2d(w/8, 0) + Vec2d(w/4/N*i, 0);
- pptr[k++] = Vec2d(w/2, h-1) - Vec2d(w/8, h-1) + Vec2d(w/4/N*i, h-1);
- pptr[k++] = Vec2d(0, h/2) - Vec2d(0, h/8) + Vec2d(0, h/4/N*i);
- pptr[k++] = Vec2d(w-1, h/2) - Vec2d(w-1, h/8) + Vec2d(w-1, h/4/N*i);
- }
-#endif
-
fisheye::undistortPoints(points, points, K, D, R);
cv::Scalar center_mass = mean(points);
cv::Vec2d cn(center_mass.val);
@@ -586,17 +574,6 @@ void cv::fisheye::estimateNewCameraMatrixForUndistortRectify(InputArray K, Input
maxx = std::max(maxx, std::abs(pptr[i][0]-cn[0]));
}
-#if 0
- double minx = -DBL_MAX, miny = -DBL_MAX, maxx = DBL_MAX, maxy = DBL_MAX;
- for(size_t i = 0; i < points.total(); ++i)
- {
- if (i % 4 == 0) miny = std::max(miny, pptr[i][1]);
- if (i % 4 == 1) maxy = std::min(maxy, pptr[i][1]);
- if (i % 4 == 2) minx = std::max(minx, pptr[i][0]);
- if (i % 4 == 3) maxx = std::min(maxx, pptr[i][0]);
- }
-#endif
-
double f1 = w * 0.5/(minx);
double f2 = w * 0.5/(maxx);
double f3 = h * 0.5 * aspect_ratio/(miny);
@@ -784,7 +761,7 @@ double cv::fisheye::calibrate(InputArrayOfArrays objectPoints, InputArrayOfArray
//-------------------------------Optimization
- for(int iter = 0; ; ++iter)
+ for(int iter = 0; iter <= std::numeric_limits<int>::max(); ++iter)
{
if ((criteria.type == 1 && iter >= criteria.maxCount) ||
(criteria.type == 2 && change <= criteria.epsilon) ||
@@ -1424,7 +1401,8 @@ void cv::internal::CalibrateExtrinsics(InputArrayOfArrays objectPoints, InputArr
if (check_cond)
{
SVD svd(JJ_kk, SVD::NO_UV);
- CV_Assert(svd.w.at<double>(0) / svd.w.at<double>((int)svd.w.total() - 1) < thresh_cond);
+ if(svd.w.at<double>(0) / svd.w.at<double>((int)svd.w.total() - 1) > thresh_cond )
+ CV_Error( cv::Error::StsInternal, format("CALIB_CHECK_COND - Ill-conditioned matrix for input array %d",image_idx));
}
omckk.reshape(3,1).copyTo(omc.getMat().col(image_idx));
Tckk.reshape(3,1).copyTo(Tc.getMat().col(image_idx));
diff --git a/modules/calib3d/src/five-point.cpp b/modules/calib3d/src/five-point.cpp
index 1d39e20..ecc1cfc 100644
--- a/modules/calib3d/src/five-point.cpp
+++ b/modules/calib3d/src/five-point.cpp
@@ -458,8 +458,9 @@ cv::Mat cv::findEssentialMat( InputArray _points1, InputArray _points2, double f
return cv::findEssentialMat(_points1, _points2, cameraMatrix, method, prob, threshold, _mask);
}
-int cv::recoverPose( InputArray E, InputArray _points1, InputArray _points2, InputArray _cameraMatrix,
- OutputArray _R, OutputArray _t, InputOutputArray _mask)
+int cv::recoverPose( InputArray E, InputArray _points1, InputArray _points2,
+ InputArray _cameraMatrix, OutputArray _R, OutputArray _t, double distanceThresh,
+ InputOutputArray _mask, OutputArray triangulatedPoints)
{
CV_INSTRUMENT_REGION()
@@ -506,51 +507,60 @@ int cv::recoverPose( InputArray E, InputArray _points1, InputArray _points2, Inp
// Notice here a threshold dist is used to filter
// out far away points (i.e. infinite points) since
// there depth may vary between postive and negtive.
- double dist = 50.0;
+ std::vector<Mat> allTriangulations(4);
Mat Q;
+
triangulatePoints(P0, P1, points1, points2, Q);
+ if(triangulatedPoints.needed())
+ Q.copyTo(allTriangulations[0]);
Mat mask1 = Q.row(2).mul(Q.row(3)) > 0;
Q.row(0) /= Q.row(3);
Q.row(1) /= Q.row(3);
Q.row(2) /= Q.row(3);
Q.row(3) /= Q.row(3);
- mask1 = (Q.row(2) < dist) & mask1;
+ mask1 = (Q.row(2) < distanceThresh) & mask1;
Q = P1 * Q;
mask1 = (Q.row(2) > 0) & mask1;
- mask1 = (Q.row(2) < dist) & mask1;
+ mask1 = (Q.row(2) < distanceThresh) & mask1;
triangulatePoints(P0, P2, points1, points2, Q);
+ if(triangulatedPoints.needed())
+ Q.copyTo(allTriangulations[1]);
Mat mask2 = Q.row(2).mul(Q.row(3)) > 0;
Q.row(0) /= Q.row(3);
Q.row(1) /= Q.row(3);
Q.row(2) /= Q.row(3);
Q.row(3) /= Q.row(3);
- mask2 = (Q.row(2) < dist) & mask2;
+ mask2 = (Q.row(2) < distanceThresh) & mask2;
Q = P2 * Q;
mask2 = (Q.row(2) > 0) & mask2;
- mask2 = (Q.row(2) < dist) & mask2;
+ mask2 = (Q.row(2) < distanceThresh) & mask2;
triangulatePoints(P0, P3, points1, points2, Q);
+ if(triangulatedPoints.needed())
+ Q.copyTo(allTriangulations[2]);
Mat mask3 = Q.row(2).mul(Q.row(3)) > 0;
Q.row(0) /= Q.row(3);
Q.row(1) /= Q.row(3);
Q.row(2) /= Q.row(3);
Q.row(3) /= Q.row(3);
- mask3 = (Q.row(2) < dist) & mask3;
+ mask3 = (Q.row(2) < distanceThresh) & mask3;
Q = P3 * Q;
mask3 = (Q.row(2) > 0) & mask3;
- mask3 = (Q.row(2) < dist) & mask3;
+ mask3 = (Q.row(2) < distanceThresh) & mask3;
triangulatePoints(P0, P4, points1, points2, Q);
+ if(triangulatedPoints.needed())
+ Q.copyTo(allTriangulations[3]);
Mat mask4 = Q.row(2).mul(Q.row(3)) > 0;
Q.row(0) /= Q.row(3);
Q.row(1) /= Q.row(3);
Q.row(2) /= Q.row(3);
Q.row(3) /= Q.row(3);
- mask4 = (Q.row(2) < dist) & mask4;
+ mask4 = (Q.row(2) < distanceThresh) & mask4;
Q = P4 * Q;
mask4 = (Q.row(2) > 0) & mask4;
- mask4 = (Q.row(2) < dist) & mask4;
+ mask4 = (Q.row(2) < distanceThresh) & mask4;
mask1 = mask1.t();
mask2 = mask2.t();
@@ -583,6 +593,7 @@ int cv::recoverPose( InputArray E, InputArray _points1, InputArray _points2, Inp
if (good1 >= good2 && good1 >= good3 && good1 >= good4)
{
+ if(triangulatedPoints.needed()) allTriangulations[0].copyTo(triangulatedPoints);
R1.copyTo(_R);
t.copyTo(_t);
if (_mask.needed()) mask1.copyTo(_mask);
@@ -590,6 +601,7 @@ int cv::recoverPose( InputArray E, InputArray _points1, InputArray _points2, Inp
}
else if (good2 >= good1 && good2 >= good3 && good2 >= good4)
{
+ if(triangulatedPoints.needed()) allTriangulations[1].copyTo(triangulatedPoints);
R2.copyTo(_R);
t.copyTo(_t);
if (_mask.needed()) mask2.copyTo(_mask);
@@ -597,6 +609,7 @@ int cv::recoverPose( InputArray E, InputArray _points1, InputArray _points2, Inp
}
else if (good3 >= good1 && good3 >= good2 && good3 >= good4)
{
+ if(triangulatedPoints.needed()) allTriangulations[2].copyTo(triangulatedPoints);
t = -t;
R1.copyTo(_R);
t.copyTo(_t);
@@ -605,6 +618,7 @@ int cv::recoverPose( InputArray E, InputArray _points1, InputArray _points2, Inp
}
else
{
+ if(triangulatedPoints.needed()) allTriangulations[3].copyTo(triangulatedPoints);
t = -t;
R2.copyTo(_R);
t.copyTo(_t);
@@ -613,6 +627,12 @@ int cv::recoverPose( InputArray E, InputArray _points1, InputArray _points2, Inp
}
}
+int cv::recoverPose( InputArray E, InputArray _points1, InputArray _points2, InputArray _cameraMatrix,
+ OutputArray _R, OutputArray _t, InputOutputArray _mask)
+{
+ return cv::recoverPose(E, _points1, _points2, _cameraMatrix, _R, _t, 50, _mask);
+}
+
int cv::recoverPose( InputArray E, InputArray _points1, InputArray _points2, OutputArray _R,
OutputArray _t, double focal, Point2d pp, InputOutputArray _mask)
{
diff --git a/modules/calib3d/src/fundam.cpp b/modules/calib3d/src/fundam.cpp
index 63bdff2..c9d8e993 100644
--- a/modules/calib3d/src/fundam.cpp
+++ b/modules/calib3d/src/fundam.cpp
@@ -423,7 +423,7 @@ namespace cv
static int run7Point( const Mat& _m1, const Mat& _m2, Mat& _fmatrix )
{
- double a[7*9], w[7], u[9*9], v[9*9], c[4], r[3];
+ double a[7*9], w[7], u[9*9], v[9*9], c[4], r[3] = {0};
double* f1, *f2;
double t0, t1, t2;
Mat A( 7, 9, CV_64F, a );
@@ -766,7 +766,7 @@ void cv::computeCorrespondEpilines( InputArray _points, int whichImage,
{
CV_INSTRUMENT_REGION()
- double f[9];
+ double f[9] = {0};
Mat tempF(3, 3, CV_64F, f);
Mat points = _points.getMat(), F = _Fmat.getMat();
diff --git a/modules/calib3d/src/homography_decomp.cpp b/modules/calib3d/src/homography_decomp.cpp
index 9007d0a..0411c4d 100644
--- a/modules/calib3d/src/homography_decomp.cpp
+++ b/modules/calib3d/src/homography_decomp.cpp
@@ -16,7 +16,7 @@
// License Agreement
// For Open Source Computer Vision Library
//
- // Copyright (C) 2014, Samson Yilma¸ (samson_yilma at yahoo.com), all rights reserved.
+ // Copyright (C) 2014, Samson Yilma (samson_yilma at yahoo.com), all rights reserved.
//
// Third party copyrights are property of their respective owners.
//
diff --git a/modules/calib3d/src/p3p.cpp b/modules/calib3d/src/p3p.cpp
index f91925b..8bf0c35 100644
--- a/modules/calib3d/src/p3p.cpp
+++ b/modules/calib3d/src/p3p.cpp
@@ -57,6 +57,41 @@ bool p3p::solve(cv::Mat& R, cv::Mat& tvec, const cv::Mat& opoints, const cv::Mat
return result;
}
+int p3p::solve(std::vector<cv::Mat>& Rs, std::vector<cv::Mat>& tvecs, const cv::Mat& opoints, const cv::Mat& ipoints)
+{
+ CV_INSTRUMENT_REGION()
+
+ double rotation_matrix[4][3][3], translation[4][3];
+ std::vector<double> points;
+ if (opoints.depth() == ipoints.depth())
+ {
+ if (opoints.depth() == CV_32F)
+ extract_points<cv::Point3f,cv::Point2f>(opoints, ipoints, points);
+ else
+ extract_points<cv::Point3d,cv::Point2d>(opoints, ipoints, points);
+ }
+ else if (opoints.depth() == CV_32F)
+ extract_points<cv::Point3f,cv::Point2d>(opoints, ipoints, points);
+ else
+ extract_points<cv::Point3d,cv::Point2f>(opoints, ipoints, points);
+
+ int solutions = solve(rotation_matrix, translation,
+ points[0], points[1], points[2], points[3], points[4],
+ points[5], points[6], points[7], points[8], points[9],
+ points[10], points[11], points[12], points[13], points[14]);
+
+ for (int i = 0; i < solutions; i++) {
+ cv::Mat R, tvec;
+ cv::Mat(3, 1, CV_64F, translation[i]).copyTo(tvec);
+ cv::Mat(3, 3, CV_64F, rotation_matrix[i]).copyTo(R);
+
+ Rs.push_back(R);
+ tvecs.push_back(tvec);
+ }
+
+ return solutions;
+}
+
bool p3p::solve(double R[3][3], double t[3],
double mu0, double mv0, double X0, double Y0, double Z0,
double mu1, double mv1, double X1, double Y1, double Z1,
diff --git a/modules/calib3d/src/p3p.h b/modules/calib3d/src/p3p.h
index 00d99ae..9c7f7ec 100644
--- a/modules/calib3d/src/p3p.h
+++ b/modules/calib3d/src/p3p.h
@@ -11,6 +11,7 @@ class p3p
p3p(cv::Mat cameraMatrix);
bool solve(cv::Mat& R, cv::Mat& tvec, const cv::Mat& opoints, const cv::Mat& ipoints);
+ int solve(std::vector<cv::Mat>& Rs, std::vector<cv::Mat>& tvecs, const cv::Mat& opoints, const cv::Mat& ipoints);
int solve(double R[4][3][3], double t[4][3],
double mu0, double mv0, double X0, double Y0, double Z0,
double mu1, double mv1, double X1, double Y1, double Z1,
@@ -34,8 +35,9 @@ class p3p
void extract_points(const cv::Mat& opoints, const cv::Mat& ipoints, std::vector<double>& points)
{
points.clear();
- points.resize(20);
- for(int i = 0; i < 4; i++)
+ int npoints = std::max(opoints.checkVector(3, CV_32F), opoints.checkVector(3, CV_64F));
+ points.resize(5*npoints);
+ for(int i = 0; i < npoints; i++)
{
points[i*5] = ipoints.at<IpointType>(i).x*fx + cx;
points[i*5+1] = ipoints.at<IpointType>(i).y*fy + cy;
diff --git a/modules/calib3d/src/ptsetreg.cpp b/modules/calib3d/src/ptsetreg.cpp
index cbf8175..ba9b786 100644
--- a/modules/calib3d/src/ptsetreg.cpp
+++ b/modules/calib3d/src/ptsetreg.cpp
@@ -802,11 +802,11 @@ Mat estimateAffine2D(InputArray _from, InputArray _to, OutputArray _inliers,
if (from.type() != CV_32FC2 || to.type() != CV_32FC2)
{
- Mat tmp;
- from.convertTo(tmp, CV_32FC2);
- from = tmp;
- to.convertTo(tmp, CV_32FC2);
- to = tmp;
+ Mat tmp1, tmp2;
+ from.convertTo(tmp1, CV_32FC2);
+ from = tmp1;
+ to.convertTo(tmp2, CV_32FC2);
+ to = tmp2;
}
// convert to N x 1 vectors
from = from.reshape(2, count);
@@ -869,11 +869,11 @@ Mat estimateAffinePartial2D(InputArray _from, InputArray _to, OutputArray _inlie
if (from.type() != CV_32FC2 || to.type() != CV_32FC2)
{
- Mat tmp;
- from.convertTo(tmp, CV_32FC2);
- from = tmp;
- to.convertTo(tmp, CV_32FC2);
- to = tmp;
+ Mat tmp1, tmp2;
+ from.convertTo(tmp1, CV_32FC2);
+ from = tmp1;
+ to.convertTo(tmp2, CV_32FC2);
+ to = tmp2;
}
// convert to N x 1 vectors
from = from.reshape(2, count);
diff --git a/modules/calib3d/src/rho.cpp b/modules/calib3d/src/rho.cpp
index 728c3f6..5d42868 100644
--- a/modules/calib3d/src/rho.cpp
+++ b/modules/calib3d/src/rho.cpp
@@ -556,7 +556,55 @@ unsigned rhoHest(Ptr<RHO_HEST> p, /* Homography estimation context. */
*/
RHO_HEST_REFC::RHO_HEST_REFC() : initialized(0){
+ arg.src = 0;
+ arg.dst = 0;
+ arg.inl = 0;
+ arg.N = 0;
+ arg.maxD = 0;
+ arg.maxI = 0;
+ arg.rConvg = 0;
+ arg.cfd = 0;
+ arg.minInl = 0;
+ arg.beta = 0;
+ arg.flags = 0;
+ arg.guessH = 0;
+ arg.finalH = 0;
+
+ ctrl.i = 0;
+ ctrl.phNum = 0;
+ ctrl.phEndI = 0;
+ ctrl.phEndFpI = 0;
+ ctrl.phMax = 0;
+ ctrl.phNumInl = 0;
+ ctrl.numModels = 0;
+ ctrl.smpl = 0;
+
+ curr.pkdPts = 0;
+ curr.H = 0;
+ curr.inl = 0;
+ curr.numInl = 0;
+
+ best.H = 0;
+ best.inl = 0;
+ best.numInl = 0;
+
+ nr.size = 0;
+ nr.beta = 0;
+
+ eval.t_M = 0;
+ eval.m_S = 0;
+ eval.epsilon = 0;
+ eval.delta = 0;
+ eval.A = 0;
+ eval.Ntested = 0;
+ eval.Ntestedtotal = 0;
+ eval.good = 0;
+ eval.lambdaAccept = 0;
+ eval.lambdaReject = 0;
+ lm.JtJ = 0;
+ lm.tmp1 = 0;
+ lm.Jte = 0;
}
/**
@@ -1200,11 +1248,11 @@ inline void RHO_HEST_REFC::rndSmpl(unsigned sampleSize,
/**
* Selection Sampling:
*
- * Algorithm S (Selection sampling technique). To select n records at random from a set of N, where 0 < n ≤ N.
- * S1. [Initialize.] Set t ← 0, m ← 0. (During this algorithm, m represents the number of records selected so far,
+ * Algorithm S (Selection sampling technique). To select n records at random from a set of N, where 0 < n <= N.
+ * S1. [Initialize.] Set t = 0, m = 0. (During this algorithm, m represents the number of records selected so far,
* and t is the total number of input records that we have dealt with.)
* S2. [Generate U.] Generate a random number U, uniformly distributed between zero and one.
- * S3. [Test.] If (N – t)U ≥ n – m, go to step S5.
+ * S3. [Test.] If (N - t)U >= n - m, go to step S5.
* S4. [Select.] Select the next record for the sample, and increase m and t by 1. If m < n, go to step S2;
* otherwise the sample is complete and the algorithm terminates.
* S5. [Skip.] Skip the next record (do not include it in the sample), increase t by 1, and go back to step S2.
diff --git a/modules/calib3d/src/solvepnp.cpp b/modules/calib3d/src/solvepnp.cpp
index e205580..60ea577 100644
--- a/modules/calib3d/src/solvepnp.cpp
+++ b/modules/calib3d/src/solvepnp.cpp
@@ -45,6 +45,7 @@
#include "dls.h"
#include "epnp.h"
#include "p3p.h"
+#include "ap3p.h"
#include "opencv2/calib3d/calib3d_c.h"
#include <iostream>
@@ -60,7 +61,7 @@ bool solvePnP( InputArray _opoints, InputArray _ipoints,
Mat opoints = _opoints.getMat(), ipoints = _ipoints.getMat();
int npoints = std::max(opoints.checkVector(3, CV_32F), opoints.checkVector(3, CV_64F));
- CV_Assert( npoints >= 0 && npoints == std::max(ipoints.checkVector(2, CV_32F), ipoints.checkVector(2, CV_64F)) );
+ CV_Assert( npoints >= 4 && npoints == std::max(ipoints.checkVector(2, CV_32F), ipoints.checkVector(2, CV_64F)) );
Mat rvec, tvec;
if( flags != SOLVEPNP_ITERATIVE )
@@ -77,8 +78,14 @@ bool solvePnP( InputArray _opoints, InputArray _ipoints,
}
else
{
- _rvec.create(3, 1, CV_64F);
- _tvec.create(3, 1, CV_64F);
+ int mtype = CV_64F;
+ // use CV_32F if all PnP inputs are CV_32F and outputs are empty
+ if (_ipoints.depth() == _cameraMatrix.depth() && _ipoints.depth() == _opoints.depth() &&
+ _rvec.empty() && _tvec.empty())
+ mtype = _opoints.depth();
+
+ _rvec.create(3, 1, mtype);
+ _tvec.create(3, 1, mtype);
}
rvec = _rvec.getMat();
tvec = _tvec.getMat();
@@ -112,6 +119,18 @@ bool solvePnP( InputArray _opoints, InputArray _ipoints,
if (result)
Rodrigues(R, rvec);
}
+ else if (flags == SOLVEPNP_AP3P)
+ {
+ CV_Assert( npoints == 4);
+ Mat undistortedPoints;
+ undistortPoints(ipoints, undistortedPoints, cameraMatrix, distCoeffs);
+ ap3p P3Psolver(cameraMatrix);
+
+ Mat R;
+ result = P3Psolver.solve(R, tvec, opoints, undistortedPoints);
+ if (result)
+ Rodrigues(R, rvec);
+ }
else if (flags == SOLVEPNP_ITERATIVE)
{
CvMat c_objectPoints = opoints, c_imagePoints = ipoints;
@@ -230,7 +249,7 @@ bool solvePnPRansac(InputArray _opoints, InputArray _ipoints,
ipoints = ipoints0;
int npoints = std::max(opoints.checkVector(3, CV_32F), opoints.checkVector(3, CV_64F));
- CV_Assert( npoints >= 0 && npoints == std::max(ipoints.checkVector(2, CV_32F), ipoints.checkVector(2, CV_64F)) );
+ CV_Assert( npoints >= 4 && npoints == std::max(ipoints.checkVector(2, CV_32F), ipoints.checkVector(2, CV_64F)) );
CV_Assert(opoints.isContinuous());
CV_Assert(opoints.depth() == CV_32F || opoints.depth() == CV_64F);
@@ -249,12 +268,42 @@ bool solvePnPRansac(InputArray _opoints, InputArray _ipoints,
int model_points = 5;
int ransac_kernel_method = SOLVEPNP_EPNP;
- if( npoints == 4 )
+ if( flags == SOLVEPNP_P3P || flags == SOLVEPNP_AP3P)
+ {
+ model_points = 4;
+ ransac_kernel_method = flags;
+ }
+ else if( npoints == 4 )
{
model_points = 4;
ransac_kernel_method = SOLVEPNP_P3P;
}
+ if( model_points == npoints )
+ {
+ bool result = solvePnP(opoints, ipoints, cameraMatrix, distCoeffs, _rvec, _tvec, useExtrinsicGuess, ransac_kernel_method);
+
+ if(!result)
+ {
+ if( _inliers.needed() )
+ _inliers.release();
+
+ return false;
+ }
+
+ if(_inliers.needed())
+ {
+ _inliers.create(npoints, 1, CV_32S);
+ Mat _local_inliers = _inliers.getMat();
+ for(int i = 0; i < npoints; i++)
+ {
+ _local_inliers.at<int>(i) = i;
+ }
+ }
+
+ return true;
+ }
+
Ptr<PointSetRegistrator::Callback> cb; // pointer to callback
cb = makePtr<PnPRansacCallback>( cameraMatrix, distCoeffs, ransac_kernel_method, useExtrinsicGuess, rvec, tvec);
@@ -269,25 +318,6 @@ bool solvePnPRansac(InputArray _opoints, InputArray _ipoints,
int result = createRANSACPointSetRegistrator(cb, model_points,
param1, param2, param3)->run(opoints, ipoints, _local_model, _mask_local_inliers);
- if( result > 0 )
- {
- vector<Point3d> opoints_inliers;
- vector<Point2d> ipoints_inliers;
- opoints = opoints.reshape(3);
- ipoints = ipoints.reshape(2);
- opoints.convertTo(opoints_inliers, CV_64F);
- ipoints.convertTo(ipoints_inliers, CV_64F);
-
- const uchar* mask = _mask_local_inliers.ptr<uchar>();
- int npoints1 = compressElems(&opoints_inliers[0], mask, 1, npoints);
- compressElems(&ipoints_inliers[0], mask, 1, npoints);
-
- opoints_inliers.resize(npoints1);
- ipoints_inliers.resize(npoints1);
- result = solvePnP(opoints_inliers, ipoints_inliers, cameraMatrix,
- distCoeffs, rvec, tvec, false, flags == SOLVEPNP_P3P ? SOLVEPNP_EPNP : flags) ? 1 : -1;
- }
-
if( result <= 0 || _local_model.rows <= 0)
{
_rvec.assign(rvec); // output rotation vector
@@ -298,10 +328,38 @@ bool solvePnPRansac(InputArray _opoints, InputArray _ipoints,
return false;
}
- else
+
+ vector<Point3d> opoints_inliers;
+ vector<Point2d> ipoints_inliers;
+ opoints = opoints.reshape(3);
+ ipoints = ipoints.reshape(2);
+ opoints.convertTo(opoints_inliers, CV_64F);
+ ipoints.convertTo(ipoints_inliers, CV_64F);
+
+ const uchar* mask = _mask_local_inliers.ptr<uchar>();
+ int npoints1 = compressElems(&opoints_inliers[0], mask, 1, npoints);
+ compressElems(&ipoints_inliers[0], mask, 1, npoints);
+
+ opoints_inliers.resize(npoints1);
+ ipoints_inliers.resize(npoints1);
+ result = solvePnP(opoints_inliers, ipoints_inliers, cameraMatrix,
+ distCoeffs, rvec, tvec, useExtrinsicGuess,
+ (flags == SOLVEPNP_P3P || flags == SOLVEPNP_AP3P) ? SOLVEPNP_EPNP : flags) ? 1 : -1;
+
+ if( result <= 0 )
{
_rvec.assign(_local_model.col(0)); // output rotation vector
_tvec.assign(_local_model.col(1)); // output translation vector
+
+ if( _inliers.needed() )
+ _inliers.release();
+
+ return false;
+ }
+ else
+ {
+ _rvec.assign(rvec); // output rotation vector
+ _tvec.assign(tvec); // output translation vector
}
if(_inliers.needed())
@@ -317,4 +375,57 @@ bool solvePnPRansac(InputArray _opoints, InputArray _ipoints,
return true;
}
+int solveP3P( InputArray _opoints, InputArray _ipoints,
+ InputArray _cameraMatrix, InputArray _distCoeffs,
+ OutputArrayOfArrays _rvecs, OutputArrayOfArrays _tvecs, int flags) {
+ CV_INSTRUMENT_REGION()
+
+ Mat opoints = _opoints.getMat(), ipoints = _ipoints.getMat();
+ int npoints = std::max(opoints.checkVector(3, CV_32F), opoints.checkVector(3, CV_64F));
+ CV_Assert( npoints == 3 && npoints == std::max(ipoints.checkVector(2, CV_32F), ipoints.checkVector(2, CV_64F)) );
+ CV_Assert( flags == SOLVEPNP_P3P || flags == SOLVEPNP_AP3P );
+
+ Mat cameraMatrix0 = _cameraMatrix.getMat();
+ Mat distCoeffs0 = _distCoeffs.getMat();
+ Mat cameraMatrix = Mat_<double>(cameraMatrix0);
+ Mat distCoeffs = Mat_<double>(distCoeffs0);
+
+ Mat undistortedPoints;
+ undistortPoints(ipoints, undistortedPoints, cameraMatrix, distCoeffs);
+ std::vector<Mat> Rs, ts;
+
+ int solutions = 0;
+ if (flags == SOLVEPNP_P3P)
+ {
+ p3p P3Psolver(cameraMatrix);
+ solutions = P3Psolver.solve(Rs, ts, opoints, undistortedPoints);
+ }
+ else if (flags == SOLVEPNP_AP3P)
+ {
+ ap3p P3Psolver(cameraMatrix);
+ solutions = P3Psolver.solve(Rs, ts, opoints, undistortedPoints);
+ }
+
+ if (solutions == 0) {
+ return 0;
+ }
+
+ if (_rvecs.needed()) {
+ _rvecs.create(solutions, 1, CV_64F);
+ }
+
+ if (_tvecs.needed()) {
+ _tvecs.create(solutions, 1, CV_64F);
+ }
+
+ for (int i = 0; i < solutions; i++) {
+ Mat rvec;
+ Rodrigues(Rs[i], rvec);
+ _tvecs.getMatRef(i) = ts[i];
+ _rvecs.getMatRef(i) = rvec;
+ }
+
+ return solutions;
+}
+
}
diff --git a/modules/calib3d/src/stereobm.cpp b/modules/calib3d/src/stereobm.cpp
index cd86131..f6708c4 100644
--- a/modules/calib3d/src/stereobm.cpp
+++ b/modules/calib3d/src/stereobm.cpp
@@ -49,6 +49,7 @@
#include <stdio.h>
#include <limits>
#include "opencl_kernels_calib3d.hpp"
+#include "opencv2/core/hal/intrin.hpp"
namespace cv
{
@@ -196,15 +197,15 @@ prefilterXSobel( const Mat& src, Mat& dst, int ftzero )
{
int x, y;
const int OFS = 256*4, TABSZ = OFS*2 + 256;
- uchar tab[TABSZ];
+ uchar tab[TABSZ] = { 0 };
Size size = src.size();
for( x = 0; x < TABSZ; x++ )
tab[x] = (uchar)(x - OFS < -ftzero ? 0 : x - OFS > ftzero ? ftzero*2 : x - OFS + ftzero);
uchar val0 = tab[0 + OFS];
-#if CV_SSE2
- volatile bool useSIMD = checkHardwareSupport(CV_CPU_SSE2);
+#if CV_SIMD128
+ bool useSIMD = hasSIMD128();
#endif
for( y = 0; y < size.height-1; y += 2 )
@@ -219,71 +220,34 @@ prefilterXSobel( const Mat& src, Mat& dst, int ftzero )
dptr0[0] = dptr0[size.width-1] = dptr1[0] = dptr1[size.width-1] = val0;
x = 1;
-#if CV_NEON
- int16x8_t ftz = vdupq_n_s16 ((short) ftzero);
- uint8x8_t ftz2 = vdup_n_u8 (cv::saturate_cast<uchar>(ftzero*2));
-
- for(; x <=size.width-9; x += 8 )
- {
- uint8x8_t c0 = vld1_u8 (srow0 + x - 1);
- uint8x8_t c1 = vld1_u8 (srow1 + x - 1);
- uint8x8_t d0 = vld1_u8 (srow0 + x + 1);
- uint8x8_t d1 = vld1_u8 (srow1 + x + 1);
-
- int16x8_t t0 = vreinterpretq_s16_u16 (vsubl_u8 (d0, c0));
- int16x8_t t1 = vreinterpretq_s16_u16 (vsubl_u8 (d1, c1));
-
- uint8x8_t c2 = vld1_u8 (srow2 + x - 1);
- uint8x8_t c3 = vld1_u8 (srow3 + x - 1);
- uint8x8_t d2 = vld1_u8 (srow2 + x + 1);
- uint8x8_t d3 = vld1_u8 (srow3 + x + 1);
-
- int16x8_t t2 = vreinterpretq_s16_u16 (vsubl_u8 (d2, c2));
- int16x8_t t3 = vreinterpretq_s16_u16 (vsubl_u8 (d3, c3));
-
- int16x8_t v0 = vaddq_s16 (vaddq_s16 (t2, t0), vaddq_s16 (t1, t1));
- int16x8_t v1 = vaddq_s16 (vaddq_s16 (t3, t1), vaddq_s16 (t2, t2));
-
-
- uint8x8_t v0_u8 = vqmovun_s16 (vaddq_s16 (v0, ftz));
- uint8x8_t v1_u8 = vqmovun_s16 (vaddq_s16 (v1, ftz));
- v0_u8 = vmin_u8 (v0_u8, ftz2);
- v1_u8 = vmin_u8 (v1_u8, ftz2);
- vqmovun_s16 (vaddq_s16 (v1, ftz));
-
- vst1_u8 (dptr0 + x, v0_u8);
- vst1_u8 (dptr1 + x, v1_u8);
- }
-#elif CV_SSE2
+#if CV_SIMD128
if( useSIMD )
{
- __m128i z = _mm_setzero_si128(), ftz = _mm_set1_epi16((short)ftzero),
- ftz2 = _mm_set1_epi8(cv::saturate_cast<uchar>(ftzero*2));
- for( ; x <= size.width-9; x += 8 )
- {
- __m128i c0 = _mm_unpacklo_epi8(_mm_loadl_epi64((__m128i*)(srow0 + x - 1)), z);
- __m128i c1 = _mm_unpacklo_epi8(_mm_loadl_epi64((__m128i*)(srow1 + x - 1)), z);
- __m128i d0 = _mm_unpacklo_epi8(_mm_loadl_epi64((__m128i*)(srow0 + x + 1)), z);
- __m128i d1 = _mm_unpacklo_epi8(_mm_loadl_epi64((__m128i*)(srow1 + x + 1)), z);
-
- d0 = _mm_sub_epi16(d0, c0);
- d1 = _mm_sub_epi16(d1, c1);
-
- __m128i c2 = _mm_unpacklo_epi8(_mm_loadl_epi64((__m128i*)(srow2 + x - 1)), z);
- __m128i c3 = _mm_unpacklo_epi8(_mm_loadl_epi64((__m128i*)(srow3 + x - 1)), z);
- __m128i d2 = _mm_unpacklo_epi8(_mm_loadl_epi64((__m128i*)(srow2 + x + 1)), z);
- __m128i d3 = _mm_unpacklo_epi8(_mm_loadl_epi64((__m128i*)(srow3 + x + 1)), z);
-
- d2 = _mm_sub_epi16(d2, c2);
- d3 = _mm_sub_epi16(d3, c3);
+ v_int16x8 ftz = v_setall_s16((short) ftzero);
+ v_int16x8 ftz2 = v_setall_s16((short)(ftzero*2));
+ v_int16x8 z = v_setzero_s16();
- __m128i v0 = _mm_add_epi16(d0, _mm_add_epi16(d2, _mm_add_epi16(d1, d1)));
- __m128i v1 = _mm_add_epi16(d1, _mm_add_epi16(d3, _mm_add_epi16(d2, d2)));
- v0 = _mm_packus_epi16(_mm_add_epi16(v0, ftz), _mm_add_epi16(v1, ftz));
- v0 = _mm_min_epu8(v0, ftz2);
-
- _mm_storel_epi64((__m128i*)(dptr0 + x), v0);
- _mm_storel_epi64((__m128i*)(dptr1 + x), _mm_unpackhi_epi64(v0, v0));
+ for(; x <= (size.width - 1) - 8; x += 8 )
+ {
+ v_int16x8 s00 = v_reinterpret_as_s16(v_load_expand(srow0 + x + 1));
+ v_int16x8 s01 = v_reinterpret_as_s16(v_load_expand(srow0 + x - 1));
+ v_int16x8 s10 = v_reinterpret_as_s16(v_load_expand(srow1 + x + 1));
+ v_int16x8 s11 = v_reinterpret_as_s16(v_load_expand(srow1 + x - 1));
+ v_int16x8 s20 = v_reinterpret_as_s16(v_load_expand(srow2 + x + 1));
+ v_int16x8 s21 = v_reinterpret_as_s16(v_load_expand(srow2 + x - 1));
+ v_int16x8 s30 = v_reinterpret_as_s16(v_load_expand(srow3 + x + 1));
+ v_int16x8 s31 = v_reinterpret_as_s16(v_load_expand(srow3 + x - 1));
+
+ v_int16x8 d0 = s00 - s01;
+ v_int16x8 d1 = s10 - s11;
+ v_int16x8 d2 = s20 - s21;
+ v_int16x8 d3 = s30 - s31;
+
+ v_uint16x8 v0 = v_reinterpret_as_u16(v_max(v_min(d0 + d1 + d1 + d2 + ftz, ftz2), z));
+ v_uint16x8 v1 = v_reinterpret_as_u16(v_max(v_min(d1 + d2 + d2 + d3 + ftz, ftz2), z));
+
+ v_pack_store(dptr0 + x, v0);
+ v_pack_store(dptr1 + x, v1);
}
}
#endif
@@ -299,18 +263,18 @@ prefilterXSobel( const Mat& src, Mat& dst, int ftzero )
}
}
-#if CV_NEON
- uint8x16_t val0_16 = vdupq_n_u8 (val0);
-#endif
-
for( ; y < size.height; y++ )
{
uchar* dptr = dst.ptr<uchar>(y);
x = 0;
- #if CV_NEON
- for(; x <= size.width-16; x+=16 )
- vst1q_u8 (dptr + x, val0_16);
- #endif
+#if CV_SIMD128
+ if( useSIMD )
+ {
+ v_uint8x16 val0_16 = v_setall_u8(val0);
+ for(; x <= size.width-16; x+=16 )
+ v_store(dptr + x, val0_16);
+ }
+#endif
for(; x < size.width; x++ )
dptr[x] = val0;
}
@@ -320,8 +284,8 @@ prefilterXSobel( const Mat& src, Mat& dst, int ftzero )
static const int DISPARITY_SHIFT_16S = 4;
static const int DISPARITY_SHIFT_32S = 8;
-#if CV_SSE2
-static void findStereoCorrespondenceBM_SSE2( const Mat& left, const Mat& right,
+#if CV_SIMD128
+static void findStereoCorrespondenceBM_SIMD( const Mat& left, const Mat& right,
Mat& disp, Mat& cost, StereoBMParams& state,
uchar* buf, int _dy0, int _dy1 )
{
@@ -354,7 +318,7 @@ static void findStereoCorrespondenceBM_SSE2( const Mat& left, const Mat& right,
int coststep = cost.data ? (int)(cost.step/sizeof(costbuf)) : 0;
const int TABSZ = 256;
uchar tab[TABSZ];
- const __m128i d0_8 = _mm_setr_epi16(0,1,2,3,4,5,6,7), dd_8 = _mm_set1_epi16(8);
+ const v_int16x8 d0_8 = v_int16x8(0,1,2,3,4,5,6,7), dd_8 = v_setall_s16(8);
sad = (ushort*)alignPtr(buf + sizeof(sad[0]), ALIGN);
hsad0 = (ushort*)alignPtr(sad + ndisp + 1 + dy0*ndisp, ALIGN);
@@ -377,18 +341,20 @@ static void findStereoCorrespondenceBM_SSE2( const Mat& left, const Mat& right,
for( y = -dy0; y < height + dy1; y++, hsad += ndisp, cbuf += ndisp, lptr += sstep, rptr += sstep )
{
int lval = lptr[0];
- __m128i lv = _mm_set1_epi8((char)lval), z = _mm_setzero_si128();
+ v_uint8x16 lv = v_setall_u8((uchar)lval);
for( d = 0; d < ndisp; d += 16 )
{
- __m128i rv = _mm_loadu_si128((const __m128i*)(rptr + d));
- __m128i hsad_l = _mm_load_si128((__m128i*)(hsad + d));
- __m128i hsad_h = _mm_load_si128((__m128i*)(hsad + d + 8));
- __m128i diff = _mm_adds_epu8(_mm_subs_epu8(lv, rv), _mm_subs_epu8(rv, lv));
- _mm_store_si128((__m128i*)(cbuf + d), diff);
- hsad_l = _mm_add_epi16(hsad_l, _mm_unpacklo_epi8(diff,z));
- hsad_h = _mm_add_epi16(hsad_h, _mm_unpackhi_epi8(diff,z));
- _mm_store_si128((__m128i*)(hsad + d), hsad_l);
- _mm_store_si128((__m128i*)(hsad + d + 8), hsad_h);
+ v_uint8x16 rv = v_load(rptr + d);
+ v_uint16x8 hsad_l = v_load(hsad + d);
+ v_uint16x8 hsad_h = v_load(hsad + d + 8);
+ v_uint8x16 diff = v_absdiff(lv, rv);
+ v_store(cbuf + d, diff);
+ v_uint16x8 diff0, diff1;
+ v_expand(diff, diff0, diff1);
+ hsad_l += diff0;
+ hsad_h += diff1;
+ v_store(hsad + d, hsad_l);
+ v_store(hsad + d + 8, hsad_h);
}
htext[y] += tab[lval];
}
@@ -419,21 +385,24 @@ static void findStereoCorrespondenceBM_SSE2( const Mat& left, const Mat& right,
hsad += ndisp, lptr += sstep, lptr_sub += sstep, rptr += sstep )
{
int lval = lptr[0];
- __m128i lv = _mm_set1_epi8((char)lval), z = _mm_setzero_si128();
+ v_uint8x16 lv = v_setall_u8((uchar)lval);
for( d = 0; d < ndisp; d += 16 )
{
- __m128i rv = _mm_loadu_si128((const __m128i*)(rptr + d));
- __m128i hsad_l = _mm_load_si128((__m128i*)(hsad + d));
- __m128i hsad_h = _mm_load_si128((__m128i*)(hsad + d + 8));
- __m128i cbs = _mm_load_si128((const __m128i*)(cbuf_sub + d));
- __m128i diff = _mm_adds_epu8(_mm_subs_epu8(lv, rv), _mm_subs_epu8(rv, lv));
- __m128i diff_h = _mm_sub_epi16(_mm_unpackhi_epi8(diff, z), _mm_unpackhi_epi8(cbs, z));
- _mm_store_si128((__m128i*)(cbuf + d), diff);
- diff = _mm_sub_epi16(_mm_unpacklo_epi8(diff, z), _mm_unpacklo_epi8(cbs, z));
- hsad_h = _mm_add_epi16(hsad_h, diff_h);
- hsad_l = _mm_add_epi16(hsad_l, diff);
- _mm_store_si128((__m128i*)(hsad + d), hsad_l);
- _mm_store_si128((__m128i*)(hsad + d + 8), hsad_h);
+ v_uint8x16 rv = v_load(rptr + d);
+ v_uint16x8 hsad_l = v_load(hsad + d);
+ v_uint16x8 hsad_h = v_load(hsad + d + 8);
+ v_uint8x16 cbs = v_load(cbuf_sub + d);
+ v_uint8x16 diff = v_absdiff(lv, rv);
+ v_int16x8 diff_l, diff_h, cbs_l, cbs_h;
+ v_store(cbuf + d, diff);
+ v_expand(v_reinterpret_as_s8(diff), diff_l, diff_h);
+ v_expand(v_reinterpret_as_s8(cbs), cbs_l, cbs_h);
+ diff_l -= cbs_l;
+ diff_h -= cbs_h;
+ hsad_h = v_reinterpret_as_u16(v_reinterpret_as_s16(hsad_h) + diff_h);
+ hsad_l = v_reinterpret_as_u16(v_reinterpret_as_s16(hsad_l) + diff_l);
+ v_store(hsad + d, hsad_l);
+ v_store(hsad + d + 8, hsad_h);
}
htext[y] += tab[lval] - tab[lptr_sub[0]];
}
@@ -450,16 +419,16 @@ static void findStereoCorrespondenceBM_SSE2( const Mat& left, const Mat& right,
hsad = hsad0 + (1 - dy0)*ndisp;
for( y = 1 - dy0; y < wsz2; y++, hsad += ndisp )
- for( d = 0; d < ndisp; d += 16 )
+ for( d = 0; d <= ndisp-16; d += 16 )
{
- __m128i s0 = _mm_load_si128((__m128i*)(sad + d));
- __m128i s1 = _mm_load_si128((__m128i*)(sad + d + 8));
- __m128i t0 = _mm_load_si128((__m128i*)(hsad + d));
- __m128i t1 = _mm_load_si128((__m128i*)(hsad + d + 8));
- s0 = _mm_add_epi16(s0, t0);
- s1 = _mm_add_epi16(s1, t1);
- _mm_store_si128((__m128i*)(sad + d), s0);
- _mm_store_si128((__m128i*)(sad + d + 8), s1);
+ v_uint16x8 s0 = v_load(sad + d);
+ v_uint16x8 s1 = v_load(sad + d + 8);
+ v_uint16x8 t0 = v_load(hsad + d);
+ v_uint16x8 t1 = v_load(hsad + d + 8);
+ s0 = s0 + t0;
+ s1 = s1 + t1;
+ v_store(sad + d, s0);
+ v_store(sad + d + 8, s1);
}
int tsum = 0;
for( y = -wsz2-1; y < wsz2; y++ )
@@ -471,38 +440,38 @@ static void findStereoCorrespondenceBM_SSE2( const Mat& left, const Mat& right,
int minsad = INT_MAX, mind = -1;
hsad = hsad0 + MIN(y + wsz2, height+dy1-1)*ndisp;
hsad_sub = hsad0 + MAX(y - wsz2 - 1, -dy0)*ndisp;
- __m128i minsad8 = _mm_set1_epi16(SHRT_MAX);
- __m128i mind8 = _mm_set1_epi16(0), d8 = d0_8, mask;
+ v_int16x8 minsad8 = v_setall_s16(SHRT_MAX);
+ v_int16x8 mind8 = v_setall_s16(0), d8 = d0_8;
for( d = 0; d < ndisp; d += 16 )
{
- __m128i u0 = _mm_load_si128((__m128i*)(hsad_sub + d));
- __m128i u1 = _mm_load_si128((__m128i*)(hsad + d));
+ v_int16x8 u0 = v_reinterpret_as_s16(v_load(hsad_sub + d));
+ v_int16x8 u1 = v_reinterpret_as_s16(v_load(hsad + d));
- __m128i v0 = _mm_load_si128((__m128i*)(hsad_sub + d + 8));
- __m128i v1 = _mm_load_si128((__m128i*)(hsad + d + 8));
+ v_int16x8 v0 = v_reinterpret_as_s16(v_load(hsad_sub + d + 8));
+ v_int16x8 v1 = v_reinterpret_as_s16(v_load(hsad + d + 8));
- __m128i usad8 = _mm_load_si128((__m128i*)(sad + d));
- __m128i vsad8 = _mm_load_si128((__m128i*)(sad + d + 8));
+ v_int16x8 usad8 = v_reinterpret_as_s16(v_load(sad + d));
+ v_int16x8 vsad8 = v_reinterpret_as_s16(v_load(sad + d + 8));
- u1 = _mm_sub_epi16(u1, u0);
- v1 = _mm_sub_epi16(v1, v0);
- usad8 = _mm_add_epi16(usad8, u1);
- vsad8 = _mm_add_epi16(vsad8, v1);
+ u1 -= u0;
+ v1 -= v0;
+ usad8 += u1;
+ vsad8 += v1;
- mask = _mm_cmpgt_epi16(minsad8, usad8);
- minsad8 = _mm_min_epi16(minsad8, usad8);
- mind8 = _mm_max_epi16(mind8, _mm_and_si128(mask, d8));
+ v_int16x8 mask = minsad8 > usad8;
+ minsad8 = v_min(minsad8, usad8);
+ mind8 = v_max(mind8, (mask& d8));
- _mm_store_si128((__m128i*)(sad + d), usad8);
- _mm_store_si128((__m128i*)(sad + d + 8), vsad8);
+ v_store(sad + d, v_reinterpret_as_u16(usad8));
+ v_store(sad + d + 8, v_reinterpret_as_u16(vsad8));
- mask = _mm_cmpgt_epi16(minsad8, vsad8);
- minsad8 = _mm_min_epi16(minsad8, vsad8);
+ mask = minsad8 > vsad8;
+ minsad8 = v_min(minsad8, vsad8);
- d8 = _mm_add_epi16(d8, dd_8);
- mind8 = _mm_max_epi16(mind8, _mm_and_si128(mask, d8));
- d8 = _mm_add_epi16(d8, dd_8);
+ d8 = d8 + dd_8;
+ mind8 = v_max(mind8, (mask & d8));
+ d8 = d8 + dd_8;
}
tsum += htext[y + wsz2] - htext[y - wsz2 - 1];
@@ -513,8 +482,8 @@ static void findStereoCorrespondenceBM_SSE2( const Mat& left, const Mat& right,
}
ushort CV_DECL_ALIGNED(16) minsad_buf[8], mind_buf[8];
- _mm_store_si128((__m128i*)minsad_buf, minsad8);
- _mm_store_si128((__m128i*)mind_buf, mind8);
+ v_store(minsad_buf, v_reinterpret_as_u16(minsad8));
+ v_store(mind_buf, v_reinterpret_as_u16(mind8));
for( d = 0; d < 8; d++ )
if(minsad > (int)minsad_buf[d] || (minsad == (int)minsad_buf[d] && mind > mind_buf[d]))
{
@@ -525,27 +494,27 @@ static void findStereoCorrespondenceBM_SSE2( const Mat& left, const Mat& right,
if( uniquenessRatio > 0 )
{
int thresh = minsad + (minsad * uniquenessRatio/100);
- __m128i thresh4 = _mm_set1_epi32(thresh + 1);
- __m128i d1 = _mm_set1_epi32(mind-1), d2 = _mm_set1_epi32(mind+1);
- __m128i dd_4 = _mm_set1_epi32(4);
- __m128i d4 = _mm_set_epi32(3,2,1,0);
- __m128i z = _mm_setzero_si128();
+ v_int32x4 thresh4 = v_setall_s32(thresh + 1);
+ v_int32x4 d1 = v_setall_s32(mind-1), d2 = v_setall_s32(mind+1);
+ v_int32x4 dd_4 = v_setall_s32(4);
+ v_int32x4 d4 = v_int32x4(0,1,2,3);
+ v_int32x4 mask4;
for( d = 0; d < ndisp; d += 8 )
{
- __m128i usad4 = _mm_loadu_si128((__m128i*)(sad + d));
- __m128i vsad4 = _mm_unpackhi_epi16(usad4, z);
- usad4 = _mm_unpacklo_epi16(usad4, z);
- mask = _mm_cmpgt_epi32( thresh4, usad4);
- mask = _mm_and_si128(mask, _mm_or_si128(_mm_cmpgt_epi32(d1,d4), _mm_cmpgt_epi32(d4,d2)));
- if( _mm_movemask_epi8(mask) )
+ v_int16x8 sad8 = v_reinterpret_as_s16(v_load(sad + d));
+ v_int32x4 sad4_l, sad4_h;
+ v_expand(sad8, sad4_l, sad4_h);
+ mask4 = thresh4 > sad4_l;
+ mask4 = mask4 & ((d1 > d4) | (d4 > d2));
+ if( v_signmask(mask4) )
break;
- d4 = _mm_add_epi16(d4, dd_4);
- mask = _mm_cmpgt_epi32( thresh4, vsad4);
- mask = _mm_and_si128(mask, _mm_or_si128(_mm_cmpgt_epi32(d1,d4), _mm_cmpgt_epi32(d4,d2)));
- if( _mm_movemask_epi8(mask) )
+ d4 += dd_4;
+ mask4 = thresh4 > sad4_h;
+ mask4 = mask4 & ((d1 > d4) | (d4 > d2));
+ if( v_signmask(mask4) )
break;
- d4 = _mm_add_epi16(d4, dd_4);
+ d4 += dd_4;
}
if( d < ndisp )
{
@@ -570,7 +539,7 @@ static void findStereoCorrespondenceBM_SSE2( const Mat& left, const Mat& right,
template <typename mType>
static void
-findStereoCorrespondenceBM_( const Mat& left, const Mat& right,
+findStereoCorrespondenceBM( const Mat& left, const Mat& right,
Mat& disp, Mat& cost, const StereoBMParams& state,
uchar* buf, int _dy0, int _dy1, const int disp_shift )
{
@@ -590,13 +559,12 @@ findStereoCorrespondenceBM_( const Mat& left, const Mat& right,
int uniquenessRatio = state.uniquenessRatio;
mType FILTERED = (mType)((mindisp - 1) << disp_shift);
-#if CV_NEON
- CV_Assert (ndisp % 8 == 0);
- int32_t d0_4_temp [4];
- for (int i = 0; i < 4; i ++)
- d0_4_temp[i] = i;
- int32x4_t d0_4 = vld1q_s32 (d0_4_temp);
- int32x4_t dd_4 = vdupq_n_s32 (4);
+#if CV_SIMD128
+ bool useSIMD = hasSIMD128();
+ if( useSIMD )
+ {
+ CV_Assert (ndisp % 8 == 0);
+ }
#endif
int *sad, *hsad0, *hsad, *hsad_sub, *htext;
@@ -633,29 +601,46 @@ findStereoCorrespondenceBM_( const Mat& left, const Mat& right,
for( y = -dy0; y < height + dy1; y++, hsad += ndisp, cbuf += ndisp, lptr += sstep, rptr += sstep )
{
int lval = lptr[0];
- #if CV_NEON
- int16x8_t lv = vdupq_n_s16 ((int16_t)lval);
-
- for( d = 0; d < ndisp; d += 8 )
+ d = 0;
+#if CV_SIMD128
+ if( useSIMD )
{
- int16x8_t rv = vreinterpretq_s16_u16 (vmovl_u8 (vld1_u8 (rptr + d)));
- int32x4_t hsad_l = vld1q_s32 (hsad + d);
- int32x4_t hsad_h = vld1q_s32 (hsad + d + 4);
- int16x8_t diff = vabdq_s16 (lv, rv);
- vst1_u8 (cbuf + d, vmovn_u16(vreinterpretq_u16_s16(diff)));
- hsad_l = vaddq_s32 (hsad_l, vmovl_s16(vget_low_s16 (diff)));
- hsad_h = vaddq_s32 (hsad_h, vmovl_s16(vget_high_s16 (diff)));
- vst1q_s32 ((hsad + d), hsad_l);
- vst1q_s32 ((hsad + d + 4), hsad_h);
+ v_uint8x16 lv = v_setall_u8((uchar)lval);
+
+ for( ; d <= ndisp - 16; d += 16 )
+ {
+ v_uint8x16 rv = v_load(rptr + d);
+ v_int32x4 hsad_0 = v_load(hsad + d);
+ v_int32x4 hsad_1 = v_load(hsad + d + 4);
+ v_int32x4 hsad_2 = v_load(hsad + d + 8);
+ v_int32x4 hsad_3 = v_load(hsad + d + 12);
+ v_uint8x16 diff = v_absdiff(lv, rv);
+ v_store(cbuf + d, diff);
+
+ v_uint16x8 diff0, diff1;
+ v_uint32x4 diff00, diff01, diff10, diff11;
+ v_expand(diff, diff0, diff1);
+ v_expand(diff0, diff00, diff01);
+ v_expand(diff1, diff10, diff11);
+
+ hsad_0 += v_reinterpret_as_s32(diff00);
+ hsad_1 += v_reinterpret_as_s32(diff01);
+ hsad_2 += v_reinterpret_as_s32(diff10);
+ hsad_3 += v_reinterpret_as_s32(diff11);
+
+ v_store(hsad + d, hsad_0);
+ v_store(hsad + d + 4, hsad_1);
+ v_store(hsad + d + 8, hsad_2);
+ v_store(hsad + d + 12, hsad_3);
+ }
}
- #else
- for( d = 0; d < ndisp; d++ )
+#endif
+ for( ; d < ndisp; d++ )
{
int diff = std::abs(lval - rptr[d]);
cbuf[d] = (uchar)diff;
hsad[d] = (int)(hsad[d] + diff);
}
- #endif
htext[y] += tab[lval];
}
}
@@ -685,31 +670,53 @@ findStereoCorrespondenceBM_( const Mat& left, const Mat& right,
hsad += ndisp, lptr += sstep, lptr_sub += sstep, rptr += sstep )
{
int lval = lptr[0];
- #if CV_NEON
- int16x8_t lv = vdupq_n_s16 ((int16_t)lval);
- for( d = 0; d < ndisp; d += 8 )
+ d = 0;
+#if CV_SIMD128
+ if( useSIMD )
{
- int16x8_t rv = vreinterpretq_s16_u16 (vmovl_u8 (vld1_u8 (rptr + d)));
- int32x4_t hsad_l = vld1q_s32 (hsad + d);
- int32x4_t hsad_h = vld1q_s32 (hsad + d + 4);
- int16x8_t cbs = vreinterpretq_s16_u16 (vmovl_u8 (vld1_u8 (cbuf_sub + d)));
- int16x8_t diff = vabdq_s16 (lv, rv);
- int32x4_t diff_h = vsubl_s16 (vget_high_s16 (diff), vget_high_s16 (cbs));
- int32x4_t diff_l = vsubl_s16 (vget_low_s16 (diff), vget_low_s16 (cbs));
- vst1_u8 (cbuf + d, vmovn_u16(vreinterpretq_u16_s16(diff)));
- hsad_h = vaddq_s32 (hsad_h, diff_h);
- hsad_l = vaddq_s32 (hsad_l, diff_l);
- vst1q_s32 ((hsad + d), hsad_l);
- vst1q_s32 ((hsad + d + 4), hsad_h);
+ v_uint8x16 lv = v_setall_u8((uchar)lval);
+ for( ; d <= ndisp - 16; d += 16 )
+ {
+ v_uint8x16 rv = v_load(rptr + d);
+ v_int32x4 hsad_0 = v_load(hsad + d);
+ v_int32x4 hsad_1 = v_load(hsad + d + 4);
+ v_int32x4 hsad_2 = v_load(hsad + d + 8);
+ v_int32x4 hsad_3 = v_load(hsad + d + 12);
+ v_uint8x16 cbs = v_load(cbuf_sub + d);
+ v_uint8x16 diff = v_absdiff(lv, rv);
+ v_store(cbuf + d, diff);
+
+ v_uint16x8 diff0, diff1, cbs0, cbs1;
+ v_int32x4 diff00, diff01, diff10, diff11, cbs00, cbs01, cbs10, cbs11;
+ v_expand(diff, diff0, diff1);
+ v_expand(cbs, cbs0, cbs1);
+ v_expand(v_reinterpret_as_s16(diff0), diff00, diff01);
+ v_expand(v_reinterpret_as_s16(diff1), diff10, diff11);
+ v_expand(v_reinterpret_as_s16(cbs0), cbs00, cbs01);
+ v_expand(v_reinterpret_as_s16(cbs1), cbs10, cbs11);
+
+ v_int32x4 diff_0 = diff00 - cbs00;
+ v_int32x4 diff_1 = diff01 - cbs01;
+ v_int32x4 diff_2 = diff10 - cbs10;
+ v_int32x4 diff_3 = diff11 - cbs11;
+ hsad_0 += diff_0;
+ hsad_1 += diff_1;
+ hsad_2 += diff_2;
+ hsad_3 += diff_3;
+
+ v_store(hsad + d, hsad_0);
+ v_store(hsad + d + 4, hsad_1);
+ v_store(hsad + d + 8, hsad_2);
+ v_store(hsad + d + 12, hsad_3);
+ }
}
- #else
- for( d = 0; d < ndisp; d++ )
+#endif
+ for( ; d < ndisp; d++ )
{
int diff = std::abs(lval - rptr[d]);
cbuf[d] = (uchar)diff;
hsad[d] = hsad[d] + diff - cbuf_sub[d];
}
- #endif
htext[y] += tab[lval] - tab[lptr_sub[0]];
}
@@ -726,22 +733,25 @@ findStereoCorrespondenceBM_( const Mat& left, const Mat& right,
hsad = hsad0 + (1 - dy0)*ndisp;
for( y = 1 - dy0; y < wsz2; y++, hsad += ndisp )
{
- #if CV_NEON
- for( d = 0; d <= ndisp-8; d += 8 )
+ d = 0;
+#if CV_SIMD128
+ if( useSIMD )
{
- int32x4_t s0 = vld1q_s32 (sad + d);
- int32x4_t s1 = vld1q_s32 (sad + d + 4);
- int32x4_t t0 = vld1q_s32 (hsad + d);
- int32x4_t t1 = vld1q_s32 (hsad + d + 4);
- s0 = vaddq_s32 (s0, t0);
- s1 = vaddq_s32 (s1, t1);
- vst1q_s32 (sad + d, s0);
- vst1q_s32 (sad + d + 4, s1);
+ for( d = 0; d <= ndisp-8; d += 8 )
+ {
+ v_int32x4 s0 = v_load(sad + d);
+ v_int32x4 s1 = v_load(sad + d + 4);
+ v_int32x4 t0 = v_load(hsad + d);
+ v_int32x4 t1 = v_load(hsad + d + 4);
+ s0 += t0;
+ s1 += t1;
+ v_store(sad + d, s0);
+ v_store(sad + d + 4, s1);
+ }
}
- #else
- for( d = 0; d < ndisp; d++ )
+#endif
+ for( ; d < ndisp; d++ )
sad[d] = (int)(sad[d] + hsad[d]);
- #endif
}
int tsum = 0;
for( y = -wsz2-1; y < wsz2; y++ )
@@ -753,62 +763,55 @@ findStereoCorrespondenceBM_( const Mat& left, const Mat& right,
int minsad = INT_MAX, mind = -1;
hsad = hsad0 + MIN(y + wsz2, height+dy1-1)*ndisp;
hsad_sub = hsad0 + MAX(y - wsz2 - 1, -dy0)*ndisp;
- #if CV_NEON
- int32x4_t minsad4 = vdupq_n_s32 (INT_MAX);
- int32x4_t mind4 = vdupq_n_s32(0), d4 = d0_4;
-
- for( d = 0; d <= ndisp-8; d += 8 )
+ d = 0;
+#if CV_SIMD128
+ if( useSIMD )
{
- int32x4_t u0 = vld1q_s32 (hsad_sub + d);
- int32x4_t u1 = vld1q_s32 (hsad + d);
+ v_int32x4 d0_4 = v_int32x4(0, 1, 2, 3);
+ v_int32x4 dd_4 = v_setall_s32(4);
+ v_int32x4 minsad4 = v_setall_s32(INT_MAX);
+ v_int32x4 mind4 = v_setall_s32(0), d4 = d0_4;
- int32x4_t v0 = vld1q_s32 (hsad_sub + d + 4);
- int32x4_t v1 = vld1q_s32 (hsad + d + 4);
+ for( ; d <= ndisp - 8; d += 8 )
+ {
+ v_int32x4 u0 = v_load(hsad_sub + d);
+ v_int32x4 u1 = v_load(hsad + d);
- int32x4_t usad4 = vld1q_s32(sad + d);
- int32x4_t vsad4 = vld1q_s32(sad + d + 4);
+ v_int32x4 v0 = v_load(hsad_sub + d + 4);
+ v_int32x4 v1 = v_load(hsad + d + 4);
- u1 = vsubq_s32 (u1, u0);
- v1 = vsubq_s32 (v1, v0);
- usad4 = vaddq_s32 (usad4, u1);
- vsad4 = vaddq_s32 (vsad4, v1);
+ v_int32x4 usad4 = v_load(sad + d);
+ v_int32x4 vsad4 = v_load(sad + d + 4);
- uint32x4_t mask = vcgtq_s32 (minsad4, usad4);
- minsad4 = vminq_s32 (minsad4, usad4);
- mind4 = vbslq_s32(mask, d4, mind4);
+ u1 -= u0;
+ v1 -= v0;
+ usad4 += u1;
+ vsad4 += v1;
- vst1q_s32 (sad + d, usad4);
- vst1q_s32 (sad + d + 4, vsad4);
- d4 = vaddq_s32 (d4, dd_4);
+ v_store(sad + d, usad4);
+ v_store(sad + d + 4, vsad4);
- mask = vcgtq_s32 (minsad4, vsad4);
- minsad4 = vminq_s32 (minsad4, vsad4);
- mind4 = vbslq_s32(mask, d4, mind4);
+ v_int32x4 mask = minsad4 > usad4;
+ minsad4 = v_min(minsad4, usad4);
+ mind4 = v_select(mask, d4, mind4);
+ d4 += dd_4;
- d4 = vaddq_s32 (d4, dd_4);
+ mask = minsad4 > vsad4;
+ minsad4 = v_min(minsad4, vsad4);
+ mind4 = v_select(mask, d4, mind4);
+ d4 += dd_4;
+ }
+ int CV_DECL_ALIGNED(16) minsad_buf[4], mind_buf[4];
+ v_store(minsad_buf, minsad4);
+ v_store(mind_buf, mind4);
+ if(minsad_buf[0] < minsad || (minsad == minsad_buf[0] && mind_buf[0] < mind)) { minsad = minsad_buf[0]; mind = mind_buf[0]; }
+ if(minsad_buf[1] < minsad || (minsad == minsad_buf[1] && mind_buf[1] < mind)) { minsad = minsad_buf[1]; mind = mind_buf[1]; }
+ if(minsad_buf[2] < minsad || (minsad == minsad_buf[2] && mind_buf[2] < mind)) { minsad = minsad_buf[2]; mind = mind_buf[2]; }
+ if(minsad_buf[3] < minsad || (minsad == minsad_buf[3] && mind_buf[3] < mind)) { minsad = minsad_buf[3]; mind = mind_buf[3]; }
}
- int32x2_t mind4_h = vget_high_s32 (mind4);
- int32x2_t mind4_l = vget_low_s32 (mind4);
- int32x2_t minsad4_h = vget_high_s32 (minsad4);
- int32x2_t minsad4_l = vget_low_s32 (minsad4);
-
- uint32x2_t mask = vorr_u32 (vclt_s32 (minsad4_h, minsad4_l), vand_u32 (vceq_s32 (minsad4_h, minsad4_l), vclt_s32 (mind4_h, mind4_l)));
- mind4_h = vbsl_s32 (mask, mind4_h, mind4_l);
- minsad4_h = vbsl_s32 (mask, minsad4_h, minsad4_l);
-
- mind4_l = vext_s32 (mind4_h,mind4_h,1);
- minsad4_l = vext_s32 (minsad4_h,minsad4_h,1);
-
- mask = vorr_u32 (vclt_s32 (minsad4_h, minsad4_l), vand_u32 (vceq_s32 (minsad4_h, minsad4_l), vclt_s32 (mind4_h, mind4_l)));
- mind4_h = vbsl_s32 (mask, mind4_h, mind4_l);
- minsad4_h = vbsl_s32 (mask, minsad4_h, minsad4_l);
-
- mind = (int) vget_lane_s32 (mind4_h, 0);
- minsad = sad[mind];
-
- #else
- for( d = 0; d < ndisp; d++ )
+#endif
+ for( ; d < ndisp; d++ )
{
int currsad = sad[d] + hsad[d] - hsad_sub[d];
sad[d] = currsad;
@@ -818,7 +821,6 @@ findStereoCorrespondenceBM_( const Mat& left, const Mat& right,
mind = d;
}
}
- #endif
tsum += htext[y + wsz2] - htext[y - wsz2 - 1];
if( tsum < textureThreshold )
@@ -855,19 +857,6 @@ findStereoCorrespondenceBM_( const Mat& left, const Mat& right,
}
}
-static void
-findStereoCorrespondenceBM( const Mat& left, const Mat& right,
- Mat& disp, Mat& cost, const StereoBMParams& state,
- uchar* buf, int _dy0, int _dy1 )
-{
- if(disp.type() == CV_16S)
- findStereoCorrespondenceBM_<short>(left, right, disp, cost, state,
- buf, _dy0, _dy1, DISPARITY_SHIFT_16S );
- else
- findStereoCorrespondenceBM_<int>(left, right, disp, cost, state,
- buf, _dy0, _dy1, DISPARITY_SHIFT_32S );
-}
-
#ifdef HAVE_OPENCL
static bool ocl_prefiltering(InputArray left0, InputArray right0, OutputArray left, OutputArray right, StereoBMParams* state)
{
@@ -972,6 +961,7 @@ struct FindStereoCorrespInvoker : public ParallelLoopBody
bool _useShorts, Rect _validDisparityRect,
Mat& _slidingSumBuf, Mat& _cost )
{
+ CV_Assert( _disp.type() == CV_16S || _disp.type() == CV_32S );
left = &_left; right = &_right;
disp = &_disp; state = _state;
nstripes = _nstripes; stripeBufSize = _stripeBufSize;
@@ -979,6 +969,9 @@ struct FindStereoCorrespInvoker : public ParallelLoopBody
validDisparityRect = _validDisparityRect;
slidingSumBuf = &_slidingSumBuf;
cost = &_cost;
+#if CV_SIMD128
+ useSIMD = hasSIMD128();
+#endif
}
void operator()( const Range& range ) const
@@ -1012,12 +1005,19 @@ struct FindStereoCorrespInvoker : public ParallelLoopBody
Mat disp_i = disp->rowRange(row0, row1);
Mat cost_i = state->disp12MaxDiff >= 0 ? cost->rowRange(row0, row1) : Mat();
-#if CV_SSE2
- if( useShorts )
- findStereoCorrespondenceBM_SSE2( left_i, right_i, disp_i, cost_i, *state, ptr, row0, rows - row1 );
+#if CV_SIMD128
+ if( useSIMD && useShorts )
+ {
+ findStereoCorrespondenceBM_SIMD( left_i, right_i, disp_i, cost_i, *state, ptr, row0, rows - row1 );
+ }
else
#endif
- findStereoCorrespondenceBM( left_i, right_i, disp_i, cost_i, *state, ptr, row0, rows - row1 );
+ {
+ if( disp_i.type() == CV_16S )
+ findStereoCorrespondenceBM<short>( left_i, right_i, disp_i, cost_i, *state, ptr, row0, rows - row1, DISPARITY_SHIFT_16S );
+ else
+ findStereoCorrespondenceBM<int>( left_i, right_i, disp_i, cost_i, *state, ptr, row0, rows - row1, DISPARITY_SHIFT_32S );
+ }
if( state->disp12MaxDiff >= 0 )
validateDisparity( disp_i, cost_i, state->minDisparity, state->numDisparities, state->disp12MaxDiff );
@@ -1043,6 +1043,7 @@ protected:
size_t stripeBufSize;
bool useShorts;
Rect validDisparityRect;
+ bool useSIMD;
};
class StereoBMImpl : public StereoBM
@@ -1168,12 +1169,7 @@ public:
if( params.speckleRange >= 0 && params.speckleWindowSize > 0 )
bufSize2 = width*height*(sizeof(Point_<short>) + sizeof(int) + sizeof(uchar));
-#if CV_SSE2
- bool useShorts = params.preFilterCap <= 31 && params.SADWindowSize <= 21 && checkHardwareSupport(CV_CPU_SSE2);
-#else
- const bool useShorts = false;
-#endif
-
+ bool useShorts = params.preFilterCap <= 31 && params.SADWindowSize <= 21;
const double SAD_overhead_coeff = 10.0;
double N0 = 8000000 / (useShorts ? 1 : 4); // approx tbb's min number instructions reasonable for one thread
double maxStripeSize = std::min(std::max(N0 / (width * ndisp), (wsz-1) * SAD_overhead_coeff), (double)height);
@@ -1188,8 +1184,8 @@ public:
parallel_for_(Range(0, 2), PrefilterInvoker(left0, right0, left, right, _buf, _buf + bufSize1, ¶ms), 1);
Rect validDisparityRect(0, 0, width, height), R1 = params.roi1, R2 = params.roi2;
- validDisparityRect = getValidDisparityROI(R1.area() > 0 ? Rect(0, 0, width, height) : validDisparityRect,
- R2.area() > 0 ? Rect(0, 0, width, height) : validDisparityRect,
+ validDisparityRect = getValidDisparityROI(R1.area() > 0 ? R1 : validDisparityRect,
+ R2.area() > 0 ? R2 : validDisparityRect,
params.minDisparity, params.numDisparities,
params.SADWindowSize);
diff --git a/modules/calib3d/src/stereosgbm.cpp b/modules/calib3d/src/stereosgbm.cpp
index 27ce62e..b5308a8 100644
--- a/modules/calib3d/src/stereosgbm.cpp
+++ b/modules/calib3d/src/stereosgbm.cpp
@@ -110,6 +110,7 @@ struct StereoSGBMParams
int mode;
};
+static const int DEFAULT_RIGHT_BORDER = -1;
/*
For each pixel row1[x], max(maxD, 0) <= minX <= x < maxX <= width - max(0, -minD),
and for each disparity minD<=d<maxD the function
@@ -123,12 +124,20 @@ struct StereoSGBMParams
static void calcPixelCostBT( const Mat& img1, const Mat& img2, int y,
int minD, int maxD, CostType* cost,
PixType* buffer, const PixType* tab,
- int tabOfs, int )
+ int tabOfs, int , int xrange_min = 0, int xrange_max = DEFAULT_RIGHT_BORDER )
{
int x, c, width = img1.cols, cn = img1.channels();
int minX1 = std::max(maxD, 0), maxX1 = width + std::min(minD, 0);
+ int D = maxD - minD, width1 = maxX1 - minX1;
+ //This minX1 & maxX2 correction is defining which part of calculatable line must be calculated
+ //That is needs of parallel algorithm
+ xrange_min = (xrange_min < 0) ? 0: xrange_min;
+ xrange_max = (xrange_max == DEFAULT_RIGHT_BORDER) || (xrange_max > width1) ? width1 : xrange_max;
+ maxX1 = minX1 + xrange_max;
+ minX1 += xrange_min;
+ width1 = maxX1 - minX1;
int minX2 = std::max(minX1 - maxD, 0), maxX2 = std::min(maxX1 - minD, width);
- int D = maxD - minD, width1 = maxX1 - minX1, width2 = maxX2 - minX2;
+ int width2 = maxX2 - minX2;
const PixType *row1 = img1.ptr<PixType>(y), *row2 = img2.ptr<PixType>(y);
PixType *prow1 = buffer + width2*2, *prow2 = prow1 + width*cn*2;
#if CV_SIMD128
@@ -146,9 +155,13 @@ static void calcPixelCostBT( const Mat& img1, const Mat& img2, int y,
int n1 = y > 0 ? -(int)img1.step : 0, s1 = y < img1.rows-1 ? (int)img1.step : 0;
int n2 = y > 0 ? -(int)img2.step : 0, s2 = y < img2.rows-1 ? (int)img2.step : 0;
+ int minX_cmn = std::min(minX1,minX2)-1;
+ int maxX_cmn = std::max(maxX1,maxX2)+1;
+ minX_cmn = std::max(minX_cmn, 1);
+ maxX_cmn = std::min(maxX_cmn, width - 1);
if( cn == 1 )
{
- for( x = 1; x < width-1; x++ )
+ for( x = minX_cmn; x < maxX_cmn; x++ )
{
prow1[x] = tab[(row1[x+1] - row1[x-1])*2 + row1[x+n1+1] - row1[x+n1-1] + row1[x+s1+1] - row1[x+s1-1]];
prow2[width-1-x] = tab[(row2[x+1] - row2[x-1])*2 + row2[x+n2+1] - row2[x+n2-1] + row2[x+s2+1] - row2[x+s2-1]];
@@ -159,7 +172,7 @@ static void calcPixelCostBT( const Mat& img1, const Mat& img2, int y,
}
else
{
- for( x = 1; x < width-1; x++ )
+ for( x = minX_cmn; x < maxX_cmn; x++ )
{
prow1[x] = tab[(row1[x*3+3] - row1[x*3-3])*2 + row1[x*3+n1+3] - row1[x*3+n1-3] + row1[x*3+s1+3] - row1[x*3+s1-3]];
prow1[x+width] = tab[(row1[x*3+4] - row1[x*3-2])*2 + row1[x*3+n1+4] - row1[x*3+n1-2] + row1[x*3+s1+4] - row1[x*3+s1-2]];
@@ -179,10 +192,10 @@ static void calcPixelCostBT( const Mat& img1, const Mat& img2, int y,
}
}
- memset( cost, 0, width1*D*sizeof(cost[0]) );
+ memset( cost + xrange_min*D, 0, width1*D*sizeof(cost[0]) );
- buffer -= minX2;
- cost -= minX1*D + minD; // simplify the cost indices inside the loop
+ buffer -= width-1-maxX2;
+ cost -= (minX1-xrange_min)*D + minD; // simplify the cost indices inside the loop
for( c = 0; c < cn*2; c++, prow1 += width, prow2 += width )
{
@@ -191,7 +204,7 @@ static void calcPixelCostBT( const Mat& img1, const Mat& img2, int y,
// precompute
// v0 = min(row2[x-1/2], row2[x], row2[x+1/2]) and
// v1 = max(row2[x-1/2], row2[x], row2[x+1/2]) and
- for( x = minX2; x < maxX2; x++ )
+ for( x = width-1-maxX2; x < width-1- minX2; x++ )
{
int v = prow2[x];
int vl = x > 0 ? (v + prow2[x-1])/2 : v;
@@ -353,7 +366,7 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2,
if( buffer.empty() || !buffer.isContinuous() ||
buffer.cols*buffer.rows*buffer.elemSize() < totalBufSize )
- buffer.create(1, (int)totalBufSize, CV_8U);
+ buffer.reserveBuffer(totalBufSize);
// summary cost over different (nDirs) directions
CostType* Cbuf = (CostType*)alignPtr(buffer.ptr(), ALIGN);
@@ -513,6 +526,7 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2,
6: r=(1, -dy*2)
7: r=(2, -dy)
*/
+
for( x = x1; x != x2; x += dx )
{
int xm = x*NR2, xd = xm*D2;
@@ -828,6 +842,670 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2,
}
}
+////////////////////////////////////////////////////////////////////////////////////////////
+struct CalcVerticalSums: public ParallelLoopBody
+{
+ CalcVerticalSums(const Mat& _img1, const Mat& _img2, const StereoSGBMParams& params,
+ CostType* alignedBuf, PixType* _clipTab): img1(_img1), img2(_img2), clipTab(_clipTab)
+ {
+ minD = params.minDisparity;
+ maxD = minD + params.numDisparities;
+ SW2 = SH2 = (params.SADWindowSize > 0 ? params.SADWindowSize : 5)/2;
+ ftzero = std::max(params.preFilterCap, 15) | 1;
+ P1 = params.P1 > 0 ? params.P1 : 2;
+ P2 = std::max(params.P2 > 0 ? params.P2 : 5, P1+1);
+ height = img1.rows;
+ width = img1.cols;
+ int minX1 = std::max(maxD, 0), maxX1 = width + std::min(minD, 0);
+ D = maxD - minD;
+ width1 = maxX1 - minX1;
+ D2 = D + 16;
+ costBufSize = width1*D;
+ CSBufSize = costBufSize*height;
+ minLrSize = width1;
+ LrSize = minLrSize*D2;
+ hsumBufNRows = SH2*2 + 2;
+ Cbuf = alignedBuf;
+ Sbuf = Cbuf + CSBufSize;
+ hsumBuf = Sbuf + CSBufSize;
+ useSIMD = hasSIMD128();
+ }
+
+ void operator()( const Range& range ) const
+ {
+ static const CostType MAX_COST = SHRT_MAX;
+ static const int ALIGN = 16;
+ static const int TAB_OFS = 256*4;
+ static const int npasses = 2;
+ int x1 = range.start, x2 = range.end, k;
+ size_t pixDiffSize = ((x2 - x1) + 2*SW2)*D;
+ size_t auxBufsSize = pixDiffSize*sizeof(CostType) + //pixdiff size
+ width*16*img1.channels()*sizeof(PixType) + 32; //tempBuf
+ Mat auxBuff;
+ auxBuff.create(1, (int)auxBufsSize, CV_8U);
+ CostType* pixDiff = (CostType*)alignPtr(auxBuff.ptr(), ALIGN);
+ PixType* tempBuf = (PixType*)(pixDiff + pixDiffSize);
+
+ // Simplification of index calculation
+ pixDiff -= (x1>SW2 ? (x1 - SW2): 0)*D;
+
+ for( int pass = 1; pass <= npasses; pass++ )
+ {
+ int y1, y2, dy;
+
+ if( pass == 1 )
+ {
+ y1 = 0; y2 = height; dy = 1;
+ }
+ else
+ {
+ y1 = height-1; y2 = -1; dy = -1;
+ }
+
+ CostType *Lr[NLR]={0}, *minLr[NLR]={0};
+
+ for( k = 0; k < NLR; k++ )
+ {
+ // shift Lr[k] and minLr[k] pointers, because we allocated them with the borders,
+ // and will occasionally use negative indices with the arrays
+ // we need to shift Lr[k] pointers by 1, to give the space for d=-1.
+ // however, then the alignment will be imperfect, i.e. bad for SSE,
+ // thus we shift the pointers by 8 (8*sizeof(short) == 16 - ideal alignment)
+ Lr[k] = hsumBuf + costBufSize*hsumBufNRows + LrSize*k + 8;
+ memset( Lr[k] + x1*D2 - 8, 0, (x2-x1)*D2*sizeof(CostType) );
+ minLr[k] = hsumBuf + costBufSize*hsumBufNRows + LrSize*NLR + minLrSize*k;
+ memset( minLr[k] + x1, 0, (x2-x1)*sizeof(CostType) );
+ }
+
+ for( int y = y1; y != y2; y += dy )
+ {
+ int x, d;
+ CostType* C = Cbuf + y*costBufSize;
+ CostType* S = Sbuf + y*costBufSize;
+
+ if( pass == 1 ) // compute C on the first pass, and reuse it on the second pass, if any.
+ {
+ int dy1 = y == 0 ? 0 : y + SH2, dy2 = y == 0 ? SH2 : dy1;
+
+ for( k = dy1; k <= dy2; k++ )
+ {
+ CostType* hsumAdd = hsumBuf + (std::min(k, height-1) % hsumBufNRows)*costBufSize;
+
+ if( k < height )
+ {
+ calcPixelCostBT( img1, img2, k, minD, maxD, pixDiff, tempBuf, clipTab, TAB_OFS, ftzero, x1 - SW2, x2 + SW2);
+
+ memset(hsumAdd + x1*D, 0, D*sizeof(CostType));
+ for( x = (x1 - SW2)*D; x <= (x1 + SW2)*D; x += D )
+ {
+ int xbord = x <= 0 ? 0 : (x > (width1 - 1)*D? (width1 - 1)*D : x);
+ for( d = 0; d < D; d++ )
+ hsumAdd[x1*D + d] = (CostType)(hsumAdd[x1*D + d] + pixDiff[xbord + d]);
+ }
+
+ if( y > 0 )
+ {
+ const CostType* hsumSub = hsumBuf + (std::max(y - SH2 - 1, 0) % hsumBufNRows)*costBufSize;
+ const CostType* Cprev = C - costBufSize;
+
+ for( d = 0; d < D; d++ )
+ C[x1*D + d] = (CostType)(Cprev[x1*D + d] + hsumAdd[x1*D + d] - hsumSub[x1*D + d]);
+
+ for( x = (x1+1)*D; x < x2*D; x += D )
+ {
+ const CostType* pixAdd = pixDiff + std::min(x + SW2*D, (width1-1)*D);
+ const CostType* pixSub = pixDiff + std::max(x - (SW2+1)*D, 0);
+
+ #if CV_SIMD128
+ if( useSIMD )
+ {
+ for( d = 0; d < D; d += 8 )
+ {
+ v_int16x8 hv = v_load(hsumAdd + x - D + d);
+ v_int16x8 Cx = v_load(Cprev + x + d);
+ v_int16x8 psub = v_load(pixSub + d);
+ v_int16x8 padd = v_load(pixAdd + d);
+ hv = (hv - psub + padd);
+ psub = v_load(hsumSub + x + d);
+ Cx = Cx - psub + hv;
+ v_store(hsumAdd + x + d, hv);
+ v_store(C + x + d, Cx);
+ }
+ }
+ else
+ #endif
+ {
+ for( d = 0; d < D; d++ )
+ {
+ int hv = hsumAdd[x + d] = (CostType)(hsumAdd[x - D + d] + pixAdd[d] - pixSub[d]);
+ C[x + d] = (CostType)(Cprev[x + d] + hv - hsumSub[x + d]);
+ }
+ }
+ }
+ }
+ else
+ {
+ for( x = (x1+1)*D; x < x2*D; x += D )
+ {
+ const CostType* pixAdd = pixDiff + std::min(x + SW2*D, (width1-1)*D);
+ const CostType* pixSub = pixDiff + std::max(x - (SW2+1)*D, 0);
+
+ for( d = 0; d < D; d++ )
+ hsumAdd[x + d] = (CostType)(hsumAdd[x - D + d] + pixAdd[d] - pixSub[d]);
+ }
+ }
+ }
+
+ if( y == 0 )
+ {
+ int scale = k == 0 ? SH2 + 1 : 1;
+ for( x = x1*D; x < x2*D; x++ )
+ C[x] = (CostType)(C[x] + hsumAdd[x]*scale);
+ }
+ }
+
+ // also, clear the S buffer
+ for( k = x1*D; k < x2*D; k++ )
+ S[k] = 0;
+ }
+
+// [formula 13 in the paper]
+// compute L_r(p, d) = C(p, d) +
+// min(L_r(p-r, d),
+// L_r(p-r, d-1) + P1,
+// L_r(p-r, d+1) + P1,
+// min_k L_r(p-r, k) + P2) - min_k L_r(p-r, k)
+// where p = (x,y), r is one of the directions.
+// we process one directions on first pass and other on second:
+// r=(0, dy), where dy=1 on first pass and dy=-1 on second
+
+ for( x = x1; x != x2; x++ )
+ {
+ int xd = x*D2;
+
+ int delta = minLr[1][x] + P2;
+
+ CostType* Lr_ppr = Lr[1] + xd;
+
+ Lr_ppr[-1] = Lr_ppr[D] = MAX_COST;
+
+ CostType* Lr_p = Lr[0] + xd;
+ const CostType* Cp = C + x*D;
+ CostType* Sp = S + x*D;
+
+ #if CV_SIMD128
+ if( useSIMD )
+ {
+ v_int16x8 _P1 = v_setall_s16((short)P1);
+
+ v_int16x8 _delta = v_setall_s16((short)delta);
+ v_int16x8 _minL = v_setall_s16((short)MAX_COST);
+
+ for( d = 0; d < D; d += 8 )
+ {
+ v_int16x8 Cpd = v_load(Cp + d);
+ v_int16x8 L;
+
+ L = v_load(Lr_ppr + d);
+
+ L = v_min(L, (v_load(Lr_ppr + d - 1) + _P1));
+ L = v_min(L, (v_load(Lr_ppr + d + 1) + _P1));
+
+ L = v_min(L, _delta);
+ L = ((L - _delta) + Cpd);
+
+ v_store(Lr_p + d, L);
+
+ // Get minimum from in L-L3
+ _minL = v_min(_minL, L);
+
+ v_int16x8 Sval = v_load(Sp + d);
+
+ Sval = Sval + L;
+
+ v_store(Sp + d, Sval);
+ }
+
+ v_int32x4 min1, min2, min12;
+ v_expand(_minL, min1, min2);
+ min12 = v_min(min1,min2);
+ minLr[0][x] = (CostType)v_reduce_min(min12);
+ }
+ else
+ #endif
+ {
+ int minL = MAX_COST;
+
+ for( d = 0; d < D; d++ )
+ {
+ int Cpd = Cp[d], L;
+
+ L = Cpd + std::min((int)Lr_ppr[d], std::min(Lr_ppr[d-1] + P1, std::min(Lr_ppr[d+1] + P1, delta))) - delta;
+
+ Lr_p[d] = (CostType)L;
+ minL = std::min(minL, L);
+
+ Sp[d] = saturate_cast<CostType>(Sp[d] + L);
+ }
+ minLr[0][x] = (CostType)minL;
+ }
+ }
+
+ // now shift the cyclic buffers
+ std::swap( Lr[0], Lr[1] );
+ std::swap( minLr[0], minLr[1] );
+ }
+ }
+ }
+ static const int NLR = 2;
+ const Mat& img1;
+ const Mat& img2;
+ CostType* Cbuf;
+ CostType* Sbuf;
+ CostType* hsumBuf;
+ PixType* clipTab;
+ int minD;
+ int maxD;
+ int D;
+ int D2;
+ int SH2;
+ int SW2;
+ int width;
+ int width1;
+ int height;
+ int P1;
+ int P2;
+ size_t costBufSize;
+ size_t CSBufSize;
+ size_t minLrSize;
+ size_t LrSize;
+ size_t hsumBufNRows;
+ int ftzero;
+ bool useSIMD;
+};
+
+struct CalcHorizontalSums: public ParallelLoopBody
+{
+ CalcHorizontalSums(const Mat& _img1, const Mat& _img2, Mat& _disp1, const StereoSGBMParams& params,
+ CostType* alignedBuf): img1(_img1), img2(_img2), disp1(_disp1)
+ {
+ minD = params.minDisparity;
+ maxD = minD + params.numDisparities;
+ P1 = params.P1 > 0 ? params.P1 : 2;
+ P2 = std::max(params.P2 > 0 ? params.P2 : 5, P1+1);
+ uniquenessRatio = params.uniquenessRatio >= 0 ? params.uniquenessRatio : 10;
+ disp12MaxDiff = params.disp12MaxDiff > 0 ? params.disp12MaxDiff : 1;
+ height = img1.rows;
+ width = img1.cols;
+ minX1 = std::max(maxD, 0);
+ maxX1 = width + std::min(minD, 0);
+ INVALID_DISP = minD - 1;
+ INVALID_DISP_SCALED = INVALID_DISP*DISP_SCALE;
+ D = maxD - minD;
+ width1 = maxX1 - minX1;
+ costBufSize = width1*D;
+ CSBufSize = costBufSize*height;
+ D2 = D + 16;
+ LrSize = 2 * D2;
+ Cbuf = alignedBuf;
+ Sbuf = Cbuf + CSBufSize;
+ useSIMD = hasSIMD128();
+ }
+
+ void operator()( const Range& range ) const
+ {
+ int y1 = range.start, y2 = range.end;
+ size_t auxBufsSize = LrSize * sizeof(CostType) + width*(sizeof(CostType) + sizeof(DispType)) + 32;
+
+ Mat auxBuff;
+ auxBuff.create(1, (int)auxBufsSize, CV_8U);
+ CostType *Lr = ((CostType*)alignPtr(auxBuff.ptr(), ALIGN)) + 8;
+ CostType* disp2cost = Lr + LrSize;
+ DispType* disp2ptr = (DispType*)(disp2cost + width);
+
+ CostType minLr;
+
+ for( int y = y1; y != y2; y++)
+ {
+ int x, d;
+ DispType* disp1ptr = disp1.ptr<DispType>(y);
+ CostType* C = Cbuf + y*costBufSize;
+ CostType* S = Sbuf + y*costBufSize;
+
+ for( x = 0; x < width; x++ )
+ {
+ disp1ptr[x] = disp2ptr[x] = (DispType)INVALID_DISP_SCALED;
+ disp2cost[x] = MAX_COST;
+ }
+
+ // clear buffers
+ memset( Lr - 8, 0, LrSize*sizeof(CostType) );
+ Lr[-1] = Lr[D] = Lr[D2 - 1] = Lr[D2 + D] = MAX_COST;
+
+ minLr = 0;
+// [formula 13 in the paper]
+// compute L_r(p, d) = C(p, d) +
+// min(L_r(p-r, d),
+// L_r(p-r, d-1) + P1,
+// L_r(p-r, d+1) + P1,
+// min_k L_r(p-r, k) + P2) - min_k L_r(p-r, k)
+// where p = (x,y), r is one of the directions.
+// we process all the directions at once:
+// we process one directions on first pass and other on second:
+// r=(dx, 0), where dx=1 on first pass and dx=-1 on second
+ for( x = 0; x != width1; x++)
+ {
+ int delta = minLr + P2;
+
+ CostType* Lr_ppr = Lr + ((x&1)? 0 : D2);
+
+ CostType* Lr_p = Lr + ((x&1)? D2 :0);
+ const CostType* Cp = C + x*D;
+ CostType* Sp = S + x*D;
+
+ #if CV_SIMD128
+ if( useSIMD )
+ {
+ v_int16x8 _P1 = v_setall_s16((short)P1);
+
+ v_int16x8 _delta = v_setall_s16((short)delta);
+ v_int16x8 _minL = v_setall_s16((short)MAX_COST);
+
+ for( d = 0; d < D; d += 8 )
+ {
+ v_int16x8 Cpd = v_load(Cp + d);
+ v_int16x8 L;
+
+ L = v_load(Lr_ppr + d);
+
+ L = v_min(L, (v_load(Lr_ppr + d - 1) + _P1));
+ L = v_min(L, (v_load(Lr_ppr + d + 1) + _P1));
+
+ L = v_min(L, _delta);
+ L = ((L - _delta) + Cpd);
+
+ v_store(Lr_p + d, L);
+
+ // Get minimum from in L-L3
+ _minL = v_min(_minL, L);
+
+ v_int16x8 Sval = v_load(Sp + d);
+
+ Sval = Sval + L;
+
+ v_store(Sp + d, Sval);
+ }
+
+ v_int32x4 min1, min2, min12;
+ v_expand(_minL, min1, min2);
+ min12 = v_min(min1,min2);
+ minLr = (CostType)v_reduce_min(min12);
+ }
+ else
+ #endif
+ {
+ minLr = MAX_COST;
+ for( d = 0; d < D; d++ )
+ {
+ int Cpd = Cp[d], L;
+
+ L = Cpd + std::min((int)Lr_ppr[d], std::min(Lr_ppr[d-1] + P1, std::min(Lr_ppr[d+1] + P1, delta))) - delta;
+
+ Lr_p[d] = (CostType)L;
+ minLr = (CostType)std::min((int)minLr, L);
+
+ Sp[d] = saturate_cast<CostType>(Sp[d] + L);
+ }
+ }
+ }
+
+ memset( Lr - 8, 0, LrSize*sizeof(CostType) );
+ Lr[-1] = Lr[D] = Lr[D2 - 1] = Lr[D2 + D] = MAX_COST;
+
+ minLr = 0;
+
+ for( x = width1-1; x != -1; x--)
+ {
+ int delta = minLr + P2;
+
+ CostType* Lr_ppr = Lr + ((x&1)? 0 :D2);
+
+ CostType* Lr_p = Lr + ((x&1)? D2 :0);
+ const CostType* Cp = C + x*D;
+ CostType* Sp = S + x*D;
+ int minS = MAX_COST, bestDisp = -1;
+ minLr = MAX_COST;
+
+ #if CV_SIMD128
+ if( useSIMD )
+ {
+ v_int16x8 _P1 = v_setall_s16((short)P1);
+
+ v_int16x8 _delta = v_setall_s16((short)delta);
+ v_int16x8 _minL = v_setall_s16((short)MAX_COST);
+
+ v_int16x8 _minS = v_setall_s16(MAX_COST), _bestDisp = v_setall_s16(-1);
+ v_int16x8 _d8 = v_int16x8(0, 1, 2, 3, 4, 5, 6, 7), _8 = v_setall_s16(8);
+
+ for( d = 0; d < D; d+= 8 )
+ {
+ v_int16x8 Cpd = v_load(Cp + d);
+ v_int16x8 L;
+
+ L = v_load(Lr_ppr + d);
+
+ L = v_min(L, (v_load(Lr_ppr + d - 1) + _P1));
+ L = v_min(L, (v_load(Lr_ppr + d + 1) + _P1));
+
+ L = v_min(L, _delta);
+ L = ((L - _delta) + Cpd);
+
+ v_store(Lr_p + d, L);
+
+ // Get minimum from in L-L3
+ _minL = v_min(_minL, L);
+
+ v_int16x8 Sval = v_load(Sp + d);
+
+ Sval = Sval + L;
+
+ v_int16x8 mask = Sval < _minS;
+ _minS = v_min( Sval, _minS );
+ _bestDisp = _bestDisp ^ ((_bestDisp ^ _d8) & mask);
+ _d8 = _d8 + _8;
+
+ v_store(Sp + d, Sval);
+ }
+ v_int32x4 min1, min2, min12;
+ v_expand(_minL, min1, min2);
+ min12 = v_min(min1,min2);
+ minLr = (CostType)v_reduce_min(min12);
+
+ v_int32x4 _d0, _d1;
+ v_expand(_minS, _d0, _d1);
+ minS = (int)std::min(v_reduce_min(_d0), v_reduce_min(_d1));
+ v_int16x8 v_mask = v_setall_s16((short)minS) == _minS;
+
+ _bestDisp = (_bestDisp & v_mask) | (v_setall_s16(SHRT_MAX) & ~v_mask);
+ v_expand(_bestDisp, _d0, _d1);
+ bestDisp = (int)std::min(v_reduce_min(_d0), v_reduce_min(_d1));
+ }
+ else
+ #endif
+ {
+ for( d = 0; d < D; d++ )
+ {
+ int Cpd = Cp[d], L;
+
+ L = Cpd + std::min((int)Lr_ppr[d], std::min(Lr_ppr[d-1] + P1, std::min(Lr_ppr[d+1] + P1, delta))) - delta;
+
+ Lr_p[d] = (CostType)L;
+ minLr = (CostType)std::min((int)minLr, L);
+
+ Sp[d] = saturate_cast<CostType>(Sp[d] + L);
+ if( Sp[d] < minS )
+ {
+ minS = Sp[d];
+ bestDisp = d;
+ }
+ }
+ }
+ //Some postprocessing procedures and saving
+ for( d = 0; d < D; d++ )
+ {
+ if( Sp[d]*(100 - uniquenessRatio) < minS*100 && std::abs(bestDisp - d) > 1 )
+ break;
+ }
+ if( d < D )
+ continue;
+ d = bestDisp;
+ int _x2 = x + minX1 - d - minD;
+ if( disp2cost[_x2] > minS )
+ {
+ disp2cost[_x2] = (CostType)minS;
+ disp2ptr[_x2] = (DispType)(d + minD);
+ }
+
+ if( 0 < d && d < D-1 )
+ {
+ // do subpixel quadratic interpolation:
+ // fit parabola into (x1=d-1, y1=Sp[d-1]), (x2=d, y2=Sp[d]), (x3=d+1, y3=Sp[d+1])
+ // then find minimum of the parabola.
+ int denom2 = std::max(Sp[d-1] + Sp[d+1] - 2*Sp[d], 1);
+ d = d*DISP_SCALE + ((Sp[d-1] - Sp[d+1])*DISP_SCALE + denom2)/(denom2*2);
+ }
+ else
+ d *= DISP_SCALE;
+ disp1ptr[x + minX1] = (DispType)(d + minD*DISP_SCALE);
+ }
+ //Left-right check sanity procedure
+ for( x = minX1; x < maxX1; x++ )
+ {
+ // we round the computed disparity both towards -inf and +inf and check
+ // if either of the corresponding disparities in disp2 is consistent.
+ // This is to give the computed disparity a chance to look valid if it is.
+ int d1 = disp1ptr[x];
+ if( d1 == INVALID_DISP_SCALED )
+ continue;
+ int _d = d1 >> DISP_SHIFT;
+ int d_ = (d1 + DISP_SCALE-1) >> DISP_SHIFT;
+ int _x = x - _d, x_ = x - d_;
+ if( 0 <= _x && _x < width && disp2ptr[_x] >= minD && std::abs(disp2ptr[_x] - _d) > disp12MaxDiff &&
+ 0 <= x_ && x_ < width && disp2ptr[x_] >= minD && std::abs(disp2ptr[x_] - d_) > disp12MaxDiff )
+ disp1ptr[x] = (DispType)INVALID_DISP_SCALED;
+ }
+ }
+ }
+
+ static const int DISP_SHIFT = StereoMatcher::DISP_SHIFT;
+ static const int DISP_SCALE = (1 << DISP_SHIFT);
+ static const CostType MAX_COST = SHRT_MAX;
+ static const int ALIGN = 16;
+ const Mat& img1;
+ const Mat& img2;
+ Mat& disp1;
+ CostType* Cbuf;
+ CostType* Sbuf;
+ int minD;
+ int maxD;
+ int D;
+ int D2;
+ int width;
+ int width1;
+ int height;
+ int P1;
+ int P2;
+ int minX1;
+ int maxX1;
+ size_t costBufSize;
+ size_t CSBufSize;
+ size_t LrSize;
+ int INVALID_DISP;
+ int INVALID_DISP_SCALED;
+ int uniquenessRatio;
+ int disp12MaxDiff;
+ bool useSIMD;
+};
+/*
+ computes disparity for "roi" in img1 w.r.t. img2 and write it to disp1buf.
+ that is, disp1buf(x, y)=d means that img1(x+roi.x, y+roi.y) ~ img2(x+roi.x-d, y+roi.y).
+ minD <= d < maxD.
+
+ note that disp1buf will have the same size as the roi and
+ On exit disp1buf is not the final disparity, it is an intermediate result that becomes
+ final after all the tiles are processed.
+
+ the disparity in disp1buf is written with sub-pixel accuracy
+ (4 fractional bits, see StereoSGBM::DISP_SCALE),
+ using quadratic interpolation, while the disparity in disp2buf
+ is written as is, without interpolation.
+ */
+static void computeDisparitySGBM_HH4( const Mat& img1, const Mat& img2,
+ Mat& disp1, const StereoSGBMParams& params,
+ Mat& buffer )
+{
+ const int ALIGN = 16;
+ const int DISP_SHIFT = StereoMatcher::DISP_SHIFT;
+ const int DISP_SCALE = (1 << DISP_SHIFT);
+ int minD = params.minDisparity, maxD = minD + params.numDisparities;
+ Size SADWindowSize;
+ SADWindowSize.width = SADWindowSize.height = params.SADWindowSize > 0 ? params.SADWindowSize : 5;
+ int ftzero = std::max(params.preFilterCap, 15) | 1;
+ int P1 = params.P1 > 0 ? params.P1 : 2, P2 = std::max(params.P2 > 0 ? params.P2 : 5, P1+1);
+ int k, width = disp1.cols, height = disp1.rows;
+ int minX1 = std::max(maxD, 0), maxX1 = width + std::min(minD, 0);
+ int D = maxD - minD, width1 = maxX1 - minX1;
+ int SH2 = SADWindowSize.height/2;
+ int INVALID_DISP = minD - 1;
+ int INVALID_DISP_SCALED = INVALID_DISP*DISP_SCALE;
+ const int TAB_OFS = 256*4, TAB_SIZE = 256 + TAB_OFS*2;
+ PixType clipTab[TAB_SIZE];
+
+ for( k = 0; k < TAB_SIZE; k++ )
+ clipTab[k] = (PixType)(std::min(std::max(k - TAB_OFS, -ftzero), ftzero) + ftzero);
+
+ if( minX1 >= maxX1 )
+ {
+ disp1 = Scalar::all(INVALID_DISP_SCALED);
+ return;
+ }
+
+ CV_Assert( D % 16 == 0 );
+
+ int D2 = D+16;
+
+ // the number of L_r(.,.) and min_k L_r(.,.) lines in the buffer:
+ // for dynamic programming we need the current row and
+ // the previous row, i.e. 2 rows in total
+ const int NLR = 2;
+
+ // for each possible stereo match (img1(x,y) <=> img2(x-d,y))
+ // we keep pixel difference cost (C) and the summary cost over 4 directions (S).
+ // we also keep all the partial costs for the previous line L_r(x,d) and also min_k L_r(x, k)
+ size_t costBufSize = width1*D;
+ size_t CSBufSize = costBufSize*height;
+ size_t minLrSize = width1 , LrSize = minLrSize*D2;
+ int hsumBufNRows = SH2*2 + 2;
+ size_t totalBufSize = (LrSize + minLrSize)*NLR*sizeof(CostType) + // minLr[] and Lr[]
+ costBufSize*hsumBufNRows*sizeof(CostType) + // hsumBuf
+ CSBufSize*2*sizeof(CostType) + 1024; // C, S
+
+ if( buffer.empty() || !buffer.isContinuous() ||
+ buffer.cols*buffer.rows*buffer.elemSize() < totalBufSize )
+ buffer.create(1, (int)totalBufSize, CV_8U);
+
+ // summary cost over different (nDirs) directions
+ CostType* Cbuf = (CostType*)alignPtr(buffer.ptr(), ALIGN);
+
+ // add P2 to every C(x,y). it saves a few operations in the inner loops
+ for(k = 0; k < (int)CSBufSize; k++ )
+ Cbuf[k] = (CostType)P2;
+
+ parallel_for_(Range(0,width1),CalcVerticalSums(img1, img2, params, Cbuf, clipTab),8);
+ parallel_for_(Range(0,height),CalcHorizontalSums(img1, img2, disp1, params, Cbuf),8);
+
+}
+
//////////////////////////////////////////////////////////////////////////////////////////////////////
void getBufferPointers(Mat& buffer, int width, int width1, int D, int num_ch, int SH2, int P2,
@@ -939,7 +1617,7 @@ void getBufferPointers(Mat& buffer, int width, int width1, int D, int num_ch, in
16; //to compensate for the alignPtr shifts
if( buffer.empty() || !buffer.isContinuous() || buffer.cols*buffer.rows*buffer.elemSize() < totalBufSize )
- buffer.create(1, (int)totalBufSize, CV_8U);
+ buffer.reserveBuffer(totalBufSize);
// set up all the pointers:
curCostVolumeLine = (CostType*)alignPtr(buffer.ptr(), 16);
@@ -1482,6 +2160,8 @@ public:
if(params.mode==MODE_SGBM_3WAY)
computeDisparity3WaySGBM( left, right, disp, params, buffers, num_stripes );
+ else if(params.mode==MODE_HH4)
+ computeDisparitySGBM_HH4( left, right, disp, params, buffer );
else
computeDisparitySGBM( left, right, disp, params, buffer );
@@ -1615,7 +2295,7 @@ void filterSpecklesImpl(cv::Mat& img, int newVal, int maxSpeckleSize, int maxDif
int width = img.cols, height = img.rows, npixels = width*height;
size_t bufSize = npixels*(int)(sizeof(Point2s) + sizeof(int) + sizeof(uchar));
if( !_buf.isContinuous() || _buf.empty() || _buf.cols*_buf.rows*_buf.elemSize() < bufSize )
- _buf.create(1, (int)bufSize, CV_8U);
+ _buf.reserveBuffer(bufSize);
uchar* buf = _buf.ptr();
int i, j, dstep = (int)(img.step/sizeof(T));
@@ -1705,43 +2385,37 @@ void filterSpecklesImpl(cv::Mat& img, int newVal, int maxSpeckleSize, int maxDif
}
#ifdef HAVE_IPP
-static bool ipp_filterSpeckles(Mat &img, int maxSpeckleSize, int newVal, int maxDiff)
+static bool ipp_filterSpeckles(Mat &img, int maxSpeckleSize, int newVal, int maxDiff, Mat &buffer)
{
+#if IPP_VERSION_X100 >= 810
CV_INSTRUMENT_REGION_IPP()
-#if IPP_VERSION_X100 >= 810
- int type = img.type();
- Ipp32s bufsize = 0;
- IppiSize roisize = { img.cols, img.rows };
- IppDataType datatype = type == CV_8UC1 ? ipp8u : ipp16s;
- Ipp8u *pBuffer = NULL;
- IppStatus status = ippStsNoErr;
+ IppDataType dataType = ippiGetDataType(img.depth());
+ IppiSize size = ippiSize(img.size());
+ int bufferSize;
- if(ippiMarkSpecklesGetBufferSize(roisize, datatype, CV_MAT_CN(type), &bufsize) < 0)
+ if(img.channels() != 1)
return false;
- pBuffer = (Ipp8u*)ippMalloc(bufsize);
- if(!pBuffer && bufsize)
+ if(dataType != ipp8u && dataType != ipp16s)
return false;
- if (type == CV_8UC1)
- {
- status = CV_INSTRUMENT_FUN_IPP(ippiMarkSpeckles_8u_C1IR, img.ptr<Ipp8u>(), (int)img.step, roisize,
- (Ipp8u)newVal, maxSpeckleSize, (Ipp8u)maxDiff, ippiNormL1, pBuffer);
- }
- else
+ if(ippiMarkSpecklesGetBufferSize(size, dataType, 1, &bufferSize) < 0)
+ return false;
+
+ if(bufferSize && (buffer.empty() || (int)(buffer.step*buffer.rows) < bufferSize))
+ buffer.create(1, (int)bufferSize, CV_8U);
+
+ switch(dataType)
{
- status = CV_INSTRUMENT_FUN_IPP(ippiMarkSpeckles_16s_C1IR, img.ptr<Ipp16s>(), (int)img.step, roisize,
- (Ipp16s)newVal, maxSpeckleSize, (Ipp16s)maxDiff, ippiNormL1, pBuffer);
+ case ipp8u: return CV_INSTRUMENT_FUN_IPP(ippiMarkSpeckles_8u_C1IR, img.ptr<Ipp8u>(), (int)img.step, size, (Ipp8u)newVal, maxSpeckleSize, (Ipp8u)maxDiff, ippiNormL1, buffer.ptr<Ipp8u>()) >= 0;
+ case ipp16s: return CV_INSTRUMENT_FUN_IPP(ippiMarkSpeckles_16s_C1IR, img.ptr<Ipp16s>(), (int)img.step, size, (Ipp16s)newVal, maxSpeckleSize, (Ipp16s)maxDiff, ippiNormL1, buffer.ptr<Ipp8u>()) >= 0;
+ default: return false;
}
- if(pBuffer) ippFree(pBuffer);
-
- if (status >= 0)
- return true;
#else
- CV_UNUSED(img); CV_UNUSED(maxSpeckleSize); CV_UNUSED(newVal); CV_UNUSED(maxDiff);
-#endif
+ CV_UNUSED(img); CV_UNUSED(maxSpeckleSize); CV_UNUSED(newVal); CV_UNUSED(maxDiff); CV_UNUSED(buffer);
return false;
+#endif
}
#endif
@@ -1759,7 +2433,7 @@ void cv::filterSpeckles( InputOutputArray _img, double _newval, int maxSpeckleSi
int newVal = cvRound(_newval), maxDiff = cvRound(_maxDiff);
- CV_IPP_RUN(IPP_VERSION_X100 >= 810 && !__buf.needed() && (type == CV_8UC1 || type == CV_16SC1), ipp_filterSpeckles(img, maxSpeckleSize, newVal, maxDiff));
+ CV_IPP_RUN_FAST(ipp_filterSpeckles(img, maxSpeckleSize, newVal, maxDiff, _buf));
if (type == CV_8UC1)
filterSpecklesImpl<uchar>(img, newVal, maxSpeckleSize, maxDiff, _buf);
diff --git a/modules/calib3d/src/triangulate.cpp b/modules/calib3d/src/triangulate.cpp
index 33c7fd7..959c244 100644
--- a/modules/calib3d/src/triangulate.cpp
+++ b/modules/calib3d/src/triangulate.cpp
@@ -114,52 +114,6 @@ cvTriangulatePoints(CvMat* projMatr1, CvMat* projMatr2, CvMat* projPoints1, CvMa
cvmSet(points4D,2,i,matrV(3,2));/* Z */
cvmSet(points4D,3,i,matrV(3,3));/* W */
}
-
-#if 0
- double err = 0;
- /* Points was reconstructed. Try to reproject points */
- /* We can compute reprojection error if need */
- {
- int i;
- CvMat point3D;
- double point3D_dat[4];
- point3D = cvMat(4,1,CV_64F,point3D_dat);
-
- CvMat point2D;
- double point2D_dat[3];
- point2D = cvMat(3,1,CV_64F,point2D_dat);
-
- for( i = 0; i < numPoints; i++ )
- {
- double W = cvmGet(points4D,3,i);
-
- point3D_dat[0] = cvmGet(points4D,0,i)/W;
- point3D_dat[1] = cvmGet(points4D,1,i)/W;
- point3D_dat[2] = cvmGet(points4D,2,i)/W;
- point3D_dat[3] = 1;
-
- /* !!! Project this point for each camera */
- for( int currCamera = 0; currCamera < 2; currCamera++ )
- {
- cvMatMul(projMatrs[currCamera], &point3D, &point2D);
-
- float x,y;
- float xr,yr,wr;
- x = (float)cvmGet(projPoints[currCamera],0,i);
- y = (float)cvmGet(projPoints[currCamera],1,i);
-
- wr = (float)point2D_dat[2];
- xr = (float)(point2D_dat[0]/wr);
- yr = (float)(point2D_dat[1]/wr);
-
- float deltaX,deltaY;
- deltaX = (float)fabs(x-xr);
- deltaY = (float)fabs(y-yr);
- err += deltaX*deltaX + deltaY*deltaY;
- }
- }
- }
-#endif
}
@@ -327,7 +281,7 @@ cvCorrectMatches(CvMat *F_, CvMat *points1_, CvMat *points2_, CvMat *new_points1
c = cvGetReal2D(RTFTR,2,1);
d = cvGetReal2D(RTFTR,2,2);
- // Form the polynomial g(t) = k6*t⁶ + k5*t⁵ + k4*t⁴ + k3*t³ + k2*t² + k1*t + k0
+ // Form the polynomial g(t) = k6*t^6 + k5*t^5 + k4*t^4 + k3*t^3 + k2*t^2 + k1*t + k0
// from f1, f2, a, b, c and d
cvSetReal2D(polynomial,0,6,( +b*c*c*f1*f1*f1*f1*a-a*a*d*f1*f1*f1*f1*c ));
cvSetReal2D(polynomial,0,5,( +f2*f2*f2*f2*c*c*c*c+2*a*a*f2*f2*c*c-a*a*d*d*f1*f1*f1*f1+b*b*c*c*f1*f1*f1*f1+a*a*a*a ));
diff --git a/modules/calib3d/src/upnp.cpp b/modules/calib3d/src/upnp.cpp
index 1054e0b..a674df5 100644
--- a/modules/calib3d/src/upnp.cpp
+++ b/modules/calib3d/src/upnp.cpp
@@ -175,7 +175,7 @@ void upnp::estimate_R_and_t(double R[3][3], double t[3])
pw0[j] /= number_of_correspondences;
}
- double abt[3 * 3], abt_d[3], abt_u[3 * 3], abt_v[3 * 3];
+ double abt[3 * 3] = {0}, abt_d[3], abt_u[3 * 3], abt_v[3 * 3];
Mat ABt = Mat(3, 3, CV_64F, abt);
Mat ABt_D = Mat(3, 1, CV_64F, abt_d);
Mat ABt_U = Mat(3, 3, CV_64F, abt_u);
@@ -575,7 +575,7 @@ void upnp::gauss_newton(const Mat * L_6x12, const Mat * Rho, double betas[4], do
{
const int iterations_number = 50;
- double a[6*4], b[6], x[4];
+ double a[6*4], b[6], x[4] = {0};
Mat * A = new Mat(6, 4, CV_64F, a);
Mat * B = new Mat(6, 1, CV_64F, b);
Mat * X = new Mat(4, 1, CV_64F, x);
@@ -720,6 +720,8 @@ void upnp::qr_solve(Mat * A, Mat * b, Mat * X)
{
const int nr = A->rows;
const int nc = A->cols;
+ if (nr <= 0 || nc <= 0)
+ return;
if (max_nr != 0 && max_nr < nr)
{
diff --git a/modules/calib3d/test/test_affine2d_estimator.cpp b/modules/calib3d/test/test_affine2d_estimator.cpp
index de9f700..2007c49 100644
--- a/modules/calib3d/test/test_affine2d_estimator.cpp
+++ b/modules/calib3d/test/test_affine2d_estimator.cpp
@@ -127,4 +127,32 @@ TEST_P(EstimateAffine2D, testNPoints)
}
}
+// test conversion from other datatypes than float
+TEST_P(EstimateAffine2D, testConversion)
+{
+ Mat aff(2, 3, CV_32S);
+ cv::randu(aff, 1., 3.);
+
+ std::vector<Point> fpts(3);
+ std::vector<Point> tpts(3);
+
+ // setting points that are not in the same line
+ fpts[0] = Point2f( rngIn(1,2), rngIn(5,6) );
+ fpts[1] = Point2f( rngIn(3,4), rngIn(3,4) );
+ fpts[2] = Point2f( rngIn(1,2), rngIn(3,4) );
+
+ transform(fpts, tpts, aff);
+
+ vector<uchar> inliers;
+ Mat aff_est = estimateAffine2D(fpts, tpts, inliers, GetParam() /* method */);
+
+ ASSERT_FALSE(aff_est.empty());
+
+ aff.convertTo(aff, CV_64F); // need to convert before compare
+ EXPECT_NEAR(0., cvtest::norm(aff_est, aff, NORM_INF), 1e-3);
+
+ // all must be inliers
+ EXPECT_EQ(countNonZero(inliers), 3);
+}
+
INSTANTIATE_TEST_CASE_P(Calib3d, EstimateAffine2D, Method::all());
diff --git a/modules/calib3d/test/test_affine_partial2d_estimator.cpp b/modules/calib3d/test/test_affine_partial2d_estimator.cpp
index dde7d7d..a61739a 100644
--- a/modules/calib3d/test/test_affine_partial2d_estimator.cpp
+++ b/modules/calib3d/test/test_affine_partial2d_estimator.cpp
@@ -137,4 +137,31 @@ TEST_P(EstimateAffinePartial2D, testNPoints)
}
}
+// test conversion from other datatypes than float
+TEST_P(EstimateAffinePartial2D, testConversion)
+{
+ Mat aff = rngPartialAffMat();
+ aff.convertTo(aff, CV_32S); // convert to int to transform ints properly
+
+ std::vector<Point> fpts(3);
+ std::vector<Point> tpts(3);
+
+ fpts[0] = Point2f( rngIn(1,2), rngIn(5,6) );
+ fpts[1] = Point2f( rngIn(3,4), rngIn(3,4) );
+ fpts[2] = Point2f( rngIn(1,2), rngIn(3,4) );
+
+ transform(fpts, tpts, aff);
+
+ vector<uchar> inliers;
+ Mat aff_est = estimateAffinePartial2D(fpts, tpts, inliers, GetParam() /* method */);
+
+ ASSERT_FALSE(aff_est.empty());
+
+ aff.convertTo(aff, CV_64F); // need to convert back before compare
+ EXPECT_NEAR(0., cvtest::norm(aff_est, aff, NORM_INF), 1e-3);
+
+ // all must be inliers
+ EXPECT_EQ(countNonZero(inliers), 3);
+}
+
INSTANTIATE_TEST_CASE_P(Calib3d, EstimateAffinePartial2D, Method::all());
diff --git a/modules/calib3d/test/test_cameracalibration.cpp b/modules/calib3d/test/test_cameracalibration.cpp
index 0f07405..d738341 100644
--- a/modules/calib3d/test/test_cameracalibration.cpp
+++ b/modules/calib3d/test/test_cameracalibration.cpp
@@ -1570,7 +1570,8 @@ void CV_StereoCalibrationTest::run( int )
{
ts->printf( cvtest::TS::LOG, "The file %s can not be opened or has invalid content\n", filepath.c_str() );
ts->set_failed_test_info( f ? cvtest::TS::FAIL_INVALID_TEST_DATA : cvtest::TS::FAIL_MISSING_TEST_DATA );
- fclose(f);
+ if (f)
+ fclose(f);
return;
}
diff --git a/modules/calib3d/test/test_chesscorners.cpp b/modules/calib3d/test/test_chesscorners.cpp
index 781eec2..64a2d69 100644
--- a/modules/calib3d/test/test_chesscorners.cpp
+++ b/modules/calib3d/test/test_chesscorners.cpp
@@ -268,14 +268,6 @@ void CV_ChessboardDetectorTest::run_batch( const string& filename )
#ifndef WRITE_POINTS
double err = calcError(v, expected);
-#if 0
- if( err > rough_success_error_level )
- {
- ts.printf( cvtest::TS::LOG, "bad accuracy of corner guesses\n" );
- ts.set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );
- continue;
- }
-#endif
max_rough_error = MAX( max_rough_error, err );
#endif
if( pattern == CHESSBOARD )
@@ -287,14 +279,12 @@ void CV_ChessboardDetectorTest::run_batch( const string& filename )
err = calcError(v, expected);
sum_error += err;
count++;
-#if 1
if( err > precise_success_error_level )
{
ts->printf( cvtest::TS::LOG, "Image %s: bad accuracy of adjusted corners %f\n", img_file.c_str(), err );
ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );
return;
}
-#endif
ts->printf(cvtest::TS::LOG, "Error on %s is %f\n", img_file.c_str(), err);
max_precise_error = MAX( max_precise_error, err );
#endif
diff --git a/modules/calib3d/test/test_fisheye.cpp b/modules/calib3d/test/test_fisheye.cpp
index 9ad8c64..af466ca 100644
--- a/modules/calib3d/test/test_fisheye.cpp
+++ b/modules/calib3d/test/test_fisheye.cpp
@@ -245,13 +245,13 @@ TEST_F(fisheyeTest, Calibration)
cv::FileStorage fs_left(combine(folder, "left.xml"), cv::FileStorage::READ);
CV_Assert(fs_left.isOpened());
for(int i = 0; i < n_images; ++i)
- fs_left[cv::format("image_%d", i )] >> imagePoints[i];
+ fs_left[cv::format("image_%d", i )] >> imagePoints[i];
fs_left.release();
cv::FileStorage fs_object(combine(folder, "object.xml"), cv::FileStorage::READ);
CV_Assert(fs_object.isOpened());
for(int i = 0; i < n_images; ++i)
- fs_object[cv::format("image_%d", i )] >> objectPoints[i];
+ fs_object[cv::format("image_%d", i )] >> objectPoints[i];
fs_object.release();
int flag = 0;
@@ -280,13 +280,13 @@ TEST_F(fisheyeTest, Homography)
cv::FileStorage fs_left(combine(folder, "left.xml"), cv::FileStorage::READ);
CV_Assert(fs_left.isOpened());
for(int i = 0; i < n_images; ++i)
- fs_left[cv::format("image_%d", i )] >> imagePoints[i];
+ fs_left[cv::format("image_%d", i )] >> imagePoints[i];
fs_left.release();
cv::FileStorage fs_object(combine(folder, "object.xml"), cv::FileStorage::READ);
CV_Assert(fs_object.isOpened());
for(int i = 0; i < n_images; ++i)
- fs_object[cv::format("image_%d", i )] >> objectPoints[i];
+ fs_object[cv::format("image_%d", i )] >> objectPoints[i];
fs_object.release();
cv::internal::IntrinsicParams param;
@@ -330,7 +330,7 @@ TEST_F(fisheyeTest, Homography)
EXPECT_MAT_NEAR(std_err, correct_std_err, 1e-12);
}
-TEST_F(fisheyeTest, EtimateUncertainties)
+TEST_F(fisheyeTest, EstimateUncertainties)
{
const int n_images = 34;
@@ -341,13 +341,13 @@ TEST_F(fisheyeTest, EtimateUncertainties)
cv::FileStorage fs_left(combine(folder, "left.xml"), cv::FileStorage::READ);
CV_Assert(fs_left.isOpened());
for(int i = 0; i < n_images; ++i)
- fs_left[cv::format("image_%d", i )] >> imagePoints[i];
+ fs_left[cv::format("image_%d", i )] >> imagePoints[i];
fs_left.release();
cv::FileStorage fs_object(combine(folder, "object.xml"), cv::FileStorage::READ);
CV_Assert(fs_object.isOpened());
for(int i = 0; i < n_images; ++i)
- fs_object[cv::format("image_%d", i )] >> objectPoints[i];
+ fs_object[cv::format("image_%d", i )] >> objectPoints[i];
fs_object.release();
int flag = 0;
@@ -435,9 +435,9 @@ TEST_F(fisheyeTest, rectify)
if (correct.empty())
cv::imwrite(combine(datasets_repository_path, cv::format("rectification_AB_%03d.png", i)), rectification);
- else
- EXPECT_MAT_NEAR(correct, rectification, 1e-10);
- }
+ else
+ EXPECT_MAT_NEAR(correct, rectification, 1e-10);
+ }
}
TEST_F(fisheyeTest, stereoCalibrate)
@@ -453,19 +453,19 @@ TEST_F(fisheyeTest, stereoCalibrate)
cv::FileStorage fs_left(combine(folder, "left.xml"), cv::FileStorage::READ);
CV_Assert(fs_left.isOpened());
for(int i = 0; i < n_images; ++i)
- fs_left[cv::format("image_%d", i )] >> leftPoints[i];
+ fs_left[cv::format("image_%d", i )] >> leftPoints[i];
fs_left.release();
cv::FileStorage fs_right(combine(folder, "right.xml"), cv::FileStorage::READ);
CV_Assert(fs_right.isOpened());
for(int i = 0; i < n_images; ++i)
- fs_right[cv::format("image_%d", i )] >> rightPoints[i];
+ fs_right[cv::format("image_%d", i )] >> rightPoints[i];
fs_right.release();
cv::FileStorage fs_object(combine(folder, "object.xml"), cv::FileStorage::READ);
CV_Assert(fs_object.isOpened());
for(int i = 0; i < n_images; ++i)
- fs_object[cv::format("image_%d", i )] >> objectPoints[i];
+ fs_object[cv::format("image_%d", i )] >> objectPoints[i];
fs_object.release();
cv::Matx33d K1, K2, theR;
@@ -476,7 +476,6 @@ TEST_F(fisheyeTest, stereoCalibrate)
flag |= cv::fisheye::CALIB_RECOMPUTE_EXTRINSIC;
flag |= cv::fisheye::CALIB_CHECK_COND;
flag |= cv::fisheye::CALIB_FIX_SKEW;
- // flag |= cv::fisheye::CALIB_FIX_INTRINSIC;
cv::fisheye::stereoCalibrate(objectPoints, leftPoints, rightPoints,
K1, D1, K2, D2, imageSize, theR, theT, flag,
@@ -521,19 +520,19 @@ TEST_F(fisheyeTest, stereoCalibrateFixIntrinsic)
cv::FileStorage fs_left(combine(folder, "left.xml"), cv::FileStorage::READ);
CV_Assert(fs_left.isOpened());
for(int i = 0; i < n_images; ++i)
- fs_left[cv::format("image_%d", i )] >> leftPoints[i];
+ fs_left[cv::format("image_%d", i )] >> leftPoints[i];
fs_left.release();
cv::FileStorage fs_right(combine(folder, "right.xml"), cv::FileStorage::READ);
CV_Assert(fs_right.isOpened());
for(int i = 0; i < n_images; ++i)
- fs_right[cv::format("image_%d", i )] >> rightPoints[i];
+ fs_right[cv::format("image_%d", i )] >> rightPoints[i];
fs_right.release();
cv::FileStorage fs_object(combine(folder, "object.xml"), cv::FileStorage::READ);
CV_Assert(fs_object.isOpened());
for(int i = 0; i < n_images; ++i)
- fs_object[cv::format("image_%d", i )] >> objectPoints[i];
+ fs_object[cv::format("image_%d", i )] >> objectPoints[i];
fs_object.release();
cv::Matx33d theR;
@@ -572,44 +571,44 @@ TEST_F(fisheyeTest, stereoCalibrateFixIntrinsic)
TEST_F(fisheyeTest, CalibrationWithDifferentPointsNumber)
{
- const int n_images = 2;
+ const int n_images = 2;
- std::vector<std::vector<cv::Point2d> > imagePoints(n_images);
- std::vector<std::vector<cv::Point3d> > objectPoints(n_images);
+ std::vector<std::vector<cv::Point2d> > imagePoints(n_images);
+ std::vector<std::vector<cv::Point3d> > objectPoints(n_images);
- std::vector<cv::Point2d> imgPoints1(10);
- std::vector<cv::Point2d> imgPoints2(15);
+ std::vector<cv::Point2d> imgPoints1(10);
+ std::vector<cv::Point2d> imgPoints2(15);
- std::vector<cv::Point3d> objectPoints1(imgPoints1.size());
- std::vector<cv::Point3d> objectPoints2(imgPoints2.size());
+ std::vector<cv::Point3d> objectPoints1(imgPoints1.size());
+ std::vector<cv::Point3d> objectPoints2(imgPoints2.size());
- for (size_t i = 0; i < imgPoints1.size(); i++)
- {
- imgPoints1[i] = cv::Point2d((double)i, (double)i);
- objectPoints1[i] = cv::Point3d((double)i, (double)i, 10.0);
- }
+ for (size_t i = 0; i < imgPoints1.size(); i++)
+ {
+ imgPoints1[i] = cv::Point2d((double)i, (double)i);
+ objectPoints1[i] = cv::Point3d((double)i, (double)i, 10.0);
+ }
- for (size_t i = 0; i < imgPoints2.size(); i++)
- {
- imgPoints2[i] = cv::Point2d(i + 0.5, i + 0.5);
- objectPoints2[i] = cv::Point3d(i + 0.5, i + 0.5, 10.0);
- }
+ for (size_t i = 0; i < imgPoints2.size(); i++)
+ {
+ imgPoints2[i] = cv::Point2d(i + 0.5, i + 0.5);
+ objectPoints2[i] = cv::Point3d(i + 0.5, i + 0.5, 10.0);
+ }
- imagePoints[0] = imgPoints1;
- imagePoints[1] = imgPoints2;
- objectPoints[0] = objectPoints1;
- objectPoints[1] = objectPoints2;
+ imagePoints[0] = imgPoints1;
+ imagePoints[1] = imgPoints2;
+ objectPoints[0] = objectPoints1;
+ objectPoints[1] = objectPoints2;
- cv::Matx33d theK = cv::Matx33d::eye();
- cv::Vec4d theD;
+ cv::Matx33d theK = cv::Matx33d::eye();
+ cv::Vec4d theD;
- int flag = 0;
- flag |= cv::fisheye::CALIB_RECOMPUTE_EXTRINSIC;
- flag |= cv::fisheye::CALIB_USE_INTRINSIC_GUESS;
- flag |= cv::fisheye::CALIB_FIX_SKEW;
+ int flag = 0;
+ flag |= cv::fisheye::CALIB_RECOMPUTE_EXTRINSIC;
+ flag |= cv::fisheye::CALIB_USE_INTRINSIC_GUESS;
+ flag |= cv::fisheye::CALIB_FIX_SKEW;
- cv::fisheye::calibrate(objectPoints, imagePoints, cv::Size(100, 100), theK, theD,
- cv::noArray(), cv::noArray(), flag, cv::TermCriteria(3, 20, 1e-6));
+ cv::fisheye::calibrate(objectPoints, imagePoints, cv::Size(100, 100), theK, theD,
+ cv::noArray(), cv::noArray(), flag, cv::TermCriteria(3, 20, 1e-6));
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/modules/calib3d/test/test_homography_decomp.cpp b/modules/calib3d/test/test_homography_decomp.cpp
index 7e1c8ea..a5a71e4 100644
--- a/modules/calib3d/test/test_homography_decomp.cpp
+++ b/modules/calib3d/test/test_homography_decomp.cpp
@@ -13,7 +13,7 @@
// License Agreement
// For Open Source Computer Vision Library
//
- // Copyright (C) 2014, Samson Yilma¸ (samson_yilma at yahoo.com), all rights reserved.
+ // Copyright (C) 2014, Samson Yilma (samson_yilma at yahoo.com), all rights reserved.
//
// Third party copyrights are property of their respective owners.
//
diff --git a/modules/calib3d/test/test_solvepnp_ransac.cpp b/modules/calib3d/test/test_solvepnp_ransac.cpp
index e6e9b6b..0adbbc9 100644
--- a/modules/calib3d/test/test_solvepnp_ransac.cpp
+++ b/modules/calib3d/test/test_solvepnp_ransac.cpp
@@ -57,25 +57,26 @@ public:
eps[SOLVEPNP_ITERATIVE] = 1.0e-2;
eps[SOLVEPNP_EPNP] = 1.0e-2;
eps[SOLVEPNP_P3P] = 1.0e-2;
+ eps[SOLVEPNP_AP3P] = 1.0e-2;
eps[SOLVEPNP_DLS] = 1.0e-2;
eps[SOLVEPNP_UPNP] = 1.0e-2;
totalTestsCount = 10;
+ pointsCount = 500;
}
~CV_solvePnPRansac_Test() {}
protected:
- void generate3DPointCloud(vector<Point3f>& points, Point3f pmin = Point3f(-1,
- -1, 5), Point3f pmax = Point3f(1, 1, 10))
+ void generate3DPointCloud(vector<Point3f>& points,
+ Point3f pmin = Point3f(-1, -1, 5),
+ Point3f pmax = Point3f(1, 1, 10))
{
- const Point3f delta = pmax - pmin;
+ RNG rng = ::theRNG(); // fix the seed to use "fixed" input 3D points
+
for (size_t i = 0; i < points.size(); i++)
{
- Point3f p(float(rand()) / RAND_MAX, float(rand()) / RAND_MAX,
- float(rand()) / RAND_MAX);
- p.x *= delta.x;
- p.y *= delta.y;
- p.z *= delta.z;
- p = p + pmin;
- points[i] = p;
+ float _x = rng.uniform(pmin.x, pmax.x);
+ float _y = rng.uniform(pmin.y, pmax.y);
+ float _z = rng.uniform(pmin.z, pmax.z);
+ points[i] = Point3f(_x, _y, _z);
}
}
@@ -137,8 +138,7 @@ protected:
}
}
- solvePnPRansac(points, projectedPoints, intrinsics, distCoeffs, rvec, tvec,
- false, 500, 0.5f, 0.99, inliers, method);
+ solvePnPRansac(points, projectedPoints, intrinsics, distCoeffs, rvec, tvec, false, pointsCount, 0.5f, 0.99, inliers, method);
bool isTestSuccess = inliers.size() >= points.size()*0.95;
@@ -152,31 +152,30 @@ protected:
return isTestSuccess;
}
- void run(int)
+ virtual void run(int)
{
ts->set_failed_test_info(cvtest::TS::OK);
vector<Point3f> points, points_dls;
- const int pointsCount = 500;
points.resize(pointsCount);
generate3DPointCloud(points);
- const int methodsCount = 5;
RNG rng = ts->get_rng();
for (int mode = 0; mode < 2; mode++)
{
- for (int method = 0; method < methodsCount; method++)
+ for (int method = 0; method < SOLVEPNP_MAX_COUNT; method++)
{
double maxError = 0;
int successfulTestsCount = 0;
for (int testIndex = 0; testIndex < totalTestsCount; testIndex++)
{
if (runTest(rng, mode, method, points, eps, maxError))
+ {
successfulTestsCount++;
+ }
}
- //cout << maxError << " " << successfulTestsCount << endl;
if (successfulTestsCount < 0.7*totalTestsCount)
{
ts->printf( cvtest::TS::LOG, "Invalid accuracy for method %d, failed %d tests from %d, maximum error equals %f, distortion mode equals %d\n",
@@ -189,8 +188,9 @@ protected:
}
}
}
- double eps[5];
+ double eps[SOLVEPNP_MAX_COUNT];
int totalTestsCount;
+ int pointsCount;
};
class CV_solvePnP_Test : public CV_solvePnPRansac_Test
@@ -200,7 +200,8 @@ public:
{
eps[SOLVEPNP_ITERATIVE] = 1.0e-6;
eps[SOLVEPNP_EPNP] = 1.0e-6;
- eps[SOLVEPNP_P3P] = 1.0e-4;
+ eps[SOLVEPNP_P3P] = 2.0e-4;
+ eps[SOLVEPNP_AP3P] = 1.0e-4;
eps[SOLVEPNP_DLS] = 1.0e-4;
eps[SOLVEPNP_UPNP] = 1.0e-4;
totalTestsCount = 1000;
@@ -214,43 +215,150 @@ protected:
Mat trueRvec, trueTvec;
Mat intrinsics, distCoeffs;
generateCameraMatrix(intrinsics, rng);
- if (method == 4) intrinsics.at<double>(1,1) = intrinsics.at<double>(0,0);
+ if (method == SOLVEPNP_DLS)
+ {
+ intrinsics.at<double>(1,1) = intrinsics.at<double>(0,0);
+ }
if (mode == 0)
+ {
distCoeffs = Mat::zeros(4, 1, CV_64FC1);
+ }
else
+ {
generateDistCoeffs(distCoeffs, rng);
+ }
generatePose(trueRvec, trueTvec, rng);
std::vector<Point3f> opoints;
- if (method == 2)
+ switch(method)
{
- opoints = std::vector<Point3f>(points.begin(), points.begin()+4);
+ case SOLVEPNP_P3P:
+ case SOLVEPNP_AP3P:
+ opoints = std::vector<Point3f>(points.begin(), points.begin()+4);
+ break;
+ case SOLVEPNP_UPNP:
+ opoints = std::vector<Point3f>(points.begin(), points.begin()+50);
+ break;
+ default:
+ opoints = points;
+ break;
}
- else if(method == 3)
- {
- opoints = std::vector<Point3f>(points.begin(), points.begin()+50);
- }
- else
- opoints = points;
vector<Point2f> projectedPoints;
projectedPoints.resize(opoints.size());
projectPoints(Mat(opoints), trueRvec, trueTvec, intrinsics, distCoeffs, projectedPoints);
- solvePnP(opoints, projectedPoints, intrinsics, distCoeffs, rvec, tvec,
- false, method);
+ bool isEstimateSuccess = solvePnP(opoints, projectedPoints, intrinsics, distCoeffs, rvec, tvec, false, method);
+ if (isEstimateSuccess == false)
+ {
+ return isEstimateSuccess;
+ }
double rvecDiff = norm(rvec-trueRvec), tvecDiff = norm(tvec-trueTvec);
bool isTestSuccess = rvecDiff < epsilon[method] && tvecDiff < epsilon[method];
double error = rvecDiff > tvecDiff ? rvecDiff : tvecDiff;
if (error > maxError)
+ {
maxError = error;
+ }
return isTestSuccess;
}
};
+class CV_solveP3P_Test : public CV_solvePnPRansac_Test
+{
+ public:
+ CV_solveP3P_Test()
+ {
+ eps[SOLVEPNP_P3P] = 2.0e-4;
+ eps[SOLVEPNP_AP3P] = 1.0e-4;
+ totalTestsCount = 1000;
+ }
+
+ ~CV_solveP3P_Test() {}
+ protected:
+ virtual bool runTest(RNG& rng, int mode, int method, const vector<Point3f>& points, const double* epsilon, double& maxError)
+ {
+ std::vector<Mat> rvecs, tvecs;
+ Mat trueRvec, trueTvec;
+ Mat intrinsics, distCoeffs;
+ generateCameraMatrix(intrinsics, rng);
+ if (mode == 0)
+ distCoeffs = Mat::zeros(4, 1, CV_64FC1);
+ else
+ generateDistCoeffs(distCoeffs, rng);
+ generatePose(trueRvec, trueTvec, rng);
+
+ std::vector<Point3f> opoints;
+ opoints = std::vector<Point3f>(points.begin(), points.begin()+3);
+
+ vector<Point2f> projectedPoints;
+ projectedPoints.resize(opoints.size());
+ projectPoints(Mat(opoints), trueRvec, trueTvec, intrinsics, distCoeffs, projectedPoints);
+
+ int num_of_solutions = solveP3P(opoints, projectedPoints, intrinsics, distCoeffs, rvecs, tvecs, method);
+ if (num_of_solutions != (int) rvecs.size() || num_of_solutions != (int) tvecs.size() || num_of_solutions == 0)
+ return false;
+
+ double min_rvecDiff = DBL_MAX, min_tvecDiff = DBL_MAX;
+ for (unsigned int i = 0; i < rvecs.size(); ++i) {
+ double rvecDiff = norm(rvecs[i]-trueRvec);
+ min_rvecDiff = std::min(rvecDiff, min_rvecDiff);
+ }
+ for (unsigned int i = 0; i < tvecs.size(); ++i) {
+ double tvecDiff = norm(tvecs[i]-trueTvec);
+ min_tvecDiff = std::min(tvecDiff, min_tvecDiff);
+ }
+ bool isTestSuccess = min_rvecDiff < epsilon[method] && min_tvecDiff < epsilon[method];
+
+ double error = std::max(min_rvecDiff, min_tvecDiff);
+ if (error > maxError)
+ maxError = error;
+
+ return isTestSuccess;
+ }
+
+ virtual void run(int)
+ {
+ ts->set_failed_test_info(cvtest::TS::OK);
+
+ vector<Point3f> points, points_dls;
+ points.resize(pointsCount);
+ generate3DPointCloud(points);
+
+ const int methodsCount = 2;
+ int methods[] = {SOLVEPNP_P3P, SOLVEPNP_AP3P};
+ RNG rng = ts->get_rng();
+
+ for (int mode = 0; mode < 2; mode++)
+ {
+ for (int method = 0; method < methodsCount; method++)
+ {
+ double maxError = 0;
+ int successfulTestsCount = 0;
+ for (int testIndex = 0; testIndex < totalTestsCount; testIndex++)
+ {
+ if (runTest(rng, mode, methods[method], points, eps, maxError))
+ successfulTestsCount++;
+ }
+ if (successfulTestsCount < 0.7*totalTestsCount)
+ {
+ ts->printf( cvtest::TS::LOG, "Invalid accuracy for method %d, failed %d tests from %d, maximum error equals %f, distortion mode equals %d\n",
+ method, totalTestsCount - successfulTestsCount, totalTestsCount, maxError, mode);
+ ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
+ }
+ cout << "mode: " << mode << ", method: " << method << " -> "
+ << ((double)successfulTestsCount / totalTestsCount) * 100 << "%"
+ << " (err < " << maxError << ")" << endl;
+ }
+ }
+ }
+};
+
+
+TEST(Calib3d_SolveP3P, accuracy) { CV_solveP3P_Test test; test.safe_run();}
TEST(Calib3d_SolvePnPRansac, accuracy) { CV_solvePnPRansac_Test test; test.safe_run(); }
TEST(Calib3d_SolvePnP, accuracy) { CV_solvePnP_Test test; test.safe_run(); }
diff --git a/modules/calib3d/test/test_stereomatching.cpp b/modules/calib3d/test/test_stereomatching.cpp
index 0aee42a..3806650 100644
--- a/modules/calib3d/test/test_stereomatching.cpp
+++ b/modules/calib3d/test/test_stereomatching.cpp
@@ -784,3 +784,25 @@ protected:
TEST(Calib3d_StereoBM, regression) { CV_StereoBMTest test; test.safe_run(); }
TEST(Calib3d_StereoSGBM, regression) { CV_StereoSGBMTest test; test.safe_run(); }
+
+TEST(Calib3d_StereoSGBM_HH4, regression)
+{
+ String path = cvtest::TS::ptr()->get_data_path() + "cv/stereomatching/datasets/teddy/";
+ Mat leftImg = imread(path + "im2.png", 0);
+ ASSERT_FALSE(leftImg.empty());
+ Mat rightImg = imread(path + "im6.png", 0);
+ ASSERT_FALSE(rightImg.empty());
+ Mat testData = imread(path + "disp2_hh4.png",-1);
+ ASSERT_FALSE(testData.empty());
+ Mat leftDisp;
+ Mat toCheck;
+ {
+ Ptr<StereoSGBM> sgbm = StereoSGBM::create( 0, 48, 3, 90, 360, 1, 63, 10, 100, 32, StereoSGBM::MODE_HH4);
+ sgbm->compute( leftImg, rightImg, leftDisp);
+ CV_Assert( leftDisp.type() == CV_16SC1 );
+ leftDisp.convertTo(toCheck, CV_16UC1,1,16);
+ }
+ Mat diff;
+ absdiff(toCheck, testData,diff);
+ CV_Assert( countNonZero(diff)==0);
+}
diff --git a/modules/calib3d/test/test_undistort_points.cpp b/modules/calib3d/test/test_undistort_points.cpp
index 0eb3552..51600ae 100644
--- a/modules/calib3d/test/test_undistort_points.cpp
+++ b/modules/calib3d/test/test_undistort_points.cpp
@@ -29,16 +29,13 @@ CV_UndistortTest::~CV_UndistortTest() {}
void CV_UndistortTest::generate3DPointCloud(vector<Point3f>& points, Point3f pmin, Point3f pmax)
{
- const Point3f delta = pmax - pmin;
+ RNG rng_Point = ::theRNG(); // fix the seed to use "fixed" input 3D points
for (size_t i = 0; i < points.size(); i++)
{
- Point3f p(float(rand()) / RAND_MAX, float(rand()) / RAND_MAX,
- float(rand()) / RAND_MAX);
- p.x *= delta.x;
- p.y *= delta.y;
- p.z *= delta.z;
- p = p + pmin;
- points[i] = p;
+ float _x = rng_Point.uniform(pmin.x, pmax.x);
+ float _y = rng_Point.uniform(pmin.y, pmax.y);
+ float _z = rng_Point.uniform(pmin.z, pmax.z);
+ points[i] = Point3f(_x, _y, _z);
}
}
void CV_UndistortTest::generateCameraMatrix(Mat& cameraMatrix)
diff --git a/modules/core/CMakeLists.txt b/modules/core/CMakeLists.txt
index 0485a08..9a09851 100644
--- a/modules/core/CMakeLists.txt
+++ b/modules/core/CMakeLists.txt
@@ -1,7 +1,10 @@
set(the_description "The Core Functionality")
+
+ocv_add_dispatched_file(mathfuncs_core SSE2 AVX AVX2)
+ocv_add_dispatched_file(stat SSE4_2 AVX2)
+
ocv_add_module(core
"${OPENCV_HAL_LINKER_LIBS}"
- PRIVATE_REQUIRED ${ZLIB_LIBRARIES} "${OPENCL_LIBRARIES}" "${VA_LIBRARIES}"
OPTIONAL opencv_cudev
WRAP java python)
@@ -19,6 +22,10 @@ if(HAVE_CUDA)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wenum-compare -Wunused-function -Wshadow)
endif()
+if(CV_TRACE AND HAVE_ITT AND BUILD_ITT)
+ add_definitions(-DOPENCV_WITH_ITT=1)
+endif()
+
file(GLOB lib_cuda_hdrs "include/opencv2/${name}/cuda/*.hpp" "include/opencv2/${name}/cuda/*.h")
file(GLOB lib_cuda_hdrs_detail "include/opencv2/${name}/cuda/detail/*.hpp" "include/opencv2/${name}/cuda/detail/*.h")
@@ -31,7 +38,30 @@ ocv_glob_module_sources(SOURCES "${OPENCV_MODULE_opencv_core_BINARY_DIR}/version
HEADERS ${lib_cuda_hdrs} ${lib_cuda_hdrs_detail})
ocv_module_include_directories(${the_module} ${ZLIB_INCLUDE_DIRS} ${OPENCL_INCLUDE_DIRS})
+if(ANDROID AND HAVE_CPUFEATURES)
+ ocv_append_sourge_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/system.cpp "HAVE_CPUFEATURES=1")
+ ocv_module_include_directories(${CPUFEATURES_INCLUDE_DIRS})
+endif()
+if(ITT_INCLUDE_DIRS)
+ ocv_module_include_directories(${ITT_INCLUDE_DIRS})
+endif()
+if(HAVE_POSIX_MEMALIGN)
+ ocv_append_sourge_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/alloc.cpp "HAVE_POSIX_MEMALIGN=1")
+endif()
+if(HAVE_MALLOC_H)
+ ocv_append_sourge_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/alloc.cpp "HAVE_MALLOC_H=1")
+endif()
+if(HAVE_MEMALIGN)
+ ocv_append_sourge_file_compile_definitions(${CMAKE_CURRENT_SOURCE_DIR}/src/alloc.cpp "HAVE_MEMALIGN=1")
+endif()
+
ocv_create_module(${extra_libs})
+ocv_target_link_libraries(${the_module}
+ "${ZLIB_LIBRARIES}" "${OPENCL_LIBRARIES}" "${VA_LIBRARIES}"
+ "${LAPACK_LIBRARIES}" "${CPUFEATURES_LIBRARIES}" "${HALIDE_LIBRARIES}"
+ "${ITT_LIBRARIES}"
+)
+
ocv_add_accuracy_tests()
ocv_add_perf_tests()
diff --git a/modules/core/include/opencv2/core.hpp b/modules/core/include/opencv2/core.hpp
index 6b89c42..31d325c 100644
--- a/modules/core/include/opencv2/core.hpp
+++ b/modules/core/include/opencv2/core.hpp
@@ -114,7 +114,7 @@ public:
*/
Exception();
/*!
- Full constructor. Normally the constuctor is not called explicitly.
+ Full constructor. Normally the constructor is not called explicitly.
Instead, the macros CV_Error(), CV_Error_() and CV_Assert() are used.
*/
Exception(int _code, const String& _err, const String& _func, const String& _file, int _line);
@@ -131,8 +131,8 @@ public:
int code; ///< error code @see CVStatus
String err; ///< error description
String func; ///< function name. Available only when the compiler supports getting it
- String file; ///< source file name where the error has occured
- int line; ///< line number in the source file where the error has occured
+ String file; ///< source file name where the error has occurred
+ int line; ///< line number in the source file where the error has occurred
};
/*! @brief Signals an error and raises the exception.
@@ -273,6 +273,9 @@ of p and len.
*/
CV_EXPORTS_W int borderInterpolate(int p, int len, int borderType);
+/** @example copyMakeBorder_demo.cpp
+An example using copyMakeBorder function
+ */
/** @brief Forms a border around an image.
The function copies the source image into the middle of the destination image. The areas to the
@@ -471,6 +474,9 @@ The function can also be emulated with a matrix expression, for example:
*/
CV_EXPORTS_W void scaleAdd(InputArray src1, double alpha, InputArray src2, OutputArray dst);
+/** @example AddingImagesTrackbar.cpp
+
+ */
/** @brief Calculates the weighted sum of two arrays.
The function addWeighted calculates the weighted sum of two arrays as follows:
@@ -626,7 +632,7 @@ then pass the matrix to calcCovarMatrix .
@param src input array that should have from 1 to 4 channels so that the results can be stored in
Scalar_ 's.
@param mean output parameter: calculated mean value.
- at param stddev output parameter: calculateded standard deviation.
+ at param stddev output parameter: calculated standard deviation.
@param mask optional operation mask.
@sa countNonZero, mean, norm, minMaxLoc, calcCovarMatrix
*/
@@ -1639,7 +1645,7 @@ CV_EXPORTS_W void mulTransposed( InputArray src, OutputArray dst, bool aTa,
The function cv::transpose transposes the matrix src :
\f[\texttt{dst} (i,j) = \texttt{src} (j,i)\f]
- at note No complex conjugation is done in case of a complex matrix. It it
+ at note No complex conjugation is done in case of a complex matrix. It
should be done separately if needed.
@param src input array.
@param dst output array of the same type as src.
@@ -2762,7 +2768,7 @@ public:
double a1 = rng.uniform((double)0, (double)1);
// produces float from [0, 1)
- double b = rng.uniform(0.f, 1.f);
+ float b = rng.uniform(0.f, 1.f);
// produces double from [0, 1)
double c = rng.uniform(0., 1.);
@@ -2778,8 +2784,8 @@ public:
want a floating-point random number, but the range boundaries are
integer numbers, either put dots in the end, if they are constants, or
use explicit type cast operators, as in the a1 initialization above.
- @param a lower inclusive boundary of the returned random numbers.
- @param b upper non-inclusive boundary of the returned random numbers.
+ @param a lower inclusive boundary of the returned random number.
+ @param b upper non-inclusive boundary of the returned random number.
*/
int uniform(int a, int b);
/** @overload */
@@ -2834,6 +2840,8 @@ public:
double gaussian(double sigma);
uint64 state;
+
+ bool operator ==(const RNG& other) const;
};
/** @brief Mersenne Twister random number generator
diff --git a/modules/core/include/opencv2/core/affine.hpp b/modules/core/include/opencv2/core/affine.hpp
index 311ff62..41de5c6 100644
--- a/modules/core/include/opencv2/core/affine.hpp
+++ b/modules/core/include/opencv2/core/affine.hpp
@@ -213,11 +213,13 @@ cv::Affine3<T>::Affine3(const cv::Mat& data, const Vec3& t)
{
rotation(data(Rect(0, 0, 3, 3)));
translation(data(Rect(3, 0, 1, 3)));
- return;
+ }
+ else
+ {
+ rotation(data);
+ translation(t);
}
- rotation(data);
- translation(t);
matrix.val[12] = matrix.val[13] = matrix.val[14] = 0;
matrix.val[15] = 1;
}
diff --git a/modules/core/include/opencv2/core/base.hpp b/modules/core/include/opencv2/core/base.hpp
index 017b484..a445599 100644
--- a/modules/core/include/opencv2/core/base.hpp
+++ b/modules/core/include/opencv2/core/base.hpp
@@ -66,38 +66,38 @@ namespace cv
namespace Error {
//! error codes
enum Code {
- StsOk= 0, //!< everithing is ok
+ StsOk= 0, //!< everything is ok
StsBackTrace= -1, //!< pseudo error for back trace
StsError= -2, //!< unknown /unspecified error
StsInternal= -3, //!< internal error (bad state)
StsNoMem= -4, //!< insufficient memory
StsBadArg= -5, //!< function arg/param is bad
StsBadFunc= -6, //!< unsupported function
- StsNoConv= -7, //!< iter. didn't converge
+ StsNoConv= -7, //!< iteration didn't converge
StsAutoTrace= -8, //!< tracing
HeaderIsNull= -9, //!< image header is NULL
BadImageSize= -10, //!< image size is invalid
BadOffset= -11, //!< offset is invalid
BadDataPtr= -12, //!<
- BadStep= -13, //!<
+ BadStep= -13, //!< image step is wrong, this may happen for a non-continuous matrix.
BadModelOrChSeq= -14, //!<
- BadNumChannels= -15, //!<
+ BadNumChannels= -15, //!< bad number of channels, for example, some functions accept only single channel matrices.
BadNumChannel1U= -16, //!<
- BadDepth= -17, //!<
+ BadDepth= -17, //!< input image depth is not supported by the function
BadAlphaChannel= -18, //!<
- BadOrder= -19, //!<
- BadOrigin= -20, //!<
- BadAlign= -21, //!<
+ BadOrder= -19, //!< number of dimensions is out of range
+ BadOrigin= -20, //!< incorrect input origin
+ BadAlign= -21, //!< incorrect input align
BadCallBack= -22, //!<
BadTileSize= -23, //!<
- BadCOI= -24, //!<
- BadROISize= -25, //!<
+ BadCOI= -24, //!< input COI is not supported
+ BadROISize= -25, //!< incorrect input roi
MaskIsTiled= -26, //!<
StsNullPtr= -27, //!< null pointer
StsVecLengthErr= -28, //!< incorrect vector length
- StsFilterStructContentErr= -29, //!< incorr. filter structure content
- StsKernelStructContentErr= -30, //!< incorr. transform kernel content
- StsFilterOffsetErr= -31, //!< incorrect filter ofset value
+ StsFilterStructContentErr= -29, //!< incorrect filter structure content
+ StsKernelStructContentErr= -30, //!< incorrect transform kernel content
+ StsFilterOffsetErr= -31, //!< incorrect filter offset value
StsBadSize= -201, //!< the input/output structure size is incorrect
StsDivByZero= -202, //!< division by zero
StsInplaceNotSupported= -203, //!< in-place operation is not supported
@@ -113,13 +113,13 @@ enum Code {
StsNotImplemented= -213, //!< the requested function/feature is not implemented
StsBadMemBlock= -214, //!< an allocated block has been corrupted
StsAssert= -215, //!< assertion failed
- GpuNotSupported= -216,
- GpuApiCallError= -217,
- OpenGlNotSupported= -218,
- OpenGlApiCallError= -219,
- OpenCLApiCallError= -220,
+ GpuNotSupported= -216, //!< no CUDA support
+ GpuApiCallError= -217, //!< GPU API call error
+ OpenGlNotSupported= -218, //!< no OpenGL support
+ OpenGlApiCallError= -219, //!< OpenGL API call error
+ OpenCLApiCallError= -220, //!< OpenCL API call error
OpenCLDoubleNotSupported= -221,
- OpenCLInitError= -222,
+ OpenCLInitError= -222, //!< OpenCL initialization error
OpenCLNoAMDBlasFft= -223
};
} //Error
@@ -239,6 +239,10 @@ enum DftFlags {
into a real array and inverse transformation is executed, the function treats the input as a
packed complex-conjugate symmetrical array, and the output will also be a real array). */
DFT_REAL_OUTPUT = 32,
+ /** specifies that input is complex input. If this flag is set, the input must have 2 channels.
+ On the other hand, for backwards compatibility reason, if input has 2 channels, input is
+ already considered complex. */
+ DFT_COMPLEX_INPUT = 64,
/** performs an inverse 1D or 2D transform instead of the default forward transform. */
DCT_INVERSE = DFT_INVERSE,
/** performs a forward or inverse transform of every individual row of the input
@@ -338,8 +342,8 @@ It is possible to alternate error processing by using redirectError().
@param _code - error code (Error::Code)
@param _err - error description
@param _func - function name. Available only when the compiler supports getting it
- at param _file - source file name where the error has occured
- at param _line - line number in the source file where the error has occured
+ at param _file - source file name where the error has occurred
+ at param _line - line number in the source file where the error has occurred
@see CV_Error, CV_Error_, CV_ErrorNoReturn, CV_ErrorNoReturn_, CV_Assert, CV_DbgAssert
*/
CV_EXPORTS void error(int _code, const String& _err, const char* _func, const char* _file, int _line);
@@ -377,6 +381,17 @@ CV_INLINE CV_NORETURN void errorNoReturn(int _code, const String& _err, const ch
#define CV_Func ""
#endif
+#ifdef CV_STATIC_ANALYSIS
+// In practice, some macro are not processed correctly (noreturn is not detected).
+// We need to use simplified definition for them.
+#define CV_Error(...) do { abort(); } while (0)
+#define CV_Error_(...) do { abort(); } while (0)
+#define CV_Assert(cond) do { if (!(cond)) abort(); } while (0)
+#define CV_ErrorNoReturn(...) do { abort(); } while (0)
+#define CV_ErrorNoReturn_(...) do { abort(); } while (0)
+
+#else // CV_STATIC_ANALYSIS
+
/** @brief Call the error handler.
Currently, the error handler prints the error code and the error message to the standard
@@ -417,6 +432,8 @@ configurations while CV_DbgAssert is only retained in the Debug configuration.
/** same as CV_Error_(code,args), but does not return */
#define CV_ErrorNoReturn_( code, args ) cv::errorNoReturn( code, cv::format args, CV_Func, __FILE__, __LINE__ )
+#endif // CV_STATIC_ANALYSIS
+
/** replaced with CV_Assert(expr) in Debug configuration */
#ifdef _DEBUG
# define CV_DbgAssert(expr) CV_Assert(expr)
@@ -667,13 +684,17 @@ namespace cudev
namespace ipp
{
-CV_EXPORTS int getIppFeatures();
-CV_EXPORTS void setIppStatus(int status, const char * const funcname = NULL, const char * const filename = NULL,
+#if OPENCV_ABI_COMPATIBILITY > 300
+CV_EXPORTS unsigned long long getIppFeatures();
+#else
+CV_EXPORTS int getIppFeatures();
+#endif
+CV_EXPORTS void setIppStatus(int status, const char * const funcname = NULL, const char * const filename = NULL,
int line = 0);
-CV_EXPORTS int getIppStatus();
-CV_EXPORTS String getIppErrorLocation();
-CV_EXPORTS bool useIPP();
-CV_EXPORTS void setUseIPP(bool flag);
+CV_EXPORTS int getIppStatus();
+CV_EXPORTS String getIppErrorLocation();
+CV_EXPORTS_W bool useIPP();
+CV_EXPORTS_W void setUseIPP(bool flag);
} // ipp
diff --git a/modules/core/include/opencv2/core/bufferpool.hpp b/modules/core/include/opencv2/core/bufferpool.hpp
index 9e7b7c2..4698e5d 100644
--- a/modules/core/include/opencv2/core/bufferpool.hpp
+++ b/modules/core/include/opencv2/core/bufferpool.hpp
@@ -7,6 +7,11 @@
#ifndef OPENCV_CORE_BUFFER_POOL_HPP
#define OPENCV_CORE_BUFFER_POOL_HPP
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable: 4265)
+#endif
+
namespace cv
{
@@ -28,4 +33,8 @@ public:
}
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
#endif // OPENCV_CORE_BUFFER_POOL_HPP
diff --git a/modules/core/include/opencv2/core/core_c.h b/modules/core/include/opencv2/core/core_c.h
index e12f79d..b992c20 100644
--- a/modules/core/include/opencv2/core/core_c.h
+++ b/modules/core/include/opencv2/core/core_c.h
@@ -2654,7 +2654,7 @@ CVAPI(int) cvGetErrMode( void );
/** Sets error processing mode, returns previously used mode */
CVAPI(int) cvSetErrMode( int mode );
-/** Sets error status and performs some additonal actions (displaying message box,
+/** Sets error status and performs some additional actions (displaying message box,
writing message to stderr, terminating application etc.)
depending on the current error mode */
CVAPI(void) cvError( int status, const char* func_name,
@@ -2663,7 +2663,7 @@ CVAPI(void) cvError( int status, const char* func_name,
/** Retrieves textual description of the error given its code */
CVAPI(const char*) cvErrorStr( int status );
-/** Retrieves detailed information about the last error occured */
+/** Retrieves detailed information about the last error occurred */
CVAPI(int) cvGetErrInfo( const char** errcode_desc, const char** description,
const char** filename, int* line );
diff --git a/modules/core/include/opencv2/core/cuda.hpp b/modules/core/include/opencv2/core/cuda.hpp
index c538392..6dca272 100644
--- a/modules/core/include/opencv2/core/cuda.hpp
+++ b/modules/core/include/opencv2/core/cuda.hpp
@@ -327,6 +327,34 @@ The function does not reallocate memory if the matrix has proper attributes alre
*/
CV_EXPORTS void ensureSizeIsEnough(int rows, int cols, int type, OutputArray arr);
+/** @brief BufferPool for use with CUDA streams
+
+ * BufferPool utilizes cuda::Stream's allocator to create new buffers. It is
+ * particularly useful when BufferPoolUsage is set to true, or a custom
+ * allocator is specified for the cuda::Stream, and you want to implement your
+ * own stream based functions utilizing the same underlying GPU memory
+ * management.
+ */
+class CV_EXPORTS BufferPool
+{
+public:
+
+ //! Gets the BufferPool for the given stream.
+ explicit BufferPool(Stream& stream);
+
+ //! Allocates a new GpuMat of given size and type.
+ GpuMat getBuffer(int rows, int cols, int type);
+
+ //! Allocates a new GpuMat of given size and type.
+ GpuMat getBuffer(Size size, int type) { return getBuffer(size.height, size.width, type); }
+
+ //! Returns the allocator associated with the stream.
+ Ptr<GpuMat::Allocator> getAllocator() const { return allocator_; }
+
+private:
+ Ptr<GpuMat::Allocator> allocator_;
+};
+
//! BufferPool management (must be called before Stream creation)
CV_EXPORTS void setBufferPoolUsage(bool on);
CV_EXPORTS void setBufferPoolConfig(int deviceId, size_t stackSize, int stackCount);
@@ -479,6 +507,9 @@ public:
//! creates a new asynchronous stream
Stream();
+ //! creates a new asynchronous stream with custom allocator
+ Stream(const Ptr<GpuMat::Allocator>& allocator);
+
/** @brief Returns true if the current stream queue is finished. Otherwise, it returns false.
*/
bool queryIfComplete() const;
@@ -564,7 +595,8 @@ private:
/** @brief Returns the number of installed CUDA-enabled devices.
Use this function before any other CUDA functions calls. If OpenCV is compiled without CUDA support,
-this function returns 0.
+this function returns 0. If the CUDA driver is not installed, or is incompatible, this function
+returns -1.
*/
CV_EXPORTS int getCudaEnabledDeviceCount();
diff --git a/modules/core/include/opencv2/core/cuda/warp.hpp b/modules/core/include/opencv2/core/cuda/warp.hpp
index ae1f8ea..8af7e6a 100644
--- a/modules/core/include/opencv2/core/cuda/warp.hpp
+++ b/modules/core/include/opencv2/core/cuda/warp.hpp
@@ -64,7 +64,7 @@ namespace cv { namespace cuda { namespace device
static __device__ __forceinline__ unsigned int laneId()
{
unsigned int ret;
- asm("mov.u32 %0, %laneid;" : "=r"(ret) );
+ asm("mov.u32 %0, %%laneid;" : "=r"(ret) );
return ret;
}
diff --git a/modules/core/include/opencv2/core/cv_cpu_dispatch.h b/modules/core/include/opencv2/core/cv_cpu_dispatch.h
new file mode 100644
index 0000000..5de35bc
--- /dev/null
+++ b/modules/core/include/opencv2/core/cv_cpu_dispatch.h
@@ -0,0 +1,210 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#if defined __OPENCV_BUILD \
+
+#include "cv_cpu_config.h"
+#include "cv_cpu_helper.h"
+
+#ifdef CV_CPU_DISPATCH_MODE
+#define CV_CPU_OPTIMIZATION_NAMESPACE __CV_CAT(opt_, CV_CPU_DISPATCH_MODE)
+#define CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN namespace __CV_CAT(opt_, CV_CPU_DISPATCH_MODE) {
+#define CV_CPU_OPTIMIZATION_NAMESPACE_END }
+#else
+#define CV_CPU_OPTIMIZATION_NAMESPACE cpu_baseline
+#define CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN namespace cpu_baseline {
+#define CV_CPU_OPTIMIZATION_NAMESPACE_END }
+#endif
+
+
+#define __CV_CPU_DISPATCH_CHAIN_END(fn, args, mode, ...) /* done */
+#define __CV_CPU_DISPATCH(fn, args, mode, ...) __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
+#define __CV_CPU_DISPATCH_EXPAND(fn, args, ...) __CV_EXPAND(__CV_CPU_DISPATCH(fn, args, __VA_ARGS__))
+#define CV_CPU_DISPATCH(fn, args, ...) __CV_CPU_DISPATCH_EXPAND(fn, args, __VA_ARGS__, END) // expand macros
+
+
+#if defined CV_ENABLE_INTRINSICS \
+ && !defined CV_DISABLE_OPTIMIZATION \
+ && !defined __CUDACC__ /* do not include SSE/AVX/NEON headers for NVCC compiler */ \
+
+#ifdef CV_CPU_COMPILE_SSE2
+# include <emmintrin.h>
+# define CV_MMX 1
+# define CV_SSE 1
+# define CV_SSE2 1
+#endif
+#ifdef CV_CPU_COMPILE_SSE3
+# include <pmmintrin.h>
+# define CV_SSE3 1
+#endif
+#ifdef CV_CPU_COMPILE_SSSE3
+# include <tmmintrin.h>
+# define CV_SSSE3 1
+#endif
+#ifdef CV_CPU_COMPILE_SSE4_1
+# include <smmintrin.h>
+# define CV_SSE4_1 1
+#endif
+#ifdef CV_CPU_COMPILE_SSE4_2
+# include <nmmintrin.h>
+# define CV_SSE4_2 1
+#endif
+#ifdef CV_CPU_COMPILE_POPCNT
+# ifdef _MSC_VER
+# include <nmmintrin.h>
+# if defined(_M_X64)
+# define CV_POPCNT_U64 _mm_popcnt_u64
+# endif
+# define CV_POPCNT_U32 _mm_popcnt_u32
+# else
+# include <popcntintrin.h>
+# if defined(__x86_64__)
+# define CV_POPCNT_U64 __builtin_popcountll
+# endif
+# define CV_POPCNT_U32 __builtin_popcount
+# endif
+# define CV_POPCNT 1
+#endif
+#ifdef CV_CPU_COMPILE_AVX
+# include <immintrin.h>
+# define CV_AVX 1
+#endif
+#ifdef CV_CPU_COMPILE_FP16
+# if defined(__arm__) || defined(__aarch64__) || defined(_M_ARM)
+# include <arm_neon.h>
+# else
+# include <immintrin.h>
+# endif
+# define CV_FP16 1
+#endif
+#ifdef CV_CPU_COMPILE_AVX2
+# include <immintrin.h>
+# define CV_AVX2 1
+#endif
+#ifdef CV_CPU_COMPILE_FMA3
+# define CV_FMA3 1
+#endif
+
+#if defined _WIN32 && defined(_M_ARM)
+# include <Intrin.h>
+# include <arm_neon.h>
+# define CV_NEON 1
+#elif defined(__ARM_NEON__) || (defined (__ARM_NEON) && defined(__aarch64__))
+# include <arm_neon.h>
+# define CV_NEON 1
+#endif
+
+#if defined(__ARM_NEON__) || defined(__aarch64__)
+# include <arm_neon.h>
+#endif
+
+#endif // CV_ENABLE_INTRINSICS && !CV_DISABLE_OPTIMIZATION && !__CUDACC__
+
+#if defined CV_CPU_COMPILE_AVX && !defined CV_CPU_BASELINE_COMPILE_AVX
+struct VZeroUpperGuard {
+#ifdef __GNUC__
+ __attribute__((always_inline))
+#endif
+ inline ~VZeroUpperGuard() { _mm256_zeroupper(); }
+};
+#define __CV_AVX_GUARD VZeroUpperGuard __vzeroupper_guard; (void)__vzeroupper_guard;
+#endif
+
+#ifdef __CV_AVX_GUARD
+#define CV_AVX_GUARD __CV_AVX_GUARD
+#else
+#define CV_AVX_GUARD
+#endif
+
+#endif // __OPENCV_BUILD
+
+
+
+#if !defined __OPENCV_BUILD /* Compatibility code */ \
+ && !defined __CUDACC__ /* do not include SSE/AVX/NEON headers for NVCC compiler */
+#if defined __SSE2__ || defined _M_X64 || (defined _M_IX86_FP && _M_IX86_FP >= 2)
+# include <emmintrin.h>
+# define CV_MMX 1
+# define CV_SSE 1
+# define CV_SSE2 1
+#elif defined _WIN32 && defined(_M_ARM)
+# include <Intrin.h>
+# include <arm_neon.h>
+# define CV_NEON 1
+#elif defined(__ARM_NEON__) || (defined (__ARM_NEON) && defined(__aarch64__))
+# include <arm_neon.h>
+# define CV_NEON 1
+#endif
+
+#endif // !__OPENCV_BUILD && !__CUDACC (Compatibility code)
+
+
+
+#ifndef CV_MMX
+# define CV_MMX 0
+#endif
+#ifndef CV_SSE
+# define CV_SSE 0
+#endif
+#ifndef CV_SSE2
+# define CV_SSE2 0
+#endif
+#ifndef CV_SSE3
+# define CV_SSE3 0
+#endif
+#ifndef CV_SSSE3
+# define CV_SSSE3 0
+#endif
+#ifndef CV_SSE4_1
+# define CV_SSE4_1 0
+#endif
+#ifndef CV_SSE4_2
+# define CV_SSE4_2 0
+#endif
+#ifndef CV_POPCNT
+# define CV_POPCNT 0
+#endif
+#ifndef CV_AVX
+# define CV_AVX 0
+#endif
+#ifndef CV_FP16
+# define CV_FP16 0
+#endif
+#ifndef CV_AVX2
+# define CV_AVX2 0
+#endif
+#ifndef CV_FMA3
+# define CV_FMA3 0
+#endif
+#ifndef CV_AVX_512F
+# define CV_AVX_512F 0
+#endif
+#ifndef CV_AVX_512BW
+# define CV_AVX_512BW 0
+#endif
+#ifndef CV_AVX_512CD
+# define CV_AVX_512CD 0
+#endif
+#ifndef CV_AVX_512DQ
+# define CV_AVX_512DQ 0
+#endif
+#ifndef CV_AVX_512ER
+# define CV_AVX_512ER 0
+#endif
+#ifndef CV_AVX_512IFMA512
+# define CV_AVX_512IFMA512 0
+#endif
+#ifndef CV_AVX_512PF
+# define CV_AVX_512PF 0
+#endif
+#ifndef CV_AVX_512VBMI
+# define CV_AVX_512VBMI 0
+#endif
+#ifndef CV_AVX_512VL
+# define CV_AVX_512VL 0
+#endif
+
+#ifndef CV_NEON
+# define CV_NEON 0
+#endif
diff --git a/modules/core/include/opencv2/core/cv_cpu_helper.h b/modules/core/include/opencv2/core/cv_cpu_helper.h
new file mode 100644
index 0000000..6eaed9e
--- /dev/null
+++ b/modules/core/include/opencv2/core/cv_cpu_helper.h
@@ -0,0 +1,184 @@
+// AUTOGENERATED, DO NOT EDIT
+
+#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE
+# define CV_TRY_SSE 1
+# define CV_CPU_HAS_SUPPORT_SSE 1
+# define CV_CPU_CALL_SSE(fn, args) return (opt_SSE::fn args)
+#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE
+# define CV_TRY_SSE 1
+# define CV_CPU_HAS_SUPPORT_SSE (cv::checkHardwareSupport(CV_CPU_SSE))
+# define CV_CPU_CALL_SSE(fn, args) if (CV_CPU_HAS_SUPPORT_SSE) return (opt_SSE::fn args)
+#else
+# define CV_TRY_SSE 0
+# define CV_CPU_HAS_SUPPORT_SSE 0
+# define CV_CPU_CALL_SSE(fn, args)
+#endif
+#define __CV_CPU_DISPATCH_CHAIN_SSE(fn, args, mode, ...) CV_CPU_CALL_SSE(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
+
+#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE2
+# define CV_TRY_SSE2 1
+# define CV_CPU_HAS_SUPPORT_SSE2 1
+# define CV_CPU_CALL_SSE2(fn, args) return (opt_SSE2::fn args)
+#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE2
+# define CV_TRY_SSE2 1
+# define CV_CPU_HAS_SUPPORT_SSE2 (cv::checkHardwareSupport(CV_CPU_SSE2))
+# define CV_CPU_CALL_SSE2(fn, args) if (CV_CPU_HAS_SUPPORT_SSE2) return (opt_SSE2::fn args)
+#else
+# define CV_TRY_SSE2 0
+# define CV_CPU_HAS_SUPPORT_SSE2 0
+# define CV_CPU_CALL_SSE2(fn, args)
+#endif
+#define __CV_CPU_DISPATCH_CHAIN_SSE2(fn, args, mode, ...) CV_CPU_CALL_SSE2(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
+
+#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE3
+# define CV_TRY_SSE3 1
+# define CV_CPU_HAS_SUPPORT_SSE3 1
+# define CV_CPU_CALL_SSE3(fn, args) return (opt_SSE3::fn args)
+#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE3
+# define CV_TRY_SSE3 1
+# define CV_CPU_HAS_SUPPORT_SSE3 (cv::checkHardwareSupport(CV_CPU_SSE3))
+# define CV_CPU_CALL_SSE3(fn, args) if (CV_CPU_HAS_SUPPORT_SSE3) return (opt_SSE3::fn args)
+#else
+# define CV_TRY_SSE3 0
+# define CV_CPU_HAS_SUPPORT_SSE3 0
+# define CV_CPU_CALL_SSE3(fn, args)
+#endif
+#define __CV_CPU_DISPATCH_CHAIN_SSE3(fn, args, mode, ...) CV_CPU_CALL_SSE3(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
+
+#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSSE3
+# define CV_TRY_SSSE3 1
+# define CV_CPU_HAS_SUPPORT_SSSE3 1
+# define CV_CPU_CALL_SSSE3(fn, args) return (opt_SSSE3::fn args)
+#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSSE3
+# define CV_TRY_SSSE3 1
+# define CV_CPU_HAS_SUPPORT_SSSE3 (cv::checkHardwareSupport(CV_CPU_SSSE3))
+# define CV_CPU_CALL_SSSE3(fn, args) if (CV_CPU_HAS_SUPPORT_SSSE3) return (opt_SSSE3::fn args)
+#else
+# define CV_TRY_SSSE3 0
+# define CV_CPU_HAS_SUPPORT_SSSE3 0
+# define CV_CPU_CALL_SSSE3(fn, args)
+#endif
+#define __CV_CPU_DISPATCH_CHAIN_SSSE3(fn, args, mode, ...) CV_CPU_CALL_SSSE3(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
+
+#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE4_1
+# define CV_TRY_SSE4_1 1
+# define CV_CPU_HAS_SUPPORT_SSE4_1 1
+# define CV_CPU_CALL_SSE4_1(fn, args) return (opt_SSE4_1::fn args)
+#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE4_1
+# define CV_TRY_SSE4_1 1
+# define CV_CPU_HAS_SUPPORT_SSE4_1 (cv::checkHardwareSupport(CV_CPU_SSE4_1))
+# define CV_CPU_CALL_SSE4_1(fn, args) if (CV_CPU_HAS_SUPPORT_SSE4_1) return (opt_SSE4_1::fn args)
+#else
+# define CV_TRY_SSE4_1 0
+# define CV_CPU_HAS_SUPPORT_SSE4_1 0
+# define CV_CPU_CALL_SSE4_1(fn, args)
+#endif
+#define __CV_CPU_DISPATCH_CHAIN_SSE4_1(fn, args, mode, ...) CV_CPU_CALL_SSE4_1(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
+
+#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE4_2
+# define CV_TRY_SSE4_2 1
+# define CV_CPU_HAS_SUPPORT_SSE4_2 1
+# define CV_CPU_CALL_SSE4_2(fn, args) return (opt_SSE4_2::fn args)
+#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE4_2
+# define CV_TRY_SSE4_2 1
+# define CV_CPU_HAS_SUPPORT_SSE4_2 (cv::checkHardwareSupport(CV_CPU_SSE4_2))
+# define CV_CPU_CALL_SSE4_2(fn, args) if (CV_CPU_HAS_SUPPORT_SSE4_2) return (opt_SSE4_2::fn args)
+#else
+# define CV_TRY_SSE4_2 0
+# define CV_CPU_HAS_SUPPORT_SSE4_2 0
+# define CV_CPU_CALL_SSE4_2(fn, args)
+#endif
+#define __CV_CPU_DISPATCH_CHAIN_SSE4_2(fn, args, mode, ...) CV_CPU_CALL_SSE4_2(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
+
+#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_POPCNT
+# define CV_TRY_POPCNT 1
+# define CV_CPU_HAS_SUPPORT_POPCNT 1
+# define CV_CPU_CALL_POPCNT(fn, args) return (opt_POPCNT::fn args)
+#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_POPCNT
+# define CV_TRY_POPCNT 1
+# define CV_CPU_HAS_SUPPORT_POPCNT (cv::checkHardwareSupport(CV_CPU_POPCNT))
+# define CV_CPU_CALL_POPCNT(fn, args) if (CV_CPU_HAS_SUPPORT_POPCNT) return (opt_POPCNT::fn args)
+#else
+# define CV_TRY_POPCNT 0
+# define CV_CPU_HAS_SUPPORT_POPCNT 0
+# define CV_CPU_CALL_POPCNT(fn, args)
+#endif
+#define __CV_CPU_DISPATCH_CHAIN_POPCNT(fn, args, mode, ...) CV_CPU_CALL_POPCNT(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
+
+#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX
+# define CV_TRY_AVX 1
+# define CV_CPU_HAS_SUPPORT_AVX 1
+# define CV_CPU_CALL_AVX(fn, args) return (opt_AVX::fn args)
+#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX
+# define CV_TRY_AVX 1
+# define CV_CPU_HAS_SUPPORT_AVX (cv::checkHardwareSupport(CV_CPU_AVX))
+# define CV_CPU_CALL_AVX(fn, args) if (CV_CPU_HAS_SUPPORT_AVX) return (opt_AVX::fn args)
+#else
+# define CV_TRY_AVX 0
+# define CV_CPU_HAS_SUPPORT_AVX 0
+# define CV_CPU_CALL_AVX(fn, args)
+#endif
+#define __CV_CPU_DISPATCH_CHAIN_AVX(fn, args, mode, ...) CV_CPU_CALL_AVX(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
+
+#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_FP16
+# define CV_TRY_FP16 1
+# define CV_CPU_HAS_SUPPORT_FP16 1
+# define CV_CPU_CALL_FP16(fn, args) return (opt_FP16::fn args)
+#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_FP16
+# define CV_TRY_FP16 1
+# define CV_CPU_HAS_SUPPORT_FP16 (cv::checkHardwareSupport(CV_CPU_FP16))
+# define CV_CPU_CALL_FP16(fn, args) if (CV_CPU_HAS_SUPPORT_FP16) return (opt_FP16::fn args)
+#else
+# define CV_TRY_FP16 0
+# define CV_CPU_HAS_SUPPORT_FP16 0
+# define CV_CPU_CALL_FP16(fn, args)
+#endif
+#define __CV_CPU_DISPATCH_CHAIN_FP16(fn, args, mode, ...) CV_CPU_CALL_FP16(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
+
+#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX2
+# define CV_TRY_AVX2 1
+# define CV_CPU_HAS_SUPPORT_AVX2 1
+# define CV_CPU_CALL_AVX2(fn, args) return (opt_AVX2::fn args)
+#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX2
+# define CV_TRY_AVX2 1
+# define CV_CPU_HAS_SUPPORT_AVX2 (cv::checkHardwareSupport(CV_CPU_AVX2))
+# define CV_CPU_CALL_AVX2(fn, args) if (CV_CPU_HAS_SUPPORT_AVX2) return (opt_AVX2::fn args)
+#else
+# define CV_TRY_AVX2 0
+# define CV_CPU_HAS_SUPPORT_AVX2 0
+# define CV_CPU_CALL_AVX2(fn, args)
+#endif
+#define __CV_CPU_DISPATCH_CHAIN_AVX2(fn, args, mode, ...) CV_CPU_CALL_AVX2(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
+
+#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_FMA3
+# define CV_TRY_FMA3 1
+# define CV_CPU_HAS_SUPPORT_FMA3 1
+# define CV_CPU_CALL_FMA3(fn, args) return (opt_FMA3::fn args)
+#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_FMA3
+# define CV_TRY_FMA3 1
+# define CV_CPU_HAS_SUPPORT_FMA3 (cv::checkHardwareSupport(CV_CPU_FMA3))
+# define CV_CPU_CALL_FMA3(fn, args) if (CV_CPU_HAS_SUPPORT_FMA3) return (opt_FMA3::fn args)
+#else
+# define CV_TRY_FMA3 0
+# define CV_CPU_HAS_SUPPORT_FMA3 0
+# define CV_CPU_CALL_FMA3(fn, args)
+#endif
+#define __CV_CPU_DISPATCH_CHAIN_FMA3(fn, args, mode, ...) CV_CPU_CALL_FMA3(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
+
+#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_NEON
+# define CV_TRY_NEON 1
+# define CV_CPU_HAS_SUPPORT_NEON 1
+# define CV_CPU_CALL_NEON(fn, args) return (opt_NEON::fn args)
+#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_NEON
+# define CV_TRY_NEON 1
+# define CV_CPU_HAS_SUPPORT_NEON (cv::checkHardwareSupport(CV_CPU_NEON))
+# define CV_CPU_CALL_NEON(fn, args) if (CV_CPU_HAS_SUPPORT_NEON) return (opt_NEON::fn args)
+#else
+# define CV_TRY_NEON 0
+# define CV_CPU_HAS_SUPPORT_NEON 0
+# define CV_CPU_CALL_NEON(fn, args)
+#endif
+#define __CV_CPU_DISPATCH_CHAIN_NEON(fn, args, mode, ...) CV_CPU_CALL_NEON(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
+
+#define CV_CPU_CALL_BASELINE(fn, args) return (cpu_baseline::fn args)
+#define __CV_CPU_DISPATCH_CHAIN_BASELINE(fn, args, mode, ...) CV_CPU_CALL_BASELINE(fn, args) /* last in sequence */
diff --git a/modules/core/include/opencv2/core/cvdef.h b/modules/core/include/opencv2/core/cvdef.h
index 699b166..70bbf93 100644
--- a/modules/core/include/opencv2/core/cvdef.h
+++ b/modules/core/include/opencv2/core/cvdef.h
@@ -48,10 +48,38 @@
//! @addtogroup core_utils
//! @{
-#if !defined _CRT_SECURE_NO_DEPRECATE && defined _MSC_VER && _MSC_VER > 1300
-# define _CRT_SECURE_NO_DEPRECATE /* to avoid multiple Visual Studio warnings */
+#if !defined CV_DOXYGEN && !defined CV_IGNORE_DEBUG_BUILD_GUARD
+#if (defined(_MSC_VER) && (defined(DEBUG) || defined(_DEBUG))) || \
+ (defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_DEBUG_PEDANTIC))
+// Guard to prevent using of binary incompatible binaries / runtimes
+// https://github.com/opencv/opencv/pull/9161
+#define CV__DEBUG_NS_BEGIN namespace debug_build_guard {
+#define CV__DEBUG_NS_END }
+namespace cv { namespace debug_build_guard { } using namespace debug_build_guard; }
+#endif
+#endif
+
+#ifndef CV__DEBUG_NS_BEGIN
+#define CV__DEBUG_NS_BEGIN
+#define CV__DEBUG_NS_END
+#endif
+
+
+#ifdef __OPENCV_BUILD
+#include "cvconfig.h"
+#endif
+
+#ifndef __CV_EXPAND
+#define __CV_EXPAND(x) x
+#endif
+
+#ifndef __CV_CAT
+#define __CV_CAT__(x, y) x ## y
+#define __CV_CAT_(x, y) __CV_CAT__(x, y)
+#define __CV_CAT(x, y) __CV_CAT_(x, y)
#endif
+
// undef problematic defines sometimes defined by system headers (windows.h in particular)
#undef small
#undef min
@@ -59,10 +87,6 @@
#undef abs
#undef Complex
-#if !defined _CRT_SECURE_NO_DEPRECATE && defined _MSC_VER && _MSC_VER > 1300
-# define _CRT_SECURE_NO_DEPRECATE /* to avoid multiple Visual Studio warnings */
-#endif
-
#include <limits.h>
#include "opencv2/core/hal/interface.h"
@@ -88,7 +112,7 @@
# endif
#endif
-#if defined CV_ICC && !defined CV_ENABLE_UNROLLED
+#if defined CV_DISABLE_OPTIMIZATION || (defined CV_ICC && !defined CV_ENABLE_UNROLLED)
# define CV_ENABLE_UNROLLED 0
#else
# define CV_ENABLE_UNROLLED 1
@@ -161,146 +185,13 @@ enum CpuFeatures {
CPU_NEON = 100
};
-// do not include SSE/AVX/NEON headers for NVCC compiler
-#ifndef __CUDACC__
-
-#if defined __SSE2__ || defined _M_X64 || (defined _M_IX86_FP && _M_IX86_FP >= 2)
-# include <emmintrin.h>
-# define CV_MMX 1
-# define CV_SSE 1
-# define CV_SSE2 1
-# if defined __SSE3__ || (defined _MSC_VER && _MSC_VER >= 1500)
-# include <pmmintrin.h>
-# define CV_SSE3 1
-# endif
-# if defined __SSSE3__ || (defined _MSC_VER && _MSC_VER >= 1500)
-# include <tmmintrin.h>
-# define CV_SSSE3 1
-# endif
-# if defined __SSE4_1__ || (defined _MSC_VER && _MSC_VER >= 1500)
-# include <smmintrin.h>
-# define CV_SSE4_1 1
-# endif
-# if defined __SSE4_2__ || (defined _MSC_VER && _MSC_VER >= 1500)
-# include <nmmintrin.h>
-# define CV_SSE4_2 1
-# endif
-# if defined __POPCNT__ || (defined _MSC_VER && _MSC_VER >= 1500)
-# ifdef _MSC_VER
-# include <nmmintrin.h>
-# else
-# include <popcntintrin.h>
-# endif
-# define CV_POPCNT 1
-# endif
-# if defined __AVX__ || (defined _MSC_VER && _MSC_VER >= 1600 && 0)
-// MS Visual Studio 2010 (2012?) has no macro pre-defined to identify the use of /arch:AVX
-// See: http://connect.microsoft.com/VisualStudio/feedback/details/605858/arch-avx-should-define-a-predefined-macro-in-x64-and-set-a-unique-value-for-m-ix86-fp-in-win32
-# include <immintrin.h>
-# define CV_AVX 1
-# if defined(_XCR_XFEATURE_ENABLED_MASK)
-# define __xgetbv() _xgetbv(_XCR_XFEATURE_ENABLED_MASK)
-# else
-# define __xgetbv() 0
-# endif
-# endif
-# if defined __AVX2__ || (defined _MSC_VER && _MSC_VER >= 1800 && 0)
-# include <immintrin.h>
-# define CV_AVX2 1
-# if defined __FMA__
-# define CV_FMA3 1
-# endif
-# endif
-#endif
-#if (defined WIN32 || defined _WIN32) && defined(_M_ARM)
-# include <Intrin.h>
-# include <arm_neon.h>
-# define CV_NEON 1
-# define CPU_HAS_NEON_FEATURE (true)
-#elif defined(__ARM_NEON__) || (defined (__ARM_NEON) && defined(__aarch64__))
-# include <arm_neon.h>
-# define CV_NEON 1
-#endif
+#include "cv_cpu_dispatch.h"
-#if defined __GNUC__ && defined __arm__ && (defined __ARM_PCS_VFP || defined __ARM_VFPV3__ || defined __ARM_NEON__) && !defined __SOFTFP__
-# define CV_VFP 1
-#endif
-
-#endif // __CUDACC__
-
-#ifndef CV_POPCNT
-#define CV_POPCNT 0
-#endif
-#ifndef CV_MMX
-# define CV_MMX 0
-#endif
-#ifndef CV_SSE
-# define CV_SSE 0
-#endif
-#ifndef CV_SSE2
-# define CV_SSE2 0
-#endif
-#ifndef CV_SSE3
-# define CV_SSE3 0
-#endif
-#ifndef CV_SSSE3
-# define CV_SSSE3 0
-#endif
-#ifndef CV_SSE4_1
-# define CV_SSE4_1 0
-#endif
-#ifndef CV_SSE4_2
-# define CV_SSE4_2 0
-#endif
-#ifndef CV_AVX
-# define CV_AVX 0
-#endif
-#ifndef CV_AVX2
-# define CV_AVX2 0
-#endif
-#ifndef CV_FMA3
-# define CV_FMA3 0
-#endif
-#ifndef CV_AVX_512F
-# define CV_AVX_512F 0
-#endif
-#ifndef CV_AVX_512BW
-# define CV_AVX_512BW 0
-#endif
-#ifndef CV_AVX_512CD
-# define CV_AVX_512CD 0
-#endif
-#ifndef CV_AVX_512DQ
-# define CV_AVX_512DQ 0
-#endif
-#ifndef CV_AVX_512ER
-# define CV_AVX_512ER 0
-#endif
-#ifndef CV_AVX_512IFMA512
-# define CV_AVX_512IFMA512 0
-#endif
-#ifndef CV_AVX_512PF
-# define CV_AVX_512PF 0
-#endif
-#ifndef CV_AVX_512VBMI
-# define CV_AVX_512VBMI 0
-#endif
-#ifndef CV_AVX_512VL
-# define CV_AVX_512VL 0
-#endif
-
-#ifndef CV_NEON
-# define CV_NEON 0
-#endif
-
-#ifndef CV_VFP
-# define CV_VFP 0
-#endif
/* fundamental constants */
#define CV_PI 3.1415926535897932384626433832795
-#define CV_2PI 6.283185307179586476925286766559
+#define CV_2PI 6.283185307179586476925286766559
#define CV_LOG2 0.69314718055994530941723212145818
#if defined __ARM_FP16_FORMAT_IEEE \
@@ -353,7 +244,7 @@ Cv64suf;
# define DISABLE_OPENCV_24_COMPATIBILITY
#endif
-#if (defined WIN32 || defined _WIN32 || defined WINCE || defined __CYGWIN__) && defined CVAPI_EXPORTS
+#if (defined _WIN32 || defined WINCE || defined __CYGWIN__) && defined CVAPI_EXPORTS
# define CV_EXPORTS __declspec(dllexport)
#elif defined __GNUC__ && __GNUC__ >= 4
# define CV_EXPORTS __attribute__ ((visibility ("default")))
@@ -361,6 +252,16 @@ Cv64suf;
# define CV_EXPORTS
#endif
+#ifndef CV_DEPRECATED
+# if defined(__GNUC__)
+# define CV_DEPRECATED __attribute__ ((deprecated))
+# elif defined(_MSC_VER)
+# define CV_DEPRECATED __declspec(deprecated)
+# else
+# define CV_DEPRECATED
+# endif
+#endif
+
#ifndef CV_EXTERN_C
# ifdef __cplusplus
# define CV_EXTERN_C extern "C"
@@ -398,7 +299,7 @@ Cv64suf;
#define CV_IS_SUBMAT(flags) ((flags) & CV_MAT_SUBMAT_FLAG)
/** Size of each channel item,
- 0x124489 = 1000 0100 0100 0010 0010 0001 0001 ~ array of sizeof(arr_type_elem) */
+ 0x8442211 = 1000 0100 0100 0010 0010 0001 0001 ~ array of sizeof(arr_type_elem) */
#define CV_ELEM_SIZE1(type) \
((((sizeof(size_t)<<28)|0x8442211) >> CV_MAT_DEPTH(type)*4) & 15)
@@ -415,12 +316,35 @@ Cv64suf;
#endif
/****************************************************************************************\
+* static analysys *
+\****************************************************************************************/
+
+// In practice, some macro are not processed correctly (noreturn is not detected).
+// We need to use simplified definition for them.
+#ifndef CV_STATIC_ANALYSIS
+# if defined(__KLOCWORK__) || defined(__clang_analyzer__) || defined(__COVERITY__)
+# define CV_STATIC_ANALYSIS
+# endif
+#endif
+
+/****************************************************************************************\
+* Thread sanitizer *
+\****************************************************************************************/
+#ifndef CV_THREAD_SANITIZER
+# if defined(__has_feature)
+# if __has_feature(thread_sanitizer)
+# define CV_THREAD_SANITIZER
+# endif
+# endif
+#endif
+
+/****************************************************************************************\
* exchange-add operation for atomic operations on reference counters *
\****************************************************************************************/
#ifdef CV_XADD
// allow to use user-defined macro
-#elif defined __GNUC__
+#elif defined __GNUC__ || defined __clang__
# if defined __clang__ && __clang_major__ >= 3 && !defined __ANDROID__ && !defined __EMSCRIPTEN__ && !defined(__CUDACC__)
# ifdef __ATOMIC_ACQ_REL
# define CV_XADD(addr, delta) __c11_atomic_fetch_add((_Atomic(int)*)(addr), delta, __ATOMIC_ACQ_REL)
@@ -459,11 +383,25 @@ Cv64suf;
/****************************************************************************************\
+* C++ 11 *
+\****************************************************************************************/
+#ifndef CV_CXX11
+# if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
+# define CV_CXX11 1
+# endif
+#else
+# if CV_CXX11 == 0
+# undef CV_CXX11
+# endif
+#endif
+
+
+/****************************************************************************************\
* C++ Move semantics *
\****************************************************************************************/
#ifndef CV_CXX_MOVE_SEMANTICS
-# if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(_MSC_VER) && _MSC_VER >= 1600
+# if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(_MSC_VER) && _MSC_VER >= 1600)
# define CV_CXX_MOVE_SEMANTICS 1
# elif defined(__clang)
# if __has_feature(cxx_rvalue_references)
@@ -476,6 +414,21 @@ Cv64suf;
# endif
#endif
+/****************************************************************************************\
+* C++11 std::array *
+\****************************************************************************************/
+
+#ifndef CV_CXX_STD_ARRAY
+# if __cplusplus >= 201103L
+# define CV_CXX_STD_ARRAY 1
+# include <array>
+# endif
+#else
+# if CV_CXX_STD_ARRAY == 0
+# undef CV_CXX_STD_ARRAY
+# endif
+#endif
+
//! @}
#endif // OPENCV_CORE_CVDEF_H
diff --git a/modules/core/include/opencv2/core/cvstd.hpp b/modules/core/include/opencv2/core/cvstd.hpp
index 2d40bd0..ddb53e5 100644
--- a/modules/core/include/opencv2/core/cvstd.hpp
+++ b/modules/core/include/opencv2/core/cvstd.hpp
@@ -49,17 +49,13 @@
#endif
#include "opencv2/core/cvdef.h"
-
#include <cstddef>
#include <cstring>
#include <cctype>
-#ifndef OPENCV_NOSTL
-# include <string>
-#endif
+#include <string>
// import useful primitives from stl
-#ifndef OPENCV_NOSTL_TRANSITIONAL
# include <algorithm>
# include <utility>
# include <cstdlib> //for abs(int)
@@ -82,21 +78,6 @@ namespace cv
using std::log;
}
-#else
-namespace cv
-{
- template<typename T> static inline T min(T a, T b) { return a < b ? a : b; }
- template<typename T> static inline T max(T a, T b) { return a > b ? a : b; }
- template<typename T> static inline T abs(T a) { return a < 0 ? -a : a; }
- template<typename T> static inline void swap(T& a, T& b) { T tmp = a; a = b; b = tmp; }
-
- template<> inline uchar abs(uchar a) { return a; }
- template<> inline ushort abs(ushort a) { return a; }
- template<> inline unsigned abs(unsigned a) { return a; }
- template<> inline uint64 abs(uint64 a) { return a; }
-}
-#endif
-
namespace cv {
//! @addtogroup core_utils
@@ -489,7 +470,7 @@ public:
static const size_t npos = size_t(-1);
- explicit String();
+ String();
String(const String& str);
String(const String& str, size_t pos, size_t len = npos);
String(const char* s);
@@ -556,7 +537,6 @@ public:
String toLowerCase() const;
-#ifndef OPENCV_NOSTL
String(const std::string& str);
String(const std::string& str, size_t pos, size_t len = npos);
String& operator=(const std::string& str);
@@ -565,7 +545,6 @@ public:
friend String operator+ (const String& lhs, const std::string& rhs);
friend String operator+ (const std::string& lhs, const String& rhs);
-#endif
private:
char* cstr_;
@@ -627,6 +606,7 @@ String::String(const char* s, size_t n)
: cstr_(0), len_(0)
{
if (!n) return;
+ if (!s) return;
memcpy(allocate(n), s, n);
}
@@ -634,6 +614,7 @@ inline
String::String(size_t n, char c)
: cstr_(0), len_(0)
{
+ if (!n) return;
memset(allocate(n), c, n);
}
@@ -642,6 +623,7 @@ String::String(const char* first, const char* last)
: cstr_(0), len_(0)
{
size_t len = (size_t)(last - first);
+ if (!len) return;
memcpy(allocate(len), first, len);
}
@@ -650,6 +632,7 @@ String::String(Iterator first, Iterator last)
: cstr_(0), len_(0)
{
size_t len = (size_t)(last - first);
+ if (!len) return;
char* str = allocate(len);
while (first != last)
{
@@ -748,7 +731,7 @@ const char* String::begin() const
inline
const char* String::end() const
{
- return len_ ? cstr_ + 1 : 0;
+ return len_ ? cstr_ + len_ : NULL;
}
inline
@@ -955,8 +938,9 @@ size_t String::find_last_of(const char* s, size_t pos) const
inline
String String::toLowerCase() const
{
+ if (!cstr_)
+ return String();
String res(cstr_, len_);
-
for (size_t i = 0; i < len_; ++i)
res.cstr_[i] = (char) ::tolower(cstr_[i]);
@@ -1045,21 +1029,10 @@ static inline bool operator>= (const String& lhs, const char* rhs) { return lh
} // cv
-#ifndef OPENCV_NOSTL_TRANSITIONAL
namespace std
{
static inline void swap(cv::String& a, cv::String& b) { a.swap(b); }
}
-#else
-namespace cv
-{
- template<> inline
- void swap<cv::String>(cv::String& a, cv::String& b)
- {
- a.swap(b);
- }
-}
-#endif
#include "opencv2/core/ptr.inl.hpp"
diff --git a/modules/core/include/opencv2/core/cvstd.inl.hpp b/modules/core/include/opencv2/core/cvstd.inl.hpp
index 876def8..6d4919d 100644
--- a/modules/core/include/opencv2/core/cvstd.inl.hpp
+++ b/modules/core/include/opencv2/core/cvstd.inl.hpp
@@ -44,16 +44,18 @@
#ifndef OPENCV_CORE_CVSTDINL_HPP
#define OPENCV_CORE_CVSTDINL_HPP
-#ifndef OPENCV_NOSTL
-# include <complex>
-# include <ostream>
-#endif
+#include <complex>
+#include <ostream>
//! @cond IGNORED
+#ifdef _MSC_VER
+#pragma warning( push )
+#pragma warning( disable: 4127 )
+#endif
+
namespace cv
{
-#ifndef OPENCV_NOSTL
template<typename _Tp> class DataType< std::complex<_Tp> >
{
@@ -151,9 +153,7 @@ FileNode::operator std::string() const
template<> inline
void operator >> (const FileNode& n, std::string& value)
{
- String val;
- read(n, val, val);
- value = val;
+ read(n, value, std::string());
}
template<> inline
@@ -183,6 +183,18 @@ std::ostream& operator << (std::ostream& out, const Mat& mtx)
return out << Formatter::get()->format(mtx);
}
+static inline
+std::ostream& operator << (std::ostream& out, const UMat& m)
+{
+ return out << m.getMat(ACCESS_READ);
+}
+
+template<typename _Tp> static inline
+std::ostream& operator << (std::ostream& out, const Complex<_Tp>& c)
+{
+ return out << "(" << c.re << "," << c.im << ")";
+}
+
template<typename _Tp> static inline
std::ostream& operator << (std::ostream& out, const std::vector<Point_<_Tp> >& vec)
{
@@ -221,14 +233,7 @@ template<typename _Tp, int n> static inline
std::ostream& operator << (std::ostream& out, const Vec<_Tp, n>& vec)
{
out << "[";
-#ifdef _MSC_VER
-#pragma warning( push )
-#pragma warning( disable: 4127 )
-#endif
if(Vec<_Tp, n>::depth < CV_32F)
-#ifdef _MSC_VER
-#pragma warning( pop )
-#endif
{
for (int i = 0; i < n - 1; ++i) {
out << (int)vec[i] << ", ";
@@ -258,10 +263,24 @@ std::ostream& operator << (std::ostream& out, const Rect_<_Tp>& rect)
return out << "[" << rect.width << " x " << rect.height << " from (" << rect.x << ", " << rect.y << ")]";
}
+static inline std::ostream& operator << (std::ostream& out, const MatSize& msize)
+{
+ int i, dims = msize.p[-1];
+ for( i = 0; i < dims; i++ )
+ {
+ out << msize.p[i];
+ if( i < dims-1 )
+ out << " x ";
+ }
+ return out;
+}
-#endif // OPENCV_NOSTL
} // cv
+#ifdef _MSC_VER
+#pragma warning( pop )
+#endif
+
//! @endcond
#endif // OPENCV_CORE_CVSTDINL_HPP
diff --git a/modules/core/include/opencv2/core/fast_math.hpp b/modules/core/include/opencv2/core/fast_math.hpp
index c76936a..7858d40 100644
--- a/modules/core/include/opencv2/core/fast_math.hpp
+++ b/modules/core/include/opencv2/core/fast_math.hpp
@@ -47,6 +47,12 @@
#include "opencv2/core/cvdef.h"
+#if ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ \
+ && defined __SSE2__ && !defined __APPLE__)) && !defined(__CUDACC__)
+#include <emmintrin.h>
+#endif
+
+
//! @addtogroup core_utils
//! @{
@@ -54,25 +60,27 @@
* fast math *
\****************************************************************************************/
-#if defined __BORLANDC__
-# include <fastmath.h>
-#elif defined __cplusplus
+#ifdef __cplusplus
# include <cmath>
#else
-# include <math.h>
+# ifdef __BORLANDC__
+# include <fastmath.h>
+# else
+# include <math.h>
+# endif
#endif
#ifdef HAVE_TEGRA_OPTIMIZATION
# include "tegra_round.hpp"
#endif
-#if CV_VFP
+#if defined __GNUC__ && defined __arm__ && (defined __ARM_PCS_VFP || defined __ARM_VFPV3__ || defined __ARM_NEON__) && !defined __SOFTFP__ && !defined(__CUDACC__)
// 1. general scheme
#define ARM_ROUND(_value, _asm_string) \
int res; \
float temp; \
(void)temp; \
- asm(_asm_string : [res] "=r" (res), [temp] "=w" (temp) : [value] "w" (_value)); \
+ __asm__(_asm_string : [res] "=r" (res), [temp] "=w" (temp) : [value] "w" (_value)); \
return res
// 2. version for double
#ifdef __clang__
@@ -82,7 +90,7 @@
#endif
// 3. version for float
#define ARM_ROUND_FLT(value) ARM_ROUND(value, "vcvtr.s32.f32 %[temp], %[value]\n vmov %[res], %[temp]")
-#endif // CV_VFP
+#endif
/** @brief Rounds floating-point number to the nearest integer
@@ -93,7 +101,7 @@ CV_INLINE int
cvRound( double value )
{
#if ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ \
- && defined __SSE2__ && !defined __APPLE__)) && !defined(__CUDACC__)
+ && defined __SSE2__ && !defined __APPLE__) || CV_SSE2) && !defined(__CUDACC__)
__m128d t = _mm_set_sd( value );
return _mm_cvtsd_si32(t);
#elif defined _MSC_VER && defined _M_IX86
@@ -108,7 +116,7 @@ cvRound( double value )
defined __GNUC__) && defined HAVE_TEGRA_OPTIMIZATION
TEGRA_ROUND_DBL(value);
#elif defined CV_ICC || defined __GNUC__
-# if CV_VFP
+# if defined ARM_ROUND_DBL
ARM_ROUND_DBL(value);
# else
return (int)lrint(value);
@@ -130,18 +138,8 @@ cvRound( double value )
*/
CV_INLINE int cvFloor( double value )
{
-#if (defined _MSC_VER && defined _M_X64 || (defined __GNUC__ && defined __SSE2__ && !defined __APPLE__)) && !defined(__CUDACC__)
- __m128d t = _mm_set_sd( value );
- int i = _mm_cvtsd_si32(t);
- return i - _mm_movemask_pd(_mm_cmplt_sd(t, _mm_cvtsi32_sd(t,i)));
-#elif defined __GNUC__
int i = (int)value;
return i - (i > value);
-#else
- int i = cvRound(value);
- float diff = (float)(value - i);
- return i - (diff < 0);
-#endif
}
/** @brief Rounds floating-point number to the nearest integer not smaller than the original.
@@ -153,18 +151,8 @@ CV_INLINE int cvFloor( double value )
*/
CV_INLINE int cvCeil( double value )
{
-#if (defined _MSC_VER && defined _M_X64 || (defined __GNUC__ && defined __SSE2__&& !defined __APPLE__)) && !defined(__CUDACC__)
- __m128d t = _mm_set_sd( value );
- int i = _mm_cvtsd_si32(t);
- return i + _mm_movemask_pd(_mm_cmplt_sd(_mm_cvtsi32_sd(t,i), t));
-#elif defined __GNUC__
int i = (int)value;
return i + (i < value);
-#else
- int i = cvRound(value);
- float diff = (float)(i - value);
- return i + (diff < 0);
-#endif
}
/** @brief Determines if the argument is Not A Number.
@@ -200,8 +188,8 @@ CV_INLINE int cvIsInf( double value )
/** @overload */
CV_INLINE int cvRound(float value)
{
-#if ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ && \
- defined __SSE2__ && !defined __APPLE__)) && !defined(__CUDACC__)
+#if ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ \
+ && defined __SSE2__ && !defined __APPLE__) || CV_SSE2) && !defined(__CUDACC__)
__m128 t = _mm_set_ss( value );
return _mm_cvtss_si32(t);
#elif defined _MSC_VER && defined _M_IX86
@@ -216,7 +204,7 @@ CV_INLINE int cvRound(float value)
defined __GNUC__) && defined HAVE_TEGRA_OPTIMIZATION
TEGRA_ROUND_FLT(value);
#elif defined CV_ICC || defined __GNUC__
-# if CV_VFP
+# if defined ARM_ROUND_FLT
ARM_ROUND_FLT(value);
# else
return (int)lrintf(value);
@@ -237,18 +225,8 @@ CV_INLINE int cvRound( int value )
/** @overload */
CV_INLINE int cvFloor( float value )
{
-#if (defined _MSC_VER && defined _M_X64 || (defined __GNUC__ && defined __SSE2__ && !defined __APPLE__)) && !defined(__CUDACC__)
- __m128 t = _mm_set_ss( value );
- int i = _mm_cvtss_si32(t);
- return i - _mm_movemask_ps(_mm_cmplt_ss(t, _mm_cvtsi32_ss(t,i)));
-#elif defined __GNUC__
int i = (int)value;
return i - (i > value);
-#else
- int i = cvRound(value);
- float diff = (float)(value - i);
- return i - (diff < 0);
-#endif
}
/** @overload */
@@ -260,18 +238,8 @@ CV_INLINE int cvFloor( int value )
/** @overload */
CV_INLINE int cvCeil( float value )
{
-#if (defined _MSC_VER && defined _M_X64 || (defined __GNUC__ && defined __SSE2__&& !defined __APPLE__)) && !defined(__CUDACC__)
- __m128 t = _mm_set_ss( value );
- int i = _mm_cvtss_si32(t);
- return i + _mm_movemask_ps(_mm_cmplt_ss(_mm_cvtsi32_ss(t,i), t));
-#elif defined __GNUC__
int i = (int)value;
return i + (i < value);
-#else
- int i = cvRound(value);
- float diff = (float)(i - value);
- return i + (diff < 0);
-#endif
}
/** @overload */
diff --git a/modules/core/include/opencv2/core/hal/intrin.hpp b/modules/core/include/opencv2/core/hal/intrin.hpp
index 34075e3..d6dedc1 100644
--- a/modules/core/include/opencv2/core/hal/intrin.hpp
+++ b/modules/core/include/opencv2/core/hal/intrin.hpp
@@ -60,6 +60,25 @@
// access from within opencv code more accessible
namespace cv {
+#ifndef CV_DOXYGEN
+
+#ifdef CV_CPU_DISPATCH_MODE
+#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE __CV_CAT(hal_, CV_CPU_DISPATCH_MODE)
+#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN namespace __CV_CAT(hal_, CV_CPU_DISPATCH_MODE) {
+#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END }
+#else
+#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE hal_baseline
+#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN namespace hal_baseline {
+#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END }
+#endif
+
+
+CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
+CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
+using namespace CV_CPU_OPTIMIZATION_HAL_NAMESPACE;
+CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
+#endif
+
//! @addtogroup core_hal_intrin
//! @{
@@ -281,6 +300,9 @@ template <typename T> struct V_SIMD128Traits
//! @}
+#ifndef CV_DOXYGEN
+CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
+#endif
}
#ifdef CV_DOXYGEN
@@ -323,6 +345,10 @@ template <typename T> struct V_SIMD128Traits
namespace cv {
+#ifndef CV_DOXYGEN
+CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
+#endif
+
template <typename R> struct V_RegTrait128;
template <> struct V_RegTrait128<uchar> {
@@ -407,6 +433,33 @@ template <> struct V_RegTrait128<double> {
};
#endif
+inline unsigned int trailingZeros32(unsigned int value) {
+#if defined(_MSC_VER)
+#if (_MSC_VER < 1700)
+ unsigned long index = 0;
+ _BitScanForward(&index, value);
+ return (unsigned int)index;
+#else
+ return _tzcnt_u32(value);
+#endif
+#elif defined(__GNUC__) || defined(__GNUG__)
+ return __builtin_ctz(value);
+#elif defined(__ICC) || defined(__INTEL_COMPILER)
+ return _bit_scan_forward(value);
+#elif defined(__clang__)
+ return llvm.cttz.i32(value, true);
+#else
+ static const int MultiplyDeBruijnBitPosition[32] = {
+ 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
+ 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 };
+ return MultiplyDeBruijnBitPosition[((uint32_t)((value & -value) * 0x077CB531U)) >> 27];
+#endif
+}
+
+#ifndef CV_DOXYGEN
+CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
+#endif
+
} // cv::
//! @endcond
diff --git a/modules/core/include/opencv2/core/hal/intrin_cpp.hpp b/modules/core/include/opencv2/core/hal/intrin_cpp.hpp
index 93ca397..0a59e9b 100644
--- a/modules/core/include/opencv2/core/hal/intrin_cpp.hpp
+++ b/modules/core/include/opencv2/core/hal/intrin_cpp.hpp
@@ -53,6 +53,10 @@
namespace cv
{
+#ifndef CV_DOXYGEN
+CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
+#endif
+
/** @addtogroup core_hal_intrin
"Universal intrinsics" is a types and functions set intended to simplify vectorization of code on
@@ -149,7 +153,7 @@ Element-wise binary and unary operations.
Most of these operations return only one value.
-- Reduce: @ref v_reduce_min, @ref v_reduce_max, @ref v_reduce_sum
+- Reduce: @ref v_reduce_min, @ref v_reduce_max, @ref v_reduce_sum, @ref v_popcount
- Mask: @ref v_signmask, @ref v_check_all, @ref v_check_any, @ref v_select
### Other math
@@ -574,6 +578,49 @@ Scheme:
For 32-bit integer and 32-bit floating point types. */
OPENCV_HAL_IMPL_REDUCE_MINMAX_FUNC(v_reduce_max, std::max)
+static const unsigned char popCountTable[] =
+{
+ 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
+ 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
+ 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+ 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+ 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
+ 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+ 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
+ 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+ 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
+ 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
+ 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
+};
+/** @brief Count the 1 bits in the vector and return 4 values
+
+Scheme:
+ at code
+{A1 A2 A3 ...} => popcount(A1)
+ at endcode
+Any types but result will be in v_uint32x4*/
+template<typename _Tp, int n> inline v_uint32x4 v_popcount(const v_reg<_Tp, n>& a)
+{
+ v_uint8x16 b;
+ b = v_reinterpret_as_u8(a);
+ for( int i = 0; i < v_uint8x16::nlanes; i++ )
+ {
+ b.s[i] = popCountTable[b.s[i]];
+ }
+ v_uint32x4 c;
+ for( int i = 0; i < v_uint32x4::nlanes; i++ )
+ {
+ c.s[i] = b.s[i*4] + b.s[i*4+1] + b.s[i*4+2] + b.s[i*4+3];
+ }
+ return c;
+}
+
+
//! @cond IGNORED
template<typename _Tp, int n>
inline void v_minmax( const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b,
@@ -674,7 +721,7 @@ inline v_reg<typename V_TypeTraits<_Tp>::abs_type, n> v_absdiff(const v_reg<_Tp,
{
typedef typename V_TypeTraits<_Tp>::abs_type rtype;
v_reg<rtype, n> c;
- const rtype mask = std::numeric_limits<_Tp>::is_signed ? (1 << (sizeof(rtype)*8 - 1)) : 0;
+ const rtype mask = (rtype)(std::numeric_limits<_Tp>::is_signed ? (1 << (sizeof(rtype)*8 - 1)) : 0);
for( int i = 0; i < n; i++ )
{
rtype ua = a.s[i] ^ mask;
@@ -860,6 +907,27 @@ template<typename _Tp, int n> inline typename V_TypeTraits<_Tp>::sum_type v_redu
return c;
}
+/** @brief Sums all elements of each input vector, returns the vector of sums
+
+ Scheme:
+ @code
+ result[0] = a[0] + a[1] + a[2] + a[3]
+ result[1] = b[0] + b[1] + b[2] + b[3]
+ result[2] = c[0] + c[1] + c[2] + c[3]
+ result[3] = d[0] + d[1] + d[2] + d[3]
+ @endcode
+*/
+inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b,
+ const v_float32x4& c, const v_float32x4& d)
+{
+ v_float32x4 r;
+ r.s[0] = a.s[0] + a.s[1] + a.s[2] + a.s[3];
+ r.s[1] = b.s[0] + b.s[1] + b.s[2] + b.s[3];
+ r.s[2] = c.s[0] + c.s[1] + c.s[2] + c.s[3];
+ r.s[3] = d.s[0] + d.s[1] + d.s[2] + d.s[3];
+ return r;
+}
+
/** @brief Get negative values mask
Returned value is a bit mask with bits set to 1 on places corresponding to negative packed values indexes.
@@ -1784,7 +1852,9 @@ static inline bool hasSIMD128()
//! @}
-
+#ifndef CV_DOXYGEN
+CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
+#endif
}
#endif
diff --git a/modules/core/include/opencv2/core/hal/intrin_neon.hpp b/modules/core/include/opencv2/core/hal/intrin_neon.hpp
index b000733..ce661c3 100644
--- a/modules/core/include/opencv2/core/hal/intrin_neon.hpp
+++ b/modules/core/include/opencv2/core/hal/intrin_neon.hpp
@@ -53,6 +53,8 @@ namespace cv
//! @cond IGNORED
+CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
+
#define CV_SIMD128 1
#if defined(__aarch64__)
#define CV_SIMD128_64F 1
@@ -276,16 +278,28 @@ struct v_float64x2
};
#endif
-#if defined (HAVE_FP16)
-// Workaround for old comiplers
+#if CV_FP16
+// Workaround for old compilers
template <typename T> static inline int16x4_t vreinterpret_s16_f16(T a)
{ return (int16x4_t)a; }
template <typename T> static inline float16x4_t vreinterpret_f16_s16(T a)
{ return (float16x4_t)a; }
-template <typename T> static inline float16x4_t vld1_f16(const T* ptr)
-{ return vreinterpret_f16_s16(vld1_s16((const short*)ptr)); }
-template <typename T> static inline void vst1_f16(T* ptr, float16x4_t a)
-{ vst1_s16((short*)ptr, vreinterpret_s16_f16(a)); }
+template <typename T> static inline float16x4_t cv_vld1_f16(const T* ptr)
+{
+#ifndef vld1_f16 // APPLE compiler defines vld1_f16 as macro
+ return vreinterpret_f16_s16(vld1_s16((const short*)ptr));
+#else
+ return vld1_f16((const __fp16*)ptr);
+#endif
+}
+template <typename T> static inline void cv_vst1_f16(T* ptr, float16x4_t a)
+{
+#ifndef vst1_f16 // APPLE compiler defines vst1_f16 as macro
+ vst1_s16((short*)ptr, vreinterpret_s16_f16(a));
+#else
+ vst1_f16((__fp16*)ptr, a);
+#endif
+}
struct v_float16x4
{
@@ -297,7 +311,7 @@ struct v_float16x4
v_float16x4(short v0, short v1, short v2, short v3)
{
short v[] = {v0, v1, v2, v3};
- val = vld1_f16(v);
+ val = cv_vld1_f16(v);
}
short get0() const
{
@@ -773,12 +787,12 @@ OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_float32x4, float, f32)
OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_float64x2, double, f64)
#endif
-#if defined (HAVE_FP16)
+#if CV_FP16
// Workaround for old comiplers
inline v_float16x4 v_load_f16(const short* ptr)
-{ return v_float16x4(vld1_f16(ptr)); }
+{ return v_float16x4(cv_vld1_f16(ptr)); }
inline void v_store_f16(short* ptr, v_float16x4& a)
-{ vst1_f16(ptr, a.val); }
+{ cv_vst1_f16(ptr, a.val); }
#endif
#define OPENCV_HAL_IMPL_NEON_REDUCE_OP_8(_Tpvec, _Tpnvec, scalartype, func, vectorfunc, suffix) \
@@ -813,6 +827,37 @@ OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_float32x4, float32x2, float, sum, add, f32)
OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_float32x4, float32x2, float, max, max, f32)
OPENCV_HAL_IMPL_NEON_REDUCE_OP_4(v_float32x4, float32x2, float, min, min, f32)
+inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b,
+ const v_float32x4& c, const v_float32x4& d)
+{
+ float32x4x2_t ab = vtrnq_f32(a.val, b.val);
+ float32x4x2_t cd = vtrnq_f32(c.val, d.val);
+
+ float32x4_t u0 = vaddq_f32(ab.val[0], ab.val[1]); // a0+a1 b0+b1 a2+a3 b2+b3
+ float32x4_t u1 = vaddq_f32(cd.val[0], cd.val[1]); // c0+c1 d0+d1 c2+c3 d2+d3
+
+ float32x4_t v0 = vcombine_f32(vget_low_f32(u0), vget_low_f32(u1));
+ float32x4_t v1 = vcombine_f32(vget_high_f32(u0), vget_high_f32(u1));
+
+ return v_float32x4(vaddq_f32(v0, v1));
+}
+
+#define OPENCV_HAL_IMPL_NEON_POPCOUNT(_Tpvec, cast) \
+inline v_uint32x4 v_popcount(const _Tpvec& a) \
+{ \
+ uint8x16_t t = vcntq_u8(cast(a.val)); \
+ uint16x8_t t0 = vpaddlq_u8(t); /* 16 -> 8 */ \
+ uint32x4_t t1 = vpaddlq_u16(t0); /* 8 -> 4 */ \
+ return v_uint32x4(t1); \
+}
+
+OPENCV_HAL_IMPL_NEON_POPCOUNT(v_uint8x16, OPENCV_HAL_NOP)
+OPENCV_HAL_IMPL_NEON_POPCOUNT(v_uint16x8, vreinterpretq_u8_u16)
+OPENCV_HAL_IMPL_NEON_POPCOUNT(v_uint32x4, vreinterpretq_u8_u32)
+OPENCV_HAL_IMPL_NEON_POPCOUNT(v_int8x16, vreinterpretq_u8_s8)
+OPENCV_HAL_IMPL_NEON_POPCOUNT(v_int16x8, vreinterpretq_u8_s16)
+OPENCV_HAL_IMPL_NEON_POPCOUNT(v_int32x4, vreinterpretq_u8_s32)
+
inline int v_signmask(const v_uint8x16& a)
{
int8x8_t m0 = vcreate_s8(CV_BIG_UINT(0x0706050403020100));
@@ -1205,7 +1250,7 @@ inline v_float64x2 v_cvt_f64_high(const v_float32x4& a)
}
#endif
-#if defined (HAVE_FP16)
+#if CV_FP16
inline v_float32x4 v_cvt_f32(const v_float16x4& a)
{
return v_float32x4(vcvt_f32_f16(a.val));
@@ -1222,11 +1267,13 @@ inline v_float16x4 v_cvt_f16(const v_float32x4& a)
//! @brief Check CPU capability of SIMD operation
static inline bool hasSIMD128()
{
- return checkHardwareSupport(CV_CPU_NEON);
+ return (CV_CPU_HAS_SUPPORT_NEON) ? true : false;
}
//! @}
+CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
+
//! @endcond
}
diff --git a/modules/core/include/opencv2/core/hal/intrin_sse.hpp b/modules/core/include/opencv2/core/hal/intrin_sse.hpp
index fc81dac..b40f1de 100644
--- a/modules/core/include/opencv2/core/hal/intrin_sse.hpp
+++ b/modules/core/include/opencv2/core/hal/intrin_sse.hpp
@@ -56,12 +56,14 @@ namespace cv
//! @cond IGNORED
+CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
+
struct v_uint8x16
{
typedef uchar lane_type;
enum { nlanes = 16 };
- v_uint8x16() {}
+ v_uint8x16() : val(_mm_setzero_si128()) {}
explicit v_uint8x16(__m128i v) : val(v) {}
v_uint8x16(uchar v0, uchar v1, uchar v2, uchar v3, uchar v4, uchar v5, uchar v6, uchar v7,
uchar v8, uchar v9, uchar v10, uchar v11, uchar v12, uchar v13, uchar v14, uchar v15)
@@ -84,7 +86,7 @@ struct v_int8x16
typedef schar lane_type;
enum { nlanes = 16 };
- v_int8x16() {}
+ v_int8x16() : val(_mm_setzero_si128()) {}
explicit v_int8x16(__m128i v) : val(v) {}
v_int8x16(schar v0, schar v1, schar v2, schar v3, schar v4, schar v5, schar v6, schar v7,
schar v8, schar v9, schar v10, schar v11, schar v12, schar v13, schar v14, schar v15)
@@ -107,7 +109,7 @@ struct v_uint16x8
typedef ushort lane_type;
enum { nlanes = 8 };
- v_uint16x8() {}
+ v_uint16x8() : val(_mm_setzero_si128()) {}
explicit v_uint16x8(__m128i v) : val(v) {}
v_uint16x8(ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5, ushort v6, ushort v7)
{
@@ -127,7 +129,7 @@ struct v_int16x8
typedef short lane_type;
enum { nlanes = 8 };
- v_int16x8() {}
+ v_int16x8() : val(_mm_setzero_si128()) {}
explicit v_int16x8(__m128i v) : val(v) {}
v_int16x8(short v0, short v1, short v2, short v3, short v4, short v5, short v6, short v7)
{
@@ -146,7 +148,7 @@ struct v_uint32x4
typedef unsigned lane_type;
enum { nlanes = 4 };
- v_uint32x4() {}
+ v_uint32x4() : val(_mm_setzero_si128()) {}
explicit v_uint32x4(__m128i v) : val(v) {}
v_uint32x4(unsigned v0, unsigned v1, unsigned v2, unsigned v3)
{
@@ -164,7 +166,7 @@ struct v_int32x4
typedef int lane_type;
enum { nlanes = 4 };
- v_int32x4() {}
+ v_int32x4() : val(_mm_setzero_si128()) {}
explicit v_int32x4(__m128i v) : val(v) {}
v_int32x4(int v0, int v1, int v2, int v3)
{
@@ -182,7 +184,7 @@ struct v_float32x4
typedef float lane_type;
enum { nlanes = 4 };
- v_float32x4() {}
+ v_float32x4() : val(_mm_setzero_ps()) {}
explicit v_float32x4(__m128 v) : val(v) {}
v_float32x4(float v0, float v1, float v2, float v3)
{
@@ -200,7 +202,7 @@ struct v_uint64x2
typedef uint64 lane_type;
enum { nlanes = 2 };
- v_uint64x2() {}
+ v_uint64x2() : val(_mm_setzero_si128()) {}
explicit v_uint64x2(__m128i v) : val(v) {}
v_uint64x2(uint64 v0, uint64 v1)
{
@@ -220,7 +222,7 @@ struct v_int64x2
typedef int64 lane_type;
enum { nlanes = 2 };
- v_int64x2() {}
+ v_int64x2() : val(_mm_setzero_si128()) {}
explicit v_int64x2(__m128i v) : val(v) {}
v_int64x2(int64 v0, int64 v1)
{
@@ -240,7 +242,7 @@ struct v_float64x2
typedef double lane_type;
enum { nlanes = 2 };
- v_float64x2() {}
+ v_float64x2() : val(_mm_setzero_pd()) {}
explicit v_float64x2(__m128d v) : val(v) {}
v_float64x2(double v0, double v1)
{
@@ -253,13 +255,13 @@ struct v_float64x2
__m128d val;
};
-#if defined(HAVE_FP16)
+#if CV_FP16
struct v_float16x4
{
typedef short lane_type;
enum { nlanes = 4 };
- v_float16x4() {}
+ v_float16x4() : val(_mm_setzero_si128()) {}
explicit v_float16x4(__m128i v) : val(v) {}
v_float16x4(short v0, short v1, short v2, short v3)
{
@@ -897,6 +899,15 @@ inline _Tpvec operator >= (const _Tpvec& a, const _Tpvec& b) \
OPENCV_HAL_IMPL_SSE_FLT_CMP_OP(v_float32x4, ps)
OPENCV_HAL_IMPL_SSE_FLT_CMP_OP(v_float64x2, pd)
+#define OPENCV_HAL_IMPL_SSE_64BIT_CMP_OP(_Tpvec, cast) \
+inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \
+{ return cast(v_reinterpret_as_f64(a) == v_reinterpret_as_f64(b)); } \
+inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \
+{ return cast(v_reinterpret_as_f64(a) != v_reinterpret_as_f64(b)); }
+
+OPENCV_HAL_IMPL_SSE_64BIT_CMP_OP(v_uint64x2, v_reinterpret_as_u64);
+OPENCV_HAL_IMPL_SSE_64BIT_CMP_OP(v_int64x2, v_reinterpret_as_s64);
+
OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_uint8x16, v_add_wrap, _mm_add_epi8)
OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_int8x16, v_add_wrap, _mm_add_epi8)
OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_uint16x8, v_add_wrap, _mm_add_epi16)
@@ -1054,7 +1065,7 @@ inline void v_store_high(_Tp* ptr, const _Tpvec& a) \
OPENCV_HAL_IMPL_SSE_LOADSTORE_FLT_OP(v_float32x4, float, ps)
OPENCV_HAL_IMPL_SSE_LOADSTORE_FLT_OP(v_float64x2, double, pd)
-#if defined(HAVE_FP16)
+#if CV_FP16
inline v_float16x4 v_load_f16(const short* ptr)
{ return v_float16x4(_mm_loadl_epi64((const __m128i*)ptr)); }
inline void v_store_f16(short* ptr, v_float16x4& a)
@@ -1101,6 +1112,15 @@ OPENCV_HAL_IMPL_SSE_REDUCE_OP_8(int16x8, short, max, epi16, (short)-32768)
OPENCV_HAL_IMPL_SSE_REDUCE_OP_8(int16x8, short, min, epi16, (short)-32768)
OPENCV_HAL_IMPL_SSE_REDUCE_OP_8_SUM(int16x8, short, 16)
+#define OPENCV_HAL_IMPL_SSE_REDUCE_OP_4_SUM(_Tpvec, scalartype, regtype, suffix, cast_from, cast_to, extract) \
+inline scalartype v_reduce_sum(const _Tpvec& a) \
+{ \
+ regtype val = a.val; \
+ val = _mm_add_##suffix(val, cast_to(_mm_srli_si128(cast_from(val), 8))); \
+ val = _mm_add_##suffix(val, cast_to(_mm_srli_si128(cast_from(val), 4))); \
+ return (scalartype)_mm_cvt##extract(val); \
+}
+
#define OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(_Tpvec, scalartype, func, scalar_func) \
inline scalartype v_reduce_##func(const _Tpvec& a) \
{ \
@@ -1111,16 +1131,53 @@ inline scalartype v_reduce_##func(const _Tpvec& a) \
return scalar_func(s0, s1); \
}
-OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_uint32x4, unsigned, sum, OPENCV_HAL_ADD)
+OPENCV_HAL_IMPL_SSE_REDUCE_OP_4_SUM(v_uint32x4, unsigned, __m128i, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NOP, si128_si32)
+OPENCV_HAL_IMPL_SSE_REDUCE_OP_4_SUM(v_int32x4, int, __m128i, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NOP, si128_si32)
+OPENCV_HAL_IMPL_SSE_REDUCE_OP_4_SUM(v_float32x4, float, __m128, ps, _mm_castps_si128, _mm_castsi128_ps, ss_f32)
+
+inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b,
+ const v_float32x4& c, const v_float32x4& d)
+{
+#if CV_SSE3
+ __m128 ab = _mm_hadd_ps(a.val, b.val);
+ __m128 cd = _mm_hadd_ps(c.val, d.val);
+ return v_float32x4(_mm_hadd_ps(ab, cd));
+#else
+ __m128 ac = _mm_add_ps(_mm_unpacklo_ps(a.val, c.val), _mm_unpackhi_ps(a.val, c.val));
+ __m128 bd = _mm_add_ps(_mm_unpacklo_ps(b.val, d.val), _mm_unpackhi_ps(b.val, d.val));
+ return v_float32x4(_mm_add_ps(_mm_unpacklo_ps(ac, bd), _mm_unpackhi_ps(ac, bd)));
+#endif
+}
+
OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_uint32x4, unsigned, max, std::max)
OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_uint32x4, unsigned, min, std::min)
-OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_int32x4, int, sum, OPENCV_HAL_ADD)
OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_int32x4, int, max, std::max)
OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_int32x4, int, min, std::min)
-OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_float32x4, float, sum, OPENCV_HAL_ADD)
OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_float32x4, float, max, std::max)
OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_float32x4, float, min, std::min)
+#define OPENCV_HAL_IMPL_SSE_POPCOUNT(_Tpvec) \
+inline v_uint32x4 v_popcount(const _Tpvec& a) \
+{ \
+ __m128i m1 = _mm_set1_epi32(0x55555555); \
+ __m128i m2 = _mm_set1_epi32(0x33333333); \
+ __m128i m4 = _mm_set1_epi32(0x0f0f0f0f); \
+ __m128i p = a.val; \
+ p = _mm_add_epi32(_mm_and_si128(_mm_srli_epi32(p, 1), m1), _mm_and_si128(p, m1)); \
+ p = _mm_add_epi32(_mm_and_si128(_mm_srli_epi32(p, 2), m2), _mm_and_si128(p, m2)); \
+ p = _mm_add_epi32(_mm_and_si128(_mm_srli_epi32(p, 4), m4), _mm_and_si128(p, m4)); \
+ p = _mm_adds_epi8(p, _mm_srli_si128(p, 1)); \
+ p = _mm_adds_epi8(p, _mm_srli_si128(p, 2)); \
+ return v_uint32x4(_mm_and_si128(p, _mm_set1_epi32(0x000000ff))); \
+}
+
+OPENCV_HAL_IMPL_SSE_POPCOUNT(v_uint8x16)
+OPENCV_HAL_IMPL_SSE_POPCOUNT(v_uint16x8)
+OPENCV_HAL_IMPL_SSE_POPCOUNT(v_uint32x4)
+OPENCV_HAL_IMPL_SSE_POPCOUNT(v_int8x16)
+OPENCV_HAL_IMPL_SSE_POPCOUNT(v_int16x8)
+OPENCV_HAL_IMPL_SSE_POPCOUNT(v_int32x4)
+
#define OPENCV_HAL_IMPL_SSE_CHECK_SIGNS(_Tpvec, suffix, pack_op, and_op, signmask, allmask) \
inline int v_signmask(const _Tpvec& a) \
{ \
@@ -1336,6 +1393,24 @@ OPENCV_HAL_IMPL_SSE_TRANSPOSE4x4(v_int32x4, epi32, OPENCV_HAL_NOP, OPENCV_HAL_NO
OPENCV_HAL_IMPL_SSE_TRANSPOSE4x4(v_float32x4, ps, _mm_castps_si128, _mm_castsi128_ps)
// adopted from sse_utils.hpp
+inline void v_load_deinterleave(const uchar* ptr, v_uint8x16& a, v_uint8x16& b)
+{
+ __m128i t00 = _mm_loadu_si128((const __m128i*)ptr);
+ __m128i t01 = _mm_loadu_si128((const __m128i*)(ptr + 16));
+
+ __m128i t10 = _mm_unpacklo_epi8(t00, t01);
+ __m128i t11 = _mm_unpackhi_epi8(t00, t01);
+
+ __m128i t20 = _mm_unpacklo_epi8(t10, t11);
+ __m128i t21 = _mm_unpackhi_epi8(t10, t11);
+
+ __m128i t30 = _mm_unpacklo_epi8(t20, t21);
+ __m128i t31 = _mm_unpackhi_epi8(t20, t21);
+
+ a.val = _mm_unpacklo_epi8(t30, t31);
+ b.val = _mm_unpackhi_epi8(t30, t31);
+}
+
inline void v_load_deinterleave(const uchar* ptr, v_uint8x16& a, v_uint8x16& b, v_uint8x16& c)
{
__m128i t00 = _mm_loadu_si128((const __m128i*)ptr);
@@ -1454,6 +1529,35 @@ inline void v_load_deinterleave(const unsigned* ptr, v_uint32x4& a, v_uint32x4&
v_transpose4x4(u0, u1, u2, u3, a, b, c, d);
}
+inline void v_load_deinterleave(const uint64 *ptr, v_uint64x2& a, v_uint64x2& b, v_uint64x2& c)
+{
+ __m128i t0 = _mm_loadu_si128((const __m128i*)ptr);
+ __m128i t1 = _mm_loadu_si128((const __m128i*)(ptr + 2));
+ __m128i t2 = _mm_loadu_si128((const __m128i*)(ptr + 4));
+
+ a = v_uint64x2(_mm_unpacklo_epi64(t0, _mm_unpackhi_epi64(t1, t1)));
+ b = v_uint64x2(_mm_unpacklo_epi64(_mm_unpackhi_epi64(t0, t0), t2));
+ c = v_uint64x2(_mm_unpacklo_epi64(t1, _mm_unpackhi_epi64(t2, t2)));
+}
+
+inline void v_load_deinterleave(const int64 *ptr, v_int64x2& a, v_int64x2& b, v_int64x2& c)
+{
+ v_uint64x2 t0, t1, t2;
+ v_load_deinterleave((const uint64*)ptr, t0, t1, t2);
+ a = v_reinterpret_as_s64(t0);
+ b = v_reinterpret_as_s64(t1);
+ c = v_reinterpret_as_s64(t2);
+}
+
+inline void v_load_deinterleave(const double *ptr, v_float64x2& a, v_float64x2& b, v_float64x2& c)
+{
+ v_uint64x2 t0, t1, t2;
+ v_load_deinterleave((const uint64*)ptr, t0, t1, t2);
+ a = v_reinterpret_as_f64(t0);
+ b = v_reinterpret_as_f64(t1);
+ c = v_reinterpret_as_f64(t2);
+}
+
// 2-channel, float only
inline void v_load_deinterleave(const float* ptr, v_float32x4& a, v_float32x4& b)
{
@@ -1475,6 +1579,15 @@ inline void v_store_interleave( short* ptr, const v_int16x8& a, const v_int16x8&
_mm_storeu_si128((__m128i*)(ptr + 8), t1);
}
+inline void v_store_interleave( uchar* ptr, const v_uint8x16& a, const v_uint8x16& b)
+{
+ __m128i v0 = _mm_unpacklo_epi8(a.val, b.val);
+ __m128i v1 = _mm_unpackhi_epi8(a.val, b.val);
+
+ _mm_storeu_si128((__m128i*)(ptr), v0);
+ _mm_storeu_si128((__m128i*)(ptr + 16), v1);
+}
+
inline void v_store_interleave( uchar* ptr, const v_uint8x16& a, const v_uint8x16& b,
const v_uint8x16& c )
{
@@ -1642,6 +1755,27 @@ inline void v_store_interleave(float* ptr, const v_float32x4& a, const v_float32
_mm_storeu_ps((ptr + 4), u1);
}
+inline void v_store_interleave(uint64 *ptr, const v_uint64x2& a, const v_uint64x2& b, const v_uint64x2& c)
+{
+ __m128i t0 = _mm_unpacklo_epi64(a.val, b.val);
+ __m128i t1 = _mm_unpacklo_epi64(c.val, _mm_unpackhi_epi64(a.val, a.val));
+ __m128i t2 = _mm_unpackhi_epi64(b.val, c.val);
+
+ _mm_storeu_si128((__m128i*)ptr, t0);
+ _mm_storeu_si128((__m128i*)(ptr + 2), t1);
+ _mm_storeu_si128((__m128i*)(ptr + 4), t2);
+}
+
+inline void v_store_interleave(int64 *ptr, const v_int64x2& a, const v_int64x2& b, const v_int64x2& c)
+{
+ v_store_interleave((uint64*)ptr, v_reinterpret_as_u64(a), v_reinterpret_as_u64(b), v_reinterpret_as_u64(c));
+}
+
+inline void v_store_interleave(double *ptr, const v_float64x2& a, const v_float64x2& b, const v_float64x2& c)
+{
+ v_store_interleave((uint64*)ptr, v_reinterpret_as_u64(a), v_reinterpret_as_u64(b), v_reinterpret_as_u64(c));
+}
+
#define OPENCV_HAL_IMPL_SSE_LOADSTORE_INTERLEAVE(_Tpvec, _Tp, suffix, _Tpuvec, _Tpu, usuffix) \
inline void v_load_deinterleave( const _Tp* ptr, _Tpvec& a0, \
_Tpvec& b0, _Tpvec& c0 ) \
@@ -1715,7 +1849,7 @@ inline v_float64x2 v_cvt_f64_high(const v_float32x4& a)
return v_float64x2(_mm_cvtps_pd(_mm_castsi128_ps(_mm_srli_si128(_mm_castps_si128(a.val),8))));
}
-#if defined(HAVE_FP16)
+#if CV_FP16
inline v_float32x4 v_cvt_f32(const v_float16x4& a)
{
return v_float32x4(_mm_cvtph_ps(a.val));
@@ -1732,11 +1866,13 @@ inline v_float16x4 v_cvt_f16(const v_float32x4& a)
//! @brief Check CPU capability of SIMD operation
static inline bool hasSIMD128()
{
- return checkHardwareSupport(CV_CPU_SSE2);
+ return (CV_CPU_HAS_SUPPORT_SSE2) ? true : false;
}
//! @}
+CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
+
//! @endcond
}
diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp
index 39c197e..8f7f6c4 100644
--- a/modules/core/include/opencv2/core/mat.hpp
+++ b/modules/core/include/opencv2/core/mat.hpp
@@ -62,6 +62,8 @@ namespace cv
enum { ACCESS_READ=1<<24, ACCESS_WRITE=1<<25,
ACCESS_RW=3<<24, ACCESS_MASK=ACCESS_RW, ACCESS_FAST=1<<26 };
+CV__DEBUG_NS_BEGIN
+
class CV_EXPORTS _OutputArray;
//////////////////////// Input/Output Array Arguments /////////////////////////////////
@@ -73,8 +75,8 @@ It is defined as:
typedef const _InputArray& InputArray;
@endcode
where _InputArray is a class that can be constructed from `Mat`, `Mat_<T>`, `Matx<T, m, n>`,
-`std::vector<T>`, `std::vector<std::vector<T> >` or `std::vector<Mat>`. It can also be constructed
-from a matrix expression.
+`std::vector<T>`, `std::vector<std::vector<T> >`, `std::vector<Mat>`, `std::vector<Mat_<T> >`,
+`UMat`, `std::vector<UMat>` or `double`. It can also be constructed from a matrix expression.
Since this is mostly implementation-level class, and its interface may change in future versions, we
do not describe it in details. There are a few key things, though, that should be kept in mind:
@@ -165,7 +167,9 @@ public:
UMAT =10 << KIND_SHIFT,
STD_VECTOR_UMAT =11 << KIND_SHIFT,
STD_BOOL_VECTOR =12 << KIND_SHIFT,
- STD_VECTOR_CUDA_GPU_MAT = 13 << KIND_SHIFT
+ STD_VECTOR_CUDA_GPU_MAT = 13 << KIND_SHIFT,
+ STD_ARRAY =14 << KIND_SHIFT,
+ STD_ARRAY_MAT =15 << KIND_SHIFT
};
_InputArray();
@@ -177,6 +181,7 @@ public:
template<typename _Tp> _InputArray(const std::vector<_Tp>& vec);
_InputArray(const std::vector<bool>& vec);
template<typename _Tp> _InputArray(const std::vector<std::vector<_Tp> >& vec);
+ _InputArray(const std::vector<std::vector<bool> >&);
template<typename _Tp> _InputArray(const std::vector<Mat_<_Tp> >& vec);
template<typename _Tp> _InputArray(const _Tp* vec, int n);
template<typename _Tp, int m, int n> _InputArray(const Matx<_Tp, m, n>& matx);
@@ -189,6 +194,11 @@ public:
_InputArray(const UMat& um);
_InputArray(const std::vector<UMat>& umv);
+#ifdef CV_CXX_STD_ARRAY
+ template<typename _Tp, std::size_t _Nm> _InputArray(const std::array<_Tp, _Nm>& arr);
+ template<std::size_t _Nm> _InputArray(const std::array<Mat, _Nm>& arr);
+#endif
+
Mat getMat(int idx=-1) const;
Mat getMat_(int idx=-1) const;
UMat getUMat(int idx=-1) const;
@@ -293,6 +303,7 @@ public:
template<typename _Tp> _OutputArray(std::vector<_Tp>& vec);
_OutputArray(std::vector<bool>& vec);
template<typename _Tp> _OutputArray(std::vector<std::vector<_Tp> >& vec);
+ _OutputArray(std::vector<std::vector<bool> >&);
template<typename _Tp> _OutputArray(std::vector<Mat_<_Tp> >& vec);
template<typename _Tp> _OutputArray(Mat_<_Tp>& m);
template<typename _Tp> _OutputArray(_Tp* vec, int n);
@@ -316,6 +327,13 @@ public:
_OutputArray(const UMat& m);
_OutputArray(const std::vector<UMat>& vec);
+#ifdef CV_CXX_STD_ARRAY
+ template<typename _Tp, std::size_t _Nm> _OutputArray(std::array<_Tp, _Nm>& arr);
+ template<typename _Tp, std::size_t _Nm> _OutputArray(const std::array<_Tp, _Nm>& arr);
+ template<std::size_t _Nm> _OutputArray(std::array<Mat, _Nm>& arr);
+ template<std::size_t _Nm> _OutputArray(const std::array<Mat, _Nm>& arr);
+#endif
+
bool fixedSize() const;
bool fixedType() const;
bool needed() const;
@@ -374,8 +392,18 @@ public:
template<typename _Tp, int m, int n> _InputOutputArray(const Matx<_Tp, m, n>& matx);
_InputOutputArray(const UMat& m);
_InputOutputArray(const std::vector<UMat>& vec);
+
+#ifdef CV_CXX_STD_ARRAY
+ template<typename _Tp, std::size_t _Nm> _InputOutputArray(std::array<_Tp, _Nm>& arr);
+ template<typename _Tp, std::size_t _Nm> _InputOutputArray(const std::array<_Tp, _Nm>& arr);
+ template<std::size_t _Nm> _InputOutputArray(std::array<Mat, _Nm>& arr);
+ template<std::size_t _Nm> _InputOutputArray(const std::array<Mat, _Nm>& arr);
+#endif
+
};
+CV__DEBUG_NS_END
+
typedef const _InputArray& InputArray;
typedef InputArray InputArrayOfArrays;
typedef const _OutputArray& OutputArray;
@@ -473,7 +501,9 @@ struct CV_EXPORTS UMatData
{
enum { COPY_ON_MAP=1, HOST_COPY_OBSOLETE=2,
DEVICE_COPY_OBSOLETE=4, TEMP_UMAT=8, TEMP_COPIED_UMAT=24,
- USER_ALLOCATED=32, DEVICE_MEM_MAPPED=64};
+ USER_ALLOCATED=32, DEVICE_MEM_MAPPED=64,
+ ASYNC_CLEANUP=128
+ };
UMatData(const MatAllocator* allocator);
~UMatData();
@@ -660,7 +690,7 @@ sub-matrices.
- Use MATLAB-style array initializers, zeros(), ones(), eye(), for example:
@code
- // create a double-precision identity martix and add it to M.
+ // create a double-precision identity matrix and add it to M.
M += Mat::eye(M.rows, M.cols, CV_64F);
@endcode
@@ -693,7 +723,7 @@ If you need to process a whole row of a 2D array, the most efficient way is to g
the row first, and then just use the plain C operator [] :
@code
// compute sum of positive matrix elements
- // (assuming that M isa double-precision matrix)
+ // (assuming that M is a double-precision matrix)
double sum=0;
for(int i = 0; i < M.rows; i++)
{
@@ -736,6 +766,8 @@ Finally, there are STL-style iterators that are smart enough to skip gaps betwee
@endcode
The matrix iterators are random-access iterators, so they can be passed to any STL algorithm,
including std::sort().
+
+ at note Matrix Expressions and arithmetic see MatExpr
*/
class CV_EXPORTS Mat
{
@@ -953,6 +985,18 @@ public:
*/
template<typename _Tp> explicit Mat(const std::vector<_Tp>& vec, bool copyData=false);
+#ifdef CV_CXX11
+ /** @overload
+ */
+ template<typename _Tp> explicit Mat(const std::initializer_list<_Tp> list);
+#endif
+
+#ifdef CV_CXX_STD_ARRAY
+ /** @overload
+ */
+ template<typename _Tp, size_t _Nm> explicit Mat(const std::array<_Tp, _Nm>& arr, bool copyData=false);
+#endif
+
/** @overload
*/
template<typename _Tp, int n> explicit Mat(const Vec<_Tp, n>& vec, bool copyData=true);
@@ -1079,10 +1123,33 @@ public:
single-column matrix. Similarly to Mat::row and Mat::col, this is an O(1) operation.
@param d index of the diagonal, with the following values:
- `d=0` is the main diagonal.
- - `d>0` is a diagonal from the lower half. For example, d=1 means the diagonal is set
+ - `d<0` is a diagonal from the lower half. For example, d=-1 means the diagonal is set
immediately below the main one.
- - `d<0` is a diagonal from the upper half. For example, d=-1 means the diagonal is set
+ - `d>0` is a diagonal from the upper half. For example, d=1 means the diagonal is set
immediately above the main one.
+ For example:
+ @code
+ Mat m = (Mat_<int>(3,3) <<
+ 1,2,3,
+ 4,5,6,
+ 7,8,9);
+ Mat d0 = m.diag(0);
+ Mat d1 = m.diag(1);
+ Mat d_1 = m.diag(-1);
+ @endcode
+ The resulting matrices are
+ @code
+ d0 =
+ [1;
+ 5;
+ 9]
+ d1 =
+ [2;
+ 6]
+ d_1 =
+ [4;
+ 8]
+ @endcode
*/
Mat diag(int d=0) const;
@@ -1190,6 +1257,9 @@ public:
/** @overload */
Mat reshape(int cn, int newndims, const int* newsz) const;
+ /** @overload */
+ Mat reshape(int cn, const std::vector<int>& newshape) const;
+
/** @brief Transposes a matrix.
The method performs matrix transposition by means of matrix expressions. It does not perform the
@@ -1402,7 +1472,7 @@ public:
*/
void release();
- //! deallocates the matrix data
+ //! internal use function, consider to use 'release' method instead; deallocates the matrix data
void deallocate();
//! internal use function; properly re-allocates _size, _step arrays
void copySize(const Mat& m);
@@ -1416,6 +1486,14 @@ public:
*/
void reserve(size_t sz);
+ /** @brief Reserves space for the certain number of bytes.
+
+ The method reserves space for sz bytes. If the matrix already has enough space to store sz bytes,
+ nothing happens. If matrix has to be reallocated its previous content could be lost.
+ @param sz Number of bytes.
+ */
+ void reserveBuffer(size_t sz);
+
/** @brief Changes the number of matrix rows.
The methods change the number of matrix rows. If the matrix is reallocated, the first
@@ -1542,6 +1620,10 @@ public:
template<typename _Tp, int n> operator Vec<_Tp, n>() const;
template<typename _Tp, int m, int n> operator Matx<_Tp, m, n>() const;
+#ifdef CV_CXX_STD_ARRAY
+ template<typename _Tp, std::size_t _Nm> operator std::array<_Tp, _Nm>() const;
+#endif
+
/** @brief Reports whether the matrix is continuous or not.
The method returns true if the matrix elements are stored continuously without gaps at the end of
@@ -1684,6 +1766,12 @@ public:
*/
size_t total() const;
+ /** @brief Returns the total number of array elements.
+
+ The method returns the number of elements within a certain sub-array slice with startDim <= dim < endDim
+ */
+ size_t total(int startDim, int endDim=INT_MAX) const;
+
//! returns N if the matrix is 1-channel (N x ptdim) or ptdim-channel (1 x N) or (N x 1); negative number otherwise
int checkVector(int elemChannels, int depth=-1, bool requireContinuous=true) const;
@@ -1891,7 +1979,7 @@ public:
// first. raw pointer access.
for (int r = 0; r < image.rows; ++r) {
- Pixel* ptr = image.ptr<Pixel>(0, r);
+ Pixel* ptr = image.ptr<Pixel>(r, 0);
const Pixel* ptr_end = ptr + image.cols;
for (; ptr != ptr_end; ++ptr) {
ptr->x = 255;
@@ -1987,7 +2075,7 @@ protected:
/** @brief Template matrix class derived from Mat
- at code
+ at code{.cpp}
template<typename _Tp> class Mat_ : public Mat
{
public:
@@ -1999,7 +2087,7 @@ protected:
The class `Mat_<_Tp>` is a *thin* template wrapper on top of the Mat class. It does not have any
extra data fields. Nor this class nor Mat has any virtual methods. Thus, references or pointers to
these two classes can be freely but carefully converted one to another. For example:
- at code
+ at code{.cpp}
// create a 100x100 8-bit matrix
Mat M(100,100,CV_8U);
// this will be compiled fine. no any data conversion will be done.
@@ -2011,7 +2099,7 @@ While Mat is sufficient in most cases, Mat_ can be more convenient if you use a
access operations and if you know matrix type at the compilation time. Note that
`Mat::at(int y,int x)` and `Mat_::operator()(int y,int x)` do absolutely the same
and run at the same speed, but the latter is certainly shorter:
- at code
+ at code{.cpp}
Mat_<double> M(20,20);
for(int i = 0; i < M.rows; i++)
for(int j = 0; j < M.cols; j++)
@@ -2021,7 +2109,7 @@ and run at the same speed, but the latter is certainly shorter:
cout << E.at<double>(0,0)/E.at<double>(M.rows-1,0);
@endcode
To use Mat_ for multi-channel images/matrices, pass Vec as a Mat_ parameter:
- at code
+ at code{.cpp}
// allocate a 320x240 color image and fill it with green (in RGB space)
Mat_<Vec3b> img(240, 320, Vec3b(0,255,0));
// now draw a diagonal white line
@@ -2032,6 +2120,17 @@ To use Mat_ for multi-channel images/matrices, pass Vec as a Mat_ parameter:
for(int j = 0; j < img.cols; j++)
img(i,j)[2] ^= (uchar)(i ^ j);
@endcode
+Mat_ is fully compatible with C++11 range-based for loop. For example such loop
+can be used to safely apply look-up table:
+ at code{.cpp}
+void applyTable(Mat_<uchar>& I, const uchar* const table)
+{
+ for(auto& pixel : I)
+ {
+ pixel = table[pixel];
+ }
+}
+ at endcode
*/
template<typename _Tp> class Mat_ : public Mat
{
@@ -2081,6 +2180,14 @@ public:
explicit Mat_(const Point3_<typename DataType<_Tp>::channel_type>& pt, bool copyData=true);
explicit Mat_(const MatCommaInitializer_<_Tp>& commaInitializer);
+#ifdef CV_CXX11
+ Mat_(std::initializer_list<_Tp> values);
+#endif
+
+#ifdef CV_CXX_STD_ARRAY
+ template <std::size_t _Nm> explicit Mat_(const std::array<_Tp, _Nm>& arr, bool copyData=false);
+#endif
+
Mat_& operator = (const Mat& m);
Mat_& operator = (const Mat_& m);
//! set all the elements to s.
@@ -2105,6 +2212,8 @@ public:
void create(Size _size);
//! equivalent to Mat::create(_ndims, _sizes, DatType<_Tp>::type)
void create(int _ndims, const int* _sizes);
+ //! equivalent to Mat::release()
+ void release();
//! cross-product
Mat_ cross(const Mat_& m) const;
//! data type conversion
@@ -2174,6 +2283,12 @@ public:
//! conversion to vector.
operator std::vector<_Tp>() const;
+
+#ifdef CV_CXX_STD_ARRAY
+ //! conversion to array.
+ template<std::size_t _Nm> operator std::array<_Tp, _Nm>() const;
+#endif
+
//! conversion to Vec
template<int n> operator Vec<typename DataType<_Tp>::channel_type, n>() const;
//! conversion to Matx
@@ -2248,6 +2363,7 @@ public:
UMat(const UMat& m, const std::vector<Range>& ranges);
//! builds matrix from std::vector with or without copying the data
template<typename _Tp> explicit UMat(const std::vector<_Tp>& vec, bool copyData=false);
+
//! builds matrix from cv::Vec; the data is copied by default
template<typename _Tp, int n> explicit UMat(const Vec<_Tp, n>& vec, bool copyData=true);
//! builds matrix from cv::Matx; the data is copied by default
@@ -2277,9 +2393,9 @@ public:
UMat colRange(int startcol, int endcol) const;
UMat colRange(const Range& r) const;
//! ... for the specified diagonal
- // (d=0 - the main diagonal,
- // >0 - a diagonal from the lower half,
- // <0 - a diagonal from the upper half)
+ //! (d=0 - the main diagonal,
+ //! >0 - a diagonal from the upper half,
+ //! <0 - a diagonal from the lower half)
UMat diag(int d=0) const;
//! constructs a square diagonal matrix which main diagonal is vector "d"
static UMat diag(const UMat& d);
@@ -2388,6 +2504,10 @@ public:
UMat& operator = (UMat&& m);
#endif
+ /*! Returns the OpenCL buffer handle on which UMat operates on.
+ The UMat instance should be kept alive during the use of the handle to prevent the buffer to be
+ returned to the OpenCV buffer pool.
+ */
void* handle(int accessFlags) const;
void ndoffset(size_t* ofs) const;
@@ -2585,11 +2705,11 @@ public:
/*!
@param [out] m - output matrix; if it does not have a proper size or type before the operation,
it is reallocated
- @param [in] rtype – desired output matrix type or, rather, the depth since the number of channels
+ @param [in] rtype - desired output matrix type or, rather, the depth since the number of channels
are the same as the input has; if rtype is negative, the output matrix will have the
same type as the input.
- @param [in] alpha – optional scale factor
- @param [in] beta – optional delta added to the scaled values
+ @param [in] alpha - optional scale factor
+ @param [in] beta - optional delta added to the scaled values
*/
void convertTo( Mat& m, int rtype, double alpha=1, double beta=0 ) const;
@@ -2863,9 +2983,7 @@ public:
typedef const uchar** pointer;
typedef uchar* reference;
-#ifndef OPENCV_NOSTL
typedef std::random_access_iterator_tag iterator_category;
-#endif
//! default constructor
MatConstIterator();
@@ -2930,9 +3048,7 @@ public:
typedef const _Tp* pointer;
typedef const _Tp& reference;
-#ifndef OPENCV_NOSTL
typedef std::random_access_iterator_tag iterator_category;
-#endif
//! default constructor
MatConstIterator_();
@@ -2983,9 +3099,7 @@ public:
typedef _Tp* pointer;
typedef _Tp& reference;
-#ifndef OPENCV_NOSTL
typedef std::random_access_iterator_tag iterator_category;
-#endif
//! the default constructor
MatIterator_();
@@ -3119,9 +3233,7 @@ template<typename _Tp> class SparseMatConstIterator_ : public SparseMatConstIter
{
public:
-#ifndef OPENCV_NOSTL
typedef std::forward_iterator_tag iterator_category;
-#endif
//! the default constructor
SparseMatConstIterator_();
@@ -3155,9 +3267,7 @@ template<typename _Tp> class SparseMatIterator_ : public SparseMatConstIterator_
{
public:
-#ifndef OPENCV_NOSTL
typedef std::forward_iterator_tag iterator_category;
-#endif
//! the default constructor
SparseMatIterator_();
diff --git a/modules/core/include/opencv2/core/mat.inl.hpp b/modules/core/include/opencv2/core/mat.inl.hpp
index 4a32de1..2df2e40 100644
--- a/modules/core/include/opencv2/core/mat.inl.hpp
+++ b/modules/core/include/opencv2/core/mat.inl.hpp
@@ -49,8 +49,15 @@
# error mat.inl.hpp header must be compiled as C++
#endif
+#ifdef _MSC_VER
+#pragma warning( push )
+#pragma warning( disable: 4127 )
+#endif
+
namespace cv
{
+CV__DEBUG_NS_BEGIN
+
//! @cond IGNORED
@@ -77,6 +84,16 @@ template<typename _Tp> inline
_InputArray::_InputArray(const std::vector<_Tp>& vec)
{ init(FIXED_TYPE + STD_VECTOR + DataType<_Tp>::type + ACCESS_READ, &vec); }
+#ifdef CV_CXX_STD_ARRAY
+template<typename _Tp, std::size_t _Nm> inline
+_InputArray::_InputArray(const std::array<_Tp, _Nm>& arr)
+{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + DataType<_Tp>::type + ACCESS_READ, arr.data(), Size(1, _Nm)); }
+
+template<std::size_t _Nm> inline
+_InputArray::_InputArray(const std::array<Mat, _Nm>& arr)
+{ init(STD_ARRAY_MAT + ACCESS_READ, arr.data(), Size(1, _Nm)); }
+#endif
+
inline
_InputArray::_InputArray(const std::vector<bool>& vec)
{ init(FIXED_TYPE + STD_BOOL_VECTOR + DataType<bool>::type + ACCESS_READ, &vec); }
@@ -85,6 +102,10 @@ template<typename _Tp> inline
_InputArray::_InputArray(const std::vector<std::vector<_Tp> >& vec)
{ init(FIXED_TYPE + STD_VECTOR_VECTOR + DataType<_Tp>::type + ACCESS_READ, &vec); }
+inline
+_InputArray::_InputArray(const std::vector<std::vector<bool> >&)
+{ CV_Error(Error::StsUnsupportedFormat, "std::vector<std::vector<bool> > is not supported!\n"); }
+
template<typename _Tp> inline
_InputArray::_InputArray(const std::vector<Mat_<_Tp> >& vec)
{ init(FIXED_TYPE + STD_VECTOR_MAT + DataType<_Tp>::type + ACCESS_READ, &vec); }
@@ -133,7 +154,9 @@ inline bool _InputArray::isUMat() const { return kind() == _InputArray::UMAT; }
inline bool _InputArray::isMatVector() const { return kind() == _InputArray::STD_VECTOR_MAT; }
inline bool _InputArray::isUMatVector() const { return kind() == _InputArray::STD_VECTOR_UMAT; }
inline bool _InputArray::isMatx() const { return kind() == _InputArray::MATX; }
-inline bool _InputArray::isVector() const { return kind() == _InputArray::STD_VECTOR || kind() == _InputArray::STD_BOOL_VECTOR; }
+inline bool _InputArray::isVector() const { return kind() == _InputArray::STD_VECTOR ||
+ kind() == _InputArray::STD_BOOL_VECTOR ||
+ kind() == _InputArray::STD_ARRAY; }
inline bool _InputArray::isGpuMatVector() const { return kind() == _InputArray::STD_VECTOR_CUDA_GPU_MAT; }
////////////////////////////////////////////////////////////////////////////////////////
@@ -149,6 +172,16 @@ template<typename _Tp> inline
_OutputArray::_OutputArray(std::vector<_Tp>& vec)
{ init(FIXED_TYPE + STD_VECTOR + DataType<_Tp>::type + ACCESS_WRITE, &vec); }
+#ifdef CV_CXX_STD_ARRAY
+template<typename _Tp, std::size_t _Nm> inline
+_OutputArray::_OutputArray(std::array<_Tp, _Nm>& arr)
+{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + DataType<_Tp>::type + ACCESS_WRITE, arr.data(), Size(1, _Nm)); }
+
+template<std::size_t _Nm> inline
+_OutputArray::_OutputArray(std::array<Mat, _Nm>& arr)
+{ init(STD_ARRAY_MAT + ACCESS_WRITE, arr.data(), Size(1, _Nm)); }
+#endif
+
inline
_OutputArray::_OutputArray(std::vector<bool>&)
{ CV_Error(Error::StsUnsupportedFormat, "std::vector<bool> cannot be an output array\n"); }
@@ -157,6 +190,10 @@ template<typename _Tp> inline
_OutputArray::_OutputArray(std::vector<std::vector<_Tp> >& vec)
{ init(FIXED_TYPE + STD_VECTOR_VECTOR + DataType<_Tp>::type + ACCESS_WRITE, &vec); }
+inline
+_OutputArray::_OutputArray(std::vector<std::vector<bool> >&)
+{ CV_Error(Error::StsUnsupportedFormat, "std::vector<std::vector<bool> > cannot be an output array\n"); }
+
template<typename _Tp> inline
_OutputArray::_OutputArray(std::vector<Mat_<_Tp> >& vec)
{ init(FIXED_TYPE + STD_VECTOR_MAT + DataType<_Tp>::type + ACCESS_WRITE, &vec); }
@@ -177,6 +214,16 @@ template<typename _Tp> inline
_OutputArray::_OutputArray(const std::vector<_Tp>& vec)
{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR + DataType<_Tp>::type + ACCESS_WRITE, &vec); }
+#ifdef CV_CXX_STD_ARRAY
+template<typename _Tp, std::size_t _Nm> inline
+_OutputArray::_OutputArray(const std::array<_Tp, _Nm>& arr)
+{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + DataType<_Tp>::type + ACCESS_WRITE, arr.data(), Size(1, _Nm)); }
+
+template<std::size_t _Nm> inline
+_OutputArray::_OutputArray(const std::array<Mat, _Nm>& arr)
+{ init(FIXED_SIZE + STD_ARRAY_MAT + ACCESS_WRITE, arr.data(), Size(1, _Nm)); }
+#endif
+
template<typename _Tp> inline
_OutputArray::_OutputArray(const std::vector<std::vector<_Tp> >& vec)
{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_VECTOR + DataType<_Tp>::type + ACCESS_WRITE, &vec); }
@@ -244,6 +291,16 @@ template<typename _Tp> inline
_InputOutputArray::_InputOutputArray(std::vector<_Tp>& vec)
{ init(FIXED_TYPE + STD_VECTOR + DataType<_Tp>::type + ACCESS_RW, &vec); }
+#ifdef CV_CXX_STD_ARRAY
+template<typename _Tp, std::size_t _Nm> inline
+_InputOutputArray::_InputOutputArray(std::array<_Tp, _Nm>& arr)
+{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + DataType<_Tp>::type + ACCESS_RW, arr.data(), Size(1, _Nm)); }
+
+template<std::size_t _Nm> inline
+_InputOutputArray::_InputOutputArray(std::array<Mat, _Nm>& arr)
+{ init(STD_ARRAY_MAT + ACCESS_RW, arr.data(), Size(1, _Nm)); }
+#endif
+
inline _InputOutputArray::_InputOutputArray(std::vector<bool>&)
{ CV_Error(Error::StsUnsupportedFormat, "std::vector<bool> cannot be an input/output array\n"); }
@@ -271,6 +328,16 @@ template<typename _Tp> inline
_InputOutputArray::_InputOutputArray(const std::vector<_Tp>& vec)
{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR + DataType<_Tp>::type + ACCESS_RW, &vec); }
+#ifdef CV_CXX_STD_ARRAY
+template<typename _Tp, std::size_t _Nm> inline
+_InputOutputArray::_InputOutputArray(const std::array<_Tp, _Nm>& arr)
+{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + DataType<_Tp>::type + ACCESS_RW, arr.data(), Size(1, _Nm)); }
+
+template<std::size_t _Nm> inline
+_InputOutputArray::_InputOutputArray(const std::array<Mat, _Nm>& arr)
+{ init(FIXED_SIZE + STD_ARRAY_MAT + ACCESS_RW, arr.data(), Size(1, _Nm)); }
+#endif
+
template<typename _Tp> inline
_InputOutputArray::_InputOutputArray(const std::vector<std::vector<_Tp> >& vec)
{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_VECTOR + DataType<_Tp>::type + ACCESS_RW, &vec); }
@@ -327,18 +394,20 @@ inline _InputOutputArray::_InputOutputArray(const ogl::Buffer& buf)
inline _InputOutputArray::_InputOutputArray(const cuda::HostMem& cuda_mem)
{ init(FIXED_TYPE + FIXED_SIZE + CUDA_HOST_MEM + ACCESS_RW, &cuda_mem); }
+CV__DEBUG_NS_END
+
//////////////////////////////////////////// Mat //////////////////////////////////////////
inline
Mat::Mat()
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
- datalimit(0), allocator(0), u(0), size(&rows)
+ datalimit(0), allocator(0), u(0), size(&rows), step(0)
{}
inline
Mat::Mat(int _rows, int _cols, int _type)
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
- datalimit(0), allocator(0), u(0), size(&rows)
+ datalimit(0), allocator(0), u(0), size(&rows), step(0)
{
create(_rows, _cols, _type);
}
@@ -346,7 +415,7 @@ Mat::Mat(int _rows, int _cols, int _type)
inline
Mat::Mat(int _rows, int _cols, int _type, const Scalar& _s)
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
- datalimit(0), allocator(0), u(0), size(&rows)
+ datalimit(0), allocator(0), u(0), size(&rows), step(0)
{
create(_rows, _cols, _type);
*this = _s;
@@ -355,7 +424,7 @@ Mat::Mat(int _rows, int _cols, int _type, const Scalar& _s)
inline
Mat::Mat(Size _sz, int _type)
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
- datalimit(0), allocator(0), u(0), size(&rows)
+ datalimit(0), allocator(0), u(0), size(&rows), step(0)
{
create( _sz.height, _sz.width, _type );
}
@@ -363,7 +432,7 @@ Mat::Mat(Size _sz, int _type)
inline
Mat::Mat(Size _sz, int _type, const Scalar& _s)
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
- datalimit(0), allocator(0), u(0), size(&rows)
+ datalimit(0), allocator(0), u(0), size(&rows), step(0)
{
create(_sz.height, _sz.width, _type);
*this = _s;
@@ -372,7 +441,7 @@ Mat::Mat(Size _sz, int _type, const Scalar& _s)
inline
Mat::Mat(int _dims, const int* _sz, int _type)
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
- datalimit(0), allocator(0), u(0), size(&rows)
+ datalimit(0), allocator(0), u(0), size(&rows), step(0)
{
create(_dims, _sz, _type);
}
@@ -380,7 +449,7 @@ Mat::Mat(int _dims, const int* _sz, int _type)
inline
Mat::Mat(int _dims, const int* _sz, int _type, const Scalar& _s)
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
- datalimit(0), allocator(0), u(0), size(&rows)
+ datalimit(0), allocator(0), u(0), size(&rows), step(0)
{
create(_dims, _sz, _type);
*this = _s;
@@ -389,7 +458,7 @@ Mat::Mat(int _dims, const int* _sz, int _type, const Scalar& _s)
inline
Mat::Mat(const std::vector<int>& _sz, int _type)
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
- datalimit(0), allocator(0), u(0), size(&rows)
+ datalimit(0), allocator(0), u(0), size(&rows), step(0)
{
create(_sz, _type);
}
@@ -397,7 +466,7 @@ Mat::Mat(const std::vector<int>& _sz, int _type)
inline
Mat::Mat(const std::vector<int>& _sz, int _type, const Scalar& _s)
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
- datalimit(0), allocator(0), u(0), size(&rows)
+ datalimit(0), allocator(0), u(0), size(&rows), step(0)
{
create(_sz, _type);
*this = _s;
@@ -407,7 +476,7 @@ inline
Mat::Mat(const Mat& m)
: flags(m.flags), dims(m.dims), rows(m.rows), cols(m.cols), data(m.data),
datastart(m.datastart), dataend(m.dataend), datalimit(m.datalimit), allocator(m.allocator),
- u(m.u), size(&rows)
+ u(m.u), size(&rows), step(0)
{
if( u )
CV_XADD(&u->refcount, 1);
@@ -491,7 +560,7 @@ Mat::Mat(Size _sz, int _type, void* _data, size_t _step)
template<typename _Tp> inline
Mat::Mat(const std::vector<_Tp>& vec, bool copyData)
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()),
- cols(1), data(0), datastart(0), dataend(0), allocator(0), u(0), size(&rows)
+ cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
{
if(vec.empty())
return;
@@ -505,10 +574,41 @@ Mat::Mat(const std::vector<_Tp>& vec, bool copyData)
Mat((int)vec.size(), 1, DataType<_Tp>::type, (uchar*)&vec[0]).copyTo(*this);
}
+#ifdef CV_CXX11
+template<typename _Tp> inline
+Mat::Mat(const std::initializer_list<_Tp> list)
+ : flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows((int)list.size()),
+ cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
+{
+ if(list.size() == 0)
+ return;
+ Mat((int)list.size(), 1, DataType<_Tp>::type, (uchar*)list.begin()).copyTo(*this);
+}
+#endif
+
+#ifdef CV_CXX_STD_ARRAY
+template<typename _Tp, std::size_t _Nm> inline
+Mat::Mat(const std::array<_Tp, _Nm>& arr, bool copyData)
+ : flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows((int)arr.size()),
+ cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
+{
+ if(arr.empty())
+ return;
+ if( !copyData )
+ {
+ step[0] = step[1] = sizeof(_Tp);
+ datastart = data = (uchar*)arr.data();
+ datalimit = dataend = datastart + rows * step[0];
+ }
+ else
+ Mat((int)arr.size(), 1, DataType<_Tp>::type, (uchar*)arr.data()).copyTo(*this);
+}
+#endif
+
template<typename _Tp, int n> inline
Mat::Mat(const Vec<_Tp, n>& vec, bool copyData)
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows(n), cols(1), data(0),
- datastart(0), dataend(0), allocator(0), u(0), size(&rows)
+ datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
{
if( !copyData )
{
@@ -524,7 +624,7 @@ Mat::Mat(const Vec<_Tp, n>& vec, bool copyData)
template<typename _Tp, int m, int n> inline
Mat::Mat(const Matx<_Tp,m,n>& M, bool copyData)
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows(m), cols(n), data(0),
- datastart(0), dataend(0), allocator(0), u(0), size(&rows)
+ datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
{
if( !copyData )
{
@@ -540,7 +640,7 @@ Mat::Mat(const Matx<_Tp,m,n>& M, bool copyData)
template<typename _Tp> inline
Mat::Mat(const Point_<_Tp>& pt, bool copyData)
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows(2), cols(1), data(0),
- datastart(0), dataend(0), allocator(0), u(0), size(&rows)
+ datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
{
if( !copyData )
{
@@ -559,7 +659,7 @@ Mat::Mat(const Point_<_Tp>& pt, bool copyData)
template<typename _Tp> inline
Mat::Mat(const Point3_<_Tp>& pt, bool copyData)
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows(3), cols(1), data(0),
- datastart(0), dataend(0), allocator(0), u(0), size(&rows)
+ datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0)
{
if( !copyData )
{
@@ -793,7 +893,7 @@ size_t Mat::step1(int i) const
inline
bool Mat::empty() const
{
- return data == 0 || total() == 0;
+ return data == 0 || total() == 0 || dims == 0;
}
inline
@@ -808,6 +908,17 @@ size_t Mat::total() const
}
inline
+size_t Mat::total(int startDim, int endDim) const
+{
+ CV_Assert( 0 <= startDim && startDim <= endDim);
+ size_t p = 1;
+ int endDim_ = endDim <= dims ? endDim : dims;
+ for( int i = startDim; i < endDim_; i++ )
+ p *= size[i];
+ return p;
+}
+
+inline
uchar* Mat::ptr(int y)
{
CV_DbgAssert( y == 0 || (data && dims >= 1 && (unsigned)y < (unsigned)size.p[0]) );
@@ -1114,6 +1225,16 @@ Mat::operator std::vector<_Tp>() const
return v;
}
+#ifdef CV_CXX_STD_ARRAY
+template<typename _Tp, std::size_t _Nm> inline
+Mat::operator std::array<_Tp, _Nm>() const
+{
+ std::array<_Tp, _Nm> v;
+ copyTo(v);
+ return v;
+}
+#endif
+
template<typename _Tp, int n> inline
Mat::operator Vec<_Tp, n>() const
{
@@ -1468,6 +1589,20 @@ Mat_<_Tp>::Mat_(const std::vector<_Tp>& vec, bool copyData)
: Mat(vec, copyData)
{}
+#ifdef CV_CXX11
+template<typename _Tp> inline
+Mat_<_Tp>::Mat_(std::initializer_list<_Tp> list)
+ : Mat(list)
+{}
+#endif
+
+#ifdef CV_CXX_STD_ARRAY
+template<typename _Tp> template<std::size_t _Nm> inline
+Mat_<_Tp>::Mat_(const std::array<_Tp, _Nm>& arr, bool copyData)
+ : Mat(arr, copyData)
+{}
+#endif
+
template<typename _Tp> inline
Mat_<_Tp>& Mat_<_Tp>::operator = (const Mat& m)
{
@@ -1519,6 +1654,15 @@ void Mat_<_Tp>::create(int _dims, const int* _sz)
}
template<typename _Tp> inline
+void Mat_<_Tp>::release()
+{
+ Mat::release();
+#ifdef _DEBUG
+ flags = (flags & ~CV_MAT_TYPE_MASK) | DataType<_Tp>::type;
+#endif
+}
+
+template<typename _Tp> inline
Mat_<_Tp> Mat_<_Tp>::cross(const Mat_& m) const
{
return Mat_<_Tp>(Mat::cross(m));
@@ -1634,14 +1778,14 @@ Mat_<_Tp> Mat_<_Tp>::operator()(const std::vector<Range>& ranges) const
template<typename _Tp> inline
_Tp* Mat_<_Tp>::operator [](int y)
{
- CV_DbgAssert( 0 <= y && y < rows );
+ CV_DbgAssert( 0 <= y && y < size.p[0] );
return (_Tp*)(data + y*step.p[0]);
}
template<typename _Tp> inline
const _Tp* Mat_<_Tp>::operator [](int y) const
{
- CV_DbgAssert( 0 <= y && y < rows );
+ CV_DbgAssert( 0 <= y && y < size.p[0] );
return (const _Tp*)(data + y*step.p[0]);
}
@@ -1745,6 +1889,16 @@ Mat_<_Tp>::operator std::vector<_Tp>() const
return v;
}
+#ifdef CV_CXX_STD_ARRAY
+template<typename _Tp> template<std::size_t _Nm> inline
+Mat_<_Tp>::operator std::array<_Tp, _Nm>() const
+{
+ std::array<_Tp, _Nm> a;
+ copyTo(a);
+ return a;
+}
+#endif
+
template<typename _Tp> template<int n> inline
Mat_<_Tp>::operator Vec<typename DataType<_Tp>::channel_type, n>() const
{
@@ -1818,7 +1972,7 @@ Mat_<_Tp>::Mat_(Mat_&& m)
template<typename _Tp> inline
Mat_<_Tp>& Mat_<_Tp>::operator = (Mat_&& m)
{
- Mat::operator = (m);
+ Mat::operator = (std::move(m));
return *this;
}
@@ -3426,7 +3580,6 @@ cols(1), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows)
Mat((int)vec.size(), 1, DataType<_Tp>::type, (uchar*)&vec[0]).copyTo(*this);
}
-
inline
UMat& UMat::operator = (const UMat& m)
{
@@ -3614,7 +3767,7 @@ size_t UMat::step1(int i) const
inline
bool UMat::empty() const
{
- return u == 0 || total() == 0;
+ return u == 0 || total() == 0 || dims == 0;
}
inline
@@ -3730,4 +3883,8 @@ inline UMatDataAutoLock::~UMatDataAutoLock() { u->unlock(); }
} //cv
+#ifdef _MSC_VER
+#pragma warning( pop )
+#endif
+
#endif
diff --git a/modules/core/include/opencv2/core/matx.hpp b/modules/core/include/opencv2/core/matx.hpp
index 0d07c3f..6469962 100644
--- a/modules/core/include/opencv2/core/matx.hpp
+++ b/modules/core/include/opencv2/core/matx.hpp
@@ -53,6 +53,10 @@
#include "opencv2/core/traits.hpp"
#include "opencv2/core/saturate.hpp"
+#ifdef CV_CXX11
+#include <initializer_list>
+#endif
+
namespace cv
{
@@ -77,12 +81,21 @@ If you need a more flexible type, use Mat . The elements of the matrix M are acc
M(i,j) notation. Most of the common matrix operations (see also @ref MatrixExpressions ) are
available. To do an operation on Matx that is not implemented, you can easily convert the matrix to
Mat and backwards:
- at code
+ at code{.cpp}
Matx33f m(1, 2, 3,
4, 5, 6,
7, 8, 9);
cout << sum(Mat(m*m.t())) << endl;
- @endcode
+ at endcode
+Except of the plain constructor which takes a list of elements, Matx can be initialized from a C-array:
+ at code{.cpp}
+ float values[] = { 1, 2, 3};
+ Matx31f m(values);
+ at endcode
+In case if C++11 features are avaliable, std::initializer_list can be also used to initizlize Matx:
+ at code{.cpp}
+ Matx31f m = { 1, 2, 3};
+ at endcode
*/
template<typename _Tp, int m, int n> class Matx
{
@@ -125,6 +138,10 @@ public:
_Tp v12, _Tp v13, _Tp v14, _Tp v15); //!< 1x16, 4x4 or 16x1 matrix
explicit Matx(const _Tp* vals); //!< initialize from a plain array
+#ifdef CV_CXX11
+ Matx(std::initializer_list<_Tp>); //!< initialize from an initializer list
+#endif
+
static Matx all(_Tp alpha);
static Matx zeros();
static Matx ones();
@@ -327,6 +344,10 @@ public:
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11, _Tp v12, _Tp v13); //!< 14-element vector constructor
explicit Vec(const _Tp* values);
+#ifdef CV_CXX11
+ Vec(std::initializer_list<_Tp>);
+#endif
+
Vec(const Vec<_Tp, cn>& v);
static Vec all(_Tp alpha);
@@ -590,11 +611,12 @@ Matx<_Tp,m,n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp
template<typename _Tp, int m, int n> inline
Matx<_Tp,m,n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11, _Tp v12, _Tp v13)
{
- CV_StaticAssert(channels == 14, "Matx should have at least 14 elements.");
+ CV_StaticAssert(channels >= 14, "Matx should have at least 14 elements.");
val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3;
val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7;
val[8] = v8; val[9] = v9; val[10] = v10; val[11] = v11;
val[12] = v12; val[13] = v13;
+ for (int i = 14; i < channels; i++) val[i] = _Tp(0);
}
@@ -615,6 +637,19 @@ Matx<_Tp, m, n>::Matx(const _Tp* values)
for( int i = 0; i < channels; i++ ) val[i] = values[i];
}
+#ifdef CV_CXX11
+template<typename _Tp, int m, int n> inline
+Matx<_Tp, m, n>::Matx(std::initializer_list<_Tp> list)
+{
+ CV_DbgAssert(list.size() == channels);
+ int i = 0;
+ for(const auto& elem : list)
+ {
+ val[i++] = elem;
+ }
+}
+#endif
+
template<typename _Tp, int m, int n> inline
Matx<_Tp, m, n> Matx<_Tp, m, n>::all(_Tp alpha)
{
@@ -956,6 +991,12 @@ template<typename _Tp, int cn> inline
Vec<_Tp, cn>::Vec(const _Tp* values)
: Matx<_Tp, cn, 1>(values) {}
+#ifdef CV_CXX11
+template<typename _Tp, int cn> inline
+Vec<_Tp, cn>::Vec(std::initializer_list<_Tp> list)
+ : Matx<_Tp, cn, 1>(list) {}
+#endif
+
template<typename _Tp, int cn> inline
Vec<_Tp, cn>::Vec(const Vec<_Tp, cn>& m)
: Matx<_Tp, cn, 1>(m.val) {}
@@ -1080,7 +1121,7 @@ Vec<_Tp, cn> normalize(const Vec<_Tp, cn>& v)
-//////////////////////////////// matx comma initializer //////////////////////////////////
+//////////////////////////////// vec comma initializer //////////////////////////////////
template<typename _Tp, typename _T2, int cn> static inline
diff --git a/modules/core/include/opencv2/core/ocl.hpp b/modules/core/include/opencv2/core/ocl.hpp
index 1a9549d..2fb02b9 100644
--- a/modules/core/include/opencv2/core/ocl.hpp
+++ b/modules/core/include/opencv2/core/ocl.hpp
@@ -160,6 +160,8 @@ public:
uint imagePitchAlignment() const;
uint imageBaseAddressAlignment() const;
+ bool intelSubgroupsSupport() const;
+
size_t image2DMaxWidth() const;
size_t image2DMaxHeight() const;
@@ -276,55 +278,38 @@ protected:
Impl* p;
};
-/*
-//! @brief Attaches OpenCL context to OpenCV
-//
-//! @note Note:
-// OpenCV will check if available OpenCL platform has platformName name,
-// then assign context to OpenCV and call clRetainContext function.
-// The deviceID device will be used as target device and new command queue
-// will be created.
-//
-// Params:
-//! @param platformName - name of OpenCL platform to attach,
-//! this string is used to check if platform is available
-//! to OpenCV at runtime
-//! @param platfromID - ID of platform attached context was created for
-//! @param context - OpenCL context to be attached to OpenCV
-//! @param deviceID - ID of device, must be created from attached context
+/** @brief Attaches OpenCL context to OpenCV
+ at note
+ OpenCV will check if available OpenCL platform has platformName name, then assign context to
+ OpenCV and call `clRetainContext` function. The deviceID device will be used as target device and
+ new command queue will be created.
+ at param platformName name of OpenCL platform to attach, this string is used to check if platform is available to OpenCV at runtime
+ at param platformID ID of platform attached context was created for
+ at param context OpenCL context to be attached to OpenCV
+ at param deviceID ID of device, must be created from attached context
*/
CV_EXPORTS void attachContext(const String& platformName, void* platformID, void* context, void* deviceID);
-/*
-//! @brief Convert OpenCL buffer to UMat
-//
-//! @note Note:
-// OpenCL buffer (cl_mem_buffer) should contain 2D image data, compatible with OpenCV.
-// Memory content is not copied from clBuffer to UMat. Instead, buffer handle assigned
-// to UMat and clRetainMemObject is called.
-//
-// Params:
-//! @param cl_mem_buffer - source clBuffer handle
-//! @param step - num of bytes in single row
-//! @param rows - number of rows
-//! @param cols - number of cols
-//! @param type - OpenCV type of image
-//! @param dst - destination UMat
+/** @brief Convert OpenCL buffer to UMat
+ at note
+ OpenCL buffer (cl_mem_buffer) should contain 2D image data, compatible with OpenCV. Memory
+ content is not copied from `clBuffer` to UMat. Instead, buffer handle assigned to UMat and
+ `clRetainMemObject` is called.
+ at param cl_mem_buffer source clBuffer handle
+ at param step num of bytes in single row
+ at param rows number of rows
+ at param cols number of cols
+ at param type OpenCV type of image
+ at param dst destination UMat
*/
CV_EXPORTS void convertFromBuffer(void* cl_mem_buffer, size_t step, int rows, int cols, int type, UMat& dst);
-/*
-//! @brief Convert OpenCL image2d_t to UMat
-//
-//! @note Note:
-// OpenCL image2d_t (cl_mem_image), should be compatible with OpenCV
-// UMat formats.
-// Memory content is copied from image to UMat with
-// clEnqueueCopyImageToBuffer function.
-//
-// Params:
-//! @param cl_mem_image - source image2d_t handle
-//! @param dst - destination UMat
+/** @brief Convert OpenCL image2d_t to UMat
+ at note
+ OpenCL `image2d_t` (cl_mem_image), should be compatible with OpenCV UMat formats. Memory content
+ is copied from image to UMat with `clEnqueueCopyImageToBuffer` function.
+ at param cl_mem_image source image2d_t handle
+ at param dst destination UMat
*/
CV_EXPORTS void convertFromImage(void* cl_mem_image, UMat& dst);
@@ -567,14 +552,12 @@ public:
i = set(i, a6); i = set(i, a7); i = set(i, a8); i = set(i, a9); i = set(i, a10); i = set(i, a11);
i = set(i, a12); i = set(i, a13); i = set(i, a14); set(i, a15); return *this;
}
- /*
- Run the OpenCL kernel.
+ /** @brief Run the OpenCL kernel.
@param dims the work problem dimensions. It is the length of globalsize and localsize. It can be either 1, 2 or 3.
- @param globalsize work items for each dimension.
- It is not the final globalsize passed to OpenCL.
- Each dimension will be adjusted to the nearest integer divisible by the corresponding value in localsize.
- If localsize is NULL, it will still be adjusted depending on dims.
- The adjusted values are greater than or equal to the original values.
+ @param globalsize work items for each dimension. It is not the final globalsize passed to
+ OpenCL. Each dimension will be adjusted to the nearest integer divisible by the corresponding
+ value in localsize. If localsize is NULL, it will still be adjusted depending on dims. The
+ adjusted values are greater than or equal to the original values.
@param localsize work-group size for each dimension.
@param sync specify whether to wait for OpenCL computation to finish before return.
@param q command queue
@@ -627,17 +610,18 @@ protected:
class CV_EXPORTS ProgramSource
{
public:
- typedef uint64 hash_t;
+ typedef uint64 hash_t; // deprecated
ProgramSource();
- explicit ProgramSource(const String& prog);
- explicit ProgramSource(const char* prog);
+ explicit ProgramSource(const String& module, const String& name, const String& codeStr, const String& codeHash);
+ explicit ProgramSource(const String& prog); // deprecated
+ explicit ProgramSource(const char* prog); // deprecated
~ProgramSource();
ProgramSource(const ProgramSource& prog);
ProgramSource& operator = (const ProgramSource& prog);
const String& source() const;
- hash_t hash() const;
+ hash_t hash() const; // deprecated
protected:
struct Impl;
@@ -708,22 +692,25 @@ class CV_EXPORTS Image2D
public:
Image2D();
- // src: The UMat from which to get image properties and data
- // norm: Flag to enable the use of normalized channel data types
- // alias: Flag indicating that the image should alias the src UMat.
- // If true, changes to the image or src will be reflected in
- // both objects.
+ /**
+ @param src UMat object from which to get image properties and data
+ @param norm flag to enable the use of normalized channel data types
+ @param alias flag indicating that the image should alias the src UMat. If true, changes to the
+ image or src will be reflected in both objects.
+ */
explicit Image2D(const UMat &src, bool norm = false, bool alias = false);
Image2D(const Image2D & i);
~Image2D();
Image2D & operator = (const Image2D & i);
- // Indicates if creating an aliased image should succeed. Depends on the
- // underlying platform and the dimensions of the UMat.
+ /** Indicates if creating an aliased image should succeed.
+ Depends on the underlying platform and the dimensions of the UMat.
+ */
static bool canCreateAlias(const UMat &u);
- // Indicates if the image format is supported.
+ /** Indicates if the image format is supported.
+ */
static bool isFormatSupported(int depth, int cn, bool norm);
void* ptr() const;
diff --git a/modules/core/include/opencv2/core/ocl_genbase.hpp b/modules/core/include/opencv2/core/ocl_genbase.hpp
index 5408958..5334cf1 100644
--- a/modules/core/include/opencv2/core/ocl_genbase.hpp
+++ b/modules/core/include/opencv2/core/ocl_genbase.hpp
@@ -42,23 +42,28 @@
#ifndef OPENCV_OPENCL_GENBASE_HPP
#define OPENCV_OPENCL_GENBASE_HPP
-namespace cv
-{
-namespace ocl
-{
-
//! @cond IGNORED
-struct ProgramEntry
+namespace cv {
+namespace ocl {
+
+class ProgramSource;
+
+namespace internal {
+
+struct CV_EXPORTS ProgramEntry
{
+ const char* module;
const char* name;
- const char* programStr;
+ const char* programCode;
const char* programHash;
+ ProgramSource* pProgramSource;
+
+ operator ProgramSource& () const;
};
-//! @endcond
+} } } // namespace
-}
-}
+//! @endcond
#endif
diff --git a/modules/core/include/opencv2/core/opencl/runtime/opencl_clamdblas.hpp b/modules/core/include/opencv2/core/opencl/runtime/opencl_clamdblas.hpp
index 039ea97..a64447e 100644
--- a/modules/core/include/opencv2/core/opencl/runtime/opencl_clamdblas.hpp
+++ b/modules/core/include/opencv2/core/opencl/runtime/opencl_clamdblas.hpp
@@ -45,7 +45,7 @@
#ifdef HAVE_CLAMDBLAS
#ifndef CL_RUNTIME_EXPORT
-#if (defined(BUILD_SHARED_LIBS) || defined(OPENCV_CORE_SHARED)) && (defined WIN32 || defined _WIN32 || defined WINCE)
+#if (defined(BUILD_SHARED_LIBS) || defined(OPENCV_CORE_SHARED)) && (defined _WIN32 || defined WINCE)
#define CL_RUNTIME_EXPORT __declspec(dllimport)
#else
#define CL_RUNTIME_EXPORT
diff --git a/modules/core/include/opencv2/core/opencl/runtime/opencl_clamdfft.hpp b/modules/core/include/opencv2/core/opencl/runtime/opencl_clamdfft.hpp
index 94037e9..e96dad2 100644
--- a/modules/core/include/opencv2/core/opencl/runtime/opencl_clamdfft.hpp
+++ b/modules/core/include/opencv2/core/opencl/runtime/opencl_clamdfft.hpp
@@ -45,7 +45,7 @@
#ifdef HAVE_CLAMDFFT
#ifndef CL_RUNTIME_EXPORT
-#if (defined(BUILD_SHARED_LIBS) || defined(OPENCV_CORE_SHARED)) && (defined WIN32 || defined _WIN32 || defined WINCE)
+#if (defined(BUILD_SHARED_LIBS) || defined(OPENCV_CORE_SHARED)) && (defined _WIN32 || defined WINCE)
#define CL_RUNTIME_EXPORT __declspec(dllimport)
#else
#define CL_RUNTIME_EXPORT
diff --git a/modules/core/include/opencv2/core/opencl/runtime/opencl_core.hpp b/modules/core/include/opencv2/core/opencl/runtime/opencl_core.hpp
index f86dfc0..492e762 100644
--- a/modules/core/include/opencv2/core/opencl/runtime/opencl_core.hpp
+++ b/modules/core/include/opencv2/core/opencl/runtime/opencl_core.hpp
@@ -55,7 +55,7 @@
#else // HAVE_OPENCL_STATIC
#ifndef CL_RUNTIME_EXPORT
-#if (defined(BUILD_SHARED_LIBS) || defined(OPENCV_CORE_SHARED)) && (defined WIN32 || defined _WIN32 || defined WINCE)
+#if (defined(BUILD_SHARED_LIBS) || defined(OPENCV_CORE_SHARED)) && (defined _WIN32 || defined WINCE)
#define CL_RUNTIME_EXPORT __declspec(dllimport)
#else
#define CL_RUNTIME_EXPORT
diff --git a/modules/core/include/opencv2/core/openvx/ovx_defs.hpp b/modules/core/include/opencv2/core/openvx/ovx_defs.hpp
index 3f055dd..a29db1b 100644
--- a/modules/core/include/opencv2/core/openvx/ovx_defs.hpp
+++ b/modules/core/include/opencv2/core/openvx/ovx_defs.hpp
@@ -20,6 +20,14 @@
#define IVX_USE_OPENCV
#include "ivx.hpp"
+namespace cv{
+namespace ovx{
+// Get common thread local OpenVX context
+CV_EXPORTS_W ivx::Context& getOpenVXContext();
+
+template <int kernel_id> inline bool skipSmallImages(int w, int h) { return w*h < 3840 * 2160; }
+}}
+
#define CV_OVX_RUN(condition, func, ...) \
if (cv::useOpenVX() && (condition) && func) \
{ \
diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp
index 4a4ad9e..9858d06 100644
--- a/modules/core/include/opencv2/core/operations.hpp
+++ b/modules/core/include/opencv2/core/operations.hpp
@@ -82,7 +82,7 @@ template<typename _Tp> struct Matx_FastInvOp<_Tp, 2>
{
bool operator()(const Matx<_Tp, 2, 2>& a, Matx<_Tp, 2, 2>& b, int) const
{
- _Tp d = determinant(a);
+ _Tp d = (_Tp)determinant(a);
if( d == 0 )
return false;
d = 1/d;
@@ -137,7 +137,7 @@ template<typename _Tp> struct Matx_FastSolveOp<_Tp, 2, 1>
bool operator()(const Matx<_Tp, 2, 2>& a, const Matx<_Tp, 2, 1>& b,
Matx<_Tp, 2, 1>& x, int) const
{
- _Tp d = determinant(a);
+ _Tp d = (_Tp)determinant(a);
if( d == 0 )
return false;
d = 1/d;
@@ -349,6 +349,8 @@ inline int RNG::uniform(int a, int b) { return a == b ? a : (int)(next(
inline float RNG::uniform(float a, float b) { return ((float)*this)*(b - a) + a; }
inline double RNG::uniform(double a, double b) { return ((double)*this)*(b - a) + a; }
+inline bool RNG::operator ==(const RNG& other) const { return state == other.state; }
+
inline unsigned RNG::next()
{
state = (uint64)(unsigned)state* /*CV_RNG_COEFF*/ 4164903690U + (unsigned)(state >> 32);
diff --git a/modules/core/include/opencv2/core/optim.hpp b/modules/core/include/opencv2/core/optim.hpp
index 7249e0f..190d543 100644
--- a/modules/core/include/opencv2/core/optim.hpp
+++ b/modules/core/include/opencv2/core/optim.hpp
@@ -73,7 +73,7 @@ public:
/** @brief Getter for the optimized function.
The optimized function is represented by Function interface, which requires derivatives to
- implement the sole method calc(double*) to evaluate the function.
+ implement the calc(double*) and getDim() methods to evaluate the function.
@return Smart-pointer to an object that implements Function interface - it represents the
function that is being optimized. It can be empty, if no function was given so far.
diff --git a/modules/core/include/opencv2/core/persistence.hpp b/modules/core/include/opencv2/core/persistence.hpp
index 3f18d54..cf09891 100644
--- a/modules/core/include/opencv2/core/persistence.hpp
+++ b/modules/core/include/opencv2/core/persistence.hpp
@@ -462,6 +462,11 @@ public:
*/
static String getDefaultObjectName(const String& filename);
+ /** @brief Returns the current format.
+ * @returns The current format, see FileStorage::Mode
+ */
+ CV_WRAP int getFormat() const;
+
Ptr<CvFileStorage> fs; //!< the underlying C FileStorage structure
String elname; //!< the currently written element
std::vector<char> structs; //!< the stack of written structures
@@ -474,7 +479,7 @@ template<> CV_EXPORTS void DefaultDeleter<CvFileStorage>::operator ()(CvFileStor
The node is used to store each and every element of the file storage opened for reading. When
XML/YAML file is read, it is first parsed and stored in the memory as a hierarchical collection of
-nodes. Each node can be a “leaf” that is contain a single number or a string, or be a collection of
+nodes. Each node can be a "leaf" that is contain a single number or a string, or be a collection of
other nodes. There can be named collections (mappings) where each element has a name and it is
accessed by a name, and ordered collections (sequences) where elements do not have names but rather
accessed by index. Type of the file node can be determined using FileNode::type method.
@@ -570,9 +575,7 @@ public:
operator double() const;
//! returns the node content as text string
operator String() const;
-#ifndef OPENCV_NOSTL
operator std::string() const;
-#endif
//! returns pointer to the underlying file node
CvFileNode* operator *();
@@ -714,6 +717,7 @@ CV_EXPORTS void read(const FileNode& node, int& value, int default_value);
CV_EXPORTS void read(const FileNode& node, float& value, float default_value);
CV_EXPORTS void read(const FileNode& node, double& value, double default_value);
CV_EXPORTS void read(const FileNode& node, String& value, const String& default_value);
+CV_EXPORTS void read(const FileNode& node, std::string& value, const std::string& default_value);
CV_EXPORTS void read(const FileNode& node, Mat& mat, const Mat& default_mat = Mat() );
CV_EXPORTS void read(const FileNode& node, SparseMat& mat, const SparseMat& default_mat = SparseMat() );
CV_EXPORTS void read(const FileNode& node, std::vector<KeyPoint>& keypoints);
@@ -945,12 +949,53 @@ void write(FileStorage& fs, const Scalar_<_Tp>& s )
}
static inline
+void write(FileStorage& fs, const KeyPoint& kpt )
+{
+ write(fs, kpt.pt.x);
+ write(fs, kpt.pt.y);
+ write(fs, kpt.size);
+ write(fs, kpt.angle);
+ write(fs, kpt.response);
+ write(fs, kpt.octave);
+ write(fs, kpt.class_id);
+}
+
+static inline
+void write(FileStorage& fs, const DMatch& m )
+{
+ write(fs, m.queryIdx);
+ write(fs, m.trainIdx);
+ write(fs, m.imgIdx);
+ write(fs, m.distance);
+}
+
+static inline
void write(FileStorage& fs, const Range& r )
{
write(fs, r.start);
write(fs, r.end);
}
+static inline
+void write( FileStorage& fs, const std::vector<KeyPoint>& vec )
+{
+ size_t npoints = vec.size();
+ for(size_t i = 0; i < npoints; i++ )
+ {
+ write(fs, vec[i]);
+ }
+}
+
+static inline
+void write( FileStorage& fs, const std::vector<DMatch>& vec )
+{
+ size_t npoints = vec.size();
+ for(size_t i = 0; i < npoints; i++ )
+ {
+ write(fs, vec[i]);
+ }
+}
+
template<typename _Tp> static inline
void write( FileStorage& fs, const std::vector<_Tp>& vec )
{
@@ -1014,6 +1059,20 @@ void write(FileStorage& fs, const String& name, const Range& r )
write(fs, r);
}
+static inline
+void write(FileStorage& fs, const String& name, const KeyPoint& r )
+{
+ cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW);
+ write(fs, r);
+}
+
+static inline
+void write(FileStorage& fs, const String& name, const DMatch& r )
+{
+ cv::internal::WriteStructContext ws(fs, name, FileNode::SEQ+FileNode::FLOW);
+ write(fs, r);
+}
+
template<typename _Tp> static inline
void write( FileStorage& fs, const String& name, const std::vector<_Tp>& vec )
{
@@ -1096,6 +1155,24 @@ void read( const FileNode& node, std::vector<_Tp>& vec, const std::vector<_Tp>&
}
}
+static inline
+void read( const FileNode& node, std::vector<KeyPoint>& vec, const std::vector<KeyPoint>& default_value )
+{
+ if(!node.node)
+ vec = default_value;
+ else
+ read(node, vec);
+}
+
+static inline
+void read( const FileNode& node, std::vector<DMatch>& vec, const std::vector<DMatch>& default_value )
+{
+ if(!node.node)
+ vec = default_value;
+ else
+ read(node, vec);
+}
+
//! @} FileNode
//! @relates cv::FileStorage
@@ -1186,6 +1263,14 @@ void operator >> (const FileNode& n, std::vector<KeyPoint>& vec)
{
read(n, vec);
}
+
+static inline
+void operator >> (const FileNode& n, KeyPoint& kpt)
+{
+ FileNodeIterator it = n.begin();
+ it >> kpt.pt.x >> kpt.pt.y >> kpt.size >> kpt.angle >> kpt.response >> kpt.octave >> kpt.class_id;
+}
+
/** @brief Reads DMatch from a file storage.
*/
//It needs special handling because it contains two types of fields, int & float.
@@ -1195,6 +1280,13 @@ void operator >> (const FileNode& n, std::vector<DMatch>& vec)
read(n, vec);
}
+static inline
+void operator >> (const FileNode& n, DMatch& m)
+{
+ FileNodeIterator it = n.begin();
+ it >> m.queryIdx >> m.trainIdx >> m.imgIdx >> m.distance;
+}
+
//! @} FileNode
//! @relates cv::FileNodeIterator
diff --git a/modules/core/include/opencv2/core/private.cuda.hpp b/modules/core/include/opencv2/core/private.cuda.hpp
index 01a4ab3..1214d70 100644
--- a/modules/core/include/opencv2/core/private.cuda.hpp
+++ b/modules/core/include/opencv2/core/private.cuda.hpp
@@ -102,20 +102,6 @@ static inline void throw_no_cuda() { CV_Error(cv::Error::StsNotImplemented, "The
namespace cv { namespace cuda
{
- class CV_EXPORTS BufferPool
- {
- public:
- explicit BufferPool(Stream& stream);
-
- GpuMat getBuffer(int rows, int cols, int type);
- GpuMat getBuffer(Size size, int type) { return getBuffer(size.height, size.width, type); }
-
- GpuMat::Allocator* getAllocator() const { return allocator_; }
-
- private:
- GpuMat::Allocator* allocator_;
- };
-
static inline void checkNppError(int code, const char* file, const int line, const char* func)
{
if (code < 0)
diff --git a/modules/core/include/opencv2/core/private.hpp b/modules/core/include/opencv2/core/private.hpp
index e428ecf..61059fa 100644
--- a/modules/core/include/opencv2/core/private.hpp
+++ b/modules/core/include/opencv2/core/private.hpp
@@ -51,6 +51,8 @@
#include "opencv2/core.hpp"
#include "cvconfig.h"
+#include <opencv2/core/utils/trace.hpp>
+
#ifdef HAVE_EIGEN
# if defined __GNUC__ && defined __APPLE__
# pragma GCC diagnostic ignored "-Wshadow"
@@ -66,17 +68,6 @@
# undef max
#endif
-#if defined HAVE_FP16 && (defined __F16C__ || (defined _MSC_VER && _MSC_VER >= 1700))
-# include <immintrin.h>
-# define CV_FP16 1
-#elif defined HAVE_FP16 && defined __GNUC__
-# define CV_FP16 1
-#endif
-
-#ifndef CV_FP16
-# define CV_FP16 0
-#endif
-
//! @cond IGNORED
namespace cv
@@ -140,7 +131,7 @@ namespace cv
\****************************************************************************************/
/* the alignment of all the allocated buffers */
-#define CV_MALLOC_ALIGN 16
+#define CV_MALLOC_ALIGN 64
/* IEEE754 constants and macros */
#define CV_TOGGLE_FLT(x) ((x)^((int)(x) < 0 ? 0x7fffffff : 0))
@@ -196,28 +187,73 @@ CV_EXPORTS void scalarToRawData(const cv::Scalar& s, void* buf, int type, int un
* Structures and macros for integration with IPP *
\****************************************************************************************/
-#ifdef HAVE_IPP
-#include "ipp.h"
+// Temporary disabled named IPP region. Accuracy
+#define IPP_DISABLE_PYRAMIDS_UP 1 // Different results
+#define IPP_DISABLE_PYRAMIDS_DOWN 1 // Different results
+#define IPP_DISABLE_PYRAMIDS_BUILD 1 // Different results
+#define IPP_DISABLE_WARPAFFINE 1 // Different results
+#define IPP_DISABLE_WARPPERSPECTIVE 1 // Different results
+#define IPP_DISABLE_REMAP 1 // Different results
+#define IPP_DISABLE_MORPH_ADV 1 // mask flipping in IPP
+#define IPP_DISABLE_SORT_IDX 0 // different order in index tables
+#define IPP_DISABLE_YUV_RGB 1 // accuracy difference
+#define IPP_DISABLE_RGB_YUV 1 // breaks OCL accuracy tests
+#define IPP_DISABLE_RGB_HSV 1 // breaks OCL accuracy tests
+#define IPP_DISABLE_RGB_LAB 1 // breaks OCL accuracy tests
+#define IPP_DISABLE_LAB_RGB 1 // breaks OCL accuracy tests
+#define IPP_DISABLE_RGB_XYZ 1 // big accuracy difference
+#define IPP_DISABLE_XYZ_RGB 1 // big accuracy difference
+#define IPP_DISABLE_HAAR 1 // improper integration/results
+#define IPP_DISABLE_HOUGH 1 // improper integration/results
+#define IPP_DISABLE_RESIZE_8U 1 // Incompatible accuracy
+#define IPP_DISABLE_RESIZE_NEAREST 1 // Accuracy mismatch (max diff 1)
+#define IPP_DISABLE_RESIZE_AREA 1 // Accuracy mismatch (max diff 1)
+
+#define IPP_DISABLE_MINMAX_NAN_SSE42 1 // cv::minMaxIdx problem with NaN input
+
+// Temporary disabled named IPP region. Performance
+#define IPP_DISABLE_PERF_COPYMAKE 1 // performance variations
+#define IPP_DISABLE_PERF_LUT 1 // there are no performance benefits (PR #2653)
+#define IPP_DISABLE_PERF_TRUE_DIST_MT 1 // cv::distanceTransform OpenCV MT performance is better
+#define IPP_DISABLE_PERF_CANNY_MT 1 // cv::Canny OpenCV MT performance is better
+#define IPP_DISABLE_PERF_HISTU32F_SSE42 1 // cv::calcHist optimizations problem
+#define IPP_DISABLE_PERF_MORPH_SSE42 1 // cv::erode, cv::dilate optimizations problem
+#define IPP_DISABLE_PERF_MAG_SSE42 1 // cv::magnitude optimizations problem
+#define IPP_DISABLE_PERF_BOX16S_SSE42 1 // cv::boxFilter optimizations problem
+#ifdef HAVE_IPP
+#include "ippversion.h"
#ifndef IPP_VERSION_UPDATE // prior to 7.1
#define IPP_VERSION_UPDATE 0
#endif
#define IPP_VERSION_X100 (IPP_VERSION_MAJOR * 100 + IPP_VERSION_MINOR*10 + IPP_VERSION_UPDATE)
-// General define for ipp function disabling
-#define IPP_DISABLE_BLOCK 0
+#ifdef HAVE_IPP_ICV_ONLY
+#define ICV_BASE
+#if IPP_VERSION_X100 >= 201700
+#include "ippicv.h"
+#else
+#include "ipp.h"
+#endif
+#else
+#include "ipp.h"
+#endif
+#ifdef HAVE_IPP_IW
+#include "iw++/iw.hpp"
+#endif
-#ifdef CV_MALLOC_ALIGN
-#undef CV_MALLOC_ALIGN
+#if IPP_VERSION_X100 >= 201700
+#define CV_IPP_MALLOC(SIZE) ippMalloc_L(SIZE)
+#else
+#define CV_IPP_MALLOC(SIZE) ippMalloc((int)SIZE)
#endif
-#define CV_MALLOC_ALIGN 32 // required for AVX optimization
#define setIppErrorStatus() cv::ipp::setIppStatus(-1, CV_Func, __FILE__, __LINE__)
-static inline IppiSize ippiSize(int width, int height)
+static inline IppiSize ippiSize(size_t width, size_t height)
{
- IppiSize size = { width, height };
+ IppiSize size = { (int)width, (int)height };
return size;
}
@@ -227,6 +263,20 @@ static inline IppiSize ippiSize(const cv::Size & _size)
return size;
}
+#if IPP_VERSION_X100 >= 201700
+static inline IppiSizeL ippiSizeL(size_t width, size_t height)
+{
+ IppiSizeL size = { (IppSizeL)width, (IppSizeL)height };
+ return size;
+}
+
+static inline IppiSizeL ippiSizeL(const cv::Size & _size)
+{
+ IppiSizeL size = { _size.width, _size.height };
+ return size;
+}
+#endif
+
static inline IppiPoint ippiPoint(const cv::Point & _point)
{
IppiPoint point = { _point.x, _point.y };
@@ -241,34 +291,177 @@ static inline IppiPoint ippiPoint(int x, int y)
static inline IppiBorderType ippiGetBorderType(int borderTypeNI)
{
- return borderTypeNI == cv::BORDER_CONSTANT ? ippBorderConst :
- borderTypeNI == cv::BORDER_WRAP ? ippBorderWrap :
- borderTypeNI == cv::BORDER_REPLICATE ? ippBorderRepl :
- borderTypeNI == cv::BORDER_REFLECT_101 ? ippBorderMirror :
- borderTypeNI == cv::BORDER_REFLECT ? ippBorderMirrorR : (IppiBorderType)-1;
+ return borderTypeNI == cv::BORDER_CONSTANT ? ippBorderConst :
+ borderTypeNI == cv::BORDER_TRANSPARENT ? ippBorderTransp :
+ borderTypeNI == cv::BORDER_REPLICATE ? ippBorderRepl :
+ borderTypeNI == cv::BORDER_REFLECT_101 ? ippBorderMirror :
+ (IppiBorderType)-1;
+}
+
+static inline IppiMaskSize ippiGetMaskSize(int kx, int ky)
+{
+ return (kx == 1 && ky == 3) ? ippMskSize1x3 :
+ (kx == 1 && ky == 5) ? ippMskSize1x5 :
+ (kx == 3 && ky == 1) ? ippMskSize3x1 :
+ (kx == 3 && ky == 3) ? ippMskSize3x3 :
+ (kx == 5 && ky == 1) ? ippMskSize5x1 :
+ (kx == 5 && ky == 5) ? ippMskSize5x5 :
+ (IppiMaskSize)-1;
}
static inline IppDataType ippiGetDataType(int depth)
{
+ depth = CV_MAT_DEPTH(depth);
return depth == CV_8U ? ipp8u :
depth == CV_8S ? ipp8s :
depth == CV_16U ? ipp16u :
depth == CV_16S ? ipp16s :
depth == CV_32S ? ipp32s :
depth == CV_32F ? ipp32f :
- depth == CV_64F ? ipp64f : (IppDataType)-1;
+ depth == CV_64F ? ipp64f :
+ (IppDataType)-1;
+}
+
+#ifdef HAVE_IPP_IW
+static inline IwiDerivativeType ippiGetDerivType(int dx, int dy, bool nvert)
+{
+ return (dx == 1 && dy == 0) ? ((nvert)?iwiDerivNVerFirst:iwiDerivVerFirst) :
+ (dx == 0 && dy == 1) ? iwiDerivHorFirst :
+ (dx == 2 && dy == 0) ? iwiDerivVerSecond :
+ (dx == 0 && dy == 2) ? iwiDerivHorSecond :
+ (IwiDerivativeType)-1;
}
-// IPP temporary buffer hepler
+static inline void ippiGetImage(const cv::Mat &src, ::ipp::IwiImage &dst)
+{
+ ::ipp::IwiBorderSize inMemBorder;
+ if(src.isSubmatrix()) // already have physical border
+ {
+ cv::Size origSize;
+ cv::Point offset;
+ src.locateROI(origSize, offset);
+
+ inMemBorder.borderLeft = (Ipp32u)offset.x;
+ inMemBorder.borderTop = (Ipp32u)offset.y;
+ inMemBorder.borderRight = (Ipp32u)(origSize.width - src.cols - offset.x);
+ inMemBorder.borderBottom = (Ipp32u)(origSize.height - src.rows - offset.y);
+ }
+
+ dst.Init(ippiSize(src.size()), ippiGetDataType(src.depth()), src.channels(), inMemBorder, (void*)src.ptr(), src.step);
+}
+
+static inline ::ipp::IwiImage ippiGetImage(const cv::Mat &src)
+{
+ ::ipp::IwiImage image;
+ ippiGetImage(src, image);
+ return image;
+}
+
+static inline IppiBorderType ippiGetBorder(::ipp::IwiImage &image, int ocvBorderType, IppiBorderSize &borderSize)
+{
+ int inMemFlags = 0;
+ IppiBorderType border = ippiGetBorderType(ocvBorderType & ~cv::BORDER_ISOLATED);
+ if((int)border == -1)
+ return (IppiBorderType)0;
+
+ if(!(ocvBorderType & cv::BORDER_ISOLATED))
+ {
+ if(image.m_inMemSize.borderLeft)
+ {
+ if(image.m_inMemSize.borderLeft >= borderSize.borderLeft)
+ inMemFlags |= ippBorderInMemLeft;
+ else
+ return (IppiBorderType)0;
+ }
+ else
+ borderSize.borderLeft = 0;
+ if(image.m_inMemSize.borderTop)
+ {
+ if(image.m_inMemSize.borderTop >= borderSize.borderTop)
+ inMemFlags |= ippBorderInMemTop;
+ else
+ return (IppiBorderType)0;
+ }
+ else
+ borderSize.borderTop = 0;
+ if(image.m_inMemSize.borderRight)
+ {
+ if(image.m_inMemSize.borderRight >= borderSize.borderRight)
+ inMemFlags |= ippBorderInMemRight;
+ else
+ return (IppiBorderType)0;
+ }
+ else
+ borderSize.borderRight = 0;
+ if(image.m_inMemSize.borderBottom)
+ {
+ if(image.m_inMemSize.borderBottom >= borderSize.borderBottom)
+ inMemFlags |= ippBorderInMemBottom;
+ else
+ return (IppiBorderType)0;
+ }
+ else
+ borderSize.borderBottom = 0;
+ }
+ else
+ borderSize.borderLeft = borderSize.borderRight = borderSize.borderTop = borderSize.borderBottom = 0;
+
+ return (IppiBorderType)(border|inMemFlags);
+}
+
+static inline ::ipp::IwValue ippiGetValue(const cv::Scalar &scalar)
+{
+ return ::ipp::IwValue(scalar[0], scalar[1], scalar[2], scalar[3]);
+}
+
+static inline int ippiSuggestThreadsNum(const ::ipp::IwiImage &image, double multiplier)
+{
+ int threads = cv::getNumThreads();
+ if(image.m_size.height > threads)
+ {
+ size_t opMemory = (int)(image.m_step*image.m_size.height*multiplier);
+ int l2cache = 0;
+#if IPP_VERSION_X100 >= 201700
+ ippGetL2CacheSize(&l2cache);
+#endif
+ if(!l2cache)
+ l2cache = 1 << 18;
+
+ return IPP_MAX(1, (IPP_MIN((int)(opMemory/l2cache), threads)));
+ }
+ return 1;
+}
+#endif
+
+static inline int ippiSuggestThreadsNum(const cv::Mat &image, double multiplier)
+{
+ int threads = cv::getNumThreads();
+ if(image.rows > threads)
+ {
+ size_t opMemory = (int)(image.total()*multiplier);
+ int l2cache = 0;
+#if IPP_VERSION_X100 >= 201700
+ ippGetL2CacheSize(&l2cache);
+#endif
+ if(!l2cache)
+ l2cache = 1 << 18;
+
+ return IPP_MAX(1, (IPP_MIN((int)(opMemory/l2cache), threads)));
+ }
+ return 1;
+}
+
+// IPP temporary buffer helper
template<typename T>
class IppAutoBuffer
{
public:
- IppAutoBuffer() { m_pBuffer = NULL; }
- IppAutoBuffer(int size) { Alloc(size); }
- ~IppAutoBuffer() { Release(); }
- T* Alloc(int size) { m_pBuffer = (T*)ippMalloc(size); return m_pBuffer; }
- void Release() { if(m_pBuffer) ippFree(m_pBuffer); }
+ IppAutoBuffer() { m_size = 0; m_pBuffer = NULL; }
+ IppAutoBuffer(size_t size) { m_size = 0; m_pBuffer = NULL; allocate(size); }
+ ~IppAutoBuffer() { deallocate(); }
+ T* allocate(size_t size) { if(m_size < size) { deallocate(); m_pBuffer = (T*)CV_IPP_MALLOC(size); m_size = size; } return m_pBuffer; }
+ void deallocate() { if(m_pBuffer) { ippFree(m_pBuffer); m_pBuffer = NULL; } m_size = 0; }
+ inline T* get() { return (T*)m_pBuffer;}
inline operator T* () { return (T*)m_pBuffer;}
inline operator const T* () const { return (const T*)m_pBuffer;}
private:
@@ -276,9 +469,17 @@ private:
IppAutoBuffer(IppAutoBuffer &) {}
IppAutoBuffer& operator =(const IppAutoBuffer &) {return *this;}
- T* m_pBuffer;
+ size_t m_size;
+ T* m_pBuffer;
};
+// Extracts border interpolation type without flags
+#if IPP_VERSION_MAJOR >= 2017
+#define IPP_BORDER_INTER(BORDER) (IppiBorderType)((BORDER)&0xF|((((BORDER)&ippBorderInMem) == ippBorderInMem)?ippBorderInMem:0));
+#else
+#define IPP_BORDER_INTER(BORDER) (IppiBorderType)((BORDER)&0xF);
+#endif
+
#else
#define IPP_VERSION_X100 0
#endif
@@ -346,6 +547,7 @@ static struct __IppInitializer__ __ipp_initializer__;
{ \
if (cv::ipp::useIPP() && (condition)) \
{ \
+ CV__TRACE_REGION_("IPP:" #func, CV_TRACE_NS::details::REGION_FLAG_IMPL_IPP) \
if(func) \
{ \
CV_IMPL_ADD(CV_IMPL_IPP); \
@@ -360,23 +562,21 @@ static struct __IppInitializer__ __ipp_initializer__;
}
#else
#define CV_IPP_RUN_(condition, func, ...) \
- if (cv::ipp::useIPP() && (condition) && (func)) \
- { \
- CV_IMPL_ADD(CV_IMPL_IPP); \
- return __VA_ARGS__; \
- }
+ if (cv::ipp::useIPP() && (condition)) \
+ { \
+ CV__TRACE_REGION_("IPP:" #func, CV_TRACE_NS::details::REGION_FLAG_IMPL_IPP) \
+ if(func) \
+ { \
+ CV_IMPL_ADD(CV_IMPL_IPP); \
+ return __VA_ARGS__; \
+ } \
+ }
#endif
-#define CV_IPP_RUN_FAST(func, ...) \
- if (cv::ipp::useIPP() && (func)) \
- { \
- CV_IMPL_ADD(CV_IMPL_IPP); \
- return __VA_ARGS__; \
- }
#else
#define CV_IPP_RUN_(condition, func, ...)
-#define CV_IPP_RUN_FAST(func, ...)
#endif
+#define CV_IPP_RUN_FAST(func, ...) CV_IPP_RUN_(true, func, __VA_ARGS__)
#define CV_IPP_RUN(condition, func, ...) CV_IPP_RUN_((condition), (func), __VA_ARGS__)
@@ -540,7 +740,7 @@ CV_EXPORTS InstrNode* getCurrentNode();
///// General instrumentation
// General OpenCV region instrumentation macro
-#define CV_INSTRUMENT_REGION() CV_INSTRUMENT_REGION_META(__FUNCTION__, false, ::cv::instr::TYPE_GENERAL, ::cv::instr::IMPL_PLAIN)
+#define CV_INSTRUMENT_REGION_() CV_INSTRUMENT_REGION_META(__FUNCTION__, false, ::cv::instr::TYPE_GENERAL, ::cv::instr::IMPL_PLAIN)
// Custom OpenCV region instrumentation macro
#define CV_INSTRUMENT_REGION_NAME(NAME) CV_INSTRUMENT_REGION_CUSTOM_META(NAME, false, ::cv::instr::TYPE_GENERAL, ::cv::instr::IMPL_PLAIN)
// Instrumentation for parallel_for_ or other regions which forks and gathers threads
@@ -566,20 +766,26 @@ CV_EXPORTS InstrNode* getCurrentNode();
#else
#define CV_INSTRUMENT_REGION_META(...)
-#define CV_INSTRUMENT_REGION()
-#define CV_INSTRUMENT_REGION_NAME(...)
+#define CV_INSTRUMENT_REGION_() CV_TRACE_FUNCTION()
+#define CV_INSTRUMENT_REGION_NAME(...) CV_TRACE_REGION(__VA_ARGS__)
#define CV_INSTRUMENT_REGION_MT_FORK()
-#define CV_INSTRUMENT_REGION_IPP()
+#define CV_INSTRUMENT_REGION_IPP() CV__TRACE_REGION_("IPP", CV_TRACE_NS::details::REGION_FLAG_IMPL_IPP)
#define CV_INSTRUMENT_FUN_IPP(FUN, ...) ((FUN)(__VA_ARGS__))
#define CV_INSTRUMENT_MARK_IPP(...)
-#define CV_INSTRUMENT_REGION_OPENCL()
+#define CV_INSTRUMENT_REGION_OPENCL() CV__TRACE_REGION_("OpenCL", CV_TRACE_NS::details::REGION_FLAG_IMPL_OPENCL)
#define CV_INSTRUMENT_REGION_OPENCL_COMPILE(...)
#define CV_INSTRUMENT_REGION_OPENCL_RUN(...)
#define CV_INSTRUMENT_MARK_OPENCL(...)
#endif
+#ifdef __CV_AVX_GUARD
+#define CV_INSTRUMENT_REGION() __CV_AVX_GUARD CV_INSTRUMENT_REGION_()
+#else
+#define CV_INSTRUMENT_REGION() CV_INSTRUMENT_REGION_()
+#endif
+
//! @endcond
#endif // OPENCV_CORE_PRIVATE_HPP
diff --git a/modules/core/include/opencv2/core/private/cv_cpu_include_simd_declarations.hpp b/modules/core/include/opencv2/core/private/cv_cpu_include_simd_declarations.hpp
new file mode 100644
index 0000000..37d06ef
--- /dev/null
+++ b/modules/core/include/opencv2/core/private/cv_cpu_include_simd_declarations.hpp
@@ -0,0 +1,30 @@
+// Helper file to include dispatched functions declaration:
+//
+// Usage:
+// #define CV_CPU_SIMD_FILENAME "<filename>.simd.hpp"
+// #define CV_CPU_DISPATCH_MODE AVX2
+// #include "opencv2/core/private/cv_cpu_include_simd_declarations.hpp"
+// #define CV_CPU_DISPATCH_MODE SSE2
+// #include "opencv2/core/private/cv_cpu_include_simd_declarations.hpp"
+
+#ifndef CV_DISABLE_OPTIMIZATION
+#ifdef _MSC_VER
+#pragma warning(disable: 4702) // unreachable code
+#endif
+#endif
+
+#ifndef CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
+#define CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
+#endif
+
+#undef CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
+#undef CV_CPU_OPTIMIZATION_NAMESPACE_END
+
+#define CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN namespace __CV_CAT(opt_, CV_CPU_DISPATCH_MODE) {
+#define CV_CPU_OPTIMIZATION_NAMESPACE_END }
+
+#include CV_CPU_SIMD_FILENAME
+
+#undef CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
+#undef CV_CPU_OPTIMIZATION_NAMESPACE_END
+#undef CV_CPU_DISPATCH_MODE
diff --git a/modules/core/include/opencv2/core/softfloat.hpp b/modules/core/include/opencv2/core/softfloat.hpp
new file mode 100644
index 0000000..a71b676
--- /dev/null
+++ b/modules/core/include/opencv2/core/softfloat.hpp
@@ -0,0 +1,245 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+// This file is based on files from package issued with the following license:
+
+/*============================================================================
+
+This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3c, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
+University of California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#pragma once
+#ifndef softfloat_h
+#define softfloat_h 1
+
+#include "cvdef.h"
+
+// int32_t / uint32_t
+#if defined(_MSC_VER) && _MSC_VER < 1600 /* MSVS 2010 */
+namespace cv {
+typedef signed int int32_t;
+typedef unsigned int uint32_t;
+}
+#elif defined(_MSC_VER) || __cplusplus >= 201103L
+#include <cstdint>
+#else
+#include <stdint.h>
+#endif
+
+namespace cv
+{
+
+struct softfloat;
+struct softdouble;
+
+struct CV_EXPORTS softfloat
+{
+public:
+ softfloat() { v = 0; }
+ softfloat( const softfloat& c) { v = c.v; }
+ softfloat& operator=( const softfloat& c )
+ {
+ if(&c != this) v = c.v;
+ return *this;
+ }
+ static const softfloat fromRaw( const uint32_t a ) { softfloat x; x.v = a; return x; }
+
+ explicit softfloat( const uint32_t );
+ explicit softfloat( const uint64_t );
+ explicit softfloat( const int32_t );
+ explicit softfloat( const int64_t );
+ explicit softfloat( const float a ) { Cv32suf s; s.f = a; v = s.u; }
+
+ operator softdouble() const;
+ operator float() const { Cv32suf s; s.u = v; return s.f; }
+
+ softfloat operator + (const softfloat&) const;
+ softfloat operator - (const softfloat&) const;
+ softfloat operator * (const softfloat&) const;
+ softfloat operator / (const softfloat&) const;
+ softfloat operator % (const softfloat&) const;
+ softfloat operator - () const { softfloat x; x.v = v ^ (1U << 31); return x; }
+
+ softfloat& operator += (const softfloat& a) { *this = *this + a; return *this; }
+ softfloat& operator -= (const softfloat& a) { *this = *this - a; return *this; }
+ softfloat& operator *= (const softfloat& a) { *this = *this * a; return *this; }
+ softfloat& operator /= (const softfloat& a) { *this = *this / a; return *this; }
+ softfloat& operator %= (const softfloat& a) { *this = *this % a; return *this; }
+
+ bool operator == ( const softfloat& ) const;
+ bool operator != ( const softfloat& ) const;
+ bool operator > ( const softfloat& ) const;
+ bool operator >= ( const softfloat& ) const;
+ bool operator < ( const softfloat& ) const;
+ bool operator <= ( const softfloat& ) const;
+
+ bool isNaN() const { return (v & 0x7fffffff) > 0x7f800000; }
+ bool isInf() const { return (v & 0x7fffffff) == 0x7f800000; }
+
+ static softfloat zero() { return softfloat::fromRaw( 0 ); }
+ static softfloat inf() { return softfloat::fromRaw( 0xFF << 23 ); }
+ static softfloat nan() { return softfloat::fromRaw( 0x7fffffff ); }
+ static softfloat one() { return softfloat::fromRaw( 127 << 23 ); }
+
+ uint32_t v;
+};
+
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+
+struct CV_EXPORTS softdouble
+{
+public:
+ softdouble() : v(0) { }
+ softdouble( const softdouble& c) { v = c.v; }
+ softdouble& operator=( const softdouble& c )
+ {
+ if(&c != this) v = c.v;
+ return *this;
+ }
+ static softdouble fromRaw( const uint64_t a ) { softdouble x; x.v = a; return x; }
+
+ explicit softdouble( const uint32_t );
+ explicit softdouble( const uint64_t );
+ explicit softdouble( const int32_t );
+ explicit softdouble( const int64_t );
+ explicit softdouble( const double a ) { Cv64suf s; s.f = a; v = s.u; }
+
+ operator softfloat() const;
+ operator double() const { Cv64suf s; s.u = v; return s.f; }
+
+ softdouble operator + (const softdouble&) const;
+ softdouble operator - (const softdouble&) const;
+ softdouble operator * (const softdouble&) const;
+ softdouble operator / (const softdouble&) const;
+ softdouble operator % (const softdouble&) const;
+ softdouble operator - () const { softdouble x; x.v = v ^ (1ULL << 63); return x; }
+
+ softdouble& operator += (const softdouble& a) { *this = *this + a; return *this; }
+ softdouble& operator -= (const softdouble& a) { *this = *this - a; return *this; }
+ softdouble& operator *= (const softdouble& a) { *this = *this * a; return *this; }
+ softdouble& operator /= (const softdouble& a) { *this = *this / a; return *this; }
+ softdouble& operator %= (const softdouble& a) { *this = *this % a; return *this; }
+
+ bool operator == ( const softdouble& ) const;
+ bool operator != ( const softdouble& ) const;
+ bool operator > ( const softdouble& ) const;
+ bool operator >= ( const softdouble& ) const;
+ bool operator < ( const softdouble& ) const;
+ bool operator <= ( const softdouble& ) const;
+
+ bool isNaN() const { return (v & 0x7fffffffffffffff) > 0x7ff0000000000000; }
+ bool isInf() const { return (v & 0x7fffffffffffffff) == 0x7ff0000000000000; }
+
+ static softdouble zero() { return softdouble::fromRaw( 0 ); }
+ static softdouble inf() { return softdouble::fromRaw( (uint_fast64_t)(0x7FF) << 52 ); }
+ static softdouble nan() { return softdouble::fromRaw( CV_BIG_INT(0x7FFFFFFFFFFFFFFF) ); }
+ static softdouble one() { return softdouble::fromRaw( (uint_fast64_t)( 1023) << 52 ); }
+
+ uint64_t v;
+};
+
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+
+CV_EXPORTS softfloat mulAdd( const softfloat& a, const softfloat& b, const softfloat & c);
+CV_EXPORTS softdouble mulAdd( const softdouble& a, const softdouble& b, const softdouble& c);
+
+CV_EXPORTS softfloat sqrt( const softfloat& a );
+CV_EXPORTS softdouble sqrt( const softdouble& a );
+}
+
+/*----------------------------------------------------------------------------
+| Ported from OpenCV and added for usability
+*----------------------------------------------------------------------------*/
+
+CV_EXPORTS int cvTrunc(const cv::softfloat& a);
+CV_EXPORTS int cvTrunc(const cv::softdouble& a);
+
+CV_EXPORTS int cvRound(const cv::softfloat& a);
+CV_EXPORTS int cvRound(const cv::softdouble& a);
+
+CV_EXPORTS int cvFloor(const cv::softfloat& a);
+CV_EXPORTS int cvFloor(const cv::softdouble& a);
+
+CV_EXPORTS int cvCeil(const cv::softfloat& a);
+CV_EXPORTS int cvCeil(const cv::softdouble& a);
+
+namespace cv
+{
+template<typename _Tp> static inline _Tp saturate_cast(softfloat a) { return _Tp(a); }
+template<typename _Tp> static inline _Tp saturate_cast(softdouble a) { return _Tp(a); }
+
+template<> inline uchar saturate_cast<uchar>(softfloat a) { return (uchar)std::max(std::min(cvRound(a), (int)UCHAR_MAX), 0); }
+template<> inline uchar saturate_cast<uchar>(softdouble a) { return (uchar)std::max(std::min(cvRound(a), (int)UCHAR_MAX), 0); }
+
+template<> inline schar saturate_cast<schar>(softfloat a) { return (schar)std::min(std::max(cvRound(a), (int)SCHAR_MIN), (int)SCHAR_MAX); }
+template<> inline schar saturate_cast<schar>(softdouble a) { return (schar)std::min(std::max(cvRound(a), (int)SCHAR_MIN), (int)SCHAR_MAX); }
+
+template<> inline ushort saturate_cast<ushort>(softfloat a) { return (ushort)std::max(std::min(cvRound(a), (int)USHRT_MAX), 0); }
+template<> inline ushort saturate_cast<ushort>(softdouble a) { return (ushort)std::max(std::min(cvRound(a), (int)USHRT_MAX), 0); }
+
+template<> inline short saturate_cast<short>(softfloat a) { return (short)std::min(std::max(cvRound(a), (int)SHRT_MIN), (int)SHRT_MAX); }
+template<> inline short saturate_cast<short>(softdouble a) { return (short)std::min(std::max(cvRound(a), (int)SHRT_MIN), (int)SHRT_MAX); }
+
+template<> inline int saturate_cast<int>(softfloat a) { return cvRound(a); }
+template<> inline int saturate_cast<int>(softdouble a) { return cvRound(a); }
+
+// we intentionally do not clip negative numbers, to make -1 become 0xffffffff etc.
+template<> inline unsigned saturate_cast<unsigned>(softfloat a) { return cvRound(a); }
+template<> inline unsigned saturate_cast<unsigned>(softdouble a) { return cvRound(a); }
+
+inline softfloat min(const softfloat& a, const softfloat& b) { return (a > b) ? b : a; }
+inline softdouble min(const softdouble& a, const softdouble& b) { return (a > b) ? b : a; }
+
+inline softfloat max(const softfloat& a, const softfloat& b) { return (a > b) ? a : b; }
+inline softdouble max(const softdouble& a, const softdouble& b) { return (a > b) ? a : b; }
+
+inline softfloat abs( softfloat a) { softfloat x; x.v = a.v & ((1U << 31) - 1); return x; }
+inline softdouble abs( softdouble a) { softdouble x; x.v = a.v & ((1ULL << 63) - 1); return x; }
+
+CV_EXPORTS softfloat exp( const softfloat& a);
+CV_EXPORTS softdouble exp( const softdouble& a);
+
+CV_EXPORTS softfloat log( const softfloat& a );
+CV_EXPORTS softdouble log( const softdouble& a );
+
+CV_EXPORTS softfloat pow( const softfloat& a, const softfloat& b);
+CV_EXPORTS softdouble pow( const softdouble& a, const softdouble& b);
+
+CV_EXPORTS softfloat cbrt(const softfloat& a);
+
+}
+
+#endif
diff --git a/modules/core/include/opencv2/core/types.hpp b/modules/core/include/opencv2/core/types.hpp
index d5c64ca..61cedc3 100644
--- a/modules/core/include/opencv2/core/types.hpp
+++ b/modules/core/include/opencv2/core/types.hpp
@@ -301,6 +301,8 @@ public:
Size_& operator = (const Size_& sz);
//! the area (width*height)
_Tp area() const;
+ //! true if empty
+ bool empty() const;
//! conversion of another data type.
template<typename _Tp2> operator Size_<_Tp2>() const;
@@ -400,6 +402,8 @@ public:
Size_<_Tp> size() const;
//! area (width*height) of the rectangle
_Tp area() const;
+ //! true if empty
+ bool empty() const;
//! conversion to another data type
template<typename _Tp2> operator Rect_<_Tp2>() const;
@@ -572,7 +576,7 @@ public:
/** @brief Template class for a 4-element vector derived from Vec.
-Being derived from Vec\<_Tp, 4\> , Scalar_ and Scalar can be used just as typical 4-element
+Being derived from Vec\<_Tp, 4\> , Scalar\_ and Scalar can be used just as typical 4-element
vectors. In addition, they can be converted to/from CvScalar . The type Scalar is widely used in
OpenCV to pass pixel values.
*/
@@ -1040,7 +1044,8 @@ Complex<_Tp> operator / (const Complex<_Tp>& a, const Complex<_Tp>& b)
template<typename _Tp> static inline
Complex<_Tp>& operator /= (Complex<_Tp>& a, const Complex<_Tp>& b)
{
- return (a = a / b);
+ a = a / b;
+ return a;
}
template<typename _Tp> static inline
@@ -1592,9 +1597,19 @@ Size_<_Tp>& Size_<_Tp>::operator = (const Size_<_Tp>& sz)
template<typename _Tp> inline
_Tp Size_<_Tp>::area() const
{
- return width * height;
+ const _Tp result = width * height;
+ CV_DbgAssert(!std::numeric_limits<_Tp>::is_integer
+ || width == 0 || result / width == height); // make sure the result fits in the return value
+ return result;
}
+template<typename _Tp> inline
+bool Size_<_Tp>::empty() const
+{
+ return width <= 0 || height <= 0;
+}
+
+
template<typename _Tp> static inline
Size_<_Tp>& operator *= (Size_<_Tp>& a, _Tp b)
{
@@ -1731,7 +1746,16 @@ Size_<_Tp> Rect_<_Tp>::size() const
template<typename _Tp> inline
_Tp Rect_<_Tp>::area() const
{
- return width * height;
+ const _Tp result = width * height;
+ CV_DbgAssert(!std::numeric_limits<_Tp>::is_integer
+ || width == 0 || result / width == height); // make sure the result fits in the return value
+ return result;
+}
+
+template<typename _Tp> inline
+bool Rect_<_Tp>::empty() const
+{
+ return width <= 0 || height <= 0;
}
template<typename _Tp> template<typename _Tp2> inline
@@ -1796,12 +1820,17 @@ Rect_<_Tp>& operator &= ( Rect_<_Tp>& a, const Rect_<_Tp>& b )
template<typename _Tp> static inline
Rect_<_Tp>& operator |= ( Rect_<_Tp>& a, const Rect_<_Tp>& b )
{
- _Tp x1 = std::min(a.x, b.x);
- _Tp y1 = std::min(a.y, b.y);
- a.width = std::max(a.x + a.width, b.x + b.width) - x1;
- a.height = std::max(a.y + a.height, b.y + b.height) - y1;
- a.x = x1;
- a.y = y1;
+ if (a.empty()) {
+ a = b;
+ }
+ else if (!b.empty()) {
+ _Tp x1 = std::min(a.x, b.x);
+ _Tp y1 = std::min(a.y, b.y);
+ a.width = std::max(a.x + a.width, b.x + b.width) - x1;
+ a.height = std::max(a.y + a.height, b.y + b.height) - y1;
+ a.x = x1;
+ a.y = y1;
+ }
return a;
}
diff --git a/modules/core/include/opencv2/core/types_c.h b/modules/core/include/opencv2/core/types_c.h
index f82a59e..4f04d0c 100644
--- a/modules/core/include/opencv2/core/types_c.h
+++ b/modules/core/include/opencv2/core/types_c.h
@@ -46,7 +46,7 @@
#ifdef HAVE_IPL
# ifndef __IPL_H__
-# if defined WIN32 || defined _WIN32
+# if defined _WIN32
# include <ipl.h>
# else
# include <ipl/ipl.h>
@@ -65,7 +65,7 @@
#include <float.h>
#endif // SKIP_INCLUDES
-#if defined WIN32 || defined _WIN32
+#if defined _WIN32
# define CV_CDECL __cdecl
# define CV_STDCALL __stdcall
#else
@@ -130,24 +130,24 @@ enum {
CV_BadImageSize= -10, /**< image size is invalid */
CV_BadOffset= -11, /**< offset is invalid */
CV_BadDataPtr= -12, /**/
- CV_BadStep= -13, /**/
+ CV_BadStep= -13, /**< image step is wrong, this may happen for a non-continuous matrix */
CV_BadModelOrChSeq= -14, /**/
- CV_BadNumChannels= -15, /**/
+ CV_BadNumChannels= -15, /**< bad number of channels, for example, some functions accept only single channel matrices */
CV_BadNumChannel1U= -16, /**/
- CV_BadDepth= -17, /**/
+ CV_BadDepth= -17, /**< input image depth is not supported by the function */
CV_BadAlphaChannel= -18, /**/
- CV_BadOrder= -19, /**/
- CV_BadOrigin= -20, /**/
- CV_BadAlign= -21, /**/
+ CV_BadOrder= -19, /**< number of dimensions is out of range */
+ CV_BadOrigin= -20, /**< incorrect input origin */
+ CV_BadAlign= -21, /**< incorrect input align */
CV_BadCallBack= -22, /**/
CV_BadTileSize= -23, /**/
- CV_BadCOI= -24, /**/
- CV_BadROISize= -25, /**/
+ CV_BadCOI= -24, /**< input COI is not supported */
+ CV_BadROISize= -25, /**< incorrect input roi */
CV_MaskIsTiled= -26, /**/
CV_StsNullPtr= -27, /**< null pointer */
CV_StsVecLengthErr= -28, /**< incorrect vector length */
- CV_StsFilterStructContentErr= -29, /**< incorr. filter structure content */
- CV_StsKernelStructContentErr= -30, /**< incorr. transform kernel content */
+ CV_StsFilterStructContentErr= -29, /**< incorrect filter structure content */
+ CV_StsKernelStructContentErr= -30, /**< incorrect transform kernel content */
CV_StsFilterOffsetErr= -31, /**< incorrect filter offset value */
CV_StsBadSize= -201, /**< the input/output structure size is incorrect */
CV_StsDivByZero= -202, /**< division by zero */
@@ -163,14 +163,14 @@ enum {
CV_StsParseError= -212, /**< invalid syntax/structure of the parsed file */
CV_StsNotImplemented= -213, /**< the requested function/feature is not implemented */
CV_StsBadMemBlock= -214, /**< an allocated block has been corrupted */
- CV_StsAssert= -215, /**< assertion failed */
- CV_GpuNotSupported= -216,
- CV_GpuApiCallError= -217,
- CV_OpenGlNotSupported= -218,
- CV_OpenGlApiCallError= -219,
- CV_OpenCLApiCallError= -220,
+ CV_StsAssert= -215, /**< assertion failed */
+ CV_GpuNotSupported= -216, /**< no CUDA support */
+ CV_GpuApiCallError= -217, /**< GPU API call error */
+ CV_OpenGlNotSupported= -218, /**< no OpenGL support */
+ CV_OpenGlApiCallError= -219, /**< OpenGL API call error */
+ CV_OpenCLApiCallError= -220, /**< OpenCL API call error */
CV_OpenCLDoubleNotSupported= -221,
- CV_OpenCLInitError= -222,
+ CV_OpenCLInitError= -222, /**< OpenCL initialization error */
CV_OpenCLNoAMDBlasFft= -223
};
diff --git a/modules/core/include/opencv2/core/utility.hpp b/modules/core/include/opencv2/core/utility.hpp
index e7a7c2d..41ccb4b 100644
--- a/modules/core/include/opencv2/core/utility.hpp
+++ b/modules/core/include/opencv2/core/utility.hpp
@@ -54,6 +54,11 @@
#endif
#include "opencv2/core.hpp"
+#include <ostream>
+
+#ifdef CV_CXX11
+#include <functional>
+#endif
namespace cv
{
@@ -61,8 +66,8 @@ namespace cv
#ifdef CV_COLLECT_IMPL_DATA
CV_EXPORTS void setImpl(int flags); // set implementation flags and reset storage arrays
CV_EXPORTS void addImpl(int flag, const char* func = 0); // add implementation and function name to storage arrays
-// Get stored implementation flags and fucntions names arrays
-// Each implementation entry correspond to function name entry, so you can find which implementation was executed in which fucntion
+// Get stored implementation flags and functions names arrays
+// Each implementation entry correspond to function name entry, so you can find which implementation was executed in which function
CV_EXPORTS int getImpl(std::vector<int> &impl, std::vector<String> &funName);
CV_EXPORTS bool useCollection(); // return implementation collection state
@@ -102,7 +107,7 @@ CV_EXPORTS void setUseCollection(bool flag); // set implementation collection st
\code
void my_func(const cv::Mat& m)
{
- cv::AutoBuffer<float> buf; // create automatic buffer containing 1000 floats
+ cv::AutoBuffer<float> buf(1000); // create automatic buffer containing 1000 floats
buf.allocate(m.rows); // if m.rows <= 1000, the pre-allocated buffer is used,
// otherwise the buffer of "m.rows" floats will be allocated
@@ -137,9 +142,9 @@ public:
void resize(size_t _size);
//! returns the current buffer size
size_t size() const;
- //! returns pointer to the real buffer, stack-allocated or head-allocated
+ //! returns pointer to the real buffer, stack-allocated or heap-allocated
operator _Tp* ();
- //! returns read-only pointer to the real buffer, stack-allocated or head-allocated
+ //! returns read-only pointer to the real buffer, stack-allocated or heap-allocated
operator const _Tp* () const;
protected:
@@ -147,7 +152,7 @@ protected:
_Tp* ptr;
//! size of the real buffer
size_t sz;
- //! pre-allocated buffer. At least 1 element to confirm C++ standard reqirements
+ //! pre-allocated buffer. At least 1 element to confirm C++ standard requirements
_Tp buf[(fixed_size > 0) ? fixed_size : 1];
};
@@ -195,13 +200,13 @@ be called outside of parallel region.
OpenCV will try to run it's functions with specified threads number, but some behaviour differs from
framework:
-- `TBB` – User-defined parallel constructions will run with the same threads number, if
- another does not specified. If late on user creates own scheduler, OpenCV will be use it.
-- `OpenMP` – No special defined behaviour.
-- `Concurrency` – If threads == 1, OpenCV will disable threading optimizations and run it's
+- `TBB` - User-defined parallel constructions will run with the same threads number, if
+ another does not specified. If later on user creates own scheduler, OpenCV will use it.
+- `OpenMP` - No special defined behaviour.
+- `Concurrency` - If threads == 1, OpenCV will disable threading optimizations and run it's
functions sequentially.
-- `GCD` – Supports only values \<= 0.
-- `C=` – No special defined behaviour.
+- `GCD` - Supports only values \<= 0.
+- `C=` - No special defined behaviour.
@param nthreads Number of threads used by OpenCV.
@sa getNumThreads, getThreadNum
*/
@@ -212,13 +217,13 @@ CV_EXPORTS_W void setNumThreads(int nthreads);
Always returns 1 if OpenCV is built without threading support.
The exact meaning of return value depends on the threading framework used by OpenCV library:
-- `TBB` – The number of threads, that OpenCV will try to use for parallel regions. If there is
+- `TBB` - The number of threads, that OpenCV will try to use for parallel regions. If there is
any tbb::thread_scheduler_init in user code conflicting with OpenCV, then function returns
default number of threads used by TBB library.
-- `OpenMP` – An upper bound on the number of threads that could be used to form a new team.
-- `Concurrency` – The number of threads, that OpenCV will try to use for parallel regions.
-- `GCD` – Unsupported; returns the GCD thread pool limit (512) for compatibility.
-- `C=` – The number of threads, that OpenCV will try to use for parallel regions, if before
+- `OpenMP` - An upper bound on the number of threads that could be used to form a new team.
+- `Concurrency` - The number of threads, that OpenCV will try to use for parallel regions.
+- `GCD` - Unsupported; returns the GCD thread pool limit (512) for compatibility.
+- `C=` - The number of threads, that OpenCV will try to use for parallel regions, if before
called setNumThreads with threads \> 0, otherwise returns the number of logical CPUs,
available for the process.
@sa setNumThreads, getThreadNum
@@ -229,12 +234,12 @@ CV_EXPORTS_W int getNumThreads();
returns 0 if called outside of parallel region.
The exact meaning of return value depends on the threading framework used by OpenCV library:
-- `TBB` – Unsupported with current 4.1 TBB release. May be will be supported in future.
-- `OpenMP` – The thread number, within the current team, of the calling thread.
-- `Concurrency` – An ID for the virtual processor that the current context is executing on (0
+- `TBB` - Unsupported with current 4.1 TBB release. Maybe will be supported in future.
+- `OpenMP` - The thread number, within the current team, of the calling thread.
+- `Concurrency` - An ID for the virtual processor that the current context is executing on (0
for master thread and unique number for others, but not necessary 1,2,3,...).
-- `GCD` – System calling thread's ID. Never returns 0 inside parallel region.
-- `C=` – The index of the current parallel task.
+- `GCD` - System calling thread's ID. Never returns 0 inside parallel region.
+- `C=` - The index of the current parallel task.
@sa setNumThreads, getNumThreads
*/
CV_EXPORTS_W int getThreadNum();
@@ -439,6 +444,23 @@ static inline size_t alignSize(size_t sz, int n)
return (sz + n-1) & -n;
}
+/** @brief Integer division with result round up.
+
+Use this function instead of `ceil((float)a / b)` expressions.
+
+ at sa alignSize
+*/
+static inline int divUp(int a, unsigned int b)
+{
+ CV_DbgAssert(a >= 0);
+ return (a + b - 1) / b;
+}
+/** @overload */
+static inline size_t divUp(size_t a, unsigned int b)
+{
+ return (a + b - 1) / b;
+}
+
/** @brief Enables or disables the optimized code.
The function can be used to dynamically turn on and off optimized code (code that uses SSE2, AVX,
@@ -477,6 +499,28 @@ public:
*/
CV_EXPORTS void parallel_for_(const Range& range, const ParallelLoopBody& body, double nstripes=-1.);
+#ifdef CV_CXX11
+class ParallelLoopBodyLambdaWrapper : public ParallelLoopBody
+{
+private:
+ std::function<void(const Range&)> m_functor;
+public:
+ ParallelLoopBodyLambdaWrapper(std::function<void(const Range&)> functor) :
+ m_functor(functor)
+ { }
+
+ virtual void operator() (const cv::Range& range) const
+ {
+ m_functor(range);
+ }
+};
+
+inline void parallel_for_(const Range& range, std::function<void(const Range&)> functor, double nstripes=-1.)
+{
+ parallel_for_(range, ParallelLoopBodyLambdaWrapper(functor), nstripes);
+}
+#endif
+
/////////////////////////////// forEach method of cv::Mat ////////////////////////////
template<typename _Tp, typename Functor> inline
void Mat::forEach_impl(const Functor& operation) {
@@ -507,7 +551,7 @@ void Mat::forEach_impl(const Functor& operation) {
this->rowCall2(row, COLS);
}
} else {
- std::vector<int> idx(COLS); /// idx is modified in this->rowCall
+ std::vector<int> idx(DIMS); /// idx is modified in this->rowCall
idx[DIMS - 2] = range.start - 1;
for (int line_num = range.start; line_num < range.end; ++line_num) {
@@ -627,6 +671,9 @@ public:
virtual void deleteDataInstance(void* pData) const = 0;
int key_;
+
+public:
+ void cleanup(); //! Release created TLS data container objects. It is similar to release() call, but it keeps TLS container valid.
};
// Main TLS data class
@@ -636,15 +683,18 @@ class TLSData : protected TLSDataContainer
public:
inline TLSData() {}
inline ~TLSData() { release(); } // Release key and delete associated data
- inline T* get() const { return (T*)getData(); } // Get data assosiated with key
+ inline T* get() const { return (T*)getData(); } // Get data associated with key
+ inline T& getRef() const { T* ptr = (T*)getData(); CV_Assert(ptr); return *ptr; } // Get data associated with key
- // Get data from all threads
+ // Get data from all threads
inline void gather(std::vector<T*> &data) const
{
std::vector<void*> &dataVoid = reinterpret_cast<std::vector<void*>&>(data);
gatherData(dataVoid);
}
+ inline void cleanup() { TLSDataContainer::cleanup(); }
+
private:
virtual void* createDataInstance() const {return new T;} // Wrapper to allocate data by template
virtual void deleteDataInstance(void* pData) const {delete (T*)pData;} // Wrapper to release data by template
@@ -687,7 +737,7 @@ The sample below demonstrates how to use CommandLineParser:
### Keys syntax
-The keys parameter is a string containing several blocks, each one is enclosed in curley braces and
+The keys parameter is a string containing several blocks, each one is enclosed in curly braces and
describes one argument. Each argument contains three parts separated by the `|` symbol:
-# argument names is a space-separated list of option synonyms (to mark argument as positional, prefix it with the `@` symbol)
@@ -845,7 +895,7 @@ public:
/** @brief Check for parsing errors
- Returns true if error occured while accessing the parameters (bad conversion, missing arguments,
+ Returns true if error occurred while accessing the parameters (bad conversion, missing arguments,
etc.). Call @ref printErrors to print error messages list.
*/
bool check() const;
@@ -989,7 +1039,6 @@ template<typename _Tp, size_t fixed_size> inline
AutoBuffer<_Tp, fixed_size>::operator const _Tp* () const
{ return ptr; }
-#ifndef OPENCV_NOSTL
template<> inline std::string CommandLineParser::get<std::string>(int index, bool space_delete) const
{
return get<String>(index, space_delete);
@@ -998,7 +1047,6 @@ template<> inline std::string CommandLineParser::get<std::string>(const String&
{
return get<String>(name, space_delete);
}
-#endif // OPENCV_NOSTL
//! @endcond
@@ -1162,6 +1210,12 @@ static inline void setFlags(int modeFlags) { setFlags((FLAGS)modeFlags); }
CV_EXPORTS FLAGS getFlags();
}
+namespace utils {
+
+CV_EXPORTS int getThreadID();
+
+} // namespace
+
} //namespace cv
#ifndef DISABLE_OPENCV_24_COMPATIBILITY
diff --git a/modules/core/include/opencv2/core/utils/logger.hpp b/modules/core/include/opencv2/core/utils/logger.hpp
new file mode 100644
index 0000000..d7e73de
--- /dev/null
+++ b/modules/core/include/opencv2/core/utils/logger.hpp
@@ -0,0 +1,84 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#ifndef OPENCV_LOGGING_HPP
+#define OPENCV_LOGGING_HPP
+
+#include <iostream>
+#include <sstream>
+#include <limits.h> // INT_MAX
+
+// TODO This file contains just interface part with implementation stubs.
+
+//! @addtogroup core_logging
+// This section describes OpenCV logging utilities.
+//
+//! @{
+
+namespace utils {
+namespace logging {
+
+// Supported logging levels and their semantic
+#define CV_LOG_LEVEL_SILENT 0 //!< for using in setLogVevel() call
+#define CV_LOG_LEVEL_FATAL 1 //!< Fatal (critical) error (unrecoverable internal error)
+#define CV_LOG_LEVEL_ERROR 2 //!< Error message
+#define CV_LOG_LEVEL_WARN 3 //!< Warning message
+#define CV_LOG_LEVEL_INFO 4 //!< Info message
+#define CV_LOG_LEVEL_DEBUG 5 //!< Debug message. Disabled in the "Release" build.
+#define CV_LOG_LEVEL_VERBOSE 6 //!< Verbose (trace) messages. Requires verbosity level. Disabled in the "Release" build.
+
+//! Supported logging levels and their semantic
+enum LogLevel {
+ LOG_LEVEL_SILENT = 0, //!< for using in setLogVevel() call
+ LOG_LEVEL_FATAL = 1, //!< Fatal (critical) error (unrecoverable internal error)
+ LOG_LEVEL_ERROR = 2, //!< Error message
+ LOG_LEVEL_WARNING = 3, //!< Warning message
+ LOG_LEVEL_INFO = 4, //!< Info message
+ LOG_LEVEL_DEBUG = 5, //!< Debug message. Disabled in the "Release" build.
+ LOG_LEVEL_VERBOSE = 6, //!< Verbose (trace) messages. Requires verbosity level. Disabled in the "Release" build.
+#ifndef CV_DOXYGEN
+ ENUM_LOG_LEVEL_FORCE_INT = INT_MAX
+#endif
+};
+
+
+/**
+ * \def CV_LOG_STRIP_LEVEL
+ *
+ * Define CV_LOG_STRIP_LEVEL=CV_LOG_LEVEL_[DEBUG|INFO|WARN|ERROR|FATAL|DISABLED] to compile out anything at that and before that logging level
+ */
+#ifndef CV_LOG_STRIP_LEVEL
+# if defined NDEBUG
+# define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_DEBUG
+# else
+# define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_VERBOSE
+# endif
+#endif
+
+
+#define CV_LOG_FATAL(tag, ...) for(;;) { std::stringstream ss; ss << "[FATAL:" << cv::utils::getThreadID() << "] " << __VA_ARGS__ << std::endl; std::cerr << ss.str(); break; }
+#define CV_LOG_ERROR(tag, ...) for(;;) { std::stringstream ss; ss << "[ERROR:" << cv::utils::getThreadID() << "] " << __VA_ARGS__ << std::endl; std::cerr << ss.str(); break; }
+#define CV_LOG_WARNING(tag, ...) for(;;) { std::stringstream ss; ss << "[ WARN:" << cv::utils::getThreadID() << "] " << __VA_ARGS__ << std::endl; std::cout << ss.str(); break; }
+#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_INFO
+#define CV_LOG_INFO(tag, ...)
+#else
+#define CV_LOG_INFO(tag, ...) for(;;) { std::stringstream ss; ss << "[ INFO:" << cv::utils::getThreadID() << "] " << __VA_ARGS__ << std::endl; std::cout << ss.str(); break; }
+#endif
+#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_DEBUG
+#define CV_LOG_DEBUG(tag, ...)
+#else
+#define CV_LOG_DEBUG(tag, ...) for(;;) { std::stringstream ss; ss << "[DEBUG:" << cv::utils::getThreadID() << "] " << __VA_ARGS__ << std::endl; std::cout << ss.str(); break; }
+#endif
+#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_VERBOSE
+#define CV_LOG_VERBOSE(tag, v, ...)
+#else
+#define CV_LOG_VERBOSE(tag, v, ...) for(;;) { std::stringstream ss; ss << "[VERB" << v << ":" << cv::utils::getThreadID() << "] " << __VA_ARGS__ << std::endl; std::cout << ss.str(); break; }
+#endif
+
+
+}} // namespace
+
+//! @}
+
+#endif // OPENCV_LOGGING_HPP
diff --git a/modules/core/include/opencv2/core/utils/trace.hpp b/modules/core/include/opencv2/core/utils/trace.hpp
new file mode 100644
index 0000000..1539fb9
--- /dev/null
+++ b/modules/core/include/opencv2/core/utils/trace.hpp
@@ -0,0 +1,250 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#ifndef OPENCV_TRACE_HPP
+#define OPENCV_TRACE_HPP
+
+#include <opencv2/core/cvdef.h>
+
+//! @addtogroup core_logging
+// This section describes OpenCV tracing utilities.
+//
+//! @{
+
+namespace cv {
+namespace utils {
+namespace trace {
+
+//! Macro to trace function
+#define CV_TRACE_FUNCTION()
+
+#define CV_TRACE_FUNCTION_SKIP_NESTED()
+
+//! Trace code scope.
+//! @note Dynamic names are not supported in this macro (on stack or heap). Use string literals here only, like "initialize".
+#define CV_TRACE_REGION(name_as_static_string_literal)
+//! mark completed of the current opened region and create new one
+//! @note Dynamic names are not supported in this macro (on stack or heap). Use string literals here only, like "step1".
+#define CV_TRACE_REGION_NEXT(name_as_static_string_literal)
+
+//! Macro to trace argument value
+#define CV_TRACE_ARG(arg_id)
+
+//! Macro to trace argument value (expanded version)
+#define CV_TRACE_ARG_VALUE(arg_id, arg_name, value)
+
+//! @cond IGNORED
+#define CV_TRACE_NS cv::utils::trace
+
+namespace details {
+
+#ifndef __OPENCV_TRACE
+# if defined __OPENCV_BUILD && !defined __OPENCV_TESTS && !defined __OPENCV_APPS
+# define __OPENCV_TRACE 1
+# else
+# define __OPENCV_TRACE 0
+# endif
+#endif
+
+#ifndef CV_TRACE_FILENAME
+# define CV_TRACE_FILENAME __FILE__
+#endif
+
+#ifndef CV__TRACE_FUNCTION
+# if defined _MSC_VER
+# define CV__TRACE_FUNCTION __FUNCSIG__
+# elif defined __GNUC__
+# define CV__TRACE_FUNCTION __PRETTY_FUNCTION__
+# else
+# define CV__TRACE_FUNCTION "<unknown>"
+# endif
+#endif
+
+//! Thread-local instance (usually allocated on stack)
+class CV_EXPORTS Region
+{
+public:
+ struct LocationExtraData;
+ struct LocationStaticStorage
+ {
+ LocationExtraData** ppExtra; //< implementation specific data
+ const char* name; //< region name (function name or other custom name)
+ const char* filename; //< source code filename
+ int line; //< source code line
+ int flags; //< flags (implementation code path: Plain, IPP, OpenCL)
+ };
+
+ Region(const LocationStaticStorage& location);
+ inline ~Region()
+ {
+ if (implFlags != 0)
+ destroy();
+ CV_DbgAssert(implFlags == 0);
+ CV_DbgAssert(pImpl == NULL);
+ }
+
+ class Impl;
+ Impl* pImpl; // NULL if current region is not active
+ int implFlags; // see RegionFlag, 0 if region is ignored
+
+ bool isActive() const { return pImpl != NULL; }
+
+ void destroy();
+private:
+ Region(const Region&); // disabled
+ Region& operator= (const Region&); // disabled
+};
+
+//! Specify region flags
+enum RegionLocationFlag {
+ REGION_FLAG_FUNCTION = (1 << 0), //< region is function (=1) / nested named region (=0)
+ REGION_FLAG_APP_CODE = (1 << 1), //< region is Application code (=1) / OpenCV library code (=0)
+ REGION_FLAG_SKIP_NESTED = (1 << 2), //< avoid processing of nested regions
+
+ REGION_FLAG_IMPL_IPP = (1 << 16), //< region is part of IPP code path
+ REGION_FLAG_IMPL_OPENCL = (2 << 16), //< region is part of OpenCL code path
+ REGION_FLAG_IMPL_OPENVX = (3 << 16), //< region is part of OpenVX code path
+
+ REGION_FLAG_IMPL_MASK = (15 << 16),
+
+ REGION_FLAG_REGION_FORCE = (1 << 30),
+ REGION_FLAG_REGION_NEXT = (1 << 31), //< close previous region (see #CV_TRACE_REGION_NEXT macro)
+
+ ENUM_REGION_FLAG_FORCE_INT = INT_MAX
+};
+
+struct CV_EXPORTS TraceArg {
+public:
+ struct ExtraData;
+ ExtraData** ppExtra;
+ const char* name;
+ int flags;
+};
+/** @brief Add meta information to current region (function)
+ * See CV_TRACE_ARG macro
+ * @param arg argument information structure (global static cache)
+ * @param value argument value (can by dynamic string literal in case of string, static allocation is not required)
+ */
+CV_EXPORTS void traceArg(const TraceArg& arg, const char* value);
+//! @overload
+CV_EXPORTS void traceArg(const TraceArg& arg, int value);
+//! @overload
+CV_EXPORTS void traceArg(const TraceArg& arg, int64 value);
+//! @overload
+CV_EXPORTS void traceArg(const TraceArg& arg, double value);
+
+#define CV__TRACE_LOCATION_VARNAME(loc_id) CVAUX_CONCAT(CVAUX_CONCAT(__cv_trace_location_, loc_id), __LINE__)
+#define CV__TRACE_LOCATION_EXTRA_VARNAME(loc_id) CVAUX_CONCAT(CVAUX_CONCAT(__cv_trace_location_extra_, loc_id) , __LINE__)
+
+#define CV__TRACE_DEFINE_LOCATION_(loc_id, name, flags) \
+ static CV_TRACE_NS::details::Region::LocationExtraData* CV__TRACE_LOCATION_EXTRA_VARNAME(loc_id) = 0; \
+ static const CV_TRACE_NS::details::Region::LocationStaticStorage \
+ CV__TRACE_LOCATION_VARNAME(loc_id) = { &(CV__TRACE_LOCATION_EXTRA_VARNAME(loc_id)), name, CV_TRACE_FILENAME, __LINE__, flags};
+
+#define CV__TRACE_DEFINE_LOCATION_FN(name, flags) CV__TRACE_DEFINE_LOCATION_(fn, name, (flags | CV_TRACE_NS::details::REGION_FLAG_FUNCTION))
+
+
+#define CV__TRACE_OPENCV_FUNCTION() \
+ CV__TRACE_DEFINE_LOCATION_FN(CV__TRACE_FUNCTION, 0); \
+ const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn));
+
+#define CV__TRACE_OPENCV_FUNCTION_NAME(name) \
+ CV__TRACE_DEFINE_LOCATION_FN(name, 0); \
+ const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn));
+
+#define CV__TRACE_APP_FUNCTION() \
+ CV__TRACE_DEFINE_LOCATION_FN(CV__TRACE_FUNCTION, CV_TRACE_NS::details::REGION_FLAG_APP_CODE); \
+ const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn));
+
+#define CV__TRACE_APP_FUNCTION_NAME(name) \
+ CV__TRACE_DEFINE_LOCATION_FN(name, CV_TRACE_NS::details::REGION_FLAG_APP_CODE); \
+ const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn));
+
+
+#define CV__TRACE_OPENCV_FUNCTION_SKIP_NESTED() \
+ CV__TRACE_DEFINE_LOCATION_FN(CV__TRACE_FUNCTION, CV_TRACE_NS::details::REGION_FLAG_SKIP_NESTED); \
+ const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn));
+
+#define CV__TRACE_OPENCV_FUNCTION_NAME_SKIP_NESTED(name) \
+ CV__TRACE_DEFINE_LOCATION_FN(name, CV_TRACE_NS::details::REGION_FLAG_SKIP_NESTED); \
+ const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn));
+
+#define CV__TRACE_APP_FUNCTION_SKIP_NESTED() \
+ CV__TRACE_DEFINE_LOCATION_FN(CV__TRACE_FUNCTION, CV_TRACE_NS::details::REGION_FLAG_SKIP_NESTED | CV_TRACE_NS::details::REGION_FLAG_APP_CODE); \
+ const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn));
+
+
+#define CV__TRACE_REGION_(name_as_static_string_literal, flags) \
+ CV__TRACE_DEFINE_LOCATION_(region, name_as_static_string_literal, flags); \
+ CV_TRACE_NS::details::Region CVAUX_CONCAT(__region_, __LINE__)(CV__TRACE_LOCATION_VARNAME(region));
+
+#define CV__TRACE_REGION(name_as_static_string_literal) CV__TRACE_REGION_(name_as_static_string_literal, 0)
+#define CV__TRACE_REGION_NEXT(name_as_static_string_literal) CV__TRACE_REGION_(name_as_static_string_literal, CV_TRACE_NS::details::REGION_FLAG_REGION_NEXT)
+
+#define CV__TRACE_ARG_VARNAME(arg_id) CVAUX_CONCAT(__cv_trace_arg_ ## arg_id, __LINE__)
+#define CV__TRACE_ARG_EXTRA_VARNAME(arg_id) CVAUX_CONCAT(__cv_trace_arg_extra_ ## arg_id, __LINE__)
+
+#define CV__TRACE_DEFINE_ARG_(arg_id, name, flags) \
+ static CV_TRACE_NS::details::TraceArg::ExtraData* CV__TRACE_ARG_EXTRA_VARNAME(arg_id) = 0; \
+ static const CV_TRACE_NS::details::TraceArg \
+ CV__TRACE_ARG_VARNAME(arg_id) = { &(CV__TRACE_ARG_EXTRA_VARNAME(arg_id)), name, flags };
+
+#define CV__TRACE_ARG_VALUE(arg_id, arg_name, value) \
+ CV__TRACE_DEFINE_ARG_(arg_id, arg_name, 0); \
+ CV_TRACE_NS::details::traceArg((CV__TRACE_ARG_VARNAME(arg_id)), value);
+
+#define CV__TRACE_ARG(arg_id) CV_TRACE_ARG_VALUE(arg_id, #arg_id, (arg_id))
+
+} // namespace
+
+#ifndef OPENCV_DISABLE_TRACE
+#undef CV_TRACE_FUNCTION
+#undef CV_TRACE_FUNCTION_SKIP_NESTED
+#if __OPENCV_TRACE
+#define CV_TRACE_FUNCTION CV__TRACE_OPENCV_FUNCTION
+#define CV_TRACE_FUNCTION_SKIP_NESTED CV__TRACE_OPENCV_FUNCTION_SKIP_NESTED
+#else
+#define CV_TRACE_FUNCTION CV__TRACE_APP_FUNCTION
+#define CV_TRACE_FUNCTION_SKIP_NESTED CV__TRACE_APP_FUNCTION_SKIP_NESTED
+#endif
+
+#undef CV_TRACE_REGION
+#define CV_TRACE_REGION CV__TRACE_REGION
+
+#undef CV_TRACE_REGION_NEXT
+#define CV_TRACE_REGION_NEXT CV__TRACE_REGION_NEXT
+
+#undef CV_TRACE_ARG_VALUE
+#define CV_TRACE_ARG_VALUE(arg_id, arg_name, value) \
+ if (__region_fn.isActive()) \
+ { \
+ CV__TRACE_ARG_VALUE(arg_id, arg_name, value); \
+ }
+
+#undef CV_TRACE_ARG
+#define CV_TRACE_ARG CV__TRACE_ARG
+
+#endif // OPENCV_DISABLE_TRACE
+
+#ifdef OPENCV_TRACE_VERBOSE
+#define CV_TRACE_FUNCTION_VERBOSE CV_TRACE_FUNCTION
+#define CV_TRACE_REGION_VERBOSE CV_TRACE_REGION
+#define CV_TRACE_REGION_NEXT_VERBOSE CV_TRACE_REGION_NEXT
+#define CV_TRACE_ARG_VALUE_VERBOSE CV_TRACE_ARG_VALUE
+#define CV_TRACE_ARG_VERBOSE CV_TRACE_ARG
+#else
+#define CV_TRACE_FUNCTION_VERBOSE(...)
+#define CV_TRACE_REGION_VERBOSE(...)
+#define CV_TRACE_REGION_NEXT_VERBOSE(...)
+#define CV_TRACE_ARG_VALUE_VERBOSE(...)
+#define CV_TRACE_ARG_VERBOSE(...)
+#endif
+
+//! @endcond
+
+}}} // namespace
+
+//! @}
+
+#endif // OPENCV_TRACE_HPP
diff --git a/modules/core/include/opencv2/core/utils/trace.private.hpp b/modules/core/include/opencv2/core/utils/trace.private.hpp
new file mode 100644
index 0000000..1798166
--- /dev/null
+++ b/modules/core/include/opencv2/core/utils/trace.private.hpp
@@ -0,0 +1,419 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#ifndef OPENCV_TRACE_PRIVATE_HPP
+#define OPENCV_TRACE_PRIVATE_HPP
+
+#ifdef OPENCV_TRACE
+
+#include <opencv2/core/utils/logger.hpp>
+
+#include "trace.hpp"
+
+//! @cond IGNORED
+
+#include <deque>
+#include <ostream>
+
+#define INTEL_ITTNOTIFY_API_PRIVATE 1
+#ifdef OPENCV_WITH_ITT
+#include "ittnotify.h"
+#endif
+
+#ifndef DEBUG_ONLY
+#ifdef _DEBUG
+#define DEBUG_ONLY(...) __VA_ARGS__
+#else
+#define DEBUG_ONLY(...) (void)0
+#endif
+#endif
+
+#ifndef DEBUG_ONLY_
+#ifdef _DEBUG
+#define DEBUG_ONLY_(...) __VA_ARGS__
+#else
+#define DEBUG_ONLY_(...)
+#endif
+#endif
+
+
+namespace cv {
+namespace utils {
+namespace trace {
+namespace details {
+
+#define CV__TRACE_OPENCV_FUNCTION_NAME_(name, flags) \
+ CV__TRACE_DEFINE_LOCATION_FN(name, flags); \
+ const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn));
+
+
+enum RegionFlag {
+ REGION_FLAG__NEED_STACK_POP = (1 << 0),
+ REGION_FLAG__ACTIVE = (1 << 1),
+
+ ENUM_REGION_FLAG_IMPL_FORCE_INT = INT_MAX
+};
+
+
+class TraceMessage;
+
+class TraceStorage {
+public:
+ TraceStorage() {}
+ virtual ~TraceStorage() {};
+
+ virtual bool put(const TraceMessage& msg) const = 0;
+};
+
+struct RegionStatistics
+{
+ int currentSkippedRegions;
+
+ int64 duration;
+#ifdef HAVE_IPP
+ int64 durationImplIPP;
+#endif
+#ifdef HAVE_OPENCL
+ int64 durationImplOpenCL;
+#endif
+#ifdef HAVE_OPENVX
+ int64 durationImplOpenVX;
+#endif
+
+ RegionStatistics() :
+ currentSkippedRegions(0),
+ duration(0)
+#ifdef HAVE_IPP
+ ,durationImplIPP(0)
+#endif
+#ifdef HAVE_OPENCL
+ ,durationImplOpenCL(0)
+#endif
+#ifdef HAVE_OPENVX
+ ,durationImplOpenVX(0)
+#endif
+ {}
+
+ void grab(RegionStatistics& result)
+ {
+ result.currentSkippedRegions = currentSkippedRegions; currentSkippedRegions = 0;
+ result.duration = duration; duration = 0;
+#ifdef HAVE_IPP
+ result.durationImplIPP = durationImplIPP; durationImplIPP = 0;
+#endif
+#ifdef HAVE_OPENCL
+ result.durationImplOpenCL = durationImplOpenCL; durationImplOpenCL = 0;
+#endif
+#ifdef HAVE_OPENVX
+ result.durationImplOpenVX = durationImplOpenVX; durationImplOpenVX = 0;
+#endif
+ }
+
+ void append(RegionStatistics& stat)
+ {
+ currentSkippedRegions += stat.currentSkippedRegions;
+ duration += stat.duration;
+#ifdef HAVE_IPP
+ durationImplIPP += stat.durationImplIPP;
+#endif
+#ifdef HAVE_OPENCL
+ durationImplOpenCL += stat.durationImplOpenCL;
+#endif
+#ifdef HAVE_OPENVX
+ durationImplOpenVX += stat.durationImplOpenVX;
+#endif
+ }
+
+ void multiply(const float c)
+ {
+ duration = (int64)(duration * c);
+#ifdef HAVE_IPP
+ durationImplIPP = (int64)(durationImplIPP * c);
+#endif
+#ifdef HAVE_OPENCL
+ durationImplOpenCL = (int64)(durationImplOpenCL * c);
+#endif
+#ifdef HAVE_OPENVX
+ durationImplOpenVX = (int64)(durationImplOpenVX * c);
+#endif
+ }
+};
+
+static inline
+std::ostream& operator<<(std::ostream& out, const RegionStatistics& stat)
+{
+ out << "skip=" << stat.currentSkippedRegions
+ << " duration=" << stat.duration
+#ifdef HAVE_IPP
+ << " durationImplIPP=" << stat.durationImplIPP
+#endif
+#ifdef HAVE_OPENCL
+ << " durationImplOpenCL=" << stat.durationImplOpenCL
+#endif
+#ifdef HAVE_OPENVX
+ << " durationImplOpenVX=" << stat.durationImplOpenVX
+#endif
+ ;
+ return out;
+}
+
+struct RegionStatisticsStatus
+{
+ int _skipDepth;
+#ifdef HAVE_IPP
+ int ignoreDepthImplIPP;
+#endif
+#ifdef HAVE_OPENCL
+ int ignoreDepthImplOpenCL;
+#endif
+#ifdef HAVE_OPENVX
+ int ignoreDepthImplOpenVX;
+#endif
+
+ RegionStatisticsStatus() { reset(); }
+
+ void reset()
+ {
+ _skipDepth = -1;
+#ifdef HAVE_IPP
+ ignoreDepthImplIPP = 0;
+#endif
+#ifdef HAVE_OPENCL
+ ignoreDepthImplOpenCL = 0;
+#endif
+#ifdef HAVE_OPENVX
+ ignoreDepthImplOpenVX = 0;
+#endif
+ }
+
+ void propagateFrom(const RegionStatisticsStatus& src)
+ {
+ _skipDepth = -1;
+ if (src._skipDepth >= 0)
+ enableSkipMode(0);
+#ifdef HAVE_IPP
+ ignoreDepthImplIPP = src.ignoreDepthImplIPP ? 1 : 0;
+#endif
+#ifdef HAVE_OPENCL
+ ignoreDepthImplOpenCL = src.ignoreDepthImplOpenCL ? 1 : 0;
+#endif
+#ifdef HAVE_OPENVX
+ ignoreDepthImplOpenVX = src.ignoreDepthImplOpenVX ? 1 : 0;
+#endif
+ }
+
+ void enableSkipMode(int depth);
+ void checkResetSkipMode(int leaveDepth);
+};
+
+static inline
+std::ostream& operator<<(std::ostream& out, const RegionStatisticsStatus& s)
+{
+ out << "ignore={";
+ if (s._skipDepth >= 0)
+ out << " SKIP=" << s._skipDepth;
+#ifdef HAVE_IPP
+ if (s.ignoreDepthImplIPP)
+ out << " IPP=" << s.ignoreDepthImplIPP;
+#endif
+#ifdef HAVE_OPENCL
+ if (s.ignoreDepthImplOpenCL)
+ out << " OpenCL=" << s.ignoreDepthImplOpenCL;
+#endif
+#ifdef HAVE_OPENVX
+ if (s.ignoreDepthImplOpenVX)
+ out << " OpenVX=" << s.ignoreDepthImplOpenVX;
+#endif
+ out << "}";
+ return out;
+}
+
+//! TraceManager for local thread
+struct TraceManagerThreadLocal
+{
+ const int threadID;
+ int region_counter;
+
+ size_t totalSkippedEvents;
+
+ Region* currentActiveRegion;
+
+ struct StackEntry
+ {
+ Region* region;
+ const Region::LocationStaticStorage* location;
+ int64 beginTimestamp;
+ StackEntry(Region* region_, const Region::LocationStaticStorage* location_, int64 beginTimestamp_) :
+ region(region_), location(location_), beginTimestamp(beginTimestamp_)
+ {}
+ StackEntry() : region(NULL), location(NULL), beginTimestamp(-1) {}
+ };
+ std::deque<StackEntry> stack;
+
+ int regionDepth; // functions only (no named regions)
+ int regionDepthOpenCV; // functions from OpenCV library
+
+ RegionStatistics stat;
+ RegionStatisticsStatus stat_status;
+
+ StackEntry dummy_stack_top; // parallel_for root region
+ RegionStatistics parallel_for_stat;
+ RegionStatisticsStatus parallel_for_stat_status;
+ size_t parallel_for_stack_size;
+
+
+ mutable cv::Ptr<TraceStorage> storage;
+
+ TraceManagerThreadLocal() :
+ threadID(cv::utils::getThreadID()),
+ region_counter(0), totalSkippedEvents(0),
+ currentActiveRegion(NULL),
+ regionDepth(0),
+ regionDepthOpenCV(0),
+ parallel_for_stack_size(0)
+ {
+ }
+
+ ~TraceManagerThreadLocal();
+
+ TraceStorage* getStorage() const;
+
+ void recordLocation(const Region::LocationStaticStorage& location);
+ void recordRegionEnter(const Region& region);
+ void recordRegionLeave(const Region& region, const RegionStatistics& result);
+ void recordRegionArg(const Region& region, const TraceArg& arg, const char& value);
+
+ inline void stackPush(Region* region, const Region::LocationStaticStorage* location, int64 beginTimestamp)
+ {
+ stack.push_back(StackEntry(region, location, beginTimestamp));
+ }
+ inline Region* stackTopRegion() const
+ {
+ if (stack.empty())
+ return dummy_stack_top.region;
+ return stack.back().region;
+ }
+ inline const Region::LocationStaticStorage* stackTopLocation() const
+ {
+ if (stack.empty())
+ return dummy_stack_top.location;
+ return stack.back().location;
+ }
+ inline int64 stackTopBeginTimestamp() const
+ {
+ if (stack.empty())
+ return dummy_stack_top.beginTimestamp;
+ return stack.back().beginTimestamp;
+ }
+ inline void stackPop()
+ {
+ CV_DbgAssert(!stack.empty());
+ stack.pop_back();
+ }
+ void dumpStack(std::ostream& out, bool onlyFunctions) const;
+
+ inline Region* getCurrentActiveRegion()
+ {
+ return currentActiveRegion;
+ }
+
+ inline int getCurrentDepth() const { return (int)stack.size(); }
+};
+
+class CV_EXPORTS TraceManager
+{
+public:
+ TraceManager();
+ ~TraceManager();
+
+ static bool isActivated();
+
+ Mutex mutexCreate;
+ Mutex mutexCount;
+
+ TLSData<TraceManagerThreadLocal> tls;
+
+ cv::Ptr<TraceStorage> trace_storage;
+private:
+ // disable copying
+ TraceManager(const TraceManager&);
+ TraceManager& operator=(const TraceManager&);
+};
+
+CV_EXPORTS TraceManager& getTraceManager();
+inline Region* getCurrentActiveRegion() { return getTraceManager().tls.get()->getCurrentActiveRegion(); }
+inline Region* getCurrentRegion() { return getTraceManager().tls.get()->stackTopRegion(); }
+
+void parallelForSetRootRegion(const Region& rootRegion, const TraceManagerThreadLocal& root_ctx);
+void parallelForAttachNestedRegion(const Region& rootRegion);
+void parallelForFinalize(const Region& rootRegion);
+
+
+
+
+
+
+
+struct Region::LocationExtraData
+{
+ int global_location_id; // 0 - region is disabled
+#ifdef OPENCV_WITH_ITT
+ // Special fields for ITT
+ __itt_string_handle* volatile ittHandle_name;
+ __itt_string_handle* volatile ittHandle_filename;
+#endif
+ LocationExtraData(const LocationStaticStorage& location);
+
+ static Region::LocationExtraData* init(const Region::LocationStaticStorage& location);
+};
+
+class Region::Impl
+{
+public:
+ const LocationStaticStorage& location;
+
+ Region& region;
+ Region* const parentRegion;
+
+ const int threadID;
+ const int global_region_id;
+
+ const int64 beginTimestamp;
+ int64 endTimestamp;
+
+ int directChildrenCount;
+
+ enum OptimizationPath {
+ CODE_PATH_PLAIN = 0,
+ CODE_PATH_IPP,
+ CODE_PATH_OPENCL,
+ CODE_PATH_OPENVX
+ };
+
+#ifdef OPENCV_WITH_ITT
+ bool itt_id_registered;
+ __itt_id itt_id;
+#endif
+
+ Impl(TraceManagerThreadLocal& ctx, Region* parentRegion_, Region& region_, const LocationStaticStorage& location_, int64 beginTimestamp_);
+
+ void enterRegion(TraceManagerThreadLocal& ctx);
+ void leaveRegion(TraceManagerThreadLocal& ctx);
+
+ void registerRegion(TraceManagerThreadLocal& ctx);
+
+ void release();
+protected:
+ ~Impl();
+};
+
+
+
+}}}} // namespace
+
+//! @endcond
+
+#endif
+
+#endif // OPENCV_TRACE_PRIVATE_HPP
diff --git a/modules/core/include/opencv2/core/version.hpp b/modules/core/include/opencv2/core/version.hpp
index b4c8f25..b22b027 100644
--- a/modules/core/include/opencv2/core/version.hpp
+++ b/modules/core/include/opencv2/core/version.hpp
@@ -51,7 +51,7 @@
#define OPENCV_VERSION_HPP
#define CV_VERSION_MAJOR 3
-#define CV_VERSION_MINOR 2
+#define CV_VERSION_MINOR 3
#define CV_VERSION_REVISION 0
#define CV_VERSION_STATUS ""
diff --git a/modules/core/misc/java/gen_dict.json b/modules/core/misc/java/gen_dict.json
new file mode 100644
index 0000000..e3ce880
--- /dev/null
+++ b/modules/core/misc/java/gen_dict.json
@@ -0,0 +1,896 @@
+{
+ "class_ignore_list" : [
+ "FileNode",
+ "FileStorage",
+ "KDTree",
+ "KeyPoint",
+ "DMatch"
+ ],
+ "missing_consts" : {
+ "Core" : {
+ "private" : [
+ ["CV_8U", 0 ], ["CV_8S", 1 ],
+ ["CV_16U", 2 ], ["CV_16S", 3 ],
+ ["CV_32S", 4 ],
+ ["CV_32F", 5 ], ["CV_64F", 6 ],
+ ["CV_USRTYPE1", 7 ]
+ ],
+ "public" : [
+ ["SVD_MODIFY_A", 1], ["SVD_NO_UV", 2], ["SVD_FULL_UV", 4],
+ ["FILLED", -1],
+ ["REDUCE_SUM", 0], ["REDUCE_AVG", 1], ["REDUCE_MAX", 2], ["REDUCE_MIN", 3]
+ ]
+ }
+ },
+ "ManualFuncs" : {
+ "Core" : {
+ "minMaxLoc" : {
+ "j_code" : [
+ "// manual port",
+ "public static class MinMaxLocResult {",
+ " public double minVal;",
+ " public double maxVal;",
+ " public Point minLoc;",
+ " public Point maxLoc;",
+ "\n",
+ " public MinMaxLocResult() {",
+ " minVal=0; maxVal=0;",
+ " minLoc=new Point();",
+ " maxLoc=new Point();",
+ " }",
+ "}",
+ "\n",
+ "// C++: minMaxLoc(Mat src, double* minVal, double* maxVal=0, Point* minLoc=0, Point* maxLoc=0, InputArray mask=noArray())",
+ "\n",
+ "//javadoc: minMaxLoc(src, mask)",
+ "public static MinMaxLocResult minMaxLoc(Mat src, Mat mask) {",
+ " MinMaxLocResult res = new MinMaxLocResult();",
+ " long maskNativeObj=0;",
+ " if (mask != null) {",
+ " maskNativeObj=mask.nativeObj;",
+ " }",
+ " double resarr[] = n_minMaxLocManual(src.nativeObj, maskNativeObj);",
+ " res.minVal=resarr[0];",
+ " res.maxVal=resarr[1];",
+ " res.minLoc.x=resarr[2];",
+ " res.minLoc.y=resarr[3];",
+ " res.maxLoc.x=resarr[4];",
+ " res.maxLoc.y=resarr[5];",
+ " return res;",
+ "}",
+ "\n",
+ "//javadoc: minMaxLoc(src)",
+ "public static MinMaxLocResult minMaxLoc(Mat src) {",
+ " return minMaxLoc(src, null);",
+ "}"
+ ],
+ "jn_code" : [
+ "private static native double[] n_minMaxLocManual(long src_nativeObj, long mask_nativeObj);\n"
+ ],
+ "cpp_code" : [
+ "// C++: minMaxLoc(Mat src, double* minVal, double* maxVal=0, Point* minLoc=0, Point* maxLoc=0, InputArray mask=noArray())",
+ "JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1minMaxLocManual (JNIEnv*, jclass, jlong, jlong);",
+ "\n",
+ "JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1minMaxLocManual",
+ " (JNIEnv* env, jclass, jlong src_nativeObj, jlong mask_nativeObj)",
+ "{",
+ " try {",
+ " LOGD(\"Core::n_1minMaxLoc()\");",
+ " jdoubleArray result;",
+ " result = env->NewDoubleArray(6);",
+ " if (result == NULL) {",
+ " return NULL; /* out of memory error thrown */",
+ " }",
+ "\n",
+ " Mat& src = *((Mat*)src_nativeObj);",
+ "\n",
+ " double minVal, maxVal;",
+ " Point minLoc, maxLoc;",
+ " if (mask_nativeObj != 0) {",
+ " Mat& mask = *((Mat*)mask_nativeObj);",
+ " minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc, mask);",
+ " } else {",
+ " minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc);",
+ " }",
+ "\n",
+ " jdouble fill[6];",
+ " fill[0]=minVal;",
+ " fill[1]=maxVal;",
+ " fill[2]=minLoc.x;",
+ " fill[3]=minLoc.y;",
+ " fill[4]=maxLoc.x;",
+ " fill[5]=maxLoc.y;",
+ "\n",
+ " env->SetDoubleArrayRegion(result, 0, 6, fill);",
+ "\n",
+ " return result;",
+ "\n",
+ " } catch(const cv::Exception& e) {",
+ " LOGD(\"Core::n_1minMaxLoc() catched cv::Exception: %s\", e.what());",
+ " jclass je = env->FindClass(\"org/opencv/core/CvException\");",
+ " if(!je) je = env->FindClass(\"java/lang/Exception\");",
+ " env->ThrowNew(je, e.what());",
+ " return NULL;",
+ " } catch (...) {",
+ " LOGD(\"Core::n_1minMaxLoc() catched unknown exception (...)\");",
+ " jclass je = env->FindClass(\"java/lang/Exception\");",
+ " env->ThrowNew(je, \"Unknown exception in JNI code {core::minMaxLoc()}\");",
+ " return NULL;",
+ " }",
+ "}",
+ "\n"
+ ]
+ },
+ "checkHardwareSupport" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
+ "setUseOptimized" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
+ "useOptimized" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] }
+ }
+ },
+ "func_arg_fix" : {
+ "randu" : { "low" : {"ctype" : "double"},
+ "high" : {"ctype" : "double"} },
+ "randn" : { "mean" : {"ctype" : "double"},
+ "stddev" : {"ctype" : "double"} },
+ "inRange" : { "lowerb" : {"ctype" : "Scalar"},
+ "upperb" : {"ctype" : "Scalar"} },
+ "boundingRect" : { "points" : {"ctype" : "vector_Point"} },
+ "hconcat" : { "src" : {"ctype" : "vector_Mat"} },
+ "vconcat" : { "src" : {"ctype" : "vector_Mat"} },
+ "checkRange" : {"pos" : {"ctype" : "*"} },
+ "meanStdDev" : { "mean" : {"ctype" : "vector_double"},
+ "stddev" : {"ctype" : "vector_double"} },
+ "mixChannels" : { "dst" : {"attrib" : []} }
+ },
+ "type_dict" : {
+ "Algorithm": {
+ "j_type": "Feature2D",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "Feature2D %(n)s",
+ "suffix": "J",
+ "j_import": "org.opencv.core.Algorithm"
+ },
+ "CvSlice": {
+ "j_type": "Range",
+ "jn_args": [
+ [
+ "int",
+ ".start"
+ ],
+ [
+ "int",
+ ".end"
+ ]
+ ],
+ "jni_type": "jdoubleArray",
+ "jni_var": "Range %(n)s(%(n)s_start, %(n)s_end)",
+ "suffix": "II",
+ "j_import": "org.opencv.core.Range"
+ },
+ "CvTermCriteria": {
+ "j_type": "TermCriteria",
+ "jn_args": [
+ [
+ "int",
+ ".type"
+ ],
+ [
+ "int",
+ ".maxCount"
+ ],
+ [
+ "double",
+ ".epsilon"
+ ]
+ ],
+ "jni_type": "jdoubleArray",
+ "jni_var": "TermCriteria %(n)s(%(n)s_type, %(n)s_maxCount, %(n)s_epsilon)",
+ "suffix": "IID",
+ "j_import": "org.opencv.core.TermCriteria"
+ },
+ "DMatch": {
+ "j_type": "DMatch",
+ "jn_args": [
+ [
+ "int",
+ "queryIdx"
+ ],
+ [
+ "int",
+ "trainIdx"
+ ],
+ [
+ "int",
+ "imgIdx"
+ ],
+ [
+ "float",
+ "distance"
+ ]
+ ],
+ "jni_type": "jdoubleArray",
+ "jni_var": "DMatch %(n)s(%(n)s_queryIdx, %(n)s_trainIdx, %(n)s_imgIdx, %(n)s_distance)",
+ "suffix": "IIIF",
+ "j_import": "org.opencv.core.DMatch"
+ },
+ "KeyPoint": {
+ "j_type": "KeyPoint",
+ "jn_args": [
+ [
+ "float",
+ ".x"
+ ],
+ [
+ "float",
+ ".y"
+ ],
+ [
+ "float",
+ ".size"
+ ],
+ [
+ "float",
+ ".angle"
+ ],
+ [
+ "float",
+ ".response"
+ ],
+ [
+ "int",
+ ".octave"
+ ],
+ [
+ "int",
+ ".class_id"
+ ]
+ ],
+ "jni_type": "jdoubleArray",
+ "jni_var": "KeyPoint %(n)s(%(n)s_x, %(n)s_y, %(n)s_size, %(n)s_angle, %(n)s_response, %(n)s_octave, %(n)s_class_id)",
+ "suffix": "FFFFFII",
+ "j_import": "org.opencv.core.KeyPoint"
+ },
+ "Mat": {
+ "j_type": "Mat",
+ "jn_args": [
+ [
+ "__int64",
+ ".nativeObj"
+ ]
+ ],
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "Mat& %(n)s = *((Mat*)%(n)s_nativeObj)",
+ "suffix": "J",
+ "j_import": "org.opencv.core.Mat"
+ },
+ "Moments": {
+ "j_type": "Moments",
+ "jn_args": [
+ [
+ "double",
+ ".m00"
+ ],
+ [
+ "double",
+ ".m10"
+ ],
+ [
+ "double",
+ ".m01"
+ ],
+ [
+ "double",
+ ".m20"
+ ],
+ [
+ "double",
+ ".m11"
+ ],
+ [
+ "double",
+ ".m02"
+ ],
+ [
+ "double",
+ ".m30"
+ ],
+ [
+ "double",
+ ".m21"
+ ],
+ [
+ "double",
+ ".m12"
+ ],
+ [
+ "double",
+ ".m03"
+ ]
+ ],
+ "jni_type": "jdoubleArray",
+ "jni_var": "Moments %(n)s(%(n)s_m00, %(n)s_m10, %(n)s_m01, %(n)s_m20, %(n)s_m11, %(n)s_m02, %(n)s_m30, %(n)s_m21, %(n)s_m12, %(n)s_m03)",
+ "suffix": "DDDDDDDDDD"
+ },
+ "Point": {
+ "j_type": "Point",
+ "jn_args": [
+ [
+ "double",
+ ".x"
+ ],
+ [
+ "double",
+ ".y"
+ ]
+ ],
+ "jni_type": "jdoubleArray",
+ "jni_var": "Point %(n)s((int)%(n)s_x, (int)%(n)s_y)",
+ "suffix": "DD",
+ "j_import": "org.opencv.core.Point"
+ },
+ "Point2d": {
+ "j_type": "Point",
+ "jn_args": [
+ [
+ "double",
+ ".x"
+ ],
+ [
+ "double",
+ ".y"
+ ]
+ ],
+ "jni_type": "jdoubleArray",
+ "jni_var": "Point2d %(n)s(%(n)s_x, %(n)s_y)",
+ "suffix": "DD",
+ "j_import": "org.opencv.core.Point"
+ },
+ "Point2f": {
+ "j_type": "Point",
+ "jn_args": [
+ [
+ "double",
+ ".x"
+ ],
+ [
+ "double",
+ ".y"
+ ]
+ ],
+ "jni_type": "jdoubleArray",
+ "jni_var": "Point2f %(n)s((float)%(n)s_x, (float)%(n)s_y)",
+ "suffix": "DD",
+ "j_import": "org.opencv.core.Point"
+ },
+ "Point3d": {
+ "j_type": "Point3",
+ "jn_args": [
+ [
+ "double",
+ ".x"
+ ],
+ [
+ "double",
+ ".y"
+ ],
+ [
+ "double",
+ ".z"
+ ]
+ ],
+ "jni_type": "jdoubleArray",
+ "jni_var": "Point3d %(n)s(%(n)s_x, %(n)s_y, %(n)s_z)",
+ "suffix": "DDD",
+ "j_import": "org.opencv.core.Point3"
+ },
+ "Point3f": {
+ "j_type": "Point3",
+ "jn_args": [
+ [
+ "double",
+ ".x"
+ ],
+ [
+ "double",
+ ".y"
+ ],
+ [
+ "double",
+ ".z"
+ ]
+ ],
+ "jni_type": "jdoubleArray",
+ "jni_var": "Point3f %(n)s((float)%(n)s_x, (float)%(n)s_y, (float)%(n)s_z)",
+ "suffix": "DDD",
+ "j_import": "org.opencv.core.Point3"
+ },
+ "Point3i": {
+ "j_type": "Point3",
+ "jn_args": [
+ [
+ "double",
+ ".x"
+ ],
+ [
+ "double",
+ ".y"
+ ],
+ [
+ "double",
+ ".z"
+ ]
+ ],
+ "jni_type": "jdoubleArray",
+ "jni_var": "Point3i %(n)s((int)%(n)s_x, (int)%(n)s_y, (int)%(n)s_z)",
+ "suffix": "DDD",
+ "j_import": "org.opencv.core.Point3"
+ },
+ "Range": {
+ "j_type": "Range",
+ "jn_args": [
+ [
+ "int",
+ ".start"
+ ],
+ [
+ "int",
+ ".end"
+ ]
+ ],
+ "jni_type": "jdoubleArray",
+ "jni_var": "Range %(n)s(%(n)s_start, %(n)s_end)",
+ "suffix": "II",
+ "j_import": "org.opencv.core.Range"
+ },
+ "Rect": {
+ "j_type": "Rect",
+ "jn_args": [
+ [
+ "int",
+ ".x"
+ ],
+ [
+ "int",
+ ".y"
+ ],
+ [
+ "int",
+ ".width"
+ ],
+ [
+ "int",
+ ".height"
+ ]
+ ],
+ "jni_type": "jdoubleArray",
+ "jni_var": "Rect %(n)s(%(n)s_x, %(n)s_y, %(n)s_width, %(n)s_height)",
+ "suffix": "IIII",
+ "j_import": "org.opencv.core.Rect"
+ },
+ "Rect2d": {
+ "j_type": "Rect2d",
+ "jn_args": [
+ [
+ "double",
+ ".x"
+ ],
+ [
+ "double",
+ ".y"
+ ],
+ [
+ "double",
+ ".width"
+ ],
+ [
+ "double",
+ ".height"
+ ]
+ ],
+ "jni_type": "jdoubleArray",
+ "jni_var": "Rect %(n)s(%(n)s_x, %(n)s_y, %(n)s_width, %(n)s_height)",
+ "suffix": "DDDD",
+ "j_import": "org.opencv.core.Rect2d"
+ },
+ "RotatedRect": {
+ "j_type": "RotatedRect",
+ "jn_args": [
+ [
+ "double",
+ ".center.x"
+ ],
+ [
+ "double",
+ ".center.y"
+ ],
+ [
+ "double",
+ ".size.width"
+ ],
+ [
+ "double",
+ ".size.height"
+ ],
+ [
+ "double",
+ ".angle"
+ ]
+ ],
+ "jni_type": "jdoubleArray",
+ "jni_var": "RotatedRect %(n)s(cv::Point2f(%(n)s_center_x, %(n)s_center_y), cv::Size2f(%(n)s_size_width, %(n)s_size_height), %(n)s_angle)",
+ "suffix": "DDDDD",
+ "j_import": "org.opencv.core.RotatedRect"
+ },
+ "Scalar": {
+ "j_type": "Scalar",
+ "jn_args": [
+ [
+ "double",
+ ".val[0]"
+ ],
+ [
+ "double",
+ ".val[1]"
+ ],
+ [
+ "double",
+ ".val[2]"
+ ],
+ [
+ "double",
+ ".val[3]"
+ ]
+ ],
+ "jni_type": "jdoubleArray",
+ "jni_var": "Scalar %(n)s(%(n)s_val0, %(n)s_val1, %(n)s_val2, %(n)s_val3)",
+ "suffix": "DDDD",
+ "j_import": "org.opencv.core.Scalar"
+ },
+ "Size": {
+ "j_type": "Size",
+ "jn_args": [
+ [
+ "double",
+ ".width"
+ ],
+ [
+ "double",
+ ".height"
+ ]
+ ],
+ "jni_type": "jdoubleArray",
+ "jni_var": "Size %(n)s((int)%(n)s_width, (int)%(n)s_height)",
+ "suffix": "DD",
+ "j_import": "org.opencv.core.Size"
+ },
+ "Size2f": {
+ "j_type": "Size",
+ "jn_args": [
+ [
+ "double",
+ ".width"
+ ],
+ [
+ "double",
+ ".height"
+ ]
+ ],
+ "jni_type": "jdoubleArray",
+ "jni_var": "Size2f %(n)s((float)%(n)s_width, (float)%(n)s_height)",
+ "suffix": "DD",
+ "j_import": "org.opencv.core.Size"
+ },
+ "String": {
+ "j_type": "String",
+ "jn_type": "String",
+ "jni_name": "n_%(n)s",
+ "jni_type": "jstring",
+ "jni_var": "const char* utf_%(n)s = env->GetStringUTFChars(%(n)s, 0); String n_%(n)s( utf_%(n)s ? utf_%(n)s : \"\" ); env->ReleaseStringUTFChars(%(n)s, utf_%(n)s)",
+ "suffix": "Ljava_lang_String_2",
+ "j_import": "java.lang.String"
+ },
+ "TermCriteria": {
+ "j_type": "TermCriteria",
+ "jn_args": [
+ [
+ "int",
+ ".type"
+ ],
+ [
+ "int",
+ ".maxCount"
+ ],
+ [
+ "double",
+ ".epsilon"
+ ]
+ ],
+ "jni_type": "jdoubleArray",
+ "jni_var": "TermCriteria %(n)s(%(n)s_type, %(n)s_maxCount, %(n)s_epsilon)",
+ "suffix": "IID",
+ "j_import": "org.opencv.core.TermCriteria"
+ },
+ "Vec2d": {
+ "j_type": "double[]",
+ "jn_args": [
+ [
+ "double",
+ ".val[0]"
+ ],
+ [
+ "double",
+ ".val[1]"
+ ]
+ ],
+ "jn_type": "double[]",
+ "jni_type": "jdoubleArray",
+ "jni_var": "Vec2d %(n)s(%(n)s_val0, %(n)s_val1)",
+ "suffix": "DD"
+ },
+ "Vec3d": {
+ "j_type": "double[]",
+ "jn_args": [
+ [
+ "double",
+ ".val[0]"
+ ],
+ [
+ "double",
+ ".val[1]"
+ ],
+ [
+ "double",
+ ".val[2]"
+ ]
+ ],
+ "jn_type": "double[]",
+ "jni_type": "jdoubleArray",
+ "jni_var": "Vec3d %(n)s(%(n)s_val0, %(n)s_val1, %(n)s_val2)",
+ "suffix": "DDD"
+ },
+ "c_string": {
+ "j_type": "String",
+ "jn_type": "String",
+ "jni_name": "n_%(n)s.c_str()",
+ "jni_type": "jstring",
+ "jni_var": "const char* utf_%(n)s = env->GetStringUTFChars(%(n)s, 0); String n_%(n)s( utf_%(n)s ? utf_%(n)s : \"\" ); env->ReleaseStringUTFChars(%(n)s, utf_%(n)s)",
+ "suffix": "Ljava_lang_String_2",
+ "j_import": "java.lang.String"
+ },
+ "size_t": {
+ "j_type": "long",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "suffix": "J"
+ },
+ "vector_DMatch": {
+ "j_type": "MatOfDMatch",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector<DMatch> %(n)s",
+ "suffix": "J",
+ "v_type": "Mat",
+ "j_import": "org.opencv.core.MatOfDMatch"
+ },
+ "vector_KeyPoint": {
+ "j_type": "MatOfKeyPoint",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector<KeyPoint> %(n)s",
+ "suffix": "J",
+ "v_type": "Mat",
+ "j_import": "org.opencv.core.MatOfKeyPoint"
+ },
+ "vector_Mat": {
+ "j_type": "List<Mat>",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector<Mat> %(n)s",
+ "suffix": "J",
+ "v_type": "Mat",
+ "j_import": "org.opencv.core.Mat"
+ },
+ "vector_Point": {
+ "j_type": "MatOfPoint",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector<Point> %(n)s",
+ "suffix": "J",
+ "v_type": "Mat",
+ "j_import": "org.opencv.core.MatOfPoint"
+ },
+ "vector_Point2f": {
+ "j_type": "MatOfPoint2f",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector<Point2f> %(n)s",
+ "suffix": "J",
+ "v_type": "Mat",
+ "j_import": "org.opencv.core.MatOfPoint2f"
+ },
+ "vector_Point3f": {
+ "j_type": "MatOfPoint3f",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector<Point3f> %(n)s",
+ "suffix": "J",
+ "v_type": "Mat",
+ "j_import": "org.opencv.core.MatOfPoint3f"
+ },
+ "vector_Point2d": {
+ "j_type": "MatOfPoint2f",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector<Point2f> %(n)s",
+ "suffix": "J",
+ "v_type": "Mat",
+ "j_import": "org.opencv.core.MatOfPoint2f"
+ },
+ "vector_Point3d": {
+ "j_type": "MatOfPoint3f",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector<Point3f> %(n)s",
+ "suffix": "J",
+ "v_type": "Mat",
+ "j_import": "org.opencv.core.MatOfPoint3f"
+ },
+ "vector_Point3i": {
+ "j_type": "MatOfPoint3",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector<Point3i> %(n)s",
+ "suffix": "J",
+ "v_type": "Mat",
+ "j_import": "org.opencv.core.MatOfPoint3"
+ },
+ "vector_Rect": {
+ "j_type": "MatOfRect",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector<Rect> %(n)s",
+ "suffix": "J",
+ "v_type": "Mat",
+ "j_import": "org.opencv.core.MatOfRect"
+ },
+ "vector_Rect2d": {
+ "j_type": "MatOfRect2d",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector<Rect2d> %(n)s",
+ "suffix": "J",
+ "v_type": "Mat",
+ "j_import": "org.opencv.core.MatOfRect2d"
+ },
+ "vector_String": {
+ "j_type": "List<String>",
+ "jn_type": "List<String>",
+ "jni_type": "jobject",
+ "jni_var": "std::vector< String > %(n)s",
+ "suffix": "Ljava_util_List",
+ "v_type": "String",
+ "j_import": "java.lang.String"
+ },
+ "vector_Vec4f": {
+ "j_type": "MatOfFloat4",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector<Vec4f> %(n)s",
+ "suffix": "J",
+ "v_type": "Mat",
+ "j_import": "org.opencv.core.MatOfFloat4"
+ },
+ "vector_Vec4i": {
+ "j_type": "MatOfInt4",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector<Vec4i> %(n)s",
+ "suffix": "J",
+ "v_type": "Mat",
+ "j_import": "org.opencv.core.MatOfInt4"
+ },
+ "vector_Vec6f": {
+ "j_type": "MatOfFloat6",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector<Vec6f> %(n)s",
+ "suffix": "J",
+ "v_type": "Mat",
+ "j_import": "org.opencv.core.MatOfFloat6"
+ },
+ "vector_char": {
+ "j_type": "MatOfByte",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector<char> %(n)s",
+ "suffix": "J",
+ "v_type": "Mat",
+ "j_import": "org.opencv.core.MatOfByte"
+ },
+ "vector_double": {
+ "j_type": "MatOfDouble",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector<double> %(n)s",
+ "suffix": "J",
+ "v_type": "Mat",
+ "j_import": "org.opencv.core.MatOfDouble"
+ },
+ "vector_float": {
+ "j_type": "MatOfFloat",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector<float> %(n)s",
+ "suffix": "J",
+ "v_type": "Mat",
+ "j_import": "org.opencv.core.MatOfFloat"
+ },
+ "vector_int": {
+ "j_type": "MatOfInt",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector<int> %(n)s",
+ "suffix": "J",
+ "v_type": "Mat",
+ "j_import": "org.opencv.core.MatOfInt"
+ },
+ "vector_uchar": {
+ "j_type": "MatOfByte",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector<uchar> %(n)s",
+ "suffix": "J",
+ "v_type": "Mat",
+ "j_import": "org.opencv.core.MatOfByte"
+ },
+ "vector_vector_DMatch": {
+ "j_type": "List<MatOfDMatch>",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector< std::vector<DMatch> > %(n)s",
+ "v_type": "vector_Mat",
+ "j_import": "org.opencv.core.MatOfDMatch"
+ },
+ "vector_vector_KeyPoint": {
+ "j_type": "List<MatOfKeyPoint>",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector< std::vector<KeyPoint> > %(n)s",
+ "v_type": "vector_Mat",
+ "j_import": "org.opencv.core.MatOfKeyPoint"
+ },
+ "vector_vector_Point": {
+ "j_type": "List<MatOfPoint>",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector< std::vector<Point> > %(n)s",
+ "v_type": "vector_Mat",
+ "j_import": "org.opencv.core.MatOfPoint"
+ },
+ "vector_vector_Point2f": {
+ "j_type": "List<MatOfPoint2f>",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector< std::vector<Point2f> > %(n)s",
+ "v_type": "vector_Mat",
+ "j_import": "org.opencv.core.MatOfPoint2f"
+ },
+ "vector_vector_Point3f": {
+ "j_type": "List<MatOfPoint3f>",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector< std::vector<Point3f> > %(n)s",
+ "v_type": "vector_Mat",
+ "j_import": "org.opencv.core.MatOfPoint3f"
+ },
+ "vector_vector_char": {
+ "j_type": "List<MatOfByte>",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector< std::vector<char> > %(n)s",
+ "v_type": "vector_Mat",
+ "j_import": "org.opencv.core.MatOfByte"
+ }
+ }
+}
diff --git a/modules/core/misc/java/src/java/core+DMatch.java b/modules/core/misc/java/src/java/core+DMatch.java
index 12bd86e..db44d9a 100644
--- a/modules/core/misc/java/src/java/core+DMatch.java
+++ b/modules/core/misc/java/src/java/core+DMatch.java
@@ -45,9 +45,6 @@ public class DMatch {
distance = _distance;
}
- /**
- * Less is better.
- */
public boolean lessThan(DMatch it) {
return distance < it.distance;
}
diff --git a/modules/core/misc/java/src/java/core+MatOfRect2d.java b/modules/core/misc/java/src/java/core+MatOfRect2d.java
new file mode 100644
index 0000000..71c4b1a
--- /dev/null
+++ b/modules/core/misc/java/src/java/core+MatOfRect2d.java
@@ -0,0 +1,81 @@
+package org.opencv.core;
+
+import java.util.Arrays;
+import java.util.List;
+
+
+public class MatOfRect2d extends Mat {
+ // 64FC4
+ private static final int _depth = CvType.CV_64F;
+ private static final int _channels = 4;
+
+ public MatOfRect2d() {
+ super();
+ }
+
+ protected MatOfRect2d(long addr) {
+ super(addr);
+ if( !empty() && checkVector(_channels, _depth) < 0 )
+ throw new IllegalArgumentException("Incompatible Mat");
+ //FIXME: do we need release() here?
+ }
+
+ public static MatOfRect2d fromNativeAddr(long addr) {
+ return new MatOfRect2d(addr);
+ }
+
+ public MatOfRect2d(Mat m) {
+ super(m, Range.all());
+ if( !empty() && checkVector(_channels, _depth) < 0 )
+ throw new IllegalArgumentException("Incompatible Mat");
+ //FIXME: do we need release() here?
+ }
+
+ public MatOfRect2d(Rect2d...a) {
+ super();
+ fromArray(a);
+ }
+
+ public void alloc(int elemNumber) {
+ if(elemNumber>0)
+ super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
+ }
+
+ public void fromArray(Rect2d...a) {
+ if(a==null || a.length==0)
+ return;
+ int num = a.length;
+ alloc(num);
+ double buff[] = new double[num * _channels];
+ for(int i=0; i<num; i++) {
+ Rect2d r = a[i];
+ buff[_channels*i+0] = (double) r.x;
+ buff[_channels*i+1] = (double) r.y;
+ buff[_channels*i+2] = (double) r.width;
+ buff[_channels*i+3] = (double) r.height;
+ }
+ put(0, 0, buff); //TODO: check ret val!
+ }
+
+
+ public Rect2d[] toArray() {
+ int num = (int) total();
+ Rect2d[] a = new Rect2d[num];
+ if(num == 0)
+ return a;
+ double buff[] = new double[num * _channels];
+ get(0, 0, buff); //TODO: check ret val!
+ for(int i=0; i<num; i++)
+ a[i] = new Rect2d(buff[i*_channels], buff[i*_channels+1], buff[i*_channels+2], buff[i*_channels+3]);
+ return a;
+ }
+ public void fromList(List<Rect2d> lr) {
+ Rect2d ap[] = lr.toArray(new Rect2d[0]);
+ fromArray(ap);
+ }
+
+ public List<Rect2d> toList() {
+ Rect2d[] ar = toArray();
+ return Arrays.asList(ar);
+ }
+}
diff --git a/modules/core/misc/java/src/java/core+Rect.java b/modules/core/misc/java/src/java/core+Rect.java
index 8f3fad7..c68e818 100644
--- a/modules/core/misc/java/src/java/core+Rect.java
+++ b/modules/core/misc/java/src/java/core+Rect.java
@@ -65,6 +65,10 @@ public class Rect {
return width * height;
}
+ public boolean empty() {
+ return width <= 0 || height <= 0;
+ }
+
public boolean contains(Point p) {
return x <= p.x && p.x < x + width && y <= p.y && p.y < y + height;
}
diff --git a/modules/core/misc/java/src/java/core+Rect2d.java b/modules/core/misc/java/src/java/core+Rect2d.java
new file mode 100644
index 0000000..4c27869
--- /dev/null
+++ b/modules/core/misc/java/src/java/core+Rect2d.java
@@ -0,0 +1,104 @@
+package org.opencv.core;
+
+//javadoc:Rect2d_
+public class Rect2d {
+
+ public double x, y, width, height;
+
+ public Rect2d(double x, double y, double width, double height) {
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ }
+
+ public Rect2d() {
+ this(0, 0, 0, 0);
+ }
+
+ public Rect2d(Point p1, Point p2) {
+ x = (double) (p1.x < p2.x ? p1.x : p2.x);
+ y = (double) (p1.y < p2.y ? p1.y : p2.y);
+ width = (double) (p1.x > p2.x ? p1.x : p2.x) - x;
+ height = (double) (p1.y > p2.y ? p1.y : p2.y) - y;
+ }
+
+ public Rect2d(Point p, Size s) {
+ this((double) p.x, (double) p.y, (double) s.width, (double) s.height);
+ }
+
+ public Rect2d(double[] vals) {
+ set(vals);
+ }
+
+ public void set(double[] vals) {
+ if (vals != null) {
+ x = vals.length > 0 ? (double) vals[0] : 0;
+ y = vals.length > 1 ? (double) vals[1] : 0;
+ width = vals.length > 2 ? (double) vals[2] : 0;
+ height = vals.length > 3 ? (double) vals[3] : 0;
+ } else {
+ x = 0;
+ y = 0;
+ width = 0;
+ height = 0;
+ }
+ }
+
+ public Rect2d clone() {
+ return new Rect2d(x, y, width, height);
+ }
+
+ public Point tl() {
+ return new Point(x, y);
+ }
+
+ public Point br() {
+ return new Point(x + width, y + height);
+ }
+
+ public Size size() {
+ return new Size(width, height);
+ }
+
+ public double area() {
+ return width * height;
+ }
+
+ public boolean empty() {
+ return width <= 0 || height <= 0;
+ }
+
+ public boolean contains(Point p) {
+ return x <= p.x && p.x < x + width && y <= p.y && p.y < y + height;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ long temp;
+ temp = Double.doubleToLongBits(height);
+ result = prime * result + (int) (temp ^ (temp >>> 32));
+ temp = Double.doubleToLongBits(width);
+ result = prime * result + (int) (temp ^ (temp >>> 32));
+ temp = Double.doubleToLongBits(x);
+ result = prime * result + (int) (temp ^ (temp >>> 32));
+ temp = Double.doubleToLongBits(y);
+ result = prime * result + (int) (temp ^ (temp >>> 32));
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (!(obj instanceof Rect2d)) return false;
+ Rect2d it = (Rect2d) obj;
+ return x == it.x && y == it.y && width == it.width && height == it.height;
+ }
+
+ @Override
+ public String toString() {
+ return "{" + x + ", " + y + ", " + width + "x" + height + "}";
+ }
+}
diff --git a/modules/core/misc/java/src/java/core+Size.java b/modules/core/misc/java/src/java/core+Size.java
index dcc5742..f7d69f3 100644
--- a/modules/core/misc/java/src/java/core+Size.java
+++ b/modules/core/misc/java/src/java/core+Size.java
@@ -37,6 +37,10 @@ public class Size {
return width * height;
}
+ public boolean empty() {
+ return width <= 0 || height <= 0;
+ }
+
public Size clone() {
return new Size(width, height);
}
diff --git a/modules/core/perf/opencl/perf_matop.cpp b/modules/core/perf/opencl/perf_matop.cpp
index 0fd5d43..8c39a91 100644
--- a/modules/core/perf/opencl/perf_matop.cpp
+++ b/modules/core/perf/opencl/perf_matop.cpp
@@ -139,7 +139,7 @@ OCL_PERF_TEST_P(CopyToFixture, CopyToWithMaskUninit,
dst.release();
startTimer();
src.copyTo(dst, mask);
- cv::ocl::finish();
+ cvtest::ocl::perf::safeFinish();
stopTimer();
}
diff --git a/modules/core/perf/perf_lut.cpp b/modules/core/perf/perf_lut.cpp
new file mode 100644
index 0000000..50ef045
--- /dev/null
+++ b/modules/core/perf/perf_lut.cpp
@@ -0,0 +1,26 @@
+#include "perf_precomp.hpp"
+
+using namespace std;
+using namespace cv;
+using namespace perf;
+
+typedef perf::TestBaseWithParam<Size> SizePrm;
+
+PERF_TEST_P( SizePrm, LUT,
+ testing::Values(szQVGA, szVGA, sz1080p)
+ )
+{
+ Size sz = GetParam();
+
+ int maxValue = 255;
+
+ Mat src(sz, CV_8UC1);
+ randu(src, 0, maxValue);
+ Mat lut(1, 256, CV_8UC1);
+ randu(lut, 0, maxValue);
+ Mat dst(sz, CV_8UC1);
+
+ TEST_CYCLE() LUT(src, lut, dst);
+
+ SANITY_CHECK(dst, 0.1);
+}
diff --git a/modules/core/perf/perf_norm.cpp b/modules/core/perf/perf_norm.cpp
index 2df2d4a..1ea6b2a 100644
--- a/modules/core/perf/perf_norm.cpp
+++ b/modules/core/perf/perf_norm.cpp
@@ -6,8 +6,10 @@ using namespace perf;
using std::tr1::make_tuple;
using std::tr1::get;
+#define HAMMING_NORM_SIZES cv::Size(640, 480), cv::Size(1920, 1080)
+#define HAMMING_NORM_TYPES CV_8UC1
-CV_FLAGS(NormType, NORM_INF, NORM_L1, NORM_L2, NORM_TYPE_MASK, NORM_RELATIVE, NORM_MINMAX)
+CV_FLAGS(NormType, NORM_HAMMING2, NORM_HAMMING, NORM_INF, NORM_L1, NORM_L2, NORM_TYPE_MASK, NORM_RELATIVE, NORM_MINMAX)
typedef std::tr1::tuple<Size, MatType, NormType> Size_MatType_NormType_t;
typedef perf::TestBaseWithParam<Size_MatType_NormType_t> Size_MatType_NormType;
@@ -103,6 +105,60 @@ PERF_TEST_P(Size_MatType_NormType, norm2_mask,
SANITY_CHECK(n, 1e-5, ERROR_RELATIVE);
}
+namespace {
+typedef std::tr1::tuple<NormType, MatType, Size> PerfHamming_t;
+typedef perf::TestBaseWithParam<PerfHamming_t> PerfHamming;
+
+PERF_TEST_P(PerfHamming, norm,
+ testing::Combine(
+ testing::Values(NORM_HAMMING, NORM_HAMMING2),
+ testing::Values(HAMMING_NORM_TYPES),
+ testing::Values(HAMMING_NORM_SIZES)
+ )
+ )
+{
+ Size sz = get<2>(GetParam());
+ int matType = get<1>(GetParam());
+ int normType = get<0>(GetParam());
+
+ Mat src(sz, matType);
+ double n;
+
+ declare.in(src, WARMUP_RNG);
+
+ TEST_CYCLE() n = norm(src, normType);
+
+ (void)n;
+ SANITY_CHECK_NOTHING();
+}
+
+PERF_TEST_P(PerfHamming, norm2,
+ testing::Combine(
+ testing::Values(NORM_HAMMING, NORM_HAMMING2),
+ testing::Values(HAMMING_NORM_TYPES),
+ testing::Values(HAMMING_NORM_SIZES)
+ )
+ )
+{
+ Size sz = get<2>(GetParam());
+ int matType = get<1>(GetParam());
+ int normType = get<0>(GetParam());
+
+ Mat src1(sz, matType);
+ Mat src2(sz, matType);
+ double n;
+
+ declare.in(src1, src2, WARMUP_RNG);
+
+ TEST_CYCLE() n = norm(src1, src2, normType);
+
+ (void)n;
+ SANITY_CHECK_NOTHING();
+}
+
+}
+
+
PERF_TEST_P(Size_MatType_NormType, normalize,
testing::Combine(
testing::Values(TYPICAL_MAT_SIZES),
diff --git a/modules/core/src/algorithm.cpp b/modules/core/src/algorithm.cpp
index 4e7701a..24f4dfb 100644
--- a/modules/core/src/algorithm.cpp
+++ b/modules/core/src/algorithm.cpp
@@ -47,14 +47,17 @@ namespace cv
Algorithm::Algorithm()
{
+ CV_TRACE_FUNCTION();
}
Algorithm::~Algorithm()
{
+ CV_TRACE_FUNCTION();
}
void Algorithm::save(const String& filename) const
{
+ CV_TRACE_FUNCTION();
FileStorage fs(filename, FileStorage::WRITE);
fs << getDefaultName() << "{";
write(fs);
@@ -63,11 +66,13 @@ void Algorithm::save(const String& filename) const
String Algorithm::getDefaultName() const
{
+ CV_TRACE_FUNCTION();
return String("my_object");
}
void Algorithm::writeFormat(FileStorage& fs) const
{
+ CV_TRACE_FUNCTION();
fs << "format" << (int)3;
}
diff --git a/modules/core/src/alloc.cpp b/modules/core/src/alloc.cpp
index 8e21873..8be7254 100644
--- a/modules/core/src/alloc.cpp
+++ b/modules/core/src/alloc.cpp
@@ -42,35 +42,50 @@
#include "precomp.hpp"
-#define CV_USE_SYSTEM_MALLOC 1
+#ifdef HAVE_POSIX_MEMALIGN
+#include <stdlib.h>
+#elif defined HAVE_MALLOC_H
+#include <malloc.h>
+#endif
-namespace cv
-{
+namespace cv {
static void* OutOfMemoryError(size_t size)
{
- CV_Error_(CV_StsNoMem, ("Failed to allocate %lu bytes", (unsigned long)size));
+ CV_Error_(CV_StsNoMem, ("Failed to allocate %llu bytes", (unsigned long long)size));
return 0;
}
-#if CV_USE_SYSTEM_MALLOC
-
-#if defined WIN32 || defined _WIN32
-void deleteThreadAllocData() {}
-#endif
void* fastMalloc( size_t size )
{
+#ifdef HAVE_POSIX_MEMALIGN
+ void* ptr = NULL;
+ if(posix_memalign(&ptr, CV_MALLOC_ALIGN, size))
+ ptr = NULL;
+ if(!ptr)
+ return OutOfMemoryError(size);
+ return ptr;
+#elif defined HAVE_MEMALIGN
+ void* ptr = memalign(CV_MALLOC_ALIGN, size);
+ if(!ptr)
+ return OutOfMemoryError(size);
+ return ptr;
+#else
uchar* udata = (uchar*)malloc(size + sizeof(void*) + CV_MALLOC_ALIGN);
if(!udata)
return OutOfMemoryError(size);
uchar** adata = alignPtr((uchar**)udata + 1, CV_MALLOC_ALIGN);
adata[-1] = udata;
return adata;
+#endif
}
void fastFree(void* ptr)
{
+#if defined HAVE_POSIX_MEMALIGN || defined HAVE_MEMALIGN
+ free(ptr);
+#else
if(ptr)
{
uchar* udata = ((uchar**)ptr)[-1];
@@ -78,621 +93,10 @@ void fastFree(void* ptr)
((uchar*)ptr - udata) <= (ptrdiff_t)(sizeof(void*)+CV_MALLOC_ALIGN));
free(udata);
}
-}
-
-#else //CV_USE_SYSTEM_MALLOC
-
-#if 0
-#define SANITY_CHECK(block) \
- CV_Assert(((size_t)(block) & (MEM_BLOCK_SIZE-1)) == 0 && \
- (unsigned)(block)->binIdx <= (unsigned)MAX_BIN && \
- (block)->signature == MEM_BLOCK_SIGNATURE)
-#else
-#define SANITY_CHECK(block)
-#endif
-
-#define STAT(stmt)
-
-#ifdef WIN32
-#if (_WIN32_WINNT >= 0x0602)
-#include <synchapi.h>
#endif
-
-struct CriticalSection
-{
- CriticalSection()
- {
-#if (_WIN32_WINNT >= 0x0600)
- InitializeCriticalSectionEx(&cs, 1000, 0);
-#else
- InitializeCriticalSection(&cs);
-#endif
- }
- ~CriticalSection() { DeleteCriticalSection(&cs); }
- void lock() { EnterCriticalSection(&cs); }
- void unlock() { LeaveCriticalSection(&cs); }
- bool trylock() { return TryEnterCriticalSection(&cs) != 0; }
-
- CRITICAL_SECTION cs;
-};
-
-void* SystemAlloc(size_t size)
-{
- void* ptr = malloc(size);
- return ptr ? ptr : OutOfMemoryError(size);
-}
-
-void SystemFree(void* ptr, size_t)
-{
- free(ptr);
-}
-#else //WIN32
-
-#include <sys/mman.h>
-
-struct CriticalSection
-{
- CriticalSection() { pthread_mutex_init(&mutex, 0); }
- ~CriticalSection() { pthread_mutex_destroy(&mutex); }
- void lock() { pthread_mutex_lock(&mutex); }
- void unlock() { pthread_mutex_unlock(&mutex); }
- bool trylock() { return pthread_mutex_trylock(&mutex) == 0; }
-
- pthread_mutex_t mutex;
-};
-
-void* SystemAlloc(size_t size)
-{
- #ifndef MAP_ANONYMOUS
- #define MAP_ANONYMOUS MAP_ANON
- #endif
- void* ptr = 0;
- ptr = mmap(ptr, size, (PROT_READ | PROT_WRITE), MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
- return ptr != MAP_FAILED ? ptr : OutOfMemoryError(size);
}
-void SystemFree(void* ptr, size_t size)
-{
- munmap(ptr, size);
-}
-#endif //WIN32
-
-struct AutoLock
-{
- AutoLock(CriticalSection& _cs) : cs(&_cs) { cs->lock(); }
- ~AutoLock() { cs->unlock(); }
- CriticalSection* cs;
-};
-
-const size_t MEM_BLOCK_SIGNATURE = 0x01234567;
-const int MEM_BLOCK_SHIFT = 14;
-const size_t MEM_BLOCK_SIZE = 1 << MEM_BLOCK_SHIFT;
-const size_t HDR_SIZE = 128;
-const size_t MAX_BLOCK_SIZE = MEM_BLOCK_SIZE - HDR_SIZE;
-const int MAX_BIN = 28;
-
-static const int binSizeTab[MAX_BIN+1] =
-{ 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 128, 160, 192, 256, 320, 384, 480, 544, 672, 768,
-896, 1056, 1328, 1600, 2688, 4048, 5408, 8128, 16256 };
-
-struct MallocTables
-{
- void initBinTab()
- {
- int i, j = 0, n;
- for( i = 0; i <= MAX_BIN; i++ )
- {
- n = binSizeTab[i]>>3;
- for( ; j <= n; j++ )
- binIdx[j] = (uchar)i;
- }
- }
- int bin(size_t size)
- {
- assert( size <= MAX_BLOCK_SIZE );
- return binIdx[(size + 7)>>3];
- }
-
- MallocTables()
- {
- initBinTab();
- }
-
- uchar binIdx[MAX_BLOCK_SIZE/8+1];
-};
-
-MallocTables mallocTables;
-
-struct Node
-{
- Node* next;
-};
-
-struct ThreadData;
-
-struct Block
-{
- Block(Block* _next)
- {
- signature = MEM_BLOCK_SIGNATURE;
- prev = 0;
- next = _next;
- privateFreeList = publicFreeList = 0;
- bumpPtr = endPtr = 0;
- objSize = 0;
- threadData = 0;
- data = (uchar*)this + HDR_SIZE;
- }
-
- ~Block() {}
-
- void init(Block* _prev, Block* _next, int _objSize, ThreadData* _threadData)
- {
- prev = _prev;
- if(prev)
- prev->next = this;
- next = _next;
- if(next)
- next->prev = this;
- objSize = _objSize;
- binIdx = mallocTables.bin(objSize);
- threadData = _threadData;
- privateFreeList = publicFreeList = 0;
- bumpPtr = data;
- int nobjects = MAX_BLOCK_SIZE/objSize;
- endPtr = bumpPtr + nobjects*objSize;
- almostEmptyThreshold = (nobjects + 1)/2;
- allocated = 0;
- }
-
- bool isFilled() const { return allocated > almostEmptyThreshold; }
-
- size_t signature;
- Block* prev;
- Block* next;
- Node* privateFreeList;
- Node* publicFreeList;
- uchar* bumpPtr;
- uchar* endPtr;
- uchar* data;
- ThreadData* threadData;
- int objSize;
- int binIdx;
- int allocated;
- int almostEmptyThreshold;
- CriticalSection cs;
-};
-
-struct BigBlock
-{
- BigBlock(int bigBlockSize, BigBlock* _next)
- {
- first = alignPtr((Block*)(this+1), MEM_BLOCK_SIZE);
- next = _next;
- nblocks = (int)(((char*)this + bigBlockSize - (char*)first)/MEM_BLOCK_SIZE);
- Block* p = 0;
- for( int i = nblocks-1; i >= 0; i-- )
- p = ::new((uchar*)first + i*MEM_BLOCK_SIZE) Block(p);
- }
-
- ~BigBlock()
- {
- for( int i = nblocks-1; i >= 0; i-- )
- ((Block*)((uchar*)first+i*MEM_BLOCK_SIZE))->~Block();
- }
-
- BigBlock* next;
- Block* first;
- int nblocks;
-};
-
-struct BlockPool
-{
- BlockPool(int _bigBlockSize=1<<20) : pool(0), bigBlockSize(_bigBlockSize)
- {
- }
-
- ~BlockPool()
- {
- AutoLock lock(cs);
- while( pool )
- {
- BigBlock* nextBlock = pool->next;
- pool->~BigBlock();
- SystemFree(pool, bigBlockSize);
- pool = nextBlock;
- }
- }
-
- Block* alloc()
- {
- AutoLock lock(cs);
- Block* block;
- if( !freeBlocks )
- {
- BigBlock* bblock = ::new(SystemAlloc(bigBlockSize)) BigBlock(bigBlockSize, pool);
- assert( bblock != 0 );
- freeBlocks = bblock->first;
- pool = bblock;
- }
- block = freeBlocks;
- freeBlocks = freeBlocks->next;
- if( freeBlocks )
- freeBlocks->prev = 0;
- STAT(stat.bruttoBytes += MEM_BLOCK_SIZE);
- return block;
- }
-
- void free(Block* block)
- {
- AutoLock lock(cs);
- block->prev = 0;
- block->next = freeBlocks;
- freeBlocks = block;
- STAT(stat.bruttoBytes -= MEM_BLOCK_SIZE);
- }
-
- CriticalSection cs;
- Block* freeBlocks;
- BigBlock* pool;
- int bigBlockSize;
- int blocksPerBigBlock;
-};
-
-BlockPool mallocPool;
-
-enum { START=0, FREE=1, GC=2 };
-
-struct ThreadData
-{
- ThreadData() { for(int i = 0; i <= MAX_BIN; i++) bins[i][START] = bins[i][FREE] = bins[i][GC] = 0; }
- ~ThreadData()
- {
- // mark all the thread blocks as abandoned or even release them
- for( int i = 0; i <= MAX_BIN; i++ )
- {
- Block *bin = bins[i][START], *block = bin;
- bins[i][START] = bins[i][FREE] = bins[i][GC] = 0;
- if( block )
- {
- do
- {
- Block* next = block->next;
- int allocated = block->allocated;
- {
- AutoLock lock(block->cs);
- block->next = block->prev = 0;
- block->threadData = 0;
- Node *node = block->publicFreeList;
- for( ; node != 0; node = node->next )
- allocated--;
- }
- if( allocated == 0 )
- mallocPool.free(block);
- block = next;
- }
- while( block != bin );
- }
- }
- }
-
- void moveBlockToFreeList( Block* block )
- {
- int i = block->binIdx;
- Block*& freePtr = bins[i][FREE];
- CV_DbgAssert( block->next->prev == block && block->prev->next == block );
- if( block != freePtr )
- {
- Block*& gcPtr = bins[i][GC];
- if( gcPtr == block )
- gcPtr = block->next;
- if( block->next != block )
- {
- block->prev->next = block->next;
- block->next->prev = block->prev;
- }
- block->next = freePtr->next;
- block->prev = freePtr;
- freePtr = block->next->prev = block->prev->next = block;
- }
- }
-
- Block* bins[MAX_BIN+1][3];
-
-#ifdef WIN32
-#ifdef WINCE
-# define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF)
-#endif //WINCE
-
- static DWORD tlsKey;
- static ThreadData* get()
- {
- ThreadData* data;
- if( tlsKey == TLS_OUT_OF_INDEXES )
- tlsKey = TlsAlloc();
- data = (ThreadData*)TlsGetValue(tlsKey);
- if( !data )
- {
- data = new ThreadData;
- TlsSetValue(tlsKey, data);
- }
- return data;
- }
-#else //WIN32
- static void deleteData(void* data)
- {
- delete (ThreadData*)data;
- }
-
- static pthread_key_t tlsKey;
- static ThreadData* get()
- {
- ThreadData* data;
- if( !tlsKey )
- pthread_key_create(&tlsKey, deleteData);
- data = (ThreadData*)pthread_getspecific(tlsKey);
- if( !data )
- {
- data = new ThreadData;
- pthread_setspecific(tlsKey, data);
- }
- return data;
- }
-#endif //WIN32
-};
-
-#ifdef WIN32
-DWORD ThreadData::tlsKey = TLS_OUT_OF_INDEXES;
-
-void deleteThreadAllocData()
-{
- if( ThreadData::tlsKey != TLS_OUT_OF_INDEXES )
- delete (ThreadData*)TlsGetValue( ThreadData::tlsKey );
-}
-
-#else //WIN32
-pthread_key_t ThreadData::tlsKey = 0;
-#endif //WIN32
-
-#if 0
-static void checkList(ThreadData* tls, int idx)
-{
- Block* block = tls->bins[idx][START];
- if( !block )
- {
- CV_DbgAssert( tls->bins[idx][FREE] == 0 && tls->bins[idx][GC] == 0 );
- }
- else
- {
- bool gcInside = false;
- bool freeInside = false;
- do
- {
- if( tls->bins[idx][FREE] == block )
- freeInside = true;
- if( tls->bins[idx][GC] == block )
- gcInside = true;
- block = block->next;
- }
- while( block != tls->bins[idx][START] );
- CV_DbgAssert( gcInside && freeInside );
- }
-}
-#else
-#define checkList(tls, idx)
-#endif
-
-void* fastMalloc( size_t size )
-{
- if( size > MAX_BLOCK_SIZE )
- {
- size_t size1 = size + sizeof(uchar*)*2 + MEM_BLOCK_SIZE;
- uchar* udata = (uchar*)SystemAlloc(size1);
- uchar** adata = alignPtr((uchar**)udata + 2, MEM_BLOCK_SIZE);
- adata[-1] = udata;
- adata[-2] = (uchar*)size1;
- return adata;
- }
-
- {
- ThreadData* tls = ThreadData::get();
- int idx = mallocTables.bin(size);
- Block*& startPtr = tls->bins[idx][START];
- Block*& gcPtr = tls->bins[idx][GC];
- Block*& freePtr = tls->bins[idx][FREE], *block = freePtr;
- checkList(tls, idx);
- size = binSizeTab[idx];
- STAT(
- stat.nettoBytes += size;
- stat.mallocCalls++;
- );
- uchar* data = 0;
-
- for(;;)
- {
- if( block )
- {
- // try to find non-full block
- for(;;)
- {
- CV_DbgAssert( block->next->prev == block && block->prev->next == block );
- if( block->bumpPtr )
- {
- data = block->bumpPtr;
- if( (block->bumpPtr += size) >= block->endPtr )
- block->bumpPtr = 0;
- break;
- }
-
- if( block->privateFreeList )
- {
- data = (uchar*)block->privateFreeList;
- block->privateFreeList = block->privateFreeList->next;
- break;
- }
-
- if( block == startPtr )
- break;
- block = block->next;
- }
-#if 0
- avg_k += _k;
- avg_nk++;
- if( avg_nk == 1000 )
- {
- printf("avg search iters per 1e3 allocs = %g\n", (double)avg_k/avg_nk );
- avg_k = avg_nk = 0;
- }
-#endif
-
- freePtr = block;
- if( !data )
- {
- block = gcPtr;
- for( int k = 0; k < 2; k++ )
- {
- SANITY_CHECK(block);
- CV_DbgAssert( block->next->prev == block && block->prev->next == block );
- if( block->publicFreeList )
- {
- {
- AutoLock lock(block->cs);
- block->privateFreeList = block->publicFreeList;
- block->publicFreeList = 0;
- }
- Node* node = block->privateFreeList;
- for(;node != 0; node = node->next)
- --block->allocated;
- data = (uchar*)block->privateFreeList;
- block->privateFreeList = block->privateFreeList->next;
- gcPtr = block->next;
- if( block->allocated+1 <= block->almostEmptyThreshold )
- tls->moveBlockToFreeList(block);
- break;
- }
- block = block->next;
- }
- if( !data )
- gcPtr = block;
- }
- }
-
- if( data )
- break;
- block = mallocPool.alloc();
- block->init(startPtr ? startPtr->prev : block, startPtr ? startPtr : block, (int)size, tls);
- if( !startPtr )
- startPtr = gcPtr = freePtr = block;
- checkList(tls, block->binIdx);
- SANITY_CHECK(block);
- }
-
- ++block->allocated;
- return data;
- }
-}
-
-void fastFree( void* ptr )
-{
- if( ((size_t)ptr & (MEM_BLOCK_SIZE-1)) == 0 )
- {
- if( ptr != 0 )
- {
- void* origPtr = ((void**)ptr)[-1];
- size_t sz = (size_t)((void**)ptr)[-2];
- SystemFree( origPtr, sz );
- }
- return;
- }
-
- {
- ThreadData* tls = ThreadData::get();
- Node* node = (Node*)ptr;
- Block* block = (Block*)((size_t)ptr & -(int)MEM_BLOCK_SIZE);
- assert( block->signature == MEM_BLOCK_SIGNATURE );
-
- if( block->threadData == tls )
- {
- STAT(
- stat.nettoBytes -= block->objSize;
- stat.freeCalls++;
- float ratio = (float)stat.nettoBytes/stat.bruttoBytes;
- if( stat.minUsageRatio > ratio )
- stat.minUsageRatio = ratio;
- );
-
- SANITY_CHECK(block);
-
- bool prevFilled = block->isFilled();
- --block->allocated;
- if( !block->isFilled() && (block->allocated == 0 || prevFilled) )
- {
- if( block->allocated == 0 )
- {
- int idx = block->binIdx;
- Block*& startPtr = tls->bins[idx][START];
- Block*& freePtr = tls->bins[idx][FREE];
- Block*& gcPtr = tls->bins[idx][GC];
-
- if( block == block->next )
- {
- CV_DbgAssert( startPtr == block && freePtr == block && gcPtr == block );
- startPtr = freePtr = gcPtr = 0;
- }
- else
- {
- if( freePtr == block )
- freePtr = block->next;
- if( gcPtr == block )
- gcPtr = block->next;
- if( startPtr == block )
- startPtr = block->next;
- block->prev->next = block->next;
- block->next->prev = block->prev;
- }
- mallocPool.free(block);
- checkList(tls, idx);
- return;
- }
-
- tls->moveBlockToFreeList(block);
- }
- node->next = block->privateFreeList;
- block->privateFreeList = node;
- }
- else
- {
- AutoLock lock(block->cs);
- SANITY_CHECK(block);
-
- node->next = block->publicFreeList;
- block->publicFreeList = node;
- if( block->threadData == 0 )
- {
- // take ownership of the abandoned block.
- // note that it can happen at the same time as
- // ThreadData::deleteData() marks the blocks as abandoned,
- // so this part of the algorithm needs to be checked for data races
- int idx = block->binIdx;
- block->threadData = tls;
- Block*& startPtr = tls->bins[idx][START];
-
- if( startPtr )
- {
- block->next = startPtr;
- block->prev = startPtr->prev;
- block->next->prev = block->prev->next = block;
- }
- else
- startPtr = tls->bins[idx][FREE] = tls->bins[idx][GC] = block;
- }
- }
- }
-}
-
-#endif //CV_USE_SYSTEM_MALLOC
-
-}
+} // namespace
CV_IMPL void* cvAlloc( size_t size )
{
@@ -704,5 +108,4 @@ CV_IMPL void cvFree_( void* ptr )
cv::fastFree( ptr );
}
-
/* End of file. */
diff --git a/modules/core/src/arithm.cpp b/modules/core/src/arithm.cpp
index 4b1c673..b4406c4 100644
--- a/modules/core/src/arithm.cpp
+++ b/modules/core/src/arithm.cpp
@@ -138,7 +138,7 @@ static bool ocl_binary_op(InputArray _src1, InputArray _src2, OutputArray _dst,
convertAndUnrollScalar(src2sc, srctype, (uchar*)buf, 1);
}
- ocl::KernelArg scalararg = ocl::KernelArg(0, 0, 0, 0, buf, esz);
+ ocl::KernelArg scalararg = ocl::KernelArg(ocl::KernelArg::CONSTANT, 0, 0, 0, buf, esz);
if( !haveMask )
k.args(src1arg, dstarg, scalararg);
@@ -523,7 +523,7 @@ static bool ocl_arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
float usrdata_f[3];
int i, n = oclop == OCL_OP_MUL_SCALE || oclop == OCL_OP_DIV_SCALE ||
oclop == OCL_OP_RDIV_SCALE || oclop == OCL_OP_RECIP_SCALE ? 1 : oclop == OCL_OP_ADDW ? 3 : 0;
- if( n > 0 && wdepth == CV_32F )
+ if( usrdata && n > 0 && wdepth == CV_32F )
{
for( i = 0; i < n; i++ )
usrdata_f[i] = (float)usrdata_d[i];
@@ -550,7 +550,7 @@ static bool ocl_arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
if( !src2sc.empty() )
convertAndUnrollScalar(src2sc, wtype, (uchar*)buf, 1);
- ocl::KernelArg scalararg = ocl::KernelArg(0, 0, 0, 0, buf, esz);
+ ocl::KernelArg scalararg = ocl::KernelArg(ocl::KernelArg::CONSTANT, 0, 0, 0, buf, esz);
if( !haveMask )
{
@@ -558,7 +558,7 @@ static bool ocl_arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
k.args(src1arg, dstarg, scalararg);
else if(n == 1)
k.args(src1arg, dstarg, scalararg,
- ocl::KernelArg(0, 0, 0, 0, usrdata_p, usrdata_esz));
+ ocl::KernelArg(ocl::KernelArg::CONSTANT, 0, 0, 0, usrdata_p, usrdata_esz));
else
CV_Error(Error::StsNotImplemented, "unsupported number of extra parameters");
}
@@ -576,12 +576,12 @@ static bool ocl_arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
k.args(src1arg, src2arg, dstarg);
else if (n == 1)
k.args(src1arg, src2arg, dstarg,
- ocl::KernelArg(0, 0, 0, 0, usrdata_p, usrdata_esz));
+ ocl::KernelArg(ocl::KernelArg::CONSTANT, 0, 0, 0, usrdata_p, usrdata_esz));
else if (n == 3)
k.args(src1arg, src2arg, dstarg,
- ocl::KernelArg(0, 0, 0, 0, usrdata_p, usrdata_esz),
- ocl::KernelArg(0, 0, 0, 0, usrdata_p + usrdata_esz, usrdata_esz),
- ocl::KernelArg(0, 0, 0, 0, usrdata_p + usrdata_esz*2, usrdata_esz));
+ ocl::KernelArg(ocl::KernelArg::CONSTANT, 0, 0, 0, usrdata_p, usrdata_esz),
+ ocl::KernelArg(ocl::KernelArg::CONSTANT, 0, 0, 0, usrdata_p + usrdata_esz, usrdata_esz),
+ ocl::KernelArg(ocl::KernelArg::CONSTANT, 0, 0, 0, usrdata_p + usrdata_esz*2, usrdata_esz));
else
CV_Error(Error::StsNotImplemented, "unsupported number of extra parameters");
}
@@ -1204,7 +1204,7 @@ static bool ocl_compare(InputArray _src1, InputArray _src2, OutputArray _dst, in
convertAndUnrollScalar(Mat(1, 1, CV_32S, &ival), depth1, (uchar *)buf, kercn);
}
- ocl::KernelArg scalararg = ocl::KernelArg(0, 0, 0, 0, buf, esz);
+ ocl::KernelArg scalararg = ocl::KernelArg(ocl::KernelArg::CONSTANT, 0, 0, 0, buf, esz);
k.args(ocl::KernelArg::ReadOnlyNoSize(src1, cn, kercn),
ocl::KernelArg::WriteOnly(dst, cn, kercn), scalararg);
@@ -1239,7 +1239,10 @@ void cv::compare(InputArray _src1, InputArray _src2, OutputArray _dst, int op)
|| !_src1.sameSize(_src2)
|| _src1.type() != _src2.type())
{
- if (checkScalar(_src1, _src2.type(), _src1.kind(), _src2.kind()))
+ bool is_src1_scalar = checkScalar(_src1, _src2.type(), _src1.kind(), _src2.kind());
+ bool is_src2_scalar = checkScalar(_src2, _src1.type(), _src2.kind(), _src1.kind());
+
+ if (is_src1_scalar && !is_src2_scalar)
{
op = op == CMP_LT ? CMP_GT : op == CMP_LE ? CMP_GE :
op == CMP_GE ? CMP_LE : op == CMP_GT ? CMP_LT : op;
@@ -1247,7 +1250,7 @@ void cv::compare(InputArray _src1, InputArray _src2, OutputArray _dst, int op)
compare(_src2, _src1, _dst, op);
return;
}
- else if( !checkScalar(_src2, _src1.type(), _src2.kind(), _src1.kind()) )
+ else if( (is_src1_scalar && is_src2_scalar) || (!is_src1_scalar && !is_src2_scalar) )
CV_Error( CV_StsUnmatchedSizes,
"The operation is neither 'array op array' (where arrays have the same size and the same type), "
"nor 'array op scalar', nor 'scalar op array'" );
@@ -1276,7 +1279,7 @@ void cv::compare(InputArray _src1, InputArray _src2, OutputArray _dst, int op)
src1 = src1.reshape(1); src2 = src2.reshape(1);
Mat dst = _dst.getMat().reshape(1);
- size_t esz = src1.elemSize();
+ size_t esz = std::max(src1.elemSize(), (size_t)1);
size_t blocksize0 = (size_t)(BLOCK_SIZE + esz-1)/esz;
BinaryFuncC func = getCmpFunc(depth1);
diff --git a/modules/core/src/array.cpp b/modules/core/src/array.cpp
index d22f9c2..b428819 100644
--- a/modules/core/src/array.cpp
+++ b/modules/core/src/array.cpp
@@ -545,7 +545,7 @@ cvCreateSparseMat( int dims, const int* sizes, int type )
if( pix_size == 0 )
CV_Error( CV_StsUnsupportedFormat, "invalid array data type" );
- if( dims <= 0 || dims > CV_MAX_DIM_HEAP )
+ if( dims <= 0 || dims > CV_MAX_DIM )
CV_Error( CV_StsOutOfRange, "bad number of dimensions" );
if( !sizes )
@@ -1839,6 +1839,7 @@ cvPtr2D( const CvArr* arr, int y, int x, int* _type )
}
else if( CV_IS_SPARSE_MAT( arr ))
{
+ CV_Assert(((CvSparseMat*)arr)->dims == 2);
int idx[] = { y, x };
ptr = icvGetNodePtr( (CvSparseMat*)arr, idx, _type, 1, 0 );
}
diff --git a/modules/core/src/command_line_parser.cpp b/modules/core/src/command_line_parser.cpp
index 542b231..2b67ce8 100644
--- a/modules/core/src/command_line_parser.cpp
+++ b/modules/core/src/command_line_parser.cpp
@@ -10,7 +10,7 @@ static const char* noneValue = "<none>";
static String cat_string(const String& str)
{
int left = 0, right = (int)str.length();
- while( left <= right && str[left] == ' ' )
+ while( left < right && str[left] == ' ' )
left++;
while( right > left && str[right-1] == ' ' )
right--;
@@ -276,10 +276,10 @@ CommandLineParser& CommandLineParser::operator = (const CommandLineParser& parse
{
if( this != &parser )
{
+ CV_XADD(&parser.impl->refcount, 1);
if(CV_XADD(&impl->refcount, -1) == 1)
delete impl;
impl = parser.impl;
- CV_XADD(&impl->refcount, 1);
}
return *this;
}
diff --git a/modules/core/src/convert.avx2.cpp b/modules/core/src/convert.avx2.cpp
new file mode 100644
index 0000000..ac1f94d
--- /dev/null
+++ b/modules/core/src/convert.avx2.cpp
@@ -0,0 +1,78 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
+// Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved.
+// Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "precomp.hpp"
+#include "convert.hpp"
+
+namespace cv
+{
+namespace opt_AVX2
+{
+
+void cvtScale_s16s32f32Line_AVX2(const short* src, int* dst, float scale, float shift, int width)
+{
+ int x = 0;
+
+ __m256 scale256 = _mm256_set1_ps(scale);
+ __m256 shift256 = _mm256_set1_ps(shift);
+ const int shuffle = 0xD8;
+
+ for (; x <= width - 16; x += 16)
+ {
+ __m256i v_src = _mm256_loadu_si256((const __m256i *)(src + x));
+ v_src = _mm256_permute4x64_epi64(v_src, shuffle);
+ __m256i v_src_lo = _mm256_srai_epi32(_mm256_unpacklo_epi16(v_src, v_src), 16);
+ __m256i v_src_hi = _mm256_srai_epi32(_mm256_unpackhi_epi16(v_src, v_src), 16);
+ __m256 v_dst0 = _mm256_add_ps(_mm256_mul_ps(_mm256_cvtepi32_ps(v_src_lo), scale256), shift256);
+ __m256 v_dst1 = _mm256_add_ps(_mm256_mul_ps(_mm256_cvtepi32_ps(v_src_hi), scale256), shift256);
+ _mm256_storeu_si256((__m256i *)(dst + x), _mm256_cvtps_epi32(v_dst0));
+ _mm256_storeu_si256((__m256i *)(dst + x + 8), _mm256_cvtps_epi32(v_dst1));
+ }
+
+ for (; x < width; x++)
+ dst[x] = saturate_cast<int>(src[x] * scale + shift);
+}
+
+}
+}
+/* End of file. */
diff --git a/modules/core/src/convert.cpp b/modules/core/src/convert.cpp
index e04d89e..d63b53b 100644
--- a/modules/core/src/convert.cpp
+++ b/modules/core/src/convert.cpp
@@ -44,7 +44,7 @@
#include "precomp.hpp"
#include "opencl_kernels_core.hpp"
-#include "opencv2/core/hal/intrin.hpp"
+#include "convert.hpp"
#include "opencv2/core/openvx/ovx_defs.hpp"
@@ -85,6 +85,66 @@ static MergeFunc getMergeFunc(int depth)
return mergeTab[depth];
}
+#ifdef HAVE_IPP
+#ifdef HAVE_IPP_IW
+extern "C" {
+IW_DECL(IppStatus) llwiCopySplit(const void *pSrc, int srcStep, void* const pDstOrig[], int dstStep,
+ IppiSize size, int typeSize, int channels);
+}
+#endif
+
+namespace cv {
+static bool ipp_split(const Mat& src, Mat* mv, int channels)
+{
+#ifdef HAVE_IPP_IW
+ CV_INSTRUMENT_REGION_IPP()
+
+ if(channels != 3 && channels != 4)
+ return false;
+
+ if(src.dims <= 2)
+ {
+ IppiSize size = ippiSize(src.size());
+ void *dstPtrs[4] = {NULL};
+ size_t dstStep = mv[0].step;
+ for(int i = 0; i < channels; i++)
+ {
+ dstPtrs[i] = mv[i].ptr();
+ if(dstStep != mv[i].step)
+ return false;
+ }
+
+ return CV_INSTRUMENT_FUN_IPP(llwiCopySplit, src.ptr(), (int)src.step, dstPtrs, (int)dstStep, size, (int)src.elemSize1(), channels) >= 0;
+ }
+ else
+ {
+ const Mat *arrays[5] = {NULL};
+ uchar *ptrs[5] = {NULL};
+ arrays[0] = &src;
+
+ for(int i = 1; i < channels; i++)
+ {
+ arrays[i] = &mv[i-1];
+ }
+
+ NAryMatIterator it(arrays, ptrs);
+ IppiSize size = { (int)it.size, 1 };
+
+ for( size_t i = 0; i < it.nplanes; i++, ++it )
+ {
+ if(CV_INSTRUMENT_FUN_IPP(llwiCopySplit, ptrs[0], 0, (void**)&ptrs[1], 0, size, (int)src.elemSize1(), channels) < 0)
+ return false;
+ }
+ return true;
+ }
+#else
+ CV_UNUSED(src); CV_UNUSED(mv); CV_UNUSED(channels);
+ return false;
+#endif
+}
+}
+#endif
+
void cv::split(const Mat& src, Mat* mv)
{
CV_INSTRUMENT_REGION()
@@ -96,6 +156,13 @@ void cv::split(const Mat& src, Mat* mv)
return;
}
+ for( k = 0; k < cn; k++ )
+ {
+ mv[k].create(src.dims, src.size, depth);
+ }
+
+ CV_IPP_RUN_FAST(ipp_split(src, mv, cn));
+
SplitFunc func = getSplitFunc(depth);
CV_Assert( func != 0 );
@@ -108,7 +175,6 @@ void cv::split(const Mat& src, Mat* mv)
arrays[0] = &src;
for( k = 0; k < cn; k++ )
{
- mv[k].create(src.dims, src.size, depth);
arrays[k+1] = &mv[k];
}
@@ -206,6 +272,66 @@ void cv::split(InputArray _m, OutputArrayOfArrays _mv)
split(m, &dst[0]);
}
+#ifdef HAVE_IPP
+#ifdef HAVE_IPP_IW
+extern "C" {
+IW_DECL(IppStatus) llwiCopyMerge(const void* const pSrc[], int srcStep, void *pDst, int dstStep,
+ IppiSize size, int typeSize, int channels);
+}
+#endif
+
+namespace cv {
+static bool ipp_merge(const Mat* mv, Mat& dst, int channels)
+{
+#ifdef HAVE_IPP_IW
+ CV_INSTRUMENT_REGION_IPP()
+
+ if(channels != 3 && channels != 4)
+ return false;
+
+ if(mv[0].dims <= 2)
+ {
+ IppiSize size = ippiSize(mv[0].size());
+ const void *srcPtrs[4] = {NULL};
+ size_t srcStep = mv[0].step;
+ for(int i = 0; i < channels; i++)
+ {
+ srcPtrs[i] = mv[i].ptr();
+ if(srcStep != mv[i].step)
+ return false;
+ }
+
+ return CV_INSTRUMENT_FUN_IPP(llwiCopyMerge, srcPtrs, (int)srcStep, dst.ptr(), (int)dst.step, size, (int)mv[0].elemSize1(), channels) >= 0;
+ }
+ else
+ {
+ const Mat *arrays[5] = {NULL};
+ uchar *ptrs[5] = {NULL};
+ arrays[0] = &dst;
+
+ for(int i = 1; i < channels; i++)
+ {
+ arrays[i] = &mv[i-1];
+ }
+
+ NAryMatIterator it(arrays, ptrs);
+ IppiSize size = { (int)it.size, 1 };
+
+ for( size_t i = 0; i < it.nplanes; i++, ++it )
+ {
+ if(CV_INSTRUMENT_FUN_IPP(llwiCopyMerge, (const void**)&ptrs[1], 0, ptrs[0], 0, size, (int)mv[0].elemSize1(), channels) < 0)
+ return false;
+ }
+ return true;
+ }
+#else
+ CV_UNUSED(dst); CV_UNUSED(mv); CV_UNUSED(channels);
+ return false;
+#endif
+}
+}
+#endif
+
void cv::merge(const Mat* mv, size_t n, OutputArray _dst)
{
CV_INSTRUMENT_REGION()
@@ -234,6 +360,8 @@ void cv::merge(const Mat* mv, size_t n, OutputArray _dst)
return;
}
+ CV_IPP_RUN_FAST(ipp_merge(mv, dst, (int)n));
+
if( !allch1 )
{
AutoBuffer<int> pairs(cn*2);
@@ -637,9 +765,11 @@ void cv::mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst,
ocl_mixChannels(src, dst, fromTo, npairs))
bool src_is_mat = src.kind() != _InputArray::STD_VECTOR_MAT &&
+ src.kind() != _InputArray::STD_ARRAY_MAT &&
src.kind() != _InputArray::STD_VECTOR_VECTOR &&
src.kind() != _InputArray::STD_VECTOR_UMAT;
bool dst_is_mat = dst.kind() != _InputArray::STD_VECTOR_MAT &&
+ dst.kind() != _InputArray::STD_ARRAY_MAT &&
dst.kind() != _InputArray::STD_VECTOR_VECTOR &&
dst.kind() != _InputArray::STD_VECTOR_UMAT;
int i;
@@ -668,9 +798,11 @@ void cv::mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst,
ocl_mixChannels(src, dst, &fromTo[0], fromTo.size()>>1))
bool src_is_mat = src.kind() != _InputArray::STD_VECTOR_MAT &&
+ src.kind() != _InputArray::STD_ARRAY_MAT &&
src.kind() != _InputArray::STD_VECTOR_VECTOR &&
src.kind() != _InputArray::STD_VECTOR_UMAT;
bool dst_is_mat = dst.kind() != _InputArray::STD_VECTOR_MAT &&
+ dst.kind() != _InputArray::STD_ARRAY_MAT &&
dst.kind() != _InputArray::STD_VECTOR_VECTOR &&
dst.kind() != _InputArray::STD_VECTOR_UMAT;
int i;
@@ -687,6 +819,59 @@ void cv::mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst,
mixChannels(&buf[0], nsrc, &buf[nsrc], ndst, &fromTo[0], fromTo.size()/2);
}
+#ifdef HAVE_IPP
+#ifdef HAVE_IPP_IW
+extern "C" {
+IW_DECL(IppStatus) llwiCopyMixed(const void *pSrc, int srcStep, int srcChannels, void *pDst, int dstStep, int dstChannels,
+ IppiSize size, int typeSize, int channelsShift);
+}
+#endif
+
+namespace cv
+{
+static bool ipp_extractInsertChannel(const Mat &src, Mat &dst, int channel)
+{
+#ifdef HAVE_IPP_IW
+ CV_INSTRUMENT_REGION_IPP()
+
+ int srcChannels = src.channels();
+ int dstChannels = dst.channels();
+
+ if(src.dims != dst.dims)
+ return false;
+
+ if(srcChannels == dstChannels || (srcChannels != 1 && dstChannels != 1))
+ return false;
+
+ if(src.dims <= 2)
+ {
+ IppiSize size = ippiSize(src.size());
+
+ return CV_INSTRUMENT_FUN_IPP(llwiCopyMixed, src.ptr(), (int)src.step, srcChannels, dst.ptr(), (int)dst.step, dstChannels, size, (int)src.elemSize1(), channel) >= 0;
+ }
+ else
+ {
+ const Mat *arrays[] = {&dst, NULL};
+ uchar *ptrs[2] = {NULL};
+ NAryMatIterator it(arrays, ptrs);
+
+ IppiSize size = {(int)it.size, 1};
+
+ for( size_t i = 0; i < it.nplanes; i++, ++it )
+ {
+ if(CV_INSTRUMENT_FUN_IPP(llwiCopyMixed, ptrs[0], 0, srcChannels, ptrs[1], 0, dstChannels, size, (int)src.elemSize1(), channel) < 0)
+ return false;
+ }
+ return true;
+ }
+#else
+ CV_UNUSED(src); CV_UNUSED(dst); CV_UNUSED(channel);
+ return false;
+#endif
+}
+}
+#endif
+
void cv::extractChannel(InputArray _src, OutputArray _dst, int coi)
{
CV_INSTRUMENT_REGION()
@@ -707,6 +892,9 @@ void cv::extractChannel(InputArray _src, OutputArray _dst, int coi)
Mat src = _src.getMat();
_dst.create(src.dims, &src.size[0], depth);
Mat dst = _dst.getMat();
+
+ CV_IPP_RUN_FAST(ipp_extractInsertChannel(src, dst, coi))
+
mixChannels(&src, 1, &dst, 1, ch, 1);
}
@@ -728,6 +916,9 @@ void cv::insertChannel(InputArray _src, InputOutputArray _dst, int coi)
}
Mat src = _src.getMat(), dst = _dst.getMat();
+
+ CV_IPP_RUN_FAST(ipp_extractInsertChannel(src, dst, coi))
+
mixChannels(&src, 1, &dst, 1, ch, 1);
}
@@ -1298,41 +1489,22 @@ struct cvtScale_SIMD<uchar, schar, float>
}
};
-#if CV_SSE4_1
+#if CV_TRY_SSE4_1
template <>
struct cvtScale_SIMD<uchar, ushort, float>
{
cvtScale_SIMD()
{
- haveSSE = checkHardwareSupport(CV_CPU_SSE4_1);
+ haveSSE = CV_CPU_HAS_SUPPORT_SSE4_1;
}
int operator () (const uchar * src, ushort * dst, int width, float scale, float shift) const
{
- int x = 0;
-
- if (!haveSSE)
- return x;
-
- __m128i v_zero = _mm_setzero_si128();
- __m128 v_scale = _mm_set1_ps(scale), v_shift = _mm_set1_ps(shift);
-
- for ( ; x <= width - 8; x += 8)
- {
- __m128i v_src = _mm_unpacklo_epi8(_mm_loadl_epi64((__m128i const *)(src + x)), v_zero);
- __m128 v_src_f = _mm_cvtepi32_ps(_mm_unpacklo_epi16(v_src, v_zero));
- __m128 v_dst_0 = _mm_add_ps(_mm_mul_ps(v_src_f, v_scale), v_shift);
-
- v_src_f = _mm_cvtepi32_ps(_mm_unpackhi_epi16(v_src, v_zero));
- __m128 v_dst_1 = _mm_add_ps(_mm_mul_ps(v_src_f, v_scale), v_shift);
-
- __m128i v_dst = _mm_packus_epi32(_mm_cvtps_epi32(v_dst_0),
- _mm_cvtps_epi32(v_dst_1));
- _mm_storeu_si128((__m128i *)(dst + x), v_dst);
- }
-
- return x;
+ if (haveSSE)
+ return opt_SSE4_1::cvtScale_SIMD_u8u16f32_SSE41(src, dst, width, scale, shift);
+ else
+ return 0;
}
bool haveSSE;
@@ -1529,41 +1701,22 @@ struct cvtScale_SIMD<schar, schar, float>
}
};
-#if CV_SSE4_1
+#if CV_TRY_SSE4_1
template <>
struct cvtScale_SIMD<schar, ushort, float>
{
cvtScale_SIMD()
{
- haveSSE = checkHardwareSupport(CV_CPU_SSE4_1);
+ haveSSE = CV_CPU_HAS_SUPPORT_SSE4_1;
}
int operator () (const schar * src, ushort * dst, int width, float scale, float shift) const
{
- int x = 0;
-
- if (!haveSSE)
- return x;
-
- __m128i v_zero = _mm_setzero_si128();
- __m128 v_scale = _mm_set1_ps(scale), v_shift = _mm_set1_ps(shift);
-
- for ( ; x <= width - 8; x += 8)
- {
- __m128i v_src = _mm_srai_epi16(_mm_unpacklo_epi8(v_zero, _mm_loadl_epi64((__m128i const *)(src + x))), 8);
- __m128 v_src_f = _mm_cvtepi32_ps(_mm_srai_epi32(_mm_unpacklo_epi16(v_zero, v_src), 16));
- __m128 v_dst_0 = _mm_add_ps(_mm_mul_ps(v_src_f, v_scale), v_shift);
-
- v_src_f = _mm_cvtepi32_ps(_mm_srai_epi32(_mm_unpackhi_epi16(v_zero, v_src), 16));
- __m128 v_dst_1 = _mm_add_ps(_mm_mul_ps(v_src_f, v_scale), v_shift);
-
- __m128i v_dst = _mm_packus_epi32(_mm_cvtps_epi32(v_dst_0),
- _mm_cvtps_epi32(v_dst_1));
- _mm_storeu_si128((__m128i *)(dst + x), v_dst);
- }
-
- return x;
+ if (haveSSE)
+ return opt_SSE4_1::cvtScale_SIMD_s8u16f32_SSE41(src, dst, width, scale, shift);
+ else
+ return 0;
}
bool haveSSE;
@@ -1761,41 +1914,22 @@ struct cvtScale_SIMD<ushort, schar, float>
}
};
-#if CV_SSE4_1
+#if CV_TRY_SSE4_1
template <>
struct cvtScale_SIMD<ushort, ushort, float>
{
cvtScale_SIMD()
{
- haveSSE = checkHardwareSupport(CV_CPU_SSE4_1);
+ haveSSE = CV_CPU_HAS_SUPPORT_SSE4_1;
}
int operator () (const ushort * src, ushort * dst, int width, float scale, float shift) const
{
- int x = 0;
-
- if (!haveSSE)
- return x;
-
- __m128i v_zero = _mm_setzero_si128();
- __m128 v_scale = _mm_set1_ps(scale), v_shift = _mm_set1_ps(shift);
-
- for ( ; x <= width - 8; x += 8)
- {
- __m128i v_src = _mm_loadu_si128((__m128i const *)(src + x));
- __m128 v_src_f = _mm_cvtepi32_ps(_mm_unpacklo_epi16(v_src, v_zero));
- __m128 v_dst_0 = _mm_add_ps(_mm_mul_ps(v_src_f, v_scale), v_shift);
-
- v_src_f = _mm_cvtepi32_ps(_mm_unpackhi_epi16(v_src, v_zero));
- __m128 v_dst_1 = _mm_add_ps(_mm_mul_ps(v_src_f, v_scale), v_shift);
-
- __m128i v_dst = _mm_packus_epi32(_mm_cvtps_epi32(v_dst_0),
- _mm_cvtps_epi32(v_dst_1));
- _mm_storeu_si128((__m128i *)(dst + x), v_dst);
- }
-
- return x;
+ if (haveSSE)
+ return opt_SSE4_1::cvtScale_SIMD_u16u16f32_SSE41(src, dst, width, scale, shift);
+ else
+ return 0;
}
bool haveSSE;
@@ -1992,41 +2126,22 @@ struct cvtScale_SIMD<short, schar, float>
}
};
-#if CV_SSE4_1
+#if CV_TRY_SSE4_1
template <>
struct cvtScale_SIMD<short, ushort, float>
{
cvtScale_SIMD()
{
- haveSSE = checkHardwareSupport(CV_CPU_SSE4_1);
+ haveSSE = CV_CPU_HAS_SUPPORT_SSE4_1;
}
int operator () (const short * src, ushort * dst, int width, float scale, float shift) const
{
- int x = 0;
-
- if (!haveSSE)
- return x;
-
- __m128i v_zero = _mm_setzero_si128();
- __m128 v_scale = _mm_set1_ps(scale), v_shift = _mm_set1_ps(shift);
-
- for ( ; x <= width - 8; x += 8)
- {
- __m128i v_src = _mm_loadu_si128((__m128i const *)(src + x));
- __m128 v_src_f = _mm_cvtepi32_ps(_mm_srai_epi32(_mm_unpacklo_epi16(v_zero, v_src), 16));
- __m128 v_dst_0 = _mm_add_ps(_mm_mul_ps(v_src_f, v_scale), v_shift);
-
- v_src_f = _mm_cvtepi32_ps(_mm_srai_epi32(_mm_unpackhi_epi16(v_zero, v_src), 16));
- __m128 v_dst_1 = _mm_add_ps(_mm_mul_ps(v_src_f, v_scale), v_shift);
-
- __m128i v_dst = _mm_packus_epi32(_mm_cvtps_epi32(v_dst_0),
- _mm_cvtps_epi32(v_dst_1));
- _mm_storeu_si128((__m128i *)(dst + x), v_dst);
- }
-
- return x;
+ if (haveSSE)
+ return opt_SSE4_1::cvtScale_SIMD_s16u16f32_SSE41(src, dst, width, scale, shift);
+ else
+ return 0;
}
bool haveSSE;
@@ -2221,39 +2336,22 @@ struct cvtScale_SIMD<int, schar, float>
}
};
-#if CV_SSE4_1
+#if CV_TRY_SSE4_1
template <>
struct cvtScale_SIMD<int, ushort, float>
{
cvtScale_SIMD()
{
- haveSSE = checkHardwareSupport(CV_CPU_SSE4_1);
+ haveSSE = CV_CPU_HAS_SUPPORT_SSE4_1;
}
int operator () (const int * src, ushort * dst, int width, float scale, float shift) const
{
- int x = 0;
-
- if (!haveSSE)
- return x;
-
- __m128 v_scale = _mm_set1_ps(scale), v_shift = _mm_set1_ps(shift);
-
- for ( ; x <= width - 8; x += 8)
- {
- __m128i v_src = _mm_loadu_si128((__m128i const *)(src + x));
- __m128 v_dst_0 = _mm_add_ps(_mm_mul_ps(_mm_cvtepi32_ps(v_src), v_scale), v_shift);
-
- v_src = _mm_loadu_si128((__m128i const *)(src + x + 4));
- __m128 v_dst_1 = _mm_add_ps(_mm_mul_ps(_mm_cvtepi32_ps(v_src), v_scale), v_shift);
-
- __m128i v_dst = _mm_packus_epi32(_mm_cvtps_epi32(v_dst_0),
- _mm_cvtps_epi32(v_dst_1));
- _mm_storeu_si128((__m128i *)(dst + x), v_dst);
- }
-
- return x;
+ if (haveSSE)
+ return opt_SSE4_1::cvtScale_SIMD_s32u16f32_SSE41(src, dst, width, scale, shift);
+ else
+ return 0;
}
bool haveSSE;
@@ -2438,39 +2536,22 @@ struct cvtScale_SIMD<float, schar, float>
}
};
-#if CV_SSE4_1
+#if CV_TRY_SSE4_1
template <>
struct cvtScale_SIMD<float, ushort, float>
{
cvtScale_SIMD()
{
- haveSSE = checkHardwareSupport(CV_CPU_SSE4_1);
+ haveSSE = CV_CPU_HAS_SUPPORT_SSE4_1;
}
int operator () (const float * src, ushort * dst, int width, float scale, float shift) const
{
- int x = 0;
-
- if (!haveSSE)
- return x;
-
- __m128 v_scale = _mm_set1_ps(scale), v_shift = _mm_set1_ps(shift);
-
- for ( ; x <= width - 8; x += 8)
- {
- __m128 v_src = _mm_loadu_ps(src + x);
- __m128 v_dst_0 = _mm_add_ps(_mm_mul_ps(v_src, v_scale), v_shift);
-
- v_src = _mm_loadu_ps(src + x + 4);
- __m128 v_dst_1 = _mm_add_ps(_mm_mul_ps(v_src, v_scale), v_shift);
-
- __m128i v_dst = _mm_packus_epi32(_mm_cvtps_epi32(v_dst_0),
- _mm_cvtps_epi32(v_dst_1));
- _mm_storeu_si128((__m128i *)(dst + x), v_dst);
- }
-
- return x;
+ if (haveSSE)
+ return opt_SSE4_1::cvtScale_SIMD_f32u16f32_SSE41(src, dst, width, scale, shift);
+ else
+ return 0;
}
bool haveSSE;
@@ -2651,41 +2732,22 @@ struct cvtScale_SIMD<double, schar, float>
}
};
-#if CV_SSE4_1
+#if CV_TRY_SSE4_1
template <>
struct cvtScale_SIMD<double, ushort, float>
{
cvtScale_SIMD()
{
- haveSSE = checkHardwareSupport(CV_CPU_SSE4_1);
+ haveSSE = CV_CPU_HAS_SUPPORT_SSE4_1;
}
int operator () (const double * src, ushort * dst, int width, float scale, float shift) const
{
- int x = 0;
-
- if (!haveSSE)
- return x;
-
- __m128 v_scale = _mm_set1_ps(scale), v_shift = _mm_set1_ps(shift);
-
- for ( ; x <= width - 8; x += 8)
- {
- __m128 v_src = _mm_movelh_ps(_mm_cvtpd_ps(_mm_loadu_pd(src + x)),
- _mm_cvtpd_ps(_mm_loadu_pd(src + x + 2)));
- __m128 v_dst_0 = _mm_add_ps(_mm_mul_ps(v_src, v_scale), v_shift);
-
- v_src = _mm_movelh_ps(_mm_cvtpd_ps(_mm_loadu_pd(src + x + 4)),
- _mm_cvtpd_ps(_mm_loadu_pd(src + x + 6)));
- __m128 v_dst_1 = _mm_add_ps(_mm_mul_ps(v_src, v_scale), v_shift);
-
- __m128i v_dst = _mm_packus_epi32(_mm_cvtps_epi32(v_dst_0),
- _mm_cvtps_epi32(v_dst_1));
- _mm_storeu_si128((__m128i *)(dst + x), v_dst);
- }
-
- return x;
+ if (haveSSE)
+ return opt_SSE4_1::cvtScale_SIMD_f64u16f32_SSE41(src, dst, width, scale, shift);
+ else
+ return 0;
}
bool haveSSE;
@@ -3612,24 +3674,11 @@ cvtScale_<short, int, float>( const short* src, size_t sstep,
{
int x = 0;
- #if CV_AVX2
- if (USE_AVX2)
+ #if CV_TRY_AVX2
+ if (CV_CPU_HAS_SUPPORT_AVX2)
{
- __m256 scale256 = _mm256_set1_ps(scale);
- __m256 shift256 = _mm256_set1_ps(shift);
- const int shuffle = 0xD8;
-
- for ( ; x <= size.width - 16; x += 16)
- {
- __m256i v_src = _mm256_loadu_si256((const __m256i *)(src + x));
- v_src = _mm256_permute4x64_epi64(v_src, shuffle);
- __m256i v_src_lo = _mm256_srai_epi32(_mm256_unpacklo_epi16(v_src, v_src), 16);
- __m256i v_src_hi = _mm256_srai_epi32(_mm256_unpackhi_epi16(v_src, v_src), 16);
- __m256 v_dst0 = _mm256_add_ps(_mm256_mul_ps(_mm256_cvtepi32_ps(v_src_lo), scale256), shift256);
- __m256 v_dst1 = _mm256_add_ps(_mm256_mul_ps(_mm256_cvtepi32_ps(v_src_hi), scale256), shift256);
- _mm256_storeu_si256((__m256i *)(dst + x), _mm256_cvtps_epi32(v_dst0));
- _mm256_storeu_si256((__m256i *)(dst + x + 8), _mm256_cvtps_epi32(v_dst1));
- }
+ opt_AVX2::cvtScale_s16s32f32Line_AVX2(src, dst, scale, shift, size.width);
+ continue;
}
#endif
#if CV_SSE2
@@ -3742,37 +3791,20 @@ struct Cvt_SIMD<double, schar>
}
};
-#if CV_SSE4_1
+#if CV_TRY_SSE4_1
template <>
struct Cvt_SIMD<double, ushort>
{
bool haveSIMD;
- Cvt_SIMD() { haveSIMD = checkHardwareSupport(CV_CPU_SSE4_1); }
+ Cvt_SIMD() { haveSIMD = CV_CPU_HAS_SUPPORT_SSE4_1; }
int operator() (const double * src, ushort * dst, int width) const
{
- int x = 0;
-
- if (!haveSIMD)
- return x;
-
- for ( ; x <= width - 8; x += 8)
- {
- __m128 v_src0 = _mm_cvtpd_ps(_mm_loadu_pd(src + x));
- __m128 v_src1 = _mm_cvtpd_ps(_mm_loadu_pd(src + x + 2));
- __m128 v_src2 = _mm_cvtpd_ps(_mm_loadu_pd(src + x + 4));
- __m128 v_src3 = _mm_cvtpd_ps(_mm_loadu_pd(src + x + 6));
-
- v_src0 = _mm_movelh_ps(v_src0, v_src1);
- v_src1 = _mm_movelh_ps(v_src2, v_src3);
-
- __m128i v_dst = _mm_packus_epi32(_mm_cvtps_epi32(v_src0),
- _mm_cvtps_epi32(v_src1));
- _mm_storeu_si128((__m128i *)(dst + x), v_dst);
- }
-
- return x;
+ if (haveSIMD)
+ return opt_SSE4_1::Cvt_SIMD_f64u16_SSE41(src, dst, width);
+ else
+ return 0;
}
};
@@ -4382,258 +4414,46 @@ struct Cvt_SIMD<float, int>
#endif
-#if !CV_FP16_TYPE
-// const numbers for floating points format
-const unsigned int kShiftSignificand = 13;
-const unsigned int kMaskFp16Significand = 0x3ff;
-const unsigned int kBiasFp16Exponent = 15;
-const unsigned int kBiasFp32Exponent = 127;
-#endif
-
-#if CV_FP16_TYPE
-static float convertFp16SW(short fp16)
-{
- // Fp16 -> Fp32
- Cv16suf a;
- a.i = fp16;
- return (float)a.h;
-}
-#else
-static float convertFp16SW(short fp16)
-{
- // Fp16 -> Fp32
- Cv16suf b;
- b.i = fp16;
- int exponent = b.fmt.exponent - kBiasFp16Exponent;
- int significand = b.fmt.significand;
-
- Cv32suf a;
- a.i = 0;
- a.fmt.sign = b.fmt.sign; // sign bit
- if( exponent == 16 )
- {
- // Inf or NaN
- a.i = a.i | 0x7F800000;
- if( significand != 0 )
- {
- // NaN
-#if defined(__x86_64__) || defined(_M_X64)
- // 64bit
- a.i = a.i | 0x7FC00000;
-#endif
- a.fmt.significand = a.fmt.significand | (significand << kShiftSignificand);
- }
- return a.f;
- }
- else if ( exponent == -15 )
- {
- // subnormal in Fp16
- if( significand == 0 )
- {
- // zero
- return a.f;
- }
- else
- {
- int shift = -1;
- while( ( significand & 0x400 ) == 0 )
- {
- significand = significand << 1;
- shift++;
- }
- significand = significand & kMaskFp16Significand;
- exponent -= shift;
- }
- }
-
- a.fmt.exponent = (exponent+kBiasFp32Exponent);
- a.fmt.significand = significand << kShiftSignificand;
- return a.f;
-}
-#endif
-
-#if CV_FP16_TYPE
-static short convertFp16SW(float fp32)
-{
- // Fp32 -> Fp16
- Cv16suf a;
- a.h = (__fp16)fp32;
- return a.i;
-}
-#else
-static short convertFp16SW(float fp32)
-{
- // Fp32 -> Fp16
- Cv32suf a;
- a.f = fp32;
- int exponent = a.fmt.exponent - kBiasFp32Exponent;
- int significand = a.fmt.significand;
-
- Cv16suf result;
- result.i = 0;
- unsigned int absolute = a.i & 0x7fffffff;
- if( 0x477ff000 <= absolute )
- {
- // Inf in Fp16
- result.i = result.i | 0x7C00;
- if( exponent == 128 && significand != 0 )
- {
- // NaN
- result.i = (short)( result.i | 0x200 | ( significand >> kShiftSignificand ) );
- }
- }
- else if ( absolute < 0x33000001 )
- {
- // too small for fp16
- result.i = 0;
- }
- else if ( absolute < 0x33c00000 )
- {
- result.i = 1;
- }
- else if ( absolute < 0x34200001 )
- {
- result.i = 2;
- }
- else if ( absolute < 0x387fe000 )
- {
- // subnormal in Fp16
- int fp16Significand = significand | 0x800000;
- int bitShift = (-exponent) - 1;
- fp16Significand = fp16Significand >> bitShift;
-
- // special cases to round up
- bitShift = exponent + 24;
- int threshold = ( ( 0x400000 >> bitShift ) | ( ( ( significand & ( 0x800000 >> bitShift ) ) >> ( 126 - a.fmt.exponent ) ) ^ 1 ) );
- if( threshold <= ( significand & ( 0xffffff >> ( exponent + 25 ) ) ) )
- {
- fp16Significand++;
- }
- result.i = (short)fp16Significand;
- }
- else
- {
- // usual situation
- // exponent
- result.fmt.exponent = ( exponent + kBiasFp16Exponent );
-
- // significand;
- short fp16Significand = (short)(significand >> kShiftSignificand);
- result.fmt.significand = fp16Significand;
-
- // special cases to round up
- short lsb10bitsFp32 = (significand & 0x1fff);
- short threshold = 0x1000 + ( ( fp16Significand & 0x1 ) ? 0 : 1 );
- if( threshold <= lsb10bitsFp32 )
- {
- result.i++;
- }
- else if ( fp16Significand == 0x3ff && exponent == -15)
- {
- result.i++;
- }
- }
-
- // sign bit
- result.fmt.sign = a.fmt.sign;
- return result.i;
-}
-#endif
-
// template for FP16 HW conversion function
template<typename T, typename DT> static void
cvtScaleHalf_( const T* src, size_t sstep, DT* dst, size_t dstep, Size size);
template<> void
-cvtScaleHalf_<float, short>( const float* src, size_t sstep, short* dst, size_t dstep, Size size)
+cvtScaleHalf_<float, short>( const float* src, size_t sstep, short* dst, size_t dstep, Size size )
{
+ CV_CPU_CALL_FP16(cvtScaleHalf_SIMD32f16f, (src, sstep, dst, dstep, size));
+
+#if !defined(CV_CPU_COMPILE_FP16)
sstep /= sizeof(src[0]);
dstep /= sizeof(dst[0]);
- if( checkHardwareSupport(CV_CPU_FP16) )
- {
- for( ; size.height--; src += sstep, dst += dstep )
- {
- int x = 0;
-
-#if defined(__x86_64__) || defined(_M_X64) || defined(_M_IX86) || defined(i386)
- if ( ( (intptr_t)dst & 0xf ) == 0 )
-#endif
- {
-#if CV_FP16 && CV_SIMD128
- for ( ; x <= size.width - 4; x += 4)
- {
- v_float32x4 v_src = v_load(src + x);
-
- v_float16x4 v_dst = v_cvt_f16(v_src);
-
- v_store_f16(dst + x, v_dst);
- }
-#endif
- }
- for ( ; x < size.width; x++ )
- {
- dst[x] = convertFp16SW(src[x]);
- }
- }
- }
- else
+ for( ; size.height--; src += sstep, dst += dstep )
{
- for( ; size.height--; src += sstep, dst += dstep )
+ for ( int x = 0; x < size.width; x++ )
{
- int x = 0;
- for ( ; x < size.width; x++ )
- {
- dst[x] = convertFp16SW(src[x]);
- }
+ dst[x] = convertFp16SW(src[x]);
}
}
+#endif
}
template<> void
-cvtScaleHalf_<short, float>( const short* src, size_t sstep, float* dst, size_t dstep, Size size)
+cvtScaleHalf_<short, float>( const short* src, size_t sstep, float* dst, size_t dstep, Size size )
{
+ CV_CPU_CALL_FP16(cvtScaleHalf_SIMD16f32f, (src, sstep, dst, dstep, size));
+
+#if !defined(CV_CPU_COMPILE_FP16)
sstep /= sizeof(src[0]);
dstep /= sizeof(dst[0]);
- if( checkHardwareSupport(CV_CPU_FP16) )
- {
- for( ; size.height--; src += sstep, dst += dstep )
- {
- int x = 0;
-
-#if defined(__x86_64__) || defined(_M_X64) || defined(_M_IX86) || defined(i386)
- if ( ( (intptr_t)src & 0xf ) == 0 )
-#endif
- {
-#if CV_FP16 && CV_SIMD128
- for ( ; x <= size.width - 4; x += 4)
- {
- v_float16x4 v_src = v_load_f16(src + x);
-
- v_float32x4 v_dst = v_cvt_f32(v_src);
-
- v_store(dst + x, v_dst);
- }
-#endif
- }
- for ( ; x < size.width; x++ )
- {
- dst[x] = convertFp16SW(src[x]);
- }
- }
- }
- else
+ for( ; size.height--; src += sstep, dst += dstep )
{
- for( ; size.height--; src += sstep, dst += dstep )
+ for ( int x = 0; x < size.width; x++ )
{
- int x = 0;
- for ( ; x < size.width; x++ )
- {
- dst[x] = convertFp16SW(src[x]);
- }
+ dst[x] = convertFp16SW(src[x]);
}
}
+#endif
}
#ifdef HAVE_OPENVX
@@ -4671,9 +4491,12 @@ static bool _openvx_cvt(const T* src, size_t sstep,
int srcType = DataType<T>::type, dstType = DataType<DT>::type;
+ if (ovx::skipSmallImages<VX_KERNEL_CONVERTDEPTH>(imgSize.width, imgSize.height))
+ return false;
+
try
{
- Context context = Context::create();
+ Context context = ovx::getOpenVXContext();
// Other conversions are marked as "experimental"
if(context.vendorID() == VX_ID_KHRONOS &&
@@ -4833,12 +4656,13 @@ static void cvtScaleAbs##suffix( const stype* src, size_t sstep, const uchar*, s
}
#define DEF_CVT_SCALE_FP16_FUNC(suffix, stype, dtype) \
-static void cvtScaleHalf##suffix( const stype* src, size_t sstep, const uchar*, size_t, \
-dtype* dst, size_t dstep, Size size, double*) \
+static void cvtScaleHalf##suffix( const stype* src, size_t sstep, \
+dtype* dst, size_t dstep, Size size) \
{ \
cvtScaleHalf_<stype,dtype>(src, sstep, dst, dstep, size); \
}
+
#define DEF_CVT_SCALE_FUNC(suffix, stype, dtype, wtype) \
static void cvtScale##suffix( const stype* src, size_t sstep, const uchar*, size_t, \
dtype* dst, size_t dstep, Size size, double* scale) \
@@ -5019,12 +4843,16 @@ static BinaryFunc getCvtScaleAbsFunc(int depth)
return cvtScaleAbsTab[depth];
}
-BinaryFunc getConvertFuncFp16(int ddepth)
+typedef void (*UnaryFunc)(const uchar* src1, size_t step1,
+ uchar* dst, size_t step, Size sz,
+ void*);
+
+static UnaryFunc getConvertFuncFp16(int ddepth)
{
- static BinaryFunc cvtTab[] =
+ static UnaryFunc cvtTab[] =
{
0, 0, 0,
- (BinaryFunc)(cvtScaleHalf32f16f), 0, (BinaryFunc)(cvtScaleHalf16f32f),
+ (UnaryFunc)(cvtScaleHalf32f16f), 0, (UnaryFunc)(cvtScaleHalf16f32f),
0, 0,
};
return cvtTab[CV_MAT_DEPTH(ddepth)];
@@ -5180,6 +5008,34 @@ static bool ocl_convertScaleAbs( InputArray _src, OutputArray _dst, double alpha
return k.run(2, globalsize, NULL, false);
}
+static bool ocl_convertFp16( InputArray _src, OutputArray _dst, int ddepth )
+{
+ int type = _src.type(), cn = CV_MAT_CN(type);
+
+ _dst.createSameSize( _src, CV_MAKETYPE(ddepth, cn) );
+ int kercn = 1;
+ int rowsPerWI = 1;
+ String build_opt = format("-D HALF_SUPPORT -D dstT=%s -D srcT=%s -D rowsPerWI=%d%s",
+ ddepth == CV_16S ? "half" : "float",
+ ddepth == CV_16S ? "float" : "half",
+ rowsPerWI,
+ ddepth == CV_16S ? " -D FLOAT_TO_HALF " : "");
+ ocl::Kernel k("convertFp16", ocl::core::halfconvert_oclsrc, build_opt);
+ if (k.empty())
+ return false;
+
+ UMat src = _src.getUMat();
+ UMat dst = _dst.getUMat();
+
+ ocl::KernelArg srcarg = ocl::KernelArg::ReadOnlyNoSize(src),
+ dstarg = ocl::KernelArg::WriteOnly(dst, cn, kercn);
+
+ k.args(srcarg, dstarg);
+
+ size_t globalsize[2] = { (size_t)src.cols * cn / kercn, ((size_t)src.rows + rowsPerWI - 1) / rowsPerWI };
+ return k.run(2, globalsize, NULL, false);
+}
+
#endif
}
@@ -5220,10 +5076,8 @@ void cv::convertFp16( InputArray _src, OutputArray _dst)
{
CV_INSTRUMENT_REGION()
- Mat src = _src.getMat();
int ddepth = 0;
-
- switch( src.depth() )
+ switch( _src.depth() )
{
case CV_32F:
ddepth = CV_16S;
@@ -5236,17 +5090,22 @@ void cv::convertFp16( InputArray _src, OutputArray _dst)
return;
}
+ CV_OCL_RUN(_src.dims() <= 2 && _dst.isUMat(),
+ ocl_convertFp16(_src, _dst, ddepth))
+
+ Mat src = _src.getMat();
+
int type = CV_MAKETYPE(ddepth, src.channels());
_dst.create( src.dims, src.size, type );
Mat dst = _dst.getMat();
- BinaryFunc func = getConvertFuncFp16(ddepth);
+ UnaryFunc func = getConvertFuncFp16(ddepth);
int cn = src.channels();
CV_Assert( func != 0 );
if( src.dims <= 2 )
{
Size sz = getContinuousSize(src, dst, cn);
- func( src.data, src.step, 0, 0, dst.data, dst.step, sz, 0);
+ func( src.data, src.step, dst.data, dst.step, sz, 0);
}
else
{
@@ -5256,10 +5115,76 @@ void cv::convertFp16( InputArray _src, OutputArray _dst)
Size sz((int)(it.size*cn), 1);
for( size_t i = 0; i < it.nplanes; i++, ++it )
- func(ptrs[0], 1, 0, 0, ptrs[1], 1, sz, 0);
+ func(ptrs[0], 1, ptrs[1], 1, sz, 0);
}
}
+#ifdef HAVE_IPP
+namespace cv
+{
+static bool ipp_convertTo(Mat &src, Mat &dst, double alpha, double beta)
+{
+#ifdef HAVE_IPP_IW
+ CV_INSTRUMENT_REGION_IPP()
+
+ IppDataType srcDepth = ippiGetDataType(src.depth());
+ IppDataType dstDepth = ippiGetDataType(dst.depth());
+ int channels = src.channels();
+
+ if(src.dims == 0)
+ return false;
+
+ ::ipp::IwiImage iwSrc;
+ ::ipp::IwiImage iwDst;
+
+ try
+ {
+ IppHintAlgorithm mode = ippAlgHintFast;
+ if(dstDepth == ipp64f ||
+ (dstDepth == ipp32f && (srcDepth == ipp32s || srcDepth == ipp64f)) ||
+ (dstDepth == ipp32s && (srcDepth == ipp32s || srcDepth == ipp64f)))
+ mode = ippAlgHintAccurate;
+
+ if(src.dims <= 2)
+ {
+ Size sz = getContinuousSize(src, dst, channels);
+
+ iwSrc.Init(ippiSize(sz), srcDepth, 1, NULL, (void*)src.ptr(), src.step);
+ iwDst.Init(ippiSize(sz), dstDepth, 1, NULL, (void*)dst.ptr(), dst.step);
+
+ CV_INSTRUMENT_FUN_IPP(::ipp::iwiScale, &iwSrc, &iwDst, alpha, beta, mode);
+ }
+ else
+ {
+ const Mat *arrays[] = {&src, &dst, NULL};
+ uchar *ptrs[2] = {NULL};
+ NAryMatIterator it(arrays, ptrs);
+
+ iwSrc.Init(ippiSize(it.size, 1), srcDepth, channels);
+ iwDst.Init(ippiSize(it.size, 1), dstDepth, channels);
+
+ for(size_t i = 0; i < it.nplanes; i++, ++it)
+ {
+ iwSrc.m_ptr = ptrs[0];
+ iwDst.m_ptr = ptrs[1];
+
+ CV_INSTRUMENT_FUN_IPP(::ipp::iwiScale, &iwSrc, &iwDst, alpha, beta, mode);
+ }
+ }
+ }
+ catch (::ipp::IwException)
+ {
+ return false;
+ }
+ return true;
+#else
+ CV_UNUSED(src); CV_UNUSED(dst); CV_UNUSED(alpha); CV_UNUSED(beta);
+ return false;
+#endif
+}
+}
+#endif
+
void cv::Mat::convertTo(OutputArray _dst, int _type, double alpha, double beta) const
{
CV_INSTRUMENT_REGION()
@@ -5279,6 +5204,13 @@ void cv::Mat::convertTo(OutputArray _dst, int _type, double alpha, double beta)
}
Mat src = *this;
+ if( dims <= 2 )
+ _dst.create( size(), _type );
+ else
+ _dst.create( dims, size, _type );
+ Mat dst = _dst.getMat();
+
+ CV_IPP_RUN_FAST(ipp_convertTo(src, dst, alpha, beta ));
BinaryFunc func = noScale ? getConvertFunc(sdepth, ddepth) : getConvertScaleFunc(sdepth, ddepth);
double scale[] = {alpha, beta};
@@ -5287,15 +5219,12 @@ void cv::Mat::convertTo(OutputArray _dst, int _type, double alpha, double beta)
if( dims <= 2 )
{
- _dst.create( size(), _type );
- Mat dst = _dst.getMat();
Size sz = getContinuousSize(src, dst, cn);
+
func( src.data, src.step, 0, 0, dst.data, dst.step, sz, scale );
}
else
{
- _dst.create( dims, size, _type );
- Mat dst = _dst.getMat();
const Mat* arrays[] = {&src, &dst, 0};
uchar* ptrs[2];
NAryMatIterator it(arrays, ptrs);
@@ -5406,7 +5335,7 @@ static bool openvx_LUT(Mat src, Mat dst, Mat _lut)
try
{
- ivx::Context ctx = ivx::Context::create();
+ ivx::Context ctx = ovx::getOpenVXContext();
ivx::Image
ia = ivx::Image::createFromHandle(ctx, VX_DF_IMAGE_U8,
@@ -5432,9 +5361,9 @@ static bool openvx_LUT(Mat src, Mat dst, Mat _lut)
#endif
#if defined(HAVE_IPP)
+#if !IPP_DISABLE_PERF_LUT // there are no performance benefits (PR #2653)
namespace ipp {
-#if IPP_DISABLE_BLOCK // there are no performance benefits (PR #2653)
class IppLUTParallelBody_LUTC1 : public ParallelLoopBody
{
public:
@@ -5443,25 +5372,17 @@ public:
const Mat& lut_;
Mat& dst_;
- typedef IppStatus (*IppFn)(const Ipp8u* pSrc, int srcStep, void* pDst, int dstStep,
- IppiSize roiSize, const void* pTable, int nBitSize);
- IppFn fn;
-
int width;
+ size_t elemSize1;
IppLUTParallelBody_LUTC1(const Mat& src, const Mat& lut, Mat& dst, bool* _ok)
: ok(_ok), src_(src), lut_(lut), dst_(dst)
{
width = dst.cols * dst.channels();
+ elemSize1 = CV_ELEM_SIZE1(dst.depth());
- size_t elemSize1 = CV_ELEM_SIZE1(dst.depth());
-
- fn =
- elemSize1 == 1 ? (IppFn)ippiLUTPalette_8u_C1R :
- elemSize1 == 4 ? (IppFn)ippiLUTPalette_8u32u_C1R :
- NULL;
-
- *ok = (fn != NULL);
+ CV_DbgAssert(elemSize1 == 1 || elemSize1 == 4);
+ *ok = true;
}
void operator()( const cv::Range& range ) const
@@ -5477,19 +5398,22 @@ public:
IppiSize sz = { width, dst.rows };
- CV_DbgAssert(fn != NULL);
- if (fn(src.data, (int)src.step[0], dst.data, (int)dst.step[0], sz, lut_.data, 8) < 0)
+ if (elemSize1 == 1)
{
- setIppErrorStatus();
- *ok = false;
+ if (CV_INSTRUMENT_FUN_IPP(ippiLUTPalette_8u_C1R, (const Ipp8u*)src.data, (int)src.step[0], dst.data, (int)dst.step[0], sz, lut_.data, 8) >= 0)
+ return;
}
- CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
+ else if (elemSize1 == 4)
+ {
+ if (CV_INSTRUMENT_FUN_IPP(ippiLUTPalette_8u32u_C1R, (const Ipp8u*)src.data, (int)src.step[0], (Ipp32u*)dst.data, (int)dst.step[0], sz, (Ipp32u*)lut_.data, 8) >= 0)
+ return;
+ }
+ *ok = false;
}
private:
IppLUTParallelBody_LUTC1(const IppLUTParallelBody_LUTC1&);
IppLUTParallelBody_LUTC1& operator=(const IppLUTParallelBody_LUTC1&);
};
-#endif
class IppLUTParallelBody_LUTCN : public ParallelLoopBody
{
@@ -5512,7 +5436,7 @@ public:
size_t elemSize1 = dst.elemSize1();
CV_DbgAssert(elemSize1 == 1);
- lutBuffer = (uchar*)ippMalloc(256 * (int)elemSize1 * 4);
+ lutBuffer = (uchar*)CV_IPP_MALLOC(256 * (int)elemSize1 * 4);
lutTable[0] = lutBuffer + 0;
lutTable[1] = lutBuffer + 1 * 256 * elemSize1;
lutTable[2] = lutBuffer + 2 * 256 * elemSize1;
@@ -5523,21 +5447,13 @@ public:
{
IppStatus status = CV_INSTRUMENT_FUN_IPP(ippiCopy_8u_C3P3R, lut.ptr(), (int)lut.step[0], lutTable, (int)lut.step[0], sz256);
if (status < 0)
- {
- setIppErrorStatus();
return;
- }
- CV_IMPL_ADD(CV_IMPL_IPP);
}
else if (lutcn == 4)
{
IppStatus status = CV_INSTRUMENT_FUN_IPP(ippiCopy_8u_C4P4R, lut.ptr(), (int)lut.step[0], lutTable, (int)lut.step[0], sz256);
if (status < 0)
- {
- setIppErrorStatus();
return;
- }
- CV_IMPL_ADD(CV_IMPL_IPP);
}
*ok = true;
@@ -5564,25 +5480,14 @@ public:
if (lutcn == 3)
{
- if (CV_INSTRUMENT_FUN_IPP(ippiLUTPalette_8u_C3R,
- src.ptr(), (int)src.step[0], dst.ptr(), (int)dst.step[0],
- ippiSize(dst.size()), lutTable, 8) >= 0)
- {
- CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
+ if (CV_INSTRUMENT_FUN_IPP(ippiLUTPalette_8u_C3R, src.ptr(), (int)src.step[0], dst.ptr(), (int)dst.step[0], ippiSize(dst.size()), lutTable, 8) >= 0)
return;
- }
}
else if (lutcn == 4)
{
- if (CV_INSTRUMENT_FUN_IPP(ippiLUTPalette_8u_C4R,
- src.ptr(), (int)src.step[0], dst.ptr(), (int)dst.step[0],
- ippiSize(dst.size()), lutTable, 8) >= 0)
- {
- CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
+ if (CV_INSTRUMENT_FUN_IPP(ippiLUTPalette_8u_C4R, src.ptr(), (int)src.step[0], dst.ptr(), (int)dst.step[0], ippiSize(dst.size()), lutTable, 8) >= 0)
return;
- }
}
- setIppErrorStatus();
*ok = false;
}
private:
@@ -5604,15 +5509,13 @@ static bool ipp_lut(Mat &src, Mat &lut, Mat &dst)
Ptr<ParallelLoopBody> body;
size_t elemSize1 = CV_ELEM_SIZE1(dst.depth());
-#if IPP_DISABLE_BLOCK // there are no performance benefits (PR #2653)
+
if (lutcn == 1)
{
ParallelLoopBody* p = new ipp::IppLUTParallelBody_LUTC1(src, lut, dst, &ok);
body.reset(p);
}
- else
-#endif
- if ((lutcn == 3 || lutcn == 4) && elemSize1 == 1)
+ else if ((lutcn == 3 || lutcn == 4) && elemSize1 == 1)
{
ParallelLoopBody* p = new ipp::IppLUTParallelBody_LUTCN(src, lut, dst, &ok);
body.reset(p);
@@ -5631,6 +5534,8 @@ static bool ipp_lut(Mat &src, Mat &lut, Mat &dst)
return false;
}
+
+#endif
#endif // IPP
class LUTParallelBody : public ParallelLoopBody
@@ -5696,10 +5601,12 @@ void cv::LUT( InputArray _src, InputArray _lut, OutputArray _dst )
_dst.create(src.dims, src.size, CV_MAKETYPE(_lut.depth(), cn));
Mat dst = _dst.getMat();
- CV_OVX_RUN(true,
+ CV_OVX_RUN(!ovx::skipSmallImages<VX_KERNEL_TABLE_LOOKUP>(src.cols, src.rows),
openvx_LUT(src, dst, lut))
+#if !IPP_DISABLE_PERF_LUT
CV_IPP_RUN(_src.dims() <= 2, ipp_lut(src, lut, dst));
+#endif
if (_src.dims() <= 2)
{
diff --git a/modules/core/src/convert.fp16.cpp b/modules/core/src/convert.fp16.cpp
new file mode 100644
index 0000000..927fb62
--- /dev/null
+++ b/modules/core/src/convert.fp16.cpp
@@ -0,0 +1,167 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
+// Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved.
+// Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "precomp.hpp"
+
+#include "convert.hpp"
+
+
+namespace cv
+{
+namespace opt_FP16
+{
+#if !defined(CV_NEON) || !CV_NEON
+const static int cVectorWidth = 8;
+
+void cvtScaleHalf_SIMD32f16f( const float* src, size_t sstep, short* dst, size_t dstep, cv::Size size )
+{
+ CV_INSTRUMENT_REGION()
+
+ sstep /= sizeof(src[0]);
+ dstep /= sizeof(dst[0]);
+
+ for( ; size.height--; src += sstep, dst += dstep )
+ {
+ int x = 0;
+ for ( ; x <= size.width - cVectorWidth ; x += cVectorWidth )
+ {
+ __m256 v_src = _mm256_loadu_ps(src + x);
+
+ // round to nearest even
+ __m128i v_dst = _mm256_cvtps_ph(v_src, 0);
+
+ _mm_storeu_si128((__m128i*)(dst + x), v_dst);
+ }
+
+ for ( ; x < size.width; x++ )
+ {
+ dst[x] = convertFp16SW(src[x]);
+ }
+ }
+}
+
+void cvtScaleHalf_SIMD16f32f( const short* src, size_t sstep, float* dst, size_t dstep, cv::Size size )
+{
+ CV_INSTRUMENT_REGION()
+
+ sstep /= sizeof(src[0]);
+ dstep /= sizeof(dst[0]);
+
+ for( ; size.height--; src += sstep, dst += dstep )
+ {
+ int x = 0;
+ for ( ; x <= size.width - cVectorWidth ; x += cVectorWidth )
+ {
+ __m128i v_src = _mm_loadu_si128((__m128i*)(src + x));
+
+ __m256 v_dst = _mm256_cvtph_ps(v_src);
+
+ _mm256_storeu_ps(dst + x, v_dst);
+ }
+
+ for ( ; x < size.width; x++ )
+ {
+ dst[x] = convertFp16SW(src[x]);
+ }
+ }
+}
+#elif CV_NEON
+const static int cVectorWidth = 4;
+
+void cvtScaleHalf_SIMD32f16f( const float* src, size_t sstep, short* dst, size_t dstep, cv::Size size )
+{
+ CV_INSTRUMENT_REGION()
+
+ sstep /= sizeof(src[0]);
+ dstep /= sizeof(dst[0]);
+
+ for( ; size.height--; src += sstep, dst += dstep )
+ {
+ int x = 0;
+ for ( ; x <= size.width - cVectorWidth ; x += cVectorWidth)
+ {
+ float32x4_t v_src = vld1q_f32(src + x);
+
+ float16x4_t v_dst = vcvt_f16_f32(v_src);
+
+ cv_vst1_f16((__fp16*)dst + x, v_dst);
+ }
+
+ for ( ; x < size.width; x++ )
+ {
+ dst[x] = convertFp16SW(src[x]);
+ }
+ }
+}
+
+void cvtScaleHalf_SIMD16f32f( const short* src, size_t sstep, float* dst, size_t dstep, cv::Size size )
+{
+ CV_INSTRUMENT_REGION()
+
+ sstep /= sizeof(src[0]);
+ dstep /= sizeof(dst[0]);
+
+ for( ; size.height--; src += sstep, dst += dstep )
+ {
+ int x = 0;
+ for ( ; x <= size.width - cVectorWidth ; x += cVectorWidth )
+ {
+ float16x4_t v_src = cv_vld1_f16((__fp16*)src + x);
+
+ float32x4_t v_dst = vcvt_f32_f16(v_src);
+
+ vst1q_f32(dst + x, v_dst);
+ }
+
+ for ( ; x < size.width; x++ )
+ {
+ dst[x] = convertFp16SW(src[x]);
+ }
+ }
+}
+#else
+#error "Unsupported build configuration"
+#endif
+}
+}
+/* End of file. */
diff --git a/modules/core/src/convert.hpp b/modules/core/src/convert.hpp
new file mode 100644
index 0000000..ce1d313
--- /dev/null
+++ b/modules/core/src/convert.hpp
@@ -0,0 +1,188 @@
+
+namespace
+{
+float convertFp16SW(short fp16);
+short convertFp16SW(float fp32);
+
+#if !CV_FP16_TYPE
+// const numbers for floating points format
+const unsigned int kShiftSignificand = 13;
+const unsigned int kMaskFp16Significand = 0x3ff;
+const unsigned int kBiasFp16Exponent = 15;
+const unsigned int kBiasFp32Exponent = 127;
+#endif
+
+#if CV_FP16_TYPE
+inline float convertFp16SW(short fp16)
+{
+ // Fp16 -> Fp32
+ Cv16suf a;
+ a.i = fp16;
+ return (float)a.h;
+}
+#else
+inline float convertFp16SW(short fp16)
+{
+ // Fp16 -> Fp32
+ Cv16suf b;
+ b.i = fp16;
+ int exponent = b.fmt.exponent - kBiasFp16Exponent;
+ int significand = b.fmt.significand;
+
+ Cv32suf a;
+ a.i = 0;
+ a.fmt.sign = b.fmt.sign; // sign bit
+ if( exponent == 16 )
+ {
+ // Inf or NaN
+ a.i = a.i | 0x7F800000;
+ if( significand != 0 )
+ {
+ // NaN
+#if defined(__x86_64__) || defined(_M_X64)
+ // 64bit
+ a.i = a.i | 0x7FC00000;
+#endif
+ a.fmt.significand = a.fmt.significand | (significand << kShiftSignificand);
+ }
+ return a.f;
+ }
+ else if ( exponent == -(int)kBiasFp16Exponent )
+ {
+ // subnormal in Fp16
+ if( significand == 0 )
+ {
+ // zero
+ return a.f;
+ }
+ else
+ {
+ int shift = -1;
+ while( ( significand & 0x400 ) == 0 )
+ {
+ significand = significand << 1;
+ shift++;
+ }
+ significand = significand & kMaskFp16Significand;
+ exponent -= shift;
+ }
+ }
+
+ a.fmt.exponent = (exponent+kBiasFp32Exponent);
+ a.fmt.significand = significand << kShiftSignificand;
+ return a.f;
+}
+#endif
+
+#if CV_FP16_TYPE
+inline short convertFp16SW(float fp32)
+{
+ // Fp32 -> Fp16
+ Cv16suf a;
+ a.h = (__fp16)fp32;
+ return a.i;
+}
+#else
+inline short convertFp16SW(float fp32)
+{
+ // Fp32 -> Fp16
+ Cv32suf a;
+ a.f = fp32;
+ int exponent = a.fmt.exponent - kBiasFp32Exponent;
+ int significand = a.fmt.significand;
+
+ Cv16suf result;
+ result.i = 0;
+ unsigned int absolute = a.i & 0x7fffffff;
+ if( 0x477ff000 <= absolute )
+ {
+ // Inf in Fp16
+ result.i = result.i | 0x7C00;
+ if( exponent == 128 && significand != 0 )
+ {
+ // NaN
+ result.i = (short)( result.i | 0x200 | ( significand >> kShiftSignificand ) );
+ }
+ }
+ else if ( absolute < 0x33000001 )
+ {
+ // too small for fp16
+ result.i = 0;
+ }
+ else if ( absolute < 0x387fe000 )
+ {
+ // subnormal in Fp16
+ int fp16Significand = significand | 0x800000;
+ int bitShift = (-exponent) - 1;
+ fp16Significand = fp16Significand >> bitShift;
+
+ // special cases to round up
+ bitShift = exponent + 24;
+ int threshold = ( ( 0x400000 >> bitShift ) | ( ( ( significand & ( 0x800000 >> bitShift ) ) >> ( 126 - a.fmt.exponent ) ) ^ 1 ) );
+ if( absolute == 0x33c00000 )
+ {
+ result.i = 2;
+ }
+ else
+ {
+ if( threshold <= ( significand & ( 0xffffff >> ( exponent + 25 ) ) ) )
+ {
+ fp16Significand++;
+ }
+ result.i = (short)fp16Significand;
+ }
+ }
+ else
+ {
+ // usual situation
+ // exponent
+ result.fmt.exponent = ( exponent + kBiasFp16Exponent );
+
+ // significand;
+ short fp16Significand = (short)(significand >> kShiftSignificand);
+ result.fmt.significand = fp16Significand;
+
+ // special cases to round up
+ short lsb10bitsFp32 = (significand & 0x1fff);
+ short threshold = 0x1000 + ( ( fp16Significand & 0x1 ) ? 0 : 1 );
+ if( threshold <= lsb10bitsFp32 )
+ {
+ result.i++;
+ }
+ else if ( fp16Significand == kMaskFp16Significand && exponent == -15)
+ {
+ result.i++;
+ }
+ }
+
+ // sign bit
+ result.fmt.sign = a.fmt.sign;
+ return result.i;
+}
+#endif
+
+}
+
+namespace cv
+{
+namespace opt_FP16
+{
+void cvtScaleHalf_SIMD32f16f( const float* src, size_t sstep, short* dst, size_t dstep, cv::Size size );
+void cvtScaleHalf_SIMD16f32f( const short* src, size_t sstep, float* dst, size_t dstep, cv::Size size );
+}
+namespace opt_AVX2
+{
+void cvtScale_s16s32f32Line_AVX2(const short* src, int* dst, float scale, float shift, int width);
+}
+namespace opt_SSE4_1
+{
+ int cvtScale_SIMD_u8u16f32_SSE41(const uchar * src, ushort * dst, int width, float scale, float shift);
+ int cvtScale_SIMD_s8u16f32_SSE41(const schar * src, ushort * dst, int width, float scale, float shift);
+ int cvtScale_SIMD_u16u16f32_SSE41(const ushort * src, ushort * dst, int width, float scale, float shift);
+ int cvtScale_SIMD_s16u16f32_SSE41(const short * src, ushort * dst, int width, float scale, float shift);
+ int cvtScale_SIMD_s32u16f32_SSE41(const int * src, ushort * dst, int width, float scale, float shift);
+ int cvtScale_SIMD_f32u16f32_SSE41(const float * src, ushort * dst, int width, float scale, float shift);
+ int cvtScale_SIMD_f64u16f32_SSE41(const double * src, ushort * dst, int width, float scale, float shift);
+ int Cvt_SIMD_f64u16_SSE41(const double * src, ushort * dst, int width);
+}
+}
\ No newline at end of file
diff --git a/modules/core/src/convert.sse4_1.cpp b/modules/core/src/convert.sse4_1.cpp
new file mode 100644
index 0000000..9a5234a
--- /dev/null
+++ b/modules/core/src/convert.sse4_1.cpp
@@ -0,0 +1,241 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
+// Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved.
+// Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "precomp.hpp"
+#include "convert.hpp"
+
+namespace cv
+{
+namespace opt_SSE4_1
+{
+
+int cvtScale_SIMD_u8u16f32_SSE41(const uchar * src, ushort * dst, int width, float scale, float shift)
+{
+ int x = 0;
+
+ __m128i v_zero = _mm_setzero_si128();
+ __m128 v_scale = _mm_set1_ps(scale), v_shift = _mm_set1_ps(shift);
+
+ for ( ; x <= width - 8; x += 8)
+ {
+ __m128i v_src = _mm_unpacklo_epi8(_mm_loadl_epi64((__m128i const *)(src + x)), v_zero);
+ __m128 v_src_f = _mm_cvtepi32_ps(_mm_unpacklo_epi16(v_src, v_zero));
+ __m128 v_dst_0 = _mm_add_ps(_mm_mul_ps(v_src_f, v_scale), v_shift);
+
+ v_src_f = _mm_cvtepi32_ps(_mm_unpackhi_epi16(v_src, v_zero));
+ __m128 v_dst_1 = _mm_add_ps(_mm_mul_ps(v_src_f, v_scale), v_shift);
+
+ __m128i v_dst = _mm_packus_epi32(_mm_cvtps_epi32(v_dst_0),
+ _mm_cvtps_epi32(v_dst_1));
+ _mm_storeu_si128((__m128i *)(dst + x), v_dst);
+ }
+
+ return x;
+}
+
+int cvtScale_SIMD_s8u16f32_SSE41(const schar * src, ushort * dst, int width, float scale, float shift)
+{
+ int x = 0;
+
+ __m128i v_zero = _mm_setzero_si128();
+ __m128 v_scale = _mm_set1_ps(scale), v_shift = _mm_set1_ps(shift);
+
+ for ( ; x <= width - 8; x += 8)
+ {
+ __m128i v_src = _mm_srai_epi16(_mm_unpacklo_epi8(v_zero, _mm_loadl_epi64((__m128i const *)(src + x))), 8);
+ __m128 v_src_f = _mm_cvtepi32_ps(_mm_srai_epi32(_mm_unpacklo_epi16(v_zero, v_src), 16));
+ __m128 v_dst_0 = _mm_add_ps(_mm_mul_ps(v_src_f, v_scale), v_shift);
+
+ v_src_f = _mm_cvtepi32_ps(_mm_srai_epi32(_mm_unpackhi_epi16(v_zero, v_src), 16));
+ __m128 v_dst_1 = _mm_add_ps(_mm_mul_ps(v_src_f, v_scale), v_shift);
+
+ __m128i v_dst = _mm_packus_epi32(_mm_cvtps_epi32(v_dst_0),
+ _mm_cvtps_epi32(v_dst_1));
+ _mm_storeu_si128((__m128i *)(dst + x), v_dst);
+ }
+
+ return x;
+}
+
+int cvtScale_SIMD_u16u16f32_SSE41(const ushort * src, ushort * dst, int width, float scale, float shift)
+{
+ int x = 0;
+
+ __m128i v_zero = _mm_setzero_si128();
+ __m128 v_scale = _mm_set1_ps(scale), v_shift = _mm_set1_ps(shift);
+
+ for ( ; x <= width - 8; x += 8)
+ {
+ __m128i v_src = _mm_loadu_si128((__m128i const *)(src + x));
+ __m128 v_src_f = _mm_cvtepi32_ps(_mm_unpacklo_epi16(v_src, v_zero));
+ __m128 v_dst_0 = _mm_add_ps(_mm_mul_ps(v_src_f, v_scale), v_shift);
+
+ v_src_f = _mm_cvtepi32_ps(_mm_unpackhi_epi16(v_src, v_zero));
+ __m128 v_dst_1 = _mm_add_ps(_mm_mul_ps(v_src_f, v_scale), v_shift);
+
+ __m128i v_dst = _mm_packus_epi32(_mm_cvtps_epi32(v_dst_0),
+ _mm_cvtps_epi32(v_dst_1));
+ _mm_storeu_si128((__m128i *)(dst + x), v_dst);
+ }
+
+ return x;
+}
+
+int cvtScale_SIMD_s16u16f32_SSE41(const short * src, ushort * dst, int width, float scale, float shift)
+{
+ int x = 0;
+
+ __m128i v_zero = _mm_setzero_si128();
+ __m128 v_scale = _mm_set1_ps(scale), v_shift = _mm_set1_ps(shift);
+
+ for ( ; x <= width - 8; x += 8)
+ {
+ __m128i v_src = _mm_loadu_si128((__m128i const *)(src + x));
+ __m128 v_src_f = _mm_cvtepi32_ps(_mm_srai_epi32(_mm_unpacklo_epi16(v_zero, v_src), 16));
+ __m128 v_dst_0 = _mm_add_ps(_mm_mul_ps(v_src_f, v_scale), v_shift);
+
+ v_src_f = _mm_cvtepi32_ps(_mm_srai_epi32(_mm_unpackhi_epi16(v_zero, v_src), 16));
+ __m128 v_dst_1 = _mm_add_ps(_mm_mul_ps(v_src_f, v_scale), v_shift);
+
+ __m128i v_dst = _mm_packus_epi32(_mm_cvtps_epi32(v_dst_0),
+ _mm_cvtps_epi32(v_dst_1));
+ _mm_storeu_si128((__m128i *)(dst + x), v_dst);
+ }
+
+ return x;
+}
+
+int cvtScale_SIMD_s32u16f32_SSE41(const int * src, ushort * dst, int width, float scale, float shift)
+{
+ int x = 0;
+
+ __m128 v_scale = _mm_set1_ps(scale), v_shift = _mm_set1_ps(shift);
+
+ for ( ; x <= width - 8; x += 8)
+ {
+ __m128i v_src = _mm_loadu_si128((__m128i const *)(src + x));
+ __m128 v_dst_0 = _mm_add_ps(_mm_mul_ps(_mm_cvtepi32_ps(v_src), v_scale), v_shift);
+
+ v_src = _mm_loadu_si128((__m128i const *)(src + x + 4));
+ __m128 v_dst_1 = _mm_add_ps(_mm_mul_ps(_mm_cvtepi32_ps(v_src), v_scale), v_shift);
+
+ __m128i v_dst = _mm_packus_epi32(_mm_cvtps_epi32(v_dst_0),
+ _mm_cvtps_epi32(v_dst_1));
+ _mm_storeu_si128((__m128i *)(dst + x), v_dst);
+ }
+
+ return x;
+}
+
+int cvtScale_SIMD_f32u16f32_SSE41(const float * src, ushort * dst, int width, float scale, float shift)
+{
+ int x = 0;
+
+ __m128 v_scale = _mm_set1_ps(scale), v_shift = _mm_set1_ps(shift);
+
+ for ( ; x <= width - 8; x += 8)
+ {
+ __m128 v_src = _mm_loadu_ps(src + x);
+ __m128 v_dst_0 = _mm_add_ps(_mm_mul_ps(v_src, v_scale), v_shift);
+
+ v_src = _mm_loadu_ps(src + x + 4);
+ __m128 v_dst_1 = _mm_add_ps(_mm_mul_ps(v_src, v_scale), v_shift);
+
+ __m128i v_dst = _mm_packus_epi32(_mm_cvtps_epi32(v_dst_0),
+ _mm_cvtps_epi32(v_dst_1));
+ _mm_storeu_si128((__m128i *)(dst + x), v_dst);
+ }
+
+ return x;
+}
+
+int cvtScale_SIMD_f64u16f32_SSE41(const double * src, ushort * dst, int width, float scale, float shift)
+{
+ int x = 0;
+
+ __m128 v_scale = _mm_set1_ps(scale), v_shift = _mm_set1_ps(shift);
+
+ for ( ; x <= width - 8; x += 8)
+ {
+ __m128 v_src = _mm_movelh_ps(_mm_cvtpd_ps(_mm_loadu_pd(src + x)),
+ _mm_cvtpd_ps(_mm_loadu_pd(src + x + 2)));
+ __m128 v_dst_0 = _mm_add_ps(_mm_mul_ps(v_src, v_scale), v_shift);
+
+ v_src = _mm_movelh_ps(_mm_cvtpd_ps(_mm_loadu_pd(src + x + 4)),
+ _mm_cvtpd_ps(_mm_loadu_pd(src + x + 6)));
+ __m128 v_dst_1 = _mm_add_ps(_mm_mul_ps(v_src, v_scale), v_shift);
+
+ __m128i v_dst = _mm_packus_epi32(_mm_cvtps_epi32(v_dst_0),
+ _mm_cvtps_epi32(v_dst_1));
+ _mm_storeu_si128((__m128i *)(dst + x), v_dst);
+ }
+
+ return x;
+}
+
+int Cvt_SIMD_f64u16_SSE41(const double * src, ushort * dst, int width)
+{
+ int x = 0;
+
+ for ( ; x <= width - 8; x += 8)
+ {
+ __m128 v_src0 = _mm_cvtpd_ps(_mm_loadu_pd(src + x));
+ __m128 v_src1 = _mm_cvtpd_ps(_mm_loadu_pd(src + x + 2));
+ __m128 v_src2 = _mm_cvtpd_ps(_mm_loadu_pd(src + x + 4));
+ __m128 v_src3 = _mm_cvtpd_ps(_mm_loadu_pd(src + x + 6));
+
+ v_src0 = _mm_movelh_ps(v_src0, v_src1);
+ v_src1 = _mm_movelh_ps(v_src2, v_src3);
+
+ __m128i v_dst = _mm_packus_epi32(_mm_cvtps_epi32(v_src0),
+ _mm_cvtps_epi32(v_src1));
+ _mm_storeu_si128((__m128i *)(dst + x), v_dst);
+ }
+
+ return x;
+}
+
+}
+}
+
+/* End of file. */
diff --git a/modules/core/src/copy.cpp b/modules/core/src/copy.cpp
index 1dd56f3..ca34e7f 100644
--- a/modules/core/src/copy.cpp
+++ b/modules/core/src/copy.cpp
@@ -49,6 +49,19 @@
#include "precomp.hpp"
#include "opencl_kernels_core.hpp"
+#ifdef HAVE_IPP_IW
+extern "C" {
+IW_DECL(IppStatus) llwiCopyMask(const void *pSrc, int srcStep, void *pDst, int dstStep,
+ IppiSize size, int typeSize, int channels, const Ipp8u *pMask, int maskStep);
+IW_DECL(IppStatus) llwiSet(const double *pValue, void *pDst, int dstStep,
+ IppiSize size, IppDataType dataType, int channels);
+IW_DECL(IppStatus) llwiSetMask(const double *pValue, void *pDst, int dstStep,
+ IppiSize size, IppDataType dataType, int channels, const Ipp8u *pMask, int maskStep);
+IW_DECL(IppStatus) llwiCopyMakeBorder(const void *pSrc, IppSizeL srcStep, void *pDst, IppSizeL dstStep,
+ IppiSizeL size, IppDataType dataType, int channels, IppiBorderSize *pBorderSize, IppiBorderType border, const Ipp64f *pBorderVal);
+}
+#endif
+
namespace cv
{
@@ -270,8 +283,9 @@ void Mat::copyTo( OutputArray _dst ) const
}
_dst.create( dims, size.p, type() );
UMat dst = _dst.getUMat();
-
- size_t i, sz[CV_MAX_DIM], dstofs[CV_MAX_DIM], esz = elemSize();
+ CV_Assert(dst.u != NULL);
+ size_t i, sz[CV_MAX_DIM] = {0}, dstofs[CV_MAX_DIM], esz = elemSize();
+ CV_Assert(dims >= 0 && dims < CV_MAX_DIM);
for( i = 0; i < (size_t)dims; i++ )
sz[i] = size.p[i];
sz[dims-1] *= esz;
@@ -298,13 +312,7 @@ void Mat::copyTo( OutputArray _dst ) const
const uchar* sptr = data;
uchar* dptr = dst.data;
- CV_IPP_RUN(
- (size_t)cols*elemSize() <= (size_t)INT_MAX &&
- (size_t)step <= (size_t)INT_MAX &&
- (size_t)dst.step <= (size_t)INT_MAX
- ,
- CV_INSTRUMENT_FUN_IPP(ippiCopy_8u_C1R, sptr, (int)step, dptr, (int)dst.step, ippiSize((int)(cols*elemSize()), rows)) >= 0
- )
+ CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippiCopy_8u_C1R_L, sptr, (int)step, dptr, (int)dst.step, ippiSizeL((int)(cols*elemSize()), rows)) >= 0)
Size sz = getContinuousSize(*this, dst);
size_t len = sz.width*elemSize();
@@ -332,6 +340,42 @@ void Mat::copyTo( OutputArray _dst ) const
}
}
+#ifdef HAVE_IPP
+static bool ipp_copyTo(const Mat &src, Mat &dst, const Mat &mask)
+{
+#ifdef HAVE_IPP_IW
+ CV_INSTRUMENT_REGION_IPP()
+
+ if(mask.channels() > 1 && mask.depth() != CV_8U)
+ return false;
+
+ if (src.dims <= 2)
+ {
+ IppiSize size = ippiSize(src.size());
+ return CV_INSTRUMENT_FUN_IPP(llwiCopyMask, src.ptr(), (int)src.step, dst.ptr(), (int)dst.step, size, (int)src.elemSize1(), src.channels(), mask.ptr(), (int)mask.step) >= 0;
+ }
+ else
+ {
+ const Mat *arrays[] = {&src, &dst, &mask, NULL};
+ uchar *ptrs[3] = {NULL};
+ NAryMatIterator it(arrays, ptrs);
+
+ IppiSize size = ippiSize(it.size, 1);
+
+ for (size_t i = 0; i < it.nplanes; i++, ++it)
+ {
+ if(CV_INSTRUMENT_FUN_IPP(llwiCopyMask, ptrs[0], 0, ptrs[1], 0, size, (int)src.elemSize1(), src.channels(), ptrs[2], 0) < 0)
+ return false;
+ }
+ return true;
+ }
+#else
+ CV_UNUSED(src); CV_UNUSED(dst); CV_UNUSED(mask);
+ return false;
+#endif
+}
+#endif
+
void Mat::copyTo( OutputArray _dst, InputArray _mask ) const
{
CV_INSTRUMENT_REGION()
@@ -346,9 +390,10 @@ void Mat::copyTo( OutputArray _dst, InputArray _mask ) const
int cn = channels(), mcn = mask.channels();
CV_Assert( mask.depth() == CV_8U && (mcn == 1 || mcn == cn) );
bool colorMask = mcn > 1;
-
- size_t esz = colorMask ? elemSize1() : elemSize();
- BinaryFunc copymask = getCopyMaskFunc(esz);
+ if( dims <= 2 )
+ {
+ CV_Assert( size() == mask.size() );
+ }
uchar* data0 = _dst.getMat().data;
_dst.create( dims, size, type() );
@@ -357,9 +402,13 @@ void Mat::copyTo( OutputArray _dst, InputArray _mask ) const
if( dst.data != data0 ) // do not leave dst uninitialized
dst = Scalar(0);
+ CV_IPP_RUN_FAST(ipp_copyTo(*this, dst, mask))
+
+ size_t esz = colorMask ? elemSize1() : elemSize();
+ BinaryFunc copymask = getCopyMaskFunc(esz);
+
if( dims <= 2 )
{
- CV_Assert( size() == mask.size() );
Size sz = getContinuousSize(*this, dst, mask, mcn);
copymask(data, step, mask.data, mask.step, dst.data, dst.step, sz, &esz);
return;
@@ -386,36 +435,6 @@ Mat& Mat::operator = (const Scalar& s)
if( is[0] == 0 && is[1] == 0 && is[2] == 0 && is[3] == 0 )
{
-#if defined HAVE_IPP && IPP_DISABLE_BLOCK
- CV_IPP_CHECK()
- {
- if (dims <= 2 || isContinuous())
- {
- IppiSize roisize = { cols, rows };
- if (isContinuous())
- {
- roisize.width = (int)total();
- roisize.height = 1;
-
- if (ippsZero_8u(data, static_cast<int>(roisize.width * elemSize())) >= 0)
- {
- CV_IMPL_ADD(CV_IMPL_IPP)
- return *this;
- }
- setIppErrorStatus();
- }
- roisize.width *= (int)elemSize();
-
- if (ippiSet_8u_C1R(0, data, (int)step, roisize) >= 0)
- {
- CV_IMPL_ADD(CV_IMPL_IPP)
- return *this;
- }
- setIppErrorStatus();
- }
- }
-#endif
-
for( size_t i = 0; i < it.nplanes; i++, ++it )
memset( dptr, 0, elsize );
}
@@ -430,6 +449,7 @@ Mat& Mat::operator = (const Scalar& s)
for( size_t j = 0; j < elsize; j += blockSize )
{
size_t sz = MIN(blockSize, elsize - j);
+ CV_Assert(sz <= sizeof(scalar));
memcpy( dptr + j, scalar, sz );
}
}
@@ -443,89 +463,55 @@ Mat& Mat::operator = (const Scalar& s)
return *this;
}
-#if defined HAVE_IPP
-static bool ipp_Mat_setTo(Mat *src, Mat &value, Mat &mask)
+#ifdef HAVE_IPP
+static bool ipp_Mat_setTo_Mat(Mat &dst, Mat &_val, Mat &mask)
{
+#ifdef HAVE_IPP_IW
CV_INSTRUMENT_REGION_IPP()
- int cn = src->channels(), depth0 = src->depth();
+ if(mask.empty())
+ return false;
- if (!mask.empty() && (src->dims <= 2 || (src->isContinuous() && mask.isContinuous())) &&
- (/*depth0 == CV_8U ||*/ depth0 == CV_16U || depth0 == CV_16S || depth0 == CV_32S || depth0 == CV_32F) &&
- (cn == 1 || cn == 3 || cn == 4))
+ if(mask.depth() != CV_8U || mask.channels() > 1)
+ return false;
+
+ if(dst.channels() > 4)
+ return false;
+
+ if(dst.dims <= 2)
{
- uchar _buf[32];
- void * buf = _buf;
- convertAndUnrollScalar( value, src->type(), _buf, 1 );
+ IppiSize size = ippiSize(dst.size());
+ IppDataType dataType = ippiGetDataType(dst.depth());
+ ::ipp::IwValue s;
+ convertAndUnrollScalar(_val, CV_MAKETYPE(CV_64F, dst.channels()), (uchar*)((Ipp64f*)s), 1);
- IppStatus status = (IppStatus)-1;
- IppiSize roisize = { src->cols, src->rows };
- int mstep = (int)mask.step[0], dstep = (int)src->step[0];
+ return CV_INSTRUMENT_FUN_IPP(llwiSetMask, s, dst.ptr(), (int)dst.step, size, dataType, dst.channels(), mask.ptr(), (int)mask.step) >= 0;
+ }
+ else
+ {
+ const Mat *arrays[] = {&dst, mask.empty()?NULL:&mask, NULL};
+ uchar *ptrs[2] = {NULL};
+ NAryMatIterator it(arrays, ptrs);
- if (src->isContinuous() && mask.isContinuous())
- {
- roisize.width = (int)src->total();
- roisize.height = 1;
- }
+ IppiSize size = {(int)it.size, 1};
+ IppDataType dataType = ippiGetDataType(dst.depth());
+ ::ipp::IwValue s;
+ convertAndUnrollScalar(_val, CV_MAKETYPE(CV_64F, dst.channels()), (uchar*)((Ipp64f*)s), 1);
- if (cn == 1)
+ for( size_t i = 0; i < it.nplanes; i++, ++it)
{
- /*if (depth0 == CV_8U)
- status = ippiSet_8u_C1MR(*(Ipp8u *)buf, (Ipp8u *)data, dstep, roisize, mask.data, mstep);
- else*/ if (depth0 == CV_16U)
- status = CV_INSTRUMENT_FUN_IPP(ippiSet_16u_C1MR, *(Ipp16u *)buf, (Ipp16u *)src->data, dstep, roisize, mask.data, mstep);
- else if (depth0 == CV_16S)
- status = CV_INSTRUMENT_FUN_IPP(ippiSet_16s_C1MR, *(Ipp16s *)buf, (Ipp16s *)src->data, dstep, roisize, mask.data, mstep);
- else if (depth0 == CV_32S)
- status = CV_INSTRUMENT_FUN_IPP(ippiSet_32s_C1MR, *(Ipp32s *)buf, (Ipp32s *)src->data, dstep, roisize, mask.data, mstep);
- else if (depth0 == CV_32F)
- status = CV_INSTRUMENT_FUN_IPP(ippiSet_32f_C1MR, *(Ipp32f *)buf, (Ipp32f *)src->data, dstep, roisize, mask.data, mstep);
+ if(CV_INSTRUMENT_FUN_IPP(llwiSetMask, s, ptrs[0], 0, size, dataType, dst.channels(), ptrs[1], 0) < 0)
+ return false;
}
- else if (cn == 3 || cn == 4)
- {
-
-#define IPP_SET(ippfavor, ippcn) \
- do \
- { \
- typedef Ipp##ippfavor ipptype; \
- ipptype ippvalue[4] = { ((ipptype *)buf)[0], ((ipptype *)buf)[1], ((ipptype *)buf)[2], ((ipptype *)buf)[3] }; \
- status = CV_INSTRUMENT_FUN_IPP(ippiSet_##ippfavor##_C##ippcn##MR, ippvalue, (ipptype *)src->data, dstep, roisize, mask.data, mstep); \
- } while ((void)0, 0)
-
-#define IPP_SET_CN(ippcn) \
- do \
- { \
- if (cn == ippcn) \
- { \
- /*if (depth0 == CV_8U) \
- IPP_SET(8u, ippcn); \
- else*/ if (depth0 == CV_16U) \
- IPP_SET(16u, ippcn); \
- else if (depth0 == CV_16S) \
- IPP_SET(16s, ippcn); \
- else if (depth0 == CV_32S) \
- IPP_SET(32s, ippcn); \
- else if (depth0 == CV_32F) \
- IPP_SET(32f, ippcn); \
- } \
- } while ((void)0, 0)
-
- IPP_SET_CN(3);
- IPP_SET_CN(4);
-
-#undef IPP_SET_CN
-#undef IPP_SET
- }
-
- if (status >= 0)
- return true;
+ return true;
}
-
+#else
+ CV_UNUSED(dst); CV_UNUSED(_val); CV_UNUSED(mask);
return false;
+#endif
}
#endif
-
Mat& Mat::setTo(InputArray _value, InputArray _mask)
{
CV_INSTRUMENT_REGION()
@@ -538,7 +524,7 @@ Mat& Mat::setTo(InputArray _value, InputArray _mask)
CV_Assert( checkScalar(value, type(), _value.kind(), _InputArray::MAT ));
CV_Assert( mask.empty() || (mask.type() == CV_8U && size == mask.size) );
- CV_IPP_RUN_FAST(ipp_Mat_setTo((cv::Mat*)this, value, mask), *this)
+ CV_IPP_RUN_FAST(ipp_Mat_setTo_Mat(*this, value, mask), *this)
size_t esz = elemSize();
BinaryFunc copymask = getCopyMaskFunc(esz);
@@ -713,73 +699,36 @@ static bool ocl_flip(InputArray _src, OutputArray _dst, int flipCode )
#endif
#if defined HAVE_IPP
-static bool ipp_flip( Mat &src, Mat &dst, int flip_mode )
+static bool ipp_flip(Mat &src, Mat &dst, int flip_mode)
{
+#ifdef HAVE_IPP_IW
CV_INSTRUMENT_REGION_IPP()
- int type = src.type();
-
- typedef IppStatus (CV_STDCALL * IppiMirror)(const void * pSrc, int srcStep, void * pDst, int dstStep, IppiSize roiSize, IppiAxis flip);
- typedef IppStatus (CV_STDCALL * IppiMirrorI)(const void * pSrcDst, int srcDstStep, IppiSize roiSize, IppiAxis flip);
- IppiMirror ippiMirror = 0;
- IppiMirrorI ippiMirror_I = 0;
-
- if (src.data == dst.data)
- {
- CV_SUPPRESS_DEPRECATED_START
- ippiMirror_I =
- type == CV_8UC1 ? (IppiMirrorI)ippiMirror_8u_C1IR :
- type == CV_8UC3 ? (IppiMirrorI)ippiMirror_8u_C3IR :
- type == CV_8UC4 ? (IppiMirrorI)ippiMirror_8u_C4IR :
- type == CV_16UC1 ? (IppiMirrorI)ippiMirror_16u_C1IR :
- type == CV_16UC3 ? (IppiMirrorI)ippiMirror_16u_C3IR :
- type == CV_16UC4 ? (IppiMirrorI)ippiMirror_16u_C4IR :
- type == CV_16SC1 ? (IppiMirrorI)ippiMirror_16s_C1IR :
- type == CV_16SC3 ? (IppiMirrorI)ippiMirror_16s_C3IR :
- type == CV_16SC4 ? (IppiMirrorI)ippiMirror_16s_C4IR :
- type == CV_32SC1 ? (IppiMirrorI)ippiMirror_32s_C1IR :
- type == CV_32SC3 ? (IppiMirrorI)ippiMirror_32s_C3IR :
- type == CV_32SC4 ? (IppiMirrorI)ippiMirror_32s_C4IR :
- type == CV_32FC1 ? (IppiMirrorI)ippiMirror_32f_C1IR :
- type == CV_32FC3 ? (IppiMirrorI)ippiMirror_32f_C3IR :
- type == CV_32FC4 ? (IppiMirrorI)ippiMirror_32f_C4IR : 0;
- CV_SUPPRESS_DEPRECATED_END
- }
+ IppiAxis ippMode;
+ if(flip_mode < 0)
+ ippMode = ippAxsBoth;
+ else if(flip_mode == 0)
+ ippMode = ippAxsHorizontal;
else
- {
- ippiMirror =
- type == CV_8UC1 ? (IppiMirror)ippiMirror_8u_C1R :
- type == CV_8UC3 ? (IppiMirror)ippiMirror_8u_C3R :
- type == CV_8UC4 ? (IppiMirror)ippiMirror_8u_C4R :
- type == CV_16UC1 ? (IppiMirror)ippiMirror_16u_C1R :
- type == CV_16UC3 ? (IppiMirror)ippiMirror_16u_C3R :
- type == CV_16UC4 ? (IppiMirror)ippiMirror_16u_C4R :
- type == CV_16SC1 ? (IppiMirror)ippiMirror_16s_C1R :
- type == CV_16SC3 ? (IppiMirror)ippiMirror_16s_C3R :
- type == CV_16SC4 ? (IppiMirror)ippiMirror_16s_C4R :
- type == CV_32SC1 ? (IppiMirror)ippiMirror_32s_C1R :
- type == CV_32SC3 ? (IppiMirror)ippiMirror_32s_C3R :
- type == CV_32SC4 ? (IppiMirror)ippiMirror_32s_C4R :
- type == CV_32FC1 ? (IppiMirror)ippiMirror_32f_C1R :
- type == CV_32FC3 ? (IppiMirror)ippiMirror_32f_C3R :
- type == CV_32FC4 ? (IppiMirror)ippiMirror_32f_C4R : 0;
- }
- IppiAxis axis = flip_mode == 0 ? ippAxsHorizontal :
- flip_mode > 0 ? ippAxsVertical : ippAxsBoth;
- IppiSize roisize = { dst.cols, dst.rows };
+ ippMode = ippAxsVertical;
- if (ippiMirror != 0)
+ try
{
- if (CV_INSTRUMENT_FUN_IPP(ippiMirror, src.ptr(), (int)src.step, dst.ptr(), (int)dst.step, ippiSize(src.cols, src.rows), axis) >= 0)
- return true;
+ ::ipp::IwiImage iwSrc = ippiGetImage(src);
+ ::ipp::IwiImage iwDst = ippiGetImage(dst);
+
+ CV_INSTRUMENT_FUN_IPP(::ipp::iwiMirror, &iwSrc, &iwDst, ippMode);
}
- else if (ippiMirror_I != 0)
+ catch(::ipp::IwException)
{
- if (CV_INSTRUMENT_FUN_IPP(ippiMirror_I, dst.ptr(), (int)dst.step, roisize, axis) >= 0)
- return true;
+ return false;
}
+ return true;
+#else
+ CV_UNUSED(src); CV_UNUSED(dst); CV_UNUSED(flip_mode);
return false;
+#endif
}
#endif
@@ -908,6 +857,7 @@ void repeat(InputArray _src, int ny, int nx, OutputArray _dst)
{
CV_INSTRUMENT_REGION()
+ CV_Assert(_src.getObj() != _dst.getObj());
CV_Assert( _src.dims() <= 2 );
CV_Assert( ny > 0 && nx > 0 );
@@ -959,7 +909,7 @@ Mat repeat(const Mat& src, int ny, int nx)
*/
int cv::borderInterpolate( int p, int len, int borderType )
{
- CV_INSTRUMENT_REGION()
+ CV_TRACE_FUNCTION_VERBOSE();
if( (unsigned)p < (unsigned)len )
;
@@ -1184,7 +1134,41 @@ static bool ocl_copyMakeBorder( InputArray _src, OutputArray _dst, int top, int
}
}
+#endif
+
+#ifdef HAVE_IPP
+namespace cv {
+
+static bool ipp_copyMakeBorder( Mat &_src, Mat &_dst, int top, int bottom,
+ int left, int right, int _borderType, const Scalar& value )
+{
+#if defined HAVE_IPP_IW && !IPP_DISABLE_PERF_COPYMAKE
+ CV_INSTRUMENT_REGION_IPP()
+ ::ipp::IwiBorderSize borderSize(left, top, right, bottom);
+ ::ipp::IwiSize size(_src.cols, _src.rows);
+ IppDataType dataType = ippiGetDataType(_src.depth());
+ IppiBorderType borderType = ippiGetBorderType(_borderType);
+ if((int)borderType == -1)
+ return false;
+
+ if(_src.dims > 2)
+ return false;
+
+ Rect dstRect(borderSize.borderLeft, borderSize.borderTop,
+ _dst.cols - borderSize.borderRight - borderSize.borderLeft,
+ _dst.rows - borderSize.borderBottom - borderSize.borderTop);
+ Mat subDst = Mat(_dst, dstRect);
+ Mat *pSrc = &_src;
+
+ return CV_INSTRUMENT_FUN_IPP(llwiCopyMakeBorder, pSrc->ptr(), pSrc->step, subDst.ptr(), subDst.step, size, dataType, _src.channels(), &borderSize, borderType, &value[0]) >= 0;
+#else
+ CV_UNUSED(_src); CV_UNUSED(_dst); CV_UNUSED(top); CV_UNUSED(bottom); CV_UNUSED(left); CV_UNUSED(right);
+ CV_UNUSED(_borderType); CV_UNUSED(value);
+ return false;
+#endif
+}
+}
#endif
void cv::copyMakeBorder( InputArray _src, OutputArray _dst, int top, int bottom,
@@ -1228,120 +1212,7 @@ void cv::copyMakeBorder( InputArray _src, OutputArray _dst, int top, int bottom,
borderType &= ~BORDER_ISOLATED;
-#if defined HAVE_IPP && IPP_DISABLE_BLOCK
- CV_IPP_CHECK()
- {
- typedef IppStatus (CV_STDCALL * ippiCopyMakeBorder)(const void * pSrc, int srcStep, IppiSize srcRoiSize, void * pDst,
- int dstStep, IppiSize dstRoiSize, int topBorderHeight, int leftBorderWidth);
- typedef IppStatus (CV_STDCALL * ippiCopyMakeBorderI)(const void * pSrc, int srcDstStep, IppiSize srcRoiSize, IppiSize dstRoiSize,
- int topBorderHeight, int leftborderwidth);
- typedef IppStatus (CV_STDCALL * ippiCopyConstBorder)(const void * pSrc, int srcStep, IppiSize srcRoiSize, void * pDst, int dstStep,
- IppiSize dstRoiSize, int topBorderHeight, int leftBorderWidth, void * value);
-
- IppiSize srcRoiSize = { src.cols, src.rows }, dstRoiSize = { dst.cols, dst.rows };
- ippiCopyMakeBorder ippFunc = 0;
- ippiCopyMakeBorderI ippFuncI = 0;
- ippiCopyConstBorder ippFuncConst = 0;
- bool inplace = dst.datastart == src.datastart;
-
- if (borderType == BORDER_CONSTANT)
- {
- ippFuncConst =
- // type == CV_8UC1 ? (ippiCopyConstBorder)ippiCopyConstBorder_8u_C1R : bug in IPP 8.1
- type == CV_16UC1 ? (ippiCopyConstBorder)ippiCopyConstBorder_16u_C1R :
- // type == CV_16SC1 ? (ippiCopyConstBorder)ippiCopyConstBorder_16s_C1R : bug in IPP 8.1
- // type == CV_32SC1 ? (ippiCopyConstBorder)ippiCopyConstBorder_32s_C1R : bug in IPP 8.1
- // type == CV_32FC1 ? (ippiCopyConstBorder)ippiCopyConstBorder_32f_C1R : bug in IPP 8.1
- type == CV_8UC3 ? (ippiCopyConstBorder)ippiCopyConstBorder_8u_C3R :
- type == CV_16UC3 ? (ippiCopyConstBorder)ippiCopyConstBorder_16u_C3R :
- type == CV_16SC3 ? (ippiCopyConstBorder)ippiCopyConstBorder_16s_C3R :
- type == CV_32SC3 ? (ippiCopyConstBorder)ippiCopyConstBorder_32s_C3R :
- type == CV_32FC3 ? (ippiCopyConstBorder)ippiCopyConstBorder_32f_C3R :
- type == CV_8UC4 ? (ippiCopyConstBorder)ippiCopyConstBorder_8u_C4R :
- type == CV_16UC4 ? (ippiCopyConstBorder)ippiCopyConstBorder_16u_C4R :
- type == CV_16SC4 ? (ippiCopyConstBorder)ippiCopyConstBorder_16s_C4R :
- type == CV_32SC4 ? (ippiCopyConstBorder)ippiCopyConstBorder_32s_C4R :
- type == CV_32FC4 ? (ippiCopyConstBorder)ippiCopyConstBorder_32f_C4R : 0;
- }
- else if (borderType == BORDER_WRAP)
- {
- if (inplace)
- {
- CV_SUPPRESS_DEPRECATED_START
- ippFuncI =
- type == CV_32SC1 ? (ippiCopyMakeBorderI)ippiCopyWrapBorder_32s_C1IR :
- type == CV_32FC1 ? (ippiCopyMakeBorderI)ippiCopyWrapBorder_32s_C1IR : 0;
- CV_SUPPRESS_DEPRECATED_END
- }
- else
- {
- ippFunc =
- type == CV_32SC1 ? (ippiCopyMakeBorder)ippiCopyWrapBorder_32s_C1R :
- type == CV_32FC1 ? (ippiCopyMakeBorder)ippiCopyWrapBorder_32s_C1R : 0;
- }
- }
- else if (borderType == BORDER_REPLICATE)
- {
- if (inplace)
- {
- CV_SUPPRESS_DEPRECATED_START
- ippFuncI =
- type == CV_8UC1 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_8u_C1IR :
- type == CV_16UC1 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_16u_C1IR :
- type == CV_16SC1 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_16s_C1IR :
- type == CV_32SC1 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_32s_C1IR :
- type == CV_32FC1 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_32f_C1IR :
- type == CV_8UC3 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_8u_C3IR :
- type == CV_16UC3 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_16u_C3IR :
- type == CV_16SC3 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_16s_C3IR :
- type == CV_32SC3 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_32s_C3IR :
- type == CV_32FC3 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_32f_C3IR :
- type == CV_8UC4 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_8u_C4IR :
- type == CV_16UC4 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_16u_C4IR :
- type == CV_16SC4 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_16s_C4IR :
- type == CV_32SC4 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_32s_C4IR :
- type == CV_32FC4 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_32f_C4IR : 0;
- CV_SUPPRESS_DEPRECATED_END
- }
- else
- {
- ippFunc =
- type == CV_8UC1 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_8u_C1R :
- type == CV_16UC1 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_16u_C1R :
- type == CV_16SC1 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_16s_C1R :
- type == CV_32SC1 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_32s_C1R :
- type == CV_32FC1 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_32f_C1R :
- type == CV_8UC3 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_8u_C3R :
- type == CV_16UC3 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_16u_C3R :
- type == CV_16SC3 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_16s_C3R :
- type == CV_32SC3 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_32s_C3R :
- type == CV_32FC3 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_32f_C3R :
- type == CV_8UC4 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_8u_C4R :
- type == CV_16UC4 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_16u_C4R :
- type == CV_16SC4 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_16s_C4R :
- type == CV_32SC4 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_32s_C4R :
- type == CV_32FC4 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_32f_C4R : 0;
- }
- }
-
- if (ippFunc || ippFuncI || ippFuncConst)
- {
- uchar scbuf[32];
- scalarToRawData(value, scbuf, type);
-
- if ( (ippFunc && ippFunc(src.data, (int)src.step, srcRoiSize, dst.data, (int)dst.step, dstRoiSize, top, left) >= 0) ||
- (ippFuncI && ippFuncI(src.data, (int)src.step, srcRoiSize, dstRoiSize, top, left) >= 0) ||
- (ippFuncConst && ippFuncConst(src.data, (int)src.step, srcRoiSize, dst.data, (int)dst.step,
- dstRoiSize, top, left, scbuf) >= 0))
- {
- CV_IMPL_ADD(CV_IMPL_IPP);
- return;
- }
-
- setIppErrorStatus();
- }
- }
-#endif
+ CV_IPP_RUN_FAST(ipp_copyMakeBorder(src, dst, top, bottom, left, right, borderType, value))
if( borderType != BORDER_CONSTANT )
copyMakeBorder_8u( src.ptr(), src.step, src.size(),
diff --git a/modules/core/src/cuda_stream.cpp b/modules/core/src/cuda_stream.cpp
index 1ea8df3..6967714 100644
--- a/modules/core/src/cuda_stream.cpp
+++ b/modules/core/src/cuda_stream.cpp
@@ -282,9 +282,10 @@ public:
cudaStream_t stream;
bool ownStream;
- Ptr<StackAllocator> stackAllocator;
+ Ptr<GpuMat::Allocator> allocator;
Impl();
+ Impl(const Ptr<GpuMat::Allocator>& allocator);
explicit Impl(cudaStream_t stream);
~Impl();
@@ -295,17 +296,23 @@ cv::cuda::Stream::Impl::Impl() : stream(0), ownStream(false)
cudaSafeCall( cudaStreamCreate(&stream) );
ownStream = true;
- stackAllocator = makePtr<StackAllocator>(stream);
+ allocator = makePtr<StackAllocator>(stream);
+}
+
+cv::cuda::Stream::Impl::Impl(const Ptr<GpuMat::Allocator>& allocator) : stream(0), ownStream(false), allocator(allocator)
+{
+ cudaSafeCall( cudaStreamCreate(&stream) );
+ ownStream = true;
}
cv::cuda::Stream::Impl::Impl(cudaStream_t stream_) : stream(stream_), ownStream(false)
{
- stackAllocator = makePtr<StackAllocator>(stream);
+ allocator = makePtr<StackAllocator>(stream);
}
cv::cuda::Stream::Impl::~Impl()
{
- stackAllocator.release();
+ allocator.release();
if (stream && ownStream)
{
@@ -417,6 +424,16 @@ cv::cuda::Stream::Stream()
#endif
}
+cv::cuda::Stream::Stream(const Ptr<GpuMat::Allocator>& allocator)
+{
+#ifndef HAVE_CUDA
+ (void) allocator;
+ throw_no_cuda();
+#else
+ impl_ = makePtr<Impl>(allocator);
+#endif
+}
+
bool cv::cuda::Stream::queryIfComplete() const
{
#ifndef HAVE_CUDA
@@ -668,20 +685,33 @@ void cv::cuda::setBufferPoolConfig(int deviceId, size_t stackSize, int stackCoun
#endif
}
-#ifdef HAVE_CUDA
-
-cv::cuda::BufferPool::BufferPool(Stream& stream) : allocator_(stream.impl_->stackAllocator.get())
+#ifndef HAVE_CUDA
+cv::cuda::BufferPool::BufferPool(Stream& stream)
+{
+ (void) stream;
+ throw_no_cuda();
+}
+#else
+cv::cuda::BufferPool::BufferPool(Stream& stream) : allocator_(stream.impl_->allocator)
{
}
+#endif
GpuMat cv::cuda::BufferPool::getBuffer(int rows, int cols, int type)
{
+#ifndef HAVE_CUDA
+ (void) rows;
+ (void) cols;
+ (void) type;
+ throw_no_cuda();
+ return GpuMat();
+#else
GpuMat buf(allocator_);
buf.create(rows, cols, type);
return buf;
+#endif
}
-#endif
////////////////////////////////////////////////////////////////
// Event
diff --git a/modules/core/src/datastructs.cpp b/modules/core/src/datastructs.cpp
index 2612de6..56528fc 100644
--- a/modules/core/src/datastructs.cpp
+++ b/modules/core/src/datastructs.cpp
@@ -2547,6 +2547,7 @@ cvSetAdd( CvSet* set, CvSetElem* element, CvSetElem** inserted_element )
CV_IMPL void
cvSetRemove( CvSet* set, int index )
{
+ CV_Assert(set != NULL);
CvSetElem* elem = cvGetSetElem( set, index );
if( elem )
cvSetRemoveByPtr( set, elem );
@@ -2881,7 +2882,7 @@ cvGraphRemoveEdgeByPtr( CvGraph* graph, CvGraphVtx* start_vtx, CvGraphVtx* end_v
break;
}
- assert( edge != 0 );
+ CV_Assert( edge != 0 );
next_edge = edge->next[ofs];
if( prev_edge )
diff --git a/modules/core/src/directx.cpp b/modules/core/src/directx.cpp
index 23a7b94..2ea1687 100644
--- a/modules/core/src/directx.cpp
+++ b/modules/core/src/directx.cpp
@@ -794,7 +794,9 @@ void convertToD3D11Texture2D(InputArray src, ID3D11Texture2D* pD3D11Texture2D)
cl_int status = 0;
cl_mem clImage = 0;
+#ifdef HAVE_DIRECTX_NV12
cl_mem clImageUV = 0;
+#endif
clImage = clCreateFromD3D11Texture2DKHR(context, CL_MEM_WRITE_ONLY, pD3D11Texture2D, 0, &status);
if (status != CL_SUCCESS)
diff --git a/modules/core/src/dxt.cpp b/modules/core/src/dxt.cpp
index f553c4f..e2a0222 100644
--- a/modules/core/src/dxt.cpp
+++ b/modules/core/src/dxt.cpp
@@ -1580,13 +1580,13 @@ public:
return;
}
- IppiDFTSpec_C_32fc* pDFTSpec = (IppiDFTSpec_C_32fc*)ippMalloc( sizeSpec );
+ IppiDFTSpec_C_32fc* pDFTSpec = (IppiDFTSpec_C_32fc*)CV_IPP_MALLOC( sizeSpec );
if ( sizeInit > 0 )
- pMemInit = (Ipp8u*)ippMalloc( sizeInit );
+ pMemInit = (Ipp8u*)CV_IPP_MALLOC( sizeInit );
if ( sizeBuffer > 0 )
- pBuffer = (Ipp8u*)ippMalloc( sizeBuffer );
+ pBuffer = (Ipp8u*)CV_IPP_MALLOC( sizeBuffer );
status = ippiDFTInit_C_32fc( srcRoiSize, norm_flag, ippAlgHintNone, pDFTSpec, pMemInit );
@@ -1661,13 +1661,13 @@ public:
return;
}
- IppiDFTSpec_R_32f* pDFTSpec = (IppiDFTSpec_R_32f*)ippMalloc( sizeSpec );
+ IppiDFTSpec_R_32f* pDFTSpec = (IppiDFTSpec_R_32f*)CV_IPP_MALLOC( sizeSpec );
if ( sizeInit > 0 )
- pMemInit = (Ipp8u*)ippMalloc( sizeInit );
+ pMemInit = (Ipp8u*)CV_IPP_MALLOC( sizeInit );
if ( sizeBuffer > 0 )
- pBuffer = (Ipp8u*)ippMalloc( sizeBuffer );
+ pBuffer = (Ipp8u*)CV_IPP_MALLOC( sizeBuffer );
status = ippiDFTInit_R_32f( srcRoiSize, norm_flag, ippAlgHintNone, pDFTSpec, pMemInit );
@@ -1767,13 +1767,13 @@ static bool ippi_DFT_C_32F(const uchar * src, size_t src_step, uchar * dst, size
if ( status < 0 )
return false;
- IppiDFTSpec_C_32fc* pDFTSpec = (IppiDFTSpec_C_32fc*)ippMalloc( sizeSpec );
+ IppiDFTSpec_C_32fc* pDFTSpec = (IppiDFTSpec_C_32fc*)CV_IPP_MALLOC( sizeSpec );
if ( sizeInit > 0 )
- pMemInit = (Ipp8u*)ippMalloc( sizeInit );
+ pMemInit = (Ipp8u*)CV_IPP_MALLOC( sizeInit );
if ( sizeBuffer > 0 )
- pBuffer = (Ipp8u*)ippMalloc( sizeBuffer );
+ pBuffer = (Ipp8u*)CV_IPP_MALLOC( sizeBuffer );
status = ippiDFTInit_C_32fc( srcRoiSize, norm_flag, ippAlgHintNone, pDFTSpec, pMemInit );
@@ -1823,13 +1823,13 @@ static bool ippi_DFT_R_32F(const uchar * src, size_t src_step, uchar * dst, size
if ( status < 0 )
return false;
- IppiDFTSpec_R_32f* pDFTSpec = (IppiDFTSpec_R_32f*)ippMalloc( sizeSpec );
+ IppiDFTSpec_R_32f* pDFTSpec = (IppiDFTSpec_R_32f*)CV_IPP_MALLOC( sizeSpec );
if ( sizeInit > 0 )
- pMemInit = (Ipp8u*)ippMalloc( sizeInit );
+ pMemInit = (Ipp8u*)CV_IPP_MALLOC( sizeInit );
if ( sizeBuffer > 0 )
- pBuffer = (Ipp8u*)ippMalloc( sizeBuffer );
+ pBuffer = (Ipp8u*)CV_IPP_MALLOC( sizeBuffer );
status = ippiDFTInit_R_32f( srcRoiSize, norm_flag, ippAlgHintNone, pDFTSpec, pMemInit );
@@ -3342,6 +3342,9 @@ void cv::dft( InputArray _src0, OutputArray _dst, int flags, int nonzero_rows )
CV_Assert( type == CV_32FC1 || type == CV_32FC2 || type == CV_64FC1 || type == CV_64FC2 );
+ // Fail if DFT_COMPLEX_INPUT is specified, but src is not 2 channels.
+ CV_Assert( !((flags & DFT_COMPLEX_INPUT) && src.channels() != 2) );
+
if( !inv && src.channels() == 1 && (flags & DFT_COMPLEX_OUTPUT) )
_dst.create( src.size(), CV_MAKETYPE(depth, 2) );
else if( inv && src.channels() == 2 && (flags & DFT_REAL_OUTPUT) )
@@ -3849,20 +3852,20 @@ public:
return;
}
- pDCTSpec = (Ipp8u*)ippMalloc(specSize);
+ pDCTSpec = (Ipp8u*)CV_IPP_MALLOC(specSize);
if(!pDCTSpec && specSize)
{
*ok = false;
return;
}
- pBuffer = (Ipp8u*)ippMalloc(bufferSize);
+ pBuffer = (Ipp8u*)CV_IPP_MALLOC(bufferSize);
if(!pBuffer && bufferSize)
{
*ok = false;
IPP_RETURN
}
- pInitBuf = (Ipp8u*)ippMalloc(initSize);
+ pInitBuf = (Ipp8u*)CV_IPP_MALLOC(initSize);
if(!pInitBuf && initSize)
{
*ok = false;
@@ -3978,17 +3981,17 @@ static bool ippi_DCT_32f(const uchar * src, size_t src_step, uchar * dst, size_t
if(ippDctGetSize(srcRoiSize, &specSize, &initSize, &bufferSize) < 0)
return false;
- pDCTSpec = (Ipp8u*)ippMalloc(specSize);
+ pDCTSpec = (Ipp8u*)CV_IPP_MALLOC(specSize);
if(!pDCTSpec && specSize)
return false;
- pBuffer = (Ipp8u*)ippMalloc(bufferSize);
+ pBuffer = (Ipp8u*)CV_IPP_MALLOC(bufferSize);
if(!pBuffer && bufferSize)
{
IPP_RELEASE
return false;
}
- pInitBuf = (Ipp8u*)ippMalloc(initSize);
+ pInitBuf = (Ipp8u*)CV_IPP_MALLOC(initSize);
if(!pInitBuf && initSize)
{
IPP_RELEASE
diff --git a/modules/core/src/glob.cpp b/modules/core/src/glob.cpp
index 9bd3bdb..60a220d 100644
--- a/modules/core/src/glob.cpp
+++ b/modules/core/src/glob.cpp
@@ -42,7 +42,7 @@
#include "precomp.hpp"
-#if defined WIN32 || defined _WIN32 || defined WINCE
+#if defined _WIN32 || defined WINCE
# include <windows.h>
const char dir_separators[] = "/\\";
const char native_separator = '\\';
@@ -139,7 +139,7 @@ const char native_separator = '/';
static bool isDir(const cv::String& path, DIR* dir)
{
-#if defined WIN32 || defined _WIN32 || defined WINCE
+#if defined _WIN32 || defined WINCE
DWORD attributes;
BOOL status = TRUE;
if (dir)
diff --git a/modules/core/src/hal_internal.cpp b/modules/core/src/hal_internal.cpp
index b2b6dc3..d98cd30 100644
--- a/modules/core/src/hal_internal.cpp
+++ b/modules/core/src/hal_internal.cpp
@@ -98,7 +98,7 @@ set_value(fptype *dst, size_t dst_ld, fptype value, size_t m, size_t n)
template <typename fptype> static inline int
lapack_LU(fptype* a, size_t a_step, int m, fptype* b, size_t b_step, int n, int* info)
{
- int lda = a_step / sizeof(fptype), sign = 0;
+ int lda = (int)(a_step / sizeof(fptype)), sign = 0;
int* piv = new int[m];
transpose_square_inplace(a, lda, m);
@@ -114,7 +114,7 @@ lapack_LU(fptype* a, size_t a_step, int m, fptype* b, size_t b_step, int n, int*
}
else
{
- int ldb = b_step / sizeof(fptype);
+ int ldb = (int)(b_step / sizeof(fptype));
fptype* tmpB = new fptype[m*n];
transpose(b, ldb, tmpB, m, m, n);
@@ -153,7 +153,7 @@ template <typename fptype> static inline int
lapack_Cholesky(fptype* a, size_t a_step, int m, fptype* b, size_t b_step, int n, bool* info)
{
int lapackStatus = 0;
- int lda = a_step / sizeof(fptype);
+ int lda = (int)(a_step / sizeof(fptype));
char L[] = {'L', '\0'};
if(b)
@@ -167,7 +167,7 @@ lapack_Cholesky(fptype* a, size_t a_step, int m, fptype* b, size_t b_step, int n
}
else
{
- int ldb = b_step / sizeof(fptype);
+ int ldb = (int)(b_step / sizeof(fptype));
fptype* tmpB = new fptype[m*n];
transpose(b, ldb, tmpB, m, m, n);
@@ -197,9 +197,9 @@ lapack_Cholesky(fptype* a, size_t a_step, int m, fptype* b, size_t b_step, int n
template <typename fptype> static inline int
lapack_SVD(fptype* a, size_t a_step, fptype *w, fptype* u, size_t u_step, fptype* vt, size_t v_step, int m, int n, int flags, int* info)
{
- int lda = a_step / sizeof(fptype);
- int ldv = v_step / sizeof(fptype);
- int ldu = u_step / sizeof(fptype);
+ int lda = (int)(a_step / sizeof(fptype));
+ int ldv = (int)(v_step / sizeof(fptype));
+ int ldu = (int)(u_step / sizeof(fptype));
int lwork = -1;
int* iworkBuf = new int[8*std::min(m, n)];
fptype work1 = 0;
@@ -256,7 +256,7 @@ lapack_SVD(fptype* a, size_t a_step, fptype *w, fptype* u, size_t u_step, fptype
template <typename fptype> static inline int
lapack_QR(fptype* a, size_t a_step, int m, int n, int k, fptype* b, size_t b_step, fptype* dst, int* info)
{
- int lda = a_step / sizeof(fptype);
+ int lda = (int)(a_step / sizeof(fptype));
char mode[] = { 'N', '\0' };
if(m < n)
return CV_HAL_ERROR_NOT_IMPLEMENTED;
@@ -290,7 +290,7 @@ lapack_QR(fptype* a, size_t a_step, int m, int n, int k, fptype* b, size_t b_ste
else if (typeid(fptype) == typeid(double))
dgels_(mode, &m, &n, &k, (double*)tmpA, &ldtmpA, (double*)b, &m, (double*)&work1, &lwork, info);
- lwork = (int)round(work1); //optimal buffer size
+ lwork = cvRound(work1); //optimal buffer size
std::vector<fptype> workBufMemHolder(lwork + 1);
fptype* buffer = &workBufMemHolder.front();
@@ -303,7 +303,7 @@ lapack_QR(fptype* a, size_t a_step, int m, int n, int k, fptype* b, size_t b_ste
{
std::vector<fptype> tmpBMemHolder(m*k);
fptype* tmpB = &tmpBMemHolder.front();
- int ldb = b_step / sizeof(fptype);
+ int ldb = (int)(b_step / sizeof(fptype));
transpose(b, ldb, tmpB, m, m, k);
if (typeid(fptype) == typeid(float))
@@ -311,7 +311,7 @@ lapack_QR(fptype* a, size_t a_step, int m, int n, int k, fptype* b, size_t b_ste
else if (typeid(fptype) == typeid(double))
dgels_(mode, &m, &n, &k, (double*)tmpA, &ldtmpA, (double*)tmpB, &m, (double*)&work1, &lwork, info);
- lwork = (int)round(work1); //optimal buffer size
+ lwork = cvRound(work1); //optimal buffer size
std::vector<fptype> workBufMemHolder(lwork + 1);
fptype* buffer = &workBufMemHolder.front();
@@ -330,7 +330,7 @@ lapack_QR(fptype* a, size_t a_step, int m, int n, int k, fptype* b, size_t b_ste
else if (typeid(fptype) == typeid(double))
dgeqrf_(&m, &n, (double*)tmpA, &ldtmpA, (double*)dst, (double*)&work1, &lwork, info);
- lwork = (int)round(work1); //optimal buffer size
+ lwork = cvRound(work1); //optimal buffer size
std::vector<fptype> workBufMemHolder(lwork + 1);
fptype* buffer = &workBufMemHolder.front();
@@ -357,10 +357,10 @@ template <typename fptype> static inline int
lapack_gemm(const fptype *src1, size_t src1_step, const fptype *src2, size_t src2_step, fptype alpha,
const fptype *src3, size_t src3_step, fptype beta, fptype *dst, size_t dst_step, int a_m, int a_n, int d_n, int flags)
{
- int ldsrc1 = src1_step / sizeof(fptype);
- int ldsrc2 = src2_step / sizeof(fptype);
- int ldsrc3 = src3_step / sizeof(fptype);
- int lddst = dst_step / sizeof(fptype);
+ int ldsrc1 = (int)(src1_step / sizeof(fptype));
+ int ldsrc2 = (int)(src2_step / sizeof(fptype));
+ int ldsrc3 = (int)(src3_step / sizeof(fptype));
+ int lddst = (int)(dst_step / sizeof(fptype));
int c_m, c_n, d_m;
CBLAS_TRANSPOSE transA, transB;
@@ -434,10 +434,10 @@ template <typename fptype> static inline int
lapack_gemm_c(const fptype *src1, size_t src1_step, const fptype *src2, size_t src2_step, fptype alpha,
const fptype *src3, size_t src3_step, fptype beta, fptype *dst, size_t dst_step, int a_m, int a_n, int d_n, int flags)
{
- int ldsrc1 = src1_step / sizeof(std::complex<fptype>);
- int ldsrc2 = src2_step / sizeof(std::complex<fptype>);
- int ldsrc3 = src3_step / sizeof(std::complex<fptype>);
- int lddst = dst_step / sizeof(std::complex<fptype>);
+ int ldsrc1 = (int)(src1_step / sizeof(std::complex<fptype>));
+ int ldsrc2 = (int)(src2_step / sizeof(std::complex<fptype>));
+ int ldsrc3 = (int)(src3_step / sizeof(std::complex<fptype>));
+ int lddst = (int)(dst_step / sizeof(std::complex<fptype>));
int c_m, c_n, d_m;
CBLAS_TRANSPOSE transA, transB;
std::complex<fptype> cAlpha(alpha, 0.0);
diff --git a/modules/core/src/intel_gpu_gemm.inl.hpp b/modules/core/src/intel_gpu_gemm.inl.hpp
new file mode 100644
index 0000000..04b5ffc
--- /dev/null
+++ b/modules/core/src/intel_gpu_gemm.inl.hpp
@@ -0,0 +1,147 @@
+/*
+* Copyright 2015-2017 Philippe Tillet
+* Copyright (c) 2017, Intel Corporation
+*
+* 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.
+*/
+
+#ifdef HAVE_OPENCL
+
+#include <sstream>
+#include "precomp.hpp"
+#include "opencl_kernels_core.hpp"
+#include "opencv2/core/opencl/runtime/opencl_clamdblas.hpp"
+#include "opencv2/core/opencl/runtime/opencl_core.hpp"
+
+namespace cv
+{
+
+static bool intel_gpu_gemm(
+ UMat A, Size sizeA,
+ UMat B, Size sizeB,
+ UMat D, Size sizeD,
+ double alpha, double beta,
+ bool atrans, bool btrans)
+{
+ CV_UNUSED(sizeB);
+
+ int M = sizeD.height, N = sizeD.width, K = ((atrans)? sizeA.height : sizeA.width);
+
+ std::string kernelName;
+ bool ret = true;
+
+ size_t lx = 8, ly = 4;
+ size_t dx = 4, dy = 8;
+
+ if(!atrans && !btrans)
+ {
+
+ if (M % 32 == 0 && N % 32 == 0 && K % 16 == 0)
+ {
+ kernelName = "intelblas_gemm_buffer_NN_sp";
+ }
+ else
+ {
+ kernelName = "intelblas_gemm_buffer_NN";
+ }
+ }
+ else if(atrans && !btrans)
+ {
+ kernelName = "intelblas_gemm_buffer_TN";
+ }
+ else if(!atrans && btrans)
+ {
+ kernelName = "intelblas_gemm_buffer_NT";
+ ly = 16;
+ dx = 1;
+ }
+ else
+ {
+ kernelName = "intelblas_gemm_buffer_TT";
+ }
+
+ const size_t gx = (size_t)(N + dx - 1) / dx;
+ const size_t gy = (size_t)(M + dy - 1) / dy;
+
+ size_t local[] = {lx, ly, 1};
+ size_t global[] = {(gx + lx - 1) / lx * lx, (gy + ly - 1) / ly * ly, 1};
+
+ int stride = (M * N < 1024 * 1024) ? 10000000 : 256;
+
+ ocl::Queue q;
+ String errmsg;
+ const ocl::Program program = ocl::Context::getDefault().getProg(ocl::core::intel_gemm_oclsrc, "", errmsg);
+
+ if(!atrans && btrans)
+ {
+ ocl::Kernel k(kernelName.c_str(), program);
+ if (k.empty())
+ {
+ return false;
+ }
+
+ k.args(ocl::KernelArg::PtrReadOnly(A),
+ (int) (A.offset / sizeof(float)),
+ ocl::KernelArg::PtrReadOnly(B),
+ (int) (B.offset / sizeof(float)),
+ ocl::KernelArg::PtrWriteOnly(D),
+ (int) (D.offset / sizeof(float)),
+ M, N, K,
+ (float)alpha,
+ (float)beta,
+ (int)(A.step / sizeof(float)),
+ (int)(B.step / sizeof(float)),
+ (int)(D.step / sizeof(float)),
+ (int) 0, // 14 start_index
+ stride);
+
+ ret = k.run(2, global, local, false, q);
+ }
+ else
+ {
+ for(int start_index = 0; start_index < K; start_index += stride)
+ {
+ ocl::Kernel k(kernelName.c_str(), program);
+ k.args(ocl::KernelArg::PtrReadOnly(A),
+ (int) (A.offset / sizeof(float)),
+ ocl::KernelArg::PtrReadOnly(B),
+ (int) (B.offset / sizeof(float)),
+ ocl::KernelArg::PtrWriteOnly(D),
+ (int) (D.offset / sizeof(float)),
+ M, N, K,
+ (float)alpha,
+ (float)beta,
+ (int)(A.step / sizeof(float)),
+ (int)(B.step / sizeof(float)),
+ (int)(D.step / sizeof(float)),
+ (int) start_index, // 14 start_index
+ stride);
+
+ ret = k.run(2, global, local, false, q);
+ if (!ret) return ret;
+ }
+ }
+
+ return ret;
+}
+
+} // namespace cv
+
+#endif
diff --git a/modules/core/src/kmeans.cpp b/modules/core/src/kmeans.cpp
index df017ad..5439933 100644
--- a/modules/core/src/kmeans.cpp
+++ b/modules/core/src/kmeans.cpp
@@ -74,6 +74,7 @@ public:
void operator()( const cv::Range& range ) const
{
+ CV_TRACE_FUNCTION();
const int begin = range.start;
const int end = range.end;
@@ -101,6 +102,7 @@ Arthur & Vassilvitskii (2007) k-means++: The Advantages of Careful Seeding
static void generateCentersPP(const Mat& _data, Mat& _out_centers,
int K, RNG& rng, int trials)
{
+ CV_TRACE_FUNCTION();
int i, j, k, dims = _data.cols, N = _data.rows;
const float* data = _data.ptr<float>(0);
size_t step = _data.step/sizeof(data[0]);
@@ -165,11 +167,13 @@ public:
KMeansDistanceComputer( double *_distances,
int *_labels,
const Mat& _data,
- const Mat& _centers )
+ const Mat& _centers,
+ bool _onlyDistance = false )
: distances(_distances),
labels(_labels),
data(_data),
- centers(_centers)
+ centers(_centers),
+ onlyDistance(_onlyDistance)
{
}
@@ -183,6 +187,12 @@ public:
for( int i = begin; i<end; ++i)
{
const float *sample = data.ptr<float>(i);
+ if (onlyDistance)
+ {
+ const float* center = centers.ptr<float>(labels[i]);
+ distances[i] = normL2Sqr(sample, center, dims);
+ continue;
+ }
int k_best = 0;
double min_dist = DBL_MAX;
@@ -210,6 +220,7 @@ private:
int *labels;
const Mat& data;
const Mat& centers;
+ bool onlyDistance;
};
}
@@ -259,6 +270,7 @@ double cv::kmeans( InputArray _data, int K,
Mat centers(K, dims, type), old_centers(K, dims, type), temp(1, dims, type);
std::vector<int> counters(K);
std::vector<Vec2f> _box(dims);
+ Mat dists(1, N, CV_64F);
Vec2f* box = &_box[0];
double best_compactness = DBL_MAX, compactness = 0;
RNG& rng = theRNG();
@@ -430,19 +442,16 @@ double cv::kmeans( InputArray _data, int K,
}
}
- if( ++iter == MAX(criteria.maxCount, 2) || max_center_shift <= criteria.epsilon )
- break;
+ bool isLastIter = (++iter == MAX(criteria.maxCount, 2) || max_center_shift <= criteria.epsilon);
// assign labels
- Mat dists(1, N, CV_64F);
+ dists = 0;
double* dist = dists.ptr<double>(0);
- parallel_for_(Range(0, N),
- KMeansDistanceComputer(dist, labels, data, centers));
- compactness = 0;
- for( i = 0; i < N; i++ )
- {
- compactness += dist[i];
- }
+ parallel_for_(Range(0, N), KMeansDistanceComputer(dist, labels, data, centers, isLastIter));
+ compactness = sum(dists)[0];
+
+ if (isLastIter)
+ break;
}
if( compactness < best_compactness )
diff --git a/modules/core/src/lapack.cpp b/modules/core/src/lapack.cpp
index a602eec..800eb0e 100644
--- a/modules/core/src/lapack.cpp
+++ b/modules/core/src/lapack.cpp
@@ -262,25 +262,21 @@ template<typename T> struct VBLAS
int givensx(T*, T*, int, T, T, T*, T*) const { return 0; }
};
-#if CV_SSE2
+#if CV_SIMD128
template<> inline int VBLAS<float>::dot(const float* a, const float* b, int n, float* result) const
{
if( n < 8 )
return 0;
int k = 0;
- __m128 s0 = _mm_setzero_ps(), s1 = _mm_setzero_ps();
- for( ; k <= n - 8; k += 8 )
+ v_float32x4 s0 = v_setzero_f32();
+ for( ; k <= n - v_float32x4::nlanes; k += v_float32x4::nlanes )
{
- __m128 a0 = _mm_load_ps(a + k), a1 = _mm_load_ps(a + k + 4);
- __m128 b0 = _mm_load_ps(b + k), b1 = _mm_load_ps(b + k + 4);
+ v_float32x4 a0 = v_load(a + k);
+ v_float32x4 b0 = v_load(b + k);
- s0 = _mm_add_ps(s0, _mm_mul_ps(a0, b0));
- s1 = _mm_add_ps(s1, _mm_mul_ps(a1, b1));
+ s0 += a0 * b0;
}
- s0 = _mm_add_ps(s0, s1);
- float sbuf[4];
- _mm_storeu_ps(sbuf, s0);
- *result = sbuf[0] + sbuf[1] + sbuf[2] + sbuf[3];
+ *result = v_reduce_sum(s0);
return k;
}
@@ -290,15 +286,15 @@ template<> inline int VBLAS<float>::givens(float* a, float* b, int n, float c, f
if( n < 4 )
return 0;
int k = 0;
- __m128 c4 = _mm_set1_ps(c), s4 = _mm_set1_ps(s);
- for( ; k <= n - 4; k += 4 )
+ v_float32x4 c4 = v_setall_f32(c), s4 = v_setall_f32(s);
+ for( ; k <= n - v_float32x4::nlanes; k += v_float32x4::nlanes )
{
- __m128 a0 = _mm_load_ps(a + k);
- __m128 b0 = _mm_load_ps(b + k);
- __m128 t0 = _mm_add_ps(_mm_mul_ps(a0, c4), _mm_mul_ps(b0, s4));
- __m128 t1 = _mm_sub_ps(_mm_mul_ps(b0, c4), _mm_mul_ps(a0, s4));
- _mm_store_ps(a + k, t0);
- _mm_store_ps(b + k, t1);
+ v_float32x4 a0 = v_load(a + k);
+ v_float32x4 b0 = v_load(b + k);
+ v_float32x4 t0 = (a0 * c4) + (b0 * s4);
+ v_float32x4 t1 = (b0 * c4) - (a0 * s4);
+ v_store(a + k, t0);
+ v_store(b + k, t1);
}
return k;
}
@@ -310,45 +306,40 @@ template<> inline int VBLAS<float>::givensx(float* a, float* b, int n, float c,
if( n < 4 )
return 0;
int k = 0;
- __m128 c4 = _mm_set1_ps(c), s4 = _mm_set1_ps(s);
- __m128 sa = _mm_setzero_ps(), sb = _mm_setzero_ps();
- for( ; k <= n - 4; k += 4 )
+ v_float32x4 c4 = v_setall_f32(c), s4 = v_setall_f32(s);
+ v_float32x4 sa = v_setzero_f32(), sb = v_setzero_f32();
+ for( ; k <= n - v_float32x4::nlanes; k += v_float32x4::nlanes )
{
- __m128 a0 = _mm_load_ps(a + k);
- __m128 b0 = _mm_load_ps(b + k);
- __m128 t0 = _mm_add_ps(_mm_mul_ps(a0, c4), _mm_mul_ps(b0, s4));
- __m128 t1 = _mm_sub_ps(_mm_mul_ps(b0, c4), _mm_mul_ps(a0, s4));
- _mm_store_ps(a + k, t0);
- _mm_store_ps(b + k, t1);
- sa = _mm_add_ps(sa, _mm_mul_ps(t0, t0));
- sb = _mm_add_ps(sb, _mm_mul_ps(t1, t1));
+ v_float32x4 a0 = v_load(a + k);
+ v_float32x4 b0 = v_load(b + k);
+ v_float32x4 t0 = (a0 * c4) + (b0 * s4);
+ v_float32x4 t1 = (b0 * c4) - (a0 * s4);
+ v_store(a + k, t0);
+ v_store(b + k, t1);
+ sa += t0 + t0;
+ sb += t1 + t1;
}
- float abuf[4], bbuf[4];
- _mm_storeu_ps(abuf, sa);
- _mm_storeu_ps(bbuf, sb);
- *anorm = abuf[0] + abuf[1] + abuf[2] + abuf[3];
- *bnorm = bbuf[0] + bbuf[1] + bbuf[2] + bbuf[3];
+ *anorm = v_reduce_sum(sa);
+ *bnorm = v_reduce_sum(sb);
return k;
}
-
+#if CV_SIMD128_64F
template<> inline int VBLAS<double>::dot(const double* a, const double* b, int n, double* result) const
{
if( n < 4 )
return 0;
int k = 0;
- __m128d s0 = _mm_setzero_pd(), s1 = _mm_setzero_pd();
- for( ; k <= n - 4; k += 4 )
+ v_float64x2 s0 = v_setzero_f64();
+ for( ; k <= n - v_float64x2::nlanes; k += v_float64x2::nlanes )
{
- __m128d a0 = _mm_load_pd(a + k), a1 = _mm_load_pd(a + k + 2);
- __m128d b0 = _mm_load_pd(b + k), b1 = _mm_load_pd(b + k + 2);
+ v_float64x2 a0 = v_load(a + k);
+ v_float64x2 b0 = v_load(b + k);
- s0 = _mm_add_pd(s0, _mm_mul_pd(a0, b0));
- s1 = _mm_add_pd(s1, _mm_mul_pd(a1, b1));
+ s0 += a0 * b0;
}
- s0 = _mm_add_pd(s0, s1);
double sbuf[2];
- _mm_storeu_pd(sbuf, s0);
+ v_store(sbuf, s0);
*result = sbuf[0] + sbuf[1];
return k;
}
@@ -357,15 +348,15 @@ template<> inline int VBLAS<double>::dot(const double* a, const double* b, int n
template<> inline int VBLAS<double>::givens(double* a, double* b, int n, double c, double s) const
{
int k = 0;
- __m128d c2 = _mm_set1_pd(c), s2 = _mm_set1_pd(s);
- for( ; k <= n - 2; k += 2 )
+ v_float64x2 c2 = v_setall_f64(c), s2 = v_setall_f64(s);
+ for( ; k <= n - v_float64x2::nlanes; k += v_float64x2::nlanes )
{
- __m128d a0 = _mm_load_pd(a + k);
- __m128d b0 = _mm_load_pd(b + k);
- __m128d t0 = _mm_add_pd(_mm_mul_pd(a0, c2), _mm_mul_pd(b0, s2));
- __m128d t1 = _mm_sub_pd(_mm_mul_pd(b0, c2), _mm_mul_pd(a0, s2));
- _mm_store_pd(a + k, t0);
- _mm_store_pd(b + k, t1);
+ v_float64x2 a0 = v_load(a + k);
+ v_float64x2 b0 = v_load(b + k);
+ v_float64x2 t0 = (a0 * c2) + (b0 * s2);
+ v_float64x2 t1 = (b0 * c2) - (a0 * s2);
+ v_store(a + k, t0);
+ v_store(b + k, t1);
}
return k;
}
@@ -375,27 +366,28 @@ template<> inline int VBLAS<double>::givensx(double* a, double* b, int n, double
double* anorm, double* bnorm) const
{
int k = 0;
- __m128d c2 = _mm_set1_pd(c), s2 = _mm_set1_pd(s);
- __m128d sa = _mm_setzero_pd(), sb = _mm_setzero_pd();
- for( ; k <= n - 2; k += 2 )
+ v_float64x2 c2 = v_setall_f64(c), s2 = v_setall_f64(s);
+ v_float64x2 sa = v_setzero_f64(), sb = v_setzero_f64();
+ for( ; k <= n - v_float64x2::nlanes; k += v_float64x2::nlanes )
{
- __m128d a0 = _mm_load_pd(a + k);
- __m128d b0 = _mm_load_pd(b + k);
- __m128d t0 = _mm_add_pd(_mm_mul_pd(a0, c2), _mm_mul_pd(b0, s2));
- __m128d t1 = _mm_sub_pd(_mm_mul_pd(b0, c2), _mm_mul_pd(a0, s2));
- _mm_store_pd(a + k, t0);
- _mm_store_pd(b + k, t1);
- sa = _mm_add_pd(sa, _mm_mul_pd(t0, t0));
- sb = _mm_add_pd(sb, _mm_mul_pd(t1, t1));
+ v_float64x2 a0 = v_load(a + k);
+ v_float64x2 b0 = v_load(b + k);
+ v_float64x2 t0 = (a0 * c2) + (b0 * s2);
+ v_float64x2 t1 = (b0 * c2) - (a0 * s2);
+ v_store(a + k, t0);
+ v_store(b + k, t1);
+ sa += t0 * t0;
+ sb += t1 * t1;
}
double abuf[2], bbuf[2];
- _mm_storeu_pd(abuf, sa);
- _mm_storeu_pd(bbuf, sb);
+ v_store(abuf, sa);
+ v_store(bbuf, sb);
*anorm = abuf[0] + abuf[1];
*bnorm = bbuf[0] + bbuf[1];
return k;
}
-#endif
+#endif //CV_SIMD128_64F
+#endif //CV_SIMD128
template<typename _Tp> void
JacobiSVDImpl_(_Tp* At, size_t astep, _Tp* _W, _Tp* Vt, size_t vstep,
@@ -905,24 +897,24 @@ double cv::invert( InputArray _src, OutputArray _dst, int method )
d = 1./d;
#if CV_SSE2
- if(USE_SSE2)
- {
- __m128 zero = _mm_setzero_ps();
- __m128 t0 = _mm_loadl_pi(zero, (const __m64*)srcdata); //t0 = sf(0,0) sf(0,1)
- __m128 t1 = _mm_loadh_pi(zero, (const __m64*)(srcdata+srcstep)); //t1 = sf(1,0) sf(1,1)
- __m128 s0 = _mm_or_ps(t0, t1);
- __m128 det =_mm_set1_ps((float)d);
- s0 = _mm_mul_ps(s0, det);
- static const uchar CV_DECL_ALIGNED(16) inv[16] = {0,0,0,0,0,0,0,0x80,0,0,0,0x80,0,0,0,0};
- __m128 pattern = _mm_load_ps((const float*)inv);
- s0 = _mm_xor_ps(s0, pattern);//==-1*s0
- s0 = _mm_shuffle_ps(s0, s0, _MM_SHUFFLE(0,2,1,3));
- _mm_storel_pi((__m64*)dstdata, s0);
- _mm_storeh_pi((__m64*)((float*)(dstdata+dststep)), s0);
- }
- else
+ if(USE_SSE2)
+ {
+ __m128 zero = _mm_setzero_ps();
+ __m128 t0 = _mm_loadl_pi(zero, (const __m64*)srcdata); //t0 = sf(0,0) sf(0,1)
+ __m128 t1 = _mm_loadh_pi(zero, (const __m64*)(srcdata+srcstep)); //t1 = sf(1,0) sf(1,1)
+ __m128 s0 = _mm_or_ps(t0, t1);
+ __m128 det =_mm_set1_ps((float)d);
+ s0 = _mm_mul_ps(s0, det);
+ static const uchar CV_DECL_ALIGNED(16) inv[16] = {0,0,0,0,0,0,0,0x80,0,0,0,0x80,0,0,0,0};
+ __m128 pattern = _mm_load_ps((const float*)inv);
+ s0 = _mm_xor_ps(s0, pattern);//==-1*s0
+ s0 = _mm_shuffle_ps(s0, s0, _MM_SHUFFLE(0,2,1,3));
+ _mm_storel_pi((__m64*)dstdata, s0);
+ _mm_storeh_pi((__m64*)((float*)(dstdata+dststep)), s0);
+ }
+ else
#endif
- {
+ {
double t0, t1;
t0 = Sf(0,0)*d;
t1 = Sf(1,1)*d;
@@ -932,7 +924,7 @@ double cv::invert( InputArray _src, OutputArray _dst, int method )
t1 = -Sf(1,0)*d;
Df(0,1) = (float)t0;
Df(1,0) = (float)t1;
- }
+ }
}
}
@@ -944,38 +936,38 @@ double cv::invert( InputArray _src, OutputArray _dst, int method )
result = true;
d = 1./d;
#if CV_SSE2
- if(USE_SSE2)
- {
- __m128d s0 = _mm_loadu_pd((const double*)srcdata); //s0 = sf(0,0) sf(0,1)
- __m128d s1 = _mm_loadu_pd ((const double*)(srcdata+srcstep));//s1 = sf(1,0) sf(1,1)
- __m128d sm = _mm_unpacklo_pd(s0, _mm_load_sd((const double*)(srcdata+srcstep)+1)); //sm = sf(0,0) sf(1,1) - main diagonal
- __m128d ss = _mm_shuffle_pd(s0, s1, _MM_SHUFFLE2(0,1)); //ss = sf(0,1) sf(1,0) - secondary diagonal
- __m128d det = _mm_load1_pd((const double*)&d);
- sm = _mm_mul_pd(sm, det);
-
- static const uchar CV_DECL_ALIGNED(16) inv[8] = {0,0,0,0,0,0,0,0x80};
- __m128d pattern = _mm_load1_pd((double*)inv);
- ss = _mm_mul_pd(ss, det);
- ss = _mm_xor_pd(ss, pattern);//==-1*ss
-
- s0 = _mm_shuffle_pd(sm, ss, _MM_SHUFFLE2(0,1));
- s1 = _mm_shuffle_pd(ss, sm, _MM_SHUFFLE2(0,1));
- _mm_storeu_pd((double*)dstdata, s0);
- _mm_storeu_pd((double*)(dstdata+dststep), s1);
- }
- else
+ if(USE_SSE2)
+ {
+ __m128d s0 = _mm_loadu_pd((const double*)srcdata); //s0 = sf(0,0) sf(0,1)
+ __m128d s1 = _mm_loadu_pd ((const double*)(srcdata+srcstep));//s1 = sf(1,0) sf(1,1)
+ __m128d sm = _mm_unpacklo_pd(s0, _mm_load_sd((const double*)(srcdata+srcstep)+1)); //sm = sf(0,0) sf(1,1) - main diagonal
+ __m128d ss = _mm_shuffle_pd(s0, s1, _MM_SHUFFLE2(0,1)); //ss = sf(0,1) sf(1,0) - secondary diagonal
+ __m128d det = _mm_load1_pd((const double*)&d);
+ sm = _mm_mul_pd(sm, det);
+
+ static const uchar CV_DECL_ALIGNED(16) inv[8] = {0,0,0,0,0,0,0,0x80};
+ __m128d pattern = _mm_load1_pd((double*)inv);
+ ss = _mm_mul_pd(ss, det);
+ ss = _mm_xor_pd(ss, pattern);//==-1*ss
+
+ s0 = _mm_shuffle_pd(sm, ss, _MM_SHUFFLE2(0,1));
+ s1 = _mm_shuffle_pd(ss, sm, _MM_SHUFFLE2(0,1));
+ _mm_storeu_pd((double*)dstdata, s0);
+ _mm_storeu_pd((double*)(dstdata+dststep), s1);
+ }
+ else
#endif
- {
- double t0, t1;
- t0 = Sd(0,0)*d;
- t1 = Sd(1,1)*d;
- Dd(1,1) = t0;
- Dd(0,0) = t1;
- t0 = -Sd(0,1)*d;
- t1 = -Sd(1,0)*d;
- Dd(0,1) = t0;
- Dd(1,0) = t1;
- }
+ {
+ double t0, t1;
+ t0 = Sd(0,0)*d;
+ t1 = Sd(1,1)*d;
+ Dd(1,1) = t0;
+ Dd(0,0) = t1;
+ t0 = -Sd(0,1)*d;
+ t1 = -Sd(1,0)*d;
+ Dd(0,1) = t0;
+ Dd(1,0) = t1;
+ }
}
}
}
diff --git a/modules/core/src/lda.cpp b/modules/core/src/lda.cpp
index 4ccbf8a..20f0604 100644
--- a/modules/core/src/lda.cpp
+++ b/modules/core/src/lda.cpp
@@ -53,7 +53,8 @@ static Mat argsort(InputArray _src, bool ascending=true)
static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double beta=0) {
// make sure the input data is a vector of matrices or vector of vector
- if(src.kind() != _InputArray::STD_VECTOR_MAT && src.kind() != _InputArray::STD_VECTOR_VECTOR) {
+ if(src.kind() != _InputArray::STD_VECTOR_MAT && src.kind() != _InputArray::STD_ARRAY_MAT &&
+ src.kind() != _InputArray::STD_VECTOR_VECTOR) {
String error_message = "The data is expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >).";
CV_Error(Error::StsBadArg, error_message);
}
@@ -882,7 +883,7 @@ private:
public:
EigenvalueDecomposition()
- : n(0) { }
+ : n(0), cdivr(0), cdivi(0), d(0), e(0), ort(0), V(0), H(0) {}
// Initializes & computes the Eigenvalue Decomposition for a general matrix
// given in src. This function is a port of the EigenvalueSolver in JAMA,
@@ -1096,6 +1097,7 @@ void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) {
void LDA::compute(InputArrayOfArrays _src, InputArray _lbls) {
switch(_src.kind()) {
case _InputArray::STD_VECTOR_MAT:
+ case _InputArray::STD_ARRAY_MAT:
lda(asRowMatrix(_src, CV_64FC1), _lbls);
break;
case _InputArray::MAT:
diff --git a/modules/core/src/lpsolver.cpp b/modules/core/src/lpsolver.cpp
index 6c53108..e5f4d99 100644
--- a/modules/core/src/lpsolver.cpp
+++ b/modules/core/src/lpsolver.cpp
@@ -41,7 +41,6 @@
#include "precomp.hpp"
#include <climits>
#include <algorithm>
-#include <cstdarg>
#define dprintf(x)
#define print_matrix(x)
diff --git a/modules/core/src/mathfuncs.cpp b/modules/core/src/mathfuncs.cpp
index b9bdf49..a3dfbd1 100644
--- a/modules/core/src/mathfuncs.cpp
+++ b/modules/core/src/mathfuncs.cpp
@@ -497,6 +497,65 @@ static bool ocl_polarToCart( InputArray _mag, InputArray _angle,
#endif
+#ifdef HAVE_IPP
+static bool ipp_polarToCart(Mat &mag, Mat &angle, Mat &x, Mat &y)
+{
+ CV_INSTRUMENT_REGION_IPP()
+
+ int depth = angle.depth();
+ if(depth != CV_32F && depth != CV_64F)
+ return false;
+
+ if(angle.dims <= 2)
+ {
+ int len = (int)(angle.cols*angle.channels());
+
+ if(depth == CV_32F)
+ {
+ for (int h = 0; h < angle.rows; h++)
+ {
+ if(CV_INSTRUMENT_FUN_IPP(ippsPolarToCart_32f, (const float*)mag.ptr(h), (const float*)angle.ptr(h), (float*)x.ptr(h), (float*)y.ptr(h), len) < 0)
+ return false;
+ }
+ }
+ else
+ {
+ for (int h = 0; h < angle.rows; h++)
+ {
+ if(CV_INSTRUMENT_FUN_IPP(ippsPolarToCart_64f, (const double*)mag.ptr(h), (const double*)angle.ptr(h), (double*)x.ptr(h), (double*)y.ptr(h), len) < 0)
+ return false;
+ }
+ }
+ return true;
+ }
+ else
+ {
+ const Mat *arrays[] = {&mag, &angle, &x, &y, NULL};
+ uchar *ptrs[4] = {NULL};
+ NAryMatIterator it(arrays, ptrs);
+ int len = (int)(it.size*angle.channels());
+
+ if(depth == CV_32F)
+ {
+ for (size_t i = 0; i < it.nplanes; i++, ++it)
+ {
+ if(CV_INSTRUMENT_FUN_IPP(ippsPolarToCart_32f, (const float*)ptrs[0], (const float*)ptrs[1], (float*)ptrs[2], (float*)ptrs[3], len) < 0)
+ return false;
+ }
+ }
+ else
+ {
+ for (size_t i = 0; i < it.nplanes; i++, ++it)
+ {
+ if(CV_INSTRUMENT_FUN_IPP(ippsPolarToCart_64f, (const double*)ptrs[0], (const double*)ptrs[1], (double*)ptrs[2], (double*)ptrs[3], len) < 0)
+ return false;
+ }
+ }
+ return true;
+ }
+}
+#endif
+
void polarToCart( InputArray src1, InputArray src2,
OutputArray dst1, OutputArray dst2, bool angleInDegrees )
{
@@ -514,28 +573,7 @@ void polarToCart( InputArray src1, InputArray src2,
dst2.create( Angle.dims, Angle.size, type );
Mat X = dst1.getMat(), Y = dst2.getMat();
-#if defined(HAVE_IPP)
- CV_IPP_CHECK()
- {
- if (Mag.isContinuous() && Angle.isContinuous() && X.isContinuous() && Y.isContinuous() && !angleInDegrees)
- {
- typedef IppStatus (CV_STDCALL * IppsPolarToCart)(const void * pSrcMagn, const void * pSrcPhase,
- void * pDstRe, void * pDstIm, int len);
- IppsPolarToCart ippsPolarToCart =
- depth == CV_32F ? (IppsPolarToCart)ippsPolarToCart_32f :
- depth == CV_64F ? (IppsPolarToCart)ippsPolarToCart_64f : 0;
- CV_Assert(ippsPolarToCart != 0);
-
- IppStatus status = CV_INSTRUMENT_FUN_IPP(ippsPolarToCart, Mag.ptr(), Angle.ptr(), X.ptr(), Y.ptr(), static_cast<int>(cn * X.total()));
- if (status >= 0)
- {
- CV_IMPL_ADD(CV_IMPL_IPP);
- return;
- }
- setIppErrorStatus();
- }
- }
-#endif
+ CV_IPP_RUN(!angleInDegrees, ipp_polarToCart(Mag, Angle, X, Y));
const Mat* arrays[] = {&Mag, &Angle, &X, &Y, 0};
uchar* ptrs[4];
@@ -1167,11 +1205,6 @@ static bool ocl_pow(InputArray _src, double power, OutputArray _dst,
#endif
-static void InvSqrt_32f(const float* src, float* dst, int n) { hal::invSqrt32f(src, dst, n); }
-static void InvSqrt_64f(const double* src, double* dst, int n) { hal::invSqrt64f(src, dst, n); }
-static void Sqrt_32f(const float* src, float* dst, int n) { hal::sqrt32f(src, dst, n); }
-static void Sqrt_64f(const double* src, double* dst, int n) { hal::sqrt64f(src, dst, n); }
-
void pow( InputArray _src, double power, OutputArray _dst )
{
CV_INSTRUMENT_REGION()
@@ -1228,8 +1261,8 @@ void pow( InputArray _src, double power, OutputArray _dst )
else if( fabs(fabs(power) - 0.5) < DBL_EPSILON )
{
MathFunc func = power < 0 ?
- (depth == CV_32F ? (MathFunc)InvSqrt_32f : (MathFunc)InvSqrt_64f) :
- (depth == CV_32F ? (MathFunc)Sqrt_32f : (MathFunc)Sqrt_64f);
+ (depth == CV_32F ? (MathFunc)hal::invSqrt32f : (MathFunc)hal::invSqrt64f) :
+ (depth == CV_32F ? (MathFunc)hal::sqrt32f : (MathFunc)hal::sqrt64f);
for( size_t i = 0; i < it.nplanes; i++, ++it )
func( ptrs[0], ptrs[1], len );
@@ -1261,24 +1294,6 @@ void pow( InputArray _src, double power, OutputArray _dst )
{
int bsz = std::min(len - j, blockSize);
-#if defined(HAVE_IPP)
- CV_IPP_CHECK()
- {
- IppStatus status = depth == CV_32F ?
- CV_INSTRUMENT_FUN_IPP(ippsPowx_32f_A21, (const float*)ptrs[0], (float)power, (float*)ptrs[1], bsz) :
- CV_INSTRUMENT_FUN_IPP(ippsPowx_64f_A50, (const double*)ptrs[0], (double)power, (double*)ptrs[1], bsz);
-
- if (status >= 0)
- {
- CV_IMPL_ADD(CV_IMPL_IPP);
- ptrs[0] += bsz*esz1;
- ptrs[1] += bsz*esz1;
- continue;
- }
- setIppErrorStatus();
- }
-#endif
-
if( depth == CV_32F )
{
float* x0 = (float*)ptrs[0];
diff --git a/modules/core/src/mathfuncs_core.cpp b/modules/core/src/mathfuncs_core.cpp
deleted file mode 100644
index e0cc5b5..0000000
--- a/modules/core/src/mathfuncs_core.cpp
+++ /dev/null
@@ -1,1587 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-using namespace std;
-
-namespace {
-
-static const float atan2_p1 = 0.9997878412794807f*(float)(180/CV_PI);
-static const float atan2_p3 = -0.3258083974640975f*(float)(180/CV_PI);
-static const float atan2_p5 = 0.1555786518463281f*(float)(180/CV_PI);
-static const float atan2_p7 = -0.04432655554792128f*(float)(180/CV_PI);
-
-using namespace cv;
-
-#if CV_SIMD128
-
-template <typename T>
-struct v_atan
-{
- typedef V_RegTrait128<T> Trait;
- typedef typename Trait::reg VT; // vector type
- enum { WorkWidth = VT::nlanes * 2 };
-
- v_atan(const T & scale)
- : s(Trait::all(scale))
- {
- eps = Trait::all(DBL_EPSILON);
- z = Trait::zero();
- p7 = Trait::all(atan2_p7);
- p5 = Trait::all(atan2_p5);
- p3 = Trait::all(atan2_p3);
- p1 = Trait::all(atan2_p1);
- val90 = Trait::all(90.f);
- val180 = Trait::all(180.f);
- val360 = Trait::all(360.f);
- }
-
- inline int operator()(int len, const T * Y, const T * X, T * angle)
- {
- int i = 0;
- const int c = VT::nlanes;
- for ( ; i <= len - c * 2; i += c * 2)
- {
- VT x1 = v_load(X + i);
- VT x2 = v_load(X + i + c);
- VT y1 = v_load(Y + i);
- VT y2 = v_load(Y + i + c);
- v_store(&angle[i], s * one(x1, y1));
- v_store(&angle[i + c], s * one(x2, y2));
- }
- return i;
- }
-
-private:
- inline VT one(VT & x, VT & y)
- {
- VT ax = v_abs(x);
- VT ay = v_abs(y);
- VT c = v_min(ax, ay) / (v_max(ax, ay) + eps);
- VT cc = c * c;
- VT a = (((p7 * cc + p5) * cc + p3) * cc + p1) * c;
- a = v_select(ax >= ay, a, val90 - a);
- a = v_select(x < z, val180 - a, a);
- a = v_select(y < z, val360 - a, a);
- return a;
- }
-
-private:
- VT eps;
- VT z;
- VT p7;
- VT p5;
- VT p3;
- VT p1;
- VT val90;
- VT val180;
- VT val360;
- VT s;
-};
-
-#if !CV_SIMD128_64F
-
-// emulation
-template <>
-struct v_atan<double>
-{
- v_atan(double scale) : impl(static_cast<float>(scale)) {}
- inline int operator()(int len, const double * Y, const double * X, double * angle)
- {
- int i = 0;
- const int c = v_atan<float>::WorkWidth;
- float bufY[c];
- float bufX[c];
- float bufA[c];
- for ( ; i <= len - c ; i += c)
- {
- for (int j = 0; j < c; ++j)
- {
- bufY[j] = static_cast<float>(Y[i + j]);
- bufX[j] = static_cast<float>(X[i + j]);
- }
- impl(c, bufY, bufX, bufA);
- for (int j = 0; j < c; ++j)
- {
- angle[i + j] = bufA[j];
- }
- }
- return i;
- }
-private:
- v_atan<float> impl;
-};
-#endif
-
-#endif
-
-template <typename T>
-static inline T atanImpl(T y, T x)
-{
- T ax = std::abs(x), ay = std::abs(y);
- T a, c, c2;
- if( ax >= ay )
- {
- c = ay/(ax + static_cast<T>(DBL_EPSILON));
- c2 = c*c;
- a = (((atan2_p7*c2 + atan2_p5)*c2 + atan2_p3)*c2 + atan2_p1)*c;
- }
- else
- {
- c = ax/(ay + static_cast<T>(DBL_EPSILON));
- c2 = c*c;
- a = 90.f - (((atan2_p7*c2 + atan2_p5)*c2 + atan2_p3)*c2 + atan2_p1)*c;
- }
- if( x < 0 )
- a = 180.f - a;
- if( y < 0 )
- a = 360.f - a;
- return a;
-}
-
-template <typename T>
-static inline void atanImpl(const T *Y, const T *X, T *angle, int len, bool angleInDegrees)
-{
- int i = 0;
- T scale = angleInDegrees ? 1 : static_cast<T>(CV_PI/180);
-
-#if CV_SIMD128
- i = v_atan<T>(scale)(len, Y, X, angle);
-#endif
-
- for( ; i < len; i++ )
- {
- angle[i] = atanImpl<T>(Y[i], X[i]) * scale;
- }
-}
-
-} // anonymous::
-
-namespace cv { namespace hal {
-
-///////////////////////////////////// ATAN2 ////////////////////////////////////
-
-void fastAtan32f(const float *Y, const float *X, float *angle, int len, bool angleInDegrees )
-{
- CV_INSTRUMENT_REGION()
-
- CALL_HAL(fastAtan32f, cv_hal_fastAtan32f, Y, X, angle, len, angleInDegrees);
- atanImpl<float>(Y, X, angle, len, angleInDegrees);
-}
-
-void fastAtan64f(const double *Y, const double *X, double *angle, int len, bool angleInDegrees)
-{
- CV_INSTRUMENT_REGION()
-
- CALL_HAL(fastAtan64f, cv_hal_fastAtan64f, Y, X, angle, len, angleInDegrees);
- atanImpl<double>(Y, X, angle, len, angleInDegrees);
-}
-
-// deprecated
-void fastAtan2(const float *Y, const float *X, float *angle, int len, bool angleInDegrees )
-{
- CV_INSTRUMENT_REGION()
-
- fastAtan32f(Y, X, angle, len, angleInDegrees);
-}
-
-void magnitude32f(const float* x, const float* y, float* mag, int len)
-{
- CV_INSTRUMENT_REGION()
-
- CALL_HAL(magnitude32f, cv_hal_magnitude32f, x, y, mag, len);
- CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsMagnitude_32f, x, y, mag, len) >= 0);
-
- int i = 0;
-
-#if CV_SIMD128
- for( ; i <= len - 8; i += 8 )
- {
- v_float32x4 x0 = v_load(x + i), x1 = v_load(x + i + 4);
- v_float32x4 y0 = v_load(y + i), y1 = v_load(y + i + 4);
- x0 = v_sqrt(v_muladd(x0, x0, y0*y0));
- x1 = v_sqrt(v_muladd(x1, x1, y1*y1));
- v_store(mag + i, x0);
- v_store(mag + i + 4, x1);
- }
-#endif
-
- for( ; i < len; i++ )
- {
- float x0 = x[i], y0 = y[i];
- mag[i] = std::sqrt(x0*x0 + y0*y0);
- }
-}
-
-void magnitude64f(const double* x, const double* y, double* mag, int len)
-{
- CV_INSTRUMENT_REGION()
-
- CALL_HAL(magnitude64f, cv_hal_magnitude64f, x, y, mag, len);
- CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsMagnitude_64f, x, y, mag, len) >= 0);
-
- int i = 0;
-
-#if CV_SIMD128_64F
- for( ; i <= len - 4; i += 4 )
- {
- v_float64x2 x0 = v_load(x + i), x1 = v_load(x + i + 2);
- v_float64x2 y0 = v_load(y + i), y1 = v_load(y + i + 2);
- x0 = v_sqrt(v_muladd(x0, x0, y0*y0));
- x1 = v_sqrt(v_muladd(x1, x1, y1*y1));
- v_store(mag + i, x0);
- v_store(mag + i + 2, x1);
- }
-#endif
-
- for( ; i < len; i++ )
- {
- double x0 = x[i], y0 = y[i];
- mag[i] = std::sqrt(x0*x0 + y0*y0);
- }
-}
-
-
-void invSqrt32f(const float* src, float* dst, int len)
-{
- CV_INSTRUMENT_REGION()
-
- CALL_HAL(invSqrt32f, cv_hal_invSqrt32f, src, dst, len);
- CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsInvSqrt_32f_A21, src, dst, len) >= 0);
-
- int i = 0;
-
-#if CV_SIMD128
- for( ; i <= len - 8; i += 8 )
- {
- v_float32x4 t0 = v_load(src + i), t1 = v_load(src + i + 4);
- t0 = v_invsqrt(t0);
- t1 = v_invsqrt(t1);
- v_store(dst + i, t0); v_store(dst + i + 4, t1);
- }
-#endif
-
- for( ; i < len; i++ )
- dst[i] = 1/std::sqrt(src[i]);
-}
-
-
-void invSqrt64f(const double* src, double* dst, int len)
-{
- CV_INSTRUMENT_REGION()
-
- CALL_HAL(invSqrt64f, cv_hal_invSqrt64f, src, dst, len);
- CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsInvSqrt_64f_A50, src, dst, len) >= 0);
-
- int i = 0;
-
-#if CV_SSE2
- __m128d v_1 = _mm_set1_pd(1.0);
- for ( ; i <= len - 2; i += 2)
- _mm_storeu_pd(dst + i, _mm_div_pd(v_1, _mm_sqrt_pd(_mm_loadu_pd(src + i))));
-#endif
-
- for( ; i < len; i++ )
- dst[i] = 1/std::sqrt(src[i]);
-}
-
-
-void sqrt32f(const float* src, float* dst, int len)
-{
- CV_INSTRUMENT_REGION()
-
- CALL_HAL(sqrt32f, cv_hal_sqrt32f, src, dst, len);
- CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsSqrt_32f_A21, src, dst, len) >= 0);
-
- int i = 0;
-
-#if CV_SIMD128
- for( ; i <= len - 8; i += 8 )
- {
- v_float32x4 t0 = v_load(src + i), t1 = v_load(src + i + 4);
- t0 = v_sqrt(t0);
- t1 = v_sqrt(t1);
- v_store(dst + i, t0); v_store(dst + i + 4, t1);
- }
-#endif
-
- for( ; i < len; i++ )
- dst[i] = std::sqrt(src[i]);
-}
-
-
-void sqrt64f(const double* src, double* dst, int len)
-{
- CV_INSTRUMENT_REGION()
-
- CALL_HAL(sqrt64f, cv_hal_sqrt64f, src, dst, len);
- CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsSqrt_64f_A50, src, dst, len) >= 0);
-
- int i = 0;
-
-#if CV_SIMD128_64F
- for( ; i <= len - 4; i += 4 )
- {
- v_float64x2 t0 = v_load(src + i), t1 = v_load(src + i + 2);
- t0 = v_sqrt(t0);
- t1 = v_sqrt(t1);
- v_store(dst + i, t0); v_store(dst + i + 2, t1);
- }
-#endif
-
- for( ; i < len; i++ )
- dst[i] = std::sqrt(src[i]);
-}
-
-// Workaround for ICE in MSVS 2015 update 3 (issue #7795)
-// CV_AVX is not used here, because generated code is faster in non-AVX mode.
-// (tested with disabled IPP on i5-6300U)
-#if (defined _MSC_VER && _MSC_VER >= 1900)
-void exp32f(const float *src, float *dst, int n)
-{
- CV_INSTRUMENT_REGION()
-
- CALL_HAL(exp32f, cv_hal_exp32f, src, dst, n);
- CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsExp_32f_A21, src, dst, n) >= 0);
-
- for (int i = 0; i < n; i++)
- {
- dst[i] = std::exp(src[i]);
- }
-}
-
-void exp64f(const double *src, double *dst, int n)
-{
- CV_INSTRUMENT_REGION()
-
- CALL_HAL(exp64f, cv_hal_exp64f, src, dst, n);
- CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsExp_64f_A50, src, dst, n) >= 0);
-
- for (int i = 0; i < n; i++)
- {
- dst[i] = std::exp(src[i]);
- }
-}
-
-void log32f(const float *src, float *dst, int n)
-{
- CV_INSTRUMENT_REGION()
-
- CALL_HAL(log32f, cv_hal_log32f, src, dst, n);
- CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsLn_32f_A21, src, dst, n) >= 0);
-
- for (int i = 0; i < n; i++)
- {
- dst[i] = std::log(src[i]);
- }
-}
-void log64f(const double *src, double *dst, int n)
-{
- CV_INSTRUMENT_REGION()
-
- CALL_HAL(log64f, cv_hal_log64f, src, dst, n);
- CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsLn_64f_A50, src, dst, n) >= 0);
-
- for (int i = 0; i < n; i++)
- {
- dst[i] = std::log(src[i]);
- }
-}
-#else
-
-////////////////////////////////////// EXP /////////////////////////////////////
-
-typedef union
-{
- struct {
-#if ( defined( WORDS_BIGENDIAN ) && !defined( OPENCV_UNIVERSAL_BUILD ) ) || defined( __BIG_ENDIAN__ )
- int hi;
- int lo;
-#else
- int lo;
- int hi;
-#endif
- } i;
- double d;
-}
-DBLINT;
-
-#define EXPTAB_SCALE 6
-#define EXPTAB_MASK ((1 << EXPTAB_SCALE) - 1)
-
-#define EXPPOLY_32F_A0 .9670371139572337719125840413672004409288e-2
-
-static const double expTab[] = {
- 1.0 * EXPPOLY_32F_A0,
- 1.0108892860517004600204097905619 * EXPPOLY_32F_A0,
- 1.0218971486541166782344801347833 * EXPPOLY_32F_A0,
- 1.0330248790212284225001082839705 * EXPPOLY_32F_A0,
- 1.0442737824274138403219664787399 * EXPPOLY_32F_A0,
- 1.0556451783605571588083413251529 * EXPPOLY_32F_A0,
- 1.0671404006768236181695211209928 * EXPPOLY_32F_A0,
- 1.0787607977571197937406800374385 * EXPPOLY_32F_A0,
- 1.0905077326652576592070106557607 * EXPPOLY_32F_A0,
- 1.1023825833078409435564142094256 * EXPPOLY_32F_A0,
- 1.1143867425958925363088129569196 * EXPPOLY_32F_A0,
- 1.126521618608241899794798643787 * EXPPOLY_32F_A0,
- 1.1387886347566916537038302838415 * EXPPOLY_32F_A0,
- 1.151189229952982705817759635202 * EXPPOLY_32F_A0,
- 1.1637248587775775138135735990922 * EXPPOLY_32F_A0,
- 1.1763969916502812762846457284838 * EXPPOLY_32F_A0,
- 1.1892071150027210667174999705605 * EXPPOLY_32F_A0,
- 1.2021567314527031420963969574978 * EXPPOLY_32F_A0,
- 1.2152473599804688781165202513388 * EXPPOLY_32F_A0,
- 1.2284805361068700056940089577928 * EXPPOLY_32F_A0,
- 1.2418578120734840485936774687266 * EXPPOLY_32F_A0,
- 1.2553807570246910895793906574423 * EXPPOLY_32F_A0,
- 1.2690509571917332225544190810323 * EXPPOLY_32F_A0,
- 1.2828700160787782807266697810215 * EXPPOLY_32F_A0,
- 1.2968395546510096659337541177925 * EXPPOLY_32F_A0,
- 1.3109612115247643419229917863308 * EXPPOLY_32F_A0,
- 1.3252366431597412946295370954987 * EXPPOLY_32F_A0,
- 1.3396675240533030053600306697244 * EXPPOLY_32F_A0,
- 1.3542555469368927282980147401407 * EXPPOLY_32F_A0,
- 1.3690024229745906119296011329822 * EXPPOLY_32F_A0,
- 1.3839098819638319548726595272652 * EXPPOLY_32F_A0,
- 1.3989796725383111402095281367152 * EXPPOLY_32F_A0,
- 1.4142135623730950488016887242097 * EXPPOLY_32F_A0,
- 1.4296133383919700112350657782751 * EXPPOLY_32F_A0,
- 1.4451808069770466200370062414717 * EXPPOLY_32F_A0,
- 1.4609177941806469886513028903106 * EXPPOLY_32F_A0,
- 1.476826145939499311386907480374 * EXPPOLY_32F_A0,
- 1.4929077282912648492006435314867 * EXPPOLY_32F_A0,
- 1.5091644275934227397660195510332 * EXPPOLY_32F_A0,
- 1.5255981507445383068512536895169 * EXPPOLY_32F_A0,
- 1.5422108254079408236122918620907 * EXPPOLY_32F_A0,
- 1.5590044002378369670337280894749 * EXPPOLY_32F_A0,
- 1.5759808451078864864552701601819 * EXPPOLY_32F_A0,
- 1.5931421513422668979372486431191 * EXPPOLY_32F_A0,
- 1.6104903319492543081795206673574 * EXPPOLY_32F_A0,
- 1.628027421857347766848218522014 * EXPPOLY_32F_A0,
- 1.6457554781539648445187567247258 * EXPPOLY_32F_A0,
- 1.6636765803267364350463364569764 * EXPPOLY_32F_A0,
- 1.6817928305074290860622509524664 * EXPPOLY_32F_A0,
- 1.7001063537185234695013625734975 * EXPPOLY_32F_A0,
- 1.7186192981224779156293443764563 * EXPPOLY_32F_A0,
- 1.7373338352737062489942020818722 * EXPPOLY_32F_A0,
- 1.7562521603732994831121606193753 * EXPPOLY_32F_A0,
- 1.7753764925265212525505592001993 * EXPPOLY_32F_A0,
- 1.7947090750031071864277032421278 * EXPPOLY_32F_A0,
- 1.8142521755003987562498346003623 * EXPPOLY_32F_A0,
- 1.8340080864093424634870831895883 * EXPPOLY_32F_A0,
- 1.8539791250833855683924530703377 * EXPPOLY_32F_A0,
- 1.8741676341102999013299989499544 * EXPPOLY_32F_A0,
- 1.8945759815869656413402186534269 * EXPPOLY_32F_A0,
- 1.9152065613971472938726112702958 * EXPPOLY_32F_A0,
- 1.9360617934922944505980559045667 * EXPPOLY_32F_A0,
- 1.9571441241754002690183222516269 * EXPPOLY_32F_A0,
- 1.9784560263879509682582499181312 * EXPPOLY_32F_A0,
-};
-
-
-// the code below uses _mm_cast* intrinsics, which are not avialable on VS2005
-#if (defined _MSC_VER && _MSC_VER < 1500) || \
-(!defined __APPLE__ && defined __GNUC__ && __GNUC__*100 + __GNUC_MINOR__ < 402)
-#undef CV_SSE2
-#define CV_SSE2 0
-#endif
-
-static const double exp_prescale = 1.4426950408889634073599246810019 * (1 << EXPTAB_SCALE);
-static const double exp_postscale = 1./(1 << EXPTAB_SCALE);
-static const double exp_max_val = 3000.*(1 << EXPTAB_SCALE); // log10(DBL_MAX) < 3000
-
-void exp32f( const float *_x, float *y, int n )
-{
- CV_INSTRUMENT_REGION()
-
- CALL_HAL(exp32f, cv_hal_exp32f, _x, y, n);
- CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsExp_32f_A21, _x, y, n) >= 0);
-
- static const float
- A4 = (float)(1.000000000000002438532970795181890933776 / EXPPOLY_32F_A0),
- A3 = (float)(.6931471805521448196800669615864773144641 / EXPPOLY_32F_A0),
- A2 = (float)(.2402265109513301490103372422686535526573 / EXPPOLY_32F_A0),
- A1 = (float)(.5550339366753125211915322047004666939128e-1 / EXPPOLY_32F_A0);
-
-#undef EXPPOLY
-#define EXPPOLY(x) \
-(((((x) + A1)*(x) + A2)*(x) + A3)*(x) + A4)
-
- int i = 0;
- const Cv32suf* x = (const Cv32suf*)_x;
- Cv32suf buf[4];
-
-#if CV_SSE2
- if( n >= 8 )
- {
- static const __m128d prescale2 = _mm_set1_pd(exp_prescale);
- static const __m128 postscale4 = _mm_set1_ps((float)exp_postscale);
- static const __m128 maxval4 = _mm_set1_ps((float)(exp_max_val/exp_prescale));
- static const __m128 minval4 = _mm_set1_ps((float)(-exp_max_val/exp_prescale));
-
- static const __m128 mA1 = _mm_set1_ps(A1);
- static const __m128 mA2 = _mm_set1_ps(A2);
- static const __m128 mA3 = _mm_set1_ps(A3);
- static const __m128 mA4 = _mm_set1_ps(A4);
- bool y_aligned = (size_t)(void*)y % 16 == 0;
-
- ushort CV_DECL_ALIGNED(16) tab_idx[8];
-
- for( ; i <= n - 8; i += 8 )
- {
- __m128 xf0, xf1;
- xf0 = _mm_loadu_ps(&x[i].f);
- xf1 = _mm_loadu_ps(&x[i+4].f);
- __m128i xi0, xi1, xi2, xi3;
-
- xf0 = _mm_min_ps(_mm_max_ps(xf0, minval4), maxval4);
- xf1 = _mm_min_ps(_mm_max_ps(xf1, minval4), maxval4);
-
- __m128d xd0 = _mm_cvtps_pd(xf0);
- __m128d xd2 = _mm_cvtps_pd(_mm_movehl_ps(xf0, xf0));
- __m128d xd1 = _mm_cvtps_pd(xf1);
- __m128d xd3 = _mm_cvtps_pd(_mm_movehl_ps(xf1, xf1));
-
- xd0 = _mm_mul_pd(xd0, prescale2);
- xd2 = _mm_mul_pd(xd2, prescale2);
- xd1 = _mm_mul_pd(xd1, prescale2);
- xd3 = _mm_mul_pd(xd3, prescale2);
-
- xi0 = _mm_cvtpd_epi32(xd0);
- xi2 = _mm_cvtpd_epi32(xd2);
-
- xi1 = _mm_cvtpd_epi32(xd1);
- xi3 = _mm_cvtpd_epi32(xd3);
-
- xd0 = _mm_sub_pd(xd0, _mm_cvtepi32_pd(xi0));
- xd2 = _mm_sub_pd(xd2, _mm_cvtepi32_pd(xi2));
- xd1 = _mm_sub_pd(xd1, _mm_cvtepi32_pd(xi1));
- xd3 = _mm_sub_pd(xd3, _mm_cvtepi32_pd(xi3));
-
- xf0 = _mm_movelh_ps(_mm_cvtpd_ps(xd0), _mm_cvtpd_ps(xd2));
- xf1 = _mm_movelh_ps(_mm_cvtpd_ps(xd1), _mm_cvtpd_ps(xd3));
-
- xf0 = _mm_mul_ps(xf0, postscale4);
- xf1 = _mm_mul_ps(xf1, postscale4);
-
- xi0 = _mm_unpacklo_epi64(xi0, xi2);
- xi1 = _mm_unpacklo_epi64(xi1, xi3);
- xi0 = _mm_packs_epi32(xi0, xi1);
-
- _mm_store_si128((__m128i*)tab_idx, _mm_and_si128(xi0, _mm_set1_epi16(EXPTAB_MASK)));
-
- xi0 = _mm_add_epi16(_mm_srai_epi16(xi0, EXPTAB_SCALE), _mm_set1_epi16(127));
- xi0 = _mm_max_epi16(xi0, _mm_setzero_si128());
- xi0 = _mm_min_epi16(xi0, _mm_set1_epi16(255));
- xi1 = _mm_unpackhi_epi16(xi0, _mm_setzero_si128());
- xi0 = _mm_unpacklo_epi16(xi0, _mm_setzero_si128());
-
- __m128d yd0 = _mm_unpacklo_pd(_mm_load_sd(expTab + tab_idx[0]), _mm_load_sd(expTab + tab_idx[1]));
- __m128d yd1 = _mm_unpacklo_pd(_mm_load_sd(expTab + tab_idx[2]), _mm_load_sd(expTab + tab_idx[3]));
- __m128d yd2 = _mm_unpacklo_pd(_mm_load_sd(expTab + tab_idx[4]), _mm_load_sd(expTab + tab_idx[5]));
- __m128d yd3 = _mm_unpacklo_pd(_mm_load_sd(expTab + tab_idx[6]), _mm_load_sd(expTab + tab_idx[7]));
-
- __m128 yf0 = _mm_movelh_ps(_mm_cvtpd_ps(yd0), _mm_cvtpd_ps(yd1));
- __m128 yf1 = _mm_movelh_ps(_mm_cvtpd_ps(yd2), _mm_cvtpd_ps(yd3));
-
- yf0 = _mm_mul_ps(yf0, _mm_castsi128_ps(_mm_slli_epi32(xi0, 23)));
- yf1 = _mm_mul_ps(yf1, _mm_castsi128_ps(_mm_slli_epi32(xi1, 23)));
-
- __m128 zf0 = _mm_add_ps(xf0, mA1);
- __m128 zf1 = _mm_add_ps(xf1, mA1);
-
- zf0 = _mm_add_ps(_mm_mul_ps(zf0, xf0), mA2);
- zf1 = _mm_add_ps(_mm_mul_ps(zf1, xf1), mA2);
-
- zf0 = _mm_add_ps(_mm_mul_ps(zf0, xf0), mA3);
- zf1 = _mm_add_ps(_mm_mul_ps(zf1, xf1), mA3);
-
- zf0 = _mm_add_ps(_mm_mul_ps(zf0, xf0), mA4);
- zf1 = _mm_add_ps(_mm_mul_ps(zf1, xf1), mA4);
-
- zf0 = _mm_mul_ps(zf0, yf0);
- zf1 = _mm_mul_ps(zf1, yf1);
-
- if( y_aligned )
- {
- _mm_store_ps(y + i, zf0);
- _mm_store_ps(y + i + 4, zf1);
- }
- else
- {
- _mm_storeu_ps(y + i, zf0);
- _mm_storeu_ps(y + i + 4, zf1);
- }
- }
- }
- else
-#endif
- for( ; i <= n - 4; i += 4 )
- {
- double x0 = x[i].f * exp_prescale;
- double x1 = x[i + 1].f * exp_prescale;
- double x2 = x[i + 2].f * exp_prescale;
- double x3 = x[i + 3].f * exp_prescale;
- int val0, val1, val2, val3, t;
-
- if( ((x[i].i >> 23) & 255) > 127 + 10 )
- x0 = x[i].i < 0 ? -exp_max_val : exp_max_val;
-
- if( ((x[i+1].i >> 23) & 255) > 127 + 10 )
- x1 = x[i+1].i < 0 ? -exp_max_val : exp_max_val;
-
- if( ((x[i+2].i >> 23) & 255) > 127 + 10 )
- x2 = x[i+2].i < 0 ? -exp_max_val : exp_max_val;
-
- if( ((x[i+3].i >> 23) & 255) > 127 + 10 )
- x3 = x[i+3].i < 0 ? -exp_max_val : exp_max_val;
-
- val0 = cvRound(x0);
- val1 = cvRound(x1);
- val2 = cvRound(x2);
- val3 = cvRound(x3);
-
- x0 = (x0 - val0)*exp_postscale;
- x1 = (x1 - val1)*exp_postscale;
- x2 = (x2 - val2)*exp_postscale;
- x3 = (x3 - val3)*exp_postscale;
-
- t = (val0 >> EXPTAB_SCALE) + 127;
- t = !(t & ~255) ? t : t < 0 ? 0 : 255;
- buf[0].i = t << 23;
-
- t = (val1 >> EXPTAB_SCALE) + 127;
- t = !(t & ~255) ? t : t < 0 ? 0 : 255;
- buf[1].i = t << 23;
-
- t = (val2 >> EXPTAB_SCALE) + 127;
- t = !(t & ~255) ? t : t < 0 ? 0 : 255;
- buf[2].i = t << 23;
-
- t = (val3 >> EXPTAB_SCALE) + 127;
- t = !(t & ~255) ? t : t < 0 ? 0 : 255;
- buf[3].i = t << 23;
-
- x0 = buf[0].f * expTab[val0 & EXPTAB_MASK] * EXPPOLY( x0 );
- x1 = buf[1].f * expTab[val1 & EXPTAB_MASK] * EXPPOLY( x1 );
-
- y[i] = (float)x0;
- y[i + 1] = (float)x1;
-
- x2 = buf[2].f * expTab[val2 & EXPTAB_MASK] * EXPPOLY( x2 );
- x3 = buf[3].f * expTab[val3 & EXPTAB_MASK] * EXPPOLY( x3 );
-
- y[i + 2] = (float)x2;
- y[i + 3] = (float)x3;
- }
-
- for( ; i < n; i++ )
- {
- double x0 = x[i].f * exp_prescale;
- int val0, t;
-
- if( ((x[i].i >> 23) & 255) > 127 + 10 )
- x0 = x[i].i < 0 ? -exp_max_val : exp_max_val;
-
- val0 = cvRound(x0);
- t = (val0 >> EXPTAB_SCALE) + 127;
- t = !(t & ~255) ? t : t < 0 ? 0 : 255;
-
- buf[0].i = t << 23;
- x0 = (x0 - val0)*exp_postscale;
-
- y[i] = (float)(buf[0].f * expTab[val0 & EXPTAB_MASK] * EXPPOLY(x0));
- }
-}
-
-void exp64f( const double *_x, double *y, int n )
-{
- CV_INSTRUMENT_REGION()
-
- CALL_HAL(exp64f, cv_hal_exp64f, _x, y, n);
- CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsExp_64f_A50, _x, y, n) >= 0);
-
- static const double
- A5 = .99999999999999999998285227504999 / EXPPOLY_32F_A0,
- A4 = .69314718055994546743029643825322 / EXPPOLY_32F_A0,
- A3 = .24022650695886477918181338054308 / EXPPOLY_32F_A0,
- A2 = .55504108793649567998466049042729e-1 / EXPPOLY_32F_A0,
- A1 = .96180973140732918010002372686186e-2 / EXPPOLY_32F_A0,
- A0 = .13369713757180123244806654839424e-2 / EXPPOLY_32F_A0;
-
-#undef EXPPOLY
-#define EXPPOLY(x) (((((A0*(x) + A1)*(x) + A2)*(x) + A3)*(x) + A4)*(x) + A5)
-
- int i = 0;
- Cv64suf buf[4];
- const Cv64suf* x = (const Cv64suf*)_x;
-
-#if CV_SSE2
- static const __m128d prescale2 = _mm_set1_pd(exp_prescale);
- static const __m128d postscale2 = _mm_set1_pd(exp_postscale);
- static const __m128d maxval2 = _mm_set1_pd(exp_max_val);
- static const __m128d minval2 = _mm_set1_pd(-exp_max_val);
-
- static const __m128d mA0 = _mm_set1_pd(A0);
- static const __m128d mA1 = _mm_set1_pd(A1);
- static const __m128d mA2 = _mm_set1_pd(A2);
- static const __m128d mA3 = _mm_set1_pd(A3);
- static const __m128d mA4 = _mm_set1_pd(A4);
- static const __m128d mA5 = _mm_set1_pd(A5);
-
- int CV_DECL_ALIGNED(16) tab_idx[4];
-
- for( ; i <= n - 4; i += 4 )
- {
- __m128d xf0 = _mm_loadu_pd(&x[i].f), xf1 = _mm_loadu_pd(&x[i+2].f);
- __m128i xi0, xi1;
- xf0 = _mm_min_pd(_mm_max_pd(xf0, minval2), maxval2);
- xf1 = _mm_min_pd(_mm_max_pd(xf1, minval2), maxval2);
- xf0 = _mm_mul_pd(xf0, prescale2);
- xf1 = _mm_mul_pd(xf1, prescale2);
-
- xi0 = _mm_cvtpd_epi32(xf0);
- xi1 = _mm_cvtpd_epi32(xf1);
- xf0 = _mm_mul_pd(_mm_sub_pd(xf0, _mm_cvtepi32_pd(xi0)), postscale2);
- xf1 = _mm_mul_pd(_mm_sub_pd(xf1, _mm_cvtepi32_pd(xi1)), postscale2);
-
- xi0 = _mm_unpacklo_epi64(xi0, xi1);
- _mm_store_si128((__m128i*)tab_idx, _mm_and_si128(xi0, _mm_set1_epi32(EXPTAB_MASK)));
-
- xi0 = _mm_add_epi32(_mm_srai_epi32(xi0, EXPTAB_SCALE), _mm_set1_epi32(1023));
- xi0 = _mm_packs_epi32(xi0, xi0);
- xi0 = _mm_max_epi16(xi0, _mm_setzero_si128());
- xi0 = _mm_min_epi16(xi0, _mm_set1_epi16(2047));
- xi0 = _mm_unpacklo_epi16(xi0, _mm_setzero_si128());
- xi1 = _mm_unpackhi_epi32(xi0, _mm_setzero_si128());
- xi0 = _mm_unpacklo_epi32(xi0, _mm_setzero_si128());
-
- __m128d yf0 = _mm_unpacklo_pd(_mm_load_sd(expTab + tab_idx[0]), _mm_load_sd(expTab + tab_idx[1]));
- __m128d yf1 = _mm_unpacklo_pd(_mm_load_sd(expTab + tab_idx[2]), _mm_load_sd(expTab + tab_idx[3]));
- yf0 = _mm_mul_pd(yf0, _mm_castsi128_pd(_mm_slli_epi64(xi0, 52)));
- yf1 = _mm_mul_pd(yf1, _mm_castsi128_pd(_mm_slli_epi64(xi1, 52)));
-
- __m128d zf0 = _mm_add_pd(_mm_mul_pd(mA0, xf0), mA1);
- __m128d zf1 = _mm_add_pd(_mm_mul_pd(mA0, xf1), mA1);
-
- zf0 = _mm_add_pd(_mm_mul_pd(zf0, xf0), mA2);
- zf1 = _mm_add_pd(_mm_mul_pd(zf1, xf1), mA2);
-
- zf0 = _mm_add_pd(_mm_mul_pd(zf0, xf0), mA3);
- zf1 = _mm_add_pd(_mm_mul_pd(zf1, xf1), mA3);
-
- zf0 = _mm_add_pd(_mm_mul_pd(zf0, xf0), mA4);
- zf1 = _mm_add_pd(_mm_mul_pd(zf1, xf1), mA4);
-
- zf0 = _mm_add_pd(_mm_mul_pd(zf0, xf0), mA5);
- zf1 = _mm_add_pd(_mm_mul_pd(zf1, xf1), mA5);
-
- zf0 = _mm_mul_pd(zf0, yf0);
- zf1 = _mm_mul_pd(zf1, yf1);
-
- _mm_storeu_pd(y + i, zf0);
- _mm_storeu_pd(y + i + 2, zf1);
- }
-#endif
- for( ; i <= n - 4; i += 4 )
- {
- double x0 = x[i].f * exp_prescale;
- double x1 = x[i + 1].f * exp_prescale;
- double x2 = x[i + 2].f * exp_prescale;
- double x3 = x[i + 3].f * exp_prescale;
-
- double y0, y1, y2, y3;
- int val0, val1, val2, val3, t;
-
- t = (int)(x[i].i >> 52);
- if( (t & 2047) > 1023 + 10 )
- x0 = t < 0 ? -exp_max_val : exp_max_val;
-
- t = (int)(x[i+1].i >> 52);
- if( (t & 2047) > 1023 + 10 )
- x1 = t < 0 ? -exp_max_val : exp_max_val;
-
- t = (int)(x[i+2].i >> 52);
- if( (t & 2047) > 1023 + 10 )
- x2 = t < 0 ? -exp_max_val : exp_max_val;
-
- t = (int)(x[i+3].i >> 52);
- if( (t & 2047) > 1023 + 10 )
- x3 = t < 0 ? -exp_max_val : exp_max_val;
-
- val0 = cvRound(x0);
- val1 = cvRound(x1);
- val2 = cvRound(x2);
- val3 = cvRound(x3);
-
- x0 = (x0 - val0)*exp_postscale;
- x1 = (x1 - val1)*exp_postscale;
- x2 = (x2 - val2)*exp_postscale;
- x3 = (x3 - val3)*exp_postscale;
-
- t = (val0 >> EXPTAB_SCALE) + 1023;
- t = !(t & ~2047) ? t : t < 0 ? 0 : 2047;
- buf[0].i = (int64)t << 52;
-
- t = (val1 >> EXPTAB_SCALE) + 1023;
- t = !(t & ~2047) ? t : t < 0 ? 0 : 2047;
- buf[1].i = (int64)t << 52;
-
- t = (val2 >> EXPTAB_SCALE) + 1023;
- t = !(t & ~2047) ? t : t < 0 ? 0 : 2047;
- buf[2].i = (int64)t << 52;
-
- t = (val3 >> EXPTAB_SCALE) + 1023;
- t = !(t & ~2047) ? t : t < 0 ? 0 : 2047;
- buf[3].i = (int64)t << 52;
-
- y0 = buf[0].f * expTab[val0 & EXPTAB_MASK] * EXPPOLY( x0 );
- y1 = buf[1].f * expTab[val1 & EXPTAB_MASK] * EXPPOLY( x1 );
-
- y[i] = y0;
- y[i + 1] = y1;
-
- y2 = buf[2].f * expTab[val2 & EXPTAB_MASK] * EXPPOLY( x2 );
- y3 = buf[3].f * expTab[val3 & EXPTAB_MASK] * EXPPOLY( x3 );
-
- y[i + 2] = y2;
- y[i + 3] = y3;
- }
-
- for( ; i < n; i++ )
- {
- double x0 = x[i].f * exp_prescale;
- int val0, t;
-
- t = (int)(x[i].i >> 52);
- if( (t & 2047) > 1023 + 10 )
- x0 = t < 0 ? -exp_max_val : exp_max_val;
-
- val0 = cvRound(x0);
- t = (val0 >> EXPTAB_SCALE) + 1023;
- t = !(t & ~2047) ? t : t < 0 ? 0 : 2047;
-
- buf[0].i = (int64)t << 52;
- x0 = (x0 - val0)*exp_postscale;
-
- y[i] = buf[0].f * expTab[val0 & EXPTAB_MASK] * EXPPOLY( x0 );
- }
-}
-
-#undef EXPTAB_SCALE
-#undef EXPTAB_MASK
-#undef EXPPOLY_32F_A0
-
-/////////////////////////////////////////// LOG ///////////////////////////////////////
-
-#define LOGTAB_SCALE 8
-#define LOGTAB_MASK ((1 << LOGTAB_SCALE) - 1)
-#define LOGTAB_MASK2 ((1 << (20 - LOGTAB_SCALE)) - 1)
-#define LOGTAB_MASK2_32F ((1 << (23 - LOGTAB_SCALE)) - 1)
-
-static const double CV_DECL_ALIGNED(16) icvLogTab[] = {
- 0.0000000000000000000000000000000000000000, 1.000000000000000000000000000000000000000,
- .00389864041565732288852075271279318258166, .9961089494163424124513618677042801556420,
- .00778214044205494809292034119607706088573, .9922480620155038759689922480620155038760,
- .01165061721997527263705585198749759001657, .9884169884169884169884169884169884169884,
- .01550418653596525274396267235488267033361, .9846153846153846153846153846153846153846,
- .01934296284313093139406447562578250654042, .9808429118773946360153256704980842911877,
- .02316705928153437593630670221500622574241, .9770992366412213740458015267175572519084,
- .02697658769820207233514075539915211265906, .9733840304182509505703422053231939163498,
- .03077165866675368732785500469617545604706, .9696969696969696969696969696969696969697,
- .03455238150665972812758397481047722976656, .9660377358490566037735849056603773584906,
- .03831886430213659461285757856785494368522, .9624060150375939849624060150375939849624,
- .04207121392068705056921373852674150839447, .9588014981273408239700374531835205992509,
- .04580953603129420126371940114040626212953, .9552238805970149253731343283582089552239,
- .04953393512227662748292900118940451648088, .9516728624535315985130111524163568773234,
- .05324451451881227759255210685296333394944, .9481481481481481481481481481481481481481,
- .05694137640013842427411105973078520037234, .9446494464944649446494464944649446494465,
- .06062462181643483993820353816772694699466, .9411764705882352941176470588235294117647,
- .06429435070539725460836422143984236754475, .9377289377289377289377289377289377289377,
- .06795066190850773679699159401934593915938, .9343065693430656934306569343065693430657,
- .07159365318700880442825962290953611955044, .9309090909090909090909090909090909090909,
- .07522342123758751775142172846244648098944, .9275362318840579710144927536231884057971,
- .07884006170777602129362549021607264876369, .9241877256317689530685920577617328519856,
- .08244366921107458556772229485432035289706, .9208633093525179856115107913669064748201,
- .08603433734180314373940490213499288074675, .9175627240143369175627240143369175627240,
- .08961215868968712416897659522874164395031, .9142857142857142857142857142857142857143,
- .09317722485418328259854092721070628613231, .9110320284697508896797153024911032028470,
- .09672962645855109897752299730200320482256, .9078014184397163120567375886524822695035,
- .10026945316367513738597949668474029749630, .9045936395759717314487632508833922261484,
- .10379679368164355934833764649738441221420, .9014084507042253521126760563380281690141,
- .10731173578908805021914218968959175981580, .8982456140350877192982456140350877192982,
- .11081436634029011301105782649756292812530, .8951048951048951048951048951048951048951,
- .11430477128005862852422325204315711744130, .8919860627177700348432055749128919860627,
- .11778303565638344185817487641543266363440, .8888888888888888888888888888888888888889,
- .12124924363286967987640707633545389398930, .8858131487889273356401384083044982698962,
- .12470347850095722663787967121606925502420, .8827586206896551724137931034482758620690,
- .12814582269193003360996385708858724683530, .8797250859106529209621993127147766323024,
- .13157635778871926146571524895989568904040, .8767123287671232876712328767123287671233,
- .13499516453750481925766280255629681050780, .8737201365187713310580204778156996587031,
- .13840232285911913123754857224412262439730, .8707482993197278911564625850340136054422,
- .14179791186025733629172407290752744302150, .8677966101694915254237288135593220338983,
- .14518200984449788903951628071808954700830, .8648648648648648648648648648648648648649,
- .14855469432313711530824207329715136438610, .8619528619528619528619528619528619528620,
- .15191604202584196858794030049466527998450, .8590604026845637583892617449664429530201,
- .15526612891112392955683674244937719777230, .8561872909698996655518394648829431438127,
- .15860503017663857283636730244325008243330, .8533333333333333333333333333333333333333,
- .16193282026931324346641360989451641216880, .8504983388704318936877076411960132890365,
- .16524957289530714521497145597095368430010, .8476821192052980132450331125827814569536,
- .16855536102980664403538924034364754334090, .8448844884488448844884488448844884488449,
- .17185025692665920060697715143760433420540, .8421052631578947368421052631578947368421,
- .17513433212784912385018287750426679849630, .8393442622950819672131147540983606557377,
- .17840765747281828179637841458315961062910, .8366013071895424836601307189542483660131,
- .18167030310763465639212199675966985523700, .8338762214983713355048859934853420195440,
- .18492233849401198964024217730184318497780, .8311688311688311688311688311688311688312,
- .18816383241818296356839823602058459073300, .8284789644012944983818770226537216828479,
- .19139485299962943898322009772527962923050, .8258064516129032258064516129032258064516,
- .19461546769967164038916962454095482826240, .8231511254019292604501607717041800643087,
- .19782574332991986754137769821682013571260, .8205128205128205128205128205128205128205,
- .20102574606059073203390141770796617493040, .8178913738019169329073482428115015974441,
- .20421554142869088876999228432396193966280, .8152866242038216560509554140127388535032,
- .20739519434607056602715147164417430758480, .8126984126984126984126984126984126984127,
- .21056476910734961416338251183333341032260, .8101265822784810126582278481012658227848,
- .21372432939771812687723695489694364368910, .8075709779179810725552050473186119873817,
- .21687393830061435506806333251006435602900, .8050314465408805031446540880503144654088,
- .22001365830528207823135744547471404075630, .8025078369905956112852664576802507836991,
- .22314355131420973710199007200571941211830, .8000000000000000000000000000000000000000,
- .22626367865045338145790765338460914790630, .7975077881619937694704049844236760124611,
- .22937410106484582006380890106811420992010, .7950310559006211180124223602484472049689,
- .23247487874309405442296849741978803649550, .7925696594427244582043343653250773993808,
- .23556607131276688371634975283086532726890, .7901234567901234567901234567901234567901,
- .23864773785017498464178231643018079921600, .7876923076923076923076923076923076923077,
- .24171993688714515924331749374687206000090, .7852760736196319018404907975460122699387,
- .24478272641769091566565919038112042471760, .7828746177370030581039755351681957186544,
- .24783616390458124145723672882013488560910, .7804878048780487804878048780487804878049,
- .25088030628580937353433455427875742316250, .7781155015197568389057750759878419452888,
- .25391520998096339667426946107298135757450, .7757575757575757575757575757575757575758,
- .25694093089750041913887912414793390780680, .7734138972809667673716012084592145015106,
- .25995752443692604627401010475296061486000, .7710843373493975903614457831325301204819,
- .26296504550088134477547896494797896593800, .7687687687687687687687687687687687687688,
- .26596354849713793599974565040611196309330, .7664670658682634730538922155688622754491,
- .26895308734550393836570947314612567424780, .7641791044776119402985074626865671641791,
- .27193371548364175804834985683555714786050, .7619047619047619047619047619047619047619,
- .27490548587279922676529508862586226314300, .7596439169139465875370919881305637982196,
- .27786845100345625159121709657483734190480, .7573964497041420118343195266272189349112,
- .28082266290088775395616949026589281857030, .7551622418879056047197640117994100294985,
- .28376817313064456316240580235898960381750, .7529411764705882352941176470588235294118,
- .28670503280395426282112225635501090437180, .7507331378299120234604105571847507331378,
- .28963329258304265634293983566749375313530, .7485380116959064327485380116959064327485,
- .29255300268637740579436012922087684273730, .7463556851311953352769679300291545189504,
- .29546421289383584252163927885703742504130, .7441860465116279069767441860465116279070,
- .29836697255179722709783618483925238251680, .7420289855072463768115942028985507246377,
- .30126133057816173455023545102449133992200, .7398843930635838150289017341040462427746,
- .30414733546729666446850615102448500692850, .7377521613832853025936599423631123919308,
- .30702503529491181888388950937951449304830, .7356321839080459770114942528735632183908,
- .30989447772286465854207904158101882785550, .7335243553008595988538681948424068767908,
- .31275571000389684739317885942000430077330, .7314285714285714285714285714285714285714,
- .31560877898630329552176476681779604405180, .7293447293447293447293447293447293447293,
- .31845373111853458869546784626436419785030, .7272727272727272727272727272727272727273,
- .32129061245373424782201254856772720813750, .7252124645892351274787535410764872521246,
- .32411946865421192853773391107097268104550, .7231638418079096045197740112994350282486,
- .32694034499585328257253991068864706903700, .7211267605633802816901408450704225352113,
- .32975328637246797969240219572384376078850, .7191011235955056179775280898876404494382,
- .33255833730007655635318997155991382896900, .7170868347338935574229691876750700280112,
- .33535554192113781191153520921943709254280, .7150837988826815642458100558659217877095,
- .33814494400871636381467055798566434532400, .7130919220055710306406685236768802228412,
- .34092658697059319283795275623560883104800, .7111111111111111111111111111111111111111,
- .34370051385331840121395430287520866841080, .7091412742382271468144044321329639889197,
- .34646676734620857063262633346312213689100, .7071823204419889502762430939226519337017,
- .34922538978528827602332285096053965389730, .7052341597796143250688705234159779614325,
- .35197642315717814209818925519357435405250, .7032967032967032967032967032967032967033,
- .35471990910292899856770532096561510115850, .7013698630136986301369863013698630136986,
- .35745588892180374385176833129662554711100, .6994535519125683060109289617486338797814,
- .36018440357500774995358483465679455548530, .6975476839237057220708446866485013623978,
- .36290549368936841911903457003063522279280, .6956521739130434782608695652173913043478,
- .36561919956096466943762379742111079394830, .6937669376693766937669376693766937669377,
- .36832556115870762614150635272380895912650, .6918918918918918918918918918918918918919,
- .37102461812787262962487488948681857436900, .6900269541778975741239892183288409703504,
- .37371640979358405898480555151763837784530, .6881720430107526881720430107526881720430,
- .37640097516425302659470730759494472295050, .6863270777479892761394101876675603217158,
- .37907835293496944251145919224654790014030, .6844919786096256684491978609625668449198,
- .38174858149084833769393299007788300514230, .6826666666666666666666666666666666666667,
- .38441169891033200034513583887019194662580, .6808510638297872340425531914893617021277,
- .38706774296844825844488013899535872042180, .6790450928381962864721485411140583554377,
- .38971675114002518602873692543653305619950, .6772486772486772486772486772486772486772,
- .39235876060286384303665840889152605086580, .6754617414248021108179419525065963060686,
- .39499380824086893770896722344332374632350, .6736842105263157894736842105263157894737,
- .39762193064713846624158577469643205404280, .6719160104986876640419947506561679790026,
- .40024316412701266276741307592601515352730, .6701570680628272251308900523560209424084,
- .40285754470108348090917615991202183067800, .6684073107049608355091383812010443864230,
- .40546510810816432934799991016916465014230, .6666666666666666666666666666666666666667,
- .40806588980822172674223224930756259709600, .6649350649350649350649350649350649350649,
- .41065992498526837639616360320360399782650, .6632124352331606217616580310880829015544,
- .41324724855021932601317757871584035456180, .6614987080103359173126614987080103359173,
- .41582789514371093497757669865677598863850, .6597938144329896907216494845360824742268,
- .41840189913888381489925905043492093682300, .6580976863753213367609254498714652956298,
- .42096929464412963239894338585145305842150, .6564102564102564102564102564102564102564,
- .42353011550580327293502591601281892508280, .6547314578005115089514066496163682864450,
- .42608439531090003260516141381231136620050, .6530612244897959183673469387755102040816,
- .42863216738969872610098832410585600882780, .6513994910941475826972010178117048346056,
- .43117346481837132143866142541810404509300, .6497461928934010152284263959390862944162,
- .43370832042155937902094819946796633303180, .6481012658227848101265822784810126582278,
- .43623676677491801667585491486534010618930, .6464646464646464646464646464646464646465,
- .43875883620762790027214350629947148263450, .6448362720403022670025188916876574307305,
- .44127456080487520440058801796112675219780, .6432160804020100502512562814070351758794,
- .44378397241030093089975139264424797147500, .6416040100250626566416040100250626566416,
- .44628710262841947420398014401143882423650, .6400000000000000000000000000000000000000,
- .44878398282700665555822183705458883196130, .6384039900249376558603491271820448877805,
- .45127464413945855836729492693848442286250, .6368159203980099502487562189054726368159,
- .45375911746712049854579618113348260521900, .6352357320099255583126550868486352357320,
- .45623743348158757315857769754074979573500, .6336633663366336633663366336633663366337,
- .45870962262697662081833982483658473938700, .6320987654320987654320987654320987654321,
- .46117571512217014895185229761409573256980, .6305418719211822660098522167487684729064,
- .46363574096303250549055974261136725544930, .6289926289926289926289926289926289926290,
- .46608972992459918316399125615134835243230, .6274509803921568627450980392156862745098,
- .46853771156323925639597405279346276074650, .6259168704156479217603911980440097799511,
- .47097971521879100631480241645476780831830, .6243902439024390243902439024390243902439,
- .47341577001667212165614273544633761048330, .6228710462287104622871046228710462287105,
- .47584590486996386493601107758877333253630, .6213592233009708737864077669902912621359,
- .47827014848147025860569669930555392056700, .6198547215496368038740920096852300242131,
- .48068852934575190261057286988943815231330, .6183574879227053140096618357487922705314,
- .48310107575113581113157579238759353756900, .6168674698795180722891566265060240963855,
- .48550781578170076890899053978500887751580, .6153846153846153846153846153846153846154,
- .48790877731923892879351001283794175833480, .6139088729016786570743405275779376498801,
- .49030398804519381705802061333088204264650, .6124401913875598086124401913875598086124,
- .49269347544257524607047571407747454941280, .6109785202863961813842482100238663484487,
- .49507726679785146739476431321236304938800, .6095238095238095238095238095238095238095,
- .49745538920281889838648226032091770321130, .6080760095011876484560570071258907363420,
- .49982786955644931126130359189119189977650, .6066350710900473933649289099526066350711,
- .50219473456671548383667413872899487614650, .6052009456264775413711583924349881796690,
- .50455601075239520092452494282042607665050, .6037735849056603773584905660377358490566,
- .50691172444485432801997148999362252652650, .6023529411764705882352941176470588235294,
- .50926190178980790257412536448100581765150, .6009389671361502347417840375586854460094,
- .51160656874906207391973111953120678663250, .5995316159250585480093676814988290398126,
- .51394575110223428282552049495279788970950, .5981308411214953271028037383177570093458,
- .51627947444845445623684554448118433356300, .5967365967365967365967365967365967365967,
- .51860776420804555186805373523384332656850, .5953488372093023255813953488372093023256,
- .52093064562418522900344441950437612831600, .5939675174013921113689095127610208816705,
- .52324814376454775732838697877014055848100, .5925925925925925925925925925925925925926,
- .52556028352292727401362526507000438869000, .5912240184757505773672055427251732101617,
- .52786708962084227803046587723656557500350, .5898617511520737327188940092165898617512,
- .53016858660912158374145519701414741575700, .5885057471264367816091954022988505747126,
- .53246479886947173376654518506256863474850, .5871559633027522935779816513761467889908,
- .53475575061602764748158733709715306758900, .5858123569794050343249427917620137299771,
- .53704146589688361856929077475797384977350, .5844748858447488584474885844748858447489,
- .53932196859560876944783558428753167390800, .5831435079726651480637813211845102505695,
- .54159728243274429804188230264117009937750, .5818181818181818181818181818181818181818,
- .54386743096728351609669971367111429572100, .5804988662131519274376417233560090702948,
- .54613243759813556721383065450936555862450, .5791855203619909502262443438914027149321,
- .54839232556557315767520321969641372561450, .5778781038374717832957110609480812641084,
- .55064711795266219063194057525834068655950, .5765765765765765765765765765765765765766,
- .55289683768667763352766542084282264113450, .5752808988764044943820224719101123595506,
- .55514150754050151093110798683483153581600, .5739910313901345291479820627802690582960,
- .55738115013400635344709144192165695130850, .5727069351230425055928411633109619686801,
- .55961578793542265941596269840374588966350, .5714285714285714285714285714285714285714,
- .56184544326269181269140062795486301183700, .5701559020044543429844097995545657015590,
- .56407013828480290218436721261241473257550, .5688888888888888888888888888888888888889,
- .56628989502311577464155334382667206227800, .5676274944567627494456762749445676274945,
- .56850473535266865532378233183408156037350, .5663716814159292035398230088495575221239,
- .57071468100347144680739575051120482385150, .5651214128035320088300220750551876379691,
- .57291975356178548306473885531886480748650, .5638766519823788546255506607929515418502,
- .57511997447138785144460371157038025558000, .5626373626373626373626373626373626373626,
- .57731536503482350219940144597785547375700, .5614035087719298245614035087719298245614,
- .57950594641464214795689713355386629700650, .5601750547045951859956236323851203501094,
- .58169173963462239562716149521293118596100, .5589519650655021834061135371179039301310,
- .58387276558098266665552955601015128195300, .5577342047930283224400871459694989106754,
- .58604904500357812846544902640744112432000, .5565217391304347826086956521739130434783,
- .58822059851708596855957011939608491957200, .5553145336225596529284164859002169197397,
- .59038744660217634674381770309992134571100, .5541125541125541125541125541125541125541,
- .59254960960667157898740242671919986605650, .5529157667386609071274298056155507559395,
- .59470710774669277576265358220553025603300, .5517241379310344827586206896551724137931,
- .59685996110779382384237123915227130055450, .5505376344086021505376344086021505376344,
- .59900818964608337768851242799428291618800, .5493562231759656652360515021459227467811,
- .60115181318933474940990890900138765573500, .5481798715203426124197002141327623126338,
- .60329085143808425240052883964381180703650, .5470085470085470085470085470085470085470,
- .60542532396671688843525771517306566238400, .5458422174840085287846481876332622601279,
- .60755525022454170969155029524699784815300, .5446808510638297872340425531914893617021,
- .60968064953685519036241657886421307921400, .5435244161358811040339702760084925690021,
- .61180154110599282990534675263916142284850, .5423728813559322033898305084745762711864,
- .61391794401237043121710712512140162289150, .5412262156448202959830866807610993657505,
- .61602987721551394351138242200249806046500, .5400843881856540084388185654008438818565,
- .61813735955507864705538167982012964785100, .5389473684210526315789473684210526315789,
- .62024040975185745772080281312810257077200, .5378151260504201680672268907563025210084,
- .62233904640877868441606324267922900617100, .5366876310272536687631027253668763102725,
- .62443328801189346144440150965237990021700, .5355648535564853556485355648535564853556,
- .62652315293135274476554741340805776417250, .5344467640918580375782881002087682672234,
- .62860865942237409420556559780379757285100, .5333333333333333333333333333333333333333,
- .63068982562619868570408243613201193511500, .5322245322245322245322245322245322245322,
- .63276666957103777644277897707070223987100, .5311203319502074688796680497925311203320,
- .63483920917301017716738442686619237065300, .5300207039337474120082815734989648033126,
- .63690746223706917739093569252872839570050, .5289256198347107438016528925619834710744,
- .63897144645792069983514238629140891134750, .5278350515463917525773195876288659793814,
- .64103117942093124081992527862894348800200, .5267489711934156378600823045267489711934,
- .64308667860302726193566513757104985415950, .5256673511293634496919917864476386036961,
- .64513796137358470073053240412264131009600, .5245901639344262295081967213114754098361,
- .64718504499530948859131740391603671014300, .5235173824130879345603271983640081799591,
- .64922794662510974195157587018911726772800, .5224489795918367346938775510204081632653,
- .65126668331495807251485530287027359008800, .5213849287169042769857433808553971486762,
- .65330127201274557080523663898929953575150, .5203252032520325203252032520325203252033,
- .65533172956312757406749369692988693714150, .5192697768762677484787018255578093306288,
- .65735807270835999727154330685152672231200, .5182186234817813765182186234817813765182,
- .65938031808912778153342060249997302889800, .5171717171717171717171717171717171717172,
- .66139848224536490484126716182800009846700, .5161290322580645161290322580645161290323,
- .66341258161706617713093692145776003599150, .5150905432595573440643863179074446680080,
- .66542263254509037562201001492212526500250, .5140562248995983935742971887550200803213,
- .66742865127195616370414654738851822912700, .5130260521042084168336673346693386773547,
- .66943065394262923906154583164607174694550, .5120000000000000000000000000000000000000,
- .67142865660530226534774556057527661323550, .5109780439121756487025948103792415169661,
- .67342267521216669923234121597488410770900, .5099601593625498007968127490039840637450,
- .67541272562017662384192817626171745359900, .5089463220675944333996023856858846918489,
- .67739882359180603188519853574689477682100, .5079365079365079365079365079365079365079,
- .67938098479579733801614338517538271844400, .5069306930693069306930693069306930693069,
- .68135922480790300781450241629499942064300, .5059288537549407114624505928853754940711,
- .68333355911162063645036823800182901322850, .5049309664694280078895463510848126232742,
- .68530400309891936760919861626462079584600, .5039370078740157480314960629921259842520,
- .68727057207096020619019327568821609020250, .5029469548133595284872298624754420432220,
- .68923328123880889251040571252815425395950, .5019607843137254901960784313725490196078,
- .69314718055994530941723212145818, 5.0e-01,
-};
-
-
-
-#define LOGTAB_TRANSLATE(x,h) (((x) - 1.)*icvLogTab[(h)+1])
-static const double ln_2 = 0.69314718055994530941723212145818;
-
-void log32f( const float *_x, float *y, int n )
-{
- CV_INSTRUMENT_REGION()
-
- CALL_HAL(log32f, cv_hal_log32f, _x, y, n);
- CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsLn_32f_A21, _x, y, n) >= 0);
-
- static const float shift[] = { 0, -1.f/512 };
- static const float
- A0 = 0.3333333333333333333333333f,
- A1 = -0.5f,
- A2 = 1.f;
-
-#undef LOGPOLY
-#define LOGPOLY(x) (((A0*(x) + A1)*(x) + A2)*(x))
-
- int i = 0;
- Cv32suf buf[4];
- const int* x = (const int*)_x;
-
-#if CV_SSE2
- static const __m128d ln2_2 = _mm_set1_pd(ln_2);
- static const __m128 _1_4 = _mm_set1_ps(1.f);
- static const __m128 shift4 = _mm_set1_ps(-1.f/512);
-
- static const __m128 mA0 = _mm_set1_ps(A0);
- static const __m128 mA1 = _mm_set1_ps(A1);
- static const __m128 mA2 = _mm_set1_ps(A2);
-
- int CV_DECL_ALIGNED(16) idx[4];
-
- for( ; i <= n - 4; i += 4 )
- {
- __m128i h0 = _mm_loadu_si128((const __m128i*)(x + i));
- __m128i yi0 = _mm_sub_epi32(_mm_and_si128(_mm_srli_epi32(h0, 23), _mm_set1_epi32(255)), _mm_set1_epi32(127));
- __m128d yd0 = _mm_mul_pd(_mm_cvtepi32_pd(yi0), ln2_2);
- __m128d yd1 = _mm_mul_pd(_mm_cvtepi32_pd(_mm_unpackhi_epi64(yi0,yi0)), ln2_2);
-
- __m128i xi0 = _mm_or_si128(_mm_and_si128(h0, _mm_set1_epi32(LOGTAB_MASK2_32F)), _mm_set1_epi32(127 << 23));
-
- h0 = _mm_and_si128(_mm_srli_epi32(h0, 23 - LOGTAB_SCALE - 1), _mm_set1_epi32(LOGTAB_MASK*2));
- _mm_store_si128((__m128i*)idx, h0);
- h0 = _mm_cmpeq_epi32(h0, _mm_set1_epi32(510));
-
- __m128d t0, t1, t2, t3, t4;
- t0 = _mm_load_pd(icvLogTab + idx[0]);
- t2 = _mm_load_pd(icvLogTab + idx[1]);
- t1 = _mm_unpackhi_pd(t0, t2);
- t0 = _mm_unpacklo_pd(t0, t2);
- t2 = _mm_load_pd(icvLogTab + idx[2]);
- t4 = _mm_load_pd(icvLogTab + idx[3]);
- t3 = _mm_unpackhi_pd(t2, t4);
- t2 = _mm_unpacklo_pd(t2, t4);
-
- yd0 = _mm_add_pd(yd0, t0);
- yd1 = _mm_add_pd(yd1, t2);
-
- __m128 yf0 = _mm_movelh_ps(_mm_cvtpd_ps(yd0), _mm_cvtpd_ps(yd1));
-
- __m128 xf0 = _mm_sub_ps(_mm_castsi128_ps(xi0), _1_4);
- xf0 = _mm_mul_ps(xf0, _mm_movelh_ps(_mm_cvtpd_ps(t1), _mm_cvtpd_ps(t3)));
- xf0 = _mm_add_ps(xf0, _mm_and_ps(_mm_castsi128_ps(h0), shift4));
-
- __m128 zf0 = _mm_mul_ps(xf0, mA0);
- zf0 = _mm_mul_ps(_mm_add_ps(zf0, mA1), xf0);
- zf0 = _mm_mul_ps(_mm_add_ps(zf0, mA2), xf0);
- yf0 = _mm_add_ps(yf0, zf0);
-
- _mm_storeu_ps(y + i, yf0);
- }
-#endif
- for( ; i <= n - 4; i += 4 )
- {
- double x0, x1, x2, x3;
- double y0, y1, y2, y3;
- int h0, h1, h2, h3;
-
- h0 = x[i];
- h1 = x[i+1];
- buf[0].i = (h0 & LOGTAB_MASK2_32F) | (127 << 23);
- buf[1].i = (h1 & LOGTAB_MASK2_32F) | (127 << 23);
-
- y0 = (((h0 >> 23) & 0xff) - 127) * ln_2;
- y1 = (((h1 >> 23) & 0xff) - 127) * ln_2;
-
- h0 = (h0 >> (23 - LOGTAB_SCALE - 1)) & LOGTAB_MASK * 2;
- h1 = (h1 >> (23 - LOGTAB_SCALE - 1)) & LOGTAB_MASK * 2;
-
- y0 += icvLogTab[h0];
- y1 += icvLogTab[h1];
-
- h2 = x[i+2];
- h3 = x[i+3];
-
- x0 = LOGTAB_TRANSLATE( buf[0].f, h0 );
- x1 = LOGTAB_TRANSLATE( buf[1].f, h1 );
-
- buf[2].i = (h2 & LOGTAB_MASK2_32F) | (127 << 23);
- buf[3].i = (h3 & LOGTAB_MASK2_32F) | (127 << 23);
-
- y2 = (((h2 >> 23) & 0xff) - 127) * ln_2;
- y3 = (((h3 >> 23) & 0xff) - 127) * ln_2;
-
- h2 = (h2 >> (23 - LOGTAB_SCALE - 1)) & LOGTAB_MASK * 2;
- h3 = (h3 >> (23 - LOGTAB_SCALE - 1)) & LOGTAB_MASK * 2;
-
- y2 += icvLogTab[h2];
- y3 += icvLogTab[h3];
-
- x2 = LOGTAB_TRANSLATE( buf[2].f, h2 );
- x3 = LOGTAB_TRANSLATE( buf[3].f, h3 );
-
- x0 += shift[h0 == 510];
- x1 += shift[h1 == 510];
- y0 += LOGPOLY( x0 );
- y1 += LOGPOLY( x1 );
-
- y[i] = (float) y0;
- y[i + 1] = (float) y1;
-
- x2 += shift[h2 == 510];
- x3 += shift[h3 == 510];
- y2 += LOGPOLY( x2 );
- y3 += LOGPOLY( x3 );
-
- y[i + 2] = (float) y2;
- y[i + 3] = (float) y3;
- }
-
- for( ; i < n; i++ )
- {
- int h0 = x[i];
- double y0;
- float x0;
-
- y0 = (((h0 >> 23) & 0xff) - 127) * ln_2;
-
- buf[0].i = (h0 & LOGTAB_MASK2_32F) | (127 << 23);
- h0 = (h0 >> (23 - LOGTAB_SCALE - 1)) & LOGTAB_MASK * 2;
-
- y0 += icvLogTab[h0];
- x0 = (float)LOGTAB_TRANSLATE( buf[0].f, h0 );
- x0 += shift[h0 == 510];
- y0 += LOGPOLY( x0 );
-
- y[i] = (float)y0;
- }
-}
-
-void log64f( const double *x, double *y, int n )
-{
- CV_INSTRUMENT_REGION()
-
- CALL_HAL(log64f, cv_hal_log64f, x, y, n);
- CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsLn_64f_A50, x, y, n) >= 0);
-
- static const double shift[] = { 0, -1./512 };
- static const double
- A7 = 1.0,
- A6 = -0.5,
- A5 = 0.333333333333333314829616256247390992939472198486328125,
- A4 = -0.25,
- A3 = 0.2,
- A2 = -0.1666666666666666574148081281236954964697360992431640625,
- A1 = 0.1428571428571428769682682968777953647077083587646484375,
- A0 = -0.125;
-
-#undef LOGPOLY
-#define LOGPOLY(x,k) ((x)+=shift[k], xq = (x)*(x),\
-(((A0*xq + A2)*xq + A4)*xq + A6)*xq + \
-(((A1*xq + A3)*xq + A5)*xq + A7)*(x))
-
- int i = 0;
- DBLINT buf[4];
- DBLINT *X = (DBLINT *) x;
-
-#if CV_SSE2
- static const __m128d ln2_2 = _mm_set1_pd(ln_2);
- static const __m128d _1_2 = _mm_set1_pd(1.);
- static const __m128d shift2 = _mm_set1_pd(-1./512);
-
- static const __m128i log_and_mask2 = _mm_set_epi32(LOGTAB_MASK2, 0xffffffff, LOGTAB_MASK2, 0xffffffff);
- static const __m128i log_or_mask2 = _mm_set_epi32(1023 << 20, 0, 1023 << 20, 0);
-
- static const __m128d mA0 = _mm_set1_pd(A0);
- static const __m128d mA1 = _mm_set1_pd(A1);
- static const __m128d mA2 = _mm_set1_pd(A2);
- static const __m128d mA3 = _mm_set1_pd(A3);
- static const __m128d mA4 = _mm_set1_pd(A4);
- static const __m128d mA5 = _mm_set1_pd(A5);
- static const __m128d mA6 = _mm_set1_pd(A6);
- static const __m128d mA7 = _mm_set1_pd(A7);
-
- int CV_DECL_ALIGNED(16) idx[4];
-
- for( ; i <= n - 4; i += 4 )
- {
- __m128i h0 = _mm_loadu_si128((const __m128i*)(x + i));
- __m128i h1 = _mm_loadu_si128((const __m128i*)(x + i + 2));
-
- __m128d xd0 = _mm_castsi128_pd(_mm_or_si128(_mm_and_si128(h0, log_and_mask2), log_or_mask2));
- __m128d xd1 = _mm_castsi128_pd(_mm_or_si128(_mm_and_si128(h1, log_and_mask2), log_or_mask2));
-
- h0 = _mm_unpackhi_epi32(_mm_unpacklo_epi32(h0, h1), _mm_unpackhi_epi32(h0, h1));
-
- __m128i yi0 = _mm_sub_epi32(_mm_and_si128(_mm_srli_epi32(h0, 20),
- _mm_set1_epi32(2047)), _mm_set1_epi32(1023));
- __m128d yd0 = _mm_mul_pd(_mm_cvtepi32_pd(yi0), ln2_2);
- __m128d yd1 = _mm_mul_pd(_mm_cvtepi32_pd(_mm_unpackhi_epi64(yi0, yi0)), ln2_2);
-
- h0 = _mm_and_si128(_mm_srli_epi32(h0, 20 - LOGTAB_SCALE - 1), _mm_set1_epi32(LOGTAB_MASK * 2));
- _mm_store_si128((__m128i*)idx, h0);
- h0 = _mm_cmpeq_epi32(h0, _mm_set1_epi32(510));
-
- __m128d t0, t1, t2, t3, t4;
- t0 = _mm_load_pd(icvLogTab + idx[0]);
- t2 = _mm_load_pd(icvLogTab + idx[1]);
- t1 = _mm_unpackhi_pd(t0, t2);
- t0 = _mm_unpacklo_pd(t0, t2);
- t2 = _mm_load_pd(icvLogTab + idx[2]);
- t4 = _mm_load_pd(icvLogTab + idx[3]);
- t3 = _mm_unpackhi_pd(t2, t4);
- t2 = _mm_unpacklo_pd(t2, t4);
-
- yd0 = _mm_add_pd(yd0, t0);
- yd1 = _mm_add_pd(yd1, t2);
-
- xd0 = _mm_mul_pd(_mm_sub_pd(xd0, _1_2), t1);
- xd1 = _mm_mul_pd(_mm_sub_pd(xd1, _1_2), t3);
-
- xd0 = _mm_add_pd(xd0, _mm_and_pd(_mm_castsi128_pd(_mm_unpacklo_epi32(h0, h0)), shift2));
- xd1 = _mm_add_pd(xd1, _mm_and_pd(_mm_castsi128_pd(_mm_unpackhi_epi32(h0, h0)), shift2));
-
- __m128d zd0 = _mm_mul_pd(xd0, mA0);
- __m128d zd1 = _mm_mul_pd(xd1, mA0);
- zd0 = _mm_mul_pd(_mm_add_pd(zd0, mA1), xd0);
- zd1 = _mm_mul_pd(_mm_add_pd(zd1, mA1), xd1);
- zd0 = _mm_mul_pd(_mm_add_pd(zd0, mA2), xd0);
- zd1 = _mm_mul_pd(_mm_add_pd(zd1, mA2), xd1);
- zd0 = _mm_mul_pd(_mm_add_pd(zd0, mA3), xd0);
- zd1 = _mm_mul_pd(_mm_add_pd(zd1, mA3), xd1);
- zd0 = _mm_mul_pd(_mm_add_pd(zd0, mA4), xd0);
- zd1 = _mm_mul_pd(_mm_add_pd(zd1, mA4), xd1);
- zd0 = _mm_mul_pd(_mm_add_pd(zd0, mA5), xd0);
- zd1 = _mm_mul_pd(_mm_add_pd(zd1, mA5), xd1);
- zd0 = _mm_mul_pd(_mm_add_pd(zd0, mA6), xd0);
- zd1 = _mm_mul_pd(_mm_add_pd(zd1, mA6), xd1);
- zd0 = _mm_mul_pd(_mm_add_pd(zd0, mA7), xd0);
- zd1 = _mm_mul_pd(_mm_add_pd(zd1, mA7), xd1);
-
- yd0 = _mm_add_pd(yd0, zd0);
- yd1 = _mm_add_pd(yd1, zd1);
-
- _mm_storeu_pd(y + i, yd0);
- _mm_storeu_pd(y + i + 2, yd1);
- }
-#endif
- for( ; i <= n - 4; i += 4 )
- {
- double xq;
- double x0, x1, x2, x3;
- double y0, y1, y2, y3;
- int h0, h1, h2, h3;
-
- h0 = X[i].i.lo;
- h1 = X[i + 1].i.lo;
- buf[0].i.lo = h0;
- buf[1].i.lo = h1;
-
- h0 = X[i].i.hi;
- h1 = X[i + 1].i.hi;
- buf[0].i.hi = (h0 & LOGTAB_MASK2) | (1023 << 20);
- buf[1].i.hi = (h1 & LOGTAB_MASK2) | (1023 << 20);
-
- y0 = (((h0 >> 20) & 0x7ff) - 1023) * ln_2;
- y1 = (((h1 >> 20) & 0x7ff) - 1023) * ln_2;
-
- h2 = X[i + 2].i.lo;
- h3 = X[i + 3].i.lo;
- buf[2].i.lo = h2;
- buf[3].i.lo = h3;
-
- h0 = (h0 >> (20 - LOGTAB_SCALE - 1)) & LOGTAB_MASK * 2;
- h1 = (h1 >> (20 - LOGTAB_SCALE - 1)) & LOGTAB_MASK * 2;
-
- y0 += icvLogTab[h0];
- y1 += icvLogTab[h1];
-
- h2 = X[i + 2].i.hi;
- h3 = X[i + 3].i.hi;
-
- x0 = LOGTAB_TRANSLATE( buf[0].d, h0 );
- x1 = LOGTAB_TRANSLATE( buf[1].d, h1 );
-
- buf[2].i.hi = (h2 & LOGTAB_MASK2) | (1023 << 20);
- buf[3].i.hi = (h3 & LOGTAB_MASK2) | (1023 << 20);
-
- y2 = (((h2 >> 20) & 0x7ff) - 1023) * ln_2;
- y3 = (((h3 >> 20) & 0x7ff) - 1023) * ln_2;
-
- h2 = (h2 >> (20 - LOGTAB_SCALE - 1)) & LOGTAB_MASK * 2;
- h3 = (h3 >> (20 - LOGTAB_SCALE - 1)) & LOGTAB_MASK * 2;
-
- y2 += icvLogTab[h2];
- y3 += icvLogTab[h3];
-
- x2 = LOGTAB_TRANSLATE( buf[2].d, h2 );
- x3 = LOGTAB_TRANSLATE( buf[3].d, h3 );
-
- y0 += LOGPOLY( x0, h0 == 510 );
- y1 += LOGPOLY( x1, h1 == 510 );
-
- y[i] = y0;
- y[i + 1] = y1;
-
- y2 += LOGPOLY( x2, h2 == 510 );
- y3 += LOGPOLY( x3, h3 == 510 );
-
- y[i + 2] = y2;
- y[i + 3] = y3;
- }
-
- for( ; i < n; i++ )
- {
- int h0 = X[i].i.hi;
- double xq;
- double x0, y0 = (((h0 >> 20) & 0x7ff) - 1023) * ln_2;
-
- buf[0].i.hi = (h0 & LOGTAB_MASK2) | (1023 << 20);
- buf[0].i.lo = X[i].i.lo;
- h0 = (h0 >> (20 - LOGTAB_SCALE - 1)) & LOGTAB_MASK * 2;
-
- y0 += icvLogTab[h0];
- x0 = LOGTAB_TRANSLATE( buf[0].d, h0 );
- y0 += LOGPOLY( x0, h0 == 510 );
- y[i] = y0;
- }
-}
-
-#endif // issue 7795
-
-//=============================================================================
-// for compatibility with 3.0
-
-void exp(const float* src, float* dst, int n)
-{
- exp32f(src, dst, n);
-}
-
-void exp(const double* src, double* dst, int n)
-{
- exp64f(src, dst, n);
-}
-
-void log(const float* src, float* dst, int n)
-{
- log32f(src, dst, n);
-}
-
-void log(const double* src, double* dst, int n)
-{
- log64f(src, dst, n);
-}
-
-void magnitude(const float* x, const float* y, float* dst, int n)
-{
- magnitude32f(x, y, dst, n);
-}
-
-void magnitude(const double* x, const double* y, double* dst, int n)
-{
- magnitude64f(x, y, dst, n);
-}
-
-void sqrt(const float* src, float* dst, int len)
-{
- sqrt32f(src, dst, len);
-}
-
-void sqrt(const double* src, double* dst, int len)
-{
- sqrt64f(src, dst, len);
-}
-
-void invSqrt(const float* src, float* dst, int len)
-{
- invSqrt32f(src, dst, len);
-}
-
-void invSqrt(const double* src, double* dst, int len)
-{
- invSqrt64f(src, dst, len);
-}
-
-
-} // cv::hal::
-} // cv::
-
-float cv::fastAtan2( float y, float x )
-{
- return atanImpl<float>(y, x);
-}
diff --git a/modules/core/src/mathfuncs_core.dispatch.cpp b/modules/core/src/mathfuncs_core.dispatch.cpp
new file mode 100644
index 0000000..b64ec4a
--- /dev/null
+++ b/modules/core/src/mathfuncs_core.dispatch.cpp
@@ -0,0 +1,215 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "precomp.hpp"
+
+#include "mathfuncs_core.simd.hpp"
+#include "mathfuncs_core.simd_declarations.hpp" // defines CV_CPU_DISPATCH_MODES_ALL=AVX2,...,BASELINE based on CMakeLists.txt content
+
+namespace cv { namespace hal {
+
+///////////////////////////////////// ATAN2 ////////////////////////////////////
+
+void fastAtan32f(const float *Y, const float *X, float *angle, int len, bool angleInDegrees )
+{
+ CV_INSTRUMENT_REGION()
+
+ CALL_HAL(fastAtan32f, cv_hal_fastAtan32f, Y, X, angle, len, angleInDegrees);
+
+ CV_CPU_DISPATCH(fastAtan32f, (Y, X, angle, len, angleInDegrees),
+ CV_CPU_DISPATCH_MODES_ALL);
+}
+
+void fastAtan64f(const double *Y, const double *X, double *angle, int len, bool angleInDegrees)
+{
+ CV_INSTRUMENT_REGION()
+
+ CALL_HAL(fastAtan64f, cv_hal_fastAtan64f, Y, X, angle, len, angleInDegrees);
+
+ CV_CPU_DISPATCH(fastAtan64f, (Y, X, angle, len, angleInDegrees),
+ CV_CPU_DISPATCH_MODES_ALL);
+}
+
+// deprecated
+void fastAtan2(const float *Y, const float *X, float *angle, int len, bool angleInDegrees )
+{
+ CV_INSTRUMENT_REGION()
+
+ fastAtan32f(Y, X, angle, len, angleInDegrees);
+}
+
+void magnitude32f(const float* x, const float* y, float* mag, int len)
+{
+ CV_INSTRUMENT_REGION()
+
+ CALL_HAL(magnitude32f, cv_hal_magnitude32f, x, y, mag, len);
+ CV_IPP_RUN(!IPP_DISABLE_PERF_MAG_SSE42 || (ipp::getIppFeatures()&ippCPUID_AVX), CV_INSTRUMENT_FUN_IPP(ippsMagnitude_32f, x, y, mag, len) >= 0);
+
+ CV_CPU_DISPATCH(magnitude32f, (x, y, mag, len),
+ CV_CPU_DISPATCH_MODES_ALL);
+}
+
+void magnitude64f(const double* x, const double* y, double* mag, int len)
+{
+ CV_INSTRUMENT_REGION()
+
+ CALL_HAL(magnitude64f, cv_hal_magnitude64f, x, y, mag, len);
+ CV_IPP_RUN(!IPP_DISABLE_PERF_MAG_SSE42 || (ipp::getIppFeatures()&ippCPUID_AVX), CV_INSTRUMENT_FUN_IPP(ippsMagnitude_64f, x, y, mag, len) >= 0);
+
+ CV_CPU_DISPATCH(magnitude64f, (x, y, mag, len),
+ CV_CPU_DISPATCH_MODES_ALL);
+}
+
+
+void invSqrt32f(const float* src, float* dst, int len)
+{
+ CV_INSTRUMENT_REGION()
+
+ CALL_HAL(invSqrt32f, cv_hal_invSqrt32f, src, dst, len);
+ CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsInvSqrt_32f_A21, src, dst, len) >= 0);
+
+ CV_CPU_DISPATCH(invSqrt32f, (src, dst, len),
+ CV_CPU_DISPATCH_MODES_ALL);
+}
+
+
+void invSqrt64f(const double* src, double* dst, int len)
+{
+ CV_INSTRUMENT_REGION()
+
+ CALL_HAL(invSqrt64f, cv_hal_invSqrt64f, src, dst, len);
+ CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsInvSqrt_64f_A50, src, dst, len) >= 0);
+
+ CV_CPU_DISPATCH(invSqrt64f, (src, dst, len),
+ CV_CPU_DISPATCH_MODES_ALL);
+}
+
+
+void sqrt32f(const float* src, float* dst, int len)
+{
+ CV_INSTRUMENT_REGION()
+
+ CALL_HAL(sqrt32f, cv_hal_sqrt32f, src, dst, len);
+ CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsSqrt_32f_A21, src, dst, len) >= 0);
+
+ CV_CPU_DISPATCH(sqrt32f, (src, dst, len),
+ CV_CPU_DISPATCH_MODES_ALL);
+}
+
+
+void sqrt64f(const double* src, double* dst, int len)
+{
+ CV_INSTRUMENT_REGION()
+
+ CALL_HAL(sqrt64f, cv_hal_sqrt64f, src, dst, len);
+ CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsSqrt_64f_A50, src, dst, len) >= 0);
+
+ CV_CPU_DISPATCH(sqrt64f, (src, dst, len),
+ CV_CPU_DISPATCH_MODES_ALL);
+}
+
+void exp32f(const float *src, float *dst, int n)
+{
+ CV_INSTRUMENT_REGION()
+
+ CALL_HAL(exp32f, cv_hal_exp32f, src, dst, n);
+ CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsExp_32f_A21, src, dst, n) >= 0);
+
+ CV_CPU_DISPATCH(exp32f, (src, dst, n),
+ CV_CPU_DISPATCH_MODES_ALL);
+}
+
+void exp64f(const double *src, double *dst, int n)
+{
+ CV_INSTRUMENT_REGION()
+
+ CALL_HAL(exp64f, cv_hal_exp64f, src, dst, n);
+ CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsExp_64f_A50, src, dst, n) >= 0);
+
+ CV_CPU_DISPATCH(exp64f, (src, dst, n),
+ CV_CPU_DISPATCH_MODES_ALL);
+}
+
+void log32f(const float *src, float *dst, int n)
+{
+ CV_INSTRUMENT_REGION()
+
+ CALL_HAL(log32f, cv_hal_log32f, src, dst, n);
+ CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsLn_32f_A21, src, dst, n) >= 0);
+
+ CV_CPU_DISPATCH(log32f, (src, dst, n),
+ CV_CPU_DISPATCH_MODES_ALL);
+}
+
+void log64f(const double *src, double *dst, int n)
+{
+ CV_INSTRUMENT_REGION()
+
+ CALL_HAL(log64f, cv_hal_log64f, src, dst, n);
+ CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsLn_64f_A50, src, dst, n) >= 0);
+
+ CV_CPU_DISPATCH(log64f, (src, dst, n),
+ CV_CPU_DISPATCH_MODES_ALL);
+}
+
+//=============================================================================
+// for compatibility with 3.0
+
+void exp(const float* src, float* dst, int n)
+{
+ exp32f(src, dst, n);
+}
+
+void exp(const double* src, double* dst, int n)
+{
+ exp64f(src, dst, n);
+}
+
+void log(const float* src, float* dst, int n)
+{
+ log32f(src, dst, n);
+}
+
+void log(const double* src, double* dst, int n)
+{
+ log64f(src, dst, n);
+}
+
+void magnitude(const float* x, const float* y, float* dst, int n)
+{
+ magnitude32f(x, y, dst, n);
+}
+
+void magnitude(const double* x, const double* y, double* dst, int n)
+{
+ magnitude64f(x, y, dst, n);
+}
+
+void sqrt(const float* src, float* dst, int len)
+{
+ sqrt32f(src, dst, len);
+}
+
+void sqrt(const double* src, double* dst, int len)
+{
+ sqrt64f(src, dst, len);
+}
+
+void invSqrt(const float* src, float* dst, int len)
+{
+ invSqrt32f(src, dst, len);
+}
+
+void invSqrt(const double* src, double* dst, int len)
+{
+ invSqrt64f(src, dst, len);
+}
+
+}} // namespace cv::hal::
+
+float cv::fastAtan2( float y, float x )
+{
+ using namespace cv::hal;
+ CV_CPU_CALL_BASELINE(fastAtan2, (y, x));
+}
diff --git a/modules/core/src/mathfuncs_core.simd.hpp b/modules/core/src/mathfuncs_core.simd.hpp
new file mode 100644
index 0000000..b10bab6
--- /dev/null
+++ b/modules/core/src/mathfuncs_core.simd.hpp
@@ -0,0 +1,1553 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+namespace cv { namespace hal {
+
+CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
+
+// forward declarations
+void fastAtan32f(const float *Y, const float *X, float *angle, int len, bool angleInDegrees);
+void fastAtan64f(const double *Y, const double *X, double *angle, int len, bool angleInDegrees);
+void fastAtan2(const float *Y, const float *X, float *angle, int len, bool angleInDegrees);
+void magnitude32f(const float* x, const float* y, float* mag, int len);
+void magnitude64f(const double* x, const double* y, double* mag, int len);
+void invSqrt32f(const float* src, float* dst, int len);
+void invSqrt64f(const double* src, double* dst, int len);
+void sqrt32f(const float* src, float* dst, int len);
+void sqrt64f(const double* src, double* dst, int len);
+void exp32f(const float *src, float *dst, int n);
+void exp64f(const double *src, double *dst, int n);
+void log32f(const float *src, float *dst, int n);
+void log64f(const double *src, double *dst, int n);
+float fastAtan2(float y, float x);
+
+
+#ifndef CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
+
+using namespace std;
+
+namespace {
+
+static const float atan2_p1 = 0.9997878412794807f*(float)(180/CV_PI);
+static const float atan2_p3 = -0.3258083974640975f*(float)(180/CV_PI);
+static const float atan2_p5 = 0.1555786518463281f*(float)(180/CV_PI);
+static const float atan2_p7 = -0.04432655554792128f*(float)(180/CV_PI);
+
+using namespace cv;
+
+#if CV_SIMD128
+
+template <typename T>
+struct v_atan
+{
+ typedef V_RegTrait128<T> Trait;
+ typedef typename Trait::reg VT; // vector type
+ enum { WorkWidth = VT::nlanes * 2 };
+
+ v_atan(const T & scale)
+ : s(Trait::all(scale))
+ {
+ eps = Trait::all(DBL_EPSILON);
+ z = Trait::zero();
+ p7 = Trait::all(atan2_p7);
+ p5 = Trait::all(atan2_p5);
+ p3 = Trait::all(atan2_p3);
+ p1 = Trait::all(atan2_p1);
+ val90 = Trait::all(90.f);
+ val180 = Trait::all(180.f);
+ val360 = Trait::all(360.f);
+ }
+
+ inline int operator()(int len, const T * Y, const T * X, T * angle)
+ {
+ int i = 0;
+ const int c = VT::nlanes;
+ for ( ; i <= len - c * 2; i += c * 2)
+ {
+ VT x1 = v_load(X + i);
+ VT x2 = v_load(X + i + c);
+ VT y1 = v_load(Y + i);
+ VT y2 = v_load(Y + i + c);
+ v_store(&angle[i], s * one(x1, y1));
+ v_store(&angle[i + c], s * one(x2, y2));
+ }
+ return i;
+ }
+
+private:
+ inline VT one(VT & x, VT & y)
+ {
+ VT ax = v_abs(x);
+ VT ay = v_abs(y);
+ VT c = v_min(ax, ay) / (v_max(ax, ay) + eps);
+ VT cc = c * c;
+ VT a = (((p7 * cc + p5) * cc + p3) * cc + p1) * c;
+ a = v_select(ax >= ay, a, val90 - a);
+ a = v_select(x < z, val180 - a, a);
+ a = v_select(y < z, val360 - a, a);
+ return a;
+ }
+
+private:
+ VT eps;
+ VT z;
+ VT p7;
+ VT p5;
+ VT p3;
+ VT p1;
+ VT val90;
+ VT val180;
+ VT val360;
+ VT s;
+};
+
+#if !CV_SIMD128_64F
+
+// emulation
+template <>
+struct v_atan<double>
+{
+ v_atan(double scale) : impl(static_cast<float>(scale)) {}
+ inline int operator()(int len, const double * Y, const double * X, double * angle)
+ {
+ int i = 0;
+ const int c = v_atan<float>::WorkWidth;
+ float bufY[c];
+ float bufX[c];
+ float bufA[c];
+ for ( ; i <= len - c ; i += c)
+ {
+ for (int j = 0; j < c; ++j)
+ {
+ bufY[j] = static_cast<float>(Y[i + j]);
+ bufX[j] = static_cast<float>(X[i + j]);
+ }
+ impl(c, bufY, bufX, bufA);
+ for (int j = 0; j < c; ++j)
+ {
+ angle[i + j] = bufA[j];
+ }
+ }
+ return i;
+ }
+private:
+ v_atan<float> impl;
+};
+#endif
+
+#endif
+
+template <typename T>
+static inline T atanImpl(T y, T x)
+{
+ T ax = std::abs(x), ay = std::abs(y);
+ T a, c, c2;
+ if( ax >= ay )
+ {
+ c = ay/(ax + static_cast<T>(DBL_EPSILON));
+ c2 = c*c;
+ a = (((atan2_p7*c2 + atan2_p5)*c2 + atan2_p3)*c2 + atan2_p1)*c;
+ }
+ else
+ {
+ c = ax/(ay + static_cast<T>(DBL_EPSILON));
+ c2 = c*c;
+ a = 90.f - (((atan2_p7*c2 + atan2_p5)*c2 + atan2_p3)*c2 + atan2_p1)*c;
+ }
+ if( x < 0 )
+ a = 180.f - a;
+ if( y < 0 )
+ a = 360.f - a;
+ return a;
+}
+
+template <typename T>
+static inline void atanImpl(const T *Y, const T *X, T *angle, int len, bool angleInDegrees)
+{
+ int i = 0;
+ T scale = angleInDegrees ? 1 : static_cast<T>(CV_PI/180);
+
+#if CV_SIMD128
+ i = v_atan<T>(scale)(len, Y, X, angle);
+#endif
+
+ for( ; i < len; i++ )
+ {
+ angle[i] = atanImpl<T>(Y[i], X[i]) * scale;
+ }
+}
+
+} // anonymous::
+
+///////////////////////////////////// ATAN2 ////////////////////////////////////
+
+void fastAtan32f(const float *Y, const float *X, float *angle, int len, bool angleInDegrees )
+{
+ CV_INSTRUMENT_REGION()
+ atanImpl<float>(Y, X, angle, len, angleInDegrees);
+}
+
+void fastAtan64f(const double *Y, const double *X, double *angle, int len, bool angleInDegrees)
+{
+ CV_INSTRUMENT_REGION()
+ atanImpl<double>(Y, X, angle, len, angleInDegrees);
+}
+
+// deprecated
+void fastAtan2(const float *Y, const float *X, float *angle, int len, bool angleInDegrees )
+{
+ CV_INSTRUMENT_REGION()
+ fastAtan32f(Y, X, angle, len, angleInDegrees);
+}
+
+void magnitude32f(const float* x, const float* y, float* mag, int len)
+{
+ CV_INSTRUMENT_REGION()
+
+ int i = 0;
+
+#if CV_SIMD128
+ for( ; i <= len - 8; i += 8 )
+ {
+ v_float32x4 x0 = v_load(x + i), x1 = v_load(x + i + 4);
+ v_float32x4 y0 = v_load(y + i), y1 = v_load(y + i + 4);
+ x0 = v_sqrt(v_muladd(x0, x0, y0*y0));
+ x1 = v_sqrt(v_muladd(x1, x1, y1*y1));
+ v_store(mag + i, x0);
+ v_store(mag + i + 4, x1);
+ }
+#endif
+
+ for( ; i < len; i++ )
+ {
+ float x0 = x[i], y0 = y[i];
+ mag[i] = std::sqrt(x0*x0 + y0*y0);
+ }
+}
+
+void magnitude64f(const double* x, const double* y, double* mag, int len)
+{
+ CV_INSTRUMENT_REGION()
+
+ int i = 0;
+
+#if CV_SIMD128_64F
+ for( ; i <= len - 4; i += 4 )
+ {
+ v_float64x2 x0 = v_load(x + i), x1 = v_load(x + i + 2);
+ v_float64x2 y0 = v_load(y + i), y1 = v_load(y + i + 2);
+ x0 = v_sqrt(v_muladd(x0, x0, y0*y0));
+ x1 = v_sqrt(v_muladd(x1, x1, y1*y1));
+ v_store(mag + i, x0);
+ v_store(mag + i + 2, x1);
+ }
+#endif
+
+ for( ; i < len; i++ )
+ {
+ double x0 = x[i], y0 = y[i];
+ mag[i] = std::sqrt(x0*x0 + y0*y0);
+ }
+}
+
+
+void invSqrt32f(const float* src, float* dst, int len)
+{
+ CV_INSTRUMENT_REGION()
+
+ int i = 0;
+
+#if CV_SIMD128
+ for( ; i <= len - 8; i += 8 )
+ {
+ v_float32x4 t0 = v_load(src + i), t1 = v_load(src + i + 4);
+ t0 = v_invsqrt(t0);
+ t1 = v_invsqrt(t1);
+ v_store(dst + i, t0); v_store(dst + i + 4, t1);
+ }
+#endif
+
+ for( ; i < len; i++ )
+ dst[i] = 1/std::sqrt(src[i]);
+}
+
+
+void invSqrt64f(const double* src, double* dst, int len)
+{
+ CV_INSTRUMENT_REGION()
+
+ int i = 0;
+
+#if CV_SSE2
+ __m128d v_1 = _mm_set1_pd(1.0);
+ for ( ; i <= len - 2; i += 2)
+ _mm_storeu_pd(dst + i, _mm_div_pd(v_1, _mm_sqrt_pd(_mm_loadu_pd(src + i))));
+#endif
+
+ for( ; i < len; i++ )
+ dst[i] = 1/std::sqrt(src[i]);
+}
+
+
+void sqrt32f(const float* src, float* dst, int len)
+{
+ CV_INSTRUMENT_REGION()
+
+ int i = 0;
+
+#if CV_SIMD128
+ for( ; i <= len - 8; i += 8 )
+ {
+ v_float32x4 t0 = v_load(src + i), t1 = v_load(src + i + 4);
+ t0 = v_sqrt(t0);
+ t1 = v_sqrt(t1);
+ v_store(dst + i, t0); v_store(dst + i + 4, t1);
+ }
+#endif
+
+ for( ; i < len; i++ )
+ dst[i] = std::sqrt(src[i]);
+}
+
+
+void sqrt64f(const double* src, double* dst, int len)
+{
+ CV_INSTRUMENT_REGION()
+
+ int i = 0;
+
+#if CV_SIMD128_64F
+ for( ; i <= len - 4; i += 4 )
+ {
+ v_float64x2 t0 = v_load(src + i), t1 = v_load(src + i + 2);
+ t0 = v_sqrt(t0);
+ t1 = v_sqrt(t1);
+ v_store(dst + i, t0); v_store(dst + i + 2, t1);
+ }
+#endif
+
+ for( ; i < len; i++ )
+ dst[i] = std::sqrt(src[i]);
+}
+
+// Workaround for ICE in MSVS 2015 update 3 (issue #7795)
+// CV_AVX is not used here, because generated code is faster in non-AVX mode.
+// (tested with disabled IPP on i5-6300U)
+#if (defined _MSC_VER && _MSC_VER >= 1900)
+void exp32f(const float *src, float *dst, int n)
+{
+ CV_INSTRUMENT_REGION()
+
+ for (int i = 0; i < n; i++)
+ {
+ dst[i] = std::exp(src[i]);
+ }
+}
+
+void exp64f(const double *src, double *dst, int n)
+{
+ CV_INSTRUMENT_REGION()
+
+ for (int i = 0; i < n; i++)
+ {
+ dst[i] = std::exp(src[i]);
+ }
+}
+
+void log32f(const float *src, float *dst, int n)
+{
+ CV_INSTRUMENT_REGION()
+
+ for (int i = 0; i < n; i++)
+ {
+ dst[i] = std::log(src[i]);
+ }
+}
+void log64f(const double *src, double *dst, int n)
+{
+ CV_INSTRUMENT_REGION()
+
+ for (int i = 0; i < n; i++)
+ {
+ dst[i] = std::log(src[i]);
+ }
+}
+#else
+
+////////////////////////////////////// EXP /////////////////////////////////////
+
+typedef union
+{
+ struct {
+#if ( defined( WORDS_BIGENDIAN ) && !defined( OPENCV_UNIVERSAL_BUILD ) ) || defined( __BIG_ENDIAN__ )
+ int hi;
+ int lo;
+#else
+ int lo;
+ int hi;
+#endif
+ } i;
+ double d;
+}
+DBLINT;
+
+#define EXPTAB_SCALE 6
+#define EXPTAB_MASK ((1 << EXPTAB_SCALE) - 1)
+
+#define EXPPOLY_32F_A0 .9670371139572337719125840413672004409288e-2
+
+static const double expTab[] = {
+ 1.0 * EXPPOLY_32F_A0,
+ 1.0108892860517004600204097905619 * EXPPOLY_32F_A0,
+ 1.0218971486541166782344801347833 * EXPPOLY_32F_A0,
+ 1.0330248790212284225001082839705 * EXPPOLY_32F_A0,
+ 1.0442737824274138403219664787399 * EXPPOLY_32F_A0,
+ 1.0556451783605571588083413251529 * EXPPOLY_32F_A0,
+ 1.0671404006768236181695211209928 * EXPPOLY_32F_A0,
+ 1.0787607977571197937406800374385 * EXPPOLY_32F_A0,
+ 1.0905077326652576592070106557607 * EXPPOLY_32F_A0,
+ 1.1023825833078409435564142094256 * EXPPOLY_32F_A0,
+ 1.1143867425958925363088129569196 * EXPPOLY_32F_A0,
+ 1.126521618608241899794798643787 * EXPPOLY_32F_A0,
+ 1.1387886347566916537038302838415 * EXPPOLY_32F_A0,
+ 1.151189229952982705817759635202 * EXPPOLY_32F_A0,
+ 1.1637248587775775138135735990922 * EXPPOLY_32F_A0,
+ 1.1763969916502812762846457284838 * EXPPOLY_32F_A0,
+ 1.1892071150027210667174999705605 * EXPPOLY_32F_A0,
+ 1.2021567314527031420963969574978 * EXPPOLY_32F_A0,
+ 1.2152473599804688781165202513388 * EXPPOLY_32F_A0,
+ 1.2284805361068700056940089577928 * EXPPOLY_32F_A0,
+ 1.2418578120734840485936774687266 * EXPPOLY_32F_A0,
+ 1.2553807570246910895793906574423 * EXPPOLY_32F_A0,
+ 1.2690509571917332225544190810323 * EXPPOLY_32F_A0,
+ 1.2828700160787782807266697810215 * EXPPOLY_32F_A0,
+ 1.2968395546510096659337541177925 * EXPPOLY_32F_A0,
+ 1.3109612115247643419229917863308 * EXPPOLY_32F_A0,
+ 1.3252366431597412946295370954987 * EXPPOLY_32F_A0,
+ 1.3396675240533030053600306697244 * EXPPOLY_32F_A0,
+ 1.3542555469368927282980147401407 * EXPPOLY_32F_A0,
+ 1.3690024229745906119296011329822 * EXPPOLY_32F_A0,
+ 1.3839098819638319548726595272652 * EXPPOLY_32F_A0,
+ 1.3989796725383111402095281367152 * EXPPOLY_32F_A0,
+ 1.4142135623730950488016887242097 * EXPPOLY_32F_A0,
+ 1.4296133383919700112350657782751 * EXPPOLY_32F_A0,
+ 1.4451808069770466200370062414717 * EXPPOLY_32F_A0,
+ 1.4609177941806469886513028903106 * EXPPOLY_32F_A0,
+ 1.476826145939499311386907480374 * EXPPOLY_32F_A0,
+ 1.4929077282912648492006435314867 * EXPPOLY_32F_A0,
+ 1.5091644275934227397660195510332 * EXPPOLY_32F_A0,
+ 1.5255981507445383068512536895169 * EXPPOLY_32F_A0,
+ 1.5422108254079408236122918620907 * EXPPOLY_32F_A0,
+ 1.5590044002378369670337280894749 * EXPPOLY_32F_A0,
+ 1.5759808451078864864552701601819 * EXPPOLY_32F_A0,
+ 1.5931421513422668979372486431191 * EXPPOLY_32F_A0,
+ 1.6104903319492543081795206673574 * EXPPOLY_32F_A0,
+ 1.628027421857347766848218522014 * EXPPOLY_32F_A0,
+ 1.6457554781539648445187567247258 * EXPPOLY_32F_A0,
+ 1.6636765803267364350463364569764 * EXPPOLY_32F_A0,
+ 1.6817928305074290860622509524664 * EXPPOLY_32F_A0,
+ 1.7001063537185234695013625734975 * EXPPOLY_32F_A0,
+ 1.7186192981224779156293443764563 * EXPPOLY_32F_A0,
+ 1.7373338352737062489942020818722 * EXPPOLY_32F_A0,
+ 1.7562521603732994831121606193753 * EXPPOLY_32F_A0,
+ 1.7753764925265212525505592001993 * EXPPOLY_32F_A0,
+ 1.7947090750031071864277032421278 * EXPPOLY_32F_A0,
+ 1.8142521755003987562498346003623 * EXPPOLY_32F_A0,
+ 1.8340080864093424634870831895883 * EXPPOLY_32F_A0,
+ 1.8539791250833855683924530703377 * EXPPOLY_32F_A0,
+ 1.8741676341102999013299989499544 * EXPPOLY_32F_A0,
+ 1.8945759815869656413402186534269 * EXPPOLY_32F_A0,
+ 1.9152065613971472938726112702958 * EXPPOLY_32F_A0,
+ 1.9360617934922944505980559045667 * EXPPOLY_32F_A0,
+ 1.9571441241754002690183222516269 * EXPPOLY_32F_A0,
+ 1.9784560263879509682582499181312 * EXPPOLY_32F_A0,
+};
+
+
+// the code below uses _mm_cast* intrinsics, which are not avialable on VS2005
+#if (defined _MSC_VER && _MSC_VER < 1500) || \
+(!defined __APPLE__ && defined __GNUC__ && __GNUC__*100 + __GNUC_MINOR__ < 402)
+#undef CV_SSE2
+#define CV_SSE2 0
+#endif
+
+static const double exp_prescale = 1.4426950408889634073599246810019 * (1 << EXPTAB_SCALE);
+static const double exp_postscale = 1./(1 << EXPTAB_SCALE);
+static const double exp_max_val = 3000.*(1 << EXPTAB_SCALE); // log10(DBL_MAX) < 3000
+
+void exp32f( const float *_x, float *y, int n )
+{
+ CV_INSTRUMENT_REGION()
+
+ static const float
+ A4 = (float)(1.000000000000002438532970795181890933776 / EXPPOLY_32F_A0),
+ A3 = (float)(.6931471805521448196800669615864773144641 / EXPPOLY_32F_A0),
+ A2 = (float)(.2402265109513301490103372422686535526573 / EXPPOLY_32F_A0),
+ A1 = (float)(.5550339366753125211915322047004666939128e-1 / EXPPOLY_32F_A0);
+
+#undef EXPPOLY
+#define EXPPOLY(x) \
+(((((x) + A1)*(x) + A2)*(x) + A3)*(x) + A4)
+
+ int i = 0;
+ const Cv32suf* x = (const Cv32suf*)_x;
+ Cv32suf buf[4];
+
+#if CV_AVX2
+ if( n >= 8 )
+ {
+ static const __m256d prescale4 = _mm256_set1_pd(exp_prescale);
+ static const __m256 postscale8 = _mm256_set1_ps((float)exp_postscale);
+ static const __m128 maxval4 = _mm_set1_ps((float)(exp_max_val/exp_prescale));
+ static const __m128 minval4 = _mm_set1_ps((float)(-exp_max_val/exp_prescale));
+
+ static const __m256 mA1 = _mm256_set1_ps(A1);
+ static const __m256 mA2 = _mm256_set1_ps(A2);
+ static const __m256 mA3 = _mm256_set1_ps(A3);
+ static const __m256 mA4 = _mm256_set1_ps(A4);
+ bool y_aligned = (size_t)(void*)y % 32 == 0;
+
+ ushort CV_DECL_ALIGNED(32) tab_idx[16];
+
+ for( ; i <= n - 8; i += 8 )
+ {
+ __m128i xi0, xi1;
+
+ __m256d xd0 = _mm256_cvtps_pd(_mm_min_ps(_mm_max_ps(_mm_loadu_ps(&x[i].f), minval4), maxval4));
+ __m256d xd1 = _mm256_cvtps_pd(_mm_min_ps(_mm_max_ps(_mm_loadu_ps(&x[i+4].f), minval4), maxval4));
+
+ xd0 = _mm256_mul_pd(xd0, prescale4);
+ xd1 = _mm256_mul_pd(xd1, prescale4);
+
+ xi0 = _mm256_cvtpd_epi32(xd0);
+ xi1 = _mm256_cvtpd_epi32(xd1);
+
+ xd0 = _mm256_sub_pd(xd0, _mm256_cvtepi32_pd(xi0));
+ xd1 = _mm256_sub_pd(xd1, _mm256_cvtepi32_pd(xi1));
+
+ // gcc does not support _mm256_set_m128
+ //xf = _mm256_set_m128(_mm256_cvtpd_ps(xd1), _mm256_cvtpd_ps(xd0));
+ __m256 xf = _mm256_insertf128_ps(_mm256_castps128_ps256(_mm256_cvtpd_ps(xd0)), _mm256_cvtpd_ps(xd1), 1);
+
+ xf = _mm256_mul_ps(xf, postscale8);
+
+ xi0 = _mm_packs_epi32(xi0, xi1);
+
+ _mm_store_si128((__m128i*)tab_idx, _mm_and_si128(xi0, _mm_set1_epi16(EXPTAB_MASK)));
+
+ xi0 = _mm_add_epi16(_mm_srai_epi16(xi0, EXPTAB_SCALE), _mm_set1_epi16(127));
+ xi0 = _mm_max_epi16(xi0, _mm_setzero_si128());
+ xi0 = _mm_min_epi16(xi0, _mm_set1_epi16(255));
+ xi1 = _mm_unpackhi_epi16(xi0, _mm_setzero_si128());
+ xi0 = _mm_unpacklo_epi16(xi0, _mm_setzero_si128());
+
+ __m256d yd0 = _mm256_set_pd(expTab[tab_idx[3]], expTab[tab_idx[2]], expTab[tab_idx[1]], expTab[tab_idx[0]]);
+ __m256d yd1 = _mm256_set_pd(expTab[tab_idx[7]], expTab[tab_idx[6]], expTab[tab_idx[5]], expTab[tab_idx[4]]);
+
+ // gcc does not support _mm256_set_m128
+ //__m256 yf = _mm256_set_m128(_mm256_cvtpd_ps(yd1), _mm256_cvtpd_ps(yd0));
+ __m256 yf = _mm256_insertf128_ps(_mm256_castps128_ps256(_mm256_cvtpd_ps(yd0)), _mm256_cvtpd_ps(yd1), 1);
+
+ //_mm256_set_m128i(xi1, xi0)
+ __m256i temp = _mm256_castps_si256(_mm256_insertf128_ps(_mm256_castps128_ps256(_mm_castsi128_ps(xi0)), _mm_castsi128_ps(xi1), 1));
+
+ yf = _mm256_mul_ps(yf, _mm256_castsi256_ps(_mm256_slli_epi32(temp, 23)));
+
+ __m256 zf = _mm256_add_ps(xf, mA1);
+
+#if CV_FMA3
+ zf = _mm256_fmadd_ps(zf, xf, mA2);
+ zf = _mm256_fmadd_ps(zf, xf, mA3);
+ zf = _mm256_fmadd_ps(zf, xf, mA4);
+#else
+ zf = _mm256_add_ps(_mm256_mul_ps(zf, xf), mA2);
+ zf = _mm256_add_ps(_mm256_mul_ps(zf, xf), mA3);
+ zf = _mm256_add_ps(_mm256_mul_ps(zf, xf), mA4);
+#endif
+ zf = _mm256_mul_ps(zf, yf);
+
+ if( y_aligned )
+ {
+ _mm256_store_ps(y + i, zf);
+ }
+ else
+ {
+ _mm256_storeu_ps(y + i, zf);
+ }
+ }
+ }
+#elif CV_SSE2
+ if( n >= 8 )
+ {
+ static const __m128d prescale2 = _mm_set1_pd(exp_prescale);
+ static const __m128 postscale4 = _mm_set1_ps((float)exp_postscale);
+ static const __m128 maxval4 = _mm_set1_ps((float)(exp_max_val/exp_prescale));
+ static const __m128 minval4 = _mm_set1_ps((float)(-exp_max_val/exp_prescale));
+
+ static const __m128 mA1 = _mm_set1_ps(A1);
+ static const __m128 mA2 = _mm_set1_ps(A2);
+ static const __m128 mA3 = _mm_set1_ps(A3);
+ static const __m128 mA4 = _mm_set1_ps(A4);
+ bool y_aligned = (size_t)(void*)y % 16 == 0;
+
+ ushort CV_DECL_ALIGNED(16) tab_idx[8];
+
+ for( ; i <= n - 8; i += 8 )
+ {
+ __m128 xf0, xf1;
+ xf0 = _mm_loadu_ps(&x[i].f);
+ xf1 = _mm_loadu_ps(&x[i+4].f);
+ __m128i xi0, xi1, xi2, xi3;
+
+ xf0 = _mm_min_ps(_mm_max_ps(xf0, minval4), maxval4);
+ xf1 = _mm_min_ps(_mm_max_ps(xf1, minval4), maxval4);
+
+ __m128d xd0 = _mm_cvtps_pd(xf0);
+ __m128d xd2 = _mm_cvtps_pd(_mm_movehl_ps(xf0, xf0));
+ __m128d xd1 = _mm_cvtps_pd(xf1);
+ __m128d xd3 = _mm_cvtps_pd(_mm_movehl_ps(xf1, xf1));
+
+ xd0 = _mm_mul_pd(xd0, prescale2);
+ xd2 = _mm_mul_pd(xd2, prescale2);
+ xd1 = _mm_mul_pd(xd1, prescale2);
+ xd3 = _mm_mul_pd(xd3, prescale2);
+
+ xi0 = _mm_cvtpd_epi32(xd0);
+ xi2 = _mm_cvtpd_epi32(xd2);
+
+ xi1 = _mm_cvtpd_epi32(xd1);
+ xi3 = _mm_cvtpd_epi32(xd3);
+
+ xd0 = _mm_sub_pd(xd0, _mm_cvtepi32_pd(xi0));
+ xd2 = _mm_sub_pd(xd2, _mm_cvtepi32_pd(xi2));
+ xd1 = _mm_sub_pd(xd1, _mm_cvtepi32_pd(xi1));
+ xd3 = _mm_sub_pd(xd3, _mm_cvtepi32_pd(xi3));
+
+ xf0 = _mm_movelh_ps(_mm_cvtpd_ps(xd0), _mm_cvtpd_ps(xd2));
+ xf1 = _mm_movelh_ps(_mm_cvtpd_ps(xd1), _mm_cvtpd_ps(xd3));
+
+ xf0 = _mm_mul_ps(xf0, postscale4);
+ xf1 = _mm_mul_ps(xf1, postscale4);
+
+ xi0 = _mm_unpacklo_epi64(xi0, xi2);
+ xi1 = _mm_unpacklo_epi64(xi1, xi3);
+ xi0 = _mm_packs_epi32(xi0, xi1);
+
+ _mm_store_si128((__m128i*)tab_idx, _mm_and_si128(xi0, _mm_set1_epi16(EXPTAB_MASK)));
+
+ xi0 = _mm_add_epi16(_mm_srai_epi16(xi0, EXPTAB_SCALE), _mm_set1_epi16(127));
+ xi0 = _mm_max_epi16(xi0, _mm_setzero_si128());
+ xi0 = _mm_min_epi16(xi0, _mm_set1_epi16(255));
+ xi1 = _mm_unpackhi_epi16(xi0, _mm_setzero_si128());
+ xi0 = _mm_unpacklo_epi16(xi0, _mm_setzero_si128());
+
+ __m128d yd0 = _mm_unpacklo_pd(_mm_load_sd(expTab + tab_idx[0]), _mm_load_sd(expTab + tab_idx[1]));
+ __m128d yd1 = _mm_unpacklo_pd(_mm_load_sd(expTab + tab_idx[2]), _mm_load_sd(expTab + tab_idx[3]));
+ __m128d yd2 = _mm_unpacklo_pd(_mm_load_sd(expTab + tab_idx[4]), _mm_load_sd(expTab + tab_idx[5]));
+ __m128d yd3 = _mm_unpacklo_pd(_mm_load_sd(expTab + tab_idx[6]), _mm_load_sd(expTab + tab_idx[7]));
+
+ __m128 yf0 = _mm_movelh_ps(_mm_cvtpd_ps(yd0), _mm_cvtpd_ps(yd1));
+ __m128 yf1 = _mm_movelh_ps(_mm_cvtpd_ps(yd2), _mm_cvtpd_ps(yd3));
+
+ yf0 = _mm_mul_ps(yf0, _mm_castsi128_ps(_mm_slli_epi32(xi0, 23)));
+ yf1 = _mm_mul_ps(yf1, _mm_castsi128_ps(_mm_slli_epi32(xi1, 23)));
+
+ __m128 zf0 = _mm_add_ps(xf0, mA1);
+ __m128 zf1 = _mm_add_ps(xf1, mA1);
+
+ zf0 = _mm_add_ps(_mm_mul_ps(zf0, xf0), mA2);
+ zf1 = _mm_add_ps(_mm_mul_ps(zf1, xf1), mA2);
+
+ zf0 = _mm_add_ps(_mm_mul_ps(zf0, xf0), mA3);
+ zf1 = _mm_add_ps(_mm_mul_ps(zf1, xf1), mA3);
+
+ zf0 = _mm_add_ps(_mm_mul_ps(zf0, xf0), mA4);
+ zf1 = _mm_add_ps(_mm_mul_ps(zf1, xf1), mA4);
+
+ zf0 = _mm_mul_ps(zf0, yf0);
+ zf1 = _mm_mul_ps(zf1, yf1);
+
+ if( y_aligned )
+ {
+ _mm_store_ps(y + i, zf0);
+ _mm_store_ps(y + i + 4, zf1);
+ }
+ else
+ {
+ _mm_storeu_ps(y + i, zf0);
+ _mm_storeu_ps(y + i + 4, zf1);
+ }
+ }
+ }
+ else
+#endif
+ for( ; i <= n - 4; i += 4 )
+ {
+ double x0 = x[i].f * exp_prescale;
+ double x1 = x[i + 1].f * exp_prescale;
+ double x2 = x[i + 2].f * exp_prescale;
+ double x3 = x[i + 3].f * exp_prescale;
+ int val0, val1, val2, val3, t;
+
+ if( ((x[i].i >> 23) & 255) > 127 + 10 )
+ x0 = x[i].i < 0 ? -exp_max_val : exp_max_val;
+
+ if( ((x[i+1].i >> 23) & 255) > 127 + 10 )
+ x1 = x[i+1].i < 0 ? -exp_max_val : exp_max_val;
+
+ if( ((x[i+2].i >> 23) & 255) > 127 + 10 )
+ x2 = x[i+2].i < 0 ? -exp_max_val : exp_max_val;
+
+ if( ((x[i+3].i >> 23) & 255) > 127 + 10 )
+ x3 = x[i+3].i < 0 ? -exp_max_val : exp_max_val;
+
+ val0 = cvRound(x0);
+ val1 = cvRound(x1);
+ val2 = cvRound(x2);
+ val3 = cvRound(x3);
+
+ x0 = (x0 - val0)*exp_postscale;
+ x1 = (x1 - val1)*exp_postscale;
+ x2 = (x2 - val2)*exp_postscale;
+ x3 = (x3 - val3)*exp_postscale;
+
+ t = (val0 >> EXPTAB_SCALE) + 127;
+ t = !(t & ~255) ? t : t < 0 ? 0 : 255;
+ buf[0].i = t << 23;
+
+ t = (val1 >> EXPTAB_SCALE) + 127;
+ t = !(t & ~255) ? t : t < 0 ? 0 : 255;
+ buf[1].i = t << 23;
+
+ t = (val2 >> EXPTAB_SCALE) + 127;
+ t = !(t & ~255) ? t : t < 0 ? 0 : 255;
+ buf[2].i = t << 23;
+
+ t = (val3 >> EXPTAB_SCALE) + 127;
+ t = !(t & ~255) ? t : t < 0 ? 0 : 255;
+ buf[3].i = t << 23;
+
+ x0 = buf[0].f * expTab[val0 & EXPTAB_MASK] * EXPPOLY( x0 );
+ x1 = buf[1].f * expTab[val1 & EXPTAB_MASK] * EXPPOLY( x1 );
+
+ y[i] = (float)x0;
+ y[i + 1] = (float)x1;
+
+ x2 = buf[2].f * expTab[val2 & EXPTAB_MASK] * EXPPOLY( x2 );
+ x3 = buf[3].f * expTab[val3 & EXPTAB_MASK] * EXPPOLY( x3 );
+
+ y[i + 2] = (float)x2;
+ y[i + 3] = (float)x3;
+ }
+
+ for( ; i < n; i++ )
+ {
+ double x0 = x[i].f * exp_prescale;
+ int val0, t;
+
+ if( ((x[i].i >> 23) & 255) > 127 + 10 )
+ x0 = x[i].i < 0 ? -exp_max_val : exp_max_val;
+
+ val0 = cvRound(x0);
+ t = (val0 >> EXPTAB_SCALE) + 127;
+ t = !(t & ~255) ? t : t < 0 ? 0 : 255;
+
+ buf[0].i = t << 23;
+ x0 = (x0 - val0)*exp_postscale;
+
+ y[i] = (float)(buf[0].f * expTab[val0 & EXPTAB_MASK] * EXPPOLY(x0));
+ }
+}
+
+void exp64f( const double *_x, double *y, int n )
+{
+ CV_INSTRUMENT_REGION()
+
+ static const double
+ A5 = .99999999999999999998285227504999 / EXPPOLY_32F_A0,
+ A4 = .69314718055994546743029643825322 / EXPPOLY_32F_A0,
+ A3 = .24022650695886477918181338054308 / EXPPOLY_32F_A0,
+ A2 = .55504108793649567998466049042729e-1 / EXPPOLY_32F_A0,
+ A1 = .96180973140732918010002372686186e-2 / EXPPOLY_32F_A0,
+ A0 = .13369713757180123244806654839424e-2 / EXPPOLY_32F_A0;
+
+#undef EXPPOLY
+#define EXPPOLY(x) (((((A0*(x) + A1)*(x) + A2)*(x) + A3)*(x) + A4)*(x) + A5)
+
+ int i = 0;
+ Cv64suf buf[4];
+ const Cv64suf* x = (const Cv64suf*)_x;
+
+#if CV_SSE2
+ static const __m128d prescale2 = _mm_set1_pd(exp_prescale);
+ static const __m128d postscale2 = _mm_set1_pd(exp_postscale);
+ static const __m128d maxval2 = _mm_set1_pd(exp_max_val);
+ static const __m128d minval2 = _mm_set1_pd(-exp_max_val);
+
+ static const __m128d mA0 = _mm_set1_pd(A0);
+ static const __m128d mA1 = _mm_set1_pd(A1);
+ static const __m128d mA2 = _mm_set1_pd(A2);
+ static const __m128d mA3 = _mm_set1_pd(A3);
+ static const __m128d mA4 = _mm_set1_pd(A4);
+ static const __m128d mA5 = _mm_set1_pd(A5);
+
+ int CV_DECL_ALIGNED(16) tab_idx[4];
+
+ for( ; i <= n - 4; i += 4 )
+ {
+ __m128d xf0 = _mm_loadu_pd(&x[i].f), xf1 = _mm_loadu_pd(&x[i+2].f);
+ __m128i xi0, xi1;
+ xf0 = _mm_min_pd(_mm_max_pd(xf0, minval2), maxval2);
+ xf1 = _mm_min_pd(_mm_max_pd(xf1, minval2), maxval2);
+ xf0 = _mm_mul_pd(xf0, prescale2);
+ xf1 = _mm_mul_pd(xf1, prescale2);
+
+ xi0 = _mm_cvtpd_epi32(xf0);
+ xi1 = _mm_cvtpd_epi32(xf1);
+ xf0 = _mm_mul_pd(_mm_sub_pd(xf0, _mm_cvtepi32_pd(xi0)), postscale2);
+ xf1 = _mm_mul_pd(_mm_sub_pd(xf1, _mm_cvtepi32_pd(xi1)), postscale2);
+
+ xi0 = _mm_unpacklo_epi64(xi0, xi1);
+ _mm_store_si128((__m128i*)tab_idx, _mm_and_si128(xi0, _mm_set1_epi32(EXPTAB_MASK)));
+
+ xi0 = _mm_add_epi32(_mm_srai_epi32(xi0, EXPTAB_SCALE), _mm_set1_epi32(1023));
+ xi0 = _mm_packs_epi32(xi0, xi0);
+ xi0 = _mm_max_epi16(xi0, _mm_setzero_si128());
+ xi0 = _mm_min_epi16(xi0, _mm_set1_epi16(2047));
+ xi0 = _mm_unpacklo_epi16(xi0, _mm_setzero_si128());
+ xi1 = _mm_unpackhi_epi32(xi0, _mm_setzero_si128());
+ xi0 = _mm_unpacklo_epi32(xi0, _mm_setzero_si128());
+
+ __m128d yf0 = _mm_unpacklo_pd(_mm_load_sd(expTab + tab_idx[0]), _mm_load_sd(expTab + tab_idx[1]));
+ __m128d yf1 = _mm_unpacklo_pd(_mm_load_sd(expTab + tab_idx[2]), _mm_load_sd(expTab + tab_idx[3]));
+ yf0 = _mm_mul_pd(yf0, _mm_castsi128_pd(_mm_slli_epi64(xi0, 52)));
+ yf1 = _mm_mul_pd(yf1, _mm_castsi128_pd(_mm_slli_epi64(xi1, 52)));
+
+ __m128d zf0 = _mm_add_pd(_mm_mul_pd(mA0, xf0), mA1);
+ __m128d zf1 = _mm_add_pd(_mm_mul_pd(mA0, xf1), mA1);
+
+ zf0 = _mm_add_pd(_mm_mul_pd(zf0, xf0), mA2);
+ zf1 = _mm_add_pd(_mm_mul_pd(zf1, xf1), mA2);
+
+ zf0 = _mm_add_pd(_mm_mul_pd(zf0, xf0), mA3);
+ zf1 = _mm_add_pd(_mm_mul_pd(zf1, xf1), mA3);
+
+ zf0 = _mm_add_pd(_mm_mul_pd(zf0, xf0), mA4);
+ zf1 = _mm_add_pd(_mm_mul_pd(zf1, xf1), mA4);
+
+ zf0 = _mm_add_pd(_mm_mul_pd(zf0, xf0), mA5);
+ zf1 = _mm_add_pd(_mm_mul_pd(zf1, xf1), mA5);
+
+ zf0 = _mm_mul_pd(zf0, yf0);
+ zf1 = _mm_mul_pd(zf1, yf1);
+
+ _mm_storeu_pd(y + i, zf0);
+ _mm_storeu_pd(y + i + 2, zf1);
+ }
+#endif
+ for( ; i <= n - 4; i += 4 )
+ {
+ double x0 = x[i].f * exp_prescale;
+ double x1 = x[i + 1].f * exp_prescale;
+ double x2 = x[i + 2].f * exp_prescale;
+ double x3 = x[i + 3].f * exp_prescale;
+
+ double y0, y1, y2, y3;
+ int val0, val1, val2, val3, t;
+
+ t = (int)(x[i].i >> 52);
+ if( (t & 2047) > 1023 + 10 )
+ x0 = t < 0 ? -exp_max_val : exp_max_val;
+
+ t = (int)(x[i+1].i >> 52);
+ if( (t & 2047) > 1023 + 10 )
+ x1 = t < 0 ? -exp_max_val : exp_max_val;
+
+ t = (int)(x[i+2].i >> 52);
+ if( (t & 2047) > 1023 + 10 )
+ x2 = t < 0 ? -exp_max_val : exp_max_val;
+
+ t = (int)(x[i+3].i >> 52);
+ if( (t & 2047) > 1023 + 10 )
+ x3 = t < 0 ? -exp_max_val : exp_max_val;
+
+ val0 = cvRound(x0);
+ val1 = cvRound(x1);
+ val2 = cvRound(x2);
+ val3 = cvRound(x3);
+
+ x0 = (x0 - val0)*exp_postscale;
+ x1 = (x1 - val1)*exp_postscale;
+ x2 = (x2 - val2)*exp_postscale;
+ x3 = (x3 - val3)*exp_postscale;
+
+ t = (val0 >> EXPTAB_SCALE) + 1023;
+ t = !(t & ~2047) ? t : t < 0 ? 0 : 2047;
+ buf[0].i = (int64)t << 52;
+
+ t = (val1 >> EXPTAB_SCALE) + 1023;
+ t = !(t & ~2047) ? t : t < 0 ? 0 : 2047;
+ buf[1].i = (int64)t << 52;
+
+ t = (val2 >> EXPTAB_SCALE) + 1023;
+ t = !(t & ~2047) ? t : t < 0 ? 0 : 2047;
+ buf[2].i = (int64)t << 52;
+
+ t = (val3 >> EXPTAB_SCALE) + 1023;
+ t = !(t & ~2047) ? t : t < 0 ? 0 : 2047;
+ buf[3].i = (int64)t << 52;
+
+ y0 = buf[0].f * expTab[val0 & EXPTAB_MASK] * EXPPOLY( x0 );
+ y1 = buf[1].f * expTab[val1 & EXPTAB_MASK] * EXPPOLY( x1 );
+
+ y[i] = y0;
+ y[i + 1] = y1;
+
+ y2 = buf[2].f * expTab[val2 & EXPTAB_MASK] * EXPPOLY( x2 );
+ y3 = buf[3].f * expTab[val3 & EXPTAB_MASK] * EXPPOLY( x3 );
+
+ y[i + 2] = y2;
+ y[i + 3] = y3;
+ }
+
+ for( ; i < n; i++ )
+ {
+ double x0 = x[i].f * exp_prescale;
+ int val0, t;
+
+ t = (int)(x[i].i >> 52);
+ if( (t & 2047) > 1023 + 10 )
+ x0 = t < 0 ? -exp_max_val : exp_max_val;
+
+ val0 = cvRound(x0);
+ t = (val0 >> EXPTAB_SCALE) + 1023;
+ t = !(t & ~2047) ? t : t < 0 ? 0 : 2047;
+
+ buf[0].i = (int64)t << 52;
+ x0 = (x0 - val0)*exp_postscale;
+
+ y[i] = buf[0].f * expTab[val0 & EXPTAB_MASK] * EXPPOLY( x0 );
+ }
+}
+
+#undef EXPTAB_SCALE
+#undef EXPTAB_MASK
+#undef EXPPOLY_32F_A0
+
+/////////////////////////////////////////// LOG ///////////////////////////////////////
+
+#define LOGTAB_SCALE 8
+#define LOGTAB_MASK ((1 << LOGTAB_SCALE) - 1)
+#define LOGTAB_MASK2 ((1 << (20 - LOGTAB_SCALE)) - 1)
+#define LOGTAB_MASK2_32F ((1 << (23 - LOGTAB_SCALE)) - 1)
+
+static const double CV_DECL_ALIGNED(16) icvLogTab[] = {
+ 0.0000000000000000000000000000000000000000, 1.000000000000000000000000000000000000000,
+ .00389864041565732288852075271279318258166, .9961089494163424124513618677042801556420,
+ .00778214044205494809292034119607706088573, .9922480620155038759689922480620155038760,
+ .01165061721997527263705585198749759001657, .9884169884169884169884169884169884169884,
+ .01550418653596525274396267235488267033361, .9846153846153846153846153846153846153846,
+ .01934296284313093139406447562578250654042, .9808429118773946360153256704980842911877,
+ .02316705928153437593630670221500622574241, .9770992366412213740458015267175572519084,
+ .02697658769820207233514075539915211265906, .9733840304182509505703422053231939163498,
+ .03077165866675368732785500469617545604706, .9696969696969696969696969696969696969697,
+ .03455238150665972812758397481047722976656, .9660377358490566037735849056603773584906,
+ .03831886430213659461285757856785494368522, .9624060150375939849624060150375939849624,
+ .04207121392068705056921373852674150839447, .9588014981273408239700374531835205992509,
+ .04580953603129420126371940114040626212953, .9552238805970149253731343283582089552239,
+ .04953393512227662748292900118940451648088, .9516728624535315985130111524163568773234,
+ .05324451451881227759255210685296333394944, .9481481481481481481481481481481481481481,
+ .05694137640013842427411105973078520037234, .9446494464944649446494464944649446494465,
+ .06062462181643483993820353816772694699466, .9411764705882352941176470588235294117647,
+ .06429435070539725460836422143984236754475, .9377289377289377289377289377289377289377,
+ .06795066190850773679699159401934593915938, .9343065693430656934306569343065693430657,
+ .07159365318700880442825962290953611955044, .9309090909090909090909090909090909090909,
+ .07522342123758751775142172846244648098944, .9275362318840579710144927536231884057971,
+ .07884006170777602129362549021607264876369, .9241877256317689530685920577617328519856,
+ .08244366921107458556772229485432035289706, .9208633093525179856115107913669064748201,
+ .08603433734180314373940490213499288074675, .9175627240143369175627240143369175627240,
+ .08961215868968712416897659522874164395031, .9142857142857142857142857142857142857143,
+ .09317722485418328259854092721070628613231, .9110320284697508896797153024911032028470,
+ .09672962645855109897752299730200320482256, .9078014184397163120567375886524822695035,
+ .10026945316367513738597949668474029749630, .9045936395759717314487632508833922261484,
+ .10379679368164355934833764649738441221420, .9014084507042253521126760563380281690141,
+ .10731173578908805021914218968959175981580, .8982456140350877192982456140350877192982,
+ .11081436634029011301105782649756292812530, .8951048951048951048951048951048951048951,
+ .11430477128005862852422325204315711744130, .8919860627177700348432055749128919860627,
+ .11778303565638344185817487641543266363440, .8888888888888888888888888888888888888889,
+ .12124924363286967987640707633545389398930, .8858131487889273356401384083044982698962,
+ .12470347850095722663787967121606925502420, .8827586206896551724137931034482758620690,
+ .12814582269193003360996385708858724683530, .8797250859106529209621993127147766323024,
+ .13157635778871926146571524895989568904040, .8767123287671232876712328767123287671233,
+ .13499516453750481925766280255629681050780, .8737201365187713310580204778156996587031,
+ .13840232285911913123754857224412262439730, .8707482993197278911564625850340136054422,
+ .14179791186025733629172407290752744302150, .8677966101694915254237288135593220338983,
+ .14518200984449788903951628071808954700830, .8648648648648648648648648648648648648649,
+ .14855469432313711530824207329715136438610, .8619528619528619528619528619528619528620,
+ .15191604202584196858794030049466527998450, .8590604026845637583892617449664429530201,
+ .15526612891112392955683674244937719777230, .8561872909698996655518394648829431438127,
+ .15860503017663857283636730244325008243330, .8533333333333333333333333333333333333333,
+ .16193282026931324346641360989451641216880, .8504983388704318936877076411960132890365,
+ .16524957289530714521497145597095368430010, .8476821192052980132450331125827814569536,
+ .16855536102980664403538924034364754334090, .8448844884488448844884488448844884488449,
+ .17185025692665920060697715143760433420540, .8421052631578947368421052631578947368421,
+ .17513433212784912385018287750426679849630, .8393442622950819672131147540983606557377,
+ .17840765747281828179637841458315961062910, .8366013071895424836601307189542483660131,
+ .18167030310763465639212199675966985523700, .8338762214983713355048859934853420195440,
+ .18492233849401198964024217730184318497780, .8311688311688311688311688311688311688312,
+ .18816383241818296356839823602058459073300, .8284789644012944983818770226537216828479,
+ .19139485299962943898322009772527962923050, .8258064516129032258064516129032258064516,
+ .19461546769967164038916962454095482826240, .8231511254019292604501607717041800643087,
+ .19782574332991986754137769821682013571260, .8205128205128205128205128205128205128205,
+ .20102574606059073203390141770796617493040, .8178913738019169329073482428115015974441,
+ .20421554142869088876999228432396193966280, .8152866242038216560509554140127388535032,
+ .20739519434607056602715147164417430758480, .8126984126984126984126984126984126984127,
+ .21056476910734961416338251183333341032260, .8101265822784810126582278481012658227848,
+ .21372432939771812687723695489694364368910, .8075709779179810725552050473186119873817,
+ .21687393830061435506806333251006435602900, .8050314465408805031446540880503144654088,
+ .22001365830528207823135744547471404075630, .8025078369905956112852664576802507836991,
+ .22314355131420973710199007200571941211830, .8000000000000000000000000000000000000000,
+ .22626367865045338145790765338460914790630, .7975077881619937694704049844236760124611,
+ .22937410106484582006380890106811420992010, .7950310559006211180124223602484472049689,
+ .23247487874309405442296849741978803649550, .7925696594427244582043343653250773993808,
+ .23556607131276688371634975283086532726890, .7901234567901234567901234567901234567901,
+ .23864773785017498464178231643018079921600, .7876923076923076923076923076923076923077,
+ .24171993688714515924331749374687206000090, .7852760736196319018404907975460122699387,
+ .24478272641769091566565919038112042471760, .7828746177370030581039755351681957186544,
+ .24783616390458124145723672882013488560910, .7804878048780487804878048780487804878049,
+ .25088030628580937353433455427875742316250, .7781155015197568389057750759878419452888,
+ .25391520998096339667426946107298135757450, .7757575757575757575757575757575757575758,
+ .25694093089750041913887912414793390780680, .7734138972809667673716012084592145015106,
+ .25995752443692604627401010475296061486000, .7710843373493975903614457831325301204819,
+ .26296504550088134477547896494797896593800, .7687687687687687687687687687687687687688,
+ .26596354849713793599974565040611196309330, .7664670658682634730538922155688622754491,
+ .26895308734550393836570947314612567424780, .7641791044776119402985074626865671641791,
+ .27193371548364175804834985683555714786050, .7619047619047619047619047619047619047619,
+ .27490548587279922676529508862586226314300, .7596439169139465875370919881305637982196,
+ .27786845100345625159121709657483734190480, .7573964497041420118343195266272189349112,
+ .28082266290088775395616949026589281857030, .7551622418879056047197640117994100294985,
+ .28376817313064456316240580235898960381750, .7529411764705882352941176470588235294118,
+ .28670503280395426282112225635501090437180, .7507331378299120234604105571847507331378,
+ .28963329258304265634293983566749375313530, .7485380116959064327485380116959064327485,
+ .29255300268637740579436012922087684273730, .7463556851311953352769679300291545189504,
+ .29546421289383584252163927885703742504130, .7441860465116279069767441860465116279070,
+ .29836697255179722709783618483925238251680, .7420289855072463768115942028985507246377,
+ .30126133057816173455023545102449133992200, .7398843930635838150289017341040462427746,
+ .30414733546729666446850615102448500692850, .7377521613832853025936599423631123919308,
+ .30702503529491181888388950937951449304830, .7356321839080459770114942528735632183908,
+ .30989447772286465854207904158101882785550, .7335243553008595988538681948424068767908,
+ .31275571000389684739317885942000430077330, .7314285714285714285714285714285714285714,
+ .31560877898630329552176476681779604405180, .7293447293447293447293447293447293447293,
+ .31845373111853458869546784626436419785030, .7272727272727272727272727272727272727273,
+ .32129061245373424782201254856772720813750, .7252124645892351274787535410764872521246,
+ .32411946865421192853773391107097268104550, .7231638418079096045197740112994350282486,
+ .32694034499585328257253991068864706903700, .7211267605633802816901408450704225352113,
+ .32975328637246797969240219572384376078850, .7191011235955056179775280898876404494382,
+ .33255833730007655635318997155991382896900, .7170868347338935574229691876750700280112,
+ .33535554192113781191153520921943709254280, .7150837988826815642458100558659217877095,
+ .33814494400871636381467055798566434532400, .7130919220055710306406685236768802228412,
+ .34092658697059319283795275623560883104800, .7111111111111111111111111111111111111111,
+ .34370051385331840121395430287520866841080, .7091412742382271468144044321329639889197,
+ .34646676734620857063262633346312213689100, .7071823204419889502762430939226519337017,
+ .34922538978528827602332285096053965389730, .7052341597796143250688705234159779614325,
+ .35197642315717814209818925519357435405250, .7032967032967032967032967032967032967033,
+ .35471990910292899856770532096561510115850, .7013698630136986301369863013698630136986,
+ .35745588892180374385176833129662554711100, .6994535519125683060109289617486338797814,
+ .36018440357500774995358483465679455548530, .6975476839237057220708446866485013623978,
+ .36290549368936841911903457003063522279280, .6956521739130434782608695652173913043478,
+ .36561919956096466943762379742111079394830, .6937669376693766937669376693766937669377,
+ .36832556115870762614150635272380895912650, .6918918918918918918918918918918918918919,
+ .37102461812787262962487488948681857436900, .6900269541778975741239892183288409703504,
+ .37371640979358405898480555151763837784530, .6881720430107526881720430107526881720430,
+ .37640097516425302659470730759494472295050, .6863270777479892761394101876675603217158,
+ .37907835293496944251145919224654790014030, .6844919786096256684491978609625668449198,
+ .38174858149084833769393299007788300514230, .6826666666666666666666666666666666666667,
+ .38441169891033200034513583887019194662580, .6808510638297872340425531914893617021277,
+ .38706774296844825844488013899535872042180, .6790450928381962864721485411140583554377,
+ .38971675114002518602873692543653305619950, .6772486772486772486772486772486772486772,
+ .39235876060286384303665840889152605086580, .6754617414248021108179419525065963060686,
+ .39499380824086893770896722344332374632350, .6736842105263157894736842105263157894737,
+ .39762193064713846624158577469643205404280, .6719160104986876640419947506561679790026,
+ .40024316412701266276741307592601515352730, .6701570680628272251308900523560209424084,
+ .40285754470108348090917615991202183067800, .6684073107049608355091383812010443864230,
+ .40546510810816432934799991016916465014230, .6666666666666666666666666666666666666667,
+ .40806588980822172674223224930756259709600, .6649350649350649350649350649350649350649,
+ .41065992498526837639616360320360399782650, .6632124352331606217616580310880829015544,
+ .41324724855021932601317757871584035456180, .6614987080103359173126614987080103359173,
+ .41582789514371093497757669865677598863850, .6597938144329896907216494845360824742268,
+ .41840189913888381489925905043492093682300, .6580976863753213367609254498714652956298,
+ .42096929464412963239894338585145305842150, .6564102564102564102564102564102564102564,
+ .42353011550580327293502591601281892508280, .6547314578005115089514066496163682864450,
+ .42608439531090003260516141381231136620050, .6530612244897959183673469387755102040816,
+ .42863216738969872610098832410585600882780, .6513994910941475826972010178117048346056,
+ .43117346481837132143866142541810404509300, .6497461928934010152284263959390862944162,
+ .43370832042155937902094819946796633303180, .6481012658227848101265822784810126582278,
+ .43623676677491801667585491486534010618930, .6464646464646464646464646464646464646465,
+ .43875883620762790027214350629947148263450, .6448362720403022670025188916876574307305,
+ .44127456080487520440058801796112675219780, .6432160804020100502512562814070351758794,
+ .44378397241030093089975139264424797147500, .6416040100250626566416040100250626566416,
+ .44628710262841947420398014401143882423650, .6400000000000000000000000000000000000000,
+ .44878398282700665555822183705458883196130, .6384039900249376558603491271820448877805,
+ .45127464413945855836729492693848442286250, .6368159203980099502487562189054726368159,
+ .45375911746712049854579618113348260521900, .6352357320099255583126550868486352357320,
+ .45623743348158757315857769754074979573500, .6336633663366336633663366336633663366337,
+ .45870962262697662081833982483658473938700, .6320987654320987654320987654320987654321,
+ .46117571512217014895185229761409573256980, .6305418719211822660098522167487684729064,
+ .46363574096303250549055974261136725544930, .6289926289926289926289926289926289926290,
+ .46608972992459918316399125615134835243230, .6274509803921568627450980392156862745098,
+ .46853771156323925639597405279346276074650, .6259168704156479217603911980440097799511,
+ .47097971521879100631480241645476780831830, .6243902439024390243902439024390243902439,
+ .47341577001667212165614273544633761048330, .6228710462287104622871046228710462287105,
+ .47584590486996386493601107758877333253630, .6213592233009708737864077669902912621359,
+ .47827014848147025860569669930555392056700, .6198547215496368038740920096852300242131,
+ .48068852934575190261057286988943815231330, .6183574879227053140096618357487922705314,
+ .48310107575113581113157579238759353756900, .6168674698795180722891566265060240963855,
+ .48550781578170076890899053978500887751580, .6153846153846153846153846153846153846154,
+ .48790877731923892879351001283794175833480, .6139088729016786570743405275779376498801,
+ .49030398804519381705802061333088204264650, .6124401913875598086124401913875598086124,
+ .49269347544257524607047571407747454941280, .6109785202863961813842482100238663484487,
+ .49507726679785146739476431321236304938800, .6095238095238095238095238095238095238095,
+ .49745538920281889838648226032091770321130, .6080760095011876484560570071258907363420,
+ .49982786955644931126130359189119189977650, .6066350710900473933649289099526066350711,
+ .50219473456671548383667413872899487614650, .6052009456264775413711583924349881796690,
+ .50455601075239520092452494282042607665050, .6037735849056603773584905660377358490566,
+ .50691172444485432801997148999362252652650, .6023529411764705882352941176470588235294,
+ .50926190178980790257412536448100581765150, .6009389671361502347417840375586854460094,
+ .51160656874906207391973111953120678663250, .5995316159250585480093676814988290398126,
+ .51394575110223428282552049495279788970950, .5981308411214953271028037383177570093458,
+ .51627947444845445623684554448118433356300, .5967365967365967365967365967365967365967,
+ .51860776420804555186805373523384332656850, .5953488372093023255813953488372093023256,
+ .52093064562418522900344441950437612831600, .5939675174013921113689095127610208816705,
+ .52324814376454775732838697877014055848100, .5925925925925925925925925925925925925926,
+ .52556028352292727401362526507000438869000, .5912240184757505773672055427251732101617,
+ .52786708962084227803046587723656557500350, .5898617511520737327188940092165898617512,
+ .53016858660912158374145519701414741575700, .5885057471264367816091954022988505747126,
+ .53246479886947173376654518506256863474850, .5871559633027522935779816513761467889908,
+ .53475575061602764748158733709715306758900, .5858123569794050343249427917620137299771,
+ .53704146589688361856929077475797384977350, .5844748858447488584474885844748858447489,
+ .53932196859560876944783558428753167390800, .5831435079726651480637813211845102505695,
+ .54159728243274429804188230264117009937750, .5818181818181818181818181818181818181818,
+ .54386743096728351609669971367111429572100, .5804988662131519274376417233560090702948,
+ .54613243759813556721383065450936555862450, .5791855203619909502262443438914027149321,
+ .54839232556557315767520321969641372561450, .5778781038374717832957110609480812641084,
+ .55064711795266219063194057525834068655950, .5765765765765765765765765765765765765766,
+ .55289683768667763352766542084282264113450, .5752808988764044943820224719101123595506,
+ .55514150754050151093110798683483153581600, .5739910313901345291479820627802690582960,
+ .55738115013400635344709144192165695130850, .5727069351230425055928411633109619686801,
+ .55961578793542265941596269840374588966350, .5714285714285714285714285714285714285714,
+ .56184544326269181269140062795486301183700, .5701559020044543429844097995545657015590,
+ .56407013828480290218436721261241473257550, .5688888888888888888888888888888888888889,
+ .56628989502311577464155334382667206227800, .5676274944567627494456762749445676274945,
+ .56850473535266865532378233183408156037350, .5663716814159292035398230088495575221239,
+ .57071468100347144680739575051120482385150, .5651214128035320088300220750551876379691,
+ .57291975356178548306473885531886480748650, .5638766519823788546255506607929515418502,
+ .57511997447138785144460371157038025558000, .5626373626373626373626373626373626373626,
+ .57731536503482350219940144597785547375700, .5614035087719298245614035087719298245614,
+ .57950594641464214795689713355386629700650, .5601750547045951859956236323851203501094,
+ .58169173963462239562716149521293118596100, .5589519650655021834061135371179039301310,
+ .58387276558098266665552955601015128195300, .5577342047930283224400871459694989106754,
+ .58604904500357812846544902640744112432000, .5565217391304347826086956521739130434783,
+ .58822059851708596855957011939608491957200, .5553145336225596529284164859002169197397,
+ .59038744660217634674381770309992134571100, .5541125541125541125541125541125541125541,
+ .59254960960667157898740242671919986605650, .5529157667386609071274298056155507559395,
+ .59470710774669277576265358220553025603300, .5517241379310344827586206896551724137931,
+ .59685996110779382384237123915227130055450, .5505376344086021505376344086021505376344,
+ .59900818964608337768851242799428291618800, .5493562231759656652360515021459227467811,
+ .60115181318933474940990890900138765573500, .5481798715203426124197002141327623126338,
+ .60329085143808425240052883964381180703650, .5470085470085470085470085470085470085470,
+ .60542532396671688843525771517306566238400, .5458422174840085287846481876332622601279,
+ .60755525022454170969155029524699784815300, .5446808510638297872340425531914893617021,
+ .60968064953685519036241657886421307921400, .5435244161358811040339702760084925690021,
+ .61180154110599282990534675263916142284850, .5423728813559322033898305084745762711864,
+ .61391794401237043121710712512140162289150, .5412262156448202959830866807610993657505,
+ .61602987721551394351138242200249806046500, .5400843881856540084388185654008438818565,
+ .61813735955507864705538167982012964785100, .5389473684210526315789473684210526315789,
+ .62024040975185745772080281312810257077200, .5378151260504201680672268907563025210084,
+ .62233904640877868441606324267922900617100, .5366876310272536687631027253668763102725,
+ .62443328801189346144440150965237990021700, .5355648535564853556485355648535564853556,
+ .62652315293135274476554741340805776417250, .5344467640918580375782881002087682672234,
+ .62860865942237409420556559780379757285100, .5333333333333333333333333333333333333333,
+ .63068982562619868570408243613201193511500, .5322245322245322245322245322245322245322,
+ .63276666957103777644277897707070223987100, .5311203319502074688796680497925311203320,
+ .63483920917301017716738442686619237065300, .5300207039337474120082815734989648033126,
+ .63690746223706917739093569252872839570050, .5289256198347107438016528925619834710744,
+ .63897144645792069983514238629140891134750, .5278350515463917525773195876288659793814,
+ .64103117942093124081992527862894348800200, .5267489711934156378600823045267489711934,
+ .64308667860302726193566513757104985415950, .5256673511293634496919917864476386036961,
+ .64513796137358470073053240412264131009600, .5245901639344262295081967213114754098361,
+ .64718504499530948859131740391603671014300, .5235173824130879345603271983640081799591,
+ .64922794662510974195157587018911726772800, .5224489795918367346938775510204081632653,
+ .65126668331495807251485530287027359008800, .5213849287169042769857433808553971486762,
+ .65330127201274557080523663898929953575150, .5203252032520325203252032520325203252033,
+ .65533172956312757406749369692988693714150, .5192697768762677484787018255578093306288,
+ .65735807270835999727154330685152672231200, .5182186234817813765182186234817813765182,
+ .65938031808912778153342060249997302889800, .5171717171717171717171717171717171717172,
+ .66139848224536490484126716182800009846700, .5161290322580645161290322580645161290323,
+ .66341258161706617713093692145776003599150, .5150905432595573440643863179074446680080,
+ .66542263254509037562201001492212526500250, .5140562248995983935742971887550200803213,
+ .66742865127195616370414654738851822912700, .5130260521042084168336673346693386773547,
+ .66943065394262923906154583164607174694550, .5120000000000000000000000000000000000000,
+ .67142865660530226534774556057527661323550, .5109780439121756487025948103792415169661,
+ .67342267521216669923234121597488410770900, .5099601593625498007968127490039840637450,
+ .67541272562017662384192817626171745359900, .5089463220675944333996023856858846918489,
+ .67739882359180603188519853574689477682100, .5079365079365079365079365079365079365079,
+ .67938098479579733801614338517538271844400, .5069306930693069306930693069306930693069,
+ .68135922480790300781450241629499942064300, .5059288537549407114624505928853754940711,
+ .68333355911162063645036823800182901322850, .5049309664694280078895463510848126232742,
+ .68530400309891936760919861626462079584600, .5039370078740157480314960629921259842520,
+ .68727057207096020619019327568821609020250, .5029469548133595284872298624754420432220,
+ .68923328123880889251040571252815425395950, .5019607843137254901960784313725490196078,
+ .69314718055994530941723212145818, 5.0e-01,
+};
+
+
+
+#define LOGTAB_TRANSLATE(x,h) (((x) - 1.)*icvLogTab[(h)+1])
+static const double ln_2 = 0.69314718055994530941723212145818;
+
+void log32f( const float *_x, float *y, int n )
+{
+ CV_INSTRUMENT_REGION()
+
+ static const float shift[] = { 0, -1.f/512 };
+ static const float
+ A0 = 0.3333333333333333333333333f,
+ A1 = -0.5f,
+ A2 = 1.f;
+
+#undef LOGPOLY
+#define LOGPOLY(x) (((A0*(x) + A1)*(x) + A2)*(x))
+
+ int i = 0;
+ Cv32suf buf[4];
+ const int* x = (const int*)_x;
+
+#if CV_SSE2
+ static const __m128d ln2_2 = _mm_set1_pd(ln_2);
+ static const __m128 _1_4 = _mm_set1_ps(1.f);
+ static const __m128 shift4 = _mm_set1_ps(-1.f/512);
+
+ static const __m128 mA0 = _mm_set1_ps(A0);
+ static const __m128 mA1 = _mm_set1_ps(A1);
+ static const __m128 mA2 = _mm_set1_ps(A2);
+
+ int CV_DECL_ALIGNED(16) idx[4];
+
+ for( ; i <= n - 4; i += 4 )
+ {
+ __m128i h0 = _mm_loadu_si128((const __m128i*)(x + i));
+ __m128i yi0 = _mm_sub_epi32(_mm_and_si128(_mm_srli_epi32(h0, 23), _mm_set1_epi32(255)), _mm_set1_epi32(127));
+ __m128d yd0 = _mm_mul_pd(_mm_cvtepi32_pd(yi0), ln2_2);
+ __m128d yd1 = _mm_mul_pd(_mm_cvtepi32_pd(_mm_unpackhi_epi64(yi0,yi0)), ln2_2);
+
+ __m128i xi0 = _mm_or_si128(_mm_and_si128(h0, _mm_set1_epi32(LOGTAB_MASK2_32F)), _mm_set1_epi32(127 << 23));
+
+ h0 = _mm_and_si128(_mm_srli_epi32(h0, 23 - LOGTAB_SCALE - 1), _mm_set1_epi32(LOGTAB_MASK*2));
+ _mm_store_si128((__m128i*)idx, h0);
+ h0 = _mm_cmpeq_epi32(h0, _mm_set1_epi32(510));
+
+ __m128d t0, t1, t2, t3, t4;
+ t0 = _mm_load_pd(icvLogTab + idx[0]);
+ t2 = _mm_load_pd(icvLogTab + idx[1]);
+ t1 = _mm_unpackhi_pd(t0, t2);
+ t0 = _mm_unpacklo_pd(t0, t2);
+ t2 = _mm_load_pd(icvLogTab + idx[2]);
+ t4 = _mm_load_pd(icvLogTab + idx[3]);
+ t3 = _mm_unpackhi_pd(t2, t4);
+ t2 = _mm_unpacklo_pd(t2, t4);
+
+ yd0 = _mm_add_pd(yd0, t0);
+ yd1 = _mm_add_pd(yd1, t2);
+
+ __m128 yf0 = _mm_movelh_ps(_mm_cvtpd_ps(yd0), _mm_cvtpd_ps(yd1));
+
+ __m128 xf0 = _mm_sub_ps(_mm_castsi128_ps(xi0), _1_4);
+ xf0 = _mm_mul_ps(xf0, _mm_movelh_ps(_mm_cvtpd_ps(t1), _mm_cvtpd_ps(t3)));
+ xf0 = _mm_add_ps(xf0, _mm_and_ps(_mm_castsi128_ps(h0), shift4));
+
+ __m128 zf0 = _mm_mul_ps(xf0, mA0);
+ zf0 = _mm_mul_ps(_mm_add_ps(zf0, mA1), xf0);
+ zf0 = _mm_mul_ps(_mm_add_ps(zf0, mA2), xf0);
+ yf0 = _mm_add_ps(yf0, zf0);
+
+ _mm_storeu_ps(y + i, yf0);
+ }
+#endif
+ for( ; i <= n - 4; i += 4 )
+ {
+ double x0, x1, x2, x3;
+ double y0, y1, y2, y3;
+ int h0, h1, h2, h3;
+
+ h0 = x[i];
+ h1 = x[i+1];
+ buf[0].i = (h0 & LOGTAB_MASK2_32F) | (127 << 23);
+ buf[1].i = (h1 & LOGTAB_MASK2_32F) | (127 << 23);
+
+ y0 = (((h0 >> 23) & 0xff) - 127) * ln_2;
+ y1 = (((h1 >> 23) & 0xff) - 127) * ln_2;
+
+ h0 = (h0 >> (23 - LOGTAB_SCALE - 1)) & LOGTAB_MASK * 2;
+ h1 = (h1 >> (23 - LOGTAB_SCALE - 1)) & LOGTAB_MASK * 2;
+
+ y0 += icvLogTab[h0];
+ y1 += icvLogTab[h1];
+
+ h2 = x[i+2];
+ h3 = x[i+3];
+
+ x0 = LOGTAB_TRANSLATE( buf[0].f, h0 );
+ x1 = LOGTAB_TRANSLATE( buf[1].f, h1 );
+
+ buf[2].i = (h2 & LOGTAB_MASK2_32F) | (127 << 23);
+ buf[3].i = (h3 & LOGTAB_MASK2_32F) | (127 << 23);
+
+ y2 = (((h2 >> 23) & 0xff) - 127) * ln_2;
+ y3 = (((h3 >> 23) & 0xff) - 127) * ln_2;
+
+ h2 = (h2 >> (23 - LOGTAB_SCALE - 1)) & LOGTAB_MASK * 2;
+ h3 = (h3 >> (23 - LOGTAB_SCALE - 1)) & LOGTAB_MASK * 2;
+
+ y2 += icvLogTab[h2];
+ y3 += icvLogTab[h3];
+
+ x2 = LOGTAB_TRANSLATE( buf[2].f, h2 );
+ x3 = LOGTAB_TRANSLATE( buf[3].f, h3 );
+
+ x0 += shift[h0 == 510];
+ x1 += shift[h1 == 510];
+ y0 += LOGPOLY( x0 );
+ y1 += LOGPOLY( x1 );
+
+ y[i] = (float) y0;
+ y[i + 1] = (float) y1;
+
+ x2 += shift[h2 == 510];
+ x3 += shift[h3 == 510];
+ y2 += LOGPOLY( x2 );
+ y3 += LOGPOLY( x3 );
+
+ y[i + 2] = (float) y2;
+ y[i + 3] = (float) y3;
+ }
+
+ for( ; i < n; i++ )
+ {
+ int h0 = x[i];
+ double y0;
+ float x0;
+
+ y0 = (((h0 >> 23) & 0xff) - 127) * ln_2;
+
+ buf[0].i = (h0 & LOGTAB_MASK2_32F) | (127 << 23);
+ h0 = (h0 >> (23 - LOGTAB_SCALE - 1)) & LOGTAB_MASK * 2;
+
+ y0 += icvLogTab[h0];
+ x0 = (float)LOGTAB_TRANSLATE( buf[0].f, h0 );
+ x0 += shift[h0 == 510];
+ y0 += LOGPOLY( x0 );
+
+ y[i] = (float)y0;
+ }
+}
+
+void log64f( const double *x, double *y, int n )
+{
+ CV_INSTRUMENT_REGION()
+
+ static const double shift[] = { 0, -1./512 };
+ static const double
+ A7 = 1.0,
+ A6 = -0.5,
+ A5 = 0.333333333333333314829616256247390992939472198486328125,
+ A4 = -0.25,
+ A3 = 0.2,
+ A2 = -0.1666666666666666574148081281236954964697360992431640625,
+ A1 = 0.1428571428571428769682682968777953647077083587646484375,
+ A0 = -0.125;
+
+#undef LOGPOLY
+#define LOGPOLY(x,k) ((x)+=shift[k], xq = (x)*(x),\
+(((A0*xq + A2)*xq + A4)*xq + A6)*xq + \
+(((A1*xq + A3)*xq + A5)*xq + A7)*(x))
+
+ int i = 0;
+ DBLINT buf[4];
+ DBLINT *X = (DBLINT *) x;
+
+#if CV_SSE2
+ static const __m128d ln2_2 = _mm_set1_pd(ln_2);
+ static const __m128d _1_2 = _mm_set1_pd(1.);
+ static const __m128d shift2 = _mm_set1_pd(-1./512);
+
+ static const __m128i log_and_mask2 = _mm_set_epi32(LOGTAB_MASK2, 0xffffffff, LOGTAB_MASK2, 0xffffffff);
+ static const __m128i log_or_mask2 = _mm_set_epi32(1023 << 20, 0, 1023 << 20, 0);
+
+ static const __m128d mA0 = _mm_set1_pd(A0);
+ static const __m128d mA1 = _mm_set1_pd(A1);
+ static const __m128d mA2 = _mm_set1_pd(A2);
+ static const __m128d mA3 = _mm_set1_pd(A3);
+ static const __m128d mA4 = _mm_set1_pd(A4);
+ static const __m128d mA5 = _mm_set1_pd(A5);
+ static const __m128d mA6 = _mm_set1_pd(A6);
+ static const __m128d mA7 = _mm_set1_pd(A7);
+
+ int CV_DECL_ALIGNED(16) idx[4];
+
+ for( ; i <= n - 4; i += 4 )
+ {
+ __m128i h0 = _mm_loadu_si128((const __m128i*)(x + i));
+ __m128i h1 = _mm_loadu_si128((const __m128i*)(x + i + 2));
+
+ __m128d xd0 = _mm_castsi128_pd(_mm_or_si128(_mm_and_si128(h0, log_and_mask2), log_or_mask2));
+ __m128d xd1 = _mm_castsi128_pd(_mm_or_si128(_mm_and_si128(h1, log_and_mask2), log_or_mask2));
+
+ h0 = _mm_unpackhi_epi32(_mm_unpacklo_epi32(h0, h1), _mm_unpackhi_epi32(h0, h1));
+
+ __m128i yi0 = _mm_sub_epi32(_mm_and_si128(_mm_srli_epi32(h0, 20),
+ _mm_set1_epi32(2047)), _mm_set1_epi32(1023));
+ __m128d yd0 = _mm_mul_pd(_mm_cvtepi32_pd(yi0), ln2_2);
+ __m128d yd1 = _mm_mul_pd(_mm_cvtepi32_pd(_mm_unpackhi_epi64(yi0, yi0)), ln2_2);
+
+ h0 = _mm_and_si128(_mm_srli_epi32(h0, 20 - LOGTAB_SCALE - 1), _mm_set1_epi32(LOGTAB_MASK * 2));
+ _mm_store_si128((__m128i*)idx, h0);
+ h0 = _mm_cmpeq_epi32(h0, _mm_set1_epi32(510));
+
+ __m128d t0, t1, t2, t3, t4;
+ t0 = _mm_load_pd(icvLogTab + idx[0]);
+ t2 = _mm_load_pd(icvLogTab + idx[1]);
+ t1 = _mm_unpackhi_pd(t0, t2);
+ t0 = _mm_unpacklo_pd(t0, t2);
+ t2 = _mm_load_pd(icvLogTab + idx[2]);
+ t4 = _mm_load_pd(icvLogTab + idx[3]);
+ t3 = _mm_unpackhi_pd(t2, t4);
+ t2 = _mm_unpacklo_pd(t2, t4);
+
+ yd0 = _mm_add_pd(yd0, t0);
+ yd1 = _mm_add_pd(yd1, t2);
+
+ xd0 = _mm_mul_pd(_mm_sub_pd(xd0, _1_2), t1);
+ xd1 = _mm_mul_pd(_mm_sub_pd(xd1, _1_2), t3);
+
+ xd0 = _mm_add_pd(xd0, _mm_and_pd(_mm_castsi128_pd(_mm_unpacklo_epi32(h0, h0)), shift2));
+ xd1 = _mm_add_pd(xd1, _mm_and_pd(_mm_castsi128_pd(_mm_unpackhi_epi32(h0, h0)), shift2));
+
+ __m128d zd0 = _mm_mul_pd(xd0, mA0);
+ __m128d zd1 = _mm_mul_pd(xd1, mA0);
+ zd0 = _mm_mul_pd(_mm_add_pd(zd0, mA1), xd0);
+ zd1 = _mm_mul_pd(_mm_add_pd(zd1, mA1), xd1);
+ zd0 = _mm_mul_pd(_mm_add_pd(zd0, mA2), xd0);
+ zd1 = _mm_mul_pd(_mm_add_pd(zd1, mA2), xd1);
+ zd0 = _mm_mul_pd(_mm_add_pd(zd0, mA3), xd0);
+ zd1 = _mm_mul_pd(_mm_add_pd(zd1, mA3), xd1);
+ zd0 = _mm_mul_pd(_mm_add_pd(zd0, mA4), xd0);
+ zd1 = _mm_mul_pd(_mm_add_pd(zd1, mA4), xd1);
+ zd0 = _mm_mul_pd(_mm_add_pd(zd0, mA5), xd0);
+ zd1 = _mm_mul_pd(_mm_add_pd(zd1, mA5), xd1);
+ zd0 = _mm_mul_pd(_mm_add_pd(zd0, mA6), xd0);
+ zd1 = _mm_mul_pd(_mm_add_pd(zd1, mA6), xd1);
+ zd0 = _mm_mul_pd(_mm_add_pd(zd0, mA7), xd0);
+ zd1 = _mm_mul_pd(_mm_add_pd(zd1, mA7), xd1);
+
+ yd0 = _mm_add_pd(yd0, zd0);
+ yd1 = _mm_add_pd(yd1, zd1);
+
+ _mm_storeu_pd(y + i, yd0);
+ _mm_storeu_pd(y + i + 2, yd1);
+ }
+#endif
+ for( ; i <= n - 4; i += 4 )
+ {
+ double xq;
+ double x0, x1, x2, x3;
+ double y0, y1, y2, y3;
+ int h0, h1, h2, h3;
+
+ h0 = X[i].i.lo;
+ h1 = X[i + 1].i.lo;
+ buf[0].i.lo = h0;
+ buf[1].i.lo = h1;
+
+ h0 = X[i].i.hi;
+ h1 = X[i + 1].i.hi;
+ buf[0].i.hi = (h0 & LOGTAB_MASK2) | (1023 << 20);
+ buf[1].i.hi = (h1 & LOGTAB_MASK2) | (1023 << 20);
+
+ y0 = (((h0 >> 20) & 0x7ff) - 1023) * ln_2;
+ y1 = (((h1 >> 20) & 0x7ff) - 1023) * ln_2;
+
+ h2 = X[i + 2].i.lo;
+ h3 = X[i + 3].i.lo;
+ buf[2].i.lo = h2;
+ buf[3].i.lo = h3;
+
+ h0 = (h0 >> (20 - LOGTAB_SCALE - 1)) & LOGTAB_MASK * 2;
+ h1 = (h1 >> (20 - LOGTAB_SCALE - 1)) & LOGTAB_MASK * 2;
+
+ y0 += icvLogTab[h0];
+ y1 += icvLogTab[h1];
+
+ h2 = X[i + 2].i.hi;
+ h3 = X[i + 3].i.hi;
+
+ x0 = LOGTAB_TRANSLATE( buf[0].d, h0 );
+ x1 = LOGTAB_TRANSLATE( buf[1].d, h1 );
+
+ buf[2].i.hi = (h2 & LOGTAB_MASK2) | (1023 << 20);
+ buf[3].i.hi = (h3 & LOGTAB_MASK2) | (1023 << 20);
+
+ y2 = (((h2 >> 20) & 0x7ff) - 1023) * ln_2;
+ y3 = (((h3 >> 20) & 0x7ff) - 1023) * ln_2;
+
+ h2 = (h2 >> (20 - LOGTAB_SCALE - 1)) & LOGTAB_MASK * 2;
+ h3 = (h3 >> (20 - LOGTAB_SCALE - 1)) & LOGTAB_MASK * 2;
+
+ y2 += icvLogTab[h2];
+ y3 += icvLogTab[h3];
+
+ x2 = LOGTAB_TRANSLATE( buf[2].d, h2 );
+ x3 = LOGTAB_TRANSLATE( buf[3].d, h3 );
+
+ y0 += LOGPOLY( x0, h0 == 510 );
+ y1 += LOGPOLY( x1, h1 == 510 );
+
+ y[i] = y0;
+ y[i + 1] = y1;
+
+ y2 += LOGPOLY( x2, h2 == 510 );
+ y3 += LOGPOLY( x3, h3 == 510 );
+
+ y[i + 2] = y2;
+ y[i + 3] = y3;
+ }
+
+ for( ; i < n; i++ )
+ {
+ int h0 = X[i].i.hi;
+ double xq;
+ double x0, y0 = (((h0 >> 20) & 0x7ff) - 1023) * ln_2;
+
+ buf[0].i.hi = (h0 & LOGTAB_MASK2) | (1023 << 20);
+ buf[0].i.lo = X[i].i.lo;
+ h0 = (h0 >> (20 - LOGTAB_SCALE - 1)) & LOGTAB_MASK * 2;
+
+ y0 += icvLogTab[h0];
+ x0 = LOGTAB_TRANSLATE( buf[0].d, h0 );
+ y0 += LOGPOLY( x0, h0 == 510 );
+ y[i] = y0;
+ }
+}
+
+#endif // issue 7795
+
+float fastAtan2( float y, float x )
+{
+ return atanImpl<float>(y, x);
+}
+
+#endif // CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
+
+CV_CPU_OPTIMIZATION_NAMESPACE_END
+
+}} // namespace cv::hal
diff --git a/modules/core/src/matmul.cpp b/modules/core/src/matmul.cpp
index 477d4ab..219089d 100644
--- a/modules/core/src/matmul.cpp
+++ b/modules/core/src/matmul.cpp
@@ -41,9 +41,12 @@
//
//M*/
+#include <sstream>
#include "precomp.hpp"
#include "opencl_kernels_core.hpp"
#include "opencv2/core/opencl/runtime/opencl_clamdblas.hpp"
+#include "opencv2/core/opencl/runtime/opencl_core.hpp"
+#include "intel_gpu_gemm.inl.hpp"
namespace cv
{
@@ -787,7 +790,6 @@ static bool ocl_gemm_amdblas( InputArray matA, InputArray matB, double alpha,
#endif
#ifdef HAVE_OPENCL
-
static bool ocl_gemm( InputArray matA, InputArray matB, double alpha,
InputArray matC, double beta, OutputArray matD, int flags )
{
@@ -806,62 +808,88 @@ static bool ocl_gemm( InputArray matA, InputArray matB, double alpha,
Size sizeA = matA.size(), sizeB = matB.size(), sizeC = haveC ? matC.size() : Size(0, 0);
bool atrans = (flags & GEMM_1_T) != 0, btrans = (flags & GEMM_2_T) != 0, ctrans = (flags & GEMM_3_T) != 0;
- if (atrans)
- sizeA = Size(sizeA.height, sizeA.width);
- if (btrans)
- sizeB = Size(sizeB.height, sizeB.width);
- if (haveC && ctrans)
- sizeC = Size(sizeC.height, sizeC.width);
-
- Size sizeD(sizeB.width, sizeA.height);
-
CV_Assert( !haveC || matC.type() == type );
- CV_Assert( sizeA.width == sizeB.height && (!haveC || sizeC == sizeD) );
-
- int max_wg_size = (int)dev.maxWorkGroupSize();
- int block_size = (max_wg_size / (32*cn) < 32) ? (max_wg_size / (16*cn) < 16) ? (max_wg_size / (8*cn) < 8) ? 1 : 8 : 16 : 32;
+ Size sizeD(((btrans)? sizeB.height : sizeB.width),
+ ((atrans)? sizeA.width : sizeA.height));
matD.create(sizeD, type);
UMat A = matA.getUMat(), B = matB.getUMat(), D = matD.getUMat();
- if (atrans)
- A = A.t();
- if (btrans)
- B = B.t();
+ if (!dev.intelSubgroupsSupport() || (depth == CV_64F) || cn != 1)
+ {
+ String opts;
- if (haveC)
- ctrans ? transpose(matC, D) : matC.copyTo(D);
+ if (atrans)
+ sizeA = Size(sizeA.height, sizeA.width);
+ if (btrans)
+ sizeB = Size(sizeB.height, sizeB.width);
+ if (haveC && ctrans)
+ sizeC = Size(sizeC.height, sizeC.width);
- int vectorWidths[] = { 4, 4, 2, 2, 1, 4, cn, -1 };
- int kercn = ocl::checkOptimalVectorWidth(vectorWidths, B, D);
+ CV_Assert( sizeA.width == sizeB.height && (!haveC || sizeC == sizeD) );
- String opts = format("-D T=%s -D T1=%s -D WT=%s -D cn=%d -D kercn=%d -D LOCAL_SIZE=%d %s %s %s",
+ int max_wg_size = (int)dev.maxWorkGroupSize();
+ int block_size = (max_wg_size / (32*cn) < 32) ? (max_wg_size / (16*cn) < 16) ? (max_wg_size / (8*cn) < 8) ? 1 : 8 : 16 : 32;
+
+ if (atrans)
+ A = A.t();
+
+ if (btrans)
+ B = B.t();
+
+ if (haveC)
+ ctrans ? transpose(matC, D) : matC.copyTo(D);
+
+ int vectorWidths[] = { 4, 4, 2, 2, 1, 4, cn, -1 };
+ int kercn = ocl::checkOptimalVectorWidth(vectorWidths, B, D);
+
+ opts += format(" -D T=%s -D T1=%s -D WT=%s -D cn=%d -D kercn=%d -D LOCAL_SIZE=%d %s %s %s",
ocl::typeToStr(type), ocl::typeToStr(depth), ocl::typeToStr(CV_MAKETYPE(depth, kercn)),
cn, kercn, block_size,
(sizeA.width % block_size !=0) ? "-D NO_MULT" : "",
haveC ? "-D HAVE_C" : "",
doubleSupport ? " -D DOUBLE_SUPPORT" : "");
- ocl::Kernel k("gemm", cv::ocl::core::gemm_oclsrc, opts);
- if (k.empty())
- return false;
+ ocl::Kernel k("gemm", cv::ocl::core::gemm_oclsrc, opts);
+ if (k.empty())
+ return false;
- if (depth == CV_64F)
- k.args(ocl::KernelArg::ReadOnlyNoSize(A),
- ocl::KernelArg::ReadOnlyNoSize(B, cn, kercn),
- ocl::KernelArg::ReadWrite(D, cn, kercn),
- sizeA.width, alpha, beta);
+ if (depth == CV_64F)
+ k.args(ocl::KernelArg::ReadOnlyNoSize(A),
+ ocl::KernelArg::ReadOnlyNoSize(B, cn, kercn),
+ ocl::KernelArg::ReadWrite(D, cn, kercn),
+ sizeA.width, alpha, beta);
+ else
+ k.args(ocl::KernelArg::ReadOnlyNoSize(A),
+ ocl::KernelArg::ReadOnlyNoSize(B, cn, kercn),
+ ocl::KernelArg::ReadWrite(D, cn, kercn),
+ sizeA.width, (float)alpha, (float)beta);
+
+ size_t globalsize[2] = { (size_t)sizeD.width * cn / kercn, (size_t)sizeD.height};
+ size_t localsize[2] = { (size_t)block_size, (size_t)block_size};
+
+ return k.run(2, globalsize, block_size!=1 ? localsize : NULL, false);
+ }
else
- k.args(ocl::KernelArg::ReadOnlyNoSize(A),
- ocl::KernelArg::ReadOnlyNoSize(B, cn, kercn),
- ocl::KernelArg::ReadWrite(D, cn, kercn),
- sizeA.width, (float)alpha, (float)beta);
+ {
+ if (haveC && beta != 0.0)
+ {
+ ctrans ? transpose(matC, D) : matC.copyTo(D);
+ }
+ else
+ {
+ beta = 0.0;
+ }
- size_t globalsize[2] = { (size_t)sizeD.width * cn / kercn, (size_t)sizeD.height};
- size_t localsize[2] = { (size_t)block_size, (size_t)block_size};
- return k.run(2, globalsize, block_size!=1 ? localsize : NULL, false);
+ return intel_gpu_gemm(A, sizeA,
+ B, sizeB,
+ D, sizeD,
+ alpha,
+ beta,
+ atrans, btrans);
+ }
}
#endif
@@ -2551,7 +2579,7 @@ void cv::calcCovarMatrix( InputArray _src, OutputArray _covar, InputOutputArray
{
CV_INSTRUMENT_REGION()
- if(_src.kind() == _InputArray::STD_VECTOR_MAT)
+ if(_src.kind() == _InputArray::STD_VECTOR_MAT || _src.kind() == _InputArray::STD_ARRAY_MAT)
{
std::vector<cv::Mat> src;
_src.getMatVector(src);
@@ -3072,18 +3100,8 @@ dotProd_(const T* src1, const T* src2, int len)
static double dotProd_8u(const uchar* src1, const uchar* src2, int len)
{
double r = 0;
-#if ARITHM_USE_IPP && IPP_DISABLE_BLOCK
- CV_IPP_CHECK()
- {
- if (0 <= CV_INSTRUMENT_FUN_IPP(ippiDotProd_8u64f_C1R, (src1, (int)(len*sizeof(src1[0])),
- src2, (int)(len*sizeof(src2[0])),
- ippiSize(len, 1), &r)))
- {
- CV_IMPL_ADD(CV_IMPL_IPP);
- return r;
- }
- setIppErrorStatus();
- }
+#if ARITHM_USE_IPP
+ CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippiDotProd_8u64f_C1R, src1, len*sizeof(uchar), src2, len*sizeof(uchar), ippiSize(len, 1), &r) >= 0, r);
#endif
int i = 0;
@@ -3270,51 +3288,27 @@ static double dotProd_8s(const schar* src1, const schar* src2, int len)
static double dotProd_16u(const ushort* src1, const ushort* src2, int len)
{
-#if (ARITHM_USE_IPP == 1)
- CV_IPP_CHECK()
- {
- double r = 0;
- if (0 <= CV_INSTRUMENT_FUN_IPP(ippiDotProd_16u64f_C1R, src1, (int)(len*sizeof(src1[0])), src2, (int)(len*sizeof(src2[0])), ippiSize(len, 1), &r))
- {
- CV_IMPL_ADD(CV_IMPL_IPP);
- return r;
- }
- setIppErrorStatus();
- }
+#if ARITHM_USE_IPP
+ double r = 0;
+ CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippiDotProd_16u64f_C1R, src1, len*sizeof(ushort), src2, len*sizeof(ushort), ippiSize(len, 1), &r) >= 0, r);
#endif
return dotProd_(src1, src2, len);
}
static double dotProd_16s(const short* src1, const short* src2, int len)
{
-#if (ARITHM_USE_IPP == 1) && (IPP_VERSION_X100 != 900) // bug in IPP 9.0.0
- CV_IPP_CHECK()
- {
- double r = 0;
- if (0 <= CV_INSTRUMENT_FUN_IPP(ippiDotProd_16s64f_C1R, src1, (int)(len*sizeof(src1[0])), src2, (int)(len*sizeof(src2[0])), ippiSize(len, 1), &r))
- {
- CV_IMPL_ADD(CV_IMPL_IPP);
- return r;
- }
- setIppErrorStatus();
- }
+#if ARITHM_USE_IPP && (IPP_VERSION_X100 != 900) // bug in IPP 9.0.0
+ double r = 0;
+ CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippiDotProd_16s64f_C1R, src1, len*sizeof(short), src2, len*sizeof(short), ippiSize(len, 1), &r) >= 0, r);
#endif
return dotProd_(src1, src2, len);
}
static double dotProd_32s(const int* src1, const int* src2, int len)
{
-#if (ARITHM_USE_IPP == 1)
- CV_IPP_CHECK()
- {
- double r = 0;
- if (0 <= CV_INSTRUMENT_FUN_IPP(ippiDotProd_32s64f_C1R, src1, (int)(len*sizeof(src1[0])), src2, (int)(len*sizeof(src2[0])), ippiSize(len, 1), &r))
- {
- CV_IMPL_ADD(CV_IMPL_IPP);
- return r;
- }
- setIppErrorStatus();
- }
+#if ARITHM_USE_IPP
+ double r = 0;
+ CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippiDotProd_32s64f_C1R, src1, len*sizeof(int), src2, len*sizeof(int), ippiSize(len, 1), &r) >= 0, r);
#endif
return dotProd_(src1, src2, len);
}
@@ -3322,19 +3316,13 @@ static double dotProd_32s(const int* src1, const int* src2, int len)
static double dotProd_32f(const float* src1, const float* src2, int len)
{
double r = 0.0;
+
+#if ARITHM_USE_IPP
+ CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippiDotProd_32f64f_C1R, src1, len*sizeof(float), src2, len*sizeof(float), ippiSize(len, 1), &r, ippAlgHintFast) >= 0, r);
+#endif
int i = 0;
-#if (ARITHM_USE_IPP == 1)
- CV_IPP_CHECK()
- {
- if (0 <= CV_INSTRUMENT_FUN_IPP(ippsDotProd_32f64f, src1, src2, len, &r))
- {
- CV_IMPL_ADD(CV_IMPL_IPP);
- return r;
- }
- setIppErrorStatus();
- }
-#elif CV_NEON
+#if CV_NEON
int len0 = len & -4, blockSize0 = (1 << 13), blockSize;
float32x4_t v_zero = vdupq_n_f32(0.0f);
CV_DECL_ALIGNED(16) float buf[4];
@@ -3361,18 +3349,11 @@ static double dotProd_32f(const float* src1, const float* src2, int len)
static double dotProd_64f(const double* src1, const double* src2, int len)
{
-#if (ARITHM_USE_IPP == 1)
- CV_IPP_CHECK()
- {
- double r = 0;
- if (0 <= CV_INSTRUMENT_FUN_IPP(ippsDotProd_64f, src1, src2, len, &r))
- {
- CV_IMPL_ADD(CV_IMPL_IPP);
- return r;
- }
- setIppErrorStatus();
- }
+#if ARITHM_USE_IPP
+ double r = 0;
+ CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippsDotProd_64f, src1, src2, len, &r) >= 0, r);
#endif
+
return dotProd_(src1, src2, len);
}
diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp
index c542a9a..ec09e21 100644
--- a/modules/core/src/matrix.cpp
+++ b/modules/core/src/matrix.cpp
@@ -60,7 +60,6 @@ void MatAllocator::unmap(UMatData* u) const
if(u->urefcount == 0 && u->refcount == 0)
{
deallocate(u);
- u = NULL;
}
}
@@ -222,7 +221,7 @@ public:
};
namespace
{
- MatAllocator* g_matAllocator = NULL;
+ MatAllocator* volatile g_matAllocator = NULL;
}
@@ -230,7 +229,11 @@ MatAllocator* Mat::getDefaultAllocator()
{
if (g_matAllocator == NULL)
{
- g_matAllocator = getStdAllocator();
+ cv::AutoLock lock(cv::getInitializationMutex());
+ if (g_matAllocator == NULL)
+ {
+ g_matAllocator = getStdAllocator();
+ }
}
return g_matAllocator;
}
@@ -457,8 +460,11 @@ void Mat::copySize(const Mat& m)
void Mat::deallocate()
{
if(u)
- (u->currAllocator ? u->currAllocator : allocator ? allocator : getDefaultAllocator())->unmap(u);
- u = NULL;
+ {
+ UMatData* u_ = u;
+ u = NULL;
+ (u_->currAllocator ? u_->currAllocator : allocator ? allocator : getDefaultAllocator())->unmap(u_);
+ }
}
Mat::Mat(const Mat& m, const Range& _rowRange, const Range& _colRange)
@@ -830,6 +836,32 @@ void Mat::reserve(size_t nelems)
dataend = data + step.p[0]*r;
}
+void Mat::reserveBuffer(size_t nbytes)
+{
+ size_t esz = 1;
+ int mtype = CV_8UC1;
+ if (!empty())
+ {
+ if (!isSubmatrix() && data + nbytes <= dataend)//Should it be datalimit?
+ return;
+ esz = elemSize();
+ mtype = type();
+ }
+
+ size_t nelems = (nbytes - 1) / esz + 1;
+
+#if SIZE_MAX > UINT_MAX
+ CV_Assert(nelems <= size_t(INT_MAX)*size_t(INT_MAX));
+ int newrows = nelems > size_t(INT_MAX) ? nelems > 0x400*size_t(INT_MAX) ? nelems > 0x100000 * size_t(INT_MAX) ? nelems > 0x40000000 * size_t(INT_MAX) ?
+ size_t(INT_MAX) : 0x40000000 : 0x100000 : 0x400 : 1;
+#else
+ int newrows = nelems > size_t(INT_MAX) ? 2 : 1;
+#endif
+ int newcols = (int)((nelems - 1) / newrows + 1);
+
+ create(newrows, newcols, mtype);
+}
+
void Mat::resize(size_t nelems)
{
@@ -971,8 +1003,13 @@ Mat& Mat::adjustROI( int dtop, int dbottom, int dleft, int dright )
Size wholeSize; Point ofs;
size_t esz = elemSize();
locateROI( wholeSize, ofs );
- int row1 = std::max(ofs.y - dtop, 0), row2 = std::min(ofs.y + rows + dbottom, wholeSize.height);
- int col1 = std::max(ofs.x - dleft, 0), col2 = std::min(ofs.x + cols + dright, wholeSize.width);
+ int row1 = std::min(std::max(ofs.y - dtop, 0), wholeSize.height), row2 = std::max(0, std::min(ofs.y + rows + dbottom, wholeSize.height));
+ int col1 = std::min(std::max(ofs.x - dleft, 0), wholeSize.width), col2 = std::max(0, std::min(ofs.x + cols + dright, wholeSize.width));
+ if(row1 > row2)
+ std::swap(row1, row2);
+ if(col1 > col2)
+ std::swap(col1, col2);
+
data += (row1 - ofs.y)*step + (col1 - ofs.x)*esz;
rows = row2 - row1; cols = col2 - col1;
size.p[0] = rows; size.p[1] = cols;
@@ -1021,12 +1058,20 @@ Mat Mat::reshape(int new_cn, int new_rows) const
int cn = channels();
Mat hdr = *this;
- if( dims > 2 && new_rows == 0 && new_cn != 0 && size[dims-1]*cn % new_cn == 0 )
+ if( dims > 2 )
{
- hdr.flags = (hdr.flags & ~CV_MAT_CN_MASK) | ((new_cn-1) << CV_CN_SHIFT);
- hdr.step[dims-1] = CV_ELEM_SIZE(hdr.flags);
- hdr.size[dims-1] = hdr.size[dims-1]*cn / new_cn;
- return hdr;
+ if( new_rows == 0 && new_cn != 0 && size[dims-1]*cn % new_cn == 0 )
+ {
+ hdr.flags = (hdr.flags & ~CV_MAT_CN_MASK) | ((new_cn-1) << CV_CN_SHIFT);
+ hdr.step[dims-1] = CV_ELEM_SIZE(hdr.flags);
+ hdr.size[dims-1] = hdr.size[dims-1]*cn / new_cn;
+ return hdr;
+ }
+ if( new_rows > 0 )
+ {
+ int sz[] = { new_rows, (int)(total()/new_rows) };
+ return reshape(new_cn, 2, sz);
+ }
}
CV_Assert( dims <= 2 );
@@ -1086,7 +1131,7 @@ Mat Mat::diag(const Mat& d)
int Mat::checkVector(int _elemChannels, int _depth, bool _requireContinuous) const
{
- return (depth() == _depth || _depth <= 0) &&
+ return data && (depth() == _depth || _depth <= 0) &&
(isContinuous() || !_requireContinuous) &&
((dims == 2 && (((rows == 1 || cols == 1) && channels() == _elemChannels) ||
(cols == _elemChannels && channels() == 1))) ||
@@ -1204,7 +1249,7 @@ Mat _InputArray::getMat_(int i) const
return (Mat)*((const MatExpr*)obj);
}
- if( k == MATX )
+ if( k == MATX || k == STD_ARRAY )
{
CV_Assert( i < 0 );
return Mat(sz, flags, obj);
@@ -1255,6 +1300,14 @@ Mat _InputArray::getMat_(int i) const
return v[i];
}
+ if( k == STD_ARRAY_MAT )
+ {
+ const Mat* v = (const Mat*)obj;
+ CV_Assert( 0 <= i && i < sz.height );
+
+ return v[i];
+ }
+
if( k == STD_VECTOR_UMAT )
{
const std::vector<UMat>& v = *(const std::vector<UMat>*)obj;
@@ -1350,7 +1403,7 @@ void _InputArray::getMatVector(std::vector<Mat>& mv) const
return;
}
- if( k == MATX )
+ if( k == MATX || k == STD_ARRAY )
{
size_t n = sz.height, esz = CV_ELEM_SIZE(flags);
mv.resize(n);
@@ -1364,7 +1417,7 @@ void _InputArray::getMatVector(std::vector<Mat>& mv) const
{
const std::vector<uchar>& v = *(const std::vector<uchar>*)obj;
- size_t n = v.size(), esz = CV_ELEM_SIZE(flags);
+ size_t n = size().width, esz = CV_ELEM_SIZE(flags);
int t = CV_MAT_DEPTH(flags), cn = CV_MAT_CN(flags);
mv.resize(n);
@@ -1405,6 +1458,17 @@ void _InputArray::getMatVector(std::vector<Mat>& mv) const
return;
}
+ if( k == STD_ARRAY_MAT )
+ {
+ const Mat* v = (const Mat*)obj;
+ size_t n = sz.height;
+ mv.resize(n);
+
+ for( size_t i = 0; i < n; i++ )
+ mv[i] = v[i];
+ return;
+ }
+
if( k == STD_VECTOR_UMAT )
{
const std::vector<UMat>& v = *(const std::vector<UMat>*)obj;
@@ -1441,6 +1505,17 @@ void _InputArray::getUMatVector(std::vector<UMat>& umv) const
return;
}
+ if( k == STD_ARRAY_MAT )
+ {
+ const Mat* v = (const Mat*)obj;
+ size_t n = sz.height;
+ umv.resize(n);
+
+ for( size_t i = 0; i < n; i++ )
+ umv[i] = v[i].getUMat(accessFlags);
+ return;
+ }
+
if( k == STD_VECTOR_UMAT )
{
const std::vector<UMat>& v = *(const std::vector<UMat>*)obj;
@@ -1553,7 +1628,7 @@ Size _InputArray::size(int i) const
return ((const UMat*)obj)->size();
}
- if( k == MATX )
+ if( k == MATX || k == STD_ARRAY )
{
CV_Assert( i < 0 );
return sz;
@@ -1600,6 +1675,16 @@ Size _InputArray::size(int i) const
return vv[i].size();
}
+ if( k == STD_ARRAY_MAT )
+ {
+ const Mat* vv = (const Mat*)obj;
+ if( i < 0 )
+ return sz.height==0 ? Size() : Size(sz.height, 1);
+ CV_Assert( i < sz.height );
+
+ return vv[i].size();
+ }
+
if (k == STD_VECTOR_CUDA_GPU_MAT)
{
const std::vector<cuda::GpuMat>& vv = *(const std::vector<cuda::GpuMat>*)obj;
@@ -1678,6 +1763,16 @@ int _InputArray::sizend(int* arrsz, int i) const
for(j = 0; j < d; j++)
arrsz[j] = m.size.p[j];
}
+ else if( k == STD_ARRAY_MAT && i >= 0 )
+ {
+ const Mat* vv = (const Mat*)obj;
+ CV_Assert( i < sz.height );
+ const Mat& m = vv[i];
+ d = m.dims;
+ if(arrsz)
+ for(j = 0; j < d; j++)
+ arrsz[j] = m.size.p[j];
+ }
else if( k == STD_VECTOR_UMAT && i >= 0 )
{
const std::vector<UMat>& vv = *(const std::vector<UMat>*)obj;
@@ -1758,7 +1853,7 @@ int _InputArray::dims(int i) const
return ((const UMat*)obj)->dims;
}
- if( k == MATX )
+ if( k == MATX || k == STD_ARRAY )
{
CV_Assert( i < 0 );
return 2;
@@ -1792,6 +1887,16 @@ int _InputArray::dims(int i) const
return vv[i].dims;
}
+ if( k == STD_ARRAY_MAT )
+ {
+ const Mat* vv = (const Mat*)obj;
+ if( i < 0 )
+ return 1;
+ CV_Assert( i < sz.height );
+
+ return vv[i].dims;
+ }
+
if( k == STD_VECTOR_UMAT )
{
const std::vector<UMat>& vv = *(const std::vector<UMat>*)obj;
@@ -1850,6 +1955,15 @@ size_t _InputArray::total(int i) const
return vv[i].total();
}
+ if( k == STD_ARRAY_MAT )
+ {
+ const Mat* vv = (const Mat*)obj;
+ if( i < 0 )
+ return sz.height;
+
+ CV_Assert( i < sz.height );
+ return vv[i].total();
+ }
if( k == STD_VECTOR_UMAT )
{
@@ -1877,7 +1991,7 @@ int _InputArray::type(int i) const
if( k == EXPR )
return ((const MatExpr*)obj)->type();
- if( k == MATX || k == STD_VECTOR || k == STD_VECTOR_VECTOR || k == STD_BOOL_VECTOR )
+ if( k == MATX || k == STD_VECTOR || k == STD_ARRAY || k == STD_VECTOR_VECTOR || k == STD_BOOL_VECTOR )
return CV_MAT_TYPE(flags);
if( k == NONE )
@@ -1907,6 +2021,18 @@ int _InputArray::type(int i) const
return vv[i >= 0 ? i : 0].type();
}
+ if( k == STD_ARRAY_MAT )
+ {
+ const Mat* vv = (const Mat*)obj;
+ if( sz.height == 0 )
+ {
+ CV_Assert((flags & FIXED_TYPE) != 0);
+ return CV_MAT_TYPE(flags);
+ }
+ CV_Assert( i < sz.height );
+ return vv[i >= 0 ? i : 0].type();
+ }
+
if (k == STD_VECTOR_CUDA_GPU_MAT)
{
const std::vector<cuda::GpuMat>& vv = *(const std::vector<cuda::GpuMat>*)obj;
@@ -1955,7 +2081,7 @@ bool _InputArray::empty() const
if( k == EXPR )
return false;
- if( k == MATX )
+ if( k == MATX || k == STD_ARRAY )
return false;
if( k == STD_VECTOR )
@@ -1985,6 +2111,11 @@ bool _InputArray::empty() const
return vv.empty();
}
+ if( k == STD_ARRAY_MAT )
+ {
+ return sz.height == 0;
+ }
+
if( k == STD_VECTOR_UMAT )
{
const std::vector<UMat>& vv = *(const std::vector<UMat>*)obj;
@@ -2020,7 +2151,7 @@ bool _InputArray::isContinuous(int i) const
if( k == UMAT )
return i < 0 ? ((const UMat*)obj)->isContinuous() : true;
- if( k == EXPR || k == MATX || k == STD_VECTOR ||
+ if( k == EXPR || k == MATX || k == STD_VECTOR || k == STD_ARRAY ||
k == NONE || k == STD_VECTOR_VECTOR || k == STD_BOOL_VECTOR )
return true;
@@ -2031,6 +2162,13 @@ bool _InputArray::isContinuous(int i) const
return vv[i].isContinuous();
}
+ if( k == STD_ARRAY_MAT )
+ {
+ const Mat* vv = (const Mat*)obj;
+ CV_Assert(i < sz.height);
+ return vv[i].isContinuous();
+ }
+
if( k == STD_VECTOR_UMAT )
{
const std::vector<UMat>& vv = *(const std::vector<UMat>*)obj;
@@ -2055,7 +2193,7 @@ bool _InputArray::isSubmatrix(int i) const
if( k == UMAT )
return i < 0 ? ((const UMat*)obj)->isSubmatrix() : false;
- if( k == EXPR || k == MATX || k == STD_VECTOR ||
+ if( k == EXPR || k == MATX || k == STD_VECTOR || k == STD_ARRAY ||
k == NONE || k == STD_VECTOR_VECTOR || k == STD_BOOL_VECTOR )
return false;
@@ -2066,6 +2204,13 @@ bool _InputArray::isSubmatrix(int i) const
return vv[i].isSubmatrix();
}
+ if( k == STD_ARRAY_MAT )
+ {
+ const Mat* vv = (const Mat*)obj;
+ CV_Assert(i < sz.height);
+ return vv[i].isSubmatrix();
+ }
+
if( k == STD_VECTOR_UMAT )
{
const std::vector<UMat>& vv = *(const std::vector<UMat>*)obj;
@@ -2094,7 +2239,7 @@ size_t _InputArray::offset(int i) const
return ((const UMat*)obj)->offset;
}
- if( k == EXPR || k == MATX || k == STD_VECTOR ||
+ if( k == EXPR || k == MATX || k == STD_VECTOR || k == STD_ARRAY ||
k == NONE || k == STD_VECTOR_VECTOR || k == STD_BOOL_VECTOR )
return 0;
@@ -2108,6 +2253,15 @@ size_t _InputArray::offset(int i) const
return (size_t)(vv[i].ptr() - vv[i].datastart);
}
+ if( k == STD_ARRAY_MAT )
+ {
+ const Mat* vv = (const Mat*)obj;
+ if( i < 0 )
+ return 1;
+ CV_Assert( i < sz.height );
+ return (size_t)(vv[i].ptr() - vv[i].datastart);
+ }
+
if( k == STD_VECTOR_UMAT )
{
const std::vector<UMat>& vv = *(const std::vector<UMat>*)obj;
@@ -2149,7 +2303,7 @@ size_t _InputArray::step(int i) const
return ((const UMat*)obj)->step;
}
- if( k == EXPR || k == MATX || k == STD_VECTOR ||
+ if( k == EXPR || k == MATX || k == STD_VECTOR || k == STD_ARRAY ||
k == NONE || k == STD_VECTOR_VECTOR || k == STD_BOOL_VECTOR )
return 0;
@@ -2162,6 +2316,15 @@ size_t _InputArray::step(int i) const
return vv[i].step;
}
+ if( k == STD_ARRAY_MAT )
+ {
+ const Mat* vv = (const Mat*)obj;
+ if( i < 0 )
+ return 1;
+ CV_Assert( i < sz.height );
+ return vv[i].step;
+ }
+
if( k == STD_VECTOR_UMAT )
{
const std::vector<UMat>& vv = *(const std::vector<UMat>*)obj;
@@ -2191,7 +2354,7 @@ void _InputArray::copyTo(const _OutputArray& arr) const
if( k == NONE )
arr.release();
- else if( k == MAT || k == MATX || k == STD_VECTOR || k == STD_BOOL_VECTOR )
+ else if( k == MAT || k == MATX || k == STD_VECTOR || k == STD_ARRAY || k == STD_BOOL_VECTOR )
{
Mat m = getMat();
m.copyTo(arr);
@@ -2216,7 +2379,7 @@ void _InputArray::copyTo(const _OutputArray& arr, const _InputArray & mask) cons
if( k == NONE )
arr.release();
- else if( k == MAT || k == MATX || k == STD_VECTOR || k == STD_BOOL_VECTOR )
+ else if( k == MAT || k == MATX || k == STD_VECTOR || k == STD_ARRAY || k == STD_BOOL_VECTOR )
{
Mat m = getMat();
m.copyTo(arr, mask);
@@ -2405,6 +2568,14 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i,
return;
}
+ if( k == STD_ARRAY )
+ {
+ int type0 = CV_MAT_TYPE(flags);
+ CV_Assert( mtype == type0 || (CV_MAT_CN(mtype) == 1 && ((1 << type0) & fixedDepthMask) != 0) );
+ CV_Assert( d == 2 && sz.area() == sizes[0]*sizes[1]);
+ return;
+ }
+
if( k == STD_VECTOR || k == STD_VECTOR_VECTOR )
{
CV_Assert( d == 2 && (sizes[0] == 1 || sizes[1] == 1 || sizes[0]*sizes[1] == 0) );
@@ -2552,6 +2723,65 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i,
return;
}
+ if( k == STD_ARRAY_MAT )
+ {
+ Mat* v = (Mat*)obj;
+
+ if( i < 0 )
+ {
+ CV_Assert( d == 2 && (sizes[0] == 1 || sizes[1] == 1 || sizes[0]*sizes[1] == 0) );
+ size_t len = sizes[0]*sizes[1] > 0 ? sizes[0] + sizes[1] - 1 : 0, len0 = sz.height;
+
+ CV_Assert(len == len0);
+ if( fixedType() )
+ {
+ int _type = CV_MAT_TYPE(flags);
+ for( size_t j = len0; j < len; j++ )
+ {
+ if( v[j].type() == _type )
+ continue;
+ CV_Assert( v[j].empty() );
+ v[j].flags = (v[j].flags & ~CV_MAT_TYPE_MASK) | _type;
+ }
+ }
+ return;
+ }
+
+ CV_Assert( i < sz.height );
+ Mat& m = v[i];
+
+ if( allowTransposed )
+ {
+ if( !m.isContinuous() )
+ {
+ CV_Assert(!fixedType() && !fixedSize());
+ m.release();
+ }
+
+ if( d == 2 && m.dims == 2 && m.data &&
+ m.type() == mtype && m.rows == sizes[1] && m.cols == sizes[0] )
+ return;
+ }
+
+ if(fixedType())
+ {
+ if(CV_MAT_CN(mtype) == m.channels() && ((1 << CV_MAT_TYPE(flags)) & fixedDepthMask) != 0 )
+ mtype = m.type();
+ else
+ CV_Assert(CV_MAT_TYPE(mtype) == m.type());
+ }
+
+ if(fixedSize())
+ {
+ CV_Assert(m.dims == d);
+ for(int j = 0; j < d; ++j)
+ CV_Assert(m.size[j] == sizes[j]);
+ }
+
+ m.create(d, sizes, mtype);
+ return;
+ }
+
if( k == STD_VECTOR_UMAT )
{
std::vector<UMat>& v = *(std::vector<UMat>*)obj;
@@ -2717,13 +2947,21 @@ Mat& _OutputArray::getMatRef(int i) const
CV_Assert( k == MAT );
return *(Mat*)obj;
}
- else
+
+ CV_Assert( k == STD_VECTOR_MAT || k == STD_ARRAY_MAT );
+
+ if( k == STD_VECTOR_MAT )
{
- CV_Assert( k == STD_VECTOR_MAT );
std::vector<Mat>& v = *(std::vector<Mat>*)obj;
CV_Assert( i < (int)v.size() );
return v[i];
}
+ else
+ {
+ Mat* v = (Mat*)obj;
+ CV_Assert( 0 <= i && i < sz.height );
+ return v[i];
+ }
}
UMat& _OutputArray::getUMatRef(int i) const
@@ -2776,7 +3014,7 @@ void _OutputArray::setTo(const _InputArray& arr, const _InputArray & mask) const
if( k == NONE )
;
- else if( k == MAT || k == MATX || k == STD_VECTOR )
+ else if( k == MAT || k == MATX || k == STD_VECTOR || k == STD_ARRAY )
{
Mat m = getMat();
m.setTo(arr, mask);
@@ -2894,7 +3132,7 @@ void cv::hconcat(InputArray _src, OutputArray dst)
void cv::vconcat(const Mat* src, size_t nsrc, OutputArray _dst)
{
- CV_INSTRUMENT_REGION()
+ CV_TRACE_FUNCTION_SKIP_NESTED()
if( nsrc == 0 || !src )
{
@@ -3168,11 +3406,6 @@ static TransposeInplaceFunc transposeInplaceTab[] =
#ifdef HAVE_OPENCL
-static inline int divUp(int a, int b)
-{
- return (a + b - 1) / b;
-}
-
static bool ocl_transpose( InputArray _src, OutputArray _dst )
{
const ocl::Device & dev = ocl::Device::getDefault();
@@ -3924,50 +4157,6 @@ void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, int dtype)
namespace cv
{
-#ifdef HAVE_IPP
-#define USE_IPP_SORT
-
-typedef IppStatus (CV_STDCALL * IppSortFunc)(void *, int);
-typedef IppSortFunc IppFlipFunc;
-
-static IppSortFunc getSortFunc(int depth, bool sortDescending)
-{
- if (!sortDescending)
- return depth == CV_8U ? (IppSortFunc)ippsSortAscend_8u_I :
-#if IPP_DISABLE_BLOCK
- depth == CV_16U ? (IppSortFunc)ippsSortAscend_16u_I :
- depth == CV_16S ? (IppSortFunc)ippsSortAscend_16s_I :
- depth == CV_32S ? (IppSortFunc)ippsSortAscend_32s_I :
- depth == CV_32F ? (IppSortFunc)ippsSortAscend_32f_I :
- depth == CV_64F ? (IppSortFunc)ippsSortAscend_64f_I :
-#endif
- 0;
- else
- return depth == CV_8U ? (IppSortFunc)ippsSortDescend_8u_I :
-#if IPP_DISABLE_BLOCK
- depth == CV_16U ? (IppSortFunc)ippsSortDescend_16u_I :
- depth == CV_16S ? (IppSortFunc)ippsSortDescend_16s_I :
- depth == CV_32S ? (IppSortFunc)ippsSortDescend_32s_I :
- depth == CV_32F ? (IppSortFunc)ippsSortDescend_32f_I :
- depth == CV_64F ? (IppSortFunc)ippsSortDescend_64f_I :
-#endif
- 0;
-}
-
-static IppFlipFunc getFlipFunc(int depth)
-{
- CV_SUPPRESS_DEPRECATED_START
- return
- depth == CV_8U || depth == CV_8S ? (IppFlipFunc)ippsFlip_8u_I :
- depth == CV_16U || depth == CV_16S ? (IppFlipFunc)ippsFlip_16u_I :
- depth == CV_32S || depth == CV_32F ? (IppFlipFunc)ippsFlip_32f_I :
- depth == CV_64F ? (IppFlipFunc)ippsFlip_64f_I : 0;
- CV_SUPPRESS_DEPRECATED_END
-}
-
-
-#endif
-
template<typename T> static void sort_( const Mat& src, Mat& dst, int flags )
{
AutoBuffer<T> buf;
@@ -3986,17 +4175,6 @@ template<typename T> static void sort_( const Mat& src, Mat& dst, int flags )
}
bptr = (T*)buf;
-#ifdef USE_IPP_SORT
- int depth = src.depth();
- IppSortFunc ippSortFunc = 0;
- IppFlipFunc ippFlipFunc = 0;
- CV_IPP_CHECK()
- {
- ippSortFunc = getSortFunc(depth, sortDescending);
- ippFlipFunc = getFlipFunc(depth);
- }
-#endif
-
for( int i = 0; i < n; i++ )
{
T* ptr = bptr;
@@ -4016,41 +4194,12 @@ template<typename T> static void sort_( const Mat& src, Mat& dst, int flags )
ptr[j] = src.ptr<T>(j)[i];
}
-#ifdef USE_IPP_SORT
- if (!ippSortFunc || CV_INSTRUMENT_FUN_IPP(ippSortFunc, ptr, len) < 0)
-#endif
+ std::sort( ptr, ptr + len );
+ if( sortDescending )
{
-#ifdef USE_IPP_SORT
- if (depth == CV_8U)
- setIppErrorStatus();
-#endif
- std::sort( ptr, ptr + len );
- if( sortDescending )
- {
-#ifdef USE_IPP_SORT
- if (!ippFlipFunc || CV_INSTRUMENT_FUN_IPP(ippFlipFunc, ptr, len) < 0)
-#endif
- {
-#ifdef USE_IPP_SORT
- setIppErrorStatus();
-#endif
- for( int j = 0; j < len/2; j++ )
- std::swap(ptr[j], ptr[len-1-j]);
- }
-#ifdef USE_IPP_SORT
- else
- {
- CV_IMPL_ADD(CV_IMPL_IPP);
- }
-#endif
- }
- }
-#ifdef USE_IPP_SORT
- else
- {
- CV_IMPL_ADD(CV_IMPL_IPP);
+ for( int j = 0; j < len/2; j++ )
+ std::swap(ptr[j], ptr[len-1-j]);
}
-#endif
if( !sortRows )
for( int j = 0; j < len; j++ )
@@ -4058,38 +4207,102 @@ template<typename T> static void sort_( const Mat& src, Mat& dst, int flags )
}
}
-template<typename _Tp> class LessThanIdx
-{
-public:
- LessThanIdx( const _Tp* _arr ) : arr(_arr) {}
- bool operator()(int a, int b) const { return arr[a] < arr[b]; }
- const _Tp* arr;
-};
-
-#if defined USE_IPP_SORT && IPP_DISABLE_BLOCK
-
-typedef IppStatus (CV_STDCALL *IppSortIndexFunc)(void *, int *, int);
+#ifdef HAVE_IPP
+typedef IppStatus (CV_STDCALL *IppSortFunc)(void *pSrcDst, int len, Ipp8u *pBuffer);
-static IppSortIndexFunc getSortIndexFunc(int depth, bool sortDescending)
+static IppSortFunc getSortFunc(int depth, bool sortDescending)
{
if (!sortDescending)
- return depth == CV_8U ? (IppSortIndexFunc)ippsSortIndexAscend_8u_I :
- depth == CV_16U ? (IppSortIndexFunc)ippsSortIndexAscend_16u_I :
- depth == CV_16S ? (IppSortIndexFunc)ippsSortIndexAscend_16s_I :
- depth == CV_32S ? (IppSortIndexFunc)ippsSortIndexAscend_32s_I :
- depth == CV_32F ? (IppSortIndexFunc)ippsSortIndexAscend_32f_I :
- depth == CV_64F ? (IppSortIndexFunc)ippsSortIndexAscend_64f_I : 0;
+ return depth == CV_8U ? (IppSortFunc)ippsSortRadixAscend_8u_I :
+ depth == CV_16U ? (IppSortFunc)ippsSortRadixAscend_16u_I :
+ depth == CV_16S ? (IppSortFunc)ippsSortRadixAscend_16s_I :
+ depth == CV_32S ? (IppSortFunc)ippsSortRadixAscend_32s_I :
+ depth == CV_32F ? (IppSortFunc)ippsSortRadixAscend_32f_I :
+ depth == CV_64F ? (IppSortFunc)ippsSortRadixAscend_64f_I :
+ 0;
else
- return depth == CV_8U ? (IppSortIndexFunc)ippsSortIndexDescend_8u_I :
- depth == CV_16U ? (IppSortIndexFunc)ippsSortIndexDescend_16u_I :
- depth == CV_16S ? (IppSortIndexFunc)ippsSortIndexDescend_16s_I :
- depth == CV_32S ? (IppSortIndexFunc)ippsSortIndexDescend_32s_I :
- depth == CV_32F ? (IppSortIndexFunc)ippsSortIndexDescend_32f_I :
- depth == CV_64F ? (IppSortIndexFunc)ippsSortIndexDescend_64f_I : 0;
+ return depth == CV_8U ? (IppSortFunc)ippsSortRadixDescend_8u_I :
+ depth == CV_16U ? (IppSortFunc)ippsSortRadixDescend_16u_I :
+ depth == CV_16S ? (IppSortFunc)ippsSortRadixDescend_16s_I :
+ depth == CV_32S ? (IppSortFunc)ippsSortRadixDescend_32s_I :
+ depth == CV_32F ? (IppSortFunc)ippsSortRadixDescend_32f_I :
+ depth == CV_64F ? (IppSortFunc)ippsSortRadixDescend_64f_I :
+ 0;
}
+static bool ipp_sort(const Mat& src, Mat& dst, int flags)
+{
+ CV_INSTRUMENT_REGION_IPP()
+
+ bool sortRows = (flags & 1) == CV_SORT_EVERY_ROW;
+ bool sortDescending = (flags & CV_SORT_DESCENDING) != 0;
+ bool inplace = (src.data == dst.data);
+ int depth = src.depth();
+ IppDataType type = ippiGetDataType(depth);
+
+ IppSortFunc ippsSortRadix_I = getSortFunc(depth, sortDescending);
+ if(!ippsSortRadix_I)
+ return false;
+
+ if(sortRows)
+ {
+ AutoBuffer<Ipp8u> buffer;
+ int bufferSize;
+ if(ippsSortRadixGetBufferSize(src.cols, type, &bufferSize) < 0)
+ return false;
+
+ buffer.allocate(bufferSize);
+
+ if(!inplace)
+ src.copyTo(dst);
+
+ for(int i = 0; i < dst.rows; i++)
+ {
+ if(CV_INSTRUMENT_FUN_IPP(ippsSortRadix_I, (void*)dst.ptr(i), dst.cols, buffer) < 0)
+ return false;
+ }
+ }
+ else
+ {
+ AutoBuffer<Ipp8u> buffer;
+ int bufferSize;
+ if(ippsSortRadixGetBufferSize(src.rows, type, &bufferSize) < 0)
+ return false;
+
+ buffer.allocate(bufferSize);
+
+ Mat row(1, src.rows, src.type());
+ Mat srcSub;
+ Mat dstSub;
+ Rect subRect(0,0,1,src.rows);
+
+ for(int i = 0; i < src.cols; i++)
+ {
+ subRect.x = i;
+ srcSub = Mat(src, subRect);
+ dstSub = Mat(dst, subRect);
+ srcSub.copyTo(row);
+
+ if(CV_INSTRUMENT_FUN_IPP(ippsSortRadix_I, (void*)row.ptr(), dst.rows, buffer) < 0)
+ return false;
+
+ row = row.reshape(1, dstSub.rows);
+ row.copyTo(dstSub);
+ }
+ }
+
+ return true;
+}
#endif
+template<typename _Tp> class LessThanIdx
+{
+public:
+ LessThanIdx( const _Tp* _arr ) : arr(_arr) {}
+ bool operator()(int a, int b) const { return arr[a] < arr[b]; }
+ const _Tp* arr;
+};
+
template<typename T> static void sortIdx_( const Mat& src, Mat& dst, int flags )
{
AutoBuffer<T> buf;
@@ -4111,17 +4324,6 @@ template<typename T> static void sortIdx_( const Mat& src, Mat& dst, int flags )
T* bptr = (T*)buf;
int* _iptr = (int*)ibuf;
-#if defined USE_IPP_SORT && IPP_DISABLE_BLOCK
- int depth = src.depth();
- IppSortIndexFunc ippFunc = 0;
- IppFlipFunc ippFlipFunc = 0;
- CV_IPP_CHECK()
- {
- ippFunc = getSortIndexFunc(depth, sortDescending);
- ippFlipFunc = getFlipFunc(depth);
- }
-#endif
-
for( int i = 0; i < n; i++ )
{
T* ptr = bptr;
@@ -4140,40 +4342,12 @@ template<typename T> static void sortIdx_( const Mat& src, Mat& dst, int flags )
for( int j = 0; j < len; j++ )
iptr[j] = j;
-#if defined USE_IPP_SORT && IPP_DISABLE_BLOCK
- if (sortRows || !ippFunc || ippFunc(ptr, iptr, len) < 0)
-#endif
- {
-#if defined USE_IPP_SORT && IPP_DISABLE_BLOCK
- setIppErrorStatus();
-#endif
- std::sort( iptr, iptr + len, LessThanIdx<T>(ptr) );
- if( sortDescending )
- {
-#if defined USE_IPP_SORT && IPP_DISABLE_BLOCK
- if (!ippFlipFunc || ippFlipFunc(iptr, len) < 0)
-#endif
- {
-#if defined USE_IPP_SORT && IPP_DISABLE_BLOCK
- setIppErrorStatus();
-#endif
- for( int j = 0; j < len/2; j++ )
- std::swap(iptr[j], iptr[len-1-j]);
- }
-#if defined USE_IPP_SORT && IPP_DISABLE_BLOCK
- else
- {
- CV_IMPL_ADD(CV_IMPL_IPP);
- }
-#endif
- }
- }
-#if defined USE_IPP_SORT && IPP_DISABLE_BLOCK
- else
+ std::sort( iptr, iptr + len, LessThanIdx<T>(ptr) );
+ if( sortDescending )
{
- CV_IMPL_ADD(CV_IMPL_IPP);
+ for( int j = 0; j < len/2; j++ )
+ std::swap(iptr[j], iptr[len-1-j]);
}
-#endif
if( !sortRows )
for( int j = 0; j < len; j++ )
@@ -4181,24 +4355,109 @@ template<typename T> static void sortIdx_( const Mat& src, Mat& dst, int flags )
}
}
-typedef void (*SortFunc)(const Mat& src, Mat& dst, int flags);
+#ifdef HAVE_IPP
+#if !IPP_DISABLE_SORT_IDX
+typedef IppStatus (CV_STDCALL *IppSortIndexFunc)(const void* pSrc, Ipp32s srcStrideBytes, Ipp32s *pDstIndx, int len, Ipp8u *pBuffer);
+static IppSortIndexFunc getSortIndexFunc(int depth, bool sortDescending)
+{
+ if (!sortDescending)
+ return depth == CV_8U ? (IppSortIndexFunc)ippsSortRadixIndexAscend_8u :
+ depth == CV_16U ? (IppSortIndexFunc)ippsSortRadixIndexAscend_16u :
+ depth == CV_16S ? (IppSortIndexFunc)ippsSortRadixIndexAscend_16s :
+ depth == CV_32S ? (IppSortIndexFunc)ippsSortRadixIndexAscend_32s :
+ depth == CV_32F ? (IppSortIndexFunc)ippsSortRadixIndexAscend_32f :
+ 0;
+ else
+ return depth == CV_8U ? (IppSortIndexFunc)ippsSortRadixIndexDescend_8u :
+ depth == CV_16U ? (IppSortIndexFunc)ippsSortRadixIndexDescend_16u :
+ depth == CV_16S ? (IppSortIndexFunc)ippsSortRadixIndexDescend_16s :
+ depth == CV_32S ? (IppSortIndexFunc)ippsSortRadixIndexDescend_32s :
+ depth == CV_32F ? (IppSortIndexFunc)ippsSortRadixIndexDescend_32f :
+ 0;
+}
+
+static bool ipp_sortIdx( const Mat& src, Mat& dst, int flags )
+{
+ CV_INSTRUMENT_REGION_IPP()
+
+ bool sortRows = (flags & 1) == SORT_EVERY_ROW;
+ bool sortDescending = (flags & SORT_DESCENDING) != 0;
+ int depth = src.depth();
+ IppDataType type = ippiGetDataType(depth);
+
+ IppSortIndexFunc ippsSortRadixIndex = getSortIndexFunc(depth, sortDescending);
+ if(!ippsSortRadixIndex)
+ return false;
+
+ if(sortRows)
+ {
+ AutoBuffer<Ipp8u> buffer;
+ int bufferSize;
+ if(ippsSortRadixIndexGetBufferSize(src.cols, type, &bufferSize) < 0)
+ return false;
+
+ buffer.allocate(bufferSize);
+
+ for(int i = 0; i < src.rows; i++)
+ {
+ if(CV_INSTRUMENT_FUN_IPP(ippsSortRadixIndex, (const void*)src.ptr(i), (Ipp32s)src.step[1], (Ipp32s*)dst.ptr(i), src.cols, buffer) < 0)
+ return false;
+ }
+ }
+ else
+ {
+ Mat dstRow(1, dst.rows, dst.type());
+ Mat dstSub;
+ Rect subRect(0,0,1,src.rows);
+
+ AutoBuffer<Ipp8u> buffer;
+ int bufferSize;
+ if(ippsSortRadixIndexGetBufferSize(src.rows, type, &bufferSize) < 0)
+ return false;
+
+ buffer.allocate(bufferSize);
+
+ Ipp32s srcStep = (Ipp32s)src.step[0];
+ for(int i = 0; i < src.cols; i++)
+ {
+ subRect.x = i;
+ dstSub = Mat(dst, subRect);
+
+ if(CV_INSTRUMENT_FUN_IPP(ippsSortRadixIndex, (const void*)src.ptr(0, i), srcStep, (Ipp32s*)dstRow.ptr(), src.rows, buffer) < 0)
+ return false;
+
+ dstRow = dstRow.reshape(1, dstSub.rows);
+ dstRow.copyTo(dstSub);
+ }
+ }
+
+ return true;
+}
+#endif
+#endif
+
+typedef void (*SortFunc)(const Mat& src, Mat& dst, int flags);
}
void cv::sort( InputArray _src, OutputArray _dst, int flags )
{
CV_INSTRUMENT_REGION()
+ Mat src = _src.getMat();
+ CV_Assert( src.dims <= 2 && src.channels() == 1 );
+ _dst.create( src.size(), src.type() );
+ Mat dst = _dst.getMat();
+ CV_IPP_RUN_FAST(ipp_sort(src, dst, flags));
+
static SortFunc tab[] =
{
sort_<uchar>, sort_<schar>, sort_<ushort>, sort_<short>,
sort_<int>, sort_<float>, sort_<double>, 0
};
- Mat src = _src.getMat();
SortFunc func = tab[src.depth()];
- CV_Assert( src.dims <= 2 && src.channels() == 1 && func != 0 );
- _dst.create( src.size(), src.type() );
- Mat dst = _dst.getMat();
+ CV_Assert( func != 0 );
+
func( src, dst, flags );
}
@@ -4206,20 +4465,24 @@ void cv::sortIdx( InputArray _src, OutputArray _dst, int flags )
{
CV_INSTRUMENT_REGION()
- static SortFunc tab[] =
- {
- sortIdx_<uchar>, sortIdx_<schar>, sortIdx_<ushort>, sortIdx_<short>,
- sortIdx_<int>, sortIdx_<float>, sortIdx_<double>, 0
- };
Mat src = _src.getMat();
- SortFunc func = tab[src.depth()];
- CV_Assert( src.dims <= 2 && src.channels() == 1 && func != 0 );
-
+ CV_Assert( src.dims <= 2 && src.channels() == 1 );
Mat dst = _dst.getMat();
if( dst.data == src.data )
_dst.release();
_dst.create( src.size(), CV_32S );
dst = _dst.getMat();
+#if !IPP_DISABLE_SORT_IDX
+ CV_IPP_RUN_FAST(ipp_sortIdx(src, dst, flags));
+#endif
+
+ static SortFunc tab[] =
+ {
+ sortIdx_<uchar>, sortIdx_<schar>, sortIdx_<ushort>, sortIdx_<short>,
+ sortIdx_<int>, sortIdx_<float>, sortIdx_<double>, 0
+ };
+ SortFunc func = tab[src.depth()];
+ CV_Assert( func != 0 );
func( src, dst, flags );
}
@@ -4451,6 +4714,18 @@ Mat Mat::reshape(int _cn, int _newndims, const int* _newsz) const
return Mat();
}
+Mat Mat::reshape(int _cn, const std::vector<int>& _newshape) const
+{
+ if(_newshape.empty())
+ {
+ CV_Assert(empty());
+ return *this;
+ }
+
+ return reshape(_cn, (int)_newshape.size(), &_newshape[0]);
+}
+
+
NAryMatIterator::NAryMatIterator()
: arrays(0), planes(0), ptrs(0), narrays(0), nplanes(0), size(0), iterdepth(0), idx(0)
{
@@ -5421,13 +5696,20 @@ double norm( const SparseMat& src, int normType )
{
if( normType == NORM_INF )
for( i = 0; i < N; i++, ++it )
+ {
+ CV_Assert(it.ptr);
result = std::max(result, std::abs((double)it.value<float>()));
+ }
else if( normType == NORM_L1 )
for( i = 0; i < N; i++, ++it )
+ {
+ CV_Assert(it.ptr);
result += std::abs(it.value<float>());
+ }
else
for( i = 0; i < N; i++, ++it )
{
+ CV_Assert(it.ptr);
double v = it.value<float>();
result += v*v;
}
@@ -5436,13 +5718,20 @@ double norm( const SparseMat& src, int normType )
{
if( normType == NORM_INF )
for( i = 0; i < N; i++, ++it )
+ {
+ CV_Assert(it.ptr);
result = std::max(result, std::abs(it.value<double>()));
+ }
else if( normType == NORM_L1 )
for( i = 0; i < N; i++, ++it )
+ {
+ CV_Assert(it.ptr);
result += std::abs(it.value<double>());
+ }
else
for( i = 0; i < N; i++, ++it )
{
+ CV_Assert(it.ptr);
double v = it.value<double>();
result += v*v;
}
@@ -5469,6 +5758,7 @@ void minMaxLoc( const SparseMat& src, double* _minval, double* _maxval, int* _mi
float minval = FLT_MAX, maxval = -FLT_MAX;
for( i = 0; i < N; i++, ++it )
{
+ CV_Assert(it.ptr);
float v = it.value<float>();
if( v < minval )
{
@@ -5491,6 +5781,7 @@ void minMaxLoc( const SparseMat& src, double* _minval, double* _maxval, int* _mi
double minval = DBL_MAX, maxval = -DBL_MAX;
for( i = 0; i < N; i++, ++it )
{
+ CV_Assert(it.ptr);
double v = it.value<double>();
if( v < minval )
{
@@ -5511,10 +5802,10 @@ void minMaxLoc( const SparseMat& src, double* _minval, double* _maxval, int* _mi
else
CV_Error( CV_StsUnsupportedFormat, "Only 32f and 64f are supported" );
- if( _minidx )
+ if( _minidx && minidx )
for( i = 0; i < d; i++ )
_minidx[i] = minidx[i];
- if( _maxidx )
+ if( _maxidx && maxidx )
for( i = 0; i < d; i++ )
_maxidx[i] = maxidx[i];
}
@@ -5623,7 +5914,7 @@ _IplImage::_IplImage(const cv::Mat& m)
CvSparseMat* cvCreateSparseMat(const cv::SparseMat& sm)
{
- if( !sm.hdr )
+ if( !sm.hdr || sm.hdr->dims > (int)cv::SparseMat::MAX_DIM)
return 0;
CvSparseMat* m = cvCreateSparseMat(sm.hdr->dims, sm.hdr->size, sm.type());
diff --git a/modules/core/src/ocl.cpp b/modules/core/src/ocl.cpp
index 60ecc69..f25b9c0 100644
--- a/modules/core/src/ocl.cpp
+++ b/modules/core/src/ocl.cpp
@@ -42,6 +42,7 @@
#include "precomp.hpp"
#include <list>
#include <map>
+#include <deque>
#include <string>
#include <sstream>
#include <iostream> // std::cerr
@@ -49,6 +50,8 @@
#include <inttypes.h>
#endif
+#include "opencv2/core/ocl_genbase.hpp"
+
#define CV_OPENCL_ALWAYS_SHOW_BUILD_LOG 0
#define CV_OPENCL_SHOW_RUN_ERRORS 0
#define CV_OPENCL_SHOW_SVM_ERROR_LOG 1
@@ -63,67 +66,6 @@
# endif
#endif
-
-// TODO Move to some common place
-static bool getBoolParameter(const char* name, bool defaultValue)
-{
-/*
- * If your system doesn't support getenv(), define NO_GETENV to disable
- * this feature.
- */
-#ifdef NO_GETENV
- const char* envValue = NULL;
-#else
- const char* envValue = getenv(name);
-#endif
- if (envValue == NULL)
- {
- return defaultValue;
- }
- cv::String value = envValue;
- if (value == "1" || value == "True" || value == "true" || value == "TRUE")
- {
- return true;
- }
- if (value == "0" || value == "False" || value == "false" || value == "FALSE")
- {
- return false;
- }
- CV_ErrorNoReturn(cv::Error::StsBadArg, cv::format("Invalid value for %s parameter: %s", name, value.c_str()));
-}
-
-
-// TODO Move to some common place
-static size_t getConfigurationParameterForSize(const char* name, size_t defaultValue)
-{
-#ifdef NO_GETENV
- const char* envValue = NULL;
-#else
- const char* envValue = getenv(name);
-#endif
- if (envValue == NULL)
- {
- return defaultValue;
- }
- cv::String value = envValue;
- size_t pos = 0;
- for (; pos < value.size(); pos++)
- {
- if (!isdigit(value[pos]))
- break;
- }
- cv::String valueStr = value.substr(0, pos);
- cv::String suffixStr = value.substr(pos, value.length() - pos);
- int v = atoi(valueStr.c_str());
- if (suffixStr.length() == 0)
- return v;
- else if (suffixStr == "MB" || suffixStr == "Mb" || suffixStr == "mb")
- return v * 1024 * 1024;
- else if (suffixStr == "KB" || suffixStr == "Kb" || suffixStr == "kb")
- return v * 1024;
- CV_ErrorNoReturn(cv::Error::StsBadArg, cv::format("Invalid value for %s parameter: %s", name, value.c_str()));
-}
-
#if CV_OPENCL_SHOW_SVM_LOG
// TODO add timestamp logging
#define CV_OPENCL_SVM_TRACE_P printf("line %d (ocl.cpp): ", __LINE__); printf
@@ -145,1215 +87,7 @@ static size_t getConfigurationParameterForSize(const char* name, size_t defaultV
#include "opencv2/core/opencl/runtime/opencl_core.hpp"
#else
// TODO FIXIT: This file can't be build without OPENCL
-
-/*
- Part of the file is an extract from the standard OpenCL headers from Khronos site.
- Below is the original copyright.
-*/
-
-/*******************************************************************************
- * Copyright (c) 2008 - 2012 The Khronos Group Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and/or associated documentation files (the
- * "Materials"), to deal in the Materials without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Materials, and to
- * permit persons to whom the Materials are 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 Materials.
- *
- * THE MATERIALS ARE 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
- * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
- ******************************************************************************/
-
-#if 0 //defined __APPLE__
-#define HAVE_OPENCL 1
-#else
-#undef HAVE_OPENCL
-#endif
-
-#define OPENCV_CL_NOT_IMPLEMENTED -1000
-
-#ifdef HAVE_OPENCL
-
-#if defined __APPLE__
-#include <OpenCL/opencl.h>
-#else
-#include <CL/opencl.h>
-#endif
-
-static const bool g_haveOpenCL = true;
-
-#else
-
-extern "C" {
-
-struct _cl_platform_id { int dummy; };
-struct _cl_device_id { int dummy; };
-struct _cl_context { int dummy; };
-struct _cl_command_queue { int dummy; };
-struct _cl_mem { int dummy; };
-struct _cl_program { int dummy; };
-struct _cl_kernel { int dummy; };
-struct _cl_event { int dummy; };
-struct _cl_sampler { int dummy; };
-
-typedef struct _cl_platform_id * cl_platform_id;
-typedef struct _cl_device_id * cl_device_id;
-typedef struct _cl_context * cl_context;
-typedef struct _cl_command_queue * cl_command_queue;
-typedef struct _cl_mem * cl_mem;
-typedef struct _cl_program * cl_program;
-typedef struct _cl_kernel * cl_kernel;
-typedef struct _cl_event * cl_event;
-typedef struct _cl_sampler * cl_sampler;
-
-typedef int cl_int;
-typedef unsigned cl_uint;
-#if defined (_WIN32) && defined(_MSC_VER)
- typedef __int64 cl_long;
- typedef unsigned __int64 cl_ulong;
-#else
- typedef long cl_long;
- typedef unsigned long cl_ulong;
-#endif
-
-typedef cl_uint cl_bool; /* WARNING! Unlike cl_ types in cl_platform.h, cl_bool is not guaranteed to be the same size as the bool in kernels. */
-typedef cl_ulong cl_bitfield;
-typedef cl_bitfield cl_device_type;
-typedef cl_uint cl_platform_info;
-typedef cl_uint cl_device_info;
-typedef cl_bitfield cl_device_fp_config;
-typedef cl_uint cl_device_mem_cache_type;
-typedef cl_uint cl_device_local_mem_type;
-typedef cl_bitfield cl_device_exec_capabilities;
-typedef cl_bitfield cl_command_queue_properties;
-typedef intptr_t cl_device_partition_property;
-typedef cl_bitfield cl_device_affinity_domain;
-
-typedef intptr_t cl_context_properties;
-typedef cl_uint cl_context_info;
-typedef cl_uint cl_command_queue_info;
-typedef cl_uint cl_channel_order;
-typedef cl_uint cl_channel_type;
-typedef cl_bitfield cl_mem_flags;
-typedef cl_uint cl_mem_object_type;
-typedef cl_uint cl_mem_info;
-typedef cl_bitfield cl_mem_migration_flags;
-typedef cl_uint cl_image_info;
-typedef cl_uint cl_buffer_create_type;
-typedef cl_uint cl_addressing_mode;
-typedef cl_uint cl_filter_mode;
-typedef cl_uint cl_sampler_info;
-typedef cl_bitfield cl_map_flags;
-typedef cl_uint cl_program_info;
-typedef cl_uint cl_program_build_info;
-typedef cl_uint cl_program_binary_type;
-typedef cl_int cl_build_status;
-typedef cl_uint cl_kernel_info;
-typedef cl_uint cl_kernel_arg_info;
-typedef cl_uint cl_kernel_arg_address_qualifier;
-typedef cl_uint cl_kernel_arg_access_qualifier;
-typedef cl_bitfield cl_kernel_arg_type_qualifier;
-typedef cl_uint cl_kernel_work_group_info;
-typedef cl_uint cl_event_info;
-typedef cl_uint cl_command_type;
-typedef cl_uint cl_profiling_info;
-
-
-typedef struct _cl_image_format {
- cl_channel_order image_channel_order;
- cl_channel_type image_channel_data_type;
-} cl_image_format;
-
-typedef struct _cl_image_desc {
- cl_mem_object_type image_type;
- size_t image_width;
- size_t image_height;
- size_t image_depth;
- size_t image_array_size;
- size_t image_row_pitch;
- size_t image_slice_pitch;
- cl_uint num_mip_levels;
- cl_uint num_samples;
- cl_mem buffer;
-} cl_image_desc;
-
-typedef struct _cl_buffer_region {
- size_t origin;
- size_t size;
-} cl_buffer_region;
-
-
-//////////////////////////////////////////////////////////
-
-#define CL_SUCCESS 0
-#define CL_DEVICE_NOT_FOUND -1
-#define CL_DEVICE_NOT_AVAILABLE -2
-#define CL_COMPILER_NOT_AVAILABLE -3
-#define CL_MEM_OBJECT_ALLOCATION_FAILURE -4
-#define CL_OUT_OF_RESOURCES -5
-#define CL_OUT_OF_HOST_MEMORY -6
-#define CL_PROFILING_INFO_NOT_AVAILABLE -7
-#define CL_MEM_COPY_OVERLAP -8
-#define CL_IMAGE_FORMAT_MISMATCH -9
-#define CL_IMAGE_FORMAT_NOT_SUPPORTED -10
-#define CL_BUILD_PROGRAM_FAILURE -11
-#define CL_MAP_FAILURE -12
-#define CL_MISALIGNED_SUB_BUFFER_OFFSET -13
-#define CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST -14
-#define CL_COMPILE_PROGRAM_FAILURE -15
-#define CL_LINKER_NOT_AVAILABLE -16
-#define CL_LINK_PROGRAM_FAILURE -17
-#define CL_DEVICE_PARTITION_FAILED -18
-#define CL_KERNEL_ARG_INFO_NOT_AVAILABLE -19
-
-#define CL_INVALID_VALUE -30
-#define CL_INVALID_DEVICE_TYPE -31
-#define CL_INVALID_PLATFORM -32
-#define CL_INVALID_DEVICE -33
-#define CL_INVALID_CONTEXT -34
-#define CL_INVALID_QUEUE_PROPERTIES -35
-#define CL_INVALID_COMMAND_QUEUE -36
-#define CL_INVALID_HOST_PTR -37
-#define CL_INVALID_MEM_OBJECT -38
-#define CL_INVALID_IMAGE_FORMAT_DESCRIPTOR -39
-#define CL_INVALID_IMAGE_SIZE -40
-#define CL_INVALID_SAMPLER -41
-#define CL_INVALID_BINARY -42
-#define CL_INVALID_BUILD_OPTIONS -43
-#define CL_INVALID_PROGRAM -44
-#define CL_INVALID_PROGRAM_EXECUTABLE -45
-#define CL_INVALID_KERNEL_NAME -46
-#define CL_INVALID_KERNEL_DEFINITION -47
-#define CL_INVALID_KERNEL -48
-#define CL_INVALID_ARG_INDEX -49
-#define CL_INVALID_ARG_VALUE -50
-#define CL_INVALID_ARG_SIZE -51
-#define CL_INVALID_KERNEL_ARGS -52
-#define CL_INVALID_WORK_DIMENSION -53
-#define CL_INVALID_WORK_GROUP_SIZE -54
-#define CL_INVALID_WORK_ITEM_SIZE -55
-#define CL_INVALID_GLOBAL_OFFSET -56
-#define CL_INVALID_EVENT_WAIT_LIST -57
-#define CL_INVALID_EVENT -58
-#define CL_INVALID_OPERATION -59
-#define CL_INVALID_GL_OBJECT -60
-#define CL_INVALID_BUFFER_SIZE -61
-#define CL_INVALID_MIP_LEVEL -62
-#define CL_INVALID_GLOBAL_WORK_SIZE -63
-#define CL_INVALID_PROPERTY -64
-#define CL_INVALID_IMAGE_DESCRIPTOR -65
-#define CL_INVALID_COMPILER_OPTIONS -66
-#define CL_INVALID_LINKER_OPTIONS -67
-#define CL_INVALID_DEVICE_PARTITION_COUNT -68
-
-/*#define CL_VERSION_1_0 1
-#define CL_VERSION_1_1 1
-#define CL_VERSION_1_2 1*/
-
-#define CL_FALSE 0
-#define CL_TRUE 1
-#define CL_BLOCKING CL_TRUE
-#define CL_NON_BLOCKING CL_FALSE
-
-#define CL_PLATFORM_PROFILE 0x0900
-#define CL_PLATFORM_VERSION 0x0901
-#define CL_PLATFORM_NAME 0x0902
-#define CL_PLATFORM_VENDOR 0x0903
-#define CL_PLATFORM_EXTENSIONS 0x0904
-
-#define CL_DEVICE_TYPE_DEFAULT (1 << 0)
-#define CL_DEVICE_TYPE_CPU (1 << 1)
-#define CL_DEVICE_TYPE_GPU (1 << 2)
-#define CL_DEVICE_TYPE_ACCELERATOR (1 << 3)
-#define CL_DEVICE_TYPE_CUSTOM (1 << 4)
-#define CL_DEVICE_TYPE_ALL 0xFFFFFFFF
-#define CL_DEVICE_TYPE 0x1000
-#define CL_DEVICE_VENDOR_ID 0x1001
-#define CL_DEVICE_MAX_COMPUTE_UNITS 0x1002
-#define CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS 0x1003
-#define CL_DEVICE_MAX_WORK_GROUP_SIZE 0x1004
-#define CL_DEVICE_MAX_WORK_ITEM_SIZES 0x1005
-#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR 0x1006
-#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT 0x1007
-#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT 0x1008
-#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG 0x1009
-#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT 0x100A
-#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE 0x100B
-#define CL_DEVICE_MAX_CLOCK_FREQUENCY 0x100C
-#define CL_DEVICE_ADDRESS_BITS 0x100D
-#define CL_DEVICE_MAX_READ_IMAGE_ARGS 0x100E
-#define CL_DEVICE_MAX_WRITE_IMAGE_ARGS 0x100F
-#define CL_DEVICE_MAX_MEM_ALLOC_SIZE 0x1010
-#define CL_DEVICE_IMAGE2D_MAX_WIDTH 0x1011
-#define CL_DEVICE_IMAGE2D_MAX_HEIGHT 0x1012
-#define CL_DEVICE_IMAGE3D_MAX_WIDTH 0x1013
-#define CL_DEVICE_IMAGE3D_MAX_HEIGHT 0x1014
-#define CL_DEVICE_IMAGE3D_MAX_DEPTH 0x1015
-#define CL_DEVICE_IMAGE_SUPPORT 0x1016
-#define CL_DEVICE_MAX_PARAMETER_SIZE 0x1017
-#define CL_DEVICE_MAX_SAMPLERS 0x1018
-#define CL_DEVICE_MEM_BASE_ADDR_ALIGN 0x1019
-#define CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE 0x101A
-#define CL_DEVICE_SINGLE_FP_CONFIG 0x101B
-#define CL_DEVICE_GLOBAL_MEM_CACHE_TYPE 0x101C
-#define CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE 0x101D
-#define CL_DEVICE_GLOBAL_MEM_CACHE_SIZE 0x101E
-#define CL_DEVICE_GLOBAL_MEM_SIZE 0x101F
-#define CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE 0x1020
-#define CL_DEVICE_MAX_CONSTANT_ARGS 0x1021
-#define CL_DEVICE_LOCAL_MEM_TYPE 0x1022
-#define CL_DEVICE_LOCAL_MEM_SIZE 0x1023
-#define CL_DEVICE_ERROR_CORRECTION_SUPPORT 0x1024
-#define CL_DEVICE_PROFILING_TIMER_RESOLUTION 0x1025
-#define CL_DEVICE_ENDIAN_LITTLE 0x1026
-#define CL_DEVICE_AVAILABLE 0x1027
-#define CL_DEVICE_COMPILER_AVAILABLE 0x1028
-#define CL_DEVICE_EXECUTION_CAPABILITIES 0x1029
-#define CL_DEVICE_QUEUE_PROPERTIES 0x102A
-#define CL_DEVICE_NAME 0x102B
-#define CL_DEVICE_VENDOR 0x102C
-#define CL_DRIVER_VERSION 0x102D
-#define CL_DEVICE_PROFILE 0x102E
-#define CL_DEVICE_VERSION 0x102F
-#define CL_DEVICE_EXTENSIONS 0x1030
-#define CL_DEVICE_PLATFORM 0x1031
-#define CL_DEVICE_DOUBLE_FP_CONFIG 0x1032
-#define CL_DEVICE_HALF_FP_CONFIG 0x1033
-#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF 0x1034
-#define CL_DEVICE_HOST_UNIFIED_MEMORY 0x1035
-#define CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR 0x1036
-#define CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT 0x1037
-#define CL_DEVICE_NATIVE_VECTOR_WIDTH_INT 0x1038
-#define CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG 0x1039
-#define CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT 0x103A
-#define CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE 0x103B
-#define CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF 0x103C
-#define CL_DEVICE_OPENCL_C_VERSION 0x103D
-#define CL_DEVICE_LINKER_AVAILABLE 0x103E
-#define CL_DEVICE_BUILT_IN_KERNELS 0x103F
-#define CL_DEVICE_IMAGE_MAX_BUFFER_SIZE 0x1040
-#define CL_DEVICE_IMAGE_MAX_ARRAY_SIZE 0x1041
-#define CL_DEVICE_PARENT_DEVICE 0x1042
-#define CL_DEVICE_PARTITION_MAX_SUB_DEVICES 0x1043
-#define CL_DEVICE_PARTITION_PROPERTIES 0x1044
-#define CL_DEVICE_PARTITION_AFFINITY_DOMAIN 0x1045
-#define CL_DEVICE_PARTITION_TYPE 0x1046
-#define CL_DEVICE_REFERENCE_COUNT 0x1047
-#define CL_DEVICE_PREFERRED_INTEROP_USER_SYNC 0x1048
-#define CL_DEVICE_PRINTF_BUFFER_SIZE 0x1049
-#define CL_DEVICE_IMAGE_PITCH_ALIGNMENT 0x104A
-#define CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT 0x104B
-
-#define CL_FP_DENORM (1 << 0)
-#define CL_FP_INF_NAN (1 << 1)
-#define CL_FP_ROUND_TO_NEAREST (1 << 2)
-#define CL_FP_ROUND_TO_ZERO (1 << 3)
-#define CL_FP_ROUND_TO_INF (1 << 4)
-#define CL_FP_FMA (1 << 5)
-#define CL_FP_SOFT_FLOAT (1 << 6)
-#define CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT (1 << 7)
-
-#define CL_NONE 0x0
-#define CL_READ_ONLY_CACHE 0x1
-#define CL_READ_WRITE_CACHE 0x2
-#define CL_LOCAL 0x1
-#define CL_GLOBAL 0x2
-#define CL_EXEC_KERNEL (1 << 0)
-#define CL_EXEC_NATIVE_KERNEL (1 << 1)
-#define CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE (1 << 0)
-#define CL_QUEUE_PROFILING_ENABLE (1 << 1)
-
-#define CL_CONTEXT_REFERENCE_COUNT 0x1080
-#define CL_CONTEXT_DEVICES 0x1081
-#define CL_CONTEXT_PROPERTIES 0x1082
-#define CL_CONTEXT_NUM_DEVICES 0x1083
-#define CL_CONTEXT_PLATFORM 0x1084
-#define CL_CONTEXT_INTEROP_USER_SYNC 0x1085
-
-#define CL_DEVICE_PARTITION_EQUALLY 0x1086
-#define CL_DEVICE_PARTITION_BY_COUNTS 0x1087
-#define CL_DEVICE_PARTITION_BY_COUNTS_LIST_END 0x0
-#define CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN 0x1088
-#define CL_DEVICE_AFFINITY_DOMAIN_NUMA (1 << 0)
-#define CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE (1 << 1)
-#define CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE (1 << 2)
-#define CL_DEVICE_AFFINITY_DOMAIN_L2_CACHE (1 << 3)
-#define CL_DEVICE_AFFINITY_DOMAIN_L1_CACHE (1 << 4)
-#define CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE (1 << 5)
-#define CL_QUEUE_CONTEXT 0x1090
-#define CL_QUEUE_DEVICE 0x1091
-#define CL_QUEUE_REFERENCE_COUNT 0x1092
-#define CL_QUEUE_PROPERTIES 0x1093
-#define CL_MEM_READ_WRITE (1 << 0)
-#define CL_MEM_WRITE_ONLY (1 << 1)
-#define CL_MEM_READ_ONLY (1 << 2)
-#define CL_MEM_USE_HOST_PTR (1 << 3)
-#define CL_MEM_ALLOC_HOST_PTR (1 << 4)
-#define CL_MEM_COPY_HOST_PTR (1 << 5)
-// reserved (1 << 6)
-#define CL_MEM_HOST_WRITE_ONLY (1 << 7)
-#define CL_MEM_HOST_READ_ONLY (1 << 8)
-#define CL_MEM_HOST_NO_ACCESS (1 << 9)
-#define CL_MIGRATE_MEM_OBJECT_HOST (1 << 0)
-#define CL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED (1 << 1)
-
-#define CL_R 0x10B0
-#define CL_A 0x10B1
-#define CL_RG 0x10B2
-#define CL_RA 0x10B3
-#define CL_RGB 0x10B4
-#define CL_RGBA 0x10B5
-#define CL_BGRA 0x10B6
-#define CL_ARGB 0x10B7
-#define CL_INTENSITY 0x10B8
-#define CL_LUMINANCE 0x10B9
-#define CL_Rx 0x10BA
-#define CL_RGx 0x10BB
-#define CL_RGBx 0x10BC
-#define CL_DEPTH 0x10BD
-#define CL_DEPTH_STENCIL 0x10BE
-
-#define CL_SNORM_INT8 0x10D0
-#define CL_SNORM_INT16 0x10D1
-#define CL_UNORM_INT8 0x10D2
-#define CL_UNORM_INT16 0x10D3
-#define CL_UNORM_SHORT_565 0x10D4
-#define CL_UNORM_SHORT_555 0x10D5
-#define CL_UNORM_INT_101010 0x10D6
-#define CL_SIGNED_INT8 0x10D7
-#define CL_SIGNED_INT16 0x10D8
-#define CL_SIGNED_INT32 0x10D9
-#define CL_UNSIGNED_INT8 0x10DA
-#define CL_UNSIGNED_INT16 0x10DB
-#define CL_UNSIGNED_INT32 0x10DC
-#define CL_HALF_FLOAT 0x10DD
-#define CL_FLOAT 0x10DE
-#define CL_UNORM_INT24 0x10DF
-
-#define CL_MEM_OBJECT_BUFFER 0x10F0
-#define CL_MEM_OBJECT_IMAGE2D 0x10F1
-#define CL_MEM_OBJECT_IMAGE3D 0x10F2
-#define CL_MEM_OBJECT_IMAGE2D_ARRAY 0x10F3
-#define CL_MEM_OBJECT_IMAGE1D 0x10F4
-#define CL_MEM_OBJECT_IMAGE1D_ARRAY 0x10F5
-#define CL_MEM_OBJECT_IMAGE1D_BUFFER 0x10F6
-
-#define CL_MEM_TYPE 0x1100
-#define CL_MEM_FLAGS 0x1101
-#define CL_MEM_SIZE 0x1102
-#define CL_MEM_HOST_PTR 0x1103
-#define CL_MEM_MAP_COUNT 0x1104
-#define CL_MEM_REFERENCE_COUNT 0x1105
-#define CL_MEM_CONTEXT 0x1106
-#define CL_MEM_ASSOCIATED_MEMOBJECT 0x1107
-#define CL_MEM_OFFSET 0x1108
-
-#define CL_IMAGE_FORMAT 0x1110
-#define CL_IMAGE_ELEMENT_SIZE 0x1111
-#define CL_IMAGE_ROW_PITCH 0x1112
-#define CL_IMAGE_SLICE_PITCH 0x1113
-#define CL_IMAGE_WIDTH 0x1114
-#define CL_IMAGE_HEIGHT 0x1115
-#define CL_IMAGE_DEPTH 0x1116
-#define CL_IMAGE_ARRAY_SIZE 0x1117
-#define CL_IMAGE_BUFFER 0x1118
-#define CL_IMAGE_NUM_MIP_LEVELS 0x1119
-#define CL_IMAGE_NUM_SAMPLES 0x111A
-
-#define CL_ADDRESS_NONE 0x1130
-#define CL_ADDRESS_CLAMP_TO_EDGE 0x1131
-#define CL_ADDRESS_CLAMP 0x1132
-#define CL_ADDRESS_REPEAT 0x1133
-#define CL_ADDRESS_MIRRORED_REPEAT 0x1134
-
-#define CL_FILTER_NEAREST 0x1140
-#define CL_FILTER_LINEAR 0x1141
-
-#define CL_SAMPLER_REFERENCE_COUNT 0x1150
-#define CL_SAMPLER_CONTEXT 0x1151
-#define CL_SAMPLER_NORMALIZED_COORDS 0x1152
-#define CL_SAMPLER_ADDRESSING_MODE 0x1153
-#define CL_SAMPLER_FILTER_MODE 0x1154
-
-#define CL_MAP_READ (1 << 0)
-#define CL_MAP_WRITE (1 << 1)
-#define CL_MAP_WRITE_INVALIDATE_REGION (1 << 2)
-
-#define CL_PROGRAM_REFERENCE_COUNT 0x1160
-#define CL_PROGRAM_CONTEXT 0x1161
-#define CL_PROGRAM_NUM_DEVICES 0x1162
-#define CL_PROGRAM_DEVICES 0x1163
-#define CL_PROGRAM_SOURCE 0x1164
-#define CL_PROGRAM_BINARY_SIZES 0x1165
-#define CL_PROGRAM_BINARIES 0x1166
-#define CL_PROGRAM_NUM_KERNELS 0x1167
-#define CL_PROGRAM_KERNEL_NAMES 0x1168
-#define CL_PROGRAM_BUILD_STATUS 0x1181
-#define CL_PROGRAM_BUILD_OPTIONS 0x1182
-#define CL_PROGRAM_BUILD_LOG 0x1183
-#define CL_PROGRAM_BINARY_TYPE 0x1184
-#define CL_PROGRAM_BINARY_TYPE_NONE 0x0
-#define CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT 0x1
-#define CL_PROGRAM_BINARY_TYPE_LIBRARY 0x2
-#define CL_PROGRAM_BINARY_TYPE_EXECUTABLE 0x4
-
-#define CL_BUILD_SUCCESS 0
-#define CL_BUILD_NONE -1
-#define CL_BUILD_ERROR -2
-#define CL_BUILD_IN_PROGRESS -3
-
-#define CL_KERNEL_FUNCTION_NAME 0x1190
-#define CL_KERNEL_NUM_ARGS 0x1191
-#define CL_KERNEL_REFERENCE_COUNT 0x1192
-#define CL_KERNEL_CONTEXT 0x1193
-#define CL_KERNEL_PROGRAM 0x1194
-#define CL_KERNEL_ATTRIBUTES 0x1195
-#define CL_KERNEL_ARG_ADDRESS_QUALIFIER 0x1196
-#define CL_KERNEL_ARG_ACCESS_QUALIFIER 0x1197
-#define CL_KERNEL_ARG_TYPE_NAME 0x1198
-#define CL_KERNEL_ARG_TYPE_QUALIFIER 0x1199
-#define CL_KERNEL_ARG_NAME 0x119A
-#define CL_KERNEL_ARG_ADDRESS_GLOBAL 0x119B
-#define CL_KERNEL_ARG_ADDRESS_LOCAL 0x119C
-#define CL_KERNEL_ARG_ADDRESS_CONSTANT 0x119D
-#define CL_KERNEL_ARG_ADDRESS_PRIVATE 0x119E
-#define CL_KERNEL_ARG_ACCESS_READ_ONLY 0x11A0
-#define CL_KERNEL_ARG_ACCESS_WRITE_ONLY 0x11A1
-#define CL_KERNEL_ARG_ACCESS_READ_WRITE 0x11A2
-#define CL_KERNEL_ARG_ACCESS_NONE 0x11A3
-#define CL_KERNEL_ARG_TYPE_NONE 0
-#define CL_KERNEL_ARG_TYPE_CONST (1 << 0)
-#define CL_KERNEL_ARG_TYPE_RESTRICT (1 << 1)
-#define CL_KERNEL_ARG_TYPE_VOLATILE (1 << 2)
-#define CL_KERNEL_WORK_GROUP_SIZE 0x11B0
-#define CL_KERNEL_COMPILE_WORK_GROUP_SIZE 0x11B1
-#define CL_KERNEL_LOCAL_MEM_SIZE 0x11B2
-#define CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE 0x11B3
-#define CL_KERNEL_PRIVATE_MEM_SIZE 0x11B4
-#define CL_KERNEL_GLOBAL_WORK_SIZE 0x11B5
-
-#define CL_EVENT_COMMAND_QUEUE 0x11D0
-#define CL_EVENT_COMMAND_TYPE 0x11D1
-#define CL_EVENT_REFERENCE_COUNT 0x11D2
-#define CL_EVENT_COMMAND_EXECUTION_STATUS 0x11D3
-#define CL_EVENT_CONTEXT 0x11D4
-
-#define CL_COMMAND_NDRANGE_KERNEL 0x11F0
-#define CL_COMMAND_TASK 0x11F1
-#define CL_COMMAND_NATIVE_KERNEL 0x11F2
-#define CL_COMMAND_READ_BUFFER 0x11F3
-#define CL_COMMAND_WRITE_BUFFER 0x11F4
-#define CL_COMMAND_COPY_BUFFER 0x11F5
-#define CL_COMMAND_READ_IMAGE 0x11F6
-#define CL_COMMAND_WRITE_IMAGE 0x11F7
-#define CL_COMMAND_COPY_IMAGE 0x11F8
-#define CL_COMMAND_COPY_IMAGE_TO_BUFFER 0x11F9
-#define CL_COMMAND_COPY_BUFFER_TO_IMAGE 0x11FA
-#define CL_COMMAND_MAP_BUFFER 0x11FB
-#define CL_COMMAND_MAP_IMAGE 0x11FC
-#define CL_COMMAND_UNMAP_MEM_OBJECT 0x11FD
-#define CL_COMMAND_MARKER 0x11FE
-#define CL_COMMAND_ACQUIRE_GL_OBJECTS 0x11FF
-#define CL_COMMAND_RELEASE_GL_OBJECTS 0x1200
-#define CL_COMMAND_READ_BUFFER_RECT 0x1201
-#define CL_COMMAND_WRITE_BUFFER_RECT 0x1202
-#define CL_COMMAND_COPY_BUFFER_RECT 0x1203
-#define CL_COMMAND_USER 0x1204
-#define CL_COMMAND_BARRIER 0x1205
-#define CL_COMMAND_MIGRATE_MEM_OBJECTS 0x1206
-#define CL_COMMAND_FILL_BUFFER 0x1207
-#define CL_COMMAND_FILL_IMAGE 0x1208
-
-#define CL_COMPLETE 0x0
-#define CL_RUNNING 0x1
-#define CL_SUBMITTED 0x2
-#define CL_QUEUED 0x3
-#define CL_BUFFER_CREATE_TYPE_REGION 0x1220
-
-#define CL_PROFILING_COMMAND_QUEUED 0x1280
-#define CL_PROFILING_COMMAND_SUBMIT 0x1281
-#define CL_PROFILING_COMMAND_START 0x1282
-#define CL_PROFILING_COMMAND_END 0x1283
-
-#define CL_CALLBACK CV_STDCALL
-
-
-#ifdef HAVE_OPENCL
-static const char* oclFuncToCheck = "clEnqueueReadBufferRect";
-static volatile bool g_haveOpenCL = false;
-#endif
-
-#if defined(__APPLE__) && defined(HAVE_OPENCL)
-#include <dlfcn.h>
-
-static void* initOpenCLAndLoad(const char* funcname)
-{
- static bool initialized = false;
- static void* handle = 0;
- if (!handle)
- {
- if(!initialized)
- {
- const char* oclpath = getenv("OPENCV_OPENCL_RUNTIME");
- oclpath = oclpath && strlen(oclpath) > 0 ? oclpath :
- "/System/Library/Frameworks/OpenCL.framework/Versions/Current/OpenCL";
- handle = dlopen(oclpath, RTLD_LAZY);
- initialized = true;
- g_haveOpenCL = handle != 0 && dlsym(handle, oclFuncToCheck) != 0;
- if( g_haveOpenCL )
- fprintf(stderr, "Successfully loaded OpenCL v1.1+ runtime from %s\n", oclpath);
- else
- fprintf(stderr, "Failed to load OpenCL runtime\n");
- }
- if(!handle)
- return 0;
- }
-
- return funcname && handle ? dlsym(handle, funcname) : 0;
-}
-
-#elif (defined WIN32 || defined _WIN32) && defined(HAVE_OPENCL)
-
-#ifndef _WIN32_WINNT // This is needed for the declaration of TryEnterCriticalSection in winbase.h with Visual Studio 2005 (and older?)
- #define _WIN32_WINNT 0x0400 // http://msdn.microsoft.com/en-us/library/ms686857(VS.85).aspx
-#endif
-#include <windows.h>
-#if (_WIN32_WINNT >= 0x0602)
- #include <synchapi.h>
-#endif
-#undef small
-#undef min
-#undef max
-#undef abs
-
-static void* initOpenCLAndLoad(const char* funcname)
-{
- static bool initialized = false;
- static HMODULE handle = 0;
- if (!handle)
- {
-#ifndef WINRT
- if(!initialized)
- {
- handle = LoadLibraryA("OpenCL.dll");
- initialized = true;
- g_haveOpenCL = handle != 0 && GetProcAddress(handle, oclFuncToCheck) != 0;
- }
-#endif
- if(!handle)
- return 0;
- }
-
- return funcname ? (void*)GetProcAddress(handle, funcname) : 0;
-}
-
-#elif defined(__linux) && defined(HAVE_OPENCL)
-
-#include <dlfcn.h>
-#include <stdio.h>
-
-static void* initOpenCLAndLoad(const char* funcname)
-{
- static bool initialized = false;
- static void* handle = 0;
- if (!handle)
- {
- if(!initialized)
- {
- handle = dlopen("libOpenCL.so", RTLD_LAZY);
- if(!handle)
- handle = dlopen("libCL.so", RTLD_LAZY);
- initialized = true;
- g_haveOpenCL = handle != 0 && dlsym(handle, oclFuncToCheck) != 0;
- }
- if(!handle)
- return 0;
- }
-
- return funcname ? (void*)dlsym(handle, funcname) : 0;
-}
-
-#else
-
-static void* initOpenCLAndLoad(const char*)
-{
- return 0;
-}
-
-#endif
-
-
-#define OCL_FUNC(rettype, funcname, argsdecl, args) \
- typedef rettype (CV_STDCALL * funcname##_t) argsdecl; \
- static rettype funcname argsdecl \
- { \
- static funcname##_t funcname##_p = 0; \
- if( !funcname##_p ) \
- { \
- funcname##_p = (funcname##_t)initOpenCLAndLoad(#funcname); \
- if( !funcname##_p ) \
- return OPENCV_CL_NOT_IMPLEMENTED; \
- } \
- return funcname##_p args; \
- }
-
-
-#define OCL_FUNC_P(rettype, funcname, argsdecl, args) \
- typedef rettype (CV_STDCALL * funcname##_t) argsdecl; \
- static rettype funcname argsdecl \
- { \
- static funcname##_t funcname##_p = 0; \
- if( !funcname##_p ) \
- { \
- funcname##_p = (funcname##_t)initOpenCLAndLoad(#funcname); \
- if( !funcname##_p ) \
- { \
- if( errcode_ret ) \
- *errcode_ret = OPENCV_CL_NOT_IMPLEMENTED; \
- return 0; \
- } \
- } \
- return funcname##_p args; \
- }
-
-OCL_FUNC(cl_int, clGetPlatformIDs,
- (cl_uint num_entries, cl_platform_id* platforms, cl_uint* num_platforms),
- (num_entries, platforms, num_platforms))
-
-OCL_FUNC(cl_int, clGetPlatformInfo,
- (cl_platform_id platform, cl_platform_info param_name,
- size_t param_value_size, void * param_value,
- size_t * param_value_size_ret),
- (platform, param_name, param_value_size, param_value, param_value_size_ret))
-
-OCL_FUNC(cl_int, clGetDeviceInfo,
- (cl_device_id device,
- cl_device_info param_name,
- size_t param_value_size,
- void * param_value,
- size_t * param_value_size_ret),
- (device, param_name, param_value_size, param_value, param_value_size_ret))
-
-
-OCL_FUNC(cl_int, clGetDeviceIDs,
- (cl_platform_id platform,
- cl_device_type device_type,
- cl_uint num_entries,
- cl_device_id * devices,
- cl_uint * num_devices),
- (platform, device_type, num_entries, devices, num_devices))
-
-OCL_FUNC_P(cl_context, clCreateContext,
- (const cl_context_properties * properties,
- cl_uint num_devices,
- const cl_device_id * devices,
- void (CL_CALLBACK * pfn_notify)(const char *, const void *, size_t, void *),
- void * user_data,
- cl_int * errcode_ret),
- (properties, num_devices, devices, pfn_notify, user_data, errcode_ret))
-
-OCL_FUNC(cl_int, clReleaseContext, (cl_context context), (context))
-
-
-OCL_FUNC(cl_int, clRetainContext, (cl_context context), (context))
-/*
-OCL_FUNC_P(cl_context, clCreateContextFromType,
- (const cl_context_properties * properties,
- cl_device_type device_type,
- void (CL_CALLBACK * pfn_notify)(const char *, const void *, size_t, void *),
- void * user_data,
- cl_int * errcode_ret),
- (properties, device_type, pfn_notify, user_data, errcode_ret))
-
-OCL_FUNC(cl_int, clGetContextInfo,
- (cl_context context,
- cl_context_info param_name,
- size_t param_value_size,
- void * param_value,
- size_t * param_value_size_ret),
- (context, param_name, param_value_size,
- param_value, param_value_size_ret))
-*/
-OCL_FUNC_P(cl_command_queue, clCreateCommandQueue,
- (cl_context context,
- cl_device_id device,
- cl_command_queue_properties properties,
- cl_int * errcode_ret),
- (context, device, properties, errcode_ret))
-
-OCL_FUNC(cl_int, clReleaseCommandQueue, (cl_command_queue command_queue), (command_queue))
-
-OCL_FUNC_P(cl_mem, clCreateBuffer,
- (cl_context context,
- cl_mem_flags flags,
- size_t size,
- void * host_ptr,
- cl_int * errcode_ret),
- (context, flags, size, host_ptr, errcode_ret))
-
-/*
-OCL_FUNC(cl_int, clRetainCommandQueue, (cl_command_queue command_queue), (command_queue))
-
-OCL_FUNC(cl_int, clGetCommandQueueInfo,
- (cl_command_queue command_queue,
- cl_command_queue_info param_name,
- size_t param_value_size,
- void * param_value,
- size_t * param_value_size_ret),
- (command_queue, param_name, param_value_size, param_value, param_value_size_ret))
-
-OCL_FUNC_P(cl_mem, clCreateSubBuffer,
- (cl_mem buffer,
- cl_mem_flags flags,
- cl_buffer_create_type buffer_create_type,
- const void * buffer_create_info,
- cl_int * errcode_ret),
- (buffer, flags, buffer_create_type, buffer_create_info, errcode_ret))
-*/
-
-OCL_FUNC_P(cl_mem, clCreateImage,
- (cl_context context,
- cl_mem_flags flags,
- const cl_image_format * image_format,
- const cl_image_desc * image_desc,
- void * host_ptr,
- cl_int * errcode_ret),
- (context, flags, image_format, image_desc, host_ptr, errcode_ret))
-
-OCL_FUNC_P(cl_mem, clCreateImage2D,
- (cl_context context,
- cl_mem_flags flags,
- const cl_image_format * image_format,
- size_t image_width,
- size_t image_height,
- size_t image_row_pitch,
- void * host_ptr,
- cl_int *errcode_ret),
- (context, flags, image_format, image_width, image_height, image_row_pitch, host_ptr, errcode_ret))
-
-OCL_FUNC(cl_int, clGetSupportedImageFormats,
- (cl_context context,
- cl_mem_flags flags,
- cl_mem_object_type image_type,
- cl_uint num_entries,
- cl_image_format * image_formats,
- cl_uint * num_image_formats),
- (context, flags, image_type, num_entries, image_formats, num_image_formats))
-
-
-OCL_FUNC(cl_int, clGetMemObjectInfo,
- (cl_mem memobj,
- cl_mem_info param_name,
- size_t param_value_size,
- void * param_value,
- size_t * param_value_size_ret),
- (memobj, param_name, param_value_size, param_value, param_value_size_ret))
-
-OCL_FUNC(cl_int, clGetImageInfo,
- (cl_mem image,
- cl_image_info param_name,
- size_t param_value_size,
- void * param_value,
- size_t * param_value_size_ret),
- (image, param_name, param_value_size, param_value, param_value_size_ret))
-
-/*
-OCL_FUNC(cl_int, clCreateKernelsInProgram,
- (cl_program program,
- cl_uint num_kernels,
- cl_kernel * kernels,
- cl_uint * num_kernels_ret),
- (program, num_kernels, kernels, num_kernels_ret))
-
-OCL_FUNC(cl_int, clRetainKernel, (cl_kernel kernel), (kernel))
-
-OCL_FUNC(cl_int, clGetKernelArgInfo,
- (cl_kernel kernel,
- cl_uint arg_indx,
- cl_kernel_arg_info param_name,
- size_t param_value_size,
- void * param_value,
- size_t * param_value_size_ret),
- (kernel, arg_indx, param_name, param_value_size, param_value, param_value_size_ret))
-
-OCL_FUNC(cl_int, clEnqueueReadImage,
- (cl_command_queue command_queue,
- cl_mem image,
- cl_bool blocking_read,
- const size_t * origin[3],
- const size_t * region[3],
- size_t row_pitch,
- size_t slice_pitch,
- void * ptr,
- cl_uint num_events_in_wait_list,
- const cl_event * event_wait_list,
- cl_event * event),
- (command_queue, image, blocking_read, origin, region,
- row_pitch, slice_pitch,
- ptr,
- num_events_in_wait_list,
- event_wait_list,
- event))
-
-OCL_FUNC(cl_int, clEnqueueWriteImage,
- (cl_command_queue command_queue,
- cl_mem image,
- cl_bool blocking_write,
- const size_t * origin[3],
- const size_t * region[3],
- size_t input_row_pitch,
- size_t input_slice_pitch,
- const void * ptr,
- cl_uint num_events_in_wait_list,
- const cl_event * event_wait_list,
- cl_event * event),
- (command_queue, image, blocking_write, origin, region, input_row_pitch,
- input_slice_pitch, ptr, num_events_in_wait_list, event_wait_list, event))
-
-OCL_FUNC(cl_int, clEnqueueFillImage,
- (cl_command_queue command_queue,
- cl_mem image,
- const void * fill_color,
- const size_t * origin[3],
- const size_t * region[3],
- cl_uint num_events_in_wait_list,
- const cl_event * event_wait_list,
- cl_event * event),
- (command_queue, image, fill_color, origin, region,
- num_events_in_wait_list, event_wait_list, event))
-
-OCL_FUNC(cl_int, clEnqueueCopyImage,
- (cl_command_queue command_queue,
- cl_mem src_image,
- cl_mem dst_image,
- const size_t * src_origin[3],
- const size_t * dst_origin[3],
- const size_t * region[3],
- cl_uint num_events_in_wait_list,
- const cl_event * event_wait_list,
- cl_event * event),
- (command_queue, src_image, dst_image, src_origin, dst_origin,
- region, num_events_in_wait_list, event_wait_list, event))
-*/
-
-OCL_FUNC(cl_int, clEnqueueCopyImageToBuffer,
- (cl_command_queue command_queue,
- cl_mem src_image,
- cl_mem dst_buffer,
- const size_t * src_origin,
- const size_t * region,
- size_t dst_offset,
- cl_uint num_events_in_wait_list,
- const cl_event * event_wait_list,
- cl_event * event),
- (command_queue, src_image, dst_buffer, src_origin, region, dst_offset,
- num_events_in_wait_list, event_wait_list, event))
-
-OCL_FUNC(cl_int, clEnqueueCopyBufferToImage,
- (cl_command_queue command_queue,
- cl_mem src_buffer,
- cl_mem dst_image,
- size_t src_offset,
- const size_t dst_origin[3],
- const size_t region[3],
- cl_uint num_events_in_wait_list,
- const cl_event * event_wait_list,
- cl_event * event),
- (command_queue, src_buffer, dst_image, src_offset, dst_origin,
- region, num_events_in_wait_list, event_wait_list, event))
-
- OCL_FUNC(cl_int, clFlush,
- (cl_command_queue command_queue),
- (command_queue))
-
-/*
-OCL_FUNC_P(void*, clEnqueueMapImage,
- (cl_command_queue command_queue,
- cl_mem image,
- cl_bool blocking_map,
- cl_map_flags map_flags,
- const size_t * origin[3],
- const size_t * region[3],
- size_t * image_row_pitch,
- size_t * image_slice_pitch,
- cl_uint num_events_in_wait_list,
- const cl_event * event_wait_list,
- cl_event * event,
- cl_int * errcode_ret),
- (command_queue, image, blocking_map, map_flags, origin, region,
- image_row_pitch, image_slice_pitch, num_events_in_wait_list,
- event_wait_list, event, errcode_ret))
-*/
-
-/*
-OCL_FUNC(cl_int, clRetainProgram, (cl_program program), (program))
-
-OCL_FUNC(cl_int, clGetKernelInfo,
- (cl_kernel kernel,
- cl_kernel_info param_name,
- size_t param_value_size,
- void * param_value,
- size_t * param_value_size_ret),
- (kernel, param_name, param_value_size, param_value, param_value_size_ret))
-
-*/
-
-OCL_FUNC(cl_int, clRetainMemObject, (cl_mem memobj), (memobj))
-
-OCL_FUNC(cl_int, clReleaseMemObject, (cl_mem memobj), (memobj))
-
-
-OCL_FUNC_P(cl_program, clCreateProgramWithSource,
- (cl_context context,
- cl_uint count,
- const char ** strings,
- const size_t * lengths,
- cl_int * errcode_ret),
- (context, count, strings, lengths, errcode_ret))
-
-OCL_FUNC_P(cl_program, clCreateProgramWithBinary,
- (cl_context context,
- cl_uint num_devices,
- const cl_device_id * device_list,
- const size_t * lengths,
- const unsigned char ** binaries,
- cl_int * binary_status,
- cl_int * errcode_ret),
- (context, num_devices, device_list, lengths, binaries, binary_status, errcode_ret))
-
-OCL_FUNC(cl_int, clReleaseProgram, (cl_program program), (program))
-
-OCL_FUNC(cl_int, clBuildProgram,
- (cl_program program,
- cl_uint num_devices,
- const cl_device_id * device_list,
- const char * options,
- void (CL_CALLBACK * pfn_notify)(cl_program, void *),
- void * user_data),
- (program, num_devices, device_list, options, pfn_notify, user_data))
-
-OCL_FUNC(cl_int, clGetProgramInfo,
- (cl_program program,
- cl_program_info param_name,
- size_t param_value_size,
- void * param_value,
- size_t * param_value_size_ret),
- (program, param_name, param_value_size, param_value, param_value_size_ret))
-
-OCL_FUNC(cl_int, clGetProgramBuildInfo,
- (cl_program program,
- cl_device_id device,
- cl_program_build_info param_name,
- size_t param_value_size,
- void * param_value,
- size_t * param_value_size_ret),
- (program, device, param_name, param_value_size, param_value, param_value_size_ret))
-
-OCL_FUNC_P(cl_kernel, clCreateKernel,
- (cl_program program,
- const char * kernel_name,
- cl_int * errcode_ret),
- (program, kernel_name, errcode_ret))
-
-OCL_FUNC(cl_int, clReleaseKernel, (cl_kernel kernel), (kernel))
-
-OCL_FUNC(cl_int, clSetKernelArg,
- (cl_kernel kernel,
- cl_uint arg_index,
- size_t arg_size,
- const void * arg_value),
- (kernel, arg_index, arg_size, arg_value))
-
-OCL_FUNC(cl_int, clGetKernelWorkGroupInfo,
- (cl_kernel kernel,
- cl_device_id device,
- cl_kernel_work_group_info param_name,
- size_t param_value_size,
- void * param_value,
- size_t * param_value_size_ret),
- (kernel, device, param_name, param_value_size, param_value, param_value_size_ret))
-
-OCL_FUNC(cl_int, clFinish, (cl_command_queue command_queue), (command_queue))
-
-OCL_FUNC(cl_int, clEnqueueReadBuffer,
- (cl_command_queue command_queue,
- cl_mem buffer,
- cl_bool blocking_read,
- size_t offset,
- size_t size,
- void * ptr,
- cl_uint num_events_in_wait_list,
- const cl_event * event_wait_list,
- cl_event * event),
- (command_queue, buffer, blocking_read, offset, size, ptr,
- num_events_in_wait_list, event_wait_list, event))
-
-OCL_FUNC(cl_int, clEnqueueReadBufferRect,
- (cl_command_queue command_queue,
- cl_mem buffer,
- cl_bool blocking_read,
- const size_t * buffer_offset,
- const size_t * host_offset,
- const size_t * region,
- size_t buffer_row_pitch,
- size_t buffer_slice_pitch,
- size_t host_row_pitch,
- size_t host_slice_pitch,
- void * ptr,
- cl_uint num_events_in_wait_list,
- const cl_event * event_wait_list,
- cl_event * event),
- (command_queue, buffer, blocking_read, buffer_offset, host_offset, region, buffer_row_pitch,
- buffer_slice_pitch, host_row_pitch, host_slice_pitch, ptr, num_events_in_wait_list,
- event_wait_list, event))
-
-OCL_FUNC(cl_int, clEnqueueWriteBuffer,
- (cl_command_queue command_queue,
- cl_mem buffer,
- cl_bool blocking_write,
- size_t offset,
- size_t size,
- const void * ptr,
- cl_uint num_events_in_wait_list,
- const cl_event * event_wait_list,
- cl_event * event),
- (command_queue, buffer, blocking_write, offset, size, ptr,
- num_events_in_wait_list, event_wait_list, event))
-
-OCL_FUNC(cl_int, clEnqueueWriteBufferRect,
- (cl_command_queue command_queue,
- cl_mem buffer,
- cl_bool blocking_write,
- const size_t * buffer_offset,
- const size_t * host_offset,
- const size_t * region,
- size_t buffer_row_pitch,
- size_t buffer_slice_pitch,
- size_t host_row_pitch,
- size_t host_slice_pitch,
- const void * ptr,
- cl_uint num_events_in_wait_list,
- const cl_event * event_wait_list,
- cl_event * event),
- (command_queue, buffer, blocking_write, buffer_offset, host_offset,
- region, buffer_row_pitch, buffer_slice_pitch, host_row_pitch,
- host_slice_pitch, ptr, num_events_in_wait_list, event_wait_list, event))
-
-/*OCL_FUNC(cl_int, clEnqueueFillBuffer,
- (cl_command_queue command_queue,
- cl_mem buffer,
- const void * pattern,
- size_t pattern_size,
- size_t offset,
- size_t size,
- cl_uint num_events_in_wait_list,
- const cl_event * event_wait_list,
- cl_event * event),
- (command_queue, buffer, pattern, pattern_size, offset, size,
- num_events_in_wait_list, event_wait_list, event))*/
-
-OCL_FUNC(cl_int, clEnqueueCopyBuffer,
- (cl_command_queue command_queue,
- cl_mem src_buffer,
- cl_mem dst_buffer,
- size_t src_offset,
- size_t dst_offset,
- size_t size,
- cl_uint num_events_in_wait_list,
- const cl_event * event_wait_list,
- cl_event * event),
- (command_queue, src_buffer, dst_buffer, src_offset, dst_offset,
- size, num_events_in_wait_list, event_wait_list, event))
-
-OCL_FUNC(cl_int, clEnqueueCopyBufferRect,
- (cl_command_queue command_queue,
- cl_mem src_buffer,
- cl_mem dst_buffer,
- const size_t * src_origin,
- const size_t * dst_origin,
- const size_t * region,
- size_t src_row_pitch,
- size_t src_slice_pitch,
- size_t dst_row_pitch,
- size_t dst_slice_pitch,
- cl_uint num_events_in_wait_list,
- const cl_event * event_wait_list,
- cl_event * event),
- (command_queue, src_buffer, dst_buffer, src_origin, dst_origin,
- region, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch,
- num_events_in_wait_list, event_wait_list, event))
-
-OCL_FUNC_P(void*, clEnqueueMapBuffer,
- (cl_command_queue command_queue,
- cl_mem buffer,
- cl_bool blocking_map,
- cl_map_flags map_flags,
- size_t offset,
- size_t size,
- cl_uint num_events_in_wait_list,
- const cl_event * event_wait_list,
- cl_event * event,
- cl_int * errcode_ret),
- (command_queue, buffer, blocking_map, map_flags, offset, size,
- num_events_in_wait_list, event_wait_list, event, errcode_ret))
-
-OCL_FUNC(cl_int, clEnqueueUnmapMemObject,
- (cl_command_queue command_queue,
- cl_mem memobj,
- void * mapped_ptr,
- cl_uint num_events_in_wait_list,
- const cl_event * event_wait_list,
- cl_event * event),
- (command_queue, memobj, mapped_ptr, num_events_in_wait_list, event_wait_list, event))
-
-OCL_FUNC(cl_int, clEnqueueNDRangeKernel,
- (cl_command_queue command_queue,
- cl_kernel kernel,
- cl_uint work_dim,
- const size_t * global_work_offset,
- const size_t * global_work_size,
- const size_t * local_work_size,
- cl_uint num_events_in_wait_list,
- const cl_event * event_wait_list,
- cl_event * event),
- (command_queue, kernel, work_dim, global_work_offset, global_work_size,
- local_work_size, num_events_in_wait_list, event_wait_list, event))
-
-OCL_FUNC(cl_int, clEnqueueTask,
- (cl_command_queue command_queue,
- cl_kernel kernel,
- cl_uint num_events_in_wait_list,
- const cl_event * event_wait_list,
- cl_event * event),
- (command_queue, kernel, num_events_in_wait_list, event_wait_list, event))
-
-OCL_FUNC(cl_int, clSetEventCallback,
- (cl_event event,
- cl_int command_exec_callback_type ,
- void (CL_CALLBACK *pfn_event_notify) (cl_event event, cl_int event_command_exec_status, void *user_data),
- void *user_data),
- (event, command_exec_callback_type, pfn_event_notify, user_data))
-
-OCL_FUNC(cl_int, clReleaseEvent, (cl_event event), (event))
-
-}
-
-#endif
-
-#ifndef CL_VERSION_1_2
-#define CL_VERSION_1_2
-#endif
-
+#include "ocl_deprecated.hpp"
#endif // HAVE_OPENCL
#ifdef _DEBUG
@@ -1365,7 +99,7 @@ static bool isRaiseError()
static bool value = false;
if (!initialized)
{
- value = getBoolParameter("OPENCV_OPENCL_RAISE_ERROR", false);
+ value = cv::utils::getConfigurationParameterBool("OPENCV_OPENCL_RAISE_ERROR", false);
initialized = true;
}
return value;
@@ -1440,24 +174,6 @@ static uint64 crc64( const uchar* data, size_t size, uint64 crc0=0 )
return ~crc;
}
-struct HashKey
-{
- typedef uint64 part;
- HashKey(part _a, part _b) : a(_a), b(_b) {}
- part a, b;
-};
-
-inline bool operator == (const HashKey& h1, const HashKey& h2)
-{
- return h1.a == h2.a && h1.b == h2.b;
-}
-
-inline bool operator < (const HashKey& h1, const HashKey& h2)
-{
- return h1.a < h2.a || (h1.a == h2.a && h1.b < h2.b);
-}
-
-
bool haveOpenCL()
{
#ifdef HAVE_OPENCL
@@ -1812,6 +528,8 @@ struct Device::Impl
String deviceVersion_ = getStrProp(CL_DEVICE_VERSION);
parseDeviceVersion(deviceVersion_, deviceVersionMajor_, deviceVersionMinor_);
+ intelSubgroupsSupport_ = isExtensionSupported("cl_intel_subgroups");
+
vendorName_ = getStrProp(CL_DEVICE_VENDOR);
if (vendorName_ == "Advanced Micro Devices, Inc." ||
vendorName_ == "AMD")
@@ -1851,6 +569,18 @@ struct Device::Impl
sz < sizeof(buf) ? String(buf) : String();
}
+ bool isExtensionSupported(const String& extensionName) const
+ {
+ bool ret = false;
+ size_t pos = getStrProp(CL_DEVICE_EXTENSIONS).find(extensionName);
+ if (pos != String::npos)
+ {
+ ret = true;
+ }
+ return ret;
+ }
+
+
IMPLEMENT_REFCOUNTABLE();
cl_device_id handle;
@@ -1866,6 +596,7 @@ struct Device::Impl
String driverVersion_;
String vendorName_;
int vendorID_;
+ bool intelSubgroupsSupport_;
};
@@ -1935,7 +666,7 @@ String Device::OpenCL_C_Version() const
{ return p ? p->getStrProp(CL_DEVICE_OPENCL_C_VERSION) : String(); }
String Device::OpenCLVersion() const
-{ return p ? p->getStrProp(CL_DEVICE_EXTENSIONS) : String(); }
+{ return p ? p->getStrProp(CL_DEVICE_VERSION) : String(); }
int Device::deviceVersionMajor() const
{ return p ? p->deviceVersionMajor_ : 0; }
@@ -2072,6 +803,9 @@ size_t Device::imageMaxArraySize() const
{ CV_REQUIRE_OPENCL_1_2_ERROR; }
#endif
+bool Device::intelSubgroupsSupport() const
+{ return p ? p->intelSubgroupsSupport_ : false; }
+
int Device::maxClockFrequency() const
{ return p ? p->getProp<cl_uint, int>(CL_DEVICE_MAX_CLOCK_FREQUENCY) : 0; }
@@ -2392,7 +1126,7 @@ not_found:
if (!configuration)
return NULL; // suppress messages on stderr
- std::cerr << "ERROR: Requested OpenCL device not found, check configuration: " << (configuration == NULL ? "" : configuration) << std::endl
+ std::cerr << "ERROR: Requested OpenCL device not found, check configuration: " << configuration << std::endl
<< " Platform: " << (platform.length() == 0 ? "any" : platform) << std::endl
<< " Device types: ";
for (size_t t = 0; t < deviceTypes.size(); t++)
@@ -2420,7 +1154,7 @@ static bool checkForceSVMUmatUsage()
static bool force = false;
if (!initialized)
{
- force = getBoolParameter("OPENCV_OPENCL_SVM_FORCE_UMAT_USAGE", false);
+ force = utils::getConfigurationParameterBool("OPENCV_OPENCL_SVM_FORCE_UMAT_USAGE", false);
initialized = true;
}
return force;
@@ -2431,7 +1165,7 @@ static bool checkDisableSVMUMatUsage()
static bool force = false;
if (!initialized)
{
- force = getBoolParameter("OPENCV_OPENCL_SVM_DISABLE_UMAT_USAGE", false);
+ force = utils::getConfigurationParameterBool("OPENCV_OPENCL_SVM_DISABLE_UMAT_USAGE", false);
initialized = true;
}
return force;
@@ -2442,7 +1176,7 @@ static bool checkDisableSVM()
static bool force = false;
if (!initialized)
{
- force = getBoolParameter("OPENCV_OPENCL_SVM_DISABLE", false);
+ force = utils::getConfigurationParameterBool("OPENCV_OPENCL_SVM_DISABLE", false);
initialized = true;
}
return force;
@@ -2467,6 +1201,18 @@ static unsigned int getSVMCapabilitiesMask()
} // namespace
#endif
+static size_t getProgramCountLimit()
+{
+ static bool initialized = false;
+ static size_t count = 0;
+ if (!initialized)
+ {
+ count = utils::getConfigurationParameterSizeT("OPENCV_OPENCL_PROGRAM_CACHE", 0);
+ initialized = true;
+ }
+ return count;
+}
+
struct Context::Impl
{
static Context::Impl* get(Context& context) { return context.p; }
@@ -2586,35 +1332,65 @@ struct Context::Impl
Program getProg(const ProgramSource& src,
const String& buildflags, String& errmsg)
{
- String prefix = Program::getPrefix(buildflags);
- HashKey k(src.hash(), crc64((const uchar*)prefix.c_str(), prefix.size()));
- phash_t::iterator it = phash.find(k);
- if( it != phash.end() )
- return it->second;
- //String filename = format("%08x%08x_%08x%08x.clb2",
+ size_t limit = getProgramCountLimit();
+ String key = cv::format("codehash=%08llx ", src.hash()) + Program::getPrefix(buildflags);
+ {
+ cv::AutoLock lock(program_cache_mutex);
+ phash_t::iterator it = phash.find(key);
+ if (it != phash.end())
+ {
+ // TODO LRU cache
+ CacheList::iterator i = std::find(cacheList.begin(), cacheList.end(), key);
+ if (i != cacheList.end() && i != cacheList.begin())
+ {
+ cacheList.erase(i);
+ cacheList.push_front(key);
+ }
+ return it->second;
+ }
+ { // cleanup program cache
+ size_t sz = phash.size();
+ if (limit > 0 && sz >= limit)
+ {
+ static bool warningFlag = false;
+ if (!warningFlag)
+ {
+ printf("\nWARNING: OpenCV-OpenCL:\n"
+ " In-memory cache for OpenCL programs is full, older programs will be unloaded.\n"
+ " You can change cache size via OPENCV_OPENCL_PROGRAM_CACHE environment variable\n\n");
+ warningFlag = true;
+ }
+ while (!cacheList.empty())
+ {
+ size_t c = phash.erase(cacheList.back());
+ cacheList.pop_back();
+ if (c != 0)
+ break;
+ }
+ }
+ }
+ }
Program prog(src, buildflags, errmsg);
if(prog.ptr())
- phash.insert(std::pair<HashKey,Program>(k, prog));
+ {
+ cv::AutoLock lock(program_cache_mutex);
+ phash.insert(std::pair<std::string, Program>(key, prog));
+ cacheList.push_front(key);
+ }
return prog;
}
+
IMPLEMENT_REFCOUNTABLE();
cl_context handle;
std::vector<Device> devices;
- typedef ProgramSource::hash_t hash_t;
-
- struct HashKey
- {
- HashKey(hash_t _a, hash_t _b) : a(_a), b(_b) {}
- bool operator < (const HashKey& k) const { return a < k.a || (a == k.a && b < k.b); }
- bool operator == (const HashKey& k) const { return a == k.a && b == k.b; }
- bool operator != (const HashKey& k) const { return a != k.a || b != k.b; }
- hash_t a, b;
- };
- typedef std::map<HashKey, Program> phash_t;
+ cv::Mutex program_cache_mutex;
+ typedef std::map<std::string, Program> phash_t;
phash_t phash;
+ typedef std::list<cv::String> CacheList;
+ CacheList cacheList;
#ifdef HAVE_OPENCL_SVM
bool svmInitialized;
@@ -3155,6 +1931,7 @@ KernelArg::KernelArg()
KernelArg::KernelArg(int _flags, UMat* _m, int _wscale, int _iwscale, const void* _obj, size_t _sz)
: flags(_flags), m(_m), obj(_obj), sz(_sz), wscale(_wscale), iwscale(_iwscale)
{
+ CV_Assert(_flags == LOCAL || _flags == CONSTANT || _m != NULL);
}
KernelArg KernelArg::Constant(const Mat& m)
@@ -3168,7 +1945,7 @@ KernelArg KernelArg::Constant(const Mat& m)
struct Kernel::Impl
{
Impl(const char* kname, const Program& prog) :
- refcount(1), e(0), nu(0)
+ refcount(1), isInProgress(false), nu(0)
{
cl_program ph = (cl_program)prog.ptr();
cl_int retval = 0;
@@ -3189,7 +1966,10 @@ struct Kernel::Impl
if( u[i] )
{
if( CV_XADD(&u[i]->urefcount, -1) == 1 )
+ {
+ u[i]->flags |= UMatData::ASYNC_CLEANUP;
u[i]->currAllocator->deallocate(u[i]);
+ }
u[i] = 0;
}
nu = 0;
@@ -3211,11 +1991,15 @@ struct Kernel::Impl
images.push_back(image);
}
- void finit()
+ void finit(cl_event e)
{
+ CV_UNUSED(e);
+#if 0
+ printf("event::callback(%p)\n", e); fflush(stdout);
+#endif
cleanupUMats();
images.clear();
- if(e) { clReleaseEvent(e); e = 0; }
+ isInProgress = false;
release();
}
@@ -3231,9 +2015,9 @@ struct Kernel::Impl
cv::String name;
#endif
cl_kernel handle;
- cl_event e;
enum { MAX_ARRS = 16 };
UMatData* u[MAX_ARRS];
+ bool isInProgress;
int nu;
std::list<Image2D> images;
bool haveTempDstUMats;
@@ -3243,9 +2027,9 @@ struct Kernel::Impl
extern "C" {
-static void CL_CALLBACK oclCleanupCallback(cl_event, cl_int, void *p)
+static void CL_CALLBACK oclCleanupCallback(cl_event e, cl_int, void *p)
{
- ((cv::ocl::Kernel::Impl*)p)->finit();
+ ((cv::ocl::Kernel::Impl*)p)->finit(e);
}
}
@@ -3433,7 +2217,7 @@ int Kernel::set(int i, const KernelArg& arg)
if( !(arg.flags & KernelArg::NO_SIZE) )
{
int cols = u3d.cols*arg.wscale/arg.iwscale;
- CV_OclDbgAssert(clSetKernelArg(p->handle, (cl_uint)i, sizeof(u3d.slices), &u3d.rows) == CL_SUCCESS);
+ CV_OclDbgAssert(clSetKernelArg(p->handle, (cl_uint)i, sizeof(u3d.slices), &u3d.slices) == CL_SUCCESS);
CV_OclDbgAssert(clSetKernelArg(p->handle, (cl_uint)(i+1), sizeof(u3d.rows), &u3d.rows) == CL_SUCCESS);
CV_OclDbgAssert(clSetKernelArg(p->handle, (cl_uint)(i+2), sizeof(u3d.cols), &cols) == CL_SUCCESS);
i += 3;
@@ -3452,7 +2236,7 @@ bool Kernel::run(int dims, size_t _globalsize[], size_t _localsize[],
{
CV_INSTRUMENT_REGION_OPENCL_RUN(p->name.c_str());
- if(!p || !p->handle || p->e != 0)
+ if(!p || !p->handle || p->isInProgress)
return false;
cl_command_queue qq = getQueue(q);
@@ -3471,9 +2255,10 @@ bool Kernel::run(int dims, size_t _globalsize[], size_t _localsize[],
return true;
if( p->haveTempDstUMats )
sync = true;
+ cl_event asyncEvent = 0;
cl_int retval = clEnqueueNDRangeKernel(qq, p->handle, (cl_uint)dims,
offset, globalsize, _localsize, 0, 0,
- sync ? 0 : &p->e);
+ sync ? 0 : &asyncEvent);
#if CV_OPENCL_SHOW_RUN_ERRORS
if (retval != CL_SUCCESS)
{
@@ -3489,18 +2274,22 @@ bool Kernel::run(int dims, size_t _globalsize[], size_t _localsize[],
else
{
p->addref();
- CV_OclDbgAssert(clSetEventCallback(p->e, CL_COMPLETE, oclCleanupCallback, p) == CL_SUCCESS);
+ p->isInProgress = true;
+ CV_OclDbgAssert(clSetEventCallback(asyncEvent, CL_COMPLETE, oclCleanupCallback, p) == CL_SUCCESS);
}
+ if (asyncEvent)
+ clReleaseEvent(asyncEvent);
return retval == CL_SUCCESS;
}
bool Kernel::runTask(bool sync, const Queue& q)
{
- if(!p || !p->handle || p->e != 0)
+ if(!p || !p->handle || p->isInProgress)
return false;
cl_command_queue qq = getQueue(q);
- cl_int retval = clEnqueueTask(qq, p->handle, 0, 0, sync ? 0 : &p->e);
+ cl_event asyncEvent = 0;
+ cl_int retval = clEnqueueTask(qq, p->handle, 0, 0, sync ? 0 : &asyncEvent);
if( sync || retval != CL_SUCCESS )
{
CV_OclDbgAssert(clFinish(qq) == CL_SUCCESS);
@@ -3509,8 +2298,11 @@ bool Kernel::runTask(bool sync, const Queue& q)
else
{
p->addref();
- CV_OclDbgAssert(clSetEventCallback(p->e, CL_COMPLETE, oclCleanupCallback, p) == CL_SUCCESS);
+ p->isInProgress = true;
+ CV_OclDbgAssert(clSetEventCallback(asyncEvent, CL_COMPLETE, oclCleanupCallback, p) == CL_SUCCESS);
}
+ if (asyncEvent)
+ clReleaseEvent(asyncEvent);
return retval == CL_SUCCESS;
}
@@ -3788,24 +2580,46 @@ String Program::getPrefix(const String& buildflags)
struct ProgramSource::Impl
{
- Impl(const char* _src)
+ Impl(const String& src)
{
- init(String(_src));
+ init(cv::String(), cv::String(), src, cv::String());
}
- Impl(const String& _src)
+ Impl(const String& module, const String& name, const String& codeStr, const String& codeHash)
{
- init(_src);
+ init(module, name, codeStr, codeHash);
}
- void init(const String& _src)
+ void init(const String& module, const String& name, const String& codeStr, const String& codeHash)
{
refcount = 1;
- src = _src;
- h = crc64((uchar*)src.c_str(), src.size());
+ module_ = module;
+ name_ = name;
+ codeStr_ = codeStr;
+ codeHash_ = codeHash;
+
+ isHashUpdated = false;
+ if (codeHash_.empty())
+ {
+ updateHash();
+ codeHash_ = cv::format("%08llx", hash_);
+ }
+ }
+
+ void updateHash()
+ {
+ hash_ = crc64((uchar*)codeStr_.c_str(), codeStr_.size());
+ isHashUpdated = true;
}
IMPLEMENT_REFCOUNTABLE();
- String src;
- ProgramSource::hash_t h;
+
+ String module_;
+ String name_;
+ String codeStr_;
+ String codeHash_;
+ // TODO std::vector<ProgramSource> includes_;
+
+ bool isHashUpdated;
+ ProgramSource::hash_t hash_;
};
@@ -3814,6 +2628,11 @@ ProgramSource::ProgramSource()
p = 0;
}
+ProgramSource::ProgramSource(const String& module, const String& name, const String& codeStr, const String& codeHash)
+{
+ p = new Impl(module, name, codeStr, codeHash);
+}
+
ProgramSource::ProgramSource(const char* prog)
{
p = new Impl(prog);
@@ -3850,15 +2669,34 @@ ProgramSource& ProgramSource::operator = (const ProgramSource& prog)
const String& ProgramSource::source() const
{
- static String dummy;
- return p ? p->src : dummy;
+ CV_Assert(p);
+ return p->codeStr_;
}
ProgramSource::hash_t ProgramSource::hash() const
{
- return p ? p->h : 0;
+ CV_Assert(p);
+ if (!p->isHashUpdated)
+ p->updateHash();
+ return p->hash_;
+}
+
+
+internal::ProgramEntry::operator ProgramSource&() const
+{
+ if (this->pProgramSource == NULL)
+ {
+ cv::AutoLock lock(cv::getInitializationMutex());
+ if (this->pProgramSource == NULL)
+ {
+ ProgramSource* ps = new ProgramSource(this->module, this->name, this->programCode, this->programHash);
+ const_cast<ProgramEntry*>(this)->pProgramSource = ps;
+ }
+ }
+ return *this->pProgramSource;
}
+
//////////////////////////////////////////// OpenCLAllocator //////////////////////////////////////////////////
template<typename T>
@@ -4294,17 +3132,21 @@ public:
{
size_t defaultPoolSize, poolSize;
defaultPoolSize = ocl::Device::getDefault().isIntel() ? 1 << 27 : 0;
- poolSize = getConfigurationParameterForSize("OPENCV_OPENCL_BUFFERPOOL_LIMIT", defaultPoolSize);
+ poolSize = utils::getConfigurationParameterSizeT("OPENCV_OPENCL_BUFFERPOOL_LIMIT", defaultPoolSize);
bufferPool.setMaxReservedSize(poolSize);
- poolSize = getConfigurationParameterForSize("OPENCV_OPENCL_HOST_PTR_BUFFERPOOL_LIMIT", defaultPoolSize);
+ poolSize = utils::getConfigurationParameterSizeT("OPENCV_OPENCL_HOST_PTR_BUFFERPOOL_LIMIT", defaultPoolSize);
bufferPoolHostPtr.setMaxReservedSize(poolSize);
#ifdef HAVE_OPENCL_SVM
- poolSize = getConfigurationParameterForSize("OPENCV_OPENCL_SVM_BUFFERPOOL_LIMIT", defaultPoolSize);
+ poolSize = utils::getConfigurationParameterSizeT("OPENCV_OPENCL_SVM_BUFFERPOOL_LIMIT", defaultPoolSize);
bufferPoolSVM.setMaxReservedSize(poolSize);
#endif
matStdAllocator = Mat::getDefaultAllocator();
}
+ ~OpenCLAllocator()
+ {
+ flushCleanupQueue();
+ }
UMatData* defaultAllocate(int dims, const int* sizes, int type, void* data, size_t* step,
int flags, UMatUsageFlags usageFlags) const
@@ -4341,6 +3183,7 @@ public:
}
Context& ctx = Context::getDefault();
+ flushCleanupQueue();
int createFlags = 0, flags0 = 0;
getBestFlags(ctx, flags, usageFlags, createFlags, flags0);
@@ -4395,6 +3238,8 @@ public:
if(!u)
return false;
+ flushCleanupQueue();
+
UMatDataAutoLock lock(u);
if(u->handle == 0)
@@ -4529,6 +3374,15 @@ public:
CV_Assert(u->handle != 0);
CV_Assert(u->mapcount == 0);
+
+ if (u->flags & UMatData::ASYNC_CLEANUP)
+ addToCleanupQueue(u);
+ else
+ deallocate_(u);
+ }
+
+ void deallocate_(UMatData* u) const
+ {
if(u->tempUMat())
{
CV_Assert(u->origdata);
@@ -5332,6 +4186,33 @@ public:
}
MatAllocator* matStdAllocator;
+
+ mutable cv::Mutex cleanupQueueMutex;
+ mutable std::deque<UMatData*> cleanupQueue;
+
+ void flushCleanupQueue() const
+ {
+ if (!cleanupQueue.empty())
+ {
+ std::deque<UMatData*> q;
+ {
+ cv::AutoLock lock(cleanupQueueMutex);
+ q.swap(cleanupQueue);
+ }
+ for (std::deque<UMatData*>::const_iterator i = q.begin(); i != q.end(); ++i)
+ {
+ deallocate_(*i);
+ }
+ }
+ }
+ void addToCleanupQueue(UMatData* u) const
+ {
+ //TODO: Validation check: CV_Assert(!u->tempUMat());
+ {
+ cv::AutoLock lock(cleanupQueueMutex);
+ cleanupQueue.push_back(u);
+ }
+ }
};
MatAllocator* getOpenCLAllocator()
@@ -5528,7 +4409,7 @@ struct PlatformInfo::Impl
getDevices(devices, handle);
}
- String getStrProp(cl_device_info prop) const
+ String getStrProp(cl_platform_info prop) const
{
char buf[1024];
size_t sz=0;
@@ -6079,7 +4960,7 @@ bool internal::isOpenCLForced()
static bool value = false;
if (!initialized)
{
- value = getBoolParameter("OPENCV_OPENCL_FORCE", false);
+ value = utils::getConfigurationParameterBool("OPENCV_OPENCL_FORCE", false);
initialized = true;
}
return value;
@@ -6091,7 +4972,7 @@ bool internal::isPerformanceCheckBypassed()
static bool value = false;
if (!initialized)
{
- value = getBoolParameter("OPENCV_OPENCL_PERF_CHECK_BYPASS", false);
+ value = utils::getConfigurationParameterBool("OPENCV_OPENCL_PERF_CHECK_BYPASS", false);
initialized = true;
}
return value;
diff --git a/modules/core/src/ocl_deprecated.hpp b/modules/core/src/ocl_deprecated.hpp
new file mode 100644
index 0000000..6bf426b
--- /dev/null
+++ b/modules/core/src/ocl_deprecated.hpp
@@ -0,0 +1,1211 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+/*
+ Part of the file is an extract from the standard OpenCL headers from Khronos site.
+ Below is the original copyright.
+*/
+
+/*******************************************************************************
+ * Copyright (c) 2008 - 2012 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are 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 Materials.
+ *
+ * THE MATERIALS ARE 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
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ ******************************************************************************/
+
+#if 0 //defined __APPLE__
+#define HAVE_OPENCL 1
+#else
+#undef HAVE_OPENCL
+#endif
+
+#define OPENCV_CL_NOT_IMPLEMENTED -1000
+
+#ifdef HAVE_OPENCL
+
+#if defined __APPLE__
+#include <OpenCL/opencl.h>
+#else
+#include <CL/opencl.h>
+#endif
+
+static const bool g_haveOpenCL = true;
+
+#else
+
+extern "C" {
+
+struct _cl_platform_id { int dummy; };
+struct _cl_device_id { int dummy; };
+struct _cl_context { int dummy; };
+struct _cl_command_queue { int dummy; };
+struct _cl_mem { int dummy; };
+struct _cl_program { int dummy; };
+struct _cl_kernel { int dummy; };
+struct _cl_event { int dummy; };
+struct _cl_sampler { int dummy; };
+
+typedef struct _cl_platform_id * cl_platform_id;
+typedef struct _cl_device_id * cl_device_id;
+typedef struct _cl_context * cl_context;
+typedef struct _cl_command_queue * cl_command_queue;
+typedef struct _cl_mem * cl_mem;
+typedef struct _cl_program * cl_program;
+typedef struct _cl_kernel * cl_kernel;
+typedef struct _cl_event * cl_event;
+typedef struct _cl_sampler * cl_sampler;
+
+typedef int cl_int;
+typedef unsigned cl_uint;
+#if defined (_WIN32) && defined(_MSC_VER)
+ typedef __int64 cl_long;
+ typedef unsigned __int64 cl_ulong;
+#else
+ typedef long cl_long;
+ typedef unsigned long cl_ulong;
+#endif
+
+typedef cl_uint cl_bool; /* WARNING! Unlike cl_ types in cl_platform.h, cl_bool is not guaranteed to be the same size as the bool in kernels. */
+typedef cl_ulong cl_bitfield;
+typedef cl_bitfield cl_device_type;
+typedef cl_uint cl_platform_info;
+typedef cl_uint cl_device_info;
+typedef cl_bitfield cl_device_fp_config;
+typedef cl_uint cl_device_mem_cache_type;
+typedef cl_uint cl_device_local_mem_type;
+typedef cl_bitfield cl_device_exec_capabilities;
+typedef cl_bitfield cl_command_queue_properties;
+typedef intptr_t cl_device_partition_property;
+typedef cl_bitfield cl_device_affinity_domain;
+
+typedef intptr_t cl_context_properties;
+typedef cl_uint cl_context_info;
+typedef cl_uint cl_command_queue_info;
+typedef cl_uint cl_channel_order;
+typedef cl_uint cl_channel_type;
+typedef cl_bitfield cl_mem_flags;
+typedef cl_uint cl_mem_object_type;
+typedef cl_uint cl_mem_info;
+typedef cl_bitfield cl_mem_migration_flags;
+typedef cl_uint cl_image_info;
+typedef cl_uint cl_buffer_create_type;
+typedef cl_uint cl_addressing_mode;
+typedef cl_uint cl_filter_mode;
+typedef cl_uint cl_sampler_info;
+typedef cl_bitfield cl_map_flags;
+typedef cl_uint cl_program_info;
+typedef cl_uint cl_program_build_info;
+typedef cl_uint cl_program_binary_type;
+typedef cl_int cl_build_status;
+typedef cl_uint cl_kernel_info;
+typedef cl_uint cl_kernel_arg_info;
+typedef cl_uint cl_kernel_arg_address_qualifier;
+typedef cl_uint cl_kernel_arg_access_qualifier;
+typedef cl_bitfield cl_kernel_arg_type_qualifier;
+typedef cl_uint cl_kernel_work_group_info;
+typedef cl_uint cl_event_info;
+typedef cl_uint cl_command_type;
+typedef cl_uint cl_profiling_info;
+
+
+typedef struct _cl_image_format {
+ cl_channel_order image_channel_order;
+ cl_channel_type image_channel_data_type;
+} cl_image_format;
+
+typedef struct _cl_image_desc {
+ cl_mem_object_type image_type;
+ size_t image_width;
+ size_t image_height;
+ size_t image_depth;
+ size_t image_array_size;
+ size_t image_row_pitch;
+ size_t image_slice_pitch;
+ cl_uint num_mip_levels;
+ cl_uint num_samples;
+ cl_mem buffer;
+} cl_image_desc;
+
+typedef struct _cl_buffer_region {
+ size_t origin;
+ size_t size;
+} cl_buffer_region;
+
+
+//////////////////////////////////////////////////////////
+
+#define CL_SUCCESS 0
+#define CL_DEVICE_NOT_FOUND -1
+#define CL_DEVICE_NOT_AVAILABLE -2
+#define CL_COMPILER_NOT_AVAILABLE -3
+#define CL_MEM_OBJECT_ALLOCATION_FAILURE -4
+#define CL_OUT_OF_RESOURCES -5
+#define CL_OUT_OF_HOST_MEMORY -6
+#define CL_PROFILING_INFO_NOT_AVAILABLE -7
+#define CL_MEM_COPY_OVERLAP -8
+#define CL_IMAGE_FORMAT_MISMATCH -9
+#define CL_IMAGE_FORMAT_NOT_SUPPORTED -10
+#define CL_BUILD_PROGRAM_FAILURE -11
+#define CL_MAP_FAILURE -12
+#define CL_MISALIGNED_SUB_BUFFER_OFFSET -13
+#define CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST -14
+#define CL_COMPILE_PROGRAM_FAILURE -15
+#define CL_LINKER_NOT_AVAILABLE -16
+#define CL_LINK_PROGRAM_FAILURE -17
+#define CL_DEVICE_PARTITION_FAILED -18
+#define CL_KERNEL_ARG_INFO_NOT_AVAILABLE -19
+
+#define CL_INVALID_VALUE -30
+#define CL_INVALID_DEVICE_TYPE -31
+#define CL_INVALID_PLATFORM -32
+#define CL_INVALID_DEVICE -33
+#define CL_INVALID_CONTEXT -34
+#define CL_INVALID_QUEUE_PROPERTIES -35
+#define CL_INVALID_COMMAND_QUEUE -36
+#define CL_INVALID_HOST_PTR -37
+#define CL_INVALID_MEM_OBJECT -38
+#define CL_INVALID_IMAGE_FORMAT_DESCRIPTOR -39
+#define CL_INVALID_IMAGE_SIZE -40
+#define CL_INVALID_SAMPLER -41
+#define CL_INVALID_BINARY -42
+#define CL_INVALID_BUILD_OPTIONS -43
+#define CL_INVALID_PROGRAM -44
+#define CL_INVALID_PROGRAM_EXECUTABLE -45
+#define CL_INVALID_KERNEL_NAME -46
+#define CL_INVALID_KERNEL_DEFINITION -47
+#define CL_INVALID_KERNEL -48
+#define CL_INVALID_ARG_INDEX -49
+#define CL_INVALID_ARG_VALUE -50
+#define CL_INVALID_ARG_SIZE -51
+#define CL_INVALID_KERNEL_ARGS -52
+#define CL_INVALID_WORK_DIMENSION -53
+#define CL_INVALID_WORK_GROUP_SIZE -54
+#define CL_INVALID_WORK_ITEM_SIZE -55
+#define CL_INVALID_GLOBAL_OFFSET -56
+#define CL_INVALID_EVENT_WAIT_LIST -57
+#define CL_INVALID_EVENT -58
+#define CL_INVALID_OPERATION -59
+#define CL_INVALID_GL_OBJECT -60
+#define CL_INVALID_BUFFER_SIZE -61
+#define CL_INVALID_MIP_LEVEL -62
+#define CL_INVALID_GLOBAL_WORK_SIZE -63
+#define CL_INVALID_PROPERTY -64
+#define CL_INVALID_IMAGE_DESCRIPTOR -65
+#define CL_INVALID_COMPILER_OPTIONS -66
+#define CL_INVALID_LINKER_OPTIONS -67
+#define CL_INVALID_DEVICE_PARTITION_COUNT -68
+
+/*#define CL_VERSION_1_0 1
+#define CL_VERSION_1_1 1
+#define CL_VERSION_1_2 1*/
+
+#define CL_FALSE 0
+#define CL_TRUE 1
+#define CL_BLOCKING CL_TRUE
+#define CL_NON_BLOCKING CL_FALSE
+
+#define CL_PLATFORM_PROFILE 0x0900
+#define CL_PLATFORM_VERSION 0x0901
+#define CL_PLATFORM_NAME 0x0902
+#define CL_PLATFORM_VENDOR 0x0903
+#define CL_PLATFORM_EXTENSIONS 0x0904
+
+#define CL_DEVICE_TYPE_DEFAULT (1 << 0)
+#define CL_DEVICE_TYPE_CPU (1 << 1)
+#define CL_DEVICE_TYPE_GPU (1 << 2)
+#define CL_DEVICE_TYPE_ACCELERATOR (1 << 3)
+#define CL_DEVICE_TYPE_CUSTOM (1 << 4)
+#define CL_DEVICE_TYPE_ALL 0xFFFFFFFF
+#define CL_DEVICE_TYPE 0x1000
+#define CL_DEVICE_VENDOR_ID 0x1001
+#define CL_DEVICE_MAX_COMPUTE_UNITS 0x1002
+#define CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS 0x1003
+#define CL_DEVICE_MAX_WORK_GROUP_SIZE 0x1004
+#define CL_DEVICE_MAX_WORK_ITEM_SIZES 0x1005
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR 0x1006
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT 0x1007
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT 0x1008
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG 0x1009
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT 0x100A
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE 0x100B
+#define CL_DEVICE_MAX_CLOCK_FREQUENCY 0x100C
+#define CL_DEVICE_ADDRESS_BITS 0x100D
+#define CL_DEVICE_MAX_READ_IMAGE_ARGS 0x100E
+#define CL_DEVICE_MAX_WRITE_IMAGE_ARGS 0x100F
+#define CL_DEVICE_MAX_MEM_ALLOC_SIZE 0x1010
+#define CL_DEVICE_IMAGE2D_MAX_WIDTH 0x1011
+#define CL_DEVICE_IMAGE2D_MAX_HEIGHT 0x1012
+#define CL_DEVICE_IMAGE3D_MAX_WIDTH 0x1013
+#define CL_DEVICE_IMAGE3D_MAX_HEIGHT 0x1014
+#define CL_DEVICE_IMAGE3D_MAX_DEPTH 0x1015
+#define CL_DEVICE_IMAGE_SUPPORT 0x1016
+#define CL_DEVICE_MAX_PARAMETER_SIZE 0x1017
+#define CL_DEVICE_MAX_SAMPLERS 0x1018
+#define CL_DEVICE_MEM_BASE_ADDR_ALIGN 0x1019
+#define CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE 0x101A
+#define CL_DEVICE_SINGLE_FP_CONFIG 0x101B
+#define CL_DEVICE_GLOBAL_MEM_CACHE_TYPE 0x101C
+#define CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE 0x101D
+#define CL_DEVICE_GLOBAL_MEM_CACHE_SIZE 0x101E
+#define CL_DEVICE_GLOBAL_MEM_SIZE 0x101F
+#define CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE 0x1020
+#define CL_DEVICE_MAX_CONSTANT_ARGS 0x1021
+#define CL_DEVICE_LOCAL_MEM_TYPE 0x1022
+#define CL_DEVICE_LOCAL_MEM_SIZE 0x1023
+#define CL_DEVICE_ERROR_CORRECTION_SUPPORT 0x1024
+#define CL_DEVICE_PROFILING_TIMER_RESOLUTION 0x1025
+#define CL_DEVICE_ENDIAN_LITTLE 0x1026
+#define CL_DEVICE_AVAILABLE 0x1027
+#define CL_DEVICE_COMPILER_AVAILABLE 0x1028
+#define CL_DEVICE_EXECUTION_CAPABILITIES 0x1029
+#define CL_DEVICE_QUEUE_PROPERTIES 0x102A
+#define CL_DEVICE_NAME 0x102B
+#define CL_DEVICE_VENDOR 0x102C
+#define CL_DRIVER_VERSION 0x102D
+#define CL_DEVICE_PROFILE 0x102E
+#define CL_DEVICE_VERSION 0x102F
+#define CL_DEVICE_EXTENSIONS 0x1030
+#define CL_DEVICE_PLATFORM 0x1031
+#define CL_DEVICE_DOUBLE_FP_CONFIG 0x1032
+#define CL_DEVICE_HALF_FP_CONFIG 0x1033
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF 0x1034
+#define CL_DEVICE_HOST_UNIFIED_MEMORY 0x1035
+#define CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR 0x1036
+#define CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT 0x1037
+#define CL_DEVICE_NATIVE_VECTOR_WIDTH_INT 0x1038
+#define CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG 0x1039
+#define CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT 0x103A
+#define CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE 0x103B
+#define CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF 0x103C
+#define CL_DEVICE_OPENCL_C_VERSION 0x103D
+#define CL_DEVICE_LINKER_AVAILABLE 0x103E
+#define CL_DEVICE_BUILT_IN_KERNELS 0x103F
+#define CL_DEVICE_IMAGE_MAX_BUFFER_SIZE 0x1040
+#define CL_DEVICE_IMAGE_MAX_ARRAY_SIZE 0x1041
+#define CL_DEVICE_PARENT_DEVICE 0x1042
+#define CL_DEVICE_PARTITION_MAX_SUB_DEVICES 0x1043
+#define CL_DEVICE_PARTITION_PROPERTIES 0x1044
+#define CL_DEVICE_PARTITION_AFFINITY_DOMAIN 0x1045
+#define CL_DEVICE_PARTITION_TYPE 0x1046
+#define CL_DEVICE_REFERENCE_COUNT 0x1047
+#define CL_DEVICE_PREFERRED_INTEROP_USER_SYNC 0x1048
+#define CL_DEVICE_PRINTF_BUFFER_SIZE 0x1049
+#define CL_DEVICE_IMAGE_PITCH_ALIGNMENT 0x104A
+#define CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT 0x104B
+
+#define CL_FP_DENORM (1 << 0)
+#define CL_FP_INF_NAN (1 << 1)
+#define CL_FP_ROUND_TO_NEAREST (1 << 2)
+#define CL_FP_ROUND_TO_ZERO (1 << 3)
+#define CL_FP_ROUND_TO_INF (1 << 4)
+#define CL_FP_FMA (1 << 5)
+#define CL_FP_SOFT_FLOAT (1 << 6)
+#define CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT (1 << 7)
+
+#define CL_NONE 0x0
+#define CL_READ_ONLY_CACHE 0x1
+#define CL_READ_WRITE_CACHE 0x2
+#define CL_LOCAL 0x1
+#define CL_GLOBAL 0x2
+#define CL_EXEC_KERNEL (1 << 0)
+#define CL_EXEC_NATIVE_KERNEL (1 << 1)
+#define CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE (1 << 0)
+#define CL_QUEUE_PROFILING_ENABLE (1 << 1)
+
+#define CL_CONTEXT_REFERENCE_COUNT 0x1080
+#define CL_CONTEXT_DEVICES 0x1081
+#define CL_CONTEXT_PROPERTIES 0x1082
+#define CL_CONTEXT_NUM_DEVICES 0x1083
+#define CL_CONTEXT_PLATFORM 0x1084
+#define CL_CONTEXT_INTEROP_USER_SYNC 0x1085
+
+#define CL_DEVICE_PARTITION_EQUALLY 0x1086
+#define CL_DEVICE_PARTITION_BY_COUNTS 0x1087
+#define CL_DEVICE_PARTITION_BY_COUNTS_LIST_END 0x0
+#define CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN 0x1088
+#define CL_DEVICE_AFFINITY_DOMAIN_NUMA (1 << 0)
+#define CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE (1 << 1)
+#define CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE (1 << 2)
+#define CL_DEVICE_AFFINITY_DOMAIN_L2_CACHE (1 << 3)
+#define CL_DEVICE_AFFINITY_DOMAIN_L1_CACHE (1 << 4)
+#define CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE (1 << 5)
+#define CL_QUEUE_CONTEXT 0x1090
+#define CL_QUEUE_DEVICE 0x1091
+#define CL_QUEUE_REFERENCE_COUNT 0x1092
+#define CL_QUEUE_PROPERTIES 0x1093
+#define CL_MEM_READ_WRITE (1 << 0)
+#define CL_MEM_WRITE_ONLY (1 << 1)
+#define CL_MEM_READ_ONLY (1 << 2)
+#define CL_MEM_USE_HOST_PTR (1 << 3)
+#define CL_MEM_ALLOC_HOST_PTR (1 << 4)
+#define CL_MEM_COPY_HOST_PTR (1 << 5)
+// reserved (1 << 6)
+#define CL_MEM_HOST_WRITE_ONLY (1 << 7)
+#define CL_MEM_HOST_READ_ONLY (1 << 8)
+#define CL_MEM_HOST_NO_ACCESS (1 << 9)
+#define CL_MIGRATE_MEM_OBJECT_HOST (1 << 0)
+#define CL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED (1 << 1)
+
+#define CL_R 0x10B0
+#define CL_A 0x10B1
+#define CL_RG 0x10B2
+#define CL_RA 0x10B3
+#define CL_RGB 0x10B4
+#define CL_RGBA 0x10B5
+#define CL_BGRA 0x10B6
+#define CL_ARGB 0x10B7
+#define CL_INTENSITY 0x10B8
+#define CL_LUMINANCE 0x10B9
+#define CL_Rx 0x10BA
+#define CL_RGx 0x10BB
+#define CL_RGBx 0x10BC
+#define CL_DEPTH 0x10BD
+#define CL_DEPTH_STENCIL 0x10BE
+
+#define CL_SNORM_INT8 0x10D0
+#define CL_SNORM_INT16 0x10D1
+#define CL_UNORM_INT8 0x10D2
+#define CL_UNORM_INT16 0x10D3
+#define CL_UNORM_SHORT_565 0x10D4
+#define CL_UNORM_SHORT_555 0x10D5
+#define CL_UNORM_INT_101010 0x10D6
+#define CL_SIGNED_INT8 0x10D7
+#define CL_SIGNED_INT16 0x10D8
+#define CL_SIGNED_INT32 0x10D9
+#define CL_UNSIGNED_INT8 0x10DA
+#define CL_UNSIGNED_INT16 0x10DB
+#define CL_UNSIGNED_INT32 0x10DC
+#define CL_HALF_FLOAT 0x10DD
+#define CL_FLOAT 0x10DE
+#define CL_UNORM_INT24 0x10DF
+
+#define CL_MEM_OBJECT_BUFFER 0x10F0
+#define CL_MEM_OBJECT_IMAGE2D 0x10F1
+#define CL_MEM_OBJECT_IMAGE3D 0x10F2
+#define CL_MEM_OBJECT_IMAGE2D_ARRAY 0x10F3
+#define CL_MEM_OBJECT_IMAGE1D 0x10F4
+#define CL_MEM_OBJECT_IMAGE1D_ARRAY 0x10F5
+#define CL_MEM_OBJECT_IMAGE1D_BUFFER 0x10F6
+
+#define CL_MEM_TYPE 0x1100
+#define CL_MEM_FLAGS 0x1101
+#define CL_MEM_SIZE 0x1102
+#define CL_MEM_HOST_PTR 0x1103
+#define CL_MEM_MAP_COUNT 0x1104
+#define CL_MEM_REFERENCE_COUNT 0x1105
+#define CL_MEM_CONTEXT 0x1106
+#define CL_MEM_ASSOCIATED_MEMOBJECT 0x1107
+#define CL_MEM_OFFSET 0x1108
+
+#define CL_IMAGE_FORMAT 0x1110
+#define CL_IMAGE_ELEMENT_SIZE 0x1111
+#define CL_IMAGE_ROW_PITCH 0x1112
+#define CL_IMAGE_SLICE_PITCH 0x1113
+#define CL_IMAGE_WIDTH 0x1114
+#define CL_IMAGE_HEIGHT 0x1115
+#define CL_IMAGE_DEPTH 0x1116
+#define CL_IMAGE_ARRAY_SIZE 0x1117
+#define CL_IMAGE_BUFFER 0x1118
+#define CL_IMAGE_NUM_MIP_LEVELS 0x1119
+#define CL_IMAGE_NUM_SAMPLES 0x111A
+
+#define CL_ADDRESS_NONE 0x1130
+#define CL_ADDRESS_CLAMP_TO_EDGE 0x1131
+#define CL_ADDRESS_CLAMP 0x1132
+#define CL_ADDRESS_REPEAT 0x1133
+#define CL_ADDRESS_MIRRORED_REPEAT 0x1134
+
+#define CL_FILTER_NEAREST 0x1140
+#define CL_FILTER_LINEAR 0x1141
+
+#define CL_SAMPLER_REFERENCE_COUNT 0x1150
+#define CL_SAMPLER_CONTEXT 0x1151
+#define CL_SAMPLER_NORMALIZED_COORDS 0x1152
+#define CL_SAMPLER_ADDRESSING_MODE 0x1153
+#define CL_SAMPLER_FILTER_MODE 0x1154
+
+#define CL_MAP_READ (1 << 0)
+#define CL_MAP_WRITE (1 << 1)
+#define CL_MAP_WRITE_INVALIDATE_REGION (1 << 2)
+
+#define CL_PROGRAM_REFERENCE_COUNT 0x1160
+#define CL_PROGRAM_CONTEXT 0x1161
+#define CL_PROGRAM_NUM_DEVICES 0x1162
+#define CL_PROGRAM_DEVICES 0x1163
+#define CL_PROGRAM_SOURCE 0x1164
+#define CL_PROGRAM_BINARY_SIZES 0x1165
+#define CL_PROGRAM_BINARIES 0x1166
+#define CL_PROGRAM_NUM_KERNELS 0x1167
+#define CL_PROGRAM_KERNEL_NAMES 0x1168
+#define CL_PROGRAM_BUILD_STATUS 0x1181
+#define CL_PROGRAM_BUILD_OPTIONS 0x1182
+#define CL_PROGRAM_BUILD_LOG 0x1183
+#define CL_PROGRAM_BINARY_TYPE 0x1184
+#define CL_PROGRAM_BINARY_TYPE_NONE 0x0
+#define CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT 0x1
+#define CL_PROGRAM_BINARY_TYPE_LIBRARY 0x2
+#define CL_PROGRAM_BINARY_TYPE_EXECUTABLE 0x4
+
+#define CL_BUILD_SUCCESS 0
+#define CL_BUILD_NONE -1
+#define CL_BUILD_ERROR -2
+#define CL_BUILD_IN_PROGRESS -3
+
+#define CL_KERNEL_FUNCTION_NAME 0x1190
+#define CL_KERNEL_NUM_ARGS 0x1191
+#define CL_KERNEL_REFERENCE_COUNT 0x1192
+#define CL_KERNEL_CONTEXT 0x1193
+#define CL_KERNEL_PROGRAM 0x1194
+#define CL_KERNEL_ATTRIBUTES 0x1195
+#define CL_KERNEL_ARG_ADDRESS_QUALIFIER 0x1196
+#define CL_KERNEL_ARG_ACCESS_QUALIFIER 0x1197
+#define CL_KERNEL_ARG_TYPE_NAME 0x1198
+#define CL_KERNEL_ARG_TYPE_QUALIFIER 0x1199
+#define CL_KERNEL_ARG_NAME 0x119A
+#define CL_KERNEL_ARG_ADDRESS_GLOBAL 0x119B
+#define CL_KERNEL_ARG_ADDRESS_LOCAL 0x119C
+#define CL_KERNEL_ARG_ADDRESS_CONSTANT 0x119D
+#define CL_KERNEL_ARG_ADDRESS_PRIVATE 0x119E
+#define CL_KERNEL_ARG_ACCESS_READ_ONLY 0x11A0
+#define CL_KERNEL_ARG_ACCESS_WRITE_ONLY 0x11A1
+#define CL_KERNEL_ARG_ACCESS_READ_WRITE 0x11A2
+#define CL_KERNEL_ARG_ACCESS_NONE 0x11A3
+#define CL_KERNEL_ARG_TYPE_NONE 0
+#define CL_KERNEL_ARG_TYPE_CONST (1 << 0)
+#define CL_KERNEL_ARG_TYPE_RESTRICT (1 << 1)
+#define CL_KERNEL_ARG_TYPE_VOLATILE (1 << 2)
+#define CL_KERNEL_WORK_GROUP_SIZE 0x11B0
+#define CL_KERNEL_COMPILE_WORK_GROUP_SIZE 0x11B1
+#define CL_KERNEL_LOCAL_MEM_SIZE 0x11B2
+#define CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE 0x11B3
+#define CL_KERNEL_PRIVATE_MEM_SIZE 0x11B4
+#define CL_KERNEL_GLOBAL_WORK_SIZE 0x11B5
+
+#define CL_EVENT_COMMAND_QUEUE 0x11D0
+#define CL_EVENT_COMMAND_TYPE 0x11D1
+#define CL_EVENT_REFERENCE_COUNT 0x11D2
+#define CL_EVENT_COMMAND_EXECUTION_STATUS 0x11D3
+#define CL_EVENT_CONTEXT 0x11D4
+
+#define CL_COMMAND_NDRANGE_KERNEL 0x11F0
+#define CL_COMMAND_TASK 0x11F1
+#define CL_COMMAND_NATIVE_KERNEL 0x11F2
+#define CL_COMMAND_READ_BUFFER 0x11F3
+#define CL_COMMAND_WRITE_BUFFER 0x11F4
+#define CL_COMMAND_COPY_BUFFER 0x11F5
+#define CL_COMMAND_READ_IMAGE 0x11F6
+#define CL_COMMAND_WRITE_IMAGE 0x11F7
+#define CL_COMMAND_COPY_IMAGE 0x11F8
+#define CL_COMMAND_COPY_IMAGE_TO_BUFFER 0x11F9
+#define CL_COMMAND_COPY_BUFFER_TO_IMAGE 0x11FA
+#define CL_COMMAND_MAP_BUFFER 0x11FB
+#define CL_COMMAND_MAP_IMAGE 0x11FC
+#define CL_COMMAND_UNMAP_MEM_OBJECT 0x11FD
+#define CL_COMMAND_MARKER 0x11FE
+#define CL_COMMAND_ACQUIRE_GL_OBJECTS 0x11FF
+#define CL_COMMAND_RELEASE_GL_OBJECTS 0x1200
+#define CL_COMMAND_READ_BUFFER_RECT 0x1201
+#define CL_COMMAND_WRITE_BUFFER_RECT 0x1202
+#define CL_COMMAND_COPY_BUFFER_RECT 0x1203
+#define CL_COMMAND_USER 0x1204
+#define CL_COMMAND_BARRIER 0x1205
+#define CL_COMMAND_MIGRATE_MEM_OBJECTS 0x1206
+#define CL_COMMAND_FILL_BUFFER 0x1207
+#define CL_COMMAND_FILL_IMAGE 0x1208
+
+#define CL_COMPLETE 0x0
+#define CL_RUNNING 0x1
+#define CL_SUBMITTED 0x2
+#define CL_QUEUED 0x3
+#define CL_BUFFER_CREATE_TYPE_REGION 0x1220
+
+#define CL_PROFILING_COMMAND_QUEUED 0x1280
+#define CL_PROFILING_COMMAND_SUBMIT 0x1281
+#define CL_PROFILING_COMMAND_START 0x1282
+#define CL_PROFILING_COMMAND_END 0x1283
+
+#define CL_CALLBACK CV_STDCALL
+
+
+#ifdef HAVE_OPENCL
+static const char* oclFuncToCheck = "clEnqueueReadBufferRect";
+static volatile bool g_haveOpenCL = false;
+#endif
+
+#if defined(__APPLE__) && defined(HAVE_OPENCL)
+#include <dlfcn.h>
+
+static void* initOpenCLAndLoad(const char* funcname)
+{
+ static bool initialized = false;
+ static void* handle = 0;
+ if (!handle)
+ {
+ if(!initialized)
+ {
+ const char* oclpath = getenv("OPENCV_OPENCL_RUNTIME");
+ oclpath = oclpath && strlen(oclpath) > 0 ? oclpath :
+ "/System/Library/Frameworks/OpenCL.framework/Versions/Current/OpenCL";
+ handle = dlopen(oclpath, RTLD_LAZY);
+ initialized = true;
+ g_haveOpenCL = handle != 0 && dlsym(handle, oclFuncToCheck) != 0;
+ if( g_haveOpenCL )
+ fprintf(stderr, "Successfully loaded OpenCL v1.1+ runtime from %s\n", oclpath);
+ else
+ fprintf(stderr, "Failed to load OpenCL runtime\n");
+ }
+ if(!handle)
+ return 0;
+ }
+
+ return funcname && handle ? dlsym(handle, funcname) : 0;
+}
+
+#elif defined _WIN32 && defined(HAVE_OPENCL)
+
+#ifndef _WIN32_WINNT // This is needed for the declaration of TryEnterCriticalSection in winbase.h with Visual Studio 2005 (and older?)
+ #define _WIN32_WINNT 0x0400 // http://msdn.microsoft.com/en-us/library/ms686857(VS.85).aspx
+#endif
+#include <windows.h>
+#if (_WIN32_WINNT >= 0x0602)
+ #include <synchapi.h>
+#endif
+#undef small
+#undef min
+#undef max
+#undef abs
+
+static void* initOpenCLAndLoad(const char* funcname)
+{
+ static bool initialized = false;
+ static HMODULE handle = 0;
+ if (!handle)
+ {
+#ifndef WINRT
+ if(!initialized)
+ {
+ handle = LoadLibraryA("OpenCL.dll");
+ initialized = true;
+ g_haveOpenCL = handle != 0 && GetProcAddress(handle, oclFuncToCheck) != 0;
+ }
+#endif
+ if(!handle)
+ return 0;
+ }
+
+ return funcname ? (void*)GetProcAddress(handle, funcname) : 0;
+}
+
+#elif defined(__linux) && defined(HAVE_OPENCL)
+
+#include <dlfcn.h>
+#include <stdio.h>
+
+static void* initOpenCLAndLoad(const char* funcname)
+{
+ static bool initialized = false;
+ static void* handle = 0;
+ if (!handle)
+ {
+ if(!initialized)
+ {
+ handle = dlopen("libOpenCL.so", RTLD_LAZY);
+ if(!handle)
+ handle = dlopen("libCL.so", RTLD_LAZY);
+ initialized = true;
+ g_haveOpenCL = handle != 0 && dlsym(handle, oclFuncToCheck) != 0;
+ }
+ if(!handle)
+ return 0;
+ }
+
+ return funcname ? (void*)dlsym(handle, funcname) : 0;
+}
+
+#else
+
+static void* initOpenCLAndLoad(const char*)
+{
+ return 0;
+}
+
+#endif
+
+
+#define OCL_FUNC(rettype, funcname, argsdecl, args) \
+ typedef rettype (CV_STDCALL * funcname##_t) argsdecl; \
+ static rettype funcname argsdecl \
+ { \
+ static funcname##_t funcname##_p = 0; \
+ if( !funcname##_p ) \
+ { \
+ funcname##_p = (funcname##_t)initOpenCLAndLoad(#funcname); \
+ if( !funcname##_p ) \
+ return OPENCV_CL_NOT_IMPLEMENTED; \
+ } \
+ return funcname##_p args; \
+ }
+
+
+#define OCL_FUNC_P(rettype, funcname, argsdecl, args) \
+ typedef rettype (CV_STDCALL * funcname##_t) argsdecl; \
+ static rettype funcname argsdecl \
+ { \
+ static funcname##_t funcname##_p = 0; \
+ if( !funcname##_p ) \
+ { \
+ funcname##_p = (funcname##_t)initOpenCLAndLoad(#funcname); \
+ if( !funcname##_p ) \
+ { \
+ if( errcode_ret ) \
+ *errcode_ret = OPENCV_CL_NOT_IMPLEMENTED; \
+ return 0; \
+ } \
+ } \
+ return funcname##_p args; \
+ }
+
+OCL_FUNC(cl_int, clGetPlatformIDs,
+ (cl_uint num_entries, cl_platform_id* platforms, cl_uint* num_platforms),
+ (num_entries, platforms, num_platforms))
+
+OCL_FUNC(cl_int, clGetPlatformInfo,
+ (cl_platform_id platform, cl_platform_info param_name,
+ size_t param_value_size, void * param_value,
+ size_t * param_value_size_ret),
+ (platform, param_name, param_value_size, param_value, param_value_size_ret))
+
+OCL_FUNC(cl_int, clGetDeviceInfo,
+ (cl_device_id device,
+ cl_device_info param_name,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret),
+ (device, param_name, param_value_size, param_value, param_value_size_ret))
+
+
+OCL_FUNC(cl_int, clGetDeviceIDs,
+ (cl_platform_id platform,
+ cl_device_type device_type,
+ cl_uint num_entries,
+ cl_device_id * devices,
+ cl_uint * num_devices),
+ (platform, device_type, num_entries, devices, num_devices))
+
+OCL_FUNC_P(cl_context, clCreateContext,
+ (const cl_context_properties * properties,
+ cl_uint num_devices,
+ const cl_device_id * devices,
+ void (CL_CALLBACK * pfn_notify)(const char *, const void *, size_t, void *),
+ void * user_data,
+ cl_int * errcode_ret),
+ (properties, num_devices, devices, pfn_notify, user_data, errcode_ret))
+
+OCL_FUNC(cl_int, clReleaseContext, (cl_context context), (context))
+
+
+OCL_FUNC(cl_int, clRetainContext, (cl_context context), (context))
+/*
+OCL_FUNC_P(cl_context, clCreateContextFromType,
+ (const cl_context_properties * properties,
+ cl_device_type device_type,
+ void (CL_CALLBACK * pfn_notify)(const char *, const void *, size_t, void *),
+ void * user_data,
+ cl_int * errcode_ret),
+ (properties, device_type, pfn_notify, user_data, errcode_ret))
+
+OCL_FUNC(cl_int, clGetContextInfo,
+ (cl_context context,
+ cl_context_info param_name,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret),
+ (context, param_name, param_value_size,
+ param_value, param_value_size_ret))
+*/
+OCL_FUNC_P(cl_command_queue, clCreateCommandQueue,
+ (cl_context context,
+ cl_device_id device,
+ cl_command_queue_properties properties,
+ cl_int * errcode_ret),
+ (context, device, properties, errcode_ret))
+
+OCL_FUNC(cl_int, clReleaseCommandQueue, (cl_command_queue command_queue), (command_queue))
+
+OCL_FUNC_P(cl_mem, clCreateBuffer,
+ (cl_context context,
+ cl_mem_flags flags,
+ size_t size,
+ void * host_ptr,
+ cl_int * errcode_ret),
+ (context, flags, size, host_ptr, errcode_ret))
+
+/*
+OCL_FUNC(cl_int, clRetainCommandQueue, (cl_command_queue command_queue), (command_queue))
+
+OCL_FUNC(cl_int, clGetCommandQueueInfo,
+ (cl_command_queue command_queue,
+ cl_command_queue_info param_name,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret),
+ (command_queue, param_name, param_value_size, param_value, param_value_size_ret))
+
+OCL_FUNC_P(cl_mem, clCreateSubBuffer,
+ (cl_mem buffer,
+ cl_mem_flags flags,
+ cl_buffer_create_type buffer_create_type,
+ const void * buffer_create_info,
+ cl_int * errcode_ret),
+ (buffer, flags, buffer_create_type, buffer_create_info, errcode_ret))
+*/
+
+OCL_FUNC_P(cl_mem, clCreateImage,
+ (cl_context context,
+ cl_mem_flags flags,
+ const cl_image_format * image_format,
+ const cl_image_desc * image_desc,
+ void * host_ptr,
+ cl_int * errcode_ret),
+ (context, flags, image_format, image_desc, host_ptr, errcode_ret))
+
+OCL_FUNC_P(cl_mem, clCreateImage2D,
+ (cl_context context,
+ cl_mem_flags flags,
+ const cl_image_format * image_format,
+ size_t image_width,
+ size_t image_height,
+ size_t image_row_pitch,
+ void * host_ptr,
+ cl_int *errcode_ret),
+ (context, flags, image_format, image_width, image_height, image_row_pitch, host_ptr, errcode_ret))
+
+OCL_FUNC(cl_int, clGetSupportedImageFormats,
+ (cl_context context,
+ cl_mem_flags flags,
+ cl_mem_object_type image_type,
+ cl_uint num_entries,
+ cl_image_format * image_formats,
+ cl_uint * num_image_formats),
+ (context, flags, image_type, num_entries, image_formats, num_image_formats))
+
+
+OCL_FUNC(cl_int, clGetMemObjectInfo,
+ (cl_mem memobj,
+ cl_mem_info param_name,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret),
+ (memobj, param_name, param_value_size, param_value, param_value_size_ret))
+
+OCL_FUNC(cl_int, clGetImageInfo,
+ (cl_mem image,
+ cl_image_info param_name,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret),
+ (image, param_name, param_value_size, param_value, param_value_size_ret))
+
+/*
+OCL_FUNC(cl_int, clCreateKernelsInProgram,
+ (cl_program program,
+ cl_uint num_kernels,
+ cl_kernel * kernels,
+ cl_uint * num_kernels_ret),
+ (program, num_kernels, kernels, num_kernels_ret))
+
+OCL_FUNC(cl_int, clRetainKernel, (cl_kernel kernel), (kernel))
+
+OCL_FUNC(cl_int, clGetKernelArgInfo,
+ (cl_kernel kernel,
+ cl_uint arg_indx,
+ cl_kernel_arg_info param_name,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret),
+ (kernel, arg_indx, param_name, param_value_size, param_value, param_value_size_ret))
+
+OCL_FUNC(cl_int, clEnqueueReadImage,
+ (cl_command_queue command_queue,
+ cl_mem image,
+ cl_bool blocking_read,
+ const size_t * origin[3],
+ const size_t * region[3],
+ size_t row_pitch,
+ size_t slice_pitch,
+ void * ptr,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event),
+ (command_queue, image, blocking_read, origin, region,
+ row_pitch, slice_pitch,
+ ptr,
+ num_events_in_wait_list,
+ event_wait_list,
+ event))
+
+OCL_FUNC(cl_int, clEnqueueWriteImage,
+ (cl_command_queue command_queue,
+ cl_mem image,
+ cl_bool blocking_write,
+ const size_t * origin[3],
+ const size_t * region[3],
+ size_t input_row_pitch,
+ size_t input_slice_pitch,
+ const void * ptr,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event),
+ (command_queue, image, blocking_write, origin, region, input_row_pitch,
+ input_slice_pitch, ptr, num_events_in_wait_list, event_wait_list, event))
+
+OCL_FUNC(cl_int, clEnqueueFillImage,
+ (cl_command_queue command_queue,
+ cl_mem image,
+ const void * fill_color,
+ const size_t * origin[3],
+ const size_t * region[3],
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event),
+ (command_queue, image, fill_color, origin, region,
+ num_events_in_wait_list, event_wait_list, event))
+
+OCL_FUNC(cl_int, clEnqueueCopyImage,
+ (cl_command_queue command_queue,
+ cl_mem src_image,
+ cl_mem dst_image,
+ const size_t * src_origin[3],
+ const size_t * dst_origin[3],
+ const size_t * region[3],
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event),
+ (command_queue, src_image, dst_image, src_origin, dst_origin,
+ region, num_events_in_wait_list, event_wait_list, event))
+*/
+
+OCL_FUNC(cl_int, clEnqueueCopyImageToBuffer,
+ (cl_command_queue command_queue,
+ cl_mem src_image,
+ cl_mem dst_buffer,
+ const size_t * src_origin,
+ const size_t * region,
+ size_t dst_offset,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event),
+ (command_queue, src_image, dst_buffer, src_origin, region, dst_offset,
+ num_events_in_wait_list, event_wait_list, event))
+
+OCL_FUNC(cl_int, clEnqueueCopyBufferToImage,
+ (cl_command_queue command_queue,
+ cl_mem src_buffer,
+ cl_mem dst_image,
+ size_t src_offset,
+ const size_t dst_origin[3],
+ const size_t region[3],
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event),
+ (command_queue, src_buffer, dst_image, src_offset, dst_origin,
+ region, num_events_in_wait_list, event_wait_list, event))
+
+ OCL_FUNC(cl_int, clFlush,
+ (cl_command_queue command_queue),
+ (command_queue))
+
+/*
+OCL_FUNC_P(void*, clEnqueueMapImage,
+ (cl_command_queue command_queue,
+ cl_mem image,
+ cl_bool blocking_map,
+ cl_map_flags map_flags,
+ const size_t * origin[3],
+ const size_t * region[3],
+ size_t * image_row_pitch,
+ size_t * image_slice_pitch,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event,
+ cl_int * errcode_ret),
+ (command_queue, image, blocking_map, map_flags, origin, region,
+ image_row_pitch, image_slice_pitch, num_events_in_wait_list,
+ event_wait_list, event, errcode_ret))
+*/
+
+/*
+OCL_FUNC(cl_int, clRetainProgram, (cl_program program), (program))
+
+OCL_FUNC(cl_int, clGetKernelInfo,
+ (cl_kernel kernel,
+ cl_kernel_info param_name,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret),
+ (kernel, param_name, param_value_size, param_value, param_value_size_ret))
+
+*/
+
+OCL_FUNC(cl_int, clRetainMemObject, (cl_mem memobj), (memobj))
+
+OCL_FUNC(cl_int, clReleaseMemObject, (cl_mem memobj), (memobj))
+
+
+OCL_FUNC_P(cl_program, clCreateProgramWithSource,
+ (cl_context context,
+ cl_uint count,
+ const char ** strings,
+ const size_t * lengths,
+ cl_int * errcode_ret),
+ (context, count, strings, lengths, errcode_ret))
+
+OCL_FUNC_P(cl_program, clCreateProgramWithBinary,
+ (cl_context context,
+ cl_uint num_devices,
+ const cl_device_id * device_list,
+ const size_t * lengths,
+ const unsigned char ** binaries,
+ cl_int * binary_status,
+ cl_int * errcode_ret),
+ (context, num_devices, device_list, lengths, binaries, binary_status, errcode_ret))
+
+OCL_FUNC(cl_int, clReleaseProgram, (cl_program program), (program))
+
+OCL_FUNC(cl_int, clBuildProgram,
+ (cl_program program,
+ cl_uint num_devices,
+ const cl_device_id * device_list,
+ const char * options,
+ void (CL_CALLBACK * pfn_notify)(cl_program, void *),
+ void * user_data),
+ (program, num_devices, device_list, options, pfn_notify, user_data))
+
+OCL_FUNC(cl_int, clGetProgramInfo,
+ (cl_program program,
+ cl_program_info param_name,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret),
+ (program, param_name, param_value_size, param_value, param_value_size_ret))
+
+OCL_FUNC(cl_int, clGetProgramBuildInfo,
+ (cl_program program,
+ cl_device_id device,
+ cl_program_build_info param_name,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret),
+ (program, device, param_name, param_value_size, param_value, param_value_size_ret))
+
+OCL_FUNC_P(cl_kernel, clCreateKernel,
+ (cl_program program,
+ const char * kernel_name,
+ cl_int * errcode_ret),
+ (program, kernel_name, errcode_ret))
+
+OCL_FUNC(cl_int, clReleaseKernel, (cl_kernel kernel), (kernel))
+
+OCL_FUNC(cl_int, clSetKernelArg,
+ (cl_kernel kernel,
+ cl_uint arg_index,
+ size_t arg_size,
+ const void * arg_value),
+ (kernel, arg_index, arg_size, arg_value))
+
+OCL_FUNC(cl_int, clGetKernelWorkGroupInfo,
+ (cl_kernel kernel,
+ cl_device_id device,
+ cl_kernel_work_group_info param_name,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret),
+ (kernel, device, param_name, param_value_size, param_value, param_value_size_ret))
+
+OCL_FUNC(cl_int, clFinish, (cl_command_queue command_queue), (command_queue))
+
+OCL_FUNC(cl_int, clEnqueueReadBuffer,
+ (cl_command_queue command_queue,
+ cl_mem buffer,
+ cl_bool blocking_read,
+ size_t offset,
+ size_t size,
+ void * ptr,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event),
+ (command_queue, buffer, blocking_read, offset, size, ptr,
+ num_events_in_wait_list, event_wait_list, event))
+
+OCL_FUNC(cl_int, clEnqueueReadBufferRect,
+ (cl_command_queue command_queue,
+ cl_mem buffer,
+ cl_bool blocking_read,
+ const size_t * buffer_offset,
+ const size_t * host_offset,
+ const size_t * region,
+ size_t buffer_row_pitch,
+ size_t buffer_slice_pitch,
+ size_t host_row_pitch,
+ size_t host_slice_pitch,
+ void * ptr,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event),
+ (command_queue, buffer, blocking_read, buffer_offset, host_offset, region, buffer_row_pitch,
+ buffer_slice_pitch, host_row_pitch, host_slice_pitch, ptr, num_events_in_wait_list,
+ event_wait_list, event))
+
+OCL_FUNC(cl_int, clEnqueueWriteBuffer,
+ (cl_command_queue command_queue,
+ cl_mem buffer,
+ cl_bool blocking_write,
+ size_t offset,
+ size_t size,
+ const void * ptr,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event),
+ (command_queue, buffer, blocking_write, offset, size, ptr,
+ num_events_in_wait_list, event_wait_list, event))
+
+OCL_FUNC(cl_int, clEnqueueWriteBufferRect,
+ (cl_command_queue command_queue,
+ cl_mem buffer,
+ cl_bool blocking_write,
+ const size_t * buffer_offset,
+ const size_t * host_offset,
+ const size_t * region,
+ size_t buffer_row_pitch,
+ size_t buffer_slice_pitch,
+ size_t host_row_pitch,
+ size_t host_slice_pitch,
+ const void * ptr,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event),
+ (command_queue, buffer, blocking_write, buffer_offset, host_offset,
+ region, buffer_row_pitch, buffer_slice_pitch, host_row_pitch,
+ host_slice_pitch, ptr, num_events_in_wait_list, event_wait_list, event))
+
+/*OCL_FUNC(cl_int, clEnqueueFillBuffer,
+ (cl_command_queue command_queue,
+ cl_mem buffer,
+ const void * pattern,
+ size_t pattern_size,
+ size_t offset,
+ size_t size,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event),
+ (command_queue, buffer, pattern, pattern_size, offset, size,
+ num_events_in_wait_list, event_wait_list, event))*/
+
+OCL_FUNC(cl_int, clEnqueueCopyBuffer,
+ (cl_command_queue command_queue,
+ cl_mem src_buffer,
+ cl_mem dst_buffer,
+ size_t src_offset,
+ size_t dst_offset,
+ size_t size,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event),
+ (command_queue, src_buffer, dst_buffer, src_offset, dst_offset,
+ size, num_events_in_wait_list, event_wait_list, event))
+
+OCL_FUNC(cl_int, clEnqueueCopyBufferRect,
+ (cl_command_queue command_queue,
+ cl_mem src_buffer,
+ cl_mem dst_buffer,
+ const size_t * src_origin,
+ const size_t * dst_origin,
+ const size_t * region,
+ size_t src_row_pitch,
+ size_t src_slice_pitch,
+ size_t dst_row_pitch,
+ size_t dst_slice_pitch,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event),
+ (command_queue, src_buffer, dst_buffer, src_origin, dst_origin,
+ region, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch,
+ num_events_in_wait_list, event_wait_list, event))
+
+OCL_FUNC_P(void*, clEnqueueMapBuffer,
+ (cl_command_queue command_queue,
+ cl_mem buffer,
+ cl_bool blocking_map,
+ cl_map_flags map_flags,
+ size_t offset,
+ size_t size,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event,
+ cl_int * errcode_ret),
+ (command_queue, buffer, blocking_map, map_flags, offset, size,
+ num_events_in_wait_list, event_wait_list, event, errcode_ret))
+
+OCL_FUNC(cl_int, clEnqueueUnmapMemObject,
+ (cl_command_queue command_queue,
+ cl_mem memobj,
+ void * mapped_ptr,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event),
+ (command_queue, memobj, mapped_ptr, num_events_in_wait_list, event_wait_list, event))
+
+OCL_FUNC(cl_int, clEnqueueNDRangeKernel,
+ (cl_command_queue command_queue,
+ cl_kernel kernel,
+ cl_uint work_dim,
+ const size_t * global_work_offset,
+ const size_t * global_work_size,
+ const size_t * local_work_size,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event),
+ (command_queue, kernel, work_dim, global_work_offset, global_work_size,
+ local_work_size, num_events_in_wait_list, event_wait_list, event))
+
+OCL_FUNC(cl_int, clEnqueueTask,
+ (cl_command_queue command_queue,
+ cl_kernel kernel,
+ cl_uint num_events_in_wait_list,
+ const cl_event * event_wait_list,
+ cl_event * event),
+ (command_queue, kernel, num_events_in_wait_list, event_wait_list, event))
+
+OCL_FUNC(cl_int, clSetEventCallback,
+ (cl_event event,
+ cl_int command_exec_callback_type ,
+ void (CL_CALLBACK *pfn_event_notify) (cl_event event, cl_int event_command_exec_status, void *user_data),
+ void *user_data),
+ (event, command_exec_callback_type, pfn_event_notify, user_data))
+
+OCL_FUNC(cl_int, clReleaseEvent, (cl_event event), (event))
+
+}
+
+#endif
+
+#ifndef CL_VERSION_1_2
+#define CL_VERSION_1_2
+#endif
diff --git a/modules/core/src/opencl/halfconvert.cl b/modules/core/src/opencl/halfconvert.cl
new file mode 100644
index 0000000..506df69
--- /dev/null
+++ b/modules/core/src/opencl/halfconvert.cl
@@ -0,0 +1,73 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, all rights reserved.
+// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors as is and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the copyright holders or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#ifdef HALF_SUPPORT
+#ifdef cl_khr_fp16
+#pragma OPENCL EXTENSION cl_khr_fp16:enable
+#endif
+#endif
+
+__kernel void convertFp16(__global const uchar * srcptr, int src_step, int src_offset,
+ __global uchar * dstptr, int dst_step, int dst_offset, int dst_rows, int dst_cols)
+{
+ int x = get_global_id(0);
+ int y0 = get_global_id(1) * rowsPerWI;
+
+ if (x < dst_cols)
+ {
+ int src_index = mad24(y0, src_step, mad24(x, (int)sizeof(srcT), src_offset));
+ int dst_index = mad24(y0, dst_step, mad24(x, (int)sizeof(dstT), dst_offset));
+
+ for (int y = y0, y1 = min(dst_rows, y0 + rowsPerWI); y < y1; ++y, src_index += src_step, dst_index += dst_step)
+ {
+ __global const srcT * src = (__global const srcT *)(srcptr + src_index);
+ __global dstT * dst = (__global dstT *)(dstptr + dst_index);
+
+#ifdef FLOAT_TO_HALF
+ vstore_half(src[0], 0, dst);
+#else
+ dst[0] = vload_half(0, src);
+#endif
+ }
+ }
+}
diff --git a/modules/core/src/opencl/intel_gemm.cl b/modules/core/src/opencl/intel_gemm.cl
new file mode 100644
index 0000000..6cea8d7
--- /dev/null
+++ b/modules/core/src/opencl/intel_gemm.cl
@@ -0,0 +1,1082 @@
+// Copyright (c) 2017, Intel Corporation
+//
+// The MIT License (MIT)
+//
+// 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.
+
+#if defined(cl_intel_subgroups)
+#pragma OPENCL EXTENSION cl_intel_subgroups : enable
+#endif
+
+#if defined(cl_intel_subgroups)
+
+#define VEC_SIZE 4
+#define LWG_HEIGHT 4
+#define TILE_M 8
+#define TILE_K 16
+#define TILE_N 32
+
+__attribute__((reqd_work_group_size(8, LWG_HEIGHT, 1)))
+__kernel void intelblas_gemm_buffer_NN_sp(
+ const __global float *src0, int off0,
+ const __global float *src1, int off1,
+ __global float *dst, int offd,
+ int M,
+ int N,
+ int K,
+ float alpha,
+ float beta,
+ int ldA,
+ int ldB,
+ int ldC,
+ int start_index,
+ int stride)
+{
+ const int group_x = get_group_id(0);
+ const int group_y = get_group_id(1);
+ const int local_x = get_local_id(0);
+ const int local_y = get_local_id(1);
+ const int global_x = get_global_id(0);
+ const int global_y = get_global_id(1);
+
+ float4 brow;
+ float2 arow0, arow1, arow2, arow3, arow4, arow5, arow6, arow7;
+
+ __global float *dst_write0 = dst + local_x * VEC_SIZE + ( group_x * TILE_N ) + ( group_y * LWG_HEIGHT * TILE_M + local_y * TILE_M) * ldC + offd;
+
+ const __global float *src0_read = src0 + local_x * ( TILE_K / 8 ) + ( group_y * LWG_HEIGHT * TILE_M + local_y * TILE_M ) * ldA + start_index + off0;
+
+ const __global float *src1_read0 = src1 + local_x * VEC_SIZE + ( group_x * TILE_N ) + start_index * ldB + off1;
+
+ float4 dot00 = (start_index != 0) ? vload4(0, dst_write0) : ((beta != 0.0) ? ((float)beta * vload4(0, dst_write0 )) : (float4)(0.0));
+ float4 dot01 = (start_index != 0) ? vload4(0, dst_write0 + 1 * ldC) : ((beta != 0.0) ? ((float)beta * vload4(0, dst_write0 + 1 * ldC)) : (float4)(0.0));
+ float4 dot02 = (start_index != 0) ? vload4(0, dst_write0 + 2 * ldC) : ((beta != 0.0) ? ((float)beta * vload4(0, dst_write0 + 2 * ldC)) : (float4)(0.0));
+ float4 dot03 = (start_index != 0) ? vload4(0, dst_write0 + 3 * ldC) : ((beta != 0.0) ? ((float)beta * vload4(0, dst_write0 + 3 * ldC)) : (float4)(0.0));
+ float4 dot04 = (start_index != 0) ? vload4(0, dst_write0 + 4 * ldC) : ((beta != 0.0) ? ((float)beta * vload4(0, dst_write0 + 4 * ldC)) : (float4)(0.0));
+ float4 dot05 = (start_index != 0) ? vload4(0, dst_write0 + 5 * ldC) : ((beta != 0.0) ? ((float)beta * vload4(0, dst_write0 + 5 * ldC)) : (float4)(0.0));
+ float4 dot06 = (start_index != 0) ? vload4(0, dst_write0 + 6 * ldC) : ((beta != 0.0) ? ((float)beta * vload4(0, dst_write0 + 6 * ldC)) : (float4)(0.0));
+ float4 dot07 = (start_index != 0) ? vload4(0, dst_write0 + 7 * ldC) : ((beta != 0.0) ? ((float)beta * vload4(0, dst_write0 + 7 * ldC)) : (float4)(0.0));
+
+ int end_index = min(start_index + stride, K);
+ int w = start_index;
+ while( w + TILE_K <= end_index ) {
+ arow0 = (float)alpha * vload2(0, src0_read + 0 * ldA);
+ arow1 = (float)alpha * vload2(0, src0_read + 1 * ldA);
+ arow2 = (float)alpha * vload2(0, src0_read + 2 * ldA);
+ arow3 = (float)alpha * vload2(0, src0_read + 3 * ldA);
+ arow4 = (float)alpha * vload2(0, src0_read + 4 * ldA);
+ arow5 = (float)alpha * vload2(0, src0_read + 5 * ldA);
+ arow6 = (float)alpha * vload2(0, src0_read + 6 * ldA);
+ arow7 = (float)alpha * vload2(0, src0_read + 7 * ldA);
+
+#define MM_DOT_PRODUCT(index, suffix) \
+ brow = vload4(0, src1_read0); src1_read0 += ldB; \
+ dot00 = mad((float4)(intel_sub_group_shuffle(arow0.s##suffix,index)),brow,dot00); \
+ dot01 = mad((float4)(intel_sub_group_shuffle(arow1.s##suffix,index)),brow,dot01); \
+ dot02 = mad((float4)(intel_sub_group_shuffle(arow2.s##suffix,index)),brow,dot02); \
+ dot03 = mad((float4)(intel_sub_group_shuffle(arow3.s##suffix,index)),brow,dot03); \
+ dot04 = mad((float4)(intel_sub_group_shuffle(arow4.s##suffix,index)),brow,dot04); \
+ dot05 = mad((float4)(intel_sub_group_shuffle(arow5.s##suffix,index)),brow,dot05); \
+ dot06 = mad((float4)(intel_sub_group_shuffle(arow6.s##suffix,index)),brow,dot06); \
+ dot07 = mad((float4)(intel_sub_group_shuffle(arow7.s##suffix,index)),brow,dot07);
+
+ MM_DOT_PRODUCT(0,0);
+ MM_DOT_PRODUCT(0,1);
+ MM_DOT_PRODUCT(1,0);
+ MM_DOT_PRODUCT(1,1);
+ MM_DOT_PRODUCT(2,0);
+ MM_DOT_PRODUCT(2,1);
+ MM_DOT_PRODUCT(3,0);
+ MM_DOT_PRODUCT(3,1);
+ MM_DOT_PRODUCT(4,0);
+ MM_DOT_PRODUCT(4,1);
+ MM_DOT_PRODUCT(5,0);
+ MM_DOT_PRODUCT(5,1);
+ MM_DOT_PRODUCT(6,0);
+ MM_DOT_PRODUCT(6,1);
+ MM_DOT_PRODUCT(7,0);
+ MM_DOT_PRODUCT(7,1);
+#undef MM_DOT_PRODUCT
+
+ src0_read += TILE_K;
+ w += TILE_K;
+ }
+
+ vstore4(dot00, 0, dst_write0); dst_write0 += ldC;
+ vstore4(dot01, 0, dst_write0); dst_write0 += ldC;
+ vstore4(dot02, 0, dst_write0); dst_write0 += ldC;
+ vstore4(dot03, 0, dst_write0); dst_write0 += ldC;
+ vstore4(dot04, 0, dst_write0); dst_write0 += ldC;
+ vstore4(dot05, 0, dst_write0); dst_write0 += ldC;
+ vstore4(dot06, 0, dst_write0); dst_write0 += ldC;
+ vstore4(dot07, 0, dst_write0); dst_write0 += ldC;
+}
+
+#undef VEC_SIZE
+#undef LWG_HEIGHT
+#undef TILE_M
+#undef TILE_K
+#undef TILE_N
+
+#define VEC_SIZE 4
+#define LWG_HEIGHT 4
+#define TILE_M 8
+#define TILE_K 16
+#define TILE_N 32
+
+__attribute__((reqd_work_group_size(8, LWG_HEIGHT, 1)))
+__kernel void intelblas_gemm_buffer_NN(
+ const __global float *src0, int off0,
+ const __global float *src1, int off1,
+ __global float *dst, int offd,
+ int M,
+ int N,
+ int K,
+ float alpha,
+ float beta,
+ int ldA,
+ int ldB,
+ int ldC,
+ int start_index,
+ int stride)
+{
+ const int group_x = get_group_id(0);
+ const int group_y = get_group_id(1);
+ const int local_x = get_local_id(0);
+ const int local_y = get_local_id(1);
+ const int global_x = get_global_id(0);
+ const int global_y = get_global_id(1);
+
+ float4 brow;
+ float2 arow0, arow1, arow2, arow3, arow4, arow5, arow6, arow7;
+
+ __global float *dst_write0 = dst + local_x * VEC_SIZE + ( group_x * TILE_N ) + ( group_y * LWG_HEIGHT * TILE_M + local_y * TILE_M) * ldC + offd;
+
+ const __global float *src0_read = src0 + local_x * ( TILE_K / 8 ) + ( group_y * LWG_HEIGHT * TILE_M + local_y * TILE_M ) * ldA + start_index + off0;
+
+ const __global float *src1_read0 = src1 + local_x * VEC_SIZE + ( group_x * TILE_N ) + start_index * ldB + off1;
+
+ int border = -(group_y * LWG_HEIGHT * TILE_M + local_y * TILE_M);
+
+ int row0 = mad24(global_y, TILE_M, 0) < M ? 0 : border;
+ int row1 = mad24(global_y, TILE_M, 1) < M ? 1 : border;
+ int row2 = mad24(global_y, TILE_M, 2) < M ? 2 : border;
+ int row3 = mad24(global_y, TILE_M, 3) < M ? 3 : border;
+ int row4 = mad24(global_y, TILE_M, 4) < M ? 4 : border;
+ int row5 = mad24(global_y, TILE_M, 5) < M ? 5 : border;
+ int row6 = mad24(global_y, TILE_M, 6) < M ? 6 : border;
+ int row7 = mad24(global_y, TILE_M, 7) < M ? 7 : border;
+
+ float4 dot00 = (start_index != 0) ? vload4(0, dst_write0) : ((beta != 0.0) ? ((float)beta * vload4(0, dst_write0 )) : (float4)(0.0));
+ float4 dot01 = (start_index != 0) ? vload4(0, dst_write0 + 1 * ldC) : ((beta != 0.0) ? ((float)beta * vload4(0, dst_write0 + 1 * ldC)) : (float4)(0.0));
+ float4 dot02 = (start_index != 0) ? vload4(0, dst_write0 + 2 * ldC) : ((beta != 0.0) ? ((float)beta * vload4(0, dst_write0 + 2 * ldC)) : (float4)(0.0));
+ float4 dot03 = (start_index != 0) ? vload4(0, dst_write0 + 3 * ldC) : ((beta != 0.0) ? ((float)beta * vload4(0, dst_write0 + 3 * ldC)) : (float4)(0.0));
+ float4 dot04 = (start_index != 0) ? vload4(0, dst_write0 + 4 * ldC) : ((beta != 0.0) ? ((float)beta * vload4(0, dst_write0 + 4 * ldC)) : (float4)(0.0));
+ float4 dot05 = (start_index != 0) ? vload4(0, dst_write0 + 5 * ldC) : ((beta != 0.0) ? ((float)beta * vload4(0, dst_write0 + 5 * ldC)) : (float4)(0.0));
+ float4 dot06 = (start_index != 0) ? vload4(0, dst_write0 + 6 * ldC) : ((beta != 0.0) ? ((float)beta * vload4(0, dst_write0 + 6 * ldC)) : (float4)(0.0));
+ float4 dot07 = (start_index != 0) ? vload4(0, dst_write0 + 7 * ldC) : ((beta != 0.0) ? ((float)beta * vload4(0, dst_write0 + 7 * ldC)) : (float4)(0.0));
+
+ int end_index = min(start_index + stride, K);
+ int w = start_index;
+ while( w + TILE_K <= end_index ) {
+ arow0 = (float)alpha * vload2(0, src0_read + row0 * ldA);
+ arow1 = (float)alpha * vload2(0, src0_read + row1 * ldA);
+ arow2 = (float)alpha * vload2(0, src0_read + row2 * ldA);
+ arow3 = (float)alpha * vload2(0, src0_read + row3 * ldA);
+ arow4 = (float)alpha * vload2(0, src0_read + row4 * ldA);
+ arow5 = (float)alpha * vload2(0, src0_read + row5 * ldA);
+ arow6 = (float)alpha * vload2(0, src0_read + row6 * ldA);
+ arow7 = (float)alpha * vload2(0, src0_read + row7 * ldA);
+
+#define MM_DOT_PRODUCT(index,suffix) \
+ brow = vload4(0, src1_read0); src1_read0 += ldB; \
+ dot00 = mad((float4)(intel_sub_group_shuffle(arow0.s##suffix,index)),brow,dot00); \
+ dot01 = mad((float4)(intel_sub_group_shuffle(arow1.s##suffix,index)),brow,dot01); \
+ dot02 = mad((float4)(intel_sub_group_shuffle(arow2.s##suffix,index)),brow,dot02); \
+ dot03 = mad((float4)(intel_sub_group_shuffle(arow3.s##suffix,index)),brow,dot03); \
+ dot04 = mad((float4)(intel_sub_group_shuffle(arow4.s##suffix,index)),brow,dot04); \
+ dot05 = mad((float4)(intel_sub_group_shuffle(arow5.s##suffix,index)),brow,dot05); \
+ dot06 = mad((float4)(intel_sub_group_shuffle(arow6.s##suffix,index)),brow,dot06); \
+ dot07 = mad((float4)(intel_sub_group_shuffle(arow7.s##suffix,index)),brow,dot07);
+
+ MM_DOT_PRODUCT(0,0);
+ MM_DOT_PRODUCT(0,1);
+ MM_DOT_PRODUCT(1,0);
+ MM_DOT_PRODUCT(1,1);
+ MM_DOT_PRODUCT(2,0);
+ MM_DOT_PRODUCT(2,1);
+ MM_DOT_PRODUCT(3,0);
+ MM_DOT_PRODUCT(3,1);
+ MM_DOT_PRODUCT(4,0);
+ MM_DOT_PRODUCT(4,1);
+ MM_DOT_PRODUCT(5,0);
+ MM_DOT_PRODUCT(5,1);
+ MM_DOT_PRODUCT(6,0);
+ MM_DOT_PRODUCT(6,1);
+ MM_DOT_PRODUCT(7,0);
+ MM_DOT_PRODUCT(7,1);
+#undef MM_DOT_PRODUCT
+
+ src0_read += TILE_K;
+ w += TILE_K;
+ }
+
+ if(w < end_index) {
+ arow0.x = ((w + local_x * 2) < K) ? (float)alpha * (src0_read + row0 * ldA)[0] : 0.0f;
+ arow0.y = ((w + local_x * 2 + 1) < K) ? (float)alpha * (src0_read + row0 * ldA)[1] : 0.0f;
+ arow1.x = ((w + local_x * 2) < K) ? (float)alpha * (src0_read + row1 * ldA)[0] : 0.0f;
+ arow1.y = ((w + local_x * 2 + 1) < K) ? (float)alpha * (src0_read + row1 * ldA)[1] : 0.0f;
+ arow2.x = ((w + local_x * 2) < K) ? (float)alpha * (src0_read + row2 * ldA)[0] : 0.0f;
+ arow2.y = ((w + local_x * 2 + 1) < K) ? (float)alpha * (src0_read + row2 * ldA)[1] : 0.0f;
+ arow3.x = ((w + local_x * 2) < K) ? (float)alpha * (src0_read + row3 * ldA)[0] : 0.0f;
+ arow3.y = ((w + local_x * 2 + 1) < K) ? (float)alpha * (src0_read + row3 * ldA)[1] : 0.0f;
+ arow4.x = ((w + local_x * 2) < K) ? (float)alpha * (src0_read + row4 * ldA)[0] : 0.0f;
+ arow4.y = ((w + local_x * 2 + 1) < K) ? (float)alpha * (src0_read + row4 * ldA)[1] : 0.0f;
+ arow5.x = ((w + local_x * 2) < K) ? (float)alpha * (src0_read + row5 * ldA)[0] : 0.0f;
+ arow5.y = ((w + local_x * 2 + 1) < K) ? (float)alpha * (src0_read + row5 * ldA)[1] : 0.0f;
+ arow6.x = ((w + local_x * 2) < K) ? (float)alpha * (src0_read + row6 * ldA)[0] : 0.0f;
+ arow6.y = ((w + local_x * 2 + 1) < K) ? (float)alpha * (src0_read + row6 * ldA)[1] : 0.0f;
+ arow7.x = ((w + local_x * 2) < K) ? (float)alpha * (src0_read + row7 * ldA)[0] : 0.0f;
+ arow7.y = ((w + local_x * 2 + 1) < K) ? (float)alpha * (src0_read + row7 * ldA)[1] : 0.0f;
+
+#define MM_DOT_PRODUCT(index,suffix) \
+ brow = (w < K) ? vload4(0, src1_read0) : (float)0.0f; src1_read0 += ldB; w++; \
+ dot00 = mad((float4)(intel_sub_group_shuffle( arow0.s##suffix, index )),brow,dot00 ); \
+ dot01 = mad((float4)(intel_sub_group_shuffle( arow1.s##suffix, index )),brow,dot01 ); \
+ dot02 = mad((float4)(intel_sub_group_shuffle( arow2.s##suffix, index )),brow,dot02 ); \
+ dot03 = mad((float4)(intel_sub_group_shuffle( arow3.s##suffix, index )),brow,dot03 ); \
+ dot04 = mad((float4)(intel_sub_group_shuffle( arow4.s##suffix, index )),brow,dot04 ); \
+ dot05 = mad((float4)(intel_sub_group_shuffle( arow5.s##suffix, index )),brow,dot05 ); \
+ dot06 = mad((float4)(intel_sub_group_shuffle( arow6.s##suffix, index )),brow,dot06 ); \
+ dot07 = mad((float4)(intel_sub_group_shuffle( arow7.s##suffix, index )),brow,dot07 );
+
+ MM_DOT_PRODUCT(0,0);
+ MM_DOT_PRODUCT(0,1);
+ MM_DOT_PRODUCT(1,0);
+ MM_DOT_PRODUCT(1,1);
+ MM_DOT_PRODUCT(2,0);
+ MM_DOT_PRODUCT(2,1);
+ MM_DOT_PRODUCT(3,0);
+ MM_DOT_PRODUCT(3,1);
+ MM_DOT_PRODUCT(4,0);
+ MM_DOT_PRODUCT(4,1);
+ MM_DOT_PRODUCT(5,0);
+ MM_DOT_PRODUCT(5,1);
+ MM_DOT_PRODUCT(6,0);
+ MM_DOT_PRODUCT(6,1);
+ MM_DOT_PRODUCT(7,0);
+ MM_DOT_PRODUCT(7,1);
+#undef MM_DOT_PRODUCT
+ }
+
+ if(global_x * 4 < N && global_y * 8 < M) {
+ if(mad24(global_x, 4, 3) < N) {
+ vstore4(dot00, 0, dst_write0); dst_write0 += ldC;
+ if(mad24(global_y, 8, 1) < M) { vstore4(dot01, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 2) < M) { vstore4(dot02, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 3) < M) { vstore4(dot03, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 4) < M) { vstore4(dot04, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 5) < M) { vstore4(dot05, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 6) < M) { vstore4(dot06, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 7) < M) { vstore4(dot07, 0, dst_write0); }
+ } else if(mad24(global_x, 4, 2) < N) {
+ vstore2(dot00.xy, 0, dst_write0);
+ dst_write0[2] = dot00.z;
+ dst_write0 += ldC;
+ if(mad24(global_y, 8, 1) < M) {
+ vstore2(dot01.xy, 0, dst_write0);
+ dst_write0[2] = dot01.z;
+ dst_write0 += ldC;
+ } else
+ return;
+ if(mad24(global_y, 8, 2) < M) {
+ vstore2(dot02.xy, 0, dst_write0);
+ dst_write0[2] = dot02.z;
+ dst_write0 += ldC;
+ } else
+ return;
+ if(mad24(global_y, 8, 3) < M) {
+ vstore2(dot03.xy, 0, dst_write0);
+ dst_write0[2] = dot03.z;
+ dst_write0 += ldC;
+ } else
+ return;
+ if(mad24(global_y, 8, 4) < M) {
+ vstore2(dot04.xy, 0, dst_write0);
+ dst_write0[2] = dot04.z;
+ dst_write0 += ldC;
+ } else
+ return;
+ if(mad24(global_y, 8, 5) < M) {
+ vstore2(dot05.xy, 0, dst_write0);
+ dst_write0[2] = dot05.z;
+ dst_write0 += ldC;
+ } else
+ return;
+ if(mad24(global_y, 8, 6) < M) {
+ vstore2(dot06.xy, 0, dst_write0);
+ dst_write0[2] = dot06.z;
+ dst_write0 += ldC;
+ } else
+ return;
+ if(mad24(global_y, 8, 7) < M) {
+ vstore2(dot07.xy, 0, dst_write0);
+ dst_write0[2] = dot07.z;
+ }
+ } else if(mad24(global_x, 4, 1) < N) {
+ vstore2(dot00.xy, 0, dst_write0); dst_write0 += ldC;
+ if(mad24(global_y, 8, 1) < M) { vstore2(dot01.xy, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 2) < M) { vstore2(dot02.xy, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 3) < M) { vstore2(dot03.xy, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 4) < M) { vstore2(dot04.xy, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 5) < M) { vstore2(dot05.xy, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 6) < M) { vstore2(dot06.xy, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 7) < M) { vstore2(dot07.xy, 0, dst_write0); }
+ } else {
+ dst_write0[0] = dot00.x; dst_write0 += ldC;
+ if(mad24(global_y, 8, 1) < M) { dst_write0[0] = dot01.x; dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 2) < M) { dst_write0[0] = dot02.x; dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 3) < M) { dst_write0[0] = dot03.x; dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 4) < M) { dst_write0[0] = dot04.x; dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 5) < M) { dst_write0[0] = dot05.x; dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 6) < M) { dst_write0[0] = dot06.x; dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 7) < M) { dst_write0[0] = dot07.x; }
+ }
+ }
+}
+
+#undef VEC_SIZE
+#undef LWG_HEIGHT
+#undef TILE_M
+#undef TILE_K
+#undef TILE_N
+
+#define VEC_SIZE 1
+#define LWG_HEIGHT 16
+#define TILE_M 8
+#define TILE_K 32
+#define TILE_N 8
+#define SLM_BLOCK 512
+
+__attribute__((reqd_work_group_size(8, LWG_HEIGHT, 1)))
+__kernel void intelblas_gemm_buffer_NT(
+ const __global float *src0, int off0,
+ const __global float *src1, int off1,
+ __global float *dst, int offd,
+ int M,
+ int N,
+ int K,
+ float alpha,
+ float beta,
+ int ldA,
+ int ldB,
+ int ldC)
+{
+ const int group_x = get_group_id(0);
+ const int group_y = get_group_id(1);
+ const int local_x = get_local_id(0);
+ const int local_y = get_local_id(1);
+ const int global_x = get_global_id(0);
+ const int global_y = get_global_id(1);
+
+ float8 dot00 = 0.f;
+ float8 dot01 = 0.f;
+ float8 dot02 = 0.f;
+ float8 dot03 = 0.f;
+ float8 dot04 = 0.f;
+ float8 dot05 = 0.f;
+ float8 dot06 = 0.f;
+ float8 dot07 = 0.f;
+
+ float4 brow0;
+ float4 brow1;
+ float4 brow2;
+ float4 brow3;
+ float4 brow4;
+ float4 brow5;
+ float4 brow6;
+ float4 brow7;
+
+ __global float *dst_write0 = dst + local_x * VEC_SIZE + ( group_x * TILE_N ) + ( group_y * LWG_HEIGHT * TILE_M + local_y * TILE_M) * ldC + offd;
+
+ const __global float *src0_read = src0 + local_x * ( TILE_K / 8 ) + ( group_y * LWG_HEIGHT * TILE_M + local_y * TILE_M ) * ldA + off0;
+
+ const __global float *src1_read0 = src1 + ( group_x * TILE_N ) * ldB + off1;
+
+ __local float slm_brow[8 * SLM_BLOCK];
+ __local float* slm_brow0;
+
+ int local_index = mad24(local_y, 8, local_x) * 4;
+ int w;
+ for(int b_tile = 0; b_tile < K; b_tile += SLM_BLOCK) {
+ barrier(CLK_LOCAL_MEM_FENCE);
+ vstore4(vload4(0, src1_read0 + mad24(0, ldB, local_index)), 0, slm_brow + mad24(0, SLM_BLOCK, local_index));
+ vstore4(vload4(0, src1_read0 + mad24(1, ldB, local_index)), 0, slm_brow + mad24(1, SLM_BLOCK, local_index));
+ vstore4(vload4(0, src1_read0 + mad24(2, ldB, local_index)), 0, slm_brow + mad24(2, SLM_BLOCK, local_index));
+ vstore4(vload4(0, src1_read0 + mad24(3, ldB, local_index)), 0, slm_brow + mad24(3, SLM_BLOCK, local_index));
+ vstore4(vload4(0, src1_read0 + mad24(4, ldB, local_index)), 0, slm_brow + mad24(4, SLM_BLOCK, local_index));
+ vstore4(vload4(0, src1_read0 + mad24(5, ldB, local_index)), 0, slm_brow + mad24(5, SLM_BLOCK, local_index));
+ vstore4(vload4(0, src1_read0 + mad24(6, ldB, local_index)), 0, slm_brow + mad24(6, SLM_BLOCK, local_index));
+ vstore4(vload4(0, src1_read0 + mad24(7, ldB, local_index)), 0, slm_brow + mad24(7, SLM_BLOCK, local_index));
+ barrier(CLK_LOCAL_MEM_FENCE);
+
+ slm_brow0 = slm_brow + local_x * (TILE_K / 8);
+ w = b_tile;
+ int end_w = min(b_tile + SLM_BLOCK, K);
+ while( w + TILE_K <= end_w ) {
+ float4 arow;
+
+ brow0 = vload4(0, slm_brow0 + 0 * SLM_BLOCK);
+ brow1 = vload4(0, slm_brow0 + 1 * SLM_BLOCK);
+ brow2 = vload4(0, slm_brow0 + 2 * SLM_BLOCK);
+ brow3 = vload4(0, slm_brow0 + 3 * SLM_BLOCK);
+ brow4 = vload4(0, slm_brow0 + 4 * SLM_BLOCK);
+ brow5 = vload4(0, slm_brow0 + 5 * SLM_BLOCK);
+ brow6 = vload4(0, slm_brow0 + 6 * SLM_BLOCK);
+ brow7 = vload4(0, slm_brow0 + 7 * SLM_BLOCK);
+
+#define MM_DOT_PRODUCT(_row,_dot) \
+ arow = vload4(0, src0_read + _row * ldA); \
+ _dot = mad( (float8)(arow.x), (float8)(brow0.x, brow1.x, brow2.x, brow3.x, brow4.x, brow5.x, brow6.x, brow7.x), _dot ); \
+ _dot = mad( (float8)(arow.y), (float8)(brow0.y, brow1.y, brow2.y, brow3.y, brow4.y, brow5.y, brow6.y, brow7.y), _dot ); \
+ _dot = mad( (float8)(arow.z), (float8)(brow0.z, brow1.z, brow2.z, brow3.z, brow4.z, brow5.z, brow6.z, brow7.z), _dot ); \
+ _dot = mad( (float8)(arow.w), (float8)(brow0.w, brow1.w, brow2.w, brow3.w, brow4.w, brow5.w, brow6.w, brow7.w), _dot );
+
+ MM_DOT_PRODUCT(0,dot00);
+ MM_DOT_PRODUCT(1,dot01);
+ MM_DOT_PRODUCT(2,dot02);
+ MM_DOT_PRODUCT(3,dot03);
+ MM_DOT_PRODUCT(4,dot04);
+ MM_DOT_PRODUCT(5,dot05);
+ MM_DOT_PRODUCT(6,dot06);
+ MM_DOT_PRODUCT(7,dot07);
+#undef MM_DOT_PRODUCT
+
+ src0_read += TILE_K;
+ slm_brow0 += TILE_K;
+ w += TILE_K;
+ }
+ src1_read0 += SLM_BLOCK;
+ }
+
+ if(w < K) {
+ float4 arow;
+
+#define READ_BROW(_brow,_row) \
+ _brow = vload4(0, slm_brow0 + _row * SLM_BLOCK); \
+ _brow.x = (mad24(local_x, 4, w) < K) ? _brow.x : 0.0f; \
+ _brow.y = (mad24(local_x, 4, w + 1) < K) ? _brow.y : 0.0f; \
+ _brow.z = (mad24(local_x, 4, w + 2) < K) ? _brow.z : 0.0f; \
+ _brow.w = (mad24(local_x, 4, w + 3) < K) ? _brow.w : 0.0f;
+
+ READ_BROW(brow0,0);
+ READ_BROW(brow1,1);
+ READ_BROW(brow2,2);
+ READ_BROW(brow3,3);
+ READ_BROW(brow4,4);
+ READ_BROW(brow5,5);
+ READ_BROW(brow6,6);
+ READ_BROW(brow7,7);
+
+#define MM_DOT_PRODUCT(_row,_dot) \
+ arow = vload4(0, src0_read + _row * ldA); \
+ arow.x = (mad24(local_x, 4, w) < K) ? arow.x : 0.0f; \
+ arow.y = (mad24(local_x, 4, w + 1) < K) ? arow.y : 0.0f; \
+ arow.z = (mad24(local_x, 4, w + 2) < K) ? arow.z : 0.0f; \
+ arow.w = (mad24(local_x, 4, w + 3) < K) ? arow.w : 0.0f; \
+ _dot = mad( (float8)(arow.x), (float8)(brow0.x, brow1.x, brow2.x, brow3.x, brow4.x, brow5.x, brow6.x, brow7.x), _dot ); \
+ _dot = mad( (float8)(arow.y), (float8)(brow0.y, brow1.y, brow2.y, brow3.y, brow4.y, brow5.y, brow6.y, brow7.y), _dot ); \
+ _dot = mad( (float8)(arow.z), (float8)(brow0.z, brow1.z, brow2.z, brow3.z, brow4.z, brow5.z, brow6.z, brow7.z), _dot ); \
+ _dot = mad( (float8)(arow.w), (float8)(brow0.w, brow1.w, brow2.w, brow3.w, brow4.w, brow5.w, brow6.w, brow7.w), _dot );
+
+ MM_DOT_PRODUCT(0,dot00);
+ MM_DOT_PRODUCT(1,dot01);
+ MM_DOT_PRODUCT(2,dot02);
+ MM_DOT_PRODUCT(3,dot03);
+ MM_DOT_PRODUCT(4,dot04);
+ MM_DOT_PRODUCT(5,dot05);
+ MM_DOT_PRODUCT(6,dot06);
+ MM_DOT_PRODUCT(7,dot07);
+#undef MM_DOT_PRODUCT
+ }
+
+#define REDUCE(_dot) \
+ _dot.s0 = intel_sub_group_shuffle(_dot.s0, 0) + intel_sub_group_shuffle(_dot.s0, 1) + intel_sub_group_shuffle(_dot.s0, 2) + intel_sub_group_shuffle(_dot.s0, 3) + \
+ intel_sub_group_shuffle(_dot.s0, 4) + intel_sub_group_shuffle(_dot.s0, 5) + intel_sub_group_shuffle(_dot.s0, 6) + intel_sub_group_shuffle(_dot.s0, 7); \
+ _dot.s1 = intel_sub_group_shuffle(_dot.s1, 0) + intel_sub_group_shuffle(_dot.s1, 1) + intel_sub_group_shuffle(_dot.s1, 2) + intel_sub_group_shuffle(_dot.s1, 3) + \
+ intel_sub_group_shuffle(_dot.s1, 4) + intel_sub_group_shuffle(_dot.s1, 5) + intel_sub_group_shuffle(_dot.s1, 6) + intel_sub_group_shuffle(_dot.s1, 7); \
+ _dot.s2 = intel_sub_group_shuffle(_dot.s2, 0) + intel_sub_group_shuffle(_dot.s2, 1) + intel_sub_group_shuffle(_dot.s2, 2) + intel_sub_group_shuffle(_dot.s2, 3) + \
+ intel_sub_group_shuffle(_dot.s2, 4) + intel_sub_group_shuffle(_dot.s2, 5) + intel_sub_group_shuffle(_dot.s2, 6) + intel_sub_group_shuffle(_dot.s2, 7); \
+ _dot.s3 = intel_sub_group_shuffle(_dot.s3, 0) + intel_sub_group_shuffle(_dot.s3, 1) + intel_sub_group_shuffle(_dot.s3, 2) + intel_sub_group_shuffle(_dot.s3, 3) + \
+ intel_sub_group_shuffle(_dot.s3, 4) + intel_sub_group_shuffle(_dot.s3, 5) + intel_sub_group_shuffle(_dot.s3, 6) + intel_sub_group_shuffle(_dot.s3, 7); \
+ _dot.s4 = intel_sub_group_shuffle(_dot.s4, 0) + intel_sub_group_shuffle(_dot.s4, 1) + intel_sub_group_shuffle(_dot.s4, 2) + intel_sub_group_shuffle(_dot.s4, 3) + \
+ intel_sub_group_shuffle(_dot.s4, 4) + intel_sub_group_shuffle(_dot.s4, 5) + intel_sub_group_shuffle(_dot.s4, 6) + intel_sub_group_shuffle(_dot.s4, 7); \
+ _dot.s5 = intel_sub_group_shuffle(_dot.s5, 0) + intel_sub_group_shuffle(_dot.s5, 1) + intel_sub_group_shuffle(_dot.s5, 2) + intel_sub_group_shuffle(_dot.s5, 3) + \
+ intel_sub_group_shuffle(_dot.s5, 4) + intel_sub_group_shuffle(_dot.s5, 5) + intel_sub_group_shuffle(_dot.s5, 6) + intel_sub_group_shuffle(_dot.s5, 7); \
+ _dot.s6 = intel_sub_group_shuffle(_dot.s6, 0) + intel_sub_group_shuffle(_dot.s6, 1) + intel_sub_group_shuffle(_dot.s6, 2) + intel_sub_group_shuffle(_dot.s6, 3) + \
+ intel_sub_group_shuffle(_dot.s6, 4) + intel_sub_group_shuffle(_dot.s6, 5) + intel_sub_group_shuffle(_dot.s6, 6) + intel_sub_group_shuffle(_dot.s6, 7); \
+ _dot.s7 = intel_sub_group_shuffle(_dot.s7, 0) + intel_sub_group_shuffle(_dot.s7, 1) + intel_sub_group_shuffle(_dot.s7, 2) + intel_sub_group_shuffle(_dot.s7, 3) + \
+ intel_sub_group_shuffle(_dot.s7, 4) + intel_sub_group_shuffle(_dot.s7, 5) + intel_sub_group_shuffle(_dot.s7, 6) + intel_sub_group_shuffle(_dot.s7, 7);
+
+ REDUCE(dot00);
+ REDUCE(dot01);
+ REDUCE(dot02);
+ REDUCE(dot03);
+ REDUCE(dot04);
+ REDUCE(dot05);
+ REDUCE(dot06);
+ REDUCE(dot07);
+#undef REDUCE
+
+ float output = 0.0f;
+#define OUTPUT(_dot) \
+ output = (local_x == 0) ? _dot.s0 : output; \
+ output = (local_x == 1) ? _dot.s1 : output; \
+ output = (local_x == 2) ? _dot.s2 : output; \
+ output = (local_x == 3) ? _dot.s3 : output; \
+ output = (local_x == 4) ? _dot.s4 : output; \
+ output = (local_x == 5) ? _dot.s5 : output; \
+ output = (local_x == 6) ? _dot.s6 : output; \
+ output = (local_x == 7) ? _dot.s7 : output; \
+ if (beta != 0.0) \
+ dst_write0[0] = mad(output, (float)alpha, ((float)beta * dst_write0[0])); \
+ else \
+ dst_write0[0] = output * (float)alpha; \
+ dst_write0 += ldC;
+
+ if(global_x < N && global_y * 8 < M) {
+ OUTPUT(dot00);
+ if(mad24(global_y, 8, 1) < M) { OUTPUT(dot01); }
+ if(mad24(global_y, 8, 2) < M) { OUTPUT(dot02); }
+ if(mad24(global_y, 8, 3) < M) { OUTPUT(dot03); }
+ if(mad24(global_y, 8, 4) < M) { OUTPUT(dot04); }
+ if(mad24(global_y, 8, 5) < M) { OUTPUT(dot05); }
+ if(mad24(global_y, 8, 6) < M) { OUTPUT(dot06); }
+ if(mad24(global_y, 8, 7) < M) { OUTPUT(dot07); }
+ }
+#undef OUTPUT
+}
+
+#undef VEC_SIZE
+#undef LWG_HEIGHT
+#undef TILE_M
+#undef TILE_K
+#undef TILE_N
+#undef SLM_BLOCK
+
+#define VEC_SIZE 4
+#define LWG_HEIGHT 4
+#define TILE_M 8
+#define TILE_K 16
+#define TILE_N 32
+
+__attribute__((reqd_work_group_size(8, LWG_HEIGHT, 1)))
+__kernel void intelblas_gemm_buffer_TN(
+ const __global float *src0, int off0,
+ const __global float *src1, int off1,
+ __global float *dst, int offd,
+ int M,
+ int N,
+ int K,
+ float alpha,
+ float beta,
+ int ldA,
+ int ldB,
+ int ldC,
+ int start_index,
+ int stride)
+
+{
+ const int group_x = get_group_id(0);
+ const int group_y = get_group_id(1);
+ const int local_x = get_local_id(0);
+ const int local_y = get_local_id(1);
+ const int global_x = get_global_id(0);
+ const int global_y = get_global_id(1);
+
+ float4 brow;
+
+ __global float *dst_write0 = dst + local_x * VEC_SIZE + ( group_x * TILE_N ) + ( group_y * LWG_HEIGHT * TILE_M + local_y * TILE_M) * ldC + offd;
+
+ const __global float *src0_read = src0 + (local_x * ( TILE_K / 8 ) + start_index) * ldA + group_y * LWG_HEIGHT * TILE_M + local_y * TILE_M + off0;
+
+ const __global float *src1_read0 = src1 + local_x * VEC_SIZE + ( group_x * TILE_N ) + start_index * ldB + off1;
+
+ float4 dot00 = (start_index != 0) ? vload4(0, dst_write0) : ((beta != 0.0) ? ((float)beta * vload4(0, dst_write0 )) : (float4)(0.0));
+ float4 dot01 = (start_index != 0) ? vload4(0, dst_write0 + 1 * ldC) : ((beta != 0.0) ? ((float)beta * vload4(0, dst_write0 + 1 * ldC)) : (float4)(0.0));
+ float4 dot02 = (start_index != 0) ? vload4(0, dst_write0 + 2 * ldC) : ((beta != 0.0) ? ((float)beta * vload4(0, dst_write0 + 2 * ldC)) : (float4)(0.0));
+ float4 dot03 = (start_index != 0) ? vload4(0, dst_write0 + 3 * ldC) : ((beta != 0.0) ? ((float)beta * vload4(0, dst_write0 + 3 * ldC)) : (float4)(0.0));
+ float4 dot04 = (start_index != 0) ? vload4(0, dst_write0 + 4 * ldC) : ((beta != 0.0) ? ((float)beta * vload4(0, dst_write0 + 4 * ldC)) : (float4)(0.0));
+ float4 dot05 = (start_index != 0) ? vload4(0, dst_write0 + 5 * ldC) : ((beta != 0.0) ? ((float)beta * vload4(0, dst_write0 + 5 * ldC)) : (float4)(0.0));
+ float4 dot06 = (start_index != 0) ? vload4(0, dst_write0 + 6 * ldC) : ((beta != 0.0) ? ((float)beta * vload4(0, dst_write0 + 6 * ldC)) : (float4)(0.0));
+ float4 dot07 = (start_index != 0) ? vload4(0, dst_write0 + 7 * ldC) : ((beta != 0.0) ? ((float)beta * vload4(0, dst_write0 + 7 * ldC)) : (float4)(0.0));
+
+ int end_index = min(start_index + stride, K);
+ while( start_index + TILE_K <= end_index ) {
+ float8 arow0 = (float)alpha * vload8(0, src0_read);
+ float8 arow1 = (float)alpha * vload8(0, src0_read + ldA);
+
+#define MM_DOT_PRODUCT(_arow,index) \
+ brow = vload4(0, src1_read0); src1_read0 += ldB; \
+ dot00 = mad( (float4)(intel_sub_group_shuffle(_arow.s0, index)), brow, dot00 ); \
+ dot01 = mad( (float4)(intel_sub_group_shuffle(_arow.s1, index)), brow, dot01 ); \
+ dot02 = mad( (float4)(intel_sub_group_shuffle(_arow.s2, index)), brow, dot02 ); \
+ dot03 = mad( (float4)(intel_sub_group_shuffle(_arow.s3, index)), brow, dot03 ); \
+ dot04 = mad( (float4)(intel_sub_group_shuffle(_arow.s4, index)), brow, dot04 ); \
+ dot05 = mad( (float4)(intel_sub_group_shuffle(_arow.s5, index)), brow, dot05 ); \
+ dot06 = mad( (float4)(intel_sub_group_shuffle(_arow.s6, index)), brow, dot06 ); \
+ dot07 = mad( (float4)(intel_sub_group_shuffle(_arow.s7, index)), brow, dot07 );
+
+ MM_DOT_PRODUCT(arow0,0);
+ MM_DOT_PRODUCT(arow1,0);
+ MM_DOT_PRODUCT(arow0,1);
+ MM_DOT_PRODUCT(arow1,1);
+ MM_DOT_PRODUCT(arow0,2);
+ MM_DOT_PRODUCT(arow1,2);
+ MM_DOT_PRODUCT(arow0,3);
+ MM_DOT_PRODUCT(arow1,3);
+ MM_DOT_PRODUCT(arow0,4);
+ MM_DOT_PRODUCT(arow1,4);
+ MM_DOT_PRODUCT(arow0,5);
+ MM_DOT_PRODUCT(arow1,5);
+ MM_DOT_PRODUCT(arow0,6);
+ MM_DOT_PRODUCT(arow1,6);
+ MM_DOT_PRODUCT(arow0,7);
+ MM_DOT_PRODUCT(arow1,7);
+#undef MM_DOT_PRODUCT
+
+ src0_read += TILE_K * ldA;
+ start_index += TILE_K;
+ }
+
+ if(start_index < end_index) {
+ float8 arow0 = ((start_index + local_x * 2) < K) ? ((float)alpha * vload8(0, src0_read)) : (float)0.0f;
+ float8 arow1 = ((start_index + local_x * 2 + 1) < K) ? ((float)alpha * vload8(0, src0_read + ldA)) : (float)0.0f;
+
+#define MM_DOT_PRODUCT(_arow,index) \
+ brow = (start_index < K) ? vload4(0, src1_read0) : (float)0.0f; src1_read0 += ldB; start_index++; \
+ dot00 = mad( (float4)(intel_sub_group_shuffle(_arow.s0, index)), brow, dot00 ); \
+ dot01 = mad( (float4)(intel_sub_group_shuffle(_arow.s1, index)), brow, dot01 ); \
+ dot02 = mad( (float4)(intel_sub_group_shuffle(_arow.s2, index)), brow, dot02 ); \
+ dot03 = mad( (float4)(intel_sub_group_shuffle(_arow.s3, index)), brow, dot03 ); \
+ dot04 = mad( (float4)(intel_sub_group_shuffle(_arow.s4, index)), brow, dot04 ); \
+ dot05 = mad( (float4)(intel_sub_group_shuffle(_arow.s5, index)), brow, dot05 ); \
+ dot06 = mad( (float4)(intel_sub_group_shuffle(_arow.s6, index)), brow, dot06 ); \
+ dot07 = mad( (float4)(intel_sub_group_shuffle(_arow.s7, index)), brow, dot07 );
+
+ MM_DOT_PRODUCT(arow0,0);
+ MM_DOT_PRODUCT(arow1,0);
+ MM_DOT_PRODUCT(arow0,1);
+ MM_DOT_PRODUCT(arow1,1);
+ MM_DOT_PRODUCT(arow0,2);
+ MM_DOT_PRODUCT(arow1,2);
+ MM_DOT_PRODUCT(arow0,3);
+ MM_DOT_PRODUCT(arow1,3);
+ MM_DOT_PRODUCT(arow0,4);
+ MM_DOT_PRODUCT(arow1,4);
+ MM_DOT_PRODUCT(arow0,5);
+ MM_DOT_PRODUCT(arow1,5);
+ MM_DOT_PRODUCT(arow0,6);
+ MM_DOT_PRODUCT(arow1,6);
+ MM_DOT_PRODUCT(arow0,7);
+ MM_DOT_PRODUCT(arow1,7);
+#undef MM_DOT_PRODUCT
+ }
+
+ if(global_x * 4 < N && global_y * 8 < M) {
+ if(mad24(global_x, 4, 3) < N) {
+ vstore4(dot00, 0, dst_write0); dst_write0 += ldC;
+ if(mad24(global_y, 8, 1) < M) { vstore4(dot01, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 2) < M) { vstore4(dot02, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 3) < M) { vstore4(dot03, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 4) < M) { vstore4(dot04, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 5) < M) { vstore4(dot05, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 6) < M) { vstore4(dot06, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 7) < M) { vstore4(dot07, 0, dst_write0); }
+ } else if(mad24(global_x, 4, 2) < N) {
+ vstore2(dot00.xy, 0, dst_write0);
+ dst_write0[2] = dot00.z;
+ dst_write0 += ldC;
+ if(mad24(global_y, 8, 1) < M) {
+ vstore2(dot01.xy, 0, dst_write0);
+ dst_write0[2] = dot01.z;
+ dst_write0 += ldC;
+ } else
+ return;
+ if(mad24(global_y, 8, 2) < M) {
+ vstore2(dot02.xy, 0, dst_write0);
+ dst_write0[2] = dot02.z;
+ dst_write0 += ldC;
+ } else
+ return;
+ if(mad24(global_y, 8, 3) < M) {
+ vstore2(dot03.xy, 0, dst_write0);
+ dst_write0[2] = dot03.z;
+ dst_write0 += ldC;
+ } else
+ return;
+ if(mad24(global_y, 8, 4) < M) {
+ vstore2(dot04.xy, 0, dst_write0);
+ dst_write0[2] = dot04.z;
+ dst_write0 += ldC;
+ } else
+ return;
+ if(mad24(global_y, 8, 5) < M) {
+ vstore2(dot05.xy, 0, dst_write0);
+ dst_write0[2] = dot05.z;
+ dst_write0 += ldC;
+ } else
+ return;
+ if(mad24(global_y, 8, 6) < M) {
+ vstore2(dot06.xy, 0, dst_write0);
+ dst_write0[2] = dot06.z;
+ dst_write0 += ldC;
+ } else
+ return;
+ if(mad24(global_y, 8, 7) < M) {
+ vstore2(dot07.xy, 0, dst_write0);
+ dst_write0[2] = dot07.z;
+ }
+ } else if(mad24(global_x, 4, 1) < N) {
+ vstore2(dot00.xy, 0, dst_write0); dst_write0 += ldC;
+ if(mad24(global_y, 8, 1) < M) { vstore2(dot01.xy, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 2) < M) { vstore2(dot02.xy, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 3) < M) { vstore2(dot03.xy, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 4) < M) { vstore2(dot04.xy, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 5) < M) { vstore2(dot05.xy, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 6) < M) { vstore2(dot06.xy, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 7) < M) { vstore2(dot07.xy, 0, dst_write0); }
+ } else {
+ dst_write0[0] = dot00.x; dst_write0 += ldC;
+ if(mad24(global_y, 8, 1) < M) { dst_write0[0] = dot01.x; dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 2) < M) { dst_write0[0] = dot02.x; dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 3) < M) { dst_write0[0] = dot03.x; dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 4) < M) { dst_write0[0] = dot04.x; dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 5) < M) { dst_write0[0] = dot05.x; dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 6) < M) { dst_write0[0] = dot06.x; dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 7) < M) { dst_write0[0] = dot07.x; }
+ }
+ }
+}
+
+#undef VEC_SIZE
+#undef LWG_HEIGHT
+#undef TILE_M
+#undef TILE_K
+#undef TILE_N
+
+#define VEC_SIZE 4
+#define LWG_HEIGHT 4
+#define TILE_M 8
+#define TILE_K 16
+#define TILE_N 32
+
+__attribute__((reqd_work_group_size(8, LWG_HEIGHT, 1)))
+__kernel void intelblas_gemm_buffer_TT(
+ const __global float *src0, int off0,
+ const __global float *src1, int off1,
+ __global float *dst, int offd,
+ int M,
+ int N,
+ int K,
+ float alpha,
+ float beta,
+ int ldA,
+ int ldB,
+ int ldC,
+ int start_index,
+ int stride)
+{
+ const int group_x = get_group_id(0);
+ const int group_y = get_group_id(1);
+ const int local_x = get_local_id(0);
+ const int local_y = get_local_id(1);
+ const int global_x = get_global_id(0);
+ const int global_y = get_global_id(1);
+
+ float8 dot0 = 0.f;
+ float8 dot1 = 0.f;
+ float8 dot2 = 0.f;
+ float8 dot3 = 0.f;
+
+ float16 brow0;
+ float16 brow1;
+ float16 brow2;
+ float16 brow3;
+
+ __global float *dst_write0 = dst + local_x * VEC_SIZE + ( group_x * TILE_N ) + ( group_y * LWG_HEIGHT * TILE_M + local_y * TILE_M) * ldC + offd;
+
+ const __global float *src0_read = src0 + (local_x * ( TILE_K / 8 ) + start_index) * ldA + group_y * LWG_HEIGHT * TILE_M + local_y * TILE_M + off0;
+
+ const __global float *src1_read0 = src1 + (local_x * VEC_SIZE + ( group_x * TILE_N )) * ldB + start_index + off1;
+
+ float4 dot00 = (start_index != 0) ? vload4(0, dst_write0) : ((beta != 0.0)? ((float)beta * vload4(0, dst_write0 )) : (float4)(0.0));
+ float4 dot01 = (start_index != 0) ? vload4(0, dst_write0 + ldC) : ((beta != 0.0)? ((float)beta * vload4(0, dst_write0 + ldC )) : (float4)(0.0));
+ float4 dot02 = (start_index != 0) ? vload4(0, dst_write0 + 2 * ldC) : ((beta != 0.0)? ((float)beta * vload4(0, dst_write0 + 2 * ldC)) : (float4)(0.0));
+ float4 dot03 = (start_index != 0) ? vload4(0, dst_write0 + 3 * ldC) : ((beta != 0.0)? ((float)beta * vload4(0, dst_write0 + 3 * ldC)) : (float4)(0.0));
+ float4 dot04 = (start_index != 0) ? vload4(0, dst_write0 + 4 * ldC) : ((beta != 0.0)? ((float)beta * vload4(0, dst_write0 + 4 * ldC)) : (float4)(0.0));
+ float4 dot05 = (start_index != 0) ? vload4(0, dst_write0 + 5 * ldC) : ((beta != 0.0)? ((float)beta * vload4(0, dst_write0 + 5 * ldC)) : (float4)(0.0));
+ float4 dot06 = (start_index != 0) ? vload4(0, dst_write0 + 6 * ldC) : ((beta != 0.0)? ((float)beta * vload4(0, dst_write0 + 6 * ldC)) : (float4)(0.0));
+ float4 dot07 = (start_index != 0) ? vload4(0, dst_write0 + 7 * ldC) : ((beta != 0.0)? ((float)beta * vload4(0, dst_write0 + 7 * ldC)) : (float4)(0.0));
+
+ int end_index = min(start_index + stride, K);
+ while( start_index + TILE_K <= end_index ) {
+ brow0 = vload16(0, src1_read0);
+ brow1 = vload16(0, src1_read0 + ldB);
+ brow2 = vload16(0, src1_read0 + 2 * ldB);
+ brow3 = vload16(0, src1_read0 + 3 * ldB);
+
+ float8 arow0 = (float)alpha * vload8(0, src0_read);
+ float8 arow1 = (float)alpha * vload8(0, src0_read + ldA);
+
+#define DOT_PRODUCT( _dot, _arow, index, _brow) \
+ _dot.s0 = mad( intel_sub_group_shuffle( _arow.s0, index ), _brow, _dot.s0 ); \
+ _dot.s1 = mad( intel_sub_group_shuffle( _arow.s1, index ), _brow, _dot.s1 ); \
+ _dot.s2 = mad( intel_sub_group_shuffle( _arow.s2, index ), _brow, _dot.s2 ); \
+ _dot.s3 = mad( intel_sub_group_shuffle( _arow.s3, index ), _brow, _dot.s3 ); \
+ _dot.s4 = mad( intel_sub_group_shuffle( _arow.s4, index ), _brow, _dot.s4 ); \
+ _dot.s5 = mad( intel_sub_group_shuffle( _arow.s5, index ), _brow, _dot.s5 ); \
+ _dot.s6 = mad( intel_sub_group_shuffle( _arow.s6, index ), _brow, _dot.s6 ); \
+ _dot.s7 = mad( intel_sub_group_shuffle( _arow.s7, index ), _brow, _dot.s7 );
+
+#define MM_DOT_PRODUCT( _brow, _dot) \
+ DOT_PRODUCT(_dot, arow0, 0, _brow.s0); \
+ DOT_PRODUCT(_dot, arow1, 0, _brow.s1); \
+ DOT_PRODUCT(_dot, arow0, 1, _brow.s2); \
+ DOT_PRODUCT(_dot, arow1, 1, _brow.s3); \
+ DOT_PRODUCT(_dot, arow0, 2, _brow.s4); \
+ DOT_PRODUCT(_dot, arow1, 2, _brow.s5); \
+ DOT_PRODUCT(_dot, arow0, 3, _brow.s6); \
+ DOT_PRODUCT(_dot, arow1, 3, _brow.s7); \
+ DOT_PRODUCT(_dot, arow0, 4, _brow.s8); \
+ DOT_PRODUCT(_dot, arow1, 4, _brow.s9); \
+ DOT_PRODUCT(_dot, arow0, 5, _brow.sa); \
+ DOT_PRODUCT(_dot, arow1, 5, _brow.sb); \
+ DOT_PRODUCT(_dot, arow0, 6, _brow.sc); \
+ DOT_PRODUCT(_dot, arow1, 6, _brow.sd); \
+ DOT_PRODUCT(_dot, arow0, 7, _brow.se); \
+ DOT_PRODUCT(_dot, arow1, 7, _brow.sf);
+
+ MM_DOT_PRODUCT( brow0, dot0 );
+ MM_DOT_PRODUCT( brow1, dot1 );
+ MM_DOT_PRODUCT( brow2, dot2 );
+ MM_DOT_PRODUCT( brow3, dot3 );
+#undef MM_DOT_PRODUCT
+#undef DOT_PRODUCT
+
+ src1_read0 += TILE_K;
+ src0_read += TILE_K * ldA;
+ start_index += TILE_K;
+ }
+
+ if(start_index < end_index) {
+ brow0 = vload16(0, src1_read0); src1_read0 += ldB;
+ brow1 = vload16(0, src1_read0); src1_read0 += ldB;
+ brow2 = vload16(0, src1_read0); src1_read0 += ldB;
+ brow3 = vload16(0, src1_read0);
+
+ float8 arow0 = (float)alpha * vload8(0, src0_read);
+ float8 arow1 = (float)alpha * vload8(0, src0_read + ldA);
+
+#define DOT_PRODUCT( _dot, _arow, index, _brow) \
+ _dot.s0 = (w < K) ? mad( intel_sub_group_shuffle( _arow.s0, index ), _brow, _dot.s0 ) : _dot.s0; \
+ _dot.s1 = (w < K) ? mad( intel_sub_group_shuffle( _arow.s1, index ), _brow, _dot.s1 ) : _dot.s1; \
+ _dot.s2 = (w < K) ? mad( intel_sub_group_shuffle( _arow.s2, index ), _brow, _dot.s2 ) : _dot.s2; \
+ _dot.s3 = (w < K) ? mad( intel_sub_group_shuffle( _arow.s3, index ), _brow, _dot.s3 ) : _dot.s3; \
+ _dot.s4 = (w < K) ? mad( intel_sub_group_shuffle( _arow.s4, index ), _brow, _dot.s4 ) : _dot.s4; \
+ _dot.s5 = (w < K) ? mad( intel_sub_group_shuffle( _arow.s5, index ), _brow, _dot.s5 ) : _dot.s5; \
+ _dot.s6 = (w < K) ? mad( intel_sub_group_shuffle( _arow.s6, index ), _brow, _dot.s6 ) : _dot.s6; \
+ _dot.s7 = (w++ < K) ? mad( intel_sub_group_shuffle( _arow.s7, index ), _brow, _dot.s7 ) : _dot.s7;
+
+#define MM_DOT_PRODUCT( _brow, _dot) \
+ DOT_PRODUCT(_dot, arow0, 0, _brow.s0); \
+ DOT_PRODUCT(_dot, arow1, 0, _brow.s1); \
+ DOT_PRODUCT(_dot, arow0, 1, _brow.s2); \
+ DOT_PRODUCT(_dot, arow1, 1, _brow.s3); \
+ DOT_PRODUCT(_dot, arow0, 2, _brow.s4); \
+ DOT_PRODUCT(_dot, arow1, 2, _brow.s5); \
+ DOT_PRODUCT(_dot, arow0, 3, _brow.s6); \
+ DOT_PRODUCT(_dot, arow1, 3, _brow.s7); \
+ DOT_PRODUCT(_dot, arow0, 4, _brow.s8); \
+ DOT_PRODUCT(_dot, arow1, 4, _brow.s9); \
+ DOT_PRODUCT(_dot, arow0, 5, _brow.sa); \
+ DOT_PRODUCT(_dot, arow1, 5, _brow.sb); \
+ DOT_PRODUCT(_dot, arow0, 6, _brow.sc); \
+ DOT_PRODUCT(_dot, arow1, 6, _brow.sd); \
+ DOT_PRODUCT(_dot, arow0, 7, _brow.se); \
+ DOT_PRODUCT(_dot, arow1, 7, _brow.sf);
+
+ int w = start_index;
+ MM_DOT_PRODUCT( brow0, dot0 );
+ w = start_index;
+ MM_DOT_PRODUCT( brow1, dot1 );
+ w = start_index;
+ MM_DOT_PRODUCT( brow2, dot2 );
+ w = start_index;
+ MM_DOT_PRODUCT( brow3, dot3 );
+#undef MM_DOT_PRODUCT
+#undef DOT_PRODUCT
+ }
+
+ dot00 += (float4)(dot0.s0, dot1.s0, dot2.s0, dot3.s0);
+ dot01 += (float4)(dot0.s1, dot1.s1, dot2.s1, dot3.s1);
+ dot02 += (float4)(dot0.s2, dot1.s2, dot2.s2, dot3.s2);
+ dot03 += (float4)(dot0.s3, dot1.s3, dot2.s3, dot3.s3);
+ dot04 += (float4)(dot0.s4, dot1.s4, dot2.s4, dot3.s4);
+ dot05 += (float4)(dot0.s5, dot1.s5, dot2.s5, dot3.s5);
+ dot06 += (float4)(dot0.s6, dot1.s6, dot2.s6, dot3.s6);
+ dot07 += (float4)(dot0.s7, dot1.s7, dot2.s7, dot3.s7);
+
+ if(global_x * 4 < N && global_y * 8 < M) {
+ if(mad24(global_x, 4, 3) < N) {
+ vstore4(dot00, 0, dst_write0); dst_write0 += ldC;
+ if(mad24(global_y, 8, 1) < M) { vstore4(dot01, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 2) < M) { vstore4(dot02, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 3) < M) { vstore4(dot03, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 4) < M) { vstore4(dot04, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 5) < M) { vstore4(dot05, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 6) < M) { vstore4(dot06, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 7) < M) { vstore4(dot07, 0, dst_write0); }
+ } else if(mad24(global_x, 4, 2) < N) {
+ vstore2(dot00.xy, 0, dst_write0);
+ dst_write0[2] = dot00.z;
+ dst_write0 += ldC;
+ if(mad24(global_y, 8, 1) < M) {
+ vstore2(dot01.xy, 0, dst_write0);
+ dst_write0[2] = dot01.z;
+ dst_write0 += ldC;
+ } else
+ return;
+ if(mad24(global_y, 8, 2) < M) {
+ vstore2(dot02.xy, 0, dst_write0);
+ dst_write0[2] = dot02.z;
+ dst_write0 += ldC;
+ } else
+ return;
+ if(mad24(global_y, 8, 3) < M) {
+ vstore2(dot03.xy, 0, dst_write0);
+ dst_write0[2] = dot03.z;
+ dst_write0 += ldC;
+ } else
+ return;
+ if(mad24(global_y, 8, 4) < M) {
+ vstore2(dot04.xy, 0, dst_write0);
+ dst_write0[2] = dot04.z;
+ dst_write0 += ldC;
+ } else
+ return;
+ if(mad24(global_y, 8, 5) < M) {
+ vstore2(dot05.xy, 0, dst_write0);
+ dst_write0[2] = dot05.z;
+ dst_write0 += ldC;
+ } else
+ return;
+ if(mad24(global_y, 8, 6) < M) {
+ vstore2(dot06.xy, 0, dst_write0);
+ dst_write0[2] = dot06.z;
+ dst_write0 += ldC;
+ } else
+ return;
+ if(mad24(global_y, 8, 7) < M) {
+ vstore2(dot07.xy, 0, dst_write0);
+ dst_write0[2] = dot07.z;
+ }
+ } else if(mad24(global_x, 4, 1) < N) {
+ vstore2(dot00.xy, 0, dst_write0); dst_write0 += ldC;
+ if(mad24(global_y, 8, 1) < M) { vstore2(dot01.xy, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 2) < M) { vstore2(dot02.xy, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 3) < M) { vstore2(dot03.xy, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 4) < M) { vstore2(dot04.xy, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 5) < M) { vstore2(dot05.xy, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 6) < M) { vstore2(dot06.xy, 0, dst_write0); dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 7) < M) { vstore2(dot07.xy, 0, dst_write0); }
+ } else {
+ dst_write0[0] = dot00.x; dst_write0 += ldC;
+ if(mad24(global_y, 8, 1) < M) { dst_write0[0] = dot01.x; dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 2) < M) { dst_write0[0] = dot02.x; dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 3) < M) { dst_write0[0] = dot03.x; dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 4) < M) { dst_write0[0] = dot04.x; dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 5) < M) { dst_write0[0] = dot05.x; dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 6) < M) { dst_write0[0] = dot06.x; dst_write0 += ldC; }
+ else return;
+ if(mad24(global_y, 8, 7) < M) { dst_write0[0] = dot07.x; }
+ }
+ }
+}
+
+#undef VEC_SIZE
+#undef LWG_HEIGHT
+#undef TILE_M
+#undef TILE_K
+#undef TILE_N
+
+#endif
diff --git a/modules/core/src/opencl/runtime/opencl_core.cpp b/modules/core/src/opencl/runtime/opencl_core.cpp
index dc3d0a4..34ae5d8 100644
--- a/modules/core/src/opencl/runtime/opencl_core.cpp
+++ b/modules/core/src/opencl/runtime/opencl_core.cpp
@@ -116,6 +116,7 @@ static void* WinGetProcAddress(const char* name)
else if (GetProcAddress(handle, OPENCL_FUNC_TO_CHECK_1_1) == NULL)
{
fprintf(stderr, ERROR_MSG_INVALID_VERSION);
+ FreeLibrary(handle);
handle = NULL;
}
}
@@ -257,14 +258,14 @@ static void* opencl_check_fn(int ID)
const struct DynamicFnEntry* e = NULL;
if (ID < CUSTOM_FUNCTION_ID)
{
- assert(ID >= 0 && ID < (int)(sizeof(opencl_fn_list)/sizeof(opencl_fn_list[0])));
+ CV_Assert(ID >= 0 && ID < (int)(sizeof(opencl_fn_list)/sizeof(opencl_fn_list[0])));
e = opencl_fn_list[ID];
}
#ifdef HAVE_OPENCL_SVM
else if (ID >= SVM_FUNCTION_ID_START && ID < SVM_FUNCTION_ID_END)
{
ID = ID - SVM_FUNCTION_ID_START;
- assert(ID >= 0 && ID < (int)(sizeof(opencl_svm_fn_list)/sizeof(opencl_svm_fn_list[0])));
+ CV_Assert(ID >= 0 && ID < (int)(sizeof(opencl_svm_fn_list)/sizeof(opencl_svm_fn_list[0])));
e = opencl_svm_fn_list[ID];
}
#endif
diff --git a/modules/core/src/opengl.cpp b/modules/core/src/opengl.cpp
index f3d106f..75ee5c7 100644
--- a/modules/core/src/opengl.cpp
+++ b/modules/core/src/opengl.cpp
@@ -1590,7 +1590,7 @@ void cv::ogl::render(const ogl::Arrays& arr, InputArray indices, int mode, Scala
#endif // HAVE_OPENCL
#if defined(HAVE_OPENGL)
-# if defined(ANDROID)
+# if defined(__ANDROID__)
# include <EGL/egl.h>
# elif defined(__linux__)
# include <GL/glx.h>
@@ -1655,11 +1655,11 @@ Context& initializeContextFromGL()
cl_context_properties properties[] =
{
-#if defined(WIN32) || defined(_WIN32)
+#if defined(_WIN32)
CL_CONTEXT_PLATFORM, (cl_context_properties)platforms[i],
CL_GL_CONTEXT_KHR, (cl_context_properties)wglGetCurrentContext(),
CL_WGL_HDC_KHR, (cl_context_properties)wglGetCurrentDC(),
-#elif defined(ANDROID)
+#elif defined(__ANDROID__)
CL_CONTEXT_PLATFORM, (cl_context_properties)platforms[i],
CL_GL_CONTEXT_KHR, (cl_context_properties)eglGetCurrentContext(),
CL_EGL_DISPLAY_KHR, (cl_context_properties)eglGetCurrentDisplay(),
diff --git a/modules/core/src/out.cpp b/modules/core/src/out.cpp
index 343fd0a..77c55ab 100644
--- a/modules/core/src/out.cpp
+++ b/modules/core/src/out.cpp
@@ -103,7 +103,7 @@ namespace cv
}
else
{
- sprintf(floatFormat, "%%.%dg", std::min(precision, 20));
+ cv_snprintf(floatFormat, sizeof(floatFormat), "%%.%dg", std::min(precision, 20));
}
switch(mtx.depth())
diff --git a/modules/core/src/ovx.cpp b/modules/core/src/ovx.cpp
index a53f553..d906ead 100644
--- a/modules/core/src/ovx.cpp
+++ b/modules/core/src/ovx.cpp
@@ -14,6 +14,38 @@
namespace cv
{
+namespace ovx
+{
+#ifdef HAVE_OPENVX
+
+// Simple TLSData<ivx::Context> doesn't work, because default constructor doesn't create any OpenVX context.
+struct OpenVXTLSData
+{
+ OpenVXTLSData() : ctx(ivx::Context::create()) {}
+ ivx::Context ctx;
+};
+
+static TLSData<OpenVXTLSData>& getOpenVXTLSData()
+{
+ CV_SINGLETON_LAZY_INIT_REF(TLSData<OpenVXTLSData>, new TLSData<OpenVXTLSData>())
+}
+
+struct OpenVXCleanupFunctor
+{
+ ~OpenVXCleanupFunctor() { getOpenVXTLSData().cleanup(); }
+};
+static OpenVXCleanupFunctor g_openvx_cleanup_functor;
+
+ivx::Context& getOpenVXContext()
+{
+ return getOpenVXTLSData().get()->ctx;
+}
+
+#endif
+
+} // namespace
+
+
bool haveOpenVX()
{
#ifdef HAVE_OPENVX
@@ -22,7 +54,7 @@ bool haveOpenVX()
{
try
{
- ivx::Context context = ivx::Context::create();
+ ivx::Context context = ovx::getOpenVXContext();
vx_uint16 vComp = ivx::compiledWithVersion();
vx_uint16 vCurr = context.version();
g_haveOpenVX =
diff --git a/modules/core/src/parallel.cpp b/modules/core/src/parallel.cpp
index 71ac94e..53ebb42 100644
--- a/modules/core/src/parallel.cpp
+++ b/modules/core/src/parallel.cpp
@@ -42,7 +42,9 @@
#include "precomp.hpp"
-#if defined WIN32 || defined WINCE
+#include <opencv2/core/utils/trace.private.hpp>
+
+#if defined _WIN32 || defined WINCE
#include <windows.h>
#undef small
#undef min
@@ -54,7 +56,7 @@
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
- #if defined ANDROID
+ #if defined __ANDROID__
#include <sys/sysconf.h>
#elif defined __APPLE__
#include <sys/sysctl.h>
@@ -163,10 +165,11 @@ namespace
}
#endif
- class ParallelLoopBodyWrapper : public cv::ParallelLoopBody
+ class ParallelLoopBodyWrapperContext
{
public:
- ParallelLoopBodyWrapper(const cv::ParallelLoopBody& _body, const cv::Range& _r, double _nstripes)
+ ParallelLoopBodyWrapperContext(const cv::ParallelLoopBody& _body, const cv::Range& _r, double _nstripes) :
+ is_rng_used(false)
{
body = &_body;
@@ -174,51 +177,119 @@ namespace
double len = wholeRange.end - wholeRange.start;
nstripes = cvRound(_nstripes <= 0 ? len : MIN(MAX(_nstripes, 1.), len));
+ // propagate main thread state
+ rng = cv::theRNG();
+
+#ifdef OPENCV_TRACE
+ traceRootRegion = CV_TRACE_NS::details::getCurrentRegion();
+ traceRootContext = CV_TRACE_NS::details::getTraceManager().tls.get();
+#endif
+
#ifdef ENABLE_INSTRUMENTATION
pThreadRoot = cv::instr::getInstrumentTLSStruct().pCurrentNode;
#endif
}
-#ifdef ENABLE_INSTRUMENTATION
- ~ParallelLoopBodyWrapper()
+ ~ParallelLoopBodyWrapperContext()
{
+#ifdef ENABLE_INSTRUMENTATION
for(size_t i = 0; i < pThreadRoot->m_childs.size(); i++)
SyncNodes(pThreadRoot->m_childs[i]);
+#endif
+ if (is_rng_used)
+ {
+ // Some parallel backends execute nested jobs in the main thread,
+ // so we need to restore initial RNG state here.
+ cv::theRNG() = rng;
+ // We can't properly update RNG state based on RNG usage in worker threads,
+ // so lets just change main thread RNG state to the next value.
+ // Note: this behaviour is not equal to single-threaded mode.
+ cv::theRNG().next();
+ }
+#ifdef OPENCV_TRACE
+ if (traceRootRegion)
+ CV_TRACE_NS::details::parallelForFinalize(*traceRootRegion);
+#endif
}
+
+ const cv::ParallelLoopBody* body;
+ cv::Range wholeRange;
+ int nstripes;
+ cv::RNG rng;
+ mutable bool is_rng_used;
+#ifdef OPENCV_TRACE
+ CV_TRACE_NS::details::Region* traceRootRegion;
+ CV_TRACE_NS::details::TraceManagerThreadLocal* traceRootContext;
#endif
+#ifdef ENABLE_INSTRUMENTATION
+ cv::instr::InstrNode *pThreadRoot;
+#endif
+ private:
+ ParallelLoopBodyWrapperContext(const ParallelLoopBodyWrapperContext&); // disabled
+ ParallelLoopBodyWrapperContext& operator=(const ParallelLoopBodyWrapperContext&); // disabled
+ };
+
+ class ParallelLoopBodyWrapper : public cv::ParallelLoopBody
+ {
+ public:
+ ParallelLoopBodyWrapper(ParallelLoopBodyWrapperContext& ctx_) :
+ ctx(ctx_)
+ {
+ }
+ ~ParallelLoopBodyWrapper()
+ {
+ }
void operator()(const cv::Range& sr) const
{
+#ifdef OPENCV_TRACE
+ // TODO CV_TRACE_NS::details::setCurrentRegion(rootRegion);
+ if (ctx.traceRootRegion && ctx.traceRootContext)
+ CV_TRACE_NS::details::parallelForSetRootRegion(*ctx.traceRootRegion, *ctx.traceRootContext);
+ CV__TRACE_OPENCV_FUNCTION_NAME("parallel_for_body");
+ if (ctx.traceRootRegion)
+ CV_TRACE_NS::details::parallelForAttachNestedRegion(*ctx.traceRootRegion);
+#endif
+
#ifdef ENABLE_INSTRUMENTATION
{
cv::instr::InstrTLSStruct *pInstrTLS = &cv::instr::getInstrumentTLSStruct();
- pInstrTLS->pCurrentNode = pThreadRoot; // Initialize TLS node for thread
+ pInstrTLS->pCurrentNode = ctx.pThreadRoot; // Initialize TLS node for thread
}
-#endif
CV_INSTRUMENT_REGION()
+#endif
+
+ // propagate main thread state
+ cv::theRNG() = ctx.rng;
cv::Range r;
+ cv::Range wholeRange = ctx.wholeRange;
+ int nstripes = ctx.nstripes;
r.start = (int)(wholeRange.start +
((uint64)sr.start*(wholeRange.end - wholeRange.start) + nstripes/2)/nstripes);
r.end = sr.end >= nstripes ? wholeRange.end : (int)(wholeRange.start +
((uint64)sr.end*(wholeRange.end - wholeRange.start) + nstripes/2)/nstripes);
- (*body)(r);
+
+#ifdef OPENCV_TRACE
+ CV_TRACE_ARG_VALUE(range_start, "range.start", (int64)r.start);
+ CV_TRACE_ARG_VALUE(range_end, "range.end", (int64)r.end);
+#endif
+
+ (*ctx.body)(r);
+
+ if (!ctx.is_rng_used && !(cv::theRNG() == ctx.rng))
+ ctx.is_rng_used = true;
}
- cv::Range stripeRange() const { return cv::Range(0, nstripes); }
+ cv::Range stripeRange() const { return cv::Range(0, ctx.nstripes); }
protected:
- const cv::ParallelLoopBody* body;
- cv::Range wholeRange;
- int nstripes;
-#ifdef ENABLE_INSTRUMENTATION
- cv::instr::InstrNode *pThreadRoot;
-#endif
+ ParallelLoopBodyWrapperContext& ctx;
};
#if defined HAVE_TBB
class ProxyLoopBody : public ParallelLoopBodyWrapper
{
public:
- ProxyLoopBody(const cv::ParallelLoopBody& _body, const cv::Range& _r, double _nstripes)
- : ParallelLoopBodyWrapper(_body, _r, _nstripes)
+ ProxyLoopBody(ParallelLoopBodyWrapperContext& ctx_)
+ : ParallelLoopBodyWrapper(ctx_)
{}
void operator ()(const tbb::blocked_range<int>& range) const
@@ -239,8 +310,8 @@ namespace
class ProxyLoopBody : public ParallelLoopBodyWrapper
{
public:
- ProxyLoopBody(const cv::ParallelLoopBody& _body, const cv::Range& _r, double _nstripes)
- : ParallelLoopBodyWrapper(_body, _r, _nstripes)
+ ProxyLoopBody(ParallelLoopBodyWrapperContext& ctx)
+ : ParallelLoopBodyWrapper(ctx)
{}
void operator ()(int i) const
@@ -294,19 +365,30 @@ static SchedPtr pplScheduler;
void cv::parallel_for_(const cv::Range& range, const cv::ParallelLoopBody& body, double nstripes)
{
+#ifdef OPENCV_TRACE
+ CV__TRACE_OPENCV_FUNCTION_NAME_("parallel_for", 0);
+ CV_TRACE_ARG_VALUE(range_start, "range.start", (int64)range.start);
+ CV_TRACE_ARG_VALUE(range_end, "range.end", (int64)range.end);
+ CV_TRACE_ARG_VALUE(nstripes, "nstripes", (int64)nstripes);
+#endif
+
CV_INSTRUMENT_REGION_MT_FORK()
if (range.empty())
return;
#ifdef CV_PARALLEL_FRAMEWORK
- if(numThreads != 0)
+ static int flagNestedParallelFor = 0;
+ bool isNotNesterParallelFor = CV_XADD(&flagNestedParallelFor, 1) == 0;
+ if(numThreads != 0 && isNotNesterParallelFor)
{
- ProxyLoopBody pbody(body, range, nstripes);
+ ParallelLoopBodyWrapperContext ctx(body, range, nstripes);
+ ProxyLoopBody pbody(ctx);
cv::Range stripeRange = pbody.stripeRange();
if( stripeRange.end - stripeRange.start == 1 )
{
body(range);
+ flagNestedParallelFor = 0;
return;
}
@@ -327,7 +409,7 @@ void cv::parallel_for_(const cv::Range& range, const cv::ParallelLoopBody& body,
#elif defined HAVE_OPENMP
- #pragma omp parallel for schedule(dynamic)
+ #pragma omp parallel for schedule(dynamic) num_threads(numThreads > 0 ? numThreads : numThreadsMax)
for (int i = stripeRange.start; i < stripeRange.end; ++i)
pbody(Range(i, i + 1));
@@ -362,7 +444,7 @@ void cv::parallel_for_(const cv::Range& range, const cv::ParallelLoopBody& body,
#error You have hacked and compiling with unsupported parallel framework
#endif
-
+ flagNestedParallelFor = 0;
}
else
@@ -396,11 +478,14 @@ int cv::getNumThreads(void)
#elif defined HAVE_OPENMP
- return omp_get_max_threads();
+ return numThreads > 0
+ ? numThreads
+ : numThreadsMax;
+
#elif defined HAVE_GCD
- return 512; // the GCD thread pool limit
+ return cv::getNumberOfCPUs(); // the GCD thread pool limit
#elif defined WINRT
@@ -441,10 +526,7 @@ void cv::setNumThreads( int threads )
#elif defined HAVE_OPENMP
- if(omp_in_parallel())
- return; // can't change number of openmp threads inside a parallel region
-
- omp_set_num_threads(threads > 0 ? threads : numThreadsMax);
+ return; // nothing needed as num_threads clause is used in #pragma omp parallel for
#elif defined HAVE_GCD
@@ -508,7 +590,7 @@ int cv::getThreadNum(void)
#endif
}
-#ifdef ANDROID
+#ifdef __ANDROID__
static inline int getNumberOfCPUsImpl()
{
FILE* cpuPossible = fopen("/sys/devices/system/cpu/possible", "r");
@@ -550,7 +632,7 @@ static inline int getNumberOfCPUsImpl()
int cv::getNumberOfCPUs(void)
{
-#if defined WIN32 || defined _WIN32
+#if defined _WIN32
SYSTEM_INFO sysinfo;
#if (defined(_M_ARM) || defined(_M_X64) || defined(WINRT)) && _WIN32_WINNT >= 0x501
GetNativeSystemInfo( &sysinfo );
@@ -559,7 +641,7 @@ int cv::getNumberOfCPUs(void)
#endif
return (int)sysinfo.dwNumberOfProcessors;
-#elif defined ANDROID
+#elif defined __ANDROID__
static int ncpus = getNumberOfCPUsImpl();
return ncpus;
#elif defined __linux__
diff --git a/modules/core/src/parallel_pthreads.cpp b/modules/core/src/parallel_pthreads.cpp
index 96ddfe7..b571ef0 100644
--- a/modules/core/src/parallel_pthreads.cpp
+++ b/modules/core/src/parallel_pthreads.cpp
@@ -112,7 +112,7 @@ class ForThread
{
public:
- ForThread(): m_task_start(false), m_parent(0), m_state(eFTNotStarted), m_id(0)
+ ForThread(): m_posix_thread(0), m_task_start(false), m_parent(0), m_state(eFTNotStarted), m_id(0)
{
}
@@ -141,10 +141,10 @@ private:
pthread_t m_posix_thread;
pthread_mutex_t m_thread_mutex;
pthread_cond_t m_cond_thread_task;
- bool m_task_start;
+ volatile bool m_task_start;
ThreadManager* m_parent;
- ForThreadState m_state;
+ volatile ForThreadState m_state;
size_t m_id;
};
@@ -206,7 +206,6 @@ private:
pthread_mutex_t m_manager_access_mutex;
static const char m_env_name[];
- static const unsigned int m_default_number_of_threads;
work_load m_work_load;
@@ -223,14 +222,6 @@ private:
const char ThreadManager::m_env_name[] = "OPENCV_FOR_THREADS_NUM";
-#ifdef ANDROID
-// many modern phones/tables have 4-core CPUs. Let's use no more
-// than 2 threads by default not to overheat the devices
-const unsigned int ThreadManager::m_default_number_of_threads = 2;
-#else
-const unsigned int ThreadManager::m_default_number_of_threads = 8;
-#endif
-
ForThread::~ForThread()
{
if(m_state == eFTStarted)
@@ -318,6 +309,8 @@ void ForThread::execute()
void ForThread::thread_body()
{
+ (void)cv::utils::getThreadID(); // notify OpenCV about new thread
+
m_parent->m_is_work_thread.get()->value = true;
pthread_mutex_lock(&m_thread_mutex);
@@ -534,7 +527,15 @@ void ThreadManager::setNumOfThreads(size_t n)
size_t ThreadManager::defaultNumberOfThreads()
{
- unsigned int result = m_default_number_of_threads;
+#ifdef __ANDROID__
+ // many modern phones/tables have 4-core CPUs. Let's use no more
+ // than 2 threads by default not to overheat the devices
+ const unsigned int default_number_of_threads = 2;
+#else
+ const unsigned int default_number_of_threads = (unsigned int)std::max(1, cv::getNumberOfCPUs());
+#endif
+
+ unsigned int result = default_number_of_threads;
char * env = getenv(m_env_name);
diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp
index ccdb135..3f12fc4 100644
--- a/modules/core/src/persistence.cpp
+++ b/modules/core/src/persistence.cpp
@@ -50,15 +50,6 @@
#define USE_ZLIB 1
-#ifdef __APPLE__
-# include "TargetConditionals.h"
-# if (defined TARGET_OS_IPHONE && TARGET_OS_IPHONE) || (defined TARGET_IPHONE_SIMULATOR && TARGET_IPHONE_SIMULATOR)
-# undef USE_ZLIB
-# define USE_ZLIB 0
- typedef void* gzFile;
-# endif
-#endif
-
#if USE_ZLIB
# ifndef _LFS64_LARGEFILE
# define _LFS64_LARGEFILE 0
@@ -67,6 +58,8 @@
# define _FILE_OFFSET_BITS 0
# endif
# include <zlib.h>
+#else
+typedef void* gzFile;
#endif
/****************************************************************************************\
@@ -374,6 +367,11 @@ namespace base64
void check_dt(const char* dt);
private:
+ // disable copy and assignment
+ Base64Writer(const Base64Writer &);
+ Base64Writer & operator=(const Base64Writer &);
+
+ private:
Base64ContextEmitter * emitter;
std::string data_type_string;
@@ -806,7 +804,7 @@ cvGetFileNode( CvFileStorage* fs, CvFileNode* _map_node,
if( !map_node )
map_node = (CvFileNode*)cvGetSeqElem( fs->roots, k );
-
+ CV_Assert(map_node != NULL);
if( !CV_NODE_IS_MAP(map_node->tag) )
{
if( (!CV_NODE_IS_SEQ(map_node->tag) || map_node->data.seq->total != 0) &&
@@ -1383,7 +1381,8 @@ static char* icvYMLParseBase64(CvFileStorage* fs, char* ptr, int indent, CvFileN
beg = end;
icvYMLGetMultilineStringContent( fs, beg, indent, beg, end );
}
- if ( !base64::base64_valid(base64_buffer.data(), 0U, base64_buffer.size()) )
+ if ( base64_buffer.empty() ||
+ !base64::base64_valid(base64_buffer.data(), 0U, base64_buffer.size()) )
CV_PARSE_ERROR( "Invalid Base64 data." );
/* buffer for decoded data(exclude header) */
@@ -1458,7 +1457,7 @@ static char*
icvYMLParseValue( CvFileStorage* fs, char* ptr, CvFileNode* node,
int parent_flags, int min_indent )
{
- char buf[CV_FS_MAX_LEN + 1024];
+ char buf[CV_FS_MAX_LEN + 1024] = {0};
char* endptr = 0;
char c = ptr[0], d = ptr[1];
int is_parent_flow = CV_NODE_IS_FLOW(parent_flags);
@@ -1475,6 +1474,26 @@ icvYMLParseValue( CvFileStorage* fs, char* ptr, CvFileNode* node,
ptr++;
value_type |= CV_NODE_USER;
}
+ if ( d == '<') //support of full type heading from YAML 1.2
+ {
+ const char* yamlTypeHeading = "<tag:yaml.org,2002:";
+ const size_t headingLenght = strlen(yamlTypeHeading);
+
+ char* typeEndPtr = ++ptr;
+
+ do d = *++typeEndPtr;
+ while( cv_isprint(d) && d != ' ' && d != '>' );
+
+ if ( d == '>' && (size_t)(typeEndPtr - ptr) > headingLenght )
+ {
+ if ( memcmp(ptr, yamlTypeHeading, headingLenght) == 0 )
+ {
+ value_type |= CV_NODE_USER;
+ *typeEndPtr = ' ';
+ ptr += headingLenght - 1;
+ }
+ }
+ }
endptr = ptr++;
do d = *++endptr;
@@ -1655,7 +1674,7 @@ force_int:
{
int new_min_indent = min_indent + !is_parent_flow;
int struct_flags = CV_NODE_FLOW + (c == '{' ? CV_NODE_MAP : CV_NODE_SEQ);
- int is_simple = 1;
+ bool is_simple = true;
icvFSCreateCollection( fs, CV_NODE_TYPE(struct_flags) +
(node->info ? CV_NODE_USER : 0), node );
@@ -1693,16 +1712,18 @@ force_int:
break;
elem = (CvFileNode*)cvSeqPush( node->data.seq, 0 );
}
+ CV_Assert(elem);
ptr = icvYMLParseValue( fs, ptr, elem, struct_flags, new_min_indent );
if( CV_NODE_IS_MAP(struct_flags) )
elem->tag |= CV_NODE_NAMED;
- is_simple &= !CV_NODE_IS_COLLECTION(elem->tag);
+ is_simple = is_simple && !CV_NODE_IS_COLLECTION(elem->tag);
}
node->data.seq->flags |= is_simple ? CV_NODE_SEQ_SIMPLE : 0;
}
else
{
- int indent, struct_flags, is_simple;
+ int indent, struct_flags;
+ bool is_simple;
if( is_parent_flow || c != '-' )
{
@@ -1747,7 +1768,7 @@ force_string:
(node->info ? CV_NODE_USER : 0), node );
indent = (int)(ptr - fs->buffer_start);
- is_simple = 1;
+ is_simple = true;
for(;;)
{
@@ -1765,12 +1786,12 @@ force_string:
elem = (CvFileNode*)cvSeqPush( node->data.seq, 0 );
}
-
+ CV_Assert(elem);
ptr = icvYMLSkipSpaces( fs, ptr, indent + 1, INT_MAX );
ptr = icvYMLParseValue( fs, ptr, elem, struct_flags, indent + 1 );
if( CV_NODE_IS_MAP(struct_flags) )
elem->tag |= CV_NODE_NAMED;
- is_simple &= !CV_NODE_IS_COLLECTION(elem->tag);
+ is_simple = is_simple && !CV_NODE_IS_COLLECTION(elem->tag);
ptr = icvYMLSkipSpaces( fs, ptr, 0, INT_MAX );
if( ptr - fs->buffer_start != indent )
@@ -2342,7 +2363,8 @@ static char* icvXMLParseBase64(CvFileStorage* fs, char* ptr, CvFileNode * node)
beg = end;
icvXMLGetMultilineStringContent( fs, beg, beg, end );
}
- if ( !base64::base64_valid(base64_buffer.data(), 0U, base64_buffer.size()) )
+ if ( base64_buffer.empty() ||
+ !base64::base64_valid(base64_buffer.data(), 0U, base64_buffer.size()) )
CV_PARSE_ERROR( "Invalid Base64 data." );
/* alloc buffer for all decoded data(include header) */
@@ -2389,7 +2411,7 @@ icvXMLParseValue( CvFileStorage* fs, char* ptr, CvFileNode* node,
int value_type CV_DEFAULT(CV_NODE_NONE))
{
CvFileNode *elem = node;
- int have_space = 1, is_simple = 1;
+ bool have_space = true, is_simple = true;
int is_user_type = CV_NODE_IS_USER(value_type);
memset( node, 0, sizeof(*node) );
@@ -2403,7 +2425,7 @@ icvXMLParseValue( CvFileStorage* fs, char* ptr, CvFileNode* node,
if( cv_isspace(c) || c == '\0' || (c == '<' && ptr[1] == '!' && ptr[2] == '-') )
{
ptr = icvXMLSkipSpaces( fs, ptr, 0 );
- have_space = 1;
+ have_space = true;
c = *ptr;
}
@@ -2469,7 +2491,7 @@ icvXMLParseValue( CvFileStorage* fs, char* ptr, CvFileNode* node,
elem = (CvFileNode*)cvSeqPush( node->data.seq, 0 );
else
elem = cvGetFileNode( fs, node, key, 1 );
-
+ CV_Assert(elem);
if (!is_binary_string)
ptr = icvXMLParseValue( fs, ptr, elem, elem_type);
else {
@@ -2480,12 +2502,12 @@ icvXMLParseValue( CvFileStorage* fs, char* ptr, CvFileNode* node,
if( !is_noname )
elem->tag |= CV_NODE_NAMED;
- is_simple &= !CV_NODE_IS_COLLECTION(elem->tag);
+ is_simple = is_simple && !CV_NODE_IS_COLLECTION(elem->tag);
elem->info = info;
ptr = icvXMLParseTag( fs, ptr, &key2, &list, &tag_type );
if( tag_type != CV_XML_CLOSING_TAG || key2 != key )
CV_PARSE_ERROR( "Mismatched closing tag" );
- have_space = 1;
+ have_space = true;
}
else
{
@@ -2534,7 +2556,7 @@ icvXMLParseValue( CvFileStorage* fs, char* ptr, CvFileNode* node,
else
{
// string
- char buf[CV_FS_MAX_LEN+16];
+ char buf[CV_FS_MAX_LEN+16] = {0};
int i = 0, len, is_quoted = 0;
elem->tag = CV_NODE_STRING;
if( c == '\"' )
@@ -2617,7 +2639,7 @@ icvXMLParseValue( CvFileStorage* fs, char* ptr, CvFileNode* node,
if( !CV_NODE_IS_COLLECTION(value_type) && value_type != CV_NODE_NONE )
break;
- have_space = 0;
+ have_space = false;
}
}
@@ -2695,6 +2717,7 @@ icvXMLParseTag( CvFileStorage* fs, char* ptr, CvStringHashNode** _tag,
while( cv_isalnum(c) || c == '_' || c == '-' );
attrname = cvGetHashedKey( fs, ptr, (int)(endptr - ptr), 1 );
+ CV_Assert(attrname);
ptr = endptr;
if( !tagname )
@@ -2827,6 +2850,7 @@ icvXMLParse( CvFileStorage* fs )
CvFileNode* root_node;
ptr = icvXMLParseTag( fs, ptr, &key, &list, &tag_type );
if( tag_type != CV_XML_OPENING_TAG ||
+ !key ||
strcmp(key->str.ptr,"opencv_storage") != 0 )
CV_PARSE_ERROR( "<opencv_storage> tag is missing" );
@@ -3641,7 +3665,6 @@ static char* icvJSONParseValue( CvFileStorage* fs, char* ptr, CvFileNode* node )
{
CV_PARSE_ERROR( "Unrecognized value" );
}
- ptr++;
}
return ptr;
@@ -3652,6 +3675,9 @@ static char* icvJSONParseMap( CvFileStorage* fs, char* ptr, CvFileNode* node );
static char* icvJSONParseSeq( CvFileStorage* fs, char* ptr, CvFileNode* node )
{
+ if (!ptr)
+ CV_PARSE_ERROR( "ptr is NULL" );
+
if ( *ptr != '[' )
CV_PARSE_ERROR( "'[' - left-brace of seq is missing" );
else
@@ -3690,6 +3716,9 @@ static char* icvJSONParseSeq( CvFileStorage* fs, char* ptr, CvFileNode* node )
CV_PARSE_ERROR( "Unexpected character" );
}
+ if (!ptr)
+ CV_PARSE_ERROR("ptr is NULL");
+
if ( *ptr != ']' )
CV_PARSE_ERROR( "']' - right-brace of seq is missing" );
else
@@ -3700,6 +3729,9 @@ static char* icvJSONParseSeq( CvFileStorage* fs, char* ptr, CvFileNode* node )
static char* icvJSONParseMap( CvFileStorage* fs, char* ptr, CvFileNode* node )
{
+ if (!ptr)
+ CV_PARSE_ERROR("ptr is NULL");
+
if ( *ptr != '{' )
CV_PARSE_ERROR( "'{' - left-brace of map is missing" );
else
@@ -3718,6 +3750,8 @@ static char* icvJSONParseMap( CvFileStorage* fs, char* ptr, CvFileNode* node )
{
CvFileNode* child = 0;
ptr = icvJSONParseKey( fs, ptr, node, &child );
+ if ( ptr == 0 || fs->dummy_eof )
+ break;
ptr = icvJSONSkipSpaces( fs, ptr );
if ( ptr == 0 || fs->dummy_eof )
break;
@@ -3746,6 +3780,7 @@ static char* icvJSONParseMap( CvFileStorage* fs, char* ptr, CvFileNode* node )
ptr = icvJSONParseMap( fs, ptr, child );
else
ptr = icvJSONParseValue( fs, ptr, child );
+ child->tag |= CV_NODE_NAMED;
}
}
@@ -3761,6 +3796,9 @@ static char* icvJSONParseMap( CvFileStorage* fs, char* ptr, CvFileNode* node )
CV_PARSE_ERROR( "Unexpected character" );
}
+ if (!ptr)
+ CV_PARSE_ERROR("ptr is NULL");
+
if ( *ptr != '}' )
CV_PARSE_ERROR( "'}' - right-brace of map is missing" );
else
@@ -4025,7 +4063,14 @@ static void
icvJSONWriteReal( CvFileStorage* fs, const char* key, double value )
{
char buf[128];
- icvJSONWrite( fs, key, icvDoubleToString( buf, value ));
+ size_t len = strlen( icvDoubleToString( buf, value ) );
+ if( len > 0 && buf[len-1] == '.' )
+ {
+ // append zero if string ends with decimal place to match JSON standard
+ buf[len] = '0';
+ buf[len+1] = '\0';
+ }
+ icvJSONWrite( fs, key, buf );
}
@@ -4160,6 +4205,7 @@ cvOpenFileStorage( const char* query, CvMemStorage* dststorage, int flags, const
CV_Error( CV_StsBadFlag, "CV_STORAGE_APPEND and CV_STORAGE_MEMORY are not currently compatible" );
fs = (CvFileStorage*)cvAlloc( sizeof(*fs) );
+ CV_Assert(fs);
memset( fs, 0, sizeof(*fs));
fs->memstorage = cvCreateMemStorage( default_block_size );
@@ -4224,11 +4270,25 @@ cvOpenFileStorage( const char* query, CvMemStorage* dststorage, int flags, const
if( fmt == CV_STORAGE_FORMAT_AUTO && filename )
{
- const char* dot_pos = strrchr( filename, '.' );
+ const char* dot_pos = NULL;
+ const char* dot_pos2 = NULL;
+ // like strrchr() implementation, but save two last positions simultaneously
+ for (const char* pos = filename; pos[0] != 0; pos++)
+ {
+ if (pos[0] == '.')
+ {
+ dot_pos2 = dot_pos;
+ dot_pos = pos;
+ }
+ }
+ if (cv_strcasecmp(dot_pos, ".gz") && dot_pos2 != NULL)
+ {
+ dot_pos = dot_pos2;
+ }
fs->fmt
- = cv_strcasecmp( dot_pos, ".xml" )
+ = (cv_strcasecmp(dot_pos, ".xml") || cv_strcasecmp(dot_pos, ".xml.gz"))
? CV_STORAGE_FORMAT_XML
- : cv_strcasecmp( dot_pos, ".json" )
+ : (cv_strcasecmp(dot_pos, ".json") || cv_strcasecmp(dot_pos, ".json.gz"))
? CV_STORAGE_FORMAT_JSON
: CV_STORAGE_FORMAT_YAML
;
@@ -4324,6 +4384,7 @@ cvOpenFileStorage( const char* query, CvMemStorage* dststorage, int flags, const
}
icvCloseFile( fs );
fs->file = fopen( fs->filename, "r+t" );
+ CV_Assert(fs->file);
fseek( fs->file, last_occurence, SEEK_SET );
// replace the last "</opencv_storage>" with " <!-- resumed -->", which has the same length
icvPuts( fs, " <!-- resumed -->" );
@@ -4377,6 +4438,7 @@ cvOpenFileStorage( const char* query, CvMemStorage* dststorage, int flags, const
{
icvCloseFile( fs );
fs->file = fopen( fs->filename, "r+t" );
+ CV_Assert(fs->file);
fseek( fs->file, roffset, SEEK_END );
fputs( ",", fs->file );
}
@@ -4829,6 +4891,17 @@ cvWriteRawData( CvFileStorage* fs, const void* _data, int len, const char* dt )
}
else
{
+ if( elem_type == CV_32F || elem_type == CV_64F )
+ {
+ size_t buf_len = strlen(ptr);
+ if( buf_len > 0 && ptr[buf_len-1] == '.' )
+ {
+ // append zero if CV_32F or CV_64F string ends with decimal place to match JSON standard
+ // ptr will point to buf, so can write to buf given ptr is const
+ buf[buf_len] = '0';
+ buf[buf_len+1] = '\0';
+ }
+ }
icvJSONWrite( fs, 0, ptr );
}
}
@@ -4876,7 +4949,7 @@ cvReadRawDataSlice( const CvFileStorage* fs, CvSeqReader* reader,
{
char* data0 = (char*)_data;
int fmt_pairs[CV_FS_MAX_FMT_PAIRS*2], k = 0, fmt_pair_count;
- int i = 0, offset = 0, count = 0;
+ int i = 0, count = 0;
CV_CHECK_FILE_STORAGE( fs );
@@ -4887,9 +4960,11 @@ cvReadRawDataSlice( const CvFileStorage* fs, CvSeqReader* reader,
CV_Error( CV_StsBadSize, "The readed sequence is a scalar, thus len must be 1" );
fmt_pair_count = icvDecodeFormat( dt, fmt_pairs, CV_FS_MAX_FMT_PAIRS );
+ size_t step = ::icvCalcStructSize(dt, 0);
for(;;)
{
+ int offset = 0;
for( k = 0; k < fmt_pair_count; k++ )
{
int elem_type = fmt_pairs[k*2+1];
@@ -5007,6 +5082,7 @@ cvReadRawDataSlice( const CvFileStorage* fs, CvSeqReader* reader,
offset = (int)(data - data0);
}
+ data0 += step;
}
end_loop:
@@ -5282,7 +5358,7 @@ icvReadMatND( CvFileStorage* fs, CvFileNode* node )
const char* dt;
CvFileNode* data;
CvFileNode* sizes_node;
- int sizes[CV_MAX_DIM], dims, elem_type;
+ int sizes[CV_MAX_DIM] = {0}, dims, elem_type;
int i, total_size;
sizes_node = cvGetFileNodeByName( fs, node, "sizes" );
@@ -5307,7 +5383,10 @@ icvReadMatND( CvFileStorage* fs, CvFileNode* node )
for( total_size = CV_MAT_CN(elem_type), i = 0; i < dims; i++ )
+ {
+ CV_Assert(sizes[i]);
total_size *= sizes[i];
+ }
int nelems = icvFileNodeSeqLen( data );
@@ -5447,7 +5526,7 @@ icvReadSparseMat( CvFileStorage* fs, CvFileNode* node )
dims = CV_NODE_IS_SEQ(sizes_node->tag) ? sizes_node->data.seq->total :
CV_NODE_IS_INT(sizes_node->tag) ? 1 : -1;
- if( dims <= 0 || dims > CV_MAX_DIM_HEAP )
+ if( dims <= 0 || dims > CV_MAX_DIM)
CV_Error( CV_StsParseError, "Could not determine sparse matrix dimensionality" );
cvReadRawData( fs, sizes_node, sizes, "i" );
@@ -5544,6 +5623,7 @@ icvWriteImage( CvFileStorage* fs, const char* name,
}
depth = IPL2CV_DEPTH(image->depth);
+ CV_Assert(depth < 9);
sprintf( dt_buf, "%d%c", image->nChannels, icvTypeSymbol[depth] );
dt = dt_buf + (dt_buf[2] == '\0' && dt_buf[0] == '1');
cvWriteString( fs, "dt", dt, 0 );
@@ -5586,7 +5666,7 @@ icvReadImage( CvFileStorage* fs, CvFileNode* node )
elem_type = icvDecodeSimpleFormat( dt );
data_order = cvReadStringByName( fs, node, "layout", "interleaved" );
- if( strcmp( data_order, "interleaved" ) != 0 )
+ if( !data_order || strcmp( data_order, "interleaved" ) != 0 )
CV_Error( CV_StsError, "Only interleaved images can be read" );
data = cvGetFileNodeByName( fs, node, "data" );
@@ -5942,6 +6022,7 @@ icvReadSeq( CvFileStorage* fs, CvFileNode* node )
if( header_node )
{
+ CV_Assert(header_dt);
cvReadRawData( fs, header_node, (char*)seq + sizeof(CvSeq), header_dt );
}
else if( rect_node )
@@ -6014,6 +6095,7 @@ icvReadSeqTree( CvFileStorage* fs, CvFileNode* node )
CvSeq* seq;
int level;
seq = (CvSeq*)cvRead( fs, elem );
+ CV_Assert(seq);
level = cvReadIntByName( fs, elem, "level", -1 );
if( level < 0 )
CV_Error( CV_StsParseError, "All the sequence tree nodes should contain \"level\" field" );
@@ -6318,7 +6400,10 @@ icvReadGraph( CvFileStorage* fs, CvFileNode* node )
graph = cvCreateGraph( flags, header_size, vtx_size, edge_size, fs->dststorage );
if( header_node )
+ {
+ CV_Assert(header_dt);
cvReadRawData( fs, header_node, (char*)graph + sizeof(CvGraph), header_dt );
+ }
read_buf_size = MAX( src_vtx_size*3, 1 << 16 );
read_buf_size = MAX( src_edge_size*3, read_buf_size );
@@ -6706,6 +6791,7 @@ cvLoad( const char* filename, CvMemStorage* memstorage,
CvSeqReader reader;
node = (CvFileNode*)cvGetSeqElem( (*fs)->roots, k );
+ CV_Assert(node != NULL);
if( !CV_NODE_IS_MAP( node->tag ))
return 0;
seq = node->data.seq;
@@ -6848,9 +6934,15 @@ FileNode FileStorage::root(int streamidx) const
return isOpened() ? FileNode(fs, cvGetRootFileNode(fs, streamidx)) : FileNode();
}
+int FileStorage::getFormat() const
+{
+ CV_Assert(!fs.empty());
+ return fs->fmt & FORMAT_MASK;
+}
+
FileStorage& operator << (FileStorage& fs, const String& str)
{
- CV_INSTRUMENT_REGION()
+ CV_TRACE_REGION_VERBOSE();
enum { NAME_EXPECTED = FileStorage::NAME_EXPECTED,
VALUE_EXPECTED = FileStorage::VALUE_EXPECTED,
@@ -6986,17 +7078,20 @@ void* FileNode::readObj() const
return cvRead( (CvFileStorage*)fs, (CvFileNode*)node );
}
+static const FileNodeIterator::SeqReader emptyReader = {0, 0, 0, 0, 0, 0, 0, 0};
+
FileNodeIterator::FileNodeIterator()
{
fs = 0;
container = 0;
- reader.ptr = 0;
+ reader = emptyReader;
remaining = 0;
}
FileNodeIterator::FileNodeIterator(const CvFileStorage* _fs,
const CvFileNode* _node, size_t _ofs)
{
+ reader = emptyReader;
if( _fs && _node && CV_NODE_TYPE(_node->tag) != CV_NODE_NONE )
{
int node_type = _node->tag & FileNode::TYPE_MASK;
@@ -7019,7 +7114,6 @@ FileNodeIterator::FileNodeIterator(const CvFileStorage* _fs,
{
fs = 0;
container = 0;
- reader.ptr = 0;
remaining = 0;
}
}
@@ -7245,14 +7339,7 @@ void write(FileStorage& fs, const String& objname, const std::vector<KeyPoint>&
int i, npoints = (int)keypoints.size();
for( i = 0; i < npoints; i++ )
{
- const KeyPoint& kpt = keypoints[i];
- cv::write(fs, kpt.pt.x);
- cv::write(fs, kpt.pt.y);
- cv::write(fs, kpt.size);
- cv::write(fs, kpt.angle);
- cv::write(fs, kpt.response);
- cv::write(fs, kpt.octave);
- cv::write(fs, kpt.class_id);
+ write(fs, keypoints[i]);
}
}
@@ -7277,11 +7364,7 @@ void write(FileStorage& fs, const String& objname, const std::vector<DMatch>& ma
int i, n = (int)matches.size();
for( i = 0; i < n; i++ )
{
- const DMatch& m = matches[i];
- cv::write(fs, m.queryIdx);
- cv::write(fs, m.trainIdx);
- cv::write(fs, m.imgIdx);
- cv::write(fs, m.distance);
+ write(fs, matches[i]);
}
}
@@ -7311,22 +7394,21 @@ size_t FileNode::size() const
void read(const FileNode& node, int& value, int default_value)
{
value = !node.node ? default_value :
- CV_NODE_IS_INT(node.node->tag) ? node.node->data.i :
- CV_NODE_IS_REAL(node.node->tag) ? cvRound(node.node->data.f) : 0x7fffffff;
+ CV_NODE_IS_INT(node.node->tag) ? node.node->data.i : std::numeric_limits<int>::max();
}
void read(const FileNode& node, float& value, float default_value)
{
value = !node.node ? default_value :
CV_NODE_IS_INT(node.node->tag) ? (float)node.node->data.i :
- CV_NODE_IS_REAL(node.node->tag) ? (float)node.node->data.f : 1e30f;
+ CV_NODE_IS_REAL(node.node->tag) ? saturate_cast<float>(node.node->data.f) : std::numeric_limits<float>::max();
}
void read(const FileNode& node, double& value, double default_value)
{
value = !node.node ? default_value :
CV_NODE_IS_INT(node.node->tag) ? (double)node.node->data.i :
- CV_NODE_IS_REAL(node.node->tag) ? node.node->data.f : 1e300;
+ CV_NODE_IS_REAL(node.node->tag) ? node.node->data.f : std::numeric_limits<double>::max();
}
void read(const FileNode& node, String& value, const String& default_value)
@@ -7334,6 +7416,11 @@ void read(const FileNode& node, String& value, const String& default_value)
value = !node.node ? default_value : CV_NODE_IS_STRING(node.node->tag) ? String(node.node->data.str.ptr) : String();
}
+void read(const FileNode& node, std::string& value, const std::string& default_value)
+{
+ value = !node.node ? default_value : CV_NODE_IS_STRING(node.node->tag) ? std::string(node.node->data.str.ptr) : default_value;
+}
+
}
@@ -7659,7 +7746,7 @@ std::string base64::make_base64_header(const char * dt)
bool base64::read_base64_header(std::vector<char> const & header, std::string & dt)
{
std::istringstream iss(header.data());
- return static_cast<bool>(iss >> dt);
+ return !!(iss >> dt);//the "std::basic_ios::operator bool" differs between C++98 and C++11. The "double not" syntax is portable and covers both cases with equivalent meaning
}
/****************************************************************************
@@ -7893,13 +7980,13 @@ class base64::RawDataToBinaryConvertor
{
public:
- RawDataToBinaryConvertor(const void* src, int len, const char* dt)
+ RawDataToBinaryConvertor(const void* src, int len, const std::string & dt)
: beg(reinterpret_cast<const uchar *>(src))
, cur(0)
, end(0)
{
CV_Assert(src);
- CV_Assert(dt);
+ CV_Assert(!dt.empty());
CV_Assert(len > 0);
/* calc step and to_binary_funcs */
@@ -7908,7 +7995,7 @@ public:
end = beg;
cur = beg;
- step = ::icvCalcStructSize(dt, 0);
+ step = ::icvCalcStructSize(dt.c_str(), 0);
end = beg + step * static_cast<size_t>(len);
}
@@ -7940,7 +8027,7 @@ private:
};
private:
- void make_to_binary_funcs(const char* dt)
+ void make_to_binary_funcs(const std::string &dt)
{
size_t cnt = 0;
size_t offset = 0;
@@ -8202,10 +8289,7 @@ base64::Base64Writer::Base64Writer(::CvFileStorage * fs)
void base64::Base64Writer::write(const void* _data, size_t len, const char* dt)
{
check_dt(dt);
-
- RawDataToBinaryConvertor convertor(
- _data, static_cast<int>(len), data_type_string.c_str()
- );
+ RawDataToBinaryConvertor convertor(_data, static_cast<int>(len), data_type_string);
emitter->write(convertor);
}
diff --git a/modules/core/src/precomp.hpp b/modules/core/src/precomp.hpp
index be30664..255a8ad 100644
--- a/modules/core/src/precomp.hpp
+++ b/modules/core/src/precomp.hpp
@@ -63,6 +63,7 @@
#include <float.h>
#include <limits.h>
#include <math.h>
+#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -75,7 +76,7 @@
#include <cstring>
#include <cassert>
-#define USE_SSE2 (cv::checkHardwareSupport(CV_CPU_SSE))
+#define USE_SSE2 (cv::checkHardwareSupport(CV_CPU_SSE2))
#define USE_SSE4_2 (cv::checkHardwareSupport(CV_CPU_SSE4_2))
#define USE_AVX (cv::checkHardwareSupport(CV_CPU_AVX))
#define USE_AVX2 (cv::checkHardwareSupport(CV_CPU_AVX2))
@@ -135,7 +136,6 @@ typedef void (*BinaryFuncC)(const uchar* src1, size_t step1,
uchar* dst, size_t step, int width, int height,
void*);
-BinaryFunc getConvertFuncFp16(int ddepth);
BinaryFunc getConvertFunc(int sdepth, int ddepth);
BinaryFunc getCopyMaskFunc(size_t esz);
@@ -148,10 +148,6 @@ BinaryFunc getCopyMaskFunc(size_t esz);
/* maximal average node_count/hash_size ratio beyond which hash table is resized */
#define CV_SPARSE_HASH_RATIO 3
-#if defined WIN32 || defined _WIN32
-void deleteThreadAllocData();
-#endif
-
inline Size getContinuousSize_( int flags, int cols, int rows, int widthScale )
{
int64 sz = (int64)cols * rows * widthScale;
@@ -272,8 +268,8 @@ struct CoreTLSData
RNG rng;
//#ifdef HAVE_OPENCL
- int device;
- ocl::Queue oclQueue;
+ int device; // device index of an array of devices in a context, see also Device::getDefault
+ ocl::Queue oclQueue; // the queue used for running a kernel, see also getQueue, Kernel::run
int useOpenCL; // 1 - use, 0 - do not use, -1 - auto/not initialized
//#endif
int useIPP; // 1 - use, 0 - do not use, -1 - auto/not initialized
@@ -288,7 +284,7 @@ struct CoreTLSData
TLSData<CoreTLSData>& getCoreTlsData();
#if defined(BUILD_SHARED_LIBS)
-#if defined WIN32 || defined _WIN32 || defined WINCE
+#if defined _WIN32 || defined WINCE
#define CL_RUNTIME_EXPORT __declspec(dllexport)
#elif defined __GNUC__ && __GNUC__ >= 4
#define CL_RUNTIME_EXPORT __attribute__ ((visibility ("default")))
@@ -299,6 +295,12 @@ TLSData<CoreTLSData>& getCoreTlsData();
#define CL_RUNTIME_EXPORT
#endif
+namespace utils {
+bool getConfigurationParameterBool(const char* name, bool defaultValue);
+size_t getConfigurationParameterSizeT(const char* name, size_t defaultValue);
+cv::String getConfigurationParameterString(const char* name, const char* defaultValue);
+}
+
extern bool __termination; // skip some cleanups, because process is terminating
// (for example, if ExitProcess() was already called)
@@ -318,6 +320,8 @@ cv::Mutex& getInitializationMutex();
#define CV_SINGLETON_LAZY_INIT(TYPE, INITIALIZER) CV_SINGLETON_LAZY_INIT_(TYPE, INITIALIZER, instance)
#define CV_SINGLETON_LAZY_INIT_REF(TYPE, INITIALIZER) CV_SINGLETON_LAZY_INIT_(TYPE, INITIALIZER, *instance)
+int cv_snprintf(char* buf, int len, const char* fmt, ...);
+int cv_vsnprintf(char* buf, int len, const char* fmt, va_list args);
}
#endif /*_CXCORE_INTERNAL_H_*/
diff --git a/modules/core/src/rand.cpp b/modules/core/src/rand.cpp
index 094cde9..08af973 100644
--- a/modules/core/src/rand.cpp
+++ b/modules/core/src/rand.cpp
@@ -48,14 +48,12 @@
#include "precomp.hpp"
-#if defined WIN32 || defined WINCE
+#if defined _WIN32 || defined WINCE
#include <windows.h>
#undef small
#undef min
#undef max
#undef abs
-#else
- #include <pthread.h>
#endif
#if defined __SSE2__ || (defined _M_IX86_FP && 2 == _M_IX86_FP)
@@ -500,7 +498,9 @@ void RNG::fill( InputOutputArray _mat, int disttype,
Mat mat = _mat.getMat(), _param1 = _param1arg.getMat(), _param2 = _param2arg.getMat();
int depth = mat.depth(), cn = mat.channels();
AutoBuffer<double> _parambuf;
- int j, k, fast_int_mode = 0, smallFlag = 1;
+ int j, k;
+ bool fast_int_mode = false;
+ bool smallFlag = true;
RandFunc func = 0;
RandnScaleFunc scaleFunc = 0;
@@ -553,7 +553,7 @@ void RNG::fill( InputOutputArray _mat, int disttype,
if( depth <= CV_32S )
{
ip = (Vec2i*)(parambuf + cn*2);
- for( j = 0, fast_int_mode = 1; j < cn; j++ )
+ for( j = 0, fast_int_mode = true; j < cn; j++ )
{
double a = std::min(p1[j], p2[j]);
double b = std::max(p1[j], p2[j]);
@@ -568,9 +568,9 @@ void RNG::fill( InputOutputArray _mat, int disttype,
int idiff = ip[j][0] = cvFloor(b) - ip[j][1] - 1;
double diff = b - a;
- fast_int_mode &= diff <= 4294967296. && (idiff & (idiff+1)) == 0;
+ fast_int_mode = fast_int_mode && diff <= 4294967296. && (idiff & (idiff+1)) == 0;
if( fast_int_mode )
- smallFlag &= idiff <= 255;
+ smallFlag = smallFlag && (idiff <= 255);
else
{
if( diff > INT_MAX )
@@ -596,7 +596,7 @@ void RNG::fill( InputOutputArray _mat, int disttype,
}
}
- func = randTab[fast_int_mode][depth];
+ func = randTab[fast_int_mode ? 1 : 0][depth];
}
else
{
@@ -687,9 +687,9 @@ void RNG::fill( InputOutputArray _mat, int disttype,
buf.allocate(blockSize*cn*4);
param = (uchar*)(double*)buf;
- if( ip )
+ if( depth <= CV_32S )
{
- if( ds )
+ if( !fast_int_mode )
{
DivStruct* p = (DivStruct*)param;
for( j = 0; j < blockSize*cn; j += cn )
@@ -704,7 +704,7 @@ void RNG::fill( InputOutputArray _mat, int disttype,
p[j + k] = ip[k];
}
}
- else if( fp )
+ else if( depth == CV_32F )
{
Vec2f* p = (Vec2f*)param;
for( j = 0; j < blockSize*cn; j += cn )
@@ -732,7 +732,7 @@ void RNG::fill( InputOutputArray _mat, int disttype,
int len = std::min(total - j, blockSize);
if( disttype == CV_RAND_UNI )
- func( ptr, len*cn, &state, param, smallFlag != 0 );
+ func( ptr, len*cn, &state, param, smallFlag );
else
{
randn_0_1_32f(nbuf, len*cn, &state);
diff --git a/modules/core/src/softfloat.cpp b/modules/core/src/softfloat.cpp
new file mode 100644
index 0000000..ac39ee8
--- /dev/null
+++ b/modules/core/src/softfloat.cpp
@@ -0,0 +1,3945 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+// This file is based on files from package issued with the following license:
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3c, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
+University of California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include "precomp.hpp"
+
+#include "opencv2/core/softfloat.hpp"
+
+namespace cv
+{
+
+/*----------------------------------------------------------------------------
+| Software floating-point underflow tininess-detection mode.
+*----------------------------------------------------------------------------*/
+enum {
+ tininess_beforeRounding = 0,
+ tininess_afterRounding = 1
+};
+//fixed to make softfloat code stateless
+static const uint_fast8_t globalDetectTininess = tininess_afterRounding;
+
+/*----------------------------------------------------------------------------
+| Software floating-point exception flags.
+*----------------------------------------------------------------------------*/
+enum {
+ flag_inexact = 1,
+ flag_underflow = 2,
+ flag_overflow = 4,
+ flag_infinite = 8,
+ flag_invalid = 16
+};
+
+// Disabled to make softfloat code stateless
+// This function may be changed in the future for better error handling
+static inline void raiseFlags( uint_fast8_t /* flags */)
+{
+ //exceptionFlags |= flags;
+}
+
+/*----------------------------------------------------------------------------
+| Software floating-point rounding mode.
+*----------------------------------------------------------------------------*/
+enum {
+ round_near_even = 0,
+ round_minMag = 1,
+ round_min = 2,
+ round_max = 3,
+ round_near_maxMag = 4,
+ round_odd = 5
+};
+
+//fixed to make softfloat code stateless
+static const uint_fast8_t globalRoundingMode = round_near_even;
+
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+
+#define signF32UI( a ) (((uint32_t) (a)>>31) != 0)
+#define expF32UI( a ) ((int_fast16_t) ((a)>>23) & 0xFF)
+#define fracF32UI( a ) ((a) & 0x007FFFFF)
+#define packToF32UI( sign, exp, sig ) (((uint32_t) (sign)<<31) + ((uint32_t) (exp)<<23) + (sig))
+
+#define isNaNF32UI( a ) (((~(a) & 0x7F800000) == 0) && ((a) & 0x007FFFFF))
+
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+
+#define signF64UI( a ) (((uint64_t) (a)>>63) != 0)
+#define expF64UI( a ) ((int_fast16_t) ((a)>>52) & 0x7FF)
+#define fracF64UI( a ) ((a) & UINT64_C( 0x000FFFFFFFFFFFFF ))
+#define packToF64UI( sign, exp, sig ) ((uint64_t) (((uint_fast64_t) (sign)<<63) + ((uint_fast64_t) (exp)<<52) + (sig)))
+
+#define isNaNF64UI( a ) (((~(a) & UINT64_C( 0x7FF0000000000000 )) == 0) && ((a) & UINT64_C( 0x000FFFFFFFFFFFFF )))
+
+/*----------------------------------------------------------------------------
+| Types used to pass 32-bit and 64-bit floating-point
+| arguments and results to/from functions. These types must be exactly
+| 32 bits and 64 bits in size, respectively. Where a
+| platform has "native" support for IEEE-Standard floating-point formats,
+| the types below may, if desired, be defined as aliases for the native types
+| (typically 'float' and 'double').
+*----------------------------------------------------------------------------*/
+typedef softfloat float32_t;
+typedef softdouble float64_t;
+
+/*----------------------------------------------------------------------------
+| Integer-to-floating-point conversion routines.
+*----------------------------------------------------------------------------*/
+static float32_t ui32_to_f32( uint32_t );
+static float64_t ui32_to_f64( uint32_t );
+static float32_t ui64_to_f32( uint64_t );
+static float64_t ui64_to_f64( uint64_t );
+static float32_t i32_to_f32( int32_t );
+static float64_t i32_to_f64( int32_t );
+static float32_t i64_to_f32( int64_t );
+static float64_t i64_to_f64( int64_t );
+
+/*----------------------------------------------------------------------------
+| 32-bit (single-precision) floating-point operations.
+*----------------------------------------------------------------------------*/
+static int_fast32_t f32_to_i32( float32_t, uint_fast8_t, bool );
+static int_fast32_t f32_to_i32_r_minMag( float32_t, bool );
+static float64_t f32_to_f64( float32_t );
+static float32_t f32_roundToInt( float32_t, uint_fast8_t, bool );
+static float32_t f32_add( float32_t, float32_t );
+static float32_t f32_sub( float32_t, float32_t );
+static float32_t f32_mul( float32_t, float32_t );
+static float32_t f32_mulAdd( float32_t, float32_t, float32_t );
+static float32_t f32_div( float32_t, float32_t );
+static float32_t f32_rem( float32_t, float32_t );
+static float32_t f32_sqrt( float32_t );
+static bool f32_eq( float32_t, float32_t );
+static bool f32_le( float32_t, float32_t );
+static bool f32_lt( float32_t, float32_t );
+
+/*----------------------------------------------------------------------------
+| 64-bit (double-precision) floating-point operations.
+*----------------------------------------------------------------------------*/
+static int_fast32_t f64_to_i32( float64_t, uint_fast8_t, bool );
+static int_fast32_t f64_to_i32_r_minMag( float64_t, bool );
+static float32_t f64_to_f32( float64_t );
+static float64_t f64_roundToInt( float64_t, uint_fast8_t, bool );
+static float64_t f64_add( float64_t, float64_t );
+static float64_t f64_sub( float64_t, float64_t );
+static float64_t f64_mul( float64_t, float64_t );
+static float64_t f64_mulAdd( float64_t, float64_t, float64_t );
+static float64_t f64_div( float64_t, float64_t );
+static float64_t f64_rem( float64_t, float64_t );
+static float64_t f64_sqrt( float64_t );
+static bool f64_eq( float64_t, float64_t );
+static bool f64_le( float64_t, float64_t );
+static bool f64_lt( float64_t, float64_t );
+
+/*----------------------------------------------------------------------------
+| Ported from OpenCV and added for usability
+*----------------------------------------------------------------------------*/
+
+static float32_t f32_powi( float32_t x, int y);
+static float64_t f64_powi( float64_t x, int y);
+
+static float32_t f32_exp( float32_t x);
+static float64_t f64_exp(float64_t x);
+static float32_t f32_log(float32_t x);
+static float64_t f64_log(float64_t x);
+static float32_t f32_cbrt(float32_t x);
+static float32_t f32_pow( float32_t x, float32_t y);
+static float64_t f64_pow( float64_t x, float64_t y);
+
+/*----------------------------------------------------------------------------
+| softfloat and softdouble methods and members
+*----------------------------------------------------------------------------*/
+
+softfloat::softfloat( const uint32_t a ) { *this = ui32_to_f32(a); }
+softfloat::softfloat( const uint64_t a ) { *this = ui64_to_f32(a); }
+softfloat::softfloat( const int32_t a ) { *this = i32_to_f32(a); }
+softfloat::softfloat( const int64_t a ) { *this = i64_to_f32(a); }
+
+softfloat::operator softdouble() const { return f32_to_f64(*this); }
+
+softfloat softfloat::operator + (const softfloat& a) const { return f32_add(*this, a); }
+softfloat softfloat::operator - (const softfloat& a) const { return f32_sub(*this, a); }
+softfloat softfloat::operator * (const softfloat& a) const { return f32_mul(*this, a); }
+softfloat softfloat::operator / (const softfloat& a) const { return f32_div(*this, a); }
+softfloat softfloat::operator % (const softfloat& a) const { return f32_rem(*this, a); }
+
+bool softfloat::operator == ( const softfloat& a ) const { return f32_eq(*this, a); }
+bool softfloat::operator != ( const softfloat& a ) const { return !f32_eq(*this, a); }
+bool softfloat::operator > ( const softfloat& a ) const { return f32_lt(a, *this); }
+bool softfloat::operator >= ( const softfloat& a ) const { return f32_le(a, *this); }
+bool softfloat::operator < ( const softfloat& a ) const { return f32_lt(*this, a); }
+bool softfloat::operator <= ( const softfloat& a ) const { return f32_le(*this, a); }
+
+softdouble::softdouble( const uint32_t a ) { *this = ui32_to_f64(a); }
+softdouble::softdouble( const uint64_t a ) { *this = ui64_to_f64(a); }
+softdouble::softdouble( const int32_t a ) { *this = i32_to_f64(a); }
+softdouble::softdouble( const int64_t a ) { *this = i64_to_f64(a); }
+
+}
+
+int cvTrunc(const cv::softfloat& a) { return cv::f32_to_i32_r_minMag(a, false); }
+int cvRound(const cv::softfloat& a) { return cv::f32_to_i32(a, cv::round_near_even, false); }
+int cvFloor(const cv::softfloat& a) { return cv::f32_to_i32(a, cv::round_min, false); }
+int cvCeil (const cv::softfloat& a) { return cv::f32_to_i32(a, cv::round_max, false); }
+
+int cvTrunc(const cv::softdouble& a) { return cv::f64_to_i32_r_minMag(a, false); }
+int cvRound(const cv::softdouble& a) { return cv::f64_to_i32(a, cv::round_near_even, false); }
+int cvFloor(const cv::softdouble& a) { return cv::f64_to_i32(a, cv::round_min, false); }
+int cvCeil (const cv::softdouble& a) { return cv::f64_to_i32(a, cv::round_max, false); }
+
+namespace cv
+{
+softdouble::operator softfloat() const { return f64_to_f32(*this); }
+
+softdouble softdouble::operator + (const softdouble& a) const { return f64_add(*this, a); }
+softdouble softdouble::operator - (const softdouble& a) const { return f64_sub(*this, a); }
+softdouble softdouble::operator * (const softdouble& a) const { return f64_mul(*this, a); }
+softdouble softdouble::operator / (const softdouble& a) const { return f64_div(*this, a); }
+softdouble softdouble::operator % (const softdouble& a) const { return f64_rem(*this, a); }
+
+bool softdouble::operator == (const softdouble& a) const { return f64_eq(*this, a); }
+bool softdouble::operator != (const softdouble& a) const { return !f64_eq(*this, a); }
+bool softdouble::operator > (const softdouble& a) const { return f64_lt(a, *this); }
+bool softdouble::operator >= (const softdouble& a) const { return f64_le(a, *this); }
+bool softdouble::operator < (const softdouble& a) const { return f64_lt(*this, a); }
+bool softdouble::operator <= (const softdouble& a) const { return f64_le(*this, a); }
+
+/*----------------------------------------------------------------------------
+| Overloads for math functions
+*----------------------------------------------------------------------------*/
+
+softfloat mulAdd( const softfloat& a, const softfloat& b, const softfloat & c) { return f32_mulAdd(a, b, c); }
+softdouble mulAdd( const softdouble& a, const softdouble& b, const softdouble& c) { return f64_mulAdd(a, b, c); }
+
+softfloat sqrt( const softfloat& a ) { return f32_sqrt(a); }
+softdouble sqrt( const softdouble& a ) { return f64_sqrt(a); }
+
+softfloat exp( const softfloat& a) { return f32_exp(a); }
+softdouble exp( const softdouble& a) { return f64_exp(a); }
+
+softfloat log( const softfloat& a ) { return f32_log(a); }
+softdouble log( const softdouble& a ) { return f64_log(a); }
+
+softfloat pow( const softfloat& a, const softfloat& b) { return f32_pow(a, b); }
+softdouble pow( const softdouble& a, const softdouble& b) { return f64_pow(a, b); }
+
+softfloat cbrt(const softfloat& a) { return f32_cbrt(a); }
+
+/*----------------------------------------------------------------------------
+| The values to return on conversions to 32-bit integer formats that raise an
+| invalid exception.
+*----------------------------------------------------------------------------*/
+#define ui32_fromPosOverflow 0xFFFFFFFF
+#define ui32_fromNegOverflow 0
+#define ui32_fromNaN 0xFFFFFFFF
+#define i32_fromPosOverflow 0x7FFFFFFF
+#define i32_fromNegOverflow (-0x7FFFFFFF - 1)
+#define i32_fromNaN 0x7FFFFFFF
+
+/*----------------------------------------------------------------------------
+| The values to return on conversions to 64-bit integer formats that raise an
+| invalid exception.
+*----------------------------------------------------------------------------*/
+#define ui64_fromPosOverflow UINT64_C( 0xFFFFFFFFFFFFFFFF )
+#define ui64_fromNegOverflow 0
+#define ui64_fromNaN UINT64_C( 0xFFFFFFFFFFFFFFFF )
+#define i64_fromPosOverflow UINT64_C( 0x7FFFFFFFFFFFFFFF )
+//fixed unsigned unary minus: -x == ~x + 1
+//#define i64_fromNegOverflow (-UINT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)
+#define i64_fromNegOverflow (~UINT64_C( 0x7FFFFFFFFFFFFFFF ) + 1 - 1)
+#define i64_fromNaN UINT64_C( 0x7FFFFFFFFFFFFFFF )
+
+/*----------------------------------------------------------------------------
+| "Common NaN" structure, used to transfer NaN representations from one format
+| to another.
+*----------------------------------------------------------------------------*/
+struct commonNaN {
+ bool sign;
+#ifndef WORDS_BIGENDIAN
+ uint64_t v0, v64;
+#else
+ uint64_t v64, v0;
+#endif
+};
+
+/*----------------------------------------------------------------------------
+| The bit pattern for a default generated 32-bit floating-point NaN.
+*----------------------------------------------------------------------------*/
+#define defaultNaNF32UI 0xFFC00000
+
+/*----------------------------------------------------------------------------
+| Returns true when 32-bit unsigned integer `uiA' has the bit pattern of a
+| 32-bit floating-point signaling NaN.
+| Note: This macro evaluates its argument more than once.
+*----------------------------------------------------------------------------*/
+#define softfloat_isSigNaNF32UI( uiA ) ((((uiA) & 0x7FC00000) == 0x7F800000) && ((uiA) & 0x003FFFFF))
+
+/*----------------------------------------------------------------------------
+| Assuming `uiA' has the bit pattern of a 32-bit floating-point NaN, converts
+| this NaN to the common NaN form, and stores the resulting common NaN at the
+| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
+| exception is raised.
+*----------------------------------------------------------------------------*/
+static void softfloat_f32UIToCommonNaN( uint_fast32_t uiA, struct commonNaN *zPtr );
+
+/*----------------------------------------------------------------------------
+| Converts the common NaN pointed to by `aPtr' into a 32-bit floating-point
+| NaN, and returns the bit pattern of this value as an unsigned integer.
+*----------------------------------------------------------------------------*/
+static uint_fast32_t softfloat_commonNaNToF32UI( const struct commonNaN *aPtr );
+
+/*----------------------------------------------------------------------------
+| Interpreting `uiA' and `uiB' as the bit patterns of two 32-bit floating-
+| point values, at least one of which is a NaN, returns the bit pattern of
+| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
+| signaling NaN, the invalid exception is raised.
+*----------------------------------------------------------------------------*/
+static uint_fast32_t softfloat_propagateNaNF32UI( uint_fast32_t uiA, uint_fast32_t uiB );
+
+/*----------------------------------------------------------------------------
+| The bit pattern for a default generated 64-bit floating-point NaN.
+*----------------------------------------------------------------------------*/
+#define defaultNaNF64UI UINT64_C( 0xFFF8000000000000 )
+
+/*----------------------------------------------------------------------------
+| Returns true when 64-bit unsigned integer `uiA' has the bit pattern of a
+| 64-bit floating-point signaling NaN.
+| Note: This macro evaluates its argument more than once.
+*----------------------------------------------------------------------------*/
+#define softfloat_isSigNaNF64UI( uiA ) \
+ ((((uiA) & UINT64_C( 0x7FF8000000000000 )) == UINT64_C( 0x7FF0000000000000 )) && \
+ ((uiA) & UINT64_C( 0x0007FFFFFFFFFFFF )))
+
+/*----------------------------------------------------------------------------
+| Assuming `uiA' has the bit pattern of a 64-bit floating-point NaN, converts
+| this NaN to the common NaN form, and stores the resulting common NaN at the
+| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
+| exception is raised.
+*----------------------------------------------------------------------------*/
+static void softfloat_f64UIToCommonNaN( uint_fast64_t uiA, struct commonNaN *zPtr );
+
+/*----------------------------------------------------------------------------
+| Converts the common NaN pointed to by `aPtr' into a 64-bit floating-point
+| NaN, and returns the bit pattern of this value as an unsigned integer.
+*----------------------------------------------------------------------------*/
+static uint_fast64_t softfloat_commonNaNToF64UI( const struct commonNaN *aPtr );
+
+/*----------------------------------------------------------------------------
+| Interpreting `uiA' and `uiB' as the bit patterns of two 64-bit floating-
+| point values, at least one of which is a NaN, returns the bit pattern of
+| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
+| signaling NaN, the invalid exception is raised.
+*----------------------------------------------------------------------------*/
+static uint_fast64_t softfloat_propagateNaNF64UI( uint_fast64_t uiA, uint_fast64_t uiB );
+
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+
+#ifndef WORDS_BIGENDIAN
+struct uint128 { uint64_t v0, v64; };
+struct uint64_extra { uint64_t extra, v; };
+struct uint128_extra { uint64_t extra; struct uint128 v; };
+#else
+struct uint128 { uint64_t v64, v0; };
+struct uint64_extra { uint64_t v, extra; };
+struct uint128_extra { struct uint128 v; uint64_t extra; };
+#endif
+
+/*----------------------------------------------------------------------------
+| These macros are used to isolate the differences in word order between big-
+| endian and little-endian platforms.
+*----------------------------------------------------------------------------*/
+#ifndef WORDS_BIGENDIAN
+#define wordIncr 1
+#define indexWord( total, n ) (n)
+#define indexWordHi( total ) ((total) - 1)
+#define indexWordLo( total ) 0
+#define indexMultiword( total, m, n ) (n)
+#define indexMultiwordHi( total, n ) ((total) - (n))
+#define indexMultiwordLo( total, n ) 0
+#define indexMultiwordHiBut( total, n ) (n)
+#define indexMultiwordLoBut( total, n ) 0
+#define INIT_UINTM4( v3, v2, v1, v0 ) { v0, v1, v2, v3 }
+#else
+#define wordIncr -1
+#define indexWord( total, n ) ((total) - 1 - (n))
+#define indexWordHi( total ) 0
+#define indexWordLo( total ) ((total) - 1)
+#define indexMultiword( total, m, n ) ((total) - 1 - (m))
+#define indexMultiwordHi( total, n ) 0
+#define indexMultiwordLo( total, n ) ((total) - (n))
+#define indexMultiwordHiBut( total, n ) 0
+#define indexMultiwordLoBut( total, n ) (n)
+#define INIT_UINTM4( v3, v2, v1, v0 ) { v3, v2, v1, v0 }
+#endif
+
+enum {
+ softfloat_mulAdd_subC = 1,
+ softfloat_mulAdd_subProd = 2
+};
+
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+static int_fast32_t softfloat_roundToI32( bool, uint_fast64_t, uint_fast8_t, bool );
+
+struct exp16_sig32 { int_fast16_t exp; uint_fast32_t sig; };
+static struct exp16_sig32 softfloat_normSubnormalF32Sig( uint_fast32_t );
+
+static float32_t softfloat_roundPackToF32( bool, int_fast16_t, uint_fast32_t );
+static float32_t softfloat_normRoundPackToF32( bool, int_fast16_t, uint_fast32_t );
+
+static float32_t softfloat_addMagsF32( uint_fast32_t, uint_fast32_t );
+static float32_t softfloat_subMagsF32( uint_fast32_t, uint_fast32_t );
+static float32_t softfloat_mulAddF32(uint_fast32_t, uint_fast32_t, uint_fast32_t, uint_fast8_t );
+
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+
+struct exp16_sig64 { int_fast16_t exp; uint_fast64_t sig; };
+static struct exp16_sig64 softfloat_normSubnormalF64Sig( uint_fast64_t );
+
+static float64_t softfloat_roundPackToF64( bool, int_fast16_t, uint_fast64_t );
+static float64_t softfloat_normRoundPackToF64( bool, int_fast16_t, uint_fast64_t );
+
+static float64_t softfloat_addMagsF64( uint_fast64_t, uint_fast64_t, bool );
+static float64_t softfloat_subMagsF64( uint_fast64_t, uint_fast64_t, bool );
+static float64_t softfloat_mulAddF64( uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast8_t );
+
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+| Shifts 'a' right by the number of bits given in 'dist', which must be in
+| the range 1 to 63. If any nonzero bits are shifted off, they are "jammed"
+| into the least-significant bit of the shifted value by setting the least-
+| significant bit to 1. This shifted-and-jammed value is returned.
+*----------------------------------------------------------------------------*/
+
+static inline uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t dist )
+{ return a>>dist | ((a & (((uint_fast64_t) 1<<dist) - 1)) != 0); }
+
+/*----------------------------------------------------------------------------
+| Shifts 'a' right by the number of bits given in 'dist', which must not
+| be zero. If any nonzero bits are shifted off, they are "jammed" into the
+| least-significant bit of the shifted value by setting the least-significant
+| bit to 1. This shifted-and-jammed value is returned.
+| The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
+| greater than 32, the result will be either 0 or 1, depending on whether 'a'
+| is zero or nonzero.
+*----------------------------------------------------------------------------*/
+
+static inline uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t dist )
+{
+ //fixed unsigned unary minus: -x == ~x + 1
+ return (dist < 31) ? a>>dist | ((uint32_t) (a<<((~dist + 1) & 31)) != 0) : (a != 0);
+}
+
+/*----------------------------------------------------------------------------
+| Shifts 'a' right by the number of bits given in 'dist', which must not
+| be zero. If any nonzero bits are shifted off, they are "jammed" into the
+| least-significant bit of the shifted value by setting the least-significant
+| bit to 1. This shifted-and-jammed value is returned.
+| The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
+| greater than 64, the result will be either 0 or 1, depending on whether 'a'
+| is zero or nonzero.
+*----------------------------------------------------------------------------*/
+static inline uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t dist )
+{
+ //fixed unsigned unary minus: -x == ~x + 1
+ return (dist < 63) ? a>>dist | ((uint64_t) (a<<((~dist + 1) & 63)) != 0) : (a != 0);
+}
+
+/*----------------------------------------------------------------------------
+| A constant table that translates an 8-bit unsigned integer (the array index)
+| into the number of leading 0 bits before the most-significant 1 of that
+| integer. For integer zero (index 0), the corresponding table element is 8.
+*----------------------------------------------------------------------------*/
+static const uint_least8_t softfloat_countLeadingZeros8[256] = {
+ 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/*----------------------------------------------------------------------------
+| Returns the number of leading 0 bits before the most-significant 1 bit of
+| 'a'. If 'a' is zero, 32 is returned.
+*----------------------------------------------------------------------------*/
+static inline uint_fast8_t softfloat_countLeadingZeros32( uint32_t a )
+{
+ uint_fast8_t count = 0;
+ if ( a < 0x10000 ) {
+ count = 16;
+ a <<= 16;
+ }
+ if ( a < 0x1000000 ) {
+ count += 8;
+ a <<= 8;
+ }
+ count += softfloat_countLeadingZeros8[a>>24];
+ return count;
+}
+
+/*----------------------------------------------------------------------------
+| Returns the number of leading 0 bits before the most-significant 1 bit of
+| 'a'. If 'a' is zero, 64 is returned.
+*----------------------------------------------------------------------------*/
+static uint_fast8_t softfloat_countLeadingZeros64( uint64_t a );
+
+/*----------------------------------------------------------------------------
+| Returns an approximation to the reciprocal of the number represented by 'a',
+| where 'a' is interpreted as an unsigned fixed-point number with one integer
+| bit and 31 fraction bits. The 'a' input must be "normalized", meaning that
+| its most-significant bit (bit 31) must be 1. Thus, if A is the value of
+| the fixed-point interpretation of 'a', then 1 <= A < 2. The returned value
+| is interpreted as a pure unsigned fraction, having no integer bits and 32
+| fraction bits. The approximation returned is never greater than the true
+| reciprocal 1/A, and it differs from the true reciprocal by at most 2.006 ulp
+| (units in the last place).
+*----------------------------------------------------------------------------*/
+#define softfloat_approxRecip32_1( a ) ((uint32_t) (UINT64_C( 0x7FFFFFFFFFFFFFFF ) / (uint32_t) (a)))
+
+/*----------------------------------------------------------------------------
+| Returns an approximation to the reciprocal of the square root of the number
+| represented by 'a', where 'a' is interpreted as an unsigned fixed-point
+| number either with one integer bit and 31 fraction bits or with two integer
+| bits and 30 fraction bits. The format of 'a' is determined by 'oddExpA',
+| which must be either 0 or 1. If 'oddExpA' is 1, 'a' is interpreted as
+| having one integer bit, and if 'oddExpA' is 0, 'a' is interpreted as having
+| two integer bits. The 'a' input must be "normalized", meaning that its
+| most-significant bit (bit 31) must be 1. Thus, if A is the value of the
+| fixed-point interpretation of 'a', it follows that 1 <= A < 2 when 'oddExpA'
+| is 1, and 2 <= A < 4 when 'oddExpA' is 0.
+| The returned value is interpreted as a pure unsigned fraction, having
+| no integer bits and 32 fraction bits. The approximation returned is never
+| greater than the true reciprocal 1/sqrt(A), and it differs from the true
+| reciprocal by at most 2.06 ulp (units in the last place). The approximation
+| returned is also always within the range 0.5 to 1; thus, the most-
+| significant bit of the result is always set.
+*----------------------------------------------------------------------------*/
+static uint32_t softfloat_approxRecipSqrt32_1( unsigned int oddExpA, uint32_t a );
+
+static const uint16_t softfloat_approxRecipSqrt_1k0s[16] = {
+ 0xB4C9, 0xFFAB, 0xAA7D, 0xF11C, 0xA1C5, 0xE4C7, 0x9A43, 0xDA29,
+ 0x93B5, 0xD0E5, 0x8DED, 0xC8B7, 0x88C6, 0xC16D, 0x8424, 0xBAE1
+};
+static const uint16_t softfloat_approxRecipSqrt_1k1s[16] = {
+ 0xA5A5, 0xEA42, 0x8C21, 0xC62D, 0x788F, 0xAA7F, 0x6928, 0x94B6,
+ 0x5CC7, 0x8335, 0x52A6, 0x74E2, 0x4A3E, 0x68FE, 0x432B, 0x5EFD
+};
+
+/*----------------------------------------------------------------------------
+| Shifts the 128 bits formed by concatenating 'a64' and 'a0' left by the
+| number of bits given in 'dist', which must be in the range 1 to 63.
+*----------------------------------------------------------------------------*/
+static inline struct uint128 softfloat_shortShiftLeft128( uint64_t a64, uint64_t a0, uint_fast8_t dist )
+{
+ struct uint128 z;
+ z.v64 = a64<<dist | a0>>(-dist & 63);
+ z.v0 = a0<<dist;
+ return z;
+}
+
+/*----------------------------------------------------------------------------
+| Shifts the 128 bits formed by concatenating 'a64' and 'a0' right by the
+| number of bits given in 'dist', which must be in the range 1 to 63. If any
+| nonzero bits are shifted off, they are "jammed" into the least-significant
+| bit of the shifted value by setting the least-significant bit to 1. This
+| shifted-and-jammed value is returned.
+*----------------------------------------------------------------------------*/
+static inline struct uint128 softfloat_shortShiftRightJam128(uint64_t a64, uint64_t a0, uint_fast8_t dist )
+{
+ uint_fast8_t negDist = -dist;
+ struct uint128 z;
+ z.v64 = a64>>dist;
+ z.v0 =
+ a64<<(negDist & 63) | a0>>dist
+ | ((uint64_t) (a0<<(negDist & 63)) != 0);
+ return z;
+}
+
+/*----------------------------------------------------------------------------
+| Shifts the 128 bits formed by concatenating 'a64' and 'a0' right by the
+| number of bits given in 'dist', which must not be zero. If any nonzero bits
+| are shifted off, they are "jammed" into the least-significant bit of the
+| shifted value by setting the least-significant bit to 1. This shifted-and-
+| jammed value is returned.
+| The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
+| greater than 128, the result will be either 0 or 1, depending on whether the
+| original 128 bits are all zeros.
+*----------------------------------------------------------------------------*/
+static struct uint128 softfloat_shiftRightJam128( uint64_t a64, uint64_t a0, uint_fast32_t dist );
+
+/*----------------------------------------------------------------------------
+| Returns the sum of the 128-bit integer formed by concatenating 'a64' and
+| 'a0' and the 128-bit integer formed by concatenating 'b64' and 'b0'. The
+| addition is modulo 2^128, so any carry out is lost.
+*----------------------------------------------------------------------------*/
+static inline struct uint128 softfloat_add128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
+{
+ struct uint128 z;
+ z.v0 = a0 + b0;
+ z.v64 = a64 + b64 + (z.v0 < a0);
+ return z;
+}
+
+/*----------------------------------------------------------------------------
+| Returns the difference of the 128-bit integer formed by concatenating 'a64'
+| and 'a0' and the 128-bit integer formed by concatenating 'b64' and 'b0'.
+| The subtraction is modulo 2^128, so any borrow out (carry out) is lost.
+*----------------------------------------------------------------------------*/
+static inline struct uint128 softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
+{
+ struct uint128 z;
+ z.v0 = a0 - b0;
+ z.v64 = a64 - b64;
+ z.v64 -= (a0 < b0);
+ return z;
+}
+
+/*----------------------------------------------------------------------------
+| Returns the 128-bit product of 'a' and 'b'.
+*----------------------------------------------------------------------------*/
+static struct uint128 softfloat_mul64To128( uint64_t a, uint64_t b );
+
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+
+static float32_t f32_add( float32_t a, float32_t b )
+{
+ uint_fast32_t uiA = a.v;
+ uint_fast32_t uiB = b.v;
+
+ if ( signF32UI( uiA ^ uiB ) ) {
+ return softfloat_subMagsF32( uiA, uiB );
+ } else {
+ return softfloat_addMagsF32( uiA, uiB );
+ }
+}
+
+static float32_t f32_div( float32_t a, float32_t b )
+{
+ uint_fast32_t uiA;
+ bool signA;
+ int_fast16_t expA;
+ uint_fast32_t sigA;
+ uint_fast32_t uiB;
+ bool signB;
+ int_fast16_t expB;
+ uint_fast32_t sigB;
+ bool signZ;
+ struct exp16_sig32 normExpSig;
+ int_fast16_t expZ;
+ uint_fast64_t sig64A;
+ uint_fast32_t sigZ;
+ uint_fast32_t uiZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiA = a.v;
+ signA = signF32UI( uiA );
+ expA = expF32UI( uiA );
+ sigA = fracF32UI( uiA );
+ uiB = b.v;
+ signB = signF32UI( uiB );
+ expB = expF32UI( uiB );
+ sigB = fracF32UI( uiB );
+ signZ = signA ^ signB;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA == 0xFF ) {
+ if ( sigA ) goto propagateNaN;
+ if ( expB == 0xFF ) {
+ if ( sigB ) goto propagateNaN;
+ goto invalid;
+ }
+ goto infinity;
+ }
+ if ( expB == 0xFF ) {
+ if ( sigB ) goto propagateNaN;
+ goto zero;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! expB ) {
+ if ( ! sigB ) {
+ if ( ! (expA | sigA) ) goto invalid;
+ raiseFlags( flag_infinite );
+ goto infinity;
+ }
+ normExpSig = softfloat_normSubnormalF32Sig( sigB );
+ expB = normExpSig.exp;
+ sigB = normExpSig.sig;
+ }
+ if ( ! expA ) {
+ if ( ! sigA ) goto zero;
+ normExpSig = softfloat_normSubnormalF32Sig( sigA );
+ expA = normExpSig.exp;
+ sigA = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expZ = expA - expB + 0x7E;
+ sigA |= 0x00800000;
+ sigB |= 0x00800000;
+ if ( sigA < sigB ) {
+ --expZ;
+ sig64A = (uint_fast64_t) sigA<<31;
+ } else {
+ sig64A = (uint_fast64_t) sigA<<30;
+ }
+ sigZ = (uint_fast32_t)(sig64A / sigB); // fixed warning on type cast
+ if ( ! (sigZ & 0x3F) ) sigZ |= ((uint_fast64_t) sigB * sigZ != sig64A);
+ return softfloat_roundPackToF32( signZ, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN:
+ uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ invalid:
+ raiseFlags( flag_invalid );
+ uiZ = defaultNaNF32UI;
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ infinity:
+ uiZ = packToF32UI( signZ, 0xFF, 0 );
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ zero:
+ uiZ = packToF32UI( signZ, 0, 0 );
+ uiZ:
+ return float32_t::fromRaw(uiZ);
+}
+
+static bool f32_eq( float32_t a, float32_t b )
+{
+ uint_fast32_t uiA;
+ uint_fast32_t uiB;
+
+ uiA = a.v;
+ uiB = b.v;
+ if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
+ if (
+ softfloat_isSigNaNF32UI( uiA ) || softfloat_isSigNaNF32UI( uiB )
+ ) {
+ raiseFlags( flag_invalid );
+ }
+ return false;
+ }
+ return (uiA == uiB) || ! (uint32_t) ((uiA | uiB)<<1);
+}
+
+static bool f32_le( float32_t a, float32_t b )
+{
+ uint_fast32_t uiA;
+ uint_fast32_t uiB;
+ bool signA, signB;
+
+ uiA = a.v;
+ uiB = b.v;
+ if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
+ raiseFlags( flag_invalid );
+ return false;
+ }
+ signA = signF32UI( uiA );
+ signB = signF32UI( uiB );
+ return
+ (signA != signB) ? signA || ! (uint32_t) ((uiA | uiB)<<1)
+ : (uiA == uiB) || (signA ^ (uiA < uiB));
+}
+
+static bool f32_lt( float32_t a, float32_t b )
+{
+ uint_fast32_t uiA;
+ uint_fast32_t uiB;
+ bool signA, signB;
+
+ uiA = a.v;
+ uiB = b.v;
+ if ( isNaNF32UI( uiA ) || isNaNF32UI( uiB ) ) {
+ raiseFlags( flag_invalid );
+ return false;
+ }
+ signA = signF32UI( uiA );
+ signB = signF32UI( uiB );
+ return
+ (signA != signB) ? signA && ((uint32_t) ((uiA | uiB)<<1) != 0)
+ : (uiA != uiB) && (signA ^ (uiA < uiB));
+}
+
+static float32_t f32_mulAdd( float32_t a, float32_t b, float32_t c )
+{
+ uint_fast32_t uiA;
+ uint_fast32_t uiB;
+ uint_fast32_t uiC;
+
+ uiA = a.v;
+ uiB = b.v;
+ uiC = c.v;
+ return softfloat_mulAddF32( uiA, uiB, uiC, 0 );
+}
+
+static float32_t f32_mul( float32_t a, float32_t b )
+{
+ uint_fast32_t uiA;
+ bool signA;
+ int_fast16_t expA;
+ uint_fast32_t sigA;
+ uint_fast32_t uiB;
+ bool signB;
+ int_fast16_t expB;
+ uint_fast32_t sigB;
+ bool signZ;
+ uint_fast32_t magBits;
+ struct exp16_sig32 normExpSig;
+ int_fast16_t expZ;
+ uint_fast32_t sigZ, uiZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiA = a.v;
+ signA = signF32UI( uiA );
+ expA = expF32UI( uiA );
+ sigA = fracF32UI( uiA );
+ uiB = b.v;
+ signB = signF32UI( uiB );
+ expB = expF32UI( uiB );
+ sigB = fracF32UI( uiB );
+ signZ = signA ^ signB;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA == 0xFF ) {
+ if ( sigA || ((expB == 0xFF) && sigB) ) goto propagateNaN;
+ magBits = expB | sigB;
+ goto infArg;
+ }
+ if ( expB == 0xFF ) {
+ if ( sigB ) goto propagateNaN;
+ magBits = expA | sigA;
+ goto infArg;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! expA ) {
+ if ( ! sigA ) goto zero;
+ normExpSig = softfloat_normSubnormalF32Sig( sigA );
+ expA = normExpSig.exp;
+ sigA = normExpSig.sig;
+ }
+ if ( ! expB ) {
+ if ( ! sigB ) goto zero;
+ normExpSig = softfloat_normSubnormalF32Sig( sigB );
+ expB = normExpSig.exp;
+ sigB = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expZ = expA + expB - 0x7F;
+ sigA = (sigA | 0x00800000)<<7;
+ sigB = (sigB | 0x00800000)<<8;
+ sigZ = (uint_fast32_t)softfloat_shortShiftRightJam64( (uint_fast64_t) sigA * sigB, 32 ); //fixed warning on type cast
+ if ( sigZ < 0x40000000 ) {
+ --expZ;
+ sigZ <<= 1;
+ }
+ return softfloat_roundPackToF32( signZ, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN:
+ uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ infArg:
+ if ( ! magBits ) {
+ raiseFlags( flag_invalid );
+ uiZ = defaultNaNF32UI;
+ } else {
+ uiZ = packToF32UI( signZ, 0xFF, 0 );
+ }
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ zero:
+ uiZ = packToF32UI( signZ, 0, 0 );
+ uiZ:
+ return float32_t::fromRaw(uiZ);
+}
+
+static float32_t f32_rem( float32_t a, float32_t b )
+{
+ uint_fast32_t uiA;
+ bool signA;
+ int_fast16_t expA;
+ uint_fast32_t sigA;
+ uint_fast32_t uiB;
+ int_fast16_t expB;
+ uint_fast32_t sigB;
+ struct exp16_sig32 normExpSig;
+ uint32_t rem;
+ int_fast16_t expDiff;
+ uint32_t q, recip32, altRem, meanRem;
+ bool signRem;
+ uint_fast32_t uiZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiA = a.v;
+ signA = signF32UI( uiA );
+ expA = expF32UI( uiA );
+ sigA = fracF32UI( uiA );
+ uiB = b.v;
+ expB = expF32UI( uiB );
+ sigB = fracF32UI( uiB );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA == 0xFF ) {
+ if ( sigA || ((expB == 0xFF) && sigB) ) goto propagateNaN;
+ goto invalid;
+ }
+ if ( expB == 0xFF ) {
+ if ( sigB ) goto propagateNaN;
+ return a;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! expB ) {
+ if ( ! sigB ) goto invalid;
+ normExpSig = softfloat_normSubnormalF32Sig( sigB );
+ expB = normExpSig.exp;
+ sigB = normExpSig.sig;
+ }
+ if ( ! expA ) {
+ if ( ! sigA ) return a;
+ normExpSig = softfloat_normSubnormalF32Sig( sigA );
+ expA = normExpSig.exp;
+ sigA = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ rem = sigA | 0x00800000;
+ sigB |= 0x00800000;
+ expDiff = expA - expB;
+ if ( expDiff < 1 ) {
+ if ( expDiff < -1 ) return a;
+ sigB <<= 6;
+ if ( expDiff ) {
+ rem <<= 5;
+ q = 0;
+ } else {
+ rem <<= 6;
+ q = (sigB <= rem);
+ if ( q ) rem -= sigB;
+ }
+ } else {
+ recip32 = softfloat_approxRecip32_1( sigB<<8 );
+ /*--------------------------------------------------------------------
+ | Changing the shift of `rem' here requires also changing the initial
+ | subtraction from `expDiff'.
+ *--------------------------------------------------------------------*/
+ rem <<= 7;
+ expDiff -= 31;
+ /*--------------------------------------------------------------------
+ | The scale of `sigB' affects how many bits are obtained during each
+ | cycle of the loop. Currently this is 29 bits per loop iteration,
+ | which is believed to be the maximum possible.
+ *--------------------------------------------------------------------*/
+ sigB <<= 6;
+ for (;;) {
+ q = (rem * (uint_fast64_t) recip32)>>32;
+ if ( expDiff < 0 ) break;
+ //fixed unsigned unary minus: -x == ~x + 1
+ rem = ~(q * (uint32_t) sigB) + 1;
+ expDiff -= 29;
+ }
+ /*--------------------------------------------------------------------
+ | (`expDiff' cannot be less than -30 here.)
+ *--------------------------------------------------------------------*/
+ q >>= ~expDiff & 31;
+ rem = (rem<<(expDiff + 30)) - q * (uint32_t) sigB;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ do {
+ altRem = rem;
+ ++q;
+ rem -= sigB;
+ } while ( ! (rem & 0x80000000) );
+ meanRem = rem + altRem;
+ if ( (meanRem & 0x80000000) || (! meanRem && (q & 1)) ) rem = altRem;
+ signRem = signA;
+ if ( 0x80000000 <= rem ) {
+ signRem = ! signRem;
+ //fixed unsigned unary minus: -x == ~x + 1
+ rem = ~rem + 1;
+ }
+ return softfloat_normRoundPackToF32( signRem, expB, rem );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN:
+ uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
+ goto uiZ;
+ invalid:
+ raiseFlags( flag_invalid );
+ uiZ = defaultNaNF32UI;
+ uiZ:
+ return float32_t::fromRaw(uiZ);
+}
+
+static float32_t f32_roundToInt( float32_t a, uint_fast8_t roundingMode, bool exact )
+{
+ uint_fast32_t uiA;
+ int_fast16_t exp;
+ uint_fast32_t uiZ, lastBitMask, roundBitsMask;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiA = a.v;
+ exp = expF32UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp <= 0x7E ) {
+ if ( ! (uint32_t) (uiA<<1) ) return a;
+ if ( exact ) raiseFlags(flag_inexact);
+ uiZ = uiA & packToF32UI( 1, 0, 0 );
+ switch ( roundingMode ) {
+ case round_near_even:
+ if ( ! fracF32UI( uiA ) ) break;
+ case round_near_maxMag:
+ if ( exp == 0x7E ) uiZ |= packToF32UI( 0, 0x7F, 0 );
+ break;
+ case round_min:
+ if ( uiZ ) uiZ = packToF32UI( 1, 0x7F, 0 );
+ break;
+ case round_max:
+ if ( ! uiZ ) uiZ = packToF32UI( 0, 0x7F, 0 );
+ break;
+ }
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( 0x96 <= exp ) {
+ if ( (exp == 0xFF) && fracF32UI( uiA ) ) {
+ uiZ = softfloat_propagateNaNF32UI( uiA, 0 );
+ goto uiZ;
+ }
+ return a;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiZ = uiA;
+ lastBitMask = (uint_fast32_t) 1<<(0x96 - exp);
+ roundBitsMask = lastBitMask - 1;
+ if ( roundingMode == round_near_maxMag ) {
+ uiZ += lastBitMask>>1;
+ } else if ( roundingMode == round_near_even ) {
+ uiZ += lastBitMask>>1;
+ if ( ! (uiZ & roundBitsMask) ) uiZ &= ~lastBitMask;
+ } else if (
+ roundingMode
+ == (signF32UI( uiZ ) ? round_min : round_max)
+ ) {
+ uiZ += roundBitsMask;
+ }
+ uiZ &= ~roundBitsMask;
+ if ( exact && (uiZ != uiA) ) {
+ raiseFlags(flag_inexact);
+ }
+ uiZ:
+ return float32_t::fromRaw(uiZ);
+}
+
+static float32_t f32_sqrt( float32_t a )
+{
+ uint_fast32_t uiA;
+ bool signA;
+ int_fast16_t expA;
+ uint_fast32_t sigA, uiZ;
+ struct exp16_sig32 normExpSig;
+ int_fast16_t expZ;
+ uint_fast32_t sigZ, shiftedSigZ;
+ uint32_t negRem;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiA = a.v;
+ signA = signF32UI( uiA );
+ expA = expF32UI( uiA );
+ sigA = fracF32UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA == 0xFF ) {
+ if ( sigA ) {
+ uiZ = softfloat_propagateNaNF32UI( uiA, 0 );
+ goto uiZ;
+ }
+ if ( ! signA ) return a;
+ goto invalid;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( signA ) {
+ if ( ! (expA | sigA) ) return a;
+ goto invalid;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! expA ) {
+ if ( ! sigA ) return a;
+ normExpSig = softfloat_normSubnormalF32Sig( sigA );
+ expA = normExpSig.exp;
+ sigA = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expZ = ((expA - 0x7F)>>1) + 0x7E;
+ expA &= 1;
+ sigA = (sigA | 0x00800000)<<8;
+ sigZ =
+ ((uint_fast64_t) sigA * softfloat_approxRecipSqrt32_1( expA, sigA ))
+ >>32;
+ if ( expA ) sigZ >>= 1;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sigZ += 2;
+ if ( (sigZ & 0x3F) < 2 ) {
+ shiftedSigZ = sigZ>>2;
+ negRem = shiftedSigZ * shiftedSigZ;
+ sigZ &= ~3;
+ if ( negRem & 0x80000000 ) {
+ sigZ |= 1;
+ } else {
+ if ( negRem ) --sigZ;
+ }
+ }
+ return softfloat_roundPackToF32( 0, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ invalid:
+ raiseFlags( flag_invalid );
+ uiZ = defaultNaNF32UI;
+ uiZ:
+ return float32_t::fromRaw(uiZ);
+}
+
+static float32_t f32_sub( float32_t a, float32_t b )
+{
+ uint_fast32_t uiA;
+ uint_fast32_t uiB;
+
+ uiA = a.v;
+ uiB = b.v;
+ if ( signF32UI( uiA ^ uiB ) ) {
+ return softfloat_addMagsF32( uiA, uiB );
+ } else {
+ return softfloat_subMagsF32( uiA, uiB );
+ }
+}
+
+static float64_t f32_to_f64( float32_t a )
+{
+ uint_fast32_t uiA;
+ bool sign;
+ int_fast16_t exp;
+ uint_fast32_t frac;
+ struct commonNaN commonNaN;
+ uint_fast64_t uiZ;
+ struct exp16_sig32 normExpSig;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiA = a.v;
+ sign = signF32UI( uiA );
+ exp = expF32UI( uiA );
+ frac = fracF32UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0xFF ) {
+ if ( frac ) {
+ softfloat_f32UIToCommonNaN( uiA, &commonNaN );
+ uiZ = softfloat_commonNaNToF64UI( &commonNaN );
+ } else {
+ uiZ = packToF64UI( sign, 0x7FF, 0 );
+ }
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! exp ) {
+ if ( ! frac ) {
+ uiZ = packToF64UI( sign, 0, 0 );
+ goto uiZ;
+ }
+ normExpSig = softfloat_normSubnormalF32Sig( frac );
+ exp = normExpSig.exp - 1;
+ frac = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiZ = packToF64UI( sign, exp + 0x380, (uint_fast64_t) frac<<29 );
+ uiZ:
+ return float64_t::fromRaw(uiZ);
+}
+
+static int_fast32_t f32_to_i32( float32_t a, uint_fast8_t roundingMode, bool exact )
+{
+ uint_fast32_t uiA;
+ bool sign;
+ int_fast16_t exp;
+ uint_fast32_t sig;
+ uint_fast64_t sig64;
+ int_fast16_t shiftDist;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiA = a.v;
+ sign = signF32UI( uiA );
+ exp = expF32UI( uiA );
+ sig = fracF32UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+#if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
+ if ( (exp == 0xFF) && sig ) {
+#if (i32_fromNaN == i32_fromPosOverflow)
+ sign = 0;
+#elif (i32_fromNaN == i32_fromNegOverflow)
+ sign = 1;
+#else
+ raiseFlags( flag_invalid );
+ return i32_fromNaN;
+#endif
+ }
+#endif
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp ) sig |= 0x00800000;
+ sig64 = (uint_fast64_t) sig<<32;
+ shiftDist = 0xAA - exp;
+ if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
+ return softfloat_roundToI32( sign, sig64, roundingMode, exact );
+}
+
+static int_fast32_t f32_to_i32_r_minMag( float32_t a, bool exact )
+{
+ uint_fast32_t uiA;
+ int_fast16_t exp;
+ uint_fast32_t sig;
+ int_fast16_t shiftDist;
+ bool sign;
+ int_fast32_t absZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiA = a.v;
+ exp = expF32UI( uiA );
+ sig = fracF32UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ shiftDist = 0x9E - exp;
+ if ( 32 <= shiftDist ) {
+ if ( exact && (exp | sig) ) {
+ raiseFlags(flag_inexact);
+ }
+ return 0;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sign = signF32UI( uiA );
+ if ( shiftDist <= 0 ) {
+ if ( uiA == packToF32UI( 1, 0x9E, 0 ) ) return -0x7FFFFFFF - 1;
+ raiseFlags( flag_invalid );
+ return
+ (exp == 0xFF) && sig ? i32_fromNaN
+ : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sig = (sig | 0x00800000)<<8;
+ absZ = sig>>shiftDist;
+ if ( exact && ((uint_fast32_t) absZ<<shiftDist != sig) ) {
+ raiseFlags(flag_inexact);
+ }
+ return sign ? -absZ : absZ;
+}
+
+static float64_t f64_add( float64_t a, float64_t b )
+{
+ uint_fast64_t uiA;
+ bool signA;
+ uint_fast64_t uiB;
+ bool signB;
+
+ uiA = a.v;
+ signA = signF64UI( uiA );
+ uiB = b.v;
+ signB = signF64UI( uiB );
+ if ( signA == signB ) {
+ return softfloat_addMagsF64( uiA, uiB, signA );
+ } else {
+ return softfloat_subMagsF64( uiA, uiB, signA );
+ }
+}
+
+static float64_t f64_div( float64_t a, float64_t b )
+{
+ uint_fast64_t uiA;
+ bool signA;
+ int_fast16_t expA;
+ uint_fast64_t sigA;
+ uint_fast64_t uiB;
+ bool signB;
+ int_fast16_t expB;
+ uint_fast64_t sigB;
+ bool signZ;
+ struct exp16_sig64 normExpSig;
+ int_fast16_t expZ;
+ uint32_t recip32, sig32Z, doubleTerm;
+ uint_fast64_t rem;
+ uint32_t q;
+ uint_fast64_t sigZ;
+ uint_fast64_t uiZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiA = a.v;
+ signA = signF64UI( uiA );
+ expA = expF64UI( uiA );
+ sigA = fracF64UI( uiA );
+ uiB = b.v;
+ signB = signF64UI( uiB );
+ expB = expF64UI( uiB );
+ sigB = fracF64UI( uiB );
+ signZ = signA ^ signB;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA == 0x7FF ) {
+ if ( sigA ) goto propagateNaN;
+ if ( expB == 0x7FF ) {
+ if ( sigB ) goto propagateNaN;
+ goto invalid;
+ }
+ goto infinity;
+ }
+ if ( expB == 0x7FF ) {
+ if ( sigB ) goto propagateNaN;
+ goto zero;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! expB ) {
+ if ( ! sigB ) {
+ if ( ! (expA | sigA) ) goto invalid;
+ raiseFlags( flag_infinite );
+ goto infinity;
+ }
+ normExpSig = softfloat_normSubnormalF64Sig( sigB );
+ expB = normExpSig.exp;
+ sigB = normExpSig.sig;
+ }
+ if ( ! expA ) {
+ if ( ! sigA ) goto zero;
+ normExpSig = softfloat_normSubnormalF64Sig( sigA );
+ expA = normExpSig.exp;
+ sigA = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expZ = expA - expB + 0x3FE;
+ sigA |= UINT64_C( 0x0010000000000000 );
+ sigB |= UINT64_C( 0x0010000000000000 );
+ if ( sigA < sigB ) {
+ --expZ;
+ sigA <<= 11;
+ } else {
+ sigA <<= 10;
+ }
+ sigB <<= 11;
+ recip32 = softfloat_approxRecip32_1( sigB>>32 ) - 2;
+ sig32Z = ((uint32_t) (sigA>>32) * (uint_fast64_t) recip32)>>32;
+ doubleTerm = sig32Z<<1;
+ rem =
+ ((sigA - (uint_fast64_t) doubleTerm * (uint32_t) (sigB>>32))<<28)
+ - (uint_fast64_t) doubleTerm * ((uint32_t) sigB>>4);
+ q = (((uint32_t) (rem>>32) * (uint_fast64_t) recip32)>>32) + 4;
+ sigZ = ((uint_fast64_t) sig32Z<<32) + ((uint_fast64_t) q<<4);
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( (sigZ & 0x1FF) < 4<<4 ) {
+ q &= ~7;
+ sigZ &= ~(uint_fast64_t) 0x7F;
+ doubleTerm = q<<1;
+ rem =
+ ((rem - (uint_fast64_t) doubleTerm * (uint32_t) (sigB>>32))<<28)
+ - (uint_fast64_t) doubleTerm * ((uint32_t) sigB>>4);
+ if ( rem & UINT64_C( 0x8000000000000000 ) ) {
+ sigZ -= 1<<7;
+ } else {
+ if ( rem ) sigZ |= 1;
+ }
+ }
+ return softfloat_roundPackToF64( signZ, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN:
+ uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ invalid:
+ raiseFlags( flag_invalid );
+ uiZ = defaultNaNF64UI;
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ infinity:
+ uiZ = packToF64UI( signZ, 0x7FF, 0 );
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ zero:
+ uiZ = packToF64UI( signZ, 0, 0 );
+ uiZ:
+ return float64_t::fromRaw(uiZ);
+}
+
+static bool f64_eq( float64_t a, float64_t b )
+{
+ uint_fast64_t uiA;
+ uint_fast64_t uiB;
+
+ uiA = a.v;
+ uiB = b.v;
+ if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
+ if (
+ softfloat_isSigNaNF64UI( uiA ) || softfloat_isSigNaNF64UI( uiB )
+ ) {
+ raiseFlags( flag_invalid );
+ }
+ return false;
+ }
+ return (uiA == uiB) || ! ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ));
+}
+
+static bool f64_le( float64_t a, float64_t b )
+{
+ uint_fast64_t uiA;
+ uint_fast64_t uiB;
+ bool signA, signB;
+
+ uiA = a.v;
+ uiB = b.v;
+ if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
+ raiseFlags( flag_invalid );
+ return false;
+ }
+ signA = signF64UI( uiA );
+ signB = signF64UI( uiB );
+ return
+ (signA != signB)
+ ? signA || ! ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
+ : (uiA == uiB) || (signA ^ (uiA < uiB));
+}
+
+static bool f64_lt( float64_t a, float64_t b )
+{
+ uint_fast64_t uiA;
+ uint_fast64_t uiB;
+ bool signA, signB;
+
+ uiA = a.v;
+ uiB = b.v;
+ if ( isNaNF64UI( uiA ) || isNaNF64UI( uiB ) ) {
+ raiseFlags( flag_invalid );
+ return false;
+ }
+ signA = signF64UI( uiA );
+ signB = signF64UI( uiB );
+ return
+ (signA != signB)
+ ? signA && ((uiA | uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
+ : (uiA != uiB) && (signA ^ (uiA < uiB));
+}
+
+static float64_t f64_mulAdd( float64_t a, float64_t b, float64_t c )
+{
+ uint_fast64_t uiA;
+ uint_fast64_t uiB;
+ uint_fast64_t uiC;
+
+ uiA = a.v;
+ uiB = b.v;
+ uiC = c.v;
+ return softfloat_mulAddF64( uiA, uiB, uiC, 0 );
+}
+
+static float64_t f64_mul( float64_t a, float64_t b )
+{
+ uint_fast64_t uiA;
+ bool signA;
+ int_fast16_t expA;
+ uint_fast64_t sigA;
+ uint_fast64_t uiB;
+ bool signB;
+ int_fast16_t expB;
+ uint_fast64_t sigB;
+ bool signZ;
+ uint_fast64_t magBits;
+ struct exp16_sig64 normExpSig;
+ int_fast16_t expZ;
+ struct uint128 sig128Z;
+ uint_fast64_t sigZ, uiZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiA = a.v;
+ signA = signF64UI( uiA );
+ expA = expF64UI( uiA );
+ sigA = fracF64UI( uiA );
+ uiB = b.v;
+ signB = signF64UI( uiB );
+ expB = expF64UI( uiB );
+ sigB = fracF64UI( uiB );
+ signZ = signA ^ signB;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA == 0x7FF ) {
+ if ( sigA || ((expB == 0x7FF) && sigB) ) goto propagateNaN;
+ magBits = expB | sigB;
+ goto infArg;
+ }
+ if ( expB == 0x7FF ) {
+ if ( sigB ) goto propagateNaN;
+ magBits = expA | sigA;
+ goto infArg;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! expA ) {
+ if ( ! sigA ) goto zero;
+ normExpSig = softfloat_normSubnormalF64Sig( sigA );
+ expA = normExpSig.exp;
+ sigA = normExpSig.sig;
+ }
+ if ( ! expB ) {
+ if ( ! sigB ) goto zero;
+ normExpSig = softfloat_normSubnormalF64Sig( sigB );
+ expB = normExpSig.exp;
+ sigB = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expZ = expA + expB - 0x3FF;
+ sigA = (sigA | UINT64_C( 0x0010000000000000 ))<<10;
+ sigB = (sigB | UINT64_C( 0x0010000000000000 ))<<11;
+ sig128Z = softfloat_mul64To128( sigA, sigB );
+ sigZ = sig128Z.v64 | (sig128Z.v0 != 0);
+
+ if ( sigZ < UINT64_C( 0x4000000000000000 ) ) {
+ --expZ;
+ sigZ <<= 1;
+ }
+ return softfloat_roundPackToF64( signZ, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN:
+ uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ infArg:
+ if ( ! magBits ) {
+ raiseFlags( flag_invalid );
+ uiZ = defaultNaNF64UI;
+ } else {
+ uiZ = packToF64UI( signZ, 0x7FF, 0 );
+ }
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ zero:
+ uiZ = packToF64UI( signZ, 0, 0 );
+ uiZ:
+ return float64_t::fromRaw(uiZ);
+}
+
+static float64_t f64_rem( float64_t a, float64_t b )
+{
+ uint_fast64_t uiA;
+ bool signA;
+ int_fast16_t expA;
+ uint_fast64_t sigA;
+ uint_fast64_t uiB;
+ int_fast16_t expB;
+ uint_fast64_t sigB;
+ struct exp16_sig64 normExpSig;
+ uint64_t rem;
+ int_fast16_t expDiff;
+ uint32_t q, recip32;
+ uint_fast64_t q64;
+ uint64_t altRem, meanRem;
+ bool signRem;
+ uint_fast64_t uiZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiA = a.v;
+ signA = signF64UI( uiA );
+ expA = expF64UI( uiA );
+ sigA = fracF64UI( uiA );
+ uiB = b.v;
+ expB = expF64UI( uiB );
+ sigB = fracF64UI( uiB );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA == 0x7FF ) {
+ if ( sigA || ((expB == 0x7FF) && sigB) ) goto propagateNaN;
+ goto invalid;
+ }
+ if ( expB == 0x7FF ) {
+ if ( sigB ) goto propagateNaN;
+ return a;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA < expB - 1 ) return a;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! expB ) {
+ if ( ! sigB ) goto invalid;
+ normExpSig = softfloat_normSubnormalF64Sig( sigB );
+ expB = normExpSig.exp;
+ sigB = normExpSig.sig;
+ }
+ if ( ! expA ) {
+ if ( ! sigA ) return a;
+ normExpSig = softfloat_normSubnormalF64Sig( sigA );
+ expA = normExpSig.exp;
+ sigA = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ rem = sigA | UINT64_C( 0x0010000000000000 );
+ sigB |= UINT64_C( 0x0010000000000000 );
+ expDiff = expA - expB;
+ if ( expDiff < 1 ) {
+ if ( expDiff < -1 ) return a;
+ sigB <<= 9;
+ if ( expDiff ) {
+ rem <<= 8;
+ q = 0;
+ } else {
+ rem <<= 9;
+ q = (sigB <= rem);
+ if ( q ) rem -= sigB;
+ }
+ } else {
+ recip32 = softfloat_approxRecip32_1( sigB>>21 );
+ /*--------------------------------------------------------------------
+ | Changing the shift of `rem' here requires also changing the initial
+ | subtraction from `expDiff'.
+ *--------------------------------------------------------------------*/
+ rem <<= 9;
+ expDiff -= 30;
+ /*--------------------------------------------------------------------
+ | The scale of `sigB' affects how many bits are obtained during each
+ | cycle of the loop. Currently this is 29 bits per loop iteration,
+ | the maximum possible.
+ *--------------------------------------------------------------------*/
+ sigB <<= 9;
+ for (;;) {
+ q64 = (uint32_t) (rem>>32) * (uint_fast64_t) recip32;
+ if ( expDiff < 0 ) break;
+ q = (q64 + 0x80000000)>>32;
+ rem <<= 29;
+ rem -= q * (uint64_t) sigB;
+ if ( rem & UINT64_C( 0x8000000000000000 ) ) rem += sigB;
+ expDiff -= 29;
+ }
+ /*--------------------------------------------------------------------
+ | (`expDiff' cannot be less than -29 here.)
+ *--------------------------------------------------------------------*/
+ q = (uint32_t) (q64>>32)>>(~expDiff & 31);
+ rem = (rem<<(expDiff + 30)) - q * (uint64_t) sigB;
+ if ( rem & UINT64_C( 0x8000000000000000 ) ) {
+ altRem = rem + sigB;
+ goto selectRem;
+ }
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ do {
+ altRem = rem;
+ ++q;
+ rem -= sigB;
+ } while ( ! (rem & UINT64_C( 0x8000000000000000 )) );
+ selectRem:
+ meanRem = rem + altRem;
+ if (
+ (meanRem & UINT64_C( 0x8000000000000000 )) || (! meanRem && (q & 1))
+ ) {
+ rem = altRem;
+ }
+ signRem = signA;
+ if ( rem & UINT64_C( 0x8000000000000000 ) ) {
+ signRem = ! signRem;
+ //fixed unsigned unary minus: -x == ~x + 1
+ rem = ~rem + 1;
+ }
+ return softfloat_normRoundPackToF64( signRem, expB, rem );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN:
+ uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
+ goto uiZ;
+ invalid:
+ raiseFlags( flag_invalid );
+ uiZ = defaultNaNF64UI;
+ uiZ:
+ return float64_t::fromRaw(uiZ);
+}
+
+static float64_t f64_roundToInt( float64_t a, uint_fast8_t roundingMode, bool exact )
+{
+ uint_fast64_t uiA;
+ int_fast16_t exp;
+ uint_fast64_t uiZ, lastBitMask, roundBitsMask;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiA = a.v;
+ exp = expF64UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp <= 0x3FE ) {
+ if ( ! (uiA & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) return a;
+ if ( exact ) raiseFlags(flag_inexact);
+ uiZ = uiA & packToF64UI( 1, 0, 0 );
+ switch ( roundingMode ) {
+ case round_near_even:
+ if ( ! fracF64UI( uiA ) ) break;
+ case round_near_maxMag:
+ if ( exp == 0x3FE ) uiZ |= packToF64UI( 0, 0x3FF, 0 );
+ break;
+ case round_min:
+ if ( uiZ ) uiZ = packToF64UI( 1, 0x3FF, 0 );
+ break;
+ case round_max:
+ if ( ! uiZ ) uiZ = packToF64UI( 0, 0x3FF, 0 );
+ break;
+ }
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( 0x433 <= exp ) {
+ if ( (exp == 0x7FF) && fracF64UI( uiA ) ) {
+ uiZ = softfloat_propagateNaNF64UI( uiA, 0 );
+ goto uiZ;
+ }
+ return a;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiZ = uiA;
+ lastBitMask = (uint_fast64_t) 1<<(0x433 - exp);
+ roundBitsMask = lastBitMask - 1;
+ if ( roundingMode == round_near_maxMag ) {
+ uiZ += lastBitMask>>1;
+ } else if ( roundingMode == round_near_even ) {
+ uiZ += lastBitMask>>1;
+ if ( ! (uiZ & roundBitsMask) ) uiZ &= ~lastBitMask;
+ } else if (
+ roundingMode
+ == (signF64UI( uiZ ) ? round_min : round_max)
+ ) {
+ uiZ += roundBitsMask;
+ }
+ uiZ &= ~roundBitsMask;
+ if ( exact && (uiZ != uiA) ) {
+ raiseFlags(flag_inexact);
+ }
+ uiZ:
+ return float64_t::fromRaw(uiZ);
+}
+
+static float64_t f64_sqrt( float64_t a )
+{
+ uint_fast64_t uiA;
+ bool signA;
+ int_fast16_t expA;
+ uint_fast64_t sigA, uiZ;
+ struct exp16_sig64 normExpSig;
+ int_fast16_t expZ;
+ uint32_t sig32A, recipSqrt32, sig32Z;
+ uint_fast64_t rem;
+ uint32_t q;
+ uint_fast64_t sigZ, shiftedSigZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiA = a.v;
+ signA = signF64UI( uiA );
+ expA = expF64UI( uiA );
+ sigA = fracF64UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA == 0x7FF ) {
+ if ( sigA ) {
+ uiZ = softfloat_propagateNaNF64UI( uiA, 0 );
+ goto uiZ;
+ }
+ if ( ! signA ) return a;
+ goto invalid;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( signA ) {
+ if ( ! (expA | sigA) ) return a;
+ goto invalid;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! expA ) {
+ if ( ! sigA ) return a;
+ normExpSig = softfloat_normSubnormalF64Sig( sigA );
+ expA = normExpSig.exp;
+ sigA = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ | (`sig32Z' is guaranteed to be a lower bound on the square root of
+ | `sig32A', which makes `sig32Z' also a lower bound on the square root of
+ | `sigA'.)
+ *------------------------------------------------------------------------*/
+ expZ = ((expA - 0x3FF)>>1) + 0x3FE;
+ expA &= 1;
+ sigA |= UINT64_C( 0x0010000000000000 );
+ sig32A = (uint32_t)(sigA>>21); //fixed warning on type cast
+ recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
+ sig32Z = ((uint_fast64_t) sig32A * recipSqrt32)>>32;
+ if ( expA ) {
+ sigA <<= 8;
+ sig32Z >>= 1;
+ } else {
+ sigA <<= 9;
+ }
+ rem = sigA - (uint_fast64_t) sig32Z * sig32Z;
+ q = ((uint32_t) (rem>>2) * (uint_fast64_t) recipSqrt32)>>32;
+ sigZ = ((uint_fast64_t) sig32Z<<32 | 1<<5) + ((uint_fast64_t) q<<3);
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( (sigZ & 0x1FF) < 1<<5 ) {
+ sigZ &= ~(uint_fast64_t) 0x3F;
+ shiftedSigZ = sigZ>>6;
+ rem = (sigA<<52) - shiftedSigZ * shiftedSigZ;
+ if ( rem & UINT64_C( 0x8000000000000000 ) ) {
+ --sigZ;
+ } else {
+ if ( rem ) sigZ |= 1;
+ }
+ }
+ return softfloat_roundPackToF64( 0, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ invalid:
+ raiseFlags( flag_invalid );
+ uiZ = defaultNaNF64UI;
+ uiZ:
+ return float64_t::fromRaw(uiZ);
+}
+
+static float64_t f64_sub( float64_t a, float64_t b )
+{
+ uint_fast64_t uiA;
+ bool signA;
+ uint_fast64_t uiB;
+ bool signB;
+
+ uiA = a.v;
+ signA = signF64UI( uiA );
+ uiB = b.v;
+ signB = signF64UI( uiB );
+
+ if ( signA == signB ) {
+ return softfloat_subMagsF64( uiA, uiB, signA );
+ } else {
+ return softfloat_addMagsF64( uiA, uiB, signA );
+ }
+}
+
+static float32_t f64_to_f32( float64_t a )
+{
+ uint_fast64_t uiA;
+ bool sign;
+ int_fast16_t exp;
+ uint_fast64_t frac;
+ struct commonNaN commonNaN;
+ uint_fast32_t uiZ, frac32;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiA = a.v;
+ sign = signF64UI( uiA );
+ exp = expF64UI( uiA );
+ frac = fracF64UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x7FF ) {
+ if ( frac ) {
+ softfloat_f64UIToCommonNaN( uiA, &commonNaN );
+ uiZ = softfloat_commonNaNToF32UI( &commonNaN );
+ } else {
+ uiZ = packToF32UI( sign, 0xFF, 0 );
+ }
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ frac32 = (uint_fast32_t)softfloat_shortShiftRightJam64( frac, 22 ); //fixed warning on type cast
+ if ( ! (exp | frac32) ) {
+ uiZ = packToF32UI( sign, 0, 0 );
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ return softfloat_roundPackToF32( sign, exp - 0x381, frac32 | 0x40000000 );
+ uiZ:
+ return float32_t::fromRaw(uiZ);
+}
+
+static int_fast32_t f64_to_i32( float64_t a, uint_fast8_t roundingMode, bool exact )
+{
+ uint_fast64_t uiA;
+ bool sign;
+ int_fast16_t exp;
+ uint_fast64_t sig;
+ int_fast16_t shiftDist;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiA = a.v;
+ sign = signF64UI( uiA );
+ exp = expF64UI( uiA );
+ sig = fracF64UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+#if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
+ if ( (exp == 0x7FF) && sig ) {
+#if (i32_fromNaN == i32_fromPosOverflow)
+ sign = 0;
+#elif (i32_fromNaN == i32_fromNegOverflow)
+ sign = 1;
+#else
+ raiseFlags( flag_invalid );
+ return i32_fromNaN;
+#endif
+ }
+#endif
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp ) sig |= UINT64_C( 0x0010000000000000 );
+ shiftDist = 0x427 - exp;
+ if ( 0 < shiftDist ) sig = softfloat_shiftRightJam64( sig, shiftDist );
+ return softfloat_roundToI32( sign, sig, roundingMode, exact );
+}
+
+static int_fast32_t f64_to_i32_r_minMag( float64_t a, bool exact )
+{
+ uint_fast64_t uiA;
+ int_fast16_t exp;
+ uint_fast64_t sig;
+ int_fast16_t shiftDist;
+ bool sign;
+ int_fast32_t absZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiA = a.v;
+ exp = expF64UI( uiA );
+ sig = fracF64UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ shiftDist = 0x433 - exp;
+ if ( 53 <= shiftDist ) {
+ if ( exact && (exp | sig) ) {
+ raiseFlags(flag_inexact);
+ }
+ return 0;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sign = signF64UI( uiA );
+ if ( shiftDist < 22 ) {
+ if (
+ sign && (exp == 0x41E) && (sig < UINT64_C( 0x0000000000200000 ))
+ ) {
+ if ( exact && sig ) {
+ raiseFlags(flag_inexact);
+ }
+ return -0x7FFFFFFF - 1;
+ }
+ raiseFlags( flag_invalid );
+ return
+ (exp == 0x7FF) && sig ? i32_fromNaN
+ : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sig |= UINT64_C( 0x0010000000000000 );
+ absZ = (int_fast32_t)(sig>>shiftDist); //fixed warning on type cast
+ if ( exact && ((uint_fast64_t) (uint_fast32_t) absZ<<shiftDist != sig) ) {
+ raiseFlags(flag_inexact);
+ }
+ return sign ? -absZ : absZ;
+}
+
+static float32_t i32_to_f32( int32_t a )
+{
+ bool sign;
+ uint_fast32_t absA;
+
+ sign = (a < 0);
+ if ( ! (a & 0x7FFFFFFF) ) {
+ return float32_t::fromRaw(sign ? packToF32UI( 1, 0x9E, 0 ) : 0);
+ }
+ //fixed unsigned unary minus: -x == ~x + 1
+ absA = sign ? (~(uint_fast32_t) a + 1) : (uint_fast32_t) a;
+ return softfloat_normRoundPackToF32( sign, 0x9C, absA );
+}
+
+static float64_t i32_to_f64( int32_t a )
+{
+ uint_fast64_t uiZ;
+ bool sign;
+ uint_fast32_t absA;
+ int_fast8_t shiftDist;
+
+ if ( ! a ) {
+ uiZ = 0;
+ } else {
+ sign = (a < 0);
+ //fixed unsigned unary minus: -x == ~x + 1
+ absA = sign ? (~(uint_fast32_t) a + 1) : (uint_fast32_t) a;
+ shiftDist = softfloat_countLeadingZeros32( absA ) + 21;
+ uiZ =
+ packToF64UI(
+ sign, 0x432 - shiftDist, (uint_fast64_t) absA<<shiftDist );
+ }
+ return float64_t::fromRaw(uiZ);
+}
+
+static float32_t i64_to_f32( int64_t a )
+{
+ bool sign;
+ uint_fast64_t absA;
+ int_fast8_t shiftDist;
+ uint_fast32_t sig;
+
+ sign = (a < 0);
+ //fixed unsigned unary minus: -x == ~x + 1
+ absA = sign ? (~(uint_fast64_t) a + 1) : (uint_fast64_t) a;
+ shiftDist = softfloat_countLeadingZeros64( absA ) - 40;
+ if ( 0 <= shiftDist ) {
+ return float32_t::fromRaw(a ? packToF32UI(sign, 0x95 - shiftDist, (uint_fast32_t) absA<<shiftDist ) : 0);
+ } else {
+ shiftDist += 7;
+ sig =
+ (shiftDist < 0)
+ ? (uint_fast32_t) softfloat_shortShiftRightJam64( absA, -shiftDist ) //fixed warning on type cast
+ : (uint_fast32_t) absA<<shiftDist;
+ return softfloat_roundPackToF32( sign, 0x9C - shiftDist, sig );
+ }
+}
+
+static float64_t i64_to_f64( int64_t a )
+{
+ bool sign;
+ uint_fast64_t absA;
+
+ sign = (a < 0);
+ if ( ! (a & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) {
+ return float64_t::fromRaw(sign ? packToF64UI( 1, 0x43E, 0 ) : 0);
+ }
+ //fixed unsigned unary minus: -x == ~x + 1
+ absA = sign ? (~(uint_fast64_t) a + 1) : (uint_fast64_t) a;
+ return softfloat_normRoundPackToF64( sign, 0x43C, absA );
+}
+
+static float32_t softfloat_addMagsF32( uint_fast32_t uiA, uint_fast32_t uiB )
+{
+ int_fast16_t expA;
+ uint_fast32_t sigA;
+ int_fast16_t expB;
+ uint_fast32_t sigB;
+ int_fast16_t expDiff;
+ uint_fast32_t uiZ;
+ bool signZ;
+ int_fast16_t expZ;
+ uint_fast32_t sigZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expA = expF32UI( uiA );
+ sigA = fracF32UI( uiA );
+ expB = expF32UI( uiB );
+ sigB = fracF32UI( uiB );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expDiff = expA - expB;
+ if ( ! expDiff ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( ! expA ) {
+ uiZ = uiA + sigB;
+ goto uiZ;
+ }
+ if ( expA == 0xFF ) {
+ if ( sigA | sigB ) goto propagateNaN;
+ uiZ = uiA;
+ goto uiZ;
+ }
+ signZ = signF32UI( uiA );
+ expZ = expA;
+ sigZ = 0x01000000 + sigA + sigB;
+ if ( ! (sigZ & 1) && (expZ < 0xFE) ) {
+ uiZ = packToF32UI( signZ, expZ, sigZ>>1 );
+ goto uiZ;
+ }
+ sigZ <<= 6;
+ } else {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ signZ = signF32UI( uiA );
+ sigA <<= 6;
+ sigB <<= 6;
+ if ( expDiff < 0 ) {
+ if ( expB == 0xFF ) {
+ if ( sigB ) goto propagateNaN;
+ uiZ = packToF32UI( signZ, 0xFF, 0 );
+ goto uiZ;
+ }
+ expZ = expB;
+ sigA += expA ? 0x20000000 : sigA;
+ sigA = softfloat_shiftRightJam32( sigA, -expDiff );
+ } else {
+ if ( expA == 0xFF ) {
+ if ( sigA ) goto propagateNaN;
+ uiZ = uiA;
+ goto uiZ;
+ }
+ expZ = expA;
+ sigB += expB ? 0x20000000 : sigB;
+ sigB = softfloat_shiftRightJam32( sigB, expDiff );
+ }
+ sigZ = 0x20000000 + sigA + sigB;
+ if ( sigZ < 0x40000000 ) {
+ --expZ;
+ sigZ <<= 1;
+ }
+ }
+ return softfloat_roundPackToF32( signZ, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN:
+ uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
+ uiZ:
+ return float32_t::fromRaw(uiZ);
+}
+
+static float64_t
+ softfloat_addMagsF64( uint_fast64_t uiA, uint_fast64_t uiB, bool signZ )
+{
+ int_fast16_t expA;
+ uint_fast64_t sigA;
+ int_fast16_t expB;
+ uint_fast64_t sigB;
+ int_fast16_t expDiff;
+ uint_fast64_t uiZ;
+ int_fast16_t expZ;
+ uint_fast64_t sigZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expA = expF64UI( uiA );
+ sigA = fracF64UI( uiA );
+ expB = expF64UI( uiB );
+ sigB = fracF64UI( uiB );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expDiff = expA - expB;
+ if ( ! expDiff ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( ! expA ) {
+ uiZ = uiA + sigB;
+ goto uiZ;
+ }
+ if ( expA == 0x7FF ) {
+ if ( sigA | sigB ) goto propagateNaN;
+ uiZ = uiA;
+ goto uiZ;
+ }
+ expZ = expA;
+ sigZ = UINT64_C( 0x0020000000000000 ) + sigA + sigB;
+ sigZ <<= 9;
+ } else {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ sigA <<= 9;
+ sigB <<= 9;
+ if ( expDiff < 0 ) {
+ if ( expB == 0x7FF ) {
+ if ( sigB ) goto propagateNaN;
+ uiZ = packToF64UI( signZ, 0x7FF, 0 );
+ goto uiZ;
+ }
+ expZ = expB;
+ if ( expA ) {
+ sigA += UINT64_C( 0x2000000000000000 );
+ } else {
+ sigA <<= 1;
+ }
+ sigA = softfloat_shiftRightJam64( sigA, -expDiff );
+ } else {
+ if ( expA == 0x7FF ) {
+ if ( sigA ) goto propagateNaN;
+ uiZ = uiA;
+ goto uiZ;
+ }
+ expZ = expA;
+ if ( expB ) {
+ sigB += UINT64_C( 0x2000000000000000 );
+ } else {
+ sigB <<= 1;
+ }
+ sigB = softfloat_shiftRightJam64( sigB, expDiff );
+ }
+ sigZ = UINT64_C( 0x2000000000000000 ) + sigA + sigB;
+ if ( sigZ < UINT64_C( 0x4000000000000000 ) ) {
+ --expZ;
+ sigZ <<= 1;
+ }
+ }
+ return softfloat_roundPackToF64( signZ, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN:
+ uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
+ uiZ:
+ return float64_t::fromRaw(uiZ);
+}
+
+static uint32_t softfloat_approxRecipSqrt32_1( unsigned int oddExpA, uint32_t a )
+{
+ int index;
+ uint16_t eps, r0;
+ uint_fast32_t ESqrR0;
+ uint32_t sigma0;
+ uint_fast32_t r;
+ uint32_t sqrSigma0;
+
+ index = (a>>27 & 0xE) + oddExpA;
+ eps = (uint16_t) (a>>12);
+ r0 = softfloat_approxRecipSqrt_1k0s[index]
+ - ((softfloat_approxRecipSqrt_1k1s[index] * (uint_fast32_t) eps)
+ >>20);
+ ESqrR0 = (uint_fast32_t) r0 * r0;
+ if ( ! oddExpA ) ESqrR0 <<= 1;
+ sigma0 = ~(uint_fast32_t) (((uint32_t) ESqrR0 * (uint_fast64_t) a)>>23);
+ r = (uint_fast32_t)(((uint_fast32_t) r0<<16) + ((r0 * (uint_fast64_t) sigma0)>>25)); //fixed warning on type cast
+ sqrSigma0 = ((uint_fast64_t) sigma0 * sigma0)>>32;
+ r += ((uint32_t) ((r>>1) + (r>>3) - ((uint_fast32_t) r0<<14))
+ * (uint_fast64_t) sqrSigma0)
+ >>48;
+ if ( ! (r & 0x80000000) ) r = 0x80000000;
+ return r;
+}
+
+/*----------------------------------------------------------------------------
+| Converts the common NaN pointed to by `aPtr' into a 32-bit floating-point
+| NaN, and returns the bit pattern of this value as an unsigned integer.
+*----------------------------------------------------------------------------*/
+static uint_fast32_t softfloat_commonNaNToF32UI( const struct commonNaN *aPtr )
+{
+ return (uint_fast32_t) aPtr->sign<<31 | 0x7FC00000 | aPtr->v64>>41;
+}
+
+/*----------------------------------------------------------------------------
+| Converts the common NaN pointed to by `aPtr' into a 64-bit floating-point
+| NaN, and returns the bit pattern of this value as an unsigned integer.
+*----------------------------------------------------------------------------*/
+static uint_fast64_t softfloat_commonNaNToF64UI( const struct commonNaN *aPtr )
+{
+ return
+ (uint_fast64_t) aPtr->sign<<63 | UINT64_C( 0x7FF8000000000000 )
+ | aPtr->v64>>12;
+}
+
+static uint_fast8_t softfloat_countLeadingZeros64( uint64_t a )
+{
+ uint_fast8_t count;
+ uint32_t a32;
+
+ count = 0;
+ a32 = a>>32;
+ if ( ! a32 ) {
+ count = 32;
+ a32 = (uint32_t) a; //fixed warning on type cast
+ }
+ /*------------------------------------------------------------------------
+ | From here, result is current count + count leading zeros of `a32'.
+ *------------------------------------------------------------------------*/
+ if ( a32 < 0x10000 ) {
+ count += 16;
+ a32 <<= 16;
+ }
+ if ( a32 < 0x1000000 ) {
+ count += 8;
+ a32 <<= 8;
+ }
+ count += softfloat_countLeadingZeros8[a32>>24];
+ return count;
+}
+
+/*----------------------------------------------------------------------------
+| Assuming `uiA' has the bit pattern of a 32-bit floating-point NaN, converts
+| this NaN to the common NaN form, and stores the resulting common NaN at the
+| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
+| exception is raised.
+*----------------------------------------------------------------------------*/
+static void softfloat_f32UIToCommonNaN( uint_fast32_t uiA, struct commonNaN *zPtr )
+{
+ if ( softfloat_isSigNaNF32UI( uiA ) ) {
+ raiseFlags( flag_invalid );
+ }
+ zPtr->sign = (uiA>>31) != 0;
+ zPtr->v64 = (uint_fast64_t) uiA<<41;
+ zPtr->v0 = 0;
+}
+
+/*----------------------------------------------------------------------------
+| Assuming `uiA' has the bit pattern of a 64-bit floating-point NaN, converts
+| this NaN to the common NaN form, and stores the resulting common NaN at the
+| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
+| exception is raised.
+*----------------------------------------------------------------------------*/
+static void softfloat_f64UIToCommonNaN( uint_fast64_t uiA, struct commonNaN *zPtr )
+{
+ if ( softfloat_isSigNaNF64UI( uiA ) ) {
+ raiseFlags( flag_invalid );
+ }
+ zPtr->sign = (uiA>>63) != 0;
+ zPtr->v64 = uiA<<12;
+ zPtr->v0 = 0;
+}
+
+static struct uint128 softfloat_mul64To128( uint64_t a, uint64_t b )
+{
+ uint32_t a32, a0, b32, b0;
+ struct uint128 z;
+ uint64_t mid1, mid;
+
+ a32 = a>>32;
+ a0 = (uint32_t)a; //fixed warning on type cast
+ b32 = b>>32;
+ b0 = (uint32_t) b; //fixed warning on type cast
+ z.v0 = (uint_fast64_t) a0 * b0;
+ mid1 = (uint_fast64_t) a32 * b0;
+ mid = mid1 + (uint_fast64_t) a0 * b32;
+ z.v64 = (uint_fast64_t) a32 * b32;
+ z.v64 += (uint_fast64_t) (mid < mid1)<<32 | mid>>32;
+ mid <<= 32;
+ z.v0 += mid;
+ z.v64 += (z.v0 < mid);
+ return z;
+}
+
+static float32_t
+ softfloat_mulAddF32(
+ uint_fast32_t uiA, uint_fast32_t uiB, uint_fast32_t uiC, uint_fast8_t op )
+{
+ bool signA;
+ int_fast16_t expA;
+ uint_fast32_t sigA;
+ bool signB;
+ int_fast16_t expB;
+ uint_fast32_t sigB;
+ bool signC;
+ int_fast16_t expC;
+ uint_fast32_t sigC;
+ bool signProd;
+ uint_fast32_t magBits, uiZ;
+ struct exp16_sig32 normExpSig;
+ int_fast16_t expProd;
+ uint_fast64_t sigProd;
+ bool signZ;
+ int_fast16_t expZ;
+ uint_fast32_t sigZ;
+ int_fast16_t expDiff;
+ uint_fast64_t sig64Z, sig64C;
+ int_fast8_t shiftDist;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ signA = signF32UI( uiA );
+ expA = expF32UI( uiA );
+ sigA = fracF32UI( uiA );
+ signB = signF32UI( uiB );
+ expB = expF32UI( uiB );
+ sigB = fracF32UI( uiB );
+ signC = signF32UI( uiC ) ^ (op == softfloat_mulAdd_subC);
+ expC = expF32UI( uiC );
+ sigC = fracF32UI( uiC );
+ signProd = signA ^ signB ^ (op == softfloat_mulAdd_subProd);
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA == 0xFF ) {
+ if ( sigA || ((expB == 0xFF) && sigB) ) goto propagateNaN_ABC;
+ magBits = expB | sigB;
+ goto infProdArg;
+ }
+ if ( expB == 0xFF ) {
+ if ( sigB ) goto propagateNaN_ABC;
+ magBits = expA | sigA;
+ goto infProdArg;
+ }
+ if ( expC == 0xFF ) {
+ if ( sigC ) {
+ uiZ = 0;
+ goto propagateNaN_ZC;
+ }
+ uiZ = uiC;
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! expA ) {
+ if ( ! sigA ) goto zeroProd;
+ normExpSig = softfloat_normSubnormalF32Sig( sigA );
+ expA = normExpSig.exp;
+ sigA = normExpSig.sig;
+ }
+ if ( ! expB ) {
+ if ( ! sigB ) goto zeroProd;
+ normExpSig = softfloat_normSubnormalF32Sig( sigB );
+ expB = normExpSig.exp;
+ sigB = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expProd = expA + expB - 0x7E;
+ sigA = (sigA | 0x00800000)<<7;
+ sigB = (sigB | 0x00800000)<<7;
+ sigProd = (uint_fast64_t) sigA * sigB;
+ if ( sigProd < UINT64_C( 0x2000000000000000 ) ) {
+ --expProd;
+ sigProd <<= 1;
+ }
+ signZ = signProd;
+ if ( ! expC ) {
+ if ( ! sigC ) {
+ expZ = expProd - 1;
+ sigZ = (uint_fast32_t) softfloat_shortShiftRightJam64( sigProd, 31 ); //fixed warning on type cast
+ goto roundPack;
+ }
+ normExpSig = softfloat_normSubnormalF32Sig( sigC );
+ expC = normExpSig.exp;
+ sigC = normExpSig.sig;
+ }
+ sigC = (sigC | 0x00800000)<<6;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expDiff = expProd - expC;
+ if ( signProd == signC ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( expDiff <= 0 ) {
+ expZ = expC;
+ sigZ = sigC + (uint_fast32_t) softfloat_shiftRightJam64( sigProd, 32 - expDiff ); //fixed warning on type cast
+ } else {
+ expZ = expProd;
+ sig64Z =
+ sigProd
+ + softfloat_shiftRightJam64(
+ (uint_fast64_t) sigC<<32, expDiff );
+ sigZ = (uint_fast32_t) softfloat_shortShiftRightJam64( sig64Z, 32 ); //fixed warning on type cast
+ }
+ if ( sigZ < 0x40000000 ) {
+ --expZ;
+ sigZ <<= 1;
+ }
+ } else {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ sig64C = (uint_fast64_t) sigC<<32;
+ if ( expDiff < 0 ) {
+ signZ = signC;
+ expZ = expC;
+ sig64Z = sig64C - softfloat_shiftRightJam64( sigProd, -expDiff );
+ } else if ( ! expDiff ) {
+ expZ = expProd;
+ sig64Z = sigProd - sig64C;
+ if ( ! sig64Z ) goto completeCancellation;
+ if ( sig64Z & UINT64_C( 0x8000000000000000 ) ) {
+ signZ = ! signZ;
+ //fixed unsigned unary minus: -x == ~x + 1
+ sig64Z = ~sig64Z + 1;
+ }
+ } else {
+ expZ = expProd;
+ sig64Z = sigProd - softfloat_shiftRightJam64( sig64C, expDiff );
+ }
+ shiftDist = softfloat_countLeadingZeros64( sig64Z ) - 1;
+ expZ -= shiftDist;
+ shiftDist -= 32;
+ if ( shiftDist < 0 ) {
+ sigZ = (uint_fast32_t) softfloat_shortShiftRightJam64( sig64Z, -shiftDist ); //fixed warning on type cast
+ } else {
+ sigZ = (uint_fast32_t) sig64Z<<shiftDist;
+ }
+ }
+ roundPack:
+ return softfloat_roundPackToF32( signZ, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN_ABC:
+ uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
+ goto propagateNaN_ZC;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ infProdArg:
+ if ( magBits ) {
+ uiZ = packToF32UI( signProd, 0xFF, 0 );
+ if ( expC != 0xFF ) goto uiZ;
+ if ( sigC ) goto propagateNaN_ZC;
+ if ( signProd == signC ) goto uiZ;
+ }
+ raiseFlags( flag_invalid );
+ uiZ = defaultNaNF32UI;
+ propagateNaN_ZC:
+ uiZ = softfloat_propagateNaNF32UI( uiZ, uiC );
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ zeroProd:
+ uiZ = uiC;
+ if ( ! (expC | sigC) && (signProd != signC) ) {
+ completeCancellation:
+ uiZ =
+ packToF32UI((globalRoundingMode == round_min), 0, 0 );
+ }
+ uiZ:
+ return float32_t::fromRaw(uiZ);
+}
+
+static float64_t
+ softfloat_mulAddF64(
+ uint_fast64_t uiA, uint_fast64_t uiB, uint_fast64_t uiC, uint_fast8_t op )
+{
+ bool signA;
+ int_fast16_t expA;
+ uint_fast64_t sigA;
+ bool signB;
+ int_fast16_t expB;
+ uint_fast64_t sigB;
+ bool signC;
+ int_fast16_t expC;
+ uint_fast64_t sigC;
+ bool signZ;
+ uint_fast64_t magBits, uiZ;
+ struct exp16_sig64 normExpSig;
+ int_fast16_t expZ;
+ struct uint128 sig128Z;
+ uint_fast64_t sigZ;
+ int_fast16_t expDiff;
+ struct uint128 sig128C;
+ int_fast8_t shiftDist;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ signA = signF64UI( uiA );
+ expA = expF64UI( uiA );
+ sigA = fracF64UI( uiA );
+ signB = signF64UI( uiB );
+ expB = expF64UI( uiB );
+ sigB = fracF64UI( uiB );
+ signC = signF64UI( uiC ) ^ (op == softfloat_mulAdd_subC);
+ expC = expF64UI( uiC );
+ sigC = fracF64UI( uiC );
+ signZ = signA ^ signB ^ (op == softfloat_mulAdd_subProd);
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA == 0x7FF ) {
+ if ( sigA || ((expB == 0x7FF) && sigB) ) goto propagateNaN_ABC;
+ magBits = expB | sigB;
+ goto infProdArg;
+ }
+ if ( expB == 0x7FF ) {
+ if ( sigB ) goto propagateNaN_ABC;
+ magBits = expA | sigA;
+ goto infProdArg;
+ }
+ if ( expC == 0x7FF ) {
+ if ( sigC ) {
+ uiZ = 0;
+ goto propagateNaN_ZC;
+ }
+ uiZ = uiC;
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! expA ) {
+ if ( ! sigA ) goto zeroProd;
+ normExpSig = softfloat_normSubnormalF64Sig( sigA );
+ expA = normExpSig.exp;
+ sigA = normExpSig.sig;
+ }
+ if ( ! expB ) {
+ if ( ! sigB ) goto zeroProd;
+ normExpSig = softfloat_normSubnormalF64Sig( sigB );
+ expB = normExpSig.exp;
+ sigB = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expZ = expA + expB - 0x3FE;
+ sigA = (sigA | UINT64_C( 0x0010000000000000 ))<<10;
+ sigB = (sigB | UINT64_C( 0x0010000000000000 ))<<10;
+ sig128Z = softfloat_mul64To128( sigA, sigB );
+ if ( sig128Z.v64 < UINT64_C( 0x2000000000000000 ) ) {
+ --expZ;
+ sig128Z =
+ softfloat_add128(
+ sig128Z.v64, sig128Z.v0, sig128Z.v64, sig128Z.v0 );
+ }
+ if ( ! expC ) {
+ if ( ! sigC ) {
+ --expZ;
+ sigZ = sig128Z.v64<<1 | (sig128Z.v0 != 0);
+ goto roundPack;
+ }
+ normExpSig = softfloat_normSubnormalF64Sig( sigC );
+ expC = normExpSig.exp;
+ sigC = normExpSig.sig;
+ }
+ sigC = (sigC | UINT64_C( 0x0010000000000000 ))<<9;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ //fixed initialization
+ sig128C.v0 = sig128C.v64 = 0;
+ expDiff = expZ - expC;
+ if ( expDiff < 0 ) {
+ expZ = expC;
+ if ( (signZ == signC) || (expDiff < -1) ) {
+ sig128Z.v64 = softfloat_shiftRightJam64( sig128Z.v64, -expDiff );
+ } else {
+ sig128Z =
+ softfloat_shortShiftRightJam128( sig128Z.v64, sig128Z.v0, 1 );
+ }
+ } else if ( expDiff ) {
+ sig128C = softfloat_shiftRightJam128( sigC, 0, expDiff );
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( signZ == signC ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( expDiff <= 0 ) {
+ sigZ = (sigC + sig128Z.v64) | (sig128Z.v0 != 0);
+ } else {
+ sig128Z =
+ softfloat_add128(
+ sig128Z.v64, sig128Z.v0, sig128C.v64, sig128C.v0 );
+ sigZ = sig128Z.v64 | (sig128Z.v0 != 0);
+ }
+ if ( sigZ < UINT64_C( 0x4000000000000000 ) ) {
+ --expZ;
+ sigZ <<= 1;
+ }
+ } else {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( expDiff < 0 ) {
+ signZ = signC;
+ sig128Z = softfloat_sub128( sigC, 0, sig128Z.v64, sig128Z.v0 );
+ } else if ( ! expDiff ) {
+ sig128Z.v64 = sig128Z.v64 - sigC;
+ if ( ! (sig128Z.v64 | sig128Z.v0) ) goto completeCancellation;
+ if ( sig128Z.v64 & UINT64_C( 0x8000000000000000 ) ) {
+ signZ = ! signZ;
+ sig128Z = softfloat_sub128( 0, 0, sig128Z.v64, sig128Z.v0 );
+ }
+ } else {
+ sig128Z =
+ softfloat_sub128(
+ sig128Z.v64, sig128Z.v0, sig128C.v64, sig128C.v0 );
+ }
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( ! sig128Z.v64 ) {
+ expZ -= 64;
+ sig128Z.v64 = sig128Z.v0;
+ sig128Z.v0 = 0;
+ }
+ shiftDist = softfloat_countLeadingZeros64( sig128Z.v64 ) - 1;
+ expZ -= shiftDist;
+ if ( shiftDist < 0 ) {
+ sigZ = softfloat_shortShiftRightJam64( sig128Z.v64, -shiftDist );
+ } else {
+ sig128Z =
+ softfloat_shortShiftLeft128(
+ sig128Z.v64, sig128Z.v0, shiftDist );
+ sigZ = sig128Z.v64;
+ }
+ sigZ |= (sig128Z.v0 != 0);
+ }
+ roundPack:
+ return softfloat_roundPackToF64( signZ, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN_ABC:
+ uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
+ goto propagateNaN_ZC;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ infProdArg:
+ if ( magBits ) {
+ uiZ = packToF64UI( signZ, 0x7FF, 0 );
+ if ( expC != 0x7FF ) goto uiZ;
+ if ( sigC ) goto propagateNaN_ZC;
+ if ( signZ == signC ) goto uiZ;
+ }
+ raiseFlags( flag_invalid );
+ uiZ = defaultNaNF64UI;
+ propagateNaN_ZC:
+ uiZ = softfloat_propagateNaNF64UI( uiZ, uiC );
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ zeroProd:
+ uiZ = uiC;
+ if ( ! (expC | sigC) && (signZ != signC) ) {
+ completeCancellation:
+ uiZ =
+ packToF64UI((globalRoundingMode == round_min), 0, 0 );
+ }
+ uiZ:
+ return float64_t::fromRaw(uiZ);
+}
+
+static float32_t
+ softfloat_normRoundPackToF32( bool sign, int_fast16_t exp, uint_fast32_t sig )
+{
+ int_fast8_t shiftDist;
+
+ shiftDist = softfloat_countLeadingZeros32( sig ) - 1;
+ exp -= shiftDist;
+ if ( (7 <= shiftDist) && ((unsigned int) exp < 0xFD) ) {
+ return float32_t::fromRaw(packToF32UI( sign, sig ? exp : 0, sig<<(shiftDist - 7) ));
+ } else {
+ return softfloat_roundPackToF32( sign, exp, sig<<shiftDist );
+ }
+}
+
+static float64_t
+ softfloat_normRoundPackToF64( bool sign, int_fast16_t exp, uint_fast64_t sig )
+{
+ int_fast8_t shiftDist;
+
+ shiftDist = softfloat_countLeadingZeros64( sig ) - 1;
+ exp -= shiftDist;
+ if ( (10 <= shiftDist) && ((unsigned int) exp < 0x7FD) ) {
+ return float64_t::fromRaw(packToF64UI( sign, sig ? exp : 0, sig<<(shiftDist - 10) ));
+ } else {
+ return softfloat_roundPackToF64( sign, exp, sig<<shiftDist );
+ }
+}
+
+static struct exp16_sig32 softfloat_normSubnormalF32Sig( uint_fast32_t sig )
+{
+ int_fast8_t shiftDist;
+ struct exp16_sig32 z;
+
+ shiftDist = softfloat_countLeadingZeros32( sig ) - 8;
+ z.exp = 1 - shiftDist;
+ z.sig = sig<<shiftDist;
+ return z;
+}
+
+static struct exp16_sig64 softfloat_normSubnormalF64Sig( uint_fast64_t sig )
+{
+ int_fast8_t shiftDist;
+ struct exp16_sig64 z;
+
+ shiftDist = softfloat_countLeadingZeros64( sig ) - 11;
+ z.exp = 1 - shiftDist;
+ z.sig = sig<<shiftDist;
+ return z;
+}
+
+/*----------------------------------------------------------------------------
+| Interpreting `uiA' and `uiB' as the bit patterns of two 32-bit floating-
+| point values, at least one of which is a NaN, returns the bit pattern of
+| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
+| signaling NaN, the invalid exception is raised.
+*----------------------------------------------------------------------------*/
+static uint_fast32_t
+ softfloat_propagateNaNF32UI( uint_fast32_t uiA, uint_fast32_t uiB )
+{
+ bool isSigNaNA;
+
+ isSigNaNA = softfloat_isSigNaNF32UI( uiA );
+ if ( isSigNaNA || softfloat_isSigNaNF32UI( uiB ) ) {
+ raiseFlags( flag_invalid );
+ if ( isSigNaNA ) return uiA | 0x00400000;
+ }
+ return (isNaNF32UI( uiA ) ? uiA : uiB) | 0x00400000;
+}
+
+/*----------------------------------------------------------------------------
+| Interpreting `uiA' and `uiB' as the bit patterns of two 64-bit floating-
+| point values, at least one of which is a NaN, returns the bit pattern of
+| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
+| signaling NaN, the invalid exception is raised.
+*----------------------------------------------------------------------------*/
+static uint_fast64_t
+ softfloat_propagateNaNF64UI( uint_fast64_t uiA, uint_fast64_t uiB )
+{
+ bool isSigNaNA;
+
+ isSigNaNA = softfloat_isSigNaNF64UI( uiA );
+ if ( isSigNaNA || softfloat_isSigNaNF64UI( uiB ) ) {
+ raiseFlags( flag_invalid );
+ if ( isSigNaNA ) return uiA | UINT64_C( 0x0008000000000000 );
+ }
+ return (isNaNF64UI( uiA ) ? uiA : uiB) | UINT64_C( 0x0008000000000000 );
+}
+
+static float32_t
+ softfloat_roundPackToF32( bool sign, int_fast16_t exp, uint_fast32_t sig )
+{
+ uint_fast8_t roundingMode;
+ bool roundNearEven;
+ uint_fast8_t roundIncrement, roundBits;
+ bool isTiny;
+ uint_fast32_t uiZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ roundingMode = globalRoundingMode;
+ roundNearEven = (roundingMode == round_near_even);
+ roundIncrement = 0x40;
+ if ( ! roundNearEven && (roundingMode != round_near_maxMag) ) {
+ roundIncrement =
+ (roundingMode
+ == (sign ? round_min : round_max))
+ ? 0x7F
+ : 0;
+ }
+ roundBits = sig & 0x7F;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( 0xFD <= (unsigned int) exp ) {
+ if ( exp < 0 ) {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ isTiny =
+ (globalDetectTininess == tininess_beforeRounding)
+ || (exp < -1) || (sig + roundIncrement < 0x80000000);
+ sig = softfloat_shiftRightJam32( sig, -exp );
+ exp = 0;
+ roundBits = sig & 0x7F;
+ if ( isTiny && roundBits ) {
+ raiseFlags( flag_underflow );
+ }
+ } else if ( (0xFD < exp) || (0x80000000 <= sig + roundIncrement) ) {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ raiseFlags(
+ flag_overflow | flag_inexact );
+ uiZ = packToF32UI( sign, 0xFF, 0 ) - ! roundIncrement;
+ goto uiZ;
+ }
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sig = (sig + roundIncrement)>>7;
+ if ( roundBits ) {
+ raiseFlags(flag_inexact);
+ if ( roundingMode == round_odd ) {
+ sig |= 1;
+ goto packReturn;
+ }
+ }
+ sig &= ~(uint_fast32_t) (! (roundBits ^ 0x40) & roundNearEven);
+ if ( ! sig ) exp = 0;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ packReturn:
+ uiZ = packToF32UI( sign, exp, sig );
+ uiZ:
+ return float32_t::fromRaw(uiZ);
+}
+
+static float64_t
+ softfloat_roundPackToF64( bool sign, int_fast16_t exp, uint_fast64_t sig )
+{
+ uint_fast8_t roundingMode;
+ bool roundNearEven;
+ uint_fast16_t roundIncrement, roundBits;
+ bool isTiny;
+ uint_fast64_t uiZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ roundingMode = globalRoundingMode;
+ roundNearEven = (roundingMode == round_near_even);
+ roundIncrement = 0x200;
+ if ( ! roundNearEven && (roundingMode != round_near_maxMag) ) {
+ roundIncrement =
+ (roundingMode
+ == (sign ? round_min : round_max))
+ ? 0x3FF
+ : 0;
+ }
+ roundBits = sig & 0x3FF;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( 0x7FD <= (uint16_t) exp ) {
+ if ( exp < 0 ) {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ isTiny =
+ (globalDetectTininess == tininess_beforeRounding)
+ || (exp < -1)
+ || (sig + roundIncrement < UINT64_C( 0x8000000000000000 ));
+ sig = softfloat_shiftRightJam64( sig, -exp );
+ exp = 0;
+ roundBits = sig & 0x3FF;
+ if ( isTiny && roundBits ) {
+ raiseFlags( flag_underflow );
+ }
+ } else if (
+ (0x7FD < exp)
+ || (UINT64_C( 0x8000000000000000 ) <= sig + roundIncrement)
+ ) {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ raiseFlags(
+ flag_overflow | flag_inexact );
+ uiZ = packToF64UI( sign, 0x7FF, 0 ) - ! roundIncrement;
+ goto uiZ;
+ }
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sig = (sig + roundIncrement)>>10;
+ if ( roundBits ) {
+ raiseFlags(flag_inexact);
+ if ( roundingMode == round_odd ) {
+ sig |= 1;
+ goto packReturn;
+ }
+ }
+ sig &= ~(uint_fast64_t) (! (roundBits ^ 0x200) & roundNearEven);
+ if ( ! sig ) exp = 0;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ packReturn:
+ uiZ = packToF64UI( sign, exp, sig );
+ uiZ:
+ return float64_t::fromRaw(uiZ);
+}
+
+static int_fast32_t
+ softfloat_roundToI32(
+ bool sign, uint_fast64_t sig, uint_fast8_t roundingMode, bool exact )
+{
+ bool roundNearEven;
+ uint_fast16_t roundIncrement, roundBits;
+ uint_fast32_t sig32;
+ union { uint32_t ui; int32_t i; } uZ;
+ int_fast32_t z;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ roundNearEven = (roundingMode == round_near_even);
+ roundIncrement = 0x800;
+ if ( ! roundNearEven && (roundingMode != round_near_maxMag) ) {
+ roundIncrement =
+ (roundingMode
+ == (sign ? round_min : round_max))
+ ? 0xFFF
+ : 0;
+ }
+ roundBits = sig & 0xFFF;
+ sig += roundIncrement;
+ if ( sig & UINT64_C( 0xFFFFF00000000000 ) ) goto invalid;
+ sig32 = (uint_fast32_t)(sig>>12); //fixed warning on type cast
+ sig32 &= ~(uint_fast32_t) (! (roundBits ^ 0x800) & roundNearEven);
+ //fixed unsigned unary minus: -x == ~x + 1
+ uZ.ui = sign ? (~sig32 + 1) : sig32;
+ z = uZ.i;
+ if ( z && ((z < 0) ^ sign) ) goto invalid;
+ if ( exact && roundBits ) {
+ raiseFlags(flag_inexact);
+ }
+ return z;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ invalid:
+ raiseFlags( flag_invalid );
+ return sign ? i32_fromNegOverflow : i32_fromPosOverflow;
+}
+
+static struct uint128
+ softfloat_shiftRightJam128( uint64_t a64, uint64_t a0, uint_fast32_t dist )
+{
+ uint_fast8_t u8NegDist;
+ struct uint128 z;
+
+ if ( dist < 64 ) {
+ //fixed unsigned unary minus: -x == ~x + 1 , fixed type cast
+ u8NegDist = (uint_fast8_t)(~dist + 1);
+ z.v64 = a64>>dist;
+ z.v0 =
+ a64<<(u8NegDist & 63) | a0>>dist
+ | ((uint64_t) (a0<<(u8NegDist & 63)) != 0);
+ } else {
+ z.v64 = 0;
+ z.v0 =
+ (dist < 127)
+ ? a64>>(dist & 63)
+ | (((a64 & (((uint_fast64_t) 1<<(dist & 63)) - 1)) | a0)
+ != 0)
+ : ((a64 | a0) != 0);
+ }
+ return z;
+}
+
+static float32_t softfloat_subMagsF32( uint_fast32_t uiA, uint_fast32_t uiB )
+{
+ int_fast16_t expA;
+ uint_fast32_t sigA;
+ int_fast16_t expB;
+ uint_fast32_t sigB;
+ int_fast16_t expDiff;
+ uint_fast32_t uiZ;
+ int_fast32_t sigDiff;
+ bool signZ;
+ int_fast8_t shiftDist;
+ int_fast16_t expZ;
+ uint_fast32_t sigX, sigY;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expA = expF32UI( uiA );
+ sigA = fracF32UI( uiA );
+ expB = expF32UI( uiB );
+ sigB = fracF32UI( uiB );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expDiff = expA - expB;
+ if ( ! expDiff ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( expA == 0xFF ) {
+ if ( sigA | sigB ) goto propagateNaN;
+ raiseFlags( flag_invalid );
+ uiZ = defaultNaNF32UI;
+ goto uiZ;
+ }
+ sigDiff = sigA - sigB;
+ if ( ! sigDiff ) {
+ uiZ =
+ packToF32UI(
+ (globalRoundingMode == round_min), 0, 0 );
+ goto uiZ;
+ }
+ if ( expA ) --expA;
+ signZ = signF32UI( uiA );
+ if ( sigDiff < 0 ) {
+ signZ = ! signZ;
+ sigDiff = -sigDiff;
+ }
+ shiftDist = softfloat_countLeadingZeros32( sigDiff ) - 8;
+ expZ = expA - shiftDist;
+ if ( expZ < 0 ) {
+ shiftDist = (int_fast8_t)expA; //fixed type cast
+ expZ = 0;
+ }
+ uiZ = packToF32UI( signZ, expZ, sigDiff<<shiftDist );
+ goto uiZ;
+ } else {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ signZ = signF32UI( uiA );
+ sigA <<= 7;
+ sigB <<= 7;
+ if ( expDiff < 0 ) {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ signZ = ! signZ;
+ if ( expB == 0xFF ) {
+ if ( sigB ) goto propagateNaN;
+ uiZ = packToF32UI( signZ, 0xFF, 0 );
+ goto uiZ;
+ }
+ expZ = expB - 1;
+ sigX = sigB | 0x40000000;
+ sigY = sigA + (expA ? 0x40000000 : sigA);
+ expDiff = -expDiff;
+ } else {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ if ( expA == 0xFF ) {
+ if ( sigA ) goto propagateNaN;
+ uiZ = uiA;
+ goto uiZ;
+ }
+ expZ = expA - 1;
+ sigX = sigA | 0x40000000;
+ sigY = sigB + (expB ? 0x40000000 : sigB);
+ }
+ return
+ softfloat_normRoundPackToF32(
+ signZ, expZ, sigX - softfloat_shiftRightJam32( sigY, expDiff )
+ );
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN:
+ uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
+ uiZ:
+ return float32_t::fromRaw(uiZ);
+}
+
+static float64_t
+ softfloat_subMagsF64( uint_fast64_t uiA, uint_fast64_t uiB, bool signZ )
+{
+ int_fast16_t expA;
+ uint_fast64_t sigA;
+ int_fast16_t expB;
+ uint_fast64_t sigB;
+ int_fast16_t expDiff;
+ uint_fast64_t uiZ;
+ int_fast64_t sigDiff;
+ int_fast8_t shiftDist;
+ int_fast16_t expZ;
+ uint_fast64_t sigZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expA = expF64UI( uiA );
+ sigA = fracF64UI( uiA );
+ expB = expF64UI( uiB );
+ sigB = fracF64UI( uiB );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expDiff = expA - expB;
+ if ( ! expDiff ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( expA == 0x7FF ) {
+ if ( sigA | sigB ) goto propagateNaN;
+ raiseFlags( flag_invalid );
+ uiZ = defaultNaNF64UI;
+ goto uiZ;
+ }
+ sigDiff = sigA - sigB;
+ if ( ! sigDiff ) {
+ uiZ =
+ packToF64UI(
+ (globalRoundingMode == round_min), 0, 0 );
+ goto uiZ;
+ }
+ if ( expA ) --expA;
+ if ( sigDiff < 0 ) {
+ signZ = ! signZ;
+ sigDiff = -sigDiff;
+ }
+ shiftDist = softfloat_countLeadingZeros64( sigDiff ) - 11;
+ expZ = expA - shiftDist;
+ if ( expZ < 0 ) {
+ shiftDist = (int_fast8_t)expA; //fixed type cast
+ expZ = 0;
+ }
+ uiZ = packToF64UI( signZ, expZ, sigDiff<<shiftDist );
+ goto uiZ;
+ } else {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ sigA <<= 10;
+ sigB <<= 10;
+ if ( expDiff < 0 ) {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ signZ = ! signZ;
+ if ( expB == 0x7FF ) {
+ if ( sigB ) goto propagateNaN;
+ uiZ = packToF64UI( signZ, 0x7FF, 0 );
+ goto uiZ;
+ }
+ sigA += expA ? UINT64_C( 0x4000000000000000 ) : sigA;
+ sigA = softfloat_shiftRightJam64( sigA, -expDiff );
+ sigB |= UINT64_C( 0x4000000000000000 );
+ expZ = expB;
+ sigZ = sigB - sigA;
+ } else {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ if ( expA == 0x7FF ) {
+ if ( sigA ) goto propagateNaN;
+ uiZ = uiA;
+ goto uiZ;
+ }
+ sigB += expB ? UINT64_C( 0x4000000000000000 ) : sigB;
+ sigB = softfloat_shiftRightJam64( sigB, expDiff );
+ sigA |= UINT64_C( 0x4000000000000000 );
+ expZ = expA;
+ sigZ = sigA - sigB;
+ }
+ return softfloat_normRoundPackToF64( signZ, expZ - 1, sigZ );
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN:
+ uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
+ uiZ:
+ return float64_t::fromRaw(uiZ);
+}
+
+static float32_t ui32_to_f32( uint32_t a )
+{
+ if ( ! a ) {
+ return float32_t::fromRaw(0);
+ }
+ if ( a & 0x80000000 ) {
+ return softfloat_roundPackToF32( 0, 0x9D, a>>1 | (a & 1) );
+ } else {
+ return softfloat_normRoundPackToF32( 0, 0x9C, a );
+ }
+}
+
+static float64_t ui32_to_f64( uint32_t a )
+{
+ uint_fast64_t uiZ;
+ int_fast8_t shiftDist;
+
+ if ( ! a ) {
+ uiZ = 0;
+ } else {
+ shiftDist = softfloat_countLeadingZeros32( a ) + 21;
+ uiZ =
+ packToF64UI( 0, 0x432 - shiftDist, (uint_fast64_t) a<<shiftDist );
+ }
+ return float64_t::fromRaw(uiZ);
+}
+
+static float32_t ui64_to_f32( uint64_t a )
+{
+ int_fast8_t shiftDist;
+ uint_fast32_t sig;
+
+ shiftDist = softfloat_countLeadingZeros64( a ) - 40;
+ if ( 0 <= shiftDist ) {
+ return float32_t::fromRaw(a ? packToF32UI(0, 0x95 - shiftDist, (uint_fast32_t) a<<shiftDist ) : 0);
+ } else {
+ shiftDist += 7;
+ sig =
+ (shiftDist < 0) ? (uint_fast32_t) softfloat_shortShiftRightJam64( a, -shiftDist ) //fixed warning on type cast
+ : (uint_fast32_t) a<<shiftDist;
+ return softfloat_roundPackToF32( 0, 0x9C - shiftDist, sig );
+ }
+}
+
+static float64_t ui64_to_f64( uint64_t a )
+{
+ if ( ! a ) {
+ return float64_t::fromRaw(0);
+ }
+ if ( a & UINT64_C( 0x8000000000000000 ) ) {
+ return
+ softfloat_roundPackToF64(
+ 0, 0x43D, softfloat_shortShiftRightJam64( a, 1 ) );
+ } else {
+ return softfloat_normRoundPackToF64( 0, 0x43C, a );
+ }
+}
+
+/*----------------------------------------------------------------------------
+| Ported from OpenCV.
+*----------------------------------------------------------------------------*/
+
+////////////////////////////////////// EXP /////////////////////////////////////
+
+#define EXPTAB_SCALE 6
+#define EXPTAB_MASK ((1 << EXPTAB_SCALE) - 1)
+
+// .9670371139572337719125840413672004409288e-2
+static const softdouble EXPPOLY_32F_A0 = float64_t::fromRaw(0x3f83ce0f3e46f431);
+
+static const uint64_t expTab[] = {
+ 0x3ff0000000000000, // 1.000000
+ 0x3ff02c9a3e778061, // 1.010889
+ 0x3ff059b0d3158574, // 1.021897
+ 0x3ff0874518759bc8, // 1.033025
+ 0x3ff0b5586cf9890f, // 1.044274
+ 0x3ff0e3ec32d3d1a2, // 1.055645
+ 0x3ff11301d0125b51, // 1.067140
+ 0x3ff1429aaea92de0, // 1.078761
+ 0x3ff172b83c7d517b, // 1.090508
+ 0x3ff1a35beb6fcb75, // 1.102383
+ 0x3ff1d4873168b9aa, // 1.114387
+ 0x3ff2063b88628cd6, // 1.126522
+ 0x3ff2387a6e756238, // 1.138789
+ 0x3ff26b4565e27cdd, // 1.151189
+ 0x3ff29e9df51fdee1, // 1.163725
+ 0x3ff2d285a6e4030b, // 1.176397
+ 0x3ff306fe0a31b715, // 1.189207
+ 0x3ff33c08b26416ff, // 1.202157
+ 0x3ff371a7373aa9cb, // 1.215247
+ 0x3ff3a7db34e59ff7, // 1.228481
+ 0x3ff3dea64c123422, // 1.241858
+ 0x3ff4160a21f72e2a, // 1.255381
+ 0x3ff44e086061892d, // 1.269051
+ 0x3ff486a2b5c13cd0, // 1.282870
+ 0x3ff4bfdad5362a27, // 1.296840
+ 0x3ff4f9b2769d2ca7, // 1.310961
+ 0x3ff5342b569d4f82, // 1.325237
+ 0x3ff56f4736b527da, // 1.339668
+ 0x3ff5ab07dd485429, // 1.354256
+ 0x3ff5e76f15ad2148, // 1.369002
+ 0x3ff6247eb03a5585, // 1.383910
+ 0x3ff6623882552225, // 1.398980
+ 0x3ff6a09e667f3bcd, // 1.414214
+ 0x3ff6dfb23c651a2f, // 1.429613
+ 0x3ff71f75e8ec5f74, // 1.445181
+ 0x3ff75feb564267c9, // 1.460918
+ 0x3ff7a11473eb0187, // 1.476826
+ 0x3ff7e2f336cf4e62, // 1.492908
+ 0x3ff82589994cce13, // 1.509164
+ 0x3ff868d99b4492ed, // 1.525598
+ 0x3ff8ace5422aa0db, // 1.542211
+ 0x3ff8f1ae99157736, // 1.559004
+ 0x3ff93737b0cdc5e5, // 1.575981
+ 0x3ff97d829fde4e50, // 1.593142
+ 0x3ff9c49182a3f090, // 1.610490
+ 0x3ffa0c667b5de565, // 1.628027
+ 0x3ffa5503b23e255d, // 1.645755
+ 0x3ffa9e6b5579fdbf, // 1.663677
+ 0x3ffae89f995ad3ad, // 1.681793
+ 0x3ffb33a2b84f15fb, // 1.700106
+ 0x3ffb7f76f2fb5e47, // 1.718619
+ 0x3ffbcc1e904bc1d2, // 1.737334
+ 0x3ffc199bdd85529c, // 1.756252
+ 0x3ffc67f12e57d14b, // 1.775376
+ 0x3ffcb720dcef9069, // 1.794709
+ 0x3ffd072d4a07897c, // 1.814252
+ 0x3ffd5818dcfba487, // 1.834008
+ 0x3ffda9e603db3285, // 1.853979
+ 0x3ffdfc97337b9b5f, // 1.874168
+ 0x3ffe502ee78b3ff6, // 1.894576
+ 0x3ffea4afa2a490da, // 1.915207
+ 0x3ffefa1bee615a27, // 1.936062
+ 0x3fff50765b6e4540, // 1.957144
+ 0x3fffa7c1819e90d8, // 1.978456
+};
+
+// 1 / ln(2) * (1 << EXPTAB_SCALE) == 1.4426950408889634073599246810019 * (1 << EXPTAB_SCALE)
+static const float64_t exp_prescale = float64_t::fromRaw(0x3ff71547652b82fe) * float64_t(1 << EXPTAB_SCALE);
+static const float64_t exp_postscale = float64_t::one()/float64_t(1 << EXPTAB_SCALE);
+static const float64_t exp_max_val(3000*(1 << EXPTAB_SCALE)); // log10(DBL_MAX) < 3000
+
+static float32_t f32_exp( float32_t x)
+{
+ //special cases
+ if(x.isNaN()) return float32_t::nan();
+ if(x.isInf()) return (x == float32_t::inf()) ? x : float32_t::zero();
+
+ static const float64_t
+ A4 = float64_t::one() / EXPPOLY_32F_A0,
+ A3 = float64_t::fromRaw(0x3fe62e42fef9277b) / EXPPOLY_32F_A0, // .6931471805521448196800669615864773144641 / EXPPOLY_32F_A0,
+ A2 = float64_t::fromRaw(0x3fcebfbe081585e7) / EXPPOLY_32F_A0, // .2402265109513301490103372422686535526573 / EXPPOLY_32F_A0,
+ A1 = float64_t::fromRaw(0x3fac6af0d93cf576) / EXPPOLY_32F_A0; // .5550339366753125211915322047004666939128e-1 / EXPPOLY_32F_A0;
+
+ float64_t x0;
+ if(expF32UI(x.v) > 127 + 10)
+ x0 = signF32UI(x.v) ? -exp_max_val : exp_max_val;
+ else
+ x0 = f32_to_f64(x) * exp_prescale;
+
+ int val0 = f64_to_i32(x0, round_near_even, false);
+ int t = (val0 >> EXPTAB_SCALE) + 1023;
+ t = t < 0 ? 0 : (t > 2047 ? 2047 : t);
+ float64_t buf; buf.v = packToF64UI(0, t, 0);
+
+ x0 = (x0 - f64_roundToInt(x0, round_near_even, false)) * exp_postscale;
+
+ return (buf * EXPPOLY_32F_A0 * float64_t::fromRaw(expTab[val0 & EXPTAB_MASK]) * ((((x0 + A1)*x0 + A2)*x0 + A3)*x0 + A4));
+}
+
+static float64_t f64_exp(float64_t x)
+{
+ //special cases
+ if(x.isNaN()) return float64_t::nan();
+ if(x.isInf()) return (x == float64_t::inf()) ? x : float64_t::zero();
+
+ static const float64_t
+ A5 = float64_t::one() / EXPPOLY_32F_A0,
+ A4 = float64_t::fromRaw(0x3fe62e42fefa39f1) / EXPPOLY_32F_A0, // .69314718055994546743029643825322 / EXPPOLY_32F_A0
+ A3 = float64_t::fromRaw(0x3fcebfbdff82a45a) / EXPPOLY_32F_A0, // .24022650695886477918181338054308 / EXPPOLY_32F_A0
+ A2 = float64_t::fromRaw(0x3fac6b08d81fec75) / EXPPOLY_32F_A0, // .55504108793649567998466049042729e-1 / EXPPOLY_32F_A0
+ A1 = float64_t::fromRaw(0x3f83b2a72b4f3cd3) / EXPPOLY_32F_A0, // .96180973140732918010002372686186e-2 / EXPPOLY_32F_A0
+ A0 = float64_t::fromRaw(0x3f55e7aa1566c2a4) / EXPPOLY_32F_A0; // .13369713757180123244806654839424e-2 / EXPPOLY_32F_A0
+
+ float64_t x0;
+ if(expF64UI(x.v) > 1023 + 10)
+ x0 = signF64UI(x.v) ? -exp_max_val : exp_max_val;
+ else
+ x0 = x * exp_prescale;
+
+ int val0 = cvRound(x0);
+ int t = (val0 >> EXPTAB_SCALE) + 1023;
+ t = t < 0 ? 0 : (t > 2047 ? 2047 : t);
+ float64_t buf; buf.v = packToF64UI(0, t, 0);
+
+ x0 = (x0 - f64_roundToInt(x0, round_near_even, false)) * exp_postscale;
+
+ return buf * EXPPOLY_32F_A0 * float64_t::fromRaw(expTab[val0 & EXPTAB_MASK]) * (((((A0*x0 + A1)*x0 + A2)*x0 + A3)*x0 + A4)*x0 + A5);
+}
+
+#undef EXPTAB_SCALE
+#undef EXPTAB_MASK
+#undef EXPPOLY_32F_A0
+
+/////////////////////////////////////////// LOG ///////////////////////////////////////
+
+#define LOGTAB_SCALE 8
+
+static const uint64_t CV_DECL_ALIGNED(16) icvLogTab[] = {
+ 0, 0x3ff0000000000000, // 0.000000, 1.000000
+ 0x3f6ff00aa2b10bc0, 0x3fefe01fe01fe020, // 0.003899, 0.996109
+ 0x3f7fe02a6b106788, 0x3fefc07f01fc07f0, // 0.007782, 0.992248
+ 0x3f87dc475f810a76, 0x3fefa11caa01fa12, // 0.011651, 0.988417
+ 0x3f8fc0a8b0fc03e3, 0x3fef81f81f81f820, // 0.015504, 0.984615
+ 0x3f93cea44346a574, 0x3fef6310aca0dbb5, // 0.019343, 0.980843
+ 0x3f97b91b07d5b11a, 0x3fef44659e4a4271, // 0.023167, 0.977099
+ 0x3f9b9fc027af9197, 0x3fef25f644230ab5, // 0.026977, 0.973384
+ 0x3f9f829b0e783300, 0x3fef07c1f07c1f08, // 0.030772, 0.969697
+ 0x3fa1b0d98923d97f, 0x3feee9c7f8458e02, // 0.034552, 0.966038
+ 0x3fa39e87b9febd5f, 0x3feecc07b301ecc0, // 0.038319, 0.962406
+ 0x3fa58a5bafc8e4d4, 0x3feeae807aba01eb, // 0.042071, 0.958801
+ 0x3fa77458f632dcfc, 0x3fee9131abf0b767, // 0.045810, 0.955224
+ 0x3fa95c830ec8e3eb, 0x3fee741aa59750e4, // 0.049534, 0.951673
+ 0x3fab42dd711971be, 0x3fee573ac901e574, // 0.053245, 0.948148
+ 0x3fad276b8adb0b52, 0x3fee3a9179dc1a73, // 0.056941, 0.944649
+ 0x3faf0a30c01162a6, 0x3fee1e1e1e1e1e1e, // 0.060625, 0.941176
+ 0x3fb075983598e471, 0x3fee01e01e01e01e, // 0.064294, 0.937729
+ 0x3fb16536eea37ae0, 0x3fede5d6e3f8868a, // 0.067951, 0.934307
+ 0x3fb253f62f0a1416, 0x3fedca01dca01dca, // 0.071594, 0.930909
+ 0x3fb341d7961bd1d0, 0x3fedae6076b981db, // 0.075223, 0.927536
+ 0x3fb42edcbea646f0, 0x3fed92f2231e7f8a, // 0.078840, 0.924188
+ 0x3fb51b073f06183f, 0x3fed77b654b82c34, // 0.082444, 0.920863
+ 0x3fb60658a93750c3, 0x3fed5cac807572b2, // 0.086034, 0.917563
+ 0x3fb6f0d28ae56b4b, 0x3fed41d41d41d41d, // 0.089612, 0.914286
+ 0x3fb7da766d7b12cc, 0x3fed272ca3fc5b1a, // 0.093177, 0.911032
+ 0x3fb8c345d6319b20, 0x3fed0cb58f6ec074, // 0.096730, 0.907801
+ 0x3fb9ab42462033ac, 0x3fecf26e5c44bfc6, // 0.100269, 0.904594
+ 0x3fba926d3a4ad563, 0x3fecd85689039b0b, // 0.103797, 0.901408
+ 0x3fbb78c82bb0eda1, 0x3fecbe6d9601cbe7, // 0.107312, 0.898246
+ 0x3fbc5e548f5bc743, 0x3feca4b3055ee191, // 0.110814, 0.895105
+ 0x3fbd4313d66cb35d, 0x3fec8b265afb8a42, // 0.114305, 0.891986
+ 0x3fbe27076e2af2e5, 0x3fec71c71c71c71c, // 0.117783, 0.888889
+ 0x3fbf0a30c01162a6, 0x3fec5894d10d4986, // 0.121249, 0.885813
+ 0x3fbfec9131dbeaba, 0x3fec3f8f01c3f8f0, // 0.124703, 0.882759
+ 0x3fc0671512ca596e, 0x3fec26b5392ea01c, // 0.128146, 0.879725
+ 0x3fc0d77e7cd08e59, 0x3fec0e070381c0e0, // 0.131576, 0.876712
+ 0x3fc14785846742ac, 0x3febf583ee868d8b, // 0.134995, 0.873720
+ 0x3fc1b72ad52f67a0, 0x3febdd2b899406f7, // 0.138402, 0.870748
+ 0x3fc2266f190a5acb, 0x3febc4fd65883e7b, // 0.141798, 0.867797
+ 0x3fc29552f81ff523, 0x3febacf914c1bad0, // 0.145182, 0.864865
+ 0x3fc303d718e47fd2, 0x3feb951e2b18ff23, // 0.148555, 0.861953
+ 0x3fc371fc201e8f74, 0x3feb7d6c3dda338b, // 0.151916, 0.859060
+ 0x3fc3dfc2b0ecc629, 0x3feb65e2e3beee05, // 0.155266, 0.856187
+ 0x3fc44d2b6ccb7d1e, 0x3feb4e81b4e81b4f, // 0.158605, 0.853333
+ 0x3fc4ba36f39a55e5, 0x3feb37484ad806ce, // 0.161933, 0.850498
+ 0x3fc526e5e3a1b437, 0x3feb2036406c80d9, // 0.165250, 0.847682
+ 0x3fc59338d9982085, 0x3feb094b31d922a4, // 0.168555, 0.844884
+ 0x3fc5ff3070a793d3, 0x3feaf286bca1af28, // 0.171850, 0.842105
+ 0x3fc66acd4272ad50, 0x3feadbe87f94905e, // 0.175134, 0.839344
+ 0x3fc6d60fe719d21c, 0x3feac5701ac5701b, // 0.178408, 0.836601
+ 0x3fc740f8f54037a4, 0x3feaaf1d2f87ebfd, // 0.181670, 0.833876
+ 0x3fc7ab890210d909, 0x3fea98ef606a63be, // 0.184922, 0.831169
+ 0x3fc815c0a14357ea, 0x3fea82e65130e159, // 0.188164, 0.828479
+ 0x3fc87fa06520c910, 0x3fea6d01a6d01a6d, // 0.191395, 0.825806
+ 0x3fc8e928de886d40, 0x3fea574107688a4a, // 0.194615, 0.823151
+ 0x3fc9525a9cf456b4, 0x3fea41a41a41a41a, // 0.197826, 0.820513
+ 0x3fc9bb362e7dfb83, 0x3fea2c2a87c51ca0, // 0.201026, 0.817891
+ 0x3fca23bc1fe2b563, 0x3fea16d3f97a4b02, // 0.204216, 0.815287
+ 0x3fca8becfc882f18, 0x3fea01a01a01a01a, // 0.207395, 0.812698
+ 0x3fcaf3c94e80bff2, 0x3fe9ec8e951033d9, // 0.210565, 0.810127
+ 0x3fcb5b519e8fb5a4, 0x3fe9d79f176b682d, // 0.213724, 0.807571
+ 0x3fcbc286742d8cd6, 0x3fe9c2d14ee4a102, // 0.216874, 0.805031
+ 0x3fcc2968558c18c0, 0x3fe9ae24ea5510da, // 0.220014, 0.802508
+ 0x3fcc8ff7c79a9a21, 0x3fe999999999999a, // 0.223144, 0.800000
+ 0x3fccf6354e09c5dc, 0x3fe9852f0d8ec0ff, // 0.226264, 0.797508
+ 0x3fcd5c216b4fbb91, 0x3fe970e4f80cb872, // 0.229374, 0.795031
+ 0x3fcdc1bca0abec7d, 0x3fe95cbb0be377ae, // 0.232475, 0.792570
+ 0x3fce27076e2af2e5, 0x3fe948b0fcd6e9e0, // 0.235566, 0.790123
+ 0x3fce8c0252aa5a5f, 0x3fe934c67f9b2ce6, // 0.238648, 0.787692
+ 0x3fcef0adcbdc5936, 0x3fe920fb49d0e229, // 0.241720, 0.785276
+ 0x3fcf550a564b7b37, 0x3fe90d4f120190d5, // 0.244783, 0.782875
+ 0x3fcfb9186d5e3e2a, 0x3fe8f9c18f9c18fa, // 0.247836, 0.780488
+ 0x3fd00e6c45ad501c, 0x3fe8e6527af1373f, // 0.250880, 0.778116
+ 0x3fd0402594b4d040, 0x3fe8d3018d3018d3, // 0.253915, 0.775758
+ 0x3fd071b85fcd590d, 0x3fe8bfce8062ff3a, // 0.256941, 0.773414
+ 0x3fd0a324e27390e3, 0x3fe8acb90f6bf3aa, // 0.259958, 0.771084
+ 0x3fd0d46b579ab74b, 0x3fe899c0f601899c, // 0.262965, 0.768769
+ 0x3fd1058bf9ae4ad5, 0x3fe886e5f0abb04a, // 0.265964, 0.766467
+ 0x3fd136870293a8b0, 0x3fe87427bcc092b9, // 0.268953, 0.764179
+ 0x3fd1675cababa60e, 0x3fe8618618618618, // 0.271934, 0.761905
+ 0x3fd1980d2dd4236f, 0x3fe84f00c2780614, // 0.274905, 0.759644
+ 0x3fd1c898c16999fa, 0x3fe83c977ab2bedd, // 0.277868, 0.757396
+ 0x3fd1f8ff9e48a2f2, 0x3fe82a4a0182a4a0, // 0.280823, 0.755162
+ 0x3fd22941fbcf7965, 0x3fe8181818181818, // 0.283768, 0.752941
+ 0x3fd2596010df7639, 0x3fe8060180601806, // 0.286705, 0.750733
+ 0x3fd2895a13de86a3, 0x3fe7f405fd017f40, // 0.289633, 0.748538
+ 0x3fd2b9303ab89d24, 0x3fe7e225515a4f1d, // 0.292553, 0.746356
+ 0x3fd2e8e2bae11d30, 0x3fe7d05f417d05f4, // 0.295464, 0.744186
+ 0x3fd31871c9544184, 0x3fe7beb3922e017c, // 0.298367, 0.742029
+ 0x3fd347dd9a987d54, 0x3fe7ad2208e0ecc3, // 0.301261, 0.739884
+ 0x3fd3772662bfd85a, 0x3fe79baa6bb6398b, // 0.304147, 0.737752
+ 0x3fd3a64c556945e9, 0x3fe78a4c8178a4c8, // 0.307025, 0.735632
+ 0x3fd3d54fa5c1f70f, 0x3fe77908119ac60d, // 0.309894, 0.733524
+ 0x3fd404308686a7e3, 0x3fe767dce434a9b1, // 0.312756, 0.731429
+ 0x3fd432ef2a04e813, 0x3fe756cac201756d, // 0.315609, 0.729345
+ 0x3fd4618bc21c5ec2, 0x3fe745d1745d1746, // 0.318454, 0.727273
+ 0x3fd49006804009d0, 0x3fe734f0c541fe8d, // 0.321291, 0.725212
+ 0x3fd4be5f957778a0, 0x3fe724287f46debc, // 0.324119, 0.723164
+ 0x3fd4ec9732600269, 0x3fe713786d9c7c09, // 0.326940, 0.721127
+ 0x3fd51aad872df82d, 0x3fe702e05c0b8170, // 0.329753, 0.719101
+ 0x3fd548a2c3add262, 0x3fe6f26016f26017, // 0.332558, 0.717087
+ 0x3fd5767717455a6c, 0x3fe6e1f76b4337c7, // 0.335356, 0.715084
+ 0x3fd5a42ab0f4cfe1, 0x3fe6d1a62681c861, // 0.338145, 0.713092
+ 0x3fd5d1bdbf5809ca, 0x3fe6c16c16c16c17, // 0.340927, 0.711111
+ 0x3fd5ff3070a793d3, 0x3fe6b1490aa31a3d, // 0.343701, 0.709141
+ 0x3fd62c82f2b9c795, 0x3fe6a13cd1537290, // 0.346467, 0.707182
+ 0x3fd659b57303e1f2, 0x3fe691473a88d0c0, // 0.349225, 0.705234
+ 0x3fd686c81e9b14ae, 0x3fe6816816816817, // 0.351976, 0.703297
+ 0x3fd6b3bb2235943d, 0x3fe6719f3601671a, // 0.354720, 0.701370
+ 0x3fd6e08eaa2ba1e3, 0x3fe661ec6a5122f9, // 0.357456, 0.699454
+ 0x3fd70d42e2789235, 0x3fe6524f853b4aa3, // 0.360184, 0.697548
+ 0x3fd739d7f6bbd006, 0x3fe642c8590b2164, // 0.362905, 0.695652
+ 0x3fd7664e1239dbce, 0x3fe63356b88ac0de, // 0.365619, 0.693767
+ 0x3fd792a55fdd47a2, 0x3fe623fa77016240, // 0.368326, 0.691892
+ 0x3fd7bede0a37afbf, 0x3fe614b36831ae94, // 0.371025, 0.690027
+ 0x3fd7eaf83b82afc3, 0x3fe6058160581606, // 0.373716, 0.688172
+ 0x3fd816f41da0d495, 0x3fe5f66434292dfc, // 0.376401, 0.686327
+ 0x3fd842d1da1e8b17, 0x3fe5e75bb8d015e7, // 0.379078, 0.684492
+ 0x3fd86e919a330ba0, 0x3fe5d867c3ece2a5, // 0.381749, 0.682667
+ 0x3fd89a3386c1425a, 0x3fe5c9882b931057, // 0.384412, 0.680851
+ 0x3fd8c5b7c858b48a, 0x3fe5babcc647fa91, // 0.387068, 0.679045
+ 0x3fd8f11e873662c7, 0x3fe5ac056b015ac0, // 0.389717, 0.677249
+ 0x3fd91c67eb45a83d, 0x3fe59d61f123ccaa, // 0.392359, 0.675462
+ 0x3fd947941c2116fa, 0x3fe58ed2308158ed, // 0.394994, 0.673684
+ 0x3fd972a341135158, 0x3fe5805601580560, // 0.397622, 0.671916
+ 0x3fd99d958117e08a, 0x3fe571ed3c506b3a, // 0.400243, 0.670157
+ 0x3fd9c86b02dc0862, 0x3fe56397ba7c52e2, // 0.402858, 0.668407
+ 0x3fd9f323ecbf984b, 0x3fe5555555555555, // 0.405465, 0.666667
+ 0x3fda1dc064d5b995, 0x3fe54725e6bb82fe, // 0.408066, 0.664935
+ 0x3fda484090e5bb0a, 0x3fe5390948f40feb, // 0.410660, 0.663212
+ 0x3fda72a4966bd9ea, 0x3fe52aff56a8054b, // 0.413247, 0.661499
+ 0x3fda9cec9a9a0849, 0x3fe51d07eae2f815, // 0.415828, 0.659794
+ 0x3fdac718c258b0e4, 0x3fe50f22e111c4c5, // 0.418402, 0.658098
+ 0x3fdaf1293247786b, 0x3fe5015015015015, // 0.420969, 0.656410
+ 0x3fdb1b1e0ebdfc5b, 0x3fe4f38f62dd4c9b, // 0.423530, 0.654731
+ 0x3fdb44f77bcc8f62, 0x3fe4e5e0a72f0539, // 0.426084, 0.653061
+ 0x3fdb6eb59d3cf35d, 0x3fe4d843bedc2c4c, // 0.428632, 0.651399
+ 0x3fdb9858969310fb, 0x3fe4cab88725af6e, // 0.431173, 0.649746
+ 0x3fdbc1e08b0dad0a, 0x3fe4bd3edda68fe1, // 0.433708, 0.648101
+ 0x3fdbeb4d9da71b7b, 0x3fe4afd6a052bf5b, // 0.436237, 0.646465
+ 0x3fdc149ff115f026, 0x3fe4a27fad76014a, // 0.438759, 0.644836
+ 0x3fdc3dd7a7cdad4d, 0x3fe49539e3b2d067, // 0.441275, 0.643216
+ 0x3fdc66f4e3ff6ff7, 0x3fe4880522014880, // 0.443784, 0.641604
+ 0x3fdc8ff7c79a9a21, 0x3fe47ae147ae147b, // 0.446287, 0.640000
+ 0x3fdcb8e0744d7ac9, 0x3fe46dce34596066, // 0.448784, 0.638404
+ 0x3fdce1af0b85f3eb, 0x3fe460cbc7f5cf9a, // 0.451275, 0.636816
+ 0x3fdd0a63ae721e64, 0x3fe453d9e2c776ca, // 0.453759, 0.635236
+ 0x3fdd32fe7e00ebd5, 0x3fe446f86562d9fb, // 0.456237, 0.633663
+ 0x3fdd5b7f9ae2c683, 0x3fe43a2730abee4d, // 0.458710, 0.632099
+ 0x3fdd83e7258a2f3e, 0x3fe42d6625d51f87, // 0.461176, 0.630542
+ 0x3fddac353e2c5954, 0x3fe420b5265e5951, // 0.463636, 0.628993
+ 0x3fddd46a04c1c4a0, 0x3fe4141414141414, // 0.466090, 0.627451
+ 0x3fddfc859906d5b5, 0x3fe40782d10e6566, // 0.468538, 0.625917
+ 0x3fde24881a7c6c26, 0x3fe3fb013fb013fb, // 0.470980, 0.624390
+ 0x3fde4c71a8687704, 0x3fe3ee8f42a5af07, // 0.473416, 0.622871
+ 0x3fde744261d68787, 0x3fe3e22cbce4a902, // 0.475846, 0.621359
+ 0x3fde9bfa659861f5, 0x3fe3d5d991aa75c6, // 0.478270, 0.619855
+ 0x3fdec399d2468cc0, 0x3fe3c995a47babe7, // 0.480689, 0.618357
+ 0x3fdeeb20c640ddf4, 0x3fe3bd60d9232955, // 0.483101, 0.616867
+ 0x3fdf128f5faf06ec, 0x3fe3b13b13b13b14, // 0.485508, 0.615385
+ 0x3fdf39e5bc811e5b, 0x3fe3a524387ac822, // 0.487909, 0.613909
+ 0x3fdf6123fa7028ac, 0x3fe3991c2c187f63, // 0.490304, 0.612440
+ 0x3fdf884a36fe9ec2, 0x3fe38d22d366088e, // 0.492693, 0.610979
+ 0x3fdfaf588f78f31e, 0x3fe3813813813814, // 0.495077, 0.609524
+ 0x3fdfd64f20f61571, 0x3fe3755bd1c945ee, // 0.497455, 0.608076
+ 0x3fdffd2e0857f498, 0x3fe3698df3de0748, // 0.499828, 0.606635
+ 0x3fe011fab125ff8a, 0x3fe35dce5f9f2af8, // 0.502195, 0.605201
+ 0x3fe02552a5a5d0fe, 0x3fe3521cfb2b78c1, // 0.504556, 0.603774
+ 0x3fe0389eefce633b, 0x3fe34679ace01346, // 0.506912, 0.602353
+ 0x3fe04bdf9da926d2, 0x3fe33ae45b57bcb2, // 0.509262, 0.600939
+ 0x3fe05f14bd26459c, 0x3fe32f5ced6a1dfa, // 0.511607, 0.599532
+ 0x3fe0723e5c1cdf40, 0x3fe323e34a2b10bf, // 0.513946, 0.598131
+ 0x3fe0855c884b450e, 0x3fe3187758e9ebb6, // 0.516279, 0.596737
+ 0x3fe0986f4f573520, 0x3fe30d190130d190, // 0.518608, 0.595349
+ 0x3fe0ab76bece14d1, 0x3fe301c82ac40260, // 0.520931, 0.593968
+ 0x3fe0be72e4252a82, 0x3fe2f684bda12f68, // 0.523248, 0.592593
+ 0x3fe0d163ccb9d6b7, 0x3fe2eb4ea1fed14b, // 0.525560, 0.591224
+ 0x3fe0e44985d1cc8b, 0x3fe2e025c04b8097, // 0.527867, 0.589862
+ 0x3fe0f7241c9b497d, 0x3fe2d50a012d50a0, // 0.530169, 0.588506
+ 0x3fe109f39e2d4c96, 0x3fe2c9fb4d812ca0, // 0.532465, 0.587156
+ 0x3fe11cb81787ccf8, 0x3fe2bef98e5a3711, // 0.534756, 0.585812
+ 0x3fe12f719593efbc, 0x3fe2b404ad012b40, // 0.537041, 0.584475
+ 0x3fe1422025243d44, 0x3fe2a91c92f3c105, // 0.539322, 0.583144
+ 0x3fe154c3d2f4d5e9, 0x3fe29e4129e4129e, // 0.541597, 0.581818
+ 0x3fe1675cababa60e, 0x3fe293725bb804a5, // 0.543867, 0.580499
+ 0x3fe179eabbd899a0, 0x3fe288b01288b013, // 0.546132, 0.579186
+ 0x3fe18c6e0ff5cf06, 0x3fe27dfa38a1ce4d, // 0.548392, 0.577878
+ 0x3fe19ee6b467c96e, 0x3fe27350b8812735, // 0.550647, 0.576577
+ 0x3fe1b154b57da29e, 0x3fe268b37cd60127, // 0.552897, 0.575281
+ 0x3fe1c3b81f713c24, 0x3fe25e22708092f1, // 0.555142, 0.573991
+ 0x3fe1d610fe677003, 0x3fe2539d7e9177b2, // 0.557381, 0.572707
+ 0x3fe1e85f5e7040d0, 0x3fe2492492492492, // 0.559616, 0.571429
+ 0x3fe1faa34b87094c, 0x3fe23eb79717605b, // 0.561845, 0.570156
+ 0x3fe20cdcd192ab6d, 0x3fe23456789abcdf, // 0.564070, 0.568889
+ 0x3fe21f0bfc65beeb, 0x3fe22a0122a0122a, // 0.566290, 0.567627
+ 0x3fe23130d7bebf42, 0x3fe21fb78121fb78, // 0.568505, 0.566372
+ 0x3fe2434b6f483933, 0x3fe21579804855e6, // 0.570715, 0.565121
+ 0x3fe2555bce98f7cb, 0x3fe20b470c67c0d9, // 0.572920, 0.563877
+ 0x3fe26762013430df, 0x3fe2012012012012, // 0.575120, 0.562637
+ 0x3fe2795e1289b11a, 0x3fe1f7047dc11f70, // 0.577315, 0.561404
+ 0x3fe28b500df60782, 0x3fe1ecf43c7fb84c, // 0.579506, 0.560175
+ 0x3fe29d37fec2b08a, 0x3fe1e2ef3b3fb874, // 0.581692, 0.558952
+ 0x3fe2af15f02640ad, 0x3fe1d8f5672e4abd, // 0.583873, 0.557734
+ 0x3fe2c0e9ed448e8b, 0x3fe1cf06ada2811d, // 0.586049, 0.556522
+ 0x3fe2d2b4012edc9d, 0x3fe1c522fc1ce059, // 0.588221, 0.555315
+ 0x3fe2e47436e40268, 0x3fe1bb4a4046ed29, // 0.590387, 0.554113
+ 0x3fe2f62a99509546, 0x3fe1b17c67f2bae3, // 0.592550, 0.552916
+ 0x3fe307d7334f10be, 0x3fe1a7b9611a7b96, // 0.594707, 0.551724
+ 0x3fe3197a0fa7fe6a, 0x3fe19e0119e0119e, // 0.596860, 0.550538
+ 0x3fe32b1339121d71, 0x3fe19453808ca29c, // 0.599008, 0.549356
+ 0x3fe33ca2ba328994, 0x3fe18ab083902bdb, // 0.601152, 0.548180
+ 0x3fe34e289d9ce1d3, 0x3fe1811811811812, // 0.603291, 0.547009
+ 0x3fe35fa4edd36ea0, 0x3fe1778a191bd684, // 0.605425, 0.545842
+ 0x3fe37117b54747b5, 0x3fe16e0689427379, // 0.607555, 0.544681
+ 0x3fe38280fe58797e, 0x3fe1648d50fc3201, // 0.609681, 0.543524
+ 0x3fe393e0d3562a19, 0x3fe15b1e5f75270d, // 0.611802, 0.542373
+ 0x3fe3a5373e7ebdf9, 0x3fe151b9a3fdd5c9, // 0.613918, 0.541226
+ 0x3fe3b68449fffc22, 0x3fe1485f0e0acd3b, // 0.616030, 0.540084
+ 0x3fe3c7c7fff73205, 0x3fe13f0e8d344724, // 0.618137, 0.538947
+ 0x3fe3d9026a7156fa, 0x3fe135c81135c811, // 0.620240, 0.537815
+ 0x3fe3ea33936b2f5b, 0x3fe12c8b89edc0ac, // 0.622339, 0.536688
+ 0x3fe3fb5b84d16f42, 0x3fe12358e75d3033, // 0.624433, 0.535565
+ 0x3fe40c7a4880dce9, 0x3fe11a3019a74826, // 0.626523, 0.534447
+ 0x3fe41d8fe84672ae, 0x3fe1111111111111, // 0.628609, 0.533333
+ 0x3fe42e9c6ddf80bf, 0x3fe107fbbe011080, // 0.630690, 0.532225
+ 0x3fe43f9fe2f9ce67, 0x3fe0fef010fef011, // 0.632767, 0.531120
+ 0x3fe4509a5133bb0a, 0x3fe0f5edfab325a2, // 0.634839, 0.530021
+ 0x3fe4618bc21c5ec2, 0x3fe0ecf56be69c90, // 0.636907, 0.528926
+ 0x3fe472743f33aaad, 0x3fe0e40655826011, // 0.638971, 0.527835
+ 0x3fe48353d1ea88df, 0x3fe0db20a88f4696, // 0.641031, 0.526749
+ 0x3fe4942a83a2fc07, 0x3fe0d24456359e3a, // 0.643087, 0.525667
+ 0x3fe4a4f85db03ebb, 0x3fe0c9714fbcda3b, // 0.645138, 0.524590
+ 0x3fe4b5bd6956e273, 0x3fe0c0a7868b4171, // 0.647185, 0.523517
+ 0x3fe4c679afccee39, 0x3fe0b7e6ec259dc8, // 0.649228, 0.522449
+ 0x3fe4d72d3a39fd00, 0x3fe0af2f722eecb5, // 0.651267, 0.521385
+ 0x3fe4e7d811b75bb0, 0x3fe0a6810a6810a7, // 0.653301, 0.520325
+ 0x3fe4f87a3f5026e8, 0x3fe09ddba6af8360, // 0.655332, 0.519270
+ 0x3fe50913cc01686b, 0x3fe0953f39010954, // 0.657358, 0.518219
+ 0x3fe519a4c0ba3446, 0x3fe08cabb37565e2, // 0.659380, 0.517172
+ 0x3fe52a2d265bc5aa, 0x3fe0842108421084, // 0.661398, 0.516129
+ 0x3fe53aad05b99b7c, 0x3fe07b9f29b8eae2, // 0.663413, 0.515091
+ 0x3fe54b2467999497, 0x3fe073260a47f7c6, // 0.665423, 0.514056
+ 0x3fe55b9354b40bcd, 0x3fe06ab59c7912fb, // 0.667429, 0.513026
+ 0x3fe56bf9d5b3f399, 0x3fe0624dd2f1a9fc, // 0.669431, 0.512000
+ 0x3fe57c57f336f190, 0x3fe059eea0727586, // 0.671429, 0.510978
+ 0x3fe58cadb5cd7989, 0x3fe05197f7d73404, // 0.673423, 0.509960
+ 0x3fe59cfb25fae87d, 0x3fe04949cc1664c5, // 0.675413, 0.508946
+ 0x3fe5ad404c359f2c, 0x3fe0410410410410, // 0.677399, 0.507937
+ 0x3fe5bd7d30e71c73, 0x3fe038c6b78247fc, // 0.679381, 0.506931
+ 0x3fe5cdb1dc6c1764, 0x3fe03091b51f5e1a, // 0.681359, 0.505929
+ 0x3fe5ddde57149923, 0x3fe02864fc7729e9, // 0.683334, 0.504931
+ 0x3fe5ee02a9241675, 0x3fe0204081020408, // 0.685304, 0.503937
+ 0x3fe5fe1edad18918, 0x3fe0182436517a37, // 0.687271, 0.502947
+ 0x3fe60e32f44788d8, 0x3fe0101010101010, // 0.689233, 0.501961
+ 0x3fe62e42fefa39ef, 0x3fe0000000000000, // 0.693147, 0.500000
+};
+
+// 0.69314718055994530941723212145818
+static const float64_t ln_2 = float64_t::fromRaw(0x3fe62e42fefa39ef);
+
+static float32_t f32_log(float32_t x)
+{
+ //special cases
+ if(x.isNaN() || x < float32_t::zero()) return float32_t::nan();
+ if(x == float32_t::zero()) return -float32_t::inf();
+
+ //first 8 bits of mantissa
+ int h0 = (x.v >> (23 - LOGTAB_SCALE)) & ((1 << LOGTAB_SCALE) - 1);
+ //buf == 0.00000000_the_rest_mantissa_bits
+ float64_t buf; buf.v = packToF64UI(0, 1023, ((uint64_t)x.v << 29) & ((1LL << (52 - LOGTAB_SCALE)) - 1));
+ buf -= float64_t::one();
+
+ float64_t tab0 = float64_t::fromRaw(icvLogTab[2*h0]);
+ float64_t tab1 = float64_t::fromRaw(icvLogTab[2*h0+1]);
+
+ float64_t x0 = buf * tab1;
+ //if last elements of icvLogTab
+ if(h0 == 255) x0 += float64_t(-float64_t::one() / float64_t(512));
+
+ float64_t y0 = ln_2 * float64_t(expF32UI(x.v) - 127) + tab0 + x0*x0*x0/float64_t(3) - x0*x0/float64_t(2) + x0;
+
+ return y0;
+}
+
+static float64_t f64_log(float64_t x)
+{
+ //special cases
+ if(x.isNaN() || x < float64_t::zero()) return float64_t::nan();
+ if(x == float64_t::zero()) return -float64_t::inf();
+
+ static const float64_t
+ A7(1),
+ A6(-float64_t::one() / float64_t(2)),
+ A5( float64_t::one() / float64_t(3)),
+ A4(-float64_t::one() / float64_t(4)),
+ A3( float64_t::one() / float64_t(5)),
+ A2(-float64_t::one() / float64_t(6)),
+ A1( float64_t::one() / float64_t(7)),
+ A0(-float64_t::one() / float64_t(8));
+
+ //first 8 bits of mantissa
+ int h0 = (x.v >> (52 - LOGTAB_SCALE)) & ((1 << LOGTAB_SCALE) - 1);
+ //buf == 0.00000000_the_rest_mantissa_bits
+ float64_t buf; buf.v = packToF64UI(0, 1023, x.v & ((1LL << (52 - LOGTAB_SCALE)) - 1));
+ buf -= float64_t::one();
+
+ float64_t tab0 = float64_t::fromRaw(icvLogTab[2*h0]);
+ float64_t tab1 = float64_t::fromRaw(icvLogTab[2*h0 + 1]);
+
+ float64_t x0 = buf * tab1;
+ //if last elements of icvLogTab
+ if(h0 == 255) x0 += float64_t(-float64_t::one()/float64_t(512));
+ float64_t xq = x0*x0;
+
+ return ln_2 * float64_t( expF64UI(x.v) - 1023) + tab0 + (((A0*xq + A2)*xq + A4)*xq + A6)*xq +
+ (((A1*xq + A3)*xq + A5)*xq + A7)*x0;
+}
+
+/* ************************************************************************** *\
+ Fast cube root by Ken Turkowski
+ (http://www.worldserver.com/turk/computergraphics/papers.html)
+\* ************************************************************************** */
+static float32_t f32_cbrt(float32_t x)
+{
+ //special cases
+ if (x.isNaN()) return float32_t::nan();
+ if (x.isInf()) return x;
+
+ int s = signF32UI(x.v);
+ int ex = expF32UI(x.v) - 127;
+ int shx = ex % 3;
+ shx -= shx >= 0 ? 3 : 0;
+ ex = (ex - shx) / 3 - 1; /* exponent of cube root */
+ float64_t fr; fr.v = packToF64UI(0, shx + 1023, ((uint64_t)fracF32UI(x.v)) << 29);
+
+ /* 0.125 <= fr < 1.0 */
+ /* Use quartic rational polynomial with error < 2^(-24) */
+ const float64_t A1 = float64_t::fromRaw(0x4046a09e6653ba70); // 45.2548339756803022511987494
+ const float64_t A2 = float64_t::fromRaw(0x406808f46c6116e0); // 192.2798368355061050458134625
+ const float64_t A3 = float64_t::fromRaw(0x405dca97439cae14); // 119.1654824285581628956914143
+ const float64_t A4 = float64_t::fromRaw(0x402add70d2827500); // 13.43250139086239872172837314
+ const float64_t A5 = float64_t::fromRaw(0x3fc4f15f83f55d2d); // 0.1636161226585754240958355063
+ const float64_t A6 = float64_t::fromRaw(0x402d9e20660edb21); // 14.80884093219134573786480845
+ const float64_t A7 = float64_t::fromRaw(0x4062ff15c0285815); // 151.9714051044435648658557668
+ const float64_t A8 = float64_t::fromRaw(0x406510d06a8112ce); // 168.5254414101568283957668343
+ const float64_t A9 = float64_t::fromRaw(0x4040fecbc9e2c375); // 33.9905941350215598754191872
+ const float64_t A10 = float64_t::one();
+
+ fr = ((((A1 * fr + A2) * fr + A3) * fr + A4) * fr + A5)/
+ ((((A6 * fr + A7) * fr + A8) * fr + A9) * fr + A10);
+ /* fr *= 2^ex * sign */
+
+ // checks for "+0" and "-0", reset sign bit
+ float32_t y; y.v = ((x.v & ((1u << 31) - 1)) != 0) ? packToF32UI(s, ex + 127, (uint32_t)(fracF64UI(fr.v) >> 29)) : 0;
+ return y;
+}
+
+/// POW functions ///
+
+static float32_t f32_pow( float32_t x, float32_t y)
+{
+ static const float32_t zero = float32_t::zero(), one = float32_t::one(), inf = float32_t::inf(), nan = float32_t::nan();
+ bool xinf = x.isInf(), yinf = y.isInf(), xnan = x.isNaN(), ynan = y.isNaN();
+ float32_t ax = abs(x);
+ bool useInf = (y > zero) == (ax > one);
+ float32_t v;
+ //special cases
+ if(ynan) v = nan;
+ else if(yinf) v = (ax == one || xnan) ? nan : (useInf ? inf : zero);
+ else if(y == zero) v = one;
+ else if(y == one ) v = x;
+ else //here y is ok
+ {
+ if(xnan) v = nan;
+ else if(xinf) v = (y < zero) ? zero : inf;
+ else if(y == f32_roundToInt(y, round_near_even, false)) v = f32_powi(x, f32_to_i32(y, round_near_even, false));
+ else if(x < zero) v = nan;
+ // (0 ** 0) == 1
+ else if(x == zero) v = (y < zero) ? inf : (y == zero ? one : zero);
+ // here x and y are ok
+ else v = f32_exp(y * f32_log(x));
+ }
+
+ return v;
+}
+
+static float64_t f64_pow( float64_t x, float64_t y)
+{
+ static const float64_t zero = float64_t::zero(), one = float64_t::one(), inf = float64_t::inf(), nan = float64_t::nan();
+ bool xinf = x.isInf(), yinf = y.isInf(), xnan = x.isNaN(), ynan = y.isNaN();
+ float64_t ax = abs(x);
+ bool useInf = (y > zero) == (ax > one);
+ float64_t v;
+ //special cases
+ if(ynan) v = nan;
+ else if(yinf) v = (ax == one || xnan) ? nan : (useInf ? inf : zero);
+ else if(y == zero) v = one;
+ else if(y == one ) v = x;
+ else //here y is ok
+ {
+ if(xnan) v = nan;
+ else if(xinf) v = (y < zero) ? zero : inf;
+ else if(y == f64_roundToInt(y, round_near_even, false)) v = f64_powi(x, f64_to_i32(y, round_near_even, false));
+ else if(x < zero) v = nan;
+ // (0 ** 0) == 1
+ else if(x == zero) v = (y < zero) ? inf : (y == zero ? one : zero);
+ // here x and y are ok
+ else v = f64_exp(y * f64_log(x));
+ }
+
+ return v;
+}
+
+// These functions are for internal use only
+
+static float32_t f32_powi( float32_t x, int y)
+{
+ float32_t v;
+ //special case: (0 ** 0) == 1
+ if(x == float32_t::zero())
+ v = (y < 0) ? float32_t::inf() : (y == 0 ? float32_t::one() : float32_t::zero());
+ // here x and y are ok
+ else
+ {
+ float32_t a = float32_t::one(), b = x;
+ int p = std::abs(y);
+ if( y < 0 )
+ b = float32_t::one()/b;
+ while( p > 1 )
+ {
+ if( p & 1 )
+ a *= b;
+ b *= b;
+ p >>= 1;
+ }
+ v = a * b;
+ }
+
+ return v;
+}
+
+static float64_t f64_powi( float64_t x, int y)
+{
+ float64_t v;
+ //special case: (0 ** 0) == 1
+ if(x == float64_t::zero())
+ v = (y < 0) ? float64_t::inf() : (y == 0 ? float64_t::one() : float64_t::zero());
+ // here x and y are ok
+ else
+ {
+ float64_t a = float64_t::one(), b = x;
+ int p = std::abs(y);
+ if( y < 0 )
+ b = float64_t::one()/b;
+ while( p > 1 )
+ {
+ if( p & 1 )
+ a *= b;
+ b *= b;
+ p >>= 1;
+ }
+ v = a * b;
+ }
+
+ return v;
+}
+
+}
diff --git a/modules/core/src/stat.cpp b/modules/core/src/stat.cpp
index 5cdae20..8018169 100644
--- a/modules/core/src/stat.cpp
+++ b/modules/core/src/stat.cpp
@@ -44,6 +44,7 @@
#include "precomp.hpp"
#include <climits>
#include <limits>
+#include "opencv2/core/hal/intrin.hpp"
#include "opencl_kernels_core.hpp"
@@ -52,16 +53,6 @@
namespace cv
{
-template<typename T> static inline Scalar rawToScalar(const T& v)
-{
- Scalar s;
- typedef typename DataType<T>::channel_type T1;
- int i, n = DataType<T>::channels;
- for( i = 0; i < n; i++ )
- s.val[i] = ((T1*)&v)[i];
- return s;
-}
-
/****************************************************************************************\
* sum *
\****************************************************************************************/
@@ -75,6 +66,13 @@ struct Sum_SIMD
}
};
+template <typename ST, typename DT>
+inline void addChannels(DT * dst, ST * buf, int cn)
+{
+ for (int i = 0; i < 4; ++i)
+ dst[i % cn] += buf[i];
+}
+
#if CV_SSE2
template <>
@@ -112,9 +110,7 @@ struct Sum_SIMD<schar, int>
int CV_DECL_ALIGNED(16) ar[4];
_mm_store_si128((__m128i*)ar, v_sum);
- for (int i = 0; i < 4; i += cn)
- for (int j = 0; j < cn; ++j)
- dst[j] += ar[j + i];
+ addChannels(dst, ar, cn);
return x / cn;
}
@@ -142,9 +138,7 @@ struct Sum_SIMD<int, double>
_mm_store_pd(ar, v_sum0);
_mm_store_pd(ar + 2, v_sum1);
- for (int i = 0; i < 4; i += cn)
- for (int j = 0; j < cn; ++j)
- dst[j] += ar[j + i];
+ addChannels(dst, ar, cn);
return x / cn;
}
@@ -173,9 +167,7 @@ struct Sum_SIMD<float, double>
_mm_store_pd(ar, v_sum0);
_mm_store_pd(ar + 2, v_sum1);
- for (int i = 0; i < 4; i += cn)
- for (int j = 0; j < cn; ++j)
- dst[j] += ar[j + i];
+ addChannels(dst, ar, cn);
return x / cn;
}
@@ -219,9 +211,7 @@ struct Sum_SIMD<uchar, int>
unsigned int CV_DECL_ALIGNED(16) ar[4];
vst1q_u32(ar, v_sum);
- for (int i = 0; i < 4; i += cn)
- for (int j = 0; j < cn; ++j)
- dst[j] += ar[j + i];
+ addChannels(dst, ar, cn);
return x / cn;
}
@@ -262,9 +252,7 @@ struct Sum_SIMD<schar, int>
int CV_DECL_ALIGNED(16) ar[4];
vst1q_s32(ar, v_sum);
- for (int i = 0; i < 4; i += cn)
- for (int j = 0; j < cn; ++j)
- dst[j] += ar[j + i];
+ addChannels(dst, ar, cn);
return x / cn;
}
@@ -295,9 +283,7 @@ struct Sum_SIMD<ushort, int>
unsigned int CV_DECL_ALIGNED(16) ar[4];
vst1q_u32(ar, v_sum);
- for (int i = 0; i < 4; i += cn)
- for (int j = 0; j < cn; ++j)
- dst[j] += ar[j + i];
+ addChannels(dst, ar, cn);
return x / cn;
}
@@ -328,9 +314,7 @@ struct Sum_SIMD<short, int>
int CV_DECL_ALIGNED(16) ar[4];
vst1q_s32(ar, v_sum);
- for (int i = 0; i < 4; i += cn)
- for (int j = 0; j < cn; ++j)
- dst[j] += ar[j + i];
+ addChannels(dst, ar, cn);
return x / cn;
}
@@ -747,6 +731,16 @@ struct SumSqr_SIMD
}
};
+template <typename T>
+inline void addSqrChannels(T * sum, T * sqsum, T * buf, int cn)
+{
+ for (int i = 0; i < 4; ++i)
+ {
+ sum[i % cn] += buf[i];
+ sqsum[i % cn] += buf[4 + i];
+ }
+}
+
#if CV_SSE2
template <>
@@ -795,12 +789,7 @@ struct SumSqr_SIMD<uchar, int, int>
_mm_store_si128((__m128i*)ar, v_sum);
_mm_store_si128((__m128i*)(ar + 4), v_sqsum);
- for (int i = 0; i < 4; i += cn)
- for (int j = 0; j < cn; ++j)
- {
- sum[j] += ar[j + i];
- sqsum[j] += ar[4 + j + i];
- }
+ addSqrChannels(sum, sqsum, ar, cn);
return x / cn;
}
@@ -852,12 +841,7 @@ struct SumSqr_SIMD<schar, int, int>
_mm_store_si128((__m128i*)ar, v_sum);
_mm_store_si128((__m128i*)(ar + 4), v_sqsum);
- for (int i = 0; i < 4; i += cn)
- for (int j = 0; j < cn; ++j)
- {
- sum[j] += ar[j + i];
- sqsum[j] += ar[4 + j + i];
- }
+ addSqrChannels(sum, sqsum, ar, cn);
return x / cn;
}
@@ -1143,6 +1127,8 @@ static bool ipp_sum(Mat &src, Scalar &_res)
#if IPP_VERSION_X100 >= 700
int cn = src.channels();
+ if (cn > 4)
+ return false;
size_t total_size = src.total();
int rows = src.size[0], cols = rows ? (int)(total_size/rows) : 0;
if( src.dims == 2 || (src.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) )
@@ -1308,30 +1294,51 @@ static bool ipp_countNonZero( Mat &src, int &res )
{
CV_INSTRUMENT_REGION_IPP()
- Ipp32s count = 0;
- IppStatus status = ippStsNoErr;
+ Ipp32s count = 0;
+ int depth = src.depth();
- int type = src.type(), depth = CV_MAT_DEPTH(type);
- IppiSize roiSize = { src.cols, src.rows };
- Ipp32s srcstep = (Ipp32s)src.step;
- if (src.isContinuous())
+ if(src.dims <= 2)
{
- roiSize.width = (Ipp32s)src.total();
- roiSize.height = 1;
- srcstep = (Ipp32s)src.total() * CV_ELEM_SIZE(type);
- }
+ IppStatus status;
+ IppiSize size = {src.cols*src.channels(), src.rows};
- if (depth == CV_8U)
- status = CV_INSTRUMENT_FUN_IPP(ippiCountInRange_8u_C1R, (const Ipp8u *)src.data, srcstep, roiSize, &count, 0, 0);
- else if (depth == CV_32F)
- status = CV_INSTRUMENT_FUN_IPP(ippiCountInRange_32f_C1R, (const Ipp32f *)src.data, srcstep, roiSize, &count, 0, 0);
+ if(depth == CV_8U)
+ status = CV_INSTRUMENT_FUN_IPP(ippiCountInRange_8u_C1R, (const Ipp8u *)src.ptr(), (int)src.step, size, &count, 0, 0);
+ else if(depth == CV_32F)
+ status = CV_INSTRUMENT_FUN_IPP(ippiCountInRange_32f_C1R, (const Ipp32f *)src.ptr(), (int)src.step, size, &count, 0, 0);
+ else
+ return false;
- if (status >= 0)
+ if(status < 0)
+ return false;
+
+ res = size.width*size.height - count;
+ }
+ else
{
- res = ((Ipp32s)src.total() - count);
- return true;
+ IppStatus status;
+ const Mat *arrays[] = {&src, NULL};
+ Mat planes[1];
+ NAryMatIterator it(arrays, planes, 1);
+ IppiSize size = {(int)it.size*src.channels(), 1};
+ res = 0;
+ for (size_t i = 0; i < it.nplanes; i++, ++it)
+ {
+ if(depth == CV_8U)
+ status = CV_INSTRUMENT_FUN_IPP(ippiCountInRange_8u_C1R, it.planes->ptr<Ipp8u>(), (int)it.planes->step, size, &count, 0, 0);
+ else if(depth == CV_32F)
+ status = CV_INSTRUMENT_FUN_IPP(ippiCountInRange_32f_C1R, it.planes->ptr<Ipp32f>(), (int)it.planes->step, size, &count, 0, 0);
+ else
+ return false;
+
+ if(status < 0 || (int)it.planes->total()*src.channels() < count)
+ return false;
+
+ res += (int)it.planes->total()*src.channels() - count;
+ }
}
- return false;
+
+ return true;
}
}
#endif
@@ -1355,7 +1362,7 @@ int cv::countNonZero( InputArray _src )
#endif
Mat src = _src.getMat();
- CV_IPP_RUN(0 && (_src.dims() <= 2 || _src.isContinuous()), ipp_countNonZero(src, res), res);
+ CV_IPP_RUN_FAST(ipp_countNonZero(src, res), res);
CountNonZeroFunc func = getCountNonZeroTab(src.depth());
CV_Assert( func != 0 );
@@ -1380,6 +1387,9 @@ static bool ipp_mean( Mat &src, Mat &mask, Scalar &ret )
#if IPP_VERSION_X100 >= 700
size_t total_size = src.total();
+ int cn = src.channels();
+ if (cn > 4)
+ return false;
int rows = src.size[0], cols = rows ? (int)(total_size/rows) : 0;
if( src.dims == 2 || (src.isContinuous() && mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) )
{
@@ -1449,7 +1459,7 @@ static bool ipp_mean( Mat &src, Mat &mask, Scalar &ret )
CV_INSTRUMENT_FUN_IPP(ippiMean, src.ptr(), (int)src.step[0], sz, res);
if( status >= 0 )
{
- for( int i = 0; i < src.channels(); i++ )
+ for( int i = 0; i < cn; i++ )
ret[i] = res[i];
return true;
}
@@ -1537,10 +1547,13 @@ static bool ocl_meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv
bool haveMask = _mask.kind() != _InputArray::NONE;
int nz = haveMask ? -1 : (int)_src.total();
- Scalar mean, stddev;
+ Scalar mean(0), stddev(0);
+ const int cn = _src.channels();
+ if (cn > 4)
+ return false;
{
- int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
+ int type = _src.type(), depth = CV_MAT_DEPTH(type);
bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0,
isContinuous = _src.isContinuous(),
isMaskContinuous = _mask.isContinuous();
@@ -1563,7 +1576,7 @@ static bool ocl_meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv
wgs2_aligned <<= 1;
wgs2_aligned >>= 1;
- if ( (!doubleSupport && depth == CV_64F) || cn > 4 )
+ if ( (!doubleSupport && depth == CV_64F) )
return false;
char cvt[2][40];
@@ -1616,7 +1629,7 @@ static bool ocl_meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv
}
double total = nz != 0 ? 1.0 / nz : 0;
- int k, j, cn = _src.channels();
+ int k, j;
for (int i = 0; i < cn; ++i)
{
mean[i] *= total;
@@ -1664,7 +1677,7 @@ namespace cv
try
{
- ivx::Context ctx = ivx::Context::create();
+ ivx::Context ctx = ovx::getOpenVXContext();
#ifndef VX_VERSION_1_1
if (ctx.vendorID() == VX_ID_KHRONOS)
return false; // Do not use OpenVX meanStdDev estimation for sample 1.0.1 implementation due to lack of accuracy
@@ -1726,6 +1739,13 @@ static bool ipp_meanStdDev(Mat& src, OutputArray _mean, OutputArray _sdv, Mat& m
#if IPP_VERSION_X100 >= 700
int cn = src.channels();
+
+#if IPP_VERSION_X100 < 201801
+ // IPP_DISABLE: C3C functions can read outside of allocated memory
+ if (cn > 1)
+ return false;
+#endif
+
size_t total_size = src.total();
int rows = src.size[0], cols = rows ? (int)(total_size/rows) : 0;
if( src.dims == 2 || (src.isContinuous() && mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) )
@@ -1842,7 +1862,7 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input
Mat src = _src.getMat(), mask = _mask.getMat();
CV_Assert( mask.empty() || mask.type() == CV_8UC1 );
- CV_OVX_RUN(true,
+ CV_OVX_RUN(!ovx::skipSmallImages<VX_KERNEL_MEAN_STDDEV>(src.cols, src.rows),
openvx_meanStdDev(src, _mean, _sdv, mask))
CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_meanStdDev(src, _mean, _sdv, mask));
@@ -2164,7 +2184,7 @@ static bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int*
{
const ocl::Device & dev = ocl::Device::getDefault();
-#ifdef ANDROID
+#ifdef __ANDROID__
if (dev.isNVidia())
return false;
#endif
@@ -2299,6 +2319,9 @@ static bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int*
#endif
#ifdef HAVE_OPENVX
+namespace ovx {
+ template <> inline bool skipSmallImages<VX_KERNEL_MINMAXLOC>(int w, int h) { return w*h < 3840 * 2160; }
+}
static bool openvx_minMaxIdx(Mat &src, double* minVal, double* maxVal, int* minIdx, int* maxIdx, Mat &mask)
{
int stype = src.type();
@@ -2311,7 +2334,7 @@ static bool openvx_minMaxIdx(Mat &src, double* minVal, double* maxVal, int* minI
try
{
- ivx::Context ctx = ivx::Context::create();
+ ivx::Context ctx = ovx::getOpenVXContext();
ivx::Image
ia = ivx::Image::createFromHandle(ctx, stype == CV_8UC1 ? VX_DF_IMAGE_U8 : VX_DF_IMAGE_S16,
ivx::Image::createAddressing(cols, rows, stype == CV_8UC1 ? 1 : 2, (vx_int32)(src.step[0])), src.ptr());
@@ -2372,109 +2395,287 @@ static bool openvx_minMaxIdx(Mat &src, double* minVal, double* maxVal, int* minI
#endif
#ifdef HAVE_IPP
-static bool ipp_minMaxIdx( Mat &src, double* minVal, double* maxVal, int* minIdx, int* maxIdx, Mat &mask)
+static IppStatus ipp_minMaxIndex_wrap(const void* pSrc, int srcStep, IppiSize size, IppDataType dataType,
+ float* pMinVal, float* pMaxVal, IppiPoint* pMinIndex, IppiPoint* pMaxIndex, const Ipp8u*, int)
{
- CV_INSTRUMENT_REGION_IPP()
+ switch(dataType)
+ {
+ case ipp8u: return CV_INSTRUMENT_FUN_IPP(ippiMinMaxIndx_8u_C1R, (const Ipp8u*)pSrc, srcStep, size, pMinVal, pMaxVal, pMinIndex, pMaxIndex);
+ case ipp16u: return CV_INSTRUMENT_FUN_IPP(ippiMinMaxIndx_16u_C1R, (const Ipp16u*)pSrc, srcStep, size, pMinVal, pMaxVal, pMinIndex, pMaxIndex);
+ case ipp32f: return CV_INSTRUMENT_FUN_IPP(ippiMinMaxIndx_32f_C1R, (const Ipp32f*)pSrc, srcStep, size, pMinVal, pMaxVal, pMinIndex, pMaxIndex);
+ default: return ippStsDataTypeErr;
+ }
+}
-#if IPP_VERSION_X100 >= 700
- int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
- size_t total_size = src.total();
- int rows = src.size[0], cols = rows ? (int)(total_size/rows) : 0;
- if( src.dims == 2 || (src.isContinuous() && mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) )
+static IppStatus ipp_minMaxIndexMask_wrap(const void* pSrc, int srcStep, IppiSize size, IppDataType dataType,
+ float* pMinVal, float* pMaxVal, IppiPoint* pMinIndex, IppiPoint* pMaxIndex, const Ipp8u* pMask, int maskStep)
+{
+ switch(dataType)
{
- IppiSize sz = { cols * cn, rows };
+ case ipp8u: return CV_INSTRUMENT_FUN_IPP(ippiMinMaxIndx_8u_C1MR, (const Ipp8u*)pSrc, srcStep, pMask, maskStep, size, pMinVal, pMaxVal, pMinIndex, pMaxIndex);
+ case ipp16u: return CV_INSTRUMENT_FUN_IPP(ippiMinMaxIndx_16u_C1MR, (const Ipp16u*)pSrc, srcStep, pMask, maskStep, size, pMinVal, pMaxVal, pMinIndex, pMaxIndex);
+ case ipp32f: return CV_INSTRUMENT_FUN_IPP(ippiMinMaxIndx_32f_C1MR, (const Ipp32f*)pSrc, srcStep, pMask, maskStep, size, pMinVal, pMaxVal, pMinIndex, pMaxIndex);
+ default: return ippStsDataTypeErr;
+ }
+}
- if( !mask.empty() )
- {
- typedef IppStatus (CV_STDCALL* ippiMaskMinMaxIndxFuncC1)(const void *, int, const void *, int,
- IppiSize, Ipp32f *, Ipp32f *, IppiPoint *, IppiPoint *);
-
- CV_SUPPRESS_DEPRECATED_START
- ippiMaskMinMaxIndxFuncC1 ippiMinMaxIndx_C1MR =
- type == CV_8UC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_8u_C1MR :
-#if IPP_VERSION_X100 < 900
- type == CV_8SC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_8s_C1MR :
+static IppStatus ipp_minMax_wrap(const void* pSrc, int srcStep, IppiSize size, IppDataType dataType,
+ float* pMinVal, float* pMaxVal, IppiPoint*, IppiPoint*, const Ipp8u*, int)
+{
+ IppStatus status;
+
+ switch(dataType)
+ {
+#if IPP_VERSION_X100 > 201701 // wrong min values
+ case ipp8u:
+ {
+ Ipp8u val[2];
+ status = CV_INSTRUMENT_FUN_IPP(ippiMinMax_8u_C1R, (const Ipp8u*)pSrc, srcStep, size, &val[0], &val[1]);
+ *pMinVal = val[0];
+ *pMaxVal = val[1];
+ return status;
+ }
#endif
- type == CV_16UC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_16u_C1MR :
- type == CV_32FC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_32f_C1MR : 0;
- CV_SUPPRESS_DEPRECATED_END
+ case ipp16u:
+ {
+ Ipp16u val[2];
+ status = CV_INSTRUMENT_FUN_IPP(ippiMinMax_16u_C1R, (const Ipp16u*)pSrc, srcStep, size, &val[0], &val[1]);
+ *pMinVal = val[0];
+ *pMaxVal = val[1];
+ return status;
+ }
+ case ipp16s:
+ {
+ Ipp16s val[2];
+ status = CV_INSTRUMENT_FUN_IPP(ippiMinMax_16s_C1R, (const Ipp16s*)pSrc, srcStep, size, &val[0], &val[1]);
+ *pMinVal = val[0];
+ *pMaxVal = val[1];
+ return status;
+ }
+ case ipp32f: return CV_INSTRUMENT_FUN_IPP(ippiMinMax_32f_C1R, (const Ipp32f*)pSrc, srcStep, size, pMinVal, pMaxVal);
+ default: return ipp_minMaxIndex_wrap(pSrc, srcStep, size, dataType, pMinVal, pMaxVal, NULL, NULL, NULL, 0);
+ }
+}
+
+static IppStatus ipp_minIdx_wrap(const void* pSrc, int srcStep, IppiSize size, IppDataType dataType,
+ float* pMinVal, float*, IppiPoint* pMinIndex, IppiPoint*, const Ipp8u*, int)
+{
+ IppStatus status;
- if( ippiMinMaxIndx_C1MR )
+ switch(dataType)
+ {
+ case ipp8u:
+ {
+ Ipp8u val;
+ status = CV_INSTRUMENT_FUN_IPP(ippiMinIndx_8u_C1R, (const Ipp8u*)pSrc, srcStep, size, &val, &pMinIndex->x, &pMinIndex->y);
+ *pMinVal = val;
+ return status;
+ }
+ case ipp16u:
+ {
+ Ipp16u val;
+ status = CV_INSTRUMENT_FUN_IPP(ippiMinIndx_16u_C1R, (const Ipp16u*)pSrc, srcStep, size, &val, &pMinIndex->x, &pMinIndex->y);
+ *pMinVal = val;
+ return status;
+ }
+ case ipp16s:
+ {
+ Ipp16s val;
+ status = CV_INSTRUMENT_FUN_IPP(ippiMinIndx_16s_C1R, (const Ipp16s*)pSrc, srcStep, size, &val, &pMinIndex->x, &pMinIndex->y);
+ *pMinVal = val;
+ return status;
+ }
+ case ipp32f: return CV_INSTRUMENT_FUN_IPP(ippiMinIndx_32f_C1R, (const Ipp32f*)pSrc, srcStep, size, pMinVal, &pMinIndex->x, &pMinIndex->y);
+ default: return ipp_minMaxIndex_wrap(pSrc, srcStep, size, dataType, pMinVal, NULL, pMinIndex, NULL, NULL, 0);
+ }
+}
+
+static IppStatus ipp_maxIdx_wrap(const void* pSrc, int srcStep, IppiSize size, IppDataType dataType,
+ float*, float* pMaxVal, IppiPoint*, IppiPoint* pMaxIndex, const Ipp8u*, int)
+{
+ IppStatus status;
+
+ switch(dataType)
+ {
+ case ipp8u:
+ {
+ Ipp8u val;
+ status = CV_INSTRUMENT_FUN_IPP(ippiMaxIndx_8u_C1R, (const Ipp8u*)pSrc, srcStep, size, &val, &pMaxIndex->x, &pMaxIndex->y);
+ *pMaxVal = val;
+ return status;
+ }
+ case ipp16u:
+ {
+ Ipp16u val;
+ status = CV_INSTRUMENT_FUN_IPP(ippiMaxIndx_16u_C1R, (const Ipp16u*)pSrc, srcStep, size, &val, &pMaxIndex->x, &pMaxIndex->y);
+ *pMaxVal = val;
+ return status;
+ }
+ case ipp16s:
+ {
+ Ipp16s val;
+ status = CV_INSTRUMENT_FUN_IPP(ippiMaxIndx_16s_C1R, (const Ipp16s*)pSrc, srcStep, size, &val, &pMaxIndex->x, &pMaxIndex->y);
+ *pMaxVal = val;
+ return status;
+ }
+ case ipp32f: return CV_INSTRUMENT_FUN_IPP(ippiMaxIndx_32f_C1R, (const Ipp32f*)pSrc, srcStep, size, pMaxVal, &pMaxIndex->x, &pMaxIndex->y);
+ default: return ipp_minMaxIndex_wrap(pSrc, srcStep, size, dataType, NULL, pMaxVal, NULL, pMaxIndex, NULL, 0);
+ }
+}
+
+typedef IppStatus (*IppMinMaxSelector)(const void* pSrc, int srcStep, IppiSize size, IppDataType dataType,
+ float* pMinVal, float* pMaxVal, IppiPoint* pMinIndex, IppiPoint* pMaxIndex, const Ipp8u* pMask, int maskStep);
+
+static bool ipp_minMaxIdx(Mat &src, double* _minVal, double* _maxVal, int* _minIdx, int* _maxIdx, Mat &mask)
+{
+#if IPP_VERSION_X100 >= 700
+ CV_INSTRUMENT_REGION_IPP()
+
+#if IPP_DISABLE_MINMAX_NAN_SSE42
+ // Disable 32F processing only
+ if(src.depth() == CV_32F && !(ipp::getIppFeatures()&ippCPUID_AVX))
+ return false;
+#endif
+
+ // cv::minMaxIdx problem with index positions on AVX
+#if IPP_VERSION_X100 < 201810
+ if(!mask.empty() && _maxIdx && ipp::getIppFeatures()&ippCPUID_AVX)
+ return false;
+#endif
+
+ IppStatus status;
+ IppDataType dataType = ippiGetDataType(src.depth());
+ float minVal = 0;
+ float maxVal = 0;
+ IppiPoint minIdx = {-1, -1};
+ IppiPoint maxIdx = {-1, -1};
+
+ float *pMinVal = (_minVal)?&minVal:NULL;
+ float *pMaxVal = (_maxVal)?&maxVal:NULL;
+ IppiPoint *pMinIdx = (_minIdx)?&minIdx:NULL;
+ IppiPoint *pMaxIdx = (_maxIdx)?&maxIdx:NULL;
+
+ IppMinMaxSelector ippMinMaxFun = ipp_minMaxIndexMask_wrap;
+ if(mask.empty())
+ {
+ if(_maxVal && _maxIdx && !_minVal && !_minIdx)
+ ippMinMaxFun = ipp_maxIdx_wrap;
+ else if(!_maxVal && !_maxIdx && _minVal && _minIdx)
+ ippMinMaxFun = ipp_minIdx_wrap;
+ else if(_maxVal && !_maxIdx && _minVal && !_minIdx)
+ ippMinMaxFun = ipp_minMax_wrap;
+ else
+ ippMinMaxFun = ipp_minMaxIndex_wrap;
+ }
+
+ if(src.dims <= 2)
+ {
+ IppiSize size = ippiSize(src.size());
+ size.width *= src.channels();
+
+ status = ippMinMaxFun(src.ptr(), (int)src.step, size, dataType, pMinVal, pMaxVal, pMinIdx, pMaxIdx, (Ipp8u*)mask.ptr(), (int)mask.step);
+ if(status < 0)
+ return false;
+ if(_minVal)
+ *_minVal = minVal;
+ if(_maxVal)
+ *_maxVal = maxVal;
+ if(_minIdx)
+ {
+ // Should be just ippStsNoOperation check, but there is a bug in the function so we need additional checks
+ if(status == ippStsNoOperation && !mask.empty() && !pMinIdx->x && !pMinIdx->y)
{
- Ipp32f min, max;
- IppiPoint minp, maxp;
- if( CV_INSTRUMENT_FUN_IPP(ippiMinMaxIndx_C1MR, src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, &min, &max, &minp, &maxp) >= 0 )
- {
- if( minVal )
- *minVal = (double)min;
- if( maxVal )
- *maxVal = (double)max;
- if( !minp.x && !minp.y && !maxp.x && !maxp.y && !mask.ptr()[0] )
- minp.x = maxp.x = -1;
- if( minIdx )
- {
- size_t minidx = minp.y * cols + minp.x + 1;
- ofs2idx(src, minidx, minIdx);
- }
- if( maxIdx )
- {
- size_t maxidx = maxp.y * cols + maxp.x + 1;
- ofs2idx(src, maxidx, maxIdx);
- }
- return true;
- }
+ _minIdx[0] = -1;
+ _minIdx[1] = -1;
+ }
+ else
+ {
+ _minIdx[0] = minIdx.y;
+ _minIdx[1] = minIdx.x;
}
}
- else
+ if(_maxIdx)
{
- typedef IppStatus (CV_STDCALL* ippiMinMaxIndxFuncC1)(const void *, int, IppiSize, Ipp32f *, Ipp32f *, IppiPoint *, IppiPoint *);
-
- CV_SUPPRESS_DEPRECATED_START
- ippiMinMaxIndxFuncC1 ippiMinMaxIndx_C1R =
-#if IPP_VERSION_X100 != 900 // bug in 9.0.0 avx2 optimization
- depth == CV_8U ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_8u_C1R :
-#endif
-#if IPP_VERSION_X100 < 900
- depth == CV_8S ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_8s_C1R :
-#endif
- depth == CV_16U ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_16u_C1R :
-#if IPP_DISABLE_BLOCK && !((defined _MSC_VER && defined _M_IX86) || defined __i386__)
- // See bug #4955: the function fails with SEGFAULT when the source matrix contains NANs
- // IPPICV version is 9.0.1.
- depth == CV_32F ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_32f_C1R :
+ // Should be just ippStsNoOperation check, but there is a bug in the function so we need additional checks
+ if(status == ippStsNoOperation && !mask.empty() && !pMaxIdx->x && !pMaxIdx->y)
+ {
+ _maxIdx[0] = -1;
+ _maxIdx[1] = -1;
+ }
+ else
+ {
+ _maxIdx[0] = maxIdx.y;
+ _maxIdx[1] = maxIdx.x;
+ }
+ }
+ }
+ else
+ {
+ const Mat *arrays[] = {&src, mask.empty()?NULL:&mask, NULL};
+ uchar *ptrs[3] = {NULL};
+ NAryMatIterator it(arrays, ptrs);
+ IppiSize size = ippiSize(it.size*src.channels(), 1);
+ int srcStep = (int)(size.width*src.elemSize1());
+ int maskStep = size.width;
+ size_t idxPos = 1;
+ size_t minIdxAll = 0;
+ size_t maxIdxAll = 0;
+ float minValAll = IPP_MAXABS_32F;
+ float maxValAll = -IPP_MAXABS_32F;
+
+ for(size_t i = 0; i < it.nplanes; i++, ++it, idxPos += size.width)
+ {
+ status = ippMinMaxFun(ptrs[0], srcStep, size, dataType, pMinVal, pMaxVal, pMinIdx, pMaxIdx, ptrs[1], maskStep);
+ if(status < 0)
+ return false;
+#if IPP_VERSION_X100 > 201701
+ // Zero-mask check, function should return ippStsNoOperation warning
+ if(status == ippStsNoOperation)
+ continue;
+#else
+ // Crude zero-mask check, waiting for fix in IPP function
+ if(ptrs[1])
+ {
+ Mat localMask(Size(size.width, 1), CV_8U, ptrs[1], maskStep);
+ if(!cv::countNonZero(localMask))
+ continue;
+ }
#endif
- 0;
- CV_SUPPRESS_DEPRECATED_END
- if( ippiMinMaxIndx_C1R )
+ if(_minVal && minVal < minValAll)
{
- Ipp32f min, max;
- IppiPoint minp, maxp;
- if( CV_INSTRUMENT_FUN_IPP(ippiMinMaxIndx_C1R, src.ptr(), (int)src.step[0], sz, &min, &max, &minp, &maxp) >= 0 )
- {
- if( minVal )
- *minVal = (double)min;
- if( maxVal )
- *maxVal = (double)max;
- if( minIdx )
- {
- size_t minidx = minp.y * cols + minp.x + 1;
- ofs2idx(src, minidx, minIdx);
- }
- if( maxIdx )
- {
- size_t maxidx = maxp.y * cols + maxp.x + 1;
- ofs2idx(src, maxidx, maxIdx);
- }
- return true;
- }
+ minValAll = minVal;
+ minIdxAll = idxPos+minIdx.x;
+ }
+ if(_maxVal && maxVal > maxValAll)
+ {
+ maxValAll = maxVal;
+ maxIdxAll = idxPos+maxIdx.x;
}
}
+ if(!src.empty() && mask.empty())
+ {
+ if(minIdxAll == 0)
+ minIdxAll = 1;
+ if(maxValAll == 0)
+ maxValAll = 1;
+ }
+
+ if(_minVal)
+ *_minVal = minValAll;
+ if(_maxVal)
+ *_maxVal = maxValAll;
+ if(_minIdx)
+ ofs2idx(src, minIdxAll, _minIdx);
+ if(_maxIdx)
+ ofs2idx(src, maxIdxAll, _maxIdx);
}
+
+ return true;
#else
-#endif
CV_UNUSED(src); CV_UNUSED(minVal); CV_UNUSED(maxVal); CV_UNUSED(minIdx); CV_UNUSED(maxIdx); CV_UNUSED(mask);
return false;
+#endif
}
#endif
@@ -2495,10 +2696,10 @@ void cv::minMaxIdx(InputArray _src, double* minVal,
Mat src = _src.getMat(), mask = _mask.getMat();
- CV_OVX_RUN(true,
+ CV_OVX_RUN(!ovx::skipSmallImages<VX_KERNEL_MINMAXLOC>(src.cols, src.rows),
openvx_minMaxIdx(src, minVal, maxVal, minIdx, maxIdx, mask))
- CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_minMaxIdx(src, minVal, maxVal, minIdx, maxIdx, mask))
+ CV_IPP_RUN_FAST(ipp_minMaxIdx(src, minVal, maxVal, minIdx, maxIdx, mask))
MinMaxIdxFunc func = getMinmaxTab(depth);
CV_Assert( func != 0 );
@@ -2785,12 +2986,14 @@ static bool ocl_norm( InputArray _src, int normType, InputArray _mask, double &
{
const ocl::Device & d = ocl::Device::getDefault();
-#ifdef ANDROID
+#ifdef __ANDROID__
if (d.isNVidia())
return false;
#endif
-
- int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
+ const int cn = _src.channels();
+ if (cn > 4)
+ return false;
+ int type = _src.type(), depth = CV_MAT_DEPTH(type);
bool doubleSupport = d.doubleFPConfig() > 0,
haveMask = _mask.kind() != _InputArray::NONE;
@@ -2815,11 +3018,8 @@ static bool ocl_norm( InputArray _src, int normType, InputArray _mask, double &
OCL_OP_SUM_SQR : (unstype ? OCL_OP_SUM : OCL_OP_SUM_ABS), _mask) )
return false;
- if (!haveMask)
- cn = 1;
-
double s = 0.0;
- for (int i = 0; i < cn; ++i)
+ for (int i = 0; i < (haveMask ? cn : 1); ++i)
s += sc[i];
result = normType == NORM_L1 || normType == NORM_L2SQR ? s : std::sqrt(s);
@@ -2836,42 +3036,31 @@ static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result)
CV_INSTRUMENT_REGION_IPP()
#if IPP_VERSION_X100 >= 700
- int cn = src.channels();
size_t total_size = src.total();
int rows = src.size[0], cols = rows ? (int)(total_size/rows) : 0;
if( (src.dims == 2 || (src.isContinuous() && mask.isContinuous()))
- && cols > 0 && (size_t)rows*cols == total_size
- && (normType == NORM_INF || normType == NORM_L1 ||
- normType == NORM_L2 || normType == NORM_L2SQR) )
+ && cols > 0 && (size_t)rows*cols == total_size )
{
- IppiSize sz = { cols, rows };
- int type = src.type();
if( !mask.empty() )
{
+ IppiSize sz = { cols, rows };
+ int type = src.type();
+
typedef IppStatus (CV_STDCALL* ippiMaskNormFuncC1)(const void *, int, const void *, int, IppiSize, Ipp64f *);
ippiMaskNormFuncC1 ippiNorm_C1MR =
normType == NORM_INF ?
(type == CV_8UC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_8u_C1MR :
-#if IPP_VERSION_X100 < 900
- type == CV_8SC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_8s_C1MR :
-#endif
-// type == CV_16UC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_16u_C1MR :
+ type == CV_16UC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_16u_C1MR :
type == CV_32FC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_32f_C1MR :
0) :
normType == NORM_L1 ?
(type == CV_8UC1 ? (ippiMaskNormFuncC1)ippiNorm_L1_8u_C1MR :
-#if IPP_VERSION_X100 < 900
- type == CV_8SC1 ? (ippiMaskNormFuncC1)ippiNorm_L1_8s_C1MR :
-#endif
type == CV_16UC1 ? (ippiMaskNormFuncC1)ippiNorm_L1_16u_C1MR :
type == CV_32FC1 ? (ippiMaskNormFuncC1)ippiNorm_L1_32f_C1MR :
0) :
normType == NORM_L2 || normType == NORM_L2SQR ?
(type == CV_8UC1 ? (ippiMaskNormFuncC1)ippiNorm_L2_8u_C1MR :
-#if IPP_VERSION_X100 < 900
- type == CV_8SC1 ? (ippiMaskNormFuncC1)ippiNorm_L2_8s_C1MR :
-#endif
type == CV_16UC1 ? (ippiMaskNormFuncC1)ippiNorm_L2_16u_C1MR :
type == CV_32FC1 ? (ippiMaskNormFuncC1)ippiNorm_L2_32f_C1MR :
0) : 0;
@@ -2884,39 +3073,29 @@ static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result)
return true;
}
}
-#if IPP_DISABLE_BLOCK
typedef IppStatus (CV_STDCALL* ippiMaskNormFuncC3)(const void *, int, const void *, int, IppiSize, int, Ipp64f *);
ippiMaskNormFuncC3 ippiNorm_C3CMR =
normType == NORM_INF ?
(type == CV_8UC3 ? (ippiMaskNormFuncC3)ippiNorm_Inf_8u_C3CMR :
-#if IPP_VERSION_X100 < 900
- type == CV_8SC3 ? (ippiMaskNormFuncC3)ippiNorm_Inf_8s_C3CMR :
-#endif
type == CV_16UC3 ? (ippiMaskNormFuncC3)ippiNorm_Inf_16u_C3CMR :
type == CV_32FC3 ? (ippiMaskNormFuncC3)ippiNorm_Inf_32f_C3CMR :
0) :
normType == NORM_L1 ?
(type == CV_8UC3 ? (ippiMaskNormFuncC3)ippiNorm_L1_8u_C3CMR :
-#if IPP_VERSION_X100 < 900
- type == CV_8SC3 ? (ippiMaskNormFuncC3)ippiNorm_L1_8s_C3CMR :
-#endif
type == CV_16UC3 ? (ippiMaskNormFuncC3)ippiNorm_L1_16u_C3CMR :
type == CV_32FC3 ? (ippiMaskNormFuncC3)ippiNorm_L1_32f_C3CMR :
0) :
normType == NORM_L2 || normType == NORM_L2SQR ?
(type == CV_8UC3 ? (ippiMaskNormFuncC3)ippiNorm_L2_8u_C3CMR :
-#if IPP_VERSION_X100 < 900
- type == CV_8SC3 ? (ippiMaskNormFuncC3)ippiNorm_L2_8s_C3CMR :
-#endif
type == CV_16UC3 ? (ippiMaskNormFuncC3)ippiNorm_L2_16u_C3CMR :
type == CV_32FC3 ? (ippiMaskNormFuncC3)ippiNorm_L2_32f_C3CMR :
0) : 0;
if( ippiNorm_C3CMR )
{
Ipp64f norm1, norm2, norm3;
- if( CV_INSTRUMENT_FUN_IPP(ippiNorm_C3CMR, (src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 1, &norm1)) >= 0 &&
- CV_INSTRUMENT_FUN_IPP(ippiNorm_C3CMR, (src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 2, &norm2)) >= 0 &&
- CV_INSTRUMENT_FUN_IPP(ippiNorm_C3CMR, (src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 3, &norm3)) >= 0)
+ if( CV_INSTRUMENT_FUN_IPP(ippiNorm_C3CMR, src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 1, &norm1) >= 0 &&
+ CV_INSTRUMENT_FUN_IPP(ippiNorm_C3CMR, src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 2, &norm2) >= 0 &&
+ CV_INSTRUMENT_FUN_IPP(ippiNorm_C3CMR, src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 3, &norm3) >= 0)
{
Ipp64f norm =
normType == NORM_INF ? std::max(std::max(norm1, norm2), norm3) :
@@ -2927,81 +3106,46 @@ static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result)
return true;
}
}
-#endif
}
else
{
+ IppiSize sz = { cols*src.channels(), rows };
+ int type = src.depth();
+
typedef IppStatus (CV_STDCALL* ippiNormFuncHint)(const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint);
typedef IppStatus (CV_STDCALL* ippiNormFuncNoHint)(const void *, int, IppiSize, Ipp64f *);
ippiNormFuncHint ippiNormHint =
normType == NORM_L1 ?
(type == CV_32FC1 ? (ippiNormFuncHint)ippiNorm_L1_32f_C1R :
- type == CV_32FC3 ? (ippiNormFuncHint)ippiNorm_L1_32f_C3R :
- type == CV_32FC4 ? (ippiNormFuncHint)ippiNorm_L1_32f_C4R :
0) :
normType == NORM_L2 || normType == NORM_L2SQR ?
(type == CV_32FC1 ? (ippiNormFuncHint)ippiNorm_L2_32f_C1R :
- type == CV_32FC3 ? (ippiNormFuncHint)ippiNorm_L2_32f_C3R :
- type == CV_32FC4 ? (ippiNormFuncHint)ippiNorm_L2_32f_C4R :
0) : 0;
ippiNormFuncNoHint ippiNorm =
normType == NORM_INF ?
(type == CV_8UC1 ? (ippiNormFuncNoHint)ippiNorm_Inf_8u_C1R :
- type == CV_8UC3 ? (ippiNormFuncNoHint)ippiNorm_Inf_8u_C3R :
- type == CV_8UC4 ? (ippiNormFuncNoHint)ippiNorm_Inf_8u_C4R :
type == CV_16UC1 ? (ippiNormFuncNoHint)ippiNorm_Inf_16u_C1R :
- type == CV_16UC3 ? (ippiNormFuncNoHint)ippiNorm_Inf_16u_C3R :
- type == CV_16UC4 ? (ippiNormFuncNoHint)ippiNorm_Inf_16u_C4R :
type == CV_16SC1 ? (ippiNormFuncNoHint)ippiNorm_Inf_16s_C1R :
-#if (IPP_VERSION_X100 >= 810)
- type == CV_16SC3 ? (ippiNormFuncNoHint)ippiNorm_Inf_16s_C3R : //Aug 2013: problem in IPP 7.1, 8.0 : -32768
- type == CV_16SC4 ? (ippiNormFuncNoHint)ippiNorm_Inf_16s_C4R : //Aug 2013: problem in IPP 7.1, 8.0 : -32768
-#endif
type == CV_32FC1 ? (ippiNormFuncNoHint)ippiNorm_Inf_32f_C1R :
- type == CV_32FC3 ? (ippiNormFuncNoHint)ippiNorm_Inf_32f_C3R :
- type == CV_32FC4 ? (ippiNormFuncNoHint)ippiNorm_Inf_32f_C4R :
0) :
normType == NORM_L1 ?
(type == CV_8UC1 ? (ippiNormFuncNoHint)ippiNorm_L1_8u_C1R :
- type == CV_8UC3 ? (ippiNormFuncNoHint)ippiNorm_L1_8u_C3R :
- type == CV_8UC4 ? (ippiNormFuncNoHint)ippiNorm_L1_8u_C4R :
type == CV_16UC1 ? (ippiNormFuncNoHint)ippiNorm_L1_16u_C1R :
- type == CV_16UC3 ? (ippiNormFuncNoHint)ippiNorm_L1_16u_C3R :
- type == CV_16UC4 ? (ippiNormFuncNoHint)ippiNorm_L1_16u_C4R :
type == CV_16SC1 ? (ippiNormFuncNoHint)ippiNorm_L1_16s_C1R :
- type == CV_16SC3 ? (ippiNormFuncNoHint)ippiNorm_L1_16s_C3R :
- type == CV_16SC4 ? (ippiNormFuncNoHint)ippiNorm_L1_16s_C4R :
0) :
normType == NORM_L2 || normType == NORM_L2SQR ?
(type == CV_8UC1 ? (ippiNormFuncNoHint)ippiNorm_L2_8u_C1R :
- type == CV_8UC3 ? (ippiNormFuncNoHint)ippiNorm_L2_8u_C3R :
- type == CV_8UC4 ? (ippiNormFuncNoHint)ippiNorm_L2_8u_C4R :
type == CV_16UC1 ? (ippiNormFuncNoHint)ippiNorm_L2_16u_C1R :
- type == CV_16UC3 ? (ippiNormFuncNoHint)ippiNorm_L2_16u_C3R :
- type == CV_16UC4 ? (ippiNormFuncNoHint)ippiNorm_L2_16u_C4R :
type == CV_16SC1 ? (ippiNormFuncNoHint)ippiNorm_L2_16s_C1R :
- type == CV_16SC3 ? (ippiNormFuncNoHint)ippiNorm_L2_16s_C3R :
- type == CV_16SC4 ? (ippiNormFuncNoHint)ippiNorm_L2_16s_C4R :
0) : 0;
- // Make sure only zero or one version of the function pointer is valid
- CV_Assert(!ippiNormHint || !ippiNorm);
if( ippiNormHint || ippiNorm )
{
- Ipp64f norm_array[4];
- IppStatus ret = ippiNormHint ? CV_INSTRUMENT_FUN_IPP(ippiNormHint, src.ptr(), (int)src.step[0], sz, norm_array, ippAlgHintAccurate) :
- CV_INSTRUMENT_FUN_IPP(ippiNorm, src.ptr(), (int)src.step[0], sz, norm_array);
+ Ipp64f norm;
+ IppStatus ret = ippiNormHint ? CV_INSTRUMENT_FUN_IPP(ippiNormHint, src.ptr(), (int)src.step[0], sz, &norm, ippAlgHintAccurate) :
+ CV_INSTRUMENT_FUN_IPP(ippiNorm, src.ptr(), (int)src.step[0], sz, &norm);
if( ret >= 0 )
{
- Ipp64f norm = (normType == NORM_L2 || normType == NORM_L2SQR) ? norm_array[0] * norm_array[0] : norm_array[0];
- for( int i = 1; i < cn; i++ )
- {
- norm =
- normType == NORM_INF ? std::max(norm, norm_array[i]) :
- normType == NORM_L1 ? norm + norm_array[i] :
- normType == NORM_L2 || normType == NORM_L2SQR ? norm + norm_array[i] * norm_array[i] :
- 0;
- }
- result = (normType == NORM_L2 ? (double)std::sqrt(norm) : (double)norm);
+ result = (normType == NORM_L2SQR) ? norm * norm : norm;
return true;
}
}
@@ -3184,13 +3328,16 @@ namespace cv {
static bool ocl_norm( InputArray _src1, InputArray _src2, int normType, InputArray _mask, double & result )
{
-#ifdef ANDROID
+#ifdef __ANDROID__
if (ocl::Device::getDefault().isNVidia())
return false;
#endif
Scalar sc1, sc2;
- int type = _src1.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
+ int cn = _src1.channels();
+ if (cn > 4)
+ return false;
+ int type = _src1.type(), depth = CV_MAT_DEPTH(type);
bool relative = (normType & NORM_RELATIVE) != 0;
normType &= ~NORM_RELATIVE;
bool normsum = normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR;
@@ -3247,53 +3394,38 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra
if( normType & CV_RELATIVE )
{
normType &= NORM_TYPE_MASK;
- CV_Assert( normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR ||
- ((normType == NORM_HAMMING || normType == NORM_HAMMING2) && src1.type() == CV_8U) );
+
size_t total_size = src1.total();
int rows = src1.size[0], cols = rows ? (int)(total_size/rows) : 0;
if( (src1.dims == 2 || (src1.isContinuous() && src2.isContinuous() && mask.isContinuous()))
- && cols > 0 && (size_t)rows*cols == total_size
- && (normType == NORM_INF || normType == NORM_L1 ||
- normType == NORM_L2 || normType == NORM_L2SQR) )
+ && cols > 0 && (size_t)rows*cols == total_size )
{
- IppiSize sz = { cols, rows };
- int type = src1.type();
if( !mask.empty() )
{
- typedef IppStatus (CV_STDCALL* ippiMaskNormRelFuncC1)(const void *, int, const void *, int, const void *, int, IppiSize, Ipp64f *);
- ippiMaskNormRelFuncC1 ippiNormDiff_C1MR =
+ IppiSize sz = { cols, rows };
+ int type = src1.type();
+
+ typedef IppStatus (CV_STDCALL* ippiMaskNormDiffFuncC1)(const void *, int, const void *, int, const void *, int, IppiSize, Ipp64f *);
+ ippiMaskNormDiffFuncC1 ippiNormRel_C1MR =
normType == NORM_INF ?
- (type == CV_8UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_Inf_8u_C1MR :
-#if IPP_VERSION_X100 < 900
-#ifndef __APPLE__
- type == CV_8SC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_Inf_8s_C1MR :
-#endif
-#endif
- type == CV_16UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_Inf_16u_C1MR :
- type == CV_32FC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_Inf_32f_C1MR :
+ (type == CV_8UC1 ? (ippiMaskNormDiffFuncC1)ippiNormRel_Inf_8u_C1MR :
+ type == CV_16UC1 ? (ippiMaskNormDiffFuncC1)ippiNormRel_Inf_16u_C1MR :
+ type == CV_32FC1 ? (ippiMaskNormDiffFuncC1)ippiNormRel_Inf_32f_C1MR :
0) :
normType == NORM_L1 ?
- (type == CV_8UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L1_8u_C1MR :
-#if IPP_VERSION_X100 < 900
-#ifndef __APPLE__
- type == CV_8SC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L1_8s_C1MR :
-#endif
-#endif
- type == CV_16UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L1_16u_C1MR :
- type == CV_32FC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L1_32f_C1MR :
+ (type == CV_8UC1 ? (ippiMaskNormDiffFuncC1)ippiNormRel_L1_8u_C1MR :
+ type == CV_16UC1 ? (ippiMaskNormDiffFuncC1)ippiNormRel_L1_16u_C1MR :
+ type == CV_32FC1 ? (ippiMaskNormDiffFuncC1)ippiNormRel_L1_32f_C1MR :
0) :
normType == NORM_L2 || normType == NORM_L2SQR ?
- (type == CV_8UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L2_8u_C1MR :
-#if IPP_VERSION_X100 < 900
- type == CV_8SC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L2_8s_C1MR :
-#endif
- type == CV_16UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L2_16u_C1MR :
- type == CV_32FC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L2_32f_C1MR :
+ (type == CV_8UC1 ? (ippiMaskNormDiffFuncC1)ippiNormRel_L2_8u_C1MR :
+ type == CV_16UC1 ? (ippiMaskNormDiffFuncC1)ippiNormRel_L2_16u_C1MR :
+ type == CV_32FC1 ? (ippiMaskNormDiffFuncC1)ippiNormRel_L2_32f_C1MR :
0) : 0;
- if( ippiNormDiff_C1MR )
+ if( ippiNormRel_C1MR )
{
Ipp64f norm;
- if( CV_INSTRUMENT_FUN_IPP(ippiNormDiff_C1MR, src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], mask.ptr(), (int)mask.step[0], sz, &norm) >= 0 )
+ if( CV_INSTRUMENT_FUN_IPP(ippiNormRel_C1MR, src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], mask.ptr(), (int)mask.step[0], sz, &norm) >= 0 )
{
result = (normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm);
return true;
@@ -3302,47 +3434,43 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra
}
else
{
- typedef IppStatus (CV_STDCALL* ippiNormRelFuncNoHint)(const void *, int, const void *, int, IppiSize, Ipp64f *);
+ IppiSize sz = { cols*src1.channels(), rows };
+ int type = src1.depth();
+
typedef IppStatus (CV_STDCALL* ippiNormRelFuncHint)(const void *, int, const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint);
- ippiNormRelFuncNoHint ippiNormDiff =
- normType == NORM_INF ?
- (type == CV_8UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_8u_C1R :
- type == CV_16UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_16u_C1R :
- type == CV_16SC1 ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_16s_C1R :
- type == CV_32FC1 ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_32f_C1R :
- 0) :
+ typedef IppStatus (CV_STDCALL* ippiNormRelFuncNoHint)(const void *, int, const void *, int, IppiSize, Ipp64f *);
+ ippiNormRelFuncHint ippiNormRelHint =
normType == NORM_L1 ?
- (type == CV_8UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_L1_8u_C1R :
- type == CV_16UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_L1_16u_C1R :
- type == CV_16SC1 ? (ippiNormRelFuncNoHint)ippiNormRel_L1_16s_C1R :
+ (type == CV_32F ? (ippiNormRelFuncHint)ippiNormRel_L1_32f_C1R :
0) :
normType == NORM_L2 || normType == NORM_L2SQR ?
- (type == CV_8UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_L2_8u_C1R :
- type == CV_16UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_L2_16u_C1R :
- type == CV_16SC1 ? (ippiNormRelFuncNoHint)ippiNormRel_L2_16s_C1R :
+ (type == CV_32F ? (ippiNormRelFuncHint)ippiNormRel_L2_32f_C1R :
0) : 0;
- ippiNormRelFuncHint ippiNormDiffHint =
+ ippiNormRelFuncNoHint ippiNormRel =
+ normType == NORM_INF ?
+ (type == CV_8U ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_8u_C1R :
+ type == CV_16U ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_16u_C1R :
+ type == CV_16S ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_16s_C1R :
+ type == CV_32F ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_32f_C1R :
+ 0) :
normType == NORM_L1 ?
- (type == CV_32FC1 ? (ippiNormRelFuncHint)ippiNormRel_L1_32f_C1R :
+ (type == CV_8U ? (ippiNormRelFuncNoHint)ippiNormRel_L1_8u_C1R :
+ type == CV_16U ? (ippiNormRelFuncNoHint)ippiNormRel_L1_16u_C1R :
+ type == CV_16S ? (ippiNormRelFuncNoHint)ippiNormRel_L1_16s_C1R :
0) :
normType == NORM_L2 || normType == NORM_L2SQR ?
- (type == CV_32FC1 ? (ippiNormRelFuncHint)ippiNormRel_L2_32f_C1R :
+ (type == CV_8U ? (ippiNormRelFuncNoHint)ippiNormRel_L2_8u_C1R :
+ type == CV_16U ? (ippiNormRelFuncNoHint)ippiNormRel_L2_16u_C1R :
+ type == CV_16S ? (ippiNormRelFuncNoHint)ippiNormRel_L2_16s_C1R :
0) : 0;
- if (ippiNormDiff)
+ if( ippiNormRelHint || ippiNormRel )
{
Ipp64f norm;
- if( CV_INSTRUMENT_FUN_IPP(ippiNormDiff, src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, &norm) >= 0 )
+ IppStatus ret = ippiNormRelHint ? CV_INSTRUMENT_FUN_IPP(ippiNormRelHint, src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, &norm, ippAlgHintAccurate) :
+ CV_INSTRUMENT_FUN_IPP(ippiNormRel, src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, &norm);
+ if( ret >= 0 )
{
- result = (double)norm;
- return true;
- }
- }
- if (ippiNormDiffHint)
- {
- Ipp64f norm;
- if( CV_INSTRUMENT_FUN_IPP(ippiNormDiffHint, src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, &norm, ippAlgHintAccurate) >= 0 )
- {
- result = (double)norm;
+ result = (normType == NORM_L2SQR) ? norm * norm : norm;
return true;
}
}
@@ -3351,47 +3479,32 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra
return false;
}
- normType &= 7;
- CV_Assert( normType == NORM_INF || normType == NORM_L1 ||
- normType == NORM_L2 || normType == NORM_L2SQR ||
- ((normType == NORM_HAMMING || normType == NORM_HAMMING2) && src1.type() == CV_8U) );
+ normType &= NORM_TYPE_MASK;
size_t total_size = src1.total();
int rows = src1.size[0], cols = rows ? (int)(total_size/rows) : 0;
if( (src1.dims == 2 || (src1.isContinuous() && src2.isContinuous() && mask.isContinuous()))
- && cols > 0 && (size_t)rows*cols == total_size
- && (normType == NORM_INF || normType == NORM_L1 ||
- normType == NORM_L2 || normType == NORM_L2SQR) )
+ && cols > 0 && (size_t)rows*cols == total_size )
{
- IppiSize sz = { cols, rows };
- int type = src1.type();
if( !mask.empty() )
{
+ IppiSize sz = { cols, rows };
+ int type = src1.type();
+
typedef IppStatus (CV_STDCALL* ippiMaskNormDiffFuncC1)(const void *, int, const void *, int, const void *, int, IppiSize, Ipp64f *);
ippiMaskNormDiffFuncC1 ippiNormDiff_C1MR =
normType == NORM_INF ?
(type == CV_8UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_Inf_8u_C1MR :
-#if IPP_VERSION_X100 < 900
- type == CV_8SC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_Inf_8s_C1MR :
-#endif
type == CV_16UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_Inf_16u_C1MR :
type == CV_32FC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_Inf_32f_C1MR :
0) :
normType == NORM_L1 ?
(type == CV_8UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L1_8u_C1MR :
-#if IPP_VERSION_X100 < 900
-#ifndef __APPLE__
- type == CV_8SC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L1_8s_C1MR :
-#endif
-#endif
type == CV_16UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L1_16u_C1MR :
type == CV_32FC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L1_32f_C1MR :
0) :
normType == NORM_L2 || normType == NORM_L2SQR ?
(type == CV_8UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L2_8u_C1MR :
-#if IPP_VERSION_X100 < 900
- type == CV_8SC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L2_8s_C1MR :
-#endif
type == CV_16UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L2_16u_C1MR :
type == CV_32FC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L2_32f_C1MR :
0) : 0;
@@ -3404,30 +3517,20 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra
return true;
}
}
-#ifndef __APPLE__
typedef IppStatus (CV_STDCALL* ippiMaskNormDiffFuncC3)(const void *, int, const void *, int, const void *, int, IppiSize, int, Ipp64f *);
ippiMaskNormDiffFuncC3 ippiNormDiff_C3CMR =
normType == NORM_INF ?
(type == CV_8UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_Inf_8u_C3CMR :
-#if IPP_VERSION_X100 < 900
- type == CV_8SC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_Inf_8s_C3CMR :
-#endif
type == CV_16UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_Inf_16u_C3CMR :
type == CV_32FC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_Inf_32f_C3CMR :
0) :
normType == NORM_L1 ?
(type == CV_8UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L1_8u_C3CMR :
-#if IPP_VERSION_X100 < 900
- type == CV_8SC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L1_8s_C3CMR :
-#endif
type == CV_16UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L1_16u_C3CMR :
type == CV_32FC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L1_32f_C3CMR :
0) :
normType == NORM_L2 || normType == NORM_L2SQR ?
(type == CV_8UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L2_8u_C3CMR :
-#if IPP_VERSION_X100 < 900
- type == CV_8SC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L2_8s_C3CMR :
-#endif
type == CV_16UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L2_16u_C3CMR :
type == CV_32FC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L2_32f_C3CMR :
0) : 0;
@@ -3447,83 +3550,46 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra
return true;
}
}
-#endif
}
else
{
+ IppiSize sz = { cols*src1.channels(), rows };
+ int type = src1.depth();
+
typedef IppStatus (CV_STDCALL* ippiNormDiffFuncHint)(const void *, int, const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint);
typedef IppStatus (CV_STDCALL* ippiNormDiffFuncNoHint)(const void *, int, const void *, int, IppiSize, Ipp64f *);
ippiNormDiffFuncHint ippiNormDiffHint =
normType == NORM_L1 ?
- (type == CV_32FC1 ? (ippiNormDiffFuncHint)ippiNormDiff_L1_32f_C1R :
- type == CV_32FC3 ? (ippiNormDiffFuncHint)ippiNormDiff_L1_32f_C3R :
- type == CV_32FC4 ? (ippiNormDiffFuncHint)ippiNormDiff_L1_32f_C4R :
+ (type == CV_32F ? (ippiNormDiffFuncHint)ippiNormDiff_L1_32f_C1R :
0) :
normType == NORM_L2 || normType == NORM_L2SQR ?
- (type == CV_32FC1 ? (ippiNormDiffFuncHint)ippiNormDiff_L2_32f_C1R :
- type == CV_32FC3 ? (ippiNormDiffFuncHint)ippiNormDiff_L2_32f_C3R :
- type == CV_32FC4 ? (ippiNormDiffFuncHint)ippiNormDiff_L2_32f_C4R :
+ (type == CV_32F ? (ippiNormDiffFuncHint)ippiNormDiff_L2_32f_C1R :
0) : 0;
ippiNormDiffFuncNoHint ippiNormDiff =
normType == NORM_INF ?
- (type == CV_8UC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_8u_C1R :
- type == CV_8UC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_8u_C3R :
- type == CV_8UC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_8u_C4R :
- type == CV_16UC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_16u_C1R :
- type == CV_16UC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_16u_C3R :
- type == CV_16UC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_16u_C4R :
- type == CV_16SC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_16s_C1R :
-#if (IPP_VERSION_X100 >= 810)
- type == CV_16SC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_16s_C3R : //Aug 2013: problem in IPP 7.1, 8.0 : -32768
- type == CV_16SC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_16s_C4R : //Aug 2013: problem in IPP 7.1, 8.0 : -32768
-#endif
- type == CV_32FC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_32f_C1R :
- type == CV_32FC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_32f_C3R :
- type == CV_32FC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_32f_C4R :
+ (type == CV_8U ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_8u_C1R :
+ type == CV_16U ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_16u_C1R :
+ type == CV_16S ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_16s_C1R :
+ type == CV_32F ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_32f_C1R :
0) :
normType == NORM_L1 ?
- (type == CV_8UC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_8u_C1R :
- type == CV_8UC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_8u_C3R :
- type == CV_8UC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_8u_C4R :
- type == CV_16UC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_16u_C1R :
- type == CV_16UC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_16u_C3R :
- type == CV_16UC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_16u_C4R :
-#if !(IPP_VERSION_X100 == 820 || IPP_VERSION_X100 == 821) // Oct 2014: Accuracy issue with IPP 8.2 / 8.2.1
- type == CV_16SC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_16s_C1R :
-#endif
- type == CV_16SC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_16s_C3R :
- type == CV_16SC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_16s_C4R :
+ (type == CV_8U ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_8u_C1R :
+ type == CV_16U ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_16u_C1R :
+ type == CV_16S ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_16s_C1R :
0) :
normType == NORM_L2 || normType == NORM_L2SQR ?
- (type == CV_8UC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_8u_C1R :
- type == CV_8UC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_8u_C3R :
- type == CV_8UC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_8u_C4R :
- type == CV_16UC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_16u_C1R :
- type == CV_16UC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_16u_C3R :
- type == CV_16UC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_16u_C4R :
- type == CV_16SC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_16s_C1R :
- type == CV_16SC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_16s_C3R :
- type == CV_16SC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_16s_C4R :
+ (type == CV_8U ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_8u_C1R :
+ type == CV_16U ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_16u_C1R :
+ type == CV_16S ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_16s_C1R :
0) : 0;
- // Make sure only zero or one version of the function pointer is valid
- CV_Assert(!ippiNormDiffHint || !ippiNormDiff);
if( ippiNormDiffHint || ippiNormDiff )
{
- Ipp64f norm_array[4];
- IppStatus ret = ippiNormDiffHint ? CV_INSTRUMENT_FUN_IPP(ippiNormDiffHint, src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, norm_array, ippAlgHintAccurate) :
- CV_INSTRUMENT_FUN_IPP(ippiNormDiff, src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, norm_array);
+ Ipp64f norm;
+ IppStatus ret = ippiNormDiffHint ? CV_INSTRUMENT_FUN_IPP(ippiNormDiffHint, src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, &norm, ippAlgHintAccurate) :
+ CV_INSTRUMENT_FUN_IPP(ippiNormDiff, src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, &norm);
if( ret >= 0 )
{
- Ipp64f norm = (normType == NORM_L2 || normType == NORM_L2SQR) ? norm_array[0] * norm_array[0] : norm_array[0];
- for( int i = 1; i < src1.channels(); i++ )
- {
- norm =
- normType == NORM_INF ? std::max(norm, norm_array[i]) :
- normType == NORM_L1 ? norm + norm_array[i] :
- normType == NORM_L2 || normType == NORM_L2SQR ? norm + norm_array[i] * norm_array[i] :
- 0;
- }
- result = (normType == NORM_L2 ? (double)std::sqrt(norm) : (double)norm);
+ result = (normType == NORM_L2SQR) ? norm * norm : norm;
return true;
}
}
@@ -4188,7 +4254,7 @@ cvNorm( const void* imgA, const void* imgB, int normType, const void* maskarr )
namespace cv { namespace hal {
-static const uchar popCountTable[] =
+extern const uchar popCountTable[256] =
{
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
@@ -4224,116 +4290,6 @@ static const uchar popCountTable4[] =
1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
};
-#if CV_AVX2
-static inline int _mm256_extract_epi32_(__m256i reg, const int i)
-{
- CV_DECL_ALIGNED(32) int reg_data[8];
- CV_DbgAssert(0 <= i && i < 8);
- _mm256_store_si256((__m256i*)reg_data, reg);
- return reg_data[i];
-}
-#endif
-
-int normHamming(const uchar* a, int n)
-{
- int i = 0;
- int result = 0;
-#if CV_NEON
- {
- uint32x4_t bits = vmovq_n_u32(0);
- for (; i <= n - 16; i += 16) {
- uint8x16_t A_vec = vld1q_u8 (a + i);
- uint8x16_t bitsSet = vcntq_u8 (A_vec);
- uint16x8_t bitSet8 = vpaddlq_u8 (bitsSet);
- uint32x4_t bitSet4 = vpaddlq_u16 (bitSet8);
- bits = vaddq_u32(bits, bitSet4);
- }
- uint64x2_t bitSet2 = vpaddlq_u32 (bits);
- result = vgetq_lane_s32 (vreinterpretq_s32_u64(bitSet2),0);
- result += vgetq_lane_s32 (vreinterpretq_s32_u64(bitSet2),2);
- }
-#elif CV_AVX2
- {
- __m256i _r0 = _mm256_setzero_si256();
- __m256i _0 = _mm256_setzero_si256();
- __m256i _popcnt_table = _mm256_setr_epi8(0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
- 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4);
- __m256i _popcnt_mask = _mm256_set1_epi8(0x0F);
-
- for(; i <= n - 32; i+= 32)
- {
- __m256i _a0 = _mm256_loadu_si256((const __m256i*)(a + i));
-
- __m256i _popc0 = _mm256_shuffle_epi8(_popcnt_table, _mm256_and_si256(_a0, _popcnt_mask));
- __m256i _popc1 = _mm256_shuffle_epi8(_popcnt_table,
- _mm256_and_si256(_mm256_srli_epi16(_a0, 4), _popcnt_mask));
-
- _r0 = _mm256_add_epi32(_r0, _mm256_sad_epu8(_0, _mm256_add_epi8(_popc0, _popc1)));
- }
- _r0 = _mm256_add_epi32(_r0, _mm256_shuffle_epi32(_r0, 2));
- result = _mm256_extract_epi32_(_mm256_add_epi32(_r0, _mm256_permute2x128_si256(_r0, _r0, 1)), 0);
- }
-#endif
- for( ; i <= n - 4; i += 4 )
- result += popCountTable[a[i]] + popCountTable[a[i+1]] +
- popCountTable[a[i+2]] + popCountTable[a[i+3]];
- for( ; i < n; i++ )
- result += popCountTable[a[i]];
- return result;
-}
-
-int normHamming(const uchar* a, const uchar* b, int n)
-{
- int i = 0;
- int result = 0;
-#if CV_NEON
- {
- uint32x4_t bits = vmovq_n_u32(0);
- for (; i <= n - 16; i += 16) {
- uint8x16_t A_vec = vld1q_u8 (a + i);
- uint8x16_t B_vec = vld1q_u8 (b + i);
- uint8x16_t AxorB = veorq_u8 (A_vec, B_vec);
- uint8x16_t bitsSet = vcntq_u8 (AxorB);
- uint16x8_t bitSet8 = vpaddlq_u8 (bitsSet);
- uint32x4_t bitSet4 = vpaddlq_u16 (bitSet8);
- bits = vaddq_u32(bits, bitSet4);
- }
- uint64x2_t bitSet2 = vpaddlq_u32 (bits);
- result = vgetq_lane_s32 (vreinterpretq_s32_u64(bitSet2),0);
- result += vgetq_lane_s32 (vreinterpretq_s32_u64(bitSet2),2);
- }
-#elif CV_AVX2
- {
- __m256i _r0 = _mm256_setzero_si256();
- __m256i _0 = _mm256_setzero_si256();
- __m256i _popcnt_table = _mm256_setr_epi8(0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
- 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4);
- __m256i _popcnt_mask = _mm256_set1_epi8(0x0F);
-
- for(; i <= n - 32; i+= 32)
- {
- __m256i _a0 = _mm256_loadu_si256((const __m256i*)(a + i));
- __m256i _b0 = _mm256_loadu_si256((const __m256i*)(b + i));
-
- __m256i _xor = _mm256_xor_si256(_a0, _b0);
-
- __m256i _popc0 = _mm256_shuffle_epi8(_popcnt_table, _mm256_and_si256(_xor, _popcnt_mask));
- __m256i _popc1 = _mm256_shuffle_epi8(_popcnt_table,
- _mm256_and_si256(_mm256_srli_epi16(_xor, 4), _popcnt_mask));
-
- _r0 = _mm256_add_epi32(_r0, _mm256_sad_epu8(_0, _mm256_add_epi8(_popc0, _popc1)));
- }
- _r0 = _mm256_add_epi32(_r0, _mm256_shuffle_epi32(_r0, 2));
- result = _mm256_extract_epi32_(_mm256_add_epi32(_r0, _mm256_permute2x128_si256(_r0, _r0, 1)), 0);
- }
-#endif
- for( ; i <= n - 4; i += 4 )
- result += popCountTable[a[i] ^ b[i]] + popCountTable[a[i+1] ^ b[i+1]] +
- popCountTable[a[i+2] ^ b[i+2]] + popCountTable[a[i+3] ^ b[i+3]];
- for( ; i < n; i++ )
- result += popCountTable[a[i] ^ b[i]];
- return result;
-}
int normHamming(const uchar* a, int n, int cellSize)
{
@@ -4370,11 +4326,11 @@ int normHamming(const uchar* a, const uchar* b, int n, int cellSize)
return -1;
int i = 0;
int result = 0;
- #if CV_ENABLE_UNROLLED
+#if CV_ENABLE_UNROLLED
for( ; i <= n - 4; i += 4 )
result += tab[a[i] ^ b[i]] + tab[a[i+1] ^ b[i+1]] +
tab[a[i+2] ^ b[i+2]] + tab[a[i+3] ^ b[i+3]];
- #endif
+#endif
for( ; i < n; i++ )
result += tab[a[i] ^ b[i]];
return result;
@@ -4383,7 +4339,22 @@ int normHamming(const uchar* a, const uchar* b, int n, int cellSize)
float normL2Sqr_(const float* a, const float* b, int n)
{
int j = 0; float d = 0.f;
-#if CV_SSE
+#if CV_AVX2
+ float CV_DECL_ALIGNED(32) buf[8];
+ __m256 d0 = _mm256_setzero_ps();
+
+ for( ; j <= n - 8; j += 8 )
+ {
+ __m256 t0 = _mm256_sub_ps(_mm256_loadu_ps(a + j), _mm256_loadu_ps(b + j));
+#ifdef CV_FMA3
+ d0 = _mm256_fmadd_ps(t0, t0, d0);
+#else
+ d0 = _mm256_add_ps(d0, _mm256_mul_ps(t0, t0));
+#endif
+ }
+ _mm256_store_ps(buf, d0);
+ d = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6] + buf[7];
+#elif CV_SSE
float CV_DECL_ALIGNED(16) buf[4];
__m128 d0 = _mm_setzero_ps(), d1 = _mm_setzero_ps();
diff --git a/modules/core/src/stat.dispatch.cpp b/modules/core/src/stat.dispatch.cpp
new file mode 100644
index 0000000..025c092
--- /dev/null
+++ b/modules/core/src/stat.dispatch.cpp
@@ -0,0 +1,28 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "precomp.hpp"
+
+#include "stat.simd.hpp"
+#include "stat.simd_declarations.hpp" // defines CV_CPU_DISPATCH_MODES_ALL=AVX2,...,BASELINE based on CMakeLists.txt content
+
+namespace cv { namespace hal {
+
+int normHamming(const uchar* a, int n)
+{
+ CV_INSTRUMENT_REGION()
+
+ CV_CPU_DISPATCH(normHamming, (a, n),
+ CV_CPU_DISPATCH_MODES_ALL);
+}
+
+int normHamming(const uchar* a, const uchar* b, int n)
+{
+ CV_INSTRUMENT_REGION()
+
+ CV_CPU_DISPATCH(normHamming, (a, b, n),
+ CV_CPU_DISPATCH_MODES_ALL);
+}
+
+}} //cv::hal
diff --git a/modules/core/src/stat.simd.hpp b/modules/core/src/stat.simd.hpp
new file mode 100644
index 0000000..b75100d
--- /dev/null
+++ b/modules/core/src/stat.simd.hpp
@@ -0,0 +1,171 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "opencv2/core/hal/intrin.hpp"
+
+namespace cv { namespace hal {
+
+extern const uchar popCountTable[256];
+
+CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
+
+// forward declarations
+int normHamming(const uchar* a, int n);
+int normHamming(const uchar* a, const uchar* b, int n);
+
+#ifndef CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
+
+#if CV_AVX2
+static inline int _mm256_extract_epi32_(__m256i reg, const int i)
+{
+ CV_DECL_ALIGNED(32) int reg_data[8];
+ CV_DbgAssert(0 <= i && i < 8);
+ _mm256_store_si256((__m256i*)reg_data, reg);
+ return reg_data[i];
+}
+#endif
+
+int normHamming(const uchar* a, int n)
+{
+ CV_AVX_GUARD;
+
+ int i = 0;
+ int result = 0;
+#if CV_AVX2
+ {
+ __m256i _r0 = _mm256_setzero_si256();
+ __m256i _0 = _mm256_setzero_si256();
+ __m256i _popcnt_table = _mm256_setr_epi8(0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
+ 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4);
+ __m256i _popcnt_mask = _mm256_set1_epi8(0x0F);
+
+ for(; i <= n - 32; i+= 32)
+ {
+ __m256i _a0 = _mm256_loadu_si256((const __m256i*)(a + i));
+
+ __m256i _popc0 = _mm256_shuffle_epi8(_popcnt_table, _mm256_and_si256(_a0, _popcnt_mask));
+ __m256i _popc1 = _mm256_shuffle_epi8(_popcnt_table,
+ _mm256_and_si256(_mm256_srli_epi16(_a0, 4), _popcnt_mask));
+
+ _r0 = _mm256_add_epi32(_r0, _mm256_sad_epu8(_0, _mm256_add_epi8(_popc0, _popc1)));
+ }
+ _r0 = _mm256_add_epi32(_r0, _mm256_shuffle_epi32(_r0, 2));
+ result = _mm256_extract_epi32_(_mm256_add_epi32(_r0, _mm256_permute2x128_si256(_r0, _r0, 1)), 0);
+ }
+#endif // CV_AVX2
+
+#if CV_POPCNT
+ {
+# if defined CV_POPCNT_U64
+ for(; i <= n - 8; i += 8)
+ {
+ result += (int)CV_POPCNT_U64(*(uint64*)(a + i));
+ }
+# endif
+ for(; i <= n - 4; i += 4)
+ {
+ result += CV_POPCNT_U32(*(uint*)(a + i));
+ }
+ }
+#endif // CV_POPCNT
+
+#if CV_SIMD128
+ {
+ v_uint32x4 t = v_setzero_u32();
+ for(; i <= n - v_uint8x16::nlanes; i += v_uint8x16::nlanes)
+ {
+ t += v_popcount(v_load(a + i));
+ }
+ result += v_reduce_sum(t);
+ }
+#endif // CV_SIMD128
+#if CV_ENABLE_UNROLLED
+ for(; i <= n - 4; i += 4)
+ {
+ result += popCountTable[a[i]] + popCountTable[a[i+1]] +
+ popCountTable[a[i+2]] + popCountTable[a[i+3]];
+ }
+#endif
+ for(; i < n; i++)
+ {
+ result += popCountTable[a[i]];
+ }
+ return result;
+}
+
+int normHamming(const uchar* a, const uchar* b, int n)
+{
+ CV_AVX_GUARD;
+
+ int i = 0;
+ int result = 0;
+#if CV_AVX2
+ {
+ __m256i _r0 = _mm256_setzero_si256();
+ __m256i _0 = _mm256_setzero_si256();
+ __m256i _popcnt_table = _mm256_setr_epi8(0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
+ 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4);
+ __m256i _popcnt_mask = _mm256_set1_epi8(0x0F);
+
+ for(; i <= n - 32; i+= 32)
+ {
+ __m256i _a0 = _mm256_loadu_si256((const __m256i*)(a + i));
+ __m256i _b0 = _mm256_loadu_si256((const __m256i*)(b + i));
+
+ __m256i _xor = _mm256_xor_si256(_a0, _b0);
+
+ __m256i _popc0 = _mm256_shuffle_epi8(_popcnt_table, _mm256_and_si256(_xor, _popcnt_mask));
+ __m256i _popc1 = _mm256_shuffle_epi8(_popcnt_table,
+ _mm256_and_si256(_mm256_srli_epi16(_xor, 4), _popcnt_mask));
+
+ _r0 = _mm256_add_epi32(_r0, _mm256_sad_epu8(_0, _mm256_add_epi8(_popc0, _popc1)));
+ }
+ _r0 = _mm256_add_epi32(_r0, _mm256_shuffle_epi32(_r0, 2));
+ result = _mm256_extract_epi32_(_mm256_add_epi32(_r0, _mm256_permute2x128_si256(_r0, _r0, 1)), 0);
+ }
+#endif // CV_AVX2
+
+#if CV_POPCNT
+ {
+# if defined CV_POPCNT_U64
+ for(; i <= n - 8; i += 8)
+ {
+ result += (int)CV_POPCNT_U64(*(uint64*)(a + i) ^ *(uint64*)(b + i));
+ }
+# endif
+ for(; i <= n - 4; i += 4)
+ {
+ result += CV_POPCNT_U32(*(uint*)(a + i) ^ *(uint*)(b + i));
+ }
+ }
+#endif // CV_POPCNT
+
+#if CV_SIMD128
+ {
+ v_uint32x4 t = v_setzero_u32();
+ for(; i <= n - v_uint8x16::nlanes; i += v_uint8x16::nlanes)
+ {
+ t += v_popcount(v_load(a + i) ^ v_load(b + i));
+ }
+ result += v_reduce_sum(t);
+ }
+#endif // CV_SIMD128
+#if CV_ENABLE_UNROLLED
+ for(; i <= n - 4; i += 4)
+ {
+ result += popCountTable[a[i] ^ b[i]] + popCountTable[a[i+1] ^ b[i+1]] +
+ popCountTable[a[i+2] ^ b[i+2]] + popCountTable[a[i+3] ^ b[i+3]];
+ }
+#endif
+ for(; i < n; i++)
+ {
+ result += popCountTable[a[i] ^ b[i]];
+ }
+ return result;
+}
+
+#endif // CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
+
+CV_CPU_OPTIMIZATION_NAMESPACE_END
+}} //cv::hal
diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp
index 3c8f39d..3eeb5fe 100644
--- a/modules/core/src/system.cpp
+++ b/modules/core/src/system.cpp
@@ -44,6 +44,8 @@
#include "precomp.hpp"
#include <iostream>
+#include <opencv2/core/utils/trace.private.hpp>
+
namespace cv {
static Mutex* __initialization_mutex = NULL;
@@ -64,16 +66,20 @@ Mutex* __initialization_mutex_initializer = &getInitializationMutex();
# endif
#endif
-#if defined ANDROID || defined __linux__ || defined __FreeBSD__
+#if defined __ANDROID__ || defined __linux__ || defined __FreeBSD__
# include <unistd.h>
# include <fcntl.h>
# include <elf.h>
-#if defined ANDROID || defined __linux__
+#if defined __ANDROID__ || defined __linux__
# include <linux/auxvec.h>
#endif
#endif
-#if defined WIN32 || defined _WIN32 || defined WINCE
+#if defined __ANDROID__ && defined HAVE_CPUFEATURES
+# include <cpu-features.h>
+#endif
+
+#if defined _WIN32 || defined WINCE
#ifndef _WIN32_WINNT // This is needed for the declaration of TryEnterCriticalSection in winbase.h with Visual Studio 2005 (and older?)
#define _WIN32_WINNT 0x0400 // http://msdn.microsoft.com/en-us/library/ms686857(VS.85).aspx
#endif
@@ -196,18 +202,16 @@ std::wstring GetTempFileNameWinRT(std::wstring prefix)
#include "omp.h"
#endif
-#include <stdarg.h>
-
#if defined __linux__ || defined __APPLE__ || defined __EMSCRIPTEN__ || defined __FreeBSD__
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
-#if defined ANDROID
+#if defined __ANDROID__
#include <sys/sysconf.h>
#endif
#endif
-#ifdef ANDROID
+#ifdef __ANDROID__
# include <android/log.h>
#endif
@@ -237,24 +241,81 @@ void Exception::formatMessage()
msg = format("%s:%d: error: (%d) %s\n", file.c_str(), line, code, err.c_str());
}
+static const char* g_hwFeatureNames[CV_HARDWARE_MAX_FEATURE] = { NULL };
+
+static const char* getHWFeatureName(int id)
+{
+ return (id < CV_HARDWARE_MAX_FEATURE) ? g_hwFeatureNames[id] : NULL;
+}
+static const char* getHWFeatureNameSafe(int id)
+{
+ const char* name = getHWFeatureName(id);
+ return name ? name : "Unknown feature";
+}
+
struct HWFeatures
{
enum { MAX_FEATURE = CV_HARDWARE_MAX_FEATURE };
- HWFeatures(void)
+ HWFeatures(bool run_initialize = false)
{
- memset( have, 0, sizeof(have) );
- x86_family = 0;
+ memset( have, 0, sizeof(have[0]) * MAX_FEATURE );
+ if (run_initialize)
+ initialize();
}
- static HWFeatures initialize(void)
+ static void initializeNames()
{
- HWFeatures f;
+ for (int i = 0; i < CV_HARDWARE_MAX_FEATURE; i++)
+ {
+ g_hwFeatureNames[i] = 0;
+ }
+ g_hwFeatureNames[CPU_MMX] = "MMX";
+ g_hwFeatureNames[CPU_SSE] = "SSE";
+ g_hwFeatureNames[CPU_SSE2] = "SSE2";
+ g_hwFeatureNames[CPU_SSE3] = "SSE3";
+ g_hwFeatureNames[CPU_SSSE3] = "SSSE3";
+ g_hwFeatureNames[CPU_SSE4_1] = "SSE4.1";
+ g_hwFeatureNames[CPU_SSE4_2] = "SSE4.2";
+ g_hwFeatureNames[CPU_POPCNT] = "POPCNT";
+ g_hwFeatureNames[CPU_FP16] = "FP16";
+ g_hwFeatureNames[CPU_AVX] = "AVX";
+ g_hwFeatureNames[CPU_AVX2] = "AVX2";
+ g_hwFeatureNames[CPU_FMA3] = "FMA3";
+
+ g_hwFeatureNames[CPU_AVX_512F] = "AVX512F";
+ g_hwFeatureNames[CPU_AVX_512BW] = "AVX512BW";
+ g_hwFeatureNames[CPU_AVX_512CD] = "AVX512CD";
+ g_hwFeatureNames[CPU_AVX_512DQ] = "AVX512DQ";
+ g_hwFeatureNames[CPU_AVX_512ER] = "AVX512ER";
+ g_hwFeatureNames[CPU_AVX_512IFMA512] = "AVX512IFMA";
+ g_hwFeatureNames[CPU_AVX_512PF] = "AVX512PF";
+ g_hwFeatureNames[CPU_AVX_512VBMI] = "AVX512VBMI";
+ g_hwFeatureNames[CPU_AVX_512VL] = "AVX512VL";
+
+ g_hwFeatureNames[CPU_NEON] = "NEON";
+ }
+
+ void initialize(void)
+ {
+#ifndef WINRT
+ if (getenv("OPENCV_DUMP_CONFIG"))
+ {
+ fprintf(stderr, "\nOpenCV build configuration is:\n%s\n",
+ cv::getBuildInformation().c_str());
+ }
+#endif
+
+ initializeNames();
+
int cpuid_data[4] = { 0, 0, 0, 0 };
+ int cpuid_data_ex[4] = { 0, 0, 0, 0 };
#if defined _MSC_VER && (defined _M_IX86 || defined _M_X64)
+ #define OPENCV_HAVE_X86_CPUID 1
__cpuid(cpuid_data, 1);
#elif defined __GNUC__ && (defined __i386__ || defined __x86_64__)
+ #define OPENCV_HAVE_X86_CPUID 1
#ifdef __x86_64__
asm __volatile__
(
@@ -278,33 +339,36 @@ struct HWFeatures
#endif
#endif
- f.x86_family = (cpuid_data[0] >> 8) & 15;
- if( f.x86_family >= 6 )
+ #ifdef OPENCV_HAVE_X86_CPUID
+ int x86_family = (cpuid_data[0] >> 8) & 15;
+ if( x86_family >= 6 )
{
- f.have[CV_CPU_MMX] = (cpuid_data[3] & (1 << 23)) != 0;
- f.have[CV_CPU_SSE] = (cpuid_data[3] & (1<<25)) != 0;
- f.have[CV_CPU_SSE2] = (cpuid_data[3] & (1<<26)) != 0;
- f.have[CV_CPU_SSE3] = (cpuid_data[2] & (1<<0)) != 0;
- f.have[CV_CPU_SSSE3] = (cpuid_data[2] & (1<<9)) != 0;
- f.have[CV_CPU_FMA3] = (cpuid_data[2] & (1<<12)) != 0;
- f.have[CV_CPU_SSE4_1] = (cpuid_data[2] & (1<<19)) != 0;
- f.have[CV_CPU_SSE4_2] = (cpuid_data[2] & (1<<20)) != 0;
- f.have[CV_CPU_POPCNT] = (cpuid_data[2] & (1<<23)) != 0;
- f.have[CV_CPU_AVX] = (((cpuid_data[2] & (1<<28)) != 0)&&((cpuid_data[2] & (1<<27)) != 0));//OS uses XSAVE_XRSTORE and CPU support AVX
- f.have[CV_CPU_FP16] = (cpuid_data[2] & (1<<29)) != 0;
+ have[CV_CPU_MMX] = (cpuid_data[3] & (1<<23)) != 0;
+ have[CV_CPU_SSE] = (cpuid_data[3] & (1<<25)) != 0;
+ have[CV_CPU_SSE2] = (cpuid_data[3] & (1<<26)) != 0;
+ have[CV_CPU_SSE3] = (cpuid_data[2] & (1<<0)) != 0;
+ have[CV_CPU_SSSE3] = (cpuid_data[2] & (1<<9)) != 0;
+ have[CV_CPU_FMA3] = (cpuid_data[2] & (1<<12)) != 0;
+ have[CV_CPU_SSE4_1] = (cpuid_data[2] & (1<<19)) != 0;
+ have[CV_CPU_SSE4_2] = (cpuid_data[2] & (1<<20)) != 0;
+ have[CV_CPU_POPCNT] = (cpuid_data[2] & (1<<23)) != 0;
+ have[CV_CPU_AVX] = (cpuid_data[2] & (1<<28)) != 0;
+ have[CV_CPU_FP16] = (cpuid_data[2] & (1<<29)) != 0;
// make the second call to the cpuid command in order to get
// information about extended features like AVX2
#if defined _MSC_VER && (defined _M_IX86 || defined _M_X64)
- __cpuidex(cpuid_data, 7, 0);
+ #define OPENCV_HAVE_X86_CPUID_EX 1
+ __cpuidex(cpuid_data_ex, 7, 0);
#elif defined __GNUC__ && (defined __i386__ || defined __x86_64__)
+ #define OPENCV_HAVE_X86_CPUID_EX 1
#ifdef __x86_64__
asm __volatile__
(
"movl $7, %%eax\n\t"
"movl $0, %%ecx\n\t"
"cpuid\n\t"
- :[eax]"=a"(cpuid_data[0]),[ebx]"=b"(cpuid_data[1]),[ecx]"=c"(cpuid_data[2]),[edx]"=d"(cpuid_data[3])
+ :[eax]"=a"(cpuid_data_ex[0]),[ebx]"=b"(cpuid_data_ex[1]),[ecx]"=c"(cpuid_data_ex[2]),[edx]"=d"(cpuid_data_ex[3])
:
: "cc"
);
@@ -317,29 +381,98 @@ struct HWFeatures
"cpuid\n\t"
"movl %%ebx, %0\n\t"
"popl %%ebx\n\t"
- : "=r"(cpuid_data[1]), "=c"(cpuid_data[2])
+ : "=r"(cpuid_data_ex[1]), "=c"(cpuid_data_ex[2])
:
: "cc"
);
#endif
#endif
- f.have[CV_CPU_AVX2] = (cpuid_data[1] & (1<<5)) != 0;
-
- f.have[CV_CPU_AVX_512F] = (cpuid_data[1] & (1<<16)) != 0;
- f.have[CV_CPU_AVX_512DQ] = (cpuid_data[1] & (1<<17)) != 0;
- f.have[CV_CPU_AVX_512IFMA512] = (cpuid_data[1] & (1<<21)) != 0;
- f.have[CV_CPU_AVX_512PF] = (cpuid_data[1] & (1<<26)) != 0;
- f.have[CV_CPU_AVX_512ER] = (cpuid_data[1] & (1<<27)) != 0;
- f.have[CV_CPU_AVX_512CD] = (cpuid_data[1] & (1<<28)) != 0;
- f.have[CV_CPU_AVX_512BW] = (cpuid_data[1] & (1<<30)) != 0;
- f.have[CV_CPU_AVX_512VL] = (cpuid_data[1] & (1<<31)) != 0;
- f.have[CV_CPU_AVX_512VBMI] = (cpuid_data[2] & (1<<1)) != 0;
+
+ #ifdef OPENCV_HAVE_X86_CPUID_EX
+ have[CV_CPU_AVX2] = (cpuid_data_ex[1] & (1<<5)) != 0;
+
+ have[CV_CPU_AVX_512F] = (cpuid_data_ex[1] & (1<<16)) != 0;
+ have[CV_CPU_AVX_512DQ] = (cpuid_data_ex[1] & (1<<17)) != 0;
+ have[CV_CPU_AVX_512IFMA512] = (cpuid_data_ex[1] & (1<<21)) != 0;
+ have[CV_CPU_AVX_512PF] = (cpuid_data_ex[1] & (1<<26)) != 0;
+ have[CV_CPU_AVX_512ER] = (cpuid_data_ex[1] & (1<<27)) != 0;
+ have[CV_CPU_AVX_512CD] = (cpuid_data_ex[1] & (1<<28)) != 0;
+ have[CV_CPU_AVX_512BW] = (cpuid_data_ex[1] & (1<<30)) != 0;
+ have[CV_CPU_AVX_512VL] = (cpuid_data_ex[1] & (1<<31)) != 0;
+ have[CV_CPU_AVX_512VBMI] = (cpuid_data_ex[2] & (1<<1)) != 0;
+ #else
+ CV_UNUSED(cpuid_data_ex);
+ #endif
+
+ bool have_AVX_OS_support = true;
+ bool have_AVX512_OS_support = true;
+ if (!(cpuid_data[2] & (1<<27)))
+ have_AVX_OS_support = false; // OS uses XSAVE_XRSTORE and CPU support AVX
+ else
+ {
+ int xcr0 = 0;
+ #ifdef _XCR_XFEATURE_ENABLED_MASK // requires immintrin.h
+ xcr0 = (int)_xgetbv(_XCR_XFEATURE_ENABLED_MASK);
+ #elif defined __GNUC__ && (defined __i386__ || defined __x86_64__)
+ __asm__ ("xgetbv" : "=a" (xcr0) : "c" (0) : "%edx" );
+ #endif
+ if ((xcr0 & 0x6) != 0x6)
+ have_AVX_OS_support = false; // YMM registers
+ if ((xcr0 & 0xe6) != 0xe6)
+ have_AVX512_OS_support = false; // ZMM registers
+ }
+
+ if (!have_AVX_OS_support)
+ {
+ have[CV_CPU_AVX] = false;
+ have[CV_CPU_FP16] = false;
+ have[CV_CPU_AVX2] = false;
+ have[CV_CPU_FMA3] = false;
+ }
+ if (!have_AVX_OS_support || !have_AVX512_OS_support)
+ {
+ have[CV_CPU_AVX_512F] = false;
+ have[CV_CPU_AVX_512BW] = false;
+ have[CV_CPU_AVX_512CD] = false;
+ have[CV_CPU_AVX_512DQ] = false;
+ have[CV_CPU_AVX_512ER] = false;
+ have[CV_CPU_AVX_512IFMA512] = false;
+ have[CV_CPU_AVX_512PF] = false;
+ have[CV_CPU_AVX_512VBMI] = false;
+ have[CV_CPU_AVX_512VL] = false;
+ }
}
+ #else
+ CV_UNUSED(cpuid_data);
+ CV_UNUSED(cpuid_data_ex);
+ #endif // OPENCV_HAVE_X86_CPUID
- #if defined ANDROID || defined __linux__
+ #if defined __ANDROID__ || defined __linux__
#ifdef __aarch64__
- f.have[CV_CPU_NEON] = true;
- f.have[CV_CPU_FP16] = true;
+ have[CV_CPU_NEON] = true;
+ have[CV_CPU_FP16] = true;
+ #elif defined __arm__ && defined __ANDROID__
+ #if defined HAVE_CPUFEATURES
+ __android_log_print(ANDROID_LOG_INFO, "OpenCV", "calling android_getCpuFeatures() ...");
+ uint64_t features = android_getCpuFeatures();
+ __android_log_print(ANDROID_LOG_INFO, "OpenCV", "calling android_getCpuFeatures() ... Done (%llx)", features);
+ have[CV_CPU_NEON] = (features & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
+ have[CV_CPU_FP16] = (features & ANDROID_CPU_ARM_FEATURE_VFP_FP16) != 0;
+ #else
+ __android_log_print(ANDROID_LOG_INFO, "OpenCV", "cpufeatures library is not avaialble for CPU detection");
+ #if CV_NEON
+ __android_log_print(ANDROID_LOG_INFO, "OpenCV", "- NEON instructions is enabled via build flags");
+ have[CV_CPU_NEON] = true;
+ #else
+ __android_log_print(ANDROID_LOG_INFO, "OpenCV", "- NEON instructions is NOT enabled via build flags");
+ #endif
+ #if CV_FP16
+ __android_log_print(ANDROID_LOG_INFO, "OpenCV", "- FP16 instructions is enabled via build flags");
+ have[CV_CPU_FP16] = true;
+ #else
+ __android_log_print(ANDROID_LOG_INFO, "OpenCV", "- FP16 instructions is NOT enabled via build flags");
+ #endif
+ #endif
#elif defined __arm__
int cpufile = open("/proc/self/auxv", O_RDONLY);
@@ -352,8 +485,8 @@ struct HWFeatures
{
if (auxv.a_type == AT_HWCAP)
{
- f.have[CV_CPU_NEON] = (auxv.a_un.a_val & 4096) != 0;
- f.have[CV_CPU_FP16] = (auxv.a_un.a_val & 2) != 0;
+ have[CV_CPU_NEON] = (auxv.a_un.a_val & 4096) != 0;
+ have[CV_CPU_FP16] = (auxv.a_un.a_val & 2) != 0;
break;
}
}
@@ -363,21 +496,133 @@ struct HWFeatures
#endif
#elif (defined __clang__ || defined __APPLE__)
#if (defined __ARM_NEON__ || (defined __ARM_NEON && defined __aarch64__))
- f.have[CV_CPU_NEON] = true;
+ have[CV_CPU_NEON] = true;
#endif
#if (defined __ARM_FP && (((__ARM_FP & 0x2) != 0) && defined __ARM_NEON__))
- f.have[CV_CPU_FP16] = true;
+ have[CV_CPU_FP16] = true;
#endif
#endif
- return f;
+ int baseline_features[] = { CV_CPU_BASELINE_FEATURES };
+ if (!checkFeatures(baseline_features, sizeof(baseline_features) / sizeof(baseline_features[0])))
+ {
+ fprintf(stderr, "\n"
+ "******************************************************************\n"
+ "* FATAL ERROR: *\n"
+ "* This OpenCV build doesn't support current CPU/HW configuration *\n"
+ "* *\n"
+ "* Use OPENCV_DUMP_CONFIG=1 environment variable for details *\n"
+ "******************************************************************\n");
+ fprintf(stderr, "\nRequired baseline features:\n");
+ checkFeatures(baseline_features, sizeof(baseline_features) / sizeof(baseline_features[0]), true);
+ CV_ErrorNoReturn(cv::Error::StsAssert, "Missing support for required CPU baseline features. Check OpenCV build configuration and required CPU/HW setup.");
+ }
+
+ readSettings(baseline_features, sizeof(baseline_features) / sizeof(baseline_features[0]));
+ }
+
+ bool checkFeatures(const int* features, int count, bool dump = false)
+ {
+ bool result = true;
+ for (int i = 0; i < count; i++)
+ {
+ int feature = features[i];
+ if (feature)
+ {
+ if (have[feature])
+ {
+ if (dump) fprintf(stderr, "%s - OK\n", getHWFeatureNameSafe(feature));
+ }
+ else
+ {
+ result = false;
+ if (dump) fprintf(stderr, "%s - NOT AVAILABLE\n", getHWFeatureNameSafe(feature));
+ }
+ }
+ }
+ return result;
+ }
+
+ static inline bool isSymbolSeparator(char c)
+ {
+ return c == ',' || c == ';' || c == '-';
+ }
+
+ void readSettings(const int* baseline_features, int baseline_count)
+ {
+ bool dump = true;
+ const char* disabled_features =
+#ifndef WINRT
+ getenv("OPENCV_CPU_DISABLE");
+#else
+ NULL;
+#endif
+ if (disabled_features && disabled_features[0] != 0)
+ {
+ const char* start = disabled_features;
+ for (;;)
+ {
+ while (start[0] != 0 && isSymbolSeparator(start[0]))
+ {
+ start++;
+ }
+ if (start[0] == 0)
+ break;
+ const char* end = start;
+ while (end[0] != 0 && !isSymbolSeparator(end[0]))
+ {
+ end++;
+ }
+ if (end == start)
+ continue;
+ cv::String feature(start, end);
+ start = end;
+
+ CV_Assert(feature.size() > 0);
+
+ bool found = false;
+ for (int i = 0; i < CV_HARDWARE_MAX_FEATURE; i++)
+ {
+ if (!g_hwFeatureNames[i]) continue;
+ size_t len = strlen(g_hwFeatureNames[i]);
+ if (len != feature.size()) continue;
+ if (feature.compare(g_hwFeatureNames[i]) == 0)
+ {
+ bool isBaseline = false;
+ for (int k = 0; k < baseline_count; k++)
+ {
+ if (baseline_features[k] == i)
+ {
+ isBaseline = true;
+ break;
+ }
+ }
+ if (isBaseline)
+ {
+ if (dump) fprintf(stderr, "OPENCV: Trying to disable baseline CPU feature: '%s'. This has very limited effect, because code optimizations for this feature are executed unconditionally in the most cases.\n", getHWFeatureNameSafe(i));
+ }
+ if (!have[i])
+ {
+ if (dump) fprintf(stderr, "OPENCV: Trying to disable unavailable CPU feature on the current platform: '%s'.\n", getHWFeatureNameSafe(i));
+ }
+ have[i] = false;
+
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ {
+ if (dump) fprintf(stderr, "OPENCV: Trying to disable unknown CPU feature: '%s'.\n", feature.c_str());
+ }
+ }
+ }
}
- int x86_family;
bool have[MAX_FEATURE+1];
};
-static HWFeatures featuresEnabled = HWFeatures::initialize(), featuresDisabled = HWFeatures();
+static HWFeatures featuresEnabled(true), featuresDisabled = HWFeatures(false);
static HWFeatures* currentFeatures = &featuresEnabled;
bool checkHardwareSupport(int feature)
@@ -410,7 +655,7 @@ bool useOptimized(void)
int64 getTickCount(void)
{
-#if defined WIN32 || defined _WIN32 || defined WINCE
+#if defined _WIN32 || defined WINCE
LARGE_INTEGER counter;
QueryPerformanceCounter( &counter );
return (int64)counter.QuadPart;
@@ -430,7 +675,7 @@ int64 getTickCount(void)
double getTickFrequency(void)
{
-#if defined WIN32 || defined _WIN32 || defined WINCE
+#if defined _WIN32 || defined WINCE
LARGE_INTEGER freq;
QueryPerformanceFrequency(&freq);
return (double)freq.QuadPart;
@@ -492,7 +737,7 @@ int64 getCPUTickCount(void)
#endif
-#elif defined _MSC_VER && defined WIN32 && defined _M_IX86
+#elif defined _MSC_VER && defined _WIN32 && defined _M_IX86
int64 getCPUTickCount(void)
{
@@ -532,15 +777,17 @@ String format( const char* fmt, ... )
{
va_list va;
va_start(va, fmt);
- int bsize = static_cast<int>(buf.size()),
- len = vsnprintf((char *)buf, bsize, fmt, va);
+ int bsize = static_cast<int>(buf.size());
+ int len = cv_vsnprintf((char *)buf, bsize, fmt, va);
va_end(va);
- if (len < 0 || len >= bsize)
+ CV_Assert(len >= 0 && "Check format string for errors");
+ if (len >= bsize)
{
- buf.resize(std::max(bsize << 1, len + 1));
+ buf.resize(len + 1);
continue;
}
+ buf[bsize - 1] = 0;
return String((char *)buf, len);
}
}
@@ -552,7 +799,7 @@ String tempfile( const char* suffix )
const char *temp_dir = getenv("OPENCV_TEMP_PATH");
#endif
-#if defined WIN32 || defined _WIN32
+#if defined _WIN32
#ifdef WINRT
RoInitialize(RO_INIT_MULTITHREADED);
std::wstring temp_dir = GetTempPathWinRT();
@@ -586,7 +833,7 @@ String tempfile( const char* suffix )
fname = temp_file;
#endif
# else
-# ifdef ANDROID
+# ifdef __ANDROID__
//char defaultTemplate[] = "/mnt/sdcard/__opencv_temp.XXXXXX";
char defaultTemplate[] = "/data/local/tmp/__opencv_temp.XXXXXX";
# else
@@ -632,6 +879,36 @@ bool setBreakOnError(bool value)
return prevVal;
}
+int cv_snprintf(char* buf, int len, const char* fmt, ...)
+{
+ va_list va;
+ va_start(va, fmt);
+ int res = cv_vsnprintf(buf, len, fmt, va);
+ va_end(va);
+ return res;
+}
+
+int cv_vsnprintf(char* buf, int len, const char* fmt, va_list args)
+{
+#if defined _MSC_VER
+ if (len <= 0) return len == 0 ? 1024 : -1;
+ int res = _vsnprintf_s(buf, len, _TRUNCATE, fmt, args);
+ // ensure null terminating on VS
+ if (res >= 0 && res < len)
+ {
+ buf[res] = 0;
+ return res;
+ }
+ else
+ {
+ buf[len - 1] = 0; // truncate happened
+ return res >= len ? res : (len * 2);
+ }
+#else
+ return vsnprintf(buf, len, fmt, args);
+#endif
+}
+
void error( const Exception& exc )
{
if (customErrorCallback != 0)
@@ -640,11 +917,12 @@ void error( const Exception& exc )
else
{
const char* errorStr = cvErrorStr(exc.code);
- char buf[1 << 16];
+ char buf[1 << 12];
- sprintf( buf, "OpenCV Error: %s (%s) in %s, file %s, line %d",
+ cv_snprintf(buf, sizeof(buf),
+ "OpenCV Error: %s (%s) in %s, file %s, line %d",
errorStr, exc.err.c_str(), exc.func.size() > 0 ?
- exc.func.c_str() : "unknown function", exc.file.c_str(), exc.line );
+ exc.func.c_str() : "unknown function", exc.file.c_str(), exc.line);
fprintf( stderr, "%s\n", buf );
fflush( stderr );
# ifdef __ANDROID__
@@ -666,6 +944,7 @@ void error(int _code, const String& _err, const char* _func, const char* _file,
error(cv::Exception(_code, _err, _func, _file, _line));
}
+
ErrorCallback
redirectError( ErrorCallback errCallback, void* userdata, void** prevUserdata)
{
@@ -751,7 +1030,7 @@ CV_IMPL const char* cvErrorStr( int status )
case CV_StsAutoTrace : return "Autotrace call";
case CV_StsBadSize : return "Incorrect size of input array";
case CV_StsNullPtr : return "Null pointer";
- case CV_StsDivByZero : return "Division by zero occured";
+ case CV_StsDivByZero : return "Division by zero occurred";
case CV_BadStep : return "Image step is wrong";
case CV_StsInplaceNotSupported : return "Inplace operation is not supported";
case CV_StsObjectNotFound : return "Requested object was not found";
@@ -845,7 +1124,7 @@ bool __termination = false;
namespace cv
{
-#if defined WIN32 || defined _WIN32 || defined WINCE
+#if defined _WIN32 || defined WINCE
struct Mutex::Impl
{
@@ -914,10 +1193,13 @@ Mutex::Mutex(const Mutex& m)
Mutex& Mutex::operator = (const Mutex& m)
{
- CV_XADD(&m.impl->refcount, 1);
- if( CV_XADD(&impl->refcount, -1) == 1 )
- delete impl;
- impl = m.impl;
+ if (this != &m)
+ {
+ CV_XADD(&m.impl->refcount, 1);
+ if( CV_XADD(&impl->refcount, -1) == 1 )
+ delete impl;
+ impl = m.impl;
+ }
return *this;
}
@@ -928,7 +1210,7 @@ bool Mutex::trylock() { return impl->trylock(); }
//////////////////////////////// thread-local storage ////////////////////////////////
-#ifdef WIN32
+#ifdef _WIN32
#ifdef _MSC_VER
#pragma warning(disable:4505) // unreferenced local function has been removed
#endif
@@ -947,16 +1229,16 @@ public:
void SetData(void *pData);
private:
-#ifdef WIN32
+#ifdef _WIN32
#ifndef WINRT
DWORD tlsKey;
#endif
-#else // WIN32
+#else // _WIN32
pthread_key_t tlsKey;
#endif
};
-#ifdef WIN32
+#ifdef _WIN32
#ifdef WINRT
static __declspec( thread ) void* tlsData = NULL; // using C++11 thread attribute for local thread data
TlsAbstraction::TlsAbstraction() {}
@@ -988,7 +1270,7 @@ void TlsAbstraction::SetData(void *pData)
CV_Assert(TlsSetValue(tlsKey, pData) == TRUE);
}
#endif
-#else // WIN32
+#else // _WIN32
TlsAbstraction::TlsAbstraction()
{
CV_Assert(pthread_key_create(&tlsKey, NULL) == 0);
@@ -1024,7 +1306,8 @@ struct ThreadData
class TlsStorage
{
public:
- TlsStorage()
+ TlsStorage() :
+ tlsSlotsSize(0)
{
tlsSlots.reserve(32);
threads.reserve(32);
@@ -1035,7 +1318,7 @@ public:
{
if(threads[i])
{
- /* Current architecture doesn't allow proper global objects relase, so this check can cause crashes
+ /* Current architecture doesn't allow proper global objects release, so this check can cause crashes
// Check if all slots were properly cleared
for(size_t j = 0; j < threads[i]->slots.size(); j++)
@@ -1069,9 +1352,10 @@ public:
size_t reserveSlot()
{
AutoLock guard(mtxGlobalAccess);
+ CV_Assert(tlsSlotsSize == tlsSlots.size());
// Find unused slots
- for(size_t slot = 0; slot < tlsSlots.size(); slot++)
+ for(size_t slot = 0; slot < tlsSlotsSize; slot++)
{
if(!tlsSlots[slot])
{
@@ -1081,15 +1365,16 @@ public:
}
// Create new slot
- tlsSlots.push_back(1);
- return (tlsSlots.size()-1);
+ tlsSlots.push_back(1); tlsSlotsSize++;
+ return tlsSlotsSize - 1;
}
- // Release TLS storage index and pass assosiated data to caller
- void releaseSlot(size_t slotIdx, std::vector<void*> &dataVec)
+ // Release TLS storage index and pass associated data to caller
+ void releaseSlot(size_t slotIdx, std::vector<void*> &dataVec, bool keepSlot = false)
{
AutoLock guard(mtxGlobalAccess);
- CV_Assert(tlsSlots.size() > slotIdx);
+ CV_Assert(tlsSlotsSize == tlsSlots.size());
+ CV_Assert(tlsSlotsSize > slotIdx);
for(size_t i = 0; i < threads.size(); i++)
{
@@ -1099,18 +1384,21 @@ public:
if (thread_slots.size() > slotIdx && thread_slots[slotIdx])
{
dataVec.push_back(thread_slots[slotIdx]);
- threads[i]->slots[slotIdx] = 0;
+ thread_slots[slotIdx] = NULL;
}
}
}
- tlsSlots[slotIdx] = 0;
+ if (!keepSlot)
+ tlsSlots[slotIdx] = 0;
}
// Get data by TLS storage index
void* getData(size_t slotIdx) const
{
- CV_Assert(tlsSlots.size() > slotIdx);
+#ifndef CV_THREAD_SANITIZER
+ CV_Assert(tlsSlotsSize > slotIdx);
+#endif
ThreadData* threadData = (ThreadData*)tls.GetData();
if(threadData && threadData->slots.size() > slotIdx)
@@ -1123,7 +1411,8 @@ public:
void gather(size_t slotIdx, std::vector<void*> &dataVec)
{
AutoLock guard(mtxGlobalAccess);
- CV_Assert(tlsSlots.size() > slotIdx);
+ CV_Assert(tlsSlotsSize == tlsSlots.size());
+ CV_Assert(tlsSlotsSize > slotIdx);
for(size_t i = 0; i < threads.size(); i++)
{
@@ -1139,7 +1428,9 @@ public:
// Set data to storage index
void setData(size_t slotIdx, void* pData)
{
- CV_Assert(tlsSlots.size() > slotIdx && pData != NULL);
+#ifndef CV_THREAD_SANITIZER
+ CV_Assert(tlsSlotsSize > slotIdx);
+#endif
ThreadData* threadData = (ThreadData*)tls.GetData();
if(!threadData)
@@ -1155,9 +1446,8 @@ public:
if(slotIdx >= threadData->slots.size())
{
- AutoLock guard(mtxGlobalAccess);
- while(slotIdx >= threadData->slots.size())
- threadData->slots.push_back(NULL);
+ AutoLock guard(mtxGlobalAccess); // keep synchronization with gather() calls
+ threadData->slots.resize(slotIdx + 1, NULL);
}
threadData->slots[slotIdx] = pData;
}
@@ -1166,6 +1456,8 @@ private:
TlsAbstraction tls; // TLS abstraction layer instance
Mutex mtxGlobalAccess; // Shared objects operation guard
+ size_t tlsSlotsSize; // equal to tlsSlots.size() in synchronized sections
+ // without synchronization this counter doesn't desrease - it is used for slotIdx sanity checks
std::vector<int> tlsSlots; // TLS keys state
std::vector<ThreadData*> threads; // Array for all allocated data. Thread data pointers are placed here to allow data cleanup
};
@@ -1196,13 +1488,23 @@ void TLSDataContainer::release()
std::vector<void*> data;
data.reserve(32);
getTlsStorage().releaseSlot(key_, data); // Release key and get stored data for proper destruction
- for(size_t i = 0; i < data.size(); i++) // Delete all assosiated data
- deleteDataInstance(data[i]);
key_ = -1;
+ for(size_t i = 0; i < data.size(); i++) // Delete all associated data
+ deleteDataInstance(data[i]);
+}
+
+void TLSDataContainer::cleanup()
+{
+ std::vector<void*> data;
+ data.reserve(32);
+ getTlsStorage().releaseSlot(key_, data, true); // Extract stored data with removal from TLS tables
+ for(size_t i = 0; i < data.size(); i++) // Delete all associated data
+ deleteDataInstance(data[i]);
}
void* TLSDataContainer::getData() const
{
+ CV_Assert(key_ != -1 && "Can't fetch data from terminated TLS container.");
void* pData = getTlsStorage().getData(key_); // Check if data was already allocated
if(!pData)
{
@@ -1218,7 +1520,7 @@ TLSData<CoreTLSData>& getCoreTlsData()
CV_SINGLETON_LAZY_INIT_REF(TLSData<CoreTLSData>, new TLSData<CoreTLSData>())
}
-#if defined CVAPI_EXPORTS && defined WIN32 && !defined WINCE
+#if defined CVAPI_EXPORTS && defined _WIN32 && !defined WINCE
#ifdef WINRT
#pragma warning(disable:4447) // Disable warning 'main' signature found without threading model
#endif
@@ -1239,7 +1541,6 @@ BOOL WINAPI DllMain(HINSTANCE, DWORD fdwReason, LPVOID lpReserved)
{
// Not allowed to free resources if lpReserved is non-null
// http://msdn.microsoft.com/en-us/library/windows/desktop/ms682583.aspx
- cv::deleteThreadAllocData();
cv::getTlsStorage().releaseThread();
}
}
@@ -1247,6 +1548,99 @@ BOOL WINAPI DllMain(HINSTANCE, DWORD fdwReason, LPVOID lpReserved)
}
#endif
+
+namespace {
+static int g_threadNum = 0;
+class ThreadID {
+public:
+ const int id;
+ ThreadID() :
+ id(CV_XADD(&g_threadNum, 1))
+ {
+#ifdef OPENCV_WITH_ITT
+ __itt_thread_set_name(cv::format("OpenCVThread-%03d", id).c_str());
+#endif
+ }
+};
+
+static TLSData<ThreadID>& getThreadIDTLS()
+{
+ CV_SINGLETON_LAZY_INIT_REF(TLSData<ThreadID>, new TLSData<ThreadID>());
+}
+
+} // namespace
+int utils::getThreadID() { return getThreadIDTLS().get()->id; }
+
+bool utils::getConfigurationParameterBool(const char* name, bool defaultValue)
+{
+#ifdef NO_GETENV
+ const char* envValue = NULL;
+#else
+ const char* envValue = getenv(name);
+#endif
+ if (envValue == NULL)
+ {
+ return defaultValue;
+ }
+ cv::String value = envValue;
+ if (value == "1" || value == "True" || value == "true" || value == "TRUE")
+ {
+ return true;
+ }
+ if (value == "0" || value == "False" || value == "false" || value == "FALSE")
+ {
+ return false;
+ }
+ CV_ErrorNoReturn(cv::Error::StsBadArg, cv::format("Invalid value for %s parameter: %s", name, value.c_str()));
+}
+
+
+size_t utils::getConfigurationParameterSizeT(const char* name, size_t defaultValue)
+{
+#ifdef NO_GETENV
+ const char* envValue = NULL;
+#else
+ const char* envValue = getenv(name);
+#endif
+ if (envValue == NULL)
+ {
+ return defaultValue;
+ }
+ cv::String value = envValue;
+ size_t pos = 0;
+ for (; pos < value.size(); pos++)
+ {
+ if (!isdigit(value[pos]))
+ break;
+ }
+ cv::String valueStr = value.substr(0, pos);
+ cv::String suffixStr = value.substr(pos, value.length() - pos);
+ int v = atoi(valueStr.c_str());
+ if (suffixStr.length() == 0)
+ return v;
+ else if (suffixStr == "MB" || suffixStr == "Mb" || suffixStr == "mb")
+ return v * 1024 * 1024;
+ else if (suffixStr == "KB" || suffixStr == "Kb" || suffixStr == "kb")
+ return v * 1024;
+ CV_ErrorNoReturn(cv::Error::StsBadArg, cv::format("Invalid value for %s parameter: %s", name, value.c_str()));
+}
+
+cv::String utils::getConfigurationParameterString(const char* name, const char* defaultValue)
+{
+#ifdef NO_GETENV
+ const char* envValue = NULL;
+#else
+ const char* envValue = getenv(name);
+#endif
+ if (envValue == NULL)
+ {
+ return defaultValue;
+ }
+ cv::String value = envValue;
+ return value;
+}
+
+
#ifdef CV_COLLECT_IMPL_DATA
ImplCollector& getImplData()
{
@@ -1509,19 +1903,19 @@ IntrumentationRegion::~IntrumentationRegion()
namespace ipp
{
+#ifdef HAVE_IPP
struct IPPInitSingleton
{
public:
IPPInitSingleton()
{
- useIPP = true;
- ippStatus = 0;
- funcname = NULL;
- filename = NULL;
- linen = 0;
- ippFeatures = 0;
+ useIPP = true;
+ ippStatus = 0;
+ funcname = NULL;
+ filename = NULL;
+ linen = 0;
+ ippFeatures = 0;
-#ifdef HAVE_IPP
const char* pIppEnv = getenv("OPENCV_IPP");
cv::String env = pIppEnv;
if(env.size())
@@ -1554,7 +1948,7 @@ public:
}
IPP_INITIALIZER(ippFeatures)
-#endif
+ ippFeatures = ippGetEnabledCpuFeatures();
}
bool useIPP;
@@ -1563,39 +1957,60 @@ public:
const char *funcname;
const char *filename;
int linen;
- int ippFeatures;
+ Ipp64u ippFeatures;
};
static IPPInitSingleton& getIPPSingleton()
{
CV_SINGLETON_LAZY_INIT_REF(IPPInitSingleton, new IPPInitSingleton())
}
+#endif
+#if OPENCV_ABI_COMPATIBILITY > 300
+unsigned long long getIppFeatures()
+#else
int getIppFeatures()
+#endif
{
#ifdef HAVE_IPP
+#if OPENCV_ABI_COMPATIBILITY > 300
return getIPPSingleton().ippFeatures;
#else
+ return (int)getIPPSingleton().ippFeatures;
+#endif
+#else
return 0;
#endif
}
void setIppStatus(int status, const char * const _funcname, const char * const _filename, int _line)
{
+#ifdef HAVE_IPP
getIPPSingleton().ippStatus = status;
getIPPSingleton().funcname = _funcname;
getIPPSingleton().filename = _filename;
getIPPSingleton().linen = _line;
+#else
+ CV_UNUSED(status); CV_UNUSED(_funcname); CV_UNUSED(_filename); CV_UNUSED(_line);
+#endif
}
int getIppStatus()
{
+#ifdef HAVE_IPP
return getIPPSingleton().ippStatus;
+#else
+ return 0;
+#endif
}
String getIppErrorLocation()
{
+#ifdef HAVE_IPP
return format("%s:%d %s", getIPPSingleton().filename ? getIPPSingleton().filename : "", getIPPSingleton().linen, getIPPSingleton().funcname ? getIPPSingleton().funcname : "");
+#else
+ return String();
+#endif
}
bool useIPP()
diff --git a/modules/core/src/trace.cpp b/modules/core/src/trace.cpp
new file mode 100644
index 0000000..d915364
--- /dev/null
+++ b/modules/core/src/trace.cpp
@@ -0,0 +1,1128 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include <precomp.hpp>
+
+#include <opencv2/core/utils/trace.hpp>
+#include <opencv2/core/utils/trace.private.hpp>
+
+#include <cstdarg> // va_start
+
+#include <sstream>
+#include <ostream>
+#include <fstream>
+
+#if 0
+#define CV_LOG(...) CV_LOG_INFO(NULL, __VA_ARGS__)
+#else
+#define CV_LOG(...) {}
+#endif
+
+#if 0
+#define CV_LOG_ITT(...) CV_LOG_INFO(NULL, __VA_ARGS__)
+#else
+#define CV_LOG_ITT(...) {}
+#endif
+
+#if 1
+#define CV_LOG_TRACE_BAILOUT(tag, ...) CV_LOG_INFO(tag, __VA_ARGS__)
+#else
+#define CV_LOG_TRACE_BAILOUT(...) {}
+#endif
+
+#if 0
+#define CV_LOG_PARALLEL(tag, ...) CV_LOG_INFO(tag, __VA_ARGS__)
+#else
+#define CV_LOG_PARALLEL(...) {}
+#endif
+
+#if 0
+#define CV_LOG_CTX_STAT(tag, ...) CV_LOG_INFO(tag, __VA_ARGS__)
+#else
+#define CV_LOG_CTX_STAT(...) {}
+#endif
+
+#if 0
+#define CV_LOG_SKIP(tag, ...) CV_LOG_INFO(tag, __VA_ARGS__)
+#else
+#define CV_LOG_SKIP(...) {}
+#endif
+
+namespace cv {
+namespace utils {
+namespace trace {
+namespace details {
+
+#ifdef OPENCV_TRACE
+
+#ifdef _MSC_VER
+#pragma warning(disable:4065) // switch statement contains 'default' but no 'case' labels
+#endif
+
+static int64 g_zero_timestamp = 0;
+
+static int64 getTimestamp()
+{
+ int64 t = getTickCount();
+ static double tick_to_ns = 1e9 / getTickFrequency();
+ return (int64)((t - g_zero_timestamp) * tick_to_ns);
+}
+
+// TODO lazy configuration flags
+static bool param_traceEnable = utils::getConfigurationParameterBool("OPENCV_TRACE", false);
+
+static int param_maxRegionDepthOpenCV = (int)utils::getConfigurationParameterSizeT("OPENCV_TRACE_DEPTH_OPENCV", 1);
+static int param_maxRegionChildrenOpenCV = (int)utils::getConfigurationParameterSizeT("OPENCV_TRACE_MAX_CHILDREN_OPENCV", 1000);
+static int param_maxRegionChildren = (int)utils::getConfigurationParameterSizeT("OPENCV_TRACE_MAX_CHILDREN", 10000);
+static cv::String param_traceLocation = utils::getConfigurationParameterString("OPENCV_TRACE_LOCATION", "OpenCVTrace");
+
+#ifdef HAVE_OPENCL
+static bool param_synchronizeOpenCL = utils::getConfigurationParameterBool("OPENCV_TRACE_SYNC_OPENCL", false);
+#endif
+
+#ifdef OPENCV_WITH_ITT
+static bool param_ITT_registerParentScope = utils::getConfigurationParameterBool("OPENCV_TRACE_ITT_PARENT", false);
+#endif
+
+static const char* _spaces(int count)
+{
+ static const char buf[64] =
+" ";
+ return &buf[63 - (count & 63)];
+}
+
+/**
+ * Text-based trace messages
+ */
+class TraceMessage
+{
+public:
+ char buffer[1024];
+ size_t len;
+ bool hasError;
+
+ TraceMessage() :
+ len(0),
+ hasError(false)
+ {}
+
+ bool printf(const char* format, ...)
+ {
+ char* buf = &buffer[len];
+ size_t sz = sizeof(buffer) - len;
+ va_list ap;
+ va_start(ap, format);
+ int n = cv_vsnprintf(buf, (int)sz, format, ap);
+ va_end(ap);
+ if (n < 0 || (size_t)n > sz)
+ {
+ hasError = true;
+ return false;
+ }
+ len += n;
+ return true;
+ }
+
+ bool formatlocation(const Region::LocationStaticStorage& location)
+ {
+ return this->printf("l,%lld,\"%s\",%d,\"%s\",0x%llX\n",
+ (long long int)(*location.ppExtra)->global_location_id,
+ location.filename,
+ location.line,
+ location.name,
+ (long long int)(location.flags & ~0xF0000000));
+ }
+ bool formatRegionEnter(const Region& region)
+ {
+ bool ok = this->printf("b,%d,%lld,%lld,%lld",
+ (int)region.pImpl->threadID,
+ (long long int)region.pImpl->beginTimestamp,
+ (long long int)((*region.pImpl->location.ppExtra)->global_location_id),
+ (long long int)region.pImpl->global_region_id);
+ if (region.pImpl->parentRegion && region.pImpl->parentRegion->pImpl)
+ {
+ if (region.pImpl->parentRegion->pImpl->threadID != region.pImpl->threadID)
+ ok &= this->printf(",parentThread=%d,parent=%lld",
+ (int)region.pImpl->parentRegion->pImpl->threadID,
+ (long long int)region.pImpl->parentRegion->pImpl->global_region_id);
+ }
+ ok &= this->printf("\n");
+ return ok;
+ }
+ bool formatRegionLeave(const Region& region, const RegionStatistics& result)
+ {
+ CV_DbgAssert(region.pImpl->endTimestamp - region.pImpl->beginTimestamp == result.duration);
+ bool ok = this->printf("e,%d,%lld,%lld,%lld,%lld",
+ (int)region.pImpl->threadID,
+ (long long int)region.pImpl->endTimestamp,
+ (long long int)(*region.pImpl->location.ppExtra)->global_location_id,
+ (long long int)region.pImpl->global_region_id,
+ (long long int)result.duration);
+ if (result.currentSkippedRegions)
+ ok &= this->printf(",skip=%d", (int)result.currentSkippedRegions);
+#ifdef HAVE_IPP
+ if (result.durationImplIPP)
+ ok &= this->printf(",tIPP=%lld", (long long int)result.durationImplIPP);
+#endif
+#ifdef HAVE_OPENCL
+ if (result.durationImplOpenCL)
+ ok &= this->printf(",tOCL=%lld", (long long int)result.durationImplOpenCL);
+#endif
+#ifdef HAVE_OPENVX
+ if (result.durationImplOpenVX)
+ ok &= this->printf(",tOVX=%lld", (long long int)result.durationImplOpenVX);
+#endif
+ ok &= this->printf("\n");
+ return ok;
+ }
+ bool recordRegionArg(const Region& region, const TraceArg& arg, const char* value)
+ {
+ return this->printf("a,%d,%lld,%lld,\"%s\",\"%s\"\n",
+ region.pImpl->threadID,
+ (long long int)region.pImpl->beginTimestamp,
+ (long long int)region.pImpl->global_region_id,
+ arg.name,
+ value);
+ }
+};
+
+
+#ifdef OPENCV_WITH_ITT
+static __itt_domain* domain = NULL;
+
+static bool isITTEnabled()
+{
+ static bool isInitialized = false;
+ static bool isEnabled = false;
+ if (!isInitialized)
+ {
+ isEnabled = !!(__itt_api_version());
+ CV_LOG_ITT("ITT is " << (isEnabled ? "enabled" : "disabled"));
+ domain = __itt_domain_create("OpenCVTrace");
+ isInitialized = true;
+ }
+ return isEnabled;
+}
+#endif
+
+
+Region::LocationExtraData::LocationExtraData(const LocationStaticStorage& location)
+{
+ CV_UNUSED(location);
+ static int g_location_id_counter = 0;
+ global_location_id = CV_XADD(&g_location_id_counter, 1) + 1;
+ CV_LOG("Register location: " << global_location_id << " (" << (void*)&location << ")"
+ << std::endl << " file: " << location.filename
+ << std::endl << " line: " << location.line
+ << std::endl << " name: " << location.name);
+#ifdef OPENCV_WITH_ITT
+ if (isITTEnabled())
+ {
+ // Caching is not required here, because there is builtin cache.
+ // https://software.intel.com/en-us/node/544203:
+ // Consecutive calls to __itt_string_handle_create with the same name return the same value.
+ ittHandle_name = __itt_string_handle_create(location.name);
+ ittHandle_filename = __itt_string_handle_create(location.filename);
+ }
+ else
+ {
+ ittHandle_name = 0;
+ ittHandle_filename = 0;
+ }
+#endif
+}
+
+/*static*/ Region::LocationExtraData* Region::LocationExtraData::init(const Region::LocationStaticStorage& location)
+{
+ LocationExtraData** pLocationExtra = location.ppExtra;
+ CV_DbgAssert(pLocationExtra);
+ if (*pLocationExtra == NULL)
+ {
+ cv::AutoLock lock(cv::getInitializationMutex());
+ if (*pLocationExtra == NULL)
+ {
+ *pLocationExtra = new Region::LocationExtraData(location);
+ TraceStorage* s = getTraceManager().trace_storage.get();
+ if (s)
+ {
+ TraceMessage msg;
+ msg.formatlocation(location);
+ s->put(msg);
+ }
+ }
+ }
+ return *pLocationExtra;
+}
+
+
+Region::Impl::Impl(TraceManagerThreadLocal& ctx, Region* parentRegion_, Region& region_, const LocationStaticStorage& location_, int64 beginTimestamp_) :
+ location(location_),
+ region(region_),
+ parentRegion(parentRegion_),
+ threadID(ctx.threadID),
+ global_region_id(++ctx.region_counter),
+ beginTimestamp(beginTimestamp_),
+ endTimestamp(0),
+ directChildrenCount(0)
+#ifdef OPENCV_WITH_ITT
+ ,itt_id_registered(false)
+ ,itt_id(__itt_null)
+#endif
+{
+ CV_DbgAssert(ctx.currentActiveRegion == parentRegion);
+ region.pImpl = this;
+
+ registerRegion(ctx);
+
+ enterRegion(ctx);
+}
+
+Region::Impl::~Impl()
+{
+#ifdef OPENCV_WITH_ITT
+ if (itt_id_registered)
+ {
+ CV_LOG_ITT(" Destroy ITT region: I=" << (void*)this);
+ __itt_id_destroy(domain, itt_id);
+ itt_id_registered = false;
+ }
+#endif
+ region.pImpl = NULL;
+}
+
+void Region::Impl::enterRegion(TraceManagerThreadLocal& ctx)
+{
+ ctx.currentActiveRegion = ®ion;
+
+ if (location.flags & REGION_FLAG_FUNCTION)
+ {
+ if ((location.flags & REGION_FLAG_APP_CODE) == 0)
+ {
+ ctx.regionDepthOpenCV++;
+ }
+ ctx.regionDepth++;
+ }
+
+ TraceStorage* s = ctx.getStorage();
+ if (s)
+ {
+ TraceMessage msg;
+ msg.formatRegionEnter(region);
+ s->put(msg);
+ }
+#ifdef OPENCV_WITH_ITT
+ if (isITTEnabled())
+ {
+ __itt_id parentID = __itt_null;
+ if (param_ITT_registerParentScope && parentRegion && parentRegion->pImpl && parentRegion->pImpl->itt_id_registered && (location.flags & REGION_FLAG_REGION_FORCE) == 0)
+ parentID = parentRegion->pImpl->itt_id;
+ __itt_task_begin(domain, itt_id, parentID, (*location.ppExtra)->ittHandle_name);
+ }
+#endif
+}
+
+void Region::Impl::leaveRegion(TraceManagerThreadLocal& ctx)
+{
+ int64 duration = endTimestamp - beginTimestamp; CV_UNUSED(duration);
+ RegionStatistics result;
+ ctx.stat.grab(result);
+ ctx.totalSkippedEvents += result.currentSkippedRegions;
+ CV_LOG(_spaces(ctx.getCurrentDepth()*4) << "leaveRegion(): " << (void*)this << " " << result);
+#ifdef OPENCV_WITH_ITT
+ if (isITTEnabled())
+ {
+ if (result.currentSkippedRegions)
+ {
+ __itt_metadata_add(domain, itt_id, __itt_string_handle_create("skipped trace entries"), __itt_metadata_u32, 1, &result.currentSkippedRegions);
+ }
+#ifdef HAVE_IPP
+ if (result.durationImplIPP)
+ __itt_metadata_add(domain, itt_id, __itt_string_handle_create("tIPP"), __itt_metadata_u64, 1, &result.durationImplIPP);
+#endif
+#ifdef HAVE_OPENCL
+ if (result.durationImplOpenCL)
+ __itt_metadata_add(domain, itt_id, __itt_string_handle_create("tOpenCL"), __itt_metadata_u64, 1, &result.durationImplOpenCL);
+#endif
+#ifdef HAVE_OPENVX
+ if (result.durationImplOpenVX)
+ __itt_metadata_add(domain, itt_id, __itt_string_handle_create("tOpenVX"), __itt_metadata_u64, 1, &result.durationImplOpenVX);
+#endif
+ __itt_task_end(domain);
+ }
+#endif
+ TraceStorage* s = ctx.getStorage();
+ if (s)
+ {
+ TraceMessage msg;
+ msg.formatRegionLeave(region, result);
+ s->put(msg);
+ }
+
+ if (location.flags & REGION_FLAG_FUNCTION)
+ {
+ if ((location.flags & REGION_FLAG_APP_CODE) == 0)
+ {
+ ctx.regionDepthOpenCV--;
+ }
+ ctx.regionDepth--;
+ }
+
+ ctx.currentActiveRegion = parentRegion;
+}
+
+void Region::Impl::release()
+{
+ delete this;
+}
+
+void Region::Impl::registerRegion(TraceManagerThreadLocal& ctx)
+{
+#ifdef OPENCV_WITH_ITT
+ if (isITTEnabled())
+ {
+ if (!itt_id_registered)
+ {
+ CV_LOG_ITT(" Register ITT region: I=" << (void*)this << " " << ctx.threadID << "-" << global_region_id);
+#if 1 // workaround for some ITT backends
+ itt_id = __itt_id_make((void*)(intptr_t)(((int64)(ctx.threadID + 1) << 32) | global_region_id), global_region_id);
+#else
+ itt_id = __itt_id_make((void*)(intptr_t)(ctx.threadID + 1), global_region_id);
+#endif
+ __itt_id_create(domain, itt_id);
+ itt_id_registered = true;
+ }
+ }
+#else
+ CV_UNUSED(ctx);
+#endif
+}
+
+void RegionStatisticsStatus::enableSkipMode(int depth)
+{
+ CV_DbgAssert(_skipDepth < 0);
+ CV_LOG_SKIP(NULL, "SKIP-ENABLE: depth=" << depth);
+ _skipDepth = depth;
+}
+void RegionStatisticsStatus::checkResetSkipMode(int leaveDepth)
+{
+ if (leaveDepth <= _skipDepth)
+ {
+ CV_LOG_SKIP(NULL, "SKIP-RESET: leaveDepth=" << leaveDepth << " skipDepth=" << _skipDepth);
+ _skipDepth = -1;
+ }
+}
+
+Region::Region(const LocationStaticStorage& location) :
+ pImpl(NULL),
+ implFlags(0)
+{
+ // Checks:
+ // - global enable flag
+ // - parent region is disabled
+ // - children count threshold
+ // - region location
+ // - depth (opencv nested calls)
+ if (!TraceManager::isActivated())
+ {
+ CV_LOG("Trace is disabled. Bailout");
+ return;
+ }
+
+ TraceManagerThreadLocal& ctx = getTraceManager().tls.getRef();
+ CV_LOG(_spaces(ctx.getCurrentDepth()*4) << "Region(): " << (void*)this << ": " << location.name);
+
+ Region* parentRegion = ctx.stackTopRegion();
+ const Region::LocationStaticStorage* parentLocation = ctx.stackTopLocation();
+
+ if (location.flags & REGION_FLAG_REGION_NEXT)
+ {
+ if (parentRegion && parentRegion->pImpl)
+ {
+ CV_DbgAssert((parentRegion->pImpl->location.flags & REGION_FLAG_FUNCTION) == 0);
+ parentRegion->destroy(); parentRegion->implFlags = 0;
+ parentRegion = ctx.stackTopRegion();
+ parentLocation = ctx.stackTopLocation();
+ }
+ }
+
+ int parentChildren = 0;
+ if (parentRegion && parentRegion->pImpl)
+ {
+ if (parentLocation == NULL)
+ {
+ // parallel_for_body code path
+ parentChildren = CV_XADD(&parentRegion->pImpl->directChildrenCount, 1) + 1;
+ }
+ else
+ {
+ parentChildren = ++parentRegion->pImpl->directChildrenCount;
+ }
+ }
+
+ int64 beginTimestamp = getTimestamp();
+
+ int currentDepth = ctx.getCurrentDepth() + 1;
+ switch (location.flags & REGION_FLAG_IMPL_MASK)
+ {
+#ifdef HAVE_IPP
+ case REGION_FLAG_IMPL_IPP:
+ if (!ctx.stat_status.ignoreDepthImplIPP)
+ ctx.stat_status.ignoreDepthImplIPP = currentDepth;
+ break;
+#endif
+#ifdef HAVE_OPENCL
+ case REGION_FLAG_IMPL_OPENCL:
+ if (!ctx.stat_status.ignoreDepthImplOpenCL)
+ ctx.stat_status.ignoreDepthImplOpenCL = currentDepth;
+ break;
+#endif
+#ifdef HAVE_OPENVX
+ case REGION_FLAG_IMPL_OPENVX:
+ if (!ctx.stat_status.ignoreDepthImplOpenVX)
+ ctx.stat_status.ignoreDepthImplOpenVX = currentDepth;
+ break;
+#endif
+ default:
+ break;
+ }
+
+ ctx.stackPush(this, &location, beginTimestamp);
+ implFlags |= REGION_FLAG__NEED_STACK_POP;
+
+ if ((location.flags & REGION_FLAG_REGION_FORCE) == 0)
+ {
+ if (ctx.stat_status._skipDepth >= 0 && currentDepth > ctx.stat_status._skipDepth)
+ {
+ CV_LOG(_spaces(ctx.getCurrentDepth()*4) << "Parent region is disabled. Bailout");
+ ctx.stat.currentSkippedRegions++;
+ return;
+ }
+
+ if (param_maxRegionChildrenOpenCV > 0 && (location.flags & REGION_FLAG_APP_CODE) == 0 && parentLocation && (parentLocation->flags & REGION_FLAG_APP_CODE) == 0)
+ {
+ if (parentChildren >= param_maxRegionChildrenOpenCV)
+ {
+ CV_LOG_TRACE_BAILOUT(NULL, _spaces(ctx.getCurrentDepth()*4) << "OpenCV parent region exceeds children count. Bailout");
+ ctx.stat_status.enableSkipMode(currentDepth - 1);
+ ctx.stat.currentSkippedRegions++;
+ DEBUG_ONLY(ctx.dumpStack(std::cout, false));
+ return;
+ }
+ }
+ if (param_maxRegionChildren > 0 && parentChildren >= param_maxRegionChildren)
+ {
+ CV_LOG_TRACE_BAILOUT(NULL, _spaces(ctx.getCurrentDepth()*4) << "Parent region exceeds children count. Bailout");
+ ctx.stat_status.enableSkipMode(currentDepth - 1);
+ ctx.stat.currentSkippedRegions++;
+ DEBUG_ONLY(ctx.dumpStack(std::cout, false));
+ return;
+ }
+ }
+
+ LocationExtraData::init(location);
+
+ if ((*location.ppExtra)->global_location_id == 0)
+ {
+ CV_LOG_TRACE_BAILOUT(NULL, _spaces(ctx.getCurrentDepth()*4) << "Region location is disabled. Bailout");
+ ctx.stat_status.enableSkipMode(currentDepth);
+ ctx.stat.currentSkippedRegions++;
+ return;
+ }
+
+ if (parentLocation && (parentLocation->flags & REGION_FLAG_SKIP_NESTED))
+ {
+ CV_LOG(_spaces(ctx.getCurrentDepth()*4) << "Parent region disables inner regions. Bailout");
+ ctx.stat_status.enableSkipMode(currentDepth);
+ ctx.stat.currentSkippedRegions++;
+ return;
+ }
+
+ if (param_maxRegionDepthOpenCV)
+ {
+ if ((location.flags & REGION_FLAG_APP_CODE) == 0)
+ {
+ if (ctx.regionDepthOpenCV >= param_maxRegionDepthOpenCV)
+ {
+ CV_LOG(_spaces(ctx.getCurrentDepth()*4) << "OpenCV region depth is exceed = " << ctx.regionDepthOpenCV << ". Bailout");
+ if (ctx.stat.currentSkippedRegions == 0)
+ {
+ DEBUG_ONLY(ctx.dumpStack(std::cout, false));
+ }
+ ctx.stat_status.enableSkipMode(currentDepth);
+ ctx.stat.currentSkippedRegions++;
+ return;
+ }
+ }
+ }
+
+ new Impl(ctx, parentRegion, *this, location, beginTimestamp);
+ CV_DbgAssert(pImpl != NULL);
+ implFlags |= REGION_FLAG__ACTIVE;
+
+ // parallel_for path
+ if (parentRegion && parentRegion->pImpl)
+ {
+ if (parentLocation == NULL)
+ {
+ pImpl->directChildrenCount = parentChildren;
+ }
+ }
+}
+
+void Region::destroy()
+{
+ CV_DbgAssert(implFlags != 0);
+
+ TraceManagerThreadLocal& ctx = getTraceManager().tls.getRef();
+ CV_LOG(_spaces(ctx.getCurrentDepth()*4) << "Region::destruct(): " << (void*)this << " pImpl=" << pImpl << " implFlags=" << implFlags << ' ' << (ctx.stackTopLocation() ? ctx.stackTopLocation()->name : "<unknown>"));
+
+ CV_DbgAssert(implFlags & REGION_FLAG__NEED_STACK_POP);
+ const int currentDepth = ctx.getCurrentDepth(); CV_UNUSED(currentDepth);
+
+ CV_LOG_CTX_STAT(NULL, _spaces(currentDepth*4) << ctx.stat << ' ' << ctx.stat_status);
+
+ const Region::LocationStaticStorage* location = ctx.stackTopLocation();
+ Impl::OptimizationPath myCodePath = Impl::CODE_PATH_PLAIN;
+ if (location)
+ {
+ switch (location->flags & REGION_FLAG_IMPL_MASK)
+ {
+#ifdef HAVE_IPP
+ case REGION_FLAG_IMPL_IPP:
+ myCodePath = Impl::CODE_PATH_IPP;
+ break;
+#endif
+#ifdef HAVE_OPENCL
+ case REGION_FLAG_IMPL_OPENCL:
+ if (param_synchronizeOpenCL && cv::ocl::useOpenCL())
+ cv::ocl::finish();
+ myCodePath = Impl::CODE_PATH_OPENCL;
+ break;
+#endif
+#ifdef HAVE_OPENVX
+ case REGION_FLAG_IMPL_OPENVX:
+ myCodePath = Impl::CODE_PATH_OPENVX;
+ break;
+#endif
+ default:
+ break;
+ }
+ }
+
+ int64 endTimestamp = getTimestamp();
+ int64 duration = endTimestamp - ctx.stackTopBeginTimestamp();
+
+ bool active = isActive();
+
+ if (active)
+ ctx.stat.duration = duration;
+ else if (ctx.stack.size() == ctx.parallel_for_stack_size + 1)
+ ctx.stat.duration += duration;
+
+ switch (myCodePath) {
+ case Impl::CODE_PATH_PLAIN:
+ // nothing
+ break;
+#ifdef HAVE_IPP
+ case Impl::CODE_PATH_IPP:
+ if (ctx.stat_status.ignoreDepthImplIPP == currentDepth)
+ {
+ ctx.stat.durationImplIPP += duration;
+ ctx.stat_status.ignoreDepthImplIPP = 0;
+ }
+ else if (active)
+ {
+ ctx.stat.durationImplIPP = duration;
+ }
+ break;
+#endif
+#ifdef HAVE_OPENCL
+ case Impl::CODE_PATH_OPENCL:
+ if (ctx.stat_status.ignoreDepthImplOpenCL == currentDepth)
+ {
+ ctx.stat.durationImplOpenCL += duration;
+ ctx.stat_status.ignoreDepthImplOpenCL = 0;
+ }
+ else if (active)
+ {
+ ctx.stat.durationImplOpenCL = duration;
+ }
+ break;
+#endif
+#ifdef HAVE_OPENVX
+ case Impl::CODE_PATH_OPENVX:
+ if (ctx.stat_status.ignoreDepthImplOpenVX == currentDepth)
+ {
+ ctx.stat.durationImplOpenVX += duration;
+ ctx.stat_status.ignoreDepthImplOpenVX = 0;
+ }
+ else if (active)
+ {
+ ctx.stat.durationImplOpenVX = duration;
+ }
+ break;
+#endif
+ default:
+ break;
+ }
+
+ if (pImpl)
+ {
+ CV_DbgAssert((implFlags & (REGION_FLAG__ACTIVE | REGION_FLAG__NEED_STACK_POP)) == (REGION_FLAG__ACTIVE | REGION_FLAG__NEED_STACK_POP));
+ CV_DbgAssert(ctx.stackTopRegion() == this);
+ pImpl->endTimestamp = endTimestamp;
+ pImpl->leaveRegion(ctx);
+ pImpl->release();
+ pImpl = NULL;
+ DEBUG_ONLY(implFlags &= ~REGION_FLAG__ACTIVE);
+ }
+ else
+ {
+ CV_DbgAssert(ctx.stat_status._skipDepth <= currentDepth);
+ }
+
+ if (implFlags & REGION_FLAG__NEED_STACK_POP)
+ {
+ CV_DbgAssert(ctx.stackTopRegion() == this);
+ ctx.stackPop();
+ ctx.stat_status.checkResetSkipMode(currentDepth);
+ DEBUG_ONLY(implFlags &= ~REGION_FLAG__NEED_STACK_POP);
+ }
+ CV_LOG_CTX_STAT(NULL, _spaces(currentDepth*4) << "===> " << ctx.stat << ' ' << ctx.stat_status);
+}
+
+
+TraceManagerThreadLocal::~TraceManagerThreadLocal()
+{
+}
+
+void TraceManagerThreadLocal::dumpStack(std::ostream& out, bool onlyFunctions) const
+{
+ std::stringstream ss;
+ std::deque<StackEntry>::const_iterator it = stack.begin();
+ std::deque<StackEntry>::const_iterator end = stack.end();
+ int depth = 0;
+ for (; it != end; ++it)
+ {
+ const Region::LocationStaticStorage* location = it->location;
+ if (location)
+ {
+ if (!onlyFunctions || (location->flags & REGION_FLAG_FUNCTION))
+ {
+ ss << _spaces(4*depth) << location->name << std::endl;
+ depth++;
+ }
+ }
+ else
+ {
+ ss << _spaces(4*depth) << "<unknown>" << std::endl;
+ depth++;
+ }
+ }
+ out << ss.str();
+}
+
+class AsyncTraceStorage : public TraceStorage
+{
+ mutable std::ofstream out;
+public:
+ const std::string name;
+
+ AsyncTraceStorage(const std::string& filename) :
+ out(filename.c_str(), std::ios::trunc),
+ name(filename)
+ {
+ out << "#description: OpenCV trace file" << std::endl;
+ out << "#version: 1.0" << std::endl;
+ }
+ ~AsyncTraceStorage()
+ {
+ out.close();
+ }
+
+ bool put(const TraceMessage& msg) const
+ {
+ if (msg.hasError)
+ return false;
+ out << msg.buffer;
+ //DEBUG_ONLY(std::flush(out)); // TODO configure flag
+ return true;
+ }
+};
+
+class SyncTraceStorage : public TraceStorage
+{
+ mutable std::ofstream out;
+ mutable cv::Mutex mutex;
+public:
+ const std::string name;
+
+ SyncTraceStorage(const std::string& filename) :
+ out(filename.c_str(), std::ios::trunc),
+ name(filename)
+ {
+ out << "#description: OpenCV trace file" << std::endl;
+ out << "#version: 1.0" << std::endl;
+ }
+ ~SyncTraceStorage()
+ {
+ cv::AutoLock l(mutex);
+ out.close();
+ }
+
+ bool put(const TraceMessage& msg) const
+ {
+ if (msg.hasError)
+ return false;
+ {
+ cv::AutoLock l(mutex);
+ out << msg.buffer;
+ std::flush(out); // TODO configure flag
+ }
+ return true;
+ }
+};
+
+
+TraceStorage* TraceManagerThreadLocal::getStorage() const
+{
+ // TODO configuration option for stdout/single trace file
+ if (storage.empty())
+ {
+ TraceStorage* global = getTraceManager().trace_storage.get();
+ if (global)
+ {
+ const std::string filepath = cv::format("%s-%03d.txt", param_traceLocation.c_str(), threadID).c_str();
+ TraceMessage msg;
+ const char* pos = strrchr(filepath.c_str(), '/'); // extract filename
+#ifdef _WIN32
+ if (!pos)
+ strrchr(filepath.c_str(), '\\');
+#endif
+ if (!pos)
+ pos = filepath.c_str();
+ msg.printf("#thread file: %s\n", pos);
+ global->put(msg);
+ storage.reset(new AsyncTraceStorage(filepath));
+ }
+ }
+ return storage.get();
+}
+
+
+
+static bool activated = false;
+static bool isInitialized = false;
+
+TraceManager::TraceManager()
+{
+ g_zero_timestamp = cv::getTickCount();
+
+ isInitialized = true;
+ CV_LOG("TraceManager ctor: " << (void*)this);
+
+ CV_LOG("TraceManager configure()");
+ activated = param_traceEnable;
+
+ if (activated)
+ trace_storage.reset(new SyncTraceStorage(std::string(param_traceLocation) + ".txt"));
+
+#ifdef OPENCV_WITH_ITT
+ if (isITTEnabled())
+ {
+ activated = true; // force trace pipeline activation (without OpenCV storage)
+ __itt_region_begin(domain, __itt_null, __itt_null, __itt_string_handle_create("OpenCVTrace"));
+ }
+#endif
+}
+TraceManager::~TraceManager()
+{
+ CV_LOG("TraceManager dtor: " << (void*)this);
+
+#ifdef OPENCV_WITH_ITT
+ if (isITTEnabled())
+ {
+ __itt_region_end(domain, __itt_null);
+ }
+#endif
+
+ std::vector<TraceManagerThreadLocal*> threads_ctx;
+ tls.gather(threads_ctx);
+ size_t totalEvents = 0, totalSkippedEvents = 0;
+ for (size_t i = 0; i < threads_ctx.size(); i++)
+ {
+ TraceManagerThreadLocal* ctx = threads_ctx[i];
+ if (ctx)
+ {
+ totalEvents += ctx->region_counter;
+ totalSkippedEvents += ctx->totalSkippedEvents;
+ }
+ }
+ if (totalEvents || activated)
+ {
+ CV_LOG_INFO(NULL, "Trace: Total events: " << totalEvents);
+ }
+ if (totalSkippedEvents)
+ {
+ CV_LOG_WARNING(NULL, "Trace: Total skipped events: " << totalSkippedEvents);
+ }
+
+ // This is a global static object, so process starts shutdown here
+ // Turn off trace
+ cv::__termination = true; // also set in DllMain() notifications handler for DLL_PROCESS_DETACH
+ activated = false;
+}
+
+bool TraceManager::isActivated()
+{
+ // Check if process starts shutdown, and set earlyExit to true
+ // to prevent further instrumentation processing earlier.
+ if (cv::__termination)
+ {
+ activated = false;
+ return false;
+ }
+
+ if (!isInitialized)
+ {
+ TraceManager& m = getTraceManager();
+ (void)m; // TODO
+ }
+
+ return activated;
+}
+
+
+static TraceManager* getTraceManagerCallOnce()
+{
+ static TraceManager globalInstance;
+ return &globalInstance;
+}
+TraceManager& getTraceManager()
+{
+ CV_SINGLETON_LAZY_INIT_REF(TraceManager, getTraceManagerCallOnce())
+}
+
+void parallelForSetRootRegion(const Region& rootRegion, const TraceManagerThreadLocal& root_ctx)
+{
+ TraceManagerThreadLocal& ctx = getTraceManager().tls.getRef();
+
+ if (ctx.dummy_stack_top.region == &rootRegion) // already attached
+ return;
+
+ CV_Assert(ctx.dummy_stack_top.region == NULL);
+ ctx.dummy_stack_top = TraceManagerThreadLocal::StackEntry(const_cast<Region*>(&rootRegion), NULL, -1);
+
+ if (&ctx == &root_ctx)
+ {
+ ctx.stat.grab(ctx.parallel_for_stat);
+ ctx.parallel_for_stat_status = ctx.stat_status;
+ ctx.parallel_for_stack_size = ctx.stack.size();
+ return;
+ }
+
+ CV_Assert(ctx.stack.empty());
+
+ ctx.currentActiveRegion = const_cast<Region*>(&rootRegion);
+
+ ctx.regionDepth = root_ctx.regionDepth;
+ ctx.regionDepthOpenCV = root_ctx.regionDepthOpenCV;
+
+ ctx.parallel_for_stack_size = 0;
+
+ ctx.stat_status.propagateFrom(root_ctx.stat_status);
+}
+
+void parallelForAttachNestedRegion(const Region& rootRegion)
+{
+ CV_UNUSED(rootRegion);
+ TraceManagerThreadLocal& ctx = getTraceManager().tls.getRef();
+
+ CV_DbgAssert(ctx.dummy_stack_top.region == &rootRegion);
+
+ Region* region = ctx.getCurrentActiveRegion();
+ CV_LOG_PARALLEL(NULL, " PARALLEL_FOR: " << (void*)region << " ==> " << &rootRegion);
+ if (!region)
+ return;
+
+#ifdef OPENCV_WITH_ITT
+ if (!rootRegion.pImpl || !rootRegion.pImpl->itt_id_registered)
+ return;
+
+ if (!region->pImpl)
+ return;
+
+ CV_LOG_PARALLEL(NULL, " PARALLEL_FOR ITT: " << (void*)rootRegion.pImpl->itt_id.d1 << ":" << rootRegion.pImpl->itt_id.d2 << ":" << (void*)rootRegion.pImpl->itt_id.d3 << " => "
+ << (void*)region->pImpl->itt_id.d1 << ":" << region->pImpl->itt_id.d2 << ":" << (void*)region->pImpl->itt_id.d3);
+ __itt_relation_add(domain, region->pImpl->itt_id, __itt_relation_is_child_of, rootRegion.pImpl->itt_id);
+#endif
+}
+
+void parallelForFinalize(const Region& rootRegion)
+{
+ TraceManagerThreadLocal& ctx = getTraceManager().tls.getRef();
+
+ int64 endTimestamp = getTimestamp();
+ int64 duration = endTimestamp - ctx.stackTopBeginTimestamp();
+ CV_LOG_PARALLEL(NULL, "parallel_for duration: " << duration << " " << &rootRegion);
+
+ std::vector<TraceManagerThreadLocal*> threads_ctx;
+ getTraceManager().tls.gather(threads_ctx);
+ RegionStatistics parallel_for_stat;
+ int threads = 0;
+ for (size_t i = 0; i < threads_ctx.size(); i++)
+ {
+ TraceManagerThreadLocal* child_ctx = threads_ctx[i];
+
+ if (child_ctx && child_ctx->stackTopRegion() == &rootRegion)
+ {
+ CV_LOG_PARALLEL(NULL, "Thread=" << child_ctx->threadID << " " << child_ctx->stat);
+ threads++;
+ RegionStatistics child_stat;
+ child_ctx->stat.grab(child_stat);
+ parallel_for_stat.append(child_stat);
+ if (child_ctx != &ctx)
+ {
+ child_ctx->dummy_stack_top = TraceManagerThreadLocal::StackEntry();
+ }
+ else
+ {
+ ctx.parallel_for_stat.grab(ctx.stat);
+ ctx.stat_status = ctx.parallel_for_stat_status;
+ child_ctx->dummy_stack_top = TraceManagerThreadLocal::StackEntry();
+ }
+ }
+ }
+ float parallel_coeff = std::min(1.0f, duration / (float)(parallel_for_stat.duration));
+ CV_LOG_PARALLEL(NULL, "parallel_coeff=" << 1.0f / parallel_coeff);
+ CV_LOG_PARALLEL(NULL, parallel_for_stat);
+ if (parallel_coeff != 1.0f)
+ {
+ parallel_for_stat.multiply(parallel_coeff);
+ CV_LOG_PARALLEL(NULL, parallel_for_stat);
+ }
+ parallel_for_stat.duration = 0;
+ ctx.stat.append(parallel_for_stat);
+ CV_LOG_PARALLEL(NULL, ctx.stat);
+}
+
+struct TraceArg::ExtraData
+{
+#ifdef OPENCV_WITH_ITT
+ // Special fields for ITT
+ __itt_string_handle* volatile ittHandle_name;
+#endif
+ ExtraData(TraceManagerThreadLocal& ctx, const TraceArg& arg)
+ {
+ CV_UNUSED(ctx); CV_UNUSED(arg);
+#ifdef OPENCV_WITH_ITT
+ if (isITTEnabled())
+ {
+ // Caching is not required here, because there is builtin cache.
+ // https://software.intel.com/en-us/node/544203:
+ // Consecutive calls to __itt_string_handle_create with the same name return the same value.
+ ittHandle_name = __itt_string_handle_create(arg.name);
+ }
+ else
+ {
+ ittHandle_name = 0;
+ }
+#endif
+ }
+};
+
+static void initTraceArg(TraceManagerThreadLocal& ctx, const TraceArg& arg)
+{
+ TraceArg::ExtraData** pExtra = arg.ppExtra;
+ if (*pExtra == NULL)
+ {
+ cv::AutoLock lock(cv::getInitializationMutex());
+ if (*pExtra == NULL)
+ {
+ *pExtra = new TraceArg::ExtraData(ctx, arg);
+ }
+ }
+}
+void traceArg(const TraceArg& arg, const char* value)
+{
+ TraceManagerThreadLocal& ctx = getTraceManager().tls.getRef();
+ Region* region = ctx.getCurrentActiveRegion();
+ if (!region)
+ return;
+ CV_Assert(region->pImpl);
+ initTraceArg(ctx, arg);
+ if (!value)
+ value = "<null>";
+#ifdef OPENCV_WITH_ITT
+ if (isITTEnabled())
+ {
+ __itt_metadata_str_add(domain, region->pImpl->itt_id, (*arg.ppExtra)->ittHandle_name, value, strlen(value));
+ }
+#endif
+}
+void traceArg(const TraceArg& arg, int value)
+{
+ TraceManagerThreadLocal& ctx = getTraceManager().tls.getRef();
+ Region* region = ctx.getCurrentActiveRegion();
+ if (!region)
+ return;
+ CV_Assert(region->pImpl);
+ initTraceArg(ctx, arg);
+#ifdef OPENCV_WITH_ITT
+ if (isITTEnabled())
+ {
+ __itt_metadata_add(domain, region->pImpl->itt_id, (*arg.ppExtra)->ittHandle_name, sizeof(int) == 4 ? __itt_metadata_s32 : __itt_metadata_s64, 1, &value);
+ }
+#else
+ CV_UNUSED(value);
+#endif
+}
+void traceArg(const TraceArg& arg, int64 value)
+{
+ TraceManagerThreadLocal& ctx = getTraceManager().tls.getRef();
+ Region* region = ctx.getCurrentActiveRegion();
+ if (!region)
+ return;
+ CV_Assert(region->pImpl);
+ initTraceArg(ctx, arg);
+#ifdef OPENCV_WITH_ITT
+ if (isITTEnabled())
+ {
+ __itt_metadata_add(domain, region->pImpl->itt_id, (*arg.ppExtra)->ittHandle_name, __itt_metadata_s64, 1, &value);
+ }
+#else
+ CV_UNUSED(value);
+#endif
+}
+void traceArg(const TraceArg& arg, double value)
+{
+ TraceManagerThreadLocal& ctx = getTraceManager().tls.getRef();
+ Region* region = ctx.getCurrentActiveRegion();
+ if (!region)
+ return;
+ CV_Assert(region->pImpl);
+ initTraceArg(ctx, arg);
+#ifdef OPENCV_WITH_ITT
+ if (isITTEnabled())
+ {
+ __itt_metadata_add(domain, region->pImpl->itt_id, (*arg.ppExtra)->ittHandle_name, __itt_metadata_double, 1, &value);
+ }
+#else
+ CV_UNUSED(value);
+#endif
+}
+
+#else
+
+Region::Region(const LocationStaticStorage&) : pImpl(NULL), implFlags(0) {}
+void Region::destroy() {}
+
+void traceArg(const TraceArg&, const char*) {}
+void traceArg(const TraceArg&, int) {};
+void traceArg(const TraceArg&, int64) {};
+void traceArg(const TraceArg&, double) {};
+
+#endif
+
+}}}} // namespace
diff --git a/modules/core/src/umatrix.cpp b/modules/core/src/umatrix.cpp
index 5874be8..58f7390 100644
--- a/modules/core/src/umatrix.cpp
+++ b/modules/core/src/umatrix.cpp
@@ -411,8 +411,9 @@ UMat::~UMat()
void UMat::deallocate()
{
- u->currAllocator->deallocate(u);
+ UMatData* u_ = u;
u = NULL;
+ u_->currAllocator->deallocate(u_);
}
@@ -599,8 +600,13 @@ UMat& UMat::adjustROI( int dtop, int dbottom, int dleft, int dright )
Size wholeSize; Point ofs;
size_t esz = elemSize();
locateROI( wholeSize, ofs );
- int row1 = std::max(ofs.y - dtop, 0), row2 = std::min(ofs.y + rows + dbottom, wholeSize.height);
- int col1 = std::max(ofs.x - dleft, 0), col2 = std::min(ofs.x + cols + dright, wholeSize.width);
+ int row1 = std::min(std::max(ofs.y - dtop, 0), wholeSize.height), row2 = std::max(0, std::min(ofs.y + rows + dbottom, wholeSize.height));
+ int col1 = std::min(std::max(ofs.x - dleft, 0), wholeSize.width), col2 = std::max(0, std::min(ofs.x + cols + dright, wholeSize.width));
+ if(row1 > row2)
+ std::swap(row1, row2);
+ if(col1 > col2)
+ std::swap(col1, col2);
+
offset += (row1 - ofs.y)*step + (col1 - ofs.x)*esz;
rows = row2 - row1; cols = col2 - col1;
size.p[0] = rows; size.p[1] = cols;
@@ -819,7 +825,7 @@ void UMat::copyTo(OutputArray _dst) const
return;
}
- size_t i, sz[CV_MAX_DIM], srcofs[CV_MAX_DIM], dstofs[CV_MAX_DIM], esz = elemSize();
+ size_t i, sz[CV_MAX_DIM] = {0}, srcofs[CV_MAX_DIM], dstofs[CV_MAX_DIM], esz = elemSize();
for( i = 0; i < (size_t)dims; i++ )
sz[i] = size.p[i];
sz[dims-1] *= esz;
@@ -830,6 +836,7 @@ void UMat::copyTo(OutputArray _dst) const
if( _dst.isUMat() )
{
UMat dst = _dst.getUMat();
+ CV_Assert(dst.u);
if( u == dst.u && dst.offset == offset )
return;
@@ -986,7 +993,7 @@ UMat& UMat::setTo(InputArray _value, InputArray _mask)
ocl::Kernel setK(haveMask ? "setMask" : "set", ocl::core::copyset_oclsrc, opts);
if( !setK.empty() )
{
- ocl::KernelArg scalararg(0, 0, 0, 0, buf, CV_ELEM_SIZE(d) * scalarcn);
+ ocl::KernelArg scalararg(ocl::KernelArg::CONSTANT, 0, 0, 0, buf, CV_ELEM_SIZE(d) * scalarcn);
UMat mask;
if( haveMask )
diff --git a/modules/core/test/ocl/test_arithm.cpp b/modules/core/test/ocl/test_arithm.cpp
index 435cbf6..9a81760 100644
--- a/modules/core/test/ocl/test_arithm.cpp
+++ b/modules/core/test/ocl/test_arithm.cpp
@@ -331,7 +331,7 @@ OCL_TEST_P(Mul, Mat_Scale)
OCL_OFF(cv::multiply(src1_roi, src2_roi, dst1_roi, val[0]));
OCL_ON(cv::multiply(usrc1_roi, usrc2_roi, udst1_roi, val[0]));
-#ifdef ANDROID
+#ifdef __ANDROID__
Near(udst1_roi.depth() >= CV_32F ? 2e-1 : 1);
#else
Near(udst1_roi.depth() >= CV_32F ? 1e-3 : 1);
@@ -447,8 +447,8 @@ OCL_TEST_P(Min, Mat)
{
generateTestData();
- OCL_OFF(cv::max(src1_roi, src2_roi, dst1_roi));
- OCL_ON(cv::max(usrc1_roi, usrc2_roi, udst1_roi));
+ OCL_OFF(cv::min(src1_roi, src2_roi, dst1_roi));
+ OCL_ON(cv::min(usrc1_roi, usrc2_roi, udst1_roi));
Near(0);
}
}
@@ -461,8 +461,8 @@ OCL_TEST_P(Max, Mat)
{
generateTestData();
- OCL_OFF(cv::min(src1_roi, src2_roi, dst1_roi));
- OCL_ON(cv::min(usrc1_roi, usrc2_roi, udst1_roi));
+ OCL_OFF(cv::max(src1_roi, src2_roi, dst1_roi));
+ OCL_ON(cv::max(usrc1_roi, usrc2_roi, udst1_roi));
Near(0);
}
}
@@ -1614,6 +1614,68 @@ OCL_TEST_P(ConvertScaleAbs, Mat)
}
}
+//////////////////////////////// ConvertFp16 ////////////////////////////////////////////////
+
+PARAM_TEST_CASE(ConvertFp16, Channels, bool)
+{
+ int cn;
+ bool fromHalf;
+ cv::Scalar val;
+
+ TEST_DECLARE_INPUT_PARAMETER(src);
+ TEST_DECLARE_OUTPUT_PARAMETER(dst);
+
+ virtual void SetUp()
+ {
+ cn = GET_PARAM(0);
+ fromHalf = GET_PARAM(1);
+ }
+
+ void generateTestData()
+ {
+ const int stype = CV_MAKE_TYPE(fromHalf ? CV_32F : CV_16S, cn);
+ const int dtype = CV_MAKE_TYPE(fromHalf ? CV_16S : CV_32F, cn);
+
+ Size roiSize = randomSize(1, MAX_VALUE);
+ Border srcBorder = randomBorder(0, 0);
+ randomSubMat(src, src_roi, roiSize, srcBorder, stype, -11, 11); // FIXIT: Test with minV, maxV
+ if (stype == CV_MAKE_TYPE(CV_16S, cn)) // eliminate NaN/Inf FP16 values
+ {
+ RNG dataRng(rng.next());
+ Mat src_i32 = cvtest::randomMat(dataRng, roiSize, CV_MAKE_TYPE(CV_32S, cn), 0, 0x7c00, false);
+ Mat shift_i32 = cvtest::randomMat(dataRng, roiSize, src_i32.type(), -1, 1, false); // values: -1, 0
+ src_i32 = src_i32 + (shift_i32 * 0x8000);
+ src_i32.convertTo(src_roi, stype);
+ }
+
+ Border dstBorder = randomBorder(0, 0);
+ randomSubMat(dst, dst_roi, roiSize, dstBorder, dtype, 5, 16);
+
+ UMAT_UPLOAD_INPUT_PARAMETER(src);
+ UMAT_UPLOAD_OUTPUT_PARAMETER(dst);
+ }
+
+ void Near(double threshold = 0.)
+ {
+ OCL_EXPECT_MATS_NEAR(dst, threshold);
+ }
+
+};
+
+
+OCL_TEST_P(ConvertFp16, Mat)
+{
+ for (int j = 0; j < test_loop_times; j++)
+ {
+ generateTestData();
+
+ OCL_OFF(cv::convertFp16(src_roi, dst_roi));
+ OCL_ON(cv::convertFp16(usrc_roi, udst_roi));
+
+ Near(1);
+ }
+}
+
//////////////////////////////// ScaleAdd ////////////////////////////////////////////////
typedef ArithmTestBase ScaleAdd;
@@ -1844,6 +1906,7 @@ OCL_INSTANTIATE_TEST_CASE_P(Arithm, Sqrt, Combine(::testing::Values(CV_32F, CV_6
OCL_INSTANTIATE_TEST_CASE_P(Arithm, Normalize, Combine(OCL_ALL_DEPTHS, Values(Channels(1)), Bool()));
OCL_INSTANTIATE_TEST_CASE_P(Arithm, InRange, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool(), Bool()));
OCL_INSTANTIATE_TEST_CASE_P(Arithm, ConvertScaleAbs, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool()));
+OCL_INSTANTIATE_TEST_CASE_P(Arithm, ConvertFp16, Combine(OCL_ALL_CHANNELS, Bool()));
OCL_INSTANTIATE_TEST_CASE_P(Arithm, ScaleAdd, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, Bool()));
OCL_INSTANTIATE_TEST_CASE_P(Arithm, PatchNaNs, Combine(OCL_ALL_CHANNELS, Bool()));
OCL_INSTANTIATE_TEST_CASE_P(Arithm, Psnr, Combine(::testing::Values((MatDepth)CV_8U), OCL_ALL_CHANNELS, Bool()));
diff --git a/modules/core/test/test_arithm.cpp b/modules/core/test/test_arithm.cpp
index a23cee9..78c0689 100644
--- a/modules/core/test/test_arithm.cpp
+++ b/modules/core/test/test_arithm.cpp
@@ -1912,3 +1912,97 @@ TEST(Subtract, scalarc4_matc4)
ASSERT_EQ(0, cv::norm(cv::Mat(5, 5, CV_8UC4, cv::Scalar::all(250)), destImage, cv::NORM_INF));
}
+
+TEST(Compare, empty)
+{
+ cv::Mat temp, dst1, dst2;
+ cv::compare(temp, temp, dst1, cv::CMP_EQ);
+ dst2 = temp > 5;
+
+ EXPECT_TRUE(dst1.empty());
+ EXPECT_TRUE(dst2.empty());
+}
+
+TEST(Compare, regression_8999)
+{
+ Mat_<double> A(4,1); A << 1, 3, 2, 4;
+ Mat_<double> B(1,1); B << 2;
+ Mat C;
+ ASSERT_ANY_THROW({
+ compare(A, B, C, CMP_LT);
+ });
+}
+
+
+TEST(Core_minMaxIdx, regression_9207_1)
+{
+ const int rows = 4;
+ const int cols = 3;
+ uchar mask_[rows*cols] = {
+ 255, 255, 255,
+ 255, 0, 255,
+ 0, 255, 255,
+ 0, 0, 255
+};
+ uchar src_[rows*cols] = {
+ 1, 1, 1,
+ 1, 1, 1,
+ 2, 1, 1,
+ 2, 2, 1
+};
+ Mat mask(Size(cols, rows), CV_8UC1, mask_);
+ Mat src(Size(cols, rows), CV_8UC1, src_);
+ double minVal = -0.0, maxVal = -0.0;
+ int minIdx[2] = { -2, -2 }, maxIdx[2] = { -2, -2 };
+ minMaxIdx(src, &minVal, &maxVal, minIdx, maxIdx, mask);
+ EXPECT_EQ(0, minIdx[0]);
+ EXPECT_EQ(0, minIdx[1]);
+ EXPECT_EQ(0, maxIdx[0]);
+ EXPECT_EQ(0, maxIdx[1]);
+}
+
+
+TEST(Core_minMaxIdx, regression_9207_2)
+{
+ const int rows = 13;
+ const int cols = 15;
+ uchar mask_[rows*cols] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255,
+ 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255,
+ 255, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255,
+ 255, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 255, 255,
+ 255, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 255, 255, 255, 0,
+ 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 0,
+ 255, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 255, 255, 0,
+ 255, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 255, 0,
+ 255, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 255, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+ uchar src_[15*13] = {
+ 5, 5, 5, 5, 5, 6, 5, 2, 0, 4, 6, 6, 4, 1, 0,
+ 6, 5, 4, 4, 5, 6, 6, 5, 2, 0, 4, 6, 5, 2, 0,
+ 3, 2, 1, 1, 2, 4, 6, 6, 4, 2, 3, 4, 4, 2, 0,
+ 1, 0, 0, 0, 0, 1, 4, 5, 4, 4, 4, 4, 3, 2, 0,
+ 0, 0, 0, 0, 0, 0, 2, 3, 4, 4, 4, 3, 2, 1, 0,
+ 0, 0, 0, 0, 0, 0, 0, 2, 3, 4, 3, 2, 1, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1,
+ 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 3, 3, 1, 0, 1,
+ 0, 0, 0, 0, 0, 0, 1, 4, 5, 6, 5, 4, 3, 2, 0,
+ 1, 0, 0, 0, 0, 0, 3, 5, 5, 4, 3, 4, 4, 3, 0,
+ 2, 0, 0, 0, 0, 2, 5, 6, 5, 2, 2, 5, 4, 3, 0
+};
+ Mat mask(Size(cols, rows), CV_8UC1, mask_);
+ Mat src(Size(cols, rows), CV_8UC1, src_);
+ double minVal = -0.0, maxVal = -0.0;
+ int minIdx[2] = { -2, -2 }, maxIdx[2] = { -2, -2 };
+ minMaxIdx(src, &minVal, &maxVal, minIdx, maxIdx, mask);
+ EXPECT_EQ(0, minIdx[0]);
+ EXPECT_EQ(14, minIdx[1]);
+ EXPECT_EQ(0, maxIdx[0]);
+ EXPECT_EQ(14, maxIdx[1]);
+}
diff --git a/modules/core/test/test_countnonzero.cpp b/modules/core/test/test_countnonzero.cpp
index 0b82103..862307c 100644
--- a/modules/core/test/test_countnonzero.cpp
+++ b/modules/core/test/test_countnonzero.cpp
@@ -250,3 +250,30 @@ void CV_CountNonZeroTest::run(int)
}
TEST (Core_CountNonZero, accuracy) { CV_CountNonZeroTest test; test.safe_run(); }
+
+
+typedef testing::TestWithParam<std::tr1::tuple<int, int> > CountNonZeroND;
+
+TEST_P (CountNonZeroND, ndim)
+{
+ const int dims = std::tr1::get<0>(GetParam());
+ const int type = std::tr1::get<1>(GetParam());
+ const int ONE_SIZE = 5;
+
+ vector<int> sizes(dims);
+ fill(sizes.begin(), sizes.end(), ONE_SIZE);
+
+ Mat data(sizes, CV_MAKETYPE(type, 1));
+ data = 0;
+ EXPECT_EQ(0, cv::countNonZero(data));
+ data = Scalar::all(1);
+ int expected = static_cast<int>(pow(static_cast<float>(ONE_SIZE), dims));
+ EXPECT_EQ(expected, cv::countNonZero(data));
+}
+
+INSTANTIATE_TEST_CASE_P(Core, CountNonZeroND,
+ testing::Combine(
+ testing::Range(2, 9),
+ testing::Values(CV_8U, CV_8S, CV_32F)
+ )
+);
diff --git a/modules/core/test/test_eigen.cpp b/modules/core/test/test_eigen.cpp
index 6a9e99e..bd51c74 100644
--- a/modules/core/test/test_eigen.cpp
+++ b/modules/core/test/test_eigen.cpp
@@ -389,11 +389,11 @@ bool Core_EigenTest::check_full(int type)
{
const int MAX_DEGREE = 7;
- srand((unsigned int)time(0));
+ RNG rng = ::theRNG(); // fix the seed
for (int i = 0; i < ntests; ++i)
{
- int src_size = (int)(std::pow(2.0, (rand()%MAX_DEGREE)+1.));
+ int src_size = (int)(std::pow(2.0, (rng.uniform(0, MAX_DEGREE) + 1.)));
cv::Mat src(src_size, src_size, type);
diff --git a/modules/core/test/test_intrin.cpp b/modules/core/test/test_intrin.cpp
index 66b2083..2ef4b8c 100644
--- a/modules/core/test/test_intrin.cpp
+++ b/modules/core/test/test_intrin.cpp
@@ -404,6 +404,18 @@ template<typename R> struct TheTest
return *this;
}
+ TheTest & test_popcount()
+ {
+ static unsigned popcountTable[] = {0, 1, 2, 4, 5, 7, 9, 12, 13, 15, 17, 20, 22, 25, 28, 32, 33};
+ Data<R> dataA;
+ R a = dataA;
+
+ unsigned resB = (unsigned)v_reduce_sum(v_popcount(a));
+ EXPECT_EQ(popcountTable[R::nlanes], resB);
+
+ return *this;
+ }
+
TheTest & test_absdiff()
{
typedef typename V_RegTrait128<LaneType>::u_reg Ru;
@@ -729,9 +741,26 @@ template<typename R> struct TheTest
return *this;
}
+ TheTest & test_reduce_sum4()
+ {
+ R a(0.1f, 0.02f, 0.003f, 0.0004f);
+ R b(1, 20, 300, 4000);
+ R c(10, 2, 0.3f, 0.04f);
+ R d(1, 2, 3, 4);
+
+ R sum = v_reduce_sum4(a, b, c, d);
+
+ Data<R> res = sum;
+ EXPECT_EQ(0.1234f, res[0]);
+ EXPECT_EQ(4321.0f, res[1]);
+ EXPECT_EQ(12.34f, res[2]);
+ EXPECT_EQ(10.0f, res[3]);
+ return *this;
+ }
+
TheTest & test_loadstore_fp16()
{
-#if CV_FP16
+#if CV_FP16 && CV_SIMD128
AlignedData<R> data;
AlignedData<R> out;
@@ -763,7 +792,7 @@ template<typename R> struct TheTest
TheTest & test_float_cvt_fp16()
{
-#if CV_FP16
+#if CV_FP16 && CV_SIMD128
AlignedData<v_float32x4> data;
if(checkHardwareSupport(CV_CPU_FP16))
@@ -798,6 +827,7 @@ TEST(hal_intrin, uint8x16) {
.test_min_max()
.test_absdiff()
.test_mask()
+ .test_popcount()
.test_pack<1>().test_pack<2>().test_pack<3>().test_pack<8>()
.test_pack_u<1>().test_pack_u<2>().test_pack_u<3>().test_pack_u<8>()
.test_unpack()
@@ -819,6 +849,7 @@ TEST(hal_intrin, int8x16) {
.test_absdiff()
.test_abs()
.test_mask()
+ .test_popcount()
.test_pack<1>().test_pack<2>().test_pack<3>().test_pack<8>()
.test_unpack()
.test_extract<0>().test_extract<1>().test_extract<8>().test_extract<15>()
@@ -844,6 +875,7 @@ TEST(hal_intrin, uint16x8) {
.test_absdiff()
.test_reduce()
.test_mask()
+ .test_popcount()
.test_pack<1>().test_pack<2>().test_pack<7>().test_pack<16>()
.test_pack_u<1>().test_pack_u<2>().test_pack_u<7>().test_pack_u<16>()
.test_unpack()
@@ -870,6 +902,7 @@ TEST(hal_intrin, int16x8) {
.test_abs()
.test_reduce()
.test_mask()
+ .test_popcount()
.test_pack<1>().test_pack<2>().test_pack<7>().test_pack<16>()
.test_unpack()
.test_extract<0>().test_extract<1>().test_extract<4>().test_extract<7>()
@@ -894,6 +927,7 @@ TEST(hal_intrin, uint32x4) {
.test_absdiff()
.test_reduce()
.test_mask()
+ .test_popcount()
.test_pack<1>().test_pack<2>().test_pack<15>().test_pack<32>()
.test_unpack()
.test_extract<0>().test_extract<1>().test_extract<2>().test_extract<3>()
@@ -910,6 +944,7 @@ TEST(hal_intrin, int32x4) {
.test_mul()
.test_abs()
.test_cmp()
+ .test_popcount()
.test_shift<1>().test_shift<8>()
.test_logic()
.test_min_max()
@@ -968,6 +1003,7 @@ TEST(hal_intrin, float32x4) {
.test_float_cvt64()
.test_matmul()
.test_transpose()
+ .test_reduce_sum4()
;
}
@@ -990,7 +1026,7 @@ TEST(hal_intrin, float64x2) {
}
#endif
-#if CV_FP16
+#if CV_FP16 && CV_SIMD128
TEST(hal_intrin, float16x4) {
TheTest<v_float16x4>()
.test_loadstore_fp16()
diff --git a/modules/core/test/test_io.cpp b/modules/core/test/test_io.cpp
index eb02a7b..4d3bb81 100644
--- a/modules/core/test/test_io.cpp
+++ b/modules/core/test/test_io.cpp
@@ -614,13 +614,41 @@ struct data_t
typedef float f;
typedef double d;
- u u1 ;u u2 ; i i1 ;
- i i2 ;i i3 ;
- d d1 ;
- d d2 ;
- i i4 ;
-
- static inline const char * signature() { return "2u3i2di"; }
+ /*0x00*/ u u1 ;u u2 ; i i1 ;
+ /*0x08*/ i i2 ;i i3 ;
+ /*0x10*/ d d1 ;
+ /*0x18*/ d d2 ;
+ /*0x20*/ i i4 ;i required_alignment_field_for_linux32;
+ /*
+ * OpenCV persistence.cpp stuff expects: sizeof(data_t) = alignSize(36, sizeof(largest type = double)) = 40
+ * Some compilers on some archs returns sizeof(data_t) = 36 due struct packaging UB
+ */
+
+ static inline const char * signature() {
+ if (sizeof(data_t) != 40)
+ {
+ printf("sizeof(data_t)=%d, u1=%p u2=%p i1=%p i2=%p i3=%p d1=%p d2=%p i4=%p\n", (int)sizeof(data_t),
+ &(((data_t*)0)->u1),
+ &(((data_t*)0)->u2),
+ &(((data_t*)0)->i1),
+ &(((data_t*)0)->i2),
+ &(((data_t*)0)->i3),
+ &(((data_t*)0)->d1),
+ &(((data_t*)0)->d2),
+ &(((data_t*)0)->i4)
+ );
+ }
+ CV_Assert(sizeof(data_t) == 40);
+ CV_Assert((size_t)&(((data_t*)0)->u1) == 0x0);
+ CV_Assert((size_t)&(((data_t*)0)->u2) == 0x1);
+ CV_Assert((size_t)&(((data_t*)0)->i1) == 0x4);
+ CV_Assert((size_t)&(((data_t*)0)->i2) == 0x8);
+ CV_Assert((size_t)&(((data_t*)0)->i3) == 0xc);
+ CV_Assert((size_t)&(((data_t*)0)->d1) == 0x10);
+ CV_Assert((size_t)&(((data_t*)0)->d2) == 0x18);
+ CV_Assert((size_t)&(((data_t*)0)->i4) == 0x20);
+ return "2u3i2di";
+ }
};
TEST(Core_InputOutput, filestorage_base64_basic)
@@ -718,16 +746,24 @@ TEST(Core_InputOutput, filestorage_base64_basic)
fs.release();
}
- for (int i = 0; i < 1000; i++) {
- // TODO: Solve this bug in `cvReadRawData`
- //EXPECT_EQ(rawdata[i].u1, 1);
- //EXPECT_EQ(rawdata[i].u2, 2);
- //EXPECT_EQ(rawdata[i].i1, 1);
- //EXPECT_EQ(rawdata[i].i2, 2);
- //EXPECT_EQ(rawdata[i].i3, 3);
- //EXPECT_EQ(rawdata[i].d1, 0.1);
- //EXPECT_EQ(rawdata[i].d2, 0.2);
- //EXPECT_EQ(rawdata[i].i4, i);
+ int errors = 0;
+ for (int i = 0; i < 1000; i++)
+ {
+ EXPECT_EQ((int)rawdata[i].u1, 1);
+ EXPECT_EQ((int)rawdata[i].u2, 2);
+ EXPECT_EQ((int)rawdata[i].i1, 1);
+ EXPECT_EQ((int)rawdata[i].i2, 2);
+ EXPECT_EQ((int)rawdata[i].i3, 3);
+ EXPECT_EQ(rawdata[i].d1, 0.1);
+ EXPECT_EQ(rawdata[i].d2, 0.2);
+ EXPECT_EQ((int)rawdata[i].i4, i);
+ if (::testing::Test::HasNonfatalFailure())
+ {
+ printf("i = %d\n", i);
+ errors++;
+ }
+ if (errors >= 3)
+ break;
}
EXPECT_TRUE(no_type_id);
@@ -741,9 +777,25 @@ TEST(Core_InputOutput, filestorage_base64_basic)
EXPECT_EQ(_2d_in.cols , _2d_out.cols);
EXPECT_EQ(_2d_in.dims , _2d_out.dims);
EXPECT_EQ(_2d_in.depth(), _2d_out.depth());
+
+ errors = 0;
for(int i = 0; i < _2d_out.rows; ++i)
+ {
for (int j = 0; j < _2d_out.cols; ++j)
+ {
EXPECT_EQ(_2d_in.at<cv::Vec3b>(i, j), _2d_out.at<cv::Vec3b>(i, j));
+ if (::testing::Test::HasNonfatalFailure())
+ {
+ printf("i = %d, j = %d\n", i, j);
+ errors++;
+ }
+ if (errors >= 3)
+ {
+ i = _2d_out.rows;
+ break;
+ }
+ }
+ }
EXPECT_EQ(_nd_in.rows , _nd_out.rows);
EXPECT_EQ(_nd_in.cols , _nd_out.cols);
@@ -996,3 +1048,300 @@ TEST(Core_InputOutput, filestorage_vec_vec_io)
remove((fileName + formats[i]).c_str());
}
}
+
+TEST(Core_InputOutput, filestorage_yaml_advanvced_type_heading)
+{
+ String content = "%YAML:1.0\n cameraMatrix: !<tag:yaml.org,2002:opencv-matrix>\n"
+ " rows: 1\n"
+ " cols: 1\n"
+ " dt: d\n"
+ " data: [ 1. ]";
+
+ cv::FileStorage fs(content, cv::FileStorage::READ | cv::FileStorage::MEMORY);
+
+ cv::Mat inputMatrix;
+ cv::Mat actualMatrix = cv::Mat::eye(1, 1, CV_64F);
+ fs["cameraMatrix"] >> inputMatrix;
+
+ ASSERT_EQ(cv::norm(inputMatrix, actualMatrix, NORM_INF), 0.);
+}
+
+TEST(Core_InputOutput, filestorage_keypoints_vec_vec_io)
+{
+ vector<vector<KeyPoint> > kptsVec;
+ vector<KeyPoint> kpts;
+ kpts.push_back(KeyPoint(0, 0, 1.1f));
+ kpts.push_back(KeyPoint(1, 1, 1.1f));
+ kptsVec.push_back(kpts);
+ kpts.clear();
+ kpts.push_back(KeyPoint(0, 0, 1.1f, 10.1f, 34.5f, 10, 11));
+ kptsVec.push_back(kpts);
+
+ FileStorage writer("", FileStorage::WRITE + FileStorage::MEMORY + FileStorage::FORMAT_XML);
+ writer << "keypoints" << kptsVec;
+ String content = writer.releaseAndGetString();
+
+ FileStorage reader(content, FileStorage::READ + FileStorage::MEMORY);
+ vector<vector<KeyPoint> > readKptsVec;
+ reader["keypoints"] >> readKptsVec;
+
+ ASSERT_EQ(kptsVec.size(), readKptsVec.size());
+
+ for(size_t i = 0; i < kptsVec.size(); i++)
+ {
+ ASSERT_EQ(kptsVec[i].size(), readKptsVec[i].size());
+ for(size_t j = 0; j < kptsVec[i].size(); j++)
+ {
+ ASSERT_FLOAT_EQ(kptsVec[i][j].pt.x, readKptsVec[i][j].pt.x);
+ ASSERT_FLOAT_EQ(kptsVec[i][j].pt.y, readKptsVec[i][j].pt.y);
+ ASSERT_FLOAT_EQ(kptsVec[i][j].angle, readKptsVec[i][j].angle);
+ ASSERT_FLOAT_EQ(kptsVec[i][j].size, readKptsVec[i][j].size);
+ ASSERT_FLOAT_EQ(kptsVec[i][j].response, readKptsVec[i][j].response);
+ ASSERT_EQ(kptsVec[i][j].octave, readKptsVec[i][j].octave);
+ ASSERT_EQ(kptsVec[i][j].class_id, readKptsVec[i][j].class_id);
+ }
+ }
+}
+
+TEST(Core_InputOutput, FileStorage_DMatch)
+{
+ cv::FileStorage fs("dmatch.yml", cv::FileStorage::WRITE | cv::FileStorage::MEMORY);
+
+ cv::DMatch d(1, 2, 3, -1.5f);
+
+ EXPECT_NO_THROW(fs << "d" << d);
+ cv::String fs_result = fs.releaseAndGetString();
+#if defined _MSC_VER && _MSC_VER <= 1700 /* MSVC 2012 and older */
+ EXPECT_STREQ(fs_result.c_str(), "%YAML:1.0\n---\nd: [ 1, 2, 3, -1.5000000000000000e+000 ]\n");
+#else
+ EXPECT_STREQ(fs_result.c_str(), "%YAML:1.0\n---\nd: [ 1, 2, 3, -1.5000000000000000e+00 ]\n");
+#endif
+
+ cv::FileStorage fs_read(fs_result, cv::FileStorage::READ | cv::FileStorage::MEMORY);
+
+ cv::DMatch d_read;
+ ASSERT_NO_THROW(fs_read["d"] >> d_read);
+
+ EXPECT_EQ(d.queryIdx, d_read.queryIdx);
+ EXPECT_EQ(d.trainIdx, d_read.trainIdx);
+ EXPECT_EQ(d.imgIdx, d_read.imgIdx);
+ EXPECT_EQ(d.distance, d_read.distance);
+}
+
+TEST(Core_InputOutput, FileStorage_DMatch_vector)
+{
+ cv::FileStorage fs("dmatch.yml", cv::FileStorage::WRITE | cv::FileStorage::MEMORY);
+
+ cv::DMatch d1(1, 2, 3, -1.5f);
+ cv::DMatch d2(2, 3, 4, 1.5f);
+ cv::DMatch d3(3, 2, 1, 0.5f);
+ std::vector<cv::DMatch> dv;
+ dv.push_back(d1);
+ dv.push_back(d2);
+ dv.push_back(d3);
+
+ EXPECT_NO_THROW(fs << "dv" << dv);
+ cv::String fs_result = fs.releaseAndGetString();
+#if defined _MSC_VER && _MSC_VER <= 1700 /* MSVC 2012 and older */
+ EXPECT_STREQ(fs_result.c_str(),
+"%YAML:1.0\n"
+"---\n"
+"dv: [ 1, 2, 3, -1.5000000000000000e+000, 2, 3, 4,\n"
+" 1.5000000000000000e+000, 3, 2, 1, 5.0000000000000000e-001 ]\n"
+);
+#else
+ EXPECT_STREQ(fs_result.c_str(),
+"%YAML:1.0\n"
+"---\n"
+"dv: [ 1, 2, 3, -1.5000000000000000e+00, 2, 3, 4, 1.5000000000000000e+00,\n"
+" 3, 2, 1, 5.0000000000000000e-01 ]\n"
+);
+#endif
+
+ cv::FileStorage fs_read(fs_result, cv::FileStorage::READ | cv::FileStorage::MEMORY);
+
+ std::vector<cv::DMatch> dv_read;
+ ASSERT_NO_THROW(fs_read["dv"] >> dv_read);
+
+ ASSERT_EQ(dv.size(), dv_read.size());
+ for (size_t i = 0; i < dv.size(); i++)
+ {
+ EXPECT_EQ(dv[i].queryIdx, dv_read[i].queryIdx);
+ EXPECT_EQ(dv[i].trainIdx, dv_read[i].trainIdx);
+ EXPECT_EQ(dv[i].imgIdx, dv_read[i].imgIdx);
+ EXPECT_EQ(dv[i].distance, dv_read[i].distance);
+ }
+}
+
+TEST(Core_InputOutput, FileStorage_DMatch_vector_vector)
+{
+ cv::FileStorage fs("dmatch.yml", cv::FileStorage::WRITE | cv::FileStorage::MEMORY);
+
+ cv::DMatch d1(1, 2, 3, -1.5f);
+ cv::DMatch d2(2, 3, 4, 1.5f);
+ cv::DMatch d3(3, 2, 1, 0.5f);
+ std::vector<cv::DMatch> dv1;
+ dv1.push_back(d1);
+ dv1.push_back(d2);
+ dv1.push_back(d3);
+
+ std::vector<cv::DMatch> dv2;
+ dv2.push_back(d3);
+ dv2.push_back(d1);
+
+ std::vector< std::vector<cv::DMatch> > dvv;
+ dvv.push_back(dv1);
+ dvv.push_back(dv2);
+
+ EXPECT_NO_THROW(fs << "dvv" << dvv);
+ cv::String fs_result = fs.releaseAndGetString();
+#if defined _MSC_VER && _MSC_VER <= 1700 /* MSVC 2012 and older */
+ EXPECT_STREQ(fs_result.c_str(),
+"%YAML:1.0\n"
+"---\n"
+"dvv:\n"
+" - [ 1, 2, 3, -1.5000000000000000e+000, 2, 3, 4,\n"
+" 1.5000000000000000e+000, 3, 2, 1, 5.0000000000000000e-001 ]\n"
+" - [ 3, 2, 1, 5.0000000000000000e-001, 1, 2, 3,\n"
+" -1.5000000000000000e+000 ]\n"
+);
+#else
+ EXPECT_STREQ(fs_result.c_str(),
+"%YAML:1.0\n"
+"---\n"
+"dvv:\n"
+" - [ 1, 2, 3, -1.5000000000000000e+00, 2, 3, 4, 1.5000000000000000e+00,\n"
+" 3, 2, 1, 5.0000000000000000e-01 ]\n"
+" - [ 3, 2, 1, 5.0000000000000000e-01, 1, 2, 3, -1.5000000000000000e+00 ]\n"
+);
+#endif
+
+ cv::FileStorage fs_read(fs_result, cv::FileStorage::READ | cv::FileStorage::MEMORY);
+
+ std::vector< std::vector<cv::DMatch> > dvv_read;
+ ASSERT_NO_THROW(fs_read["dvv"] >> dvv_read);
+
+ ASSERT_EQ(dvv.size(), dvv_read.size());
+ for (size_t j = 0; j < dvv.size(); j++)
+ {
+ const std::vector<cv::DMatch>& dv = dvv[j];
+ const std::vector<cv::DMatch>& dv_read = dvv_read[j];
+ ASSERT_EQ(dvv.size(), dvv_read.size());
+ for (size_t i = 0; i < dv.size(); i++)
+ {
+ EXPECT_EQ(dv[i].queryIdx, dv_read[i].queryIdx);
+ EXPECT_EQ(dv[i].trainIdx, dv_read[i].trainIdx);
+ EXPECT_EQ(dv[i].imgIdx, dv_read[i].imgIdx);
+ EXPECT_EQ(dv[i].distance, dv_read[i].distance);
+ }
+ }
+}
+
+TEST(Core_InputOutput, FileStorage_format_xml)
+{
+ FileStorage fs;
+ fs.open("opencv_storage.xml", FileStorage::WRITE | FileStorage::MEMORY);
+ EXPECT_EQ(FileStorage::FORMAT_XML, fs.getFormat());
+}
+
+TEST(Core_InputOutput, FileStorage_format_xml_gz)
+{
+ FileStorage fs;
+ fs.open("opencv_storage.xml.gz", FileStorage::WRITE | FileStorage::MEMORY);
+ EXPECT_EQ(FileStorage::FORMAT_XML, fs.getFormat());
+}
+
+TEST(Core_InputOutput, FileStorage_format_json)
+{
+ FileStorage fs;
+ fs.open("opencv_storage.json", FileStorage::WRITE | FileStorage::MEMORY);
+ EXPECT_EQ(FileStorage::FORMAT_JSON, fs.getFormat());
+}
+
+TEST(Core_InputOutput, FileStorage_format_json_gz)
+{
+ FileStorage fs;
+ fs.open("opencv_storage.json.gz", FileStorage::WRITE | FileStorage::MEMORY);
+ EXPECT_EQ(FileStorage::FORMAT_JSON, fs.getFormat());
+}
+
+TEST(Core_InputOutput, FileStorage_format_yaml)
+{
+ FileStorage fs;
+ fs.open("opencv_storage.yaml", FileStorage::WRITE | FileStorage::MEMORY);
+ EXPECT_EQ(FileStorage::FORMAT_YAML, fs.getFormat());
+}
+
+TEST(Core_InputOutput, FileStorage_format_yaml_gz)
+{
+ FileStorage fs;
+ fs.open("opencv_storage.yaml.gz", FileStorage::WRITE | FileStorage::MEMORY);
+ EXPECT_EQ(FileStorage::FORMAT_YAML, fs.getFormat());
+}
+
+TEST(Core_InputOutput, FileStorage_format_yml)
+{
+ FileStorage fs;
+ fs.open("opencv_storage.yml", FileStorage::WRITE | FileStorage::MEMORY);
+ EXPECT_EQ(FileStorage::FORMAT_YAML, fs.getFormat());
+}
+
+TEST(Core_InputOutput, FileStorage_format_yml_gz)
+{
+ FileStorage fs;
+ fs.open("opencv_storage.yml.gz", FileStorage::WRITE | FileStorage::MEMORY);
+ EXPECT_EQ(FileStorage::FORMAT_YAML, fs.getFormat());
+}
+
+TEST(Core_InputOutput, FileStorage_json_named_nodes)
+{
+ std::string test =
+ "{ "
+ "\"int_value\": -324,"
+ "\"map_value\": {"
+ "\"str_value\": \"mystring\""
+ "},"
+ "\"array\": [0.2, 0.1]"
+ "}";
+ FileStorage fs(test, FileStorage::READ | FileStorage::MEMORY);
+
+ ASSERT_TRUE(fs["int_value"].isNamed());
+ ASSERT_TRUE(fs["map_value"].isNamed());
+ ASSERT_TRUE(fs["map_value"]["str_value"].isNamed());
+ ASSERT_TRUE(fs["array"].isNamed());
+ ASSERT_FALSE(fs["array"][0].isNamed());
+ ASSERT_FALSE(fs["array"][1].isNamed());
+
+ ASSERT_EQ(fs["int_value"].name(), "int_value");
+ ASSERT_EQ(fs["map_value"].name(), "map_value");
+ ASSERT_EQ(fs["map_value"]["str_value"].name(), "str_value");
+ ASSERT_EQ(fs["array"].name(), "array");
+ fs.release();
+}
+
+TEST(Core_InputOutput, FileStorage_json_bool)
+{
+ std::string test =
+ "{ "
+ "\"str_true\": \"true\","
+ "\"map_value\": {"
+ "\"int_value\": -33333,\n"
+ "\"bool_true\": true,"
+ "\"str_false\": \"false\","
+ "},"
+ "\"bool_false\": false, \n"
+ "\"array\": [0.1, 0.2]"
+ "}";
+ FileStorage fs(test, FileStorage::READ | FileStorage::MEMORY);
+
+ ASSERT_TRUE(fs["str_true"].isString());
+ ASSERT_TRUE(fs["map_value"]["bool_true"].isInt());
+ ASSERT_TRUE(fs["map_value"]["str_false"].isString());
+ ASSERT_TRUE(fs["bool_false"].isInt());
+
+ ASSERT_EQ((std::string)fs["str_true"], "true");
+ ASSERT_EQ((int)fs["map_value"]["bool_true"], 1);
+ ASSERT_EQ((std::string)fs["map_value"]["str_false"], "false");
+ ASSERT_EQ((int)fs["bool_false"], 0);
+ fs.release();
+}
diff --git a/modules/core/test/test_ippasync.cpp b/modules/core/test/test_ippasync.cpp
index 5ba9f60..5069a81 100644
--- a/modules/core/test/test_ippasync.cpp
+++ b/modules/core/test/test_ippasync.cpp
@@ -110,17 +110,6 @@ PARAM_TEST_CASE(IPPAsyncShared, Channels, hppAccelType)
sts = hppQueryMatrixAllocParams(accel, (hpp32u)(matrix_Size.width*cn), (hpp32u)matrix_Size.height, HPP_DATA_TYPE_8U, &pitch, &size);
- if (pitch!=0 && size!=0)
- {
- uchar *pData = (uchar*)_aligned_malloc(size, 4096);
-
- for (int j=0; j<matrix_Size.height; j++)
- for(int i=0; i<matrix_Size.width*cn; i++)
- pData[i+j*pitch] = rand()%upValue;
-
- matrix = Mat(matrix_Size.height, matrix_Size.width, type, pData, pitch);
- }
-
matrix = randomMat(matrix_Size, type, 0, upValue);
}
diff --git a/modules/core/test/test_mat.cpp b/modules/core/test/test_mat.cpp
index 9a379f4..4145895 100644
--- a/modules/core/test/test_mat.cpp
+++ b/modules/core/test/test_mat.cpp
@@ -659,6 +659,18 @@ struct InitializerFunctor{
}
};
+template<typename Pixel>
+struct InitializerFunctor5D{
+ /// Initializer for cv::Mat::forEach test (5 dimensional case)
+ void operator()(Pixel & pixel, const int * idx) const {
+ pixel[0] = idx[0];
+ pixel[1] = idx[1];
+ pixel[2] = idx[2];
+ pixel[3] = idx[3];
+ pixel[4] = idx[4];
+ }
+};
+
void Core_ArrayOpTest::run( int /* start_from */)
{
int errcount = 0;
@@ -736,6 +748,57 @@ void Core_ArrayOpTest::run( int /* start_from */)
}
}
+ // test cv::Mat::forEach
+ // with a matrix that has more dimensions than columns
+ // See https://github.com/opencv/opencv/issues/8447
+ {
+ const int dims[5] = { 2, 2, 2, 2, 2 };
+ typedef cv::Vec<int, 5> Pixel;
+
+ cv::Mat a = cv::Mat::zeros(5, dims, CV_32SC(5));
+ InitializerFunctor5D<Pixel> initializer;
+
+ a.forEach<Pixel>(initializer);
+
+ uint64 total = 0;
+ bool error_reported = false;
+ for (int i0 = 0; i0 < dims[0]; ++i0) {
+ for (int i1 = 0; i1 < dims[1]; ++i1) {
+ for (int i2 = 0; i2 < dims[2]; ++i2) {
+ for (int i3 = 0; i3 < dims[3]; ++i3) {
+ for (int i4 = 0; i4 < dims[4]; ++i4) {
+ const int i[5] = { i0, i1, i2, i3, i4 };
+ Pixel& pixel = a.at<Pixel>(i);
+ if (pixel[0] != i0 || pixel[1] != i1 || pixel[2] != i2 || pixel[3] != i3 || pixel[4] != i4) {
+ if (!error_reported) {
+ ts->printf(cvtest::TS::LOG, "forEach is not correct.\n"
+ "First error detected at position (%d, %d, %d, %d, %d), got value (%d, %d, %d, %d, %d).\n",
+ i0, i1, i2, i3, i4,
+ pixel[0], pixel[1], pixel[2], pixel[3], pixel[4]);
+ error_reported = true;
+ }
+ errcount++;
+ }
+ total += pixel[0];
+ total += pixel[1];
+ total += pixel[2];
+ total += pixel[3];
+ total += pixel[4];
+ }
+ }
+ }
+ }
+ }
+ uint64 total2 = 0;
+ for (size_t i = 0; i < sizeof(dims) / sizeof(dims[0]); ++i) {
+ total2 += ((dims[i] - 1) * dims[i] / 2) * dims[0] * dims[1] * dims[2] * dims[3] * dims[4] / dims[i];
+ }
+ if (total != total2) {
+ ts->printf(cvtest::TS::LOG, "forEach is not correct because total is invalid.\n");
+ errcount++;
+ }
+ }
+
RNG rng;
const int MAX_DIM = 5, MAX_DIM_SZ = 10;
// sparse matrix operations
@@ -1335,6 +1398,15 @@ TEST(Core_Matx, fromMat_)
ASSERT_EQ( cvtest::norm(a, b, NORM_INF), 0.);
}
+#ifdef CV_CXX11
+TEST(Core_Matx, from_initializer_list)
+{
+ Mat_<double> a = (Mat_<double>(2,2) << 10, 11, 12, 13);
+ Matx22d b = {10, 11, 12, 13};
+ ASSERT_EQ( cvtest::norm(a, b, NORM_INF), 0.);
+}
+#endif
+
TEST(Core_InputArray, empty)
{
vector<vector<Point> > data;
@@ -1571,3 +1643,138 @@ TEST(Mat, regression_7873_mat_vector_initialize)
ASSERT_EQ(3, sub_mat.size[1]);
ASSERT_EQ(2, sub_mat.size[2]);
}
+
+#ifdef CV_CXX_STD_ARRAY
+TEST(Core_Mat_array, outputArray_create_getMat)
+{
+ cv::Mat_<uchar> src_base(5, 1);
+ std::array<uchar, 5> dst8;
+
+ src_base << 1, 2, 3, 4, 5;
+
+ Mat src(src_base);
+ OutputArray _dst(dst8);
+
+ {
+ _dst.create(src.rows, src.cols, src.type());
+ Mat dst = _dst.getMat();
+ EXPECT_EQ(src.dims, dst.dims);
+ EXPECT_EQ(src.cols, dst.cols);
+ EXPECT_EQ(src.rows, dst.rows);
+ }
+}
+
+TEST(Core_Mat_array, copyTo_roi_column)
+{
+ cv::Mat_<uchar> src_base(5, 2);
+
+ src_base << 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;
+
+ Mat src_full(src_base);
+ Mat src(src_full.col(0));
+
+ std::array<uchar, 5> dst1;
+ src.copyTo(dst1);
+ std::cout << "src = " << src << std::endl;
+ std::cout << "dst = " << Mat(dst1) << std::endl;
+ EXPECT_EQ((size_t)5, dst1.size());
+ EXPECT_EQ(1, (int)dst1[0]);
+ EXPECT_EQ(3, (int)dst1[1]);
+ EXPECT_EQ(5, (int)dst1[2]);
+ EXPECT_EQ(7, (int)dst1[3]);
+ EXPECT_EQ(9, (int)dst1[4]);
+}
+
+TEST(Core_Mat_array, copyTo_roi_row)
+{
+ cv::Mat_<uchar> src_base(2, 5);
+ std::array<uchar, 5> dst1;
+
+ src_base << 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;
+
+ Mat src_full(src_base);
+ Mat src(src_full.row(0));
+ OutputArray _dst(dst1);
+ {
+ _dst.create(5, 1, src.type());
+ Mat dst = _dst.getMat();
+ EXPECT_EQ(src.dims, dst.dims);
+ EXPECT_EQ(1, dst.cols);
+ EXPECT_EQ(5, dst.rows);
+ }
+
+ std::array<uchar, 5> dst2;
+ src.copyTo(dst2);
+ std::cout << "src = " << src << std::endl;
+ std::cout << "dst = " << Mat(dst2) << std::endl;
+ EXPECT_EQ(1, (int)dst2[0]);
+ EXPECT_EQ(2, (int)dst2[1]);
+ EXPECT_EQ(3, (int)dst2[2]);
+ EXPECT_EQ(4, (int)dst2[3]);
+ EXPECT_EQ(5, (int)dst2[4]);
+}
+
+TEST(Core_Mat_array, SplitMerge)
+{
+ std::array<cv::Mat, 3> src;
+ for(size_t i=0; i<src.size(); ++i) {
+ src[i].create(10, 10, CV_8U);
+ src[i] = 127 * i;
+ }
+
+ Mat merged;
+ merge(src, merged);
+
+ std::array<cv::Mat, 3> dst;
+ split(merged, dst);
+
+ Mat diff;
+ for(size_t i=0; i<dst.size(); ++i) {
+ absdiff(src[i], dst[i], diff);
+ EXPECT_EQ(0, countNonZero(diff));
+ }
+}
+#endif
+
+TEST(Mat, regression_8680)
+{
+ Mat_<Point2i> mat(3,1);
+ ASSERT_EQ(mat.channels(), 2);
+ mat.release();
+ ASSERT_EQ(mat.channels(), 2);
+}
+
+#ifdef CV_CXX11
+
+TEST(Mat_, range_based_for)
+{
+ Mat_<uchar> img = Mat_<uchar>::zeros(3, 3);
+
+ for(auto& pixel : img)
+ {
+ pixel = 1;
+ }
+
+ Mat_<uchar> ref(3, 3);
+ ref.setTo(Scalar(1));
+ ASSERT_DOUBLE_EQ(norm(img, ref), 0.);
+}
+
+TEST(Mat, from_initializer_list)
+{
+ Mat A({1.f, 2.f, 3.f});
+ Mat_<float> B(3, 1); B << 1, 2, 3;
+
+ ASSERT_EQ(A.type(), CV_32F);
+ ASSERT_DOUBLE_EQ(norm(A, B, NORM_INF), 0.);
+}
+
+TEST(Mat_, from_initializer_list)
+{
+ Mat_<float> A = {1, 2, 3};
+ Mat_<float> B(3, 1); B << 1, 2, 3;
+
+ ASSERT_DOUBLE_EQ(norm(A, B, NORM_INF), 0.);
+}
+
+#endif
diff --git a/modules/core/test/test_math.cpp b/modules/core/test/test_math.cpp
index 3870d31..3bb4201 100644
--- a/modules/core/test/test_math.cpp
+++ b/modules/core/test/test_math.cpp
@@ -5,6 +5,7 @@
#include "test_precomp.hpp"
#include <float.h>
#include <math.h>
+#include "opencv2/core/softfloat.hpp"
using namespace cv;
using namespace std;
@@ -2748,21 +2749,23 @@ public:
protected:
void run(int inVariant)
{
+ RNG& rng = ts->get_rng();
int i, iter = 0, N = 0, N0 = 0, K = 0, dims = 0;
Mat labels;
- try
+
{
- RNG& rng = theRNG();
const int MAX_DIM=5;
int MAX_POINTS = 100, maxIter = 100;
for( iter = 0; iter < maxIter; iter++ )
{
ts->update_context(this, iter, true);
dims = rng.uniform(inVariant == MAT_1_N_CDIM ? 2 : 1, MAX_DIM+1);
- N = rng.uniform(1, MAX_POINTS+1);
+ N = rng.uniform(2, MAX_POINTS+1);
N0 = rng.uniform(1, MAX(N/10, 2));
K = rng.uniform(1, N+1);
+ Mat centers;
+
if (inVariant == VECTOR)
{
dims = 2;
@@ -2775,7 +2778,7 @@ protected:
data[i] = data0[rng.uniform(0, N0)];
kmeans(data, K, labels, TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 30, 0),
- 5, KMEANS_PP_CENTERS);
+ 5, KMEANS_PP_CENTERS, centers);
}
else
{
@@ -2820,28 +2823,24 @@ protected:
}
kmeans(data, K, labels, TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS, 30, 0),
- 5, KMEANS_PP_CENTERS);
+ 5, KMEANS_PP_CENTERS, centers);
}
+ ASSERT_EQ(centers.rows, K);
+ ASSERT_EQ(labels.rows, N);
+
Mat hist(K, 1, CV_32S, Scalar(0));
for( i = 0; i < N; i++ )
{
int l = labels.at<int>(i);
- CV_Assert(0 <= l && l < K);
+ ASSERT_GE(l, 0);
+ ASSERT_LT(l, K);
hist.at<int>(l)++;
}
for( i = 0; i < K; i++ )
- CV_Assert( hist.at<int>(i) != 0 );
+ ASSERT_GT(hist.at<int>(i), 0);
}
}
- catch(...)
- {
- ts->printf(cvtest::TS::LOG,
- "context: iteration=%d, N=%d, N0=%d, K=%d\n",
- iter, N, N0, K);
- std::cout << labels << std::endl;
- ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH);
- }
}
};
@@ -2859,6 +2858,35 @@ TEST_P(Core_KMeans_InputVariants, singular)
INSTANTIATE_TEST_CASE_P(AllVariants, Core_KMeans_InputVariants, KMeansInputVariant::all());
+TEST(Core_KMeans, compactness)
+{
+ const int N = 1024;
+ const int attempts = 4;
+ const TermCriteria crit = TermCriteria(TermCriteria::COUNT, 5, 0); // low number of iterations
+ cvtest::TS& ts = *cvtest::TS::ptr();
+ for (int K = 1; K <= N; K *= 2)
+ {
+ Mat data(N, 1, CV_32FC2);
+ cvtest::randUni(ts.get_rng(), data, Scalar(-200, -200), Scalar(200, 200));
+ Mat labels, centers;
+ double compactness = kmeans(data, K, labels, crit, attempts, KMEANS_PP_CENTERS, centers);
+ centers = centers.reshape(2);
+ EXPECT_EQ(labels.rows, N);
+ EXPECT_EQ(centers.rows, K);
+ EXPECT_GE(compactness, 0.0);
+ double expected = 0.0;
+ for (int i = 0; i < N; ++i)
+ {
+ int l = labels.at<int>(i);
+ Point2f d = data.at<Point2f>(i) - centers.at<Point2f>(l);
+ expected += d.x * d.x + d.y * d.y;
+ }
+ EXPECT_NEAR(expected, compactness, expected * 1e-8);
+ if (K == N)
+ EXPECT_DOUBLE_EQ(compactness, 0.0);
+ }
+}
+
TEST(CovariationMatrixVectorOfMat, accuracy)
{
unsigned int col_problem_size = 8, row_problem_size = 8, vector_size = 16;
@@ -3041,4 +3069,523 @@ TEST(Core_QR_Solver, accuracy64f)
ASSERT_FALSE(solve(A, B, solutionQR, DECOMP_QR));
}
+softdouble naiveExp(softdouble x)
+{
+ int exponent = ((x.v >>52) & 0x7FF) - 1023;
+ int sign = (((uint64_t)(x.v) >> 63) != 0) ? -1 : 1;
+ if(sign < 0 && exponent >= 10) return softdouble::inf();
+ softdouble mantissa;
+ //mantissa.v = packToF64UI(0, 1023, fracF64UI(x.v));
+ mantissa.v = ((uint64_t)(1023)<<52) + (((x.v) & UINT64_C( 0x000FFFFFFFFFFFFF )));
+ //Taylor series for mantissa
+ uint64 fac[20] = {1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800,
+ 39916800, 479001600, 6227020800, 87178291200, 1307674368000,
+ 20922789888000, 355687428096000, 6402373705728000, 121645100408832000,
+ 2432902008176640000};
+ softdouble sum = softdouble::one();
+ // 21! > (2 ** 64)
+ for(int i = 20; i > 0; i--)
+ sum += pow(mantissa, softdouble(i))/softdouble(fac[i-1]);
+ if(exponent >= 0)
+ {
+ exponent = (1 << exponent);
+ return pow(sum, softdouble(exponent*sign));
+ }
+ else
+ {
+ if(sign < 0) sum = softdouble::one()/sum;
+ exponent = -exponent;
+ for(int j = 0; j < exponent; j++)
+ sum = sqrt(sum);
+ return sum;
+ }
+}
+
+TEST(Core_SoftFloat, exp32)
+{
+ //special cases
+ ASSERT_TRUE(exp( softfloat::nan()).isNaN());
+ ASSERT_TRUE(exp( softfloat::inf()).isInf());
+ ASSERT_EQ (exp(-softfloat::inf()), softfloat::zero());
+
+ //ln(FLT_MAX) ~ 88.722
+ const float ln_max = 88.722f;
+ vector<float> inputs;
+ RNG rng(0);
+ inputs.push_back(0);
+ inputs.push_back(1);
+ inputs.push_back(FLT_MIN);
+ for(int i = 0; i < 50000; i++)
+ {
+ Cv32suf x;
+ x.fmt.sign = rng() % 2;
+ x.fmt.exponent = rng() % (10 + 127); //bigger exponent will produce inf
+ x.fmt.significand = rng() % (1 << 23);
+ if(x.f > ln_max)
+ x.f = rng.uniform(0.0f, ln_max);
+ inputs.push_back(x.f);
+ }
+
+ for(size_t i = 0; i < inputs.size(); i++)
+ {
+ float xf = inputs[i];
+ softfloat x(xf);
+ softfloat y = exp(x);
+ ASSERT_TRUE(!y.isNaN());
+ ASSERT_TRUE(!y.isInf());
+ ASSERT_GE(y, softfloat::zero());
+ softfloat ygood = naiveExp(x);
+ softfloat diff = abs(ygood - y);
+ const softfloat eps(FLT_EPSILON);
+ if(diff > eps)
+ {
+ ASSERT_LE(diff/max(abs(y), abs(ygood)), eps);
+ }
+ }
+}
+
+TEST(Core_SoftFloat, exp64)
+{
+ //special cases
+ ASSERT_TRUE(exp( softdouble::nan()).isNaN());
+ ASSERT_TRUE(exp( softdouble::inf()).isInf());
+ ASSERT_EQ (exp(-softdouble::inf()), softdouble::zero());
+
+ //ln(DBL_MAX) ~ 709.7827
+ const double ln_max = 709.7827;
+ vector<double> inputs;
+ RNG rng(0);
+ inputs.push_back(0);
+ inputs.push_back(1);
+ inputs.push_back(DBL_MIN);
+ for(int i = 0; i < 50000; i++)
+ {
+ Cv64suf x;
+ uint64 sign = rng() % 2;
+ uint64 exponent = rng() % (10 + 1023); //bigger exponent will produce inf
+ uint64 mantissa = (((long long int)((unsigned int)(rng)) << 32 ) | (unsigned int)(rng)) & ((1LL << 52) - 1);
+ x.u = (sign << 63) | (exponent << 52) | mantissa;
+ if(x.f > ln_max)
+ x.f = rng.uniform(0.0, ln_max);
+ inputs.push_back(x.f);
+ }
+
+ for(size_t i = 0; i < inputs.size(); i++)
+ {
+ double xf = inputs[i];
+ softdouble x(xf);
+ softdouble y = exp(x);
+ ASSERT_TRUE(!y.isNaN());
+ ASSERT_TRUE(!y.isInf());
+ ASSERT_GE(y, softdouble::zero());
+ softdouble ygood = naiveExp(x);
+ softdouble diff = abs(ygood - y);
+ const softdouble eps(DBL_EPSILON);
+ if(diff > eps)
+ {
+ ASSERT_LE(diff/max(abs(y), abs(ygood)), softdouble(8192)*eps);
+ }
+ }
+}
+
+TEST(Core_SoftFloat, log32)
+{
+ const int nValues = 50000;
+ RNG rng(0);
+ //special cases
+ ASSERT_TRUE(log(softfloat::nan()).isNaN());
+ for(int i = 0; i < nValues; i++)
+ {
+ Cv32suf x;
+ x.fmt.sign = 1;
+ x.fmt.exponent = rng() % 255;
+ x.fmt.significand = rng() % (1 << 23);
+ softfloat x32(x.f);
+ ASSERT_TRUE(log(x32).isNaN());
+ }
+ ASSERT_TRUE(log(softfloat::zero()).isInf());
+
+ vector<float> inputs;
+
+ inputs.push_back(1);
+ inputs.push_back(std::exp(1.f));
+ inputs.push_back(FLT_MIN);
+ inputs.push_back(FLT_MAX);
+ for(int i = 0; i < nValues; i++)
+ {
+ Cv32suf x;
+ x.fmt.sign = 0;
+ x.fmt.exponent = rng() % 255;
+ x.fmt.significand = rng() % (1 << 23);
+ inputs.push_back(x.f);
+ }
+
+ for(size_t i = 0; i < inputs.size(); i++)
+ {
+ float xf = inputs[i];
+ softfloat x(xf);
+ softfloat y = log(x);
+ ASSERT_TRUE(!y.isNaN());
+ ASSERT_TRUE(!y.isInf());
+ softfloat ex = exp(y);
+ softfloat diff = abs(ex - x);
+ // 88 is approx estimate of max exp() argument
+ ASSERT_TRUE(!ex.isInf() || (y > softfloat(88)));
+ if(!ex.isInf() && diff > softfloat(FLT_EPSILON))
+ {
+ ASSERT_LT(diff/max(abs(ex), x), softfloat(0.00001f));
+ }
+ }
+}
+
+TEST(Core_SoftFloat, log64)
+{
+ const int nValues = 50000;
+ RNG rng(0);
+ //special cases
+ ASSERT_TRUE(log(softdouble::nan()).isNaN());
+ for(int i = 0; i < nValues; i++)
+ {
+ Cv64suf x;
+ uint64 sign = 1;
+ uint64 exponent = rng() % 2047;
+ uint64 mantissa = (((long long int)((unsigned int)(rng)) << 32 ) | (unsigned int)(rng)) & ((1LL << 52) - 1);
+ x.u = (sign << 63) | (exponent << 52) | mantissa;
+ softdouble x64(x.f);
+ ASSERT_TRUE(log(x64).isNaN());
+ }
+ ASSERT_TRUE(log(softdouble::zero()).isInf());
+
+ vector<double> inputs;
+ inputs.push_back(1);
+ inputs.push_back(exp(softdouble::one()));
+ inputs.push_back(DBL_MIN);
+ inputs.push_back(DBL_MAX);
+ for(int i = 0; i < nValues; i++)
+ {
+ Cv64suf x;
+ uint64 sign = 0;
+ uint64 exponent = rng() % 2047;
+ uint64 mantissa = (((long long int)((unsigned int)(rng)) << 32 ) | (unsigned int)(rng)) & ((1LL << 52) - 1);
+ x.u = (sign << 63) | (exponent << 52) | mantissa;
+ inputs.push_back(abs(x.f));
+ }
+
+ for(size_t i = 0; i < inputs.size(); i++)
+ {
+ double xf = inputs[i];
+ softdouble x(xf);
+ softdouble y = log(x);
+ ASSERT_TRUE(!y.isNaN());
+ ASSERT_TRUE(!y.isInf());
+ softdouble ex = exp(y);
+ softdouble diff = abs(ex - x);
+ // 700 is approx estimate of max exp() argument
+ ASSERT_TRUE(!ex.isInf() || (y > softdouble(700)));
+ if(!ex.isInf() && diff > softdouble(DBL_EPSILON))
+ {
+ ASSERT_LT(diff/max(abs(ex), x), softdouble(1e-10));
+ }
+ }
+}
+
+TEST(Core_SoftFloat, cbrt32)
+{
+ vector<float> inputs;
+ RNG rng(0);
+ inputs.push_back(0);
+ inputs.push_back(1);
+ inputs.push_back(FLT_MAX);
+ inputs.push_back(FLT_MIN);
+ for(int i = 0; i < 50000; i++)
+ {
+ Cv32suf x;
+ x.fmt.sign = rng() % 2;
+ x.fmt.exponent = rng() % 255;
+ x.fmt.significand = rng() % (1 << 23);
+ inputs.push_back(x.f);
+ }
+
+ for(size_t i = 0; i < inputs.size(); i++)
+ {
+ float xf = inputs[i];
+ softfloat x(xf);
+ softfloat y = cbrt(x);
+ ASSERT_TRUE(!y.isNaN());
+ ASSERT_TRUE(!y.isInf());
+ softfloat cube = y*y*y;
+ softfloat diff = abs(x - cube);
+ const softfloat eps(FLT_EPSILON);
+ if(diff > eps)
+ {
+ ASSERT_LT(diff/max(abs(x), abs(cube)), softfloat(4)*eps);
+ }
+ }
+}
+
+TEST(Core_SoftFloat, pow32)
+{
+ const softfloat zero = softfloat::zero(), one = softfloat::one();
+ const softfloat inf = softfloat::inf(), nan = softfloat::nan();
+ const size_t nValues = 5000;
+ RNG rng(0);
+ //x ** nan == nan
+ for(size_t i = 0; i < nValues; i++)
+ {
+ Cv32suf x;
+ x.u = rng();
+ ASSERT_TRUE(pow(softfloat(x.f), nan).isNaN());
+ }
+ //x ** inf check
+ for(size_t i = 0; i < nValues; i++)
+ {
+ Cv32suf x;
+ x.u = rng();
+ softfloat x32(x.f);
+ softfloat ax = abs(x32);
+ if(x32.isNaN())
+ {
+ ASSERT_TRUE(pow(x32, inf).isNaN());
+ }
+ if(ax > one)
+ {
+ ASSERT_TRUE(pow(x32, inf).isInf());
+ ASSERT_EQ (pow(x32, -inf), zero);
+ }
+ if(ax < one && ax > zero)
+ {
+ ASSERT_TRUE(pow(x32, -inf).isInf());
+ ASSERT_EQ (pow(x32, inf), zero);
+ }
+ }
+ //+-1 ** inf
+ ASSERT_TRUE(pow( one, inf).isNaN());
+ ASSERT_TRUE(pow(-one, inf).isNaN());
+
+ // x ** 0 == 1
+ for(size_t i = 0; i < nValues; i++)
+ {
+ Cv32suf x;
+ x.u = rng();
+ ASSERT_EQ(pow(softfloat(x.f), zero), one);
+ }
+
+ // x ** 1 == x
+ for(size_t i = 0; i < nValues; i++)
+ {
+ Cv32suf x;
+ x.u = rng();
+ softfloat x32(x.f);
+ softfloat val = pow(x32, one);
+ // don't compare val and x32 directly because x != x if x is nan
+ ASSERT_EQ(val.v, x32.v);
+ }
+
+ // nan ** y == nan, if y != 0
+ for(size_t i = 0; i < nValues; i++)
+ {
+ Cv32suf x;
+ x.u = rng();
+ if(!x.u) x.f = FLT_MIN;
+ softfloat x32(x.f);
+ ASSERT_TRUE(pow(nan, x32).isNaN());
+ }
+ // nan ** 0 == 1
+ ASSERT_EQ(pow(nan, zero), one);
+
+ // inf ** y == 0, if y < 0
+ // inf ** y == inf, if y > 0
+ for(size_t i = 0; i < nValues; i++)
+ {
+ Cv32suf x;
+ x.fmt.sign = 0;
+ x.fmt.exponent = rng() % 255;
+ x.fmt.significand = rng() % (1 << 23);
+ softfloat x32 = softfloat(x.f);
+ ASSERT_TRUE(pow( inf, x32).isInf());
+ ASSERT_TRUE(pow(-inf, x32).isInf());
+ ASSERT_EQ(pow( inf, -x32), zero);
+ ASSERT_EQ(pow(-inf, -x32), zero);
+ }
+
+ // x ** y == (-x) ** y, if y % 2 == 0
+ // x ** y == - (-x) ** y, if y % 2 == 1
+ // x ** y == nan, if x < 0 and y is not integer
+ for(size_t i = 0; i < nValues; i++)
+ {
+ Cv32suf x;
+ x.fmt.sign = 1;
+ x.fmt.exponent = rng() % 255;
+ x.fmt.significand = rng() % (1 << 23);
+ softfloat x32(x.f);
+ Cv32suf y;
+ y.fmt.sign = rng() % 2;
+ //bigger exponent produces integer numbers only
+ y.fmt.exponent = rng() % (23 + 127);
+ y.fmt.significand = rng() % (1 << 23);
+ softfloat y32(y.f);
+ int yi = cvRound(y32);
+ if(y32 != softfloat(yi))
+ ASSERT_TRUE(pow(x32, y32).isNaN());
+ else if(yi % 2)
+ ASSERT_EQ(pow(-x32, y32), -pow(x32, y32));
+ else
+ ASSERT_EQ(pow(-x32, y32), pow(x32, y32));
+ }
+
+ // (0 ** 0) == 1
+ ASSERT_EQ(pow(zero, zero), one);
+
+ // 0 ** y == inf, if y < 0
+ // 0 ** y == 0, if y > 0
+ for(size_t i = 0; i < nValues; i++)
+ {
+ Cv32suf x;
+ x.fmt.sign = 0;
+ x.fmt.exponent = rng() % 255;
+ x.fmt.significand = rng() % (1 << 23);
+ softfloat x32(x.f);
+ ASSERT_TRUE(pow(zero, -x32).isInf());
+ if(x32 != one)
+ ASSERT_EQ(pow(zero, x32), zero);
+ }
+}
+
+TEST(Core_SoftFloat, pow64)
+{
+ const softdouble zero = softdouble::zero(), one = softdouble::one();
+ const softdouble inf = softdouble::inf(), nan = softdouble::nan();
+
+ const size_t nValues = 5000;
+ RNG rng(0);
+
+ //x ** nan == nan
+ for(size_t i = 0; i < nValues; i++)
+ {
+ Cv64suf x;
+ x.u = ((long long int)((unsigned int)(rng)) << 32 ) | (unsigned int)(rng);
+ ASSERT_TRUE(pow(softdouble(x.f), nan).isNaN());
+ }
+ //x ** inf check
+ for(size_t i = 0; i < nValues; i++)
+ {
+ Cv64suf x;
+ x.u = ((long long int)((unsigned int)(rng)) << 32 ) | (unsigned int)(rng);
+ softdouble x64(x.f);
+ softdouble ax = abs(x64);
+ if(x64.isNaN())
+ {
+ ASSERT_TRUE(pow(x64, inf).isNaN());
+ }
+ if(ax > one)
+ {
+ ASSERT_TRUE(pow(x64, inf).isInf());
+ ASSERT_EQ(pow(x64, -inf), zero);
+ }
+ if(ax < one && ax > zero)
+ {
+ ASSERT_TRUE(pow(x64, -inf).isInf());
+ ASSERT_EQ(pow(x64, inf), zero);
+ }
+ }
+ //+-1 ** inf
+ ASSERT_TRUE(pow( one, inf).isNaN());
+ ASSERT_TRUE(pow(-one, inf).isNaN());
+
+ // x ** 0 == 1
+ for(size_t i = 0; i < nValues; i++)
+ {
+ Cv64suf x;
+ x.u = ((long long int)((unsigned int)(rng)) << 32 ) | (unsigned int)(rng);
+ ASSERT_EQ(pow(softdouble(x.f), zero), one);
+ }
+
+ // x ** 1 == x
+ for(size_t i = 0; i < nValues; i++)
+ {
+ Cv64suf x;
+ x.u = ((long long int)((unsigned int)(rng)) << 32 ) | (unsigned int)(rng);
+ softdouble x64(x.f);
+ softdouble val = pow(x64, one);
+ // don't compare val and x64 directly because x != x if x is nan
+ ASSERT_EQ(val.v, x64.v);
+ }
+
+ // nan ** y == nan, if y != 0
+ for(size_t i = 0; i < nValues; i++)
+ {
+ Cv64suf x;
+ x.u = ((long long int)((unsigned int)(rng)) << 32 ) | (unsigned int)(rng);
+ if(!x.u) x.f = DBL_MIN;
+ softdouble x64(x.f);
+ ASSERT_TRUE(pow(nan, x64).isNaN());
+ }
+ // nan ** 0 == 1
+ ASSERT_EQ(pow(nan, zero), one);
+
+ // inf ** y == 0, if y < 0
+ // inf ** y == inf, if y > 0
+ for(size_t i = 0; i < nValues; i++)
+ {
+ Cv64suf x;
+ uint64 sign = 0;
+ uint64 exponent = rng() % 2047;
+ uint64 mantissa = (((long long int)((unsigned int)(rng)) << 32 ) | (unsigned int)(rng)) & ((1LL << 52) - 1);
+ x.u = (sign << 63) | (exponent << 52) | mantissa;
+ softdouble x64(x.f);
+ ASSERT_TRUE(pow( inf, x64).isInf());
+ ASSERT_TRUE(pow(-inf, x64).isInf());
+ ASSERT_EQ(pow( inf, -x64), zero);
+ ASSERT_EQ(pow(-inf, -x64), zero);
+ }
+
+ // x ** y == (-x) ** y, if y % 2 == 0
+ // x ** y == - (-x) ** y, if y % 2 == 1
+ // x ** y == nan, if x < 0 and y is not integer
+ for(size_t i = 0; i < nValues; i++)
+ {
+ Cv64suf x;
+ uint64 sign = 1;
+ uint64 exponent = rng() % 2047;
+ uint64 mantissa = (((long long int)((unsigned int)(rng)) << 32 ) | (unsigned int)(rng)) & ((1LL << 52) - 1);
+ x.u = (sign << 63) | (exponent << 52) | mantissa;
+ softdouble x64(x.f);
+ Cv64suf y;
+ sign = rng() % 2;
+ //bigger exponent produces integer numbers only
+ //exponent = rng() % (52 + 1023);
+ //bigger exponent is too big
+ exponent = rng() % (23 + 1023);
+ mantissa = (((long long int)((unsigned int)(rng)) << 32 ) | (unsigned int)(rng)) & ((1LL << 52) - 1);
+ y.u = (sign << 63) | (exponent << 52) | mantissa;
+ softdouble y64(y.f);
+ uint64 yi = cvRound(y64);
+ if(y64 != softdouble(yi))
+ ASSERT_TRUE(pow(x64, y64).isNaN());
+ else if(yi % 2)
+ ASSERT_EQ(pow(-x64, y64), -pow(x64, y64));
+ else
+ ASSERT_EQ(pow(-x64, y64), pow(x64, y64));
+ }
+
+ // (0 ** 0) == 1
+ ASSERT_EQ(pow(zero, zero), one);
+
+ // 0 ** y == inf, if y < 0
+ // 0 ** y == 0, if y > 0
+ for(size_t i = 0; i < nValues; i++)
+ {
+ Cv64suf x;
+ uint64 sign = 0;
+ uint64 exponent = rng() % 2047;
+ uint64 mantissa = (((long long int)((unsigned int)(rng)) << 32 ) | (unsigned int)(rng)) & ((1LL << 52) - 1);
+ x.u = (sign << 63) | (exponent << 52) | mantissa;
+ softdouble x64(x.f);
+
+ ASSERT_TRUE(pow(zero, -x64).isInf());
+ if(x64 != one)
+ ASSERT_EQ(pow(zero, x64), zero);
+ }
+}
+
/* End of file. */
diff --git a/modules/core/test/test_misc.cpp b/modules/core/test/test_misc.cpp
index 9e69ffb..edbd184 100644
--- a/modules/core/test/test_misc.cpp
+++ b/modules/core/test/test_misc.cpp
@@ -138,3 +138,19 @@ TEST(Core_String, find_last_of__with__empty_string)
// npos is not exported: EXPECT_EQ(cv::String::npos, p);
EXPECT_EQ(std::string::npos, p);
}
+
+TEST(Core_String, end_method_regression)
+{
+ cv::String old_string = "012345";
+ cv::String new_string(old_string.begin(), old_string.end());
+ EXPECT_EQ(6u, new_string.size());
+}
+
+TEST(Core_Copy, repeat_regression_8972)
+{
+ Mat src = (Mat_<int>(1, 4) << 1, 2, 3, 4);
+
+ ASSERT_ANY_THROW({
+ repeat(src, 5, 1, src);
+ });
+}
diff --git a/modules/core/test/test_operations.cpp b/modules/core/test/test_operations.cpp
index 543fb31..aea5d5d 100644
--- a/modules/core/test/test_operations.cpp
+++ b/modules/core/test/test_operations.cpp
@@ -41,17 +41,10 @@
//M*/
#include "test_precomp.hpp"
+#include "opencv2/ts/ocl_test.hpp" // T-API like tests
-#include <string>
-#include <iostream>
-#include <fstream>
-#include <iterator>
-#include <limits>
-#include <numeric>
-
-using namespace cv;
-using namespace std;
-
+namespace cvtest {
+namespace {
class CV_OperationsTest : public cvtest::BaseTest
{
@@ -1120,8 +1113,8 @@ void CV_OperationsTest::run( int /* start_from */)
if (!TestTemplateMat())
return;
- /* if (!TestMatND())
- return;*/
+ if (!TestMatND())
+ return;
if (!TestSparseMat())
return;
@@ -1240,3 +1233,159 @@ protected:
};
TEST(Core_SparseMat, iterations) { CV_SparseMatTest test; test.safe_run(); }
+
+TEST(MatTestRoi, adjustRoiOverflow)
+{
+ Mat m(15, 10, CV_32S);
+ Mat roi(m, cv::Range(2, 10), cv::Range(3,6));
+ int rowsInROI = roi.rows;
+ roi.adjustROI(1, 0, 0, 0);
+
+ ASSERT_EQ(roi.rows, rowsInROI + 1);
+
+ roi.adjustROI(-m.rows, -m.rows, 0, 0);
+
+ ASSERT_EQ(roi.rows, m.rows);
+}
+
+
+CV_ENUM(SortRowCol, SORT_EVERY_COLUMN, SORT_EVERY_ROW)
+CV_ENUM(SortOrder, SORT_ASCENDING, SORT_DESCENDING)
+
+PARAM_TEST_CASE(sortIdx, MatDepth, SortRowCol, SortOrder, Size, bool)
+{
+ int type;
+ Size size;
+ int flags;
+ bool use_roi;
+
+ Mat src, src_roi;
+ Mat dst, dst_roi;
+
+ virtual void SetUp()
+ {
+ int depth = GET_PARAM(0);
+ int rowFlags = GET_PARAM(1);
+ int orderFlags = GET_PARAM(2);
+ size = GET_PARAM(3);
+ use_roi = GET_PARAM(4);
+
+ type = CV_MAKE_TYPE(depth, 1);
+
+ flags = rowFlags | orderFlags;
+ }
+
+ void generateTestData()
+ {
+ Border srcBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
+ randomSubMat(src, src_roi, size, srcBorder, type, -100, 100);
+
+ Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
+ randomSubMat(dst, dst_roi, size, dstBorder, CV_32S, 5, 16);
+ }
+
+ template<typename T>
+ void check_(const cv::Mat& values_, const cv::Mat_<int>& idx_)
+ {
+ cv::Mat_<T>& values = (cv::Mat_<T>&)values_;
+ cv::Mat_<int>& idx = (cv::Mat_<int>&)idx_;
+ size_t N = values.total();
+ std::vector<bool> processed(N, false);
+ int prevIdx = idx(0);
+ T prevValue = values(prevIdx);
+ processed[prevIdx] = true;
+ for (size_t i = 1; i < N; i++)
+ {
+ int nextIdx = idx((int)i);
+ T value = values(nextIdx);
+ ASSERT_EQ(false, processed[nextIdx]) << "Indexes must be unique. i=" << i << " idx=" << nextIdx << std::endl << idx;
+ processed[nextIdx] = true;
+ if ((flags & SORT_DESCENDING) == SORT_DESCENDING)
+ ASSERT_GE(prevValue, value) << "i=" << i << " prevIdx=" << prevIdx << " idx=" << nextIdx;
+ else
+ ASSERT_LE(prevValue, value) << "i=" << i << " prevIdx=" << prevIdx << " idx=" << nextIdx;
+ prevValue = value;
+ prevIdx = nextIdx;
+ }
+ }
+
+ void validate()
+ {
+ ASSERT_EQ(CV_32SC1, dst_roi.type());
+ ASSERT_EQ(size, dst_roi.size());
+ bool isColumn = (flags & SORT_EVERY_COLUMN) == SORT_EVERY_COLUMN;
+ size_t N = isColumn ? src_roi.cols : src_roi.rows;
+ Mat values_row((int)N, 1, type), idx_row((int)N, 1, CV_32S);
+ for (size_t i = 0; i < N; i++)
+ {
+ SCOPED_TRACE(cv::format("row/col=%d", (int)i));
+ if (isColumn)
+ {
+ src_roi.col((int)i).copyTo(values_row);
+ dst_roi.col((int)i).copyTo(idx_row);
+ }
+ else
+ {
+ src_roi.row((int)i).copyTo(values_row);
+ dst_roi.row((int)i).copyTo(idx_row);
+ }
+ switch(type)
+ {
+ case CV_8U: check_<uchar>(values_row, idx_row); break;
+ case CV_8S: check_<char>(values_row, idx_row); break;
+ case CV_16S: check_<short>(values_row, idx_row); break;
+ case CV_32S: check_<int>(values_row, idx_row); break;
+ case CV_32F: check_<float>(values_row, idx_row); break;
+ case CV_64F: check_<double>(values_row, idx_row); break;
+ default: ASSERT_FALSE(true) << "Unsupported type: " << type;
+ }
+ }
+ }
+};
+
+TEST_P(sortIdx, simple)
+{
+ for (int j = 0; j < 5; j++)
+ {
+ generateTestData();
+
+ cv::sortIdx(src_roi, dst_roi, flags);
+ validate();
+ }
+}
+
+INSTANTIATE_TEST_CASE_P(Core, sortIdx, Combine(
+ Values(CV_8U, CV_8S, CV_16S, CV_32S, CV_32F, CV_64F), // depth
+ Values(SORT_EVERY_COLUMN, SORT_EVERY_ROW),
+ Values(SORT_ASCENDING, SORT_DESCENDING),
+ Values(Size(3, 3), Size(16, 8)),
+ ::testing::Bool()
+));
+
+
+TEST(Core_sortIdx, regression_8941)
+{
+ cv::Mat src = (cv::Mat_<int>(3, 3) <<
+ 1, 2, 3,
+ 0, 9, 5,
+ 8, 1, 6
+ );
+ cv::Mat expected = (cv::Mat_<int>(3, 1) <<
+ 1,
+ 0,
+ 2
+ );
+
+ cv::Mat result;
+ cv::sortIdx(src.col(0), result, CV_SORT_EVERY_COLUMN | CV_SORT_ASCENDING);
+#if 0
+ std::cout << src.col(0) << std::endl;
+ std::cout << result << std::endl;
+#endif
+ ASSERT_EQ(expected.size(), result.size());
+ EXPECT_EQ(0, cvtest::norm(expected, result, NORM_INF)) <<
+ "result=" << std::endl << result << std::endl <<
+ "expected=" << std::endl << expected;
+}
+
+}} // namespace
diff --git a/modules/core/test/test_rand.cpp b/modules/core/test/test_rand.cpp
index 63b9094..b687a8f 100644
--- a/modules/core/test/test_rand.cpp
+++ b/modules/core/test/test_rand.cpp
@@ -382,3 +382,39 @@ TEST(Core_Rand, Regression_Stack_Corruption)
ASSERT_EQ(param1, -9);
ASSERT_EQ(param2, 2);
}
+
+namespace {
+
+class RandRowFillParallelLoopBody : public cv::ParallelLoopBody
+{
+public:
+ RandRowFillParallelLoopBody(Mat& dst) : dst_(dst) {}
+ ~RandRowFillParallelLoopBody() {}
+ void operator()(const cv::Range& r) const
+ {
+ cv::RNG rng = cv::theRNG(); // copy state
+ for (int y = r.start; y < r.end; y++)
+ {
+ cv::theRNG() = cv::RNG(rng.state + y); // seed is based on processed row
+ cv::randu(dst_.row(y), Scalar(-100), Scalar(100));
+ }
+ // theRNG() state is changed here (but state collision has low probability, so we don't check this)
+ }
+protected:
+ Mat& dst_;
+};
+
+TEST(Core_Rand, parallel_for_stable_results)
+{
+ cv::RNG rng = cv::theRNG(); // save rng state
+ Mat dst1(1000, 100, CV_8SC1);
+ parallel_for_(cv::Range(0, dst1.rows), RandRowFillParallelLoopBody(dst1));
+
+ cv::theRNG() = rng; // restore rng state
+ Mat dst2(1000, 100, CV_8SC1);
+ parallel_for_(cv::Range(0, dst2.rows), RandRowFillParallelLoopBody(dst2));
+
+ ASSERT_EQ(0, countNonZero(dst1 != dst2));
+}
+
+} // namespace
diff --git a/modules/core/test/test_umat.cpp b/modules/core/test/test_umat.cpp
index 9e9835f..d7a3e6d 100644
--- a/modules/core/test/test_umat.cpp
+++ b/modules/core/test/test_umat.cpp
@@ -496,6 +496,20 @@ TEST_P(UMatTestRoi, adjustRoi)
INSTANTIATE_TEST_CASE_P(UMat, UMatTestRoi, Combine(OCL_ALL_DEPTHS, OCL_ALL_CHANNELS, UMAT_TEST_SIZES ));
+TEST(UMatTestRoi, adjustRoiOverflow)
+{
+ UMat m(15, 10, CV_32S);
+ UMat roi(m, cv::Range(2, 10), cv::Range(3,6));
+ int rowsInROI = roi.rows;
+ roi.adjustROI(1, 0, 0, 0);
+
+ ASSERT_EQ(roi.rows, rowsInROI + 1);
+
+ roi.adjustROI(-m.rows, -m.rows, 0, 0);
+
+ ASSERT_EQ(roi.rows, m.rows);
+}
+
/////////////////////////////////////////////////////////////// Size ////////////////////////////////////////////////////////////////////
PARAM_TEST_CASE(UMatTestSizeOperations, int, int, Size, bool)
diff --git a/modules/cudaarithm/include/opencv2/cudaarithm.hpp b/modules/cudaarithm/include/opencv2/cudaarithm.hpp
index f2ee845..a482b49 100644
--- a/modules/cudaarithm/include/opencv2/cudaarithm.hpp
+++ b/modules/cudaarithm/include/opencv2/cudaarithm.hpp
@@ -788,6 +788,7 @@ CV_EXPORTS void mulAndScaleSpectrums(InputArray src1, InputArray src2, OutputArr
(obtained from dft_size ).
- **DFT_INVERSE** inverts DFT. Use for complex-complex cases (real-complex and complex-real
cases are always forward and inverse, respectively).
+- **DFT_COMPLEX_INPUT** Specifies that input is complex input with 2 channels.
- **DFT_REAL_OUTPUT** specifies the output as real. The source matrix is the result of
real-complex transform, so the destination matrix must be real.
@param stream Stream for the asynchronous version.
@@ -813,6 +814,35 @@ instead of the width.
*/
CV_EXPORTS void dft(InputArray src, OutputArray dst, Size dft_size, int flags=0, Stream& stream = Stream::Null());
+/** @brief Base class for DFT operator as a cv::Algorithm. :
+ */
+class CV_EXPORTS DFT : public Algorithm
+{
+public:
+ /** @brief Computes an FFT of a given image.
+
+ @param image Source image. Only CV_32FC1 images are supported for now.
+ @param result Result image.
+ @param stream Stream for the asynchronous version.
+ */
+ virtual void compute(InputArray image, OutputArray result, Stream& stream = Stream::Null()) = 0;
+};
+
+/** @brief Creates implementation for cuda::DFT.
+
+ at param dft_size The image size.
+ at param flags Optional flags:
+- **DFT_ROWS** transforms each individual row of the source matrix.
+- **DFT_SCALE** scales the result: divide it by the number of elements in the transform
+(obtained from dft_size ).
+- **DFT_INVERSE** inverts DFT. Use for complex-complex cases (real-complex and complex-real
+cases are always forward and inverse, respectively).
+- **DFT_COMPLEX_INPUT** Specifies that inputs will be complex with 2 channels.
+- **DFT_REAL_OUTPUT** specifies the output as real. The source matrix is the result of
+real-complex transform, so the destination matrix must be real.
+ */
+CV_EXPORTS Ptr<DFT> createDFT(Size dft_size, int flags);
+
/** @brief Base class for convolution (or cross-correlation) operator. :
*/
class CV_EXPORTS Convolution : public Algorithm
diff --git a/modules/cudaarithm/src/arithm.cpp b/modules/cudaarithm/src/arithm.cpp
index 08de4e4..01a0169 100644
--- a/modules/cudaarithm/src/arithm.cpp
+++ b/modules/cudaarithm/src/arithm.cpp
@@ -286,111 +286,146 @@ void cv::cuda::gemm(InputArray _src1, InputArray _src2, double alpha, InputArray
}
//////////////////////////////////////////////////////////////////////////////
-// dft
+// DFT function
void cv::cuda::dft(InputArray _src, OutputArray _dst, Size dft_size, int flags, Stream& stream)
{
-#ifndef HAVE_CUFFT
- (void) _src;
- (void) _dst;
- (void) dft_size;
- (void) flags;
- (void) stream;
- throw_no_cuda();
-#else
- GpuMat src = getInputMat(_src, stream);
+ if (getInputMat(_src, stream).channels() == 2)
+ flags |= DFT_COMPLEX_INPUT;
- CV_Assert( src.type() == CV_32FC1 || src.type() == CV_32FC2 );
+ Ptr<DFT> dft = createDFT(dft_size, flags);
+ dft->compute(_src, _dst, stream);
+}
- // We don't support unpacked output (in the case of real input)
- CV_Assert( !(flags & DFT_COMPLEX_OUTPUT) );
+//////////////////////////////////////////////////////////////////////////////
+// DFT algorithm
- const bool is_1d_input = (dft_size.height == 1) || (dft_size.width == 1);
- const bool is_row_dft = (flags & DFT_ROWS) != 0;
- const bool is_scaled_dft = (flags & DFT_SCALE) != 0;
- const bool is_inverse = (flags & DFT_INVERSE) != 0;
- const bool is_complex_input = src.channels() == 2;
- const bool is_complex_output = !(flags & DFT_REAL_OUTPUT);
+#ifdef HAVE_CUFFT
- // We don't support real-to-real transform
- CV_Assert( is_complex_input || is_complex_output );
+namespace
+{
- // Make sure here we work with the continuous input,
- // as CUFFT can't handle gaps
- GpuMat src_cont;
- if (src.isContinuous())
+ class DFTImpl : public DFT
{
- src_cont = src;
- }
- else
- {
- BufferPool pool(stream);
- src_cont.allocator = pool.getAllocator();
- createContinuous(src.rows, src.cols, src.type(), src_cont);
- src.copyTo(src_cont, stream);
- }
+ Size dft_size, dft_size_opt;
+ bool is_1d_input, is_row_dft, is_scaled_dft, is_inverse, is_complex_input, is_complex_output;
- Size dft_size_opt = dft_size;
- if (is_1d_input && !is_row_dft)
- {
- // If the source matrix is single column handle it as single row
- dft_size_opt.width = std::max(dft_size.width, dft_size.height);
- dft_size_opt.height = std::min(dft_size.width, dft_size.height);
- }
+ cufftType dft_type;
+ cufftHandle plan;
- CV_Assert( dft_size_opt.width > 1 );
+ public:
+ DFTImpl(Size dft_size, int flags)
+ : dft_size(dft_size),
+ dft_size_opt(dft_size),
+ is_1d_input((dft_size.height == 1) || (dft_size.width == 1)),
+ is_row_dft((flags & DFT_ROWS) != 0),
+ is_scaled_dft((flags & DFT_SCALE) != 0),
+ is_inverse((flags & DFT_INVERSE) != 0),
+ is_complex_input((flags & DFT_COMPLEX_INPUT) != 0),
+ is_complex_output(!(flags & DFT_REAL_OUTPUT)),
+ dft_type(!is_complex_input ? CUFFT_R2C : (is_complex_output ? CUFFT_C2C : CUFFT_C2R))
+ {
+ // We don't support unpacked output (in the case of real input)
+ CV_Assert( !(flags & DFT_COMPLEX_OUTPUT) );
- cufftType dft_type = CUFFT_R2C;
- if (is_complex_input)
- dft_type = is_complex_output ? CUFFT_C2C : CUFFT_C2R;
+ // We don't support real-to-real transform
+ CV_Assert( is_complex_input || is_complex_output );
- cufftHandle plan;
- if (is_1d_input || is_row_dft)
- cufftSafeCall( cufftPlan1d(&plan, dft_size_opt.width, dft_type, dft_size_opt.height) );
- else
- cufftSafeCall( cufftPlan2d(&plan, dft_size_opt.height, dft_size_opt.width, dft_type) );
+ if (is_1d_input && !is_row_dft)
+ {
+ // If the source matrix is single column handle it as single row
+ dft_size_opt.width = std::max(dft_size.width, dft_size.height);
+ dft_size_opt.height = std::min(dft_size.width, dft_size.height);
+ }
- cufftSafeCall( cufftSetStream(plan, StreamAccessor::getStream(stream)) );
+ CV_Assert( dft_size_opt.width > 1 );
- if (is_complex_input)
- {
- if (is_complex_output)
- {
- createContinuous(dft_size, CV_32FC2, _dst);
- GpuMat dst = _dst.getGpuMat();
+ if (is_1d_input || is_row_dft)
+ cufftSafeCall( cufftPlan1d(&plan, dft_size_opt.width, dft_type, dft_size_opt.height) );
+ else
+ cufftSafeCall( cufftPlan2d(&plan, dft_size_opt.height, dft_size_opt.width, dft_type) );
+ }
- cufftSafeCall(cufftExecC2C(
- plan, src_cont.ptr<cufftComplex>(), dst.ptr<cufftComplex>(),
- is_inverse ? CUFFT_INVERSE : CUFFT_FORWARD));
+ ~DFTImpl()
+ {
+ cufftSafeCall( cufftDestroy(plan) );
}
- else
+
+ void compute(InputArray _src, OutputArray _dst, Stream& stream)
{
- createContinuous(dft_size, CV_32F, _dst);
- GpuMat dst = _dst.getGpuMat();
+ GpuMat src = getInputMat(_src, stream);
- cufftSafeCall(cufftExecC2R(
- plan, src_cont.ptr<cufftComplex>(), dst.ptr<cufftReal>()));
- }
- }
- else
- {
- // We could swap dft_size for efficiency. Here we must reflect it
- if (dft_size == dft_size_opt)
- createContinuous(Size(dft_size.width / 2 + 1, dft_size.height), CV_32FC2, _dst);
- else
- createContinuous(Size(dft_size.width, dft_size.height / 2 + 1), CV_32FC2, _dst);
+ CV_Assert( src.type() == CV_32FC1 || src.type() == CV_32FC2 );
+ CV_Assert( is_complex_input == (src.channels() == 2) );
- GpuMat dst = _dst.getGpuMat();
+ // Make sure here we work with the continuous input,
+ // as CUFFT can't handle gaps
+ GpuMat src_cont;
+ if (src.isContinuous())
+ {
+ src_cont = src;
+ }
+ else
+ {
+ BufferPool pool(stream);
+ src_cont.allocator = pool.getAllocator();
+ createContinuous(src.rows, src.cols, src.type(), src_cont);
+ src.copyTo(src_cont, stream);
+ }
- cufftSafeCall(cufftExecR2C(
- plan, src_cont.ptr<cufftReal>(), dst.ptr<cufftComplex>()));
- }
+ cufftSafeCall( cufftSetStream(plan, StreamAccessor::getStream(stream)) );
- cufftSafeCall( cufftDestroy(plan) );
+ if (is_complex_input)
+ {
+ if (is_complex_output)
+ {
+ createContinuous(dft_size, CV_32FC2, _dst);
+ GpuMat dst = _dst.getGpuMat();
+
+ cufftSafeCall(cufftExecC2C(
+ plan, src_cont.ptr<cufftComplex>(), dst.ptr<cufftComplex>(),
+ is_inverse ? CUFFT_INVERSE : CUFFT_FORWARD));
+ }
+ else
+ {
+ createContinuous(dft_size, CV_32F, _dst);
+ GpuMat dst = _dst.getGpuMat();
+
+ cufftSafeCall(cufftExecC2R(
+ plan, src_cont.ptr<cufftComplex>(), dst.ptr<cufftReal>()));
+ }
+ }
+ else
+ {
+ // We could swap dft_size for efficiency. Here we must reflect it
+ if (dft_size == dft_size_opt)
+ createContinuous(Size(dft_size.width / 2 + 1, dft_size.height), CV_32FC2, _dst);
+ else
+ createContinuous(Size(dft_size.width, dft_size.height / 2 + 1), CV_32FC2, _dst);
- if (is_scaled_dft)
- cuda::multiply(_dst, Scalar::all(1. / dft_size.area()), _dst, 1, -1, stream);
+ GpuMat dst = _dst.getGpuMat();
+ cufftSafeCall(cufftExecR2C(
+ plan, src_cont.ptr<cufftReal>(), dst.ptr<cufftComplex>()));
+ }
+
+ if (is_scaled_dft)
+ cuda::multiply(_dst, Scalar::all(1. / dft_size.area()), _dst, 1, -1, stream);
+ }
+ };
+}
+
+#endif
+
+Ptr<DFT> cv::cuda::createDFT(Size dft_size, int flags)
+{
+#ifndef HAVE_CUFFT
+ (void) dft_size;
+ (void) flags;
+ CV_Error(Error::StsNotImplemented, "The library was build without CUFFT");
+ return Ptr<DFT>();
+#else
+ return makePtr<DFTImpl>(dft_size, flags);
#endif
}
diff --git a/modules/cudaarithm/src/cuda/absdiff_scalar.cu b/modules/cudaarithm/src/cuda/absdiff_scalar.cu
index 3ffd066..0955e40 100644
--- a/modules/cudaarithm/src/cuda/absdiff_scalar.cu
+++ b/modules/cudaarithm/src/cuda/absdiff_scalar.cu
@@ -56,14 +56,14 @@ void absDiffScalar(const GpuMat& src, cv::Scalar val, bool, GpuMat& dst, const G
namespace
{
- template <typename T, typename S> struct AbsDiffScalarOp : unary_function<T, T>
+ template <typename SrcType, typename ScalarType, typename DstType> struct AbsDiffScalarOp : unary_function<SrcType, DstType>
{
- S val;
+ ScalarType val;
- __device__ __forceinline__ T operator ()(T a) const
+ __device__ __forceinline__ DstType operator ()(SrcType a) const
{
- abs_func<S> f;
- return saturate_cast<T>(f(a - val));
+ abs_func<ScalarType> f;
+ return saturate_cast<DstType>(f(saturate_cast<ScalarType>(a) - val));
}
};
@@ -78,33 +78,56 @@ namespace
};
template <typename SrcType, typename ScalarDepth>
- void absDiffScalarImpl(const GpuMat& src, double value, GpuMat& dst, Stream& stream)
+ void absDiffScalarImpl(const GpuMat& src, cv::Scalar value, GpuMat& dst, Stream& stream)
{
- AbsDiffScalarOp<SrcType, ScalarDepth> op;
- op.val = static_cast<ScalarDepth>(value);
+ typedef typename MakeVec<ScalarDepth, VecTraits<SrcType>::cn>::type ScalarType;
+
+ cv::Scalar_<ScalarDepth> value_ = value;
+
+ AbsDiffScalarOp<SrcType, ScalarType, SrcType> op;
+ op.val = VecTraits<ScalarType>::make(value_.val);
gridTransformUnary_< TransformPolicy<ScalarDepth> >(globPtr<SrcType>(src), globPtr<SrcType>(dst), op, stream);
}
}
void absDiffScalar(const GpuMat& src, cv::Scalar val, bool, GpuMat& dst, const GpuMat&, double, Stream& stream, int)
{
- typedef void (*func_t)(const GpuMat& src, double val, GpuMat& dst, Stream& stream);
- static const func_t funcs[] =
+ typedef void (*func_t)(const GpuMat& src, cv::Scalar val, GpuMat& dst, Stream& stream);
+ static const func_t funcs[7][4] =
{
- absDiffScalarImpl<uchar, float>,
- absDiffScalarImpl<schar, float>,
- absDiffScalarImpl<ushort, float>,
- absDiffScalarImpl<short, float>,
- absDiffScalarImpl<int, float>,
- absDiffScalarImpl<float, float>,
- absDiffScalarImpl<double, double>
+ {
+ absDiffScalarImpl<uchar, float>, absDiffScalarImpl<uchar2, float>, absDiffScalarImpl<uchar3, float>, absDiffScalarImpl<uchar4, float>
+ },
+ {
+ absDiffScalarImpl<schar, float>, absDiffScalarImpl<char2, float>, absDiffScalarImpl<char3, float>, absDiffScalarImpl<char4, float>
+ },
+ {
+ absDiffScalarImpl<ushort, float>, absDiffScalarImpl<ushort2, float>, absDiffScalarImpl<ushort3, float>, absDiffScalarImpl<ushort4, float>
+ },
+ {
+ absDiffScalarImpl<short, float>, absDiffScalarImpl<short2, float>, absDiffScalarImpl<short3, float>, absDiffScalarImpl<short4, float>
+ },
+ {
+ absDiffScalarImpl<int, float>, absDiffScalarImpl<int2, float>, absDiffScalarImpl<int3, float>, absDiffScalarImpl<int4, float>
+ },
+ {
+ absDiffScalarImpl<float, float>, absDiffScalarImpl<float2, float>, absDiffScalarImpl<float3, float>, absDiffScalarImpl<float4, float>
+ },
+ {
+ absDiffScalarImpl<double, double>, absDiffScalarImpl<double2, double>, absDiffScalarImpl<double3, double>, absDiffScalarImpl<double4, double>
+ }
};
- const int depth = src.depth();
+ const int sdepth = src.depth();
+ const int cn = src.channels();
+
+ CV_DbgAssert( sdepth <= CV_64F && cn <= 4 && src.type() == dst.type());
- CV_DbgAssert( depth <= CV_64F );
+ const func_t func = funcs[sdepth][cn - 1];
+ if (!func)
+ CV_Error(cv::Error::StsUnsupportedFormat, "Unsupported combination of source and destination types");
- funcs[depth](src, val[0], dst, stream);
+ func(src, val, dst, stream);
}
#endif
diff --git a/modules/cudaarithm/test/test_arithm.cpp b/modules/cudaarithm/test/test_arithm.cpp
index 257f523..3e99ed4 100644
--- a/modules/cudaarithm/test/test_arithm.cpp
+++ b/modules/cudaarithm/test/test_arithm.cpp
@@ -250,6 +250,33 @@ CUDA_TEST_P(Dft, C2C)
}
}
+CUDA_TEST_P(Dft, Algorithm)
+{
+ int cols = randomInt(2, 100);
+ int rows = randomInt(2, 100);
+
+ int flags = 0;
+ cv::Ptr<cv::cuda::DFT> dft = cv::cuda::createDFT(cv::Size(cols, rows), flags);
+
+ for (int i = 0; i < 5; ++i)
+ {
+ SCOPED_TRACE("dft algorithm");
+
+ cv::Mat a = randomMat(cv::Size(cols, rows), CV_32FC2, 0.0, 10.0);
+
+ cv::cuda::GpuMat d_b;
+ cv::cuda::GpuMat d_b_data;
+ dft->compute(loadMat(a), d_b);
+
+ cv::Mat b_gold;
+ cv::dft(a, b_gold, flags);
+
+ ASSERT_EQ(CV_32F, d_b.depth());
+ ASSERT_EQ(2, d_b.channels());
+ EXPECT_MAT_NEAR(b_gold, cv::Mat(d_b), rows * cols * 1e-4);
+ }
+}
+
namespace
{
void testR2CThenC2R(const std::string& hint, int cols, int rows, bool inplace)
diff --git a/modules/cudabgsegm/perf/perf_bgsegm.cpp b/modules/cudabgsegm/perf/perf_bgsegm.cpp
index 48bda4a..21d03bc 100644
--- a/modules/cudabgsegm/perf/perf_bgsegm.cpp
+++ b/modules/cudabgsegm/perf/perf_bgsegm.cpp
@@ -46,23 +46,10 @@ using namespace std;
using namespace testing;
using namespace perf;
-#if defined(HAVE_XINE) || \
- defined(HAVE_GSTREAMER) || \
- defined(HAVE_QUICKTIME) || \
- defined(HAVE_QTKIT) || \
- defined(HAVE_AVFOUNDATION) || \
- defined(HAVE_FFMPEG) || \
- defined(WIN32) /* assume that we have ffmpeg */
-
-# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
-#else
-# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
-#endif
-
//////////////////////////////////////////////////////
// MOG
-#if BUILD_WITH_VIDEO_INPUT_SUPPORT
+#ifdef HAVE_VIDEO_INPUT
DEF_PARAM_TEST(Video_Cn_LearningRate, string, MatCn, double);
@@ -167,7 +154,7 @@ PERF_TEST_P(Video_Cn_LearningRate, MOG,
//////////////////////////////////////////////////////
// MOG2
-#if BUILD_WITH_VIDEO_INPUT_SUPPORT
+#ifdef HAVE_VIDEO_INPUT
DEF_PARAM_TEST(Video_Cn, string, int);
@@ -324,7 +311,7 @@ PERF_TEST_P(Video_Cn, DISABLED_MOG2,
//////////////////////////////////////////////////////
// MOG2GetBackgroundImage
-#if BUILD_WITH_VIDEO_INPUT_SUPPORT
+#ifdef HAVE_VIDEO_INPUT
PERF_TEST_P(Video_Cn, MOG2GetBackgroundImage,
Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"),
diff --git a/modules/cudabgsegm/test/test_bgsegm.cpp b/modules/cudabgsegm/test/test_bgsegm.cpp
index 9c463c3..a30cb1e 100644
--- a/modules/cudabgsegm/test/test_bgsegm.cpp
+++ b/modules/cudabgsegm/test/test_bgsegm.cpp
@@ -46,23 +46,10 @@
using namespace cvtest;
-#if defined(HAVE_XINE) || \
- defined(HAVE_GSTREAMER) || \
- defined(HAVE_QUICKTIME) || \
- defined(HAVE_QTKIT) || \
- defined(HAVE_AVFOUNDATION) || \
- defined(HAVE_FFMPEG) || \
- defined(WIN32) /* assume that we have ffmpeg */
-
-# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
-#else
-# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
-#endif
-
//////////////////////////////////////////////////////
// MOG2
-#if BUILD_WITH_VIDEO_INPUT_SUPPORT
+#ifdef HAVE_VIDEO_INPUT
namespace
{
diff --git a/modules/cudacodec/perf/perf_video.cpp b/modules/cudacodec/perf/perf_video.cpp
index 7c3439e..38b70af 100644
--- a/modules/cudacodec/perf/perf_video.cpp
+++ b/modules/cudacodec/perf/perf_video.cpp
@@ -47,25 +47,12 @@ using namespace std;
using namespace testing;
using namespace perf;
-#if defined(HAVE_XINE) || \
- defined(HAVE_GSTREAMER) || \
- defined(HAVE_QUICKTIME) || \
- defined(HAVE_QTKIT) || \
- defined(HAVE_AVFOUNDATION) || \
- defined(HAVE_FFMPEG) || \
- defined(WIN32) /* assume that we have ffmpeg */
-
-# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
-#else
-# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
-#endif
-
DEF_PARAM_TEST_1(FileName, string);
//////////////////////////////////////////////////////
// VideoReader
-#if defined(HAVE_NVCUVID) && BUILD_WITH_VIDEO_INPUT_SUPPORT
+#if defined(HAVE_NVCUVID) && defined(HAVE_VIDEO_INPUT)
PERF_TEST_P(FileName, VideoReader, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"))
{
@@ -101,7 +88,7 @@ PERF_TEST_P(FileName, VideoReader, Values("gpu/video/768x576.avi", "gpu/video/19
//////////////////////////////////////////////////////
// VideoWriter
-#if defined(HAVE_NVCUVID) && defined(WIN32)
+#if defined(HAVE_NVCUVID) && defined(_WIN32)
PERF_TEST_P(FileName, VideoWriter, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"))
{
diff --git a/modules/cudacodec/src/ffmpeg_video_source.cpp b/modules/cudacodec/src/ffmpeg_video_source.cpp
index 02c9fbc..1978e78 100644
--- a/modules/cudacodec/src/ffmpeg_video_source.cpp
+++ b/modules/cudacodec/src/ffmpeg_video_source.cpp
@@ -61,7 +61,7 @@ namespace
if (!initialized)
{
- #if defined WIN32 || defined _WIN32
+ #if defined _WIN32
const char* module_name = "opencv_ffmpeg"
CVAUX_STR(CV_VERSION_MAJOR) CVAUX_STR(CV_VERSION_MINOR) CVAUX_STR(CV_VERSION_REVISION)
#if (defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__)
diff --git a/modules/cudacodec/src/precomp.hpp b/modules/cudacodec/src/precomp.hpp
index 0abd7b0..906b13a 100644
--- a/modules/cudacodec/src/precomp.hpp
+++ b/modules/cudacodec/src/precomp.hpp
@@ -58,7 +58,7 @@
#ifdef HAVE_NVCUVID
#include <nvcuvid.h>
- #ifdef WIN32
+ #ifdef _WIN32
#define NOMINMAX
#include <windows.h>
#ifdef HAVE_NVCUVENC
diff --git a/modules/cudacodec/src/thread.cpp b/modules/cudacodec/src/thread.cpp
index ef97032..d326449 100644
--- a/modules/cudacodec/src/thread.cpp
+++ b/modules/cudacodec/src/thread.cpp
@@ -47,7 +47,7 @@
using namespace cv::cudacodec::detail;
-#ifdef WIN32
+#ifdef _WIN32
namespace
{
@@ -160,7 +160,7 @@ void cv::cudacodec::detail::Thread::wait()
void cv::cudacodec::detail::Thread::sleep(int ms)
{
-#ifdef WIN32
+#ifdef _WIN32
::Sleep(ms);
#else
::usleep(ms * 1000);
diff --git a/modules/cudacodec/src/video_writer.cpp b/modules/cudacodec/src/video_writer.cpp
index f6b9fc7..dec5a67 100644
--- a/modules/cudacodec/src/video_writer.cpp
+++ b/modules/cudacodec/src/video_writer.cpp
@@ -47,7 +47,7 @@ using namespace cv;
using namespace cv::cuda;
using namespace cv::cudacodec;
-#if !defined(HAVE_NVCUVENC) || !defined(WIN32)
+#if !defined(HAVE_NVCUVENC) || !defined(_WIN32)
cv::cudacodec::EncoderParams::EncoderParams() { throw_no_cuda(); }
cv::cudacodec::EncoderParams::EncoderParams(const String&) { throw_no_cuda(); }
@@ -60,7 +60,7 @@ Ptr<VideoWriter> cv::cudacodec::createVideoWriter(const String&, Size, double, c
Ptr<VideoWriter> cv::cudacodec::createVideoWriter(const Ptr<EncoderCallBack>&, Size, double, SurfaceFormat) { throw_no_cuda(); return Ptr<VideoWriter>(); }
Ptr<VideoWriter> cv::cudacodec::createVideoWriter(const Ptr<EncoderCallBack>&, Size, double, const EncoderParams&, SurfaceFormat) { throw_no_cuda(); return Ptr<VideoWriter>(); }
-#else // !defined HAVE_NVCUVENC || !defined WIN32
+#else // !defined HAVE_NVCUVENC || !defined _WIN32
void RGB_to_YV12(const GpuMat& src, GpuMat& dst);
@@ -731,7 +731,7 @@ namespace
if (!initialized)
{
- #if defined(WIN32) || defined(_WIN32)
+ #if defined(_WIN32)
const char* module_name = "opencv_ffmpeg"
CVAUX_STR(CV_VERSION_MAJOR) CVAUX_STR(CV_VERSION_MINOR) CVAUX_STR(CV_VERSION_REVISION)
#if (defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__)
@@ -913,4 +913,4 @@ Ptr<VideoWriter> cv::cudacodec::createVideoWriter(const Ptr<EncoderCallBack>& en
return makePtr<VideoWriterImpl>(encoderCallback, frameSize, fps, params, format);
}
-#endif // !defined HAVE_NVCUVENC || !defined WIN32
+#endif // !defined HAVE_NVCUVENC || !defined _WIN32
diff --git a/modules/cudacodec/test/test_video.cpp b/modules/cudacodec/test/test_video.cpp
index 83f0cb2..7babb4b 100644
--- a/modules/cudacodec/test/test_video.cpp
+++ b/modules/cudacodec/test/test_video.cpp
@@ -71,7 +71,7 @@ CUDA_TEST_P(Video, Reader)
//////////////////////////////////////////////////////
// VideoWriter
-#ifdef WIN32
+#ifdef _WIN32
CUDA_TEST_P(Video, Writer)
{
@@ -116,7 +116,7 @@ CUDA_TEST_P(Video, Writer)
}
}
-#endif // WIN32
+#endif // _WIN32
INSTANTIATE_TEST_CASE_P(CUDA_Codec, Video, testing::Combine(
ALL_DEVICES,
diff --git a/modules/cudafilters/src/cuda/median_filter.cu b/modules/cudafilters/src/cuda/median_filter.cu
index f66b429..f8e02cb 100644
--- a/modules/cudafilters/src/cuda/median_filter.cu
+++ b/modules/cudafilters/src/cuda/median_filter.cu
@@ -42,11 +42,6 @@
#if !defined CUDA_DISABLER
-#include "precomp.hpp"
-
-using namespace cv;
-using namespace cv::cuda;
-
#include "opencv2/core/cuda/common.hpp"
#include "opencv2/core/cuda/vec_traits.hpp"
#include "opencv2/core/cuda/vec_math.hpp"
diff --git a/modules/cudafilters/src/filtering.cpp b/modules/cudafilters/src/filtering.cpp
index 21efde0..1afd9cd 100644
--- a/modules/cudafilters/src/filtering.cpp
+++ b/modules/cudafilters/src/filtering.cpp
@@ -1068,6 +1068,8 @@ namespace
private:
int windowSize;
int partitions;
+ GpuMat devHist;
+ GpuMat devCoarseHist;
};
MedianFilter::MedianFilter(int srcType, int _windowSize, int _partitions) :
@@ -1099,9 +1101,8 @@ namespace
// Note - these are hardcoded in the actual GPU kernel. Do not change these values.
int histSize=256, histCoarseSize=8;
- BufferPool pool(_stream);
- GpuMat devHist = pool.getBuffer(1, src.cols*histSize*partitions,CV_32SC1);
- GpuMat devCoarseHist = pool.getBuffer(1,src.cols*histCoarseSize*partitions,CV_32SC1);
+ devHist.create(1, src.cols*histSize*partitions, CV_32SC1);
+ devCoarseHist.create(1, src.cols*histCoarseSize*partitions, CV_32SC1);
devHist.setTo(0, _stream);
devCoarseHist.setTo(0, _stream);
diff --git a/modules/cudaimgproc/include/opencv2/cudaimgproc.hpp b/modules/cudaimgproc/include/opencv2/cudaimgproc.hpp
index dc876b7..25a324a 100644
--- a/modules/cudaimgproc/include/opencv2/cudaimgproc.hpp
+++ b/modules/cudaimgproc/include/opencv2/cudaimgproc.hpp
@@ -201,6 +201,15 @@ CV_EXPORTS void alphaComp(InputArray img1, InputArray img2, OutputArray dst, int
*/
CV_EXPORTS void calcHist(InputArray src, OutputArray hist, Stream& stream = Stream::Null());
+/** @brief Calculates histogram for one channel 8-bit image confined in given mask.
+
+ at param src Source image with CV_8UC1 type.
+ at param hist Destination histogram with one row, 256 columns, and the CV_32SC1 type.
+ at param mask A mask image same size as src and of type CV_8UC1.
+ at param stream Stream for the asynchronous version.
+ */
+CV_EXPORTS void calcHist(InputArray src, InputArray mask, OutputArray hist, Stream& stream = Stream::Null());
+
/** @brief Equalizes the histogram of a grayscale image.
@param src Source image with CV_8UC1 type.
diff --git a/modules/cudaimgproc/src/cuda/hist.cu b/modules/cudaimgproc/src/cuda/hist.cu
index ba9290c..be13091 100644
--- a/modules/cudaimgproc/src/cuda/hist.cu
+++ b/modules/cudaimgproc/src/cuda/hist.cu
@@ -105,6 +105,72 @@ namespace hist
if (stream == 0)
cudaSafeCall( cudaDeviceSynchronize() );
}
+
+ __global__ void histogram256Kernel(const uchar* src, int cols, int rows, size_t srcStep, const uchar* mask, size_t maskStep, int* hist)
+ {
+ __shared__ int shist[256];
+
+ const int y = blockIdx.x * blockDim.y + threadIdx.y;
+ const int tid = threadIdx.y * blockDim.x + threadIdx.x;
+
+ shist[tid] = 0;
+ __syncthreads();
+
+ if (y < rows)
+ {
+ const unsigned int* rowPtr = (const unsigned int*) (src + y * srcStep);
+ const unsigned int* maskRowPtr = (const unsigned int*) (mask + y * maskStep);
+
+ const int cols_4 = cols / 4;
+ for (int x = threadIdx.x; x < cols_4; x += blockDim.x)
+ {
+ unsigned int data = rowPtr[x];
+ unsigned int m = maskRowPtr[x];
+
+ if ((m >> 0) & 0xFFU)
+ Emulation::smem::atomicAdd(&shist[(data >> 0) & 0xFFU], 1);
+
+ if ((m >> 8) & 0xFFU)
+ Emulation::smem::atomicAdd(&shist[(data >> 8) & 0xFFU], 1);
+
+ if ((m >> 16) & 0xFFU)
+ Emulation::smem::atomicAdd(&shist[(data >> 16) & 0xFFU], 1);
+
+ if ((m >> 24) & 0xFFU)
+ Emulation::smem::atomicAdd(&shist[(data >> 24) & 0xFFU], 1);
+ }
+
+ if (cols % 4 != 0 && threadIdx.x == 0)
+ {
+ for (int x = cols_4 * 4; x < cols; ++x)
+ {
+ unsigned int data = ((const uchar*)rowPtr)[x];
+ unsigned int m = ((const uchar*)maskRowPtr)[x];
+
+ if (m)
+ Emulation::smem::atomicAdd(&shist[data], 1);
+ }
+ }
+ }
+
+ __syncthreads();
+
+ const int histVal = shist[tid];
+ if (histVal > 0)
+ ::atomicAdd(hist + tid, histVal);
+ }
+
+ void histogram256(PtrStepSzb src, PtrStepSzb mask, int* hist, cudaStream_t stream)
+ {
+ const dim3 block(32, 8);
+ const dim3 grid(divUp(src.rows, block.y));
+
+ histogram256Kernel<<<grid, block, 0, stream>>>(src.data, src.cols, src.rows, src.step, mask.data, mask.step, hist);
+ cudaSafeCall( cudaGetLastError() );
+
+ if (stream == 0)
+ cudaSafeCall( cudaDeviceSynchronize() );
+ }
}
/////////////////////////////////////////////////////////////////////////
diff --git a/modules/cudaimgproc/src/histogram.cpp b/modules/cudaimgproc/src/histogram.cpp
index 59aa833..fce5057 100644
--- a/modules/cudaimgproc/src/histogram.cpp
+++ b/modules/cudaimgproc/src/histogram.cpp
@@ -69,20 +69,32 @@ void cv::cuda::histRange(InputArray, GpuMat*, const GpuMat*, Stream&) { throw_no
namespace hist
{
void histogram256(PtrStepSzb src, int* hist, cudaStream_t stream);
+ void histogram256(PtrStepSzb src, PtrStepSzb mask, int* hist, cudaStream_t stream);
}
void cv::cuda::calcHist(InputArray _src, OutputArray _hist, Stream& stream)
{
+ calcHist(_src, cv::cuda::GpuMat(), _hist, stream);
+}
+
+void cv::cuda::calcHist(InputArray _src, InputArray _mask, OutputArray _hist, Stream& stream)
+{
GpuMat src = _src.getGpuMat();
+ GpuMat mask = _mask.getGpuMat();
CV_Assert( src.type() == CV_8UC1 );
+ CV_Assert( mask.empty() || mask.type() == CV_8UC1 );
+ CV_Assert( mask.empty() || mask.size() == src.size() );
_hist.create(1, 256, CV_32SC1);
GpuMat hist = _hist.getGpuMat();
hist.setTo(Scalar::all(0), stream);
- hist::histogram256(src, hist.ptr<int>(), StreamAccessor::getStream(stream));
+ if (mask.empty())
+ hist::histogram256(src, hist.ptr<int>(), StreamAccessor::getStream(stream));
+ else
+ hist::histogram256(src, mask, hist.ptr<int>(), StreamAccessor::getStream(stream));
}
////////////////////////////////////////////////////////////////////////
diff --git a/modules/cudaimgproc/test/test_histogram.cpp b/modules/cudaimgproc/test/test_histogram.cpp
index 3d32173..7fcde85 100644
--- a/modules/cudaimgproc/test/test_histogram.cpp
+++ b/modules/cudaimgproc/test/test_histogram.cpp
@@ -136,6 +136,49 @@ INSTANTIATE_TEST_CASE_P(CUDA_ImgProc, CalcHist, testing::Combine(
ALL_DEVICES,
DIFFERENT_SIZES));
+PARAM_TEST_CASE(CalcHistWithMask, cv::cuda::DeviceInfo, cv::Size)
+{
+ cv::cuda::DeviceInfo devInfo;
+
+ cv::Size size;
+
+ virtual void SetUp()
+ {
+ devInfo = GET_PARAM(0);
+ size = GET_PARAM(1);
+
+ cv::cuda::setDevice(devInfo.deviceID());
+ }
+};
+
+CUDA_TEST_P(CalcHistWithMask, Accuracy)
+{
+ cv::Mat src = randomMat(size, CV_8UC1);
+ cv::Mat mask = randomMat(size, CV_8UC1);
+ cv::Mat(mask, cv::Rect(0, 0, size.width / 2, size.height / 2)).setTo(0);
+
+ cv::cuda::GpuMat hist;
+ cv::cuda::calcHist(loadMat(src), loadMat(mask), hist);
+
+ cv::Mat hist_gold;
+
+ const int hbins = 256;
+ const float hranges[] = {0.0f, 256.0f};
+ const int histSize[] = {hbins};
+ const float* ranges[] = {hranges};
+ const int channels[] = {0};
+
+ cv::calcHist(&src, 1, channels, mask, hist_gold, 1, histSize, ranges);
+ hist_gold = hist_gold.reshape(1, 1);
+ hist_gold.convertTo(hist_gold, CV_32S);
+
+ EXPECT_MAT_NEAR(hist_gold, hist, 0.0);
+}
+
+INSTANTIATE_TEST_CASE_P(CUDA_ImgProc, CalcHistWithMask, testing::Combine(
+ ALL_DEVICES,
+ DIFFERENT_SIZES));
+
///////////////////////////////////////////////////////////////////////////////////////////////////////
// EqualizeHist
diff --git a/modules/cudalegacy/perf/perf_bgsegm.cpp b/modules/cudalegacy/perf/perf_bgsegm.cpp
index 4367910..58f859f 100644
--- a/modules/cudalegacy/perf/perf_bgsegm.cpp
+++ b/modules/cudalegacy/perf/perf_bgsegm.cpp
@@ -50,23 +50,10 @@ using namespace std;
using namespace testing;
using namespace perf;
-#if defined(HAVE_XINE) || \
- defined(HAVE_GSTREAMER) || \
- defined(HAVE_QUICKTIME) || \
- defined(HAVE_QTKIT) || \
- defined(HAVE_AVFOUNDATION) || \
- defined(HAVE_FFMPEG) || \
- defined(WIN32) /* assume that we have ffmpeg */
-
-# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
-#else
-# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
-#endif
-
//////////////////////////////////////////////////////
// FGDStatModel
-#if BUILD_WITH_VIDEO_INPUT_SUPPORT
+#ifdef HAVE_VIDEO_INPUT
DEF_PARAM_TEST_1(Video, string);
@@ -136,7 +123,7 @@ PERF_TEST_P(Video, FGDStatModel,
//////////////////////////////////////////////////////
// GMG
-#if BUILD_WITH_VIDEO_INPUT_SUPPORT
+#ifdef HAVE_VIDEO_INPUT
DEF_PARAM_TEST(Video_Cn_MaxFeatures, string, MatCn, int);
diff --git a/modules/cudaobjdetect/src/cuda/hog.cu b/modules/cudaobjdetect/src/cuda/hog.cu
index c8609e7..45a3ecb 100644
--- a/modules/cudaobjdetect/src/cuda/hog.cu
+++ b/modules/cudaobjdetect/src/cuda/hog.cu
@@ -98,28 +98,31 @@ namespace cv { namespace cuda { namespace device
}
- void set_up_constants(int nbins, int block_stride_x, int block_stride_y,
- int nblocks_win_x, int nblocks_win_y, int ncells_block_x, int ncells_block_y)
+ void set_up_constants(int nbins,
+ int block_stride_x, int block_stride_y,
+ int nblocks_win_x, int nblocks_win_y,
+ int ncells_block_x, int ncells_block_y,
+ const cudaStream_t& stream)
{
- cudaSafeCall( cudaMemcpyToSymbol(cnbins, &nbins, sizeof(nbins)) );
- cudaSafeCall( cudaMemcpyToSymbol(cblock_stride_x, &block_stride_x, sizeof(block_stride_x)) );
- cudaSafeCall( cudaMemcpyToSymbol(cblock_stride_y, &block_stride_y, sizeof(block_stride_y)) );
- cudaSafeCall( cudaMemcpyToSymbol(cnblocks_win_x, &nblocks_win_x, sizeof(nblocks_win_x)) );
- cudaSafeCall( cudaMemcpyToSymbol(cnblocks_win_y, &nblocks_win_y, sizeof(nblocks_win_y)) );
- cudaSafeCall( cudaMemcpyToSymbol(cncells_block_x, &ncells_block_x, sizeof(ncells_block_x)) );
- cudaSafeCall( cudaMemcpyToSymbol(cncells_block_y, &ncells_block_y, sizeof(ncells_block_y)) );
+ cudaSafeCall(cudaMemcpyToSymbolAsync(cnbins, &nbins, sizeof(nbins), 0, cudaMemcpyHostToDevice, stream));
+ cudaSafeCall(cudaMemcpyToSymbolAsync(cblock_stride_x, &block_stride_x, sizeof(block_stride_x), 0, cudaMemcpyHostToDevice, stream));
+ cudaSafeCall(cudaMemcpyToSymbolAsync(cblock_stride_y, &block_stride_y, sizeof(block_stride_y), 0, cudaMemcpyHostToDevice, stream));
+ cudaSafeCall(cudaMemcpyToSymbolAsync(cnblocks_win_x, &nblocks_win_x, sizeof(nblocks_win_x), 0, cudaMemcpyHostToDevice, stream));
+ cudaSafeCall(cudaMemcpyToSymbolAsync(cnblocks_win_y, &nblocks_win_y, sizeof(nblocks_win_y), 0, cudaMemcpyHostToDevice, stream));
+ cudaSafeCall(cudaMemcpyToSymbolAsync(cncells_block_x, &ncells_block_x, sizeof(ncells_block_x), 0, cudaMemcpyHostToDevice, stream));
+ cudaSafeCall(cudaMemcpyToSymbolAsync(cncells_block_y, &ncells_block_y, sizeof(ncells_block_y), 0, cudaMemcpyHostToDevice, stream));
int block_hist_size = nbins * ncells_block_x * ncells_block_y;
- cudaSafeCall( cudaMemcpyToSymbol(cblock_hist_size, &block_hist_size, sizeof(block_hist_size)) );
+ cudaSafeCall(cudaMemcpyToSymbolAsync(cblock_hist_size, &block_hist_size, sizeof(block_hist_size), 0, cudaMemcpyHostToDevice, stream));
int block_hist_size_2up = power_2up(block_hist_size);
- cudaSafeCall( cudaMemcpyToSymbol(cblock_hist_size_2up, &block_hist_size_2up, sizeof(block_hist_size_2up)) );
+ cudaSafeCall(cudaMemcpyToSymbolAsync(cblock_hist_size_2up, &block_hist_size_2up, sizeof(block_hist_size_2up), 0, cudaMemcpyHostToDevice, stream));
int descr_width = nblocks_win_x * block_hist_size;
- cudaSafeCall( cudaMemcpyToSymbol(cdescr_width, &descr_width, sizeof(descr_width)) );
+ cudaSafeCall(cudaMemcpyToSymbolAsync(cdescr_width, &descr_width, sizeof(descr_width), 0, cudaMemcpyHostToDevice, stream));
int descr_size = descr_width * nblocks_win_y;
- cudaSafeCall( cudaMemcpyToSymbol(cdescr_size, &descr_size, sizeof(descr_size)) );
+ cudaSafeCall(cudaMemcpyToSymbolAsync(cdescr_size, &descr_size, sizeof(descr_size), 0, cudaMemcpyHostToDevice, stream));
}
@@ -230,10 +233,15 @@ namespace cv { namespace cuda { namespace device
}
//declaration of variables and invoke the kernel with the calculated number of blocks
- void compute_hists(int nbins, int block_stride_x, int block_stride_y,
- int height, int width, const PtrStepSzf& grad,
- const PtrStepSzb& qangle, float sigma, float* block_hists,
- int cell_size_x, int cell_size_y, int ncells_block_x, int ncells_block_y)
+ void compute_hists(int nbins,
+ int block_stride_x, int block_stride_y,
+ int height, int width,
+ const PtrStepSzf& grad, const PtrStepSzb& qangle,
+ float sigma,
+ float* block_hists,
+ int cell_size_x, int cell_size_y,
+ int ncells_block_x, int ncells_block_y,
+ const cudaStream_t& stream)
{
const int ncells_block = ncells_block_x * ncells_block_y;
const int patch_side = cell_size_x / 4;
@@ -259,20 +267,15 @@ namespace cv { namespace cuda { namespace device
int final_hists_size = (nbins * ncells_block * nblocks) * sizeof(float);
int smem = hists_size + final_hists_size;
if (nblocks == 4)
- compute_hists_kernel_many_blocks<4><<<grid, threads, smem>>>(
- img_block_width, grad, qangle, scale, block_hists, cell_size_x, patch_size, block_patch_size, threads_cell, threads_block, half_cell_size);
+ compute_hists_kernel_many_blocks<4><<<grid, threads, smem, stream>>>(img_block_width, grad, qangle, scale, block_hists, cell_size_x, patch_size, block_patch_size, threads_cell, threads_block, half_cell_size);
else if (nblocks == 3)
- compute_hists_kernel_many_blocks<3><<<grid, threads, smem>>>(
- img_block_width, grad, qangle, scale, block_hists, cell_size_x, patch_size, block_patch_size, threads_cell, threads_block, half_cell_size);
+ compute_hists_kernel_many_blocks<3><<<grid, threads, smem, stream>>>(img_block_width, grad, qangle, scale, block_hists, cell_size_x, patch_size, block_patch_size, threads_cell, threads_block, half_cell_size);
else if (nblocks == 2)
- compute_hists_kernel_many_blocks<2><<<grid, threads, smem>>>(
- img_block_width, grad, qangle, scale, block_hists, cell_size_x, patch_size, block_patch_size, threads_cell, threads_block, half_cell_size);
+ compute_hists_kernel_many_blocks<2><<<grid, threads, smem, stream>>>(img_block_width, grad, qangle, scale, block_hists, cell_size_x, patch_size, block_patch_size, threads_cell, threads_block, half_cell_size);
else
- compute_hists_kernel_many_blocks<1><<<grid, threads, smem>>>(
- img_block_width, grad, qangle, scale, block_hists, cell_size_x, patch_size, block_patch_size, threads_cell, threads_block, half_cell_size);
- cudaSafeCall( cudaGetLastError() );
+ compute_hists_kernel_many_blocks<1><<<grid, threads, smem, stream>>>(img_block_width, grad, qangle, scale, block_hists, cell_size_x, patch_size, block_patch_size, threads_cell, threads_block, half_cell_size);
- cudaSafeCall( cudaDeviceSynchronize() );
+ cudaSafeCall( cudaGetLastError() );
}
@@ -347,8 +350,14 @@ namespace cv { namespace cuda { namespace device
}
- void normalize_hists(int nbins, int block_stride_x, int block_stride_y,
- int height, int width, float* block_hists, float threshold, int cell_size_x, int cell_size_y, int ncells_block_x, int ncells_block_y)
+ void normalize_hists(int nbins,
+ int block_stride_x, int block_stride_y,
+ int height, int width,
+ float* block_hists,
+ float threshold,
+ int cell_size_x, int cell_size_y,
+ int ncells_block_x, int ncells_block_y,
+ const cudaStream_t& stream)
{
const int nblocks = 1;
@@ -361,21 +370,19 @@ namespace cv { namespace cuda { namespace device
dim3 grid(divUp(img_block_width, nblocks), img_block_height);
if (nthreads == 32)
- normalize_hists_kernel_many_blocks<32, nblocks><<<grid, threads>>>(block_hist_size, img_block_width, block_hists, threshold);
+ normalize_hists_kernel_many_blocks<32, nblocks><<<grid, threads, 0, stream>>>(block_hist_size, img_block_width, block_hists, threshold);
else if (nthreads == 64)
- normalize_hists_kernel_many_blocks<64, nblocks><<<grid, threads>>>(block_hist_size, img_block_width, block_hists, threshold);
+ normalize_hists_kernel_many_blocks<64, nblocks><<<grid, threads, 0, stream>>>(block_hist_size, img_block_width, block_hists, threshold);
else if (nthreads == 128)
- normalize_hists_kernel_many_blocks<128, nblocks><<<grid, threads>>>(block_hist_size, img_block_width, block_hists, threshold);
+ normalize_hists_kernel_many_blocks<128, nblocks><<<grid, threads, 0, stream>>>(block_hist_size, img_block_width, block_hists, threshold);
else if (nthreads == 256)
- normalize_hists_kernel_many_blocks<256, nblocks><<<grid, threads>>>(block_hist_size, img_block_width, block_hists, threshold);
+ normalize_hists_kernel_many_blocks<256, nblocks><<<grid, threads, 0, stream>>>(block_hist_size, img_block_width, block_hists, threshold);
else if (nthreads == 512)
- normalize_hists_kernel_many_blocks<512, nblocks><<<grid, threads>>>(block_hist_size, img_block_width, block_hists, threshold);
+ normalize_hists_kernel_many_blocks<512, nblocks><<<grid, threads, 0, stream>>>(block_hist_size, img_block_width, block_hists, threshold);
else
CV_Error(cv::Error::StsBadArg, "normalize_hists: histogram's size is too big, try to decrease number of bins");
cudaSafeCall( cudaGetLastError() );
-
- cudaSafeCall( cudaDeviceSynchronize() );
}
@@ -511,8 +518,10 @@ namespace cv { namespace cuda { namespace device
template <int nthreads>
- __global__ void extract_descrs_by_rows_kernel(const int img_block_width, const int win_block_stride_x, const int win_block_stride_y,
- const float* block_hists, PtrStepf descriptors)
+ __global__ void extract_descrs_by_rows_kernel(const int img_block_width,
+ const int win_block_stride_x, const int win_block_stride_y,
+ const float* block_hists,
+ PtrStepf descriptors)
{
// Get left top corner of the window in src
const float* hist = block_hists + (blockIdx.y * win_block_stride_y * img_block_width +
@@ -531,8 +540,14 @@ namespace cv { namespace cuda { namespace device
}
- void extract_descrs_by_rows(int win_height, int win_width, int block_stride_y, int block_stride_x, int win_stride_y, int win_stride_x,
- int height, int width, float* block_hists, int cell_size_x, int ncells_block_x, PtrStepSzf descriptors)
+ void extract_descrs_by_rows(int win_height, int win_width,
+ int block_stride_y, int block_stride_x,
+ int win_stride_y, int win_stride_x,
+ int height, int width,
+ float* block_hists, int cell_size_x,
+ int ncells_block_x,
+ PtrStepSzf descriptors,
+ const cudaStream_t& stream)
{
const int nthreads = 256;
@@ -544,17 +559,16 @@ namespace cv { namespace cuda { namespace device
dim3 grid(img_win_width, img_win_height);
int img_block_width = (width - ncells_block_x * cell_size_x + block_stride_x) / block_stride_x;
- extract_descrs_by_rows_kernel<nthreads><<<grid, threads>>>(
- img_block_width, win_block_stride_x, win_block_stride_y, block_hists, descriptors);
- cudaSafeCall( cudaGetLastError() );
+ extract_descrs_by_rows_kernel<nthreads><<<grid, threads, 0, stream>>>(img_block_width, win_block_stride_x, win_block_stride_y, block_hists, descriptors);
- cudaSafeCall( cudaDeviceSynchronize() );
+ cudaSafeCall( cudaGetLastError() );
}
template <int nthreads>
- __global__ void extract_descrs_by_cols_kernel(const int img_block_width, const int win_block_stride_x,
- const int win_block_stride_y, const float* block_hists,
+ __global__ void extract_descrs_by_cols_kernel(const int img_block_width,
+ const int win_block_stride_x, const int win_block_stride_y,
+ const float* block_hists,
PtrStepf descriptors)
{
// Get left top corner of the window in src
@@ -579,9 +593,14 @@ namespace cv { namespace cuda { namespace device
}
- void extract_descrs_by_cols(int win_height, int win_width, int block_stride_y, int block_stride_x,
- int win_stride_y, int win_stride_x, int height, int width, float* block_hists, int cell_size_x, int ncells_block_x,
- PtrStepSzf descriptors)
+ void extract_descrs_by_cols(int win_height, int win_width,
+ int block_stride_y, int block_stride_x,
+ int win_stride_y, int win_stride_x,
+ int height, int width,
+ float* block_hists,
+ int cell_size_x, int ncells_block_x,
+ PtrStepSzf descriptors,
+ const cudaStream_t& stream)
{
const int nthreads = 256;
@@ -593,11 +612,9 @@ namespace cv { namespace cuda { namespace device
dim3 grid(img_win_width, img_win_height);
int img_block_width = (width - ncells_block_x * cell_size_x + block_stride_x) / block_stride_x;
- extract_descrs_by_cols_kernel<nthreads><<<grid, threads>>>(
- img_block_width, win_block_stride_x, win_block_stride_y, block_hists, descriptors);
- cudaSafeCall( cudaGetLastError() );
+ extract_descrs_by_cols_kernel<nthreads><<<grid, threads, 0, stream>>>(img_block_width, win_block_stride_x, win_block_stride_y, block_hists, descriptors);
- cudaSafeCall( cudaDeviceSynchronize() );
+ cudaSafeCall( cudaGetLastError() );
}
//----------------------------------------------------------------------------
@@ -707,8 +724,12 @@ namespace cv { namespace cuda { namespace device
}
- void compute_gradients_8UC4(int nbins, int height, int width, const PtrStepSzb& img,
- float angle_scale, PtrStepSzf grad, PtrStepSzb qangle, bool correct_gamma)
+ void compute_gradients_8UC4(int nbins,
+ int height, int width, const PtrStepSzb& img,
+ float angle_scale,
+ PtrStepSzf grad, PtrStepSzb qangle,
+ bool correct_gamma,
+ const cudaStream_t& stream)
{
(void)nbins;
const int nthreads = 256;
@@ -717,13 +738,11 @@ namespace cv { namespace cuda { namespace device
dim3 gdim(divUp(width, bdim.x), divUp(height, bdim.y));
if (correct_gamma)
- compute_gradients_8UC4_kernel<nthreads, 1><<<gdim, bdim>>>(height, width, img, angle_scale, grad, qangle);
+ compute_gradients_8UC4_kernel<nthreads, 1><<<gdim, bdim, 0, stream>>>(height, width, img, angle_scale, grad, qangle);
else
- compute_gradients_8UC4_kernel<nthreads, 0><<<gdim, bdim>>>(height, width, img, angle_scale, grad, qangle);
+ compute_gradients_8UC4_kernel<nthreads, 0><<<gdim, bdim, 0, stream>>>(height, width, img, angle_scale, grad, qangle);
cudaSafeCall( cudaGetLastError() );
-
- cudaSafeCall( cudaDeviceSynchronize() );
}
template <int nthreads, int correct_gamma>
@@ -780,8 +799,12 @@ namespace cv { namespace cuda { namespace device
}
- void compute_gradients_8UC1(int nbins, int height, int width, const PtrStepSzb& img,
- float angle_scale, PtrStepSzf grad, PtrStepSzb qangle, bool correct_gamma)
+ void compute_gradients_8UC1(int nbins,
+ int height, int width, const PtrStepSzb& img,
+ float angle_scale,
+ PtrStepSzf grad, PtrStepSzb qangle,
+ bool correct_gamma,
+ const cudaStream_t& stream)
{
(void)nbins;
const int nthreads = 256;
@@ -790,13 +813,11 @@ namespace cv { namespace cuda { namespace device
dim3 gdim(divUp(width, bdim.x), divUp(height, bdim.y));
if (correct_gamma)
- compute_gradients_8UC1_kernel<nthreads, 1><<<gdim, bdim>>>(height, width, img, angle_scale, grad, qangle);
+ compute_gradients_8UC1_kernel<nthreads, 1><<<gdim, bdim, 0, stream>>>(height, width, img, angle_scale, grad, qangle);
else
- compute_gradients_8UC1_kernel<nthreads, 0><<<gdim, bdim>>>(height, width, img, angle_scale, grad, qangle);
+ compute_gradients_8UC1_kernel<nthreads, 0><<<gdim, bdim, 0, stream>>>(height, width, img, angle_scale, grad, qangle);
cudaSafeCall( cudaGetLastError() );
-
- cudaSafeCall( cudaDeviceSynchronize() );
}
diff --git a/modules/cudaobjdetect/src/hog.cpp b/modules/cudaobjdetect/src/hog.cpp
index 3d3b5d3..db391b6 100644
--- a/modules/cudaobjdetect/src/hog.cpp
+++ b/modules/cudaobjdetect/src/hog.cpp
@@ -64,17 +64,30 @@ namespace cv { namespace cuda { namespace device
{
namespace hog
{
- void set_up_constants(int nbins, int block_stride_x, int block_stride_y,
+ void set_up_constants(int nbins,
+ int block_stride_x, int block_stride_y,
int nblocks_win_x, int nblocks_win_y,
- int ncells_block_x, int ncells_block_y);
-
- void compute_hists(int nbins, int block_stride_x, int block_stride_y,
- int height, int width, const PtrStepSzf& grad,
- const PtrStepSzb& qangle, float sigma, float* block_hists,
- int cell_size_x, int cell_size_y, int ncells_block_x, int ncells_block_y);
-
- void normalize_hists(int nbins, int block_stride_x, int block_stride_y,
- int height, int width, float* block_hists, float threshold, int cell_size_x, int cell_size_y, int ncells_block_x, int ncells_block_y);
+ int ncells_block_x, int ncells_block_y,
+ const cudaStream_t& stream);
+
+ void compute_hists(int nbins,
+ int block_stride_x, int block_stride_y,
+ int height, int width,
+ const PtrStepSzf& grad, const PtrStepSzb& qangle,
+ float sigma,
+ float* block_hists,
+ int cell_size_x, int cell_size_y,
+ int ncells_block_x, int ncells_block_y,
+ const cudaStream_t& stream);
+
+ void normalize_hists(int nbins,
+ int block_stride_x, int block_stride_y,
+ int height, int width,
+ float* block_hists,
+ float threshold,
+ int cell_size_x, int cell_size_y,
+ int ncells_block_x, int ncells_block_y,
+ const cudaStream_t& stream);
void classify_hists(int win_height, int win_width, int block_stride_y,
int block_stride_x, int win_stride_y, int win_stride_x, int height,
@@ -82,20 +95,38 @@ namespace cv { namespace cuda { namespace device
float threshold, int cell_size_x, int ncells_block_x, unsigned char* labels);
void compute_confidence_hists(int win_height, int win_width, int block_stride_y, int block_stride_x,
- int win_stride_y, int win_stride_x, int height, int width, float* block_hists,
- float* coefs, float free_coef, float threshold, int cell_size_x, int ncells_block_x, float *confidences);
-
- void extract_descrs_by_rows(int win_height, int win_width, int block_stride_y, int block_stride_x,
- int win_stride_y, int win_stride_x, int height, int width, float* block_hists, int cell_size_x, int ncells_block_x,
- cv::cuda::PtrStepSzf descriptors);
- void extract_descrs_by_cols(int win_height, int win_width, int block_stride_y, int block_stride_x,
- int win_stride_y, int win_stride_x, int height, int width, float* block_hists, int cell_size_x, int ncells_block_x,
- cv::cuda::PtrStepSzf descriptors);
-
- void compute_gradients_8UC1(int nbins, int height, int width, const cv::cuda::PtrStepSzb& img,
- float angle_scale, cv::cuda::PtrStepSzf grad, cv::cuda::PtrStepSzb qangle, bool correct_gamma);
- void compute_gradients_8UC4(int nbins, int height, int width, const cv::cuda::PtrStepSzb& img,
- float angle_scale, cv::cuda::PtrStepSzf grad, cv::cuda::PtrStepSzb qangle, bool correct_gamma);
+ int win_stride_y, int win_stride_x, int height, int width, float* block_hists,
+ float* coefs, float free_coef, float threshold, int cell_size_x, int ncells_block_x, float *confidences);
+
+ void extract_descrs_by_rows(int win_height, int win_width,
+ int block_stride_y, int block_stride_x,
+ int win_stride_y, int win_stride_x,
+ int height, int width,
+ float* block_hists,
+ int cell_size_x, int ncells_block_x,
+ cv::cuda::PtrStepSzf descriptors,
+ const cudaStream_t& stream);
+ void extract_descrs_by_cols(int win_height, int win_width,
+ int block_stride_y, int block_stride_x,
+ int win_stride_y, int win_stride_x,
+ int height, int width,
+ float* block_hists,
+ int cell_size_x, int ncells_block_x,
+ cv::cuda::PtrStepSzf descriptors,
+ const cudaStream_t& stream);
+
+ void compute_gradients_8UC1(int nbins,
+ int height, int width, const cv::cuda::PtrStepSzb& img,
+ float angle_scale,
+ cv::cuda::PtrStepSzf grad, cv::cuda::PtrStepSzb qangle,
+ bool correct_gamma,
+ const cudaStream_t& stream);
+ void compute_gradients_8UC4(int nbins,
+ int height, int width, const cv::cuda::PtrStepSzb& img,
+ float angle_scale,
+ cv::cuda::PtrStepSzf grad, cv::cuda::PtrStepSzb qangle,
+ bool correct_gamma,
+ const cudaStream_t& stream);
void resize_8UC1(const cv::cuda::PtrStepSzb& src, cv::cuda::PtrStepSzb dst);
void resize_8UC4(const cv::cuda::PtrStepSzb& src, cv::cuda::PtrStepSzb dst);
@@ -182,8 +213,8 @@ namespace
private:
int getTotalHistSize(Size img_size) const;
- void computeBlockHistograms(const GpuMat& img, GpuMat& block_hists);
- void computeGradient(const GpuMat& img, GpuMat& grad, GpuMat& qangle);
+ void computeBlockHistograms(const GpuMat& img, GpuMat& block_hists, Stream& stream);
+// void computeGradient(const GpuMat& img, GpuMat& grad, GpuMat& qangle, Stream& stream);
// Coefficients of the separating plane
float free_coef_;
@@ -220,7 +251,7 @@ namespace
// Navneet Dalal and Bill Triggs. Histograms of oriented gradients for
// human detection. In International Conference on Computer Vision and
- // Pattern Recognition, volume 2, pages 886–893, June 2005
+ // Pattern Recognition, volume 2, pages 886-893, June 2005
// http://lear.inrialpes.fr/people/triggs/pubs/Dalal-cvpr05.pdf (28.07.2015) [Figure 5]
CV_Assert(block_stride == (block_size / 2));
@@ -310,7 +341,7 @@ namespace
BufferPool pool(Stream::Null());
GpuMat block_hists = pool.getBuffer(1, getTotalHistSize(img.size()), CV_32FC1);
- computeBlockHistograms(img, block_hists);
+ computeBlockHistograms(img, block_hists, Stream::Null());
Size wins_per_img = numPartsWithin(img.size(), win_size_, win_stride_);
@@ -458,19 +489,16 @@ namespace
CV_Assert( img.type() == CV_8UC1 || img.type() == CV_8UC4 );
CV_Assert( win_stride_.width % block_stride_.width == 0 && win_stride_.height % block_stride_.height == 0 );
- CV_Assert( !stream );
-
- BufferPool pool(stream);
-
- GpuMat block_hists = pool.getBuffer(1, getTotalHistSize(img.size()), CV_32FC1);
- computeBlockHistograms(img, block_hists);
+ BufferPool pool(stream);
+ GpuMat block_hists = pool.getBuffer(1, getTotalHistSize(img.size()), CV_32FC1);
+ Size wins_per_img = numPartsWithin(img.size(), win_size_, win_stride_);
+ Size blocks_per_win = numPartsWithin(win_size_, block_size_, block_stride_);
const size_t block_hist_size = getBlockHistogramSize();
- Size blocks_per_win = numPartsWithin(win_size_, block_size_, block_stride_);
- Size wins_per_img = numPartsWithin(img.size(), win_size_, win_stride_);
-
_descriptors.create(wins_per_img.area(), static_cast<int>(blocks_per_win.area() * block_hist_size), CV_32FC1);
- GpuMat descriptors = _descriptors.getGpuMat();
+ GpuMat descriptors = _descriptors.getGpuMat();
+
+ computeBlockHistograms(img, block_hists, stream);
switch (descr_format_)
{
@@ -481,7 +509,8 @@ namespace
img.rows, img.cols,
block_hists.ptr<float>(),
cell_size_.width, cells_per_block_.width,
- descriptors);
+ descriptors,
+ StreamAccessor::getStream(stream));
break;
case DESCR_FORMAT_COL_BY_COL:
hog::extract_descrs_by_cols(win_size_.height, win_size_.width,
@@ -490,7 +519,8 @@ namespace
img.rows, img.cols,
block_hists.ptr<float>(),
cell_size_.width, cells_per_block_.width,
- descriptors);
+ descriptors,
+ StreamAccessor::getStream(stream));
break;
default:
CV_Error(cv::Error::StsBadArg, "Unknown descriptor format");
@@ -504,18 +534,39 @@ namespace
return static_cast<int>(block_hist_size * blocks_per_img.area());
}
- void HOG_Impl::computeBlockHistograms(const GpuMat& img, GpuMat& block_hists)
+ void HOG_Impl::computeBlockHistograms(const GpuMat& img, GpuMat& block_hists, Stream& stream)
{
+ BufferPool pool(stream);
cv::Size blocks_per_win = numPartsWithin(win_size_, block_size_, block_stride_);
- hog::set_up_constants(nbins_, block_stride_.width, block_stride_.height, blocks_per_win.width, blocks_per_win.height, cells_per_block_.width, cells_per_block_.height);
+ float angleScale = static_cast<float>(nbins_ / CV_PI);
+ GpuMat grad = pool.getBuffer(img.size(), CV_32FC2);
+ GpuMat qangle = pool.getBuffer(img.size(), CV_8UC2);
- BufferPool pool(Stream::Null());
-
- GpuMat grad = pool.getBuffer(img.size(), CV_32FC2);
- GpuMat qangle = pool.getBuffer(img.size(), CV_8UC2);
- computeGradient(img, grad, qangle);
+ hog::set_up_constants(nbins_,
+ block_stride_.width, block_stride_.height,
+ blocks_per_win.width, blocks_per_win.height,
+ cells_per_block_.width, cells_per_block_.height,
+ StreamAccessor::getStream(stream));
- block_hists.create(1, getTotalHistSize(img.size()), CV_32FC1);
+ switch (img.type())
+ {
+ case CV_8UC1:
+ hog::compute_gradients_8UC1(nbins_,
+ img.rows, img.cols, img,
+ angleScale,
+ grad, qangle,
+ gamma_correction_,
+ StreamAccessor::getStream(stream));
+ break;
+ case CV_8UC4:
+ hog::compute_gradients_8UC4(nbins_,
+ img.rows, img.cols, img,
+ angleScale,
+ grad, qangle,
+ gamma_correction_,
+ StreamAccessor::getStream(stream));
+ break;
+ }
hog::compute_hists(nbins_,
block_stride_.width, block_stride_.height,
@@ -524,7 +575,8 @@ namespace
(float)getWinSigma(),
block_hists.ptr<float>(),
cell_size_.width, cell_size_.height,
- cells_per_block_.width, cells_per_block_.height);
+ cells_per_block_.width, cells_per_block_.height,
+ StreamAccessor::getStream(stream));
hog::normalize_hists(nbins_,
block_stride_.width, block_stride_.height,
@@ -532,24 +584,8 @@ namespace
block_hists.ptr<float>(),
(float)threshold_L2hys_,
cell_size_.width, cell_size_.height,
- cells_per_block_.width, cells_per_block_.height);
- }
-
- void HOG_Impl::computeGradient(const GpuMat& img, GpuMat& grad, GpuMat& qangle)
- {
- grad.create(img.size(), CV_32FC2);
- qangle.create(img.size(), CV_8UC2);
-
- float angleScale = (float)(nbins_ / CV_PI);
- switch (img.type())
- {
- case CV_8UC1:
- hog::compute_gradients_8UC1(nbins_, img.rows, img.cols, img, angleScale, grad, qangle, gamma_correction_);
- break;
- case CV_8UC4:
- hog::compute_gradients_8UC4(nbins_, img.rows, img.cols, img, angleScale, grad, qangle, gamma_correction_);
- break;
- }
+ cells_per_block_.width, cells_per_block_.height,
+ StreamAccessor::getStream(stream));
}
}
diff --git a/modules/cudaoptflow/include/opencv2/cudaoptflow.hpp b/modules/cudaoptflow/include/opencv2/cudaoptflow.hpp
index 576164b..eb8c5ef 100644
--- a/modules/cudaoptflow/include/opencv2/cudaoptflow.hpp
+++ b/modules/cudaoptflow/include/opencv2/cudaoptflow.hpp
@@ -210,7 +210,7 @@ public:
// FarnebackOpticalFlow
//
-/** @brief Class computing a dense optical flow using the Gunnar Farneback’s algorithm.
+/** @brief Class computing a dense optical flow using the Gunnar Farneback's algorithm.
*/
class CV_EXPORTS FarnebackOpticalFlow : public DenseOpticalFlow
{
diff --git a/modules/cudaoptflow/src/cuda/pyrlk.cu b/modules/cudaoptflow/src/cuda/pyrlk.cu
index 2f28650..e3cca57 100644
--- a/modules/cudaoptflow/src/cuda/pyrlk.cu
+++ b/modules/cudaoptflow/src/cuda/pyrlk.cu
@@ -51,6 +51,8 @@
#include "opencv2/core/cuda/filters.hpp"
#include "opencv2/core/cuda/border_interpolate.hpp"
+#include <iostream>
+
using namespace cv::cuda;
using namespace cv::cuda::device;
@@ -923,15 +925,15 @@ namespace pyrlk
float x = xBase - c_halfWin_x + j + 0.5f;
float y = yBase - c_halfWin_y + i + 0.5f;
- I_patch[i * patchWidth + j] = tex2D(tex_Ib, x, y);
+ I_patch[i * patchWidth + j] = tex2D(tex_If, x, y);
// Sharr Deriv
- dIdx_patch[i * patchWidth + j] = 3 * tex2D(tex_Ib, x+1, y-1) + 10 * tex2D(tex_Ib, x+1, y) + 3 * tex2D(tex_Ib, x+1, y+1) -
- (3 * tex2D(tex_Ib, x-1, y-1) + 10 * tex2D(tex_Ib, x-1, y) + 3 * tex2D(tex_Ib, x-1, y+1));
+ dIdx_patch[i * patchWidth + j] = 3 * tex2D(tex_If, x+1, y-1) + 10 * tex2D(tex_If, x+1, y) + 3 * tex2D(tex_If, x+1, y+1) -
+ (3 * tex2D(tex_If, x-1, y-1) + 10 * tex2D(tex_If, x-1, y) + 3 * tex2D(tex_If, x-1, y+1));
- dIdy_patch[i * patchWidth + j] = 3 * tex2D(tex_Ib, x-1, y+1) + 10 * tex2D(tex_Ib, x, y+1) + 3 * tex2D(tex_Ib, x+1, y+1) -
- (3 * tex2D(tex_Ib, x-1, y-1) + 10 * tex2D(tex_Ib, x, y-1) + 3 * tex2D(tex_Ib, x+1, y-1));
+ dIdy_patch[i * patchWidth + j] = 3 * tex2D(tex_If, x-1, y+1) + 10 * tex2D(tex_If, x, y+1) + 3 * tex2D(tex_If, x+1, y+1) -
+ (3 * tex2D(tex_If, x-1, y-1) + 10 * tex2D(tex_If, x, y-1) + 3 * tex2D(tex_If, x+1, y-1));
}
}
@@ -943,6 +945,7 @@ namespace pyrlk
if (x >= cols || y >= rows)
return;
+
int A11i = 0;
int A12i = 0;
int A22i = 0;
@@ -970,7 +973,6 @@ namespace pyrlk
{
if (calcErr)
err(y, x) = numeric_limits<float>::max();
-
return;
}
@@ -1014,6 +1016,7 @@ namespace pyrlk
}
}
+
float2 delta;
delta.x = A12 * b2 - A22 * b1;
delta.y = A12 * b1 - A11 * b2;
@@ -1083,11 +1086,11 @@ namespace pyrlk
funcs[patch.y - 1][patch.x - 1](I, J, I.rows, I.cols, prevPts, nextPts, status, err, ptcount,
level, block, stream);
}
- static void dense(PtrStepSzb I, PtrStepSz<T> J, PtrStepSzf u, PtrStepSzf v, PtrStepSzf prevU, PtrStepSzf prevV, PtrStepSzf err, int2 winSize, cudaStream_t stream)
+ static void dense(PtrStepSz<T> I, PtrStepSz<T> J, PtrStepSzf u, PtrStepSzf v, PtrStepSzf prevU, PtrStepSzf prevV, PtrStepSzf err, int2 winSize, cudaStream_t stream)
{
dim3 block(16, 16);
dim3 grid(divUp(I.cols, block.x), divUp(I.rows, block.y));
- Tex_I<1, uchar>::bindTexture_(I);
+ Tex_I<1, T>::bindTexture_(I);
Tex_J<1, T>::bindTexture_(J);
int2 halfWin = make_int2((winSize.x - 1) / 2, (winSize.y - 1) / 2);
diff --git a/modules/cudaoptflow/src/pyrlk.cpp b/modules/cudaoptflow/src/pyrlk.cpp
index c7f7060..d170447 100644
--- a/modules/cudaoptflow/src/pyrlk.cpp
+++ b/modules/cudaoptflow/src/pyrlk.cpp
@@ -61,7 +61,7 @@ namespace pyrlk
static void sparse(PtrStepSz<typename device::TypeVec<T, cn>::vec_type> I, PtrStepSz<typename device::TypeVec<T, cn>::vec_type> J, const float2* prevPts, float2* nextPts, uchar* status, float* err, int ptcount,
int level, dim3 block, dim3 patch, cudaStream_t stream);
- static void dense(PtrStepSzb I, PtrStepSzf J, PtrStepSzf u, PtrStepSzf v, PtrStepSzf prevU, PtrStepSzf prevV,
+ static void dense(PtrStepSzf I, PtrStepSzf J, PtrStepSzf u, PtrStepSzf v, PtrStepSzf prevU, PtrStepSzf prevV,
PtrStepSzf err, int2 winSize, cudaStream_t stream);
};
@@ -236,7 +236,9 @@ namespace
prevPyr_.resize(maxLevel_ + 1);
nextPyr_.resize(maxLevel_ + 1);
- prevPyr_[0] = prevImg;
+ //prevPyr_[0] = prevImg;
+
+ prevImg.convertTo(prevPyr_[0], CV_32F, stream);
nextImg.convertTo(nextPyr_[0], CV_32F, stream);
for (int level = 1; level <= maxLevel_; ++level)
diff --git a/modules/cudev/include/opencv2/cudev/warp/warp.hpp b/modules/cudev/include/opencv2/cudev/warp/warp.hpp
index 6860ccf..db096c5 100644
--- a/modules/cudev/include/opencv2/cudev/warp/warp.hpp
+++ b/modules/cudev/include/opencv2/cudev/warp/warp.hpp
@@ -64,7 +64,7 @@ struct Warp
__device__ __forceinline__ static uint laneId()
{
uint ret;
- asm("mov.u32 %0, %laneid;" : "=r"(ret));
+ asm("mov.u32 %0, %%laneid;" : "=r"(ret));
return ret;
}
diff --git a/modules/dnn/CMakeLists.txt b/modules/dnn/CMakeLists.txt
new file mode 100644
index 0000000..2a71568
--- /dev/null
+++ b/modules/dnn/CMakeLists.txt
@@ -0,0 +1,90 @@
+if(WINRT)
+ ocv_module_disable(dnn)
+endif()
+
+if(DEFINED BUILD_opencv_dnn AND NOT BUILD_opencv_dnn)
+ return()
+endif()
+
+include(${OpenCV_SOURCE_DIR}/cmake/OpenCVFindLibProtobuf.cmake)
+if(NOT Protobuf_FOUND)
+ ocv_module_disable(opencv_dnn)
+endif()
+
+set(the_description "Deep neural network module. It allows to load models from different frameworks and to make forward pass")
+
+ocv_add_dispatched_file("layers/layers_common" AVX AVX2)
+
+ocv_add_module(dnn opencv_core opencv_imgproc WRAP python matlab java)
+ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-shadow -Wno-parentheses -Wmaybe-uninitialized -Wsign-promo
+ -Wmissing-declarations -Wmissing-prototypes
+)
+ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4701 /wd4100)
+
+if(MSVC)
+ add_definitions( -D_CRT_SECURE_NO_WARNINGS=1 )
+ ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146
+ /wd4305 /wd4127 /wd4100 /wd4512 /wd4125 /wd4389 /wd4510 /wd4610
+ /wd4702 /wd4456 /wd4457 /wd4065 /wd4310 /wd4661 /wd4506
+ )
+else()
+ ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated -Wmissing-prototypes -Wmissing-declarations -Wshadow
+ -Wunused-parameter -Wunused-local-typedefs -Wsign-compare -Wsign-promo
+ -Wundef -Wtautological-undefined-compare -Wignored-qualifiers -Wextra
+ -Wunused-function -Wunused-const-variable -Wdeprecated-declarations
+ )
+endif()
+
+if(APPLE_FRAMEWORK)
+ ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshorten-64-to-32)
+endif()
+
+if(ANDROID)
+ add_definitions(-DDISABLE_POSIX_MEMALIGN -DTH_DISABLE_HEAP_TRACKING)
+endif()
+
+#supress warnings in autogenerated caffe.pb.* files
+add_definitions(-DHAVE_PROTOBUF=1)
+ocv_warnings_disable(CMAKE_CXX_FLAGS
+ -Wunused-parameter -Wundef -Wignored-qualifiers -Wno-enum-compare
+ -Wdeprecated-declarations
+ /wd4125 /wd4267 /wd4127 /wd4244 /wd4512 /wd4702
+ /wd4456 /wd4510 /wd4610 /wd4800
+ -wd858 -wd2196
+)
+
+if(PROTOBUF_UPDATE_FILES)
+ file(GLOB proto_files src/tensorflow/*.proto)
+ list(APPEND proto_files src/caffe/caffe.proto)
+ PROTOBUF_GENERATE_CPP(Protobuf_HDRS Protobuf_SRCS ${proto_files})
+else()
+ file(GLOB fw_srcs ${CMAKE_CURRENT_SOURCE_DIR}/misc/tensorflow/*.cc)
+ file(GLOB fw_hdrs ${CMAKE_CURRENT_SOURCE_DIR}/misc/tensorflow/*.h)
+ list(APPEND fw_srcs ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/caffe.pb.cc)
+ list(APPEND fw_hdrs ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/caffe.pb.h)
+ list(APPEND Protobuf_SRCS ${fw_srcs})
+ list(APPEND Protobuf_HDRS ${fw_hdrs})
+ list(APPEND Protobuf_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe)
+ list(APPEND Protobuf_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/misc/tensorflow)
+endif()
+
+ocv_source_group("Src\\protobuf" FILES ${Protobuf_SRCS} ${Protobuf_HDRS})
+ocv_module_include_directories(include ${Protobuf_INCLUDE_DIRS})
+
+ocv_glob_module_sources(${Protobuf_SRCS} ${Protobuf_HDRS} ${CBLAS_H_PROXY_PATH})
+ocv_create_module(${Protobuf_LIBRARIES} ${LAPACK_LIBRARIES})
+ocv_add_samples()
+ocv_add_accuracy_tests()
+ocv_add_perf_tests()
+
+# ----------------------------------------------------------------------------
+# Torch7 importer of blobs and models, produced by Torch.nn module
+# ----------------------------------------------------------------------------
+OCV_OPTION(${the_module}_BUILD_TORCH_IMPORTER "Build Torch model importer" ON)
+if(${the_module}_BUILD_TORCH_IMPORTER)
+ message(STATUS "Torch importer has been enabled. To run the tests you have to install Torch "
+ "('th' executable should be available) "
+ "and generate testdata using opencv_extra/testdata/dnn/generate_torch_models.py script.")
+ add_definitions(-DENABLE_TORCH_IMPORTER=1)
+ ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4702 /wd4127 /wd4267) #supress warnings in original torch files
+endif()
diff --git a/modules/dnn/include/opencv2/dnn.hpp b/modules/dnn/include/opencv2/dnn.hpp
new file mode 100644
index 0000000..690a82a
--- /dev/null
+++ b/modules/dnn/include/opencv2/dnn.hpp
@@ -0,0 +1,64 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#ifndef OPENCV_DNN_HPP
+#define OPENCV_DNN_HPP
+
+// This is an umbrealla header to include into you project.
+// We are free to change headers layout in dnn subfolder, so please include
+// this header for future compatibility
+
+
+/** @defgroup dnn Deep Neural Network module
+ @{
+ This module contains:
+ - API for new layers creation, layers are building bricks of neural networks;
+ - set of built-in most-useful Layers;
+ - API to constuct and modify comprehensive neural networks from layers;
+ - functionality for loading serialized networks models from differnet frameworks.
+
+ Functionality of this module is designed only for forward pass computations (i. e. network testing).
+ A network training is in principle not supported.
+ @}
+*/
+#include <opencv2/dnn/dnn.hpp>
+
+#endif /* OPENCV_DNN_HPP */
diff --git a/modules/dnn/include/opencv2/dnn/all_layers.hpp b/modules/dnn/include/opencv2/dnn/all_layers.hpp
new file mode 100644
index 0000000..333656a
--- /dev/null
+++ b/modules/dnn/include/opencv2/dnn/all_layers.hpp
@@ -0,0 +1,471 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#ifndef OPENCV_DNN_DNN_ALL_LAYERS_HPP
+#define OPENCV_DNN_DNN_ALL_LAYERS_HPP
+#include <opencv2/dnn.hpp>
+
+namespace cv {
+namespace dnn {
+CV__DNN_EXPERIMENTAL_NS_BEGIN
+//! @addtogroup dnn
+//! @{
+
+/** @defgroup dnnLayerList Partial List of Implemented Layers
+ @{
+ This subsection of dnn module contains information about bult-in layers and their descriptions.
+
+ Classes listed here, in fact, provides C++ API for creating intances of bult-in layers.
+ In addition to this way of layers instantiation, there is a more common factory API (see @ref dnnLayerFactory), it allows to create layers dynamically (by name) and register new ones.
+ You can use both API, but factory API is less convinient for native C++ programming and basically designed for use inside importers (see @ref Importer, @ref createCaffeImporter(), @ref createTorchImporter()).
+
+ Bult-in layers partially reproduce functionality of corresponding Caffe and Torch7 layers.
+ In partuclar, the following layers and Caffe @ref Importer were tested to reproduce <a href="http://caffe.berkeleyvision.org/tutorial/layers.html">Caffe</a> functionality:
+ - Convolution
+ - Deconvolution
+ - Pooling
+ - InnerProduct
+ - TanH, ReLU, Sigmoid, BNLL, Power, AbsVal
+ - Softmax
+ - Reshape, Flatten, Slice, Split
+ - LRN
+ - MVN
+ - Dropout (since it does nothing on forward pass -))
+*/
+
+ class CV_EXPORTS BlankLayer : public Layer
+ {
+ public:
+ static Ptr<BlankLayer> create(const LayerParams ¶ms);
+ };
+
+ //! LSTM recurrent layer
+ class CV_EXPORTS LSTMLayer : public Layer
+ {
+ public:
+ /** Creates instance of LSTM layer */
+ static Ptr<LSTMLayer> create(const LayerParams& params);
+
+ /** Set trained weights for LSTM layer.
+ LSTM behavior on each step is defined by current input, previous output, previous cell state and learned weights.
+
+ Let @f$x_t at f$ be current input, @f$h_t at f$ be current output, @f$c_t at f$ be current state.
+ Than current output and current cell state is computed as follows:
+ @f{eqnarray*}{
+ h_t &= o_t \odot tanh(c_t), \\
+ c_t &= f_t \odot c_{t-1} + i_t \odot g_t, \\
+ @f}
+ where @f$\odot at f$ is per-element multiply operation and @f$i_t, f_t, o_t, g_t at f$ is internal gates that are computed using learned wights.
+
+ Gates are computed as follows:
+ @f{eqnarray*}{
+ i_t &= sigmoid&(W_{xi} x_t + W_{hi} h_{t-1} + b_i), \\
+ f_t &= sigmoid&(W_{xf} x_t + W_{hf} h_{t-1} + b_f), \\
+ o_t &= sigmoid&(W_{xo} x_t + W_{ho} h_{t-1} + b_o), \\
+ g_t &= tanh &(W_{xg} x_t + W_{hg} h_{t-1} + b_g), \\
+ @f}
+ where @f$W_{x?}@f$, @f$W_{h?}@f$ and @f$b_{?}@f$ are learned weights represented as matrices:
+ @f$W_{x?} \in R^{N_h \times N_x}@f$, @f$W_{h?} \in R^{N_h \times N_h}@f$, @f$b_? \in R^{N_h}@f$.
+
+ For simplicity and performance purposes we use @f$ W_x = [W_{xi}; W_{xf}; W_{xo}, W_{xg}] @f$
+ (i.e. @f$W_x at f$ is vertical contacentaion of @f$ W_{x?} @f$), @f$ W_x \in R^{4N_h \times N_x} @f$.
+ The same for @f$ W_h = [W_{hi}; W_{hf}; W_{ho}, W_{hg}], W_h \in R^{4N_h \times N_h} @f$
+ and for @f$ b = [b_i; b_f, b_o, b_g]@f$, @f$b \in R^{4N_h} @f$.
+
+ @param Wh is matrix defining how previous output is transformed to internal gates (i.e. according to abovemtioned notation is @f$ W_h @f$)
+ @param Wx is matrix defining how current input is transformed to internal gates (i.e. according to abovemtioned notation is @f$ W_x @f$)
+ @param b is bias vector (i.e. according to abovemtioned notation is @f$ b @f$)
+ */
+ virtual void setWeights(const Mat &Wh, const Mat &Wx, const Mat &b) = 0;
+
+ /** @brief Specifies shape of output blob which will be [[`T`], `N`] + @p outTailShape.
+ * @details If this parameter is empty or unset then @p outTailShape = [`Wh`.size(0)] will be used,
+ * where `Wh` is parameter from setWeights().
+ */
+ virtual void setOutShape(const MatShape &outTailShape = MatShape()) = 0;
+
+ /** @brief Specifies either interpet first dimension of input blob as timestamp dimenion either as sample.
+ *
+ * If flag is set to true then shape of input blob will be interpeted as [`T`, `N`, `[data dims]`] where `T` specifies number of timpestamps, `N` is number of independent streams.
+ * In this case each forward() call will iterate through `T` timestamps and update layer's state `T` times.
+ *
+ * If flag is set to false then shape of input blob will be interpeted as [`N`, `[data dims]`].
+ * In this case each forward() call will make one iteration and produce one timestamp with shape [`N`, `[out dims]`].
+ */
+ virtual void setUseTimstampsDim(bool use = true) = 0;
+
+ /** @brief If this flag is set to true then layer will produce @f$ c_t @f$ as second output.
+ * @details Shape of the second output is the same as first output.
+ */
+ virtual void setProduceCellOutput(bool produce = false) = 0;
+
+ /* In common case it use single input with @f$x_t at f$ values to compute output(s) @f$h_t at f$ (and @f$c_t at f$).
+ * @param input should contain packed values @f$x_t at f$
+ * @param output contains computed outputs: @f$h_t at f$ (and @f$c_t at f$ if setProduceCellOutput() flag was set to true).
+ *
+ * If setUseTimstampsDim() is set to true then @p input[0] should has at least two dimensions with the following shape: [`T`, `N`, `[data dims]`],
+ * where `T` specifies number of timpestamps, `N` is number of independent streams (i.e. @f$ x_{t_0 + t}^{stream} @f$ is stored inside @p input[0][t, stream, ...]).
+ *
+ * If setUseTimstampsDim() is set to fase then @p input[0] should contain single timestamp, its shape should has form [`N`, `[data dims]`] with at least one dimension.
+ * (i.e. @f$ x_{t}^{stream} @f$ is stored inside @p input[0][stream, ...]).
+ */
+
+ int inputNameToIndex(String inputName);
+ int outputNameToIndex(String outputName);
+ };
+
+ /** @brief Classical recurrent layer
+
+ Accepts two inputs @f$x_t at f$ and @f$h_{t-1}@f$ and compute two outputs @f$o_t at f$ and @f$h_t at f$.
+
+ - input: should contain packed input @f$x_t at f$.
+ - output: should contain output @f$o_t at f$ (and @f$h_t at f$ if setProduceHiddenOutput() is set to true).
+
+ input[0] should have shape [`T`, `N`, `data_dims`] where `T` and `N` is number of timestamps and number of independent samples of @f$x_t at f$ respectively.
+
+ output[0] will have shape [`T`, `N`, @f$N_o at f$], where @f$N_o at f$ is number of rows in @f$ W_{xo} @f$ matrix.
+
+ If setProduceHiddenOutput() is set to true then @p output[1] will contain a Mat with shape [`T`, `N`, @f$N_h at f$], where @f$N_h at f$ is number of rows in @f$ W_{hh} @f$ matrix.
+ */
+ class CV_EXPORTS RNNLayer : public Layer
+ {
+ public:
+ /** Creates instance of RNNLayer */
+ static Ptr<RNNLayer> create(const LayerParams& params);
+
+ /** Setups learned weights.
+
+ Recurrent-layer behavior on each step is defined by current input @f$ x_t @f$, previous state @f$ h_t @f$ and learned weights as follows:
+ @f{eqnarray*}{
+ h_t &= tanh&(W_{hh} h_{t-1} + W_{xh} x_t + b_h), \\
+ o_t &= tanh&(W_{ho} h_t + b_o),
+ @f}
+
+ @param Wxh is @f$ W_{xh} @f$ matrix
+ @param bh is @f$ b_{h} @f$ vector
+ @param Whh is @f$ W_{hh} @f$ matrix
+ @param Who is @f$ W_{xo} @f$ matrix
+ @param bo is @f$ b_{o} @f$ vector
+ */
+ virtual void setWeights(const Mat &Wxh, const Mat &bh, const Mat &Whh, const Mat &Who, const Mat &bo) = 0;
+
+ /** @brief If this flag is set to true then layer will produce @f$ h_t @f$ as second output.
+ * @details Shape of the second output is the same as first output.
+ */
+ virtual void setProduceHiddenOutput(bool produce = false) = 0;
+
+ };
+
+ class CV_EXPORTS BaseConvolutionLayer : public Layer
+ {
+ public:
+ Size kernel, stride, pad, dilation, adjustPad;
+ String padMode;
+ };
+
+ class CV_EXPORTS ConvolutionLayer : public BaseConvolutionLayer
+ {
+ public:
+ static Ptr<BaseConvolutionLayer> create(const LayerParams& params);
+ };
+
+ class CV_EXPORTS DeconvolutionLayer : public BaseConvolutionLayer
+ {
+ public:
+ static Ptr<BaseConvolutionLayer> create(const LayerParams& params);
+ };
+
+ class CV_EXPORTS LRNLayer : public Layer
+ {
+ public:
+ enum Type
+ {
+ CHANNEL_NRM,
+ SPATIAL_NRM
+ };
+ int type;
+
+ int size;
+ float alpha, beta, bias;
+ bool normBySize;
+
+ static Ptr<LRNLayer> create(const LayerParams& params);
+ };
+
+ class CV_EXPORTS PoolingLayer : public Layer
+ {
+ public:
+ enum Type
+ {
+ MAX,
+ AVE,
+ STOCHASTIC
+ };
+
+ int type;
+ Size kernel, stride, pad;
+ bool globalPooling;
+ bool computeMaxIdx;
+ String padMode;
+
+ static Ptr<PoolingLayer> create(const LayerParams& params);
+ };
+
+ class CV_EXPORTS SoftmaxLayer : public Layer
+ {
+ public:
+ bool logSoftMax;
+
+ static Ptr<SoftmaxLayer> create(const LayerParams& params);
+ };
+
+ class CV_EXPORTS InnerProductLayer : public Layer
+ {
+ public:
+ int axis;
+ static Ptr<InnerProductLayer> create(const LayerParams& params);
+ };
+
+ class CV_EXPORTS MVNLayer : public Layer
+ {
+ public:
+ float eps;
+ bool normVariance, acrossChannels;
+
+ static Ptr<MVNLayer> create(const LayerParams& params);
+ };
+
+ /* Reshaping */
+
+ class CV_EXPORTS ReshapeLayer : public Layer
+ {
+ public:
+ MatShape newShapeDesc;
+ Range newShapeRange;
+
+ static Ptr<ReshapeLayer> create(const LayerParams& params);
+ };
+
+ class CV_EXPORTS FlattenLayer : public Layer
+ {
+ public:
+ static Ptr<FlattenLayer> create(const LayerParams ¶ms);
+ };
+
+ class CV_EXPORTS ConcatLayer : public Layer
+ {
+ public:
+ int axis;
+
+ static Ptr<ConcatLayer> create(const LayerParams ¶ms);
+ };
+
+ class CV_EXPORTS SplitLayer : public Layer
+ {
+ public:
+ int outputsCount; //!< Number of copies that will be produced (is ignored when negative).
+
+ static Ptr<SplitLayer> create(const LayerParams ¶ms);
+ };
+
+ class CV_EXPORTS SliceLayer : public Layer
+ {
+ public:
+ int axis;
+ std::vector<int> sliceIndices;
+
+ static Ptr<SliceLayer> create(const LayerParams ¶ms);
+ };
+
+ class CV_EXPORTS PermuteLayer : public Layer
+ {
+ public:
+ static Ptr<PermuteLayer> create(const LayerParams& params);
+ };
+
+ class CV_EXPORTS PaddingLayer : public Layer
+ {
+ public:
+ static Ptr<PaddingLayer> create(const LayerParams& params);
+ };
+
+ /* Activations */
+ class CV_EXPORTS ActivationLayer : public Layer
+ {
+ public:
+ virtual void forwardSlice(const float* src, float* dst, int len,
+ size_t outPlaneSize, int cn0, int cn1) const = 0;
+ };
+
+ class CV_EXPORTS ReLULayer : public ActivationLayer
+ {
+ public:
+ float negativeSlope;
+
+ static Ptr<ReLULayer> create(const LayerParams ¶ms);
+ };
+
+ class CV_EXPORTS ChannelsPReLULayer : public ActivationLayer
+ {
+ public:
+ static Ptr<ChannelsPReLULayer> create(const LayerParams& params);
+ };
+
+ class CV_EXPORTS ELULayer : public ActivationLayer
+ {
+ public:
+ static Ptr<ELULayer> create(const LayerParams ¶ms);
+ };
+
+ class CV_EXPORTS TanHLayer : public ActivationLayer
+ {
+ public:
+ static Ptr<TanHLayer> create(const LayerParams ¶ms);
+ };
+
+ class CV_EXPORTS SigmoidLayer : public ActivationLayer
+ {
+ public:
+ static Ptr<SigmoidLayer> create(const LayerParams ¶ms);
+ };
+
+ class CV_EXPORTS BNLLLayer : public ActivationLayer
+ {
+ public:
+ static Ptr<BNLLLayer> create(const LayerParams ¶ms);
+ };
+
+ class CV_EXPORTS AbsLayer : public ActivationLayer
+ {
+ public:
+ static Ptr<AbsLayer> create(const LayerParams ¶ms);
+ };
+
+ class CV_EXPORTS PowerLayer : public ActivationLayer
+ {
+ public:
+ float power, scale, shift;
+
+ static Ptr<PowerLayer> create(const LayerParams ¶ms);
+ };
+
+ /* Layers used in semantic segmentation */
+
+ class CV_EXPORTS CropLayer : public Layer
+ {
+ public:
+ int startAxis;
+ std::vector<int> offset;
+
+ static Ptr<CropLayer> create(const LayerParams ¶ms);
+ };
+
+ class CV_EXPORTS EltwiseLayer : public Layer
+ {
+ public:
+ enum EltwiseOp
+ {
+ PROD = 0,
+ SUM = 1,
+ MAX = 2,
+ };
+
+ static Ptr<EltwiseLayer> create(const LayerParams ¶ms);
+ };
+
+ class CV_EXPORTS BatchNormLayer : public Layer
+ {
+ public:
+ bool hasWeights, hasBias;
+ float epsilon;
+
+ virtual void getScaleShift(Mat& scale, Mat& shift) const = 0;
+ static Ptr<BatchNormLayer> create(const LayerParams ¶ms);
+ };
+
+ class CV_EXPORTS MaxUnpoolLayer : public Layer
+ {
+ public:
+ Size poolKernel;
+ Size poolPad;
+ Size poolStride;
+
+ static Ptr<MaxUnpoolLayer> create(const LayerParams ¶ms);
+ };
+
+ class CV_EXPORTS ScaleLayer : public Layer
+ {
+ public:
+ bool hasBias;
+
+ static Ptr<ScaleLayer> create(const LayerParams& params);
+ };
+
+ class CV_EXPORTS ShiftLayer : public Layer
+ {
+ public:
+ static Ptr<ShiftLayer> create(const LayerParams& params);
+ };
+
+ class CV_EXPORTS PriorBoxLayer : public Layer
+ {
+ public:
+ static Ptr<PriorBoxLayer> create(const LayerParams& params);
+ };
+
+ class CV_EXPORTS DetectionOutputLayer : public Layer
+ {
+ public:
+ static Ptr<DetectionOutputLayer> create(const LayerParams& params);
+ };
+
+ class NormalizeBBoxLayer : public Layer
+ {
+ public:
+ static Ptr<NormalizeBBoxLayer> create(const LayerParams& params);
+ };
+
+//! @}
+//! @}
+CV__DNN_EXPERIMENTAL_NS_END
+}
+}
+#endif
diff --git a/modules/dnn/include/opencv2/dnn/dict.hpp b/modules/dnn/include/opencv2/dnn/dict.hpp
new file mode 100644
index 0000000..43cb58a
--- /dev/null
+++ b/modules/dnn/include/opencv2/dnn/dict.hpp
@@ -0,0 +1,152 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include <opencv2/core.hpp>
+#include <map>
+#include <ostream>
+
+#include <opencv2/dnn/dnn.hpp>
+
+#ifndef OPENCV_DNN_DNN_DICT_HPP
+#define OPENCV_DNN_DNN_DICT_HPP
+
+namespace cv {
+namespace dnn {
+CV__DNN_EXPERIMENTAL_NS_BEGIN
+//! @addtogroup dnn
+//! @{
+
+/** @brief This struct stores the scalar value (or array) of one of the following type: double, cv::String or int64.
+ * @todo Maybe int64 is useless because double type exactly stores at least 2^52 integers.
+ */
+struct CV_EXPORTS_W DictValue
+{
+ DictValue(const DictValue &r);
+ DictValue(int64 i = 0) : type(Param::INT), pi(new AutoBuffer<int64,1>) { (*pi)[0] = i; } //!< Constructs integer scalar
+ CV_WRAP DictValue(int i) : type(Param::INT), pi(new AutoBuffer<int64,1>) { (*pi)[0] = i; } //!< Constructs integer scalar
+ DictValue(unsigned p) : type(Param::INT), pi(new AutoBuffer<int64,1>) { (*pi)[0] = p; } //!< Constructs integer scalar
+ CV_WRAP DictValue(double p) : type(Param::REAL), pd(new AutoBuffer<double,1>) { (*pd)[0] = p; } //!< Constructs floating point scalar
+ CV_WRAP DictValue(const String &s) : type(Param::STRING), ps(new AutoBuffer<String,1>) { (*ps)[0] = s; } //!< Constructs string scalar
+ DictValue(const char *s) : type(Param::STRING), ps(new AutoBuffer<String,1>) { (*ps)[0] = s; } //!< @overload
+
+ template<typename TypeIter>
+ static DictValue arrayInt(TypeIter begin, int size); //!< Constructs integer array
+ template<typename TypeIter>
+ static DictValue arrayReal(TypeIter begin, int size); //!< Constructs floating point array
+ template<typename TypeIter>
+ static DictValue arrayString(TypeIter begin, int size); //!< Constructs array of strings
+
+ template<typename T>
+ T get(int idx = -1) const; //!< Tries to convert array element with specified index to requested type and returns its.
+
+ int size() const;
+
+ CV_WRAP bool isInt() const;
+ CV_WRAP bool isString() const;
+ CV_WRAP bool isReal() const;
+
+ CV_WRAP int getIntValue(int idx = -1) const;
+ CV_WRAP double getRealValue(int idx = -1) const;
+ CV_WRAP String getStringValue(int idx = -1) const;
+
+ DictValue &operator=(const DictValue &r);
+
+ friend std::ostream &operator<<(std::ostream &stream, const DictValue &dictv);
+
+ ~DictValue();
+
+private:
+
+ int type;
+
+ union
+ {
+ AutoBuffer<int64, 1> *pi;
+ AutoBuffer<double, 1> *pd;
+ AutoBuffer<String, 1> *ps;
+ void *pv;
+ };
+
+ DictValue(int _type, void *_p) : type(_type), pv(_p) {}
+ void release();
+};
+
+/** @brief This class implements name-value dictionary, values are instances of DictValue. */
+class CV_EXPORTS Dict
+{
+ typedef std::map<String, DictValue> _Dict;
+ _Dict dict;
+
+public:
+
+ //! Checks a presence of the @p key in the dictionary.
+ bool has(const String &key) const;
+
+ //! If the @p key in the dictionary then returns pointer to its value, else returns NULL.
+ DictValue *ptr(const String &key);
+
+ /** @overload */
+ const DictValue *ptr(const String &key) const;
+
+ //! If the @p key in the dictionary then returns its value, else an error will be generated.
+ const DictValue &get(const String &key) const;
+
+ /** @overload */
+ template <typename T>
+ T get(const String &key) const;
+
+ //! If the @p key in the dictionary then returns its value, else returns @p defaultValue.
+ template <typename T>
+ T get(const String &key, const T &defaultValue) const;
+
+ //! Sets new @p value for the @p key, or adds new key-value pair into the dictionary.
+ template<typename T>
+ const T &set(const String &key, const T &value);
+
+ friend std::ostream &operator<<(std::ostream &stream, const Dict &dict);
+};
+
+//! @}
+CV__DNN_EXPERIMENTAL_NS_END
+}
+}
+
+#endif
diff --git a/modules/dnn/include/opencv2/dnn/dnn.hpp b/modules/dnn/include/opencv2/dnn/dnn.hpp
new file mode 100644
index 0000000..8324fe9
--- /dev/null
+++ b/modules/dnn/include/opencv2/dnn/dnn.hpp
@@ -0,0 +1,697 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#ifndef OPENCV_DNN_DNN_HPP
+#define OPENCV_DNN_DNN_HPP
+
+#include <vector>
+#include <opencv2/core.hpp>
+
+#if !defined CV_DOXYGEN && !defined CV_DNN_DONT_ADD_EXPERIMENTAL_NS
+#define CV__DNN_EXPERIMENTAL_NS_BEGIN namespace experimental_dnn_v1 {
+#define CV__DNN_EXPERIMENTAL_NS_END }
+namespace cv { namespace dnn { namespace experimental_dnn_v1 { } using namespace experimental_dnn_v1; }}
+#else
+#define CV__DNN_EXPERIMENTAL_NS_BEGIN
+#define CV__DNN_EXPERIMENTAL_NS_END
+#endif
+
+#include <opencv2/dnn/dict.hpp>
+
+namespace cv {
+namespace dnn {
+CV__DNN_EXPERIMENTAL_NS_BEGIN
+//! @addtogroup dnn
+//! @{
+
+ typedef std::vector<int> MatShape;
+
+ /**
+ * @brief Enum of computation backends supported by layers.
+ */
+ enum Backend
+ {
+ DNN_BACKEND_DEFAULT,
+ DNN_BACKEND_HALIDE
+ };
+
+ /**
+ * @brief Enum of target devices for computations.
+ */
+ enum Target
+ {
+ DNN_TARGET_CPU,
+ DNN_TARGET_OPENCL
+ };
+
+ /** @brief This class provides all data needed to initialize layer.
+ *
+ * It includes dictionary with scalar params (which can be readed by using Dict interface),
+ * blob params #blobs and optional meta information: #name and #type of layer instance.
+ */
+ class CV_EXPORTS LayerParams : public Dict
+ {
+ public:
+ //TODO: Add ability to name blob params
+ std::vector<Mat> blobs; //!< List of learned parameters stored as blobs.
+
+ String name; //!< Name of the layer instance (optional, can be used internal purposes).
+ String type; //!< Type name which was used for creating layer by layer factory (optional).
+ };
+
+ /**
+ * @brief Derivatives of this class encapsulates functions of certain backends.
+ */
+ class BackendNode
+ {
+ public:
+ BackendNode(int backendId);
+
+ virtual ~BackendNode(); //!< Virtual destructor to make polymorphism.
+
+ int backendId; //!< Backend identifier.
+ };
+
+ /**
+ * @brief Derivatives of this class wraps cv::Mat for different backends and targets.
+ */
+ class BackendWrapper
+ {
+ public:
+ BackendWrapper(int backendId, int targetId);
+
+ /**
+ * @brief Wrap cv::Mat for specific backend and target.
+ * @param[in] targetId Target identifier.
+ * @param[in] m cv::Mat for wrapping.
+ *
+ * Make CPU->GPU data transfer if it's require for the target.
+ */
+ BackendWrapper(int targetId, const cv::Mat& m);
+
+ /**
+ * @brief Make wrapper for reused cv::Mat.
+ * @param[in] base Wrapper of cv::Mat that will be reused.
+ * @param[in] shape Specific shape.
+ *
+ * Initialize wrapper from another one. It'll wrap the same host CPU
+ * memory and mustn't allocate memory on device(i.e. GPU). It might
+ * has different shape. Use in case of CPU memory reusing for reuse
+ * associented memory on device too.
+ */
+ BackendWrapper(const Ptr<BackendWrapper>& base, const MatShape& shape);
+
+ virtual ~BackendWrapper(); //!< Virtual destructor to make polymorphism.
+
+ /**
+ * @brief Transfer data to CPU host memory.
+ */
+ virtual void copyToHost() = 0;
+
+ int backendId; //!< Backend identifier.
+ int targetId; //!< Target identifier.
+ };
+
+ class CV_EXPORTS ActivationLayer;
+ class CV_EXPORTS BatchNormLayer;
+ class CV_EXPORTS ScaleLayer;
+
+ /** @brief This interface class allows to build new Layers - are building blocks of networks.
+ *
+ * Each class, derived from Layer, must implement allocate() methods to declare own outputs and forward() to compute outputs.
+ * Also before using the new layer into networks you must register your layer by using one of @ref dnnLayerFactory "LayerFactory" macros.
+ */
+ class CV_EXPORTS_W Layer : public Algorithm
+ {
+ public:
+
+ //! List of learned parameters must be stored here to allow read them by using Net::getParam().
+ CV_PROP_RW std::vector<Mat> blobs;
+
+ /** @brief Computes and sets internal parameters according to inputs, outputs and blobs.
+ * @param[in] input vector of already allocated input blobs
+ * @param[out] output vector of already allocated output blobs
+ *
+ * If this method is called after network has allocated all memory for input and output blobs
+ * and before inferencing.
+ */
+ virtual void finalize(const std::vector<Mat*> &input, std::vector<Mat> &output);
+
+ /** @brief Given the @p input blobs, computes the output @p blobs.
+ * @param[in] input the input blobs.
+ * @param[out] output allocated output blobs, which will store results of the computation.
+ * @param[out] internals allocated internal blobs
+ */
+ virtual void forward(std::vector<Mat*> &input, std::vector<Mat> &output, std::vector<Mat> &internals) = 0;
+
+ /** @brief @overload */
+ CV_WRAP void finalize(const std::vector<Mat> &inputs, CV_OUT std::vector<Mat> &outputs);
+
+ /** @brief @overload */
+ CV_WRAP std::vector<Mat> finalize(const std::vector<Mat> &inputs);
+
+ /** @brief @overload */
+ CV_WRAP void forward(const std::vector<Mat> &inputs, CV_IN_OUT std::vector<Mat> &outputs,
+ CV_IN_OUT std::vector<Mat> &internals);
+
+ /** @brief Allocates layer and computes output. */
+ CV_WRAP void run(const std::vector<Mat> &inputs, CV_OUT std::vector<Mat> &outputs,
+ CV_IN_OUT std::vector<Mat> &internals);
+
+ /** @brief Returns index of input blob into the input array.
+ * @param inputName label of input blob
+ *
+ * Each layer input and output can be labeled to easily identify them using "%<layer_name%>[.output_name]" notation.
+ * This method maps label of input blob to its index into input vector.
+ */
+ virtual int inputNameToIndex(String inputName);
+ /** @brief Returns index of output blob in output array.
+ * @see inputNameToIndex()
+ */
+ virtual int outputNameToIndex(String outputName);
+
+ /**
+ * @brief Ask layer if it support specific backend for doing computations.
+ * @param[in] backendId computation backend identifier.
+ * @see Backend
+ */
+ virtual bool supportBackend(int backendId);
+
+ /**
+ * @brief Returns Halide backend node.
+ * @param[in] inputs Input Halide buffers.
+ * @see BackendNode, BackendWrapper
+ *
+ * Input buffers should be exactly the same that will be used in forward invocations.
+ * Despite we can use Halide::ImageParam based on input shape only,
+ * it helps prevent some memory management issues (if something wrong,
+ * Halide tests will be failed).
+ */
+ virtual Ptr<BackendNode> initHalide(const std::vector<Ptr<BackendWrapper> > &inputs);
+
+ /**
+ * @brief Automatic Halide scheduling based on layer hyper-parameters.
+ * @param[in] node Backend node with Halide functions.
+ * @param[in] inputs Blobs that will be used in forward invocations.
+ * @param[in] outputs Blobs that will be used in forward invocations.
+ * @param[in] targetId Target identifier
+ * @see BackendNode, Target
+ *
+ * Layer don't use own Halide::Func members because we can have applied
+ * layers fusing. In this way the fused function should be scheduled.
+ */
+ virtual void applyHalideScheduler(Ptr<BackendNode>& node,
+ const std::vector<Mat*> &inputs,
+ const std::vector<Mat> &outputs,
+ int targetId) const;
+
+ /**
+ * @brief Implement layers fusing.
+ * @param[in] node Backend node of bottom layer.
+ * @see BackendNode
+ *
+ * Actual for graph-based backends. If layer attached successfully,
+ * returns non-empty cv::Ptr to node of the same backend.
+ * Fuse only over the last function.
+ */
+ virtual Ptr<BackendNode> tryAttach(const Ptr<BackendNode>& node);
+
+ /**
+ * @brief Tries to attach to the layer the subsequent activation layer, i.e. do the layer fusion in a partial case.
+ * @param[in] layer The subsequent activation layer.
+ *
+ * Returns true if the activation layer has been attached successfully.
+ */
+ virtual bool setActivation(const Ptr<ActivationLayer>& layer);
+
+ /**
+ * @brief Tries to attach to the layer the subsequent batch normalization layer, i.e. do the layer fusion in a partial case.
+ * @param[in] layer The subsequent batch normalization layer.
+ *
+ * Returns true if the batch normalization layer has been attached successfully.
+ */
+ virtual bool setBatchNorm(const Ptr<BatchNormLayer>& layer);
+
+ /**
+ * @brief Tries to attach to the layer the subsequent scaling layer, i.e. do the layer fusion in a partial case.
+ * @param[in] layer The subsequent scaling layer.
+ *
+ * Returns true if the scaling layer has been attached successfully.
+ */
+ virtual bool setScale(const Ptr<ScaleLayer>& layer);
+
+ /**
+ * @brief "Deattaches" all the layers, attached to particular layer.
+ */
+ virtual void unsetAttached();
+
+ virtual bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const;
+ virtual int64 getFLOPS(const std::vector<MatShape> &inputs,
+ const std::vector<MatShape> &outputs) const {(void)inputs; (void)outputs; return 0;}
+
+ CV_PROP String name; //!< Name of the layer instance, can be used for logging or other internal purposes.
+ CV_PROP String type; //!< Type name which was used for creating layer by layer factory.
+
+ Layer();
+ explicit Layer(const LayerParams ¶ms); //!< Initializes only #name, #type and #blobs fields.
+ void setParamsFrom(const LayerParams ¶ms); //!< Initializes only #name, #type and #blobs fields.
+ virtual ~Layer();
+ };
+
+ /** @brief This class allows to create and manipulate comprehensive artificial neural networks.
+ *
+ * Neural network is presented as directed acyclic graph (DAG), where vertices are Layer instances,
+ * and edges specify relationships between layers inputs and outputs.
+ *
+ * Each network layer has unique integer id and unique string name inside its network.
+ * LayerId can store either layer name or layer id.
+ *
+ * This class supports reference counting of its instances, i. e. copies point to the same instance.
+ */
+ class CV_EXPORTS_W_SIMPLE Net
+ {
+ public:
+
+ CV_WRAP Net(); //!< Default constructor.
+ CV_WRAP ~Net(); //!< Destructor frees the net only if there aren't references to the net anymore.
+
+ /** Returns true if there are no layers in the network. */
+ CV_WRAP bool empty() const;
+
+ /** @brief Adds new layer to the net.
+ * @param name unique name of the adding layer.
+ * @param type typename of the adding layer (type must be registered in LayerRegister).
+ * @param params parameters which will be used to initialize the creating layer.
+ * @returns unique identifier of created layer, or -1 if a failure will happen.
+ */
+ int addLayer(const String &name, const String &type, LayerParams ¶ms);
+ /** @brief Adds new layer and connects its first input to the first output of previously added layer.
+ * @see addLayer()
+ */
+ int addLayerToPrev(const String &name, const String &type, LayerParams ¶ms);
+
+ /** @brief Converts string name of the layer to the integer identifier.
+ * @returns id of the layer, or -1 if the layer wasn't found.
+ */
+ CV_WRAP int getLayerId(const String &layer);
+
+ CV_WRAP std::vector<String> getLayerNames() const;
+
+ /** @brief Container for strings and integers. */
+ typedef DictValue LayerId;
+
+ /** @brief Returns pointer to layer with specified id or name which the network use. */
+ CV_WRAP Ptr<Layer> getLayer(LayerId layerId);
+
+ /** @brief Returns pointers to input layers of specific layer. */
+ CV_WRAP std::vector<Ptr<Layer> > getLayerInputs(LayerId layerId);
+
+ /** @brief Delete layer for the network (not implemented yet) */
+ CV_WRAP void deleteLayer(LayerId layer);
+
+ /** @brief Connects output of the first layer to input of the second layer.
+ * @param outPin descriptor of the first layer output.
+ * @param inpPin descriptor of the second layer input.
+ *
+ * Descriptors have the following template <DFN><layer_name>[.input_number]</DFN>:
+ * - the first part of the template <DFN>layer_name</DFN> is sting name of the added layer.
+ * If this part is empty then the network input pseudo layer will be used;
+ * - the second optional part of the template <DFN>input_number</DFN>
+ * is either number of the layer input, either label one.
+ * If this part is omitted then the first layer input will be used.
+ *
+ * @see setNetInputs(), Layer::inputNameToIndex(), Layer::outputNameToIndex()
+ */
+ CV_WRAP void connect(String outPin, String inpPin);
+
+ /** @brief Connects #@p outNum output of the first layer to #@p inNum input of the second layer.
+ * @param outLayerId identifier of the first layer
+ * @param inpLayerId identifier of the second layer
+ * @param outNum number of the first layer output
+ * @param inpNum number of the second layer input
+ */
+ void connect(int outLayerId, int outNum, int inpLayerId, int inpNum);
+
+ /** @brief Sets outputs names of the network input pseudo layer.
+ *
+ * Each net always has special own the network input pseudo layer with id=0.
+ * This layer stores the user blobs only and don't make any computations.
+ * In fact, this layer provides the only way to pass user data into the network.
+ * As any other layer, this layer can label its outputs and this function provides an easy way to do this.
+ */
+ CV_WRAP void setInputsNames(const std::vector<String> &inputBlobNames);
+
+ /** @brief Runs forward pass to compute output of layer with name @p outputName.
+ * @param outputName name for layer which output is needed to get
+ * @return blob for first output of specified layer.
+ * @details By default runs forward pass for the whole network.
+ */
+ CV_WRAP Mat forward(const String& outputName = String());
+
+ /** @brief Runs forward pass to compute output of layer with name @p outputName.
+ * @param outputBlobs contains all output blobs for specified layer.
+ * @param outputName name for layer which output is needed to get
+ * @details If @p outputName is empty, runs forward pass for the whole network.
+ */
+ CV_WRAP void forward(std::vector<Mat>& outputBlobs, const String& outputName = String());
+
+ /** @brief Runs forward pass to compute outputs of layers listed in @p outBlobNames.
+ * @param outputBlobs contains blobs for first outputs of specified layers.
+ * @param outBlobNames names for layers which outputs are needed to get
+ */
+ CV_WRAP void forward(std::vector<Mat>& outputBlobs,
+ const std::vector<String>& outBlobNames);
+
+ /** @brief Runs forward pass to compute outputs of layers listed in @p outBlobNames.
+ * @param outputBlobs contains all output blobs for each layer specified in @p outBlobNames.
+ * @param outBlobNames names for layers which outputs are needed to get
+ */
+ CV_WRAP void forward(std::vector<std::vector<Mat> >& outputBlobs,
+ const std::vector<String>& outBlobNames);
+
+ //TODO:
+ /** @brief Optimized forward.
+ * @warning Not implemented yet.
+ * @details Makes forward only those layers which weren't changed after previous forward().
+ */
+ void forwardOpt(LayerId toLayer);
+ /** @overload */
+ void forwardOpt(const std::vector<LayerId> &toLayers);
+
+ /**
+ * @brief Compile Halide layers.
+ * @param[in] scheduler Path to YAML file with scheduling directives.
+ * @see setPreferableBackend
+ *
+ * Schedule layers that support Halide backend. Then compile them for
+ * specific target. For layers that not represented in scheduling file
+ * or if no manual scheduling used at all, automatic scheduling will be applied.
+ */
+ void setHalideScheduler(const String& scheduler);
+
+ /**
+ * @brief Ask network to use specific computation backend where it supported.
+ * @param[in] backendId backend identifier.
+ * @see Backend
+ */
+ void setPreferableBackend(int backendId);
+
+ /**
+ * @brief Ask network to make computations on specific target device.
+ * @param[in] targetId target identifier.
+ * @see Target
+ */
+ void setPreferableTarget(int targetId);
+
+ /** @brief Sets the new value for the layer output blob
+ * @param name descriptor of the updating layer output blob.
+ * @param blob new blob.
+ * @see connect(String, String) to know format of the descriptor.
+ * @note If updating blob is not empty then @p blob must have the same shape,
+ * because network reshaping is not implemented yet.
+ */
+ CV_WRAP void setInput(const Mat &blob, const String& name = "");
+
+ /** @brief Sets the new value for the learned param of the layer.
+ * @param layer name or id of the layer.
+ * @param numParam index of the layer parameter in the Layer::blobs array.
+ * @param blob the new value.
+ * @see Layer::blobs
+ * @note If shape of the new blob differs from the previous shape,
+ * then the following forward pass may fail.
+ */
+ CV_WRAP void setParam(LayerId layer, int numParam, const Mat &blob);
+
+ /** @brief Returns parameter blob of the layer.
+ * @param layer name or id of the layer.
+ * @param numParam index of the layer parameter in the Layer::blobs array.
+ * @see Layer::blobs
+ */
+ CV_WRAP Mat getParam(LayerId layer, int numParam = 0);
+
+ /** @brief Returns indexes of layers with unconnected outputs.
+ */
+ CV_WRAP std::vector<int> getUnconnectedOutLayers() const;
+ /** @brief Returns input and output shapes for all layers in loaded model;
+ * preliminary inferencing isn't necessary.
+ * @param netInputShapes shapes for all input blobs in net input layer.
+ * @param layersIds output parameter for layer IDs.
+ * @param inLayersShapes output parameter for input layers shapes;
+ * order is the same as in layersIds
+ * @param outLayersShapes output parameter for output layers shapes;
+ * order is the same as in layersIds
+ */
+ CV_WRAP void getLayersShapes(const std::vector<MatShape>& netInputShapes,
+ std::vector<int>* layersIds,
+ std::vector<std::vector<MatShape> >* inLayersShapes,
+ std::vector<std::vector<MatShape> >* outLayersShapes) const;
+
+ /** @overload */
+ CV_WRAP void getLayersShapes(const MatShape& netInputShape,
+ std::vector<int>* layersIds,
+ std::vector<std::vector<MatShape> >* inLayersShapes,
+ std::vector<std::vector<MatShape> >* outLayersShapes) const;
+
+ /** @brief Returns input and output shapes for layer with specified
+ * id in loaded model; preliminary inferencing isn't necessary.
+ * @param netInputShape shape input blob in net input layer.
+ * @param layerId id for layer.
+ * @param inLayerShapes output parameter for input layers shapes;
+ * order is the same as in layersIds
+ * @param outLayerShapes output parameter for output layers shapes;
+ * order is the same as in layersIds
+ */
+ CV_WRAP void getLayerShapes(const MatShape& netInputShape,
+ const int layerId,
+ std::vector<MatShape>* inLayerShapes,
+ std::vector<MatShape>* outLayerShapes) const;
+
+ /** @overload */
+ CV_WRAP void getLayerShapes(const std::vector<MatShape>& netInputShapes,
+ const int layerId,
+ std::vector<MatShape>* inLayerShapes,
+ std::vector<MatShape>* outLayerShapes) const;
+
+ /** @brief Computes FLOP for whole loaded model with specified input shapes.
+ * @param netInputShapes vector of shapes for all net inputs.
+ * @returns computed FLOP.
+ */
+ CV_WRAP int64 getFLOPS(const std::vector<MatShape>& netInputShapes) const;
+ /** @overload */
+ CV_WRAP int64 getFLOPS(const MatShape& netInputShape) const;
+ /** @overload */
+ CV_WRAP int64 getFLOPS(const int layerId,
+ const std::vector<MatShape>& netInputShapes) const;
+ /** @overload */
+ CV_WRAP int64 getFLOPS(const int layerId,
+ const MatShape& netInputShape) const;
+
+ /** @brief Returns list of types for layer used in model.
+ * @param layersTypes output parameter for returning types.
+ */
+ CV_WRAP void getLayerTypes(CV_OUT std::vector<String>& layersTypes) const;
+
+ /** @brief Returns count of layers of specified type.
+ * @param layerType type.
+ * @returns count of layers
+ */
+ CV_WRAP int getLayersCount(const String& layerType) const;
+
+ /** @brief Computes bytes number which are requered to store
+ * all weights and intermediate blobs for model.
+ * @param netInputShapes vector of shapes for all net inputs.
+ * @param weights output parameter to store resulting bytes for weights.
+ * @param blobs output parameter to store resulting bytes for intermediate blobs.
+ */
+ CV_WRAP void getMemoryConsumption(const std::vector<MatShape>& netInputShapes,
+ CV_OUT size_t& weights, CV_OUT size_t& blobs) const;
+ /** @overload */
+ CV_WRAP void getMemoryConsumption(const MatShape& netInputShape,
+ CV_OUT size_t& weights, CV_OUT size_t& blobs) const;
+ /** @overload */
+ CV_WRAP void getMemoryConsumption(const int layerId,
+ const std::vector<MatShape>& netInputShapes,
+ CV_OUT size_t& weights, CV_OUT size_t& blobs) const;
+ /** @overload */
+ CV_WRAP void getMemoryConsumption(const int layerId,
+ const MatShape& netInputShape,
+ CV_OUT size_t& weights, CV_OUT size_t& blobs) const;
+
+ /** @brief Computes bytes number which are requered to store
+ * all weights and intermediate blobs for each layer.
+ * @param netInputShapes vector of shapes for all net inputs.
+ * @param layerIds output vector to save layer IDs.
+ * @param weights output parameter to store resulting bytes for weights.
+ * @param blobs output parameter to store resulting bytes for intermediate blobs.
+ */
+ CV_WRAP void getMemoryConsumption(const std::vector<MatShape>& netInputShapes,
+ CV_OUT std::vector<int>& layerIds, CV_OUT std::vector<size_t>& weights,
+ CV_OUT std::vector<size_t>& blobs) const;
+ /** @overload */
+ CV_WRAP void getMemoryConsumption(const MatShape& netInputShape,
+ CV_OUT std::vector<int>& layerIds, CV_OUT std::vector<size_t>& weights,
+ CV_OUT std::vector<size_t>& blobs) const;
+
+ /** @brief Enables or disables layer fusion in the network.
+ * @param fusion true to enable the fusion, false to disable. The fusion is enabled by default.
+ */
+ CV_WRAP void enableFusion(bool fusion);
+
+ private:
+ struct Impl;
+ Ptr<Impl> impl;
+ };
+
+ /** @brief Small interface class for loading trained serialized models of different dnn-frameworks. */
+ class CV_EXPORTS_W Importer : public Algorithm
+ {
+ public:
+
+ /** @brief Adds loaded layers into the @p net and sets connections between them. */
+ CV_WRAP virtual void populateNet(Net net) = 0;
+
+ virtual ~Importer();
+ };
+
+ /** @brief Creates the importer of <a href="http://caffe.berkeleyvision.org">Caffe</a> framework network.
+ * @param prototxt path to the .prototxt file with text description of the network architecture.
+ * @param caffeModel path to the .caffemodel file with learned network.
+ * @returns Pointer to the created importer, NULL in failure cases.
+ */
+ CV_EXPORTS_W Ptr<Importer> createCaffeImporter(const String &prototxt, const String &caffeModel = String());
+
+ /** @brief Reads a network model stored in Caffe model files.
+ * @details This is shortcut consisting from createCaffeImporter and Net::populateNet calls.
+ */
+ CV_EXPORTS_W Net readNetFromCaffe(const String &prototxt, const String &caffeModel = String());
+
+ /** @brief Reads a network model stored in Tensorflow model file.
+ * @details This is shortcut consisting from createTensorflowImporter and Net::populateNet calls.
+ */
+ CV_EXPORTS_W Net readNetFromTensorflow(const String &model);
+
+ /** @brief Reads a network model stored in Torch model file.
+ * @details This is shortcut consisting from createTorchImporter and Net::populateNet calls.
+ */
+ CV_EXPORTS_W Net readNetFromTorch(const String &model, bool isBinary = true);
+
+ /** @brief Creates the importer of <a href="http://www.tensorflow.org">TensorFlow</a> framework network.
+ * @param model path to the .pb file with binary protobuf description of the network architecture.
+ * @returns Pointer to the created importer, NULL in failure cases.
+ */
+ CV_EXPORTS_W Ptr<Importer> createTensorflowImporter(const String &model);
+
+ /** @brief Creates the importer of <a href="http://torch.ch">Torch7</a> framework network.
+ * @param filename path to the file, dumped from Torch by using torch.save() function.
+ * @param isBinary specifies whether the network was serialized in ascii mode or binary.
+ * @returns Pointer to the created importer, NULL in failure cases.
+ *
+ * @warning Torch7 importer is experimental now, you need explicitly set CMake `opencv_dnn_BUILD_TORCH_IMPORTER` flag to compile its.
+ *
+ * @note Ascii mode of Torch serializer is more preferable, because binary mode extensively use `long` type of C language,
+ * which has various bit-length on different systems.
+ *
+ * The loading file must contain serialized <a href="https://github.com/torch/nn/blob/master/doc/module.md">nn.Module</a> object
+ * with importing network. Try to eliminate a custom objects from serialazing data to avoid importing errors.
+ *
+ * List of supported layers (i.e. object instances derived from Torch nn.Module class):
+ * - nn.Sequential
+ * - nn.Parallel
+ * - nn.Concat
+ * - nn.Linear
+ * - nn.SpatialConvolution
+ * - nn.SpatialMaxPooling, nn.SpatialAveragePooling
+ * - nn.ReLU, nn.TanH, nn.Sigmoid
+ * - nn.Reshape
+ * - nn.SoftMax, nn.LogSoftMax
+ *
+ * Also some equivalents of these classes from cunn, cudnn, and fbcunn may be successfully imported.
+ */
+ CV_EXPORTS_W Ptr<Importer> createTorchImporter(const String &filename, bool isBinary = true);
+
+ /** @brief Loads blob which was serialized as torch.Tensor object of Torch7 framework.
+ * @warning This function has the same limitations as createTorchImporter().
+ */
+ CV_EXPORTS_W Mat readTorchBlob(const String &filename, bool isBinary = true);
+ /** @brief Creates 4-dimensional blob from image. Optionally resizes and crops @p image from center,
+ * subtract @p mean values, scales values by @p scalefactor, swap Blue and Red channels.
+ * @param image input image (with 1- or 3-channels).
+ * @param size spatial size for output image
+ * @param mean scalar with mean values which are subtracted from channels. Values are intended
+ * to be in (mean-R, mean-G, mean-B) order if @p image has BGR ordering and @p swapRB is true.
+ * @param scalefactor multiplier for @p image values.
+ * @param swapRB flag which indicates that swap first and last channels
+ * in 3-channel image is necessary.
+ * @details input image is resized so one side after resize is equal to corresponing
+ * dimension in @p size and another one is equal or larger. Then, crop from the center is performed.
+ * @returns 4-dimansional Mat with NCHW dimensions order.
+ */
+ CV_EXPORTS_W Mat blobFromImage(const Mat& image, double scalefactor=1.0, const Size& size = Size(),
+ const Scalar& mean = Scalar(), bool swapRB=true);
+ /** @brief Creates 4-dimensional blob from series of images. Optionally resizes and
+ * crops @p images from center, subtract @p mean values, scales values by @p scalefactor,
+ * swap Blue and Red channels.
+ * @param images input images (all with 1- or 3-channels).
+ * @param size spatial size for output image
+ * @param mean scalar with mean values which are subtracted from channels. Values are intended
+ * to be in (mean-R, mean-G, mean-B) order if @p image has BGR ordering and @p swapRB is true.
+ * @param scalefactor multiplier for @p images values.
+ * @param swapRB flag which indicates that swap first and last channels
+ * in 3-channel image is necessary.
+ * @details input image is resized so one side after resize is equal to corresponing
+ * dimension in @p size and another one is equal or larger. Then, crop from the center is performed.
+ * @returns 4-dimansional Mat with NCHW dimensions order.
+ */
+ CV_EXPORTS_W Mat blobFromImages(const std::vector<Mat>& images, double scalefactor=1.0,
+ Size size = Size(), const Scalar& mean = Scalar(), bool swapRB=true);
+
+//! @}
+CV__DNN_EXPERIMENTAL_NS_END
+}
+}
+
+#include <opencv2/dnn/layer.hpp>
+#include <opencv2/dnn/dnn.inl.hpp>
+
+#endif /* OPENCV_DNN_DNN_HPP */
diff --git a/modules/dnn/include/opencv2/dnn/dnn.inl.hpp b/modules/dnn/include/opencv2/dnn/dnn.inl.hpp
new file mode 100644
index 0000000..c30185b
--- /dev/null
+++ b/modules/dnn/include/opencv2/dnn/dnn.inl.hpp
@@ -0,0 +1,373 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#ifndef OPENCV_DNN_DNN_INL_HPP
+#define OPENCV_DNN_DNN_INL_HPP
+
+#include <opencv2/dnn.hpp>
+
+namespace cv {
+namespace dnn {
+CV__DNN_EXPERIMENTAL_NS_BEGIN
+
+template<typename TypeIter>
+DictValue DictValue::arrayInt(TypeIter begin, int size)
+{
+ DictValue res(Param::INT, new AutoBuffer<int64, 1>(size));
+ for (int j = 0; j < size; begin++, j++)
+ (*res.pi)[j] = *begin;
+ return res;
+}
+
+template<typename TypeIter>
+DictValue DictValue::arrayReal(TypeIter begin, int size)
+{
+ DictValue res(Param::REAL, new AutoBuffer<double, 1>(size));
+ for (int j = 0; j < size; begin++, j++)
+ (*res.pd)[j] = *begin;
+ return res;
+}
+
+template<typename TypeIter>
+DictValue DictValue::arrayString(TypeIter begin, int size)
+{
+ DictValue res(Param::STRING, new AutoBuffer<String, 1>(size));
+ for (int j = 0; j < size; begin++, j++)
+ (*res.ps)[j] = *begin;
+ return res;
+}
+
+template<>
+inline DictValue DictValue::get<DictValue>(int idx) const
+{
+ CV_Assert(idx == -1);
+ return *this;
+}
+
+template<>
+inline int64 DictValue::get<int64>(int idx) const
+{
+ CV_Assert((idx == -1 && size() == 1) || (idx >= 0 && idx < size()));
+ idx = (idx == -1) ? 0 : idx;
+
+ if (type == Param::INT)
+ {
+ return (*pi)[idx];
+ }
+ else if (type == Param::REAL)
+ {
+ double doubleValue = (*pd)[idx];
+
+ double fracpart, intpart;
+ fracpart = std::modf(doubleValue, &intpart);
+ CV_Assert(fracpart == 0.0);
+
+ return (int64)doubleValue;
+ }
+ else
+ {
+ CV_Assert(isInt() || isReal());
+ return 0;
+ }
+}
+
+template<>
+inline int DictValue::get<int>(int idx) const
+{
+ return (int)get<int64>(idx);
+}
+
+inline int DictValue::getIntValue(int idx) const
+{
+ return (int)get<int64>(idx);
+}
+
+template<>
+inline unsigned DictValue::get<unsigned>(int idx) const
+{
+ return (unsigned)get<int64>(idx);
+}
+
+template<>
+inline bool DictValue::get<bool>(int idx) const
+{
+ return (get<int64>(idx) != 0);
+}
+
+template<>
+inline double DictValue::get<double>(int idx) const
+{
+ CV_Assert((idx == -1 && size() == 1) || (idx >= 0 && idx < size()));
+ idx = (idx == -1) ? 0 : idx;
+
+ if (type == Param::REAL)
+ {
+ return (*pd)[idx];
+ }
+ else if (type == Param::INT)
+ {
+ return (double)(*pi)[idx];
+ }
+ else
+ {
+ CV_Assert(isReal() || isInt());
+ return 0;
+ }
+}
+
+inline double DictValue::getRealValue(int idx) const
+{
+ return get<double>(idx);
+}
+
+template<>
+inline float DictValue::get<float>(int idx) const
+{
+ return (float)get<double>(idx);
+}
+
+template<>
+inline String DictValue::get<String>(int idx) const
+{
+ CV_Assert(isString());
+ CV_Assert((idx == -1 && ps->size() == 1) || (idx >= 0 && idx < (int)ps->size()));
+ return (*ps)[(idx == -1) ? 0 : idx];
+}
+
+
+inline String DictValue::getStringValue(int idx) const
+{
+ return get<String>(idx);
+}
+
+inline void DictValue::release()
+{
+ switch (type)
+ {
+ case Param::INT:
+ delete pi;
+ break;
+ case Param::STRING:
+ delete ps;
+ break;
+ case Param::REAL:
+ delete pd;
+ break;
+ }
+}
+
+inline DictValue::~DictValue()
+{
+ release();
+}
+
+inline DictValue & DictValue::operator=(const DictValue &r)
+{
+ if (&r == this)
+ return *this;
+
+ if (r.type == Param::INT)
+ {
+ AutoBuffer<int64, 1> *tmp = new AutoBuffer<int64, 1>(*r.pi);
+ release();
+ pi = tmp;
+ }
+ else if (r.type == Param::STRING)
+ {
+ AutoBuffer<String, 1> *tmp = new AutoBuffer<String, 1>(*r.ps);
+ release();
+ ps = tmp;
+ }
+ else if (r.type == Param::REAL)
+ {
+ AutoBuffer<double, 1> *tmp = new AutoBuffer<double, 1>(*r.pd);
+ release();
+ pd = tmp;
+ }
+
+ type = r.type;
+
+ return *this;
+}
+
+inline DictValue::DictValue(const DictValue &r)
+{
+ type = r.type;
+
+ if (r.type == Param::INT)
+ pi = new AutoBuffer<int64, 1>(*r.pi);
+ else if (r.type == Param::STRING)
+ ps = new AutoBuffer<String, 1>(*r.ps);
+ else if (r.type == Param::REAL)
+ pd = new AutoBuffer<double, 1>(*r.pd);
+}
+
+inline bool DictValue::isString() const
+{
+ return (type == Param::STRING);
+}
+
+inline bool DictValue::isInt() const
+{
+ return (type == Param::INT);
+}
+
+inline bool DictValue::isReal() const
+{
+ return (type == Param::REAL || type == Param::INT);
+}
+
+inline int DictValue::size() const
+{
+ switch (type)
+ {
+ case Param::INT:
+ return (int)pi->size();
+ break;
+ case Param::STRING:
+ return (int)ps->size();
+ break;
+ case Param::REAL:
+ return (int)pd->size();
+ break;
+ default:
+ CV_Error(Error::StsInternal, "");
+ return -1;
+ }
+}
+
+inline std::ostream &operator<<(std::ostream &stream, const DictValue &dictv)
+{
+ int i;
+
+ if (dictv.isInt())
+ {
+ for (i = 0; i < dictv.size() - 1; i++)
+ stream << dictv.get<int64>(i) << ", ";
+ stream << dictv.get<int64>(i);
+ }
+ else if (dictv.isReal())
+ {
+ for (i = 0; i < dictv.size() - 1; i++)
+ stream << dictv.get<double>(i) << ", ";
+ stream << dictv.get<double>(i);
+ }
+ else if (dictv.isString())
+ {
+ for (i = 0; i < dictv.size() - 1; i++)
+ stream << "\"" << dictv.get<String>(i) << "\", ";
+ stream << dictv.get<String>(i);
+ }
+
+ return stream;
+}
+
+/////////////////////////////////////////////////////////////////
+
+inline bool Dict::has(const String &key) const
+{
+ return dict.count(key) != 0;
+}
+
+inline DictValue *Dict::ptr(const String &key)
+{
+ _Dict::iterator i = dict.find(key);
+ return (i == dict.end()) ? NULL : &i->second;
+}
+
+inline const DictValue *Dict::ptr(const String &key) const
+{
+ _Dict::const_iterator i = dict.find(key);
+ return (i == dict.end()) ? NULL : &i->second;
+}
+
+inline const DictValue &Dict::get(const String &key) const
+{
+ _Dict::const_iterator i = dict.find(key);
+ if (i == dict.end())
+ CV_Error(Error::StsObjectNotFound, "Required argument \"" + key + "\" not found into dictionary");
+ return i->second;
+}
+
+template <typename T>
+inline T Dict::get(const String &key) const
+{
+ return this->get(key).get<T>();
+}
+
+template <typename T>
+inline T Dict::get(const String &key, const T &defaultValue) const
+{
+ _Dict::const_iterator i = dict.find(key);
+
+ if (i != dict.end())
+ return i->second.get<T>();
+ else
+ return defaultValue;
+}
+
+template<typename T>
+inline const T &Dict::set(const String &key, const T &value)
+{
+ _Dict::iterator i = dict.find(key);
+
+ if (i != dict.end())
+ i->second = DictValue(value);
+ else
+ dict.insert(std::make_pair(key, DictValue(value)));
+
+ return value;
+}
+
+inline std::ostream &operator<<(std::ostream &stream, const Dict &dict)
+{
+ Dict::_Dict::const_iterator it;
+ for (it = dict.dict.begin(); it != dict.dict.end(); it++)
+ stream << it->first << " : " << it->second << "\n";
+
+ return stream;
+}
+
+CV__DNN_EXPERIMENTAL_NS_END
+}
+}
+
+#endif
diff --git a/modules/dnn/include/opencv2/dnn/layer.details.hpp b/modules/dnn/include/opencv2/dnn/layer.details.hpp
new file mode 100644
index 0000000..82bd3b1
--- /dev/null
+++ b/modules/dnn/include/opencv2/dnn/layer.details.hpp
@@ -0,0 +1,78 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+//
+#ifndef OPENCV_DNN_LAYER_DETAILS_HPP
+#define OPENCV_DNN_LAYER_DETAILS_HPP
+
+#include <opencv2/dnn/layer.hpp>
+
+namespace cv {
+namespace dnn {
+CV__DNN_EXPERIMENTAL_NS_BEGIN
+
+/** @brief Registers layer constructor in runtime.
+* @param type string, containing type name of the layer.
+* @param constuctorFunc pointer to the function of type LayerRegister::Constuctor, which creates the layer.
+* @details This macros must be placed inside the function code.
+*/
+#define CV_DNN_REGISTER_LAYER_FUNC(type, constuctorFunc) \
+ cv::dnn::LayerFactory::registerLayer(#type, constuctorFunc);
+
+/** @brief Registers layer class in runtime.
+ * @param type string, containing type name of the layer.
+ * @param class C++ class, derived from Layer.
+ * @details This macros must be placed inside the function code.
+ */
+#define CV_DNN_REGISTER_LAYER_CLASS(type, class) \
+ cv::dnn::LayerFactory::registerLayer(#type, cv::dnn::details::_layerDynamicRegisterer<class>);
+
+/** @brief Registers layer constructor on module load time.
+* @param type string, containing type name of the layer.
+* @param constuctorFunc pointer to the function of type LayerRegister::Constuctor, which creates the layer.
+* @details This macros must be placed outside the function code.
+*/
+#define CV_DNN_REGISTER_LAYER_FUNC_STATIC(type, constuctorFunc) \
+static cv::dnn::details::_LayerStaticRegisterer __LayerStaticRegisterer_##type(#type, constuctorFunc);
+
+/** @brief Registers layer class on module load time.
+ * @param type string, containing type name of the layer.
+ * @param class C++ class, derived from Layer.
+ * @details This macros must be placed outside the function code.
+ */
+#define CV_DNN_REGISTER_LAYER_CLASS_STATIC(type, class) \
+Ptr<Layer> __LayerStaticRegisterer_func_##type(LayerParams ¶ms) \
+ { return Ptr<Layer>(new class(params)); } \
+static cv::dnn::details::_LayerStaticRegisterer __LayerStaticRegisterer_##type(#type, __LayerStaticRegisterer_func_##type);
+
+namespace details {
+
+template<typename LayerClass>
+Ptr<Layer> _layerDynamicRegisterer(LayerParams ¶ms)
+{
+ return Ptr<Layer>(LayerClass::create(params));
+}
+
+//allows automatically register created layer on module load time
+class _LayerStaticRegisterer
+{
+ String type;
+public:
+
+ _LayerStaticRegisterer(const String &layerType, LayerFactory::Constuctor layerConstuctor)
+ {
+ this->type = layerType;
+ LayerFactory::registerLayer(layerType, layerConstuctor);
+ }
+
+ ~_LayerStaticRegisterer()
+ {
+ LayerFactory::unregisterLayer(type);
+ }
+};
+
+} // namespace
+CV__DNN_EXPERIMENTAL_NS_END
+}} // namespace
+
+#endif
diff --git a/modules/dnn/include/opencv2/dnn/layer.hpp b/modules/dnn/include/opencv2/dnn/layer.hpp
new file mode 100644
index 0000000..3fb81f3
--- /dev/null
+++ b/modules/dnn/include/opencv2/dnn/layer.hpp
@@ -0,0 +1,85 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#ifndef OPENCV_DNN_LAYER_HPP
+#define OPENCV_DNN_LAYER_HPP
+#include <opencv2/dnn.hpp>
+
+namespace cv {
+namespace dnn {
+CV__DNN_EXPERIMENTAL_NS_BEGIN
+//! @addtogroup dnn
+//! @{
+//!
+//! @defgroup dnnLayerFactory Utilities for New Layers Registration
+//! @{
+
+/** @brief %Layer factory allows to create instances of registered layers. */
+class CV_EXPORTS LayerFactory
+{
+public:
+
+ //! Each Layer class must provide this function to the factory
+ typedef Ptr<Layer>(*Constuctor)(LayerParams ¶ms);
+
+ //! Registers the layer class with typename @p type and specified @p constructor. Thread-safe.
+ static void registerLayer(const String &type, Constuctor constructor);
+
+ //! Unregisters registered layer with specified type name. Thread-safe.
+ static void unregisterLayer(const String &type);
+
+ /** @brief Creates instance of registered layer.
+ * @param type type name of creating layer.
+ * @param params parameters which will be used for layer initialization.
+ * @note Thread-safe.
+ */
+ static Ptr<Layer> createLayerInstance(const String &type, LayerParams& params);
+
+private:
+ LayerFactory();
+};
+
+//! @}
+//! @}
+CV__DNN_EXPERIMENTAL_NS_END
+}
+}
+#endif
diff --git a/modules/dnn/include/opencv2/dnn/shape_utils.hpp b/modules/dnn/include/opencv2/dnn/shape_utils.hpp
new file mode 100644
index 0000000..e74b53c
--- /dev/null
+++ b/modules/dnn/include/opencv2/dnn/shape_utils.hpp
@@ -0,0 +1,197 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#ifndef OPENCV_DNN_DNN_SHAPE_UTILS_HPP
+#define OPENCV_DNN_DNN_SHAPE_UTILS_HPP
+
+#include <opencv2/core.hpp>
+#include <opencv2/core/types_c.h>
+#include <ostream>
+
+namespace cv {
+namespace dnn {
+CV__DNN_EXPERIMENTAL_NS_BEGIN
+
+//Useful shortcut
+inline std::ostream &operator<< (std::ostream &s, cv::Range &r)
+{
+ return s << "[" << r.start << ", " << r.end << ")";
+}
+
+//Slicing
+
+struct _Range : public cv::Range
+{
+ _Range(const Range &r) : cv::Range(r) {}
+ _Range(int start_, int size_ = 1) : cv::Range(start_, start_ + size_) {}
+};
+
+static inline Mat slice(const Mat &m, const _Range &r0)
+{
+ Range ranges[CV_MAX_DIM];
+ for (int i = 1; i < m.dims; i++)
+ ranges[i] = Range::all();
+ ranges[0] = r0;
+ return m(&ranges[0]);
+}
+
+static inline Mat slice(const Mat &m, const _Range &r0, const _Range &r1)
+{
+ CV_Assert(m.dims >= 2);
+ Range ranges[CV_MAX_DIM];
+ for (int i = 2; i < m.dims; i++)
+ ranges[i] = Range::all();
+ ranges[0] = r0;
+ ranges[1] = r1;
+ return m(&ranges[0]);
+}
+
+static inline Mat slice(const Mat &m, const _Range &r0, const _Range &r1, const _Range &r2)
+{
+ CV_Assert(m.dims >= 3);
+ Range ranges[CV_MAX_DIM];
+ for (int i = 3; i < m.dims; i++)
+ ranges[i] = Range::all();
+ ranges[0] = r0;
+ ranges[1] = r1;
+ ranges[2] = r2;
+ return m(&ranges[0]);
+}
+
+static inline Mat slice(const Mat &m, const _Range &r0, const _Range &r1, const _Range &r2, const _Range &r3)
+{
+ CV_Assert(m.dims >= 4);
+ Range ranges[CV_MAX_DIM];
+ for (int i = 4; i < m.dims; i++)
+ ranges[i] = Range::all();
+ ranges[0] = r0;
+ ranges[1] = r1;
+ ranges[2] = r2;
+ ranges[3] = r3;
+ return m(&ranges[0]);
+}
+
+static inline Mat getPlane(const Mat &m, int n, int cn)
+{
+ CV_Assert(m.dims > 2);
+ Range range[CV_MAX_DIM];
+ int sz[CV_MAX_DIM];
+ for(int i = 2; i < m.dims; i++)
+ {
+ sz[i-2] = m.size.p[i];
+ range[i] = Range::all();
+ }
+ range[0] = Range(n, n+1);
+ range[1] = Range(cn, cn+1);
+ return m(range).reshape(1, m.dims-2, sz);
+}
+
+static inline MatShape shape(const int* dims, const int n = 4)
+{
+ MatShape shape;
+ shape.assign(dims, dims + n);
+ return shape;
+}
+
+static inline MatShape shape(const Mat& mat)
+{
+ return shape(mat.size.p, mat.dims);
+}
+
+namespace {inline bool is_neg(int i) { return i < 0; }}
+
+static inline MatShape shape(int a0, int a1=-1, int a2=-1, int a3=-1)
+{
+ int dims[] = {a0, a1, a2, a3};
+ MatShape s = shape(dims);
+ s.erase(std::remove_if(s.begin(), s.end(), is_neg), s.end());
+ return s;
+}
+
+static inline int total(const MatShape& shape, int start = -1, int end = -1)
+{
+ if (start == -1) start = 0;
+ if (end == -1) end = (int)shape.size();
+
+ if (shape.empty())
+ return 0;
+
+ int elems = 1;
+ CV_Assert(start < (int)shape.size() && end <= (int)shape.size() &&
+ start <= end);
+ for(int i = start; i < end; i++)
+ {
+ elems *= shape[i];
+ }
+ return elems;
+}
+
+static inline MatShape concat(const MatShape& a, const MatShape& b)
+{
+ MatShape c = a;
+ c.insert(c.end(), b.begin(), b.end());
+
+ return c;
+}
+
+inline void print(const MatShape& shape, const String& name = "")
+{
+ printf("%s: [", name.c_str());
+ size_t i, n = shape.size();
+ for( i = 0; i < n; i++ )
+ printf(" %d", shape[i]);
+ printf(" ]\n");
+}
+
+inline int clamp(int ax, int dims)
+{
+ return ax < 0 ? ax + dims : ax;
+}
+
+inline int clamp(int ax, const MatShape& shape)
+{
+ return clamp(ax, (int)shape.size());
+}
+
+CV__DNN_EXPERIMENTAL_NS_END
+}
+}
+#endif
diff --git a/modules/dnn/misc/caffe/caffe.pb.cc b/modules/dnn/misc/caffe/caffe.pb.cc
new file mode 100644
index 0000000..f866183
--- /dev/null
+++ b/modules/dnn/misc/caffe/caffe.pb.cc
@@ -0,0 +1,53676 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: caffe.proto
+
+#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
+#include "caffe.pb.h"
+
+#include <algorithm>
+
+#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/stubs/port.h>
+#include <google/protobuf/stubs/once.h>
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/wire_format_lite_inl.h>
+#include <google/protobuf/descriptor.h>
+#include <google/protobuf/generated_message_reflection.h>
+#include <google/protobuf/reflection_ops.h>
+#include <google/protobuf/wire_format.h>
+// @@protoc_insertion_point(includes)
+
+namespace caffe {
+
+namespace {
+
+const ::google::protobuf::Descriptor* BlobShape_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ BlobShape_reflection_ = NULL;
+const ::google::protobuf::Descriptor* BlobProto_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ BlobProto_reflection_ = NULL;
+const ::google::protobuf::Descriptor* BlobProtoVector_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ BlobProtoVector_reflection_ = NULL;
+const ::google::protobuf::Descriptor* PermuteParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ PermuteParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* NormalizeBBoxParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ NormalizeBBoxParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* PriorBoxParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ PriorBoxParameter_reflection_ = NULL;
+const ::google::protobuf::EnumDescriptor* PriorBoxParameter_CodeType_descriptor_ = NULL;
+const ::google::protobuf::Descriptor* DetectionOutputParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ DetectionOutputParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* Datum_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ Datum_reflection_ = NULL;
+const ::google::protobuf::Descriptor* FillerParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ FillerParameter_reflection_ = NULL;
+const ::google::protobuf::EnumDescriptor* FillerParameter_VarianceNorm_descriptor_ = NULL;
+const ::google::protobuf::Descriptor* NetParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ NetParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* SolverParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ SolverParameter_reflection_ = NULL;
+const ::google::protobuf::EnumDescriptor* SolverParameter_SnapshotFormat_descriptor_ = NULL;
+const ::google::protobuf::EnumDescriptor* SolverParameter_SolverMode_descriptor_ = NULL;
+const ::google::protobuf::EnumDescriptor* SolverParameter_SolverType_descriptor_ = NULL;
+const ::google::protobuf::Descriptor* SolverState_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ SolverState_reflection_ = NULL;
+const ::google::protobuf::Descriptor* NetState_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ NetState_reflection_ = NULL;
+const ::google::protobuf::Descriptor* NetStateRule_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ NetStateRule_reflection_ = NULL;
+const ::google::protobuf::Descriptor* ParamSpec_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ ParamSpec_reflection_ = NULL;
+const ::google::protobuf::EnumDescriptor* ParamSpec_DimCheckMode_descriptor_ = NULL;
+const ::google::protobuf::Descriptor* LayerParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ LayerParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* TransformationParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ TransformationParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* LossParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ LossParameter_reflection_ = NULL;
+const ::google::protobuf::EnumDescriptor* LossParameter_NormalizationMode_descriptor_ = NULL;
+const ::google::protobuf::Descriptor* AccuracyParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ AccuracyParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* ArgMaxParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ ArgMaxParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* ConcatParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ ConcatParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* BatchNormParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ BatchNormParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* BiasParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ BiasParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* ContrastiveLossParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ ContrastiveLossParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* ConvolutionParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ ConvolutionParameter_reflection_ = NULL;
+const ::google::protobuf::EnumDescriptor* ConvolutionParameter_Engine_descriptor_ = NULL;
+const ::google::protobuf::Descriptor* CropParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ CropParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* DataParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ DataParameter_reflection_ = NULL;
+const ::google::protobuf::EnumDescriptor* DataParameter_DB_descriptor_ = NULL;
+const ::google::protobuf::Descriptor* NonMaximumSuppressionParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ NonMaximumSuppressionParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* SaveOutputParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ SaveOutputParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* DropoutParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ DropoutParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* DummyDataParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ DummyDataParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* EltwiseParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ EltwiseParameter_reflection_ = NULL;
+const ::google::protobuf::EnumDescriptor* EltwiseParameter_EltwiseOp_descriptor_ = NULL;
+const ::google::protobuf::Descriptor* ELUParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ ELUParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* EmbedParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ EmbedParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* ExpParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ ExpParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* FlattenParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ FlattenParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* HDF5DataParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ HDF5DataParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* HDF5OutputParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ HDF5OutputParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* HingeLossParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ HingeLossParameter_reflection_ = NULL;
+const ::google::protobuf::EnumDescriptor* HingeLossParameter_Norm_descriptor_ = NULL;
+const ::google::protobuf::Descriptor* ImageDataParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ ImageDataParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* InfogainLossParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ InfogainLossParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* InnerProductParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ InnerProductParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* InputParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ InputParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* LogParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ LogParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* LRNParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ LRNParameter_reflection_ = NULL;
+const ::google::protobuf::EnumDescriptor* LRNParameter_NormRegion_descriptor_ = NULL;
+const ::google::protobuf::EnumDescriptor* LRNParameter_Engine_descriptor_ = NULL;
+const ::google::protobuf::Descriptor* MemoryDataParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ MemoryDataParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* MVNParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ MVNParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* ParameterParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ ParameterParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* PoolingParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ PoolingParameter_reflection_ = NULL;
+const ::google::protobuf::EnumDescriptor* PoolingParameter_PoolMethod_descriptor_ = NULL;
+const ::google::protobuf::EnumDescriptor* PoolingParameter_Engine_descriptor_ = NULL;
+const ::google::protobuf::Descriptor* PowerParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ PowerParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* PythonParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ PythonParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* RecurrentParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ RecurrentParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* ReductionParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ ReductionParameter_reflection_ = NULL;
+const ::google::protobuf::EnumDescriptor* ReductionParameter_ReductionOp_descriptor_ = NULL;
+const ::google::protobuf::Descriptor* ReLUParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ ReLUParameter_reflection_ = NULL;
+const ::google::protobuf::EnumDescriptor* ReLUParameter_Engine_descriptor_ = NULL;
+const ::google::protobuf::Descriptor* ReshapeParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ ReshapeParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* ScaleParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ ScaleParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* SigmoidParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ SigmoidParameter_reflection_ = NULL;
+const ::google::protobuf::EnumDescriptor* SigmoidParameter_Engine_descriptor_ = NULL;
+const ::google::protobuf::Descriptor* SliceParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ SliceParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* SoftmaxParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ SoftmaxParameter_reflection_ = NULL;
+const ::google::protobuf::EnumDescriptor* SoftmaxParameter_Engine_descriptor_ = NULL;
+const ::google::protobuf::Descriptor* TanHParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ TanHParameter_reflection_ = NULL;
+const ::google::protobuf::EnumDescriptor* TanHParameter_Engine_descriptor_ = NULL;
+const ::google::protobuf::Descriptor* TileParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ TileParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* ThresholdParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ ThresholdParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* WindowDataParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ WindowDataParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* SPPParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ SPPParameter_reflection_ = NULL;
+const ::google::protobuf::EnumDescriptor* SPPParameter_PoolMethod_descriptor_ = NULL;
+const ::google::protobuf::EnumDescriptor* SPPParameter_Engine_descriptor_ = NULL;
+const ::google::protobuf::Descriptor* V1LayerParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ V1LayerParameter_reflection_ = NULL;
+const ::google::protobuf::EnumDescriptor* V1LayerParameter_LayerType_descriptor_ = NULL;
+const ::google::protobuf::EnumDescriptor* V1LayerParameter_DimCheckMode_descriptor_ = NULL;
+const ::google::protobuf::Descriptor* V0LayerParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ V0LayerParameter_reflection_ = NULL;
+const ::google::protobuf::EnumDescriptor* V0LayerParameter_PoolMethod_descriptor_ = NULL;
+const ::google::protobuf::Descriptor* PReLUParameter_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ PReLUParameter_reflection_ = NULL;
+const ::google::protobuf::Descriptor* NormalizedBBox_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ NormalizedBBox_reflection_ = NULL;
+const ::google::protobuf::EnumDescriptor* Phase_descriptor_ = NULL;
+
+} // namespace
+
+
+void protobuf_AssignDesc_caffe_2eproto() GOOGLE_ATTRIBUTE_COLD;
+void protobuf_AssignDesc_caffe_2eproto() {
+ protobuf_AddDesc_caffe_2eproto();
+ const ::google::protobuf::FileDescriptor* file =
+ ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
+ "caffe.proto");
+ GOOGLE_CHECK(file != NULL);
+ BlobShape_descriptor_ = file->message_type(0);
+ static const int BlobShape_offsets_[1] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobShape, dim_),
+ };
+ BlobShape_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ BlobShape_descriptor_,
+ BlobShape::internal_default_instance(),
+ BlobShape_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobShape, _has_bits_),
+ -1,
+ -1,
+ sizeof(BlobShape),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobShape, _internal_metadata_));
+ BlobProto_descriptor_ = file->message_type(1);
+ static const int BlobProto_offsets_[9] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, shape_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, data_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, diff_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, double_data_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, double_diff_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, num_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, channels_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, height_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, width_),
+ };
+ BlobProto_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ BlobProto_descriptor_,
+ BlobProto::internal_default_instance(),
+ BlobProto_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, _has_bits_),
+ -1,
+ -1,
+ sizeof(BlobProto),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProto, _internal_metadata_));
+ BlobProtoVector_descriptor_ = file->message_type(2);
+ static const int BlobProtoVector_offsets_[1] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProtoVector, blobs_),
+ };
+ BlobProtoVector_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ BlobProtoVector_descriptor_,
+ BlobProtoVector::internal_default_instance(),
+ BlobProtoVector_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProtoVector, _has_bits_),
+ -1,
+ -1,
+ sizeof(BlobProtoVector),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BlobProtoVector, _internal_metadata_));
+ PermuteParameter_descriptor_ = file->message_type(3);
+ static const int PermuteParameter_offsets_[1] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PermuteParameter, order_),
+ };
+ PermuteParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ PermuteParameter_descriptor_,
+ PermuteParameter::internal_default_instance(),
+ PermuteParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PermuteParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(PermuteParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PermuteParameter, _internal_metadata_));
+ NormalizeBBoxParameter_descriptor_ = file->message_type(4);
+ static const int NormalizeBBoxParameter_offsets_[4] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizeBBoxParameter, across_spatial_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizeBBoxParameter, scale_filler_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizeBBoxParameter, channel_shared_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizeBBoxParameter, eps_),
+ };
+ NormalizeBBoxParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ NormalizeBBoxParameter_descriptor_,
+ NormalizeBBoxParameter::internal_default_instance(),
+ NormalizeBBoxParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizeBBoxParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(NormalizeBBoxParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizeBBoxParameter, _internal_metadata_));
+ PriorBoxParameter_descriptor_ = file->message_type(5);
+ static const int PriorBoxParameter_offsets_[13] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, min_size_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, max_size_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, aspect_ratio_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, flip_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, clip_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, variance_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, img_size_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, img_h_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, img_w_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, step_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, step_h_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, step_w_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, offset_),
+ };
+ PriorBoxParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ PriorBoxParameter_descriptor_,
+ PriorBoxParameter::internal_default_instance(),
+ PriorBoxParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(PriorBoxParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, _internal_metadata_));
+ PriorBoxParameter_CodeType_descriptor_ = PriorBoxParameter_descriptor_->enum_type(0);
+ DetectionOutputParameter_descriptor_ = file->message_type(6);
+ static const int DetectionOutputParameter_offsets_[9] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, num_classes_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, share_location_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, background_label_id_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, nms_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, save_output_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, code_type_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, variance_encoded_in_target_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, keep_top_k_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, confidence_threshold_),
+ };
+ DetectionOutputParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ DetectionOutputParameter_descriptor_,
+ DetectionOutputParameter::internal_default_instance(),
+ DetectionOutputParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(DetectionOutputParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DetectionOutputParameter, _internal_metadata_));
+ Datum_descriptor_ = file->message_type(7);
+ static const int Datum_offsets_[7] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Datum, channels_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Datum, height_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Datum, width_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Datum, data_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Datum, label_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Datum, float_data_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Datum, encoded_),
+ };
+ Datum_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ Datum_descriptor_,
+ Datum::internal_default_instance(),
+ Datum_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Datum, _has_bits_),
+ -1,
+ -1,
+ sizeof(Datum),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Datum, _internal_metadata_));
+ FillerParameter_descriptor_ = file->message_type(8);
+ static const int FillerParameter_offsets_[8] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, type_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, value_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, min_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, max_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, mean_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, std_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, sparse_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, variance_norm_),
+ };
+ FillerParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ FillerParameter_descriptor_,
+ FillerParameter::internal_default_instance(),
+ FillerParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(FillerParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FillerParameter, _internal_metadata_));
+ FillerParameter_VarianceNorm_descriptor_ = FillerParameter_descriptor_->enum_type(0);
+ NetParameter_descriptor_ = file->message_type(9);
+ static const int NetParameter_offsets_[9] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, input_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, input_shape_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, input_dim_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, force_backward_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, state_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, debug_info_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, layer_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, layers_),
+ };
+ NetParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ NetParameter_descriptor_,
+ NetParameter::internal_default_instance(),
+ NetParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(NetParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetParameter, _internal_metadata_));
+ SolverParameter_descriptor_ = file->message_type(10);
+ static const int SolverParameter_offsets_[40] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, net_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, net_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, train_net_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, test_net_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, train_net_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, test_net_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, train_state_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, test_state_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, test_iter_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, test_interval_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, test_compute_loss_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, test_initialization_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, base_lr_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, display_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, average_loss_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, max_iter_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, iter_size_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, lr_policy_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, gamma_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, power_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, momentum_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, weight_decay_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, regularization_type_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, stepsize_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, stepvalue_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, clip_gradients_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, snapshot_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, snapshot_prefix_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, snapshot_diff_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, snapshot_format_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, solver_mode_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, device_id_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, random_seed_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, type_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, delta_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, momentum2_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, rms_decay_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, debug_info_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, snapshot_after_train_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, solver_type_),
+ };
+ SolverParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ SolverParameter_descriptor_,
+ SolverParameter::internal_default_instance(),
+ SolverParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(SolverParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverParameter, _internal_metadata_));
+ SolverParameter_SnapshotFormat_descriptor_ = SolverParameter_descriptor_->enum_type(0);
+ SolverParameter_SolverMode_descriptor_ = SolverParameter_descriptor_->enum_type(1);
+ SolverParameter_SolverType_descriptor_ = SolverParameter_descriptor_->enum_type(2);
+ SolverState_descriptor_ = file->message_type(11);
+ static const int SolverState_offsets_[4] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverState, iter_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverState, learned_net_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverState, history_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverState, current_step_),
+ };
+ SolverState_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ SolverState_descriptor_,
+ SolverState::internal_default_instance(),
+ SolverState_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverState, _has_bits_),
+ -1,
+ -1,
+ sizeof(SolverState),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SolverState, _internal_metadata_));
+ NetState_descriptor_ = file->message_type(12);
+ static const int NetState_offsets_[3] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetState, phase_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetState, level_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetState, stage_),
+ };
+ NetState_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ NetState_descriptor_,
+ NetState::internal_default_instance(),
+ NetState_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetState, _has_bits_),
+ -1,
+ -1,
+ sizeof(NetState),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetState, _internal_metadata_));
+ NetStateRule_descriptor_ = file->message_type(13);
+ static const int NetStateRule_offsets_[5] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetStateRule, phase_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetStateRule, min_level_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetStateRule, max_level_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetStateRule, stage_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetStateRule, not_stage_),
+ };
+ NetStateRule_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ NetStateRule_descriptor_,
+ NetStateRule::internal_default_instance(),
+ NetStateRule_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetStateRule, _has_bits_),
+ -1,
+ -1,
+ sizeof(NetStateRule),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NetStateRule, _internal_metadata_));
+ ParamSpec_descriptor_ = file->message_type(14);
+ static const int ParamSpec_offsets_[4] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ParamSpec, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ParamSpec, share_mode_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ParamSpec, lr_mult_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ParamSpec, decay_mult_),
+ };
+ ParamSpec_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ ParamSpec_descriptor_,
+ ParamSpec::internal_default_instance(),
+ ParamSpec_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ParamSpec, _has_bits_),
+ -1,
+ -1,
+ sizeof(ParamSpec),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ParamSpec, _internal_metadata_));
+ ParamSpec_DimCheckMode_descriptor_ = ParamSpec_descriptor_->enum_type(0);
+ LayerParameter_descriptor_ = file->message_type(15);
+ static const int LayerParameter_offsets_[62] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, type_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, bottom_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, top_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, phase_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, loss_weight_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, blobs_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, propagate_down_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, include_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, exclude_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, transform_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, loss_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, accuracy_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, argmax_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, batch_norm_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, bias_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, concat_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, contrastive_loss_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, convolution_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, crop_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, data_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, detection_output_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, dropout_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, dummy_data_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, eltwise_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, elu_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, embed_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, exp_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, flatten_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, hdf5_data_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, hdf5_output_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, hinge_loss_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, image_data_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, infogain_loss_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, inner_product_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, input_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, log_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, lrn_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, memory_data_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, mvn_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, norm_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, permute_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, parameter_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, pooling_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, power_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, prelu_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, prior_box_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, python_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, recurrent_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, reduction_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, relu_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, reshape_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, scale_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, sigmoid_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, softmax_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, spp_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, slice_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, tanh_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, threshold_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, tile_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, window_data_param_),
+ };
+ LayerParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ LayerParameter_descriptor_,
+ LayerParameter::internal_default_instance(),
+ LayerParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(LayerParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LayerParameter, _internal_metadata_));
+ TransformationParameter_descriptor_ = file->message_type(16);
+ static const int TransformationParameter_offsets_[7] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TransformationParameter, scale_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TransformationParameter, mirror_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TransformationParameter, crop_size_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TransformationParameter, mean_file_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TransformationParameter, mean_value_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TransformationParameter, force_color_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TransformationParameter, force_gray_),
+ };
+ TransformationParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ TransformationParameter_descriptor_,
+ TransformationParameter::internal_default_instance(),
+ TransformationParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TransformationParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(TransformationParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TransformationParameter, _internal_metadata_));
+ LossParameter_descriptor_ = file->message_type(17);
+ static const int LossParameter_offsets_[3] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LossParameter, ignore_label_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LossParameter, normalization_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LossParameter, normalize_),
+ };
+ LossParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ LossParameter_descriptor_,
+ LossParameter::internal_default_instance(),
+ LossParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LossParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(LossParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LossParameter, _internal_metadata_));
+ LossParameter_NormalizationMode_descriptor_ = LossParameter_descriptor_->enum_type(0);
+ AccuracyParameter_descriptor_ = file->message_type(18);
+ static const int AccuracyParameter_offsets_[3] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(AccuracyParameter, top_k_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(AccuracyParameter, axis_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(AccuracyParameter, ignore_label_),
+ };
+ AccuracyParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ AccuracyParameter_descriptor_,
+ AccuracyParameter::internal_default_instance(),
+ AccuracyParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(AccuracyParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(AccuracyParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(AccuracyParameter, _internal_metadata_));
+ ArgMaxParameter_descriptor_ = file->message_type(19);
+ static const int ArgMaxParameter_offsets_[3] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ArgMaxParameter, out_max_val_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ArgMaxParameter, top_k_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ArgMaxParameter, axis_),
+ };
+ ArgMaxParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ ArgMaxParameter_descriptor_,
+ ArgMaxParameter::internal_default_instance(),
+ ArgMaxParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ArgMaxParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(ArgMaxParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ArgMaxParameter, _internal_metadata_));
+ ConcatParameter_descriptor_ = file->message_type(20);
+ static const int ConcatParameter_offsets_[2] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConcatParameter, axis_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConcatParameter, concat_dim_),
+ };
+ ConcatParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ ConcatParameter_descriptor_,
+ ConcatParameter::internal_default_instance(),
+ ConcatParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConcatParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(ConcatParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConcatParameter, _internal_metadata_));
+ BatchNormParameter_descriptor_ = file->message_type(21);
+ static const int BatchNormParameter_offsets_[3] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BatchNormParameter, use_global_stats_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BatchNormParameter, moving_average_fraction_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BatchNormParameter, eps_),
+ };
+ BatchNormParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ BatchNormParameter_descriptor_,
+ BatchNormParameter::internal_default_instance(),
+ BatchNormParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BatchNormParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(BatchNormParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BatchNormParameter, _internal_metadata_));
+ BiasParameter_descriptor_ = file->message_type(22);
+ static const int BiasParameter_offsets_[3] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BiasParameter, axis_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BiasParameter, num_axes_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BiasParameter, filler_),
+ };
+ BiasParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ BiasParameter_descriptor_,
+ BiasParameter::internal_default_instance(),
+ BiasParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BiasParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(BiasParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BiasParameter, _internal_metadata_));
+ ContrastiveLossParameter_descriptor_ = file->message_type(23);
+ static const int ContrastiveLossParameter_offsets_[2] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ContrastiveLossParameter, margin_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ContrastiveLossParameter, legacy_version_),
+ };
+ ContrastiveLossParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ ContrastiveLossParameter_descriptor_,
+ ContrastiveLossParameter::internal_default_instance(),
+ ContrastiveLossParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ContrastiveLossParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(ContrastiveLossParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ContrastiveLossParameter, _internal_metadata_));
+ ConvolutionParameter_descriptor_ = file->message_type(24);
+ static const int ConvolutionParameter_offsets_[18] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, num_output_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, bias_term_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, pad_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, kernel_size_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, stride_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, dilation_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, pad_h_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, pad_w_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, kernel_h_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, kernel_w_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, stride_h_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, stride_w_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, group_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, weight_filler_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, bias_filler_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, engine_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, axis_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, force_nd_im2col_),
+ };
+ ConvolutionParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ ConvolutionParameter_descriptor_,
+ ConvolutionParameter::internal_default_instance(),
+ ConvolutionParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(ConvolutionParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ConvolutionParameter, _internal_metadata_));
+ ConvolutionParameter_Engine_descriptor_ = ConvolutionParameter_descriptor_->enum_type(0);
+ CropParameter_descriptor_ = file->message_type(25);
+ static const int CropParameter_offsets_[2] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CropParameter, axis_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CropParameter, offset_),
+ };
+ CropParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ CropParameter_descriptor_,
+ CropParameter::internal_default_instance(),
+ CropParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CropParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(CropParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CropParameter, _internal_metadata_));
+ DataParameter_descriptor_ = file->message_type(26);
+ static const int DataParameter_offsets_[10] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, source_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, batch_size_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, rand_skip_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, backend_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, scale_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, mean_file_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, crop_size_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, mirror_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, force_encoded_color_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, prefetch_),
+ };
+ DataParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ DataParameter_descriptor_,
+ DataParameter::internal_default_instance(),
+ DataParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(DataParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DataParameter, _internal_metadata_));
+ DataParameter_DB_descriptor_ = DataParameter_descriptor_->enum_type(0);
+ NonMaximumSuppressionParameter_descriptor_ = file->message_type(27);
+ static const int NonMaximumSuppressionParameter_offsets_[3] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NonMaximumSuppressionParameter, nms_threshold_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NonMaximumSuppressionParameter, top_k_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NonMaximumSuppressionParameter, eta_),
+ };
+ NonMaximumSuppressionParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ NonMaximumSuppressionParameter_descriptor_,
+ NonMaximumSuppressionParameter::internal_default_instance(),
+ NonMaximumSuppressionParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NonMaximumSuppressionParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(NonMaximumSuppressionParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NonMaximumSuppressionParameter, _internal_metadata_));
+ SaveOutputParameter_descriptor_ = file->message_type(28);
+ static const int SaveOutputParameter_offsets_[6] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SaveOutputParameter, output_directory_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SaveOutputParameter, output_name_prefix_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SaveOutputParameter, output_format_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SaveOutputParameter, label_map_file_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SaveOutputParameter, name_size_file_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SaveOutputParameter, num_test_image_),
+ };
+ SaveOutputParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ SaveOutputParameter_descriptor_,
+ SaveOutputParameter::internal_default_instance(),
+ SaveOutputParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SaveOutputParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(SaveOutputParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SaveOutputParameter, _internal_metadata_));
+ DropoutParameter_descriptor_ = file->message_type(29);
+ static const int DropoutParameter_offsets_[1] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DropoutParameter, dropout_ratio_),
+ };
+ DropoutParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ DropoutParameter_descriptor_,
+ DropoutParameter::internal_default_instance(),
+ DropoutParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DropoutParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(DropoutParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DropoutParameter, _internal_metadata_));
+ DummyDataParameter_descriptor_ = file->message_type(30);
+ static const int DummyDataParameter_offsets_[6] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DummyDataParameter, data_filler_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DummyDataParameter, shape_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DummyDataParameter, num_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DummyDataParameter, channels_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DummyDataParameter, height_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DummyDataParameter, width_),
+ };
+ DummyDataParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ DummyDataParameter_descriptor_,
+ DummyDataParameter::internal_default_instance(),
+ DummyDataParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DummyDataParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(DummyDataParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DummyDataParameter, _internal_metadata_));
+ EltwiseParameter_descriptor_ = file->message_type(31);
+ static const int EltwiseParameter_offsets_[3] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EltwiseParameter, operation_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EltwiseParameter, coeff_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EltwiseParameter, stable_prod_grad_),
+ };
+ EltwiseParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ EltwiseParameter_descriptor_,
+ EltwiseParameter::internal_default_instance(),
+ EltwiseParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EltwiseParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(EltwiseParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EltwiseParameter, _internal_metadata_));
+ EltwiseParameter_EltwiseOp_descriptor_ = EltwiseParameter_descriptor_->enum_type(0);
+ ELUParameter_descriptor_ = file->message_type(32);
+ static const int ELUParameter_offsets_[1] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ELUParameter, alpha_),
+ };
+ ELUParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ ELUParameter_descriptor_,
+ ELUParameter::internal_default_instance(),
+ ELUParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ELUParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(ELUParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ELUParameter, _internal_metadata_));
+ EmbedParameter_descriptor_ = file->message_type(33);
+ static const int EmbedParameter_offsets_[5] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EmbedParameter, num_output_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EmbedParameter, input_dim_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EmbedParameter, bias_term_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EmbedParameter, weight_filler_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EmbedParameter, bias_filler_),
+ };
+ EmbedParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ EmbedParameter_descriptor_,
+ EmbedParameter::internal_default_instance(),
+ EmbedParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EmbedParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(EmbedParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EmbedParameter, _internal_metadata_));
+ ExpParameter_descriptor_ = file->message_type(34);
+ static const int ExpParameter_offsets_[3] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExpParameter, base_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExpParameter, scale_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExpParameter, shift_),
+ };
+ ExpParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ ExpParameter_descriptor_,
+ ExpParameter::internal_default_instance(),
+ ExpParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExpParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(ExpParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ExpParameter, _internal_metadata_));
+ FlattenParameter_descriptor_ = file->message_type(35);
+ static const int FlattenParameter_offsets_[2] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FlattenParameter, axis_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FlattenParameter, end_axis_),
+ };
+ FlattenParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ FlattenParameter_descriptor_,
+ FlattenParameter::internal_default_instance(),
+ FlattenParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FlattenParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(FlattenParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FlattenParameter, _internal_metadata_));
+ HDF5DataParameter_descriptor_ = file->message_type(36);
+ static const int HDF5DataParameter_offsets_[3] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5DataParameter, source_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5DataParameter, batch_size_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5DataParameter, shuffle_),
+ };
+ HDF5DataParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ HDF5DataParameter_descriptor_,
+ HDF5DataParameter::internal_default_instance(),
+ HDF5DataParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5DataParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(HDF5DataParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5DataParameter, _internal_metadata_));
+ HDF5OutputParameter_descriptor_ = file->message_type(37);
+ static const int HDF5OutputParameter_offsets_[1] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5OutputParameter, file_name_),
+ };
+ HDF5OutputParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ HDF5OutputParameter_descriptor_,
+ HDF5OutputParameter::internal_default_instance(),
+ HDF5OutputParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5OutputParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(HDF5OutputParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HDF5OutputParameter, _internal_metadata_));
+ HingeLossParameter_descriptor_ = file->message_type(38);
+ static const int HingeLossParameter_offsets_[1] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HingeLossParameter, norm_),
+ };
+ HingeLossParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ HingeLossParameter_descriptor_,
+ HingeLossParameter::internal_default_instance(),
+ HingeLossParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HingeLossParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(HingeLossParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(HingeLossParameter, _internal_metadata_));
+ HingeLossParameter_Norm_descriptor_ = HingeLossParameter_descriptor_->enum_type(0);
+ ImageDataParameter_descriptor_ = file->message_type(39);
+ static const int ImageDataParameter_offsets_[12] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, source_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, batch_size_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, rand_skip_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, shuffle_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, new_height_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, new_width_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, is_color_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, scale_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, mean_file_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, crop_size_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, mirror_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, root_folder_),
+ };
+ ImageDataParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ ImageDataParameter_descriptor_,
+ ImageDataParameter::internal_default_instance(),
+ ImageDataParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(ImageDataParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ImageDataParameter, _internal_metadata_));
+ InfogainLossParameter_descriptor_ = file->message_type(40);
+ static const int InfogainLossParameter_offsets_[1] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InfogainLossParameter, source_),
+ };
+ InfogainLossParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ InfogainLossParameter_descriptor_,
+ InfogainLossParameter::internal_default_instance(),
+ InfogainLossParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InfogainLossParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(InfogainLossParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InfogainLossParameter, _internal_metadata_));
+ InnerProductParameter_descriptor_ = file->message_type(41);
+ static const int InnerProductParameter_offsets_[6] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InnerProductParameter, num_output_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InnerProductParameter, bias_term_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InnerProductParameter, weight_filler_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InnerProductParameter, bias_filler_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InnerProductParameter, axis_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InnerProductParameter, transpose_),
+ };
+ InnerProductParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ InnerProductParameter_descriptor_,
+ InnerProductParameter::internal_default_instance(),
+ InnerProductParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InnerProductParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(InnerProductParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InnerProductParameter, _internal_metadata_));
+ InputParameter_descriptor_ = file->message_type(42);
+ static const int InputParameter_offsets_[1] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InputParameter, shape_),
+ };
+ InputParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ InputParameter_descriptor_,
+ InputParameter::internal_default_instance(),
+ InputParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InputParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(InputParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(InputParameter, _internal_metadata_));
+ LogParameter_descriptor_ = file->message_type(43);
+ static const int LogParameter_offsets_[3] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LogParameter, base_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LogParameter, scale_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LogParameter, shift_),
+ };
+ LogParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ LogParameter_descriptor_,
+ LogParameter::internal_default_instance(),
+ LogParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LogParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(LogParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LogParameter, _internal_metadata_));
+ LRNParameter_descriptor_ = file->message_type(44);
+ static const int LRNParameter_offsets_[6] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LRNParameter, local_size_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LRNParameter, alpha_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LRNParameter, beta_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LRNParameter, norm_region_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LRNParameter, k_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LRNParameter, engine_),
+ };
+ LRNParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ LRNParameter_descriptor_,
+ LRNParameter::internal_default_instance(),
+ LRNParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LRNParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(LRNParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(LRNParameter, _internal_metadata_));
+ LRNParameter_NormRegion_descriptor_ = LRNParameter_descriptor_->enum_type(0);
+ LRNParameter_Engine_descriptor_ = LRNParameter_descriptor_->enum_type(1);
+ MemoryDataParameter_descriptor_ = file->message_type(45);
+ static const int MemoryDataParameter_offsets_[4] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MemoryDataParameter, batch_size_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MemoryDataParameter, channels_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MemoryDataParameter, height_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MemoryDataParameter, width_),
+ };
+ MemoryDataParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ MemoryDataParameter_descriptor_,
+ MemoryDataParameter::internal_default_instance(),
+ MemoryDataParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MemoryDataParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(MemoryDataParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MemoryDataParameter, _internal_metadata_));
+ MVNParameter_descriptor_ = file->message_type(46);
+ static const int MVNParameter_offsets_[3] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MVNParameter, normalize_variance_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MVNParameter, across_channels_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MVNParameter, eps_),
+ };
+ MVNParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ MVNParameter_descriptor_,
+ MVNParameter::internal_default_instance(),
+ MVNParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MVNParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(MVNParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MVNParameter, _internal_metadata_));
+ ParameterParameter_descriptor_ = file->message_type(47);
+ static const int ParameterParameter_offsets_[1] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ParameterParameter, shape_),
+ };
+ ParameterParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ ParameterParameter_descriptor_,
+ ParameterParameter::internal_default_instance(),
+ ParameterParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ParameterParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(ParameterParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ParameterParameter, _internal_metadata_));
+ PoolingParameter_descriptor_ = file->message_type(48);
+ static const int PoolingParameter_offsets_[12] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, pool_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, pad_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, pad_h_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, pad_w_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, kernel_size_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, kernel_h_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, kernel_w_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, stride_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, stride_h_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, stride_w_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, engine_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, global_pooling_),
+ };
+ PoolingParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ PoolingParameter_descriptor_,
+ PoolingParameter::internal_default_instance(),
+ PoolingParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(PoolingParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PoolingParameter, _internal_metadata_));
+ PoolingParameter_PoolMethod_descriptor_ = PoolingParameter_descriptor_->enum_type(0);
+ PoolingParameter_Engine_descriptor_ = PoolingParameter_descriptor_->enum_type(1);
+ PowerParameter_descriptor_ = file->message_type(49);
+ static const int PowerParameter_offsets_[3] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PowerParameter, power_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PowerParameter, scale_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PowerParameter, shift_),
+ };
+ PowerParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ PowerParameter_descriptor_,
+ PowerParameter::internal_default_instance(),
+ PowerParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PowerParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(PowerParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PowerParameter, _internal_metadata_));
+ PythonParameter_descriptor_ = file->message_type(50);
+ static const int PythonParameter_offsets_[4] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PythonParameter, module_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PythonParameter, layer_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PythonParameter, param_str_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PythonParameter, share_in_parallel_),
+ };
+ PythonParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ PythonParameter_descriptor_,
+ PythonParameter::internal_default_instance(),
+ PythonParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PythonParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(PythonParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PythonParameter, _internal_metadata_));
+ RecurrentParameter_descriptor_ = file->message_type(51);
+ static const int RecurrentParameter_offsets_[5] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RecurrentParameter, num_output_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RecurrentParameter, weight_filler_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RecurrentParameter, bias_filler_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RecurrentParameter, debug_info_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RecurrentParameter, expose_hidden_),
+ };
+ RecurrentParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ RecurrentParameter_descriptor_,
+ RecurrentParameter::internal_default_instance(),
+ RecurrentParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RecurrentParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(RecurrentParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(RecurrentParameter, _internal_metadata_));
+ ReductionParameter_descriptor_ = file->message_type(52);
+ static const int ReductionParameter_offsets_[3] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReductionParameter, operation_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReductionParameter, axis_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReductionParameter, coeff_),
+ };
+ ReductionParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ ReductionParameter_descriptor_,
+ ReductionParameter::internal_default_instance(),
+ ReductionParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReductionParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(ReductionParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReductionParameter, _internal_metadata_));
+ ReductionParameter_ReductionOp_descriptor_ = ReductionParameter_descriptor_->enum_type(0);
+ ReLUParameter_descriptor_ = file->message_type(53);
+ static const int ReLUParameter_offsets_[2] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReLUParameter, negative_slope_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReLUParameter, engine_),
+ };
+ ReLUParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ ReLUParameter_descriptor_,
+ ReLUParameter::internal_default_instance(),
+ ReLUParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReLUParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(ReLUParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReLUParameter, _internal_metadata_));
+ ReLUParameter_Engine_descriptor_ = ReLUParameter_descriptor_->enum_type(0);
+ ReshapeParameter_descriptor_ = file->message_type(54);
+ static const int ReshapeParameter_offsets_[3] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReshapeParameter, shape_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReshapeParameter, axis_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReshapeParameter, num_axes_),
+ };
+ ReshapeParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ ReshapeParameter_descriptor_,
+ ReshapeParameter::internal_default_instance(),
+ ReshapeParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReshapeParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(ReshapeParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ReshapeParameter, _internal_metadata_));
+ ScaleParameter_descriptor_ = file->message_type(55);
+ static const int ScaleParameter_offsets_[5] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ScaleParameter, axis_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ScaleParameter, num_axes_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ScaleParameter, filler_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ScaleParameter, bias_term_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ScaleParameter, bias_filler_),
+ };
+ ScaleParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ ScaleParameter_descriptor_,
+ ScaleParameter::internal_default_instance(),
+ ScaleParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ScaleParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(ScaleParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ScaleParameter, _internal_metadata_));
+ SigmoidParameter_descriptor_ = file->message_type(56);
+ static const int SigmoidParameter_offsets_[1] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SigmoidParameter, engine_),
+ };
+ SigmoidParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ SigmoidParameter_descriptor_,
+ SigmoidParameter::internal_default_instance(),
+ SigmoidParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SigmoidParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(SigmoidParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SigmoidParameter, _internal_metadata_));
+ SigmoidParameter_Engine_descriptor_ = SigmoidParameter_descriptor_->enum_type(0);
+ SliceParameter_descriptor_ = file->message_type(57);
+ static const int SliceParameter_offsets_[3] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SliceParameter, axis_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SliceParameter, slice_point_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SliceParameter, slice_dim_),
+ };
+ SliceParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ SliceParameter_descriptor_,
+ SliceParameter::internal_default_instance(),
+ SliceParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SliceParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(SliceParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SliceParameter, _internal_metadata_));
+ SoftmaxParameter_descriptor_ = file->message_type(58);
+ static const int SoftmaxParameter_offsets_[2] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SoftmaxParameter, engine_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SoftmaxParameter, axis_),
+ };
+ SoftmaxParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ SoftmaxParameter_descriptor_,
+ SoftmaxParameter::internal_default_instance(),
+ SoftmaxParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SoftmaxParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(SoftmaxParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SoftmaxParameter, _internal_metadata_));
+ SoftmaxParameter_Engine_descriptor_ = SoftmaxParameter_descriptor_->enum_type(0);
+ TanHParameter_descriptor_ = file->message_type(59);
+ static const int TanHParameter_offsets_[1] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TanHParameter, engine_),
+ };
+ TanHParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ TanHParameter_descriptor_,
+ TanHParameter::internal_default_instance(),
+ TanHParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TanHParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(TanHParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TanHParameter, _internal_metadata_));
+ TanHParameter_Engine_descriptor_ = TanHParameter_descriptor_->enum_type(0);
+ TileParameter_descriptor_ = file->message_type(60);
+ static const int TileParameter_offsets_[2] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TileParameter, axis_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TileParameter, tiles_),
+ };
+ TileParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ TileParameter_descriptor_,
+ TileParameter::internal_default_instance(),
+ TileParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TileParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(TileParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TileParameter, _internal_metadata_));
+ ThresholdParameter_descriptor_ = file->message_type(61);
+ static const int ThresholdParameter_offsets_[1] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ThresholdParameter, threshold_),
+ };
+ ThresholdParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ ThresholdParameter_descriptor_,
+ ThresholdParameter::internal_default_instance(),
+ ThresholdParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ThresholdParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(ThresholdParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ThresholdParameter, _internal_metadata_));
+ WindowDataParameter_descriptor_ = file->message_type(62);
+ static const int WindowDataParameter_offsets_[13] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, source_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, scale_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, mean_file_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, batch_size_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, crop_size_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, mirror_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, fg_threshold_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, bg_threshold_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, fg_fraction_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, context_pad_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, crop_mode_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, cache_images_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, root_folder_),
+ };
+ WindowDataParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ WindowDataParameter_descriptor_,
+ WindowDataParameter::internal_default_instance(),
+ WindowDataParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(WindowDataParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(WindowDataParameter, _internal_metadata_));
+ SPPParameter_descriptor_ = file->message_type(63);
+ static const int SPPParameter_offsets_[3] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SPPParameter, pyramid_height_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SPPParameter, pool_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SPPParameter, engine_),
+ };
+ SPPParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ SPPParameter_descriptor_,
+ SPPParameter::internal_default_instance(),
+ SPPParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SPPParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(SPPParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SPPParameter, _internal_metadata_));
+ SPPParameter_PoolMethod_descriptor_ = SPPParameter_descriptor_->enum_type(0);
+ SPPParameter_Engine_descriptor_ = SPPParameter_descriptor_->enum_type(1);
+ V1LayerParameter_descriptor_ = file->message_type(64);
+ static const int V1LayerParameter_offsets_[43] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, bottom_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, top_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, include_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, exclude_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, type_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, blobs_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, blob_share_mode_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, blobs_lr_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, weight_decay_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, loss_weight_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, accuracy_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, argmax_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, concat_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, contrastive_loss_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, convolution_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, data_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, dropout_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, dummy_data_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, eltwise_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, exp_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, hdf5_data_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, hdf5_output_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, hinge_loss_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, image_data_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, infogain_loss_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, inner_product_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, lrn_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, memory_data_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, mvn_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, pooling_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, power_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, relu_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, sigmoid_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, softmax_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, slice_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, tanh_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, threshold_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, window_data_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, transform_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, loss_param_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, layer_),
+ };
+ V1LayerParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ V1LayerParameter_descriptor_,
+ V1LayerParameter::internal_default_instance(),
+ V1LayerParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(V1LayerParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V1LayerParameter, _internal_metadata_));
+ V1LayerParameter_LayerType_descriptor_ = V1LayerParameter_descriptor_->enum_type(0);
+ V1LayerParameter_DimCheckMode_descriptor_ = V1LayerParameter_descriptor_->enum_type(1);
+ V0LayerParameter_descriptor_ = file->message_type(65);
+ static const int V0LayerParameter_offsets_[38] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, name_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, type_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, num_output_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, biasterm_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, weight_filler_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, bias_filler_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, pad_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, kernelsize_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, group_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, stride_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, pool_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, dropout_ratio_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, local_size_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, alpha_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, beta_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, k_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, source_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, scale_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, meanfile_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, batchsize_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, cropsize_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, mirror_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, blobs_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, blobs_lr_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, weight_decay_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, rand_skip_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, det_fg_threshold_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, det_bg_threshold_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, det_fg_fraction_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, det_context_pad_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, det_crop_mode_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, new_num_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, new_channels_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, new_height_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, new_width_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, shuffle_images_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, concat_dim_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, hdf5_output_param_),
+ };
+ V0LayerParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ V0LayerParameter_descriptor_,
+ V0LayerParameter::internal_default_instance(),
+ V0LayerParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(V0LayerParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(V0LayerParameter, _internal_metadata_));
+ V0LayerParameter_PoolMethod_descriptor_ = V0LayerParameter_descriptor_->enum_type(0);
+ PReLUParameter_descriptor_ = file->message_type(66);
+ static const int PReLUParameter_offsets_[2] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PReLUParameter, filler_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PReLUParameter, channel_shared_),
+ };
+ PReLUParameter_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ PReLUParameter_descriptor_,
+ PReLUParameter::internal_default_instance(),
+ PReLUParameter_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PReLUParameter, _has_bits_),
+ -1,
+ -1,
+ sizeof(PReLUParameter),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PReLUParameter, _internal_metadata_));
+ NormalizedBBox_descriptor_ = file->message_type(67);
+ static const int NormalizedBBox_offsets_[8] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, xmin_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, ymin_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, xmax_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, ymax_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, label_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, difficult_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, score_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, size_),
+ };
+ NormalizedBBox_reflection_ =
+ ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
+ NormalizedBBox_descriptor_,
+ NormalizedBBox::internal_default_instance(),
+ NormalizedBBox_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, _has_bits_),
+ -1,
+ -1,
+ sizeof(NormalizedBBox),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizedBBox, _internal_metadata_));
+ Phase_descriptor_ = file->enum_type(0);
+}
+
+namespace {
+
+GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
+void protobuf_AssignDescriptorsOnce() {
+ ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
+ &protobuf_AssignDesc_caffe_2eproto);
+}
+
+void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;
+void protobuf_RegisterTypes(const ::std::string&) {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ BlobShape_descriptor_, BlobShape::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ BlobProto_descriptor_, BlobProto::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ BlobProtoVector_descriptor_, BlobProtoVector::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ PermuteParameter_descriptor_, PermuteParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ NormalizeBBoxParameter_descriptor_, NormalizeBBoxParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ PriorBoxParameter_descriptor_, PriorBoxParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ DetectionOutputParameter_descriptor_, DetectionOutputParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ Datum_descriptor_, Datum::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ FillerParameter_descriptor_, FillerParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ NetParameter_descriptor_, NetParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ SolverParameter_descriptor_, SolverParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ SolverState_descriptor_, SolverState::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ NetState_descriptor_, NetState::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ NetStateRule_descriptor_, NetStateRule::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ ParamSpec_descriptor_, ParamSpec::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ LayerParameter_descriptor_, LayerParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ TransformationParameter_descriptor_, TransformationParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ LossParameter_descriptor_, LossParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ AccuracyParameter_descriptor_, AccuracyParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ ArgMaxParameter_descriptor_, ArgMaxParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ ConcatParameter_descriptor_, ConcatParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ BatchNormParameter_descriptor_, BatchNormParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ BiasParameter_descriptor_, BiasParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ ContrastiveLossParameter_descriptor_, ContrastiveLossParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ ConvolutionParameter_descriptor_, ConvolutionParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ CropParameter_descriptor_, CropParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ DataParameter_descriptor_, DataParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ NonMaximumSuppressionParameter_descriptor_, NonMaximumSuppressionParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ SaveOutputParameter_descriptor_, SaveOutputParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ DropoutParameter_descriptor_, DropoutParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ DummyDataParameter_descriptor_, DummyDataParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ EltwiseParameter_descriptor_, EltwiseParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ ELUParameter_descriptor_, ELUParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ EmbedParameter_descriptor_, EmbedParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ ExpParameter_descriptor_, ExpParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ FlattenParameter_descriptor_, FlattenParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ HDF5DataParameter_descriptor_, HDF5DataParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ HDF5OutputParameter_descriptor_, HDF5OutputParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ HingeLossParameter_descriptor_, HingeLossParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ ImageDataParameter_descriptor_, ImageDataParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ InfogainLossParameter_descriptor_, InfogainLossParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ InnerProductParameter_descriptor_, InnerProductParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ InputParameter_descriptor_, InputParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ LogParameter_descriptor_, LogParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ LRNParameter_descriptor_, LRNParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ MemoryDataParameter_descriptor_, MemoryDataParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ MVNParameter_descriptor_, MVNParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ ParameterParameter_descriptor_, ParameterParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ PoolingParameter_descriptor_, PoolingParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ PowerParameter_descriptor_, PowerParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ PythonParameter_descriptor_, PythonParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ RecurrentParameter_descriptor_, RecurrentParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ ReductionParameter_descriptor_, ReductionParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ ReLUParameter_descriptor_, ReLUParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ ReshapeParameter_descriptor_, ReshapeParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ ScaleParameter_descriptor_, ScaleParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ SigmoidParameter_descriptor_, SigmoidParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ SliceParameter_descriptor_, SliceParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ SoftmaxParameter_descriptor_, SoftmaxParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ TanHParameter_descriptor_, TanHParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ TileParameter_descriptor_, TileParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ ThresholdParameter_descriptor_, ThresholdParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ WindowDataParameter_descriptor_, WindowDataParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ SPPParameter_descriptor_, SPPParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ V1LayerParameter_descriptor_, V1LayerParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ V0LayerParameter_descriptor_, V0LayerParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ PReLUParameter_descriptor_, PReLUParameter::internal_default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ NormalizedBBox_descriptor_, NormalizedBBox::internal_default_instance());
+}
+
+} // namespace
+
+void protobuf_ShutdownFile_caffe_2eproto() {
+ BlobShape_default_instance_.Shutdown();
+ delete BlobShape_reflection_;
+ BlobProto_default_instance_.Shutdown();
+ delete BlobProto_reflection_;
+ BlobProtoVector_default_instance_.Shutdown();
+ delete BlobProtoVector_reflection_;
+ PermuteParameter_default_instance_.Shutdown();
+ delete PermuteParameter_reflection_;
+ NormalizeBBoxParameter_default_instance_.Shutdown();
+ delete NormalizeBBoxParameter_reflection_;
+ PriorBoxParameter_default_instance_.Shutdown();
+ delete PriorBoxParameter_reflection_;
+ DetectionOutputParameter_default_instance_.Shutdown();
+ delete DetectionOutputParameter_reflection_;
+ Datum_default_instance_.Shutdown();
+ delete Datum_reflection_;
+ FillerParameter_default_instance_.Shutdown();
+ delete FillerParameter_reflection_;
+ delete FillerParameter::_default_type_;
+ NetParameter_default_instance_.Shutdown();
+ delete NetParameter_reflection_;
+ SolverParameter_default_instance_.Shutdown();
+ delete SolverParameter_reflection_;
+ delete SolverParameter::_default_regularization_type_;
+ delete SolverParameter::_default_type_;
+ SolverState_default_instance_.Shutdown();
+ delete SolverState_reflection_;
+ NetState_default_instance_.Shutdown();
+ delete NetState_reflection_;
+ NetStateRule_default_instance_.Shutdown();
+ delete NetStateRule_reflection_;
+ ParamSpec_default_instance_.Shutdown();
+ delete ParamSpec_reflection_;
+ LayerParameter_default_instance_.Shutdown();
+ delete LayerParameter_reflection_;
+ TransformationParameter_default_instance_.Shutdown();
+ delete TransformationParameter_reflection_;
+ LossParameter_default_instance_.Shutdown();
+ delete LossParameter_reflection_;
+ AccuracyParameter_default_instance_.Shutdown();
+ delete AccuracyParameter_reflection_;
+ ArgMaxParameter_default_instance_.Shutdown();
+ delete ArgMaxParameter_reflection_;
+ ConcatParameter_default_instance_.Shutdown();
+ delete ConcatParameter_reflection_;
+ BatchNormParameter_default_instance_.Shutdown();
+ delete BatchNormParameter_reflection_;
+ BiasParameter_default_instance_.Shutdown();
+ delete BiasParameter_reflection_;
+ ContrastiveLossParameter_default_instance_.Shutdown();
+ delete ContrastiveLossParameter_reflection_;
+ ConvolutionParameter_default_instance_.Shutdown();
+ delete ConvolutionParameter_reflection_;
+ CropParameter_default_instance_.Shutdown();
+ delete CropParameter_reflection_;
+ DataParameter_default_instance_.Shutdown();
+ delete DataParameter_reflection_;
+ NonMaximumSuppressionParameter_default_instance_.Shutdown();
+ delete NonMaximumSuppressionParameter_reflection_;
+ SaveOutputParameter_default_instance_.Shutdown();
+ delete SaveOutputParameter_reflection_;
+ DropoutParameter_default_instance_.Shutdown();
+ delete DropoutParameter_reflection_;
+ DummyDataParameter_default_instance_.Shutdown();
+ delete DummyDataParameter_reflection_;
+ EltwiseParameter_default_instance_.Shutdown();
+ delete EltwiseParameter_reflection_;
+ ELUParameter_default_instance_.Shutdown();
+ delete ELUParameter_reflection_;
+ EmbedParameter_default_instance_.Shutdown();
+ delete EmbedParameter_reflection_;
+ ExpParameter_default_instance_.Shutdown();
+ delete ExpParameter_reflection_;
+ FlattenParameter_default_instance_.Shutdown();
+ delete FlattenParameter_reflection_;
+ HDF5DataParameter_default_instance_.Shutdown();
+ delete HDF5DataParameter_reflection_;
+ HDF5OutputParameter_default_instance_.Shutdown();
+ delete HDF5OutputParameter_reflection_;
+ HingeLossParameter_default_instance_.Shutdown();
+ delete HingeLossParameter_reflection_;
+ ImageDataParameter_default_instance_.Shutdown();
+ delete ImageDataParameter_reflection_;
+ InfogainLossParameter_default_instance_.Shutdown();
+ delete InfogainLossParameter_reflection_;
+ InnerProductParameter_default_instance_.Shutdown();
+ delete InnerProductParameter_reflection_;
+ InputParameter_default_instance_.Shutdown();
+ delete InputParameter_reflection_;
+ LogParameter_default_instance_.Shutdown();
+ delete LogParameter_reflection_;
+ LRNParameter_default_instance_.Shutdown();
+ delete LRNParameter_reflection_;
+ MemoryDataParameter_default_instance_.Shutdown();
+ delete MemoryDataParameter_reflection_;
+ MVNParameter_default_instance_.Shutdown();
+ delete MVNParameter_reflection_;
+ ParameterParameter_default_instance_.Shutdown();
+ delete ParameterParameter_reflection_;
+ PoolingParameter_default_instance_.Shutdown();
+ delete PoolingParameter_reflection_;
+ PowerParameter_default_instance_.Shutdown();
+ delete PowerParameter_reflection_;
+ PythonParameter_default_instance_.Shutdown();
+ delete PythonParameter_reflection_;
+ RecurrentParameter_default_instance_.Shutdown();
+ delete RecurrentParameter_reflection_;
+ ReductionParameter_default_instance_.Shutdown();
+ delete ReductionParameter_reflection_;
+ ReLUParameter_default_instance_.Shutdown();
+ delete ReLUParameter_reflection_;
+ ReshapeParameter_default_instance_.Shutdown();
+ delete ReshapeParameter_reflection_;
+ ScaleParameter_default_instance_.Shutdown();
+ delete ScaleParameter_reflection_;
+ SigmoidParameter_default_instance_.Shutdown();
+ delete SigmoidParameter_reflection_;
+ SliceParameter_default_instance_.Shutdown();
+ delete SliceParameter_reflection_;
+ SoftmaxParameter_default_instance_.Shutdown();
+ delete SoftmaxParameter_reflection_;
+ TanHParameter_default_instance_.Shutdown();
+ delete TanHParameter_reflection_;
+ TileParameter_default_instance_.Shutdown();
+ delete TileParameter_reflection_;
+ ThresholdParameter_default_instance_.Shutdown();
+ delete ThresholdParameter_reflection_;
+ WindowDataParameter_default_instance_.Shutdown();
+ delete WindowDataParameter_reflection_;
+ delete WindowDataParameter::_default_crop_mode_;
+ SPPParameter_default_instance_.Shutdown();
+ delete SPPParameter_reflection_;
+ V1LayerParameter_default_instance_.Shutdown();
+ delete V1LayerParameter_reflection_;
+ V0LayerParameter_default_instance_.Shutdown();
+ delete V0LayerParameter_reflection_;
+ delete V0LayerParameter::_default_det_crop_mode_;
+ PReLUParameter_default_instance_.Shutdown();
+ delete PReLUParameter_reflection_;
+ NormalizedBBox_default_instance_.Shutdown();
+ delete NormalizedBBox_reflection_;
+}
+
+void protobuf_InitDefaults_caffe_2eproto_impl() {
+ GOOGLE_PROTOBUF_VERIFY_VERSION;
+
+ BlobShape_default_instance_.DefaultConstruct();
+ BlobProto_default_instance_.DefaultConstruct();
+ BlobProtoVector_default_instance_.DefaultConstruct();
+ PermuteParameter_default_instance_.DefaultConstruct();
+ NormalizeBBoxParameter_default_instance_.DefaultConstruct();
+ PriorBoxParameter_default_instance_.DefaultConstruct();
+ DetectionOutputParameter_default_instance_.DefaultConstruct();
+ ::google::protobuf::internal::GetEmptyString();
+ Datum_default_instance_.DefaultConstruct();
+ ::google::protobuf::internal::GetEmptyString();
+ FillerParameter::_default_type_ =
+ new ::std::string("constant", 8);
+ FillerParameter_default_instance_.DefaultConstruct();
+ ::google::protobuf::internal::GetEmptyString();
+ NetParameter_default_instance_.DefaultConstruct();
+ ::google::protobuf::internal::GetEmptyString();
+ SolverParameter::_default_regularization_type_ =
+ new ::std::string("L2", 2);
+ SolverParameter::_default_type_ =
+ new ::std::string("SGD", 3);
+ SolverParameter_default_instance_.DefaultConstruct();
+ ::google::protobuf::internal::GetEmptyString();
+ SolverState_default_instance_.DefaultConstruct();
+ ::google::protobuf::internal::GetEmptyString();
+ NetState_default_instance_.DefaultConstruct();
+ ::google::protobuf::internal::GetEmptyString();
+ NetStateRule_default_instance_.DefaultConstruct();
+ ::google::protobuf::internal::GetEmptyString();
+ ParamSpec_default_instance_.DefaultConstruct();
+ ::google::protobuf::internal::GetEmptyString();
+ LayerParameter_default_instance_.DefaultConstruct();
+ ::google::protobuf::internal::GetEmptyString();
+ TransformationParameter_default_instance_.DefaultConstruct();
+ LossParameter_default_instance_.DefaultConstruct();
+ AccuracyParameter_default_instance_.DefaultConstruct();
+ ArgMaxParameter_default_instance_.DefaultConstruct();
+ ConcatParameter_default_instance_.DefaultConstruct();
+ BatchNormParameter_default_instance_.DefaultConstruct();
+ BiasParameter_default_instance_.DefaultConstruct();
+ ContrastiveLossParameter_default_instance_.DefaultConstruct();
+ ConvolutionParameter_default_instance_.DefaultConstruct();
+ CropParameter_default_instance_.DefaultConstruct();
+ ::google::protobuf::internal::GetEmptyString();
+ DataParameter_default_instance_.DefaultConstruct();
+ NonMaximumSuppressionParameter_default_instance_.DefaultConstruct();
+ ::google::protobuf::internal::GetEmptyString();
+ SaveOutputParameter_default_instance_.DefaultConstruct();
+ DropoutParameter_default_instance_.DefaultConstruct();
+ DummyDataParameter_default_instance_.DefaultConstruct();
+ EltwiseParameter_default_instance_.DefaultConstruct();
+ ELUParameter_default_instance_.DefaultConstruct();
+ EmbedParameter_default_instance_.DefaultConstruct();
+ ExpParameter_default_instance_.DefaultConstruct();
+ FlattenParameter_default_instance_.DefaultConstruct();
+ ::google::protobuf::internal::GetEmptyString();
+ HDF5DataParameter_default_instance_.DefaultConstruct();
+ ::google::protobuf::internal::GetEmptyString();
+ HDF5OutputParameter_default_instance_.DefaultConstruct();
+ HingeLossParameter_default_instance_.DefaultConstruct();
+ ::google::protobuf::internal::GetEmptyString();
+ ImageDataParameter_default_instance_.DefaultConstruct();
+ ::google::protobuf::internal::GetEmptyString();
+ InfogainLossParameter_default_instance_.DefaultConstruct();
+ InnerProductParameter_default_instance_.DefaultConstruct();
+ InputParameter_default_instance_.DefaultConstruct();
+ LogParameter_default_instance_.DefaultConstruct();
+ LRNParameter_default_instance_.DefaultConstruct();
+ MemoryDataParameter_default_instance_.DefaultConstruct();
+ MVNParameter_default_instance_.DefaultConstruct();
+ ParameterParameter_default_instance_.DefaultConstruct();
+ PoolingParameter_default_instance_.DefaultConstruct();
+ PowerParameter_default_instance_.DefaultConstruct();
+ ::google::protobuf::internal::GetEmptyString();
+ PythonParameter_default_instance_.DefaultConstruct();
+ RecurrentParameter_default_instance_.DefaultConstruct();
+ ReductionParameter_default_instance_.DefaultConstruct();
+ ReLUParameter_default_instance_.DefaultConstruct();
+ ReshapeParameter_default_instance_.DefaultConstruct();
+ ScaleParameter_default_instance_.DefaultConstruct();
+ SigmoidParameter_default_instance_.DefaultConstruct();
+ SliceParameter_default_instance_.DefaultConstruct();
+ SoftmaxParameter_default_instance_.DefaultConstruct();
+ TanHParameter_default_instance_.DefaultConstruct();
+ TileParameter_default_instance_.DefaultConstruct();
+ ThresholdParameter_default_instance_.DefaultConstruct();
+ ::google::protobuf::internal::GetEmptyString();
+ WindowDataParameter::_default_crop_mode_ =
+ new ::std::string("warp", 4);
+ WindowDataParameter_default_instance_.DefaultConstruct();
+ SPPParameter_default_instance_.DefaultConstruct();
+ ::google::protobuf::internal::GetEmptyString();
+ V1LayerParameter_default_instance_.DefaultConstruct();
+ ::google::protobuf::internal::GetEmptyString();
+ V0LayerParameter::_default_det_crop_mode_ =
+ new ::std::string("warp", 4);
+ V0LayerParameter_default_instance_.DefaultConstruct();
+ PReLUParameter_default_instance_.DefaultConstruct();
+ NormalizedBBox_default_instance_.DefaultConstruct();
+ BlobShape_default_instance_.get_mutable()->InitAsDefaultInstance();
+ BlobProto_default_instance_.get_mutable()->InitAsDefaultInstance();
+ BlobProtoVector_default_instance_.get_mutable()->InitAsDefaultInstance();
+ PermuteParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ NormalizeBBoxParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ PriorBoxParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ DetectionOutputParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ Datum_default_instance_.get_mutable()->InitAsDefaultInstance();
+ FillerParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ NetParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ SolverParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ SolverState_default_instance_.get_mutable()->InitAsDefaultInstance();
+ NetState_default_instance_.get_mutable()->InitAsDefaultInstance();
+ NetStateRule_default_instance_.get_mutable()->InitAsDefaultInstance();
+ ParamSpec_default_instance_.get_mutable()->InitAsDefaultInstance();
+ LayerParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ TransformationParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ LossParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ AccuracyParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ ArgMaxParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ ConcatParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ BatchNormParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ BiasParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ ContrastiveLossParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ ConvolutionParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ CropParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ DataParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ NonMaximumSuppressionParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ SaveOutputParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ DropoutParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ DummyDataParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ EltwiseParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ ELUParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ EmbedParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ ExpParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ FlattenParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ HDF5DataParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ HDF5OutputParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ HingeLossParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ ImageDataParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ InfogainLossParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ InnerProductParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ InputParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ LogParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ LRNParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ MemoryDataParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ MVNParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ ParameterParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ PoolingParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ PowerParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ PythonParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ RecurrentParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ ReductionParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ ReLUParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ ReshapeParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ ScaleParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ SigmoidParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ SliceParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ SoftmaxParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ TanHParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ TileParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ ThresholdParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ WindowDataParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ SPPParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ V1LayerParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ V0LayerParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ PReLUParameter_default_instance_.get_mutable()->InitAsDefaultInstance();
+ NormalizedBBox_default_instance_.get_mutable()->InitAsDefaultInstance();
+}
+
+GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_InitDefaults_caffe_2eproto_once_);
+void protobuf_InitDefaults_caffe_2eproto() {
+ ::google::protobuf::GoogleOnceInit(&protobuf_InitDefaults_caffe_2eproto_once_,
+ &protobuf_InitDefaults_caffe_2eproto_impl);
+}
+void protobuf_AddDesc_caffe_2eproto_impl() {
+ GOOGLE_PROTOBUF_VERIFY_VERSION;
+
+ protobuf_InitDefaults_caffe_2eproto();
+ ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
+ "\n\013caffe.proto\022\005caffe\"\034\n\tBlobShape\022\017\n\003dim"
+ "\030\001 \003(\003B\002\020\001\"\314\001\n\tBlobProto\022\037\n\005shape\030\007 \001(\0132"
+ "\020.caffe.BlobShape\022\020\n\004data\030\005 \003(\002B\002\020\001\022\020\n\004d"
+ "iff\030\006 \003(\002B\002\020\001\022\027\n\013double_data\030\010 \003(\001B\002\020\001\022\027"
+ "\n\013double_diff\030\t \003(\001B\002\020\001\022\016\n\003num\030\001 \001(\005:\0010\022"
+ "\023\n\010channels\030\002 \001(\005:\0010\022\021\n\006height\030\003 \001(\005:\0010\022"
+ "\020\n\005width\030\004 \001(\005:\0010\"2\n\017BlobProtoVector\022\037\n\005"
+ "blobs\030\001 \003(\0132\020.caffe.BlobProto\"!\n\020Permute"
+ "Parameter\022\r\n\005order\030\001 \003(\r\"\226\001\n\026NormalizeBB"
+ "oxParameter\022\034\n\016across_spatial\030\001 \001(\010:\004tru"
+ "e\022,\n\014scale_filler\030\002 \001(\0132\026.caffe.FillerPa"
+ "rameter\022\034\n\016channel_shared\030\003 \001(\010:\004true\022\022\n"
+ "\003eps\030\004 \001(\002:\0051e-10\"\243\002\n\021PriorBoxParameter\022"
+ "\020\n\010min_size\030\001 \001(\002\022\020\n\010max_size\030\002 \001(\002\022\024\n\014a"
+ "spect_ratio\030\003 \003(\002\022\022\n\004flip\030\004 \001(\010:\004true\022\022\n"
+ "\004clip\030\005 \001(\010:\004true\022\020\n\010variance\030\006 \003(\002\022\020\n\010i"
+ "mg_size\030\007 \001(\r\022\r\n\005img_h\030\010 \001(\r\022\r\n\005img_w\030\t "
+ "\001(\r\022\014\n\004step\030\n \001(\002\022\016\n\006step_h\030\013 \001(\002\022\016\n\006ste"
+ "p_w\030\014 \001(\002\022\023\n\006offset\030\r \001(\002:\0030.5\"\'\n\010CodeTy"
+ "pe\022\n\n\006CORNER\020\001\022\017\n\013CENTER_SIZE\020\002\"\375\002\n\030Dete"
+ "ctionOutputParameter\022\023\n\013num_classes\030\001 \001("
+ "\r\022\034\n\016share_location\030\002 \001(\010:\004true\022\036\n\023backg"
+ "round_label_id\030\003 \001(\005:\0010\0228\n\tnms_param\030\004 \001"
+ "(\0132%.caffe.NonMaximumSuppressionParamete"
+ "r\0225\n\021save_output_param\030\005 \001(\0132\032.caffe.Sav"
+ "eOutputParameter\022<\n\tcode_type\030\006 \001(\0162!.ca"
+ "ffe.PriorBoxParameter.CodeType:\006CORNER\022)"
+ "\n\032variance_encoded_in_target\030\010 \001(\010:\005fals"
+ "e\022\026\n\nkeep_top_k\030\007 \001(\005:\002-1\022\034\n\024confidence_"
+ "threshold\030\t \001(\002\"\201\001\n\005Datum\022\020\n\010channels\030\001 "
+ "\001(\005\022\016\n\006height\030\002 \001(\005\022\r\n\005width\030\003 \001(\005\022\014\n\004da"
+ "ta\030\004 \001(\014\022\r\n\005label\030\005 \001(\005\022\022\n\nfloat_data\030\006 "
+ "\003(\002\022\026\n\007encoded\030\007 \001(\010:\005false\"\212\002\n\017FillerPa"
+ "rameter\022\026\n\004type\030\001 \001(\t:\010constant\022\020\n\005value"
+ "\030\002 \001(\002:\0010\022\016\n\003min\030\003 \001(\002:\0010\022\016\n\003max\030\004 \001(\002:\001"
+ "1\022\017\n\004mean\030\005 \001(\002:\0010\022\016\n\003std\030\006 \001(\002:\0011\022\022\n\006sp"
+ "arse\030\007 \001(\005:\002-1\022B\n\rvariance_norm\030\010 \001(\0162#."
+ "caffe.FillerParameter.VarianceNorm:\006FAN_"
+ "IN\"4\n\014VarianceNorm\022\n\n\006FAN_IN\020\000\022\013\n\007FAN_OU"
+ "T\020\001\022\013\n\007AVERAGE\020\002\"\216\002\n\014NetParameter\022\014\n\004nam"
+ "e\030\001 \001(\t\022\r\n\005input\030\003 \003(\t\022%\n\013input_shape\030\010 "
+ "\003(\0132\020.caffe.BlobShape\022\021\n\tinput_dim\030\004 \003(\005"
+ "\022\035\n\016force_backward\030\005 \001(\010:\005false\022\036\n\005state"
+ "\030\006 \001(\0132\017.caffe.NetState\022\031\n\ndebug_info\030\007 "
+ "\001(\010:\005false\022$\n\005layer\030d \003(\0132\025.caffe.LayerP"
+ "arameter\022\'\n\006layers\030\002 \003(\0132\027.caffe.V1Layer"
+ "Parameter\"\242\n\n\017SolverParameter\022\013\n\003net\030\030 \001"
+ "(\t\022&\n\tnet_param\030\031 \001(\0132\023.caffe.NetParamet"
+ "er\022\021\n\ttrain_net\030\001 \001(\t\022\020\n\010test_net\030\002 \003(\t\022"
+ ",\n\017train_net_param\030\025 \001(\0132\023.caffe.NetPara"
+ "meter\022+\n\016test_net_param\030\026 \003(\0132\023.caffe.Ne"
+ "tParameter\022$\n\013train_state\030\032 \001(\0132\017.caffe."
+ "NetState\022#\n\ntest_state\030\033 \003(\0132\017.caffe.Net"
+ "State\022\021\n\ttest_iter\030\003 \003(\005\022\030\n\rtest_interva"
+ "l\030\004 \001(\005:\0010\022 \n\021test_compute_loss\030\023 \001(\010:\005f"
+ "alse\022!\n\023test_initialization\030 \001(\010:\004true\022"
+ "\017\n\007base_lr\030\005 \001(\002\022\017\n\007display\030\006 \001(\005\022\027\n\014ave"
+ "rage_loss\030! \001(\005:\0011\022\020\n\010max_iter\030\007 \001(\005\022\024\n\t"
+ "iter_size\030$ \001(\005:\0011\022\021\n\tlr_policy\030\010 \001(\t\022\r\n"
+ "\005gamma\030\t \001(\002\022\r\n\005power\030\n \001(\002\022\020\n\010momentum\030"
+ "\013 \001(\002\022\024\n\014weight_decay\030\014 \001(\002\022\037\n\023regulariz"
+ "ation_type\030\035 \001(\t:\002L2\022\020\n\010stepsize\030\r \001(\005\022\021"
+ "\n\tstepvalue\030\" \003(\005\022\032\n\016clip_gradients\030# \001("
+ "\002:\002-1\022\023\n\010snapshot\030\016 \001(\005:\0010\022\027\n\017snapshot_p"
+ "refix\030\017 \001(\t\022\034\n\rsnapshot_diff\030\020 \001(\010:\005fals"
+ "e\022K\n\017snapshot_format\030% \001(\0162%.caffe.Solve"
+ "rParameter.SnapshotFormat:\013BINARYPROTO\022;"
+ "\n\013solver_mode\030\021 \001(\0162!.caffe.SolverParame"
+ "ter.SolverMode:\003GPU\022\024\n\tdevice_id\030\022 \001(\005:\001"
+ "0\022\027\n\013random_seed\030\024 \001(\003:\002-1\022\021\n\004type\030( \001(\t"
+ ":\003SGD\022\024\n\005delta\030\037 \001(\002:\0051e-08\022\030\n\tmomentum2"
+ "\030\' \001(\002:\0050.999\022\027\n\trms_decay\030& \001(\002:\0040.99\022\031"
+ "\n\ndebug_info\030\027 \001(\010:\005false\022\"\n\024snapshot_af"
+ "ter_train\030\034 \001(\010:\004true\022;\n\013solver_type\030\036 \001"
+ "(\0162!.caffe.SolverParameter.SolverType:\003S"
+ "GD\"+\n\016SnapshotFormat\022\010\n\004HDF5\020\000\022\017\n\013BINARY"
+ "PROTO\020\001\"\036\n\nSolverMode\022\007\n\003CPU\020\000\022\007\n\003GPU\020\001\""
+ "U\n\nSolverType\022\007\n\003SGD\020\000\022\014\n\010NESTEROV\020\001\022\013\n\007"
+ "ADAGRAD\020\002\022\013\n\007RMSPROP\020\003\022\014\n\010ADADELTA\020\004\022\010\n\004"
+ "ADAM\020\005\"l\n\013SolverState\022\014\n\004iter\030\001 \001(\005\022\023\n\013l"
+ "earned_net\030\002 \001(\t\022!\n\007history\030\003 \003(\0132\020.caff"
+ "e.BlobProto\022\027\n\014current_step\030\004 \001(\005:\0010\"N\n\010"
+ "NetState\022!\n\005phase\030\001 \001(\0162\014.caffe.Phase:\004T"
+ "EST\022\020\n\005level\030\002 \001(\005:\0010\022\r\n\005stage\030\003 \003(\t\"s\n\014"
+ "NetStateRule\022\033\n\005phase\030\001 \001(\0162\014.caffe.Phas"
+ "e\022\021\n\tmin_level\030\002 \001(\005\022\021\n\tmax_level\030\003 \001(\005\022"
+ "\r\n\005stage\030\004 \003(\t\022\021\n\tnot_stage\030\005 \003(\t\"\243\001\n\tPa"
+ "ramSpec\022\014\n\004name\030\001 \001(\t\0221\n\nshare_mode\030\002 \001("
+ "\0162\035.caffe.ParamSpec.DimCheckMode\022\022\n\007lr_m"
+ "ult\030\003 \001(\002:\0011\022\025\n\ndecay_mult\030\004 \001(\002:\0011\"*\n\014D"
+ "imCheckMode\022\n\n\006STRICT\020\000\022\016\n\nPERMISSIVE\020\001\""
+ "\335\025\n\016LayerParameter\022\014\n\004name\030\001 \001(\t\022\014\n\004type"
+ "\030\002 \001(\t\022\016\n\006bottom\030\003 \003(\t\022\013\n\003top\030\004 \003(\t\022\033\n\005p"
+ "hase\030\n \001(\0162\014.caffe.Phase\022\023\n\013loss_weight\030"
+ "\005 \003(\002\022\037\n\005param\030\006 \003(\0132\020.caffe.ParamSpec\022\037"
+ "\n\005blobs\030\007 \003(\0132\020.caffe.BlobProto\022\026\n\016propa"
+ "gate_down\030\013 \003(\010\022$\n\007include\030\010 \003(\0132\023.caffe"
+ ".NetStateRule\022$\n\007exclude\030\t \003(\0132\023.caffe.N"
+ "etStateRule\0227\n\017transform_param\030d \001(\0132\036.c"
+ "affe.TransformationParameter\022(\n\nloss_par"
+ "am\030e \001(\0132\024.caffe.LossParameter\0220\n\016accura"
+ "cy_param\030f \001(\0132\030.caffe.AccuracyParameter"
+ "\022,\n\014argmax_param\030g \001(\0132\026.caffe.ArgMaxPar"
+ "ameter\0224\n\020batch_norm_param\030\213\001 \001(\0132\031.caff"
+ "e.BatchNormParameter\022)\n\nbias_param\030\215\001 \001("
+ "\0132\024.caffe.BiasParameter\022,\n\014concat_param\030"
+ "h \001(\0132\026.caffe.ConcatParameter\022\?\n\026contras"
+ "tive_loss_param\030i \001(\0132\037.caffe.Contrastiv"
+ "eLossParameter\0226\n\021convolution_param\030j \001("
+ "\0132\033.caffe.ConvolutionParameter\022)\n\ncrop_p"
+ "aram\030\220\001 \001(\0132\024.caffe.CropParameter\022(\n\ndat"
+ "a_param\030k \001(\0132\024.caffe.DataParameter\022@\n\026d"
+ "etection_output_param\030\223\001 \001(\0132\037.caffe.Det"
+ "ectionOutputParameter\022.\n\rdropout_param\030l"
+ " \001(\0132\027.caffe.DropoutParameter\0223\n\020dummy_d"
+ "ata_param\030m \001(\0132\031.caffe.DummyDataParamet"
+ "er\022.\n\reltwise_param\030n \001(\0132\027.caffe.Eltwis"
+ "eParameter\022\'\n\telu_param\030\214\001 \001(\0132\023.caffe.E"
+ "LUParameter\022+\n\013embed_param\030\211\001 \001(\0132\025.caff"
+ "e.EmbedParameter\022&\n\texp_param\030o \001(\0132\023.ca"
+ "ffe.ExpParameter\022/\n\rflatten_param\030\207\001 \001(\013"
+ "2\027.caffe.FlattenParameter\0221\n\017hdf5_data_p"
+ "aram\030p \001(\0132\030.caffe.HDF5DataParameter\0225\n\021"
+ "hdf5_output_param\030q \001(\0132\032.caffe.HDF5Outp"
+ "utParameter\0223\n\020hinge_loss_param\030r \001(\0132\031."
+ "caffe.HingeLossParameter\0223\n\020image_data_p"
+ "aram\030s \001(\0132\031.caffe.ImageDataParameter\0229\n"
+ "\023infogain_loss_param\030t \001(\0132\034.caffe.Infog"
+ "ainLossParameter\0229\n\023inner_product_param\030"
+ "u \001(\0132\034.caffe.InnerProductParameter\022+\n\013i"
+ "nput_param\030\217\001 \001(\0132\025.caffe.InputParameter"
+ "\022\'\n\tlog_param\030\206\001 \001(\0132\023.caffe.LogParamete"
+ "r\022&\n\tlrn_param\030v \001(\0132\023.caffe.LRNParamete"
+ "r\0225\n\021memory_data_param\030w \001(\0132\032.caffe.Mem"
+ "oryDataParameter\022&\n\tmvn_param\030x \001(\0132\023.ca"
+ "ffe.MVNParameter\0222\n\nnorm_param\030\225\001 \001(\0132\035."
+ "caffe.NormalizeBBoxParameter\022/\n\rpermute_"
+ "param\030\224\001 \001(\0132\027.caffe.PermuteParameter\0223\n"
+ "\017parameter_param\030\221\001 \001(\0132\031.caffe.Paramete"
+ "rParameter\022.\n\rpooling_param\030y \001(\0132\027.caff"
+ "e.PoolingParameter\022*\n\013power_param\030z \001(\0132"
+ "\025.caffe.PowerParameter\022+\n\013prelu_param\030\203\001"
+ " \001(\0132\025.caffe.PReLUParameter\0222\n\017prior_box"
+ "_param\030\226\001 \001(\0132\030.caffe.PriorBoxParameter\022"
+ "-\n\014python_param\030\202\001 \001(\0132\026.caffe.PythonPar"
+ "ameter\0223\n\017recurrent_param\030\222\001 \001(\0132\031.caffe"
+ ".RecurrentParameter\0223\n\017reduction_param\030\210"
+ "\001 \001(\0132\031.caffe.ReductionParameter\022(\n\nrelu"
+ "_param\030{ \001(\0132\024.caffe.ReLUParameter\022/\n\rre"
+ "shape_param\030\205\001 \001(\0132\027.caffe.ReshapeParame"
+ "ter\022+\n\013scale_param\030\216\001 \001(\0132\025.caffe.ScaleP"
+ "arameter\022.\n\rsigmoid_param\030| \001(\0132\027.caffe."
+ "SigmoidParameter\022.\n\rsoftmax_param\030} \001(\0132"
+ "\027.caffe.SoftmaxParameter\022\'\n\tspp_param\030\204\001"
+ " \001(\0132\023.caffe.SPPParameter\022*\n\013slice_param"
+ "\030~ \001(\0132\025.caffe.SliceParameter\022(\n\ntanh_pa"
+ "ram\030\177 \001(\0132\024.caffe.TanHParameter\0223\n\017thres"
+ "hold_param\030\200\001 \001(\0132\031.caffe.ThresholdParam"
+ "eter\022)\n\ntile_param\030\212\001 \001(\0132\024.caffe.TilePa"
+ "rameter\0226\n\021window_data_param\030\201\001 \001(\0132\032.ca"
+ "ffe.WindowDataParameter\"\266\001\n\027Transformati"
+ "onParameter\022\020\n\005scale\030\001 \001(\002:\0011\022\025\n\006mirror\030"
+ "\002 \001(\010:\005false\022\024\n\tcrop_size\030\003 \001(\r:\0010\022\021\n\tme"
+ "an_file\030\004 \001(\t\022\022\n\nmean_value\030\005 \003(\002\022\032\n\013for"
+ "ce_color\030\006 \001(\010:\005false\022\031\n\nforce_gray\030\007 \001("
+ "\010:\005false\"\302\001\n\rLossParameter\022\024\n\014ignore_lab"
+ "el\030\001 \001(\005\022D\n\rnormalization\030\003 \001(\0162&.caffe."
+ "LossParameter.NormalizationMode:\005VALID\022\021"
+ "\n\tnormalize\030\002 \001(\010\"B\n\021NormalizationMode\022\010"
+ "\n\004FULL\020\000\022\t\n\005VALID\020\001\022\016\n\nBATCH_SIZE\020\002\022\010\n\004N"
+ "ONE\020\003\"L\n\021AccuracyParameter\022\020\n\005top_k\030\001 \001("
+ "\r:\0011\022\017\n\004axis\030\002 \001(\005:\0011\022\024\n\014ignore_label\030\003 "
+ "\001(\005\"M\n\017ArgMaxParameter\022\032\n\013out_max_val\030\001 "
+ "\001(\010:\005false\022\020\n\005top_k\030\002 \001(\r:\0011\022\014\n\004axis\030\003 \001"
+ "(\005\"9\n\017ConcatParameter\022\017\n\004axis\030\002 \001(\005:\0011\022\025"
+ "\n\nconcat_dim\030\001 \001(\r:\0011\"j\n\022BatchNormParame"
+ "ter\022\030\n\020use_global_stats\030\001 \001(\010\022&\n\027moving_"
+ "average_fraction\030\002 \001(\002:\0050.999\022\022\n\003eps\030\003 \001"
+ "(\002:\0051e-05\"]\n\rBiasParameter\022\017\n\004axis\030\001 \001(\005"
+ ":\0011\022\023\n\010num_axes\030\002 \001(\005:\0011\022&\n\006filler\030\003 \001(\013"
+ "2\026.caffe.FillerParameter\"L\n\030ContrastiveL"
+ "ossParameter\022\021\n\006margin\030\001 \001(\002:\0011\022\035\n\016legac"
+ "y_version\030\002 \001(\010:\005false\"\374\003\n\024ConvolutionPa"
+ "rameter\022\022\n\nnum_output\030\001 \001(\r\022\027\n\tbias_term"
+ "\030\002 \001(\010:\004true\022\013\n\003pad\030\003 \003(\r\022\023\n\013kernel_size"
+ "\030\004 \003(\r\022\016\n\006stride\030\006 \003(\r\022\020\n\010dilation\030\022 \003(\r"
+ "\022\020\n\005pad_h\030\t \001(\r:\0010\022\020\n\005pad_w\030\n \001(\r:\0010\022\020\n\010"
+ "kernel_h\030\013 \001(\r\022\020\n\010kernel_w\030\014 \001(\r\022\020\n\010stri"
+ "de_h\030\r \001(\r\022\020\n\010stride_w\030\016 \001(\r\022\020\n\005group\030\005 "
+ "\001(\r:\0011\022-\n\rweight_filler\030\007 \001(\0132\026.caffe.Fi"
+ "llerParameter\022+\n\013bias_filler\030\010 \001(\0132\026.caf"
+ "fe.FillerParameter\022;\n\006engine\030\017 \001(\0162\".caf"
+ "fe.ConvolutionParameter.Engine:\007DEFAULT\022"
+ "\017\n\004axis\030\020 \001(\005:\0011\022\036\n\017force_nd_im2col\030\021 \001("
+ "\010:\005false\"+\n\006Engine\022\013\n\007DEFAULT\020\000\022\t\n\005CAFFE"
+ "\020\001\022\t\n\005CUDNN\020\002\"0\n\rCropParameter\022\017\n\004axis\030\001"
+ " \001(\005:\0012\022\016\n\006offset\030\002 \003(\r\"\244\002\n\rDataParamete"
+ "r\022\016\n\006source\030\001 \001(\t\022\022\n\nbatch_size\030\004 \001(\r\022\024\n"
+ "\trand_skip\030\007 \001(\r:\0010\0221\n\007backend\030\010 \001(\0162\027.c"
+ "affe.DataParameter.DB:\007LEVELDB\022\020\n\005scale\030"
+ "\002 \001(\002:\0011\022\021\n\tmean_file\030\003 \001(\t\022\024\n\tcrop_size"
+ "\030\005 \001(\r:\0010\022\025\n\006mirror\030\006 \001(\010:\005false\022\"\n\023forc"
+ "e_encoded_color\030\t \001(\010:\005false\022\023\n\010prefetch"
+ "\030\n \001(\r:\0014\"\033\n\002DB\022\013\n\007LEVELDB\020\000\022\010\n\004LMDB\020\001\"["
+ "\n\036NonMaximumSuppressionParameter\022\032\n\rnms_"
+ "threshold\030\001 \001(\002:\0030.3\022\r\n\005top_k\030\002 \001(\005\022\016\n\003e"
+ "ta\030\003 \001(\002:\0011\"\252\001\n\023SaveOutputParameter\022\030\n\020o"
+ "utput_directory\030\001 \001(\t\022\032\n\022output_name_pre"
+ "fix\030\002 \001(\t\022\025\n\routput_format\030\003 \001(\t\022\026\n\016labe"
+ "l_map_file\030\004 \001(\t\022\026\n\016name_size_file\030\005 \001(\t"
+ "\022\026\n\016num_test_image\030\006 \001(\r\".\n\020DropoutParam"
+ "eter\022\032\n\rdropout_ratio\030\001 \001(\002:\0030.5\"\240\001\n\022Dum"
+ "myDataParameter\022+\n\013data_filler\030\001 \003(\0132\026.c"
+ "affe.FillerParameter\022\037\n\005shape\030\006 \003(\0132\020.ca"
+ "ffe.BlobShape\022\013\n\003num\030\002 \003(\r\022\020\n\010channels\030\003"
+ " \003(\r\022\016\n\006height\030\004 \003(\r\022\r\n\005width\030\005 \003(\r\"\245\001\n\020"
+ "EltwiseParameter\0229\n\toperation\030\001 \001(\0162!.ca"
+ "ffe.EltwiseParameter.EltwiseOp:\003SUM\022\r\n\005c"
+ "oeff\030\002 \003(\002\022\036\n\020stable_prod_grad\030\003 \001(\010:\004tr"
+ "ue\"\'\n\tEltwiseOp\022\010\n\004PROD\020\000\022\007\n\003SUM\020\001\022\007\n\003MA"
+ "X\020\002\" \n\014ELUParameter\022\020\n\005alpha\030\001 \001(\002:\0011\"\254\001"
+ "\n\016EmbedParameter\022\022\n\nnum_output\030\001 \001(\r\022\021\n\t"
+ "input_dim\030\002 \001(\r\022\027\n\tbias_term\030\003 \001(\010:\004true"
+ "\022-\n\rweight_filler\030\004 \001(\0132\026.caffe.FillerPa"
+ "rameter\022+\n\013bias_filler\030\005 \001(\0132\026.caffe.Fil"
+ "lerParameter\"D\n\014ExpParameter\022\020\n\004base\030\001 \001"
+ "(\002:\002-1\022\020\n\005scale\030\002 \001(\002:\0011\022\020\n\005shift\030\003 \001(\002:"
+ "\0010\"9\n\020FlattenParameter\022\017\n\004axis\030\001 \001(\005:\0011\022"
+ "\024\n\010end_axis\030\002 \001(\005:\002-1\"O\n\021HDF5DataParamet"
+ "er\022\016\n\006source\030\001 \001(\t\022\022\n\nbatch_size\030\002 \001(\r\022\026"
+ "\n\007shuffle\030\003 \001(\010:\005false\"(\n\023HDF5OutputPara"
+ "meter\022\021\n\tfile_name\030\001 \001(\t\"^\n\022HingeLossPar"
+ "ameter\0220\n\004norm\030\001 \001(\0162\036.caffe.HingeLossPa"
+ "rameter.Norm:\002L1\"\026\n\004Norm\022\006\n\002L1\020\001\022\006\n\002L2\020\002"
+ "\"\227\002\n\022ImageDataParameter\022\016\n\006source\030\001 \001(\t\022"
+ "\025\n\nbatch_size\030\004 \001(\r:\0011\022\024\n\trand_skip\030\007 \001("
+ "\r:\0010\022\026\n\007shuffle\030\010 \001(\010:\005false\022\025\n\nnew_heig"
+ "ht\030\t \001(\r:\0010\022\024\n\tnew_width\030\n \001(\r:\0010\022\026\n\010is_"
+ "color\030\013 \001(\010:\004true\022\020\n\005scale\030\002 \001(\002:\0011\022\021\n\tm"
+ "ean_file\030\003 \001(\t\022\024\n\tcrop_size\030\005 \001(\r:\0010\022\025\n\006"
+ "mirror\030\006 \001(\010:\005false\022\025\n\013root_folder\030\014 \001(\t"
+ ":\000\"\'\n\025InfogainLossParameter\022\016\n\006source\030\001 "
+ "\001(\t\"\313\001\n\025InnerProductParameter\022\022\n\nnum_out"
+ "put\030\001 \001(\r\022\027\n\tbias_term\030\002 \001(\010:\004true\022-\n\rwe"
+ "ight_filler\030\003 \001(\0132\026.caffe.FillerParamete"
+ "r\022+\n\013bias_filler\030\004 \001(\0132\026.caffe.FillerPar"
+ "ameter\022\017\n\004axis\030\005 \001(\005:\0011\022\030\n\ttranspose\030\006 \001"
+ "(\010:\005false\"1\n\016InputParameter\022\037\n\005shape\030\001 \003"
+ "(\0132\020.caffe.BlobShape\"D\n\014LogParameter\022\020\n\004"
+ "base\030\001 \001(\002:\002-1\022\020\n\005scale\030\002 \001(\002:\0011\022\020\n\005shif"
+ "t\030\003 \001(\002:\0010\"\270\002\n\014LRNParameter\022\025\n\nlocal_siz"
+ "e\030\001 \001(\r:\0015\022\020\n\005alpha\030\002 \001(\002:\0011\022\022\n\004beta\030\003 \001"
+ "(\002:\0040.75\022D\n\013norm_region\030\004 \001(\0162\036.caffe.LR"
+ "NParameter.NormRegion:\017ACROSS_CHANNELS\022\014"
+ "\n\001k\030\005 \001(\002:\0011\0223\n\006engine\030\006 \001(\0162\032.caffe.LRN"
+ "Parameter.Engine:\007DEFAULT\"5\n\nNormRegion\022"
+ "\023\n\017ACROSS_CHANNELS\020\000\022\022\n\016WITHIN_CHANNEL\020\001"
+ "\"+\n\006Engine\022\013\n\007DEFAULT\020\000\022\t\n\005CAFFE\020\001\022\t\n\005CU"
+ "DNN\020\002\"Z\n\023MemoryDataParameter\022\022\n\nbatch_si"
+ "ze\030\001 \001(\r\022\020\n\010channels\030\002 \001(\r\022\016\n\006height\030\003 \001"
+ "(\r\022\r\n\005width\030\004 \001(\r\"d\n\014MVNParameter\022 \n\022nor"
+ "malize_variance\030\001 \001(\010:\004true\022\036\n\017across_ch"
+ "annels\030\002 \001(\010:\005false\022\022\n\003eps\030\003 \001(\002:\0051e-09\""
+ "5\n\022ParameterParameter\022\037\n\005shape\030\001 \001(\0132\020.c"
+ "affe.BlobShape\"\242\003\n\020PoolingParameter\0225\n\004p"
+ "ool\030\001 \001(\0162\".caffe.PoolingParameter.PoolM"
+ "ethod:\003MAX\022\016\n\003pad\030\004 \001(\r:\0010\022\020\n\005pad_h\030\t \001("
+ "\r:\0010\022\020\n\005pad_w\030\n \001(\r:\0010\022\023\n\013kernel_size\030\002 "
+ "\001(\r\022\020\n\010kernel_h\030\005 \001(\r\022\020\n\010kernel_w\030\006 \001(\r\022"
+ "\021\n\006stride\030\003 \001(\r:\0011\022\020\n\010stride_h\030\007 \001(\r\022\020\n\010"
+ "stride_w\030\010 \001(\r\0227\n\006engine\030\013 \001(\0162\036.caffe.P"
+ "oolingParameter.Engine:\007DEFAULT\022\035\n\016globa"
+ "l_pooling\030\014 \001(\010:\005false\".\n\nPoolMethod\022\007\n\003"
+ "MAX\020\000\022\007\n\003AVE\020\001\022\016\n\nSTOCHASTIC\020\002\"+\n\006Engine"
+ "\022\013\n\007DEFAULT\020\000\022\t\n\005CAFFE\020\001\022\t\n\005CUDNN\020\002\"F\n\016P"
+ "owerParameter\022\020\n\005power\030\001 \001(\002:\0011\022\020\n\005scale"
+ "\030\002 \001(\002:\0011\022\020\n\005shift\030\003 \001(\002:\0010\"g\n\017PythonPar"
+ "ameter\022\016\n\006module\030\001 \001(\t\022\r\n\005layer\030\002 \001(\t\022\023\n"
+ "\tparam_str\030\003 \001(\t:\000\022 \n\021share_in_parallel\030"
+ "\004 \001(\010:\005false\"\300\001\n\022RecurrentParameter\022\025\n\nn"
+ "um_output\030\001 \001(\r:\0010\022-\n\rweight_filler\030\002 \001("
+ "\0132\026.caffe.FillerParameter\022+\n\013bias_filler"
+ "\030\003 \001(\0132\026.caffe.FillerParameter\022\031\n\ndebug_"
+ "info\030\004 \001(\010:\005false\022\034\n\rexpose_hidden\030\005 \001(\010"
+ ":\005false\"\255\001\n\022ReductionParameter\022=\n\toperat"
+ "ion\030\001 \001(\0162%.caffe.ReductionParameter.Red"
+ "uctionOp:\003SUM\022\017\n\004axis\030\002 \001(\005:\0010\022\020\n\005coeff\030"
+ "\003 \001(\002:\0011\"5\n\013ReductionOp\022\007\n\003SUM\020\001\022\010\n\004ASUM"
+ "\020\002\022\t\n\005SUMSQ\020\003\022\010\n\004MEAN\020\004\"\215\001\n\rReLUParamete"
+ "r\022\031\n\016negative_slope\030\001 \001(\002:\0010\0224\n\006engine\030\002"
+ " \001(\0162\033.caffe.ReLUParameter.Engine:\007DEFAU"
+ "LT\"+\n\006Engine\022\013\n\007DEFAULT\020\000\022\t\n\005CAFFE\020\001\022\t\n\005"
+ "CUDNN\020\002\"Z\n\020ReshapeParameter\022\037\n\005shape\030\001 \001"
+ "(\0132\020.caffe.BlobShape\022\017\n\004axis\030\002 \001(\005:\0010\022\024\n"
+ "\010num_axes\030\003 \001(\005:\002-1\"\245\001\n\016ScaleParameter\022\017"
+ "\n\004axis\030\001 \001(\005:\0011\022\023\n\010num_axes\030\002 \001(\005:\0011\022&\n\006"
+ "filler\030\003 \001(\0132\026.caffe.FillerParameter\022\030\n\t"
+ "bias_term\030\004 \001(\010:\005false\022+\n\013bias_filler\030\005 "
+ "\001(\0132\026.caffe.FillerParameter\"x\n\020SigmoidPa"
+ "rameter\0227\n\006engine\030\001 \001(\0162\036.caffe.SigmoidP"
+ "arameter.Engine:\007DEFAULT\"+\n\006Engine\022\013\n\007DE"
+ "FAULT\020\000\022\t\n\005CAFFE\020\001\022\t\n\005CUDNN\020\002\"L\n\016SlicePa"
+ "rameter\022\017\n\004axis\030\003 \001(\005:\0011\022\023\n\013slice_point\030"
+ "\002 \003(\r\022\024\n\tslice_dim\030\001 \001(\r:\0011\"\211\001\n\020SoftmaxP"
+ "arameter\0227\n\006engine\030\001 \001(\0162\036.caffe.Softmax"
+ "Parameter.Engine:\007DEFAULT\022\017\n\004axis\030\002 \001(\005:"
+ "\0011\"+\n\006Engine\022\013\n\007DEFAULT\020\000\022\t\n\005CAFFE\020\001\022\t\n\005"
+ "CUDNN\020\002\"r\n\rTanHParameter\0224\n\006engine\030\001 \001(\016"
+ "2\033.caffe.TanHParameter.Engine:\007DEFAULT\"+"
+ "\n\006Engine\022\013\n\007DEFAULT\020\000\022\t\n\005CAFFE\020\001\022\t\n\005CUDN"
+ "N\020\002\"/\n\rTileParameter\022\017\n\004axis\030\001 \001(\005:\0011\022\r\n"
+ "\005tiles\030\002 \001(\005\"*\n\022ThresholdParameter\022\024\n\tth"
+ "reshold\030\001 \001(\002:\0010\"\301\002\n\023WindowDataParameter"
+ "\022\016\n\006source\030\001 \001(\t\022\020\n\005scale\030\002 \001(\002:\0011\022\021\n\tme"
+ "an_file\030\003 \001(\t\022\022\n\nbatch_size\030\004 \001(\r\022\024\n\tcro"
+ "p_size\030\005 \001(\r:\0010\022\025\n\006mirror\030\006 \001(\010:\005false\022\031"
+ "\n\014fg_threshold\030\007 \001(\002:\0030.5\022\031\n\014bg_threshol"
+ "d\030\010 \001(\002:\0030.5\022\031\n\013fg_fraction\030\t \001(\002:\0040.25\022"
+ "\026\n\013context_pad\030\n \001(\r:\0010\022\027\n\tcrop_mode\030\013 \001"
+ "(\t:\004warp\022\033\n\014cache_images\030\014 \001(\010:\005false\022\025\n"
+ "\013root_folder\030\r \001(\t:\000\"\353\001\n\014SPPParameter\022\026\n"
+ "\016pyramid_height\030\001 \001(\r\0221\n\004pool\030\002 \001(\0162\036.ca"
+ "ffe.SPPParameter.PoolMethod:\003MAX\0223\n\006engi"
+ "ne\030\006 \001(\0162\032.caffe.SPPParameter.Engine:\007DE"
+ "FAULT\".\n\nPoolMethod\022\007\n\003MAX\020\000\022\007\n\003AVE\020\001\022\016\n"
+ "\nSTOCHASTIC\020\002\"+\n\006Engine\022\013\n\007DEFAULT\020\000\022\t\n\005"
+ "CAFFE\020\001\022\t\n\005CUDNN\020\002\"\340\023\n\020V1LayerParameter\022"
+ "\016\n\006bottom\030\002 \003(\t\022\013\n\003top\030\003 \003(\t\022\014\n\004name\030\004 \001"
+ "(\t\022$\n\007include\030 \003(\0132\023.caffe.NetStateRule"
+ "\022$\n\007exclude\030! \003(\0132\023.caffe.NetStateRule\022/"
+ "\n\004type\030\005 \001(\0162!.caffe.V1LayerParameter.La"
+ "yerType\022\037\n\005blobs\030\006 \003(\0132\020.caffe.BlobProto"
+ "\022\016\n\005param\030\351\007 \003(\t\022>\n\017blob_share_mode\030\352\007 \003"
+ "(\0162$.caffe.V1LayerParameter.DimCheckMode"
+ "\022\020\n\010blobs_lr\030\007 \003(\002\022\024\n\014weight_decay\030\010 \003(\002"
+ "\022\023\n\013loss_weight\030# \003(\002\0220\n\016accuracy_param\030"
+ "\033 \001(\0132\030.caffe.AccuracyParameter\022,\n\014argma"
+ "x_param\030\027 \001(\0132\026.caffe.ArgMaxParameter\022,\n"
+ "\014concat_param\030\t \001(\0132\026.caffe.ConcatParame"
+ "ter\022\?\n\026contrastive_loss_param\030( \001(\0132\037.ca"
+ "ffe.ContrastiveLossParameter\0226\n\021convolut"
+ "ion_param\030\n \001(\0132\033.caffe.ConvolutionParam"
+ "eter\022(\n\ndata_param\030\013 \001(\0132\024.caffe.DataPar"
+ "ameter\022.\n\rdropout_param\030\014 \001(\0132\027.caffe.Dr"
+ "opoutParameter\0223\n\020dummy_data_param\030\032 \001(\013"
+ "2\031.caffe.DummyDataParameter\022.\n\reltwise_p"
+ "aram\030\030 \001(\0132\027.caffe.EltwiseParameter\022&\n\te"
+ "xp_param\030) \001(\0132\023.caffe.ExpParameter\0221\n\017h"
+ "df5_data_param\030\r \001(\0132\030.caffe.HDF5DataPar"
+ "ameter\0225\n\021hdf5_output_param\030\016 \001(\0132\032.caff"
+ "e.HDF5OutputParameter\0223\n\020hinge_loss_para"
+ "m\030\035 \001(\0132\031.caffe.HingeLossParameter\0223\n\020im"
+ "age_data_param\030\017 \001(\0132\031.caffe.ImageDataPa"
+ "rameter\0229\n\023infogain_loss_param\030\020 \001(\0132\034.c"
+ "affe.InfogainLossParameter\0229\n\023inner_prod"
+ "uct_param\030\021 \001(\0132\034.caffe.InnerProductPara"
+ "meter\022&\n\tlrn_param\030\022 \001(\0132\023.caffe.LRNPara"
+ "meter\0225\n\021memory_data_param\030\026 \001(\0132\032.caffe"
+ ".MemoryDataParameter\022&\n\tmvn_param\030\" \001(\0132"
+ "\023.caffe.MVNParameter\022.\n\rpooling_param\030\023 "
+ "\001(\0132\027.caffe.PoolingParameter\022*\n\013power_pa"
+ "ram\030\025 \001(\0132\025.caffe.PowerParameter\022(\n\nrelu"
+ "_param\030\036 \001(\0132\024.caffe.ReLUParameter\022.\n\rsi"
+ "gmoid_param\030& \001(\0132\027.caffe.SigmoidParamet"
+ "er\022.\n\rsoftmax_param\030\' \001(\0132\027.caffe.Softma"
+ "xParameter\022*\n\013slice_param\030\037 \001(\0132\025.caffe."
+ "SliceParameter\022(\n\ntanh_param\030% \001(\0132\024.caf"
+ "fe.TanHParameter\0222\n\017threshold_param\030\031 \001("
+ "\0132\031.caffe.ThresholdParameter\0225\n\021window_d"
+ "ata_param\030\024 \001(\0132\032.caffe.WindowDataParame"
+ "ter\0227\n\017transform_param\030$ \001(\0132\036.caffe.Tra"
+ "nsformationParameter\022(\n\nloss_param\030* \001(\013"
+ "2\024.caffe.LossParameter\022&\n\005layer\030\001 \001(\0132\027."
+ "caffe.V0LayerParameter\"\330\004\n\tLayerType\022\010\n\004"
+ "NONE\020\000\022\n\n\006ABSVAL\020#\022\014\n\010ACCURACY\020\001\022\n\n\006ARGM"
+ "AX\020\036\022\010\n\004BNLL\020\002\022\n\n\006CONCAT\020\003\022\024\n\020CONTRASTIV"
+ "E_LOSS\020%\022\017\n\013CONVOLUTION\020\004\022\010\n\004DATA\020\005\022\021\n\rD"
+ "ECONVOLUTION\020\'\022\013\n\007DROPOUT\020\006\022\016\n\nDUMMY_DAT"
+ "A\020 \022\022\n\016EUCLIDEAN_LOSS\020\007\022\013\n\007ELTWISE\020\031\022\007\n\003"
+ "EXP\020&\022\013\n\007FLATTEN\020\010\022\r\n\tHDF5_DATA\020\t\022\017\n\013HDF"
+ "5_OUTPUT\020\n\022\016\n\nHINGE_LOSS\020\034\022\n\n\006IM2COL\020\013\022\016"
+ "\n\nIMAGE_DATA\020\014\022\021\n\rINFOGAIN_LOSS\020\r\022\021\n\rINN"
+ "ER_PRODUCT\020\016\022\007\n\003LRN\020\017\022\017\n\013MEMORY_DATA\020\035\022\035"
+ "\n\031MULTINOMIAL_LOGISTIC_LOSS\020\020\022\007\n\003MVN\020\"\022\013"
+ "\n\007POOLING\020\021\022\t\n\005POWER\020\032\022\010\n\004RELU\020\022\022\013\n\007SIGM"
+ "OID\020\023\022\036\n\032SIGMOID_CROSS_ENTROPY_LOSS\020\033\022\013\n"
+ "\007SILENCE\020$\022\013\n\007SOFTMAX\020\024\022\020\n\014SOFTMAX_LOSS\020"
+ "\025\022\t\n\005SPLIT\020\026\022\t\n\005SLICE\020!\022\010\n\004TANH\020\027\022\017\n\013WIN"
+ "DOW_DATA\020\030\022\r\n\tTHRESHOLD\020\037\"*\n\014DimCheckMod"
+ "e\022\n\n\006STRICT\020\000\022\016\n\nPERMISSIVE\020\001\"\375\007\n\020V0Laye"
+ "rParameter\022\014\n\004name\030\001 \001(\t\022\014\n\004type\030\002 \001(\t\022\022"
+ "\n\nnum_output\030\003 \001(\r\022\026\n\010biasterm\030\004 \001(\010:\004tr"
+ "ue\022-\n\rweight_filler\030\005 \001(\0132\026.caffe.Filler"
+ "Parameter\022+\n\013bias_filler\030\006 \001(\0132\026.caffe.F"
+ "illerParameter\022\016\n\003pad\030\007 \001(\r:\0010\022\022\n\nkernel"
+ "size\030\010 \001(\r\022\020\n\005group\030\t \001(\r:\0011\022\021\n\006stride\030\n"
+ " \001(\r:\0011\0225\n\004pool\030\013 \001(\0162\".caffe.V0LayerPar"
+ "ameter.PoolMethod:\003MAX\022\032\n\rdropout_ratio\030"
+ "\014 \001(\002:\0030.5\022\025\n\nlocal_size\030\r \001(\r:\0015\022\020\n\005alp"
+ "ha\030\016 \001(\002:\0011\022\022\n\004beta\030\017 \001(\002:\0040.75\022\014\n\001k\030\026 \001"
+ "(\002:\0011\022\016\n\006source\030\020 \001(\t\022\020\n\005scale\030\021 \001(\002:\0011\022"
+ "\020\n\010meanfile\030\022 \001(\t\022\021\n\tbatchsize\030\023 \001(\r\022\023\n\010"
+ "cropsize\030\024 \001(\r:\0010\022\025\n\006mirror\030\025 \001(\010:\005false"
+ "\022\037\n\005blobs\0302 \003(\0132\020.caffe.BlobProto\022\020\n\010blo"
+ "bs_lr\0303 \003(\002\022\024\n\014weight_decay\0304 \003(\002\022\024\n\tran"
+ "d_skip\0305 \001(\r:\0010\022\035\n\020det_fg_threshold\0306 \001("
+ "\002:\0030.5\022\035\n\020det_bg_threshold\0307 \001(\002:\0030.5\022\035\n"
+ "\017det_fg_fraction\0308 \001(\002:\0040.25\022\032\n\017det_cont"
+ "ext_pad\030: \001(\r:\0010\022\033\n\rdet_crop_mode\030; \001(\t:"
+ "\004warp\022\022\n\007new_num\030< \001(\005:\0010\022\027\n\014new_channel"
+ "s\030= \001(\005:\0010\022\025\n\nnew_height\030> \001(\005:\0010\022\024\n\tnew"
+ "_width\030\? \001(\005:\0010\022\035\n\016shuffle_images\030@ \001(\010:"
+ "\005false\022\025\n\nconcat_dim\030A \001(\r:\0011\0226\n\021hdf5_ou"
+ "tput_param\030\351\007 \001(\0132\032.caffe.HDF5OutputPara"
+ "meter\".\n\nPoolMethod\022\007\n\003MAX\020\000\022\007\n\003AVE\020\001\022\016\n"
+ "\nSTOCHASTIC\020\002\"W\n\016PReLUParameter\022&\n\006fille"
+ "r\030\001 \001(\0132\026.caffe.FillerParameter\022\035\n\016chann"
+ "el_shared\030\002 \001(\010:\005false\"\207\001\n\016NormalizedBBo"
+ "x\022\014\n\004xmin\030\001 \001(\002\022\014\n\004ymin\030\002 \001(\002\022\014\n\004xmax\030\003 "
+ "\001(\002\022\014\n\004ymax\030\004 \001(\002\022\r\n\005label\030\005 \001(\005\022\021\n\tdiff"
+ "icult\030\006 \001(\010\022\r\n\005score\030\007 \001(\002\022\014\n\004size\030\010 \001(\002"
+ "*\034\n\005Phase\022\t\n\005TRAIN\020\000\022\010\n\004TEST\020\001", 16870);
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
+ "caffe.proto", &protobuf_RegisterTypes);
+ ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_caffe_2eproto);
+}
+
+GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AddDesc_caffe_2eproto_once_);
+void protobuf_AddDesc_caffe_2eproto() {
+ ::google::protobuf::GoogleOnceInit(&protobuf_AddDesc_caffe_2eproto_once_,
+ &protobuf_AddDesc_caffe_2eproto_impl);
+}
+// Force AddDescriptors() to be called at static initialization time.
+struct StaticDescriptorInitializer_caffe_2eproto {
+ StaticDescriptorInitializer_caffe_2eproto() {
+ protobuf_AddDesc_caffe_2eproto();
+ }
+} static_descriptor_initializer_caffe_2eproto_;
+const ::google::protobuf::EnumDescriptor* Phase_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return Phase_descriptor_;
+}
+bool Phase_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ return true;
+ default:
+ return false;
+ }
+}
+
+
+namespace {
+
+static void MergeFromFail(int line) GOOGLE_ATTRIBUTE_COLD GOOGLE_ATTRIBUTE_NORETURN;
+static void MergeFromFail(int line) {
+ ::google::protobuf::internal::MergeFromFail(__FILE__, line);
+}
+
+} // namespace
+
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int BlobShape::kDimFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+BlobShape::BlobShape()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.BlobShape)
+}
+
+void BlobShape::InitAsDefaultInstance() {
+}
+
+BlobShape::BlobShape(const BlobShape& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.BlobShape)
+}
+
+void BlobShape::SharedCtor() {
+ _cached_size_ = 0;
+}
+
+BlobShape::~BlobShape() {
+ // @@protoc_insertion_point(destructor:caffe.BlobShape)
+ SharedDtor();
+}
+
+void BlobShape::SharedDtor() {
+}
+
+void BlobShape::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* BlobShape::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return BlobShape_descriptor_;
+}
+
+const BlobShape& BlobShape::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<BlobShape> BlobShape_default_instance_;
+
+BlobShape* BlobShape::New(::google::protobuf::Arena* arena) const {
+ BlobShape* n = new BlobShape;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void BlobShape::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.BlobShape)
+ dim_.Clear();
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool BlobShape::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.BlobShape)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // repeated int64 dim = 1 [packed = true];
+ case 1: {
+ if (tag == 10) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive<
+ ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
+ input, this->mutable_dim())));
+ } else if (tag == 8) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline<
+ ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
+ 1, 10, input, this->mutable_dim())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.BlobShape)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.BlobShape)
+ return false;
+#undef DO_
+}
+
+void BlobShape::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.BlobShape)
+ // repeated int64 dim = 1 [packed = true];
+ if (this->dim_size() > 0) {
+ ::google::protobuf::internal::WireFormatLite::WriteTag(1, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output);
+ output->WriteVarint32(_dim_cached_byte_size_);
+ }
+ for (int i = 0; i < this->dim_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt64NoTag(
+ this->dim(i), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.BlobShape)
+}
+
+::google::protobuf::uint8* BlobShape::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.BlobShape)
+ // repeated int64 dim = 1 [packed = true];
+ if (this->dim_size() > 0) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray(
+ 1,
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,
+ target);
+ target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(
+ _dim_cached_byte_size_, target);
+ }
+ for (int i = 0; i < this->dim_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteInt64NoTagToArray(this->dim(i), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.BlobShape)
+ return target;
+}
+
+size_t BlobShape::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.BlobShape)
+ size_t total_size = 0;
+
+ // repeated int64 dim = 1 [packed = true];
+ {
+ size_t data_size = 0;
+ unsigned int count = this->dim_size();
+ for (unsigned int i = 0; i < count; i++) {
+ data_size += ::google::protobuf::internal::WireFormatLite::
+ Int64Size(this->dim(i));
+ }
+ if (data_size > 0) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _dim_cached_byte_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ total_size += data_size;
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void BlobShape::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.BlobShape)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const BlobShape* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const BlobShape>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.BlobShape)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.BlobShape)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void BlobShape::MergeFrom(const BlobShape& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.BlobShape)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void BlobShape::UnsafeMergeFrom(const BlobShape& from) {
+ GOOGLE_DCHECK(&from != this);
+ dim_.UnsafeMergeFrom(from.dim_);
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void BlobShape::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.BlobShape)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void BlobShape::CopyFrom(const BlobShape& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.BlobShape)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool BlobShape::IsInitialized() const {
+
+ return true;
+}
+
+void BlobShape::Swap(BlobShape* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void BlobShape::InternalSwap(BlobShape* other) {
+ dim_.UnsafeArenaSwap(&other->dim_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata BlobShape::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = BlobShape_descriptor_;
+ metadata.reflection = BlobShape_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// BlobShape
+
+// repeated int64 dim = 1 [packed = true];
+int BlobShape::dim_size() const {
+ return dim_.size();
+}
+void BlobShape::clear_dim() {
+ dim_.Clear();
+}
+::google::protobuf::int64 BlobShape::dim(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.BlobShape.dim)
+ return dim_.Get(index);
+}
+void BlobShape::set_dim(int index, ::google::protobuf::int64 value) {
+ dim_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.BlobShape.dim)
+}
+void BlobShape::add_dim(::google::protobuf::int64 value) {
+ dim_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.BlobShape.dim)
+}
+const ::google::protobuf::RepeatedField< ::google::protobuf::int64 >&
+BlobShape::dim() const {
+ // @@protoc_insertion_point(field_list:caffe.BlobShape.dim)
+ return dim_;
+}
+::google::protobuf::RepeatedField< ::google::protobuf::int64 >*
+BlobShape::mutable_dim() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.BlobShape.dim)
+ return &dim_;
+}
+
+inline const BlobShape* BlobShape::internal_default_instance() {
+ return &BlobShape_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int BlobProto::kShapeFieldNumber;
+const int BlobProto::kDataFieldNumber;
+const int BlobProto::kDiffFieldNumber;
+const int BlobProto::kDoubleDataFieldNumber;
+const int BlobProto::kDoubleDiffFieldNumber;
+const int BlobProto::kNumFieldNumber;
+const int BlobProto::kChannelsFieldNumber;
+const int BlobProto::kHeightFieldNumber;
+const int BlobProto::kWidthFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+BlobProto::BlobProto()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.BlobProto)
+}
+
+void BlobProto::InitAsDefaultInstance() {
+ shape_ = const_cast< ::caffe::BlobShape*>(
+ ::caffe::BlobShape::internal_default_instance());
+}
+
+BlobProto::BlobProto(const BlobProto& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.BlobProto)
+}
+
+void BlobProto::SharedCtor() {
+ _cached_size_ = 0;
+ shape_ = NULL;
+ ::memset(&num_, 0, reinterpret_cast<char*>(&width_) -
+ reinterpret_cast<char*>(&num_) + sizeof(width_));
+}
+
+BlobProto::~BlobProto() {
+ // @@protoc_insertion_point(destructor:caffe.BlobProto)
+ SharedDtor();
+}
+
+void BlobProto::SharedDtor() {
+ if (this != &BlobProto_default_instance_.get()) {
+ delete shape_;
+ }
+}
+
+void BlobProto::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* BlobProto::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return BlobProto_descriptor_;
+}
+
+const BlobProto& BlobProto::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<BlobProto> BlobProto_default_instance_;
+
+BlobProto* BlobProto::New(::google::protobuf::Arena* arena) const {
+ BlobProto* n = new BlobProto;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void BlobProto::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.BlobProto)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(BlobProto, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<BlobProto*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ if (_has_bits_[0 / 32] & 225u) {
+ ZR_(num_, height_);
+ if (has_shape()) {
+ if (shape_ != NULL) shape_->::caffe::BlobShape::Clear();
+ }
+ }
+ width_ = 0;
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ data_.Clear();
+ diff_.Clear();
+ double_data_.Clear();
+ double_diff_.Clear();
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool BlobProto::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.BlobProto)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional int32 num = 1 [default = 0];
+ case 1: {
+ if (tag == 8) {
+ set_has_num();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &num_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_channels;
+ break;
+ }
+
+ // optional int32 channels = 2 [default = 0];
+ case 2: {
+ if (tag == 16) {
+ parse_channels:
+ set_has_channels();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &channels_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(24)) goto parse_height;
+ break;
+ }
+
+ // optional int32 height = 3 [default = 0];
+ case 3: {
+ if (tag == 24) {
+ parse_height:
+ set_has_height();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &height_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(32)) goto parse_width;
+ break;
+ }
+
+ // optional int32 width = 4 [default = 0];
+ case 4: {
+ if (tag == 32) {
+ parse_width:
+ set_has_width();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &width_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(42)) goto parse_data;
+ break;
+ }
+
+ // repeated float data = 5 [packed = true];
+ case 5: {
+ if (tag == 42) {
+ parse_data:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, this->mutable_data())));
+ } else if (tag == 45) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ 1, 42, input, this->mutable_data())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(50)) goto parse_diff;
+ break;
+ }
+
+ // repeated float diff = 6 [packed = true];
+ case 6: {
+ if (tag == 50) {
+ parse_diff:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, this->mutable_diff())));
+ } else if (tag == 53) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ 1, 50, input, this->mutable_diff())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(58)) goto parse_shape;
+ break;
+ }
+
+ // optional .caffe.BlobShape shape = 7;
+ case 7: {
+ if (tag == 58) {
+ parse_shape:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_shape()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(66)) goto parse_double_data;
+ break;
+ }
+
+ // repeated double double_data = 8 [packed = true];
+ case 8: {
+ if (tag == 66) {
+ parse_double_data:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive<
+ double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>(
+ input, this->mutable_double_data())));
+ } else if (tag == 65) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline<
+ double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>(
+ 1, 66, input, this->mutable_double_data())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(74)) goto parse_double_diff;
+ break;
+ }
+
+ // repeated double double_diff = 9 [packed = true];
+ case 9: {
+ if (tag == 74) {
+ parse_double_diff:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive<
+ double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>(
+ input, this->mutable_double_diff())));
+ } else if (tag == 73) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline<
+ double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>(
+ 1, 74, input, this->mutable_double_diff())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.BlobProto)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.BlobProto)
+ return false;
+#undef DO_
+}
+
+void BlobProto::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.BlobProto)
+ // optional int32 num = 1 [default = 0];
+ if (has_num()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->num(), output);
+ }
+
+ // optional int32 channels = 2 [default = 0];
+ if (has_channels()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->channels(), output);
+ }
+
+ // optional int32 height = 3 [default = 0];
+ if (has_height()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->height(), output);
+ }
+
+ // optional int32 width = 4 [default = 0];
+ if (has_width()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->width(), output);
+ }
+
+ // repeated float data = 5 [packed = true];
+ if (this->data_size() > 0) {
+ ::google::protobuf::internal::WireFormatLite::WriteTag(5, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output);
+ output->WriteVarint32(_data_cached_byte_size_);
+ }
+ for (int i = 0; i < this->data_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloatNoTag(
+ this->data(i), output);
+ }
+
+ // repeated float diff = 6 [packed = true];
+ if (this->diff_size() > 0) {
+ ::google::protobuf::internal::WireFormatLite::WriteTag(6, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output);
+ output->WriteVarint32(_diff_cached_byte_size_);
+ }
+ for (int i = 0; i < this->diff_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloatNoTag(
+ this->diff(i), output);
+ }
+
+ // optional .caffe.BlobShape shape = 7;
+ if (has_shape()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 7, *this->shape_, output);
+ }
+
+ // repeated double double_data = 8 [packed = true];
+ if (this->double_data_size() > 0) {
+ ::google::protobuf::internal::WireFormatLite::WriteTag(8, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output);
+ output->WriteVarint32(_double_data_cached_byte_size_);
+ }
+ for (int i = 0; i < this->double_data_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteDoubleNoTag(
+ this->double_data(i), output);
+ }
+
+ // repeated double double_diff = 9 [packed = true];
+ if (this->double_diff_size() > 0) {
+ ::google::protobuf::internal::WireFormatLite::WriteTag(9, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output);
+ output->WriteVarint32(_double_diff_cached_byte_size_);
+ }
+ for (int i = 0; i < this->double_diff_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteDoubleNoTag(
+ this->double_diff(i), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.BlobProto)
+}
+
+::google::protobuf::uint8* BlobProto::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.BlobProto)
+ // optional int32 num = 1 [default = 0];
+ if (has_num()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->num(), target);
+ }
+
+ // optional int32 channels = 2 [default = 0];
+ if (has_channels()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->channels(), target);
+ }
+
+ // optional int32 height = 3 [default = 0];
+ if (has_height()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->height(), target);
+ }
+
+ // optional int32 width = 4 [default = 0];
+ if (has_width()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->width(), target);
+ }
+
+ // repeated float data = 5 [packed = true];
+ if (this->data_size() > 0) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray(
+ 5,
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,
+ target);
+ target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(
+ _data_cached_byte_size_, target);
+ }
+ for (int i = 0; i < this->data_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteFloatNoTagToArray(this->data(i), target);
+ }
+
+ // repeated float diff = 6 [packed = true];
+ if (this->diff_size() > 0) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray(
+ 6,
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,
+ target);
+ target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(
+ _diff_cached_byte_size_, target);
+ }
+ for (int i = 0; i < this->diff_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteFloatNoTagToArray(this->diff(i), target);
+ }
+
+ // optional .caffe.BlobShape shape = 7;
+ if (has_shape()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 7, *this->shape_, false, target);
+ }
+
+ // repeated double double_data = 8 [packed = true];
+ if (this->double_data_size() > 0) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray(
+ 8,
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,
+ target);
+ target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(
+ _double_data_cached_byte_size_, target);
+ }
+ for (int i = 0; i < this->double_data_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteDoubleNoTagToArray(this->double_data(i), target);
+ }
+
+ // repeated double double_diff = 9 [packed = true];
+ if (this->double_diff_size() > 0) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray(
+ 9,
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,
+ target);
+ target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(
+ _double_diff_cached_byte_size_, target);
+ }
+ for (int i = 0; i < this->double_diff_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteDoubleNoTagToArray(this->double_diff(i), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.BlobProto)
+ return target;
+}
+
+size_t BlobProto::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.BlobProto)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 225u) {
+ // optional .caffe.BlobShape shape = 7;
+ if (has_shape()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->shape_);
+ }
+
+ // optional int32 num = 1 [default = 0];
+ if (has_num()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->num());
+ }
+
+ // optional int32 channels = 2 [default = 0];
+ if (has_channels()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->channels());
+ }
+
+ // optional int32 height = 3 [default = 0];
+ if (has_height()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->height());
+ }
+
+ }
+ // optional int32 width = 4 [default = 0];
+ if (has_width()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->width());
+ }
+
+ // repeated float data = 5 [packed = true];
+ {
+ size_t data_size = 0;
+ unsigned int count = this->data_size();
+ data_size = 4UL * count;
+ if (data_size > 0) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _data_cached_byte_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ total_size += data_size;
+ }
+
+ // repeated float diff = 6 [packed = true];
+ {
+ size_t data_size = 0;
+ unsigned int count = this->diff_size();
+ data_size = 4UL * count;
+ if (data_size > 0) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _diff_cached_byte_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ total_size += data_size;
+ }
+
+ // repeated double double_data = 8 [packed = true];
+ {
+ size_t data_size = 0;
+ unsigned int count = this->double_data_size();
+ data_size = 8UL * count;
+ if (data_size > 0) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _double_data_cached_byte_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ total_size += data_size;
+ }
+
+ // repeated double double_diff = 9 [packed = true];
+ {
+ size_t data_size = 0;
+ unsigned int count = this->double_diff_size();
+ data_size = 8UL * count;
+ if (data_size > 0) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(data_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _double_diff_cached_byte_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ total_size += data_size;
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void BlobProto::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.BlobProto)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const BlobProto* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const BlobProto>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.BlobProto)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.BlobProto)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void BlobProto::MergeFrom(const BlobProto& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.BlobProto)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void BlobProto::UnsafeMergeFrom(const BlobProto& from) {
+ GOOGLE_DCHECK(&from != this);
+ data_.UnsafeMergeFrom(from.data_);
+ diff_.UnsafeMergeFrom(from.diff_);
+ double_data_.UnsafeMergeFrom(from.double_data_);
+ double_diff_.UnsafeMergeFrom(from.double_diff_);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_shape()) {
+ mutable_shape()->::caffe::BlobShape::MergeFrom(from.shape());
+ }
+ if (from.has_num()) {
+ set_num(from.num());
+ }
+ if (from.has_channels()) {
+ set_channels(from.channels());
+ }
+ if (from.has_height()) {
+ set_height(from.height());
+ }
+ }
+ if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) {
+ if (from.has_width()) {
+ set_width(from.width());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void BlobProto::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.BlobProto)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void BlobProto::CopyFrom(const BlobProto& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.BlobProto)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool BlobProto::IsInitialized() const {
+
+ return true;
+}
+
+void BlobProto::Swap(BlobProto* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void BlobProto::InternalSwap(BlobProto* other) {
+ std::swap(shape_, other->shape_);
+ data_.UnsafeArenaSwap(&other->data_);
+ diff_.UnsafeArenaSwap(&other->diff_);
+ double_data_.UnsafeArenaSwap(&other->double_data_);
+ double_diff_.UnsafeArenaSwap(&other->double_diff_);
+ std::swap(num_, other->num_);
+ std::swap(channels_, other->channels_);
+ std::swap(height_, other->height_);
+ std::swap(width_, other->width_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata BlobProto::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = BlobProto_descriptor_;
+ metadata.reflection = BlobProto_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// BlobProto
+
+// optional .caffe.BlobShape shape = 7;
+bool BlobProto::has_shape() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void BlobProto::set_has_shape() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void BlobProto::clear_has_shape() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void BlobProto::clear_shape() {
+ if (shape_ != NULL) shape_->::caffe::BlobShape::Clear();
+ clear_has_shape();
+}
+const ::caffe::BlobShape& BlobProto::shape() const {
+ // @@protoc_insertion_point(field_get:caffe.BlobProto.shape)
+ return shape_ != NULL ? *shape_
+ : *::caffe::BlobShape::internal_default_instance();
+}
+::caffe::BlobShape* BlobProto::mutable_shape() {
+ set_has_shape();
+ if (shape_ == NULL) {
+ shape_ = new ::caffe::BlobShape;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.BlobProto.shape)
+ return shape_;
+}
+::caffe::BlobShape* BlobProto::release_shape() {
+ // @@protoc_insertion_point(field_release:caffe.BlobProto.shape)
+ clear_has_shape();
+ ::caffe::BlobShape* temp = shape_;
+ shape_ = NULL;
+ return temp;
+}
+void BlobProto::set_allocated_shape(::caffe::BlobShape* shape) {
+ delete shape_;
+ shape_ = shape;
+ if (shape) {
+ set_has_shape();
+ } else {
+ clear_has_shape();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.BlobProto.shape)
+}
+
+// repeated float data = 5 [packed = true];
+int BlobProto::data_size() const {
+ return data_.size();
+}
+void BlobProto::clear_data() {
+ data_.Clear();
+}
+float BlobProto::data(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.BlobProto.data)
+ return data_.Get(index);
+}
+void BlobProto::set_data(int index, float value) {
+ data_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.BlobProto.data)
+}
+void BlobProto::add_data(float value) {
+ data_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.BlobProto.data)
+}
+const ::google::protobuf::RepeatedField< float >&
+BlobProto::data() const {
+ // @@protoc_insertion_point(field_list:caffe.BlobProto.data)
+ return data_;
+}
+::google::protobuf::RepeatedField< float >*
+BlobProto::mutable_data() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.BlobProto.data)
+ return &data_;
+}
+
+// repeated float diff = 6 [packed = true];
+int BlobProto::diff_size() const {
+ return diff_.size();
+}
+void BlobProto::clear_diff() {
+ diff_.Clear();
+}
+float BlobProto::diff(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.BlobProto.diff)
+ return diff_.Get(index);
+}
+void BlobProto::set_diff(int index, float value) {
+ diff_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.BlobProto.diff)
+}
+void BlobProto::add_diff(float value) {
+ diff_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.BlobProto.diff)
+}
+const ::google::protobuf::RepeatedField< float >&
+BlobProto::diff() const {
+ // @@protoc_insertion_point(field_list:caffe.BlobProto.diff)
+ return diff_;
+}
+::google::protobuf::RepeatedField< float >*
+BlobProto::mutable_diff() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.BlobProto.diff)
+ return &diff_;
+}
+
+// repeated double double_data = 8 [packed = true];
+int BlobProto::double_data_size() const {
+ return double_data_.size();
+}
+void BlobProto::clear_double_data() {
+ double_data_.Clear();
+}
+double BlobProto::double_data(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.BlobProto.double_data)
+ return double_data_.Get(index);
+}
+void BlobProto::set_double_data(int index, double value) {
+ double_data_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.BlobProto.double_data)
+}
+void BlobProto::add_double_data(double value) {
+ double_data_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.BlobProto.double_data)
+}
+const ::google::protobuf::RepeatedField< double >&
+BlobProto::double_data() const {
+ // @@protoc_insertion_point(field_list:caffe.BlobProto.double_data)
+ return double_data_;
+}
+::google::protobuf::RepeatedField< double >*
+BlobProto::mutable_double_data() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.BlobProto.double_data)
+ return &double_data_;
+}
+
+// repeated double double_diff = 9 [packed = true];
+int BlobProto::double_diff_size() const {
+ return double_diff_.size();
+}
+void BlobProto::clear_double_diff() {
+ double_diff_.Clear();
+}
+double BlobProto::double_diff(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.BlobProto.double_diff)
+ return double_diff_.Get(index);
+}
+void BlobProto::set_double_diff(int index, double value) {
+ double_diff_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.BlobProto.double_diff)
+}
+void BlobProto::add_double_diff(double value) {
+ double_diff_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.BlobProto.double_diff)
+}
+const ::google::protobuf::RepeatedField< double >&
+BlobProto::double_diff() const {
+ // @@protoc_insertion_point(field_list:caffe.BlobProto.double_diff)
+ return double_diff_;
+}
+::google::protobuf::RepeatedField< double >*
+BlobProto::mutable_double_diff() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.BlobProto.double_diff)
+ return &double_diff_;
+}
+
+// optional int32 num = 1 [default = 0];
+bool BlobProto::has_num() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+void BlobProto::set_has_num() {
+ _has_bits_[0] |= 0x00000020u;
+}
+void BlobProto::clear_has_num() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+void BlobProto::clear_num() {
+ num_ = 0;
+ clear_has_num();
+}
+::google::protobuf::int32 BlobProto::num() const {
+ // @@protoc_insertion_point(field_get:caffe.BlobProto.num)
+ return num_;
+}
+void BlobProto::set_num(::google::protobuf::int32 value) {
+ set_has_num();
+ num_ = value;
+ // @@protoc_insertion_point(field_set:caffe.BlobProto.num)
+}
+
+// optional int32 channels = 2 [default = 0];
+bool BlobProto::has_channels() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+void BlobProto::set_has_channels() {
+ _has_bits_[0] |= 0x00000040u;
+}
+void BlobProto::clear_has_channels() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+void BlobProto::clear_channels() {
+ channels_ = 0;
+ clear_has_channels();
+}
+::google::protobuf::int32 BlobProto::channels() const {
+ // @@protoc_insertion_point(field_get:caffe.BlobProto.channels)
+ return channels_;
+}
+void BlobProto::set_channels(::google::protobuf::int32 value) {
+ set_has_channels();
+ channels_ = value;
+ // @@protoc_insertion_point(field_set:caffe.BlobProto.channels)
+}
+
+// optional int32 height = 3 [default = 0];
+bool BlobProto::has_height() const {
+ return (_has_bits_[0] & 0x00000080u) != 0;
+}
+void BlobProto::set_has_height() {
+ _has_bits_[0] |= 0x00000080u;
+}
+void BlobProto::clear_has_height() {
+ _has_bits_[0] &= ~0x00000080u;
+}
+void BlobProto::clear_height() {
+ height_ = 0;
+ clear_has_height();
+}
+::google::protobuf::int32 BlobProto::height() const {
+ // @@protoc_insertion_point(field_get:caffe.BlobProto.height)
+ return height_;
+}
+void BlobProto::set_height(::google::protobuf::int32 value) {
+ set_has_height();
+ height_ = value;
+ // @@protoc_insertion_point(field_set:caffe.BlobProto.height)
+}
+
+// optional int32 width = 4 [default = 0];
+bool BlobProto::has_width() const {
+ return (_has_bits_[0] & 0x00000100u) != 0;
+}
+void BlobProto::set_has_width() {
+ _has_bits_[0] |= 0x00000100u;
+}
+void BlobProto::clear_has_width() {
+ _has_bits_[0] &= ~0x00000100u;
+}
+void BlobProto::clear_width() {
+ width_ = 0;
+ clear_has_width();
+}
+::google::protobuf::int32 BlobProto::width() const {
+ // @@protoc_insertion_point(field_get:caffe.BlobProto.width)
+ return width_;
+}
+void BlobProto::set_width(::google::protobuf::int32 value) {
+ set_has_width();
+ width_ = value;
+ // @@protoc_insertion_point(field_set:caffe.BlobProto.width)
+}
+
+inline const BlobProto* BlobProto::internal_default_instance() {
+ return &BlobProto_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int BlobProtoVector::kBlobsFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+BlobProtoVector::BlobProtoVector()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.BlobProtoVector)
+}
+
+void BlobProtoVector::InitAsDefaultInstance() {
+}
+
+BlobProtoVector::BlobProtoVector(const BlobProtoVector& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.BlobProtoVector)
+}
+
+void BlobProtoVector::SharedCtor() {
+ _cached_size_ = 0;
+}
+
+BlobProtoVector::~BlobProtoVector() {
+ // @@protoc_insertion_point(destructor:caffe.BlobProtoVector)
+ SharedDtor();
+}
+
+void BlobProtoVector::SharedDtor() {
+}
+
+void BlobProtoVector::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* BlobProtoVector::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return BlobProtoVector_descriptor_;
+}
+
+const BlobProtoVector& BlobProtoVector::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<BlobProtoVector> BlobProtoVector_default_instance_;
+
+BlobProtoVector* BlobProtoVector::New(::google::protobuf::Arena* arena) const {
+ BlobProtoVector* n = new BlobProtoVector;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void BlobProtoVector::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.BlobProtoVector)
+ blobs_.Clear();
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool BlobProtoVector::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.BlobProtoVector)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // repeated .caffe.BlobProto blobs = 1;
+ case 1: {
+ if (tag == 10) {
+ DO_(input->IncrementRecursionDepth());
+ parse_loop_blobs:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
+ input, add_blobs()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(10)) goto parse_loop_blobs;
+ input->UnsafeDecrementRecursionDepth();
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.BlobProtoVector)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.BlobProtoVector)
+ return false;
+#undef DO_
+}
+
+void BlobProtoVector::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.BlobProtoVector)
+ // repeated .caffe.BlobProto blobs = 1;
+ for (unsigned int i = 0, n = this->blobs_size(); i < n; i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 1, this->blobs(i), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.BlobProtoVector)
+}
+
+::google::protobuf::uint8* BlobProtoVector::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.BlobProtoVector)
+ // repeated .caffe.BlobProto blobs = 1;
+ for (unsigned int i = 0, n = this->blobs_size(); i < n; i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 1, this->blobs(i), false, target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.BlobProtoVector)
+ return target;
+}
+
+size_t BlobProtoVector::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.BlobProtoVector)
+ size_t total_size = 0;
+
+ // repeated .caffe.BlobProto blobs = 1;
+ {
+ unsigned int count = this->blobs_size();
+ total_size += 1UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->blobs(i));
+ }
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void BlobProtoVector::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.BlobProtoVector)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const BlobProtoVector* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const BlobProtoVector>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.BlobProtoVector)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.BlobProtoVector)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void BlobProtoVector::MergeFrom(const BlobProtoVector& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.BlobProtoVector)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void BlobProtoVector::UnsafeMergeFrom(const BlobProtoVector& from) {
+ GOOGLE_DCHECK(&from != this);
+ blobs_.MergeFrom(from.blobs_);
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void BlobProtoVector::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.BlobProtoVector)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void BlobProtoVector::CopyFrom(const BlobProtoVector& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.BlobProtoVector)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool BlobProtoVector::IsInitialized() const {
+
+ return true;
+}
+
+void BlobProtoVector::Swap(BlobProtoVector* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void BlobProtoVector::InternalSwap(BlobProtoVector* other) {
+ blobs_.UnsafeArenaSwap(&other->blobs_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata BlobProtoVector::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = BlobProtoVector_descriptor_;
+ metadata.reflection = BlobProtoVector_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// BlobProtoVector
+
+// repeated .caffe.BlobProto blobs = 1;
+int BlobProtoVector::blobs_size() const {
+ return blobs_.size();
+}
+void BlobProtoVector::clear_blobs() {
+ blobs_.Clear();
+}
+const ::caffe::BlobProto& BlobProtoVector::blobs(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.BlobProtoVector.blobs)
+ return blobs_.Get(index);
+}
+::caffe::BlobProto* BlobProtoVector::mutable_blobs(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.BlobProtoVector.blobs)
+ return blobs_.Mutable(index);
+}
+::caffe::BlobProto* BlobProtoVector::add_blobs() {
+ // @@protoc_insertion_point(field_add:caffe.BlobProtoVector.blobs)
+ return blobs_.Add();
+}
+::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
+BlobProtoVector::mutable_blobs() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.BlobProtoVector.blobs)
+ return &blobs_;
+}
+const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
+BlobProtoVector::blobs() const {
+ // @@protoc_insertion_point(field_list:caffe.BlobProtoVector.blobs)
+ return blobs_;
+}
+
+inline const BlobProtoVector* BlobProtoVector::internal_default_instance() {
+ return &BlobProtoVector_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int PermuteParameter::kOrderFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+PermuteParameter::PermuteParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.PermuteParameter)
+}
+
+void PermuteParameter::InitAsDefaultInstance() {
+}
+
+PermuteParameter::PermuteParameter(const PermuteParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.PermuteParameter)
+}
+
+void PermuteParameter::SharedCtor() {
+ _cached_size_ = 0;
+}
+
+PermuteParameter::~PermuteParameter() {
+ // @@protoc_insertion_point(destructor:caffe.PermuteParameter)
+ SharedDtor();
+}
+
+void PermuteParameter::SharedDtor() {
+}
+
+void PermuteParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* PermuteParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return PermuteParameter_descriptor_;
+}
+
+const PermuteParameter& PermuteParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<PermuteParameter> PermuteParameter_default_instance_;
+
+PermuteParameter* PermuteParameter::New(::google::protobuf::Arena* arena) const {
+ PermuteParameter* n = new PermuteParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void PermuteParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.PermuteParameter)
+ order_.Clear();
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool PermuteParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.PermuteParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // repeated uint32 order = 1;
+ case 1: {
+ if (tag == 8) {
+ parse_order:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ 1, 8, input, this->mutable_order())));
+ } else if (tag == 10) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, this->mutable_order())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(8)) goto parse_order;
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.PermuteParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.PermuteParameter)
+ return false;
+#undef DO_
+}
+
+void PermuteParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.PermuteParameter)
+ // repeated uint32 order = 1;
+ for (int i = 0; i < this->order_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(
+ 1, this->order(i), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.PermuteParameter)
+}
+
+::google::protobuf::uint8* PermuteParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.PermuteParameter)
+ // repeated uint32 order = 1;
+ for (int i = 0; i < this->order_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteUInt32ToArray(1, this->order(i), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.PermuteParameter)
+ return target;
+}
+
+size_t PermuteParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.PermuteParameter)
+ size_t total_size = 0;
+
+ // repeated uint32 order = 1;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->order_size();
+ for (unsigned int i = 0; i < count; i++) {
+ data_size += ::google::protobuf::internal::WireFormatLite::
+ UInt32Size(this->order(i));
+ }
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->order_size());
+ total_size += data_size;
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void PermuteParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.PermuteParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const PermuteParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const PermuteParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.PermuteParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.PermuteParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void PermuteParameter::MergeFrom(const PermuteParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.PermuteParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void PermuteParameter::UnsafeMergeFrom(const PermuteParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ order_.UnsafeMergeFrom(from.order_);
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void PermuteParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.PermuteParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void PermuteParameter::CopyFrom(const PermuteParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.PermuteParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool PermuteParameter::IsInitialized() const {
+
+ return true;
+}
+
+void PermuteParameter::Swap(PermuteParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void PermuteParameter::InternalSwap(PermuteParameter* other) {
+ order_.UnsafeArenaSwap(&other->order_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata PermuteParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = PermuteParameter_descriptor_;
+ metadata.reflection = PermuteParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// PermuteParameter
+
+// repeated uint32 order = 1;
+int PermuteParameter::order_size() const {
+ return order_.size();
+}
+void PermuteParameter::clear_order() {
+ order_.Clear();
+}
+::google::protobuf::uint32 PermuteParameter::order(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.PermuteParameter.order)
+ return order_.Get(index);
+}
+void PermuteParameter::set_order(int index, ::google::protobuf::uint32 value) {
+ order_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.PermuteParameter.order)
+}
+void PermuteParameter::add_order(::google::protobuf::uint32 value) {
+ order_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.PermuteParameter.order)
+}
+const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+PermuteParameter::order() const {
+ // @@protoc_insertion_point(field_list:caffe.PermuteParameter.order)
+ return order_;
+}
+::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+PermuteParameter::mutable_order() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.PermuteParameter.order)
+ return &order_;
+}
+
+inline const PermuteParameter* PermuteParameter::internal_default_instance() {
+ return &PermuteParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int NormalizeBBoxParameter::kAcrossSpatialFieldNumber;
+const int NormalizeBBoxParameter::kScaleFillerFieldNumber;
+const int NormalizeBBoxParameter::kChannelSharedFieldNumber;
+const int NormalizeBBoxParameter::kEpsFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+NormalizeBBoxParameter::NormalizeBBoxParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.NormalizeBBoxParameter)
+}
+
+void NormalizeBBoxParameter::InitAsDefaultInstance() {
+ scale_filler_ = const_cast< ::caffe::FillerParameter*>(
+ ::caffe::FillerParameter::internal_default_instance());
+}
+
+NormalizeBBoxParameter::NormalizeBBoxParameter(const NormalizeBBoxParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.NormalizeBBoxParameter)
+}
+
+void NormalizeBBoxParameter::SharedCtor() {
+ _cached_size_ = 0;
+ scale_filler_ = NULL;
+ across_spatial_ = true;
+ channel_shared_ = true;
+ eps_ = 1e-10f;
+}
+
+NormalizeBBoxParameter::~NormalizeBBoxParameter() {
+ // @@protoc_insertion_point(destructor:caffe.NormalizeBBoxParameter)
+ SharedDtor();
+}
+
+void NormalizeBBoxParameter::SharedDtor() {
+ if (this != &NormalizeBBoxParameter_default_instance_.get()) {
+ delete scale_filler_;
+ }
+}
+
+void NormalizeBBoxParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* NormalizeBBoxParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return NormalizeBBoxParameter_descriptor_;
+}
+
+const NormalizeBBoxParameter& NormalizeBBoxParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<NormalizeBBoxParameter> NormalizeBBoxParameter_default_instance_;
+
+NormalizeBBoxParameter* NormalizeBBoxParameter::New(::google::protobuf::Arena* arena) const {
+ NormalizeBBoxParameter* n = new NormalizeBBoxParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void NormalizeBBoxParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.NormalizeBBoxParameter)
+ if (_has_bits_[0 / 32] & 15u) {
+ across_spatial_ = true;
+ if (has_scale_filler()) {
+ if (scale_filler_ != NULL) scale_filler_->::caffe::FillerParameter::Clear();
+ }
+ channel_shared_ = true;
+ eps_ = 1e-10f;
+ }
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool NormalizeBBoxParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.NormalizeBBoxParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional bool across_spatial = 1 [default = true];
+ case 1: {
+ if (tag == 8) {
+ set_has_across_spatial();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &across_spatial_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(18)) goto parse_scale_filler;
+ break;
+ }
+
+ // optional .caffe.FillerParameter scale_filler = 2;
+ case 2: {
+ if (tag == 18) {
+ parse_scale_filler:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_scale_filler()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(24)) goto parse_channel_shared;
+ break;
+ }
+
+ // optional bool channel_shared = 3 [default = true];
+ case 3: {
+ if (tag == 24) {
+ parse_channel_shared:
+ set_has_channel_shared();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &channel_shared_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(37)) goto parse_eps;
+ break;
+ }
+
+ // optional float eps = 4 [default = 1e-10];
+ case 4: {
+ if (tag == 37) {
+ parse_eps:
+ set_has_eps();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &eps_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.NormalizeBBoxParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.NormalizeBBoxParameter)
+ return false;
+#undef DO_
+}
+
+void NormalizeBBoxParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.NormalizeBBoxParameter)
+ // optional bool across_spatial = 1 [default = true];
+ if (has_across_spatial()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(1, this->across_spatial(), output);
+ }
+
+ // optional .caffe.FillerParameter scale_filler = 2;
+ if (has_scale_filler()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 2, *this->scale_filler_, output);
+ }
+
+ // optional bool channel_shared = 3 [default = true];
+ if (has_channel_shared()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(3, this->channel_shared(), output);
+ }
+
+ // optional float eps = 4 [default = 1e-10];
+ if (has_eps()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(4, this->eps(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.NormalizeBBoxParameter)
+}
+
+::google::protobuf::uint8* NormalizeBBoxParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.NormalizeBBoxParameter)
+ // optional bool across_spatial = 1 [default = true];
+ if (has_across_spatial()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->across_spatial(), target);
+ }
+
+ // optional .caffe.FillerParameter scale_filler = 2;
+ if (has_scale_filler()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 2, *this->scale_filler_, false, target);
+ }
+
+ // optional bool channel_shared = 3 [default = true];
+ if (has_channel_shared()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(3, this->channel_shared(), target);
+ }
+
+ // optional float eps = 4 [default = 1e-10];
+ if (has_eps()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(4, this->eps(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.NormalizeBBoxParameter)
+ return target;
+}
+
+size_t NormalizeBBoxParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.NormalizeBBoxParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 15u) {
+ // optional bool across_spatial = 1 [default = true];
+ if (has_across_spatial()) {
+ total_size += 1 + 1;
+ }
+
+ // optional .caffe.FillerParameter scale_filler = 2;
+ if (has_scale_filler()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->scale_filler_);
+ }
+
+ // optional bool channel_shared = 3 [default = true];
+ if (has_channel_shared()) {
+ total_size += 1 + 1;
+ }
+
+ // optional float eps = 4 [default = 1e-10];
+ if (has_eps()) {
+ total_size += 1 + 4;
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void NormalizeBBoxParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.NormalizeBBoxParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const NormalizeBBoxParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const NormalizeBBoxParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.NormalizeBBoxParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.NormalizeBBoxParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void NormalizeBBoxParameter::MergeFrom(const NormalizeBBoxParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.NormalizeBBoxParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void NormalizeBBoxParameter::UnsafeMergeFrom(const NormalizeBBoxParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_across_spatial()) {
+ set_across_spatial(from.across_spatial());
+ }
+ if (from.has_scale_filler()) {
+ mutable_scale_filler()->::caffe::FillerParameter::MergeFrom(from.scale_filler());
+ }
+ if (from.has_channel_shared()) {
+ set_channel_shared(from.channel_shared());
+ }
+ if (from.has_eps()) {
+ set_eps(from.eps());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void NormalizeBBoxParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.NormalizeBBoxParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void NormalizeBBoxParameter::CopyFrom(const NormalizeBBoxParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.NormalizeBBoxParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool NormalizeBBoxParameter::IsInitialized() const {
+
+ return true;
+}
+
+void NormalizeBBoxParameter::Swap(NormalizeBBoxParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void NormalizeBBoxParameter::InternalSwap(NormalizeBBoxParameter* other) {
+ std::swap(across_spatial_, other->across_spatial_);
+ std::swap(scale_filler_, other->scale_filler_);
+ std::swap(channel_shared_, other->channel_shared_);
+ std::swap(eps_, other->eps_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata NormalizeBBoxParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = NormalizeBBoxParameter_descriptor_;
+ metadata.reflection = NormalizeBBoxParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// NormalizeBBoxParameter
+
+// optional bool across_spatial = 1 [default = true];
+bool NormalizeBBoxParameter::has_across_spatial() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void NormalizeBBoxParameter::set_has_across_spatial() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void NormalizeBBoxParameter::clear_has_across_spatial() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void NormalizeBBoxParameter::clear_across_spatial() {
+ across_spatial_ = true;
+ clear_has_across_spatial();
+}
+bool NormalizeBBoxParameter::across_spatial() const {
+ // @@protoc_insertion_point(field_get:caffe.NormalizeBBoxParameter.across_spatial)
+ return across_spatial_;
+}
+void NormalizeBBoxParameter::set_across_spatial(bool value) {
+ set_has_across_spatial();
+ across_spatial_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NormalizeBBoxParameter.across_spatial)
+}
+
+// optional .caffe.FillerParameter scale_filler = 2;
+bool NormalizeBBoxParameter::has_scale_filler() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void NormalizeBBoxParameter::set_has_scale_filler() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void NormalizeBBoxParameter::clear_has_scale_filler() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void NormalizeBBoxParameter::clear_scale_filler() {
+ if (scale_filler_ != NULL) scale_filler_->::caffe::FillerParameter::Clear();
+ clear_has_scale_filler();
+}
+const ::caffe::FillerParameter& NormalizeBBoxParameter::scale_filler() const {
+ // @@protoc_insertion_point(field_get:caffe.NormalizeBBoxParameter.scale_filler)
+ return scale_filler_ != NULL ? *scale_filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+::caffe::FillerParameter* NormalizeBBoxParameter::mutable_scale_filler() {
+ set_has_scale_filler();
+ if (scale_filler_ == NULL) {
+ scale_filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.NormalizeBBoxParameter.scale_filler)
+ return scale_filler_;
+}
+::caffe::FillerParameter* NormalizeBBoxParameter::release_scale_filler() {
+ // @@protoc_insertion_point(field_release:caffe.NormalizeBBoxParameter.scale_filler)
+ clear_has_scale_filler();
+ ::caffe::FillerParameter* temp = scale_filler_;
+ scale_filler_ = NULL;
+ return temp;
+}
+void NormalizeBBoxParameter::set_allocated_scale_filler(::caffe::FillerParameter* scale_filler) {
+ delete scale_filler_;
+ scale_filler_ = scale_filler;
+ if (scale_filler) {
+ set_has_scale_filler();
+ } else {
+ clear_has_scale_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.NormalizeBBoxParameter.scale_filler)
+}
+
+// optional bool channel_shared = 3 [default = true];
+bool NormalizeBBoxParameter::has_channel_shared() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void NormalizeBBoxParameter::set_has_channel_shared() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void NormalizeBBoxParameter::clear_has_channel_shared() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void NormalizeBBoxParameter::clear_channel_shared() {
+ channel_shared_ = true;
+ clear_has_channel_shared();
+}
+bool NormalizeBBoxParameter::channel_shared() const {
+ // @@protoc_insertion_point(field_get:caffe.NormalizeBBoxParameter.channel_shared)
+ return channel_shared_;
+}
+void NormalizeBBoxParameter::set_channel_shared(bool value) {
+ set_has_channel_shared();
+ channel_shared_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NormalizeBBoxParameter.channel_shared)
+}
+
+// optional float eps = 4 [default = 1e-10];
+bool NormalizeBBoxParameter::has_eps() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+void NormalizeBBoxParameter::set_has_eps() {
+ _has_bits_[0] |= 0x00000008u;
+}
+void NormalizeBBoxParameter::clear_has_eps() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+void NormalizeBBoxParameter::clear_eps() {
+ eps_ = 1e-10f;
+ clear_has_eps();
+}
+float NormalizeBBoxParameter::eps() const {
+ // @@protoc_insertion_point(field_get:caffe.NormalizeBBoxParameter.eps)
+ return eps_;
+}
+void NormalizeBBoxParameter::set_eps(float value) {
+ set_has_eps();
+ eps_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NormalizeBBoxParameter.eps)
+}
+
+inline const NormalizeBBoxParameter* NormalizeBBoxParameter::internal_default_instance() {
+ return &NormalizeBBoxParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+const ::google::protobuf::EnumDescriptor* PriorBoxParameter_CodeType_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return PriorBoxParameter_CodeType_descriptor_;
+}
+bool PriorBoxParameter_CodeType_IsValid(int value) {
+ switch (value) {
+ case 1:
+ case 2:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const PriorBoxParameter_CodeType PriorBoxParameter::CORNER;
+const PriorBoxParameter_CodeType PriorBoxParameter::CENTER_SIZE;
+const PriorBoxParameter_CodeType PriorBoxParameter::CodeType_MIN;
+const PriorBoxParameter_CodeType PriorBoxParameter::CodeType_MAX;
+const int PriorBoxParameter::CodeType_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int PriorBoxParameter::kMinSizeFieldNumber;
+const int PriorBoxParameter::kMaxSizeFieldNumber;
+const int PriorBoxParameter::kAspectRatioFieldNumber;
+const int PriorBoxParameter::kFlipFieldNumber;
+const int PriorBoxParameter::kClipFieldNumber;
+const int PriorBoxParameter::kVarianceFieldNumber;
+const int PriorBoxParameter::kImgSizeFieldNumber;
+const int PriorBoxParameter::kImgHFieldNumber;
+const int PriorBoxParameter::kImgWFieldNumber;
+const int PriorBoxParameter::kStepFieldNumber;
+const int PriorBoxParameter::kStepHFieldNumber;
+const int PriorBoxParameter::kStepWFieldNumber;
+const int PriorBoxParameter::kOffsetFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+PriorBoxParameter::PriorBoxParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.PriorBoxParameter)
+}
+
+void PriorBoxParameter::InitAsDefaultInstance() {
+}
+
+PriorBoxParameter::PriorBoxParameter(const PriorBoxParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.PriorBoxParameter)
+}
+
+void PriorBoxParameter::SharedCtor() {
+ _cached_size_ = 0;
+ ::memset(&min_size_, 0, reinterpret_cast<char*>(&step_w_) -
+ reinterpret_cast<char*>(&min_size_) + sizeof(step_w_));
+ flip_ = true;
+ clip_ = true;
+ offset_ = 0.5f;
+}
+
+PriorBoxParameter::~PriorBoxParameter() {
+ // @@protoc_insertion_point(destructor:caffe.PriorBoxParameter)
+ SharedDtor();
+}
+
+void PriorBoxParameter::SharedDtor() {
+}
+
+void PriorBoxParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* PriorBoxParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return PriorBoxParameter_descriptor_;
+}
+
+const PriorBoxParameter& PriorBoxParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<PriorBoxParameter> PriorBoxParameter_default_instance_;
+
+PriorBoxParameter* PriorBoxParameter::New(::google::protobuf::Arena* arena) const {
+ PriorBoxParameter* n = new PriorBoxParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void PriorBoxParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.PriorBoxParameter)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(PriorBoxParameter, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<PriorBoxParameter*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ if (_has_bits_[0 / 32] & 219u) {
+ ZR_(min_size_, img_h_);
+ flip_ = true;
+ clip_ = true;
+ }
+ if (_has_bits_[8 / 32] & 7936u) {
+ ZR_(img_w_, step_w_);
+ offset_ = 0.5f;
+ }
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ aspect_ratio_.Clear();
+ variance_.Clear();
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool PriorBoxParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.PriorBoxParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional float min_size = 1;
+ case 1: {
+ if (tag == 13) {
+ set_has_min_size();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &min_size_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(21)) goto parse_max_size;
+ break;
+ }
+
+ // optional float max_size = 2;
+ case 2: {
+ if (tag == 21) {
+ parse_max_size:
+ set_has_max_size();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &max_size_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(29)) goto parse_aspect_ratio;
+ break;
+ }
+
+ // repeated float aspect_ratio = 3;
+ case 3: {
+ if (tag == 29) {
+ parse_aspect_ratio:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ 1, 29, input, this->mutable_aspect_ratio())));
+ } else if (tag == 26) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, this->mutable_aspect_ratio())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(29)) goto parse_aspect_ratio;
+ if (input->ExpectTag(32)) goto parse_flip;
+ break;
+ }
+
+ // optional bool flip = 4 [default = true];
+ case 4: {
+ if (tag == 32) {
+ parse_flip:
+ set_has_flip();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &flip_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(40)) goto parse_clip;
+ break;
+ }
+
+ // optional bool clip = 5 [default = true];
+ case 5: {
+ if (tag == 40) {
+ parse_clip:
+ set_has_clip();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &clip_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(53)) goto parse_variance;
+ break;
+ }
+
+ // repeated float variance = 6;
+ case 6: {
+ if (tag == 53) {
+ parse_variance:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ 1, 53, input, this->mutable_variance())));
+ } else if (tag == 50) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, this->mutable_variance())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(53)) goto parse_variance;
+ if (input->ExpectTag(56)) goto parse_img_size;
+ break;
+ }
+
+ // optional uint32 img_size = 7;
+ case 7: {
+ if (tag == 56) {
+ parse_img_size:
+ set_has_img_size();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &img_size_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(64)) goto parse_img_h;
+ break;
+ }
+
+ // optional uint32 img_h = 8;
+ case 8: {
+ if (tag == 64) {
+ parse_img_h:
+ set_has_img_h();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &img_h_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(72)) goto parse_img_w;
+ break;
+ }
+
+ // optional uint32 img_w = 9;
+ case 9: {
+ if (tag == 72) {
+ parse_img_w:
+ set_has_img_w();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &img_w_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(85)) goto parse_step;
+ break;
+ }
+
+ // optional float step = 10;
+ case 10: {
+ if (tag == 85) {
+ parse_step:
+ set_has_step();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &step_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(93)) goto parse_step_h;
+ break;
+ }
+
+ // optional float step_h = 11;
+ case 11: {
+ if (tag == 93) {
+ parse_step_h:
+ set_has_step_h();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &step_h_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(101)) goto parse_step_w;
+ break;
+ }
+
+ // optional float step_w = 12;
+ case 12: {
+ if (tag == 101) {
+ parse_step_w:
+ set_has_step_w();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &step_w_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(109)) goto parse_offset;
+ break;
+ }
+
+ // optional float offset = 13 [default = 0.5];
+ case 13: {
+ if (tag == 109) {
+ parse_offset:
+ set_has_offset();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &offset_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.PriorBoxParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.PriorBoxParameter)
+ return false;
+#undef DO_
+}
+
+void PriorBoxParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.PriorBoxParameter)
+ // optional float min_size = 1;
+ if (has_min_size()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->min_size(), output);
+ }
+
+ // optional float max_size = 2;
+ if (has_max_size()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->max_size(), output);
+ }
+
+ // repeated float aspect_ratio = 3;
+ for (int i = 0; i < this->aspect_ratio_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(
+ 3, this->aspect_ratio(i), output);
+ }
+
+ // optional bool flip = 4 [default = true];
+ if (has_flip()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(4, this->flip(), output);
+ }
+
+ // optional bool clip = 5 [default = true];
+ if (has_clip()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(5, this->clip(), output);
+ }
+
+ // repeated float variance = 6;
+ for (int i = 0; i < this->variance_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(
+ 6, this->variance(i), output);
+ }
+
+ // optional uint32 img_size = 7;
+ if (has_img_size()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(7, this->img_size(), output);
+ }
+
+ // optional uint32 img_h = 8;
+ if (has_img_h()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(8, this->img_h(), output);
+ }
+
+ // optional uint32 img_w = 9;
+ if (has_img_w()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(9, this->img_w(), output);
+ }
+
+ // optional float step = 10;
+ if (has_step()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(10, this->step(), output);
+ }
+
+ // optional float step_h = 11;
+ if (has_step_h()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(11, this->step_h(), output);
+ }
+
+ // optional float step_w = 12;
+ if (has_step_w()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(12, this->step_w(), output);
+ }
+
+ // optional float offset = 13 [default = 0.5];
+ if (has_offset()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(13, this->offset(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.PriorBoxParameter)
+}
+
+::google::protobuf::uint8* PriorBoxParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.PriorBoxParameter)
+ // optional float min_size = 1;
+ if (has_min_size()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->min_size(), target);
+ }
+
+ // optional float max_size = 2;
+ if (has_max_size()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->max_size(), target);
+ }
+
+ // repeated float aspect_ratio = 3;
+ for (int i = 0; i < this->aspect_ratio_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteFloatToArray(3, this->aspect_ratio(i), target);
+ }
+
+ // optional bool flip = 4 [default = true];
+ if (has_flip()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(4, this->flip(), target);
+ }
+
+ // optional bool clip = 5 [default = true];
+ if (has_clip()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(5, this->clip(), target);
+ }
+
+ // repeated float variance = 6;
+ for (int i = 0; i < this->variance_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteFloatToArray(6, this->variance(i), target);
+ }
+
+ // optional uint32 img_size = 7;
+ if (has_img_size()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(7, this->img_size(), target);
+ }
+
+ // optional uint32 img_h = 8;
+ if (has_img_h()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(8, this->img_h(), target);
+ }
+
+ // optional uint32 img_w = 9;
+ if (has_img_w()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(9, this->img_w(), target);
+ }
+
+ // optional float step = 10;
+ if (has_step()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(10, this->step(), target);
+ }
+
+ // optional float step_h = 11;
+ if (has_step_h()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(11, this->step_h(), target);
+ }
+
+ // optional float step_w = 12;
+ if (has_step_w()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(12, this->step_w(), target);
+ }
+
+ // optional float offset = 13 [default = 0.5];
+ if (has_offset()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(13, this->offset(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.PriorBoxParameter)
+ return target;
+}
+
+size_t PriorBoxParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.PriorBoxParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 219u) {
+ // optional float min_size = 1;
+ if (has_min_size()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float max_size = 2;
+ if (has_max_size()) {
+ total_size += 1 + 4;
+ }
+
+ // optional bool flip = 4 [default = true];
+ if (has_flip()) {
+ total_size += 1 + 1;
+ }
+
+ // optional bool clip = 5 [default = true];
+ if (has_clip()) {
+ total_size += 1 + 1;
+ }
+
+ // optional uint32 img_size = 7;
+ if (has_img_size()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->img_size());
+ }
+
+ // optional uint32 img_h = 8;
+ if (has_img_h()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->img_h());
+ }
+
+ }
+ if (_has_bits_[8 / 32] & 7936u) {
+ // optional uint32 img_w = 9;
+ if (has_img_w()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->img_w());
+ }
+
+ // optional float step = 10;
+ if (has_step()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float step_h = 11;
+ if (has_step_h()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float step_w = 12;
+ if (has_step_w()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float offset = 13 [default = 0.5];
+ if (has_offset()) {
+ total_size += 1 + 4;
+ }
+
+ }
+ // repeated float aspect_ratio = 3;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->aspect_ratio_size();
+ data_size = 4UL * count;
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->aspect_ratio_size());
+ total_size += data_size;
+ }
+
+ // repeated float variance = 6;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->variance_size();
+ data_size = 4UL * count;
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->variance_size());
+ total_size += data_size;
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void PriorBoxParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.PriorBoxParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const PriorBoxParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const PriorBoxParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.PriorBoxParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.PriorBoxParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void PriorBoxParameter::MergeFrom(const PriorBoxParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.PriorBoxParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void PriorBoxParameter::UnsafeMergeFrom(const PriorBoxParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ aspect_ratio_.UnsafeMergeFrom(from.aspect_ratio_);
+ variance_.UnsafeMergeFrom(from.variance_);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_min_size()) {
+ set_min_size(from.min_size());
+ }
+ if (from.has_max_size()) {
+ set_max_size(from.max_size());
+ }
+ if (from.has_flip()) {
+ set_flip(from.flip());
+ }
+ if (from.has_clip()) {
+ set_clip(from.clip());
+ }
+ if (from.has_img_size()) {
+ set_img_size(from.img_size());
+ }
+ if (from.has_img_h()) {
+ set_img_h(from.img_h());
+ }
+ }
+ if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) {
+ if (from.has_img_w()) {
+ set_img_w(from.img_w());
+ }
+ if (from.has_step()) {
+ set_step(from.step());
+ }
+ if (from.has_step_h()) {
+ set_step_h(from.step_h());
+ }
+ if (from.has_step_w()) {
+ set_step_w(from.step_w());
+ }
+ if (from.has_offset()) {
+ set_offset(from.offset());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void PriorBoxParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.PriorBoxParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void PriorBoxParameter::CopyFrom(const PriorBoxParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.PriorBoxParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool PriorBoxParameter::IsInitialized() const {
+
+ return true;
+}
+
+void PriorBoxParameter::Swap(PriorBoxParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void PriorBoxParameter::InternalSwap(PriorBoxParameter* other) {
+ std::swap(min_size_, other->min_size_);
+ std::swap(max_size_, other->max_size_);
+ aspect_ratio_.UnsafeArenaSwap(&other->aspect_ratio_);
+ std::swap(flip_, other->flip_);
+ std::swap(clip_, other->clip_);
+ variance_.UnsafeArenaSwap(&other->variance_);
+ std::swap(img_size_, other->img_size_);
+ std::swap(img_h_, other->img_h_);
+ std::swap(img_w_, other->img_w_);
+ std::swap(step_, other->step_);
+ std::swap(step_h_, other->step_h_);
+ std::swap(step_w_, other->step_w_);
+ std::swap(offset_, other->offset_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata PriorBoxParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = PriorBoxParameter_descriptor_;
+ metadata.reflection = PriorBoxParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// PriorBoxParameter
+
+// optional float min_size = 1;
+bool PriorBoxParameter::has_min_size() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void PriorBoxParameter::set_has_min_size() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void PriorBoxParameter::clear_has_min_size() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void PriorBoxParameter::clear_min_size() {
+ min_size_ = 0;
+ clear_has_min_size();
+}
+float PriorBoxParameter::min_size() const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.min_size)
+ return min_size_;
+}
+void PriorBoxParameter::set_min_size(float value) {
+ set_has_min_size();
+ min_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.min_size)
+}
+
+// optional float max_size = 2;
+bool PriorBoxParameter::has_max_size() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void PriorBoxParameter::set_has_max_size() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void PriorBoxParameter::clear_has_max_size() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void PriorBoxParameter::clear_max_size() {
+ max_size_ = 0;
+ clear_has_max_size();
+}
+float PriorBoxParameter::max_size() const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.max_size)
+ return max_size_;
+}
+void PriorBoxParameter::set_max_size(float value) {
+ set_has_max_size();
+ max_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.max_size)
+}
+
+// repeated float aspect_ratio = 3;
+int PriorBoxParameter::aspect_ratio_size() const {
+ return aspect_ratio_.size();
+}
+void PriorBoxParameter::clear_aspect_ratio() {
+ aspect_ratio_.Clear();
+}
+float PriorBoxParameter::aspect_ratio(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.aspect_ratio)
+ return aspect_ratio_.Get(index);
+}
+void PriorBoxParameter::set_aspect_ratio(int index, float value) {
+ aspect_ratio_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.aspect_ratio)
+}
+void PriorBoxParameter::add_aspect_ratio(float value) {
+ aspect_ratio_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.PriorBoxParameter.aspect_ratio)
+}
+const ::google::protobuf::RepeatedField< float >&
+PriorBoxParameter::aspect_ratio() const {
+ // @@protoc_insertion_point(field_list:caffe.PriorBoxParameter.aspect_ratio)
+ return aspect_ratio_;
+}
+::google::protobuf::RepeatedField< float >*
+PriorBoxParameter::mutable_aspect_ratio() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.PriorBoxParameter.aspect_ratio)
+ return &aspect_ratio_;
+}
+
+// optional bool flip = 4 [default = true];
+bool PriorBoxParameter::has_flip() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+void PriorBoxParameter::set_has_flip() {
+ _has_bits_[0] |= 0x00000008u;
+}
+void PriorBoxParameter::clear_has_flip() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+void PriorBoxParameter::clear_flip() {
+ flip_ = true;
+ clear_has_flip();
+}
+bool PriorBoxParameter::flip() const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.flip)
+ return flip_;
+}
+void PriorBoxParameter::set_flip(bool value) {
+ set_has_flip();
+ flip_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.flip)
+}
+
+// optional bool clip = 5 [default = true];
+bool PriorBoxParameter::has_clip() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+void PriorBoxParameter::set_has_clip() {
+ _has_bits_[0] |= 0x00000010u;
+}
+void PriorBoxParameter::clear_has_clip() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+void PriorBoxParameter::clear_clip() {
+ clip_ = true;
+ clear_has_clip();
+}
+bool PriorBoxParameter::clip() const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.clip)
+ return clip_;
+}
+void PriorBoxParameter::set_clip(bool value) {
+ set_has_clip();
+ clip_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.clip)
+}
+
+// repeated float variance = 6;
+int PriorBoxParameter::variance_size() const {
+ return variance_.size();
+}
+void PriorBoxParameter::clear_variance() {
+ variance_.Clear();
+}
+float PriorBoxParameter::variance(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.variance)
+ return variance_.Get(index);
+}
+void PriorBoxParameter::set_variance(int index, float value) {
+ variance_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.variance)
+}
+void PriorBoxParameter::add_variance(float value) {
+ variance_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.PriorBoxParameter.variance)
+}
+const ::google::protobuf::RepeatedField< float >&
+PriorBoxParameter::variance() const {
+ // @@protoc_insertion_point(field_list:caffe.PriorBoxParameter.variance)
+ return variance_;
+}
+::google::protobuf::RepeatedField< float >*
+PriorBoxParameter::mutable_variance() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.PriorBoxParameter.variance)
+ return &variance_;
+}
+
+// optional uint32 img_size = 7;
+bool PriorBoxParameter::has_img_size() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+void PriorBoxParameter::set_has_img_size() {
+ _has_bits_[0] |= 0x00000040u;
+}
+void PriorBoxParameter::clear_has_img_size() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+void PriorBoxParameter::clear_img_size() {
+ img_size_ = 0u;
+ clear_has_img_size();
+}
+::google::protobuf::uint32 PriorBoxParameter::img_size() const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.img_size)
+ return img_size_;
+}
+void PriorBoxParameter::set_img_size(::google::protobuf::uint32 value) {
+ set_has_img_size();
+ img_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.img_size)
+}
+
+// optional uint32 img_h = 8;
+bool PriorBoxParameter::has_img_h() const {
+ return (_has_bits_[0] & 0x00000080u) != 0;
+}
+void PriorBoxParameter::set_has_img_h() {
+ _has_bits_[0] |= 0x00000080u;
+}
+void PriorBoxParameter::clear_has_img_h() {
+ _has_bits_[0] &= ~0x00000080u;
+}
+void PriorBoxParameter::clear_img_h() {
+ img_h_ = 0u;
+ clear_has_img_h();
+}
+::google::protobuf::uint32 PriorBoxParameter::img_h() const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.img_h)
+ return img_h_;
+}
+void PriorBoxParameter::set_img_h(::google::protobuf::uint32 value) {
+ set_has_img_h();
+ img_h_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.img_h)
+}
+
+// optional uint32 img_w = 9;
+bool PriorBoxParameter::has_img_w() const {
+ return (_has_bits_[0] & 0x00000100u) != 0;
+}
+void PriorBoxParameter::set_has_img_w() {
+ _has_bits_[0] |= 0x00000100u;
+}
+void PriorBoxParameter::clear_has_img_w() {
+ _has_bits_[0] &= ~0x00000100u;
+}
+void PriorBoxParameter::clear_img_w() {
+ img_w_ = 0u;
+ clear_has_img_w();
+}
+::google::protobuf::uint32 PriorBoxParameter::img_w() const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.img_w)
+ return img_w_;
+}
+void PriorBoxParameter::set_img_w(::google::protobuf::uint32 value) {
+ set_has_img_w();
+ img_w_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.img_w)
+}
+
+// optional float step = 10;
+bool PriorBoxParameter::has_step() const {
+ return (_has_bits_[0] & 0x00000200u) != 0;
+}
+void PriorBoxParameter::set_has_step() {
+ _has_bits_[0] |= 0x00000200u;
+}
+void PriorBoxParameter::clear_has_step() {
+ _has_bits_[0] &= ~0x00000200u;
+}
+void PriorBoxParameter::clear_step() {
+ step_ = 0;
+ clear_has_step();
+}
+float PriorBoxParameter::step() const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.step)
+ return step_;
+}
+void PriorBoxParameter::set_step(float value) {
+ set_has_step();
+ step_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.step)
+}
+
+// optional float step_h = 11;
+bool PriorBoxParameter::has_step_h() const {
+ return (_has_bits_[0] & 0x00000400u) != 0;
+}
+void PriorBoxParameter::set_has_step_h() {
+ _has_bits_[0] |= 0x00000400u;
+}
+void PriorBoxParameter::clear_has_step_h() {
+ _has_bits_[0] &= ~0x00000400u;
+}
+void PriorBoxParameter::clear_step_h() {
+ step_h_ = 0;
+ clear_has_step_h();
+}
+float PriorBoxParameter::step_h() const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.step_h)
+ return step_h_;
+}
+void PriorBoxParameter::set_step_h(float value) {
+ set_has_step_h();
+ step_h_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.step_h)
+}
+
+// optional float step_w = 12;
+bool PriorBoxParameter::has_step_w() const {
+ return (_has_bits_[0] & 0x00000800u) != 0;
+}
+void PriorBoxParameter::set_has_step_w() {
+ _has_bits_[0] |= 0x00000800u;
+}
+void PriorBoxParameter::clear_has_step_w() {
+ _has_bits_[0] &= ~0x00000800u;
+}
+void PriorBoxParameter::clear_step_w() {
+ step_w_ = 0;
+ clear_has_step_w();
+}
+float PriorBoxParameter::step_w() const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.step_w)
+ return step_w_;
+}
+void PriorBoxParameter::set_step_w(float value) {
+ set_has_step_w();
+ step_w_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.step_w)
+}
+
+// optional float offset = 13 [default = 0.5];
+bool PriorBoxParameter::has_offset() const {
+ return (_has_bits_[0] & 0x00001000u) != 0;
+}
+void PriorBoxParameter::set_has_offset() {
+ _has_bits_[0] |= 0x00001000u;
+}
+void PriorBoxParameter::clear_has_offset() {
+ _has_bits_[0] &= ~0x00001000u;
+}
+void PriorBoxParameter::clear_offset() {
+ offset_ = 0.5f;
+ clear_has_offset();
+}
+float PriorBoxParameter::offset() const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.offset)
+ return offset_;
+}
+void PriorBoxParameter::set_offset(float value) {
+ set_has_offset();
+ offset_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.offset)
+}
+
+inline const PriorBoxParameter* PriorBoxParameter::internal_default_instance() {
+ return &PriorBoxParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int DetectionOutputParameter::kNumClassesFieldNumber;
+const int DetectionOutputParameter::kShareLocationFieldNumber;
+const int DetectionOutputParameter::kBackgroundLabelIdFieldNumber;
+const int DetectionOutputParameter::kNmsParamFieldNumber;
+const int DetectionOutputParameter::kSaveOutputParamFieldNumber;
+const int DetectionOutputParameter::kCodeTypeFieldNumber;
+const int DetectionOutputParameter::kVarianceEncodedInTargetFieldNumber;
+const int DetectionOutputParameter::kKeepTopKFieldNumber;
+const int DetectionOutputParameter::kConfidenceThresholdFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+DetectionOutputParameter::DetectionOutputParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.DetectionOutputParameter)
+}
+
+void DetectionOutputParameter::InitAsDefaultInstance() {
+ nms_param_ = const_cast< ::caffe::NonMaximumSuppressionParameter*>(
+ ::caffe::NonMaximumSuppressionParameter::internal_default_instance());
+ save_output_param_ = const_cast< ::caffe::SaveOutputParameter*>(
+ ::caffe::SaveOutputParameter::internal_default_instance());
+}
+
+DetectionOutputParameter::DetectionOutputParameter(const DetectionOutputParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.DetectionOutputParameter)
+}
+
+void DetectionOutputParameter::SharedCtor() {
+ _cached_size_ = 0;
+ nms_param_ = NULL;
+ save_output_param_ = NULL;
+ ::memset(&num_classes_, 0, reinterpret_cast<char*>(&confidence_threshold_) -
+ reinterpret_cast<char*>(&num_classes_) + sizeof(confidence_threshold_));
+ keep_top_k_ = -1;
+ share_location_ = true;
+ code_type_ = 1;
+}
+
+DetectionOutputParameter::~DetectionOutputParameter() {
+ // @@protoc_insertion_point(destructor:caffe.DetectionOutputParameter)
+ SharedDtor();
+}
+
+void DetectionOutputParameter::SharedDtor() {
+ if (this != &DetectionOutputParameter_default_instance_.get()) {
+ delete nms_param_;
+ delete save_output_param_;
+ }
+}
+
+void DetectionOutputParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* DetectionOutputParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return DetectionOutputParameter_descriptor_;
+}
+
+const DetectionOutputParameter& DetectionOutputParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<DetectionOutputParameter> DetectionOutputParameter_default_instance_;
+
+DetectionOutputParameter* DetectionOutputParameter::New(::google::protobuf::Arena* arena) const {
+ DetectionOutputParameter* n = new DetectionOutputParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void DetectionOutputParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.DetectionOutputParameter)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(DetectionOutputParameter, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<DetectionOutputParameter*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ if (_has_bits_[0 / 32] & 255u) {
+ ZR_(num_classes_, variance_encoded_in_target_);
+ share_location_ = true;
+ if (has_nms_param()) {
+ if (nms_param_ != NULL) nms_param_->::caffe::NonMaximumSuppressionParameter::Clear();
+ }
+ if (has_save_output_param()) {
+ if (save_output_param_ != NULL) save_output_param_->::caffe::SaveOutputParameter::Clear();
+ }
+ code_type_ = 1;
+ keep_top_k_ = -1;
+ }
+ confidence_threshold_ = 0;
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool DetectionOutputParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.DetectionOutputParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional uint32 num_classes = 1;
+ case 1: {
+ if (tag == 8) {
+ set_has_num_classes();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &num_classes_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_share_location;
+ break;
+ }
+
+ // optional bool share_location = 2 [default = true];
+ case 2: {
+ if (tag == 16) {
+ parse_share_location:
+ set_has_share_location();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &share_location_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(24)) goto parse_background_label_id;
+ break;
+ }
+
+ // optional int32 background_label_id = 3 [default = 0];
+ case 3: {
+ if (tag == 24) {
+ parse_background_label_id:
+ set_has_background_label_id();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &background_label_id_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(34)) goto parse_nms_param;
+ break;
+ }
+
+ // optional .caffe.NonMaximumSuppressionParameter nms_param = 4;
+ case 4: {
+ if (tag == 34) {
+ parse_nms_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_nms_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(42)) goto parse_save_output_param;
+ break;
+ }
+
+ // optional .caffe.SaveOutputParameter save_output_param = 5;
+ case 5: {
+ if (tag == 42) {
+ parse_save_output_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_save_output_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(48)) goto parse_code_type;
+ break;
+ }
+
+ // optional .caffe.PriorBoxParameter.CodeType code_type = 6 [default = CORNER];
+ case 6: {
+ if (tag == 48) {
+ parse_code_type:
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::PriorBoxParameter_CodeType_IsValid(value)) {
+ set_code_type(static_cast< ::caffe::PriorBoxParameter_CodeType >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(6, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(56)) goto parse_keep_top_k;
+ break;
+ }
+
+ // optional int32 keep_top_k = 7 [default = -1];
+ case 7: {
+ if (tag == 56) {
+ parse_keep_top_k:
+ set_has_keep_top_k();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &keep_top_k_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(64)) goto parse_variance_encoded_in_target;
+ break;
+ }
+
+ // optional bool variance_encoded_in_target = 8 [default = false];
+ case 8: {
+ if (tag == 64) {
+ parse_variance_encoded_in_target:
+ set_has_variance_encoded_in_target();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &variance_encoded_in_target_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(77)) goto parse_confidence_threshold;
+ break;
+ }
+
+ // optional float confidence_threshold = 9;
+ case 9: {
+ if (tag == 77) {
+ parse_confidence_threshold:
+ set_has_confidence_threshold();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &confidence_threshold_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.DetectionOutputParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.DetectionOutputParameter)
+ return false;
+#undef DO_
+}
+
+void DetectionOutputParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.DetectionOutputParameter)
+ // optional uint32 num_classes = 1;
+ if (has_num_classes()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->num_classes(), output);
+ }
+
+ // optional bool share_location = 2 [default = true];
+ if (has_share_location()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->share_location(), output);
+ }
+
+ // optional int32 background_label_id = 3 [default = 0];
+ if (has_background_label_id()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->background_label_id(), output);
+ }
+
+ // optional .caffe.NonMaximumSuppressionParameter nms_param = 4;
+ if (has_nms_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 4, *this->nms_param_, output);
+ }
+
+ // optional .caffe.SaveOutputParameter save_output_param = 5;
+ if (has_save_output_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 5, *this->save_output_param_, output);
+ }
+
+ // optional .caffe.PriorBoxParameter.CodeType code_type = 6 [default = CORNER];
+ if (has_code_type()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 6, this->code_type(), output);
+ }
+
+ // optional int32 keep_top_k = 7 [default = -1];
+ if (has_keep_top_k()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(7, this->keep_top_k(), output);
+ }
+
+ // optional bool variance_encoded_in_target = 8 [default = false];
+ if (has_variance_encoded_in_target()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(8, this->variance_encoded_in_target(), output);
+ }
+
+ // optional float confidence_threshold = 9;
+ if (has_confidence_threshold()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(9, this->confidence_threshold(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.DetectionOutputParameter)
+}
+
+::google::protobuf::uint8* DetectionOutputParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.DetectionOutputParameter)
+ // optional uint32 num_classes = 1;
+ if (has_num_classes()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->num_classes(), target);
+ }
+
+ // optional bool share_location = 2 [default = true];
+ if (has_share_location()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->share_location(), target);
+ }
+
+ // optional int32 background_label_id = 3 [default = 0];
+ if (has_background_label_id()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->background_label_id(), target);
+ }
+
+ // optional .caffe.NonMaximumSuppressionParameter nms_param = 4;
+ if (has_nms_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 4, *this->nms_param_, false, target);
+ }
+
+ // optional .caffe.SaveOutputParameter save_output_param = 5;
+ if (has_save_output_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 5, *this->save_output_param_, false, target);
+ }
+
+ // optional .caffe.PriorBoxParameter.CodeType code_type = 6 [default = CORNER];
+ if (has_code_type()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 6, this->code_type(), target);
+ }
+
+ // optional int32 keep_top_k = 7 [default = -1];
+ if (has_keep_top_k()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(7, this->keep_top_k(), target);
+ }
+
+ // optional bool variance_encoded_in_target = 8 [default = false];
+ if (has_variance_encoded_in_target()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(8, this->variance_encoded_in_target(), target);
+ }
+
+ // optional float confidence_threshold = 9;
+ if (has_confidence_threshold()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(9, this->confidence_threshold(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.DetectionOutputParameter)
+ return target;
+}
+
+size_t DetectionOutputParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.DetectionOutputParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 255u) {
+ // optional uint32 num_classes = 1;
+ if (has_num_classes()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->num_classes());
+ }
+
+ // optional bool share_location = 2 [default = true];
+ if (has_share_location()) {
+ total_size += 1 + 1;
+ }
+
+ // optional int32 background_label_id = 3 [default = 0];
+ if (has_background_label_id()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->background_label_id());
+ }
+
+ // optional .caffe.NonMaximumSuppressionParameter nms_param = 4;
+ if (has_nms_param()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->nms_param_);
+ }
+
+ // optional .caffe.SaveOutputParameter save_output_param = 5;
+ if (has_save_output_param()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->save_output_param_);
+ }
+
+ // optional .caffe.PriorBoxParameter.CodeType code_type = 6 [default = CORNER];
+ if (has_code_type()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->code_type());
+ }
+
+ // optional bool variance_encoded_in_target = 8 [default = false];
+ if (has_variance_encoded_in_target()) {
+ total_size += 1 + 1;
+ }
+
+ // optional int32 keep_top_k = 7 [default = -1];
+ if (has_keep_top_k()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->keep_top_k());
+ }
+
+ }
+ // optional float confidence_threshold = 9;
+ if (has_confidence_threshold()) {
+ total_size += 1 + 4;
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void DetectionOutputParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.DetectionOutputParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const DetectionOutputParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const DetectionOutputParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.DetectionOutputParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.DetectionOutputParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void DetectionOutputParameter::MergeFrom(const DetectionOutputParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.DetectionOutputParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void DetectionOutputParameter::UnsafeMergeFrom(const DetectionOutputParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_num_classes()) {
+ set_num_classes(from.num_classes());
+ }
+ if (from.has_share_location()) {
+ set_share_location(from.share_location());
+ }
+ if (from.has_background_label_id()) {
+ set_background_label_id(from.background_label_id());
+ }
+ if (from.has_nms_param()) {
+ mutable_nms_param()->::caffe::NonMaximumSuppressionParameter::MergeFrom(from.nms_param());
+ }
+ if (from.has_save_output_param()) {
+ mutable_save_output_param()->::caffe::SaveOutputParameter::MergeFrom(from.save_output_param());
+ }
+ if (from.has_code_type()) {
+ set_code_type(from.code_type());
+ }
+ if (from.has_variance_encoded_in_target()) {
+ set_variance_encoded_in_target(from.variance_encoded_in_target());
+ }
+ if (from.has_keep_top_k()) {
+ set_keep_top_k(from.keep_top_k());
+ }
+ }
+ if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) {
+ if (from.has_confidence_threshold()) {
+ set_confidence_threshold(from.confidence_threshold());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void DetectionOutputParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.DetectionOutputParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void DetectionOutputParameter::CopyFrom(const DetectionOutputParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.DetectionOutputParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool DetectionOutputParameter::IsInitialized() const {
+
+ return true;
+}
+
+void DetectionOutputParameter::Swap(DetectionOutputParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void DetectionOutputParameter::InternalSwap(DetectionOutputParameter* other) {
+ std::swap(num_classes_, other->num_classes_);
+ std::swap(share_location_, other->share_location_);
+ std::swap(background_label_id_, other->background_label_id_);
+ std::swap(nms_param_, other->nms_param_);
+ std::swap(save_output_param_, other->save_output_param_);
+ std::swap(code_type_, other->code_type_);
+ std::swap(variance_encoded_in_target_, other->variance_encoded_in_target_);
+ std::swap(keep_top_k_, other->keep_top_k_);
+ std::swap(confidence_threshold_, other->confidence_threshold_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata DetectionOutputParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = DetectionOutputParameter_descriptor_;
+ metadata.reflection = DetectionOutputParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// DetectionOutputParameter
+
+// optional uint32 num_classes = 1;
+bool DetectionOutputParameter::has_num_classes() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void DetectionOutputParameter::set_has_num_classes() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void DetectionOutputParameter::clear_has_num_classes() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void DetectionOutputParameter::clear_num_classes() {
+ num_classes_ = 0u;
+ clear_has_num_classes();
+}
+::google::protobuf::uint32 DetectionOutputParameter::num_classes() const {
+ // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.num_classes)
+ return num_classes_;
+}
+void DetectionOutputParameter::set_num_classes(::google::protobuf::uint32 value) {
+ set_has_num_classes();
+ num_classes_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.num_classes)
+}
+
+// optional bool share_location = 2 [default = true];
+bool DetectionOutputParameter::has_share_location() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void DetectionOutputParameter::set_has_share_location() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void DetectionOutputParameter::clear_has_share_location() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void DetectionOutputParameter::clear_share_location() {
+ share_location_ = true;
+ clear_has_share_location();
+}
+bool DetectionOutputParameter::share_location() const {
+ // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.share_location)
+ return share_location_;
+}
+void DetectionOutputParameter::set_share_location(bool value) {
+ set_has_share_location();
+ share_location_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.share_location)
+}
+
+// optional int32 background_label_id = 3 [default = 0];
+bool DetectionOutputParameter::has_background_label_id() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void DetectionOutputParameter::set_has_background_label_id() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void DetectionOutputParameter::clear_has_background_label_id() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void DetectionOutputParameter::clear_background_label_id() {
+ background_label_id_ = 0;
+ clear_has_background_label_id();
+}
+::google::protobuf::int32 DetectionOutputParameter::background_label_id() const {
+ // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.background_label_id)
+ return background_label_id_;
+}
+void DetectionOutputParameter::set_background_label_id(::google::protobuf::int32 value) {
+ set_has_background_label_id();
+ background_label_id_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.background_label_id)
+}
+
+// optional .caffe.NonMaximumSuppressionParameter nms_param = 4;
+bool DetectionOutputParameter::has_nms_param() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+void DetectionOutputParameter::set_has_nms_param() {
+ _has_bits_[0] |= 0x00000008u;
+}
+void DetectionOutputParameter::clear_has_nms_param() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+void DetectionOutputParameter::clear_nms_param() {
+ if (nms_param_ != NULL) nms_param_->::caffe::NonMaximumSuppressionParameter::Clear();
+ clear_has_nms_param();
+}
+const ::caffe::NonMaximumSuppressionParameter& DetectionOutputParameter::nms_param() const {
+ // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.nms_param)
+ return nms_param_ != NULL ? *nms_param_
+ : *::caffe::NonMaximumSuppressionParameter::internal_default_instance();
+}
+::caffe::NonMaximumSuppressionParameter* DetectionOutputParameter::mutable_nms_param() {
+ set_has_nms_param();
+ if (nms_param_ == NULL) {
+ nms_param_ = new ::caffe::NonMaximumSuppressionParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.DetectionOutputParameter.nms_param)
+ return nms_param_;
+}
+::caffe::NonMaximumSuppressionParameter* DetectionOutputParameter::release_nms_param() {
+ // @@protoc_insertion_point(field_release:caffe.DetectionOutputParameter.nms_param)
+ clear_has_nms_param();
+ ::caffe::NonMaximumSuppressionParameter* temp = nms_param_;
+ nms_param_ = NULL;
+ return temp;
+}
+void DetectionOutputParameter::set_allocated_nms_param(::caffe::NonMaximumSuppressionParameter* nms_param) {
+ delete nms_param_;
+ nms_param_ = nms_param;
+ if (nms_param) {
+ set_has_nms_param();
+ } else {
+ clear_has_nms_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.DetectionOutputParameter.nms_param)
+}
+
+// optional .caffe.SaveOutputParameter save_output_param = 5;
+bool DetectionOutputParameter::has_save_output_param() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+void DetectionOutputParameter::set_has_save_output_param() {
+ _has_bits_[0] |= 0x00000010u;
+}
+void DetectionOutputParameter::clear_has_save_output_param() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+void DetectionOutputParameter::clear_save_output_param() {
+ if (save_output_param_ != NULL) save_output_param_->::caffe::SaveOutputParameter::Clear();
+ clear_has_save_output_param();
+}
+const ::caffe::SaveOutputParameter& DetectionOutputParameter::save_output_param() const {
+ // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.save_output_param)
+ return save_output_param_ != NULL ? *save_output_param_
+ : *::caffe::SaveOutputParameter::internal_default_instance();
+}
+::caffe::SaveOutputParameter* DetectionOutputParameter::mutable_save_output_param() {
+ set_has_save_output_param();
+ if (save_output_param_ == NULL) {
+ save_output_param_ = new ::caffe::SaveOutputParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.DetectionOutputParameter.save_output_param)
+ return save_output_param_;
+}
+::caffe::SaveOutputParameter* DetectionOutputParameter::release_save_output_param() {
+ // @@protoc_insertion_point(field_release:caffe.DetectionOutputParameter.save_output_param)
+ clear_has_save_output_param();
+ ::caffe::SaveOutputParameter* temp = save_output_param_;
+ save_output_param_ = NULL;
+ return temp;
+}
+void DetectionOutputParameter::set_allocated_save_output_param(::caffe::SaveOutputParameter* save_output_param) {
+ delete save_output_param_;
+ save_output_param_ = save_output_param;
+ if (save_output_param) {
+ set_has_save_output_param();
+ } else {
+ clear_has_save_output_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.DetectionOutputParameter.save_output_param)
+}
+
+// optional .caffe.PriorBoxParameter.CodeType code_type = 6 [default = CORNER];
+bool DetectionOutputParameter::has_code_type() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+void DetectionOutputParameter::set_has_code_type() {
+ _has_bits_[0] |= 0x00000020u;
+}
+void DetectionOutputParameter::clear_has_code_type() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+void DetectionOutputParameter::clear_code_type() {
+ code_type_ = 1;
+ clear_has_code_type();
+}
+::caffe::PriorBoxParameter_CodeType DetectionOutputParameter::code_type() const {
+ // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.code_type)
+ return static_cast< ::caffe::PriorBoxParameter_CodeType >(code_type_);
+}
+void DetectionOutputParameter::set_code_type(::caffe::PriorBoxParameter_CodeType value) {
+ assert(::caffe::PriorBoxParameter_CodeType_IsValid(value));
+ set_has_code_type();
+ code_type_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.code_type)
+}
+
+// optional bool variance_encoded_in_target = 8 [default = false];
+bool DetectionOutputParameter::has_variance_encoded_in_target() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+void DetectionOutputParameter::set_has_variance_encoded_in_target() {
+ _has_bits_[0] |= 0x00000040u;
+}
+void DetectionOutputParameter::clear_has_variance_encoded_in_target() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+void DetectionOutputParameter::clear_variance_encoded_in_target() {
+ variance_encoded_in_target_ = false;
+ clear_has_variance_encoded_in_target();
+}
+bool DetectionOutputParameter::variance_encoded_in_target() const {
+ // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.variance_encoded_in_target)
+ return variance_encoded_in_target_;
+}
+void DetectionOutputParameter::set_variance_encoded_in_target(bool value) {
+ set_has_variance_encoded_in_target();
+ variance_encoded_in_target_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.variance_encoded_in_target)
+}
+
+// optional int32 keep_top_k = 7 [default = -1];
+bool DetectionOutputParameter::has_keep_top_k() const {
+ return (_has_bits_[0] & 0x00000080u) != 0;
+}
+void DetectionOutputParameter::set_has_keep_top_k() {
+ _has_bits_[0] |= 0x00000080u;
+}
+void DetectionOutputParameter::clear_has_keep_top_k() {
+ _has_bits_[0] &= ~0x00000080u;
+}
+void DetectionOutputParameter::clear_keep_top_k() {
+ keep_top_k_ = -1;
+ clear_has_keep_top_k();
+}
+::google::protobuf::int32 DetectionOutputParameter::keep_top_k() const {
+ // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.keep_top_k)
+ return keep_top_k_;
+}
+void DetectionOutputParameter::set_keep_top_k(::google::protobuf::int32 value) {
+ set_has_keep_top_k();
+ keep_top_k_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.keep_top_k)
+}
+
+// optional float confidence_threshold = 9;
+bool DetectionOutputParameter::has_confidence_threshold() const {
+ return (_has_bits_[0] & 0x00000100u) != 0;
+}
+void DetectionOutputParameter::set_has_confidence_threshold() {
+ _has_bits_[0] |= 0x00000100u;
+}
+void DetectionOutputParameter::clear_has_confidence_threshold() {
+ _has_bits_[0] &= ~0x00000100u;
+}
+void DetectionOutputParameter::clear_confidence_threshold() {
+ confidence_threshold_ = 0;
+ clear_has_confidence_threshold();
+}
+float DetectionOutputParameter::confidence_threshold() const {
+ // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.confidence_threshold)
+ return confidence_threshold_;
+}
+void DetectionOutputParameter::set_confidence_threshold(float value) {
+ set_has_confidence_threshold();
+ confidence_threshold_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.confidence_threshold)
+}
+
+inline const DetectionOutputParameter* DetectionOutputParameter::internal_default_instance() {
+ return &DetectionOutputParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int Datum::kChannelsFieldNumber;
+const int Datum::kHeightFieldNumber;
+const int Datum::kWidthFieldNumber;
+const int Datum::kDataFieldNumber;
+const int Datum::kLabelFieldNumber;
+const int Datum::kFloatDataFieldNumber;
+const int Datum::kEncodedFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+Datum::Datum()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.Datum)
+}
+
+void Datum::InitAsDefaultInstance() {
+}
+
+Datum::Datum(const Datum& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.Datum)
+}
+
+void Datum::SharedCtor() {
+ _cached_size_ = 0;
+ data_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ ::memset(&channels_, 0, reinterpret_cast<char*>(&encoded_) -
+ reinterpret_cast<char*>(&channels_) + sizeof(encoded_));
+}
+
+Datum::~Datum() {
+ // @@protoc_insertion_point(destructor:caffe.Datum)
+ SharedDtor();
+}
+
+void Datum::SharedDtor() {
+ data_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+
+void Datum::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* Datum::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return Datum_descriptor_;
+}
+
+const Datum& Datum::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<Datum> Datum_default_instance_;
+
+Datum* Datum::New(::google::protobuf::Arena* arena) const {
+ Datum* n = new Datum;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void Datum::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.Datum)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(Datum, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<Datum*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ if (_has_bits_[0 / 32] & 95u) {
+ ZR_(channels_, encoded_);
+ if (has_data()) {
+ data_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ }
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ float_data_.Clear();
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool Datum::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.Datum)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional int32 channels = 1;
+ case 1: {
+ if (tag == 8) {
+ set_has_channels();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &channels_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_height;
+ break;
+ }
+
+ // optional int32 height = 2;
+ case 2: {
+ if (tag == 16) {
+ parse_height:
+ set_has_height();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &height_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(24)) goto parse_width;
+ break;
+ }
+
+ // optional int32 width = 3;
+ case 3: {
+ if (tag == 24) {
+ parse_width:
+ set_has_width();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &width_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(34)) goto parse_data;
+ break;
+ }
+
+ // optional bytes data = 4;
+ case 4: {
+ if (tag == 34) {
+ parse_data:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
+ input, this->mutable_data()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(40)) goto parse_label;
+ break;
+ }
+
+ // optional int32 label = 5;
+ case 5: {
+ if (tag == 40) {
+ parse_label:
+ set_has_label();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &label_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(53)) goto parse_float_data;
+ break;
+ }
+
+ // repeated float float_data = 6;
+ case 6: {
+ if (tag == 53) {
+ parse_float_data:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ 1, 53, input, this->mutable_float_data())));
+ } else if (tag == 50) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, this->mutable_float_data())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(53)) goto parse_float_data;
+ if (input->ExpectTag(56)) goto parse_encoded;
+ break;
+ }
+
+ // optional bool encoded = 7 [default = false];
+ case 7: {
+ if (tag == 56) {
+ parse_encoded:
+ set_has_encoded();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &encoded_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.Datum)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.Datum)
+ return false;
+#undef DO_
+}
+
+void Datum::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.Datum)
+ // optional int32 channels = 1;
+ if (has_channels()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->channels(), output);
+ }
+
+ // optional int32 height = 2;
+ if (has_height()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->height(), output);
+ }
+
+ // optional int32 width = 3;
+ if (has_width()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->width(), output);
+ }
+
+ // optional bytes data = 4;
+ if (has_data()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(
+ 4, this->data(), output);
+ }
+
+ // optional int32 label = 5;
+ if (has_label()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(5, this->label(), output);
+ }
+
+ // repeated float float_data = 6;
+ for (int i = 0; i < this->float_data_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(
+ 6, this->float_data(i), output);
+ }
+
+ // optional bool encoded = 7 [default = false];
+ if (has_encoded()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(7, this->encoded(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.Datum)
+}
+
+::google::protobuf::uint8* Datum::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.Datum)
+ // optional int32 channels = 1;
+ if (has_channels()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->channels(), target);
+ }
+
+ // optional int32 height = 2;
+ if (has_height()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->height(), target);
+ }
+
+ // optional int32 width = 3;
+ if (has_width()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->width(), target);
+ }
+
+ // optional bytes data = 4;
+ if (has_data()) {
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteBytesToArray(
+ 4, this->data(), target);
+ }
+
+ // optional int32 label = 5;
+ if (has_label()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(5, this->label(), target);
+ }
+
+ // repeated float float_data = 6;
+ for (int i = 0; i < this->float_data_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteFloatToArray(6, this->float_data(i), target);
+ }
+
+ // optional bool encoded = 7 [default = false];
+ if (has_encoded()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(7, this->encoded(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.Datum)
+ return target;
+}
+
+size_t Datum::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.Datum)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 95u) {
+ // optional int32 channels = 1;
+ if (has_channels()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->channels());
+ }
+
+ // optional int32 height = 2;
+ if (has_height()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->height());
+ }
+
+ // optional int32 width = 3;
+ if (has_width()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->width());
+ }
+
+ // optional bytes data = 4;
+ if (has_data()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::BytesSize(
+ this->data());
+ }
+
+ // optional int32 label = 5;
+ if (has_label()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->label());
+ }
+
+ // optional bool encoded = 7 [default = false];
+ if (has_encoded()) {
+ total_size += 1 + 1;
+ }
+
+ }
+ // repeated float float_data = 6;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->float_data_size();
+ data_size = 4UL * count;
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->float_data_size());
+ total_size += data_size;
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void Datum::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.Datum)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const Datum* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const Datum>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.Datum)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.Datum)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void Datum::MergeFrom(const Datum& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.Datum)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void Datum::UnsafeMergeFrom(const Datum& from) {
+ GOOGLE_DCHECK(&from != this);
+ float_data_.UnsafeMergeFrom(from.float_data_);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_channels()) {
+ set_channels(from.channels());
+ }
+ if (from.has_height()) {
+ set_height(from.height());
+ }
+ if (from.has_width()) {
+ set_width(from.width());
+ }
+ if (from.has_data()) {
+ set_has_data();
+ data_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.data_);
+ }
+ if (from.has_label()) {
+ set_label(from.label());
+ }
+ if (from.has_encoded()) {
+ set_encoded(from.encoded());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void Datum::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.Datum)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void Datum::CopyFrom(const Datum& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.Datum)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool Datum::IsInitialized() const {
+
+ return true;
+}
+
+void Datum::Swap(Datum* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void Datum::InternalSwap(Datum* other) {
+ std::swap(channels_, other->channels_);
+ std::swap(height_, other->height_);
+ std::swap(width_, other->width_);
+ data_.Swap(&other->data_);
+ std::swap(label_, other->label_);
+ float_data_.UnsafeArenaSwap(&other->float_data_);
+ std::swap(encoded_, other->encoded_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata Datum::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = Datum_descriptor_;
+ metadata.reflection = Datum_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// Datum
+
+// optional int32 channels = 1;
+bool Datum::has_channels() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void Datum::set_has_channels() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void Datum::clear_has_channels() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void Datum::clear_channels() {
+ channels_ = 0;
+ clear_has_channels();
+}
+::google::protobuf::int32 Datum::channels() const {
+ // @@protoc_insertion_point(field_get:caffe.Datum.channels)
+ return channels_;
+}
+void Datum::set_channels(::google::protobuf::int32 value) {
+ set_has_channels();
+ channels_ = value;
+ // @@protoc_insertion_point(field_set:caffe.Datum.channels)
+}
+
+// optional int32 height = 2;
+bool Datum::has_height() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void Datum::set_has_height() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void Datum::clear_has_height() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void Datum::clear_height() {
+ height_ = 0;
+ clear_has_height();
+}
+::google::protobuf::int32 Datum::height() const {
+ // @@protoc_insertion_point(field_get:caffe.Datum.height)
+ return height_;
+}
+void Datum::set_height(::google::protobuf::int32 value) {
+ set_has_height();
+ height_ = value;
+ // @@protoc_insertion_point(field_set:caffe.Datum.height)
+}
+
+// optional int32 width = 3;
+bool Datum::has_width() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void Datum::set_has_width() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void Datum::clear_has_width() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void Datum::clear_width() {
+ width_ = 0;
+ clear_has_width();
+}
+::google::protobuf::int32 Datum::width() const {
+ // @@protoc_insertion_point(field_get:caffe.Datum.width)
+ return width_;
+}
+void Datum::set_width(::google::protobuf::int32 value) {
+ set_has_width();
+ width_ = value;
+ // @@protoc_insertion_point(field_set:caffe.Datum.width)
+}
+
+// optional bytes data = 4;
+bool Datum::has_data() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+void Datum::set_has_data() {
+ _has_bits_[0] |= 0x00000008u;
+}
+void Datum::clear_has_data() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+void Datum::clear_data() {
+ data_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_data();
+}
+const ::std::string& Datum::data() const {
+ // @@protoc_insertion_point(field_get:caffe.Datum.data)
+ return data_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void Datum::set_data(const ::std::string& value) {
+ set_has_data();
+ data_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.Datum.data)
+}
+void Datum::set_data(const char* value) {
+ set_has_data();
+ data_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.Datum.data)
+}
+void Datum::set_data(const void* value, size_t size) {
+ set_has_data();
+ data_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.Datum.data)
+}
+::std::string* Datum::mutable_data() {
+ set_has_data();
+ // @@protoc_insertion_point(field_mutable:caffe.Datum.data)
+ return data_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* Datum::release_data() {
+ // @@protoc_insertion_point(field_release:caffe.Datum.data)
+ clear_has_data();
+ return data_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void Datum::set_allocated_data(::std::string* data) {
+ if (data != NULL) {
+ set_has_data();
+ } else {
+ clear_has_data();
+ }
+ data_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), data);
+ // @@protoc_insertion_point(field_set_allocated:caffe.Datum.data)
+}
+
+// optional int32 label = 5;
+bool Datum::has_label() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+void Datum::set_has_label() {
+ _has_bits_[0] |= 0x00000010u;
+}
+void Datum::clear_has_label() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+void Datum::clear_label() {
+ label_ = 0;
+ clear_has_label();
+}
+::google::protobuf::int32 Datum::label() const {
+ // @@protoc_insertion_point(field_get:caffe.Datum.label)
+ return label_;
+}
+void Datum::set_label(::google::protobuf::int32 value) {
+ set_has_label();
+ label_ = value;
+ // @@protoc_insertion_point(field_set:caffe.Datum.label)
+}
+
+// repeated float float_data = 6;
+int Datum::float_data_size() const {
+ return float_data_.size();
+}
+void Datum::clear_float_data() {
+ float_data_.Clear();
+}
+float Datum::float_data(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.Datum.float_data)
+ return float_data_.Get(index);
+}
+void Datum::set_float_data(int index, float value) {
+ float_data_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.Datum.float_data)
+}
+void Datum::add_float_data(float value) {
+ float_data_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.Datum.float_data)
+}
+const ::google::protobuf::RepeatedField< float >&
+Datum::float_data() const {
+ // @@protoc_insertion_point(field_list:caffe.Datum.float_data)
+ return float_data_;
+}
+::google::protobuf::RepeatedField< float >*
+Datum::mutable_float_data() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.Datum.float_data)
+ return &float_data_;
+}
+
+// optional bool encoded = 7 [default = false];
+bool Datum::has_encoded() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+void Datum::set_has_encoded() {
+ _has_bits_[0] |= 0x00000040u;
+}
+void Datum::clear_has_encoded() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+void Datum::clear_encoded() {
+ encoded_ = false;
+ clear_has_encoded();
+}
+bool Datum::encoded() const {
+ // @@protoc_insertion_point(field_get:caffe.Datum.encoded)
+ return encoded_;
+}
+void Datum::set_encoded(bool value) {
+ set_has_encoded();
+ encoded_ = value;
+ // @@protoc_insertion_point(field_set:caffe.Datum.encoded)
+}
+
+inline const Datum* Datum::internal_default_instance() {
+ return &Datum_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+const ::google::protobuf::EnumDescriptor* FillerParameter_VarianceNorm_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return FillerParameter_VarianceNorm_descriptor_;
+}
+bool FillerParameter_VarianceNorm_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ case 2:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const FillerParameter_VarianceNorm FillerParameter::FAN_IN;
+const FillerParameter_VarianceNorm FillerParameter::FAN_OUT;
+const FillerParameter_VarianceNorm FillerParameter::AVERAGE;
+const FillerParameter_VarianceNorm FillerParameter::VarianceNorm_MIN;
+const FillerParameter_VarianceNorm FillerParameter::VarianceNorm_MAX;
+const int FillerParameter::VarianceNorm_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+::std::string* FillerParameter::_default_type_ = NULL;
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int FillerParameter::kTypeFieldNumber;
+const int FillerParameter::kValueFieldNumber;
+const int FillerParameter::kMinFieldNumber;
+const int FillerParameter::kMaxFieldNumber;
+const int FillerParameter::kMeanFieldNumber;
+const int FillerParameter::kStdFieldNumber;
+const int FillerParameter::kSparseFieldNumber;
+const int FillerParameter::kVarianceNormFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+FillerParameter::FillerParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.FillerParameter)
+}
+
+void FillerParameter::InitAsDefaultInstance() {
+}
+
+FillerParameter::FillerParameter(const FillerParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.FillerParameter)
+}
+
+void FillerParameter::SharedCtor() {
+ _cached_size_ = 0;
+ type_.UnsafeSetDefault(_default_type_);
+ ::memset(&value_, 0, reinterpret_cast<char*>(&variance_norm_) -
+ reinterpret_cast<char*>(&value_) + sizeof(variance_norm_));
+ sparse_ = -1;
+ max_ = 1;
+ std_ = 1;
+}
+
+FillerParameter::~FillerParameter() {
+ // @@protoc_insertion_point(destructor:caffe.FillerParameter)
+ SharedDtor();
+}
+
+void FillerParameter::SharedDtor() {
+ type_.DestroyNoArena(_default_type_);
+}
+
+void FillerParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* FillerParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return FillerParameter_descriptor_;
+}
+
+const FillerParameter& FillerParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<FillerParameter> FillerParameter_default_instance_;
+
+FillerParameter* FillerParameter::New(::google::protobuf::Arena* arena) const {
+ FillerParameter* n = new FillerParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void FillerParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.FillerParameter)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(FillerParameter, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<FillerParameter*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ if (_has_bits_[0 / 32] & 255u) {
+ ZR_(value_, variance_norm_);
+ if (has_type()) {
+ type_.ClearToDefaultNoArena(_default_type_);
+ }
+ max_ = 1;
+ std_ = 1;
+ sparse_ = -1;
+ }
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool FillerParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.FillerParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional string type = 1 [default = "constant"];
+ case 1: {
+ if (tag == 10) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_type()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->type().data(), this->type().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.FillerParameter.type");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(21)) goto parse_value;
+ break;
+ }
+
+ // optional float value = 2 [default = 0];
+ case 2: {
+ if (tag == 21) {
+ parse_value:
+ set_has_value();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &value_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(29)) goto parse_min;
+ break;
+ }
+
+ // optional float min = 3 [default = 0];
+ case 3: {
+ if (tag == 29) {
+ parse_min:
+ set_has_min();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &min_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(37)) goto parse_max;
+ break;
+ }
+
+ // optional float max = 4 [default = 1];
+ case 4: {
+ if (tag == 37) {
+ parse_max:
+ set_has_max();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &max_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(45)) goto parse_mean;
+ break;
+ }
+
+ // optional float mean = 5 [default = 0];
+ case 5: {
+ if (tag == 45) {
+ parse_mean:
+ set_has_mean();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &mean_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(53)) goto parse_std;
+ break;
+ }
+
+ // optional float std = 6 [default = 1];
+ case 6: {
+ if (tag == 53) {
+ parse_std:
+ set_has_std();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &std_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(56)) goto parse_sparse;
+ break;
+ }
+
+ // optional int32 sparse = 7 [default = -1];
+ case 7: {
+ if (tag == 56) {
+ parse_sparse:
+ set_has_sparse();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &sparse_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(64)) goto parse_variance_norm;
+ break;
+ }
+
+ // optional .caffe.FillerParameter.VarianceNorm variance_norm = 8 [default = FAN_IN];
+ case 8: {
+ if (tag == 64) {
+ parse_variance_norm:
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::FillerParameter_VarianceNorm_IsValid(value)) {
+ set_variance_norm(static_cast< ::caffe::FillerParameter_VarianceNorm >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(8, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.FillerParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.FillerParameter)
+ return false;
+#undef DO_
+}
+
+void FillerParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.FillerParameter)
+ // optional string type = 1 [default = "constant"];
+ if (has_type()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->type().data(), this->type().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.FillerParameter.type");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 1, this->type(), output);
+ }
+
+ // optional float value = 2 [default = 0];
+ if (has_value()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->value(), output);
+ }
+
+ // optional float min = 3 [default = 0];
+ if (has_min()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->min(), output);
+ }
+
+ // optional float max = 4 [default = 1];
+ if (has_max()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(4, this->max(), output);
+ }
+
+ // optional float mean = 5 [default = 0];
+ if (has_mean()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(5, this->mean(), output);
+ }
+
+ // optional float std = 6 [default = 1];
+ if (has_std()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(6, this->std(), output);
+ }
+
+ // optional int32 sparse = 7 [default = -1];
+ if (has_sparse()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(7, this->sparse(), output);
+ }
+
+ // optional .caffe.FillerParameter.VarianceNorm variance_norm = 8 [default = FAN_IN];
+ if (has_variance_norm()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 8, this->variance_norm(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.FillerParameter)
+}
+
+::google::protobuf::uint8* FillerParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.FillerParameter)
+ // optional string type = 1 [default = "constant"];
+ if (has_type()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->type().data(), this->type().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.FillerParameter.type");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 1, this->type(), target);
+ }
+
+ // optional float value = 2 [default = 0];
+ if (has_value()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->value(), target);
+ }
+
+ // optional float min = 3 [default = 0];
+ if (has_min()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->min(), target);
+ }
+
+ // optional float max = 4 [default = 1];
+ if (has_max()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(4, this->max(), target);
+ }
+
+ // optional float mean = 5 [default = 0];
+ if (has_mean()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(5, this->mean(), target);
+ }
+
+ // optional float std = 6 [default = 1];
+ if (has_std()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(6, this->std(), target);
+ }
+
+ // optional int32 sparse = 7 [default = -1];
+ if (has_sparse()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(7, this->sparse(), target);
+ }
+
+ // optional .caffe.FillerParameter.VarianceNorm variance_norm = 8 [default = FAN_IN];
+ if (has_variance_norm()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 8, this->variance_norm(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.FillerParameter)
+ return target;
+}
+
+size_t FillerParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.FillerParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 255u) {
+ // optional string type = 1 [default = "constant"];
+ if (has_type()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->type());
+ }
+
+ // optional float value = 2 [default = 0];
+ if (has_value()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float min = 3 [default = 0];
+ if (has_min()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float max = 4 [default = 1];
+ if (has_max()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float mean = 5 [default = 0];
+ if (has_mean()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float std = 6 [default = 1];
+ if (has_std()) {
+ total_size += 1 + 4;
+ }
+
+ // optional int32 sparse = 7 [default = -1];
+ if (has_sparse()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->sparse());
+ }
+
+ // optional .caffe.FillerParameter.VarianceNorm variance_norm = 8 [default = FAN_IN];
+ if (has_variance_norm()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->variance_norm());
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void FillerParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.FillerParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const FillerParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const FillerParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.FillerParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.FillerParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void FillerParameter::MergeFrom(const FillerParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.FillerParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void FillerParameter::UnsafeMergeFrom(const FillerParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_type()) {
+ set_has_type();
+ type_.AssignWithDefault(_default_type_, from.type_);
+ }
+ if (from.has_value()) {
+ set_value(from.value());
+ }
+ if (from.has_min()) {
+ set_min(from.min());
+ }
+ if (from.has_max()) {
+ set_max(from.max());
+ }
+ if (from.has_mean()) {
+ set_mean(from.mean());
+ }
+ if (from.has_std()) {
+ set_std(from.std());
+ }
+ if (from.has_sparse()) {
+ set_sparse(from.sparse());
+ }
+ if (from.has_variance_norm()) {
+ set_variance_norm(from.variance_norm());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void FillerParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.FillerParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void FillerParameter::CopyFrom(const FillerParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.FillerParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool FillerParameter::IsInitialized() const {
+
+ return true;
+}
+
+void FillerParameter::Swap(FillerParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void FillerParameter::InternalSwap(FillerParameter* other) {
+ type_.Swap(&other->type_);
+ std::swap(value_, other->value_);
+ std::swap(min_, other->min_);
+ std::swap(max_, other->max_);
+ std::swap(mean_, other->mean_);
+ std::swap(std_, other->std_);
+ std::swap(sparse_, other->sparse_);
+ std::swap(variance_norm_, other->variance_norm_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata FillerParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = FillerParameter_descriptor_;
+ metadata.reflection = FillerParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// FillerParameter
+
+// optional string type = 1 [default = "constant"];
+bool FillerParameter::has_type() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void FillerParameter::set_has_type() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void FillerParameter::clear_has_type() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void FillerParameter::clear_type() {
+ type_.ClearToDefaultNoArena(_default_type_);
+ clear_has_type();
+}
+const ::std::string& FillerParameter::type() const {
+ // @@protoc_insertion_point(field_get:caffe.FillerParameter.type)
+ return type_.GetNoArena(_default_type_);
+}
+void FillerParameter::set_type(const ::std::string& value) {
+ set_has_type();
+ type_.SetNoArena(_default_type_, value);
+ // @@protoc_insertion_point(field_set:caffe.FillerParameter.type)
+}
+void FillerParameter::set_type(const char* value) {
+ set_has_type();
+ type_.SetNoArena(_default_type_, ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.FillerParameter.type)
+}
+void FillerParameter::set_type(const char* value, size_t size) {
+ set_has_type();
+ type_.SetNoArena(_default_type_,
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.FillerParameter.type)
+}
+::std::string* FillerParameter::mutable_type() {
+ set_has_type();
+ // @@protoc_insertion_point(field_mutable:caffe.FillerParameter.type)
+ return type_.MutableNoArena(_default_type_);
+}
+::std::string* FillerParameter::release_type() {
+ // @@protoc_insertion_point(field_release:caffe.FillerParameter.type)
+ clear_has_type();
+ return type_.ReleaseNoArena(_default_type_);
+}
+void FillerParameter::set_allocated_type(::std::string* type) {
+ if (type != NULL) {
+ set_has_type();
+ } else {
+ clear_has_type();
+ }
+ type_.SetAllocatedNoArena(_default_type_, type);
+ // @@protoc_insertion_point(field_set_allocated:caffe.FillerParameter.type)
+}
+
+// optional float value = 2 [default = 0];
+bool FillerParameter::has_value() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void FillerParameter::set_has_value() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void FillerParameter::clear_has_value() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void FillerParameter::clear_value() {
+ value_ = 0;
+ clear_has_value();
+}
+float FillerParameter::value() const {
+ // @@protoc_insertion_point(field_get:caffe.FillerParameter.value)
+ return value_;
+}
+void FillerParameter::set_value(float value) {
+ set_has_value();
+ value_ = value;
+ // @@protoc_insertion_point(field_set:caffe.FillerParameter.value)
+}
+
+// optional float min = 3 [default = 0];
+bool FillerParameter::has_min() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void FillerParameter::set_has_min() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void FillerParameter::clear_has_min() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void FillerParameter::clear_min() {
+ min_ = 0;
+ clear_has_min();
+}
+float FillerParameter::min() const {
+ // @@protoc_insertion_point(field_get:caffe.FillerParameter.min)
+ return min_;
+}
+void FillerParameter::set_min(float value) {
+ set_has_min();
+ min_ = value;
+ // @@protoc_insertion_point(field_set:caffe.FillerParameter.min)
+}
+
+// optional float max = 4 [default = 1];
+bool FillerParameter::has_max() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+void FillerParameter::set_has_max() {
+ _has_bits_[0] |= 0x00000008u;
+}
+void FillerParameter::clear_has_max() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+void FillerParameter::clear_max() {
+ max_ = 1;
+ clear_has_max();
+}
+float FillerParameter::max() const {
+ // @@protoc_insertion_point(field_get:caffe.FillerParameter.max)
+ return max_;
+}
+void FillerParameter::set_max(float value) {
+ set_has_max();
+ max_ = value;
+ // @@protoc_insertion_point(field_set:caffe.FillerParameter.max)
+}
+
+// optional float mean = 5 [default = 0];
+bool FillerParameter::has_mean() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+void FillerParameter::set_has_mean() {
+ _has_bits_[0] |= 0x00000010u;
+}
+void FillerParameter::clear_has_mean() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+void FillerParameter::clear_mean() {
+ mean_ = 0;
+ clear_has_mean();
+}
+float FillerParameter::mean() const {
+ // @@protoc_insertion_point(field_get:caffe.FillerParameter.mean)
+ return mean_;
+}
+void FillerParameter::set_mean(float value) {
+ set_has_mean();
+ mean_ = value;
+ // @@protoc_insertion_point(field_set:caffe.FillerParameter.mean)
+}
+
+// optional float std = 6 [default = 1];
+bool FillerParameter::has_std() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+void FillerParameter::set_has_std() {
+ _has_bits_[0] |= 0x00000020u;
+}
+void FillerParameter::clear_has_std() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+void FillerParameter::clear_std() {
+ std_ = 1;
+ clear_has_std();
+}
+float FillerParameter::std() const {
+ // @@protoc_insertion_point(field_get:caffe.FillerParameter.std)
+ return std_;
+}
+void FillerParameter::set_std(float value) {
+ set_has_std();
+ std_ = value;
+ // @@protoc_insertion_point(field_set:caffe.FillerParameter.std)
+}
+
+// optional int32 sparse = 7 [default = -1];
+bool FillerParameter::has_sparse() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+void FillerParameter::set_has_sparse() {
+ _has_bits_[0] |= 0x00000040u;
+}
+void FillerParameter::clear_has_sparse() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+void FillerParameter::clear_sparse() {
+ sparse_ = -1;
+ clear_has_sparse();
+}
+::google::protobuf::int32 FillerParameter::sparse() const {
+ // @@protoc_insertion_point(field_get:caffe.FillerParameter.sparse)
+ return sparse_;
+}
+void FillerParameter::set_sparse(::google::protobuf::int32 value) {
+ set_has_sparse();
+ sparse_ = value;
+ // @@protoc_insertion_point(field_set:caffe.FillerParameter.sparse)
+}
+
+// optional .caffe.FillerParameter.VarianceNorm variance_norm = 8 [default = FAN_IN];
+bool FillerParameter::has_variance_norm() const {
+ return (_has_bits_[0] & 0x00000080u) != 0;
+}
+void FillerParameter::set_has_variance_norm() {
+ _has_bits_[0] |= 0x00000080u;
+}
+void FillerParameter::clear_has_variance_norm() {
+ _has_bits_[0] &= ~0x00000080u;
+}
+void FillerParameter::clear_variance_norm() {
+ variance_norm_ = 0;
+ clear_has_variance_norm();
+}
+::caffe::FillerParameter_VarianceNorm FillerParameter::variance_norm() const {
+ // @@protoc_insertion_point(field_get:caffe.FillerParameter.variance_norm)
+ return static_cast< ::caffe::FillerParameter_VarianceNorm >(variance_norm_);
+}
+void FillerParameter::set_variance_norm(::caffe::FillerParameter_VarianceNorm value) {
+ assert(::caffe::FillerParameter_VarianceNorm_IsValid(value));
+ set_has_variance_norm();
+ variance_norm_ = value;
+ // @@protoc_insertion_point(field_set:caffe.FillerParameter.variance_norm)
+}
+
+inline const FillerParameter* FillerParameter::internal_default_instance() {
+ return &FillerParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int NetParameter::kNameFieldNumber;
+const int NetParameter::kInputFieldNumber;
+const int NetParameter::kInputShapeFieldNumber;
+const int NetParameter::kInputDimFieldNumber;
+const int NetParameter::kForceBackwardFieldNumber;
+const int NetParameter::kStateFieldNumber;
+const int NetParameter::kDebugInfoFieldNumber;
+const int NetParameter::kLayerFieldNumber;
+const int NetParameter::kLayersFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+NetParameter::NetParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.NetParameter)
+}
+
+void NetParameter::InitAsDefaultInstance() {
+ state_ = const_cast< ::caffe::NetState*>(
+ ::caffe::NetState::internal_default_instance());
+}
+
+NetParameter::NetParameter(const NetParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.NetParameter)
+}
+
+void NetParameter::SharedCtor() {
+ _cached_size_ = 0;
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ state_ = NULL;
+ ::memset(&force_backward_, 0, reinterpret_cast<char*>(&debug_info_) -
+ reinterpret_cast<char*>(&force_backward_) + sizeof(debug_info_));
+}
+
+NetParameter::~NetParameter() {
+ // @@protoc_insertion_point(destructor:caffe.NetParameter)
+ SharedDtor();
+}
+
+void NetParameter::SharedDtor() {
+ name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (this != &NetParameter_default_instance_.get()) {
+ delete state_;
+ }
+}
+
+void NetParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* NetParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return NetParameter_descriptor_;
+}
+
+const NetParameter& NetParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<NetParameter> NetParameter_default_instance_;
+
+NetParameter* NetParameter::New(::google::protobuf::Arena* arena) const {
+ NetParameter* n = new NetParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void NetParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.NetParameter)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(NetParameter, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<NetParameter*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ if (_has_bits_[0 / 32] & 113u) {
+ ZR_(force_backward_, debug_info_);
+ if (has_name()) {
+ name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ if (has_state()) {
+ if (state_ != NULL) state_->::caffe::NetState::Clear();
+ }
+ }
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ input_.Clear();
+ input_shape_.Clear();
+ input_dim_.Clear();
+ layer_.Clear();
+ layers_.Clear();
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool NetParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.NetParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional string name = 1;
+ case 1: {
+ if (tag == 10) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_name()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->name().data(), this->name().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.NetParameter.name");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(18)) goto parse_layers;
+ break;
+ }
+
+ // repeated .caffe.V1LayerParameter layers = 2;
+ case 2: {
+ if (tag == 18) {
+ parse_layers:
+ DO_(input->IncrementRecursionDepth());
+ parse_loop_layers:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
+ input, add_layers()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(18)) goto parse_loop_layers;
+ input->UnsafeDecrementRecursionDepth();
+ if (input->ExpectTag(26)) goto parse_input;
+ break;
+ }
+
+ // repeated string input = 3;
+ case 3: {
+ if (tag == 26) {
+ parse_input:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->add_input()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->input(this->input_size() - 1).data(),
+ this->input(this->input_size() - 1).length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.NetParameter.input");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(26)) goto parse_input;
+ if (input->ExpectTag(32)) goto parse_input_dim;
+ break;
+ }
+
+ // repeated int32 input_dim = 4;
+ case 4: {
+ if (tag == 32) {
+ parse_input_dim:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ 1, 32, input, this->mutable_input_dim())));
+ } else if (tag == 34) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, this->mutable_input_dim())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(32)) goto parse_input_dim;
+ if (input->ExpectTag(40)) goto parse_force_backward;
+ break;
+ }
+
+ // optional bool force_backward = 5 [default = false];
+ case 5: {
+ if (tag == 40) {
+ parse_force_backward:
+ set_has_force_backward();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &force_backward_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(50)) goto parse_state;
+ break;
+ }
+
+ // optional .caffe.NetState state = 6;
+ case 6: {
+ if (tag == 50) {
+ parse_state:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_state()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(56)) goto parse_debug_info;
+ break;
+ }
+
+ // optional bool debug_info = 7 [default = false];
+ case 7: {
+ if (tag == 56) {
+ parse_debug_info:
+ set_has_debug_info();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &debug_info_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(66)) goto parse_input_shape;
+ break;
+ }
+
+ // repeated .caffe.BlobShape input_shape = 8;
+ case 8: {
+ if (tag == 66) {
+ parse_input_shape:
+ DO_(input->IncrementRecursionDepth());
+ parse_loop_input_shape:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
+ input, add_input_shape()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(66)) goto parse_loop_input_shape;
+ if (input->ExpectTag(802)) goto parse_loop_layer;
+ input->UnsafeDecrementRecursionDepth();
+ break;
+ }
+
+ // repeated .caffe.LayerParameter layer = 100;
+ case 100: {
+ if (tag == 802) {
+ DO_(input->IncrementRecursionDepth());
+ parse_loop_layer:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
+ input, add_layer()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(802)) goto parse_loop_layer;
+ input->UnsafeDecrementRecursionDepth();
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.NetParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.NetParameter)
+ return false;
+#undef DO_
+}
+
+void NetParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.NetParameter)
+ // optional string name = 1;
+ if (has_name()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->name().data(), this->name().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.NetParameter.name");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 1, this->name(), output);
+ }
+
+ // repeated .caffe.V1LayerParameter layers = 2;
+ for (unsigned int i = 0, n = this->layers_size(); i < n; i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 2, this->layers(i), output);
+ }
+
+ // repeated string input = 3;
+ for (int i = 0; i < this->input_size(); i++) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->input(i).data(), this->input(i).length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.NetParameter.input");
+ ::google::protobuf::internal::WireFormatLite::WriteString(
+ 3, this->input(i), output);
+ }
+
+ // repeated int32 input_dim = 4;
+ for (int i = 0; i < this->input_dim_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(
+ 4, this->input_dim(i), output);
+ }
+
+ // optional bool force_backward = 5 [default = false];
+ if (has_force_backward()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(5, this->force_backward(), output);
+ }
+
+ // optional .caffe.NetState state = 6;
+ if (has_state()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 6, *this->state_, output);
+ }
+
+ // optional bool debug_info = 7 [default = false];
+ if (has_debug_info()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(7, this->debug_info(), output);
+ }
+
+ // repeated .caffe.BlobShape input_shape = 8;
+ for (unsigned int i = 0, n = this->input_shape_size(); i < n; i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 8, this->input_shape(i), output);
+ }
+
+ // repeated .caffe.LayerParameter layer = 100;
+ for (unsigned int i = 0, n = this->layer_size(); i < n; i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 100, this->layer(i), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.NetParameter)
+}
+
+::google::protobuf::uint8* NetParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.NetParameter)
+ // optional string name = 1;
+ if (has_name()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->name().data(), this->name().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.NetParameter.name");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 1, this->name(), target);
+ }
+
+ // repeated .caffe.V1LayerParameter layers = 2;
+ for (unsigned int i = 0, n = this->layers_size(); i < n; i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 2, this->layers(i), false, target);
+ }
+
+ // repeated string input = 3;
+ for (int i = 0; i < this->input_size(); i++) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->input(i).data(), this->input(i).length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.NetParameter.input");
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteStringToArray(3, this->input(i), target);
+ }
+
+ // repeated int32 input_dim = 4;
+ for (int i = 0; i < this->input_dim_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteInt32ToArray(4, this->input_dim(i), target);
+ }
+
+ // optional bool force_backward = 5 [default = false];
+ if (has_force_backward()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(5, this->force_backward(), target);
+ }
+
+ // optional .caffe.NetState state = 6;
+ if (has_state()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 6, *this->state_, false, target);
+ }
+
+ // optional bool debug_info = 7 [default = false];
+ if (has_debug_info()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(7, this->debug_info(), target);
+ }
+
+ // repeated .caffe.BlobShape input_shape = 8;
+ for (unsigned int i = 0, n = this->input_shape_size(); i < n; i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 8, this->input_shape(i), false, target);
+ }
+
+ // repeated .caffe.LayerParameter layer = 100;
+ for (unsigned int i = 0, n = this->layer_size(); i < n; i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 100, this->layer(i), false, target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.NetParameter)
+ return target;
+}
+
+size_t NetParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.NetParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 113u) {
+ // optional string name = 1;
+ if (has_name()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->name());
+ }
+
+ // optional bool force_backward = 5 [default = false];
+ if (has_force_backward()) {
+ total_size += 1 + 1;
+ }
+
+ // optional .caffe.NetState state = 6;
+ if (has_state()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->state_);
+ }
+
+ // optional bool debug_info = 7 [default = false];
+ if (has_debug_info()) {
+ total_size += 1 + 1;
+ }
+
+ }
+ // repeated string input = 3;
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->input_size());
+ for (int i = 0; i < this->input_size(); i++) {
+ total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->input(i));
+ }
+
+ // repeated .caffe.BlobShape input_shape = 8;
+ {
+ unsigned int count = this->input_shape_size();
+ total_size += 1UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->input_shape(i));
+ }
+ }
+
+ // repeated int32 input_dim = 4;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->input_dim_size();
+ for (unsigned int i = 0; i < count; i++) {
+ data_size += ::google::protobuf::internal::WireFormatLite::
+ Int32Size(this->input_dim(i));
+ }
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->input_dim_size());
+ total_size += data_size;
+ }
+
+ // repeated .caffe.LayerParameter layer = 100;
+ {
+ unsigned int count = this->layer_size();
+ total_size += 2UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->layer(i));
+ }
+ }
+
+ // repeated .caffe.V1LayerParameter layers = 2;
+ {
+ unsigned int count = this->layers_size();
+ total_size += 1UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->layers(i));
+ }
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void NetParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.NetParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const NetParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const NetParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.NetParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.NetParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void NetParameter::MergeFrom(const NetParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.NetParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void NetParameter::UnsafeMergeFrom(const NetParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ input_.UnsafeMergeFrom(from.input_);
+ input_shape_.MergeFrom(from.input_shape_);
+ input_dim_.UnsafeMergeFrom(from.input_dim_);
+ layer_.MergeFrom(from.layer_);
+ layers_.MergeFrom(from.layers_);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_name()) {
+ set_has_name();
+ name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
+ }
+ if (from.has_force_backward()) {
+ set_force_backward(from.force_backward());
+ }
+ if (from.has_state()) {
+ mutable_state()->::caffe::NetState::MergeFrom(from.state());
+ }
+ if (from.has_debug_info()) {
+ set_debug_info(from.debug_info());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void NetParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.NetParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void NetParameter::CopyFrom(const NetParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.NetParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool NetParameter::IsInitialized() const {
+
+ return true;
+}
+
+void NetParameter::Swap(NetParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void NetParameter::InternalSwap(NetParameter* other) {
+ name_.Swap(&other->name_);
+ input_.UnsafeArenaSwap(&other->input_);
+ input_shape_.UnsafeArenaSwap(&other->input_shape_);
+ input_dim_.UnsafeArenaSwap(&other->input_dim_);
+ std::swap(force_backward_, other->force_backward_);
+ std::swap(state_, other->state_);
+ std::swap(debug_info_, other->debug_info_);
+ layer_.UnsafeArenaSwap(&other->layer_);
+ layers_.UnsafeArenaSwap(&other->layers_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata NetParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = NetParameter_descriptor_;
+ metadata.reflection = NetParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// NetParameter
+
+// optional string name = 1;
+bool NetParameter::has_name() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void NetParameter::set_has_name() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void NetParameter::clear_has_name() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void NetParameter::clear_name() {
+ name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_name();
+}
+const ::std::string& NetParameter::name() const {
+ // @@protoc_insertion_point(field_get:caffe.NetParameter.name)
+ return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void NetParameter::set_name(const ::std::string& value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.NetParameter.name)
+}
+void NetParameter::set_name(const char* value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.NetParameter.name)
+}
+void NetParameter::set_name(const char* value, size_t size) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.NetParameter.name)
+}
+::std::string* NetParameter::mutable_name() {
+ set_has_name();
+ // @@protoc_insertion_point(field_mutable:caffe.NetParameter.name)
+ return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* NetParameter::release_name() {
+ // @@protoc_insertion_point(field_release:caffe.NetParameter.name)
+ clear_has_name();
+ return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void NetParameter::set_allocated_name(::std::string* name) {
+ if (name != NULL) {
+ set_has_name();
+ } else {
+ clear_has_name();
+ }
+ name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
+ // @@protoc_insertion_point(field_set_allocated:caffe.NetParameter.name)
+}
+
+// repeated string input = 3;
+int NetParameter::input_size() const {
+ return input_.size();
+}
+void NetParameter::clear_input() {
+ input_.Clear();
+}
+const ::std::string& NetParameter::input(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.NetParameter.input)
+ return input_.Get(index);
+}
+::std::string* NetParameter::mutable_input(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.NetParameter.input)
+ return input_.Mutable(index);
+}
+void NetParameter::set_input(int index, const ::std::string& value) {
+ // @@protoc_insertion_point(field_set:caffe.NetParameter.input)
+ input_.Mutable(index)->assign(value);
+}
+void NetParameter::set_input(int index, const char* value) {
+ input_.Mutable(index)->assign(value);
+ // @@protoc_insertion_point(field_set_char:caffe.NetParameter.input)
+}
+void NetParameter::set_input(int index, const char* value, size_t size) {
+ input_.Mutable(index)->assign(
+ reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_set_pointer:caffe.NetParameter.input)
+}
+::std::string* NetParameter::add_input() {
+ // @@protoc_insertion_point(field_add_mutable:caffe.NetParameter.input)
+ return input_.Add();
+}
+void NetParameter::add_input(const ::std::string& value) {
+ input_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add:caffe.NetParameter.input)
+}
+void NetParameter::add_input(const char* value) {
+ input_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add_char:caffe.NetParameter.input)
+}
+void NetParameter::add_input(const char* value, size_t size) {
+ input_.Add()->assign(reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_add_pointer:caffe.NetParameter.input)
+}
+const ::google::protobuf::RepeatedPtrField< ::std::string>&
+NetParameter::input() const {
+ // @@protoc_insertion_point(field_list:caffe.NetParameter.input)
+ return input_;
+}
+::google::protobuf::RepeatedPtrField< ::std::string>*
+NetParameter::mutable_input() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.input)
+ return &input_;
+}
+
+// repeated .caffe.BlobShape input_shape = 8;
+int NetParameter::input_shape_size() const {
+ return input_shape_.size();
+}
+void NetParameter::clear_input_shape() {
+ input_shape_.Clear();
+}
+const ::caffe::BlobShape& NetParameter::input_shape(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.NetParameter.input_shape)
+ return input_shape_.Get(index);
+}
+::caffe::BlobShape* NetParameter::mutable_input_shape(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.NetParameter.input_shape)
+ return input_shape_.Mutable(index);
+}
+::caffe::BlobShape* NetParameter::add_input_shape() {
+ // @@protoc_insertion_point(field_add:caffe.NetParameter.input_shape)
+ return input_shape_.Add();
+}
+::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >*
+NetParameter::mutable_input_shape() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.input_shape)
+ return &input_shape_;
+}
+const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >&
+NetParameter::input_shape() const {
+ // @@protoc_insertion_point(field_list:caffe.NetParameter.input_shape)
+ return input_shape_;
+}
+
+// repeated int32 input_dim = 4;
+int NetParameter::input_dim_size() const {
+ return input_dim_.size();
+}
+void NetParameter::clear_input_dim() {
+ input_dim_.Clear();
+}
+::google::protobuf::int32 NetParameter::input_dim(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.NetParameter.input_dim)
+ return input_dim_.Get(index);
+}
+void NetParameter::set_input_dim(int index, ::google::protobuf::int32 value) {
+ input_dim_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.NetParameter.input_dim)
+}
+void NetParameter::add_input_dim(::google::protobuf::int32 value) {
+ input_dim_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.NetParameter.input_dim)
+}
+const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
+NetParameter::input_dim() const {
+ // @@protoc_insertion_point(field_list:caffe.NetParameter.input_dim)
+ return input_dim_;
+}
+::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
+NetParameter::mutable_input_dim() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.input_dim)
+ return &input_dim_;
+}
+
+// optional bool force_backward = 5 [default = false];
+bool NetParameter::has_force_backward() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+void NetParameter::set_has_force_backward() {
+ _has_bits_[0] |= 0x00000010u;
+}
+void NetParameter::clear_has_force_backward() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+void NetParameter::clear_force_backward() {
+ force_backward_ = false;
+ clear_has_force_backward();
+}
+bool NetParameter::force_backward() const {
+ // @@protoc_insertion_point(field_get:caffe.NetParameter.force_backward)
+ return force_backward_;
+}
+void NetParameter::set_force_backward(bool value) {
+ set_has_force_backward();
+ force_backward_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NetParameter.force_backward)
+}
+
+// optional .caffe.NetState state = 6;
+bool NetParameter::has_state() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+void NetParameter::set_has_state() {
+ _has_bits_[0] |= 0x00000020u;
+}
+void NetParameter::clear_has_state() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+void NetParameter::clear_state() {
+ if (state_ != NULL) state_->::caffe::NetState::Clear();
+ clear_has_state();
+}
+const ::caffe::NetState& NetParameter::state() const {
+ // @@protoc_insertion_point(field_get:caffe.NetParameter.state)
+ return state_ != NULL ? *state_
+ : *::caffe::NetState::internal_default_instance();
+}
+::caffe::NetState* NetParameter::mutable_state() {
+ set_has_state();
+ if (state_ == NULL) {
+ state_ = new ::caffe::NetState;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.NetParameter.state)
+ return state_;
+}
+::caffe::NetState* NetParameter::release_state() {
+ // @@protoc_insertion_point(field_release:caffe.NetParameter.state)
+ clear_has_state();
+ ::caffe::NetState* temp = state_;
+ state_ = NULL;
+ return temp;
+}
+void NetParameter::set_allocated_state(::caffe::NetState* state) {
+ delete state_;
+ state_ = state;
+ if (state) {
+ set_has_state();
+ } else {
+ clear_has_state();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.NetParameter.state)
+}
+
+// optional bool debug_info = 7 [default = false];
+bool NetParameter::has_debug_info() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+void NetParameter::set_has_debug_info() {
+ _has_bits_[0] |= 0x00000040u;
+}
+void NetParameter::clear_has_debug_info() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+void NetParameter::clear_debug_info() {
+ debug_info_ = false;
+ clear_has_debug_info();
+}
+bool NetParameter::debug_info() const {
+ // @@protoc_insertion_point(field_get:caffe.NetParameter.debug_info)
+ return debug_info_;
+}
+void NetParameter::set_debug_info(bool value) {
+ set_has_debug_info();
+ debug_info_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NetParameter.debug_info)
+}
+
+// repeated .caffe.LayerParameter layer = 100;
+int NetParameter::layer_size() const {
+ return layer_.size();
+}
+void NetParameter::clear_layer() {
+ layer_.Clear();
+}
+const ::caffe::LayerParameter& NetParameter::layer(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.NetParameter.layer)
+ return layer_.Get(index);
+}
+::caffe::LayerParameter* NetParameter::mutable_layer(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.NetParameter.layer)
+ return layer_.Mutable(index);
+}
+::caffe::LayerParameter* NetParameter::add_layer() {
+ // @@protoc_insertion_point(field_add:caffe.NetParameter.layer)
+ return layer_.Add();
+}
+::google::protobuf::RepeatedPtrField< ::caffe::LayerParameter >*
+NetParameter::mutable_layer() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.layer)
+ return &layer_;
+}
+const ::google::protobuf::RepeatedPtrField< ::caffe::LayerParameter >&
+NetParameter::layer() const {
+ // @@protoc_insertion_point(field_list:caffe.NetParameter.layer)
+ return layer_;
+}
+
+// repeated .caffe.V1LayerParameter layers = 2;
+int NetParameter::layers_size() const {
+ return layers_.size();
+}
+void NetParameter::clear_layers() {
+ layers_.Clear();
+}
+const ::caffe::V1LayerParameter& NetParameter::layers(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.NetParameter.layers)
+ return layers_.Get(index);
+}
+::caffe::V1LayerParameter* NetParameter::mutable_layers(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.NetParameter.layers)
+ return layers_.Mutable(index);
+}
+::caffe::V1LayerParameter* NetParameter::add_layers() {
+ // @@protoc_insertion_point(field_add:caffe.NetParameter.layers)
+ return layers_.Add();
+}
+::google::protobuf::RepeatedPtrField< ::caffe::V1LayerParameter >*
+NetParameter::mutable_layers() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.layers)
+ return &layers_;
+}
+const ::google::protobuf::RepeatedPtrField< ::caffe::V1LayerParameter >&
+NetParameter::layers() const {
+ // @@protoc_insertion_point(field_list:caffe.NetParameter.layers)
+ return layers_;
+}
+
+inline const NetParameter* NetParameter::internal_default_instance() {
+ return &NetParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+const ::google::protobuf::EnumDescriptor* SolverParameter_SnapshotFormat_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return SolverParameter_SnapshotFormat_descriptor_;
+}
+bool SolverParameter_SnapshotFormat_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const SolverParameter_SnapshotFormat SolverParameter::HDF5;
+const SolverParameter_SnapshotFormat SolverParameter::BINARYPROTO;
+const SolverParameter_SnapshotFormat SolverParameter::SnapshotFormat_MIN;
+const SolverParameter_SnapshotFormat SolverParameter::SnapshotFormat_MAX;
+const int SolverParameter::SnapshotFormat_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+const ::google::protobuf::EnumDescriptor* SolverParameter_SolverMode_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return SolverParameter_SolverMode_descriptor_;
+}
+bool SolverParameter_SolverMode_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const SolverParameter_SolverMode SolverParameter::CPU;
+const SolverParameter_SolverMode SolverParameter::GPU;
+const SolverParameter_SolverMode SolverParameter::SolverMode_MIN;
+const SolverParameter_SolverMode SolverParameter::SolverMode_MAX;
+const int SolverParameter::SolverMode_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+const ::google::protobuf::EnumDescriptor* SolverParameter_SolverType_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return SolverParameter_SolverType_descriptor_;
+}
+bool SolverParameter_SolverType_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const SolverParameter_SolverType SolverParameter::SGD;
+const SolverParameter_SolverType SolverParameter::NESTEROV;
+const SolverParameter_SolverType SolverParameter::ADAGRAD;
+const SolverParameter_SolverType SolverParameter::RMSPROP;
+const SolverParameter_SolverType SolverParameter::ADADELTA;
+const SolverParameter_SolverType SolverParameter::ADAM;
+const SolverParameter_SolverType SolverParameter::SolverType_MIN;
+const SolverParameter_SolverType SolverParameter::SolverType_MAX;
+const int SolverParameter::SolverType_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+::std::string* SolverParameter::_default_regularization_type_ = NULL;
+::std::string* SolverParameter::_default_type_ = NULL;
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int SolverParameter::kNetFieldNumber;
+const int SolverParameter::kNetParamFieldNumber;
+const int SolverParameter::kTrainNetFieldNumber;
+const int SolverParameter::kTestNetFieldNumber;
+const int SolverParameter::kTrainNetParamFieldNumber;
+const int SolverParameter::kTestNetParamFieldNumber;
+const int SolverParameter::kTrainStateFieldNumber;
+const int SolverParameter::kTestStateFieldNumber;
+const int SolverParameter::kTestIterFieldNumber;
+const int SolverParameter::kTestIntervalFieldNumber;
+const int SolverParameter::kTestComputeLossFieldNumber;
+const int SolverParameter::kTestInitializationFieldNumber;
+const int SolverParameter::kBaseLrFieldNumber;
+const int SolverParameter::kDisplayFieldNumber;
+const int SolverParameter::kAverageLossFieldNumber;
+const int SolverParameter::kMaxIterFieldNumber;
+const int SolverParameter::kIterSizeFieldNumber;
+const int SolverParameter::kLrPolicyFieldNumber;
+const int SolverParameter::kGammaFieldNumber;
+const int SolverParameter::kPowerFieldNumber;
+const int SolverParameter::kMomentumFieldNumber;
+const int SolverParameter::kWeightDecayFieldNumber;
+const int SolverParameter::kRegularizationTypeFieldNumber;
+const int SolverParameter::kStepsizeFieldNumber;
+const int SolverParameter::kStepvalueFieldNumber;
+const int SolverParameter::kClipGradientsFieldNumber;
+const int SolverParameter::kSnapshotFieldNumber;
+const int SolverParameter::kSnapshotPrefixFieldNumber;
+const int SolverParameter::kSnapshotDiffFieldNumber;
+const int SolverParameter::kSnapshotFormatFieldNumber;
+const int SolverParameter::kSolverModeFieldNumber;
+const int SolverParameter::kDeviceIdFieldNumber;
+const int SolverParameter::kRandomSeedFieldNumber;
+const int SolverParameter::kTypeFieldNumber;
+const int SolverParameter::kDeltaFieldNumber;
+const int SolverParameter::kMomentum2FieldNumber;
+const int SolverParameter::kRmsDecayFieldNumber;
+const int SolverParameter::kDebugInfoFieldNumber;
+const int SolverParameter::kSnapshotAfterTrainFieldNumber;
+const int SolverParameter::kSolverTypeFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+SolverParameter::SolverParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.SolverParameter)
+}
+
+void SolverParameter::InitAsDefaultInstance() {
+ net_param_ = const_cast< ::caffe::NetParameter*>(
+ ::caffe::NetParameter::internal_default_instance());
+ train_net_param_ = const_cast< ::caffe::NetParameter*>(
+ ::caffe::NetParameter::internal_default_instance());
+ train_state_ = const_cast< ::caffe::NetState*>(
+ ::caffe::NetState::internal_default_instance());
+}
+
+SolverParameter::SolverParameter(const SolverParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.SolverParameter)
+}
+
+void SolverParameter::SharedCtor() {
+ net_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ train_net_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ lr_policy_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ regularization_type_.UnsafeSetDefault(_default_regularization_type_);
+ snapshot_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ type_.UnsafeSetDefault(_default_type_);
+ net_param_ = NULL;
+ train_net_param_ = NULL;
+ train_state_ = NULL;
+ ::memset(&test_interval_, 0, reinterpret_cast<char*>(&solver_type_) -
+ reinterpret_cast<char*>(&test_interval_) + sizeof(solver_type_));
+ rms_decay_ = 0.99f;
+ average_loss_ = 1;
+ iter_size_ = 1;
+ test_initialization_ = true;
+ snapshot_after_train_ = true;
+ clip_gradients_ = -1;
+ snapshot_format_ = 1;
+ solver_mode_ = 1;
+ random_seed_ = GOOGLE_LONGLONG(-1);
+ delta_ = 1e-08f;
+ momentum2_ = 0.999f;
+ _cached_size_ = 0;
+}
+
+SolverParameter::~SolverParameter() {
+ // @@protoc_insertion_point(destructor:caffe.SolverParameter)
+ SharedDtor();
+}
+
+void SolverParameter::SharedDtor() {
+ net_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ train_net_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ lr_policy_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ regularization_type_.DestroyNoArena(_default_regularization_type_);
+ snapshot_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ type_.DestroyNoArena(_default_type_);
+ if (this != &SolverParameter_default_instance_.get()) {
+ delete net_param_;
+ delete train_net_param_;
+ delete train_state_;
+ }
+}
+
+void SolverParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* SolverParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return SolverParameter_descriptor_;
+}
+
+const SolverParameter& SolverParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<SolverParameter> SolverParameter_default_instance_;
+
+SolverParameter* SolverParameter::New(::google::protobuf::Arena* arena) const {
+ SolverParameter* n = new SolverParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void SolverParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.SolverParameter)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(SolverParameter, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<SolverParameter*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ if (_has_bits_[0 / 32] & 87u) {
+ if (has_net()) {
+ net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ if (has_net_param()) {
+ if (net_param_ != NULL) net_param_->::caffe::NetParameter::Clear();
+ }
+ if (has_train_net()) {
+ train_net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ if (has_train_net_param()) {
+ if (train_net_param_ != NULL) train_net_param_->::caffe::NetParameter::Clear();
+ }
+ if (has_train_state()) {
+ if (train_state_ != NULL) train_state_->::caffe::NetState::Clear();
+ }
+ }
+ if (_has_bits_[8 / 32] & 65024u) {
+ ZR_(test_interval_, max_iter_);
+ test_compute_loss_ = false;
+ test_initialization_ = true;
+ average_loss_ = 1;
+ }
+ if (_has_bits_[16 / 32] & 16711680u) {
+ ZR_(gamma_, stepsize_);
+ iter_size_ = 1;
+ if (has_lr_policy()) {
+ lr_policy_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ if (has_regularization_type()) {
+ regularization_type_.ClearToDefaultNoArena(_default_regularization_type_);
+ }
+ }
+ if (_has_bits_[24 / 32] & 4261412864u) {
+ ZR_(snapshot_, device_id_);
+ clip_gradients_ = -1;
+ if (has_snapshot_prefix()) {
+ snapshot_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ snapshot_diff_ = false;
+ snapshot_format_ = 1;
+ solver_mode_ = 1;
+ }
+ if (_has_bits_[32 / 32] & 255u) {
+ random_seed_ = GOOGLE_LONGLONG(-1);
+ if (has_type()) {
+ type_.ClearToDefaultNoArena(_default_type_);
+ }
+ delta_ = 1e-08f;
+ momentum2_ = 0.999f;
+ rms_decay_ = 0.99f;
+ debug_info_ = false;
+ snapshot_after_train_ = true;
+ solver_type_ = 0;
+ }
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ test_net_.Clear();
+ test_net_param_.Clear();
+ test_state_.Clear();
+ test_iter_.Clear();
+ stepvalue_.Clear();
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool SolverParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.SolverParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional string train_net = 1;
+ case 1: {
+ if (tag == 10) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_train_net()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->train_net().data(), this->train_net().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.SolverParameter.train_net");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(18)) goto parse_test_net;
+ break;
+ }
+
+ // repeated string test_net = 2;
+ case 2: {
+ if (tag == 18) {
+ parse_test_net:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->add_test_net()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->test_net(this->test_net_size() - 1).data(),
+ this->test_net(this->test_net_size() - 1).length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.SolverParameter.test_net");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(18)) goto parse_test_net;
+ if (input->ExpectTag(24)) goto parse_test_iter;
+ break;
+ }
+
+ // repeated int32 test_iter = 3;
+ case 3: {
+ if (tag == 24) {
+ parse_test_iter:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ 1, 24, input, this->mutable_test_iter())));
+ } else if (tag == 26) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, this->mutable_test_iter())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(24)) goto parse_test_iter;
+ if (input->ExpectTag(32)) goto parse_test_interval;
+ break;
+ }
+
+ // optional int32 test_interval = 4 [default = 0];
+ case 4: {
+ if (tag == 32) {
+ parse_test_interval:
+ set_has_test_interval();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &test_interval_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(45)) goto parse_base_lr;
+ break;
+ }
+
+ // optional float base_lr = 5;
+ case 5: {
+ if (tag == 45) {
+ parse_base_lr:
+ set_has_base_lr();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &base_lr_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(48)) goto parse_display;
+ break;
+ }
+
+ // optional int32 display = 6;
+ case 6: {
+ if (tag == 48) {
+ parse_display:
+ set_has_display();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &display_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(56)) goto parse_max_iter;
+ break;
+ }
+
+ // optional int32 max_iter = 7;
+ case 7: {
+ if (tag == 56) {
+ parse_max_iter:
+ set_has_max_iter();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &max_iter_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(66)) goto parse_lr_policy;
+ break;
+ }
+
+ // optional string lr_policy = 8;
+ case 8: {
+ if (tag == 66) {
+ parse_lr_policy:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_lr_policy()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->lr_policy().data(), this->lr_policy().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.SolverParameter.lr_policy");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(77)) goto parse_gamma;
+ break;
+ }
+
+ // optional float gamma = 9;
+ case 9: {
+ if (tag == 77) {
+ parse_gamma:
+ set_has_gamma();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &gamma_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(85)) goto parse_power;
+ break;
+ }
+
+ // optional float power = 10;
+ case 10: {
+ if (tag == 85) {
+ parse_power:
+ set_has_power();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &power_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(93)) goto parse_momentum;
+ break;
+ }
+
+ // optional float momentum = 11;
+ case 11: {
+ if (tag == 93) {
+ parse_momentum:
+ set_has_momentum();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &momentum_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(101)) goto parse_weight_decay;
+ break;
+ }
+
+ // optional float weight_decay = 12;
+ case 12: {
+ if (tag == 101) {
+ parse_weight_decay:
+ set_has_weight_decay();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &weight_decay_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(104)) goto parse_stepsize;
+ break;
+ }
+
+ // optional int32 stepsize = 13;
+ case 13: {
+ if (tag == 104) {
+ parse_stepsize:
+ set_has_stepsize();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &stepsize_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(112)) goto parse_snapshot;
+ break;
+ }
+
+ // optional int32 snapshot = 14 [default = 0];
+ case 14: {
+ if (tag == 112) {
+ parse_snapshot:
+ set_has_snapshot();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &snapshot_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(122)) goto parse_snapshot_prefix;
+ break;
+ }
+
+ // optional string snapshot_prefix = 15;
+ case 15: {
+ if (tag == 122) {
+ parse_snapshot_prefix:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_snapshot_prefix()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->snapshot_prefix().data(), this->snapshot_prefix().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.SolverParameter.snapshot_prefix");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(128)) goto parse_snapshot_diff;
+ break;
+ }
+
+ // optional bool snapshot_diff = 16 [default = false];
+ case 16: {
+ if (tag == 128) {
+ parse_snapshot_diff:
+ set_has_snapshot_diff();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &snapshot_diff_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(136)) goto parse_solver_mode;
+ break;
+ }
+
+ // optional .caffe.SolverParameter.SolverMode solver_mode = 17 [default = GPU];
+ case 17: {
+ if (tag == 136) {
+ parse_solver_mode:
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::SolverParameter_SolverMode_IsValid(value)) {
+ set_solver_mode(static_cast< ::caffe::SolverParameter_SolverMode >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(17, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(144)) goto parse_device_id;
+ break;
+ }
+
+ // optional int32 device_id = 18 [default = 0];
+ case 18: {
+ if (tag == 144) {
+ parse_device_id:
+ set_has_device_id();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &device_id_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(152)) goto parse_test_compute_loss;
+ break;
+ }
+
+ // optional bool test_compute_loss = 19 [default = false];
+ case 19: {
+ if (tag == 152) {
+ parse_test_compute_loss:
+ set_has_test_compute_loss();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &test_compute_loss_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(160)) goto parse_random_seed;
+ break;
+ }
+
+ // optional int64 random_seed = 20 [default = -1];
+ case 20: {
+ if (tag == 160) {
+ parse_random_seed:
+ set_has_random_seed();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
+ input, &random_seed_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(170)) goto parse_train_net_param;
+ break;
+ }
+
+ // optional .caffe.NetParameter train_net_param = 21;
+ case 21: {
+ if (tag == 170) {
+ parse_train_net_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_train_net_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(178)) goto parse_test_net_param;
+ break;
+ }
+
+ // repeated .caffe.NetParameter test_net_param = 22;
+ case 22: {
+ if (tag == 178) {
+ parse_test_net_param:
+ DO_(input->IncrementRecursionDepth());
+ parse_loop_test_net_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
+ input, add_test_net_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(178)) goto parse_loop_test_net_param;
+ input->UnsafeDecrementRecursionDepth();
+ if (input->ExpectTag(184)) goto parse_debug_info;
+ break;
+ }
+
+ // optional bool debug_info = 23 [default = false];
+ case 23: {
+ if (tag == 184) {
+ parse_debug_info:
+ set_has_debug_info();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &debug_info_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(194)) goto parse_net;
+ break;
+ }
+
+ // optional string net = 24;
+ case 24: {
+ if (tag == 194) {
+ parse_net:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_net()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->net().data(), this->net().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.SolverParameter.net");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(202)) goto parse_net_param;
+ break;
+ }
+
+ // optional .caffe.NetParameter net_param = 25;
+ case 25: {
+ if (tag == 202) {
+ parse_net_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_net_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(210)) goto parse_train_state;
+ break;
+ }
+
+ // optional .caffe.NetState train_state = 26;
+ case 26: {
+ if (tag == 210) {
+ parse_train_state:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_train_state()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(218)) goto parse_test_state;
+ break;
+ }
+
+ // repeated .caffe.NetState test_state = 27;
+ case 27: {
+ if (tag == 218) {
+ parse_test_state:
+ DO_(input->IncrementRecursionDepth());
+ parse_loop_test_state:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
+ input, add_test_state()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(218)) goto parse_loop_test_state;
+ input->UnsafeDecrementRecursionDepth();
+ if (input->ExpectTag(224)) goto parse_snapshot_after_train;
+ break;
+ }
+
+ // optional bool snapshot_after_train = 28 [default = true];
+ case 28: {
+ if (tag == 224) {
+ parse_snapshot_after_train:
+ set_has_snapshot_after_train();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &snapshot_after_train_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(234)) goto parse_regularization_type;
+ break;
+ }
+
+ // optional string regularization_type = 29 [default = "L2"];
+ case 29: {
+ if (tag == 234) {
+ parse_regularization_type:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_regularization_type()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->regularization_type().data(), this->regularization_type().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.SolverParameter.regularization_type");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(240)) goto parse_solver_type;
+ break;
+ }
+
+ // optional .caffe.SolverParameter.SolverType solver_type = 30 [default = SGD];
+ case 30: {
+ if (tag == 240) {
+ parse_solver_type:
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::SolverParameter_SolverType_IsValid(value)) {
+ set_solver_type(static_cast< ::caffe::SolverParameter_SolverType >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(30, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(253)) goto parse_delta;
+ break;
+ }
+
+ // optional float delta = 31 [default = 1e-08];
+ case 31: {
+ if (tag == 253) {
+ parse_delta:
+ set_has_delta();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &delta_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(256)) goto parse_test_initialization;
+ break;
+ }
+
+ // optional bool test_initialization = 32 [default = true];
+ case 32: {
+ if (tag == 256) {
+ parse_test_initialization:
+ set_has_test_initialization();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &test_initialization_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(264)) goto parse_average_loss;
+ break;
+ }
+
+ // optional int32 average_loss = 33 [default = 1];
+ case 33: {
+ if (tag == 264) {
+ parse_average_loss:
+ set_has_average_loss();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &average_loss_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(272)) goto parse_stepvalue;
+ break;
+ }
+
+ // repeated int32 stepvalue = 34;
+ case 34: {
+ if (tag == 272) {
+ parse_stepvalue:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ 2, 272, input, this->mutable_stepvalue())));
+ } else if (tag == 274) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, this->mutable_stepvalue())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(272)) goto parse_stepvalue;
+ if (input->ExpectTag(285)) goto parse_clip_gradients;
+ break;
+ }
+
+ // optional float clip_gradients = 35 [default = -1];
+ case 35: {
+ if (tag == 285) {
+ parse_clip_gradients:
+ set_has_clip_gradients();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &clip_gradients_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(288)) goto parse_iter_size;
+ break;
+ }
+
+ // optional int32 iter_size = 36 [default = 1];
+ case 36: {
+ if (tag == 288) {
+ parse_iter_size:
+ set_has_iter_size();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &iter_size_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(296)) goto parse_snapshot_format;
+ break;
+ }
+
+ // optional .caffe.SolverParameter.SnapshotFormat snapshot_format = 37 [default = BINARYPROTO];
+ case 37: {
+ if (tag == 296) {
+ parse_snapshot_format:
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::SolverParameter_SnapshotFormat_IsValid(value)) {
+ set_snapshot_format(static_cast< ::caffe::SolverParameter_SnapshotFormat >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(37, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(309)) goto parse_rms_decay;
+ break;
+ }
+
+ // optional float rms_decay = 38 [default = 0.99];
+ case 38: {
+ if (tag == 309) {
+ parse_rms_decay:
+ set_has_rms_decay();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &rms_decay_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(317)) goto parse_momentum2;
+ break;
+ }
+
+ // optional float momentum2 = 39 [default = 0.999];
+ case 39: {
+ if (tag == 317) {
+ parse_momentum2:
+ set_has_momentum2();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &momentum2_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(322)) goto parse_type;
+ break;
+ }
+
+ // optional string type = 40 [default = "SGD"];
+ case 40: {
+ if (tag == 322) {
+ parse_type:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_type()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->type().data(), this->type().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.SolverParameter.type");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.SolverParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.SolverParameter)
+ return false;
+#undef DO_
+}
+
+void SolverParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.SolverParameter)
+ // optional string train_net = 1;
+ if (has_train_net()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->train_net().data(), this->train_net().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SolverParameter.train_net");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 1, this->train_net(), output);
+ }
+
+ // repeated string test_net = 2;
+ for (int i = 0; i < this->test_net_size(); i++) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->test_net(i).data(), this->test_net(i).length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SolverParameter.test_net");
+ ::google::protobuf::internal::WireFormatLite::WriteString(
+ 2, this->test_net(i), output);
+ }
+
+ // repeated int32 test_iter = 3;
+ for (int i = 0; i < this->test_iter_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(
+ 3, this->test_iter(i), output);
+ }
+
+ // optional int32 test_interval = 4 [default = 0];
+ if (has_test_interval()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->test_interval(), output);
+ }
+
+ // optional float base_lr = 5;
+ if (has_base_lr()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(5, this->base_lr(), output);
+ }
+
+ // optional int32 display = 6;
+ if (has_display()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(6, this->display(), output);
+ }
+
+ // optional int32 max_iter = 7;
+ if (has_max_iter()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(7, this->max_iter(), output);
+ }
+
+ // optional string lr_policy = 8;
+ if (has_lr_policy()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->lr_policy().data(), this->lr_policy().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SolverParameter.lr_policy");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 8, this->lr_policy(), output);
+ }
+
+ // optional float gamma = 9;
+ if (has_gamma()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(9, this->gamma(), output);
+ }
+
+ // optional float power = 10;
+ if (has_power()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(10, this->power(), output);
+ }
+
+ // optional float momentum = 11;
+ if (has_momentum()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(11, this->momentum(), output);
+ }
+
+ // optional float weight_decay = 12;
+ if (has_weight_decay()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(12, this->weight_decay(), output);
+ }
+
+ // optional int32 stepsize = 13;
+ if (has_stepsize()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(13, this->stepsize(), output);
+ }
+
+ // optional int32 snapshot = 14 [default = 0];
+ if (has_snapshot()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(14, this->snapshot(), output);
+ }
+
+ // optional string snapshot_prefix = 15;
+ if (has_snapshot_prefix()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->snapshot_prefix().data(), this->snapshot_prefix().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SolverParameter.snapshot_prefix");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 15, this->snapshot_prefix(), output);
+ }
+
+ // optional bool snapshot_diff = 16 [default = false];
+ if (has_snapshot_diff()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(16, this->snapshot_diff(), output);
+ }
+
+ // optional .caffe.SolverParameter.SolverMode solver_mode = 17 [default = GPU];
+ if (has_solver_mode()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 17, this->solver_mode(), output);
+ }
+
+ // optional int32 device_id = 18 [default = 0];
+ if (has_device_id()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(18, this->device_id(), output);
+ }
+
+ // optional bool test_compute_loss = 19 [default = false];
+ if (has_test_compute_loss()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(19, this->test_compute_loss(), output);
+ }
+
+ // optional int64 random_seed = 20 [default = -1];
+ if (has_random_seed()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt64(20, this->random_seed(), output);
+ }
+
+ // optional .caffe.NetParameter train_net_param = 21;
+ if (has_train_net_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 21, *this->train_net_param_, output);
+ }
+
+ // repeated .caffe.NetParameter test_net_param = 22;
+ for (unsigned int i = 0, n = this->test_net_param_size(); i < n; i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 22, this->test_net_param(i), output);
+ }
+
+ // optional bool debug_info = 23 [default = false];
+ if (has_debug_info()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(23, this->debug_info(), output);
+ }
+
+ // optional string net = 24;
+ if (has_net()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->net().data(), this->net().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SolverParameter.net");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 24, this->net(), output);
+ }
+
+ // optional .caffe.NetParameter net_param = 25;
+ if (has_net_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 25, *this->net_param_, output);
+ }
+
+ // optional .caffe.NetState train_state = 26;
+ if (has_train_state()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 26, *this->train_state_, output);
+ }
+
+ // repeated .caffe.NetState test_state = 27;
+ for (unsigned int i = 0, n = this->test_state_size(); i < n; i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 27, this->test_state(i), output);
+ }
+
+ // optional bool snapshot_after_train = 28 [default = true];
+ if (has_snapshot_after_train()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(28, this->snapshot_after_train(), output);
+ }
+
+ // optional string regularization_type = 29 [default = "L2"];
+ if (has_regularization_type()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->regularization_type().data(), this->regularization_type().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SolverParameter.regularization_type");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 29, this->regularization_type(), output);
+ }
+
+ // optional .caffe.SolverParameter.SolverType solver_type = 30 [default = SGD];
+ if (has_solver_type()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 30, this->solver_type(), output);
+ }
+
+ // optional float delta = 31 [default = 1e-08];
+ if (has_delta()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(31, this->delta(), output);
+ }
+
+ // optional bool test_initialization = 32 [default = true];
+ if (has_test_initialization()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(32, this->test_initialization(), output);
+ }
+
+ // optional int32 average_loss = 33 [default = 1];
+ if (has_average_loss()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(33, this->average_loss(), output);
+ }
+
+ // repeated int32 stepvalue = 34;
+ for (int i = 0; i < this->stepvalue_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(
+ 34, this->stepvalue(i), output);
+ }
+
+ // optional float clip_gradients = 35 [default = -1];
+ if (has_clip_gradients()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(35, this->clip_gradients(), output);
+ }
+
+ // optional int32 iter_size = 36 [default = 1];
+ if (has_iter_size()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(36, this->iter_size(), output);
+ }
+
+ // optional .caffe.SolverParameter.SnapshotFormat snapshot_format = 37 [default = BINARYPROTO];
+ if (has_snapshot_format()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 37, this->snapshot_format(), output);
+ }
+
+ // optional float rms_decay = 38 [default = 0.99];
+ if (has_rms_decay()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(38, this->rms_decay(), output);
+ }
+
+ // optional float momentum2 = 39 [default = 0.999];
+ if (has_momentum2()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(39, this->momentum2(), output);
+ }
+
+ // optional string type = 40 [default = "SGD"];
+ if (has_type()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->type().data(), this->type().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SolverParameter.type");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 40, this->type(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.SolverParameter)
+}
+
+::google::protobuf::uint8* SolverParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.SolverParameter)
+ // optional string train_net = 1;
+ if (has_train_net()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->train_net().data(), this->train_net().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SolverParameter.train_net");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 1, this->train_net(), target);
+ }
+
+ // repeated string test_net = 2;
+ for (int i = 0; i < this->test_net_size(); i++) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->test_net(i).data(), this->test_net(i).length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SolverParameter.test_net");
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteStringToArray(2, this->test_net(i), target);
+ }
+
+ // repeated int32 test_iter = 3;
+ for (int i = 0; i < this->test_iter_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteInt32ToArray(3, this->test_iter(i), target);
+ }
+
+ // optional int32 test_interval = 4 [default = 0];
+ if (has_test_interval()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->test_interval(), target);
+ }
+
+ // optional float base_lr = 5;
+ if (has_base_lr()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(5, this->base_lr(), target);
+ }
+
+ // optional int32 display = 6;
+ if (has_display()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(6, this->display(), target);
+ }
+
+ // optional int32 max_iter = 7;
+ if (has_max_iter()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(7, this->max_iter(), target);
+ }
+
+ // optional string lr_policy = 8;
+ if (has_lr_policy()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->lr_policy().data(), this->lr_policy().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SolverParameter.lr_policy");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 8, this->lr_policy(), target);
+ }
+
+ // optional float gamma = 9;
+ if (has_gamma()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(9, this->gamma(), target);
+ }
+
+ // optional float power = 10;
+ if (has_power()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(10, this->power(), target);
+ }
+
+ // optional float momentum = 11;
+ if (has_momentum()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(11, this->momentum(), target);
+ }
+
+ // optional float weight_decay = 12;
+ if (has_weight_decay()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(12, this->weight_decay(), target);
+ }
+
+ // optional int32 stepsize = 13;
+ if (has_stepsize()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(13, this->stepsize(), target);
+ }
+
+ // optional int32 snapshot = 14 [default = 0];
+ if (has_snapshot()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(14, this->snapshot(), target);
+ }
+
+ // optional string snapshot_prefix = 15;
+ if (has_snapshot_prefix()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->snapshot_prefix().data(), this->snapshot_prefix().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SolverParameter.snapshot_prefix");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 15, this->snapshot_prefix(), target);
+ }
+
+ // optional bool snapshot_diff = 16 [default = false];
+ if (has_snapshot_diff()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(16, this->snapshot_diff(), target);
+ }
+
+ // optional .caffe.SolverParameter.SolverMode solver_mode = 17 [default = GPU];
+ if (has_solver_mode()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 17, this->solver_mode(), target);
+ }
+
+ // optional int32 device_id = 18 [default = 0];
+ if (has_device_id()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(18, this->device_id(), target);
+ }
+
+ // optional bool test_compute_loss = 19 [default = false];
+ if (has_test_compute_loss()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(19, this->test_compute_loss(), target);
+ }
+
+ // optional int64 random_seed = 20 [default = -1];
+ if (has_random_seed()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(20, this->random_seed(), target);
+ }
+
+ // optional .caffe.NetParameter train_net_param = 21;
+ if (has_train_net_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 21, *this->train_net_param_, false, target);
+ }
+
+ // repeated .caffe.NetParameter test_net_param = 22;
+ for (unsigned int i = 0, n = this->test_net_param_size(); i < n; i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 22, this->test_net_param(i), false, target);
+ }
+
+ // optional bool debug_info = 23 [default = false];
+ if (has_debug_info()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(23, this->debug_info(), target);
+ }
+
+ // optional string net = 24;
+ if (has_net()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->net().data(), this->net().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SolverParameter.net");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 24, this->net(), target);
+ }
+
+ // optional .caffe.NetParameter net_param = 25;
+ if (has_net_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 25, *this->net_param_, false, target);
+ }
+
+ // optional .caffe.NetState train_state = 26;
+ if (has_train_state()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 26, *this->train_state_, false, target);
+ }
+
+ // repeated .caffe.NetState test_state = 27;
+ for (unsigned int i = 0, n = this->test_state_size(); i < n; i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 27, this->test_state(i), false, target);
+ }
+
+ // optional bool snapshot_after_train = 28 [default = true];
+ if (has_snapshot_after_train()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(28, this->snapshot_after_train(), target);
+ }
+
+ // optional string regularization_type = 29 [default = "L2"];
+ if (has_regularization_type()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->regularization_type().data(), this->regularization_type().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SolverParameter.regularization_type");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 29, this->regularization_type(), target);
+ }
+
+ // optional .caffe.SolverParameter.SolverType solver_type = 30 [default = SGD];
+ if (has_solver_type()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 30, this->solver_type(), target);
+ }
+
+ // optional float delta = 31 [default = 1e-08];
+ if (has_delta()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(31, this->delta(), target);
+ }
+
+ // optional bool test_initialization = 32 [default = true];
+ if (has_test_initialization()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(32, this->test_initialization(), target);
+ }
+
+ // optional int32 average_loss = 33 [default = 1];
+ if (has_average_loss()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(33, this->average_loss(), target);
+ }
+
+ // repeated int32 stepvalue = 34;
+ for (int i = 0; i < this->stepvalue_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteInt32ToArray(34, this->stepvalue(i), target);
+ }
+
+ // optional float clip_gradients = 35 [default = -1];
+ if (has_clip_gradients()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(35, this->clip_gradients(), target);
+ }
+
+ // optional int32 iter_size = 36 [default = 1];
+ if (has_iter_size()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(36, this->iter_size(), target);
+ }
+
+ // optional .caffe.SolverParameter.SnapshotFormat snapshot_format = 37 [default = BINARYPROTO];
+ if (has_snapshot_format()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 37, this->snapshot_format(), target);
+ }
+
+ // optional float rms_decay = 38 [default = 0.99];
+ if (has_rms_decay()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(38, this->rms_decay(), target);
+ }
+
+ // optional float momentum2 = 39 [default = 0.999];
+ if (has_momentum2()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(39, this->momentum2(), target);
+ }
+
+ // optional string type = 40 [default = "SGD"];
+ if (has_type()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->type().data(), this->type().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SolverParameter.type");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 40, this->type(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.SolverParameter)
+ return target;
+}
+
+size_t SolverParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.SolverParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 87u) {
+ // optional string net = 24;
+ if (has_net()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->net());
+ }
+
+ // optional .caffe.NetParameter net_param = 25;
+ if (has_net_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->net_param_);
+ }
+
+ // optional string train_net = 1;
+ if (has_train_net()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->train_net());
+ }
+
+ // optional .caffe.NetParameter train_net_param = 21;
+ if (has_train_net_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->train_net_param_);
+ }
+
+ // optional .caffe.NetState train_state = 26;
+ if (has_train_state()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->train_state_);
+ }
+
+ }
+ if (_has_bits_[9 / 32] & 65024u) {
+ // optional int32 test_interval = 4 [default = 0];
+ if (has_test_interval()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->test_interval());
+ }
+
+ // optional bool test_compute_loss = 19 [default = false];
+ if (has_test_compute_loss()) {
+ total_size += 2 + 1;
+ }
+
+ // optional bool test_initialization = 32 [default = true];
+ if (has_test_initialization()) {
+ total_size += 2 + 1;
+ }
+
+ // optional float base_lr = 5;
+ if (has_base_lr()) {
+ total_size += 1 + 4;
+ }
+
+ // optional int32 display = 6;
+ if (has_display()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->display());
+ }
+
+ // optional int32 average_loss = 33 [default = 1];
+ if (has_average_loss()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->average_loss());
+ }
+
+ // optional int32 max_iter = 7;
+ if (has_max_iter()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->max_iter());
+ }
+
+ }
+ if (_has_bits_[16 / 32] & 16711680u) {
+ // optional int32 iter_size = 36 [default = 1];
+ if (has_iter_size()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->iter_size());
+ }
+
+ // optional string lr_policy = 8;
+ if (has_lr_policy()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->lr_policy());
+ }
+
+ // optional float gamma = 9;
+ if (has_gamma()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float power = 10;
+ if (has_power()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float momentum = 11;
+ if (has_momentum()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float weight_decay = 12;
+ if (has_weight_decay()) {
+ total_size += 1 + 4;
+ }
+
+ // optional string regularization_type = 29 [default = "L2"];
+ if (has_regularization_type()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->regularization_type());
+ }
+
+ // optional int32 stepsize = 13;
+ if (has_stepsize()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->stepsize());
+ }
+
+ }
+ if (_has_bits_[25 / 32] & 4261412864u) {
+ // optional float clip_gradients = 35 [default = -1];
+ if (has_clip_gradients()) {
+ total_size += 2 + 4;
+ }
+
+ // optional int32 snapshot = 14 [default = 0];
+ if (has_snapshot()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->snapshot());
+ }
+
+ // optional string snapshot_prefix = 15;
+ if (has_snapshot_prefix()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->snapshot_prefix());
+ }
+
+ // optional bool snapshot_diff = 16 [default = false];
+ if (has_snapshot_diff()) {
+ total_size += 2 + 1;
+ }
+
+ // optional .caffe.SolverParameter.SnapshotFormat snapshot_format = 37 [default = BINARYPROTO];
+ if (has_snapshot_format()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->snapshot_format());
+ }
+
+ // optional .caffe.SolverParameter.SolverMode solver_mode = 17 [default = GPU];
+ if (has_solver_mode()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->solver_mode());
+ }
+
+ // optional int32 device_id = 18 [default = 0];
+ if (has_device_id()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->device_id());
+ }
+
+ }
+ if (_has_bits_[32 / 32] & 255u) {
+ // optional int64 random_seed = 20 [default = -1];
+ if (has_random_seed()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::Int64Size(
+ this->random_seed());
+ }
+
+ // optional string type = 40 [default = "SGD"];
+ if (has_type()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->type());
+ }
+
+ // optional float delta = 31 [default = 1e-08];
+ if (has_delta()) {
+ total_size += 2 + 4;
+ }
+
+ // optional float momentum2 = 39 [default = 0.999];
+ if (has_momentum2()) {
+ total_size += 2 + 4;
+ }
+
+ // optional float rms_decay = 38 [default = 0.99];
+ if (has_rms_decay()) {
+ total_size += 2 + 4;
+ }
+
+ // optional bool debug_info = 23 [default = false];
+ if (has_debug_info()) {
+ total_size += 2 + 1;
+ }
+
+ // optional bool snapshot_after_train = 28 [default = true];
+ if (has_snapshot_after_train()) {
+ total_size += 2 + 1;
+ }
+
+ // optional .caffe.SolverParameter.SolverType solver_type = 30 [default = SGD];
+ if (has_solver_type()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->solver_type());
+ }
+
+ }
+ // repeated string test_net = 2;
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->test_net_size());
+ for (int i = 0; i < this->test_net_size(); i++) {
+ total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->test_net(i));
+ }
+
+ // repeated .caffe.NetParameter test_net_param = 22;
+ {
+ unsigned int count = this->test_net_param_size();
+ total_size += 2UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->test_net_param(i));
+ }
+ }
+
+ // repeated .caffe.NetState test_state = 27;
+ {
+ unsigned int count = this->test_state_size();
+ total_size += 2UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->test_state(i));
+ }
+ }
+
+ // repeated int32 test_iter = 3;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->test_iter_size();
+ for (unsigned int i = 0; i < count; i++) {
+ data_size += ::google::protobuf::internal::WireFormatLite::
+ Int32Size(this->test_iter(i));
+ }
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->test_iter_size());
+ total_size += data_size;
+ }
+
+ // repeated int32 stepvalue = 34;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->stepvalue_size();
+ for (unsigned int i = 0; i < count; i++) {
+ data_size += ::google::protobuf::internal::WireFormatLite::
+ Int32Size(this->stepvalue(i));
+ }
+ total_size += 2 *
+ ::google::protobuf::internal::FromIntSize(this->stepvalue_size());
+ total_size += data_size;
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void SolverParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.SolverParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const SolverParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const SolverParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.SolverParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.SolverParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void SolverParameter::MergeFrom(const SolverParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.SolverParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void SolverParameter::UnsafeMergeFrom(const SolverParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ test_net_.UnsafeMergeFrom(from.test_net_);
+ test_net_param_.MergeFrom(from.test_net_param_);
+ test_state_.MergeFrom(from.test_state_);
+ test_iter_.UnsafeMergeFrom(from.test_iter_);
+ stepvalue_.UnsafeMergeFrom(from.stepvalue_);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_net()) {
+ set_has_net();
+ net_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.net_);
+ }
+ if (from.has_net_param()) {
+ mutable_net_param()->::caffe::NetParameter::MergeFrom(from.net_param());
+ }
+ if (from.has_train_net()) {
+ set_has_train_net();
+ train_net_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.train_net_);
+ }
+ if (from.has_train_net_param()) {
+ mutable_train_net_param()->::caffe::NetParameter::MergeFrom(from.train_net_param());
+ }
+ if (from.has_train_state()) {
+ mutable_train_state()->::caffe::NetState::MergeFrom(from.train_state());
+ }
+ }
+ if (from._has_bits_[9 / 32] & (0xffu << (9 % 32))) {
+ if (from.has_test_interval()) {
+ set_test_interval(from.test_interval());
+ }
+ if (from.has_test_compute_loss()) {
+ set_test_compute_loss(from.test_compute_loss());
+ }
+ if (from.has_test_initialization()) {
+ set_test_initialization(from.test_initialization());
+ }
+ if (from.has_base_lr()) {
+ set_base_lr(from.base_lr());
+ }
+ if (from.has_display()) {
+ set_display(from.display());
+ }
+ if (from.has_average_loss()) {
+ set_average_loss(from.average_loss());
+ }
+ if (from.has_max_iter()) {
+ set_max_iter(from.max_iter());
+ }
+ }
+ if (from._has_bits_[16 / 32] & (0xffu << (16 % 32))) {
+ if (from.has_iter_size()) {
+ set_iter_size(from.iter_size());
+ }
+ if (from.has_lr_policy()) {
+ set_has_lr_policy();
+ lr_policy_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.lr_policy_);
+ }
+ if (from.has_gamma()) {
+ set_gamma(from.gamma());
+ }
+ if (from.has_power()) {
+ set_power(from.power());
+ }
+ if (from.has_momentum()) {
+ set_momentum(from.momentum());
+ }
+ if (from.has_weight_decay()) {
+ set_weight_decay(from.weight_decay());
+ }
+ if (from.has_regularization_type()) {
+ set_has_regularization_type();
+ regularization_type_.AssignWithDefault(_default_regularization_type_, from.regularization_type_);
+ }
+ if (from.has_stepsize()) {
+ set_stepsize(from.stepsize());
+ }
+ }
+ if (from._has_bits_[25 / 32] & (0xffu << (25 % 32))) {
+ if (from.has_clip_gradients()) {
+ set_clip_gradients(from.clip_gradients());
+ }
+ if (from.has_snapshot()) {
+ set_snapshot(from.snapshot());
+ }
+ if (from.has_snapshot_prefix()) {
+ set_has_snapshot_prefix();
+ snapshot_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.snapshot_prefix_);
+ }
+ if (from.has_snapshot_diff()) {
+ set_snapshot_diff(from.snapshot_diff());
+ }
+ if (from.has_snapshot_format()) {
+ set_snapshot_format(from.snapshot_format());
+ }
+ if (from.has_solver_mode()) {
+ set_solver_mode(from.solver_mode());
+ }
+ if (from.has_device_id()) {
+ set_device_id(from.device_id());
+ }
+ }
+ if (from._has_bits_[32 / 32] & (0xffu << (32 % 32))) {
+ if (from.has_random_seed()) {
+ set_random_seed(from.random_seed());
+ }
+ if (from.has_type()) {
+ set_has_type();
+ type_.AssignWithDefault(_default_type_, from.type_);
+ }
+ if (from.has_delta()) {
+ set_delta(from.delta());
+ }
+ if (from.has_momentum2()) {
+ set_momentum2(from.momentum2());
+ }
+ if (from.has_rms_decay()) {
+ set_rms_decay(from.rms_decay());
+ }
+ if (from.has_debug_info()) {
+ set_debug_info(from.debug_info());
+ }
+ if (from.has_snapshot_after_train()) {
+ set_snapshot_after_train(from.snapshot_after_train());
+ }
+ if (from.has_solver_type()) {
+ set_solver_type(from.solver_type());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void SolverParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.SolverParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void SolverParameter::CopyFrom(const SolverParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.SolverParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool SolverParameter::IsInitialized() const {
+
+ return true;
+}
+
+void SolverParameter::Swap(SolverParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void SolverParameter::InternalSwap(SolverParameter* other) {
+ net_.Swap(&other->net_);
+ std::swap(net_param_, other->net_param_);
+ train_net_.Swap(&other->train_net_);
+ test_net_.UnsafeArenaSwap(&other->test_net_);
+ std::swap(train_net_param_, other->train_net_param_);
+ test_net_param_.UnsafeArenaSwap(&other->test_net_param_);
+ std::swap(train_state_, other->train_state_);
+ test_state_.UnsafeArenaSwap(&other->test_state_);
+ test_iter_.UnsafeArenaSwap(&other->test_iter_);
+ std::swap(test_interval_, other->test_interval_);
+ std::swap(test_compute_loss_, other->test_compute_loss_);
+ std::swap(test_initialization_, other->test_initialization_);
+ std::swap(base_lr_, other->base_lr_);
+ std::swap(display_, other->display_);
+ std::swap(average_loss_, other->average_loss_);
+ std::swap(max_iter_, other->max_iter_);
+ std::swap(iter_size_, other->iter_size_);
+ lr_policy_.Swap(&other->lr_policy_);
+ std::swap(gamma_, other->gamma_);
+ std::swap(power_, other->power_);
+ std::swap(momentum_, other->momentum_);
+ std::swap(weight_decay_, other->weight_decay_);
+ regularization_type_.Swap(&other->regularization_type_);
+ std::swap(stepsize_, other->stepsize_);
+ stepvalue_.UnsafeArenaSwap(&other->stepvalue_);
+ std::swap(clip_gradients_, other->clip_gradients_);
+ std::swap(snapshot_, other->snapshot_);
+ snapshot_prefix_.Swap(&other->snapshot_prefix_);
+ std::swap(snapshot_diff_, other->snapshot_diff_);
+ std::swap(snapshot_format_, other->snapshot_format_);
+ std::swap(solver_mode_, other->solver_mode_);
+ std::swap(device_id_, other->device_id_);
+ std::swap(random_seed_, other->random_seed_);
+ type_.Swap(&other->type_);
+ std::swap(delta_, other->delta_);
+ std::swap(momentum2_, other->momentum2_);
+ std::swap(rms_decay_, other->rms_decay_);
+ std::swap(debug_info_, other->debug_info_);
+ std::swap(snapshot_after_train_, other->snapshot_after_train_);
+ std::swap(solver_type_, other->solver_type_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ std::swap(_has_bits_[1], other->_has_bits_[1]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata SolverParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = SolverParameter_descriptor_;
+ metadata.reflection = SolverParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// SolverParameter
+
+// optional string net = 24;
+bool SolverParameter::has_net() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void SolverParameter::set_has_net() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void SolverParameter::clear_has_net() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void SolverParameter::clear_net() {
+ net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_net();
+}
+const ::std::string& SolverParameter::net() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.net)
+ return net_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void SolverParameter::set_net(const ::std::string& value) {
+ set_has_net();
+ net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.net)
+}
+void SolverParameter::set_net(const char* value) {
+ set_has_net();
+ net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.net)
+}
+void SolverParameter::set_net(const char* value, size_t size) {
+ set_has_net();
+ net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.net)
+}
+::std::string* SolverParameter::mutable_net() {
+ set_has_net();
+ // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.net)
+ return net_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* SolverParameter::release_net() {
+ // @@protoc_insertion_point(field_release:caffe.SolverParameter.net)
+ clear_has_net();
+ return net_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void SolverParameter::set_allocated_net(::std::string* net) {
+ if (net != NULL) {
+ set_has_net();
+ } else {
+ clear_has_net();
+ }
+ net_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), net);
+ // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.net)
+}
+
+// optional .caffe.NetParameter net_param = 25;
+bool SolverParameter::has_net_param() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void SolverParameter::set_has_net_param() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void SolverParameter::clear_has_net_param() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void SolverParameter::clear_net_param() {
+ if (net_param_ != NULL) net_param_->::caffe::NetParameter::Clear();
+ clear_has_net_param();
+}
+const ::caffe::NetParameter& SolverParameter::net_param() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.net_param)
+ return net_param_ != NULL ? *net_param_
+ : *::caffe::NetParameter::internal_default_instance();
+}
+::caffe::NetParameter* SolverParameter::mutable_net_param() {
+ set_has_net_param();
+ if (net_param_ == NULL) {
+ net_param_ = new ::caffe::NetParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.net_param)
+ return net_param_;
+}
+::caffe::NetParameter* SolverParameter::release_net_param() {
+ // @@protoc_insertion_point(field_release:caffe.SolverParameter.net_param)
+ clear_has_net_param();
+ ::caffe::NetParameter* temp = net_param_;
+ net_param_ = NULL;
+ return temp;
+}
+void SolverParameter::set_allocated_net_param(::caffe::NetParameter* net_param) {
+ delete net_param_;
+ net_param_ = net_param;
+ if (net_param) {
+ set_has_net_param();
+ } else {
+ clear_has_net_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.net_param)
+}
+
+// optional string train_net = 1;
+bool SolverParameter::has_train_net() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void SolverParameter::set_has_train_net() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void SolverParameter::clear_has_train_net() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void SolverParameter::clear_train_net() {
+ train_net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_train_net();
+}
+const ::std::string& SolverParameter::train_net() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.train_net)
+ return train_net_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void SolverParameter::set_train_net(const ::std::string& value) {
+ set_has_train_net();
+ train_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.train_net)
+}
+void SolverParameter::set_train_net(const char* value) {
+ set_has_train_net();
+ train_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.train_net)
+}
+void SolverParameter::set_train_net(const char* value, size_t size) {
+ set_has_train_net();
+ train_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.train_net)
+}
+::std::string* SolverParameter::mutable_train_net() {
+ set_has_train_net();
+ // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.train_net)
+ return train_net_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* SolverParameter::release_train_net() {
+ // @@protoc_insertion_point(field_release:caffe.SolverParameter.train_net)
+ clear_has_train_net();
+ return train_net_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void SolverParameter::set_allocated_train_net(::std::string* train_net) {
+ if (train_net != NULL) {
+ set_has_train_net();
+ } else {
+ clear_has_train_net();
+ }
+ train_net_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), train_net);
+ // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.train_net)
+}
+
+// repeated string test_net = 2;
+int SolverParameter::test_net_size() const {
+ return test_net_.size();
+}
+void SolverParameter::clear_test_net() {
+ test_net_.Clear();
+}
+const ::std::string& SolverParameter::test_net(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_net)
+ return test_net_.Get(index);
+}
+::std::string* SolverParameter::mutable_test_net(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.test_net)
+ return test_net_.Mutable(index);
+}
+void SolverParameter::set_test_net(int index, const ::std::string& value) {
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_net)
+ test_net_.Mutable(index)->assign(value);
+}
+void SolverParameter::set_test_net(int index, const char* value) {
+ test_net_.Mutable(index)->assign(value);
+ // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.test_net)
+}
+void SolverParameter::set_test_net(int index, const char* value, size_t size) {
+ test_net_.Mutable(index)->assign(
+ reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.test_net)
+}
+::std::string* SolverParameter::add_test_net() {
+ // @@protoc_insertion_point(field_add_mutable:caffe.SolverParameter.test_net)
+ return test_net_.Add();
+}
+void SolverParameter::add_test_net(const ::std::string& value) {
+ test_net_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add:caffe.SolverParameter.test_net)
+}
+void SolverParameter::add_test_net(const char* value) {
+ test_net_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add_char:caffe.SolverParameter.test_net)
+}
+void SolverParameter::add_test_net(const char* value, size_t size) {
+ test_net_.Add()->assign(reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_add_pointer:caffe.SolverParameter.test_net)
+}
+const ::google::protobuf::RepeatedPtrField< ::std::string>&
+SolverParameter::test_net() const {
+ // @@protoc_insertion_point(field_list:caffe.SolverParameter.test_net)
+ return test_net_;
+}
+::google::protobuf::RepeatedPtrField< ::std::string>*
+SolverParameter::mutable_test_net() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.test_net)
+ return &test_net_;
+}
+
+// optional .caffe.NetParameter train_net_param = 21;
+bool SolverParameter::has_train_net_param() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+void SolverParameter::set_has_train_net_param() {
+ _has_bits_[0] |= 0x00000010u;
+}
+void SolverParameter::clear_has_train_net_param() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+void SolverParameter::clear_train_net_param() {
+ if (train_net_param_ != NULL) train_net_param_->::caffe::NetParameter::Clear();
+ clear_has_train_net_param();
+}
+const ::caffe::NetParameter& SolverParameter::train_net_param() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.train_net_param)
+ return train_net_param_ != NULL ? *train_net_param_
+ : *::caffe::NetParameter::internal_default_instance();
+}
+::caffe::NetParameter* SolverParameter::mutable_train_net_param() {
+ set_has_train_net_param();
+ if (train_net_param_ == NULL) {
+ train_net_param_ = new ::caffe::NetParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.train_net_param)
+ return train_net_param_;
+}
+::caffe::NetParameter* SolverParameter::release_train_net_param() {
+ // @@protoc_insertion_point(field_release:caffe.SolverParameter.train_net_param)
+ clear_has_train_net_param();
+ ::caffe::NetParameter* temp = train_net_param_;
+ train_net_param_ = NULL;
+ return temp;
+}
+void SolverParameter::set_allocated_train_net_param(::caffe::NetParameter* train_net_param) {
+ delete train_net_param_;
+ train_net_param_ = train_net_param;
+ if (train_net_param) {
+ set_has_train_net_param();
+ } else {
+ clear_has_train_net_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.train_net_param)
+}
+
+// repeated .caffe.NetParameter test_net_param = 22;
+int SolverParameter::test_net_param_size() const {
+ return test_net_param_.size();
+}
+void SolverParameter::clear_test_net_param() {
+ test_net_param_.Clear();
+}
+const ::caffe::NetParameter& SolverParameter::test_net_param(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_net_param)
+ return test_net_param_.Get(index);
+}
+::caffe::NetParameter* SolverParameter::mutable_test_net_param(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.test_net_param)
+ return test_net_param_.Mutable(index);
+}
+::caffe::NetParameter* SolverParameter::add_test_net_param() {
+ // @@protoc_insertion_point(field_add:caffe.SolverParameter.test_net_param)
+ return test_net_param_.Add();
+}
+::google::protobuf::RepeatedPtrField< ::caffe::NetParameter >*
+SolverParameter::mutable_test_net_param() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.test_net_param)
+ return &test_net_param_;
+}
+const ::google::protobuf::RepeatedPtrField< ::caffe::NetParameter >&
+SolverParameter::test_net_param() const {
+ // @@protoc_insertion_point(field_list:caffe.SolverParameter.test_net_param)
+ return test_net_param_;
+}
+
+// optional .caffe.NetState train_state = 26;
+bool SolverParameter::has_train_state() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+void SolverParameter::set_has_train_state() {
+ _has_bits_[0] |= 0x00000040u;
+}
+void SolverParameter::clear_has_train_state() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+void SolverParameter::clear_train_state() {
+ if (train_state_ != NULL) train_state_->::caffe::NetState::Clear();
+ clear_has_train_state();
+}
+const ::caffe::NetState& SolverParameter::train_state() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.train_state)
+ return train_state_ != NULL ? *train_state_
+ : *::caffe::NetState::internal_default_instance();
+}
+::caffe::NetState* SolverParameter::mutable_train_state() {
+ set_has_train_state();
+ if (train_state_ == NULL) {
+ train_state_ = new ::caffe::NetState;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.train_state)
+ return train_state_;
+}
+::caffe::NetState* SolverParameter::release_train_state() {
+ // @@protoc_insertion_point(field_release:caffe.SolverParameter.train_state)
+ clear_has_train_state();
+ ::caffe::NetState* temp = train_state_;
+ train_state_ = NULL;
+ return temp;
+}
+void SolverParameter::set_allocated_train_state(::caffe::NetState* train_state) {
+ delete train_state_;
+ train_state_ = train_state;
+ if (train_state) {
+ set_has_train_state();
+ } else {
+ clear_has_train_state();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.train_state)
+}
+
+// repeated .caffe.NetState test_state = 27;
+int SolverParameter::test_state_size() const {
+ return test_state_.size();
+}
+void SolverParameter::clear_test_state() {
+ test_state_.Clear();
+}
+const ::caffe::NetState& SolverParameter::test_state(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_state)
+ return test_state_.Get(index);
+}
+::caffe::NetState* SolverParameter::mutable_test_state(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.test_state)
+ return test_state_.Mutable(index);
+}
+::caffe::NetState* SolverParameter::add_test_state() {
+ // @@protoc_insertion_point(field_add:caffe.SolverParameter.test_state)
+ return test_state_.Add();
+}
+::google::protobuf::RepeatedPtrField< ::caffe::NetState >*
+SolverParameter::mutable_test_state() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.test_state)
+ return &test_state_;
+}
+const ::google::protobuf::RepeatedPtrField< ::caffe::NetState >&
+SolverParameter::test_state() const {
+ // @@protoc_insertion_point(field_list:caffe.SolverParameter.test_state)
+ return test_state_;
+}
+
+// repeated int32 test_iter = 3;
+int SolverParameter::test_iter_size() const {
+ return test_iter_.size();
+}
+void SolverParameter::clear_test_iter() {
+ test_iter_.Clear();
+}
+::google::protobuf::int32 SolverParameter::test_iter(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_iter)
+ return test_iter_.Get(index);
+}
+void SolverParameter::set_test_iter(int index, ::google::protobuf::int32 value) {
+ test_iter_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_iter)
+}
+void SolverParameter::add_test_iter(::google::protobuf::int32 value) {
+ test_iter_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.SolverParameter.test_iter)
+}
+const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
+SolverParameter::test_iter() const {
+ // @@protoc_insertion_point(field_list:caffe.SolverParameter.test_iter)
+ return test_iter_;
+}
+::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
+SolverParameter::mutable_test_iter() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.test_iter)
+ return &test_iter_;
+}
+
+// optional int32 test_interval = 4 [default = 0];
+bool SolverParameter::has_test_interval() const {
+ return (_has_bits_[0] & 0x00000200u) != 0;
+}
+void SolverParameter::set_has_test_interval() {
+ _has_bits_[0] |= 0x00000200u;
+}
+void SolverParameter::clear_has_test_interval() {
+ _has_bits_[0] &= ~0x00000200u;
+}
+void SolverParameter::clear_test_interval() {
+ test_interval_ = 0;
+ clear_has_test_interval();
+}
+::google::protobuf::int32 SolverParameter::test_interval() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_interval)
+ return test_interval_;
+}
+void SolverParameter::set_test_interval(::google::protobuf::int32 value) {
+ set_has_test_interval();
+ test_interval_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_interval)
+}
+
+// optional bool test_compute_loss = 19 [default = false];
+bool SolverParameter::has_test_compute_loss() const {
+ return (_has_bits_[0] & 0x00000400u) != 0;
+}
+void SolverParameter::set_has_test_compute_loss() {
+ _has_bits_[0] |= 0x00000400u;
+}
+void SolverParameter::clear_has_test_compute_loss() {
+ _has_bits_[0] &= ~0x00000400u;
+}
+void SolverParameter::clear_test_compute_loss() {
+ test_compute_loss_ = false;
+ clear_has_test_compute_loss();
+}
+bool SolverParameter::test_compute_loss() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_compute_loss)
+ return test_compute_loss_;
+}
+void SolverParameter::set_test_compute_loss(bool value) {
+ set_has_test_compute_loss();
+ test_compute_loss_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_compute_loss)
+}
+
+// optional bool test_initialization = 32 [default = true];
+bool SolverParameter::has_test_initialization() const {
+ return (_has_bits_[0] & 0x00000800u) != 0;
+}
+void SolverParameter::set_has_test_initialization() {
+ _has_bits_[0] |= 0x00000800u;
+}
+void SolverParameter::clear_has_test_initialization() {
+ _has_bits_[0] &= ~0x00000800u;
+}
+void SolverParameter::clear_test_initialization() {
+ test_initialization_ = true;
+ clear_has_test_initialization();
+}
+bool SolverParameter::test_initialization() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_initialization)
+ return test_initialization_;
+}
+void SolverParameter::set_test_initialization(bool value) {
+ set_has_test_initialization();
+ test_initialization_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_initialization)
+}
+
+// optional float base_lr = 5;
+bool SolverParameter::has_base_lr() const {
+ return (_has_bits_[0] & 0x00001000u) != 0;
+}
+void SolverParameter::set_has_base_lr() {
+ _has_bits_[0] |= 0x00001000u;
+}
+void SolverParameter::clear_has_base_lr() {
+ _has_bits_[0] &= ~0x00001000u;
+}
+void SolverParameter::clear_base_lr() {
+ base_lr_ = 0;
+ clear_has_base_lr();
+}
+float SolverParameter::base_lr() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.base_lr)
+ return base_lr_;
+}
+void SolverParameter::set_base_lr(float value) {
+ set_has_base_lr();
+ base_lr_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.base_lr)
+}
+
+// optional int32 display = 6;
+bool SolverParameter::has_display() const {
+ return (_has_bits_[0] & 0x00002000u) != 0;
+}
+void SolverParameter::set_has_display() {
+ _has_bits_[0] |= 0x00002000u;
+}
+void SolverParameter::clear_has_display() {
+ _has_bits_[0] &= ~0x00002000u;
+}
+void SolverParameter::clear_display() {
+ display_ = 0;
+ clear_has_display();
+}
+::google::protobuf::int32 SolverParameter::display() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.display)
+ return display_;
+}
+void SolverParameter::set_display(::google::protobuf::int32 value) {
+ set_has_display();
+ display_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.display)
+}
+
+// optional int32 average_loss = 33 [default = 1];
+bool SolverParameter::has_average_loss() const {
+ return (_has_bits_[0] & 0x00004000u) != 0;
+}
+void SolverParameter::set_has_average_loss() {
+ _has_bits_[0] |= 0x00004000u;
+}
+void SolverParameter::clear_has_average_loss() {
+ _has_bits_[0] &= ~0x00004000u;
+}
+void SolverParameter::clear_average_loss() {
+ average_loss_ = 1;
+ clear_has_average_loss();
+}
+::google::protobuf::int32 SolverParameter::average_loss() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.average_loss)
+ return average_loss_;
+}
+void SolverParameter::set_average_loss(::google::protobuf::int32 value) {
+ set_has_average_loss();
+ average_loss_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.average_loss)
+}
+
+// optional int32 max_iter = 7;
+bool SolverParameter::has_max_iter() const {
+ return (_has_bits_[0] & 0x00008000u) != 0;
+}
+void SolverParameter::set_has_max_iter() {
+ _has_bits_[0] |= 0x00008000u;
+}
+void SolverParameter::clear_has_max_iter() {
+ _has_bits_[0] &= ~0x00008000u;
+}
+void SolverParameter::clear_max_iter() {
+ max_iter_ = 0;
+ clear_has_max_iter();
+}
+::google::protobuf::int32 SolverParameter::max_iter() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.max_iter)
+ return max_iter_;
+}
+void SolverParameter::set_max_iter(::google::protobuf::int32 value) {
+ set_has_max_iter();
+ max_iter_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.max_iter)
+}
+
+// optional int32 iter_size = 36 [default = 1];
+bool SolverParameter::has_iter_size() const {
+ return (_has_bits_[0] & 0x00010000u) != 0;
+}
+void SolverParameter::set_has_iter_size() {
+ _has_bits_[0] |= 0x00010000u;
+}
+void SolverParameter::clear_has_iter_size() {
+ _has_bits_[0] &= ~0x00010000u;
+}
+void SolverParameter::clear_iter_size() {
+ iter_size_ = 1;
+ clear_has_iter_size();
+}
+::google::protobuf::int32 SolverParameter::iter_size() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.iter_size)
+ return iter_size_;
+}
+void SolverParameter::set_iter_size(::google::protobuf::int32 value) {
+ set_has_iter_size();
+ iter_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.iter_size)
+}
+
+// optional string lr_policy = 8;
+bool SolverParameter::has_lr_policy() const {
+ return (_has_bits_[0] & 0x00020000u) != 0;
+}
+void SolverParameter::set_has_lr_policy() {
+ _has_bits_[0] |= 0x00020000u;
+}
+void SolverParameter::clear_has_lr_policy() {
+ _has_bits_[0] &= ~0x00020000u;
+}
+void SolverParameter::clear_lr_policy() {
+ lr_policy_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_lr_policy();
+}
+const ::std::string& SolverParameter::lr_policy() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.lr_policy)
+ return lr_policy_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void SolverParameter::set_lr_policy(const ::std::string& value) {
+ set_has_lr_policy();
+ lr_policy_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.lr_policy)
+}
+void SolverParameter::set_lr_policy(const char* value) {
+ set_has_lr_policy();
+ lr_policy_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.lr_policy)
+}
+void SolverParameter::set_lr_policy(const char* value, size_t size) {
+ set_has_lr_policy();
+ lr_policy_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.lr_policy)
+}
+::std::string* SolverParameter::mutable_lr_policy() {
+ set_has_lr_policy();
+ // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.lr_policy)
+ return lr_policy_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* SolverParameter::release_lr_policy() {
+ // @@protoc_insertion_point(field_release:caffe.SolverParameter.lr_policy)
+ clear_has_lr_policy();
+ return lr_policy_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void SolverParameter::set_allocated_lr_policy(::std::string* lr_policy) {
+ if (lr_policy != NULL) {
+ set_has_lr_policy();
+ } else {
+ clear_has_lr_policy();
+ }
+ lr_policy_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), lr_policy);
+ // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.lr_policy)
+}
+
+// optional float gamma = 9;
+bool SolverParameter::has_gamma() const {
+ return (_has_bits_[0] & 0x00040000u) != 0;
+}
+void SolverParameter::set_has_gamma() {
+ _has_bits_[0] |= 0x00040000u;
+}
+void SolverParameter::clear_has_gamma() {
+ _has_bits_[0] &= ~0x00040000u;
+}
+void SolverParameter::clear_gamma() {
+ gamma_ = 0;
+ clear_has_gamma();
+}
+float SolverParameter::gamma() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.gamma)
+ return gamma_;
+}
+void SolverParameter::set_gamma(float value) {
+ set_has_gamma();
+ gamma_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.gamma)
+}
+
+// optional float power = 10;
+bool SolverParameter::has_power() const {
+ return (_has_bits_[0] & 0x00080000u) != 0;
+}
+void SolverParameter::set_has_power() {
+ _has_bits_[0] |= 0x00080000u;
+}
+void SolverParameter::clear_has_power() {
+ _has_bits_[0] &= ~0x00080000u;
+}
+void SolverParameter::clear_power() {
+ power_ = 0;
+ clear_has_power();
+}
+float SolverParameter::power() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.power)
+ return power_;
+}
+void SolverParameter::set_power(float value) {
+ set_has_power();
+ power_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.power)
+}
+
+// optional float momentum = 11;
+bool SolverParameter::has_momentum() const {
+ return (_has_bits_[0] & 0x00100000u) != 0;
+}
+void SolverParameter::set_has_momentum() {
+ _has_bits_[0] |= 0x00100000u;
+}
+void SolverParameter::clear_has_momentum() {
+ _has_bits_[0] &= ~0x00100000u;
+}
+void SolverParameter::clear_momentum() {
+ momentum_ = 0;
+ clear_has_momentum();
+}
+float SolverParameter::momentum() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.momentum)
+ return momentum_;
+}
+void SolverParameter::set_momentum(float value) {
+ set_has_momentum();
+ momentum_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.momentum)
+}
+
+// optional float weight_decay = 12;
+bool SolverParameter::has_weight_decay() const {
+ return (_has_bits_[0] & 0x00200000u) != 0;
+}
+void SolverParameter::set_has_weight_decay() {
+ _has_bits_[0] |= 0x00200000u;
+}
+void SolverParameter::clear_has_weight_decay() {
+ _has_bits_[0] &= ~0x00200000u;
+}
+void SolverParameter::clear_weight_decay() {
+ weight_decay_ = 0;
+ clear_has_weight_decay();
+}
+float SolverParameter::weight_decay() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.weight_decay)
+ return weight_decay_;
+}
+void SolverParameter::set_weight_decay(float value) {
+ set_has_weight_decay();
+ weight_decay_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.weight_decay)
+}
+
+// optional string regularization_type = 29 [default = "L2"];
+bool SolverParameter::has_regularization_type() const {
+ return (_has_bits_[0] & 0x00400000u) != 0;
+}
+void SolverParameter::set_has_regularization_type() {
+ _has_bits_[0] |= 0x00400000u;
+}
+void SolverParameter::clear_has_regularization_type() {
+ _has_bits_[0] &= ~0x00400000u;
+}
+void SolverParameter::clear_regularization_type() {
+ regularization_type_.ClearToDefaultNoArena(_default_regularization_type_);
+ clear_has_regularization_type();
+}
+const ::std::string& SolverParameter::regularization_type() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.regularization_type)
+ return regularization_type_.GetNoArena(_default_regularization_type_);
+}
+void SolverParameter::set_regularization_type(const ::std::string& value) {
+ set_has_regularization_type();
+ regularization_type_.SetNoArena(_default_regularization_type_, value);
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.regularization_type)
+}
+void SolverParameter::set_regularization_type(const char* value) {
+ set_has_regularization_type();
+ regularization_type_.SetNoArena(_default_regularization_type_, ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.regularization_type)
+}
+void SolverParameter::set_regularization_type(const char* value, size_t size) {
+ set_has_regularization_type();
+ regularization_type_.SetNoArena(_default_regularization_type_,
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.regularization_type)
+}
+::std::string* SolverParameter::mutable_regularization_type() {
+ set_has_regularization_type();
+ // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.regularization_type)
+ return regularization_type_.MutableNoArena(_default_regularization_type_);
+}
+::std::string* SolverParameter::release_regularization_type() {
+ // @@protoc_insertion_point(field_release:caffe.SolverParameter.regularization_type)
+ clear_has_regularization_type();
+ return regularization_type_.ReleaseNoArena(_default_regularization_type_);
+}
+void SolverParameter::set_allocated_regularization_type(::std::string* regularization_type) {
+ if (regularization_type != NULL) {
+ set_has_regularization_type();
+ } else {
+ clear_has_regularization_type();
+ }
+ regularization_type_.SetAllocatedNoArena(_default_regularization_type_, regularization_type);
+ // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.regularization_type)
+}
+
+// optional int32 stepsize = 13;
+bool SolverParameter::has_stepsize() const {
+ return (_has_bits_[0] & 0x00800000u) != 0;
+}
+void SolverParameter::set_has_stepsize() {
+ _has_bits_[0] |= 0x00800000u;
+}
+void SolverParameter::clear_has_stepsize() {
+ _has_bits_[0] &= ~0x00800000u;
+}
+void SolverParameter::clear_stepsize() {
+ stepsize_ = 0;
+ clear_has_stepsize();
+}
+::google::protobuf::int32 SolverParameter::stepsize() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.stepsize)
+ return stepsize_;
+}
+void SolverParameter::set_stepsize(::google::protobuf::int32 value) {
+ set_has_stepsize();
+ stepsize_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.stepsize)
+}
+
+// repeated int32 stepvalue = 34;
+int SolverParameter::stepvalue_size() const {
+ return stepvalue_.size();
+}
+void SolverParameter::clear_stepvalue() {
+ stepvalue_.Clear();
+}
+::google::protobuf::int32 SolverParameter::stepvalue(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.stepvalue)
+ return stepvalue_.Get(index);
+}
+void SolverParameter::set_stepvalue(int index, ::google::protobuf::int32 value) {
+ stepvalue_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.stepvalue)
+}
+void SolverParameter::add_stepvalue(::google::protobuf::int32 value) {
+ stepvalue_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.SolverParameter.stepvalue)
+}
+const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
+SolverParameter::stepvalue() const {
+ // @@protoc_insertion_point(field_list:caffe.SolverParameter.stepvalue)
+ return stepvalue_;
+}
+::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
+SolverParameter::mutable_stepvalue() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.stepvalue)
+ return &stepvalue_;
+}
+
+// optional float clip_gradients = 35 [default = -1];
+bool SolverParameter::has_clip_gradients() const {
+ return (_has_bits_[0] & 0x02000000u) != 0;
+}
+void SolverParameter::set_has_clip_gradients() {
+ _has_bits_[0] |= 0x02000000u;
+}
+void SolverParameter::clear_has_clip_gradients() {
+ _has_bits_[0] &= ~0x02000000u;
+}
+void SolverParameter::clear_clip_gradients() {
+ clip_gradients_ = -1;
+ clear_has_clip_gradients();
+}
+float SolverParameter::clip_gradients() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.clip_gradients)
+ return clip_gradients_;
+}
+void SolverParameter::set_clip_gradients(float value) {
+ set_has_clip_gradients();
+ clip_gradients_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.clip_gradients)
+}
+
+// optional int32 snapshot = 14 [default = 0];
+bool SolverParameter::has_snapshot() const {
+ return (_has_bits_[0] & 0x04000000u) != 0;
+}
+void SolverParameter::set_has_snapshot() {
+ _has_bits_[0] |= 0x04000000u;
+}
+void SolverParameter::clear_has_snapshot() {
+ _has_bits_[0] &= ~0x04000000u;
+}
+void SolverParameter::clear_snapshot() {
+ snapshot_ = 0;
+ clear_has_snapshot();
+}
+::google::protobuf::int32 SolverParameter::snapshot() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot)
+ return snapshot_;
+}
+void SolverParameter::set_snapshot(::google::protobuf::int32 value) {
+ set_has_snapshot();
+ snapshot_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot)
+}
+
+// optional string snapshot_prefix = 15;
+bool SolverParameter::has_snapshot_prefix() const {
+ return (_has_bits_[0] & 0x08000000u) != 0;
+}
+void SolverParameter::set_has_snapshot_prefix() {
+ _has_bits_[0] |= 0x08000000u;
+}
+void SolverParameter::clear_has_snapshot_prefix() {
+ _has_bits_[0] &= ~0x08000000u;
+}
+void SolverParameter::clear_snapshot_prefix() {
+ snapshot_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_snapshot_prefix();
+}
+const ::std::string& SolverParameter::snapshot_prefix() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot_prefix)
+ return snapshot_prefix_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void SolverParameter::set_snapshot_prefix(const ::std::string& value) {
+ set_has_snapshot_prefix();
+ snapshot_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot_prefix)
+}
+void SolverParameter::set_snapshot_prefix(const char* value) {
+ set_has_snapshot_prefix();
+ snapshot_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.snapshot_prefix)
+}
+void SolverParameter::set_snapshot_prefix(const char* value, size_t size) {
+ set_has_snapshot_prefix();
+ snapshot_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.snapshot_prefix)
+}
+::std::string* SolverParameter::mutable_snapshot_prefix() {
+ set_has_snapshot_prefix();
+ // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.snapshot_prefix)
+ return snapshot_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* SolverParameter::release_snapshot_prefix() {
+ // @@protoc_insertion_point(field_release:caffe.SolverParameter.snapshot_prefix)
+ clear_has_snapshot_prefix();
+ return snapshot_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void SolverParameter::set_allocated_snapshot_prefix(::std::string* snapshot_prefix) {
+ if (snapshot_prefix != NULL) {
+ set_has_snapshot_prefix();
+ } else {
+ clear_has_snapshot_prefix();
+ }
+ snapshot_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), snapshot_prefix);
+ // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.snapshot_prefix)
+}
+
+// optional bool snapshot_diff = 16 [default = false];
+bool SolverParameter::has_snapshot_diff() const {
+ return (_has_bits_[0] & 0x10000000u) != 0;
+}
+void SolverParameter::set_has_snapshot_diff() {
+ _has_bits_[0] |= 0x10000000u;
+}
+void SolverParameter::clear_has_snapshot_diff() {
+ _has_bits_[0] &= ~0x10000000u;
+}
+void SolverParameter::clear_snapshot_diff() {
+ snapshot_diff_ = false;
+ clear_has_snapshot_diff();
+}
+bool SolverParameter::snapshot_diff() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot_diff)
+ return snapshot_diff_;
+}
+void SolverParameter::set_snapshot_diff(bool value) {
+ set_has_snapshot_diff();
+ snapshot_diff_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot_diff)
+}
+
+// optional .caffe.SolverParameter.SnapshotFormat snapshot_format = 37 [default = BINARYPROTO];
+bool SolverParameter::has_snapshot_format() const {
+ return (_has_bits_[0] & 0x20000000u) != 0;
+}
+void SolverParameter::set_has_snapshot_format() {
+ _has_bits_[0] |= 0x20000000u;
+}
+void SolverParameter::clear_has_snapshot_format() {
+ _has_bits_[0] &= ~0x20000000u;
+}
+void SolverParameter::clear_snapshot_format() {
+ snapshot_format_ = 1;
+ clear_has_snapshot_format();
+}
+::caffe::SolverParameter_SnapshotFormat SolverParameter::snapshot_format() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot_format)
+ return static_cast< ::caffe::SolverParameter_SnapshotFormat >(snapshot_format_);
+}
+void SolverParameter::set_snapshot_format(::caffe::SolverParameter_SnapshotFormat value) {
+ assert(::caffe::SolverParameter_SnapshotFormat_IsValid(value));
+ set_has_snapshot_format();
+ snapshot_format_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot_format)
+}
+
+// optional .caffe.SolverParameter.SolverMode solver_mode = 17 [default = GPU];
+bool SolverParameter::has_solver_mode() const {
+ return (_has_bits_[0] & 0x40000000u) != 0;
+}
+void SolverParameter::set_has_solver_mode() {
+ _has_bits_[0] |= 0x40000000u;
+}
+void SolverParameter::clear_has_solver_mode() {
+ _has_bits_[0] &= ~0x40000000u;
+}
+void SolverParameter::clear_solver_mode() {
+ solver_mode_ = 1;
+ clear_has_solver_mode();
+}
+::caffe::SolverParameter_SolverMode SolverParameter::solver_mode() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.solver_mode)
+ return static_cast< ::caffe::SolverParameter_SolverMode >(solver_mode_);
+}
+void SolverParameter::set_solver_mode(::caffe::SolverParameter_SolverMode value) {
+ assert(::caffe::SolverParameter_SolverMode_IsValid(value));
+ set_has_solver_mode();
+ solver_mode_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.solver_mode)
+}
+
+// optional int32 device_id = 18 [default = 0];
+bool SolverParameter::has_device_id() const {
+ return (_has_bits_[0] & 0x80000000u) != 0;
+}
+void SolverParameter::set_has_device_id() {
+ _has_bits_[0] |= 0x80000000u;
+}
+void SolverParameter::clear_has_device_id() {
+ _has_bits_[0] &= ~0x80000000u;
+}
+void SolverParameter::clear_device_id() {
+ device_id_ = 0;
+ clear_has_device_id();
+}
+::google::protobuf::int32 SolverParameter::device_id() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.device_id)
+ return device_id_;
+}
+void SolverParameter::set_device_id(::google::protobuf::int32 value) {
+ set_has_device_id();
+ device_id_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.device_id)
+}
+
+// optional int64 random_seed = 20 [default = -1];
+bool SolverParameter::has_random_seed() const {
+ return (_has_bits_[1] & 0x00000001u) != 0;
+}
+void SolverParameter::set_has_random_seed() {
+ _has_bits_[1] |= 0x00000001u;
+}
+void SolverParameter::clear_has_random_seed() {
+ _has_bits_[1] &= ~0x00000001u;
+}
+void SolverParameter::clear_random_seed() {
+ random_seed_ = GOOGLE_LONGLONG(-1);
+ clear_has_random_seed();
+}
+::google::protobuf::int64 SolverParameter::random_seed() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.random_seed)
+ return random_seed_;
+}
+void SolverParameter::set_random_seed(::google::protobuf::int64 value) {
+ set_has_random_seed();
+ random_seed_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.random_seed)
+}
+
+// optional string type = 40 [default = "SGD"];
+bool SolverParameter::has_type() const {
+ return (_has_bits_[1] & 0x00000002u) != 0;
+}
+void SolverParameter::set_has_type() {
+ _has_bits_[1] |= 0x00000002u;
+}
+void SolverParameter::clear_has_type() {
+ _has_bits_[1] &= ~0x00000002u;
+}
+void SolverParameter::clear_type() {
+ type_.ClearToDefaultNoArena(_default_type_);
+ clear_has_type();
+}
+const ::std::string& SolverParameter::type() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.type)
+ return type_.GetNoArena(_default_type_);
+}
+void SolverParameter::set_type(const ::std::string& value) {
+ set_has_type();
+ type_.SetNoArena(_default_type_, value);
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.type)
+}
+void SolverParameter::set_type(const char* value) {
+ set_has_type();
+ type_.SetNoArena(_default_type_, ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.type)
+}
+void SolverParameter::set_type(const char* value, size_t size) {
+ set_has_type();
+ type_.SetNoArena(_default_type_,
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.type)
+}
+::std::string* SolverParameter::mutable_type() {
+ set_has_type();
+ // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.type)
+ return type_.MutableNoArena(_default_type_);
+}
+::std::string* SolverParameter::release_type() {
+ // @@protoc_insertion_point(field_release:caffe.SolverParameter.type)
+ clear_has_type();
+ return type_.ReleaseNoArena(_default_type_);
+}
+void SolverParameter::set_allocated_type(::std::string* type) {
+ if (type != NULL) {
+ set_has_type();
+ } else {
+ clear_has_type();
+ }
+ type_.SetAllocatedNoArena(_default_type_, type);
+ // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.type)
+}
+
+// optional float delta = 31 [default = 1e-08];
+bool SolverParameter::has_delta() const {
+ return (_has_bits_[1] & 0x00000004u) != 0;
+}
+void SolverParameter::set_has_delta() {
+ _has_bits_[1] |= 0x00000004u;
+}
+void SolverParameter::clear_has_delta() {
+ _has_bits_[1] &= ~0x00000004u;
+}
+void SolverParameter::clear_delta() {
+ delta_ = 1e-08f;
+ clear_has_delta();
+}
+float SolverParameter::delta() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.delta)
+ return delta_;
+}
+void SolverParameter::set_delta(float value) {
+ set_has_delta();
+ delta_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.delta)
+}
+
+// optional float momentum2 = 39 [default = 0.999];
+bool SolverParameter::has_momentum2() const {
+ return (_has_bits_[1] & 0x00000008u) != 0;
+}
+void SolverParameter::set_has_momentum2() {
+ _has_bits_[1] |= 0x00000008u;
+}
+void SolverParameter::clear_has_momentum2() {
+ _has_bits_[1] &= ~0x00000008u;
+}
+void SolverParameter::clear_momentum2() {
+ momentum2_ = 0.999f;
+ clear_has_momentum2();
+}
+float SolverParameter::momentum2() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.momentum2)
+ return momentum2_;
+}
+void SolverParameter::set_momentum2(float value) {
+ set_has_momentum2();
+ momentum2_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.momentum2)
+}
+
+// optional float rms_decay = 38 [default = 0.99];
+bool SolverParameter::has_rms_decay() const {
+ return (_has_bits_[1] & 0x00000010u) != 0;
+}
+void SolverParameter::set_has_rms_decay() {
+ _has_bits_[1] |= 0x00000010u;
+}
+void SolverParameter::clear_has_rms_decay() {
+ _has_bits_[1] &= ~0x00000010u;
+}
+void SolverParameter::clear_rms_decay() {
+ rms_decay_ = 0.99f;
+ clear_has_rms_decay();
+}
+float SolverParameter::rms_decay() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.rms_decay)
+ return rms_decay_;
+}
+void SolverParameter::set_rms_decay(float value) {
+ set_has_rms_decay();
+ rms_decay_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.rms_decay)
+}
+
+// optional bool debug_info = 23 [default = false];
+bool SolverParameter::has_debug_info() const {
+ return (_has_bits_[1] & 0x00000020u) != 0;
+}
+void SolverParameter::set_has_debug_info() {
+ _has_bits_[1] |= 0x00000020u;
+}
+void SolverParameter::clear_has_debug_info() {
+ _has_bits_[1] &= ~0x00000020u;
+}
+void SolverParameter::clear_debug_info() {
+ debug_info_ = false;
+ clear_has_debug_info();
+}
+bool SolverParameter::debug_info() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.debug_info)
+ return debug_info_;
+}
+void SolverParameter::set_debug_info(bool value) {
+ set_has_debug_info();
+ debug_info_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.debug_info)
+}
+
+// optional bool snapshot_after_train = 28 [default = true];
+bool SolverParameter::has_snapshot_after_train() const {
+ return (_has_bits_[1] & 0x00000040u) != 0;
+}
+void SolverParameter::set_has_snapshot_after_train() {
+ _has_bits_[1] |= 0x00000040u;
+}
+void SolverParameter::clear_has_snapshot_after_train() {
+ _has_bits_[1] &= ~0x00000040u;
+}
+void SolverParameter::clear_snapshot_after_train() {
+ snapshot_after_train_ = true;
+ clear_has_snapshot_after_train();
+}
+bool SolverParameter::snapshot_after_train() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot_after_train)
+ return snapshot_after_train_;
+}
+void SolverParameter::set_snapshot_after_train(bool value) {
+ set_has_snapshot_after_train();
+ snapshot_after_train_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot_after_train)
+}
+
+// optional .caffe.SolverParameter.SolverType solver_type = 30 [default = SGD];
+bool SolverParameter::has_solver_type() const {
+ return (_has_bits_[1] & 0x00000080u) != 0;
+}
+void SolverParameter::set_has_solver_type() {
+ _has_bits_[1] |= 0x00000080u;
+}
+void SolverParameter::clear_has_solver_type() {
+ _has_bits_[1] &= ~0x00000080u;
+}
+void SolverParameter::clear_solver_type() {
+ solver_type_ = 0;
+ clear_has_solver_type();
+}
+::caffe::SolverParameter_SolverType SolverParameter::solver_type() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.solver_type)
+ return static_cast< ::caffe::SolverParameter_SolverType >(solver_type_);
+}
+void SolverParameter::set_solver_type(::caffe::SolverParameter_SolverType value) {
+ assert(::caffe::SolverParameter_SolverType_IsValid(value));
+ set_has_solver_type();
+ solver_type_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.solver_type)
+}
+
+inline const SolverParameter* SolverParameter::internal_default_instance() {
+ return &SolverParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int SolverState::kIterFieldNumber;
+const int SolverState::kLearnedNetFieldNumber;
+const int SolverState::kHistoryFieldNumber;
+const int SolverState::kCurrentStepFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+SolverState::SolverState()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.SolverState)
+}
+
+void SolverState::InitAsDefaultInstance() {
+}
+
+SolverState::SolverState(const SolverState& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.SolverState)
+}
+
+void SolverState::SharedCtor() {
+ _cached_size_ = 0;
+ learned_net_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ ::memset(&iter_, 0, reinterpret_cast<char*>(¤t_step_) -
+ reinterpret_cast<char*>(&iter_) + sizeof(current_step_));
+}
+
+SolverState::~SolverState() {
+ // @@protoc_insertion_point(destructor:caffe.SolverState)
+ SharedDtor();
+}
+
+void SolverState::SharedDtor() {
+ learned_net_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+
+void SolverState::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* SolverState::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return SolverState_descriptor_;
+}
+
+const SolverState& SolverState::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<SolverState> SolverState_default_instance_;
+
+SolverState* SolverState::New(::google::protobuf::Arena* arena) const {
+ SolverState* n = new SolverState;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void SolverState::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.SolverState)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(SolverState, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<SolverState*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ if (_has_bits_[0 / 32] & 11u) {
+ ZR_(iter_, current_step_);
+ if (has_learned_net()) {
+ learned_net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ }
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ history_.Clear();
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool SolverState::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.SolverState)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional int32 iter = 1;
+ case 1: {
+ if (tag == 8) {
+ set_has_iter();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &iter_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(18)) goto parse_learned_net;
+ break;
+ }
+
+ // optional string learned_net = 2;
+ case 2: {
+ if (tag == 18) {
+ parse_learned_net:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_learned_net()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->learned_net().data(), this->learned_net().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.SolverState.learned_net");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(26)) goto parse_history;
+ break;
+ }
+
+ // repeated .caffe.BlobProto history = 3;
+ case 3: {
+ if (tag == 26) {
+ parse_history:
+ DO_(input->IncrementRecursionDepth());
+ parse_loop_history:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
+ input, add_history()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(26)) goto parse_loop_history;
+ input->UnsafeDecrementRecursionDepth();
+ if (input->ExpectTag(32)) goto parse_current_step;
+ break;
+ }
+
+ // optional int32 current_step = 4 [default = 0];
+ case 4: {
+ if (tag == 32) {
+ parse_current_step:
+ set_has_current_step();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, ¤t_step_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.SolverState)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.SolverState)
+ return false;
+#undef DO_
+}
+
+void SolverState::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.SolverState)
+ // optional int32 iter = 1;
+ if (has_iter()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->iter(), output);
+ }
+
+ // optional string learned_net = 2;
+ if (has_learned_net()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->learned_net().data(), this->learned_net().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SolverState.learned_net");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 2, this->learned_net(), output);
+ }
+
+ // repeated .caffe.BlobProto history = 3;
+ for (unsigned int i = 0, n = this->history_size(); i < n; i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 3, this->history(i), output);
+ }
+
+ // optional int32 current_step = 4 [default = 0];
+ if (has_current_step()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->current_step(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.SolverState)
+}
+
+::google::protobuf::uint8* SolverState::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.SolverState)
+ // optional int32 iter = 1;
+ if (has_iter()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->iter(), target);
+ }
+
+ // optional string learned_net = 2;
+ if (has_learned_net()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->learned_net().data(), this->learned_net().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SolverState.learned_net");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 2, this->learned_net(), target);
+ }
+
+ // repeated .caffe.BlobProto history = 3;
+ for (unsigned int i = 0, n = this->history_size(); i < n; i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 3, this->history(i), false, target);
+ }
+
+ // optional int32 current_step = 4 [default = 0];
+ if (has_current_step()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->current_step(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.SolverState)
+ return target;
+}
+
+size_t SolverState::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.SolverState)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 11u) {
+ // optional int32 iter = 1;
+ if (has_iter()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->iter());
+ }
+
+ // optional string learned_net = 2;
+ if (has_learned_net()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->learned_net());
+ }
+
+ // optional int32 current_step = 4 [default = 0];
+ if (has_current_step()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->current_step());
+ }
+
+ }
+ // repeated .caffe.BlobProto history = 3;
+ {
+ unsigned int count = this->history_size();
+ total_size += 1UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->history(i));
+ }
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void SolverState::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.SolverState)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const SolverState* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const SolverState>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.SolverState)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.SolverState)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void SolverState::MergeFrom(const SolverState& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.SolverState)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void SolverState::UnsafeMergeFrom(const SolverState& from) {
+ GOOGLE_DCHECK(&from != this);
+ history_.MergeFrom(from.history_);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_iter()) {
+ set_iter(from.iter());
+ }
+ if (from.has_learned_net()) {
+ set_has_learned_net();
+ learned_net_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.learned_net_);
+ }
+ if (from.has_current_step()) {
+ set_current_step(from.current_step());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void SolverState::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.SolverState)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void SolverState::CopyFrom(const SolverState& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.SolverState)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool SolverState::IsInitialized() const {
+
+ return true;
+}
+
+void SolverState::Swap(SolverState* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void SolverState::InternalSwap(SolverState* other) {
+ std::swap(iter_, other->iter_);
+ learned_net_.Swap(&other->learned_net_);
+ history_.UnsafeArenaSwap(&other->history_);
+ std::swap(current_step_, other->current_step_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata SolverState::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = SolverState_descriptor_;
+ metadata.reflection = SolverState_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// SolverState
+
+// optional int32 iter = 1;
+bool SolverState::has_iter() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void SolverState::set_has_iter() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void SolverState::clear_has_iter() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void SolverState::clear_iter() {
+ iter_ = 0;
+ clear_has_iter();
+}
+::google::protobuf::int32 SolverState::iter() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverState.iter)
+ return iter_;
+}
+void SolverState::set_iter(::google::protobuf::int32 value) {
+ set_has_iter();
+ iter_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverState.iter)
+}
+
+// optional string learned_net = 2;
+bool SolverState::has_learned_net() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void SolverState::set_has_learned_net() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void SolverState::clear_has_learned_net() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void SolverState::clear_learned_net() {
+ learned_net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_learned_net();
+}
+const ::std::string& SolverState::learned_net() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverState.learned_net)
+ return learned_net_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void SolverState::set_learned_net(const ::std::string& value) {
+ set_has_learned_net();
+ learned_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.SolverState.learned_net)
+}
+void SolverState::set_learned_net(const char* value) {
+ set_has_learned_net();
+ learned_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.SolverState.learned_net)
+}
+void SolverState::set_learned_net(const char* value, size_t size) {
+ set_has_learned_net();
+ learned_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.SolverState.learned_net)
+}
+::std::string* SolverState::mutable_learned_net() {
+ set_has_learned_net();
+ // @@protoc_insertion_point(field_mutable:caffe.SolverState.learned_net)
+ return learned_net_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* SolverState::release_learned_net() {
+ // @@protoc_insertion_point(field_release:caffe.SolverState.learned_net)
+ clear_has_learned_net();
+ return learned_net_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void SolverState::set_allocated_learned_net(::std::string* learned_net) {
+ if (learned_net != NULL) {
+ set_has_learned_net();
+ } else {
+ clear_has_learned_net();
+ }
+ learned_net_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), learned_net);
+ // @@protoc_insertion_point(field_set_allocated:caffe.SolverState.learned_net)
+}
+
+// repeated .caffe.BlobProto history = 3;
+int SolverState::history_size() const {
+ return history_.size();
+}
+void SolverState::clear_history() {
+ history_.Clear();
+}
+const ::caffe::BlobProto& SolverState::history(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.SolverState.history)
+ return history_.Get(index);
+}
+::caffe::BlobProto* SolverState::mutable_history(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.SolverState.history)
+ return history_.Mutable(index);
+}
+::caffe::BlobProto* SolverState::add_history() {
+ // @@protoc_insertion_point(field_add:caffe.SolverState.history)
+ return history_.Add();
+}
+::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
+SolverState::mutable_history() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.SolverState.history)
+ return &history_;
+}
+const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
+SolverState::history() const {
+ // @@protoc_insertion_point(field_list:caffe.SolverState.history)
+ return history_;
+}
+
+// optional int32 current_step = 4 [default = 0];
+bool SolverState::has_current_step() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+void SolverState::set_has_current_step() {
+ _has_bits_[0] |= 0x00000008u;
+}
+void SolverState::clear_has_current_step() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+void SolverState::clear_current_step() {
+ current_step_ = 0;
+ clear_has_current_step();
+}
+::google::protobuf::int32 SolverState::current_step() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverState.current_step)
+ return current_step_;
+}
+void SolverState::set_current_step(::google::protobuf::int32 value) {
+ set_has_current_step();
+ current_step_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverState.current_step)
+}
+
+inline const SolverState* SolverState::internal_default_instance() {
+ return &SolverState_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int NetState::kPhaseFieldNumber;
+const int NetState::kLevelFieldNumber;
+const int NetState::kStageFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+NetState::NetState()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.NetState)
+}
+
+void NetState::InitAsDefaultInstance() {
+}
+
+NetState::NetState(const NetState& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.NetState)
+}
+
+void NetState::SharedCtor() {
+ _cached_size_ = 0;
+ level_ = 0;
+ phase_ = 1;
+}
+
+NetState::~NetState() {
+ // @@protoc_insertion_point(destructor:caffe.NetState)
+ SharedDtor();
+}
+
+void NetState::SharedDtor() {
+}
+
+void NetState::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* NetState::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return NetState_descriptor_;
+}
+
+const NetState& NetState::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<NetState> NetState_default_instance_;
+
+NetState* NetState::New(::google::protobuf::Arena* arena) const {
+ NetState* n = new NetState;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void NetState::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.NetState)
+ if (_has_bits_[0 / 32] & 3u) {
+ phase_ = 1;
+ level_ = 0;
+ }
+ stage_.Clear();
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool NetState::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.NetState)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional .caffe.Phase phase = 1 [default = TEST];
+ case 1: {
+ if (tag == 8) {
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::Phase_IsValid(value)) {
+ set_phase(static_cast< ::caffe::Phase >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(1, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_level;
+ break;
+ }
+
+ // optional int32 level = 2 [default = 0];
+ case 2: {
+ if (tag == 16) {
+ parse_level:
+ set_has_level();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &level_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(26)) goto parse_stage;
+ break;
+ }
+
+ // repeated string stage = 3;
+ case 3: {
+ if (tag == 26) {
+ parse_stage:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->add_stage()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->stage(this->stage_size() - 1).data(),
+ this->stage(this->stage_size() - 1).length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.NetState.stage");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(26)) goto parse_stage;
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.NetState)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.NetState)
+ return false;
+#undef DO_
+}
+
+void NetState::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.NetState)
+ // optional .caffe.Phase phase = 1 [default = TEST];
+ if (has_phase()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 1, this->phase(), output);
+ }
+
+ // optional int32 level = 2 [default = 0];
+ if (has_level()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->level(), output);
+ }
+
+ // repeated string stage = 3;
+ for (int i = 0; i < this->stage_size(); i++) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->stage(i).data(), this->stage(i).length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.NetState.stage");
+ ::google::protobuf::internal::WireFormatLite::WriteString(
+ 3, this->stage(i), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.NetState)
+}
+
+::google::protobuf::uint8* NetState::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.NetState)
+ // optional .caffe.Phase phase = 1 [default = TEST];
+ if (has_phase()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 1, this->phase(), target);
+ }
+
+ // optional int32 level = 2 [default = 0];
+ if (has_level()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->level(), target);
+ }
+
+ // repeated string stage = 3;
+ for (int i = 0; i < this->stage_size(); i++) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->stage(i).data(), this->stage(i).length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.NetState.stage");
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteStringToArray(3, this->stage(i), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.NetState)
+ return target;
+}
+
+size_t NetState::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.NetState)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 3u) {
+ // optional .caffe.Phase phase = 1 [default = TEST];
+ if (has_phase()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->phase());
+ }
+
+ // optional int32 level = 2 [default = 0];
+ if (has_level()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->level());
+ }
+
+ }
+ // repeated string stage = 3;
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->stage_size());
+ for (int i = 0; i < this->stage_size(); i++) {
+ total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->stage(i));
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void NetState::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.NetState)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const NetState* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const NetState>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.NetState)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.NetState)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void NetState::MergeFrom(const NetState& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.NetState)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void NetState::UnsafeMergeFrom(const NetState& from) {
+ GOOGLE_DCHECK(&from != this);
+ stage_.UnsafeMergeFrom(from.stage_);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_phase()) {
+ set_phase(from.phase());
+ }
+ if (from.has_level()) {
+ set_level(from.level());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void NetState::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.NetState)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void NetState::CopyFrom(const NetState& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.NetState)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool NetState::IsInitialized() const {
+
+ return true;
+}
+
+void NetState::Swap(NetState* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void NetState::InternalSwap(NetState* other) {
+ std::swap(phase_, other->phase_);
+ std::swap(level_, other->level_);
+ stage_.UnsafeArenaSwap(&other->stage_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata NetState::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = NetState_descriptor_;
+ metadata.reflection = NetState_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// NetState
+
+// optional .caffe.Phase phase = 1 [default = TEST];
+bool NetState::has_phase() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void NetState::set_has_phase() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void NetState::clear_has_phase() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void NetState::clear_phase() {
+ phase_ = 1;
+ clear_has_phase();
+}
+::caffe::Phase NetState::phase() const {
+ // @@protoc_insertion_point(field_get:caffe.NetState.phase)
+ return static_cast< ::caffe::Phase >(phase_);
+}
+void NetState::set_phase(::caffe::Phase value) {
+ assert(::caffe::Phase_IsValid(value));
+ set_has_phase();
+ phase_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NetState.phase)
+}
+
+// optional int32 level = 2 [default = 0];
+bool NetState::has_level() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void NetState::set_has_level() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void NetState::clear_has_level() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void NetState::clear_level() {
+ level_ = 0;
+ clear_has_level();
+}
+::google::protobuf::int32 NetState::level() const {
+ // @@protoc_insertion_point(field_get:caffe.NetState.level)
+ return level_;
+}
+void NetState::set_level(::google::protobuf::int32 value) {
+ set_has_level();
+ level_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NetState.level)
+}
+
+// repeated string stage = 3;
+int NetState::stage_size() const {
+ return stage_.size();
+}
+void NetState::clear_stage() {
+ stage_.Clear();
+}
+const ::std::string& NetState::stage(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.NetState.stage)
+ return stage_.Get(index);
+}
+::std::string* NetState::mutable_stage(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.NetState.stage)
+ return stage_.Mutable(index);
+}
+void NetState::set_stage(int index, const ::std::string& value) {
+ // @@protoc_insertion_point(field_set:caffe.NetState.stage)
+ stage_.Mutable(index)->assign(value);
+}
+void NetState::set_stage(int index, const char* value) {
+ stage_.Mutable(index)->assign(value);
+ // @@protoc_insertion_point(field_set_char:caffe.NetState.stage)
+}
+void NetState::set_stage(int index, const char* value, size_t size) {
+ stage_.Mutable(index)->assign(
+ reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_set_pointer:caffe.NetState.stage)
+}
+::std::string* NetState::add_stage() {
+ // @@protoc_insertion_point(field_add_mutable:caffe.NetState.stage)
+ return stage_.Add();
+}
+void NetState::add_stage(const ::std::string& value) {
+ stage_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add:caffe.NetState.stage)
+}
+void NetState::add_stage(const char* value) {
+ stage_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add_char:caffe.NetState.stage)
+}
+void NetState::add_stage(const char* value, size_t size) {
+ stage_.Add()->assign(reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_add_pointer:caffe.NetState.stage)
+}
+const ::google::protobuf::RepeatedPtrField< ::std::string>&
+NetState::stage() const {
+ // @@protoc_insertion_point(field_list:caffe.NetState.stage)
+ return stage_;
+}
+::google::protobuf::RepeatedPtrField< ::std::string>*
+NetState::mutable_stage() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.NetState.stage)
+ return &stage_;
+}
+
+inline const NetState* NetState::internal_default_instance() {
+ return &NetState_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int NetStateRule::kPhaseFieldNumber;
+const int NetStateRule::kMinLevelFieldNumber;
+const int NetStateRule::kMaxLevelFieldNumber;
+const int NetStateRule::kStageFieldNumber;
+const int NetStateRule::kNotStageFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+NetStateRule::NetStateRule()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.NetStateRule)
+}
+
+void NetStateRule::InitAsDefaultInstance() {
+}
+
+NetStateRule::NetStateRule(const NetStateRule& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.NetStateRule)
+}
+
+void NetStateRule::SharedCtor() {
+ _cached_size_ = 0;
+ ::memset(&phase_, 0, reinterpret_cast<char*>(&max_level_) -
+ reinterpret_cast<char*>(&phase_) + sizeof(max_level_));
+}
+
+NetStateRule::~NetStateRule() {
+ // @@protoc_insertion_point(destructor:caffe.NetStateRule)
+ SharedDtor();
+}
+
+void NetStateRule::SharedDtor() {
+}
+
+void NetStateRule::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* NetStateRule::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return NetStateRule_descriptor_;
+}
+
+const NetStateRule& NetStateRule::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<NetStateRule> NetStateRule_default_instance_;
+
+NetStateRule* NetStateRule::New(::google::protobuf::Arena* arena) const {
+ NetStateRule* n = new NetStateRule;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void NetStateRule::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.NetStateRule)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(NetStateRule, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<NetStateRule*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ ZR_(phase_, max_level_);
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ stage_.Clear();
+ not_stage_.Clear();
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool NetStateRule::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.NetStateRule)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional .caffe.Phase phase = 1;
+ case 1: {
+ if (tag == 8) {
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::Phase_IsValid(value)) {
+ set_phase(static_cast< ::caffe::Phase >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(1, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_min_level;
+ break;
+ }
+
+ // optional int32 min_level = 2;
+ case 2: {
+ if (tag == 16) {
+ parse_min_level:
+ set_has_min_level();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &min_level_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(24)) goto parse_max_level;
+ break;
+ }
+
+ // optional int32 max_level = 3;
+ case 3: {
+ if (tag == 24) {
+ parse_max_level:
+ set_has_max_level();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &max_level_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(34)) goto parse_stage;
+ break;
+ }
+
+ // repeated string stage = 4;
+ case 4: {
+ if (tag == 34) {
+ parse_stage:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->add_stage()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->stage(this->stage_size() - 1).data(),
+ this->stage(this->stage_size() - 1).length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.NetStateRule.stage");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(34)) goto parse_stage;
+ if (input->ExpectTag(42)) goto parse_not_stage;
+ break;
+ }
+
+ // repeated string not_stage = 5;
+ case 5: {
+ if (tag == 42) {
+ parse_not_stage:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->add_not_stage()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->not_stage(this->not_stage_size() - 1).data(),
+ this->not_stage(this->not_stage_size() - 1).length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.NetStateRule.not_stage");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(42)) goto parse_not_stage;
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.NetStateRule)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.NetStateRule)
+ return false;
+#undef DO_
+}
+
+void NetStateRule::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.NetStateRule)
+ // optional .caffe.Phase phase = 1;
+ if (has_phase()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 1, this->phase(), output);
+ }
+
+ // optional int32 min_level = 2;
+ if (has_min_level()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->min_level(), output);
+ }
+
+ // optional int32 max_level = 3;
+ if (has_max_level()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->max_level(), output);
+ }
+
+ // repeated string stage = 4;
+ for (int i = 0; i < this->stage_size(); i++) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->stage(i).data(), this->stage(i).length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.NetStateRule.stage");
+ ::google::protobuf::internal::WireFormatLite::WriteString(
+ 4, this->stage(i), output);
+ }
+
+ // repeated string not_stage = 5;
+ for (int i = 0; i < this->not_stage_size(); i++) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->not_stage(i).data(), this->not_stage(i).length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.NetStateRule.not_stage");
+ ::google::protobuf::internal::WireFormatLite::WriteString(
+ 5, this->not_stage(i), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.NetStateRule)
+}
+
+::google::protobuf::uint8* NetStateRule::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.NetStateRule)
+ // optional .caffe.Phase phase = 1;
+ if (has_phase()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 1, this->phase(), target);
+ }
+
+ // optional int32 min_level = 2;
+ if (has_min_level()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->min_level(), target);
+ }
+
+ // optional int32 max_level = 3;
+ if (has_max_level()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->max_level(), target);
+ }
+
+ // repeated string stage = 4;
+ for (int i = 0; i < this->stage_size(); i++) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->stage(i).data(), this->stage(i).length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.NetStateRule.stage");
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteStringToArray(4, this->stage(i), target);
+ }
+
+ // repeated string not_stage = 5;
+ for (int i = 0; i < this->not_stage_size(); i++) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->not_stage(i).data(), this->not_stage(i).length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.NetStateRule.not_stage");
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteStringToArray(5, this->not_stage(i), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.NetStateRule)
+ return target;
+}
+
+size_t NetStateRule::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.NetStateRule)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 7u) {
+ // optional .caffe.Phase phase = 1;
+ if (has_phase()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->phase());
+ }
+
+ // optional int32 min_level = 2;
+ if (has_min_level()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->min_level());
+ }
+
+ // optional int32 max_level = 3;
+ if (has_max_level()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->max_level());
+ }
+
+ }
+ // repeated string stage = 4;
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->stage_size());
+ for (int i = 0; i < this->stage_size(); i++) {
+ total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->stage(i));
+ }
+
+ // repeated string not_stage = 5;
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->not_stage_size());
+ for (int i = 0; i < this->not_stage_size(); i++) {
+ total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->not_stage(i));
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void NetStateRule::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.NetStateRule)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const NetStateRule* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const NetStateRule>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.NetStateRule)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.NetStateRule)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void NetStateRule::MergeFrom(const NetStateRule& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.NetStateRule)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void NetStateRule::UnsafeMergeFrom(const NetStateRule& from) {
+ GOOGLE_DCHECK(&from != this);
+ stage_.UnsafeMergeFrom(from.stage_);
+ not_stage_.UnsafeMergeFrom(from.not_stage_);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_phase()) {
+ set_phase(from.phase());
+ }
+ if (from.has_min_level()) {
+ set_min_level(from.min_level());
+ }
+ if (from.has_max_level()) {
+ set_max_level(from.max_level());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void NetStateRule::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.NetStateRule)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void NetStateRule::CopyFrom(const NetStateRule& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.NetStateRule)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool NetStateRule::IsInitialized() const {
+
+ return true;
+}
+
+void NetStateRule::Swap(NetStateRule* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void NetStateRule::InternalSwap(NetStateRule* other) {
+ std::swap(phase_, other->phase_);
+ std::swap(min_level_, other->min_level_);
+ std::swap(max_level_, other->max_level_);
+ stage_.UnsafeArenaSwap(&other->stage_);
+ not_stage_.UnsafeArenaSwap(&other->not_stage_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata NetStateRule::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = NetStateRule_descriptor_;
+ metadata.reflection = NetStateRule_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// NetStateRule
+
+// optional .caffe.Phase phase = 1;
+bool NetStateRule::has_phase() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void NetStateRule::set_has_phase() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void NetStateRule::clear_has_phase() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void NetStateRule::clear_phase() {
+ phase_ = 0;
+ clear_has_phase();
+}
+::caffe::Phase NetStateRule::phase() const {
+ // @@protoc_insertion_point(field_get:caffe.NetStateRule.phase)
+ return static_cast< ::caffe::Phase >(phase_);
+}
+void NetStateRule::set_phase(::caffe::Phase value) {
+ assert(::caffe::Phase_IsValid(value));
+ set_has_phase();
+ phase_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NetStateRule.phase)
+}
+
+// optional int32 min_level = 2;
+bool NetStateRule::has_min_level() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void NetStateRule::set_has_min_level() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void NetStateRule::clear_has_min_level() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void NetStateRule::clear_min_level() {
+ min_level_ = 0;
+ clear_has_min_level();
+}
+::google::protobuf::int32 NetStateRule::min_level() const {
+ // @@protoc_insertion_point(field_get:caffe.NetStateRule.min_level)
+ return min_level_;
+}
+void NetStateRule::set_min_level(::google::protobuf::int32 value) {
+ set_has_min_level();
+ min_level_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NetStateRule.min_level)
+}
+
+// optional int32 max_level = 3;
+bool NetStateRule::has_max_level() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void NetStateRule::set_has_max_level() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void NetStateRule::clear_has_max_level() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void NetStateRule::clear_max_level() {
+ max_level_ = 0;
+ clear_has_max_level();
+}
+::google::protobuf::int32 NetStateRule::max_level() const {
+ // @@protoc_insertion_point(field_get:caffe.NetStateRule.max_level)
+ return max_level_;
+}
+void NetStateRule::set_max_level(::google::protobuf::int32 value) {
+ set_has_max_level();
+ max_level_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NetStateRule.max_level)
+}
+
+// repeated string stage = 4;
+int NetStateRule::stage_size() const {
+ return stage_.size();
+}
+void NetStateRule::clear_stage() {
+ stage_.Clear();
+}
+const ::std::string& NetStateRule::stage(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.NetStateRule.stage)
+ return stage_.Get(index);
+}
+::std::string* NetStateRule::mutable_stage(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.NetStateRule.stage)
+ return stage_.Mutable(index);
+}
+void NetStateRule::set_stage(int index, const ::std::string& value) {
+ // @@protoc_insertion_point(field_set:caffe.NetStateRule.stage)
+ stage_.Mutable(index)->assign(value);
+}
+void NetStateRule::set_stage(int index, const char* value) {
+ stage_.Mutable(index)->assign(value);
+ // @@protoc_insertion_point(field_set_char:caffe.NetStateRule.stage)
+}
+void NetStateRule::set_stage(int index, const char* value, size_t size) {
+ stage_.Mutable(index)->assign(
+ reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_set_pointer:caffe.NetStateRule.stage)
+}
+::std::string* NetStateRule::add_stage() {
+ // @@protoc_insertion_point(field_add_mutable:caffe.NetStateRule.stage)
+ return stage_.Add();
+}
+void NetStateRule::add_stage(const ::std::string& value) {
+ stage_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add:caffe.NetStateRule.stage)
+}
+void NetStateRule::add_stage(const char* value) {
+ stage_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add_char:caffe.NetStateRule.stage)
+}
+void NetStateRule::add_stage(const char* value, size_t size) {
+ stage_.Add()->assign(reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_add_pointer:caffe.NetStateRule.stage)
+}
+const ::google::protobuf::RepeatedPtrField< ::std::string>&
+NetStateRule::stage() const {
+ // @@protoc_insertion_point(field_list:caffe.NetStateRule.stage)
+ return stage_;
+}
+::google::protobuf::RepeatedPtrField< ::std::string>*
+NetStateRule::mutable_stage() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.NetStateRule.stage)
+ return &stage_;
+}
+
+// repeated string not_stage = 5;
+int NetStateRule::not_stage_size() const {
+ return not_stage_.size();
+}
+void NetStateRule::clear_not_stage() {
+ not_stage_.Clear();
+}
+const ::std::string& NetStateRule::not_stage(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.NetStateRule.not_stage)
+ return not_stage_.Get(index);
+}
+::std::string* NetStateRule::mutable_not_stage(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.NetStateRule.not_stage)
+ return not_stage_.Mutable(index);
+}
+void NetStateRule::set_not_stage(int index, const ::std::string& value) {
+ // @@protoc_insertion_point(field_set:caffe.NetStateRule.not_stage)
+ not_stage_.Mutable(index)->assign(value);
+}
+void NetStateRule::set_not_stage(int index, const char* value) {
+ not_stage_.Mutable(index)->assign(value);
+ // @@protoc_insertion_point(field_set_char:caffe.NetStateRule.not_stage)
+}
+void NetStateRule::set_not_stage(int index, const char* value, size_t size) {
+ not_stage_.Mutable(index)->assign(
+ reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_set_pointer:caffe.NetStateRule.not_stage)
+}
+::std::string* NetStateRule::add_not_stage() {
+ // @@protoc_insertion_point(field_add_mutable:caffe.NetStateRule.not_stage)
+ return not_stage_.Add();
+}
+void NetStateRule::add_not_stage(const ::std::string& value) {
+ not_stage_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add:caffe.NetStateRule.not_stage)
+}
+void NetStateRule::add_not_stage(const char* value) {
+ not_stage_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add_char:caffe.NetStateRule.not_stage)
+}
+void NetStateRule::add_not_stage(const char* value, size_t size) {
+ not_stage_.Add()->assign(reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_add_pointer:caffe.NetStateRule.not_stage)
+}
+const ::google::protobuf::RepeatedPtrField< ::std::string>&
+NetStateRule::not_stage() const {
+ // @@protoc_insertion_point(field_list:caffe.NetStateRule.not_stage)
+ return not_stage_;
+}
+::google::protobuf::RepeatedPtrField< ::std::string>*
+NetStateRule::mutable_not_stage() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.NetStateRule.not_stage)
+ return ¬_stage_;
+}
+
+inline const NetStateRule* NetStateRule::internal_default_instance() {
+ return &NetStateRule_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+const ::google::protobuf::EnumDescriptor* ParamSpec_DimCheckMode_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return ParamSpec_DimCheckMode_descriptor_;
+}
+bool ParamSpec_DimCheckMode_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const ParamSpec_DimCheckMode ParamSpec::STRICT;
+const ParamSpec_DimCheckMode ParamSpec::PERMISSIVE;
+const ParamSpec_DimCheckMode ParamSpec::DimCheckMode_MIN;
+const ParamSpec_DimCheckMode ParamSpec::DimCheckMode_MAX;
+const int ParamSpec::DimCheckMode_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int ParamSpec::kNameFieldNumber;
+const int ParamSpec::kShareModeFieldNumber;
+const int ParamSpec::kLrMultFieldNumber;
+const int ParamSpec::kDecayMultFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+ParamSpec::ParamSpec()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.ParamSpec)
+}
+
+void ParamSpec::InitAsDefaultInstance() {
+}
+
+ParamSpec::ParamSpec(const ParamSpec& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.ParamSpec)
+}
+
+void ParamSpec::SharedCtor() {
+ _cached_size_ = 0;
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ share_mode_ = 0;
+ lr_mult_ = 1;
+ decay_mult_ = 1;
+}
+
+ParamSpec::~ParamSpec() {
+ // @@protoc_insertion_point(destructor:caffe.ParamSpec)
+ SharedDtor();
+}
+
+void ParamSpec::SharedDtor() {
+ name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+
+void ParamSpec::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* ParamSpec::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return ParamSpec_descriptor_;
+}
+
+const ParamSpec& ParamSpec::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<ParamSpec> ParamSpec_default_instance_;
+
+ParamSpec* ParamSpec::New(::google::protobuf::Arena* arena) const {
+ ParamSpec* n = new ParamSpec;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void ParamSpec::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.ParamSpec)
+ if (_has_bits_[0 / 32] & 15u) {
+ if (has_name()) {
+ name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ share_mode_ = 0;
+ lr_mult_ = 1;
+ decay_mult_ = 1;
+ }
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool ParamSpec::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.ParamSpec)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional string name = 1;
+ case 1: {
+ if (tag == 10) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_name()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->name().data(), this->name().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.ParamSpec.name");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_share_mode;
+ break;
+ }
+
+ // optional .caffe.ParamSpec.DimCheckMode share_mode = 2;
+ case 2: {
+ if (tag == 16) {
+ parse_share_mode:
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::ParamSpec_DimCheckMode_IsValid(value)) {
+ set_share_mode(static_cast< ::caffe::ParamSpec_DimCheckMode >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(2, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(29)) goto parse_lr_mult;
+ break;
+ }
+
+ // optional float lr_mult = 3 [default = 1];
+ case 3: {
+ if (tag == 29) {
+ parse_lr_mult:
+ set_has_lr_mult();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &lr_mult_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(37)) goto parse_decay_mult;
+ break;
+ }
+
+ // optional float decay_mult = 4 [default = 1];
+ case 4: {
+ if (tag == 37) {
+ parse_decay_mult:
+ set_has_decay_mult();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &decay_mult_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.ParamSpec)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.ParamSpec)
+ return false;
+#undef DO_
+}
+
+void ParamSpec::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.ParamSpec)
+ // optional string name = 1;
+ if (has_name()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->name().data(), this->name().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.ParamSpec.name");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 1, this->name(), output);
+ }
+
+ // optional .caffe.ParamSpec.DimCheckMode share_mode = 2;
+ if (has_share_mode()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 2, this->share_mode(), output);
+ }
+
+ // optional float lr_mult = 3 [default = 1];
+ if (has_lr_mult()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->lr_mult(), output);
+ }
+
+ // optional float decay_mult = 4 [default = 1];
+ if (has_decay_mult()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(4, this->decay_mult(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.ParamSpec)
+}
+
+::google::protobuf::uint8* ParamSpec::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.ParamSpec)
+ // optional string name = 1;
+ if (has_name()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->name().data(), this->name().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.ParamSpec.name");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 1, this->name(), target);
+ }
+
+ // optional .caffe.ParamSpec.DimCheckMode share_mode = 2;
+ if (has_share_mode()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 2, this->share_mode(), target);
+ }
+
+ // optional float lr_mult = 3 [default = 1];
+ if (has_lr_mult()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->lr_mult(), target);
+ }
+
+ // optional float decay_mult = 4 [default = 1];
+ if (has_decay_mult()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(4, this->decay_mult(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.ParamSpec)
+ return target;
+}
+
+size_t ParamSpec::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.ParamSpec)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 15u) {
+ // optional string name = 1;
+ if (has_name()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->name());
+ }
+
+ // optional .caffe.ParamSpec.DimCheckMode share_mode = 2;
+ if (has_share_mode()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->share_mode());
+ }
+
+ // optional float lr_mult = 3 [default = 1];
+ if (has_lr_mult()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float decay_mult = 4 [default = 1];
+ if (has_decay_mult()) {
+ total_size += 1 + 4;
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void ParamSpec::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.ParamSpec)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const ParamSpec* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const ParamSpec>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ParamSpec)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ParamSpec)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void ParamSpec::MergeFrom(const ParamSpec& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ParamSpec)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void ParamSpec::UnsafeMergeFrom(const ParamSpec& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_name()) {
+ set_has_name();
+ name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
+ }
+ if (from.has_share_mode()) {
+ set_share_mode(from.share_mode());
+ }
+ if (from.has_lr_mult()) {
+ set_lr_mult(from.lr_mult());
+ }
+ if (from.has_decay_mult()) {
+ set_decay_mult(from.decay_mult());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void ParamSpec::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.ParamSpec)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void ParamSpec::CopyFrom(const ParamSpec& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ParamSpec)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool ParamSpec::IsInitialized() const {
+
+ return true;
+}
+
+void ParamSpec::Swap(ParamSpec* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void ParamSpec::InternalSwap(ParamSpec* other) {
+ name_.Swap(&other->name_);
+ std::swap(share_mode_, other->share_mode_);
+ std::swap(lr_mult_, other->lr_mult_);
+ std::swap(decay_mult_, other->decay_mult_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata ParamSpec::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = ParamSpec_descriptor_;
+ metadata.reflection = ParamSpec_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// ParamSpec
+
+// optional string name = 1;
+bool ParamSpec::has_name() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void ParamSpec::set_has_name() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void ParamSpec::clear_has_name() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void ParamSpec::clear_name() {
+ name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_name();
+}
+const ::std::string& ParamSpec::name() const {
+ // @@protoc_insertion_point(field_get:caffe.ParamSpec.name)
+ return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void ParamSpec::set_name(const ::std::string& value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.ParamSpec.name)
+}
+void ParamSpec::set_name(const char* value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.ParamSpec.name)
+}
+void ParamSpec::set_name(const char* value, size_t size) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.ParamSpec.name)
+}
+::std::string* ParamSpec::mutable_name() {
+ set_has_name();
+ // @@protoc_insertion_point(field_mutable:caffe.ParamSpec.name)
+ return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* ParamSpec::release_name() {
+ // @@protoc_insertion_point(field_release:caffe.ParamSpec.name)
+ clear_has_name();
+ return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void ParamSpec::set_allocated_name(::std::string* name) {
+ if (name != NULL) {
+ set_has_name();
+ } else {
+ clear_has_name();
+ }
+ name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
+ // @@protoc_insertion_point(field_set_allocated:caffe.ParamSpec.name)
+}
+
+// optional .caffe.ParamSpec.DimCheckMode share_mode = 2;
+bool ParamSpec::has_share_mode() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void ParamSpec::set_has_share_mode() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void ParamSpec::clear_has_share_mode() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void ParamSpec::clear_share_mode() {
+ share_mode_ = 0;
+ clear_has_share_mode();
+}
+::caffe::ParamSpec_DimCheckMode ParamSpec::share_mode() const {
+ // @@protoc_insertion_point(field_get:caffe.ParamSpec.share_mode)
+ return static_cast< ::caffe::ParamSpec_DimCheckMode >(share_mode_);
+}
+void ParamSpec::set_share_mode(::caffe::ParamSpec_DimCheckMode value) {
+ assert(::caffe::ParamSpec_DimCheckMode_IsValid(value));
+ set_has_share_mode();
+ share_mode_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ParamSpec.share_mode)
+}
+
+// optional float lr_mult = 3 [default = 1];
+bool ParamSpec::has_lr_mult() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void ParamSpec::set_has_lr_mult() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void ParamSpec::clear_has_lr_mult() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void ParamSpec::clear_lr_mult() {
+ lr_mult_ = 1;
+ clear_has_lr_mult();
+}
+float ParamSpec::lr_mult() const {
+ // @@protoc_insertion_point(field_get:caffe.ParamSpec.lr_mult)
+ return lr_mult_;
+}
+void ParamSpec::set_lr_mult(float value) {
+ set_has_lr_mult();
+ lr_mult_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ParamSpec.lr_mult)
+}
+
+// optional float decay_mult = 4 [default = 1];
+bool ParamSpec::has_decay_mult() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+void ParamSpec::set_has_decay_mult() {
+ _has_bits_[0] |= 0x00000008u;
+}
+void ParamSpec::clear_has_decay_mult() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+void ParamSpec::clear_decay_mult() {
+ decay_mult_ = 1;
+ clear_has_decay_mult();
+}
+float ParamSpec::decay_mult() const {
+ // @@protoc_insertion_point(field_get:caffe.ParamSpec.decay_mult)
+ return decay_mult_;
+}
+void ParamSpec::set_decay_mult(float value) {
+ set_has_decay_mult();
+ decay_mult_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ParamSpec.decay_mult)
+}
+
+inline const ParamSpec* ParamSpec::internal_default_instance() {
+ return &ParamSpec_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int LayerParameter::kNameFieldNumber;
+const int LayerParameter::kTypeFieldNumber;
+const int LayerParameter::kBottomFieldNumber;
+const int LayerParameter::kTopFieldNumber;
+const int LayerParameter::kPhaseFieldNumber;
+const int LayerParameter::kLossWeightFieldNumber;
+const int LayerParameter::kParamFieldNumber;
+const int LayerParameter::kBlobsFieldNumber;
+const int LayerParameter::kPropagateDownFieldNumber;
+const int LayerParameter::kIncludeFieldNumber;
+const int LayerParameter::kExcludeFieldNumber;
+const int LayerParameter::kTransformParamFieldNumber;
+const int LayerParameter::kLossParamFieldNumber;
+const int LayerParameter::kAccuracyParamFieldNumber;
+const int LayerParameter::kArgmaxParamFieldNumber;
+const int LayerParameter::kBatchNormParamFieldNumber;
+const int LayerParameter::kBiasParamFieldNumber;
+const int LayerParameter::kConcatParamFieldNumber;
+const int LayerParameter::kContrastiveLossParamFieldNumber;
+const int LayerParameter::kConvolutionParamFieldNumber;
+const int LayerParameter::kCropParamFieldNumber;
+const int LayerParameter::kDataParamFieldNumber;
+const int LayerParameter::kDetectionOutputParamFieldNumber;
+const int LayerParameter::kDropoutParamFieldNumber;
+const int LayerParameter::kDummyDataParamFieldNumber;
+const int LayerParameter::kEltwiseParamFieldNumber;
+const int LayerParameter::kEluParamFieldNumber;
+const int LayerParameter::kEmbedParamFieldNumber;
+const int LayerParameter::kExpParamFieldNumber;
+const int LayerParameter::kFlattenParamFieldNumber;
+const int LayerParameter::kHdf5DataParamFieldNumber;
+const int LayerParameter::kHdf5OutputParamFieldNumber;
+const int LayerParameter::kHingeLossParamFieldNumber;
+const int LayerParameter::kImageDataParamFieldNumber;
+const int LayerParameter::kInfogainLossParamFieldNumber;
+const int LayerParameter::kInnerProductParamFieldNumber;
+const int LayerParameter::kInputParamFieldNumber;
+const int LayerParameter::kLogParamFieldNumber;
+const int LayerParameter::kLrnParamFieldNumber;
+const int LayerParameter::kMemoryDataParamFieldNumber;
+const int LayerParameter::kMvnParamFieldNumber;
+const int LayerParameter::kNormParamFieldNumber;
+const int LayerParameter::kPermuteParamFieldNumber;
+const int LayerParameter::kParameterParamFieldNumber;
+const int LayerParameter::kPoolingParamFieldNumber;
+const int LayerParameter::kPowerParamFieldNumber;
+const int LayerParameter::kPreluParamFieldNumber;
+const int LayerParameter::kPriorBoxParamFieldNumber;
+const int LayerParameter::kPythonParamFieldNumber;
+const int LayerParameter::kRecurrentParamFieldNumber;
+const int LayerParameter::kReductionParamFieldNumber;
+const int LayerParameter::kReluParamFieldNumber;
+const int LayerParameter::kReshapeParamFieldNumber;
+const int LayerParameter::kScaleParamFieldNumber;
+const int LayerParameter::kSigmoidParamFieldNumber;
+const int LayerParameter::kSoftmaxParamFieldNumber;
+const int LayerParameter::kSppParamFieldNumber;
+const int LayerParameter::kSliceParamFieldNumber;
+const int LayerParameter::kTanhParamFieldNumber;
+const int LayerParameter::kThresholdParamFieldNumber;
+const int LayerParameter::kTileParamFieldNumber;
+const int LayerParameter::kWindowDataParamFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+LayerParameter::LayerParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.LayerParameter)
+}
+
+void LayerParameter::InitAsDefaultInstance() {
+ transform_param_ = const_cast< ::caffe::TransformationParameter*>(
+ ::caffe::TransformationParameter::internal_default_instance());
+ loss_param_ = const_cast< ::caffe::LossParameter*>(
+ ::caffe::LossParameter::internal_default_instance());
+ accuracy_param_ = const_cast< ::caffe::AccuracyParameter*>(
+ ::caffe::AccuracyParameter::internal_default_instance());
+ argmax_param_ = const_cast< ::caffe::ArgMaxParameter*>(
+ ::caffe::ArgMaxParameter::internal_default_instance());
+ batch_norm_param_ = const_cast< ::caffe::BatchNormParameter*>(
+ ::caffe::BatchNormParameter::internal_default_instance());
+ bias_param_ = const_cast< ::caffe::BiasParameter*>(
+ ::caffe::BiasParameter::internal_default_instance());
+ concat_param_ = const_cast< ::caffe::ConcatParameter*>(
+ ::caffe::ConcatParameter::internal_default_instance());
+ contrastive_loss_param_ = const_cast< ::caffe::ContrastiveLossParameter*>(
+ ::caffe::ContrastiveLossParameter::internal_default_instance());
+ convolution_param_ = const_cast< ::caffe::ConvolutionParameter*>(
+ ::caffe::ConvolutionParameter::internal_default_instance());
+ crop_param_ = const_cast< ::caffe::CropParameter*>(
+ ::caffe::CropParameter::internal_default_instance());
+ data_param_ = const_cast< ::caffe::DataParameter*>(
+ ::caffe::DataParameter::internal_default_instance());
+ detection_output_param_ = const_cast< ::caffe::DetectionOutputParameter*>(
+ ::caffe::DetectionOutputParameter::internal_default_instance());
+ dropout_param_ = const_cast< ::caffe::DropoutParameter*>(
+ ::caffe::DropoutParameter::internal_default_instance());
+ dummy_data_param_ = const_cast< ::caffe::DummyDataParameter*>(
+ ::caffe::DummyDataParameter::internal_default_instance());
+ eltwise_param_ = const_cast< ::caffe::EltwiseParameter*>(
+ ::caffe::EltwiseParameter::internal_default_instance());
+ elu_param_ = const_cast< ::caffe::ELUParameter*>(
+ ::caffe::ELUParameter::internal_default_instance());
+ embed_param_ = const_cast< ::caffe::EmbedParameter*>(
+ ::caffe::EmbedParameter::internal_default_instance());
+ exp_param_ = const_cast< ::caffe::ExpParameter*>(
+ ::caffe::ExpParameter::internal_default_instance());
+ flatten_param_ = const_cast< ::caffe::FlattenParameter*>(
+ ::caffe::FlattenParameter::internal_default_instance());
+ hdf5_data_param_ = const_cast< ::caffe::HDF5DataParameter*>(
+ ::caffe::HDF5DataParameter::internal_default_instance());
+ hdf5_output_param_ = const_cast< ::caffe::HDF5OutputParameter*>(
+ ::caffe::HDF5OutputParameter::internal_default_instance());
+ hinge_loss_param_ = const_cast< ::caffe::HingeLossParameter*>(
+ ::caffe::HingeLossParameter::internal_default_instance());
+ image_data_param_ = const_cast< ::caffe::ImageDataParameter*>(
+ ::caffe::ImageDataParameter::internal_default_instance());
+ infogain_loss_param_ = const_cast< ::caffe::InfogainLossParameter*>(
+ ::caffe::InfogainLossParameter::internal_default_instance());
+ inner_product_param_ = const_cast< ::caffe::InnerProductParameter*>(
+ ::caffe::InnerProductParameter::internal_default_instance());
+ input_param_ = const_cast< ::caffe::InputParameter*>(
+ ::caffe::InputParameter::internal_default_instance());
+ log_param_ = const_cast< ::caffe::LogParameter*>(
+ ::caffe::LogParameter::internal_default_instance());
+ lrn_param_ = const_cast< ::caffe::LRNParameter*>(
+ ::caffe::LRNParameter::internal_default_instance());
+ memory_data_param_ = const_cast< ::caffe::MemoryDataParameter*>(
+ ::caffe::MemoryDataParameter::internal_default_instance());
+ mvn_param_ = const_cast< ::caffe::MVNParameter*>(
+ ::caffe::MVNParameter::internal_default_instance());
+ norm_param_ = const_cast< ::caffe::NormalizeBBoxParameter*>(
+ ::caffe::NormalizeBBoxParameter::internal_default_instance());
+ permute_param_ = const_cast< ::caffe::PermuteParameter*>(
+ ::caffe::PermuteParameter::internal_default_instance());
+ parameter_param_ = const_cast< ::caffe::ParameterParameter*>(
+ ::caffe::ParameterParameter::internal_default_instance());
+ pooling_param_ = const_cast< ::caffe::PoolingParameter*>(
+ ::caffe::PoolingParameter::internal_default_instance());
+ power_param_ = const_cast< ::caffe::PowerParameter*>(
+ ::caffe::PowerParameter::internal_default_instance());
+ prelu_param_ = const_cast< ::caffe::PReLUParameter*>(
+ ::caffe::PReLUParameter::internal_default_instance());
+ prior_box_param_ = const_cast< ::caffe::PriorBoxParameter*>(
+ ::caffe::PriorBoxParameter::internal_default_instance());
+ python_param_ = const_cast< ::caffe::PythonParameter*>(
+ ::caffe::PythonParameter::internal_default_instance());
+ recurrent_param_ = const_cast< ::caffe::RecurrentParameter*>(
+ ::caffe::RecurrentParameter::internal_default_instance());
+ reduction_param_ = const_cast< ::caffe::ReductionParameter*>(
+ ::caffe::ReductionParameter::internal_default_instance());
+ relu_param_ = const_cast< ::caffe::ReLUParameter*>(
+ ::caffe::ReLUParameter::internal_default_instance());
+ reshape_param_ = const_cast< ::caffe::ReshapeParameter*>(
+ ::caffe::ReshapeParameter::internal_default_instance());
+ scale_param_ = const_cast< ::caffe::ScaleParameter*>(
+ ::caffe::ScaleParameter::internal_default_instance());
+ sigmoid_param_ = const_cast< ::caffe::SigmoidParameter*>(
+ ::caffe::SigmoidParameter::internal_default_instance());
+ softmax_param_ = const_cast< ::caffe::SoftmaxParameter*>(
+ ::caffe::SoftmaxParameter::internal_default_instance());
+ spp_param_ = const_cast< ::caffe::SPPParameter*>(
+ ::caffe::SPPParameter::internal_default_instance());
+ slice_param_ = const_cast< ::caffe::SliceParameter*>(
+ ::caffe::SliceParameter::internal_default_instance());
+ tanh_param_ = const_cast< ::caffe::TanHParameter*>(
+ ::caffe::TanHParameter::internal_default_instance());
+ threshold_param_ = const_cast< ::caffe::ThresholdParameter*>(
+ ::caffe::ThresholdParameter::internal_default_instance());
+ tile_param_ = const_cast< ::caffe::TileParameter*>(
+ ::caffe::TileParameter::internal_default_instance());
+ window_data_param_ = const_cast< ::caffe::WindowDataParameter*>(
+ ::caffe::WindowDataParameter::internal_default_instance());
+}
+
+LayerParameter::LayerParameter(const LayerParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.LayerParameter)
+}
+
+void LayerParameter::SharedCtor() {
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ transform_param_ = NULL;
+ loss_param_ = NULL;
+ accuracy_param_ = NULL;
+ argmax_param_ = NULL;
+ batch_norm_param_ = NULL;
+ bias_param_ = NULL;
+ concat_param_ = NULL;
+ contrastive_loss_param_ = NULL;
+ convolution_param_ = NULL;
+ crop_param_ = NULL;
+ data_param_ = NULL;
+ detection_output_param_ = NULL;
+ dropout_param_ = NULL;
+ dummy_data_param_ = NULL;
+ eltwise_param_ = NULL;
+ elu_param_ = NULL;
+ embed_param_ = NULL;
+ exp_param_ = NULL;
+ flatten_param_ = NULL;
+ hdf5_data_param_ = NULL;
+ hdf5_output_param_ = NULL;
+ hinge_loss_param_ = NULL;
+ image_data_param_ = NULL;
+ infogain_loss_param_ = NULL;
+ inner_product_param_ = NULL;
+ input_param_ = NULL;
+ log_param_ = NULL;
+ lrn_param_ = NULL;
+ memory_data_param_ = NULL;
+ mvn_param_ = NULL;
+ norm_param_ = NULL;
+ permute_param_ = NULL;
+ parameter_param_ = NULL;
+ pooling_param_ = NULL;
+ power_param_ = NULL;
+ prelu_param_ = NULL;
+ prior_box_param_ = NULL;
+ python_param_ = NULL;
+ recurrent_param_ = NULL;
+ reduction_param_ = NULL;
+ relu_param_ = NULL;
+ reshape_param_ = NULL;
+ scale_param_ = NULL;
+ sigmoid_param_ = NULL;
+ softmax_param_ = NULL;
+ spp_param_ = NULL;
+ slice_param_ = NULL;
+ tanh_param_ = NULL;
+ threshold_param_ = NULL;
+ tile_param_ = NULL;
+ window_data_param_ = NULL;
+ phase_ = 0;
+ _cached_size_ = 0;
+}
+
+LayerParameter::~LayerParameter() {
+ // @@protoc_insertion_point(destructor:caffe.LayerParameter)
+ SharedDtor();
+}
+
+void LayerParameter::SharedDtor() {
+ name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ type_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (this != &LayerParameter_default_instance_.get()) {
+ delete transform_param_;
+ delete loss_param_;
+ delete accuracy_param_;
+ delete argmax_param_;
+ delete batch_norm_param_;
+ delete bias_param_;
+ delete concat_param_;
+ delete contrastive_loss_param_;
+ delete convolution_param_;
+ delete crop_param_;
+ delete data_param_;
+ delete detection_output_param_;
+ delete dropout_param_;
+ delete dummy_data_param_;
+ delete eltwise_param_;
+ delete elu_param_;
+ delete embed_param_;
+ delete exp_param_;
+ delete flatten_param_;
+ delete hdf5_data_param_;
+ delete hdf5_output_param_;
+ delete hinge_loss_param_;
+ delete image_data_param_;
+ delete infogain_loss_param_;
+ delete inner_product_param_;
+ delete input_param_;
+ delete log_param_;
+ delete lrn_param_;
+ delete memory_data_param_;
+ delete mvn_param_;
+ delete norm_param_;
+ delete permute_param_;
+ delete parameter_param_;
+ delete pooling_param_;
+ delete power_param_;
+ delete prelu_param_;
+ delete prior_box_param_;
+ delete python_param_;
+ delete recurrent_param_;
+ delete reduction_param_;
+ delete relu_param_;
+ delete reshape_param_;
+ delete scale_param_;
+ delete sigmoid_param_;
+ delete softmax_param_;
+ delete spp_param_;
+ delete slice_param_;
+ delete tanh_param_;
+ delete threshold_param_;
+ delete tile_param_;
+ delete window_data_param_;
+ }
+}
+
+void LayerParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* LayerParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return LayerParameter_descriptor_;
+}
+
+const LayerParameter& LayerParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<LayerParameter> LayerParameter_default_instance_;
+
+LayerParameter* LayerParameter::New(::google::protobuf::Arena* arena) const {
+ LayerParameter* n = new LayerParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void LayerParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.LayerParameter)
+ if (_has_bits_[0 / 32] & 19u) {
+ if (has_name()) {
+ name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ if (has_type()) {
+ type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ phase_ = 0;
+ }
+ if (_has_bits_[8 / 32] & 63488u) {
+ if (has_transform_param()) {
+ if (transform_param_ != NULL) transform_param_->::caffe::TransformationParameter::Clear();
+ }
+ if (has_loss_param()) {
+ if (loss_param_ != NULL) loss_param_->::caffe::LossParameter::Clear();
+ }
+ if (has_accuracy_param()) {
+ if (accuracy_param_ != NULL) accuracy_param_->::caffe::AccuracyParameter::Clear();
+ }
+ if (has_argmax_param()) {
+ if (argmax_param_ != NULL) argmax_param_->::caffe::ArgMaxParameter::Clear();
+ }
+ if (has_batch_norm_param()) {
+ if (batch_norm_param_ != NULL) batch_norm_param_->::caffe::BatchNormParameter::Clear();
+ }
+ }
+ if (_has_bits_[16 / 32] & 16711680u) {
+ if (has_bias_param()) {
+ if (bias_param_ != NULL) bias_param_->::caffe::BiasParameter::Clear();
+ }
+ if (has_concat_param()) {
+ if (concat_param_ != NULL) concat_param_->::caffe::ConcatParameter::Clear();
+ }
+ if (has_contrastive_loss_param()) {
+ if (contrastive_loss_param_ != NULL) contrastive_loss_param_->::caffe::ContrastiveLossParameter::Clear();
+ }
+ if (has_convolution_param()) {
+ if (convolution_param_ != NULL) convolution_param_->::caffe::ConvolutionParameter::Clear();
+ }
+ if (has_crop_param()) {
+ if (crop_param_ != NULL) crop_param_->::caffe::CropParameter::Clear();
+ }
+ if (has_data_param()) {
+ if (data_param_ != NULL) data_param_->::caffe::DataParameter::Clear();
+ }
+ if (has_detection_output_param()) {
+ if (detection_output_param_ != NULL) detection_output_param_->::caffe::DetectionOutputParameter::Clear();
+ }
+ if (has_dropout_param()) {
+ if (dropout_param_ != NULL) dropout_param_->::caffe::DropoutParameter::Clear();
+ }
+ }
+ if (_has_bits_[24 / 32] & 4278190080u) {
+ if (has_dummy_data_param()) {
+ if (dummy_data_param_ != NULL) dummy_data_param_->::caffe::DummyDataParameter::Clear();
+ }
+ if (has_eltwise_param()) {
+ if (eltwise_param_ != NULL) eltwise_param_->::caffe::EltwiseParameter::Clear();
+ }
+ if (has_elu_param()) {
+ if (elu_param_ != NULL) elu_param_->::caffe::ELUParameter::Clear();
+ }
+ if (has_embed_param()) {
+ if (embed_param_ != NULL) embed_param_->::caffe::EmbedParameter::Clear();
+ }
+ if (has_exp_param()) {
+ if (exp_param_ != NULL) exp_param_->::caffe::ExpParameter::Clear();
+ }
+ if (has_flatten_param()) {
+ if (flatten_param_ != NULL) flatten_param_->::caffe::FlattenParameter::Clear();
+ }
+ if (has_hdf5_data_param()) {
+ if (hdf5_data_param_ != NULL) hdf5_data_param_->::caffe::HDF5DataParameter::Clear();
+ }
+ if (has_hdf5_output_param()) {
+ if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear();
+ }
+ }
+ if (_has_bits_[32 / 32] & 255u) {
+ if (has_hinge_loss_param()) {
+ if (hinge_loss_param_ != NULL) hinge_loss_param_->::caffe::HingeLossParameter::Clear();
+ }
+ if (has_image_data_param()) {
+ if (image_data_param_ != NULL) image_data_param_->::caffe::ImageDataParameter::Clear();
+ }
+ if (has_infogain_loss_param()) {
+ if (infogain_loss_param_ != NULL) infogain_loss_param_->::caffe::InfogainLossParameter::Clear();
+ }
+ if (has_inner_product_param()) {
+ if (inner_product_param_ != NULL) inner_product_param_->::caffe::InnerProductParameter::Clear();
+ }
+ if (has_input_param()) {
+ if (input_param_ != NULL) input_param_->::caffe::InputParameter::Clear();
+ }
+ if (has_log_param()) {
+ if (log_param_ != NULL) log_param_->::caffe::LogParameter::Clear();
+ }
+ if (has_lrn_param()) {
+ if (lrn_param_ != NULL) lrn_param_->::caffe::LRNParameter::Clear();
+ }
+ if (has_memory_data_param()) {
+ if (memory_data_param_ != NULL) memory_data_param_->::caffe::MemoryDataParameter::Clear();
+ }
+ }
+ if (_has_bits_[40 / 32] & 65280u) {
+ if (has_mvn_param()) {
+ if (mvn_param_ != NULL) mvn_param_->::caffe::MVNParameter::Clear();
+ }
+ if (has_norm_param()) {
+ if (norm_param_ != NULL) norm_param_->::caffe::NormalizeBBoxParameter::Clear();
+ }
+ if (has_permute_param()) {
+ if (permute_param_ != NULL) permute_param_->::caffe::PermuteParameter::Clear();
+ }
+ if (has_parameter_param()) {
+ if (parameter_param_ != NULL) parameter_param_->::caffe::ParameterParameter::Clear();
+ }
+ if (has_pooling_param()) {
+ if (pooling_param_ != NULL) pooling_param_->::caffe::PoolingParameter::Clear();
+ }
+ if (has_power_param()) {
+ if (power_param_ != NULL) power_param_->::caffe::PowerParameter::Clear();
+ }
+ if (has_prelu_param()) {
+ if (prelu_param_ != NULL) prelu_param_->::caffe::PReLUParameter::Clear();
+ }
+ if (has_prior_box_param()) {
+ if (prior_box_param_ != NULL) prior_box_param_->::caffe::PriorBoxParameter::Clear();
+ }
+ }
+ if (_has_bits_[48 / 32] & 16711680u) {
+ if (has_python_param()) {
+ if (python_param_ != NULL) python_param_->::caffe::PythonParameter::Clear();
+ }
+ if (has_recurrent_param()) {
+ if (recurrent_param_ != NULL) recurrent_param_->::caffe::RecurrentParameter::Clear();
+ }
+ if (has_reduction_param()) {
+ if (reduction_param_ != NULL) reduction_param_->::caffe::ReductionParameter::Clear();
+ }
+ if (has_relu_param()) {
+ if (relu_param_ != NULL) relu_param_->::caffe::ReLUParameter::Clear();
+ }
+ if (has_reshape_param()) {
+ if (reshape_param_ != NULL) reshape_param_->::caffe::ReshapeParameter::Clear();
+ }
+ if (has_scale_param()) {
+ if (scale_param_ != NULL) scale_param_->::caffe::ScaleParameter::Clear();
+ }
+ if (has_sigmoid_param()) {
+ if (sigmoid_param_ != NULL) sigmoid_param_->::caffe::SigmoidParameter::Clear();
+ }
+ if (has_softmax_param()) {
+ if (softmax_param_ != NULL) softmax_param_->::caffe::SoftmaxParameter::Clear();
+ }
+ }
+ if (_has_bits_[56 / 32] & 1056964608u) {
+ if (has_spp_param()) {
+ if (spp_param_ != NULL) spp_param_->::caffe::SPPParameter::Clear();
+ }
+ if (has_slice_param()) {
+ if (slice_param_ != NULL) slice_param_->::caffe::SliceParameter::Clear();
+ }
+ if (has_tanh_param()) {
+ if (tanh_param_ != NULL) tanh_param_->::caffe::TanHParameter::Clear();
+ }
+ if (has_threshold_param()) {
+ if (threshold_param_ != NULL) threshold_param_->::caffe::ThresholdParameter::Clear();
+ }
+ if (has_tile_param()) {
+ if (tile_param_ != NULL) tile_param_->::caffe::TileParameter::Clear();
+ }
+ if (has_window_data_param()) {
+ if (window_data_param_ != NULL) window_data_param_->::caffe::WindowDataParameter::Clear();
+ }
+ }
+ bottom_.Clear();
+ top_.Clear();
+ loss_weight_.Clear();
+ param_.Clear();
+ blobs_.Clear();
+ propagate_down_.Clear();
+ include_.Clear();
+ exclude_.Clear();
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool LayerParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.LayerParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional string name = 1;
+ case 1: {
+ if (tag == 10) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_name()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->name().data(), this->name().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.LayerParameter.name");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(18)) goto parse_type;
+ break;
+ }
+
+ // optional string type = 2;
+ case 2: {
+ if (tag == 18) {
+ parse_type:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_type()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->type().data(), this->type().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.LayerParameter.type");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(26)) goto parse_bottom;
+ break;
+ }
+
+ // repeated string bottom = 3;
+ case 3: {
+ if (tag == 26) {
+ parse_bottom:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->add_bottom()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->bottom(this->bottom_size() - 1).data(),
+ this->bottom(this->bottom_size() - 1).length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.LayerParameter.bottom");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(26)) goto parse_bottom;
+ if (input->ExpectTag(34)) goto parse_top;
+ break;
+ }
+
+ // repeated string top = 4;
+ case 4: {
+ if (tag == 34) {
+ parse_top:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->add_top()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->top(this->top_size() - 1).data(),
+ this->top(this->top_size() - 1).length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.LayerParameter.top");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(34)) goto parse_top;
+ if (input->ExpectTag(45)) goto parse_loss_weight;
+ break;
+ }
+
+ // repeated float loss_weight = 5;
+ case 5: {
+ if (tag == 45) {
+ parse_loss_weight:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ 1, 45, input, this->mutable_loss_weight())));
+ } else if (tag == 42) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, this->mutable_loss_weight())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(45)) goto parse_loss_weight;
+ if (input->ExpectTag(50)) goto parse_param;
+ break;
+ }
+
+ // repeated .caffe.ParamSpec param = 6;
+ case 6: {
+ if (tag == 50) {
+ parse_param:
+ DO_(input->IncrementRecursionDepth());
+ parse_loop_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
+ input, add_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(50)) goto parse_loop_param;
+ if (input->ExpectTag(58)) goto parse_loop_blobs;
+ input->UnsafeDecrementRecursionDepth();
+ break;
+ }
+
+ // repeated .caffe.BlobProto blobs = 7;
+ case 7: {
+ if (tag == 58) {
+ DO_(input->IncrementRecursionDepth());
+ parse_loop_blobs:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
+ input, add_blobs()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(58)) goto parse_loop_blobs;
+ if (input->ExpectTag(66)) goto parse_loop_include;
+ input->UnsafeDecrementRecursionDepth();
+ break;
+ }
+
+ // repeated .caffe.NetStateRule include = 8;
+ case 8: {
+ if (tag == 66) {
+ DO_(input->IncrementRecursionDepth());
+ parse_loop_include:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
+ input, add_include()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(66)) goto parse_loop_include;
+ if (input->ExpectTag(74)) goto parse_loop_exclude;
+ input->UnsafeDecrementRecursionDepth();
+ break;
+ }
+
+ // repeated .caffe.NetStateRule exclude = 9;
+ case 9: {
+ if (tag == 74) {
+ DO_(input->IncrementRecursionDepth());
+ parse_loop_exclude:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
+ input, add_exclude()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(74)) goto parse_loop_exclude;
+ input->UnsafeDecrementRecursionDepth();
+ if (input->ExpectTag(80)) goto parse_phase;
+ break;
+ }
+
+ // optional .caffe.Phase phase = 10;
+ case 10: {
+ if (tag == 80) {
+ parse_phase:
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::Phase_IsValid(value)) {
+ set_phase(static_cast< ::caffe::Phase >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(10, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(88)) goto parse_propagate_down;
+ break;
+ }
+
+ // repeated bool propagate_down = 11;
+ case 11: {
+ if (tag == 88) {
+ parse_propagate_down:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ 1, 88, input, this->mutable_propagate_down())));
+ } else if (tag == 90) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, this->mutable_propagate_down())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(88)) goto parse_propagate_down;
+ if (input->ExpectTag(802)) goto parse_transform_param;
+ break;
+ }
+
+ // optional .caffe.TransformationParameter transform_param = 100;
+ case 100: {
+ if (tag == 802) {
+ parse_transform_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_transform_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(810)) goto parse_loss_param;
+ break;
+ }
+
+ // optional .caffe.LossParameter loss_param = 101;
+ case 101: {
+ if (tag == 810) {
+ parse_loss_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_loss_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(818)) goto parse_accuracy_param;
+ break;
+ }
+
+ // optional .caffe.AccuracyParameter accuracy_param = 102;
+ case 102: {
+ if (tag == 818) {
+ parse_accuracy_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_accuracy_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(826)) goto parse_argmax_param;
+ break;
+ }
+
+ // optional .caffe.ArgMaxParameter argmax_param = 103;
+ case 103: {
+ if (tag == 826) {
+ parse_argmax_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_argmax_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(834)) goto parse_concat_param;
+ break;
+ }
+
+ // optional .caffe.ConcatParameter concat_param = 104;
+ case 104: {
+ if (tag == 834) {
+ parse_concat_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_concat_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(842)) goto parse_contrastive_loss_param;
+ break;
+ }
+
+ // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 105;
+ case 105: {
+ if (tag == 842) {
+ parse_contrastive_loss_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_contrastive_loss_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(850)) goto parse_convolution_param;
+ break;
+ }
+
+ // optional .caffe.ConvolutionParameter convolution_param = 106;
+ case 106: {
+ if (tag == 850) {
+ parse_convolution_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_convolution_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(858)) goto parse_data_param;
+ break;
+ }
+
+ // optional .caffe.DataParameter data_param = 107;
+ case 107: {
+ if (tag == 858) {
+ parse_data_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_data_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(866)) goto parse_dropout_param;
+ break;
+ }
+
+ // optional .caffe.DropoutParameter dropout_param = 108;
+ case 108: {
+ if (tag == 866) {
+ parse_dropout_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_dropout_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(874)) goto parse_dummy_data_param;
+ break;
+ }
+
+ // optional .caffe.DummyDataParameter dummy_data_param = 109;
+ case 109: {
+ if (tag == 874) {
+ parse_dummy_data_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_dummy_data_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(882)) goto parse_eltwise_param;
+ break;
+ }
+
+ // optional .caffe.EltwiseParameter eltwise_param = 110;
+ case 110: {
+ if (tag == 882) {
+ parse_eltwise_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_eltwise_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(890)) goto parse_exp_param;
+ break;
+ }
+
+ // optional .caffe.ExpParameter exp_param = 111;
+ case 111: {
+ if (tag == 890) {
+ parse_exp_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_exp_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(898)) goto parse_hdf5_data_param;
+ break;
+ }
+
+ // optional .caffe.HDF5DataParameter hdf5_data_param = 112;
+ case 112: {
+ if (tag == 898) {
+ parse_hdf5_data_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_hdf5_data_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(906)) goto parse_hdf5_output_param;
+ break;
+ }
+
+ // optional .caffe.HDF5OutputParameter hdf5_output_param = 113;
+ case 113: {
+ if (tag == 906) {
+ parse_hdf5_output_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_hdf5_output_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(914)) goto parse_hinge_loss_param;
+ break;
+ }
+
+ // optional .caffe.HingeLossParameter hinge_loss_param = 114;
+ case 114: {
+ if (tag == 914) {
+ parse_hinge_loss_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_hinge_loss_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(922)) goto parse_image_data_param;
+ break;
+ }
+
+ // optional .caffe.ImageDataParameter image_data_param = 115;
+ case 115: {
+ if (tag == 922) {
+ parse_image_data_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_image_data_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(930)) goto parse_infogain_loss_param;
+ break;
+ }
+
+ // optional .caffe.InfogainLossParameter infogain_loss_param = 116;
+ case 116: {
+ if (tag == 930) {
+ parse_infogain_loss_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_infogain_loss_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(938)) goto parse_inner_product_param;
+ break;
+ }
+
+ // optional .caffe.InnerProductParameter inner_product_param = 117;
+ case 117: {
+ if (tag == 938) {
+ parse_inner_product_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_inner_product_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(946)) goto parse_lrn_param;
+ break;
+ }
+
+ // optional .caffe.LRNParameter lrn_param = 118;
+ case 118: {
+ if (tag == 946) {
+ parse_lrn_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_lrn_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(954)) goto parse_memory_data_param;
+ break;
+ }
+
+ // optional .caffe.MemoryDataParameter memory_data_param = 119;
+ case 119: {
+ if (tag == 954) {
+ parse_memory_data_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_memory_data_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(962)) goto parse_mvn_param;
+ break;
+ }
+
+ // optional .caffe.MVNParameter mvn_param = 120;
+ case 120: {
+ if (tag == 962) {
+ parse_mvn_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_mvn_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(970)) goto parse_pooling_param;
+ break;
+ }
+
+ // optional .caffe.PoolingParameter pooling_param = 121;
+ case 121: {
+ if (tag == 970) {
+ parse_pooling_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_pooling_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(978)) goto parse_power_param;
+ break;
+ }
+
+ // optional .caffe.PowerParameter power_param = 122;
+ case 122: {
+ if (tag == 978) {
+ parse_power_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_power_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(986)) goto parse_relu_param;
+ break;
+ }
+
+ // optional .caffe.ReLUParameter relu_param = 123;
+ case 123: {
+ if (tag == 986) {
+ parse_relu_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_relu_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(994)) goto parse_sigmoid_param;
+ break;
+ }
+
+ // optional .caffe.SigmoidParameter sigmoid_param = 124;
+ case 124: {
+ if (tag == 994) {
+ parse_sigmoid_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_sigmoid_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1002)) goto parse_softmax_param;
+ break;
+ }
+
+ // optional .caffe.SoftmaxParameter softmax_param = 125;
+ case 125: {
+ if (tag == 1002) {
+ parse_softmax_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_softmax_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1010)) goto parse_slice_param;
+ break;
+ }
+
+ // optional .caffe.SliceParameter slice_param = 126;
+ case 126: {
+ if (tag == 1010) {
+ parse_slice_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_slice_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1018)) goto parse_tanh_param;
+ break;
+ }
+
+ // optional .caffe.TanHParameter tanh_param = 127;
+ case 127: {
+ if (tag == 1018) {
+ parse_tanh_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_tanh_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1026)) goto parse_threshold_param;
+ break;
+ }
+
+ // optional .caffe.ThresholdParameter threshold_param = 128;
+ case 128: {
+ if (tag == 1026) {
+ parse_threshold_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_threshold_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1034)) goto parse_window_data_param;
+ break;
+ }
+
+ // optional .caffe.WindowDataParameter window_data_param = 129;
+ case 129: {
+ if (tag == 1034) {
+ parse_window_data_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_window_data_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1042)) goto parse_python_param;
+ break;
+ }
+
+ // optional .caffe.PythonParameter python_param = 130;
+ case 130: {
+ if (tag == 1042) {
+ parse_python_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_python_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1050)) goto parse_prelu_param;
+ break;
+ }
+
+ // optional .caffe.PReLUParameter prelu_param = 131;
+ case 131: {
+ if (tag == 1050) {
+ parse_prelu_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_prelu_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1058)) goto parse_spp_param;
+ break;
+ }
+
+ // optional .caffe.SPPParameter spp_param = 132;
+ case 132: {
+ if (tag == 1058) {
+ parse_spp_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_spp_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1066)) goto parse_reshape_param;
+ break;
+ }
+
+ // optional .caffe.ReshapeParameter reshape_param = 133;
+ case 133: {
+ if (tag == 1066) {
+ parse_reshape_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_reshape_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1074)) goto parse_log_param;
+ break;
+ }
+
+ // optional .caffe.LogParameter log_param = 134;
+ case 134: {
+ if (tag == 1074) {
+ parse_log_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_log_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1082)) goto parse_flatten_param;
+ break;
+ }
+
+ // optional .caffe.FlattenParameter flatten_param = 135;
+ case 135: {
+ if (tag == 1082) {
+ parse_flatten_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_flatten_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1090)) goto parse_reduction_param;
+ break;
+ }
+
+ // optional .caffe.ReductionParameter reduction_param = 136;
+ case 136: {
+ if (tag == 1090) {
+ parse_reduction_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_reduction_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1098)) goto parse_embed_param;
+ break;
+ }
+
+ // optional .caffe.EmbedParameter embed_param = 137;
+ case 137: {
+ if (tag == 1098) {
+ parse_embed_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_embed_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1106)) goto parse_tile_param;
+ break;
+ }
+
+ // optional .caffe.TileParameter tile_param = 138;
+ case 138: {
+ if (tag == 1106) {
+ parse_tile_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_tile_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1114)) goto parse_batch_norm_param;
+ break;
+ }
+
+ // optional .caffe.BatchNormParameter batch_norm_param = 139;
+ case 139: {
+ if (tag == 1114) {
+ parse_batch_norm_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_batch_norm_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1122)) goto parse_elu_param;
+ break;
+ }
+
+ // optional .caffe.ELUParameter elu_param = 140;
+ case 140: {
+ if (tag == 1122) {
+ parse_elu_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_elu_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1130)) goto parse_bias_param;
+ break;
+ }
+
+ // optional .caffe.BiasParameter bias_param = 141;
+ case 141: {
+ if (tag == 1130) {
+ parse_bias_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_bias_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1138)) goto parse_scale_param;
+ break;
+ }
+
+ // optional .caffe.ScaleParameter scale_param = 142;
+ case 142: {
+ if (tag == 1138) {
+ parse_scale_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_scale_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1146)) goto parse_input_param;
+ break;
+ }
+
+ // optional .caffe.InputParameter input_param = 143;
+ case 143: {
+ if (tag == 1146) {
+ parse_input_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_input_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1154)) goto parse_crop_param;
+ break;
+ }
+
+ // optional .caffe.CropParameter crop_param = 144;
+ case 144: {
+ if (tag == 1154) {
+ parse_crop_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_crop_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1162)) goto parse_parameter_param;
+ break;
+ }
+
+ // optional .caffe.ParameterParameter parameter_param = 145;
+ case 145: {
+ if (tag == 1162) {
+ parse_parameter_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_parameter_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1170)) goto parse_recurrent_param;
+ break;
+ }
+
+ // optional .caffe.RecurrentParameter recurrent_param = 146;
+ case 146: {
+ if (tag == 1170) {
+ parse_recurrent_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_recurrent_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1178)) goto parse_detection_output_param;
+ break;
+ }
+
+ // optional .caffe.DetectionOutputParameter detection_output_param = 147;
+ case 147: {
+ if (tag == 1178) {
+ parse_detection_output_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_detection_output_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1186)) goto parse_permute_param;
+ break;
+ }
+
+ // optional .caffe.PermuteParameter permute_param = 148;
+ case 148: {
+ if (tag == 1186) {
+ parse_permute_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_permute_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1194)) goto parse_norm_param;
+ break;
+ }
+
+ // optional .caffe.NormalizeBBoxParameter norm_param = 149;
+ case 149: {
+ if (tag == 1194) {
+ parse_norm_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_norm_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(1202)) goto parse_prior_box_param;
+ break;
+ }
+
+ // optional .caffe.PriorBoxParameter prior_box_param = 150;
+ case 150: {
+ if (tag == 1202) {
+ parse_prior_box_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_prior_box_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.LayerParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.LayerParameter)
+ return false;
+#undef DO_
+}
+
+void LayerParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.LayerParameter)
+ // optional string name = 1;
+ if (has_name()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->name().data(), this->name().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.LayerParameter.name");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 1, this->name(), output);
+ }
+
+ // optional string type = 2;
+ if (has_type()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->type().data(), this->type().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.LayerParameter.type");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 2, this->type(), output);
+ }
+
+ // repeated string bottom = 3;
+ for (int i = 0; i < this->bottom_size(); i++) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->bottom(i).data(), this->bottom(i).length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.LayerParameter.bottom");
+ ::google::protobuf::internal::WireFormatLite::WriteString(
+ 3, this->bottom(i), output);
+ }
+
+ // repeated string top = 4;
+ for (int i = 0; i < this->top_size(); i++) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->top(i).data(), this->top(i).length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.LayerParameter.top");
+ ::google::protobuf::internal::WireFormatLite::WriteString(
+ 4, this->top(i), output);
+ }
+
+ // repeated float loss_weight = 5;
+ for (int i = 0; i < this->loss_weight_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(
+ 5, this->loss_weight(i), output);
+ }
+
+ // repeated .caffe.ParamSpec param = 6;
+ for (unsigned int i = 0, n = this->param_size(); i < n; i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 6, this->param(i), output);
+ }
+
+ // repeated .caffe.BlobProto blobs = 7;
+ for (unsigned int i = 0, n = this->blobs_size(); i < n; i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 7, this->blobs(i), output);
+ }
+
+ // repeated .caffe.NetStateRule include = 8;
+ for (unsigned int i = 0, n = this->include_size(); i < n; i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 8, this->include(i), output);
+ }
+
+ // repeated .caffe.NetStateRule exclude = 9;
+ for (unsigned int i = 0, n = this->exclude_size(); i < n; i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 9, this->exclude(i), output);
+ }
+
+ // optional .caffe.Phase phase = 10;
+ if (has_phase()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 10, this->phase(), output);
+ }
+
+ // repeated bool propagate_down = 11;
+ for (int i = 0; i < this->propagate_down_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(
+ 11, this->propagate_down(i), output);
+ }
+
+ // optional .caffe.TransformationParameter transform_param = 100;
+ if (has_transform_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 100, *this->transform_param_, output);
+ }
+
+ // optional .caffe.LossParameter loss_param = 101;
+ if (has_loss_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 101, *this->loss_param_, output);
+ }
+
+ // optional .caffe.AccuracyParameter accuracy_param = 102;
+ if (has_accuracy_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 102, *this->accuracy_param_, output);
+ }
+
+ // optional .caffe.ArgMaxParameter argmax_param = 103;
+ if (has_argmax_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 103, *this->argmax_param_, output);
+ }
+
+ // optional .caffe.ConcatParameter concat_param = 104;
+ if (has_concat_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 104, *this->concat_param_, output);
+ }
+
+ // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 105;
+ if (has_contrastive_loss_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 105, *this->contrastive_loss_param_, output);
+ }
+
+ // optional .caffe.ConvolutionParameter convolution_param = 106;
+ if (has_convolution_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 106, *this->convolution_param_, output);
+ }
+
+ // optional .caffe.DataParameter data_param = 107;
+ if (has_data_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 107, *this->data_param_, output);
+ }
+
+ // optional .caffe.DropoutParameter dropout_param = 108;
+ if (has_dropout_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 108, *this->dropout_param_, output);
+ }
+
+ // optional .caffe.DummyDataParameter dummy_data_param = 109;
+ if (has_dummy_data_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 109, *this->dummy_data_param_, output);
+ }
+
+ // optional .caffe.EltwiseParameter eltwise_param = 110;
+ if (has_eltwise_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 110, *this->eltwise_param_, output);
+ }
+
+ // optional .caffe.ExpParameter exp_param = 111;
+ if (has_exp_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 111, *this->exp_param_, output);
+ }
+
+ // optional .caffe.HDF5DataParameter hdf5_data_param = 112;
+ if (has_hdf5_data_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 112, *this->hdf5_data_param_, output);
+ }
+
+ // optional .caffe.HDF5OutputParameter hdf5_output_param = 113;
+ if (has_hdf5_output_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 113, *this->hdf5_output_param_, output);
+ }
+
+ // optional .caffe.HingeLossParameter hinge_loss_param = 114;
+ if (has_hinge_loss_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 114, *this->hinge_loss_param_, output);
+ }
+
+ // optional .caffe.ImageDataParameter image_data_param = 115;
+ if (has_image_data_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 115, *this->image_data_param_, output);
+ }
+
+ // optional .caffe.InfogainLossParameter infogain_loss_param = 116;
+ if (has_infogain_loss_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 116, *this->infogain_loss_param_, output);
+ }
+
+ // optional .caffe.InnerProductParameter inner_product_param = 117;
+ if (has_inner_product_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 117, *this->inner_product_param_, output);
+ }
+
+ // optional .caffe.LRNParameter lrn_param = 118;
+ if (has_lrn_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 118, *this->lrn_param_, output);
+ }
+
+ // optional .caffe.MemoryDataParameter memory_data_param = 119;
+ if (has_memory_data_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 119, *this->memory_data_param_, output);
+ }
+
+ // optional .caffe.MVNParameter mvn_param = 120;
+ if (has_mvn_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 120, *this->mvn_param_, output);
+ }
+
+ // optional .caffe.PoolingParameter pooling_param = 121;
+ if (has_pooling_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 121, *this->pooling_param_, output);
+ }
+
+ // optional .caffe.PowerParameter power_param = 122;
+ if (has_power_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 122, *this->power_param_, output);
+ }
+
+ // optional .caffe.ReLUParameter relu_param = 123;
+ if (has_relu_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 123, *this->relu_param_, output);
+ }
+
+ // optional .caffe.SigmoidParameter sigmoid_param = 124;
+ if (has_sigmoid_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 124, *this->sigmoid_param_, output);
+ }
+
+ // optional .caffe.SoftmaxParameter softmax_param = 125;
+ if (has_softmax_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 125, *this->softmax_param_, output);
+ }
+
+ // optional .caffe.SliceParameter slice_param = 126;
+ if (has_slice_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 126, *this->slice_param_, output);
+ }
+
+ // optional .caffe.TanHParameter tanh_param = 127;
+ if (has_tanh_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 127, *this->tanh_param_, output);
+ }
+
+ // optional .caffe.ThresholdParameter threshold_param = 128;
+ if (has_threshold_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 128, *this->threshold_param_, output);
+ }
+
+ // optional .caffe.WindowDataParameter window_data_param = 129;
+ if (has_window_data_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 129, *this->window_data_param_, output);
+ }
+
+ // optional .caffe.PythonParameter python_param = 130;
+ if (has_python_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 130, *this->python_param_, output);
+ }
+
+ // optional .caffe.PReLUParameter prelu_param = 131;
+ if (has_prelu_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 131, *this->prelu_param_, output);
+ }
+
+ // optional .caffe.SPPParameter spp_param = 132;
+ if (has_spp_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 132, *this->spp_param_, output);
+ }
+
+ // optional .caffe.ReshapeParameter reshape_param = 133;
+ if (has_reshape_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 133, *this->reshape_param_, output);
+ }
+
+ // optional .caffe.LogParameter log_param = 134;
+ if (has_log_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 134, *this->log_param_, output);
+ }
+
+ // optional .caffe.FlattenParameter flatten_param = 135;
+ if (has_flatten_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 135, *this->flatten_param_, output);
+ }
+
+ // optional .caffe.ReductionParameter reduction_param = 136;
+ if (has_reduction_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 136, *this->reduction_param_, output);
+ }
+
+ // optional .caffe.EmbedParameter embed_param = 137;
+ if (has_embed_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 137, *this->embed_param_, output);
+ }
+
+ // optional .caffe.TileParameter tile_param = 138;
+ if (has_tile_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 138, *this->tile_param_, output);
+ }
+
+ // optional .caffe.BatchNormParameter batch_norm_param = 139;
+ if (has_batch_norm_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 139, *this->batch_norm_param_, output);
+ }
+
+ // optional .caffe.ELUParameter elu_param = 140;
+ if (has_elu_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 140, *this->elu_param_, output);
+ }
+
+ // optional .caffe.BiasParameter bias_param = 141;
+ if (has_bias_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 141, *this->bias_param_, output);
+ }
+
+ // optional .caffe.ScaleParameter scale_param = 142;
+ if (has_scale_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 142, *this->scale_param_, output);
+ }
+
+ // optional .caffe.InputParameter input_param = 143;
+ if (has_input_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 143, *this->input_param_, output);
+ }
+
+ // optional .caffe.CropParameter crop_param = 144;
+ if (has_crop_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 144, *this->crop_param_, output);
+ }
+
+ // optional .caffe.ParameterParameter parameter_param = 145;
+ if (has_parameter_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 145, *this->parameter_param_, output);
+ }
+
+ // optional .caffe.RecurrentParameter recurrent_param = 146;
+ if (has_recurrent_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 146, *this->recurrent_param_, output);
+ }
+
+ // optional .caffe.DetectionOutputParameter detection_output_param = 147;
+ if (has_detection_output_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 147, *this->detection_output_param_, output);
+ }
+
+ // optional .caffe.PermuteParameter permute_param = 148;
+ if (has_permute_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 148, *this->permute_param_, output);
+ }
+
+ // optional .caffe.NormalizeBBoxParameter norm_param = 149;
+ if (has_norm_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 149, *this->norm_param_, output);
+ }
+
+ // optional .caffe.PriorBoxParameter prior_box_param = 150;
+ if (has_prior_box_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 150, *this->prior_box_param_, output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.LayerParameter)
+}
+
+::google::protobuf::uint8* LayerParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.LayerParameter)
+ // optional string name = 1;
+ if (has_name()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->name().data(), this->name().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.LayerParameter.name");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 1, this->name(), target);
+ }
+
+ // optional string type = 2;
+ if (has_type()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->type().data(), this->type().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.LayerParameter.type");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 2, this->type(), target);
+ }
+
+ // repeated string bottom = 3;
+ for (int i = 0; i < this->bottom_size(); i++) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->bottom(i).data(), this->bottom(i).length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.LayerParameter.bottom");
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteStringToArray(3, this->bottom(i), target);
+ }
+
+ // repeated string top = 4;
+ for (int i = 0; i < this->top_size(); i++) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->top(i).data(), this->top(i).length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.LayerParameter.top");
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteStringToArray(4, this->top(i), target);
+ }
+
+ // repeated float loss_weight = 5;
+ for (int i = 0; i < this->loss_weight_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteFloatToArray(5, this->loss_weight(i), target);
+ }
+
+ // repeated .caffe.ParamSpec param = 6;
+ for (unsigned int i = 0, n = this->param_size(); i < n; i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 6, this->param(i), false, target);
+ }
+
+ // repeated .caffe.BlobProto blobs = 7;
+ for (unsigned int i = 0, n = this->blobs_size(); i < n; i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 7, this->blobs(i), false, target);
+ }
+
+ // repeated .caffe.NetStateRule include = 8;
+ for (unsigned int i = 0, n = this->include_size(); i < n; i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 8, this->include(i), false, target);
+ }
+
+ // repeated .caffe.NetStateRule exclude = 9;
+ for (unsigned int i = 0, n = this->exclude_size(); i < n; i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 9, this->exclude(i), false, target);
+ }
+
+ // optional .caffe.Phase phase = 10;
+ if (has_phase()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 10, this->phase(), target);
+ }
+
+ // repeated bool propagate_down = 11;
+ for (int i = 0; i < this->propagate_down_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteBoolToArray(11, this->propagate_down(i), target);
+ }
+
+ // optional .caffe.TransformationParameter transform_param = 100;
+ if (has_transform_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 100, *this->transform_param_, false, target);
+ }
+
+ // optional .caffe.LossParameter loss_param = 101;
+ if (has_loss_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 101, *this->loss_param_, false, target);
+ }
+
+ // optional .caffe.AccuracyParameter accuracy_param = 102;
+ if (has_accuracy_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 102, *this->accuracy_param_, false, target);
+ }
+
+ // optional .caffe.ArgMaxParameter argmax_param = 103;
+ if (has_argmax_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 103, *this->argmax_param_, false, target);
+ }
+
+ // optional .caffe.ConcatParameter concat_param = 104;
+ if (has_concat_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 104, *this->concat_param_, false, target);
+ }
+
+ // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 105;
+ if (has_contrastive_loss_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 105, *this->contrastive_loss_param_, false, target);
+ }
+
+ // optional .caffe.ConvolutionParameter convolution_param = 106;
+ if (has_convolution_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 106, *this->convolution_param_, false, target);
+ }
+
+ // optional .caffe.DataParameter data_param = 107;
+ if (has_data_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 107, *this->data_param_, false, target);
+ }
+
+ // optional .caffe.DropoutParameter dropout_param = 108;
+ if (has_dropout_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 108, *this->dropout_param_, false, target);
+ }
+
+ // optional .caffe.DummyDataParameter dummy_data_param = 109;
+ if (has_dummy_data_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 109, *this->dummy_data_param_, false, target);
+ }
+
+ // optional .caffe.EltwiseParameter eltwise_param = 110;
+ if (has_eltwise_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 110, *this->eltwise_param_, false, target);
+ }
+
+ // optional .caffe.ExpParameter exp_param = 111;
+ if (has_exp_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 111, *this->exp_param_, false, target);
+ }
+
+ // optional .caffe.HDF5DataParameter hdf5_data_param = 112;
+ if (has_hdf5_data_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 112, *this->hdf5_data_param_, false, target);
+ }
+
+ // optional .caffe.HDF5OutputParameter hdf5_output_param = 113;
+ if (has_hdf5_output_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 113, *this->hdf5_output_param_, false, target);
+ }
+
+ // optional .caffe.HingeLossParameter hinge_loss_param = 114;
+ if (has_hinge_loss_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 114, *this->hinge_loss_param_, false, target);
+ }
+
+ // optional .caffe.ImageDataParameter image_data_param = 115;
+ if (has_image_data_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 115, *this->image_data_param_, false, target);
+ }
+
+ // optional .caffe.InfogainLossParameter infogain_loss_param = 116;
+ if (has_infogain_loss_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 116, *this->infogain_loss_param_, false, target);
+ }
+
+ // optional .caffe.InnerProductParameter inner_product_param = 117;
+ if (has_inner_product_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 117, *this->inner_product_param_, false, target);
+ }
+
+ // optional .caffe.LRNParameter lrn_param = 118;
+ if (has_lrn_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 118, *this->lrn_param_, false, target);
+ }
+
+ // optional .caffe.MemoryDataParameter memory_data_param = 119;
+ if (has_memory_data_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 119, *this->memory_data_param_, false, target);
+ }
+
+ // optional .caffe.MVNParameter mvn_param = 120;
+ if (has_mvn_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 120, *this->mvn_param_, false, target);
+ }
+
+ // optional .caffe.PoolingParameter pooling_param = 121;
+ if (has_pooling_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 121, *this->pooling_param_, false, target);
+ }
+
+ // optional .caffe.PowerParameter power_param = 122;
+ if (has_power_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 122, *this->power_param_, false, target);
+ }
+
+ // optional .caffe.ReLUParameter relu_param = 123;
+ if (has_relu_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 123, *this->relu_param_, false, target);
+ }
+
+ // optional .caffe.SigmoidParameter sigmoid_param = 124;
+ if (has_sigmoid_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 124, *this->sigmoid_param_, false, target);
+ }
+
+ // optional .caffe.SoftmaxParameter softmax_param = 125;
+ if (has_softmax_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 125, *this->softmax_param_, false, target);
+ }
+
+ // optional .caffe.SliceParameter slice_param = 126;
+ if (has_slice_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 126, *this->slice_param_, false, target);
+ }
+
+ // optional .caffe.TanHParameter tanh_param = 127;
+ if (has_tanh_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 127, *this->tanh_param_, false, target);
+ }
+
+ // optional .caffe.ThresholdParameter threshold_param = 128;
+ if (has_threshold_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 128, *this->threshold_param_, false, target);
+ }
+
+ // optional .caffe.WindowDataParameter window_data_param = 129;
+ if (has_window_data_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 129, *this->window_data_param_, false, target);
+ }
+
+ // optional .caffe.PythonParameter python_param = 130;
+ if (has_python_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 130, *this->python_param_, false, target);
+ }
+
+ // optional .caffe.PReLUParameter prelu_param = 131;
+ if (has_prelu_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 131, *this->prelu_param_, false, target);
+ }
+
+ // optional .caffe.SPPParameter spp_param = 132;
+ if (has_spp_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 132, *this->spp_param_, false, target);
+ }
+
+ // optional .caffe.ReshapeParameter reshape_param = 133;
+ if (has_reshape_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 133, *this->reshape_param_, false, target);
+ }
+
+ // optional .caffe.LogParameter log_param = 134;
+ if (has_log_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 134, *this->log_param_, false, target);
+ }
+
+ // optional .caffe.FlattenParameter flatten_param = 135;
+ if (has_flatten_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 135, *this->flatten_param_, false, target);
+ }
+
+ // optional .caffe.ReductionParameter reduction_param = 136;
+ if (has_reduction_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 136, *this->reduction_param_, false, target);
+ }
+
+ // optional .caffe.EmbedParameter embed_param = 137;
+ if (has_embed_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 137, *this->embed_param_, false, target);
+ }
+
+ // optional .caffe.TileParameter tile_param = 138;
+ if (has_tile_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 138, *this->tile_param_, false, target);
+ }
+
+ // optional .caffe.BatchNormParameter batch_norm_param = 139;
+ if (has_batch_norm_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 139, *this->batch_norm_param_, false, target);
+ }
+
+ // optional .caffe.ELUParameter elu_param = 140;
+ if (has_elu_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 140, *this->elu_param_, false, target);
+ }
+
+ // optional .caffe.BiasParameter bias_param = 141;
+ if (has_bias_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 141, *this->bias_param_, false, target);
+ }
+
+ // optional .caffe.ScaleParameter scale_param = 142;
+ if (has_scale_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 142, *this->scale_param_, false, target);
+ }
+
+ // optional .caffe.InputParameter input_param = 143;
+ if (has_input_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 143, *this->input_param_, false, target);
+ }
+
+ // optional .caffe.CropParameter crop_param = 144;
+ if (has_crop_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 144, *this->crop_param_, false, target);
+ }
+
+ // optional .caffe.ParameterParameter parameter_param = 145;
+ if (has_parameter_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 145, *this->parameter_param_, false, target);
+ }
+
+ // optional .caffe.RecurrentParameter recurrent_param = 146;
+ if (has_recurrent_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 146, *this->recurrent_param_, false, target);
+ }
+
+ // optional .caffe.DetectionOutputParameter detection_output_param = 147;
+ if (has_detection_output_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 147, *this->detection_output_param_, false, target);
+ }
+
+ // optional .caffe.PermuteParameter permute_param = 148;
+ if (has_permute_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 148, *this->permute_param_, false, target);
+ }
+
+ // optional .caffe.NormalizeBBoxParameter norm_param = 149;
+ if (has_norm_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 149, *this->norm_param_, false, target);
+ }
+
+ // optional .caffe.PriorBoxParameter prior_box_param = 150;
+ if (has_prior_box_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 150, *this->prior_box_param_, false, target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.LayerParameter)
+ return target;
+}
+
+size_t LayerParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.LayerParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 19u) {
+ // optional string name = 1;
+ if (has_name()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->name());
+ }
+
+ // optional string type = 2;
+ if (has_type()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->type());
+ }
+
+ // optional .caffe.Phase phase = 10;
+ if (has_phase()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->phase());
+ }
+
+ }
+ if (_has_bits_[11 / 32] & 63488u) {
+ // optional .caffe.TransformationParameter transform_param = 100;
+ if (has_transform_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->transform_param_);
+ }
+
+ // optional .caffe.LossParameter loss_param = 101;
+ if (has_loss_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->loss_param_);
+ }
+
+ // optional .caffe.AccuracyParameter accuracy_param = 102;
+ if (has_accuracy_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->accuracy_param_);
+ }
+
+ // optional .caffe.ArgMaxParameter argmax_param = 103;
+ if (has_argmax_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->argmax_param_);
+ }
+
+ // optional .caffe.BatchNormParameter batch_norm_param = 139;
+ if (has_batch_norm_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->batch_norm_param_);
+ }
+
+ }
+ if (_has_bits_[16 / 32] & 16711680u) {
+ // optional .caffe.BiasParameter bias_param = 141;
+ if (has_bias_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->bias_param_);
+ }
+
+ // optional .caffe.ConcatParameter concat_param = 104;
+ if (has_concat_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->concat_param_);
+ }
+
+ // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 105;
+ if (has_contrastive_loss_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->contrastive_loss_param_);
+ }
+
+ // optional .caffe.ConvolutionParameter convolution_param = 106;
+ if (has_convolution_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->convolution_param_);
+ }
+
+ // optional .caffe.CropParameter crop_param = 144;
+ if (has_crop_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->crop_param_);
+ }
+
+ // optional .caffe.DataParameter data_param = 107;
+ if (has_data_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->data_param_);
+ }
+
+ // optional .caffe.DetectionOutputParameter detection_output_param = 147;
+ if (has_detection_output_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->detection_output_param_);
+ }
+
+ // optional .caffe.DropoutParameter dropout_param = 108;
+ if (has_dropout_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->dropout_param_);
+ }
+
+ }
+ if (_has_bits_[24 / 32] & 4278190080u) {
+ // optional .caffe.DummyDataParameter dummy_data_param = 109;
+ if (has_dummy_data_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->dummy_data_param_);
+ }
+
+ // optional .caffe.EltwiseParameter eltwise_param = 110;
+ if (has_eltwise_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->eltwise_param_);
+ }
+
+ // optional .caffe.ELUParameter elu_param = 140;
+ if (has_elu_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->elu_param_);
+ }
+
+ // optional .caffe.EmbedParameter embed_param = 137;
+ if (has_embed_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->embed_param_);
+ }
+
+ // optional .caffe.ExpParameter exp_param = 111;
+ if (has_exp_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->exp_param_);
+ }
+
+ // optional .caffe.FlattenParameter flatten_param = 135;
+ if (has_flatten_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->flatten_param_);
+ }
+
+ // optional .caffe.HDF5DataParameter hdf5_data_param = 112;
+ if (has_hdf5_data_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->hdf5_data_param_);
+ }
+
+ // optional .caffe.HDF5OutputParameter hdf5_output_param = 113;
+ if (has_hdf5_output_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->hdf5_output_param_);
+ }
+
+ }
+ if (_has_bits_[32 / 32] & 255u) {
+ // optional .caffe.HingeLossParameter hinge_loss_param = 114;
+ if (has_hinge_loss_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->hinge_loss_param_);
+ }
+
+ // optional .caffe.ImageDataParameter image_data_param = 115;
+ if (has_image_data_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->image_data_param_);
+ }
+
+ // optional .caffe.InfogainLossParameter infogain_loss_param = 116;
+ if (has_infogain_loss_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->infogain_loss_param_);
+ }
+
+ // optional .caffe.InnerProductParameter inner_product_param = 117;
+ if (has_inner_product_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->inner_product_param_);
+ }
+
+ // optional .caffe.InputParameter input_param = 143;
+ if (has_input_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->input_param_);
+ }
+
+ // optional .caffe.LogParameter log_param = 134;
+ if (has_log_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->log_param_);
+ }
+
+ // optional .caffe.LRNParameter lrn_param = 118;
+ if (has_lrn_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->lrn_param_);
+ }
+
+ // optional .caffe.MemoryDataParameter memory_data_param = 119;
+ if (has_memory_data_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->memory_data_param_);
+ }
+
+ }
+ if (_has_bits_[40 / 32] & 65280u) {
+ // optional .caffe.MVNParameter mvn_param = 120;
+ if (has_mvn_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->mvn_param_);
+ }
+
+ // optional .caffe.NormalizeBBoxParameter norm_param = 149;
+ if (has_norm_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->norm_param_);
+ }
+
+ // optional .caffe.PermuteParameter permute_param = 148;
+ if (has_permute_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->permute_param_);
+ }
+
+ // optional .caffe.ParameterParameter parameter_param = 145;
+ if (has_parameter_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->parameter_param_);
+ }
+
+ // optional .caffe.PoolingParameter pooling_param = 121;
+ if (has_pooling_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->pooling_param_);
+ }
+
+ // optional .caffe.PowerParameter power_param = 122;
+ if (has_power_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->power_param_);
+ }
+
+ // optional .caffe.PReLUParameter prelu_param = 131;
+ if (has_prelu_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->prelu_param_);
+ }
+
+ // optional .caffe.PriorBoxParameter prior_box_param = 150;
+ if (has_prior_box_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->prior_box_param_);
+ }
+
+ }
+ if (_has_bits_[48 / 32] & 16711680u) {
+ // optional .caffe.PythonParameter python_param = 130;
+ if (has_python_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->python_param_);
+ }
+
+ // optional .caffe.RecurrentParameter recurrent_param = 146;
+ if (has_recurrent_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->recurrent_param_);
+ }
+
+ // optional .caffe.ReductionParameter reduction_param = 136;
+ if (has_reduction_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->reduction_param_);
+ }
+
+ // optional .caffe.ReLUParameter relu_param = 123;
+ if (has_relu_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->relu_param_);
+ }
+
+ // optional .caffe.ReshapeParameter reshape_param = 133;
+ if (has_reshape_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->reshape_param_);
+ }
+
+ // optional .caffe.ScaleParameter scale_param = 142;
+ if (has_scale_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->scale_param_);
+ }
+
+ // optional .caffe.SigmoidParameter sigmoid_param = 124;
+ if (has_sigmoid_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->sigmoid_param_);
+ }
+
+ // optional .caffe.SoftmaxParameter softmax_param = 125;
+ if (has_softmax_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->softmax_param_);
+ }
+
+ }
+ if (_has_bits_[56 / 32] & 1056964608u) {
+ // optional .caffe.SPPParameter spp_param = 132;
+ if (has_spp_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->spp_param_);
+ }
+
+ // optional .caffe.SliceParameter slice_param = 126;
+ if (has_slice_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->slice_param_);
+ }
+
+ // optional .caffe.TanHParameter tanh_param = 127;
+ if (has_tanh_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->tanh_param_);
+ }
+
+ // optional .caffe.ThresholdParameter threshold_param = 128;
+ if (has_threshold_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->threshold_param_);
+ }
+
+ // optional .caffe.TileParameter tile_param = 138;
+ if (has_tile_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->tile_param_);
+ }
+
+ // optional .caffe.WindowDataParameter window_data_param = 129;
+ if (has_window_data_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->window_data_param_);
+ }
+
+ }
+ // repeated string bottom = 3;
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->bottom_size());
+ for (int i = 0; i < this->bottom_size(); i++) {
+ total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->bottom(i));
+ }
+
+ // repeated string top = 4;
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->top_size());
+ for (int i = 0; i < this->top_size(); i++) {
+ total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->top(i));
+ }
+
+ // repeated float loss_weight = 5;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->loss_weight_size();
+ data_size = 4UL * count;
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->loss_weight_size());
+ total_size += data_size;
+ }
+
+ // repeated .caffe.ParamSpec param = 6;
+ {
+ unsigned int count = this->param_size();
+ total_size += 1UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->param(i));
+ }
+ }
+
+ // repeated .caffe.BlobProto blobs = 7;
+ {
+ unsigned int count = this->blobs_size();
+ total_size += 1UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->blobs(i));
+ }
+ }
+
+ // repeated bool propagate_down = 11;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->propagate_down_size();
+ data_size = 1UL * count;
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->propagate_down_size());
+ total_size += data_size;
+ }
+
+ // repeated .caffe.NetStateRule include = 8;
+ {
+ unsigned int count = this->include_size();
+ total_size += 1UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->include(i));
+ }
+ }
+
+ // repeated .caffe.NetStateRule exclude = 9;
+ {
+ unsigned int count = this->exclude_size();
+ total_size += 1UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->exclude(i));
+ }
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void LayerParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.LayerParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const LayerParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const LayerParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.LayerParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.LayerParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void LayerParameter::MergeFrom(const LayerParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.LayerParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void LayerParameter::UnsafeMergeFrom(const LayerParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ bottom_.UnsafeMergeFrom(from.bottom_);
+ top_.UnsafeMergeFrom(from.top_);
+ loss_weight_.UnsafeMergeFrom(from.loss_weight_);
+ param_.MergeFrom(from.param_);
+ blobs_.MergeFrom(from.blobs_);
+ propagate_down_.UnsafeMergeFrom(from.propagate_down_);
+ include_.MergeFrom(from.include_);
+ exclude_.MergeFrom(from.exclude_);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_name()) {
+ set_has_name();
+ name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
+ }
+ if (from.has_type()) {
+ set_has_type();
+ type_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_);
+ }
+ if (from.has_phase()) {
+ set_phase(from.phase());
+ }
+ }
+ if (from._has_bits_[11 / 32] & (0xffu << (11 % 32))) {
+ if (from.has_transform_param()) {
+ mutable_transform_param()->::caffe::TransformationParameter::MergeFrom(from.transform_param());
+ }
+ if (from.has_loss_param()) {
+ mutable_loss_param()->::caffe::LossParameter::MergeFrom(from.loss_param());
+ }
+ if (from.has_accuracy_param()) {
+ mutable_accuracy_param()->::caffe::AccuracyParameter::MergeFrom(from.accuracy_param());
+ }
+ if (from.has_argmax_param()) {
+ mutable_argmax_param()->::caffe::ArgMaxParameter::MergeFrom(from.argmax_param());
+ }
+ if (from.has_batch_norm_param()) {
+ mutable_batch_norm_param()->::caffe::BatchNormParameter::MergeFrom(from.batch_norm_param());
+ }
+ }
+ if (from._has_bits_[16 / 32] & (0xffu << (16 % 32))) {
+ if (from.has_bias_param()) {
+ mutable_bias_param()->::caffe::BiasParameter::MergeFrom(from.bias_param());
+ }
+ if (from.has_concat_param()) {
+ mutable_concat_param()->::caffe::ConcatParameter::MergeFrom(from.concat_param());
+ }
+ if (from.has_contrastive_loss_param()) {
+ mutable_contrastive_loss_param()->::caffe::ContrastiveLossParameter::MergeFrom(from.contrastive_loss_param());
+ }
+ if (from.has_convolution_param()) {
+ mutable_convolution_param()->::caffe::ConvolutionParameter::MergeFrom(from.convolution_param());
+ }
+ if (from.has_crop_param()) {
+ mutable_crop_param()->::caffe::CropParameter::MergeFrom(from.crop_param());
+ }
+ if (from.has_data_param()) {
+ mutable_data_param()->::caffe::DataParameter::MergeFrom(from.data_param());
+ }
+ if (from.has_detection_output_param()) {
+ mutable_detection_output_param()->::caffe::DetectionOutputParameter::MergeFrom(from.detection_output_param());
+ }
+ if (from.has_dropout_param()) {
+ mutable_dropout_param()->::caffe::DropoutParameter::MergeFrom(from.dropout_param());
+ }
+ }
+ if (from._has_bits_[24 / 32] & (0xffu << (24 % 32))) {
+ if (from.has_dummy_data_param()) {
+ mutable_dummy_data_param()->::caffe::DummyDataParameter::MergeFrom(from.dummy_data_param());
+ }
+ if (from.has_eltwise_param()) {
+ mutable_eltwise_param()->::caffe::EltwiseParameter::MergeFrom(from.eltwise_param());
+ }
+ if (from.has_elu_param()) {
+ mutable_elu_param()->::caffe::ELUParameter::MergeFrom(from.elu_param());
+ }
+ if (from.has_embed_param()) {
+ mutable_embed_param()->::caffe::EmbedParameter::MergeFrom(from.embed_param());
+ }
+ if (from.has_exp_param()) {
+ mutable_exp_param()->::caffe::ExpParameter::MergeFrom(from.exp_param());
+ }
+ if (from.has_flatten_param()) {
+ mutable_flatten_param()->::caffe::FlattenParameter::MergeFrom(from.flatten_param());
+ }
+ if (from.has_hdf5_data_param()) {
+ mutable_hdf5_data_param()->::caffe::HDF5DataParameter::MergeFrom(from.hdf5_data_param());
+ }
+ if (from.has_hdf5_output_param()) {
+ mutable_hdf5_output_param()->::caffe::HDF5OutputParameter::MergeFrom(from.hdf5_output_param());
+ }
+ }
+ if (from._has_bits_[32 / 32] & (0xffu << (32 % 32))) {
+ if (from.has_hinge_loss_param()) {
+ mutable_hinge_loss_param()->::caffe::HingeLossParameter::MergeFrom(from.hinge_loss_param());
+ }
+ if (from.has_image_data_param()) {
+ mutable_image_data_param()->::caffe::ImageDataParameter::MergeFrom(from.image_data_param());
+ }
+ if (from.has_infogain_loss_param()) {
+ mutable_infogain_loss_param()->::caffe::InfogainLossParameter::MergeFrom(from.infogain_loss_param());
+ }
+ if (from.has_inner_product_param()) {
+ mutable_inner_product_param()->::caffe::InnerProductParameter::MergeFrom(from.inner_product_param());
+ }
+ if (from.has_input_param()) {
+ mutable_input_param()->::caffe::InputParameter::MergeFrom(from.input_param());
+ }
+ if (from.has_log_param()) {
+ mutable_log_param()->::caffe::LogParameter::MergeFrom(from.log_param());
+ }
+ if (from.has_lrn_param()) {
+ mutable_lrn_param()->::caffe::LRNParameter::MergeFrom(from.lrn_param());
+ }
+ if (from.has_memory_data_param()) {
+ mutable_memory_data_param()->::caffe::MemoryDataParameter::MergeFrom(from.memory_data_param());
+ }
+ }
+ if (from._has_bits_[40 / 32] & (0xffu << (40 % 32))) {
+ if (from.has_mvn_param()) {
+ mutable_mvn_param()->::caffe::MVNParameter::MergeFrom(from.mvn_param());
+ }
+ if (from.has_norm_param()) {
+ mutable_norm_param()->::caffe::NormalizeBBoxParameter::MergeFrom(from.norm_param());
+ }
+ if (from.has_permute_param()) {
+ mutable_permute_param()->::caffe::PermuteParameter::MergeFrom(from.permute_param());
+ }
+ if (from.has_parameter_param()) {
+ mutable_parameter_param()->::caffe::ParameterParameter::MergeFrom(from.parameter_param());
+ }
+ if (from.has_pooling_param()) {
+ mutable_pooling_param()->::caffe::PoolingParameter::MergeFrom(from.pooling_param());
+ }
+ if (from.has_power_param()) {
+ mutable_power_param()->::caffe::PowerParameter::MergeFrom(from.power_param());
+ }
+ if (from.has_prelu_param()) {
+ mutable_prelu_param()->::caffe::PReLUParameter::MergeFrom(from.prelu_param());
+ }
+ if (from.has_prior_box_param()) {
+ mutable_prior_box_param()->::caffe::PriorBoxParameter::MergeFrom(from.prior_box_param());
+ }
+ }
+ if (from._has_bits_[48 / 32] & (0xffu << (48 % 32))) {
+ if (from.has_python_param()) {
+ mutable_python_param()->::caffe::PythonParameter::MergeFrom(from.python_param());
+ }
+ if (from.has_recurrent_param()) {
+ mutable_recurrent_param()->::caffe::RecurrentParameter::MergeFrom(from.recurrent_param());
+ }
+ if (from.has_reduction_param()) {
+ mutable_reduction_param()->::caffe::ReductionParameter::MergeFrom(from.reduction_param());
+ }
+ if (from.has_relu_param()) {
+ mutable_relu_param()->::caffe::ReLUParameter::MergeFrom(from.relu_param());
+ }
+ if (from.has_reshape_param()) {
+ mutable_reshape_param()->::caffe::ReshapeParameter::MergeFrom(from.reshape_param());
+ }
+ if (from.has_scale_param()) {
+ mutable_scale_param()->::caffe::ScaleParameter::MergeFrom(from.scale_param());
+ }
+ if (from.has_sigmoid_param()) {
+ mutable_sigmoid_param()->::caffe::SigmoidParameter::MergeFrom(from.sigmoid_param());
+ }
+ if (from.has_softmax_param()) {
+ mutable_softmax_param()->::caffe::SoftmaxParameter::MergeFrom(from.softmax_param());
+ }
+ }
+ if (from._has_bits_[56 / 32] & (0xffu << (56 % 32))) {
+ if (from.has_spp_param()) {
+ mutable_spp_param()->::caffe::SPPParameter::MergeFrom(from.spp_param());
+ }
+ if (from.has_slice_param()) {
+ mutable_slice_param()->::caffe::SliceParameter::MergeFrom(from.slice_param());
+ }
+ if (from.has_tanh_param()) {
+ mutable_tanh_param()->::caffe::TanHParameter::MergeFrom(from.tanh_param());
+ }
+ if (from.has_threshold_param()) {
+ mutable_threshold_param()->::caffe::ThresholdParameter::MergeFrom(from.threshold_param());
+ }
+ if (from.has_tile_param()) {
+ mutable_tile_param()->::caffe::TileParameter::MergeFrom(from.tile_param());
+ }
+ if (from.has_window_data_param()) {
+ mutable_window_data_param()->::caffe::WindowDataParameter::MergeFrom(from.window_data_param());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void LayerParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.LayerParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void LayerParameter::CopyFrom(const LayerParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.LayerParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool LayerParameter::IsInitialized() const {
+
+ return true;
+}
+
+void LayerParameter::Swap(LayerParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void LayerParameter::InternalSwap(LayerParameter* other) {
+ name_.Swap(&other->name_);
+ type_.Swap(&other->type_);
+ bottom_.UnsafeArenaSwap(&other->bottom_);
+ top_.UnsafeArenaSwap(&other->top_);
+ std::swap(phase_, other->phase_);
+ loss_weight_.UnsafeArenaSwap(&other->loss_weight_);
+ param_.UnsafeArenaSwap(&other->param_);
+ blobs_.UnsafeArenaSwap(&other->blobs_);
+ propagate_down_.UnsafeArenaSwap(&other->propagate_down_);
+ include_.UnsafeArenaSwap(&other->include_);
+ exclude_.UnsafeArenaSwap(&other->exclude_);
+ std::swap(transform_param_, other->transform_param_);
+ std::swap(loss_param_, other->loss_param_);
+ std::swap(accuracy_param_, other->accuracy_param_);
+ std::swap(argmax_param_, other->argmax_param_);
+ std::swap(batch_norm_param_, other->batch_norm_param_);
+ std::swap(bias_param_, other->bias_param_);
+ std::swap(concat_param_, other->concat_param_);
+ std::swap(contrastive_loss_param_, other->contrastive_loss_param_);
+ std::swap(convolution_param_, other->convolution_param_);
+ std::swap(crop_param_, other->crop_param_);
+ std::swap(data_param_, other->data_param_);
+ std::swap(detection_output_param_, other->detection_output_param_);
+ std::swap(dropout_param_, other->dropout_param_);
+ std::swap(dummy_data_param_, other->dummy_data_param_);
+ std::swap(eltwise_param_, other->eltwise_param_);
+ std::swap(elu_param_, other->elu_param_);
+ std::swap(embed_param_, other->embed_param_);
+ std::swap(exp_param_, other->exp_param_);
+ std::swap(flatten_param_, other->flatten_param_);
+ std::swap(hdf5_data_param_, other->hdf5_data_param_);
+ std::swap(hdf5_output_param_, other->hdf5_output_param_);
+ std::swap(hinge_loss_param_, other->hinge_loss_param_);
+ std::swap(image_data_param_, other->image_data_param_);
+ std::swap(infogain_loss_param_, other->infogain_loss_param_);
+ std::swap(inner_product_param_, other->inner_product_param_);
+ std::swap(input_param_, other->input_param_);
+ std::swap(log_param_, other->log_param_);
+ std::swap(lrn_param_, other->lrn_param_);
+ std::swap(memory_data_param_, other->memory_data_param_);
+ std::swap(mvn_param_, other->mvn_param_);
+ std::swap(norm_param_, other->norm_param_);
+ std::swap(permute_param_, other->permute_param_);
+ std::swap(parameter_param_, other->parameter_param_);
+ std::swap(pooling_param_, other->pooling_param_);
+ std::swap(power_param_, other->power_param_);
+ std::swap(prelu_param_, other->prelu_param_);
+ std::swap(prior_box_param_, other->prior_box_param_);
+ std::swap(python_param_, other->python_param_);
+ std::swap(recurrent_param_, other->recurrent_param_);
+ std::swap(reduction_param_, other->reduction_param_);
+ std::swap(relu_param_, other->relu_param_);
+ std::swap(reshape_param_, other->reshape_param_);
+ std::swap(scale_param_, other->scale_param_);
+ std::swap(sigmoid_param_, other->sigmoid_param_);
+ std::swap(softmax_param_, other->softmax_param_);
+ std::swap(spp_param_, other->spp_param_);
+ std::swap(slice_param_, other->slice_param_);
+ std::swap(tanh_param_, other->tanh_param_);
+ std::swap(threshold_param_, other->threshold_param_);
+ std::swap(tile_param_, other->tile_param_);
+ std::swap(window_data_param_, other->window_data_param_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ std::swap(_has_bits_[1], other->_has_bits_[1]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata LayerParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = LayerParameter_descriptor_;
+ metadata.reflection = LayerParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// LayerParameter
+
+// optional string name = 1;
+bool LayerParameter::has_name() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void LayerParameter::set_has_name() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void LayerParameter::clear_has_name() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void LayerParameter::clear_name() {
+ name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_name();
+}
+const ::std::string& LayerParameter::name() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.name)
+ return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void LayerParameter::set_name(const ::std::string& value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.LayerParameter.name)
+}
+void LayerParameter::set_name(const char* value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.LayerParameter.name)
+}
+void LayerParameter::set_name(const char* value, size_t size) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.LayerParameter.name)
+}
+::std::string* LayerParameter::mutable_name() {
+ set_has_name();
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.name)
+ return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* LayerParameter::release_name() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.name)
+ clear_has_name();
+ return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void LayerParameter::set_allocated_name(::std::string* name) {
+ if (name != NULL) {
+ set_has_name();
+ } else {
+ clear_has_name();
+ }
+ name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.name)
+}
+
+// optional string type = 2;
+bool LayerParameter::has_type() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void LayerParameter::set_has_type() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void LayerParameter::clear_has_type() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void LayerParameter::clear_type() {
+ type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_type();
+}
+const ::std::string& LayerParameter::type() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.type)
+ return type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void LayerParameter::set_type(const ::std::string& value) {
+ set_has_type();
+ type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.LayerParameter.type)
+}
+void LayerParameter::set_type(const char* value) {
+ set_has_type();
+ type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.LayerParameter.type)
+}
+void LayerParameter::set_type(const char* value, size_t size) {
+ set_has_type();
+ type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.LayerParameter.type)
+}
+::std::string* LayerParameter::mutable_type() {
+ set_has_type();
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.type)
+ return type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* LayerParameter::release_type() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.type)
+ clear_has_type();
+ return type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void LayerParameter::set_allocated_type(::std::string* type) {
+ if (type != NULL) {
+ set_has_type();
+ } else {
+ clear_has_type();
+ }
+ type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type);
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.type)
+}
+
+// repeated string bottom = 3;
+int LayerParameter::bottom_size() const {
+ return bottom_.size();
+}
+void LayerParameter::clear_bottom() {
+ bottom_.Clear();
+}
+const ::std::string& LayerParameter::bottom(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.bottom)
+ return bottom_.Get(index);
+}
+::std::string* LayerParameter::mutable_bottom(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.bottom)
+ return bottom_.Mutable(index);
+}
+void LayerParameter::set_bottom(int index, const ::std::string& value) {
+ // @@protoc_insertion_point(field_set:caffe.LayerParameter.bottom)
+ bottom_.Mutable(index)->assign(value);
+}
+void LayerParameter::set_bottom(int index, const char* value) {
+ bottom_.Mutable(index)->assign(value);
+ // @@protoc_insertion_point(field_set_char:caffe.LayerParameter.bottom)
+}
+void LayerParameter::set_bottom(int index, const char* value, size_t size) {
+ bottom_.Mutable(index)->assign(
+ reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_set_pointer:caffe.LayerParameter.bottom)
+}
+::std::string* LayerParameter::add_bottom() {
+ // @@protoc_insertion_point(field_add_mutable:caffe.LayerParameter.bottom)
+ return bottom_.Add();
+}
+void LayerParameter::add_bottom(const ::std::string& value) {
+ bottom_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add:caffe.LayerParameter.bottom)
+}
+void LayerParameter::add_bottom(const char* value) {
+ bottom_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add_char:caffe.LayerParameter.bottom)
+}
+void LayerParameter::add_bottom(const char* value, size_t size) {
+ bottom_.Add()->assign(reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_add_pointer:caffe.LayerParameter.bottom)
+}
+const ::google::protobuf::RepeatedPtrField< ::std::string>&
+LayerParameter::bottom() const {
+ // @@protoc_insertion_point(field_list:caffe.LayerParameter.bottom)
+ return bottom_;
+}
+::google::protobuf::RepeatedPtrField< ::std::string>*
+LayerParameter::mutable_bottom() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.bottom)
+ return &bottom_;
+}
+
+// repeated string top = 4;
+int LayerParameter::top_size() const {
+ return top_.size();
+}
+void LayerParameter::clear_top() {
+ top_.Clear();
+}
+const ::std::string& LayerParameter::top(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.top)
+ return top_.Get(index);
+}
+::std::string* LayerParameter::mutable_top(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.top)
+ return top_.Mutable(index);
+}
+void LayerParameter::set_top(int index, const ::std::string& value) {
+ // @@protoc_insertion_point(field_set:caffe.LayerParameter.top)
+ top_.Mutable(index)->assign(value);
+}
+void LayerParameter::set_top(int index, const char* value) {
+ top_.Mutable(index)->assign(value);
+ // @@protoc_insertion_point(field_set_char:caffe.LayerParameter.top)
+}
+void LayerParameter::set_top(int index, const char* value, size_t size) {
+ top_.Mutable(index)->assign(
+ reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_set_pointer:caffe.LayerParameter.top)
+}
+::std::string* LayerParameter::add_top() {
+ // @@protoc_insertion_point(field_add_mutable:caffe.LayerParameter.top)
+ return top_.Add();
+}
+void LayerParameter::add_top(const ::std::string& value) {
+ top_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add:caffe.LayerParameter.top)
+}
+void LayerParameter::add_top(const char* value) {
+ top_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add_char:caffe.LayerParameter.top)
+}
+void LayerParameter::add_top(const char* value, size_t size) {
+ top_.Add()->assign(reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_add_pointer:caffe.LayerParameter.top)
+}
+const ::google::protobuf::RepeatedPtrField< ::std::string>&
+LayerParameter::top() const {
+ // @@protoc_insertion_point(field_list:caffe.LayerParameter.top)
+ return top_;
+}
+::google::protobuf::RepeatedPtrField< ::std::string>*
+LayerParameter::mutable_top() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.top)
+ return &top_;
+}
+
+// optional .caffe.Phase phase = 10;
+bool LayerParameter::has_phase() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+void LayerParameter::set_has_phase() {
+ _has_bits_[0] |= 0x00000010u;
+}
+void LayerParameter::clear_has_phase() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+void LayerParameter::clear_phase() {
+ phase_ = 0;
+ clear_has_phase();
+}
+::caffe::Phase LayerParameter::phase() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.phase)
+ return static_cast< ::caffe::Phase >(phase_);
+}
+void LayerParameter::set_phase(::caffe::Phase value) {
+ assert(::caffe::Phase_IsValid(value));
+ set_has_phase();
+ phase_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LayerParameter.phase)
+}
+
+// repeated float loss_weight = 5;
+int LayerParameter::loss_weight_size() const {
+ return loss_weight_.size();
+}
+void LayerParameter::clear_loss_weight() {
+ loss_weight_.Clear();
+}
+float LayerParameter::loss_weight(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.loss_weight)
+ return loss_weight_.Get(index);
+}
+void LayerParameter::set_loss_weight(int index, float value) {
+ loss_weight_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.LayerParameter.loss_weight)
+}
+void LayerParameter::add_loss_weight(float value) {
+ loss_weight_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.LayerParameter.loss_weight)
+}
+const ::google::protobuf::RepeatedField< float >&
+LayerParameter::loss_weight() const {
+ // @@protoc_insertion_point(field_list:caffe.LayerParameter.loss_weight)
+ return loss_weight_;
+}
+::google::protobuf::RepeatedField< float >*
+LayerParameter::mutable_loss_weight() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.loss_weight)
+ return &loss_weight_;
+}
+
+// repeated .caffe.ParamSpec param = 6;
+int LayerParameter::param_size() const {
+ return param_.size();
+}
+void LayerParameter::clear_param() {
+ param_.Clear();
+}
+const ::caffe::ParamSpec& LayerParameter::param(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.param)
+ return param_.Get(index);
+}
+::caffe::ParamSpec* LayerParameter::mutable_param(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.param)
+ return param_.Mutable(index);
+}
+::caffe::ParamSpec* LayerParameter::add_param() {
+ // @@protoc_insertion_point(field_add:caffe.LayerParameter.param)
+ return param_.Add();
+}
+::google::protobuf::RepeatedPtrField< ::caffe::ParamSpec >*
+LayerParameter::mutable_param() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.param)
+ return ¶m_;
+}
+const ::google::protobuf::RepeatedPtrField< ::caffe::ParamSpec >&
+LayerParameter::param() const {
+ // @@protoc_insertion_point(field_list:caffe.LayerParameter.param)
+ return param_;
+}
+
+// repeated .caffe.BlobProto blobs = 7;
+int LayerParameter::blobs_size() const {
+ return blobs_.size();
+}
+void LayerParameter::clear_blobs() {
+ blobs_.Clear();
+}
+const ::caffe::BlobProto& LayerParameter::blobs(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.blobs)
+ return blobs_.Get(index);
+}
+::caffe::BlobProto* LayerParameter::mutable_blobs(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.blobs)
+ return blobs_.Mutable(index);
+}
+::caffe::BlobProto* LayerParameter::add_blobs() {
+ // @@protoc_insertion_point(field_add:caffe.LayerParameter.blobs)
+ return blobs_.Add();
+}
+::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
+LayerParameter::mutable_blobs() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.blobs)
+ return &blobs_;
+}
+const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
+LayerParameter::blobs() const {
+ // @@protoc_insertion_point(field_list:caffe.LayerParameter.blobs)
+ return blobs_;
+}
+
+// repeated bool propagate_down = 11;
+int LayerParameter::propagate_down_size() const {
+ return propagate_down_.size();
+}
+void LayerParameter::clear_propagate_down() {
+ propagate_down_.Clear();
+}
+bool LayerParameter::propagate_down(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.propagate_down)
+ return propagate_down_.Get(index);
+}
+void LayerParameter::set_propagate_down(int index, bool value) {
+ propagate_down_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.LayerParameter.propagate_down)
+}
+void LayerParameter::add_propagate_down(bool value) {
+ propagate_down_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.LayerParameter.propagate_down)
+}
+const ::google::protobuf::RepeatedField< bool >&
+LayerParameter::propagate_down() const {
+ // @@protoc_insertion_point(field_list:caffe.LayerParameter.propagate_down)
+ return propagate_down_;
+}
+::google::protobuf::RepeatedField< bool >*
+LayerParameter::mutable_propagate_down() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.propagate_down)
+ return &propagate_down_;
+}
+
+// repeated .caffe.NetStateRule include = 8;
+int LayerParameter::include_size() const {
+ return include_.size();
+}
+void LayerParameter::clear_include() {
+ include_.Clear();
+}
+const ::caffe::NetStateRule& LayerParameter::include(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.include)
+ return include_.Get(index);
+}
+::caffe::NetStateRule* LayerParameter::mutable_include(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.include)
+ return include_.Mutable(index);
+}
+::caffe::NetStateRule* LayerParameter::add_include() {
+ // @@protoc_insertion_point(field_add:caffe.LayerParameter.include)
+ return include_.Add();
+}
+::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >*
+LayerParameter::mutable_include() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.include)
+ return &include_;
+}
+const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >&
+LayerParameter::include() const {
+ // @@protoc_insertion_point(field_list:caffe.LayerParameter.include)
+ return include_;
+}
+
+// repeated .caffe.NetStateRule exclude = 9;
+int LayerParameter::exclude_size() const {
+ return exclude_.size();
+}
+void LayerParameter::clear_exclude() {
+ exclude_.Clear();
+}
+const ::caffe::NetStateRule& LayerParameter::exclude(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.exclude)
+ return exclude_.Get(index);
+}
+::caffe::NetStateRule* LayerParameter::mutable_exclude(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.exclude)
+ return exclude_.Mutable(index);
+}
+::caffe::NetStateRule* LayerParameter::add_exclude() {
+ // @@protoc_insertion_point(field_add:caffe.LayerParameter.exclude)
+ return exclude_.Add();
+}
+::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >*
+LayerParameter::mutable_exclude() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.exclude)
+ return &exclude_;
+}
+const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >&
+LayerParameter::exclude() const {
+ // @@protoc_insertion_point(field_list:caffe.LayerParameter.exclude)
+ return exclude_;
+}
+
+// optional .caffe.TransformationParameter transform_param = 100;
+bool LayerParameter::has_transform_param() const {
+ return (_has_bits_[0] & 0x00000800u) != 0;
+}
+void LayerParameter::set_has_transform_param() {
+ _has_bits_[0] |= 0x00000800u;
+}
+void LayerParameter::clear_has_transform_param() {
+ _has_bits_[0] &= ~0x00000800u;
+}
+void LayerParameter::clear_transform_param() {
+ if (transform_param_ != NULL) transform_param_->::caffe::TransformationParameter::Clear();
+ clear_has_transform_param();
+}
+const ::caffe::TransformationParameter& LayerParameter::transform_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.transform_param)
+ return transform_param_ != NULL ? *transform_param_
+ : *::caffe::TransformationParameter::internal_default_instance();
+}
+::caffe::TransformationParameter* LayerParameter::mutable_transform_param() {
+ set_has_transform_param();
+ if (transform_param_ == NULL) {
+ transform_param_ = new ::caffe::TransformationParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.transform_param)
+ return transform_param_;
+}
+::caffe::TransformationParameter* LayerParameter::release_transform_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.transform_param)
+ clear_has_transform_param();
+ ::caffe::TransformationParameter* temp = transform_param_;
+ transform_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_transform_param(::caffe::TransformationParameter* transform_param) {
+ delete transform_param_;
+ transform_param_ = transform_param;
+ if (transform_param) {
+ set_has_transform_param();
+ } else {
+ clear_has_transform_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.transform_param)
+}
+
+// optional .caffe.LossParameter loss_param = 101;
+bool LayerParameter::has_loss_param() const {
+ return (_has_bits_[0] & 0x00001000u) != 0;
+}
+void LayerParameter::set_has_loss_param() {
+ _has_bits_[0] |= 0x00001000u;
+}
+void LayerParameter::clear_has_loss_param() {
+ _has_bits_[0] &= ~0x00001000u;
+}
+void LayerParameter::clear_loss_param() {
+ if (loss_param_ != NULL) loss_param_->::caffe::LossParameter::Clear();
+ clear_has_loss_param();
+}
+const ::caffe::LossParameter& LayerParameter::loss_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.loss_param)
+ return loss_param_ != NULL ? *loss_param_
+ : *::caffe::LossParameter::internal_default_instance();
+}
+::caffe::LossParameter* LayerParameter::mutable_loss_param() {
+ set_has_loss_param();
+ if (loss_param_ == NULL) {
+ loss_param_ = new ::caffe::LossParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.loss_param)
+ return loss_param_;
+}
+::caffe::LossParameter* LayerParameter::release_loss_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.loss_param)
+ clear_has_loss_param();
+ ::caffe::LossParameter* temp = loss_param_;
+ loss_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_loss_param(::caffe::LossParameter* loss_param) {
+ delete loss_param_;
+ loss_param_ = loss_param;
+ if (loss_param) {
+ set_has_loss_param();
+ } else {
+ clear_has_loss_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.loss_param)
+}
+
+// optional .caffe.AccuracyParameter accuracy_param = 102;
+bool LayerParameter::has_accuracy_param() const {
+ return (_has_bits_[0] & 0x00002000u) != 0;
+}
+void LayerParameter::set_has_accuracy_param() {
+ _has_bits_[0] |= 0x00002000u;
+}
+void LayerParameter::clear_has_accuracy_param() {
+ _has_bits_[0] &= ~0x00002000u;
+}
+void LayerParameter::clear_accuracy_param() {
+ if (accuracy_param_ != NULL) accuracy_param_->::caffe::AccuracyParameter::Clear();
+ clear_has_accuracy_param();
+}
+const ::caffe::AccuracyParameter& LayerParameter::accuracy_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.accuracy_param)
+ return accuracy_param_ != NULL ? *accuracy_param_
+ : *::caffe::AccuracyParameter::internal_default_instance();
+}
+::caffe::AccuracyParameter* LayerParameter::mutable_accuracy_param() {
+ set_has_accuracy_param();
+ if (accuracy_param_ == NULL) {
+ accuracy_param_ = new ::caffe::AccuracyParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.accuracy_param)
+ return accuracy_param_;
+}
+::caffe::AccuracyParameter* LayerParameter::release_accuracy_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.accuracy_param)
+ clear_has_accuracy_param();
+ ::caffe::AccuracyParameter* temp = accuracy_param_;
+ accuracy_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_accuracy_param(::caffe::AccuracyParameter* accuracy_param) {
+ delete accuracy_param_;
+ accuracy_param_ = accuracy_param;
+ if (accuracy_param) {
+ set_has_accuracy_param();
+ } else {
+ clear_has_accuracy_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.accuracy_param)
+}
+
+// optional .caffe.ArgMaxParameter argmax_param = 103;
+bool LayerParameter::has_argmax_param() const {
+ return (_has_bits_[0] & 0x00004000u) != 0;
+}
+void LayerParameter::set_has_argmax_param() {
+ _has_bits_[0] |= 0x00004000u;
+}
+void LayerParameter::clear_has_argmax_param() {
+ _has_bits_[0] &= ~0x00004000u;
+}
+void LayerParameter::clear_argmax_param() {
+ if (argmax_param_ != NULL) argmax_param_->::caffe::ArgMaxParameter::Clear();
+ clear_has_argmax_param();
+}
+const ::caffe::ArgMaxParameter& LayerParameter::argmax_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.argmax_param)
+ return argmax_param_ != NULL ? *argmax_param_
+ : *::caffe::ArgMaxParameter::internal_default_instance();
+}
+::caffe::ArgMaxParameter* LayerParameter::mutable_argmax_param() {
+ set_has_argmax_param();
+ if (argmax_param_ == NULL) {
+ argmax_param_ = new ::caffe::ArgMaxParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.argmax_param)
+ return argmax_param_;
+}
+::caffe::ArgMaxParameter* LayerParameter::release_argmax_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.argmax_param)
+ clear_has_argmax_param();
+ ::caffe::ArgMaxParameter* temp = argmax_param_;
+ argmax_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_argmax_param(::caffe::ArgMaxParameter* argmax_param) {
+ delete argmax_param_;
+ argmax_param_ = argmax_param;
+ if (argmax_param) {
+ set_has_argmax_param();
+ } else {
+ clear_has_argmax_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.argmax_param)
+}
+
+// optional .caffe.BatchNormParameter batch_norm_param = 139;
+bool LayerParameter::has_batch_norm_param() const {
+ return (_has_bits_[0] & 0x00008000u) != 0;
+}
+void LayerParameter::set_has_batch_norm_param() {
+ _has_bits_[0] |= 0x00008000u;
+}
+void LayerParameter::clear_has_batch_norm_param() {
+ _has_bits_[0] &= ~0x00008000u;
+}
+void LayerParameter::clear_batch_norm_param() {
+ if (batch_norm_param_ != NULL) batch_norm_param_->::caffe::BatchNormParameter::Clear();
+ clear_has_batch_norm_param();
+}
+const ::caffe::BatchNormParameter& LayerParameter::batch_norm_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.batch_norm_param)
+ return batch_norm_param_ != NULL ? *batch_norm_param_
+ : *::caffe::BatchNormParameter::internal_default_instance();
+}
+::caffe::BatchNormParameter* LayerParameter::mutable_batch_norm_param() {
+ set_has_batch_norm_param();
+ if (batch_norm_param_ == NULL) {
+ batch_norm_param_ = new ::caffe::BatchNormParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.batch_norm_param)
+ return batch_norm_param_;
+}
+::caffe::BatchNormParameter* LayerParameter::release_batch_norm_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.batch_norm_param)
+ clear_has_batch_norm_param();
+ ::caffe::BatchNormParameter* temp = batch_norm_param_;
+ batch_norm_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_batch_norm_param(::caffe::BatchNormParameter* batch_norm_param) {
+ delete batch_norm_param_;
+ batch_norm_param_ = batch_norm_param;
+ if (batch_norm_param) {
+ set_has_batch_norm_param();
+ } else {
+ clear_has_batch_norm_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.batch_norm_param)
+}
+
+// optional .caffe.BiasParameter bias_param = 141;
+bool LayerParameter::has_bias_param() const {
+ return (_has_bits_[0] & 0x00010000u) != 0;
+}
+void LayerParameter::set_has_bias_param() {
+ _has_bits_[0] |= 0x00010000u;
+}
+void LayerParameter::clear_has_bias_param() {
+ _has_bits_[0] &= ~0x00010000u;
+}
+void LayerParameter::clear_bias_param() {
+ if (bias_param_ != NULL) bias_param_->::caffe::BiasParameter::Clear();
+ clear_has_bias_param();
+}
+const ::caffe::BiasParameter& LayerParameter::bias_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.bias_param)
+ return bias_param_ != NULL ? *bias_param_
+ : *::caffe::BiasParameter::internal_default_instance();
+}
+::caffe::BiasParameter* LayerParameter::mutable_bias_param() {
+ set_has_bias_param();
+ if (bias_param_ == NULL) {
+ bias_param_ = new ::caffe::BiasParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.bias_param)
+ return bias_param_;
+}
+::caffe::BiasParameter* LayerParameter::release_bias_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.bias_param)
+ clear_has_bias_param();
+ ::caffe::BiasParameter* temp = bias_param_;
+ bias_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_bias_param(::caffe::BiasParameter* bias_param) {
+ delete bias_param_;
+ bias_param_ = bias_param;
+ if (bias_param) {
+ set_has_bias_param();
+ } else {
+ clear_has_bias_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.bias_param)
+}
+
+// optional .caffe.ConcatParameter concat_param = 104;
+bool LayerParameter::has_concat_param() const {
+ return (_has_bits_[0] & 0x00020000u) != 0;
+}
+void LayerParameter::set_has_concat_param() {
+ _has_bits_[0] |= 0x00020000u;
+}
+void LayerParameter::clear_has_concat_param() {
+ _has_bits_[0] &= ~0x00020000u;
+}
+void LayerParameter::clear_concat_param() {
+ if (concat_param_ != NULL) concat_param_->::caffe::ConcatParameter::Clear();
+ clear_has_concat_param();
+}
+const ::caffe::ConcatParameter& LayerParameter::concat_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.concat_param)
+ return concat_param_ != NULL ? *concat_param_
+ : *::caffe::ConcatParameter::internal_default_instance();
+}
+::caffe::ConcatParameter* LayerParameter::mutable_concat_param() {
+ set_has_concat_param();
+ if (concat_param_ == NULL) {
+ concat_param_ = new ::caffe::ConcatParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.concat_param)
+ return concat_param_;
+}
+::caffe::ConcatParameter* LayerParameter::release_concat_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.concat_param)
+ clear_has_concat_param();
+ ::caffe::ConcatParameter* temp = concat_param_;
+ concat_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_concat_param(::caffe::ConcatParameter* concat_param) {
+ delete concat_param_;
+ concat_param_ = concat_param;
+ if (concat_param) {
+ set_has_concat_param();
+ } else {
+ clear_has_concat_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.concat_param)
+}
+
+// optional .caffe.ContrastiveLossParameter contrastive_loss_param = 105;
+bool LayerParameter::has_contrastive_loss_param() const {
+ return (_has_bits_[0] & 0x00040000u) != 0;
+}
+void LayerParameter::set_has_contrastive_loss_param() {
+ _has_bits_[0] |= 0x00040000u;
+}
+void LayerParameter::clear_has_contrastive_loss_param() {
+ _has_bits_[0] &= ~0x00040000u;
+}
+void LayerParameter::clear_contrastive_loss_param() {
+ if (contrastive_loss_param_ != NULL) contrastive_loss_param_->::caffe::ContrastiveLossParameter::Clear();
+ clear_has_contrastive_loss_param();
+}
+const ::caffe::ContrastiveLossParameter& LayerParameter::contrastive_loss_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.contrastive_loss_param)
+ return contrastive_loss_param_ != NULL ? *contrastive_loss_param_
+ : *::caffe::ContrastiveLossParameter::internal_default_instance();
+}
+::caffe::ContrastiveLossParameter* LayerParameter::mutable_contrastive_loss_param() {
+ set_has_contrastive_loss_param();
+ if (contrastive_loss_param_ == NULL) {
+ contrastive_loss_param_ = new ::caffe::ContrastiveLossParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.contrastive_loss_param)
+ return contrastive_loss_param_;
+}
+::caffe::ContrastiveLossParameter* LayerParameter::release_contrastive_loss_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.contrastive_loss_param)
+ clear_has_contrastive_loss_param();
+ ::caffe::ContrastiveLossParameter* temp = contrastive_loss_param_;
+ contrastive_loss_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_contrastive_loss_param(::caffe::ContrastiveLossParameter* contrastive_loss_param) {
+ delete contrastive_loss_param_;
+ contrastive_loss_param_ = contrastive_loss_param;
+ if (contrastive_loss_param) {
+ set_has_contrastive_loss_param();
+ } else {
+ clear_has_contrastive_loss_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.contrastive_loss_param)
+}
+
+// optional .caffe.ConvolutionParameter convolution_param = 106;
+bool LayerParameter::has_convolution_param() const {
+ return (_has_bits_[0] & 0x00080000u) != 0;
+}
+void LayerParameter::set_has_convolution_param() {
+ _has_bits_[0] |= 0x00080000u;
+}
+void LayerParameter::clear_has_convolution_param() {
+ _has_bits_[0] &= ~0x00080000u;
+}
+void LayerParameter::clear_convolution_param() {
+ if (convolution_param_ != NULL) convolution_param_->::caffe::ConvolutionParameter::Clear();
+ clear_has_convolution_param();
+}
+const ::caffe::ConvolutionParameter& LayerParameter::convolution_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.convolution_param)
+ return convolution_param_ != NULL ? *convolution_param_
+ : *::caffe::ConvolutionParameter::internal_default_instance();
+}
+::caffe::ConvolutionParameter* LayerParameter::mutable_convolution_param() {
+ set_has_convolution_param();
+ if (convolution_param_ == NULL) {
+ convolution_param_ = new ::caffe::ConvolutionParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.convolution_param)
+ return convolution_param_;
+}
+::caffe::ConvolutionParameter* LayerParameter::release_convolution_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.convolution_param)
+ clear_has_convolution_param();
+ ::caffe::ConvolutionParameter* temp = convolution_param_;
+ convolution_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_convolution_param(::caffe::ConvolutionParameter* convolution_param) {
+ delete convolution_param_;
+ convolution_param_ = convolution_param;
+ if (convolution_param) {
+ set_has_convolution_param();
+ } else {
+ clear_has_convolution_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.convolution_param)
+}
+
+// optional .caffe.CropParameter crop_param = 144;
+bool LayerParameter::has_crop_param() const {
+ return (_has_bits_[0] & 0x00100000u) != 0;
+}
+void LayerParameter::set_has_crop_param() {
+ _has_bits_[0] |= 0x00100000u;
+}
+void LayerParameter::clear_has_crop_param() {
+ _has_bits_[0] &= ~0x00100000u;
+}
+void LayerParameter::clear_crop_param() {
+ if (crop_param_ != NULL) crop_param_->::caffe::CropParameter::Clear();
+ clear_has_crop_param();
+}
+const ::caffe::CropParameter& LayerParameter::crop_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.crop_param)
+ return crop_param_ != NULL ? *crop_param_
+ : *::caffe::CropParameter::internal_default_instance();
+}
+::caffe::CropParameter* LayerParameter::mutable_crop_param() {
+ set_has_crop_param();
+ if (crop_param_ == NULL) {
+ crop_param_ = new ::caffe::CropParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.crop_param)
+ return crop_param_;
+}
+::caffe::CropParameter* LayerParameter::release_crop_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.crop_param)
+ clear_has_crop_param();
+ ::caffe::CropParameter* temp = crop_param_;
+ crop_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_crop_param(::caffe::CropParameter* crop_param) {
+ delete crop_param_;
+ crop_param_ = crop_param;
+ if (crop_param) {
+ set_has_crop_param();
+ } else {
+ clear_has_crop_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.crop_param)
+}
+
+// optional .caffe.DataParameter data_param = 107;
+bool LayerParameter::has_data_param() const {
+ return (_has_bits_[0] & 0x00200000u) != 0;
+}
+void LayerParameter::set_has_data_param() {
+ _has_bits_[0] |= 0x00200000u;
+}
+void LayerParameter::clear_has_data_param() {
+ _has_bits_[0] &= ~0x00200000u;
+}
+void LayerParameter::clear_data_param() {
+ if (data_param_ != NULL) data_param_->::caffe::DataParameter::Clear();
+ clear_has_data_param();
+}
+const ::caffe::DataParameter& LayerParameter::data_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.data_param)
+ return data_param_ != NULL ? *data_param_
+ : *::caffe::DataParameter::internal_default_instance();
+}
+::caffe::DataParameter* LayerParameter::mutable_data_param() {
+ set_has_data_param();
+ if (data_param_ == NULL) {
+ data_param_ = new ::caffe::DataParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.data_param)
+ return data_param_;
+}
+::caffe::DataParameter* LayerParameter::release_data_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.data_param)
+ clear_has_data_param();
+ ::caffe::DataParameter* temp = data_param_;
+ data_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_data_param(::caffe::DataParameter* data_param) {
+ delete data_param_;
+ data_param_ = data_param;
+ if (data_param) {
+ set_has_data_param();
+ } else {
+ clear_has_data_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.data_param)
+}
+
+// optional .caffe.DetectionOutputParameter detection_output_param = 147;
+bool LayerParameter::has_detection_output_param() const {
+ return (_has_bits_[0] & 0x00400000u) != 0;
+}
+void LayerParameter::set_has_detection_output_param() {
+ _has_bits_[0] |= 0x00400000u;
+}
+void LayerParameter::clear_has_detection_output_param() {
+ _has_bits_[0] &= ~0x00400000u;
+}
+void LayerParameter::clear_detection_output_param() {
+ if (detection_output_param_ != NULL) detection_output_param_->::caffe::DetectionOutputParameter::Clear();
+ clear_has_detection_output_param();
+}
+const ::caffe::DetectionOutputParameter& LayerParameter::detection_output_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.detection_output_param)
+ return detection_output_param_ != NULL ? *detection_output_param_
+ : *::caffe::DetectionOutputParameter::internal_default_instance();
+}
+::caffe::DetectionOutputParameter* LayerParameter::mutable_detection_output_param() {
+ set_has_detection_output_param();
+ if (detection_output_param_ == NULL) {
+ detection_output_param_ = new ::caffe::DetectionOutputParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.detection_output_param)
+ return detection_output_param_;
+}
+::caffe::DetectionOutputParameter* LayerParameter::release_detection_output_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.detection_output_param)
+ clear_has_detection_output_param();
+ ::caffe::DetectionOutputParameter* temp = detection_output_param_;
+ detection_output_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_detection_output_param(::caffe::DetectionOutputParameter* detection_output_param) {
+ delete detection_output_param_;
+ detection_output_param_ = detection_output_param;
+ if (detection_output_param) {
+ set_has_detection_output_param();
+ } else {
+ clear_has_detection_output_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.detection_output_param)
+}
+
+// optional .caffe.DropoutParameter dropout_param = 108;
+bool LayerParameter::has_dropout_param() const {
+ return (_has_bits_[0] & 0x00800000u) != 0;
+}
+void LayerParameter::set_has_dropout_param() {
+ _has_bits_[0] |= 0x00800000u;
+}
+void LayerParameter::clear_has_dropout_param() {
+ _has_bits_[0] &= ~0x00800000u;
+}
+void LayerParameter::clear_dropout_param() {
+ if (dropout_param_ != NULL) dropout_param_->::caffe::DropoutParameter::Clear();
+ clear_has_dropout_param();
+}
+const ::caffe::DropoutParameter& LayerParameter::dropout_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.dropout_param)
+ return dropout_param_ != NULL ? *dropout_param_
+ : *::caffe::DropoutParameter::internal_default_instance();
+}
+::caffe::DropoutParameter* LayerParameter::mutable_dropout_param() {
+ set_has_dropout_param();
+ if (dropout_param_ == NULL) {
+ dropout_param_ = new ::caffe::DropoutParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.dropout_param)
+ return dropout_param_;
+}
+::caffe::DropoutParameter* LayerParameter::release_dropout_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.dropout_param)
+ clear_has_dropout_param();
+ ::caffe::DropoutParameter* temp = dropout_param_;
+ dropout_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_dropout_param(::caffe::DropoutParameter* dropout_param) {
+ delete dropout_param_;
+ dropout_param_ = dropout_param;
+ if (dropout_param) {
+ set_has_dropout_param();
+ } else {
+ clear_has_dropout_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.dropout_param)
+}
+
+// optional .caffe.DummyDataParameter dummy_data_param = 109;
+bool LayerParameter::has_dummy_data_param() const {
+ return (_has_bits_[0] & 0x01000000u) != 0;
+}
+void LayerParameter::set_has_dummy_data_param() {
+ _has_bits_[0] |= 0x01000000u;
+}
+void LayerParameter::clear_has_dummy_data_param() {
+ _has_bits_[0] &= ~0x01000000u;
+}
+void LayerParameter::clear_dummy_data_param() {
+ if (dummy_data_param_ != NULL) dummy_data_param_->::caffe::DummyDataParameter::Clear();
+ clear_has_dummy_data_param();
+}
+const ::caffe::DummyDataParameter& LayerParameter::dummy_data_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.dummy_data_param)
+ return dummy_data_param_ != NULL ? *dummy_data_param_
+ : *::caffe::DummyDataParameter::internal_default_instance();
+}
+::caffe::DummyDataParameter* LayerParameter::mutable_dummy_data_param() {
+ set_has_dummy_data_param();
+ if (dummy_data_param_ == NULL) {
+ dummy_data_param_ = new ::caffe::DummyDataParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.dummy_data_param)
+ return dummy_data_param_;
+}
+::caffe::DummyDataParameter* LayerParameter::release_dummy_data_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.dummy_data_param)
+ clear_has_dummy_data_param();
+ ::caffe::DummyDataParameter* temp = dummy_data_param_;
+ dummy_data_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_dummy_data_param(::caffe::DummyDataParameter* dummy_data_param) {
+ delete dummy_data_param_;
+ dummy_data_param_ = dummy_data_param;
+ if (dummy_data_param) {
+ set_has_dummy_data_param();
+ } else {
+ clear_has_dummy_data_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.dummy_data_param)
+}
+
+// optional .caffe.EltwiseParameter eltwise_param = 110;
+bool LayerParameter::has_eltwise_param() const {
+ return (_has_bits_[0] & 0x02000000u) != 0;
+}
+void LayerParameter::set_has_eltwise_param() {
+ _has_bits_[0] |= 0x02000000u;
+}
+void LayerParameter::clear_has_eltwise_param() {
+ _has_bits_[0] &= ~0x02000000u;
+}
+void LayerParameter::clear_eltwise_param() {
+ if (eltwise_param_ != NULL) eltwise_param_->::caffe::EltwiseParameter::Clear();
+ clear_has_eltwise_param();
+}
+const ::caffe::EltwiseParameter& LayerParameter::eltwise_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.eltwise_param)
+ return eltwise_param_ != NULL ? *eltwise_param_
+ : *::caffe::EltwiseParameter::internal_default_instance();
+}
+::caffe::EltwiseParameter* LayerParameter::mutable_eltwise_param() {
+ set_has_eltwise_param();
+ if (eltwise_param_ == NULL) {
+ eltwise_param_ = new ::caffe::EltwiseParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.eltwise_param)
+ return eltwise_param_;
+}
+::caffe::EltwiseParameter* LayerParameter::release_eltwise_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.eltwise_param)
+ clear_has_eltwise_param();
+ ::caffe::EltwiseParameter* temp = eltwise_param_;
+ eltwise_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_eltwise_param(::caffe::EltwiseParameter* eltwise_param) {
+ delete eltwise_param_;
+ eltwise_param_ = eltwise_param;
+ if (eltwise_param) {
+ set_has_eltwise_param();
+ } else {
+ clear_has_eltwise_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.eltwise_param)
+}
+
+// optional .caffe.ELUParameter elu_param = 140;
+bool LayerParameter::has_elu_param() const {
+ return (_has_bits_[0] & 0x04000000u) != 0;
+}
+void LayerParameter::set_has_elu_param() {
+ _has_bits_[0] |= 0x04000000u;
+}
+void LayerParameter::clear_has_elu_param() {
+ _has_bits_[0] &= ~0x04000000u;
+}
+void LayerParameter::clear_elu_param() {
+ if (elu_param_ != NULL) elu_param_->::caffe::ELUParameter::Clear();
+ clear_has_elu_param();
+}
+const ::caffe::ELUParameter& LayerParameter::elu_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.elu_param)
+ return elu_param_ != NULL ? *elu_param_
+ : *::caffe::ELUParameter::internal_default_instance();
+}
+::caffe::ELUParameter* LayerParameter::mutable_elu_param() {
+ set_has_elu_param();
+ if (elu_param_ == NULL) {
+ elu_param_ = new ::caffe::ELUParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.elu_param)
+ return elu_param_;
+}
+::caffe::ELUParameter* LayerParameter::release_elu_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.elu_param)
+ clear_has_elu_param();
+ ::caffe::ELUParameter* temp = elu_param_;
+ elu_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_elu_param(::caffe::ELUParameter* elu_param) {
+ delete elu_param_;
+ elu_param_ = elu_param;
+ if (elu_param) {
+ set_has_elu_param();
+ } else {
+ clear_has_elu_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.elu_param)
+}
+
+// optional .caffe.EmbedParameter embed_param = 137;
+bool LayerParameter::has_embed_param() const {
+ return (_has_bits_[0] & 0x08000000u) != 0;
+}
+void LayerParameter::set_has_embed_param() {
+ _has_bits_[0] |= 0x08000000u;
+}
+void LayerParameter::clear_has_embed_param() {
+ _has_bits_[0] &= ~0x08000000u;
+}
+void LayerParameter::clear_embed_param() {
+ if (embed_param_ != NULL) embed_param_->::caffe::EmbedParameter::Clear();
+ clear_has_embed_param();
+}
+const ::caffe::EmbedParameter& LayerParameter::embed_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.embed_param)
+ return embed_param_ != NULL ? *embed_param_
+ : *::caffe::EmbedParameter::internal_default_instance();
+}
+::caffe::EmbedParameter* LayerParameter::mutable_embed_param() {
+ set_has_embed_param();
+ if (embed_param_ == NULL) {
+ embed_param_ = new ::caffe::EmbedParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.embed_param)
+ return embed_param_;
+}
+::caffe::EmbedParameter* LayerParameter::release_embed_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.embed_param)
+ clear_has_embed_param();
+ ::caffe::EmbedParameter* temp = embed_param_;
+ embed_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_embed_param(::caffe::EmbedParameter* embed_param) {
+ delete embed_param_;
+ embed_param_ = embed_param;
+ if (embed_param) {
+ set_has_embed_param();
+ } else {
+ clear_has_embed_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.embed_param)
+}
+
+// optional .caffe.ExpParameter exp_param = 111;
+bool LayerParameter::has_exp_param() const {
+ return (_has_bits_[0] & 0x10000000u) != 0;
+}
+void LayerParameter::set_has_exp_param() {
+ _has_bits_[0] |= 0x10000000u;
+}
+void LayerParameter::clear_has_exp_param() {
+ _has_bits_[0] &= ~0x10000000u;
+}
+void LayerParameter::clear_exp_param() {
+ if (exp_param_ != NULL) exp_param_->::caffe::ExpParameter::Clear();
+ clear_has_exp_param();
+}
+const ::caffe::ExpParameter& LayerParameter::exp_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.exp_param)
+ return exp_param_ != NULL ? *exp_param_
+ : *::caffe::ExpParameter::internal_default_instance();
+}
+::caffe::ExpParameter* LayerParameter::mutable_exp_param() {
+ set_has_exp_param();
+ if (exp_param_ == NULL) {
+ exp_param_ = new ::caffe::ExpParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.exp_param)
+ return exp_param_;
+}
+::caffe::ExpParameter* LayerParameter::release_exp_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.exp_param)
+ clear_has_exp_param();
+ ::caffe::ExpParameter* temp = exp_param_;
+ exp_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_exp_param(::caffe::ExpParameter* exp_param) {
+ delete exp_param_;
+ exp_param_ = exp_param;
+ if (exp_param) {
+ set_has_exp_param();
+ } else {
+ clear_has_exp_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.exp_param)
+}
+
+// optional .caffe.FlattenParameter flatten_param = 135;
+bool LayerParameter::has_flatten_param() const {
+ return (_has_bits_[0] & 0x20000000u) != 0;
+}
+void LayerParameter::set_has_flatten_param() {
+ _has_bits_[0] |= 0x20000000u;
+}
+void LayerParameter::clear_has_flatten_param() {
+ _has_bits_[0] &= ~0x20000000u;
+}
+void LayerParameter::clear_flatten_param() {
+ if (flatten_param_ != NULL) flatten_param_->::caffe::FlattenParameter::Clear();
+ clear_has_flatten_param();
+}
+const ::caffe::FlattenParameter& LayerParameter::flatten_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.flatten_param)
+ return flatten_param_ != NULL ? *flatten_param_
+ : *::caffe::FlattenParameter::internal_default_instance();
+}
+::caffe::FlattenParameter* LayerParameter::mutable_flatten_param() {
+ set_has_flatten_param();
+ if (flatten_param_ == NULL) {
+ flatten_param_ = new ::caffe::FlattenParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.flatten_param)
+ return flatten_param_;
+}
+::caffe::FlattenParameter* LayerParameter::release_flatten_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.flatten_param)
+ clear_has_flatten_param();
+ ::caffe::FlattenParameter* temp = flatten_param_;
+ flatten_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_flatten_param(::caffe::FlattenParameter* flatten_param) {
+ delete flatten_param_;
+ flatten_param_ = flatten_param;
+ if (flatten_param) {
+ set_has_flatten_param();
+ } else {
+ clear_has_flatten_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.flatten_param)
+}
+
+// optional .caffe.HDF5DataParameter hdf5_data_param = 112;
+bool LayerParameter::has_hdf5_data_param() const {
+ return (_has_bits_[0] & 0x40000000u) != 0;
+}
+void LayerParameter::set_has_hdf5_data_param() {
+ _has_bits_[0] |= 0x40000000u;
+}
+void LayerParameter::clear_has_hdf5_data_param() {
+ _has_bits_[0] &= ~0x40000000u;
+}
+void LayerParameter::clear_hdf5_data_param() {
+ if (hdf5_data_param_ != NULL) hdf5_data_param_->::caffe::HDF5DataParameter::Clear();
+ clear_has_hdf5_data_param();
+}
+const ::caffe::HDF5DataParameter& LayerParameter::hdf5_data_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.hdf5_data_param)
+ return hdf5_data_param_ != NULL ? *hdf5_data_param_
+ : *::caffe::HDF5DataParameter::internal_default_instance();
+}
+::caffe::HDF5DataParameter* LayerParameter::mutable_hdf5_data_param() {
+ set_has_hdf5_data_param();
+ if (hdf5_data_param_ == NULL) {
+ hdf5_data_param_ = new ::caffe::HDF5DataParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.hdf5_data_param)
+ return hdf5_data_param_;
+}
+::caffe::HDF5DataParameter* LayerParameter::release_hdf5_data_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.hdf5_data_param)
+ clear_has_hdf5_data_param();
+ ::caffe::HDF5DataParameter* temp = hdf5_data_param_;
+ hdf5_data_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_hdf5_data_param(::caffe::HDF5DataParameter* hdf5_data_param) {
+ delete hdf5_data_param_;
+ hdf5_data_param_ = hdf5_data_param;
+ if (hdf5_data_param) {
+ set_has_hdf5_data_param();
+ } else {
+ clear_has_hdf5_data_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.hdf5_data_param)
+}
+
+// optional .caffe.HDF5OutputParameter hdf5_output_param = 113;
+bool LayerParameter::has_hdf5_output_param() const {
+ return (_has_bits_[0] & 0x80000000u) != 0;
+}
+void LayerParameter::set_has_hdf5_output_param() {
+ _has_bits_[0] |= 0x80000000u;
+}
+void LayerParameter::clear_has_hdf5_output_param() {
+ _has_bits_[0] &= ~0x80000000u;
+}
+void LayerParameter::clear_hdf5_output_param() {
+ if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear();
+ clear_has_hdf5_output_param();
+}
+const ::caffe::HDF5OutputParameter& LayerParameter::hdf5_output_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.hdf5_output_param)
+ return hdf5_output_param_ != NULL ? *hdf5_output_param_
+ : *::caffe::HDF5OutputParameter::internal_default_instance();
+}
+::caffe::HDF5OutputParameter* LayerParameter::mutable_hdf5_output_param() {
+ set_has_hdf5_output_param();
+ if (hdf5_output_param_ == NULL) {
+ hdf5_output_param_ = new ::caffe::HDF5OutputParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.hdf5_output_param)
+ return hdf5_output_param_;
+}
+::caffe::HDF5OutputParameter* LayerParameter::release_hdf5_output_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.hdf5_output_param)
+ clear_has_hdf5_output_param();
+ ::caffe::HDF5OutputParameter* temp = hdf5_output_param_;
+ hdf5_output_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param) {
+ delete hdf5_output_param_;
+ hdf5_output_param_ = hdf5_output_param;
+ if (hdf5_output_param) {
+ set_has_hdf5_output_param();
+ } else {
+ clear_has_hdf5_output_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.hdf5_output_param)
+}
+
+// optional .caffe.HingeLossParameter hinge_loss_param = 114;
+bool LayerParameter::has_hinge_loss_param() const {
+ return (_has_bits_[1] & 0x00000001u) != 0;
+}
+void LayerParameter::set_has_hinge_loss_param() {
+ _has_bits_[1] |= 0x00000001u;
+}
+void LayerParameter::clear_has_hinge_loss_param() {
+ _has_bits_[1] &= ~0x00000001u;
+}
+void LayerParameter::clear_hinge_loss_param() {
+ if (hinge_loss_param_ != NULL) hinge_loss_param_->::caffe::HingeLossParameter::Clear();
+ clear_has_hinge_loss_param();
+}
+const ::caffe::HingeLossParameter& LayerParameter::hinge_loss_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.hinge_loss_param)
+ return hinge_loss_param_ != NULL ? *hinge_loss_param_
+ : *::caffe::HingeLossParameter::internal_default_instance();
+}
+::caffe::HingeLossParameter* LayerParameter::mutable_hinge_loss_param() {
+ set_has_hinge_loss_param();
+ if (hinge_loss_param_ == NULL) {
+ hinge_loss_param_ = new ::caffe::HingeLossParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.hinge_loss_param)
+ return hinge_loss_param_;
+}
+::caffe::HingeLossParameter* LayerParameter::release_hinge_loss_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.hinge_loss_param)
+ clear_has_hinge_loss_param();
+ ::caffe::HingeLossParameter* temp = hinge_loss_param_;
+ hinge_loss_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_hinge_loss_param(::caffe::HingeLossParameter* hinge_loss_param) {
+ delete hinge_loss_param_;
+ hinge_loss_param_ = hinge_loss_param;
+ if (hinge_loss_param) {
+ set_has_hinge_loss_param();
+ } else {
+ clear_has_hinge_loss_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.hinge_loss_param)
+}
+
+// optional .caffe.ImageDataParameter image_data_param = 115;
+bool LayerParameter::has_image_data_param() const {
+ return (_has_bits_[1] & 0x00000002u) != 0;
+}
+void LayerParameter::set_has_image_data_param() {
+ _has_bits_[1] |= 0x00000002u;
+}
+void LayerParameter::clear_has_image_data_param() {
+ _has_bits_[1] &= ~0x00000002u;
+}
+void LayerParameter::clear_image_data_param() {
+ if (image_data_param_ != NULL) image_data_param_->::caffe::ImageDataParameter::Clear();
+ clear_has_image_data_param();
+}
+const ::caffe::ImageDataParameter& LayerParameter::image_data_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.image_data_param)
+ return image_data_param_ != NULL ? *image_data_param_
+ : *::caffe::ImageDataParameter::internal_default_instance();
+}
+::caffe::ImageDataParameter* LayerParameter::mutable_image_data_param() {
+ set_has_image_data_param();
+ if (image_data_param_ == NULL) {
+ image_data_param_ = new ::caffe::ImageDataParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.image_data_param)
+ return image_data_param_;
+}
+::caffe::ImageDataParameter* LayerParameter::release_image_data_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.image_data_param)
+ clear_has_image_data_param();
+ ::caffe::ImageDataParameter* temp = image_data_param_;
+ image_data_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_image_data_param(::caffe::ImageDataParameter* image_data_param) {
+ delete image_data_param_;
+ image_data_param_ = image_data_param;
+ if (image_data_param) {
+ set_has_image_data_param();
+ } else {
+ clear_has_image_data_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.image_data_param)
+}
+
+// optional .caffe.InfogainLossParameter infogain_loss_param = 116;
+bool LayerParameter::has_infogain_loss_param() const {
+ return (_has_bits_[1] & 0x00000004u) != 0;
+}
+void LayerParameter::set_has_infogain_loss_param() {
+ _has_bits_[1] |= 0x00000004u;
+}
+void LayerParameter::clear_has_infogain_loss_param() {
+ _has_bits_[1] &= ~0x00000004u;
+}
+void LayerParameter::clear_infogain_loss_param() {
+ if (infogain_loss_param_ != NULL) infogain_loss_param_->::caffe::InfogainLossParameter::Clear();
+ clear_has_infogain_loss_param();
+}
+const ::caffe::InfogainLossParameter& LayerParameter::infogain_loss_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.infogain_loss_param)
+ return infogain_loss_param_ != NULL ? *infogain_loss_param_
+ : *::caffe::InfogainLossParameter::internal_default_instance();
+}
+::caffe::InfogainLossParameter* LayerParameter::mutable_infogain_loss_param() {
+ set_has_infogain_loss_param();
+ if (infogain_loss_param_ == NULL) {
+ infogain_loss_param_ = new ::caffe::InfogainLossParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.infogain_loss_param)
+ return infogain_loss_param_;
+}
+::caffe::InfogainLossParameter* LayerParameter::release_infogain_loss_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.infogain_loss_param)
+ clear_has_infogain_loss_param();
+ ::caffe::InfogainLossParameter* temp = infogain_loss_param_;
+ infogain_loss_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_infogain_loss_param(::caffe::InfogainLossParameter* infogain_loss_param) {
+ delete infogain_loss_param_;
+ infogain_loss_param_ = infogain_loss_param;
+ if (infogain_loss_param) {
+ set_has_infogain_loss_param();
+ } else {
+ clear_has_infogain_loss_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.infogain_loss_param)
+}
+
+// optional .caffe.InnerProductParameter inner_product_param = 117;
+bool LayerParameter::has_inner_product_param() const {
+ return (_has_bits_[1] & 0x00000008u) != 0;
+}
+void LayerParameter::set_has_inner_product_param() {
+ _has_bits_[1] |= 0x00000008u;
+}
+void LayerParameter::clear_has_inner_product_param() {
+ _has_bits_[1] &= ~0x00000008u;
+}
+void LayerParameter::clear_inner_product_param() {
+ if (inner_product_param_ != NULL) inner_product_param_->::caffe::InnerProductParameter::Clear();
+ clear_has_inner_product_param();
+}
+const ::caffe::InnerProductParameter& LayerParameter::inner_product_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.inner_product_param)
+ return inner_product_param_ != NULL ? *inner_product_param_
+ : *::caffe::InnerProductParameter::internal_default_instance();
+}
+::caffe::InnerProductParameter* LayerParameter::mutable_inner_product_param() {
+ set_has_inner_product_param();
+ if (inner_product_param_ == NULL) {
+ inner_product_param_ = new ::caffe::InnerProductParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.inner_product_param)
+ return inner_product_param_;
+}
+::caffe::InnerProductParameter* LayerParameter::release_inner_product_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.inner_product_param)
+ clear_has_inner_product_param();
+ ::caffe::InnerProductParameter* temp = inner_product_param_;
+ inner_product_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_inner_product_param(::caffe::InnerProductParameter* inner_product_param) {
+ delete inner_product_param_;
+ inner_product_param_ = inner_product_param;
+ if (inner_product_param) {
+ set_has_inner_product_param();
+ } else {
+ clear_has_inner_product_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.inner_product_param)
+}
+
+// optional .caffe.InputParameter input_param = 143;
+bool LayerParameter::has_input_param() const {
+ return (_has_bits_[1] & 0x00000010u) != 0;
+}
+void LayerParameter::set_has_input_param() {
+ _has_bits_[1] |= 0x00000010u;
+}
+void LayerParameter::clear_has_input_param() {
+ _has_bits_[1] &= ~0x00000010u;
+}
+void LayerParameter::clear_input_param() {
+ if (input_param_ != NULL) input_param_->::caffe::InputParameter::Clear();
+ clear_has_input_param();
+}
+const ::caffe::InputParameter& LayerParameter::input_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.input_param)
+ return input_param_ != NULL ? *input_param_
+ : *::caffe::InputParameter::internal_default_instance();
+}
+::caffe::InputParameter* LayerParameter::mutable_input_param() {
+ set_has_input_param();
+ if (input_param_ == NULL) {
+ input_param_ = new ::caffe::InputParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.input_param)
+ return input_param_;
+}
+::caffe::InputParameter* LayerParameter::release_input_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.input_param)
+ clear_has_input_param();
+ ::caffe::InputParameter* temp = input_param_;
+ input_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_input_param(::caffe::InputParameter* input_param) {
+ delete input_param_;
+ input_param_ = input_param;
+ if (input_param) {
+ set_has_input_param();
+ } else {
+ clear_has_input_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.input_param)
+}
+
+// optional .caffe.LogParameter log_param = 134;
+bool LayerParameter::has_log_param() const {
+ return (_has_bits_[1] & 0x00000020u) != 0;
+}
+void LayerParameter::set_has_log_param() {
+ _has_bits_[1] |= 0x00000020u;
+}
+void LayerParameter::clear_has_log_param() {
+ _has_bits_[1] &= ~0x00000020u;
+}
+void LayerParameter::clear_log_param() {
+ if (log_param_ != NULL) log_param_->::caffe::LogParameter::Clear();
+ clear_has_log_param();
+}
+const ::caffe::LogParameter& LayerParameter::log_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.log_param)
+ return log_param_ != NULL ? *log_param_
+ : *::caffe::LogParameter::internal_default_instance();
+}
+::caffe::LogParameter* LayerParameter::mutable_log_param() {
+ set_has_log_param();
+ if (log_param_ == NULL) {
+ log_param_ = new ::caffe::LogParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.log_param)
+ return log_param_;
+}
+::caffe::LogParameter* LayerParameter::release_log_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.log_param)
+ clear_has_log_param();
+ ::caffe::LogParameter* temp = log_param_;
+ log_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_log_param(::caffe::LogParameter* log_param) {
+ delete log_param_;
+ log_param_ = log_param;
+ if (log_param) {
+ set_has_log_param();
+ } else {
+ clear_has_log_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.log_param)
+}
+
+// optional .caffe.LRNParameter lrn_param = 118;
+bool LayerParameter::has_lrn_param() const {
+ return (_has_bits_[1] & 0x00000040u) != 0;
+}
+void LayerParameter::set_has_lrn_param() {
+ _has_bits_[1] |= 0x00000040u;
+}
+void LayerParameter::clear_has_lrn_param() {
+ _has_bits_[1] &= ~0x00000040u;
+}
+void LayerParameter::clear_lrn_param() {
+ if (lrn_param_ != NULL) lrn_param_->::caffe::LRNParameter::Clear();
+ clear_has_lrn_param();
+}
+const ::caffe::LRNParameter& LayerParameter::lrn_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.lrn_param)
+ return lrn_param_ != NULL ? *lrn_param_
+ : *::caffe::LRNParameter::internal_default_instance();
+}
+::caffe::LRNParameter* LayerParameter::mutable_lrn_param() {
+ set_has_lrn_param();
+ if (lrn_param_ == NULL) {
+ lrn_param_ = new ::caffe::LRNParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.lrn_param)
+ return lrn_param_;
+}
+::caffe::LRNParameter* LayerParameter::release_lrn_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.lrn_param)
+ clear_has_lrn_param();
+ ::caffe::LRNParameter* temp = lrn_param_;
+ lrn_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_lrn_param(::caffe::LRNParameter* lrn_param) {
+ delete lrn_param_;
+ lrn_param_ = lrn_param;
+ if (lrn_param) {
+ set_has_lrn_param();
+ } else {
+ clear_has_lrn_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.lrn_param)
+}
+
+// optional .caffe.MemoryDataParameter memory_data_param = 119;
+bool LayerParameter::has_memory_data_param() const {
+ return (_has_bits_[1] & 0x00000080u) != 0;
+}
+void LayerParameter::set_has_memory_data_param() {
+ _has_bits_[1] |= 0x00000080u;
+}
+void LayerParameter::clear_has_memory_data_param() {
+ _has_bits_[1] &= ~0x00000080u;
+}
+void LayerParameter::clear_memory_data_param() {
+ if (memory_data_param_ != NULL) memory_data_param_->::caffe::MemoryDataParameter::Clear();
+ clear_has_memory_data_param();
+}
+const ::caffe::MemoryDataParameter& LayerParameter::memory_data_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.memory_data_param)
+ return memory_data_param_ != NULL ? *memory_data_param_
+ : *::caffe::MemoryDataParameter::internal_default_instance();
+}
+::caffe::MemoryDataParameter* LayerParameter::mutable_memory_data_param() {
+ set_has_memory_data_param();
+ if (memory_data_param_ == NULL) {
+ memory_data_param_ = new ::caffe::MemoryDataParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.memory_data_param)
+ return memory_data_param_;
+}
+::caffe::MemoryDataParameter* LayerParameter::release_memory_data_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.memory_data_param)
+ clear_has_memory_data_param();
+ ::caffe::MemoryDataParameter* temp = memory_data_param_;
+ memory_data_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_memory_data_param(::caffe::MemoryDataParameter* memory_data_param) {
+ delete memory_data_param_;
+ memory_data_param_ = memory_data_param;
+ if (memory_data_param) {
+ set_has_memory_data_param();
+ } else {
+ clear_has_memory_data_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.memory_data_param)
+}
+
+// optional .caffe.MVNParameter mvn_param = 120;
+bool LayerParameter::has_mvn_param() const {
+ return (_has_bits_[1] & 0x00000100u) != 0;
+}
+void LayerParameter::set_has_mvn_param() {
+ _has_bits_[1] |= 0x00000100u;
+}
+void LayerParameter::clear_has_mvn_param() {
+ _has_bits_[1] &= ~0x00000100u;
+}
+void LayerParameter::clear_mvn_param() {
+ if (mvn_param_ != NULL) mvn_param_->::caffe::MVNParameter::Clear();
+ clear_has_mvn_param();
+}
+const ::caffe::MVNParameter& LayerParameter::mvn_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.mvn_param)
+ return mvn_param_ != NULL ? *mvn_param_
+ : *::caffe::MVNParameter::internal_default_instance();
+}
+::caffe::MVNParameter* LayerParameter::mutable_mvn_param() {
+ set_has_mvn_param();
+ if (mvn_param_ == NULL) {
+ mvn_param_ = new ::caffe::MVNParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.mvn_param)
+ return mvn_param_;
+}
+::caffe::MVNParameter* LayerParameter::release_mvn_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.mvn_param)
+ clear_has_mvn_param();
+ ::caffe::MVNParameter* temp = mvn_param_;
+ mvn_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_mvn_param(::caffe::MVNParameter* mvn_param) {
+ delete mvn_param_;
+ mvn_param_ = mvn_param;
+ if (mvn_param) {
+ set_has_mvn_param();
+ } else {
+ clear_has_mvn_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.mvn_param)
+}
+
+// optional .caffe.NormalizeBBoxParameter norm_param = 149;
+bool LayerParameter::has_norm_param() const {
+ return (_has_bits_[1] & 0x00000200u) != 0;
+}
+void LayerParameter::set_has_norm_param() {
+ _has_bits_[1] |= 0x00000200u;
+}
+void LayerParameter::clear_has_norm_param() {
+ _has_bits_[1] &= ~0x00000200u;
+}
+void LayerParameter::clear_norm_param() {
+ if (norm_param_ != NULL) norm_param_->::caffe::NormalizeBBoxParameter::Clear();
+ clear_has_norm_param();
+}
+const ::caffe::NormalizeBBoxParameter& LayerParameter::norm_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.norm_param)
+ return norm_param_ != NULL ? *norm_param_
+ : *::caffe::NormalizeBBoxParameter::internal_default_instance();
+}
+::caffe::NormalizeBBoxParameter* LayerParameter::mutable_norm_param() {
+ set_has_norm_param();
+ if (norm_param_ == NULL) {
+ norm_param_ = new ::caffe::NormalizeBBoxParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.norm_param)
+ return norm_param_;
+}
+::caffe::NormalizeBBoxParameter* LayerParameter::release_norm_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.norm_param)
+ clear_has_norm_param();
+ ::caffe::NormalizeBBoxParameter* temp = norm_param_;
+ norm_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_norm_param(::caffe::NormalizeBBoxParameter* norm_param) {
+ delete norm_param_;
+ norm_param_ = norm_param;
+ if (norm_param) {
+ set_has_norm_param();
+ } else {
+ clear_has_norm_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.norm_param)
+}
+
+// optional .caffe.PermuteParameter permute_param = 148;
+bool LayerParameter::has_permute_param() const {
+ return (_has_bits_[1] & 0x00000400u) != 0;
+}
+void LayerParameter::set_has_permute_param() {
+ _has_bits_[1] |= 0x00000400u;
+}
+void LayerParameter::clear_has_permute_param() {
+ _has_bits_[1] &= ~0x00000400u;
+}
+void LayerParameter::clear_permute_param() {
+ if (permute_param_ != NULL) permute_param_->::caffe::PermuteParameter::Clear();
+ clear_has_permute_param();
+}
+const ::caffe::PermuteParameter& LayerParameter::permute_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.permute_param)
+ return permute_param_ != NULL ? *permute_param_
+ : *::caffe::PermuteParameter::internal_default_instance();
+}
+::caffe::PermuteParameter* LayerParameter::mutable_permute_param() {
+ set_has_permute_param();
+ if (permute_param_ == NULL) {
+ permute_param_ = new ::caffe::PermuteParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.permute_param)
+ return permute_param_;
+}
+::caffe::PermuteParameter* LayerParameter::release_permute_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.permute_param)
+ clear_has_permute_param();
+ ::caffe::PermuteParameter* temp = permute_param_;
+ permute_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_permute_param(::caffe::PermuteParameter* permute_param) {
+ delete permute_param_;
+ permute_param_ = permute_param;
+ if (permute_param) {
+ set_has_permute_param();
+ } else {
+ clear_has_permute_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.permute_param)
+}
+
+// optional .caffe.ParameterParameter parameter_param = 145;
+bool LayerParameter::has_parameter_param() const {
+ return (_has_bits_[1] & 0x00000800u) != 0;
+}
+void LayerParameter::set_has_parameter_param() {
+ _has_bits_[1] |= 0x00000800u;
+}
+void LayerParameter::clear_has_parameter_param() {
+ _has_bits_[1] &= ~0x00000800u;
+}
+void LayerParameter::clear_parameter_param() {
+ if (parameter_param_ != NULL) parameter_param_->::caffe::ParameterParameter::Clear();
+ clear_has_parameter_param();
+}
+const ::caffe::ParameterParameter& LayerParameter::parameter_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.parameter_param)
+ return parameter_param_ != NULL ? *parameter_param_
+ : *::caffe::ParameterParameter::internal_default_instance();
+}
+::caffe::ParameterParameter* LayerParameter::mutable_parameter_param() {
+ set_has_parameter_param();
+ if (parameter_param_ == NULL) {
+ parameter_param_ = new ::caffe::ParameterParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.parameter_param)
+ return parameter_param_;
+}
+::caffe::ParameterParameter* LayerParameter::release_parameter_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.parameter_param)
+ clear_has_parameter_param();
+ ::caffe::ParameterParameter* temp = parameter_param_;
+ parameter_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_parameter_param(::caffe::ParameterParameter* parameter_param) {
+ delete parameter_param_;
+ parameter_param_ = parameter_param;
+ if (parameter_param) {
+ set_has_parameter_param();
+ } else {
+ clear_has_parameter_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.parameter_param)
+}
+
+// optional .caffe.PoolingParameter pooling_param = 121;
+bool LayerParameter::has_pooling_param() const {
+ return (_has_bits_[1] & 0x00001000u) != 0;
+}
+void LayerParameter::set_has_pooling_param() {
+ _has_bits_[1] |= 0x00001000u;
+}
+void LayerParameter::clear_has_pooling_param() {
+ _has_bits_[1] &= ~0x00001000u;
+}
+void LayerParameter::clear_pooling_param() {
+ if (pooling_param_ != NULL) pooling_param_->::caffe::PoolingParameter::Clear();
+ clear_has_pooling_param();
+}
+const ::caffe::PoolingParameter& LayerParameter::pooling_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.pooling_param)
+ return pooling_param_ != NULL ? *pooling_param_
+ : *::caffe::PoolingParameter::internal_default_instance();
+}
+::caffe::PoolingParameter* LayerParameter::mutable_pooling_param() {
+ set_has_pooling_param();
+ if (pooling_param_ == NULL) {
+ pooling_param_ = new ::caffe::PoolingParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.pooling_param)
+ return pooling_param_;
+}
+::caffe::PoolingParameter* LayerParameter::release_pooling_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.pooling_param)
+ clear_has_pooling_param();
+ ::caffe::PoolingParameter* temp = pooling_param_;
+ pooling_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_pooling_param(::caffe::PoolingParameter* pooling_param) {
+ delete pooling_param_;
+ pooling_param_ = pooling_param;
+ if (pooling_param) {
+ set_has_pooling_param();
+ } else {
+ clear_has_pooling_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.pooling_param)
+}
+
+// optional .caffe.PowerParameter power_param = 122;
+bool LayerParameter::has_power_param() const {
+ return (_has_bits_[1] & 0x00002000u) != 0;
+}
+void LayerParameter::set_has_power_param() {
+ _has_bits_[1] |= 0x00002000u;
+}
+void LayerParameter::clear_has_power_param() {
+ _has_bits_[1] &= ~0x00002000u;
+}
+void LayerParameter::clear_power_param() {
+ if (power_param_ != NULL) power_param_->::caffe::PowerParameter::Clear();
+ clear_has_power_param();
+}
+const ::caffe::PowerParameter& LayerParameter::power_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.power_param)
+ return power_param_ != NULL ? *power_param_
+ : *::caffe::PowerParameter::internal_default_instance();
+}
+::caffe::PowerParameter* LayerParameter::mutable_power_param() {
+ set_has_power_param();
+ if (power_param_ == NULL) {
+ power_param_ = new ::caffe::PowerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.power_param)
+ return power_param_;
+}
+::caffe::PowerParameter* LayerParameter::release_power_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.power_param)
+ clear_has_power_param();
+ ::caffe::PowerParameter* temp = power_param_;
+ power_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_power_param(::caffe::PowerParameter* power_param) {
+ delete power_param_;
+ power_param_ = power_param;
+ if (power_param) {
+ set_has_power_param();
+ } else {
+ clear_has_power_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.power_param)
+}
+
+// optional .caffe.PReLUParameter prelu_param = 131;
+bool LayerParameter::has_prelu_param() const {
+ return (_has_bits_[1] & 0x00004000u) != 0;
+}
+void LayerParameter::set_has_prelu_param() {
+ _has_bits_[1] |= 0x00004000u;
+}
+void LayerParameter::clear_has_prelu_param() {
+ _has_bits_[1] &= ~0x00004000u;
+}
+void LayerParameter::clear_prelu_param() {
+ if (prelu_param_ != NULL) prelu_param_->::caffe::PReLUParameter::Clear();
+ clear_has_prelu_param();
+}
+const ::caffe::PReLUParameter& LayerParameter::prelu_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.prelu_param)
+ return prelu_param_ != NULL ? *prelu_param_
+ : *::caffe::PReLUParameter::internal_default_instance();
+}
+::caffe::PReLUParameter* LayerParameter::mutable_prelu_param() {
+ set_has_prelu_param();
+ if (prelu_param_ == NULL) {
+ prelu_param_ = new ::caffe::PReLUParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.prelu_param)
+ return prelu_param_;
+}
+::caffe::PReLUParameter* LayerParameter::release_prelu_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.prelu_param)
+ clear_has_prelu_param();
+ ::caffe::PReLUParameter* temp = prelu_param_;
+ prelu_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_prelu_param(::caffe::PReLUParameter* prelu_param) {
+ delete prelu_param_;
+ prelu_param_ = prelu_param;
+ if (prelu_param) {
+ set_has_prelu_param();
+ } else {
+ clear_has_prelu_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.prelu_param)
+}
+
+// optional .caffe.PriorBoxParameter prior_box_param = 150;
+bool LayerParameter::has_prior_box_param() const {
+ return (_has_bits_[1] & 0x00008000u) != 0;
+}
+void LayerParameter::set_has_prior_box_param() {
+ _has_bits_[1] |= 0x00008000u;
+}
+void LayerParameter::clear_has_prior_box_param() {
+ _has_bits_[1] &= ~0x00008000u;
+}
+void LayerParameter::clear_prior_box_param() {
+ if (prior_box_param_ != NULL) prior_box_param_->::caffe::PriorBoxParameter::Clear();
+ clear_has_prior_box_param();
+}
+const ::caffe::PriorBoxParameter& LayerParameter::prior_box_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.prior_box_param)
+ return prior_box_param_ != NULL ? *prior_box_param_
+ : *::caffe::PriorBoxParameter::internal_default_instance();
+}
+::caffe::PriorBoxParameter* LayerParameter::mutable_prior_box_param() {
+ set_has_prior_box_param();
+ if (prior_box_param_ == NULL) {
+ prior_box_param_ = new ::caffe::PriorBoxParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.prior_box_param)
+ return prior_box_param_;
+}
+::caffe::PriorBoxParameter* LayerParameter::release_prior_box_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.prior_box_param)
+ clear_has_prior_box_param();
+ ::caffe::PriorBoxParameter* temp = prior_box_param_;
+ prior_box_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_prior_box_param(::caffe::PriorBoxParameter* prior_box_param) {
+ delete prior_box_param_;
+ prior_box_param_ = prior_box_param;
+ if (prior_box_param) {
+ set_has_prior_box_param();
+ } else {
+ clear_has_prior_box_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.prior_box_param)
+}
+
+// optional .caffe.PythonParameter python_param = 130;
+bool LayerParameter::has_python_param() const {
+ return (_has_bits_[1] & 0x00010000u) != 0;
+}
+void LayerParameter::set_has_python_param() {
+ _has_bits_[1] |= 0x00010000u;
+}
+void LayerParameter::clear_has_python_param() {
+ _has_bits_[1] &= ~0x00010000u;
+}
+void LayerParameter::clear_python_param() {
+ if (python_param_ != NULL) python_param_->::caffe::PythonParameter::Clear();
+ clear_has_python_param();
+}
+const ::caffe::PythonParameter& LayerParameter::python_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.python_param)
+ return python_param_ != NULL ? *python_param_
+ : *::caffe::PythonParameter::internal_default_instance();
+}
+::caffe::PythonParameter* LayerParameter::mutable_python_param() {
+ set_has_python_param();
+ if (python_param_ == NULL) {
+ python_param_ = new ::caffe::PythonParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.python_param)
+ return python_param_;
+}
+::caffe::PythonParameter* LayerParameter::release_python_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.python_param)
+ clear_has_python_param();
+ ::caffe::PythonParameter* temp = python_param_;
+ python_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_python_param(::caffe::PythonParameter* python_param) {
+ delete python_param_;
+ python_param_ = python_param;
+ if (python_param) {
+ set_has_python_param();
+ } else {
+ clear_has_python_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.python_param)
+}
+
+// optional .caffe.RecurrentParameter recurrent_param = 146;
+bool LayerParameter::has_recurrent_param() const {
+ return (_has_bits_[1] & 0x00020000u) != 0;
+}
+void LayerParameter::set_has_recurrent_param() {
+ _has_bits_[1] |= 0x00020000u;
+}
+void LayerParameter::clear_has_recurrent_param() {
+ _has_bits_[1] &= ~0x00020000u;
+}
+void LayerParameter::clear_recurrent_param() {
+ if (recurrent_param_ != NULL) recurrent_param_->::caffe::RecurrentParameter::Clear();
+ clear_has_recurrent_param();
+}
+const ::caffe::RecurrentParameter& LayerParameter::recurrent_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.recurrent_param)
+ return recurrent_param_ != NULL ? *recurrent_param_
+ : *::caffe::RecurrentParameter::internal_default_instance();
+}
+::caffe::RecurrentParameter* LayerParameter::mutable_recurrent_param() {
+ set_has_recurrent_param();
+ if (recurrent_param_ == NULL) {
+ recurrent_param_ = new ::caffe::RecurrentParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.recurrent_param)
+ return recurrent_param_;
+}
+::caffe::RecurrentParameter* LayerParameter::release_recurrent_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.recurrent_param)
+ clear_has_recurrent_param();
+ ::caffe::RecurrentParameter* temp = recurrent_param_;
+ recurrent_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_recurrent_param(::caffe::RecurrentParameter* recurrent_param) {
+ delete recurrent_param_;
+ recurrent_param_ = recurrent_param;
+ if (recurrent_param) {
+ set_has_recurrent_param();
+ } else {
+ clear_has_recurrent_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.recurrent_param)
+}
+
+// optional .caffe.ReductionParameter reduction_param = 136;
+bool LayerParameter::has_reduction_param() const {
+ return (_has_bits_[1] & 0x00040000u) != 0;
+}
+void LayerParameter::set_has_reduction_param() {
+ _has_bits_[1] |= 0x00040000u;
+}
+void LayerParameter::clear_has_reduction_param() {
+ _has_bits_[1] &= ~0x00040000u;
+}
+void LayerParameter::clear_reduction_param() {
+ if (reduction_param_ != NULL) reduction_param_->::caffe::ReductionParameter::Clear();
+ clear_has_reduction_param();
+}
+const ::caffe::ReductionParameter& LayerParameter::reduction_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.reduction_param)
+ return reduction_param_ != NULL ? *reduction_param_
+ : *::caffe::ReductionParameter::internal_default_instance();
+}
+::caffe::ReductionParameter* LayerParameter::mutable_reduction_param() {
+ set_has_reduction_param();
+ if (reduction_param_ == NULL) {
+ reduction_param_ = new ::caffe::ReductionParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.reduction_param)
+ return reduction_param_;
+}
+::caffe::ReductionParameter* LayerParameter::release_reduction_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.reduction_param)
+ clear_has_reduction_param();
+ ::caffe::ReductionParameter* temp = reduction_param_;
+ reduction_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_reduction_param(::caffe::ReductionParameter* reduction_param) {
+ delete reduction_param_;
+ reduction_param_ = reduction_param;
+ if (reduction_param) {
+ set_has_reduction_param();
+ } else {
+ clear_has_reduction_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.reduction_param)
+}
+
+// optional .caffe.ReLUParameter relu_param = 123;
+bool LayerParameter::has_relu_param() const {
+ return (_has_bits_[1] & 0x00080000u) != 0;
+}
+void LayerParameter::set_has_relu_param() {
+ _has_bits_[1] |= 0x00080000u;
+}
+void LayerParameter::clear_has_relu_param() {
+ _has_bits_[1] &= ~0x00080000u;
+}
+void LayerParameter::clear_relu_param() {
+ if (relu_param_ != NULL) relu_param_->::caffe::ReLUParameter::Clear();
+ clear_has_relu_param();
+}
+const ::caffe::ReLUParameter& LayerParameter::relu_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.relu_param)
+ return relu_param_ != NULL ? *relu_param_
+ : *::caffe::ReLUParameter::internal_default_instance();
+}
+::caffe::ReLUParameter* LayerParameter::mutable_relu_param() {
+ set_has_relu_param();
+ if (relu_param_ == NULL) {
+ relu_param_ = new ::caffe::ReLUParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.relu_param)
+ return relu_param_;
+}
+::caffe::ReLUParameter* LayerParameter::release_relu_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.relu_param)
+ clear_has_relu_param();
+ ::caffe::ReLUParameter* temp = relu_param_;
+ relu_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_relu_param(::caffe::ReLUParameter* relu_param) {
+ delete relu_param_;
+ relu_param_ = relu_param;
+ if (relu_param) {
+ set_has_relu_param();
+ } else {
+ clear_has_relu_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.relu_param)
+}
+
+// optional .caffe.ReshapeParameter reshape_param = 133;
+bool LayerParameter::has_reshape_param() const {
+ return (_has_bits_[1] & 0x00100000u) != 0;
+}
+void LayerParameter::set_has_reshape_param() {
+ _has_bits_[1] |= 0x00100000u;
+}
+void LayerParameter::clear_has_reshape_param() {
+ _has_bits_[1] &= ~0x00100000u;
+}
+void LayerParameter::clear_reshape_param() {
+ if (reshape_param_ != NULL) reshape_param_->::caffe::ReshapeParameter::Clear();
+ clear_has_reshape_param();
+}
+const ::caffe::ReshapeParameter& LayerParameter::reshape_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.reshape_param)
+ return reshape_param_ != NULL ? *reshape_param_
+ : *::caffe::ReshapeParameter::internal_default_instance();
+}
+::caffe::ReshapeParameter* LayerParameter::mutable_reshape_param() {
+ set_has_reshape_param();
+ if (reshape_param_ == NULL) {
+ reshape_param_ = new ::caffe::ReshapeParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.reshape_param)
+ return reshape_param_;
+}
+::caffe::ReshapeParameter* LayerParameter::release_reshape_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.reshape_param)
+ clear_has_reshape_param();
+ ::caffe::ReshapeParameter* temp = reshape_param_;
+ reshape_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_reshape_param(::caffe::ReshapeParameter* reshape_param) {
+ delete reshape_param_;
+ reshape_param_ = reshape_param;
+ if (reshape_param) {
+ set_has_reshape_param();
+ } else {
+ clear_has_reshape_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.reshape_param)
+}
+
+// optional .caffe.ScaleParameter scale_param = 142;
+bool LayerParameter::has_scale_param() const {
+ return (_has_bits_[1] & 0x00200000u) != 0;
+}
+void LayerParameter::set_has_scale_param() {
+ _has_bits_[1] |= 0x00200000u;
+}
+void LayerParameter::clear_has_scale_param() {
+ _has_bits_[1] &= ~0x00200000u;
+}
+void LayerParameter::clear_scale_param() {
+ if (scale_param_ != NULL) scale_param_->::caffe::ScaleParameter::Clear();
+ clear_has_scale_param();
+}
+const ::caffe::ScaleParameter& LayerParameter::scale_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.scale_param)
+ return scale_param_ != NULL ? *scale_param_
+ : *::caffe::ScaleParameter::internal_default_instance();
+}
+::caffe::ScaleParameter* LayerParameter::mutable_scale_param() {
+ set_has_scale_param();
+ if (scale_param_ == NULL) {
+ scale_param_ = new ::caffe::ScaleParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.scale_param)
+ return scale_param_;
+}
+::caffe::ScaleParameter* LayerParameter::release_scale_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.scale_param)
+ clear_has_scale_param();
+ ::caffe::ScaleParameter* temp = scale_param_;
+ scale_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_scale_param(::caffe::ScaleParameter* scale_param) {
+ delete scale_param_;
+ scale_param_ = scale_param;
+ if (scale_param) {
+ set_has_scale_param();
+ } else {
+ clear_has_scale_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.scale_param)
+}
+
+// optional .caffe.SigmoidParameter sigmoid_param = 124;
+bool LayerParameter::has_sigmoid_param() const {
+ return (_has_bits_[1] & 0x00400000u) != 0;
+}
+void LayerParameter::set_has_sigmoid_param() {
+ _has_bits_[1] |= 0x00400000u;
+}
+void LayerParameter::clear_has_sigmoid_param() {
+ _has_bits_[1] &= ~0x00400000u;
+}
+void LayerParameter::clear_sigmoid_param() {
+ if (sigmoid_param_ != NULL) sigmoid_param_->::caffe::SigmoidParameter::Clear();
+ clear_has_sigmoid_param();
+}
+const ::caffe::SigmoidParameter& LayerParameter::sigmoid_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.sigmoid_param)
+ return sigmoid_param_ != NULL ? *sigmoid_param_
+ : *::caffe::SigmoidParameter::internal_default_instance();
+}
+::caffe::SigmoidParameter* LayerParameter::mutable_sigmoid_param() {
+ set_has_sigmoid_param();
+ if (sigmoid_param_ == NULL) {
+ sigmoid_param_ = new ::caffe::SigmoidParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.sigmoid_param)
+ return sigmoid_param_;
+}
+::caffe::SigmoidParameter* LayerParameter::release_sigmoid_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.sigmoid_param)
+ clear_has_sigmoid_param();
+ ::caffe::SigmoidParameter* temp = sigmoid_param_;
+ sigmoid_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_sigmoid_param(::caffe::SigmoidParameter* sigmoid_param) {
+ delete sigmoid_param_;
+ sigmoid_param_ = sigmoid_param;
+ if (sigmoid_param) {
+ set_has_sigmoid_param();
+ } else {
+ clear_has_sigmoid_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.sigmoid_param)
+}
+
+// optional .caffe.SoftmaxParameter softmax_param = 125;
+bool LayerParameter::has_softmax_param() const {
+ return (_has_bits_[1] & 0x00800000u) != 0;
+}
+void LayerParameter::set_has_softmax_param() {
+ _has_bits_[1] |= 0x00800000u;
+}
+void LayerParameter::clear_has_softmax_param() {
+ _has_bits_[1] &= ~0x00800000u;
+}
+void LayerParameter::clear_softmax_param() {
+ if (softmax_param_ != NULL) softmax_param_->::caffe::SoftmaxParameter::Clear();
+ clear_has_softmax_param();
+}
+const ::caffe::SoftmaxParameter& LayerParameter::softmax_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.softmax_param)
+ return softmax_param_ != NULL ? *softmax_param_
+ : *::caffe::SoftmaxParameter::internal_default_instance();
+}
+::caffe::SoftmaxParameter* LayerParameter::mutable_softmax_param() {
+ set_has_softmax_param();
+ if (softmax_param_ == NULL) {
+ softmax_param_ = new ::caffe::SoftmaxParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.softmax_param)
+ return softmax_param_;
+}
+::caffe::SoftmaxParameter* LayerParameter::release_softmax_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.softmax_param)
+ clear_has_softmax_param();
+ ::caffe::SoftmaxParameter* temp = softmax_param_;
+ softmax_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_softmax_param(::caffe::SoftmaxParameter* softmax_param) {
+ delete softmax_param_;
+ softmax_param_ = softmax_param;
+ if (softmax_param) {
+ set_has_softmax_param();
+ } else {
+ clear_has_softmax_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.softmax_param)
+}
+
+// optional .caffe.SPPParameter spp_param = 132;
+bool LayerParameter::has_spp_param() const {
+ return (_has_bits_[1] & 0x01000000u) != 0;
+}
+void LayerParameter::set_has_spp_param() {
+ _has_bits_[1] |= 0x01000000u;
+}
+void LayerParameter::clear_has_spp_param() {
+ _has_bits_[1] &= ~0x01000000u;
+}
+void LayerParameter::clear_spp_param() {
+ if (spp_param_ != NULL) spp_param_->::caffe::SPPParameter::Clear();
+ clear_has_spp_param();
+}
+const ::caffe::SPPParameter& LayerParameter::spp_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.spp_param)
+ return spp_param_ != NULL ? *spp_param_
+ : *::caffe::SPPParameter::internal_default_instance();
+}
+::caffe::SPPParameter* LayerParameter::mutable_spp_param() {
+ set_has_spp_param();
+ if (spp_param_ == NULL) {
+ spp_param_ = new ::caffe::SPPParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.spp_param)
+ return spp_param_;
+}
+::caffe::SPPParameter* LayerParameter::release_spp_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.spp_param)
+ clear_has_spp_param();
+ ::caffe::SPPParameter* temp = spp_param_;
+ spp_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_spp_param(::caffe::SPPParameter* spp_param) {
+ delete spp_param_;
+ spp_param_ = spp_param;
+ if (spp_param) {
+ set_has_spp_param();
+ } else {
+ clear_has_spp_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.spp_param)
+}
+
+// optional .caffe.SliceParameter slice_param = 126;
+bool LayerParameter::has_slice_param() const {
+ return (_has_bits_[1] & 0x02000000u) != 0;
+}
+void LayerParameter::set_has_slice_param() {
+ _has_bits_[1] |= 0x02000000u;
+}
+void LayerParameter::clear_has_slice_param() {
+ _has_bits_[1] &= ~0x02000000u;
+}
+void LayerParameter::clear_slice_param() {
+ if (slice_param_ != NULL) slice_param_->::caffe::SliceParameter::Clear();
+ clear_has_slice_param();
+}
+const ::caffe::SliceParameter& LayerParameter::slice_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.slice_param)
+ return slice_param_ != NULL ? *slice_param_
+ : *::caffe::SliceParameter::internal_default_instance();
+}
+::caffe::SliceParameter* LayerParameter::mutable_slice_param() {
+ set_has_slice_param();
+ if (slice_param_ == NULL) {
+ slice_param_ = new ::caffe::SliceParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.slice_param)
+ return slice_param_;
+}
+::caffe::SliceParameter* LayerParameter::release_slice_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.slice_param)
+ clear_has_slice_param();
+ ::caffe::SliceParameter* temp = slice_param_;
+ slice_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_slice_param(::caffe::SliceParameter* slice_param) {
+ delete slice_param_;
+ slice_param_ = slice_param;
+ if (slice_param) {
+ set_has_slice_param();
+ } else {
+ clear_has_slice_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.slice_param)
+}
+
+// optional .caffe.TanHParameter tanh_param = 127;
+bool LayerParameter::has_tanh_param() const {
+ return (_has_bits_[1] & 0x04000000u) != 0;
+}
+void LayerParameter::set_has_tanh_param() {
+ _has_bits_[1] |= 0x04000000u;
+}
+void LayerParameter::clear_has_tanh_param() {
+ _has_bits_[1] &= ~0x04000000u;
+}
+void LayerParameter::clear_tanh_param() {
+ if (tanh_param_ != NULL) tanh_param_->::caffe::TanHParameter::Clear();
+ clear_has_tanh_param();
+}
+const ::caffe::TanHParameter& LayerParameter::tanh_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.tanh_param)
+ return tanh_param_ != NULL ? *tanh_param_
+ : *::caffe::TanHParameter::internal_default_instance();
+}
+::caffe::TanHParameter* LayerParameter::mutable_tanh_param() {
+ set_has_tanh_param();
+ if (tanh_param_ == NULL) {
+ tanh_param_ = new ::caffe::TanHParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.tanh_param)
+ return tanh_param_;
+}
+::caffe::TanHParameter* LayerParameter::release_tanh_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.tanh_param)
+ clear_has_tanh_param();
+ ::caffe::TanHParameter* temp = tanh_param_;
+ tanh_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_tanh_param(::caffe::TanHParameter* tanh_param) {
+ delete tanh_param_;
+ tanh_param_ = tanh_param;
+ if (tanh_param) {
+ set_has_tanh_param();
+ } else {
+ clear_has_tanh_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.tanh_param)
+}
+
+// optional .caffe.ThresholdParameter threshold_param = 128;
+bool LayerParameter::has_threshold_param() const {
+ return (_has_bits_[1] & 0x08000000u) != 0;
+}
+void LayerParameter::set_has_threshold_param() {
+ _has_bits_[1] |= 0x08000000u;
+}
+void LayerParameter::clear_has_threshold_param() {
+ _has_bits_[1] &= ~0x08000000u;
+}
+void LayerParameter::clear_threshold_param() {
+ if (threshold_param_ != NULL) threshold_param_->::caffe::ThresholdParameter::Clear();
+ clear_has_threshold_param();
+}
+const ::caffe::ThresholdParameter& LayerParameter::threshold_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.threshold_param)
+ return threshold_param_ != NULL ? *threshold_param_
+ : *::caffe::ThresholdParameter::internal_default_instance();
+}
+::caffe::ThresholdParameter* LayerParameter::mutable_threshold_param() {
+ set_has_threshold_param();
+ if (threshold_param_ == NULL) {
+ threshold_param_ = new ::caffe::ThresholdParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.threshold_param)
+ return threshold_param_;
+}
+::caffe::ThresholdParameter* LayerParameter::release_threshold_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.threshold_param)
+ clear_has_threshold_param();
+ ::caffe::ThresholdParameter* temp = threshold_param_;
+ threshold_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_threshold_param(::caffe::ThresholdParameter* threshold_param) {
+ delete threshold_param_;
+ threshold_param_ = threshold_param;
+ if (threshold_param) {
+ set_has_threshold_param();
+ } else {
+ clear_has_threshold_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.threshold_param)
+}
+
+// optional .caffe.TileParameter tile_param = 138;
+bool LayerParameter::has_tile_param() const {
+ return (_has_bits_[1] & 0x10000000u) != 0;
+}
+void LayerParameter::set_has_tile_param() {
+ _has_bits_[1] |= 0x10000000u;
+}
+void LayerParameter::clear_has_tile_param() {
+ _has_bits_[1] &= ~0x10000000u;
+}
+void LayerParameter::clear_tile_param() {
+ if (tile_param_ != NULL) tile_param_->::caffe::TileParameter::Clear();
+ clear_has_tile_param();
+}
+const ::caffe::TileParameter& LayerParameter::tile_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.tile_param)
+ return tile_param_ != NULL ? *tile_param_
+ : *::caffe::TileParameter::internal_default_instance();
+}
+::caffe::TileParameter* LayerParameter::mutable_tile_param() {
+ set_has_tile_param();
+ if (tile_param_ == NULL) {
+ tile_param_ = new ::caffe::TileParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.tile_param)
+ return tile_param_;
+}
+::caffe::TileParameter* LayerParameter::release_tile_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.tile_param)
+ clear_has_tile_param();
+ ::caffe::TileParameter* temp = tile_param_;
+ tile_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_tile_param(::caffe::TileParameter* tile_param) {
+ delete tile_param_;
+ tile_param_ = tile_param;
+ if (tile_param) {
+ set_has_tile_param();
+ } else {
+ clear_has_tile_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.tile_param)
+}
+
+// optional .caffe.WindowDataParameter window_data_param = 129;
+bool LayerParameter::has_window_data_param() const {
+ return (_has_bits_[1] & 0x20000000u) != 0;
+}
+void LayerParameter::set_has_window_data_param() {
+ _has_bits_[1] |= 0x20000000u;
+}
+void LayerParameter::clear_has_window_data_param() {
+ _has_bits_[1] &= ~0x20000000u;
+}
+void LayerParameter::clear_window_data_param() {
+ if (window_data_param_ != NULL) window_data_param_->::caffe::WindowDataParameter::Clear();
+ clear_has_window_data_param();
+}
+const ::caffe::WindowDataParameter& LayerParameter::window_data_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.window_data_param)
+ return window_data_param_ != NULL ? *window_data_param_
+ : *::caffe::WindowDataParameter::internal_default_instance();
+}
+::caffe::WindowDataParameter* LayerParameter::mutable_window_data_param() {
+ set_has_window_data_param();
+ if (window_data_param_ == NULL) {
+ window_data_param_ = new ::caffe::WindowDataParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.window_data_param)
+ return window_data_param_;
+}
+::caffe::WindowDataParameter* LayerParameter::release_window_data_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.window_data_param)
+ clear_has_window_data_param();
+ ::caffe::WindowDataParameter* temp = window_data_param_;
+ window_data_param_ = NULL;
+ return temp;
+}
+void LayerParameter::set_allocated_window_data_param(::caffe::WindowDataParameter* window_data_param) {
+ delete window_data_param_;
+ window_data_param_ = window_data_param;
+ if (window_data_param) {
+ set_has_window_data_param();
+ } else {
+ clear_has_window_data_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.window_data_param)
+}
+
+inline const LayerParameter* LayerParameter::internal_default_instance() {
+ return &LayerParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int TransformationParameter::kScaleFieldNumber;
+const int TransformationParameter::kMirrorFieldNumber;
+const int TransformationParameter::kCropSizeFieldNumber;
+const int TransformationParameter::kMeanFileFieldNumber;
+const int TransformationParameter::kMeanValueFieldNumber;
+const int TransformationParameter::kForceColorFieldNumber;
+const int TransformationParameter::kForceGrayFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+TransformationParameter::TransformationParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.TransformationParameter)
+}
+
+void TransformationParameter::InitAsDefaultInstance() {
+}
+
+TransformationParameter::TransformationParameter(const TransformationParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.TransformationParameter)
+}
+
+void TransformationParameter::SharedCtor() {
+ _cached_size_ = 0;
+ mean_file_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ ::memset(&crop_size_, 0, reinterpret_cast<char*>(&force_gray_) -
+ reinterpret_cast<char*>(&crop_size_) + sizeof(force_gray_));
+ scale_ = 1;
+}
+
+TransformationParameter::~TransformationParameter() {
+ // @@protoc_insertion_point(destructor:caffe.TransformationParameter)
+ SharedDtor();
+}
+
+void TransformationParameter::SharedDtor() {
+ mean_file_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+
+void TransformationParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* TransformationParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return TransformationParameter_descriptor_;
+}
+
+const TransformationParameter& TransformationParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<TransformationParameter> TransformationParameter_default_instance_;
+
+TransformationParameter* TransformationParameter::New(::google::protobuf::Arena* arena) const {
+ TransformationParameter* n = new TransformationParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void TransformationParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.TransformationParameter)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(TransformationParameter, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<TransformationParameter*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ if (_has_bits_[0 / 32] & 111u) {
+ ZR_(crop_size_, force_gray_);
+ scale_ = 1;
+ if (has_mean_file()) {
+ mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ }
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ mean_value_.Clear();
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool TransformationParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.TransformationParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional float scale = 1 [default = 1];
+ case 1: {
+ if (tag == 13) {
+ set_has_scale();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &scale_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_mirror;
+ break;
+ }
+
+ // optional bool mirror = 2 [default = false];
+ case 2: {
+ if (tag == 16) {
+ parse_mirror:
+ set_has_mirror();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &mirror_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(24)) goto parse_crop_size;
+ break;
+ }
+
+ // optional uint32 crop_size = 3 [default = 0];
+ case 3: {
+ if (tag == 24) {
+ parse_crop_size:
+ set_has_crop_size();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &crop_size_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(34)) goto parse_mean_file;
+ break;
+ }
+
+ // optional string mean_file = 4;
+ case 4: {
+ if (tag == 34) {
+ parse_mean_file:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_mean_file()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->mean_file().data(), this->mean_file().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.TransformationParameter.mean_file");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(45)) goto parse_mean_value;
+ break;
+ }
+
+ // repeated float mean_value = 5;
+ case 5: {
+ if (tag == 45) {
+ parse_mean_value:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ 1, 45, input, this->mutable_mean_value())));
+ } else if (tag == 42) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, this->mutable_mean_value())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(45)) goto parse_mean_value;
+ if (input->ExpectTag(48)) goto parse_force_color;
+ break;
+ }
+
+ // optional bool force_color = 6 [default = false];
+ case 6: {
+ if (tag == 48) {
+ parse_force_color:
+ set_has_force_color();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &force_color_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(56)) goto parse_force_gray;
+ break;
+ }
+
+ // optional bool force_gray = 7 [default = false];
+ case 7: {
+ if (tag == 56) {
+ parse_force_gray:
+ set_has_force_gray();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &force_gray_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.TransformationParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.TransformationParameter)
+ return false;
+#undef DO_
+}
+
+void TransformationParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.TransformationParameter)
+ // optional float scale = 1 [default = 1];
+ if (has_scale()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->scale(), output);
+ }
+
+ // optional bool mirror = 2 [default = false];
+ if (has_mirror()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->mirror(), output);
+ }
+
+ // optional uint32 crop_size = 3 [default = 0];
+ if (has_crop_size()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(3, this->crop_size(), output);
+ }
+
+ // optional string mean_file = 4;
+ if (has_mean_file()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->mean_file().data(), this->mean_file().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.TransformationParameter.mean_file");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 4, this->mean_file(), output);
+ }
+
+ // repeated float mean_value = 5;
+ for (int i = 0; i < this->mean_value_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(
+ 5, this->mean_value(i), output);
+ }
+
+ // optional bool force_color = 6 [default = false];
+ if (has_force_color()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(6, this->force_color(), output);
+ }
+
+ // optional bool force_gray = 7 [default = false];
+ if (has_force_gray()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(7, this->force_gray(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.TransformationParameter)
+}
+
+::google::protobuf::uint8* TransformationParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.TransformationParameter)
+ // optional float scale = 1 [default = 1];
+ if (has_scale()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->scale(), target);
+ }
+
+ // optional bool mirror = 2 [default = false];
+ if (has_mirror()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->mirror(), target);
+ }
+
+ // optional uint32 crop_size = 3 [default = 0];
+ if (has_crop_size()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(3, this->crop_size(), target);
+ }
+
+ // optional string mean_file = 4;
+ if (has_mean_file()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->mean_file().data(), this->mean_file().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.TransformationParameter.mean_file");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 4, this->mean_file(), target);
+ }
+
+ // repeated float mean_value = 5;
+ for (int i = 0; i < this->mean_value_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteFloatToArray(5, this->mean_value(i), target);
+ }
+
+ // optional bool force_color = 6 [default = false];
+ if (has_force_color()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(6, this->force_color(), target);
+ }
+
+ // optional bool force_gray = 7 [default = false];
+ if (has_force_gray()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(7, this->force_gray(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.TransformationParameter)
+ return target;
+}
+
+size_t TransformationParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.TransformationParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 111u) {
+ // optional float scale = 1 [default = 1];
+ if (has_scale()) {
+ total_size += 1 + 4;
+ }
+
+ // optional bool mirror = 2 [default = false];
+ if (has_mirror()) {
+ total_size += 1 + 1;
+ }
+
+ // optional uint32 crop_size = 3 [default = 0];
+ if (has_crop_size()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->crop_size());
+ }
+
+ // optional string mean_file = 4;
+ if (has_mean_file()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->mean_file());
+ }
+
+ // optional bool force_color = 6 [default = false];
+ if (has_force_color()) {
+ total_size += 1 + 1;
+ }
+
+ // optional bool force_gray = 7 [default = false];
+ if (has_force_gray()) {
+ total_size += 1 + 1;
+ }
+
+ }
+ // repeated float mean_value = 5;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->mean_value_size();
+ data_size = 4UL * count;
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->mean_value_size());
+ total_size += data_size;
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void TransformationParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.TransformationParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const TransformationParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const TransformationParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.TransformationParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.TransformationParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void TransformationParameter::MergeFrom(const TransformationParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.TransformationParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void TransformationParameter::UnsafeMergeFrom(const TransformationParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ mean_value_.UnsafeMergeFrom(from.mean_value_);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_scale()) {
+ set_scale(from.scale());
+ }
+ if (from.has_mirror()) {
+ set_mirror(from.mirror());
+ }
+ if (from.has_crop_size()) {
+ set_crop_size(from.crop_size());
+ }
+ if (from.has_mean_file()) {
+ set_has_mean_file();
+ mean_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.mean_file_);
+ }
+ if (from.has_force_color()) {
+ set_force_color(from.force_color());
+ }
+ if (from.has_force_gray()) {
+ set_force_gray(from.force_gray());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void TransformationParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.TransformationParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void TransformationParameter::CopyFrom(const TransformationParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.TransformationParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool TransformationParameter::IsInitialized() const {
+
+ return true;
+}
+
+void TransformationParameter::Swap(TransformationParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void TransformationParameter::InternalSwap(TransformationParameter* other) {
+ std::swap(scale_, other->scale_);
+ std::swap(mirror_, other->mirror_);
+ std::swap(crop_size_, other->crop_size_);
+ mean_file_.Swap(&other->mean_file_);
+ mean_value_.UnsafeArenaSwap(&other->mean_value_);
+ std::swap(force_color_, other->force_color_);
+ std::swap(force_gray_, other->force_gray_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata TransformationParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = TransformationParameter_descriptor_;
+ metadata.reflection = TransformationParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// TransformationParameter
+
+// optional float scale = 1 [default = 1];
+bool TransformationParameter::has_scale() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void TransformationParameter::set_has_scale() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void TransformationParameter::clear_has_scale() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void TransformationParameter::clear_scale() {
+ scale_ = 1;
+ clear_has_scale();
+}
+float TransformationParameter::scale() const {
+ // @@protoc_insertion_point(field_get:caffe.TransformationParameter.scale)
+ return scale_;
+}
+void TransformationParameter::set_scale(float value) {
+ set_has_scale();
+ scale_ = value;
+ // @@protoc_insertion_point(field_set:caffe.TransformationParameter.scale)
+}
+
+// optional bool mirror = 2 [default = false];
+bool TransformationParameter::has_mirror() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void TransformationParameter::set_has_mirror() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void TransformationParameter::clear_has_mirror() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void TransformationParameter::clear_mirror() {
+ mirror_ = false;
+ clear_has_mirror();
+}
+bool TransformationParameter::mirror() const {
+ // @@protoc_insertion_point(field_get:caffe.TransformationParameter.mirror)
+ return mirror_;
+}
+void TransformationParameter::set_mirror(bool value) {
+ set_has_mirror();
+ mirror_ = value;
+ // @@protoc_insertion_point(field_set:caffe.TransformationParameter.mirror)
+}
+
+// optional uint32 crop_size = 3 [default = 0];
+bool TransformationParameter::has_crop_size() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void TransformationParameter::set_has_crop_size() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void TransformationParameter::clear_has_crop_size() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void TransformationParameter::clear_crop_size() {
+ crop_size_ = 0u;
+ clear_has_crop_size();
+}
+::google::protobuf::uint32 TransformationParameter::crop_size() const {
+ // @@protoc_insertion_point(field_get:caffe.TransformationParameter.crop_size)
+ return crop_size_;
+}
+void TransformationParameter::set_crop_size(::google::protobuf::uint32 value) {
+ set_has_crop_size();
+ crop_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.TransformationParameter.crop_size)
+}
+
+// optional string mean_file = 4;
+bool TransformationParameter::has_mean_file() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+void TransformationParameter::set_has_mean_file() {
+ _has_bits_[0] |= 0x00000008u;
+}
+void TransformationParameter::clear_has_mean_file() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+void TransformationParameter::clear_mean_file() {
+ mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_mean_file();
+}
+const ::std::string& TransformationParameter::mean_file() const {
+ // @@protoc_insertion_point(field_get:caffe.TransformationParameter.mean_file)
+ return mean_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void TransformationParameter::set_mean_file(const ::std::string& value) {
+ set_has_mean_file();
+ mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.TransformationParameter.mean_file)
+}
+void TransformationParameter::set_mean_file(const char* value) {
+ set_has_mean_file();
+ mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.TransformationParameter.mean_file)
+}
+void TransformationParameter::set_mean_file(const char* value, size_t size) {
+ set_has_mean_file();
+ mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.TransformationParameter.mean_file)
+}
+::std::string* TransformationParameter::mutable_mean_file() {
+ set_has_mean_file();
+ // @@protoc_insertion_point(field_mutable:caffe.TransformationParameter.mean_file)
+ return mean_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* TransformationParameter::release_mean_file() {
+ // @@protoc_insertion_point(field_release:caffe.TransformationParameter.mean_file)
+ clear_has_mean_file();
+ return mean_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void TransformationParameter::set_allocated_mean_file(::std::string* mean_file) {
+ if (mean_file != NULL) {
+ set_has_mean_file();
+ } else {
+ clear_has_mean_file();
+ }
+ mean_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), mean_file);
+ // @@protoc_insertion_point(field_set_allocated:caffe.TransformationParameter.mean_file)
+}
+
+// repeated float mean_value = 5;
+int TransformationParameter::mean_value_size() const {
+ return mean_value_.size();
+}
+void TransformationParameter::clear_mean_value() {
+ mean_value_.Clear();
+}
+float TransformationParameter::mean_value(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.TransformationParameter.mean_value)
+ return mean_value_.Get(index);
+}
+void TransformationParameter::set_mean_value(int index, float value) {
+ mean_value_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.TransformationParameter.mean_value)
+}
+void TransformationParameter::add_mean_value(float value) {
+ mean_value_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.TransformationParameter.mean_value)
+}
+const ::google::protobuf::RepeatedField< float >&
+TransformationParameter::mean_value() const {
+ // @@protoc_insertion_point(field_list:caffe.TransformationParameter.mean_value)
+ return mean_value_;
+}
+::google::protobuf::RepeatedField< float >*
+TransformationParameter::mutable_mean_value() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.TransformationParameter.mean_value)
+ return &mean_value_;
+}
+
+// optional bool force_color = 6 [default = false];
+bool TransformationParameter::has_force_color() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+void TransformationParameter::set_has_force_color() {
+ _has_bits_[0] |= 0x00000020u;
+}
+void TransformationParameter::clear_has_force_color() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+void TransformationParameter::clear_force_color() {
+ force_color_ = false;
+ clear_has_force_color();
+}
+bool TransformationParameter::force_color() const {
+ // @@protoc_insertion_point(field_get:caffe.TransformationParameter.force_color)
+ return force_color_;
+}
+void TransformationParameter::set_force_color(bool value) {
+ set_has_force_color();
+ force_color_ = value;
+ // @@protoc_insertion_point(field_set:caffe.TransformationParameter.force_color)
+}
+
+// optional bool force_gray = 7 [default = false];
+bool TransformationParameter::has_force_gray() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+void TransformationParameter::set_has_force_gray() {
+ _has_bits_[0] |= 0x00000040u;
+}
+void TransformationParameter::clear_has_force_gray() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+void TransformationParameter::clear_force_gray() {
+ force_gray_ = false;
+ clear_has_force_gray();
+}
+bool TransformationParameter::force_gray() const {
+ // @@protoc_insertion_point(field_get:caffe.TransformationParameter.force_gray)
+ return force_gray_;
+}
+void TransformationParameter::set_force_gray(bool value) {
+ set_has_force_gray();
+ force_gray_ = value;
+ // @@protoc_insertion_point(field_set:caffe.TransformationParameter.force_gray)
+}
+
+inline const TransformationParameter* TransformationParameter::internal_default_instance() {
+ return &TransformationParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+const ::google::protobuf::EnumDescriptor* LossParameter_NormalizationMode_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return LossParameter_NormalizationMode_descriptor_;
+}
+bool LossParameter_NormalizationMode_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const LossParameter_NormalizationMode LossParameter::FULL;
+const LossParameter_NormalizationMode LossParameter::VALID;
+const LossParameter_NormalizationMode LossParameter::BATCH_SIZE;
+const LossParameter_NormalizationMode LossParameter::NONE;
+const LossParameter_NormalizationMode LossParameter::NormalizationMode_MIN;
+const LossParameter_NormalizationMode LossParameter::NormalizationMode_MAX;
+const int LossParameter::NormalizationMode_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int LossParameter::kIgnoreLabelFieldNumber;
+const int LossParameter::kNormalizationFieldNumber;
+const int LossParameter::kNormalizeFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+LossParameter::LossParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.LossParameter)
+}
+
+void LossParameter::InitAsDefaultInstance() {
+}
+
+LossParameter::LossParameter(const LossParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.LossParameter)
+}
+
+void LossParameter::SharedCtor() {
+ _cached_size_ = 0;
+ ::memset(&ignore_label_, 0, reinterpret_cast<char*>(&normalize_) -
+ reinterpret_cast<char*>(&ignore_label_) + sizeof(normalize_));
+ normalization_ = 1;
+}
+
+LossParameter::~LossParameter() {
+ // @@protoc_insertion_point(destructor:caffe.LossParameter)
+ SharedDtor();
+}
+
+void LossParameter::SharedDtor() {
+}
+
+void LossParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* LossParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return LossParameter_descriptor_;
+}
+
+const LossParameter& LossParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<LossParameter> LossParameter_default_instance_;
+
+LossParameter* LossParameter::New(::google::protobuf::Arena* arena) const {
+ LossParameter* n = new LossParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void LossParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.LossParameter)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(LossParameter, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<LossParameter*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ if (_has_bits_[0 / 32] & 7u) {
+ ZR_(ignore_label_, normalize_);
+ normalization_ = 1;
+ }
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool LossParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.LossParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional int32 ignore_label = 1;
+ case 1: {
+ if (tag == 8) {
+ set_has_ignore_label();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &ignore_label_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_normalize;
+ break;
+ }
+
+ // optional bool normalize = 2;
+ case 2: {
+ if (tag == 16) {
+ parse_normalize:
+ set_has_normalize();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &normalize_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(24)) goto parse_normalization;
+ break;
+ }
+
+ // optional .caffe.LossParameter.NormalizationMode normalization = 3 [default = VALID];
+ case 3: {
+ if (tag == 24) {
+ parse_normalization:
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::LossParameter_NormalizationMode_IsValid(value)) {
+ set_normalization(static_cast< ::caffe::LossParameter_NormalizationMode >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(3, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.LossParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.LossParameter)
+ return false;
+#undef DO_
+}
+
+void LossParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.LossParameter)
+ // optional int32 ignore_label = 1;
+ if (has_ignore_label()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->ignore_label(), output);
+ }
+
+ // optional bool normalize = 2;
+ if (has_normalize()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->normalize(), output);
+ }
+
+ // optional .caffe.LossParameter.NormalizationMode normalization = 3 [default = VALID];
+ if (has_normalization()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 3, this->normalization(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.LossParameter)
+}
+
+::google::protobuf::uint8* LossParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.LossParameter)
+ // optional int32 ignore_label = 1;
+ if (has_ignore_label()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->ignore_label(), target);
+ }
+
+ // optional bool normalize = 2;
+ if (has_normalize()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->normalize(), target);
+ }
+
+ // optional .caffe.LossParameter.NormalizationMode normalization = 3 [default = VALID];
+ if (has_normalization()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 3, this->normalization(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.LossParameter)
+ return target;
+}
+
+size_t LossParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.LossParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 7u) {
+ // optional int32 ignore_label = 1;
+ if (has_ignore_label()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->ignore_label());
+ }
+
+ // optional .caffe.LossParameter.NormalizationMode normalization = 3 [default = VALID];
+ if (has_normalization()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->normalization());
+ }
+
+ // optional bool normalize = 2;
+ if (has_normalize()) {
+ total_size += 1 + 1;
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void LossParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.LossParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const LossParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const LossParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.LossParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.LossParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void LossParameter::MergeFrom(const LossParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.LossParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void LossParameter::UnsafeMergeFrom(const LossParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_ignore_label()) {
+ set_ignore_label(from.ignore_label());
+ }
+ if (from.has_normalization()) {
+ set_normalization(from.normalization());
+ }
+ if (from.has_normalize()) {
+ set_normalize(from.normalize());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void LossParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.LossParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void LossParameter::CopyFrom(const LossParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.LossParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool LossParameter::IsInitialized() const {
+
+ return true;
+}
+
+void LossParameter::Swap(LossParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void LossParameter::InternalSwap(LossParameter* other) {
+ std::swap(ignore_label_, other->ignore_label_);
+ std::swap(normalization_, other->normalization_);
+ std::swap(normalize_, other->normalize_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata LossParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = LossParameter_descriptor_;
+ metadata.reflection = LossParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// LossParameter
+
+// optional int32 ignore_label = 1;
+bool LossParameter::has_ignore_label() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void LossParameter::set_has_ignore_label() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void LossParameter::clear_has_ignore_label() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void LossParameter::clear_ignore_label() {
+ ignore_label_ = 0;
+ clear_has_ignore_label();
+}
+::google::protobuf::int32 LossParameter::ignore_label() const {
+ // @@protoc_insertion_point(field_get:caffe.LossParameter.ignore_label)
+ return ignore_label_;
+}
+void LossParameter::set_ignore_label(::google::protobuf::int32 value) {
+ set_has_ignore_label();
+ ignore_label_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LossParameter.ignore_label)
+}
+
+// optional .caffe.LossParameter.NormalizationMode normalization = 3 [default = VALID];
+bool LossParameter::has_normalization() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void LossParameter::set_has_normalization() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void LossParameter::clear_has_normalization() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void LossParameter::clear_normalization() {
+ normalization_ = 1;
+ clear_has_normalization();
+}
+::caffe::LossParameter_NormalizationMode LossParameter::normalization() const {
+ // @@protoc_insertion_point(field_get:caffe.LossParameter.normalization)
+ return static_cast< ::caffe::LossParameter_NormalizationMode >(normalization_);
+}
+void LossParameter::set_normalization(::caffe::LossParameter_NormalizationMode value) {
+ assert(::caffe::LossParameter_NormalizationMode_IsValid(value));
+ set_has_normalization();
+ normalization_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LossParameter.normalization)
+}
+
+// optional bool normalize = 2;
+bool LossParameter::has_normalize() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void LossParameter::set_has_normalize() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void LossParameter::clear_has_normalize() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void LossParameter::clear_normalize() {
+ normalize_ = false;
+ clear_has_normalize();
+}
+bool LossParameter::normalize() const {
+ // @@protoc_insertion_point(field_get:caffe.LossParameter.normalize)
+ return normalize_;
+}
+void LossParameter::set_normalize(bool value) {
+ set_has_normalize();
+ normalize_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LossParameter.normalize)
+}
+
+inline const LossParameter* LossParameter::internal_default_instance() {
+ return &LossParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int AccuracyParameter::kTopKFieldNumber;
+const int AccuracyParameter::kAxisFieldNumber;
+const int AccuracyParameter::kIgnoreLabelFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+AccuracyParameter::AccuracyParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.AccuracyParameter)
+}
+
+void AccuracyParameter::InitAsDefaultInstance() {
+}
+
+AccuracyParameter::AccuracyParameter(const AccuracyParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.AccuracyParameter)
+}
+
+void AccuracyParameter::SharedCtor() {
+ _cached_size_ = 0;
+ ignore_label_ = 0;
+ top_k_ = 1u;
+ axis_ = 1;
+}
+
+AccuracyParameter::~AccuracyParameter() {
+ // @@protoc_insertion_point(destructor:caffe.AccuracyParameter)
+ SharedDtor();
+}
+
+void AccuracyParameter::SharedDtor() {
+}
+
+void AccuracyParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* AccuracyParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return AccuracyParameter_descriptor_;
+}
+
+const AccuracyParameter& AccuracyParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<AccuracyParameter> AccuracyParameter_default_instance_;
+
+AccuracyParameter* AccuracyParameter::New(::google::protobuf::Arena* arena) const {
+ AccuracyParameter* n = new AccuracyParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void AccuracyParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.AccuracyParameter)
+ if (_has_bits_[0 / 32] & 7u) {
+ top_k_ = 1u;
+ axis_ = 1;
+ ignore_label_ = 0;
+ }
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool AccuracyParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.AccuracyParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional uint32 top_k = 1 [default = 1];
+ case 1: {
+ if (tag == 8) {
+ set_has_top_k();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &top_k_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_axis;
+ break;
+ }
+
+ // optional int32 axis = 2 [default = 1];
+ case 2: {
+ if (tag == 16) {
+ parse_axis:
+ set_has_axis();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &axis_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(24)) goto parse_ignore_label;
+ break;
+ }
+
+ // optional int32 ignore_label = 3;
+ case 3: {
+ if (tag == 24) {
+ parse_ignore_label:
+ set_has_ignore_label();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &ignore_label_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.AccuracyParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.AccuracyParameter)
+ return false;
+#undef DO_
+}
+
+void AccuracyParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.AccuracyParameter)
+ // optional uint32 top_k = 1 [default = 1];
+ if (has_top_k()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->top_k(), output);
+ }
+
+ // optional int32 axis = 2 [default = 1];
+ if (has_axis()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->axis(), output);
+ }
+
+ // optional int32 ignore_label = 3;
+ if (has_ignore_label()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->ignore_label(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.AccuracyParameter)
+}
+
+::google::protobuf::uint8* AccuracyParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.AccuracyParameter)
+ // optional uint32 top_k = 1 [default = 1];
+ if (has_top_k()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->top_k(), target);
+ }
+
+ // optional int32 axis = 2 [default = 1];
+ if (has_axis()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->axis(), target);
+ }
+
+ // optional int32 ignore_label = 3;
+ if (has_ignore_label()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->ignore_label(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.AccuracyParameter)
+ return target;
+}
+
+size_t AccuracyParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.AccuracyParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 7u) {
+ // optional uint32 top_k = 1 [default = 1];
+ if (has_top_k()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->top_k());
+ }
+
+ // optional int32 axis = 2 [default = 1];
+ if (has_axis()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->axis());
+ }
+
+ // optional int32 ignore_label = 3;
+ if (has_ignore_label()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->ignore_label());
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void AccuracyParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.AccuracyParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const AccuracyParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const AccuracyParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.AccuracyParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.AccuracyParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void AccuracyParameter::MergeFrom(const AccuracyParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.AccuracyParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void AccuracyParameter::UnsafeMergeFrom(const AccuracyParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_top_k()) {
+ set_top_k(from.top_k());
+ }
+ if (from.has_axis()) {
+ set_axis(from.axis());
+ }
+ if (from.has_ignore_label()) {
+ set_ignore_label(from.ignore_label());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void AccuracyParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.AccuracyParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void AccuracyParameter::CopyFrom(const AccuracyParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.AccuracyParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool AccuracyParameter::IsInitialized() const {
+
+ return true;
+}
+
+void AccuracyParameter::Swap(AccuracyParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void AccuracyParameter::InternalSwap(AccuracyParameter* other) {
+ std::swap(top_k_, other->top_k_);
+ std::swap(axis_, other->axis_);
+ std::swap(ignore_label_, other->ignore_label_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata AccuracyParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = AccuracyParameter_descriptor_;
+ metadata.reflection = AccuracyParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// AccuracyParameter
+
+// optional uint32 top_k = 1 [default = 1];
+bool AccuracyParameter::has_top_k() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void AccuracyParameter::set_has_top_k() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void AccuracyParameter::clear_has_top_k() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void AccuracyParameter::clear_top_k() {
+ top_k_ = 1u;
+ clear_has_top_k();
+}
+::google::protobuf::uint32 AccuracyParameter::top_k() const {
+ // @@protoc_insertion_point(field_get:caffe.AccuracyParameter.top_k)
+ return top_k_;
+}
+void AccuracyParameter::set_top_k(::google::protobuf::uint32 value) {
+ set_has_top_k();
+ top_k_ = value;
+ // @@protoc_insertion_point(field_set:caffe.AccuracyParameter.top_k)
+}
+
+// optional int32 axis = 2 [default = 1];
+bool AccuracyParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void AccuracyParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void AccuracyParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void AccuracyParameter::clear_axis() {
+ axis_ = 1;
+ clear_has_axis();
+}
+::google::protobuf::int32 AccuracyParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.AccuracyParameter.axis)
+ return axis_;
+}
+void AccuracyParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.AccuracyParameter.axis)
+}
+
+// optional int32 ignore_label = 3;
+bool AccuracyParameter::has_ignore_label() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void AccuracyParameter::set_has_ignore_label() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void AccuracyParameter::clear_has_ignore_label() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void AccuracyParameter::clear_ignore_label() {
+ ignore_label_ = 0;
+ clear_has_ignore_label();
+}
+::google::protobuf::int32 AccuracyParameter::ignore_label() const {
+ // @@protoc_insertion_point(field_get:caffe.AccuracyParameter.ignore_label)
+ return ignore_label_;
+}
+void AccuracyParameter::set_ignore_label(::google::protobuf::int32 value) {
+ set_has_ignore_label();
+ ignore_label_ = value;
+ // @@protoc_insertion_point(field_set:caffe.AccuracyParameter.ignore_label)
+}
+
+inline const AccuracyParameter* AccuracyParameter::internal_default_instance() {
+ return &AccuracyParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int ArgMaxParameter::kOutMaxValFieldNumber;
+const int ArgMaxParameter::kTopKFieldNumber;
+const int ArgMaxParameter::kAxisFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+ArgMaxParameter::ArgMaxParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.ArgMaxParameter)
+}
+
+void ArgMaxParameter::InitAsDefaultInstance() {
+}
+
+ArgMaxParameter::ArgMaxParameter(const ArgMaxParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.ArgMaxParameter)
+}
+
+void ArgMaxParameter::SharedCtor() {
+ _cached_size_ = 0;
+ ::memset(&out_max_val_, 0, reinterpret_cast<char*>(&axis_) -
+ reinterpret_cast<char*>(&out_max_val_) + sizeof(axis_));
+ top_k_ = 1u;
+}
+
+ArgMaxParameter::~ArgMaxParameter() {
+ // @@protoc_insertion_point(destructor:caffe.ArgMaxParameter)
+ SharedDtor();
+}
+
+void ArgMaxParameter::SharedDtor() {
+}
+
+void ArgMaxParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* ArgMaxParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return ArgMaxParameter_descriptor_;
+}
+
+const ArgMaxParameter& ArgMaxParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<ArgMaxParameter> ArgMaxParameter_default_instance_;
+
+ArgMaxParameter* ArgMaxParameter::New(::google::protobuf::Arena* arena) const {
+ ArgMaxParameter* n = new ArgMaxParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void ArgMaxParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.ArgMaxParameter)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(ArgMaxParameter, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<ArgMaxParameter*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ if (_has_bits_[0 / 32] & 7u) {
+ ZR_(out_max_val_, axis_);
+ top_k_ = 1u;
+ }
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool ArgMaxParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.ArgMaxParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional bool out_max_val = 1 [default = false];
+ case 1: {
+ if (tag == 8) {
+ set_has_out_max_val();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &out_max_val_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_top_k;
+ break;
+ }
+
+ // optional uint32 top_k = 2 [default = 1];
+ case 2: {
+ if (tag == 16) {
+ parse_top_k:
+ set_has_top_k();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &top_k_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(24)) goto parse_axis;
+ break;
+ }
+
+ // optional int32 axis = 3;
+ case 3: {
+ if (tag == 24) {
+ parse_axis:
+ set_has_axis();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &axis_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.ArgMaxParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.ArgMaxParameter)
+ return false;
+#undef DO_
+}
+
+void ArgMaxParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.ArgMaxParameter)
+ // optional bool out_max_val = 1 [default = false];
+ if (has_out_max_val()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(1, this->out_max_val(), output);
+ }
+
+ // optional uint32 top_k = 2 [default = 1];
+ if (has_top_k()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(2, this->top_k(), output);
+ }
+
+ // optional int32 axis = 3;
+ if (has_axis()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->axis(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.ArgMaxParameter)
+}
+
+::google::protobuf::uint8* ArgMaxParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.ArgMaxParameter)
+ // optional bool out_max_val = 1 [default = false];
+ if (has_out_max_val()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->out_max_val(), target);
+ }
+
+ // optional uint32 top_k = 2 [default = 1];
+ if (has_top_k()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(2, this->top_k(), target);
+ }
+
+ // optional int32 axis = 3;
+ if (has_axis()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->axis(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.ArgMaxParameter)
+ return target;
+}
+
+size_t ArgMaxParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.ArgMaxParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 7u) {
+ // optional bool out_max_val = 1 [default = false];
+ if (has_out_max_val()) {
+ total_size += 1 + 1;
+ }
+
+ // optional uint32 top_k = 2 [default = 1];
+ if (has_top_k()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->top_k());
+ }
+
+ // optional int32 axis = 3;
+ if (has_axis()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->axis());
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void ArgMaxParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.ArgMaxParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const ArgMaxParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const ArgMaxParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ArgMaxParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ArgMaxParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void ArgMaxParameter::MergeFrom(const ArgMaxParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ArgMaxParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void ArgMaxParameter::UnsafeMergeFrom(const ArgMaxParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_out_max_val()) {
+ set_out_max_val(from.out_max_val());
+ }
+ if (from.has_top_k()) {
+ set_top_k(from.top_k());
+ }
+ if (from.has_axis()) {
+ set_axis(from.axis());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void ArgMaxParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.ArgMaxParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void ArgMaxParameter::CopyFrom(const ArgMaxParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ArgMaxParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool ArgMaxParameter::IsInitialized() const {
+
+ return true;
+}
+
+void ArgMaxParameter::Swap(ArgMaxParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void ArgMaxParameter::InternalSwap(ArgMaxParameter* other) {
+ std::swap(out_max_val_, other->out_max_val_);
+ std::swap(top_k_, other->top_k_);
+ std::swap(axis_, other->axis_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata ArgMaxParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = ArgMaxParameter_descriptor_;
+ metadata.reflection = ArgMaxParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// ArgMaxParameter
+
+// optional bool out_max_val = 1 [default = false];
+bool ArgMaxParameter::has_out_max_val() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void ArgMaxParameter::set_has_out_max_val() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void ArgMaxParameter::clear_has_out_max_val() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void ArgMaxParameter::clear_out_max_val() {
+ out_max_val_ = false;
+ clear_has_out_max_val();
+}
+bool ArgMaxParameter::out_max_val() const {
+ // @@protoc_insertion_point(field_get:caffe.ArgMaxParameter.out_max_val)
+ return out_max_val_;
+}
+void ArgMaxParameter::set_out_max_val(bool value) {
+ set_has_out_max_val();
+ out_max_val_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ArgMaxParameter.out_max_val)
+}
+
+// optional uint32 top_k = 2 [default = 1];
+bool ArgMaxParameter::has_top_k() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void ArgMaxParameter::set_has_top_k() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void ArgMaxParameter::clear_has_top_k() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void ArgMaxParameter::clear_top_k() {
+ top_k_ = 1u;
+ clear_has_top_k();
+}
+::google::protobuf::uint32 ArgMaxParameter::top_k() const {
+ // @@protoc_insertion_point(field_get:caffe.ArgMaxParameter.top_k)
+ return top_k_;
+}
+void ArgMaxParameter::set_top_k(::google::protobuf::uint32 value) {
+ set_has_top_k();
+ top_k_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ArgMaxParameter.top_k)
+}
+
+// optional int32 axis = 3;
+bool ArgMaxParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void ArgMaxParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void ArgMaxParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void ArgMaxParameter::clear_axis() {
+ axis_ = 0;
+ clear_has_axis();
+}
+::google::protobuf::int32 ArgMaxParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.ArgMaxParameter.axis)
+ return axis_;
+}
+void ArgMaxParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ArgMaxParameter.axis)
+}
+
+inline const ArgMaxParameter* ArgMaxParameter::internal_default_instance() {
+ return &ArgMaxParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int ConcatParameter::kAxisFieldNumber;
+const int ConcatParameter::kConcatDimFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+ConcatParameter::ConcatParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.ConcatParameter)
+}
+
+void ConcatParameter::InitAsDefaultInstance() {
+}
+
+ConcatParameter::ConcatParameter(const ConcatParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.ConcatParameter)
+}
+
+void ConcatParameter::SharedCtor() {
+ _cached_size_ = 0;
+ axis_ = 1;
+ concat_dim_ = 1u;
+}
+
+ConcatParameter::~ConcatParameter() {
+ // @@protoc_insertion_point(destructor:caffe.ConcatParameter)
+ SharedDtor();
+}
+
+void ConcatParameter::SharedDtor() {
+}
+
+void ConcatParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* ConcatParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return ConcatParameter_descriptor_;
+}
+
+const ConcatParameter& ConcatParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<ConcatParameter> ConcatParameter_default_instance_;
+
+ConcatParameter* ConcatParameter::New(::google::protobuf::Arena* arena) const {
+ ConcatParameter* n = new ConcatParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void ConcatParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.ConcatParameter)
+ if (_has_bits_[0 / 32] & 3u) {
+ axis_ = 1;
+ concat_dim_ = 1u;
+ }
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool ConcatParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.ConcatParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional uint32 concat_dim = 1 [default = 1];
+ case 1: {
+ if (tag == 8) {
+ set_has_concat_dim();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &concat_dim_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_axis;
+ break;
+ }
+
+ // optional int32 axis = 2 [default = 1];
+ case 2: {
+ if (tag == 16) {
+ parse_axis:
+ set_has_axis();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &axis_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.ConcatParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.ConcatParameter)
+ return false;
+#undef DO_
+}
+
+void ConcatParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.ConcatParameter)
+ // optional uint32 concat_dim = 1 [default = 1];
+ if (has_concat_dim()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->concat_dim(), output);
+ }
+
+ // optional int32 axis = 2 [default = 1];
+ if (has_axis()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->axis(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.ConcatParameter)
+}
+
+::google::protobuf::uint8* ConcatParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.ConcatParameter)
+ // optional uint32 concat_dim = 1 [default = 1];
+ if (has_concat_dim()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->concat_dim(), target);
+ }
+
+ // optional int32 axis = 2 [default = 1];
+ if (has_axis()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->axis(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.ConcatParameter)
+ return target;
+}
+
+size_t ConcatParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.ConcatParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 3u) {
+ // optional int32 axis = 2 [default = 1];
+ if (has_axis()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->axis());
+ }
+
+ // optional uint32 concat_dim = 1 [default = 1];
+ if (has_concat_dim()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->concat_dim());
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void ConcatParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.ConcatParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const ConcatParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const ConcatParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ConcatParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ConcatParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void ConcatParameter::MergeFrom(const ConcatParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ConcatParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void ConcatParameter::UnsafeMergeFrom(const ConcatParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_axis()) {
+ set_axis(from.axis());
+ }
+ if (from.has_concat_dim()) {
+ set_concat_dim(from.concat_dim());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void ConcatParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.ConcatParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void ConcatParameter::CopyFrom(const ConcatParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ConcatParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool ConcatParameter::IsInitialized() const {
+
+ return true;
+}
+
+void ConcatParameter::Swap(ConcatParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void ConcatParameter::InternalSwap(ConcatParameter* other) {
+ std::swap(axis_, other->axis_);
+ std::swap(concat_dim_, other->concat_dim_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata ConcatParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = ConcatParameter_descriptor_;
+ metadata.reflection = ConcatParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// ConcatParameter
+
+// optional int32 axis = 2 [default = 1];
+bool ConcatParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void ConcatParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void ConcatParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void ConcatParameter::clear_axis() {
+ axis_ = 1;
+ clear_has_axis();
+}
+::google::protobuf::int32 ConcatParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.ConcatParameter.axis)
+ return axis_;
+}
+void ConcatParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConcatParameter.axis)
+}
+
+// optional uint32 concat_dim = 1 [default = 1];
+bool ConcatParameter::has_concat_dim() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void ConcatParameter::set_has_concat_dim() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void ConcatParameter::clear_has_concat_dim() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void ConcatParameter::clear_concat_dim() {
+ concat_dim_ = 1u;
+ clear_has_concat_dim();
+}
+::google::protobuf::uint32 ConcatParameter::concat_dim() const {
+ // @@protoc_insertion_point(field_get:caffe.ConcatParameter.concat_dim)
+ return concat_dim_;
+}
+void ConcatParameter::set_concat_dim(::google::protobuf::uint32 value) {
+ set_has_concat_dim();
+ concat_dim_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConcatParameter.concat_dim)
+}
+
+inline const ConcatParameter* ConcatParameter::internal_default_instance() {
+ return &ConcatParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int BatchNormParameter::kUseGlobalStatsFieldNumber;
+const int BatchNormParameter::kMovingAverageFractionFieldNumber;
+const int BatchNormParameter::kEpsFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+BatchNormParameter::BatchNormParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.BatchNormParameter)
+}
+
+void BatchNormParameter::InitAsDefaultInstance() {
+}
+
+BatchNormParameter::BatchNormParameter(const BatchNormParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.BatchNormParameter)
+}
+
+void BatchNormParameter::SharedCtor() {
+ _cached_size_ = 0;
+ use_global_stats_ = false;
+ moving_average_fraction_ = 0.999f;
+ eps_ = 1e-05f;
+}
+
+BatchNormParameter::~BatchNormParameter() {
+ // @@protoc_insertion_point(destructor:caffe.BatchNormParameter)
+ SharedDtor();
+}
+
+void BatchNormParameter::SharedDtor() {
+}
+
+void BatchNormParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* BatchNormParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return BatchNormParameter_descriptor_;
+}
+
+const BatchNormParameter& BatchNormParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<BatchNormParameter> BatchNormParameter_default_instance_;
+
+BatchNormParameter* BatchNormParameter::New(::google::protobuf::Arena* arena) const {
+ BatchNormParameter* n = new BatchNormParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void BatchNormParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.BatchNormParameter)
+ if (_has_bits_[0 / 32] & 7u) {
+ use_global_stats_ = false;
+ moving_average_fraction_ = 0.999f;
+ eps_ = 1e-05f;
+ }
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool BatchNormParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.BatchNormParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional bool use_global_stats = 1;
+ case 1: {
+ if (tag == 8) {
+ set_has_use_global_stats();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &use_global_stats_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(21)) goto parse_moving_average_fraction;
+ break;
+ }
+
+ // optional float moving_average_fraction = 2 [default = 0.999];
+ case 2: {
+ if (tag == 21) {
+ parse_moving_average_fraction:
+ set_has_moving_average_fraction();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &moving_average_fraction_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(29)) goto parse_eps;
+ break;
+ }
+
+ // optional float eps = 3 [default = 1e-05];
+ case 3: {
+ if (tag == 29) {
+ parse_eps:
+ set_has_eps();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &eps_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.BatchNormParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.BatchNormParameter)
+ return false;
+#undef DO_
+}
+
+void BatchNormParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.BatchNormParameter)
+ // optional bool use_global_stats = 1;
+ if (has_use_global_stats()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(1, this->use_global_stats(), output);
+ }
+
+ // optional float moving_average_fraction = 2 [default = 0.999];
+ if (has_moving_average_fraction()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->moving_average_fraction(), output);
+ }
+
+ // optional float eps = 3 [default = 1e-05];
+ if (has_eps()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->eps(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.BatchNormParameter)
+}
+
+::google::protobuf::uint8* BatchNormParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.BatchNormParameter)
+ // optional bool use_global_stats = 1;
+ if (has_use_global_stats()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->use_global_stats(), target);
+ }
+
+ // optional float moving_average_fraction = 2 [default = 0.999];
+ if (has_moving_average_fraction()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->moving_average_fraction(), target);
+ }
+
+ // optional float eps = 3 [default = 1e-05];
+ if (has_eps()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->eps(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.BatchNormParameter)
+ return target;
+}
+
+size_t BatchNormParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.BatchNormParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 7u) {
+ // optional bool use_global_stats = 1;
+ if (has_use_global_stats()) {
+ total_size += 1 + 1;
+ }
+
+ // optional float moving_average_fraction = 2 [default = 0.999];
+ if (has_moving_average_fraction()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float eps = 3 [default = 1e-05];
+ if (has_eps()) {
+ total_size += 1 + 4;
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void BatchNormParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.BatchNormParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const BatchNormParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const BatchNormParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.BatchNormParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.BatchNormParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void BatchNormParameter::MergeFrom(const BatchNormParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.BatchNormParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void BatchNormParameter::UnsafeMergeFrom(const BatchNormParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_use_global_stats()) {
+ set_use_global_stats(from.use_global_stats());
+ }
+ if (from.has_moving_average_fraction()) {
+ set_moving_average_fraction(from.moving_average_fraction());
+ }
+ if (from.has_eps()) {
+ set_eps(from.eps());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void BatchNormParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.BatchNormParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void BatchNormParameter::CopyFrom(const BatchNormParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.BatchNormParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool BatchNormParameter::IsInitialized() const {
+
+ return true;
+}
+
+void BatchNormParameter::Swap(BatchNormParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void BatchNormParameter::InternalSwap(BatchNormParameter* other) {
+ std::swap(use_global_stats_, other->use_global_stats_);
+ std::swap(moving_average_fraction_, other->moving_average_fraction_);
+ std::swap(eps_, other->eps_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata BatchNormParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = BatchNormParameter_descriptor_;
+ metadata.reflection = BatchNormParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// BatchNormParameter
+
+// optional bool use_global_stats = 1;
+bool BatchNormParameter::has_use_global_stats() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void BatchNormParameter::set_has_use_global_stats() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void BatchNormParameter::clear_has_use_global_stats() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void BatchNormParameter::clear_use_global_stats() {
+ use_global_stats_ = false;
+ clear_has_use_global_stats();
+}
+bool BatchNormParameter::use_global_stats() const {
+ // @@protoc_insertion_point(field_get:caffe.BatchNormParameter.use_global_stats)
+ return use_global_stats_;
+}
+void BatchNormParameter::set_use_global_stats(bool value) {
+ set_has_use_global_stats();
+ use_global_stats_ = value;
+ // @@protoc_insertion_point(field_set:caffe.BatchNormParameter.use_global_stats)
+}
+
+// optional float moving_average_fraction = 2 [default = 0.999];
+bool BatchNormParameter::has_moving_average_fraction() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void BatchNormParameter::set_has_moving_average_fraction() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void BatchNormParameter::clear_has_moving_average_fraction() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void BatchNormParameter::clear_moving_average_fraction() {
+ moving_average_fraction_ = 0.999f;
+ clear_has_moving_average_fraction();
+}
+float BatchNormParameter::moving_average_fraction() const {
+ // @@protoc_insertion_point(field_get:caffe.BatchNormParameter.moving_average_fraction)
+ return moving_average_fraction_;
+}
+void BatchNormParameter::set_moving_average_fraction(float value) {
+ set_has_moving_average_fraction();
+ moving_average_fraction_ = value;
+ // @@protoc_insertion_point(field_set:caffe.BatchNormParameter.moving_average_fraction)
+}
+
+// optional float eps = 3 [default = 1e-05];
+bool BatchNormParameter::has_eps() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void BatchNormParameter::set_has_eps() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void BatchNormParameter::clear_has_eps() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void BatchNormParameter::clear_eps() {
+ eps_ = 1e-05f;
+ clear_has_eps();
+}
+float BatchNormParameter::eps() const {
+ // @@protoc_insertion_point(field_get:caffe.BatchNormParameter.eps)
+ return eps_;
+}
+void BatchNormParameter::set_eps(float value) {
+ set_has_eps();
+ eps_ = value;
+ // @@protoc_insertion_point(field_set:caffe.BatchNormParameter.eps)
+}
+
+inline const BatchNormParameter* BatchNormParameter::internal_default_instance() {
+ return &BatchNormParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int BiasParameter::kAxisFieldNumber;
+const int BiasParameter::kNumAxesFieldNumber;
+const int BiasParameter::kFillerFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+BiasParameter::BiasParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.BiasParameter)
+}
+
+void BiasParameter::InitAsDefaultInstance() {
+ filler_ = const_cast< ::caffe::FillerParameter*>(
+ ::caffe::FillerParameter::internal_default_instance());
+}
+
+BiasParameter::BiasParameter(const BiasParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.BiasParameter)
+}
+
+void BiasParameter::SharedCtor() {
+ _cached_size_ = 0;
+ filler_ = NULL;
+ axis_ = 1;
+ num_axes_ = 1;
+}
+
+BiasParameter::~BiasParameter() {
+ // @@protoc_insertion_point(destructor:caffe.BiasParameter)
+ SharedDtor();
+}
+
+void BiasParameter::SharedDtor() {
+ if (this != &BiasParameter_default_instance_.get()) {
+ delete filler_;
+ }
+}
+
+void BiasParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* BiasParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return BiasParameter_descriptor_;
+}
+
+const BiasParameter& BiasParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<BiasParameter> BiasParameter_default_instance_;
+
+BiasParameter* BiasParameter::New(::google::protobuf::Arena* arena) const {
+ BiasParameter* n = new BiasParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void BiasParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.BiasParameter)
+ if (_has_bits_[0 / 32] & 7u) {
+ axis_ = 1;
+ num_axes_ = 1;
+ if (has_filler()) {
+ if (filler_ != NULL) filler_->::caffe::FillerParameter::Clear();
+ }
+ }
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool BiasParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.BiasParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional int32 axis = 1 [default = 1];
+ case 1: {
+ if (tag == 8) {
+ set_has_axis();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &axis_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_num_axes;
+ break;
+ }
+
+ // optional int32 num_axes = 2 [default = 1];
+ case 2: {
+ if (tag == 16) {
+ parse_num_axes:
+ set_has_num_axes();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &num_axes_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(26)) goto parse_filler;
+ break;
+ }
+
+ // optional .caffe.FillerParameter filler = 3;
+ case 3: {
+ if (tag == 26) {
+ parse_filler:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_filler()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.BiasParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.BiasParameter)
+ return false;
+#undef DO_
+}
+
+void BiasParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.BiasParameter)
+ // optional int32 axis = 1 [default = 1];
+ if (has_axis()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->axis(), output);
+ }
+
+ // optional int32 num_axes = 2 [default = 1];
+ if (has_num_axes()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->num_axes(), output);
+ }
+
+ // optional .caffe.FillerParameter filler = 3;
+ if (has_filler()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 3, *this->filler_, output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.BiasParameter)
+}
+
+::google::protobuf::uint8* BiasParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.BiasParameter)
+ // optional int32 axis = 1 [default = 1];
+ if (has_axis()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->axis(), target);
+ }
+
+ // optional int32 num_axes = 2 [default = 1];
+ if (has_num_axes()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->num_axes(), target);
+ }
+
+ // optional .caffe.FillerParameter filler = 3;
+ if (has_filler()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 3, *this->filler_, false, target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.BiasParameter)
+ return target;
+}
+
+size_t BiasParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.BiasParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 7u) {
+ // optional int32 axis = 1 [default = 1];
+ if (has_axis()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->axis());
+ }
+
+ // optional int32 num_axes = 2 [default = 1];
+ if (has_num_axes()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->num_axes());
+ }
+
+ // optional .caffe.FillerParameter filler = 3;
+ if (has_filler()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->filler_);
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void BiasParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.BiasParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const BiasParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const BiasParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.BiasParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.BiasParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void BiasParameter::MergeFrom(const BiasParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.BiasParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void BiasParameter::UnsafeMergeFrom(const BiasParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_axis()) {
+ set_axis(from.axis());
+ }
+ if (from.has_num_axes()) {
+ set_num_axes(from.num_axes());
+ }
+ if (from.has_filler()) {
+ mutable_filler()->::caffe::FillerParameter::MergeFrom(from.filler());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void BiasParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.BiasParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void BiasParameter::CopyFrom(const BiasParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.BiasParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool BiasParameter::IsInitialized() const {
+
+ return true;
+}
+
+void BiasParameter::Swap(BiasParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void BiasParameter::InternalSwap(BiasParameter* other) {
+ std::swap(axis_, other->axis_);
+ std::swap(num_axes_, other->num_axes_);
+ std::swap(filler_, other->filler_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata BiasParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = BiasParameter_descriptor_;
+ metadata.reflection = BiasParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// BiasParameter
+
+// optional int32 axis = 1 [default = 1];
+bool BiasParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void BiasParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void BiasParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void BiasParameter::clear_axis() {
+ axis_ = 1;
+ clear_has_axis();
+}
+::google::protobuf::int32 BiasParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.BiasParameter.axis)
+ return axis_;
+}
+void BiasParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.BiasParameter.axis)
+}
+
+// optional int32 num_axes = 2 [default = 1];
+bool BiasParameter::has_num_axes() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void BiasParameter::set_has_num_axes() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void BiasParameter::clear_has_num_axes() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void BiasParameter::clear_num_axes() {
+ num_axes_ = 1;
+ clear_has_num_axes();
+}
+::google::protobuf::int32 BiasParameter::num_axes() const {
+ // @@protoc_insertion_point(field_get:caffe.BiasParameter.num_axes)
+ return num_axes_;
+}
+void BiasParameter::set_num_axes(::google::protobuf::int32 value) {
+ set_has_num_axes();
+ num_axes_ = value;
+ // @@protoc_insertion_point(field_set:caffe.BiasParameter.num_axes)
+}
+
+// optional .caffe.FillerParameter filler = 3;
+bool BiasParameter::has_filler() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void BiasParameter::set_has_filler() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void BiasParameter::clear_has_filler() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void BiasParameter::clear_filler() {
+ if (filler_ != NULL) filler_->::caffe::FillerParameter::Clear();
+ clear_has_filler();
+}
+const ::caffe::FillerParameter& BiasParameter::filler() const {
+ // @@protoc_insertion_point(field_get:caffe.BiasParameter.filler)
+ return filler_ != NULL ? *filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+::caffe::FillerParameter* BiasParameter::mutable_filler() {
+ set_has_filler();
+ if (filler_ == NULL) {
+ filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.BiasParameter.filler)
+ return filler_;
+}
+::caffe::FillerParameter* BiasParameter::release_filler() {
+ // @@protoc_insertion_point(field_release:caffe.BiasParameter.filler)
+ clear_has_filler();
+ ::caffe::FillerParameter* temp = filler_;
+ filler_ = NULL;
+ return temp;
+}
+void BiasParameter::set_allocated_filler(::caffe::FillerParameter* filler) {
+ delete filler_;
+ filler_ = filler;
+ if (filler) {
+ set_has_filler();
+ } else {
+ clear_has_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.BiasParameter.filler)
+}
+
+inline const BiasParameter* BiasParameter::internal_default_instance() {
+ return &BiasParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int ContrastiveLossParameter::kMarginFieldNumber;
+const int ContrastiveLossParameter::kLegacyVersionFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+ContrastiveLossParameter::ContrastiveLossParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.ContrastiveLossParameter)
+}
+
+void ContrastiveLossParameter::InitAsDefaultInstance() {
+}
+
+ContrastiveLossParameter::ContrastiveLossParameter(const ContrastiveLossParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.ContrastiveLossParameter)
+}
+
+void ContrastiveLossParameter::SharedCtor() {
+ _cached_size_ = 0;
+ legacy_version_ = false;
+ margin_ = 1;
+}
+
+ContrastiveLossParameter::~ContrastiveLossParameter() {
+ // @@protoc_insertion_point(destructor:caffe.ContrastiveLossParameter)
+ SharedDtor();
+}
+
+void ContrastiveLossParameter::SharedDtor() {
+}
+
+void ContrastiveLossParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* ContrastiveLossParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return ContrastiveLossParameter_descriptor_;
+}
+
+const ContrastiveLossParameter& ContrastiveLossParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<ContrastiveLossParameter> ContrastiveLossParameter_default_instance_;
+
+ContrastiveLossParameter* ContrastiveLossParameter::New(::google::protobuf::Arena* arena) const {
+ ContrastiveLossParameter* n = new ContrastiveLossParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void ContrastiveLossParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.ContrastiveLossParameter)
+ if (_has_bits_[0 / 32] & 3u) {
+ margin_ = 1;
+ legacy_version_ = false;
+ }
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool ContrastiveLossParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.ContrastiveLossParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional float margin = 1 [default = 1];
+ case 1: {
+ if (tag == 13) {
+ set_has_margin();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &margin_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_legacy_version;
+ break;
+ }
+
+ // optional bool legacy_version = 2 [default = false];
+ case 2: {
+ if (tag == 16) {
+ parse_legacy_version:
+ set_has_legacy_version();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &legacy_version_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.ContrastiveLossParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.ContrastiveLossParameter)
+ return false;
+#undef DO_
+}
+
+void ContrastiveLossParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.ContrastiveLossParameter)
+ // optional float margin = 1 [default = 1];
+ if (has_margin()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->margin(), output);
+ }
+
+ // optional bool legacy_version = 2 [default = false];
+ if (has_legacy_version()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->legacy_version(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.ContrastiveLossParameter)
+}
+
+::google::protobuf::uint8* ContrastiveLossParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.ContrastiveLossParameter)
+ // optional float margin = 1 [default = 1];
+ if (has_margin()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->margin(), target);
+ }
+
+ // optional bool legacy_version = 2 [default = false];
+ if (has_legacy_version()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->legacy_version(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.ContrastiveLossParameter)
+ return target;
+}
+
+size_t ContrastiveLossParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.ContrastiveLossParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 3u) {
+ // optional float margin = 1 [default = 1];
+ if (has_margin()) {
+ total_size += 1 + 4;
+ }
+
+ // optional bool legacy_version = 2 [default = false];
+ if (has_legacy_version()) {
+ total_size += 1 + 1;
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void ContrastiveLossParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.ContrastiveLossParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const ContrastiveLossParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const ContrastiveLossParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ContrastiveLossParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ContrastiveLossParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void ContrastiveLossParameter::MergeFrom(const ContrastiveLossParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ContrastiveLossParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void ContrastiveLossParameter::UnsafeMergeFrom(const ContrastiveLossParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_margin()) {
+ set_margin(from.margin());
+ }
+ if (from.has_legacy_version()) {
+ set_legacy_version(from.legacy_version());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void ContrastiveLossParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.ContrastiveLossParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void ContrastiveLossParameter::CopyFrom(const ContrastiveLossParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ContrastiveLossParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool ContrastiveLossParameter::IsInitialized() const {
+
+ return true;
+}
+
+void ContrastiveLossParameter::Swap(ContrastiveLossParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void ContrastiveLossParameter::InternalSwap(ContrastiveLossParameter* other) {
+ std::swap(margin_, other->margin_);
+ std::swap(legacy_version_, other->legacy_version_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata ContrastiveLossParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = ContrastiveLossParameter_descriptor_;
+ metadata.reflection = ContrastiveLossParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// ContrastiveLossParameter
+
+// optional float margin = 1 [default = 1];
+bool ContrastiveLossParameter::has_margin() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void ContrastiveLossParameter::set_has_margin() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void ContrastiveLossParameter::clear_has_margin() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void ContrastiveLossParameter::clear_margin() {
+ margin_ = 1;
+ clear_has_margin();
+}
+float ContrastiveLossParameter::margin() const {
+ // @@protoc_insertion_point(field_get:caffe.ContrastiveLossParameter.margin)
+ return margin_;
+}
+void ContrastiveLossParameter::set_margin(float value) {
+ set_has_margin();
+ margin_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ContrastiveLossParameter.margin)
+}
+
+// optional bool legacy_version = 2 [default = false];
+bool ContrastiveLossParameter::has_legacy_version() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void ContrastiveLossParameter::set_has_legacy_version() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void ContrastiveLossParameter::clear_has_legacy_version() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void ContrastiveLossParameter::clear_legacy_version() {
+ legacy_version_ = false;
+ clear_has_legacy_version();
+}
+bool ContrastiveLossParameter::legacy_version() const {
+ // @@protoc_insertion_point(field_get:caffe.ContrastiveLossParameter.legacy_version)
+ return legacy_version_;
+}
+void ContrastiveLossParameter::set_legacy_version(bool value) {
+ set_has_legacy_version();
+ legacy_version_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ContrastiveLossParameter.legacy_version)
+}
+
+inline const ContrastiveLossParameter* ContrastiveLossParameter::internal_default_instance() {
+ return &ContrastiveLossParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+const ::google::protobuf::EnumDescriptor* ConvolutionParameter_Engine_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return ConvolutionParameter_Engine_descriptor_;
+}
+bool ConvolutionParameter_Engine_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ case 2:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const ConvolutionParameter_Engine ConvolutionParameter::DEFAULT;
+const ConvolutionParameter_Engine ConvolutionParameter::CAFFE;
+const ConvolutionParameter_Engine ConvolutionParameter::CUDNN;
+const ConvolutionParameter_Engine ConvolutionParameter::Engine_MIN;
+const ConvolutionParameter_Engine ConvolutionParameter::Engine_MAX;
+const int ConvolutionParameter::Engine_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int ConvolutionParameter::kNumOutputFieldNumber;
+const int ConvolutionParameter::kBiasTermFieldNumber;
+const int ConvolutionParameter::kPadFieldNumber;
+const int ConvolutionParameter::kKernelSizeFieldNumber;
+const int ConvolutionParameter::kStrideFieldNumber;
+const int ConvolutionParameter::kDilationFieldNumber;
+const int ConvolutionParameter::kPadHFieldNumber;
+const int ConvolutionParameter::kPadWFieldNumber;
+const int ConvolutionParameter::kKernelHFieldNumber;
+const int ConvolutionParameter::kKernelWFieldNumber;
+const int ConvolutionParameter::kStrideHFieldNumber;
+const int ConvolutionParameter::kStrideWFieldNumber;
+const int ConvolutionParameter::kGroupFieldNumber;
+const int ConvolutionParameter::kWeightFillerFieldNumber;
+const int ConvolutionParameter::kBiasFillerFieldNumber;
+const int ConvolutionParameter::kEngineFieldNumber;
+const int ConvolutionParameter::kAxisFieldNumber;
+const int ConvolutionParameter::kForceNdIm2ColFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+ConvolutionParameter::ConvolutionParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.ConvolutionParameter)
+}
+
+void ConvolutionParameter::InitAsDefaultInstance() {
+ weight_filler_ = const_cast< ::caffe::FillerParameter*>(
+ ::caffe::FillerParameter::internal_default_instance());
+ bias_filler_ = const_cast< ::caffe::FillerParameter*>(
+ ::caffe::FillerParameter::internal_default_instance());
+}
+
+ConvolutionParameter::ConvolutionParameter(const ConvolutionParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.ConvolutionParameter)
+}
+
+void ConvolutionParameter::SharedCtor() {
+ _cached_size_ = 0;
+ weight_filler_ = NULL;
+ bias_filler_ = NULL;
+ ::memset(&num_output_, 0, reinterpret_cast<char*>(&force_nd_im2col_) -
+ reinterpret_cast<char*>(&num_output_) + sizeof(force_nd_im2col_));
+ axis_ = 1;
+ bias_term_ = true;
+ group_ = 1u;
+}
+
+ConvolutionParameter::~ConvolutionParameter() {
+ // @@protoc_insertion_point(destructor:caffe.ConvolutionParameter)
+ SharedDtor();
+}
+
+void ConvolutionParameter::SharedDtor() {
+ if (this != &ConvolutionParameter_default_instance_.get()) {
+ delete weight_filler_;
+ delete bias_filler_;
+ }
+}
+
+void ConvolutionParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* ConvolutionParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return ConvolutionParameter_descriptor_;
+}
+
+const ConvolutionParameter& ConvolutionParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<ConvolutionParameter> ConvolutionParameter_default_instance_;
+
+ConvolutionParameter* ConvolutionParameter::New(::google::protobuf::Arena* arena) const {
+ ConvolutionParameter* n = new ConvolutionParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void ConvolutionParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.ConvolutionParameter)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(ConvolutionParameter, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<ConvolutionParameter*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ if (_has_bits_[0 / 32] & 195u) {
+ ZR_(num_output_, pad_w_);
+ bias_term_ = true;
+ }
+ if (_has_bits_[8 / 32] & 65280u) {
+ ZR_(kernel_h_, engine_);
+ group_ = 1u;
+ if (has_weight_filler()) {
+ if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear();
+ }
+ if (has_bias_filler()) {
+ if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
+ }
+ }
+ if (_has_bits_[16 / 32] & 196608u) {
+ axis_ = 1;
+ force_nd_im2col_ = false;
+ }
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ pad_.Clear();
+ kernel_size_.Clear();
+ stride_.Clear();
+ dilation_.Clear();
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool ConvolutionParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.ConvolutionParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional uint32 num_output = 1;
+ case 1: {
+ if (tag == 8) {
+ set_has_num_output();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &num_output_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_bias_term;
+ break;
+ }
+
+ // optional bool bias_term = 2 [default = true];
+ case 2: {
+ if (tag == 16) {
+ parse_bias_term:
+ set_has_bias_term();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &bias_term_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(24)) goto parse_pad;
+ break;
+ }
+
+ // repeated uint32 pad = 3;
+ case 3: {
+ if (tag == 24) {
+ parse_pad:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ 1, 24, input, this->mutable_pad())));
+ } else if (tag == 26) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, this->mutable_pad())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(24)) goto parse_pad;
+ if (input->ExpectTag(32)) goto parse_kernel_size;
+ break;
+ }
+
+ // repeated uint32 kernel_size = 4;
+ case 4: {
+ if (tag == 32) {
+ parse_kernel_size:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ 1, 32, input, this->mutable_kernel_size())));
+ } else if (tag == 34) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, this->mutable_kernel_size())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(32)) goto parse_kernel_size;
+ if (input->ExpectTag(40)) goto parse_group;
+ break;
+ }
+
+ // optional uint32 group = 5 [default = 1];
+ case 5: {
+ if (tag == 40) {
+ parse_group:
+ set_has_group();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &group_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(48)) goto parse_stride;
+ break;
+ }
+
+ // repeated uint32 stride = 6;
+ case 6: {
+ if (tag == 48) {
+ parse_stride:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ 1, 48, input, this->mutable_stride())));
+ } else if (tag == 50) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, this->mutable_stride())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(48)) goto parse_stride;
+ if (input->ExpectTag(58)) goto parse_weight_filler;
+ break;
+ }
+
+ // optional .caffe.FillerParameter weight_filler = 7;
+ case 7: {
+ if (tag == 58) {
+ parse_weight_filler:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_weight_filler()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(66)) goto parse_bias_filler;
+ break;
+ }
+
+ // optional .caffe.FillerParameter bias_filler = 8;
+ case 8: {
+ if (tag == 66) {
+ parse_bias_filler:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_bias_filler()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(72)) goto parse_pad_h;
+ break;
+ }
+
+ // optional uint32 pad_h = 9 [default = 0];
+ case 9: {
+ if (tag == 72) {
+ parse_pad_h:
+ set_has_pad_h();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &pad_h_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(80)) goto parse_pad_w;
+ break;
+ }
+
+ // optional uint32 pad_w = 10 [default = 0];
+ case 10: {
+ if (tag == 80) {
+ parse_pad_w:
+ set_has_pad_w();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &pad_w_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(88)) goto parse_kernel_h;
+ break;
+ }
+
+ // optional uint32 kernel_h = 11;
+ case 11: {
+ if (tag == 88) {
+ parse_kernel_h:
+ set_has_kernel_h();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &kernel_h_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(96)) goto parse_kernel_w;
+ break;
+ }
+
+ // optional uint32 kernel_w = 12;
+ case 12: {
+ if (tag == 96) {
+ parse_kernel_w:
+ set_has_kernel_w();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &kernel_w_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(104)) goto parse_stride_h;
+ break;
+ }
+
+ // optional uint32 stride_h = 13;
+ case 13: {
+ if (tag == 104) {
+ parse_stride_h:
+ set_has_stride_h();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &stride_h_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(112)) goto parse_stride_w;
+ break;
+ }
+
+ // optional uint32 stride_w = 14;
+ case 14: {
+ if (tag == 112) {
+ parse_stride_w:
+ set_has_stride_w();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &stride_w_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(120)) goto parse_engine;
+ break;
+ }
+
+ // optional .caffe.ConvolutionParameter.Engine engine = 15 [default = DEFAULT];
+ case 15: {
+ if (tag == 120) {
+ parse_engine:
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::ConvolutionParameter_Engine_IsValid(value)) {
+ set_engine(static_cast< ::caffe::ConvolutionParameter_Engine >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(15, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(128)) goto parse_axis;
+ break;
+ }
+
+ // optional int32 axis = 16 [default = 1];
+ case 16: {
+ if (tag == 128) {
+ parse_axis:
+ set_has_axis();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &axis_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(136)) goto parse_force_nd_im2col;
+ break;
+ }
+
+ // optional bool force_nd_im2col = 17 [default = false];
+ case 17: {
+ if (tag == 136) {
+ parse_force_nd_im2col:
+ set_has_force_nd_im2col();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &force_nd_im2col_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(144)) goto parse_dilation;
+ break;
+ }
+
+ // repeated uint32 dilation = 18;
+ case 18: {
+ if (tag == 144) {
+ parse_dilation:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ 2, 144, input, this->mutable_dilation())));
+ } else if (tag == 146) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, this->mutable_dilation())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(144)) goto parse_dilation;
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.ConvolutionParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.ConvolutionParameter)
+ return false;
+#undef DO_
+}
+
+void ConvolutionParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.ConvolutionParameter)
+ // optional uint32 num_output = 1;
+ if (has_num_output()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->num_output(), output);
+ }
+
+ // optional bool bias_term = 2 [default = true];
+ if (has_bias_term()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->bias_term(), output);
+ }
+
+ // repeated uint32 pad = 3;
+ for (int i = 0; i < this->pad_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(
+ 3, this->pad(i), output);
+ }
+
+ // repeated uint32 kernel_size = 4;
+ for (int i = 0; i < this->kernel_size_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(
+ 4, this->kernel_size(i), output);
+ }
+
+ // optional uint32 group = 5 [default = 1];
+ if (has_group()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(5, this->group(), output);
+ }
+
+ // repeated uint32 stride = 6;
+ for (int i = 0; i < this->stride_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(
+ 6, this->stride(i), output);
+ }
+
+ // optional .caffe.FillerParameter weight_filler = 7;
+ if (has_weight_filler()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 7, *this->weight_filler_, output);
+ }
+
+ // optional .caffe.FillerParameter bias_filler = 8;
+ if (has_bias_filler()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 8, *this->bias_filler_, output);
+ }
+
+ // optional uint32 pad_h = 9 [default = 0];
+ if (has_pad_h()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(9, this->pad_h(), output);
+ }
+
+ // optional uint32 pad_w = 10 [default = 0];
+ if (has_pad_w()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(10, this->pad_w(), output);
+ }
+
+ // optional uint32 kernel_h = 11;
+ if (has_kernel_h()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(11, this->kernel_h(), output);
+ }
+
+ // optional uint32 kernel_w = 12;
+ if (has_kernel_w()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(12, this->kernel_w(), output);
+ }
+
+ // optional uint32 stride_h = 13;
+ if (has_stride_h()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(13, this->stride_h(), output);
+ }
+
+ // optional uint32 stride_w = 14;
+ if (has_stride_w()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(14, this->stride_w(), output);
+ }
+
+ // optional .caffe.ConvolutionParameter.Engine engine = 15 [default = DEFAULT];
+ if (has_engine()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 15, this->engine(), output);
+ }
+
+ // optional int32 axis = 16 [default = 1];
+ if (has_axis()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(16, this->axis(), output);
+ }
+
+ // optional bool force_nd_im2col = 17 [default = false];
+ if (has_force_nd_im2col()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(17, this->force_nd_im2col(), output);
+ }
+
+ // repeated uint32 dilation = 18;
+ for (int i = 0; i < this->dilation_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(
+ 18, this->dilation(i), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.ConvolutionParameter)
+}
+
+::google::protobuf::uint8* ConvolutionParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.ConvolutionParameter)
+ // optional uint32 num_output = 1;
+ if (has_num_output()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->num_output(), target);
+ }
+
+ // optional bool bias_term = 2 [default = true];
+ if (has_bias_term()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->bias_term(), target);
+ }
+
+ // repeated uint32 pad = 3;
+ for (int i = 0; i < this->pad_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteUInt32ToArray(3, this->pad(i), target);
+ }
+
+ // repeated uint32 kernel_size = 4;
+ for (int i = 0; i < this->kernel_size_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteUInt32ToArray(4, this->kernel_size(i), target);
+ }
+
+ // optional uint32 group = 5 [default = 1];
+ if (has_group()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(5, this->group(), target);
+ }
+
+ // repeated uint32 stride = 6;
+ for (int i = 0; i < this->stride_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteUInt32ToArray(6, this->stride(i), target);
+ }
+
+ // optional .caffe.FillerParameter weight_filler = 7;
+ if (has_weight_filler()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 7, *this->weight_filler_, false, target);
+ }
+
+ // optional .caffe.FillerParameter bias_filler = 8;
+ if (has_bias_filler()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 8, *this->bias_filler_, false, target);
+ }
+
+ // optional uint32 pad_h = 9 [default = 0];
+ if (has_pad_h()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(9, this->pad_h(), target);
+ }
+
+ // optional uint32 pad_w = 10 [default = 0];
+ if (has_pad_w()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(10, this->pad_w(), target);
+ }
+
+ // optional uint32 kernel_h = 11;
+ if (has_kernel_h()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(11, this->kernel_h(), target);
+ }
+
+ // optional uint32 kernel_w = 12;
+ if (has_kernel_w()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(12, this->kernel_w(), target);
+ }
+
+ // optional uint32 stride_h = 13;
+ if (has_stride_h()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(13, this->stride_h(), target);
+ }
+
+ // optional uint32 stride_w = 14;
+ if (has_stride_w()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(14, this->stride_w(), target);
+ }
+
+ // optional .caffe.ConvolutionParameter.Engine engine = 15 [default = DEFAULT];
+ if (has_engine()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 15, this->engine(), target);
+ }
+
+ // optional int32 axis = 16 [default = 1];
+ if (has_axis()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(16, this->axis(), target);
+ }
+
+ // optional bool force_nd_im2col = 17 [default = false];
+ if (has_force_nd_im2col()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(17, this->force_nd_im2col(), target);
+ }
+
+ // repeated uint32 dilation = 18;
+ for (int i = 0; i < this->dilation_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteUInt32ToArray(18, this->dilation(i), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.ConvolutionParameter)
+ return target;
+}
+
+size_t ConvolutionParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.ConvolutionParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 195u) {
+ // optional uint32 num_output = 1;
+ if (has_num_output()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->num_output());
+ }
+
+ // optional bool bias_term = 2 [default = true];
+ if (has_bias_term()) {
+ total_size += 1 + 1;
+ }
+
+ // optional uint32 pad_h = 9 [default = 0];
+ if (has_pad_h()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->pad_h());
+ }
+
+ // optional uint32 pad_w = 10 [default = 0];
+ if (has_pad_w()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->pad_w());
+ }
+
+ }
+ if (_has_bits_[8 / 32] & 65280u) {
+ // optional uint32 kernel_h = 11;
+ if (has_kernel_h()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->kernel_h());
+ }
+
+ // optional uint32 kernel_w = 12;
+ if (has_kernel_w()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->kernel_w());
+ }
+
+ // optional uint32 stride_h = 13;
+ if (has_stride_h()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->stride_h());
+ }
+
+ // optional uint32 stride_w = 14;
+ if (has_stride_w()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->stride_w());
+ }
+
+ // optional uint32 group = 5 [default = 1];
+ if (has_group()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->group());
+ }
+
+ // optional .caffe.FillerParameter weight_filler = 7;
+ if (has_weight_filler()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->weight_filler_);
+ }
+
+ // optional .caffe.FillerParameter bias_filler = 8;
+ if (has_bias_filler()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->bias_filler_);
+ }
+
+ // optional .caffe.ConvolutionParameter.Engine engine = 15 [default = DEFAULT];
+ if (has_engine()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->engine());
+ }
+
+ }
+ if (_has_bits_[16 / 32] & 196608u) {
+ // optional int32 axis = 16 [default = 1];
+ if (has_axis()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->axis());
+ }
+
+ // optional bool force_nd_im2col = 17 [default = false];
+ if (has_force_nd_im2col()) {
+ total_size += 2 + 1;
+ }
+
+ }
+ // repeated uint32 pad = 3;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->pad_size();
+ for (unsigned int i = 0; i < count; i++) {
+ data_size += ::google::protobuf::internal::WireFormatLite::
+ UInt32Size(this->pad(i));
+ }
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->pad_size());
+ total_size += data_size;
+ }
+
+ // repeated uint32 kernel_size = 4;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->kernel_size_size();
+ for (unsigned int i = 0; i < count; i++) {
+ data_size += ::google::protobuf::internal::WireFormatLite::
+ UInt32Size(this->kernel_size(i));
+ }
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->kernel_size_size());
+ total_size += data_size;
+ }
+
+ // repeated uint32 stride = 6;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->stride_size();
+ for (unsigned int i = 0; i < count; i++) {
+ data_size += ::google::protobuf::internal::WireFormatLite::
+ UInt32Size(this->stride(i));
+ }
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->stride_size());
+ total_size += data_size;
+ }
+
+ // repeated uint32 dilation = 18;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->dilation_size();
+ for (unsigned int i = 0; i < count; i++) {
+ data_size += ::google::protobuf::internal::WireFormatLite::
+ UInt32Size(this->dilation(i));
+ }
+ total_size += 2 *
+ ::google::protobuf::internal::FromIntSize(this->dilation_size());
+ total_size += data_size;
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void ConvolutionParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.ConvolutionParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const ConvolutionParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const ConvolutionParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ConvolutionParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ConvolutionParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void ConvolutionParameter::MergeFrom(const ConvolutionParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ConvolutionParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void ConvolutionParameter::UnsafeMergeFrom(const ConvolutionParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ pad_.UnsafeMergeFrom(from.pad_);
+ kernel_size_.UnsafeMergeFrom(from.kernel_size_);
+ stride_.UnsafeMergeFrom(from.stride_);
+ dilation_.UnsafeMergeFrom(from.dilation_);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_num_output()) {
+ set_num_output(from.num_output());
+ }
+ if (from.has_bias_term()) {
+ set_bias_term(from.bias_term());
+ }
+ if (from.has_pad_h()) {
+ set_pad_h(from.pad_h());
+ }
+ if (from.has_pad_w()) {
+ set_pad_w(from.pad_w());
+ }
+ }
+ if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) {
+ if (from.has_kernel_h()) {
+ set_kernel_h(from.kernel_h());
+ }
+ if (from.has_kernel_w()) {
+ set_kernel_w(from.kernel_w());
+ }
+ if (from.has_stride_h()) {
+ set_stride_h(from.stride_h());
+ }
+ if (from.has_stride_w()) {
+ set_stride_w(from.stride_w());
+ }
+ if (from.has_group()) {
+ set_group(from.group());
+ }
+ if (from.has_weight_filler()) {
+ mutable_weight_filler()->::caffe::FillerParameter::MergeFrom(from.weight_filler());
+ }
+ if (from.has_bias_filler()) {
+ mutable_bias_filler()->::caffe::FillerParameter::MergeFrom(from.bias_filler());
+ }
+ if (from.has_engine()) {
+ set_engine(from.engine());
+ }
+ }
+ if (from._has_bits_[16 / 32] & (0xffu << (16 % 32))) {
+ if (from.has_axis()) {
+ set_axis(from.axis());
+ }
+ if (from.has_force_nd_im2col()) {
+ set_force_nd_im2col(from.force_nd_im2col());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void ConvolutionParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.ConvolutionParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void ConvolutionParameter::CopyFrom(const ConvolutionParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ConvolutionParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool ConvolutionParameter::IsInitialized() const {
+
+ return true;
+}
+
+void ConvolutionParameter::Swap(ConvolutionParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void ConvolutionParameter::InternalSwap(ConvolutionParameter* other) {
+ std::swap(num_output_, other->num_output_);
+ std::swap(bias_term_, other->bias_term_);
+ pad_.UnsafeArenaSwap(&other->pad_);
+ kernel_size_.UnsafeArenaSwap(&other->kernel_size_);
+ stride_.UnsafeArenaSwap(&other->stride_);
+ dilation_.UnsafeArenaSwap(&other->dilation_);
+ std::swap(pad_h_, other->pad_h_);
+ std::swap(pad_w_, other->pad_w_);
+ std::swap(kernel_h_, other->kernel_h_);
+ std::swap(kernel_w_, other->kernel_w_);
+ std::swap(stride_h_, other->stride_h_);
+ std::swap(stride_w_, other->stride_w_);
+ std::swap(group_, other->group_);
+ std::swap(weight_filler_, other->weight_filler_);
+ std::swap(bias_filler_, other->bias_filler_);
+ std::swap(engine_, other->engine_);
+ std::swap(axis_, other->axis_);
+ std::swap(force_nd_im2col_, other->force_nd_im2col_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata ConvolutionParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = ConvolutionParameter_descriptor_;
+ metadata.reflection = ConvolutionParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// ConvolutionParameter
+
+// optional uint32 num_output = 1;
+bool ConvolutionParameter::has_num_output() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void ConvolutionParameter::set_has_num_output() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void ConvolutionParameter::clear_has_num_output() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void ConvolutionParameter::clear_num_output() {
+ num_output_ = 0u;
+ clear_has_num_output();
+}
+::google::protobuf::uint32 ConvolutionParameter::num_output() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.num_output)
+ return num_output_;
+}
+void ConvolutionParameter::set_num_output(::google::protobuf::uint32 value) {
+ set_has_num_output();
+ num_output_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.num_output)
+}
+
+// optional bool bias_term = 2 [default = true];
+bool ConvolutionParameter::has_bias_term() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void ConvolutionParameter::set_has_bias_term() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void ConvolutionParameter::clear_has_bias_term() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void ConvolutionParameter::clear_bias_term() {
+ bias_term_ = true;
+ clear_has_bias_term();
+}
+bool ConvolutionParameter::bias_term() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.bias_term)
+ return bias_term_;
+}
+void ConvolutionParameter::set_bias_term(bool value) {
+ set_has_bias_term();
+ bias_term_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.bias_term)
+}
+
+// repeated uint32 pad = 3;
+int ConvolutionParameter::pad_size() const {
+ return pad_.size();
+}
+void ConvolutionParameter::clear_pad() {
+ pad_.Clear();
+}
+::google::protobuf::uint32 ConvolutionParameter::pad(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.pad)
+ return pad_.Get(index);
+}
+void ConvolutionParameter::set_pad(int index, ::google::protobuf::uint32 value) {
+ pad_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.pad)
+}
+void ConvolutionParameter::add_pad(::google::protobuf::uint32 value) {
+ pad_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.ConvolutionParameter.pad)
+}
+const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+ConvolutionParameter::pad() const {
+ // @@protoc_insertion_point(field_list:caffe.ConvolutionParameter.pad)
+ return pad_;
+}
+::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+ConvolutionParameter::mutable_pad() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.ConvolutionParameter.pad)
+ return &pad_;
+}
+
+// repeated uint32 kernel_size = 4;
+int ConvolutionParameter::kernel_size_size() const {
+ return kernel_size_.size();
+}
+void ConvolutionParameter::clear_kernel_size() {
+ kernel_size_.Clear();
+}
+::google::protobuf::uint32 ConvolutionParameter::kernel_size(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.kernel_size)
+ return kernel_size_.Get(index);
+}
+void ConvolutionParameter::set_kernel_size(int index, ::google::protobuf::uint32 value) {
+ kernel_size_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.kernel_size)
+}
+void ConvolutionParameter::add_kernel_size(::google::protobuf::uint32 value) {
+ kernel_size_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.ConvolutionParameter.kernel_size)
+}
+const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+ConvolutionParameter::kernel_size() const {
+ // @@protoc_insertion_point(field_list:caffe.ConvolutionParameter.kernel_size)
+ return kernel_size_;
+}
+::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+ConvolutionParameter::mutable_kernel_size() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.ConvolutionParameter.kernel_size)
+ return &kernel_size_;
+}
+
+// repeated uint32 stride = 6;
+int ConvolutionParameter::stride_size() const {
+ return stride_.size();
+}
+void ConvolutionParameter::clear_stride() {
+ stride_.Clear();
+}
+::google::protobuf::uint32 ConvolutionParameter::stride(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.stride)
+ return stride_.Get(index);
+}
+void ConvolutionParameter::set_stride(int index, ::google::protobuf::uint32 value) {
+ stride_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.stride)
+}
+void ConvolutionParameter::add_stride(::google::protobuf::uint32 value) {
+ stride_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.ConvolutionParameter.stride)
+}
+const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+ConvolutionParameter::stride() const {
+ // @@protoc_insertion_point(field_list:caffe.ConvolutionParameter.stride)
+ return stride_;
+}
+::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+ConvolutionParameter::mutable_stride() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.ConvolutionParameter.stride)
+ return &stride_;
+}
+
+// repeated uint32 dilation = 18;
+int ConvolutionParameter::dilation_size() const {
+ return dilation_.size();
+}
+void ConvolutionParameter::clear_dilation() {
+ dilation_.Clear();
+}
+::google::protobuf::uint32 ConvolutionParameter::dilation(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.dilation)
+ return dilation_.Get(index);
+}
+void ConvolutionParameter::set_dilation(int index, ::google::protobuf::uint32 value) {
+ dilation_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.dilation)
+}
+void ConvolutionParameter::add_dilation(::google::protobuf::uint32 value) {
+ dilation_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.ConvolutionParameter.dilation)
+}
+const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+ConvolutionParameter::dilation() const {
+ // @@protoc_insertion_point(field_list:caffe.ConvolutionParameter.dilation)
+ return dilation_;
+}
+::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+ConvolutionParameter::mutable_dilation() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.ConvolutionParameter.dilation)
+ return &dilation_;
+}
+
+// optional uint32 pad_h = 9 [default = 0];
+bool ConvolutionParameter::has_pad_h() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+void ConvolutionParameter::set_has_pad_h() {
+ _has_bits_[0] |= 0x00000040u;
+}
+void ConvolutionParameter::clear_has_pad_h() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+void ConvolutionParameter::clear_pad_h() {
+ pad_h_ = 0u;
+ clear_has_pad_h();
+}
+::google::protobuf::uint32 ConvolutionParameter::pad_h() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.pad_h)
+ return pad_h_;
+}
+void ConvolutionParameter::set_pad_h(::google::protobuf::uint32 value) {
+ set_has_pad_h();
+ pad_h_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.pad_h)
+}
+
+// optional uint32 pad_w = 10 [default = 0];
+bool ConvolutionParameter::has_pad_w() const {
+ return (_has_bits_[0] & 0x00000080u) != 0;
+}
+void ConvolutionParameter::set_has_pad_w() {
+ _has_bits_[0] |= 0x00000080u;
+}
+void ConvolutionParameter::clear_has_pad_w() {
+ _has_bits_[0] &= ~0x00000080u;
+}
+void ConvolutionParameter::clear_pad_w() {
+ pad_w_ = 0u;
+ clear_has_pad_w();
+}
+::google::protobuf::uint32 ConvolutionParameter::pad_w() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.pad_w)
+ return pad_w_;
+}
+void ConvolutionParameter::set_pad_w(::google::protobuf::uint32 value) {
+ set_has_pad_w();
+ pad_w_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.pad_w)
+}
+
+// optional uint32 kernel_h = 11;
+bool ConvolutionParameter::has_kernel_h() const {
+ return (_has_bits_[0] & 0x00000100u) != 0;
+}
+void ConvolutionParameter::set_has_kernel_h() {
+ _has_bits_[0] |= 0x00000100u;
+}
+void ConvolutionParameter::clear_has_kernel_h() {
+ _has_bits_[0] &= ~0x00000100u;
+}
+void ConvolutionParameter::clear_kernel_h() {
+ kernel_h_ = 0u;
+ clear_has_kernel_h();
+}
+::google::protobuf::uint32 ConvolutionParameter::kernel_h() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.kernel_h)
+ return kernel_h_;
+}
+void ConvolutionParameter::set_kernel_h(::google::protobuf::uint32 value) {
+ set_has_kernel_h();
+ kernel_h_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.kernel_h)
+}
+
+// optional uint32 kernel_w = 12;
+bool ConvolutionParameter::has_kernel_w() const {
+ return (_has_bits_[0] & 0x00000200u) != 0;
+}
+void ConvolutionParameter::set_has_kernel_w() {
+ _has_bits_[0] |= 0x00000200u;
+}
+void ConvolutionParameter::clear_has_kernel_w() {
+ _has_bits_[0] &= ~0x00000200u;
+}
+void ConvolutionParameter::clear_kernel_w() {
+ kernel_w_ = 0u;
+ clear_has_kernel_w();
+}
+::google::protobuf::uint32 ConvolutionParameter::kernel_w() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.kernel_w)
+ return kernel_w_;
+}
+void ConvolutionParameter::set_kernel_w(::google::protobuf::uint32 value) {
+ set_has_kernel_w();
+ kernel_w_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.kernel_w)
+}
+
+// optional uint32 stride_h = 13;
+bool ConvolutionParameter::has_stride_h() const {
+ return (_has_bits_[0] & 0x00000400u) != 0;
+}
+void ConvolutionParameter::set_has_stride_h() {
+ _has_bits_[0] |= 0x00000400u;
+}
+void ConvolutionParameter::clear_has_stride_h() {
+ _has_bits_[0] &= ~0x00000400u;
+}
+void ConvolutionParameter::clear_stride_h() {
+ stride_h_ = 0u;
+ clear_has_stride_h();
+}
+::google::protobuf::uint32 ConvolutionParameter::stride_h() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.stride_h)
+ return stride_h_;
+}
+void ConvolutionParameter::set_stride_h(::google::protobuf::uint32 value) {
+ set_has_stride_h();
+ stride_h_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.stride_h)
+}
+
+// optional uint32 stride_w = 14;
+bool ConvolutionParameter::has_stride_w() const {
+ return (_has_bits_[0] & 0x00000800u) != 0;
+}
+void ConvolutionParameter::set_has_stride_w() {
+ _has_bits_[0] |= 0x00000800u;
+}
+void ConvolutionParameter::clear_has_stride_w() {
+ _has_bits_[0] &= ~0x00000800u;
+}
+void ConvolutionParameter::clear_stride_w() {
+ stride_w_ = 0u;
+ clear_has_stride_w();
+}
+::google::protobuf::uint32 ConvolutionParameter::stride_w() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.stride_w)
+ return stride_w_;
+}
+void ConvolutionParameter::set_stride_w(::google::protobuf::uint32 value) {
+ set_has_stride_w();
+ stride_w_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.stride_w)
+}
+
+// optional uint32 group = 5 [default = 1];
+bool ConvolutionParameter::has_group() const {
+ return (_has_bits_[0] & 0x00001000u) != 0;
+}
+void ConvolutionParameter::set_has_group() {
+ _has_bits_[0] |= 0x00001000u;
+}
+void ConvolutionParameter::clear_has_group() {
+ _has_bits_[0] &= ~0x00001000u;
+}
+void ConvolutionParameter::clear_group() {
+ group_ = 1u;
+ clear_has_group();
+}
+::google::protobuf::uint32 ConvolutionParameter::group() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.group)
+ return group_;
+}
+void ConvolutionParameter::set_group(::google::protobuf::uint32 value) {
+ set_has_group();
+ group_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.group)
+}
+
+// optional .caffe.FillerParameter weight_filler = 7;
+bool ConvolutionParameter::has_weight_filler() const {
+ return (_has_bits_[0] & 0x00002000u) != 0;
+}
+void ConvolutionParameter::set_has_weight_filler() {
+ _has_bits_[0] |= 0x00002000u;
+}
+void ConvolutionParameter::clear_has_weight_filler() {
+ _has_bits_[0] &= ~0x00002000u;
+}
+void ConvolutionParameter::clear_weight_filler() {
+ if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear();
+ clear_has_weight_filler();
+}
+const ::caffe::FillerParameter& ConvolutionParameter::weight_filler() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.weight_filler)
+ return weight_filler_ != NULL ? *weight_filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+::caffe::FillerParameter* ConvolutionParameter::mutable_weight_filler() {
+ set_has_weight_filler();
+ if (weight_filler_ == NULL) {
+ weight_filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.ConvolutionParameter.weight_filler)
+ return weight_filler_;
+}
+::caffe::FillerParameter* ConvolutionParameter::release_weight_filler() {
+ // @@protoc_insertion_point(field_release:caffe.ConvolutionParameter.weight_filler)
+ clear_has_weight_filler();
+ ::caffe::FillerParameter* temp = weight_filler_;
+ weight_filler_ = NULL;
+ return temp;
+}
+void ConvolutionParameter::set_allocated_weight_filler(::caffe::FillerParameter* weight_filler) {
+ delete weight_filler_;
+ weight_filler_ = weight_filler;
+ if (weight_filler) {
+ set_has_weight_filler();
+ } else {
+ clear_has_weight_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.ConvolutionParameter.weight_filler)
+}
+
+// optional .caffe.FillerParameter bias_filler = 8;
+bool ConvolutionParameter::has_bias_filler() const {
+ return (_has_bits_[0] & 0x00004000u) != 0;
+}
+void ConvolutionParameter::set_has_bias_filler() {
+ _has_bits_[0] |= 0x00004000u;
+}
+void ConvolutionParameter::clear_has_bias_filler() {
+ _has_bits_[0] &= ~0x00004000u;
+}
+void ConvolutionParameter::clear_bias_filler() {
+ if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
+ clear_has_bias_filler();
+}
+const ::caffe::FillerParameter& ConvolutionParameter::bias_filler() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.bias_filler)
+ return bias_filler_ != NULL ? *bias_filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+::caffe::FillerParameter* ConvolutionParameter::mutable_bias_filler() {
+ set_has_bias_filler();
+ if (bias_filler_ == NULL) {
+ bias_filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.ConvolutionParameter.bias_filler)
+ return bias_filler_;
+}
+::caffe::FillerParameter* ConvolutionParameter::release_bias_filler() {
+ // @@protoc_insertion_point(field_release:caffe.ConvolutionParameter.bias_filler)
+ clear_has_bias_filler();
+ ::caffe::FillerParameter* temp = bias_filler_;
+ bias_filler_ = NULL;
+ return temp;
+}
+void ConvolutionParameter::set_allocated_bias_filler(::caffe::FillerParameter* bias_filler) {
+ delete bias_filler_;
+ bias_filler_ = bias_filler;
+ if (bias_filler) {
+ set_has_bias_filler();
+ } else {
+ clear_has_bias_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.ConvolutionParameter.bias_filler)
+}
+
+// optional .caffe.ConvolutionParameter.Engine engine = 15 [default = DEFAULT];
+bool ConvolutionParameter::has_engine() const {
+ return (_has_bits_[0] & 0x00008000u) != 0;
+}
+void ConvolutionParameter::set_has_engine() {
+ _has_bits_[0] |= 0x00008000u;
+}
+void ConvolutionParameter::clear_has_engine() {
+ _has_bits_[0] &= ~0x00008000u;
+}
+void ConvolutionParameter::clear_engine() {
+ engine_ = 0;
+ clear_has_engine();
+}
+::caffe::ConvolutionParameter_Engine ConvolutionParameter::engine() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.engine)
+ return static_cast< ::caffe::ConvolutionParameter_Engine >(engine_);
+}
+void ConvolutionParameter::set_engine(::caffe::ConvolutionParameter_Engine value) {
+ assert(::caffe::ConvolutionParameter_Engine_IsValid(value));
+ set_has_engine();
+ engine_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.engine)
+}
+
+// optional int32 axis = 16 [default = 1];
+bool ConvolutionParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00010000u) != 0;
+}
+void ConvolutionParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00010000u;
+}
+void ConvolutionParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00010000u;
+}
+void ConvolutionParameter::clear_axis() {
+ axis_ = 1;
+ clear_has_axis();
+}
+::google::protobuf::int32 ConvolutionParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.axis)
+ return axis_;
+}
+void ConvolutionParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.axis)
+}
+
+// optional bool force_nd_im2col = 17 [default = false];
+bool ConvolutionParameter::has_force_nd_im2col() const {
+ return (_has_bits_[0] & 0x00020000u) != 0;
+}
+void ConvolutionParameter::set_has_force_nd_im2col() {
+ _has_bits_[0] |= 0x00020000u;
+}
+void ConvolutionParameter::clear_has_force_nd_im2col() {
+ _has_bits_[0] &= ~0x00020000u;
+}
+void ConvolutionParameter::clear_force_nd_im2col() {
+ force_nd_im2col_ = false;
+ clear_has_force_nd_im2col();
+}
+bool ConvolutionParameter::force_nd_im2col() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.force_nd_im2col)
+ return force_nd_im2col_;
+}
+void ConvolutionParameter::set_force_nd_im2col(bool value) {
+ set_has_force_nd_im2col();
+ force_nd_im2col_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.force_nd_im2col)
+}
+
+inline const ConvolutionParameter* ConvolutionParameter::internal_default_instance() {
+ return &ConvolutionParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int CropParameter::kAxisFieldNumber;
+const int CropParameter::kOffsetFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+CropParameter::CropParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.CropParameter)
+}
+
+void CropParameter::InitAsDefaultInstance() {
+}
+
+CropParameter::CropParameter(const CropParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.CropParameter)
+}
+
+void CropParameter::SharedCtor() {
+ _cached_size_ = 0;
+ axis_ = 2;
+}
+
+CropParameter::~CropParameter() {
+ // @@protoc_insertion_point(destructor:caffe.CropParameter)
+ SharedDtor();
+}
+
+void CropParameter::SharedDtor() {
+}
+
+void CropParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* CropParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return CropParameter_descriptor_;
+}
+
+const CropParameter& CropParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<CropParameter> CropParameter_default_instance_;
+
+CropParameter* CropParameter::New(::google::protobuf::Arena* arena) const {
+ CropParameter* n = new CropParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void CropParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.CropParameter)
+ axis_ = 2;
+ offset_.Clear();
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool CropParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.CropParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional int32 axis = 1 [default = 2];
+ case 1: {
+ if (tag == 8) {
+ set_has_axis();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &axis_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_offset;
+ break;
+ }
+
+ // repeated uint32 offset = 2;
+ case 2: {
+ if (tag == 16) {
+ parse_offset:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ 1, 16, input, this->mutable_offset())));
+ } else if (tag == 18) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, this->mutable_offset())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_offset;
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.CropParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.CropParameter)
+ return false;
+#undef DO_
+}
+
+void CropParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.CropParameter)
+ // optional int32 axis = 1 [default = 2];
+ if (has_axis()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->axis(), output);
+ }
+
+ // repeated uint32 offset = 2;
+ for (int i = 0; i < this->offset_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(
+ 2, this->offset(i), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.CropParameter)
+}
+
+::google::protobuf::uint8* CropParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.CropParameter)
+ // optional int32 axis = 1 [default = 2];
+ if (has_axis()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->axis(), target);
+ }
+
+ // repeated uint32 offset = 2;
+ for (int i = 0; i < this->offset_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteUInt32ToArray(2, this->offset(i), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.CropParameter)
+ return target;
+}
+
+size_t CropParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.CropParameter)
+ size_t total_size = 0;
+
+ // optional int32 axis = 1 [default = 2];
+ if (has_axis()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->axis());
+ }
+
+ // repeated uint32 offset = 2;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->offset_size();
+ for (unsigned int i = 0; i < count; i++) {
+ data_size += ::google::protobuf::internal::WireFormatLite::
+ UInt32Size(this->offset(i));
+ }
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->offset_size());
+ total_size += data_size;
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void CropParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.CropParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const CropParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const CropParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.CropParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.CropParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void CropParameter::MergeFrom(const CropParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.CropParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void CropParameter::UnsafeMergeFrom(const CropParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ offset_.UnsafeMergeFrom(from.offset_);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_axis()) {
+ set_axis(from.axis());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void CropParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.CropParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void CropParameter::CopyFrom(const CropParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.CropParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool CropParameter::IsInitialized() const {
+
+ return true;
+}
+
+void CropParameter::Swap(CropParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void CropParameter::InternalSwap(CropParameter* other) {
+ std::swap(axis_, other->axis_);
+ offset_.UnsafeArenaSwap(&other->offset_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata CropParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = CropParameter_descriptor_;
+ metadata.reflection = CropParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// CropParameter
+
+// optional int32 axis = 1 [default = 2];
+bool CropParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void CropParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void CropParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void CropParameter::clear_axis() {
+ axis_ = 2;
+ clear_has_axis();
+}
+::google::protobuf::int32 CropParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.CropParameter.axis)
+ return axis_;
+}
+void CropParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.CropParameter.axis)
+}
+
+// repeated uint32 offset = 2;
+int CropParameter::offset_size() const {
+ return offset_.size();
+}
+void CropParameter::clear_offset() {
+ offset_.Clear();
+}
+::google::protobuf::uint32 CropParameter::offset(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.CropParameter.offset)
+ return offset_.Get(index);
+}
+void CropParameter::set_offset(int index, ::google::protobuf::uint32 value) {
+ offset_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.CropParameter.offset)
+}
+void CropParameter::add_offset(::google::protobuf::uint32 value) {
+ offset_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.CropParameter.offset)
+}
+const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+CropParameter::offset() const {
+ // @@protoc_insertion_point(field_list:caffe.CropParameter.offset)
+ return offset_;
+}
+::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+CropParameter::mutable_offset() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.CropParameter.offset)
+ return &offset_;
+}
+
+inline const CropParameter* CropParameter::internal_default_instance() {
+ return &CropParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+const ::google::protobuf::EnumDescriptor* DataParameter_DB_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return DataParameter_DB_descriptor_;
+}
+bool DataParameter_DB_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const DataParameter_DB DataParameter::LEVELDB;
+const DataParameter_DB DataParameter::LMDB;
+const DataParameter_DB DataParameter::DB_MIN;
+const DataParameter_DB DataParameter::DB_MAX;
+const int DataParameter::DB_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int DataParameter::kSourceFieldNumber;
+const int DataParameter::kBatchSizeFieldNumber;
+const int DataParameter::kRandSkipFieldNumber;
+const int DataParameter::kBackendFieldNumber;
+const int DataParameter::kScaleFieldNumber;
+const int DataParameter::kMeanFileFieldNumber;
+const int DataParameter::kCropSizeFieldNumber;
+const int DataParameter::kMirrorFieldNumber;
+const int DataParameter::kForceEncodedColorFieldNumber;
+const int DataParameter::kPrefetchFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+DataParameter::DataParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.DataParameter)
+}
+
+void DataParameter::InitAsDefaultInstance() {
+}
+
+DataParameter::DataParameter(const DataParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.DataParameter)
+}
+
+void DataParameter::SharedCtor() {
+ _cached_size_ = 0;
+ source_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ mean_file_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ ::memset(&batch_size_, 0, reinterpret_cast<char*>(&force_encoded_color_) -
+ reinterpret_cast<char*>(&batch_size_) + sizeof(force_encoded_color_));
+ scale_ = 1;
+ prefetch_ = 4u;
+}
+
+DataParameter::~DataParameter() {
+ // @@protoc_insertion_point(destructor:caffe.DataParameter)
+ SharedDtor();
+}
+
+void DataParameter::SharedDtor() {
+ source_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ mean_file_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+
+void DataParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* DataParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return DataParameter_descriptor_;
+}
+
+const DataParameter& DataParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<DataParameter> DataParameter_default_instance_;
+
+DataParameter* DataParameter::New(::google::protobuf::Arena* arena) const {
+ DataParameter* n = new DataParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void DataParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.DataParameter)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(DataParameter, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<DataParameter*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ if (_has_bits_[0 / 32] & 255u) {
+ ZR_(batch_size_, mirror_);
+ if (has_source()) {
+ source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ scale_ = 1;
+ if (has_mean_file()) {
+ mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ }
+ if (_has_bits_[8 / 32] & 768u) {
+ force_encoded_color_ = false;
+ prefetch_ = 4u;
+ }
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool DataParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.DataParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional string source = 1;
+ case 1: {
+ if (tag == 10) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_source()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->source().data(), this->source().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.DataParameter.source");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(21)) goto parse_scale;
+ break;
+ }
+
+ // optional float scale = 2 [default = 1];
+ case 2: {
+ if (tag == 21) {
+ parse_scale:
+ set_has_scale();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &scale_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(26)) goto parse_mean_file;
+ break;
+ }
+
+ // optional string mean_file = 3;
+ case 3: {
+ if (tag == 26) {
+ parse_mean_file:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_mean_file()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->mean_file().data(), this->mean_file().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.DataParameter.mean_file");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(32)) goto parse_batch_size;
+ break;
+ }
+
+ // optional uint32 batch_size = 4;
+ case 4: {
+ if (tag == 32) {
+ parse_batch_size:
+ set_has_batch_size();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &batch_size_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(40)) goto parse_crop_size;
+ break;
+ }
+
+ // optional uint32 crop_size = 5 [default = 0];
+ case 5: {
+ if (tag == 40) {
+ parse_crop_size:
+ set_has_crop_size();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &crop_size_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(48)) goto parse_mirror;
+ break;
+ }
+
+ // optional bool mirror = 6 [default = false];
+ case 6: {
+ if (tag == 48) {
+ parse_mirror:
+ set_has_mirror();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &mirror_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(56)) goto parse_rand_skip;
+ break;
+ }
+
+ // optional uint32 rand_skip = 7 [default = 0];
+ case 7: {
+ if (tag == 56) {
+ parse_rand_skip:
+ set_has_rand_skip();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &rand_skip_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(64)) goto parse_backend;
+ break;
+ }
+
+ // optional .caffe.DataParameter.DB backend = 8 [default = LEVELDB];
+ case 8: {
+ if (tag == 64) {
+ parse_backend:
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::DataParameter_DB_IsValid(value)) {
+ set_backend(static_cast< ::caffe::DataParameter_DB >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(8, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(72)) goto parse_force_encoded_color;
+ break;
+ }
+
+ // optional bool force_encoded_color = 9 [default = false];
+ case 9: {
+ if (tag == 72) {
+ parse_force_encoded_color:
+ set_has_force_encoded_color();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &force_encoded_color_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(80)) goto parse_prefetch;
+ break;
+ }
+
+ // optional uint32 prefetch = 10 [default = 4];
+ case 10: {
+ if (tag == 80) {
+ parse_prefetch:
+ set_has_prefetch();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &prefetch_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.DataParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.DataParameter)
+ return false;
+#undef DO_
+}
+
+void DataParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.DataParameter)
+ // optional string source = 1;
+ if (has_source()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->source().data(), this->source().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.DataParameter.source");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 1, this->source(), output);
+ }
+
+ // optional float scale = 2 [default = 1];
+ if (has_scale()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->scale(), output);
+ }
+
+ // optional string mean_file = 3;
+ if (has_mean_file()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->mean_file().data(), this->mean_file().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.DataParameter.mean_file");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 3, this->mean_file(), output);
+ }
+
+ // optional uint32 batch_size = 4;
+ if (has_batch_size()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(4, this->batch_size(), output);
+ }
+
+ // optional uint32 crop_size = 5 [default = 0];
+ if (has_crop_size()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(5, this->crop_size(), output);
+ }
+
+ // optional bool mirror = 6 [default = false];
+ if (has_mirror()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(6, this->mirror(), output);
+ }
+
+ // optional uint32 rand_skip = 7 [default = 0];
+ if (has_rand_skip()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(7, this->rand_skip(), output);
+ }
+
+ // optional .caffe.DataParameter.DB backend = 8 [default = LEVELDB];
+ if (has_backend()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 8, this->backend(), output);
+ }
+
+ // optional bool force_encoded_color = 9 [default = false];
+ if (has_force_encoded_color()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(9, this->force_encoded_color(), output);
+ }
+
+ // optional uint32 prefetch = 10 [default = 4];
+ if (has_prefetch()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(10, this->prefetch(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.DataParameter)
+}
+
+::google::protobuf::uint8* DataParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.DataParameter)
+ // optional string source = 1;
+ if (has_source()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->source().data(), this->source().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.DataParameter.source");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 1, this->source(), target);
+ }
+
+ // optional float scale = 2 [default = 1];
+ if (has_scale()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->scale(), target);
+ }
+
+ // optional string mean_file = 3;
+ if (has_mean_file()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->mean_file().data(), this->mean_file().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.DataParameter.mean_file");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 3, this->mean_file(), target);
+ }
+
+ // optional uint32 batch_size = 4;
+ if (has_batch_size()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(4, this->batch_size(), target);
+ }
+
+ // optional uint32 crop_size = 5 [default = 0];
+ if (has_crop_size()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(5, this->crop_size(), target);
+ }
+
+ // optional bool mirror = 6 [default = false];
+ if (has_mirror()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(6, this->mirror(), target);
+ }
+
+ // optional uint32 rand_skip = 7 [default = 0];
+ if (has_rand_skip()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(7, this->rand_skip(), target);
+ }
+
+ // optional .caffe.DataParameter.DB backend = 8 [default = LEVELDB];
+ if (has_backend()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 8, this->backend(), target);
+ }
+
+ // optional bool force_encoded_color = 9 [default = false];
+ if (has_force_encoded_color()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(9, this->force_encoded_color(), target);
+ }
+
+ // optional uint32 prefetch = 10 [default = 4];
+ if (has_prefetch()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(10, this->prefetch(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.DataParameter)
+ return target;
+}
+
+size_t DataParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.DataParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 255u) {
+ // optional string source = 1;
+ if (has_source()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->source());
+ }
+
+ // optional uint32 batch_size = 4;
+ if (has_batch_size()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->batch_size());
+ }
+
+ // optional uint32 rand_skip = 7 [default = 0];
+ if (has_rand_skip()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->rand_skip());
+ }
+
+ // optional .caffe.DataParameter.DB backend = 8 [default = LEVELDB];
+ if (has_backend()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->backend());
+ }
+
+ // optional float scale = 2 [default = 1];
+ if (has_scale()) {
+ total_size += 1 + 4;
+ }
+
+ // optional string mean_file = 3;
+ if (has_mean_file()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->mean_file());
+ }
+
+ // optional uint32 crop_size = 5 [default = 0];
+ if (has_crop_size()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->crop_size());
+ }
+
+ // optional bool mirror = 6 [default = false];
+ if (has_mirror()) {
+ total_size += 1 + 1;
+ }
+
+ }
+ if (_has_bits_[8 / 32] & 768u) {
+ // optional bool force_encoded_color = 9 [default = false];
+ if (has_force_encoded_color()) {
+ total_size += 1 + 1;
+ }
+
+ // optional uint32 prefetch = 10 [default = 4];
+ if (has_prefetch()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->prefetch());
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void DataParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.DataParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const DataParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const DataParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.DataParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.DataParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void DataParameter::MergeFrom(const DataParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.DataParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void DataParameter::UnsafeMergeFrom(const DataParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_source()) {
+ set_has_source();
+ source_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_);
+ }
+ if (from.has_batch_size()) {
+ set_batch_size(from.batch_size());
+ }
+ if (from.has_rand_skip()) {
+ set_rand_skip(from.rand_skip());
+ }
+ if (from.has_backend()) {
+ set_backend(from.backend());
+ }
+ if (from.has_scale()) {
+ set_scale(from.scale());
+ }
+ if (from.has_mean_file()) {
+ set_has_mean_file();
+ mean_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.mean_file_);
+ }
+ if (from.has_crop_size()) {
+ set_crop_size(from.crop_size());
+ }
+ if (from.has_mirror()) {
+ set_mirror(from.mirror());
+ }
+ }
+ if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) {
+ if (from.has_force_encoded_color()) {
+ set_force_encoded_color(from.force_encoded_color());
+ }
+ if (from.has_prefetch()) {
+ set_prefetch(from.prefetch());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void DataParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.DataParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void DataParameter::CopyFrom(const DataParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.DataParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool DataParameter::IsInitialized() const {
+
+ return true;
+}
+
+void DataParameter::Swap(DataParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void DataParameter::InternalSwap(DataParameter* other) {
+ source_.Swap(&other->source_);
+ std::swap(batch_size_, other->batch_size_);
+ std::swap(rand_skip_, other->rand_skip_);
+ std::swap(backend_, other->backend_);
+ std::swap(scale_, other->scale_);
+ mean_file_.Swap(&other->mean_file_);
+ std::swap(crop_size_, other->crop_size_);
+ std::swap(mirror_, other->mirror_);
+ std::swap(force_encoded_color_, other->force_encoded_color_);
+ std::swap(prefetch_, other->prefetch_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata DataParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = DataParameter_descriptor_;
+ metadata.reflection = DataParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// DataParameter
+
+// optional string source = 1;
+bool DataParameter::has_source() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void DataParameter::set_has_source() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void DataParameter::clear_has_source() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void DataParameter::clear_source() {
+ source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_source();
+}
+const ::std::string& DataParameter::source() const {
+ // @@protoc_insertion_point(field_get:caffe.DataParameter.source)
+ return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void DataParameter::set_source(const ::std::string& value) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.DataParameter.source)
+}
+void DataParameter::set_source(const char* value) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.DataParameter.source)
+}
+void DataParameter::set_source(const char* value, size_t size) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.DataParameter.source)
+}
+::std::string* DataParameter::mutable_source() {
+ set_has_source();
+ // @@protoc_insertion_point(field_mutable:caffe.DataParameter.source)
+ return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* DataParameter::release_source() {
+ // @@protoc_insertion_point(field_release:caffe.DataParameter.source)
+ clear_has_source();
+ return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void DataParameter::set_allocated_source(::std::string* source) {
+ if (source != NULL) {
+ set_has_source();
+ } else {
+ clear_has_source();
+ }
+ source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source);
+ // @@protoc_insertion_point(field_set_allocated:caffe.DataParameter.source)
+}
+
+// optional uint32 batch_size = 4;
+bool DataParameter::has_batch_size() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void DataParameter::set_has_batch_size() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void DataParameter::clear_has_batch_size() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void DataParameter::clear_batch_size() {
+ batch_size_ = 0u;
+ clear_has_batch_size();
+}
+::google::protobuf::uint32 DataParameter::batch_size() const {
+ // @@protoc_insertion_point(field_get:caffe.DataParameter.batch_size)
+ return batch_size_;
+}
+void DataParameter::set_batch_size(::google::protobuf::uint32 value) {
+ set_has_batch_size();
+ batch_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DataParameter.batch_size)
+}
+
+// optional uint32 rand_skip = 7 [default = 0];
+bool DataParameter::has_rand_skip() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void DataParameter::set_has_rand_skip() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void DataParameter::clear_has_rand_skip() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void DataParameter::clear_rand_skip() {
+ rand_skip_ = 0u;
+ clear_has_rand_skip();
+}
+::google::protobuf::uint32 DataParameter::rand_skip() const {
+ // @@protoc_insertion_point(field_get:caffe.DataParameter.rand_skip)
+ return rand_skip_;
+}
+void DataParameter::set_rand_skip(::google::protobuf::uint32 value) {
+ set_has_rand_skip();
+ rand_skip_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DataParameter.rand_skip)
+}
+
+// optional .caffe.DataParameter.DB backend = 8 [default = LEVELDB];
+bool DataParameter::has_backend() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+void DataParameter::set_has_backend() {
+ _has_bits_[0] |= 0x00000008u;
+}
+void DataParameter::clear_has_backend() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+void DataParameter::clear_backend() {
+ backend_ = 0;
+ clear_has_backend();
+}
+::caffe::DataParameter_DB DataParameter::backend() const {
+ // @@protoc_insertion_point(field_get:caffe.DataParameter.backend)
+ return static_cast< ::caffe::DataParameter_DB >(backend_);
+}
+void DataParameter::set_backend(::caffe::DataParameter_DB value) {
+ assert(::caffe::DataParameter_DB_IsValid(value));
+ set_has_backend();
+ backend_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DataParameter.backend)
+}
+
+// optional float scale = 2 [default = 1];
+bool DataParameter::has_scale() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+void DataParameter::set_has_scale() {
+ _has_bits_[0] |= 0x00000010u;
+}
+void DataParameter::clear_has_scale() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+void DataParameter::clear_scale() {
+ scale_ = 1;
+ clear_has_scale();
+}
+float DataParameter::scale() const {
+ // @@protoc_insertion_point(field_get:caffe.DataParameter.scale)
+ return scale_;
+}
+void DataParameter::set_scale(float value) {
+ set_has_scale();
+ scale_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DataParameter.scale)
+}
+
+// optional string mean_file = 3;
+bool DataParameter::has_mean_file() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+void DataParameter::set_has_mean_file() {
+ _has_bits_[0] |= 0x00000020u;
+}
+void DataParameter::clear_has_mean_file() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+void DataParameter::clear_mean_file() {
+ mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_mean_file();
+}
+const ::std::string& DataParameter::mean_file() const {
+ // @@protoc_insertion_point(field_get:caffe.DataParameter.mean_file)
+ return mean_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void DataParameter::set_mean_file(const ::std::string& value) {
+ set_has_mean_file();
+ mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.DataParameter.mean_file)
+}
+void DataParameter::set_mean_file(const char* value) {
+ set_has_mean_file();
+ mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.DataParameter.mean_file)
+}
+void DataParameter::set_mean_file(const char* value, size_t size) {
+ set_has_mean_file();
+ mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.DataParameter.mean_file)
+}
+::std::string* DataParameter::mutable_mean_file() {
+ set_has_mean_file();
+ // @@protoc_insertion_point(field_mutable:caffe.DataParameter.mean_file)
+ return mean_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* DataParameter::release_mean_file() {
+ // @@protoc_insertion_point(field_release:caffe.DataParameter.mean_file)
+ clear_has_mean_file();
+ return mean_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void DataParameter::set_allocated_mean_file(::std::string* mean_file) {
+ if (mean_file != NULL) {
+ set_has_mean_file();
+ } else {
+ clear_has_mean_file();
+ }
+ mean_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), mean_file);
+ // @@protoc_insertion_point(field_set_allocated:caffe.DataParameter.mean_file)
+}
+
+// optional uint32 crop_size = 5 [default = 0];
+bool DataParameter::has_crop_size() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+void DataParameter::set_has_crop_size() {
+ _has_bits_[0] |= 0x00000040u;
+}
+void DataParameter::clear_has_crop_size() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+void DataParameter::clear_crop_size() {
+ crop_size_ = 0u;
+ clear_has_crop_size();
+}
+::google::protobuf::uint32 DataParameter::crop_size() const {
+ // @@protoc_insertion_point(field_get:caffe.DataParameter.crop_size)
+ return crop_size_;
+}
+void DataParameter::set_crop_size(::google::protobuf::uint32 value) {
+ set_has_crop_size();
+ crop_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DataParameter.crop_size)
+}
+
+// optional bool mirror = 6 [default = false];
+bool DataParameter::has_mirror() const {
+ return (_has_bits_[0] & 0x00000080u) != 0;
+}
+void DataParameter::set_has_mirror() {
+ _has_bits_[0] |= 0x00000080u;
+}
+void DataParameter::clear_has_mirror() {
+ _has_bits_[0] &= ~0x00000080u;
+}
+void DataParameter::clear_mirror() {
+ mirror_ = false;
+ clear_has_mirror();
+}
+bool DataParameter::mirror() const {
+ // @@protoc_insertion_point(field_get:caffe.DataParameter.mirror)
+ return mirror_;
+}
+void DataParameter::set_mirror(bool value) {
+ set_has_mirror();
+ mirror_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DataParameter.mirror)
+}
+
+// optional bool force_encoded_color = 9 [default = false];
+bool DataParameter::has_force_encoded_color() const {
+ return (_has_bits_[0] & 0x00000100u) != 0;
+}
+void DataParameter::set_has_force_encoded_color() {
+ _has_bits_[0] |= 0x00000100u;
+}
+void DataParameter::clear_has_force_encoded_color() {
+ _has_bits_[0] &= ~0x00000100u;
+}
+void DataParameter::clear_force_encoded_color() {
+ force_encoded_color_ = false;
+ clear_has_force_encoded_color();
+}
+bool DataParameter::force_encoded_color() const {
+ // @@protoc_insertion_point(field_get:caffe.DataParameter.force_encoded_color)
+ return force_encoded_color_;
+}
+void DataParameter::set_force_encoded_color(bool value) {
+ set_has_force_encoded_color();
+ force_encoded_color_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DataParameter.force_encoded_color)
+}
+
+// optional uint32 prefetch = 10 [default = 4];
+bool DataParameter::has_prefetch() const {
+ return (_has_bits_[0] & 0x00000200u) != 0;
+}
+void DataParameter::set_has_prefetch() {
+ _has_bits_[0] |= 0x00000200u;
+}
+void DataParameter::clear_has_prefetch() {
+ _has_bits_[0] &= ~0x00000200u;
+}
+void DataParameter::clear_prefetch() {
+ prefetch_ = 4u;
+ clear_has_prefetch();
+}
+::google::protobuf::uint32 DataParameter::prefetch() const {
+ // @@protoc_insertion_point(field_get:caffe.DataParameter.prefetch)
+ return prefetch_;
+}
+void DataParameter::set_prefetch(::google::protobuf::uint32 value) {
+ set_has_prefetch();
+ prefetch_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DataParameter.prefetch)
+}
+
+inline const DataParameter* DataParameter::internal_default_instance() {
+ return &DataParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int NonMaximumSuppressionParameter::kNmsThresholdFieldNumber;
+const int NonMaximumSuppressionParameter::kTopKFieldNumber;
+const int NonMaximumSuppressionParameter::kEtaFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+NonMaximumSuppressionParameter::NonMaximumSuppressionParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.NonMaximumSuppressionParameter)
+}
+
+void NonMaximumSuppressionParameter::InitAsDefaultInstance() {
+}
+
+NonMaximumSuppressionParameter::NonMaximumSuppressionParameter(const NonMaximumSuppressionParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.NonMaximumSuppressionParameter)
+}
+
+void NonMaximumSuppressionParameter::SharedCtor() {
+ _cached_size_ = 0;
+ top_k_ = 0;
+ nms_threshold_ = 0.3f;
+ eta_ = 1;
+}
+
+NonMaximumSuppressionParameter::~NonMaximumSuppressionParameter() {
+ // @@protoc_insertion_point(destructor:caffe.NonMaximumSuppressionParameter)
+ SharedDtor();
+}
+
+void NonMaximumSuppressionParameter::SharedDtor() {
+}
+
+void NonMaximumSuppressionParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* NonMaximumSuppressionParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return NonMaximumSuppressionParameter_descriptor_;
+}
+
+const NonMaximumSuppressionParameter& NonMaximumSuppressionParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<NonMaximumSuppressionParameter> NonMaximumSuppressionParameter_default_instance_;
+
+NonMaximumSuppressionParameter* NonMaximumSuppressionParameter::New(::google::protobuf::Arena* arena) const {
+ NonMaximumSuppressionParameter* n = new NonMaximumSuppressionParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void NonMaximumSuppressionParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.NonMaximumSuppressionParameter)
+ if (_has_bits_[0 / 32] & 7u) {
+ nms_threshold_ = 0.3f;
+ top_k_ = 0;
+ eta_ = 1;
+ }
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool NonMaximumSuppressionParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.NonMaximumSuppressionParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional float nms_threshold = 1 [default = 0.3];
+ case 1: {
+ if (tag == 13) {
+ set_has_nms_threshold();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &nms_threshold_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_top_k;
+ break;
+ }
+
+ // optional int32 top_k = 2;
+ case 2: {
+ if (tag == 16) {
+ parse_top_k:
+ set_has_top_k();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &top_k_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(29)) goto parse_eta;
+ break;
+ }
+
+ // optional float eta = 3 [default = 1];
+ case 3: {
+ if (tag == 29) {
+ parse_eta:
+ set_has_eta();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &eta_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.NonMaximumSuppressionParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.NonMaximumSuppressionParameter)
+ return false;
+#undef DO_
+}
+
+void NonMaximumSuppressionParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.NonMaximumSuppressionParameter)
+ // optional float nms_threshold = 1 [default = 0.3];
+ if (has_nms_threshold()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->nms_threshold(), output);
+ }
+
+ // optional int32 top_k = 2;
+ if (has_top_k()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->top_k(), output);
+ }
+
+ // optional float eta = 3 [default = 1];
+ if (has_eta()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->eta(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.NonMaximumSuppressionParameter)
+}
+
+::google::protobuf::uint8* NonMaximumSuppressionParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.NonMaximumSuppressionParameter)
+ // optional float nms_threshold = 1 [default = 0.3];
+ if (has_nms_threshold()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->nms_threshold(), target);
+ }
+
+ // optional int32 top_k = 2;
+ if (has_top_k()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->top_k(), target);
+ }
+
+ // optional float eta = 3 [default = 1];
+ if (has_eta()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->eta(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.NonMaximumSuppressionParameter)
+ return target;
+}
+
+size_t NonMaximumSuppressionParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.NonMaximumSuppressionParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 7u) {
+ // optional float nms_threshold = 1 [default = 0.3];
+ if (has_nms_threshold()) {
+ total_size += 1 + 4;
+ }
+
+ // optional int32 top_k = 2;
+ if (has_top_k()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->top_k());
+ }
+
+ // optional float eta = 3 [default = 1];
+ if (has_eta()) {
+ total_size += 1 + 4;
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void NonMaximumSuppressionParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.NonMaximumSuppressionParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const NonMaximumSuppressionParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const NonMaximumSuppressionParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.NonMaximumSuppressionParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.NonMaximumSuppressionParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void NonMaximumSuppressionParameter::MergeFrom(const NonMaximumSuppressionParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.NonMaximumSuppressionParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void NonMaximumSuppressionParameter::UnsafeMergeFrom(const NonMaximumSuppressionParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_nms_threshold()) {
+ set_nms_threshold(from.nms_threshold());
+ }
+ if (from.has_top_k()) {
+ set_top_k(from.top_k());
+ }
+ if (from.has_eta()) {
+ set_eta(from.eta());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void NonMaximumSuppressionParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.NonMaximumSuppressionParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void NonMaximumSuppressionParameter::CopyFrom(const NonMaximumSuppressionParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.NonMaximumSuppressionParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool NonMaximumSuppressionParameter::IsInitialized() const {
+
+ return true;
+}
+
+void NonMaximumSuppressionParameter::Swap(NonMaximumSuppressionParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void NonMaximumSuppressionParameter::InternalSwap(NonMaximumSuppressionParameter* other) {
+ std::swap(nms_threshold_, other->nms_threshold_);
+ std::swap(top_k_, other->top_k_);
+ std::swap(eta_, other->eta_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata NonMaximumSuppressionParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = NonMaximumSuppressionParameter_descriptor_;
+ metadata.reflection = NonMaximumSuppressionParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// NonMaximumSuppressionParameter
+
+// optional float nms_threshold = 1 [default = 0.3];
+bool NonMaximumSuppressionParameter::has_nms_threshold() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void NonMaximumSuppressionParameter::set_has_nms_threshold() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void NonMaximumSuppressionParameter::clear_has_nms_threshold() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void NonMaximumSuppressionParameter::clear_nms_threshold() {
+ nms_threshold_ = 0.3f;
+ clear_has_nms_threshold();
+}
+float NonMaximumSuppressionParameter::nms_threshold() const {
+ // @@protoc_insertion_point(field_get:caffe.NonMaximumSuppressionParameter.nms_threshold)
+ return nms_threshold_;
+}
+void NonMaximumSuppressionParameter::set_nms_threshold(float value) {
+ set_has_nms_threshold();
+ nms_threshold_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NonMaximumSuppressionParameter.nms_threshold)
+}
+
+// optional int32 top_k = 2;
+bool NonMaximumSuppressionParameter::has_top_k() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void NonMaximumSuppressionParameter::set_has_top_k() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void NonMaximumSuppressionParameter::clear_has_top_k() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void NonMaximumSuppressionParameter::clear_top_k() {
+ top_k_ = 0;
+ clear_has_top_k();
+}
+::google::protobuf::int32 NonMaximumSuppressionParameter::top_k() const {
+ // @@protoc_insertion_point(field_get:caffe.NonMaximumSuppressionParameter.top_k)
+ return top_k_;
+}
+void NonMaximumSuppressionParameter::set_top_k(::google::protobuf::int32 value) {
+ set_has_top_k();
+ top_k_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NonMaximumSuppressionParameter.top_k)
+}
+
+// optional float eta = 3 [default = 1];
+bool NonMaximumSuppressionParameter::has_eta() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void NonMaximumSuppressionParameter::set_has_eta() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void NonMaximumSuppressionParameter::clear_has_eta() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void NonMaximumSuppressionParameter::clear_eta() {
+ eta_ = 1;
+ clear_has_eta();
+}
+float NonMaximumSuppressionParameter::eta() const {
+ // @@protoc_insertion_point(field_get:caffe.NonMaximumSuppressionParameter.eta)
+ return eta_;
+}
+void NonMaximumSuppressionParameter::set_eta(float value) {
+ set_has_eta();
+ eta_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NonMaximumSuppressionParameter.eta)
+}
+
+inline const NonMaximumSuppressionParameter* NonMaximumSuppressionParameter::internal_default_instance() {
+ return &NonMaximumSuppressionParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int SaveOutputParameter::kOutputDirectoryFieldNumber;
+const int SaveOutputParameter::kOutputNamePrefixFieldNumber;
+const int SaveOutputParameter::kOutputFormatFieldNumber;
+const int SaveOutputParameter::kLabelMapFileFieldNumber;
+const int SaveOutputParameter::kNameSizeFileFieldNumber;
+const int SaveOutputParameter::kNumTestImageFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+SaveOutputParameter::SaveOutputParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.SaveOutputParameter)
+}
+
+void SaveOutputParameter::InitAsDefaultInstance() {
+}
+
+SaveOutputParameter::SaveOutputParameter(const SaveOutputParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.SaveOutputParameter)
+}
+
+void SaveOutputParameter::SharedCtor() {
+ _cached_size_ = 0;
+ output_directory_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ output_name_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ output_format_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ label_map_file_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ name_size_file_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ num_test_image_ = 0u;
+}
+
+SaveOutputParameter::~SaveOutputParameter() {
+ // @@protoc_insertion_point(destructor:caffe.SaveOutputParameter)
+ SharedDtor();
+}
+
+void SaveOutputParameter::SharedDtor() {
+ output_directory_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ output_name_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ output_format_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ label_map_file_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ name_size_file_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+
+void SaveOutputParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* SaveOutputParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return SaveOutputParameter_descriptor_;
+}
+
+const SaveOutputParameter& SaveOutputParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<SaveOutputParameter> SaveOutputParameter_default_instance_;
+
+SaveOutputParameter* SaveOutputParameter::New(::google::protobuf::Arena* arena) const {
+ SaveOutputParameter* n = new SaveOutputParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void SaveOutputParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.SaveOutputParameter)
+ if (_has_bits_[0 / 32] & 63u) {
+ if (has_output_directory()) {
+ output_directory_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ if (has_output_name_prefix()) {
+ output_name_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ if (has_output_format()) {
+ output_format_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ if (has_label_map_file()) {
+ label_map_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ if (has_name_size_file()) {
+ name_size_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ num_test_image_ = 0u;
+ }
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool SaveOutputParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.SaveOutputParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional string output_directory = 1;
+ case 1: {
+ if (tag == 10) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_output_directory()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->output_directory().data(), this->output_directory().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.SaveOutputParameter.output_directory");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(18)) goto parse_output_name_prefix;
+ break;
+ }
+
+ // optional string output_name_prefix = 2;
+ case 2: {
+ if (tag == 18) {
+ parse_output_name_prefix:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_output_name_prefix()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->output_name_prefix().data(), this->output_name_prefix().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.SaveOutputParameter.output_name_prefix");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(26)) goto parse_output_format;
+ break;
+ }
+
+ // optional string output_format = 3;
+ case 3: {
+ if (tag == 26) {
+ parse_output_format:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_output_format()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->output_format().data(), this->output_format().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.SaveOutputParameter.output_format");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(34)) goto parse_label_map_file;
+ break;
+ }
+
+ // optional string label_map_file = 4;
+ case 4: {
+ if (tag == 34) {
+ parse_label_map_file:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_label_map_file()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->label_map_file().data(), this->label_map_file().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.SaveOutputParameter.label_map_file");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(42)) goto parse_name_size_file;
+ break;
+ }
+
+ // optional string name_size_file = 5;
+ case 5: {
+ if (tag == 42) {
+ parse_name_size_file:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_name_size_file()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->name_size_file().data(), this->name_size_file().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.SaveOutputParameter.name_size_file");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(48)) goto parse_num_test_image;
+ break;
+ }
+
+ // optional uint32 num_test_image = 6;
+ case 6: {
+ if (tag == 48) {
+ parse_num_test_image:
+ set_has_num_test_image();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &num_test_image_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.SaveOutputParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.SaveOutputParameter)
+ return false;
+#undef DO_
+}
+
+void SaveOutputParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.SaveOutputParameter)
+ // optional string output_directory = 1;
+ if (has_output_directory()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->output_directory().data(), this->output_directory().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SaveOutputParameter.output_directory");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 1, this->output_directory(), output);
+ }
+
+ // optional string output_name_prefix = 2;
+ if (has_output_name_prefix()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->output_name_prefix().data(), this->output_name_prefix().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SaveOutputParameter.output_name_prefix");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 2, this->output_name_prefix(), output);
+ }
+
+ // optional string output_format = 3;
+ if (has_output_format()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->output_format().data(), this->output_format().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SaveOutputParameter.output_format");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 3, this->output_format(), output);
+ }
+
+ // optional string label_map_file = 4;
+ if (has_label_map_file()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->label_map_file().data(), this->label_map_file().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SaveOutputParameter.label_map_file");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 4, this->label_map_file(), output);
+ }
+
+ // optional string name_size_file = 5;
+ if (has_name_size_file()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->name_size_file().data(), this->name_size_file().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SaveOutputParameter.name_size_file");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 5, this->name_size_file(), output);
+ }
+
+ // optional uint32 num_test_image = 6;
+ if (has_num_test_image()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(6, this->num_test_image(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.SaveOutputParameter)
+}
+
+::google::protobuf::uint8* SaveOutputParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.SaveOutputParameter)
+ // optional string output_directory = 1;
+ if (has_output_directory()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->output_directory().data(), this->output_directory().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SaveOutputParameter.output_directory");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 1, this->output_directory(), target);
+ }
+
+ // optional string output_name_prefix = 2;
+ if (has_output_name_prefix()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->output_name_prefix().data(), this->output_name_prefix().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SaveOutputParameter.output_name_prefix");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 2, this->output_name_prefix(), target);
+ }
+
+ // optional string output_format = 3;
+ if (has_output_format()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->output_format().data(), this->output_format().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SaveOutputParameter.output_format");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 3, this->output_format(), target);
+ }
+
+ // optional string label_map_file = 4;
+ if (has_label_map_file()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->label_map_file().data(), this->label_map_file().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SaveOutputParameter.label_map_file");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 4, this->label_map_file(), target);
+ }
+
+ // optional string name_size_file = 5;
+ if (has_name_size_file()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->name_size_file().data(), this->name_size_file().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.SaveOutputParameter.name_size_file");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 5, this->name_size_file(), target);
+ }
+
+ // optional uint32 num_test_image = 6;
+ if (has_num_test_image()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(6, this->num_test_image(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.SaveOutputParameter)
+ return target;
+}
+
+size_t SaveOutputParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.SaveOutputParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 63u) {
+ // optional string output_directory = 1;
+ if (has_output_directory()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->output_directory());
+ }
+
+ // optional string output_name_prefix = 2;
+ if (has_output_name_prefix()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->output_name_prefix());
+ }
+
+ // optional string output_format = 3;
+ if (has_output_format()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->output_format());
+ }
+
+ // optional string label_map_file = 4;
+ if (has_label_map_file()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->label_map_file());
+ }
+
+ // optional string name_size_file = 5;
+ if (has_name_size_file()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->name_size_file());
+ }
+
+ // optional uint32 num_test_image = 6;
+ if (has_num_test_image()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->num_test_image());
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void SaveOutputParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.SaveOutputParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const SaveOutputParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const SaveOutputParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.SaveOutputParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.SaveOutputParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void SaveOutputParameter::MergeFrom(const SaveOutputParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.SaveOutputParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void SaveOutputParameter::UnsafeMergeFrom(const SaveOutputParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_output_directory()) {
+ set_has_output_directory();
+ output_directory_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.output_directory_);
+ }
+ if (from.has_output_name_prefix()) {
+ set_has_output_name_prefix();
+ output_name_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.output_name_prefix_);
+ }
+ if (from.has_output_format()) {
+ set_has_output_format();
+ output_format_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.output_format_);
+ }
+ if (from.has_label_map_file()) {
+ set_has_label_map_file();
+ label_map_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.label_map_file_);
+ }
+ if (from.has_name_size_file()) {
+ set_has_name_size_file();
+ name_size_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_size_file_);
+ }
+ if (from.has_num_test_image()) {
+ set_num_test_image(from.num_test_image());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void SaveOutputParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.SaveOutputParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void SaveOutputParameter::CopyFrom(const SaveOutputParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.SaveOutputParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool SaveOutputParameter::IsInitialized() const {
+
+ return true;
+}
+
+void SaveOutputParameter::Swap(SaveOutputParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void SaveOutputParameter::InternalSwap(SaveOutputParameter* other) {
+ output_directory_.Swap(&other->output_directory_);
+ output_name_prefix_.Swap(&other->output_name_prefix_);
+ output_format_.Swap(&other->output_format_);
+ label_map_file_.Swap(&other->label_map_file_);
+ name_size_file_.Swap(&other->name_size_file_);
+ std::swap(num_test_image_, other->num_test_image_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata SaveOutputParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = SaveOutputParameter_descriptor_;
+ metadata.reflection = SaveOutputParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// SaveOutputParameter
+
+// optional string output_directory = 1;
+bool SaveOutputParameter::has_output_directory() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void SaveOutputParameter::set_has_output_directory() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void SaveOutputParameter::clear_has_output_directory() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void SaveOutputParameter::clear_output_directory() {
+ output_directory_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_output_directory();
+}
+const ::std::string& SaveOutputParameter::output_directory() const {
+ // @@protoc_insertion_point(field_get:caffe.SaveOutputParameter.output_directory)
+ return output_directory_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void SaveOutputParameter::set_output_directory(const ::std::string& value) {
+ set_has_output_directory();
+ output_directory_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.SaveOutputParameter.output_directory)
+}
+void SaveOutputParameter::set_output_directory(const char* value) {
+ set_has_output_directory();
+ output_directory_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.SaveOutputParameter.output_directory)
+}
+void SaveOutputParameter::set_output_directory(const char* value, size_t size) {
+ set_has_output_directory();
+ output_directory_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.SaveOutputParameter.output_directory)
+}
+::std::string* SaveOutputParameter::mutable_output_directory() {
+ set_has_output_directory();
+ // @@protoc_insertion_point(field_mutable:caffe.SaveOutputParameter.output_directory)
+ return output_directory_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* SaveOutputParameter::release_output_directory() {
+ // @@protoc_insertion_point(field_release:caffe.SaveOutputParameter.output_directory)
+ clear_has_output_directory();
+ return output_directory_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void SaveOutputParameter::set_allocated_output_directory(::std::string* output_directory) {
+ if (output_directory != NULL) {
+ set_has_output_directory();
+ } else {
+ clear_has_output_directory();
+ }
+ output_directory_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), output_directory);
+ // @@protoc_insertion_point(field_set_allocated:caffe.SaveOutputParameter.output_directory)
+}
+
+// optional string output_name_prefix = 2;
+bool SaveOutputParameter::has_output_name_prefix() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void SaveOutputParameter::set_has_output_name_prefix() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void SaveOutputParameter::clear_has_output_name_prefix() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void SaveOutputParameter::clear_output_name_prefix() {
+ output_name_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_output_name_prefix();
+}
+const ::std::string& SaveOutputParameter::output_name_prefix() const {
+ // @@protoc_insertion_point(field_get:caffe.SaveOutputParameter.output_name_prefix)
+ return output_name_prefix_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void SaveOutputParameter::set_output_name_prefix(const ::std::string& value) {
+ set_has_output_name_prefix();
+ output_name_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.SaveOutputParameter.output_name_prefix)
+}
+void SaveOutputParameter::set_output_name_prefix(const char* value) {
+ set_has_output_name_prefix();
+ output_name_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.SaveOutputParameter.output_name_prefix)
+}
+void SaveOutputParameter::set_output_name_prefix(const char* value, size_t size) {
+ set_has_output_name_prefix();
+ output_name_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.SaveOutputParameter.output_name_prefix)
+}
+::std::string* SaveOutputParameter::mutable_output_name_prefix() {
+ set_has_output_name_prefix();
+ // @@protoc_insertion_point(field_mutable:caffe.SaveOutputParameter.output_name_prefix)
+ return output_name_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* SaveOutputParameter::release_output_name_prefix() {
+ // @@protoc_insertion_point(field_release:caffe.SaveOutputParameter.output_name_prefix)
+ clear_has_output_name_prefix();
+ return output_name_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void SaveOutputParameter::set_allocated_output_name_prefix(::std::string* output_name_prefix) {
+ if (output_name_prefix != NULL) {
+ set_has_output_name_prefix();
+ } else {
+ clear_has_output_name_prefix();
+ }
+ output_name_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), output_name_prefix);
+ // @@protoc_insertion_point(field_set_allocated:caffe.SaveOutputParameter.output_name_prefix)
+}
+
+// optional string output_format = 3;
+bool SaveOutputParameter::has_output_format() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void SaveOutputParameter::set_has_output_format() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void SaveOutputParameter::clear_has_output_format() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void SaveOutputParameter::clear_output_format() {
+ output_format_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_output_format();
+}
+const ::std::string& SaveOutputParameter::output_format() const {
+ // @@protoc_insertion_point(field_get:caffe.SaveOutputParameter.output_format)
+ return output_format_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void SaveOutputParameter::set_output_format(const ::std::string& value) {
+ set_has_output_format();
+ output_format_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.SaveOutputParameter.output_format)
+}
+void SaveOutputParameter::set_output_format(const char* value) {
+ set_has_output_format();
+ output_format_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.SaveOutputParameter.output_format)
+}
+void SaveOutputParameter::set_output_format(const char* value, size_t size) {
+ set_has_output_format();
+ output_format_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.SaveOutputParameter.output_format)
+}
+::std::string* SaveOutputParameter::mutable_output_format() {
+ set_has_output_format();
+ // @@protoc_insertion_point(field_mutable:caffe.SaveOutputParameter.output_format)
+ return output_format_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* SaveOutputParameter::release_output_format() {
+ // @@protoc_insertion_point(field_release:caffe.SaveOutputParameter.output_format)
+ clear_has_output_format();
+ return output_format_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void SaveOutputParameter::set_allocated_output_format(::std::string* output_format) {
+ if (output_format != NULL) {
+ set_has_output_format();
+ } else {
+ clear_has_output_format();
+ }
+ output_format_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), output_format);
+ // @@protoc_insertion_point(field_set_allocated:caffe.SaveOutputParameter.output_format)
+}
+
+// optional string label_map_file = 4;
+bool SaveOutputParameter::has_label_map_file() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+void SaveOutputParameter::set_has_label_map_file() {
+ _has_bits_[0] |= 0x00000008u;
+}
+void SaveOutputParameter::clear_has_label_map_file() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+void SaveOutputParameter::clear_label_map_file() {
+ label_map_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_label_map_file();
+}
+const ::std::string& SaveOutputParameter::label_map_file() const {
+ // @@protoc_insertion_point(field_get:caffe.SaveOutputParameter.label_map_file)
+ return label_map_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void SaveOutputParameter::set_label_map_file(const ::std::string& value) {
+ set_has_label_map_file();
+ label_map_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.SaveOutputParameter.label_map_file)
+}
+void SaveOutputParameter::set_label_map_file(const char* value) {
+ set_has_label_map_file();
+ label_map_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.SaveOutputParameter.label_map_file)
+}
+void SaveOutputParameter::set_label_map_file(const char* value, size_t size) {
+ set_has_label_map_file();
+ label_map_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.SaveOutputParameter.label_map_file)
+}
+::std::string* SaveOutputParameter::mutable_label_map_file() {
+ set_has_label_map_file();
+ // @@protoc_insertion_point(field_mutable:caffe.SaveOutputParameter.label_map_file)
+ return label_map_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* SaveOutputParameter::release_label_map_file() {
+ // @@protoc_insertion_point(field_release:caffe.SaveOutputParameter.label_map_file)
+ clear_has_label_map_file();
+ return label_map_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void SaveOutputParameter::set_allocated_label_map_file(::std::string* label_map_file) {
+ if (label_map_file != NULL) {
+ set_has_label_map_file();
+ } else {
+ clear_has_label_map_file();
+ }
+ label_map_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), label_map_file);
+ // @@protoc_insertion_point(field_set_allocated:caffe.SaveOutputParameter.label_map_file)
+}
+
+// optional string name_size_file = 5;
+bool SaveOutputParameter::has_name_size_file() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+void SaveOutputParameter::set_has_name_size_file() {
+ _has_bits_[0] |= 0x00000010u;
+}
+void SaveOutputParameter::clear_has_name_size_file() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+void SaveOutputParameter::clear_name_size_file() {
+ name_size_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_name_size_file();
+}
+const ::std::string& SaveOutputParameter::name_size_file() const {
+ // @@protoc_insertion_point(field_get:caffe.SaveOutputParameter.name_size_file)
+ return name_size_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void SaveOutputParameter::set_name_size_file(const ::std::string& value) {
+ set_has_name_size_file();
+ name_size_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.SaveOutputParameter.name_size_file)
+}
+void SaveOutputParameter::set_name_size_file(const char* value) {
+ set_has_name_size_file();
+ name_size_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.SaveOutputParameter.name_size_file)
+}
+void SaveOutputParameter::set_name_size_file(const char* value, size_t size) {
+ set_has_name_size_file();
+ name_size_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.SaveOutputParameter.name_size_file)
+}
+::std::string* SaveOutputParameter::mutable_name_size_file() {
+ set_has_name_size_file();
+ // @@protoc_insertion_point(field_mutable:caffe.SaveOutputParameter.name_size_file)
+ return name_size_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* SaveOutputParameter::release_name_size_file() {
+ // @@protoc_insertion_point(field_release:caffe.SaveOutputParameter.name_size_file)
+ clear_has_name_size_file();
+ return name_size_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void SaveOutputParameter::set_allocated_name_size_file(::std::string* name_size_file) {
+ if (name_size_file != NULL) {
+ set_has_name_size_file();
+ } else {
+ clear_has_name_size_file();
+ }
+ name_size_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name_size_file);
+ // @@protoc_insertion_point(field_set_allocated:caffe.SaveOutputParameter.name_size_file)
+}
+
+// optional uint32 num_test_image = 6;
+bool SaveOutputParameter::has_num_test_image() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+void SaveOutputParameter::set_has_num_test_image() {
+ _has_bits_[0] |= 0x00000020u;
+}
+void SaveOutputParameter::clear_has_num_test_image() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+void SaveOutputParameter::clear_num_test_image() {
+ num_test_image_ = 0u;
+ clear_has_num_test_image();
+}
+::google::protobuf::uint32 SaveOutputParameter::num_test_image() const {
+ // @@protoc_insertion_point(field_get:caffe.SaveOutputParameter.num_test_image)
+ return num_test_image_;
+}
+void SaveOutputParameter::set_num_test_image(::google::protobuf::uint32 value) {
+ set_has_num_test_image();
+ num_test_image_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SaveOutputParameter.num_test_image)
+}
+
+inline const SaveOutputParameter* SaveOutputParameter::internal_default_instance() {
+ return &SaveOutputParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int DropoutParameter::kDropoutRatioFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+DropoutParameter::DropoutParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.DropoutParameter)
+}
+
+void DropoutParameter::InitAsDefaultInstance() {
+}
+
+DropoutParameter::DropoutParameter(const DropoutParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.DropoutParameter)
+}
+
+void DropoutParameter::SharedCtor() {
+ _cached_size_ = 0;
+ dropout_ratio_ = 0.5f;
+}
+
+DropoutParameter::~DropoutParameter() {
+ // @@protoc_insertion_point(destructor:caffe.DropoutParameter)
+ SharedDtor();
+}
+
+void DropoutParameter::SharedDtor() {
+}
+
+void DropoutParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* DropoutParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return DropoutParameter_descriptor_;
+}
+
+const DropoutParameter& DropoutParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<DropoutParameter> DropoutParameter_default_instance_;
+
+DropoutParameter* DropoutParameter::New(::google::protobuf::Arena* arena) const {
+ DropoutParameter* n = new DropoutParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void DropoutParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.DropoutParameter)
+ dropout_ratio_ = 0.5f;
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool DropoutParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.DropoutParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional float dropout_ratio = 1 [default = 0.5];
+ case 1: {
+ if (tag == 13) {
+ set_has_dropout_ratio();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &dropout_ratio_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.DropoutParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.DropoutParameter)
+ return false;
+#undef DO_
+}
+
+void DropoutParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.DropoutParameter)
+ // optional float dropout_ratio = 1 [default = 0.5];
+ if (has_dropout_ratio()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->dropout_ratio(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.DropoutParameter)
+}
+
+::google::protobuf::uint8* DropoutParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.DropoutParameter)
+ // optional float dropout_ratio = 1 [default = 0.5];
+ if (has_dropout_ratio()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->dropout_ratio(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.DropoutParameter)
+ return target;
+}
+
+size_t DropoutParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.DropoutParameter)
+ size_t total_size = 0;
+
+ // optional float dropout_ratio = 1 [default = 0.5];
+ if (has_dropout_ratio()) {
+ total_size += 1 + 4;
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void DropoutParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.DropoutParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const DropoutParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const DropoutParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.DropoutParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.DropoutParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void DropoutParameter::MergeFrom(const DropoutParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.DropoutParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void DropoutParameter::UnsafeMergeFrom(const DropoutParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_dropout_ratio()) {
+ set_dropout_ratio(from.dropout_ratio());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void DropoutParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.DropoutParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void DropoutParameter::CopyFrom(const DropoutParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.DropoutParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool DropoutParameter::IsInitialized() const {
+
+ return true;
+}
+
+void DropoutParameter::Swap(DropoutParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void DropoutParameter::InternalSwap(DropoutParameter* other) {
+ std::swap(dropout_ratio_, other->dropout_ratio_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata DropoutParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = DropoutParameter_descriptor_;
+ metadata.reflection = DropoutParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// DropoutParameter
+
+// optional float dropout_ratio = 1 [default = 0.5];
+bool DropoutParameter::has_dropout_ratio() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void DropoutParameter::set_has_dropout_ratio() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void DropoutParameter::clear_has_dropout_ratio() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void DropoutParameter::clear_dropout_ratio() {
+ dropout_ratio_ = 0.5f;
+ clear_has_dropout_ratio();
+}
+float DropoutParameter::dropout_ratio() const {
+ // @@protoc_insertion_point(field_get:caffe.DropoutParameter.dropout_ratio)
+ return dropout_ratio_;
+}
+void DropoutParameter::set_dropout_ratio(float value) {
+ set_has_dropout_ratio();
+ dropout_ratio_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DropoutParameter.dropout_ratio)
+}
+
+inline const DropoutParameter* DropoutParameter::internal_default_instance() {
+ return &DropoutParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int DummyDataParameter::kDataFillerFieldNumber;
+const int DummyDataParameter::kShapeFieldNumber;
+const int DummyDataParameter::kNumFieldNumber;
+const int DummyDataParameter::kChannelsFieldNumber;
+const int DummyDataParameter::kHeightFieldNumber;
+const int DummyDataParameter::kWidthFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+DummyDataParameter::DummyDataParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.DummyDataParameter)
+}
+
+void DummyDataParameter::InitAsDefaultInstance() {
+}
+
+DummyDataParameter::DummyDataParameter(const DummyDataParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.DummyDataParameter)
+}
+
+void DummyDataParameter::SharedCtor() {
+ _cached_size_ = 0;
+}
+
+DummyDataParameter::~DummyDataParameter() {
+ // @@protoc_insertion_point(destructor:caffe.DummyDataParameter)
+ SharedDtor();
+}
+
+void DummyDataParameter::SharedDtor() {
+}
+
+void DummyDataParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* DummyDataParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return DummyDataParameter_descriptor_;
+}
+
+const DummyDataParameter& DummyDataParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<DummyDataParameter> DummyDataParameter_default_instance_;
+
+DummyDataParameter* DummyDataParameter::New(::google::protobuf::Arena* arena) const {
+ DummyDataParameter* n = new DummyDataParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void DummyDataParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.DummyDataParameter)
+ data_filler_.Clear();
+ shape_.Clear();
+ num_.Clear();
+ channels_.Clear();
+ height_.Clear();
+ width_.Clear();
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool DummyDataParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.DummyDataParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // repeated .caffe.FillerParameter data_filler = 1;
+ case 1: {
+ if (tag == 10) {
+ DO_(input->IncrementRecursionDepth());
+ parse_loop_data_filler:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
+ input, add_data_filler()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(10)) goto parse_loop_data_filler;
+ input->UnsafeDecrementRecursionDepth();
+ if (input->ExpectTag(16)) goto parse_num;
+ break;
+ }
+
+ // repeated uint32 num = 2;
+ case 2: {
+ if (tag == 16) {
+ parse_num:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ 1, 16, input, this->mutable_num())));
+ } else if (tag == 18) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, this->mutable_num())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_num;
+ if (input->ExpectTag(24)) goto parse_channels;
+ break;
+ }
+
+ // repeated uint32 channels = 3;
+ case 3: {
+ if (tag == 24) {
+ parse_channels:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ 1, 24, input, this->mutable_channels())));
+ } else if (tag == 26) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, this->mutable_channels())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(24)) goto parse_channels;
+ if (input->ExpectTag(32)) goto parse_height;
+ break;
+ }
+
+ // repeated uint32 height = 4;
+ case 4: {
+ if (tag == 32) {
+ parse_height:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ 1, 32, input, this->mutable_height())));
+ } else if (tag == 34) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, this->mutable_height())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(32)) goto parse_height;
+ if (input->ExpectTag(40)) goto parse_width;
+ break;
+ }
+
+ // repeated uint32 width = 5;
+ case 5: {
+ if (tag == 40) {
+ parse_width:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ 1, 40, input, this->mutable_width())));
+ } else if (tag == 42) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, this->mutable_width())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(40)) goto parse_width;
+ if (input->ExpectTag(50)) goto parse_shape;
+ break;
+ }
+
+ // repeated .caffe.BlobShape shape = 6;
+ case 6: {
+ if (tag == 50) {
+ parse_shape:
+ DO_(input->IncrementRecursionDepth());
+ parse_loop_shape:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
+ input, add_shape()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(50)) goto parse_loop_shape;
+ input->UnsafeDecrementRecursionDepth();
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.DummyDataParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.DummyDataParameter)
+ return false;
+#undef DO_
+}
+
+void DummyDataParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.DummyDataParameter)
+ // repeated .caffe.FillerParameter data_filler = 1;
+ for (unsigned int i = 0, n = this->data_filler_size(); i < n; i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 1, this->data_filler(i), output);
+ }
+
+ // repeated uint32 num = 2;
+ for (int i = 0; i < this->num_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(
+ 2, this->num(i), output);
+ }
+
+ // repeated uint32 channels = 3;
+ for (int i = 0; i < this->channels_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(
+ 3, this->channels(i), output);
+ }
+
+ // repeated uint32 height = 4;
+ for (int i = 0; i < this->height_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(
+ 4, this->height(i), output);
+ }
+
+ // repeated uint32 width = 5;
+ for (int i = 0; i < this->width_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(
+ 5, this->width(i), output);
+ }
+
+ // repeated .caffe.BlobShape shape = 6;
+ for (unsigned int i = 0, n = this->shape_size(); i < n; i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 6, this->shape(i), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.DummyDataParameter)
+}
+
+::google::protobuf::uint8* DummyDataParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.DummyDataParameter)
+ // repeated .caffe.FillerParameter data_filler = 1;
+ for (unsigned int i = 0, n = this->data_filler_size(); i < n; i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 1, this->data_filler(i), false, target);
+ }
+
+ // repeated uint32 num = 2;
+ for (int i = 0; i < this->num_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteUInt32ToArray(2, this->num(i), target);
+ }
+
+ // repeated uint32 channels = 3;
+ for (int i = 0; i < this->channels_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteUInt32ToArray(3, this->channels(i), target);
+ }
+
+ // repeated uint32 height = 4;
+ for (int i = 0; i < this->height_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteUInt32ToArray(4, this->height(i), target);
+ }
+
+ // repeated uint32 width = 5;
+ for (int i = 0; i < this->width_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteUInt32ToArray(5, this->width(i), target);
+ }
+
+ // repeated .caffe.BlobShape shape = 6;
+ for (unsigned int i = 0, n = this->shape_size(); i < n; i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 6, this->shape(i), false, target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.DummyDataParameter)
+ return target;
+}
+
+size_t DummyDataParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.DummyDataParameter)
+ size_t total_size = 0;
+
+ // repeated .caffe.FillerParameter data_filler = 1;
+ {
+ unsigned int count = this->data_filler_size();
+ total_size += 1UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->data_filler(i));
+ }
+ }
+
+ // repeated .caffe.BlobShape shape = 6;
+ {
+ unsigned int count = this->shape_size();
+ total_size += 1UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->shape(i));
+ }
+ }
+
+ // repeated uint32 num = 2;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->num_size();
+ for (unsigned int i = 0; i < count; i++) {
+ data_size += ::google::protobuf::internal::WireFormatLite::
+ UInt32Size(this->num(i));
+ }
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->num_size());
+ total_size += data_size;
+ }
+
+ // repeated uint32 channels = 3;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->channels_size();
+ for (unsigned int i = 0; i < count; i++) {
+ data_size += ::google::protobuf::internal::WireFormatLite::
+ UInt32Size(this->channels(i));
+ }
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->channels_size());
+ total_size += data_size;
+ }
+
+ // repeated uint32 height = 4;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->height_size();
+ for (unsigned int i = 0; i < count; i++) {
+ data_size += ::google::protobuf::internal::WireFormatLite::
+ UInt32Size(this->height(i));
+ }
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->height_size());
+ total_size += data_size;
+ }
+
+ // repeated uint32 width = 5;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->width_size();
+ for (unsigned int i = 0; i < count; i++) {
+ data_size += ::google::protobuf::internal::WireFormatLite::
+ UInt32Size(this->width(i));
+ }
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->width_size());
+ total_size += data_size;
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void DummyDataParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.DummyDataParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const DummyDataParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const DummyDataParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.DummyDataParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.DummyDataParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void DummyDataParameter::MergeFrom(const DummyDataParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.DummyDataParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void DummyDataParameter::UnsafeMergeFrom(const DummyDataParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ data_filler_.MergeFrom(from.data_filler_);
+ shape_.MergeFrom(from.shape_);
+ num_.UnsafeMergeFrom(from.num_);
+ channels_.UnsafeMergeFrom(from.channels_);
+ height_.UnsafeMergeFrom(from.height_);
+ width_.UnsafeMergeFrom(from.width_);
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void DummyDataParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.DummyDataParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void DummyDataParameter::CopyFrom(const DummyDataParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.DummyDataParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool DummyDataParameter::IsInitialized() const {
+
+ return true;
+}
+
+void DummyDataParameter::Swap(DummyDataParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void DummyDataParameter::InternalSwap(DummyDataParameter* other) {
+ data_filler_.UnsafeArenaSwap(&other->data_filler_);
+ shape_.UnsafeArenaSwap(&other->shape_);
+ num_.UnsafeArenaSwap(&other->num_);
+ channels_.UnsafeArenaSwap(&other->channels_);
+ height_.UnsafeArenaSwap(&other->height_);
+ width_.UnsafeArenaSwap(&other->width_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata DummyDataParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = DummyDataParameter_descriptor_;
+ metadata.reflection = DummyDataParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// DummyDataParameter
+
+// repeated .caffe.FillerParameter data_filler = 1;
+int DummyDataParameter::data_filler_size() const {
+ return data_filler_.size();
+}
+void DummyDataParameter::clear_data_filler() {
+ data_filler_.Clear();
+}
+const ::caffe::FillerParameter& DummyDataParameter::data_filler(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.data_filler)
+ return data_filler_.Get(index);
+}
+::caffe::FillerParameter* DummyDataParameter::mutable_data_filler(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.DummyDataParameter.data_filler)
+ return data_filler_.Mutable(index);
+}
+::caffe::FillerParameter* DummyDataParameter::add_data_filler() {
+ // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.data_filler)
+ return data_filler_.Add();
+}
+::google::protobuf::RepeatedPtrField< ::caffe::FillerParameter >*
+DummyDataParameter::mutable_data_filler() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.data_filler)
+ return &data_filler_;
+}
+const ::google::protobuf::RepeatedPtrField< ::caffe::FillerParameter >&
+DummyDataParameter::data_filler() const {
+ // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.data_filler)
+ return data_filler_;
+}
+
+// repeated .caffe.BlobShape shape = 6;
+int DummyDataParameter::shape_size() const {
+ return shape_.size();
+}
+void DummyDataParameter::clear_shape() {
+ shape_.Clear();
+}
+const ::caffe::BlobShape& DummyDataParameter::shape(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.shape)
+ return shape_.Get(index);
+}
+::caffe::BlobShape* DummyDataParameter::mutable_shape(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.DummyDataParameter.shape)
+ return shape_.Mutable(index);
+}
+::caffe::BlobShape* DummyDataParameter::add_shape() {
+ // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.shape)
+ return shape_.Add();
+}
+::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >*
+DummyDataParameter::mutable_shape() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.shape)
+ return &shape_;
+}
+const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >&
+DummyDataParameter::shape() const {
+ // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.shape)
+ return shape_;
+}
+
+// repeated uint32 num = 2;
+int DummyDataParameter::num_size() const {
+ return num_.size();
+}
+void DummyDataParameter::clear_num() {
+ num_.Clear();
+}
+::google::protobuf::uint32 DummyDataParameter::num(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.num)
+ return num_.Get(index);
+}
+void DummyDataParameter::set_num(int index, ::google::protobuf::uint32 value) {
+ num_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.DummyDataParameter.num)
+}
+void DummyDataParameter::add_num(::google::protobuf::uint32 value) {
+ num_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.num)
+}
+const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+DummyDataParameter::num() const {
+ // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.num)
+ return num_;
+}
+::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+DummyDataParameter::mutable_num() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.num)
+ return &num_;
+}
+
+// repeated uint32 channels = 3;
+int DummyDataParameter::channels_size() const {
+ return channels_.size();
+}
+void DummyDataParameter::clear_channels() {
+ channels_.Clear();
+}
+::google::protobuf::uint32 DummyDataParameter::channels(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.channels)
+ return channels_.Get(index);
+}
+void DummyDataParameter::set_channels(int index, ::google::protobuf::uint32 value) {
+ channels_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.DummyDataParameter.channels)
+}
+void DummyDataParameter::add_channels(::google::protobuf::uint32 value) {
+ channels_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.channels)
+}
+const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+DummyDataParameter::channels() const {
+ // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.channels)
+ return channels_;
+}
+::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+DummyDataParameter::mutable_channels() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.channels)
+ return &channels_;
+}
+
+// repeated uint32 height = 4;
+int DummyDataParameter::height_size() const {
+ return height_.size();
+}
+void DummyDataParameter::clear_height() {
+ height_.Clear();
+}
+::google::protobuf::uint32 DummyDataParameter::height(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.height)
+ return height_.Get(index);
+}
+void DummyDataParameter::set_height(int index, ::google::protobuf::uint32 value) {
+ height_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.DummyDataParameter.height)
+}
+void DummyDataParameter::add_height(::google::protobuf::uint32 value) {
+ height_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.height)
+}
+const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+DummyDataParameter::height() const {
+ // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.height)
+ return height_;
+}
+::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+DummyDataParameter::mutable_height() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.height)
+ return &height_;
+}
+
+// repeated uint32 width = 5;
+int DummyDataParameter::width_size() const {
+ return width_.size();
+}
+void DummyDataParameter::clear_width() {
+ width_.Clear();
+}
+::google::protobuf::uint32 DummyDataParameter::width(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.width)
+ return width_.Get(index);
+}
+void DummyDataParameter::set_width(int index, ::google::protobuf::uint32 value) {
+ width_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.DummyDataParameter.width)
+}
+void DummyDataParameter::add_width(::google::protobuf::uint32 value) {
+ width_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.width)
+}
+const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+DummyDataParameter::width() const {
+ // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.width)
+ return width_;
+}
+::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+DummyDataParameter::mutable_width() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.width)
+ return &width_;
+}
+
+inline const DummyDataParameter* DummyDataParameter::internal_default_instance() {
+ return &DummyDataParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+const ::google::protobuf::EnumDescriptor* EltwiseParameter_EltwiseOp_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return EltwiseParameter_EltwiseOp_descriptor_;
+}
+bool EltwiseParameter_EltwiseOp_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ case 2:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const EltwiseParameter_EltwiseOp EltwiseParameter::PROD;
+const EltwiseParameter_EltwiseOp EltwiseParameter::SUM;
+const EltwiseParameter_EltwiseOp EltwiseParameter::MAX;
+const EltwiseParameter_EltwiseOp EltwiseParameter::EltwiseOp_MIN;
+const EltwiseParameter_EltwiseOp EltwiseParameter::EltwiseOp_MAX;
+const int EltwiseParameter::EltwiseOp_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int EltwiseParameter::kOperationFieldNumber;
+const int EltwiseParameter::kCoeffFieldNumber;
+const int EltwiseParameter::kStableProdGradFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+EltwiseParameter::EltwiseParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.EltwiseParameter)
+}
+
+void EltwiseParameter::InitAsDefaultInstance() {
+}
+
+EltwiseParameter::EltwiseParameter(const EltwiseParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.EltwiseParameter)
+}
+
+void EltwiseParameter::SharedCtor() {
+ _cached_size_ = 0;
+ operation_ = 1;
+ stable_prod_grad_ = true;
+}
+
+EltwiseParameter::~EltwiseParameter() {
+ // @@protoc_insertion_point(destructor:caffe.EltwiseParameter)
+ SharedDtor();
+}
+
+void EltwiseParameter::SharedDtor() {
+}
+
+void EltwiseParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* EltwiseParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return EltwiseParameter_descriptor_;
+}
+
+const EltwiseParameter& EltwiseParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<EltwiseParameter> EltwiseParameter_default_instance_;
+
+EltwiseParameter* EltwiseParameter::New(::google::protobuf::Arena* arena) const {
+ EltwiseParameter* n = new EltwiseParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void EltwiseParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.EltwiseParameter)
+ if (_has_bits_[0 / 32] & 5u) {
+ operation_ = 1;
+ stable_prod_grad_ = true;
+ }
+ coeff_.Clear();
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool EltwiseParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.EltwiseParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional .caffe.EltwiseParameter.EltwiseOp operation = 1 [default = SUM];
+ case 1: {
+ if (tag == 8) {
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::EltwiseParameter_EltwiseOp_IsValid(value)) {
+ set_operation(static_cast< ::caffe::EltwiseParameter_EltwiseOp >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(1, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(21)) goto parse_coeff;
+ break;
+ }
+
+ // repeated float coeff = 2;
+ case 2: {
+ if (tag == 21) {
+ parse_coeff:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ 1, 21, input, this->mutable_coeff())));
+ } else if (tag == 18) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, this->mutable_coeff())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(21)) goto parse_coeff;
+ if (input->ExpectTag(24)) goto parse_stable_prod_grad;
+ break;
+ }
+
+ // optional bool stable_prod_grad = 3 [default = true];
+ case 3: {
+ if (tag == 24) {
+ parse_stable_prod_grad:
+ set_has_stable_prod_grad();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &stable_prod_grad_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.EltwiseParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.EltwiseParameter)
+ return false;
+#undef DO_
+}
+
+void EltwiseParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.EltwiseParameter)
+ // optional .caffe.EltwiseParameter.EltwiseOp operation = 1 [default = SUM];
+ if (has_operation()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 1, this->operation(), output);
+ }
+
+ // repeated float coeff = 2;
+ for (int i = 0; i < this->coeff_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(
+ 2, this->coeff(i), output);
+ }
+
+ // optional bool stable_prod_grad = 3 [default = true];
+ if (has_stable_prod_grad()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(3, this->stable_prod_grad(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.EltwiseParameter)
+}
+
+::google::protobuf::uint8* EltwiseParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.EltwiseParameter)
+ // optional .caffe.EltwiseParameter.EltwiseOp operation = 1 [default = SUM];
+ if (has_operation()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 1, this->operation(), target);
+ }
+
+ // repeated float coeff = 2;
+ for (int i = 0; i < this->coeff_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteFloatToArray(2, this->coeff(i), target);
+ }
+
+ // optional bool stable_prod_grad = 3 [default = true];
+ if (has_stable_prod_grad()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(3, this->stable_prod_grad(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.EltwiseParameter)
+ return target;
+}
+
+size_t EltwiseParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.EltwiseParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 5u) {
+ // optional .caffe.EltwiseParameter.EltwiseOp operation = 1 [default = SUM];
+ if (has_operation()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->operation());
+ }
+
+ // optional bool stable_prod_grad = 3 [default = true];
+ if (has_stable_prod_grad()) {
+ total_size += 1 + 1;
+ }
+
+ }
+ // repeated float coeff = 2;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->coeff_size();
+ data_size = 4UL * count;
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->coeff_size());
+ total_size += data_size;
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void EltwiseParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.EltwiseParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const EltwiseParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const EltwiseParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.EltwiseParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.EltwiseParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void EltwiseParameter::MergeFrom(const EltwiseParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.EltwiseParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void EltwiseParameter::UnsafeMergeFrom(const EltwiseParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ coeff_.UnsafeMergeFrom(from.coeff_);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_operation()) {
+ set_operation(from.operation());
+ }
+ if (from.has_stable_prod_grad()) {
+ set_stable_prod_grad(from.stable_prod_grad());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void EltwiseParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.EltwiseParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void EltwiseParameter::CopyFrom(const EltwiseParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.EltwiseParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool EltwiseParameter::IsInitialized() const {
+
+ return true;
+}
+
+void EltwiseParameter::Swap(EltwiseParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void EltwiseParameter::InternalSwap(EltwiseParameter* other) {
+ std::swap(operation_, other->operation_);
+ coeff_.UnsafeArenaSwap(&other->coeff_);
+ std::swap(stable_prod_grad_, other->stable_prod_grad_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata EltwiseParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = EltwiseParameter_descriptor_;
+ metadata.reflection = EltwiseParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// EltwiseParameter
+
+// optional .caffe.EltwiseParameter.EltwiseOp operation = 1 [default = SUM];
+bool EltwiseParameter::has_operation() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void EltwiseParameter::set_has_operation() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void EltwiseParameter::clear_has_operation() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void EltwiseParameter::clear_operation() {
+ operation_ = 1;
+ clear_has_operation();
+}
+::caffe::EltwiseParameter_EltwiseOp EltwiseParameter::operation() const {
+ // @@protoc_insertion_point(field_get:caffe.EltwiseParameter.operation)
+ return static_cast< ::caffe::EltwiseParameter_EltwiseOp >(operation_);
+}
+void EltwiseParameter::set_operation(::caffe::EltwiseParameter_EltwiseOp value) {
+ assert(::caffe::EltwiseParameter_EltwiseOp_IsValid(value));
+ set_has_operation();
+ operation_ = value;
+ // @@protoc_insertion_point(field_set:caffe.EltwiseParameter.operation)
+}
+
+// repeated float coeff = 2;
+int EltwiseParameter::coeff_size() const {
+ return coeff_.size();
+}
+void EltwiseParameter::clear_coeff() {
+ coeff_.Clear();
+}
+float EltwiseParameter::coeff(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.EltwiseParameter.coeff)
+ return coeff_.Get(index);
+}
+void EltwiseParameter::set_coeff(int index, float value) {
+ coeff_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.EltwiseParameter.coeff)
+}
+void EltwiseParameter::add_coeff(float value) {
+ coeff_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.EltwiseParameter.coeff)
+}
+const ::google::protobuf::RepeatedField< float >&
+EltwiseParameter::coeff() const {
+ // @@protoc_insertion_point(field_list:caffe.EltwiseParameter.coeff)
+ return coeff_;
+}
+::google::protobuf::RepeatedField< float >*
+EltwiseParameter::mutable_coeff() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.EltwiseParameter.coeff)
+ return &coeff_;
+}
+
+// optional bool stable_prod_grad = 3 [default = true];
+bool EltwiseParameter::has_stable_prod_grad() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void EltwiseParameter::set_has_stable_prod_grad() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void EltwiseParameter::clear_has_stable_prod_grad() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void EltwiseParameter::clear_stable_prod_grad() {
+ stable_prod_grad_ = true;
+ clear_has_stable_prod_grad();
+}
+bool EltwiseParameter::stable_prod_grad() const {
+ // @@protoc_insertion_point(field_get:caffe.EltwiseParameter.stable_prod_grad)
+ return stable_prod_grad_;
+}
+void EltwiseParameter::set_stable_prod_grad(bool value) {
+ set_has_stable_prod_grad();
+ stable_prod_grad_ = value;
+ // @@protoc_insertion_point(field_set:caffe.EltwiseParameter.stable_prod_grad)
+}
+
+inline const EltwiseParameter* EltwiseParameter::internal_default_instance() {
+ return &EltwiseParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int ELUParameter::kAlphaFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+ELUParameter::ELUParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.ELUParameter)
+}
+
+void ELUParameter::InitAsDefaultInstance() {
+}
+
+ELUParameter::ELUParameter(const ELUParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.ELUParameter)
+}
+
+void ELUParameter::SharedCtor() {
+ _cached_size_ = 0;
+ alpha_ = 1;
+}
+
+ELUParameter::~ELUParameter() {
+ // @@protoc_insertion_point(destructor:caffe.ELUParameter)
+ SharedDtor();
+}
+
+void ELUParameter::SharedDtor() {
+}
+
+void ELUParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* ELUParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return ELUParameter_descriptor_;
+}
+
+const ELUParameter& ELUParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<ELUParameter> ELUParameter_default_instance_;
+
+ELUParameter* ELUParameter::New(::google::protobuf::Arena* arena) const {
+ ELUParameter* n = new ELUParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void ELUParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.ELUParameter)
+ alpha_ = 1;
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool ELUParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.ELUParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional float alpha = 1 [default = 1];
+ case 1: {
+ if (tag == 13) {
+ set_has_alpha();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &alpha_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.ELUParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.ELUParameter)
+ return false;
+#undef DO_
+}
+
+void ELUParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.ELUParameter)
+ // optional float alpha = 1 [default = 1];
+ if (has_alpha()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->alpha(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.ELUParameter)
+}
+
+::google::protobuf::uint8* ELUParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.ELUParameter)
+ // optional float alpha = 1 [default = 1];
+ if (has_alpha()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->alpha(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.ELUParameter)
+ return target;
+}
+
+size_t ELUParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.ELUParameter)
+ size_t total_size = 0;
+
+ // optional float alpha = 1 [default = 1];
+ if (has_alpha()) {
+ total_size += 1 + 4;
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void ELUParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.ELUParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const ELUParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const ELUParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ELUParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ELUParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void ELUParameter::MergeFrom(const ELUParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ELUParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void ELUParameter::UnsafeMergeFrom(const ELUParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_alpha()) {
+ set_alpha(from.alpha());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void ELUParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.ELUParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void ELUParameter::CopyFrom(const ELUParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ELUParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool ELUParameter::IsInitialized() const {
+
+ return true;
+}
+
+void ELUParameter::Swap(ELUParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void ELUParameter::InternalSwap(ELUParameter* other) {
+ std::swap(alpha_, other->alpha_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata ELUParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = ELUParameter_descriptor_;
+ metadata.reflection = ELUParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// ELUParameter
+
+// optional float alpha = 1 [default = 1];
+bool ELUParameter::has_alpha() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void ELUParameter::set_has_alpha() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void ELUParameter::clear_has_alpha() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void ELUParameter::clear_alpha() {
+ alpha_ = 1;
+ clear_has_alpha();
+}
+float ELUParameter::alpha() const {
+ // @@protoc_insertion_point(field_get:caffe.ELUParameter.alpha)
+ return alpha_;
+}
+void ELUParameter::set_alpha(float value) {
+ set_has_alpha();
+ alpha_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ELUParameter.alpha)
+}
+
+inline const ELUParameter* ELUParameter::internal_default_instance() {
+ return &ELUParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int EmbedParameter::kNumOutputFieldNumber;
+const int EmbedParameter::kInputDimFieldNumber;
+const int EmbedParameter::kBiasTermFieldNumber;
+const int EmbedParameter::kWeightFillerFieldNumber;
+const int EmbedParameter::kBiasFillerFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+EmbedParameter::EmbedParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.EmbedParameter)
+}
+
+void EmbedParameter::InitAsDefaultInstance() {
+ weight_filler_ = const_cast< ::caffe::FillerParameter*>(
+ ::caffe::FillerParameter::internal_default_instance());
+ bias_filler_ = const_cast< ::caffe::FillerParameter*>(
+ ::caffe::FillerParameter::internal_default_instance());
+}
+
+EmbedParameter::EmbedParameter(const EmbedParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.EmbedParameter)
+}
+
+void EmbedParameter::SharedCtor() {
+ _cached_size_ = 0;
+ weight_filler_ = NULL;
+ bias_filler_ = NULL;
+ ::memset(&num_output_, 0, reinterpret_cast<char*>(&input_dim_) -
+ reinterpret_cast<char*>(&num_output_) + sizeof(input_dim_));
+ bias_term_ = true;
+}
+
+EmbedParameter::~EmbedParameter() {
+ // @@protoc_insertion_point(destructor:caffe.EmbedParameter)
+ SharedDtor();
+}
+
+void EmbedParameter::SharedDtor() {
+ if (this != &EmbedParameter_default_instance_.get()) {
+ delete weight_filler_;
+ delete bias_filler_;
+ }
+}
+
+void EmbedParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* EmbedParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return EmbedParameter_descriptor_;
+}
+
+const EmbedParameter& EmbedParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<EmbedParameter> EmbedParameter_default_instance_;
+
+EmbedParameter* EmbedParameter::New(::google::protobuf::Arena* arena) const {
+ EmbedParameter* n = new EmbedParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void EmbedParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.EmbedParameter)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(EmbedParameter, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<EmbedParameter*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ if (_has_bits_[0 / 32] & 31u) {
+ ZR_(num_output_, input_dim_);
+ bias_term_ = true;
+ if (has_weight_filler()) {
+ if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear();
+ }
+ if (has_bias_filler()) {
+ if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
+ }
+ }
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool EmbedParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.EmbedParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional uint32 num_output = 1;
+ case 1: {
+ if (tag == 8) {
+ set_has_num_output();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &num_output_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_input_dim;
+ break;
+ }
+
+ // optional uint32 input_dim = 2;
+ case 2: {
+ if (tag == 16) {
+ parse_input_dim:
+ set_has_input_dim();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &input_dim_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(24)) goto parse_bias_term;
+ break;
+ }
+
+ // optional bool bias_term = 3 [default = true];
+ case 3: {
+ if (tag == 24) {
+ parse_bias_term:
+ set_has_bias_term();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &bias_term_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(34)) goto parse_weight_filler;
+ break;
+ }
+
+ // optional .caffe.FillerParameter weight_filler = 4;
+ case 4: {
+ if (tag == 34) {
+ parse_weight_filler:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_weight_filler()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(42)) goto parse_bias_filler;
+ break;
+ }
+
+ // optional .caffe.FillerParameter bias_filler = 5;
+ case 5: {
+ if (tag == 42) {
+ parse_bias_filler:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_bias_filler()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.EmbedParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.EmbedParameter)
+ return false;
+#undef DO_
+}
+
+void EmbedParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.EmbedParameter)
+ // optional uint32 num_output = 1;
+ if (has_num_output()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->num_output(), output);
+ }
+
+ // optional uint32 input_dim = 2;
+ if (has_input_dim()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(2, this->input_dim(), output);
+ }
+
+ // optional bool bias_term = 3 [default = true];
+ if (has_bias_term()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(3, this->bias_term(), output);
+ }
+
+ // optional .caffe.FillerParameter weight_filler = 4;
+ if (has_weight_filler()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 4, *this->weight_filler_, output);
+ }
+
+ // optional .caffe.FillerParameter bias_filler = 5;
+ if (has_bias_filler()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 5, *this->bias_filler_, output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.EmbedParameter)
+}
+
+::google::protobuf::uint8* EmbedParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.EmbedParameter)
+ // optional uint32 num_output = 1;
+ if (has_num_output()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->num_output(), target);
+ }
+
+ // optional uint32 input_dim = 2;
+ if (has_input_dim()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(2, this->input_dim(), target);
+ }
+
+ // optional bool bias_term = 3 [default = true];
+ if (has_bias_term()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(3, this->bias_term(), target);
+ }
+
+ // optional .caffe.FillerParameter weight_filler = 4;
+ if (has_weight_filler()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 4, *this->weight_filler_, false, target);
+ }
+
+ // optional .caffe.FillerParameter bias_filler = 5;
+ if (has_bias_filler()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 5, *this->bias_filler_, false, target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.EmbedParameter)
+ return target;
+}
+
+size_t EmbedParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.EmbedParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 31u) {
+ // optional uint32 num_output = 1;
+ if (has_num_output()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->num_output());
+ }
+
+ // optional uint32 input_dim = 2;
+ if (has_input_dim()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->input_dim());
+ }
+
+ // optional bool bias_term = 3 [default = true];
+ if (has_bias_term()) {
+ total_size += 1 + 1;
+ }
+
+ // optional .caffe.FillerParameter weight_filler = 4;
+ if (has_weight_filler()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->weight_filler_);
+ }
+
+ // optional .caffe.FillerParameter bias_filler = 5;
+ if (has_bias_filler()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->bias_filler_);
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void EmbedParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.EmbedParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const EmbedParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const EmbedParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.EmbedParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.EmbedParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void EmbedParameter::MergeFrom(const EmbedParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.EmbedParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void EmbedParameter::UnsafeMergeFrom(const EmbedParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_num_output()) {
+ set_num_output(from.num_output());
+ }
+ if (from.has_input_dim()) {
+ set_input_dim(from.input_dim());
+ }
+ if (from.has_bias_term()) {
+ set_bias_term(from.bias_term());
+ }
+ if (from.has_weight_filler()) {
+ mutable_weight_filler()->::caffe::FillerParameter::MergeFrom(from.weight_filler());
+ }
+ if (from.has_bias_filler()) {
+ mutable_bias_filler()->::caffe::FillerParameter::MergeFrom(from.bias_filler());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void EmbedParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.EmbedParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void EmbedParameter::CopyFrom(const EmbedParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.EmbedParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool EmbedParameter::IsInitialized() const {
+
+ return true;
+}
+
+void EmbedParameter::Swap(EmbedParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void EmbedParameter::InternalSwap(EmbedParameter* other) {
+ std::swap(num_output_, other->num_output_);
+ std::swap(input_dim_, other->input_dim_);
+ std::swap(bias_term_, other->bias_term_);
+ std::swap(weight_filler_, other->weight_filler_);
+ std::swap(bias_filler_, other->bias_filler_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata EmbedParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = EmbedParameter_descriptor_;
+ metadata.reflection = EmbedParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// EmbedParameter
+
+// optional uint32 num_output = 1;
+bool EmbedParameter::has_num_output() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void EmbedParameter::set_has_num_output() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void EmbedParameter::clear_has_num_output() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void EmbedParameter::clear_num_output() {
+ num_output_ = 0u;
+ clear_has_num_output();
+}
+::google::protobuf::uint32 EmbedParameter::num_output() const {
+ // @@protoc_insertion_point(field_get:caffe.EmbedParameter.num_output)
+ return num_output_;
+}
+void EmbedParameter::set_num_output(::google::protobuf::uint32 value) {
+ set_has_num_output();
+ num_output_ = value;
+ // @@protoc_insertion_point(field_set:caffe.EmbedParameter.num_output)
+}
+
+// optional uint32 input_dim = 2;
+bool EmbedParameter::has_input_dim() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void EmbedParameter::set_has_input_dim() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void EmbedParameter::clear_has_input_dim() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void EmbedParameter::clear_input_dim() {
+ input_dim_ = 0u;
+ clear_has_input_dim();
+}
+::google::protobuf::uint32 EmbedParameter::input_dim() const {
+ // @@protoc_insertion_point(field_get:caffe.EmbedParameter.input_dim)
+ return input_dim_;
+}
+void EmbedParameter::set_input_dim(::google::protobuf::uint32 value) {
+ set_has_input_dim();
+ input_dim_ = value;
+ // @@protoc_insertion_point(field_set:caffe.EmbedParameter.input_dim)
+}
+
+// optional bool bias_term = 3 [default = true];
+bool EmbedParameter::has_bias_term() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void EmbedParameter::set_has_bias_term() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void EmbedParameter::clear_has_bias_term() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void EmbedParameter::clear_bias_term() {
+ bias_term_ = true;
+ clear_has_bias_term();
+}
+bool EmbedParameter::bias_term() const {
+ // @@protoc_insertion_point(field_get:caffe.EmbedParameter.bias_term)
+ return bias_term_;
+}
+void EmbedParameter::set_bias_term(bool value) {
+ set_has_bias_term();
+ bias_term_ = value;
+ // @@protoc_insertion_point(field_set:caffe.EmbedParameter.bias_term)
+}
+
+// optional .caffe.FillerParameter weight_filler = 4;
+bool EmbedParameter::has_weight_filler() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+void EmbedParameter::set_has_weight_filler() {
+ _has_bits_[0] |= 0x00000008u;
+}
+void EmbedParameter::clear_has_weight_filler() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+void EmbedParameter::clear_weight_filler() {
+ if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear();
+ clear_has_weight_filler();
+}
+const ::caffe::FillerParameter& EmbedParameter::weight_filler() const {
+ // @@protoc_insertion_point(field_get:caffe.EmbedParameter.weight_filler)
+ return weight_filler_ != NULL ? *weight_filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+::caffe::FillerParameter* EmbedParameter::mutable_weight_filler() {
+ set_has_weight_filler();
+ if (weight_filler_ == NULL) {
+ weight_filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.EmbedParameter.weight_filler)
+ return weight_filler_;
+}
+::caffe::FillerParameter* EmbedParameter::release_weight_filler() {
+ // @@protoc_insertion_point(field_release:caffe.EmbedParameter.weight_filler)
+ clear_has_weight_filler();
+ ::caffe::FillerParameter* temp = weight_filler_;
+ weight_filler_ = NULL;
+ return temp;
+}
+void EmbedParameter::set_allocated_weight_filler(::caffe::FillerParameter* weight_filler) {
+ delete weight_filler_;
+ weight_filler_ = weight_filler;
+ if (weight_filler) {
+ set_has_weight_filler();
+ } else {
+ clear_has_weight_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.EmbedParameter.weight_filler)
+}
+
+// optional .caffe.FillerParameter bias_filler = 5;
+bool EmbedParameter::has_bias_filler() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+void EmbedParameter::set_has_bias_filler() {
+ _has_bits_[0] |= 0x00000010u;
+}
+void EmbedParameter::clear_has_bias_filler() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+void EmbedParameter::clear_bias_filler() {
+ if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
+ clear_has_bias_filler();
+}
+const ::caffe::FillerParameter& EmbedParameter::bias_filler() const {
+ // @@protoc_insertion_point(field_get:caffe.EmbedParameter.bias_filler)
+ return bias_filler_ != NULL ? *bias_filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+::caffe::FillerParameter* EmbedParameter::mutable_bias_filler() {
+ set_has_bias_filler();
+ if (bias_filler_ == NULL) {
+ bias_filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.EmbedParameter.bias_filler)
+ return bias_filler_;
+}
+::caffe::FillerParameter* EmbedParameter::release_bias_filler() {
+ // @@protoc_insertion_point(field_release:caffe.EmbedParameter.bias_filler)
+ clear_has_bias_filler();
+ ::caffe::FillerParameter* temp = bias_filler_;
+ bias_filler_ = NULL;
+ return temp;
+}
+void EmbedParameter::set_allocated_bias_filler(::caffe::FillerParameter* bias_filler) {
+ delete bias_filler_;
+ bias_filler_ = bias_filler;
+ if (bias_filler) {
+ set_has_bias_filler();
+ } else {
+ clear_has_bias_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.EmbedParameter.bias_filler)
+}
+
+inline const EmbedParameter* EmbedParameter::internal_default_instance() {
+ return &EmbedParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int ExpParameter::kBaseFieldNumber;
+const int ExpParameter::kScaleFieldNumber;
+const int ExpParameter::kShiftFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+ExpParameter::ExpParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.ExpParameter)
+}
+
+void ExpParameter::InitAsDefaultInstance() {
+}
+
+ExpParameter::ExpParameter(const ExpParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.ExpParameter)
+}
+
+void ExpParameter::SharedCtor() {
+ _cached_size_ = 0;
+ shift_ = 0;
+ base_ = -1;
+ scale_ = 1;
+}
+
+ExpParameter::~ExpParameter() {
+ // @@protoc_insertion_point(destructor:caffe.ExpParameter)
+ SharedDtor();
+}
+
+void ExpParameter::SharedDtor() {
+}
+
+void ExpParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* ExpParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return ExpParameter_descriptor_;
+}
+
+const ExpParameter& ExpParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<ExpParameter> ExpParameter_default_instance_;
+
+ExpParameter* ExpParameter::New(::google::protobuf::Arena* arena) const {
+ ExpParameter* n = new ExpParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void ExpParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.ExpParameter)
+ if (_has_bits_[0 / 32] & 7u) {
+ base_ = -1;
+ scale_ = 1;
+ shift_ = 0;
+ }
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool ExpParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.ExpParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional float base = 1 [default = -1];
+ case 1: {
+ if (tag == 13) {
+ set_has_base();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &base_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(21)) goto parse_scale;
+ break;
+ }
+
+ // optional float scale = 2 [default = 1];
+ case 2: {
+ if (tag == 21) {
+ parse_scale:
+ set_has_scale();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &scale_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(29)) goto parse_shift;
+ break;
+ }
+
+ // optional float shift = 3 [default = 0];
+ case 3: {
+ if (tag == 29) {
+ parse_shift:
+ set_has_shift();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &shift_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.ExpParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.ExpParameter)
+ return false;
+#undef DO_
+}
+
+void ExpParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.ExpParameter)
+ // optional float base = 1 [default = -1];
+ if (has_base()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->base(), output);
+ }
+
+ // optional float scale = 2 [default = 1];
+ if (has_scale()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->scale(), output);
+ }
+
+ // optional float shift = 3 [default = 0];
+ if (has_shift()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->shift(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.ExpParameter)
+}
+
+::google::protobuf::uint8* ExpParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.ExpParameter)
+ // optional float base = 1 [default = -1];
+ if (has_base()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->base(), target);
+ }
+
+ // optional float scale = 2 [default = 1];
+ if (has_scale()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->scale(), target);
+ }
+
+ // optional float shift = 3 [default = 0];
+ if (has_shift()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->shift(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.ExpParameter)
+ return target;
+}
+
+size_t ExpParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.ExpParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 7u) {
+ // optional float base = 1 [default = -1];
+ if (has_base()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float scale = 2 [default = 1];
+ if (has_scale()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float shift = 3 [default = 0];
+ if (has_shift()) {
+ total_size += 1 + 4;
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void ExpParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.ExpParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const ExpParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const ExpParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ExpParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ExpParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void ExpParameter::MergeFrom(const ExpParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ExpParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void ExpParameter::UnsafeMergeFrom(const ExpParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_base()) {
+ set_base(from.base());
+ }
+ if (from.has_scale()) {
+ set_scale(from.scale());
+ }
+ if (from.has_shift()) {
+ set_shift(from.shift());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void ExpParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.ExpParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void ExpParameter::CopyFrom(const ExpParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ExpParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool ExpParameter::IsInitialized() const {
+
+ return true;
+}
+
+void ExpParameter::Swap(ExpParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void ExpParameter::InternalSwap(ExpParameter* other) {
+ std::swap(base_, other->base_);
+ std::swap(scale_, other->scale_);
+ std::swap(shift_, other->shift_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata ExpParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = ExpParameter_descriptor_;
+ metadata.reflection = ExpParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// ExpParameter
+
+// optional float base = 1 [default = -1];
+bool ExpParameter::has_base() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void ExpParameter::set_has_base() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void ExpParameter::clear_has_base() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void ExpParameter::clear_base() {
+ base_ = -1;
+ clear_has_base();
+}
+float ExpParameter::base() const {
+ // @@protoc_insertion_point(field_get:caffe.ExpParameter.base)
+ return base_;
+}
+void ExpParameter::set_base(float value) {
+ set_has_base();
+ base_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ExpParameter.base)
+}
+
+// optional float scale = 2 [default = 1];
+bool ExpParameter::has_scale() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void ExpParameter::set_has_scale() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void ExpParameter::clear_has_scale() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void ExpParameter::clear_scale() {
+ scale_ = 1;
+ clear_has_scale();
+}
+float ExpParameter::scale() const {
+ // @@protoc_insertion_point(field_get:caffe.ExpParameter.scale)
+ return scale_;
+}
+void ExpParameter::set_scale(float value) {
+ set_has_scale();
+ scale_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ExpParameter.scale)
+}
+
+// optional float shift = 3 [default = 0];
+bool ExpParameter::has_shift() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void ExpParameter::set_has_shift() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void ExpParameter::clear_has_shift() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void ExpParameter::clear_shift() {
+ shift_ = 0;
+ clear_has_shift();
+}
+float ExpParameter::shift() const {
+ // @@protoc_insertion_point(field_get:caffe.ExpParameter.shift)
+ return shift_;
+}
+void ExpParameter::set_shift(float value) {
+ set_has_shift();
+ shift_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ExpParameter.shift)
+}
+
+inline const ExpParameter* ExpParameter::internal_default_instance() {
+ return &ExpParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int FlattenParameter::kAxisFieldNumber;
+const int FlattenParameter::kEndAxisFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+FlattenParameter::FlattenParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.FlattenParameter)
+}
+
+void FlattenParameter::InitAsDefaultInstance() {
+}
+
+FlattenParameter::FlattenParameter(const FlattenParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.FlattenParameter)
+}
+
+void FlattenParameter::SharedCtor() {
+ _cached_size_ = 0;
+ axis_ = 1;
+ end_axis_ = -1;
+}
+
+FlattenParameter::~FlattenParameter() {
+ // @@protoc_insertion_point(destructor:caffe.FlattenParameter)
+ SharedDtor();
+}
+
+void FlattenParameter::SharedDtor() {
+}
+
+void FlattenParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* FlattenParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return FlattenParameter_descriptor_;
+}
+
+const FlattenParameter& FlattenParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<FlattenParameter> FlattenParameter_default_instance_;
+
+FlattenParameter* FlattenParameter::New(::google::protobuf::Arena* arena) const {
+ FlattenParameter* n = new FlattenParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void FlattenParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.FlattenParameter)
+ if (_has_bits_[0 / 32] & 3u) {
+ axis_ = 1;
+ end_axis_ = -1;
+ }
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool FlattenParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.FlattenParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional int32 axis = 1 [default = 1];
+ case 1: {
+ if (tag == 8) {
+ set_has_axis();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &axis_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_end_axis;
+ break;
+ }
+
+ // optional int32 end_axis = 2 [default = -1];
+ case 2: {
+ if (tag == 16) {
+ parse_end_axis:
+ set_has_end_axis();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &end_axis_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.FlattenParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.FlattenParameter)
+ return false;
+#undef DO_
+}
+
+void FlattenParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.FlattenParameter)
+ // optional int32 axis = 1 [default = 1];
+ if (has_axis()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->axis(), output);
+ }
+
+ // optional int32 end_axis = 2 [default = -1];
+ if (has_end_axis()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->end_axis(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.FlattenParameter)
+}
+
+::google::protobuf::uint8* FlattenParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.FlattenParameter)
+ // optional int32 axis = 1 [default = 1];
+ if (has_axis()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->axis(), target);
+ }
+
+ // optional int32 end_axis = 2 [default = -1];
+ if (has_end_axis()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->end_axis(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.FlattenParameter)
+ return target;
+}
+
+size_t FlattenParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.FlattenParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 3u) {
+ // optional int32 axis = 1 [default = 1];
+ if (has_axis()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->axis());
+ }
+
+ // optional int32 end_axis = 2 [default = -1];
+ if (has_end_axis()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->end_axis());
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void FlattenParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.FlattenParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const FlattenParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const FlattenParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.FlattenParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.FlattenParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void FlattenParameter::MergeFrom(const FlattenParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.FlattenParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void FlattenParameter::UnsafeMergeFrom(const FlattenParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_axis()) {
+ set_axis(from.axis());
+ }
+ if (from.has_end_axis()) {
+ set_end_axis(from.end_axis());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void FlattenParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.FlattenParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void FlattenParameter::CopyFrom(const FlattenParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.FlattenParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool FlattenParameter::IsInitialized() const {
+
+ return true;
+}
+
+void FlattenParameter::Swap(FlattenParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void FlattenParameter::InternalSwap(FlattenParameter* other) {
+ std::swap(axis_, other->axis_);
+ std::swap(end_axis_, other->end_axis_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata FlattenParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = FlattenParameter_descriptor_;
+ metadata.reflection = FlattenParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// FlattenParameter
+
+// optional int32 axis = 1 [default = 1];
+bool FlattenParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void FlattenParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void FlattenParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void FlattenParameter::clear_axis() {
+ axis_ = 1;
+ clear_has_axis();
+}
+::google::protobuf::int32 FlattenParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.FlattenParameter.axis)
+ return axis_;
+}
+void FlattenParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.FlattenParameter.axis)
+}
+
+// optional int32 end_axis = 2 [default = -1];
+bool FlattenParameter::has_end_axis() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void FlattenParameter::set_has_end_axis() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void FlattenParameter::clear_has_end_axis() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void FlattenParameter::clear_end_axis() {
+ end_axis_ = -1;
+ clear_has_end_axis();
+}
+::google::protobuf::int32 FlattenParameter::end_axis() const {
+ // @@protoc_insertion_point(field_get:caffe.FlattenParameter.end_axis)
+ return end_axis_;
+}
+void FlattenParameter::set_end_axis(::google::protobuf::int32 value) {
+ set_has_end_axis();
+ end_axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.FlattenParameter.end_axis)
+}
+
+inline const FlattenParameter* FlattenParameter::internal_default_instance() {
+ return &FlattenParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int HDF5DataParameter::kSourceFieldNumber;
+const int HDF5DataParameter::kBatchSizeFieldNumber;
+const int HDF5DataParameter::kShuffleFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+HDF5DataParameter::HDF5DataParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.HDF5DataParameter)
+}
+
+void HDF5DataParameter::InitAsDefaultInstance() {
+}
+
+HDF5DataParameter::HDF5DataParameter(const HDF5DataParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.HDF5DataParameter)
+}
+
+void HDF5DataParameter::SharedCtor() {
+ _cached_size_ = 0;
+ source_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ ::memset(&batch_size_, 0, reinterpret_cast<char*>(&shuffle_) -
+ reinterpret_cast<char*>(&batch_size_) + sizeof(shuffle_));
+}
+
+HDF5DataParameter::~HDF5DataParameter() {
+ // @@protoc_insertion_point(destructor:caffe.HDF5DataParameter)
+ SharedDtor();
+}
+
+void HDF5DataParameter::SharedDtor() {
+ source_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+
+void HDF5DataParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* HDF5DataParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return HDF5DataParameter_descriptor_;
+}
+
+const HDF5DataParameter& HDF5DataParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<HDF5DataParameter> HDF5DataParameter_default_instance_;
+
+HDF5DataParameter* HDF5DataParameter::New(::google::protobuf::Arena* arena) const {
+ HDF5DataParameter* n = new HDF5DataParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void HDF5DataParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.HDF5DataParameter)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(HDF5DataParameter, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<HDF5DataParameter*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ if (_has_bits_[0 / 32] & 7u) {
+ ZR_(batch_size_, shuffle_);
+ if (has_source()) {
+ source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ }
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool HDF5DataParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.HDF5DataParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional string source = 1;
+ case 1: {
+ if (tag == 10) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_source()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->source().data(), this->source().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.HDF5DataParameter.source");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_batch_size;
+ break;
+ }
+
+ // optional uint32 batch_size = 2;
+ case 2: {
+ if (tag == 16) {
+ parse_batch_size:
+ set_has_batch_size();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &batch_size_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(24)) goto parse_shuffle;
+ break;
+ }
+
+ // optional bool shuffle = 3 [default = false];
+ case 3: {
+ if (tag == 24) {
+ parse_shuffle:
+ set_has_shuffle();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &shuffle_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.HDF5DataParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.HDF5DataParameter)
+ return false;
+#undef DO_
+}
+
+void HDF5DataParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.HDF5DataParameter)
+ // optional string source = 1;
+ if (has_source()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->source().data(), this->source().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.HDF5DataParameter.source");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 1, this->source(), output);
+ }
+
+ // optional uint32 batch_size = 2;
+ if (has_batch_size()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(2, this->batch_size(), output);
+ }
+
+ // optional bool shuffle = 3 [default = false];
+ if (has_shuffle()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(3, this->shuffle(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.HDF5DataParameter)
+}
+
+::google::protobuf::uint8* HDF5DataParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.HDF5DataParameter)
+ // optional string source = 1;
+ if (has_source()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->source().data(), this->source().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.HDF5DataParameter.source");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 1, this->source(), target);
+ }
+
+ // optional uint32 batch_size = 2;
+ if (has_batch_size()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(2, this->batch_size(), target);
+ }
+
+ // optional bool shuffle = 3 [default = false];
+ if (has_shuffle()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(3, this->shuffle(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.HDF5DataParameter)
+ return target;
+}
+
+size_t HDF5DataParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.HDF5DataParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 7u) {
+ // optional string source = 1;
+ if (has_source()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->source());
+ }
+
+ // optional uint32 batch_size = 2;
+ if (has_batch_size()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->batch_size());
+ }
+
+ // optional bool shuffle = 3 [default = false];
+ if (has_shuffle()) {
+ total_size += 1 + 1;
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void HDF5DataParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.HDF5DataParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const HDF5DataParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const HDF5DataParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.HDF5DataParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.HDF5DataParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void HDF5DataParameter::MergeFrom(const HDF5DataParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.HDF5DataParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void HDF5DataParameter::UnsafeMergeFrom(const HDF5DataParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_source()) {
+ set_has_source();
+ source_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_);
+ }
+ if (from.has_batch_size()) {
+ set_batch_size(from.batch_size());
+ }
+ if (from.has_shuffle()) {
+ set_shuffle(from.shuffle());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void HDF5DataParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.HDF5DataParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void HDF5DataParameter::CopyFrom(const HDF5DataParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.HDF5DataParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool HDF5DataParameter::IsInitialized() const {
+
+ return true;
+}
+
+void HDF5DataParameter::Swap(HDF5DataParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void HDF5DataParameter::InternalSwap(HDF5DataParameter* other) {
+ source_.Swap(&other->source_);
+ std::swap(batch_size_, other->batch_size_);
+ std::swap(shuffle_, other->shuffle_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata HDF5DataParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = HDF5DataParameter_descriptor_;
+ metadata.reflection = HDF5DataParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// HDF5DataParameter
+
+// optional string source = 1;
+bool HDF5DataParameter::has_source() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void HDF5DataParameter::set_has_source() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void HDF5DataParameter::clear_has_source() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void HDF5DataParameter::clear_source() {
+ source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_source();
+}
+const ::std::string& HDF5DataParameter::source() const {
+ // @@protoc_insertion_point(field_get:caffe.HDF5DataParameter.source)
+ return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void HDF5DataParameter::set_source(const ::std::string& value) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.HDF5DataParameter.source)
+}
+void HDF5DataParameter::set_source(const char* value) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.HDF5DataParameter.source)
+}
+void HDF5DataParameter::set_source(const char* value, size_t size) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.HDF5DataParameter.source)
+}
+::std::string* HDF5DataParameter::mutable_source() {
+ set_has_source();
+ // @@protoc_insertion_point(field_mutable:caffe.HDF5DataParameter.source)
+ return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* HDF5DataParameter::release_source() {
+ // @@protoc_insertion_point(field_release:caffe.HDF5DataParameter.source)
+ clear_has_source();
+ return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void HDF5DataParameter::set_allocated_source(::std::string* source) {
+ if (source != NULL) {
+ set_has_source();
+ } else {
+ clear_has_source();
+ }
+ source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source);
+ // @@protoc_insertion_point(field_set_allocated:caffe.HDF5DataParameter.source)
+}
+
+// optional uint32 batch_size = 2;
+bool HDF5DataParameter::has_batch_size() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void HDF5DataParameter::set_has_batch_size() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void HDF5DataParameter::clear_has_batch_size() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void HDF5DataParameter::clear_batch_size() {
+ batch_size_ = 0u;
+ clear_has_batch_size();
+}
+::google::protobuf::uint32 HDF5DataParameter::batch_size() const {
+ // @@protoc_insertion_point(field_get:caffe.HDF5DataParameter.batch_size)
+ return batch_size_;
+}
+void HDF5DataParameter::set_batch_size(::google::protobuf::uint32 value) {
+ set_has_batch_size();
+ batch_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.HDF5DataParameter.batch_size)
+}
+
+// optional bool shuffle = 3 [default = false];
+bool HDF5DataParameter::has_shuffle() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void HDF5DataParameter::set_has_shuffle() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void HDF5DataParameter::clear_has_shuffle() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void HDF5DataParameter::clear_shuffle() {
+ shuffle_ = false;
+ clear_has_shuffle();
+}
+bool HDF5DataParameter::shuffle() const {
+ // @@protoc_insertion_point(field_get:caffe.HDF5DataParameter.shuffle)
+ return shuffle_;
+}
+void HDF5DataParameter::set_shuffle(bool value) {
+ set_has_shuffle();
+ shuffle_ = value;
+ // @@protoc_insertion_point(field_set:caffe.HDF5DataParameter.shuffle)
+}
+
+inline const HDF5DataParameter* HDF5DataParameter::internal_default_instance() {
+ return &HDF5DataParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int HDF5OutputParameter::kFileNameFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+HDF5OutputParameter::HDF5OutputParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.HDF5OutputParameter)
+}
+
+void HDF5OutputParameter::InitAsDefaultInstance() {
+}
+
+HDF5OutputParameter::HDF5OutputParameter(const HDF5OutputParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.HDF5OutputParameter)
+}
+
+void HDF5OutputParameter::SharedCtor() {
+ _cached_size_ = 0;
+ file_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+
+HDF5OutputParameter::~HDF5OutputParameter() {
+ // @@protoc_insertion_point(destructor:caffe.HDF5OutputParameter)
+ SharedDtor();
+}
+
+void HDF5OutputParameter::SharedDtor() {
+ file_name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+
+void HDF5OutputParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* HDF5OutputParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return HDF5OutputParameter_descriptor_;
+}
+
+const HDF5OutputParameter& HDF5OutputParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<HDF5OutputParameter> HDF5OutputParameter_default_instance_;
+
+HDF5OutputParameter* HDF5OutputParameter::New(::google::protobuf::Arena* arena) const {
+ HDF5OutputParameter* n = new HDF5OutputParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void HDF5OutputParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.HDF5OutputParameter)
+ if (has_file_name()) {
+ file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool HDF5OutputParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.HDF5OutputParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional string file_name = 1;
+ case 1: {
+ if (tag == 10) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_file_name()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->file_name().data(), this->file_name().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.HDF5OutputParameter.file_name");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.HDF5OutputParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.HDF5OutputParameter)
+ return false;
+#undef DO_
+}
+
+void HDF5OutputParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.HDF5OutputParameter)
+ // optional string file_name = 1;
+ if (has_file_name()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->file_name().data(), this->file_name().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.HDF5OutputParameter.file_name");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 1, this->file_name(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.HDF5OutputParameter)
+}
+
+::google::protobuf::uint8* HDF5OutputParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.HDF5OutputParameter)
+ // optional string file_name = 1;
+ if (has_file_name()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->file_name().data(), this->file_name().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.HDF5OutputParameter.file_name");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 1, this->file_name(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.HDF5OutputParameter)
+ return target;
+}
+
+size_t HDF5OutputParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.HDF5OutputParameter)
+ size_t total_size = 0;
+
+ // optional string file_name = 1;
+ if (has_file_name()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->file_name());
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void HDF5OutputParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.HDF5OutputParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const HDF5OutputParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const HDF5OutputParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.HDF5OutputParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.HDF5OutputParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void HDF5OutputParameter::MergeFrom(const HDF5OutputParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.HDF5OutputParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void HDF5OutputParameter::UnsafeMergeFrom(const HDF5OutputParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_file_name()) {
+ set_has_file_name();
+ file_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.file_name_);
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void HDF5OutputParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.HDF5OutputParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void HDF5OutputParameter::CopyFrom(const HDF5OutputParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.HDF5OutputParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool HDF5OutputParameter::IsInitialized() const {
+
+ return true;
+}
+
+void HDF5OutputParameter::Swap(HDF5OutputParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void HDF5OutputParameter::InternalSwap(HDF5OutputParameter* other) {
+ file_name_.Swap(&other->file_name_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata HDF5OutputParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = HDF5OutputParameter_descriptor_;
+ metadata.reflection = HDF5OutputParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// HDF5OutputParameter
+
+// optional string file_name = 1;
+bool HDF5OutputParameter::has_file_name() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void HDF5OutputParameter::set_has_file_name() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void HDF5OutputParameter::clear_has_file_name() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void HDF5OutputParameter::clear_file_name() {
+ file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_file_name();
+}
+const ::std::string& HDF5OutputParameter::file_name() const {
+ // @@protoc_insertion_point(field_get:caffe.HDF5OutputParameter.file_name)
+ return file_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void HDF5OutputParameter::set_file_name(const ::std::string& value) {
+ set_has_file_name();
+ file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.HDF5OutputParameter.file_name)
+}
+void HDF5OutputParameter::set_file_name(const char* value) {
+ set_has_file_name();
+ file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.HDF5OutputParameter.file_name)
+}
+void HDF5OutputParameter::set_file_name(const char* value, size_t size) {
+ set_has_file_name();
+ file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.HDF5OutputParameter.file_name)
+}
+::std::string* HDF5OutputParameter::mutable_file_name() {
+ set_has_file_name();
+ // @@protoc_insertion_point(field_mutable:caffe.HDF5OutputParameter.file_name)
+ return file_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* HDF5OutputParameter::release_file_name() {
+ // @@protoc_insertion_point(field_release:caffe.HDF5OutputParameter.file_name)
+ clear_has_file_name();
+ return file_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void HDF5OutputParameter::set_allocated_file_name(::std::string* file_name) {
+ if (file_name != NULL) {
+ set_has_file_name();
+ } else {
+ clear_has_file_name();
+ }
+ file_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), file_name);
+ // @@protoc_insertion_point(field_set_allocated:caffe.HDF5OutputParameter.file_name)
+}
+
+inline const HDF5OutputParameter* HDF5OutputParameter::internal_default_instance() {
+ return &HDF5OutputParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+const ::google::protobuf::EnumDescriptor* HingeLossParameter_Norm_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return HingeLossParameter_Norm_descriptor_;
+}
+bool HingeLossParameter_Norm_IsValid(int value) {
+ switch (value) {
+ case 1:
+ case 2:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const HingeLossParameter_Norm HingeLossParameter::L1;
+const HingeLossParameter_Norm HingeLossParameter::L2;
+const HingeLossParameter_Norm HingeLossParameter::Norm_MIN;
+const HingeLossParameter_Norm HingeLossParameter::Norm_MAX;
+const int HingeLossParameter::Norm_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int HingeLossParameter::kNormFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+HingeLossParameter::HingeLossParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.HingeLossParameter)
+}
+
+void HingeLossParameter::InitAsDefaultInstance() {
+}
+
+HingeLossParameter::HingeLossParameter(const HingeLossParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.HingeLossParameter)
+}
+
+void HingeLossParameter::SharedCtor() {
+ _cached_size_ = 0;
+ norm_ = 1;
+}
+
+HingeLossParameter::~HingeLossParameter() {
+ // @@protoc_insertion_point(destructor:caffe.HingeLossParameter)
+ SharedDtor();
+}
+
+void HingeLossParameter::SharedDtor() {
+}
+
+void HingeLossParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* HingeLossParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return HingeLossParameter_descriptor_;
+}
+
+const HingeLossParameter& HingeLossParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<HingeLossParameter> HingeLossParameter_default_instance_;
+
+HingeLossParameter* HingeLossParameter::New(::google::protobuf::Arena* arena) const {
+ HingeLossParameter* n = new HingeLossParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void HingeLossParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.HingeLossParameter)
+ norm_ = 1;
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool HingeLossParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.HingeLossParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional .caffe.HingeLossParameter.Norm norm = 1 [default = L1];
+ case 1: {
+ if (tag == 8) {
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::HingeLossParameter_Norm_IsValid(value)) {
+ set_norm(static_cast< ::caffe::HingeLossParameter_Norm >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(1, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.HingeLossParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.HingeLossParameter)
+ return false;
+#undef DO_
+}
+
+void HingeLossParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.HingeLossParameter)
+ // optional .caffe.HingeLossParameter.Norm norm = 1 [default = L1];
+ if (has_norm()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 1, this->norm(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.HingeLossParameter)
+}
+
+::google::protobuf::uint8* HingeLossParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.HingeLossParameter)
+ // optional .caffe.HingeLossParameter.Norm norm = 1 [default = L1];
+ if (has_norm()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 1, this->norm(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.HingeLossParameter)
+ return target;
+}
+
+size_t HingeLossParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.HingeLossParameter)
+ size_t total_size = 0;
+
+ // optional .caffe.HingeLossParameter.Norm norm = 1 [default = L1];
+ if (has_norm()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->norm());
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void HingeLossParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.HingeLossParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const HingeLossParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const HingeLossParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.HingeLossParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.HingeLossParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void HingeLossParameter::MergeFrom(const HingeLossParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.HingeLossParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void HingeLossParameter::UnsafeMergeFrom(const HingeLossParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_norm()) {
+ set_norm(from.norm());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void HingeLossParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.HingeLossParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void HingeLossParameter::CopyFrom(const HingeLossParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.HingeLossParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool HingeLossParameter::IsInitialized() const {
+
+ return true;
+}
+
+void HingeLossParameter::Swap(HingeLossParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void HingeLossParameter::InternalSwap(HingeLossParameter* other) {
+ std::swap(norm_, other->norm_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata HingeLossParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = HingeLossParameter_descriptor_;
+ metadata.reflection = HingeLossParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// HingeLossParameter
+
+// optional .caffe.HingeLossParameter.Norm norm = 1 [default = L1];
+bool HingeLossParameter::has_norm() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void HingeLossParameter::set_has_norm() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void HingeLossParameter::clear_has_norm() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void HingeLossParameter::clear_norm() {
+ norm_ = 1;
+ clear_has_norm();
+}
+::caffe::HingeLossParameter_Norm HingeLossParameter::norm() const {
+ // @@protoc_insertion_point(field_get:caffe.HingeLossParameter.norm)
+ return static_cast< ::caffe::HingeLossParameter_Norm >(norm_);
+}
+void HingeLossParameter::set_norm(::caffe::HingeLossParameter_Norm value) {
+ assert(::caffe::HingeLossParameter_Norm_IsValid(value));
+ set_has_norm();
+ norm_ = value;
+ // @@protoc_insertion_point(field_set:caffe.HingeLossParameter.norm)
+}
+
+inline const HingeLossParameter* HingeLossParameter::internal_default_instance() {
+ return &HingeLossParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int ImageDataParameter::kSourceFieldNumber;
+const int ImageDataParameter::kBatchSizeFieldNumber;
+const int ImageDataParameter::kRandSkipFieldNumber;
+const int ImageDataParameter::kShuffleFieldNumber;
+const int ImageDataParameter::kNewHeightFieldNumber;
+const int ImageDataParameter::kNewWidthFieldNumber;
+const int ImageDataParameter::kIsColorFieldNumber;
+const int ImageDataParameter::kScaleFieldNumber;
+const int ImageDataParameter::kMeanFileFieldNumber;
+const int ImageDataParameter::kCropSizeFieldNumber;
+const int ImageDataParameter::kMirrorFieldNumber;
+const int ImageDataParameter::kRootFolderFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+ImageDataParameter::ImageDataParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.ImageDataParameter)
+}
+
+void ImageDataParameter::InitAsDefaultInstance() {
+}
+
+ImageDataParameter::ImageDataParameter(const ImageDataParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.ImageDataParameter)
+}
+
+void ImageDataParameter::SharedCtor() {
+ _cached_size_ = 0;
+ source_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ mean_file_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ root_folder_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ ::memset(&rand_skip_, 0, reinterpret_cast<char*>(&crop_size_) -
+ reinterpret_cast<char*>(&rand_skip_) + sizeof(crop_size_));
+ scale_ = 1;
+ batch_size_ = 1u;
+ is_color_ = true;
+}
+
+ImageDataParameter::~ImageDataParameter() {
+ // @@protoc_insertion_point(destructor:caffe.ImageDataParameter)
+ SharedDtor();
+}
+
+void ImageDataParameter::SharedDtor() {
+ source_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ mean_file_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ root_folder_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+
+void ImageDataParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* ImageDataParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return ImageDataParameter_descriptor_;
+}
+
+const ImageDataParameter& ImageDataParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<ImageDataParameter> ImageDataParameter_default_instance_;
+
+ImageDataParameter* ImageDataParameter::New(::google::protobuf::Arena* arena) const {
+ ImageDataParameter* n = new ImageDataParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void ImageDataParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.ImageDataParameter)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(ImageDataParameter, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<ImageDataParameter*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ if (_has_bits_[0 / 32] & 255u) {
+ ZR_(rand_skip_, shuffle_);
+ if (has_source()) {
+ source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ batch_size_ = 1u;
+ is_color_ = true;
+ scale_ = 1;
+ }
+ if (_has_bits_[8 / 32] & 3840u) {
+ ZR_(mirror_, crop_size_);
+ if (has_mean_file()) {
+ mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ if (has_root_folder()) {
+ root_folder_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ }
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool ImageDataParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.ImageDataParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional string source = 1;
+ case 1: {
+ if (tag == 10) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_source()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->source().data(), this->source().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.ImageDataParameter.source");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(21)) goto parse_scale;
+ break;
+ }
+
+ // optional float scale = 2 [default = 1];
+ case 2: {
+ if (tag == 21) {
+ parse_scale:
+ set_has_scale();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &scale_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(26)) goto parse_mean_file;
+ break;
+ }
+
+ // optional string mean_file = 3;
+ case 3: {
+ if (tag == 26) {
+ parse_mean_file:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_mean_file()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->mean_file().data(), this->mean_file().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.ImageDataParameter.mean_file");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(32)) goto parse_batch_size;
+ break;
+ }
+
+ // optional uint32 batch_size = 4 [default = 1];
+ case 4: {
+ if (tag == 32) {
+ parse_batch_size:
+ set_has_batch_size();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &batch_size_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(40)) goto parse_crop_size;
+ break;
+ }
+
+ // optional uint32 crop_size = 5 [default = 0];
+ case 5: {
+ if (tag == 40) {
+ parse_crop_size:
+ set_has_crop_size();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &crop_size_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(48)) goto parse_mirror;
+ break;
+ }
+
+ // optional bool mirror = 6 [default = false];
+ case 6: {
+ if (tag == 48) {
+ parse_mirror:
+ set_has_mirror();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &mirror_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(56)) goto parse_rand_skip;
+ break;
+ }
+
+ // optional uint32 rand_skip = 7 [default = 0];
+ case 7: {
+ if (tag == 56) {
+ parse_rand_skip:
+ set_has_rand_skip();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &rand_skip_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(64)) goto parse_shuffle;
+ break;
+ }
+
+ // optional bool shuffle = 8 [default = false];
+ case 8: {
+ if (tag == 64) {
+ parse_shuffle:
+ set_has_shuffle();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &shuffle_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(72)) goto parse_new_height;
+ break;
+ }
+
+ // optional uint32 new_height = 9 [default = 0];
+ case 9: {
+ if (tag == 72) {
+ parse_new_height:
+ set_has_new_height();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &new_height_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(80)) goto parse_new_width;
+ break;
+ }
+
+ // optional uint32 new_width = 10 [default = 0];
+ case 10: {
+ if (tag == 80) {
+ parse_new_width:
+ set_has_new_width();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &new_width_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(88)) goto parse_is_color;
+ break;
+ }
+
+ // optional bool is_color = 11 [default = true];
+ case 11: {
+ if (tag == 88) {
+ parse_is_color:
+ set_has_is_color();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &is_color_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(98)) goto parse_root_folder;
+ break;
+ }
+
+ // optional string root_folder = 12 [default = ""];
+ case 12: {
+ if (tag == 98) {
+ parse_root_folder:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_root_folder()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->root_folder().data(), this->root_folder().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.ImageDataParameter.root_folder");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.ImageDataParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.ImageDataParameter)
+ return false;
+#undef DO_
+}
+
+void ImageDataParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.ImageDataParameter)
+ // optional string source = 1;
+ if (has_source()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->source().data(), this->source().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.ImageDataParameter.source");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 1, this->source(), output);
+ }
+
+ // optional float scale = 2 [default = 1];
+ if (has_scale()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->scale(), output);
+ }
+
+ // optional string mean_file = 3;
+ if (has_mean_file()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->mean_file().data(), this->mean_file().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.ImageDataParameter.mean_file");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 3, this->mean_file(), output);
+ }
+
+ // optional uint32 batch_size = 4 [default = 1];
+ if (has_batch_size()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(4, this->batch_size(), output);
+ }
+
+ // optional uint32 crop_size = 5 [default = 0];
+ if (has_crop_size()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(5, this->crop_size(), output);
+ }
+
+ // optional bool mirror = 6 [default = false];
+ if (has_mirror()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(6, this->mirror(), output);
+ }
+
+ // optional uint32 rand_skip = 7 [default = 0];
+ if (has_rand_skip()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(7, this->rand_skip(), output);
+ }
+
+ // optional bool shuffle = 8 [default = false];
+ if (has_shuffle()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(8, this->shuffle(), output);
+ }
+
+ // optional uint32 new_height = 9 [default = 0];
+ if (has_new_height()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(9, this->new_height(), output);
+ }
+
+ // optional uint32 new_width = 10 [default = 0];
+ if (has_new_width()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(10, this->new_width(), output);
+ }
+
+ // optional bool is_color = 11 [default = true];
+ if (has_is_color()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(11, this->is_color(), output);
+ }
+
+ // optional string root_folder = 12 [default = ""];
+ if (has_root_folder()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->root_folder().data(), this->root_folder().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.ImageDataParameter.root_folder");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 12, this->root_folder(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.ImageDataParameter)
+}
+
+::google::protobuf::uint8* ImageDataParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.ImageDataParameter)
+ // optional string source = 1;
+ if (has_source()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->source().data(), this->source().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.ImageDataParameter.source");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 1, this->source(), target);
+ }
+
+ // optional float scale = 2 [default = 1];
+ if (has_scale()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->scale(), target);
+ }
+
+ // optional string mean_file = 3;
+ if (has_mean_file()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->mean_file().data(), this->mean_file().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.ImageDataParameter.mean_file");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 3, this->mean_file(), target);
+ }
+
+ // optional uint32 batch_size = 4 [default = 1];
+ if (has_batch_size()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(4, this->batch_size(), target);
+ }
+
+ // optional uint32 crop_size = 5 [default = 0];
+ if (has_crop_size()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(5, this->crop_size(), target);
+ }
+
+ // optional bool mirror = 6 [default = false];
+ if (has_mirror()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(6, this->mirror(), target);
+ }
+
+ // optional uint32 rand_skip = 7 [default = 0];
+ if (has_rand_skip()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(7, this->rand_skip(), target);
+ }
+
+ // optional bool shuffle = 8 [default = false];
+ if (has_shuffle()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(8, this->shuffle(), target);
+ }
+
+ // optional uint32 new_height = 9 [default = 0];
+ if (has_new_height()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(9, this->new_height(), target);
+ }
+
+ // optional uint32 new_width = 10 [default = 0];
+ if (has_new_width()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(10, this->new_width(), target);
+ }
+
+ // optional bool is_color = 11 [default = true];
+ if (has_is_color()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(11, this->is_color(), target);
+ }
+
+ // optional string root_folder = 12 [default = ""];
+ if (has_root_folder()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->root_folder().data(), this->root_folder().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.ImageDataParameter.root_folder");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 12, this->root_folder(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.ImageDataParameter)
+ return target;
+}
+
+size_t ImageDataParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.ImageDataParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 255u) {
+ // optional string source = 1;
+ if (has_source()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->source());
+ }
+
+ // optional uint32 batch_size = 4 [default = 1];
+ if (has_batch_size()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->batch_size());
+ }
+
+ // optional uint32 rand_skip = 7 [default = 0];
+ if (has_rand_skip()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->rand_skip());
+ }
+
+ // optional bool shuffle = 8 [default = false];
+ if (has_shuffle()) {
+ total_size += 1 + 1;
+ }
+
+ // optional uint32 new_height = 9 [default = 0];
+ if (has_new_height()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->new_height());
+ }
+
+ // optional uint32 new_width = 10 [default = 0];
+ if (has_new_width()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->new_width());
+ }
+
+ // optional bool is_color = 11 [default = true];
+ if (has_is_color()) {
+ total_size += 1 + 1;
+ }
+
+ // optional float scale = 2 [default = 1];
+ if (has_scale()) {
+ total_size += 1 + 4;
+ }
+
+ }
+ if (_has_bits_[8 / 32] & 3840u) {
+ // optional string mean_file = 3;
+ if (has_mean_file()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->mean_file());
+ }
+
+ // optional uint32 crop_size = 5 [default = 0];
+ if (has_crop_size()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->crop_size());
+ }
+
+ // optional bool mirror = 6 [default = false];
+ if (has_mirror()) {
+ total_size += 1 + 1;
+ }
+
+ // optional string root_folder = 12 [default = ""];
+ if (has_root_folder()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->root_folder());
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void ImageDataParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.ImageDataParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const ImageDataParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const ImageDataParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ImageDataParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ImageDataParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void ImageDataParameter::MergeFrom(const ImageDataParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ImageDataParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void ImageDataParameter::UnsafeMergeFrom(const ImageDataParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_source()) {
+ set_has_source();
+ source_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_);
+ }
+ if (from.has_batch_size()) {
+ set_batch_size(from.batch_size());
+ }
+ if (from.has_rand_skip()) {
+ set_rand_skip(from.rand_skip());
+ }
+ if (from.has_shuffle()) {
+ set_shuffle(from.shuffle());
+ }
+ if (from.has_new_height()) {
+ set_new_height(from.new_height());
+ }
+ if (from.has_new_width()) {
+ set_new_width(from.new_width());
+ }
+ if (from.has_is_color()) {
+ set_is_color(from.is_color());
+ }
+ if (from.has_scale()) {
+ set_scale(from.scale());
+ }
+ }
+ if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) {
+ if (from.has_mean_file()) {
+ set_has_mean_file();
+ mean_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.mean_file_);
+ }
+ if (from.has_crop_size()) {
+ set_crop_size(from.crop_size());
+ }
+ if (from.has_mirror()) {
+ set_mirror(from.mirror());
+ }
+ if (from.has_root_folder()) {
+ set_has_root_folder();
+ root_folder_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.root_folder_);
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void ImageDataParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.ImageDataParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void ImageDataParameter::CopyFrom(const ImageDataParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ImageDataParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool ImageDataParameter::IsInitialized() const {
+
+ return true;
+}
+
+void ImageDataParameter::Swap(ImageDataParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void ImageDataParameter::InternalSwap(ImageDataParameter* other) {
+ source_.Swap(&other->source_);
+ std::swap(batch_size_, other->batch_size_);
+ std::swap(rand_skip_, other->rand_skip_);
+ std::swap(shuffle_, other->shuffle_);
+ std::swap(new_height_, other->new_height_);
+ std::swap(new_width_, other->new_width_);
+ std::swap(is_color_, other->is_color_);
+ std::swap(scale_, other->scale_);
+ mean_file_.Swap(&other->mean_file_);
+ std::swap(crop_size_, other->crop_size_);
+ std::swap(mirror_, other->mirror_);
+ root_folder_.Swap(&other->root_folder_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata ImageDataParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = ImageDataParameter_descriptor_;
+ metadata.reflection = ImageDataParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// ImageDataParameter
+
+// optional string source = 1;
+bool ImageDataParameter::has_source() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void ImageDataParameter::set_has_source() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void ImageDataParameter::clear_has_source() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void ImageDataParameter::clear_source() {
+ source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_source();
+}
+const ::std::string& ImageDataParameter::source() const {
+ // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.source)
+ return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void ImageDataParameter::set_source(const ::std::string& value) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.source)
+}
+void ImageDataParameter::set_source(const char* value) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.ImageDataParameter.source)
+}
+void ImageDataParameter::set_source(const char* value, size_t size) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.ImageDataParameter.source)
+}
+::std::string* ImageDataParameter::mutable_source() {
+ set_has_source();
+ // @@protoc_insertion_point(field_mutable:caffe.ImageDataParameter.source)
+ return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* ImageDataParameter::release_source() {
+ // @@protoc_insertion_point(field_release:caffe.ImageDataParameter.source)
+ clear_has_source();
+ return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void ImageDataParameter::set_allocated_source(::std::string* source) {
+ if (source != NULL) {
+ set_has_source();
+ } else {
+ clear_has_source();
+ }
+ source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source);
+ // @@protoc_insertion_point(field_set_allocated:caffe.ImageDataParameter.source)
+}
+
+// optional uint32 batch_size = 4 [default = 1];
+bool ImageDataParameter::has_batch_size() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void ImageDataParameter::set_has_batch_size() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void ImageDataParameter::clear_has_batch_size() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void ImageDataParameter::clear_batch_size() {
+ batch_size_ = 1u;
+ clear_has_batch_size();
+}
+::google::protobuf::uint32 ImageDataParameter::batch_size() const {
+ // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.batch_size)
+ return batch_size_;
+}
+void ImageDataParameter::set_batch_size(::google::protobuf::uint32 value) {
+ set_has_batch_size();
+ batch_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.batch_size)
+}
+
+// optional uint32 rand_skip = 7 [default = 0];
+bool ImageDataParameter::has_rand_skip() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void ImageDataParameter::set_has_rand_skip() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void ImageDataParameter::clear_has_rand_skip() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void ImageDataParameter::clear_rand_skip() {
+ rand_skip_ = 0u;
+ clear_has_rand_skip();
+}
+::google::protobuf::uint32 ImageDataParameter::rand_skip() const {
+ // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.rand_skip)
+ return rand_skip_;
+}
+void ImageDataParameter::set_rand_skip(::google::protobuf::uint32 value) {
+ set_has_rand_skip();
+ rand_skip_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.rand_skip)
+}
+
+// optional bool shuffle = 8 [default = false];
+bool ImageDataParameter::has_shuffle() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+void ImageDataParameter::set_has_shuffle() {
+ _has_bits_[0] |= 0x00000008u;
+}
+void ImageDataParameter::clear_has_shuffle() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+void ImageDataParameter::clear_shuffle() {
+ shuffle_ = false;
+ clear_has_shuffle();
+}
+bool ImageDataParameter::shuffle() const {
+ // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.shuffle)
+ return shuffle_;
+}
+void ImageDataParameter::set_shuffle(bool value) {
+ set_has_shuffle();
+ shuffle_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.shuffle)
+}
+
+// optional uint32 new_height = 9 [default = 0];
+bool ImageDataParameter::has_new_height() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+void ImageDataParameter::set_has_new_height() {
+ _has_bits_[0] |= 0x00000010u;
+}
+void ImageDataParameter::clear_has_new_height() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+void ImageDataParameter::clear_new_height() {
+ new_height_ = 0u;
+ clear_has_new_height();
+}
+::google::protobuf::uint32 ImageDataParameter::new_height() const {
+ // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.new_height)
+ return new_height_;
+}
+void ImageDataParameter::set_new_height(::google::protobuf::uint32 value) {
+ set_has_new_height();
+ new_height_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.new_height)
+}
+
+// optional uint32 new_width = 10 [default = 0];
+bool ImageDataParameter::has_new_width() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+void ImageDataParameter::set_has_new_width() {
+ _has_bits_[0] |= 0x00000020u;
+}
+void ImageDataParameter::clear_has_new_width() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+void ImageDataParameter::clear_new_width() {
+ new_width_ = 0u;
+ clear_has_new_width();
+}
+::google::protobuf::uint32 ImageDataParameter::new_width() const {
+ // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.new_width)
+ return new_width_;
+}
+void ImageDataParameter::set_new_width(::google::protobuf::uint32 value) {
+ set_has_new_width();
+ new_width_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.new_width)
+}
+
+// optional bool is_color = 11 [default = true];
+bool ImageDataParameter::has_is_color() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+void ImageDataParameter::set_has_is_color() {
+ _has_bits_[0] |= 0x00000040u;
+}
+void ImageDataParameter::clear_has_is_color() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+void ImageDataParameter::clear_is_color() {
+ is_color_ = true;
+ clear_has_is_color();
+}
+bool ImageDataParameter::is_color() const {
+ // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.is_color)
+ return is_color_;
+}
+void ImageDataParameter::set_is_color(bool value) {
+ set_has_is_color();
+ is_color_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.is_color)
+}
+
+// optional float scale = 2 [default = 1];
+bool ImageDataParameter::has_scale() const {
+ return (_has_bits_[0] & 0x00000080u) != 0;
+}
+void ImageDataParameter::set_has_scale() {
+ _has_bits_[0] |= 0x00000080u;
+}
+void ImageDataParameter::clear_has_scale() {
+ _has_bits_[0] &= ~0x00000080u;
+}
+void ImageDataParameter::clear_scale() {
+ scale_ = 1;
+ clear_has_scale();
+}
+float ImageDataParameter::scale() const {
+ // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.scale)
+ return scale_;
+}
+void ImageDataParameter::set_scale(float value) {
+ set_has_scale();
+ scale_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.scale)
+}
+
+// optional string mean_file = 3;
+bool ImageDataParameter::has_mean_file() const {
+ return (_has_bits_[0] & 0x00000100u) != 0;
+}
+void ImageDataParameter::set_has_mean_file() {
+ _has_bits_[0] |= 0x00000100u;
+}
+void ImageDataParameter::clear_has_mean_file() {
+ _has_bits_[0] &= ~0x00000100u;
+}
+void ImageDataParameter::clear_mean_file() {
+ mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_mean_file();
+}
+const ::std::string& ImageDataParameter::mean_file() const {
+ // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.mean_file)
+ return mean_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void ImageDataParameter::set_mean_file(const ::std::string& value) {
+ set_has_mean_file();
+ mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.mean_file)
+}
+void ImageDataParameter::set_mean_file(const char* value) {
+ set_has_mean_file();
+ mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.ImageDataParameter.mean_file)
+}
+void ImageDataParameter::set_mean_file(const char* value, size_t size) {
+ set_has_mean_file();
+ mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.ImageDataParameter.mean_file)
+}
+::std::string* ImageDataParameter::mutable_mean_file() {
+ set_has_mean_file();
+ // @@protoc_insertion_point(field_mutable:caffe.ImageDataParameter.mean_file)
+ return mean_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* ImageDataParameter::release_mean_file() {
+ // @@protoc_insertion_point(field_release:caffe.ImageDataParameter.mean_file)
+ clear_has_mean_file();
+ return mean_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void ImageDataParameter::set_allocated_mean_file(::std::string* mean_file) {
+ if (mean_file != NULL) {
+ set_has_mean_file();
+ } else {
+ clear_has_mean_file();
+ }
+ mean_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), mean_file);
+ // @@protoc_insertion_point(field_set_allocated:caffe.ImageDataParameter.mean_file)
+}
+
+// optional uint32 crop_size = 5 [default = 0];
+bool ImageDataParameter::has_crop_size() const {
+ return (_has_bits_[0] & 0x00000200u) != 0;
+}
+void ImageDataParameter::set_has_crop_size() {
+ _has_bits_[0] |= 0x00000200u;
+}
+void ImageDataParameter::clear_has_crop_size() {
+ _has_bits_[0] &= ~0x00000200u;
+}
+void ImageDataParameter::clear_crop_size() {
+ crop_size_ = 0u;
+ clear_has_crop_size();
+}
+::google::protobuf::uint32 ImageDataParameter::crop_size() const {
+ // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.crop_size)
+ return crop_size_;
+}
+void ImageDataParameter::set_crop_size(::google::protobuf::uint32 value) {
+ set_has_crop_size();
+ crop_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.crop_size)
+}
+
+// optional bool mirror = 6 [default = false];
+bool ImageDataParameter::has_mirror() const {
+ return (_has_bits_[0] & 0x00000400u) != 0;
+}
+void ImageDataParameter::set_has_mirror() {
+ _has_bits_[0] |= 0x00000400u;
+}
+void ImageDataParameter::clear_has_mirror() {
+ _has_bits_[0] &= ~0x00000400u;
+}
+void ImageDataParameter::clear_mirror() {
+ mirror_ = false;
+ clear_has_mirror();
+}
+bool ImageDataParameter::mirror() const {
+ // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.mirror)
+ return mirror_;
+}
+void ImageDataParameter::set_mirror(bool value) {
+ set_has_mirror();
+ mirror_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.mirror)
+}
+
+// optional string root_folder = 12 [default = ""];
+bool ImageDataParameter::has_root_folder() const {
+ return (_has_bits_[0] & 0x00000800u) != 0;
+}
+void ImageDataParameter::set_has_root_folder() {
+ _has_bits_[0] |= 0x00000800u;
+}
+void ImageDataParameter::clear_has_root_folder() {
+ _has_bits_[0] &= ~0x00000800u;
+}
+void ImageDataParameter::clear_root_folder() {
+ root_folder_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_root_folder();
+}
+const ::std::string& ImageDataParameter::root_folder() const {
+ // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.root_folder)
+ return root_folder_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void ImageDataParameter::set_root_folder(const ::std::string& value) {
+ set_has_root_folder();
+ root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.root_folder)
+}
+void ImageDataParameter::set_root_folder(const char* value) {
+ set_has_root_folder();
+ root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.ImageDataParameter.root_folder)
+}
+void ImageDataParameter::set_root_folder(const char* value, size_t size) {
+ set_has_root_folder();
+ root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.ImageDataParameter.root_folder)
+}
+::std::string* ImageDataParameter::mutable_root_folder() {
+ set_has_root_folder();
+ // @@protoc_insertion_point(field_mutable:caffe.ImageDataParameter.root_folder)
+ return root_folder_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* ImageDataParameter::release_root_folder() {
+ // @@protoc_insertion_point(field_release:caffe.ImageDataParameter.root_folder)
+ clear_has_root_folder();
+ return root_folder_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void ImageDataParameter::set_allocated_root_folder(::std::string* root_folder) {
+ if (root_folder != NULL) {
+ set_has_root_folder();
+ } else {
+ clear_has_root_folder();
+ }
+ root_folder_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), root_folder);
+ // @@protoc_insertion_point(field_set_allocated:caffe.ImageDataParameter.root_folder)
+}
+
+inline const ImageDataParameter* ImageDataParameter::internal_default_instance() {
+ return &ImageDataParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int InfogainLossParameter::kSourceFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+InfogainLossParameter::InfogainLossParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.InfogainLossParameter)
+}
+
+void InfogainLossParameter::InitAsDefaultInstance() {
+}
+
+InfogainLossParameter::InfogainLossParameter(const InfogainLossParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.InfogainLossParameter)
+}
+
+void InfogainLossParameter::SharedCtor() {
+ _cached_size_ = 0;
+ source_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+
+InfogainLossParameter::~InfogainLossParameter() {
+ // @@protoc_insertion_point(destructor:caffe.InfogainLossParameter)
+ SharedDtor();
+}
+
+void InfogainLossParameter::SharedDtor() {
+ source_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+
+void InfogainLossParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* InfogainLossParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return InfogainLossParameter_descriptor_;
+}
+
+const InfogainLossParameter& InfogainLossParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<InfogainLossParameter> InfogainLossParameter_default_instance_;
+
+InfogainLossParameter* InfogainLossParameter::New(::google::protobuf::Arena* arena) const {
+ InfogainLossParameter* n = new InfogainLossParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void InfogainLossParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.InfogainLossParameter)
+ if (has_source()) {
+ source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool InfogainLossParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.InfogainLossParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional string source = 1;
+ case 1: {
+ if (tag == 10) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_source()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->source().data(), this->source().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.InfogainLossParameter.source");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.InfogainLossParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.InfogainLossParameter)
+ return false;
+#undef DO_
+}
+
+void InfogainLossParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.InfogainLossParameter)
+ // optional string source = 1;
+ if (has_source()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->source().data(), this->source().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.InfogainLossParameter.source");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 1, this->source(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.InfogainLossParameter)
+}
+
+::google::protobuf::uint8* InfogainLossParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.InfogainLossParameter)
+ // optional string source = 1;
+ if (has_source()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->source().data(), this->source().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.InfogainLossParameter.source");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 1, this->source(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.InfogainLossParameter)
+ return target;
+}
+
+size_t InfogainLossParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.InfogainLossParameter)
+ size_t total_size = 0;
+
+ // optional string source = 1;
+ if (has_source()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->source());
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void InfogainLossParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.InfogainLossParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const InfogainLossParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const InfogainLossParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.InfogainLossParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.InfogainLossParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void InfogainLossParameter::MergeFrom(const InfogainLossParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.InfogainLossParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void InfogainLossParameter::UnsafeMergeFrom(const InfogainLossParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_source()) {
+ set_has_source();
+ source_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_);
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void InfogainLossParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.InfogainLossParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void InfogainLossParameter::CopyFrom(const InfogainLossParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.InfogainLossParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool InfogainLossParameter::IsInitialized() const {
+
+ return true;
+}
+
+void InfogainLossParameter::Swap(InfogainLossParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void InfogainLossParameter::InternalSwap(InfogainLossParameter* other) {
+ source_.Swap(&other->source_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata InfogainLossParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = InfogainLossParameter_descriptor_;
+ metadata.reflection = InfogainLossParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// InfogainLossParameter
+
+// optional string source = 1;
+bool InfogainLossParameter::has_source() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void InfogainLossParameter::set_has_source() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void InfogainLossParameter::clear_has_source() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void InfogainLossParameter::clear_source() {
+ source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_source();
+}
+const ::std::string& InfogainLossParameter::source() const {
+ // @@protoc_insertion_point(field_get:caffe.InfogainLossParameter.source)
+ return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void InfogainLossParameter::set_source(const ::std::string& value) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.InfogainLossParameter.source)
+}
+void InfogainLossParameter::set_source(const char* value) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.InfogainLossParameter.source)
+}
+void InfogainLossParameter::set_source(const char* value, size_t size) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.InfogainLossParameter.source)
+}
+::std::string* InfogainLossParameter::mutable_source() {
+ set_has_source();
+ // @@protoc_insertion_point(field_mutable:caffe.InfogainLossParameter.source)
+ return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* InfogainLossParameter::release_source() {
+ // @@protoc_insertion_point(field_release:caffe.InfogainLossParameter.source)
+ clear_has_source();
+ return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void InfogainLossParameter::set_allocated_source(::std::string* source) {
+ if (source != NULL) {
+ set_has_source();
+ } else {
+ clear_has_source();
+ }
+ source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source);
+ // @@protoc_insertion_point(field_set_allocated:caffe.InfogainLossParameter.source)
+}
+
+inline const InfogainLossParameter* InfogainLossParameter::internal_default_instance() {
+ return &InfogainLossParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int InnerProductParameter::kNumOutputFieldNumber;
+const int InnerProductParameter::kBiasTermFieldNumber;
+const int InnerProductParameter::kWeightFillerFieldNumber;
+const int InnerProductParameter::kBiasFillerFieldNumber;
+const int InnerProductParameter::kAxisFieldNumber;
+const int InnerProductParameter::kTransposeFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+InnerProductParameter::InnerProductParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.InnerProductParameter)
+}
+
+void InnerProductParameter::InitAsDefaultInstance() {
+ weight_filler_ = const_cast< ::caffe::FillerParameter*>(
+ ::caffe::FillerParameter::internal_default_instance());
+ bias_filler_ = const_cast< ::caffe::FillerParameter*>(
+ ::caffe::FillerParameter::internal_default_instance());
+}
+
+InnerProductParameter::InnerProductParameter(const InnerProductParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.InnerProductParameter)
+}
+
+void InnerProductParameter::SharedCtor() {
+ _cached_size_ = 0;
+ weight_filler_ = NULL;
+ bias_filler_ = NULL;
+ ::memset(&num_output_, 0, reinterpret_cast<char*>(&transpose_) -
+ reinterpret_cast<char*>(&num_output_) + sizeof(transpose_));
+ bias_term_ = true;
+ axis_ = 1;
+}
+
+InnerProductParameter::~InnerProductParameter() {
+ // @@protoc_insertion_point(destructor:caffe.InnerProductParameter)
+ SharedDtor();
+}
+
+void InnerProductParameter::SharedDtor() {
+ if (this != &InnerProductParameter_default_instance_.get()) {
+ delete weight_filler_;
+ delete bias_filler_;
+ }
+}
+
+void InnerProductParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* InnerProductParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return InnerProductParameter_descriptor_;
+}
+
+const InnerProductParameter& InnerProductParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<InnerProductParameter> InnerProductParameter_default_instance_;
+
+InnerProductParameter* InnerProductParameter::New(::google::protobuf::Arena* arena) const {
+ InnerProductParameter* n = new InnerProductParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void InnerProductParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.InnerProductParameter)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(InnerProductParameter, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<InnerProductParameter*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ if (_has_bits_[0 / 32] & 63u) {
+ ZR_(num_output_, transpose_);
+ bias_term_ = true;
+ if (has_weight_filler()) {
+ if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear();
+ }
+ if (has_bias_filler()) {
+ if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
+ }
+ axis_ = 1;
+ }
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool InnerProductParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.InnerProductParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional uint32 num_output = 1;
+ case 1: {
+ if (tag == 8) {
+ set_has_num_output();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &num_output_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_bias_term;
+ break;
+ }
+
+ // optional bool bias_term = 2 [default = true];
+ case 2: {
+ if (tag == 16) {
+ parse_bias_term:
+ set_has_bias_term();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &bias_term_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(26)) goto parse_weight_filler;
+ break;
+ }
+
+ // optional .caffe.FillerParameter weight_filler = 3;
+ case 3: {
+ if (tag == 26) {
+ parse_weight_filler:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_weight_filler()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(34)) goto parse_bias_filler;
+ break;
+ }
+
+ // optional .caffe.FillerParameter bias_filler = 4;
+ case 4: {
+ if (tag == 34) {
+ parse_bias_filler:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_bias_filler()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(40)) goto parse_axis;
+ break;
+ }
+
+ // optional int32 axis = 5 [default = 1];
+ case 5: {
+ if (tag == 40) {
+ parse_axis:
+ set_has_axis();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &axis_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(48)) goto parse_transpose;
+ break;
+ }
+
+ // optional bool transpose = 6 [default = false];
+ case 6: {
+ if (tag == 48) {
+ parse_transpose:
+ set_has_transpose();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &transpose_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.InnerProductParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.InnerProductParameter)
+ return false;
+#undef DO_
+}
+
+void InnerProductParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.InnerProductParameter)
+ // optional uint32 num_output = 1;
+ if (has_num_output()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->num_output(), output);
+ }
+
+ // optional bool bias_term = 2 [default = true];
+ if (has_bias_term()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->bias_term(), output);
+ }
+
+ // optional .caffe.FillerParameter weight_filler = 3;
+ if (has_weight_filler()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 3, *this->weight_filler_, output);
+ }
+
+ // optional .caffe.FillerParameter bias_filler = 4;
+ if (has_bias_filler()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 4, *this->bias_filler_, output);
+ }
+
+ // optional int32 axis = 5 [default = 1];
+ if (has_axis()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(5, this->axis(), output);
+ }
+
+ // optional bool transpose = 6 [default = false];
+ if (has_transpose()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(6, this->transpose(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.InnerProductParameter)
+}
+
+::google::protobuf::uint8* InnerProductParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.InnerProductParameter)
+ // optional uint32 num_output = 1;
+ if (has_num_output()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->num_output(), target);
+ }
+
+ // optional bool bias_term = 2 [default = true];
+ if (has_bias_term()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->bias_term(), target);
+ }
+
+ // optional .caffe.FillerParameter weight_filler = 3;
+ if (has_weight_filler()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 3, *this->weight_filler_, false, target);
+ }
+
+ // optional .caffe.FillerParameter bias_filler = 4;
+ if (has_bias_filler()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 4, *this->bias_filler_, false, target);
+ }
+
+ // optional int32 axis = 5 [default = 1];
+ if (has_axis()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(5, this->axis(), target);
+ }
+
+ // optional bool transpose = 6 [default = false];
+ if (has_transpose()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(6, this->transpose(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.InnerProductParameter)
+ return target;
+}
+
+size_t InnerProductParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.InnerProductParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 63u) {
+ // optional uint32 num_output = 1;
+ if (has_num_output()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->num_output());
+ }
+
+ // optional bool bias_term = 2 [default = true];
+ if (has_bias_term()) {
+ total_size += 1 + 1;
+ }
+
+ // optional .caffe.FillerParameter weight_filler = 3;
+ if (has_weight_filler()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->weight_filler_);
+ }
+
+ // optional .caffe.FillerParameter bias_filler = 4;
+ if (has_bias_filler()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->bias_filler_);
+ }
+
+ // optional int32 axis = 5 [default = 1];
+ if (has_axis()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->axis());
+ }
+
+ // optional bool transpose = 6 [default = false];
+ if (has_transpose()) {
+ total_size += 1 + 1;
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void InnerProductParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.InnerProductParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const InnerProductParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const InnerProductParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.InnerProductParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.InnerProductParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void InnerProductParameter::MergeFrom(const InnerProductParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.InnerProductParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void InnerProductParameter::UnsafeMergeFrom(const InnerProductParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_num_output()) {
+ set_num_output(from.num_output());
+ }
+ if (from.has_bias_term()) {
+ set_bias_term(from.bias_term());
+ }
+ if (from.has_weight_filler()) {
+ mutable_weight_filler()->::caffe::FillerParameter::MergeFrom(from.weight_filler());
+ }
+ if (from.has_bias_filler()) {
+ mutable_bias_filler()->::caffe::FillerParameter::MergeFrom(from.bias_filler());
+ }
+ if (from.has_axis()) {
+ set_axis(from.axis());
+ }
+ if (from.has_transpose()) {
+ set_transpose(from.transpose());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void InnerProductParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.InnerProductParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void InnerProductParameter::CopyFrom(const InnerProductParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.InnerProductParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool InnerProductParameter::IsInitialized() const {
+
+ return true;
+}
+
+void InnerProductParameter::Swap(InnerProductParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void InnerProductParameter::InternalSwap(InnerProductParameter* other) {
+ std::swap(num_output_, other->num_output_);
+ std::swap(bias_term_, other->bias_term_);
+ std::swap(weight_filler_, other->weight_filler_);
+ std::swap(bias_filler_, other->bias_filler_);
+ std::swap(axis_, other->axis_);
+ std::swap(transpose_, other->transpose_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata InnerProductParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = InnerProductParameter_descriptor_;
+ metadata.reflection = InnerProductParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// InnerProductParameter
+
+// optional uint32 num_output = 1;
+bool InnerProductParameter::has_num_output() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void InnerProductParameter::set_has_num_output() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void InnerProductParameter::clear_has_num_output() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void InnerProductParameter::clear_num_output() {
+ num_output_ = 0u;
+ clear_has_num_output();
+}
+::google::protobuf::uint32 InnerProductParameter::num_output() const {
+ // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.num_output)
+ return num_output_;
+}
+void InnerProductParameter::set_num_output(::google::protobuf::uint32 value) {
+ set_has_num_output();
+ num_output_ = value;
+ // @@protoc_insertion_point(field_set:caffe.InnerProductParameter.num_output)
+}
+
+// optional bool bias_term = 2 [default = true];
+bool InnerProductParameter::has_bias_term() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void InnerProductParameter::set_has_bias_term() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void InnerProductParameter::clear_has_bias_term() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void InnerProductParameter::clear_bias_term() {
+ bias_term_ = true;
+ clear_has_bias_term();
+}
+bool InnerProductParameter::bias_term() const {
+ // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.bias_term)
+ return bias_term_;
+}
+void InnerProductParameter::set_bias_term(bool value) {
+ set_has_bias_term();
+ bias_term_ = value;
+ // @@protoc_insertion_point(field_set:caffe.InnerProductParameter.bias_term)
+}
+
+// optional .caffe.FillerParameter weight_filler = 3;
+bool InnerProductParameter::has_weight_filler() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void InnerProductParameter::set_has_weight_filler() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void InnerProductParameter::clear_has_weight_filler() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void InnerProductParameter::clear_weight_filler() {
+ if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear();
+ clear_has_weight_filler();
+}
+const ::caffe::FillerParameter& InnerProductParameter::weight_filler() const {
+ // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.weight_filler)
+ return weight_filler_ != NULL ? *weight_filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+::caffe::FillerParameter* InnerProductParameter::mutable_weight_filler() {
+ set_has_weight_filler();
+ if (weight_filler_ == NULL) {
+ weight_filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.InnerProductParameter.weight_filler)
+ return weight_filler_;
+}
+::caffe::FillerParameter* InnerProductParameter::release_weight_filler() {
+ // @@protoc_insertion_point(field_release:caffe.InnerProductParameter.weight_filler)
+ clear_has_weight_filler();
+ ::caffe::FillerParameter* temp = weight_filler_;
+ weight_filler_ = NULL;
+ return temp;
+}
+void InnerProductParameter::set_allocated_weight_filler(::caffe::FillerParameter* weight_filler) {
+ delete weight_filler_;
+ weight_filler_ = weight_filler;
+ if (weight_filler) {
+ set_has_weight_filler();
+ } else {
+ clear_has_weight_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.InnerProductParameter.weight_filler)
+}
+
+// optional .caffe.FillerParameter bias_filler = 4;
+bool InnerProductParameter::has_bias_filler() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+void InnerProductParameter::set_has_bias_filler() {
+ _has_bits_[0] |= 0x00000008u;
+}
+void InnerProductParameter::clear_has_bias_filler() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+void InnerProductParameter::clear_bias_filler() {
+ if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
+ clear_has_bias_filler();
+}
+const ::caffe::FillerParameter& InnerProductParameter::bias_filler() const {
+ // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.bias_filler)
+ return bias_filler_ != NULL ? *bias_filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+::caffe::FillerParameter* InnerProductParameter::mutable_bias_filler() {
+ set_has_bias_filler();
+ if (bias_filler_ == NULL) {
+ bias_filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.InnerProductParameter.bias_filler)
+ return bias_filler_;
+}
+::caffe::FillerParameter* InnerProductParameter::release_bias_filler() {
+ // @@protoc_insertion_point(field_release:caffe.InnerProductParameter.bias_filler)
+ clear_has_bias_filler();
+ ::caffe::FillerParameter* temp = bias_filler_;
+ bias_filler_ = NULL;
+ return temp;
+}
+void InnerProductParameter::set_allocated_bias_filler(::caffe::FillerParameter* bias_filler) {
+ delete bias_filler_;
+ bias_filler_ = bias_filler;
+ if (bias_filler) {
+ set_has_bias_filler();
+ } else {
+ clear_has_bias_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.InnerProductParameter.bias_filler)
+}
+
+// optional int32 axis = 5 [default = 1];
+bool InnerProductParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+void InnerProductParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000010u;
+}
+void InnerProductParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+void InnerProductParameter::clear_axis() {
+ axis_ = 1;
+ clear_has_axis();
+}
+::google::protobuf::int32 InnerProductParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.axis)
+ return axis_;
+}
+void InnerProductParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.InnerProductParameter.axis)
+}
+
+// optional bool transpose = 6 [default = false];
+bool InnerProductParameter::has_transpose() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+void InnerProductParameter::set_has_transpose() {
+ _has_bits_[0] |= 0x00000020u;
+}
+void InnerProductParameter::clear_has_transpose() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+void InnerProductParameter::clear_transpose() {
+ transpose_ = false;
+ clear_has_transpose();
+}
+bool InnerProductParameter::transpose() const {
+ // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.transpose)
+ return transpose_;
+}
+void InnerProductParameter::set_transpose(bool value) {
+ set_has_transpose();
+ transpose_ = value;
+ // @@protoc_insertion_point(field_set:caffe.InnerProductParameter.transpose)
+}
+
+inline const InnerProductParameter* InnerProductParameter::internal_default_instance() {
+ return &InnerProductParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int InputParameter::kShapeFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+InputParameter::InputParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.InputParameter)
+}
+
+void InputParameter::InitAsDefaultInstance() {
+}
+
+InputParameter::InputParameter(const InputParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.InputParameter)
+}
+
+void InputParameter::SharedCtor() {
+ _cached_size_ = 0;
+}
+
+InputParameter::~InputParameter() {
+ // @@protoc_insertion_point(destructor:caffe.InputParameter)
+ SharedDtor();
+}
+
+void InputParameter::SharedDtor() {
+}
+
+void InputParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* InputParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return InputParameter_descriptor_;
+}
+
+const InputParameter& InputParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<InputParameter> InputParameter_default_instance_;
+
+InputParameter* InputParameter::New(::google::protobuf::Arena* arena) const {
+ InputParameter* n = new InputParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void InputParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.InputParameter)
+ shape_.Clear();
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool InputParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.InputParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // repeated .caffe.BlobShape shape = 1;
+ case 1: {
+ if (tag == 10) {
+ DO_(input->IncrementRecursionDepth());
+ parse_loop_shape:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
+ input, add_shape()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(10)) goto parse_loop_shape;
+ input->UnsafeDecrementRecursionDepth();
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.InputParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.InputParameter)
+ return false;
+#undef DO_
+}
+
+void InputParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.InputParameter)
+ // repeated .caffe.BlobShape shape = 1;
+ for (unsigned int i = 0, n = this->shape_size(); i < n; i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 1, this->shape(i), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.InputParameter)
+}
+
+::google::protobuf::uint8* InputParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.InputParameter)
+ // repeated .caffe.BlobShape shape = 1;
+ for (unsigned int i = 0, n = this->shape_size(); i < n; i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 1, this->shape(i), false, target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.InputParameter)
+ return target;
+}
+
+size_t InputParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.InputParameter)
+ size_t total_size = 0;
+
+ // repeated .caffe.BlobShape shape = 1;
+ {
+ unsigned int count = this->shape_size();
+ total_size += 1UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->shape(i));
+ }
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void InputParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.InputParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const InputParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const InputParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.InputParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.InputParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void InputParameter::MergeFrom(const InputParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.InputParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void InputParameter::UnsafeMergeFrom(const InputParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ shape_.MergeFrom(from.shape_);
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void InputParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.InputParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void InputParameter::CopyFrom(const InputParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.InputParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool InputParameter::IsInitialized() const {
+
+ return true;
+}
+
+void InputParameter::Swap(InputParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void InputParameter::InternalSwap(InputParameter* other) {
+ shape_.UnsafeArenaSwap(&other->shape_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata InputParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = InputParameter_descriptor_;
+ metadata.reflection = InputParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// InputParameter
+
+// repeated .caffe.BlobShape shape = 1;
+int InputParameter::shape_size() const {
+ return shape_.size();
+}
+void InputParameter::clear_shape() {
+ shape_.Clear();
+}
+const ::caffe::BlobShape& InputParameter::shape(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.InputParameter.shape)
+ return shape_.Get(index);
+}
+::caffe::BlobShape* InputParameter::mutable_shape(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.InputParameter.shape)
+ return shape_.Mutable(index);
+}
+::caffe::BlobShape* InputParameter::add_shape() {
+ // @@protoc_insertion_point(field_add:caffe.InputParameter.shape)
+ return shape_.Add();
+}
+::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >*
+InputParameter::mutable_shape() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.InputParameter.shape)
+ return &shape_;
+}
+const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >&
+InputParameter::shape() const {
+ // @@protoc_insertion_point(field_list:caffe.InputParameter.shape)
+ return shape_;
+}
+
+inline const InputParameter* InputParameter::internal_default_instance() {
+ return &InputParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int LogParameter::kBaseFieldNumber;
+const int LogParameter::kScaleFieldNumber;
+const int LogParameter::kShiftFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+LogParameter::LogParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.LogParameter)
+}
+
+void LogParameter::InitAsDefaultInstance() {
+}
+
+LogParameter::LogParameter(const LogParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.LogParameter)
+}
+
+void LogParameter::SharedCtor() {
+ _cached_size_ = 0;
+ shift_ = 0;
+ base_ = -1;
+ scale_ = 1;
+}
+
+LogParameter::~LogParameter() {
+ // @@protoc_insertion_point(destructor:caffe.LogParameter)
+ SharedDtor();
+}
+
+void LogParameter::SharedDtor() {
+}
+
+void LogParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* LogParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return LogParameter_descriptor_;
+}
+
+const LogParameter& LogParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<LogParameter> LogParameter_default_instance_;
+
+LogParameter* LogParameter::New(::google::protobuf::Arena* arena) const {
+ LogParameter* n = new LogParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void LogParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.LogParameter)
+ if (_has_bits_[0 / 32] & 7u) {
+ base_ = -1;
+ scale_ = 1;
+ shift_ = 0;
+ }
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool LogParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.LogParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional float base = 1 [default = -1];
+ case 1: {
+ if (tag == 13) {
+ set_has_base();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &base_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(21)) goto parse_scale;
+ break;
+ }
+
+ // optional float scale = 2 [default = 1];
+ case 2: {
+ if (tag == 21) {
+ parse_scale:
+ set_has_scale();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &scale_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(29)) goto parse_shift;
+ break;
+ }
+
+ // optional float shift = 3 [default = 0];
+ case 3: {
+ if (tag == 29) {
+ parse_shift:
+ set_has_shift();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &shift_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.LogParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.LogParameter)
+ return false;
+#undef DO_
+}
+
+void LogParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.LogParameter)
+ // optional float base = 1 [default = -1];
+ if (has_base()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->base(), output);
+ }
+
+ // optional float scale = 2 [default = 1];
+ if (has_scale()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->scale(), output);
+ }
+
+ // optional float shift = 3 [default = 0];
+ if (has_shift()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->shift(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.LogParameter)
+}
+
+::google::protobuf::uint8* LogParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.LogParameter)
+ // optional float base = 1 [default = -1];
+ if (has_base()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->base(), target);
+ }
+
+ // optional float scale = 2 [default = 1];
+ if (has_scale()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->scale(), target);
+ }
+
+ // optional float shift = 3 [default = 0];
+ if (has_shift()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->shift(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.LogParameter)
+ return target;
+}
+
+size_t LogParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.LogParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 7u) {
+ // optional float base = 1 [default = -1];
+ if (has_base()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float scale = 2 [default = 1];
+ if (has_scale()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float shift = 3 [default = 0];
+ if (has_shift()) {
+ total_size += 1 + 4;
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void LogParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.LogParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const LogParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const LogParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.LogParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.LogParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void LogParameter::MergeFrom(const LogParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.LogParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void LogParameter::UnsafeMergeFrom(const LogParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_base()) {
+ set_base(from.base());
+ }
+ if (from.has_scale()) {
+ set_scale(from.scale());
+ }
+ if (from.has_shift()) {
+ set_shift(from.shift());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void LogParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.LogParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void LogParameter::CopyFrom(const LogParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.LogParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool LogParameter::IsInitialized() const {
+
+ return true;
+}
+
+void LogParameter::Swap(LogParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void LogParameter::InternalSwap(LogParameter* other) {
+ std::swap(base_, other->base_);
+ std::swap(scale_, other->scale_);
+ std::swap(shift_, other->shift_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata LogParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = LogParameter_descriptor_;
+ metadata.reflection = LogParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// LogParameter
+
+// optional float base = 1 [default = -1];
+bool LogParameter::has_base() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void LogParameter::set_has_base() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void LogParameter::clear_has_base() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void LogParameter::clear_base() {
+ base_ = -1;
+ clear_has_base();
+}
+float LogParameter::base() const {
+ // @@protoc_insertion_point(field_get:caffe.LogParameter.base)
+ return base_;
+}
+void LogParameter::set_base(float value) {
+ set_has_base();
+ base_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LogParameter.base)
+}
+
+// optional float scale = 2 [default = 1];
+bool LogParameter::has_scale() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void LogParameter::set_has_scale() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void LogParameter::clear_has_scale() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void LogParameter::clear_scale() {
+ scale_ = 1;
+ clear_has_scale();
+}
+float LogParameter::scale() const {
+ // @@protoc_insertion_point(field_get:caffe.LogParameter.scale)
+ return scale_;
+}
+void LogParameter::set_scale(float value) {
+ set_has_scale();
+ scale_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LogParameter.scale)
+}
+
+// optional float shift = 3 [default = 0];
+bool LogParameter::has_shift() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void LogParameter::set_has_shift() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void LogParameter::clear_has_shift() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void LogParameter::clear_shift() {
+ shift_ = 0;
+ clear_has_shift();
+}
+float LogParameter::shift() const {
+ // @@protoc_insertion_point(field_get:caffe.LogParameter.shift)
+ return shift_;
+}
+void LogParameter::set_shift(float value) {
+ set_has_shift();
+ shift_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LogParameter.shift)
+}
+
+inline const LogParameter* LogParameter::internal_default_instance() {
+ return &LogParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+const ::google::protobuf::EnumDescriptor* LRNParameter_NormRegion_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return LRNParameter_NormRegion_descriptor_;
+}
+bool LRNParameter_NormRegion_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const LRNParameter_NormRegion LRNParameter::ACROSS_CHANNELS;
+const LRNParameter_NormRegion LRNParameter::WITHIN_CHANNEL;
+const LRNParameter_NormRegion LRNParameter::NormRegion_MIN;
+const LRNParameter_NormRegion LRNParameter::NormRegion_MAX;
+const int LRNParameter::NormRegion_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+const ::google::protobuf::EnumDescriptor* LRNParameter_Engine_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return LRNParameter_Engine_descriptor_;
+}
+bool LRNParameter_Engine_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ case 2:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const LRNParameter_Engine LRNParameter::DEFAULT;
+const LRNParameter_Engine LRNParameter::CAFFE;
+const LRNParameter_Engine LRNParameter::CUDNN;
+const LRNParameter_Engine LRNParameter::Engine_MIN;
+const LRNParameter_Engine LRNParameter::Engine_MAX;
+const int LRNParameter::Engine_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int LRNParameter::kLocalSizeFieldNumber;
+const int LRNParameter::kAlphaFieldNumber;
+const int LRNParameter::kBetaFieldNumber;
+const int LRNParameter::kNormRegionFieldNumber;
+const int LRNParameter::kKFieldNumber;
+const int LRNParameter::kEngineFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+LRNParameter::LRNParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.LRNParameter)
+}
+
+void LRNParameter::InitAsDefaultInstance() {
+}
+
+LRNParameter::LRNParameter(const LRNParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.LRNParameter)
+}
+
+void LRNParameter::SharedCtor() {
+ _cached_size_ = 0;
+ ::memset(&norm_region_, 0, reinterpret_cast<char*>(&engine_) -
+ reinterpret_cast<char*>(&norm_region_) + sizeof(engine_));
+ local_size_ = 5u;
+ alpha_ = 1;
+ beta_ = 0.75f;
+ k_ = 1;
+}
+
+LRNParameter::~LRNParameter() {
+ // @@protoc_insertion_point(destructor:caffe.LRNParameter)
+ SharedDtor();
+}
+
+void LRNParameter::SharedDtor() {
+}
+
+void LRNParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* LRNParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return LRNParameter_descriptor_;
+}
+
+const LRNParameter& LRNParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<LRNParameter> LRNParameter_default_instance_;
+
+LRNParameter* LRNParameter::New(::google::protobuf::Arena* arena) const {
+ LRNParameter* n = new LRNParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void LRNParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.LRNParameter)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(LRNParameter, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<LRNParameter*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ if (_has_bits_[0 / 32] & 63u) {
+ ZR_(norm_region_, engine_);
+ local_size_ = 5u;
+ alpha_ = 1;
+ beta_ = 0.75f;
+ k_ = 1;
+ }
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool LRNParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.LRNParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional uint32 local_size = 1 [default = 5];
+ case 1: {
+ if (tag == 8) {
+ set_has_local_size();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &local_size_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(21)) goto parse_alpha;
+ break;
+ }
+
+ // optional float alpha = 2 [default = 1];
+ case 2: {
+ if (tag == 21) {
+ parse_alpha:
+ set_has_alpha();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &alpha_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(29)) goto parse_beta;
+ break;
+ }
+
+ // optional float beta = 3 [default = 0.75];
+ case 3: {
+ if (tag == 29) {
+ parse_beta:
+ set_has_beta();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &beta_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(32)) goto parse_norm_region;
+ break;
+ }
+
+ // optional .caffe.LRNParameter.NormRegion norm_region = 4 [default = ACROSS_CHANNELS];
+ case 4: {
+ if (tag == 32) {
+ parse_norm_region:
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::LRNParameter_NormRegion_IsValid(value)) {
+ set_norm_region(static_cast< ::caffe::LRNParameter_NormRegion >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(4, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(45)) goto parse_k;
+ break;
+ }
+
+ // optional float k = 5 [default = 1];
+ case 5: {
+ if (tag == 45) {
+ parse_k:
+ set_has_k();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &k_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(48)) goto parse_engine;
+ break;
+ }
+
+ // optional .caffe.LRNParameter.Engine engine = 6 [default = DEFAULT];
+ case 6: {
+ if (tag == 48) {
+ parse_engine:
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::LRNParameter_Engine_IsValid(value)) {
+ set_engine(static_cast< ::caffe::LRNParameter_Engine >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(6, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.LRNParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.LRNParameter)
+ return false;
+#undef DO_
+}
+
+void LRNParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.LRNParameter)
+ // optional uint32 local_size = 1 [default = 5];
+ if (has_local_size()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->local_size(), output);
+ }
+
+ // optional float alpha = 2 [default = 1];
+ if (has_alpha()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->alpha(), output);
+ }
+
+ // optional float beta = 3 [default = 0.75];
+ if (has_beta()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->beta(), output);
+ }
+
+ // optional .caffe.LRNParameter.NormRegion norm_region = 4 [default = ACROSS_CHANNELS];
+ if (has_norm_region()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 4, this->norm_region(), output);
+ }
+
+ // optional float k = 5 [default = 1];
+ if (has_k()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(5, this->k(), output);
+ }
+
+ // optional .caffe.LRNParameter.Engine engine = 6 [default = DEFAULT];
+ if (has_engine()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 6, this->engine(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.LRNParameter)
+}
+
+::google::protobuf::uint8* LRNParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.LRNParameter)
+ // optional uint32 local_size = 1 [default = 5];
+ if (has_local_size()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->local_size(), target);
+ }
+
+ // optional float alpha = 2 [default = 1];
+ if (has_alpha()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->alpha(), target);
+ }
+
+ // optional float beta = 3 [default = 0.75];
+ if (has_beta()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->beta(), target);
+ }
+
+ // optional .caffe.LRNParameter.NormRegion norm_region = 4 [default = ACROSS_CHANNELS];
+ if (has_norm_region()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 4, this->norm_region(), target);
+ }
+
+ // optional float k = 5 [default = 1];
+ if (has_k()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(5, this->k(), target);
+ }
+
+ // optional .caffe.LRNParameter.Engine engine = 6 [default = DEFAULT];
+ if (has_engine()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 6, this->engine(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.LRNParameter)
+ return target;
+}
+
+size_t LRNParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.LRNParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 63u) {
+ // optional uint32 local_size = 1 [default = 5];
+ if (has_local_size()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->local_size());
+ }
+
+ // optional float alpha = 2 [default = 1];
+ if (has_alpha()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float beta = 3 [default = 0.75];
+ if (has_beta()) {
+ total_size += 1 + 4;
+ }
+
+ // optional .caffe.LRNParameter.NormRegion norm_region = 4 [default = ACROSS_CHANNELS];
+ if (has_norm_region()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->norm_region());
+ }
+
+ // optional float k = 5 [default = 1];
+ if (has_k()) {
+ total_size += 1 + 4;
+ }
+
+ // optional .caffe.LRNParameter.Engine engine = 6 [default = DEFAULT];
+ if (has_engine()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->engine());
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void LRNParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.LRNParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const LRNParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const LRNParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.LRNParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.LRNParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void LRNParameter::MergeFrom(const LRNParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.LRNParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void LRNParameter::UnsafeMergeFrom(const LRNParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_local_size()) {
+ set_local_size(from.local_size());
+ }
+ if (from.has_alpha()) {
+ set_alpha(from.alpha());
+ }
+ if (from.has_beta()) {
+ set_beta(from.beta());
+ }
+ if (from.has_norm_region()) {
+ set_norm_region(from.norm_region());
+ }
+ if (from.has_k()) {
+ set_k(from.k());
+ }
+ if (from.has_engine()) {
+ set_engine(from.engine());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void LRNParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.LRNParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void LRNParameter::CopyFrom(const LRNParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.LRNParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool LRNParameter::IsInitialized() const {
+
+ return true;
+}
+
+void LRNParameter::Swap(LRNParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void LRNParameter::InternalSwap(LRNParameter* other) {
+ std::swap(local_size_, other->local_size_);
+ std::swap(alpha_, other->alpha_);
+ std::swap(beta_, other->beta_);
+ std::swap(norm_region_, other->norm_region_);
+ std::swap(k_, other->k_);
+ std::swap(engine_, other->engine_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata LRNParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = LRNParameter_descriptor_;
+ metadata.reflection = LRNParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// LRNParameter
+
+// optional uint32 local_size = 1 [default = 5];
+bool LRNParameter::has_local_size() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void LRNParameter::set_has_local_size() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void LRNParameter::clear_has_local_size() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void LRNParameter::clear_local_size() {
+ local_size_ = 5u;
+ clear_has_local_size();
+}
+::google::protobuf::uint32 LRNParameter::local_size() const {
+ // @@protoc_insertion_point(field_get:caffe.LRNParameter.local_size)
+ return local_size_;
+}
+void LRNParameter::set_local_size(::google::protobuf::uint32 value) {
+ set_has_local_size();
+ local_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LRNParameter.local_size)
+}
+
+// optional float alpha = 2 [default = 1];
+bool LRNParameter::has_alpha() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void LRNParameter::set_has_alpha() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void LRNParameter::clear_has_alpha() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void LRNParameter::clear_alpha() {
+ alpha_ = 1;
+ clear_has_alpha();
+}
+float LRNParameter::alpha() const {
+ // @@protoc_insertion_point(field_get:caffe.LRNParameter.alpha)
+ return alpha_;
+}
+void LRNParameter::set_alpha(float value) {
+ set_has_alpha();
+ alpha_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LRNParameter.alpha)
+}
+
+// optional float beta = 3 [default = 0.75];
+bool LRNParameter::has_beta() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void LRNParameter::set_has_beta() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void LRNParameter::clear_has_beta() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void LRNParameter::clear_beta() {
+ beta_ = 0.75f;
+ clear_has_beta();
+}
+float LRNParameter::beta() const {
+ // @@protoc_insertion_point(field_get:caffe.LRNParameter.beta)
+ return beta_;
+}
+void LRNParameter::set_beta(float value) {
+ set_has_beta();
+ beta_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LRNParameter.beta)
+}
+
+// optional .caffe.LRNParameter.NormRegion norm_region = 4 [default = ACROSS_CHANNELS];
+bool LRNParameter::has_norm_region() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+void LRNParameter::set_has_norm_region() {
+ _has_bits_[0] |= 0x00000008u;
+}
+void LRNParameter::clear_has_norm_region() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+void LRNParameter::clear_norm_region() {
+ norm_region_ = 0;
+ clear_has_norm_region();
+}
+::caffe::LRNParameter_NormRegion LRNParameter::norm_region() const {
+ // @@protoc_insertion_point(field_get:caffe.LRNParameter.norm_region)
+ return static_cast< ::caffe::LRNParameter_NormRegion >(norm_region_);
+}
+void LRNParameter::set_norm_region(::caffe::LRNParameter_NormRegion value) {
+ assert(::caffe::LRNParameter_NormRegion_IsValid(value));
+ set_has_norm_region();
+ norm_region_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LRNParameter.norm_region)
+}
+
+// optional float k = 5 [default = 1];
+bool LRNParameter::has_k() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+void LRNParameter::set_has_k() {
+ _has_bits_[0] |= 0x00000010u;
+}
+void LRNParameter::clear_has_k() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+void LRNParameter::clear_k() {
+ k_ = 1;
+ clear_has_k();
+}
+float LRNParameter::k() const {
+ // @@protoc_insertion_point(field_get:caffe.LRNParameter.k)
+ return k_;
+}
+void LRNParameter::set_k(float value) {
+ set_has_k();
+ k_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LRNParameter.k)
+}
+
+// optional .caffe.LRNParameter.Engine engine = 6 [default = DEFAULT];
+bool LRNParameter::has_engine() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+void LRNParameter::set_has_engine() {
+ _has_bits_[0] |= 0x00000020u;
+}
+void LRNParameter::clear_has_engine() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+void LRNParameter::clear_engine() {
+ engine_ = 0;
+ clear_has_engine();
+}
+::caffe::LRNParameter_Engine LRNParameter::engine() const {
+ // @@protoc_insertion_point(field_get:caffe.LRNParameter.engine)
+ return static_cast< ::caffe::LRNParameter_Engine >(engine_);
+}
+void LRNParameter::set_engine(::caffe::LRNParameter_Engine value) {
+ assert(::caffe::LRNParameter_Engine_IsValid(value));
+ set_has_engine();
+ engine_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LRNParameter.engine)
+}
+
+inline const LRNParameter* LRNParameter::internal_default_instance() {
+ return &LRNParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int MemoryDataParameter::kBatchSizeFieldNumber;
+const int MemoryDataParameter::kChannelsFieldNumber;
+const int MemoryDataParameter::kHeightFieldNumber;
+const int MemoryDataParameter::kWidthFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+MemoryDataParameter::MemoryDataParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.MemoryDataParameter)
+}
+
+void MemoryDataParameter::InitAsDefaultInstance() {
+}
+
+MemoryDataParameter::MemoryDataParameter(const MemoryDataParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.MemoryDataParameter)
+}
+
+void MemoryDataParameter::SharedCtor() {
+ _cached_size_ = 0;
+ ::memset(&batch_size_, 0, reinterpret_cast<char*>(&width_) -
+ reinterpret_cast<char*>(&batch_size_) + sizeof(width_));
+}
+
+MemoryDataParameter::~MemoryDataParameter() {
+ // @@protoc_insertion_point(destructor:caffe.MemoryDataParameter)
+ SharedDtor();
+}
+
+void MemoryDataParameter::SharedDtor() {
+}
+
+void MemoryDataParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* MemoryDataParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return MemoryDataParameter_descriptor_;
+}
+
+const MemoryDataParameter& MemoryDataParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<MemoryDataParameter> MemoryDataParameter_default_instance_;
+
+MemoryDataParameter* MemoryDataParameter::New(::google::protobuf::Arena* arena) const {
+ MemoryDataParameter* n = new MemoryDataParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void MemoryDataParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.MemoryDataParameter)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(MemoryDataParameter, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<MemoryDataParameter*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ ZR_(batch_size_, width_);
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool MemoryDataParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.MemoryDataParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional uint32 batch_size = 1;
+ case 1: {
+ if (tag == 8) {
+ set_has_batch_size();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &batch_size_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_channels;
+ break;
+ }
+
+ // optional uint32 channels = 2;
+ case 2: {
+ if (tag == 16) {
+ parse_channels:
+ set_has_channels();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &channels_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(24)) goto parse_height;
+ break;
+ }
+
+ // optional uint32 height = 3;
+ case 3: {
+ if (tag == 24) {
+ parse_height:
+ set_has_height();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &height_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(32)) goto parse_width;
+ break;
+ }
+
+ // optional uint32 width = 4;
+ case 4: {
+ if (tag == 32) {
+ parse_width:
+ set_has_width();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &width_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.MemoryDataParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.MemoryDataParameter)
+ return false;
+#undef DO_
+}
+
+void MemoryDataParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.MemoryDataParameter)
+ // optional uint32 batch_size = 1;
+ if (has_batch_size()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->batch_size(), output);
+ }
+
+ // optional uint32 channels = 2;
+ if (has_channels()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(2, this->channels(), output);
+ }
+
+ // optional uint32 height = 3;
+ if (has_height()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(3, this->height(), output);
+ }
+
+ // optional uint32 width = 4;
+ if (has_width()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(4, this->width(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.MemoryDataParameter)
+}
+
+::google::protobuf::uint8* MemoryDataParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.MemoryDataParameter)
+ // optional uint32 batch_size = 1;
+ if (has_batch_size()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->batch_size(), target);
+ }
+
+ // optional uint32 channels = 2;
+ if (has_channels()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(2, this->channels(), target);
+ }
+
+ // optional uint32 height = 3;
+ if (has_height()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(3, this->height(), target);
+ }
+
+ // optional uint32 width = 4;
+ if (has_width()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(4, this->width(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.MemoryDataParameter)
+ return target;
+}
+
+size_t MemoryDataParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.MemoryDataParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 15u) {
+ // optional uint32 batch_size = 1;
+ if (has_batch_size()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->batch_size());
+ }
+
+ // optional uint32 channels = 2;
+ if (has_channels()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->channels());
+ }
+
+ // optional uint32 height = 3;
+ if (has_height()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->height());
+ }
+
+ // optional uint32 width = 4;
+ if (has_width()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->width());
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void MemoryDataParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.MemoryDataParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const MemoryDataParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const MemoryDataParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.MemoryDataParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.MemoryDataParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void MemoryDataParameter::MergeFrom(const MemoryDataParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.MemoryDataParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void MemoryDataParameter::UnsafeMergeFrom(const MemoryDataParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_batch_size()) {
+ set_batch_size(from.batch_size());
+ }
+ if (from.has_channels()) {
+ set_channels(from.channels());
+ }
+ if (from.has_height()) {
+ set_height(from.height());
+ }
+ if (from.has_width()) {
+ set_width(from.width());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void MemoryDataParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.MemoryDataParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void MemoryDataParameter::CopyFrom(const MemoryDataParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.MemoryDataParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool MemoryDataParameter::IsInitialized() const {
+
+ return true;
+}
+
+void MemoryDataParameter::Swap(MemoryDataParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void MemoryDataParameter::InternalSwap(MemoryDataParameter* other) {
+ std::swap(batch_size_, other->batch_size_);
+ std::swap(channels_, other->channels_);
+ std::swap(height_, other->height_);
+ std::swap(width_, other->width_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata MemoryDataParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = MemoryDataParameter_descriptor_;
+ metadata.reflection = MemoryDataParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// MemoryDataParameter
+
+// optional uint32 batch_size = 1;
+bool MemoryDataParameter::has_batch_size() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void MemoryDataParameter::set_has_batch_size() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void MemoryDataParameter::clear_has_batch_size() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void MemoryDataParameter::clear_batch_size() {
+ batch_size_ = 0u;
+ clear_has_batch_size();
+}
+::google::protobuf::uint32 MemoryDataParameter::batch_size() const {
+ // @@protoc_insertion_point(field_get:caffe.MemoryDataParameter.batch_size)
+ return batch_size_;
+}
+void MemoryDataParameter::set_batch_size(::google::protobuf::uint32 value) {
+ set_has_batch_size();
+ batch_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.MemoryDataParameter.batch_size)
+}
+
+// optional uint32 channels = 2;
+bool MemoryDataParameter::has_channels() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void MemoryDataParameter::set_has_channels() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void MemoryDataParameter::clear_has_channels() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void MemoryDataParameter::clear_channels() {
+ channels_ = 0u;
+ clear_has_channels();
+}
+::google::protobuf::uint32 MemoryDataParameter::channels() const {
+ // @@protoc_insertion_point(field_get:caffe.MemoryDataParameter.channels)
+ return channels_;
+}
+void MemoryDataParameter::set_channels(::google::protobuf::uint32 value) {
+ set_has_channels();
+ channels_ = value;
+ // @@protoc_insertion_point(field_set:caffe.MemoryDataParameter.channels)
+}
+
+// optional uint32 height = 3;
+bool MemoryDataParameter::has_height() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void MemoryDataParameter::set_has_height() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void MemoryDataParameter::clear_has_height() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void MemoryDataParameter::clear_height() {
+ height_ = 0u;
+ clear_has_height();
+}
+::google::protobuf::uint32 MemoryDataParameter::height() const {
+ // @@protoc_insertion_point(field_get:caffe.MemoryDataParameter.height)
+ return height_;
+}
+void MemoryDataParameter::set_height(::google::protobuf::uint32 value) {
+ set_has_height();
+ height_ = value;
+ // @@protoc_insertion_point(field_set:caffe.MemoryDataParameter.height)
+}
+
+// optional uint32 width = 4;
+bool MemoryDataParameter::has_width() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+void MemoryDataParameter::set_has_width() {
+ _has_bits_[0] |= 0x00000008u;
+}
+void MemoryDataParameter::clear_has_width() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+void MemoryDataParameter::clear_width() {
+ width_ = 0u;
+ clear_has_width();
+}
+::google::protobuf::uint32 MemoryDataParameter::width() const {
+ // @@protoc_insertion_point(field_get:caffe.MemoryDataParameter.width)
+ return width_;
+}
+void MemoryDataParameter::set_width(::google::protobuf::uint32 value) {
+ set_has_width();
+ width_ = value;
+ // @@protoc_insertion_point(field_set:caffe.MemoryDataParameter.width)
+}
+
+inline const MemoryDataParameter* MemoryDataParameter::internal_default_instance() {
+ return &MemoryDataParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int MVNParameter::kNormalizeVarianceFieldNumber;
+const int MVNParameter::kAcrossChannelsFieldNumber;
+const int MVNParameter::kEpsFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+MVNParameter::MVNParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.MVNParameter)
+}
+
+void MVNParameter::InitAsDefaultInstance() {
+}
+
+MVNParameter::MVNParameter(const MVNParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.MVNParameter)
+}
+
+void MVNParameter::SharedCtor() {
+ _cached_size_ = 0;
+ across_channels_ = false;
+ normalize_variance_ = true;
+ eps_ = 1e-09f;
+}
+
+MVNParameter::~MVNParameter() {
+ // @@protoc_insertion_point(destructor:caffe.MVNParameter)
+ SharedDtor();
+}
+
+void MVNParameter::SharedDtor() {
+}
+
+void MVNParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* MVNParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return MVNParameter_descriptor_;
+}
+
+const MVNParameter& MVNParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<MVNParameter> MVNParameter_default_instance_;
+
+MVNParameter* MVNParameter::New(::google::protobuf::Arena* arena) const {
+ MVNParameter* n = new MVNParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void MVNParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.MVNParameter)
+ if (_has_bits_[0 / 32] & 7u) {
+ normalize_variance_ = true;
+ across_channels_ = false;
+ eps_ = 1e-09f;
+ }
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool MVNParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.MVNParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional bool normalize_variance = 1 [default = true];
+ case 1: {
+ if (tag == 8) {
+ set_has_normalize_variance();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &normalize_variance_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_across_channels;
+ break;
+ }
+
+ // optional bool across_channels = 2 [default = false];
+ case 2: {
+ if (tag == 16) {
+ parse_across_channels:
+ set_has_across_channels();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &across_channels_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(29)) goto parse_eps;
+ break;
+ }
+
+ // optional float eps = 3 [default = 1e-09];
+ case 3: {
+ if (tag == 29) {
+ parse_eps:
+ set_has_eps();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &eps_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.MVNParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.MVNParameter)
+ return false;
+#undef DO_
+}
+
+void MVNParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.MVNParameter)
+ // optional bool normalize_variance = 1 [default = true];
+ if (has_normalize_variance()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(1, this->normalize_variance(), output);
+ }
+
+ // optional bool across_channels = 2 [default = false];
+ if (has_across_channels()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->across_channels(), output);
+ }
+
+ // optional float eps = 3 [default = 1e-09];
+ if (has_eps()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->eps(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.MVNParameter)
+}
+
+::google::protobuf::uint8* MVNParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.MVNParameter)
+ // optional bool normalize_variance = 1 [default = true];
+ if (has_normalize_variance()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->normalize_variance(), target);
+ }
+
+ // optional bool across_channels = 2 [default = false];
+ if (has_across_channels()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->across_channels(), target);
+ }
+
+ // optional float eps = 3 [default = 1e-09];
+ if (has_eps()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->eps(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.MVNParameter)
+ return target;
+}
+
+size_t MVNParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.MVNParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 7u) {
+ // optional bool normalize_variance = 1 [default = true];
+ if (has_normalize_variance()) {
+ total_size += 1 + 1;
+ }
+
+ // optional bool across_channels = 2 [default = false];
+ if (has_across_channels()) {
+ total_size += 1 + 1;
+ }
+
+ // optional float eps = 3 [default = 1e-09];
+ if (has_eps()) {
+ total_size += 1 + 4;
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void MVNParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.MVNParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const MVNParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const MVNParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.MVNParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.MVNParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void MVNParameter::MergeFrom(const MVNParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.MVNParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void MVNParameter::UnsafeMergeFrom(const MVNParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_normalize_variance()) {
+ set_normalize_variance(from.normalize_variance());
+ }
+ if (from.has_across_channels()) {
+ set_across_channels(from.across_channels());
+ }
+ if (from.has_eps()) {
+ set_eps(from.eps());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void MVNParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.MVNParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void MVNParameter::CopyFrom(const MVNParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.MVNParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool MVNParameter::IsInitialized() const {
+
+ return true;
+}
+
+void MVNParameter::Swap(MVNParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void MVNParameter::InternalSwap(MVNParameter* other) {
+ std::swap(normalize_variance_, other->normalize_variance_);
+ std::swap(across_channels_, other->across_channels_);
+ std::swap(eps_, other->eps_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata MVNParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = MVNParameter_descriptor_;
+ metadata.reflection = MVNParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// MVNParameter
+
+// optional bool normalize_variance = 1 [default = true];
+bool MVNParameter::has_normalize_variance() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void MVNParameter::set_has_normalize_variance() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void MVNParameter::clear_has_normalize_variance() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void MVNParameter::clear_normalize_variance() {
+ normalize_variance_ = true;
+ clear_has_normalize_variance();
+}
+bool MVNParameter::normalize_variance() const {
+ // @@protoc_insertion_point(field_get:caffe.MVNParameter.normalize_variance)
+ return normalize_variance_;
+}
+void MVNParameter::set_normalize_variance(bool value) {
+ set_has_normalize_variance();
+ normalize_variance_ = value;
+ // @@protoc_insertion_point(field_set:caffe.MVNParameter.normalize_variance)
+}
+
+// optional bool across_channels = 2 [default = false];
+bool MVNParameter::has_across_channels() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void MVNParameter::set_has_across_channels() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void MVNParameter::clear_has_across_channels() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void MVNParameter::clear_across_channels() {
+ across_channels_ = false;
+ clear_has_across_channels();
+}
+bool MVNParameter::across_channels() const {
+ // @@protoc_insertion_point(field_get:caffe.MVNParameter.across_channels)
+ return across_channels_;
+}
+void MVNParameter::set_across_channels(bool value) {
+ set_has_across_channels();
+ across_channels_ = value;
+ // @@protoc_insertion_point(field_set:caffe.MVNParameter.across_channels)
+}
+
+// optional float eps = 3 [default = 1e-09];
+bool MVNParameter::has_eps() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void MVNParameter::set_has_eps() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void MVNParameter::clear_has_eps() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void MVNParameter::clear_eps() {
+ eps_ = 1e-09f;
+ clear_has_eps();
+}
+float MVNParameter::eps() const {
+ // @@protoc_insertion_point(field_get:caffe.MVNParameter.eps)
+ return eps_;
+}
+void MVNParameter::set_eps(float value) {
+ set_has_eps();
+ eps_ = value;
+ // @@protoc_insertion_point(field_set:caffe.MVNParameter.eps)
+}
+
+inline const MVNParameter* MVNParameter::internal_default_instance() {
+ return &MVNParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int ParameterParameter::kShapeFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+ParameterParameter::ParameterParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.ParameterParameter)
+}
+
+void ParameterParameter::InitAsDefaultInstance() {
+ shape_ = const_cast< ::caffe::BlobShape*>(
+ ::caffe::BlobShape::internal_default_instance());
+}
+
+ParameterParameter::ParameterParameter(const ParameterParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.ParameterParameter)
+}
+
+void ParameterParameter::SharedCtor() {
+ _cached_size_ = 0;
+ shape_ = NULL;
+}
+
+ParameterParameter::~ParameterParameter() {
+ // @@protoc_insertion_point(destructor:caffe.ParameterParameter)
+ SharedDtor();
+}
+
+void ParameterParameter::SharedDtor() {
+ if (this != &ParameterParameter_default_instance_.get()) {
+ delete shape_;
+ }
+}
+
+void ParameterParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* ParameterParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return ParameterParameter_descriptor_;
+}
+
+const ParameterParameter& ParameterParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<ParameterParameter> ParameterParameter_default_instance_;
+
+ParameterParameter* ParameterParameter::New(::google::protobuf::Arena* arena) const {
+ ParameterParameter* n = new ParameterParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void ParameterParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.ParameterParameter)
+ if (has_shape()) {
+ if (shape_ != NULL) shape_->::caffe::BlobShape::Clear();
+ }
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool ParameterParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.ParameterParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional .caffe.BlobShape shape = 1;
+ case 1: {
+ if (tag == 10) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_shape()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.ParameterParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.ParameterParameter)
+ return false;
+#undef DO_
+}
+
+void ParameterParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.ParameterParameter)
+ // optional .caffe.BlobShape shape = 1;
+ if (has_shape()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 1, *this->shape_, output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.ParameterParameter)
+}
+
+::google::protobuf::uint8* ParameterParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.ParameterParameter)
+ // optional .caffe.BlobShape shape = 1;
+ if (has_shape()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 1, *this->shape_, false, target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.ParameterParameter)
+ return target;
+}
+
+size_t ParameterParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.ParameterParameter)
+ size_t total_size = 0;
+
+ // optional .caffe.BlobShape shape = 1;
+ if (has_shape()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->shape_);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void ParameterParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.ParameterParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const ParameterParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const ParameterParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ParameterParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ParameterParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void ParameterParameter::MergeFrom(const ParameterParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ParameterParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void ParameterParameter::UnsafeMergeFrom(const ParameterParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_shape()) {
+ mutable_shape()->::caffe::BlobShape::MergeFrom(from.shape());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void ParameterParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.ParameterParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void ParameterParameter::CopyFrom(const ParameterParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ParameterParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool ParameterParameter::IsInitialized() const {
+
+ return true;
+}
+
+void ParameterParameter::Swap(ParameterParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void ParameterParameter::InternalSwap(ParameterParameter* other) {
+ std::swap(shape_, other->shape_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata ParameterParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = ParameterParameter_descriptor_;
+ metadata.reflection = ParameterParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// ParameterParameter
+
+// optional .caffe.BlobShape shape = 1;
+bool ParameterParameter::has_shape() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void ParameterParameter::set_has_shape() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void ParameterParameter::clear_has_shape() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void ParameterParameter::clear_shape() {
+ if (shape_ != NULL) shape_->::caffe::BlobShape::Clear();
+ clear_has_shape();
+}
+const ::caffe::BlobShape& ParameterParameter::shape() const {
+ // @@protoc_insertion_point(field_get:caffe.ParameterParameter.shape)
+ return shape_ != NULL ? *shape_
+ : *::caffe::BlobShape::internal_default_instance();
+}
+::caffe::BlobShape* ParameterParameter::mutable_shape() {
+ set_has_shape();
+ if (shape_ == NULL) {
+ shape_ = new ::caffe::BlobShape;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.ParameterParameter.shape)
+ return shape_;
+}
+::caffe::BlobShape* ParameterParameter::release_shape() {
+ // @@protoc_insertion_point(field_release:caffe.ParameterParameter.shape)
+ clear_has_shape();
+ ::caffe::BlobShape* temp = shape_;
+ shape_ = NULL;
+ return temp;
+}
+void ParameterParameter::set_allocated_shape(::caffe::BlobShape* shape) {
+ delete shape_;
+ shape_ = shape;
+ if (shape) {
+ set_has_shape();
+ } else {
+ clear_has_shape();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.ParameterParameter.shape)
+}
+
+inline const ParameterParameter* ParameterParameter::internal_default_instance() {
+ return &ParameterParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+const ::google::protobuf::EnumDescriptor* PoolingParameter_PoolMethod_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return PoolingParameter_PoolMethod_descriptor_;
+}
+bool PoolingParameter_PoolMethod_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ case 2:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const PoolingParameter_PoolMethod PoolingParameter::MAX;
+const PoolingParameter_PoolMethod PoolingParameter::AVE;
+const PoolingParameter_PoolMethod PoolingParameter::STOCHASTIC;
+const PoolingParameter_PoolMethod PoolingParameter::PoolMethod_MIN;
+const PoolingParameter_PoolMethod PoolingParameter::PoolMethod_MAX;
+const int PoolingParameter::PoolMethod_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+const ::google::protobuf::EnumDescriptor* PoolingParameter_Engine_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return PoolingParameter_Engine_descriptor_;
+}
+bool PoolingParameter_Engine_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ case 2:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const PoolingParameter_Engine PoolingParameter::DEFAULT;
+const PoolingParameter_Engine PoolingParameter::CAFFE;
+const PoolingParameter_Engine PoolingParameter::CUDNN;
+const PoolingParameter_Engine PoolingParameter::Engine_MIN;
+const PoolingParameter_Engine PoolingParameter::Engine_MAX;
+const int PoolingParameter::Engine_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int PoolingParameter::kPoolFieldNumber;
+const int PoolingParameter::kPadFieldNumber;
+const int PoolingParameter::kPadHFieldNumber;
+const int PoolingParameter::kPadWFieldNumber;
+const int PoolingParameter::kKernelSizeFieldNumber;
+const int PoolingParameter::kKernelHFieldNumber;
+const int PoolingParameter::kKernelWFieldNumber;
+const int PoolingParameter::kStrideFieldNumber;
+const int PoolingParameter::kStrideHFieldNumber;
+const int PoolingParameter::kStrideWFieldNumber;
+const int PoolingParameter::kEngineFieldNumber;
+const int PoolingParameter::kGlobalPoolingFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+PoolingParameter::PoolingParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.PoolingParameter)
+}
+
+void PoolingParameter::InitAsDefaultInstance() {
+}
+
+PoolingParameter::PoolingParameter(const PoolingParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.PoolingParameter)
+}
+
+void PoolingParameter::SharedCtor() {
+ _cached_size_ = 0;
+ ::memset(&pool_, 0, reinterpret_cast<char*>(&global_pooling_) -
+ reinterpret_cast<char*>(&pool_) + sizeof(global_pooling_));
+ stride_ = 1u;
+}
+
+PoolingParameter::~PoolingParameter() {
+ // @@protoc_insertion_point(destructor:caffe.PoolingParameter)
+ SharedDtor();
+}
+
+void PoolingParameter::SharedDtor() {
+}
+
+void PoolingParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* PoolingParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return PoolingParameter_descriptor_;
+}
+
+const PoolingParameter& PoolingParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<PoolingParameter> PoolingParameter_default_instance_;
+
+PoolingParameter* PoolingParameter::New(::google::protobuf::Arena* arena) const {
+ PoolingParameter* n = new PoolingParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void PoolingParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.PoolingParameter)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(PoolingParameter, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<PoolingParameter*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ if (_has_bits_[0 / 32] & 255u) {
+ ZR_(pool_, kernel_w_);
+ stride_ = 1u;
+ }
+ ZR_(stride_h_, global_pooling_);
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool PoolingParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.PoolingParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional .caffe.PoolingParameter.PoolMethod pool = 1 [default = MAX];
+ case 1: {
+ if (tag == 8) {
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::PoolingParameter_PoolMethod_IsValid(value)) {
+ set_pool(static_cast< ::caffe::PoolingParameter_PoolMethod >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(1, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_kernel_size;
+ break;
+ }
+
+ // optional uint32 kernel_size = 2;
+ case 2: {
+ if (tag == 16) {
+ parse_kernel_size:
+ set_has_kernel_size();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &kernel_size_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(24)) goto parse_stride;
+ break;
+ }
+
+ // optional uint32 stride = 3 [default = 1];
+ case 3: {
+ if (tag == 24) {
+ parse_stride:
+ set_has_stride();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &stride_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(32)) goto parse_pad;
+ break;
+ }
+
+ // optional uint32 pad = 4 [default = 0];
+ case 4: {
+ if (tag == 32) {
+ parse_pad:
+ set_has_pad();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &pad_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(40)) goto parse_kernel_h;
+ break;
+ }
+
+ // optional uint32 kernel_h = 5;
+ case 5: {
+ if (tag == 40) {
+ parse_kernel_h:
+ set_has_kernel_h();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &kernel_h_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(48)) goto parse_kernel_w;
+ break;
+ }
+
+ // optional uint32 kernel_w = 6;
+ case 6: {
+ if (tag == 48) {
+ parse_kernel_w:
+ set_has_kernel_w();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &kernel_w_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(56)) goto parse_stride_h;
+ break;
+ }
+
+ // optional uint32 stride_h = 7;
+ case 7: {
+ if (tag == 56) {
+ parse_stride_h:
+ set_has_stride_h();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &stride_h_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(64)) goto parse_stride_w;
+ break;
+ }
+
+ // optional uint32 stride_w = 8;
+ case 8: {
+ if (tag == 64) {
+ parse_stride_w:
+ set_has_stride_w();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &stride_w_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(72)) goto parse_pad_h;
+ break;
+ }
+
+ // optional uint32 pad_h = 9 [default = 0];
+ case 9: {
+ if (tag == 72) {
+ parse_pad_h:
+ set_has_pad_h();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &pad_h_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(80)) goto parse_pad_w;
+ break;
+ }
+
+ // optional uint32 pad_w = 10 [default = 0];
+ case 10: {
+ if (tag == 80) {
+ parse_pad_w:
+ set_has_pad_w();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &pad_w_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(88)) goto parse_engine;
+ break;
+ }
+
+ // optional .caffe.PoolingParameter.Engine engine = 11 [default = DEFAULT];
+ case 11: {
+ if (tag == 88) {
+ parse_engine:
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::PoolingParameter_Engine_IsValid(value)) {
+ set_engine(static_cast< ::caffe::PoolingParameter_Engine >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(11, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(96)) goto parse_global_pooling;
+ break;
+ }
+
+ // optional bool global_pooling = 12 [default = false];
+ case 12: {
+ if (tag == 96) {
+ parse_global_pooling:
+ set_has_global_pooling();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &global_pooling_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.PoolingParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.PoolingParameter)
+ return false;
+#undef DO_
+}
+
+void PoolingParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.PoolingParameter)
+ // optional .caffe.PoolingParameter.PoolMethod pool = 1 [default = MAX];
+ if (has_pool()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 1, this->pool(), output);
+ }
+
+ // optional uint32 kernel_size = 2;
+ if (has_kernel_size()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(2, this->kernel_size(), output);
+ }
+
+ // optional uint32 stride = 3 [default = 1];
+ if (has_stride()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(3, this->stride(), output);
+ }
+
+ // optional uint32 pad = 4 [default = 0];
+ if (has_pad()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(4, this->pad(), output);
+ }
+
+ // optional uint32 kernel_h = 5;
+ if (has_kernel_h()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(5, this->kernel_h(), output);
+ }
+
+ // optional uint32 kernel_w = 6;
+ if (has_kernel_w()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(6, this->kernel_w(), output);
+ }
+
+ // optional uint32 stride_h = 7;
+ if (has_stride_h()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(7, this->stride_h(), output);
+ }
+
+ // optional uint32 stride_w = 8;
+ if (has_stride_w()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(8, this->stride_w(), output);
+ }
+
+ // optional uint32 pad_h = 9 [default = 0];
+ if (has_pad_h()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(9, this->pad_h(), output);
+ }
+
+ // optional uint32 pad_w = 10 [default = 0];
+ if (has_pad_w()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(10, this->pad_w(), output);
+ }
+
+ // optional .caffe.PoolingParameter.Engine engine = 11 [default = DEFAULT];
+ if (has_engine()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 11, this->engine(), output);
+ }
+
+ // optional bool global_pooling = 12 [default = false];
+ if (has_global_pooling()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(12, this->global_pooling(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.PoolingParameter)
+}
+
+::google::protobuf::uint8* PoolingParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.PoolingParameter)
+ // optional .caffe.PoolingParameter.PoolMethod pool = 1 [default = MAX];
+ if (has_pool()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 1, this->pool(), target);
+ }
+
+ // optional uint32 kernel_size = 2;
+ if (has_kernel_size()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(2, this->kernel_size(), target);
+ }
+
+ // optional uint32 stride = 3 [default = 1];
+ if (has_stride()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(3, this->stride(), target);
+ }
+
+ // optional uint32 pad = 4 [default = 0];
+ if (has_pad()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(4, this->pad(), target);
+ }
+
+ // optional uint32 kernel_h = 5;
+ if (has_kernel_h()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(5, this->kernel_h(), target);
+ }
+
+ // optional uint32 kernel_w = 6;
+ if (has_kernel_w()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(6, this->kernel_w(), target);
+ }
+
+ // optional uint32 stride_h = 7;
+ if (has_stride_h()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(7, this->stride_h(), target);
+ }
+
+ // optional uint32 stride_w = 8;
+ if (has_stride_w()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(8, this->stride_w(), target);
+ }
+
+ // optional uint32 pad_h = 9 [default = 0];
+ if (has_pad_h()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(9, this->pad_h(), target);
+ }
+
+ // optional uint32 pad_w = 10 [default = 0];
+ if (has_pad_w()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(10, this->pad_w(), target);
+ }
+
+ // optional .caffe.PoolingParameter.Engine engine = 11 [default = DEFAULT];
+ if (has_engine()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 11, this->engine(), target);
+ }
+
+ // optional bool global_pooling = 12 [default = false];
+ if (has_global_pooling()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(12, this->global_pooling(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.PoolingParameter)
+ return target;
+}
+
+size_t PoolingParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.PoolingParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 255u) {
+ // optional .caffe.PoolingParameter.PoolMethod pool = 1 [default = MAX];
+ if (has_pool()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->pool());
+ }
+
+ // optional uint32 pad = 4 [default = 0];
+ if (has_pad()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->pad());
+ }
+
+ // optional uint32 pad_h = 9 [default = 0];
+ if (has_pad_h()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->pad_h());
+ }
+
+ // optional uint32 pad_w = 10 [default = 0];
+ if (has_pad_w()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->pad_w());
+ }
+
+ // optional uint32 kernel_size = 2;
+ if (has_kernel_size()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->kernel_size());
+ }
+
+ // optional uint32 kernel_h = 5;
+ if (has_kernel_h()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->kernel_h());
+ }
+
+ // optional uint32 kernel_w = 6;
+ if (has_kernel_w()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->kernel_w());
+ }
+
+ // optional uint32 stride = 3 [default = 1];
+ if (has_stride()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->stride());
+ }
+
+ }
+ if (_has_bits_[8 / 32] & 3840u) {
+ // optional uint32 stride_h = 7;
+ if (has_stride_h()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->stride_h());
+ }
+
+ // optional uint32 stride_w = 8;
+ if (has_stride_w()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->stride_w());
+ }
+
+ // optional .caffe.PoolingParameter.Engine engine = 11 [default = DEFAULT];
+ if (has_engine()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->engine());
+ }
+
+ // optional bool global_pooling = 12 [default = false];
+ if (has_global_pooling()) {
+ total_size += 1 + 1;
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void PoolingParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.PoolingParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const PoolingParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const PoolingParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.PoolingParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.PoolingParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void PoolingParameter::MergeFrom(const PoolingParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.PoolingParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void PoolingParameter::UnsafeMergeFrom(const PoolingParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_pool()) {
+ set_pool(from.pool());
+ }
+ if (from.has_pad()) {
+ set_pad(from.pad());
+ }
+ if (from.has_pad_h()) {
+ set_pad_h(from.pad_h());
+ }
+ if (from.has_pad_w()) {
+ set_pad_w(from.pad_w());
+ }
+ if (from.has_kernel_size()) {
+ set_kernel_size(from.kernel_size());
+ }
+ if (from.has_kernel_h()) {
+ set_kernel_h(from.kernel_h());
+ }
+ if (from.has_kernel_w()) {
+ set_kernel_w(from.kernel_w());
+ }
+ if (from.has_stride()) {
+ set_stride(from.stride());
+ }
+ }
+ if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) {
+ if (from.has_stride_h()) {
+ set_stride_h(from.stride_h());
+ }
+ if (from.has_stride_w()) {
+ set_stride_w(from.stride_w());
+ }
+ if (from.has_engine()) {
+ set_engine(from.engine());
+ }
+ if (from.has_global_pooling()) {
+ set_global_pooling(from.global_pooling());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void PoolingParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.PoolingParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void PoolingParameter::CopyFrom(const PoolingParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.PoolingParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool PoolingParameter::IsInitialized() const {
+
+ return true;
+}
+
+void PoolingParameter::Swap(PoolingParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void PoolingParameter::InternalSwap(PoolingParameter* other) {
+ std::swap(pool_, other->pool_);
+ std::swap(pad_, other->pad_);
+ std::swap(pad_h_, other->pad_h_);
+ std::swap(pad_w_, other->pad_w_);
+ std::swap(kernel_size_, other->kernel_size_);
+ std::swap(kernel_h_, other->kernel_h_);
+ std::swap(kernel_w_, other->kernel_w_);
+ std::swap(stride_, other->stride_);
+ std::swap(stride_h_, other->stride_h_);
+ std::swap(stride_w_, other->stride_w_);
+ std::swap(engine_, other->engine_);
+ std::swap(global_pooling_, other->global_pooling_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata PoolingParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = PoolingParameter_descriptor_;
+ metadata.reflection = PoolingParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// PoolingParameter
+
+// optional .caffe.PoolingParameter.PoolMethod pool = 1 [default = MAX];
+bool PoolingParameter::has_pool() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void PoolingParameter::set_has_pool() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void PoolingParameter::clear_has_pool() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void PoolingParameter::clear_pool() {
+ pool_ = 0;
+ clear_has_pool();
+}
+::caffe::PoolingParameter_PoolMethod PoolingParameter::pool() const {
+ // @@protoc_insertion_point(field_get:caffe.PoolingParameter.pool)
+ return static_cast< ::caffe::PoolingParameter_PoolMethod >(pool_);
+}
+void PoolingParameter::set_pool(::caffe::PoolingParameter_PoolMethod value) {
+ assert(::caffe::PoolingParameter_PoolMethod_IsValid(value));
+ set_has_pool();
+ pool_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PoolingParameter.pool)
+}
+
+// optional uint32 pad = 4 [default = 0];
+bool PoolingParameter::has_pad() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void PoolingParameter::set_has_pad() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void PoolingParameter::clear_has_pad() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void PoolingParameter::clear_pad() {
+ pad_ = 0u;
+ clear_has_pad();
+}
+::google::protobuf::uint32 PoolingParameter::pad() const {
+ // @@protoc_insertion_point(field_get:caffe.PoolingParameter.pad)
+ return pad_;
+}
+void PoolingParameter::set_pad(::google::protobuf::uint32 value) {
+ set_has_pad();
+ pad_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PoolingParameter.pad)
+}
+
+// optional uint32 pad_h = 9 [default = 0];
+bool PoolingParameter::has_pad_h() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void PoolingParameter::set_has_pad_h() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void PoolingParameter::clear_has_pad_h() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void PoolingParameter::clear_pad_h() {
+ pad_h_ = 0u;
+ clear_has_pad_h();
+}
+::google::protobuf::uint32 PoolingParameter::pad_h() const {
+ // @@protoc_insertion_point(field_get:caffe.PoolingParameter.pad_h)
+ return pad_h_;
+}
+void PoolingParameter::set_pad_h(::google::protobuf::uint32 value) {
+ set_has_pad_h();
+ pad_h_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PoolingParameter.pad_h)
+}
+
+// optional uint32 pad_w = 10 [default = 0];
+bool PoolingParameter::has_pad_w() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+void PoolingParameter::set_has_pad_w() {
+ _has_bits_[0] |= 0x00000008u;
+}
+void PoolingParameter::clear_has_pad_w() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+void PoolingParameter::clear_pad_w() {
+ pad_w_ = 0u;
+ clear_has_pad_w();
+}
+::google::protobuf::uint32 PoolingParameter::pad_w() const {
+ // @@protoc_insertion_point(field_get:caffe.PoolingParameter.pad_w)
+ return pad_w_;
+}
+void PoolingParameter::set_pad_w(::google::protobuf::uint32 value) {
+ set_has_pad_w();
+ pad_w_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PoolingParameter.pad_w)
+}
+
+// optional uint32 kernel_size = 2;
+bool PoolingParameter::has_kernel_size() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+void PoolingParameter::set_has_kernel_size() {
+ _has_bits_[0] |= 0x00000010u;
+}
+void PoolingParameter::clear_has_kernel_size() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+void PoolingParameter::clear_kernel_size() {
+ kernel_size_ = 0u;
+ clear_has_kernel_size();
+}
+::google::protobuf::uint32 PoolingParameter::kernel_size() const {
+ // @@protoc_insertion_point(field_get:caffe.PoolingParameter.kernel_size)
+ return kernel_size_;
+}
+void PoolingParameter::set_kernel_size(::google::protobuf::uint32 value) {
+ set_has_kernel_size();
+ kernel_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PoolingParameter.kernel_size)
+}
+
+// optional uint32 kernel_h = 5;
+bool PoolingParameter::has_kernel_h() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+void PoolingParameter::set_has_kernel_h() {
+ _has_bits_[0] |= 0x00000020u;
+}
+void PoolingParameter::clear_has_kernel_h() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+void PoolingParameter::clear_kernel_h() {
+ kernel_h_ = 0u;
+ clear_has_kernel_h();
+}
+::google::protobuf::uint32 PoolingParameter::kernel_h() const {
+ // @@protoc_insertion_point(field_get:caffe.PoolingParameter.kernel_h)
+ return kernel_h_;
+}
+void PoolingParameter::set_kernel_h(::google::protobuf::uint32 value) {
+ set_has_kernel_h();
+ kernel_h_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PoolingParameter.kernel_h)
+}
+
+// optional uint32 kernel_w = 6;
+bool PoolingParameter::has_kernel_w() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+void PoolingParameter::set_has_kernel_w() {
+ _has_bits_[0] |= 0x00000040u;
+}
+void PoolingParameter::clear_has_kernel_w() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+void PoolingParameter::clear_kernel_w() {
+ kernel_w_ = 0u;
+ clear_has_kernel_w();
+}
+::google::protobuf::uint32 PoolingParameter::kernel_w() const {
+ // @@protoc_insertion_point(field_get:caffe.PoolingParameter.kernel_w)
+ return kernel_w_;
+}
+void PoolingParameter::set_kernel_w(::google::protobuf::uint32 value) {
+ set_has_kernel_w();
+ kernel_w_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PoolingParameter.kernel_w)
+}
+
+// optional uint32 stride = 3 [default = 1];
+bool PoolingParameter::has_stride() const {
+ return (_has_bits_[0] & 0x00000080u) != 0;
+}
+void PoolingParameter::set_has_stride() {
+ _has_bits_[0] |= 0x00000080u;
+}
+void PoolingParameter::clear_has_stride() {
+ _has_bits_[0] &= ~0x00000080u;
+}
+void PoolingParameter::clear_stride() {
+ stride_ = 1u;
+ clear_has_stride();
+}
+::google::protobuf::uint32 PoolingParameter::stride() const {
+ // @@protoc_insertion_point(field_get:caffe.PoolingParameter.stride)
+ return stride_;
+}
+void PoolingParameter::set_stride(::google::protobuf::uint32 value) {
+ set_has_stride();
+ stride_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PoolingParameter.stride)
+}
+
+// optional uint32 stride_h = 7;
+bool PoolingParameter::has_stride_h() const {
+ return (_has_bits_[0] & 0x00000100u) != 0;
+}
+void PoolingParameter::set_has_stride_h() {
+ _has_bits_[0] |= 0x00000100u;
+}
+void PoolingParameter::clear_has_stride_h() {
+ _has_bits_[0] &= ~0x00000100u;
+}
+void PoolingParameter::clear_stride_h() {
+ stride_h_ = 0u;
+ clear_has_stride_h();
+}
+::google::protobuf::uint32 PoolingParameter::stride_h() const {
+ // @@protoc_insertion_point(field_get:caffe.PoolingParameter.stride_h)
+ return stride_h_;
+}
+void PoolingParameter::set_stride_h(::google::protobuf::uint32 value) {
+ set_has_stride_h();
+ stride_h_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PoolingParameter.stride_h)
+}
+
+// optional uint32 stride_w = 8;
+bool PoolingParameter::has_stride_w() const {
+ return (_has_bits_[0] & 0x00000200u) != 0;
+}
+void PoolingParameter::set_has_stride_w() {
+ _has_bits_[0] |= 0x00000200u;
+}
+void PoolingParameter::clear_has_stride_w() {
+ _has_bits_[0] &= ~0x00000200u;
+}
+void PoolingParameter::clear_stride_w() {
+ stride_w_ = 0u;
+ clear_has_stride_w();
+}
+::google::protobuf::uint32 PoolingParameter::stride_w() const {
+ // @@protoc_insertion_point(field_get:caffe.PoolingParameter.stride_w)
+ return stride_w_;
+}
+void PoolingParameter::set_stride_w(::google::protobuf::uint32 value) {
+ set_has_stride_w();
+ stride_w_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PoolingParameter.stride_w)
+}
+
+// optional .caffe.PoolingParameter.Engine engine = 11 [default = DEFAULT];
+bool PoolingParameter::has_engine() const {
+ return (_has_bits_[0] & 0x00000400u) != 0;
+}
+void PoolingParameter::set_has_engine() {
+ _has_bits_[0] |= 0x00000400u;
+}
+void PoolingParameter::clear_has_engine() {
+ _has_bits_[0] &= ~0x00000400u;
+}
+void PoolingParameter::clear_engine() {
+ engine_ = 0;
+ clear_has_engine();
+}
+::caffe::PoolingParameter_Engine PoolingParameter::engine() const {
+ // @@protoc_insertion_point(field_get:caffe.PoolingParameter.engine)
+ return static_cast< ::caffe::PoolingParameter_Engine >(engine_);
+}
+void PoolingParameter::set_engine(::caffe::PoolingParameter_Engine value) {
+ assert(::caffe::PoolingParameter_Engine_IsValid(value));
+ set_has_engine();
+ engine_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PoolingParameter.engine)
+}
+
+// optional bool global_pooling = 12 [default = false];
+bool PoolingParameter::has_global_pooling() const {
+ return (_has_bits_[0] & 0x00000800u) != 0;
+}
+void PoolingParameter::set_has_global_pooling() {
+ _has_bits_[0] |= 0x00000800u;
+}
+void PoolingParameter::clear_has_global_pooling() {
+ _has_bits_[0] &= ~0x00000800u;
+}
+void PoolingParameter::clear_global_pooling() {
+ global_pooling_ = false;
+ clear_has_global_pooling();
+}
+bool PoolingParameter::global_pooling() const {
+ // @@protoc_insertion_point(field_get:caffe.PoolingParameter.global_pooling)
+ return global_pooling_;
+}
+void PoolingParameter::set_global_pooling(bool value) {
+ set_has_global_pooling();
+ global_pooling_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PoolingParameter.global_pooling)
+}
+
+inline const PoolingParameter* PoolingParameter::internal_default_instance() {
+ return &PoolingParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int PowerParameter::kPowerFieldNumber;
+const int PowerParameter::kScaleFieldNumber;
+const int PowerParameter::kShiftFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+PowerParameter::PowerParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.PowerParameter)
+}
+
+void PowerParameter::InitAsDefaultInstance() {
+}
+
+PowerParameter::PowerParameter(const PowerParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.PowerParameter)
+}
+
+void PowerParameter::SharedCtor() {
+ _cached_size_ = 0;
+ shift_ = 0;
+ power_ = 1;
+ scale_ = 1;
+}
+
+PowerParameter::~PowerParameter() {
+ // @@protoc_insertion_point(destructor:caffe.PowerParameter)
+ SharedDtor();
+}
+
+void PowerParameter::SharedDtor() {
+}
+
+void PowerParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* PowerParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return PowerParameter_descriptor_;
+}
+
+const PowerParameter& PowerParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<PowerParameter> PowerParameter_default_instance_;
+
+PowerParameter* PowerParameter::New(::google::protobuf::Arena* arena) const {
+ PowerParameter* n = new PowerParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void PowerParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.PowerParameter)
+ if (_has_bits_[0 / 32] & 7u) {
+ power_ = 1;
+ scale_ = 1;
+ shift_ = 0;
+ }
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool PowerParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.PowerParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional float power = 1 [default = 1];
+ case 1: {
+ if (tag == 13) {
+ set_has_power();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &power_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(21)) goto parse_scale;
+ break;
+ }
+
+ // optional float scale = 2 [default = 1];
+ case 2: {
+ if (tag == 21) {
+ parse_scale:
+ set_has_scale();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &scale_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(29)) goto parse_shift;
+ break;
+ }
+
+ // optional float shift = 3 [default = 0];
+ case 3: {
+ if (tag == 29) {
+ parse_shift:
+ set_has_shift();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &shift_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.PowerParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.PowerParameter)
+ return false;
+#undef DO_
+}
+
+void PowerParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.PowerParameter)
+ // optional float power = 1 [default = 1];
+ if (has_power()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->power(), output);
+ }
+
+ // optional float scale = 2 [default = 1];
+ if (has_scale()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->scale(), output);
+ }
+
+ // optional float shift = 3 [default = 0];
+ if (has_shift()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->shift(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.PowerParameter)
+}
+
+::google::protobuf::uint8* PowerParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.PowerParameter)
+ // optional float power = 1 [default = 1];
+ if (has_power()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->power(), target);
+ }
+
+ // optional float scale = 2 [default = 1];
+ if (has_scale()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->scale(), target);
+ }
+
+ // optional float shift = 3 [default = 0];
+ if (has_shift()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->shift(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.PowerParameter)
+ return target;
+}
+
+size_t PowerParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.PowerParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 7u) {
+ // optional float power = 1 [default = 1];
+ if (has_power()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float scale = 2 [default = 1];
+ if (has_scale()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float shift = 3 [default = 0];
+ if (has_shift()) {
+ total_size += 1 + 4;
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void PowerParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.PowerParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const PowerParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const PowerParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.PowerParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.PowerParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void PowerParameter::MergeFrom(const PowerParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.PowerParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void PowerParameter::UnsafeMergeFrom(const PowerParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_power()) {
+ set_power(from.power());
+ }
+ if (from.has_scale()) {
+ set_scale(from.scale());
+ }
+ if (from.has_shift()) {
+ set_shift(from.shift());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void PowerParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.PowerParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void PowerParameter::CopyFrom(const PowerParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.PowerParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool PowerParameter::IsInitialized() const {
+
+ return true;
+}
+
+void PowerParameter::Swap(PowerParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void PowerParameter::InternalSwap(PowerParameter* other) {
+ std::swap(power_, other->power_);
+ std::swap(scale_, other->scale_);
+ std::swap(shift_, other->shift_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata PowerParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = PowerParameter_descriptor_;
+ metadata.reflection = PowerParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// PowerParameter
+
+// optional float power = 1 [default = 1];
+bool PowerParameter::has_power() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void PowerParameter::set_has_power() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void PowerParameter::clear_has_power() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void PowerParameter::clear_power() {
+ power_ = 1;
+ clear_has_power();
+}
+float PowerParameter::power() const {
+ // @@protoc_insertion_point(field_get:caffe.PowerParameter.power)
+ return power_;
+}
+void PowerParameter::set_power(float value) {
+ set_has_power();
+ power_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PowerParameter.power)
+}
+
+// optional float scale = 2 [default = 1];
+bool PowerParameter::has_scale() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void PowerParameter::set_has_scale() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void PowerParameter::clear_has_scale() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void PowerParameter::clear_scale() {
+ scale_ = 1;
+ clear_has_scale();
+}
+float PowerParameter::scale() const {
+ // @@protoc_insertion_point(field_get:caffe.PowerParameter.scale)
+ return scale_;
+}
+void PowerParameter::set_scale(float value) {
+ set_has_scale();
+ scale_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PowerParameter.scale)
+}
+
+// optional float shift = 3 [default = 0];
+bool PowerParameter::has_shift() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void PowerParameter::set_has_shift() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void PowerParameter::clear_has_shift() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void PowerParameter::clear_shift() {
+ shift_ = 0;
+ clear_has_shift();
+}
+float PowerParameter::shift() const {
+ // @@protoc_insertion_point(field_get:caffe.PowerParameter.shift)
+ return shift_;
+}
+void PowerParameter::set_shift(float value) {
+ set_has_shift();
+ shift_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PowerParameter.shift)
+}
+
+inline const PowerParameter* PowerParameter::internal_default_instance() {
+ return &PowerParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int PythonParameter::kModuleFieldNumber;
+const int PythonParameter::kLayerFieldNumber;
+const int PythonParameter::kParamStrFieldNumber;
+const int PythonParameter::kShareInParallelFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+PythonParameter::PythonParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.PythonParameter)
+}
+
+void PythonParameter::InitAsDefaultInstance() {
+}
+
+PythonParameter::PythonParameter(const PythonParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.PythonParameter)
+}
+
+void PythonParameter::SharedCtor() {
+ _cached_size_ = 0;
+ module_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ layer_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ param_str_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ share_in_parallel_ = false;
+}
+
+PythonParameter::~PythonParameter() {
+ // @@protoc_insertion_point(destructor:caffe.PythonParameter)
+ SharedDtor();
+}
+
+void PythonParameter::SharedDtor() {
+ module_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ layer_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ param_str_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+
+void PythonParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* PythonParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return PythonParameter_descriptor_;
+}
+
+const PythonParameter& PythonParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<PythonParameter> PythonParameter_default_instance_;
+
+PythonParameter* PythonParameter::New(::google::protobuf::Arena* arena) const {
+ PythonParameter* n = new PythonParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void PythonParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.PythonParameter)
+ if (_has_bits_[0 / 32] & 15u) {
+ if (has_module()) {
+ module_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ if (has_layer()) {
+ layer_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ if (has_param_str()) {
+ param_str_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ share_in_parallel_ = false;
+ }
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool PythonParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.PythonParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional string module = 1;
+ case 1: {
+ if (tag == 10) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_module()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->module().data(), this->module().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.PythonParameter.module");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(18)) goto parse_layer;
+ break;
+ }
+
+ // optional string layer = 2;
+ case 2: {
+ if (tag == 18) {
+ parse_layer:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_layer()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->layer().data(), this->layer().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.PythonParameter.layer");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(26)) goto parse_param_str;
+ break;
+ }
+
+ // optional string param_str = 3 [default = ""];
+ case 3: {
+ if (tag == 26) {
+ parse_param_str:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_param_str()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->param_str().data(), this->param_str().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.PythonParameter.param_str");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(32)) goto parse_share_in_parallel;
+ break;
+ }
+
+ // optional bool share_in_parallel = 4 [default = false];
+ case 4: {
+ if (tag == 32) {
+ parse_share_in_parallel:
+ set_has_share_in_parallel();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &share_in_parallel_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.PythonParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.PythonParameter)
+ return false;
+#undef DO_
+}
+
+void PythonParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.PythonParameter)
+ // optional string module = 1;
+ if (has_module()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->module().data(), this->module().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.PythonParameter.module");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 1, this->module(), output);
+ }
+
+ // optional string layer = 2;
+ if (has_layer()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->layer().data(), this->layer().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.PythonParameter.layer");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 2, this->layer(), output);
+ }
+
+ // optional string param_str = 3 [default = ""];
+ if (has_param_str()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->param_str().data(), this->param_str().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.PythonParameter.param_str");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 3, this->param_str(), output);
+ }
+
+ // optional bool share_in_parallel = 4 [default = false];
+ if (has_share_in_parallel()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(4, this->share_in_parallel(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.PythonParameter)
+}
+
+::google::protobuf::uint8* PythonParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.PythonParameter)
+ // optional string module = 1;
+ if (has_module()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->module().data(), this->module().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.PythonParameter.module");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 1, this->module(), target);
+ }
+
+ // optional string layer = 2;
+ if (has_layer()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->layer().data(), this->layer().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.PythonParameter.layer");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 2, this->layer(), target);
+ }
+
+ // optional string param_str = 3 [default = ""];
+ if (has_param_str()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->param_str().data(), this->param_str().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.PythonParameter.param_str");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 3, this->param_str(), target);
+ }
+
+ // optional bool share_in_parallel = 4 [default = false];
+ if (has_share_in_parallel()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(4, this->share_in_parallel(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.PythonParameter)
+ return target;
+}
+
+size_t PythonParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.PythonParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 15u) {
+ // optional string module = 1;
+ if (has_module()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->module());
+ }
+
+ // optional string layer = 2;
+ if (has_layer()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->layer());
+ }
+
+ // optional string param_str = 3 [default = ""];
+ if (has_param_str()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->param_str());
+ }
+
+ // optional bool share_in_parallel = 4 [default = false];
+ if (has_share_in_parallel()) {
+ total_size += 1 + 1;
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void PythonParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.PythonParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const PythonParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const PythonParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.PythonParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.PythonParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void PythonParameter::MergeFrom(const PythonParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.PythonParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void PythonParameter::UnsafeMergeFrom(const PythonParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_module()) {
+ set_has_module();
+ module_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.module_);
+ }
+ if (from.has_layer()) {
+ set_has_layer();
+ layer_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.layer_);
+ }
+ if (from.has_param_str()) {
+ set_has_param_str();
+ param_str_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.param_str_);
+ }
+ if (from.has_share_in_parallel()) {
+ set_share_in_parallel(from.share_in_parallel());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void PythonParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.PythonParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void PythonParameter::CopyFrom(const PythonParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.PythonParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool PythonParameter::IsInitialized() const {
+
+ return true;
+}
+
+void PythonParameter::Swap(PythonParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void PythonParameter::InternalSwap(PythonParameter* other) {
+ module_.Swap(&other->module_);
+ layer_.Swap(&other->layer_);
+ param_str_.Swap(&other->param_str_);
+ std::swap(share_in_parallel_, other->share_in_parallel_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata PythonParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = PythonParameter_descriptor_;
+ metadata.reflection = PythonParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// PythonParameter
+
+// optional string module = 1;
+bool PythonParameter::has_module() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void PythonParameter::set_has_module() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void PythonParameter::clear_has_module() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void PythonParameter::clear_module() {
+ module_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_module();
+}
+const ::std::string& PythonParameter::module() const {
+ // @@protoc_insertion_point(field_get:caffe.PythonParameter.module)
+ return module_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void PythonParameter::set_module(const ::std::string& value) {
+ set_has_module();
+ module_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.PythonParameter.module)
+}
+void PythonParameter::set_module(const char* value) {
+ set_has_module();
+ module_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.PythonParameter.module)
+}
+void PythonParameter::set_module(const char* value, size_t size) {
+ set_has_module();
+ module_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.PythonParameter.module)
+}
+::std::string* PythonParameter::mutable_module() {
+ set_has_module();
+ // @@protoc_insertion_point(field_mutable:caffe.PythonParameter.module)
+ return module_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* PythonParameter::release_module() {
+ // @@protoc_insertion_point(field_release:caffe.PythonParameter.module)
+ clear_has_module();
+ return module_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void PythonParameter::set_allocated_module(::std::string* module) {
+ if (module != NULL) {
+ set_has_module();
+ } else {
+ clear_has_module();
+ }
+ module_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), module);
+ // @@protoc_insertion_point(field_set_allocated:caffe.PythonParameter.module)
+}
+
+// optional string layer = 2;
+bool PythonParameter::has_layer() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void PythonParameter::set_has_layer() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void PythonParameter::clear_has_layer() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void PythonParameter::clear_layer() {
+ layer_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_layer();
+}
+const ::std::string& PythonParameter::layer() const {
+ // @@protoc_insertion_point(field_get:caffe.PythonParameter.layer)
+ return layer_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void PythonParameter::set_layer(const ::std::string& value) {
+ set_has_layer();
+ layer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.PythonParameter.layer)
+}
+void PythonParameter::set_layer(const char* value) {
+ set_has_layer();
+ layer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.PythonParameter.layer)
+}
+void PythonParameter::set_layer(const char* value, size_t size) {
+ set_has_layer();
+ layer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.PythonParameter.layer)
+}
+::std::string* PythonParameter::mutable_layer() {
+ set_has_layer();
+ // @@protoc_insertion_point(field_mutable:caffe.PythonParameter.layer)
+ return layer_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* PythonParameter::release_layer() {
+ // @@protoc_insertion_point(field_release:caffe.PythonParameter.layer)
+ clear_has_layer();
+ return layer_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void PythonParameter::set_allocated_layer(::std::string* layer) {
+ if (layer != NULL) {
+ set_has_layer();
+ } else {
+ clear_has_layer();
+ }
+ layer_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), layer);
+ // @@protoc_insertion_point(field_set_allocated:caffe.PythonParameter.layer)
+}
+
+// optional string param_str = 3 [default = ""];
+bool PythonParameter::has_param_str() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void PythonParameter::set_has_param_str() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void PythonParameter::clear_has_param_str() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void PythonParameter::clear_param_str() {
+ param_str_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_param_str();
+}
+const ::std::string& PythonParameter::param_str() const {
+ // @@protoc_insertion_point(field_get:caffe.PythonParameter.param_str)
+ return param_str_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void PythonParameter::set_param_str(const ::std::string& value) {
+ set_has_param_str();
+ param_str_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.PythonParameter.param_str)
+}
+void PythonParameter::set_param_str(const char* value) {
+ set_has_param_str();
+ param_str_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.PythonParameter.param_str)
+}
+void PythonParameter::set_param_str(const char* value, size_t size) {
+ set_has_param_str();
+ param_str_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.PythonParameter.param_str)
+}
+::std::string* PythonParameter::mutable_param_str() {
+ set_has_param_str();
+ // @@protoc_insertion_point(field_mutable:caffe.PythonParameter.param_str)
+ return param_str_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* PythonParameter::release_param_str() {
+ // @@protoc_insertion_point(field_release:caffe.PythonParameter.param_str)
+ clear_has_param_str();
+ return param_str_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void PythonParameter::set_allocated_param_str(::std::string* param_str) {
+ if (param_str != NULL) {
+ set_has_param_str();
+ } else {
+ clear_has_param_str();
+ }
+ param_str_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), param_str);
+ // @@protoc_insertion_point(field_set_allocated:caffe.PythonParameter.param_str)
+}
+
+// optional bool share_in_parallel = 4 [default = false];
+bool PythonParameter::has_share_in_parallel() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+void PythonParameter::set_has_share_in_parallel() {
+ _has_bits_[0] |= 0x00000008u;
+}
+void PythonParameter::clear_has_share_in_parallel() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+void PythonParameter::clear_share_in_parallel() {
+ share_in_parallel_ = false;
+ clear_has_share_in_parallel();
+}
+bool PythonParameter::share_in_parallel() const {
+ // @@protoc_insertion_point(field_get:caffe.PythonParameter.share_in_parallel)
+ return share_in_parallel_;
+}
+void PythonParameter::set_share_in_parallel(bool value) {
+ set_has_share_in_parallel();
+ share_in_parallel_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PythonParameter.share_in_parallel)
+}
+
+inline const PythonParameter* PythonParameter::internal_default_instance() {
+ return &PythonParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int RecurrentParameter::kNumOutputFieldNumber;
+const int RecurrentParameter::kWeightFillerFieldNumber;
+const int RecurrentParameter::kBiasFillerFieldNumber;
+const int RecurrentParameter::kDebugInfoFieldNumber;
+const int RecurrentParameter::kExposeHiddenFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+RecurrentParameter::RecurrentParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.RecurrentParameter)
+}
+
+void RecurrentParameter::InitAsDefaultInstance() {
+ weight_filler_ = const_cast< ::caffe::FillerParameter*>(
+ ::caffe::FillerParameter::internal_default_instance());
+ bias_filler_ = const_cast< ::caffe::FillerParameter*>(
+ ::caffe::FillerParameter::internal_default_instance());
+}
+
+RecurrentParameter::RecurrentParameter(const RecurrentParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.RecurrentParameter)
+}
+
+void RecurrentParameter::SharedCtor() {
+ _cached_size_ = 0;
+ weight_filler_ = NULL;
+ bias_filler_ = NULL;
+ ::memset(&num_output_, 0, reinterpret_cast<char*>(&expose_hidden_) -
+ reinterpret_cast<char*>(&num_output_) + sizeof(expose_hidden_));
+}
+
+RecurrentParameter::~RecurrentParameter() {
+ // @@protoc_insertion_point(destructor:caffe.RecurrentParameter)
+ SharedDtor();
+}
+
+void RecurrentParameter::SharedDtor() {
+ if (this != &RecurrentParameter_default_instance_.get()) {
+ delete weight_filler_;
+ delete bias_filler_;
+ }
+}
+
+void RecurrentParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* RecurrentParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return RecurrentParameter_descriptor_;
+}
+
+const RecurrentParameter& RecurrentParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<RecurrentParameter> RecurrentParameter_default_instance_;
+
+RecurrentParameter* RecurrentParameter::New(::google::protobuf::Arena* arena) const {
+ RecurrentParameter* n = new RecurrentParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void RecurrentParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.RecurrentParameter)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(RecurrentParameter, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<RecurrentParameter*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ if (_has_bits_[0 / 32] & 31u) {
+ ZR_(num_output_, expose_hidden_);
+ if (has_weight_filler()) {
+ if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear();
+ }
+ if (has_bias_filler()) {
+ if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
+ }
+ }
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool RecurrentParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.RecurrentParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional uint32 num_output = 1 [default = 0];
+ case 1: {
+ if (tag == 8) {
+ set_has_num_output();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &num_output_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(18)) goto parse_weight_filler;
+ break;
+ }
+
+ // optional .caffe.FillerParameter weight_filler = 2;
+ case 2: {
+ if (tag == 18) {
+ parse_weight_filler:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_weight_filler()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(26)) goto parse_bias_filler;
+ break;
+ }
+
+ // optional .caffe.FillerParameter bias_filler = 3;
+ case 3: {
+ if (tag == 26) {
+ parse_bias_filler:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_bias_filler()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(32)) goto parse_debug_info;
+ break;
+ }
+
+ // optional bool debug_info = 4 [default = false];
+ case 4: {
+ if (tag == 32) {
+ parse_debug_info:
+ set_has_debug_info();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &debug_info_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(40)) goto parse_expose_hidden;
+ break;
+ }
+
+ // optional bool expose_hidden = 5 [default = false];
+ case 5: {
+ if (tag == 40) {
+ parse_expose_hidden:
+ set_has_expose_hidden();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &expose_hidden_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.RecurrentParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.RecurrentParameter)
+ return false;
+#undef DO_
+}
+
+void RecurrentParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.RecurrentParameter)
+ // optional uint32 num_output = 1 [default = 0];
+ if (has_num_output()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->num_output(), output);
+ }
+
+ // optional .caffe.FillerParameter weight_filler = 2;
+ if (has_weight_filler()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 2, *this->weight_filler_, output);
+ }
+
+ // optional .caffe.FillerParameter bias_filler = 3;
+ if (has_bias_filler()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 3, *this->bias_filler_, output);
+ }
+
+ // optional bool debug_info = 4 [default = false];
+ if (has_debug_info()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(4, this->debug_info(), output);
+ }
+
+ // optional bool expose_hidden = 5 [default = false];
+ if (has_expose_hidden()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(5, this->expose_hidden(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.RecurrentParameter)
+}
+
+::google::protobuf::uint8* RecurrentParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.RecurrentParameter)
+ // optional uint32 num_output = 1 [default = 0];
+ if (has_num_output()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->num_output(), target);
+ }
+
+ // optional .caffe.FillerParameter weight_filler = 2;
+ if (has_weight_filler()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 2, *this->weight_filler_, false, target);
+ }
+
+ // optional .caffe.FillerParameter bias_filler = 3;
+ if (has_bias_filler()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 3, *this->bias_filler_, false, target);
+ }
+
+ // optional bool debug_info = 4 [default = false];
+ if (has_debug_info()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(4, this->debug_info(), target);
+ }
+
+ // optional bool expose_hidden = 5 [default = false];
+ if (has_expose_hidden()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(5, this->expose_hidden(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.RecurrentParameter)
+ return target;
+}
+
+size_t RecurrentParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.RecurrentParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 31u) {
+ // optional uint32 num_output = 1 [default = 0];
+ if (has_num_output()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->num_output());
+ }
+
+ // optional .caffe.FillerParameter weight_filler = 2;
+ if (has_weight_filler()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->weight_filler_);
+ }
+
+ // optional .caffe.FillerParameter bias_filler = 3;
+ if (has_bias_filler()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->bias_filler_);
+ }
+
+ // optional bool debug_info = 4 [default = false];
+ if (has_debug_info()) {
+ total_size += 1 + 1;
+ }
+
+ // optional bool expose_hidden = 5 [default = false];
+ if (has_expose_hidden()) {
+ total_size += 1 + 1;
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void RecurrentParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.RecurrentParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const RecurrentParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const RecurrentParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.RecurrentParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.RecurrentParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void RecurrentParameter::MergeFrom(const RecurrentParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.RecurrentParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void RecurrentParameter::UnsafeMergeFrom(const RecurrentParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_num_output()) {
+ set_num_output(from.num_output());
+ }
+ if (from.has_weight_filler()) {
+ mutable_weight_filler()->::caffe::FillerParameter::MergeFrom(from.weight_filler());
+ }
+ if (from.has_bias_filler()) {
+ mutable_bias_filler()->::caffe::FillerParameter::MergeFrom(from.bias_filler());
+ }
+ if (from.has_debug_info()) {
+ set_debug_info(from.debug_info());
+ }
+ if (from.has_expose_hidden()) {
+ set_expose_hidden(from.expose_hidden());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void RecurrentParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.RecurrentParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void RecurrentParameter::CopyFrom(const RecurrentParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.RecurrentParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool RecurrentParameter::IsInitialized() const {
+
+ return true;
+}
+
+void RecurrentParameter::Swap(RecurrentParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void RecurrentParameter::InternalSwap(RecurrentParameter* other) {
+ std::swap(num_output_, other->num_output_);
+ std::swap(weight_filler_, other->weight_filler_);
+ std::swap(bias_filler_, other->bias_filler_);
+ std::swap(debug_info_, other->debug_info_);
+ std::swap(expose_hidden_, other->expose_hidden_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata RecurrentParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = RecurrentParameter_descriptor_;
+ metadata.reflection = RecurrentParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// RecurrentParameter
+
+// optional uint32 num_output = 1 [default = 0];
+bool RecurrentParameter::has_num_output() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void RecurrentParameter::set_has_num_output() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void RecurrentParameter::clear_has_num_output() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void RecurrentParameter::clear_num_output() {
+ num_output_ = 0u;
+ clear_has_num_output();
+}
+::google::protobuf::uint32 RecurrentParameter::num_output() const {
+ // @@protoc_insertion_point(field_get:caffe.RecurrentParameter.num_output)
+ return num_output_;
+}
+void RecurrentParameter::set_num_output(::google::protobuf::uint32 value) {
+ set_has_num_output();
+ num_output_ = value;
+ // @@protoc_insertion_point(field_set:caffe.RecurrentParameter.num_output)
+}
+
+// optional .caffe.FillerParameter weight_filler = 2;
+bool RecurrentParameter::has_weight_filler() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void RecurrentParameter::set_has_weight_filler() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void RecurrentParameter::clear_has_weight_filler() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void RecurrentParameter::clear_weight_filler() {
+ if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear();
+ clear_has_weight_filler();
+}
+const ::caffe::FillerParameter& RecurrentParameter::weight_filler() const {
+ // @@protoc_insertion_point(field_get:caffe.RecurrentParameter.weight_filler)
+ return weight_filler_ != NULL ? *weight_filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+::caffe::FillerParameter* RecurrentParameter::mutable_weight_filler() {
+ set_has_weight_filler();
+ if (weight_filler_ == NULL) {
+ weight_filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.RecurrentParameter.weight_filler)
+ return weight_filler_;
+}
+::caffe::FillerParameter* RecurrentParameter::release_weight_filler() {
+ // @@protoc_insertion_point(field_release:caffe.RecurrentParameter.weight_filler)
+ clear_has_weight_filler();
+ ::caffe::FillerParameter* temp = weight_filler_;
+ weight_filler_ = NULL;
+ return temp;
+}
+void RecurrentParameter::set_allocated_weight_filler(::caffe::FillerParameter* weight_filler) {
+ delete weight_filler_;
+ weight_filler_ = weight_filler;
+ if (weight_filler) {
+ set_has_weight_filler();
+ } else {
+ clear_has_weight_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.RecurrentParameter.weight_filler)
+}
+
+// optional .caffe.FillerParameter bias_filler = 3;
+bool RecurrentParameter::has_bias_filler() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void RecurrentParameter::set_has_bias_filler() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void RecurrentParameter::clear_has_bias_filler() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void RecurrentParameter::clear_bias_filler() {
+ if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
+ clear_has_bias_filler();
+}
+const ::caffe::FillerParameter& RecurrentParameter::bias_filler() const {
+ // @@protoc_insertion_point(field_get:caffe.RecurrentParameter.bias_filler)
+ return bias_filler_ != NULL ? *bias_filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+::caffe::FillerParameter* RecurrentParameter::mutable_bias_filler() {
+ set_has_bias_filler();
+ if (bias_filler_ == NULL) {
+ bias_filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.RecurrentParameter.bias_filler)
+ return bias_filler_;
+}
+::caffe::FillerParameter* RecurrentParameter::release_bias_filler() {
+ // @@protoc_insertion_point(field_release:caffe.RecurrentParameter.bias_filler)
+ clear_has_bias_filler();
+ ::caffe::FillerParameter* temp = bias_filler_;
+ bias_filler_ = NULL;
+ return temp;
+}
+void RecurrentParameter::set_allocated_bias_filler(::caffe::FillerParameter* bias_filler) {
+ delete bias_filler_;
+ bias_filler_ = bias_filler;
+ if (bias_filler) {
+ set_has_bias_filler();
+ } else {
+ clear_has_bias_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.RecurrentParameter.bias_filler)
+}
+
+// optional bool debug_info = 4 [default = false];
+bool RecurrentParameter::has_debug_info() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+void RecurrentParameter::set_has_debug_info() {
+ _has_bits_[0] |= 0x00000008u;
+}
+void RecurrentParameter::clear_has_debug_info() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+void RecurrentParameter::clear_debug_info() {
+ debug_info_ = false;
+ clear_has_debug_info();
+}
+bool RecurrentParameter::debug_info() const {
+ // @@protoc_insertion_point(field_get:caffe.RecurrentParameter.debug_info)
+ return debug_info_;
+}
+void RecurrentParameter::set_debug_info(bool value) {
+ set_has_debug_info();
+ debug_info_ = value;
+ // @@protoc_insertion_point(field_set:caffe.RecurrentParameter.debug_info)
+}
+
+// optional bool expose_hidden = 5 [default = false];
+bool RecurrentParameter::has_expose_hidden() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+void RecurrentParameter::set_has_expose_hidden() {
+ _has_bits_[0] |= 0x00000010u;
+}
+void RecurrentParameter::clear_has_expose_hidden() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+void RecurrentParameter::clear_expose_hidden() {
+ expose_hidden_ = false;
+ clear_has_expose_hidden();
+}
+bool RecurrentParameter::expose_hidden() const {
+ // @@protoc_insertion_point(field_get:caffe.RecurrentParameter.expose_hidden)
+ return expose_hidden_;
+}
+void RecurrentParameter::set_expose_hidden(bool value) {
+ set_has_expose_hidden();
+ expose_hidden_ = value;
+ // @@protoc_insertion_point(field_set:caffe.RecurrentParameter.expose_hidden)
+}
+
+inline const RecurrentParameter* RecurrentParameter::internal_default_instance() {
+ return &RecurrentParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+const ::google::protobuf::EnumDescriptor* ReductionParameter_ReductionOp_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return ReductionParameter_ReductionOp_descriptor_;
+}
+bool ReductionParameter_ReductionOp_IsValid(int value) {
+ switch (value) {
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const ReductionParameter_ReductionOp ReductionParameter::SUM;
+const ReductionParameter_ReductionOp ReductionParameter::ASUM;
+const ReductionParameter_ReductionOp ReductionParameter::SUMSQ;
+const ReductionParameter_ReductionOp ReductionParameter::MEAN;
+const ReductionParameter_ReductionOp ReductionParameter::ReductionOp_MIN;
+const ReductionParameter_ReductionOp ReductionParameter::ReductionOp_MAX;
+const int ReductionParameter::ReductionOp_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int ReductionParameter::kOperationFieldNumber;
+const int ReductionParameter::kAxisFieldNumber;
+const int ReductionParameter::kCoeffFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+ReductionParameter::ReductionParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.ReductionParameter)
+}
+
+void ReductionParameter::InitAsDefaultInstance() {
+}
+
+ReductionParameter::ReductionParameter(const ReductionParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.ReductionParameter)
+}
+
+void ReductionParameter::SharedCtor() {
+ _cached_size_ = 0;
+ axis_ = 0;
+ operation_ = 1;
+ coeff_ = 1;
+}
+
+ReductionParameter::~ReductionParameter() {
+ // @@protoc_insertion_point(destructor:caffe.ReductionParameter)
+ SharedDtor();
+}
+
+void ReductionParameter::SharedDtor() {
+}
+
+void ReductionParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* ReductionParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return ReductionParameter_descriptor_;
+}
+
+const ReductionParameter& ReductionParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<ReductionParameter> ReductionParameter_default_instance_;
+
+ReductionParameter* ReductionParameter::New(::google::protobuf::Arena* arena) const {
+ ReductionParameter* n = new ReductionParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void ReductionParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.ReductionParameter)
+ if (_has_bits_[0 / 32] & 7u) {
+ operation_ = 1;
+ axis_ = 0;
+ coeff_ = 1;
+ }
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool ReductionParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.ReductionParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional .caffe.ReductionParameter.ReductionOp operation = 1 [default = SUM];
+ case 1: {
+ if (tag == 8) {
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::ReductionParameter_ReductionOp_IsValid(value)) {
+ set_operation(static_cast< ::caffe::ReductionParameter_ReductionOp >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(1, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_axis;
+ break;
+ }
+
+ // optional int32 axis = 2 [default = 0];
+ case 2: {
+ if (tag == 16) {
+ parse_axis:
+ set_has_axis();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &axis_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(29)) goto parse_coeff;
+ break;
+ }
+
+ // optional float coeff = 3 [default = 1];
+ case 3: {
+ if (tag == 29) {
+ parse_coeff:
+ set_has_coeff();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &coeff_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.ReductionParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.ReductionParameter)
+ return false;
+#undef DO_
+}
+
+void ReductionParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.ReductionParameter)
+ // optional .caffe.ReductionParameter.ReductionOp operation = 1 [default = SUM];
+ if (has_operation()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 1, this->operation(), output);
+ }
+
+ // optional int32 axis = 2 [default = 0];
+ if (has_axis()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->axis(), output);
+ }
+
+ // optional float coeff = 3 [default = 1];
+ if (has_coeff()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->coeff(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.ReductionParameter)
+}
+
+::google::protobuf::uint8* ReductionParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.ReductionParameter)
+ // optional .caffe.ReductionParameter.ReductionOp operation = 1 [default = SUM];
+ if (has_operation()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 1, this->operation(), target);
+ }
+
+ // optional int32 axis = 2 [default = 0];
+ if (has_axis()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->axis(), target);
+ }
+
+ // optional float coeff = 3 [default = 1];
+ if (has_coeff()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->coeff(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.ReductionParameter)
+ return target;
+}
+
+size_t ReductionParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.ReductionParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 7u) {
+ // optional .caffe.ReductionParameter.ReductionOp operation = 1 [default = SUM];
+ if (has_operation()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->operation());
+ }
+
+ // optional int32 axis = 2 [default = 0];
+ if (has_axis()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->axis());
+ }
+
+ // optional float coeff = 3 [default = 1];
+ if (has_coeff()) {
+ total_size += 1 + 4;
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void ReductionParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.ReductionParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const ReductionParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const ReductionParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ReductionParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ReductionParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void ReductionParameter::MergeFrom(const ReductionParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ReductionParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void ReductionParameter::UnsafeMergeFrom(const ReductionParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_operation()) {
+ set_operation(from.operation());
+ }
+ if (from.has_axis()) {
+ set_axis(from.axis());
+ }
+ if (from.has_coeff()) {
+ set_coeff(from.coeff());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void ReductionParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.ReductionParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void ReductionParameter::CopyFrom(const ReductionParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ReductionParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool ReductionParameter::IsInitialized() const {
+
+ return true;
+}
+
+void ReductionParameter::Swap(ReductionParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void ReductionParameter::InternalSwap(ReductionParameter* other) {
+ std::swap(operation_, other->operation_);
+ std::swap(axis_, other->axis_);
+ std::swap(coeff_, other->coeff_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata ReductionParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = ReductionParameter_descriptor_;
+ metadata.reflection = ReductionParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// ReductionParameter
+
+// optional .caffe.ReductionParameter.ReductionOp operation = 1 [default = SUM];
+bool ReductionParameter::has_operation() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void ReductionParameter::set_has_operation() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void ReductionParameter::clear_has_operation() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void ReductionParameter::clear_operation() {
+ operation_ = 1;
+ clear_has_operation();
+}
+::caffe::ReductionParameter_ReductionOp ReductionParameter::operation() const {
+ // @@protoc_insertion_point(field_get:caffe.ReductionParameter.operation)
+ return static_cast< ::caffe::ReductionParameter_ReductionOp >(operation_);
+}
+void ReductionParameter::set_operation(::caffe::ReductionParameter_ReductionOp value) {
+ assert(::caffe::ReductionParameter_ReductionOp_IsValid(value));
+ set_has_operation();
+ operation_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ReductionParameter.operation)
+}
+
+// optional int32 axis = 2 [default = 0];
+bool ReductionParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void ReductionParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void ReductionParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void ReductionParameter::clear_axis() {
+ axis_ = 0;
+ clear_has_axis();
+}
+::google::protobuf::int32 ReductionParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.ReductionParameter.axis)
+ return axis_;
+}
+void ReductionParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ReductionParameter.axis)
+}
+
+// optional float coeff = 3 [default = 1];
+bool ReductionParameter::has_coeff() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void ReductionParameter::set_has_coeff() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void ReductionParameter::clear_has_coeff() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void ReductionParameter::clear_coeff() {
+ coeff_ = 1;
+ clear_has_coeff();
+}
+float ReductionParameter::coeff() const {
+ // @@protoc_insertion_point(field_get:caffe.ReductionParameter.coeff)
+ return coeff_;
+}
+void ReductionParameter::set_coeff(float value) {
+ set_has_coeff();
+ coeff_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ReductionParameter.coeff)
+}
+
+inline const ReductionParameter* ReductionParameter::internal_default_instance() {
+ return &ReductionParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+const ::google::protobuf::EnumDescriptor* ReLUParameter_Engine_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return ReLUParameter_Engine_descriptor_;
+}
+bool ReLUParameter_Engine_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ case 2:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const ReLUParameter_Engine ReLUParameter::DEFAULT;
+const ReLUParameter_Engine ReLUParameter::CAFFE;
+const ReLUParameter_Engine ReLUParameter::CUDNN;
+const ReLUParameter_Engine ReLUParameter::Engine_MIN;
+const ReLUParameter_Engine ReLUParameter::Engine_MAX;
+const int ReLUParameter::Engine_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int ReLUParameter::kNegativeSlopeFieldNumber;
+const int ReLUParameter::kEngineFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+ReLUParameter::ReLUParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.ReLUParameter)
+}
+
+void ReLUParameter::InitAsDefaultInstance() {
+}
+
+ReLUParameter::ReLUParameter(const ReLUParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.ReLUParameter)
+}
+
+void ReLUParameter::SharedCtor() {
+ _cached_size_ = 0;
+ ::memset(&negative_slope_, 0, reinterpret_cast<char*>(&engine_) -
+ reinterpret_cast<char*>(&negative_slope_) + sizeof(engine_));
+}
+
+ReLUParameter::~ReLUParameter() {
+ // @@protoc_insertion_point(destructor:caffe.ReLUParameter)
+ SharedDtor();
+}
+
+void ReLUParameter::SharedDtor() {
+}
+
+void ReLUParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* ReLUParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return ReLUParameter_descriptor_;
+}
+
+const ReLUParameter& ReLUParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<ReLUParameter> ReLUParameter_default_instance_;
+
+ReLUParameter* ReLUParameter::New(::google::protobuf::Arena* arena) const {
+ ReLUParameter* n = new ReLUParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void ReLUParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.ReLUParameter)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(ReLUParameter, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<ReLUParameter*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ ZR_(negative_slope_, engine_);
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool ReLUParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.ReLUParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional float negative_slope = 1 [default = 0];
+ case 1: {
+ if (tag == 13) {
+ set_has_negative_slope();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &negative_slope_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_engine;
+ break;
+ }
+
+ // optional .caffe.ReLUParameter.Engine engine = 2 [default = DEFAULT];
+ case 2: {
+ if (tag == 16) {
+ parse_engine:
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::ReLUParameter_Engine_IsValid(value)) {
+ set_engine(static_cast< ::caffe::ReLUParameter_Engine >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(2, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.ReLUParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.ReLUParameter)
+ return false;
+#undef DO_
+}
+
+void ReLUParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.ReLUParameter)
+ // optional float negative_slope = 1 [default = 0];
+ if (has_negative_slope()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->negative_slope(), output);
+ }
+
+ // optional .caffe.ReLUParameter.Engine engine = 2 [default = DEFAULT];
+ if (has_engine()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 2, this->engine(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.ReLUParameter)
+}
+
+::google::protobuf::uint8* ReLUParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.ReLUParameter)
+ // optional float negative_slope = 1 [default = 0];
+ if (has_negative_slope()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->negative_slope(), target);
+ }
+
+ // optional .caffe.ReLUParameter.Engine engine = 2 [default = DEFAULT];
+ if (has_engine()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 2, this->engine(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.ReLUParameter)
+ return target;
+}
+
+size_t ReLUParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.ReLUParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 3u) {
+ // optional float negative_slope = 1 [default = 0];
+ if (has_negative_slope()) {
+ total_size += 1 + 4;
+ }
+
+ // optional .caffe.ReLUParameter.Engine engine = 2 [default = DEFAULT];
+ if (has_engine()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->engine());
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void ReLUParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.ReLUParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const ReLUParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const ReLUParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ReLUParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ReLUParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void ReLUParameter::MergeFrom(const ReLUParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ReLUParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void ReLUParameter::UnsafeMergeFrom(const ReLUParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_negative_slope()) {
+ set_negative_slope(from.negative_slope());
+ }
+ if (from.has_engine()) {
+ set_engine(from.engine());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void ReLUParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.ReLUParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void ReLUParameter::CopyFrom(const ReLUParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ReLUParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool ReLUParameter::IsInitialized() const {
+
+ return true;
+}
+
+void ReLUParameter::Swap(ReLUParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void ReLUParameter::InternalSwap(ReLUParameter* other) {
+ std::swap(negative_slope_, other->negative_slope_);
+ std::swap(engine_, other->engine_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata ReLUParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = ReLUParameter_descriptor_;
+ metadata.reflection = ReLUParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// ReLUParameter
+
+// optional float negative_slope = 1 [default = 0];
+bool ReLUParameter::has_negative_slope() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void ReLUParameter::set_has_negative_slope() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void ReLUParameter::clear_has_negative_slope() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void ReLUParameter::clear_negative_slope() {
+ negative_slope_ = 0;
+ clear_has_negative_slope();
+}
+float ReLUParameter::negative_slope() const {
+ // @@protoc_insertion_point(field_get:caffe.ReLUParameter.negative_slope)
+ return negative_slope_;
+}
+void ReLUParameter::set_negative_slope(float value) {
+ set_has_negative_slope();
+ negative_slope_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ReLUParameter.negative_slope)
+}
+
+// optional .caffe.ReLUParameter.Engine engine = 2 [default = DEFAULT];
+bool ReLUParameter::has_engine() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void ReLUParameter::set_has_engine() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void ReLUParameter::clear_has_engine() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void ReLUParameter::clear_engine() {
+ engine_ = 0;
+ clear_has_engine();
+}
+::caffe::ReLUParameter_Engine ReLUParameter::engine() const {
+ // @@protoc_insertion_point(field_get:caffe.ReLUParameter.engine)
+ return static_cast< ::caffe::ReLUParameter_Engine >(engine_);
+}
+void ReLUParameter::set_engine(::caffe::ReLUParameter_Engine value) {
+ assert(::caffe::ReLUParameter_Engine_IsValid(value));
+ set_has_engine();
+ engine_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ReLUParameter.engine)
+}
+
+inline const ReLUParameter* ReLUParameter::internal_default_instance() {
+ return &ReLUParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int ReshapeParameter::kShapeFieldNumber;
+const int ReshapeParameter::kAxisFieldNumber;
+const int ReshapeParameter::kNumAxesFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+ReshapeParameter::ReshapeParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.ReshapeParameter)
+}
+
+void ReshapeParameter::InitAsDefaultInstance() {
+ shape_ = const_cast< ::caffe::BlobShape*>(
+ ::caffe::BlobShape::internal_default_instance());
+}
+
+ReshapeParameter::ReshapeParameter(const ReshapeParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.ReshapeParameter)
+}
+
+void ReshapeParameter::SharedCtor() {
+ _cached_size_ = 0;
+ shape_ = NULL;
+ axis_ = 0;
+ num_axes_ = -1;
+}
+
+ReshapeParameter::~ReshapeParameter() {
+ // @@protoc_insertion_point(destructor:caffe.ReshapeParameter)
+ SharedDtor();
+}
+
+void ReshapeParameter::SharedDtor() {
+ if (this != &ReshapeParameter_default_instance_.get()) {
+ delete shape_;
+ }
+}
+
+void ReshapeParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* ReshapeParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return ReshapeParameter_descriptor_;
+}
+
+const ReshapeParameter& ReshapeParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<ReshapeParameter> ReshapeParameter_default_instance_;
+
+ReshapeParameter* ReshapeParameter::New(::google::protobuf::Arena* arena) const {
+ ReshapeParameter* n = new ReshapeParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void ReshapeParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.ReshapeParameter)
+ if (_has_bits_[0 / 32] & 7u) {
+ if (has_shape()) {
+ if (shape_ != NULL) shape_->::caffe::BlobShape::Clear();
+ }
+ axis_ = 0;
+ num_axes_ = -1;
+ }
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool ReshapeParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.ReshapeParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional .caffe.BlobShape shape = 1;
+ case 1: {
+ if (tag == 10) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_shape()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_axis;
+ break;
+ }
+
+ // optional int32 axis = 2 [default = 0];
+ case 2: {
+ if (tag == 16) {
+ parse_axis:
+ set_has_axis();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &axis_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(24)) goto parse_num_axes;
+ break;
+ }
+
+ // optional int32 num_axes = 3 [default = -1];
+ case 3: {
+ if (tag == 24) {
+ parse_num_axes:
+ set_has_num_axes();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &num_axes_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.ReshapeParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.ReshapeParameter)
+ return false;
+#undef DO_
+}
+
+void ReshapeParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.ReshapeParameter)
+ // optional .caffe.BlobShape shape = 1;
+ if (has_shape()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 1, *this->shape_, output);
+ }
+
+ // optional int32 axis = 2 [default = 0];
+ if (has_axis()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->axis(), output);
+ }
+
+ // optional int32 num_axes = 3 [default = -1];
+ if (has_num_axes()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->num_axes(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.ReshapeParameter)
+}
+
+::google::protobuf::uint8* ReshapeParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.ReshapeParameter)
+ // optional .caffe.BlobShape shape = 1;
+ if (has_shape()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 1, *this->shape_, false, target);
+ }
+
+ // optional int32 axis = 2 [default = 0];
+ if (has_axis()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->axis(), target);
+ }
+
+ // optional int32 num_axes = 3 [default = -1];
+ if (has_num_axes()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->num_axes(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.ReshapeParameter)
+ return target;
+}
+
+size_t ReshapeParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.ReshapeParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 7u) {
+ // optional .caffe.BlobShape shape = 1;
+ if (has_shape()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->shape_);
+ }
+
+ // optional int32 axis = 2 [default = 0];
+ if (has_axis()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->axis());
+ }
+
+ // optional int32 num_axes = 3 [default = -1];
+ if (has_num_axes()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->num_axes());
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void ReshapeParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.ReshapeParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const ReshapeParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const ReshapeParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ReshapeParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ReshapeParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void ReshapeParameter::MergeFrom(const ReshapeParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ReshapeParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void ReshapeParameter::UnsafeMergeFrom(const ReshapeParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_shape()) {
+ mutable_shape()->::caffe::BlobShape::MergeFrom(from.shape());
+ }
+ if (from.has_axis()) {
+ set_axis(from.axis());
+ }
+ if (from.has_num_axes()) {
+ set_num_axes(from.num_axes());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void ReshapeParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.ReshapeParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void ReshapeParameter::CopyFrom(const ReshapeParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ReshapeParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool ReshapeParameter::IsInitialized() const {
+
+ return true;
+}
+
+void ReshapeParameter::Swap(ReshapeParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void ReshapeParameter::InternalSwap(ReshapeParameter* other) {
+ std::swap(shape_, other->shape_);
+ std::swap(axis_, other->axis_);
+ std::swap(num_axes_, other->num_axes_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata ReshapeParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = ReshapeParameter_descriptor_;
+ metadata.reflection = ReshapeParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// ReshapeParameter
+
+// optional .caffe.BlobShape shape = 1;
+bool ReshapeParameter::has_shape() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void ReshapeParameter::set_has_shape() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void ReshapeParameter::clear_has_shape() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void ReshapeParameter::clear_shape() {
+ if (shape_ != NULL) shape_->::caffe::BlobShape::Clear();
+ clear_has_shape();
+}
+const ::caffe::BlobShape& ReshapeParameter::shape() const {
+ // @@protoc_insertion_point(field_get:caffe.ReshapeParameter.shape)
+ return shape_ != NULL ? *shape_
+ : *::caffe::BlobShape::internal_default_instance();
+}
+::caffe::BlobShape* ReshapeParameter::mutable_shape() {
+ set_has_shape();
+ if (shape_ == NULL) {
+ shape_ = new ::caffe::BlobShape;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.ReshapeParameter.shape)
+ return shape_;
+}
+::caffe::BlobShape* ReshapeParameter::release_shape() {
+ // @@protoc_insertion_point(field_release:caffe.ReshapeParameter.shape)
+ clear_has_shape();
+ ::caffe::BlobShape* temp = shape_;
+ shape_ = NULL;
+ return temp;
+}
+void ReshapeParameter::set_allocated_shape(::caffe::BlobShape* shape) {
+ delete shape_;
+ shape_ = shape;
+ if (shape) {
+ set_has_shape();
+ } else {
+ clear_has_shape();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.ReshapeParameter.shape)
+}
+
+// optional int32 axis = 2 [default = 0];
+bool ReshapeParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void ReshapeParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void ReshapeParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void ReshapeParameter::clear_axis() {
+ axis_ = 0;
+ clear_has_axis();
+}
+::google::protobuf::int32 ReshapeParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.ReshapeParameter.axis)
+ return axis_;
+}
+void ReshapeParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ReshapeParameter.axis)
+}
+
+// optional int32 num_axes = 3 [default = -1];
+bool ReshapeParameter::has_num_axes() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void ReshapeParameter::set_has_num_axes() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void ReshapeParameter::clear_has_num_axes() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void ReshapeParameter::clear_num_axes() {
+ num_axes_ = -1;
+ clear_has_num_axes();
+}
+::google::protobuf::int32 ReshapeParameter::num_axes() const {
+ // @@protoc_insertion_point(field_get:caffe.ReshapeParameter.num_axes)
+ return num_axes_;
+}
+void ReshapeParameter::set_num_axes(::google::protobuf::int32 value) {
+ set_has_num_axes();
+ num_axes_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ReshapeParameter.num_axes)
+}
+
+inline const ReshapeParameter* ReshapeParameter::internal_default_instance() {
+ return &ReshapeParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int ScaleParameter::kAxisFieldNumber;
+const int ScaleParameter::kNumAxesFieldNumber;
+const int ScaleParameter::kFillerFieldNumber;
+const int ScaleParameter::kBiasTermFieldNumber;
+const int ScaleParameter::kBiasFillerFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+ScaleParameter::ScaleParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.ScaleParameter)
+}
+
+void ScaleParameter::InitAsDefaultInstance() {
+ filler_ = const_cast< ::caffe::FillerParameter*>(
+ ::caffe::FillerParameter::internal_default_instance());
+ bias_filler_ = const_cast< ::caffe::FillerParameter*>(
+ ::caffe::FillerParameter::internal_default_instance());
+}
+
+ScaleParameter::ScaleParameter(const ScaleParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.ScaleParameter)
+}
+
+void ScaleParameter::SharedCtor() {
+ _cached_size_ = 0;
+ filler_ = NULL;
+ bias_filler_ = NULL;
+ bias_term_ = false;
+ axis_ = 1;
+ num_axes_ = 1;
+}
+
+ScaleParameter::~ScaleParameter() {
+ // @@protoc_insertion_point(destructor:caffe.ScaleParameter)
+ SharedDtor();
+}
+
+void ScaleParameter::SharedDtor() {
+ if (this != &ScaleParameter_default_instance_.get()) {
+ delete filler_;
+ delete bias_filler_;
+ }
+}
+
+void ScaleParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* ScaleParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return ScaleParameter_descriptor_;
+}
+
+const ScaleParameter& ScaleParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<ScaleParameter> ScaleParameter_default_instance_;
+
+ScaleParameter* ScaleParameter::New(::google::protobuf::Arena* arena) const {
+ ScaleParameter* n = new ScaleParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void ScaleParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.ScaleParameter)
+ if (_has_bits_[0 / 32] & 31u) {
+ axis_ = 1;
+ num_axes_ = 1;
+ if (has_filler()) {
+ if (filler_ != NULL) filler_->::caffe::FillerParameter::Clear();
+ }
+ bias_term_ = false;
+ if (has_bias_filler()) {
+ if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
+ }
+ }
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool ScaleParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.ScaleParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional int32 axis = 1 [default = 1];
+ case 1: {
+ if (tag == 8) {
+ set_has_axis();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &axis_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_num_axes;
+ break;
+ }
+
+ // optional int32 num_axes = 2 [default = 1];
+ case 2: {
+ if (tag == 16) {
+ parse_num_axes:
+ set_has_num_axes();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &num_axes_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(26)) goto parse_filler;
+ break;
+ }
+
+ // optional .caffe.FillerParameter filler = 3;
+ case 3: {
+ if (tag == 26) {
+ parse_filler:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_filler()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(32)) goto parse_bias_term;
+ break;
+ }
+
+ // optional bool bias_term = 4 [default = false];
+ case 4: {
+ if (tag == 32) {
+ parse_bias_term:
+ set_has_bias_term();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &bias_term_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(42)) goto parse_bias_filler;
+ break;
+ }
+
+ // optional .caffe.FillerParameter bias_filler = 5;
+ case 5: {
+ if (tag == 42) {
+ parse_bias_filler:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_bias_filler()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.ScaleParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.ScaleParameter)
+ return false;
+#undef DO_
+}
+
+void ScaleParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.ScaleParameter)
+ // optional int32 axis = 1 [default = 1];
+ if (has_axis()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->axis(), output);
+ }
+
+ // optional int32 num_axes = 2 [default = 1];
+ if (has_num_axes()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->num_axes(), output);
+ }
+
+ // optional .caffe.FillerParameter filler = 3;
+ if (has_filler()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 3, *this->filler_, output);
+ }
+
+ // optional bool bias_term = 4 [default = false];
+ if (has_bias_term()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(4, this->bias_term(), output);
+ }
+
+ // optional .caffe.FillerParameter bias_filler = 5;
+ if (has_bias_filler()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 5, *this->bias_filler_, output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.ScaleParameter)
+}
+
+::google::protobuf::uint8* ScaleParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.ScaleParameter)
+ // optional int32 axis = 1 [default = 1];
+ if (has_axis()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->axis(), target);
+ }
+
+ // optional int32 num_axes = 2 [default = 1];
+ if (has_num_axes()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->num_axes(), target);
+ }
+
+ // optional .caffe.FillerParameter filler = 3;
+ if (has_filler()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 3, *this->filler_, false, target);
+ }
+
+ // optional bool bias_term = 4 [default = false];
+ if (has_bias_term()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(4, this->bias_term(), target);
+ }
+
+ // optional .caffe.FillerParameter bias_filler = 5;
+ if (has_bias_filler()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 5, *this->bias_filler_, false, target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.ScaleParameter)
+ return target;
+}
+
+size_t ScaleParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.ScaleParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 31u) {
+ // optional int32 axis = 1 [default = 1];
+ if (has_axis()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->axis());
+ }
+
+ // optional int32 num_axes = 2 [default = 1];
+ if (has_num_axes()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->num_axes());
+ }
+
+ // optional .caffe.FillerParameter filler = 3;
+ if (has_filler()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->filler_);
+ }
+
+ // optional bool bias_term = 4 [default = false];
+ if (has_bias_term()) {
+ total_size += 1 + 1;
+ }
+
+ // optional .caffe.FillerParameter bias_filler = 5;
+ if (has_bias_filler()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->bias_filler_);
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void ScaleParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.ScaleParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const ScaleParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const ScaleParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ScaleParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ScaleParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void ScaleParameter::MergeFrom(const ScaleParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ScaleParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void ScaleParameter::UnsafeMergeFrom(const ScaleParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_axis()) {
+ set_axis(from.axis());
+ }
+ if (from.has_num_axes()) {
+ set_num_axes(from.num_axes());
+ }
+ if (from.has_filler()) {
+ mutable_filler()->::caffe::FillerParameter::MergeFrom(from.filler());
+ }
+ if (from.has_bias_term()) {
+ set_bias_term(from.bias_term());
+ }
+ if (from.has_bias_filler()) {
+ mutable_bias_filler()->::caffe::FillerParameter::MergeFrom(from.bias_filler());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void ScaleParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.ScaleParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void ScaleParameter::CopyFrom(const ScaleParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ScaleParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool ScaleParameter::IsInitialized() const {
+
+ return true;
+}
+
+void ScaleParameter::Swap(ScaleParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void ScaleParameter::InternalSwap(ScaleParameter* other) {
+ std::swap(axis_, other->axis_);
+ std::swap(num_axes_, other->num_axes_);
+ std::swap(filler_, other->filler_);
+ std::swap(bias_term_, other->bias_term_);
+ std::swap(bias_filler_, other->bias_filler_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata ScaleParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = ScaleParameter_descriptor_;
+ metadata.reflection = ScaleParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// ScaleParameter
+
+// optional int32 axis = 1 [default = 1];
+bool ScaleParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void ScaleParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void ScaleParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void ScaleParameter::clear_axis() {
+ axis_ = 1;
+ clear_has_axis();
+}
+::google::protobuf::int32 ScaleParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.ScaleParameter.axis)
+ return axis_;
+}
+void ScaleParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ScaleParameter.axis)
+}
+
+// optional int32 num_axes = 2 [default = 1];
+bool ScaleParameter::has_num_axes() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void ScaleParameter::set_has_num_axes() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void ScaleParameter::clear_has_num_axes() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void ScaleParameter::clear_num_axes() {
+ num_axes_ = 1;
+ clear_has_num_axes();
+}
+::google::protobuf::int32 ScaleParameter::num_axes() const {
+ // @@protoc_insertion_point(field_get:caffe.ScaleParameter.num_axes)
+ return num_axes_;
+}
+void ScaleParameter::set_num_axes(::google::protobuf::int32 value) {
+ set_has_num_axes();
+ num_axes_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ScaleParameter.num_axes)
+}
+
+// optional .caffe.FillerParameter filler = 3;
+bool ScaleParameter::has_filler() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void ScaleParameter::set_has_filler() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void ScaleParameter::clear_has_filler() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void ScaleParameter::clear_filler() {
+ if (filler_ != NULL) filler_->::caffe::FillerParameter::Clear();
+ clear_has_filler();
+}
+const ::caffe::FillerParameter& ScaleParameter::filler() const {
+ // @@protoc_insertion_point(field_get:caffe.ScaleParameter.filler)
+ return filler_ != NULL ? *filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+::caffe::FillerParameter* ScaleParameter::mutable_filler() {
+ set_has_filler();
+ if (filler_ == NULL) {
+ filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.ScaleParameter.filler)
+ return filler_;
+}
+::caffe::FillerParameter* ScaleParameter::release_filler() {
+ // @@protoc_insertion_point(field_release:caffe.ScaleParameter.filler)
+ clear_has_filler();
+ ::caffe::FillerParameter* temp = filler_;
+ filler_ = NULL;
+ return temp;
+}
+void ScaleParameter::set_allocated_filler(::caffe::FillerParameter* filler) {
+ delete filler_;
+ filler_ = filler;
+ if (filler) {
+ set_has_filler();
+ } else {
+ clear_has_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.ScaleParameter.filler)
+}
+
+// optional bool bias_term = 4 [default = false];
+bool ScaleParameter::has_bias_term() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+void ScaleParameter::set_has_bias_term() {
+ _has_bits_[0] |= 0x00000008u;
+}
+void ScaleParameter::clear_has_bias_term() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+void ScaleParameter::clear_bias_term() {
+ bias_term_ = false;
+ clear_has_bias_term();
+}
+bool ScaleParameter::bias_term() const {
+ // @@protoc_insertion_point(field_get:caffe.ScaleParameter.bias_term)
+ return bias_term_;
+}
+void ScaleParameter::set_bias_term(bool value) {
+ set_has_bias_term();
+ bias_term_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ScaleParameter.bias_term)
+}
+
+// optional .caffe.FillerParameter bias_filler = 5;
+bool ScaleParameter::has_bias_filler() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+void ScaleParameter::set_has_bias_filler() {
+ _has_bits_[0] |= 0x00000010u;
+}
+void ScaleParameter::clear_has_bias_filler() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+void ScaleParameter::clear_bias_filler() {
+ if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
+ clear_has_bias_filler();
+}
+const ::caffe::FillerParameter& ScaleParameter::bias_filler() const {
+ // @@protoc_insertion_point(field_get:caffe.ScaleParameter.bias_filler)
+ return bias_filler_ != NULL ? *bias_filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+::caffe::FillerParameter* ScaleParameter::mutable_bias_filler() {
+ set_has_bias_filler();
+ if (bias_filler_ == NULL) {
+ bias_filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.ScaleParameter.bias_filler)
+ return bias_filler_;
+}
+::caffe::FillerParameter* ScaleParameter::release_bias_filler() {
+ // @@protoc_insertion_point(field_release:caffe.ScaleParameter.bias_filler)
+ clear_has_bias_filler();
+ ::caffe::FillerParameter* temp = bias_filler_;
+ bias_filler_ = NULL;
+ return temp;
+}
+void ScaleParameter::set_allocated_bias_filler(::caffe::FillerParameter* bias_filler) {
+ delete bias_filler_;
+ bias_filler_ = bias_filler;
+ if (bias_filler) {
+ set_has_bias_filler();
+ } else {
+ clear_has_bias_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.ScaleParameter.bias_filler)
+}
+
+inline const ScaleParameter* ScaleParameter::internal_default_instance() {
+ return &ScaleParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+const ::google::protobuf::EnumDescriptor* SigmoidParameter_Engine_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return SigmoidParameter_Engine_descriptor_;
+}
+bool SigmoidParameter_Engine_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ case 2:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const SigmoidParameter_Engine SigmoidParameter::DEFAULT;
+const SigmoidParameter_Engine SigmoidParameter::CAFFE;
+const SigmoidParameter_Engine SigmoidParameter::CUDNN;
+const SigmoidParameter_Engine SigmoidParameter::Engine_MIN;
+const SigmoidParameter_Engine SigmoidParameter::Engine_MAX;
+const int SigmoidParameter::Engine_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int SigmoidParameter::kEngineFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+SigmoidParameter::SigmoidParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.SigmoidParameter)
+}
+
+void SigmoidParameter::InitAsDefaultInstance() {
+}
+
+SigmoidParameter::SigmoidParameter(const SigmoidParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.SigmoidParameter)
+}
+
+void SigmoidParameter::SharedCtor() {
+ _cached_size_ = 0;
+ engine_ = 0;
+}
+
+SigmoidParameter::~SigmoidParameter() {
+ // @@protoc_insertion_point(destructor:caffe.SigmoidParameter)
+ SharedDtor();
+}
+
+void SigmoidParameter::SharedDtor() {
+}
+
+void SigmoidParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* SigmoidParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return SigmoidParameter_descriptor_;
+}
+
+const SigmoidParameter& SigmoidParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<SigmoidParameter> SigmoidParameter_default_instance_;
+
+SigmoidParameter* SigmoidParameter::New(::google::protobuf::Arena* arena) const {
+ SigmoidParameter* n = new SigmoidParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void SigmoidParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.SigmoidParameter)
+ engine_ = 0;
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool SigmoidParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.SigmoidParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional .caffe.SigmoidParameter.Engine engine = 1 [default = DEFAULT];
+ case 1: {
+ if (tag == 8) {
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::SigmoidParameter_Engine_IsValid(value)) {
+ set_engine(static_cast< ::caffe::SigmoidParameter_Engine >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(1, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.SigmoidParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.SigmoidParameter)
+ return false;
+#undef DO_
+}
+
+void SigmoidParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.SigmoidParameter)
+ // optional .caffe.SigmoidParameter.Engine engine = 1 [default = DEFAULT];
+ if (has_engine()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 1, this->engine(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.SigmoidParameter)
+}
+
+::google::protobuf::uint8* SigmoidParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.SigmoidParameter)
+ // optional .caffe.SigmoidParameter.Engine engine = 1 [default = DEFAULT];
+ if (has_engine()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 1, this->engine(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.SigmoidParameter)
+ return target;
+}
+
+size_t SigmoidParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.SigmoidParameter)
+ size_t total_size = 0;
+
+ // optional .caffe.SigmoidParameter.Engine engine = 1 [default = DEFAULT];
+ if (has_engine()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->engine());
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void SigmoidParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.SigmoidParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const SigmoidParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const SigmoidParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.SigmoidParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.SigmoidParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void SigmoidParameter::MergeFrom(const SigmoidParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.SigmoidParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void SigmoidParameter::UnsafeMergeFrom(const SigmoidParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_engine()) {
+ set_engine(from.engine());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void SigmoidParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.SigmoidParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void SigmoidParameter::CopyFrom(const SigmoidParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.SigmoidParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool SigmoidParameter::IsInitialized() const {
+
+ return true;
+}
+
+void SigmoidParameter::Swap(SigmoidParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void SigmoidParameter::InternalSwap(SigmoidParameter* other) {
+ std::swap(engine_, other->engine_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata SigmoidParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = SigmoidParameter_descriptor_;
+ metadata.reflection = SigmoidParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// SigmoidParameter
+
+// optional .caffe.SigmoidParameter.Engine engine = 1 [default = DEFAULT];
+bool SigmoidParameter::has_engine() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void SigmoidParameter::set_has_engine() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void SigmoidParameter::clear_has_engine() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void SigmoidParameter::clear_engine() {
+ engine_ = 0;
+ clear_has_engine();
+}
+::caffe::SigmoidParameter_Engine SigmoidParameter::engine() const {
+ // @@protoc_insertion_point(field_get:caffe.SigmoidParameter.engine)
+ return static_cast< ::caffe::SigmoidParameter_Engine >(engine_);
+}
+void SigmoidParameter::set_engine(::caffe::SigmoidParameter_Engine value) {
+ assert(::caffe::SigmoidParameter_Engine_IsValid(value));
+ set_has_engine();
+ engine_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SigmoidParameter.engine)
+}
+
+inline const SigmoidParameter* SigmoidParameter::internal_default_instance() {
+ return &SigmoidParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int SliceParameter::kAxisFieldNumber;
+const int SliceParameter::kSlicePointFieldNumber;
+const int SliceParameter::kSliceDimFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+SliceParameter::SliceParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.SliceParameter)
+}
+
+void SliceParameter::InitAsDefaultInstance() {
+}
+
+SliceParameter::SliceParameter(const SliceParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.SliceParameter)
+}
+
+void SliceParameter::SharedCtor() {
+ _cached_size_ = 0;
+ axis_ = 1;
+ slice_dim_ = 1u;
+}
+
+SliceParameter::~SliceParameter() {
+ // @@protoc_insertion_point(destructor:caffe.SliceParameter)
+ SharedDtor();
+}
+
+void SliceParameter::SharedDtor() {
+}
+
+void SliceParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* SliceParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return SliceParameter_descriptor_;
+}
+
+const SliceParameter& SliceParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<SliceParameter> SliceParameter_default_instance_;
+
+SliceParameter* SliceParameter::New(::google::protobuf::Arena* arena) const {
+ SliceParameter* n = new SliceParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void SliceParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.SliceParameter)
+ if (_has_bits_[0 / 32] & 5u) {
+ axis_ = 1;
+ slice_dim_ = 1u;
+ }
+ slice_point_.Clear();
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool SliceParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.SliceParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional uint32 slice_dim = 1 [default = 1];
+ case 1: {
+ if (tag == 8) {
+ set_has_slice_dim();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &slice_dim_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_slice_point;
+ break;
+ }
+
+ // repeated uint32 slice_point = 2;
+ case 2: {
+ if (tag == 16) {
+ parse_slice_point:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ 1, 16, input, this->mutable_slice_point())));
+ } else if (tag == 18) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, this->mutable_slice_point())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_slice_point;
+ if (input->ExpectTag(24)) goto parse_axis;
+ break;
+ }
+
+ // optional int32 axis = 3 [default = 1];
+ case 3: {
+ if (tag == 24) {
+ parse_axis:
+ set_has_axis();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &axis_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.SliceParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.SliceParameter)
+ return false;
+#undef DO_
+}
+
+void SliceParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.SliceParameter)
+ // optional uint32 slice_dim = 1 [default = 1];
+ if (has_slice_dim()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->slice_dim(), output);
+ }
+
+ // repeated uint32 slice_point = 2;
+ for (int i = 0; i < this->slice_point_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(
+ 2, this->slice_point(i), output);
+ }
+
+ // optional int32 axis = 3 [default = 1];
+ if (has_axis()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->axis(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.SliceParameter)
+}
+
+::google::protobuf::uint8* SliceParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.SliceParameter)
+ // optional uint32 slice_dim = 1 [default = 1];
+ if (has_slice_dim()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->slice_dim(), target);
+ }
+
+ // repeated uint32 slice_point = 2;
+ for (int i = 0; i < this->slice_point_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteUInt32ToArray(2, this->slice_point(i), target);
+ }
+
+ // optional int32 axis = 3 [default = 1];
+ if (has_axis()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->axis(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.SliceParameter)
+ return target;
+}
+
+size_t SliceParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.SliceParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 5u) {
+ // optional int32 axis = 3 [default = 1];
+ if (has_axis()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->axis());
+ }
+
+ // optional uint32 slice_dim = 1 [default = 1];
+ if (has_slice_dim()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->slice_dim());
+ }
+
+ }
+ // repeated uint32 slice_point = 2;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->slice_point_size();
+ for (unsigned int i = 0; i < count; i++) {
+ data_size += ::google::protobuf::internal::WireFormatLite::
+ UInt32Size(this->slice_point(i));
+ }
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->slice_point_size());
+ total_size += data_size;
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void SliceParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.SliceParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const SliceParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const SliceParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.SliceParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.SliceParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void SliceParameter::MergeFrom(const SliceParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.SliceParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void SliceParameter::UnsafeMergeFrom(const SliceParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ slice_point_.UnsafeMergeFrom(from.slice_point_);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_axis()) {
+ set_axis(from.axis());
+ }
+ if (from.has_slice_dim()) {
+ set_slice_dim(from.slice_dim());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void SliceParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.SliceParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void SliceParameter::CopyFrom(const SliceParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.SliceParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool SliceParameter::IsInitialized() const {
+
+ return true;
+}
+
+void SliceParameter::Swap(SliceParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void SliceParameter::InternalSwap(SliceParameter* other) {
+ std::swap(axis_, other->axis_);
+ slice_point_.UnsafeArenaSwap(&other->slice_point_);
+ std::swap(slice_dim_, other->slice_dim_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata SliceParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = SliceParameter_descriptor_;
+ metadata.reflection = SliceParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// SliceParameter
+
+// optional int32 axis = 3 [default = 1];
+bool SliceParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void SliceParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void SliceParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void SliceParameter::clear_axis() {
+ axis_ = 1;
+ clear_has_axis();
+}
+::google::protobuf::int32 SliceParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.SliceParameter.axis)
+ return axis_;
+}
+void SliceParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SliceParameter.axis)
+}
+
+// repeated uint32 slice_point = 2;
+int SliceParameter::slice_point_size() const {
+ return slice_point_.size();
+}
+void SliceParameter::clear_slice_point() {
+ slice_point_.Clear();
+}
+::google::protobuf::uint32 SliceParameter::slice_point(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.SliceParameter.slice_point)
+ return slice_point_.Get(index);
+}
+void SliceParameter::set_slice_point(int index, ::google::protobuf::uint32 value) {
+ slice_point_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.SliceParameter.slice_point)
+}
+void SliceParameter::add_slice_point(::google::protobuf::uint32 value) {
+ slice_point_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.SliceParameter.slice_point)
+}
+const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+SliceParameter::slice_point() const {
+ // @@protoc_insertion_point(field_list:caffe.SliceParameter.slice_point)
+ return slice_point_;
+}
+::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+SliceParameter::mutable_slice_point() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.SliceParameter.slice_point)
+ return &slice_point_;
+}
+
+// optional uint32 slice_dim = 1 [default = 1];
+bool SliceParameter::has_slice_dim() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void SliceParameter::set_has_slice_dim() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void SliceParameter::clear_has_slice_dim() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void SliceParameter::clear_slice_dim() {
+ slice_dim_ = 1u;
+ clear_has_slice_dim();
+}
+::google::protobuf::uint32 SliceParameter::slice_dim() const {
+ // @@protoc_insertion_point(field_get:caffe.SliceParameter.slice_dim)
+ return slice_dim_;
+}
+void SliceParameter::set_slice_dim(::google::protobuf::uint32 value) {
+ set_has_slice_dim();
+ slice_dim_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SliceParameter.slice_dim)
+}
+
+inline const SliceParameter* SliceParameter::internal_default_instance() {
+ return &SliceParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+const ::google::protobuf::EnumDescriptor* SoftmaxParameter_Engine_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return SoftmaxParameter_Engine_descriptor_;
+}
+bool SoftmaxParameter_Engine_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ case 2:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const SoftmaxParameter_Engine SoftmaxParameter::DEFAULT;
+const SoftmaxParameter_Engine SoftmaxParameter::CAFFE;
+const SoftmaxParameter_Engine SoftmaxParameter::CUDNN;
+const SoftmaxParameter_Engine SoftmaxParameter::Engine_MIN;
+const SoftmaxParameter_Engine SoftmaxParameter::Engine_MAX;
+const int SoftmaxParameter::Engine_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int SoftmaxParameter::kEngineFieldNumber;
+const int SoftmaxParameter::kAxisFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+SoftmaxParameter::SoftmaxParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.SoftmaxParameter)
+}
+
+void SoftmaxParameter::InitAsDefaultInstance() {
+}
+
+SoftmaxParameter::SoftmaxParameter(const SoftmaxParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.SoftmaxParameter)
+}
+
+void SoftmaxParameter::SharedCtor() {
+ _cached_size_ = 0;
+ engine_ = 0;
+ axis_ = 1;
+}
+
+SoftmaxParameter::~SoftmaxParameter() {
+ // @@protoc_insertion_point(destructor:caffe.SoftmaxParameter)
+ SharedDtor();
+}
+
+void SoftmaxParameter::SharedDtor() {
+}
+
+void SoftmaxParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* SoftmaxParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return SoftmaxParameter_descriptor_;
+}
+
+const SoftmaxParameter& SoftmaxParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<SoftmaxParameter> SoftmaxParameter_default_instance_;
+
+SoftmaxParameter* SoftmaxParameter::New(::google::protobuf::Arena* arena) const {
+ SoftmaxParameter* n = new SoftmaxParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void SoftmaxParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.SoftmaxParameter)
+ if (_has_bits_[0 / 32] & 3u) {
+ engine_ = 0;
+ axis_ = 1;
+ }
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool SoftmaxParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.SoftmaxParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional .caffe.SoftmaxParameter.Engine engine = 1 [default = DEFAULT];
+ case 1: {
+ if (tag == 8) {
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::SoftmaxParameter_Engine_IsValid(value)) {
+ set_engine(static_cast< ::caffe::SoftmaxParameter_Engine >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(1, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_axis;
+ break;
+ }
+
+ // optional int32 axis = 2 [default = 1];
+ case 2: {
+ if (tag == 16) {
+ parse_axis:
+ set_has_axis();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &axis_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.SoftmaxParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.SoftmaxParameter)
+ return false;
+#undef DO_
+}
+
+void SoftmaxParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.SoftmaxParameter)
+ // optional .caffe.SoftmaxParameter.Engine engine = 1 [default = DEFAULT];
+ if (has_engine()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 1, this->engine(), output);
+ }
+
+ // optional int32 axis = 2 [default = 1];
+ if (has_axis()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->axis(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.SoftmaxParameter)
+}
+
+::google::protobuf::uint8* SoftmaxParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.SoftmaxParameter)
+ // optional .caffe.SoftmaxParameter.Engine engine = 1 [default = DEFAULT];
+ if (has_engine()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 1, this->engine(), target);
+ }
+
+ // optional int32 axis = 2 [default = 1];
+ if (has_axis()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->axis(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.SoftmaxParameter)
+ return target;
+}
+
+size_t SoftmaxParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.SoftmaxParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 3u) {
+ // optional .caffe.SoftmaxParameter.Engine engine = 1 [default = DEFAULT];
+ if (has_engine()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->engine());
+ }
+
+ // optional int32 axis = 2 [default = 1];
+ if (has_axis()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->axis());
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void SoftmaxParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.SoftmaxParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const SoftmaxParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const SoftmaxParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.SoftmaxParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.SoftmaxParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void SoftmaxParameter::MergeFrom(const SoftmaxParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.SoftmaxParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void SoftmaxParameter::UnsafeMergeFrom(const SoftmaxParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_engine()) {
+ set_engine(from.engine());
+ }
+ if (from.has_axis()) {
+ set_axis(from.axis());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void SoftmaxParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.SoftmaxParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void SoftmaxParameter::CopyFrom(const SoftmaxParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.SoftmaxParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool SoftmaxParameter::IsInitialized() const {
+
+ return true;
+}
+
+void SoftmaxParameter::Swap(SoftmaxParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void SoftmaxParameter::InternalSwap(SoftmaxParameter* other) {
+ std::swap(engine_, other->engine_);
+ std::swap(axis_, other->axis_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata SoftmaxParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = SoftmaxParameter_descriptor_;
+ metadata.reflection = SoftmaxParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// SoftmaxParameter
+
+// optional .caffe.SoftmaxParameter.Engine engine = 1 [default = DEFAULT];
+bool SoftmaxParameter::has_engine() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void SoftmaxParameter::set_has_engine() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void SoftmaxParameter::clear_has_engine() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void SoftmaxParameter::clear_engine() {
+ engine_ = 0;
+ clear_has_engine();
+}
+::caffe::SoftmaxParameter_Engine SoftmaxParameter::engine() const {
+ // @@protoc_insertion_point(field_get:caffe.SoftmaxParameter.engine)
+ return static_cast< ::caffe::SoftmaxParameter_Engine >(engine_);
+}
+void SoftmaxParameter::set_engine(::caffe::SoftmaxParameter_Engine value) {
+ assert(::caffe::SoftmaxParameter_Engine_IsValid(value));
+ set_has_engine();
+ engine_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SoftmaxParameter.engine)
+}
+
+// optional int32 axis = 2 [default = 1];
+bool SoftmaxParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void SoftmaxParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void SoftmaxParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void SoftmaxParameter::clear_axis() {
+ axis_ = 1;
+ clear_has_axis();
+}
+::google::protobuf::int32 SoftmaxParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.SoftmaxParameter.axis)
+ return axis_;
+}
+void SoftmaxParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SoftmaxParameter.axis)
+}
+
+inline const SoftmaxParameter* SoftmaxParameter::internal_default_instance() {
+ return &SoftmaxParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+const ::google::protobuf::EnumDescriptor* TanHParameter_Engine_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return TanHParameter_Engine_descriptor_;
+}
+bool TanHParameter_Engine_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ case 2:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const TanHParameter_Engine TanHParameter::DEFAULT;
+const TanHParameter_Engine TanHParameter::CAFFE;
+const TanHParameter_Engine TanHParameter::CUDNN;
+const TanHParameter_Engine TanHParameter::Engine_MIN;
+const TanHParameter_Engine TanHParameter::Engine_MAX;
+const int TanHParameter::Engine_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int TanHParameter::kEngineFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+TanHParameter::TanHParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.TanHParameter)
+}
+
+void TanHParameter::InitAsDefaultInstance() {
+}
+
+TanHParameter::TanHParameter(const TanHParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.TanHParameter)
+}
+
+void TanHParameter::SharedCtor() {
+ _cached_size_ = 0;
+ engine_ = 0;
+}
+
+TanHParameter::~TanHParameter() {
+ // @@protoc_insertion_point(destructor:caffe.TanHParameter)
+ SharedDtor();
+}
+
+void TanHParameter::SharedDtor() {
+}
+
+void TanHParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* TanHParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return TanHParameter_descriptor_;
+}
+
+const TanHParameter& TanHParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<TanHParameter> TanHParameter_default_instance_;
+
+TanHParameter* TanHParameter::New(::google::protobuf::Arena* arena) const {
+ TanHParameter* n = new TanHParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void TanHParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.TanHParameter)
+ engine_ = 0;
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool TanHParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.TanHParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional .caffe.TanHParameter.Engine engine = 1 [default = DEFAULT];
+ case 1: {
+ if (tag == 8) {
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::TanHParameter_Engine_IsValid(value)) {
+ set_engine(static_cast< ::caffe::TanHParameter_Engine >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(1, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.TanHParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.TanHParameter)
+ return false;
+#undef DO_
+}
+
+void TanHParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.TanHParameter)
+ // optional .caffe.TanHParameter.Engine engine = 1 [default = DEFAULT];
+ if (has_engine()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 1, this->engine(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.TanHParameter)
+}
+
+::google::protobuf::uint8* TanHParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.TanHParameter)
+ // optional .caffe.TanHParameter.Engine engine = 1 [default = DEFAULT];
+ if (has_engine()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 1, this->engine(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.TanHParameter)
+ return target;
+}
+
+size_t TanHParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.TanHParameter)
+ size_t total_size = 0;
+
+ // optional .caffe.TanHParameter.Engine engine = 1 [default = DEFAULT];
+ if (has_engine()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->engine());
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void TanHParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.TanHParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const TanHParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const TanHParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.TanHParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.TanHParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void TanHParameter::MergeFrom(const TanHParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.TanHParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void TanHParameter::UnsafeMergeFrom(const TanHParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_engine()) {
+ set_engine(from.engine());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void TanHParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.TanHParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void TanHParameter::CopyFrom(const TanHParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.TanHParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool TanHParameter::IsInitialized() const {
+
+ return true;
+}
+
+void TanHParameter::Swap(TanHParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void TanHParameter::InternalSwap(TanHParameter* other) {
+ std::swap(engine_, other->engine_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata TanHParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = TanHParameter_descriptor_;
+ metadata.reflection = TanHParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// TanHParameter
+
+// optional .caffe.TanHParameter.Engine engine = 1 [default = DEFAULT];
+bool TanHParameter::has_engine() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void TanHParameter::set_has_engine() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void TanHParameter::clear_has_engine() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void TanHParameter::clear_engine() {
+ engine_ = 0;
+ clear_has_engine();
+}
+::caffe::TanHParameter_Engine TanHParameter::engine() const {
+ // @@protoc_insertion_point(field_get:caffe.TanHParameter.engine)
+ return static_cast< ::caffe::TanHParameter_Engine >(engine_);
+}
+void TanHParameter::set_engine(::caffe::TanHParameter_Engine value) {
+ assert(::caffe::TanHParameter_Engine_IsValid(value));
+ set_has_engine();
+ engine_ = value;
+ // @@protoc_insertion_point(field_set:caffe.TanHParameter.engine)
+}
+
+inline const TanHParameter* TanHParameter::internal_default_instance() {
+ return &TanHParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int TileParameter::kAxisFieldNumber;
+const int TileParameter::kTilesFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+TileParameter::TileParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.TileParameter)
+}
+
+void TileParameter::InitAsDefaultInstance() {
+}
+
+TileParameter::TileParameter(const TileParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.TileParameter)
+}
+
+void TileParameter::SharedCtor() {
+ _cached_size_ = 0;
+ tiles_ = 0;
+ axis_ = 1;
+}
+
+TileParameter::~TileParameter() {
+ // @@protoc_insertion_point(destructor:caffe.TileParameter)
+ SharedDtor();
+}
+
+void TileParameter::SharedDtor() {
+}
+
+void TileParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* TileParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return TileParameter_descriptor_;
+}
+
+const TileParameter& TileParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<TileParameter> TileParameter_default_instance_;
+
+TileParameter* TileParameter::New(::google::protobuf::Arena* arena) const {
+ TileParameter* n = new TileParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void TileParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.TileParameter)
+ if (_has_bits_[0 / 32] & 3u) {
+ axis_ = 1;
+ tiles_ = 0;
+ }
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool TileParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.TileParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional int32 axis = 1 [default = 1];
+ case 1: {
+ if (tag == 8) {
+ set_has_axis();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &axis_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_tiles;
+ break;
+ }
+
+ // optional int32 tiles = 2;
+ case 2: {
+ if (tag == 16) {
+ parse_tiles:
+ set_has_tiles();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &tiles_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.TileParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.TileParameter)
+ return false;
+#undef DO_
+}
+
+void TileParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.TileParameter)
+ // optional int32 axis = 1 [default = 1];
+ if (has_axis()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->axis(), output);
+ }
+
+ // optional int32 tiles = 2;
+ if (has_tiles()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->tiles(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.TileParameter)
+}
+
+::google::protobuf::uint8* TileParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.TileParameter)
+ // optional int32 axis = 1 [default = 1];
+ if (has_axis()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->axis(), target);
+ }
+
+ // optional int32 tiles = 2;
+ if (has_tiles()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->tiles(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.TileParameter)
+ return target;
+}
+
+size_t TileParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.TileParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 3u) {
+ // optional int32 axis = 1 [default = 1];
+ if (has_axis()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->axis());
+ }
+
+ // optional int32 tiles = 2;
+ if (has_tiles()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->tiles());
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void TileParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.TileParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const TileParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const TileParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.TileParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.TileParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void TileParameter::MergeFrom(const TileParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.TileParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void TileParameter::UnsafeMergeFrom(const TileParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_axis()) {
+ set_axis(from.axis());
+ }
+ if (from.has_tiles()) {
+ set_tiles(from.tiles());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void TileParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.TileParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void TileParameter::CopyFrom(const TileParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.TileParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool TileParameter::IsInitialized() const {
+
+ return true;
+}
+
+void TileParameter::Swap(TileParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void TileParameter::InternalSwap(TileParameter* other) {
+ std::swap(axis_, other->axis_);
+ std::swap(tiles_, other->tiles_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata TileParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = TileParameter_descriptor_;
+ metadata.reflection = TileParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// TileParameter
+
+// optional int32 axis = 1 [default = 1];
+bool TileParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void TileParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void TileParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void TileParameter::clear_axis() {
+ axis_ = 1;
+ clear_has_axis();
+}
+::google::protobuf::int32 TileParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.TileParameter.axis)
+ return axis_;
+}
+void TileParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.TileParameter.axis)
+}
+
+// optional int32 tiles = 2;
+bool TileParameter::has_tiles() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void TileParameter::set_has_tiles() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void TileParameter::clear_has_tiles() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void TileParameter::clear_tiles() {
+ tiles_ = 0;
+ clear_has_tiles();
+}
+::google::protobuf::int32 TileParameter::tiles() const {
+ // @@protoc_insertion_point(field_get:caffe.TileParameter.tiles)
+ return tiles_;
+}
+void TileParameter::set_tiles(::google::protobuf::int32 value) {
+ set_has_tiles();
+ tiles_ = value;
+ // @@protoc_insertion_point(field_set:caffe.TileParameter.tiles)
+}
+
+inline const TileParameter* TileParameter::internal_default_instance() {
+ return &TileParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int ThresholdParameter::kThresholdFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+ThresholdParameter::ThresholdParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.ThresholdParameter)
+}
+
+void ThresholdParameter::InitAsDefaultInstance() {
+}
+
+ThresholdParameter::ThresholdParameter(const ThresholdParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.ThresholdParameter)
+}
+
+void ThresholdParameter::SharedCtor() {
+ _cached_size_ = 0;
+ threshold_ = 0;
+}
+
+ThresholdParameter::~ThresholdParameter() {
+ // @@protoc_insertion_point(destructor:caffe.ThresholdParameter)
+ SharedDtor();
+}
+
+void ThresholdParameter::SharedDtor() {
+}
+
+void ThresholdParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* ThresholdParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return ThresholdParameter_descriptor_;
+}
+
+const ThresholdParameter& ThresholdParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<ThresholdParameter> ThresholdParameter_default_instance_;
+
+ThresholdParameter* ThresholdParameter::New(::google::protobuf::Arena* arena) const {
+ ThresholdParameter* n = new ThresholdParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void ThresholdParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.ThresholdParameter)
+ threshold_ = 0;
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool ThresholdParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.ThresholdParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional float threshold = 1 [default = 0];
+ case 1: {
+ if (tag == 13) {
+ set_has_threshold();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &threshold_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.ThresholdParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.ThresholdParameter)
+ return false;
+#undef DO_
+}
+
+void ThresholdParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.ThresholdParameter)
+ // optional float threshold = 1 [default = 0];
+ if (has_threshold()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->threshold(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.ThresholdParameter)
+}
+
+::google::protobuf::uint8* ThresholdParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.ThresholdParameter)
+ // optional float threshold = 1 [default = 0];
+ if (has_threshold()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->threshold(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.ThresholdParameter)
+ return target;
+}
+
+size_t ThresholdParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.ThresholdParameter)
+ size_t total_size = 0;
+
+ // optional float threshold = 1 [default = 0];
+ if (has_threshold()) {
+ total_size += 1 + 4;
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void ThresholdParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.ThresholdParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const ThresholdParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const ThresholdParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.ThresholdParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.ThresholdParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void ThresholdParameter::MergeFrom(const ThresholdParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.ThresholdParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void ThresholdParameter::UnsafeMergeFrom(const ThresholdParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_threshold()) {
+ set_threshold(from.threshold());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void ThresholdParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.ThresholdParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void ThresholdParameter::CopyFrom(const ThresholdParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.ThresholdParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool ThresholdParameter::IsInitialized() const {
+
+ return true;
+}
+
+void ThresholdParameter::Swap(ThresholdParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void ThresholdParameter::InternalSwap(ThresholdParameter* other) {
+ std::swap(threshold_, other->threshold_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata ThresholdParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = ThresholdParameter_descriptor_;
+ metadata.reflection = ThresholdParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// ThresholdParameter
+
+// optional float threshold = 1 [default = 0];
+bool ThresholdParameter::has_threshold() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void ThresholdParameter::set_has_threshold() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void ThresholdParameter::clear_has_threshold() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void ThresholdParameter::clear_threshold() {
+ threshold_ = 0;
+ clear_has_threshold();
+}
+float ThresholdParameter::threshold() const {
+ // @@protoc_insertion_point(field_get:caffe.ThresholdParameter.threshold)
+ return threshold_;
+}
+void ThresholdParameter::set_threshold(float value) {
+ set_has_threshold();
+ threshold_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ThresholdParameter.threshold)
+}
+
+inline const ThresholdParameter* ThresholdParameter::internal_default_instance() {
+ return &ThresholdParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+::std::string* WindowDataParameter::_default_crop_mode_ = NULL;
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int WindowDataParameter::kSourceFieldNumber;
+const int WindowDataParameter::kScaleFieldNumber;
+const int WindowDataParameter::kMeanFileFieldNumber;
+const int WindowDataParameter::kBatchSizeFieldNumber;
+const int WindowDataParameter::kCropSizeFieldNumber;
+const int WindowDataParameter::kMirrorFieldNumber;
+const int WindowDataParameter::kFgThresholdFieldNumber;
+const int WindowDataParameter::kBgThresholdFieldNumber;
+const int WindowDataParameter::kFgFractionFieldNumber;
+const int WindowDataParameter::kContextPadFieldNumber;
+const int WindowDataParameter::kCropModeFieldNumber;
+const int WindowDataParameter::kCacheImagesFieldNumber;
+const int WindowDataParameter::kRootFolderFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+WindowDataParameter::WindowDataParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.WindowDataParameter)
+}
+
+void WindowDataParameter::InitAsDefaultInstance() {
+}
+
+WindowDataParameter::WindowDataParameter(const WindowDataParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.WindowDataParameter)
+}
+
+void WindowDataParameter::SharedCtor() {
+ _cached_size_ = 0;
+ source_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ mean_file_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ crop_mode_.UnsafeSetDefault(_default_crop_mode_);
+ root_folder_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ ::memset(&batch_size_, 0, reinterpret_cast<char*>(&context_pad_) -
+ reinterpret_cast<char*>(&batch_size_) + sizeof(context_pad_));
+ scale_ = 1;
+ fg_threshold_ = 0.5f;
+ bg_threshold_ = 0.5f;
+ fg_fraction_ = 0.25f;
+}
+
+WindowDataParameter::~WindowDataParameter() {
+ // @@protoc_insertion_point(destructor:caffe.WindowDataParameter)
+ SharedDtor();
+}
+
+void WindowDataParameter::SharedDtor() {
+ source_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ mean_file_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ crop_mode_.DestroyNoArena(_default_crop_mode_);
+ root_folder_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+
+void WindowDataParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* WindowDataParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return WindowDataParameter_descriptor_;
+}
+
+const WindowDataParameter& WindowDataParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<WindowDataParameter> WindowDataParameter_default_instance_;
+
+WindowDataParameter* WindowDataParameter::New(::google::protobuf::Arena* arena) const {
+ WindowDataParameter* n = new WindowDataParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void WindowDataParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.WindowDataParameter)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(WindowDataParameter, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<WindowDataParameter*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ if (_has_bits_[0 / 32] & 255u) {
+ ZR_(batch_size_, mirror_);
+ if (has_source()) {
+ source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ scale_ = 1;
+ if (has_mean_file()) {
+ mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ fg_threshold_ = 0.5f;
+ bg_threshold_ = 0.5f;
+ }
+ if (_has_bits_[8 / 32] & 7936u) {
+ ZR_(cache_images_, context_pad_);
+ fg_fraction_ = 0.25f;
+ if (has_crop_mode()) {
+ crop_mode_.ClearToDefaultNoArena(_default_crop_mode_);
+ }
+ if (has_root_folder()) {
+ root_folder_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ }
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool WindowDataParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.WindowDataParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional string source = 1;
+ case 1: {
+ if (tag == 10) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_source()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->source().data(), this->source().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.WindowDataParameter.source");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(21)) goto parse_scale;
+ break;
+ }
+
+ // optional float scale = 2 [default = 1];
+ case 2: {
+ if (tag == 21) {
+ parse_scale:
+ set_has_scale();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &scale_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(26)) goto parse_mean_file;
+ break;
+ }
+
+ // optional string mean_file = 3;
+ case 3: {
+ if (tag == 26) {
+ parse_mean_file:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_mean_file()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->mean_file().data(), this->mean_file().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.WindowDataParameter.mean_file");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(32)) goto parse_batch_size;
+ break;
+ }
+
+ // optional uint32 batch_size = 4;
+ case 4: {
+ if (tag == 32) {
+ parse_batch_size:
+ set_has_batch_size();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &batch_size_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(40)) goto parse_crop_size;
+ break;
+ }
+
+ // optional uint32 crop_size = 5 [default = 0];
+ case 5: {
+ if (tag == 40) {
+ parse_crop_size:
+ set_has_crop_size();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &crop_size_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(48)) goto parse_mirror;
+ break;
+ }
+
+ // optional bool mirror = 6 [default = false];
+ case 6: {
+ if (tag == 48) {
+ parse_mirror:
+ set_has_mirror();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &mirror_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(61)) goto parse_fg_threshold;
+ break;
+ }
+
+ // optional float fg_threshold = 7 [default = 0.5];
+ case 7: {
+ if (tag == 61) {
+ parse_fg_threshold:
+ set_has_fg_threshold();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &fg_threshold_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(69)) goto parse_bg_threshold;
+ break;
+ }
+
+ // optional float bg_threshold = 8 [default = 0.5];
+ case 8: {
+ if (tag == 69) {
+ parse_bg_threshold:
+ set_has_bg_threshold();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &bg_threshold_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(77)) goto parse_fg_fraction;
+ break;
+ }
+
+ // optional float fg_fraction = 9 [default = 0.25];
+ case 9: {
+ if (tag == 77) {
+ parse_fg_fraction:
+ set_has_fg_fraction();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &fg_fraction_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(80)) goto parse_context_pad;
+ break;
+ }
+
+ // optional uint32 context_pad = 10 [default = 0];
+ case 10: {
+ if (tag == 80) {
+ parse_context_pad:
+ set_has_context_pad();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &context_pad_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(90)) goto parse_crop_mode;
+ break;
+ }
+
+ // optional string crop_mode = 11 [default = "warp"];
+ case 11: {
+ if (tag == 90) {
+ parse_crop_mode:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_crop_mode()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->crop_mode().data(), this->crop_mode().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.WindowDataParameter.crop_mode");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(96)) goto parse_cache_images;
+ break;
+ }
+
+ // optional bool cache_images = 12 [default = false];
+ case 12: {
+ if (tag == 96) {
+ parse_cache_images:
+ set_has_cache_images();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &cache_images_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(106)) goto parse_root_folder;
+ break;
+ }
+
+ // optional string root_folder = 13 [default = ""];
+ case 13: {
+ if (tag == 106) {
+ parse_root_folder:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_root_folder()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->root_folder().data(), this->root_folder().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.WindowDataParameter.root_folder");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.WindowDataParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.WindowDataParameter)
+ return false;
+#undef DO_
+}
+
+void WindowDataParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.WindowDataParameter)
+ // optional string source = 1;
+ if (has_source()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->source().data(), this->source().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.WindowDataParameter.source");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 1, this->source(), output);
+ }
+
+ // optional float scale = 2 [default = 1];
+ if (has_scale()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->scale(), output);
+ }
+
+ // optional string mean_file = 3;
+ if (has_mean_file()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->mean_file().data(), this->mean_file().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.WindowDataParameter.mean_file");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 3, this->mean_file(), output);
+ }
+
+ // optional uint32 batch_size = 4;
+ if (has_batch_size()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(4, this->batch_size(), output);
+ }
+
+ // optional uint32 crop_size = 5 [default = 0];
+ if (has_crop_size()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(5, this->crop_size(), output);
+ }
+
+ // optional bool mirror = 6 [default = false];
+ if (has_mirror()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(6, this->mirror(), output);
+ }
+
+ // optional float fg_threshold = 7 [default = 0.5];
+ if (has_fg_threshold()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(7, this->fg_threshold(), output);
+ }
+
+ // optional float bg_threshold = 8 [default = 0.5];
+ if (has_bg_threshold()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(8, this->bg_threshold(), output);
+ }
+
+ // optional float fg_fraction = 9 [default = 0.25];
+ if (has_fg_fraction()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(9, this->fg_fraction(), output);
+ }
+
+ // optional uint32 context_pad = 10 [default = 0];
+ if (has_context_pad()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(10, this->context_pad(), output);
+ }
+
+ // optional string crop_mode = 11 [default = "warp"];
+ if (has_crop_mode()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->crop_mode().data(), this->crop_mode().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.WindowDataParameter.crop_mode");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 11, this->crop_mode(), output);
+ }
+
+ // optional bool cache_images = 12 [default = false];
+ if (has_cache_images()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(12, this->cache_images(), output);
+ }
+
+ // optional string root_folder = 13 [default = ""];
+ if (has_root_folder()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->root_folder().data(), this->root_folder().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.WindowDataParameter.root_folder");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 13, this->root_folder(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.WindowDataParameter)
+}
+
+::google::protobuf::uint8* WindowDataParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.WindowDataParameter)
+ // optional string source = 1;
+ if (has_source()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->source().data(), this->source().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.WindowDataParameter.source");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 1, this->source(), target);
+ }
+
+ // optional float scale = 2 [default = 1];
+ if (has_scale()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->scale(), target);
+ }
+
+ // optional string mean_file = 3;
+ if (has_mean_file()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->mean_file().data(), this->mean_file().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.WindowDataParameter.mean_file");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 3, this->mean_file(), target);
+ }
+
+ // optional uint32 batch_size = 4;
+ if (has_batch_size()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(4, this->batch_size(), target);
+ }
+
+ // optional uint32 crop_size = 5 [default = 0];
+ if (has_crop_size()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(5, this->crop_size(), target);
+ }
+
+ // optional bool mirror = 6 [default = false];
+ if (has_mirror()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(6, this->mirror(), target);
+ }
+
+ // optional float fg_threshold = 7 [default = 0.5];
+ if (has_fg_threshold()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(7, this->fg_threshold(), target);
+ }
+
+ // optional float bg_threshold = 8 [default = 0.5];
+ if (has_bg_threshold()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(8, this->bg_threshold(), target);
+ }
+
+ // optional float fg_fraction = 9 [default = 0.25];
+ if (has_fg_fraction()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(9, this->fg_fraction(), target);
+ }
+
+ // optional uint32 context_pad = 10 [default = 0];
+ if (has_context_pad()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(10, this->context_pad(), target);
+ }
+
+ // optional string crop_mode = 11 [default = "warp"];
+ if (has_crop_mode()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->crop_mode().data(), this->crop_mode().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.WindowDataParameter.crop_mode");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 11, this->crop_mode(), target);
+ }
+
+ // optional bool cache_images = 12 [default = false];
+ if (has_cache_images()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(12, this->cache_images(), target);
+ }
+
+ // optional string root_folder = 13 [default = ""];
+ if (has_root_folder()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->root_folder().data(), this->root_folder().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.WindowDataParameter.root_folder");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 13, this->root_folder(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.WindowDataParameter)
+ return target;
+}
+
+size_t WindowDataParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.WindowDataParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 255u) {
+ // optional string source = 1;
+ if (has_source()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->source());
+ }
+
+ // optional float scale = 2 [default = 1];
+ if (has_scale()) {
+ total_size += 1 + 4;
+ }
+
+ // optional string mean_file = 3;
+ if (has_mean_file()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->mean_file());
+ }
+
+ // optional uint32 batch_size = 4;
+ if (has_batch_size()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->batch_size());
+ }
+
+ // optional uint32 crop_size = 5 [default = 0];
+ if (has_crop_size()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->crop_size());
+ }
+
+ // optional bool mirror = 6 [default = false];
+ if (has_mirror()) {
+ total_size += 1 + 1;
+ }
+
+ // optional float fg_threshold = 7 [default = 0.5];
+ if (has_fg_threshold()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float bg_threshold = 8 [default = 0.5];
+ if (has_bg_threshold()) {
+ total_size += 1 + 4;
+ }
+
+ }
+ if (_has_bits_[8 / 32] & 7936u) {
+ // optional float fg_fraction = 9 [default = 0.25];
+ if (has_fg_fraction()) {
+ total_size += 1 + 4;
+ }
+
+ // optional uint32 context_pad = 10 [default = 0];
+ if (has_context_pad()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->context_pad());
+ }
+
+ // optional string crop_mode = 11 [default = "warp"];
+ if (has_crop_mode()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->crop_mode());
+ }
+
+ // optional bool cache_images = 12 [default = false];
+ if (has_cache_images()) {
+ total_size += 1 + 1;
+ }
+
+ // optional string root_folder = 13 [default = ""];
+ if (has_root_folder()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->root_folder());
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void WindowDataParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.WindowDataParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const WindowDataParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const WindowDataParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.WindowDataParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.WindowDataParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void WindowDataParameter::MergeFrom(const WindowDataParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.WindowDataParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void WindowDataParameter::UnsafeMergeFrom(const WindowDataParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_source()) {
+ set_has_source();
+ source_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_);
+ }
+ if (from.has_scale()) {
+ set_scale(from.scale());
+ }
+ if (from.has_mean_file()) {
+ set_has_mean_file();
+ mean_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.mean_file_);
+ }
+ if (from.has_batch_size()) {
+ set_batch_size(from.batch_size());
+ }
+ if (from.has_crop_size()) {
+ set_crop_size(from.crop_size());
+ }
+ if (from.has_mirror()) {
+ set_mirror(from.mirror());
+ }
+ if (from.has_fg_threshold()) {
+ set_fg_threshold(from.fg_threshold());
+ }
+ if (from.has_bg_threshold()) {
+ set_bg_threshold(from.bg_threshold());
+ }
+ }
+ if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) {
+ if (from.has_fg_fraction()) {
+ set_fg_fraction(from.fg_fraction());
+ }
+ if (from.has_context_pad()) {
+ set_context_pad(from.context_pad());
+ }
+ if (from.has_crop_mode()) {
+ set_has_crop_mode();
+ crop_mode_.AssignWithDefault(_default_crop_mode_, from.crop_mode_);
+ }
+ if (from.has_cache_images()) {
+ set_cache_images(from.cache_images());
+ }
+ if (from.has_root_folder()) {
+ set_has_root_folder();
+ root_folder_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.root_folder_);
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void WindowDataParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.WindowDataParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void WindowDataParameter::CopyFrom(const WindowDataParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.WindowDataParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool WindowDataParameter::IsInitialized() const {
+
+ return true;
+}
+
+void WindowDataParameter::Swap(WindowDataParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void WindowDataParameter::InternalSwap(WindowDataParameter* other) {
+ source_.Swap(&other->source_);
+ std::swap(scale_, other->scale_);
+ mean_file_.Swap(&other->mean_file_);
+ std::swap(batch_size_, other->batch_size_);
+ std::swap(crop_size_, other->crop_size_);
+ std::swap(mirror_, other->mirror_);
+ std::swap(fg_threshold_, other->fg_threshold_);
+ std::swap(bg_threshold_, other->bg_threshold_);
+ std::swap(fg_fraction_, other->fg_fraction_);
+ std::swap(context_pad_, other->context_pad_);
+ crop_mode_.Swap(&other->crop_mode_);
+ std::swap(cache_images_, other->cache_images_);
+ root_folder_.Swap(&other->root_folder_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata WindowDataParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = WindowDataParameter_descriptor_;
+ metadata.reflection = WindowDataParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// WindowDataParameter
+
+// optional string source = 1;
+bool WindowDataParameter::has_source() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void WindowDataParameter::set_has_source() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void WindowDataParameter::clear_has_source() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void WindowDataParameter::clear_source() {
+ source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_source();
+}
+const ::std::string& WindowDataParameter::source() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.source)
+ return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void WindowDataParameter::set_source(const ::std::string& value) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.source)
+}
+void WindowDataParameter::set_source(const char* value) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.WindowDataParameter.source)
+}
+void WindowDataParameter::set_source(const char* value, size_t size) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.WindowDataParameter.source)
+}
+::std::string* WindowDataParameter::mutable_source() {
+ set_has_source();
+ // @@protoc_insertion_point(field_mutable:caffe.WindowDataParameter.source)
+ return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* WindowDataParameter::release_source() {
+ // @@protoc_insertion_point(field_release:caffe.WindowDataParameter.source)
+ clear_has_source();
+ return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void WindowDataParameter::set_allocated_source(::std::string* source) {
+ if (source != NULL) {
+ set_has_source();
+ } else {
+ clear_has_source();
+ }
+ source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source);
+ // @@protoc_insertion_point(field_set_allocated:caffe.WindowDataParameter.source)
+}
+
+// optional float scale = 2 [default = 1];
+bool WindowDataParameter::has_scale() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void WindowDataParameter::set_has_scale() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void WindowDataParameter::clear_has_scale() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void WindowDataParameter::clear_scale() {
+ scale_ = 1;
+ clear_has_scale();
+}
+float WindowDataParameter::scale() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.scale)
+ return scale_;
+}
+void WindowDataParameter::set_scale(float value) {
+ set_has_scale();
+ scale_ = value;
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.scale)
+}
+
+// optional string mean_file = 3;
+bool WindowDataParameter::has_mean_file() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void WindowDataParameter::set_has_mean_file() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void WindowDataParameter::clear_has_mean_file() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void WindowDataParameter::clear_mean_file() {
+ mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_mean_file();
+}
+const ::std::string& WindowDataParameter::mean_file() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.mean_file)
+ return mean_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void WindowDataParameter::set_mean_file(const ::std::string& value) {
+ set_has_mean_file();
+ mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.mean_file)
+}
+void WindowDataParameter::set_mean_file(const char* value) {
+ set_has_mean_file();
+ mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.WindowDataParameter.mean_file)
+}
+void WindowDataParameter::set_mean_file(const char* value, size_t size) {
+ set_has_mean_file();
+ mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.WindowDataParameter.mean_file)
+}
+::std::string* WindowDataParameter::mutable_mean_file() {
+ set_has_mean_file();
+ // @@protoc_insertion_point(field_mutable:caffe.WindowDataParameter.mean_file)
+ return mean_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* WindowDataParameter::release_mean_file() {
+ // @@protoc_insertion_point(field_release:caffe.WindowDataParameter.mean_file)
+ clear_has_mean_file();
+ return mean_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void WindowDataParameter::set_allocated_mean_file(::std::string* mean_file) {
+ if (mean_file != NULL) {
+ set_has_mean_file();
+ } else {
+ clear_has_mean_file();
+ }
+ mean_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), mean_file);
+ // @@protoc_insertion_point(field_set_allocated:caffe.WindowDataParameter.mean_file)
+}
+
+// optional uint32 batch_size = 4;
+bool WindowDataParameter::has_batch_size() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+void WindowDataParameter::set_has_batch_size() {
+ _has_bits_[0] |= 0x00000008u;
+}
+void WindowDataParameter::clear_has_batch_size() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+void WindowDataParameter::clear_batch_size() {
+ batch_size_ = 0u;
+ clear_has_batch_size();
+}
+::google::protobuf::uint32 WindowDataParameter::batch_size() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.batch_size)
+ return batch_size_;
+}
+void WindowDataParameter::set_batch_size(::google::protobuf::uint32 value) {
+ set_has_batch_size();
+ batch_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.batch_size)
+}
+
+// optional uint32 crop_size = 5 [default = 0];
+bool WindowDataParameter::has_crop_size() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+void WindowDataParameter::set_has_crop_size() {
+ _has_bits_[0] |= 0x00000010u;
+}
+void WindowDataParameter::clear_has_crop_size() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+void WindowDataParameter::clear_crop_size() {
+ crop_size_ = 0u;
+ clear_has_crop_size();
+}
+::google::protobuf::uint32 WindowDataParameter::crop_size() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.crop_size)
+ return crop_size_;
+}
+void WindowDataParameter::set_crop_size(::google::protobuf::uint32 value) {
+ set_has_crop_size();
+ crop_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.crop_size)
+}
+
+// optional bool mirror = 6 [default = false];
+bool WindowDataParameter::has_mirror() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+void WindowDataParameter::set_has_mirror() {
+ _has_bits_[0] |= 0x00000020u;
+}
+void WindowDataParameter::clear_has_mirror() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+void WindowDataParameter::clear_mirror() {
+ mirror_ = false;
+ clear_has_mirror();
+}
+bool WindowDataParameter::mirror() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.mirror)
+ return mirror_;
+}
+void WindowDataParameter::set_mirror(bool value) {
+ set_has_mirror();
+ mirror_ = value;
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.mirror)
+}
+
+// optional float fg_threshold = 7 [default = 0.5];
+bool WindowDataParameter::has_fg_threshold() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+void WindowDataParameter::set_has_fg_threshold() {
+ _has_bits_[0] |= 0x00000040u;
+}
+void WindowDataParameter::clear_has_fg_threshold() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+void WindowDataParameter::clear_fg_threshold() {
+ fg_threshold_ = 0.5f;
+ clear_has_fg_threshold();
+}
+float WindowDataParameter::fg_threshold() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.fg_threshold)
+ return fg_threshold_;
+}
+void WindowDataParameter::set_fg_threshold(float value) {
+ set_has_fg_threshold();
+ fg_threshold_ = value;
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.fg_threshold)
+}
+
+// optional float bg_threshold = 8 [default = 0.5];
+bool WindowDataParameter::has_bg_threshold() const {
+ return (_has_bits_[0] & 0x00000080u) != 0;
+}
+void WindowDataParameter::set_has_bg_threshold() {
+ _has_bits_[0] |= 0x00000080u;
+}
+void WindowDataParameter::clear_has_bg_threshold() {
+ _has_bits_[0] &= ~0x00000080u;
+}
+void WindowDataParameter::clear_bg_threshold() {
+ bg_threshold_ = 0.5f;
+ clear_has_bg_threshold();
+}
+float WindowDataParameter::bg_threshold() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.bg_threshold)
+ return bg_threshold_;
+}
+void WindowDataParameter::set_bg_threshold(float value) {
+ set_has_bg_threshold();
+ bg_threshold_ = value;
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.bg_threshold)
+}
+
+// optional float fg_fraction = 9 [default = 0.25];
+bool WindowDataParameter::has_fg_fraction() const {
+ return (_has_bits_[0] & 0x00000100u) != 0;
+}
+void WindowDataParameter::set_has_fg_fraction() {
+ _has_bits_[0] |= 0x00000100u;
+}
+void WindowDataParameter::clear_has_fg_fraction() {
+ _has_bits_[0] &= ~0x00000100u;
+}
+void WindowDataParameter::clear_fg_fraction() {
+ fg_fraction_ = 0.25f;
+ clear_has_fg_fraction();
+}
+float WindowDataParameter::fg_fraction() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.fg_fraction)
+ return fg_fraction_;
+}
+void WindowDataParameter::set_fg_fraction(float value) {
+ set_has_fg_fraction();
+ fg_fraction_ = value;
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.fg_fraction)
+}
+
+// optional uint32 context_pad = 10 [default = 0];
+bool WindowDataParameter::has_context_pad() const {
+ return (_has_bits_[0] & 0x00000200u) != 0;
+}
+void WindowDataParameter::set_has_context_pad() {
+ _has_bits_[0] |= 0x00000200u;
+}
+void WindowDataParameter::clear_has_context_pad() {
+ _has_bits_[0] &= ~0x00000200u;
+}
+void WindowDataParameter::clear_context_pad() {
+ context_pad_ = 0u;
+ clear_has_context_pad();
+}
+::google::protobuf::uint32 WindowDataParameter::context_pad() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.context_pad)
+ return context_pad_;
+}
+void WindowDataParameter::set_context_pad(::google::protobuf::uint32 value) {
+ set_has_context_pad();
+ context_pad_ = value;
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.context_pad)
+}
+
+// optional string crop_mode = 11 [default = "warp"];
+bool WindowDataParameter::has_crop_mode() const {
+ return (_has_bits_[0] & 0x00000400u) != 0;
+}
+void WindowDataParameter::set_has_crop_mode() {
+ _has_bits_[0] |= 0x00000400u;
+}
+void WindowDataParameter::clear_has_crop_mode() {
+ _has_bits_[0] &= ~0x00000400u;
+}
+void WindowDataParameter::clear_crop_mode() {
+ crop_mode_.ClearToDefaultNoArena(_default_crop_mode_);
+ clear_has_crop_mode();
+}
+const ::std::string& WindowDataParameter::crop_mode() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.crop_mode)
+ return crop_mode_.GetNoArena(_default_crop_mode_);
+}
+void WindowDataParameter::set_crop_mode(const ::std::string& value) {
+ set_has_crop_mode();
+ crop_mode_.SetNoArena(_default_crop_mode_, value);
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.crop_mode)
+}
+void WindowDataParameter::set_crop_mode(const char* value) {
+ set_has_crop_mode();
+ crop_mode_.SetNoArena(_default_crop_mode_, ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.WindowDataParameter.crop_mode)
+}
+void WindowDataParameter::set_crop_mode(const char* value, size_t size) {
+ set_has_crop_mode();
+ crop_mode_.SetNoArena(_default_crop_mode_,
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.WindowDataParameter.crop_mode)
+}
+::std::string* WindowDataParameter::mutable_crop_mode() {
+ set_has_crop_mode();
+ // @@protoc_insertion_point(field_mutable:caffe.WindowDataParameter.crop_mode)
+ return crop_mode_.MutableNoArena(_default_crop_mode_);
+}
+::std::string* WindowDataParameter::release_crop_mode() {
+ // @@protoc_insertion_point(field_release:caffe.WindowDataParameter.crop_mode)
+ clear_has_crop_mode();
+ return crop_mode_.ReleaseNoArena(_default_crop_mode_);
+}
+void WindowDataParameter::set_allocated_crop_mode(::std::string* crop_mode) {
+ if (crop_mode != NULL) {
+ set_has_crop_mode();
+ } else {
+ clear_has_crop_mode();
+ }
+ crop_mode_.SetAllocatedNoArena(_default_crop_mode_, crop_mode);
+ // @@protoc_insertion_point(field_set_allocated:caffe.WindowDataParameter.crop_mode)
+}
+
+// optional bool cache_images = 12 [default = false];
+bool WindowDataParameter::has_cache_images() const {
+ return (_has_bits_[0] & 0x00000800u) != 0;
+}
+void WindowDataParameter::set_has_cache_images() {
+ _has_bits_[0] |= 0x00000800u;
+}
+void WindowDataParameter::clear_has_cache_images() {
+ _has_bits_[0] &= ~0x00000800u;
+}
+void WindowDataParameter::clear_cache_images() {
+ cache_images_ = false;
+ clear_has_cache_images();
+}
+bool WindowDataParameter::cache_images() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.cache_images)
+ return cache_images_;
+}
+void WindowDataParameter::set_cache_images(bool value) {
+ set_has_cache_images();
+ cache_images_ = value;
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.cache_images)
+}
+
+// optional string root_folder = 13 [default = ""];
+bool WindowDataParameter::has_root_folder() const {
+ return (_has_bits_[0] & 0x00001000u) != 0;
+}
+void WindowDataParameter::set_has_root_folder() {
+ _has_bits_[0] |= 0x00001000u;
+}
+void WindowDataParameter::clear_has_root_folder() {
+ _has_bits_[0] &= ~0x00001000u;
+}
+void WindowDataParameter::clear_root_folder() {
+ root_folder_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_root_folder();
+}
+const ::std::string& WindowDataParameter::root_folder() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.root_folder)
+ return root_folder_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void WindowDataParameter::set_root_folder(const ::std::string& value) {
+ set_has_root_folder();
+ root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.root_folder)
+}
+void WindowDataParameter::set_root_folder(const char* value) {
+ set_has_root_folder();
+ root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.WindowDataParameter.root_folder)
+}
+void WindowDataParameter::set_root_folder(const char* value, size_t size) {
+ set_has_root_folder();
+ root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.WindowDataParameter.root_folder)
+}
+::std::string* WindowDataParameter::mutable_root_folder() {
+ set_has_root_folder();
+ // @@protoc_insertion_point(field_mutable:caffe.WindowDataParameter.root_folder)
+ return root_folder_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* WindowDataParameter::release_root_folder() {
+ // @@protoc_insertion_point(field_release:caffe.WindowDataParameter.root_folder)
+ clear_has_root_folder();
+ return root_folder_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void WindowDataParameter::set_allocated_root_folder(::std::string* root_folder) {
+ if (root_folder != NULL) {
+ set_has_root_folder();
+ } else {
+ clear_has_root_folder();
+ }
+ root_folder_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), root_folder);
+ // @@protoc_insertion_point(field_set_allocated:caffe.WindowDataParameter.root_folder)
+}
+
+inline const WindowDataParameter* WindowDataParameter::internal_default_instance() {
+ return &WindowDataParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+const ::google::protobuf::EnumDescriptor* SPPParameter_PoolMethod_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return SPPParameter_PoolMethod_descriptor_;
+}
+bool SPPParameter_PoolMethod_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ case 2:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const SPPParameter_PoolMethod SPPParameter::MAX;
+const SPPParameter_PoolMethod SPPParameter::AVE;
+const SPPParameter_PoolMethod SPPParameter::STOCHASTIC;
+const SPPParameter_PoolMethod SPPParameter::PoolMethod_MIN;
+const SPPParameter_PoolMethod SPPParameter::PoolMethod_MAX;
+const int SPPParameter::PoolMethod_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+const ::google::protobuf::EnumDescriptor* SPPParameter_Engine_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return SPPParameter_Engine_descriptor_;
+}
+bool SPPParameter_Engine_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ case 2:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const SPPParameter_Engine SPPParameter::DEFAULT;
+const SPPParameter_Engine SPPParameter::CAFFE;
+const SPPParameter_Engine SPPParameter::CUDNN;
+const SPPParameter_Engine SPPParameter::Engine_MIN;
+const SPPParameter_Engine SPPParameter::Engine_MAX;
+const int SPPParameter::Engine_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int SPPParameter::kPyramidHeightFieldNumber;
+const int SPPParameter::kPoolFieldNumber;
+const int SPPParameter::kEngineFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+SPPParameter::SPPParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.SPPParameter)
+}
+
+void SPPParameter::InitAsDefaultInstance() {
+}
+
+SPPParameter::SPPParameter(const SPPParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.SPPParameter)
+}
+
+void SPPParameter::SharedCtor() {
+ _cached_size_ = 0;
+ ::memset(&pyramid_height_, 0, reinterpret_cast<char*>(&engine_) -
+ reinterpret_cast<char*>(&pyramid_height_) + sizeof(engine_));
+}
+
+SPPParameter::~SPPParameter() {
+ // @@protoc_insertion_point(destructor:caffe.SPPParameter)
+ SharedDtor();
+}
+
+void SPPParameter::SharedDtor() {
+}
+
+void SPPParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* SPPParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return SPPParameter_descriptor_;
+}
+
+const SPPParameter& SPPParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<SPPParameter> SPPParameter_default_instance_;
+
+SPPParameter* SPPParameter::New(::google::protobuf::Arena* arena) const {
+ SPPParameter* n = new SPPParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void SPPParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.SPPParameter)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(SPPParameter, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<SPPParameter*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ ZR_(pyramid_height_, engine_);
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool SPPParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.SPPParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional uint32 pyramid_height = 1;
+ case 1: {
+ if (tag == 8) {
+ set_has_pyramid_height();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &pyramid_height_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_pool;
+ break;
+ }
+
+ // optional .caffe.SPPParameter.PoolMethod pool = 2 [default = MAX];
+ case 2: {
+ if (tag == 16) {
+ parse_pool:
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::SPPParameter_PoolMethod_IsValid(value)) {
+ set_pool(static_cast< ::caffe::SPPParameter_PoolMethod >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(2, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(48)) goto parse_engine;
+ break;
+ }
+
+ // optional .caffe.SPPParameter.Engine engine = 6 [default = DEFAULT];
+ case 6: {
+ if (tag == 48) {
+ parse_engine:
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::SPPParameter_Engine_IsValid(value)) {
+ set_engine(static_cast< ::caffe::SPPParameter_Engine >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(6, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.SPPParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.SPPParameter)
+ return false;
+#undef DO_
+}
+
+void SPPParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.SPPParameter)
+ // optional uint32 pyramid_height = 1;
+ if (has_pyramid_height()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->pyramid_height(), output);
+ }
+
+ // optional .caffe.SPPParameter.PoolMethod pool = 2 [default = MAX];
+ if (has_pool()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 2, this->pool(), output);
+ }
+
+ // optional .caffe.SPPParameter.Engine engine = 6 [default = DEFAULT];
+ if (has_engine()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 6, this->engine(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.SPPParameter)
+}
+
+::google::protobuf::uint8* SPPParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.SPPParameter)
+ // optional uint32 pyramid_height = 1;
+ if (has_pyramid_height()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->pyramid_height(), target);
+ }
+
+ // optional .caffe.SPPParameter.PoolMethod pool = 2 [default = MAX];
+ if (has_pool()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 2, this->pool(), target);
+ }
+
+ // optional .caffe.SPPParameter.Engine engine = 6 [default = DEFAULT];
+ if (has_engine()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 6, this->engine(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.SPPParameter)
+ return target;
+}
+
+size_t SPPParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.SPPParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 7u) {
+ // optional uint32 pyramid_height = 1;
+ if (has_pyramid_height()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->pyramid_height());
+ }
+
+ // optional .caffe.SPPParameter.PoolMethod pool = 2 [default = MAX];
+ if (has_pool()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->pool());
+ }
+
+ // optional .caffe.SPPParameter.Engine engine = 6 [default = DEFAULT];
+ if (has_engine()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->engine());
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void SPPParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.SPPParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const SPPParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const SPPParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.SPPParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.SPPParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void SPPParameter::MergeFrom(const SPPParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.SPPParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void SPPParameter::UnsafeMergeFrom(const SPPParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_pyramid_height()) {
+ set_pyramid_height(from.pyramid_height());
+ }
+ if (from.has_pool()) {
+ set_pool(from.pool());
+ }
+ if (from.has_engine()) {
+ set_engine(from.engine());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void SPPParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.SPPParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void SPPParameter::CopyFrom(const SPPParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.SPPParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool SPPParameter::IsInitialized() const {
+
+ return true;
+}
+
+void SPPParameter::Swap(SPPParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void SPPParameter::InternalSwap(SPPParameter* other) {
+ std::swap(pyramid_height_, other->pyramid_height_);
+ std::swap(pool_, other->pool_);
+ std::swap(engine_, other->engine_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata SPPParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = SPPParameter_descriptor_;
+ metadata.reflection = SPPParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// SPPParameter
+
+// optional uint32 pyramid_height = 1;
+bool SPPParameter::has_pyramid_height() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void SPPParameter::set_has_pyramid_height() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void SPPParameter::clear_has_pyramid_height() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void SPPParameter::clear_pyramid_height() {
+ pyramid_height_ = 0u;
+ clear_has_pyramid_height();
+}
+::google::protobuf::uint32 SPPParameter::pyramid_height() const {
+ // @@protoc_insertion_point(field_get:caffe.SPPParameter.pyramid_height)
+ return pyramid_height_;
+}
+void SPPParameter::set_pyramid_height(::google::protobuf::uint32 value) {
+ set_has_pyramid_height();
+ pyramid_height_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SPPParameter.pyramid_height)
+}
+
+// optional .caffe.SPPParameter.PoolMethod pool = 2 [default = MAX];
+bool SPPParameter::has_pool() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void SPPParameter::set_has_pool() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void SPPParameter::clear_has_pool() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void SPPParameter::clear_pool() {
+ pool_ = 0;
+ clear_has_pool();
+}
+::caffe::SPPParameter_PoolMethod SPPParameter::pool() const {
+ // @@protoc_insertion_point(field_get:caffe.SPPParameter.pool)
+ return static_cast< ::caffe::SPPParameter_PoolMethod >(pool_);
+}
+void SPPParameter::set_pool(::caffe::SPPParameter_PoolMethod value) {
+ assert(::caffe::SPPParameter_PoolMethod_IsValid(value));
+ set_has_pool();
+ pool_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SPPParameter.pool)
+}
+
+// optional .caffe.SPPParameter.Engine engine = 6 [default = DEFAULT];
+bool SPPParameter::has_engine() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void SPPParameter::set_has_engine() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void SPPParameter::clear_has_engine() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void SPPParameter::clear_engine() {
+ engine_ = 0;
+ clear_has_engine();
+}
+::caffe::SPPParameter_Engine SPPParameter::engine() const {
+ // @@protoc_insertion_point(field_get:caffe.SPPParameter.engine)
+ return static_cast< ::caffe::SPPParameter_Engine >(engine_);
+}
+void SPPParameter::set_engine(::caffe::SPPParameter_Engine value) {
+ assert(::caffe::SPPParameter_Engine_IsValid(value));
+ set_has_engine();
+ engine_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SPPParameter.engine)
+}
+
+inline const SPPParameter* SPPParameter::internal_default_instance() {
+ return &SPPParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+const ::google::protobuf::EnumDescriptor* V1LayerParameter_LayerType_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return V1LayerParameter_LayerType_descriptor_;
+}
+bool V1LayerParameter_LayerType_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ case 10:
+ case 11:
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ case 16:
+ case 17:
+ case 18:
+ case 19:
+ case 20:
+ case 21:
+ case 22:
+ case 23:
+ case 24:
+ case 25:
+ case 26:
+ case 27:
+ case 28:
+ case 29:
+ case 30:
+ case 31:
+ case 32:
+ case 33:
+ case 34:
+ case 35:
+ case 36:
+ case 37:
+ case 38:
+ case 39:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const V1LayerParameter_LayerType V1LayerParameter::NONE;
+const V1LayerParameter_LayerType V1LayerParameter::ABSVAL;
+const V1LayerParameter_LayerType V1LayerParameter::ACCURACY;
+const V1LayerParameter_LayerType V1LayerParameter::ARGMAX;
+const V1LayerParameter_LayerType V1LayerParameter::BNLL;
+const V1LayerParameter_LayerType V1LayerParameter::CONCAT;
+const V1LayerParameter_LayerType V1LayerParameter::CONTRASTIVE_LOSS;
+const V1LayerParameter_LayerType V1LayerParameter::CONVOLUTION;
+const V1LayerParameter_LayerType V1LayerParameter::DATA;
+const V1LayerParameter_LayerType V1LayerParameter::DECONVOLUTION;
+const V1LayerParameter_LayerType V1LayerParameter::DROPOUT;
+const V1LayerParameter_LayerType V1LayerParameter::DUMMY_DATA;
+const V1LayerParameter_LayerType V1LayerParameter::EUCLIDEAN_LOSS;
+const V1LayerParameter_LayerType V1LayerParameter::ELTWISE;
+const V1LayerParameter_LayerType V1LayerParameter::EXP;
+const V1LayerParameter_LayerType V1LayerParameter::FLATTEN;
+const V1LayerParameter_LayerType V1LayerParameter::HDF5_DATA;
+const V1LayerParameter_LayerType V1LayerParameter::HDF5_OUTPUT;
+const V1LayerParameter_LayerType V1LayerParameter::HINGE_LOSS;
+const V1LayerParameter_LayerType V1LayerParameter::IM2COL;
+const V1LayerParameter_LayerType V1LayerParameter::IMAGE_DATA;
+const V1LayerParameter_LayerType V1LayerParameter::INFOGAIN_LOSS;
+const V1LayerParameter_LayerType V1LayerParameter::INNER_PRODUCT;
+const V1LayerParameter_LayerType V1LayerParameter::LRN;
+const V1LayerParameter_LayerType V1LayerParameter::MEMORY_DATA;
+const V1LayerParameter_LayerType V1LayerParameter::MULTINOMIAL_LOGISTIC_LOSS;
+const V1LayerParameter_LayerType V1LayerParameter::MVN;
+const V1LayerParameter_LayerType V1LayerParameter::POOLING;
+const V1LayerParameter_LayerType V1LayerParameter::POWER;
+const V1LayerParameter_LayerType V1LayerParameter::RELU;
+const V1LayerParameter_LayerType V1LayerParameter::SIGMOID;
+const V1LayerParameter_LayerType V1LayerParameter::SIGMOID_CROSS_ENTROPY_LOSS;
+const V1LayerParameter_LayerType V1LayerParameter::SILENCE;
+const V1LayerParameter_LayerType V1LayerParameter::SOFTMAX;
+const V1LayerParameter_LayerType V1LayerParameter::SOFTMAX_LOSS;
+const V1LayerParameter_LayerType V1LayerParameter::SPLIT;
+const V1LayerParameter_LayerType V1LayerParameter::SLICE;
+const V1LayerParameter_LayerType V1LayerParameter::TANH;
+const V1LayerParameter_LayerType V1LayerParameter::WINDOW_DATA;
+const V1LayerParameter_LayerType V1LayerParameter::THRESHOLD;
+const V1LayerParameter_LayerType V1LayerParameter::LayerType_MIN;
+const V1LayerParameter_LayerType V1LayerParameter::LayerType_MAX;
+const int V1LayerParameter::LayerType_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+const ::google::protobuf::EnumDescriptor* V1LayerParameter_DimCheckMode_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return V1LayerParameter_DimCheckMode_descriptor_;
+}
+bool V1LayerParameter_DimCheckMode_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const V1LayerParameter_DimCheckMode V1LayerParameter::STRICT;
+const V1LayerParameter_DimCheckMode V1LayerParameter::PERMISSIVE;
+const V1LayerParameter_DimCheckMode V1LayerParameter::DimCheckMode_MIN;
+const V1LayerParameter_DimCheckMode V1LayerParameter::DimCheckMode_MAX;
+const int V1LayerParameter::DimCheckMode_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int V1LayerParameter::kBottomFieldNumber;
+const int V1LayerParameter::kTopFieldNumber;
+const int V1LayerParameter::kNameFieldNumber;
+const int V1LayerParameter::kIncludeFieldNumber;
+const int V1LayerParameter::kExcludeFieldNumber;
+const int V1LayerParameter::kTypeFieldNumber;
+const int V1LayerParameter::kBlobsFieldNumber;
+const int V1LayerParameter::kParamFieldNumber;
+const int V1LayerParameter::kBlobShareModeFieldNumber;
+const int V1LayerParameter::kBlobsLrFieldNumber;
+const int V1LayerParameter::kWeightDecayFieldNumber;
+const int V1LayerParameter::kLossWeightFieldNumber;
+const int V1LayerParameter::kAccuracyParamFieldNumber;
+const int V1LayerParameter::kArgmaxParamFieldNumber;
+const int V1LayerParameter::kConcatParamFieldNumber;
+const int V1LayerParameter::kContrastiveLossParamFieldNumber;
+const int V1LayerParameter::kConvolutionParamFieldNumber;
+const int V1LayerParameter::kDataParamFieldNumber;
+const int V1LayerParameter::kDropoutParamFieldNumber;
+const int V1LayerParameter::kDummyDataParamFieldNumber;
+const int V1LayerParameter::kEltwiseParamFieldNumber;
+const int V1LayerParameter::kExpParamFieldNumber;
+const int V1LayerParameter::kHdf5DataParamFieldNumber;
+const int V1LayerParameter::kHdf5OutputParamFieldNumber;
+const int V1LayerParameter::kHingeLossParamFieldNumber;
+const int V1LayerParameter::kImageDataParamFieldNumber;
+const int V1LayerParameter::kInfogainLossParamFieldNumber;
+const int V1LayerParameter::kInnerProductParamFieldNumber;
+const int V1LayerParameter::kLrnParamFieldNumber;
+const int V1LayerParameter::kMemoryDataParamFieldNumber;
+const int V1LayerParameter::kMvnParamFieldNumber;
+const int V1LayerParameter::kPoolingParamFieldNumber;
+const int V1LayerParameter::kPowerParamFieldNumber;
+const int V1LayerParameter::kReluParamFieldNumber;
+const int V1LayerParameter::kSigmoidParamFieldNumber;
+const int V1LayerParameter::kSoftmaxParamFieldNumber;
+const int V1LayerParameter::kSliceParamFieldNumber;
+const int V1LayerParameter::kTanhParamFieldNumber;
+const int V1LayerParameter::kThresholdParamFieldNumber;
+const int V1LayerParameter::kWindowDataParamFieldNumber;
+const int V1LayerParameter::kTransformParamFieldNumber;
+const int V1LayerParameter::kLossParamFieldNumber;
+const int V1LayerParameter::kLayerFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+V1LayerParameter::V1LayerParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.V1LayerParameter)
+}
+
+void V1LayerParameter::InitAsDefaultInstance() {
+ accuracy_param_ = const_cast< ::caffe::AccuracyParameter*>(
+ ::caffe::AccuracyParameter::internal_default_instance());
+ argmax_param_ = const_cast< ::caffe::ArgMaxParameter*>(
+ ::caffe::ArgMaxParameter::internal_default_instance());
+ concat_param_ = const_cast< ::caffe::ConcatParameter*>(
+ ::caffe::ConcatParameter::internal_default_instance());
+ contrastive_loss_param_ = const_cast< ::caffe::ContrastiveLossParameter*>(
+ ::caffe::ContrastiveLossParameter::internal_default_instance());
+ convolution_param_ = const_cast< ::caffe::ConvolutionParameter*>(
+ ::caffe::ConvolutionParameter::internal_default_instance());
+ data_param_ = const_cast< ::caffe::DataParameter*>(
+ ::caffe::DataParameter::internal_default_instance());
+ dropout_param_ = const_cast< ::caffe::DropoutParameter*>(
+ ::caffe::DropoutParameter::internal_default_instance());
+ dummy_data_param_ = const_cast< ::caffe::DummyDataParameter*>(
+ ::caffe::DummyDataParameter::internal_default_instance());
+ eltwise_param_ = const_cast< ::caffe::EltwiseParameter*>(
+ ::caffe::EltwiseParameter::internal_default_instance());
+ exp_param_ = const_cast< ::caffe::ExpParameter*>(
+ ::caffe::ExpParameter::internal_default_instance());
+ hdf5_data_param_ = const_cast< ::caffe::HDF5DataParameter*>(
+ ::caffe::HDF5DataParameter::internal_default_instance());
+ hdf5_output_param_ = const_cast< ::caffe::HDF5OutputParameter*>(
+ ::caffe::HDF5OutputParameter::internal_default_instance());
+ hinge_loss_param_ = const_cast< ::caffe::HingeLossParameter*>(
+ ::caffe::HingeLossParameter::internal_default_instance());
+ image_data_param_ = const_cast< ::caffe::ImageDataParameter*>(
+ ::caffe::ImageDataParameter::internal_default_instance());
+ infogain_loss_param_ = const_cast< ::caffe::InfogainLossParameter*>(
+ ::caffe::InfogainLossParameter::internal_default_instance());
+ inner_product_param_ = const_cast< ::caffe::InnerProductParameter*>(
+ ::caffe::InnerProductParameter::internal_default_instance());
+ lrn_param_ = const_cast< ::caffe::LRNParameter*>(
+ ::caffe::LRNParameter::internal_default_instance());
+ memory_data_param_ = const_cast< ::caffe::MemoryDataParameter*>(
+ ::caffe::MemoryDataParameter::internal_default_instance());
+ mvn_param_ = const_cast< ::caffe::MVNParameter*>(
+ ::caffe::MVNParameter::internal_default_instance());
+ pooling_param_ = const_cast< ::caffe::PoolingParameter*>(
+ ::caffe::PoolingParameter::internal_default_instance());
+ power_param_ = const_cast< ::caffe::PowerParameter*>(
+ ::caffe::PowerParameter::internal_default_instance());
+ relu_param_ = const_cast< ::caffe::ReLUParameter*>(
+ ::caffe::ReLUParameter::internal_default_instance());
+ sigmoid_param_ = const_cast< ::caffe::SigmoidParameter*>(
+ ::caffe::SigmoidParameter::internal_default_instance());
+ softmax_param_ = const_cast< ::caffe::SoftmaxParameter*>(
+ ::caffe::SoftmaxParameter::internal_default_instance());
+ slice_param_ = const_cast< ::caffe::SliceParameter*>(
+ ::caffe::SliceParameter::internal_default_instance());
+ tanh_param_ = const_cast< ::caffe::TanHParameter*>(
+ ::caffe::TanHParameter::internal_default_instance());
+ threshold_param_ = const_cast< ::caffe::ThresholdParameter*>(
+ ::caffe::ThresholdParameter::internal_default_instance());
+ window_data_param_ = const_cast< ::caffe::WindowDataParameter*>(
+ ::caffe::WindowDataParameter::internal_default_instance());
+ transform_param_ = const_cast< ::caffe::TransformationParameter*>(
+ ::caffe::TransformationParameter::internal_default_instance());
+ loss_param_ = const_cast< ::caffe::LossParameter*>(
+ ::caffe::LossParameter::internal_default_instance());
+ layer_ = const_cast< ::caffe::V0LayerParameter*>(
+ ::caffe::V0LayerParameter::internal_default_instance());
+}
+
+V1LayerParameter::V1LayerParameter(const V1LayerParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.V1LayerParameter)
+}
+
+void V1LayerParameter::SharedCtor() {
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ accuracy_param_ = NULL;
+ argmax_param_ = NULL;
+ concat_param_ = NULL;
+ contrastive_loss_param_ = NULL;
+ convolution_param_ = NULL;
+ data_param_ = NULL;
+ dropout_param_ = NULL;
+ dummy_data_param_ = NULL;
+ eltwise_param_ = NULL;
+ exp_param_ = NULL;
+ hdf5_data_param_ = NULL;
+ hdf5_output_param_ = NULL;
+ hinge_loss_param_ = NULL;
+ image_data_param_ = NULL;
+ infogain_loss_param_ = NULL;
+ inner_product_param_ = NULL;
+ lrn_param_ = NULL;
+ memory_data_param_ = NULL;
+ mvn_param_ = NULL;
+ pooling_param_ = NULL;
+ power_param_ = NULL;
+ relu_param_ = NULL;
+ sigmoid_param_ = NULL;
+ softmax_param_ = NULL;
+ slice_param_ = NULL;
+ tanh_param_ = NULL;
+ threshold_param_ = NULL;
+ window_data_param_ = NULL;
+ transform_param_ = NULL;
+ loss_param_ = NULL;
+ layer_ = NULL;
+ type_ = 0;
+ _cached_size_ = 0;
+}
+
+V1LayerParameter::~V1LayerParameter() {
+ // @@protoc_insertion_point(destructor:caffe.V1LayerParameter)
+ SharedDtor();
+}
+
+void V1LayerParameter::SharedDtor() {
+ name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ if (this != &V1LayerParameter_default_instance_.get()) {
+ delete accuracy_param_;
+ delete argmax_param_;
+ delete concat_param_;
+ delete contrastive_loss_param_;
+ delete convolution_param_;
+ delete data_param_;
+ delete dropout_param_;
+ delete dummy_data_param_;
+ delete eltwise_param_;
+ delete exp_param_;
+ delete hdf5_data_param_;
+ delete hdf5_output_param_;
+ delete hinge_loss_param_;
+ delete image_data_param_;
+ delete infogain_loss_param_;
+ delete inner_product_param_;
+ delete lrn_param_;
+ delete memory_data_param_;
+ delete mvn_param_;
+ delete pooling_param_;
+ delete power_param_;
+ delete relu_param_;
+ delete sigmoid_param_;
+ delete softmax_param_;
+ delete slice_param_;
+ delete tanh_param_;
+ delete threshold_param_;
+ delete window_data_param_;
+ delete transform_param_;
+ delete loss_param_;
+ delete layer_;
+ }
+}
+
+void V1LayerParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* V1LayerParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return V1LayerParameter_descriptor_;
+}
+
+const V1LayerParameter& V1LayerParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<V1LayerParameter> V1LayerParameter_default_instance_;
+
+V1LayerParameter* V1LayerParameter::New(::google::protobuf::Arena* arena) const {
+ V1LayerParameter* n = new V1LayerParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void V1LayerParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.V1LayerParameter)
+ if (_has_bits_[0 / 32] & 36u) {
+ if (has_name()) {
+ name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ type_ = 0;
+ }
+ if (_has_bits_[8 / 32] & 61440u) {
+ if (has_accuracy_param()) {
+ if (accuracy_param_ != NULL) accuracy_param_->::caffe::AccuracyParameter::Clear();
+ }
+ if (has_argmax_param()) {
+ if (argmax_param_ != NULL) argmax_param_->::caffe::ArgMaxParameter::Clear();
+ }
+ if (has_concat_param()) {
+ if (concat_param_ != NULL) concat_param_->::caffe::ConcatParameter::Clear();
+ }
+ if (has_contrastive_loss_param()) {
+ if (contrastive_loss_param_ != NULL) contrastive_loss_param_->::caffe::ContrastiveLossParameter::Clear();
+ }
+ }
+ if (_has_bits_[16 / 32] & 16711680u) {
+ if (has_convolution_param()) {
+ if (convolution_param_ != NULL) convolution_param_->::caffe::ConvolutionParameter::Clear();
+ }
+ if (has_data_param()) {
+ if (data_param_ != NULL) data_param_->::caffe::DataParameter::Clear();
+ }
+ if (has_dropout_param()) {
+ if (dropout_param_ != NULL) dropout_param_->::caffe::DropoutParameter::Clear();
+ }
+ if (has_dummy_data_param()) {
+ if (dummy_data_param_ != NULL) dummy_data_param_->::caffe::DummyDataParameter::Clear();
+ }
+ if (has_eltwise_param()) {
+ if (eltwise_param_ != NULL) eltwise_param_->::caffe::EltwiseParameter::Clear();
+ }
+ if (has_exp_param()) {
+ if (exp_param_ != NULL) exp_param_->::caffe::ExpParameter::Clear();
+ }
+ if (has_hdf5_data_param()) {
+ if (hdf5_data_param_ != NULL) hdf5_data_param_->::caffe::HDF5DataParameter::Clear();
+ }
+ if (has_hdf5_output_param()) {
+ if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear();
+ }
+ }
+ if (_has_bits_[24 / 32] & 4278190080u) {
+ if (has_hinge_loss_param()) {
+ if (hinge_loss_param_ != NULL) hinge_loss_param_->::caffe::HingeLossParameter::Clear();
+ }
+ if (has_image_data_param()) {
+ if (image_data_param_ != NULL) image_data_param_->::caffe::ImageDataParameter::Clear();
+ }
+ if (has_infogain_loss_param()) {
+ if (infogain_loss_param_ != NULL) infogain_loss_param_->::caffe::InfogainLossParameter::Clear();
+ }
+ if (has_inner_product_param()) {
+ if (inner_product_param_ != NULL) inner_product_param_->::caffe::InnerProductParameter::Clear();
+ }
+ if (has_lrn_param()) {
+ if (lrn_param_ != NULL) lrn_param_->::caffe::LRNParameter::Clear();
+ }
+ if (has_memory_data_param()) {
+ if (memory_data_param_ != NULL) memory_data_param_->::caffe::MemoryDataParameter::Clear();
+ }
+ if (has_mvn_param()) {
+ if (mvn_param_ != NULL) mvn_param_->::caffe::MVNParameter::Clear();
+ }
+ if (has_pooling_param()) {
+ if (pooling_param_ != NULL) pooling_param_->::caffe::PoolingParameter::Clear();
+ }
+ }
+ if (_has_bits_[32 / 32] & 255u) {
+ if (has_power_param()) {
+ if (power_param_ != NULL) power_param_->::caffe::PowerParameter::Clear();
+ }
+ if (has_relu_param()) {
+ if (relu_param_ != NULL) relu_param_->::caffe::ReLUParameter::Clear();
+ }
+ if (has_sigmoid_param()) {
+ if (sigmoid_param_ != NULL) sigmoid_param_->::caffe::SigmoidParameter::Clear();
+ }
+ if (has_softmax_param()) {
+ if (softmax_param_ != NULL) softmax_param_->::caffe::SoftmaxParameter::Clear();
+ }
+ if (has_slice_param()) {
+ if (slice_param_ != NULL) slice_param_->::caffe::SliceParameter::Clear();
+ }
+ if (has_tanh_param()) {
+ if (tanh_param_ != NULL) tanh_param_->::caffe::TanHParameter::Clear();
+ }
+ if (has_threshold_param()) {
+ if (threshold_param_ != NULL) threshold_param_->::caffe::ThresholdParameter::Clear();
+ }
+ if (has_window_data_param()) {
+ if (window_data_param_ != NULL) window_data_param_->::caffe::WindowDataParameter::Clear();
+ }
+ }
+ if (_has_bits_[40 / 32] & 1792u) {
+ if (has_transform_param()) {
+ if (transform_param_ != NULL) transform_param_->::caffe::TransformationParameter::Clear();
+ }
+ if (has_loss_param()) {
+ if (loss_param_ != NULL) loss_param_->::caffe::LossParameter::Clear();
+ }
+ if (has_layer()) {
+ if (layer_ != NULL) layer_->::caffe::V0LayerParameter::Clear();
+ }
+ }
+ bottom_.Clear();
+ top_.Clear();
+ include_.Clear();
+ exclude_.Clear();
+ blobs_.Clear();
+ param_.Clear();
+ blob_share_mode_.Clear();
+ blobs_lr_.Clear();
+ weight_decay_.Clear();
+ loss_weight_.Clear();
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool V1LayerParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.V1LayerParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional .caffe.V0LayerParameter layer = 1;
+ case 1: {
+ if (tag == 10) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_layer()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(18)) goto parse_bottom;
+ break;
+ }
+
+ // repeated string bottom = 2;
+ case 2: {
+ if (tag == 18) {
+ parse_bottom:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->add_bottom()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->bottom(this->bottom_size() - 1).data(),
+ this->bottom(this->bottom_size() - 1).length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.V1LayerParameter.bottom");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(18)) goto parse_bottom;
+ if (input->ExpectTag(26)) goto parse_top;
+ break;
+ }
+
+ // repeated string top = 3;
+ case 3: {
+ if (tag == 26) {
+ parse_top:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->add_top()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->top(this->top_size() - 1).data(),
+ this->top(this->top_size() - 1).length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.V1LayerParameter.top");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(26)) goto parse_top;
+ if (input->ExpectTag(34)) goto parse_name;
+ break;
+ }
+
+ // optional string name = 4;
+ case 4: {
+ if (tag == 34) {
+ parse_name:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_name()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->name().data(), this->name().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.V1LayerParameter.name");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(40)) goto parse_type;
+ break;
+ }
+
+ // optional .caffe.V1LayerParameter.LayerType type = 5;
+ case 5: {
+ if (tag == 40) {
+ parse_type:
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::V1LayerParameter_LayerType_IsValid(value)) {
+ set_type(static_cast< ::caffe::V1LayerParameter_LayerType >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(5, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(50)) goto parse_blobs;
+ break;
+ }
+
+ // repeated .caffe.BlobProto blobs = 6;
+ case 6: {
+ if (tag == 50) {
+ parse_blobs:
+ DO_(input->IncrementRecursionDepth());
+ parse_loop_blobs:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
+ input, add_blobs()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(50)) goto parse_loop_blobs;
+ input->UnsafeDecrementRecursionDepth();
+ if (input->ExpectTag(61)) goto parse_blobs_lr;
+ break;
+ }
+
+ // repeated float blobs_lr = 7;
+ case 7: {
+ if (tag == 61) {
+ parse_blobs_lr:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ 1, 61, input, this->mutable_blobs_lr())));
+ } else if (tag == 58) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, this->mutable_blobs_lr())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(61)) goto parse_blobs_lr;
+ if (input->ExpectTag(69)) goto parse_weight_decay;
+ break;
+ }
+
+ // repeated float weight_decay = 8;
+ case 8: {
+ if (tag == 69) {
+ parse_weight_decay:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ 1, 69, input, this->mutable_weight_decay())));
+ } else if (tag == 66) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, this->mutable_weight_decay())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(69)) goto parse_weight_decay;
+ if (input->ExpectTag(74)) goto parse_concat_param;
+ break;
+ }
+
+ // optional .caffe.ConcatParameter concat_param = 9;
+ case 9: {
+ if (tag == 74) {
+ parse_concat_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_concat_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(82)) goto parse_convolution_param;
+ break;
+ }
+
+ // optional .caffe.ConvolutionParameter convolution_param = 10;
+ case 10: {
+ if (tag == 82) {
+ parse_convolution_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_convolution_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(90)) goto parse_data_param;
+ break;
+ }
+
+ // optional .caffe.DataParameter data_param = 11;
+ case 11: {
+ if (tag == 90) {
+ parse_data_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_data_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(98)) goto parse_dropout_param;
+ break;
+ }
+
+ // optional .caffe.DropoutParameter dropout_param = 12;
+ case 12: {
+ if (tag == 98) {
+ parse_dropout_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_dropout_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(106)) goto parse_hdf5_data_param;
+ break;
+ }
+
+ // optional .caffe.HDF5DataParameter hdf5_data_param = 13;
+ case 13: {
+ if (tag == 106) {
+ parse_hdf5_data_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_hdf5_data_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(114)) goto parse_hdf5_output_param;
+ break;
+ }
+
+ // optional .caffe.HDF5OutputParameter hdf5_output_param = 14;
+ case 14: {
+ if (tag == 114) {
+ parse_hdf5_output_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_hdf5_output_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(122)) goto parse_image_data_param;
+ break;
+ }
+
+ // optional .caffe.ImageDataParameter image_data_param = 15;
+ case 15: {
+ if (tag == 122) {
+ parse_image_data_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_image_data_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(130)) goto parse_infogain_loss_param;
+ break;
+ }
+
+ // optional .caffe.InfogainLossParameter infogain_loss_param = 16;
+ case 16: {
+ if (tag == 130) {
+ parse_infogain_loss_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_infogain_loss_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(138)) goto parse_inner_product_param;
+ break;
+ }
+
+ // optional .caffe.InnerProductParameter inner_product_param = 17;
+ case 17: {
+ if (tag == 138) {
+ parse_inner_product_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_inner_product_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(146)) goto parse_lrn_param;
+ break;
+ }
+
+ // optional .caffe.LRNParameter lrn_param = 18;
+ case 18: {
+ if (tag == 146) {
+ parse_lrn_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_lrn_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(154)) goto parse_pooling_param;
+ break;
+ }
+
+ // optional .caffe.PoolingParameter pooling_param = 19;
+ case 19: {
+ if (tag == 154) {
+ parse_pooling_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_pooling_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(162)) goto parse_window_data_param;
+ break;
+ }
+
+ // optional .caffe.WindowDataParameter window_data_param = 20;
+ case 20: {
+ if (tag == 162) {
+ parse_window_data_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_window_data_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(170)) goto parse_power_param;
+ break;
+ }
+
+ // optional .caffe.PowerParameter power_param = 21;
+ case 21: {
+ if (tag == 170) {
+ parse_power_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_power_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(178)) goto parse_memory_data_param;
+ break;
+ }
+
+ // optional .caffe.MemoryDataParameter memory_data_param = 22;
+ case 22: {
+ if (tag == 178) {
+ parse_memory_data_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_memory_data_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(186)) goto parse_argmax_param;
+ break;
+ }
+
+ // optional .caffe.ArgMaxParameter argmax_param = 23;
+ case 23: {
+ if (tag == 186) {
+ parse_argmax_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_argmax_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(194)) goto parse_eltwise_param;
+ break;
+ }
+
+ // optional .caffe.EltwiseParameter eltwise_param = 24;
+ case 24: {
+ if (tag == 194) {
+ parse_eltwise_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_eltwise_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(202)) goto parse_threshold_param;
+ break;
+ }
+
+ // optional .caffe.ThresholdParameter threshold_param = 25;
+ case 25: {
+ if (tag == 202) {
+ parse_threshold_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_threshold_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(210)) goto parse_dummy_data_param;
+ break;
+ }
+
+ // optional .caffe.DummyDataParameter dummy_data_param = 26;
+ case 26: {
+ if (tag == 210) {
+ parse_dummy_data_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_dummy_data_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(218)) goto parse_accuracy_param;
+ break;
+ }
+
+ // optional .caffe.AccuracyParameter accuracy_param = 27;
+ case 27: {
+ if (tag == 218) {
+ parse_accuracy_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_accuracy_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(234)) goto parse_hinge_loss_param;
+ break;
+ }
+
+ // optional .caffe.HingeLossParameter hinge_loss_param = 29;
+ case 29: {
+ if (tag == 234) {
+ parse_hinge_loss_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_hinge_loss_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(242)) goto parse_relu_param;
+ break;
+ }
+
+ // optional .caffe.ReLUParameter relu_param = 30;
+ case 30: {
+ if (tag == 242) {
+ parse_relu_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_relu_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(250)) goto parse_slice_param;
+ break;
+ }
+
+ // optional .caffe.SliceParameter slice_param = 31;
+ case 31: {
+ if (tag == 250) {
+ parse_slice_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_slice_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(258)) goto parse_include;
+ break;
+ }
+
+ // repeated .caffe.NetStateRule include = 32;
+ case 32: {
+ if (tag == 258) {
+ parse_include:
+ DO_(input->IncrementRecursionDepth());
+ parse_loop_include:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
+ input, add_include()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(258)) goto parse_loop_include;
+ if (input->ExpectTag(266)) goto parse_loop_exclude;
+ input->UnsafeDecrementRecursionDepth();
+ break;
+ }
+
+ // repeated .caffe.NetStateRule exclude = 33;
+ case 33: {
+ if (tag == 266) {
+ DO_(input->IncrementRecursionDepth());
+ parse_loop_exclude:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
+ input, add_exclude()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(266)) goto parse_loop_exclude;
+ input->UnsafeDecrementRecursionDepth();
+ if (input->ExpectTag(274)) goto parse_mvn_param;
+ break;
+ }
+
+ // optional .caffe.MVNParameter mvn_param = 34;
+ case 34: {
+ if (tag == 274) {
+ parse_mvn_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_mvn_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(285)) goto parse_loss_weight;
+ break;
+ }
+
+ // repeated float loss_weight = 35;
+ case 35: {
+ if (tag == 285) {
+ parse_loss_weight:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ 2, 285, input, this->mutable_loss_weight())));
+ } else if (tag == 282) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, this->mutable_loss_weight())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(285)) goto parse_loss_weight;
+ if (input->ExpectTag(290)) goto parse_transform_param;
+ break;
+ }
+
+ // optional .caffe.TransformationParameter transform_param = 36;
+ case 36: {
+ if (tag == 290) {
+ parse_transform_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_transform_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(298)) goto parse_tanh_param;
+ break;
+ }
+
+ // optional .caffe.TanHParameter tanh_param = 37;
+ case 37: {
+ if (tag == 298) {
+ parse_tanh_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_tanh_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(306)) goto parse_sigmoid_param;
+ break;
+ }
+
+ // optional .caffe.SigmoidParameter sigmoid_param = 38;
+ case 38: {
+ if (tag == 306) {
+ parse_sigmoid_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_sigmoid_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(314)) goto parse_softmax_param;
+ break;
+ }
+
+ // optional .caffe.SoftmaxParameter softmax_param = 39;
+ case 39: {
+ if (tag == 314) {
+ parse_softmax_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_softmax_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(322)) goto parse_contrastive_loss_param;
+ break;
+ }
+
+ // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40;
+ case 40: {
+ if (tag == 322) {
+ parse_contrastive_loss_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_contrastive_loss_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(330)) goto parse_exp_param;
+ break;
+ }
+
+ // optional .caffe.ExpParameter exp_param = 41;
+ case 41: {
+ if (tag == 330) {
+ parse_exp_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_exp_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(338)) goto parse_loss_param;
+ break;
+ }
+
+ // optional .caffe.LossParameter loss_param = 42;
+ case 42: {
+ if (tag == 338) {
+ parse_loss_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_loss_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(8010)) goto parse_param;
+ break;
+ }
+
+ // repeated string param = 1001;
+ case 1001: {
+ if (tag == 8010) {
+ parse_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->add_param()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->param(this->param_size() - 1).data(),
+ this->param(this->param_size() - 1).length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.V1LayerParameter.param");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(8010)) goto parse_param;
+ if (input->ExpectTag(8016)) goto parse_blob_share_mode;
+ break;
+ }
+
+ // repeated .caffe.V1LayerParameter.DimCheckMode blob_share_mode = 1002;
+ case 1002: {
+ if (tag == 8016) {
+ parse_blob_share_mode:
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::V1LayerParameter_DimCheckMode_IsValid(value)) {
+ add_blob_share_mode(static_cast< ::caffe::V1LayerParameter_DimCheckMode >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(1002, value);
+ }
+ } else if (tag == 8018) {
+ DO_((::google::protobuf::internal::WireFormat::ReadPackedEnumPreserveUnknowns(
+ input,
+ 1002,
+ ::caffe::V1LayerParameter_DimCheckMode_IsValid,
+ mutable_unknown_fields(),
+ this->mutable_blob_share_mode())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(8016)) goto parse_blob_share_mode;
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.V1LayerParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.V1LayerParameter)
+ return false;
+#undef DO_
+}
+
+void V1LayerParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.V1LayerParameter)
+ // optional .caffe.V0LayerParameter layer = 1;
+ if (has_layer()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 1, *this->layer_, output);
+ }
+
+ // repeated string bottom = 2;
+ for (int i = 0; i < this->bottom_size(); i++) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->bottom(i).data(), this->bottom(i).length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.V1LayerParameter.bottom");
+ ::google::protobuf::internal::WireFormatLite::WriteString(
+ 2, this->bottom(i), output);
+ }
+
+ // repeated string top = 3;
+ for (int i = 0; i < this->top_size(); i++) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->top(i).data(), this->top(i).length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.V1LayerParameter.top");
+ ::google::protobuf::internal::WireFormatLite::WriteString(
+ 3, this->top(i), output);
+ }
+
+ // optional string name = 4;
+ if (has_name()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->name().data(), this->name().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.V1LayerParameter.name");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 4, this->name(), output);
+ }
+
+ // optional .caffe.V1LayerParameter.LayerType type = 5;
+ if (has_type()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 5, this->type(), output);
+ }
+
+ // repeated .caffe.BlobProto blobs = 6;
+ for (unsigned int i = 0, n = this->blobs_size(); i < n; i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 6, this->blobs(i), output);
+ }
+
+ // repeated float blobs_lr = 7;
+ for (int i = 0; i < this->blobs_lr_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(
+ 7, this->blobs_lr(i), output);
+ }
+
+ // repeated float weight_decay = 8;
+ for (int i = 0; i < this->weight_decay_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(
+ 8, this->weight_decay(i), output);
+ }
+
+ // optional .caffe.ConcatParameter concat_param = 9;
+ if (has_concat_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 9, *this->concat_param_, output);
+ }
+
+ // optional .caffe.ConvolutionParameter convolution_param = 10;
+ if (has_convolution_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 10, *this->convolution_param_, output);
+ }
+
+ // optional .caffe.DataParameter data_param = 11;
+ if (has_data_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 11, *this->data_param_, output);
+ }
+
+ // optional .caffe.DropoutParameter dropout_param = 12;
+ if (has_dropout_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 12, *this->dropout_param_, output);
+ }
+
+ // optional .caffe.HDF5DataParameter hdf5_data_param = 13;
+ if (has_hdf5_data_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 13, *this->hdf5_data_param_, output);
+ }
+
+ // optional .caffe.HDF5OutputParameter hdf5_output_param = 14;
+ if (has_hdf5_output_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 14, *this->hdf5_output_param_, output);
+ }
+
+ // optional .caffe.ImageDataParameter image_data_param = 15;
+ if (has_image_data_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 15, *this->image_data_param_, output);
+ }
+
+ // optional .caffe.InfogainLossParameter infogain_loss_param = 16;
+ if (has_infogain_loss_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 16, *this->infogain_loss_param_, output);
+ }
+
+ // optional .caffe.InnerProductParameter inner_product_param = 17;
+ if (has_inner_product_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 17, *this->inner_product_param_, output);
+ }
+
+ // optional .caffe.LRNParameter lrn_param = 18;
+ if (has_lrn_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 18, *this->lrn_param_, output);
+ }
+
+ // optional .caffe.PoolingParameter pooling_param = 19;
+ if (has_pooling_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 19, *this->pooling_param_, output);
+ }
+
+ // optional .caffe.WindowDataParameter window_data_param = 20;
+ if (has_window_data_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 20, *this->window_data_param_, output);
+ }
+
+ // optional .caffe.PowerParameter power_param = 21;
+ if (has_power_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 21, *this->power_param_, output);
+ }
+
+ // optional .caffe.MemoryDataParameter memory_data_param = 22;
+ if (has_memory_data_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 22, *this->memory_data_param_, output);
+ }
+
+ // optional .caffe.ArgMaxParameter argmax_param = 23;
+ if (has_argmax_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 23, *this->argmax_param_, output);
+ }
+
+ // optional .caffe.EltwiseParameter eltwise_param = 24;
+ if (has_eltwise_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 24, *this->eltwise_param_, output);
+ }
+
+ // optional .caffe.ThresholdParameter threshold_param = 25;
+ if (has_threshold_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 25, *this->threshold_param_, output);
+ }
+
+ // optional .caffe.DummyDataParameter dummy_data_param = 26;
+ if (has_dummy_data_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 26, *this->dummy_data_param_, output);
+ }
+
+ // optional .caffe.AccuracyParameter accuracy_param = 27;
+ if (has_accuracy_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 27, *this->accuracy_param_, output);
+ }
+
+ // optional .caffe.HingeLossParameter hinge_loss_param = 29;
+ if (has_hinge_loss_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 29, *this->hinge_loss_param_, output);
+ }
+
+ // optional .caffe.ReLUParameter relu_param = 30;
+ if (has_relu_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 30, *this->relu_param_, output);
+ }
+
+ // optional .caffe.SliceParameter slice_param = 31;
+ if (has_slice_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 31, *this->slice_param_, output);
+ }
+
+ // repeated .caffe.NetStateRule include = 32;
+ for (unsigned int i = 0, n = this->include_size(); i < n; i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 32, this->include(i), output);
+ }
+
+ // repeated .caffe.NetStateRule exclude = 33;
+ for (unsigned int i = 0, n = this->exclude_size(); i < n; i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 33, this->exclude(i), output);
+ }
+
+ // optional .caffe.MVNParameter mvn_param = 34;
+ if (has_mvn_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 34, *this->mvn_param_, output);
+ }
+
+ // repeated float loss_weight = 35;
+ for (int i = 0; i < this->loss_weight_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(
+ 35, this->loss_weight(i), output);
+ }
+
+ // optional .caffe.TransformationParameter transform_param = 36;
+ if (has_transform_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 36, *this->transform_param_, output);
+ }
+
+ // optional .caffe.TanHParameter tanh_param = 37;
+ if (has_tanh_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 37, *this->tanh_param_, output);
+ }
+
+ // optional .caffe.SigmoidParameter sigmoid_param = 38;
+ if (has_sigmoid_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 38, *this->sigmoid_param_, output);
+ }
+
+ // optional .caffe.SoftmaxParameter softmax_param = 39;
+ if (has_softmax_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 39, *this->softmax_param_, output);
+ }
+
+ // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40;
+ if (has_contrastive_loss_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 40, *this->contrastive_loss_param_, output);
+ }
+
+ // optional .caffe.ExpParameter exp_param = 41;
+ if (has_exp_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 41, *this->exp_param_, output);
+ }
+
+ // optional .caffe.LossParameter loss_param = 42;
+ if (has_loss_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 42, *this->loss_param_, output);
+ }
+
+ // repeated string param = 1001;
+ for (int i = 0; i < this->param_size(); i++) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->param(i).data(), this->param(i).length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.V1LayerParameter.param");
+ ::google::protobuf::internal::WireFormatLite::WriteString(
+ 1001, this->param(i), output);
+ }
+
+ // repeated .caffe.V1LayerParameter.DimCheckMode blob_share_mode = 1002;
+ for (int i = 0; i < this->blob_share_mode_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 1002, this->blob_share_mode(i), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.V1LayerParameter)
+}
+
+::google::protobuf::uint8* V1LayerParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.V1LayerParameter)
+ // optional .caffe.V0LayerParameter layer = 1;
+ if (has_layer()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 1, *this->layer_, false, target);
+ }
+
+ // repeated string bottom = 2;
+ for (int i = 0; i < this->bottom_size(); i++) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->bottom(i).data(), this->bottom(i).length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.V1LayerParameter.bottom");
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteStringToArray(2, this->bottom(i), target);
+ }
+
+ // repeated string top = 3;
+ for (int i = 0; i < this->top_size(); i++) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->top(i).data(), this->top(i).length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.V1LayerParameter.top");
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteStringToArray(3, this->top(i), target);
+ }
+
+ // optional string name = 4;
+ if (has_name()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->name().data(), this->name().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.V1LayerParameter.name");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 4, this->name(), target);
+ }
+
+ // optional .caffe.V1LayerParameter.LayerType type = 5;
+ if (has_type()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 5, this->type(), target);
+ }
+
+ // repeated .caffe.BlobProto blobs = 6;
+ for (unsigned int i = 0, n = this->blobs_size(); i < n; i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 6, this->blobs(i), false, target);
+ }
+
+ // repeated float blobs_lr = 7;
+ for (int i = 0; i < this->blobs_lr_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteFloatToArray(7, this->blobs_lr(i), target);
+ }
+
+ // repeated float weight_decay = 8;
+ for (int i = 0; i < this->weight_decay_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteFloatToArray(8, this->weight_decay(i), target);
+ }
+
+ // optional .caffe.ConcatParameter concat_param = 9;
+ if (has_concat_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 9, *this->concat_param_, false, target);
+ }
+
+ // optional .caffe.ConvolutionParameter convolution_param = 10;
+ if (has_convolution_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 10, *this->convolution_param_, false, target);
+ }
+
+ // optional .caffe.DataParameter data_param = 11;
+ if (has_data_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 11, *this->data_param_, false, target);
+ }
+
+ // optional .caffe.DropoutParameter dropout_param = 12;
+ if (has_dropout_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 12, *this->dropout_param_, false, target);
+ }
+
+ // optional .caffe.HDF5DataParameter hdf5_data_param = 13;
+ if (has_hdf5_data_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 13, *this->hdf5_data_param_, false, target);
+ }
+
+ // optional .caffe.HDF5OutputParameter hdf5_output_param = 14;
+ if (has_hdf5_output_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 14, *this->hdf5_output_param_, false, target);
+ }
+
+ // optional .caffe.ImageDataParameter image_data_param = 15;
+ if (has_image_data_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 15, *this->image_data_param_, false, target);
+ }
+
+ // optional .caffe.InfogainLossParameter infogain_loss_param = 16;
+ if (has_infogain_loss_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 16, *this->infogain_loss_param_, false, target);
+ }
+
+ // optional .caffe.InnerProductParameter inner_product_param = 17;
+ if (has_inner_product_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 17, *this->inner_product_param_, false, target);
+ }
+
+ // optional .caffe.LRNParameter lrn_param = 18;
+ if (has_lrn_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 18, *this->lrn_param_, false, target);
+ }
+
+ // optional .caffe.PoolingParameter pooling_param = 19;
+ if (has_pooling_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 19, *this->pooling_param_, false, target);
+ }
+
+ // optional .caffe.WindowDataParameter window_data_param = 20;
+ if (has_window_data_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 20, *this->window_data_param_, false, target);
+ }
+
+ // optional .caffe.PowerParameter power_param = 21;
+ if (has_power_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 21, *this->power_param_, false, target);
+ }
+
+ // optional .caffe.MemoryDataParameter memory_data_param = 22;
+ if (has_memory_data_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 22, *this->memory_data_param_, false, target);
+ }
+
+ // optional .caffe.ArgMaxParameter argmax_param = 23;
+ if (has_argmax_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 23, *this->argmax_param_, false, target);
+ }
+
+ // optional .caffe.EltwiseParameter eltwise_param = 24;
+ if (has_eltwise_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 24, *this->eltwise_param_, false, target);
+ }
+
+ // optional .caffe.ThresholdParameter threshold_param = 25;
+ if (has_threshold_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 25, *this->threshold_param_, false, target);
+ }
+
+ // optional .caffe.DummyDataParameter dummy_data_param = 26;
+ if (has_dummy_data_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 26, *this->dummy_data_param_, false, target);
+ }
+
+ // optional .caffe.AccuracyParameter accuracy_param = 27;
+ if (has_accuracy_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 27, *this->accuracy_param_, false, target);
+ }
+
+ // optional .caffe.HingeLossParameter hinge_loss_param = 29;
+ if (has_hinge_loss_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 29, *this->hinge_loss_param_, false, target);
+ }
+
+ // optional .caffe.ReLUParameter relu_param = 30;
+ if (has_relu_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 30, *this->relu_param_, false, target);
+ }
+
+ // optional .caffe.SliceParameter slice_param = 31;
+ if (has_slice_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 31, *this->slice_param_, false, target);
+ }
+
+ // repeated .caffe.NetStateRule include = 32;
+ for (unsigned int i = 0, n = this->include_size(); i < n; i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 32, this->include(i), false, target);
+ }
+
+ // repeated .caffe.NetStateRule exclude = 33;
+ for (unsigned int i = 0, n = this->exclude_size(); i < n; i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 33, this->exclude(i), false, target);
+ }
+
+ // optional .caffe.MVNParameter mvn_param = 34;
+ if (has_mvn_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 34, *this->mvn_param_, false, target);
+ }
+
+ // repeated float loss_weight = 35;
+ for (int i = 0; i < this->loss_weight_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteFloatToArray(35, this->loss_weight(i), target);
+ }
+
+ // optional .caffe.TransformationParameter transform_param = 36;
+ if (has_transform_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 36, *this->transform_param_, false, target);
+ }
+
+ // optional .caffe.TanHParameter tanh_param = 37;
+ if (has_tanh_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 37, *this->tanh_param_, false, target);
+ }
+
+ // optional .caffe.SigmoidParameter sigmoid_param = 38;
+ if (has_sigmoid_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 38, *this->sigmoid_param_, false, target);
+ }
+
+ // optional .caffe.SoftmaxParameter softmax_param = 39;
+ if (has_softmax_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 39, *this->softmax_param_, false, target);
+ }
+
+ // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40;
+ if (has_contrastive_loss_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 40, *this->contrastive_loss_param_, false, target);
+ }
+
+ // optional .caffe.ExpParameter exp_param = 41;
+ if (has_exp_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 41, *this->exp_param_, false, target);
+ }
+
+ // optional .caffe.LossParameter loss_param = 42;
+ if (has_loss_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 42, *this->loss_param_, false, target);
+ }
+
+ // repeated string param = 1001;
+ for (int i = 0; i < this->param_size(); i++) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->param(i).data(), this->param(i).length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.V1LayerParameter.param");
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteStringToArray(1001, this->param(i), target);
+ }
+
+ // repeated .caffe.V1LayerParameter.DimCheckMode blob_share_mode = 1002;
+ for (int i = 0; i < this->blob_share_mode_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 1002, this->blob_share_mode(i), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.V1LayerParameter)
+ return target;
+}
+
+size_t V1LayerParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.V1LayerParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[2 / 32] & 36u) {
+ // optional string name = 4;
+ if (has_name()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->name());
+ }
+
+ // optional .caffe.V1LayerParameter.LayerType type = 5;
+ if (has_type()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->type());
+ }
+
+ }
+ if (_has_bits_[12 / 32] & 61440u) {
+ // optional .caffe.AccuracyParameter accuracy_param = 27;
+ if (has_accuracy_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->accuracy_param_);
+ }
+
+ // optional .caffe.ArgMaxParameter argmax_param = 23;
+ if (has_argmax_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->argmax_param_);
+ }
+
+ // optional .caffe.ConcatParameter concat_param = 9;
+ if (has_concat_param()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->concat_param_);
+ }
+
+ // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40;
+ if (has_contrastive_loss_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->contrastive_loss_param_);
+ }
+
+ }
+ if (_has_bits_[16 / 32] & 16711680u) {
+ // optional .caffe.ConvolutionParameter convolution_param = 10;
+ if (has_convolution_param()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->convolution_param_);
+ }
+
+ // optional .caffe.DataParameter data_param = 11;
+ if (has_data_param()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->data_param_);
+ }
+
+ // optional .caffe.DropoutParameter dropout_param = 12;
+ if (has_dropout_param()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->dropout_param_);
+ }
+
+ // optional .caffe.DummyDataParameter dummy_data_param = 26;
+ if (has_dummy_data_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->dummy_data_param_);
+ }
+
+ // optional .caffe.EltwiseParameter eltwise_param = 24;
+ if (has_eltwise_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->eltwise_param_);
+ }
+
+ // optional .caffe.ExpParameter exp_param = 41;
+ if (has_exp_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->exp_param_);
+ }
+
+ // optional .caffe.HDF5DataParameter hdf5_data_param = 13;
+ if (has_hdf5_data_param()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->hdf5_data_param_);
+ }
+
+ // optional .caffe.HDF5OutputParameter hdf5_output_param = 14;
+ if (has_hdf5_output_param()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->hdf5_output_param_);
+ }
+
+ }
+ if (_has_bits_[24 / 32] & 4278190080u) {
+ // optional .caffe.HingeLossParameter hinge_loss_param = 29;
+ if (has_hinge_loss_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->hinge_loss_param_);
+ }
+
+ // optional .caffe.ImageDataParameter image_data_param = 15;
+ if (has_image_data_param()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->image_data_param_);
+ }
+
+ // optional .caffe.InfogainLossParameter infogain_loss_param = 16;
+ if (has_infogain_loss_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->infogain_loss_param_);
+ }
+
+ // optional .caffe.InnerProductParameter inner_product_param = 17;
+ if (has_inner_product_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->inner_product_param_);
+ }
+
+ // optional .caffe.LRNParameter lrn_param = 18;
+ if (has_lrn_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->lrn_param_);
+ }
+
+ // optional .caffe.MemoryDataParameter memory_data_param = 22;
+ if (has_memory_data_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->memory_data_param_);
+ }
+
+ // optional .caffe.MVNParameter mvn_param = 34;
+ if (has_mvn_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->mvn_param_);
+ }
+
+ // optional .caffe.PoolingParameter pooling_param = 19;
+ if (has_pooling_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->pooling_param_);
+ }
+
+ }
+ if (_has_bits_[32 / 32] & 255u) {
+ // optional .caffe.PowerParameter power_param = 21;
+ if (has_power_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->power_param_);
+ }
+
+ // optional .caffe.ReLUParameter relu_param = 30;
+ if (has_relu_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->relu_param_);
+ }
+
+ // optional .caffe.SigmoidParameter sigmoid_param = 38;
+ if (has_sigmoid_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->sigmoid_param_);
+ }
+
+ // optional .caffe.SoftmaxParameter softmax_param = 39;
+ if (has_softmax_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->softmax_param_);
+ }
+
+ // optional .caffe.SliceParameter slice_param = 31;
+ if (has_slice_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->slice_param_);
+ }
+
+ // optional .caffe.TanHParameter tanh_param = 37;
+ if (has_tanh_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->tanh_param_);
+ }
+
+ // optional .caffe.ThresholdParameter threshold_param = 25;
+ if (has_threshold_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->threshold_param_);
+ }
+
+ // optional .caffe.WindowDataParameter window_data_param = 20;
+ if (has_window_data_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->window_data_param_);
+ }
+
+ }
+ if (_has_bits_[40 / 32] & 1792u) {
+ // optional .caffe.TransformationParameter transform_param = 36;
+ if (has_transform_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->transform_param_);
+ }
+
+ // optional .caffe.LossParameter loss_param = 42;
+ if (has_loss_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->loss_param_);
+ }
+
+ // optional .caffe.V0LayerParameter layer = 1;
+ if (has_layer()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->layer_);
+ }
+
+ }
+ // repeated string bottom = 2;
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->bottom_size());
+ for (int i = 0; i < this->bottom_size(); i++) {
+ total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->bottom(i));
+ }
+
+ // repeated string top = 3;
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->top_size());
+ for (int i = 0; i < this->top_size(); i++) {
+ total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->top(i));
+ }
+
+ // repeated .caffe.NetStateRule include = 32;
+ {
+ unsigned int count = this->include_size();
+ total_size += 2UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->include(i));
+ }
+ }
+
+ // repeated .caffe.NetStateRule exclude = 33;
+ {
+ unsigned int count = this->exclude_size();
+ total_size += 2UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->exclude(i));
+ }
+ }
+
+ // repeated .caffe.BlobProto blobs = 6;
+ {
+ unsigned int count = this->blobs_size();
+ total_size += 1UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->blobs(i));
+ }
+ }
+
+ // repeated string param = 1001;
+ total_size += 2 *
+ ::google::protobuf::internal::FromIntSize(this->param_size());
+ for (int i = 0; i < this->param_size(); i++) {
+ total_size += ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->param(i));
+ }
+
+ // repeated .caffe.V1LayerParameter.DimCheckMode blob_share_mode = 1002;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->blob_share_mode_size();for (unsigned int i = 0; i < count; i++) {
+ data_size += ::google::protobuf::internal::WireFormatLite::EnumSize(
+ this->blob_share_mode(i));
+ }
+ total_size += (2UL * count) + data_size;
+ }
+
+ // repeated float blobs_lr = 7;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->blobs_lr_size();
+ data_size = 4UL * count;
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->blobs_lr_size());
+ total_size += data_size;
+ }
+
+ // repeated float weight_decay = 8;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->weight_decay_size();
+ data_size = 4UL * count;
+ total_size += 1 *
+ ::google::protobuf::internal::FromIntSize(this->weight_decay_size());
+ total_size += data_size;
+ }
+
+ // repeated float loss_weight = 35;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->loss_weight_size();
+ data_size = 4UL * count;
+ total_size += 2 *
+ ::google::protobuf::internal::FromIntSize(this->loss_weight_size());
+ total_size += data_size;
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void V1LayerParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.V1LayerParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const V1LayerParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const V1LayerParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.V1LayerParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.V1LayerParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void V1LayerParameter::MergeFrom(const V1LayerParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.V1LayerParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void V1LayerParameter::UnsafeMergeFrom(const V1LayerParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ bottom_.UnsafeMergeFrom(from.bottom_);
+ top_.UnsafeMergeFrom(from.top_);
+ include_.MergeFrom(from.include_);
+ exclude_.MergeFrom(from.exclude_);
+ blobs_.MergeFrom(from.blobs_);
+ param_.UnsafeMergeFrom(from.param_);
+ blob_share_mode_.UnsafeMergeFrom(from.blob_share_mode_);
+ blobs_lr_.UnsafeMergeFrom(from.blobs_lr_);
+ weight_decay_.UnsafeMergeFrom(from.weight_decay_);
+ loss_weight_.UnsafeMergeFrom(from.loss_weight_);
+ if (from._has_bits_[2 / 32] & (0xffu << (2 % 32))) {
+ if (from.has_name()) {
+ set_has_name();
+ name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
+ }
+ if (from.has_type()) {
+ set_type(from.type());
+ }
+ }
+ if (from._has_bits_[12 / 32] & (0xffu << (12 % 32))) {
+ if (from.has_accuracy_param()) {
+ mutable_accuracy_param()->::caffe::AccuracyParameter::MergeFrom(from.accuracy_param());
+ }
+ if (from.has_argmax_param()) {
+ mutable_argmax_param()->::caffe::ArgMaxParameter::MergeFrom(from.argmax_param());
+ }
+ if (from.has_concat_param()) {
+ mutable_concat_param()->::caffe::ConcatParameter::MergeFrom(from.concat_param());
+ }
+ if (from.has_contrastive_loss_param()) {
+ mutable_contrastive_loss_param()->::caffe::ContrastiveLossParameter::MergeFrom(from.contrastive_loss_param());
+ }
+ }
+ if (from._has_bits_[16 / 32] & (0xffu << (16 % 32))) {
+ if (from.has_convolution_param()) {
+ mutable_convolution_param()->::caffe::ConvolutionParameter::MergeFrom(from.convolution_param());
+ }
+ if (from.has_data_param()) {
+ mutable_data_param()->::caffe::DataParameter::MergeFrom(from.data_param());
+ }
+ if (from.has_dropout_param()) {
+ mutable_dropout_param()->::caffe::DropoutParameter::MergeFrom(from.dropout_param());
+ }
+ if (from.has_dummy_data_param()) {
+ mutable_dummy_data_param()->::caffe::DummyDataParameter::MergeFrom(from.dummy_data_param());
+ }
+ if (from.has_eltwise_param()) {
+ mutable_eltwise_param()->::caffe::EltwiseParameter::MergeFrom(from.eltwise_param());
+ }
+ if (from.has_exp_param()) {
+ mutable_exp_param()->::caffe::ExpParameter::MergeFrom(from.exp_param());
+ }
+ if (from.has_hdf5_data_param()) {
+ mutable_hdf5_data_param()->::caffe::HDF5DataParameter::MergeFrom(from.hdf5_data_param());
+ }
+ if (from.has_hdf5_output_param()) {
+ mutable_hdf5_output_param()->::caffe::HDF5OutputParameter::MergeFrom(from.hdf5_output_param());
+ }
+ }
+ if (from._has_bits_[24 / 32] & (0xffu << (24 % 32))) {
+ if (from.has_hinge_loss_param()) {
+ mutable_hinge_loss_param()->::caffe::HingeLossParameter::MergeFrom(from.hinge_loss_param());
+ }
+ if (from.has_image_data_param()) {
+ mutable_image_data_param()->::caffe::ImageDataParameter::MergeFrom(from.image_data_param());
+ }
+ if (from.has_infogain_loss_param()) {
+ mutable_infogain_loss_param()->::caffe::InfogainLossParameter::MergeFrom(from.infogain_loss_param());
+ }
+ if (from.has_inner_product_param()) {
+ mutable_inner_product_param()->::caffe::InnerProductParameter::MergeFrom(from.inner_product_param());
+ }
+ if (from.has_lrn_param()) {
+ mutable_lrn_param()->::caffe::LRNParameter::MergeFrom(from.lrn_param());
+ }
+ if (from.has_memory_data_param()) {
+ mutable_memory_data_param()->::caffe::MemoryDataParameter::MergeFrom(from.memory_data_param());
+ }
+ if (from.has_mvn_param()) {
+ mutable_mvn_param()->::caffe::MVNParameter::MergeFrom(from.mvn_param());
+ }
+ if (from.has_pooling_param()) {
+ mutable_pooling_param()->::caffe::PoolingParameter::MergeFrom(from.pooling_param());
+ }
+ }
+ if (from._has_bits_[32 / 32] & (0xffu << (32 % 32))) {
+ if (from.has_power_param()) {
+ mutable_power_param()->::caffe::PowerParameter::MergeFrom(from.power_param());
+ }
+ if (from.has_relu_param()) {
+ mutable_relu_param()->::caffe::ReLUParameter::MergeFrom(from.relu_param());
+ }
+ if (from.has_sigmoid_param()) {
+ mutable_sigmoid_param()->::caffe::SigmoidParameter::MergeFrom(from.sigmoid_param());
+ }
+ if (from.has_softmax_param()) {
+ mutable_softmax_param()->::caffe::SoftmaxParameter::MergeFrom(from.softmax_param());
+ }
+ if (from.has_slice_param()) {
+ mutable_slice_param()->::caffe::SliceParameter::MergeFrom(from.slice_param());
+ }
+ if (from.has_tanh_param()) {
+ mutable_tanh_param()->::caffe::TanHParameter::MergeFrom(from.tanh_param());
+ }
+ if (from.has_threshold_param()) {
+ mutable_threshold_param()->::caffe::ThresholdParameter::MergeFrom(from.threshold_param());
+ }
+ if (from.has_window_data_param()) {
+ mutable_window_data_param()->::caffe::WindowDataParameter::MergeFrom(from.window_data_param());
+ }
+ }
+ if (from._has_bits_[40 / 32] & (0xffu << (40 % 32))) {
+ if (from.has_transform_param()) {
+ mutable_transform_param()->::caffe::TransformationParameter::MergeFrom(from.transform_param());
+ }
+ if (from.has_loss_param()) {
+ mutable_loss_param()->::caffe::LossParameter::MergeFrom(from.loss_param());
+ }
+ if (from.has_layer()) {
+ mutable_layer()->::caffe::V0LayerParameter::MergeFrom(from.layer());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void V1LayerParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.V1LayerParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void V1LayerParameter::CopyFrom(const V1LayerParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.V1LayerParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool V1LayerParameter::IsInitialized() const {
+
+ return true;
+}
+
+void V1LayerParameter::Swap(V1LayerParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void V1LayerParameter::InternalSwap(V1LayerParameter* other) {
+ bottom_.UnsafeArenaSwap(&other->bottom_);
+ top_.UnsafeArenaSwap(&other->top_);
+ name_.Swap(&other->name_);
+ include_.UnsafeArenaSwap(&other->include_);
+ exclude_.UnsafeArenaSwap(&other->exclude_);
+ std::swap(type_, other->type_);
+ blobs_.UnsafeArenaSwap(&other->blobs_);
+ param_.UnsafeArenaSwap(&other->param_);
+ blob_share_mode_.UnsafeArenaSwap(&other->blob_share_mode_);
+ blobs_lr_.UnsafeArenaSwap(&other->blobs_lr_);
+ weight_decay_.UnsafeArenaSwap(&other->weight_decay_);
+ loss_weight_.UnsafeArenaSwap(&other->loss_weight_);
+ std::swap(accuracy_param_, other->accuracy_param_);
+ std::swap(argmax_param_, other->argmax_param_);
+ std::swap(concat_param_, other->concat_param_);
+ std::swap(contrastive_loss_param_, other->contrastive_loss_param_);
+ std::swap(convolution_param_, other->convolution_param_);
+ std::swap(data_param_, other->data_param_);
+ std::swap(dropout_param_, other->dropout_param_);
+ std::swap(dummy_data_param_, other->dummy_data_param_);
+ std::swap(eltwise_param_, other->eltwise_param_);
+ std::swap(exp_param_, other->exp_param_);
+ std::swap(hdf5_data_param_, other->hdf5_data_param_);
+ std::swap(hdf5_output_param_, other->hdf5_output_param_);
+ std::swap(hinge_loss_param_, other->hinge_loss_param_);
+ std::swap(image_data_param_, other->image_data_param_);
+ std::swap(infogain_loss_param_, other->infogain_loss_param_);
+ std::swap(inner_product_param_, other->inner_product_param_);
+ std::swap(lrn_param_, other->lrn_param_);
+ std::swap(memory_data_param_, other->memory_data_param_);
+ std::swap(mvn_param_, other->mvn_param_);
+ std::swap(pooling_param_, other->pooling_param_);
+ std::swap(power_param_, other->power_param_);
+ std::swap(relu_param_, other->relu_param_);
+ std::swap(sigmoid_param_, other->sigmoid_param_);
+ std::swap(softmax_param_, other->softmax_param_);
+ std::swap(slice_param_, other->slice_param_);
+ std::swap(tanh_param_, other->tanh_param_);
+ std::swap(threshold_param_, other->threshold_param_);
+ std::swap(window_data_param_, other->window_data_param_);
+ std::swap(transform_param_, other->transform_param_);
+ std::swap(loss_param_, other->loss_param_);
+ std::swap(layer_, other->layer_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ std::swap(_has_bits_[1], other->_has_bits_[1]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata V1LayerParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = V1LayerParameter_descriptor_;
+ metadata.reflection = V1LayerParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// V1LayerParameter
+
+// repeated string bottom = 2;
+int V1LayerParameter::bottom_size() const {
+ return bottom_.size();
+}
+void V1LayerParameter::clear_bottom() {
+ bottom_.Clear();
+}
+const ::std::string& V1LayerParameter::bottom(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.bottom)
+ return bottom_.Get(index);
+}
+::std::string* V1LayerParameter::mutable_bottom(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.bottom)
+ return bottom_.Mutable(index);
+}
+void V1LayerParameter::set_bottom(int index, const ::std::string& value) {
+ // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.bottom)
+ bottom_.Mutable(index)->assign(value);
+}
+void V1LayerParameter::set_bottom(int index, const char* value) {
+ bottom_.Mutable(index)->assign(value);
+ // @@protoc_insertion_point(field_set_char:caffe.V1LayerParameter.bottom)
+}
+void V1LayerParameter::set_bottom(int index, const char* value, size_t size) {
+ bottom_.Mutable(index)->assign(
+ reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_set_pointer:caffe.V1LayerParameter.bottom)
+}
+::std::string* V1LayerParameter::add_bottom() {
+ // @@protoc_insertion_point(field_add_mutable:caffe.V1LayerParameter.bottom)
+ return bottom_.Add();
+}
+void V1LayerParameter::add_bottom(const ::std::string& value) {
+ bottom_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.bottom)
+}
+void V1LayerParameter::add_bottom(const char* value) {
+ bottom_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add_char:caffe.V1LayerParameter.bottom)
+}
+void V1LayerParameter::add_bottom(const char* value, size_t size) {
+ bottom_.Add()->assign(reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_add_pointer:caffe.V1LayerParameter.bottom)
+}
+const ::google::protobuf::RepeatedPtrField< ::std::string>&
+V1LayerParameter::bottom() const {
+ // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.bottom)
+ return bottom_;
+}
+::google::protobuf::RepeatedPtrField< ::std::string>*
+V1LayerParameter::mutable_bottom() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.bottom)
+ return &bottom_;
+}
+
+// repeated string top = 3;
+int V1LayerParameter::top_size() const {
+ return top_.size();
+}
+void V1LayerParameter::clear_top() {
+ top_.Clear();
+}
+const ::std::string& V1LayerParameter::top(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.top)
+ return top_.Get(index);
+}
+::std::string* V1LayerParameter::mutable_top(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.top)
+ return top_.Mutable(index);
+}
+void V1LayerParameter::set_top(int index, const ::std::string& value) {
+ // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.top)
+ top_.Mutable(index)->assign(value);
+}
+void V1LayerParameter::set_top(int index, const char* value) {
+ top_.Mutable(index)->assign(value);
+ // @@protoc_insertion_point(field_set_char:caffe.V1LayerParameter.top)
+}
+void V1LayerParameter::set_top(int index, const char* value, size_t size) {
+ top_.Mutable(index)->assign(
+ reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_set_pointer:caffe.V1LayerParameter.top)
+}
+::std::string* V1LayerParameter::add_top() {
+ // @@protoc_insertion_point(field_add_mutable:caffe.V1LayerParameter.top)
+ return top_.Add();
+}
+void V1LayerParameter::add_top(const ::std::string& value) {
+ top_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.top)
+}
+void V1LayerParameter::add_top(const char* value) {
+ top_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add_char:caffe.V1LayerParameter.top)
+}
+void V1LayerParameter::add_top(const char* value, size_t size) {
+ top_.Add()->assign(reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_add_pointer:caffe.V1LayerParameter.top)
+}
+const ::google::protobuf::RepeatedPtrField< ::std::string>&
+V1LayerParameter::top() const {
+ // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.top)
+ return top_;
+}
+::google::protobuf::RepeatedPtrField< ::std::string>*
+V1LayerParameter::mutable_top() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.top)
+ return &top_;
+}
+
+// optional string name = 4;
+bool V1LayerParameter::has_name() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void V1LayerParameter::set_has_name() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void V1LayerParameter::clear_has_name() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void V1LayerParameter::clear_name() {
+ name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_name();
+}
+const ::std::string& V1LayerParameter::name() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.name)
+ return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void V1LayerParameter::set_name(const ::std::string& value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.name)
+}
+void V1LayerParameter::set_name(const char* value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.V1LayerParameter.name)
+}
+void V1LayerParameter::set_name(const char* value, size_t size) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.V1LayerParameter.name)
+}
+::std::string* V1LayerParameter::mutable_name() {
+ set_has_name();
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.name)
+ return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* V1LayerParameter::release_name() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.name)
+ clear_has_name();
+ return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void V1LayerParameter::set_allocated_name(::std::string* name) {
+ if (name != NULL) {
+ set_has_name();
+ } else {
+ clear_has_name();
+ }
+ name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.name)
+}
+
+// repeated .caffe.NetStateRule include = 32;
+int V1LayerParameter::include_size() const {
+ return include_.size();
+}
+void V1LayerParameter::clear_include() {
+ include_.Clear();
+}
+const ::caffe::NetStateRule& V1LayerParameter::include(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.include)
+ return include_.Get(index);
+}
+::caffe::NetStateRule* V1LayerParameter::mutable_include(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.include)
+ return include_.Mutable(index);
+}
+::caffe::NetStateRule* V1LayerParameter::add_include() {
+ // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.include)
+ return include_.Add();
+}
+::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >*
+V1LayerParameter::mutable_include() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.include)
+ return &include_;
+}
+const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >&
+V1LayerParameter::include() const {
+ // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.include)
+ return include_;
+}
+
+// repeated .caffe.NetStateRule exclude = 33;
+int V1LayerParameter::exclude_size() const {
+ return exclude_.size();
+}
+void V1LayerParameter::clear_exclude() {
+ exclude_.Clear();
+}
+const ::caffe::NetStateRule& V1LayerParameter::exclude(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.exclude)
+ return exclude_.Get(index);
+}
+::caffe::NetStateRule* V1LayerParameter::mutable_exclude(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.exclude)
+ return exclude_.Mutable(index);
+}
+::caffe::NetStateRule* V1LayerParameter::add_exclude() {
+ // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.exclude)
+ return exclude_.Add();
+}
+::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >*
+V1LayerParameter::mutable_exclude() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.exclude)
+ return &exclude_;
+}
+const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >&
+V1LayerParameter::exclude() const {
+ // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.exclude)
+ return exclude_;
+}
+
+// optional .caffe.V1LayerParameter.LayerType type = 5;
+bool V1LayerParameter::has_type() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+void V1LayerParameter::set_has_type() {
+ _has_bits_[0] |= 0x00000020u;
+}
+void V1LayerParameter::clear_has_type() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+void V1LayerParameter::clear_type() {
+ type_ = 0;
+ clear_has_type();
+}
+::caffe::V1LayerParameter_LayerType V1LayerParameter::type() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.type)
+ return static_cast< ::caffe::V1LayerParameter_LayerType >(type_);
+}
+void V1LayerParameter::set_type(::caffe::V1LayerParameter_LayerType value) {
+ assert(::caffe::V1LayerParameter_LayerType_IsValid(value));
+ set_has_type();
+ type_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.type)
+}
+
+// repeated .caffe.BlobProto blobs = 6;
+int V1LayerParameter::blobs_size() const {
+ return blobs_.size();
+}
+void V1LayerParameter::clear_blobs() {
+ blobs_.Clear();
+}
+const ::caffe::BlobProto& V1LayerParameter::blobs(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.blobs)
+ return blobs_.Get(index);
+}
+::caffe::BlobProto* V1LayerParameter::mutable_blobs(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.blobs)
+ return blobs_.Mutable(index);
+}
+::caffe::BlobProto* V1LayerParameter::add_blobs() {
+ // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.blobs)
+ return blobs_.Add();
+}
+::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
+V1LayerParameter::mutable_blobs() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.blobs)
+ return &blobs_;
+}
+const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
+V1LayerParameter::blobs() const {
+ // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.blobs)
+ return blobs_;
+}
+
+// repeated string param = 1001;
+int V1LayerParameter::param_size() const {
+ return param_.size();
+}
+void V1LayerParameter::clear_param() {
+ param_.Clear();
+}
+const ::std::string& V1LayerParameter::param(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.param)
+ return param_.Get(index);
+}
+::std::string* V1LayerParameter::mutable_param(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.param)
+ return param_.Mutable(index);
+}
+void V1LayerParameter::set_param(int index, const ::std::string& value) {
+ // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.param)
+ param_.Mutable(index)->assign(value);
+}
+void V1LayerParameter::set_param(int index, const char* value) {
+ param_.Mutable(index)->assign(value);
+ // @@protoc_insertion_point(field_set_char:caffe.V1LayerParameter.param)
+}
+void V1LayerParameter::set_param(int index, const char* value, size_t size) {
+ param_.Mutable(index)->assign(
+ reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_set_pointer:caffe.V1LayerParameter.param)
+}
+::std::string* V1LayerParameter::add_param() {
+ // @@protoc_insertion_point(field_add_mutable:caffe.V1LayerParameter.param)
+ return param_.Add();
+}
+void V1LayerParameter::add_param(const ::std::string& value) {
+ param_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.param)
+}
+void V1LayerParameter::add_param(const char* value) {
+ param_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add_char:caffe.V1LayerParameter.param)
+}
+void V1LayerParameter::add_param(const char* value, size_t size) {
+ param_.Add()->assign(reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_add_pointer:caffe.V1LayerParameter.param)
+}
+const ::google::protobuf::RepeatedPtrField< ::std::string>&
+V1LayerParameter::param() const {
+ // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.param)
+ return param_;
+}
+::google::protobuf::RepeatedPtrField< ::std::string>*
+V1LayerParameter::mutable_param() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.param)
+ return ¶m_;
+}
+
+// repeated .caffe.V1LayerParameter.DimCheckMode blob_share_mode = 1002;
+int V1LayerParameter::blob_share_mode_size() const {
+ return blob_share_mode_.size();
+}
+void V1LayerParameter::clear_blob_share_mode() {
+ blob_share_mode_.Clear();
+}
+::caffe::V1LayerParameter_DimCheckMode V1LayerParameter::blob_share_mode(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.blob_share_mode)
+ return static_cast< ::caffe::V1LayerParameter_DimCheckMode >(blob_share_mode_.Get(index));
+}
+void V1LayerParameter::set_blob_share_mode(int index, ::caffe::V1LayerParameter_DimCheckMode value) {
+ assert(::caffe::V1LayerParameter_DimCheckMode_IsValid(value));
+ blob_share_mode_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.blob_share_mode)
+}
+void V1LayerParameter::add_blob_share_mode(::caffe::V1LayerParameter_DimCheckMode value) {
+ assert(::caffe::V1LayerParameter_DimCheckMode_IsValid(value));
+ blob_share_mode_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.blob_share_mode)
+}
+const ::google::protobuf::RepeatedField<int>&
+V1LayerParameter::blob_share_mode() const {
+ // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.blob_share_mode)
+ return blob_share_mode_;
+}
+::google::protobuf::RepeatedField<int>*
+V1LayerParameter::mutable_blob_share_mode() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.blob_share_mode)
+ return &blob_share_mode_;
+}
+
+// repeated float blobs_lr = 7;
+int V1LayerParameter::blobs_lr_size() const {
+ return blobs_lr_.size();
+}
+void V1LayerParameter::clear_blobs_lr() {
+ blobs_lr_.Clear();
+}
+float V1LayerParameter::blobs_lr(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.blobs_lr)
+ return blobs_lr_.Get(index);
+}
+void V1LayerParameter::set_blobs_lr(int index, float value) {
+ blobs_lr_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.blobs_lr)
+}
+void V1LayerParameter::add_blobs_lr(float value) {
+ blobs_lr_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.blobs_lr)
+}
+const ::google::protobuf::RepeatedField< float >&
+V1LayerParameter::blobs_lr() const {
+ // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.blobs_lr)
+ return blobs_lr_;
+}
+::google::protobuf::RepeatedField< float >*
+V1LayerParameter::mutable_blobs_lr() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.blobs_lr)
+ return &blobs_lr_;
+}
+
+// repeated float weight_decay = 8;
+int V1LayerParameter::weight_decay_size() const {
+ return weight_decay_.size();
+}
+void V1LayerParameter::clear_weight_decay() {
+ weight_decay_.Clear();
+}
+float V1LayerParameter::weight_decay(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.weight_decay)
+ return weight_decay_.Get(index);
+}
+void V1LayerParameter::set_weight_decay(int index, float value) {
+ weight_decay_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.weight_decay)
+}
+void V1LayerParameter::add_weight_decay(float value) {
+ weight_decay_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.weight_decay)
+}
+const ::google::protobuf::RepeatedField< float >&
+V1LayerParameter::weight_decay() const {
+ // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.weight_decay)
+ return weight_decay_;
+}
+::google::protobuf::RepeatedField< float >*
+V1LayerParameter::mutable_weight_decay() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.weight_decay)
+ return &weight_decay_;
+}
+
+// repeated float loss_weight = 35;
+int V1LayerParameter::loss_weight_size() const {
+ return loss_weight_.size();
+}
+void V1LayerParameter::clear_loss_weight() {
+ loss_weight_.Clear();
+}
+float V1LayerParameter::loss_weight(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.loss_weight)
+ return loss_weight_.Get(index);
+}
+void V1LayerParameter::set_loss_weight(int index, float value) {
+ loss_weight_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.loss_weight)
+}
+void V1LayerParameter::add_loss_weight(float value) {
+ loss_weight_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.loss_weight)
+}
+const ::google::protobuf::RepeatedField< float >&
+V1LayerParameter::loss_weight() const {
+ // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.loss_weight)
+ return loss_weight_;
+}
+::google::protobuf::RepeatedField< float >*
+V1LayerParameter::mutable_loss_weight() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.loss_weight)
+ return &loss_weight_;
+}
+
+// optional .caffe.AccuracyParameter accuracy_param = 27;
+bool V1LayerParameter::has_accuracy_param() const {
+ return (_has_bits_[0] & 0x00001000u) != 0;
+}
+void V1LayerParameter::set_has_accuracy_param() {
+ _has_bits_[0] |= 0x00001000u;
+}
+void V1LayerParameter::clear_has_accuracy_param() {
+ _has_bits_[0] &= ~0x00001000u;
+}
+void V1LayerParameter::clear_accuracy_param() {
+ if (accuracy_param_ != NULL) accuracy_param_->::caffe::AccuracyParameter::Clear();
+ clear_has_accuracy_param();
+}
+const ::caffe::AccuracyParameter& V1LayerParameter::accuracy_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.accuracy_param)
+ return accuracy_param_ != NULL ? *accuracy_param_
+ : *::caffe::AccuracyParameter::internal_default_instance();
+}
+::caffe::AccuracyParameter* V1LayerParameter::mutable_accuracy_param() {
+ set_has_accuracy_param();
+ if (accuracy_param_ == NULL) {
+ accuracy_param_ = new ::caffe::AccuracyParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.accuracy_param)
+ return accuracy_param_;
+}
+::caffe::AccuracyParameter* V1LayerParameter::release_accuracy_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.accuracy_param)
+ clear_has_accuracy_param();
+ ::caffe::AccuracyParameter* temp = accuracy_param_;
+ accuracy_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_accuracy_param(::caffe::AccuracyParameter* accuracy_param) {
+ delete accuracy_param_;
+ accuracy_param_ = accuracy_param;
+ if (accuracy_param) {
+ set_has_accuracy_param();
+ } else {
+ clear_has_accuracy_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.accuracy_param)
+}
+
+// optional .caffe.ArgMaxParameter argmax_param = 23;
+bool V1LayerParameter::has_argmax_param() const {
+ return (_has_bits_[0] & 0x00002000u) != 0;
+}
+void V1LayerParameter::set_has_argmax_param() {
+ _has_bits_[0] |= 0x00002000u;
+}
+void V1LayerParameter::clear_has_argmax_param() {
+ _has_bits_[0] &= ~0x00002000u;
+}
+void V1LayerParameter::clear_argmax_param() {
+ if (argmax_param_ != NULL) argmax_param_->::caffe::ArgMaxParameter::Clear();
+ clear_has_argmax_param();
+}
+const ::caffe::ArgMaxParameter& V1LayerParameter::argmax_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.argmax_param)
+ return argmax_param_ != NULL ? *argmax_param_
+ : *::caffe::ArgMaxParameter::internal_default_instance();
+}
+::caffe::ArgMaxParameter* V1LayerParameter::mutable_argmax_param() {
+ set_has_argmax_param();
+ if (argmax_param_ == NULL) {
+ argmax_param_ = new ::caffe::ArgMaxParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.argmax_param)
+ return argmax_param_;
+}
+::caffe::ArgMaxParameter* V1LayerParameter::release_argmax_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.argmax_param)
+ clear_has_argmax_param();
+ ::caffe::ArgMaxParameter* temp = argmax_param_;
+ argmax_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_argmax_param(::caffe::ArgMaxParameter* argmax_param) {
+ delete argmax_param_;
+ argmax_param_ = argmax_param;
+ if (argmax_param) {
+ set_has_argmax_param();
+ } else {
+ clear_has_argmax_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.argmax_param)
+}
+
+// optional .caffe.ConcatParameter concat_param = 9;
+bool V1LayerParameter::has_concat_param() const {
+ return (_has_bits_[0] & 0x00004000u) != 0;
+}
+void V1LayerParameter::set_has_concat_param() {
+ _has_bits_[0] |= 0x00004000u;
+}
+void V1LayerParameter::clear_has_concat_param() {
+ _has_bits_[0] &= ~0x00004000u;
+}
+void V1LayerParameter::clear_concat_param() {
+ if (concat_param_ != NULL) concat_param_->::caffe::ConcatParameter::Clear();
+ clear_has_concat_param();
+}
+const ::caffe::ConcatParameter& V1LayerParameter::concat_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.concat_param)
+ return concat_param_ != NULL ? *concat_param_
+ : *::caffe::ConcatParameter::internal_default_instance();
+}
+::caffe::ConcatParameter* V1LayerParameter::mutable_concat_param() {
+ set_has_concat_param();
+ if (concat_param_ == NULL) {
+ concat_param_ = new ::caffe::ConcatParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.concat_param)
+ return concat_param_;
+}
+::caffe::ConcatParameter* V1LayerParameter::release_concat_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.concat_param)
+ clear_has_concat_param();
+ ::caffe::ConcatParameter* temp = concat_param_;
+ concat_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_concat_param(::caffe::ConcatParameter* concat_param) {
+ delete concat_param_;
+ concat_param_ = concat_param;
+ if (concat_param) {
+ set_has_concat_param();
+ } else {
+ clear_has_concat_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.concat_param)
+}
+
+// optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40;
+bool V1LayerParameter::has_contrastive_loss_param() const {
+ return (_has_bits_[0] & 0x00008000u) != 0;
+}
+void V1LayerParameter::set_has_contrastive_loss_param() {
+ _has_bits_[0] |= 0x00008000u;
+}
+void V1LayerParameter::clear_has_contrastive_loss_param() {
+ _has_bits_[0] &= ~0x00008000u;
+}
+void V1LayerParameter::clear_contrastive_loss_param() {
+ if (contrastive_loss_param_ != NULL) contrastive_loss_param_->::caffe::ContrastiveLossParameter::Clear();
+ clear_has_contrastive_loss_param();
+}
+const ::caffe::ContrastiveLossParameter& V1LayerParameter::contrastive_loss_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.contrastive_loss_param)
+ return contrastive_loss_param_ != NULL ? *contrastive_loss_param_
+ : *::caffe::ContrastiveLossParameter::internal_default_instance();
+}
+::caffe::ContrastiveLossParameter* V1LayerParameter::mutable_contrastive_loss_param() {
+ set_has_contrastive_loss_param();
+ if (contrastive_loss_param_ == NULL) {
+ contrastive_loss_param_ = new ::caffe::ContrastiveLossParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.contrastive_loss_param)
+ return contrastive_loss_param_;
+}
+::caffe::ContrastiveLossParameter* V1LayerParameter::release_contrastive_loss_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.contrastive_loss_param)
+ clear_has_contrastive_loss_param();
+ ::caffe::ContrastiveLossParameter* temp = contrastive_loss_param_;
+ contrastive_loss_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_contrastive_loss_param(::caffe::ContrastiveLossParameter* contrastive_loss_param) {
+ delete contrastive_loss_param_;
+ contrastive_loss_param_ = contrastive_loss_param;
+ if (contrastive_loss_param) {
+ set_has_contrastive_loss_param();
+ } else {
+ clear_has_contrastive_loss_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.contrastive_loss_param)
+}
+
+// optional .caffe.ConvolutionParameter convolution_param = 10;
+bool V1LayerParameter::has_convolution_param() const {
+ return (_has_bits_[0] & 0x00010000u) != 0;
+}
+void V1LayerParameter::set_has_convolution_param() {
+ _has_bits_[0] |= 0x00010000u;
+}
+void V1LayerParameter::clear_has_convolution_param() {
+ _has_bits_[0] &= ~0x00010000u;
+}
+void V1LayerParameter::clear_convolution_param() {
+ if (convolution_param_ != NULL) convolution_param_->::caffe::ConvolutionParameter::Clear();
+ clear_has_convolution_param();
+}
+const ::caffe::ConvolutionParameter& V1LayerParameter::convolution_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.convolution_param)
+ return convolution_param_ != NULL ? *convolution_param_
+ : *::caffe::ConvolutionParameter::internal_default_instance();
+}
+::caffe::ConvolutionParameter* V1LayerParameter::mutable_convolution_param() {
+ set_has_convolution_param();
+ if (convolution_param_ == NULL) {
+ convolution_param_ = new ::caffe::ConvolutionParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.convolution_param)
+ return convolution_param_;
+}
+::caffe::ConvolutionParameter* V1LayerParameter::release_convolution_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.convolution_param)
+ clear_has_convolution_param();
+ ::caffe::ConvolutionParameter* temp = convolution_param_;
+ convolution_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_convolution_param(::caffe::ConvolutionParameter* convolution_param) {
+ delete convolution_param_;
+ convolution_param_ = convolution_param;
+ if (convolution_param) {
+ set_has_convolution_param();
+ } else {
+ clear_has_convolution_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.convolution_param)
+}
+
+// optional .caffe.DataParameter data_param = 11;
+bool V1LayerParameter::has_data_param() const {
+ return (_has_bits_[0] & 0x00020000u) != 0;
+}
+void V1LayerParameter::set_has_data_param() {
+ _has_bits_[0] |= 0x00020000u;
+}
+void V1LayerParameter::clear_has_data_param() {
+ _has_bits_[0] &= ~0x00020000u;
+}
+void V1LayerParameter::clear_data_param() {
+ if (data_param_ != NULL) data_param_->::caffe::DataParameter::Clear();
+ clear_has_data_param();
+}
+const ::caffe::DataParameter& V1LayerParameter::data_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.data_param)
+ return data_param_ != NULL ? *data_param_
+ : *::caffe::DataParameter::internal_default_instance();
+}
+::caffe::DataParameter* V1LayerParameter::mutable_data_param() {
+ set_has_data_param();
+ if (data_param_ == NULL) {
+ data_param_ = new ::caffe::DataParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.data_param)
+ return data_param_;
+}
+::caffe::DataParameter* V1LayerParameter::release_data_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.data_param)
+ clear_has_data_param();
+ ::caffe::DataParameter* temp = data_param_;
+ data_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_data_param(::caffe::DataParameter* data_param) {
+ delete data_param_;
+ data_param_ = data_param;
+ if (data_param) {
+ set_has_data_param();
+ } else {
+ clear_has_data_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.data_param)
+}
+
+// optional .caffe.DropoutParameter dropout_param = 12;
+bool V1LayerParameter::has_dropout_param() const {
+ return (_has_bits_[0] & 0x00040000u) != 0;
+}
+void V1LayerParameter::set_has_dropout_param() {
+ _has_bits_[0] |= 0x00040000u;
+}
+void V1LayerParameter::clear_has_dropout_param() {
+ _has_bits_[0] &= ~0x00040000u;
+}
+void V1LayerParameter::clear_dropout_param() {
+ if (dropout_param_ != NULL) dropout_param_->::caffe::DropoutParameter::Clear();
+ clear_has_dropout_param();
+}
+const ::caffe::DropoutParameter& V1LayerParameter::dropout_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.dropout_param)
+ return dropout_param_ != NULL ? *dropout_param_
+ : *::caffe::DropoutParameter::internal_default_instance();
+}
+::caffe::DropoutParameter* V1LayerParameter::mutable_dropout_param() {
+ set_has_dropout_param();
+ if (dropout_param_ == NULL) {
+ dropout_param_ = new ::caffe::DropoutParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.dropout_param)
+ return dropout_param_;
+}
+::caffe::DropoutParameter* V1LayerParameter::release_dropout_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.dropout_param)
+ clear_has_dropout_param();
+ ::caffe::DropoutParameter* temp = dropout_param_;
+ dropout_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_dropout_param(::caffe::DropoutParameter* dropout_param) {
+ delete dropout_param_;
+ dropout_param_ = dropout_param;
+ if (dropout_param) {
+ set_has_dropout_param();
+ } else {
+ clear_has_dropout_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.dropout_param)
+}
+
+// optional .caffe.DummyDataParameter dummy_data_param = 26;
+bool V1LayerParameter::has_dummy_data_param() const {
+ return (_has_bits_[0] & 0x00080000u) != 0;
+}
+void V1LayerParameter::set_has_dummy_data_param() {
+ _has_bits_[0] |= 0x00080000u;
+}
+void V1LayerParameter::clear_has_dummy_data_param() {
+ _has_bits_[0] &= ~0x00080000u;
+}
+void V1LayerParameter::clear_dummy_data_param() {
+ if (dummy_data_param_ != NULL) dummy_data_param_->::caffe::DummyDataParameter::Clear();
+ clear_has_dummy_data_param();
+}
+const ::caffe::DummyDataParameter& V1LayerParameter::dummy_data_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.dummy_data_param)
+ return dummy_data_param_ != NULL ? *dummy_data_param_
+ : *::caffe::DummyDataParameter::internal_default_instance();
+}
+::caffe::DummyDataParameter* V1LayerParameter::mutable_dummy_data_param() {
+ set_has_dummy_data_param();
+ if (dummy_data_param_ == NULL) {
+ dummy_data_param_ = new ::caffe::DummyDataParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.dummy_data_param)
+ return dummy_data_param_;
+}
+::caffe::DummyDataParameter* V1LayerParameter::release_dummy_data_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.dummy_data_param)
+ clear_has_dummy_data_param();
+ ::caffe::DummyDataParameter* temp = dummy_data_param_;
+ dummy_data_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_dummy_data_param(::caffe::DummyDataParameter* dummy_data_param) {
+ delete dummy_data_param_;
+ dummy_data_param_ = dummy_data_param;
+ if (dummy_data_param) {
+ set_has_dummy_data_param();
+ } else {
+ clear_has_dummy_data_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.dummy_data_param)
+}
+
+// optional .caffe.EltwiseParameter eltwise_param = 24;
+bool V1LayerParameter::has_eltwise_param() const {
+ return (_has_bits_[0] & 0x00100000u) != 0;
+}
+void V1LayerParameter::set_has_eltwise_param() {
+ _has_bits_[0] |= 0x00100000u;
+}
+void V1LayerParameter::clear_has_eltwise_param() {
+ _has_bits_[0] &= ~0x00100000u;
+}
+void V1LayerParameter::clear_eltwise_param() {
+ if (eltwise_param_ != NULL) eltwise_param_->::caffe::EltwiseParameter::Clear();
+ clear_has_eltwise_param();
+}
+const ::caffe::EltwiseParameter& V1LayerParameter::eltwise_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.eltwise_param)
+ return eltwise_param_ != NULL ? *eltwise_param_
+ : *::caffe::EltwiseParameter::internal_default_instance();
+}
+::caffe::EltwiseParameter* V1LayerParameter::mutable_eltwise_param() {
+ set_has_eltwise_param();
+ if (eltwise_param_ == NULL) {
+ eltwise_param_ = new ::caffe::EltwiseParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.eltwise_param)
+ return eltwise_param_;
+}
+::caffe::EltwiseParameter* V1LayerParameter::release_eltwise_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.eltwise_param)
+ clear_has_eltwise_param();
+ ::caffe::EltwiseParameter* temp = eltwise_param_;
+ eltwise_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_eltwise_param(::caffe::EltwiseParameter* eltwise_param) {
+ delete eltwise_param_;
+ eltwise_param_ = eltwise_param;
+ if (eltwise_param) {
+ set_has_eltwise_param();
+ } else {
+ clear_has_eltwise_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.eltwise_param)
+}
+
+// optional .caffe.ExpParameter exp_param = 41;
+bool V1LayerParameter::has_exp_param() const {
+ return (_has_bits_[0] & 0x00200000u) != 0;
+}
+void V1LayerParameter::set_has_exp_param() {
+ _has_bits_[0] |= 0x00200000u;
+}
+void V1LayerParameter::clear_has_exp_param() {
+ _has_bits_[0] &= ~0x00200000u;
+}
+void V1LayerParameter::clear_exp_param() {
+ if (exp_param_ != NULL) exp_param_->::caffe::ExpParameter::Clear();
+ clear_has_exp_param();
+}
+const ::caffe::ExpParameter& V1LayerParameter::exp_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.exp_param)
+ return exp_param_ != NULL ? *exp_param_
+ : *::caffe::ExpParameter::internal_default_instance();
+}
+::caffe::ExpParameter* V1LayerParameter::mutable_exp_param() {
+ set_has_exp_param();
+ if (exp_param_ == NULL) {
+ exp_param_ = new ::caffe::ExpParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.exp_param)
+ return exp_param_;
+}
+::caffe::ExpParameter* V1LayerParameter::release_exp_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.exp_param)
+ clear_has_exp_param();
+ ::caffe::ExpParameter* temp = exp_param_;
+ exp_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_exp_param(::caffe::ExpParameter* exp_param) {
+ delete exp_param_;
+ exp_param_ = exp_param;
+ if (exp_param) {
+ set_has_exp_param();
+ } else {
+ clear_has_exp_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.exp_param)
+}
+
+// optional .caffe.HDF5DataParameter hdf5_data_param = 13;
+bool V1LayerParameter::has_hdf5_data_param() const {
+ return (_has_bits_[0] & 0x00400000u) != 0;
+}
+void V1LayerParameter::set_has_hdf5_data_param() {
+ _has_bits_[0] |= 0x00400000u;
+}
+void V1LayerParameter::clear_has_hdf5_data_param() {
+ _has_bits_[0] &= ~0x00400000u;
+}
+void V1LayerParameter::clear_hdf5_data_param() {
+ if (hdf5_data_param_ != NULL) hdf5_data_param_->::caffe::HDF5DataParameter::Clear();
+ clear_has_hdf5_data_param();
+}
+const ::caffe::HDF5DataParameter& V1LayerParameter::hdf5_data_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.hdf5_data_param)
+ return hdf5_data_param_ != NULL ? *hdf5_data_param_
+ : *::caffe::HDF5DataParameter::internal_default_instance();
+}
+::caffe::HDF5DataParameter* V1LayerParameter::mutable_hdf5_data_param() {
+ set_has_hdf5_data_param();
+ if (hdf5_data_param_ == NULL) {
+ hdf5_data_param_ = new ::caffe::HDF5DataParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.hdf5_data_param)
+ return hdf5_data_param_;
+}
+::caffe::HDF5DataParameter* V1LayerParameter::release_hdf5_data_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.hdf5_data_param)
+ clear_has_hdf5_data_param();
+ ::caffe::HDF5DataParameter* temp = hdf5_data_param_;
+ hdf5_data_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_hdf5_data_param(::caffe::HDF5DataParameter* hdf5_data_param) {
+ delete hdf5_data_param_;
+ hdf5_data_param_ = hdf5_data_param;
+ if (hdf5_data_param) {
+ set_has_hdf5_data_param();
+ } else {
+ clear_has_hdf5_data_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.hdf5_data_param)
+}
+
+// optional .caffe.HDF5OutputParameter hdf5_output_param = 14;
+bool V1LayerParameter::has_hdf5_output_param() const {
+ return (_has_bits_[0] & 0x00800000u) != 0;
+}
+void V1LayerParameter::set_has_hdf5_output_param() {
+ _has_bits_[0] |= 0x00800000u;
+}
+void V1LayerParameter::clear_has_hdf5_output_param() {
+ _has_bits_[0] &= ~0x00800000u;
+}
+void V1LayerParameter::clear_hdf5_output_param() {
+ if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear();
+ clear_has_hdf5_output_param();
+}
+const ::caffe::HDF5OutputParameter& V1LayerParameter::hdf5_output_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.hdf5_output_param)
+ return hdf5_output_param_ != NULL ? *hdf5_output_param_
+ : *::caffe::HDF5OutputParameter::internal_default_instance();
+}
+::caffe::HDF5OutputParameter* V1LayerParameter::mutable_hdf5_output_param() {
+ set_has_hdf5_output_param();
+ if (hdf5_output_param_ == NULL) {
+ hdf5_output_param_ = new ::caffe::HDF5OutputParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.hdf5_output_param)
+ return hdf5_output_param_;
+}
+::caffe::HDF5OutputParameter* V1LayerParameter::release_hdf5_output_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.hdf5_output_param)
+ clear_has_hdf5_output_param();
+ ::caffe::HDF5OutputParameter* temp = hdf5_output_param_;
+ hdf5_output_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param) {
+ delete hdf5_output_param_;
+ hdf5_output_param_ = hdf5_output_param;
+ if (hdf5_output_param) {
+ set_has_hdf5_output_param();
+ } else {
+ clear_has_hdf5_output_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.hdf5_output_param)
+}
+
+// optional .caffe.HingeLossParameter hinge_loss_param = 29;
+bool V1LayerParameter::has_hinge_loss_param() const {
+ return (_has_bits_[0] & 0x01000000u) != 0;
+}
+void V1LayerParameter::set_has_hinge_loss_param() {
+ _has_bits_[0] |= 0x01000000u;
+}
+void V1LayerParameter::clear_has_hinge_loss_param() {
+ _has_bits_[0] &= ~0x01000000u;
+}
+void V1LayerParameter::clear_hinge_loss_param() {
+ if (hinge_loss_param_ != NULL) hinge_loss_param_->::caffe::HingeLossParameter::Clear();
+ clear_has_hinge_loss_param();
+}
+const ::caffe::HingeLossParameter& V1LayerParameter::hinge_loss_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.hinge_loss_param)
+ return hinge_loss_param_ != NULL ? *hinge_loss_param_
+ : *::caffe::HingeLossParameter::internal_default_instance();
+}
+::caffe::HingeLossParameter* V1LayerParameter::mutable_hinge_loss_param() {
+ set_has_hinge_loss_param();
+ if (hinge_loss_param_ == NULL) {
+ hinge_loss_param_ = new ::caffe::HingeLossParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.hinge_loss_param)
+ return hinge_loss_param_;
+}
+::caffe::HingeLossParameter* V1LayerParameter::release_hinge_loss_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.hinge_loss_param)
+ clear_has_hinge_loss_param();
+ ::caffe::HingeLossParameter* temp = hinge_loss_param_;
+ hinge_loss_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_hinge_loss_param(::caffe::HingeLossParameter* hinge_loss_param) {
+ delete hinge_loss_param_;
+ hinge_loss_param_ = hinge_loss_param;
+ if (hinge_loss_param) {
+ set_has_hinge_loss_param();
+ } else {
+ clear_has_hinge_loss_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.hinge_loss_param)
+}
+
+// optional .caffe.ImageDataParameter image_data_param = 15;
+bool V1LayerParameter::has_image_data_param() const {
+ return (_has_bits_[0] & 0x02000000u) != 0;
+}
+void V1LayerParameter::set_has_image_data_param() {
+ _has_bits_[0] |= 0x02000000u;
+}
+void V1LayerParameter::clear_has_image_data_param() {
+ _has_bits_[0] &= ~0x02000000u;
+}
+void V1LayerParameter::clear_image_data_param() {
+ if (image_data_param_ != NULL) image_data_param_->::caffe::ImageDataParameter::Clear();
+ clear_has_image_data_param();
+}
+const ::caffe::ImageDataParameter& V1LayerParameter::image_data_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.image_data_param)
+ return image_data_param_ != NULL ? *image_data_param_
+ : *::caffe::ImageDataParameter::internal_default_instance();
+}
+::caffe::ImageDataParameter* V1LayerParameter::mutable_image_data_param() {
+ set_has_image_data_param();
+ if (image_data_param_ == NULL) {
+ image_data_param_ = new ::caffe::ImageDataParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.image_data_param)
+ return image_data_param_;
+}
+::caffe::ImageDataParameter* V1LayerParameter::release_image_data_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.image_data_param)
+ clear_has_image_data_param();
+ ::caffe::ImageDataParameter* temp = image_data_param_;
+ image_data_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_image_data_param(::caffe::ImageDataParameter* image_data_param) {
+ delete image_data_param_;
+ image_data_param_ = image_data_param;
+ if (image_data_param) {
+ set_has_image_data_param();
+ } else {
+ clear_has_image_data_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.image_data_param)
+}
+
+// optional .caffe.InfogainLossParameter infogain_loss_param = 16;
+bool V1LayerParameter::has_infogain_loss_param() const {
+ return (_has_bits_[0] & 0x04000000u) != 0;
+}
+void V1LayerParameter::set_has_infogain_loss_param() {
+ _has_bits_[0] |= 0x04000000u;
+}
+void V1LayerParameter::clear_has_infogain_loss_param() {
+ _has_bits_[0] &= ~0x04000000u;
+}
+void V1LayerParameter::clear_infogain_loss_param() {
+ if (infogain_loss_param_ != NULL) infogain_loss_param_->::caffe::InfogainLossParameter::Clear();
+ clear_has_infogain_loss_param();
+}
+const ::caffe::InfogainLossParameter& V1LayerParameter::infogain_loss_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.infogain_loss_param)
+ return infogain_loss_param_ != NULL ? *infogain_loss_param_
+ : *::caffe::InfogainLossParameter::internal_default_instance();
+}
+::caffe::InfogainLossParameter* V1LayerParameter::mutable_infogain_loss_param() {
+ set_has_infogain_loss_param();
+ if (infogain_loss_param_ == NULL) {
+ infogain_loss_param_ = new ::caffe::InfogainLossParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.infogain_loss_param)
+ return infogain_loss_param_;
+}
+::caffe::InfogainLossParameter* V1LayerParameter::release_infogain_loss_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.infogain_loss_param)
+ clear_has_infogain_loss_param();
+ ::caffe::InfogainLossParameter* temp = infogain_loss_param_;
+ infogain_loss_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_infogain_loss_param(::caffe::InfogainLossParameter* infogain_loss_param) {
+ delete infogain_loss_param_;
+ infogain_loss_param_ = infogain_loss_param;
+ if (infogain_loss_param) {
+ set_has_infogain_loss_param();
+ } else {
+ clear_has_infogain_loss_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.infogain_loss_param)
+}
+
+// optional .caffe.InnerProductParameter inner_product_param = 17;
+bool V1LayerParameter::has_inner_product_param() const {
+ return (_has_bits_[0] & 0x08000000u) != 0;
+}
+void V1LayerParameter::set_has_inner_product_param() {
+ _has_bits_[0] |= 0x08000000u;
+}
+void V1LayerParameter::clear_has_inner_product_param() {
+ _has_bits_[0] &= ~0x08000000u;
+}
+void V1LayerParameter::clear_inner_product_param() {
+ if (inner_product_param_ != NULL) inner_product_param_->::caffe::InnerProductParameter::Clear();
+ clear_has_inner_product_param();
+}
+const ::caffe::InnerProductParameter& V1LayerParameter::inner_product_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.inner_product_param)
+ return inner_product_param_ != NULL ? *inner_product_param_
+ : *::caffe::InnerProductParameter::internal_default_instance();
+}
+::caffe::InnerProductParameter* V1LayerParameter::mutable_inner_product_param() {
+ set_has_inner_product_param();
+ if (inner_product_param_ == NULL) {
+ inner_product_param_ = new ::caffe::InnerProductParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.inner_product_param)
+ return inner_product_param_;
+}
+::caffe::InnerProductParameter* V1LayerParameter::release_inner_product_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.inner_product_param)
+ clear_has_inner_product_param();
+ ::caffe::InnerProductParameter* temp = inner_product_param_;
+ inner_product_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_inner_product_param(::caffe::InnerProductParameter* inner_product_param) {
+ delete inner_product_param_;
+ inner_product_param_ = inner_product_param;
+ if (inner_product_param) {
+ set_has_inner_product_param();
+ } else {
+ clear_has_inner_product_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.inner_product_param)
+}
+
+// optional .caffe.LRNParameter lrn_param = 18;
+bool V1LayerParameter::has_lrn_param() const {
+ return (_has_bits_[0] & 0x10000000u) != 0;
+}
+void V1LayerParameter::set_has_lrn_param() {
+ _has_bits_[0] |= 0x10000000u;
+}
+void V1LayerParameter::clear_has_lrn_param() {
+ _has_bits_[0] &= ~0x10000000u;
+}
+void V1LayerParameter::clear_lrn_param() {
+ if (lrn_param_ != NULL) lrn_param_->::caffe::LRNParameter::Clear();
+ clear_has_lrn_param();
+}
+const ::caffe::LRNParameter& V1LayerParameter::lrn_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.lrn_param)
+ return lrn_param_ != NULL ? *lrn_param_
+ : *::caffe::LRNParameter::internal_default_instance();
+}
+::caffe::LRNParameter* V1LayerParameter::mutable_lrn_param() {
+ set_has_lrn_param();
+ if (lrn_param_ == NULL) {
+ lrn_param_ = new ::caffe::LRNParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.lrn_param)
+ return lrn_param_;
+}
+::caffe::LRNParameter* V1LayerParameter::release_lrn_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.lrn_param)
+ clear_has_lrn_param();
+ ::caffe::LRNParameter* temp = lrn_param_;
+ lrn_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_lrn_param(::caffe::LRNParameter* lrn_param) {
+ delete lrn_param_;
+ lrn_param_ = lrn_param;
+ if (lrn_param) {
+ set_has_lrn_param();
+ } else {
+ clear_has_lrn_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.lrn_param)
+}
+
+// optional .caffe.MemoryDataParameter memory_data_param = 22;
+bool V1LayerParameter::has_memory_data_param() const {
+ return (_has_bits_[0] & 0x20000000u) != 0;
+}
+void V1LayerParameter::set_has_memory_data_param() {
+ _has_bits_[0] |= 0x20000000u;
+}
+void V1LayerParameter::clear_has_memory_data_param() {
+ _has_bits_[0] &= ~0x20000000u;
+}
+void V1LayerParameter::clear_memory_data_param() {
+ if (memory_data_param_ != NULL) memory_data_param_->::caffe::MemoryDataParameter::Clear();
+ clear_has_memory_data_param();
+}
+const ::caffe::MemoryDataParameter& V1LayerParameter::memory_data_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.memory_data_param)
+ return memory_data_param_ != NULL ? *memory_data_param_
+ : *::caffe::MemoryDataParameter::internal_default_instance();
+}
+::caffe::MemoryDataParameter* V1LayerParameter::mutable_memory_data_param() {
+ set_has_memory_data_param();
+ if (memory_data_param_ == NULL) {
+ memory_data_param_ = new ::caffe::MemoryDataParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.memory_data_param)
+ return memory_data_param_;
+}
+::caffe::MemoryDataParameter* V1LayerParameter::release_memory_data_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.memory_data_param)
+ clear_has_memory_data_param();
+ ::caffe::MemoryDataParameter* temp = memory_data_param_;
+ memory_data_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_memory_data_param(::caffe::MemoryDataParameter* memory_data_param) {
+ delete memory_data_param_;
+ memory_data_param_ = memory_data_param;
+ if (memory_data_param) {
+ set_has_memory_data_param();
+ } else {
+ clear_has_memory_data_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.memory_data_param)
+}
+
+// optional .caffe.MVNParameter mvn_param = 34;
+bool V1LayerParameter::has_mvn_param() const {
+ return (_has_bits_[0] & 0x40000000u) != 0;
+}
+void V1LayerParameter::set_has_mvn_param() {
+ _has_bits_[0] |= 0x40000000u;
+}
+void V1LayerParameter::clear_has_mvn_param() {
+ _has_bits_[0] &= ~0x40000000u;
+}
+void V1LayerParameter::clear_mvn_param() {
+ if (mvn_param_ != NULL) mvn_param_->::caffe::MVNParameter::Clear();
+ clear_has_mvn_param();
+}
+const ::caffe::MVNParameter& V1LayerParameter::mvn_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.mvn_param)
+ return mvn_param_ != NULL ? *mvn_param_
+ : *::caffe::MVNParameter::internal_default_instance();
+}
+::caffe::MVNParameter* V1LayerParameter::mutable_mvn_param() {
+ set_has_mvn_param();
+ if (mvn_param_ == NULL) {
+ mvn_param_ = new ::caffe::MVNParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.mvn_param)
+ return mvn_param_;
+}
+::caffe::MVNParameter* V1LayerParameter::release_mvn_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.mvn_param)
+ clear_has_mvn_param();
+ ::caffe::MVNParameter* temp = mvn_param_;
+ mvn_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_mvn_param(::caffe::MVNParameter* mvn_param) {
+ delete mvn_param_;
+ mvn_param_ = mvn_param;
+ if (mvn_param) {
+ set_has_mvn_param();
+ } else {
+ clear_has_mvn_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.mvn_param)
+}
+
+// optional .caffe.PoolingParameter pooling_param = 19;
+bool V1LayerParameter::has_pooling_param() const {
+ return (_has_bits_[0] & 0x80000000u) != 0;
+}
+void V1LayerParameter::set_has_pooling_param() {
+ _has_bits_[0] |= 0x80000000u;
+}
+void V1LayerParameter::clear_has_pooling_param() {
+ _has_bits_[0] &= ~0x80000000u;
+}
+void V1LayerParameter::clear_pooling_param() {
+ if (pooling_param_ != NULL) pooling_param_->::caffe::PoolingParameter::Clear();
+ clear_has_pooling_param();
+}
+const ::caffe::PoolingParameter& V1LayerParameter::pooling_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.pooling_param)
+ return pooling_param_ != NULL ? *pooling_param_
+ : *::caffe::PoolingParameter::internal_default_instance();
+}
+::caffe::PoolingParameter* V1LayerParameter::mutable_pooling_param() {
+ set_has_pooling_param();
+ if (pooling_param_ == NULL) {
+ pooling_param_ = new ::caffe::PoolingParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.pooling_param)
+ return pooling_param_;
+}
+::caffe::PoolingParameter* V1LayerParameter::release_pooling_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.pooling_param)
+ clear_has_pooling_param();
+ ::caffe::PoolingParameter* temp = pooling_param_;
+ pooling_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_pooling_param(::caffe::PoolingParameter* pooling_param) {
+ delete pooling_param_;
+ pooling_param_ = pooling_param;
+ if (pooling_param) {
+ set_has_pooling_param();
+ } else {
+ clear_has_pooling_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.pooling_param)
+}
+
+// optional .caffe.PowerParameter power_param = 21;
+bool V1LayerParameter::has_power_param() const {
+ return (_has_bits_[1] & 0x00000001u) != 0;
+}
+void V1LayerParameter::set_has_power_param() {
+ _has_bits_[1] |= 0x00000001u;
+}
+void V1LayerParameter::clear_has_power_param() {
+ _has_bits_[1] &= ~0x00000001u;
+}
+void V1LayerParameter::clear_power_param() {
+ if (power_param_ != NULL) power_param_->::caffe::PowerParameter::Clear();
+ clear_has_power_param();
+}
+const ::caffe::PowerParameter& V1LayerParameter::power_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.power_param)
+ return power_param_ != NULL ? *power_param_
+ : *::caffe::PowerParameter::internal_default_instance();
+}
+::caffe::PowerParameter* V1LayerParameter::mutable_power_param() {
+ set_has_power_param();
+ if (power_param_ == NULL) {
+ power_param_ = new ::caffe::PowerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.power_param)
+ return power_param_;
+}
+::caffe::PowerParameter* V1LayerParameter::release_power_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.power_param)
+ clear_has_power_param();
+ ::caffe::PowerParameter* temp = power_param_;
+ power_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_power_param(::caffe::PowerParameter* power_param) {
+ delete power_param_;
+ power_param_ = power_param;
+ if (power_param) {
+ set_has_power_param();
+ } else {
+ clear_has_power_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.power_param)
+}
+
+// optional .caffe.ReLUParameter relu_param = 30;
+bool V1LayerParameter::has_relu_param() const {
+ return (_has_bits_[1] & 0x00000002u) != 0;
+}
+void V1LayerParameter::set_has_relu_param() {
+ _has_bits_[1] |= 0x00000002u;
+}
+void V1LayerParameter::clear_has_relu_param() {
+ _has_bits_[1] &= ~0x00000002u;
+}
+void V1LayerParameter::clear_relu_param() {
+ if (relu_param_ != NULL) relu_param_->::caffe::ReLUParameter::Clear();
+ clear_has_relu_param();
+}
+const ::caffe::ReLUParameter& V1LayerParameter::relu_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.relu_param)
+ return relu_param_ != NULL ? *relu_param_
+ : *::caffe::ReLUParameter::internal_default_instance();
+}
+::caffe::ReLUParameter* V1LayerParameter::mutable_relu_param() {
+ set_has_relu_param();
+ if (relu_param_ == NULL) {
+ relu_param_ = new ::caffe::ReLUParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.relu_param)
+ return relu_param_;
+}
+::caffe::ReLUParameter* V1LayerParameter::release_relu_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.relu_param)
+ clear_has_relu_param();
+ ::caffe::ReLUParameter* temp = relu_param_;
+ relu_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_relu_param(::caffe::ReLUParameter* relu_param) {
+ delete relu_param_;
+ relu_param_ = relu_param;
+ if (relu_param) {
+ set_has_relu_param();
+ } else {
+ clear_has_relu_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.relu_param)
+}
+
+// optional .caffe.SigmoidParameter sigmoid_param = 38;
+bool V1LayerParameter::has_sigmoid_param() const {
+ return (_has_bits_[1] & 0x00000004u) != 0;
+}
+void V1LayerParameter::set_has_sigmoid_param() {
+ _has_bits_[1] |= 0x00000004u;
+}
+void V1LayerParameter::clear_has_sigmoid_param() {
+ _has_bits_[1] &= ~0x00000004u;
+}
+void V1LayerParameter::clear_sigmoid_param() {
+ if (sigmoid_param_ != NULL) sigmoid_param_->::caffe::SigmoidParameter::Clear();
+ clear_has_sigmoid_param();
+}
+const ::caffe::SigmoidParameter& V1LayerParameter::sigmoid_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.sigmoid_param)
+ return sigmoid_param_ != NULL ? *sigmoid_param_
+ : *::caffe::SigmoidParameter::internal_default_instance();
+}
+::caffe::SigmoidParameter* V1LayerParameter::mutable_sigmoid_param() {
+ set_has_sigmoid_param();
+ if (sigmoid_param_ == NULL) {
+ sigmoid_param_ = new ::caffe::SigmoidParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.sigmoid_param)
+ return sigmoid_param_;
+}
+::caffe::SigmoidParameter* V1LayerParameter::release_sigmoid_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.sigmoid_param)
+ clear_has_sigmoid_param();
+ ::caffe::SigmoidParameter* temp = sigmoid_param_;
+ sigmoid_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_sigmoid_param(::caffe::SigmoidParameter* sigmoid_param) {
+ delete sigmoid_param_;
+ sigmoid_param_ = sigmoid_param;
+ if (sigmoid_param) {
+ set_has_sigmoid_param();
+ } else {
+ clear_has_sigmoid_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.sigmoid_param)
+}
+
+// optional .caffe.SoftmaxParameter softmax_param = 39;
+bool V1LayerParameter::has_softmax_param() const {
+ return (_has_bits_[1] & 0x00000008u) != 0;
+}
+void V1LayerParameter::set_has_softmax_param() {
+ _has_bits_[1] |= 0x00000008u;
+}
+void V1LayerParameter::clear_has_softmax_param() {
+ _has_bits_[1] &= ~0x00000008u;
+}
+void V1LayerParameter::clear_softmax_param() {
+ if (softmax_param_ != NULL) softmax_param_->::caffe::SoftmaxParameter::Clear();
+ clear_has_softmax_param();
+}
+const ::caffe::SoftmaxParameter& V1LayerParameter::softmax_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.softmax_param)
+ return softmax_param_ != NULL ? *softmax_param_
+ : *::caffe::SoftmaxParameter::internal_default_instance();
+}
+::caffe::SoftmaxParameter* V1LayerParameter::mutable_softmax_param() {
+ set_has_softmax_param();
+ if (softmax_param_ == NULL) {
+ softmax_param_ = new ::caffe::SoftmaxParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.softmax_param)
+ return softmax_param_;
+}
+::caffe::SoftmaxParameter* V1LayerParameter::release_softmax_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.softmax_param)
+ clear_has_softmax_param();
+ ::caffe::SoftmaxParameter* temp = softmax_param_;
+ softmax_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_softmax_param(::caffe::SoftmaxParameter* softmax_param) {
+ delete softmax_param_;
+ softmax_param_ = softmax_param;
+ if (softmax_param) {
+ set_has_softmax_param();
+ } else {
+ clear_has_softmax_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.softmax_param)
+}
+
+// optional .caffe.SliceParameter slice_param = 31;
+bool V1LayerParameter::has_slice_param() const {
+ return (_has_bits_[1] & 0x00000010u) != 0;
+}
+void V1LayerParameter::set_has_slice_param() {
+ _has_bits_[1] |= 0x00000010u;
+}
+void V1LayerParameter::clear_has_slice_param() {
+ _has_bits_[1] &= ~0x00000010u;
+}
+void V1LayerParameter::clear_slice_param() {
+ if (slice_param_ != NULL) slice_param_->::caffe::SliceParameter::Clear();
+ clear_has_slice_param();
+}
+const ::caffe::SliceParameter& V1LayerParameter::slice_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.slice_param)
+ return slice_param_ != NULL ? *slice_param_
+ : *::caffe::SliceParameter::internal_default_instance();
+}
+::caffe::SliceParameter* V1LayerParameter::mutable_slice_param() {
+ set_has_slice_param();
+ if (slice_param_ == NULL) {
+ slice_param_ = new ::caffe::SliceParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.slice_param)
+ return slice_param_;
+}
+::caffe::SliceParameter* V1LayerParameter::release_slice_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.slice_param)
+ clear_has_slice_param();
+ ::caffe::SliceParameter* temp = slice_param_;
+ slice_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_slice_param(::caffe::SliceParameter* slice_param) {
+ delete slice_param_;
+ slice_param_ = slice_param;
+ if (slice_param) {
+ set_has_slice_param();
+ } else {
+ clear_has_slice_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.slice_param)
+}
+
+// optional .caffe.TanHParameter tanh_param = 37;
+bool V1LayerParameter::has_tanh_param() const {
+ return (_has_bits_[1] & 0x00000020u) != 0;
+}
+void V1LayerParameter::set_has_tanh_param() {
+ _has_bits_[1] |= 0x00000020u;
+}
+void V1LayerParameter::clear_has_tanh_param() {
+ _has_bits_[1] &= ~0x00000020u;
+}
+void V1LayerParameter::clear_tanh_param() {
+ if (tanh_param_ != NULL) tanh_param_->::caffe::TanHParameter::Clear();
+ clear_has_tanh_param();
+}
+const ::caffe::TanHParameter& V1LayerParameter::tanh_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.tanh_param)
+ return tanh_param_ != NULL ? *tanh_param_
+ : *::caffe::TanHParameter::internal_default_instance();
+}
+::caffe::TanHParameter* V1LayerParameter::mutable_tanh_param() {
+ set_has_tanh_param();
+ if (tanh_param_ == NULL) {
+ tanh_param_ = new ::caffe::TanHParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.tanh_param)
+ return tanh_param_;
+}
+::caffe::TanHParameter* V1LayerParameter::release_tanh_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.tanh_param)
+ clear_has_tanh_param();
+ ::caffe::TanHParameter* temp = tanh_param_;
+ tanh_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_tanh_param(::caffe::TanHParameter* tanh_param) {
+ delete tanh_param_;
+ tanh_param_ = tanh_param;
+ if (tanh_param) {
+ set_has_tanh_param();
+ } else {
+ clear_has_tanh_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.tanh_param)
+}
+
+// optional .caffe.ThresholdParameter threshold_param = 25;
+bool V1LayerParameter::has_threshold_param() const {
+ return (_has_bits_[1] & 0x00000040u) != 0;
+}
+void V1LayerParameter::set_has_threshold_param() {
+ _has_bits_[1] |= 0x00000040u;
+}
+void V1LayerParameter::clear_has_threshold_param() {
+ _has_bits_[1] &= ~0x00000040u;
+}
+void V1LayerParameter::clear_threshold_param() {
+ if (threshold_param_ != NULL) threshold_param_->::caffe::ThresholdParameter::Clear();
+ clear_has_threshold_param();
+}
+const ::caffe::ThresholdParameter& V1LayerParameter::threshold_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.threshold_param)
+ return threshold_param_ != NULL ? *threshold_param_
+ : *::caffe::ThresholdParameter::internal_default_instance();
+}
+::caffe::ThresholdParameter* V1LayerParameter::mutable_threshold_param() {
+ set_has_threshold_param();
+ if (threshold_param_ == NULL) {
+ threshold_param_ = new ::caffe::ThresholdParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.threshold_param)
+ return threshold_param_;
+}
+::caffe::ThresholdParameter* V1LayerParameter::release_threshold_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.threshold_param)
+ clear_has_threshold_param();
+ ::caffe::ThresholdParameter* temp = threshold_param_;
+ threshold_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_threshold_param(::caffe::ThresholdParameter* threshold_param) {
+ delete threshold_param_;
+ threshold_param_ = threshold_param;
+ if (threshold_param) {
+ set_has_threshold_param();
+ } else {
+ clear_has_threshold_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.threshold_param)
+}
+
+// optional .caffe.WindowDataParameter window_data_param = 20;
+bool V1LayerParameter::has_window_data_param() const {
+ return (_has_bits_[1] & 0x00000080u) != 0;
+}
+void V1LayerParameter::set_has_window_data_param() {
+ _has_bits_[1] |= 0x00000080u;
+}
+void V1LayerParameter::clear_has_window_data_param() {
+ _has_bits_[1] &= ~0x00000080u;
+}
+void V1LayerParameter::clear_window_data_param() {
+ if (window_data_param_ != NULL) window_data_param_->::caffe::WindowDataParameter::Clear();
+ clear_has_window_data_param();
+}
+const ::caffe::WindowDataParameter& V1LayerParameter::window_data_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.window_data_param)
+ return window_data_param_ != NULL ? *window_data_param_
+ : *::caffe::WindowDataParameter::internal_default_instance();
+}
+::caffe::WindowDataParameter* V1LayerParameter::mutable_window_data_param() {
+ set_has_window_data_param();
+ if (window_data_param_ == NULL) {
+ window_data_param_ = new ::caffe::WindowDataParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.window_data_param)
+ return window_data_param_;
+}
+::caffe::WindowDataParameter* V1LayerParameter::release_window_data_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.window_data_param)
+ clear_has_window_data_param();
+ ::caffe::WindowDataParameter* temp = window_data_param_;
+ window_data_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_window_data_param(::caffe::WindowDataParameter* window_data_param) {
+ delete window_data_param_;
+ window_data_param_ = window_data_param;
+ if (window_data_param) {
+ set_has_window_data_param();
+ } else {
+ clear_has_window_data_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.window_data_param)
+}
+
+// optional .caffe.TransformationParameter transform_param = 36;
+bool V1LayerParameter::has_transform_param() const {
+ return (_has_bits_[1] & 0x00000100u) != 0;
+}
+void V1LayerParameter::set_has_transform_param() {
+ _has_bits_[1] |= 0x00000100u;
+}
+void V1LayerParameter::clear_has_transform_param() {
+ _has_bits_[1] &= ~0x00000100u;
+}
+void V1LayerParameter::clear_transform_param() {
+ if (transform_param_ != NULL) transform_param_->::caffe::TransformationParameter::Clear();
+ clear_has_transform_param();
+}
+const ::caffe::TransformationParameter& V1LayerParameter::transform_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.transform_param)
+ return transform_param_ != NULL ? *transform_param_
+ : *::caffe::TransformationParameter::internal_default_instance();
+}
+::caffe::TransformationParameter* V1LayerParameter::mutable_transform_param() {
+ set_has_transform_param();
+ if (transform_param_ == NULL) {
+ transform_param_ = new ::caffe::TransformationParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.transform_param)
+ return transform_param_;
+}
+::caffe::TransformationParameter* V1LayerParameter::release_transform_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.transform_param)
+ clear_has_transform_param();
+ ::caffe::TransformationParameter* temp = transform_param_;
+ transform_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_transform_param(::caffe::TransformationParameter* transform_param) {
+ delete transform_param_;
+ transform_param_ = transform_param;
+ if (transform_param) {
+ set_has_transform_param();
+ } else {
+ clear_has_transform_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.transform_param)
+}
+
+// optional .caffe.LossParameter loss_param = 42;
+bool V1LayerParameter::has_loss_param() const {
+ return (_has_bits_[1] & 0x00000200u) != 0;
+}
+void V1LayerParameter::set_has_loss_param() {
+ _has_bits_[1] |= 0x00000200u;
+}
+void V1LayerParameter::clear_has_loss_param() {
+ _has_bits_[1] &= ~0x00000200u;
+}
+void V1LayerParameter::clear_loss_param() {
+ if (loss_param_ != NULL) loss_param_->::caffe::LossParameter::Clear();
+ clear_has_loss_param();
+}
+const ::caffe::LossParameter& V1LayerParameter::loss_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.loss_param)
+ return loss_param_ != NULL ? *loss_param_
+ : *::caffe::LossParameter::internal_default_instance();
+}
+::caffe::LossParameter* V1LayerParameter::mutable_loss_param() {
+ set_has_loss_param();
+ if (loss_param_ == NULL) {
+ loss_param_ = new ::caffe::LossParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.loss_param)
+ return loss_param_;
+}
+::caffe::LossParameter* V1LayerParameter::release_loss_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.loss_param)
+ clear_has_loss_param();
+ ::caffe::LossParameter* temp = loss_param_;
+ loss_param_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_loss_param(::caffe::LossParameter* loss_param) {
+ delete loss_param_;
+ loss_param_ = loss_param;
+ if (loss_param) {
+ set_has_loss_param();
+ } else {
+ clear_has_loss_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.loss_param)
+}
+
+// optional .caffe.V0LayerParameter layer = 1;
+bool V1LayerParameter::has_layer() const {
+ return (_has_bits_[1] & 0x00000400u) != 0;
+}
+void V1LayerParameter::set_has_layer() {
+ _has_bits_[1] |= 0x00000400u;
+}
+void V1LayerParameter::clear_has_layer() {
+ _has_bits_[1] &= ~0x00000400u;
+}
+void V1LayerParameter::clear_layer() {
+ if (layer_ != NULL) layer_->::caffe::V0LayerParameter::Clear();
+ clear_has_layer();
+}
+const ::caffe::V0LayerParameter& V1LayerParameter::layer() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.layer)
+ return layer_ != NULL ? *layer_
+ : *::caffe::V0LayerParameter::internal_default_instance();
+}
+::caffe::V0LayerParameter* V1LayerParameter::mutable_layer() {
+ set_has_layer();
+ if (layer_ == NULL) {
+ layer_ = new ::caffe::V0LayerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.layer)
+ return layer_;
+}
+::caffe::V0LayerParameter* V1LayerParameter::release_layer() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.layer)
+ clear_has_layer();
+ ::caffe::V0LayerParameter* temp = layer_;
+ layer_ = NULL;
+ return temp;
+}
+void V1LayerParameter::set_allocated_layer(::caffe::V0LayerParameter* layer) {
+ delete layer_;
+ layer_ = layer;
+ if (layer) {
+ set_has_layer();
+ } else {
+ clear_has_layer();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.layer)
+}
+
+inline const V1LayerParameter* V1LayerParameter::internal_default_instance() {
+ return &V1LayerParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+const ::google::protobuf::EnumDescriptor* V0LayerParameter_PoolMethod_descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return V0LayerParameter_PoolMethod_descriptor_;
+}
+bool V0LayerParameter_PoolMethod_IsValid(int value) {
+ switch (value) {
+ case 0:
+ case 1:
+ case 2:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const V0LayerParameter_PoolMethod V0LayerParameter::MAX;
+const V0LayerParameter_PoolMethod V0LayerParameter::AVE;
+const V0LayerParameter_PoolMethod V0LayerParameter::STOCHASTIC;
+const V0LayerParameter_PoolMethod V0LayerParameter::PoolMethod_MIN;
+const V0LayerParameter_PoolMethod V0LayerParameter::PoolMethod_MAX;
+const int V0LayerParameter::PoolMethod_ARRAYSIZE;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+::std::string* V0LayerParameter::_default_det_crop_mode_ = NULL;
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int V0LayerParameter::kNameFieldNumber;
+const int V0LayerParameter::kTypeFieldNumber;
+const int V0LayerParameter::kNumOutputFieldNumber;
+const int V0LayerParameter::kBiastermFieldNumber;
+const int V0LayerParameter::kWeightFillerFieldNumber;
+const int V0LayerParameter::kBiasFillerFieldNumber;
+const int V0LayerParameter::kPadFieldNumber;
+const int V0LayerParameter::kKernelsizeFieldNumber;
+const int V0LayerParameter::kGroupFieldNumber;
+const int V0LayerParameter::kStrideFieldNumber;
+const int V0LayerParameter::kPoolFieldNumber;
+const int V0LayerParameter::kDropoutRatioFieldNumber;
+const int V0LayerParameter::kLocalSizeFieldNumber;
+const int V0LayerParameter::kAlphaFieldNumber;
+const int V0LayerParameter::kBetaFieldNumber;
+const int V0LayerParameter::kKFieldNumber;
+const int V0LayerParameter::kSourceFieldNumber;
+const int V0LayerParameter::kScaleFieldNumber;
+const int V0LayerParameter::kMeanfileFieldNumber;
+const int V0LayerParameter::kBatchsizeFieldNumber;
+const int V0LayerParameter::kCropsizeFieldNumber;
+const int V0LayerParameter::kMirrorFieldNumber;
+const int V0LayerParameter::kBlobsFieldNumber;
+const int V0LayerParameter::kBlobsLrFieldNumber;
+const int V0LayerParameter::kWeightDecayFieldNumber;
+const int V0LayerParameter::kRandSkipFieldNumber;
+const int V0LayerParameter::kDetFgThresholdFieldNumber;
+const int V0LayerParameter::kDetBgThresholdFieldNumber;
+const int V0LayerParameter::kDetFgFractionFieldNumber;
+const int V0LayerParameter::kDetContextPadFieldNumber;
+const int V0LayerParameter::kDetCropModeFieldNumber;
+const int V0LayerParameter::kNewNumFieldNumber;
+const int V0LayerParameter::kNewChannelsFieldNumber;
+const int V0LayerParameter::kNewHeightFieldNumber;
+const int V0LayerParameter::kNewWidthFieldNumber;
+const int V0LayerParameter::kShuffleImagesFieldNumber;
+const int V0LayerParameter::kConcatDimFieldNumber;
+const int V0LayerParameter::kHdf5OutputParamFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+V0LayerParameter::V0LayerParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.V0LayerParameter)
+}
+
+void V0LayerParameter::InitAsDefaultInstance() {
+ weight_filler_ = const_cast< ::caffe::FillerParameter*>(
+ ::caffe::FillerParameter::internal_default_instance());
+ bias_filler_ = const_cast< ::caffe::FillerParameter*>(
+ ::caffe::FillerParameter::internal_default_instance());
+ hdf5_output_param_ = const_cast< ::caffe::HDF5OutputParameter*>(
+ ::caffe::HDF5OutputParameter::internal_default_instance());
+}
+
+V0LayerParameter::V0LayerParameter(const V0LayerParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.V0LayerParameter)
+}
+
+void V0LayerParameter::SharedCtor() {
+ name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ source_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ meanfile_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ det_crop_mode_.UnsafeSetDefault(_default_det_crop_mode_);
+ weight_filler_ = NULL;
+ bias_filler_ = NULL;
+ hdf5_output_param_ = NULL;
+ ::memset(&num_output_, 0, reinterpret_cast<char*>(&new_width_) -
+ reinterpret_cast<char*>(&num_output_) + sizeof(new_width_));
+ concat_dim_ = 1u;
+ biasterm_ = true;
+ group_ = 1u;
+ stride_ = 1u;
+ dropout_ratio_ = 0.5f;
+ local_size_ = 5u;
+ alpha_ = 1;
+ beta_ = 0.75f;
+ k_ = 1;
+ scale_ = 1;
+ det_fg_threshold_ = 0.5f;
+ det_bg_threshold_ = 0.5f;
+ det_fg_fraction_ = 0.25f;
+ _cached_size_ = 0;
+}
+
+V0LayerParameter::~V0LayerParameter() {
+ // @@protoc_insertion_point(destructor:caffe.V0LayerParameter)
+ SharedDtor();
+}
+
+void V0LayerParameter::SharedDtor() {
+ name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ type_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ source_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ meanfile_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ det_crop_mode_.DestroyNoArena(_default_det_crop_mode_);
+ if (this != &V0LayerParameter_default_instance_.get()) {
+ delete weight_filler_;
+ delete bias_filler_;
+ delete hdf5_output_param_;
+ }
+}
+
+void V0LayerParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* V0LayerParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return V0LayerParameter_descriptor_;
+}
+
+const V0LayerParameter& V0LayerParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<V0LayerParameter> V0LayerParameter_default_instance_;
+
+V0LayerParameter* V0LayerParameter::New(::google::protobuf::Arena* arena) const {
+ V0LayerParameter* n = new V0LayerParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void V0LayerParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.V0LayerParameter)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(V0LayerParameter, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<V0LayerParameter*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ if (_has_bits_[0 / 32] & 255u) {
+ ZR_(num_output_, kernelsize_);
+ if (has_name()) {
+ name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ if (has_type()) {
+ type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ biasterm_ = true;
+ if (has_weight_filler()) {
+ if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear();
+ }
+ if (has_bias_filler()) {
+ if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
+ }
+ }
+ if (_has_bits_[8 / 32] & 65280u) {
+ group_ = 1u;
+ stride_ = 1u;
+ pool_ = 0;
+ dropout_ratio_ = 0.5f;
+ local_size_ = 5u;
+ alpha_ = 1;
+ beta_ = 0.75f;
+ k_ = 1;
+ }
+ if (_has_bits_[16 / 32] & 4128768u) {
+ ZR_(batchsize_, cropsize_);
+ if (has_source()) {
+ source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ scale_ = 1;
+ if (has_meanfile()) {
+ meanfile_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ }
+ mirror_ = false;
+ }
+ if (_has_bits_[24 / 32] & 4261412864u) {
+ ZR_(det_context_pad_, new_num_);
+ rand_skip_ = 0u;
+ det_fg_threshold_ = 0.5f;
+ det_bg_threshold_ = 0.5f;
+ det_fg_fraction_ = 0.25f;
+ if (has_det_crop_mode()) {
+ det_crop_mode_.ClearToDefaultNoArena(_default_det_crop_mode_);
+ }
+ }
+ if (_has_bits_[32 / 32] & 63u) {
+ ZR_(new_channels_, new_width_);
+ shuffle_images_ = false;
+ concat_dim_ = 1u;
+ if (has_hdf5_output_param()) {
+ if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear();
+ }
+ }
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ blobs_.Clear();
+ blobs_lr_.Clear();
+ weight_decay_.Clear();
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool V0LayerParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.V0LayerParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional string name = 1;
+ case 1: {
+ if (tag == 10) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_name()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->name().data(), this->name().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.V0LayerParameter.name");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(18)) goto parse_type;
+ break;
+ }
+
+ // optional string type = 2;
+ case 2: {
+ if (tag == 18) {
+ parse_type:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_type()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->type().data(), this->type().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.V0LayerParameter.type");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(24)) goto parse_num_output;
+ break;
+ }
+
+ // optional uint32 num_output = 3;
+ case 3: {
+ if (tag == 24) {
+ parse_num_output:
+ set_has_num_output();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &num_output_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(32)) goto parse_biasterm;
+ break;
+ }
+
+ // optional bool biasterm = 4 [default = true];
+ case 4: {
+ if (tag == 32) {
+ parse_biasterm:
+ set_has_biasterm();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &biasterm_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(42)) goto parse_weight_filler;
+ break;
+ }
+
+ // optional .caffe.FillerParameter weight_filler = 5;
+ case 5: {
+ if (tag == 42) {
+ parse_weight_filler:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_weight_filler()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(50)) goto parse_bias_filler;
+ break;
+ }
+
+ // optional .caffe.FillerParameter bias_filler = 6;
+ case 6: {
+ if (tag == 50) {
+ parse_bias_filler:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_bias_filler()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(56)) goto parse_pad;
+ break;
+ }
+
+ // optional uint32 pad = 7 [default = 0];
+ case 7: {
+ if (tag == 56) {
+ parse_pad:
+ set_has_pad();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &pad_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(64)) goto parse_kernelsize;
+ break;
+ }
+
+ // optional uint32 kernelsize = 8;
+ case 8: {
+ if (tag == 64) {
+ parse_kernelsize:
+ set_has_kernelsize();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &kernelsize_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(72)) goto parse_group;
+ break;
+ }
+
+ // optional uint32 group = 9 [default = 1];
+ case 9: {
+ if (tag == 72) {
+ parse_group:
+ set_has_group();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &group_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(80)) goto parse_stride;
+ break;
+ }
+
+ // optional uint32 stride = 10 [default = 1];
+ case 10: {
+ if (tag == 80) {
+ parse_stride:
+ set_has_stride();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &stride_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(88)) goto parse_pool;
+ break;
+ }
+
+ // optional .caffe.V0LayerParameter.PoolMethod pool = 11 [default = MAX];
+ case 11: {
+ if (tag == 88) {
+ parse_pool:
+ int value;
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+ input, &value)));
+ if (::caffe::V0LayerParameter_PoolMethod_IsValid(value)) {
+ set_pool(static_cast< ::caffe::V0LayerParameter_PoolMethod >(value));
+ } else {
+ mutable_unknown_fields()->AddVarint(11, value);
+ }
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(101)) goto parse_dropout_ratio;
+ break;
+ }
+
+ // optional float dropout_ratio = 12 [default = 0.5];
+ case 12: {
+ if (tag == 101) {
+ parse_dropout_ratio:
+ set_has_dropout_ratio();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &dropout_ratio_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(104)) goto parse_local_size;
+ break;
+ }
+
+ // optional uint32 local_size = 13 [default = 5];
+ case 13: {
+ if (tag == 104) {
+ parse_local_size:
+ set_has_local_size();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &local_size_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(117)) goto parse_alpha;
+ break;
+ }
+
+ // optional float alpha = 14 [default = 1];
+ case 14: {
+ if (tag == 117) {
+ parse_alpha:
+ set_has_alpha();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &alpha_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(125)) goto parse_beta;
+ break;
+ }
+
+ // optional float beta = 15 [default = 0.75];
+ case 15: {
+ if (tag == 125) {
+ parse_beta:
+ set_has_beta();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &beta_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(130)) goto parse_source;
+ break;
+ }
+
+ // optional string source = 16;
+ case 16: {
+ if (tag == 130) {
+ parse_source:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_source()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->source().data(), this->source().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.V0LayerParameter.source");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(141)) goto parse_scale;
+ break;
+ }
+
+ // optional float scale = 17 [default = 1];
+ case 17: {
+ if (tag == 141) {
+ parse_scale:
+ set_has_scale();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &scale_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(146)) goto parse_meanfile;
+ break;
+ }
+
+ // optional string meanfile = 18;
+ case 18: {
+ if (tag == 146) {
+ parse_meanfile:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_meanfile()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->meanfile().data(), this->meanfile().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.V0LayerParameter.meanfile");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(152)) goto parse_batchsize;
+ break;
+ }
+
+ // optional uint32 batchsize = 19;
+ case 19: {
+ if (tag == 152) {
+ parse_batchsize:
+ set_has_batchsize();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &batchsize_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(160)) goto parse_cropsize;
+ break;
+ }
+
+ // optional uint32 cropsize = 20 [default = 0];
+ case 20: {
+ if (tag == 160) {
+ parse_cropsize:
+ set_has_cropsize();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &cropsize_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(168)) goto parse_mirror;
+ break;
+ }
+
+ // optional bool mirror = 21 [default = false];
+ case 21: {
+ if (tag == 168) {
+ parse_mirror:
+ set_has_mirror();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &mirror_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(181)) goto parse_k;
+ break;
+ }
+
+ // optional float k = 22 [default = 1];
+ case 22: {
+ if (tag == 181) {
+ parse_k:
+ set_has_k();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &k_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(402)) goto parse_blobs;
+ break;
+ }
+
+ // repeated .caffe.BlobProto blobs = 50;
+ case 50: {
+ if (tag == 402) {
+ parse_blobs:
+ DO_(input->IncrementRecursionDepth());
+ parse_loop_blobs:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(
+ input, add_blobs()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(402)) goto parse_loop_blobs;
+ input->UnsafeDecrementRecursionDepth();
+ if (input->ExpectTag(413)) goto parse_blobs_lr;
+ break;
+ }
+
+ // repeated float blobs_lr = 51;
+ case 51: {
+ if (tag == 413) {
+ parse_blobs_lr:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ 2, 413, input, this->mutable_blobs_lr())));
+ } else if (tag == 410) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, this->mutable_blobs_lr())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(413)) goto parse_blobs_lr;
+ if (input->ExpectTag(421)) goto parse_weight_decay;
+ break;
+ }
+
+ // repeated float weight_decay = 52;
+ case 52: {
+ if (tag == 421) {
+ parse_weight_decay:
+ DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ 2, 421, input, this->mutable_weight_decay())));
+ } else if (tag == 418) {
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, this->mutable_weight_decay())));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(421)) goto parse_weight_decay;
+ if (input->ExpectTag(424)) goto parse_rand_skip;
+ break;
+ }
+
+ // optional uint32 rand_skip = 53 [default = 0];
+ case 53: {
+ if (tag == 424) {
+ parse_rand_skip:
+ set_has_rand_skip();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &rand_skip_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(437)) goto parse_det_fg_threshold;
+ break;
+ }
+
+ // optional float det_fg_threshold = 54 [default = 0.5];
+ case 54: {
+ if (tag == 437) {
+ parse_det_fg_threshold:
+ set_has_det_fg_threshold();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &det_fg_threshold_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(445)) goto parse_det_bg_threshold;
+ break;
+ }
+
+ // optional float det_bg_threshold = 55 [default = 0.5];
+ case 55: {
+ if (tag == 445) {
+ parse_det_bg_threshold:
+ set_has_det_bg_threshold();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &det_bg_threshold_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(453)) goto parse_det_fg_fraction;
+ break;
+ }
+
+ // optional float det_fg_fraction = 56 [default = 0.25];
+ case 56: {
+ if (tag == 453) {
+ parse_det_fg_fraction:
+ set_has_det_fg_fraction();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &det_fg_fraction_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(464)) goto parse_det_context_pad;
+ break;
+ }
+
+ // optional uint32 det_context_pad = 58 [default = 0];
+ case 58: {
+ if (tag == 464) {
+ parse_det_context_pad:
+ set_has_det_context_pad();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &det_context_pad_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(474)) goto parse_det_crop_mode;
+ break;
+ }
+
+ // optional string det_crop_mode = 59 [default = "warp"];
+ case 59: {
+ if (tag == 474) {
+ parse_det_crop_mode:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_det_crop_mode()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->det_crop_mode().data(), this->det_crop_mode().length(),
+ ::google::protobuf::internal::WireFormat::PARSE,
+ "caffe.V0LayerParameter.det_crop_mode");
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(480)) goto parse_new_num;
+ break;
+ }
+
+ // optional int32 new_num = 60 [default = 0];
+ case 60: {
+ if (tag == 480) {
+ parse_new_num:
+ set_has_new_num();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &new_num_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(488)) goto parse_new_channels;
+ break;
+ }
+
+ // optional int32 new_channels = 61 [default = 0];
+ case 61: {
+ if (tag == 488) {
+ parse_new_channels:
+ set_has_new_channels();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &new_channels_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(496)) goto parse_new_height;
+ break;
+ }
+
+ // optional int32 new_height = 62 [default = 0];
+ case 62: {
+ if (tag == 496) {
+ parse_new_height:
+ set_has_new_height();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &new_height_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(504)) goto parse_new_width;
+ break;
+ }
+
+ // optional int32 new_width = 63 [default = 0];
+ case 63: {
+ if (tag == 504) {
+ parse_new_width:
+ set_has_new_width();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &new_width_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(512)) goto parse_shuffle_images;
+ break;
+ }
+
+ // optional bool shuffle_images = 64 [default = false];
+ case 64: {
+ if (tag == 512) {
+ parse_shuffle_images:
+ set_has_shuffle_images();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &shuffle_images_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(520)) goto parse_concat_dim;
+ break;
+ }
+
+ // optional uint32 concat_dim = 65 [default = 1];
+ case 65: {
+ if (tag == 520) {
+ parse_concat_dim:
+ set_has_concat_dim();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
+ input, &concat_dim_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(8010)) goto parse_hdf5_output_param;
+ break;
+ }
+
+ // optional .caffe.HDF5OutputParameter hdf5_output_param = 1001;
+ case 1001: {
+ if (tag == 8010) {
+ parse_hdf5_output_param:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_hdf5_output_param()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.V0LayerParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.V0LayerParameter)
+ return false;
+#undef DO_
+}
+
+void V0LayerParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.V0LayerParameter)
+ // optional string name = 1;
+ if (has_name()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->name().data(), this->name().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.V0LayerParameter.name");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 1, this->name(), output);
+ }
+
+ // optional string type = 2;
+ if (has_type()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->type().data(), this->type().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.V0LayerParameter.type");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 2, this->type(), output);
+ }
+
+ // optional uint32 num_output = 3;
+ if (has_num_output()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(3, this->num_output(), output);
+ }
+
+ // optional bool biasterm = 4 [default = true];
+ if (has_biasterm()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(4, this->biasterm(), output);
+ }
+
+ // optional .caffe.FillerParameter weight_filler = 5;
+ if (has_weight_filler()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 5, *this->weight_filler_, output);
+ }
+
+ // optional .caffe.FillerParameter bias_filler = 6;
+ if (has_bias_filler()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 6, *this->bias_filler_, output);
+ }
+
+ // optional uint32 pad = 7 [default = 0];
+ if (has_pad()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(7, this->pad(), output);
+ }
+
+ // optional uint32 kernelsize = 8;
+ if (has_kernelsize()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(8, this->kernelsize(), output);
+ }
+
+ // optional uint32 group = 9 [default = 1];
+ if (has_group()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(9, this->group(), output);
+ }
+
+ // optional uint32 stride = 10 [default = 1];
+ if (has_stride()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(10, this->stride(), output);
+ }
+
+ // optional .caffe.V0LayerParameter.PoolMethod pool = 11 [default = MAX];
+ if (has_pool()) {
+ ::google::protobuf::internal::WireFormatLite::WriteEnum(
+ 11, this->pool(), output);
+ }
+
+ // optional float dropout_ratio = 12 [default = 0.5];
+ if (has_dropout_ratio()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(12, this->dropout_ratio(), output);
+ }
+
+ // optional uint32 local_size = 13 [default = 5];
+ if (has_local_size()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(13, this->local_size(), output);
+ }
+
+ // optional float alpha = 14 [default = 1];
+ if (has_alpha()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(14, this->alpha(), output);
+ }
+
+ // optional float beta = 15 [default = 0.75];
+ if (has_beta()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(15, this->beta(), output);
+ }
+
+ // optional string source = 16;
+ if (has_source()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->source().data(), this->source().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.V0LayerParameter.source");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 16, this->source(), output);
+ }
+
+ // optional float scale = 17 [default = 1];
+ if (has_scale()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(17, this->scale(), output);
+ }
+
+ // optional string meanfile = 18;
+ if (has_meanfile()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->meanfile().data(), this->meanfile().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.V0LayerParameter.meanfile");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 18, this->meanfile(), output);
+ }
+
+ // optional uint32 batchsize = 19;
+ if (has_batchsize()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(19, this->batchsize(), output);
+ }
+
+ // optional uint32 cropsize = 20 [default = 0];
+ if (has_cropsize()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(20, this->cropsize(), output);
+ }
+
+ // optional bool mirror = 21 [default = false];
+ if (has_mirror()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(21, this->mirror(), output);
+ }
+
+ // optional float k = 22 [default = 1];
+ if (has_k()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(22, this->k(), output);
+ }
+
+ // repeated .caffe.BlobProto blobs = 50;
+ for (unsigned int i = 0, n = this->blobs_size(); i < n; i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 50, this->blobs(i), output);
+ }
+
+ // repeated float blobs_lr = 51;
+ for (int i = 0; i < this->blobs_lr_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(
+ 51, this->blobs_lr(i), output);
+ }
+
+ // repeated float weight_decay = 52;
+ for (int i = 0; i < this->weight_decay_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(
+ 52, this->weight_decay(i), output);
+ }
+
+ // optional uint32 rand_skip = 53 [default = 0];
+ if (has_rand_skip()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(53, this->rand_skip(), output);
+ }
+
+ // optional float det_fg_threshold = 54 [default = 0.5];
+ if (has_det_fg_threshold()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(54, this->det_fg_threshold(), output);
+ }
+
+ // optional float det_bg_threshold = 55 [default = 0.5];
+ if (has_det_bg_threshold()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(55, this->det_bg_threshold(), output);
+ }
+
+ // optional float det_fg_fraction = 56 [default = 0.25];
+ if (has_det_fg_fraction()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(56, this->det_fg_fraction(), output);
+ }
+
+ // optional uint32 det_context_pad = 58 [default = 0];
+ if (has_det_context_pad()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(58, this->det_context_pad(), output);
+ }
+
+ // optional string det_crop_mode = 59 [default = "warp"];
+ if (has_det_crop_mode()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->det_crop_mode().data(), this->det_crop_mode().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.V0LayerParameter.det_crop_mode");
+ ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+ 59, this->det_crop_mode(), output);
+ }
+
+ // optional int32 new_num = 60 [default = 0];
+ if (has_new_num()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(60, this->new_num(), output);
+ }
+
+ // optional int32 new_channels = 61 [default = 0];
+ if (has_new_channels()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(61, this->new_channels(), output);
+ }
+
+ // optional int32 new_height = 62 [default = 0];
+ if (has_new_height()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(62, this->new_height(), output);
+ }
+
+ // optional int32 new_width = 63 [default = 0];
+ if (has_new_width()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(63, this->new_width(), output);
+ }
+
+ // optional bool shuffle_images = 64 [default = false];
+ if (has_shuffle_images()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(64, this->shuffle_images(), output);
+ }
+
+ // optional uint32 concat_dim = 65 [default = 1];
+ if (has_concat_dim()) {
+ ::google::protobuf::internal::WireFormatLite::WriteUInt32(65, this->concat_dim(), output);
+ }
+
+ // optional .caffe.HDF5OutputParameter hdf5_output_param = 1001;
+ if (has_hdf5_output_param()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 1001, *this->hdf5_output_param_, output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.V0LayerParameter)
+}
+
+::google::protobuf::uint8* V0LayerParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.V0LayerParameter)
+ // optional string name = 1;
+ if (has_name()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->name().data(), this->name().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.V0LayerParameter.name");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 1, this->name(), target);
+ }
+
+ // optional string type = 2;
+ if (has_type()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->type().data(), this->type().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.V0LayerParameter.type");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 2, this->type(), target);
+ }
+
+ // optional uint32 num_output = 3;
+ if (has_num_output()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(3, this->num_output(), target);
+ }
+
+ // optional bool biasterm = 4 [default = true];
+ if (has_biasterm()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(4, this->biasterm(), target);
+ }
+
+ // optional .caffe.FillerParameter weight_filler = 5;
+ if (has_weight_filler()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 5, *this->weight_filler_, false, target);
+ }
+
+ // optional .caffe.FillerParameter bias_filler = 6;
+ if (has_bias_filler()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 6, *this->bias_filler_, false, target);
+ }
+
+ // optional uint32 pad = 7 [default = 0];
+ if (has_pad()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(7, this->pad(), target);
+ }
+
+ // optional uint32 kernelsize = 8;
+ if (has_kernelsize()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(8, this->kernelsize(), target);
+ }
+
+ // optional uint32 group = 9 [default = 1];
+ if (has_group()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(9, this->group(), target);
+ }
+
+ // optional uint32 stride = 10 [default = 1];
+ if (has_stride()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(10, this->stride(), target);
+ }
+
+ // optional .caffe.V0LayerParameter.PoolMethod pool = 11 [default = MAX];
+ if (has_pool()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+ 11, this->pool(), target);
+ }
+
+ // optional float dropout_ratio = 12 [default = 0.5];
+ if (has_dropout_ratio()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(12, this->dropout_ratio(), target);
+ }
+
+ // optional uint32 local_size = 13 [default = 5];
+ if (has_local_size()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(13, this->local_size(), target);
+ }
+
+ // optional float alpha = 14 [default = 1];
+ if (has_alpha()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(14, this->alpha(), target);
+ }
+
+ // optional float beta = 15 [default = 0.75];
+ if (has_beta()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(15, this->beta(), target);
+ }
+
+ // optional string source = 16;
+ if (has_source()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->source().data(), this->source().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.V0LayerParameter.source");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 16, this->source(), target);
+ }
+
+ // optional float scale = 17 [default = 1];
+ if (has_scale()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(17, this->scale(), target);
+ }
+
+ // optional string meanfile = 18;
+ if (has_meanfile()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->meanfile().data(), this->meanfile().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.V0LayerParameter.meanfile");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 18, this->meanfile(), target);
+ }
+
+ // optional uint32 batchsize = 19;
+ if (has_batchsize()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(19, this->batchsize(), target);
+ }
+
+ // optional uint32 cropsize = 20 [default = 0];
+ if (has_cropsize()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(20, this->cropsize(), target);
+ }
+
+ // optional bool mirror = 21 [default = false];
+ if (has_mirror()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(21, this->mirror(), target);
+ }
+
+ // optional float k = 22 [default = 1];
+ if (has_k()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(22, this->k(), target);
+ }
+
+ // repeated .caffe.BlobProto blobs = 50;
+ for (unsigned int i = 0, n = this->blobs_size(); i < n; i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 50, this->blobs(i), false, target);
+ }
+
+ // repeated float blobs_lr = 51;
+ for (int i = 0; i < this->blobs_lr_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteFloatToArray(51, this->blobs_lr(i), target);
+ }
+
+ // repeated float weight_decay = 52;
+ for (int i = 0; i < this->weight_decay_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteFloatToArray(52, this->weight_decay(i), target);
+ }
+
+ // optional uint32 rand_skip = 53 [default = 0];
+ if (has_rand_skip()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(53, this->rand_skip(), target);
+ }
+
+ // optional float det_fg_threshold = 54 [default = 0.5];
+ if (has_det_fg_threshold()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(54, this->det_fg_threshold(), target);
+ }
+
+ // optional float det_bg_threshold = 55 [default = 0.5];
+ if (has_det_bg_threshold()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(55, this->det_bg_threshold(), target);
+ }
+
+ // optional float det_fg_fraction = 56 [default = 0.25];
+ if (has_det_fg_fraction()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(56, this->det_fg_fraction(), target);
+ }
+
+ // optional uint32 det_context_pad = 58 [default = 0];
+ if (has_det_context_pad()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(58, this->det_context_pad(), target);
+ }
+
+ // optional string det_crop_mode = 59 [default = "warp"];
+ if (has_det_crop_mode()) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
+ this->det_crop_mode().data(), this->det_crop_mode().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE,
+ "caffe.V0LayerParameter.det_crop_mode");
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 59, this->det_crop_mode(), target);
+ }
+
+ // optional int32 new_num = 60 [default = 0];
+ if (has_new_num()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(60, this->new_num(), target);
+ }
+
+ // optional int32 new_channels = 61 [default = 0];
+ if (has_new_channels()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(61, this->new_channels(), target);
+ }
+
+ // optional int32 new_height = 62 [default = 0];
+ if (has_new_height()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(62, this->new_height(), target);
+ }
+
+ // optional int32 new_width = 63 [default = 0];
+ if (has_new_width()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(63, this->new_width(), target);
+ }
+
+ // optional bool shuffle_images = 64 [default = false];
+ if (has_shuffle_images()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(64, this->shuffle_images(), target);
+ }
+
+ // optional uint32 concat_dim = 65 [default = 1];
+ if (has_concat_dim()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(65, this->concat_dim(), target);
+ }
+
+ // optional .caffe.HDF5OutputParameter hdf5_output_param = 1001;
+ if (has_hdf5_output_param()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 1001, *this->hdf5_output_param_, false, target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.V0LayerParameter)
+ return target;
+}
+
+size_t V0LayerParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.V0LayerParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 255u) {
+ // optional string name = 1;
+ if (has_name()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->name());
+ }
+
+ // optional string type = 2;
+ if (has_type()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->type());
+ }
+
+ // optional uint32 num_output = 3;
+ if (has_num_output()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->num_output());
+ }
+
+ // optional bool biasterm = 4 [default = true];
+ if (has_biasterm()) {
+ total_size += 1 + 1;
+ }
+
+ // optional .caffe.FillerParameter weight_filler = 5;
+ if (has_weight_filler()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->weight_filler_);
+ }
+
+ // optional .caffe.FillerParameter bias_filler = 6;
+ if (has_bias_filler()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->bias_filler_);
+ }
+
+ // optional uint32 pad = 7 [default = 0];
+ if (has_pad()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->pad());
+ }
+
+ // optional uint32 kernelsize = 8;
+ if (has_kernelsize()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->kernelsize());
+ }
+
+ }
+ if (_has_bits_[8 / 32] & 65280u) {
+ // optional uint32 group = 9 [default = 1];
+ if (has_group()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->group());
+ }
+
+ // optional uint32 stride = 10 [default = 1];
+ if (has_stride()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->stride());
+ }
+
+ // optional .caffe.V0LayerParameter.PoolMethod pool = 11 [default = MAX];
+ if (has_pool()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::EnumSize(this->pool());
+ }
+
+ // optional float dropout_ratio = 12 [default = 0.5];
+ if (has_dropout_ratio()) {
+ total_size += 1 + 4;
+ }
+
+ // optional uint32 local_size = 13 [default = 5];
+ if (has_local_size()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->local_size());
+ }
+
+ // optional float alpha = 14 [default = 1];
+ if (has_alpha()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float beta = 15 [default = 0.75];
+ if (has_beta()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float k = 22 [default = 1];
+ if (has_k()) {
+ total_size += 2 + 4;
+ }
+
+ }
+ if (_has_bits_[16 / 32] & 4128768u) {
+ // optional string source = 16;
+ if (has_source()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->source());
+ }
+
+ // optional float scale = 17 [default = 1];
+ if (has_scale()) {
+ total_size += 2 + 4;
+ }
+
+ // optional string meanfile = 18;
+ if (has_meanfile()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->meanfile());
+ }
+
+ // optional uint32 batchsize = 19;
+ if (has_batchsize()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->batchsize());
+ }
+
+ // optional uint32 cropsize = 20 [default = 0];
+ if (has_cropsize()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->cropsize());
+ }
+
+ // optional bool mirror = 21 [default = false];
+ if (has_mirror()) {
+ total_size += 2 + 1;
+ }
+
+ }
+ if (_has_bits_[25 / 32] & 4261412864u) {
+ // optional uint32 rand_skip = 53 [default = 0];
+ if (has_rand_skip()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->rand_skip());
+ }
+
+ // optional float det_fg_threshold = 54 [default = 0.5];
+ if (has_det_fg_threshold()) {
+ total_size += 2 + 4;
+ }
+
+ // optional float det_bg_threshold = 55 [default = 0.5];
+ if (has_det_bg_threshold()) {
+ total_size += 2 + 4;
+ }
+
+ // optional float det_fg_fraction = 56 [default = 0.25];
+ if (has_det_fg_fraction()) {
+ total_size += 2 + 4;
+ }
+
+ // optional uint32 det_context_pad = 58 [default = 0];
+ if (has_det_context_pad()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->det_context_pad());
+ }
+
+ // optional string det_crop_mode = 59 [default = "warp"];
+ if (has_det_crop_mode()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->det_crop_mode());
+ }
+
+ // optional int32 new_num = 60 [default = 0];
+ if (has_new_num()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->new_num());
+ }
+
+ }
+ if (_has_bits_[32 / 32] & 63u) {
+ // optional int32 new_channels = 61 [default = 0];
+ if (has_new_channels()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->new_channels());
+ }
+
+ // optional int32 new_height = 62 [default = 0];
+ if (has_new_height()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->new_height());
+ }
+
+ // optional int32 new_width = 63 [default = 0];
+ if (has_new_width()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->new_width());
+ }
+
+ // optional bool shuffle_images = 64 [default = false];
+ if (has_shuffle_images()) {
+ total_size += 2 + 1;
+ }
+
+ // optional uint32 concat_dim = 65 [default = 1];
+ if (has_concat_dim()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::UInt32Size(
+ this->concat_dim());
+ }
+
+ // optional .caffe.HDF5OutputParameter hdf5_output_param = 1001;
+ if (has_hdf5_output_param()) {
+ total_size += 2 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->hdf5_output_param_);
+ }
+
+ }
+ // repeated .caffe.BlobProto blobs = 50;
+ {
+ unsigned int count = this->blobs_size();
+ total_size += 2UL * count;
+ for (unsigned int i = 0; i < count; i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->blobs(i));
+ }
+ }
+
+ // repeated float blobs_lr = 51;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->blobs_lr_size();
+ data_size = 4UL * count;
+ total_size += 2 *
+ ::google::protobuf::internal::FromIntSize(this->blobs_lr_size());
+ total_size += data_size;
+ }
+
+ // repeated float weight_decay = 52;
+ {
+ size_t data_size = 0;
+ unsigned int count = this->weight_decay_size();
+ data_size = 4UL * count;
+ total_size += 2 *
+ ::google::protobuf::internal::FromIntSize(this->weight_decay_size());
+ total_size += data_size;
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void V0LayerParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.V0LayerParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const V0LayerParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const V0LayerParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.V0LayerParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.V0LayerParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void V0LayerParameter::MergeFrom(const V0LayerParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.V0LayerParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void V0LayerParameter::UnsafeMergeFrom(const V0LayerParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ blobs_.MergeFrom(from.blobs_);
+ blobs_lr_.UnsafeMergeFrom(from.blobs_lr_);
+ weight_decay_.UnsafeMergeFrom(from.weight_decay_);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_name()) {
+ set_has_name();
+ name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);
+ }
+ if (from.has_type()) {
+ set_has_type();
+ type_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_);
+ }
+ if (from.has_num_output()) {
+ set_num_output(from.num_output());
+ }
+ if (from.has_biasterm()) {
+ set_biasterm(from.biasterm());
+ }
+ if (from.has_weight_filler()) {
+ mutable_weight_filler()->::caffe::FillerParameter::MergeFrom(from.weight_filler());
+ }
+ if (from.has_bias_filler()) {
+ mutable_bias_filler()->::caffe::FillerParameter::MergeFrom(from.bias_filler());
+ }
+ if (from.has_pad()) {
+ set_pad(from.pad());
+ }
+ if (from.has_kernelsize()) {
+ set_kernelsize(from.kernelsize());
+ }
+ }
+ if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) {
+ if (from.has_group()) {
+ set_group(from.group());
+ }
+ if (from.has_stride()) {
+ set_stride(from.stride());
+ }
+ if (from.has_pool()) {
+ set_pool(from.pool());
+ }
+ if (from.has_dropout_ratio()) {
+ set_dropout_ratio(from.dropout_ratio());
+ }
+ if (from.has_local_size()) {
+ set_local_size(from.local_size());
+ }
+ if (from.has_alpha()) {
+ set_alpha(from.alpha());
+ }
+ if (from.has_beta()) {
+ set_beta(from.beta());
+ }
+ if (from.has_k()) {
+ set_k(from.k());
+ }
+ }
+ if (from._has_bits_[16 / 32] & (0xffu << (16 % 32))) {
+ if (from.has_source()) {
+ set_has_source();
+ source_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_);
+ }
+ if (from.has_scale()) {
+ set_scale(from.scale());
+ }
+ if (from.has_meanfile()) {
+ set_has_meanfile();
+ meanfile_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.meanfile_);
+ }
+ if (from.has_batchsize()) {
+ set_batchsize(from.batchsize());
+ }
+ if (from.has_cropsize()) {
+ set_cropsize(from.cropsize());
+ }
+ if (from.has_mirror()) {
+ set_mirror(from.mirror());
+ }
+ }
+ if (from._has_bits_[25 / 32] & (0xffu << (25 % 32))) {
+ if (from.has_rand_skip()) {
+ set_rand_skip(from.rand_skip());
+ }
+ if (from.has_det_fg_threshold()) {
+ set_det_fg_threshold(from.det_fg_threshold());
+ }
+ if (from.has_det_bg_threshold()) {
+ set_det_bg_threshold(from.det_bg_threshold());
+ }
+ if (from.has_det_fg_fraction()) {
+ set_det_fg_fraction(from.det_fg_fraction());
+ }
+ if (from.has_det_context_pad()) {
+ set_det_context_pad(from.det_context_pad());
+ }
+ if (from.has_det_crop_mode()) {
+ set_has_det_crop_mode();
+ det_crop_mode_.AssignWithDefault(_default_det_crop_mode_, from.det_crop_mode_);
+ }
+ if (from.has_new_num()) {
+ set_new_num(from.new_num());
+ }
+ }
+ if (from._has_bits_[32 / 32] & (0xffu << (32 % 32))) {
+ if (from.has_new_channels()) {
+ set_new_channels(from.new_channels());
+ }
+ if (from.has_new_height()) {
+ set_new_height(from.new_height());
+ }
+ if (from.has_new_width()) {
+ set_new_width(from.new_width());
+ }
+ if (from.has_shuffle_images()) {
+ set_shuffle_images(from.shuffle_images());
+ }
+ if (from.has_concat_dim()) {
+ set_concat_dim(from.concat_dim());
+ }
+ if (from.has_hdf5_output_param()) {
+ mutable_hdf5_output_param()->::caffe::HDF5OutputParameter::MergeFrom(from.hdf5_output_param());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void V0LayerParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.V0LayerParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void V0LayerParameter::CopyFrom(const V0LayerParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.V0LayerParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool V0LayerParameter::IsInitialized() const {
+
+ return true;
+}
+
+void V0LayerParameter::Swap(V0LayerParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void V0LayerParameter::InternalSwap(V0LayerParameter* other) {
+ name_.Swap(&other->name_);
+ type_.Swap(&other->type_);
+ std::swap(num_output_, other->num_output_);
+ std::swap(biasterm_, other->biasterm_);
+ std::swap(weight_filler_, other->weight_filler_);
+ std::swap(bias_filler_, other->bias_filler_);
+ std::swap(pad_, other->pad_);
+ std::swap(kernelsize_, other->kernelsize_);
+ std::swap(group_, other->group_);
+ std::swap(stride_, other->stride_);
+ std::swap(pool_, other->pool_);
+ std::swap(dropout_ratio_, other->dropout_ratio_);
+ std::swap(local_size_, other->local_size_);
+ std::swap(alpha_, other->alpha_);
+ std::swap(beta_, other->beta_);
+ std::swap(k_, other->k_);
+ source_.Swap(&other->source_);
+ std::swap(scale_, other->scale_);
+ meanfile_.Swap(&other->meanfile_);
+ std::swap(batchsize_, other->batchsize_);
+ std::swap(cropsize_, other->cropsize_);
+ std::swap(mirror_, other->mirror_);
+ blobs_.UnsafeArenaSwap(&other->blobs_);
+ blobs_lr_.UnsafeArenaSwap(&other->blobs_lr_);
+ weight_decay_.UnsafeArenaSwap(&other->weight_decay_);
+ std::swap(rand_skip_, other->rand_skip_);
+ std::swap(det_fg_threshold_, other->det_fg_threshold_);
+ std::swap(det_bg_threshold_, other->det_bg_threshold_);
+ std::swap(det_fg_fraction_, other->det_fg_fraction_);
+ std::swap(det_context_pad_, other->det_context_pad_);
+ det_crop_mode_.Swap(&other->det_crop_mode_);
+ std::swap(new_num_, other->new_num_);
+ std::swap(new_channels_, other->new_channels_);
+ std::swap(new_height_, other->new_height_);
+ std::swap(new_width_, other->new_width_);
+ std::swap(shuffle_images_, other->shuffle_images_);
+ std::swap(concat_dim_, other->concat_dim_);
+ std::swap(hdf5_output_param_, other->hdf5_output_param_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ std::swap(_has_bits_[1], other->_has_bits_[1]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata V0LayerParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = V0LayerParameter_descriptor_;
+ metadata.reflection = V0LayerParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// V0LayerParameter
+
+// optional string name = 1;
+bool V0LayerParameter::has_name() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void V0LayerParameter::set_has_name() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void V0LayerParameter::clear_has_name() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void V0LayerParameter::clear_name() {
+ name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_name();
+}
+const ::std::string& V0LayerParameter::name() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.name)
+ return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void V0LayerParameter::set_name(const ::std::string& value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.name)
+}
+void V0LayerParameter::set_name(const char* value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.name)
+}
+void V0LayerParameter::set_name(const char* value, size_t size) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.name)
+}
+::std::string* V0LayerParameter::mutable_name() {
+ set_has_name();
+ // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.name)
+ return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* V0LayerParameter::release_name() {
+ // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.name)
+ clear_has_name();
+ return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void V0LayerParameter::set_allocated_name(::std::string* name) {
+ if (name != NULL) {
+ set_has_name();
+ } else {
+ clear_has_name();
+ }
+ name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
+ // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.name)
+}
+
+// optional string type = 2;
+bool V0LayerParameter::has_type() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void V0LayerParameter::set_has_type() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void V0LayerParameter::clear_has_type() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void V0LayerParameter::clear_type() {
+ type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_type();
+}
+const ::std::string& V0LayerParameter::type() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.type)
+ return type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void V0LayerParameter::set_type(const ::std::string& value) {
+ set_has_type();
+ type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.type)
+}
+void V0LayerParameter::set_type(const char* value) {
+ set_has_type();
+ type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.type)
+}
+void V0LayerParameter::set_type(const char* value, size_t size) {
+ set_has_type();
+ type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.type)
+}
+::std::string* V0LayerParameter::mutable_type() {
+ set_has_type();
+ // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.type)
+ return type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* V0LayerParameter::release_type() {
+ // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.type)
+ clear_has_type();
+ return type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void V0LayerParameter::set_allocated_type(::std::string* type) {
+ if (type != NULL) {
+ set_has_type();
+ } else {
+ clear_has_type();
+ }
+ type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type);
+ // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.type)
+}
+
+// optional uint32 num_output = 3;
+bool V0LayerParameter::has_num_output() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void V0LayerParameter::set_has_num_output() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void V0LayerParameter::clear_has_num_output() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void V0LayerParameter::clear_num_output() {
+ num_output_ = 0u;
+ clear_has_num_output();
+}
+::google::protobuf::uint32 V0LayerParameter::num_output() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.num_output)
+ return num_output_;
+}
+void V0LayerParameter::set_num_output(::google::protobuf::uint32 value) {
+ set_has_num_output();
+ num_output_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.num_output)
+}
+
+// optional bool biasterm = 4 [default = true];
+bool V0LayerParameter::has_biasterm() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+void V0LayerParameter::set_has_biasterm() {
+ _has_bits_[0] |= 0x00000008u;
+}
+void V0LayerParameter::clear_has_biasterm() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+void V0LayerParameter::clear_biasterm() {
+ biasterm_ = true;
+ clear_has_biasterm();
+}
+bool V0LayerParameter::biasterm() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.biasterm)
+ return biasterm_;
+}
+void V0LayerParameter::set_biasterm(bool value) {
+ set_has_biasterm();
+ biasterm_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.biasterm)
+}
+
+// optional .caffe.FillerParameter weight_filler = 5;
+bool V0LayerParameter::has_weight_filler() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+void V0LayerParameter::set_has_weight_filler() {
+ _has_bits_[0] |= 0x00000010u;
+}
+void V0LayerParameter::clear_has_weight_filler() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+void V0LayerParameter::clear_weight_filler() {
+ if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear();
+ clear_has_weight_filler();
+}
+const ::caffe::FillerParameter& V0LayerParameter::weight_filler() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.weight_filler)
+ return weight_filler_ != NULL ? *weight_filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+::caffe::FillerParameter* V0LayerParameter::mutable_weight_filler() {
+ set_has_weight_filler();
+ if (weight_filler_ == NULL) {
+ weight_filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.weight_filler)
+ return weight_filler_;
+}
+::caffe::FillerParameter* V0LayerParameter::release_weight_filler() {
+ // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.weight_filler)
+ clear_has_weight_filler();
+ ::caffe::FillerParameter* temp = weight_filler_;
+ weight_filler_ = NULL;
+ return temp;
+}
+void V0LayerParameter::set_allocated_weight_filler(::caffe::FillerParameter* weight_filler) {
+ delete weight_filler_;
+ weight_filler_ = weight_filler;
+ if (weight_filler) {
+ set_has_weight_filler();
+ } else {
+ clear_has_weight_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.weight_filler)
+}
+
+// optional .caffe.FillerParameter bias_filler = 6;
+bool V0LayerParameter::has_bias_filler() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+void V0LayerParameter::set_has_bias_filler() {
+ _has_bits_[0] |= 0x00000020u;
+}
+void V0LayerParameter::clear_has_bias_filler() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+void V0LayerParameter::clear_bias_filler() {
+ if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
+ clear_has_bias_filler();
+}
+const ::caffe::FillerParameter& V0LayerParameter::bias_filler() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.bias_filler)
+ return bias_filler_ != NULL ? *bias_filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+::caffe::FillerParameter* V0LayerParameter::mutable_bias_filler() {
+ set_has_bias_filler();
+ if (bias_filler_ == NULL) {
+ bias_filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.bias_filler)
+ return bias_filler_;
+}
+::caffe::FillerParameter* V0LayerParameter::release_bias_filler() {
+ // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.bias_filler)
+ clear_has_bias_filler();
+ ::caffe::FillerParameter* temp = bias_filler_;
+ bias_filler_ = NULL;
+ return temp;
+}
+void V0LayerParameter::set_allocated_bias_filler(::caffe::FillerParameter* bias_filler) {
+ delete bias_filler_;
+ bias_filler_ = bias_filler;
+ if (bias_filler) {
+ set_has_bias_filler();
+ } else {
+ clear_has_bias_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.bias_filler)
+}
+
+// optional uint32 pad = 7 [default = 0];
+bool V0LayerParameter::has_pad() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+void V0LayerParameter::set_has_pad() {
+ _has_bits_[0] |= 0x00000040u;
+}
+void V0LayerParameter::clear_has_pad() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+void V0LayerParameter::clear_pad() {
+ pad_ = 0u;
+ clear_has_pad();
+}
+::google::protobuf::uint32 V0LayerParameter::pad() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.pad)
+ return pad_;
+}
+void V0LayerParameter::set_pad(::google::protobuf::uint32 value) {
+ set_has_pad();
+ pad_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.pad)
+}
+
+// optional uint32 kernelsize = 8;
+bool V0LayerParameter::has_kernelsize() const {
+ return (_has_bits_[0] & 0x00000080u) != 0;
+}
+void V0LayerParameter::set_has_kernelsize() {
+ _has_bits_[0] |= 0x00000080u;
+}
+void V0LayerParameter::clear_has_kernelsize() {
+ _has_bits_[0] &= ~0x00000080u;
+}
+void V0LayerParameter::clear_kernelsize() {
+ kernelsize_ = 0u;
+ clear_has_kernelsize();
+}
+::google::protobuf::uint32 V0LayerParameter::kernelsize() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.kernelsize)
+ return kernelsize_;
+}
+void V0LayerParameter::set_kernelsize(::google::protobuf::uint32 value) {
+ set_has_kernelsize();
+ kernelsize_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.kernelsize)
+}
+
+// optional uint32 group = 9 [default = 1];
+bool V0LayerParameter::has_group() const {
+ return (_has_bits_[0] & 0x00000100u) != 0;
+}
+void V0LayerParameter::set_has_group() {
+ _has_bits_[0] |= 0x00000100u;
+}
+void V0LayerParameter::clear_has_group() {
+ _has_bits_[0] &= ~0x00000100u;
+}
+void V0LayerParameter::clear_group() {
+ group_ = 1u;
+ clear_has_group();
+}
+::google::protobuf::uint32 V0LayerParameter::group() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.group)
+ return group_;
+}
+void V0LayerParameter::set_group(::google::protobuf::uint32 value) {
+ set_has_group();
+ group_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.group)
+}
+
+// optional uint32 stride = 10 [default = 1];
+bool V0LayerParameter::has_stride() const {
+ return (_has_bits_[0] & 0x00000200u) != 0;
+}
+void V0LayerParameter::set_has_stride() {
+ _has_bits_[0] |= 0x00000200u;
+}
+void V0LayerParameter::clear_has_stride() {
+ _has_bits_[0] &= ~0x00000200u;
+}
+void V0LayerParameter::clear_stride() {
+ stride_ = 1u;
+ clear_has_stride();
+}
+::google::protobuf::uint32 V0LayerParameter::stride() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.stride)
+ return stride_;
+}
+void V0LayerParameter::set_stride(::google::protobuf::uint32 value) {
+ set_has_stride();
+ stride_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.stride)
+}
+
+// optional .caffe.V0LayerParameter.PoolMethod pool = 11 [default = MAX];
+bool V0LayerParameter::has_pool() const {
+ return (_has_bits_[0] & 0x00000400u) != 0;
+}
+void V0LayerParameter::set_has_pool() {
+ _has_bits_[0] |= 0x00000400u;
+}
+void V0LayerParameter::clear_has_pool() {
+ _has_bits_[0] &= ~0x00000400u;
+}
+void V0LayerParameter::clear_pool() {
+ pool_ = 0;
+ clear_has_pool();
+}
+::caffe::V0LayerParameter_PoolMethod V0LayerParameter::pool() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.pool)
+ return static_cast< ::caffe::V0LayerParameter_PoolMethod >(pool_);
+}
+void V0LayerParameter::set_pool(::caffe::V0LayerParameter_PoolMethod value) {
+ assert(::caffe::V0LayerParameter_PoolMethod_IsValid(value));
+ set_has_pool();
+ pool_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.pool)
+}
+
+// optional float dropout_ratio = 12 [default = 0.5];
+bool V0LayerParameter::has_dropout_ratio() const {
+ return (_has_bits_[0] & 0x00000800u) != 0;
+}
+void V0LayerParameter::set_has_dropout_ratio() {
+ _has_bits_[0] |= 0x00000800u;
+}
+void V0LayerParameter::clear_has_dropout_ratio() {
+ _has_bits_[0] &= ~0x00000800u;
+}
+void V0LayerParameter::clear_dropout_ratio() {
+ dropout_ratio_ = 0.5f;
+ clear_has_dropout_ratio();
+}
+float V0LayerParameter::dropout_ratio() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.dropout_ratio)
+ return dropout_ratio_;
+}
+void V0LayerParameter::set_dropout_ratio(float value) {
+ set_has_dropout_ratio();
+ dropout_ratio_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.dropout_ratio)
+}
+
+// optional uint32 local_size = 13 [default = 5];
+bool V0LayerParameter::has_local_size() const {
+ return (_has_bits_[0] & 0x00001000u) != 0;
+}
+void V0LayerParameter::set_has_local_size() {
+ _has_bits_[0] |= 0x00001000u;
+}
+void V0LayerParameter::clear_has_local_size() {
+ _has_bits_[0] &= ~0x00001000u;
+}
+void V0LayerParameter::clear_local_size() {
+ local_size_ = 5u;
+ clear_has_local_size();
+}
+::google::protobuf::uint32 V0LayerParameter::local_size() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.local_size)
+ return local_size_;
+}
+void V0LayerParameter::set_local_size(::google::protobuf::uint32 value) {
+ set_has_local_size();
+ local_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.local_size)
+}
+
+// optional float alpha = 14 [default = 1];
+bool V0LayerParameter::has_alpha() const {
+ return (_has_bits_[0] & 0x00002000u) != 0;
+}
+void V0LayerParameter::set_has_alpha() {
+ _has_bits_[0] |= 0x00002000u;
+}
+void V0LayerParameter::clear_has_alpha() {
+ _has_bits_[0] &= ~0x00002000u;
+}
+void V0LayerParameter::clear_alpha() {
+ alpha_ = 1;
+ clear_has_alpha();
+}
+float V0LayerParameter::alpha() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.alpha)
+ return alpha_;
+}
+void V0LayerParameter::set_alpha(float value) {
+ set_has_alpha();
+ alpha_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.alpha)
+}
+
+// optional float beta = 15 [default = 0.75];
+bool V0LayerParameter::has_beta() const {
+ return (_has_bits_[0] & 0x00004000u) != 0;
+}
+void V0LayerParameter::set_has_beta() {
+ _has_bits_[0] |= 0x00004000u;
+}
+void V0LayerParameter::clear_has_beta() {
+ _has_bits_[0] &= ~0x00004000u;
+}
+void V0LayerParameter::clear_beta() {
+ beta_ = 0.75f;
+ clear_has_beta();
+}
+float V0LayerParameter::beta() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.beta)
+ return beta_;
+}
+void V0LayerParameter::set_beta(float value) {
+ set_has_beta();
+ beta_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.beta)
+}
+
+// optional float k = 22 [default = 1];
+bool V0LayerParameter::has_k() const {
+ return (_has_bits_[0] & 0x00008000u) != 0;
+}
+void V0LayerParameter::set_has_k() {
+ _has_bits_[0] |= 0x00008000u;
+}
+void V0LayerParameter::clear_has_k() {
+ _has_bits_[0] &= ~0x00008000u;
+}
+void V0LayerParameter::clear_k() {
+ k_ = 1;
+ clear_has_k();
+}
+float V0LayerParameter::k() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.k)
+ return k_;
+}
+void V0LayerParameter::set_k(float value) {
+ set_has_k();
+ k_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.k)
+}
+
+// optional string source = 16;
+bool V0LayerParameter::has_source() const {
+ return (_has_bits_[0] & 0x00010000u) != 0;
+}
+void V0LayerParameter::set_has_source() {
+ _has_bits_[0] |= 0x00010000u;
+}
+void V0LayerParameter::clear_has_source() {
+ _has_bits_[0] &= ~0x00010000u;
+}
+void V0LayerParameter::clear_source() {
+ source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_source();
+}
+const ::std::string& V0LayerParameter::source() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.source)
+ return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void V0LayerParameter::set_source(const ::std::string& value) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.source)
+}
+void V0LayerParameter::set_source(const char* value) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.source)
+}
+void V0LayerParameter::set_source(const char* value, size_t size) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.source)
+}
+::std::string* V0LayerParameter::mutable_source() {
+ set_has_source();
+ // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.source)
+ return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* V0LayerParameter::release_source() {
+ // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.source)
+ clear_has_source();
+ return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void V0LayerParameter::set_allocated_source(::std::string* source) {
+ if (source != NULL) {
+ set_has_source();
+ } else {
+ clear_has_source();
+ }
+ source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source);
+ // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.source)
+}
+
+// optional float scale = 17 [default = 1];
+bool V0LayerParameter::has_scale() const {
+ return (_has_bits_[0] & 0x00020000u) != 0;
+}
+void V0LayerParameter::set_has_scale() {
+ _has_bits_[0] |= 0x00020000u;
+}
+void V0LayerParameter::clear_has_scale() {
+ _has_bits_[0] &= ~0x00020000u;
+}
+void V0LayerParameter::clear_scale() {
+ scale_ = 1;
+ clear_has_scale();
+}
+float V0LayerParameter::scale() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.scale)
+ return scale_;
+}
+void V0LayerParameter::set_scale(float value) {
+ set_has_scale();
+ scale_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.scale)
+}
+
+// optional string meanfile = 18;
+bool V0LayerParameter::has_meanfile() const {
+ return (_has_bits_[0] & 0x00040000u) != 0;
+}
+void V0LayerParameter::set_has_meanfile() {
+ _has_bits_[0] |= 0x00040000u;
+}
+void V0LayerParameter::clear_has_meanfile() {
+ _has_bits_[0] &= ~0x00040000u;
+}
+void V0LayerParameter::clear_meanfile() {
+ meanfile_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_meanfile();
+}
+const ::std::string& V0LayerParameter::meanfile() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.meanfile)
+ return meanfile_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void V0LayerParameter::set_meanfile(const ::std::string& value) {
+ set_has_meanfile();
+ meanfile_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.meanfile)
+}
+void V0LayerParameter::set_meanfile(const char* value) {
+ set_has_meanfile();
+ meanfile_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.meanfile)
+}
+void V0LayerParameter::set_meanfile(const char* value, size_t size) {
+ set_has_meanfile();
+ meanfile_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.meanfile)
+}
+::std::string* V0LayerParameter::mutable_meanfile() {
+ set_has_meanfile();
+ // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.meanfile)
+ return meanfile_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+::std::string* V0LayerParameter::release_meanfile() {
+ // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.meanfile)
+ clear_has_meanfile();
+ return meanfile_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+void V0LayerParameter::set_allocated_meanfile(::std::string* meanfile) {
+ if (meanfile != NULL) {
+ set_has_meanfile();
+ } else {
+ clear_has_meanfile();
+ }
+ meanfile_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), meanfile);
+ // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.meanfile)
+}
+
+// optional uint32 batchsize = 19;
+bool V0LayerParameter::has_batchsize() const {
+ return (_has_bits_[0] & 0x00080000u) != 0;
+}
+void V0LayerParameter::set_has_batchsize() {
+ _has_bits_[0] |= 0x00080000u;
+}
+void V0LayerParameter::clear_has_batchsize() {
+ _has_bits_[0] &= ~0x00080000u;
+}
+void V0LayerParameter::clear_batchsize() {
+ batchsize_ = 0u;
+ clear_has_batchsize();
+}
+::google::protobuf::uint32 V0LayerParameter::batchsize() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.batchsize)
+ return batchsize_;
+}
+void V0LayerParameter::set_batchsize(::google::protobuf::uint32 value) {
+ set_has_batchsize();
+ batchsize_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.batchsize)
+}
+
+// optional uint32 cropsize = 20 [default = 0];
+bool V0LayerParameter::has_cropsize() const {
+ return (_has_bits_[0] & 0x00100000u) != 0;
+}
+void V0LayerParameter::set_has_cropsize() {
+ _has_bits_[0] |= 0x00100000u;
+}
+void V0LayerParameter::clear_has_cropsize() {
+ _has_bits_[0] &= ~0x00100000u;
+}
+void V0LayerParameter::clear_cropsize() {
+ cropsize_ = 0u;
+ clear_has_cropsize();
+}
+::google::protobuf::uint32 V0LayerParameter::cropsize() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.cropsize)
+ return cropsize_;
+}
+void V0LayerParameter::set_cropsize(::google::protobuf::uint32 value) {
+ set_has_cropsize();
+ cropsize_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.cropsize)
+}
+
+// optional bool mirror = 21 [default = false];
+bool V0LayerParameter::has_mirror() const {
+ return (_has_bits_[0] & 0x00200000u) != 0;
+}
+void V0LayerParameter::set_has_mirror() {
+ _has_bits_[0] |= 0x00200000u;
+}
+void V0LayerParameter::clear_has_mirror() {
+ _has_bits_[0] &= ~0x00200000u;
+}
+void V0LayerParameter::clear_mirror() {
+ mirror_ = false;
+ clear_has_mirror();
+}
+bool V0LayerParameter::mirror() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.mirror)
+ return mirror_;
+}
+void V0LayerParameter::set_mirror(bool value) {
+ set_has_mirror();
+ mirror_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.mirror)
+}
+
+// repeated .caffe.BlobProto blobs = 50;
+int V0LayerParameter::blobs_size() const {
+ return blobs_.size();
+}
+void V0LayerParameter::clear_blobs() {
+ blobs_.Clear();
+}
+const ::caffe::BlobProto& V0LayerParameter::blobs(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.blobs)
+ return blobs_.Get(index);
+}
+::caffe::BlobProto* V0LayerParameter::mutable_blobs(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.blobs)
+ return blobs_.Mutable(index);
+}
+::caffe::BlobProto* V0LayerParameter::add_blobs() {
+ // @@protoc_insertion_point(field_add:caffe.V0LayerParameter.blobs)
+ return blobs_.Add();
+}
+::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
+V0LayerParameter::mutable_blobs() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V0LayerParameter.blobs)
+ return &blobs_;
+}
+const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
+V0LayerParameter::blobs() const {
+ // @@protoc_insertion_point(field_list:caffe.V0LayerParameter.blobs)
+ return blobs_;
+}
+
+// repeated float blobs_lr = 51;
+int V0LayerParameter::blobs_lr_size() const {
+ return blobs_lr_.size();
+}
+void V0LayerParameter::clear_blobs_lr() {
+ blobs_lr_.Clear();
+}
+float V0LayerParameter::blobs_lr(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.blobs_lr)
+ return blobs_lr_.Get(index);
+}
+void V0LayerParameter::set_blobs_lr(int index, float value) {
+ blobs_lr_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.blobs_lr)
+}
+void V0LayerParameter::add_blobs_lr(float value) {
+ blobs_lr_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.V0LayerParameter.blobs_lr)
+}
+const ::google::protobuf::RepeatedField< float >&
+V0LayerParameter::blobs_lr() const {
+ // @@protoc_insertion_point(field_list:caffe.V0LayerParameter.blobs_lr)
+ return blobs_lr_;
+}
+::google::protobuf::RepeatedField< float >*
+V0LayerParameter::mutable_blobs_lr() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V0LayerParameter.blobs_lr)
+ return &blobs_lr_;
+}
+
+// repeated float weight_decay = 52;
+int V0LayerParameter::weight_decay_size() const {
+ return weight_decay_.size();
+}
+void V0LayerParameter::clear_weight_decay() {
+ weight_decay_.Clear();
+}
+float V0LayerParameter::weight_decay(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.weight_decay)
+ return weight_decay_.Get(index);
+}
+void V0LayerParameter::set_weight_decay(int index, float value) {
+ weight_decay_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.weight_decay)
+}
+void V0LayerParameter::add_weight_decay(float value) {
+ weight_decay_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.V0LayerParameter.weight_decay)
+}
+const ::google::protobuf::RepeatedField< float >&
+V0LayerParameter::weight_decay() const {
+ // @@protoc_insertion_point(field_list:caffe.V0LayerParameter.weight_decay)
+ return weight_decay_;
+}
+::google::protobuf::RepeatedField< float >*
+V0LayerParameter::mutable_weight_decay() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V0LayerParameter.weight_decay)
+ return &weight_decay_;
+}
+
+// optional uint32 rand_skip = 53 [default = 0];
+bool V0LayerParameter::has_rand_skip() const {
+ return (_has_bits_[0] & 0x02000000u) != 0;
+}
+void V0LayerParameter::set_has_rand_skip() {
+ _has_bits_[0] |= 0x02000000u;
+}
+void V0LayerParameter::clear_has_rand_skip() {
+ _has_bits_[0] &= ~0x02000000u;
+}
+void V0LayerParameter::clear_rand_skip() {
+ rand_skip_ = 0u;
+ clear_has_rand_skip();
+}
+::google::protobuf::uint32 V0LayerParameter::rand_skip() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.rand_skip)
+ return rand_skip_;
+}
+void V0LayerParameter::set_rand_skip(::google::protobuf::uint32 value) {
+ set_has_rand_skip();
+ rand_skip_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.rand_skip)
+}
+
+// optional float det_fg_threshold = 54 [default = 0.5];
+bool V0LayerParameter::has_det_fg_threshold() const {
+ return (_has_bits_[0] & 0x04000000u) != 0;
+}
+void V0LayerParameter::set_has_det_fg_threshold() {
+ _has_bits_[0] |= 0x04000000u;
+}
+void V0LayerParameter::clear_has_det_fg_threshold() {
+ _has_bits_[0] &= ~0x04000000u;
+}
+void V0LayerParameter::clear_det_fg_threshold() {
+ det_fg_threshold_ = 0.5f;
+ clear_has_det_fg_threshold();
+}
+float V0LayerParameter::det_fg_threshold() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_fg_threshold)
+ return det_fg_threshold_;
+}
+void V0LayerParameter::set_det_fg_threshold(float value) {
+ set_has_det_fg_threshold();
+ det_fg_threshold_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_fg_threshold)
+}
+
+// optional float det_bg_threshold = 55 [default = 0.5];
+bool V0LayerParameter::has_det_bg_threshold() const {
+ return (_has_bits_[0] & 0x08000000u) != 0;
+}
+void V0LayerParameter::set_has_det_bg_threshold() {
+ _has_bits_[0] |= 0x08000000u;
+}
+void V0LayerParameter::clear_has_det_bg_threshold() {
+ _has_bits_[0] &= ~0x08000000u;
+}
+void V0LayerParameter::clear_det_bg_threshold() {
+ det_bg_threshold_ = 0.5f;
+ clear_has_det_bg_threshold();
+}
+float V0LayerParameter::det_bg_threshold() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_bg_threshold)
+ return det_bg_threshold_;
+}
+void V0LayerParameter::set_det_bg_threshold(float value) {
+ set_has_det_bg_threshold();
+ det_bg_threshold_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_bg_threshold)
+}
+
+// optional float det_fg_fraction = 56 [default = 0.25];
+bool V0LayerParameter::has_det_fg_fraction() const {
+ return (_has_bits_[0] & 0x10000000u) != 0;
+}
+void V0LayerParameter::set_has_det_fg_fraction() {
+ _has_bits_[0] |= 0x10000000u;
+}
+void V0LayerParameter::clear_has_det_fg_fraction() {
+ _has_bits_[0] &= ~0x10000000u;
+}
+void V0LayerParameter::clear_det_fg_fraction() {
+ det_fg_fraction_ = 0.25f;
+ clear_has_det_fg_fraction();
+}
+float V0LayerParameter::det_fg_fraction() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_fg_fraction)
+ return det_fg_fraction_;
+}
+void V0LayerParameter::set_det_fg_fraction(float value) {
+ set_has_det_fg_fraction();
+ det_fg_fraction_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_fg_fraction)
+}
+
+// optional uint32 det_context_pad = 58 [default = 0];
+bool V0LayerParameter::has_det_context_pad() const {
+ return (_has_bits_[0] & 0x20000000u) != 0;
+}
+void V0LayerParameter::set_has_det_context_pad() {
+ _has_bits_[0] |= 0x20000000u;
+}
+void V0LayerParameter::clear_has_det_context_pad() {
+ _has_bits_[0] &= ~0x20000000u;
+}
+void V0LayerParameter::clear_det_context_pad() {
+ det_context_pad_ = 0u;
+ clear_has_det_context_pad();
+}
+::google::protobuf::uint32 V0LayerParameter::det_context_pad() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_context_pad)
+ return det_context_pad_;
+}
+void V0LayerParameter::set_det_context_pad(::google::protobuf::uint32 value) {
+ set_has_det_context_pad();
+ det_context_pad_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_context_pad)
+}
+
+// optional string det_crop_mode = 59 [default = "warp"];
+bool V0LayerParameter::has_det_crop_mode() const {
+ return (_has_bits_[0] & 0x40000000u) != 0;
+}
+void V0LayerParameter::set_has_det_crop_mode() {
+ _has_bits_[0] |= 0x40000000u;
+}
+void V0LayerParameter::clear_has_det_crop_mode() {
+ _has_bits_[0] &= ~0x40000000u;
+}
+void V0LayerParameter::clear_det_crop_mode() {
+ det_crop_mode_.ClearToDefaultNoArena(_default_det_crop_mode_);
+ clear_has_det_crop_mode();
+}
+const ::std::string& V0LayerParameter::det_crop_mode() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_crop_mode)
+ return det_crop_mode_.GetNoArena(_default_det_crop_mode_);
+}
+void V0LayerParameter::set_det_crop_mode(const ::std::string& value) {
+ set_has_det_crop_mode();
+ det_crop_mode_.SetNoArena(_default_det_crop_mode_, value);
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_crop_mode)
+}
+void V0LayerParameter::set_det_crop_mode(const char* value) {
+ set_has_det_crop_mode();
+ det_crop_mode_.SetNoArena(_default_det_crop_mode_, ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.det_crop_mode)
+}
+void V0LayerParameter::set_det_crop_mode(const char* value, size_t size) {
+ set_has_det_crop_mode();
+ det_crop_mode_.SetNoArena(_default_det_crop_mode_,
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.det_crop_mode)
+}
+::std::string* V0LayerParameter::mutable_det_crop_mode() {
+ set_has_det_crop_mode();
+ // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.det_crop_mode)
+ return det_crop_mode_.MutableNoArena(_default_det_crop_mode_);
+}
+::std::string* V0LayerParameter::release_det_crop_mode() {
+ // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.det_crop_mode)
+ clear_has_det_crop_mode();
+ return det_crop_mode_.ReleaseNoArena(_default_det_crop_mode_);
+}
+void V0LayerParameter::set_allocated_det_crop_mode(::std::string* det_crop_mode) {
+ if (det_crop_mode != NULL) {
+ set_has_det_crop_mode();
+ } else {
+ clear_has_det_crop_mode();
+ }
+ det_crop_mode_.SetAllocatedNoArena(_default_det_crop_mode_, det_crop_mode);
+ // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.det_crop_mode)
+}
+
+// optional int32 new_num = 60 [default = 0];
+bool V0LayerParameter::has_new_num() const {
+ return (_has_bits_[0] & 0x80000000u) != 0;
+}
+void V0LayerParameter::set_has_new_num() {
+ _has_bits_[0] |= 0x80000000u;
+}
+void V0LayerParameter::clear_has_new_num() {
+ _has_bits_[0] &= ~0x80000000u;
+}
+void V0LayerParameter::clear_new_num() {
+ new_num_ = 0;
+ clear_has_new_num();
+}
+::google::protobuf::int32 V0LayerParameter::new_num() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.new_num)
+ return new_num_;
+}
+void V0LayerParameter::set_new_num(::google::protobuf::int32 value) {
+ set_has_new_num();
+ new_num_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.new_num)
+}
+
+// optional int32 new_channels = 61 [default = 0];
+bool V0LayerParameter::has_new_channels() const {
+ return (_has_bits_[1] & 0x00000001u) != 0;
+}
+void V0LayerParameter::set_has_new_channels() {
+ _has_bits_[1] |= 0x00000001u;
+}
+void V0LayerParameter::clear_has_new_channels() {
+ _has_bits_[1] &= ~0x00000001u;
+}
+void V0LayerParameter::clear_new_channels() {
+ new_channels_ = 0;
+ clear_has_new_channels();
+}
+::google::protobuf::int32 V0LayerParameter::new_channels() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.new_channels)
+ return new_channels_;
+}
+void V0LayerParameter::set_new_channels(::google::protobuf::int32 value) {
+ set_has_new_channels();
+ new_channels_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.new_channels)
+}
+
+// optional int32 new_height = 62 [default = 0];
+bool V0LayerParameter::has_new_height() const {
+ return (_has_bits_[1] & 0x00000002u) != 0;
+}
+void V0LayerParameter::set_has_new_height() {
+ _has_bits_[1] |= 0x00000002u;
+}
+void V0LayerParameter::clear_has_new_height() {
+ _has_bits_[1] &= ~0x00000002u;
+}
+void V0LayerParameter::clear_new_height() {
+ new_height_ = 0;
+ clear_has_new_height();
+}
+::google::protobuf::int32 V0LayerParameter::new_height() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.new_height)
+ return new_height_;
+}
+void V0LayerParameter::set_new_height(::google::protobuf::int32 value) {
+ set_has_new_height();
+ new_height_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.new_height)
+}
+
+// optional int32 new_width = 63 [default = 0];
+bool V0LayerParameter::has_new_width() const {
+ return (_has_bits_[1] & 0x00000004u) != 0;
+}
+void V0LayerParameter::set_has_new_width() {
+ _has_bits_[1] |= 0x00000004u;
+}
+void V0LayerParameter::clear_has_new_width() {
+ _has_bits_[1] &= ~0x00000004u;
+}
+void V0LayerParameter::clear_new_width() {
+ new_width_ = 0;
+ clear_has_new_width();
+}
+::google::protobuf::int32 V0LayerParameter::new_width() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.new_width)
+ return new_width_;
+}
+void V0LayerParameter::set_new_width(::google::protobuf::int32 value) {
+ set_has_new_width();
+ new_width_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.new_width)
+}
+
+// optional bool shuffle_images = 64 [default = false];
+bool V0LayerParameter::has_shuffle_images() const {
+ return (_has_bits_[1] & 0x00000008u) != 0;
+}
+void V0LayerParameter::set_has_shuffle_images() {
+ _has_bits_[1] |= 0x00000008u;
+}
+void V0LayerParameter::clear_has_shuffle_images() {
+ _has_bits_[1] &= ~0x00000008u;
+}
+void V0LayerParameter::clear_shuffle_images() {
+ shuffle_images_ = false;
+ clear_has_shuffle_images();
+}
+bool V0LayerParameter::shuffle_images() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.shuffle_images)
+ return shuffle_images_;
+}
+void V0LayerParameter::set_shuffle_images(bool value) {
+ set_has_shuffle_images();
+ shuffle_images_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.shuffle_images)
+}
+
+// optional uint32 concat_dim = 65 [default = 1];
+bool V0LayerParameter::has_concat_dim() const {
+ return (_has_bits_[1] & 0x00000010u) != 0;
+}
+void V0LayerParameter::set_has_concat_dim() {
+ _has_bits_[1] |= 0x00000010u;
+}
+void V0LayerParameter::clear_has_concat_dim() {
+ _has_bits_[1] &= ~0x00000010u;
+}
+void V0LayerParameter::clear_concat_dim() {
+ concat_dim_ = 1u;
+ clear_has_concat_dim();
+}
+::google::protobuf::uint32 V0LayerParameter::concat_dim() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.concat_dim)
+ return concat_dim_;
+}
+void V0LayerParameter::set_concat_dim(::google::protobuf::uint32 value) {
+ set_has_concat_dim();
+ concat_dim_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.concat_dim)
+}
+
+// optional .caffe.HDF5OutputParameter hdf5_output_param = 1001;
+bool V0LayerParameter::has_hdf5_output_param() const {
+ return (_has_bits_[1] & 0x00000020u) != 0;
+}
+void V0LayerParameter::set_has_hdf5_output_param() {
+ _has_bits_[1] |= 0x00000020u;
+}
+void V0LayerParameter::clear_has_hdf5_output_param() {
+ _has_bits_[1] &= ~0x00000020u;
+}
+void V0LayerParameter::clear_hdf5_output_param() {
+ if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear();
+ clear_has_hdf5_output_param();
+}
+const ::caffe::HDF5OutputParameter& V0LayerParameter::hdf5_output_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.hdf5_output_param)
+ return hdf5_output_param_ != NULL ? *hdf5_output_param_
+ : *::caffe::HDF5OutputParameter::internal_default_instance();
+}
+::caffe::HDF5OutputParameter* V0LayerParameter::mutable_hdf5_output_param() {
+ set_has_hdf5_output_param();
+ if (hdf5_output_param_ == NULL) {
+ hdf5_output_param_ = new ::caffe::HDF5OutputParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.hdf5_output_param)
+ return hdf5_output_param_;
+}
+::caffe::HDF5OutputParameter* V0LayerParameter::release_hdf5_output_param() {
+ // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.hdf5_output_param)
+ clear_has_hdf5_output_param();
+ ::caffe::HDF5OutputParameter* temp = hdf5_output_param_;
+ hdf5_output_param_ = NULL;
+ return temp;
+}
+void V0LayerParameter::set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param) {
+ delete hdf5_output_param_;
+ hdf5_output_param_ = hdf5_output_param;
+ if (hdf5_output_param) {
+ set_has_hdf5_output_param();
+ } else {
+ clear_has_hdf5_output_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.hdf5_output_param)
+}
+
+inline const V0LayerParameter* V0LayerParameter::internal_default_instance() {
+ return &V0LayerParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int PReLUParameter::kFillerFieldNumber;
+const int PReLUParameter::kChannelSharedFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+PReLUParameter::PReLUParameter()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.PReLUParameter)
+}
+
+void PReLUParameter::InitAsDefaultInstance() {
+ filler_ = const_cast< ::caffe::FillerParameter*>(
+ ::caffe::FillerParameter::internal_default_instance());
+}
+
+PReLUParameter::PReLUParameter(const PReLUParameter& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.PReLUParameter)
+}
+
+void PReLUParameter::SharedCtor() {
+ _cached_size_ = 0;
+ filler_ = NULL;
+ channel_shared_ = false;
+}
+
+PReLUParameter::~PReLUParameter() {
+ // @@protoc_insertion_point(destructor:caffe.PReLUParameter)
+ SharedDtor();
+}
+
+void PReLUParameter::SharedDtor() {
+ if (this != &PReLUParameter_default_instance_.get()) {
+ delete filler_;
+ }
+}
+
+void PReLUParameter::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* PReLUParameter::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return PReLUParameter_descriptor_;
+}
+
+const PReLUParameter& PReLUParameter::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<PReLUParameter> PReLUParameter_default_instance_;
+
+PReLUParameter* PReLUParameter::New(::google::protobuf::Arena* arena) const {
+ PReLUParameter* n = new PReLUParameter;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void PReLUParameter::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.PReLUParameter)
+ if (_has_bits_[0 / 32] & 3u) {
+ if (has_filler()) {
+ if (filler_ != NULL) filler_->::caffe::FillerParameter::Clear();
+ }
+ channel_shared_ = false;
+ }
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool PReLUParameter::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.PReLUParameter)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional .caffe.FillerParameter filler = 1;
+ case 1: {
+ if (tag == 10) {
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, mutable_filler()));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(16)) goto parse_channel_shared;
+ break;
+ }
+
+ // optional bool channel_shared = 2 [default = false];
+ case 2: {
+ if (tag == 16) {
+ parse_channel_shared:
+ set_has_channel_shared();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &channel_shared_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.PReLUParameter)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.PReLUParameter)
+ return false;
+#undef DO_
+}
+
+void PReLUParameter::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.PReLUParameter)
+ // optional .caffe.FillerParameter filler = 1;
+ if (has_filler()) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+ 1, *this->filler_, output);
+ }
+
+ // optional bool channel_shared = 2 [default = false];
+ if (has_channel_shared()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->channel_shared(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.PReLUParameter)
+}
+
+::google::protobuf::uint8* PReLUParameter::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.PReLUParameter)
+ // optional .caffe.FillerParameter filler = 1;
+ if (has_filler()) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ InternalWriteMessageNoVirtualToArray(
+ 1, *this->filler_, false, target);
+ }
+
+ // optional bool channel_shared = 2 [default = false];
+ if (has_channel_shared()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->channel_shared(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.PReLUParameter)
+ return target;
+}
+
+size_t PReLUParameter::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.PReLUParameter)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 3u) {
+ // optional .caffe.FillerParameter filler = 1;
+ if (has_filler()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ *this->filler_);
+ }
+
+ // optional bool channel_shared = 2 [default = false];
+ if (has_channel_shared()) {
+ total_size += 1 + 1;
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void PReLUParameter::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.PReLUParameter)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const PReLUParameter* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const PReLUParameter>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.PReLUParameter)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.PReLUParameter)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void PReLUParameter::MergeFrom(const PReLUParameter& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.PReLUParameter)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void PReLUParameter::UnsafeMergeFrom(const PReLUParameter& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_filler()) {
+ mutable_filler()->::caffe::FillerParameter::MergeFrom(from.filler());
+ }
+ if (from.has_channel_shared()) {
+ set_channel_shared(from.channel_shared());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void PReLUParameter::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.PReLUParameter)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void PReLUParameter::CopyFrom(const PReLUParameter& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.PReLUParameter)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool PReLUParameter::IsInitialized() const {
+
+ return true;
+}
+
+void PReLUParameter::Swap(PReLUParameter* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void PReLUParameter::InternalSwap(PReLUParameter* other) {
+ std::swap(filler_, other->filler_);
+ std::swap(channel_shared_, other->channel_shared_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata PReLUParameter::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = PReLUParameter_descriptor_;
+ metadata.reflection = PReLUParameter_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// PReLUParameter
+
+// optional .caffe.FillerParameter filler = 1;
+bool PReLUParameter::has_filler() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void PReLUParameter::set_has_filler() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void PReLUParameter::clear_has_filler() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void PReLUParameter::clear_filler() {
+ if (filler_ != NULL) filler_->::caffe::FillerParameter::Clear();
+ clear_has_filler();
+}
+const ::caffe::FillerParameter& PReLUParameter::filler() const {
+ // @@protoc_insertion_point(field_get:caffe.PReLUParameter.filler)
+ return filler_ != NULL ? *filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+::caffe::FillerParameter* PReLUParameter::mutable_filler() {
+ set_has_filler();
+ if (filler_ == NULL) {
+ filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.PReLUParameter.filler)
+ return filler_;
+}
+::caffe::FillerParameter* PReLUParameter::release_filler() {
+ // @@protoc_insertion_point(field_release:caffe.PReLUParameter.filler)
+ clear_has_filler();
+ ::caffe::FillerParameter* temp = filler_;
+ filler_ = NULL;
+ return temp;
+}
+void PReLUParameter::set_allocated_filler(::caffe::FillerParameter* filler) {
+ delete filler_;
+ filler_ = filler;
+ if (filler) {
+ set_has_filler();
+ } else {
+ clear_has_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.PReLUParameter.filler)
+}
+
+// optional bool channel_shared = 2 [default = false];
+bool PReLUParameter::has_channel_shared() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void PReLUParameter::set_has_channel_shared() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void PReLUParameter::clear_has_channel_shared() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void PReLUParameter::clear_channel_shared() {
+ channel_shared_ = false;
+ clear_has_channel_shared();
+}
+bool PReLUParameter::channel_shared() const {
+ // @@protoc_insertion_point(field_get:caffe.PReLUParameter.channel_shared)
+ return channel_shared_;
+}
+void PReLUParameter::set_channel_shared(bool value) {
+ set_has_channel_shared();
+ channel_shared_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PReLUParameter.channel_shared)
+}
+
+inline const PReLUParameter* PReLUParameter::internal_default_instance() {
+ return &PReLUParameter_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// ===================================================================
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int NormalizedBBox::kXminFieldNumber;
+const int NormalizedBBox::kYminFieldNumber;
+const int NormalizedBBox::kXmaxFieldNumber;
+const int NormalizedBBox::kYmaxFieldNumber;
+const int NormalizedBBox::kLabelFieldNumber;
+const int NormalizedBBox::kDifficultFieldNumber;
+const int NormalizedBBox::kScoreFieldNumber;
+const int NormalizedBBox::kSizeFieldNumber;
+#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+NormalizedBBox::NormalizedBBox()
+ : ::google::protobuf::Message(), _internal_metadata_(NULL) {
+ if (this != internal_default_instance()) protobuf_InitDefaults_caffe_2eproto();
+ SharedCtor();
+ // @@protoc_insertion_point(constructor:caffe.NormalizedBBox)
+}
+
+void NormalizedBBox::InitAsDefaultInstance() {
+}
+
+NormalizedBBox::NormalizedBBox(const NormalizedBBox& from)
+ : ::google::protobuf::Message(),
+ _internal_metadata_(NULL) {
+ SharedCtor();
+ UnsafeMergeFrom(from);
+ // @@protoc_insertion_point(copy_constructor:caffe.NormalizedBBox)
+}
+
+void NormalizedBBox::SharedCtor() {
+ _cached_size_ = 0;
+ ::memset(&xmin_, 0, reinterpret_cast<char*>(&size_) -
+ reinterpret_cast<char*>(&xmin_) + sizeof(size_));
+}
+
+NormalizedBBox::~NormalizedBBox() {
+ // @@protoc_insertion_point(destructor:caffe.NormalizedBBox)
+ SharedDtor();
+}
+
+void NormalizedBBox::SharedDtor() {
+}
+
+void NormalizedBBox::SetCachedSize(int size) const {
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+}
+const ::google::protobuf::Descriptor* NormalizedBBox::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return NormalizedBBox_descriptor_;
+}
+
+const NormalizedBBox& NormalizedBBox::default_instance() {
+ protobuf_InitDefaults_caffe_2eproto();
+ return *internal_default_instance();
+}
+
+::google::protobuf::internal::ExplicitlyConstructed<NormalizedBBox> NormalizedBBox_default_instance_;
+
+NormalizedBBox* NormalizedBBox::New(::google::protobuf::Arena* arena) const {
+ NormalizedBBox* n = new NormalizedBBox;
+ if (arena != NULL) {
+ arena->Own(n);
+ }
+ return n;
+}
+
+void NormalizedBBox::Clear() {
+// @@protoc_insertion_point(message_clear_start:caffe.NormalizedBBox)
+#if defined(__clang__)
+#define ZR_HELPER_(f) \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
+ __builtin_offsetof(NormalizedBBox, f) \
+ _Pragma("clang diagnostic pop")
+#else
+#define ZR_HELPER_(f) reinterpret_cast<char*>(\
+ &reinterpret_cast<NormalizedBBox*>(16)->f)
+#endif
+
+#define ZR_(first, last) do {\
+ ::memset(&(first), 0,\
+ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
+} while (0)
+
+ ZR_(xmin_, size_);
+
+#undef ZR_HELPER_
+#undef ZR_
+
+ _has_bits_.Clear();
+ if (_internal_metadata_.have_unknown_fields()) {
+ mutable_unknown_fields()->Clear();
+ }
+}
+
+bool NormalizedBBox::MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
+ ::google::protobuf::uint32 tag;
+ // @@protoc_insertion_point(parse_start:caffe.NormalizedBBox)
+ for (;;) {
+ ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);
+ tag = p.first;
+ if (!p.second) goto handle_unusual;
+ switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+ // optional float xmin = 1;
+ case 1: {
+ if (tag == 13) {
+ set_has_xmin();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &xmin_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(21)) goto parse_ymin;
+ break;
+ }
+
+ // optional float ymin = 2;
+ case 2: {
+ if (tag == 21) {
+ parse_ymin:
+ set_has_ymin();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &ymin_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(29)) goto parse_xmax;
+ break;
+ }
+
+ // optional float xmax = 3;
+ case 3: {
+ if (tag == 29) {
+ parse_xmax:
+ set_has_xmax();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &xmax_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(37)) goto parse_ymax;
+ break;
+ }
+
+ // optional float ymax = 4;
+ case 4: {
+ if (tag == 37) {
+ parse_ymax:
+ set_has_ymax();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &ymax_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(40)) goto parse_label;
+ break;
+ }
+
+ // optional int32 label = 5;
+ case 5: {
+ if (tag == 40) {
+ parse_label:
+ set_has_label();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+ input, &label_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(48)) goto parse_difficult;
+ break;
+ }
+
+ // optional bool difficult = 6;
+ case 6: {
+ if (tag == 48) {
+ parse_difficult:
+ set_has_difficult();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
+ input, &difficult_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(61)) goto parse_score;
+ break;
+ }
+
+ // optional float score = 7;
+ case 7: {
+ if (tag == 61) {
+ parse_score:
+ set_has_score();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &score_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectTag(69)) goto parse_size;
+ break;
+ }
+
+ // optional float size = 8;
+ case 8: {
+ if (tag == 69) {
+ parse_size:
+ set_has_size();
+ DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+ float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(
+ input, &size_)));
+ } else {
+ goto handle_unusual;
+ }
+ if (input->ExpectAtEnd()) goto success;
+ break;
+ }
+
+ default: {
+ handle_unusual:
+ if (tag == 0 ||
+ ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
+ goto success;
+ }
+ DO_(::google::protobuf::internal::WireFormat::SkipField(
+ input, tag, mutable_unknown_fields()));
+ break;
+ }
+ }
+ }
+success:
+ // @@protoc_insertion_point(parse_success:caffe.NormalizedBBox)
+ return true;
+failure:
+ // @@protoc_insertion_point(parse_failure:caffe.NormalizedBBox)
+ return false;
+#undef DO_
+}
+
+void NormalizedBBox::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ // @@protoc_insertion_point(serialize_start:caffe.NormalizedBBox)
+ // optional float xmin = 1;
+ if (has_xmin()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->xmin(), output);
+ }
+
+ // optional float ymin = 2;
+ if (has_ymin()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(2, this->ymin(), output);
+ }
+
+ // optional float xmax = 3;
+ if (has_xmax()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(3, this->xmax(), output);
+ }
+
+ // optional float ymax = 4;
+ if (has_ymax()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(4, this->ymax(), output);
+ }
+
+ // optional int32 label = 5;
+ if (has_label()) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(5, this->label(), output);
+ }
+
+ // optional bool difficult = 6;
+ if (has_difficult()) {
+ ::google::protobuf::internal::WireFormatLite::WriteBool(6, this->difficult(), output);
+ }
+
+ // optional float score = 7;
+ if (has_score()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(7, this->score(), output);
+ }
+
+ // optional float size = 8;
+ if (has_size()) {
+ ::google::protobuf::internal::WireFormatLite::WriteFloat(8, this->size(), output);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+ // @@protoc_insertion_point(serialize_end:caffe.NormalizedBBox)
+}
+
+::google::protobuf::uint8* NormalizedBBox::InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* target) const {
+ (void)deterministic; // Unused
+ // @@protoc_insertion_point(serialize_to_array_start:caffe.NormalizedBBox)
+ // optional float xmin = 1;
+ if (has_xmin()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->xmin(), target);
+ }
+
+ // optional float ymin = 2;
+ if (has_ymin()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(2, this->ymin(), target);
+ }
+
+ // optional float xmax = 3;
+ if (has_xmax()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(3, this->xmax(), target);
+ }
+
+ // optional float ymax = 4;
+ if (has_ymax()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(4, this->ymax(), target);
+ }
+
+ // optional int32 label = 5;
+ if (has_label()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(5, this->label(), target);
+ }
+
+ // optional bool difficult = 6;
+ if (has_difficult()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(6, this->difficult(), target);
+ }
+
+ // optional float score = 7;
+ if (has_score()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(7, this->score(), target);
+ }
+
+ // optional float size = 8;
+ if (has_size()) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(8, this->size(), target);
+ }
+
+ if (_internal_metadata_.have_unknown_fields()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ // @@protoc_insertion_point(serialize_to_array_end:caffe.NormalizedBBox)
+ return target;
+}
+
+size_t NormalizedBBox::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:caffe.NormalizedBBox)
+ size_t total_size = 0;
+
+ if (_has_bits_[0 / 32] & 255u) {
+ // optional float xmin = 1;
+ if (has_xmin()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float ymin = 2;
+ if (has_ymin()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float xmax = 3;
+ if (has_xmax()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float ymax = 4;
+ if (has_ymax()) {
+ total_size += 1 + 4;
+ }
+
+ // optional int32 label = 5;
+ if (has_label()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->label());
+ }
+
+ // optional bool difficult = 6;
+ if (has_difficult()) {
+ total_size += 1 + 1;
+ }
+
+ // optional float score = 7;
+ if (has_score()) {
+ total_size += 1 + 4;
+ }
+
+ // optional float size = 8;
+ if (has_size()) {
+ total_size += 1 + 4;
+ }
+
+ }
+ if (_internal_metadata_.have_unknown_fields()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+ GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
+ _cached_size_ = cached_size;
+ GOOGLE_SAFE_CONCURRENT_WRITES_END();
+ return total_size;
+}
+
+void NormalizedBBox::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:caffe.NormalizedBBox)
+ if (GOOGLE_PREDICT_FALSE(&from == this)) MergeFromFail(__LINE__);
+ const NormalizedBBox* source =
+ ::google::protobuf::internal::DynamicCastToGenerated<const NormalizedBBox>(
+ &from);
+ if (source == NULL) {
+ // @@protoc_insertion_point(generalized_merge_from_cast_fail:caffe.NormalizedBBox)
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ // @@protoc_insertion_point(generalized_merge_from_cast_success:caffe.NormalizedBBox)
+ UnsafeMergeFrom(*source);
+ }
+}
+
+void NormalizedBBox::MergeFrom(const NormalizedBBox& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:caffe.NormalizedBBox)
+ if (GOOGLE_PREDICT_TRUE(&from != this)) {
+ UnsafeMergeFrom(from);
+ } else {
+ MergeFromFail(__LINE__);
+ }
+}
+
+void NormalizedBBox::UnsafeMergeFrom(const NormalizedBBox& from) {
+ GOOGLE_DCHECK(&from != this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from.has_xmin()) {
+ set_xmin(from.xmin());
+ }
+ if (from.has_ymin()) {
+ set_ymin(from.ymin());
+ }
+ if (from.has_xmax()) {
+ set_xmax(from.xmax());
+ }
+ if (from.has_ymax()) {
+ set_ymax(from.ymax());
+ }
+ if (from.has_label()) {
+ set_label(from.label());
+ }
+ if (from.has_difficult()) {
+ set_difficult(from.difficult());
+ }
+ if (from.has_score()) {
+ set_score(from.score());
+ }
+ if (from.has_size()) {
+ set_size(from.size());
+ }
+ }
+ if (from._internal_metadata_.have_unknown_fields()) {
+ ::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
+ from.unknown_fields(), &_internal_metadata_);
+ }
+}
+
+void NormalizedBBox::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:caffe.NormalizedBBox)
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void NormalizedBBox::CopyFrom(const NormalizedBBox& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:caffe.NormalizedBBox)
+ if (&from == this) return;
+ Clear();
+ UnsafeMergeFrom(from);
+}
+
+bool NormalizedBBox::IsInitialized() const {
+
+ return true;
+}
+
+void NormalizedBBox::Swap(NormalizedBBox* other) {
+ if (other == this) return;
+ InternalSwap(other);
+}
+void NormalizedBBox::InternalSwap(NormalizedBBox* other) {
+ std::swap(xmin_, other->xmin_);
+ std::swap(ymin_, other->ymin_);
+ std::swap(xmax_, other->xmax_);
+ std::swap(ymax_, other->ymax_);
+ std::swap(label_, other->label_);
+ std::swap(difficult_, other->difficult_);
+ std::swap(score_, other->score_);
+ std::swap(size_, other->size_);
+ std::swap(_has_bits_[0], other->_has_bits_[0]);
+ _internal_metadata_.Swap(&other->_internal_metadata_);
+ std::swap(_cached_size_, other->_cached_size_);
+}
+
+::google::protobuf::Metadata NormalizedBBox::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = NormalizedBBox_descriptor_;
+ metadata.reflection = NormalizedBBox_reflection_;
+ return metadata;
+}
+
+#if PROTOBUF_INLINE_NOT_IN_HEADERS
+// NormalizedBBox
+
+// optional float xmin = 1;
+bool NormalizedBBox::has_xmin() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+void NormalizedBBox::set_has_xmin() {
+ _has_bits_[0] |= 0x00000001u;
+}
+void NormalizedBBox::clear_has_xmin() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+void NormalizedBBox::clear_xmin() {
+ xmin_ = 0;
+ clear_has_xmin();
+}
+float NormalizedBBox::xmin() const {
+ // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.xmin)
+ return xmin_;
+}
+void NormalizedBBox::set_xmin(float value) {
+ set_has_xmin();
+ xmin_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.xmin)
+}
+
+// optional float ymin = 2;
+bool NormalizedBBox::has_ymin() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+void NormalizedBBox::set_has_ymin() {
+ _has_bits_[0] |= 0x00000002u;
+}
+void NormalizedBBox::clear_has_ymin() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+void NormalizedBBox::clear_ymin() {
+ ymin_ = 0;
+ clear_has_ymin();
+}
+float NormalizedBBox::ymin() const {
+ // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.ymin)
+ return ymin_;
+}
+void NormalizedBBox::set_ymin(float value) {
+ set_has_ymin();
+ ymin_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.ymin)
+}
+
+// optional float xmax = 3;
+bool NormalizedBBox::has_xmax() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+void NormalizedBBox::set_has_xmax() {
+ _has_bits_[0] |= 0x00000004u;
+}
+void NormalizedBBox::clear_has_xmax() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+void NormalizedBBox::clear_xmax() {
+ xmax_ = 0;
+ clear_has_xmax();
+}
+float NormalizedBBox::xmax() const {
+ // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.xmax)
+ return xmax_;
+}
+void NormalizedBBox::set_xmax(float value) {
+ set_has_xmax();
+ xmax_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.xmax)
+}
+
+// optional float ymax = 4;
+bool NormalizedBBox::has_ymax() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+void NormalizedBBox::set_has_ymax() {
+ _has_bits_[0] |= 0x00000008u;
+}
+void NormalizedBBox::clear_has_ymax() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+void NormalizedBBox::clear_ymax() {
+ ymax_ = 0;
+ clear_has_ymax();
+}
+float NormalizedBBox::ymax() const {
+ // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.ymax)
+ return ymax_;
+}
+void NormalizedBBox::set_ymax(float value) {
+ set_has_ymax();
+ ymax_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.ymax)
+}
+
+// optional int32 label = 5;
+bool NormalizedBBox::has_label() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+void NormalizedBBox::set_has_label() {
+ _has_bits_[0] |= 0x00000010u;
+}
+void NormalizedBBox::clear_has_label() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+void NormalizedBBox::clear_label() {
+ label_ = 0;
+ clear_has_label();
+}
+::google::protobuf::int32 NormalizedBBox::label() const {
+ // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.label)
+ return label_;
+}
+void NormalizedBBox::set_label(::google::protobuf::int32 value) {
+ set_has_label();
+ label_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.label)
+}
+
+// optional bool difficult = 6;
+bool NormalizedBBox::has_difficult() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+void NormalizedBBox::set_has_difficult() {
+ _has_bits_[0] |= 0x00000020u;
+}
+void NormalizedBBox::clear_has_difficult() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+void NormalizedBBox::clear_difficult() {
+ difficult_ = false;
+ clear_has_difficult();
+}
+bool NormalizedBBox::difficult() const {
+ // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.difficult)
+ return difficult_;
+}
+void NormalizedBBox::set_difficult(bool value) {
+ set_has_difficult();
+ difficult_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.difficult)
+}
+
+// optional float score = 7;
+bool NormalizedBBox::has_score() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+void NormalizedBBox::set_has_score() {
+ _has_bits_[0] |= 0x00000040u;
+}
+void NormalizedBBox::clear_has_score() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+void NormalizedBBox::clear_score() {
+ score_ = 0;
+ clear_has_score();
+}
+float NormalizedBBox::score() const {
+ // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.score)
+ return score_;
+}
+void NormalizedBBox::set_score(float value) {
+ set_has_score();
+ score_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.score)
+}
+
+// optional float size = 8;
+bool NormalizedBBox::has_size() const {
+ return (_has_bits_[0] & 0x00000080u) != 0;
+}
+void NormalizedBBox::set_has_size() {
+ _has_bits_[0] |= 0x00000080u;
+}
+void NormalizedBBox::clear_has_size() {
+ _has_bits_[0] &= ~0x00000080u;
+}
+void NormalizedBBox::clear_size() {
+ size_ = 0;
+ clear_has_size();
+}
+float NormalizedBBox::size() const {
+ // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.size)
+ return size_;
+}
+void NormalizedBBox::set_size(float value) {
+ set_has_size();
+ size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.size)
+}
+
+inline const NormalizedBBox* NormalizedBBox::internal_default_instance() {
+ return &NormalizedBBox_default_instance_.get();
+}
+#endif // PROTOBUF_INLINE_NOT_IN_HEADERS
+
+// @@protoc_insertion_point(namespace_scope)
+
+} // namespace caffe
+
+// @@protoc_insertion_point(global_scope)
diff --git a/modules/dnn/misc/caffe/caffe.pb.h b/modules/dnn/misc/caffe/caffe.pb.h
new file mode 100644
index 0000000..e2fe083
--- /dev/null
+++ b/modules/dnn/misc/caffe/caffe.pb.h
@@ -0,0 +1,28612 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: caffe.proto
+
+#ifndef PROTOBUF_caffe_2eproto__INCLUDED
+#define PROTOBUF_caffe_2eproto__INCLUDED
+
+#include <string>
+
+#include <google/protobuf/stubs/common.h>
+
+#if GOOGLE_PROTOBUF_VERSION < 3001000
+#error This file was generated by a newer version of protoc which is
+#error incompatible with your Protocol Buffer headers. Please update
+#error your headers.
+#endif
+#if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#error This file was generated by an older version of protoc which is
+#error incompatible with your Protocol Buffer headers. Please
+#error regenerate this file with a newer version of protoc.
+#endif
+
+#include <google/protobuf/arena.h>
+#include <google/protobuf/arenastring.h>
+#include <google/protobuf/generated_message_util.h>
+#include <google/protobuf/metadata.h>
+#include <google/protobuf/message.h>
+#include <google/protobuf/repeated_field.h>
+#include <google/protobuf/extension_set.h>
+#include <google/protobuf/generated_enum_reflection.h>
+#include <google/protobuf/unknown_field_set.h>
+// @@protoc_insertion_point(includes)
+
+namespace caffe {
+
+// Internal implementation detail -- do not call these.
+void protobuf_AddDesc_caffe_2eproto();
+void protobuf_InitDefaults_caffe_2eproto();
+void protobuf_AssignDesc_caffe_2eproto();
+void protobuf_ShutdownFile_caffe_2eproto();
+
+class AccuracyParameter;
+class ArgMaxParameter;
+class BatchNormParameter;
+class BiasParameter;
+class BlobProto;
+class BlobProtoVector;
+class BlobShape;
+class ConcatParameter;
+class ContrastiveLossParameter;
+class ConvolutionParameter;
+class CropParameter;
+class DataParameter;
+class Datum;
+class DetectionOutputParameter;
+class DropoutParameter;
+class DummyDataParameter;
+class ELUParameter;
+class EltwiseParameter;
+class EmbedParameter;
+class ExpParameter;
+class FillerParameter;
+class FlattenParameter;
+class HDF5DataParameter;
+class HDF5OutputParameter;
+class HingeLossParameter;
+class ImageDataParameter;
+class InfogainLossParameter;
+class InnerProductParameter;
+class InputParameter;
+class LRNParameter;
+class LayerParameter;
+class LogParameter;
+class LossParameter;
+class MVNParameter;
+class MemoryDataParameter;
+class NetParameter;
+class NetState;
+class NetStateRule;
+class NonMaximumSuppressionParameter;
+class NormalizeBBoxParameter;
+class NormalizedBBox;
+class PReLUParameter;
+class ParamSpec;
+class ParameterParameter;
+class PermuteParameter;
+class PoolingParameter;
+class PowerParameter;
+class PriorBoxParameter;
+class PythonParameter;
+class ReLUParameter;
+class RecurrentParameter;
+class ReductionParameter;
+class ReshapeParameter;
+class SPPParameter;
+class SaveOutputParameter;
+class ScaleParameter;
+class SigmoidParameter;
+class SliceParameter;
+class SoftmaxParameter;
+class SolverParameter;
+class SolverState;
+class TanHParameter;
+class ThresholdParameter;
+class TileParameter;
+class TransformationParameter;
+class V0LayerParameter;
+class V1LayerParameter;
+class WindowDataParameter;
+
+enum PriorBoxParameter_CodeType {
+ PriorBoxParameter_CodeType_CORNER = 1,
+ PriorBoxParameter_CodeType_CENTER_SIZE = 2
+};
+bool PriorBoxParameter_CodeType_IsValid(int value);
+const PriorBoxParameter_CodeType PriorBoxParameter_CodeType_CodeType_MIN = PriorBoxParameter_CodeType_CORNER;
+const PriorBoxParameter_CodeType PriorBoxParameter_CodeType_CodeType_MAX = PriorBoxParameter_CodeType_CENTER_SIZE;
+const int PriorBoxParameter_CodeType_CodeType_ARRAYSIZE = PriorBoxParameter_CodeType_CodeType_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* PriorBoxParameter_CodeType_descriptor();
+inline const ::std::string& PriorBoxParameter_CodeType_Name(PriorBoxParameter_CodeType value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ PriorBoxParameter_CodeType_descriptor(), value);
+}
+inline bool PriorBoxParameter_CodeType_Parse(
+ const ::std::string& name, PriorBoxParameter_CodeType* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<PriorBoxParameter_CodeType>(
+ PriorBoxParameter_CodeType_descriptor(), name, value);
+}
+enum FillerParameter_VarianceNorm {
+ FillerParameter_VarianceNorm_FAN_IN = 0,
+ FillerParameter_VarianceNorm_FAN_OUT = 1,
+ FillerParameter_VarianceNorm_AVERAGE = 2
+};
+bool FillerParameter_VarianceNorm_IsValid(int value);
+const FillerParameter_VarianceNorm FillerParameter_VarianceNorm_VarianceNorm_MIN = FillerParameter_VarianceNorm_FAN_IN;
+const FillerParameter_VarianceNorm FillerParameter_VarianceNorm_VarianceNorm_MAX = FillerParameter_VarianceNorm_AVERAGE;
+const int FillerParameter_VarianceNorm_VarianceNorm_ARRAYSIZE = FillerParameter_VarianceNorm_VarianceNorm_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* FillerParameter_VarianceNorm_descriptor();
+inline const ::std::string& FillerParameter_VarianceNorm_Name(FillerParameter_VarianceNorm value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ FillerParameter_VarianceNorm_descriptor(), value);
+}
+inline bool FillerParameter_VarianceNorm_Parse(
+ const ::std::string& name, FillerParameter_VarianceNorm* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<FillerParameter_VarianceNorm>(
+ FillerParameter_VarianceNorm_descriptor(), name, value);
+}
+enum SolverParameter_SnapshotFormat {
+ SolverParameter_SnapshotFormat_HDF5 = 0,
+ SolverParameter_SnapshotFormat_BINARYPROTO = 1
+};
+bool SolverParameter_SnapshotFormat_IsValid(int value);
+const SolverParameter_SnapshotFormat SolverParameter_SnapshotFormat_SnapshotFormat_MIN = SolverParameter_SnapshotFormat_HDF5;
+const SolverParameter_SnapshotFormat SolverParameter_SnapshotFormat_SnapshotFormat_MAX = SolverParameter_SnapshotFormat_BINARYPROTO;
+const int SolverParameter_SnapshotFormat_SnapshotFormat_ARRAYSIZE = SolverParameter_SnapshotFormat_SnapshotFormat_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* SolverParameter_SnapshotFormat_descriptor();
+inline const ::std::string& SolverParameter_SnapshotFormat_Name(SolverParameter_SnapshotFormat value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ SolverParameter_SnapshotFormat_descriptor(), value);
+}
+inline bool SolverParameter_SnapshotFormat_Parse(
+ const ::std::string& name, SolverParameter_SnapshotFormat* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<SolverParameter_SnapshotFormat>(
+ SolverParameter_SnapshotFormat_descriptor(), name, value);
+}
+enum SolverParameter_SolverMode {
+ SolverParameter_SolverMode_CPU = 0,
+ SolverParameter_SolverMode_GPU = 1
+};
+bool SolverParameter_SolverMode_IsValid(int value);
+const SolverParameter_SolverMode SolverParameter_SolverMode_SolverMode_MIN = SolverParameter_SolverMode_CPU;
+const SolverParameter_SolverMode SolverParameter_SolverMode_SolverMode_MAX = SolverParameter_SolverMode_GPU;
+const int SolverParameter_SolverMode_SolverMode_ARRAYSIZE = SolverParameter_SolverMode_SolverMode_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* SolverParameter_SolverMode_descriptor();
+inline const ::std::string& SolverParameter_SolverMode_Name(SolverParameter_SolverMode value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ SolverParameter_SolverMode_descriptor(), value);
+}
+inline bool SolverParameter_SolverMode_Parse(
+ const ::std::string& name, SolverParameter_SolverMode* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<SolverParameter_SolverMode>(
+ SolverParameter_SolverMode_descriptor(), name, value);
+}
+enum SolverParameter_SolverType {
+ SolverParameter_SolverType_SGD = 0,
+ SolverParameter_SolverType_NESTEROV = 1,
+ SolverParameter_SolverType_ADAGRAD = 2,
+ SolverParameter_SolverType_RMSPROP = 3,
+ SolverParameter_SolverType_ADADELTA = 4,
+ SolverParameter_SolverType_ADAM = 5
+};
+bool SolverParameter_SolverType_IsValid(int value);
+const SolverParameter_SolverType SolverParameter_SolverType_SolverType_MIN = SolverParameter_SolverType_SGD;
+const SolverParameter_SolverType SolverParameter_SolverType_SolverType_MAX = SolverParameter_SolverType_ADAM;
+const int SolverParameter_SolverType_SolverType_ARRAYSIZE = SolverParameter_SolverType_SolverType_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* SolverParameter_SolverType_descriptor();
+inline const ::std::string& SolverParameter_SolverType_Name(SolverParameter_SolverType value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ SolverParameter_SolverType_descriptor(), value);
+}
+inline bool SolverParameter_SolverType_Parse(
+ const ::std::string& name, SolverParameter_SolverType* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<SolverParameter_SolverType>(
+ SolverParameter_SolverType_descriptor(), name, value);
+}
+enum ParamSpec_DimCheckMode {
+ ParamSpec_DimCheckMode_STRICT = 0,
+ ParamSpec_DimCheckMode_PERMISSIVE = 1
+};
+bool ParamSpec_DimCheckMode_IsValid(int value);
+const ParamSpec_DimCheckMode ParamSpec_DimCheckMode_DimCheckMode_MIN = ParamSpec_DimCheckMode_STRICT;
+const ParamSpec_DimCheckMode ParamSpec_DimCheckMode_DimCheckMode_MAX = ParamSpec_DimCheckMode_PERMISSIVE;
+const int ParamSpec_DimCheckMode_DimCheckMode_ARRAYSIZE = ParamSpec_DimCheckMode_DimCheckMode_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* ParamSpec_DimCheckMode_descriptor();
+inline const ::std::string& ParamSpec_DimCheckMode_Name(ParamSpec_DimCheckMode value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ ParamSpec_DimCheckMode_descriptor(), value);
+}
+inline bool ParamSpec_DimCheckMode_Parse(
+ const ::std::string& name, ParamSpec_DimCheckMode* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<ParamSpec_DimCheckMode>(
+ ParamSpec_DimCheckMode_descriptor(), name, value);
+}
+enum LossParameter_NormalizationMode {
+ LossParameter_NormalizationMode_FULL = 0,
+ LossParameter_NormalizationMode_VALID = 1,
+ LossParameter_NormalizationMode_BATCH_SIZE = 2,
+ LossParameter_NormalizationMode_NONE = 3
+};
+bool LossParameter_NormalizationMode_IsValid(int value);
+const LossParameter_NormalizationMode LossParameter_NormalizationMode_NormalizationMode_MIN = LossParameter_NormalizationMode_FULL;
+const LossParameter_NormalizationMode LossParameter_NormalizationMode_NormalizationMode_MAX = LossParameter_NormalizationMode_NONE;
+const int LossParameter_NormalizationMode_NormalizationMode_ARRAYSIZE = LossParameter_NormalizationMode_NormalizationMode_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* LossParameter_NormalizationMode_descriptor();
+inline const ::std::string& LossParameter_NormalizationMode_Name(LossParameter_NormalizationMode value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ LossParameter_NormalizationMode_descriptor(), value);
+}
+inline bool LossParameter_NormalizationMode_Parse(
+ const ::std::string& name, LossParameter_NormalizationMode* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<LossParameter_NormalizationMode>(
+ LossParameter_NormalizationMode_descriptor(), name, value);
+}
+enum ConvolutionParameter_Engine {
+ ConvolutionParameter_Engine_DEFAULT = 0,
+ ConvolutionParameter_Engine_CAFFE = 1,
+ ConvolutionParameter_Engine_CUDNN = 2
+};
+bool ConvolutionParameter_Engine_IsValid(int value);
+const ConvolutionParameter_Engine ConvolutionParameter_Engine_Engine_MIN = ConvolutionParameter_Engine_DEFAULT;
+const ConvolutionParameter_Engine ConvolutionParameter_Engine_Engine_MAX = ConvolutionParameter_Engine_CUDNN;
+const int ConvolutionParameter_Engine_Engine_ARRAYSIZE = ConvolutionParameter_Engine_Engine_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* ConvolutionParameter_Engine_descriptor();
+inline const ::std::string& ConvolutionParameter_Engine_Name(ConvolutionParameter_Engine value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ ConvolutionParameter_Engine_descriptor(), value);
+}
+inline bool ConvolutionParameter_Engine_Parse(
+ const ::std::string& name, ConvolutionParameter_Engine* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<ConvolutionParameter_Engine>(
+ ConvolutionParameter_Engine_descriptor(), name, value);
+}
+enum DataParameter_DB {
+ DataParameter_DB_LEVELDB = 0,
+ DataParameter_DB_LMDB = 1
+};
+bool DataParameter_DB_IsValid(int value);
+const DataParameter_DB DataParameter_DB_DB_MIN = DataParameter_DB_LEVELDB;
+const DataParameter_DB DataParameter_DB_DB_MAX = DataParameter_DB_LMDB;
+const int DataParameter_DB_DB_ARRAYSIZE = DataParameter_DB_DB_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* DataParameter_DB_descriptor();
+inline const ::std::string& DataParameter_DB_Name(DataParameter_DB value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ DataParameter_DB_descriptor(), value);
+}
+inline bool DataParameter_DB_Parse(
+ const ::std::string& name, DataParameter_DB* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<DataParameter_DB>(
+ DataParameter_DB_descriptor(), name, value);
+}
+enum EltwiseParameter_EltwiseOp {
+ EltwiseParameter_EltwiseOp_PROD = 0,
+ EltwiseParameter_EltwiseOp_SUM = 1,
+ EltwiseParameter_EltwiseOp_MAX = 2
+};
+bool EltwiseParameter_EltwiseOp_IsValid(int value);
+const EltwiseParameter_EltwiseOp EltwiseParameter_EltwiseOp_EltwiseOp_MIN = EltwiseParameter_EltwiseOp_PROD;
+const EltwiseParameter_EltwiseOp EltwiseParameter_EltwiseOp_EltwiseOp_MAX = EltwiseParameter_EltwiseOp_MAX;
+const int EltwiseParameter_EltwiseOp_EltwiseOp_ARRAYSIZE = EltwiseParameter_EltwiseOp_EltwiseOp_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* EltwiseParameter_EltwiseOp_descriptor();
+inline const ::std::string& EltwiseParameter_EltwiseOp_Name(EltwiseParameter_EltwiseOp value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ EltwiseParameter_EltwiseOp_descriptor(), value);
+}
+inline bool EltwiseParameter_EltwiseOp_Parse(
+ const ::std::string& name, EltwiseParameter_EltwiseOp* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<EltwiseParameter_EltwiseOp>(
+ EltwiseParameter_EltwiseOp_descriptor(), name, value);
+}
+enum HingeLossParameter_Norm {
+ HingeLossParameter_Norm_L1 = 1,
+ HingeLossParameter_Norm_L2 = 2
+};
+bool HingeLossParameter_Norm_IsValid(int value);
+const HingeLossParameter_Norm HingeLossParameter_Norm_Norm_MIN = HingeLossParameter_Norm_L1;
+const HingeLossParameter_Norm HingeLossParameter_Norm_Norm_MAX = HingeLossParameter_Norm_L2;
+const int HingeLossParameter_Norm_Norm_ARRAYSIZE = HingeLossParameter_Norm_Norm_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* HingeLossParameter_Norm_descriptor();
+inline const ::std::string& HingeLossParameter_Norm_Name(HingeLossParameter_Norm value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ HingeLossParameter_Norm_descriptor(), value);
+}
+inline bool HingeLossParameter_Norm_Parse(
+ const ::std::string& name, HingeLossParameter_Norm* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<HingeLossParameter_Norm>(
+ HingeLossParameter_Norm_descriptor(), name, value);
+}
+enum LRNParameter_NormRegion {
+ LRNParameter_NormRegion_ACROSS_CHANNELS = 0,
+ LRNParameter_NormRegion_WITHIN_CHANNEL = 1
+};
+bool LRNParameter_NormRegion_IsValid(int value);
+const LRNParameter_NormRegion LRNParameter_NormRegion_NormRegion_MIN = LRNParameter_NormRegion_ACROSS_CHANNELS;
+const LRNParameter_NormRegion LRNParameter_NormRegion_NormRegion_MAX = LRNParameter_NormRegion_WITHIN_CHANNEL;
+const int LRNParameter_NormRegion_NormRegion_ARRAYSIZE = LRNParameter_NormRegion_NormRegion_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* LRNParameter_NormRegion_descriptor();
+inline const ::std::string& LRNParameter_NormRegion_Name(LRNParameter_NormRegion value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ LRNParameter_NormRegion_descriptor(), value);
+}
+inline bool LRNParameter_NormRegion_Parse(
+ const ::std::string& name, LRNParameter_NormRegion* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<LRNParameter_NormRegion>(
+ LRNParameter_NormRegion_descriptor(), name, value);
+}
+enum LRNParameter_Engine {
+ LRNParameter_Engine_DEFAULT = 0,
+ LRNParameter_Engine_CAFFE = 1,
+ LRNParameter_Engine_CUDNN = 2
+};
+bool LRNParameter_Engine_IsValid(int value);
+const LRNParameter_Engine LRNParameter_Engine_Engine_MIN = LRNParameter_Engine_DEFAULT;
+const LRNParameter_Engine LRNParameter_Engine_Engine_MAX = LRNParameter_Engine_CUDNN;
+const int LRNParameter_Engine_Engine_ARRAYSIZE = LRNParameter_Engine_Engine_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* LRNParameter_Engine_descriptor();
+inline const ::std::string& LRNParameter_Engine_Name(LRNParameter_Engine value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ LRNParameter_Engine_descriptor(), value);
+}
+inline bool LRNParameter_Engine_Parse(
+ const ::std::string& name, LRNParameter_Engine* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<LRNParameter_Engine>(
+ LRNParameter_Engine_descriptor(), name, value);
+}
+enum PoolingParameter_PoolMethod {
+ PoolingParameter_PoolMethod_MAX = 0,
+ PoolingParameter_PoolMethod_AVE = 1,
+ PoolingParameter_PoolMethod_STOCHASTIC = 2
+};
+bool PoolingParameter_PoolMethod_IsValid(int value);
+const PoolingParameter_PoolMethod PoolingParameter_PoolMethod_PoolMethod_MIN = PoolingParameter_PoolMethod_MAX;
+const PoolingParameter_PoolMethod PoolingParameter_PoolMethod_PoolMethod_MAX = PoolingParameter_PoolMethod_STOCHASTIC;
+const int PoolingParameter_PoolMethod_PoolMethod_ARRAYSIZE = PoolingParameter_PoolMethod_PoolMethod_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* PoolingParameter_PoolMethod_descriptor();
+inline const ::std::string& PoolingParameter_PoolMethod_Name(PoolingParameter_PoolMethod value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ PoolingParameter_PoolMethod_descriptor(), value);
+}
+inline bool PoolingParameter_PoolMethod_Parse(
+ const ::std::string& name, PoolingParameter_PoolMethod* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<PoolingParameter_PoolMethod>(
+ PoolingParameter_PoolMethod_descriptor(), name, value);
+}
+enum PoolingParameter_Engine {
+ PoolingParameter_Engine_DEFAULT = 0,
+ PoolingParameter_Engine_CAFFE = 1,
+ PoolingParameter_Engine_CUDNN = 2
+};
+bool PoolingParameter_Engine_IsValid(int value);
+const PoolingParameter_Engine PoolingParameter_Engine_Engine_MIN = PoolingParameter_Engine_DEFAULT;
+const PoolingParameter_Engine PoolingParameter_Engine_Engine_MAX = PoolingParameter_Engine_CUDNN;
+const int PoolingParameter_Engine_Engine_ARRAYSIZE = PoolingParameter_Engine_Engine_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* PoolingParameter_Engine_descriptor();
+inline const ::std::string& PoolingParameter_Engine_Name(PoolingParameter_Engine value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ PoolingParameter_Engine_descriptor(), value);
+}
+inline bool PoolingParameter_Engine_Parse(
+ const ::std::string& name, PoolingParameter_Engine* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<PoolingParameter_Engine>(
+ PoolingParameter_Engine_descriptor(), name, value);
+}
+enum ReductionParameter_ReductionOp {
+ ReductionParameter_ReductionOp_SUM = 1,
+ ReductionParameter_ReductionOp_ASUM = 2,
+ ReductionParameter_ReductionOp_SUMSQ = 3,
+ ReductionParameter_ReductionOp_MEAN = 4
+};
+bool ReductionParameter_ReductionOp_IsValid(int value);
+const ReductionParameter_ReductionOp ReductionParameter_ReductionOp_ReductionOp_MIN = ReductionParameter_ReductionOp_SUM;
+const ReductionParameter_ReductionOp ReductionParameter_ReductionOp_ReductionOp_MAX = ReductionParameter_ReductionOp_MEAN;
+const int ReductionParameter_ReductionOp_ReductionOp_ARRAYSIZE = ReductionParameter_ReductionOp_ReductionOp_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* ReductionParameter_ReductionOp_descriptor();
+inline const ::std::string& ReductionParameter_ReductionOp_Name(ReductionParameter_ReductionOp value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ ReductionParameter_ReductionOp_descriptor(), value);
+}
+inline bool ReductionParameter_ReductionOp_Parse(
+ const ::std::string& name, ReductionParameter_ReductionOp* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<ReductionParameter_ReductionOp>(
+ ReductionParameter_ReductionOp_descriptor(), name, value);
+}
+enum ReLUParameter_Engine {
+ ReLUParameter_Engine_DEFAULT = 0,
+ ReLUParameter_Engine_CAFFE = 1,
+ ReLUParameter_Engine_CUDNN = 2
+};
+bool ReLUParameter_Engine_IsValid(int value);
+const ReLUParameter_Engine ReLUParameter_Engine_Engine_MIN = ReLUParameter_Engine_DEFAULT;
+const ReLUParameter_Engine ReLUParameter_Engine_Engine_MAX = ReLUParameter_Engine_CUDNN;
+const int ReLUParameter_Engine_Engine_ARRAYSIZE = ReLUParameter_Engine_Engine_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* ReLUParameter_Engine_descriptor();
+inline const ::std::string& ReLUParameter_Engine_Name(ReLUParameter_Engine value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ ReLUParameter_Engine_descriptor(), value);
+}
+inline bool ReLUParameter_Engine_Parse(
+ const ::std::string& name, ReLUParameter_Engine* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<ReLUParameter_Engine>(
+ ReLUParameter_Engine_descriptor(), name, value);
+}
+enum SigmoidParameter_Engine {
+ SigmoidParameter_Engine_DEFAULT = 0,
+ SigmoidParameter_Engine_CAFFE = 1,
+ SigmoidParameter_Engine_CUDNN = 2
+};
+bool SigmoidParameter_Engine_IsValid(int value);
+const SigmoidParameter_Engine SigmoidParameter_Engine_Engine_MIN = SigmoidParameter_Engine_DEFAULT;
+const SigmoidParameter_Engine SigmoidParameter_Engine_Engine_MAX = SigmoidParameter_Engine_CUDNN;
+const int SigmoidParameter_Engine_Engine_ARRAYSIZE = SigmoidParameter_Engine_Engine_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* SigmoidParameter_Engine_descriptor();
+inline const ::std::string& SigmoidParameter_Engine_Name(SigmoidParameter_Engine value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ SigmoidParameter_Engine_descriptor(), value);
+}
+inline bool SigmoidParameter_Engine_Parse(
+ const ::std::string& name, SigmoidParameter_Engine* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<SigmoidParameter_Engine>(
+ SigmoidParameter_Engine_descriptor(), name, value);
+}
+enum SoftmaxParameter_Engine {
+ SoftmaxParameter_Engine_DEFAULT = 0,
+ SoftmaxParameter_Engine_CAFFE = 1,
+ SoftmaxParameter_Engine_CUDNN = 2
+};
+bool SoftmaxParameter_Engine_IsValid(int value);
+const SoftmaxParameter_Engine SoftmaxParameter_Engine_Engine_MIN = SoftmaxParameter_Engine_DEFAULT;
+const SoftmaxParameter_Engine SoftmaxParameter_Engine_Engine_MAX = SoftmaxParameter_Engine_CUDNN;
+const int SoftmaxParameter_Engine_Engine_ARRAYSIZE = SoftmaxParameter_Engine_Engine_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* SoftmaxParameter_Engine_descriptor();
+inline const ::std::string& SoftmaxParameter_Engine_Name(SoftmaxParameter_Engine value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ SoftmaxParameter_Engine_descriptor(), value);
+}
+inline bool SoftmaxParameter_Engine_Parse(
+ const ::std::string& name, SoftmaxParameter_Engine* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<SoftmaxParameter_Engine>(
+ SoftmaxParameter_Engine_descriptor(), name, value);
+}
+enum TanHParameter_Engine {
+ TanHParameter_Engine_DEFAULT = 0,
+ TanHParameter_Engine_CAFFE = 1,
+ TanHParameter_Engine_CUDNN = 2
+};
+bool TanHParameter_Engine_IsValid(int value);
+const TanHParameter_Engine TanHParameter_Engine_Engine_MIN = TanHParameter_Engine_DEFAULT;
+const TanHParameter_Engine TanHParameter_Engine_Engine_MAX = TanHParameter_Engine_CUDNN;
+const int TanHParameter_Engine_Engine_ARRAYSIZE = TanHParameter_Engine_Engine_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* TanHParameter_Engine_descriptor();
+inline const ::std::string& TanHParameter_Engine_Name(TanHParameter_Engine value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ TanHParameter_Engine_descriptor(), value);
+}
+inline bool TanHParameter_Engine_Parse(
+ const ::std::string& name, TanHParameter_Engine* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<TanHParameter_Engine>(
+ TanHParameter_Engine_descriptor(), name, value);
+}
+enum SPPParameter_PoolMethod {
+ SPPParameter_PoolMethod_MAX = 0,
+ SPPParameter_PoolMethod_AVE = 1,
+ SPPParameter_PoolMethod_STOCHASTIC = 2
+};
+bool SPPParameter_PoolMethod_IsValid(int value);
+const SPPParameter_PoolMethod SPPParameter_PoolMethod_PoolMethod_MIN = SPPParameter_PoolMethod_MAX;
+const SPPParameter_PoolMethod SPPParameter_PoolMethod_PoolMethod_MAX = SPPParameter_PoolMethod_STOCHASTIC;
+const int SPPParameter_PoolMethod_PoolMethod_ARRAYSIZE = SPPParameter_PoolMethod_PoolMethod_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* SPPParameter_PoolMethod_descriptor();
+inline const ::std::string& SPPParameter_PoolMethod_Name(SPPParameter_PoolMethod value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ SPPParameter_PoolMethod_descriptor(), value);
+}
+inline bool SPPParameter_PoolMethod_Parse(
+ const ::std::string& name, SPPParameter_PoolMethod* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<SPPParameter_PoolMethod>(
+ SPPParameter_PoolMethod_descriptor(), name, value);
+}
+enum SPPParameter_Engine {
+ SPPParameter_Engine_DEFAULT = 0,
+ SPPParameter_Engine_CAFFE = 1,
+ SPPParameter_Engine_CUDNN = 2
+};
+bool SPPParameter_Engine_IsValid(int value);
+const SPPParameter_Engine SPPParameter_Engine_Engine_MIN = SPPParameter_Engine_DEFAULT;
+const SPPParameter_Engine SPPParameter_Engine_Engine_MAX = SPPParameter_Engine_CUDNN;
+const int SPPParameter_Engine_Engine_ARRAYSIZE = SPPParameter_Engine_Engine_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* SPPParameter_Engine_descriptor();
+inline const ::std::string& SPPParameter_Engine_Name(SPPParameter_Engine value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ SPPParameter_Engine_descriptor(), value);
+}
+inline bool SPPParameter_Engine_Parse(
+ const ::std::string& name, SPPParameter_Engine* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<SPPParameter_Engine>(
+ SPPParameter_Engine_descriptor(), name, value);
+}
+enum V1LayerParameter_LayerType {
+ V1LayerParameter_LayerType_NONE = 0,
+ V1LayerParameter_LayerType_ABSVAL = 35,
+ V1LayerParameter_LayerType_ACCURACY = 1,
+ V1LayerParameter_LayerType_ARGMAX = 30,
+ V1LayerParameter_LayerType_BNLL = 2,
+ V1LayerParameter_LayerType_CONCAT = 3,
+ V1LayerParameter_LayerType_CONTRASTIVE_LOSS = 37,
+ V1LayerParameter_LayerType_CONVOLUTION = 4,
+ V1LayerParameter_LayerType_DATA = 5,
+ V1LayerParameter_LayerType_DECONVOLUTION = 39,
+ V1LayerParameter_LayerType_DROPOUT = 6,
+ V1LayerParameter_LayerType_DUMMY_DATA = 32,
+ V1LayerParameter_LayerType_EUCLIDEAN_LOSS = 7,
+ V1LayerParameter_LayerType_ELTWISE = 25,
+ V1LayerParameter_LayerType_EXP = 38,
+ V1LayerParameter_LayerType_FLATTEN = 8,
+ V1LayerParameter_LayerType_HDF5_DATA = 9,
+ V1LayerParameter_LayerType_HDF5_OUTPUT = 10,
+ V1LayerParameter_LayerType_HINGE_LOSS = 28,
+ V1LayerParameter_LayerType_IM2COL = 11,
+ V1LayerParameter_LayerType_IMAGE_DATA = 12,
+ V1LayerParameter_LayerType_INFOGAIN_LOSS = 13,
+ V1LayerParameter_LayerType_INNER_PRODUCT = 14,
+ V1LayerParameter_LayerType_LRN = 15,
+ V1LayerParameter_LayerType_MEMORY_DATA = 29,
+ V1LayerParameter_LayerType_MULTINOMIAL_LOGISTIC_LOSS = 16,
+ V1LayerParameter_LayerType_MVN = 34,
+ V1LayerParameter_LayerType_POOLING = 17,
+ V1LayerParameter_LayerType_POWER = 26,
+ V1LayerParameter_LayerType_RELU = 18,
+ V1LayerParameter_LayerType_SIGMOID = 19,
+ V1LayerParameter_LayerType_SIGMOID_CROSS_ENTROPY_LOSS = 27,
+ V1LayerParameter_LayerType_SILENCE = 36,
+ V1LayerParameter_LayerType_SOFTMAX = 20,
+ V1LayerParameter_LayerType_SOFTMAX_LOSS = 21,
+ V1LayerParameter_LayerType_SPLIT = 22,
+ V1LayerParameter_LayerType_SLICE = 33,
+ V1LayerParameter_LayerType_TANH = 23,
+ V1LayerParameter_LayerType_WINDOW_DATA = 24,
+ V1LayerParameter_LayerType_THRESHOLD = 31
+};
+bool V1LayerParameter_LayerType_IsValid(int value);
+const V1LayerParameter_LayerType V1LayerParameter_LayerType_LayerType_MIN = V1LayerParameter_LayerType_NONE;
+const V1LayerParameter_LayerType V1LayerParameter_LayerType_LayerType_MAX = V1LayerParameter_LayerType_DECONVOLUTION;
+const int V1LayerParameter_LayerType_LayerType_ARRAYSIZE = V1LayerParameter_LayerType_LayerType_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* V1LayerParameter_LayerType_descriptor();
+inline const ::std::string& V1LayerParameter_LayerType_Name(V1LayerParameter_LayerType value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ V1LayerParameter_LayerType_descriptor(), value);
+}
+inline bool V1LayerParameter_LayerType_Parse(
+ const ::std::string& name, V1LayerParameter_LayerType* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<V1LayerParameter_LayerType>(
+ V1LayerParameter_LayerType_descriptor(), name, value);
+}
+enum V1LayerParameter_DimCheckMode {
+ V1LayerParameter_DimCheckMode_STRICT = 0,
+ V1LayerParameter_DimCheckMode_PERMISSIVE = 1
+};
+bool V1LayerParameter_DimCheckMode_IsValid(int value);
+const V1LayerParameter_DimCheckMode V1LayerParameter_DimCheckMode_DimCheckMode_MIN = V1LayerParameter_DimCheckMode_STRICT;
+const V1LayerParameter_DimCheckMode V1LayerParameter_DimCheckMode_DimCheckMode_MAX = V1LayerParameter_DimCheckMode_PERMISSIVE;
+const int V1LayerParameter_DimCheckMode_DimCheckMode_ARRAYSIZE = V1LayerParameter_DimCheckMode_DimCheckMode_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* V1LayerParameter_DimCheckMode_descriptor();
+inline const ::std::string& V1LayerParameter_DimCheckMode_Name(V1LayerParameter_DimCheckMode value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ V1LayerParameter_DimCheckMode_descriptor(), value);
+}
+inline bool V1LayerParameter_DimCheckMode_Parse(
+ const ::std::string& name, V1LayerParameter_DimCheckMode* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<V1LayerParameter_DimCheckMode>(
+ V1LayerParameter_DimCheckMode_descriptor(), name, value);
+}
+enum V0LayerParameter_PoolMethod {
+ V0LayerParameter_PoolMethod_MAX = 0,
+ V0LayerParameter_PoolMethod_AVE = 1,
+ V0LayerParameter_PoolMethod_STOCHASTIC = 2
+};
+bool V0LayerParameter_PoolMethod_IsValid(int value);
+const V0LayerParameter_PoolMethod V0LayerParameter_PoolMethod_PoolMethod_MIN = V0LayerParameter_PoolMethod_MAX;
+const V0LayerParameter_PoolMethod V0LayerParameter_PoolMethod_PoolMethod_MAX = V0LayerParameter_PoolMethod_STOCHASTIC;
+const int V0LayerParameter_PoolMethod_PoolMethod_ARRAYSIZE = V0LayerParameter_PoolMethod_PoolMethod_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* V0LayerParameter_PoolMethod_descriptor();
+inline const ::std::string& V0LayerParameter_PoolMethod_Name(V0LayerParameter_PoolMethod value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ V0LayerParameter_PoolMethod_descriptor(), value);
+}
+inline bool V0LayerParameter_PoolMethod_Parse(
+ const ::std::string& name, V0LayerParameter_PoolMethod* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<V0LayerParameter_PoolMethod>(
+ V0LayerParameter_PoolMethod_descriptor(), name, value);
+}
+enum Phase {
+ TRAIN = 0,
+ TEST = 1
+};
+bool Phase_IsValid(int value);
+const Phase Phase_MIN = TRAIN;
+const Phase Phase_MAX = TEST;
+const int Phase_ARRAYSIZE = Phase_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* Phase_descriptor();
+inline const ::std::string& Phase_Name(Phase value) {
+ return ::google::protobuf::internal::NameOfEnum(
+ Phase_descriptor(), value);
+}
+inline bool Phase_Parse(
+ const ::std::string& name, Phase* value) {
+ return ::google::protobuf::internal::ParseNamedEnum<Phase>(
+ Phase_descriptor(), name, value);
+}
+// ===================================================================
+
+class BlobShape : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.BlobShape) */ {
+ public:
+ BlobShape();
+ virtual ~BlobShape();
+
+ BlobShape(const BlobShape& from);
+
+ inline BlobShape& operator=(const BlobShape& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const BlobShape& default_instance();
+
+ static const BlobShape* internal_default_instance();
+
+ void Swap(BlobShape* other);
+
+ // implements Message ----------------------------------------------
+
+ inline BlobShape* New() const { return New(NULL); }
+
+ BlobShape* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const BlobShape& from);
+ void MergeFrom(const BlobShape& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(BlobShape* other);
+ void UnsafeMergeFrom(const BlobShape& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // repeated int64 dim = 1 [packed = true];
+ int dim_size() const;
+ void clear_dim();
+ static const int kDimFieldNumber = 1;
+ ::google::protobuf::int64 dim(int index) const;
+ void set_dim(int index, ::google::protobuf::int64 value);
+ void add_dim(::google::protobuf::int64 value);
+ const ::google::protobuf::RepeatedField< ::google::protobuf::int64 >&
+ dim() const;
+ ::google::protobuf::RepeatedField< ::google::protobuf::int64 >*
+ mutable_dim();
+
+ // @@protoc_insertion_point(class_scope:caffe.BlobShape)
+ private:
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::RepeatedField< ::google::protobuf::int64 > dim_;
+ mutable int _dim_cached_byte_size_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<BlobShape> BlobShape_default_instance_;
+
+// -------------------------------------------------------------------
+
+class BlobProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.BlobProto) */ {
+ public:
+ BlobProto();
+ virtual ~BlobProto();
+
+ BlobProto(const BlobProto& from);
+
+ inline BlobProto& operator=(const BlobProto& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const BlobProto& default_instance();
+
+ static const BlobProto* internal_default_instance();
+
+ void Swap(BlobProto* other);
+
+ // implements Message ----------------------------------------------
+
+ inline BlobProto* New() const { return New(NULL); }
+
+ BlobProto* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const BlobProto& from);
+ void MergeFrom(const BlobProto& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(BlobProto* other);
+ void UnsafeMergeFrom(const BlobProto& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional .caffe.BlobShape shape = 7;
+ bool has_shape() const;
+ void clear_shape();
+ static const int kShapeFieldNumber = 7;
+ const ::caffe::BlobShape& shape() const;
+ ::caffe::BlobShape* mutable_shape();
+ ::caffe::BlobShape* release_shape();
+ void set_allocated_shape(::caffe::BlobShape* shape);
+
+ // repeated float data = 5 [packed = true];
+ int data_size() const;
+ void clear_data();
+ static const int kDataFieldNumber = 5;
+ float data(int index) const;
+ void set_data(int index, float value);
+ void add_data(float value);
+ const ::google::protobuf::RepeatedField< float >&
+ data() const;
+ ::google::protobuf::RepeatedField< float >*
+ mutable_data();
+
+ // repeated float diff = 6 [packed = true];
+ int diff_size() const;
+ void clear_diff();
+ static const int kDiffFieldNumber = 6;
+ float diff(int index) const;
+ void set_diff(int index, float value);
+ void add_diff(float value);
+ const ::google::protobuf::RepeatedField< float >&
+ diff() const;
+ ::google::protobuf::RepeatedField< float >*
+ mutable_diff();
+
+ // repeated double double_data = 8 [packed = true];
+ int double_data_size() const;
+ void clear_double_data();
+ static const int kDoubleDataFieldNumber = 8;
+ double double_data(int index) const;
+ void set_double_data(int index, double value);
+ void add_double_data(double value);
+ const ::google::protobuf::RepeatedField< double >&
+ double_data() const;
+ ::google::protobuf::RepeatedField< double >*
+ mutable_double_data();
+
+ // repeated double double_diff = 9 [packed = true];
+ int double_diff_size() const;
+ void clear_double_diff();
+ static const int kDoubleDiffFieldNumber = 9;
+ double double_diff(int index) const;
+ void set_double_diff(int index, double value);
+ void add_double_diff(double value);
+ const ::google::protobuf::RepeatedField< double >&
+ double_diff() const;
+ ::google::protobuf::RepeatedField< double >*
+ mutable_double_diff();
+
+ // optional int32 num = 1 [default = 0];
+ bool has_num() const;
+ void clear_num();
+ static const int kNumFieldNumber = 1;
+ ::google::protobuf::int32 num() const;
+ void set_num(::google::protobuf::int32 value);
+
+ // optional int32 channels = 2 [default = 0];
+ bool has_channels() const;
+ void clear_channels();
+ static const int kChannelsFieldNumber = 2;
+ ::google::protobuf::int32 channels() const;
+ void set_channels(::google::protobuf::int32 value);
+
+ // optional int32 height = 3 [default = 0];
+ bool has_height() const;
+ void clear_height();
+ static const int kHeightFieldNumber = 3;
+ ::google::protobuf::int32 height() const;
+ void set_height(::google::protobuf::int32 value);
+
+ // optional int32 width = 4 [default = 0];
+ bool has_width() const;
+ void clear_width();
+ static const int kWidthFieldNumber = 4;
+ ::google::protobuf::int32 width() const;
+ void set_width(::google::protobuf::int32 value);
+
+ // @@protoc_insertion_point(class_scope:caffe.BlobProto)
+ private:
+ inline void set_has_shape();
+ inline void clear_has_shape();
+ inline void set_has_num();
+ inline void clear_has_num();
+ inline void set_has_channels();
+ inline void clear_has_channels();
+ inline void set_has_height();
+ inline void clear_has_height();
+ inline void set_has_width();
+ inline void clear_has_width();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::RepeatedField< float > data_;
+ mutable int _data_cached_byte_size_;
+ ::google::protobuf::RepeatedField< float > diff_;
+ mutable int _diff_cached_byte_size_;
+ ::google::protobuf::RepeatedField< double > double_data_;
+ mutable int _double_data_cached_byte_size_;
+ ::google::protobuf::RepeatedField< double > double_diff_;
+ mutable int _double_diff_cached_byte_size_;
+ ::caffe::BlobShape* shape_;
+ ::google::protobuf::int32 num_;
+ ::google::protobuf::int32 channels_;
+ ::google::protobuf::int32 height_;
+ ::google::protobuf::int32 width_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<BlobProto> BlobProto_default_instance_;
+
+// -------------------------------------------------------------------
+
+class BlobProtoVector : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.BlobProtoVector) */ {
+ public:
+ BlobProtoVector();
+ virtual ~BlobProtoVector();
+
+ BlobProtoVector(const BlobProtoVector& from);
+
+ inline BlobProtoVector& operator=(const BlobProtoVector& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const BlobProtoVector& default_instance();
+
+ static const BlobProtoVector* internal_default_instance();
+
+ void Swap(BlobProtoVector* other);
+
+ // implements Message ----------------------------------------------
+
+ inline BlobProtoVector* New() const { return New(NULL); }
+
+ BlobProtoVector* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const BlobProtoVector& from);
+ void MergeFrom(const BlobProtoVector& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(BlobProtoVector* other);
+ void UnsafeMergeFrom(const BlobProtoVector& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // repeated .caffe.BlobProto blobs = 1;
+ int blobs_size() const;
+ void clear_blobs();
+ static const int kBlobsFieldNumber = 1;
+ const ::caffe::BlobProto& blobs(int index) const;
+ ::caffe::BlobProto* mutable_blobs(int index);
+ ::caffe::BlobProto* add_blobs();
+ ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
+ mutable_blobs();
+ const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
+ blobs() const;
+
+ // @@protoc_insertion_point(class_scope:caffe.BlobProtoVector)
+ private:
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto > blobs_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<BlobProtoVector> BlobProtoVector_default_instance_;
+
+// -------------------------------------------------------------------
+
+class PermuteParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.PermuteParameter) */ {
+ public:
+ PermuteParameter();
+ virtual ~PermuteParameter();
+
+ PermuteParameter(const PermuteParameter& from);
+
+ inline PermuteParameter& operator=(const PermuteParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const PermuteParameter& default_instance();
+
+ static const PermuteParameter* internal_default_instance();
+
+ void Swap(PermuteParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline PermuteParameter* New() const { return New(NULL); }
+
+ PermuteParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const PermuteParameter& from);
+ void MergeFrom(const PermuteParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(PermuteParameter* other);
+ void UnsafeMergeFrom(const PermuteParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // repeated uint32 order = 1;
+ int order_size() const;
+ void clear_order();
+ static const int kOrderFieldNumber = 1;
+ ::google::protobuf::uint32 order(int index) const;
+ void set_order(int index, ::google::protobuf::uint32 value);
+ void add_order(::google::protobuf::uint32 value);
+ const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+ order() const;
+ ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+ mutable_order();
+
+ // @@protoc_insertion_point(class_scope:caffe.PermuteParameter)
+ private:
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > order_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<PermuteParameter> PermuteParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class NormalizeBBoxParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.NormalizeBBoxParameter) */ {
+ public:
+ NormalizeBBoxParameter();
+ virtual ~NormalizeBBoxParameter();
+
+ NormalizeBBoxParameter(const NormalizeBBoxParameter& from);
+
+ inline NormalizeBBoxParameter& operator=(const NormalizeBBoxParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const NormalizeBBoxParameter& default_instance();
+
+ static const NormalizeBBoxParameter* internal_default_instance();
+
+ void Swap(NormalizeBBoxParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline NormalizeBBoxParameter* New() const { return New(NULL); }
+
+ NormalizeBBoxParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const NormalizeBBoxParameter& from);
+ void MergeFrom(const NormalizeBBoxParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(NormalizeBBoxParameter* other);
+ void UnsafeMergeFrom(const NormalizeBBoxParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional bool across_spatial = 1 [default = true];
+ bool has_across_spatial() const;
+ void clear_across_spatial();
+ static const int kAcrossSpatialFieldNumber = 1;
+ bool across_spatial() const;
+ void set_across_spatial(bool value);
+
+ // optional .caffe.FillerParameter scale_filler = 2;
+ bool has_scale_filler() const;
+ void clear_scale_filler();
+ static const int kScaleFillerFieldNumber = 2;
+ const ::caffe::FillerParameter& scale_filler() const;
+ ::caffe::FillerParameter* mutable_scale_filler();
+ ::caffe::FillerParameter* release_scale_filler();
+ void set_allocated_scale_filler(::caffe::FillerParameter* scale_filler);
+
+ // optional bool channel_shared = 3 [default = true];
+ bool has_channel_shared() const;
+ void clear_channel_shared();
+ static const int kChannelSharedFieldNumber = 3;
+ bool channel_shared() const;
+ void set_channel_shared(bool value);
+
+ // optional float eps = 4 [default = 1e-10];
+ bool has_eps() const;
+ void clear_eps();
+ static const int kEpsFieldNumber = 4;
+ float eps() const;
+ void set_eps(float value);
+
+ // @@protoc_insertion_point(class_scope:caffe.NormalizeBBoxParameter)
+ private:
+ inline void set_has_across_spatial();
+ inline void clear_has_across_spatial();
+ inline void set_has_scale_filler();
+ inline void clear_has_scale_filler();
+ inline void set_has_channel_shared();
+ inline void clear_has_channel_shared();
+ inline void set_has_eps();
+ inline void clear_has_eps();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::caffe::FillerParameter* scale_filler_;
+ bool across_spatial_;
+ bool channel_shared_;
+ float eps_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<NormalizeBBoxParameter> NormalizeBBoxParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class PriorBoxParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.PriorBoxParameter) */ {
+ public:
+ PriorBoxParameter();
+ virtual ~PriorBoxParameter();
+
+ PriorBoxParameter(const PriorBoxParameter& from);
+
+ inline PriorBoxParameter& operator=(const PriorBoxParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const PriorBoxParameter& default_instance();
+
+ static const PriorBoxParameter* internal_default_instance();
+
+ void Swap(PriorBoxParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline PriorBoxParameter* New() const { return New(NULL); }
+
+ PriorBoxParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const PriorBoxParameter& from);
+ void MergeFrom(const PriorBoxParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(PriorBoxParameter* other);
+ void UnsafeMergeFrom(const PriorBoxParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ typedef PriorBoxParameter_CodeType CodeType;
+ static const CodeType CORNER =
+ PriorBoxParameter_CodeType_CORNER;
+ static const CodeType CENTER_SIZE =
+ PriorBoxParameter_CodeType_CENTER_SIZE;
+ static inline bool CodeType_IsValid(int value) {
+ return PriorBoxParameter_CodeType_IsValid(value);
+ }
+ static const CodeType CodeType_MIN =
+ PriorBoxParameter_CodeType_CodeType_MIN;
+ static const CodeType CodeType_MAX =
+ PriorBoxParameter_CodeType_CodeType_MAX;
+ static const int CodeType_ARRAYSIZE =
+ PriorBoxParameter_CodeType_CodeType_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ CodeType_descriptor() {
+ return PriorBoxParameter_CodeType_descriptor();
+ }
+ static inline const ::std::string& CodeType_Name(CodeType value) {
+ return PriorBoxParameter_CodeType_Name(value);
+ }
+ static inline bool CodeType_Parse(const ::std::string& name,
+ CodeType* value) {
+ return PriorBoxParameter_CodeType_Parse(name, value);
+ }
+
+ // accessors -------------------------------------------------------
+
+ // optional float min_size = 1;
+ bool has_min_size() const;
+ void clear_min_size();
+ static const int kMinSizeFieldNumber = 1;
+ float min_size() const;
+ void set_min_size(float value);
+
+ // optional float max_size = 2;
+ bool has_max_size() const;
+ void clear_max_size();
+ static const int kMaxSizeFieldNumber = 2;
+ float max_size() const;
+ void set_max_size(float value);
+
+ // repeated float aspect_ratio = 3;
+ int aspect_ratio_size() const;
+ void clear_aspect_ratio();
+ static const int kAspectRatioFieldNumber = 3;
+ float aspect_ratio(int index) const;
+ void set_aspect_ratio(int index, float value);
+ void add_aspect_ratio(float value);
+ const ::google::protobuf::RepeatedField< float >&
+ aspect_ratio() const;
+ ::google::protobuf::RepeatedField< float >*
+ mutable_aspect_ratio();
+
+ // optional bool flip = 4 [default = true];
+ bool has_flip() const;
+ void clear_flip();
+ static const int kFlipFieldNumber = 4;
+ bool flip() const;
+ void set_flip(bool value);
+
+ // optional bool clip = 5 [default = true];
+ bool has_clip() const;
+ void clear_clip();
+ static const int kClipFieldNumber = 5;
+ bool clip() const;
+ void set_clip(bool value);
+
+ // repeated float variance = 6;
+ int variance_size() const;
+ void clear_variance();
+ static const int kVarianceFieldNumber = 6;
+ float variance(int index) const;
+ void set_variance(int index, float value);
+ void add_variance(float value);
+ const ::google::protobuf::RepeatedField< float >&
+ variance() const;
+ ::google::protobuf::RepeatedField< float >*
+ mutable_variance();
+
+ // optional uint32 img_size = 7;
+ bool has_img_size() const;
+ void clear_img_size();
+ static const int kImgSizeFieldNumber = 7;
+ ::google::protobuf::uint32 img_size() const;
+ void set_img_size(::google::protobuf::uint32 value);
+
+ // optional uint32 img_h = 8;
+ bool has_img_h() const;
+ void clear_img_h();
+ static const int kImgHFieldNumber = 8;
+ ::google::protobuf::uint32 img_h() const;
+ void set_img_h(::google::protobuf::uint32 value);
+
+ // optional uint32 img_w = 9;
+ bool has_img_w() const;
+ void clear_img_w();
+ static const int kImgWFieldNumber = 9;
+ ::google::protobuf::uint32 img_w() const;
+ void set_img_w(::google::protobuf::uint32 value);
+
+ // optional float step = 10;
+ bool has_step() const;
+ void clear_step();
+ static const int kStepFieldNumber = 10;
+ float step() const;
+ void set_step(float value);
+
+ // optional float step_h = 11;
+ bool has_step_h() const;
+ void clear_step_h();
+ static const int kStepHFieldNumber = 11;
+ float step_h() const;
+ void set_step_h(float value);
+
+ // optional float step_w = 12;
+ bool has_step_w() const;
+ void clear_step_w();
+ static const int kStepWFieldNumber = 12;
+ float step_w() const;
+ void set_step_w(float value);
+
+ // optional float offset = 13 [default = 0.5];
+ bool has_offset() const;
+ void clear_offset();
+ static const int kOffsetFieldNumber = 13;
+ float offset() const;
+ void set_offset(float value);
+
+ // @@protoc_insertion_point(class_scope:caffe.PriorBoxParameter)
+ private:
+ inline void set_has_min_size();
+ inline void clear_has_min_size();
+ inline void set_has_max_size();
+ inline void clear_has_max_size();
+ inline void set_has_flip();
+ inline void clear_has_flip();
+ inline void set_has_clip();
+ inline void clear_has_clip();
+ inline void set_has_img_size();
+ inline void clear_has_img_size();
+ inline void set_has_img_h();
+ inline void clear_has_img_h();
+ inline void set_has_img_w();
+ inline void clear_has_img_w();
+ inline void set_has_step();
+ inline void clear_has_step();
+ inline void set_has_step_h();
+ inline void clear_has_step_h();
+ inline void set_has_step_w();
+ inline void clear_has_step_w();
+ inline void set_has_offset();
+ inline void clear_has_offset();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::RepeatedField< float > aspect_ratio_;
+ ::google::protobuf::RepeatedField< float > variance_;
+ float min_size_;
+ float max_size_;
+ ::google::protobuf::uint32 img_size_;
+ ::google::protobuf::uint32 img_h_;
+ ::google::protobuf::uint32 img_w_;
+ float step_;
+ float step_h_;
+ float step_w_;
+ bool flip_;
+ bool clip_;
+ float offset_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<PriorBoxParameter> PriorBoxParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class DetectionOutputParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.DetectionOutputParameter) */ {
+ public:
+ DetectionOutputParameter();
+ virtual ~DetectionOutputParameter();
+
+ DetectionOutputParameter(const DetectionOutputParameter& from);
+
+ inline DetectionOutputParameter& operator=(const DetectionOutputParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const DetectionOutputParameter& default_instance();
+
+ static const DetectionOutputParameter* internal_default_instance();
+
+ void Swap(DetectionOutputParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline DetectionOutputParameter* New() const { return New(NULL); }
+
+ DetectionOutputParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const DetectionOutputParameter& from);
+ void MergeFrom(const DetectionOutputParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(DetectionOutputParameter* other);
+ void UnsafeMergeFrom(const DetectionOutputParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional uint32 num_classes = 1;
+ bool has_num_classes() const;
+ void clear_num_classes();
+ static const int kNumClassesFieldNumber = 1;
+ ::google::protobuf::uint32 num_classes() const;
+ void set_num_classes(::google::protobuf::uint32 value);
+
+ // optional bool share_location = 2 [default = true];
+ bool has_share_location() const;
+ void clear_share_location();
+ static const int kShareLocationFieldNumber = 2;
+ bool share_location() const;
+ void set_share_location(bool value);
+
+ // optional int32 background_label_id = 3 [default = 0];
+ bool has_background_label_id() const;
+ void clear_background_label_id();
+ static const int kBackgroundLabelIdFieldNumber = 3;
+ ::google::protobuf::int32 background_label_id() const;
+ void set_background_label_id(::google::protobuf::int32 value);
+
+ // optional .caffe.NonMaximumSuppressionParameter nms_param = 4;
+ bool has_nms_param() const;
+ void clear_nms_param();
+ static const int kNmsParamFieldNumber = 4;
+ const ::caffe::NonMaximumSuppressionParameter& nms_param() const;
+ ::caffe::NonMaximumSuppressionParameter* mutable_nms_param();
+ ::caffe::NonMaximumSuppressionParameter* release_nms_param();
+ void set_allocated_nms_param(::caffe::NonMaximumSuppressionParameter* nms_param);
+
+ // optional .caffe.SaveOutputParameter save_output_param = 5;
+ bool has_save_output_param() const;
+ void clear_save_output_param();
+ static const int kSaveOutputParamFieldNumber = 5;
+ const ::caffe::SaveOutputParameter& save_output_param() const;
+ ::caffe::SaveOutputParameter* mutable_save_output_param();
+ ::caffe::SaveOutputParameter* release_save_output_param();
+ void set_allocated_save_output_param(::caffe::SaveOutputParameter* save_output_param);
+
+ // optional .caffe.PriorBoxParameter.CodeType code_type = 6 [default = CORNER];
+ bool has_code_type() const;
+ void clear_code_type();
+ static const int kCodeTypeFieldNumber = 6;
+ ::caffe::PriorBoxParameter_CodeType code_type() const;
+ void set_code_type(::caffe::PriorBoxParameter_CodeType value);
+
+ // optional bool variance_encoded_in_target = 8 [default = false];
+ bool has_variance_encoded_in_target() const;
+ void clear_variance_encoded_in_target();
+ static const int kVarianceEncodedInTargetFieldNumber = 8;
+ bool variance_encoded_in_target() const;
+ void set_variance_encoded_in_target(bool value);
+
+ // optional int32 keep_top_k = 7 [default = -1];
+ bool has_keep_top_k() const;
+ void clear_keep_top_k();
+ static const int kKeepTopKFieldNumber = 7;
+ ::google::protobuf::int32 keep_top_k() const;
+ void set_keep_top_k(::google::protobuf::int32 value);
+
+ // optional float confidence_threshold = 9;
+ bool has_confidence_threshold() const;
+ void clear_confidence_threshold();
+ static const int kConfidenceThresholdFieldNumber = 9;
+ float confidence_threshold() const;
+ void set_confidence_threshold(float value);
+
+ // @@protoc_insertion_point(class_scope:caffe.DetectionOutputParameter)
+ private:
+ inline void set_has_num_classes();
+ inline void clear_has_num_classes();
+ inline void set_has_share_location();
+ inline void clear_has_share_location();
+ inline void set_has_background_label_id();
+ inline void clear_has_background_label_id();
+ inline void set_has_nms_param();
+ inline void clear_has_nms_param();
+ inline void set_has_save_output_param();
+ inline void clear_has_save_output_param();
+ inline void set_has_code_type();
+ inline void clear_has_code_type();
+ inline void set_has_variance_encoded_in_target();
+ inline void clear_has_variance_encoded_in_target();
+ inline void set_has_keep_top_k();
+ inline void clear_has_keep_top_k();
+ inline void set_has_confidence_threshold();
+ inline void clear_has_confidence_threshold();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::caffe::NonMaximumSuppressionParameter* nms_param_;
+ ::caffe::SaveOutputParameter* save_output_param_;
+ ::google::protobuf::uint32 num_classes_;
+ ::google::protobuf::int32 background_label_id_;
+ bool variance_encoded_in_target_;
+ float confidence_threshold_;
+ ::google::protobuf::int32 keep_top_k_;
+ bool share_location_;
+ int code_type_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<DetectionOutputParameter> DetectionOutputParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class Datum : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.Datum) */ {
+ public:
+ Datum();
+ virtual ~Datum();
+
+ Datum(const Datum& from);
+
+ inline Datum& operator=(const Datum& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const Datum& default_instance();
+
+ static const Datum* internal_default_instance();
+
+ void Swap(Datum* other);
+
+ // implements Message ----------------------------------------------
+
+ inline Datum* New() const { return New(NULL); }
+
+ Datum* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const Datum& from);
+ void MergeFrom(const Datum& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(Datum* other);
+ void UnsafeMergeFrom(const Datum& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional int32 channels = 1;
+ bool has_channels() const;
+ void clear_channels();
+ static const int kChannelsFieldNumber = 1;
+ ::google::protobuf::int32 channels() const;
+ void set_channels(::google::protobuf::int32 value);
+
+ // optional int32 height = 2;
+ bool has_height() const;
+ void clear_height();
+ static const int kHeightFieldNumber = 2;
+ ::google::protobuf::int32 height() const;
+ void set_height(::google::protobuf::int32 value);
+
+ // optional int32 width = 3;
+ bool has_width() const;
+ void clear_width();
+ static const int kWidthFieldNumber = 3;
+ ::google::protobuf::int32 width() const;
+ void set_width(::google::protobuf::int32 value);
+
+ // optional bytes data = 4;
+ bool has_data() const;
+ void clear_data();
+ static const int kDataFieldNumber = 4;
+ const ::std::string& data() const;
+ void set_data(const ::std::string& value);
+ void set_data(const char* value);
+ void set_data(const void* value, size_t size);
+ ::std::string* mutable_data();
+ ::std::string* release_data();
+ void set_allocated_data(::std::string* data);
+
+ // optional int32 label = 5;
+ bool has_label() const;
+ void clear_label();
+ static const int kLabelFieldNumber = 5;
+ ::google::protobuf::int32 label() const;
+ void set_label(::google::protobuf::int32 value);
+
+ // repeated float float_data = 6;
+ int float_data_size() const;
+ void clear_float_data();
+ static const int kFloatDataFieldNumber = 6;
+ float float_data(int index) const;
+ void set_float_data(int index, float value);
+ void add_float_data(float value);
+ const ::google::protobuf::RepeatedField< float >&
+ float_data() const;
+ ::google::protobuf::RepeatedField< float >*
+ mutable_float_data();
+
+ // optional bool encoded = 7 [default = false];
+ bool has_encoded() const;
+ void clear_encoded();
+ static const int kEncodedFieldNumber = 7;
+ bool encoded() const;
+ void set_encoded(bool value);
+
+ // @@protoc_insertion_point(class_scope:caffe.Datum)
+ private:
+ inline void set_has_channels();
+ inline void clear_has_channels();
+ inline void set_has_height();
+ inline void clear_has_height();
+ inline void set_has_width();
+ inline void clear_has_width();
+ inline void set_has_data();
+ inline void clear_has_data();
+ inline void set_has_label();
+ inline void clear_has_label();
+ inline void set_has_encoded();
+ inline void clear_has_encoded();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::RepeatedField< float > float_data_;
+ ::google::protobuf::internal::ArenaStringPtr data_;
+ ::google::protobuf::int32 channels_;
+ ::google::protobuf::int32 height_;
+ ::google::protobuf::int32 width_;
+ ::google::protobuf::int32 label_;
+ bool encoded_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<Datum> Datum_default_instance_;
+
+// -------------------------------------------------------------------
+
+class FillerParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.FillerParameter) */ {
+ public:
+ FillerParameter();
+ virtual ~FillerParameter();
+
+ FillerParameter(const FillerParameter& from);
+
+ inline FillerParameter& operator=(const FillerParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const FillerParameter& default_instance();
+
+ static const FillerParameter* internal_default_instance();
+
+ void Swap(FillerParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline FillerParameter* New() const { return New(NULL); }
+
+ FillerParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const FillerParameter& from);
+ void MergeFrom(const FillerParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(FillerParameter* other);
+ void UnsafeMergeFrom(const FillerParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ typedef FillerParameter_VarianceNorm VarianceNorm;
+ static const VarianceNorm FAN_IN =
+ FillerParameter_VarianceNorm_FAN_IN;
+ static const VarianceNorm FAN_OUT =
+ FillerParameter_VarianceNorm_FAN_OUT;
+ static const VarianceNorm AVERAGE =
+ FillerParameter_VarianceNorm_AVERAGE;
+ static inline bool VarianceNorm_IsValid(int value) {
+ return FillerParameter_VarianceNorm_IsValid(value);
+ }
+ static const VarianceNorm VarianceNorm_MIN =
+ FillerParameter_VarianceNorm_VarianceNorm_MIN;
+ static const VarianceNorm VarianceNorm_MAX =
+ FillerParameter_VarianceNorm_VarianceNorm_MAX;
+ static const int VarianceNorm_ARRAYSIZE =
+ FillerParameter_VarianceNorm_VarianceNorm_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ VarianceNorm_descriptor() {
+ return FillerParameter_VarianceNorm_descriptor();
+ }
+ static inline const ::std::string& VarianceNorm_Name(VarianceNorm value) {
+ return FillerParameter_VarianceNorm_Name(value);
+ }
+ static inline bool VarianceNorm_Parse(const ::std::string& name,
+ VarianceNorm* value) {
+ return FillerParameter_VarianceNorm_Parse(name, value);
+ }
+
+ // accessors -------------------------------------------------------
+
+ // optional string type = 1 [default = "constant"];
+ bool has_type() const;
+ void clear_type();
+ static const int kTypeFieldNumber = 1;
+ const ::std::string& type() const;
+ void set_type(const ::std::string& value);
+ void set_type(const char* value);
+ void set_type(const char* value, size_t size);
+ ::std::string* mutable_type();
+ ::std::string* release_type();
+ void set_allocated_type(::std::string* type);
+
+ // optional float value = 2 [default = 0];
+ bool has_value() const;
+ void clear_value();
+ static const int kValueFieldNumber = 2;
+ float value() const;
+ void set_value(float value);
+
+ // optional float min = 3 [default = 0];
+ bool has_min() const;
+ void clear_min();
+ static const int kMinFieldNumber = 3;
+ float min() const;
+ void set_min(float value);
+
+ // optional float max = 4 [default = 1];
+ bool has_max() const;
+ void clear_max();
+ static const int kMaxFieldNumber = 4;
+ float max() const;
+ void set_max(float value);
+
+ // optional float mean = 5 [default = 0];
+ bool has_mean() const;
+ void clear_mean();
+ static const int kMeanFieldNumber = 5;
+ float mean() const;
+ void set_mean(float value);
+
+ // optional float std = 6 [default = 1];
+ bool has_std() const;
+ void clear_std();
+ static const int kStdFieldNumber = 6;
+ float std() const;
+ void set_std(float value);
+
+ // optional int32 sparse = 7 [default = -1];
+ bool has_sparse() const;
+ void clear_sparse();
+ static const int kSparseFieldNumber = 7;
+ ::google::protobuf::int32 sparse() const;
+ void set_sparse(::google::protobuf::int32 value);
+
+ // optional .caffe.FillerParameter.VarianceNorm variance_norm = 8 [default = FAN_IN];
+ bool has_variance_norm() const;
+ void clear_variance_norm();
+ static const int kVarianceNormFieldNumber = 8;
+ ::caffe::FillerParameter_VarianceNorm variance_norm() const;
+ void set_variance_norm(::caffe::FillerParameter_VarianceNorm value);
+
+ // @@protoc_insertion_point(class_scope:caffe.FillerParameter)
+ private:
+ inline void set_has_type();
+ inline void clear_has_type();
+ inline void set_has_value();
+ inline void clear_has_value();
+ inline void set_has_min();
+ inline void clear_has_min();
+ inline void set_has_max();
+ inline void clear_has_max();
+ inline void set_has_mean();
+ inline void clear_has_mean();
+ inline void set_has_std();
+ inline void clear_has_std();
+ inline void set_has_sparse();
+ inline void clear_has_sparse();
+ inline void set_has_variance_norm();
+ inline void clear_has_variance_norm();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ static ::std::string* _default_type_;
+ ::google::protobuf::internal::ArenaStringPtr type_;
+ float value_;
+ float min_;
+ float mean_;
+ int variance_norm_;
+ ::google::protobuf::int32 sparse_;
+ float max_;
+ float std_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<FillerParameter> FillerParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class NetParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.NetParameter) */ {
+ public:
+ NetParameter();
+ virtual ~NetParameter();
+
+ NetParameter(const NetParameter& from);
+
+ inline NetParameter& operator=(const NetParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const NetParameter& default_instance();
+
+ static const NetParameter* internal_default_instance();
+
+ void Swap(NetParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline NetParameter* New() const { return New(NULL); }
+
+ NetParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const NetParameter& from);
+ void MergeFrom(const NetParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(NetParameter* other);
+ void UnsafeMergeFrom(const NetParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional string name = 1;
+ bool has_name() const;
+ void clear_name();
+ static const int kNameFieldNumber = 1;
+ const ::std::string& name() const;
+ void set_name(const ::std::string& value);
+ void set_name(const char* value);
+ void set_name(const char* value, size_t size);
+ ::std::string* mutable_name();
+ ::std::string* release_name();
+ void set_allocated_name(::std::string* name);
+
+ // repeated string input = 3;
+ int input_size() const;
+ void clear_input();
+ static const int kInputFieldNumber = 3;
+ const ::std::string& input(int index) const;
+ ::std::string* mutable_input(int index);
+ void set_input(int index, const ::std::string& value);
+ void set_input(int index, const char* value);
+ void set_input(int index, const char* value, size_t size);
+ ::std::string* add_input();
+ void add_input(const ::std::string& value);
+ void add_input(const char* value);
+ void add_input(const char* value, size_t size);
+ const ::google::protobuf::RepeatedPtrField< ::std::string>& input() const;
+ ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_input();
+
+ // repeated .caffe.BlobShape input_shape = 8;
+ int input_shape_size() const;
+ void clear_input_shape();
+ static const int kInputShapeFieldNumber = 8;
+ const ::caffe::BlobShape& input_shape(int index) const;
+ ::caffe::BlobShape* mutable_input_shape(int index);
+ ::caffe::BlobShape* add_input_shape();
+ ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >*
+ mutable_input_shape();
+ const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >&
+ input_shape() const;
+
+ // repeated int32 input_dim = 4;
+ int input_dim_size() const;
+ void clear_input_dim();
+ static const int kInputDimFieldNumber = 4;
+ ::google::protobuf::int32 input_dim(int index) const;
+ void set_input_dim(int index, ::google::protobuf::int32 value);
+ void add_input_dim(::google::protobuf::int32 value);
+ const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
+ input_dim() const;
+ ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
+ mutable_input_dim();
+
+ // optional bool force_backward = 5 [default = false];
+ bool has_force_backward() const;
+ void clear_force_backward();
+ static const int kForceBackwardFieldNumber = 5;
+ bool force_backward() const;
+ void set_force_backward(bool value);
+
+ // optional .caffe.NetState state = 6;
+ bool has_state() const;
+ void clear_state();
+ static const int kStateFieldNumber = 6;
+ const ::caffe::NetState& state() const;
+ ::caffe::NetState* mutable_state();
+ ::caffe::NetState* release_state();
+ void set_allocated_state(::caffe::NetState* state);
+
+ // optional bool debug_info = 7 [default = false];
+ bool has_debug_info() const;
+ void clear_debug_info();
+ static const int kDebugInfoFieldNumber = 7;
+ bool debug_info() const;
+ void set_debug_info(bool value);
+
+ // repeated .caffe.LayerParameter layer = 100;
+ int layer_size() const;
+ void clear_layer();
+ static const int kLayerFieldNumber = 100;
+ const ::caffe::LayerParameter& layer(int index) const;
+ ::caffe::LayerParameter* mutable_layer(int index);
+ ::caffe::LayerParameter* add_layer();
+ ::google::protobuf::RepeatedPtrField< ::caffe::LayerParameter >*
+ mutable_layer();
+ const ::google::protobuf::RepeatedPtrField< ::caffe::LayerParameter >&
+ layer() const;
+
+ // repeated .caffe.V1LayerParameter layers = 2;
+ int layers_size() const;
+ void clear_layers();
+ static const int kLayersFieldNumber = 2;
+ const ::caffe::V1LayerParameter& layers(int index) const;
+ ::caffe::V1LayerParameter* mutable_layers(int index);
+ ::caffe::V1LayerParameter* add_layers();
+ ::google::protobuf::RepeatedPtrField< ::caffe::V1LayerParameter >*
+ mutable_layers();
+ const ::google::protobuf::RepeatedPtrField< ::caffe::V1LayerParameter >&
+ layers() const;
+
+ // @@protoc_insertion_point(class_scope:caffe.NetParameter)
+ private:
+ inline void set_has_name();
+ inline void clear_has_name();
+ inline void set_has_force_backward();
+ inline void clear_has_force_backward();
+ inline void set_has_state();
+ inline void clear_has_state();
+ inline void set_has_debug_info();
+ inline void clear_has_debug_info();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::RepeatedPtrField< ::std::string> input_;
+ ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape > input_shape_;
+ ::google::protobuf::RepeatedField< ::google::protobuf::int32 > input_dim_;
+ ::google::protobuf::RepeatedPtrField< ::caffe::LayerParameter > layer_;
+ ::google::protobuf::RepeatedPtrField< ::caffe::V1LayerParameter > layers_;
+ ::google::protobuf::internal::ArenaStringPtr name_;
+ ::caffe::NetState* state_;
+ bool force_backward_;
+ bool debug_info_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<NetParameter> NetParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class SolverParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.SolverParameter) */ {
+ public:
+ SolverParameter();
+ virtual ~SolverParameter();
+
+ SolverParameter(const SolverParameter& from);
+
+ inline SolverParameter& operator=(const SolverParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const SolverParameter& default_instance();
+
+ static const SolverParameter* internal_default_instance();
+
+ void Swap(SolverParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline SolverParameter* New() const { return New(NULL); }
+
+ SolverParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const SolverParameter& from);
+ void MergeFrom(const SolverParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(SolverParameter* other);
+ void UnsafeMergeFrom(const SolverParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ typedef SolverParameter_SnapshotFormat SnapshotFormat;
+ static const SnapshotFormat HDF5 =
+ SolverParameter_SnapshotFormat_HDF5;
+ static const SnapshotFormat BINARYPROTO =
+ SolverParameter_SnapshotFormat_BINARYPROTO;
+ static inline bool SnapshotFormat_IsValid(int value) {
+ return SolverParameter_SnapshotFormat_IsValid(value);
+ }
+ static const SnapshotFormat SnapshotFormat_MIN =
+ SolverParameter_SnapshotFormat_SnapshotFormat_MIN;
+ static const SnapshotFormat SnapshotFormat_MAX =
+ SolverParameter_SnapshotFormat_SnapshotFormat_MAX;
+ static const int SnapshotFormat_ARRAYSIZE =
+ SolverParameter_SnapshotFormat_SnapshotFormat_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ SnapshotFormat_descriptor() {
+ return SolverParameter_SnapshotFormat_descriptor();
+ }
+ static inline const ::std::string& SnapshotFormat_Name(SnapshotFormat value) {
+ return SolverParameter_SnapshotFormat_Name(value);
+ }
+ static inline bool SnapshotFormat_Parse(const ::std::string& name,
+ SnapshotFormat* value) {
+ return SolverParameter_SnapshotFormat_Parse(name, value);
+ }
+
+ typedef SolverParameter_SolverMode SolverMode;
+ static const SolverMode CPU =
+ SolverParameter_SolverMode_CPU;
+ static const SolverMode GPU =
+ SolverParameter_SolverMode_GPU;
+ static inline bool SolverMode_IsValid(int value) {
+ return SolverParameter_SolverMode_IsValid(value);
+ }
+ static const SolverMode SolverMode_MIN =
+ SolverParameter_SolverMode_SolverMode_MIN;
+ static const SolverMode SolverMode_MAX =
+ SolverParameter_SolverMode_SolverMode_MAX;
+ static const int SolverMode_ARRAYSIZE =
+ SolverParameter_SolverMode_SolverMode_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ SolverMode_descriptor() {
+ return SolverParameter_SolverMode_descriptor();
+ }
+ static inline const ::std::string& SolverMode_Name(SolverMode value) {
+ return SolverParameter_SolverMode_Name(value);
+ }
+ static inline bool SolverMode_Parse(const ::std::string& name,
+ SolverMode* value) {
+ return SolverParameter_SolverMode_Parse(name, value);
+ }
+
+ typedef SolverParameter_SolverType SolverType;
+ static const SolverType SGD =
+ SolverParameter_SolverType_SGD;
+ static const SolverType NESTEROV =
+ SolverParameter_SolverType_NESTEROV;
+ static const SolverType ADAGRAD =
+ SolverParameter_SolverType_ADAGRAD;
+ static const SolverType RMSPROP =
+ SolverParameter_SolverType_RMSPROP;
+ static const SolverType ADADELTA =
+ SolverParameter_SolverType_ADADELTA;
+ static const SolverType ADAM =
+ SolverParameter_SolverType_ADAM;
+ static inline bool SolverType_IsValid(int value) {
+ return SolverParameter_SolverType_IsValid(value);
+ }
+ static const SolverType SolverType_MIN =
+ SolverParameter_SolverType_SolverType_MIN;
+ static const SolverType SolverType_MAX =
+ SolverParameter_SolverType_SolverType_MAX;
+ static const int SolverType_ARRAYSIZE =
+ SolverParameter_SolverType_SolverType_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ SolverType_descriptor() {
+ return SolverParameter_SolverType_descriptor();
+ }
+ static inline const ::std::string& SolverType_Name(SolverType value) {
+ return SolverParameter_SolverType_Name(value);
+ }
+ static inline bool SolverType_Parse(const ::std::string& name,
+ SolverType* value) {
+ return SolverParameter_SolverType_Parse(name, value);
+ }
+
+ // accessors -------------------------------------------------------
+
+ // optional string net = 24;
+ bool has_net() const;
+ void clear_net();
+ static const int kNetFieldNumber = 24;
+ const ::std::string& net() const;
+ void set_net(const ::std::string& value);
+ void set_net(const char* value);
+ void set_net(const char* value, size_t size);
+ ::std::string* mutable_net();
+ ::std::string* release_net();
+ void set_allocated_net(::std::string* net);
+
+ // optional .caffe.NetParameter net_param = 25;
+ bool has_net_param() const;
+ void clear_net_param();
+ static const int kNetParamFieldNumber = 25;
+ const ::caffe::NetParameter& net_param() const;
+ ::caffe::NetParameter* mutable_net_param();
+ ::caffe::NetParameter* release_net_param();
+ void set_allocated_net_param(::caffe::NetParameter* net_param);
+
+ // optional string train_net = 1;
+ bool has_train_net() const;
+ void clear_train_net();
+ static const int kTrainNetFieldNumber = 1;
+ const ::std::string& train_net() const;
+ void set_train_net(const ::std::string& value);
+ void set_train_net(const char* value);
+ void set_train_net(const char* value, size_t size);
+ ::std::string* mutable_train_net();
+ ::std::string* release_train_net();
+ void set_allocated_train_net(::std::string* train_net);
+
+ // repeated string test_net = 2;
+ int test_net_size() const;
+ void clear_test_net();
+ static const int kTestNetFieldNumber = 2;
+ const ::std::string& test_net(int index) const;
+ ::std::string* mutable_test_net(int index);
+ void set_test_net(int index, const ::std::string& value);
+ void set_test_net(int index, const char* value);
+ void set_test_net(int index, const char* value, size_t size);
+ ::std::string* add_test_net();
+ void add_test_net(const ::std::string& value);
+ void add_test_net(const char* value);
+ void add_test_net(const char* value, size_t size);
+ const ::google::protobuf::RepeatedPtrField< ::std::string>& test_net() const;
+ ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_test_net();
+
+ // optional .caffe.NetParameter train_net_param = 21;
+ bool has_train_net_param() const;
+ void clear_train_net_param();
+ static const int kTrainNetParamFieldNumber = 21;
+ const ::caffe::NetParameter& train_net_param() const;
+ ::caffe::NetParameter* mutable_train_net_param();
+ ::caffe::NetParameter* release_train_net_param();
+ void set_allocated_train_net_param(::caffe::NetParameter* train_net_param);
+
+ // repeated .caffe.NetParameter test_net_param = 22;
+ int test_net_param_size() const;
+ void clear_test_net_param();
+ static const int kTestNetParamFieldNumber = 22;
+ const ::caffe::NetParameter& test_net_param(int index) const;
+ ::caffe::NetParameter* mutable_test_net_param(int index);
+ ::caffe::NetParameter* add_test_net_param();
+ ::google::protobuf::RepeatedPtrField< ::caffe::NetParameter >*
+ mutable_test_net_param();
+ const ::google::protobuf::RepeatedPtrField< ::caffe::NetParameter >&
+ test_net_param() const;
+
+ // optional .caffe.NetState train_state = 26;
+ bool has_train_state() const;
+ void clear_train_state();
+ static const int kTrainStateFieldNumber = 26;
+ const ::caffe::NetState& train_state() const;
+ ::caffe::NetState* mutable_train_state();
+ ::caffe::NetState* release_train_state();
+ void set_allocated_train_state(::caffe::NetState* train_state);
+
+ // repeated .caffe.NetState test_state = 27;
+ int test_state_size() const;
+ void clear_test_state();
+ static const int kTestStateFieldNumber = 27;
+ const ::caffe::NetState& test_state(int index) const;
+ ::caffe::NetState* mutable_test_state(int index);
+ ::caffe::NetState* add_test_state();
+ ::google::protobuf::RepeatedPtrField< ::caffe::NetState >*
+ mutable_test_state();
+ const ::google::protobuf::RepeatedPtrField< ::caffe::NetState >&
+ test_state() const;
+
+ // repeated int32 test_iter = 3;
+ int test_iter_size() const;
+ void clear_test_iter();
+ static const int kTestIterFieldNumber = 3;
+ ::google::protobuf::int32 test_iter(int index) const;
+ void set_test_iter(int index, ::google::protobuf::int32 value);
+ void add_test_iter(::google::protobuf::int32 value);
+ const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
+ test_iter() const;
+ ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
+ mutable_test_iter();
+
+ // optional int32 test_interval = 4 [default = 0];
+ bool has_test_interval() const;
+ void clear_test_interval();
+ static const int kTestIntervalFieldNumber = 4;
+ ::google::protobuf::int32 test_interval() const;
+ void set_test_interval(::google::protobuf::int32 value);
+
+ // optional bool test_compute_loss = 19 [default = false];
+ bool has_test_compute_loss() const;
+ void clear_test_compute_loss();
+ static const int kTestComputeLossFieldNumber = 19;
+ bool test_compute_loss() const;
+ void set_test_compute_loss(bool value);
+
+ // optional bool test_initialization = 32 [default = true];
+ bool has_test_initialization() const;
+ void clear_test_initialization();
+ static const int kTestInitializationFieldNumber = 32;
+ bool test_initialization() const;
+ void set_test_initialization(bool value);
+
+ // optional float base_lr = 5;
+ bool has_base_lr() const;
+ void clear_base_lr();
+ static const int kBaseLrFieldNumber = 5;
+ float base_lr() const;
+ void set_base_lr(float value);
+
+ // optional int32 display = 6;
+ bool has_display() const;
+ void clear_display();
+ static const int kDisplayFieldNumber = 6;
+ ::google::protobuf::int32 display() const;
+ void set_display(::google::protobuf::int32 value);
+
+ // optional int32 average_loss = 33 [default = 1];
+ bool has_average_loss() const;
+ void clear_average_loss();
+ static const int kAverageLossFieldNumber = 33;
+ ::google::protobuf::int32 average_loss() const;
+ void set_average_loss(::google::protobuf::int32 value);
+
+ // optional int32 max_iter = 7;
+ bool has_max_iter() const;
+ void clear_max_iter();
+ static const int kMaxIterFieldNumber = 7;
+ ::google::protobuf::int32 max_iter() const;
+ void set_max_iter(::google::protobuf::int32 value);
+
+ // optional int32 iter_size = 36 [default = 1];
+ bool has_iter_size() const;
+ void clear_iter_size();
+ static const int kIterSizeFieldNumber = 36;
+ ::google::protobuf::int32 iter_size() const;
+ void set_iter_size(::google::protobuf::int32 value);
+
+ // optional string lr_policy = 8;
+ bool has_lr_policy() const;
+ void clear_lr_policy();
+ static const int kLrPolicyFieldNumber = 8;
+ const ::std::string& lr_policy() const;
+ void set_lr_policy(const ::std::string& value);
+ void set_lr_policy(const char* value);
+ void set_lr_policy(const char* value, size_t size);
+ ::std::string* mutable_lr_policy();
+ ::std::string* release_lr_policy();
+ void set_allocated_lr_policy(::std::string* lr_policy);
+
+ // optional float gamma = 9;
+ bool has_gamma() const;
+ void clear_gamma();
+ static const int kGammaFieldNumber = 9;
+ float gamma() const;
+ void set_gamma(float value);
+
+ // optional float power = 10;
+ bool has_power() const;
+ void clear_power();
+ static const int kPowerFieldNumber = 10;
+ float power() const;
+ void set_power(float value);
+
+ // optional float momentum = 11;
+ bool has_momentum() const;
+ void clear_momentum();
+ static const int kMomentumFieldNumber = 11;
+ float momentum() const;
+ void set_momentum(float value);
+
+ // optional float weight_decay = 12;
+ bool has_weight_decay() const;
+ void clear_weight_decay();
+ static const int kWeightDecayFieldNumber = 12;
+ float weight_decay() const;
+ void set_weight_decay(float value);
+
+ // optional string regularization_type = 29 [default = "L2"];
+ bool has_regularization_type() const;
+ void clear_regularization_type();
+ static const int kRegularizationTypeFieldNumber = 29;
+ const ::std::string& regularization_type() const;
+ void set_regularization_type(const ::std::string& value);
+ void set_regularization_type(const char* value);
+ void set_regularization_type(const char* value, size_t size);
+ ::std::string* mutable_regularization_type();
+ ::std::string* release_regularization_type();
+ void set_allocated_regularization_type(::std::string* regularization_type);
+
+ // optional int32 stepsize = 13;
+ bool has_stepsize() const;
+ void clear_stepsize();
+ static const int kStepsizeFieldNumber = 13;
+ ::google::protobuf::int32 stepsize() const;
+ void set_stepsize(::google::protobuf::int32 value);
+
+ // repeated int32 stepvalue = 34;
+ int stepvalue_size() const;
+ void clear_stepvalue();
+ static const int kStepvalueFieldNumber = 34;
+ ::google::protobuf::int32 stepvalue(int index) const;
+ void set_stepvalue(int index, ::google::protobuf::int32 value);
+ void add_stepvalue(::google::protobuf::int32 value);
+ const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
+ stepvalue() const;
+ ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
+ mutable_stepvalue();
+
+ // optional float clip_gradients = 35 [default = -1];
+ bool has_clip_gradients() const;
+ void clear_clip_gradients();
+ static const int kClipGradientsFieldNumber = 35;
+ float clip_gradients() const;
+ void set_clip_gradients(float value);
+
+ // optional int32 snapshot = 14 [default = 0];
+ bool has_snapshot() const;
+ void clear_snapshot();
+ static const int kSnapshotFieldNumber = 14;
+ ::google::protobuf::int32 snapshot() const;
+ void set_snapshot(::google::protobuf::int32 value);
+
+ // optional string snapshot_prefix = 15;
+ bool has_snapshot_prefix() const;
+ void clear_snapshot_prefix();
+ static const int kSnapshotPrefixFieldNumber = 15;
+ const ::std::string& snapshot_prefix() const;
+ void set_snapshot_prefix(const ::std::string& value);
+ void set_snapshot_prefix(const char* value);
+ void set_snapshot_prefix(const char* value, size_t size);
+ ::std::string* mutable_snapshot_prefix();
+ ::std::string* release_snapshot_prefix();
+ void set_allocated_snapshot_prefix(::std::string* snapshot_prefix);
+
+ // optional bool snapshot_diff = 16 [default = false];
+ bool has_snapshot_diff() const;
+ void clear_snapshot_diff();
+ static const int kSnapshotDiffFieldNumber = 16;
+ bool snapshot_diff() const;
+ void set_snapshot_diff(bool value);
+
+ // optional .caffe.SolverParameter.SnapshotFormat snapshot_format = 37 [default = BINARYPROTO];
+ bool has_snapshot_format() const;
+ void clear_snapshot_format();
+ static const int kSnapshotFormatFieldNumber = 37;
+ ::caffe::SolverParameter_SnapshotFormat snapshot_format() const;
+ void set_snapshot_format(::caffe::SolverParameter_SnapshotFormat value);
+
+ // optional .caffe.SolverParameter.SolverMode solver_mode = 17 [default = GPU];
+ bool has_solver_mode() const;
+ void clear_solver_mode();
+ static const int kSolverModeFieldNumber = 17;
+ ::caffe::SolverParameter_SolverMode solver_mode() const;
+ void set_solver_mode(::caffe::SolverParameter_SolverMode value);
+
+ // optional int32 device_id = 18 [default = 0];
+ bool has_device_id() const;
+ void clear_device_id();
+ static const int kDeviceIdFieldNumber = 18;
+ ::google::protobuf::int32 device_id() const;
+ void set_device_id(::google::protobuf::int32 value);
+
+ // optional int64 random_seed = 20 [default = -1];
+ bool has_random_seed() const;
+ void clear_random_seed();
+ static const int kRandomSeedFieldNumber = 20;
+ ::google::protobuf::int64 random_seed() const;
+ void set_random_seed(::google::protobuf::int64 value);
+
+ // optional string type = 40 [default = "SGD"];
+ bool has_type() const;
+ void clear_type();
+ static const int kTypeFieldNumber = 40;
+ const ::std::string& type() const;
+ void set_type(const ::std::string& value);
+ void set_type(const char* value);
+ void set_type(const char* value, size_t size);
+ ::std::string* mutable_type();
+ ::std::string* release_type();
+ void set_allocated_type(::std::string* type);
+
+ // optional float delta = 31 [default = 1e-08];
+ bool has_delta() const;
+ void clear_delta();
+ static const int kDeltaFieldNumber = 31;
+ float delta() const;
+ void set_delta(float value);
+
+ // optional float momentum2 = 39 [default = 0.999];
+ bool has_momentum2() const;
+ void clear_momentum2();
+ static const int kMomentum2FieldNumber = 39;
+ float momentum2() const;
+ void set_momentum2(float value);
+
+ // optional float rms_decay = 38 [default = 0.99];
+ bool has_rms_decay() const;
+ void clear_rms_decay();
+ static const int kRmsDecayFieldNumber = 38;
+ float rms_decay() const;
+ void set_rms_decay(float value);
+
+ // optional bool debug_info = 23 [default = false];
+ bool has_debug_info() const;
+ void clear_debug_info();
+ static const int kDebugInfoFieldNumber = 23;
+ bool debug_info() const;
+ void set_debug_info(bool value);
+
+ // optional bool snapshot_after_train = 28 [default = true];
+ bool has_snapshot_after_train() const;
+ void clear_snapshot_after_train();
+ static const int kSnapshotAfterTrainFieldNumber = 28;
+ bool snapshot_after_train() const;
+ void set_snapshot_after_train(bool value);
+
+ // optional .caffe.SolverParameter.SolverType solver_type = 30 [default = SGD];
+ bool has_solver_type() const;
+ void clear_solver_type();
+ static const int kSolverTypeFieldNumber = 30;
+ ::caffe::SolverParameter_SolverType solver_type() const;
+ void set_solver_type(::caffe::SolverParameter_SolverType value);
+
+ // @@protoc_insertion_point(class_scope:caffe.SolverParameter)
+ private:
+ inline void set_has_net();
+ inline void clear_has_net();
+ inline void set_has_net_param();
+ inline void clear_has_net_param();
+ inline void set_has_train_net();
+ inline void clear_has_train_net();
+ inline void set_has_train_net_param();
+ inline void clear_has_train_net_param();
+ inline void set_has_train_state();
+ inline void clear_has_train_state();
+ inline void set_has_test_interval();
+ inline void clear_has_test_interval();
+ inline void set_has_test_compute_loss();
+ inline void clear_has_test_compute_loss();
+ inline void set_has_test_initialization();
+ inline void clear_has_test_initialization();
+ inline void set_has_base_lr();
+ inline void clear_has_base_lr();
+ inline void set_has_display();
+ inline void clear_has_display();
+ inline void set_has_average_loss();
+ inline void clear_has_average_loss();
+ inline void set_has_max_iter();
+ inline void clear_has_max_iter();
+ inline void set_has_iter_size();
+ inline void clear_has_iter_size();
+ inline void set_has_lr_policy();
+ inline void clear_has_lr_policy();
+ inline void set_has_gamma();
+ inline void clear_has_gamma();
+ inline void set_has_power();
+ inline void clear_has_power();
+ inline void set_has_momentum();
+ inline void clear_has_momentum();
+ inline void set_has_weight_decay();
+ inline void clear_has_weight_decay();
+ inline void set_has_regularization_type();
+ inline void clear_has_regularization_type();
+ inline void set_has_stepsize();
+ inline void clear_has_stepsize();
+ inline void set_has_clip_gradients();
+ inline void clear_has_clip_gradients();
+ inline void set_has_snapshot();
+ inline void clear_has_snapshot();
+ inline void set_has_snapshot_prefix();
+ inline void clear_has_snapshot_prefix();
+ inline void set_has_snapshot_diff();
+ inline void clear_has_snapshot_diff();
+ inline void set_has_snapshot_format();
+ inline void clear_has_snapshot_format();
+ inline void set_has_solver_mode();
+ inline void clear_has_solver_mode();
+ inline void set_has_device_id();
+ inline void clear_has_device_id();
+ inline void set_has_random_seed();
+ inline void clear_has_random_seed();
+ inline void set_has_type();
+ inline void clear_has_type();
+ inline void set_has_delta();
+ inline void clear_has_delta();
+ inline void set_has_momentum2();
+ inline void clear_has_momentum2();
+ inline void set_has_rms_decay();
+ inline void clear_has_rms_decay();
+ inline void set_has_debug_info();
+ inline void clear_has_debug_info();
+ inline void set_has_snapshot_after_train();
+ inline void clear_has_snapshot_after_train();
+ inline void set_has_solver_type();
+ inline void clear_has_solver_type();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<2> _has_bits_;
+ ::google::protobuf::RepeatedPtrField< ::std::string> test_net_;
+ ::google::protobuf::RepeatedPtrField< ::caffe::NetParameter > test_net_param_;
+ ::google::protobuf::RepeatedPtrField< ::caffe::NetState > test_state_;
+ ::google::protobuf::RepeatedField< ::google::protobuf::int32 > test_iter_;
+ ::google::protobuf::RepeatedField< ::google::protobuf::int32 > stepvalue_;
+ ::google::protobuf::internal::ArenaStringPtr net_;
+ ::google::protobuf::internal::ArenaStringPtr train_net_;
+ ::google::protobuf::internal::ArenaStringPtr lr_policy_;
+ static ::std::string* _default_regularization_type_;
+ ::google::protobuf::internal::ArenaStringPtr regularization_type_;
+ ::google::protobuf::internal::ArenaStringPtr snapshot_prefix_;
+ static ::std::string* _default_type_;
+ ::google::protobuf::internal::ArenaStringPtr type_;
+ ::caffe::NetParameter* net_param_;
+ ::caffe::NetParameter* train_net_param_;
+ ::caffe::NetState* train_state_;
+ ::google::protobuf::int32 test_interval_;
+ float base_lr_;
+ ::google::protobuf::int32 display_;
+ ::google::protobuf::int32 max_iter_;
+ float gamma_;
+ float power_;
+ float momentum_;
+ float weight_decay_;
+ ::google::protobuf::int32 stepsize_;
+ bool test_compute_loss_;
+ bool snapshot_diff_;
+ bool debug_info_;
+ ::google::protobuf::int32 snapshot_;
+ ::google::protobuf::int32 device_id_;
+ int solver_type_;
+ float rms_decay_;
+ ::google::protobuf::int32 average_loss_;
+ ::google::protobuf::int32 iter_size_;
+ bool test_initialization_;
+ bool snapshot_after_train_;
+ float clip_gradients_;
+ int snapshot_format_;
+ int solver_mode_;
+ ::google::protobuf::int64 random_seed_;
+ float delta_;
+ float momentum2_;
+ mutable int _cached_size_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<SolverParameter> SolverParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class SolverState : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.SolverState) */ {
+ public:
+ SolverState();
+ virtual ~SolverState();
+
+ SolverState(const SolverState& from);
+
+ inline SolverState& operator=(const SolverState& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const SolverState& default_instance();
+
+ static const SolverState* internal_default_instance();
+
+ void Swap(SolverState* other);
+
+ // implements Message ----------------------------------------------
+
+ inline SolverState* New() const { return New(NULL); }
+
+ SolverState* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const SolverState& from);
+ void MergeFrom(const SolverState& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(SolverState* other);
+ void UnsafeMergeFrom(const SolverState& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional int32 iter = 1;
+ bool has_iter() const;
+ void clear_iter();
+ static const int kIterFieldNumber = 1;
+ ::google::protobuf::int32 iter() const;
+ void set_iter(::google::protobuf::int32 value);
+
+ // optional string learned_net = 2;
+ bool has_learned_net() const;
+ void clear_learned_net();
+ static const int kLearnedNetFieldNumber = 2;
+ const ::std::string& learned_net() const;
+ void set_learned_net(const ::std::string& value);
+ void set_learned_net(const char* value);
+ void set_learned_net(const char* value, size_t size);
+ ::std::string* mutable_learned_net();
+ ::std::string* release_learned_net();
+ void set_allocated_learned_net(::std::string* learned_net);
+
+ // repeated .caffe.BlobProto history = 3;
+ int history_size() const;
+ void clear_history();
+ static const int kHistoryFieldNumber = 3;
+ const ::caffe::BlobProto& history(int index) const;
+ ::caffe::BlobProto* mutable_history(int index);
+ ::caffe::BlobProto* add_history();
+ ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
+ mutable_history();
+ const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
+ history() const;
+
+ // optional int32 current_step = 4 [default = 0];
+ bool has_current_step() const;
+ void clear_current_step();
+ static const int kCurrentStepFieldNumber = 4;
+ ::google::protobuf::int32 current_step() const;
+ void set_current_step(::google::protobuf::int32 value);
+
+ // @@protoc_insertion_point(class_scope:caffe.SolverState)
+ private:
+ inline void set_has_iter();
+ inline void clear_has_iter();
+ inline void set_has_learned_net();
+ inline void clear_has_learned_net();
+ inline void set_has_current_step();
+ inline void clear_has_current_step();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto > history_;
+ ::google::protobuf::internal::ArenaStringPtr learned_net_;
+ ::google::protobuf::int32 iter_;
+ ::google::protobuf::int32 current_step_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<SolverState> SolverState_default_instance_;
+
+// -------------------------------------------------------------------
+
+class NetState : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.NetState) */ {
+ public:
+ NetState();
+ virtual ~NetState();
+
+ NetState(const NetState& from);
+
+ inline NetState& operator=(const NetState& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const NetState& default_instance();
+
+ static const NetState* internal_default_instance();
+
+ void Swap(NetState* other);
+
+ // implements Message ----------------------------------------------
+
+ inline NetState* New() const { return New(NULL); }
+
+ NetState* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const NetState& from);
+ void MergeFrom(const NetState& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(NetState* other);
+ void UnsafeMergeFrom(const NetState& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional .caffe.Phase phase = 1 [default = TEST];
+ bool has_phase() const;
+ void clear_phase();
+ static const int kPhaseFieldNumber = 1;
+ ::caffe::Phase phase() const;
+ void set_phase(::caffe::Phase value);
+
+ // optional int32 level = 2 [default = 0];
+ bool has_level() const;
+ void clear_level();
+ static const int kLevelFieldNumber = 2;
+ ::google::protobuf::int32 level() const;
+ void set_level(::google::protobuf::int32 value);
+
+ // repeated string stage = 3;
+ int stage_size() const;
+ void clear_stage();
+ static const int kStageFieldNumber = 3;
+ const ::std::string& stage(int index) const;
+ ::std::string* mutable_stage(int index);
+ void set_stage(int index, const ::std::string& value);
+ void set_stage(int index, const char* value);
+ void set_stage(int index, const char* value, size_t size);
+ ::std::string* add_stage();
+ void add_stage(const ::std::string& value);
+ void add_stage(const char* value);
+ void add_stage(const char* value, size_t size);
+ const ::google::protobuf::RepeatedPtrField< ::std::string>& stage() const;
+ ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_stage();
+
+ // @@protoc_insertion_point(class_scope:caffe.NetState)
+ private:
+ inline void set_has_phase();
+ inline void clear_has_phase();
+ inline void set_has_level();
+ inline void clear_has_level();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::RepeatedPtrField< ::std::string> stage_;
+ ::google::protobuf::int32 level_;
+ int phase_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<NetState> NetState_default_instance_;
+
+// -------------------------------------------------------------------
+
+class NetStateRule : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.NetStateRule) */ {
+ public:
+ NetStateRule();
+ virtual ~NetStateRule();
+
+ NetStateRule(const NetStateRule& from);
+
+ inline NetStateRule& operator=(const NetStateRule& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const NetStateRule& default_instance();
+
+ static const NetStateRule* internal_default_instance();
+
+ void Swap(NetStateRule* other);
+
+ // implements Message ----------------------------------------------
+
+ inline NetStateRule* New() const { return New(NULL); }
+
+ NetStateRule* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const NetStateRule& from);
+ void MergeFrom(const NetStateRule& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(NetStateRule* other);
+ void UnsafeMergeFrom(const NetStateRule& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional .caffe.Phase phase = 1;
+ bool has_phase() const;
+ void clear_phase();
+ static const int kPhaseFieldNumber = 1;
+ ::caffe::Phase phase() const;
+ void set_phase(::caffe::Phase value);
+
+ // optional int32 min_level = 2;
+ bool has_min_level() const;
+ void clear_min_level();
+ static const int kMinLevelFieldNumber = 2;
+ ::google::protobuf::int32 min_level() const;
+ void set_min_level(::google::protobuf::int32 value);
+
+ // optional int32 max_level = 3;
+ bool has_max_level() const;
+ void clear_max_level();
+ static const int kMaxLevelFieldNumber = 3;
+ ::google::protobuf::int32 max_level() const;
+ void set_max_level(::google::protobuf::int32 value);
+
+ // repeated string stage = 4;
+ int stage_size() const;
+ void clear_stage();
+ static const int kStageFieldNumber = 4;
+ const ::std::string& stage(int index) const;
+ ::std::string* mutable_stage(int index);
+ void set_stage(int index, const ::std::string& value);
+ void set_stage(int index, const char* value);
+ void set_stage(int index, const char* value, size_t size);
+ ::std::string* add_stage();
+ void add_stage(const ::std::string& value);
+ void add_stage(const char* value);
+ void add_stage(const char* value, size_t size);
+ const ::google::protobuf::RepeatedPtrField< ::std::string>& stage() const;
+ ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_stage();
+
+ // repeated string not_stage = 5;
+ int not_stage_size() const;
+ void clear_not_stage();
+ static const int kNotStageFieldNumber = 5;
+ const ::std::string& not_stage(int index) const;
+ ::std::string* mutable_not_stage(int index);
+ void set_not_stage(int index, const ::std::string& value);
+ void set_not_stage(int index, const char* value);
+ void set_not_stage(int index, const char* value, size_t size);
+ ::std::string* add_not_stage();
+ void add_not_stage(const ::std::string& value);
+ void add_not_stage(const char* value);
+ void add_not_stage(const char* value, size_t size);
+ const ::google::protobuf::RepeatedPtrField< ::std::string>& not_stage() const;
+ ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_not_stage();
+
+ // @@protoc_insertion_point(class_scope:caffe.NetStateRule)
+ private:
+ inline void set_has_phase();
+ inline void clear_has_phase();
+ inline void set_has_min_level();
+ inline void clear_has_min_level();
+ inline void set_has_max_level();
+ inline void clear_has_max_level();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::RepeatedPtrField< ::std::string> stage_;
+ ::google::protobuf::RepeatedPtrField< ::std::string> not_stage_;
+ int phase_;
+ ::google::protobuf::int32 min_level_;
+ ::google::protobuf::int32 max_level_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<NetStateRule> NetStateRule_default_instance_;
+
+// -------------------------------------------------------------------
+
+class ParamSpec : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ParamSpec) */ {
+ public:
+ ParamSpec();
+ virtual ~ParamSpec();
+
+ ParamSpec(const ParamSpec& from);
+
+ inline ParamSpec& operator=(const ParamSpec& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const ParamSpec& default_instance();
+
+ static const ParamSpec* internal_default_instance();
+
+ void Swap(ParamSpec* other);
+
+ // implements Message ----------------------------------------------
+
+ inline ParamSpec* New() const { return New(NULL); }
+
+ ParamSpec* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const ParamSpec& from);
+ void MergeFrom(const ParamSpec& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(ParamSpec* other);
+ void UnsafeMergeFrom(const ParamSpec& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ typedef ParamSpec_DimCheckMode DimCheckMode;
+ static const DimCheckMode STRICT =
+ ParamSpec_DimCheckMode_STRICT;
+ static const DimCheckMode PERMISSIVE =
+ ParamSpec_DimCheckMode_PERMISSIVE;
+ static inline bool DimCheckMode_IsValid(int value) {
+ return ParamSpec_DimCheckMode_IsValid(value);
+ }
+ static const DimCheckMode DimCheckMode_MIN =
+ ParamSpec_DimCheckMode_DimCheckMode_MIN;
+ static const DimCheckMode DimCheckMode_MAX =
+ ParamSpec_DimCheckMode_DimCheckMode_MAX;
+ static const int DimCheckMode_ARRAYSIZE =
+ ParamSpec_DimCheckMode_DimCheckMode_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ DimCheckMode_descriptor() {
+ return ParamSpec_DimCheckMode_descriptor();
+ }
+ static inline const ::std::string& DimCheckMode_Name(DimCheckMode value) {
+ return ParamSpec_DimCheckMode_Name(value);
+ }
+ static inline bool DimCheckMode_Parse(const ::std::string& name,
+ DimCheckMode* value) {
+ return ParamSpec_DimCheckMode_Parse(name, value);
+ }
+
+ // accessors -------------------------------------------------------
+
+ // optional string name = 1;
+ bool has_name() const;
+ void clear_name();
+ static const int kNameFieldNumber = 1;
+ const ::std::string& name() const;
+ void set_name(const ::std::string& value);
+ void set_name(const char* value);
+ void set_name(const char* value, size_t size);
+ ::std::string* mutable_name();
+ ::std::string* release_name();
+ void set_allocated_name(::std::string* name);
+
+ // optional .caffe.ParamSpec.DimCheckMode share_mode = 2;
+ bool has_share_mode() const;
+ void clear_share_mode();
+ static const int kShareModeFieldNumber = 2;
+ ::caffe::ParamSpec_DimCheckMode share_mode() const;
+ void set_share_mode(::caffe::ParamSpec_DimCheckMode value);
+
+ // optional float lr_mult = 3 [default = 1];
+ bool has_lr_mult() const;
+ void clear_lr_mult();
+ static const int kLrMultFieldNumber = 3;
+ float lr_mult() const;
+ void set_lr_mult(float value);
+
+ // optional float decay_mult = 4 [default = 1];
+ bool has_decay_mult() const;
+ void clear_decay_mult();
+ static const int kDecayMultFieldNumber = 4;
+ float decay_mult() const;
+ void set_decay_mult(float value);
+
+ // @@protoc_insertion_point(class_scope:caffe.ParamSpec)
+ private:
+ inline void set_has_name();
+ inline void clear_has_name();
+ inline void set_has_share_mode();
+ inline void clear_has_share_mode();
+ inline void set_has_lr_mult();
+ inline void clear_has_lr_mult();
+ inline void set_has_decay_mult();
+ inline void clear_has_decay_mult();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::internal::ArenaStringPtr name_;
+ int share_mode_;
+ float lr_mult_;
+ float decay_mult_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<ParamSpec> ParamSpec_default_instance_;
+
+// -------------------------------------------------------------------
+
+class LayerParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.LayerParameter) */ {
+ public:
+ LayerParameter();
+ virtual ~LayerParameter();
+
+ LayerParameter(const LayerParameter& from);
+
+ inline LayerParameter& operator=(const LayerParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const LayerParameter& default_instance();
+
+ static const LayerParameter* internal_default_instance();
+
+ void Swap(LayerParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline LayerParameter* New() const { return New(NULL); }
+
+ LayerParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const LayerParameter& from);
+ void MergeFrom(const LayerParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(LayerParameter* other);
+ void UnsafeMergeFrom(const LayerParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional string name = 1;
+ bool has_name() const;
+ void clear_name();
+ static const int kNameFieldNumber = 1;
+ const ::std::string& name() const;
+ void set_name(const ::std::string& value);
+ void set_name(const char* value);
+ void set_name(const char* value, size_t size);
+ ::std::string* mutable_name();
+ ::std::string* release_name();
+ void set_allocated_name(::std::string* name);
+
+ // optional string type = 2;
+ bool has_type() const;
+ void clear_type();
+ static const int kTypeFieldNumber = 2;
+ const ::std::string& type() const;
+ void set_type(const ::std::string& value);
+ void set_type(const char* value);
+ void set_type(const char* value, size_t size);
+ ::std::string* mutable_type();
+ ::std::string* release_type();
+ void set_allocated_type(::std::string* type);
+
+ // repeated string bottom = 3;
+ int bottom_size() const;
+ void clear_bottom();
+ static const int kBottomFieldNumber = 3;
+ const ::std::string& bottom(int index) const;
+ ::std::string* mutable_bottom(int index);
+ void set_bottom(int index, const ::std::string& value);
+ void set_bottom(int index, const char* value);
+ void set_bottom(int index, const char* value, size_t size);
+ ::std::string* add_bottom();
+ void add_bottom(const ::std::string& value);
+ void add_bottom(const char* value);
+ void add_bottom(const char* value, size_t size);
+ const ::google::protobuf::RepeatedPtrField< ::std::string>& bottom() const;
+ ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_bottom();
+
+ // repeated string top = 4;
+ int top_size() const;
+ void clear_top();
+ static const int kTopFieldNumber = 4;
+ const ::std::string& top(int index) const;
+ ::std::string* mutable_top(int index);
+ void set_top(int index, const ::std::string& value);
+ void set_top(int index, const char* value);
+ void set_top(int index, const char* value, size_t size);
+ ::std::string* add_top();
+ void add_top(const ::std::string& value);
+ void add_top(const char* value);
+ void add_top(const char* value, size_t size);
+ const ::google::protobuf::RepeatedPtrField< ::std::string>& top() const;
+ ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_top();
+
+ // optional .caffe.Phase phase = 10;
+ bool has_phase() const;
+ void clear_phase();
+ static const int kPhaseFieldNumber = 10;
+ ::caffe::Phase phase() const;
+ void set_phase(::caffe::Phase value);
+
+ // repeated float loss_weight = 5;
+ int loss_weight_size() const;
+ void clear_loss_weight();
+ static const int kLossWeightFieldNumber = 5;
+ float loss_weight(int index) const;
+ void set_loss_weight(int index, float value);
+ void add_loss_weight(float value);
+ const ::google::protobuf::RepeatedField< float >&
+ loss_weight() const;
+ ::google::protobuf::RepeatedField< float >*
+ mutable_loss_weight();
+
+ // repeated .caffe.ParamSpec param = 6;
+ int param_size() const;
+ void clear_param();
+ static const int kParamFieldNumber = 6;
+ const ::caffe::ParamSpec& param(int index) const;
+ ::caffe::ParamSpec* mutable_param(int index);
+ ::caffe::ParamSpec* add_param();
+ ::google::protobuf::RepeatedPtrField< ::caffe::ParamSpec >*
+ mutable_param();
+ const ::google::protobuf::RepeatedPtrField< ::caffe::ParamSpec >&
+ param() const;
+
+ // repeated .caffe.BlobProto blobs = 7;
+ int blobs_size() const;
+ void clear_blobs();
+ static const int kBlobsFieldNumber = 7;
+ const ::caffe::BlobProto& blobs(int index) const;
+ ::caffe::BlobProto* mutable_blobs(int index);
+ ::caffe::BlobProto* add_blobs();
+ ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
+ mutable_blobs();
+ const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
+ blobs() const;
+
+ // repeated bool propagate_down = 11;
+ int propagate_down_size() const;
+ void clear_propagate_down();
+ static const int kPropagateDownFieldNumber = 11;
+ bool propagate_down(int index) const;
+ void set_propagate_down(int index, bool value);
+ void add_propagate_down(bool value);
+ const ::google::protobuf::RepeatedField< bool >&
+ propagate_down() const;
+ ::google::protobuf::RepeatedField< bool >*
+ mutable_propagate_down();
+
+ // repeated .caffe.NetStateRule include = 8;
+ int include_size() const;
+ void clear_include();
+ static const int kIncludeFieldNumber = 8;
+ const ::caffe::NetStateRule& include(int index) const;
+ ::caffe::NetStateRule* mutable_include(int index);
+ ::caffe::NetStateRule* add_include();
+ ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >*
+ mutable_include();
+ const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >&
+ include() const;
+
+ // repeated .caffe.NetStateRule exclude = 9;
+ int exclude_size() const;
+ void clear_exclude();
+ static const int kExcludeFieldNumber = 9;
+ const ::caffe::NetStateRule& exclude(int index) const;
+ ::caffe::NetStateRule* mutable_exclude(int index);
+ ::caffe::NetStateRule* add_exclude();
+ ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >*
+ mutable_exclude();
+ const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >&
+ exclude() const;
+
+ // optional .caffe.TransformationParameter transform_param = 100;
+ bool has_transform_param() const;
+ void clear_transform_param();
+ static const int kTransformParamFieldNumber = 100;
+ const ::caffe::TransformationParameter& transform_param() const;
+ ::caffe::TransformationParameter* mutable_transform_param();
+ ::caffe::TransformationParameter* release_transform_param();
+ void set_allocated_transform_param(::caffe::TransformationParameter* transform_param);
+
+ // optional .caffe.LossParameter loss_param = 101;
+ bool has_loss_param() const;
+ void clear_loss_param();
+ static const int kLossParamFieldNumber = 101;
+ const ::caffe::LossParameter& loss_param() const;
+ ::caffe::LossParameter* mutable_loss_param();
+ ::caffe::LossParameter* release_loss_param();
+ void set_allocated_loss_param(::caffe::LossParameter* loss_param);
+
+ // optional .caffe.AccuracyParameter accuracy_param = 102;
+ bool has_accuracy_param() const;
+ void clear_accuracy_param();
+ static const int kAccuracyParamFieldNumber = 102;
+ const ::caffe::AccuracyParameter& accuracy_param() const;
+ ::caffe::AccuracyParameter* mutable_accuracy_param();
+ ::caffe::AccuracyParameter* release_accuracy_param();
+ void set_allocated_accuracy_param(::caffe::AccuracyParameter* accuracy_param);
+
+ // optional .caffe.ArgMaxParameter argmax_param = 103;
+ bool has_argmax_param() const;
+ void clear_argmax_param();
+ static const int kArgmaxParamFieldNumber = 103;
+ const ::caffe::ArgMaxParameter& argmax_param() const;
+ ::caffe::ArgMaxParameter* mutable_argmax_param();
+ ::caffe::ArgMaxParameter* release_argmax_param();
+ void set_allocated_argmax_param(::caffe::ArgMaxParameter* argmax_param);
+
+ // optional .caffe.BatchNormParameter batch_norm_param = 139;
+ bool has_batch_norm_param() const;
+ void clear_batch_norm_param();
+ static const int kBatchNormParamFieldNumber = 139;
+ const ::caffe::BatchNormParameter& batch_norm_param() const;
+ ::caffe::BatchNormParameter* mutable_batch_norm_param();
+ ::caffe::BatchNormParameter* release_batch_norm_param();
+ void set_allocated_batch_norm_param(::caffe::BatchNormParameter* batch_norm_param);
+
+ // optional .caffe.BiasParameter bias_param = 141;
+ bool has_bias_param() const;
+ void clear_bias_param();
+ static const int kBiasParamFieldNumber = 141;
+ const ::caffe::BiasParameter& bias_param() const;
+ ::caffe::BiasParameter* mutable_bias_param();
+ ::caffe::BiasParameter* release_bias_param();
+ void set_allocated_bias_param(::caffe::BiasParameter* bias_param);
+
+ // optional .caffe.ConcatParameter concat_param = 104;
+ bool has_concat_param() const;
+ void clear_concat_param();
+ static const int kConcatParamFieldNumber = 104;
+ const ::caffe::ConcatParameter& concat_param() const;
+ ::caffe::ConcatParameter* mutable_concat_param();
+ ::caffe::ConcatParameter* release_concat_param();
+ void set_allocated_concat_param(::caffe::ConcatParameter* concat_param);
+
+ // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 105;
+ bool has_contrastive_loss_param() const;
+ void clear_contrastive_loss_param();
+ static const int kContrastiveLossParamFieldNumber = 105;
+ const ::caffe::ContrastiveLossParameter& contrastive_loss_param() const;
+ ::caffe::ContrastiveLossParameter* mutable_contrastive_loss_param();
+ ::caffe::ContrastiveLossParameter* release_contrastive_loss_param();
+ void set_allocated_contrastive_loss_param(::caffe::ContrastiveLossParameter* contrastive_loss_param);
+
+ // optional .caffe.ConvolutionParameter convolution_param = 106;
+ bool has_convolution_param() const;
+ void clear_convolution_param();
+ static const int kConvolutionParamFieldNumber = 106;
+ const ::caffe::ConvolutionParameter& convolution_param() const;
+ ::caffe::ConvolutionParameter* mutable_convolution_param();
+ ::caffe::ConvolutionParameter* release_convolution_param();
+ void set_allocated_convolution_param(::caffe::ConvolutionParameter* convolution_param);
+
+ // optional .caffe.CropParameter crop_param = 144;
+ bool has_crop_param() const;
+ void clear_crop_param();
+ static const int kCropParamFieldNumber = 144;
+ const ::caffe::CropParameter& crop_param() const;
+ ::caffe::CropParameter* mutable_crop_param();
+ ::caffe::CropParameter* release_crop_param();
+ void set_allocated_crop_param(::caffe::CropParameter* crop_param);
+
+ // optional .caffe.DataParameter data_param = 107;
+ bool has_data_param() const;
+ void clear_data_param();
+ static const int kDataParamFieldNumber = 107;
+ const ::caffe::DataParameter& data_param() const;
+ ::caffe::DataParameter* mutable_data_param();
+ ::caffe::DataParameter* release_data_param();
+ void set_allocated_data_param(::caffe::DataParameter* data_param);
+
+ // optional .caffe.DetectionOutputParameter detection_output_param = 147;
+ bool has_detection_output_param() const;
+ void clear_detection_output_param();
+ static const int kDetectionOutputParamFieldNumber = 147;
+ const ::caffe::DetectionOutputParameter& detection_output_param() const;
+ ::caffe::DetectionOutputParameter* mutable_detection_output_param();
+ ::caffe::DetectionOutputParameter* release_detection_output_param();
+ void set_allocated_detection_output_param(::caffe::DetectionOutputParameter* detection_output_param);
+
+ // optional .caffe.DropoutParameter dropout_param = 108;
+ bool has_dropout_param() const;
+ void clear_dropout_param();
+ static const int kDropoutParamFieldNumber = 108;
+ const ::caffe::DropoutParameter& dropout_param() const;
+ ::caffe::DropoutParameter* mutable_dropout_param();
+ ::caffe::DropoutParameter* release_dropout_param();
+ void set_allocated_dropout_param(::caffe::DropoutParameter* dropout_param);
+
+ // optional .caffe.DummyDataParameter dummy_data_param = 109;
+ bool has_dummy_data_param() const;
+ void clear_dummy_data_param();
+ static const int kDummyDataParamFieldNumber = 109;
+ const ::caffe::DummyDataParameter& dummy_data_param() const;
+ ::caffe::DummyDataParameter* mutable_dummy_data_param();
+ ::caffe::DummyDataParameter* release_dummy_data_param();
+ void set_allocated_dummy_data_param(::caffe::DummyDataParameter* dummy_data_param);
+
+ // optional .caffe.EltwiseParameter eltwise_param = 110;
+ bool has_eltwise_param() const;
+ void clear_eltwise_param();
+ static const int kEltwiseParamFieldNumber = 110;
+ const ::caffe::EltwiseParameter& eltwise_param() const;
+ ::caffe::EltwiseParameter* mutable_eltwise_param();
+ ::caffe::EltwiseParameter* release_eltwise_param();
+ void set_allocated_eltwise_param(::caffe::EltwiseParameter* eltwise_param);
+
+ // optional .caffe.ELUParameter elu_param = 140;
+ bool has_elu_param() const;
+ void clear_elu_param();
+ static const int kEluParamFieldNumber = 140;
+ const ::caffe::ELUParameter& elu_param() const;
+ ::caffe::ELUParameter* mutable_elu_param();
+ ::caffe::ELUParameter* release_elu_param();
+ void set_allocated_elu_param(::caffe::ELUParameter* elu_param);
+
+ // optional .caffe.EmbedParameter embed_param = 137;
+ bool has_embed_param() const;
+ void clear_embed_param();
+ static const int kEmbedParamFieldNumber = 137;
+ const ::caffe::EmbedParameter& embed_param() const;
+ ::caffe::EmbedParameter* mutable_embed_param();
+ ::caffe::EmbedParameter* release_embed_param();
+ void set_allocated_embed_param(::caffe::EmbedParameter* embed_param);
+
+ // optional .caffe.ExpParameter exp_param = 111;
+ bool has_exp_param() const;
+ void clear_exp_param();
+ static const int kExpParamFieldNumber = 111;
+ const ::caffe::ExpParameter& exp_param() const;
+ ::caffe::ExpParameter* mutable_exp_param();
+ ::caffe::ExpParameter* release_exp_param();
+ void set_allocated_exp_param(::caffe::ExpParameter* exp_param);
+
+ // optional .caffe.FlattenParameter flatten_param = 135;
+ bool has_flatten_param() const;
+ void clear_flatten_param();
+ static const int kFlattenParamFieldNumber = 135;
+ const ::caffe::FlattenParameter& flatten_param() const;
+ ::caffe::FlattenParameter* mutable_flatten_param();
+ ::caffe::FlattenParameter* release_flatten_param();
+ void set_allocated_flatten_param(::caffe::FlattenParameter* flatten_param);
+
+ // optional .caffe.HDF5DataParameter hdf5_data_param = 112;
+ bool has_hdf5_data_param() const;
+ void clear_hdf5_data_param();
+ static const int kHdf5DataParamFieldNumber = 112;
+ const ::caffe::HDF5DataParameter& hdf5_data_param() const;
+ ::caffe::HDF5DataParameter* mutable_hdf5_data_param();
+ ::caffe::HDF5DataParameter* release_hdf5_data_param();
+ void set_allocated_hdf5_data_param(::caffe::HDF5DataParameter* hdf5_data_param);
+
+ // optional .caffe.HDF5OutputParameter hdf5_output_param = 113;
+ bool has_hdf5_output_param() const;
+ void clear_hdf5_output_param();
+ static const int kHdf5OutputParamFieldNumber = 113;
+ const ::caffe::HDF5OutputParameter& hdf5_output_param() const;
+ ::caffe::HDF5OutputParameter* mutable_hdf5_output_param();
+ ::caffe::HDF5OutputParameter* release_hdf5_output_param();
+ void set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param);
+
+ // optional .caffe.HingeLossParameter hinge_loss_param = 114;
+ bool has_hinge_loss_param() const;
+ void clear_hinge_loss_param();
+ static const int kHingeLossParamFieldNumber = 114;
+ const ::caffe::HingeLossParameter& hinge_loss_param() const;
+ ::caffe::HingeLossParameter* mutable_hinge_loss_param();
+ ::caffe::HingeLossParameter* release_hinge_loss_param();
+ void set_allocated_hinge_loss_param(::caffe::HingeLossParameter* hinge_loss_param);
+
+ // optional .caffe.ImageDataParameter image_data_param = 115;
+ bool has_image_data_param() const;
+ void clear_image_data_param();
+ static const int kImageDataParamFieldNumber = 115;
+ const ::caffe::ImageDataParameter& image_data_param() const;
+ ::caffe::ImageDataParameter* mutable_image_data_param();
+ ::caffe::ImageDataParameter* release_image_data_param();
+ void set_allocated_image_data_param(::caffe::ImageDataParameter* image_data_param);
+
+ // optional .caffe.InfogainLossParameter infogain_loss_param = 116;
+ bool has_infogain_loss_param() const;
+ void clear_infogain_loss_param();
+ static const int kInfogainLossParamFieldNumber = 116;
+ const ::caffe::InfogainLossParameter& infogain_loss_param() const;
+ ::caffe::InfogainLossParameter* mutable_infogain_loss_param();
+ ::caffe::InfogainLossParameter* release_infogain_loss_param();
+ void set_allocated_infogain_loss_param(::caffe::InfogainLossParameter* infogain_loss_param);
+
+ // optional .caffe.InnerProductParameter inner_product_param = 117;
+ bool has_inner_product_param() const;
+ void clear_inner_product_param();
+ static const int kInnerProductParamFieldNumber = 117;
+ const ::caffe::InnerProductParameter& inner_product_param() const;
+ ::caffe::InnerProductParameter* mutable_inner_product_param();
+ ::caffe::InnerProductParameter* release_inner_product_param();
+ void set_allocated_inner_product_param(::caffe::InnerProductParameter* inner_product_param);
+
+ // optional .caffe.InputParameter input_param = 143;
+ bool has_input_param() const;
+ void clear_input_param();
+ static const int kInputParamFieldNumber = 143;
+ const ::caffe::InputParameter& input_param() const;
+ ::caffe::InputParameter* mutable_input_param();
+ ::caffe::InputParameter* release_input_param();
+ void set_allocated_input_param(::caffe::InputParameter* input_param);
+
+ // optional .caffe.LogParameter log_param = 134;
+ bool has_log_param() const;
+ void clear_log_param();
+ static const int kLogParamFieldNumber = 134;
+ const ::caffe::LogParameter& log_param() const;
+ ::caffe::LogParameter* mutable_log_param();
+ ::caffe::LogParameter* release_log_param();
+ void set_allocated_log_param(::caffe::LogParameter* log_param);
+
+ // optional .caffe.LRNParameter lrn_param = 118;
+ bool has_lrn_param() const;
+ void clear_lrn_param();
+ static const int kLrnParamFieldNumber = 118;
+ const ::caffe::LRNParameter& lrn_param() const;
+ ::caffe::LRNParameter* mutable_lrn_param();
+ ::caffe::LRNParameter* release_lrn_param();
+ void set_allocated_lrn_param(::caffe::LRNParameter* lrn_param);
+
+ // optional .caffe.MemoryDataParameter memory_data_param = 119;
+ bool has_memory_data_param() const;
+ void clear_memory_data_param();
+ static const int kMemoryDataParamFieldNumber = 119;
+ const ::caffe::MemoryDataParameter& memory_data_param() const;
+ ::caffe::MemoryDataParameter* mutable_memory_data_param();
+ ::caffe::MemoryDataParameter* release_memory_data_param();
+ void set_allocated_memory_data_param(::caffe::MemoryDataParameter* memory_data_param);
+
+ // optional .caffe.MVNParameter mvn_param = 120;
+ bool has_mvn_param() const;
+ void clear_mvn_param();
+ static const int kMvnParamFieldNumber = 120;
+ const ::caffe::MVNParameter& mvn_param() const;
+ ::caffe::MVNParameter* mutable_mvn_param();
+ ::caffe::MVNParameter* release_mvn_param();
+ void set_allocated_mvn_param(::caffe::MVNParameter* mvn_param);
+
+ // optional .caffe.NormalizeBBoxParameter norm_param = 149;
+ bool has_norm_param() const;
+ void clear_norm_param();
+ static const int kNormParamFieldNumber = 149;
+ const ::caffe::NormalizeBBoxParameter& norm_param() const;
+ ::caffe::NormalizeBBoxParameter* mutable_norm_param();
+ ::caffe::NormalizeBBoxParameter* release_norm_param();
+ void set_allocated_norm_param(::caffe::NormalizeBBoxParameter* norm_param);
+
+ // optional .caffe.PermuteParameter permute_param = 148;
+ bool has_permute_param() const;
+ void clear_permute_param();
+ static const int kPermuteParamFieldNumber = 148;
+ const ::caffe::PermuteParameter& permute_param() const;
+ ::caffe::PermuteParameter* mutable_permute_param();
+ ::caffe::PermuteParameter* release_permute_param();
+ void set_allocated_permute_param(::caffe::PermuteParameter* permute_param);
+
+ // optional .caffe.ParameterParameter parameter_param = 145;
+ bool has_parameter_param() const;
+ void clear_parameter_param();
+ static const int kParameterParamFieldNumber = 145;
+ const ::caffe::ParameterParameter& parameter_param() const;
+ ::caffe::ParameterParameter* mutable_parameter_param();
+ ::caffe::ParameterParameter* release_parameter_param();
+ void set_allocated_parameter_param(::caffe::ParameterParameter* parameter_param);
+
+ // optional .caffe.PoolingParameter pooling_param = 121;
+ bool has_pooling_param() const;
+ void clear_pooling_param();
+ static const int kPoolingParamFieldNumber = 121;
+ const ::caffe::PoolingParameter& pooling_param() const;
+ ::caffe::PoolingParameter* mutable_pooling_param();
+ ::caffe::PoolingParameter* release_pooling_param();
+ void set_allocated_pooling_param(::caffe::PoolingParameter* pooling_param);
+
+ // optional .caffe.PowerParameter power_param = 122;
+ bool has_power_param() const;
+ void clear_power_param();
+ static const int kPowerParamFieldNumber = 122;
+ const ::caffe::PowerParameter& power_param() const;
+ ::caffe::PowerParameter* mutable_power_param();
+ ::caffe::PowerParameter* release_power_param();
+ void set_allocated_power_param(::caffe::PowerParameter* power_param);
+
+ // optional .caffe.PReLUParameter prelu_param = 131;
+ bool has_prelu_param() const;
+ void clear_prelu_param();
+ static const int kPreluParamFieldNumber = 131;
+ const ::caffe::PReLUParameter& prelu_param() const;
+ ::caffe::PReLUParameter* mutable_prelu_param();
+ ::caffe::PReLUParameter* release_prelu_param();
+ void set_allocated_prelu_param(::caffe::PReLUParameter* prelu_param);
+
+ // optional .caffe.PriorBoxParameter prior_box_param = 150;
+ bool has_prior_box_param() const;
+ void clear_prior_box_param();
+ static const int kPriorBoxParamFieldNumber = 150;
+ const ::caffe::PriorBoxParameter& prior_box_param() const;
+ ::caffe::PriorBoxParameter* mutable_prior_box_param();
+ ::caffe::PriorBoxParameter* release_prior_box_param();
+ void set_allocated_prior_box_param(::caffe::PriorBoxParameter* prior_box_param);
+
+ // optional .caffe.PythonParameter python_param = 130;
+ bool has_python_param() const;
+ void clear_python_param();
+ static const int kPythonParamFieldNumber = 130;
+ const ::caffe::PythonParameter& python_param() const;
+ ::caffe::PythonParameter* mutable_python_param();
+ ::caffe::PythonParameter* release_python_param();
+ void set_allocated_python_param(::caffe::PythonParameter* python_param);
+
+ // optional .caffe.RecurrentParameter recurrent_param = 146;
+ bool has_recurrent_param() const;
+ void clear_recurrent_param();
+ static const int kRecurrentParamFieldNumber = 146;
+ const ::caffe::RecurrentParameter& recurrent_param() const;
+ ::caffe::RecurrentParameter* mutable_recurrent_param();
+ ::caffe::RecurrentParameter* release_recurrent_param();
+ void set_allocated_recurrent_param(::caffe::RecurrentParameter* recurrent_param);
+
+ // optional .caffe.ReductionParameter reduction_param = 136;
+ bool has_reduction_param() const;
+ void clear_reduction_param();
+ static const int kReductionParamFieldNumber = 136;
+ const ::caffe::ReductionParameter& reduction_param() const;
+ ::caffe::ReductionParameter* mutable_reduction_param();
+ ::caffe::ReductionParameter* release_reduction_param();
+ void set_allocated_reduction_param(::caffe::ReductionParameter* reduction_param);
+
+ // optional .caffe.ReLUParameter relu_param = 123;
+ bool has_relu_param() const;
+ void clear_relu_param();
+ static const int kReluParamFieldNumber = 123;
+ const ::caffe::ReLUParameter& relu_param() const;
+ ::caffe::ReLUParameter* mutable_relu_param();
+ ::caffe::ReLUParameter* release_relu_param();
+ void set_allocated_relu_param(::caffe::ReLUParameter* relu_param);
+
+ // optional .caffe.ReshapeParameter reshape_param = 133;
+ bool has_reshape_param() const;
+ void clear_reshape_param();
+ static const int kReshapeParamFieldNumber = 133;
+ const ::caffe::ReshapeParameter& reshape_param() const;
+ ::caffe::ReshapeParameter* mutable_reshape_param();
+ ::caffe::ReshapeParameter* release_reshape_param();
+ void set_allocated_reshape_param(::caffe::ReshapeParameter* reshape_param);
+
+ // optional .caffe.ScaleParameter scale_param = 142;
+ bool has_scale_param() const;
+ void clear_scale_param();
+ static const int kScaleParamFieldNumber = 142;
+ const ::caffe::ScaleParameter& scale_param() const;
+ ::caffe::ScaleParameter* mutable_scale_param();
+ ::caffe::ScaleParameter* release_scale_param();
+ void set_allocated_scale_param(::caffe::ScaleParameter* scale_param);
+
+ // optional .caffe.SigmoidParameter sigmoid_param = 124;
+ bool has_sigmoid_param() const;
+ void clear_sigmoid_param();
+ static const int kSigmoidParamFieldNumber = 124;
+ const ::caffe::SigmoidParameter& sigmoid_param() const;
+ ::caffe::SigmoidParameter* mutable_sigmoid_param();
+ ::caffe::SigmoidParameter* release_sigmoid_param();
+ void set_allocated_sigmoid_param(::caffe::SigmoidParameter* sigmoid_param);
+
+ // optional .caffe.SoftmaxParameter softmax_param = 125;
+ bool has_softmax_param() const;
+ void clear_softmax_param();
+ static const int kSoftmaxParamFieldNumber = 125;
+ const ::caffe::SoftmaxParameter& softmax_param() const;
+ ::caffe::SoftmaxParameter* mutable_softmax_param();
+ ::caffe::SoftmaxParameter* release_softmax_param();
+ void set_allocated_softmax_param(::caffe::SoftmaxParameter* softmax_param);
+
+ // optional .caffe.SPPParameter spp_param = 132;
+ bool has_spp_param() const;
+ void clear_spp_param();
+ static const int kSppParamFieldNumber = 132;
+ const ::caffe::SPPParameter& spp_param() const;
+ ::caffe::SPPParameter* mutable_spp_param();
+ ::caffe::SPPParameter* release_spp_param();
+ void set_allocated_spp_param(::caffe::SPPParameter* spp_param);
+
+ // optional .caffe.SliceParameter slice_param = 126;
+ bool has_slice_param() const;
+ void clear_slice_param();
+ static const int kSliceParamFieldNumber = 126;
+ const ::caffe::SliceParameter& slice_param() const;
+ ::caffe::SliceParameter* mutable_slice_param();
+ ::caffe::SliceParameter* release_slice_param();
+ void set_allocated_slice_param(::caffe::SliceParameter* slice_param);
+
+ // optional .caffe.TanHParameter tanh_param = 127;
+ bool has_tanh_param() const;
+ void clear_tanh_param();
+ static const int kTanhParamFieldNumber = 127;
+ const ::caffe::TanHParameter& tanh_param() const;
+ ::caffe::TanHParameter* mutable_tanh_param();
+ ::caffe::TanHParameter* release_tanh_param();
+ void set_allocated_tanh_param(::caffe::TanHParameter* tanh_param);
+
+ // optional .caffe.ThresholdParameter threshold_param = 128;
+ bool has_threshold_param() const;
+ void clear_threshold_param();
+ static const int kThresholdParamFieldNumber = 128;
+ const ::caffe::ThresholdParameter& threshold_param() const;
+ ::caffe::ThresholdParameter* mutable_threshold_param();
+ ::caffe::ThresholdParameter* release_threshold_param();
+ void set_allocated_threshold_param(::caffe::ThresholdParameter* threshold_param);
+
+ // optional .caffe.TileParameter tile_param = 138;
+ bool has_tile_param() const;
+ void clear_tile_param();
+ static const int kTileParamFieldNumber = 138;
+ const ::caffe::TileParameter& tile_param() const;
+ ::caffe::TileParameter* mutable_tile_param();
+ ::caffe::TileParameter* release_tile_param();
+ void set_allocated_tile_param(::caffe::TileParameter* tile_param);
+
+ // optional .caffe.WindowDataParameter window_data_param = 129;
+ bool has_window_data_param() const;
+ void clear_window_data_param();
+ static const int kWindowDataParamFieldNumber = 129;
+ const ::caffe::WindowDataParameter& window_data_param() const;
+ ::caffe::WindowDataParameter* mutable_window_data_param();
+ ::caffe::WindowDataParameter* release_window_data_param();
+ void set_allocated_window_data_param(::caffe::WindowDataParameter* window_data_param);
+
+ // @@protoc_insertion_point(class_scope:caffe.LayerParameter)
+ private:
+ inline void set_has_name();
+ inline void clear_has_name();
+ inline void set_has_type();
+ inline void clear_has_type();
+ inline void set_has_phase();
+ inline void clear_has_phase();
+ inline void set_has_transform_param();
+ inline void clear_has_transform_param();
+ inline void set_has_loss_param();
+ inline void clear_has_loss_param();
+ inline void set_has_accuracy_param();
+ inline void clear_has_accuracy_param();
+ inline void set_has_argmax_param();
+ inline void clear_has_argmax_param();
+ inline void set_has_batch_norm_param();
+ inline void clear_has_batch_norm_param();
+ inline void set_has_bias_param();
+ inline void clear_has_bias_param();
+ inline void set_has_concat_param();
+ inline void clear_has_concat_param();
+ inline void set_has_contrastive_loss_param();
+ inline void clear_has_contrastive_loss_param();
+ inline void set_has_convolution_param();
+ inline void clear_has_convolution_param();
+ inline void set_has_crop_param();
+ inline void clear_has_crop_param();
+ inline void set_has_data_param();
+ inline void clear_has_data_param();
+ inline void set_has_detection_output_param();
+ inline void clear_has_detection_output_param();
+ inline void set_has_dropout_param();
+ inline void clear_has_dropout_param();
+ inline void set_has_dummy_data_param();
+ inline void clear_has_dummy_data_param();
+ inline void set_has_eltwise_param();
+ inline void clear_has_eltwise_param();
+ inline void set_has_elu_param();
+ inline void clear_has_elu_param();
+ inline void set_has_embed_param();
+ inline void clear_has_embed_param();
+ inline void set_has_exp_param();
+ inline void clear_has_exp_param();
+ inline void set_has_flatten_param();
+ inline void clear_has_flatten_param();
+ inline void set_has_hdf5_data_param();
+ inline void clear_has_hdf5_data_param();
+ inline void set_has_hdf5_output_param();
+ inline void clear_has_hdf5_output_param();
+ inline void set_has_hinge_loss_param();
+ inline void clear_has_hinge_loss_param();
+ inline void set_has_image_data_param();
+ inline void clear_has_image_data_param();
+ inline void set_has_infogain_loss_param();
+ inline void clear_has_infogain_loss_param();
+ inline void set_has_inner_product_param();
+ inline void clear_has_inner_product_param();
+ inline void set_has_input_param();
+ inline void clear_has_input_param();
+ inline void set_has_log_param();
+ inline void clear_has_log_param();
+ inline void set_has_lrn_param();
+ inline void clear_has_lrn_param();
+ inline void set_has_memory_data_param();
+ inline void clear_has_memory_data_param();
+ inline void set_has_mvn_param();
+ inline void clear_has_mvn_param();
+ inline void set_has_norm_param();
+ inline void clear_has_norm_param();
+ inline void set_has_permute_param();
+ inline void clear_has_permute_param();
+ inline void set_has_parameter_param();
+ inline void clear_has_parameter_param();
+ inline void set_has_pooling_param();
+ inline void clear_has_pooling_param();
+ inline void set_has_power_param();
+ inline void clear_has_power_param();
+ inline void set_has_prelu_param();
+ inline void clear_has_prelu_param();
+ inline void set_has_prior_box_param();
+ inline void clear_has_prior_box_param();
+ inline void set_has_python_param();
+ inline void clear_has_python_param();
+ inline void set_has_recurrent_param();
+ inline void clear_has_recurrent_param();
+ inline void set_has_reduction_param();
+ inline void clear_has_reduction_param();
+ inline void set_has_relu_param();
+ inline void clear_has_relu_param();
+ inline void set_has_reshape_param();
+ inline void clear_has_reshape_param();
+ inline void set_has_scale_param();
+ inline void clear_has_scale_param();
+ inline void set_has_sigmoid_param();
+ inline void clear_has_sigmoid_param();
+ inline void set_has_softmax_param();
+ inline void clear_has_softmax_param();
+ inline void set_has_spp_param();
+ inline void clear_has_spp_param();
+ inline void set_has_slice_param();
+ inline void clear_has_slice_param();
+ inline void set_has_tanh_param();
+ inline void clear_has_tanh_param();
+ inline void set_has_threshold_param();
+ inline void clear_has_threshold_param();
+ inline void set_has_tile_param();
+ inline void clear_has_tile_param();
+ inline void set_has_window_data_param();
+ inline void clear_has_window_data_param();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<2> _has_bits_;
+ ::google::protobuf::RepeatedPtrField< ::std::string> bottom_;
+ ::google::protobuf::RepeatedPtrField< ::std::string> top_;
+ ::google::protobuf::RepeatedField< float > loss_weight_;
+ ::google::protobuf::RepeatedPtrField< ::caffe::ParamSpec > param_;
+ ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto > blobs_;
+ ::google::protobuf::RepeatedField< bool > propagate_down_;
+ ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule > include_;
+ ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule > exclude_;
+ ::google::protobuf::internal::ArenaStringPtr name_;
+ ::google::protobuf::internal::ArenaStringPtr type_;
+ ::caffe::TransformationParameter* transform_param_;
+ ::caffe::LossParameter* loss_param_;
+ ::caffe::AccuracyParameter* accuracy_param_;
+ ::caffe::ArgMaxParameter* argmax_param_;
+ ::caffe::BatchNormParameter* batch_norm_param_;
+ ::caffe::BiasParameter* bias_param_;
+ ::caffe::ConcatParameter* concat_param_;
+ ::caffe::ContrastiveLossParameter* contrastive_loss_param_;
+ ::caffe::ConvolutionParameter* convolution_param_;
+ ::caffe::CropParameter* crop_param_;
+ ::caffe::DataParameter* data_param_;
+ ::caffe::DetectionOutputParameter* detection_output_param_;
+ ::caffe::DropoutParameter* dropout_param_;
+ ::caffe::DummyDataParameter* dummy_data_param_;
+ ::caffe::EltwiseParameter* eltwise_param_;
+ ::caffe::ELUParameter* elu_param_;
+ ::caffe::EmbedParameter* embed_param_;
+ ::caffe::ExpParameter* exp_param_;
+ ::caffe::FlattenParameter* flatten_param_;
+ ::caffe::HDF5DataParameter* hdf5_data_param_;
+ ::caffe::HDF5OutputParameter* hdf5_output_param_;
+ ::caffe::HingeLossParameter* hinge_loss_param_;
+ ::caffe::ImageDataParameter* image_data_param_;
+ ::caffe::InfogainLossParameter* infogain_loss_param_;
+ ::caffe::InnerProductParameter* inner_product_param_;
+ ::caffe::InputParameter* input_param_;
+ ::caffe::LogParameter* log_param_;
+ ::caffe::LRNParameter* lrn_param_;
+ ::caffe::MemoryDataParameter* memory_data_param_;
+ ::caffe::MVNParameter* mvn_param_;
+ ::caffe::NormalizeBBoxParameter* norm_param_;
+ ::caffe::PermuteParameter* permute_param_;
+ ::caffe::ParameterParameter* parameter_param_;
+ ::caffe::PoolingParameter* pooling_param_;
+ ::caffe::PowerParameter* power_param_;
+ ::caffe::PReLUParameter* prelu_param_;
+ ::caffe::PriorBoxParameter* prior_box_param_;
+ ::caffe::PythonParameter* python_param_;
+ ::caffe::RecurrentParameter* recurrent_param_;
+ ::caffe::ReductionParameter* reduction_param_;
+ ::caffe::ReLUParameter* relu_param_;
+ ::caffe::ReshapeParameter* reshape_param_;
+ ::caffe::ScaleParameter* scale_param_;
+ ::caffe::SigmoidParameter* sigmoid_param_;
+ ::caffe::SoftmaxParameter* softmax_param_;
+ ::caffe::SPPParameter* spp_param_;
+ ::caffe::SliceParameter* slice_param_;
+ ::caffe::TanHParameter* tanh_param_;
+ ::caffe::ThresholdParameter* threshold_param_;
+ ::caffe::TileParameter* tile_param_;
+ ::caffe::WindowDataParameter* window_data_param_;
+ int phase_;
+ mutable int _cached_size_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<LayerParameter> LayerParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class TransformationParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.TransformationParameter) */ {
+ public:
+ TransformationParameter();
+ virtual ~TransformationParameter();
+
+ TransformationParameter(const TransformationParameter& from);
+
+ inline TransformationParameter& operator=(const TransformationParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const TransformationParameter& default_instance();
+
+ static const TransformationParameter* internal_default_instance();
+
+ void Swap(TransformationParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline TransformationParameter* New() const { return New(NULL); }
+
+ TransformationParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const TransformationParameter& from);
+ void MergeFrom(const TransformationParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(TransformationParameter* other);
+ void UnsafeMergeFrom(const TransformationParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional float scale = 1 [default = 1];
+ bool has_scale() const;
+ void clear_scale();
+ static const int kScaleFieldNumber = 1;
+ float scale() const;
+ void set_scale(float value);
+
+ // optional bool mirror = 2 [default = false];
+ bool has_mirror() const;
+ void clear_mirror();
+ static const int kMirrorFieldNumber = 2;
+ bool mirror() const;
+ void set_mirror(bool value);
+
+ // optional uint32 crop_size = 3 [default = 0];
+ bool has_crop_size() const;
+ void clear_crop_size();
+ static const int kCropSizeFieldNumber = 3;
+ ::google::protobuf::uint32 crop_size() const;
+ void set_crop_size(::google::protobuf::uint32 value);
+
+ // optional string mean_file = 4;
+ bool has_mean_file() const;
+ void clear_mean_file();
+ static const int kMeanFileFieldNumber = 4;
+ const ::std::string& mean_file() const;
+ void set_mean_file(const ::std::string& value);
+ void set_mean_file(const char* value);
+ void set_mean_file(const char* value, size_t size);
+ ::std::string* mutable_mean_file();
+ ::std::string* release_mean_file();
+ void set_allocated_mean_file(::std::string* mean_file);
+
+ // repeated float mean_value = 5;
+ int mean_value_size() const;
+ void clear_mean_value();
+ static const int kMeanValueFieldNumber = 5;
+ float mean_value(int index) const;
+ void set_mean_value(int index, float value);
+ void add_mean_value(float value);
+ const ::google::protobuf::RepeatedField< float >&
+ mean_value() const;
+ ::google::protobuf::RepeatedField< float >*
+ mutable_mean_value();
+
+ // optional bool force_color = 6 [default = false];
+ bool has_force_color() const;
+ void clear_force_color();
+ static const int kForceColorFieldNumber = 6;
+ bool force_color() const;
+ void set_force_color(bool value);
+
+ // optional bool force_gray = 7 [default = false];
+ bool has_force_gray() const;
+ void clear_force_gray();
+ static const int kForceGrayFieldNumber = 7;
+ bool force_gray() const;
+ void set_force_gray(bool value);
+
+ // @@protoc_insertion_point(class_scope:caffe.TransformationParameter)
+ private:
+ inline void set_has_scale();
+ inline void clear_has_scale();
+ inline void set_has_mirror();
+ inline void clear_has_mirror();
+ inline void set_has_crop_size();
+ inline void clear_has_crop_size();
+ inline void set_has_mean_file();
+ inline void clear_has_mean_file();
+ inline void set_has_force_color();
+ inline void clear_has_force_color();
+ inline void set_has_force_gray();
+ inline void clear_has_force_gray();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::RepeatedField< float > mean_value_;
+ ::google::protobuf::internal::ArenaStringPtr mean_file_;
+ ::google::protobuf::uint32 crop_size_;
+ bool mirror_;
+ bool force_color_;
+ bool force_gray_;
+ float scale_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<TransformationParameter> TransformationParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class LossParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.LossParameter) */ {
+ public:
+ LossParameter();
+ virtual ~LossParameter();
+
+ LossParameter(const LossParameter& from);
+
+ inline LossParameter& operator=(const LossParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const LossParameter& default_instance();
+
+ static const LossParameter* internal_default_instance();
+
+ void Swap(LossParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline LossParameter* New() const { return New(NULL); }
+
+ LossParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const LossParameter& from);
+ void MergeFrom(const LossParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(LossParameter* other);
+ void UnsafeMergeFrom(const LossParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ typedef LossParameter_NormalizationMode NormalizationMode;
+ static const NormalizationMode FULL =
+ LossParameter_NormalizationMode_FULL;
+ static const NormalizationMode VALID =
+ LossParameter_NormalizationMode_VALID;
+ static const NormalizationMode BATCH_SIZE =
+ LossParameter_NormalizationMode_BATCH_SIZE;
+ static const NormalizationMode NONE =
+ LossParameter_NormalizationMode_NONE;
+ static inline bool NormalizationMode_IsValid(int value) {
+ return LossParameter_NormalizationMode_IsValid(value);
+ }
+ static const NormalizationMode NormalizationMode_MIN =
+ LossParameter_NormalizationMode_NormalizationMode_MIN;
+ static const NormalizationMode NormalizationMode_MAX =
+ LossParameter_NormalizationMode_NormalizationMode_MAX;
+ static const int NormalizationMode_ARRAYSIZE =
+ LossParameter_NormalizationMode_NormalizationMode_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ NormalizationMode_descriptor() {
+ return LossParameter_NormalizationMode_descriptor();
+ }
+ static inline const ::std::string& NormalizationMode_Name(NormalizationMode value) {
+ return LossParameter_NormalizationMode_Name(value);
+ }
+ static inline bool NormalizationMode_Parse(const ::std::string& name,
+ NormalizationMode* value) {
+ return LossParameter_NormalizationMode_Parse(name, value);
+ }
+
+ // accessors -------------------------------------------------------
+
+ // optional int32 ignore_label = 1;
+ bool has_ignore_label() const;
+ void clear_ignore_label();
+ static const int kIgnoreLabelFieldNumber = 1;
+ ::google::protobuf::int32 ignore_label() const;
+ void set_ignore_label(::google::protobuf::int32 value);
+
+ // optional .caffe.LossParameter.NormalizationMode normalization = 3 [default = VALID];
+ bool has_normalization() const;
+ void clear_normalization();
+ static const int kNormalizationFieldNumber = 3;
+ ::caffe::LossParameter_NormalizationMode normalization() const;
+ void set_normalization(::caffe::LossParameter_NormalizationMode value);
+
+ // optional bool normalize = 2;
+ bool has_normalize() const;
+ void clear_normalize();
+ static const int kNormalizeFieldNumber = 2;
+ bool normalize() const;
+ void set_normalize(bool value);
+
+ // @@protoc_insertion_point(class_scope:caffe.LossParameter)
+ private:
+ inline void set_has_ignore_label();
+ inline void clear_has_ignore_label();
+ inline void set_has_normalization();
+ inline void clear_has_normalization();
+ inline void set_has_normalize();
+ inline void clear_has_normalize();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::int32 ignore_label_;
+ bool normalize_;
+ int normalization_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<LossParameter> LossParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class AccuracyParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.AccuracyParameter) */ {
+ public:
+ AccuracyParameter();
+ virtual ~AccuracyParameter();
+
+ AccuracyParameter(const AccuracyParameter& from);
+
+ inline AccuracyParameter& operator=(const AccuracyParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const AccuracyParameter& default_instance();
+
+ static const AccuracyParameter* internal_default_instance();
+
+ void Swap(AccuracyParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline AccuracyParameter* New() const { return New(NULL); }
+
+ AccuracyParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const AccuracyParameter& from);
+ void MergeFrom(const AccuracyParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(AccuracyParameter* other);
+ void UnsafeMergeFrom(const AccuracyParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional uint32 top_k = 1 [default = 1];
+ bool has_top_k() const;
+ void clear_top_k();
+ static const int kTopKFieldNumber = 1;
+ ::google::protobuf::uint32 top_k() const;
+ void set_top_k(::google::protobuf::uint32 value);
+
+ // optional int32 axis = 2 [default = 1];
+ bool has_axis() const;
+ void clear_axis();
+ static const int kAxisFieldNumber = 2;
+ ::google::protobuf::int32 axis() const;
+ void set_axis(::google::protobuf::int32 value);
+
+ // optional int32 ignore_label = 3;
+ bool has_ignore_label() const;
+ void clear_ignore_label();
+ static const int kIgnoreLabelFieldNumber = 3;
+ ::google::protobuf::int32 ignore_label() const;
+ void set_ignore_label(::google::protobuf::int32 value);
+
+ // @@protoc_insertion_point(class_scope:caffe.AccuracyParameter)
+ private:
+ inline void set_has_top_k();
+ inline void clear_has_top_k();
+ inline void set_has_axis();
+ inline void clear_has_axis();
+ inline void set_has_ignore_label();
+ inline void clear_has_ignore_label();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::int32 ignore_label_;
+ ::google::protobuf::uint32 top_k_;
+ ::google::protobuf::int32 axis_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<AccuracyParameter> AccuracyParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class ArgMaxParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ArgMaxParameter) */ {
+ public:
+ ArgMaxParameter();
+ virtual ~ArgMaxParameter();
+
+ ArgMaxParameter(const ArgMaxParameter& from);
+
+ inline ArgMaxParameter& operator=(const ArgMaxParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const ArgMaxParameter& default_instance();
+
+ static const ArgMaxParameter* internal_default_instance();
+
+ void Swap(ArgMaxParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline ArgMaxParameter* New() const { return New(NULL); }
+
+ ArgMaxParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const ArgMaxParameter& from);
+ void MergeFrom(const ArgMaxParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(ArgMaxParameter* other);
+ void UnsafeMergeFrom(const ArgMaxParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional bool out_max_val = 1 [default = false];
+ bool has_out_max_val() const;
+ void clear_out_max_val();
+ static const int kOutMaxValFieldNumber = 1;
+ bool out_max_val() const;
+ void set_out_max_val(bool value);
+
+ // optional uint32 top_k = 2 [default = 1];
+ bool has_top_k() const;
+ void clear_top_k();
+ static const int kTopKFieldNumber = 2;
+ ::google::protobuf::uint32 top_k() const;
+ void set_top_k(::google::protobuf::uint32 value);
+
+ // optional int32 axis = 3;
+ bool has_axis() const;
+ void clear_axis();
+ static const int kAxisFieldNumber = 3;
+ ::google::protobuf::int32 axis() const;
+ void set_axis(::google::protobuf::int32 value);
+
+ // @@protoc_insertion_point(class_scope:caffe.ArgMaxParameter)
+ private:
+ inline void set_has_out_max_val();
+ inline void clear_has_out_max_val();
+ inline void set_has_top_k();
+ inline void clear_has_top_k();
+ inline void set_has_axis();
+ inline void clear_has_axis();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ bool out_max_val_;
+ ::google::protobuf::int32 axis_;
+ ::google::protobuf::uint32 top_k_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<ArgMaxParameter> ArgMaxParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class ConcatParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ConcatParameter) */ {
+ public:
+ ConcatParameter();
+ virtual ~ConcatParameter();
+
+ ConcatParameter(const ConcatParameter& from);
+
+ inline ConcatParameter& operator=(const ConcatParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const ConcatParameter& default_instance();
+
+ static const ConcatParameter* internal_default_instance();
+
+ void Swap(ConcatParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline ConcatParameter* New() const { return New(NULL); }
+
+ ConcatParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const ConcatParameter& from);
+ void MergeFrom(const ConcatParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(ConcatParameter* other);
+ void UnsafeMergeFrom(const ConcatParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional int32 axis = 2 [default = 1];
+ bool has_axis() const;
+ void clear_axis();
+ static const int kAxisFieldNumber = 2;
+ ::google::protobuf::int32 axis() const;
+ void set_axis(::google::protobuf::int32 value);
+
+ // optional uint32 concat_dim = 1 [default = 1];
+ bool has_concat_dim() const;
+ void clear_concat_dim();
+ static const int kConcatDimFieldNumber = 1;
+ ::google::protobuf::uint32 concat_dim() const;
+ void set_concat_dim(::google::protobuf::uint32 value);
+
+ // @@protoc_insertion_point(class_scope:caffe.ConcatParameter)
+ private:
+ inline void set_has_axis();
+ inline void clear_has_axis();
+ inline void set_has_concat_dim();
+ inline void clear_has_concat_dim();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::int32 axis_;
+ ::google::protobuf::uint32 concat_dim_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<ConcatParameter> ConcatParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class BatchNormParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.BatchNormParameter) */ {
+ public:
+ BatchNormParameter();
+ virtual ~BatchNormParameter();
+
+ BatchNormParameter(const BatchNormParameter& from);
+
+ inline BatchNormParameter& operator=(const BatchNormParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const BatchNormParameter& default_instance();
+
+ static const BatchNormParameter* internal_default_instance();
+
+ void Swap(BatchNormParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline BatchNormParameter* New() const { return New(NULL); }
+
+ BatchNormParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const BatchNormParameter& from);
+ void MergeFrom(const BatchNormParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(BatchNormParameter* other);
+ void UnsafeMergeFrom(const BatchNormParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional bool use_global_stats = 1;
+ bool has_use_global_stats() const;
+ void clear_use_global_stats();
+ static const int kUseGlobalStatsFieldNumber = 1;
+ bool use_global_stats() const;
+ void set_use_global_stats(bool value);
+
+ // optional float moving_average_fraction = 2 [default = 0.999];
+ bool has_moving_average_fraction() const;
+ void clear_moving_average_fraction();
+ static const int kMovingAverageFractionFieldNumber = 2;
+ float moving_average_fraction() const;
+ void set_moving_average_fraction(float value);
+
+ // optional float eps = 3 [default = 1e-05];
+ bool has_eps() const;
+ void clear_eps();
+ static const int kEpsFieldNumber = 3;
+ float eps() const;
+ void set_eps(float value);
+
+ // @@protoc_insertion_point(class_scope:caffe.BatchNormParameter)
+ private:
+ inline void set_has_use_global_stats();
+ inline void clear_has_use_global_stats();
+ inline void set_has_moving_average_fraction();
+ inline void clear_has_moving_average_fraction();
+ inline void set_has_eps();
+ inline void clear_has_eps();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ bool use_global_stats_;
+ float moving_average_fraction_;
+ float eps_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<BatchNormParameter> BatchNormParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class BiasParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.BiasParameter) */ {
+ public:
+ BiasParameter();
+ virtual ~BiasParameter();
+
+ BiasParameter(const BiasParameter& from);
+
+ inline BiasParameter& operator=(const BiasParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const BiasParameter& default_instance();
+
+ static const BiasParameter* internal_default_instance();
+
+ void Swap(BiasParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline BiasParameter* New() const { return New(NULL); }
+
+ BiasParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const BiasParameter& from);
+ void MergeFrom(const BiasParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(BiasParameter* other);
+ void UnsafeMergeFrom(const BiasParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional int32 axis = 1 [default = 1];
+ bool has_axis() const;
+ void clear_axis();
+ static const int kAxisFieldNumber = 1;
+ ::google::protobuf::int32 axis() const;
+ void set_axis(::google::protobuf::int32 value);
+
+ // optional int32 num_axes = 2 [default = 1];
+ bool has_num_axes() const;
+ void clear_num_axes();
+ static const int kNumAxesFieldNumber = 2;
+ ::google::protobuf::int32 num_axes() const;
+ void set_num_axes(::google::protobuf::int32 value);
+
+ // optional .caffe.FillerParameter filler = 3;
+ bool has_filler() const;
+ void clear_filler();
+ static const int kFillerFieldNumber = 3;
+ const ::caffe::FillerParameter& filler() const;
+ ::caffe::FillerParameter* mutable_filler();
+ ::caffe::FillerParameter* release_filler();
+ void set_allocated_filler(::caffe::FillerParameter* filler);
+
+ // @@protoc_insertion_point(class_scope:caffe.BiasParameter)
+ private:
+ inline void set_has_axis();
+ inline void clear_has_axis();
+ inline void set_has_num_axes();
+ inline void clear_has_num_axes();
+ inline void set_has_filler();
+ inline void clear_has_filler();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::caffe::FillerParameter* filler_;
+ ::google::protobuf::int32 axis_;
+ ::google::protobuf::int32 num_axes_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<BiasParameter> BiasParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class ContrastiveLossParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ContrastiveLossParameter) */ {
+ public:
+ ContrastiveLossParameter();
+ virtual ~ContrastiveLossParameter();
+
+ ContrastiveLossParameter(const ContrastiveLossParameter& from);
+
+ inline ContrastiveLossParameter& operator=(const ContrastiveLossParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const ContrastiveLossParameter& default_instance();
+
+ static const ContrastiveLossParameter* internal_default_instance();
+
+ void Swap(ContrastiveLossParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline ContrastiveLossParameter* New() const { return New(NULL); }
+
+ ContrastiveLossParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const ContrastiveLossParameter& from);
+ void MergeFrom(const ContrastiveLossParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(ContrastiveLossParameter* other);
+ void UnsafeMergeFrom(const ContrastiveLossParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional float margin = 1 [default = 1];
+ bool has_margin() const;
+ void clear_margin();
+ static const int kMarginFieldNumber = 1;
+ float margin() const;
+ void set_margin(float value);
+
+ // optional bool legacy_version = 2 [default = false];
+ bool has_legacy_version() const;
+ void clear_legacy_version();
+ static const int kLegacyVersionFieldNumber = 2;
+ bool legacy_version() const;
+ void set_legacy_version(bool value);
+
+ // @@protoc_insertion_point(class_scope:caffe.ContrastiveLossParameter)
+ private:
+ inline void set_has_margin();
+ inline void clear_has_margin();
+ inline void set_has_legacy_version();
+ inline void clear_has_legacy_version();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ bool legacy_version_;
+ float margin_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<ContrastiveLossParameter> ContrastiveLossParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class ConvolutionParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ConvolutionParameter) */ {
+ public:
+ ConvolutionParameter();
+ virtual ~ConvolutionParameter();
+
+ ConvolutionParameter(const ConvolutionParameter& from);
+
+ inline ConvolutionParameter& operator=(const ConvolutionParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const ConvolutionParameter& default_instance();
+
+ static const ConvolutionParameter* internal_default_instance();
+
+ void Swap(ConvolutionParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline ConvolutionParameter* New() const { return New(NULL); }
+
+ ConvolutionParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const ConvolutionParameter& from);
+ void MergeFrom(const ConvolutionParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(ConvolutionParameter* other);
+ void UnsafeMergeFrom(const ConvolutionParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ typedef ConvolutionParameter_Engine Engine;
+ static const Engine DEFAULT =
+ ConvolutionParameter_Engine_DEFAULT;
+ static const Engine CAFFE =
+ ConvolutionParameter_Engine_CAFFE;
+ static const Engine CUDNN =
+ ConvolutionParameter_Engine_CUDNN;
+ static inline bool Engine_IsValid(int value) {
+ return ConvolutionParameter_Engine_IsValid(value);
+ }
+ static const Engine Engine_MIN =
+ ConvolutionParameter_Engine_Engine_MIN;
+ static const Engine Engine_MAX =
+ ConvolutionParameter_Engine_Engine_MAX;
+ static const int Engine_ARRAYSIZE =
+ ConvolutionParameter_Engine_Engine_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ Engine_descriptor() {
+ return ConvolutionParameter_Engine_descriptor();
+ }
+ static inline const ::std::string& Engine_Name(Engine value) {
+ return ConvolutionParameter_Engine_Name(value);
+ }
+ static inline bool Engine_Parse(const ::std::string& name,
+ Engine* value) {
+ return ConvolutionParameter_Engine_Parse(name, value);
+ }
+
+ // accessors -------------------------------------------------------
+
+ // optional uint32 num_output = 1;
+ bool has_num_output() const;
+ void clear_num_output();
+ static const int kNumOutputFieldNumber = 1;
+ ::google::protobuf::uint32 num_output() const;
+ void set_num_output(::google::protobuf::uint32 value);
+
+ // optional bool bias_term = 2 [default = true];
+ bool has_bias_term() const;
+ void clear_bias_term();
+ static const int kBiasTermFieldNumber = 2;
+ bool bias_term() const;
+ void set_bias_term(bool value);
+
+ // repeated uint32 pad = 3;
+ int pad_size() const;
+ void clear_pad();
+ static const int kPadFieldNumber = 3;
+ ::google::protobuf::uint32 pad(int index) const;
+ void set_pad(int index, ::google::protobuf::uint32 value);
+ void add_pad(::google::protobuf::uint32 value);
+ const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+ pad() const;
+ ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+ mutable_pad();
+
+ // repeated uint32 kernel_size = 4;
+ int kernel_size_size() const;
+ void clear_kernel_size();
+ static const int kKernelSizeFieldNumber = 4;
+ ::google::protobuf::uint32 kernel_size(int index) const;
+ void set_kernel_size(int index, ::google::protobuf::uint32 value);
+ void add_kernel_size(::google::protobuf::uint32 value);
+ const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+ kernel_size() const;
+ ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+ mutable_kernel_size();
+
+ // repeated uint32 stride = 6;
+ int stride_size() const;
+ void clear_stride();
+ static const int kStrideFieldNumber = 6;
+ ::google::protobuf::uint32 stride(int index) const;
+ void set_stride(int index, ::google::protobuf::uint32 value);
+ void add_stride(::google::protobuf::uint32 value);
+ const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+ stride() const;
+ ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+ mutable_stride();
+
+ // repeated uint32 dilation = 18;
+ int dilation_size() const;
+ void clear_dilation();
+ static const int kDilationFieldNumber = 18;
+ ::google::protobuf::uint32 dilation(int index) const;
+ void set_dilation(int index, ::google::protobuf::uint32 value);
+ void add_dilation(::google::protobuf::uint32 value);
+ const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+ dilation() const;
+ ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+ mutable_dilation();
+
+ // optional uint32 pad_h = 9 [default = 0];
+ bool has_pad_h() const;
+ void clear_pad_h();
+ static const int kPadHFieldNumber = 9;
+ ::google::protobuf::uint32 pad_h() const;
+ void set_pad_h(::google::protobuf::uint32 value);
+
+ // optional uint32 pad_w = 10 [default = 0];
+ bool has_pad_w() const;
+ void clear_pad_w();
+ static const int kPadWFieldNumber = 10;
+ ::google::protobuf::uint32 pad_w() const;
+ void set_pad_w(::google::protobuf::uint32 value);
+
+ // optional uint32 kernel_h = 11;
+ bool has_kernel_h() const;
+ void clear_kernel_h();
+ static const int kKernelHFieldNumber = 11;
+ ::google::protobuf::uint32 kernel_h() const;
+ void set_kernel_h(::google::protobuf::uint32 value);
+
+ // optional uint32 kernel_w = 12;
+ bool has_kernel_w() const;
+ void clear_kernel_w();
+ static const int kKernelWFieldNumber = 12;
+ ::google::protobuf::uint32 kernel_w() const;
+ void set_kernel_w(::google::protobuf::uint32 value);
+
+ // optional uint32 stride_h = 13;
+ bool has_stride_h() const;
+ void clear_stride_h();
+ static const int kStrideHFieldNumber = 13;
+ ::google::protobuf::uint32 stride_h() const;
+ void set_stride_h(::google::protobuf::uint32 value);
+
+ // optional uint32 stride_w = 14;
+ bool has_stride_w() const;
+ void clear_stride_w();
+ static const int kStrideWFieldNumber = 14;
+ ::google::protobuf::uint32 stride_w() const;
+ void set_stride_w(::google::protobuf::uint32 value);
+
+ // optional uint32 group = 5 [default = 1];
+ bool has_group() const;
+ void clear_group();
+ static const int kGroupFieldNumber = 5;
+ ::google::protobuf::uint32 group() const;
+ void set_group(::google::protobuf::uint32 value);
+
+ // optional .caffe.FillerParameter weight_filler = 7;
+ bool has_weight_filler() const;
+ void clear_weight_filler();
+ static const int kWeightFillerFieldNumber = 7;
+ const ::caffe::FillerParameter& weight_filler() const;
+ ::caffe::FillerParameter* mutable_weight_filler();
+ ::caffe::FillerParameter* release_weight_filler();
+ void set_allocated_weight_filler(::caffe::FillerParameter* weight_filler);
+
+ // optional .caffe.FillerParameter bias_filler = 8;
+ bool has_bias_filler() const;
+ void clear_bias_filler();
+ static const int kBiasFillerFieldNumber = 8;
+ const ::caffe::FillerParameter& bias_filler() const;
+ ::caffe::FillerParameter* mutable_bias_filler();
+ ::caffe::FillerParameter* release_bias_filler();
+ void set_allocated_bias_filler(::caffe::FillerParameter* bias_filler);
+
+ // optional .caffe.ConvolutionParameter.Engine engine = 15 [default = DEFAULT];
+ bool has_engine() const;
+ void clear_engine();
+ static const int kEngineFieldNumber = 15;
+ ::caffe::ConvolutionParameter_Engine engine() const;
+ void set_engine(::caffe::ConvolutionParameter_Engine value);
+
+ // optional int32 axis = 16 [default = 1];
+ bool has_axis() const;
+ void clear_axis();
+ static const int kAxisFieldNumber = 16;
+ ::google::protobuf::int32 axis() const;
+ void set_axis(::google::protobuf::int32 value);
+
+ // optional bool force_nd_im2col = 17 [default = false];
+ bool has_force_nd_im2col() const;
+ void clear_force_nd_im2col();
+ static const int kForceNdIm2ColFieldNumber = 17;
+ bool force_nd_im2col() const;
+ void set_force_nd_im2col(bool value);
+
+ // @@protoc_insertion_point(class_scope:caffe.ConvolutionParameter)
+ private:
+ inline void set_has_num_output();
+ inline void clear_has_num_output();
+ inline void set_has_bias_term();
+ inline void clear_has_bias_term();
+ inline void set_has_pad_h();
+ inline void clear_has_pad_h();
+ inline void set_has_pad_w();
+ inline void clear_has_pad_w();
+ inline void set_has_kernel_h();
+ inline void clear_has_kernel_h();
+ inline void set_has_kernel_w();
+ inline void clear_has_kernel_w();
+ inline void set_has_stride_h();
+ inline void clear_has_stride_h();
+ inline void set_has_stride_w();
+ inline void clear_has_stride_w();
+ inline void set_has_group();
+ inline void clear_has_group();
+ inline void set_has_weight_filler();
+ inline void clear_has_weight_filler();
+ inline void set_has_bias_filler();
+ inline void clear_has_bias_filler();
+ inline void set_has_engine();
+ inline void clear_has_engine();
+ inline void set_has_axis();
+ inline void clear_has_axis();
+ inline void set_has_force_nd_im2col();
+ inline void clear_has_force_nd_im2col();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > pad_;
+ ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > kernel_size_;
+ ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > stride_;
+ ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > dilation_;
+ ::caffe::FillerParameter* weight_filler_;
+ ::caffe::FillerParameter* bias_filler_;
+ ::google::protobuf::uint32 num_output_;
+ ::google::protobuf::uint32 pad_h_;
+ ::google::protobuf::uint32 pad_w_;
+ ::google::protobuf::uint32 kernel_h_;
+ ::google::protobuf::uint32 kernel_w_;
+ ::google::protobuf::uint32 stride_h_;
+ ::google::protobuf::uint32 stride_w_;
+ int engine_;
+ bool force_nd_im2col_;
+ ::google::protobuf::int32 axis_;
+ bool bias_term_;
+ ::google::protobuf::uint32 group_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<ConvolutionParameter> ConvolutionParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class CropParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.CropParameter) */ {
+ public:
+ CropParameter();
+ virtual ~CropParameter();
+
+ CropParameter(const CropParameter& from);
+
+ inline CropParameter& operator=(const CropParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const CropParameter& default_instance();
+
+ static const CropParameter* internal_default_instance();
+
+ void Swap(CropParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline CropParameter* New() const { return New(NULL); }
+
+ CropParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const CropParameter& from);
+ void MergeFrom(const CropParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(CropParameter* other);
+ void UnsafeMergeFrom(const CropParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional int32 axis = 1 [default = 2];
+ bool has_axis() const;
+ void clear_axis();
+ static const int kAxisFieldNumber = 1;
+ ::google::protobuf::int32 axis() const;
+ void set_axis(::google::protobuf::int32 value);
+
+ // repeated uint32 offset = 2;
+ int offset_size() const;
+ void clear_offset();
+ static const int kOffsetFieldNumber = 2;
+ ::google::protobuf::uint32 offset(int index) const;
+ void set_offset(int index, ::google::protobuf::uint32 value);
+ void add_offset(::google::protobuf::uint32 value);
+ const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+ offset() const;
+ ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+ mutable_offset();
+
+ // @@protoc_insertion_point(class_scope:caffe.CropParameter)
+ private:
+ inline void set_has_axis();
+ inline void clear_has_axis();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > offset_;
+ ::google::protobuf::int32 axis_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<CropParameter> CropParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class DataParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.DataParameter) */ {
+ public:
+ DataParameter();
+ virtual ~DataParameter();
+
+ DataParameter(const DataParameter& from);
+
+ inline DataParameter& operator=(const DataParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const DataParameter& default_instance();
+
+ static const DataParameter* internal_default_instance();
+
+ void Swap(DataParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline DataParameter* New() const { return New(NULL); }
+
+ DataParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const DataParameter& from);
+ void MergeFrom(const DataParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(DataParameter* other);
+ void UnsafeMergeFrom(const DataParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ typedef DataParameter_DB DB;
+ static const DB LEVELDB =
+ DataParameter_DB_LEVELDB;
+ static const DB LMDB =
+ DataParameter_DB_LMDB;
+ static inline bool DB_IsValid(int value) {
+ return DataParameter_DB_IsValid(value);
+ }
+ static const DB DB_MIN =
+ DataParameter_DB_DB_MIN;
+ static const DB DB_MAX =
+ DataParameter_DB_DB_MAX;
+ static const int DB_ARRAYSIZE =
+ DataParameter_DB_DB_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ DB_descriptor() {
+ return DataParameter_DB_descriptor();
+ }
+ static inline const ::std::string& DB_Name(DB value) {
+ return DataParameter_DB_Name(value);
+ }
+ static inline bool DB_Parse(const ::std::string& name,
+ DB* value) {
+ return DataParameter_DB_Parse(name, value);
+ }
+
+ // accessors -------------------------------------------------------
+
+ // optional string source = 1;
+ bool has_source() const;
+ void clear_source();
+ static const int kSourceFieldNumber = 1;
+ const ::std::string& source() const;
+ void set_source(const ::std::string& value);
+ void set_source(const char* value);
+ void set_source(const char* value, size_t size);
+ ::std::string* mutable_source();
+ ::std::string* release_source();
+ void set_allocated_source(::std::string* source);
+
+ // optional uint32 batch_size = 4;
+ bool has_batch_size() const;
+ void clear_batch_size();
+ static const int kBatchSizeFieldNumber = 4;
+ ::google::protobuf::uint32 batch_size() const;
+ void set_batch_size(::google::protobuf::uint32 value);
+
+ // optional uint32 rand_skip = 7 [default = 0];
+ bool has_rand_skip() const;
+ void clear_rand_skip();
+ static const int kRandSkipFieldNumber = 7;
+ ::google::protobuf::uint32 rand_skip() const;
+ void set_rand_skip(::google::protobuf::uint32 value);
+
+ // optional .caffe.DataParameter.DB backend = 8 [default = LEVELDB];
+ bool has_backend() const;
+ void clear_backend();
+ static const int kBackendFieldNumber = 8;
+ ::caffe::DataParameter_DB backend() const;
+ void set_backend(::caffe::DataParameter_DB value);
+
+ // optional float scale = 2 [default = 1];
+ bool has_scale() const;
+ void clear_scale();
+ static const int kScaleFieldNumber = 2;
+ float scale() const;
+ void set_scale(float value);
+
+ // optional string mean_file = 3;
+ bool has_mean_file() const;
+ void clear_mean_file();
+ static const int kMeanFileFieldNumber = 3;
+ const ::std::string& mean_file() const;
+ void set_mean_file(const ::std::string& value);
+ void set_mean_file(const char* value);
+ void set_mean_file(const char* value, size_t size);
+ ::std::string* mutable_mean_file();
+ ::std::string* release_mean_file();
+ void set_allocated_mean_file(::std::string* mean_file);
+
+ // optional uint32 crop_size = 5 [default = 0];
+ bool has_crop_size() const;
+ void clear_crop_size();
+ static const int kCropSizeFieldNumber = 5;
+ ::google::protobuf::uint32 crop_size() const;
+ void set_crop_size(::google::protobuf::uint32 value);
+
+ // optional bool mirror = 6 [default = false];
+ bool has_mirror() const;
+ void clear_mirror();
+ static const int kMirrorFieldNumber = 6;
+ bool mirror() const;
+ void set_mirror(bool value);
+
+ // optional bool force_encoded_color = 9 [default = false];
+ bool has_force_encoded_color() const;
+ void clear_force_encoded_color();
+ static const int kForceEncodedColorFieldNumber = 9;
+ bool force_encoded_color() const;
+ void set_force_encoded_color(bool value);
+
+ // optional uint32 prefetch = 10 [default = 4];
+ bool has_prefetch() const;
+ void clear_prefetch();
+ static const int kPrefetchFieldNumber = 10;
+ ::google::protobuf::uint32 prefetch() const;
+ void set_prefetch(::google::protobuf::uint32 value);
+
+ // @@protoc_insertion_point(class_scope:caffe.DataParameter)
+ private:
+ inline void set_has_source();
+ inline void clear_has_source();
+ inline void set_has_batch_size();
+ inline void clear_has_batch_size();
+ inline void set_has_rand_skip();
+ inline void clear_has_rand_skip();
+ inline void set_has_backend();
+ inline void clear_has_backend();
+ inline void set_has_scale();
+ inline void clear_has_scale();
+ inline void set_has_mean_file();
+ inline void clear_has_mean_file();
+ inline void set_has_crop_size();
+ inline void clear_has_crop_size();
+ inline void set_has_mirror();
+ inline void clear_has_mirror();
+ inline void set_has_force_encoded_color();
+ inline void clear_has_force_encoded_color();
+ inline void set_has_prefetch();
+ inline void clear_has_prefetch();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::internal::ArenaStringPtr source_;
+ ::google::protobuf::internal::ArenaStringPtr mean_file_;
+ ::google::protobuf::uint32 batch_size_;
+ ::google::protobuf::uint32 rand_skip_;
+ int backend_;
+ ::google::protobuf::uint32 crop_size_;
+ bool mirror_;
+ bool force_encoded_color_;
+ float scale_;
+ ::google::protobuf::uint32 prefetch_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<DataParameter> DataParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class NonMaximumSuppressionParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.NonMaximumSuppressionParameter) */ {
+ public:
+ NonMaximumSuppressionParameter();
+ virtual ~NonMaximumSuppressionParameter();
+
+ NonMaximumSuppressionParameter(const NonMaximumSuppressionParameter& from);
+
+ inline NonMaximumSuppressionParameter& operator=(const NonMaximumSuppressionParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const NonMaximumSuppressionParameter& default_instance();
+
+ static const NonMaximumSuppressionParameter* internal_default_instance();
+
+ void Swap(NonMaximumSuppressionParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline NonMaximumSuppressionParameter* New() const { return New(NULL); }
+
+ NonMaximumSuppressionParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const NonMaximumSuppressionParameter& from);
+ void MergeFrom(const NonMaximumSuppressionParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(NonMaximumSuppressionParameter* other);
+ void UnsafeMergeFrom(const NonMaximumSuppressionParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional float nms_threshold = 1 [default = 0.3];
+ bool has_nms_threshold() const;
+ void clear_nms_threshold();
+ static const int kNmsThresholdFieldNumber = 1;
+ float nms_threshold() const;
+ void set_nms_threshold(float value);
+
+ // optional int32 top_k = 2;
+ bool has_top_k() const;
+ void clear_top_k();
+ static const int kTopKFieldNumber = 2;
+ ::google::protobuf::int32 top_k() const;
+ void set_top_k(::google::protobuf::int32 value);
+
+ // optional float eta = 3 [default = 1];
+ bool has_eta() const;
+ void clear_eta();
+ static const int kEtaFieldNumber = 3;
+ float eta() const;
+ void set_eta(float value);
+
+ // @@protoc_insertion_point(class_scope:caffe.NonMaximumSuppressionParameter)
+ private:
+ inline void set_has_nms_threshold();
+ inline void clear_has_nms_threshold();
+ inline void set_has_top_k();
+ inline void clear_has_top_k();
+ inline void set_has_eta();
+ inline void clear_has_eta();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::int32 top_k_;
+ float nms_threshold_;
+ float eta_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<NonMaximumSuppressionParameter> NonMaximumSuppressionParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class SaveOutputParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.SaveOutputParameter) */ {
+ public:
+ SaveOutputParameter();
+ virtual ~SaveOutputParameter();
+
+ SaveOutputParameter(const SaveOutputParameter& from);
+
+ inline SaveOutputParameter& operator=(const SaveOutputParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const SaveOutputParameter& default_instance();
+
+ static const SaveOutputParameter* internal_default_instance();
+
+ void Swap(SaveOutputParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline SaveOutputParameter* New() const { return New(NULL); }
+
+ SaveOutputParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const SaveOutputParameter& from);
+ void MergeFrom(const SaveOutputParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(SaveOutputParameter* other);
+ void UnsafeMergeFrom(const SaveOutputParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional string output_directory = 1;
+ bool has_output_directory() const;
+ void clear_output_directory();
+ static const int kOutputDirectoryFieldNumber = 1;
+ const ::std::string& output_directory() const;
+ void set_output_directory(const ::std::string& value);
+ void set_output_directory(const char* value);
+ void set_output_directory(const char* value, size_t size);
+ ::std::string* mutable_output_directory();
+ ::std::string* release_output_directory();
+ void set_allocated_output_directory(::std::string* output_directory);
+
+ // optional string output_name_prefix = 2;
+ bool has_output_name_prefix() const;
+ void clear_output_name_prefix();
+ static const int kOutputNamePrefixFieldNumber = 2;
+ const ::std::string& output_name_prefix() const;
+ void set_output_name_prefix(const ::std::string& value);
+ void set_output_name_prefix(const char* value);
+ void set_output_name_prefix(const char* value, size_t size);
+ ::std::string* mutable_output_name_prefix();
+ ::std::string* release_output_name_prefix();
+ void set_allocated_output_name_prefix(::std::string* output_name_prefix);
+
+ // optional string output_format = 3;
+ bool has_output_format() const;
+ void clear_output_format();
+ static const int kOutputFormatFieldNumber = 3;
+ const ::std::string& output_format() const;
+ void set_output_format(const ::std::string& value);
+ void set_output_format(const char* value);
+ void set_output_format(const char* value, size_t size);
+ ::std::string* mutable_output_format();
+ ::std::string* release_output_format();
+ void set_allocated_output_format(::std::string* output_format);
+
+ // optional string label_map_file = 4;
+ bool has_label_map_file() const;
+ void clear_label_map_file();
+ static const int kLabelMapFileFieldNumber = 4;
+ const ::std::string& label_map_file() const;
+ void set_label_map_file(const ::std::string& value);
+ void set_label_map_file(const char* value);
+ void set_label_map_file(const char* value, size_t size);
+ ::std::string* mutable_label_map_file();
+ ::std::string* release_label_map_file();
+ void set_allocated_label_map_file(::std::string* label_map_file);
+
+ // optional string name_size_file = 5;
+ bool has_name_size_file() const;
+ void clear_name_size_file();
+ static const int kNameSizeFileFieldNumber = 5;
+ const ::std::string& name_size_file() const;
+ void set_name_size_file(const ::std::string& value);
+ void set_name_size_file(const char* value);
+ void set_name_size_file(const char* value, size_t size);
+ ::std::string* mutable_name_size_file();
+ ::std::string* release_name_size_file();
+ void set_allocated_name_size_file(::std::string* name_size_file);
+
+ // optional uint32 num_test_image = 6;
+ bool has_num_test_image() const;
+ void clear_num_test_image();
+ static const int kNumTestImageFieldNumber = 6;
+ ::google::protobuf::uint32 num_test_image() const;
+ void set_num_test_image(::google::protobuf::uint32 value);
+
+ // @@protoc_insertion_point(class_scope:caffe.SaveOutputParameter)
+ private:
+ inline void set_has_output_directory();
+ inline void clear_has_output_directory();
+ inline void set_has_output_name_prefix();
+ inline void clear_has_output_name_prefix();
+ inline void set_has_output_format();
+ inline void clear_has_output_format();
+ inline void set_has_label_map_file();
+ inline void clear_has_label_map_file();
+ inline void set_has_name_size_file();
+ inline void clear_has_name_size_file();
+ inline void set_has_num_test_image();
+ inline void clear_has_num_test_image();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::internal::ArenaStringPtr output_directory_;
+ ::google::protobuf::internal::ArenaStringPtr output_name_prefix_;
+ ::google::protobuf::internal::ArenaStringPtr output_format_;
+ ::google::protobuf::internal::ArenaStringPtr label_map_file_;
+ ::google::protobuf::internal::ArenaStringPtr name_size_file_;
+ ::google::protobuf::uint32 num_test_image_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<SaveOutputParameter> SaveOutputParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class DropoutParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.DropoutParameter) */ {
+ public:
+ DropoutParameter();
+ virtual ~DropoutParameter();
+
+ DropoutParameter(const DropoutParameter& from);
+
+ inline DropoutParameter& operator=(const DropoutParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const DropoutParameter& default_instance();
+
+ static const DropoutParameter* internal_default_instance();
+
+ void Swap(DropoutParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline DropoutParameter* New() const { return New(NULL); }
+
+ DropoutParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const DropoutParameter& from);
+ void MergeFrom(const DropoutParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(DropoutParameter* other);
+ void UnsafeMergeFrom(const DropoutParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional float dropout_ratio = 1 [default = 0.5];
+ bool has_dropout_ratio() const;
+ void clear_dropout_ratio();
+ static const int kDropoutRatioFieldNumber = 1;
+ float dropout_ratio() const;
+ void set_dropout_ratio(float value);
+
+ // @@protoc_insertion_point(class_scope:caffe.DropoutParameter)
+ private:
+ inline void set_has_dropout_ratio();
+ inline void clear_has_dropout_ratio();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ float dropout_ratio_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<DropoutParameter> DropoutParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class DummyDataParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.DummyDataParameter) */ {
+ public:
+ DummyDataParameter();
+ virtual ~DummyDataParameter();
+
+ DummyDataParameter(const DummyDataParameter& from);
+
+ inline DummyDataParameter& operator=(const DummyDataParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const DummyDataParameter& default_instance();
+
+ static const DummyDataParameter* internal_default_instance();
+
+ void Swap(DummyDataParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline DummyDataParameter* New() const { return New(NULL); }
+
+ DummyDataParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const DummyDataParameter& from);
+ void MergeFrom(const DummyDataParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(DummyDataParameter* other);
+ void UnsafeMergeFrom(const DummyDataParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // repeated .caffe.FillerParameter data_filler = 1;
+ int data_filler_size() const;
+ void clear_data_filler();
+ static const int kDataFillerFieldNumber = 1;
+ const ::caffe::FillerParameter& data_filler(int index) const;
+ ::caffe::FillerParameter* mutable_data_filler(int index);
+ ::caffe::FillerParameter* add_data_filler();
+ ::google::protobuf::RepeatedPtrField< ::caffe::FillerParameter >*
+ mutable_data_filler();
+ const ::google::protobuf::RepeatedPtrField< ::caffe::FillerParameter >&
+ data_filler() const;
+
+ // repeated .caffe.BlobShape shape = 6;
+ int shape_size() const;
+ void clear_shape();
+ static const int kShapeFieldNumber = 6;
+ const ::caffe::BlobShape& shape(int index) const;
+ ::caffe::BlobShape* mutable_shape(int index);
+ ::caffe::BlobShape* add_shape();
+ ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >*
+ mutable_shape();
+ const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >&
+ shape() const;
+
+ // repeated uint32 num = 2;
+ int num_size() const;
+ void clear_num();
+ static const int kNumFieldNumber = 2;
+ ::google::protobuf::uint32 num(int index) const;
+ void set_num(int index, ::google::protobuf::uint32 value);
+ void add_num(::google::protobuf::uint32 value);
+ const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+ num() const;
+ ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+ mutable_num();
+
+ // repeated uint32 channels = 3;
+ int channels_size() const;
+ void clear_channels();
+ static const int kChannelsFieldNumber = 3;
+ ::google::protobuf::uint32 channels(int index) const;
+ void set_channels(int index, ::google::protobuf::uint32 value);
+ void add_channels(::google::protobuf::uint32 value);
+ const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+ channels() const;
+ ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+ mutable_channels();
+
+ // repeated uint32 height = 4;
+ int height_size() const;
+ void clear_height();
+ static const int kHeightFieldNumber = 4;
+ ::google::protobuf::uint32 height(int index) const;
+ void set_height(int index, ::google::protobuf::uint32 value);
+ void add_height(::google::protobuf::uint32 value);
+ const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+ height() const;
+ ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+ mutable_height();
+
+ // repeated uint32 width = 5;
+ int width_size() const;
+ void clear_width();
+ static const int kWidthFieldNumber = 5;
+ ::google::protobuf::uint32 width(int index) const;
+ void set_width(int index, ::google::protobuf::uint32 value);
+ void add_width(::google::protobuf::uint32 value);
+ const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+ width() const;
+ ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+ mutable_width();
+
+ // @@protoc_insertion_point(class_scope:caffe.DummyDataParameter)
+ private:
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::RepeatedPtrField< ::caffe::FillerParameter > data_filler_;
+ ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape > shape_;
+ ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > num_;
+ ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > channels_;
+ ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > height_;
+ ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > width_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<DummyDataParameter> DummyDataParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class EltwiseParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.EltwiseParameter) */ {
+ public:
+ EltwiseParameter();
+ virtual ~EltwiseParameter();
+
+ EltwiseParameter(const EltwiseParameter& from);
+
+ inline EltwiseParameter& operator=(const EltwiseParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const EltwiseParameter& default_instance();
+
+ static const EltwiseParameter* internal_default_instance();
+
+ void Swap(EltwiseParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline EltwiseParameter* New() const { return New(NULL); }
+
+ EltwiseParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const EltwiseParameter& from);
+ void MergeFrom(const EltwiseParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(EltwiseParameter* other);
+ void UnsafeMergeFrom(const EltwiseParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ typedef EltwiseParameter_EltwiseOp EltwiseOp;
+ static const EltwiseOp PROD =
+ EltwiseParameter_EltwiseOp_PROD;
+ static const EltwiseOp SUM =
+ EltwiseParameter_EltwiseOp_SUM;
+ static const EltwiseOp MAX =
+ EltwiseParameter_EltwiseOp_MAX;
+ static inline bool EltwiseOp_IsValid(int value) {
+ return EltwiseParameter_EltwiseOp_IsValid(value);
+ }
+ static const EltwiseOp EltwiseOp_MIN =
+ EltwiseParameter_EltwiseOp_EltwiseOp_MIN;
+ static const EltwiseOp EltwiseOp_MAX =
+ EltwiseParameter_EltwiseOp_EltwiseOp_MAX;
+ static const int EltwiseOp_ARRAYSIZE =
+ EltwiseParameter_EltwiseOp_EltwiseOp_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ EltwiseOp_descriptor() {
+ return EltwiseParameter_EltwiseOp_descriptor();
+ }
+ static inline const ::std::string& EltwiseOp_Name(EltwiseOp value) {
+ return EltwiseParameter_EltwiseOp_Name(value);
+ }
+ static inline bool EltwiseOp_Parse(const ::std::string& name,
+ EltwiseOp* value) {
+ return EltwiseParameter_EltwiseOp_Parse(name, value);
+ }
+
+ // accessors -------------------------------------------------------
+
+ // optional .caffe.EltwiseParameter.EltwiseOp operation = 1 [default = SUM];
+ bool has_operation() const;
+ void clear_operation();
+ static const int kOperationFieldNumber = 1;
+ ::caffe::EltwiseParameter_EltwiseOp operation() const;
+ void set_operation(::caffe::EltwiseParameter_EltwiseOp value);
+
+ // repeated float coeff = 2;
+ int coeff_size() const;
+ void clear_coeff();
+ static const int kCoeffFieldNumber = 2;
+ float coeff(int index) const;
+ void set_coeff(int index, float value);
+ void add_coeff(float value);
+ const ::google::protobuf::RepeatedField< float >&
+ coeff() const;
+ ::google::protobuf::RepeatedField< float >*
+ mutable_coeff();
+
+ // optional bool stable_prod_grad = 3 [default = true];
+ bool has_stable_prod_grad() const;
+ void clear_stable_prod_grad();
+ static const int kStableProdGradFieldNumber = 3;
+ bool stable_prod_grad() const;
+ void set_stable_prod_grad(bool value);
+
+ // @@protoc_insertion_point(class_scope:caffe.EltwiseParameter)
+ private:
+ inline void set_has_operation();
+ inline void clear_has_operation();
+ inline void set_has_stable_prod_grad();
+ inline void clear_has_stable_prod_grad();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::RepeatedField< float > coeff_;
+ int operation_;
+ bool stable_prod_grad_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<EltwiseParameter> EltwiseParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class ELUParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ELUParameter) */ {
+ public:
+ ELUParameter();
+ virtual ~ELUParameter();
+
+ ELUParameter(const ELUParameter& from);
+
+ inline ELUParameter& operator=(const ELUParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const ELUParameter& default_instance();
+
+ static const ELUParameter* internal_default_instance();
+
+ void Swap(ELUParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline ELUParameter* New() const { return New(NULL); }
+
+ ELUParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const ELUParameter& from);
+ void MergeFrom(const ELUParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(ELUParameter* other);
+ void UnsafeMergeFrom(const ELUParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional float alpha = 1 [default = 1];
+ bool has_alpha() const;
+ void clear_alpha();
+ static const int kAlphaFieldNumber = 1;
+ float alpha() const;
+ void set_alpha(float value);
+
+ // @@protoc_insertion_point(class_scope:caffe.ELUParameter)
+ private:
+ inline void set_has_alpha();
+ inline void clear_has_alpha();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ float alpha_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<ELUParameter> ELUParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class EmbedParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.EmbedParameter) */ {
+ public:
+ EmbedParameter();
+ virtual ~EmbedParameter();
+
+ EmbedParameter(const EmbedParameter& from);
+
+ inline EmbedParameter& operator=(const EmbedParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const EmbedParameter& default_instance();
+
+ static const EmbedParameter* internal_default_instance();
+
+ void Swap(EmbedParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline EmbedParameter* New() const { return New(NULL); }
+
+ EmbedParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const EmbedParameter& from);
+ void MergeFrom(const EmbedParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(EmbedParameter* other);
+ void UnsafeMergeFrom(const EmbedParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional uint32 num_output = 1;
+ bool has_num_output() const;
+ void clear_num_output();
+ static const int kNumOutputFieldNumber = 1;
+ ::google::protobuf::uint32 num_output() const;
+ void set_num_output(::google::protobuf::uint32 value);
+
+ // optional uint32 input_dim = 2;
+ bool has_input_dim() const;
+ void clear_input_dim();
+ static const int kInputDimFieldNumber = 2;
+ ::google::protobuf::uint32 input_dim() const;
+ void set_input_dim(::google::protobuf::uint32 value);
+
+ // optional bool bias_term = 3 [default = true];
+ bool has_bias_term() const;
+ void clear_bias_term();
+ static const int kBiasTermFieldNumber = 3;
+ bool bias_term() const;
+ void set_bias_term(bool value);
+
+ // optional .caffe.FillerParameter weight_filler = 4;
+ bool has_weight_filler() const;
+ void clear_weight_filler();
+ static const int kWeightFillerFieldNumber = 4;
+ const ::caffe::FillerParameter& weight_filler() const;
+ ::caffe::FillerParameter* mutable_weight_filler();
+ ::caffe::FillerParameter* release_weight_filler();
+ void set_allocated_weight_filler(::caffe::FillerParameter* weight_filler);
+
+ // optional .caffe.FillerParameter bias_filler = 5;
+ bool has_bias_filler() const;
+ void clear_bias_filler();
+ static const int kBiasFillerFieldNumber = 5;
+ const ::caffe::FillerParameter& bias_filler() const;
+ ::caffe::FillerParameter* mutable_bias_filler();
+ ::caffe::FillerParameter* release_bias_filler();
+ void set_allocated_bias_filler(::caffe::FillerParameter* bias_filler);
+
+ // @@protoc_insertion_point(class_scope:caffe.EmbedParameter)
+ private:
+ inline void set_has_num_output();
+ inline void clear_has_num_output();
+ inline void set_has_input_dim();
+ inline void clear_has_input_dim();
+ inline void set_has_bias_term();
+ inline void clear_has_bias_term();
+ inline void set_has_weight_filler();
+ inline void clear_has_weight_filler();
+ inline void set_has_bias_filler();
+ inline void clear_has_bias_filler();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::caffe::FillerParameter* weight_filler_;
+ ::caffe::FillerParameter* bias_filler_;
+ ::google::protobuf::uint32 num_output_;
+ ::google::protobuf::uint32 input_dim_;
+ bool bias_term_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<EmbedParameter> EmbedParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class ExpParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ExpParameter) */ {
+ public:
+ ExpParameter();
+ virtual ~ExpParameter();
+
+ ExpParameter(const ExpParameter& from);
+
+ inline ExpParameter& operator=(const ExpParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const ExpParameter& default_instance();
+
+ static const ExpParameter* internal_default_instance();
+
+ void Swap(ExpParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline ExpParameter* New() const { return New(NULL); }
+
+ ExpParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const ExpParameter& from);
+ void MergeFrom(const ExpParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(ExpParameter* other);
+ void UnsafeMergeFrom(const ExpParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional float base = 1 [default = -1];
+ bool has_base() const;
+ void clear_base();
+ static const int kBaseFieldNumber = 1;
+ float base() const;
+ void set_base(float value);
+
+ // optional float scale = 2 [default = 1];
+ bool has_scale() const;
+ void clear_scale();
+ static const int kScaleFieldNumber = 2;
+ float scale() const;
+ void set_scale(float value);
+
+ // optional float shift = 3 [default = 0];
+ bool has_shift() const;
+ void clear_shift();
+ static const int kShiftFieldNumber = 3;
+ float shift() const;
+ void set_shift(float value);
+
+ // @@protoc_insertion_point(class_scope:caffe.ExpParameter)
+ private:
+ inline void set_has_base();
+ inline void clear_has_base();
+ inline void set_has_scale();
+ inline void clear_has_scale();
+ inline void set_has_shift();
+ inline void clear_has_shift();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ float shift_;
+ float base_;
+ float scale_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<ExpParameter> ExpParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class FlattenParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.FlattenParameter) */ {
+ public:
+ FlattenParameter();
+ virtual ~FlattenParameter();
+
+ FlattenParameter(const FlattenParameter& from);
+
+ inline FlattenParameter& operator=(const FlattenParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const FlattenParameter& default_instance();
+
+ static const FlattenParameter* internal_default_instance();
+
+ void Swap(FlattenParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline FlattenParameter* New() const { return New(NULL); }
+
+ FlattenParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const FlattenParameter& from);
+ void MergeFrom(const FlattenParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(FlattenParameter* other);
+ void UnsafeMergeFrom(const FlattenParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional int32 axis = 1 [default = 1];
+ bool has_axis() const;
+ void clear_axis();
+ static const int kAxisFieldNumber = 1;
+ ::google::protobuf::int32 axis() const;
+ void set_axis(::google::protobuf::int32 value);
+
+ // optional int32 end_axis = 2 [default = -1];
+ bool has_end_axis() const;
+ void clear_end_axis();
+ static const int kEndAxisFieldNumber = 2;
+ ::google::protobuf::int32 end_axis() const;
+ void set_end_axis(::google::protobuf::int32 value);
+
+ // @@protoc_insertion_point(class_scope:caffe.FlattenParameter)
+ private:
+ inline void set_has_axis();
+ inline void clear_has_axis();
+ inline void set_has_end_axis();
+ inline void clear_has_end_axis();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::int32 axis_;
+ ::google::protobuf::int32 end_axis_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<FlattenParameter> FlattenParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class HDF5DataParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.HDF5DataParameter) */ {
+ public:
+ HDF5DataParameter();
+ virtual ~HDF5DataParameter();
+
+ HDF5DataParameter(const HDF5DataParameter& from);
+
+ inline HDF5DataParameter& operator=(const HDF5DataParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const HDF5DataParameter& default_instance();
+
+ static const HDF5DataParameter* internal_default_instance();
+
+ void Swap(HDF5DataParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline HDF5DataParameter* New() const { return New(NULL); }
+
+ HDF5DataParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const HDF5DataParameter& from);
+ void MergeFrom(const HDF5DataParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(HDF5DataParameter* other);
+ void UnsafeMergeFrom(const HDF5DataParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional string source = 1;
+ bool has_source() const;
+ void clear_source();
+ static const int kSourceFieldNumber = 1;
+ const ::std::string& source() const;
+ void set_source(const ::std::string& value);
+ void set_source(const char* value);
+ void set_source(const char* value, size_t size);
+ ::std::string* mutable_source();
+ ::std::string* release_source();
+ void set_allocated_source(::std::string* source);
+
+ // optional uint32 batch_size = 2;
+ bool has_batch_size() const;
+ void clear_batch_size();
+ static const int kBatchSizeFieldNumber = 2;
+ ::google::protobuf::uint32 batch_size() const;
+ void set_batch_size(::google::protobuf::uint32 value);
+
+ // optional bool shuffle = 3 [default = false];
+ bool has_shuffle() const;
+ void clear_shuffle();
+ static const int kShuffleFieldNumber = 3;
+ bool shuffle() const;
+ void set_shuffle(bool value);
+
+ // @@protoc_insertion_point(class_scope:caffe.HDF5DataParameter)
+ private:
+ inline void set_has_source();
+ inline void clear_has_source();
+ inline void set_has_batch_size();
+ inline void clear_has_batch_size();
+ inline void set_has_shuffle();
+ inline void clear_has_shuffle();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::internal::ArenaStringPtr source_;
+ ::google::protobuf::uint32 batch_size_;
+ bool shuffle_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<HDF5DataParameter> HDF5DataParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class HDF5OutputParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.HDF5OutputParameter) */ {
+ public:
+ HDF5OutputParameter();
+ virtual ~HDF5OutputParameter();
+
+ HDF5OutputParameter(const HDF5OutputParameter& from);
+
+ inline HDF5OutputParameter& operator=(const HDF5OutputParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const HDF5OutputParameter& default_instance();
+
+ static const HDF5OutputParameter* internal_default_instance();
+
+ void Swap(HDF5OutputParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline HDF5OutputParameter* New() const { return New(NULL); }
+
+ HDF5OutputParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const HDF5OutputParameter& from);
+ void MergeFrom(const HDF5OutputParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(HDF5OutputParameter* other);
+ void UnsafeMergeFrom(const HDF5OutputParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional string file_name = 1;
+ bool has_file_name() const;
+ void clear_file_name();
+ static const int kFileNameFieldNumber = 1;
+ const ::std::string& file_name() const;
+ void set_file_name(const ::std::string& value);
+ void set_file_name(const char* value);
+ void set_file_name(const char* value, size_t size);
+ ::std::string* mutable_file_name();
+ ::std::string* release_file_name();
+ void set_allocated_file_name(::std::string* file_name);
+
+ // @@protoc_insertion_point(class_scope:caffe.HDF5OutputParameter)
+ private:
+ inline void set_has_file_name();
+ inline void clear_has_file_name();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::internal::ArenaStringPtr file_name_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<HDF5OutputParameter> HDF5OutputParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class HingeLossParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.HingeLossParameter) */ {
+ public:
+ HingeLossParameter();
+ virtual ~HingeLossParameter();
+
+ HingeLossParameter(const HingeLossParameter& from);
+
+ inline HingeLossParameter& operator=(const HingeLossParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const HingeLossParameter& default_instance();
+
+ static const HingeLossParameter* internal_default_instance();
+
+ void Swap(HingeLossParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline HingeLossParameter* New() const { return New(NULL); }
+
+ HingeLossParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const HingeLossParameter& from);
+ void MergeFrom(const HingeLossParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(HingeLossParameter* other);
+ void UnsafeMergeFrom(const HingeLossParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ typedef HingeLossParameter_Norm Norm;
+ static const Norm L1 =
+ HingeLossParameter_Norm_L1;
+ static const Norm L2 =
+ HingeLossParameter_Norm_L2;
+ static inline bool Norm_IsValid(int value) {
+ return HingeLossParameter_Norm_IsValid(value);
+ }
+ static const Norm Norm_MIN =
+ HingeLossParameter_Norm_Norm_MIN;
+ static const Norm Norm_MAX =
+ HingeLossParameter_Norm_Norm_MAX;
+ static const int Norm_ARRAYSIZE =
+ HingeLossParameter_Norm_Norm_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ Norm_descriptor() {
+ return HingeLossParameter_Norm_descriptor();
+ }
+ static inline const ::std::string& Norm_Name(Norm value) {
+ return HingeLossParameter_Norm_Name(value);
+ }
+ static inline bool Norm_Parse(const ::std::string& name,
+ Norm* value) {
+ return HingeLossParameter_Norm_Parse(name, value);
+ }
+
+ // accessors -------------------------------------------------------
+
+ // optional .caffe.HingeLossParameter.Norm norm = 1 [default = L1];
+ bool has_norm() const;
+ void clear_norm();
+ static const int kNormFieldNumber = 1;
+ ::caffe::HingeLossParameter_Norm norm() const;
+ void set_norm(::caffe::HingeLossParameter_Norm value);
+
+ // @@protoc_insertion_point(class_scope:caffe.HingeLossParameter)
+ private:
+ inline void set_has_norm();
+ inline void clear_has_norm();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ int norm_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<HingeLossParameter> HingeLossParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class ImageDataParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ImageDataParameter) */ {
+ public:
+ ImageDataParameter();
+ virtual ~ImageDataParameter();
+
+ ImageDataParameter(const ImageDataParameter& from);
+
+ inline ImageDataParameter& operator=(const ImageDataParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const ImageDataParameter& default_instance();
+
+ static const ImageDataParameter* internal_default_instance();
+
+ void Swap(ImageDataParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline ImageDataParameter* New() const { return New(NULL); }
+
+ ImageDataParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const ImageDataParameter& from);
+ void MergeFrom(const ImageDataParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(ImageDataParameter* other);
+ void UnsafeMergeFrom(const ImageDataParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional string source = 1;
+ bool has_source() const;
+ void clear_source();
+ static const int kSourceFieldNumber = 1;
+ const ::std::string& source() const;
+ void set_source(const ::std::string& value);
+ void set_source(const char* value);
+ void set_source(const char* value, size_t size);
+ ::std::string* mutable_source();
+ ::std::string* release_source();
+ void set_allocated_source(::std::string* source);
+
+ // optional uint32 batch_size = 4 [default = 1];
+ bool has_batch_size() const;
+ void clear_batch_size();
+ static const int kBatchSizeFieldNumber = 4;
+ ::google::protobuf::uint32 batch_size() const;
+ void set_batch_size(::google::protobuf::uint32 value);
+
+ // optional uint32 rand_skip = 7 [default = 0];
+ bool has_rand_skip() const;
+ void clear_rand_skip();
+ static const int kRandSkipFieldNumber = 7;
+ ::google::protobuf::uint32 rand_skip() const;
+ void set_rand_skip(::google::protobuf::uint32 value);
+
+ // optional bool shuffle = 8 [default = false];
+ bool has_shuffle() const;
+ void clear_shuffle();
+ static const int kShuffleFieldNumber = 8;
+ bool shuffle() const;
+ void set_shuffle(bool value);
+
+ // optional uint32 new_height = 9 [default = 0];
+ bool has_new_height() const;
+ void clear_new_height();
+ static const int kNewHeightFieldNumber = 9;
+ ::google::protobuf::uint32 new_height() const;
+ void set_new_height(::google::protobuf::uint32 value);
+
+ // optional uint32 new_width = 10 [default = 0];
+ bool has_new_width() const;
+ void clear_new_width();
+ static const int kNewWidthFieldNumber = 10;
+ ::google::protobuf::uint32 new_width() const;
+ void set_new_width(::google::protobuf::uint32 value);
+
+ // optional bool is_color = 11 [default = true];
+ bool has_is_color() const;
+ void clear_is_color();
+ static const int kIsColorFieldNumber = 11;
+ bool is_color() const;
+ void set_is_color(bool value);
+
+ // optional float scale = 2 [default = 1];
+ bool has_scale() const;
+ void clear_scale();
+ static const int kScaleFieldNumber = 2;
+ float scale() const;
+ void set_scale(float value);
+
+ // optional string mean_file = 3;
+ bool has_mean_file() const;
+ void clear_mean_file();
+ static const int kMeanFileFieldNumber = 3;
+ const ::std::string& mean_file() const;
+ void set_mean_file(const ::std::string& value);
+ void set_mean_file(const char* value);
+ void set_mean_file(const char* value, size_t size);
+ ::std::string* mutable_mean_file();
+ ::std::string* release_mean_file();
+ void set_allocated_mean_file(::std::string* mean_file);
+
+ // optional uint32 crop_size = 5 [default = 0];
+ bool has_crop_size() const;
+ void clear_crop_size();
+ static const int kCropSizeFieldNumber = 5;
+ ::google::protobuf::uint32 crop_size() const;
+ void set_crop_size(::google::protobuf::uint32 value);
+
+ // optional bool mirror = 6 [default = false];
+ bool has_mirror() const;
+ void clear_mirror();
+ static const int kMirrorFieldNumber = 6;
+ bool mirror() const;
+ void set_mirror(bool value);
+
+ // optional string root_folder = 12 [default = ""];
+ bool has_root_folder() const;
+ void clear_root_folder();
+ static const int kRootFolderFieldNumber = 12;
+ const ::std::string& root_folder() const;
+ void set_root_folder(const ::std::string& value);
+ void set_root_folder(const char* value);
+ void set_root_folder(const char* value, size_t size);
+ ::std::string* mutable_root_folder();
+ ::std::string* release_root_folder();
+ void set_allocated_root_folder(::std::string* root_folder);
+
+ // @@protoc_insertion_point(class_scope:caffe.ImageDataParameter)
+ private:
+ inline void set_has_source();
+ inline void clear_has_source();
+ inline void set_has_batch_size();
+ inline void clear_has_batch_size();
+ inline void set_has_rand_skip();
+ inline void clear_has_rand_skip();
+ inline void set_has_shuffle();
+ inline void clear_has_shuffle();
+ inline void set_has_new_height();
+ inline void clear_has_new_height();
+ inline void set_has_new_width();
+ inline void clear_has_new_width();
+ inline void set_has_is_color();
+ inline void clear_has_is_color();
+ inline void set_has_scale();
+ inline void clear_has_scale();
+ inline void set_has_mean_file();
+ inline void clear_has_mean_file();
+ inline void set_has_crop_size();
+ inline void clear_has_crop_size();
+ inline void set_has_mirror();
+ inline void clear_has_mirror();
+ inline void set_has_root_folder();
+ inline void clear_has_root_folder();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::internal::ArenaStringPtr source_;
+ ::google::protobuf::internal::ArenaStringPtr mean_file_;
+ ::google::protobuf::internal::ArenaStringPtr root_folder_;
+ ::google::protobuf::uint32 rand_skip_;
+ ::google::protobuf::uint32 new_height_;
+ ::google::protobuf::uint32 new_width_;
+ bool shuffle_;
+ bool mirror_;
+ ::google::protobuf::uint32 crop_size_;
+ float scale_;
+ ::google::protobuf::uint32 batch_size_;
+ bool is_color_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<ImageDataParameter> ImageDataParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class InfogainLossParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.InfogainLossParameter) */ {
+ public:
+ InfogainLossParameter();
+ virtual ~InfogainLossParameter();
+
+ InfogainLossParameter(const InfogainLossParameter& from);
+
+ inline InfogainLossParameter& operator=(const InfogainLossParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const InfogainLossParameter& default_instance();
+
+ static const InfogainLossParameter* internal_default_instance();
+
+ void Swap(InfogainLossParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline InfogainLossParameter* New() const { return New(NULL); }
+
+ InfogainLossParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const InfogainLossParameter& from);
+ void MergeFrom(const InfogainLossParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(InfogainLossParameter* other);
+ void UnsafeMergeFrom(const InfogainLossParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional string source = 1;
+ bool has_source() const;
+ void clear_source();
+ static const int kSourceFieldNumber = 1;
+ const ::std::string& source() const;
+ void set_source(const ::std::string& value);
+ void set_source(const char* value);
+ void set_source(const char* value, size_t size);
+ ::std::string* mutable_source();
+ ::std::string* release_source();
+ void set_allocated_source(::std::string* source);
+
+ // @@protoc_insertion_point(class_scope:caffe.InfogainLossParameter)
+ private:
+ inline void set_has_source();
+ inline void clear_has_source();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::internal::ArenaStringPtr source_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<InfogainLossParameter> InfogainLossParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class InnerProductParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.InnerProductParameter) */ {
+ public:
+ InnerProductParameter();
+ virtual ~InnerProductParameter();
+
+ InnerProductParameter(const InnerProductParameter& from);
+
+ inline InnerProductParameter& operator=(const InnerProductParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const InnerProductParameter& default_instance();
+
+ static const InnerProductParameter* internal_default_instance();
+
+ void Swap(InnerProductParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline InnerProductParameter* New() const { return New(NULL); }
+
+ InnerProductParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const InnerProductParameter& from);
+ void MergeFrom(const InnerProductParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(InnerProductParameter* other);
+ void UnsafeMergeFrom(const InnerProductParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional uint32 num_output = 1;
+ bool has_num_output() const;
+ void clear_num_output();
+ static const int kNumOutputFieldNumber = 1;
+ ::google::protobuf::uint32 num_output() const;
+ void set_num_output(::google::protobuf::uint32 value);
+
+ // optional bool bias_term = 2 [default = true];
+ bool has_bias_term() const;
+ void clear_bias_term();
+ static const int kBiasTermFieldNumber = 2;
+ bool bias_term() const;
+ void set_bias_term(bool value);
+
+ // optional .caffe.FillerParameter weight_filler = 3;
+ bool has_weight_filler() const;
+ void clear_weight_filler();
+ static const int kWeightFillerFieldNumber = 3;
+ const ::caffe::FillerParameter& weight_filler() const;
+ ::caffe::FillerParameter* mutable_weight_filler();
+ ::caffe::FillerParameter* release_weight_filler();
+ void set_allocated_weight_filler(::caffe::FillerParameter* weight_filler);
+
+ // optional .caffe.FillerParameter bias_filler = 4;
+ bool has_bias_filler() const;
+ void clear_bias_filler();
+ static const int kBiasFillerFieldNumber = 4;
+ const ::caffe::FillerParameter& bias_filler() const;
+ ::caffe::FillerParameter* mutable_bias_filler();
+ ::caffe::FillerParameter* release_bias_filler();
+ void set_allocated_bias_filler(::caffe::FillerParameter* bias_filler);
+
+ // optional int32 axis = 5 [default = 1];
+ bool has_axis() const;
+ void clear_axis();
+ static const int kAxisFieldNumber = 5;
+ ::google::protobuf::int32 axis() const;
+ void set_axis(::google::protobuf::int32 value);
+
+ // optional bool transpose = 6 [default = false];
+ bool has_transpose() const;
+ void clear_transpose();
+ static const int kTransposeFieldNumber = 6;
+ bool transpose() const;
+ void set_transpose(bool value);
+
+ // @@protoc_insertion_point(class_scope:caffe.InnerProductParameter)
+ private:
+ inline void set_has_num_output();
+ inline void clear_has_num_output();
+ inline void set_has_bias_term();
+ inline void clear_has_bias_term();
+ inline void set_has_weight_filler();
+ inline void clear_has_weight_filler();
+ inline void set_has_bias_filler();
+ inline void clear_has_bias_filler();
+ inline void set_has_axis();
+ inline void clear_has_axis();
+ inline void set_has_transpose();
+ inline void clear_has_transpose();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::caffe::FillerParameter* weight_filler_;
+ ::caffe::FillerParameter* bias_filler_;
+ ::google::protobuf::uint32 num_output_;
+ bool transpose_;
+ bool bias_term_;
+ ::google::protobuf::int32 axis_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<InnerProductParameter> InnerProductParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class InputParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.InputParameter) */ {
+ public:
+ InputParameter();
+ virtual ~InputParameter();
+
+ InputParameter(const InputParameter& from);
+
+ inline InputParameter& operator=(const InputParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const InputParameter& default_instance();
+
+ static const InputParameter* internal_default_instance();
+
+ void Swap(InputParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline InputParameter* New() const { return New(NULL); }
+
+ InputParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const InputParameter& from);
+ void MergeFrom(const InputParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(InputParameter* other);
+ void UnsafeMergeFrom(const InputParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // repeated .caffe.BlobShape shape = 1;
+ int shape_size() const;
+ void clear_shape();
+ static const int kShapeFieldNumber = 1;
+ const ::caffe::BlobShape& shape(int index) const;
+ ::caffe::BlobShape* mutable_shape(int index);
+ ::caffe::BlobShape* add_shape();
+ ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >*
+ mutable_shape();
+ const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >&
+ shape() const;
+
+ // @@protoc_insertion_point(class_scope:caffe.InputParameter)
+ private:
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape > shape_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<InputParameter> InputParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class LogParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.LogParameter) */ {
+ public:
+ LogParameter();
+ virtual ~LogParameter();
+
+ LogParameter(const LogParameter& from);
+
+ inline LogParameter& operator=(const LogParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const LogParameter& default_instance();
+
+ static const LogParameter* internal_default_instance();
+
+ void Swap(LogParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline LogParameter* New() const { return New(NULL); }
+
+ LogParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const LogParameter& from);
+ void MergeFrom(const LogParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(LogParameter* other);
+ void UnsafeMergeFrom(const LogParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional float base = 1 [default = -1];
+ bool has_base() const;
+ void clear_base();
+ static const int kBaseFieldNumber = 1;
+ float base() const;
+ void set_base(float value);
+
+ // optional float scale = 2 [default = 1];
+ bool has_scale() const;
+ void clear_scale();
+ static const int kScaleFieldNumber = 2;
+ float scale() const;
+ void set_scale(float value);
+
+ // optional float shift = 3 [default = 0];
+ bool has_shift() const;
+ void clear_shift();
+ static const int kShiftFieldNumber = 3;
+ float shift() const;
+ void set_shift(float value);
+
+ // @@protoc_insertion_point(class_scope:caffe.LogParameter)
+ private:
+ inline void set_has_base();
+ inline void clear_has_base();
+ inline void set_has_scale();
+ inline void clear_has_scale();
+ inline void set_has_shift();
+ inline void clear_has_shift();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ float shift_;
+ float base_;
+ float scale_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<LogParameter> LogParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class LRNParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.LRNParameter) */ {
+ public:
+ LRNParameter();
+ virtual ~LRNParameter();
+
+ LRNParameter(const LRNParameter& from);
+
+ inline LRNParameter& operator=(const LRNParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const LRNParameter& default_instance();
+
+ static const LRNParameter* internal_default_instance();
+
+ void Swap(LRNParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline LRNParameter* New() const { return New(NULL); }
+
+ LRNParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const LRNParameter& from);
+ void MergeFrom(const LRNParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(LRNParameter* other);
+ void UnsafeMergeFrom(const LRNParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ typedef LRNParameter_NormRegion NormRegion;
+ static const NormRegion ACROSS_CHANNELS =
+ LRNParameter_NormRegion_ACROSS_CHANNELS;
+ static const NormRegion WITHIN_CHANNEL =
+ LRNParameter_NormRegion_WITHIN_CHANNEL;
+ static inline bool NormRegion_IsValid(int value) {
+ return LRNParameter_NormRegion_IsValid(value);
+ }
+ static const NormRegion NormRegion_MIN =
+ LRNParameter_NormRegion_NormRegion_MIN;
+ static const NormRegion NormRegion_MAX =
+ LRNParameter_NormRegion_NormRegion_MAX;
+ static const int NormRegion_ARRAYSIZE =
+ LRNParameter_NormRegion_NormRegion_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ NormRegion_descriptor() {
+ return LRNParameter_NormRegion_descriptor();
+ }
+ static inline const ::std::string& NormRegion_Name(NormRegion value) {
+ return LRNParameter_NormRegion_Name(value);
+ }
+ static inline bool NormRegion_Parse(const ::std::string& name,
+ NormRegion* value) {
+ return LRNParameter_NormRegion_Parse(name, value);
+ }
+
+ typedef LRNParameter_Engine Engine;
+ static const Engine DEFAULT =
+ LRNParameter_Engine_DEFAULT;
+ static const Engine CAFFE =
+ LRNParameter_Engine_CAFFE;
+ static const Engine CUDNN =
+ LRNParameter_Engine_CUDNN;
+ static inline bool Engine_IsValid(int value) {
+ return LRNParameter_Engine_IsValid(value);
+ }
+ static const Engine Engine_MIN =
+ LRNParameter_Engine_Engine_MIN;
+ static const Engine Engine_MAX =
+ LRNParameter_Engine_Engine_MAX;
+ static const int Engine_ARRAYSIZE =
+ LRNParameter_Engine_Engine_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ Engine_descriptor() {
+ return LRNParameter_Engine_descriptor();
+ }
+ static inline const ::std::string& Engine_Name(Engine value) {
+ return LRNParameter_Engine_Name(value);
+ }
+ static inline bool Engine_Parse(const ::std::string& name,
+ Engine* value) {
+ return LRNParameter_Engine_Parse(name, value);
+ }
+
+ // accessors -------------------------------------------------------
+
+ // optional uint32 local_size = 1 [default = 5];
+ bool has_local_size() const;
+ void clear_local_size();
+ static const int kLocalSizeFieldNumber = 1;
+ ::google::protobuf::uint32 local_size() const;
+ void set_local_size(::google::protobuf::uint32 value);
+
+ // optional float alpha = 2 [default = 1];
+ bool has_alpha() const;
+ void clear_alpha();
+ static const int kAlphaFieldNumber = 2;
+ float alpha() const;
+ void set_alpha(float value);
+
+ // optional float beta = 3 [default = 0.75];
+ bool has_beta() const;
+ void clear_beta();
+ static const int kBetaFieldNumber = 3;
+ float beta() const;
+ void set_beta(float value);
+
+ // optional .caffe.LRNParameter.NormRegion norm_region = 4 [default = ACROSS_CHANNELS];
+ bool has_norm_region() const;
+ void clear_norm_region();
+ static const int kNormRegionFieldNumber = 4;
+ ::caffe::LRNParameter_NormRegion norm_region() const;
+ void set_norm_region(::caffe::LRNParameter_NormRegion value);
+
+ // optional float k = 5 [default = 1];
+ bool has_k() const;
+ void clear_k();
+ static const int kKFieldNumber = 5;
+ float k() const;
+ void set_k(float value);
+
+ // optional .caffe.LRNParameter.Engine engine = 6 [default = DEFAULT];
+ bool has_engine() const;
+ void clear_engine();
+ static const int kEngineFieldNumber = 6;
+ ::caffe::LRNParameter_Engine engine() const;
+ void set_engine(::caffe::LRNParameter_Engine value);
+
+ // @@protoc_insertion_point(class_scope:caffe.LRNParameter)
+ private:
+ inline void set_has_local_size();
+ inline void clear_has_local_size();
+ inline void set_has_alpha();
+ inline void clear_has_alpha();
+ inline void set_has_beta();
+ inline void clear_has_beta();
+ inline void set_has_norm_region();
+ inline void clear_has_norm_region();
+ inline void set_has_k();
+ inline void clear_has_k();
+ inline void set_has_engine();
+ inline void clear_has_engine();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ int norm_region_;
+ int engine_;
+ ::google::protobuf::uint32 local_size_;
+ float alpha_;
+ float beta_;
+ float k_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<LRNParameter> LRNParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class MemoryDataParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.MemoryDataParameter) */ {
+ public:
+ MemoryDataParameter();
+ virtual ~MemoryDataParameter();
+
+ MemoryDataParameter(const MemoryDataParameter& from);
+
+ inline MemoryDataParameter& operator=(const MemoryDataParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const MemoryDataParameter& default_instance();
+
+ static const MemoryDataParameter* internal_default_instance();
+
+ void Swap(MemoryDataParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline MemoryDataParameter* New() const { return New(NULL); }
+
+ MemoryDataParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const MemoryDataParameter& from);
+ void MergeFrom(const MemoryDataParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(MemoryDataParameter* other);
+ void UnsafeMergeFrom(const MemoryDataParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional uint32 batch_size = 1;
+ bool has_batch_size() const;
+ void clear_batch_size();
+ static const int kBatchSizeFieldNumber = 1;
+ ::google::protobuf::uint32 batch_size() const;
+ void set_batch_size(::google::protobuf::uint32 value);
+
+ // optional uint32 channels = 2;
+ bool has_channels() const;
+ void clear_channels();
+ static const int kChannelsFieldNumber = 2;
+ ::google::protobuf::uint32 channels() const;
+ void set_channels(::google::protobuf::uint32 value);
+
+ // optional uint32 height = 3;
+ bool has_height() const;
+ void clear_height();
+ static const int kHeightFieldNumber = 3;
+ ::google::protobuf::uint32 height() const;
+ void set_height(::google::protobuf::uint32 value);
+
+ // optional uint32 width = 4;
+ bool has_width() const;
+ void clear_width();
+ static const int kWidthFieldNumber = 4;
+ ::google::protobuf::uint32 width() const;
+ void set_width(::google::protobuf::uint32 value);
+
+ // @@protoc_insertion_point(class_scope:caffe.MemoryDataParameter)
+ private:
+ inline void set_has_batch_size();
+ inline void clear_has_batch_size();
+ inline void set_has_channels();
+ inline void clear_has_channels();
+ inline void set_has_height();
+ inline void clear_has_height();
+ inline void set_has_width();
+ inline void clear_has_width();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::uint32 batch_size_;
+ ::google::protobuf::uint32 channels_;
+ ::google::protobuf::uint32 height_;
+ ::google::protobuf::uint32 width_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<MemoryDataParameter> MemoryDataParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class MVNParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.MVNParameter) */ {
+ public:
+ MVNParameter();
+ virtual ~MVNParameter();
+
+ MVNParameter(const MVNParameter& from);
+
+ inline MVNParameter& operator=(const MVNParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const MVNParameter& default_instance();
+
+ static const MVNParameter* internal_default_instance();
+
+ void Swap(MVNParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline MVNParameter* New() const { return New(NULL); }
+
+ MVNParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const MVNParameter& from);
+ void MergeFrom(const MVNParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(MVNParameter* other);
+ void UnsafeMergeFrom(const MVNParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional bool normalize_variance = 1 [default = true];
+ bool has_normalize_variance() const;
+ void clear_normalize_variance();
+ static const int kNormalizeVarianceFieldNumber = 1;
+ bool normalize_variance() const;
+ void set_normalize_variance(bool value);
+
+ // optional bool across_channels = 2 [default = false];
+ bool has_across_channels() const;
+ void clear_across_channels();
+ static const int kAcrossChannelsFieldNumber = 2;
+ bool across_channels() const;
+ void set_across_channels(bool value);
+
+ // optional float eps = 3 [default = 1e-09];
+ bool has_eps() const;
+ void clear_eps();
+ static const int kEpsFieldNumber = 3;
+ float eps() const;
+ void set_eps(float value);
+
+ // @@protoc_insertion_point(class_scope:caffe.MVNParameter)
+ private:
+ inline void set_has_normalize_variance();
+ inline void clear_has_normalize_variance();
+ inline void set_has_across_channels();
+ inline void clear_has_across_channels();
+ inline void set_has_eps();
+ inline void clear_has_eps();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ bool across_channels_;
+ bool normalize_variance_;
+ float eps_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<MVNParameter> MVNParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class ParameterParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ParameterParameter) */ {
+ public:
+ ParameterParameter();
+ virtual ~ParameterParameter();
+
+ ParameterParameter(const ParameterParameter& from);
+
+ inline ParameterParameter& operator=(const ParameterParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const ParameterParameter& default_instance();
+
+ static const ParameterParameter* internal_default_instance();
+
+ void Swap(ParameterParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline ParameterParameter* New() const { return New(NULL); }
+
+ ParameterParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const ParameterParameter& from);
+ void MergeFrom(const ParameterParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(ParameterParameter* other);
+ void UnsafeMergeFrom(const ParameterParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional .caffe.BlobShape shape = 1;
+ bool has_shape() const;
+ void clear_shape();
+ static const int kShapeFieldNumber = 1;
+ const ::caffe::BlobShape& shape() const;
+ ::caffe::BlobShape* mutable_shape();
+ ::caffe::BlobShape* release_shape();
+ void set_allocated_shape(::caffe::BlobShape* shape);
+
+ // @@protoc_insertion_point(class_scope:caffe.ParameterParameter)
+ private:
+ inline void set_has_shape();
+ inline void clear_has_shape();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::caffe::BlobShape* shape_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<ParameterParameter> ParameterParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class PoolingParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.PoolingParameter) */ {
+ public:
+ PoolingParameter();
+ virtual ~PoolingParameter();
+
+ PoolingParameter(const PoolingParameter& from);
+
+ inline PoolingParameter& operator=(const PoolingParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const PoolingParameter& default_instance();
+
+ static const PoolingParameter* internal_default_instance();
+
+ void Swap(PoolingParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline PoolingParameter* New() const { return New(NULL); }
+
+ PoolingParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const PoolingParameter& from);
+ void MergeFrom(const PoolingParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(PoolingParameter* other);
+ void UnsafeMergeFrom(const PoolingParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ typedef PoolingParameter_PoolMethod PoolMethod;
+ static const PoolMethod MAX =
+ PoolingParameter_PoolMethod_MAX;
+ static const PoolMethod AVE =
+ PoolingParameter_PoolMethod_AVE;
+ static const PoolMethod STOCHASTIC =
+ PoolingParameter_PoolMethod_STOCHASTIC;
+ static inline bool PoolMethod_IsValid(int value) {
+ return PoolingParameter_PoolMethod_IsValid(value);
+ }
+ static const PoolMethod PoolMethod_MIN =
+ PoolingParameter_PoolMethod_PoolMethod_MIN;
+ static const PoolMethod PoolMethod_MAX =
+ PoolingParameter_PoolMethod_PoolMethod_MAX;
+ static const int PoolMethod_ARRAYSIZE =
+ PoolingParameter_PoolMethod_PoolMethod_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ PoolMethod_descriptor() {
+ return PoolingParameter_PoolMethod_descriptor();
+ }
+ static inline const ::std::string& PoolMethod_Name(PoolMethod value) {
+ return PoolingParameter_PoolMethod_Name(value);
+ }
+ static inline bool PoolMethod_Parse(const ::std::string& name,
+ PoolMethod* value) {
+ return PoolingParameter_PoolMethod_Parse(name, value);
+ }
+
+ typedef PoolingParameter_Engine Engine;
+ static const Engine DEFAULT =
+ PoolingParameter_Engine_DEFAULT;
+ static const Engine CAFFE =
+ PoolingParameter_Engine_CAFFE;
+ static const Engine CUDNN =
+ PoolingParameter_Engine_CUDNN;
+ static inline bool Engine_IsValid(int value) {
+ return PoolingParameter_Engine_IsValid(value);
+ }
+ static const Engine Engine_MIN =
+ PoolingParameter_Engine_Engine_MIN;
+ static const Engine Engine_MAX =
+ PoolingParameter_Engine_Engine_MAX;
+ static const int Engine_ARRAYSIZE =
+ PoolingParameter_Engine_Engine_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ Engine_descriptor() {
+ return PoolingParameter_Engine_descriptor();
+ }
+ static inline const ::std::string& Engine_Name(Engine value) {
+ return PoolingParameter_Engine_Name(value);
+ }
+ static inline bool Engine_Parse(const ::std::string& name,
+ Engine* value) {
+ return PoolingParameter_Engine_Parse(name, value);
+ }
+
+ // accessors -------------------------------------------------------
+
+ // optional .caffe.PoolingParameter.PoolMethod pool = 1 [default = MAX];
+ bool has_pool() const;
+ void clear_pool();
+ static const int kPoolFieldNumber = 1;
+ ::caffe::PoolingParameter_PoolMethod pool() const;
+ void set_pool(::caffe::PoolingParameter_PoolMethod value);
+
+ // optional uint32 pad = 4 [default = 0];
+ bool has_pad() const;
+ void clear_pad();
+ static const int kPadFieldNumber = 4;
+ ::google::protobuf::uint32 pad() const;
+ void set_pad(::google::protobuf::uint32 value);
+
+ // optional uint32 pad_h = 9 [default = 0];
+ bool has_pad_h() const;
+ void clear_pad_h();
+ static const int kPadHFieldNumber = 9;
+ ::google::protobuf::uint32 pad_h() const;
+ void set_pad_h(::google::protobuf::uint32 value);
+
+ // optional uint32 pad_w = 10 [default = 0];
+ bool has_pad_w() const;
+ void clear_pad_w();
+ static const int kPadWFieldNumber = 10;
+ ::google::protobuf::uint32 pad_w() const;
+ void set_pad_w(::google::protobuf::uint32 value);
+
+ // optional uint32 kernel_size = 2;
+ bool has_kernel_size() const;
+ void clear_kernel_size();
+ static const int kKernelSizeFieldNumber = 2;
+ ::google::protobuf::uint32 kernel_size() const;
+ void set_kernel_size(::google::protobuf::uint32 value);
+
+ // optional uint32 kernel_h = 5;
+ bool has_kernel_h() const;
+ void clear_kernel_h();
+ static const int kKernelHFieldNumber = 5;
+ ::google::protobuf::uint32 kernel_h() const;
+ void set_kernel_h(::google::protobuf::uint32 value);
+
+ // optional uint32 kernel_w = 6;
+ bool has_kernel_w() const;
+ void clear_kernel_w();
+ static const int kKernelWFieldNumber = 6;
+ ::google::protobuf::uint32 kernel_w() const;
+ void set_kernel_w(::google::protobuf::uint32 value);
+
+ // optional uint32 stride = 3 [default = 1];
+ bool has_stride() const;
+ void clear_stride();
+ static const int kStrideFieldNumber = 3;
+ ::google::protobuf::uint32 stride() const;
+ void set_stride(::google::protobuf::uint32 value);
+
+ // optional uint32 stride_h = 7;
+ bool has_stride_h() const;
+ void clear_stride_h();
+ static const int kStrideHFieldNumber = 7;
+ ::google::protobuf::uint32 stride_h() const;
+ void set_stride_h(::google::protobuf::uint32 value);
+
+ // optional uint32 stride_w = 8;
+ bool has_stride_w() const;
+ void clear_stride_w();
+ static const int kStrideWFieldNumber = 8;
+ ::google::protobuf::uint32 stride_w() const;
+ void set_stride_w(::google::protobuf::uint32 value);
+
+ // optional .caffe.PoolingParameter.Engine engine = 11 [default = DEFAULT];
+ bool has_engine() const;
+ void clear_engine();
+ static const int kEngineFieldNumber = 11;
+ ::caffe::PoolingParameter_Engine engine() const;
+ void set_engine(::caffe::PoolingParameter_Engine value);
+
+ // optional bool global_pooling = 12 [default = false];
+ bool has_global_pooling() const;
+ void clear_global_pooling();
+ static const int kGlobalPoolingFieldNumber = 12;
+ bool global_pooling() const;
+ void set_global_pooling(bool value);
+
+ // @@protoc_insertion_point(class_scope:caffe.PoolingParameter)
+ private:
+ inline void set_has_pool();
+ inline void clear_has_pool();
+ inline void set_has_pad();
+ inline void clear_has_pad();
+ inline void set_has_pad_h();
+ inline void clear_has_pad_h();
+ inline void set_has_pad_w();
+ inline void clear_has_pad_w();
+ inline void set_has_kernel_size();
+ inline void clear_has_kernel_size();
+ inline void set_has_kernel_h();
+ inline void clear_has_kernel_h();
+ inline void set_has_kernel_w();
+ inline void clear_has_kernel_w();
+ inline void set_has_stride();
+ inline void clear_has_stride();
+ inline void set_has_stride_h();
+ inline void clear_has_stride_h();
+ inline void set_has_stride_w();
+ inline void clear_has_stride_w();
+ inline void set_has_engine();
+ inline void clear_has_engine();
+ inline void set_has_global_pooling();
+ inline void clear_has_global_pooling();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ int pool_;
+ ::google::protobuf::uint32 pad_;
+ ::google::protobuf::uint32 pad_h_;
+ ::google::protobuf::uint32 pad_w_;
+ ::google::protobuf::uint32 kernel_size_;
+ ::google::protobuf::uint32 kernel_h_;
+ ::google::protobuf::uint32 kernel_w_;
+ ::google::protobuf::uint32 stride_h_;
+ ::google::protobuf::uint32 stride_w_;
+ int engine_;
+ bool global_pooling_;
+ ::google::protobuf::uint32 stride_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<PoolingParameter> PoolingParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class PowerParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.PowerParameter) */ {
+ public:
+ PowerParameter();
+ virtual ~PowerParameter();
+
+ PowerParameter(const PowerParameter& from);
+
+ inline PowerParameter& operator=(const PowerParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const PowerParameter& default_instance();
+
+ static const PowerParameter* internal_default_instance();
+
+ void Swap(PowerParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline PowerParameter* New() const { return New(NULL); }
+
+ PowerParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const PowerParameter& from);
+ void MergeFrom(const PowerParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(PowerParameter* other);
+ void UnsafeMergeFrom(const PowerParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional float power = 1 [default = 1];
+ bool has_power() const;
+ void clear_power();
+ static const int kPowerFieldNumber = 1;
+ float power() const;
+ void set_power(float value);
+
+ // optional float scale = 2 [default = 1];
+ bool has_scale() const;
+ void clear_scale();
+ static const int kScaleFieldNumber = 2;
+ float scale() const;
+ void set_scale(float value);
+
+ // optional float shift = 3 [default = 0];
+ bool has_shift() const;
+ void clear_shift();
+ static const int kShiftFieldNumber = 3;
+ float shift() const;
+ void set_shift(float value);
+
+ // @@protoc_insertion_point(class_scope:caffe.PowerParameter)
+ private:
+ inline void set_has_power();
+ inline void clear_has_power();
+ inline void set_has_scale();
+ inline void clear_has_scale();
+ inline void set_has_shift();
+ inline void clear_has_shift();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ float shift_;
+ float power_;
+ float scale_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<PowerParameter> PowerParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class PythonParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.PythonParameter) */ {
+ public:
+ PythonParameter();
+ virtual ~PythonParameter();
+
+ PythonParameter(const PythonParameter& from);
+
+ inline PythonParameter& operator=(const PythonParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const PythonParameter& default_instance();
+
+ static const PythonParameter* internal_default_instance();
+
+ void Swap(PythonParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline PythonParameter* New() const { return New(NULL); }
+
+ PythonParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const PythonParameter& from);
+ void MergeFrom(const PythonParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(PythonParameter* other);
+ void UnsafeMergeFrom(const PythonParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional string module = 1;
+ bool has_module() const;
+ void clear_module();
+ static const int kModuleFieldNumber = 1;
+ const ::std::string& module() const;
+ void set_module(const ::std::string& value);
+ void set_module(const char* value);
+ void set_module(const char* value, size_t size);
+ ::std::string* mutable_module();
+ ::std::string* release_module();
+ void set_allocated_module(::std::string* module);
+
+ // optional string layer = 2;
+ bool has_layer() const;
+ void clear_layer();
+ static const int kLayerFieldNumber = 2;
+ const ::std::string& layer() const;
+ void set_layer(const ::std::string& value);
+ void set_layer(const char* value);
+ void set_layer(const char* value, size_t size);
+ ::std::string* mutable_layer();
+ ::std::string* release_layer();
+ void set_allocated_layer(::std::string* layer);
+
+ // optional string param_str = 3 [default = ""];
+ bool has_param_str() const;
+ void clear_param_str();
+ static const int kParamStrFieldNumber = 3;
+ const ::std::string& param_str() const;
+ void set_param_str(const ::std::string& value);
+ void set_param_str(const char* value);
+ void set_param_str(const char* value, size_t size);
+ ::std::string* mutable_param_str();
+ ::std::string* release_param_str();
+ void set_allocated_param_str(::std::string* param_str);
+
+ // optional bool share_in_parallel = 4 [default = false];
+ bool has_share_in_parallel() const;
+ void clear_share_in_parallel();
+ static const int kShareInParallelFieldNumber = 4;
+ bool share_in_parallel() const;
+ void set_share_in_parallel(bool value);
+
+ // @@protoc_insertion_point(class_scope:caffe.PythonParameter)
+ private:
+ inline void set_has_module();
+ inline void clear_has_module();
+ inline void set_has_layer();
+ inline void clear_has_layer();
+ inline void set_has_param_str();
+ inline void clear_has_param_str();
+ inline void set_has_share_in_parallel();
+ inline void clear_has_share_in_parallel();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::internal::ArenaStringPtr module_;
+ ::google::protobuf::internal::ArenaStringPtr layer_;
+ ::google::protobuf::internal::ArenaStringPtr param_str_;
+ bool share_in_parallel_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<PythonParameter> PythonParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class RecurrentParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.RecurrentParameter) */ {
+ public:
+ RecurrentParameter();
+ virtual ~RecurrentParameter();
+
+ RecurrentParameter(const RecurrentParameter& from);
+
+ inline RecurrentParameter& operator=(const RecurrentParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const RecurrentParameter& default_instance();
+
+ static const RecurrentParameter* internal_default_instance();
+
+ void Swap(RecurrentParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline RecurrentParameter* New() const { return New(NULL); }
+
+ RecurrentParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const RecurrentParameter& from);
+ void MergeFrom(const RecurrentParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(RecurrentParameter* other);
+ void UnsafeMergeFrom(const RecurrentParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional uint32 num_output = 1 [default = 0];
+ bool has_num_output() const;
+ void clear_num_output();
+ static const int kNumOutputFieldNumber = 1;
+ ::google::protobuf::uint32 num_output() const;
+ void set_num_output(::google::protobuf::uint32 value);
+
+ // optional .caffe.FillerParameter weight_filler = 2;
+ bool has_weight_filler() const;
+ void clear_weight_filler();
+ static const int kWeightFillerFieldNumber = 2;
+ const ::caffe::FillerParameter& weight_filler() const;
+ ::caffe::FillerParameter* mutable_weight_filler();
+ ::caffe::FillerParameter* release_weight_filler();
+ void set_allocated_weight_filler(::caffe::FillerParameter* weight_filler);
+
+ // optional .caffe.FillerParameter bias_filler = 3;
+ bool has_bias_filler() const;
+ void clear_bias_filler();
+ static const int kBiasFillerFieldNumber = 3;
+ const ::caffe::FillerParameter& bias_filler() const;
+ ::caffe::FillerParameter* mutable_bias_filler();
+ ::caffe::FillerParameter* release_bias_filler();
+ void set_allocated_bias_filler(::caffe::FillerParameter* bias_filler);
+
+ // optional bool debug_info = 4 [default = false];
+ bool has_debug_info() const;
+ void clear_debug_info();
+ static const int kDebugInfoFieldNumber = 4;
+ bool debug_info() const;
+ void set_debug_info(bool value);
+
+ // optional bool expose_hidden = 5 [default = false];
+ bool has_expose_hidden() const;
+ void clear_expose_hidden();
+ static const int kExposeHiddenFieldNumber = 5;
+ bool expose_hidden() const;
+ void set_expose_hidden(bool value);
+
+ // @@protoc_insertion_point(class_scope:caffe.RecurrentParameter)
+ private:
+ inline void set_has_num_output();
+ inline void clear_has_num_output();
+ inline void set_has_weight_filler();
+ inline void clear_has_weight_filler();
+ inline void set_has_bias_filler();
+ inline void clear_has_bias_filler();
+ inline void set_has_debug_info();
+ inline void clear_has_debug_info();
+ inline void set_has_expose_hidden();
+ inline void clear_has_expose_hidden();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::caffe::FillerParameter* weight_filler_;
+ ::caffe::FillerParameter* bias_filler_;
+ ::google::protobuf::uint32 num_output_;
+ bool debug_info_;
+ bool expose_hidden_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<RecurrentParameter> RecurrentParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class ReductionParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ReductionParameter) */ {
+ public:
+ ReductionParameter();
+ virtual ~ReductionParameter();
+
+ ReductionParameter(const ReductionParameter& from);
+
+ inline ReductionParameter& operator=(const ReductionParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const ReductionParameter& default_instance();
+
+ static const ReductionParameter* internal_default_instance();
+
+ void Swap(ReductionParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline ReductionParameter* New() const { return New(NULL); }
+
+ ReductionParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const ReductionParameter& from);
+ void MergeFrom(const ReductionParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(ReductionParameter* other);
+ void UnsafeMergeFrom(const ReductionParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ typedef ReductionParameter_ReductionOp ReductionOp;
+ static const ReductionOp SUM =
+ ReductionParameter_ReductionOp_SUM;
+ static const ReductionOp ASUM =
+ ReductionParameter_ReductionOp_ASUM;
+ static const ReductionOp SUMSQ =
+ ReductionParameter_ReductionOp_SUMSQ;
+ static const ReductionOp MEAN =
+ ReductionParameter_ReductionOp_MEAN;
+ static inline bool ReductionOp_IsValid(int value) {
+ return ReductionParameter_ReductionOp_IsValid(value);
+ }
+ static const ReductionOp ReductionOp_MIN =
+ ReductionParameter_ReductionOp_ReductionOp_MIN;
+ static const ReductionOp ReductionOp_MAX =
+ ReductionParameter_ReductionOp_ReductionOp_MAX;
+ static const int ReductionOp_ARRAYSIZE =
+ ReductionParameter_ReductionOp_ReductionOp_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ ReductionOp_descriptor() {
+ return ReductionParameter_ReductionOp_descriptor();
+ }
+ static inline const ::std::string& ReductionOp_Name(ReductionOp value) {
+ return ReductionParameter_ReductionOp_Name(value);
+ }
+ static inline bool ReductionOp_Parse(const ::std::string& name,
+ ReductionOp* value) {
+ return ReductionParameter_ReductionOp_Parse(name, value);
+ }
+
+ // accessors -------------------------------------------------------
+
+ // optional .caffe.ReductionParameter.ReductionOp operation = 1 [default = SUM];
+ bool has_operation() const;
+ void clear_operation();
+ static const int kOperationFieldNumber = 1;
+ ::caffe::ReductionParameter_ReductionOp operation() const;
+ void set_operation(::caffe::ReductionParameter_ReductionOp value);
+
+ // optional int32 axis = 2 [default = 0];
+ bool has_axis() const;
+ void clear_axis();
+ static const int kAxisFieldNumber = 2;
+ ::google::protobuf::int32 axis() const;
+ void set_axis(::google::protobuf::int32 value);
+
+ // optional float coeff = 3 [default = 1];
+ bool has_coeff() const;
+ void clear_coeff();
+ static const int kCoeffFieldNumber = 3;
+ float coeff() const;
+ void set_coeff(float value);
+
+ // @@protoc_insertion_point(class_scope:caffe.ReductionParameter)
+ private:
+ inline void set_has_operation();
+ inline void clear_has_operation();
+ inline void set_has_axis();
+ inline void clear_has_axis();
+ inline void set_has_coeff();
+ inline void clear_has_coeff();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::int32 axis_;
+ int operation_;
+ float coeff_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<ReductionParameter> ReductionParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class ReLUParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ReLUParameter) */ {
+ public:
+ ReLUParameter();
+ virtual ~ReLUParameter();
+
+ ReLUParameter(const ReLUParameter& from);
+
+ inline ReLUParameter& operator=(const ReLUParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const ReLUParameter& default_instance();
+
+ static const ReLUParameter* internal_default_instance();
+
+ void Swap(ReLUParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline ReLUParameter* New() const { return New(NULL); }
+
+ ReLUParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const ReLUParameter& from);
+ void MergeFrom(const ReLUParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(ReLUParameter* other);
+ void UnsafeMergeFrom(const ReLUParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ typedef ReLUParameter_Engine Engine;
+ static const Engine DEFAULT =
+ ReLUParameter_Engine_DEFAULT;
+ static const Engine CAFFE =
+ ReLUParameter_Engine_CAFFE;
+ static const Engine CUDNN =
+ ReLUParameter_Engine_CUDNN;
+ static inline bool Engine_IsValid(int value) {
+ return ReLUParameter_Engine_IsValid(value);
+ }
+ static const Engine Engine_MIN =
+ ReLUParameter_Engine_Engine_MIN;
+ static const Engine Engine_MAX =
+ ReLUParameter_Engine_Engine_MAX;
+ static const int Engine_ARRAYSIZE =
+ ReLUParameter_Engine_Engine_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ Engine_descriptor() {
+ return ReLUParameter_Engine_descriptor();
+ }
+ static inline const ::std::string& Engine_Name(Engine value) {
+ return ReLUParameter_Engine_Name(value);
+ }
+ static inline bool Engine_Parse(const ::std::string& name,
+ Engine* value) {
+ return ReLUParameter_Engine_Parse(name, value);
+ }
+
+ // accessors -------------------------------------------------------
+
+ // optional float negative_slope = 1 [default = 0];
+ bool has_negative_slope() const;
+ void clear_negative_slope();
+ static const int kNegativeSlopeFieldNumber = 1;
+ float negative_slope() const;
+ void set_negative_slope(float value);
+
+ // optional .caffe.ReLUParameter.Engine engine = 2 [default = DEFAULT];
+ bool has_engine() const;
+ void clear_engine();
+ static const int kEngineFieldNumber = 2;
+ ::caffe::ReLUParameter_Engine engine() const;
+ void set_engine(::caffe::ReLUParameter_Engine value);
+
+ // @@protoc_insertion_point(class_scope:caffe.ReLUParameter)
+ private:
+ inline void set_has_negative_slope();
+ inline void clear_has_negative_slope();
+ inline void set_has_engine();
+ inline void clear_has_engine();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ float negative_slope_;
+ int engine_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<ReLUParameter> ReLUParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class ReshapeParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ReshapeParameter) */ {
+ public:
+ ReshapeParameter();
+ virtual ~ReshapeParameter();
+
+ ReshapeParameter(const ReshapeParameter& from);
+
+ inline ReshapeParameter& operator=(const ReshapeParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const ReshapeParameter& default_instance();
+
+ static const ReshapeParameter* internal_default_instance();
+
+ void Swap(ReshapeParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline ReshapeParameter* New() const { return New(NULL); }
+
+ ReshapeParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const ReshapeParameter& from);
+ void MergeFrom(const ReshapeParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(ReshapeParameter* other);
+ void UnsafeMergeFrom(const ReshapeParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional .caffe.BlobShape shape = 1;
+ bool has_shape() const;
+ void clear_shape();
+ static const int kShapeFieldNumber = 1;
+ const ::caffe::BlobShape& shape() const;
+ ::caffe::BlobShape* mutable_shape();
+ ::caffe::BlobShape* release_shape();
+ void set_allocated_shape(::caffe::BlobShape* shape);
+
+ // optional int32 axis = 2 [default = 0];
+ bool has_axis() const;
+ void clear_axis();
+ static const int kAxisFieldNumber = 2;
+ ::google::protobuf::int32 axis() const;
+ void set_axis(::google::protobuf::int32 value);
+
+ // optional int32 num_axes = 3 [default = -1];
+ bool has_num_axes() const;
+ void clear_num_axes();
+ static const int kNumAxesFieldNumber = 3;
+ ::google::protobuf::int32 num_axes() const;
+ void set_num_axes(::google::protobuf::int32 value);
+
+ // @@protoc_insertion_point(class_scope:caffe.ReshapeParameter)
+ private:
+ inline void set_has_shape();
+ inline void clear_has_shape();
+ inline void set_has_axis();
+ inline void clear_has_axis();
+ inline void set_has_num_axes();
+ inline void clear_has_num_axes();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::caffe::BlobShape* shape_;
+ ::google::protobuf::int32 axis_;
+ ::google::protobuf::int32 num_axes_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<ReshapeParameter> ReshapeParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class ScaleParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ScaleParameter) */ {
+ public:
+ ScaleParameter();
+ virtual ~ScaleParameter();
+
+ ScaleParameter(const ScaleParameter& from);
+
+ inline ScaleParameter& operator=(const ScaleParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const ScaleParameter& default_instance();
+
+ static const ScaleParameter* internal_default_instance();
+
+ void Swap(ScaleParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline ScaleParameter* New() const { return New(NULL); }
+
+ ScaleParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const ScaleParameter& from);
+ void MergeFrom(const ScaleParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(ScaleParameter* other);
+ void UnsafeMergeFrom(const ScaleParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional int32 axis = 1 [default = 1];
+ bool has_axis() const;
+ void clear_axis();
+ static const int kAxisFieldNumber = 1;
+ ::google::protobuf::int32 axis() const;
+ void set_axis(::google::protobuf::int32 value);
+
+ // optional int32 num_axes = 2 [default = 1];
+ bool has_num_axes() const;
+ void clear_num_axes();
+ static const int kNumAxesFieldNumber = 2;
+ ::google::protobuf::int32 num_axes() const;
+ void set_num_axes(::google::protobuf::int32 value);
+
+ // optional .caffe.FillerParameter filler = 3;
+ bool has_filler() const;
+ void clear_filler();
+ static const int kFillerFieldNumber = 3;
+ const ::caffe::FillerParameter& filler() const;
+ ::caffe::FillerParameter* mutable_filler();
+ ::caffe::FillerParameter* release_filler();
+ void set_allocated_filler(::caffe::FillerParameter* filler);
+
+ // optional bool bias_term = 4 [default = false];
+ bool has_bias_term() const;
+ void clear_bias_term();
+ static const int kBiasTermFieldNumber = 4;
+ bool bias_term() const;
+ void set_bias_term(bool value);
+
+ // optional .caffe.FillerParameter bias_filler = 5;
+ bool has_bias_filler() const;
+ void clear_bias_filler();
+ static const int kBiasFillerFieldNumber = 5;
+ const ::caffe::FillerParameter& bias_filler() const;
+ ::caffe::FillerParameter* mutable_bias_filler();
+ ::caffe::FillerParameter* release_bias_filler();
+ void set_allocated_bias_filler(::caffe::FillerParameter* bias_filler);
+
+ // @@protoc_insertion_point(class_scope:caffe.ScaleParameter)
+ private:
+ inline void set_has_axis();
+ inline void clear_has_axis();
+ inline void set_has_num_axes();
+ inline void clear_has_num_axes();
+ inline void set_has_filler();
+ inline void clear_has_filler();
+ inline void set_has_bias_term();
+ inline void clear_has_bias_term();
+ inline void set_has_bias_filler();
+ inline void clear_has_bias_filler();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::caffe::FillerParameter* filler_;
+ ::caffe::FillerParameter* bias_filler_;
+ bool bias_term_;
+ ::google::protobuf::int32 axis_;
+ ::google::protobuf::int32 num_axes_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<ScaleParameter> ScaleParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class SigmoidParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.SigmoidParameter) */ {
+ public:
+ SigmoidParameter();
+ virtual ~SigmoidParameter();
+
+ SigmoidParameter(const SigmoidParameter& from);
+
+ inline SigmoidParameter& operator=(const SigmoidParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const SigmoidParameter& default_instance();
+
+ static const SigmoidParameter* internal_default_instance();
+
+ void Swap(SigmoidParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline SigmoidParameter* New() const { return New(NULL); }
+
+ SigmoidParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const SigmoidParameter& from);
+ void MergeFrom(const SigmoidParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(SigmoidParameter* other);
+ void UnsafeMergeFrom(const SigmoidParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ typedef SigmoidParameter_Engine Engine;
+ static const Engine DEFAULT =
+ SigmoidParameter_Engine_DEFAULT;
+ static const Engine CAFFE =
+ SigmoidParameter_Engine_CAFFE;
+ static const Engine CUDNN =
+ SigmoidParameter_Engine_CUDNN;
+ static inline bool Engine_IsValid(int value) {
+ return SigmoidParameter_Engine_IsValid(value);
+ }
+ static const Engine Engine_MIN =
+ SigmoidParameter_Engine_Engine_MIN;
+ static const Engine Engine_MAX =
+ SigmoidParameter_Engine_Engine_MAX;
+ static const int Engine_ARRAYSIZE =
+ SigmoidParameter_Engine_Engine_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ Engine_descriptor() {
+ return SigmoidParameter_Engine_descriptor();
+ }
+ static inline const ::std::string& Engine_Name(Engine value) {
+ return SigmoidParameter_Engine_Name(value);
+ }
+ static inline bool Engine_Parse(const ::std::string& name,
+ Engine* value) {
+ return SigmoidParameter_Engine_Parse(name, value);
+ }
+
+ // accessors -------------------------------------------------------
+
+ // optional .caffe.SigmoidParameter.Engine engine = 1 [default = DEFAULT];
+ bool has_engine() const;
+ void clear_engine();
+ static const int kEngineFieldNumber = 1;
+ ::caffe::SigmoidParameter_Engine engine() const;
+ void set_engine(::caffe::SigmoidParameter_Engine value);
+
+ // @@protoc_insertion_point(class_scope:caffe.SigmoidParameter)
+ private:
+ inline void set_has_engine();
+ inline void clear_has_engine();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ int engine_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<SigmoidParameter> SigmoidParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class SliceParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.SliceParameter) */ {
+ public:
+ SliceParameter();
+ virtual ~SliceParameter();
+
+ SliceParameter(const SliceParameter& from);
+
+ inline SliceParameter& operator=(const SliceParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const SliceParameter& default_instance();
+
+ static const SliceParameter* internal_default_instance();
+
+ void Swap(SliceParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline SliceParameter* New() const { return New(NULL); }
+
+ SliceParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const SliceParameter& from);
+ void MergeFrom(const SliceParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(SliceParameter* other);
+ void UnsafeMergeFrom(const SliceParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional int32 axis = 3 [default = 1];
+ bool has_axis() const;
+ void clear_axis();
+ static const int kAxisFieldNumber = 3;
+ ::google::protobuf::int32 axis() const;
+ void set_axis(::google::protobuf::int32 value);
+
+ // repeated uint32 slice_point = 2;
+ int slice_point_size() const;
+ void clear_slice_point();
+ static const int kSlicePointFieldNumber = 2;
+ ::google::protobuf::uint32 slice_point(int index) const;
+ void set_slice_point(int index, ::google::protobuf::uint32 value);
+ void add_slice_point(::google::protobuf::uint32 value);
+ const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+ slice_point() const;
+ ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+ mutable_slice_point();
+
+ // optional uint32 slice_dim = 1 [default = 1];
+ bool has_slice_dim() const;
+ void clear_slice_dim();
+ static const int kSliceDimFieldNumber = 1;
+ ::google::protobuf::uint32 slice_dim() const;
+ void set_slice_dim(::google::protobuf::uint32 value);
+
+ // @@protoc_insertion_point(class_scope:caffe.SliceParameter)
+ private:
+ inline void set_has_axis();
+ inline void clear_has_axis();
+ inline void set_has_slice_dim();
+ inline void clear_has_slice_dim();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > slice_point_;
+ ::google::protobuf::int32 axis_;
+ ::google::protobuf::uint32 slice_dim_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<SliceParameter> SliceParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class SoftmaxParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.SoftmaxParameter) */ {
+ public:
+ SoftmaxParameter();
+ virtual ~SoftmaxParameter();
+
+ SoftmaxParameter(const SoftmaxParameter& from);
+
+ inline SoftmaxParameter& operator=(const SoftmaxParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const SoftmaxParameter& default_instance();
+
+ static const SoftmaxParameter* internal_default_instance();
+
+ void Swap(SoftmaxParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline SoftmaxParameter* New() const { return New(NULL); }
+
+ SoftmaxParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const SoftmaxParameter& from);
+ void MergeFrom(const SoftmaxParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(SoftmaxParameter* other);
+ void UnsafeMergeFrom(const SoftmaxParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ typedef SoftmaxParameter_Engine Engine;
+ static const Engine DEFAULT =
+ SoftmaxParameter_Engine_DEFAULT;
+ static const Engine CAFFE =
+ SoftmaxParameter_Engine_CAFFE;
+ static const Engine CUDNN =
+ SoftmaxParameter_Engine_CUDNN;
+ static inline bool Engine_IsValid(int value) {
+ return SoftmaxParameter_Engine_IsValid(value);
+ }
+ static const Engine Engine_MIN =
+ SoftmaxParameter_Engine_Engine_MIN;
+ static const Engine Engine_MAX =
+ SoftmaxParameter_Engine_Engine_MAX;
+ static const int Engine_ARRAYSIZE =
+ SoftmaxParameter_Engine_Engine_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ Engine_descriptor() {
+ return SoftmaxParameter_Engine_descriptor();
+ }
+ static inline const ::std::string& Engine_Name(Engine value) {
+ return SoftmaxParameter_Engine_Name(value);
+ }
+ static inline bool Engine_Parse(const ::std::string& name,
+ Engine* value) {
+ return SoftmaxParameter_Engine_Parse(name, value);
+ }
+
+ // accessors -------------------------------------------------------
+
+ // optional .caffe.SoftmaxParameter.Engine engine = 1 [default = DEFAULT];
+ bool has_engine() const;
+ void clear_engine();
+ static const int kEngineFieldNumber = 1;
+ ::caffe::SoftmaxParameter_Engine engine() const;
+ void set_engine(::caffe::SoftmaxParameter_Engine value);
+
+ // optional int32 axis = 2 [default = 1];
+ bool has_axis() const;
+ void clear_axis();
+ static const int kAxisFieldNumber = 2;
+ ::google::protobuf::int32 axis() const;
+ void set_axis(::google::protobuf::int32 value);
+
+ // @@protoc_insertion_point(class_scope:caffe.SoftmaxParameter)
+ private:
+ inline void set_has_engine();
+ inline void clear_has_engine();
+ inline void set_has_axis();
+ inline void clear_has_axis();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ int engine_;
+ ::google::protobuf::int32 axis_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<SoftmaxParameter> SoftmaxParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class TanHParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.TanHParameter) */ {
+ public:
+ TanHParameter();
+ virtual ~TanHParameter();
+
+ TanHParameter(const TanHParameter& from);
+
+ inline TanHParameter& operator=(const TanHParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const TanHParameter& default_instance();
+
+ static const TanHParameter* internal_default_instance();
+
+ void Swap(TanHParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline TanHParameter* New() const { return New(NULL); }
+
+ TanHParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const TanHParameter& from);
+ void MergeFrom(const TanHParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(TanHParameter* other);
+ void UnsafeMergeFrom(const TanHParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ typedef TanHParameter_Engine Engine;
+ static const Engine DEFAULT =
+ TanHParameter_Engine_DEFAULT;
+ static const Engine CAFFE =
+ TanHParameter_Engine_CAFFE;
+ static const Engine CUDNN =
+ TanHParameter_Engine_CUDNN;
+ static inline bool Engine_IsValid(int value) {
+ return TanHParameter_Engine_IsValid(value);
+ }
+ static const Engine Engine_MIN =
+ TanHParameter_Engine_Engine_MIN;
+ static const Engine Engine_MAX =
+ TanHParameter_Engine_Engine_MAX;
+ static const int Engine_ARRAYSIZE =
+ TanHParameter_Engine_Engine_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ Engine_descriptor() {
+ return TanHParameter_Engine_descriptor();
+ }
+ static inline const ::std::string& Engine_Name(Engine value) {
+ return TanHParameter_Engine_Name(value);
+ }
+ static inline bool Engine_Parse(const ::std::string& name,
+ Engine* value) {
+ return TanHParameter_Engine_Parse(name, value);
+ }
+
+ // accessors -------------------------------------------------------
+
+ // optional .caffe.TanHParameter.Engine engine = 1 [default = DEFAULT];
+ bool has_engine() const;
+ void clear_engine();
+ static const int kEngineFieldNumber = 1;
+ ::caffe::TanHParameter_Engine engine() const;
+ void set_engine(::caffe::TanHParameter_Engine value);
+
+ // @@protoc_insertion_point(class_scope:caffe.TanHParameter)
+ private:
+ inline void set_has_engine();
+ inline void clear_has_engine();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ int engine_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<TanHParameter> TanHParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class TileParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.TileParameter) */ {
+ public:
+ TileParameter();
+ virtual ~TileParameter();
+
+ TileParameter(const TileParameter& from);
+
+ inline TileParameter& operator=(const TileParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const TileParameter& default_instance();
+
+ static const TileParameter* internal_default_instance();
+
+ void Swap(TileParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline TileParameter* New() const { return New(NULL); }
+
+ TileParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const TileParameter& from);
+ void MergeFrom(const TileParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(TileParameter* other);
+ void UnsafeMergeFrom(const TileParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional int32 axis = 1 [default = 1];
+ bool has_axis() const;
+ void clear_axis();
+ static const int kAxisFieldNumber = 1;
+ ::google::protobuf::int32 axis() const;
+ void set_axis(::google::protobuf::int32 value);
+
+ // optional int32 tiles = 2;
+ bool has_tiles() const;
+ void clear_tiles();
+ static const int kTilesFieldNumber = 2;
+ ::google::protobuf::int32 tiles() const;
+ void set_tiles(::google::protobuf::int32 value);
+
+ // @@protoc_insertion_point(class_scope:caffe.TileParameter)
+ private:
+ inline void set_has_axis();
+ inline void clear_has_axis();
+ inline void set_has_tiles();
+ inline void clear_has_tiles();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::int32 tiles_;
+ ::google::protobuf::int32 axis_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<TileParameter> TileParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class ThresholdParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.ThresholdParameter) */ {
+ public:
+ ThresholdParameter();
+ virtual ~ThresholdParameter();
+
+ ThresholdParameter(const ThresholdParameter& from);
+
+ inline ThresholdParameter& operator=(const ThresholdParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const ThresholdParameter& default_instance();
+
+ static const ThresholdParameter* internal_default_instance();
+
+ void Swap(ThresholdParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline ThresholdParameter* New() const { return New(NULL); }
+
+ ThresholdParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const ThresholdParameter& from);
+ void MergeFrom(const ThresholdParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(ThresholdParameter* other);
+ void UnsafeMergeFrom(const ThresholdParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional float threshold = 1 [default = 0];
+ bool has_threshold() const;
+ void clear_threshold();
+ static const int kThresholdFieldNumber = 1;
+ float threshold() const;
+ void set_threshold(float value);
+
+ // @@protoc_insertion_point(class_scope:caffe.ThresholdParameter)
+ private:
+ inline void set_has_threshold();
+ inline void clear_has_threshold();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ float threshold_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<ThresholdParameter> ThresholdParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class WindowDataParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.WindowDataParameter) */ {
+ public:
+ WindowDataParameter();
+ virtual ~WindowDataParameter();
+
+ WindowDataParameter(const WindowDataParameter& from);
+
+ inline WindowDataParameter& operator=(const WindowDataParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const WindowDataParameter& default_instance();
+
+ static const WindowDataParameter* internal_default_instance();
+
+ void Swap(WindowDataParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline WindowDataParameter* New() const { return New(NULL); }
+
+ WindowDataParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const WindowDataParameter& from);
+ void MergeFrom(const WindowDataParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(WindowDataParameter* other);
+ void UnsafeMergeFrom(const WindowDataParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional string source = 1;
+ bool has_source() const;
+ void clear_source();
+ static const int kSourceFieldNumber = 1;
+ const ::std::string& source() const;
+ void set_source(const ::std::string& value);
+ void set_source(const char* value);
+ void set_source(const char* value, size_t size);
+ ::std::string* mutable_source();
+ ::std::string* release_source();
+ void set_allocated_source(::std::string* source);
+
+ // optional float scale = 2 [default = 1];
+ bool has_scale() const;
+ void clear_scale();
+ static const int kScaleFieldNumber = 2;
+ float scale() const;
+ void set_scale(float value);
+
+ // optional string mean_file = 3;
+ bool has_mean_file() const;
+ void clear_mean_file();
+ static const int kMeanFileFieldNumber = 3;
+ const ::std::string& mean_file() const;
+ void set_mean_file(const ::std::string& value);
+ void set_mean_file(const char* value);
+ void set_mean_file(const char* value, size_t size);
+ ::std::string* mutable_mean_file();
+ ::std::string* release_mean_file();
+ void set_allocated_mean_file(::std::string* mean_file);
+
+ // optional uint32 batch_size = 4;
+ bool has_batch_size() const;
+ void clear_batch_size();
+ static const int kBatchSizeFieldNumber = 4;
+ ::google::protobuf::uint32 batch_size() const;
+ void set_batch_size(::google::protobuf::uint32 value);
+
+ // optional uint32 crop_size = 5 [default = 0];
+ bool has_crop_size() const;
+ void clear_crop_size();
+ static const int kCropSizeFieldNumber = 5;
+ ::google::protobuf::uint32 crop_size() const;
+ void set_crop_size(::google::protobuf::uint32 value);
+
+ // optional bool mirror = 6 [default = false];
+ bool has_mirror() const;
+ void clear_mirror();
+ static const int kMirrorFieldNumber = 6;
+ bool mirror() const;
+ void set_mirror(bool value);
+
+ // optional float fg_threshold = 7 [default = 0.5];
+ bool has_fg_threshold() const;
+ void clear_fg_threshold();
+ static const int kFgThresholdFieldNumber = 7;
+ float fg_threshold() const;
+ void set_fg_threshold(float value);
+
+ // optional float bg_threshold = 8 [default = 0.5];
+ bool has_bg_threshold() const;
+ void clear_bg_threshold();
+ static const int kBgThresholdFieldNumber = 8;
+ float bg_threshold() const;
+ void set_bg_threshold(float value);
+
+ // optional float fg_fraction = 9 [default = 0.25];
+ bool has_fg_fraction() const;
+ void clear_fg_fraction();
+ static const int kFgFractionFieldNumber = 9;
+ float fg_fraction() const;
+ void set_fg_fraction(float value);
+
+ // optional uint32 context_pad = 10 [default = 0];
+ bool has_context_pad() const;
+ void clear_context_pad();
+ static const int kContextPadFieldNumber = 10;
+ ::google::protobuf::uint32 context_pad() const;
+ void set_context_pad(::google::protobuf::uint32 value);
+
+ // optional string crop_mode = 11 [default = "warp"];
+ bool has_crop_mode() const;
+ void clear_crop_mode();
+ static const int kCropModeFieldNumber = 11;
+ const ::std::string& crop_mode() const;
+ void set_crop_mode(const ::std::string& value);
+ void set_crop_mode(const char* value);
+ void set_crop_mode(const char* value, size_t size);
+ ::std::string* mutable_crop_mode();
+ ::std::string* release_crop_mode();
+ void set_allocated_crop_mode(::std::string* crop_mode);
+
+ // optional bool cache_images = 12 [default = false];
+ bool has_cache_images() const;
+ void clear_cache_images();
+ static const int kCacheImagesFieldNumber = 12;
+ bool cache_images() const;
+ void set_cache_images(bool value);
+
+ // optional string root_folder = 13 [default = ""];
+ bool has_root_folder() const;
+ void clear_root_folder();
+ static const int kRootFolderFieldNumber = 13;
+ const ::std::string& root_folder() const;
+ void set_root_folder(const ::std::string& value);
+ void set_root_folder(const char* value);
+ void set_root_folder(const char* value, size_t size);
+ ::std::string* mutable_root_folder();
+ ::std::string* release_root_folder();
+ void set_allocated_root_folder(::std::string* root_folder);
+
+ // @@protoc_insertion_point(class_scope:caffe.WindowDataParameter)
+ private:
+ inline void set_has_source();
+ inline void clear_has_source();
+ inline void set_has_scale();
+ inline void clear_has_scale();
+ inline void set_has_mean_file();
+ inline void clear_has_mean_file();
+ inline void set_has_batch_size();
+ inline void clear_has_batch_size();
+ inline void set_has_crop_size();
+ inline void clear_has_crop_size();
+ inline void set_has_mirror();
+ inline void clear_has_mirror();
+ inline void set_has_fg_threshold();
+ inline void clear_has_fg_threshold();
+ inline void set_has_bg_threshold();
+ inline void clear_has_bg_threshold();
+ inline void set_has_fg_fraction();
+ inline void clear_has_fg_fraction();
+ inline void set_has_context_pad();
+ inline void clear_has_context_pad();
+ inline void set_has_crop_mode();
+ inline void clear_has_crop_mode();
+ inline void set_has_cache_images();
+ inline void clear_has_cache_images();
+ inline void set_has_root_folder();
+ inline void clear_has_root_folder();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::internal::ArenaStringPtr source_;
+ ::google::protobuf::internal::ArenaStringPtr mean_file_;
+ static ::std::string* _default_crop_mode_;
+ ::google::protobuf::internal::ArenaStringPtr crop_mode_;
+ ::google::protobuf::internal::ArenaStringPtr root_folder_;
+ ::google::protobuf::uint32 batch_size_;
+ ::google::protobuf::uint32 crop_size_;
+ bool mirror_;
+ bool cache_images_;
+ ::google::protobuf::uint32 context_pad_;
+ float scale_;
+ float fg_threshold_;
+ float bg_threshold_;
+ float fg_fraction_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<WindowDataParameter> WindowDataParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class SPPParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.SPPParameter) */ {
+ public:
+ SPPParameter();
+ virtual ~SPPParameter();
+
+ SPPParameter(const SPPParameter& from);
+
+ inline SPPParameter& operator=(const SPPParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const SPPParameter& default_instance();
+
+ static const SPPParameter* internal_default_instance();
+
+ void Swap(SPPParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline SPPParameter* New() const { return New(NULL); }
+
+ SPPParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const SPPParameter& from);
+ void MergeFrom(const SPPParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(SPPParameter* other);
+ void UnsafeMergeFrom(const SPPParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ typedef SPPParameter_PoolMethod PoolMethod;
+ static const PoolMethod MAX =
+ SPPParameter_PoolMethod_MAX;
+ static const PoolMethod AVE =
+ SPPParameter_PoolMethod_AVE;
+ static const PoolMethod STOCHASTIC =
+ SPPParameter_PoolMethod_STOCHASTIC;
+ static inline bool PoolMethod_IsValid(int value) {
+ return SPPParameter_PoolMethod_IsValid(value);
+ }
+ static const PoolMethod PoolMethod_MIN =
+ SPPParameter_PoolMethod_PoolMethod_MIN;
+ static const PoolMethod PoolMethod_MAX =
+ SPPParameter_PoolMethod_PoolMethod_MAX;
+ static const int PoolMethod_ARRAYSIZE =
+ SPPParameter_PoolMethod_PoolMethod_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ PoolMethod_descriptor() {
+ return SPPParameter_PoolMethod_descriptor();
+ }
+ static inline const ::std::string& PoolMethod_Name(PoolMethod value) {
+ return SPPParameter_PoolMethod_Name(value);
+ }
+ static inline bool PoolMethod_Parse(const ::std::string& name,
+ PoolMethod* value) {
+ return SPPParameter_PoolMethod_Parse(name, value);
+ }
+
+ typedef SPPParameter_Engine Engine;
+ static const Engine DEFAULT =
+ SPPParameter_Engine_DEFAULT;
+ static const Engine CAFFE =
+ SPPParameter_Engine_CAFFE;
+ static const Engine CUDNN =
+ SPPParameter_Engine_CUDNN;
+ static inline bool Engine_IsValid(int value) {
+ return SPPParameter_Engine_IsValid(value);
+ }
+ static const Engine Engine_MIN =
+ SPPParameter_Engine_Engine_MIN;
+ static const Engine Engine_MAX =
+ SPPParameter_Engine_Engine_MAX;
+ static const int Engine_ARRAYSIZE =
+ SPPParameter_Engine_Engine_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ Engine_descriptor() {
+ return SPPParameter_Engine_descriptor();
+ }
+ static inline const ::std::string& Engine_Name(Engine value) {
+ return SPPParameter_Engine_Name(value);
+ }
+ static inline bool Engine_Parse(const ::std::string& name,
+ Engine* value) {
+ return SPPParameter_Engine_Parse(name, value);
+ }
+
+ // accessors -------------------------------------------------------
+
+ // optional uint32 pyramid_height = 1;
+ bool has_pyramid_height() const;
+ void clear_pyramid_height();
+ static const int kPyramidHeightFieldNumber = 1;
+ ::google::protobuf::uint32 pyramid_height() const;
+ void set_pyramid_height(::google::protobuf::uint32 value);
+
+ // optional .caffe.SPPParameter.PoolMethod pool = 2 [default = MAX];
+ bool has_pool() const;
+ void clear_pool();
+ static const int kPoolFieldNumber = 2;
+ ::caffe::SPPParameter_PoolMethod pool() const;
+ void set_pool(::caffe::SPPParameter_PoolMethod value);
+
+ // optional .caffe.SPPParameter.Engine engine = 6 [default = DEFAULT];
+ bool has_engine() const;
+ void clear_engine();
+ static const int kEngineFieldNumber = 6;
+ ::caffe::SPPParameter_Engine engine() const;
+ void set_engine(::caffe::SPPParameter_Engine value);
+
+ // @@protoc_insertion_point(class_scope:caffe.SPPParameter)
+ private:
+ inline void set_has_pyramid_height();
+ inline void clear_has_pyramid_height();
+ inline void set_has_pool();
+ inline void clear_has_pool();
+ inline void set_has_engine();
+ inline void clear_has_engine();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::google::protobuf::uint32 pyramid_height_;
+ int pool_;
+ int engine_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<SPPParameter> SPPParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class V1LayerParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.V1LayerParameter) */ {
+ public:
+ V1LayerParameter();
+ virtual ~V1LayerParameter();
+
+ V1LayerParameter(const V1LayerParameter& from);
+
+ inline V1LayerParameter& operator=(const V1LayerParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const V1LayerParameter& default_instance();
+
+ static const V1LayerParameter* internal_default_instance();
+
+ void Swap(V1LayerParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline V1LayerParameter* New() const { return New(NULL); }
+
+ V1LayerParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const V1LayerParameter& from);
+ void MergeFrom(const V1LayerParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(V1LayerParameter* other);
+ void UnsafeMergeFrom(const V1LayerParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ typedef V1LayerParameter_LayerType LayerType;
+ static const LayerType NONE =
+ V1LayerParameter_LayerType_NONE;
+ static const LayerType ABSVAL =
+ V1LayerParameter_LayerType_ABSVAL;
+ static const LayerType ACCURACY =
+ V1LayerParameter_LayerType_ACCURACY;
+ static const LayerType ARGMAX =
+ V1LayerParameter_LayerType_ARGMAX;
+ static const LayerType BNLL =
+ V1LayerParameter_LayerType_BNLL;
+ static const LayerType CONCAT =
+ V1LayerParameter_LayerType_CONCAT;
+ static const LayerType CONTRASTIVE_LOSS =
+ V1LayerParameter_LayerType_CONTRASTIVE_LOSS;
+ static const LayerType CONVOLUTION =
+ V1LayerParameter_LayerType_CONVOLUTION;
+ static const LayerType DATA =
+ V1LayerParameter_LayerType_DATA;
+ static const LayerType DECONVOLUTION =
+ V1LayerParameter_LayerType_DECONVOLUTION;
+ static const LayerType DROPOUT =
+ V1LayerParameter_LayerType_DROPOUT;
+ static const LayerType DUMMY_DATA =
+ V1LayerParameter_LayerType_DUMMY_DATA;
+ static const LayerType EUCLIDEAN_LOSS =
+ V1LayerParameter_LayerType_EUCLIDEAN_LOSS;
+ static const LayerType ELTWISE =
+ V1LayerParameter_LayerType_ELTWISE;
+ static const LayerType EXP =
+ V1LayerParameter_LayerType_EXP;
+ static const LayerType FLATTEN =
+ V1LayerParameter_LayerType_FLATTEN;
+ static const LayerType HDF5_DATA =
+ V1LayerParameter_LayerType_HDF5_DATA;
+ static const LayerType HDF5_OUTPUT =
+ V1LayerParameter_LayerType_HDF5_OUTPUT;
+ static const LayerType HINGE_LOSS =
+ V1LayerParameter_LayerType_HINGE_LOSS;
+ static const LayerType IM2COL =
+ V1LayerParameter_LayerType_IM2COL;
+ static const LayerType IMAGE_DATA =
+ V1LayerParameter_LayerType_IMAGE_DATA;
+ static const LayerType INFOGAIN_LOSS =
+ V1LayerParameter_LayerType_INFOGAIN_LOSS;
+ static const LayerType INNER_PRODUCT =
+ V1LayerParameter_LayerType_INNER_PRODUCT;
+ static const LayerType LRN =
+ V1LayerParameter_LayerType_LRN;
+ static const LayerType MEMORY_DATA =
+ V1LayerParameter_LayerType_MEMORY_DATA;
+ static const LayerType MULTINOMIAL_LOGISTIC_LOSS =
+ V1LayerParameter_LayerType_MULTINOMIAL_LOGISTIC_LOSS;
+ static const LayerType MVN =
+ V1LayerParameter_LayerType_MVN;
+ static const LayerType POOLING =
+ V1LayerParameter_LayerType_POOLING;
+ static const LayerType POWER =
+ V1LayerParameter_LayerType_POWER;
+ static const LayerType RELU =
+ V1LayerParameter_LayerType_RELU;
+ static const LayerType SIGMOID =
+ V1LayerParameter_LayerType_SIGMOID;
+ static const LayerType SIGMOID_CROSS_ENTROPY_LOSS =
+ V1LayerParameter_LayerType_SIGMOID_CROSS_ENTROPY_LOSS;
+ static const LayerType SILENCE =
+ V1LayerParameter_LayerType_SILENCE;
+ static const LayerType SOFTMAX =
+ V1LayerParameter_LayerType_SOFTMAX;
+ static const LayerType SOFTMAX_LOSS =
+ V1LayerParameter_LayerType_SOFTMAX_LOSS;
+ static const LayerType SPLIT =
+ V1LayerParameter_LayerType_SPLIT;
+ static const LayerType SLICE =
+ V1LayerParameter_LayerType_SLICE;
+ static const LayerType TANH =
+ V1LayerParameter_LayerType_TANH;
+ static const LayerType WINDOW_DATA =
+ V1LayerParameter_LayerType_WINDOW_DATA;
+ static const LayerType THRESHOLD =
+ V1LayerParameter_LayerType_THRESHOLD;
+ static inline bool LayerType_IsValid(int value) {
+ return V1LayerParameter_LayerType_IsValid(value);
+ }
+ static const LayerType LayerType_MIN =
+ V1LayerParameter_LayerType_LayerType_MIN;
+ static const LayerType LayerType_MAX =
+ V1LayerParameter_LayerType_LayerType_MAX;
+ static const int LayerType_ARRAYSIZE =
+ V1LayerParameter_LayerType_LayerType_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ LayerType_descriptor() {
+ return V1LayerParameter_LayerType_descriptor();
+ }
+ static inline const ::std::string& LayerType_Name(LayerType value) {
+ return V1LayerParameter_LayerType_Name(value);
+ }
+ static inline bool LayerType_Parse(const ::std::string& name,
+ LayerType* value) {
+ return V1LayerParameter_LayerType_Parse(name, value);
+ }
+
+ typedef V1LayerParameter_DimCheckMode DimCheckMode;
+ static const DimCheckMode STRICT =
+ V1LayerParameter_DimCheckMode_STRICT;
+ static const DimCheckMode PERMISSIVE =
+ V1LayerParameter_DimCheckMode_PERMISSIVE;
+ static inline bool DimCheckMode_IsValid(int value) {
+ return V1LayerParameter_DimCheckMode_IsValid(value);
+ }
+ static const DimCheckMode DimCheckMode_MIN =
+ V1LayerParameter_DimCheckMode_DimCheckMode_MIN;
+ static const DimCheckMode DimCheckMode_MAX =
+ V1LayerParameter_DimCheckMode_DimCheckMode_MAX;
+ static const int DimCheckMode_ARRAYSIZE =
+ V1LayerParameter_DimCheckMode_DimCheckMode_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ DimCheckMode_descriptor() {
+ return V1LayerParameter_DimCheckMode_descriptor();
+ }
+ static inline const ::std::string& DimCheckMode_Name(DimCheckMode value) {
+ return V1LayerParameter_DimCheckMode_Name(value);
+ }
+ static inline bool DimCheckMode_Parse(const ::std::string& name,
+ DimCheckMode* value) {
+ return V1LayerParameter_DimCheckMode_Parse(name, value);
+ }
+
+ // accessors -------------------------------------------------------
+
+ // repeated string bottom = 2;
+ int bottom_size() const;
+ void clear_bottom();
+ static const int kBottomFieldNumber = 2;
+ const ::std::string& bottom(int index) const;
+ ::std::string* mutable_bottom(int index);
+ void set_bottom(int index, const ::std::string& value);
+ void set_bottom(int index, const char* value);
+ void set_bottom(int index, const char* value, size_t size);
+ ::std::string* add_bottom();
+ void add_bottom(const ::std::string& value);
+ void add_bottom(const char* value);
+ void add_bottom(const char* value, size_t size);
+ const ::google::protobuf::RepeatedPtrField< ::std::string>& bottom() const;
+ ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_bottom();
+
+ // repeated string top = 3;
+ int top_size() const;
+ void clear_top();
+ static const int kTopFieldNumber = 3;
+ const ::std::string& top(int index) const;
+ ::std::string* mutable_top(int index);
+ void set_top(int index, const ::std::string& value);
+ void set_top(int index, const char* value);
+ void set_top(int index, const char* value, size_t size);
+ ::std::string* add_top();
+ void add_top(const ::std::string& value);
+ void add_top(const char* value);
+ void add_top(const char* value, size_t size);
+ const ::google::protobuf::RepeatedPtrField< ::std::string>& top() const;
+ ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_top();
+
+ // optional string name = 4;
+ bool has_name() const;
+ void clear_name();
+ static const int kNameFieldNumber = 4;
+ const ::std::string& name() const;
+ void set_name(const ::std::string& value);
+ void set_name(const char* value);
+ void set_name(const char* value, size_t size);
+ ::std::string* mutable_name();
+ ::std::string* release_name();
+ void set_allocated_name(::std::string* name);
+
+ // repeated .caffe.NetStateRule include = 32;
+ int include_size() const;
+ void clear_include();
+ static const int kIncludeFieldNumber = 32;
+ const ::caffe::NetStateRule& include(int index) const;
+ ::caffe::NetStateRule* mutable_include(int index);
+ ::caffe::NetStateRule* add_include();
+ ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >*
+ mutable_include();
+ const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >&
+ include() const;
+
+ // repeated .caffe.NetStateRule exclude = 33;
+ int exclude_size() const;
+ void clear_exclude();
+ static const int kExcludeFieldNumber = 33;
+ const ::caffe::NetStateRule& exclude(int index) const;
+ ::caffe::NetStateRule* mutable_exclude(int index);
+ ::caffe::NetStateRule* add_exclude();
+ ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >*
+ mutable_exclude();
+ const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >&
+ exclude() const;
+
+ // optional .caffe.V1LayerParameter.LayerType type = 5;
+ bool has_type() const;
+ void clear_type();
+ static const int kTypeFieldNumber = 5;
+ ::caffe::V1LayerParameter_LayerType type() const;
+ void set_type(::caffe::V1LayerParameter_LayerType value);
+
+ // repeated .caffe.BlobProto blobs = 6;
+ int blobs_size() const;
+ void clear_blobs();
+ static const int kBlobsFieldNumber = 6;
+ const ::caffe::BlobProto& blobs(int index) const;
+ ::caffe::BlobProto* mutable_blobs(int index);
+ ::caffe::BlobProto* add_blobs();
+ ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
+ mutable_blobs();
+ const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
+ blobs() const;
+
+ // repeated string param = 1001;
+ int param_size() const;
+ void clear_param();
+ static const int kParamFieldNumber = 1001;
+ const ::std::string& param(int index) const;
+ ::std::string* mutable_param(int index);
+ void set_param(int index, const ::std::string& value);
+ void set_param(int index, const char* value);
+ void set_param(int index, const char* value, size_t size);
+ ::std::string* add_param();
+ void add_param(const ::std::string& value);
+ void add_param(const char* value);
+ void add_param(const char* value, size_t size);
+ const ::google::protobuf::RepeatedPtrField< ::std::string>& param() const;
+ ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_param();
+
+ // repeated .caffe.V1LayerParameter.DimCheckMode blob_share_mode = 1002;
+ int blob_share_mode_size() const;
+ void clear_blob_share_mode();
+ static const int kBlobShareModeFieldNumber = 1002;
+ ::caffe::V1LayerParameter_DimCheckMode blob_share_mode(int index) const;
+ void set_blob_share_mode(int index, ::caffe::V1LayerParameter_DimCheckMode value);
+ void add_blob_share_mode(::caffe::V1LayerParameter_DimCheckMode value);
+ const ::google::protobuf::RepeatedField<int>& blob_share_mode() const;
+ ::google::protobuf::RepeatedField<int>* mutable_blob_share_mode();
+
+ // repeated float blobs_lr = 7;
+ int blobs_lr_size() const;
+ void clear_blobs_lr();
+ static const int kBlobsLrFieldNumber = 7;
+ float blobs_lr(int index) const;
+ void set_blobs_lr(int index, float value);
+ void add_blobs_lr(float value);
+ const ::google::protobuf::RepeatedField< float >&
+ blobs_lr() const;
+ ::google::protobuf::RepeatedField< float >*
+ mutable_blobs_lr();
+
+ // repeated float weight_decay = 8;
+ int weight_decay_size() const;
+ void clear_weight_decay();
+ static const int kWeightDecayFieldNumber = 8;
+ float weight_decay(int index) const;
+ void set_weight_decay(int index, float value);
+ void add_weight_decay(float value);
+ const ::google::protobuf::RepeatedField< float >&
+ weight_decay() const;
+ ::google::protobuf::RepeatedField< float >*
+ mutable_weight_decay();
+
+ // repeated float loss_weight = 35;
+ int loss_weight_size() const;
+ void clear_loss_weight();
+ static const int kLossWeightFieldNumber = 35;
+ float loss_weight(int index) const;
+ void set_loss_weight(int index, float value);
+ void add_loss_weight(float value);
+ const ::google::protobuf::RepeatedField< float >&
+ loss_weight() const;
+ ::google::protobuf::RepeatedField< float >*
+ mutable_loss_weight();
+
+ // optional .caffe.AccuracyParameter accuracy_param = 27;
+ bool has_accuracy_param() const;
+ void clear_accuracy_param();
+ static const int kAccuracyParamFieldNumber = 27;
+ const ::caffe::AccuracyParameter& accuracy_param() const;
+ ::caffe::AccuracyParameter* mutable_accuracy_param();
+ ::caffe::AccuracyParameter* release_accuracy_param();
+ void set_allocated_accuracy_param(::caffe::AccuracyParameter* accuracy_param);
+
+ // optional .caffe.ArgMaxParameter argmax_param = 23;
+ bool has_argmax_param() const;
+ void clear_argmax_param();
+ static const int kArgmaxParamFieldNumber = 23;
+ const ::caffe::ArgMaxParameter& argmax_param() const;
+ ::caffe::ArgMaxParameter* mutable_argmax_param();
+ ::caffe::ArgMaxParameter* release_argmax_param();
+ void set_allocated_argmax_param(::caffe::ArgMaxParameter* argmax_param);
+
+ // optional .caffe.ConcatParameter concat_param = 9;
+ bool has_concat_param() const;
+ void clear_concat_param();
+ static const int kConcatParamFieldNumber = 9;
+ const ::caffe::ConcatParameter& concat_param() const;
+ ::caffe::ConcatParameter* mutable_concat_param();
+ ::caffe::ConcatParameter* release_concat_param();
+ void set_allocated_concat_param(::caffe::ConcatParameter* concat_param);
+
+ // optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40;
+ bool has_contrastive_loss_param() const;
+ void clear_contrastive_loss_param();
+ static const int kContrastiveLossParamFieldNumber = 40;
+ const ::caffe::ContrastiveLossParameter& contrastive_loss_param() const;
+ ::caffe::ContrastiveLossParameter* mutable_contrastive_loss_param();
+ ::caffe::ContrastiveLossParameter* release_contrastive_loss_param();
+ void set_allocated_contrastive_loss_param(::caffe::ContrastiveLossParameter* contrastive_loss_param);
+
+ // optional .caffe.ConvolutionParameter convolution_param = 10;
+ bool has_convolution_param() const;
+ void clear_convolution_param();
+ static const int kConvolutionParamFieldNumber = 10;
+ const ::caffe::ConvolutionParameter& convolution_param() const;
+ ::caffe::ConvolutionParameter* mutable_convolution_param();
+ ::caffe::ConvolutionParameter* release_convolution_param();
+ void set_allocated_convolution_param(::caffe::ConvolutionParameter* convolution_param);
+
+ // optional .caffe.DataParameter data_param = 11;
+ bool has_data_param() const;
+ void clear_data_param();
+ static const int kDataParamFieldNumber = 11;
+ const ::caffe::DataParameter& data_param() const;
+ ::caffe::DataParameter* mutable_data_param();
+ ::caffe::DataParameter* release_data_param();
+ void set_allocated_data_param(::caffe::DataParameter* data_param);
+
+ // optional .caffe.DropoutParameter dropout_param = 12;
+ bool has_dropout_param() const;
+ void clear_dropout_param();
+ static const int kDropoutParamFieldNumber = 12;
+ const ::caffe::DropoutParameter& dropout_param() const;
+ ::caffe::DropoutParameter* mutable_dropout_param();
+ ::caffe::DropoutParameter* release_dropout_param();
+ void set_allocated_dropout_param(::caffe::DropoutParameter* dropout_param);
+
+ // optional .caffe.DummyDataParameter dummy_data_param = 26;
+ bool has_dummy_data_param() const;
+ void clear_dummy_data_param();
+ static const int kDummyDataParamFieldNumber = 26;
+ const ::caffe::DummyDataParameter& dummy_data_param() const;
+ ::caffe::DummyDataParameter* mutable_dummy_data_param();
+ ::caffe::DummyDataParameter* release_dummy_data_param();
+ void set_allocated_dummy_data_param(::caffe::DummyDataParameter* dummy_data_param);
+
+ // optional .caffe.EltwiseParameter eltwise_param = 24;
+ bool has_eltwise_param() const;
+ void clear_eltwise_param();
+ static const int kEltwiseParamFieldNumber = 24;
+ const ::caffe::EltwiseParameter& eltwise_param() const;
+ ::caffe::EltwiseParameter* mutable_eltwise_param();
+ ::caffe::EltwiseParameter* release_eltwise_param();
+ void set_allocated_eltwise_param(::caffe::EltwiseParameter* eltwise_param);
+
+ // optional .caffe.ExpParameter exp_param = 41;
+ bool has_exp_param() const;
+ void clear_exp_param();
+ static const int kExpParamFieldNumber = 41;
+ const ::caffe::ExpParameter& exp_param() const;
+ ::caffe::ExpParameter* mutable_exp_param();
+ ::caffe::ExpParameter* release_exp_param();
+ void set_allocated_exp_param(::caffe::ExpParameter* exp_param);
+
+ // optional .caffe.HDF5DataParameter hdf5_data_param = 13;
+ bool has_hdf5_data_param() const;
+ void clear_hdf5_data_param();
+ static const int kHdf5DataParamFieldNumber = 13;
+ const ::caffe::HDF5DataParameter& hdf5_data_param() const;
+ ::caffe::HDF5DataParameter* mutable_hdf5_data_param();
+ ::caffe::HDF5DataParameter* release_hdf5_data_param();
+ void set_allocated_hdf5_data_param(::caffe::HDF5DataParameter* hdf5_data_param);
+
+ // optional .caffe.HDF5OutputParameter hdf5_output_param = 14;
+ bool has_hdf5_output_param() const;
+ void clear_hdf5_output_param();
+ static const int kHdf5OutputParamFieldNumber = 14;
+ const ::caffe::HDF5OutputParameter& hdf5_output_param() const;
+ ::caffe::HDF5OutputParameter* mutable_hdf5_output_param();
+ ::caffe::HDF5OutputParameter* release_hdf5_output_param();
+ void set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param);
+
+ // optional .caffe.HingeLossParameter hinge_loss_param = 29;
+ bool has_hinge_loss_param() const;
+ void clear_hinge_loss_param();
+ static const int kHingeLossParamFieldNumber = 29;
+ const ::caffe::HingeLossParameter& hinge_loss_param() const;
+ ::caffe::HingeLossParameter* mutable_hinge_loss_param();
+ ::caffe::HingeLossParameter* release_hinge_loss_param();
+ void set_allocated_hinge_loss_param(::caffe::HingeLossParameter* hinge_loss_param);
+
+ // optional .caffe.ImageDataParameter image_data_param = 15;
+ bool has_image_data_param() const;
+ void clear_image_data_param();
+ static const int kImageDataParamFieldNumber = 15;
+ const ::caffe::ImageDataParameter& image_data_param() const;
+ ::caffe::ImageDataParameter* mutable_image_data_param();
+ ::caffe::ImageDataParameter* release_image_data_param();
+ void set_allocated_image_data_param(::caffe::ImageDataParameter* image_data_param);
+
+ // optional .caffe.InfogainLossParameter infogain_loss_param = 16;
+ bool has_infogain_loss_param() const;
+ void clear_infogain_loss_param();
+ static const int kInfogainLossParamFieldNumber = 16;
+ const ::caffe::InfogainLossParameter& infogain_loss_param() const;
+ ::caffe::InfogainLossParameter* mutable_infogain_loss_param();
+ ::caffe::InfogainLossParameter* release_infogain_loss_param();
+ void set_allocated_infogain_loss_param(::caffe::InfogainLossParameter* infogain_loss_param);
+
+ // optional .caffe.InnerProductParameter inner_product_param = 17;
+ bool has_inner_product_param() const;
+ void clear_inner_product_param();
+ static const int kInnerProductParamFieldNumber = 17;
+ const ::caffe::InnerProductParameter& inner_product_param() const;
+ ::caffe::InnerProductParameter* mutable_inner_product_param();
+ ::caffe::InnerProductParameter* release_inner_product_param();
+ void set_allocated_inner_product_param(::caffe::InnerProductParameter* inner_product_param);
+
+ // optional .caffe.LRNParameter lrn_param = 18;
+ bool has_lrn_param() const;
+ void clear_lrn_param();
+ static const int kLrnParamFieldNumber = 18;
+ const ::caffe::LRNParameter& lrn_param() const;
+ ::caffe::LRNParameter* mutable_lrn_param();
+ ::caffe::LRNParameter* release_lrn_param();
+ void set_allocated_lrn_param(::caffe::LRNParameter* lrn_param);
+
+ // optional .caffe.MemoryDataParameter memory_data_param = 22;
+ bool has_memory_data_param() const;
+ void clear_memory_data_param();
+ static const int kMemoryDataParamFieldNumber = 22;
+ const ::caffe::MemoryDataParameter& memory_data_param() const;
+ ::caffe::MemoryDataParameter* mutable_memory_data_param();
+ ::caffe::MemoryDataParameter* release_memory_data_param();
+ void set_allocated_memory_data_param(::caffe::MemoryDataParameter* memory_data_param);
+
+ // optional .caffe.MVNParameter mvn_param = 34;
+ bool has_mvn_param() const;
+ void clear_mvn_param();
+ static const int kMvnParamFieldNumber = 34;
+ const ::caffe::MVNParameter& mvn_param() const;
+ ::caffe::MVNParameter* mutable_mvn_param();
+ ::caffe::MVNParameter* release_mvn_param();
+ void set_allocated_mvn_param(::caffe::MVNParameter* mvn_param);
+
+ // optional .caffe.PoolingParameter pooling_param = 19;
+ bool has_pooling_param() const;
+ void clear_pooling_param();
+ static const int kPoolingParamFieldNumber = 19;
+ const ::caffe::PoolingParameter& pooling_param() const;
+ ::caffe::PoolingParameter* mutable_pooling_param();
+ ::caffe::PoolingParameter* release_pooling_param();
+ void set_allocated_pooling_param(::caffe::PoolingParameter* pooling_param);
+
+ // optional .caffe.PowerParameter power_param = 21;
+ bool has_power_param() const;
+ void clear_power_param();
+ static const int kPowerParamFieldNumber = 21;
+ const ::caffe::PowerParameter& power_param() const;
+ ::caffe::PowerParameter* mutable_power_param();
+ ::caffe::PowerParameter* release_power_param();
+ void set_allocated_power_param(::caffe::PowerParameter* power_param);
+
+ // optional .caffe.ReLUParameter relu_param = 30;
+ bool has_relu_param() const;
+ void clear_relu_param();
+ static const int kReluParamFieldNumber = 30;
+ const ::caffe::ReLUParameter& relu_param() const;
+ ::caffe::ReLUParameter* mutable_relu_param();
+ ::caffe::ReLUParameter* release_relu_param();
+ void set_allocated_relu_param(::caffe::ReLUParameter* relu_param);
+
+ // optional .caffe.SigmoidParameter sigmoid_param = 38;
+ bool has_sigmoid_param() const;
+ void clear_sigmoid_param();
+ static const int kSigmoidParamFieldNumber = 38;
+ const ::caffe::SigmoidParameter& sigmoid_param() const;
+ ::caffe::SigmoidParameter* mutable_sigmoid_param();
+ ::caffe::SigmoidParameter* release_sigmoid_param();
+ void set_allocated_sigmoid_param(::caffe::SigmoidParameter* sigmoid_param);
+
+ // optional .caffe.SoftmaxParameter softmax_param = 39;
+ bool has_softmax_param() const;
+ void clear_softmax_param();
+ static const int kSoftmaxParamFieldNumber = 39;
+ const ::caffe::SoftmaxParameter& softmax_param() const;
+ ::caffe::SoftmaxParameter* mutable_softmax_param();
+ ::caffe::SoftmaxParameter* release_softmax_param();
+ void set_allocated_softmax_param(::caffe::SoftmaxParameter* softmax_param);
+
+ // optional .caffe.SliceParameter slice_param = 31;
+ bool has_slice_param() const;
+ void clear_slice_param();
+ static const int kSliceParamFieldNumber = 31;
+ const ::caffe::SliceParameter& slice_param() const;
+ ::caffe::SliceParameter* mutable_slice_param();
+ ::caffe::SliceParameter* release_slice_param();
+ void set_allocated_slice_param(::caffe::SliceParameter* slice_param);
+
+ // optional .caffe.TanHParameter tanh_param = 37;
+ bool has_tanh_param() const;
+ void clear_tanh_param();
+ static const int kTanhParamFieldNumber = 37;
+ const ::caffe::TanHParameter& tanh_param() const;
+ ::caffe::TanHParameter* mutable_tanh_param();
+ ::caffe::TanHParameter* release_tanh_param();
+ void set_allocated_tanh_param(::caffe::TanHParameter* tanh_param);
+
+ // optional .caffe.ThresholdParameter threshold_param = 25;
+ bool has_threshold_param() const;
+ void clear_threshold_param();
+ static const int kThresholdParamFieldNumber = 25;
+ const ::caffe::ThresholdParameter& threshold_param() const;
+ ::caffe::ThresholdParameter* mutable_threshold_param();
+ ::caffe::ThresholdParameter* release_threshold_param();
+ void set_allocated_threshold_param(::caffe::ThresholdParameter* threshold_param);
+
+ // optional .caffe.WindowDataParameter window_data_param = 20;
+ bool has_window_data_param() const;
+ void clear_window_data_param();
+ static const int kWindowDataParamFieldNumber = 20;
+ const ::caffe::WindowDataParameter& window_data_param() const;
+ ::caffe::WindowDataParameter* mutable_window_data_param();
+ ::caffe::WindowDataParameter* release_window_data_param();
+ void set_allocated_window_data_param(::caffe::WindowDataParameter* window_data_param);
+
+ // optional .caffe.TransformationParameter transform_param = 36;
+ bool has_transform_param() const;
+ void clear_transform_param();
+ static const int kTransformParamFieldNumber = 36;
+ const ::caffe::TransformationParameter& transform_param() const;
+ ::caffe::TransformationParameter* mutable_transform_param();
+ ::caffe::TransformationParameter* release_transform_param();
+ void set_allocated_transform_param(::caffe::TransformationParameter* transform_param);
+
+ // optional .caffe.LossParameter loss_param = 42;
+ bool has_loss_param() const;
+ void clear_loss_param();
+ static const int kLossParamFieldNumber = 42;
+ const ::caffe::LossParameter& loss_param() const;
+ ::caffe::LossParameter* mutable_loss_param();
+ ::caffe::LossParameter* release_loss_param();
+ void set_allocated_loss_param(::caffe::LossParameter* loss_param);
+
+ // optional .caffe.V0LayerParameter layer = 1;
+ bool has_layer() const;
+ void clear_layer();
+ static const int kLayerFieldNumber = 1;
+ const ::caffe::V0LayerParameter& layer() const;
+ ::caffe::V0LayerParameter* mutable_layer();
+ ::caffe::V0LayerParameter* release_layer();
+ void set_allocated_layer(::caffe::V0LayerParameter* layer);
+
+ // @@protoc_insertion_point(class_scope:caffe.V1LayerParameter)
+ private:
+ inline void set_has_name();
+ inline void clear_has_name();
+ inline void set_has_type();
+ inline void clear_has_type();
+ inline void set_has_accuracy_param();
+ inline void clear_has_accuracy_param();
+ inline void set_has_argmax_param();
+ inline void clear_has_argmax_param();
+ inline void set_has_concat_param();
+ inline void clear_has_concat_param();
+ inline void set_has_contrastive_loss_param();
+ inline void clear_has_contrastive_loss_param();
+ inline void set_has_convolution_param();
+ inline void clear_has_convolution_param();
+ inline void set_has_data_param();
+ inline void clear_has_data_param();
+ inline void set_has_dropout_param();
+ inline void clear_has_dropout_param();
+ inline void set_has_dummy_data_param();
+ inline void clear_has_dummy_data_param();
+ inline void set_has_eltwise_param();
+ inline void clear_has_eltwise_param();
+ inline void set_has_exp_param();
+ inline void clear_has_exp_param();
+ inline void set_has_hdf5_data_param();
+ inline void clear_has_hdf5_data_param();
+ inline void set_has_hdf5_output_param();
+ inline void clear_has_hdf5_output_param();
+ inline void set_has_hinge_loss_param();
+ inline void clear_has_hinge_loss_param();
+ inline void set_has_image_data_param();
+ inline void clear_has_image_data_param();
+ inline void set_has_infogain_loss_param();
+ inline void clear_has_infogain_loss_param();
+ inline void set_has_inner_product_param();
+ inline void clear_has_inner_product_param();
+ inline void set_has_lrn_param();
+ inline void clear_has_lrn_param();
+ inline void set_has_memory_data_param();
+ inline void clear_has_memory_data_param();
+ inline void set_has_mvn_param();
+ inline void clear_has_mvn_param();
+ inline void set_has_pooling_param();
+ inline void clear_has_pooling_param();
+ inline void set_has_power_param();
+ inline void clear_has_power_param();
+ inline void set_has_relu_param();
+ inline void clear_has_relu_param();
+ inline void set_has_sigmoid_param();
+ inline void clear_has_sigmoid_param();
+ inline void set_has_softmax_param();
+ inline void clear_has_softmax_param();
+ inline void set_has_slice_param();
+ inline void clear_has_slice_param();
+ inline void set_has_tanh_param();
+ inline void clear_has_tanh_param();
+ inline void set_has_threshold_param();
+ inline void clear_has_threshold_param();
+ inline void set_has_window_data_param();
+ inline void clear_has_window_data_param();
+ inline void set_has_transform_param();
+ inline void clear_has_transform_param();
+ inline void set_has_loss_param();
+ inline void clear_has_loss_param();
+ inline void set_has_layer();
+ inline void clear_has_layer();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<2> _has_bits_;
+ ::google::protobuf::RepeatedPtrField< ::std::string> bottom_;
+ ::google::protobuf::RepeatedPtrField< ::std::string> top_;
+ ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule > include_;
+ ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule > exclude_;
+ ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto > blobs_;
+ ::google::protobuf::RepeatedPtrField< ::std::string> param_;
+ ::google::protobuf::RepeatedField<int> blob_share_mode_;
+ ::google::protobuf::RepeatedField< float > blobs_lr_;
+ ::google::protobuf::RepeatedField< float > weight_decay_;
+ ::google::protobuf::RepeatedField< float > loss_weight_;
+ ::google::protobuf::internal::ArenaStringPtr name_;
+ ::caffe::AccuracyParameter* accuracy_param_;
+ ::caffe::ArgMaxParameter* argmax_param_;
+ ::caffe::ConcatParameter* concat_param_;
+ ::caffe::ContrastiveLossParameter* contrastive_loss_param_;
+ ::caffe::ConvolutionParameter* convolution_param_;
+ ::caffe::DataParameter* data_param_;
+ ::caffe::DropoutParameter* dropout_param_;
+ ::caffe::DummyDataParameter* dummy_data_param_;
+ ::caffe::EltwiseParameter* eltwise_param_;
+ ::caffe::ExpParameter* exp_param_;
+ ::caffe::HDF5DataParameter* hdf5_data_param_;
+ ::caffe::HDF5OutputParameter* hdf5_output_param_;
+ ::caffe::HingeLossParameter* hinge_loss_param_;
+ ::caffe::ImageDataParameter* image_data_param_;
+ ::caffe::InfogainLossParameter* infogain_loss_param_;
+ ::caffe::InnerProductParameter* inner_product_param_;
+ ::caffe::LRNParameter* lrn_param_;
+ ::caffe::MemoryDataParameter* memory_data_param_;
+ ::caffe::MVNParameter* mvn_param_;
+ ::caffe::PoolingParameter* pooling_param_;
+ ::caffe::PowerParameter* power_param_;
+ ::caffe::ReLUParameter* relu_param_;
+ ::caffe::SigmoidParameter* sigmoid_param_;
+ ::caffe::SoftmaxParameter* softmax_param_;
+ ::caffe::SliceParameter* slice_param_;
+ ::caffe::TanHParameter* tanh_param_;
+ ::caffe::ThresholdParameter* threshold_param_;
+ ::caffe::WindowDataParameter* window_data_param_;
+ ::caffe::TransformationParameter* transform_param_;
+ ::caffe::LossParameter* loss_param_;
+ ::caffe::V0LayerParameter* layer_;
+ int type_;
+ mutable int _cached_size_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<V1LayerParameter> V1LayerParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class V0LayerParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.V0LayerParameter) */ {
+ public:
+ V0LayerParameter();
+ virtual ~V0LayerParameter();
+
+ V0LayerParameter(const V0LayerParameter& from);
+
+ inline V0LayerParameter& operator=(const V0LayerParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const V0LayerParameter& default_instance();
+
+ static const V0LayerParameter* internal_default_instance();
+
+ void Swap(V0LayerParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline V0LayerParameter* New() const { return New(NULL); }
+
+ V0LayerParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const V0LayerParameter& from);
+ void MergeFrom(const V0LayerParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(V0LayerParameter* other);
+ void UnsafeMergeFrom(const V0LayerParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ typedef V0LayerParameter_PoolMethod PoolMethod;
+ static const PoolMethod MAX =
+ V0LayerParameter_PoolMethod_MAX;
+ static const PoolMethod AVE =
+ V0LayerParameter_PoolMethod_AVE;
+ static const PoolMethod STOCHASTIC =
+ V0LayerParameter_PoolMethod_STOCHASTIC;
+ static inline bool PoolMethod_IsValid(int value) {
+ return V0LayerParameter_PoolMethod_IsValid(value);
+ }
+ static const PoolMethod PoolMethod_MIN =
+ V0LayerParameter_PoolMethod_PoolMethod_MIN;
+ static const PoolMethod PoolMethod_MAX =
+ V0LayerParameter_PoolMethod_PoolMethod_MAX;
+ static const int PoolMethod_ARRAYSIZE =
+ V0LayerParameter_PoolMethod_PoolMethod_ARRAYSIZE;
+ static inline const ::google::protobuf::EnumDescriptor*
+ PoolMethod_descriptor() {
+ return V0LayerParameter_PoolMethod_descriptor();
+ }
+ static inline const ::std::string& PoolMethod_Name(PoolMethod value) {
+ return V0LayerParameter_PoolMethod_Name(value);
+ }
+ static inline bool PoolMethod_Parse(const ::std::string& name,
+ PoolMethod* value) {
+ return V0LayerParameter_PoolMethod_Parse(name, value);
+ }
+
+ // accessors -------------------------------------------------------
+
+ // optional string name = 1;
+ bool has_name() const;
+ void clear_name();
+ static const int kNameFieldNumber = 1;
+ const ::std::string& name() const;
+ void set_name(const ::std::string& value);
+ void set_name(const char* value);
+ void set_name(const char* value, size_t size);
+ ::std::string* mutable_name();
+ ::std::string* release_name();
+ void set_allocated_name(::std::string* name);
+
+ // optional string type = 2;
+ bool has_type() const;
+ void clear_type();
+ static const int kTypeFieldNumber = 2;
+ const ::std::string& type() const;
+ void set_type(const ::std::string& value);
+ void set_type(const char* value);
+ void set_type(const char* value, size_t size);
+ ::std::string* mutable_type();
+ ::std::string* release_type();
+ void set_allocated_type(::std::string* type);
+
+ // optional uint32 num_output = 3;
+ bool has_num_output() const;
+ void clear_num_output();
+ static const int kNumOutputFieldNumber = 3;
+ ::google::protobuf::uint32 num_output() const;
+ void set_num_output(::google::protobuf::uint32 value);
+
+ // optional bool biasterm = 4 [default = true];
+ bool has_biasterm() const;
+ void clear_biasterm();
+ static const int kBiastermFieldNumber = 4;
+ bool biasterm() const;
+ void set_biasterm(bool value);
+
+ // optional .caffe.FillerParameter weight_filler = 5;
+ bool has_weight_filler() const;
+ void clear_weight_filler();
+ static const int kWeightFillerFieldNumber = 5;
+ const ::caffe::FillerParameter& weight_filler() const;
+ ::caffe::FillerParameter* mutable_weight_filler();
+ ::caffe::FillerParameter* release_weight_filler();
+ void set_allocated_weight_filler(::caffe::FillerParameter* weight_filler);
+
+ // optional .caffe.FillerParameter bias_filler = 6;
+ bool has_bias_filler() const;
+ void clear_bias_filler();
+ static const int kBiasFillerFieldNumber = 6;
+ const ::caffe::FillerParameter& bias_filler() const;
+ ::caffe::FillerParameter* mutable_bias_filler();
+ ::caffe::FillerParameter* release_bias_filler();
+ void set_allocated_bias_filler(::caffe::FillerParameter* bias_filler);
+
+ // optional uint32 pad = 7 [default = 0];
+ bool has_pad() const;
+ void clear_pad();
+ static const int kPadFieldNumber = 7;
+ ::google::protobuf::uint32 pad() const;
+ void set_pad(::google::protobuf::uint32 value);
+
+ // optional uint32 kernelsize = 8;
+ bool has_kernelsize() const;
+ void clear_kernelsize();
+ static const int kKernelsizeFieldNumber = 8;
+ ::google::protobuf::uint32 kernelsize() const;
+ void set_kernelsize(::google::protobuf::uint32 value);
+
+ // optional uint32 group = 9 [default = 1];
+ bool has_group() const;
+ void clear_group();
+ static const int kGroupFieldNumber = 9;
+ ::google::protobuf::uint32 group() const;
+ void set_group(::google::protobuf::uint32 value);
+
+ // optional uint32 stride = 10 [default = 1];
+ bool has_stride() const;
+ void clear_stride();
+ static const int kStrideFieldNumber = 10;
+ ::google::protobuf::uint32 stride() const;
+ void set_stride(::google::protobuf::uint32 value);
+
+ // optional .caffe.V0LayerParameter.PoolMethod pool = 11 [default = MAX];
+ bool has_pool() const;
+ void clear_pool();
+ static const int kPoolFieldNumber = 11;
+ ::caffe::V0LayerParameter_PoolMethod pool() const;
+ void set_pool(::caffe::V0LayerParameter_PoolMethod value);
+
+ // optional float dropout_ratio = 12 [default = 0.5];
+ bool has_dropout_ratio() const;
+ void clear_dropout_ratio();
+ static const int kDropoutRatioFieldNumber = 12;
+ float dropout_ratio() const;
+ void set_dropout_ratio(float value);
+
+ // optional uint32 local_size = 13 [default = 5];
+ bool has_local_size() const;
+ void clear_local_size();
+ static const int kLocalSizeFieldNumber = 13;
+ ::google::protobuf::uint32 local_size() const;
+ void set_local_size(::google::protobuf::uint32 value);
+
+ // optional float alpha = 14 [default = 1];
+ bool has_alpha() const;
+ void clear_alpha();
+ static const int kAlphaFieldNumber = 14;
+ float alpha() const;
+ void set_alpha(float value);
+
+ // optional float beta = 15 [default = 0.75];
+ bool has_beta() const;
+ void clear_beta();
+ static const int kBetaFieldNumber = 15;
+ float beta() const;
+ void set_beta(float value);
+
+ // optional float k = 22 [default = 1];
+ bool has_k() const;
+ void clear_k();
+ static const int kKFieldNumber = 22;
+ float k() const;
+ void set_k(float value);
+
+ // optional string source = 16;
+ bool has_source() const;
+ void clear_source();
+ static const int kSourceFieldNumber = 16;
+ const ::std::string& source() const;
+ void set_source(const ::std::string& value);
+ void set_source(const char* value);
+ void set_source(const char* value, size_t size);
+ ::std::string* mutable_source();
+ ::std::string* release_source();
+ void set_allocated_source(::std::string* source);
+
+ // optional float scale = 17 [default = 1];
+ bool has_scale() const;
+ void clear_scale();
+ static const int kScaleFieldNumber = 17;
+ float scale() const;
+ void set_scale(float value);
+
+ // optional string meanfile = 18;
+ bool has_meanfile() const;
+ void clear_meanfile();
+ static const int kMeanfileFieldNumber = 18;
+ const ::std::string& meanfile() const;
+ void set_meanfile(const ::std::string& value);
+ void set_meanfile(const char* value);
+ void set_meanfile(const char* value, size_t size);
+ ::std::string* mutable_meanfile();
+ ::std::string* release_meanfile();
+ void set_allocated_meanfile(::std::string* meanfile);
+
+ // optional uint32 batchsize = 19;
+ bool has_batchsize() const;
+ void clear_batchsize();
+ static const int kBatchsizeFieldNumber = 19;
+ ::google::protobuf::uint32 batchsize() const;
+ void set_batchsize(::google::protobuf::uint32 value);
+
+ // optional uint32 cropsize = 20 [default = 0];
+ bool has_cropsize() const;
+ void clear_cropsize();
+ static const int kCropsizeFieldNumber = 20;
+ ::google::protobuf::uint32 cropsize() const;
+ void set_cropsize(::google::protobuf::uint32 value);
+
+ // optional bool mirror = 21 [default = false];
+ bool has_mirror() const;
+ void clear_mirror();
+ static const int kMirrorFieldNumber = 21;
+ bool mirror() const;
+ void set_mirror(bool value);
+
+ // repeated .caffe.BlobProto blobs = 50;
+ int blobs_size() const;
+ void clear_blobs();
+ static const int kBlobsFieldNumber = 50;
+ const ::caffe::BlobProto& blobs(int index) const;
+ ::caffe::BlobProto* mutable_blobs(int index);
+ ::caffe::BlobProto* add_blobs();
+ ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
+ mutable_blobs();
+ const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
+ blobs() const;
+
+ // repeated float blobs_lr = 51;
+ int blobs_lr_size() const;
+ void clear_blobs_lr();
+ static const int kBlobsLrFieldNumber = 51;
+ float blobs_lr(int index) const;
+ void set_blobs_lr(int index, float value);
+ void add_blobs_lr(float value);
+ const ::google::protobuf::RepeatedField< float >&
+ blobs_lr() const;
+ ::google::protobuf::RepeatedField< float >*
+ mutable_blobs_lr();
+
+ // repeated float weight_decay = 52;
+ int weight_decay_size() const;
+ void clear_weight_decay();
+ static const int kWeightDecayFieldNumber = 52;
+ float weight_decay(int index) const;
+ void set_weight_decay(int index, float value);
+ void add_weight_decay(float value);
+ const ::google::protobuf::RepeatedField< float >&
+ weight_decay() const;
+ ::google::protobuf::RepeatedField< float >*
+ mutable_weight_decay();
+
+ // optional uint32 rand_skip = 53 [default = 0];
+ bool has_rand_skip() const;
+ void clear_rand_skip();
+ static const int kRandSkipFieldNumber = 53;
+ ::google::protobuf::uint32 rand_skip() const;
+ void set_rand_skip(::google::protobuf::uint32 value);
+
+ // optional float det_fg_threshold = 54 [default = 0.5];
+ bool has_det_fg_threshold() const;
+ void clear_det_fg_threshold();
+ static const int kDetFgThresholdFieldNumber = 54;
+ float det_fg_threshold() const;
+ void set_det_fg_threshold(float value);
+
+ // optional float det_bg_threshold = 55 [default = 0.5];
+ bool has_det_bg_threshold() const;
+ void clear_det_bg_threshold();
+ static const int kDetBgThresholdFieldNumber = 55;
+ float det_bg_threshold() const;
+ void set_det_bg_threshold(float value);
+
+ // optional float det_fg_fraction = 56 [default = 0.25];
+ bool has_det_fg_fraction() const;
+ void clear_det_fg_fraction();
+ static const int kDetFgFractionFieldNumber = 56;
+ float det_fg_fraction() const;
+ void set_det_fg_fraction(float value);
+
+ // optional uint32 det_context_pad = 58 [default = 0];
+ bool has_det_context_pad() const;
+ void clear_det_context_pad();
+ static const int kDetContextPadFieldNumber = 58;
+ ::google::protobuf::uint32 det_context_pad() const;
+ void set_det_context_pad(::google::protobuf::uint32 value);
+
+ // optional string det_crop_mode = 59 [default = "warp"];
+ bool has_det_crop_mode() const;
+ void clear_det_crop_mode();
+ static const int kDetCropModeFieldNumber = 59;
+ const ::std::string& det_crop_mode() const;
+ void set_det_crop_mode(const ::std::string& value);
+ void set_det_crop_mode(const char* value);
+ void set_det_crop_mode(const char* value, size_t size);
+ ::std::string* mutable_det_crop_mode();
+ ::std::string* release_det_crop_mode();
+ void set_allocated_det_crop_mode(::std::string* det_crop_mode);
+
+ // optional int32 new_num = 60 [default = 0];
+ bool has_new_num() const;
+ void clear_new_num();
+ static const int kNewNumFieldNumber = 60;
+ ::google::protobuf::int32 new_num() const;
+ void set_new_num(::google::protobuf::int32 value);
+
+ // optional int32 new_channels = 61 [default = 0];
+ bool has_new_channels() const;
+ void clear_new_channels();
+ static const int kNewChannelsFieldNumber = 61;
+ ::google::protobuf::int32 new_channels() const;
+ void set_new_channels(::google::protobuf::int32 value);
+
+ // optional int32 new_height = 62 [default = 0];
+ bool has_new_height() const;
+ void clear_new_height();
+ static const int kNewHeightFieldNumber = 62;
+ ::google::protobuf::int32 new_height() const;
+ void set_new_height(::google::protobuf::int32 value);
+
+ // optional int32 new_width = 63 [default = 0];
+ bool has_new_width() const;
+ void clear_new_width();
+ static const int kNewWidthFieldNumber = 63;
+ ::google::protobuf::int32 new_width() const;
+ void set_new_width(::google::protobuf::int32 value);
+
+ // optional bool shuffle_images = 64 [default = false];
+ bool has_shuffle_images() const;
+ void clear_shuffle_images();
+ static const int kShuffleImagesFieldNumber = 64;
+ bool shuffle_images() const;
+ void set_shuffle_images(bool value);
+
+ // optional uint32 concat_dim = 65 [default = 1];
+ bool has_concat_dim() const;
+ void clear_concat_dim();
+ static const int kConcatDimFieldNumber = 65;
+ ::google::protobuf::uint32 concat_dim() const;
+ void set_concat_dim(::google::protobuf::uint32 value);
+
+ // optional .caffe.HDF5OutputParameter hdf5_output_param = 1001;
+ bool has_hdf5_output_param() const;
+ void clear_hdf5_output_param();
+ static const int kHdf5OutputParamFieldNumber = 1001;
+ const ::caffe::HDF5OutputParameter& hdf5_output_param() const;
+ ::caffe::HDF5OutputParameter* mutable_hdf5_output_param();
+ ::caffe::HDF5OutputParameter* release_hdf5_output_param();
+ void set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param);
+
+ // @@protoc_insertion_point(class_scope:caffe.V0LayerParameter)
+ private:
+ inline void set_has_name();
+ inline void clear_has_name();
+ inline void set_has_type();
+ inline void clear_has_type();
+ inline void set_has_num_output();
+ inline void clear_has_num_output();
+ inline void set_has_biasterm();
+ inline void clear_has_biasterm();
+ inline void set_has_weight_filler();
+ inline void clear_has_weight_filler();
+ inline void set_has_bias_filler();
+ inline void clear_has_bias_filler();
+ inline void set_has_pad();
+ inline void clear_has_pad();
+ inline void set_has_kernelsize();
+ inline void clear_has_kernelsize();
+ inline void set_has_group();
+ inline void clear_has_group();
+ inline void set_has_stride();
+ inline void clear_has_stride();
+ inline void set_has_pool();
+ inline void clear_has_pool();
+ inline void set_has_dropout_ratio();
+ inline void clear_has_dropout_ratio();
+ inline void set_has_local_size();
+ inline void clear_has_local_size();
+ inline void set_has_alpha();
+ inline void clear_has_alpha();
+ inline void set_has_beta();
+ inline void clear_has_beta();
+ inline void set_has_k();
+ inline void clear_has_k();
+ inline void set_has_source();
+ inline void clear_has_source();
+ inline void set_has_scale();
+ inline void clear_has_scale();
+ inline void set_has_meanfile();
+ inline void clear_has_meanfile();
+ inline void set_has_batchsize();
+ inline void clear_has_batchsize();
+ inline void set_has_cropsize();
+ inline void clear_has_cropsize();
+ inline void set_has_mirror();
+ inline void clear_has_mirror();
+ inline void set_has_rand_skip();
+ inline void clear_has_rand_skip();
+ inline void set_has_det_fg_threshold();
+ inline void clear_has_det_fg_threshold();
+ inline void set_has_det_bg_threshold();
+ inline void clear_has_det_bg_threshold();
+ inline void set_has_det_fg_fraction();
+ inline void clear_has_det_fg_fraction();
+ inline void set_has_det_context_pad();
+ inline void clear_has_det_context_pad();
+ inline void set_has_det_crop_mode();
+ inline void clear_has_det_crop_mode();
+ inline void set_has_new_num();
+ inline void clear_has_new_num();
+ inline void set_has_new_channels();
+ inline void clear_has_new_channels();
+ inline void set_has_new_height();
+ inline void clear_has_new_height();
+ inline void set_has_new_width();
+ inline void clear_has_new_width();
+ inline void set_has_shuffle_images();
+ inline void clear_has_shuffle_images();
+ inline void set_has_concat_dim();
+ inline void clear_has_concat_dim();
+ inline void set_has_hdf5_output_param();
+ inline void clear_has_hdf5_output_param();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<2> _has_bits_;
+ ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto > blobs_;
+ ::google::protobuf::RepeatedField< float > blobs_lr_;
+ ::google::protobuf::RepeatedField< float > weight_decay_;
+ ::google::protobuf::internal::ArenaStringPtr name_;
+ ::google::protobuf::internal::ArenaStringPtr type_;
+ ::google::protobuf::internal::ArenaStringPtr source_;
+ ::google::protobuf::internal::ArenaStringPtr meanfile_;
+ static ::std::string* _default_det_crop_mode_;
+ ::google::protobuf::internal::ArenaStringPtr det_crop_mode_;
+ ::caffe::FillerParameter* weight_filler_;
+ ::caffe::FillerParameter* bias_filler_;
+ ::caffe::HDF5OutputParameter* hdf5_output_param_;
+ ::google::protobuf::uint32 num_output_;
+ ::google::protobuf::uint32 pad_;
+ ::google::protobuf::uint32 kernelsize_;
+ int pool_;
+ ::google::protobuf::uint32 batchsize_;
+ ::google::protobuf::uint32 cropsize_;
+ ::google::protobuf::uint32 rand_skip_;
+ bool mirror_;
+ bool shuffle_images_;
+ ::google::protobuf::uint32 det_context_pad_;
+ ::google::protobuf::int32 new_num_;
+ ::google::protobuf::int32 new_channels_;
+ ::google::protobuf::int32 new_height_;
+ ::google::protobuf::int32 new_width_;
+ ::google::protobuf::uint32 concat_dim_;
+ bool biasterm_;
+ ::google::protobuf::uint32 group_;
+ ::google::protobuf::uint32 stride_;
+ float dropout_ratio_;
+ ::google::protobuf::uint32 local_size_;
+ float alpha_;
+ float beta_;
+ float k_;
+ float scale_;
+ float det_fg_threshold_;
+ float det_bg_threshold_;
+ float det_fg_fraction_;
+ mutable int _cached_size_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<V0LayerParameter> V0LayerParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class PReLUParameter : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.PReLUParameter) */ {
+ public:
+ PReLUParameter();
+ virtual ~PReLUParameter();
+
+ PReLUParameter(const PReLUParameter& from);
+
+ inline PReLUParameter& operator=(const PReLUParameter& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const PReLUParameter& default_instance();
+
+ static const PReLUParameter* internal_default_instance();
+
+ void Swap(PReLUParameter* other);
+
+ // implements Message ----------------------------------------------
+
+ inline PReLUParameter* New() const { return New(NULL); }
+
+ PReLUParameter* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const PReLUParameter& from);
+ void MergeFrom(const PReLUParameter& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(PReLUParameter* other);
+ void UnsafeMergeFrom(const PReLUParameter& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional .caffe.FillerParameter filler = 1;
+ bool has_filler() const;
+ void clear_filler();
+ static const int kFillerFieldNumber = 1;
+ const ::caffe::FillerParameter& filler() const;
+ ::caffe::FillerParameter* mutable_filler();
+ ::caffe::FillerParameter* release_filler();
+ void set_allocated_filler(::caffe::FillerParameter* filler);
+
+ // optional bool channel_shared = 2 [default = false];
+ bool has_channel_shared() const;
+ void clear_channel_shared();
+ static const int kChannelSharedFieldNumber = 2;
+ bool channel_shared() const;
+ void set_channel_shared(bool value);
+
+ // @@protoc_insertion_point(class_scope:caffe.PReLUParameter)
+ private:
+ inline void set_has_filler();
+ inline void clear_has_filler();
+ inline void set_has_channel_shared();
+ inline void clear_has_channel_shared();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ ::caffe::FillerParameter* filler_;
+ bool channel_shared_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<PReLUParameter> PReLUParameter_default_instance_;
+
+// -------------------------------------------------------------------
+
+class NormalizedBBox : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:caffe.NormalizedBBox) */ {
+ public:
+ NormalizedBBox();
+ virtual ~NormalizedBBox();
+
+ NormalizedBBox(const NormalizedBBox& from);
+
+ inline NormalizedBBox& operator=(const NormalizedBBox& from) {
+ CopyFrom(from);
+ return *this;
+ }
+
+ inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
+ return _internal_metadata_.unknown_fields();
+ }
+
+ inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
+ return _internal_metadata_.mutable_unknown_fields();
+ }
+
+ static const ::google::protobuf::Descriptor* descriptor();
+ static const NormalizedBBox& default_instance();
+
+ static const NormalizedBBox* internal_default_instance();
+
+ void Swap(NormalizedBBox* other);
+
+ // implements Message ----------------------------------------------
+
+ inline NormalizedBBox* New() const { return New(NULL); }
+
+ NormalizedBBox* New(::google::protobuf::Arena* arena) const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const NormalizedBBox& from);
+ void MergeFrom(const NormalizedBBox& from);
+ void Clear();
+ bool IsInitialized() const;
+
+ size_t ByteSizeLong() const;
+ bool MergePartialFromCodedStream(
+ ::google::protobuf::io::CodedInputStream* input);
+ void SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const;
+ ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+ bool deterministic, ::google::protobuf::uint8* output) const;
+ ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {
+ return InternalSerializeWithCachedSizesToArray(false, output);
+ }
+ int GetCachedSize() const { return _cached_size_; }
+ private:
+ void SharedCtor();
+ void SharedDtor();
+ void SetCachedSize(int size) const;
+ void InternalSwap(NormalizedBBox* other);
+ void UnsafeMergeFrom(const NormalizedBBox& from);
+ private:
+ inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+ return _internal_metadata_.arena();
+ }
+ inline void* MaybeArenaPtr() const {
+ return _internal_metadata_.raw_arena_ptr();
+ }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // optional float xmin = 1;
+ bool has_xmin() const;
+ void clear_xmin();
+ static const int kXminFieldNumber = 1;
+ float xmin() const;
+ void set_xmin(float value);
+
+ // optional float ymin = 2;
+ bool has_ymin() const;
+ void clear_ymin();
+ static const int kYminFieldNumber = 2;
+ float ymin() const;
+ void set_ymin(float value);
+
+ // optional float xmax = 3;
+ bool has_xmax() const;
+ void clear_xmax();
+ static const int kXmaxFieldNumber = 3;
+ float xmax() const;
+ void set_xmax(float value);
+
+ // optional float ymax = 4;
+ bool has_ymax() const;
+ void clear_ymax();
+ static const int kYmaxFieldNumber = 4;
+ float ymax() const;
+ void set_ymax(float value);
+
+ // optional int32 label = 5;
+ bool has_label() const;
+ void clear_label();
+ static const int kLabelFieldNumber = 5;
+ ::google::protobuf::int32 label() const;
+ void set_label(::google::protobuf::int32 value);
+
+ // optional bool difficult = 6;
+ bool has_difficult() const;
+ void clear_difficult();
+ static const int kDifficultFieldNumber = 6;
+ bool difficult() const;
+ void set_difficult(bool value);
+
+ // optional float score = 7;
+ bool has_score() const;
+ void clear_score();
+ static const int kScoreFieldNumber = 7;
+ float score() const;
+ void set_score(float value);
+
+ // optional float size = 8;
+ bool has_size() const;
+ void clear_size();
+ static const int kSizeFieldNumber = 8;
+ float size() const;
+ void set_size(float value);
+
+ // @@protoc_insertion_point(class_scope:caffe.NormalizedBBox)
+ private:
+ inline void set_has_xmin();
+ inline void clear_has_xmin();
+ inline void set_has_ymin();
+ inline void clear_has_ymin();
+ inline void set_has_xmax();
+ inline void clear_has_xmax();
+ inline void set_has_ymax();
+ inline void clear_has_ymax();
+ inline void set_has_label();
+ inline void clear_has_label();
+ inline void set_has_difficult();
+ inline void clear_has_difficult();
+ inline void set_has_score();
+ inline void clear_has_score();
+ inline void set_has_size();
+ inline void clear_has_size();
+
+ ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+ ::google::protobuf::internal::HasBits<1> _has_bits_;
+ mutable int _cached_size_;
+ float xmin_;
+ float ymin_;
+ float xmax_;
+ float ymax_;
+ ::google::protobuf::int32 label_;
+ bool difficult_;
+ float score_;
+ float size_;
+ friend void protobuf_InitDefaults_caffe_2eproto_impl();
+ friend void protobuf_AddDesc_caffe_2eproto_impl();
+ friend void protobuf_AssignDesc_caffe_2eproto();
+ friend void protobuf_ShutdownFile_caffe_2eproto();
+
+ void InitAsDefaultInstance();
+};
+extern ::google::protobuf::internal::ExplicitlyConstructed<NormalizedBBox> NormalizedBBox_default_instance_;
+
+// ===================================================================
+
+
+// ===================================================================
+
+#if !PROTOBUF_INLINE_NOT_IN_HEADERS
+// BlobShape
+
+// repeated int64 dim = 1 [packed = true];
+inline int BlobShape::dim_size() const {
+ return dim_.size();
+}
+inline void BlobShape::clear_dim() {
+ dim_.Clear();
+}
+inline ::google::protobuf::int64 BlobShape::dim(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.BlobShape.dim)
+ return dim_.Get(index);
+}
+inline void BlobShape::set_dim(int index, ::google::protobuf::int64 value) {
+ dim_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.BlobShape.dim)
+}
+inline void BlobShape::add_dim(::google::protobuf::int64 value) {
+ dim_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.BlobShape.dim)
+}
+inline const ::google::protobuf::RepeatedField< ::google::protobuf::int64 >&
+BlobShape::dim() const {
+ // @@protoc_insertion_point(field_list:caffe.BlobShape.dim)
+ return dim_;
+}
+inline ::google::protobuf::RepeatedField< ::google::protobuf::int64 >*
+BlobShape::mutable_dim() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.BlobShape.dim)
+ return &dim_;
+}
+
+inline const BlobShape* BlobShape::internal_default_instance() {
+ return &BlobShape_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// BlobProto
+
+// optional .caffe.BlobShape shape = 7;
+inline bool BlobProto::has_shape() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void BlobProto::set_has_shape() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void BlobProto::clear_has_shape() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void BlobProto::clear_shape() {
+ if (shape_ != NULL) shape_->::caffe::BlobShape::Clear();
+ clear_has_shape();
+}
+inline const ::caffe::BlobShape& BlobProto::shape() const {
+ // @@protoc_insertion_point(field_get:caffe.BlobProto.shape)
+ return shape_ != NULL ? *shape_
+ : *::caffe::BlobShape::internal_default_instance();
+}
+inline ::caffe::BlobShape* BlobProto::mutable_shape() {
+ set_has_shape();
+ if (shape_ == NULL) {
+ shape_ = new ::caffe::BlobShape;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.BlobProto.shape)
+ return shape_;
+}
+inline ::caffe::BlobShape* BlobProto::release_shape() {
+ // @@protoc_insertion_point(field_release:caffe.BlobProto.shape)
+ clear_has_shape();
+ ::caffe::BlobShape* temp = shape_;
+ shape_ = NULL;
+ return temp;
+}
+inline void BlobProto::set_allocated_shape(::caffe::BlobShape* shape) {
+ delete shape_;
+ shape_ = shape;
+ if (shape) {
+ set_has_shape();
+ } else {
+ clear_has_shape();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.BlobProto.shape)
+}
+
+// repeated float data = 5 [packed = true];
+inline int BlobProto::data_size() const {
+ return data_.size();
+}
+inline void BlobProto::clear_data() {
+ data_.Clear();
+}
+inline float BlobProto::data(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.BlobProto.data)
+ return data_.Get(index);
+}
+inline void BlobProto::set_data(int index, float value) {
+ data_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.BlobProto.data)
+}
+inline void BlobProto::add_data(float value) {
+ data_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.BlobProto.data)
+}
+inline const ::google::protobuf::RepeatedField< float >&
+BlobProto::data() const {
+ // @@protoc_insertion_point(field_list:caffe.BlobProto.data)
+ return data_;
+}
+inline ::google::protobuf::RepeatedField< float >*
+BlobProto::mutable_data() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.BlobProto.data)
+ return &data_;
+}
+
+// repeated float diff = 6 [packed = true];
+inline int BlobProto::diff_size() const {
+ return diff_.size();
+}
+inline void BlobProto::clear_diff() {
+ diff_.Clear();
+}
+inline float BlobProto::diff(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.BlobProto.diff)
+ return diff_.Get(index);
+}
+inline void BlobProto::set_diff(int index, float value) {
+ diff_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.BlobProto.diff)
+}
+inline void BlobProto::add_diff(float value) {
+ diff_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.BlobProto.diff)
+}
+inline const ::google::protobuf::RepeatedField< float >&
+BlobProto::diff() const {
+ // @@protoc_insertion_point(field_list:caffe.BlobProto.diff)
+ return diff_;
+}
+inline ::google::protobuf::RepeatedField< float >*
+BlobProto::mutable_diff() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.BlobProto.diff)
+ return &diff_;
+}
+
+// repeated double double_data = 8 [packed = true];
+inline int BlobProto::double_data_size() const {
+ return double_data_.size();
+}
+inline void BlobProto::clear_double_data() {
+ double_data_.Clear();
+}
+inline double BlobProto::double_data(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.BlobProto.double_data)
+ return double_data_.Get(index);
+}
+inline void BlobProto::set_double_data(int index, double value) {
+ double_data_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.BlobProto.double_data)
+}
+inline void BlobProto::add_double_data(double value) {
+ double_data_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.BlobProto.double_data)
+}
+inline const ::google::protobuf::RepeatedField< double >&
+BlobProto::double_data() const {
+ // @@protoc_insertion_point(field_list:caffe.BlobProto.double_data)
+ return double_data_;
+}
+inline ::google::protobuf::RepeatedField< double >*
+BlobProto::mutable_double_data() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.BlobProto.double_data)
+ return &double_data_;
+}
+
+// repeated double double_diff = 9 [packed = true];
+inline int BlobProto::double_diff_size() const {
+ return double_diff_.size();
+}
+inline void BlobProto::clear_double_diff() {
+ double_diff_.Clear();
+}
+inline double BlobProto::double_diff(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.BlobProto.double_diff)
+ return double_diff_.Get(index);
+}
+inline void BlobProto::set_double_diff(int index, double value) {
+ double_diff_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.BlobProto.double_diff)
+}
+inline void BlobProto::add_double_diff(double value) {
+ double_diff_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.BlobProto.double_diff)
+}
+inline const ::google::protobuf::RepeatedField< double >&
+BlobProto::double_diff() const {
+ // @@protoc_insertion_point(field_list:caffe.BlobProto.double_diff)
+ return double_diff_;
+}
+inline ::google::protobuf::RepeatedField< double >*
+BlobProto::mutable_double_diff() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.BlobProto.double_diff)
+ return &double_diff_;
+}
+
+// optional int32 num = 1 [default = 0];
+inline bool BlobProto::has_num() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+inline void BlobProto::set_has_num() {
+ _has_bits_[0] |= 0x00000020u;
+}
+inline void BlobProto::clear_has_num() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+inline void BlobProto::clear_num() {
+ num_ = 0;
+ clear_has_num();
+}
+inline ::google::protobuf::int32 BlobProto::num() const {
+ // @@protoc_insertion_point(field_get:caffe.BlobProto.num)
+ return num_;
+}
+inline void BlobProto::set_num(::google::protobuf::int32 value) {
+ set_has_num();
+ num_ = value;
+ // @@protoc_insertion_point(field_set:caffe.BlobProto.num)
+}
+
+// optional int32 channels = 2 [default = 0];
+inline bool BlobProto::has_channels() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+inline void BlobProto::set_has_channels() {
+ _has_bits_[0] |= 0x00000040u;
+}
+inline void BlobProto::clear_has_channels() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+inline void BlobProto::clear_channels() {
+ channels_ = 0;
+ clear_has_channels();
+}
+inline ::google::protobuf::int32 BlobProto::channels() const {
+ // @@protoc_insertion_point(field_get:caffe.BlobProto.channels)
+ return channels_;
+}
+inline void BlobProto::set_channels(::google::protobuf::int32 value) {
+ set_has_channels();
+ channels_ = value;
+ // @@protoc_insertion_point(field_set:caffe.BlobProto.channels)
+}
+
+// optional int32 height = 3 [default = 0];
+inline bool BlobProto::has_height() const {
+ return (_has_bits_[0] & 0x00000080u) != 0;
+}
+inline void BlobProto::set_has_height() {
+ _has_bits_[0] |= 0x00000080u;
+}
+inline void BlobProto::clear_has_height() {
+ _has_bits_[0] &= ~0x00000080u;
+}
+inline void BlobProto::clear_height() {
+ height_ = 0;
+ clear_has_height();
+}
+inline ::google::protobuf::int32 BlobProto::height() const {
+ // @@protoc_insertion_point(field_get:caffe.BlobProto.height)
+ return height_;
+}
+inline void BlobProto::set_height(::google::protobuf::int32 value) {
+ set_has_height();
+ height_ = value;
+ // @@protoc_insertion_point(field_set:caffe.BlobProto.height)
+}
+
+// optional int32 width = 4 [default = 0];
+inline bool BlobProto::has_width() const {
+ return (_has_bits_[0] & 0x00000100u) != 0;
+}
+inline void BlobProto::set_has_width() {
+ _has_bits_[0] |= 0x00000100u;
+}
+inline void BlobProto::clear_has_width() {
+ _has_bits_[0] &= ~0x00000100u;
+}
+inline void BlobProto::clear_width() {
+ width_ = 0;
+ clear_has_width();
+}
+inline ::google::protobuf::int32 BlobProto::width() const {
+ // @@protoc_insertion_point(field_get:caffe.BlobProto.width)
+ return width_;
+}
+inline void BlobProto::set_width(::google::protobuf::int32 value) {
+ set_has_width();
+ width_ = value;
+ // @@protoc_insertion_point(field_set:caffe.BlobProto.width)
+}
+
+inline const BlobProto* BlobProto::internal_default_instance() {
+ return &BlobProto_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// BlobProtoVector
+
+// repeated .caffe.BlobProto blobs = 1;
+inline int BlobProtoVector::blobs_size() const {
+ return blobs_.size();
+}
+inline void BlobProtoVector::clear_blobs() {
+ blobs_.Clear();
+}
+inline const ::caffe::BlobProto& BlobProtoVector::blobs(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.BlobProtoVector.blobs)
+ return blobs_.Get(index);
+}
+inline ::caffe::BlobProto* BlobProtoVector::mutable_blobs(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.BlobProtoVector.blobs)
+ return blobs_.Mutable(index);
+}
+inline ::caffe::BlobProto* BlobProtoVector::add_blobs() {
+ // @@protoc_insertion_point(field_add:caffe.BlobProtoVector.blobs)
+ return blobs_.Add();
+}
+inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
+BlobProtoVector::mutable_blobs() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.BlobProtoVector.blobs)
+ return &blobs_;
+}
+inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
+BlobProtoVector::blobs() const {
+ // @@protoc_insertion_point(field_list:caffe.BlobProtoVector.blobs)
+ return blobs_;
+}
+
+inline const BlobProtoVector* BlobProtoVector::internal_default_instance() {
+ return &BlobProtoVector_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// PermuteParameter
+
+// repeated uint32 order = 1;
+inline int PermuteParameter::order_size() const {
+ return order_.size();
+}
+inline void PermuteParameter::clear_order() {
+ order_.Clear();
+}
+inline ::google::protobuf::uint32 PermuteParameter::order(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.PermuteParameter.order)
+ return order_.Get(index);
+}
+inline void PermuteParameter::set_order(int index, ::google::protobuf::uint32 value) {
+ order_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.PermuteParameter.order)
+}
+inline void PermuteParameter::add_order(::google::protobuf::uint32 value) {
+ order_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.PermuteParameter.order)
+}
+inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+PermuteParameter::order() const {
+ // @@protoc_insertion_point(field_list:caffe.PermuteParameter.order)
+ return order_;
+}
+inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+PermuteParameter::mutable_order() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.PermuteParameter.order)
+ return &order_;
+}
+
+inline const PermuteParameter* PermuteParameter::internal_default_instance() {
+ return &PermuteParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// NormalizeBBoxParameter
+
+// optional bool across_spatial = 1 [default = true];
+inline bool NormalizeBBoxParameter::has_across_spatial() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void NormalizeBBoxParameter::set_has_across_spatial() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void NormalizeBBoxParameter::clear_has_across_spatial() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void NormalizeBBoxParameter::clear_across_spatial() {
+ across_spatial_ = true;
+ clear_has_across_spatial();
+}
+inline bool NormalizeBBoxParameter::across_spatial() const {
+ // @@protoc_insertion_point(field_get:caffe.NormalizeBBoxParameter.across_spatial)
+ return across_spatial_;
+}
+inline void NormalizeBBoxParameter::set_across_spatial(bool value) {
+ set_has_across_spatial();
+ across_spatial_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NormalizeBBoxParameter.across_spatial)
+}
+
+// optional .caffe.FillerParameter scale_filler = 2;
+inline bool NormalizeBBoxParameter::has_scale_filler() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void NormalizeBBoxParameter::set_has_scale_filler() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void NormalizeBBoxParameter::clear_has_scale_filler() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void NormalizeBBoxParameter::clear_scale_filler() {
+ if (scale_filler_ != NULL) scale_filler_->::caffe::FillerParameter::Clear();
+ clear_has_scale_filler();
+}
+inline const ::caffe::FillerParameter& NormalizeBBoxParameter::scale_filler() const {
+ // @@protoc_insertion_point(field_get:caffe.NormalizeBBoxParameter.scale_filler)
+ return scale_filler_ != NULL ? *scale_filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+inline ::caffe::FillerParameter* NormalizeBBoxParameter::mutable_scale_filler() {
+ set_has_scale_filler();
+ if (scale_filler_ == NULL) {
+ scale_filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.NormalizeBBoxParameter.scale_filler)
+ return scale_filler_;
+}
+inline ::caffe::FillerParameter* NormalizeBBoxParameter::release_scale_filler() {
+ // @@protoc_insertion_point(field_release:caffe.NormalizeBBoxParameter.scale_filler)
+ clear_has_scale_filler();
+ ::caffe::FillerParameter* temp = scale_filler_;
+ scale_filler_ = NULL;
+ return temp;
+}
+inline void NormalizeBBoxParameter::set_allocated_scale_filler(::caffe::FillerParameter* scale_filler) {
+ delete scale_filler_;
+ scale_filler_ = scale_filler;
+ if (scale_filler) {
+ set_has_scale_filler();
+ } else {
+ clear_has_scale_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.NormalizeBBoxParameter.scale_filler)
+}
+
+// optional bool channel_shared = 3 [default = true];
+inline bool NormalizeBBoxParameter::has_channel_shared() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void NormalizeBBoxParameter::set_has_channel_shared() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void NormalizeBBoxParameter::clear_has_channel_shared() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void NormalizeBBoxParameter::clear_channel_shared() {
+ channel_shared_ = true;
+ clear_has_channel_shared();
+}
+inline bool NormalizeBBoxParameter::channel_shared() const {
+ // @@protoc_insertion_point(field_get:caffe.NormalizeBBoxParameter.channel_shared)
+ return channel_shared_;
+}
+inline void NormalizeBBoxParameter::set_channel_shared(bool value) {
+ set_has_channel_shared();
+ channel_shared_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NormalizeBBoxParameter.channel_shared)
+}
+
+// optional float eps = 4 [default = 1e-10];
+inline bool NormalizeBBoxParameter::has_eps() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void NormalizeBBoxParameter::set_has_eps() {
+ _has_bits_[0] |= 0x00000008u;
+}
+inline void NormalizeBBoxParameter::clear_has_eps() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+inline void NormalizeBBoxParameter::clear_eps() {
+ eps_ = 1e-10f;
+ clear_has_eps();
+}
+inline float NormalizeBBoxParameter::eps() const {
+ // @@protoc_insertion_point(field_get:caffe.NormalizeBBoxParameter.eps)
+ return eps_;
+}
+inline void NormalizeBBoxParameter::set_eps(float value) {
+ set_has_eps();
+ eps_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NormalizeBBoxParameter.eps)
+}
+
+inline const NormalizeBBoxParameter* NormalizeBBoxParameter::internal_default_instance() {
+ return &NormalizeBBoxParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// PriorBoxParameter
+
+// optional float min_size = 1;
+inline bool PriorBoxParameter::has_min_size() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void PriorBoxParameter::set_has_min_size() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void PriorBoxParameter::clear_has_min_size() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void PriorBoxParameter::clear_min_size() {
+ min_size_ = 0;
+ clear_has_min_size();
+}
+inline float PriorBoxParameter::min_size() const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.min_size)
+ return min_size_;
+}
+inline void PriorBoxParameter::set_min_size(float value) {
+ set_has_min_size();
+ min_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.min_size)
+}
+
+// optional float max_size = 2;
+inline bool PriorBoxParameter::has_max_size() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void PriorBoxParameter::set_has_max_size() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void PriorBoxParameter::clear_has_max_size() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void PriorBoxParameter::clear_max_size() {
+ max_size_ = 0;
+ clear_has_max_size();
+}
+inline float PriorBoxParameter::max_size() const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.max_size)
+ return max_size_;
+}
+inline void PriorBoxParameter::set_max_size(float value) {
+ set_has_max_size();
+ max_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.max_size)
+}
+
+// repeated float aspect_ratio = 3;
+inline int PriorBoxParameter::aspect_ratio_size() const {
+ return aspect_ratio_.size();
+}
+inline void PriorBoxParameter::clear_aspect_ratio() {
+ aspect_ratio_.Clear();
+}
+inline float PriorBoxParameter::aspect_ratio(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.aspect_ratio)
+ return aspect_ratio_.Get(index);
+}
+inline void PriorBoxParameter::set_aspect_ratio(int index, float value) {
+ aspect_ratio_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.aspect_ratio)
+}
+inline void PriorBoxParameter::add_aspect_ratio(float value) {
+ aspect_ratio_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.PriorBoxParameter.aspect_ratio)
+}
+inline const ::google::protobuf::RepeatedField< float >&
+PriorBoxParameter::aspect_ratio() const {
+ // @@protoc_insertion_point(field_list:caffe.PriorBoxParameter.aspect_ratio)
+ return aspect_ratio_;
+}
+inline ::google::protobuf::RepeatedField< float >*
+PriorBoxParameter::mutable_aspect_ratio() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.PriorBoxParameter.aspect_ratio)
+ return &aspect_ratio_;
+}
+
+// optional bool flip = 4 [default = true];
+inline bool PriorBoxParameter::has_flip() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void PriorBoxParameter::set_has_flip() {
+ _has_bits_[0] |= 0x00000008u;
+}
+inline void PriorBoxParameter::clear_has_flip() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+inline void PriorBoxParameter::clear_flip() {
+ flip_ = true;
+ clear_has_flip();
+}
+inline bool PriorBoxParameter::flip() const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.flip)
+ return flip_;
+}
+inline void PriorBoxParameter::set_flip(bool value) {
+ set_has_flip();
+ flip_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.flip)
+}
+
+// optional bool clip = 5 [default = true];
+inline bool PriorBoxParameter::has_clip() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+inline void PriorBoxParameter::set_has_clip() {
+ _has_bits_[0] |= 0x00000010u;
+}
+inline void PriorBoxParameter::clear_has_clip() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+inline void PriorBoxParameter::clear_clip() {
+ clip_ = true;
+ clear_has_clip();
+}
+inline bool PriorBoxParameter::clip() const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.clip)
+ return clip_;
+}
+inline void PriorBoxParameter::set_clip(bool value) {
+ set_has_clip();
+ clip_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.clip)
+}
+
+// repeated float variance = 6;
+inline int PriorBoxParameter::variance_size() const {
+ return variance_.size();
+}
+inline void PriorBoxParameter::clear_variance() {
+ variance_.Clear();
+}
+inline float PriorBoxParameter::variance(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.variance)
+ return variance_.Get(index);
+}
+inline void PriorBoxParameter::set_variance(int index, float value) {
+ variance_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.variance)
+}
+inline void PriorBoxParameter::add_variance(float value) {
+ variance_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.PriorBoxParameter.variance)
+}
+inline const ::google::protobuf::RepeatedField< float >&
+PriorBoxParameter::variance() const {
+ // @@protoc_insertion_point(field_list:caffe.PriorBoxParameter.variance)
+ return variance_;
+}
+inline ::google::protobuf::RepeatedField< float >*
+PriorBoxParameter::mutable_variance() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.PriorBoxParameter.variance)
+ return &variance_;
+}
+
+// optional uint32 img_size = 7;
+inline bool PriorBoxParameter::has_img_size() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+inline void PriorBoxParameter::set_has_img_size() {
+ _has_bits_[0] |= 0x00000040u;
+}
+inline void PriorBoxParameter::clear_has_img_size() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+inline void PriorBoxParameter::clear_img_size() {
+ img_size_ = 0u;
+ clear_has_img_size();
+}
+inline ::google::protobuf::uint32 PriorBoxParameter::img_size() const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.img_size)
+ return img_size_;
+}
+inline void PriorBoxParameter::set_img_size(::google::protobuf::uint32 value) {
+ set_has_img_size();
+ img_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.img_size)
+}
+
+// optional uint32 img_h = 8;
+inline bool PriorBoxParameter::has_img_h() const {
+ return (_has_bits_[0] & 0x00000080u) != 0;
+}
+inline void PriorBoxParameter::set_has_img_h() {
+ _has_bits_[0] |= 0x00000080u;
+}
+inline void PriorBoxParameter::clear_has_img_h() {
+ _has_bits_[0] &= ~0x00000080u;
+}
+inline void PriorBoxParameter::clear_img_h() {
+ img_h_ = 0u;
+ clear_has_img_h();
+}
+inline ::google::protobuf::uint32 PriorBoxParameter::img_h() const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.img_h)
+ return img_h_;
+}
+inline void PriorBoxParameter::set_img_h(::google::protobuf::uint32 value) {
+ set_has_img_h();
+ img_h_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.img_h)
+}
+
+// optional uint32 img_w = 9;
+inline bool PriorBoxParameter::has_img_w() const {
+ return (_has_bits_[0] & 0x00000100u) != 0;
+}
+inline void PriorBoxParameter::set_has_img_w() {
+ _has_bits_[0] |= 0x00000100u;
+}
+inline void PriorBoxParameter::clear_has_img_w() {
+ _has_bits_[0] &= ~0x00000100u;
+}
+inline void PriorBoxParameter::clear_img_w() {
+ img_w_ = 0u;
+ clear_has_img_w();
+}
+inline ::google::protobuf::uint32 PriorBoxParameter::img_w() const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.img_w)
+ return img_w_;
+}
+inline void PriorBoxParameter::set_img_w(::google::protobuf::uint32 value) {
+ set_has_img_w();
+ img_w_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.img_w)
+}
+
+// optional float step = 10;
+inline bool PriorBoxParameter::has_step() const {
+ return (_has_bits_[0] & 0x00000200u) != 0;
+}
+inline void PriorBoxParameter::set_has_step() {
+ _has_bits_[0] |= 0x00000200u;
+}
+inline void PriorBoxParameter::clear_has_step() {
+ _has_bits_[0] &= ~0x00000200u;
+}
+inline void PriorBoxParameter::clear_step() {
+ step_ = 0;
+ clear_has_step();
+}
+inline float PriorBoxParameter::step() const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.step)
+ return step_;
+}
+inline void PriorBoxParameter::set_step(float value) {
+ set_has_step();
+ step_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.step)
+}
+
+// optional float step_h = 11;
+inline bool PriorBoxParameter::has_step_h() const {
+ return (_has_bits_[0] & 0x00000400u) != 0;
+}
+inline void PriorBoxParameter::set_has_step_h() {
+ _has_bits_[0] |= 0x00000400u;
+}
+inline void PriorBoxParameter::clear_has_step_h() {
+ _has_bits_[0] &= ~0x00000400u;
+}
+inline void PriorBoxParameter::clear_step_h() {
+ step_h_ = 0;
+ clear_has_step_h();
+}
+inline float PriorBoxParameter::step_h() const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.step_h)
+ return step_h_;
+}
+inline void PriorBoxParameter::set_step_h(float value) {
+ set_has_step_h();
+ step_h_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.step_h)
+}
+
+// optional float step_w = 12;
+inline bool PriorBoxParameter::has_step_w() const {
+ return (_has_bits_[0] & 0x00000800u) != 0;
+}
+inline void PriorBoxParameter::set_has_step_w() {
+ _has_bits_[0] |= 0x00000800u;
+}
+inline void PriorBoxParameter::clear_has_step_w() {
+ _has_bits_[0] &= ~0x00000800u;
+}
+inline void PriorBoxParameter::clear_step_w() {
+ step_w_ = 0;
+ clear_has_step_w();
+}
+inline float PriorBoxParameter::step_w() const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.step_w)
+ return step_w_;
+}
+inline void PriorBoxParameter::set_step_w(float value) {
+ set_has_step_w();
+ step_w_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.step_w)
+}
+
+// optional float offset = 13 [default = 0.5];
+inline bool PriorBoxParameter::has_offset() const {
+ return (_has_bits_[0] & 0x00001000u) != 0;
+}
+inline void PriorBoxParameter::set_has_offset() {
+ _has_bits_[0] |= 0x00001000u;
+}
+inline void PriorBoxParameter::clear_has_offset() {
+ _has_bits_[0] &= ~0x00001000u;
+}
+inline void PriorBoxParameter::clear_offset() {
+ offset_ = 0.5f;
+ clear_has_offset();
+}
+inline float PriorBoxParameter::offset() const {
+ // @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.offset)
+ return offset_;
+}
+inline void PriorBoxParameter::set_offset(float value) {
+ set_has_offset();
+ offset_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.offset)
+}
+
+inline const PriorBoxParameter* PriorBoxParameter::internal_default_instance() {
+ return &PriorBoxParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// DetectionOutputParameter
+
+// optional uint32 num_classes = 1;
+inline bool DetectionOutputParameter::has_num_classes() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void DetectionOutputParameter::set_has_num_classes() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void DetectionOutputParameter::clear_has_num_classes() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void DetectionOutputParameter::clear_num_classes() {
+ num_classes_ = 0u;
+ clear_has_num_classes();
+}
+inline ::google::protobuf::uint32 DetectionOutputParameter::num_classes() const {
+ // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.num_classes)
+ return num_classes_;
+}
+inline void DetectionOutputParameter::set_num_classes(::google::protobuf::uint32 value) {
+ set_has_num_classes();
+ num_classes_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.num_classes)
+}
+
+// optional bool share_location = 2 [default = true];
+inline bool DetectionOutputParameter::has_share_location() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void DetectionOutputParameter::set_has_share_location() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void DetectionOutputParameter::clear_has_share_location() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void DetectionOutputParameter::clear_share_location() {
+ share_location_ = true;
+ clear_has_share_location();
+}
+inline bool DetectionOutputParameter::share_location() const {
+ // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.share_location)
+ return share_location_;
+}
+inline void DetectionOutputParameter::set_share_location(bool value) {
+ set_has_share_location();
+ share_location_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.share_location)
+}
+
+// optional int32 background_label_id = 3 [default = 0];
+inline bool DetectionOutputParameter::has_background_label_id() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void DetectionOutputParameter::set_has_background_label_id() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void DetectionOutputParameter::clear_has_background_label_id() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void DetectionOutputParameter::clear_background_label_id() {
+ background_label_id_ = 0;
+ clear_has_background_label_id();
+}
+inline ::google::protobuf::int32 DetectionOutputParameter::background_label_id() const {
+ // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.background_label_id)
+ return background_label_id_;
+}
+inline void DetectionOutputParameter::set_background_label_id(::google::protobuf::int32 value) {
+ set_has_background_label_id();
+ background_label_id_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.background_label_id)
+}
+
+// optional .caffe.NonMaximumSuppressionParameter nms_param = 4;
+inline bool DetectionOutputParameter::has_nms_param() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void DetectionOutputParameter::set_has_nms_param() {
+ _has_bits_[0] |= 0x00000008u;
+}
+inline void DetectionOutputParameter::clear_has_nms_param() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+inline void DetectionOutputParameter::clear_nms_param() {
+ if (nms_param_ != NULL) nms_param_->::caffe::NonMaximumSuppressionParameter::Clear();
+ clear_has_nms_param();
+}
+inline const ::caffe::NonMaximumSuppressionParameter& DetectionOutputParameter::nms_param() const {
+ // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.nms_param)
+ return nms_param_ != NULL ? *nms_param_
+ : *::caffe::NonMaximumSuppressionParameter::internal_default_instance();
+}
+inline ::caffe::NonMaximumSuppressionParameter* DetectionOutputParameter::mutable_nms_param() {
+ set_has_nms_param();
+ if (nms_param_ == NULL) {
+ nms_param_ = new ::caffe::NonMaximumSuppressionParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.DetectionOutputParameter.nms_param)
+ return nms_param_;
+}
+inline ::caffe::NonMaximumSuppressionParameter* DetectionOutputParameter::release_nms_param() {
+ // @@protoc_insertion_point(field_release:caffe.DetectionOutputParameter.nms_param)
+ clear_has_nms_param();
+ ::caffe::NonMaximumSuppressionParameter* temp = nms_param_;
+ nms_param_ = NULL;
+ return temp;
+}
+inline void DetectionOutputParameter::set_allocated_nms_param(::caffe::NonMaximumSuppressionParameter* nms_param) {
+ delete nms_param_;
+ nms_param_ = nms_param;
+ if (nms_param) {
+ set_has_nms_param();
+ } else {
+ clear_has_nms_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.DetectionOutputParameter.nms_param)
+}
+
+// optional .caffe.SaveOutputParameter save_output_param = 5;
+inline bool DetectionOutputParameter::has_save_output_param() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+inline void DetectionOutputParameter::set_has_save_output_param() {
+ _has_bits_[0] |= 0x00000010u;
+}
+inline void DetectionOutputParameter::clear_has_save_output_param() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+inline void DetectionOutputParameter::clear_save_output_param() {
+ if (save_output_param_ != NULL) save_output_param_->::caffe::SaveOutputParameter::Clear();
+ clear_has_save_output_param();
+}
+inline const ::caffe::SaveOutputParameter& DetectionOutputParameter::save_output_param() const {
+ // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.save_output_param)
+ return save_output_param_ != NULL ? *save_output_param_
+ : *::caffe::SaveOutputParameter::internal_default_instance();
+}
+inline ::caffe::SaveOutputParameter* DetectionOutputParameter::mutable_save_output_param() {
+ set_has_save_output_param();
+ if (save_output_param_ == NULL) {
+ save_output_param_ = new ::caffe::SaveOutputParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.DetectionOutputParameter.save_output_param)
+ return save_output_param_;
+}
+inline ::caffe::SaveOutputParameter* DetectionOutputParameter::release_save_output_param() {
+ // @@protoc_insertion_point(field_release:caffe.DetectionOutputParameter.save_output_param)
+ clear_has_save_output_param();
+ ::caffe::SaveOutputParameter* temp = save_output_param_;
+ save_output_param_ = NULL;
+ return temp;
+}
+inline void DetectionOutputParameter::set_allocated_save_output_param(::caffe::SaveOutputParameter* save_output_param) {
+ delete save_output_param_;
+ save_output_param_ = save_output_param;
+ if (save_output_param) {
+ set_has_save_output_param();
+ } else {
+ clear_has_save_output_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.DetectionOutputParameter.save_output_param)
+}
+
+// optional .caffe.PriorBoxParameter.CodeType code_type = 6 [default = CORNER];
+inline bool DetectionOutputParameter::has_code_type() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+inline void DetectionOutputParameter::set_has_code_type() {
+ _has_bits_[0] |= 0x00000020u;
+}
+inline void DetectionOutputParameter::clear_has_code_type() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+inline void DetectionOutputParameter::clear_code_type() {
+ code_type_ = 1;
+ clear_has_code_type();
+}
+inline ::caffe::PriorBoxParameter_CodeType DetectionOutputParameter::code_type() const {
+ // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.code_type)
+ return static_cast< ::caffe::PriorBoxParameter_CodeType >(code_type_);
+}
+inline void DetectionOutputParameter::set_code_type(::caffe::PriorBoxParameter_CodeType value) {
+ assert(::caffe::PriorBoxParameter_CodeType_IsValid(value));
+ set_has_code_type();
+ code_type_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.code_type)
+}
+
+// optional bool variance_encoded_in_target = 8 [default = false];
+inline bool DetectionOutputParameter::has_variance_encoded_in_target() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+inline void DetectionOutputParameter::set_has_variance_encoded_in_target() {
+ _has_bits_[0] |= 0x00000040u;
+}
+inline void DetectionOutputParameter::clear_has_variance_encoded_in_target() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+inline void DetectionOutputParameter::clear_variance_encoded_in_target() {
+ variance_encoded_in_target_ = false;
+ clear_has_variance_encoded_in_target();
+}
+inline bool DetectionOutputParameter::variance_encoded_in_target() const {
+ // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.variance_encoded_in_target)
+ return variance_encoded_in_target_;
+}
+inline void DetectionOutputParameter::set_variance_encoded_in_target(bool value) {
+ set_has_variance_encoded_in_target();
+ variance_encoded_in_target_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.variance_encoded_in_target)
+}
+
+// optional int32 keep_top_k = 7 [default = -1];
+inline bool DetectionOutputParameter::has_keep_top_k() const {
+ return (_has_bits_[0] & 0x00000080u) != 0;
+}
+inline void DetectionOutputParameter::set_has_keep_top_k() {
+ _has_bits_[0] |= 0x00000080u;
+}
+inline void DetectionOutputParameter::clear_has_keep_top_k() {
+ _has_bits_[0] &= ~0x00000080u;
+}
+inline void DetectionOutputParameter::clear_keep_top_k() {
+ keep_top_k_ = -1;
+ clear_has_keep_top_k();
+}
+inline ::google::protobuf::int32 DetectionOutputParameter::keep_top_k() const {
+ // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.keep_top_k)
+ return keep_top_k_;
+}
+inline void DetectionOutputParameter::set_keep_top_k(::google::protobuf::int32 value) {
+ set_has_keep_top_k();
+ keep_top_k_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.keep_top_k)
+}
+
+// optional float confidence_threshold = 9;
+inline bool DetectionOutputParameter::has_confidence_threshold() const {
+ return (_has_bits_[0] & 0x00000100u) != 0;
+}
+inline void DetectionOutputParameter::set_has_confidence_threshold() {
+ _has_bits_[0] |= 0x00000100u;
+}
+inline void DetectionOutputParameter::clear_has_confidence_threshold() {
+ _has_bits_[0] &= ~0x00000100u;
+}
+inline void DetectionOutputParameter::clear_confidence_threshold() {
+ confidence_threshold_ = 0;
+ clear_has_confidence_threshold();
+}
+inline float DetectionOutputParameter::confidence_threshold() const {
+ // @@protoc_insertion_point(field_get:caffe.DetectionOutputParameter.confidence_threshold)
+ return confidence_threshold_;
+}
+inline void DetectionOutputParameter::set_confidence_threshold(float value) {
+ set_has_confidence_threshold();
+ confidence_threshold_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DetectionOutputParameter.confidence_threshold)
+}
+
+inline const DetectionOutputParameter* DetectionOutputParameter::internal_default_instance() {
+ return &DetectionOutputParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// Datum
+
+// optional int32 channels = 1;
+inline bool Datum::has_channels() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void Datum::set_has_channels() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void Datum::clear_has_channels() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void Datum::clear_channels() {
+ channels_ = 0;
+ clear_has_channels();
+}
+inline ::google::protobuf::int32 Datum::channels() const {
+ // @@protoc_insertion_point(field_get:caffe.Datum.channels)
+ return channels_;
+}
+inline void Datum::set_channels(::google::protobuf::int32 value) {
+ set_has_channels();
+ channels_ = value;
+ // @@protoc_insertion_point(field_set:caffe.Datum.channels)
+}
+
+// optional int32 height = 2;
+inline bool Datum::has_height() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void Datum::set_has_height() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void Datum::clear_has_height() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void Datum::clear_height() {
+ height_ = 0;
+ clear_has_height();
+}
+inline ::google::protobuf::int32 Datum::height() const {
+ // @@protoc_insertion_point(field_get:caffe.Datum.height)
+ return height_;
+}
+inline void Datum::set_height(::google::protobuf::int32 value) {
+ set_has_height();
+ height_ = value;
+ // @@protoc_insertion_point(field_set:caffe.Datum.height)
+}
+
+// optional int32 width = 3;
+inline bool Datum::has_width() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void Datum::set_has_width() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void Datum::clear_has_width() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void Datum::clear_width() {
+ width_ = 0;
+ clear_has_width();
+}
+inline ::google::protobuf::int32 Datum::width() const {
+ // @@protoc_insertion_point(field_get:caffe.Datum.width)
+ return width_;
+}
+inline void Datum::set_width(::google::protobuf::int32 value) {
+ set_has_width();
+ width_ = value;
+ // @@protoc_insertion_point(field_set:caffe.Datum.width)
+}
+
+// optional bytes data = 4;
+inline bool Datum::has_data() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void Datum::set_has_data() {
+ _has_bits_[0] |= 0x00000008u;
+}
+inline void Datum::clear_has_data() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+inline void Datum::clear_data() {
+ data_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_data();
+}
+inline const ::std::string& Datum::data() const {
+ // @@protoc_insertion_point(field_get:caffe.Datum.data)
+ return data_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void Datum::set_data(const ::std::string& value) {
+ set_has_data();
+ data_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.Datum.data)
+}
+inline void Datum::set_data(const char* value) {
+ set_has_data();
+ data_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.Datum.data)
+}
+inline void Datum::set_data(const void* value, size_t size) {
+ set_has_data();
+ data_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.Datum.data)
+}
+inline ::std::string* Datum::mutable_data() {
+ set_has_data();
+ // @@protoc_insertion_point(field_mutable:caffe.Datum.data)
+ return data_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* Datum::release_data() {
+ // @@protoc_insertion_point(field_release:caffe.Datum.data)
+ clear_has_data();
+ return data_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void Datum::set_allocated_data(::std::string* data) {
+ if (data != NULL) {
+ set_has_data();
+ } else {
+ clear_has_data();
+ }
+ data_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), data);
+ // @@protoc_insertion_point(field_set_allocated:caffe.Datum.data)
+}
+
+// optional int32 label = 5;
+inline bool Datum::has_label() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+inline void Datum::set_has_label() {
+ _has_bits_[0] |= 0x00000010u;
+}
+inline void Datum::clear_has_label() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+inline void Datum::clear_label() {
+ label_ = 0;
+ clear_has_label();
+}
+inline ::google::protobuf::int32 Datum::label() const {
+ // @@protoc_insertion_point(field_get:caffe.Datum.label)
+ return label_;
+}
+inline void Datum::set_label(::google::protobuf::int32 value) {
+ set_has_label();
+ label_ = value;
+ // @@protoc_insertion_point(field_set:caffe.Datum.label)
+}
+
+// repeated float float_data = 6;
+inline int Datum::float_data_size() const {
+ return float_data_.size();
+}
+inline void Datum::clear_float_data() {
+ float_data_.Clear();
+}
+inline float Datum::float_data(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.Datum.float_data)
+ return float_data_.Get(index);
+}
+inline void Datum::set_float_data(int index, float value) {
+ float_data_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.Datum.float_data)
+}
+inline void Datum::add_float_data(float value) {
+ float_data_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.Datum.float_data)
+}
+inline const ::google::protobuf::RepeatedField< float >&
+Datum::float_data() const {
+ // @@protoc_insertion_point(field_list:caffe.Datum.float_data)
+ return float_data_;
+}
+inline ::google::protobuf::RepeatedField< float >*
+Datum::mutable_float_data() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.Datum.float_data)
+ return &float_data_;
+}
+
+// optional bool encoded = 7 [default = false];
+inline bool Datum::has_encoded() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+inline void Datum::set_has_encoded() {
+ _has_bits_[0] |= 0x00000040u;
+}
+inline void Datum::clear_has_encoded() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+inline void Datum::clear_encoded() {
+ encoded_ = false;
+ clear_has_encoded();
+}
+inline bool Datum::encoded() const {
+ // @@protoc_insertion_point(field_get:caffe.Datum.encoded)
+ return encoded_;
+}
+inline void Datum::set_encoded(bool value) {
+ set_has_encoded();
+ encoded_ = value;
+ // @@protoc_insertion_point(field_set:caffe.Datum.encoded)
+}
+
+inline const Datum* Datum::internal_default_instance() {
+ return &Datum_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// FillerParameter
+
+// optional string type = 1 [default = "constant"];
+inline bool FillerParameter::has_type() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void FillerParameter::set_has_type() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void FillerParameter::clear_has_type() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void FillerParameter::clear_type() {
+ type_.ClearToDefaultNoArena(_default_type_);
+ clear_has_type();
+}
+inline const ::std::string& FillerParameter::type() const {
+ // @@protoc_insertion_point(field_get:caffe.FillerParameter.type)
+ return type_.GetNoArena(_default_type_);
+}
+inline void FillerParameter::set_type(const ::std::string& value) {
+ set_has_type();
+ type_.SetNoArena(_default_type_, value);
+ // @@protoc_insertion_point(field_set:caffe.FillerParameter.type)
+}
+inline void FillerParameter::set_type(const char* value) {
+ set_has_type();
+ type_.SetNoArena(_default_type_, ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.FillerParameter.type)
+}
+inline void FillerParameter::set_type(const char* value, size_t size) {
+ set_has_type();
+ type_.SetNoArena(_default_type_,
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.FillerParameter.type)
+}
+inline ::std::string* FillerParameter::mutable_type() {
+ set_has_type();
+ // @@protoc_insertion_point(field_mutable:caffe.FillerParameter.type)
+ return type_.MutableNoArena(_default_type_);
+}
+inline ::std::string* FillerParameter::release_type() {
+ // @@protoc_insertion_point(field_release:caffe.FillerParameter.type)
+ clear_has_type();
+ return type_.ReleaseNoArena(_default_type_);
+}
+inline void FillerParameter::set_allocated_type(::std::string* type) {
+ if (type != NULL) {
+ set_has_type();
+ } else {
+ clear_has_type();
+ }
+ type_.SetAllocatedNoArena(_default_type_, type);
+ // @@protoc_insertion_point(field_set_allocated:caffe.FillerParameter.type)
+}
+
+// optional float value = 2 [default = 0];
+inline bool FillerParameter::has_value() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void FillerParameter::set_has_value() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void FillerParameter::clear_has_value() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void FillerParameter::clear_value() {
+ value_ = 0;
+ clear_has_value();
+}
+inline float FillerParameter::value() const {
+ // @@protoc_insertion_point(field_get:caffe.FillerParameter.value)
+ return value_;
+}
+inline void FillerParameter::set_value(float value) {
+ set_has_value();
+ value_ = value;
+ // @@protoc_insertion_point(field_set:caffe.FillerParameter.value)
+}
+
+// optional float min = 3 [default = 0];
+inline bool FillerParameter::has_min() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void FillerParameter::set_has_min() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void FillerParameter::clear_has_min() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void FillerParameter::clear_min() {
+ min_ = 0;
+ clear_has_min();
+}
+inline float FillerParameter::min() const {
+ // @@protoc_insertion_point(field_get:caffe.FillerParameter.min)
+ return min_;
+}
+inline void FillerParameter::set_min(float value) {
+ set_has_min();
+ min_ = value;
+ // @@protoc_insertion_point(field_set:caffe.FillerParameter.min)
+}
+
+// optional float max = 4 [default = 1];
+inline bool FillerParameter::has_max() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void FillerParameter::set_has_max() {
+ _has_bits_[0] |= 0x00000008u;
+}
+inline void FillerParameter::clear_has_max() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+inline void FillerParameter::clear_max() {
+ max_ = 1;
+ clear_has_max();
+}
+inline float FillerParameter::max() const {
+ // @@protoc_insertion_point(field_get:caffe.FillerParameter.max)
+ return max_;
+}
+inline void FillerParameter::set_max(float value) {
+ set_has_max();
+ max_ = value;
+ // @@protoc_insertion_point(field_set:caffe.FillerParameter.max)
+}
+
+// optional float mean = 5 [default = 0];
+inline bool FillerParameter::has_mean() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+inline void FillerParameter::set_has_mean() {
+ _has_bits_[0] |= 0x00000010u;
+}
+inline void FillerParameter::clear_has_mean() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+inline void FillerParameter::clear_mean() {
+ mean_ = 0;
+ clear_has_mean();
+}
+inline float FillerParameter::mean() const {
+ // @@protoc_insertion_point(field_get:caffe.FillerParameter.mean)
+ return mean_;
+}
+inline void FillerParameter::set_mean(float value) {
+ set_has_mean();
+ mean_ = value;
+ // @@protoc_insertion_point(field_set:caffe.FillerParameter.mean)
+}
+
+// optional float std = 6 [default = 1];
+inline bool FillerParameter::has_std() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+inline void FillerParameter::set_has_std() {
+ _has_bits_[0] |= 0x00000020u;
+}
+inline void FillerParameter::clear_has_std() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+inline void FillerParameter::clear_std() {
+ std_ = 1;
+ clear_has_std();
+}
+inline float FillerParameter::std() const {
+ // @@protoc_insertion_point(field_get:caffe.FillerParameter.std)
+ return std_;
+}
+inline void FillerParameter::set_std(float value) {
+ set_has_std();
+ std_ = value;
+ // @@protoc_insertion_point(field_set:caffe.FillerParameter.std)
+}
+
+// optional int32 sparse = 7 [default = -1];
+inline bool FillerParameter::has_sparse() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+inline void FillerParameter::set_has_sparse() {
+ _has_bits_[0] |= 0x00000040u;
+}
+inline void FillerParameter::clear_has_sparse() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+inline void FillerParameter::clear_sparse() {
+ sparse_ = -1;
+ clear_has_sparse();
+}
+inline ::google::protobuf::int32 FillerParameter::sparse() const {
+ // @@protoc_insertion_point(field_get:caffe.FillerParameter.sparse)
+ return sparse_;
+}
+inline void FillerParameter::set_sparse(::google::protobuf::int32 value) {
+ set_has_sparse();
+ sparse_ = value;
+ // @@protoc_insertion_point(field_set:caffe.FillerParameter.sparse)
+}
+
+// optional .caffe.FillerParameter.VarianceNorm variance_norm = 8 [default = FAN_IN];
+inline bool FillerParameter::has_variance_norm() const {
+ return (_has_bits_[0] & 0x00000080u) != 0;
+}
+inline void FillerParameter::set_has_variance_norm() {
+ _has_bits_[0] |= 0x00000080u;
+}
+inline void FillerParameter::clear_has_variance_norm() {
+ _has_bits_[0] &= ~0x00000080u;
+}
+inline void FillerParameter::clear_variance_norm() {
+ variance_norm_ = 0;
+ clear_has_variance_norm();
+}
+inline ::caffe::FillerParameter_VarianceNorm FillerParameter::variance_norm() const {
+ // @@protoc_insertion_point(field_get:caffe.FillerParameter.variance_norm)
+ return static_cast< ::caffe::FillerParameter_VarianceNorm >(variance_norm_);
+}
+inline void FillerParameter::set_variance_norm(::caffe::FillerParameter_VarianceNorm value) {
+ assert(::caffe::FillerParameter_VarianceNorm_IsValid(value));
+ set_has_variance_norm();
+ variance_norm_ = value;
+ // @@protoc_insertion_point(field_set:caffe.FillerParameter.variance_norm)
+}
+
+inline const FillerParameter* FillerParameter::internal_default_instance() {
+ return &FillerParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// NetParameter
+
+// optional string name = 1;
+inline bool NetParameter::has_name() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void NetParameter::set_has_name() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void NetParameter::clear_has_name() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void NetParameter::clear_name() {
+ name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_name();
+}
+inline const ::std::string& NetParameter::name() const {
+ // @@protoc_insertion_point(field_get:caffe.NetParameter.name)
+ return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void NetParameter::set_name(const ::std::string& value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.NetParameter.name)
+}
+inline void NetParameter::set_name(const char* value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.NetParameter.name)
+}
+inline void NetParameter::set_name(const char* value, size_t size) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.NetParameter.name)
+}
+inline ::std::string* NetParameter::mutable_name() {
+ set_has_name();
+ // @@protoc_insertion_point(field_mutable:caffe.NetParameter.name)
+ return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* NetParameter::release_name() {
+ // @@protoc_insertion_point(field_release:caffe.NetParameter.name)
+ clear_has_name();
+ return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void NetParameter::set_allocated_name(::std::string* name) {
+ if (name != NULL) {
+ set_has_name();
+ } else {
+ clear_has_name();
+ }
+ name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
+ // @@protoc_insertion_point(field_set_allocated:caffe.NetParameter.name)
+}
+
+// repeated string input = 3;
+inline int NetParameter::input_size() const {
+ return input_.size();
+}
+inline void NetParameter::clear_input() {
+ input_.Clear();
+}
+inline const ::std::string& NetParameter::input(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.NetParameter.input)
+ return input_.Get(index);
+}
+inline ::std::string* NetParameter::mutable_input(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.NetParameter.input)
+ return input_.Mutable(index);
+}
+inline void NetParameter::set_input(int index, const ::std::string& value) {
+ // @@protoc_insertion_point(field_set:caffe.NetParameter.input)
+ input_.Mutable(index)->assign(value);
+}
+inline void NetParameter::set_input(int index, const char* value) {
+ input_.Mutable(index)->assign(value);
+ // @@protoc_insertion_point(field_set_char:caffe.NetParameter.input)
+}
+inline void NetParameter::set_input(int index, const char* value, size_t size) {
+ input_.Mutable(index)->assign(
+ reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_set_pointer:caffe.NetParameter.input)
+}
+inline ::std::string* NetParameter::add_input() {
+ // @@protoc_insertion_point(field_add_mutable:caffe.NetParameter.input)
+ return input_.Add();
+}
+inline void NetParameter::add_input(const ::std::string& value) {
+ input_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add:caffe.NetParameter.input)
+}
+inline void NetParameter::add_input(const char* value) {
+ input_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add_char:caffe.NetParameter.input)
+}
+inline void NetParameter::add_input(const char* value, size_t size) {
+ input_.Add()->assign(reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_add_pointer:caffe.NetParameter.input)
+}
+inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
+NetParameter::input() const {
+ // @@protoc_insertion_point(field_list:caffe.NetParameter.input)
+ return input_;
+}
+inline ::google::protobuf::RepeatedPtrField< ::std::string>*
+NetParameter::mutable_input() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.input)
+ return &input_;
+}
+
+// repeated .caffe.BlobShape input_shape = 8;
+inline int NetParameter::input_shape_size() const {
+ return input_shape_.size();
+}
+inline void NetParameter::clear_input_shape() {
+ input_shape_.Clear();
+}
+inline const ::caffe::BlobShape& NetParameter::input_shape(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.NetParameter.input_shape)
+ return input_shape_.Get(index);
+}
+inline ::caffe::BlobShape* NetParameter::mutable_input_shape(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.NetParameter.input_shape)
+ return input_shape_.Mutable(index);
+}
+inline ::caffe::BlobShape* NetParameter::add_input_shape() {
+ // @@protoc_insertion_point(field_add:caffe.NetParameter.input_shape)
+ return input_shape_.Add();
+}
+inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >*
+NetParameter::mutable_input_shape() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.input_shape)
+ return &input_shape_;
+}
+inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >&
+NetParameter::input_shape() const {
+ // @@protoc_insertion_point(field_list:caffe.NetParameter.input_shape)
+ return input_shape_;
+}
+
+// repeated int32 input_dim = 4;
+inline int NetParameter::input_dim_size() const {
+ return input_dim_.size();
+}
+inline void NetParameter::clear_input_dim() {
+ input_dim_.Clear();
+}
+inline ::google::protobuf::int32 NetParameter::input_dim(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.NetParameter.input_dim)
+ return input_dim_.Get(index);
+}
+inline void NetParameter::set_input_dim(int index, ::google::protobuf::int32 value) {
+ input_dim_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.NetParameter.input_dim)
+}
+inline void NetParameter::add_input_dim(::google::protobuf::int32 value) {
+ input_dim_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.NetParameter.input_dim)
+}
+inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
+NetParameter::input_dim() const {
+ // @@protoc_insertion_point(field_list:caffe.NetParameter.input_dim)
+ return input_dim_;
+}
+inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
+NetParameter::mutable_input_dim() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.input_dim)
+ return &input_dim_;
+}
+
+// optional bool force_backward = 5 [default = false];
+inline bool NetParameter::has_force_backward() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+inline void NetParameter::set_has_force_backward() {
+ _has_bits_[0] |= 0x00000010u;
+}
+inline void NetParameter::clear_has_force_backward() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+inline void NetParameter::clear_force_backward() {
+ force_backward_ = false;
+ clear_has_force_backward();
+}
+inline bool NetParameter::force_backward() const {
+ // @@protoc_insertion_point(field_get:caffe.NetParameter.force_backward)
+ return force_backward_;
+}
+inline void NetParameter::set_force_backward(bool value) {
+ set_has_force_backward();
+ force_backward_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NetParameter.force_backward)
+}
+
+// optional .caffe.NetState state = 6;
+inline bool NetParameter::has_state() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+inline void NetParameter::set_has_state() {
+ _has_bits_[0] |= 0x00000020u;
+}
+inline void NetParameter::clear_has_state() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+inline void NetParameter::clear_state() {
+ if (state_ != NULL) state_->::caffe::NetState::Clear();
+ clear_has_state();
+}
+inline const ::caffe::NetState& NetParameter::state() const {
+ // @@protoc_insertion_point(field_get:caffe.NetParameter.state)
+ return state_ != NULL ? *state_
+ : *::caffe::NetState::internal_default_instance();
+}
+inline ::caffe::NetState* NetParameter::mutable_state() {
+ set_has_state();
+ if (state_ == NULL) {
+ state_ = new ::caffe::NetState;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.NetParameter.state)
+ return state_;
+}
+inline ::caffe::NetState* NetParameter::release_state() {
+ // @@protoc_insertion_point(field_release:caffe.NetParameter.state)
+ clear_has_state();
+ ::caffe::NetState* temp = state_;
+ state_ = NULL;
+ return temp;
+}
+inline void NetParameter::set_allocated_state(::caffe::NetState* state) {
+ delete state_;
+ state_ = state;
+ if (state) {
+ set_has_state();
+ } else {
+ clear_has_state();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.NetParameter.state)
+}
+
+// optional bool debug_info = 7 [default = false];
+inline bool NetParameter::has_debug_info() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+inline void NetParameter::set_has_debug_info() {
+ _has_bits_[0] |= 0x00000040u;
+}
+inline void NetParameter::clear_has_debug_info() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+inline void NetParameter::clear_debug_info() {
+ debug_info_ = false;
+ clear_has_debug_info();
+}
+inline bool NetParameter::debug_info() const {
+ // @@protoc_insertion_point(field_get:caffe.NetParameter.debug_info)
+ return debug_info_;
+}
+inline void NetParameter::set_debug_info(bool value) {
+ set_has_debug_info();
+ debug_info_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NetParameter.debug_info)
+}
+
+// repeated .caffe.LayerParameter layer = 100;
+inline int NetParameter::layer_size() const {
+ return layer_.size();
+}
+inline void NetParameter::clear_layer() {
+ layer_.Clear();
+}
+inline const ::caffe::LayerParameter& NetParameter::layer(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.NetParameter.layer)
+ return layer_.Get(index);
+}
+inline ::caffe::LayerParameter* NetParameter::mutable_layer(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.NetParameter.layer)
+ return layer_.Mutable(index);
+}
+inline ::caffe::LayerParameter* NetParameter::add_layer() {
+ // @@protoc_insertion_point(field_add:caffe.NetParameter.layer)
+ return layer_.Add();
+}
+inline ::google::protobuf::RepeatedPtrField< ::caffe::LayerParameter >*
+NetParameter::mutable_layer() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.layer)
+ return &layer_;
+}
+inline const ::google::protobuf::RepeatedPtrField< ::caffe::LayerParameter >&
+NetParameter::layer() const {
+ // @@protoc_insertion_point(field_list:caffe.NetParameter.layer)
+ return layer_;
+}
+
+// repeated .caffe.V1LayerParameter layers = 2;
+inline int NetParameter::layers_size() const {
+ return layers_.size();
+}
+inline void NetParameter::clear_layers() {
+ layers_.Clear();
+}
+inline const ::caffe::V1LayerParameter& NetParameter::layers(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.NetParameter.layers)
+ return layers_.Get(index);
+}
+inline ::caffe::V1LayerParameter* NetParameter::mutable_layers(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.NetParameter.layers)
+ return layers_.Mutable(index);
+}
+inline ::caffe::V1LayerParameter* NetParameter::add_layers() {
+ // @@protoc_insertion_point(field_add:caffe.NetParameter.layers)
+ return layers_.Add();
+}
+inline ::google::protobuf::RepeatedPtrField< ::caffe::V1LayerParameter >*
+NetParameter::mutable_layers() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.NetParameter.layers)
+ return &layers_;
+}
+inline const ::google::protobuf::RepeatedPtrField< ::caffe::V1LayerParameter >&
+NetParameter::layers() const {
+ // @@protoc_insertion_point(field_list:caffe.NetParameter.layers)
+ return layers_;
+}
+
+inline const NetParameter* NetParameter::internal_default_instance() {
+ return &NetParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// SolverParameter
+
+// optional string net = 24;
+inline bool SolverParameter::has_net() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void SolverParameter::set_has_net() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void SolverParameter::clear_has_net() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void SolverParameter::clear_net() {
+ net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_net();
+}
+inline const ::std::string& SolverParameter::net() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.net)
+ return net_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void SolverParameter::set_net(const ::std::string& value) {
+ set_has_net();
+ net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.net)
+}
+inline void SolverParameter::set_net(const char* value) {
+ set_has_net();
+ net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.net)
+}
+inline void SolverParameter::set_net(const char* value, size_t size) {
+ set_has_net();
+ net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.net)
+}
+inline ::std::string* SolverParameter::mutable_net() {
+ set_has_net();
+ // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.net)
+ return net_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* SolverParameter::release_net() {
+ // @@protoc_insertion_point(field_release:caffe.SolverParameter.net)
+ clear_has_net();
+ return net_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void SolverParameter::set_allocated_net(::std::string* net) {
+ if (net != NULL) {
+ set_has_net();
+ } else {
+ clear_has_net();
+ }
+ net_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), net);
+ // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.net)
+}
+
+// optional .caffe.NetParameter net_param = 25;
+inline bool SolverParameter::has_net_param() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void SolverParameter::set_has_net_param() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void SolverParameter::clear_has_net_param() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void SolverParameter::clear_net_param() {
+ if (net_param_ != NULL) net_param_->::caffe::NetParameter::Clear();
+ clear_has_net_param();
+}
+inline const ::caffe::NetParameter& SolverParameter::net_param() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.net_param)
+ return net_param_ != NULL ? *net_param_
+ : *::caffe::NetParameter::internal_default_instance();
+}
+inline ::caffe::NetParameter* SolverParameter::mutable_net_param() {
+ set_has_net_param();
+ if (net_param_ == NULL) {
+ net_param_ = new ::caffe::NetParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.net_param)
+ return net_param_;
+}
+inline ::caffe::NetParameter* SolverParameter::release_net_param() {
+ // @@protoc_insertion_point(field_release:caffe.SolverParameter.net_param)
+ clear_has_net_param();
+ ::caffe::NetParameter* temp = net_param_;
+ net_param_ = NULL;
+ return temp;
+}
+inline void SolverParameter::set_allocated_net_param(::caffe::NetParameter* net_param) {
+ delete net_param_;
+ net_param_ = net_param;
+ if (net_param) {
+ set_has_net_param();
+ } else {
+ clear_has_net_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.net_param)
+}
+
+// optional string train_net = 1;
+inline bool SolverParameter::has_train_net() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void SolverParameter::set_has_train_net() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void SolverParameter::clear_has_train_net() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void SolverParameter::clear_train_net() {
+ train_net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_train_net();
+}
+inline const ::std::string& SolverParameter::train_net() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.train_net)
+ return train_net_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void SolverParameter::set_train_net(const ::std::string& value) {
+ set_has_train_net();
+ train_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.train_net)
+}
+inline void SolverParameter::set_train_net(const char* value) {
+ set_has_train_net();
+ train_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.train_net)
+}
+inline void SolverParameter::set_train_net(const char* value, size_t size) {
+ set_has_train_net();
+ train_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.train_net)
+}
+inline ::std::string* SolverParameter::mutable_train_net() {
+ set_has_train_net();
+ // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.train_net)
+ return train_net_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* SolverParameter::release_train_net() {
+ // @@protoc_insertion_point(field_release:caffe.SolverParameter.train_net)
+ clear_has_train_net();
+ return train_net_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void SolverParameter::set_allocated_train_net(::std::string* train_net) {
+ if (train_net != NULL) {
+ set_has_train_net();
+ } else {
+ clear_has_train_net();
+ }
+ train_net_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), train_net);
+ // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.train_net)
+}
+
+// repeated string test_net = 2;
+inline int SolverParameter::test_net_size() const {
+ return test_net_.size();
+}
+inline void SolverParameter::clear_test_net() {
+ test_net_.Clear();
+}
+inline const ::std::string& SolverParameter::test_net(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_net)
+ return test_net_.Get(index);
+}
+inline ::std::string* SolverParameter::mutable_test_net(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.test_net)
+ return test_net_.Mutable(index);
+}
+inline void SolverParameter::set_test_net(int index, const ::std::string& value) {
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_net)
+ test_net_.Mutable(index)->assign(value);
+}
+inline void SolverParameter::set_test_net(int index, const char* value) {
+ test_net_.Mutable(index)->assign(value);
+ // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.test_net)
+}
+inline void SolverParameter::set_test_net(int index, const char* value, size_t size) {
+ test_net_.Mutable(index)->assign(
+ reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.test_net)
+}
+inline ::std::string* SolverParameter::add_test_net() {
+ // @@protoc_insertion_point(field_add_mutable:caffe.SolverParameter.test_net)
+ return test_net_.Add();
+}
+inline void SolverParameter::add_test_net(const ::std::string& value) {
+ test_net_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add:caffe.SolverParameter.test_net)
+}
+inline void SolverParameter::add_test_net(const char* value) {
+ test_net_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add_char:caffe.SolverParameter.test_net)
+}
+inline void SolverParameter::add_test_net(const char* value, size_t size) {
+ test_net_.Add()->assign(reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_add_pointer:caffe.SolverParameter.test_net)
+}
+inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
+SolverParameter::test_net() const {
+ // @@protoc_insertion_point(field_list:caffe.SolverParameter.test_net)
+ return test_net_;
+}
+inline ::google::protobuf::RepeatedPtrField< ::std::string>*
+SolverParameter::mutable_test_net() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.test_net)
+ return &test_net_;
+}
+
+// optional .caffe.NetParameter train_net_param = 21;
+inline bool SolverParameter::has_train_net_param() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+inline void SolverParameter::set_has_train_net_param() {
+ _has_bits_[0] |= 0x00000010u;
+}
+inline void SolverParameter::clear_has_train_net_param() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+inline void SolverParameter::clear_train_net_param() {
+ if (train_net_param_ != NULL) train_net_param_->::caffe::NetParameter::Clear();
+ clear_has_train_net_param();
+}
+inline const ::caffe::NetParameter& SolverParameter::train_net_param() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.train_net_param)
+ return train_net_param_ != NULL ? *train_net_param_
+ : *::caffe::NetParameter::internal_default_instance();
+}
+inline ::caffe::NetParameter* SolverParameter::mutable_train_net_param() {
+ set_has_train_net_param();
+ if (train_net_param_ == NULL) {
+ train_net_param_ = new ::caffe::NetParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.train_net_param)
+ return train_net_param_;
+}
+inline ::caffe::NetParameter* SolverParameter::release_train_net_param() {
+ // @@protoc_insertion_point(field_release:caffe.SolverParameter.train_net_param)
+ clear_has_train_net_param();
+ ::caffe::NetParameter* temp = train_net_param_;
+ train_net_param_ = NULL;
+ return temp;
+}
+inline void SolverParameter::set_allocated_train_net_param(::caffe::NetParameter* train_net_param) {
+ delete train_net_param_;
+ train_net_param_ = train_net_param;
+ if (train_net_param) {
+ set_has_train_net_param();
+ } else {
+ clear_has_train_net_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.train_net_param)
+}
+
+// repeated .caffe.NetParameter test_net_param = 22;
+inline int SolverParameter::test_net_param_size() const {
+ return test_net_param_.size();
+}
+inline void SolverParameter::clear_test_net_param() {
+ test_net_param_.Clear();
+}
+inline const ::caffe::NetParameter& SolverParameter::test_net_param(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_net_param)
+ return test_net_param_.Get(index);
+}
+inline ::caffe::NetParameter* SolverParameter::mutable_test_net_param(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.test_net_param)
+ return test_net_param_.Mutable(index);
+}
+inline ::caffe::NetParameter* SolverParameter::add_test_net_param() {
+ // @@protoc_insertion_point(field_add:caffe.SolverParameter.test_net_param)
+ return test_net_param_.Add();
+}
+inline ::google::protobuf::RepeatedPtrField< ::caffe::NetParameter >*
+SolverParameter::mutable_test_net_param() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.test_net_param)
+ return &test_net_param_;
+}
+inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetParameter >&
+SolverParameter::test_net_param() const {
+ // @@protoc_insertion_point(field_list:caffe.SolverParameter.test_net_param)
+ return test_net_param_;
+}
+
+// optional .caffe.NetState train_state = 26;
+inline bool SolverParameter::has_train_state() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+inline void SolverParameter::set_has_train_state() {
+ _has_bits_[0] |= 0x00000040u;
+}
+inline void SolverParameter::clear_has_train_state() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+inline void SolverParameter::clear_train_state() {
+ if (train_state_ != NULL) train_state_->::caffe::NetState::Clear();
+ clear_has_train_state();
+}
+inline const ::caffe::NetState& SolverParameter::train_state() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.train_state)
+ return train_state_ != NULL ? *train_state_
+ : *::caffe::NetState::internal_default_instance();
+}
+inline ::caffe::NetState* SolverParameter::mutable_train_state() {
+ set_has_train_state();
+ if (train_state_ == NULL) {
+ train_state_ = new ::caffe::NetState;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.train_state)
+ return train_state_;
+}
+inline ::caffe::NetState* SolverParameter::release_train_state() {
+ // @@protoc_insertion_point(field_release:caffe.SolverParameter.train_state)
+ clear_has_train_state();
+ ::caffe::NetState* temp = train_state_;
+ train_state_ = NULL;
+ return temp;
+}
+inline void SolverParameter::set_allocated_train_state(::caffe::NetState* train_state) {
+ delete train_state_;
+ train_state_ = train_state;
+ if (train_state) {
+ set_has_train_state();
+ } else {
+ clear_has_train_state();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.train_state)
+}
+
+// repeated .caffe.NetState test_state = 27;
+inline int SolverParameter::test_state_size() const {
+ return test_state_.size();
+}
+inline void SolverParameter::clear_test_state() {
+ test_state_.Clear();
+}
+inline const ::caffe::NetState& SolverParameter::test_state(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_state)
+ return test_state_.Get(index);
+}
+inline ::caffe::NetState* SolverParameter::mutable_test_state(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.test_state)
+ return test_state_.Mutable(index);
+}
+inline ::caffe::NetState* SolverParameter::add_test_state() {
+ // @@protoc_insertion_point(field_add:caffe.SolverParameter.test_state)
+ return test_state_.Add();
+}
+inline ::google::protobuf::RepeatedPtrField< ::caffe::NetState >*
+SolverParameter::mutable_test_state() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.test_state)
+ return &test_state_;
+}
+inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetState >&
+SolverParameter::test_state() const {
+ // @@protoc_insertion_point(field_list:caffe.SolverParameter.test_state)
+ return test_state_;
+}
+
+// repeated int32 test_iter = 3;
+inline int SolverParameter::test_iter_size() const {
+ return test_iter_.size();
+}
+inline void SolverParameter::clear_test_iter() {
+ test_iter_.Clear();
+}
+inline ::google::protobuf::int32 SolverParameter::test_iter(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_iter)
+ return test_iter_.Get(index);
+}
+inline void SolverParameter::set_test_iter(int index, ::google::protobuf::int32 value) {
+ test_iter_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_iter)
+}
+inline void SolverParameter::add_test_iter(::google::protobuf::int32 value) {
+ test_iter_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.SolverParameter.test_iter)
+}
+inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
+SolverParameter::test_iter() const {
+ // @@protoc_insertion_point(field_list:caffe.SolverParameter.test_iter)
+ return test_iter_;
+}
+inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
+SolverParameter::mutable_test_iter() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.test_iter)
+ return &test_iter_;
+}
+
+// optional int32 test_interval = 4 [default = 0];
+inline bool SolverParameter::has_test_interval() const {
+ return (_has_bits_[0] & 0x00000200u) != 0;
+}
+inline void SolverParameter::set_has_test_interval() {
+ _has_bits_[0] |= 0x00000200u;
+}
+inline void SolverParameter::clear_has_test_interval() {
+ _has_bits_[0] &= ~0x00000200u;
+}
+inline void SolverParameter::clear_test_interval() {
+ test_interval_ = 0;
+ clear_has_test_interval();
+}
+inline ::google::protobuf::int32 SolverParameter::test_interval() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_interval)
+ return test_interval_;
+}
+inline void SolverParameter::set_test_interval(::google::protobuf::int32 value) {
+ set_has_test_interval();
+ test_interval_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_interval)
+}
+
+// optional bool test_compute_loss = 19 [default = false];
+inline bool SolverParameter::has_test_compute_loss() const {
+ return (_has_bits_[0] & 0x00000400u) != 0;
+}
+inline void SolverParameter::set_has_test_compute_loss() {
+ _has_bits_[0] |= 0x00000400u;
+}
+inline void SolverParameter::clear_has_test_compute_loss() {
+ _has_bits_[0] &= ~0x00000400u;
+}
+inline void SolverParameter::clear_test_compute_loss() {
+ test_compute_loss_ = false;
+ clear_has_test_compute_loss();
+}
+inline bool SolverParameter::test_compute_loss() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_compute_loss)
+ return test_compute_loss_;
+}
+inline void SolverParameter::set_test_compute_loss(bool value) {
+ set_has_test_compute_loss();
+ test_compute_loss_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_compute_loss)
+}
+
+// optional bool test_initialization = 32 [default = true];
+inline bool SolverParameter::has_test_initialization() const {
+ return (_has_bits_[0] & 0x00000800u) != 0;
+}
+inline void SolverParameter::set_has_test_initialization() {
+ _has_bits_[0] |= 0x00000800u;
+}
+inline void SolverParameter::clear_has_test_initialization() {
+ _has_bits_[0] &= ~0x00000800u;
+}
+inline void SolverParameter::clear_test_initialization() {
+ test_initialization_ = true;
+ clear_has_test_initialization();
+}
+inline bool SolverParameter::test_initialization() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.test_initialization)
+ return test_initialization_;
+}
+inline void SolverParameter::set_test_initialization(bool value) {
+ set_has_test_initialization();
+ test_initialization_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.test_initialization)
+}
+
+// optional float base_lr = 5;
+inline bool SolverParameter::has_base_lr() const {
+ return (_has_bits_[0] & 0x00001000u) != 0;
+}
+inline void SolverParameter::set_has_base_lr() {
+ _has_bits_[0] |= 0x00001000u;
+}
+inline void SolverParameter::clear_has_base_lr() {
+ _has_bits_[0] &= ~0x00001000u;
+}
+inline void SolverParameter::clear_base_lr() {
+ base_lr_ = 0;
+ clear_has_base_lr();
+}
+inline float SolverParameter::base_lr() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.base_lr)
+ return base_lr_;
+}
+inline void SolverParameter::set_base_lr(float value) {
+ set_has_base_lr();
+ base_lr_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.base_lr)
+}
+
+// optional int32 display = 6;
+inline bool SolverParameter::has_display() const {
+ return (_has_bits_[0] & 0x00002000u) != 0;
+}
+inline void SolverParameter::set_has_display() {
+ _has_bits_[0] |= 0x00002000u;
+}
+inline void SolverParameter::clear_has_display() {
+ _has_bits_[0] &= ~0x00002000u;
+}
+inline void SolverParameter::clear_display() {
+ display_ = 0;
+ clear_has_display();
+}
+inline ::google::protobuf::int32 SolverParameter::display() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.display)
+ return display_;
+}
+inline void SolverParameter::set_display(::google::protobuf::int32 value) {
+ set_has_display();
+ display_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.display)
+}
+
+// optional int32 average_loss = 33 [default = 1];
+inline bool SolverParameter::has_average_loss() const {
+ return (_has_bits_[0] & 0x00004000u) != 0;
+}
+inline void SolverParameter::set_has_average_loss() {
+ _has_bits_[0] |= 0x00004000u;
+}
+inline void SolverParameter::clear_has_average_loss() {
+ _has_bits_[0] &= ~0x00004000u;
+}
+inline void SolverParameter::clear_average_loss() {
+ average_loss_ = 1;
+ clear_has_average_loss();
+}
+inline ::google::protobuf::int32 SolverParameter::average_loss() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.average_loss)
+ return average_loss_;
+}
+inline void SolverParameter::set_average_loss(::google::protobuf::int32 value) {
+ set_has_average_loss();
+ average_loss_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.average_loss)
+}
+
+// optional int32 max_iter = 7;
+inline bool SolverParameter::has_max_iter() const {
+ return (_has_bits_[0] & 0x00008000u) != 0;
+}
+inline void SolverParameter::set_has_max_iter() {
+ _has_bits_[0] |= 0x00008000u;
+}
+inline void SolverParameter::clear_has_max_iter() {
+ _has_bits_[0] &= ~0x00008000u;
+}
+inline void SolverParameter::clear_max_iter() {
+ max_iter_ = 0;
+ clear_has_max_iter();
+}
+inline ::google::protobuf::int32 SolverParameter::max_iter() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.max_iter)
+ return max_iter_;
+}
+inline void SolverParameter::set_max_iter(::google::protobuf::int32 value) {
+ set_has_max_iter();
+ max_iter_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.max_iter)
+}
+
+// optional int32 iter_size = 36 [default = 1];
+inline bool SolverParameter::has_iter_size() const {
+ return (_has_bits_[0] & 0x00010000u) != 0;
+}
+inline void SolverParameter::set_has_iter_size() {
+ _has_bits_[0] |= 0x00010000u;
+}
+inline void SolverParameter::clear_has_iter_size() {
+ _has_bits_[0] &= ~0x00010000u;
+}
+inline void SolverParameter::clear_iter_size() {
+ iter_size_ = 1;
+ clear_has_iter_size();
+}
+inline ::google::protobuf::int32 SolverParameter::iter_size() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.iter_size)
+ return iter_size_;
+}
+inline void SolverParameter::set_iter_size(::google::protobuf::int32 value) {
+ set_has_iter_size();
+ iter_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.iter_size)
+}
+
+// optional string lr_policy = 8;
+inline bool SolverParameter::has_lr_policy() const {
+ return (_has_bits_[0] & 0x00020000u) != 0;
+}
+inline void SolverParameter::set_has_lr_policy() {
+ _has_bits_[0] |= 0x00020000u;
+}
+inline void SolverParameter::clear_has_lr_policy() {
+ _has_bits_[0] &= ~0x00020000u;
+}
+inline void SolverParameter::clear_lr_policy() {
+ lr_policy_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_lr_policy();
+}
+inline const ::std::string& SolverParameter::lr_policy() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.lr_policy)
+ return lr_policy_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void SolverParameter::set_lr_policy(const ::std::string& value) {
+ set_has_lr_policy();
+ lr_policy_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.lr_policy)
+}
+inline void SolverParameter::set_lr_policy(const char* value) {
+ set_has_lr_policy();
+ lr_policy_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.lr_policy)
+}
+inline void SolverParameter::set_lr_policy(const char* value, size_t size) {
+ set_has_lr_policy();
+ lr_policy_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.lr_policy)
+}
+inline ::std::string* SolverParameter::mutable_lr_policy() {
+ set_has_lr_policy();
+ // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.lr_policy)
+ return lr_policy_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* SolverParameter::release_lr_policy() {
+ // @@protoc_insertion_point(field_release:caffe.SolverParameter.lr_policy)
+ clear_has_lr_policy();
+ return lr_policy_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void SolverParameter::set_allocated_lr_policy(::std::string* lr_policy) {
+ if (lr_policy != NULL) {
+ set_has_lr_policy();
+ } else {
+ clear_has_lr_policy();
+ }
+ lr_policy_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), lr_policy);
+ // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.lr_policy)
+}
+
+// optional float gamma = 9;
+inline bool SolverParameter::has_gamma() const {
+ return (_has_bits_[0] & 0x00040000u) != 0;
+}
+inline void SolverParameter::set_has_gamma() {
+ _has_bits_[0] |= 0x00040000u;
+}
+inline void SolverParameter::clear_has_gamma() {
+ _has_bits_[0] &= ~0x00040000u;
+}
+inline void SolverParameter::clear_gamma() {
+ gamma_ = 0;
+ clear_has_gamma();
+}
+inline float SolverParameter::gamma() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.gamma)
+ return gamma_;
+}
+inline void SolverParameter::set_gamma(float value) {
+ set_has_gamma();
+ gamma_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.gamma)
+}
+
+// optional float power = 10;
+inline bool SolverParameter::has_power() const {
+ return (_has_bits_[0] & 0x00080000u) != 0;
+}
+inline void SolverParameter::set_has_power() {
+ _has_bits_[0] |= 0x00080000u;
+}
+inline void SolverParameter::clear_has_power() {
+ _has_bits_[0] &= ~0x00080000u;
+}
+inline void SolverParameter::clear_power() {
+ power_ = 0;
+ clear_has_power();
+}
+inline float SolverParameter::power() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.power)
+ return power_;
+}
+inline void SolverParameter::set_power(float value) {
+ set_has_power();
+ power_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.power)
+}
+
+// optional float momentum = 11;
+inline bool SolverParameter::has_momentum() const {
+ return (_has_bits_[0] & 0x00100000u) != 0;
+}
+inline void SolverParameter::set_has_momentum() {
+ _has_bits_[0] |= 0x00100000u;
+}
+inline void SolverParameter::clear_has_momentum() {
+ _has_bits_[0] &= ~0x00100000u;
+}
+inline void SolverParameter::clear_momentum() {
+ momentum_ = 0;
+ clear_has_momentum();
+}
+inline float SolverParameter::momentum() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.momentum)
+ return momentum_;
+}
+inline void SolverParameter::set_momentum(float value) {
+ set_has_momentum();
+ momentum_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.momentum)
+}
+
+// optional float weight_decay = 12;
+inline bool SolverParameter::has_weight_decay() const {
+ return (_has_bits_[0] & 0x00200000u) != 0;
+}
+inline void SolverParameter::set_has_weight_decay() {
+ _has_bits_[0] |= 0x00200000u;
+}
+inline void SolverParameter::clear_has_weight_decay() {
+ _has_bits_[0] &= ~0x00200000u;
+}
+inline void SolverParameter::clear_weight_decay() {
+ weight_decay_ = 0;
+ clear_has_weight_decay();
+}
+inline float SolverParameter::weight_decay() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.weight_decay)
+ return weight_decay_;
+}
+inline void SolverParameter::set_weight_decay(float value) {
+ set_has_weight_decay();
+ weight_decay_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.weight_decay)
+}
+
+// optional string regularization_type = 29 [default = "L2"];
+inline bool SolverParameter::has_regularization_type() const {
+ return (_has_bits_[0] & 0x00400000u) != 0;
+}
+inline void SolverParameter::set_has_regularization_type() {
+ _has_bits_[0] |= 0x00400000u;
+}
+inline void SolverParameter::clear_has_regularization_type() {
+ _has_bits_[0] &= ~0x00400000u;
+}
+inline void SolverParameter::clear_regularization_type() {
+ regularization_type_.ClearToDefaultNoArena(_default_regularization_type_);
+ clear_has_regularization_type();
+}
+inline const ::std::string& SolverParameter::regularization_type() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.regularization_type)
+ return regularization_type_.GetNoArena(_default_regularization_type_);
+}
+inline void SolverParameter::set_regularization_type(const ::std::string& value) {
+ set_has_regularization_type();
+ regularization_type_.SetNoArena(_default_regularization_type_, value);
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.regularization_type)
+}
+inline void SolverParameter::set_regularization_type(const char* value) {
+ set_has_regularization_type();
+ regularization_type_.SetNoArena(_default_regularization_type_, ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.regularization_type)
+}
+inline void SolverParameter::set_regularization_type(const char* value, size_t size) {
+ set_has_regularization_type();
+ regularization_type_.SetNoArena(_default_regularization_type_,
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.regularization_type)
+}
+inline ::std::string* SolverParameter::mutable_regularization_type() {
+ set_has_regularization_type();
+ // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.regularization_type)
+ return regularization_type_.MutableNoArena(_default_regularization_type_);
+}
+inline ::std::string* SolverParameter::release_regularization_type() {
+ // @@protoc_insertion_point(field_release:caffe.SolverParameter.regularization_type)
+ clear_has_regularization_type();
+ return regularization_type_.ReleaseNoArena(_default_regularization_type_);
+}
+inline void SolverParameter::set_allocated_regularization_type(::std::string* regularization_type) {
+ if (regularization_type != NULL) {
+ set_has_regularization_type();
+ } else {
+ clear_has_regularization_type();
+ }
+ regularization_type_.SetAllocatedNoArena(_default_regularization_type_, regularization_type);
+ // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.regularization_type)
+}
+
+// optional int32 stepsize = 13;
+inline bool SolverParameter::has_stepsize() const {
+ return (_has_bits_[0] & 0x00800000u) != 0;
+}
+inline void SolverParameter::set_has_stepsize() {
+ _has_bits_[0] |= 0x00800000u;
+}
+inline void SolverParameter::clear_has_stepsize() {
+ _has_bits_[0] &= ~0x00800000u;
+}
+inline void SolverParameter::clear_stepsize() {
+ stepsize_ = 0;
+ clear_has_stepsize();
+}
+inline ::google::protobuf::int32 SolverParameter::stepsize() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.stepsize)
+ return stepsize_;
+}
+inline void SolverParameter::set_stepsize(::google::protobuf::int32 value) {
+ set_has_stepsize();
+ stepsize_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.stepsize)
+}
+
+// repeated int32 stepvalue = 34;
+inline int SolverParameter::stepvalue_size() const {
+ return stepvalue_.size();
+}
+inline void SolverParameter::clear_stepvalue() {
+ stepvalue_.Clear();
+}
+inline ::google::protobuf::int32 SolverParameter::stepvalue(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.stepvalue)
+ return stepvalue_.Get(index);
+}
+inline void SolverParameter::set_stepvalue(int index, ::google::protobuf::int32 value) {
+ stepvalue_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.stepvalue)
+}
+inline void SolverParameter::add_stepvalue(::google::protobuf::int32 value) {
+ stepvalue_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.SolverParameter.stepvalue)
+}
+inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
+SolverParameter::stepvalue() const {
+ // @@protoc_insertion_point(field_list:caffe.SolverParameter.stepvalue)
+ return stepvalue_;
+}
+inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
+SolverParameter::mutable_stepvalue() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.SolverParameter.stepvalue)
+ return &stepvalue_;
+}
+
+// optional float clip_gradients = 35 [default = -1];
+inline bool SolverParameter::has_clip_gradients() const {
+ return (_has_bits_[0] & 0x02000000u) != 0;
+}
+inline void SolverParameter::set_has_clip_gradients() {
+ _has_bits_[0] |= 0x02000000u;
+}
+inline void SolverParameter::clear_has_clip_gradients() {
+ _has_bits_[0] &= ~0x02000000u;
+}
+inline void SolverParameter::clear_clip_gradients() {
+ clip_gradients_ = -1;
+ clear_has_clip_gradients();
+}
+inline float SolverParameter::clip_gradients() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.clip_gradients)
+ return clip_gradients_;
+}
+inline void SolverParameter::set_clip_gradients(float value) {
+ set_has_clip_gradients();
+ clip_gradients_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.clip_gradients)
+}
+
+// optional int32 snapshot = 14 [default = 0];
+inline bool SolverParameter::has_snapshot() const {
+ return (_has_bits_[0] & 0x04000000u) != 0;
+}
+inline void SolverParameter::set_has_snapshot() {
+ _has_bits_[0] |= 0x04000000u;
+}
+inline void SolverParameter::clear_has_snapshot() {
+ _has_bits_[0] &= ~0x04000000u;
+}
+inline void SolverParameter::clear_snapshot() {
+ snapshot_ = 0;
+ clear_has_snapshot();
+}
+inline ::google::protobuf::int32 SolverParameter::snapshot() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot)
+ return snapshot_;
+}
+inline void SolverParameter::set_snapshot(::google::protobuf::int32 value) {
+ set_has_snapshot();
+ snapshot_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot)
+}
+
+// optional string snapshot_prefix = 15;
+inline bool SolverParameter::has_snapshot_prefix() const {
+ return (_has_bits_[0] & 0x08000000u) != 0;
+}
+inline void SolverParameter::set_has_snapshot_prefix() {
+ _has_bits_[0] |= 0x08000000u;
+}
+inline void SolverParameter::clear_has_snapshot_prefix() {
+ _has_bits_[0] &= ~0x08000000u;
+}
+inline void SolverParameter::clear_snapshot_prefix() {
+ snapshot_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_snapshot_prefix();
+}
+inline const ::std::string& SolverParameter::snapshot_prefix() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot_prefix)
+ return snapshot_prefix_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void SolverParameter::set_snapshot_prefix(const ::std::string& value) {
+ set_has_snapshot_prefix();
+ snapshot_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot_prefix)
+}
+inline void SolverParameter::set_snapshot_prefix(const char* value) {
+ set_has_snapshot_prefix();
+ snapshot_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.snapshot_prefix)
+}
+inline void SolverParameter::set_snapshot_prefix(const char* value, size_t size) {
+ set_has_snapshot_prefix();
+ snapshot_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.snapshot_prefix)
+}
+inline ::std::string* SolverParameter::mutable_snapshot_prefix() {
+ set_has_snapshot_prefix();
+ // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.snapshot_prefix)
+ return snapshot_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* SolverParameter::release_snapshot_prefix() {
+ // @@protoc_insertion_point(field_release:caffe.SolverParameter.snapshot_prefix)
+ clear_has_snapshot_prefix();
+ return snapshot_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void SolverParameter::set_allocated_snapshot_prefix(::std::string* snapshot_prefix) {
+ if (snapshot_prefix != NULL) {
+ set_has_snapshot_prefix();
+ } else {
+ clear_has_snapshot_prefix();
+ }
+ snapshot_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), snapshot_prefix);
+ // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.snapshot_prefix)
+}
+
+// optional bool snapshot_diff = 16 [default = false];
+inline bool SolverParameter::has_snapshot_diff() const {
+ return (_has_bits_[0] & 0x10000000u) != 0;
+}
+inline void SolverParameter::set_has_snapshot_diff() {
+ _has_bits_[0] |= 0x10000000u;
+}
+inline void SolverParameter::clear_has_snapshot_diff() {
+ _has_bits_[0] &= ~0x10000000u;
+}
+inline void SolverParameter::clear_snapshot_diff() {
+ snapshot_diff_ = false;
+ clear_has_snapshot_diff();
+}
+inline bool SolverParameter::snapshot_diff() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot_diff)
+ return snapshot_diff_;
+}
+inline void SolverParameter::set_snapshot_diff(bool value) {
+ set_has_snapshot_diff();
+ snapshot_diff_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot_diff)
+}
+
+// optional .caffe.SolverParameter.SnapshotFormat snapshot_format = 37 [default = BINARYPROTO];
+inline bool SolverParameter::has_snapshot_format() const {
+ return (_has_bits_[0] & 0x20000000u) != 0;
+}
+inline void SolverParameter::set_has_snapshot_format() {
+ _has_bits_[0] |= 0x20000000u;
+}
+inline void SolverParameter::clear_has_snapshot_format() {
+ _has_bits_[0] &= ~0x20000000u;
+}
+inline void SolverParameter::clear_snapshot_format() {
+ snapshot_format_ = 1;
+ clear_has_snapshot_format();
+}
+inline ::caffe::SolverParameter_SnapshotFormat SolverParameter::snapshot_format() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot_format)
+ return static_cast< ::caffe::SolverParameter_SnapshotFormat >(snapshot_format_);
+}
+inline void SolverParameter::set_snapshot_format(::caffe::SolverParameter_SnapshotFormat value) {
+ assert(::caffe::SolverParameter_SnapshotFormat_IsValid(value));
+ set_has_snapshot_format();
+ snapshot_format_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot_format)
+}
+
+// optional .caffe.SolverParameter.SolverMode solver_mode = 17 [default = GPU];
+inline bool SolverParameter::has_solver_mode() const {
+ return (_has_bits_[0] & 0x40000000u) != 0;
+}
+inline void SolverParameter::set_has_solver_mode() {
+ _has_bits_[0] |= 0x40000000u;
+}
+inline void SolverParameter::clear_has_solver_mode() {
+ _has_bits_[0] &= ~0x40000000u;
+}
+inline void SolverParameter::clear_solver_mode() {
+ solver_mode_ = 1;
+ clear_has_solver_mode();
+}
+inline ::caffe::SolverParameter_SolverMode SolverParameter::solver_mode() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.solver_mode)
+ return static_cast< ::caffe::SolverParameter_SolverMode >(solver_mode_);
+}
+inline void SolverParameter::set_solver_mode(::caffe::SolverParameter_SolverMode value) {
+ assert(::caffe::SolverParameter_SolverMode_IsValid(value));
+ set_has_solver_mode();
+ solver_mode_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.solver_mode)
+}
+
+// optional int32 device_id = 18 [default = 0];
+inline bool SolverParameter::has_device_id() const {
+ return (_has_bits_[0] & 0x80000000u) != 0;
+}
+inline void SolverParameter::set_has_device_id() {
+ _has_bits_[0] |= 0x80000000u;
+}
+inline void SolverParameter::clear_has_device_id() {
+ _has_bits_[0] &= ~0x80000000u;
+}
+inline void SolverParameter::clear_device_id() {
+ device_id_ = 0;
+ clear_has_device_id();
+}
+inline ::google::protobuf::int32 SolverParameter::device_id() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.device_id)
+ return device_id_;
+}
+inline void SolverParameter::set_device_id(::google::protobuf::int32 value) {
+ set_has_device_id();
+ device_id_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.device_id)
+}
+
+// optional int64 random_seed = 20 [default = -1];
+inline bool SolverParameter::has_random_seed() const {
+ return (_has_bits_[1] & 0x00000001u) != 0;
+}
+inline void SolverParameter::set_has_random_seed() {
+ _has_bits_[1] |= 0x00000001u;
+}
+inline void SolverParameter::clear_has_random_seed() {
+ _has_bits_[1] &= ~0x00000001u;
+}
+inline void SolverParameter::clear_random_seed() {
+ random_seed_ = GOOGLE_LONGLONG(-1);
+ clear_has_random_seed();
+}
+inline ::google::protobuf::int64 SolverParameter::random_seed() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.random_seed)
+ return random_seed_;
+}
+inline void SolverParameter::set_random_seed(::google::protobuf::int64 value) {
+ set_has_random_seed();
+ random_seed_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.random_seed)
+}
+
+// optional string type = 40 [default = "SGD"];
+inline bool SolverParameter::has_type() const {
+ return (_has_bits_[1] & 0x00000002u) != 0;
+}
+inline void SolverParameter::set_has_type() {
+ _has_bits_[1] |= 0x00000002u;
+}
+inline void SolverParameter::clear_has_type() {
+ _has_bits_[1] &= ~0x00000002u;
+}
+inline void SolverParameter::clear_type() {
+ type_.ClearToDefaultNoArena(_default_type_);
+ clear_has_type();
+}
+inline const ::std::string& SolverParameter::type() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.type)
+ return type_.GetNoArena(_default_type_);
+}
+inline void SolverParameter::set_type(const ::std::string& value) {
+ set_has_type();
+ type_.SetNoArena(_default_type_, value);
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.type)
+}
+inline void SolverParameter::set_type(const char* value) {
+ set_has_type();
+ type_.SetNoArena(_default_type_, ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.SolverParameter.type)
+}
+inline void SolverParameter::set_type(const char* value, size_t size) {
+ set_has_type();
+ type_.SetNoArena(_default_type_,
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.SolverParameter.type)
+}
+inline ::std::string* SolverParameter::mutable_type() {
+ set_has_type();
+ // @@protoc_insertion_point(field_mutable:caffe.SolverParameter.type)
+ return type_.MutableNoArena(_default_type_);
+}
+inline ::std::string* SolverParameter::release_type() {
+ // @@protoc_insertion_point(field_release:caffe.SolverParameter.type)
+ clear_has_type();
+ return type_.ReleaseNoArena(_default_type_);
+}
+inline void SolverParameter::set_allocated_type(::std::string* type) {
+ if (type != NULL) {
+ set_has_type();
+ } else {
+ clear_has_type();
+ }
+ type_.SetAllocatedNoArena(_default_type_, type);
+ // @@protoc_insertion_point(field_set_allocated:caffe.SolverParameter.type)
+}
+
+// optional float delta = 31 [default = 1e-08];
+inline bool SolverParameter::has_delta() const {
+ return (_has_bits_[1] & 0x00000004u) != 0;
+}
+inline void SolverParameter::set_has_delta() {
+ _has_bits_[1] |= 0x00000004u;
+}
+inline void SolverParameter::clear_has_delta() {
+ _has_bits_[1] &= ~0x00000004u;
+}
+inline void SolverParameter::clear_delta() {
+ delta_ = 1e-08f;
+ clear_has_delta();
+}
+inline float SolverParameter::delta() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.delta)
+ return delta_;
+}
+inline void SolverParameter::set_delta(float value) {
+ set_has_delta();
+ delta_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.delta)
+}
+
+// optional float momentum2 = 39 [default = 0.999];
+inline bool SolverParameter::has_momentum2() const {
+ return (_has_bits_[1] & 0x00000008u) != 0;
+}
+inline void SolverParameter::set_has_momentum2() {
+ _has_bits_[1] |= 0x00000008u;
+}
+inline void SolverParameter::clear_has_momentum2() {
+ _has_bits_[1] &= ~0x00000008u;
+}
+inline void SolverParameter::clear_momentum2() {
+ momentum2_ = 0.999f;
+ clear_has_momentum2();
+}
+inline float SolverParameter::momentum2() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.momentum2)
+ return momentum2_;
+}
+inline void SolverParameter::set_momentum2(float value) {
+ set_has_momentum2();
+ momentum2_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.momentum2)
+}
+
+// optional float rms_decay = 38 [default = 0.99];
+inline bool SolverParameter::has_rms_decay() const {
+ return (_has_bits_[1] & 0x00000010u) != 0;
+}
+inline void SolverParameter::set_has_rms_decay() {
+ _has_bits_[1] |= 0x00000010u;
+}
+inline void SolverParameter::clear_has_rms_decay() {
+ _has_bits_[1] &= ~0x00000010u;
+}
+inline void SolverParameter::clear_rms_decay() {
+ rms_decay_ = 0.99f;
+ clear_has_rms_decay();
+}
+inline float SolverParameter::rms_decay() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.rms_decay)
+ return rms_decay_;
+}
+inline void SolverParameter::set_rms_decay(float value) {
+ set_has_rms_decay();
+ rms_decay_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.rms_decay)
+}
+
+// optional bool debug_info = 23 [default = false];
+inline bool SolverParameter::has_debug_info() const {
+ return (_has_bits_[1] & 0x00000020u) != 0;
+}
+inline void SolverParameter::set_has_debug_info() {
+ _has_bits_[1] |= 0x00000020u;
+}
+inline void SolverParameter::clear_has_debug_info() {
+ _has_bits_[1] &= ~0x00000020u;
+}
+inline void SolverParameter::clear_debug_info() {
+ debug_info_ = false;
+ clear_has_debug_info();
+}
+inline bool SolverParameter::debug_info() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.debug_info)
+ return debug_info_;
+}
+inline void SolverParameter::set_debug_info(bool value) {
+ set_has_debug_info();
+ debug_info_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.debug_info)
+}
+
+// optional bool snapshot_after_train = 28 [default = true];
+inline bool SolverParameter::has_snapshot_after_train() const {
+ return (_has_bits_[1] & 0x00000040u) != 0;
+}
+inline void SolverParameter::set_has_snapshot_after_train() {
+ _has_bits_[1] |= 0x00000040u;
+}
+inline void SolverParameter::clear_has_snapshot_after_train() {
+ _has_bits_[1] &= ~0x00000040u;
+}
+inline void SolverParameter::clear_snapshot_after_train() {
+ snapshot_after_train_ = true;
+ clear_has_snapshot_after_train();
+}
+inline bool SolverParameter::snapshot_after_train() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.snapshot_after_train)
+ return snapshot_after_train_;
+}
+inline void SolverParameter::set_snapshot_after_train(bool value) {
+ set_has_snapshot_after_train();
+ snapshot_after_train_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.snapshot_after_train)
+}
+
+// optional .caffe.SolverParameter.SolverType solver_type = 30 [default = SGD];
+inline bool SolverParameter::has_solver_type() const {
+ return (_has_bits_[1] & 0x00000080u) != 0;
+}
+inline void SolverParameter::set_has_solver_type() {
+ _has_bits_[1] |= 0x00000080u;
+}
+inline void SolverParameter::clear_has_solver_type() {
+ _has_bits_[1] &= ~0x00000080u;
+}
+inline void SolverParameter::clear_solver_type() {
+ solver_type_ = 0;
+ clear_has_solver_type();
+}
+inline ::caffe::SolverParameter_SolverType SolverParameter::solver_type() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverParameter.solver_type)
+ return static_cast< ::caffe::SolverParameter_SolverType >(solver_type_);
+}
+inline void SolverParameter::set_solver_type(::caffe::SolverParameter_SolverType value) {
+ assert(::caffe::SolverParameter_SolverType_IsValid(value));
+ set_has_solver_type();
+ solver_type_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverParameter.solver_type)
+}
+
+inline const SolverParameter* SolverParameter::internal_default_instance() {
+ return &SolverParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// SolverState
+
+// optional int32 iter = 1;
+inline bool SolverState::has_iter() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void SolverState::set_has_iter() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void SolverState::clear_has_iter() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void SolverState::clear_iter() {
+ iter_ = 0;
+ clear_has_iter();
+}
+inline ::google::protobuf::int32 SolverState::iter() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverState.iter)
+ return iter_;
+}
+inline void SolverState::set_iter(::google::protobuf::int32 value) {
+ set_has_iter();
+ iter_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverState.iter)
+}
+
+// optional string learned_net = 2;
+inline bool SolverState::has_learned_net() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void SolverState::set_has_learned_net() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void SolverState::clear_has_learned_net() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void SolverState::clear_learned_net() {
+ learned_net_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_learned_net();
+}
+inline const ::std::string& SolverState::learned_net() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverState.learned_net)
+ return learned_net_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void SolverState::set_learned_net(const ::std::string& value) {
+ set_has_learned_net();
+ learned_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.SolverState.learned_net)
+}
+inline void SolverState::set_learned_net(const char* value) {
+ set_has_learned_net();
+ learned_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.SolverState.learned_net)
+}
+inline void SolverState::set_learned_net(const char* value, size_t size) {
+ set_has_learned_net();
+ learned_net_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.SolverState.learned_net)
+}
+inline ::std::string* SolverState::mutable_learned_net() {
+ set_has_learned_net();
+ // @@protoc_insertion_point(field_mutable:caffe.SolverState.learned_net)
+ return learned_net_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* SolverState::release_learned_net() {
+ // @@protoc_insertion_point(field_release:caffe.SolverState.learned_net)
+ clear_has_learned_net();
+ return learned_net_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void SolverState::set_allocated_learned_net(::std::string* learned_net) {
+ if (learned_net != NULL) {
+ set_has_learned_net();
+ } else {
+ clear_has_learned_net();
+ }
+ learned_net_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), learned_net);
+ // @@protoc_insertion_point(field_set_allocated:caffe.SolverState.learned_net)
+}
+
+// repeated .caffe.BlobProto history = 3;
+inline int SolverState::history_size() const {
+ return history_.size();
+}
+inline void SolverState::clear_history() {
+ history_.Clear();
+}
+inline const ::caffe::BlobProto& SolverState::history(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.SolverState.history)
+ return history_.Get(index);
+}
+inline ::caffe::BlobProto* SolverState::mutable_history(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.SolverState.history)
+ return history_.Mutable(index);
+}
+inline ::caffe::BlobProto* SolverState::add_history() {
+ // @@protoc_insertion_point(field_add:caffe.SolverState.history)
+ return history_.Add();
+}
+inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
+SolverState::mutable_history() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.SolverState.history)
+ return &history_;
+}
+inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
+SolverState::history() const {
+ // @@protoc_insertion_point(field_list:caffe.SolverState.history)
+ return history_;
+}
+
+// optional int32 current_step = 4 [default = 0];
+inline bool SolverState::has_current_step() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void SolverState::set_has_current_step() {
+ _has_bits_[0] |= 0x00000008u;
+}
+inline void SolverState::clear_has_current_step() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+inline void SolverState::clear_current_step() {
+ current_step_ = 0;
+ clear_has_current_step();
+}
+inline ::google::protobuf::int32 SolverState::current_step() const {
+ // @@protoc_insertion_point(field_get:caffe.SolverState.current_step)
+ return current_step_;
+}
+inline void SolverState::set_current_step(::google::protobuf::int32 value) {
+ set_has_current_step();
+ current_step_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SolverState.current_step)
+}
+
+inline const SolverState* SolverState::internal_default_instance() {
+ return &SolverState_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// NetState
+
+// optional .caffe.Phase phase = 1 [default = TEST];
+inline bool NetState::has_phase() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void NetState::set_has_phase() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void NetState::clear_has_phase() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void NetState::clear_phase() {
+ phase_ = 1;
+ clear_has_phase();
+}
+inline ::caffe::Phase NetState::phase() const {
+ // @@protoc_insertion_point(field_get:caffe.NetState.phase)
+ return static_cast< ::caffe::Phase >(phase_);
+}
+inline void NetState::set_phase(::caffe::Phase value) {
+ assert(::caffe::Phase_IsValid(value));
+ set_has_phase();
+ phase_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NetState.phase)
+}
+
+// optional int32 level = 2 [default = 0];
+inline bool NetState::has_level() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void NetState::set_has_level() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void NetState::clear_has_level() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void NetState::clear_level() {
+ level_ = 0;
+ clear_has_level();
+}
+inline ::google::protobuf::int32 NetState::level() const {
+ // @@protoc_insertion_point(field_get:caffe.NetState.level)
+ return level_;
+}
+inline void NetState::set_level(::google::protobuf::int32 value) {
+ set_has_level();
+ level_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NetState.level)
+}
+
+// repeated string stage = 3;
+inline int NetState::stage_size() const {
+ return stage_.size();
+}
+inline void NetState::clear_stage() {
+ stage_.Clear();
+}
+inline const ::std::string& NetState::stage(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.NetState.stage)
+ return stage_.Get(index);
+}
+inline ::std::string* NetState::mutable_stage(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.NetState.stage)
+ return stage_.Mutable(index);
+}
+inline void NetState::set_stage(int index, const ::std::string& value) {
+ // @@protoc_insertion_point(field_set:caffe.NetState.stage)
+ stage_.Mutable(index)->assign(value);
+}
+inline void NetState::set_stage(int index, const char* value) {
+ stage_.Mutable(index)->assign(value);
+ // @@protoc_insertion_point(field_set_char:caffe.NetState.stage)
+}
+inline void NetState::set_stage(int index, const char* value, size_t size) {
+ stage_.Mutable(index)->assign(
+ reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_set_pointer:caffe.NetState.stage)
+}
+inline ::std::string* NetState::add_stage() {
+ // @@protoc_insertion_point(field_add_mutable:caffe.NetState.stage)
+ return stage_.Add();
+}
+inline void NetState::add_stage(const ::std::string& value) {
+ stage_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add:caffe.NetState.stage)
+}
+inline void NetState::add_stage(const char* value) {
+ stage_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add_char:caffe.NetState.stage)
+}
+inline void NetState::add_stage(const char* value, size_t size) {
+ stage_.Add()->assign(reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_add_pointer:caffe.NetState.stage)
+}
+inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
+NetState::stage() const {
+ // @@protoc_insertion_point(field_list:caffe.NetState.stage)
+ return stage_;
+}
+inline ::google::protobuf::RepeatedPtrField< ::std::string>*
+NetState::mutable_stage() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.NetState.stage)
+ return &stage_;
+}
+
+inline const NetState* NetState::internal_default_instance() {
+ return &NetState_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// NetStateRule
+
+// optional .caffe.Phase phase = 1;
+inline bool NetStateRule::has_phase() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void NetStateRule::set_has_phase() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void NetStateRule::clear_has_phase() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void NetStateRule::clear_phase() {
+ phase_ = 0;
+ clear_has_phase();
+}
+inline ::caffe::Phase NetStateRule::phase() const {
+ // @@protoc_insertion_point(field_get:caffe.NetStateRule.phase)
+ return static_cast< ::caffe::Phase >(phase_);
+}
+inline void NetStateRule::set_phase(::caffe::Phase value) {
+ assert(::caffe::Phase_IsValid(value));
+ set_has_phase();
+ phase_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NetStateRule.phase)
+}
+
+// optional int32 min_level = 2;
+inline bool NetStateRule::has_min_level() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void NetStateRule::set_has_min_level() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void NetStateRule::clear_has_min_level() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void NetStateRule::clear_min_level() {
+ min_level_ = 0;
+ clear_has_min_level();
+}
+inline ::google::protobuf::int32 NetStateRule::min_level() const {
+ // @@protoc_insertion_point(field_get:caffe.NetStateRule.min_level)
+ return min_level_;
+}
+inline void NetStateRule::set_min_level(::google::protobuf::int32 value) {
+ set_has_min_level();
+ min_level_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NetStateRule.min_level)
+}
+
+// optional int32 max_level = 3;
+inline bool NetStateRule::has_max_level() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void NetStateRule::set_has_max_level() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void NetStateRule::clear_has_max_level() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void NetStateRule::clear_max_level() {
+ max_level_ = 0;
+ clear_has_max_level();
+}
+inline ::google::protobuf::int32 NetStateRule::max_level() const {
+ // @@protoc_insertion_point(field_get:caffe.NetStateRule.max_level)
+ return max_level_;
+}
+inline void NetStateRule::set_max_level(::google::protobuf::int32 value) {
+ set_has_max_level();
+ max_level_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NetStateRule.max_level)
+}
+
+// repeated string stage = 4;
+inline int NetStateRule::stage_size() const {
+ return stage_.size();
+}
+inline void NetStateRule::clear_stage() {
+ stage_.Clear();
+}
+inline const ::std::string& NetStateRule::stage(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.NetStateRule.stage)
+ return stage_.Get(index);
+}
+inline ::std::string* NetStateRule::mutable_stage(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.NetStateRule.stage)
+ return stage_.Mutable(index);
+}
+inline void NetStateRule::set_stage(int index, const ::std::string& value) {
+ // @@protoc_insertion_point(field_set:caffe.NetStateRule.stage)
+ stage_.Mutable(index)->assign(value);
+}
+inline void NetStateRule::set_stage(int index, const char* value) {
+ stage_.Mutable(index)->assign(value);
+ // @@protoc_insertion_point(field_set_char:caffe.NetStateRule.stage)
+}
+inline void NetStateRule::set_stage(int index, const char* value, size_t size) {
+ stage_.Mutable(index)->assign(
+ reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_set_pointer:caffe.NetStateRule.stage)
+}
+inline ::std::string* NetStateRule::add_stage() {
+ // @@protoc_insertion_point(field_add_mutable:caffe.NetStateRule.stage)
+ return stage_.Add();
+}
+inline void NetStateRule::add_stage(const ::std::string& value) {
+ stage_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add:caffe.NetStateRule.stage)
+}
+inline void NetStateRule::add_stage(const char* value) {
+ stage_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add_char:caffe.NetStateRule.stage)
+}
+inline void NetStateRule::add_stage(const char* value, size_t size) {
+ stage_.Add()->assign(reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_add_pointer:caffe.NetStateRule.stage)
+}
+inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
+NetStateRule::stage() const {
+ // @@protoc_insertion_point(field_list:caffe.NetStateRule.stage)
+ return stage_;
+}
+inline ::google::protobuf::RepeatedPtrField< ::std::string>*
+NetStateRule::mutable_stage() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.NetStateRule.stage)
+ return &stage_;
+}
+
+// repeated string not_stage = 5;
+inline int NetStateRule::not_stage_size() const {
+ return not_stage_.size();
+}
+inline void NetStateRule::clear_not_stage() {
+ not_stage_.Clear();
+}
+inline const ::std::string& NetStateRule::not_stage(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.NetStateRule.not_stage)
+ return not_stage_.Get(index);
+}
+inline ::std::string* NetStateRule::mutable_not_stage(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.NetStateRule.not_stage)
+ return not_stage_.Mutable(index);
+}
+inline void NetStateRule::set_not_stage(int index, const ::std::string& value) {
+ // @@protoc_insertion_point(field_set:caffe.NetStateRule.not_stage)
+ not_stage_.Mutable(index)->assign(value);
+}
+inline void NetStateRule::set_not_stage(int index, const char* value) {
+ not_stage_.Mutable(index)->assign(value);
+ // @@protoc_insertion_point(field_set_char:caffe.NetStateRule.not_stage)
+}
+inline void NetStateRule::set_not_stage(int index, const char* value, size_t size) {
+ not_stage_.Mutable(index)->assign(
+ reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_set_pointer:caffe.NetStateRule.not_stage)
+}
+inline ::std::string* NetStateRule::add_not_stage() {
+ // @@protoc_insertion_point(field_add_mutable:caffe.NetStateRule.not_stage)
+ return not_stage_.Add();
+}
+inline void NetStateRule::add_not_stage(const ::std::string& value) {
+ not_stage_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add:caffe.NetStateRule.not_stage)
+}
+inline void NetStateRule::add_not_stage(const char* value) {
+ not_stage_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add_char:caffe.NetStateRule.not_stage)
+}
+inline void NetStateRule::add_not_stage(const char* value, size_t size) {
+ not_stage_.Add()->assign(reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_add_pointer:caffe.NetStateRule.not_stage)
+}
+inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
+NetStateRule::not_stage() const {
+ // @@protoc_insertion_point(field_list:caffe.NetStateRule.not_stage)
+ return not_stage_;
+}
+inline ::google::protobuf::RepeatedPtrField< ::std::string>*
+NetStateRule::mutable_not_stage() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.NetStateRule.not_stage)
+ return ¬_stage_;
+}
+
+inline const NetStateRule* NetStateRule::internal_default_instance() {
+ return &NetStateRule_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// ParamSpec
+
+// optional string name = 1;
+inline bool ParamSpec::has_name() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void ParamSpec::set_has_name() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void ParamSpec::clear_has_name() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void ParamSpec::clear_name() {
+ name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_name();
+}
+inline const ::std::string& ParamSpec::name() const {
+ // @@protoc_insertion_point(field_get:caffe.ParamSpec.name)
+ return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void ParamSpec::set_name(const ::std::string& value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.ParamSpec.name)
+}
+inline void ParamSpec::set_name(const char* value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.ParamSpec.name)
+}
+inline void ParamSpec::set_name(const char* value, size_t size) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.ParamSpec.name)
+}
+inline ::std::string* ParamSpec::mutable_name() {
+ set_has_name();
+ // @@protoc_insertion_point(field_mutable:caffe.ParamSpec.name)
+ return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* ParamSpec::release_name() {
+ // @@protoc_insertion_point(field_release:caffe.ParamSpec.name)
+ clear_has_name();
+ return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void ParamSpec::set_allocated_name(::std::string* name) {
+ if (name != NULL) {
+ set_has_name();
+ } else {
+ clear_has_name();
+ }
+ name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
+ // @@protoc_insertion_point(field_set_allocated:caffe.ParamSpec.name)
+}
+
+// optional .caffe.ParamSpec.DimCheckMode share_mode = 2;
+inline bool ParamSpec::has_share_mode() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void ParamSpec::set_has_share_mode() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void ParamSpec::clear_has_share_mode() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void ParamSpec::clear_share_mode() {
+ share_mode_ = 0;
+ clear_has_share_mode();
+}
+inline ::caffe::ParamSpec_DimCheckMode ParamSpec::share_mode() const {
+ // @@protoc_insertion_point(field_get:caffe.ParamSpec.share_mode)
+ return static_cast< ::caffe::ParamSpec_DimCheckMode >(share_mode_);
+}
+inline void ParamSpec::set_share_mode(::caffe::ParamSpec_DimCheckMode value) {
+ assert(::caffe::ParamSpec_DimCheckMode_IsValid(value));
+ set_has_share_mode();
+ share_mode_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ParamSpec.share_mode)
+}
+
+// optional float lr_mult = 3 [default = 1];
+inline bool ParamSpec::has_lr_mult() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void ParamSpec::set_has_lr_mult() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void ParamSpec::clear_has_lr_mult() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void ParamSpec::clear_lr_mult() {
+ lr_mult_ = 1;
+ clear_has_lr_mult();
+}
+inline float ParamSpec::lr_mult() const {
+ // @@protoc_insertion_point(field_get:caffe.ParamSpec.lr_mult)
+ return lr_mult_;
+}
+inline void ParamSpec::set_lr_mult(float value) {
+ set_has_lr_mult();
+ lr_mult_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ParamSpec.lr_mult)
+}
+
+// optional float decay_mult = 4 [default = 1];
+inline bool ParamSpec::has_decay_mult() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void ParamSpec::set_has_decay_mult() {
+ _has_bits_[0] |= 0x00000008u;
+}
+inline void ParamSpec::clear_has_decay_mult() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+inline void ParamSpec::clear_decay_mult() {
+ decay_mult_ = 1;
+ clear_has_decay_mult();
+}
+inline float ParamSpec::decay_mult() const {
+ // @@protoc_insertion_point(field_get:caffe.ParamSpec.decay_mult)
+ return decay_mult_;
+}
+inline void ParamSpec::set_decay_mult(float value) {
+ set_has_decay_mult();
+ decay_mult_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ParamSpec.decay_mult)
+}
+
+inline const ParamSpec* ParamSpec::internal_default_instance() {
+ return &ParamSpec_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// LayerParameter
+
+// optional string name = 1;
+inline bool LayerParameter::has_name() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void LayerParameter::set_has_name() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void LayerParameter::clear_has_name() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void LayerParameter::clear_name() {
+ name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_name();
+}
+inline const ::std::string& LayerParameter::name() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.name)
+ return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void LayerParameter::set_name(const ::std::string& value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.LayerParameter.name)
+}
+inline void LayerParameter::set_name(const char* value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.LayerParameter.name)
+}
+inline void LayerParameter::set_name(const char* value, size_t size) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.LayerParameter.name)
+}
+inline ::std::string* LayerParameter::mutable_name() {
+ set_has_name();
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.name)
+ return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* LayerParameter::release_name() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.name)
+ clear_has_name();
+ return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void LayerParameter::set_allocated_name(::std::string* name) {
+ if (name != NULL) {
+ set_has_name();
+ } else {
+ clear_has_name();
+ }
+ name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.name)
+}
+
+// optional string type = 2;
+inline bool LayerParameter::has_type() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void LayerParameter::set_has_type() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void LayerParameter::clear_has_type() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void LayerParameter::clear_type() {
+ type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_type();
+}
+inline const ::std::string& LayerParameter::type() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.type)
+ return type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void LayerParameter::set_type(const ::std::string& value) {
+ set_has_type();
+ type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.LayerParameter.type)
+}
+inline void LayerParameter::set_type(const char* value) {
+ set_has_type();
+ type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.LayerParameter.type)
+}
+inline void LayerParameter::set_type(const char* value, size_t size) {
+ set_has_type();
+ type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.LayerParameter.type)
+}
+inline ::std::string* LayerParameter::mutable_type() {
+ set_has_type();
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.type)
+ return type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* LayerParameter::release_type() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.type)
+ clear_has_type();
+ return type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void LayerParameter::set_allocated_type(::std::string* type) {
+ if (type != NULL) {
+ set_has_type();
+ } else {
+ clear_has_type();
+ }
+ type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type);
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.type)
+}
+
+// repeated string bottom = 3;
+inline int LayerParameter::bottom_size() const {
+ return bottom_.size();
+}
+inline void LayerParameter::clear_bottom() {
+ bottom_.Clear();
+}
+inline const ::std::string& LayerParameter::bottom(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.bottom)
+ return bottom_.Get(index);
+}
+inline ::std::string* LayerParameter::mutable_bottom(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.bottom)
+ return bottom_.Mutable(index);
+}
+inline void LayerParameter::set_bottom(int index, const ::std::string& value) {
+ // @@protoc_insertion_point(field_set:caffe.LayerParameter.bottom)
+ bottom_.Mutable(index)->assign(value);
+}
+inline void LayerParameter::set_bottom(int index, const char* value) {
+ bottom_.Mutable(index)->assign(value);
+ // @@protoc_insertion_point(field_set_char:caffe.LayerParameter.bottom)
+}
+inline void LayerParameter::set_bottom(int index, const char* value, size_t size) {
+ bottom_.Mutable(index)->assign(
+ reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_set_pointer:caffe.LayerParameter.bottom)
+}
+inline ::std::string* LayerParameter::add_bottom() {
+ // @@protoc_insertion_point(field_add_mutable:caffe.LayerParameter.bottom)
+ return bottom_.Add();
+}
+inline void LayerParameter::add_bottom(const ::std::string& value) {
+ bottom_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add:caffe.LayerParameter.bottom)
+}
+inline void LayerParameter::add_bottom(const char* value) {
+ bottom_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add_char:caffe.LayerParameter.bottom)
+}
+inline void LayerParameter::add_bottom(const char* value, size_t size) {
+ bottom_.Add()->assign(reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_add_pointer:caffe.LayerParameter.bottom)
+}
+inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
+LayerParameter::bottom() const {
+ // @@protoc_insertion_point(field_list:caffe.LayerParameter.bottom)
+ return bottom_;
+}
+inline ::google::protobuf::RepeatedPtrField< ::std::string>*
+LayerParameter::mutable_bottom() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.bottom)
+ return &bottom_;
+}
+
+// repeated string top = 4;
+inline int LayerParameter::top_size() const {
+ return top_.size();
+}
+inline void LayerParameter::clear_top() {
+ top_.Clear();
+}
+inline const ::std::string& LayerParameter::top(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.top)
+ return top_.Get(index);
+}
+inline ::std::string* LayerParameter::mutable_top(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.top)
+ return top_.Mutable(index);
+}
+inline void LayerParameter::set_top(int index, const ::std::string& value) {
+ // @@protoc_insertion_point(field_set:caffe.LayerParameter.top)
+ top_.Mutable(index)->assign(value);
+}
+inline void LayerParameter::set_top(int index, const char* value) {
+ top_.Mutable(index)->assign(value);
+ // @@protoc_insertion_point(field_set_char:caffe.LayerParameter.top)
+}
+inline void LayerParameter::set_top(int index, const char* value, size_t size) {
+ top_.Mutable(index)->assign(
+ reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_set_pointer:caffe.LayerParameter.top)
+}
+inline ::std::string* LayerParameter::add_top() {
+ // @@protoc_insertion_point(field_add_mutable:caffe.LayerParameter.top)
+ return top_.Add();
+}
+inline void LayerParameter::add_top(const ::std::string& value) {
+ top_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add:caffe.LayerParameter.top)
+}
+inline void LayerParameter::add_top(const char* value) {
+ top_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add_char:caffe.LayerParameter.top)
+}
+inline void LayerParameter::add_top(const char* value, size_t size) {
+ top_.Add()->assign(reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_add_pointer:caffe.LayerParameter.top)
+}
+inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
+LayerParameter::top() const {
+ // @@protoc_insertion_point(field_list:caffe.LayerParameter.top)
+ return top_;
+}
+inline ::google::protobuf::RepeatedPtrField< ::std::string>*
+LayerParameter::mutable_top() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.top)
+ return &top_;
+}
+
+// optional .caffe.Phase phase = 10;
+inline bool LayerParameter::has_phase() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+inline void LayerParameter::set_has_phase() {
+ _has_bits_[0] |= 0x00000010u;
+}
+inline void LayerParameter::clear_has_phase() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+inline void LayerParameter::clear_phase() {
+ phase_ = 0;
+ clear_has_phase();
+}
+inline ::caffe::Phase LayerParameter::phase() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.phase)
+ return static_cast< ::caffe::Phase >(phase_);
+}
+inline void LayerParameter::set_phase(::caffe::Phase value) {
+ assert(::caffe::Phase_IsValid(value));
+ set_has_phase();
+ phase_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LayerParameter.phase)
+}
+
+// repeated float loss_weight = 5;
+inline int LayerParameter::loss_weight_size() const {
+ return loss_weight_.size();
+}
+inline void LayerParameter::clear_loss_weight() {
+ loss_weight_.Clear();
+}
+inline float LayerParameter::loss_weight(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.loss_weight)
+ return loss_weight_.Get(index);
+}
+inline void LayerParameter::set_loss_weight(int index, float value) {
+ loss_weight_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.LayerParameter.loss_weight)
+}
+inline void LayerParameter::add_loss_weight(float value) {
+ loss_weight_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.LayerParameter.loss_weight)
+}
+inline const ::google::protobuf::RepeatedField< float >&
+LayerParameter::loss_weight() const {
+ // @@protoc_insertion_point(field_list:caffe.LayerParameter.loss_weight)
+ return loss_weight_;
+}
+inline ::google::protobuf::RepeatedField< float >*
+LayerParameter::mutable_loss_weight() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.loss_weight)
+ return &loss_weight_;
+}
+
+// repeated .caffe.ParamSpec param = 6;
+inline int LayerParameter::param_size() const {
+ return param_.size();
+}
+inline void LayerParameter::clear_param() {
+ param_.Clear();
+}
+inline const ::caffe::ParamSpec& LayerParameter::param(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.param)
+ return param_.Get(index);
+}
+inline ::caffe::ParamSpec* LayerParameter::mutable_param(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.param)
+ return param_.Mutable(index);
+}
+inline ::caffe::ParamSpec* LayerParameter::add_param() {
+ // @@protoc_insertion_point(field_add:caffe.LayerParameter.param)
+ return param_.Add();
+}
+inline ::google::protobuf::RepeatedPtrField< ::caffe::ParamSpec >*
+LayerParameter::mutable_param() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.param)
+ return ¶m_;
+}
+inline const ::google::protobuf::RepeatedPtrField< ::caffe::ParamSpec >&
+LayerParameter::param() const {
+ // @@protoc_insertion_point(field_list:caffe.LayerParameter.param)
+ return param_;
+}
+
+// repeated .caffe.BlobProto blobs = 7;
+inline int LayerParameter::blobs_size() const {
+ return blobs_.size();
+}
+inline void LayerParameter::clear_blobs() {
+ blobs_.Clear();
+}
+inline const ::caffe::BlobProto& LayerParameter::blobs(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.blobs)
+ return blobs_.Get(index);
+}
+inline ::caffe::BlobProto* LayerParameter::mutable_blobs(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.blobs)
+ return blobs_.Mutable(index);
+}
+inline ::caffe::BlobProto* LayerParameter::add_blobs() {
+ // @@protoc_insertion_point(field_add:caffe.LayerParameter.blobs)
+ return blobs_.Add();
+}
+inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
+LayerParameter::mutable_blobs() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.blobs)
+ return &blobs_;
+}
+inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
+LayerParameter::blobs() const {
+ // @@protoc_insertion_point(field_list:caffe.LayerParameter.blobs)
+ return blobs_;
+}
+
+// repeated bool propagate_down = 11;
+inline int LayerParameter::propagate_down_size() const {
+ return propagate_down_.size();
+}
+inline void LayerParameter::clear_propagate_down() {
+ propagate_down_.Clear();
+}
+inline bool LayerParameter::propagate_down(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.propagate_down)
+ return propagate_down_.Get(index);
+}
+inline void LayerParameter::set_propagate_down(int index, bool value) {
+ propagate_down_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.LayerParameter.propagate_down)
+}
+inline void LayerParameter::add_propagate_down(bool value) {
+ propagate_down_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.LayerParameter.propagate_down)
+}
+inline const ::google::protobuf::RepeatedField< bool >&
+LayerParameter::propagate_down() const {
+ // @@protoc_insertion_point(field_list:caffe.LayerParameter.propagate_down)
+ return propagate_down_;
+}
+inline ::google::protobuf::RepeatedField< bool >*
+LayerParameter::mutable_propagate_down() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.propagate_down)
+ return &propagate_down_;
+}
+
+// repeated .caffe.NetStateRule include = 8;
+inline int LayerParameter::include_size() const {
+ return include_.size();
+}
+inline void LayerParameter::clear_include() {
+ include_.Clear();
+}
+inline const ::caffe::NetStateRule& LayerParameter::include(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.include)
+ return include_.Get(index);
+}
+inline ::caffe::NetStateRule* LayerParameter::mutable_include(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.include)
+ return include_.Mutable(index);
+}
+inline ::caffe::NetStateRule* LayerParameter::add_include() {
+ // @@protoc_insertion_point(field_add:caffe.LayerParameter.include)
+ return include_.Add();
+}
+inline ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >*
+LayerParameter::mutable_include() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.include)
+ return &include_;
+}
+inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >&
+LayerParameter::include() const {
+ // @@protoc_insertion_point(field_list:caffe.LayerParameter.include)
+ return include_;
+}
+
+// repeated .caffe.NetStateRule exclude = 9;
+inline int LayerParameter::exclude_size() const {
+ return exclude_.size();
+}
+inline void LayerParameter::clear_exclude() {
+ exclude_.Clear();
+}
+inline const ::caffe::NetStateRule& LayerParameter::exclude(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.exclude)
+ return exclude_.Get(index);
+}
+inline ::caffe::NetStateRule* LayerParameter::mutable_exclude(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.exclude)
+ return exclude_.Mutable(index);
+}
+inline ::caffe::NetStateRule* LayerParameter::add_exclude() {
+ // @@protoc_insertion_point(field_add:caffe.LayerParameter.exclude)
+ return exclude_.Add();
+}
+inline ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >*
+LayerParameter::mutable_exclude() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.LayerParameter.exclude)
+ return &exclude_;
+}
+inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >&
+LayerParameter::exclude() const {
+ // @@protoc_insertion_point(field_list:caffe.LayerParameter.exclude)
+ return exclude_;
+}
+
+// optional .caffe.TransformationParameter transform_param = 100;
+inline bool LayerParameter::has_transform_param() const {
+ return (_has_bits_[0] & 0x00000800u) != 0;
+}
+inline void LayerParameter::set_has_transform_param() {
+ _has_bits_[0] |= 0x00000800u;
+}
+inline void LayerParameter::clear_has_transform_param() {
+ _has_bits_[0] &= ~0x00000800u;
+}
+inline void LayerParameter::clear_transform_param() {
+ if (transform_param_ != NULL) transform_param_->::caffe::TransformationParameter::Clear();
+ clear_has_transform_param();
+}
+inline const ::caffe::TransformationParameter& LayerParameter::transform_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.transform_param)
+ return transform_param_ != NULL ? *transform_param_
+ : *::caffe::TransformationParameter::internal_default_instance();
+}
+inline ::caffe::TransformationParameter* LayerParameter::mutable_transform_param() {
+ set_has_transform_param();
+ if (transform_param_ == NULL) {
+ transform_param_ = new ::caffe::TransformationParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.transform_param)
+ return transform_param_;
+}
+inline ::caffe::TransformationParameter* LayerParameter::release_transform_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.transform_param)
+ clear_has_transform_param();
+ ::caffe::TransformationParameter* temp = transform_param_;
+ transform_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_transform_param(::caffe::TransformationParameter* transform_param) {
+ delete transform_param_;
+ transform_param_ = transform_param;
+ if (transform_param) {
+ set_has_transform_param();
+ } else {
+ clear_has_transform_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.transform_param)
+}
+
+// optional .caffe.LossParameter loss_param = 101;
+inline bool LayerParameter::has_loss_param() const {
+ return (_has_bits_[0] & 0x00001000u) != 0;
+}
+inline void LayerParameter::set_has_loss_param() {
+ _has_bits_[0] |= 0x00001000u;
+}
+inline void LayerParameter::clear_has_loss_param() {
+ _has_bits_[0] &= ~0x00001000u;
+}
+inline void LayerParameter::clear_loss_param() {
+ if (loss_param_ != NULL) loss_param_->::caffe::LossParameter::Clear();
+ clear_has_loss_param();
+}
+inline const ::caffe::LossParameter& LayerParameter::loss_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.loss_param)
+ return loss_param_ != NULL ? *loss_param_
+ : *::caffe::LossParameter::internal_default_instance();
+}
+inline ::caffe::LossParameter* LayerParameter::mutable_loss_param() {
+ set_has_loss_param();
+ if (loss_param_ == NULL) {
+ loss_param_ = new ::caffe::LossParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.loss_param)
+ return loss_param_;
+}
+inline ::caffe::LossParameter* LayerParameter::release_loss_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.loss_param)
+ clear_has_loss_param();
+ ::caffe::LossParameter* temp = loss_param_;
+ loss_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_loss_param(::caffe::LossParameter* loss_param) {
+ delete loss_param_;
+ loss_param_ = loss_param;
+ if (loss_param) {
+ set_has_loss_param();
+ } else {
+ clear_has_loss_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.loss_param)
+}
+
+// optional .caffe.AccuracyParameter accuracy_param = 102;
+inline bool LayerParameter::has_accuracy_param() const {
+ return (_has_bits_[0] & 0x00002000u) != 0;
+}
+inline void LayerParameter::set_has_accuracy_param() {
+ _has_bits_[0] |= 0x00002000u;
+}
+inline void LayerParameter::clear_has_accuracy_param() {
+ _has_bits_[0] &= ~0x00002000u;
+}
+inline void LayerParameter::clear_accuracy_param() {
+ if (accuracy_param_ != NULL) accuracy_param_->::caffe::AccuracyParameter::Clear();
+ clear_has_accuracy_param();
+}
+inline const ::caffe::AccuracyParameter& LayerParameter::accuracy_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.accuracy_param)
+ return accuracy_param_ != NULL ? *accuracy_param_
+ : *::caffe::AccuracyParameter::internal_default_instance();
+}
+inline ::caffe::AccuracyParameter* LayerParameter::mutable_accuracy_param() {
+ set_has_accuracy_param();
+ if (accuracy_param_ == NULL) {
+ accuracy_param_ = new ::caffe::AccuracyParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.accuracy_param)
+ return accuracy_param_;
+}
+inline ::caffe::AccuracyParameter* LayerParameter::release_accuracy_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.accuracy_param)
+ clear_has_accuracy_param();
+ ::caffe::AccuracyParameter* temp = accuracy_param_;
+ accuracy_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_accuracy_param(::caffe::AccuracyParameter* accuracy_param) {
+ delete accuracy_param_;
+ accuracy_param_ = accuracy_param;
+ if (accuracy_param) {
+ set_has_accuracy_param();
+ } else {
+ clear_has_accuracy_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.accuracy_param)
+}
+
+// optional .caffe.ArgMaxParameter argmax_param = 103;
+inline bool LayerParameter::has_argmax_param() const {
+ return (_has_bits_[0] & 0x00004000u) != 0;
+}
+inline void LayerParameter::set_has_argmax_param() {
+ _has_bits_[0] |= 0x00004000u;
+}
+inline void LayerParameter::clear_has_argmax_param() {
+ _has_bits_[0] &= ~0x00004000u;
+}
+inline void LayerParameter::clear_argmax_param() {
+ if (argmax_param_ != NULL) argmax_param_->::caffe::ArgMaxParameter::Clear();
+ clear_has_argmax_param();
+}
+inline const ::caffe::ArgMaxParameter& LayerParameter::argmax_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.argmax_param)
+ return argmax_param_ != NULL ? *argmax_param_
+ : *::caffe::ArgMaxParameter::internal_default_instance();
+}
+inline ::caffe::ArgMaxParameter* LayerParameter::mutable_argmax_param() {
+ set_has_argmax_param();
+ if (argmax_param_ == NULL) {
+ argmax_param_ = new ::caffe::ArgMaxParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.argmax_param)
+ return argmax_param_;
+}
+inline ::caffe::ArgMaxParameter* LayerParameter::release_argmax_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.argmax_param)
+ clear_has_argmax_param();
+ ::caffe::ArgMaxParameter* temp = argmax_param_;
+ argmax_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_argmax_param(::caffe::ArgMaxParameter* argmax_param) {
+ delete argmax_param_;
+ argmax_param_ = argmax_param;
+ if (argmax_param) {
+ set_has_argmax_param();
+ } else {
+ clear_has_argmax_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.argmax_param)
+}
+
+// optional .caffe.BatchNormParameter batch_norm_param = 139;
+inline bool LayerParameter::has_batch_norm_param() const {
+ return (_has_bits_[0] & 0x00008000u) != 0;
+}
+inline void LayerParameter::set_has_batch_norm_param() {
+ _has_bits_[0] |= 0x00008000u;
+}
+inline void LayerParameter::clear_has_batch_norm_param() {
+ _has_bits_[0] &= ~0x00008000u;
+}
+inline void LayerParameter::clear_batch_norm_param() {
+ if (batch_norm_param_ != NULL) batch_norm_param_->::caffe::BatchNormParameter::Clear();
+ clear_has_batch_norm_param();
+}
+inline const ::caffe::BatchNormParameter& LayerParameter::batch_norm_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.batch_norm_param)
+ return batch_norm_param_ != NULL ? *batch_norm_param_
+ : *::caffe::BatchNormParameter::internal_default_instance();
+}
+inline ::caffe::BatchNormParameter* LayerParameter::mutable_batch_norm_param() {
+ set_has_batch_norm_param();
+ if (batch_norm_param_ == NULL) {
+ batch_norm_param_ = new ::caffe::BatchNormParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.batch_norm_param)
+ return batch_norm_param_;
+}
+inline ::caffe::BatchNormParameter* LayerParameter::release_batch_norm_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.batch_norm_param)
+ clear_has_batch_norm_param();
+ ::caffe::BatchNormParameter* temp = batch_norm_param_;
+ batch_norm_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_batch_norm_param(::caffe::BatchNormParameter* batch_norm_param) {
+ delete batch_norm_param_;
+ batch_norm_param_ = batch_norm_param;
+ if (batch_norm_param) {
+ set_has_batch_norm_param();
+ } else {
+ clear_has_batch_norm_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.batch_norm_param)
+}
+
+// optional .caffe.BiasParameter bias_param = 141;
+inline bool LayerParameter::has_bias_param() const {
+ return (_has_bits_[0] & 0x00010000u) != 0;
+}
+inline void LayerParameter::set_has_bias_param() {
+ _has_bits_[0] |= 0x00010000u;
+}
+inline void LayerParameter::clear_has_bias_param() {
+ _has_bits_[0] &= ~0x00010000u;
+}
+inline void LayerParameter::clear_bias_param() {
+ if (bias_param_ != NULL) bias_param_->::caffe::BiasParameter::Clear();
+ clear_has_bias_param();
+}
+inline const ::caffe::BiasParameter& LayerParameter::bias_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.bias_param)
+ return bias_param_ != NULL ? *bias_param_
+ : *::caffe::BiasParameter::internal_default_instance();
+}
+inline ::caffe::BiasParameter* LayerParameter::mutable_bias_param() {
+ set_has_bias_param();
+ if (bias_param_ == NULL) {
+ bias_param_ = new ::caffe::BiasParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.bias_param)
+ return bias_param_;
+}
+inline ::caffe::BiasParameter* LayerParameter::release_bias_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.bias_param)
+ clear_has_bias_param();
+ ::caffe::BiasParameter* temp = bias_param_;
+ bias_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_bias_param(::caffe::BiasParameter* bias_param) {
+ delete bias_param_;
+ bias_param_ = bias_param;
+ if (bias_param) {
+ set_has_bias_param();
+ } else {
+ clear_has_bias_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.bias_param)
+}
+
+// optional .caffe.ConcatParameter concat_param = 104;
+inline bool LayerParameter::has_concat_param() const {
+ return (_has_bits_[0] & 0x00020000u) != 0;
+}
+inline void LayerParameter::set_has_concat_param() {
+ _has_bits_[0] |= 0x00020000u;
+}
+inline void LayerParameter::clear_has_concat_param() {
+ _has_bits_[0] &= ~0x00020000u;
+}
+inline void LayerParameter::clear_concat_param() {
+ if (concat_param_ != NULL) concat_param_->::caffe::ConcatParameter::Clear();
+ clear_has_concat_param();
+}
+inline const ::caffe::ConcatParameter& LayerParameter::concat_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.concat_param)
+ return concat_param_ != NULL ? *concat_param_
+ : *::caffe::ConcatParameter::internal_default_instance();
+}
+inline ::caffe::ConcatParameter* LayerParameter::mutable_concat_param() {
+ set_has_concat_param();
+ if (concat_param_ == NULL) {
+ concat_param_ = new ::caffe::ConcatParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.concat_param)
+ return concat_param_;
+}
+inline ::caffe::ConcatParameter* LayerParameter::release_concat_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.concat_param)
+ clear_has_concat_param();
+ ::caffe::ConcatParameter* temp = concat_param_;
+ concat_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_concat_param(::caffe::ConcatParameter* concat_param) {
+ delete concat_param_;
+ concat_param_ = concat_param;
+ if (concat_param) {
+ set_has_concat_param();
+ } else {
+ clear_has_concat_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.concat_param)
+}
+
+// optional .caffe.ContrastiveLossParameter contrastive_loss_param = 105;
+inline bool LayerParameter::has_contrastive_loss_param() const {
+ return (_has_bits_[0] & 0x00040000u) != 0;
+}
+inline void LayerParameter::set_has_contrastive_loss_param() {
+ _has_bits_[0] |= 0x00040000u;
+}
+inline void LayerParameter::clear_has_contrastive_loss_param() {
+ _has_bits_[0] &= ~0x00040000u;
+}
+inline void LayerParameter::clear_contrastive_loss_param() {
+ if (contrastive_loss_param_ != NULL) contrastive_loss_param_->::caffe::ContrastiveLossParameter::Clear();
+ clear_has_contrastive_loss_param();
+}
+inline const ::caffe::ContrastiveLossParameter& LayerParameter::contrastive_loss_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.contrastive_loss_param)
+ return contrastive_loss_param_ != NULL ? *contrastive_loss_param_
+ : *::caffe::ContrastiveLossParameter::internal_default_instance();
+}
+inline ::caffe::ContrastiveLossParameter* LayerParameter::mutable_contrastive_loss_param() {
+ set_has_contrastive_loss_param();
+ if (contrastive_loss_param_ == NULL) {
+ contrastive_loss_param_ = new ::caffe::ContrastiveLossParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.contrastive_loss_param)
+ return contrastive_loss_param_;
+}
+inline ::caffe::ContrastiveLossParameter* LayerParameter::release_contrastive_loss_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.contrastive_loss_param)
+ clear_has_contrastive_loss_param();
+ ::caffe::ContrastiveLossParameter* temp = contrastive_loss_param_;
+ contrastive_loss_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_contrastive_loss_param(::caffe::ContrastiveLossParameter* contrastive_loss_param) {
+ delete contrastive_loss_param_;
+ contrastive_loss_param_ = contrastive_loss_param;
+ if (contrastive_loss_param) {
+ set_has_contrastive_loss_param();
+ } else {
+ clear_has_contrastive_loss_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.contrastive_loss_param)
+}
+
+// optional .caffe.ConvolutionParameter convolution_param = 106;
+inline bool LayerParameter::has_convolution_param() const {
+ return (_has_bits_[0] & 0x00080000u) != 0;
+}
+inline void LayerParameter::set_has_convolution_param() {
+ _has_bits_[0] |= 0x00080000u;
+}
+inline void LayerParameter::clear_has_convolution_param() {
+ _has_bits_[0] &= ~0x00080000u;
+}
+inline void LayerParameter::clear_convolution_param() {
+ if (convolution_param_ != NULL) convolution_param_->::caffe::ConvolutionParameter::Clear();
+ clear_has_convolution_param();
+}
+inline const ::caffe::ConvolutionParameter& LayerParameter::convolution_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.convolution_param)
+ return convolution_param_ != NULL ? *convolution_param_
+ : *::caffe::ConvolutionParameter::internal_default_instance();
+}
+inline ::caffe::ConvolutionParameter* LayerParameter::mutable_convolution_param() {
+ set_has_convolution_param();
+ if (convolution_param_ == NULL) {
+ convolution_param_ = new ::caffe::ConvolutionParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.convolution_param)
+ return convolution_param_;
+}
+inline ::caffe::ConvolutionParameter* LayerParameter::release_convolution_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.convolution_param)
+ clear_has_convolution_param();
+ ::caffe::ConvolutionParameter* temp = convolution_param_;
+ convolution_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_convolution_param(::caffe::ConvolutionParameter* convolution_param) {
+ delete convolution_param_;
+ convolution_param_ = convolution_param;
+ if (convolution_param) {
+ set_has_convolution_param();
+ } else {
+ clear_has_convolution_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.convolution_param)
+}
+
+// optional .caffe.CropParameter crop_param = 144;
+inline bool LayerParameter::has_crop_param() const {
+ return (_has_bits_[0] & 0x00100000u) != 0;
+}
+inline void LayerParameter::set_has_crop_param() {
+ _has_bits_[0] |= 0x00100000u;
+}
+inline void LayerParameter::clear_has_crop_param() {
+ _has_bits_[0] &= ~0x00100000u;
+}
+inline void LayerParameter::clear_crop_param() {
+ if (crop_param_ != NULL) crop_param_->::caffe::CropParameter::Clear();
+ clear_has_crop_param();
+}
+inline const ::caffe::CropParameter& LayerParameter::crop_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.crop_param)
+ return crop_param_ != NULL ? *crop_param_
+ : *::caffe::CropParameter::internal_default_instance();
+}
+inline ::caffe::CropParameter* LayerParameter::mutable_crop_param() {
+ set_has_crop_param();
+ if (crop_param_ == NULL) {
+ crop_param_ = new ::caffe::CropParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.crop_param)
+ return crop_param_;
+}
+inline ::caffe::CropParameter* LayerParameter::release_crop_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.crop_param)
+ clear_has_crop_param();
+ ::caffe::CropParameter* temp = crop_param_;
+ crop_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_crop_param(::caffe::CropParameter* crop_param) {
+ delete crop_param_;
+ crop_param_ = crop_param;
+ if (crop_param) {
+ set_has_crop_param();
+ } else {
+ clear_has_crop_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.crop_param)
+}
+
+// optional .caffe.DataParameter data_param = 107;
+inline bool LayerParameter::has_data_param() const {
+ return (_has_bits_[0] & 0x00200000u) != 0;
+}
+inline void LayerParameter::set_has_data_param() {
+ _has_bits_[0] |= 0x00200000u;
+}
+inline void LayerParameter::clear_has_data_param() {
+ _has_bits_[0] &= ~0x00200000u;
+}
+inline void LayerParameter::clear_data_param() {
+ if (data_param_ != NULL) data_param_->::caffe::DataParameter::Clear();
+ clear_has_data_param();
+}
+inline const ::caffe::DataParameter& LayerParameter::data_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.data_param)
+ return data_param_ != NULL ? *data_param_
+ : *::caffe::DataParameter::internal_default_instance();
+}
+inline ::caffe::DataParameter* LayerParameter::mutable_data_param() {
+ set_has_data_param();
+ if (data_param_ == NULL) {
+ data_param_ = new ::caffe::DataParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.data_param)
+ return data_param_;
+}
+inline ::caffe::DataParameter* LayerParameter::release_data_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.data_param)
+ clear_has_data_param();
+ ::caffe::DataParameter* temp = data_param_;
+ data_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_data_param(::caffe::DataParameter* data_param) {
+ delete data_param_;
+ data_param_ = data_param;
+ if (data_param) {
+ set_has_data_param();
+ } else {
+ clear_has_data_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.data_param)
+}
+
+// optional .caffe.DetectionOutputParameter detection_output_param = 147;
+inline bool LayerParameter::has_detection_output_param() const {
+ return (_has_bits_[0] & 0x00400000u) != 0;
+}
+inline void LayerParameter::set_has_detection_output_param() {
+ _has_bits_[0] |= 0x00400000u;
+}
+inline void LayerParameter::clear_has_detection_output_param() {
+ _has_bits_[0] &= ~0x00400000u;
+}
+inline void LayerParameter::clear_detection_output_param() {
+ if (detection_output_param_ != NULL) detection_output_param_->::caffe::DetectionOutputParameter::Clear();
+ clear_has_detection_output_param();
+}
+inline const ::caffe::DetectionOutputParameter& LayerParameter::detection_output_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.detection_output_param)
+ return detection_output_param_ != NULL ? *detection_output_param_
+ : *::caffe::DetectionOutputParameter::internal_default_instance();
+}
+inline ::caffe::DetectionOutputParameter* LayerParameter::mutable_detection_output_param() {
+ set_has_detection_output_param();
+ if (detection_output_param_ == NULL) {
+ detection_output_param_ = new ::caffe::DetectionOutputParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.detection_output_param)
+ return detection_output_param_;
+}
+inline ::caffe::DetectionOutputParameter* LayerParameter::release_detection_output_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.detection_output_param)
+ clear_has_detection_output_param();
+ ::caffe::DetectionOutputParameter* temp = detection_output_param_;
+ detection_output_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_detection_output_param(::caffe::DetectionOutputParameter* detection_output_param) {
+ delete detection_output_param_;
+ detection_output_param_ = detection_output_param;
+ if (detection_output_param) {
+ set_has_detection_output_param();
+ } else {
+ clear_has_detection_output_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.detection_output_param)
+}
+
+// optional .caffe.DropoutParameter dropout_param = 108;
+inline bool LayerParameter::has_dropout_param() const {
+ return (_has_bits_[0] & 0x00800000u) != 0;
+}
+inline void LayerParameter::set_has_dropout_param() {
+ _has_bits_[0] |= 0x00800000u;
+}
+inline void LayerParameter::clear_has_dropout_param() {
+ _has_bits_[0] &= ~0x00800000u;
+}
+inline void LayerParameter::clear_dropout_param() {
+ if (dropout_param_ != NULL) dropout_param_->::caffe::DropoutParameter::Clear();
+ clear_has_dropout_param();
+}
+inline const ::caffe::DropoutParameter& LayerParameter::dropout_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.dropout_param)
+ return dropout_param_ != NULL ? *dropout_param_
+ : *::caffe::DropoutParameter::internal_default_instance();
+}
+inline ::caffe::DropoutParameter* LayerParameter::mutable_dropout_param() {
+ set_has_dropout_param();
+ if (dropout_param_ == NULL) {
+ dropout_param_ = new ::caffe::DropoutParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.dropout_param)
+ return dropout_param_;
+}
+inline ::caffe::DropoutParameter* LayerParameter::release_dropout_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.dropout_param)
+ clear_has_dropout_param();
+ ::caffe::DropoutParameter* temp = dropout_param_;
+ dropout_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_dropout_param(::caffe::DropoutParameter* dropout_param) {
+ delete dropout_param_;
+ dropout_param_ = dropout_param;
+ if (dropout_param) {
+ set_has_dropout_param();
+ } else {
+ clear_has_dropout_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.dropout_param)
+}
+
+// optional .caffe.DummyDataParameter dummy_data_param = 109;
+inline bool LayerParameter::has_dummy_data_param() const {
+ return (_has_bits_[0] & 0x01000000u) != 0;
+}
+inline void LayerParameter::set_has_dummy_data_param() {
+ _has_bits_[0] |= 0x01000000u;
+}
+inline void LayerParameter::clear_has_dummy_data_param() {
+ _has_bits_[0] &= ~0x01000000u;
+}
+inline void LayerParameter::clear_dummy_data_param() {
+ if (dummy_data_param_ != NULL) dummy_data_param_->::caffe::DummyDataParameter::Clear();
+ clear_has_dummy_data_param();
+}
+inline const ::caffe::DummyDataParameter& LayerParameter::dummy_data_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.dummy_data_param)
+ return dummy_data_param_ != NULL ? *dummy_data_param_
+ : *::caffe::DummyDataParameter::internal_default_instance();
+}
+inline ::caffe::DummyDataParameter* LayerParameter::mutable_dummy_data_param() {
+ set_has_dummy_data_param();
+ if (dummy_data_param_ == NULL) {
+ dummy_data_param_ = new ::caffe::DummyDataParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.dummy_data_param)
+ return dummy_data_param_;
+}
+inline ::caffe::DummyDataParameter* LayerParameter::release_dummy_data_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.dummy_data_param)
+ clear_has_dummy_data_param();
+ ::caffe::DummyDataParameter* temp = dummy_data_param_;
+ dummy_data_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_dummy_data_param(::caffe::DummyDataParameter* dummy_data_param) {
+ delete dummy_data_param_;
+ dummy_data_param_ = dummy_data_param;
+ if (dummy_data_param) {
+ set_has_dummy_data_param();
+ } else {
+ clear_has_dummy_data_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.dummy_data_param)
+}
+
+// optional .caffe.EltwiseParameter eltwise_param = 110;
+inline bool LayerParameter::has_eltwise_param() const {
+ return (_has_bits_[0] & 0x02000000u) != 0;
+}
+inline void LayerParameter::set_has_eltwise_param() {
+ _has_bits_[0] |= 0x02000000u;
+}
+inline void LayerParameter::clear_has_eltwise_param() {
+ _has_bits_[0] &= ~0x02000000u;
+}
+inline void LayerParameter::clear_eltwise_param() {
+ if (eltwise_param_ != NULL) eltwise_param_->::caffe::EltwiseParameter::Clear();
+ clear_has_eltwise_param();
+}
+inline const ::caffe::EltwiseParameter& LayerParameter::eltwise_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.eltwise_param)
+ return eltwise_param_ != NULL ? *eltwise_param_
+ : *::caffe::EltwiseParameter::internal_default_instance();
+}
+inline ::caffe::EltwiseParameter* LayerParameter::mutable_eltwise_param() {
+ set_has_eltwise_param();
+ if (eltwise_param_ == NULL) {
+ eltwise_param_ = new ::caffe::EltwiseParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.eltwise_param)
+ return eltwise_param_;
+}
+inline ::caffe::EltwiseParameter* LayerParameter::release_eltwise_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.eltwise_param)
+ clear_has_eltwise_param();
+ ::caffe::EltwiseParameter* temp = eltwise_param_;
+ eltwise_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_eltwise_param(::caffe::EltwiseParameter* eltwise_param) {
+ delete eltwise_param_;
+ eltwise_param_ = eltwise_param;
+ if (eltwise_param) {
+ set_has_eltwise_param();
+ } else {
+ clear_has_eltwise_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.eltwise_param)
+}
+
+// optional .caffe.ELUParameter elu_param = 140;
+inline bool LayerParameter::has_elu_param() const {
+ return (_has_bits_[0] & 0x04000000u) != 0;
+}
+inline void LayerParameter::set_has_elu_param() {
+ _has_bits_[0] |= 0x04000000u;
+}
+inline void LayerParameter::clear_has_elu_param() {
+ _has_bits_[0] &= ~0x04000000u;
+}
+inline void LayerParameter::clear_elu_param() {
+ if (elu_param_ != NULL) elu_param_->::caffe::ELUParameter::Clear();
+ clear_has_elu_param();
+}
+inline const ::caffe::ELUParameter& LayerParameter::elu_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.elu_param)
+ return elu_param_ != NULL ? *elu_param_
+ : *::caffe::ELUParameter::internal_default_instance();
+}
+inline ::caffe::ELUParameter* LayerParameter::mutable_elu_param() {
+ set_has_elu_param();
+ if (elu_param_ == NULL) {
+ elu_param_ = new ::caffe::ELUParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.elu_param)
+ return elu_param_;
+}
+inline ::caffe::ELUParameter* LayerParameter::release_elu_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.elu_param)
+ clear_has_elu_param();
+ ::caffe::ELUParameter* temp = elu_param_;
+ elu_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_elu_param(::caffe::ELUParameter* elu_param) {
+ delete elu_param_;
+ elu_param_ = elu_param;
+ if (elu_param) {
+ set_has_elu_param();
+ } else {
+ clear_has_elu_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.elu_param)
+}
+
+// optional .caffe.EmbedParameter embed_param = 137;
+inline bool LayerParameter::has_embed_param() const {
+ return (_has_bits_[0] & 0x08000000u) != 0;
+}
+inline void LayerParameter::set_has_embed_param() {
+ _has_bits_[0] |= 0x08000000u;
+}
+inline void LayerParameter::clear_has_embed_param() {
+ _has_bits_[0] &= ~0x08000000u;
+}
+inline void LayerParameter::clear_embed_param() {
+ if (embed_param_ != NULL) embed_param_->::caffe::EmbedParameter::Clear();
+ clear_has_embed_param();
+}
+inline const ::caffe::EmbedParameter& LayerParameter::embed_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.embed_param)
+ return embed_param_ != NULL ? *embed_param_
+ : *::caffe::EmbedParameter::internal_default_instance();
+}
+inline ::caffe::EmbedParameter* LayerParameter::mutable_embed_param() {
+ set_has_embed_param();
+ if (embed_param_ == NULL) {
+ embed_param_ = new ::caffe::EmbedParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.embed_param)
+ return embed_param_;
+}
+inline ::caffe::EmbedParameter* LayerParameter::release_embed_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.embed_param)
+ clear_has_embed_param();
+ ::caffe::EmbedParameter* temp = embed_param_;
+ embed_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_embed_param(::caffe::EmbedParameter* embed_param) {
+ delete embed_param_;
+ embed_param_ = embed_param;
+ if (embed_param) {
+ set_has_embed_param();
+ } else {
+ clear_has_embed_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.embed_param)
+}
+
+// optional .caffe.ExpParameter exp_param = 111;
+inline bool LayerParameter::has_exp_param() const {
+ return (_has_bits_[0] & 0x10000000u) != 0;
+}
+inline void LayerParameter::set_has_exp_param() {
+ _has_bits_[0] |= 0x10000000u;
+}
+inline void LayerParameter::clear_has_exp_param() {
+ _has_bits_[0] &= ~0x10000000u;
+}
+inline void LayerParameter::clear_exp_param() {
+ if (exp_param_ != NULL) exp_param_->::caffe::ExpParameter::Clear();
+ clear_has_exp_param();
+}
+inline const ::caffe::ExpParameter& LayerParameter::exp_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.exp_param)
+ return exp_param_ != NULL ? *exp_param_
+ : *::caffe::ExpParameter::internal_default_instance();
+}
+inline ::caffe::ExpParameter* LayerParameter::mutable_exp_param() {
+ set_has_exp_param();
+ if (exp_param_ == NULL) {
+ exp_param_ = new ::caffe::ExpParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.exp_param)
+ return exp_param_;
+}
+inline ::caffe::ExpParameter* LayerParameter::release_exp_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.exp_param)
+ clear_has_exp_param();
+ ::caffe::ExpParameter* temp = exp_param_;
+ exp_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_exp_param(::caffe::ExpParameter* exp_param) {
+ delete exp_param_;
+ exp_param_ = exp_param;
+ if (exp_param) {
+ set_has_exp_param();
+ } else {
+ clear_has_exp_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.exp_param)
+}
+
+// optional .caffe.FlattenParameter flatten_param = 135;
+inline bool LayerParameter::has_flatten_param() const {
+ return (_has_bits_[0] & 0x20000000u) != 0;
+}
+inline void LayerParameter::set_has_flatten_param() {
+ _has_bits_[0] |= 0x20000000u;
+}
+inline void LayerParameter::clear_has_flatten_param() {
+ _has_bits_[0] &= ~0x20000000u;
+}
+inline void LayerParameter::clear_flatten_param() {
+ if (flatten_param_ != NULL) flatten_param_->::caffe::FlattenParameter::Clear();
+ clear_has_flatten_param();
+}
+inline const ::caffe::FlattenParameter& LayerParameter::flatten_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.flatten_param)
+ return flatten_param_ != NULL ? *flatten_param_
+ : *::caffe::FlattenParameter::internal_default_instance();
+}
+inline ::caffe::FlattenParameter* LayerParameter::mutable_flatten_param() {
+ set_has_flatten_param();
+ if (flatten_param_ == NULL) {
+ flatten_param_ = new ::caffe::FlattenParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.flatten_param)
+ return flatten_param_;
+}
+inline ::caffe::FlattenParameter* LayerParameter::release_flatten_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.flatten_param)
+ clear_has_flatten_param();
+ ::caffe::FlattenParameter* temp = flatten_param_;
+ flatten_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_flatten_param(::caffe::FlattenParameter* flatten_param) {
+ delete flatten_param_;
+ flatten_param_ = flatten_param;
+ if (flatten_param) {
+ set_has_flatten_param();
+ } else {
+ clear_has_flatten_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.flatten_param)
+}
+
+// optional .caffe.HDF5DataParameter hdf5_data_param = 112;
+inline bool LayerParameter::has_hdf5_data_param() const {
+ return (_has_bits_[0] & 0x40000000u) != 0;
+}
+inline void LayerParameter::set_has_hdf5_data_param() {
+ _has_bits_[0] |= 0x40000000u;
+}
+inline void LayerParameter::clear_has_hdf5_data_param() {
+ _has_bits_[0] &= ~0x40000000u;
+}
+inline void LayerParameter::clear_hdf5_data_param() {
+ if (hdf5_data_param_ != NULL) hdf5_data_param_->::caffe::HDF5DataParameter::Clear();
+ clear_has_hdf5_data_param();
+}
+inline const ::caffe::HDF5DataParameter& LayerParameter::hdf5_data_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.hdf5_data_param)
+ return hdf5_data_param_ != NULL ? *hdf5_data_param_
+ : *::caffe::HDF5DataParameter::internal_default_instance();
+}
+inline ::caffe::HDF5DataParameter* LayerParameter::mutable_hdf5_data_param() {
+ set_has_hdf5_data_param();
+ if (hdf5_data_param_ == NULL) {
+ hdf5_data_param_ = new ::caffe::HDF5DataParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.hdf5_data_param)
+ return hdf5_data_param_;
+}
+inline ::caffe::HDF5DataParameter* LayerParameter::release_hdf5_data_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.hdf5_data_param)
+ clear_has_hdf5_data_param();
+ ::caffe::HDF5DataParameter* temp = hdf5_data_param_;
+ hdf5_data_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_hdf5_data_param(::caffe::HDF5DataParameter* hdf5_data_param) {
+ delete hdf5_data_param_;
+ hdf5_data_param_ = hdf5_data_param;
+ if (hdf5_data_param) {
+ set_has_hdf5_data_param();
+ } else {
+ clear_has_hdf5_data_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.hdf5_data_param)
+}
+
+// optional .caffe.HDF5OutputParameter hdf5_output_param = 113;
+inline bool LayerParameter::has_hdf5_output_param() const {
+ return (_has_bits_[0] & 0x80000000u) != 0;
+}
+inline void LayerParameter::set_has_hdf5_output_param() {
+ _has_bits_[0] |= 0x80000000u;
+}
+inline void LayerParameter::clear_has_hdf5_output_param() {
+ _has_bits_[0] &= ~0x80000000u;
+}
+inline void LayerParameter::clear_hdf5_output_param() {
+ if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear();
+ clear_has_hdf5_output_param();
+}
+inline const ::caffe::HDF5OutputParameter& LayerParameter::hdf5_output_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.hdf5_output_param)
+ return hdf5_output_param_ != NULL ? *hdf5_output_param_
+ : *::caffe::HDF5OutputParameter::internal_default_instance();
+}
+inline ::caffe::HDF5OutputParameter* LayerParameter::mutable_hdf5_output_param() {
+ set_has_hdf5_output_param();
+ if (hdf5_output_param_ == NULL) {
+ hdf5_output_param_ = new ::caffe::HDF5OutputParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.hdf5_output_param)
+ return hdf5_output_param_;
+}
+inline ::caffe::HDF5OutputParameter* LayerParameter::release_hdf5_output_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.hdf5_output_param)
+ clear_has_hdf5_output_param();
+ ::caffe::HDF5OutputParameter* temp = hdf5_output_param_;
+ hdf5_output_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param) {
+ delete hdf5_output_param_;
+ hdf5_output_param_ = hdf5_output_param;
+ if (hdf5_output_param) {
+ set_has_hdf5_output_param();
+ } else {
+ clear_has_hdf5_output_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.hdf5_output_param)
+}
+
+// optional .caffe.HingeLossParameter hinge_loss_param = 114;
+inline bool LayerParameter::has_hinge_loss_param() const {
+ return (_has_bits_[1] & 0x00000001u) != 0;
+}
+inline void LayerParameter::set_has_hinge_loss_param() {
+ _has_bits_[1] |= 0x00000001u;
+}
+inline void LayerParameter::clear_has_hinge_loss_param() {
+ _has_bits_[1] &= ~0x00000001u;
+}
+inline void LayerParameter::clear_hinge_loss_param() {
+ if (hinge_loss_param_ != NULL) hinge_loss_param_->::caffe::HingeLossParameter::Clear();
+ clear_has_hinge_loss_param();
+}
+inline const ::caffe::HingeLossParameter& LayerParameter::hinge_loss_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.hinge_loss_param)
+ return hinge_loss_param_ != NULL ? *hinge_loss_param_
+ : *::caffe::HingeLossParameter::internal_default_instance();
+}
+inline ::caffe::HingeLossParameter* LayerParameter::mutable_hinge_loss_param() {
+ set_has_hinge_loss_param();
+ if (hinge_loss_param_ == NULL) {
+ hinge_loss_param_ = new ::caffe::HingeLossParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.hinge_loss_param)
+ return hinge_loss_param_;
+}
+inline ::caffe::HingeLossParameter* LayerParameter::release_hinge_loss_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.hinge_loss_param)
+ clear_has_hinge_loss_param();
+ ::caffe::HingeLossParameter* temp = hinge_loss_param_;
+ hinge_loss_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_hinge_loss_param(::caffe::HingeLossParameter* hinge_loss_param) {
+ delete hinge_loss_param_;
+ hinge_loss_param_ = hinge_loss_param;
+ if (hinge_loss_param) {
+ set_has_hinge_loss_param();
+ } else {
+ clear_has_hinge_loss_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.hinge_loss_param)
+}
+
+// optional .caffe.ImageDataParameter image_data_param = 115;
+inline bool LayerParameter::has_image_data_param() const {
+ return (_has_bits_[1] & 0x00000002u) != 0;
+}
+inline void LayerParameter::set_has_image_data_param() {
+ _has_bits_[1] |= 0x00000002u;
+}
+inline void LayerParameter::clear_has_image_data_param() {
+ _has_bits_[1] &= ~0x00000002u;
+}
+inline void LayerParameter::clear_image_data_param() {
+ if (image_data_param_ != NULL) image_data_param_->::caffe::ImageDataParameter::Clear();
+ clear_has_image_data_param();
+}
+inline const ::caffe::ImageDataParameter& LayerParameter::image_data_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.image_data_param)
+ return image_data_param_ != NULL ? *image_data_param_
+ : *::caffe::ImageDataParameter::internal_default_instance();
+}
+inline ::caffe::ImageDataParameter* LayerParameter::mutable_image_data_param() {
+ set_has_image_data_param();
+ if (image_data_param_ == NULL) {
+ image_data_param_ = new ::caffe::ImageDataParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.image_data_param)
+ return image_data_param_;
+}
+inline ::caffe::ImageDataParameter* LayerParameter::release_image_data_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.image_data_param)
+ clear_has_image_data_param();
+ ::caffe::ImageDataParameter* temp = image_data_param_;
+ image_data_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_image_data_param(::caffe::ImageDataParameter* image_data_param) {
+ delete image_data_param_;
+ image_data_param_ = image_data_param;
+ if (image_data_param) {
+ set_has_image_data_param();
+ } else {
+ clear_has_image_data_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.image_data_param)
+}
+
+// optional .caffe.InfogainLossParameter infogain_loss_param = 116;
+inline bool LayerParameter::has_infogain_loss_param() const {
+ return (_has_bits_[1] & 0x00000004u) != 0;
+}
+inline void LayerParameter::set_has_infogain_loss_param() {
+ _has_bits_[1] |= 0x00000004u;
+}
+inline void LayerParameter::clear_has_infogain_loss_param() {
+ _has_bits_[1] &= ~0x00000004u;
+}
+inline void LayerParameter::clear_infogain_loss_param() {
+ if (infogain_loss_param_ != NULL) infogain_loss_param_->::caffe::InfogainLossParameter::Clear();
+ clear_has_infogain_loss_param();
+}
+inline const ::caffe::InfogainLossParameter& LayerParameter::infogain_loss_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.infogain_loss_param)
+ return infogain_loss_param_ != NULL ? *infogain_loss_param_
+ : *::caffe::InfogainLossParameter::internal_default_instance();
+}
+inline ::caffe::InfogainLossParameter* LayerParameter::mutable_infogain_loss_param() {
+ set_has_infogain_loss_param();
+ if (infogain_loss_param_ == NULL) {
+ infogain_loss_param_ = new ::caffe::InfogainLossParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.infogain_loss_param)
+ return infogain_loss_param_;
+}
+inline ::caffe::InfogainLossParameter* LayerParameter::release_infogain_loss_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.infogain_loss_param)
+ clear_has_infogain_loss_param();
+ ::caffe::InfogainLossParameter* temp = infogain_loss_param_;
+ infogain_loss_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_infogain_loss_param(::caffe::InfogainLossParameter* infogain_loss_param) {
+ delete infogain_loss_param_;
+ infogain_loss_param_ = infogain_loss_param;
+ if (infogain_loss_param) {
+ set_has_infogain_loss_param();
+ } else {
+ clear_has_infogain_loss_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.infogain_loss_param)
+}
+
+// optional .caffe.InnerProductParameter inner_product_param = 117;
+inline bool LayerParameter::has_inner_product_param() const {
+ return (_has_bits_[1] & 0x00000008u) != 0;
+}
+inline void LayerParameter::set_has_inner_product_param() {
+ _has_bits_[1] |= 0x00000008u;
+}
+inline void LayerParameter::clear_has_inner_product_param() {
+ _has_bits_[1] &= ~0x00000008u;
+}
+inline void LayerParameter::clear_inner_product_param() {
+ if (inner_product_param_ != NULL) inner_product_param_->::caffe::InnerProductParameter::Clear();
+ clear_has_inner_product_param();
+}
+inline const ::caffe::InnerProductParameter& LayerParameter::inner_product_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.inner_product_param)
+ return inner_product_param_ != NULL ? *inner_product_param_
+ : *::caffe::InnerProductParameter::internal_default_instance();
+}
+inline ::caffe::InnerProductParameter* LayerParameter::mutable_inner_product_param() {
+ set_has_inner_product_param();
+ if (inner_product_param_ == NULL) {
+ inner_product_param_ = new ::caffe::InnerProductParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.inner_product_param)
+ return inner_product_param_;
+}
+inline ::caffe::InnerProductParameter* LayerParameter::release_inner_product_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.inner_product_param)
+ clear_has_inner_product_param();
+ ::caffe::InnerProductParameter* temp = inner_product_param_;
+ inner_product_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_inner_product_param(::caffe::InnerProductParameter* inner_product_param) {
+ delete inner_product_param_;
+ inner_product_param_ = inner_product_param;
+ if (inner_product_param) {
+ set_has_inner_product_param();
+ } else {
+ clear_has_inner_product_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.inner_product_param)
+}
+
+// optional .caffe.InputParameter input_param = 143;
+inline bool LayerParameter::has_input_param() const {
+ return (_has_bits_[1] & 0x00000010u) != 0;
+}
+inline void LayerParameter::set_has_input_param() {
+ _has_bits_[1] |= 0x00000010u;
+}
+inline void LayerParameter::clear_has_input_param() {
+ _has_bits_[1] &= ~0x00000010u;
+}
+inline void LayerParameter::clear_input_param() {
+ if (input_param_ != NULL) input_param_->::caffe::InputParameter::Clear();
+ clear_has_input_param();
+}
+inline const ::caffe::InputParameter& LayerParameter::input_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.input_param)
+ return input_param_ != NULL ? *input_param_
+ : *::caffe::InputParameter::internal_default_instance();
+}
+inline ::caffe::InputParameter* LayerParameter::mutable_input_param() {
+ set_has_input_param();
+ if (input_param_ == NULL) {
+ input_param_ = new ::caffe::InputParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.input_param)
+ return input_param_;
+}
+inline ::caffe::InputParameter* LayerParameter::release_input_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.input_param)
+ clear_has_input_param();
+ ::caffe::InputParameter* temp = input_param_;
+ input_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_input_param(::caffe::InputParameter* input_param) {
+ delete input_param_;
+ input_param_ = input_param;
+ if (input_param) {
+ set_has_input_param();
+ } else {
+ clear_has_input_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.input_param)
+}
+
+// optional .caffe.LogParameter log_param = 134;
+inline bool LayerParameter::has_log_param() const {
+ return (_has_bits_[1] & 0x00000020u) != 0;
+}
+inline void LayerParameter::set_has_log_param() {
+ _has_bits_[1] |= 0x00000020u;
+}
+inline void LayerParameter::clear_has_log_param() {
+ _has_bits_[1] &= ~0x00000020u;
+}
+inline void LayerParameter::clear_log_param() {
+ if (log_param_ != NULL) log_param_->::caffe::LogParameter::Clear();
+ clear_has_log_param();
+}
+inline const ::caffe::LogParameter& LayerParameter::log_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.log_param)
+ return log_param_ != NULL ? *log_param_
+ : *::caffe::LogParameter::internal_default_instance();
+}
+inline ::caffe::LogParameter* LayerParameter::mutable_log_param() {
+ set_has_log_param();
+ if (log_param_ == NULL) {
+ log_param_ = new ::caffe::LogParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.log_param)
+ return log_param_;
+}
+inline ::caffe::LogParameter* LayerParameter::release_log_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.log_param)
+ clear_has_log_param();
+ ::caffe::LogParameter* temp = log_param_;
+ log_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_log_param(::caffe::LogParameter* log_param) {
+ delete log_param_;
+ log_param_ = log_param;
+ if (log_param) {
+ set_has_log_param();
+ } else {
+ clear_has_log_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.log_param)
+}
+
+// optional .caffe.LRNParameter lrn_param = 118;
+inline bool LayerParameter::has_lrn_param() const {
+ return (_has_bits_[1] & 0x00000040u) != 0;
+}
+inline void LayerParameter::set_has_lrn_param() {
+ _has_bits_[1] |= 0x00000040u;
+}
+inline void LayerParameter::clear_has_lrn_param() {
+ _has_bits_[1] &= ~0x00000040u;
+}
+inline void LayerParameter::clear_lrn_param() {
+ if (lrn_param_ != NULL) lrn_param_->::caffe::LRNParameter::Clear();
+ clear_has_lrn_param();
+}
+inline const ::caffe::LRNParameter& LayerParameter::lrn_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.lrn_param)
+ return lrn_param_ != NULL ? *lrn_param_
+ : *::caffe::LRNParameter::internal_default_instance();
+}
+inline ::caffe::LRNParameter* LayerParameter::mutable_lrn_param() {
+ set_has_lrn_param();
+ if (lrn_param_ == NULL) {
+ lrn_param_ = new ::caffe::LRNParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.lrn_param)
+ return lrn_param_;
+}
+inline ::caffe::LRNParameter* LayerParameter::release_lrn_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.lrn_param)
+ clear_has_lrn_param();
+ ::caffe::LRNParameter* temp = lrn_param_;
+ lrn_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_lrn_param(::caffe::LRNParameter* lrn_param) {
+ delete lrn_param_;
+ lrn_param_ = lrn_param;
+ if (lrn_param) {
+ set_has_lrn_param();
+ } else {
+ clear_has_lrn_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.lrn_param)
+}
+
+// optional .caffe.MemoryDataParameter memory_data_param = 119;
+inline bool LayerParameter::has_memory_data_param() const {
+ return (_has_bits_[1] & 0x00000080u) != 0;
+}
+inline void LayerParameter::set_has_memory_data_param() {
+ _has_bits_[1] |= 0x00000080u;
+}
+inline void LayerParameter::clear_has_memory_data_param() {
+ _has_bits_[1] &= ~0x00000080u;
+}
+inline void LayerParameter::clear_memory_data_param() {
+ if (memory_data_param_ != NULL) memory_data_param_->::caffe::MemoryDataParameter::Clear();
+ clear_has_memory_data_param();
+}
+inline const ::caffe::MemoryDataParameter& LayerParameter::memory_data_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.memory_data_param)
+ return memory_data_param_ != NULL ? *memory_data_param_
+ : *::caffe::MemoryDataParameter::internal_default_instance();
+}
+inline ::caffe::MemoryDataParameter* LayerParameter::mutable_memory_data_param() {
+ set_has_memory_data_param();
+ if (memory_data_param_ == NULL) {
+ memory_data_param_ = new ::caffe::MemoryDataParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.memory_data_param)
+ return memory_data_param_;
+}
+inline ::caffe::MemoryDataParameter* LayerParameter::release_memory_data_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.memory_data_param)
+ clear_has_memory_data_param();
+ ::caffe::MemoryDataParameter* temp = memory_data_param_;
+ memory_data_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_memory_data_param(::caffe::MemoryDataParameter* memory_data_param) {
+ delete memory_data_param_;
+ memory_data_param_ = memory_data_param;
+ if (memory_data_param) {
+ set_has_memory_data_param();
+ } else {
+ clear_has_memory_data_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.memory_data_param)
+}
+
+// optional .caffe.MVNParameter mvn_param = 120;
+inline bool LayerParameter::has_mvn_param() const {
+ return (_has_bits_[1] & 0x00000100u) != 0;
+}
+inline void LayerParameter::set_has_mvn_param() {
+ _has_bits_[1] |= 0x00000100u;
+}
+inline void LayerParameter::clear_has_mvn_param() {
+ _has_bits_[1] &= ~0x00000100u;
+}
+inline void LayerParameter::clear_mvn_param() {
+ if (mvn_param_ != NULL) mvn_param_->::caffe::MVNParameter::Clear();
+ clear_has_mvn_param();
+}
+inline const ::caffe::MVNParameter& LayerParameter::mvn_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.mvn_param)
+ return mvn_param_ != NULL ? *mvn_param_
+ : *::caffe::MVNParameter::internal_default_instance();
+}
+inline ::caffe::MVNParameter* LayerParameter::mutable_mvn_param() {
+ set_has_mvn_param();
+ if (mvn_param_ == NULL) {
+ mvn_param_ = new ::caffe::MVNParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.mvn_param)
+ return mvn_param_;
+}
+inline ::caffe::MVNParameter* LayerParameter::release_mvn_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.mvn_param)
+ clear_has_mvn_param();
+ ::caffe::MVNParameter* temp = mvn_param_;
+ mvn_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_mvn_param(::caffe::MVNParameter* mvn_param) {
+ delete mvn_param_;
+ mvn_param_ = mvn_param;
+ if (mvn_param) {
+ set_has_mvn_param();
+ } else {
+ clear_has_mvn_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.mvn_param)
+}
+
+// optional .caffe.NormalizeBBoxParameter norm_param = 149;
+inline bool LayerParameter::has_norm_param() const {
+ return (_has_bits_[1] & 0x00000200u) != 0;
+}
+inline void LayerParameter::set_has_norm_param() {
+ _has_bits_[1] |= 0x00000200u;
+}
+inline void LayerParameter::clear_has_norm_param() {
+ _has_bits_[1] &= ~0x00000200u;
+}
+inline void LayerParameter::clear_norm_param() {
+ if (norm_param_ != NULL) norm_param_->::caffe::NormalizeBBoxParameter::Clear();
+ clear_has_norm_param();
+}
+inline const ::caffe::NormalizeBBoxParameter& LayerParameter::norm_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.norm_param)
+ return norm_param_ != NULL ? *norm_param_
+ : *::caffe::NormalizeBBoxParameter::internal_default_instance();
+}
+inline ::caffe::NormalizeBBoxParameter* LayerParameter::mutable_norm_param() {
+ set_has_norm_param();
+ if (norm_param_ == NULL) {
+ norm_param_ = new ::caffe::NormalizeBBoxParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.norm_param)
+ return norm_param_;
+}
+inline ::caffe::NormalizeBBoxParameter* LayerParameter::release_norm_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.norm_param)
+ clear_has_norm_param();
+ ::caffe::NormalizeBBoxParameter* temp = norm_param_;
+ norm_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_norm_param(::caffe::NormalizeBBoxParameter* norm_param) {
+ delete norm_param_;
+ norm_param_ = norm_param;
+ if (norm_param) {
+ set_has_norm_param();
+ } else {
+ clear_has_norm_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.norm_param)
+}
+
+// optional .caffe.PermuteParameter permute_param = 148;
+inline bool LayerParameter::has_permute_param() const {
+ return (_has_bits_[1] & 0x00000400u) != 0;
+}
+inline void LayerParameter::set_has_permute_param() {
+ _has_bits_[1] |= 0x00000400u;
+}
+inline void LayerParameter::clear_has_permute_param() {
+ _has_bits_[1] &= ~0x00000400u;
+}
+inline void LayerParameter::clear_permute_param() {
+ if (permute_param_ != NULL) permute_param_->::caffe::PermuteParameter::Clear();
+ clear_has_permute_param();
+}
+inline const ::caffe::PermuteParameter& LayerParameter::permute_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.permute_param)
+ return permute_param_ != NULL ? *permute_param_
+ : *::caffe::PermuteParameter::internal_default_instance();
+}
+inline ::caffe::PermuteParameter* LayerParameter::mutable_permute_param() {
+ set_has_permute_param();
+ if (permute_param_ == NULL) {
+ permute_param_ = new ::caffe::PermuteParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.permute_param)
+ return permute_param_;
+}
+inline ::caffe::PermuteParameter* LayerParameter::release_permute_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.permute_param)
+ clear_has_permute_param();
+ ::caffe::PermuteParameter* temp = permute_param_;
+ permute_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_permute_param(::caffe::PermuteParameter* permute_param) {
+ delete permute_param_;
+ permute_param_ = permute_param;
+ if (permute_param) {
+ set_has_permute_param();
+ } else {
+ clear_has_permute_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.permute_param)
+}
+
+// optional .caffe.ParameterParameter parameter_param = 145;
+inline bool LayerParameter::has_parameter_param() const {
+ return (_has_bits_[1] & 0x00000800u) != 0;
+}
+inline void LayerParameter::set_has_parameter_param() {
+ _has_bits_[1] |= 0x00000800u;
+}
+inline void LayerParameter::clear_has_parameter_param() {
+ _has_bits_[1] &= ~0x00000800u;
+}
+inline void LayerParameter::clear_parameter_param() {
+ if (parameter_param_ != NULL) parameter_param_->::caffe::ParameterParameter::Clear();
+ clear_has_parameter_param();
+}
+inline const ::caffe::ParameterParameter& LayerParameter::parameter_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.parameter_param)
+ return parameter_param_ != NULL ? *parameter_param_
+ : *::caffe::ParameterParameter::internal_default_instance();
+}
+inline ::caffe::ParameterParameter* LayerParameter::mutable_parameter_param() {
+ set_has_parameter_param();
+ if (parameter_param_ == NULL) {
+ parameter_param_ = new ::caffe::ParameterParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.parameter_param)
+ return parameter_param_;
+}
+inline ::caffe::ParameterParameter* LayerParameter::release_parameter_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.parameter_param)
+ clear_has_parameter_param();
+ ::caffe::ParameterParameter* temp = parameter_param_;
+ parameter_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_parameter_param(::caffe::ParameterParameter* parameter_param) {
+ delete parameter_param_;
+ parameter_param_ = parameter_param;
+ if (parameter_param) {
+ set_has_parameter_param();
+ } else {
+ clear_has_parameter_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.parameter_param)
+}
+
+// optional .caffe.PoolingParameter pooling_param = 121;
+inline bool LayerParameter::has_pooling_param() const {
+ return (_has_bits_[1] & 0x00001000u) != 0;
+}
+inline void LayerParameter::set_has_pooling_param() {
+ _has_bits_[1] |= 0x00001000u;
+}
+inline void LayerParameter::clear_has_pooling_param() {
+ _has_bits_[1] &= ~0x00001000u;
+}
+inline void LayerParameter::clear_pooling_param() {
+ if (pooling_param_ != NULL) pooling_param_->::caffe::PoolingParameter::Clear();
+ clear_has_pooling_param();
+}
+inline const ::caffe::PoolingParameter& LayerParameter::pooling_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.pooling_param)
+ return pooling_param_ != NULL ? *pooling_param_
+ : *::caffe::PoolingParameter::internal_default_instance();
+}
+inline ::caffe::PoolingParameter* LayerParameter::mutable_pooling_param() {
+ set_has_pooling_param();
+ if (pooling_param_ == NULL) {
+ pooling_param_ = new ::caffe::PoolingParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.pooling_param)
+ return pooling_param_;
+}
+inline ::caffe::PoolingParameter* LayerParameter::release_pooling_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.pooling_param)
+ clear_has_pooling_param();
+ ::caffe::PoolingParameter* temp = pooling_param_;
+ pooling_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_pooling_param(::caffe::PoolingParameter* pooling_param) {
+ delete pooling_param_;
+ pooling_param_ = pooling_param;
+ if (pooling_param) {
+ set_has_pooling_param();
+ } else {
+ clear_has_pooling_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.pooling_param)
+}
+
+// optional .caffe.PowerParameter power_param = 122;
+inline bool LayerParameter::has_power_param() const {
+ return (_has_bits_[1] & 0x00002000u) != 0;
+}
+inline void LayerParameter::set_has_power_param() {
+ _has_bits_[1] |= 0x00002000u;
+}
+inline void LayerParameter::clear_has_power_param() {
+ _has_bits_[1] &= ~0x00002000u;
+}
+inline void LayerParameter::clear_power_param() {
+ if (power_param_ != NULL) power_param_->::caffe::PowerParameter::Clear();
+ clear_has_power_param();
+}
+inline const ::caffe::PowerParameter& LayerParameter::power_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.power_param)
+ return power_param_ != NULL ? *power_param_
+ : *::caffe::PowerParameter::internal_default_instance();
+}
+inline ::caffe::PowerParameter* LayerParameter::mutable_power_param() {
+ set_has_power_param();
+ if (power_param_ == NULL) {
+ power_param_ = new ::caffe::PowerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.power_param)
+ return power_param_;
+}
+inline ::caffe::PowerParameter* LayerParameter::release_power_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.power_param)
+ clear_has_power_param();
+ ::caffe::PowerParameter* temp = power_param_;
+ power_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_power_param(::caffe::PowerParameter* power_param) {
+ delete power_param_;
+ power_param_ = power_param;
+ if (power_param) {
+ set_has_power_param();
+ } else {
+ clear_has_power_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.power_param)
+}
+
+// optional .caffe.PReLUParameter prelu_param = 131;
+inline bool LayerParameter::has_prelu_param() const {
+ return (_has_bits_[1] & 0x00004000u) != 0;
+}
+inline void LayerParameter::set_has_prelu_param() {
+ _has_bits_[1] |= 0x00004000u;
+}
+inline void LayerParameter::clear_has_prelu_param() {
+ _has_bits_[1] &= ~0x00004000u;
+}
+inline void LayerParameter::clear_prelu_param() {
+ if (prelu_param_ != NULL) prelu_param_->::caffe::PReLUParameter::Clear();
+ clear_has_prelu_param();
+}
+inline const ::caffe::PReLUParameter& LayerParameter::prelu_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.prelu_param)
+ return prelu_param_ != NULL ? *prelu_param_
+ : *::caffe::PReLUParameter::internal_default_instance();
+}
+inline ::caffe::PReLUParameter* LayerParameter::mutable_prelu_param() {
+ set_has_prelu_param();
+ if (prelu_param_ == NULL) {
+ prelu_param_ = new ::caffe::PReLUParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.prelu_param)
+ return prelu_param_;
+}
+inline ::caffe::PReLUParameter* LayerParameter::release_prelu_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.prelu_param)
+ clear_has_prelu_param();
+ ::caffe::PReLUParameter* temp = prelu_param_;
+ prelu_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_prelu_param(::caffe::PReLUParameter* prelu_param) {
+ delete prelu_param_;
+ prelu_param_ = prelu_param;
+ if (prelu_param) {
+ set_has_prelu_param();
+ } else {
+ clear_has_prelu_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.prelu_param)
+}
+
+// optional .caffe.PriorBoxParameter prior_box_param = 150;
+inline bool LayerParameter::has_prior_box_param() const {
+ return (_has_bits_[1] & 0x00008000u) != 0;
+}
+inline void LayerParameter::set_has_prior_box_param() {
+ _has_bits_[1] |= 0x00008000u;
+}
+inline void LayerParameter::clear_has_prior_box_param() {
+ _has_bits_[1] &= ~0x00008000u;
+}
+inline void LayerParameter::clear_prior_box_param() {
+ if (prior_box_param_ != NULL) prior_box_param_->::caffe::PriorBoxParameter::Clear();
+ clear_has_prior_box_param();
+}
+inline const ::caffe::PriorBoxParameter& LayerParameter::prior_box_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.prior_box_param)
+ return prior_box_param_ != NULL ? *prior_box_param_
+ : *::caffe::PriorBoxParameter::internal_default_instance();
+}
+inline ::caffe::PriorBoxParameter* LayerParameter::mutable_prior_box_param() {
+ set_has_prior_box_param();
+ if (prior_box_param_ == NULL) {
+ prior_box_param_ = new ::caffe::PriorBoxParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.prior_box_param)
+ return prior_box_param_;
+}
+inline ::caffe::PriorBoxParameter* LayerParameter::release_prior_box_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.prior_box_param)
+ clear_has_prior_box_param();
+ ::caffe::PriorBoxParameter* temp = prior_box_param_;
+ prior_box_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_prior_box_param(::caffe::PriorBoxParameter* prior_box_param) {
+ delete prior_box_param_;
+ prior_box_param_ = prior_box_param;
+ if (prior_box_param) {
+ set_has_prior_box_param();
+ } else {
+ clear_has_prior_box_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.prior_box_param)
+}
+
+// optional .caffe.PythonParameter python_param = 130;
+inline bool LayerParameter::has_python_param() const {
+ return (_has_bits_[1] & 0x00010000u) != 0;
+}
+inline void LayerParameter::set_has_python_param() {
+ _has_bits_[1] |= 0x00010000u;
+}
+inline void LayerParameter::clear_has_python_param() {
+ _has_bits_[1] &= ~0x00010000u;
+}
+inline void LayerParameter::clear_python_param() {
+ if (python_param_ != NULL) python_param_->::caffe::PythonParameter::Clear();
+ clear_has_python_param();
+}
+inline const ::caffe::PythonParameter& LayerParameter::python_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.python_param)
+ return python_param_ != NULL ? *python_param_
+ : *::caffe::PythonParameter::internal_default_instance();
+}
+inline ::caffe::PythonParameter* LayerParameter::mutable_python_param() {
+ set_has_python_param();
+ if (python_param_ == NULL) {
+ python_param_ = new ::caffe::PythonParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.python_param)
+ return python_param_;
+}
+inline ::caffe::PythonParameter* LayerParameter::release_python_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.python_param)
+ clear_has_python_param();
+ ::caffe::PythonParameter* temp = python_param_;
+ python_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_python_param(::caffe::PythonParameter* python_param) {
+ delete python_param_;
+ python_param_ = python_param;
+ if (python_param) {
+ set_has_python_param();
+ } else {
+ clear_has_python_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.python_param)
+}
+
+// optional .caffe.RecurrentParameter recurrent_param = 146;
+inline bool LayerParameter::has_recurrent_param() const {
+ return (_has_bits_[1] & 0x00020000u) != 0;
+}
+inline void LayerParameter::set_has_recurrent_param() {
+ _has_bits_[1] |= 0x00020000u;
+}
+inline void LayerParameter::clear_has_recurrent_param() {
+ _has_bits_[1] &= ~0x00020000u;
+}
+inline void LayerParameter::clear_recurrent_param() {
+ if (recurrent_param_ != NULL) recurrent_param_->::caffe::RecurrentParameter::Clear();
+ clear_has_recurrent_param();
+}
+inline const ::caffe::RecurrentParameter& LayerParameter::recurrent_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.recurrent_param)
+ return recurrent_param_ != NULL ? *recurrent_param_
+ : *::caffe::RecurrentParameter::internal_default_instance();
+}
+inline ::caffe::RecurrentParameter* LayerParameter::mutable_recurrent_param() {
+ set_has_recurrent_param();
+ if (recurrent_param_ == NULL) {
+ recurrent_param_ = new ::caffe::RecurrentParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.recurrent_param)
+ return recurrent_param_;
+}
+inline ::caffe::RecurrentParameter* LayerParameter::release_recurrent_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.recurrent_param)
+ clear_has_recurrent_param();
+ ::caffe::RecurrentParameter* temp = recurrent_param_;
+ recurrent_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_recurrent_param(::caffe::RecurrentParameter* recurrent_param) {
+ delete recurrent_param_;
+ recurrent_param_ = recurrent_param;
+ if (recurrent_param) {
+ set_has_recurrent_param();
+ } else {
+ clear_has_recurrent_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.recurrent_param)
+}
+
+// optional .caffe.ReductionParameter reduction_param = 136;
+inline bool LayerParameter::has_reduction_param() const {
+ return (_has_bits_[1] & 0x00040000u) != 0;
+}
+inline void LayerParameter::set_has_reduction_param() {
+ _has_bits_[1] |= 0x00040000u;
+}
+inline void LayerParameter::clear_has_reduction_param() {
+ _has_bits_[1] &= ~0x00040000u;
+}
+inline void LayerParameter::clear_reduction_param() {
+ if (reduction_param_ != NULL) reduction_param_->::caffe::ReductionParameter::Clear();
+ clear_has_reduction_param();
+}
+inline const ::caffe::ReductionParameter& LayerParameter::reduction_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.reduction_param)
+ return reduction_param_ != NULL ? *reduction_param_
+ : *::caffe::ReductionParameter::internal_default_instance();
+}
+inline ::caffe::ReductionParameter* LayerParameter::mutable_reduction_param() {
+ set_has_reduction_param();
+ if (reduction_param_ == NULL) {
+ reduction_param_ = new ::caffe::ReductionParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.reduction_param)
+ return reduction_param_;
+}
+inline ::caffe::ReductionParameter* LayerParameter::release_reduction_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.reduction_param)
+ clear_has_reduction_param();
+ ::caffe::ReductionParameter* temp = reduction_param_;
+ reduction_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_reduction_param(::caffe::ReductionParameter* reduction_param) {
+ delete reduction_param_;
+ reduction_param_ = reduction_param;
+ if (reduction_param) {
+ set_has_reduction_param();
+ } else {
+ clear_has_reduction_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.reduction_param)
+}
+
+// optional .caffe.ReLUParameter relu_param = 123;
+inline bool LayerParameter::has_relu_param() const {
+ return (_has_bits_[1] & 0x00080000u) != 0;
+}
+inline void LayerParameter::set_has_relu_param() {
+ _has_bits_[1] |= 0x00080000u;
+}
+inline void LayerParameter::clear_has_relu_param() {
+ _has_bits_[1] &= ~0x00080000u;
+}
+inline void LayerParameter::clear_relu_param() {
+ if (relu_param_ != NULL) relu_param_->::caffe::ReLUParameter::Clear();
+ clear_has_relu_param();
+}
+inline const ::caffe::ReLUParameter& LayerParameter::relu_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.relu_param)
+ return relu_param_ != NULL ? *relu_param_
+ : *::caffe::ReLUParameter::internal_default_instance();
+}
+inline ::caffe::ReLUParameter* LayerParameter::mutable_relu_param() {
+ set_has_relu_param();
+ if (relu_param_ == NULL) {
+ relu_param_ = new ::caffe::ReLUParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.relu_param)
+ return relu_param_;
+}
+inline ::caffe::ReLUParameter* LayerParameter::release_relu_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.relu_param)
+ clear_has_relu_param();
+ ::caffe::ReLUParameter* temp = relu_param_;
+ relu_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_relu_param(::caffe::ReLUParameter* relu_param) {
+ delete relu_param_;
+ relu_param_ = relu_param;
+ if (relu_param) {
+ set_has_relu_param();
+ } else {
+ clear_has_relu_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.relu_param)
+}
+
+// optional .caffe.ReshapeParameter reshape_param = 133;
+inline bool LayerParameter::has_reshape_param() const {
+ return (_has_bits_[1] & 0x00100000u) != 0;
+}
+inline void LayerParameter::set_has_reshape_param() {
+ _has_bits_[1] |= 0x00100000u;
+}
+inline void LayerParameter::clear_has_reshape_param() {
+ _has_bits_[1] &= ~0x00100000u;
+}
+inline void LayerParameter::clear_reshape_param() {
+ if (reshape_param_ != NULL) reshape_param_->::caffe::ReshapeParameter::Clear();
+ clear_has_reshape_param();
+}
+inline const ::caffe::ReshapeParameter& LayerParameter::reshape_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.reshape_param)
+ return reshape_param_ != NULL ? *reshape_param_
+ : *::caffe::ReshapeParameter::internal_default_instance();
+}
+inline ::caffe::ReshapeParameter* LayerParameter::mutable_reshape_param() {
+ set_has_reshape_param();
+ if (reshape_param_ == NULL) {
+ reshape_param_ = new ::caffe::ReshapeParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.reshape_param)
+ return reshape_param_;
+}
+inline ::caffe::ReshapeParameter* LayerParameter::release_reshape_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.reshape_param)
+ clear_has_reshape_param();
+ ::caffe::ReshapeParameter* temp = reshape_param_;
+ reshape_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_reshape_param(::caffe::ReshapeParameter* reshape_param) {
+ delete reshape_param_;
+ reshape_param_ = reshape_param;
+ if (reshape_param) {
+ set_has_reshape_param();
+ } else {
+ clear_has_reshape_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.reshape_param)
+}
+
+// optional .caffe.ScaleParameter scale_param = 142;
+inline bool LayerParameter::has_scale_param() const {
+ return (_has_bits_[1] & 0x00200000u) != 0;
+}
+inline void LayerParameter::set_has_scale_param() {
+ _has_bits_[1] |= 0x00200000u;
+}
+inline void LayerParameter::clear_has_scale_param() {
+ _has_bits_[1] &= ~0x00200000u;
+}
+inline void LayerParameter::clear_scale_param() {
+ if (scale_param_ != NULL) scale_param_->::caffe::ScaleParameter::Clear();
+ clear_has_scale_param();
+}
+inline const ::caffe::ScaleParameter& LayerParameter::scale_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.scale_param)
+ return scale_param_ != NULL ? *scale_param_
+ : *::caffe::ScaleParameter::internal_default_instance();
+}
+inline ::caffe::ScaleParameter* LayerParameter::mutable_scale_param() {
+ set_has_scale_param();
+ if (scale_param_ == NULL) {
+ scale_param_ = new ::caffe::ScaleParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.scale_param)
+ return scale_param_;
+}
+inline ::caffe::ScaleParameter* LayerParameter::release_scale_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.scale_param)
+ clear_has_scale_param();
+ ::caffe::ScaleParameter* temp = scale_param_;
+ scale_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_scale_param(::caffe::ScaleParameter* scale_param) {
+ delete scale_param_;
+ scale_param_ = scale_param;
+ if (scale_param) {
+ set_has_scale_param();
+ } else {
+ clear_has_scale_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.scale_param)
+}
+
+// optional .caffe.SigmoidParameter sigmoid_param = 124;
+inline bool LayerParameter::has_sigmoid_param() const {
+ return (_has_bits_[1] & 0x00400000u) != 0;
+}
+inline void LayerParameter::set_has_sigmoid_param() {
+ _has_bits_[1] |= 0x00400000u;
+}
+inline void LayerParameter::clear_has_sigmoid_param() {
+ _has_bits_[1] &= ~0x00400000u;
+}
+inline void LayerParameter::clear_sigmoid_param() {
+ if (sigmoid_param_ != NULL) sigmoid_param_->::caffe::SigmoidParameter::Clear();
+ clear_has_sigmoid_param();
+}
+inline const ::caffe::SigmoidParameter& LayerParameter::sigmoid_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.sigmoid_param)
+ return sigmoid_param_ != NULL ? *sigmoid_param_
+ : *::caffe::SigmoidParameter::internal_default_instance();
+}
+inline ::caffe::SigmoidParameter* LayerParameter::mutable_sigmoid_param() {
+ set_has_sigmoid_param();
+ if (sigmoid_param_ == NULL) {
+ sigmoid_param_ = new ::caffe::SigmoidParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.sigmoid_param)
+ return sigmoid_param_;
+}
+inline ::caffe::SigmoidParameter* LayerParameter::release_sigmoid_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.sigmoid_param)
+ clear_has_sigmoid_param();
+ ::caffe::SigmoidParameter* temp = sigmoid_param_;
+ sigmoid_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_sigmoid_param(::caffe::SigmoidParameter* sigmoid_param) {
+ delete sigmoid_param_;
+ sigmoid_param_ = sigmoid_param;
+ if (sigmoid_param) {
+ set_has_sigmoid_param();
+ } else {
+ clear_has_sigmoid_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.sigmoid_param)
+}
+
+// optional .caffe.SoftmaxParameter softmax_param = 125;
+inline bool LayerParameter::has_softmax_param() const {
+ return (_has_bits_[1] & 0x00800000u) != 0;
+}
+inline void LayerParameter::set_has_softmax_param() {
+ _has_bits_[1] |= 0x00800000u;
+}
+inline void LayerParameter::clear_has_softmax_param() {
+ _has_bits_[1] &= ~0x00800000u;
+}
+inline void LayerParameter::clear_softmax_param() {
+ if (softmax_param_ != NULL) softmax_param_->::caffe::SoftmaxParameter::Clear();
+ clear_has_softmax_param();
+}
+inline const ::caffe::SoftmaxParameter& LayerParameter::softmax_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.softmax_param)
+ return softmax_param_ != NULL ? *softmax_param_
+ : *::caffe::SoftmaxParameter::internal_default_instance();
+}
+inline ::caffe::SoftmaxParameter* LayerParameter::mutable_softmax_param() {
+ set_has_softmax_param();
+ if (softmax_param_ == NULL) {
+ softmax_param_ = new ::caffe::SoftmaxParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.softmax_param)
+ return softmax_param_;
+}
+inline ::caffe::SoftmaxParameter* LayerParameter::release_softmax_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.softmax_param)
+ clear_has_softmax_param();
+ ::caffe::SoftmaxParameter* temp = softmax_param_;
+ softmax_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_softmax_param(::caffe::SoftmaxParameter* softmax_param) {
+ delete softmax_param_;
+ softmax_param_ = softmax_param;
+ if (softmax_param) {
+ set_has_softmax_param();
+ } else {
+ clear_has_softmax_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.softmax_param)
+}
+
+// optional .caffe.SPPParameter spp_param = 132;
+inline bool LayerParameter::has_spp_param() const {
+ return (_has_bits_[1] & 0x01000000u) != 0;
+}
+inline void LayerParameter::set_has_spp_param() {
+ _has_bits_[1] |= 0x01000000u;
+}
+inline void LayerParameter::clear_has_spp_param() {
+ _has_bits_[1] &= ~0x01000000u;
+}
+inline void LayerParameter::clear_spp_param() {
+ if (spp_param_ != NULL) spp_param_->::caffe::SPPParameter::Clear();
+ clear_has_spp_param();
+}
+inline const ::caffe::SPPParameter& LayerParameter::spp_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.spp_param)
+ return spp_param_ != NULL ? *spp_param_
+ : *::caffe::SPPParameter::internal_default_instance();
+}
+inline ::caffe::SPPParameter* LayerParameter::mutable_spp_param() {
+ set_has_spp_param();
+ if (spp_param_ == NULL) {
+ spp_param_ = new ::caffe::SPPParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.spp_param)
+ return spp_param_;
+}
+inline ::caffe::SPPParameter* LayerParameter::release_spp_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.spp_param)
+ clear_has_spp_param();
+ ::caffe::SPPParameter* temp = spp_param_;
+ spp_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_spp_param(::caffe::SPPParameter* spp_param) {
+ delete spp_param_;
+ spp_param_ = spp_param;
+ if (spp_param) {
+ set_has_spp_param();
+ } else {
+ clear_has_spp_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.spp_param)
+}
+
+// optional .caffe.SliceParameter slice_param = 126;
+inline bool LayerParameter::has_slice_param() const {
+ return (_has_bits_[1] & 0x02000000u) != 0;
+}
+inline void LayerParameter::set_has_slice_param() {
+ _has_bits_[1] |= 0x02000000u;
+}
+inline void LayerParameter::clear_has_slice_param() {
+ _has_bits_[1] &= ~0x02000000u;
+}
+inline void LayerParameter::clear_slice_param() {
+ if (slice_param_ != NULL) slice_param_->::caffe::SliceParameter::Clear();
+ clear_has_slice_param();
+}
+inline const ::caffe::SliceParameter& LayerParameter::slice_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.slice_param)
+ return slice_param_ != NULL ? *slice_param_
+ : *::caffe::SliceParameter::internal_default_instance();
+}
+inline ::caffe::SliceParameter* LayerParameter::mutable_slice_param() {
+ set_has_slice_param();
+ if (slice_param_ == NULL) {
+ slice_param_ = new ::caffe::SliceParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.slice_param)
+ return slice_param_;
+}
+inline ::caffe::SliceParameter* LayerParameter::release_slice_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.slice_param)
+ clear_has_slice_param();
+ ::caffe::SliceParameter* temp = slice_param_;
+ slice_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_slice_param(::caffe::SliceParameter* slice_param) {
+ delete slice_param_;
+ slice_param_ = slice_param;
+ if (slice_param) {
+ set_has_slice_param();
+ } else {
+ clear_has_slice_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.slice_param)
+}
+
+// optional .caffe.TanHParameter tanh_param = 127;
+inline bool LayerParameter::has_tanh_param() const {
+ return (_has_bits_[1] & 0x04000000u) != 0;
+}
+inline void LayerParameter::set_has_tanh_param() {
+ _has_bits_[1] |= 0x04000000u;
+}
+inline void LayerParameter::clear_has_tanh_param() {
+ _has_bits_[1] &= ~0x04000000u;
+}
+inline void LayerParameter::clear_tanh_param() {
+ if (tanh_param_ != NULL) tanh_param_->::caffe::TanHParameter::Clear();
+ clear_has_tanh_param();
+}
+inline const ::caffe::TanHParameter& LayerParameter::tanh_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.tanh_param)
+ return tanh_param_ != NULL ? *tanh_param_
+ : *::caffe::TanHParameter::internal_default_instance();
+}
+inline ::caffe::TanHParameter* LayerParameter::mutable_tanh_param() {
+ set_has_tanh_param();
+ if (tanh_param_ == NULL) {
+ tanh_param_ = new ::caffe::TanHParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.tanh_param)
+ return tanh_param_;
+}
+inline ::caffe::TanHParameter* LayerParameter::release_tanh_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.tanh_param)
+ clear_has_tanh_param();
+ ::caffe::TanHParameter* temp = tanh_param_;
+ tanh_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_tanh_param(::caffe::TanHParameter* tanh_param) {
+ delete tanh_param_;
+ tanh_param_ = tanh_param;
+ if (tanh_param) {
+ set_has_tanh_param();
+ } else {
+ clear_has_tanh_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.tanh_param)
+}
+
+// optional .caffe.ThresholdParameter threshold_param = 128;
+inline bool LayerParameter::has_threshold_param() const {
+ return (_has_bits_[1] & 0x08000000u) != 0;
+}
+inline void LayerParameter::set_has_threshold_param() {
+ _has_bits_[1] |= 0x08000000u;
+}
+inline void LayerParameter::clear_has_threshold_param() {
+ _has_bits_[1] &= ~0x08000000u;
+}
+inline void LayerParameter::clear_threshold_param() {
+ if (threshold_param_ != NULL) threshold_param_->::caffe::ThresholdParameter::Clear();
+ clear_has_threshold_param();
+}
+inline const ::caffe::ThresholdParameter& LayerParameter::threshold_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.threshold_param)
+ return threshold_param_ != NULL ? *threshold_param_
+ : *::caffe::ThresholdParameter::internal_default_instance();
+}
+inline ::caffe::ThresholdParameter* LayerParameter::mutable_threshold_param() {
+ set_has_threshold_param();
+ if (threshold_param_ == NULL) {
+ threshold_param_ = new ::caffe::ThresholdParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.threshold_param)
+ return threshold_param_;
+}
+inline ::caffe::ThresholdParameter* LayerParameter::release_threshold_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.threshold_param)
+ clear_has_threshold_param();
+ ::caffe::ThresholdParameter* temp = threshold_param_;
+ threshold_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_threshold_param(::caffe::ThresholdParameter* threshold_param) {
+ delete threshold_param_;
+ threshold_param_ = threshold_param;
+ if (threshold_param) {
+ set_has_threshold_param();
+ } else {
+ clear_has_threshold_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.threshold_param)
+}
+
+// optional .caffe.TileParameter tile_param = 138;
+inline bool LayerParameter::has_tile_param() const {
+ return (_has_bits_[1] & 0x10000000u) != 0;
+}
+inline void LayerParameter::set_has_tile_param() {
+ _has_bits_[1] |= 0x10000000u;
+}
+inline void LayerParameter::clear_has_tile_param() {
+ _has_bits_[1] &= ~0x10000000u;
+}
+inline void LayerParameter::clear_tile_param() {
+ if (tile_param_ != NULL) tile_param_->::caffe::TileParameter::Clear();
+ clear_has_tile_param();
+}
+inline const ::caffe::TileParameter& LayerParameter::tile_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.tile_param)
+ return tile_param_ != NULL ? *tile_param_
+ : *::caffe::TileParameter::internal_default_instance();
+}
+inline ::caffe::TileParameter* LayerParameter::mutable_tile_param() {
+ set_has_tile_param();
+ if (tile_param_ == NULL) {
+ tile_param_ = new ::caffe::TileParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.tile_param)
+ return tile_param_;
+}
+inline ::caffe::TileParameter* LayerParameter::release_tile_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.tile_param)
+ clear_has_tile_param();
+ ::caffe::TileParameter* temp = tile_param_;
+ tile_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_tile_param(::caffe::TileParameter* tile_param) {
+ delete tile_param_;
+ tile_param_ = tile_param;
+ if (tile_param) {
+ set_has_tile_param();
+ } else {
+ clear_has_tile_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.tile_param)
+}
+
+// optional .caffe.WindowDataParameter window_data_param = 129;
+inline bool LayerParameter::has_window_data_param() const {
+ return (_has_bits_[1] & 0x20000000u) != 0;
+}
+inline void LayerParameter::set_has_window_data_param() {
+ _has_bits_[1] |= 0x20000000u;
+}
+inline void LayerParameter::clear_has_window_data_param() {
+ _has_bits_[1] &= ~0x20000000u;
+}
+inline void LayerParameter::clear_window_data_param() {
+ if (window_data_param_ != NULL) window_data_param_->::caffe::WindowDataParameter::Clear();
+ clear_has_window_data_param();
+}
+inline const ::caffe::WindowDataParameter& LayerParameter::window_data_param() const {
+ // @@protoc_insertion_point(field_get:caffe.LayerParameter.window_data_param)
+ return window_data_param_ != NULL ? *window_data_param_
+ : *::caffe::WindowDataParameter::internal_default_instance();
+}
+inline ::caffe::WindowDataParameter* LayerParameter::mutable_window_data_param() {
+ set_has_window_data_param();
+ if (window_data_param_ == NULL) {
+ window_data_param_ = new ::caffe::WindowDataParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.LayerParameter.window_data_param)
+ return window_data_param_;
+}
+inline ::caffe::WindowDataParameter* LayerParameter::release_window_data_param() {
+ // @@protoc_insertion_point(field_release:caffe.LayerParameter.window_data_param)
+ clear_has_window_data_param();
+ ::caffe::WindowDataParameter* temp = window_data_param_;
+ window_data_param_ = NULL;
+ return temp;
+}
+inline void LayerParameter::set_allocated_window_data_param(::caffe::WindowDataParameter* window_data_param) {
+ delete window_data_param_;
+ window_data_param_ = window_data_param;
+ if (window_data_param) {
+ set_has_window_data_param();
+ } else {
+ clear_has_window_data_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.LayerParameter.window_data_param)
+}
+
+inline const LayerParameter* LayerParameter::internal_default_instance() {
+ return &LayerParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// TransformationParameter
+
+// optional float scale = 1 [default = 1];
+inline bool TransformationParameter::has_scale() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void TransformationParameter::set_has_scale() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void TransformationParameter::clear_has_scale() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void TransformationParameter::clear_scale() {
+ scale_ = 1;
+ clear_has_scale();
+}
+inline float TransformationParameter::scale() const {
+ // @@protoc_insertion_point(field_get:caffe.TransformationParameter.scale)
+ return scale_;
+}
+inline void TransformationParameter::set_scale(float value) {
+ set_has_scale();
+ scale_ = value;
+ // @@protoc_insertion_point(field_set:caffe.TransformationParameter.scale)
+}
+
+// optional bool mirror = 2 [default = false];
+inline bool TransformationParameter::has_mirror() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void TransformationParameter::set_has_mirror() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void TransformationParameter::clear_has_mirror() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void TransformationParameter::clear_mirror() {
+ mirror_ = false;
+ clear_has_mirror();
+}
+inline bool TransformationParameter::mirror() const {
+ // @@protoc_insertion_point(field_get:caffe.TransformationParameter.mirror)
+ return mirror_;
+}
+inline void TransformationParameter::set_mirror(bool value) {
+ set_has_mirror();
+ mirror_ = value;
+ // @@protoc_insertion_point(field_set:caffe.TransformationParameter.mirror)
+}
+
+// optional uint32 crop_size = 3 [default = 0];
+inline bool TransformationParameter::has_crop_size() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void TransformationParameter::set_has_crop_size() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void TransformationParameter::clear_has_crop_size() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void TransformationParameter::clear_crop_size() {
+ crop_size_ = 0u;
+ clear_has_crop_size();
+}
+inline ::google::protobuf::uint32 TransformationParameter::crop_size() const {
+ // @@protoc_insertion_point(field_get:caffe.TransformationParameter.crop_size)
+ return crop_size_;
+}
+inline void TransformationParameter::set_crop_size(::google::protobuf::uint32 value) {
+ set_has_crop_size();
+ crop_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.TransformationParameter.crop_size)
+}
+
+// optional string mean_file = 4;
+inline bool TransformationParameter::has_mean_file() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void TransformationParameter::set_has_mean_file() {
+ _has_bits_[0] |= 0x00000008u;
+}
+inline void TransformationParameter::clear_has_mean_file() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+inline void TransformationParameter::clear_mean_file() {
+ mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_mean_file();
+}
+inline const ::std::string& TransformationParameter::mean_file() const {
+ // @@protoc_insertion_point(field_get:caffe.TransformationParameter.mean_file)
+ return mean_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void TransformationParameter::set_mean_file(const ::std::string& value) {
+ set_has_mean_file();
+ mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.TransformationParameter.mean_file)
+}
+inline void TransformationParameter::set_mean_file(const char* value) {
+ set_has_mean_file();
+ mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.TransformationParameter.mean_file)
+}
+inline void TransformationParameter::set_mean_file(const char* value, size_t size) {
+ set_has_mean_file();
+ mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.TransformationParameter.mean_file)
+}
+inline ::std::string* TransformationParameter::mutable_mean_file() {
+ set_has_mean_file();
+ // @@protoc_insertion_point(field_mutable:caffe.TransformationParameter.mean_file)
+ return mean_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* TransformationParameter::release_mean_file() {
+ // @@protoc_insertion_point(field_release:caffe.TransformationParameter.mean_file)
+ clear_has_mean_file();
+ return mean_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void TransformationParameter::set_allocated_mean_file(::std::string* mean_file) {
+ if (mean_file != NULL) {
+ set_has_mean_file();
+ } else {
+ clear_has_mean_file();
+ }
+ mean_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), mean_file);
+ // @@protoc_insertion_point(field_set_allocated:caffe.TransformationParameter.mean_file)
+}
+
+// repeated float mean_value = 5;
+inline int TransformationParameter::mean_value_size() const {
+ return mean_value_.size();
+}
+inline void TransformationParameter::clear_mean_value() {
+ mean_value_.Clear();
+}
+inline float TransformationParameter::mean_value(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.TransformationParameter.mean_value)
+ return mean_value_.Get(index);
+}
+inline void TransformationParameter::set_mean_value(int index, float value) {
+ mean_value_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.TransformationParameter.mean_value)
+}
+inline void TransformationParameter::add_mean_value(float value) {
+ mean_value_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.TransformationParameter.mean_value)
+}
+inline const ::google::protobuf::RepeatedField< float >&
+TransformationParameter::mean_value() const {
+ // @@protoc_insertion_point(field_list:caffe.TransformationParameter.mean_value)
+ return mean_value_;
+}
+inline ::google::protobuf::RepeatedField< float >*
+TransformationParameter::mutable_mean_value() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.TransformationParameter.mean_value)
+ return &mean_value_;
+}
+
+// optional bool force_color = 6 [default = false];
+inline bool TransformationParameter::has_force_color() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+inline void TransformationParameter::set_has_force_color() {
+ _has_bits_[0] |= 0x00000020u;
+}
+inline void TransformationParameter::clear_has_force_color() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+inline void TransformationParameter::clear_force_color() {
+ force_color_ = false;
+ clear_has_force_color();
+}
+inline bool TransformationParameter::force_color() const {
+ // @@protoc_insertion_point(field_get:caffe.TransformationParameter.force_color)
+ return force_color_;
+}
+inline void TransformationParameter::set_force_color(bool value) {
+ set_has_force_color();
+ force_color_ = value;
+ // @@protoc_insertion_point(field_set:caffe.TransformationParameter.force_color)
+}
+
+// optional bool force_gray = 7 [default = false];
+inline bool TransformationParameter::has_force_gray() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+inline void TransformationParameter::set_has_force_gray() {
+ _has_bits_[0] |= 0x00000040u;
+}
+inline void TransformationParameter::clear_has_force_gray() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+inline void TransformationParameter::clear_force_gray() {
+ force_gray_ = false;
+ clear_has_force_gray();
+}
+inline bool TransformationParameter::force_gray() const {
+ // @@protoc_insertion_point(field_get:caffe.TransformationParameter.force_gray)
+ return force_gray_;
+}
+inline void TransformationParameter::set_force_gray(bool value) {
+ set_has_force_gray();
+ force_gray_ = value;
+ // @@protoc_insertion_point(field_set:caffe.TransformationParameter.force_gray)
+}
+
+inline const TransformationParameter* TransformationParameter::internal_default_instance() {
+ return &TransformationParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// LossParameter
+
+// optional int32 ignore_label = 1;
+inline bool LossParameter::has_ignore_label() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void LossParameter::set_has_ignore_label() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void LossParameter::clear_has_ignore_label() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void LossParameter::clear_ignore_label() {
+ ignore_label_ = 0;
+ clear_has_ignore_label();
+}
+inline ::google::protobuf::int32 LossParameter::ignore_label() const {
+ // @@protoc_insertion_point(field_get:caffe.LossParameter.ignore_label)
+ return ignore_label_;
+}
+inline void LossParameter::set_ignore_label(::google::protobuf::int32 value) {
+ set_has_ignore_label();
+ ignore_label_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LossParameter.ignore_label)
+}
+
+// optional .caffe.LossParameter.NormalizationMode normalization = 3 [default = VALID];
+inline bool LossParameter::has_normalization() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void LossParameter::set_has_normalization() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void LossParameter::clear_has_normalization() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void LossParameter::clear_normalization() {
+ normalization_ = 1;
+ clear_has_normalization();
+}
+inline ::caffe::LossParameter_NormalizationMode LossParameter::normalization() const {
+ // @@protoc_insertion_point(field_get:caffe.LossParameter.normalization)
+ return static_cast< ::caffe::LossParameter_NormalizationMode >(normalization_);
+}
+inline void LossParameter::set_normalization(::caffe::LossParameter_NormalizationMode value) {
+ assert(::caffe::LossParameter_NormalizationMode_IsValid(value));
+ set_has_normalization();
+ normalization_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LossParameter.normalization)
+}
+
+// optional bool normalize = 2;
+inline bool LossParameter::has_normalize() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void LossParameter::set_has_normalize() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void LossParameter::clear_has_normalize() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void LossParameter::clear_normalize() {
+ normalize_ = false;
+ clear_has_normalize();
+}
+inline bool LossParameter::normalize() const {
+ // @@protoc_insertion_point(field_get:caffe.LossParameter.normalize)
+ return normalize_;
+}
+inline void LossParameter::set_normalize(bool value) {
+ set_has_normalize();
+ normalize_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LossParameter.normalize)
+}
+
+inline const LossParameter* LossParameter::internal_default_instance() {
+ return &LossParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// AccuracyParameter
+
+// optional uint32 top_k = 1 [default = 1];
+inline bool AccuracyParameter::has_top_k() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void AccuracyParameter::set_has_top_k() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void AccuracyParameter::clear_has_top_k() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void AccuracyParameter::clear_top_k() {
+ top_k_ = 1u;
+ clear_has_top_k();
+}
+inline ::google::protobuf::uint32 AccuracyParameter::top_k() const {
+ // @@protoc_insertion_point(field_get:caffe.AccuracyParameter.top_k)
+ return top_k_;
+}
+inline void AccuracyParameter::set_top_k(::google::protobuf::uint32 value) {
+ set_has_top_k();
+ top_k_ = value;
+ // @@protoc_insertion_point(field_set:caffe.AccuracyParameter.top_k)
+}
+
+// optional int32 axis = 2 [default = 1];
+inline bool AccuracyParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void AccuracyParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void AccuracyParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void AccuracyParameter::clear_axis() {
+ axis_ = 1;
+ clear_has_axis();
+}
+inline ::google::protobuf::int32 AccuracyParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.AccuracyParameter.axis)
+ return axis_;
+}
+inline void AccuracyParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.AccuracyParameter.axis)
+}
+
+// optional int32 ignore_label = 3;
+inline bool AccuracyParameter::has_ignore_label() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void AccuracyParameter::set_has_ignore_label() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void AccuracyParameter::clear_has_ignore_label() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void AccuracyParameter::clear_ignore_label() {
+ ignore_label_ = 0;
+ clear_has_ignore_label();
+}
+inline ::google::protobuf::int32 AccuracyParameter::ignore_label() const {
+ // @@protoc_insertion_point(field_get:caffe.AccuracyParameter.ignore_label)
+ return ignore_label_;
+}
+inline void AccuracyParameter::set_ignore_label(::google::protobuf::int32 value) {
+ set_has_ignore_label();
+ ignore_label_ = value;
+ // @@protoc_insertion_point(field_set:caffe.AccuracyParameter.ignore_label)
+}
+
+inline const AccuracyParameter* AccuracyParameter::internal_default_instance() {
+ return &AccuracyParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// ArgMaxParameter
+
+// optional bool out_max_val = 1 [default = false];
+inline bool ArgMaxParameter::has_out_max_val() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void ArgMaxParameter::set_has_out_max_val() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void ArgMaxParameter::clear_has_out_max_val() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void ArgMaxParameter::clear_out_max_val() {
+ out_max_val_ = false;
+ clear_has_out_max_val();
+}
+inline bool ArgMaxParameter::out_max_val() const {
+ // @@protoc_insertion_point(field_get:caffe.ArgMaxParameter.out_max_val)
+ return out_max_val_;
+}
+inline void ArgMaxParameter::set_out_max_val(bool value) {
+ set_has_out_max_val();
+ out_max_val_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ArgMaxParameter.out_max_val)
+}
+
+// optional uint32 top_k = 2 [default = 1];
+inline bool ArgMaxParameter::has_top_k() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void ArgMaxParameter::set_has_top_k() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void ArgMaxParameter::clear_has_top_k() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void ArgMaxParameter::clear_top_k() {
+ top_k_ = 1u;
+ clear_has_top_k();
+}
+inline ::google::protobuf::uint32 ArgMaxParameter::top_k() const {
+ // @@protoc_insertion_point(field_get:caffe.ArgMaxParameter.top_k)
+ return top_k_;
+}
+inline void ArgMaxParameter::set_top_k(::google::protobuf::uint32 value) {
+ set_has_top_k();
+ top_k_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ArgMaxParameter.top_k)
+}
+
+// optional int32 axis = 3;
+inline bool ArgMaxParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void ArgMaxParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void ArgMaxParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void ArgMaxParameter::clear_axis() {
+ axis_ = 0;
+ clear_has_axis();
+}
+inline ::google::protobuf::int32 ArgMaxParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.ArgMaxParameter.axis)
+ return axis_;
+}
+inline void ArgMaxParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ArgMaxParameter.axis)
+}
+
+inline const ArgMaxParameter* ArgMaxParameter::internal_default_instance() {
+ return &ArgMaxParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// ConcatParameter
+
+// optional int32 axis = 2 [default = 1];
+inline bool ConcatParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void ConcatParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void ConcatParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void ConcatParameter::clear_axis() {
+ axis_ = 1;
+ clear_has_axis();
+}
+inline ::google::protobuf::int32 ConcatParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.ConcatParameter.axis)
+ return axis_;
+}
+inline void ConcatParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConcatParameter.axis)
+}
+
+// optional uint32 concat_dim = 1 [default = 1];
+inline bool ConcatParameter::has_concat_dim() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void ConcatParameter::set_has_concat_dim() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void ConcatParameter::clear_has_concat_dim() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void ConcatParameter::clear_concat_dim() {
+ concat_dim_ = 1u;
+ clear_has_concat_dim();
+}
+inline ::google::protobuf::uint32 ConcatParameter::concat_dim() const {
+ // @@protoc_insertion_point(field_get:caffe.ConcatParameter.concat_dim)
+ return concat_dim_;
+}
+inline void ConcatParameter::set_concat_dim(::google::protobuf::uint32 value) {
+ set_has_concat_dim();
+ concat_dim_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConcatParameter.concat_dim)
+}
+
+inline const ConcatParameter* ConcatParameter::internal_default_instance() {
+ return &ConcatParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// BatchNormParameter
+
+// optional bool use_global_stats = 1;
+inline bool BatchNormParameter::has_use_global_stats() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void BatchNormParameter::set_has_use_global_stats() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void BatchNormParameter::clear_has_use_global_stats() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void BatchNormParameter::clear_use_global_stats() {
+ use_global_stats_ = false;
+ clear_has_use_global_stats();
+}
+inline bool BatchNormParameter::use_global_stats() const {
+ // @@protoc_insertion_point(field_get:caffe.BatchNormParameter.use_global_stats)
+ return use_global_stats_;
+}
+inline void BatchNormParameter::set_use_global_stats(bool value) {
+ set_has_use_global_stats();
+ use_global_stats_ = value;
+ // @@protoc_insertion_point(field_set:caffe.BatchNormParameter.use_global_stats)
+}
+
+// optional float moving_average_fraction = 2 [default = 0.999];
+inline bool BatchNormParameter::has_moving_average_fraction() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void BatchNormParameter::set_has_moving_average_fraction() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void BatchNormParameter::clear_has_moving_average_fraction() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void BatchNormParameter::clear_moving_average_fraction() {
+ moving_average_fraction_ = 0.999f;
+ clear_has_moving_average_fraction();
+}
+inline float BatchNormParameter::moving_average_fraction() const {
+ // @@protoc_insertion_point(field_get:caffe.BatchNormParameter.moving_average_fraction)
+ return moving_average_fraction_;
+}
+inline void BatchNormParameter::set_moving_average_fraction(float value) {
+ set_has_moving_average_fraction();
+ moving_average_fraction_ = value;
+ // @@protoc_insertion_point(field_set:caffe.BatchNormParameter.moving_average_fraction)
+}
+
+// optional float eps = 3 [default = 1e-05];
+inline bool BatchNormParameter::has_eps() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void BatchNormParameter::set_has_eps() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void BatchNormParameter::clear_has_eps() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void BatchNormParameter::clear_eps() {
+ eps_ = 1e-05f;
+ clear_has_eps();
+}
+inline float BatchNormParameter::eps() const {
+ // @@protoc_insertion_point(field_get:caffe.BatchNormParameter.eps)
+ return eps_;
+}
+inline void BatchNormParameter::set_eps(float value) {
+ set_has_eps();
+ eps_ = value;
+ // @@protoc_insertion_point(field_set:caffe.BatchNormParameter.eps)
+}
+
+inline const BatchNormParameter* BatchNormParameter::internal_default_instance() {
+ return &BatchNormParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// BiasParameter
+
+// optional int32 axis = 1 [default = 1];
+inline bool BiasParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void BiasParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void BiasParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void BiasParameter::clear_axis() {
+ axis_ = 1;
+ clear_has_axis();
+}
+inline ::google::protobuf::int32 BiasParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.BiasParameter.axis)
+ return axis_;
+}
+inline void BiasParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.BiasParameter.axis)
+}
+
+// optional int32 num_axes = 2 [default = 1];
+inline bool BiasParameter::has_num_axes() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void BiasParameter::set_has_num_axes() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void BiasParameter::clear_has_num_axes() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void BiasParameter::clear_num_axes() {
+ num_axes_ = 1;
+ clear_has_num_axes();
+}
+inline ::google::protobuf::int32 BiasParameter::num_axes() const {
+ // @@protoc_insertion_point(field_get:caffe.BiasParameter.num_axes)
+ return num_axes_;
+}
+inline void BiasParameter::set_num_axes(::google::protobuf::int32 value) {
+ set_has_num_axes();
+ num_axes_ = value;
+ // @@protoc_insertion_point(field_set:caffe.BiasParameter.num_axes)
+}
+
+// optional .caffe.FillerParameter filler = 3;
+inline bool BiasParameter::has_filler() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void BiasParameter::set_has_filler() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void BiasParameter::clear_has_filler() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void BiasParameter::clear_filler() {
+ if (filler_ != NULL) filler_->::caffe::FillerParameter::Clear();
+ clear_has_filler();
+}
+inline const ::caffe::FillerParameter& BiasParameter::filler() const {
+ // @@protoc_insertion_point(field_get:caffe.BiasParameter.filler)
+ return filler_ != NULL ? *filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+inline ::caffe::FillerParameter* BiasParameter::mutable_filler() {
+ set_has_filler();
+ if (filler_ == NULL) {
+ filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.BiasParameter.filler)
+ return filler_;
+}
+inline ::caffe::FillerParameter* BiasParameter::release_filler() {
+ // @@protoc_insertion_point(field_release:caffe.BiasParameter.filler)
+ clear_has_filler();
+ ::caffe::FillerParameter* temp = filler_;
+ filler_ = NULL;
+ return temp;
+}
+inline void BiasParameter::set_allocated_filler(::caffe::FillerParameter* filler) {
+ delete filler_;
+ filler_ = filler;
+ if (filler) {
+ set_has_filler();
+ } else {
+ clear_has_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.BiasParameter.filler)
+}
+
+inline const BiasParameter* BiasParameter::internal_default_instance() {
+ return &BiasParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// ContrastiveLossParameter
+
+// optional float margin = 1 [default = 1];
+inline bool ContrastiveLossParameter::has_margin() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void ContrastiveLossParameter::set_has_margin() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void ContrastiveLossParameter::clear_has_margin() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void ContrastiveLossParameter::clear_margin() {
+ margin_ = 1;
+ clear_has_margin();
+}
+inline float ContrastiveLossParameter::margin() const {
+ // @@protoc_insertion_point(field_get:caffe.ContrastiveLossParameter.margin)
+ return margin_;
+}
+inline void ContrastiveLossParameter::set_margin(float value) {
+ set_has_margin();
+ margin_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ContrastiveLossParameter.margin)
+}
+
+// optional bool legacy_version = 2 [default = false];
+inline bool ContrastiveLossParameter::has_legacy_version() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void ContrastiveLossParameter::set_has_legacy_version() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void ContrastiveLossParameter::clear_has_legacy_version() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void ContrastiveLossParameter::clear_legacy_version() {
+ legacy_version_ = false;
+ clear_has_legacy_version();
+}
+inline bool ContrastiveLossParameter::legacy_version() const {
+ // @@protoc_insertion_point(field_get:caffe.ContrastiveLossParameter.legacy_version)
+ return legacy_version_;
+}
+inline void ContrastiveLossParameter::set_legacy_version(bool value) {
+ set_has_legacy_version();
+ legacy_version_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ContrastiveLossParameter.legacy_version)
+}
+
+inline const ContrastiveLossParameter* ContrastiveLossParameter::internal_default_instance() {
+ return &ContrastiveLossParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// ConvolutionParameter
+
+// optional uint32 num_output = 1;
+inline bool ConvolutionParameter::has_num_output() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void ConvolutionParameter::set_has_num_output() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void ConvolutionParameter::clear_has_num_output() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void ConvolutionParameter::clear_num_output() {
+ num_output_ = 0u;
+ clear_has_num_output();
+}
+inline ::google::protobuf::uint32 ConvolutionParameter::num_output() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.num_output)
+ return num_output_;
+}
+inline void ConvolutionParameter::set_num_output(::google::protobuf::uint32 value) {
+ set_has_num_output();
+ num_output_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.num_output)
+}
+
+// optional bool bias_term = 2 [default = true];
+inline bool ConvolutionParameter::has_bias_term() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void ConvolutionParameter::set_has_bias_term() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void ConvolutionParameter::clear_has_bias_term() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void ConvolutionParameter::clear_bias_term() {
+ bias_term_ = true;
+ clear_has_bias_term();
+}
+inline bool ConvolutionParameter::bias_term() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.bias_term)
+ return bias_term_;
+}
+inline void ConvolutionParameter::set_bias_term(bool value) {
+ set_has_bias_term();
+ bias_term_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.bias_term)
+}
+
+// repeated uint32 pad = 3;
+inline int ConvolutionParameter::pad_size() const {
+ return pad_.size();
+}
+inline void ConvolutionParameter::clear_pad() {
+ pad_.Clear();
+}
+inline ::google::protobuf::uint32 ConvolutionParameter::pad(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.pad)
+ return pad_.Get(index);
+}
+inline void ConvolutionParameter::set_pad(int index, ::google::protobuf::uint32 value) {
+ pad_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.pad)
+}
+inline void ConvolutionParameter::add_pad(::google::protobuf::uint32 value) {
+ pad_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.ConvolutionParameter.pad)
+}
+inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+ConvolutionParameter::pad() const {
+ // @@protoc_insertion_point(field_list:caffe.ConvolutionParameter.pad)
+ return pad_;
+}
+inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+ConvolutionParameter::mutable_pad() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.ConvolutionParameter.pad)
+ return &pad_;
+}
+
+// repeated uint32 kernel_size = 4;
+inline int ConvolutionParameter::kernel_size_size() const {
+ return kernel_size_.size();
+}
+inline void ConvolutionParameter::clear_kernel_size() {
+ kernel_size_.Clear();
+}
+inline ::google::protobuf::uint32 ConvolutionParameter::kernel_size(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.kernel_size)
+ return kernel_size_.Get(index);
+}
+inline void ConvolutionParameter::set_kernel_size(int index, ::google::protobuf::uint32 value) {
+ kernel_size_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.kernel_size)
+}
+inline void ConvolutionParameter::add_kernel_size(::google::protobuf::uint32 value) {
+ kernel_size_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.ConvolutionParameter.kernel_size)
+}
+inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+ConvolutionParameter::kernel_size() const {
+ // @@protoc_insertion_point(field_list:caffe.ConvolutionParameter.kernel_size)
+ return kernel_size_;
+}
+inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+ConvolutionParameter::mutable_kernel_size() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.ConvolutionParameter.kernel_size)
+ return &kernel_size_;
+}
+
+// repeated uint32 stride = 6;
+inline int ConvolutionParameter::stride_size() const {
+ return stride_.size();
+}
+inline void ConvolutionParameter::clear_stride() {
+ stride_.Clear();
+}
+inline ::google::protobuf::uint32 ConvolutionParameter::stride(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.stride)
+ return stride_.Get(index);
+}
+inline void ConvolutionParameter::set_stride(int index, ::google::protobuf::uint32 value) {
+ stride_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.stride)
+}
+inline void ConvolutionParameter::add_stride(::google::protobuf::uint32 value) {
+ stride_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.ConvolutionParameter.stride)
+}
+inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+ConvolutionParameter::stride() const {
+ // @@protoc_insertion_point(field_list:caffe.ConvolutionParameter.stride)
+ return stride_;
+}
+inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+ConvolutionParameter::mutable_stride() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.ConvolutionParameter.stride)
+ return &stride_;
+}
+
+// repeated uint32 dilation = 18;
+inline int ConvolutionParameter::dilation_size() const {
+ return dilation_.size();
+}
+inline void ConvolutionParameter::clear_dilation() {
+ dilation_.Clear();
+}
+inline ::google::protobuf::uint32 ConvolutionParameter::dilation(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.dilation)
+ return dilation_.Get(index);
+}
+inline void ConvolutionParameter::set_dilation(int index, ::google::protobuf::uint32 value) {
+ dilation_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.dilation)
+}
+inline void ConvolutionParameter::add_dilation(::google::protobuf::uint32 value) {
+ dilation_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.ConvolutionParameter.dilation)
+}
+inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+ConvolutionParameter::dilation() const {
+ // @@protoc_insertion_point(field_list:caffe.ConvolutionParameter.dilation)
+ return dilation_;
+}
+inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+ConvolutionParameter::mutable_dilation() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.ConvolutionParameter.dilation)
+ return &dilation_;
+}
+
+// optional uint32 pad_h = 9 [default = 0];
+inline bool ConvolutionParameter::has_pad_h() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+inline void ConvolutionParameter::set_has_pad_h() {
+ _has_bits_[0] |= 0x00000040u;
+}
+inline void ConvolutionParameter::clear_has_pad_h() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+inline void ConvolutionParameter::clear_pad_h() {
+ pad_h_ = 0u;
+ clear_has_pad_h();
+}
+inline ::google::protobuf::uint32 ConvolutionParameter::pad_h() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.pad_h)
+ return pad_h_;
+}
+inline void ConvolutionParameter::set_pad_h(::google::protobuf::uint32 value) {
+ set_has_pad_h();
+ pad_h_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.pad_h)
+}
+
+// optional uint32 pad_w = 10 [default = 0];
+inline bool ConvolutionParameter::has_pad_w() const {
+ return (_has_bits_[0] & 0x00000080u) != 0;
+}
+inline void ConvolutionParameter::set_has_pad_w() {
+ _has_bits_[0] |= 0x00000080u;
+}
+inline void ConvolutionParameter::clear_has_pad_w() {
+ _has_bits_[0] &= ~0x00000080u;
+}
+inline void ConvolutionParameter::clear_pad_w() {
+ pad_w_ = 0u;
+ clear_has_pad_w();
+}
+inline ::google::protobuf::uint32 ConvolutionParameter::pad_w() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.pad_w)
+ return pad_w_;
+}
+inline void ConvolutionParameter::set_pad_w(::google::protobuf::uint32 value) {
+ set_has_pad_w();
+ pad_w_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.pad_w)
+}
+
+// optional uint32 kernel_h = 11;
+inline bool ConvolutionParameter::has_kernel_h() const {
+ return (_has_bits_[0] & 0x00000100u) != 0;
+}
+inline void ConvolutionParameter::set_has_kernel_h() {
+ _has_bits_[0] |= 0x00000100u;
+}
+inline void ConvolutionParameter::clear_has_kernel_h() {
+ _has_bits_[0] &= ~0x00000100u;
+}
+inline void ConvolutionParameter::clear_kernel_h() {
+ kernel_h_ = 0u;
+ clear_has_kernel_h();
+}
+inline ::google::protobuf::uint32 ConvolutionParameter::kernel_h() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.kernel_h)
+ return kernel_h_;
+}
+inline void ConvolutionParameter::set_kernel_h(::google::protobuf::uint32 value) {
+ set_has_kernel_h();
+ kernel_h_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.kernel_h)
+}
+
+// optional uint32 kernel_w = 12;
+inline bool ConvolutionParameter::has_kernel_w() const {
+ return (_has_bits_[0] & 0x00000200u) != 0;
+}
+inline void ConvolutionParameter::set_has_kernel_w() {
+ _has_bits_[0] |= 0x00000200u;
+}
+inline void ConvolutionParameter::clear_has_kernel_w() {
+ _has_bits_[0] &= ~0x00000200u;
+}
+inline void ConvolutionParameter::clear_kernel_w() {
+ kernel_w_ = 0u;
+ clear_has_kernel_w();
+}
+inline ::google::protobuf::uint32 ConvolutionParameter::kernel_w() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.kernel_w)
+ return kernel_w_;
+}
+inline void ConvolutionParameter::set_kernel_w(::google::protobuf::uint32 value) {
+ set_has_kernel_w();
+ kernel_w_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.kernel_w)
+}
+
+// optional uint32 stride_h = 13;
+inline bool ConvolutionParameter::has_stride_h() const {
+ return (_has_bits_[0] & 0x00000400u) != 0;
+}
+inline void ConvolutionParameter::set_has_stride_h() {
+ _has_bits_[0] |= 0x00000400u;
+}
+inline void ConvolutionParameter::clear_has_stride_h() {
+ _has_bits_[0] &= ~0x00000400u;
+}
+inline void ConvolutionParameter::clear_stride_h() {
+ stride_h_ = 0u;
+ clear_has_stride_h();
+}
+inline ::google::protobuf::uint32 ConvolutionParameter::stride_h() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.stride_h)
+ return stride_h_;
+}
+inline void ConvolutionParameter::set_stride_h(::google::protobuf::uint32 value) {
+ set_has_stride_h();
+ stride_h_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.stride_h)
+}
+
+// optional uint32 stride_w = 14;
+inline bool ConvolutionParameter::has_stride_w() const {
+ return (_has_bits_[0] & 0x00000800u) != 0;
+}
+inline void ConvolutionParameter::set_has_stride_w() {
+ _has_bits_[0] |= 0x00000800u;
+}
+inline void ConvolutionParameter::clear_has_stride_w() {
+ _has_bits_[0] &= ~0x00000800u;
+}
+inline void ConvolutionParameter::clear_stride_w() {
+ stride_w_ = 0u;
+ clear_has_stride_w();
+}
+inline ::google::protobuf::uint32 ConvolutionParameter::stride_w() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.stride_w)
+ return stride_w_;
+}
+inline void ConvolutionParameter::set_stride_w(::google::protobuf::uint32 value) {
+ set_has_stride_w();
+ stride_w_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.stride_w)
+}
+
+// optional uint32 group = 5 [default = 1];
+inline bool ConvolutionParameter::has_group() const {
+ return (_has_bits_[0] & 0x00001000u) != 0;
+}
+inline void ConvolutionParameter::set_has_group() {
+ _has_bits_[0] |= 0x00001000u;
+}
+inline void ConvolutionParameter::clear_has_group() {
+ _has_bits_[0] &= ~0x00001000u;
+}
+inline void ConvolutionParameter::clear_group() {
+ group_ = 1u;
+ clear_has_group();
+}
+inline ::google::protobuf::uint32 ConvolutionParameter::group() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.group)
+ return group_;
+}
+inline void ConvolutionParameter::set_group(::google::protobuf::uint32 value) {
+ set_has_group();
+ group_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.group)
+}
+
+// optional .caffe.FillerParameter weight_filler = 7;
+inline bool ConvolutionParameter::has_weight_filler() const {
+ return (_has_bits_[0] & 0x00002000u) != 0;
+}
+inline void ConvolutionParameter::set_has_weight_filler() {
+ _has_bits_[0] |= 0x00002000u;
+}
+inline void ConvolutionParameter::clear_has_weight_filler() {
+ _has_bits_[0] &= ~0x00002000u;
+}
+inline void ConvolutionParameter::clear_weight_filler() {
+ if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear();
+ clear_has_weight_filler();
+}
+inline const ::caffe::FillerParameter& ConvolutionParameter::weight_filler() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.weight_filler)
+ return weight_filler_ != NULL ? *weight_filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+inline ::caffe::FillerParameter* ConvolutionParameter::mutable_weight_filler() {
+ set_has_weight_filler();
+ if (weight_filler_ == NULL) {
+ weight_filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.ConvolutionParameter.weight_filler)
+ return weight_filler_;
+}
+inline ::caffe::FillerParameter* ConvolutionParameter::release_weight_filler() {
+ // @@protoc_insertion_point(field_release:caffe.ConvolutionParameter.weight_filler)
+ clear_has_weight_filler();
+ ::caffe::FillerParameter* temp = weight_filler_;
+ weight_filler_ = NULL;
+ return temp;
+}
+inline void ConvolutionParameter::set_allocated_weight_filler(::caffe::FillerParameter* weight_filler) {
+ delete weight_filler_;
+ weight_filler_ = weight_filler;
+ if (weight_filler) {
+ set_has_weight_filler();
+ } else {
+ clear_has_weight_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.ConvolutionParameter.weight_filler)
+}
+
+// optional .caffe.FillerParameter bias_filler = 8;
+inline bool ConvolutionParameter::has_bias_filler() const {
+ return (_has_bits_[0] & 0x00004000u) != 0;
+}
+inline void ConvolutionParameter::set_has_bias_filler() {
+ _has_bits_[0] |= 0x00004000u;
+}
+inline void ConvolutionParameter::clear_has_bias_filler() {
+ _has_bits_[0] &= ~0x00004000u;
+}
+inline void ConvolutionParameter::clear_bias_filler() {
+ if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
+ clear_has_bias_filler();
+}
+inline const ::caffe::FillerParameter& ConvolutionParameter::bias_filler() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.bias_filler)
+ return bias_filler_ != NULL ? *bias_filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+inline ::caffe::FillerParameter* ConvolutionParameter::mutable_bias_filler() {
+ set_has_bias_filler();
+ if (bias_filler_ == NULL) {
+ bias_filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.ConvolutionParameter.bias_filler)
+ return bias_filler_;
+}
+inline ::caffe::FillerParameter* ConvolutionParameter::release_bias_filler() {
+ // @@protoc_insertion_point(field_release:caffe.ConvolutionParameter.bias_filler)
+ clear_has_bias_filler();
+ ::caffe::FillerParameter* temp = bias_filler_;
+ bias_filler_ = NULL;
+ return temp;
+}
+inline void ConvolutionParameter::set_allocated_bias_filler(::caffe::FillerParameter* bias_filler) {
+ delete bias_filler_;
+ bias_filler_ = bias_filler;
+ if (bias_filler) {
+ set_has_bias_filler();
+ } else {
+ clear_has_bias_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.ConvolutionParameter.bias_filler)
+}
+
+// optional .caffe.ConvolutionParameter.Engine engine = 15 [default = DEFAULT];
+inline bool ConvolutionParameter::has_engine() const {
+ return (_has_bits_[0] & 0x00008000u) != 0;
+}
+inline void ConvolutionParameter::set_has_engine() {
+ _has_bits_[0] |= 0x00008000u;
+}
+inline void ConvolutionParameter::clear_has_engine() {
+ _has_bits_[0] &= ~0x00008000u;
+}
+inline void ConvolutionParameter::clear_engine() {
+ engine_ = 0;
+ clear_has_engine();
+}
+inline ::caffe::ConvolutionParameter_Engine ConvolutionParameter::engine() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.engine)
+ return static_cast< ::caffe::ConvolutionParameter_Engine >(engine_);
+}
+inline void ConvolutionParameter::set_engine(::caffe::ConvolutionParameter_Engine value) {
+ assert(::caffe::ConvolutionParameter_Engine_IsValid(value));
+ set_has_engine();
+ engine_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.engine)
+}
+
+// optional int32 axis = 16 [default = 1];
+inline bool ConvolutionParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00010000u) != 0;
+}
+inline void ConvolutionParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00010000u;
+}
+inline void ConvolutionParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00010000u;
+}
+inline void ConvolutionParameter::clear_axis() {
+ axis_ = 1;
+ clear_has_axis();
+}
+inline ::google::protobuf::int32 ConvolutionParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.axis)
+ return axis_;
+}
+inline void ConvolutionParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.axis)
+}
+
+// optional bool force_nd_im2col = 17 [default = false];
+inline bool ConvolutionParameter::has_force_nd_im2col() const {
+ return (_has_bits_[0] & 0x00020000u) != 0;
+}
+inline void ConvolutionParameter::set_has_force_nd_im2col() {
+ _has_bits_[0] |= 0x00020000u;
+}
+inline void ConvolutionParameter::clear_has_force_nd_im2col() {
+ _has_bits_[0] &= ~0x00020000u;
+}
+inline void ConvolutionParameter::clear_force_nd_im2col() {
+ force_nd_im2col_ = false;
+ clear_has_force_nd_im2col();
+}
+inline bool ConvolutionParameter::force_nd_im2col() const {
+ // @@protoc_insertion_point(field_get:caffe.ConvolutionParameter.force_nd_im2col)
+ return force_nd_im2col_;
+}
+inline void ConvolutionParameter::set_force_nd_im2col(bool value) {
+ set_has_force_nd_im2col();
+ force_nd_im2col_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ConvolutionParameter.force_nd_im2col)
+}
+
+inline const ConvolutionParameter* ConvolutionParameter::internal_default_instance() {
+ return &ConvolutionParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// CropParameter
+
+// optional int32 axis = 1 [default = 2];
+inline bool CropParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void CropParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void CropParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void CropParameter::clear_axis() {
+ axis_ = 2;
+ clear_has_axis();
+}
+inline ::google::protobuf::int32 CropParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.CropParameter.axis)
+ return axis_;
+}
+inline void CropParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.CropParameter.axis)
+}
+
+// repeated uint32 offset = 2;
+inline int CropParameter::offset_size() const {
+ return offset_.size();
+}
+inline void CropParameter::clear_offset() {
+ offset_.Clear();
+}
+inline ::google::protobuf::uint32 CropParameter::offset(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.CropParameter.offset)
+ return offset_.Get(index);
+}
+inline void CropParameter::set_offset(int index, ::google::protobuf::uint32 value) {
+ offset_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.CropParameter.offset)
+}
+inline void CropParameter::add_offset(::google::protobuf::uint32 value) {
+ offset_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.CropParameter.offset)
+}
+inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+CropParameter::offset() const {
+ // @@protoc_insertion_point(field_list:caffe.CropParameter.offset)
+ return offset_;
+}
+inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+CropParameter::mutable_offset() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.CropParameter.offset)
+ return &offset_;
+}
+
+inline const CropParameter* CropParameter::internal_default_instance() {
+ return &CropParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// DataParameter
+
+// optional string source = 1;
+inline bool DataParameter::has_source() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void DataParameter::set_has_source() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void DataParameter::clear_has_source() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void DataParameter::clear_source() {
+ source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_source();
+}
+inline const ::std::string& DataParameter::source() const {
+ // @@protoc_insertion_point(field_get:caffe.DataParameter.source)
+ return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void DataParameter::set_source(const ::std::string& value) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.DataParameter.source)
+}
+inline void DataParameter::set_source(const char* value) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.DataParameter.source)
+}
+inline void DataParameter::set_source(const char* value, size_t size) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.DataParameter.source)
+}
+inline ::std::string* DataParameter::mutable_source() {
+ set_has_source();
+ // @@protoc_insertion_point(field_mutable:caffe.DataParameter.source)
+ return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* DataParameter::release_source() {
+ // @@protoc_insertion_point(field_release:caffe.DataParameter.source)
+ clear_has_source();
+ return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void DataParameter::set_allocated_source(::std::string* source) {
+ if (source != NULL) {
+ set_has_source();
+ } else {
+ clear_has_source();
+ }
+ source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source);
+ // @@protoc_insertion_point(field_set_allocated:caffe.DataParameter.source)
+}
+
+// optional uint32 batch_size = 4;
+inline bool DataParameter::has_batch_size() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void DataParameter::set_has_batch_size() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void DataParameter::clear_has_batch_size() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void DataParameter::clear_batch_size() {
+ batch_size_ = 0u;
+ clear_has_batch_size();
+}
+inline ::google::protobuf::uint32 DataParameter::batch_size() const {
+ // @@protoc_insertion_point(field_get:caffe.DataParameter.batch_size)
+ return batch_size_;
+}
+inline void DataParameter::set_batch_size(::google::protobuf::uint32 value) {
+ set_has_batch_size();
+ batch_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DataParameter.batch_size)
+}
+
+// optional uint32 rand_skip = 7 [default = 0];
+inline bool DataParameter::has_rand_skip() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void DataParameter::set_has_rand_skip() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void DataParameter::clear_has_rand_skip() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void DataParameter::clear_rand_skip() {
+ rand_skip_ = 0u;
+ clear_has_rand_skip();
+}
+inline ::google::protobuf::uint32 DataParameter::rand_skip() const {
+ // @@protoc_insertion_point(field_get:caffe.DataParameter.rand_skip)
+ return rand_skip_;
+}
+inline void DataParameter::set_rand_skip(::google::protobuf::uint32 value) {
+ set_has_rand_skip();
+ rand_skip_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DataParameter.rand_skip)
+}
+
+// optional .caffe.DataParameter.DB backend = 8 [default = LEVELDB];
+inline bool DataParameter::has_backend() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void DataParameter::set_has_backend() {
+ _has_bits_[0] |= 0x00000008u;
+}
+inline void DataParameter::clear_has_backend() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+inline void DataParameter::clear_backend() {
+ backend_ = 0;
+ clear_has_backend();
+}
+inline ::caffe::DataParameter_DB DataParameter::backend() const {
+ // @@protoc_insertion_point(field_get:caffe.DataParameter.backend)
+ return static_cast< ::caffe::DataParameter_DB >(backend_);
+}
+inline void DataParameter::set_backend(::caffe::DataParameter_DB value) {
+ assert(::caffe::DataParameter_DB_IsValid(value));
+ set_has_backend();
+ backend_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DataParameter.backend)
+}
+
+// optional float scale = 2 [default = 1];
+inline bool DataParameter::has_scale() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+inline void DataParameter::set_has_scale() {
+ _has_bits_[0] |= 0x00000010u;
+}
+inline void DataParameter::clear_has_scale() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+inline void DataParameter::clear_scale() {
+ scale_ = 1;
+ clear_has_scale();
+}
+inline float DataParameter::scale() const {
+ // @@protoc_insertion_point(field_get:caffe.DataParameter.scale)
+ return scale_;
+}
+inline void DataParameter::set_scale(float value) {
+ set_has_scale();
+ scale_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DataParameter.scale)
+}
+
+// optional string mean_file = 3;
+inline bool DataParameter::has_mean_file() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+inline void DataParameter::set_has_mean_file() {
+ _has_bits_[0] |= 0x00000020u;
+}
+inline void DataParameter::clear_has_mean_file() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+inline void DataParameter::clear_mean_file() {
+ mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_mean_file();
+}
+inline const ::std::string& DataParameter::mean_file() const {
+ // @@protoc_insertion_point(field_get:caffe.DataParameter.mean_file)
+ return mean_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void DataParameter::set_mean_file(const ::std::string& value) {
+ set_has_mean_file();
+ mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.DataParameter.mean_file)
+}
+inline void DataParameter::set_mean_file(const char* value) {
+ set_has_mean_file();
+ mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.DataParameter.mean_file)
+}
+inline void DataParameter::set_mean_file(const char* value, size_t size) {
+ set_has_mean_file();
+ mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.DataParameter.mean_file)
+}
+inline ::std::string* DataParameter::mutable_mean_file() {
+ set_has_mean_file();
+ // @@protoc_insertion_point(field_mutable:caffe.DataParameter.mean_file)
+ return mean_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* DataParameter::release_mean_file() {
+ // @@protoc_insertion_point(field_release:caffe.DataParameter.mean_file)
+ clear_has_mean_file();
+ return mean_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void DataParameter::set_allocated_mean_file(::std::string* mean_file) {
+ if (mean_file != NULL) {
+ set_has_mean_file();
+ } else {
+ clear_has_mean_file();
+ }
+ mean_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), mean_file);
+ // @@protoc_insertion_point(field_set_allocated:caffe.DataParameter.mean_file)
+}
+
+// optional uint32 crop_size = 5 [default = 0];
+inline bool DataParameter::has_crop_size() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+inline void DataParameter::set_has_crop_size() {
+ _has_bits_[0] |= 0x00000040u;
+}
+inline void DataParameter::clear_has_crop_size() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+inline void DataParameter::clear_crop_size() {
+ crop_size_ = 0u;
+ clear_has_crop_size();
+}
+inline ::google::protobuf::uint32 DataParameter::crop_size() const {
+ // @@protoc_insertion_point(field_get:caffe.DataParameter.crop_size)
+ return crop_size_;
+}
+inline void DataParameter::set_crop_size(::google::protobuf::uint32 value) {
+ set_has_crop_size();
+ crop_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DataParameter.crop_size)
+}
+
+// optional bool mirror = 6 [default = false];
+inline bool DataParameter::has_mirror() const {
+ return (_has_bits_[0] & 0x00000080u) != 0;
+}
+inline void DataParameter::set_has_mirror() {
+ _has_bits_[0] |= 0x00000080u;
+}
+inline void DataParameter::clear_has_mirror() {
+ _has_bits_[0] &= ~0x00000080u;
+}
+inline void DataParameter::clear_mirror() {
+ mirror_ = false;
+ clear_has_mirror();
+}
+inline bool DataParameter::mirror() const {
+ // @@protoc_insertion_point(field_get:caffe.DataParameter.mirror)
+ return mirror_;
+}
+inline void DataParameter::set_mirror(bool value) {
+ set_has_mirror();
+ mirror_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DataParameter.mirror)
+}
+
+// optional bool force_encoded_color = 9 [default = false];
+inline bool DataParameter::has_force_encoded_color() const {
+ return (_has_bits_[0] & 0x00000100u) != 0;
+}
+inline void DataParameter::set_has_force_encoded_color() {
+ _has_bits_[0] |= 0x00000100u;
+}
+inline void DataParameter::clear_has_force_encoded_color() {
+ _has_bits_[0] &= ~0x00000100u;
+}
+inline void DataParameter::clear_force_encoded_color() {
+ force_encoded_color_ = false;
+ clear_has_force_encoded_color();
+}
+inline bool DataParameter::force_encoded_color() const {
+ // @@protoc_insertion_point(field_get:caffe.DataParameter.force_encoded_color)
+ return force_encoded_color_;
+}
+inline void DataParameter::set_force_encoded_color(bool value) {
+ set_has_force_encoded_color();
+ force_encoded_color_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DataParameter.force_encoded_color)
+}
+
+// optional uint32 prefetch = 10 [default = 4];
+inline bool DataParameter::has_prefetch() const {
+ return (_has_bits_[0] & 0x00000200u) != 0;
+}
+inline void DataParameter::set_has_prefetch() {
+ _has_bits_[0] |= 0x00000200u;
+}
+inline void DataParameter::clear_has_prefetch() {
+ _has_bits_[0] &= ~0x00000200u;
+}
+inline void DataParameter::clear_prefetch() {
+ prefetch_ = 4u;
+ clear_has_prefetch();
+}
+inline ::google::protobuf::uint32 DataParameter::prefetch() const {
+ // @@protoc_insertion_point(field_get:caffe.DataParameter.prefetch)
+ return prefetch_;
+}
+inline void DataParameter::set_prefetch(::google::protobuf::uint32 value) {
+ set_has_prefetch();
+ prefetch_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DataParameter.prefetch)
+}
+
+inline const DataParameter* DataParameter::internal_default_instance() {
+ return &DataParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// NonMaximumSuppressionParameter
+
+// optional float nms_threshold = 1 [default = 0.3];
+inline bool NonMaximumSuppressionParameter::has_nms_threshold() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void NonMaximumSuppressionParameter::set_has_nms_threshold() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void NonMaximumSuppressionParameter::clear_has_nms_threshold() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void NonMaximumSuppressionParameter::clear_nms_threshold() {
+ nms_threshold_ = 0.3f;
+ clear_has_nms_threshold();
+}
+inline float NonMaximumSuppressionParameter::nms_threshold() const {
+ // @@protoc_insertion_point(field_get:caffe.NonMaximumSuppressionParameter.nms_threshold)
+ return nms_threshold_;
+}
+inline void NonMaximumSuppressionParameter::set_nms_threshold(float value) {
+ set_has_nms_threshold();
+ nms_threshold_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NonMaximumSuppressionParameter.nms_threshold)
+}
+
+// optional int32 top_k = 2;
+inline bool NonMaximumSuppressionParameter::has_top_k() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void NonMaximumSuppressionParameter::set_has_top_k() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void NonMaximumSuppressionParameter::clear_has_top_k() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void NonMaximumSuppressionParameter::clear_top_k() {
+ top_k_ = 0;
+ clear_has_top_k();
+}
+inline ::google::protobuf::int32 NonMaximumSuppressionParameter::top_k() const {
+ // @@protoc_insertion_point(field_get:caffe.NonMaximumSuppressionParameter.top_k)
+ return top_k_;
+}
+inline void NonMaximumSuppressionParameter::set_top_k(::google::protobuf::int32 value) {
+ set_has_top_k();
+ top_k_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NonMaximumSuppressionParameter.top_k)
+}
+
+// optional float eta = 3 [default = 1];
+inline bool NonMaximumSuppressionParameter::has_eta() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void NonMaximumSuppressionParameter::set_has_eta() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void NonMaximumSuppressionParameter::clear_has_eta() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void NonMaximumSuppressionParameter::clear_eta() {
+ eta_ = 1;
+ clear_has_eta();
+}
+inline float NonMaximumSuppressionParameter::eta() const {
+ // @@protoc_insertion_point(field_get:caffe.NonMaximumSuppressionParameter.eta)
+ return eta_;
+}
+inline void NonMaximumSuppressionParameter::set_eta(float value) {
+ set_has_eta();
+ eta_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NonMaximumSuppressionParameter.eta)
+}
+
+inline const NonMaximumSuppressionParameter* NonMaximumSuppressionParameter::internal_default_instance() {
+ return &NonMaximumSuppressionParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// SaveOutputParameter
+
+// optional string output_directory = 1;
+inline bool SaveOutputParameter::has_output_directory() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void SaveOutputParameter::set_has_output_directory() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void SaveOutputParameter::clear_has_output_directory() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void SaveOutputParameter::clear_output_directory() {
+ output_directory_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_output_directory();
+}
+inline const ::std::string& SaveOutputParameter::output_directory() const {
+ // @@protoc_insertion_point(field_get:caffe.SaveOutputParameter.output_directory)
+ return output_directory_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void SaveOutputParameter::set_output_directory(const ::std::string& value) {
+ set_has_output_directory();
+ output_directory_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.SaveOutputParameter.output_directory)
+}
+inline void SaveOutputParameter::set_output_directory(const char* value) {
+ set_has_output_directory();
+ output_directory_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.SaveOutputParameter.output_directory)
+}
+inline void SaveOutputParameter::set_output_directory(const char* value, size_t size) {
+ set_has_output_directory();
+ output_directory_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.SaveOutputParameter.output_directory)
+}
+inline ::std::string* SaveOutputParameter::mutable_output_directory() {
+ set_has_output_directory();
+ // @@protoc_insertion_point(field_mutable:caffe.SaveOutputParameter.output_directory)
+ return output_directory_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* SaveOutputParameter::release_output_directory() {
+ // @@protoc_insertion_point(field_release:caffe.SaveOutputParameter.output_directory)
+ clear_has_output_directory();
+ return output_directory_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void SaveOutputParameter::set_allocated_output_directory(::std::string* output_directory) {
+ if (output_directory != NULL) {
+ set_has_output_directory();
+ } else {
+ clear_has_output_directory();
+ }
+ output_directory_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), output_directory);
+ // @@protoc_insertion_point(field_set_allocated:caffe.SaveOutputParameter.output_directory)
+}
+
+// optional string output_name_prefix = 2;
+inline bool SaveOutputParameter::has_output_name_prefix() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void SaveOutputParameter::set_has_output_name_prefix() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void SaveOutputParameter::clear_has_output_name_prefix() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void SaveOutputParameter::clear_output_name_prefix() {
+ output_name_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_output_name_prefix();
+}
+inline const ::std::string& SaveOutputParameter::output_name_prefix() const {
+ // @@protoc_insertion_point(field_get:caffe.SaveOutputParameter.output_name_prefix)
+ return output_name_prefix_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void SaveOutputParameter::set_output_name_prefix(const ::std::string& value) {
+ set_has_output_name_prefix();
+ output_name_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.SaveOutputParameter.output_name_prefix)
+}
+inline void SaveOutputParameter::set_output_name_prefix(const char* value) {
+ set_has_output_name_prefix();
+ output_name_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.SaveOutputParameter.output_name_prefix)
+}
+inline void SaveOutputParameter::set_output_name_prefix(const char* value, size_t size) {
+ set_has_output_name_prefix();
+ output_name_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.SaveOutputParameter.output_name_prefix)
+}
+inline ::std::string* SaveOutputParameter::mutable_output_name_prefix() {
+ set_has_output_name_prefix();
+ // @@protoc_insertion_point(field_mutable:caffe.SaveOutputParameter.output_name_prefix)
+ return output_name_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* SaveOutputParameter::release_output_name_prefix() {
+ // @@protoc_insertion_point(field_release:caffe.SaveOutputParameter.output_name_prefix)
+ clear_has_output_name_prefix();
+ return output_name_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void SaveOutputParameter::set_allocated_output_name_prefix(::std::string* output_name_prefix) {
+ if (output_name_prefix != NULL) {
+ set_has_output_name_prefix();
+ } else {
+ clear_has_output_name_prefix();
+ }
+ output_name_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), output_name_prefix);
+ // @@protoc_insertion_point(field_set_allocated:caffe.SaveOutputParameter.output_name_prefix)
+}
+
+// optional string output_format = 3;
+inline bool SaveOutputParameter::has_output_format() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void SaveOutputParameter::set_has_output_format() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void SaveOutputParameter::clear_has_output_format() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void SaveOutputParameter::clear_output_format() {
+ output_format_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_output_format();
+}
+inline const ::std::string& SaveOutputParameter::output_format() const {
+ // @@protoc_insertion_point(field_get:caffe.SaveOutputParameter.output_format)
+ return output_format_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void SaveOutputParameter::set_output_format(const ::std::string& value) {
+ set_has_output_format();
+ output_format_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.SaveOutputParameter.output_format)
+}
+inline void SaveOutputParameter::set_output_format(const char* value) {
+ set_has_output_format();
+ output_format_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.SaveOutputParameter.output_format)
+}
+inline void SaveOutputParameter::set_output_format(const char* value, size_t size) {
+ set_has_output_format();
+ output_format_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.SaveOutputParameter.output_format)
+}
+inline ::std::string* SaveOutputParameter::mutable_output_format() {
+ set_has_output_format();
+ // @@protoc_insertion_point(field_mutable:caffe.SaveOutputParameter.output_format)
+ return output_format_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* SaveOutputParameter::release_output_format() {
+ // @@protoc_insertion_point(field_release:caffe.SaveOutputParameter.output_format)
+ clear_has_output_format();
+ return output_format_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void SaveOutputParameter::set_allocated_output_format(::std::string* output_format) {
+ if (output_format != NULL) {
+ set_has_output_format();
+ } else {
+ clear_has_output_format();
+ }
+ output_format_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), output_format);
+ // @@protoc_insertion_point(field_set_allocated:caffe.SaveOutputParameter.output_format)
+}
+
+// optional string label_map_file = 4;
+inline bool SaveOutputParameter::has_label_map_file() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void SaveOutputParameter::set_has_label_map_file() {
+ _has_bits_[0] |= 0x00000008u;
+}
+inline void SaveOutputParameter::clear_has_label_map_file() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+inline void SaveOutputParameter::clear_label_map_file() {
+ label_map_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_label_map_file();
+}
+inline const ::std::string& SaveOutputParameter::label_map_file() const {
+ // @@protoc_insertion_point(field_get:caffe.SaveOutputParameter.label_map_file)
+ return label_map_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void SaveOutputParameter::set_label_map_file(const ::std::string& value) {
+ set_has_label_map_file();
+ label_map_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.SaveOutputParameter.label_map_file)
+}
+inline void SaveOutputParameter::set_label_map_file(const char* value) {
+ set_has_label_map_file();
+ label_map_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.SaveOutputParameter.label_map_file)
+}
+inline void SaveOutputParameter::set_label_map_file(const char* value, size_t size) {
+ set_has_label_map_file();
+ label_map_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.SaveOutputParameter.label_map_file)
+}
+inline ::std::string* SaveOutputParameter::mutable_label_map_file() {
+ set_has_label_map_file();
+ // @@protoc_insertion_point(field_mutable:caffe.SaveOutputParameter.label_map_file)
+ return label_map_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* SaveOutputParameter::release_label_map_file() {
+ // @@protoc_insertion_point(field_release:caffe.SaveOutputParameter.label_map_file)
+ clear_has_label_map_file();
+ return label_map_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void SaveOutputParameter::set_allocated_label_map_file(::std::string* label_map_file) {
+ if (label_map_file != NULL) {
+ set_has_label_map_file();
+ } else {
+ clear_has_label_map_file();
+ }
+ label_map_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), label_map_file);
+ // @@protoc_insertion_point(field_set_allocated:caffe.SaveOutputParameter.label_map_file)
+}
+
+// optional string name_size_file = 5;
+inline bool SaveOutputParameter::has_name_size_file() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+inline void SaveOutputParameter::set_has_name_size_file() {
+ _has_bits_[0] |= 0x00000010u;
+}
+inline void SaveOutputParameter::clear_has_name_size_file() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+inline void SaveOutputParameter::clear_name_size_file() {
+ name_size_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_name_size_file();
+}
+inline const ::std::string& SaveOutputParameter::name_size_file() const {
+ // @@protoc_insertion_point(field_get:caffe.SaveOutputParameter.name_size_file)
+ return name_size_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void SaveOutputParameter::set_name_size_file(const ::std::string& value) {
+ set_has_name_size_file();
+ name_size_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.SaveOutputParameter.name_size_file)
+}
+inline void SaveOutputParameter::set_name_size_file(const char* value) {
+ set_has_name_size_file();
+ name_size_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.SaveOutputParameter.name_size_file)
+}
+inline void SaveOutputParameter::set_name_size_file(const char* value, size_t size) {
+ set_has_name_size_file();
+ name_size_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.SaveOutputParameter.name_size_file)
+}
+inline ::std::string* SaveOutputParameter::mutable_name_size_file() {
+ set_has_name_size_file();
+ // @@protoc_insertion_point(field_mutable:caffe.SaveOutputParameter.name_size_file)
+ return name_size_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* SaveOutputParameter::release_name_size_file() {
+ // @@protoc_insertion_point(field_release:caffe.SaveOutputParameter.name_size_file)
+ clear_has_name_size_file();
+ return name_size_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void SaveOutputParameter::set_allocated_name_size_file(::std::string* name_size_file) {
+ if (name_size_file != NULL) {
+ set_has_name_size_file();
+ } else {
+ clear_has_name_size_file();
+ }
+ name_size_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name_size_file);
+ // @@protoc_insertion_point(field_set_allocated:caffe.SaveOutputParameter.name_size_file)
+}
+
+// optional uint32 num_test_image = 6;
+inline bool SaveOutputParameter::has_num_test_image() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+inline void SaveOutputParameter::set_has_num_test_image() {
+ _has_bits_[0] |= 0x00000020u;
+}
+inline void SaveOutputParameter::clear_has_num_test_image() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+inline void SaveOutputParameter::clear_num_test_image() {
+ num_test_image_ = 0u;
+ clear_has_num_test_image();
+}
+inline ::google::protobuf::uint32 SaveOutputParameter::num_test_image() const {
+ // @@protoc_insertion_point(field_get:caffe.SaveOutputParameter.num_test_image)
+ return num_test_image_;
+}
+inline void SaveOutputParameter::set_num_test_image(::google::protobuf::uint32 value) {
+ set_has_num_test_image();
+ num_test_image_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SaveOutputParameter.num_test_image)
+}
+
+inline const SaveOutputParameter* SaveOutputParameter::internal_default_instance() {
+ return &SaveOutputParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// DropoutParameter
+
+// optional float dropout_ratio = 1 [default = 0.5];
+inline bool DropoutParameter::has_dropout_ratio() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void DropoutParameter::set_has_dropout_ratio() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void DropoutParameter::clear_has_dropout_ratio() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void DropoutParameter::clear_dropout_ratio() {
+ dropout_ratio_ = 0.5f;
+ clear_has_dropout_ratio();
+}
+inline float DropoutParameter::dropout_ratio() const {
+ // @@protoc_insertion_point(field_get:caffe.DropoutParameter.dropout_ratio)
+ return dropout_ratio_;
+}
+inline void DropoutParameter::set_dropout_ratio(float value) {
+ set_has_dropout_ratio();
+ dropout_ratio_ = value;
+ // @@protoc_insertion_point(field_set:caffe.DropoutParameter.dropout_ratio)
+}
+
+inline const DropoutParameter* DropoutParameter::internal_default_instance() {
+ return &DropoutParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// DummyDataParameter
+
+// repeated .caffe.FillerParameter data_filler = 1;
+inline int DummyDataParameter::data_filler_size() const {
+ return data_filler_.size();
+}
+inline void DummyDataParameter::clear_data_filler() {
+ data_filler_.Clear();
+}
+inline const ::caffe::FillerParameter& DummyDataParameter::data_filler(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.data_filler)
+ return data_filler_.Get(index);
+}
+inline ::caffe::FillerParameter* DummyDataParameter::mutable_data_filler(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.DummyDataParameter.data_filler)
+ return data_filler_.Mutable(index);
+}
+inline ::caffe::FillerParameter* DummyDataParameter::add_data_filler() {
+ // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.data_filler)
+ return data_filler_.Add();
+}
+inline ::google::protobuf::RepeatedPtrField< ::caffe::FillerParameter >*
+DummyDataParameter::mutable_data_filler() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.data_filler)
+ return &data_filler_;
+}
+inline const ::google::protobuf::RepeatedPtrField< ::caffe::FillerParameter >&
+DummyDataParameter::data_filler() const {
+ // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.data_filler)
+ return data_filler_;
+}
+
+// repeated .caffe.BlobShape shape = 6;
+inline int DummyDataParameter::shape_size() const {
+ return shape_.size();
+}
+inline void DummyDataParameter::clear_shape() {
+ shape_.Clear();
+}
+inline const ::caffe::BlobShape& DummyDataParameter::shape(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.shape)
+ return shape_.Get(index);
+}
+inline ::caffe::BlobShape* DummyDataParameter::mutable_shape(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.DummyDataParameter.shape)
+ return shape_.Mutable(index);
+}
+inline ::caffe::BlobShape* DummyDataParameter::add_shape() {
+ // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.shape)
+ return shape_.Add();
+}
+inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >*
+DummyDataParameter::mutable_shape() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.shape)
+ return &shape_;
+}
+inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >&
+DummyDataParameter::shape() const {
+ // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.shape)
+ return shape_;
+}
+
+// repeated uint32 num = 2;
+inline int DummyDataParameter::num_size() const {
+ return num_.size();
+}
+inline void DummyDataParameter::clear_num() {
+ num_.Clear();
+}
+inline ::google::protobuf::uint32 DummyDataParameter::num(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.num)
+ return num_.Get(index);
+}
+inline void DummyDataParameter::set_num(int index, ::google::protobuf::uint32 value) {
+ num_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.DummyDataParameter.num)
+}
+inline void DummyDataParameter::add_num(::google::protobuf::uint32 value) {
+ num_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.num)
+}
+inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+DummyDataParameter::num() const {
+ // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.num)
+ return num_;
+}
+inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+DummyDataParameter::mutable_num() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.num)
+ return &num_;
+}
+
+// repeated uint32 channels = 3;
+inline int DummyDataParameter::channels_size() const {
+ return channels_.size();
+}
+inline void DummyDataParameter::clear_channels() {
+ channels_.Clear();
+}
+inline ::google::protobuf::uint32 DummyDataParameter::channels(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.channels)
+ return channels_.Get(index);
+}
+inline void DummyDataParameter::set_channels(int index, ::google::protobuf::uint32 value) {
+ channels_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.DummyDataParameter.channels)
+}
+inline void DummyDataParameter::add_channels(::google::protobuf::uint32 value) {
+ channels_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.channels)
+}
+inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+DummyDataParameter::channels() const {
+ // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.channels)
+ return channels_;
+}
+inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+DummyDataParameter::mutable_channels() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.channels)
+ return &channels_;
+}
+
+// repeated uint32 height = 4;
+inline int DummyDataParameter::height_size() const {
+ return height_.size();
+}
+inline void DummyDataParameter::clear_height() {
+ height_.Clear();
+}
+inline ::google::protobuf::uint32 DummyDataParameter::height(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.height)
+ return height_.Get(index);
+}
+inline void DummyDataParameter::set_height(int index, ::google::protobuf::uint32 value) {
+ height_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.DummyDataParameter.height)
+}
+inline void DummyDataParameter::add_height(::google::protobuf::uint32 value) {
+ height_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.height)
+}
+inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+DummyDataParameter::height() const {
+ // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.height)
+ return height_;
+}
+inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+DummyDataParameter::mutable_height() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.height)
+ return &height_;
+}
+
+// repeated uint32 width = 5;
+inline int DummyDataParameter::width_size() const {
+ return width_.size();
+}
+inline void DummyDataParameter::clear_width() {
+ width_.Clear();
+}
+inline ::google::protobuf::uint32 DummyDataParameter::width(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.DummyDataParameter.width)
+ return width_.Get(index);
+}
+inline void DummyDataParameter::set_width(int index, ::google::protobuf::uint32 value) {
+ width_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.DummyDataParameter.width)
+}
+inline void DummyDataParameter::add_width(::google::protobuf::uint32 value) {
+ width_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.DummyDataParameter.width)
+}
+inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+DummyDataParameter::width() const {
+ // @@protoc_insertion_point(field_list:caffe.DummyDataParameter.width)
+ return width_;
+}
+inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+DummyDataParameter::mutable_width() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.DummyDataParameter.width)
+ return &width_;
+}
+
+inline const DummyDataParameter* DummyDataParameter::internal_default_instance() {
+ return &DummyDataParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// EltwiseParameter
+
+// optional .caffe.EltwiseParameter.EltwiseOp operation = 1 [default = SUM];
+inline bool EltwiseParameter::has_operation() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void EltwiseParameter::set_has_operation() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void EltwiseParameter::clear_has_operation() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void EltwiseParameter::clear_operation() {
+ operation_ = 1;
+ clear_has_operation();
+}
+inline ::caffe::EltwiseParameter_EltwiseOp EltwiseParameter::operation() const {
+ // @@protoc_insertion_point(field_get:caffe.EltwiseParameter.operation)
+ return static_cast< ::caffe::EltwiseParameter_EltwiseOp >(operation_);
+}
+inline void EltwiseParameter::set_operation(::caffe::EltwiseParameter_EltwiseOp value) {
+ assert(::caffe::EltwiseParameter_EltwiseOp_IsValid(value));
+ set_has_operation();
+ operation_ = value;
+ // @@protoc_insertion_point(field_set:caffe.EltwiseParameter.operation)
+}
+
+// repeated float coeff = 2;
+inline int EltwiseParameter::coeff_size() const {
+ return coeff_.size();
+}
+inline void EltwiseParameter::clear_coeff() {
+ coeff_.Clear();
+}
+inline float EltwiseParameter::coeff(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.EltwiseParameter.coeff)
+ return coeff_.Get(index);
+}
+inline void EltwiseParameter::set_coeff(int index, float value) {
+ coeff_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.EltwiseParameter.coeff)
+}
+inline void EltwiseParameter::add_coeff(float value) {
+ coeff_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.EltwiseParameter.coeff)
+}
+inline const ::google::protobuf::RepeatedField< float >&
+EltwiseParameter::coeff() const {
+ // @@protoc_insertion_point(field_list:caffe.EltwiseParameter.coeff)
+ return coeff_;
+}
+inline ::google::protobuf::RepeatedField< float >*
+EltwiseParameter::mutable_coeff() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.EltwiseParameter.coeff)
+ return &coeff_;
+}
+
+// optional bool stable_prod_grad = 3 [default = true];
+inline bool EltwiseParameter::has_stable_prod_grad() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void EltwiseParameter::set_has_stable_prod_grad() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void EltwiseParameter::clear_has_stable_prod_grad() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void EltwiseParameter::clear_stable_prod_grad() {
+ stable_prod_grad_ = true;
+ clear_has_stable_prod_grad();
+}
+inline bool EltwiseParameter::stable_prod_grad() const {
+ // @@protoc_insertion_point(field_get:caffe.EltwiseParameter.stable_prod_grad)
+ return stable_prod_grad_;
+}
+inline void EltwiseParameter::set_stable_prod_grad(bool value) {
+ set_has_stable_prod_grad();
+ stable_prod_grad_ = value;
+ // @@protoc_insertion_point(field_set:caffe.EltwiseParameter.stable_prod_grad)
+}
+
+inline const EltwiseParameter* EltwiseParameter::internal_default_instance() {
+ return &EltwiseParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// ELUParameter
+
+// optional float alpha = 1 [default = 1];
+inline bool ELUParameter::has_alpha() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void ELUParameter::set_has_alpha() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void ELUParameter::clear_has_alpha() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void ELUParameter::clear_alpha() {
+ alpha_ = 1;
+ clear_has_alpha();
+}
+inline float ELUParameter::alpha() const {
+ // @@protoc_insertion_point(field_get:caffe.ELUParameter.alpha)
+ return alpha_;
+}
+inline void ELUParameter::set_alpha(float value) {
+ set_has_alpha();
+ alpha_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ELUParameter.alpha)
+}
+
+inline const ELUParameter* ELUParameter::internal_default_instance() {
+ return &ELUParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// EmbedParameter
+
+// optional uint32 num_output = 1;
+inline bool EmbedParameter::has_num_output() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void EmbedParameter::set_has_num_output() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void EmbedParameter::clear_has_num_output() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void EmbedParameter::clear_num_output() {
+ num_output_ = 0u;
+ clear_has_num_output();
+}
+inline ::google::protobuf::uint32 EmbedParameter::num_output() const {
+ // @@protoc_insertion_point(field_get:caffe.EmbedParameter.num_output)
+ return num_output_;
+}
+inline void EmbedParameter::set_num_output(::google::protobuf::uint32 value) {
+ set_has_num_output();
+ num_output_ = value;
+ // @@protoc_insertion_point(field_set:caffe.EmbedParameter.num_output)
+}
+
+// optional uint32 input_dim = 2;
+inline bool EmbedParameter::has_input_dim() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void EmbedParameter::set_has_input_dim() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void EmbedParameter::clear_has_input_dim() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void EmbedParameter::clear_input_dim() {
+ input_dim_ = 0u;
+ clear_has_input_dim();
+}
+inline ::google::protobuf::uint32 EmbedParameter::input_dim() const {
+ // @@protoc_insertion_point(field_get:caffe.EmbedParameter.input_dim)
+ return input_dim_;
+}
+inline void EmbedParameter::set_input_dim(::google::protobuf::uint32 value) {
+ set_has_input_dim();
+ input_dim_ = value;
+ // @@protoc_insertion_point(field_set:caffe.EmbedParameter.input_dim)
+}
+
+// optional bool bias_term = 3 [default = true];
+inline bool EmbedParameter::has_bias_term() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void EmbedParameter::set_has_bias_term() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void EmbedParameter::clear_has_bias_term() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void EmbedParameter::clear_bias_term() {
+ bias_term_ = true;
+ clear_has_bias_term();
+}
+inline bool EmbedParameter::bias_term() const {
+ // @@protoc_insertion_point(field_get:caffe.EmbedParameter.bias_term)
+ return bias_term_;
+}
+inline void EmbedParameter::set_bias_term(bool value) {
+ set_has_bias_term();
+ bias_term_ = value;
+ // @@protoc_insertion_point(field_set:caffe.EmbedParameter.bias_term)
+}
+
+// optional .caffe.FillerParameter weight_filler = 4;
+inline bool EmbedParameter::has_weight_filler() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void EmbedParameter::set_has_weight_filler() {
+ _has_bits_[0] |= 0x00000008u;
+}
+inline void EmbedParameter::clear_has_weight_filler() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+inline void EmbedParameter::clear_weight_filler() {
+ if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear();
+ clear_has_weight_filler();
+}
+inline const ::caffe::FillerParameter& EmbedParameter::weight_filler() const {
+ // @@protoc_insertion_point(field_get:caffe.EmbedParameter.weight_filler)
+ return weight_filler_ != NULL ? *weight_filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+inline ::caffe::FillerParameter* EmbedParameter::mutable_weight_filler() {
+ set_has_weight_filler();
+ if (weight_filler_ == NULL) {
+ weight_filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.EmbedParameter.weight_filler)
+ return weight_filler_;
+}
+inline ::caffe::FillerParameter* EmbedParameter::release_weight_filler() {
+ // @@protoc_insertion_point(field_release:caffe.EmbedParameter.weight_filler)
+ clear_has_weight_filler();
+ ::caffe::FillerParameter* temp = weight_filler_;
+ weight_filler_ = NULL;
+ return temp;
+}
+inline void EmbedParameter::set_allocated_weight_filler(::caffe::FillerParameter* weight_filler) {
+ delete weight_filler_;
+ weight_filler_ = weight_filler;
+ if (weight_filler) {
+ set_has_weight_filler();
+ } else {
+ clear_has_weight_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.EmbedParameter.weight_filler)
+}
+
+// optional .caffe.FillerParameter bias_filler = 5;
+inline bool EmbedParameter::has_bias_filler() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+inline void EmbedParameter::set_has_bias_filler() {
+ _has_bits_[0] |= 0x00000010u;
+}
+inline void EmbedParameter::clear_has_bias_filler() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+inline void EmbedParameter::clear_bias_filler() {
+ if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
+ clear_has_bias_filler();
+}
+inline const ::caffe::FillerParameter& EmbedParameter::bias_filler() const {
+ // @@protoc_insertion_point(field_get:caffe.EmbedParameter.bias_filler)
+ return bias_filler_ != NULL ? *bias_filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+inline ::caffe::FillerParameter* EmbedParameter::mutable_bias_filler() {
+ set_has_bias_filler();
+ if (bias_filler_ == NULL) {
+ bias_filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.EmbedParameter.bias_filler)
+ return bias_filler_;
+}
+inline ::caffe::FillerParameter* EmbedParameter::release_bias_filler() {
+ // @@protoc_insertion_point(field_release:caffe.EmbedParameter.bias_filler)
+ clear_has_bias_filler();
+ ::caffe::FillerParameter* temp = bias_filler_;
+ bias_filler_ = NULL;
+ return temp;
+}
+inline void EmbedParameter::set_allocated_bias_filler(::caffe::FillerParameter* bias_filler) {
+ delete bias_filler_;
+ bias_filler_ = bias_filler;
+ if (bias_filler) {
+ set_has_bias_filler();
+ } else {
+ clear_has_bias_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.EmbedParameter.bias_filler)
+}
+
+inline const EmbedParameter* EmbedParameter::internal_default_instance() {
+ return &EmbedParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// ExpParameter
+
+// optional float base = 1 [default = -1];
+inline bool ExpParameter::has_base() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void ExpParameter::set_has_base() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void ExpParameter::clear_has_base() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void ExpParameter::clear_base() {
+ base_ = -1;
+ clear_has_base();
+}
+inline float ExpParameter::base() const {
+ // @@protoc_insertion_point(field_get:caffe.ExpParameter.base)
+ return base_;
+}
+inline void ExpParameter::set_base(float value) {
+ set_has_base();
+ base_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ExpParameter.base)
+}
+
+// optional float scale = 2 [default = 1];
+inline bool ExpParameter::has_scale() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void ExpParameter::set_has_scale() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void ExpParameter::clear_has_scale() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void ExpParameter::clear_scale() {
+ scale_ = 1;
+ clear_has_scale();
+}
+inline float ExpParameter::scale() const {
+ // @@protoc_insertion_point(field_get:caffe.ExpParameter.scale)
+ return scale_;
+}
+inline void ExpParameter::set_scale(float value) {
+ set_has_scale();
+ scale_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ExpParameter.scale)
+}
+
+// optional float shift = 3 [default = 0];
+inline bool ExpParameter::has_shift() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void ExpParameter::set_has_shift() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void ExpParameter::clear_has_shift() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void ExpParameter::clear_shift() {
+ shift_ = 0;
+ clear_has_shift();
+}
+inline float ExpParameter::shift() const {
+ // @@protoc_insertion_point(field_get:caffe.ExpParameter.shift)
+ return shift_;
+}
+inline void ExpParameter::set_shift(float value) {
+ set_has_shift();
+ shift_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ExpParameter.shift)
+}
+
+inline const ExpParameter* ExpParameter::internal_default_instance() {
+ return &ExpParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// FlattenParameter
+
+// optional int32 axis = 1 [default = 1];
+inline bool FlattenParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void FlattenParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void FlattenParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void FlattenParameter::clear_axis() {
+ axis_ = 1;
+ clear_has_axis();
+}
+inline ::google::protobuf::int32 FlattenParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.FlattenParameter.axis)
+ return axis_;
+}
+inline void FlattenParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.FlattenParameter.axis)
+}
+
+// optional int32 end_axis = 2 [default = -1];
+inline bool FlattenParameter::has_end_axis() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void FlattenParameter::set_has_end_axis() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void FlattenParameter::clear_has_end_axis() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void FlattenParameter::clear_end_axis() {
+ end_axis_ = -1;
+ clear_has_end_axis();
+}
+inline ::google::protobuf::int32 FlattenParameter::end_axis() const {
+ // @@protoc_insertion_point(field_get:caffe.FlattenParameter.end_axis)
+ return end_axis_;
+}
+inline void FlattenParameter::set_end_axis(::google::protobuf::int32 value) {
+ set_has_end_axis();
+ end_axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.FlattenParameter.end_axis)
+}
+
+inline const FlattenParameter* FlattenParameter::internal_default_instance() {
+ return &FlattenParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// HDF5DataParameter
+
+// optional string source = 1;
+inline bool HDF5DataParameter::has_source() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void HDF5DataParameter::set_has_source() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void HDF5DataParameter::clear_has_source() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void HDF5DataParameter::clear_source() {
+ source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_source();
+}
+inline const ::std::string& HDF5DataParameter::source() const {
+ // @@protoc_insertion_point(field_get:caffe.HDF5DataParameter.source)
+ return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void HDF5DataParameter::set_source(const ::std::string& value) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.HDF5DataParameter.source)
+}
+inline void HDF5DataParameter::set_source(const char* value) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.HDF5DataParameter.source)
+}
+inline void HDF5DataParameter::set_source(const char* value, size_t size) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.HDF5DataParameter.source)
+}
+inline ::std::string* HDF5DataParameter::mutable_source() {
+ set_has_source();
+ // @@protoc_insertion_point(field_mutable:caffe.HDF5DataParameter.source)
+ return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* HDF5DataParameter::release_source() {
+ // @@protoc_insertion_point(field_release:caffe.HDF5DataParameter.source)
+ clear_has_source();
+ return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void HDF5DataParameter::set_allocated_source(::std::string* source) {
+ if (source != NULL) {
+ set_has_source();
+ } else {
+ clear_has_source();
+ }
+ source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source);
+ // @@protoc_insertion_point(field_set_allocated:caffe.HDF5DataParameter.source)
+}
+
+// optional uint32 batch_size = 2;
+inline bool HDF5DataParameter::has_batch_size() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void HDF5DataParameter::set_has_batch_size() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void HDF5DataParameter::clear_has_batch_size() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void HDF5DataParameter::clear_batch_size() {
+ batch_size_ = 0u;
+ clear_has_batch_size();
+}
+inline ::google::protobuf::uint32 HDF5DataParameter::batch_size() const {
+ // @@protoc_insertion_point(field_get:caffe.HDF5DataParameter.batch_size)
+ return batch_size_;
+}
+inline void HDF5DataParameter::set_batch_size(::google::protobuf::uint32 value) {
+ set_has_batch_size();
+ batch_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.HDF5DataParameter.batch_size)
+}
+
+// optional bool shuffle = 3 [default = false];
+inline bool HDF5DataParameter::has_shuffle() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void HDF5DataParameter::set_has_shuffle() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void HDF5DataParameter::clear_has_shuffle() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void HDF5DataParameter::clear_shuffle() {
+ shuffle_ = false;
+ clear_has_shuffle();
+}
+inline bool HDF5DataParameter::shuffle() const {
+ // @@protoc_insertion_point(field_get:caffe.HDF5DataParameter.shuffle)
+ return shuffle_;
+}
+inline void HDF5DataParameter::set_shuffle(bool value) {
+ set_has_shuffle();
+ shuffle_ = value;
+ // @@protoc_insertion_point(field_set:caffe.HDF5DataParameter.shuffle)
+}
+
+inline const HDF5DataParameter* HDF5DataParameter::internal_default_instance() {
+ return &HDF5DataParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// HDF5OutputParameter
+
+// optional string file_name = 1;
+inline bool HDF5OutputParameter::has_file_name() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void HDF5OutputParameter::set_has_file_name() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void HDF5OutputParameter::clear_has_file_name() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void HDF5OutputParameter::clear_file_name() {
+ file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_file_name();
+}
+inline const ::std::string& HDF5OutputParameter::file_name() const {
+ // @@protoc_insertion_point(field_get:caffe.HDF5OutputParameter.file_name)
+ return file_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void HDF5OutputParameter::set_file_name(const ::std::string& value) {
+ set_has_file_name();
+ file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.HDF5OutputParameter.file_name)
+}
+inline void HDF5OutputParameter::set_file_name(const char* value) {
+ set_has_file_name();
+ file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.HDF5OutputParameter.file_name)
+}
+inline void HDF5OutputParameter::set_file_name(const char* value, size_t size) {
+ set_has_file_name();
+ file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.HDF5OutputParameter.file_name)
+}
+inline ::std::string* HDF5OutputParameter::mutable_file_name() {
+ set_has_file_name();
+ // @@protoc_insertion_point(field_mutable:caffe.HDF5OutputParameter.file_name)
+ return file_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* HDF5OutputParameter::release_file_name() {
+ // @@protoc_insertion_point(field_release:caffe.HDF5OutputParameter.file_name)
+ clear_has_file_name();
+ return file_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void HDF5OutputParameter::set_allocated_file_name(::std::string* file_name) {
+ if (file_name != NULL) {
+ set_has_file_name();
+ } else {
+ clear_has_file_name();
+ }
+ file_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), file_name);
+ // @@protoc_insertion_point(field_set_allocated:caffe.HDF5OutputParameter.file_name)
+}
+
+inline const HDF5OutputParameter* HDF5OutputParameter::internal_default_instance() {
+ return &HDF5OutputParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// HingeLossParameter
+
+// optional .caffe.HingeLossParameter.Norm norm = 1 [default = L1];
+inline bool HingeLossParameter::has_norm() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void HingeLossParameter::set_has_norm() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void HingeLossParameter::clear_has_norm() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void HingeLossParameter::clear_norm() {
+ norm_ = 1;
+ clear_has_norm();
+}
+inline ::caffe::HingeLossParameter_Norm HingeLossParameter::norm() const {
+ // @@protoc_insertion_point(field_get:caffe.HingeLossParameter.norm)
+ return static_cast< ::caffe::HingeLossParameter_Norm >(norm_);
+}
+inline void HingeLossParameter::set_norm(::caffe::HingeLossParameter_Norm value) {
+ assert(::caffe::HingeLossParameter_Norm_IsValid(value));
+ set_has_norm();
+ norm_ = value;
+ // @@protoc_insertion_point(field_set:caffe.HingeLossParameter.norm)
+}
+
+inline const HingeLossParameter* HingeLossParameter::internal_default_instance() {
+ return &HingeLossParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// ImageDataParameter
+
+// optional string source = 1;
+inline bool ImageDataParameter::has_source() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void ImageDataParameter::set_has_source() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void ImageDataParameter::clear_has_source() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void ImageDataParameter::clear_source() {
+ source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_source();
+}
+inline const ::std::string& ImageDataParameter::source() const {
+ // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.source)
+ return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void ImageDataParameter::set_source(const ::std::string& value) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.source)
+}
+inline void ImageDataParameter::set_source(const char* value) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.ImageDataParameter.source)
+}
+inline void ImageDataParameter::set_source(const char* value, size_t size) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.ImageDataParameter.source)
+}
+inline ::std::string* ImageDataParameter::mutable_source() {
+ set_has_source();
+ // @@protoc_insertion_point(field_mutable:caffe.ImageDataParameter.source)
+ return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* ImageDataParameter::release_source() {
+ // @@protoc_insertion_point(field_release:caffe.ImageDataParameter.source)
+ clear_has_source();
+ return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void ImageDataParameter::set_allocated_source(::std::string* source) {
+ if (source != NULL) {
+ set_has_source();
+ } else {
+ clear_has_source();
+ }
+ source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source);
+ // @@protoc_insertion_point(field_set_allocated:caffe.ImageDataParameter.source)
+}
+
+// optional uint32 batch_size = 4 [default = 1];
+inline bool ImageDataParameter::has_batch_size() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void ImageDataParameter::set_has_batch_size() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void ImageDataParameter::clear_has_batch_size() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void ImageDataParameter::clear_batch_size() {
+ batch_size_ = 1u;
+ clear_has_batch_size();
+}
+inline ::google::protobuf::uint32 ImageDataParameter::batch_size() const {
+ // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.batch_size)
+ return batch_size_;
+}
+inline void ImageDataParameter::set_batch_size(::google::protobuf::uint32 value) {
+ set_has_batch_size();
+ batch_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.batch_size)
+}
+
+// optional uint32 rand_skip = 7 [default = 0];
+inline bool ImageDataParameter::has_rand_skip() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void ImageDataParameter::set_has_rand_skip() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void ImageDataParameter::clear_has_rand_skip() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void ImageDataParameter::clear_rand_skip() {
+ rand_skip_ = 0u;
+ clear_has_rand_skip();
+}
+inline ::google::protobuf::uint32 ImageDataParameter::rand_skip() const {
+ // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.rand_skip)
+ return rand_skip_;
+}
+inline void ImageDataParameter::set_rand_skip(::google::protobuf::uint32 value) {
+ set_has_rand_skip();
+ rand_skip_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.rand_skip)
+}
+
+// optional bool shuffle = 8 [default = false];
+inline bool ImageDataParameter::has_shuffle() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void ImageDataParameter::set_has_shuffle() {
+ _has_bits_[0] |= 0x00000008u;
+}
+inline void ImageDataParameter::clear_has_shuffle() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+inline void ImageDataParameter::clear_shuffle() {
+ shuffle_ = false;
+ clear_has_shuffle();
+}
+inline bool ImageDataParameter::shuffle() const {
+ // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.shuffle)
+ return shuffle_;
+}
+inline void ImageDataParameter::set_shuffle(bool value) {
+ set_has_shuffle();
+ shuffle_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.shuffle)
+}
+
+// optional uint32 new_height = 9 [default = 0];
+inline bool ImageDataParameter::has_new_height() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+inline void ImageDataParameter::set_has_new_height() {
+ _has_bits_[0] |= 0x00000010u;
+}
+inline void ImageDataParameter::clear_has_new_height() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+inline void ImageDataParameter::clear_new_height() {
+ new_height_ = 0u;
+ clear_has_new_height();
+}
+inline ::google::protobuf::uint32 ImageDataParameter::new_height() const {
+ // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.new_height)
+ return new_height_;
+}
+inline void ImageDataParameter::set_new_height(::google::protobuf::uint32 value) {
+ set_has_new_height();
+ new_height_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.new_height)
+}
+
+// optional uint32 new_width = 10 [default = 0];
+inline bool ImageDataParameter::has_new_width() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+inline void ImageDataParameter::set_has_new_width() {
+ _has_bits_[0] |= 0x00000020u;
+}
+inline void ImageDataParameter::clear_has_new_width() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+inline void ImageDataParameter::clear_new_width() {
+ new_width_ = 0u;
+ clear_has_new_width();
+}
+inline ::google::protobuf::uint32 ImageDataParameter::new_width() const {
+ // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.new_width)
+ return new_width_;
+}
+inline void ImageDataParameter::set_new_width(::google::protobuf::uint32 value) {
+ set_has_new_width();
+ new_width_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.new_width)
+}
+
+// optional bool is_color = 11 [default = true];
+inline bool ImageDataParameter::has_is_color() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+inline void ImageDataParameter::set_has_is_color() {
+ _has_bits_[0] |= 0x00000040u;
+}
+inline void ImageDataParameter::clear_has_is_color() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+inline void ImageDataParameter::clear_is_color() {
+ is_color_ = true;
+ clear_has_is_color();
+}
+inline bool ImageDataParameter::is_color() const {
+ // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.is_color)
+ return is_color_;
+}
+inline void ImageDataParameter::set_is_color(bool value) {
+ set_has_is_color();
+ is_color_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.is_color)
+}
+
+// optional float scale = 2 [default = 1];
+inline bool ImageDataParameter::has_scale() const {
+ return (_has_bits_[0] & 0x00000080u) != 0;
+}
+inline void ImageDataParameter::set_has_scale() {
+ _has_bits_[0] |= 0x00000080u;
+}
+inline void ImageDataParameter::clear_has_scale() {
+ _has_bits_[0] &= ~0x00000080u;
+}
+inline void ImageDataParameter::clear_scale() {
+ scale_ = 1;
+ clear_has_scale();
+}
+inline float ImageDataParameter::scale() const {
+ // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.scale)
+ return scale_;
+}
+inline void ImageDataParameter::set_scale(float value) {
+ set_has_scale();
+ scale_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.scale)
+}
+
+// optional string mean_file = 3;
+inline bool ImageDataParameter::has_mean_file() const {
+ return (_has_bits_[0] & 0x00000100u) != 0;
+}
+inline void ImageDataParameter::set_has_mean_file() {
+ _has_bits_[0] |= 0x00000100u;
+}
+inline void ImageDataParameter::clear_has_mean_file() {
+ _has_bits_[0] &= ~0x00000100u;
+}
+inline void ImageDataParameter::clear_mean_file() {
+ mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_mean_file();
+}
+inline const ::std::string& ImageDataParameter::mean_file() const {
+ // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.mean_file)
+ return mean_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void ImageDataParameter::set_mean_file(const ::std::string& value) {
+ set_has_mean_file();
+ mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.mean_file)
+}
+inline void ImageDataParameter::set_mean_file(const char* value) {
+ set_has_mean_file();
+ mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.ImageDataParameter.mean_file)
+}
+inline void ImageDataParameter::set_mean_file(const char* value, size_t size) {
+ set_has_mean_file();
+ mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.ImageDataParameter.mean_file)
+}
+inline ::std::string* ImageDataParameter::mutable_mean_file() {
+ set_has_mean_file();
+ // @@protoc_insertion_point(field_mutable:caffe.ImageDataParameter.mean_file)
+ return mean_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* ImageDataParameter::release_mean_file() {
+ // @@protoc_insertion_point(field_release:caffe.ImageDataParameter.mean_file)
+ clear_has_mean_file();
+ return mean_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void ImageDataParameter::set_allocated_mean_file(::std::string* mean_file) {
+ if (mean_file != NULL) {
+ set_has_mean_file();
+ } else {
+ clear_has_mean_file();
+ }
+ mean_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), mean_file);
+ // @@protoc_insertion_point(field_set_allocated:caffe.ImageDataParameter.mean_file)
+}
+
+// optional uint32 crop_size = 5 [default = 0];
+inline bool ImageDataParameter::has_crop_size() const {
+ return (_has_bits_[0] & 0x00000200u) != 0;
+}
+inline void ImageDataParameter::set_has_crop_size() {
+ _has_bits_[0] |= 0x00000200u;
+}
+inline void ImageDataParameter::clear_has_crop_size() {
+ _has_bits_[0] &= ~0x00000200u;
+}
+inline void ImageDataParameter::clear_crop_size() {
+ crop_size_ = 0u;
+ clear_has_crop_size();
+}
+inline ::google::protobuf::uint32 ImageDataParameter::crop_size() const {
+ // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.crop_size)
+ return crop_size_;
+}
+inline void ImageDataParameter::set_crop_size(::google::protobuf::uint32 value) {
+ set_has_crop_size();
+ crop_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.crop_size)
+}
+
+// optional bool mirror = 6 [default = false];
+inline bool ImageDataParameter::has_mirror() const {
+ return (_has_bits_[0] & 0x00000400u) != 0;
+}
+inline void ImageDataParameter::set_has_mirror() {
+ _has_bits_[0] |= 0x00000400u;
+}
+inline void ImageDataParameter::clear_has_mirror() {
+ _has_bits_[0] &= ~0x00000400u;
+}
+inline void ImageDataParameter::clear_mirror() {
+ mirror_ = false;
+ clear_has_mirror();
+}
+inline bool ImageDataParameter::mirror() const {
+ // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.mirror)
+ return mirror_;
+}
+inline void ImageDataParameter::set_mirror(bool value) {
+ set_has_mirror();
+ mirror_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.mirror)
+}
+
+// optional string root_folder = 12 [default = ""];
+inline bool ImageDataParameter::has_root_folder() const {
+ return (_has_bits_[0] & 0x00000800u) != 0;
+}
+inline void ImageDataParameter::set_has_root_folder() {
+ _has_bits_[0] |= 0x00000800u;
+}
+inline void ImageDataParameter::clear_has_root_folder() {
+ _has_bits_[0] &= ~0x00000800u;
+}
+inline void ImageDataParameter::clear_root_folder() {
+ root_folder_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_root_folder();
+}
+inline const ::std::string& ImageDataParameter::root_folder() const {
+ // @@protoc_insertion_point(field_get:caffe.ImageDataParameter.root_folder)
+ return root_folder_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void ImageDataParameter::set_root_folder(const ::std::string& value) {
+ set_has_root_folder();
+ root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.ImageDataParameter.root_folder)
+}
+inline void ImageDataParameter::set_root_folder(const char* value) {
+ set_has_root_folder();
+ root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.ImageDataParameter.root_folder)
+}
+inline void ImageDataParameter::set_root_folder(const char* value, size_t size) {
+ set_has_root_folder();
+ root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.ImageDataParameter.root_folder)
+}
+inline ::std::string* ImageDataParameter::mutable_root_folder() {
+ set_has_root_folder();
+ // @@protoc_insertion_point(field_mutable:caffe.ImageDataParameter.root_folder)
+ return root_folder_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* ImageDataParameter::release_root_folder() {
+ // @@protoc_insertion_point(field_release:caffe.ImageDataParameter.root_folder)
+ clear_has_root_folder();
+ return root_folder_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void ImageDataParameter::set_allocated_root_folder(::std::string* root_folder) {
+ if (root_folder != NULL) {
+ set_has_root_folder();
+ } else {
+ clear_has_root_folder();
+ }
+ root_folder_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), root_folder);
+ // @@protoc_insertion_point(field_set_allocated:caffe.ImageDataParameter.root_folder)
+}
+
+inline const ImageDataParameter* ImageDataParameter::internal_default_instance() {
+ return &ImageDataParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// InfogainLossParameter
+
+// optional string source = 1;
+inline bool InfogainLossParameter::has_source() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void InfogainLossParameter::set_has_source() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void InfogainLossParameter::clear_has_source() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void InfogainLossParameter::clear_source() {
+ source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_source();
+}
+inline const ::std::string& InfogainLossParameter::source() const {
+ // @@protoc_insertion_point(field_get:caffe.InfogainLossParameter.source)
+ return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void InfogainLossParameter::set_source(const ::std::string& value) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.InfogainLossParameter.source)
+}
+inline void InfogainLossParameter::set_source(const char* value) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.InfogainLossParameter.source)
+}
+inline void InfogainLossParameter::set_source(const char* value, size_t size) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.InfogainLossParameter.source)
+}
+inline ::std::string* InfogainLossParameter::mutable_source() {
+ set_has_source();
+ // @@protoc_insertion_point(field_mutable:caffe.InfogainLossParameter.source)
+ return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* InfogainLossParameter::release_source() {
+ // @@protoc_insertion_point(field_release:caffe.InfogainLossParameter.source)
+ clear_has_source();
+ return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void InfogainLossParameter::set_allocated_source(::std::string* source) {
+ if (source != NULL) {
+ set_has_source();
+ } else {
+ clear_has_source();
+ }
+ source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source);
+ // @@protoc_insertion_point(field_set_allocated:caffe.InfogainLossParameter.source)
+}
+
+inline const InfogainLossParameter* InfogainLossParameter::internal_default_instance() {
+ return &InfogainLossParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// InnerProductParameter
+
+// optional uint32 num_output = 1;
+inline bool InnerProductParameter::has_num_output() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void InnerProductParameter::set_has_num_output() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void InnerProductParameter::clear_has_num_output() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void InnerProductParameter::clear_num_output() {
+ num_output_ = 0u;
+ clear_has_num_output();
+}
+inline ::google::protobuf::uint32 InnerProductParameter::num_output() const {
+ // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.num_output)
+ return num_output_;
+}
+inline void InnerProductParameter::set_num_output(::google::protobuf::uint32 value) {
+ set_has_num_output();
+ num_output_ = value;
+ // @@protoc_insertion_point(field_set:caffe.InnerProductParameter.num_output)
+}
+
+// optional bool bias_term = 2 [default = true];
+inline bool InnerProductParameter::has_bias_term() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void InnerProductParameter::set_has_bias_term() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void InnerProductParameter::clear_has_bias_term() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void InnerProductParameter::clear_bias_term() {
+ bias_term_ = true;
+ clear_has_bias_term();
+}
+inline bool InnerProductParameter::bias_term() const {
+ // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.bias_term)
+ return bias_term_;
+}
+inline void InnerProductParameter::set_bias_term(bool value) {
+ set_has_bias_term();
+ bias_term_ = value;
+ // @@protoc_insertion_point(field_set:caffe.InnerProductParameter.bias_term)
+}
+
+// optional .caffe.FillerParameter weight_filler = 3;
+inline bool InnerProductParameter::has_weight_filler() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void InnerProductParameter::set_has_weight_filler() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void InnerProductParameter::clear_has_weight_filler() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void InnerProductParameter::clear_weight_filler() {
+ if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear();
+ clear_has_weight_filler();
+}
+inline const ::caffe::FillerParameter& InnerProductParameter::weight_filler() const {
+ // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.weight_filler)
+ return weight_filler_ != NULL ? *weight_filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+inline ::caffe::FillerParameter* InnerProductParameter::mutable_weight_filler() {
+ set_has_weight_filler();
+ if (weight_filler_ == NULL) {
+ weight_filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.InnerProductParameter.weight_filler)
+ return weight_filler_;
+}
+inline ::caffe::FillerParameter* InnerProductParameter::release_weight_filler() {
+ // @@protoc_insertion_point(field_release:caffe.InnerProductParameter.weight_filler)
+ clear_has_weight_filler();
+ ::caffe::FillerParameter* temp = weight_filler_;
+ weight_filler_ = NULL;
+ return temp;
+}
+inline void InnerProductParameter::set_allocated_weight_filler(::caffe::FillerParameter* weight_filler) {
+ delete weight_filler_;
+ weight_filler_ = weight_filler;
+ if (weight_filler) {
+ set_has_weight_filler();
+ } else {
+ clear_has_weight_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.InnerProductParameter.weight_filler)
+}
+
+// optional .caffe.FillerParameter bias_filler = 4;
+inline bool InnerProductParameter::has_bias_filler() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void InnerProductParameter::set_has_bias_filler() {
+ _has_bits_[0] |= 0x00000008u;
+}
+inline void InnerProductParameter::clear_has_bias_filler() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+inline void InnerProductParameter::clear_bias_filler() {
+ if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
+ clear_has_bias_filler();
+}
+inline const ::caffe::FillerParameter& InnerProductParameter::bias_filler() const {
+ // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.bias_filler)
+ return bias_filler_ != NULL ? *bias_filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+inline ::caffe::FillerParameter* InnerProductParameter::mutable_bias_filler() {
+ set_has_bias_filler();
+ if (bias_filler_ == NULL) {
+ bias_filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.InnerProductParameter.bias_filler)
+ return bias_filler_;
+}
+inline ::caffe::FillerParameter* InnerProductParameter::release_bias_filler() {
+ // @@protoc_insertion_point(field_release:caffe.InnerProductParameter.bias_filler)
+ clear_has_bias_filler();
+ ::caffe::FillerParameter* temp = bias_filler_;
+ bias_filler_ = NULL;
+ return temp;
+}
+inline void InnerProductParameter::set_allocated_bias_filler(::caffe::FillerParameter* bias_filler) {
+ delete bias_filler_;
+ bias_filler_ = bias_filler;
+ if (bias_filler) {
+ set_has_bias_filler();
+ } else {
+ clear_has_bias_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.InnerProductParameter.bias_filler)
+}
+
+// optional int32 axis = 5 [default = 1];
+inline bool InnerProductParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+inline void InnerProductParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000010u;
+}
+inline void InnerProductParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+inline void InnerProductParameter::clear_axis() {
+ axis_ = 1;
+ clear_has_axis();
+}
+inline ::google::protobuf::int32 InnerProductParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.axis)
+ return axis_;
+}
+inline void InnerProductParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.InnerProductParameter.axis)
+}
+
+// optional bool transpose = 6 [default = false];
+inline bool InnerProductParameter::has_transpose() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+inline void InnerProductParameter::set_has_transpose() {
+ _has_bits_[0] |= 0x00000020u;
+}
+inline void InnerProductParameter::clear_has_transpose() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+inline void InnerProductParameter::clear_transpose() {
+ transpose_ = false;
+ clear_has_transpose();
+}
+inline bool InnerProductParameter::transpose() const {
+ // @@protoc_insertion_point(field_get:caffe.InnerProductParameter.transpose)
+ return transpose_;
+}
+inline void InnerProductParameter::set_transpose(bool value) {
+ set_has_transpose();
+ transpose_ = value;
+ // @@protoc_insertion_point(field_set:caffe.InnerProductParameter.transpose)
+}
+
+inline const InnerProductParameter* InnerProductParameter::internal_default_instance() {
+ return &InnerProductParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// InputParameter
+
+// repeated .caffe.BlobShape shape = 1;
+inline int InputParameter::shape_size() const {
+ return shape_.size();
+}
+inline void InputParameter::clear_shape() {
+ shape_.Clear();
+}
+inline const ::caffe::BlobShape& InputParameter::shape(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.InputParameter.shape)
+ return shape_.Get(index);
+}
+inline ::caffe::BlobShape* InputParameter::mutable_shape(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.InputParameter.shape)
+ return shape_.Mutable(index);
+}
+inline ::caffe::BlobShape* InputParameter::add_shape() {
+ // @@protoc_insertion_point(field_add:caffe.InputParameter.shape)
+ return shape_.Add();
+}
+inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >*
+InputParameter::mutable_shape() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.InputParameter.shape)
+ return &shape_;
+}
+inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobShape >&
+InputParameter::shape() const {
+ // @@protoc_insertion_point(field_list:caffe.InputParameter.shape)
+ return shape_;
+}
+
+inline const InputParameter* InputParameter::internal_default_instance() {
+ return &InputParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// LogParameter
+
+// optional float base = 1 [default = -1];
+inline bool LogParameter::has_base() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void LogParameter::set_has_base() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void LogParameter::clear_has_base() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void LogParameter::clear_base() {
+ base_ = -1;
+ clear_has_base();
+}
+inline float LogParameter::base() const {
+ // @@protoc_insertion_point(field_get:caffe.LogParameter.base)
+ return base_;
+}
+inline void LogParameter::set_base(float value) {
+ set_has_base();
+ base_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LogParameter.base)
+}
+
+// optional float scale = 2 [default = 1];
+inline bool LogParameter::has_scale() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void LogParameter::set_has_scale() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void LogParameter::clear_has_scale() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void LogParameter::clear_scale() {
+ scale_ = 1;
+ clear_has_scale();
+}
+inline float LogParameter::scale() const {
+ // @@protoc_insertion_point(field_get:caffe.LogParameter.scale)
+ return scale_;
+}
+inline void LogParameter::set_scale(float value) {
+ set_has_scale();
+ scale_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LogParameter.scale)
+}
+
+// optional float shift = 3 [default = 0];
+inline bool LogParameter::has_shift() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void LogParameter::set_has_shift() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void LogParameter::clear_has_shift() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void LogParameter::clear_shift() {
+ shift_ = 0;
+ clear_has_shift();
+}
+inline float LogParameter::shift() const {
+ // @@protoc_insertion_point(field_get:caffe.LogParameter.shift)
+ return shift_;
+}
+inline void LogParameter::set_shift(float value) {
+ set_has_shift();
+ shift_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LogParameter.shift)
+}
+
+inline const LogParameter* LogParameter::internal_default_instance() {
+ return &LogParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// LRNParameter
+
+// optional uint32 local_size = 1 [default = 5];
+inline bool LRNParameter::has_local_size() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void LRNParameter::set_has_local_size() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void LRNParameter::clear_has_local_size() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void LRNParameter::clear_local_size() {
+ local_size_ = 5u;
+ clear_has_local_size();
+}
+inline ::google::protobuf::uint32 LRNParameter::local_size() const {
+ // @@protoc_insertion_point(field_get:caffe.LRNParameter.local_size)
+ return local_size_;
+}
+inline void LRNParameter::set_local_size(::google::protobuf::uint32 value) {
+ set_has_local_size();
+ local_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LRNParameter.local_size)
+}
+
+// optional float alpha = 2 [default = 1];
+inline bool LRNParameter::has_alpha() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void LRNParameter::set_has_alpha() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void LRNParameter::clear_has_alpha() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void LRNParameter::clear_alpha() {
+ alpha_ = 1;
+ clear_has_alpha();
+}
+inline float LRNParameter::alpha() const {
+ // @@protoc_insertion_point(field_get:caffe.LRNParameter.alpha)
+ return alpha_;
+}
+inline void LRNParameter::set_alpha(float value) {
+ set_has_alpha();
+ alpha_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LRNParameter.alpha)
+}
+
+// optional float beta = 3 [default = 0.75];
+inline bool LRNParameter::has_beta() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void LRNParameter::set_has_beta() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void LRNParameter::clear_has_beta() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void LRNParameter::clear_beta() {
+ beta_ = 0.75f;
+ clear_has_beta();
+}
+inline float LRNParameter::beta() const {
+ // @@protoc_insertion_point(field_get:caffe.LRNParameter.beta)
+ return beta_;
+}
+inline void LRNParameter::set_beta(float value) {
+ set_has_beta();
+ beta_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LRNParameter.beta)
+}
+
+// optional .caffe.LRNParameter.NormRegion norm_region = 4 [default = ACROSS_CHANNELS];
+inline bool LRNParameter::has_norm_region() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void LRNParameter::set_has_norm_region() {
+ _has_bits_[0] |= 0x00000008u;
+}
+inline void LRNParameter::clear_has_norm_region() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+inline void LRNParameter::clear_norm_region() {
+ norm_region_ = 0;
+ clear_has_norm_region();
+}
+inline ::caffe::LRNParameter_NormRegion LRNParameter::norm_region() const {
+ // @@protoc_insertion_point(field_get:caffe.LRNParameter.norm_region)
+ return static_cast< ::caffe::LRNParameter_NormRegion >(norm_region_);
+}
+inline void LRNParameter::set_norm_region(::caffe::LRNParameter_NormRegion value) {
+ assert(::caffe::LRNParameter_NormRegion_IsValid(value));
+ set_has_norm_region();
+ norm_region_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LRNParameter.norm_region)
+}
+
+// optional float k = 5 [default = 1];
+inline bool LRNParameter::has_k() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+inline void LRNParameter::set_has_k() {
+ _has_bits_[0] |= 0x00000010u;
+}
+inline void LRNParameter::clear_has_k() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+inline void LRNParameter::clear_k() {
+ k_ = 1;
+ clear_has_k();
+}
+inline float LRNParameter::k() const {
+ // @@protoc_insertion_point(field_get:caffe.LRNParameter.k)
+ return k_;
+}
+inline void LRNParameter::set_k(float value) {
+ set_has_k();
+ k_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LRNParameter.k)
+}
+
+// optional .caffe.LRNParameter.Engine engine = 6 [default = DEFAULT];
+inline bool LRNParameter::has_engine() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+inline void LRNParameter::set_has_engine() {
+ _has_bits_[0] |= 0x00000020u;
+}
+inline void LRNParameter::clear_has_engine() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+inline void LRNParameter::clear_engine() {
+ engine_ = 0;
+ clear_has_engine();
+}
+inline ::caffe::LRNParameter_Engine LRNParameter::engine() const {
+ // @@protoc_insertion_point(field_get:caffe.LRNParameter.engine)
+ return static_cast< ::caffe::LRNParameter_Engine >(engine_);
+}
+inline void LRNParameter::set_engine(::caffe::LRNParameter_Engine value) {
+ assert(::caffe::LRNParameter_Engine_IsValid(value));
+ set_has_engine();
+ engine_ = value;
+ // @@protoc_insertion_point(field_set:caffe.LRNParameter.engine)
+}
+
+inline const LRNParameter* LRNParameter::internal_default_instance() {
+ return &LRNParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// MemoryDataParameter
+
+// optional uint32 batch_size = 1;
+inline bool MemoryDataParameter::has_batch_size() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void MemoryDataParameter::set_has_batch_size() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void MemoryDataParameter::clear_has_batch_size() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void MemoryDataParameter::clear_batch_size() {
+ batch_size_ = 0u;
+ clear_has_batch_size();
+}
+inline ::google::protobuf::uint32 MemoryDataParameter::batch_size() const {
+ // @@protoc_insertion_point(field_get:caffe.MemoryDataParameter.batch_size)
+ return batch_size_;
+}
+inline void MemoryDataParameter::set_batch_size(::google::protobuf::uint32 value) {
+ set_has_batch_size();
+ batch_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.MemoryDataParameter.batch_size)
+}
+
+// optional uint32 channels = 2;
+inline bool MemoryDataParameter::has_channels() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void MemoryDataParameter::set_has_channels() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void MemoryDataParameter::clear_has_channels() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void MemoryDataParameter::clear_channels() {
+ channels_ = 0u;
+ clear_has_channels();
+}
+inline ::google::protobuf::uint32 MemoryDataParameter::channels() const {
+ // @@protoc_insertion_point(field_get:caffe.MemoryDataParameter.channels)
+ return channels_;
+}
+inline void MemoryDataParameter::set_channels(::google::protobuf::uint32 value) {
+ set_has_channels();
+ channels_ = value;
+ // @@protoc_insertion_point(field_set:caffe.MemoryDataParameter.channels)
+}
+
+// optional uint32 height = 3;
+inline bool MemoryDataParameter::has_height() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void MemoryDataParameter::set_has_height() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void MemoryDataParameter::clear_has_height() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void MemoryDataParameter::clear_height() {
+ height_ = 0u;
+ clear_has_height();
+}
+inline ::google::protobuf::uint32 MemoryDataParameter::height() const {
+ // @@protoc_insertion_point(field_get:caffe.MemoryDataParameter.height)
+ return height_;
+}
+inline void MemoryDataParameter::set_height(::google::protobuf::uint32 value) {
+ set_has_height();
+ height_ = value;
+ // @@protoc_insertion_point(field_set:caffe.MemoryDataParameter.height)
+}
+
+// optional uint32 width = 4;
+inline bool MemoryDataParameter::has_width() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void MemoryDataParameter::set_has_width() {
+ _has_bits_[0] |= 0x00000008u;
+}
+inline void MemoryDataParameter::clear_has_width() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+inline void MemoryDataParameter::clear_width() {
+ width_ = 0u;
+ clear_has_width();
+}
+inline ::google::protobuf::uint32 MemoryDataParameter::width() const {
+ // @@protoc_insertion_point(field_get:caffe.MemoryDataParameter.width)
+ return width_;
+}
+inline void MemoryDataParameter::set_width(::google::protobuf::uint32 value) {
+ set_has_width();
+ width_ = value;
+ // @@protoc_insertion_point(field_set:caffe.MemoryDataParameter.width)
+}
+
+inline const MemoryDataParameter* MemoryDataParameter::internal_default_instance() {
+ return &MemoryDataParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// MVNParameter
+
+// optional bool normalize_variance = 1 [default = true];
+inline bool MVNParameter::has_normalize_variance() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void MVNParameter::set_has_normalize_variance() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void MVNParameter::clear_has_normalize_variance() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void MVNParameter::clear_normalize_variance() {
+ normalize_variance_ = true;
+ clear_has_normalize_variance();
+}
+inline bool MVNParameter::normalize_variance() const {
+ // @@protoc_insertion_point(field_get:caffe.MVNParameter.normalize_variance)
+ return normalize_variance_;
+}
+inline void MVNParameter::set_normalize_variance(bool value) {
+ set_has_normalize_variance();
+ normalize_variance_ = value;
+ // @@protoc_insertion_point(field_set:caffe.MVNParameter.normalize_variance)
+}
+
+// optional bool across_channels = 2 [default = false];
+inline bool MVNParameter::has_across_channels() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void MVNParameter::set_has_across_channels() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void MVNParameter::clear_has_across_channels() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void MVNParameter::clear_across_channels() {
+ across_channels_ = false;
+ clear_has_across_channels();
+}
+inline bool MVNParameter::across_channels() const {
+ // @@protoc_insertion_point(field_get:caffe.MVNParameter.across_channels)
+ return across_channels_;
+}
+inline void MVNParameter::set_across_channels(bool value) {
+ set_has_across_channels();
+ across_channels_ = value;
+ // @@protoc_insertion_point(field_set:caffe.MVNParameter.across_channels)
+}
+
+// optional float eps = 3 [default = 1e-09];
+inline bool MVNParameter::has_eps() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void MVNParameter::set_has_eps() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void MVNParameter::clear_has_eps() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void MVNParameter::clear_eps() {
+ eps_ = 1e-09f;
+ clear_has_eps();
+}
+inline float MVNParameter::eps() const {
+ // @@protoc_insertion_point(field_get:caffe.MVNParameter.eps)
+ return eps_;
+}
+inline void MVNParameter::set_eps(float value) {
+ set_has_eps();
+ eps_ = value;
+ // @@protoc_insertion_point(field_set:caffe.MVNParameter.eps)
+}
+
+inline const MVNParameter* MVNParameter::internal_default_instance() {
+ return &MVNParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// ParameterParameter
+
+// optional .caffe.BlobShape shape = 1;
+inline bool ParameterParameter::has_shape() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void ParameterParameter::set_has_shape() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void ParameterParameter::clear_has_shape() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void ParameterParameter::clear_shape() {
+ if (shape_ != NULL) shape_->::caffe::BlobShape::Clear();
+ clear_has_shape();
+}
+inline const ::caffe::BlobShape& ParameterParameter::shape() const {
+ // @@protoc_insertion_point(field_get:caffe.ParameterParameter.shape)
+ return shape_ != NULL ? *shape_
+ : *::caffe::BlobShape::internal_default_instance();
+}
+inline ::caffe::BlobShape* ParameterParameter::mutable_shape() {
+ set_has_shape();
+ if (shape_ == NULL) {
+ shape_ = new ::caffe::BlobShape;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.ParameterParameter.shape)
+ return shape_;
+}
+inline ::caffe::BlobShape* ParameterParameter::release_shape() {
+ // @@protoc_insertion_point(field_release:caffe.ParameterParameter.shape)
+ clear_has_shape();
+ ::caffe::BlobShape* temp = shape_;
+ shape_ = NULL;
+ return temp;
+}
+inline void ParameterParameter::set_allocated_shape(::caffe::BlobShape* shape) {
+ delete shape_;
+ shape_ = shape;
+ if (shape) {
+ set_has_shape();
+ } else {
+ clear_has_shape();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.ParameterParameter.shape)
+}
+
+inline const ParameterParameter* ParameterParameter::internal_default_instance() {
+ return &ParameterParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// PoolingParameter
+
+// optional .caffe.PoolingParameter.PoolMethod pool = 1 [default = MAX];
+inline bool PoolingParameter::has_pool() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void PoolingParameter::set_has_pool() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void PoolingParameter::clear_has_pool() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void PoolingParameter::clear_pool() {
+ pool_ = 0;
+ clear_has_pool();
+}
+inline ::caffe::PoolingParameter_PoolMethod PoolingParameter::pool() const {
+ // @@protoc_insertion_point(field_get:caffe.PoolingParameter.pool)
+ return static_cast< ::caffe::PoolingParameter_PoolMethod >(pool_);
+}
+inline void PoolingParameter::set_pool(::caffe::PoolingParameter_PoolMethod value) {
+ assert(::caffe::PoolingParameter_PoolMethod_IsValid(value));
+ set_has_pool();
+ pool_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PoolingParameter.pool)
+}
+
+// optional uint32 pad = 4 [default = 0];
+inline bool PoolingParameter::has_pad() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void PoolingParameter::set_has_pad() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void PoolingParameter::clear_has_pad() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void PoolingParameter::clear_pad() {
+ pad_ = 0u;
+ clear_has_pad();
+}
+inline ::google::protobuf::uint32 PoolingParameter::pad() const {
+ // @@protoc_insertion_point(field_get:caffe.PoolingParameter.pad)
+ return pad_;
+}
+inline void PoolingParameter::set_pad(::google::protobuf::uint32 value) {
+ set_has_pad();
+ pad_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PoolingParameter.pad)
+}
+
+// optional uint32 pad_h = 9 [default = 0];
+inline bool PoolingParameter::has_pad_h() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void PoolingParameter::set_has_pad_h() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void PoolingParameter::clear_has_pad_h() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void PoolingParameter::clear_pad_h() {
+ pad_h_ = 0u;
+ clear_has_pad_h();
+}
+inline ::google::protobuf::uint32 PoolingParameter::pad_h() const {
+ // @@protoc_insertion_point(field_get:caffe.PoolingParameter.pad_h)
+ return pad_h_;
+}
+inline void PoolingParameter::set_pad_h(::google::protobuf::uint32 value) {
+ set_has_pad_h();
+ pad_h_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PoolingParameter.pad_h)
+}
+
+// optional uint32 pad_w = 10 [default = 0];
+inline bool PoolingParameter::has_pad_w() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void PoolingParameter::set_has_pad_w() {
+ _has_bits_[0] |= 0x00000008u;
+}
+inline void PoolingParameter::clear_has_pad_w() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+inline void PoolingParameter::clear_pad_w() {
+ pad_w_ = 0u;
+ clear_has_pad_w();
+}
+inline ::google::protobuf::uint32 PoolingParameter::pad_w() const {
+ // @@protoc_insertion_point(field_get:caffe.PoolingParameter.pad_w)
+ return pad_w_;
+}
+inline void PoolingParameter::set_pad_w(::google::protobuf::uint32 value) {
+ set_has_pad_w();
+ pad_w_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PoolingParameter.pad_w)
+}
+
+// optional uint32 kernel_size = 2;
+inline bool PoolingParameter::has_kernel_size() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+inline void PoolingParameter::set_has_kernel_size() {
+ _has_bits_[0] |= 0x00000010u;
+}
+inline void PoolingParameter::clear_has_kernel_size() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+inline void PoolingParameter::clear_kernel_size() {
+ kernel_size_ = 0u;
+ clear_has_kernel_size();
+}
+inline ::google::protobuf::uint32 PoolingParameter::kernel_size() const {
+ // @@protoc_insertion_point(field_get:caffe.PoolingParameter.kernel_size)
+ return kernel_size_;
+}
+inline void PoolingParameter::set_kernel_size(::google::protobuf::uint32 value) {
+ set_has_kernel_size();
+ kernel_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PoolingParameter.kernel_size)
+}
+
+// optional uint32 kernel_h = 5;
+inline bool PoolingParameter::has_kernel_h() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+inline void PoolingParameter::set_has_kernel_h() {
+ _has_bits_[0] |= 0x00000020u;
+}
+inline void PoolingParameter::clear_has_kernel_h() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+inline void PoolingParameter::clear_kernel_h() {
+ kernel_h_ = 0u;
+ clear_has_kernel_h();
+}
+inline ::google::protobuf::uint32 PoolingParameter::kernel_h() const {
+ // @@protoc_insertion_point(field_get:caffe.PoolingParameter.kernel_h)
+ return kernel_h_;
+}
+inline void PoolingParameter::set_kernel_h(::google::protobuf::uint32 value) {
+ set_has_kernel_h();
+ kernel_h_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PoolingParameter.kernel_h)
+}
+
+// optional uint32 kernel_w = 6;
+inline bool PoolingParameter::has_kernel_w() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+inline void PoolingParameter::set_has_kernel_w() {
+ _has_bits_[0] |= 0x00000040u;
+}
+inline void PoolingParameter::clear_has_kernel_w() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+inline void PoolingParameter::clear_kernel_w() {
+ kernel_w_ = 0u;
+ clear_has_kernel_w();
+}
+inline ::google::protobuf::uint32 PoolingParameter::kernel_w() const {
+ // @@protoc_insertion_point(field_get:caffe.PoolingParameter.kernel_w)
+ return kernel_w_;
+}
+inline void PoolingParameter::set_kernel_w(::google::protobuf::uint32 value) {
+ set_has_kernel_w();
+ kernel_w_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PoolingParameter.kernel_w)
+}
+
+// optional uint32 stride = 3 [default = 1];
+inline bool PoolingParameter::has_stride() const {
+ return (_has_bits_[0] & 0x00000080u) != 0;
+}
+inline void PoolingParameter::set_has_stride() {
+ _has_bits_[0] |= 0x00000080u;
+}
+inline void PoolingParameter::clear_has_stride() {
+ _has_bits_[0] &= ~0x00000080u;
+}
+inline void PoolingParameter::clear_stride() {
+ stride_ = 1u;
+ clear_has_stride();
+}
+inline ::google::protobuf::uint32 PoolingParameter::stride() const {
+ // @@protoc_insertion_point(field_get:caffe.PoolingParameter.stride)
+ return stride_;
+}
+inline void PoolingParameter::set_stride(::google::protobuf::uint32 value) {
+ set_has_stride();
+ stride_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PoolingParameter.stride)
+}
+
+// optional uint32 stride_h = 7;
+inline bool PoolingParameter::has_stride_h() const {
+ return (_has_bits_[0] & 0x00000100u) != 0;
+}
+inline void PoolingParameter::set_has_stride_h() {
+ _has_bits_[0] |= 0x00000100u;
+}
+inline void PoolingParameter::clear_has_stride_h() {
+ _has_bits_[0] &= ~0x00000100u;
+}
+inline void PoolingParameter::clear_stride_h() {
+ stride_h_ = 0u;
+ clear_has_stride_h();
+}
+inline ::google::protobuf::uint32 PoolingParameter::stride_h() const {
+ // @@protoc_insertion_point(field_get:caffe.PoolingParameter.stride_h)
+ return stride_h_;
+}
+inline void PoolingParameter::set_stride_h(::google::protobuf::uint32 value) {
+ set_has_stride_h();
+ stride_h_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PoolingParameter.stride_h)
+}
+
+// optional uint32 stride_w = 8;
+inline bool PoolingParameter::has_stride_w() const {
+ return (_has_bits_[0] & 0x00000200u) != 0;
+}
+inline void PoolingParameter::set_has_stride_w() {
+ _has_bits_[0] |= 0x00000200u;
+}
+inline void PoolingParameter::clear_has_stride_w() {
+ _has_bits_[0] &= ~0x00000200u;
+}
+inline void PoolingParameter::clear_stride_w() {
+ stride_w_ = 0u;
+ clear_has_stride_w();
+}
+inline ::google::protobuf::uint32 PoolingParameter::stride_w() const {
+ // @@protoc_insertion_point(field_get:caffe.PoolingParameter.stride_w)
+ return stride_w_;
+}
+inline void PoolingParameter::set_stride_w(::google::protobuf::uint32 value) {
+ set_has_stride_w();
+ stride_w_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PoolingParameter.stride_w)
+}
+
+// optional .caffe.PoolingParameter.Engine engine = 11 [default = DEFAULT];
+inline bool PoolingParameter::has_engine() const {
+ return (_has_bits_[0] & 0x00000400u) != 0;
+}
+inline void PoolingParameter::set_has_engine() {
+ _has_bits_[0] |= 0x00000400u;
+}
+inline void PoolingParameter::clear_has_engine() {
+ _has_bits_[0] &= ~0x00000400u;
+}
+inline void PoolingParameter::clear_engine() {
+ engine_ = 0;
+ clear_has_engine();
+}
+inline ::caffe::PoolingParameter_Engine PoolingParameter::engine() const {
+ // @@protoc_insertion_point(field_get:caffe.PoolingParameter.engine)
+ return static_cast< ::caffe::PoolingParameter_Engine >(engine_);
+}
+inline void PoolingParameter::set_engine(::caffe::PoolingParameter_Engine value) {
+ assert(::caffe::PoolingParameter_Engine_IsValid(value));
+ set_has_engine();
+ engine_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PoolingParameter.engine)
+}
+
+// optional bool global_pooling = 12 [default = false];
+inline bool PoolingParameter::has_global_pooling() const {
+ return (_has_bits_[0] & 0x00000800u) != 0;
+}
+inline void PoolingParameter::set_has_global_pooling() {
+ _has_bits_[0] |= 0x00000800u;
+}
+inline void PoolingParameter::clear_has_global_pooling() {
+ _has_bits_[0] &= ~0x00000800u;
+}
+inline void PoolingParameter::clear_global_pooling() {
+ global_pooling_ = false;
+ clear_has_global_pooling();
+}
+inline bool PoolingParameter::global_pooling() const {
+ // @@protoc_insertion_point(field_get:caffe.PoolingParameter.global_pooling)
+ return global_pooling_;
+}
+inline void PoolingParameter::set_global_pooling(bool value) {
+ set_has_global_pooling();
+ global_pooling_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PoolingParameter.global_pooling)
+}
+
+inline const PoolingParameter* PoolingParameter::internal_default_instance() {
+ return &PoolingParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// PowerParameter
+
+// optional float power = 1 [default = 1];
+inline bool PowerParameter::has_power() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void PowerParameter::set_has_power() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void PowerParameter::clear_has_power() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void PowerParameter::clear_power() {
+ power_ = 1;
+ clear_has_power();
+}
+inline float PowerParameter::power() const {
+ // @@protoc_insertion_point(field_get:caffe.PowerParameter.power)
+ return power_;
+}
+inline void PowerParameter::set_power(float value) {
+ set_has_power();
+ power_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PowerParameter.power)
+}
+
+// optional float scale = 2 [default = 1];
+inline bool PowerParameter::has_scale() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void PowerParameter::set_has_scale() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void PowerParameter::clear_has_scale() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void PowerParameter::clear_scale() {
+ scale_ = 1;
+ clear_has_scale();
+}
+inline float PowerParameter::scale() const {
+ // @@protoc_insertion_point(field_get:caffe.PowerParameter.scale)
+ return scale_;
+}
+inline void PowerParameter::set_scale(float value) {
+ set_has_scale();
+ scale_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PowerParameter.scale)
+}
+
+// optional float shift = 3 [default = 0];
+inline bool PowerParameter::has_shift() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void PowerParameter::set_has_shift() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void PowerParameter::clear_has_shift() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void PowerParameter::clear_shift() {
+ shift_ = 0;
+ clear_has_shift();
+}
+inline float PowerParameter::shift() const {
+ // @@protoc_insertion_point(field_get:caffe.PowerParameter.shift)
+ return shift_;
+}
+inline void PowerParameter::set_shift(float value) {
+ set_has_shift();
+ shift_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PowerParameter.shift)
+}
+
+inline const PowerParameter* PowerParameter::internal_default_instance() {
+ return &PowerParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// PythonParameter
+
+// optional string module = 1;
+inline bool PythonParameter::has_module() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void PythonParameter::set_has_module() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void PythonParameter::clear_has_module() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void PythonParameter::clear_module() {
+ module_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_module();
+}
+inline const ::std::string& PythonParameter::module() const {
+ // @@protoc_insertion_point(field_get:caffe.PythonParameter.module)
+ return module_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void PythonParameter::set_module(const ::std::string& value) {
+ set_has_module();
+ module_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.PythonParameter.module)
+}
+inline void PythonParameter::set_module(const char* value) {
+ set_has_module();
+ module_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.PythonParameter.module)
+}
+inline void PythonParameter::set_module(const char* value, size_t size) {
+ set_has_module();
+ module_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.PythonParameter.module)
+}
+inline ::std::string* PythonParameter::mutable_module() {
+ set_has_module();
+ // @@protoc_insertion_point(field_mutable:caffe.PythonParameter.module)
+ return module_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* PythonParameter::release_module() {
+ // @@protoc_insertion_point(field_release:caffe.PythonParameter.module)
+ clear_has_module();
+ return module_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void PythonParameter::set_allocated_module(::std::string* module) {
+ if (module != NULL) {
+ set_has_module();
+ } else {
+ clear_has_module();
+ }
+ module_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), module);
+ // @@protoc_insertion_point(field_set_allocated:caffe.PythonParameter.module)
+}
+
+// optional string layer = 2;
+inline bool PythonParameter::has_layer() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void PythonParameter::set_has_layer() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void PythonParameter::clear_has_layer() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void PythonParameter::clear_layer() {
+ layer_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_layer();
+}
+inline const ::std::string& PythonParameter::layer() const {
+ // @@protoc_insertion_point(field_get:caffe.PythonParameter.layer)
+ return layer_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void PythonParameter::set_layer(const ::std::string& value) {
+ set_has_layer();
+ layer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.PythonParameter.layer)
+}
+inline void PythonParameter::set_layer(const char* value) {
+ set_has_layer();
+ layer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.PythonParameter.layer)
+}
+inline void PythonParameter::set_layer(const char* value, size_t size) {
+ set_has_layer();
+ layer_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.PythonParameter.layer)
+}
+inline ::std::string* PythonParameter::mutable_layer() {
+ set_has_layer();
+ // @@protoc_insertion_point(field_mutable:caffe.PythonParameter.layer)
+ return layer_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* PythonParameter::release_layer() {
+ // @@protoc_insertion_point(field_release:caffe.PythonParameter.layer)
+ clear_has_layer();
+ return layer_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void PythonParameter::set_allocated_layer(::std::string* layer) {
+ if (layer != NULL) {
+ set_has_layer();
+ } else {
+ clear_has_layer();
+ }
+ layer_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), layer);
+ // @@protoc_insertion_point(field_set_allocated:caffe.PythonParameter.layer)
+}
+
+// optional string param_str = 3 [default = ""];
+inline bool PythonParameter::has_param_str() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void PythonParameter::set_has_param_str() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void PythonParameter::clear_has_param_str() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void PythonParameter::clear_param_str() {
+ param_str_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_param_str();
+}
+inline const ::std::string& PythonParameter::param_str() const {
+ // @@protoc_insertion_point(field_get:caffe.PythonParameter.param_str)
+ return param_str_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void PythonParameter::set_param_str(const ::std::string& value) {
+ set_has_param_str();
+ param_str_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.PythonParameter.param_str)
+}
+inline void PythonParameter::set_param_str(const char* value) {
+ set_has_param_str();
+ param_str_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.PythonParameter.param_str)
+}
+inline void PythonParameter::set_param_str(const char* value, size_t size) {
+ set_has_param_str();
+ param_str_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.PythonParameter.param_str)
+}
+inline ::std::string* PythonParameter::mutable_param_str() {
+ set_has_param_str();
+ // @@protoc_insertion_point(field_mutable:caffe.PythonParameter.param_str)
+ return param_str_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* PythonParameter::release_param_str() {
+ // @@protoc_insertion_point(field_release:caffe.PythonParameter.param_str)
+ clear_has_param_str();
+ return param_str_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void PythonParameter::set_allocated_param_str(::std::string* param_str) {
+ if (param_str != NULL) {
+ set_has_param_str();
+ } else {
+ clear_has_param_str();
+ }
+ param_str_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), param_str);
+ // @@protoc_insertion_point(field_set_allocated:caffe.PythonParameter.param_str)
+}
+
+// optional bool share_in_parallel = 4 [default = false];
+inline bool PythonParameter::has_share_in_parallel() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void PythonParameter::set_has_share_in_parallel() {
+ _has_bits_[0] |= 0x00000008u;
+}
+inline void PythonParameter::clear_has_share_in_parallel() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+inline void PythonParameter::clear_share_in_parallel() {
+ share_in_parallel_ = false;
+ clear_has_share_in_parallel();
+}
+inline bool PythonParameter::share_in_parallel() const {
+ // @@protoc_insertion_point(field_get:caffe.PythonParameter.share_in_parallel)
+ return share_in_parallel_;
+}
+inline void PythonParameter::set_share_in_parallel(bool value) {
+ set_has_share_in_parallel();
+ share_in_parallel_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PythonParameter.share_in_parallel)
+}
+
+inline const PythonParameter* PythonParameter::internal_default_instance() {
+ return &PythonParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// RecurrentParameter
+
+// optional uint32 num_output = 1 [default = 0];
+inline bool RecurrentParameter::has_num_output() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void RecurrentParameter::set_has_num_output() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void RecurrentParameter::clear_has_num_output() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void RecurrentParameter::clear_num_output() {
+ num_output_ = 0u;
+ clear_has_num_output();
+}
+inline ::google::protobuf::uint32 RecurrentParameter::num_output() const {
+ // @@protoc_insertion_point(field_get:caffe.RecurrentParameter.num_output)
+ return num_output_;
+}
+inline void RecurrentParameter::set_num_output(::google::protobuf::uint32 value) {
+ set_has_num_output();
+ num_output_ = value;
+ // @@protoc_insertion_point(field_set:caffe.RecurrentParameter.num_output)
+}
+
+// optional .caffe.FillerParameter weight_filler = 2;
+inline bool RecurrentParameter::has_weight_filler() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void RecurrentParameter::set_has_weight_filler() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void RecurrentParameter::clear_has_weight_filler() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void RecurrentParameter::clear_weight_filler() {
+ if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear();
+ clear_has_weight_filler();
+}
+inline const ::caffe::FillerParameter& RecurrentParameter::weight_filler() const {
+ // @@protoc_insertion_point(field_get:caffe.RecurrentParameter.weight_filler)
+ return weight_filler_ != NULL ? *weight_filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+inline ::caffe::FillerParameter* RecurrentParameter::mutable_weight_filler() {
+ set_has_weight_filler();
+ if (weight_filler_ == NULL) {
+ weight_filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.RecurrentParameter.weight_filler)
+ return weight_filler_;
+}
+inline ::caffe::FillerParameter* RecurrentParameter::release_weight_filler() {
+ // @@protoc_insertion_point(field_release:caffe.RecurrentParameter.weight_filler)
+ clear_has_weight_filler();
+ ::caffe::FillerParameter* temp = weight_filler_;
+ weight_filler_ = NULL;
+ return temp;
+}
+inline void RecurrentParameter::set_allocated_weight_filler(::caffe::FillerParameter* weight_filler) {
+ delete weight_filler_;
+ weight_filler_ = weight_filler;
+ if (weight_filler) {
+ set_has_weight_filler();
+ } else {
+ clear_has_weight_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.RecurrentParameter.weight_filler)
+}
+
+// optional .caffe.FillerParameter bias_filler = 3;
+inline bool RecurrentParameter::has_bias_filler() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void RecurrentParameter::set_has_bias_filler() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void RecurrentParameter::clear_has_bias_filler() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void RecurrentParameter::clear_bias_filler() {
+ if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
+ clear_has_bias_filler();
+}
+inline const ::caffe::FillerParameter& RecurrentParameter::bias_filler() const {
+ // @@protoc_insertion_point(field_get:caffe.RecurrentParameter.bias_filler)
+ return bias_filler_ != NULL ? *bias_filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+inline ::caffe::FillerParameter* RecurrentParameter::mutable_bias_filler() {
+ set_has_bias_filler();
+ if (bias_filler_ == NULL) {
+ bias_filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.RecurrentParameter.bias_filler)
+ return bias_filler_;
+}
+inline ::caffe::FillerParameter* RecurrentParameter::release_bias_filler() {
+ // @@protoc_insertion_point(field_release:caffe.RecurrentParameter.bias_filler)
+ clear_has_bias_filler();
+ ::caffe::FillerParameter* temp = bias_filler_;
+ bias_filler_ = NULL;
+ return temp;
+}
+inline void RecurrentParameter::set_allocated_bias_filler(::caffe::FillerParameter* bias_filler) {
+ delete bias_filler_;
+ bias_filler_ = bias_filler;
+ if (bias_filler) {
+ set_has_bias_filler();
+ } else {
+ clear_has_bias_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.RecurrentParameter.bias_filler)
+}
+
+// optional bool debug_info = 4 [default = false];
+inline bool RecurrentParameter::has_debug_info() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void RecurrentParameter::set_has_debug_info() {
+ _has_bits_[0] |= 0x00000008u;
+}
+inline void RecurrentParameter::clear_has_debug_info() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+inline void RecurrentParameter::clear_debug_info() {
+ debug_info_ = false;
+ clear_has_debug_info();
+}
+inline bool RecurrentParameter::debug_info() const {
+ // @@protoc_insertion_point(field_get:caffe.RecurrentParameter.debug_info)
+ return debug_info_;
+}
+inline void RecurrentParameter::set_debug_info(bool value) {
+ set_has_debug_info();
+ debug_info_ = value;
+ // @@protoc_insertion_point(field_set:caffe.RecurrentParameter.debug_info)
+}
+
+// optional bool expose_hidden = 5 [default = false];
+inline bool RecurrentParameter::has_expose_hidden() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+inline void RecurrentParameter::set_has_expose_hidden() {
+ _has_bits_[0] |= 0x00000010u;
+}
+inline void RecurrentParameter::clear_has_expose_hidden() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+inline void RecurrentParameter::clear_expose_hidden() {
+ expose_hidden_ = false;
+ clear_has_expose_hidden();
+}
+inline bool RecurrentParameter::expose_hidden() const {
+ // @@protoc_insertion_point(field_get:caffe.RecurrentParameter.expose_hidden)
+ return expose_hidden_;
+}
+inline void RecurrentParameter::set_expose_hidden(bool value) {
+ set_has_expose_hidden();
+ expose_hidden_ = value;
+ // @@protoc_insertion_point(field_set:caffe.RecurrentParameter.expose_hidden)
+}
+
+inline const RecurrentParameter* RecurrentParameter::internal_default_instance() {
+ return &RecurrentParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// ReductionParameter
+
+// optional .caffe.ReductionParameter.ReductionOp operation = 1 [default = SUM];
+inline bool ReductionParameter::has_operation() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void ReductionParameter::set_has_operation() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void ReductionParameter::clear_has_operation() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void ReductionParameter::clear_operation() {
+ operation_ = 1;
+ clear_has_operation();
+}
+inline ::caffe::ReductionParameter_ReductionOp ReductionParameter::operation() const {
+ // @@protoc_insertion_point(field_get:caffe.ReductionParameter.operation)
+ return static_cast< ::caffe::ReductionParameter_ReductionOp >(operation_);
+}
+inline void ReductionParameter::set_operation(::caffe::ReductionParameter_ReductionOp value) {
+ assert(::caffe::ReductionParameter_ReductionOp_IsValid(value));
+ set_has_operation();
+ operation_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ReductionParameter.operation)
+}
+
+// optional int32 axis = 2 [default = 0];
+inline bool ReductionParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void ReductionParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void ReductionParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void ReductionParameter::clear_axis() {
+ axis_ = 0;
+ clear_has_axis();
+}
+inline ::google::protobuf::int32 ReductionParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.ReductionParameter.axis)
+ return axis_;
+}
+inline void ReductionParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ReductionParameter.axis)
+}
+
+// optional float coeff = 3 [default = 1];
+inline bool ReductionParameter::has_coeff() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void ReductionParameter::set_has_coeff() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void ReductionParameter::clear_has_coeff() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void ReductionParameter::clear_coeff() {
+ coeff_ = 1;
+ clear_has_coeff();
+}
+inline float ReductionParameter::coeff() const {
+ // @@protoc_insertion_point(field_get:caffe.ReductionParameter.coeff)
+ return coeff_;
+}
+inline void ReductionParameter::set_coeff(float value) {
+ set_has_coeff();
+ coeff_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ReductionParameter.coeff)
+}
+
+inline const ReductionParameter* ReductionParameter::internal_default_instance() {
+ return &ReductionParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// ReLUParameter
+
+// optional float negative_slope = 1 [default = 0];
+inline bool ReLUParameter::has_negative_slope() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void ReLUParameter::set_has_negative_slope() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void ReLUParameter::clear_has_negative_slope() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void ReLUParameter::clear_negative_slope() {
+ negative_slope_ = 0;
+ clear_has_negative_slope();
+}
+inline float ReLUParameter::negative_slope() const {
+ // @@protoc_insertion_point(field_get:caffe.ReLUParameter.negative_slope)
+ return negative_slope_;
+}
+inline void ReLUParameter::set_negative_slope(float value) {
+ set_has_negative_slope();
+ negative_slope_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ReLUParameter.negative_slope)
+}
+
+// optional .caffe.ReLUParameter.Engine engine = 2 [default = DEFAULT];
+inline bool ReLUParameter::has_engine() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void ReLUParameter::set_has_engine() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void ReLUParameter::clear_has_engine() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void ReLUParameter::clear_engine() {
+ engine_ = 0;
+ clear_has_engine();
+}
+inline ::caffe::ReLUParameter_Engine ReLUParameter::engine() const {
+ // @@protoc_insertion_point(field_get:caffe.ReLUParameter.engine)
+ return static_cast< ::caffe::ReLUParameter_Engine >(engine_);
+}
+inline void ReLUParameter::set_engine(::caffe::ReLUParameter_Engine value) {
+ assert(::caffe::ReLUParameter_Engine_IsValid(value));
+ set_has_engine();
+ engine_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ReLUParameter.engine)
+}
+
+inline const ReLUParameter* ReLUParameter::internal_default_instance() {
+ return &ReLUParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// ReshapeParameter
+
+// optional .caffe.BlobShape shape = 1;
+inline bool ReshapeParameter::has_shape() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void ReshapeParameter::set_has_shape() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void ReshapeParameter::clear_has_shape() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void ReshapeParameter::clear_shape() {
+ if (shape_ != NULL) shape_->::caffe::BlobShape::Clear();
+ clear_has_shape();
+}
+inline const ::caffe::BlobShape& ReshapeParameter::shape() const {
+ // @@protoc_insertion_point(field_get:caffe.ReshapeParameter.shape)
+ return shape_ != NULL ? *shape_
+ : *::caffe::BlobShape::internal_default_instance();
+}
+inline ::caffe::BlobShape* ReshapeParameter::mutable_shape() {
+ set_has_shape();
+ if (shape_ == NULL) {
+ shape_ = new ::caffe::BlobShape;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.ReshapeParameter.shape)
+ return shape_;
+}
+inline ::caffe::BlobShape* ReshapeParameter::release_shape() {
+ // @@protoc_insertion_point(field_release:caffe.ReshapeParameter.shape)
+ clear_has_shape();
+ ::caffe::BlobShape* temp = shape_;
+ shape_ = NULL;
+ return temp;
+}
+inline void ReshapeParameter::set_allocated_shape(::caffe::BlobShape* shape) {
+ delete shape_;
+ shape_ = shape;
+ if (shape) {
+ set_has_shape();
+ } else {
+ clear_has_shape();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.ReshapeParameter.shape)
+}
+
+// optional int32 axis = 2 [default = 0];
+inline bool ReshapeParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void ReshapeParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void ReshapeParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void ReshapeParameter::clear_axis() {
+ axis_ = 0;
+ clear_has_axis();
+}
+inline ::google::protobuf::int32 ReshapeParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.ReshapeParameter.axis)
+ return axis_;
+}
+inline void ReshapeParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ReshapeParameter.axis)
+}
+
+// optional int32 num_axes = 3 [default = -1];
+inline bool ReshapeParameter::has_num_axes() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void ReshapeParameter::set_has_num_axes() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void ReshapeParameter::clear_has_num_axes() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void ReshapeParameter::clear_num_axes() {
+ num_axes_ = -1;
+ clear_has_num_axes();
+}
+inline ::google::protobuf::int32 ReshapeParameter::num_axes() const {
+ // @@protoc_insertion_point(field_get:caffe.ReshapeParameter.num_axes)
+ return num_axes_;
+}
+inline void ReshapeParameter::set_num_axes(::google::protobuf::int32 value) {
+ set_has_num_axes();
+ num_axes_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ReshapeParameter.num_axes)
+}
+
+inline const ReshapeParameter* ReshapeParameter::internal_default_instance() {
+ return &ReshapeParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// ScaleParameter
+
+// optional int32 axis = 1 [default = 1];
+inline bool ScaleParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void ScaleParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void ScaleParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void ScaleParameter::clear_axis() {
+ axis_ = 1;
+ clear_has_axis();
+}
+inline ::google::protobuf::int32 ScaleParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.ScaleParameter.axis)
+ return axis_;
+}
+inline void ScaleParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ScaleParameter.axis)
+}
+
+// optional int32 num_axes = 2 [default = 1];
+inline bool ScaleParameter::has_num_axes() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void ScaleParameter::set_has_num_axes() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void ScaleParameter::clear_has_num_axes() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void ScaleParameter::clear_num_axes() {
+ num_axes_ = 1;
+ clear_has_num_axes();
+}
+inline ::google::protobuf::int32 ScaleParameter::num_axes() const {
+ // @@protoc_insertion_point(field_get:caffe.ScaleParameter.num_axes)
+ return num_axes_;
+}
+inline void ScaleParameter::set_num_axes(::google::protobuf::int32 value) {
+ set_has_num_axes();
+ num_axes_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ScaleParameter.num_axes)
+}
+
+// optional .caffe.FillerParameter filler = 3;
+inline bool ScaleParameter::has_filler() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void ScaleParameter::set_has_filler() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void ScaleParameter::clear_has_filler() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void ScaleParameter::clear_filler() {
+ if (filler_ != NULL) filler_->::caffe::FillerParameter::Clear();
+ clear_has_filler();
+}
+inline const ::caffe::FillerParameter& ScaleParameter::filler() const {
+ // @@protoc_insertion_point(field_get:caffe.ScaleParameter.filler)
+ return filler_ != NULL ? *filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+inline ::caffe::FillerParameter* ScaleParameter::mutable_filler() {
+ set_has_filler();
+ if (filler_ == NULL) {
+ filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.ScaleParameter.filler)
+ return filler_;
+}
+inline ::caffe::FillerParameter* ScaleParameter::release_filler() {
+ // @@protoc_insertion_point(field_release:caffe.ScaleParameter.filler)
+ clear_has_filler();
+ ::caffe::FillerParameter* temp = filler_;
+ filler_ = NULL;
+ return temp;
+}
+inline void ScaleParameter::set_allocated_filler(::caffe::FillerParameter* filler) {
+ delete filler_;
+ filler_ = filler;
+ if (filler) {
+ set_has_filler();
+ } else {
+ clear_has_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.ScaleParameter.filler)
+}
+
+// optional bool bias_term = 4 [default = false];
+inline bool ScaleParameter::has_bias_term() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void ScaleParameter::set_has_bias_term() {
+ _has_bits_[0] |= 0x00000008u;
+}
+inline void ScaleParameter::clear_has_bias_term() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+inline void ScaleParameter::clear_bias_term() {
+ bias_term_ = false;
+ clear_has_bias_term();
+}
+inline bool ScaleParameter::bias_term() const {
+ // @@protoc_insertion_point(field_get:caffe.ScaleParameter.bias_term)
+ return bias_term_;
+}
+inline void ScaleParameter::set_bias_term(bool value) {
+ set_has_bias_term();
+ bias_term_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ScaleParameter.bias_term)
+}
+
+// optional .caffe.FillerParameter bias_filler = 5;
+inline bool ScaleParameter::has_bias_filler() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+inline void ScaleParameter::set_has_bias_filler() {
+ _has_bits_[0] |= 0x00000010u;
+}
+inline void ScaleParameter::clear_has_bias_filler() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+inline void ScaleParameter::clear_bias_filler() {
+ if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
+ clear_has_bias_filler();
+}
+inline const ::caffe::FillerParameter& ScaleParameter::bias_filler() const {
+ // @@protoc_insertion_point(field_get:caffe.ScaleParameter.bias_filler)
+ return bias_filler_ != NULL ? *bias_filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+inline ::caffe::FillerParameter* ScaleParameter::mutable_bias_filler() {
+ set_has_bias_filler();
+ if (bias_filler_ == NULL) {
+ bias_filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.ScaleParameter.bias_filler)
+ return bias_filler_;
+}
+inline ::caffe::FillerParameter* ScaleParameter::release_bias_filler() {
+ // @@protoc_insertion_point(field_release:caffe.ScaleParameter.bias_filler)
+ clear_has_bias_filler();
+ ::caffe::FillerParameter* temp = bias_filler_;
+ bias_filler_ = NULL;
+ return temp;
+}
+inline void ScaleParameter::set_allocated_bias_filler(::caffe::FillerParameter* bias_filler) {
+ delete bias_filler_;
+ bias_filler_ = bias_filler;
+ if (bias_filler) {
+ set_has_bias_filler();
+ } else {
+ clear_has_bias_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.ScaleParameter.bias_filler)
+}
+
+inline const ScaleParameter* ScaleParameter::internal_default_instance() {
+ return &ScaleParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// SigmoidParameter
+
+// optional .caffe.SigmoidParameter.Engine engine = 1 [default = DEFAULT];
+inline bool SigmoidParameter::has_engine() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void SigmoidParameter::set_has_engine() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void SigmoidParameter::clear_has_engine() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void SigmoidParameter::clear_engine() {
+ engine_ = 0;
+ clear_has_engine();
+}
+inline ::caffe::SigmoidParameter_Engine SigmoidParameter::engine() const {
+ // @@protoc_insertion_point(field_get:caffe.SigmoidParameter.engine)
+ return static_cast< ::caffe::SigmoidParameter_Engine >(engine_);
+}
+inline void SigmoidParameter::set_engine(::caffe::SigmoidParameter_Engine value) {
+ assert(::caffe::SigmoidParameter_Engine_IsValid(value));
+ set_has_engine();
+ engine_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SigmoidParameter.engine)
+}
+
+inline const SigmoidParameter* SigmoidParameter::internal_default_instance() {
+ return &SigmoidParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// SliceParameter
+
+// optional int32 axis = 3 [default = 1];
+inline bool SliceParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void SliceParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void SliceParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void SliceParameter::clear_axis() {
+ axis_ = 1;
+ clear_has_axis();
+}
+inline ::google::protobuf::int32 SliceParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.SliceParameter.axis)
+ return axis_;
+}
+inline void SliceParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SliceParameter.axis)
+}
+
+// repeated uint32 slice_point = 2;
+inline int SliceParameter::slice_point_size() const {
+ return slice_point_.size();
+}
+inline void SliceParameter::clear_slice_point() {
+ slice_point_.Clear();
+}
+inline ::google::protobuf::uint32 SliceParameter::slice_point(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.SliceParameter.slice_point)
+ return slice_point_.Get(index);
+}
+inline void SliceParameter::set_slice_point(int index, ::google::protobuf::uint32 value) {
+ slice_point_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.SliceParameter.slice_point)
+}
+inline void SliceParameter::add_slice_point(::google::protobuf::uint32 value) {
+ slice_point_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.SliceParameter.slice_point)
+}
+inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
+SliceParameter::slice_point() const {
+ // @@protoc_insertion_point(field_list:caffe.SliceParameter.slice_point)
+ return slice_point_;
+}
+inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
+SliceParameter::mutable_slice_point() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.SliceParameter.slice_point)
+ return &slice_point_;
+}
+
+// optional uint32 slice_dim = 1 [default = 1];
+inline bool SliceParameter::has_slice_dim() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void SliceParameter::set_has_slice_dim() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void SliceParameter::clear_has_slice_dim() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void SliceParameter::clear_slice_dim() {
+ slice_dim_ = 1u;
+ clear_has_slice_dim();
+}
+inline ::google::protobuf::uint32 SliceParameter::slice_dim() const {
+ // @@protoc_insertion_point(field_get:caffe.SliceParameter.slice_dim)
+ return slice_dim_;
+}
+inline void SliceParameter::set_slice_dim(::google::protobuf::uint32 value) {
+ set_has_slice_dim();
+ slice_dim_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SliceParameter.slice_dim)
+}
+
+inline const SliceParameter* SliceParameter::internal_default_instance() {
+ return &SliceParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// SoftmaxParameter
+
+// optional .caffe.SoftmaxParameter.Engine engine = 1 [default = DEFAULT];
+inline bool SoftmaxParameter::has_engine() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void SoftmaxParameter::set_has_engine() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void SoftmaxParameter::clear_has_engine() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void SoftmaxParameter::clear_engine() {
+ engine_ = 0;
+ clear_has_engine();
+}
+inline ::caffe::SoftmaxParameter_Engine SoftmaxParameter::engine() const {
+ // @@protoc_insertion_point(field_get:caffe.SoftmaxParameter.engine)
+ return static_cast< ::caffe::SoftmaxParameter_Engine >(engine_);
+}
+inline void SoftmaxParameter::set_engine(::caffe::SoftmaxParameter_Engine value) {
+ assert(::caffe::SoftmaxParameter_Engine_IsValid(value));
+ set_has_engine();
+ engine_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SoftmaxParameter.engine)
+}
+
+// optional int32 axis = 2 [default = 1];
+inline bool SoftmaxParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void SoftmaxParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void SoftmaxParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void SoftmaxParameter::clear_axis() {
+ axis_ = 1;
+ clear_has_axis();
+}
+inline ::google::protobuf::int32 SoftmaxParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.SoftmaxParameter.axis)
+ return axis_;
+}
+inline void SoftmaxParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SoftmaxParameter.axis)
+}
+
+inline const SoftmaxParameter* SoftmaxParameter::internal_default_instance() {
+ return &SoftmaxParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// TanHParameter
+
+// optional .caffe.TanHParameter.Engine engine = 1 [default = DEFAULT];
+inline bool TanHParameter::has_engine() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void TanHParameter::set_has_engine() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void TanHParameter::clear_has_engine() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void TanHParameter::clear_engine() {
+ engine_ = 0;
+ clear_has_engine();
+}
+inline ::caffe::TanHParameter_Engine TanHParameter::engine() const {
+ // @@protoc_insertion_point(field_get:caffe.TanHParameter.engine)
+ return static_cast< ::caffe::TanHParameter_Engine >(engine_);
+}
+inline void TanHParameter::set_engine(::caffe::TanHParameter_Engine value) {
+ assert(::caffe::TanHParameter_Engine_IsValid(value));
+ set_has_engine();
+ engine_ = value;
+ // @@protoc_insertion_point(field_set:caffe.TanHParameter.engine)
+}
+
+inline const TanHParameter* TanHParameter::internal_default_instance() {
+ return &TanHParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// TileParameter
+
+// optional int32 axis = 1 [default = 1];
+inline bool TileParameter::has_axis() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void TileParameter::set_has_axis() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void TileParameter::clear_has_axis() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void TileParameter::clear_axis() {
+ axis_ = 1;
+ clear_has_axis();
+}
+inline ::google::protobuf::int32 TileParameter::axis() const {
+ // @@protoc_insertion_point(field_get:caffe.TileParameter.axis)
+ return axis_;
+}
+inline void TileParameter::set_axis(::google::protobuf::int32 value) {
+ set_has_axis();
+ axis_ = value;
+ // @@protoc_insertion_point(field_set:caffe.TileParameter.axis)
+}
+
+// optional int32 tiles = 2;
+inline bool TileParameter::has_tiles() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void TileParameter::set_has_tiles() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void TileParameter::clear_has_tiles() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void TileParameter::clear_tiles() {
+ tiles_ = 0;
+ clear_has_tiles();
+}
+inline ::google::protobuf::int32 TileParameter::tiles() const {
+ // @@protoc_insertion_point(field_get:caffe.TileParameter.tiles)
+ return tiles_;
+}
+inline void TileParameter::set_tiles(::google::protobuf::int32 value) {
+ set_has_tiles();
+ tiles_ = value;
+ // @@protoc_insertion_point(field_set:caffe.TileParameter.tiles)
+}
+
+inline const TileParameter* TileParameter::internal_default_instance() {
+ return &TileParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// ThresholdParameter
+
+// optional float threshold = 1 [default = 0];
+inline bool ThresholdParameter::has_threshold() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void ThresholdParameter::set_has_threshold() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void ThresholdParameter::clear_has_threshold() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void ThresholdParameter::clear_threshold() {
+ threshold_ = 0;
+ clear_has_threshold();
+}
+inline float ThresholdParameter::threshold() const {
+ // @@protoc_insertion_point(field_get:caffe.ThresholdParameter.threshold)
+ return threshold_;
+}
+inline void ThresholdParameter::set_threshold(float value) {
+ set_has_threshold();
+ threshold_ = value;
+ // @@protoc_insertion_point(field_set:caffe.ThresholdParameter.threshold)
+}
+
+inline const ThresholdParameter* ThresholdParameter::internal_default_instance() {
+ return &ThresholdParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// WindowDataParameter
+
+// optional string source = 1;
+inline bool WindowDataParameter::has_source() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void WindowDataParameter::set_has_source() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void WindowDataParameter::clear_has_source() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void WindowDataParameter::clear_source() {
+ source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_source();
+}
+inline const ::std::string& WindowDataParameter::source() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.source)
+ return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void WindowDataParameter::set_source(const ::std::string& value) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.source)
+}
+inline void WindowDataParameter::set_source(const char* value) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.WindowDataParameter.source)
+}
+inline void WindowDataParameter::set_source(const char* value, size_t size) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.WindowDataParameter.source)
+}
+inline ::std::string* WindowDataParameter::mutable_source() {
+ set_has_source();
+ // @@protoc_insertion_point(field_mutable:caffe.WindowDataParameter.source)
+ return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* WindowDataParameter::release_source() {
+ // @@protoc_insertion_point(field_release:caffe.WindowDataParameter.source)
+ clear_has_source();
+ return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void WindowDataParameter::set_allocated_source(::std::string* source) {
+ if (source != NULL) {
+ set_has_source();
+ } else {
+ clear_has_source();
+ }
+ source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source);
+ // @@protoc_insertion_point(field_set_allocated:caffe.WindowDataParameter.source)
+}
+
+// optional float scale = 2 [default = 1];
+inline bool WindowDataParameter::has_scale() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void WindowDataParameter::set_has_scale() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void WindowDataParameter::clear_has_scale() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void WindowDataParameter::clear_scale() {
+ scale_ = 1;
+ clear_has_scale();
+}
+inline float WindowDataParameter::scale() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.scale)
+ return scale_;
+}
+inline void WindowDataParameter::set_scale(float value) {
+ set_has_scale();
+ scale_ = value;
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.scale)
+}
+
+// optional string mean_file = 3;
+inline bool WindowDataParameter::has_mean_file() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void WindowDataParameter::set_has_mean_file() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void WindowDataParameter::clear_has_mean_file() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void WindowDataParameter::clear_mean_file() {
+ mean_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_mean_file();
+}
+inline const ::std::string& WindowDataParameter::mean_file() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.mean_file)
+ return mean_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void WindowDataParameter::set_mean_file(const ::std::string& value) {
+ set_has_mean_file();
+ mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.mean_file)
+}
+inline void WindowDataParameter::set_mean_file(const char* value) {
+ set_has_mean_file();
+ mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.WindowDataParameter.mean_file)
+}
+inline void WindowDataParameter::set_mean_file(const char* value, size_t size) {
+ set_has_mean_file();
+ mean_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.WindowDataParameter.mean_file)
+}
+inline ::std::string* WindowDataParameter::mutable_mean_file() {
+ set_has_mean_file();
+ // @@protoc_insertion_point(field_mutable:caffe.WindowDataParameter.mean_file)
+ return mean_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* WindowDataParameter::release_mean_file() {
+ // @@protoc_insertion_point(field_release:caffe.WindowDataParameter.mean_file)
+ clear_has_mean_file();
+ return mean_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void WindowDataParameter::set_allocated_mean_file(::std::string* mean_file) {
+ if (mean_file != NULL) {
+ set_has_mean_file();
+ } else {
+ clear_has_mean_file();
+ }
+ mean_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), mean_file);
+ // @@protoc_insertion_point(field_set_allocated:caffe.WindowDataParameter.mean_file)
+}
+
+// optional uint32 batch_size = 4;
+inline bool WindowDataParameter::has_batch_size() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void WindowDataParameter::set_has_batch_size() {
+ _has_bits_[0] |= 0x00000008u;
+}
+inline void WindowDataParameter::clear_has_batch_size() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+inline void WindowDataParameter::clear_batch_size() {
+ batch_size_ = 0u;
+ clear_has_batch_size();
+}
+inline ::google::protobuf::uint32 WindowDataParameter::batch_size() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.batch_size)
+ return batch_size_;
+}
+inline void WindowDataParameter::set_batch_size(::google::protobuf::uint32 value) {
+ set_has_batch_size();
+ batch_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.batch_size)
+}
+
+// optional uint32 crop_size = 5 [default = 0];
+inline bool WindowDataParameter::has_crop_size() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+inline void WindowDataParameter::set_has_crop_size() {
+ _has_bits_[0] |= 0x00000010u;
+}
+inline void WindowDataParameter::clear_has_crop_size() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+inline void WindowDataParameter::clear_crop_size() {
+ crop_size_ = 0u;
+ clear_has_crop_size();
+}
+inline ::google::protobuf::uint32 WindowDataParameter::crop_size() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.crop_size)
+ return crop_size_;
+}
+inline void WindowDataParameter::set_crop_size(::google::protobuf::uint32 value) {
+ set_has_crop_size();
+ crop_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.crop_size)
+}
+
+// optional bool mirror = 6 [default = false];
+inline bool WindowDataParameter::has_mirror() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+inline void WindowDataParameter::set_has_mirror() {
+ _has_bits_[0] |= 0x00000020u;
+}
+inline void WindowDataParameter::clear_has_mirror() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+inline void WindowDataParameter::clear_mirror() {
+ mirror_ = false;
+ clear_has_mirror();
+}
+inline bool WindowDataParameter::mirror() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.mirror)
+ return mirror_;
+}
+inline void WindowDataParameter::set_mirror(bool value) {
+ set_has_mirror();
+ mirror_ = value;
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.mirror)
+}
+
+// optional float fg_threshold = 7 [default = 0.5];
+inline bool WindowDataParameter::has_fg_threshold() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+inline void WindowDataParameter::set_has_fg_threshold() {
+ _has_bits_[0] |= 0x00000040u;
+}
+inline void WindowDataParameter::clear_has_fg_threshold() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+inline void WindowDataParameter::clear_fg_threshold() {
+ fg_threshold_ = 0.5f;
+ clear_has_fg_threshold();
+}
+inline float WindowDataParameter::fg_threshold() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.fg_threshold)
+ return fg_threshold_;
+}
+inline void WindowDataParameter::set_fg_threshold(float value) {
+ set_has_fg_threshold();
+ fg_threshold_ = value;
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.fg_threshold)
+}
+
+// optional float bg_threshold = 8 [default = 0.5];
+inline bool WindowDataParameter::has_bg_threshold() const {
+ return (_has_bits_[0] & 0x00000080u) != 0;
+}
+inline void WindowDataParameter::set_has_bg_threshold() {
+ _has_bits_[0] |= 0x00000080u;
+}
+inline void WindowDataParameter::clear_has_bg_threshold() {
+ _has_bits_[0] &= ~0x00000080u;
+}
+inline void WindowDataParameter::clear_bg_threshold() {
+ bg_threshold_ = 0.5f;
+ clear_has_bg_threshold();
+}
+inline float WindowDataParameter::bg_threshold() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.bg_threshold)
+ return bg_threshold_;
+}
+inline void WindowDataParameter::set_bg_threshold(float value) {
+ set_has_bg_threshold();
+ bg_threshold_ = value;
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.bg_threshold)
+}
+
+// optional float fg_fraction = 9 [default = 0.25];
+inline bool WindowDataParameter::has_fg_fraction() const {
+ return (_has_bits_[0] & 0x00000100u) != 0;
+}
+inline void WindowDataParameter::set_has_fg_fraction() {
+ _has_bits_[0] |= 0x00000100u;
+}
+inline void WindowDataParameter::clear_has_fg_fraction() {
+ _has_bits_[0] &= ~0x00000100u;
+}
+inline void WindowDataParameter::clear_fg_fraction() {
+ fg_fraction_ = 0.25f;
+ clear_has_fg_fraction();
+}
+inline float WindowDataParameter::fg_fraction() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.fg_fraction)
+ return fg_fraction_;
+}
+inline void WindowDataParameter::set_fg_fraction(float value) {
+ set_has_fg_fraction();
+ fg_fraction_ = value;
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.fg_fraction)
+}
+
+// optional uint32 context_pad = 10 [default = 0];
+inline bool WindowDataParameter::has_context_pad() const {
+ return (_has_bits_[0] & 0x00000200u) != 0;
+}
+inline void WindowDataParameter::set_has_context_pad() {
+ _has_bits_[0] |= 0x00000200u;
+}
+inline void WindowDataParameter::clear_has_context_pad() {
+ _has_bits_[0] &= ~0x00000200u;
+}
+inline void WindowDataParameter::clear_context_pad() {
+ context_pad_ = 0u;
+ clear_has_context_pad();
+}
+inline ::google::protobuf::uint32 WindowDataParameter::context_pad() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.context_pad)
+ return context_pad_;
+}
+inline void WindowDataParameter::set_context_pad(::google::protobuf::uint32 value) {
+ set_has_context_pad();
+ context_pad_ = value;
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.context_pad)
+}
+
+// optional string crop_mode = 11 [default = "warp"];
+inline bool WindowDataParameter::has_crop_mode() const {
+ return (_has_bits_[0] & 0x00000400u) != 0;
+}
+inline void WindowDataParameter::set_has_crop_mode() {
+ _has_bits_[0] |= 0x00000400u;
+}
+inline void WindowDataParameter::clear_has_crop_mode() {
+ _has_bits_[0] &= ~0x00000400u;
+}
+inline void WindowDataParameter::clear_crop_mode() {
+ crop_mode_.ClearToDefaultNoArena(_default_crop_mode_);
+ clear_has_crop_mode();
+}
+inline const ::std::string& WindowDataParameter::crop_mode() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.crop_mode)
+ return crop_mode_.GetNoArena(_default_crop_mode_);
+}
+inline void WindowDataParameter::set_crop_mode(const ::std::string& value) {
+ set_has_crop_mode();
+ crop_mode_.SetNoArena(_default_crop_mode_, value);
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.crop_mode)
+}
+inline void WindowDataParameter::set_crop_mode(const char* value) {
+ set_has_crop_mode();
+ crop_mode_.SetNoArena(_default_crop_mode_, ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.WindowDataParameter.crop_mode)
+}
+inline void WindowDataParameter::set_crop_mode(const char* value, size_t size) {
+ set_has_crop_mode();
+ crop_mode_.SetNoArena(_default_crop_mode_,
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.WindowDataParameter.crop_mode)
+}
+inline ::std::string* WindowDataParameter::mutable_crop_mode() {
+ set_has_crop_mode();
+ // @@protoc_insertion_point(field_mutable:caffe.WindowDataParameter.crop_mode)
+ return crop_mode_.MutableNoArena(_default_crop_mode_);
+}
+inline ::std::string* WindowDataParameter::release_crop_mode() {
+ // @@protoc_insertion_point(field_release:caffe.WindowDataParameter.crop_mode)
+ clear_has_crop_mode();
+ return crop_mode_.ReleaseNoArena(_default_crop_mode_);
+}
+inline void WindowDataParameter::set_allocated_crop_mode(::std::string* crop_mode) {
+ if (crop_mode != NULL) {
+ set_has_crop_mode();
+ } else {
+ clear_has_crop_mode();
+ }
+ crop_mode_.SetAllocatedNoArena(_default_crop_mode_, crop_mode);
+ // @@protoc_insertion_point(field_set_allocated:caffe.WindowDataParameter.crop_mode)
+}
+
+// optional bool cache_images = 12 [default = false];
+inline bool WindowDataParameter::has_cache_images() const {
+ return (_has_bits_[0] & 0x00000800u) != 0;
+}
+inline void WindowDataParameter::set_has_cache_images() {
+ _has_bits_[0] |= 0x00000800u;
+}
+inline void WindowDataParameter::clear_has_cache_images() {
+ _has_bits_[0] &= ~0x00000800u;
+}
+inline void WindowDataParameter::clear_cache_images() {
+ cache_images_ = false;
+ clear_has_cache_images();
+}
+inline bool WindowDataParameter::cache_images() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.cache_images)
+ return cache_images_;
+}
+inline void WindowDataParameter::set_cache_images(bool value) {
+ set_has_cache_images();
+ cache_images_ = value;
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.cache_images)
+}
+
+// optional string root_folder = 13 [default = ""];
+inline bool WindowDataParameter::has_root_folder() const {
+ return (_has_bits_[0] & 0x00001000u) != 0;
+}
+inline void WindowDataParameter::set_has_root_folder() {
+ _has_bits_[0] |= 0x00001000u;
+}
+inline void WindowDataParameter::clear_has_root_folder() {
+ _has_bits_[0] &= ~0x00001000u;
+}
+inline void WindowDataParameter::clear_root_folder() {
+ root_folder_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_root_folder();
+}
+inline const ::std::string& WindowDataParameter::root_folder() const {
+ // @@protoc_insertion_point(field_get:caffe.WindowDataParameter.root_folder)
+ return root_folder_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void WindowDataParameter::set_root_folder(const ::std::string& value) {
+ set_has_root_folder();
+ root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.WindowDataParameter.root_folder)
+}
+inline void WindowDataParameter::set_root_folder(const char* value) {
+ set_has_root_folder();
+ root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.WindowDataParameter.root_folder)
+}
+inline void WindowDataParameter::set_root_folder(const char* value, size_t size) {
+ set_has_root_folder();
+ root_folder_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.WindowDataParameter.root_folder)
+}
+inline ::std::string* WindowDataParameter::mutable_root_folder() {
+ set_has_root_folder();
+ // @@protoc_insertion_point(field_mutable:caffe.WindowDataParameter.root_folder)
+ return root_folder_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* WindowDataParameter::release_root_folder() {
+ // @@protoc_insertion_point(field_release:caffe.WindowDataParameter.root_folder)
+ clear_has_root_folder();
+ return root_folder_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void WindowDataParameter::set_allocated_root_folder(::std::string* root_folder) {
+ if (root_folder != NULL) {
+ set_has_root_folder();
+ } else {
+ clear_has_root_folder();
+ }
+ root_folder_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), root_folder);
+ // @@protoc_insertion_point(field_set_allocated:caffe.WindowDataParameter.root_folder)
+}
+
+inline const WindowDataParameter* WindowDataParameter::internal_default_instance() {
+ return &WindowDataParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// SPPParameter
+
+// optional uint32 pyramid_height = 1;
+inline bool SPPParameter::has_pyramid_height() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void SPPParameter::set_has_pyramid_height() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void SPPParameter::clear_has_pyramid_height() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void SPPParameter::clear_pyramid_height() {
+ pyramid_height_ = 0u;
+ clear_has_pyramid_height();
+}
+inline ::google::protobuf::uint32 SPPParameter::pyramid_height() const {
+ // @@protoc_insertion_point(field_get:caffe.SPPParameter.pyramid_height)
+ return pyramid_height_;
+}
+inline void SPPParameter::set_pyramid_height(::google::protobuf::uint32 value) {
+ set_has_pyramid_height();
+ pyramid_height_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SPPParameter.pyramid_height)
+}
+
+// optional .caffe.SPPParameter.PoolMethod pool = 2 [default = MAX];
+inline bool SPPParameter::has_pool() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void SPPParameter::set_has_pool() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void SPPParameter::clear_has_pool() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void SPPParameter::clear_pool() {
+ pool_ = 0;
+ clear_has_pool();
+}
+inline ::caffe::SPPParameter_PoolMethod SPPParameter::pool() const {
+ // @@protoc_insertion_point(field_get:caffe.SPPParameter.pool)
+ return static_cast< ::caffe::SPPParameter_PoolMethod >(pool_);
+}
+inline void SPPParameter::set_pool(::caffe::SPPParameter_PoolMethod value) {
+ assert(::caffe::SPPParameter_PoolMethod_IsValid(value));
+ set_has_pool();
+ pool_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SPPParameter.pool)
+}
+
+// optional .caffe.SPPParameter.Engine engine = 6 [default = DEFAULT];
+inline bool SPPParameter::has_engine() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void SPPParameter::set_has_engine() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void SPPParameter::clear_has_engine() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void SPPParameter::clear_engine() {
+ engine_ = 0;
+ clear_has_engine();
+}
+inline ::caffe::SPPParameter_Engine SPPParameter::engine() const {
+ // @@protoc_insertion_point(field_get:caffe.SPPParameter.engine)
+ return static_cast< ::caffe::SPPParameter_Engine >(engine_);
+}
+inline void SPPParameter::set_engine(::caffe::SPPParameter_Engine value) {
+ assert(::caffe::SPPParameter_Engine_IsValid(value));
+ set_has_engine();
+ engine_ = value;
+ // @@protoc_insertion_point(field_set:caffe.SPPParameter.engine)
+}
+
+inline const SPPParameter* SPPParameter::internal_default_instance() {
+ return &SPPParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// V1LayerParameter
+
+// repeated string bottom = 2;
+inline int V1LayerParameter::bottom_size() const {
+ return bottom_.size();
+}
+inline void V1LayerParameter::clear_bottom() {
+ bottom_.Clear();
+}
+inline const ::std::string& V1LayerParameter::bottom(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.bottom)
+ return bottom_.Get(index);
+}
+inline ::std::string* V1LayerParameter::mutable_bottom(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.bottom)
+ return bottom_.Mutable(index);
+}
+inline void V1LayerParameter::set_bottom(int index, const ::std::string& value) {
+ // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.bottom)
+ bottom_.Mutable(index)->assign(value);
+}
+inline void V1LayerParameter::set_bottom(int index, const char* value) {
+ bottom_.Mutable(index)->assign(value);
+ // @@protoc_insertion_point(field_set_char:caffe.V1LayerParameter.bottom)
+}
+inline void V1LayerParameter::set_bottom(int index, const char* value, size_t size) {
+ bottom_.Mutable(index)->assign(
+ reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_set_pointer:caffe.V1LayerParameter.bottom)
+}
+inline ::std::string* V1LayerParameter::add_bottom() {
+ // @@protoc_insertion_point(field_add_mutable:caffe.V1LayerParameter.bottom)
+ return bottom_.Add();
+}
+inline void V1LayerParameter::add_bottom(const ::std::string& value) {
+ bottom_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.bottom)
+}
+inline void V1LayerParameter::add_bottom(const char* value) {
+ bottom_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add_char:caffe.V1LayerParameter.bottom)
+}
+inline void V1LayerParameter::add_bottom(const char* value, size_t size) {
+ bottom_.Add()->assign(reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_add_pointer:caffe.V1LayerParameter.bottom)
+}
+inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
+V1LayerParameter::bottom() const {
+ // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.bottom)
+ return bottom_;
+}
+inline ::google::protobuf::RepeatedPtrField< ::std::string>*
+V1LayerParameter::mutable_bottom() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.bottom)
+ return &bottom_;
+}
+
+// repeated string top = 3;
+inline int V1LayerParameter::top_size() const {
+ return top_.size();
+}
+inline void V1LayerParameter::clear_top() {
+ top_.Clear();
+}
+inline const ::std::string& V1LayerParameter::top(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.top)
+ return top_.Get(index);
+}
+inline ::std::string* V1LayerParameter::mutable_top(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.top)
+ return top_.Mutable(index);
+}
+inline void V1LayerParameter::set_top(int index, const ::std::string& value) {
+ // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.top)
+ top_.Mutable(index)->assign(value);
+}
+inline void V1LayerParameter::set_top(int index, const char* value) {
+ top_.Mutable(index)->assign(value);
+ // @@protoc_insertion_point(field_set_char:caffe.V1LayerParameter.top)
+}
+inline void V1LayerParameter::set_top(int index, const char* value, size_t size) {
+ top_.Mutable(index)->assign(
+ reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_set_pointer:caffe.V1LayerParameter.top)
+}
+inline ::std::string* V1LayerParameter::add_top() {
+ // @@protoc_insertion_point(field_add_mutable:caffe.V1LayerParameter.top)
+ return top_.Add();
+}
+inline void V1LayerParameter::add_top(const ::std::string& value) {
+ top_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.top)
+}
+inline void V1LayerParameter::add_top(const char* value) {
+ top_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add_char:caffe.V1LayerParameter.top)
+}
+inline void V1LayerParameter::add_top(const char* value, size_t size) {
+ top_.Add()->assign(reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_add_pointer:caffe.V1LayerParameter.top)
+}
+inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
+V1LayerParameter::top() const {
+ // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.top)
+ return top_;
+}
+inline ::google::protobuf::RepeatedPtrField< ::std::string>*
+V1LayerParameter::mutable_top() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.top)
+ return &top_;
+}
+
+// optional string name = 4;
+inline bool V1LayerParameter::has_name() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void V1LayerParameter::set_has_name() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void V1LayerParameter::clear_has_name() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void V1LayerParameter::clear_name() {
+ name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_name();
+}
+inline const ::std::string& V1LayerParameter::name() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.name)
+ return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void V1LayerParameter::set_name(const ::std::string& value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.name)
+}
+inline void V1LayerParameter::set_name(const char* value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.V1LayerParameter.name)
+}
+inline void V1LayerParameter::set_name(const char* value, size_t size) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.V1LayerParameter.name)
+}
+inline ::std::string* V1LayerParameter::mutable_name() {
+ set_has_name();
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.name)
+ return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* V1LayerParameter::release_name() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.name)
+ clear_has_name();
+ return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void V1LayerParameter::set_allocated_name(::std::string* name) {
+ if (name != NULL) {
+ set_has_name();
+ } else {
+ clear_has_name();
+ }
+ name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.name)
+}
+
+// repeated .caffe.NetStateRule include = 32;
+inline int V1LayerParameter::include_size() const {
+ return include_.size();
+}
+inline void V1LayerParameter::clear_include() {
+ include_.Clear();
+}
+inline const ::caffe::NetStateRule& V1LayerParameter::include(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.include)
+ return include_.Get(index);
+}
+inline ::caffe::NetStateRule* V1LayerParameter::mutable_include(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.include)
+ return include_.Mutable(index);
+}
+inline ::caffe::NetStateRule* V1LayerParameter::add_include() {
+ // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.include)
+ return include_.Add();
+}
+inline ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >*
+V1LayerParameter::mutable_include() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.include)
+ return &include_;
+}
+inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >&
+V1LayerParameter::include() const {
+ // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.include)
+ return include_;
+}
+
+// repeated .caffe.NetStateRule exclude = 33;
+inline int V1LayerParameter::exclude_size() const {
+ return exclude_.size();
+}
+inline void V1LayerParameter::clear_exclude() {
+ exclude_.Clear();
+}
+inline const ::caffe::NetStateRule& V1LayerParameter::exclude(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.exclude)
+ return exclude_.Get(index);
+}
+inline ::caffe::NetStateRule* V1LayerParameter::mutable_exclude(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.exclude)
+ return exclude_.Mutable(index);
+}
+inline ::caffe::NetStateRule* V1LayerParameter::add_exclude() {
+ // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.exclude)
+ return exclude_.Add();
+}
+inline ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >*
+V1LayerParameter::mutable_exclude() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.exclude)
+ return &exclude_;
+}
+inline const ::google::protobuf::RepeatedPtrField< ::caffe::NetStateRule >&
+V1LayerParameter::exclude() const {
+ // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.exclude)
+ return exclude_;
+}
+
+// optional .caffe.V1LayerParameter.LayerType type = 5;
+inline bool V1LayerParameter::has_type() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+inline void V1LayerParameter::set_has_type() {
+ _has_bits_[0] |= 0x00000020u;
+}
+inline void V1LayerParameter::clear_has_type() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+inline void V1LayerParameter::clear_type() {
+ type_ = 0;
+ clear_has_type();
+}
+inline ::caffe::V1LayerParameter_LayerType V1LayerParameter::type() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.type)
+ return static_cast< ::caffe::V1LayerParameter_LayerType >(type_);
+}
+inline void V1LayerParameter::set_type(::caffe::V1LayerParameter_LayerType value) {
+ assert(::caffe::V1LayerParameter_LayerType_IsValid(value));
+ set_has_type();
+ type_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.type)
+}
+
+// repeated .caffe.BlobProto blobs = 6;
+inline int V1LayerParameter::blobs_size() const {
+ return blobs_.size();
+}
+inline void V1LayerParameter::clear_blobs() {
+ blobs_.Clear();
+}
+inline const ::caffe::BlobProto& V1LayerParameter::blobs(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.blobs)
+ return blobs_.Get(index);
+}
+inline ::caffe::BlobProto* V1LayerParameter::mutable_blobs(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.blobs)
+ return blobs_.Mutable(index);
+}
+inline ::caffe::BlobProto* V1LayerParameter::add_blobs() {
+ // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.blobs)
+ return blobs_.Add();
+}
+inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
+V1LayerParameter::mutable_blobs() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.blobs)
+ return &blobs_;
+}
+inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
+V1LayerParameter::blobs() const {
+ // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.blobs)
+ return blobs_;
+}
+
+// repeated string param = 1001;
+inline int V1LayerParameter::param_size() const {
+ return param_.size();
+}
+inline void V1LayerParameter::clear_param() {
+ param_.Clear();
+}
+inline const ::std::string& V1LayerParameter::param(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.param)
+ return param_.Get(index);
+}
+inline ::std::string* V1LayerParameter::mutable_param(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.param)
+ return param_.Mutable(index);
+}
+inline void V1LayerParameter::set_param(int index, const ::std::string& value) {
+ // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.param)
+ param_.Mutable(index)->assign(value);
+}
+inline void V1LayerParameter::set_param(int index, const char* value) {
+ param_.Mutable(index)->assign(value);
+ // @@protoc_insertion_point(field_set_char:caffe.V1LayerParameter.param)
+}
+inline void V1LayerParameter::set_param(int index, const char* value, size_t size) {
+ param_.Mutable(index)->assign(
+ reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_set_pointer:caffe.V1LayerParameter.param)
+}
+inline ::std::string* V1LayerParameter::add_param() {
+ // @@protoc_insertion_point(field_add_mutable:caffe.V1LayerParameter.param)
+ return param_.Add();
+}
+inline void V1LayerParameter::add_param(const ::std::string& value) {
+ param_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.param)
+}
+inline void V1LayerParameter::add_param(const char* value) {
+ param_.Add()->assign(value);
+ // @@protoc_insertion_point(field_add_char:caffe.V1LayerParameter.param)
+}
+inline void V1LayerParameter::add_param(const char* value, size_t size) {
+ param_.Add()->assign(reinterpret_cast<const char*>(value), size);
+ // @@protoc_insertion_point(field_add_pointer:caffe.V1LayerParameter.param)
+}
+inline const ::google::protobuf::RepeatedPtrField< ::std::string>&
+V1LayerParameter::param() const {
+ // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.param)
+ return param_;
+}
+inline ::google::protobuf::RepeatedPtrField< ::std::string>*
+V1LayerParameter::mutable_param() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.param)
+ return ¶m_;
+}
+
+// repeated .caffe.V1LayerParameter.DimCheckMode blob_share_mode = 1002;
+inline int V1LayerParameter::blob_share_mode_size() const {
+ return blob_share_mode_.size();
+}
+inline void V1LayerParameter::clear_blob_share_mode() {
+ blob_share_mode_.Clear();
+}
+inline ::caffe::V1LayerParameter_DimCheckMode V1LayerParameter::blob_share_mode(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.blob_share_mode)
+ return static_cast< ::caffe::V1LayerParameter_DimCheckMode >(blob_share_mode_.Get(index));
+}
+inline void V1LayerParameter::set_blob_share_mode(int index, ::caffe::V1LayerParameter_DimCheckMode value) {
+ assert(::caffe::V1LayerParameter_DimCheckMode_IsValid(value));
+ blob_share_mode_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.blob_share_mode)
+}
+inline void V1LayerParameter::add_blob_share_mode(::caffe::V1LayerParameter_DimCheckMode value) {
+ assert(::caffe::V1LayerParameter_DimCheckMode_IsValid(value));
+ blob_share_mode_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.blob_share_mode)
+}
+inline const ::google::protobuf::RepeatedField<int>&
+V1LayerParameter::blob_share_mode() const {
+ // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.blob_share_mode)
+ return blob_share_mode_;
+}
+inline ::google::protobuf::RepeatedField<int>*
+V1LayerParameter::mutable_blob_share_mode() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.blob_share_mode)
+ return &blob_share_mode_;
+}
+
+// repeated float blobs_lr = 7;
+inline int V1LayerParameter::blobs_lr_size() const {
+ return blobs_lr_.size();
+}
+inline void V1LayerParameter::clear_blobs_lr() {
+ blobs_lr_.Clear();
+}
+inline float V1LayerParameter::blobs_lr(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.blobs_lr)
+ return blobs_lr_.Get(index);
+}
+inline void V1LayerParameter::set_blobs_lr(int index, float value) {
+ blobs_lr_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.blobs_lr)
+}
+inline void V1LayerParameter::add_blobs_lr(float value) {
+ blobs_lr_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.blobs_lr)
+}
+inline const ::google::protobuf::RepeatedField< float >&
+V1LayerParameter::blobs_lr() const {
+ // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.blobs_lr)
+ return blobs_lr_;
+}
+inline ::google::protobuf::RepeatedField< float >*
+V1LayerParameter::mutable_blobs_lr() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.blobs_lr)
+ return &blobs_lr_;
+}
+
+// repeated float weight_decay = 8;
+inline int V1LayerParameter::weight_decay_size() const {
+ return weight_decay_.size();
+}
+inline void V1LayerParameter::clear_weight_decay() {
+ weight_decay_.Clear();
+}
+inline float V1LayerParameter::weight_decay(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.weight_decay)
+ return weight_decay_.Get(index);
+}
+inline void V1LayerParameter::set_weight_decay(int index, float value) {
+ weight_decay_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.weight_decay)
+}
+inline void V1LayerParameter::add_weight_decay(float value) {
+ weight_decay_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.weight_decay)
+}
+inline const ::google::protobuf::RepeatedField< float >&
+V1LayerParameter::weight_decay() const {
+ // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.weight_decay)
+ return weight_decay_;
+}
+inline ::google::protobuf::RepeatedField< float >*
+V1LayerParameter::mutable_weight_decay() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.weight_decay)
+ return &weight_decay_;
+}
+
+// repeated float loss_weight = 35;
+inline int V1LayerParameter::loss_weight_size() const {
+ return loss_weight_.size();
+}
+inline void V1LayerParameter::clear_loss_weight() {
+ loss_weight_.Clear();
+}
+inline float V1LayerParameter::loss_weight(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.loss_weight)
+ return loss_weight_.Get(index);
+}
+inline void V1LayerParameter::set_loss_weight(int index, float value) {
+ loss_weight_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.V1LayerParameter.loss_weight)
+}
+inline void V1LayerParameter::add_loss_weight(float value) {
+ loss_weight_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.V1LayerParameter.loss_weight)
+}
+inline const ::google::protobuf::RepeatedField< float >&
+V1LayerParameter::loss_weight() const {
+ // @@protoc_insertion_point(field_list:caffe.V1LayerParameter.loss_weight)
+ return loss_weight_;
+}
+inline ::google::protobuf::RepeatedField< float >*
+V1LayerParameter::mutable_loss_weight() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V1LayerParameter.loss_weight)
+ return &loss_weight_;
+}
+
+// optional .caffe.AccuracyParameter accuracy_param = 27;
+inline bool V1LayerParameter::has_accuracy_param() const {
+ return (_has_bits_[0] & 0x00001000u) != 0;
+}
+inline void V1LayerParameter::set_has_accuracy_param() {
+ _has_bits_[0] |= 0x00001000u;
+}
+inline void V1LayerParameter::clear_has_accuracy_param() {
+ _has_bits_[0] &= ~0x00001000u;
+}
+inline void V1LayerParameter::clear_accuracy_param() {
+ if (accuracy_param_ != NULL) accuracy_param_->::caffe::AccuracyParameter::Clear();
+ clear_has_accuracy_param();
+}
+inline const ::caffe::AccuracyParameter& V1LayerParameter::accuracy_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.accuracy_param)
+ return accuracy_param_ != NULL ? *accuracy_param_
+ : *::caffe::AccuracyParameter::internal_default_instance();
+}
+inline ::caffe::AccuracyParameter* V1LayerParameter::mutable_accuracy_param() {
+ set_has_accuracy_param();
+ if (accuracy_param_ == NULL) {
+ accuracy_param_ = new ::caffe::AccuracyParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.accuracy_param)
+ return accuracy_param_;
+}
+inline ::caffe::AccuracyParameter* V1LayerParameter::release_accuracy_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.accuracy_param)
+ clear_has_accuracy_param();
+ ::caffe::AccuracyParameter* temp = accuracy_param_;
+ accuracy_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_accuracy_param(::caffe::AccuracyParameter* accuracy_param) {
+ delete accuracy_param_;
+ accuracy_param_ = accuracy_param;
+ if (accuracy_param) {
+ set_has_accuracy_param();
+ } else {
+ clear_has_accuracy_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.accuracy_param)
+}
+
+// optional .caffe.ArgMaxParameter argmax_param = 23;
+inline bool V1LayerParameter::has_argmax_param() const {
+ return (_has_bits_[0] & 0x00002000u) != 0;
+}
+inline void V1LayerParameter::set_has_argmax_param() {
+ _has_bits_[0] |= 0x00002000u;
+}
+inline void V1LayerParameter::clear_has_argmax_param() {
+ _has_bits_[0] &= ~0x00002000u;
+}
+inline void V1LayerParameter::clear_argmax_param() {
+ if (argmax_param_ != NULL) argmax_param_->::caffe::ArgMaxParameter::Clear();
+ clear_has_argmax_param();
+}
+inline const ::caffe::ArgMaxParameter& V1LayerParameter::argmax_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.argmax_param)
+ return argmax_param_ != NULL ? *argmax_param_
+ : *::caffe::ArgMaxParameter::internal_default_instance();
+}
+inline ::caffe::ArgMaxParameter* V1LayerParameter::mutable_argmax_param() {
+ set_has_argmax_param();
+ if (argmax_param_ == NULL) {
+ argmax_param_ = new ::caffe::ArgMaxParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.argmax_param)
+ return argmax_param_;
+}
+inline ::caffe::ArgMaxParameter* V1LayerParameter::release_argmax_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.argmax_param)
+ clear_has_argmax_param();
+ ::caffe::ArgMaxParameter* temp = argmax_param_;
+ argmax_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_argmax_param(::caffe::ArgMaxParameter* argmax_param) {
+ delete argmax_param_;
+ argmax_param_ = argmax_param;
+ if (argmax_param) {
+ set_has_argmax_param();
+ } else {
+ clear_has_argmax_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.argmax_param)
+}
+
+// optional .caffe.ConcatParameter concat_param = 9;
+inline bool V1LayerParameter::has_concat_param() const {
+ return (_has_bits_[0] & 0x00004000u) != 0;
+}
+inline void V1LayerParameter::set_has_concat_param() {
+ _has_bits_[0] |= 0x00004000u;
+}
+inline void V1LayerParameter::clear_has_concat_param() {
+ _has_bits_[0] &= ~0x00004000u;
+}
+inline void V1LayerParameter::clear_concat_param() {
+ if (concat_param_ != NULL) concat_param_->::caffe::ConcatParameter::Clear();
+ clear_has_concat_param();
+}
+inline const ::caffe::ConcatParameter& V1LayerParameter::concat_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.concat_param)
+ return concat_param_ != NULL ? *concat_param_
+ : *::caffe::ConcatParameter::internal_default_instance();
+}
+inline ::caffe::ConcatParameter* V1LayerParameter::mutable_concat_param() {
+ set_has_concat_param();
+ if (concat_param_ == NULL) {
+ concat_param_ = new ::caffe::ConcatParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.concat_param)
+ return concat_param_;
+}
+inline ::caffe::ConcatParameter* V1LayerParameter::release_concat_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.concat_param)
+ clear_has_concat_param();
+ ::caffe::ConcatParameter* temp = concat_param_;
+ concat_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_concat_param(::caffe::ConcatParameter* concat_param) {
+ delete concat_param_;
+ concat_param_ = concat_param;
+ if (concat_param) {
+ set_has_concat_param();
+ } else {
+ clear_has_concat_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.concat_param)
+}
+
+// optional .caffe.ContrastiveLossParameter contrastive_loss_param = 40;
+inline bool V1LayerParameter::has_contrastive_loss_param() const {
+ return (_has_bits_[0] & 0x00008000u) != 0;
+}
+inline void V1LayerParameter::set_has_contrastive_loss_param() {
+ _has_bits_[0] |= 0x00008000u;
+}
+inline void V1LayerParameter::clear_has_contrastive_loss_param() {
+ _has_bits_[0] &= ~0x00008000u;
+}
+inline void V1LayerParameter::clear_contrastive_loss_param() {
+ if (contrastive_loss_param_ != NULL) contrastive_loss_param_->::caffe::ContrastiveLossParameter::Clear();
+ clear_has_contrastive_loss_param();
+}
+inline const ::caffe::ContrastiveLossParameter& V1LayerParameter::contrastive_loss_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.contrastive_loss_param)
+ return contrastive_loss_param_ != NULL ? *contrastive_loss_param_
+ : *::caffe::ContrastiveLossParameter::internal_default_instance();
+}
+inline ::caffe::ContrastiveLossParameter* V1LayerParameter::mutable_contrastive_loss_param() {
+ set_has_contrastive_loss_param();
+ if (contrastive_loss_param_ == NULL) {
+ contrastive_loss_param_ = new ::caffe::ContrastiveLossParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.contrastive_loss_param)
+ return contrastive_loss_param_;
+}
+inline ::caffe::ContrastiveLossParameter* V1LayerParameter::release_contrastive_loss_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.contrastive_loss_param)
+ clear_has_contrastive_loss_param();
+ ::caffe::ContrastiveLossParameter* temp = contrastive_loss_param_;
+ contrastive_loss_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_contrastive_loss_param(::caffe::ContrastiveLossParameter* contrastive_loss_param) {
+ delete contrastive_loss_param_;
+ contrastive_loss_param_ = contrastive_loss_param;
+ if (contrastive_loss_param) {
+ set_has_contrastive_loss_param();
+ } else {
+ clear_has_contrastive_loss_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.contrastive_loss_param)
+}
+
+// optional .caffe.ConvolutionParameter convolution_param = 10;
+inline bool V1LayerParameter::has_convolution_param() const {
+ return (_has_bits_[0] & 0x00010000u) != 0;
+}
+inline void V1LayerParameter::set_has_convolution_param() {
+ _has_bits_[0] |= 0x00010000u;
+}
+inline void V1LayerParameter::clear_has_convolution_param() {
+ _has_bits_[0] &= ~0x00010000u;
+}
+inline void V1LayerParameter::clear_convolution_param() {
+ if (convolution_param_ != NULL) convolution_param_->::caffe::ConvolutionParameter::Clear();
+ clear_has_convolution_param();
+}
+inline const ::caffe::ConvolutionParameter& V1LayerParameter::convolution_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.convolution_param)
+ return convolution_param_ != NULL ? *convolution_param_
+ : *::caffe::ConvolutionParameter::internal_default_instance();
+}
+inline ::caffe::ConvolutionParameter* V1LayerParameter::mutable_convolution_param() {
+ set_has_convolution_param();
+ if (convolution_param_ == NULL) {
+ convolution_param_ = new ::caffe::ConvolutionParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.convolution_param)
+ return convolution_param_;
+}
+inline ::caffe::ConvolutionParameter* V1LayerParameter::release_convolution_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.convolution_param)
+ clear_has_convolution_param();
+ ::caffe::ConvolutionParameter* temp = convolution_param_;
+ convolution_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_convolution_param(::caffe::ConvolutionParameter* convolution_param) {
+ delete convolution_param_;
+ convolution_param_ = convolution_param;
+ if (convolution_param) {
+ set_has_convolution_param();
+ } else {
+ clear_has_convolution_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.convolution_param)
+}
+
+// optional .caffe.DataParameter data_param = 11;
+inline bool V1LayerParameter::has_data_param() const {
+ return (_has_bits_[0] & 0x00020000u) != 0;
+}
+inline void V1LayerParameter::set_has_data_param() {
+ _has_bits_[0] |= 0x00020000u;
+}
+inline void V1LayerParameter::clear_has_data_param() {
+ _has_bits_[0] &= ~0x00020000u;
+}
+inline void V1LayerParameter::clear_data_param() {
+ if (data_param_ != NULL) data_param_->::caffe::DataParameter::Clear();
+ clear_has_data_param();
+}
+inline const ::caffe::DataParameter& V1LayerParameter::data_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.data_param)
+ return data_param_ != NULL ? *data_param_
+ : *::caffe::DataParameter::internal_default_instance();
+}
+inline ::caffe::DataParameter* V1LayerParameter::mutable_data_param() {
+ set_has_data_param();
+ if (data_param_ == NULL) {
+ data_param_ = new ::caffe::DataParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.data_param)
+ return data_param_;
+}
+inline ::caffe::DataParameter* V1LayerParameter::release_data_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.data_param)
+ clear_has_data_param();
+ ::caffe::DataParameter* temp = data_param_;
+ data_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_data_param(::caffe::DataParameter* data_param) {
+ delete data_param_;
+ data_param_ = data_param;
+ if (data_param) {
+ set_has_data_param();
+ } else {
+ clear_has_data_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.data_param)
+}
+
+// optional .caffe.DropoutParameter dropout_param = 12;
+inline bool V1LayerParameter::has_dropout_param() const {
+ return (_has_bits_[0] & 0x00040000u) != 0;
+}
+inline void V1LayerParameter::set_has_dropout_param() {
+ _has_bits_[0] |= 0x00040000u;
+}
+inline void V1LayerParameter::clear_has_dropout_param() {
+ _has_bits_[0] &= ~0x00040000u;
+}
+inline void V1LayerParameter::clear_dropout_param() {
+ if (dropout_param_ != NULL) dropout_param_->::caffe::DropoutParameter::Clear();
+ clear_has_dropout_param();
+}
+inline const ::caffe::DropoutParameter& V1LayerParameter::dropout_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.dropout_param)
+ return dropout_param_ != NULL ? *dropout_param_
+ : *::caffe::DropoutParameter::internal_default_instance();
+}
+inline ::caffe::DropoutParameter* V1LayerParameter::mutable_dropout_param() {
+ set_has_dropout_param();
+ if (dropout_param_ == NULL) {
+ dropout_param_ = new ::caffe::DropoutParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.dropout_param)
+ return dropout_param_;
+}
+inline ::caffe::DropoutParameter* V1LayerParameter::release_dropout_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.dropout_param)
+ clear_has_dropout_param();
+ ::caffe::DropoutParameter* temp = dropout_param_;
+ dropout_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_dropout_param(::caffe::DropoutParameter* dropout_param) {
+ delete dropout_param_;
+ dropout_param_ = dropout_param;
+ if (dropout_param) {
+ set_has_dropout_param();
+ } else {
+ clear_has_dropout_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.dropout_param)
+}
+
+// optional .caffe.DummyDataParameter dummy_data_param = 26;
+inline bool V1LayerParameter::has_dummy_data_param() const {
+ return (_has_bits_[0] & 0x00080000u) != 0;
+}
+inline void V1LayerParameter::set_has_dummy_data_param() {
+ _has_bits_[0] |= 0x00080000u;
+}
+inline void V1LayerParameter::clear_has_dummy_data_param() {
+ _has_bits_[0] &= ~0x00080000u;
+}
+inline void V1LayerParameter::clear_dummy_data_param() {
+ if (dummy_data_param_ != NULL) dummy_data_param_->::caffe::DummyDataParameter::Clear();
+ clear_has_dummy_data_param();
+}
+inline const ::caffe::DummyDataParameter& V1LayerParameter::dummy_data_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.dummy_data_param)
+ return dummy_data_param_ != NULL ? *dummy_data_param_
+ : *::caffe::DummyDataParameter::internal_default_instance();
+}
+inline ::caffe::DummyDataParameter* V1LayerParameter::mutable_dummy_data_param() {
+ set_has_dummy_data_param();
+ if (dummy_data_param_ == NULL) {
+ dummy_data_param_ = new ::caffe::DummyDataParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.dummy_data_param)
+ return dummy_data_param_;
+}
+inline ::caffe::DummyDataParameter* V1LayerParameter::release_dummy_data_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.dummy_data_param)
+ clear_has_dummy_data_param();
+ ::caffe::DummyDataParameter* temp = dummy_data_param_;
+ dummy_data_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_dummy_data_param(::caffe::DummyDataParameter* dummy_data_param) {
+ delete dummy_data_param_;
+ dummy_data_param_ = dummy_data_param;
+ if (dummy_data_param) {
+ set_has_dummy_data_param();
+ } else {
+ clear_has_dummy_data_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.dummy_data_param)
+}
+
+// optional .caffe.EltwiseParameter eltwise_param = 24;
+inline bool V1LayerParameter::has_eltwise_param() const {
+ return (_has_bits_[0] & 0x00100000u) != 0;
+}
+inline void V1LayerParameter::set_has_eltwise_param() {
+ _has_bits_[0] |= 0x00100000u;
+}
+inline void V1LayerParameter::clear_has_eltwise_param() {
+ _has_bits_[0] &= ~0x00100000u;
+}
+inline void V1LayerParameter::clear_eltwise_param() {
+ if (eltwise_param_ != NULL) eltwise_param_->::caffe::EltwiseParameter::Clear();
+ clear_has_eltwise_param();
+}
+inline const ::caffe::EltwiseParameter& V1LayerParameter::eltwise_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.eltwise_param)
+ return eltwise_param_ != NULL ? *eltwise_param_
+ : *::caffe::EltwiseParameter::internal_default_instance();
+}
+inline ::caffe::EltwiseParameter* V1LayerParameter::mutable_eltwise_param() {
+ set_has_eltwise_param();
+ if (eltwise_param_ == NULL) {
+ eltwise_param_ = new ::caffe::EltwiseParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.eltwise_param)
+ return eltwise_param_;
+}
+inline ::caffe::EltwiseParameter* V1LayerParameter::release_eltwise_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.eltwise_param)
+ clear_has_eltwise_param();
+ ::caffe::EltwiseParameter* temp = eltwise_param_;
+ eltwise_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_eltwise_param(::caffe::EltwiseParameter* eltwise_param) {
+ delete eltwise_param_;
+ eltwise_param_ = eltwise_param;
+ if (eltwise_param) {
+ set_has_eltwise_param();
+ } else {
+ clear_has_eltwise_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.eltwise_param)
+}
+
+// optional .caffe.ExpParameter exp_param = 41;
+inline bool V1LayerParameter::has_exp_param() const {
+ return (_has_bits_[0] & 0x00200000u) != 0;
+}
+inline void V1LayerParameter::set_has_exp_param() {
+ _has_bits_[0] |= 0x00200000u;
+}
+inline void V1LayerParameter::clear_has_exp_param() {
+ _has_bits_[0] &= ~0x00200000u;
+}
+inline void V1LayerParameter::clear_exp_param() {
+ if (exp_param_ != NULL) exp_param_->::caffe::ExpParameter::Clear();
+ clear_has_exp_param();
+}
+inline const ::caffe::ExpParameter& V1LayerParameter::exp_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.exp_param)
+ return exp_param_ != NULL ? *exp_param_
+ : *::caffe::ExpParameter::internal_default_instance();
+}
+inline ::caffe::ExpParameter* V1LayerParameter::mutable_exp_param() {
+ set_has_exp_param();
+ if (exp_param_ == NULL) {
+ exp_param_ = new ::caffe::ExpParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.exp_param)
+ return exp_param_;
+}
+inline ::caffe::ExpParameter* V1LayerParameter::release_exp_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.exp_param)
+ clear_has_exp_param();
+ ::caffe::ExpParameter* temp = exp_param_;
+ exp_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_exp_param(::caffe::ExpParameter* exp_param) {
+ delete exp_param_;
+ exp_param_ = exp_param;
+ if (exp_param) {
+ set_has_exp_param();
+ } else {
+ clear_has_exp_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.exp_param)
+}
+
+// optional .caffe.HDF5DataParameter hdf5_data_param = 13;
+inline bool V1LayerParameter::has_hdf5_data_param() const {
+ return (_has_bits_[0] & 0x00400000u) != 0;
+}
+inline void V1LayerParameter::set_has_hdf5_data_param() {
+ _has_bits_[0] |= 0x00400000u;
+}
+inline void V1LayerParameter::clear_has_hdf5_data_param() {
+ _has_bits_[0] &= ~0x00400000u;
+}
+inline void V1LayerParameter::clear_hdf5_data_param() {
+ if (hdf5_data_param_ != NULL) hdf5_data_param_->::caffe::HDF5DataParameter::Clear();
+ clear_has_hdf5_data_param();
+}
+inline const ::caffe::HDF5DataParameter& V1LayerParameter::hdf5_data_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.hdf5_data_param)
+ return hdf5_data_param_ != NULL ? *hdf5_data_param_
+ : *::caffe::HDF5DataParameter::internal_default_instance();
+}
+inline ::caffe::HDF5DataParameter* V1LayerParameter::mutable_hdf5_data_param() {
+ set_has_hdf5_data_param();
+ if (hdf5_data_param_ == NULL) {
+ hdf5_data_param_ = new ::caffe::HDF5DataParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.hdf5_data_param)
+ return hdf5_data_param_;
+}
+inline ::caffe::HDF5DataParameter* V1LayerParameter::release_hdf5_data_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.hdf5_data_param)
+ clear_has_hdf5_data_param();
+ ::caffe::HDF5DataParameter* temp = hdf5_data_param_;
+ hdf5_data_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_hdf5_data_param(::caffe::HDF5DataParameter* hdf5_data_param) {
+ delete hdf5_data_param_;
+ hdf5_data_param_ = hdf5_data_param;
+ if (hdf5_data_param) {
+ set_has_hdf5_data_param();
+ } else {
+ clear_has_hdf5_data_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.hdf5_data_param)
+}
+
+// optional .caffe.HDF5OutputParameter hdf5_output_param = 14;
+inline bool V1LayerParameter::has_hdf5_output_param() const {
+ return (_has_bits_[0] & 0x00800000u) != 0;
+}
+inline void V1LayerParameter::set_has_hdf5_output_param() {
+ _has_bits_[0] |= 0x00800000u;
+}
+inline void V1LayerParameter::clear_has_hdf5_output_param() {
+ _has_bits_[0] &= ~0x00800000u;
+}
+inline void V1LayerParameter::clear_hdf5_output_param() {
+ if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear();
+ clear_has_hdf5_output_param();
+}
+inline const ::caffe::HDF5OutputParameter& V1LayerParameter::hdf5_output_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.hdf5_output_param)
+ return hdf5_output_param_ != NULL ? *hdf5_output_param_
+ : *::caffe::HDF5OutputParameter::internal_default_instance();
+}
+inline ::caffe::HDF5OutputParameter* V1LayerParameter::mutable_hdf5_output_param() {
+ set_has_hdf5_output_param();
+ if (hdf5_output_param_ == NULL) {
+ hdf5_output_param_ = new ::caffe::HDF5OutputParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.hdf5_output_param)
+ return hdf5_output_param_;
+}
+inline ::caffe::HDF5OutputParameter* V1LayerParameter::release_hdf5_output_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.hdf5_output_param)
+ clear_has_hdf5_output_param();
+ ::caffe::HDF5OutputParameter* temp = hdf5_output_param_;
+ hdf5_output_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param) {
+ delete hdf5_output_param_;
+ hdf5_output_param_ = hdf5_output_param;
+ if (hdf5_output_param) {
+ set_has_hdf5_output_param();
+ } else {
+ clear_has_hdf5_output_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.hdf5_output_param)
+}
+
+// optional .caffe.HingeLossParameter hinge_loss_param = 29;
+inline bool V1LayerParameter::has_hinge_loss_param() const {
+ return (_has_bits_[0] & 0x01000000u) != 0;
+}
+inline void V1LayerParameter::set_has_hinge_loss_param() {
+ _has_bits_[0] |= 0x01000000u;
+}
+inline void V1LayerParameter::clear_has_hinge_loss_param() {
+ _has_bits_[0] &= ~0x01000000u;
+}
+inline void V1LayerParameter::clear_hinge_loss_param() {
+ if (hinge_loss_param_ != NULL) hinge_loss_param_->::caffe::HingeLossParameter::Clear();
+ clear_has_hinge_loss_param();
+}
+inline const ::caffe::HingeLossParameter& V1LayerParameter::hinge_loss_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.hinge_loss_param)
+ return hinge_loss_param_ != NULL ? *hinge_loss_param_
+ : *::caffe::HingeLossParameter::internal_default_instance();
+}
+inline ::caffe::HingeLossParameter* V1LayerParameter::mutable_hinge_loss_param() {
+ set_has_hinge_loss_param();
+ if (hinge_loss_param_ == NULL) {
+ hinge_loss_param_ = new ::caffe::HingeLossParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.hinge_loss_param)
+ return hinge_loss_param_;
+}
+inline ::caffe::HingeLossParameter* V1LayerParameter::release_hinge_loss_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.hinge_loss_param)
+ clear_has_hinge_loss_param();
+ ::caffe::HingeLossParameter* temp = hinge_loss_param_;
+ hinge_loss_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_hinge_loss_param(::caffe::HingeLossParameter* hinge_loss_param) {
+ delete hinge_loss_param_;
+ hinge_loss_param_ = hinge_loss_param;
+ if (hinge_loss_param) {
+ set_has_hinge_loss_param();
+ } else {
+ clear_has_hinge_loss_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.hinge_loss_param)
+}
+
+// optional .caffe.ImageDataParameter image_data_param = 15;
+inline bool V1LayerParameter::has_image_data_param() const {
+ return (_has_bits_[0] & 0x02000000u) != 0;
+}
+inline void V1LayerParameter::set_has_image_data_param() {
+ _has_bits_[0] |= 0x02000000u;
+}
+inline void V1LayerParameter::clear_has_image_data_param() {
+ _has_bits_[0] &= ~0x02000000u;
+}
+inline void V1LayerParameter::clear_image_data_param() {
+ if (image_data_param_ != NULL) image_data_param_->::caffe::ImageDataParameter::Clear();
+ clear_has_image_data_param();
+}
+inline const ::caffe::ImageDataParameter& V1LayerParameter::image_data_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.image_data_param)
+ return image_data_param_ != NULL ? *image_data_param_
+ : *::caffe::ImageDataParameter::internal_default_instance();
+}
+inline ::caffe::ImageDataParameter* V1LayerParameter::mutable_image_data_param() {
+ set_has_image_data_param();
+ if (image_data_param_ == NULL) {
+ image_data_param_ = new ::caffe::ImageDataParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.image_data_param)
+ return image_data_param_;
+}
+inline ::caffe::ImageDataParameter* V1LayerParameter::release_image_data_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.image_data_param)
+ clear_has_image_data_param();
+ ::caffe::ImageDataParameter* temp = image_data_param_;
+ image_data_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_image_data_param(::caffe::ImageDataParameter* image_data_param) {
+ delete image_data_param_;
+ image_data_param_ = image_data_param;
+ if (image_data_param) {
+ set_has_image_data_param();
+ } else {
+ clear_has_image_data_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.image_data_param)
+}
+
+// optional .caffe.InfogainLossParameter infogain_loss_param = 16;
+inline bool V1LayerParameter::has_infogain_loss_param() const {
+ return (_has_bits_[0] & 0x04000000u) != 0;
+}
+inline void V1LayerParameter::set_has_infogain_loss_param() {
+ _has_bits_[0] |= 0x04000000u;
+}
+inline void V1LayerParameter::clear_has_infogain_loss_param() {
+ _has_bits_[0] &= ~0x04000000u;
+}
+inline void V1LayerParameter::clear_infogain_loss_param() {
+ if (infogain_loss_param_ != NULL) infogain_loss_param_->::caffe::InfogainLossParameter::Clear();
+ clear_has_infogain_loss_param();
+}
+inline const ::caffe::InfogainLossParameter& V1LayerParameter::infogain_loss_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.infogain_loss_param)
+ return infogain_loss_param_ != NULL ? *infogain_loss_param_
+ : *::caffe::InfogainLossParameter::internal_default_instance();
+}
+inline ::caffe::InfogainLossParameter* V1LayerParameter::mutable_infogain_loss_param() {
+ set_has_infogain_loss_param();
+ if (infogain_loss_param_ == NULL) {
+ infogain_loss_param_ = new ::caffe::InfogainLossParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.infogain_loss_param)
+ return infogain_loss_param_;
+}
+inline ::caffe::InfogainLossParameter* V1LayerParameter::release_infogain_loss_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.infogain_loss_param)
+ clear_has_infogain_loss_param();
+ ::caffe::InfogainLossParameter* temp = infogain_loss_param_;
+ infogain_loss_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_infogain_loss_param(::caffe::InfogainLossParameter* infogain_loss_param) {
+ delete infogain_loss_param_;
+ infogain_loss_param_ = infogain_loss_param;
+ if (infogain_loss_param) {
+ set_has_infogain_loss_param();
+ } else {
+ clear_has_infogain_loss_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.infogain_loss_param)
+}
+
+// optional .caffe.InnerProductParameter inner_product_param = 17;
+inline bool V1LayerParameter::has_inner_product_param() const {
+ return (_has_bits_[0] & 0x08000000u) != 0;
+}
+inline void V1LayerParameter::set_has_inner_product_param() {
+ _has_bits_[0] |= 0x08000000u;
+}
+inline void V1LayerParameter::clear_has_inner_product_param() {
+ _has_bits_[0] &= ~0x08000000u;
+}
+inline void V1LayerParameter::clear_inner_product_param() {
+ if (inner_product_param_ != NULL) inner_product_param_->::caffe::InnerProductParameter::Clear();
+ clear_has_inner_product_param();
+}
+inline const ::caffe::InnerProductParameter& V1LayerParameter::inner_product_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.inner_product_param)
+ return inner_product_param_ != NULL ? *inner_product_param_
+ : *::caffe::InnerProductParameter::internal_default_instance();
+}
+inline ::caffe::InnerProductParameter* V1LayerParameter::mutable_inner_product_param() {
+ set_has_inner_product_param();
+ if (inner_product_param_ == NULL) {
+ inner_product_param_ = new ::caffe::InnerProductParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.inner_product_param)
+ return inner_product_param_;
+}
+inline ::caffe::InnerProductParameter* V1LayerParameter::release_inner_product_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.inner_product_param)
+ clear_has_inner_product_param();
+ ::caffe::InnerProductParameter* temp = inner_product_param_;
+ inner_product_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_inner_product_param(::caffe::InnerProductParameter* inner_product_param) {
+ delete inner_product_param_;
+ inner_product_param_ = inner_product_param;
+ if (inner_product_param) {
+ set_has_inner_product_param();
+ } else {
+ clear_has_inner_product_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.inner_product_param)
+}
+
+// optional .caffe.LRNParameter lrn_param = 18;
+inline bool V1LayerParameter::has_lrn_param() const {
+ return (_has_bits_[0] & 0x10000000u) != 0;
+}
+inline void V1LayerParameter::set_has_lrn_param() {
+ _has_bits_[0] |= 0x10000000u;
+}
+inline void V1LayerParameter::clear_has_lrn_param() {
+ _has_bits_[0] &= ~0x10000000u;
+}
+inline void V1LayerParameter::clear_lrn_param() {
+ if (lrn_param_ != NULL) lrn_param_->::caffe::LRNParameter::Clear();
+ clear_has_lrn_param();
+}
+inline const ::caffe::LRNParameter& V1LayerParameter::lrn_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.lrn_param)
+ return lrn_param_ != NULL ? *lrn_param_
+ : *::caffe::LRNParameter::internal_default_instance();
+}
+inline ::caffe::LRNParameter* V1LayerParameter::mutable_lrn_param() {
+ set_has_lrn_param();
+ if (lrn_param_ == NULL) {
+ lrn_param_ = new ::caffe::LRNParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.lrn_param)
+ return lrn_param_;
+}
+inline ::caffe::LRNParameter* V1LayerParameter::release_lrn_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.lrn_param)
+ clear_has_lrn_param();
+ ::caffe::LRNParameter* temp = lrn_param_;
+ lrn_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_lrn_param(::caffe::LRNParameter* lrn_param) {
+ delete lrn_param_;
+ lrn_param_ = lrn_param;
+ if (lrn_param) {
+ set_has_lrn_param();
+ } else {
+ clear_has_lrn_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.lrn_param)
+}
+
+// optional .caffe.MemoryDataParameter memory_data_param = 22;
+inline bool V1LayerParameter::has_memory_data_param() const {
+ return (_has_bits_[0] & 0x20000000u) != 0;
+}
+inline void V1LayerParameter::set_has_memory_data_param() {
+ _has_bits_[0] |= 0x20000000u;
+}
+inline void V1LayerParameter::clear_has_memory_data_param() {
+ _has_bits_[0] &= ~0x20000000u;
+}
+inline void V1LayerParameter::clear_memory_data_param() {
+ if (memory_data_param_ != NULL) memory_data_param_->::caffe::MemoryDataParameter::Clear();
+ clear_has_memory_data_param();
+}
+inline const ::caffe::MemoryDataParameter& V1LayerParameter::memory_data_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.memory_data_param)
+ return memory_data_param_ != NULL ? *memory_data_param_
+ : *::caffe::MemoryDataParameter::internal_default_instance();
+}
+inline ::caffe::MemoryDataParameter* V1LayerParameter::mutable_memory_data_param() {
+ set_has_memory_data_param();
+ if (memory_data_param_ == NULL) {
+ memory_data_param_ = new ::caffe::MemoryDataParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.memory_data_param)
+ return memory_data_param_;
+}
+inline ::caffe::MemoryDataParameter* V1LayerParameter::release_memory_data_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.memory_data_param)
+ clear_has_memory_data_param();
+ ::caffe::MemoryDataParameter* temp = memory_data_param_;
+ memory_data_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_memory_data_param(::caffe::MemoryDataParameter* memory_data_param) {
+ delete memory_data_param_;
+ memory_data_param_ = memory_data_param;
+ if (memory_data_param) {
+ set_has_memory_data_param();
+ } else {
+ clear_has_memory_data_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.memory_data_param)
+}
+
+// optional .caffe.MVNParameter mvn_param = 34;
+inline bool V1LayerParameter::has_mvn_param() const {
+ return (_has_bits_[0] & 0x40000000u) != 0;
+}
+inline void V1LayerParameter::set_has_mvn_param() {
+ _has_bits_[0] |= 0x40000000u;
+}
+inline void V1LayerParameter::clear_has_mvn_param() {
+ _has_bits_[0] &= ~0x40000000u;
+}
+inline void V1LayerParameter::clear_mvn_param() {
+ if (mvn_param_ != NULL) mvn_param_->::caffe::MVNParameter::Clear();
+ clear_has_mvn_param();
+}
+inline const ::caffe::MVNParameter& V1LayerParameter::mvn_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.mvn_param)
+ return mvn_param_ != NULL ? *mvn_param_
+ : *::caffe::MVNParameter::internal_default_instance();
+}
+inline ::caffe::MVNParameter* V1LayerParameter::mutable_mvn_param() {
+ set_has_mvn_param();
+ if (mvn_param_ == NULL) {
+ mvn_param_ = new ::caffe::MVNParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.mvn_param)
+ return mvn_param_;
+}
+inline ::caffe::MVNParameter* V1LayerParameter::release_mvn_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.mvn_param)
+ clear_has_mvn_param();
+ ::caffe::MVNParameter* temp = mvn_param_;
+ mvn_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_mvn_param(::caffe::MVNParameter* mvn_param) {
+ delete mvn_param_;
+ mvn_param_ = mvn_param;
+ if (mvn_param) {
+ set_has_mvn_param();
+ } else {
+ clear_has_mvn_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.mvn_param)
+}
+
+// optional .caffe.PoolingParameter pooling_param = 19;
+inline bool V1LayerParameter::has_pooling_param() const {
+ return (_has_bits_[0] & 0x80000000u) != 0;
+}
+inline void V1LayerParameter::set_has_pooling_param() {
+ _has_bits_[0] |= 0x80000000u;
+}
+inline void V1LayerParameter::clear_has_pooling_param() {
+ _has_bits_[0] &= ~0x80000000u;
+}
+inline void V1LayerParameter::clear_pooling_param() {
+ if (pooling_param_ != NULL) pooling_param_->::caffe::PoolingParameter::Clear();
+ clear_has_pooling_param();
+}
+inline const ::caffe::PoolingParameter& V1LayerParameter::pooling_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.pooling_param)
+ return pooling_param_ != NULL ? *pooling_param_
+ : *::caffe::PoolingParameter::internal_default_instance();
+}
+inline ::caffe::PoolingParameter* V1LayerParameter::mutable_pooling_param() {
+ set_has_pooling_param();
+ if (pooling_param_ == NULL) {
+ pooling_param_ = new ::caffe::PoolingParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.pooling_param)
+ return pooling_param_;
+}
+inline ::caffe::PoolingParameter* V1LayerParameter::release_pooling_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.pooling_param)
+ clear_has_pooling_param();
+ ::caffe::PoolingParameter* temp = pooling_param_;
+ pooling_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_pooling_param(::caffe::PoolingParameter* pooling_param) {
+ delete pooling_param_;
+ pooling_param_ = pooling_param;
+ if (pooling_param) {
+ set_has_pooling_param();
+ } else {
+ clear_has_pooling_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.pooling_param)
+}
+
+// optional .caffe.PowerParameter power_param = 21;
+inline bool V1LayerParameter::has_power_param() const {
+ return (_has_bits_[1] & 0x00000001u) != 0;
+}
+inline void V1LayerParameter::set_has_power_param() {
+ _has_bits_[1] |= 0x00000001u;
+}
+inline void V1LayerParameter::clear_has_power_param() {
+ _has_bits_[1] &= ~0x00000001u;
+}
+inline void V1LayerParameter::clear_power_param() {
+ if (power_param_ != NULL) power_param_->::caffe::PowerParameter::Clear();
+ clear_has_power_param();
+}
+inline const ::caffe::PowerParameter& V1LayerParameter::power_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.power_param)
+ return power_param_ != NULL ? *power_param_
+ : *::caffe::PowerParameter::internal_default_instance();
+}
+inline ::caffe::PowerParameter* V1LayerParameter::mutable_power_param() {
+ set_has_power_param();
+ if (power_param_ == NULL) {
+ power_param_ = new ::caffe::PowerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.power_param)
+ return power_param_;
+}
+inline ::caffe::PowerParameter* V1LayerParameter::release_power_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.power_param)
+ clear_has_power_param();
+ ::caffe::PowerParameter* temp = power_param_;
+ power_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_power_param(::caffe::PowerParameter* power_param) {
+ delete power_param_;
+ power_param_ = power_param;
+ if (power_param) {
+ set_has_power_param();
+ } else {
+ clear_has_power_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.power_param)
+}
+
+// optional .caffe.ReLUParameter relu_param = 30;
+inline bool V1LayerParameter::has_relu_param() const {
+ return (_has_bits_[1] & 0x00000002u) != 0;
+}
+inline void V1LayerParameter::set_has_relu_param() {
+ _has_bits_[1] |= 0x00000002u;
+}
+inline void V1LayerParameter::clear_has_relu_param() {
+ _has_bits_[1] &= ~0x00000002u;
+}
+inline void V1LayerParameter::clear_relu_param() {
+ if (relu_param_ != NULL) relu_param_->::caffe::ReLUParameter::Clear();
+ clear_has_relu_param();
+}
+inline const ::caffe::ReLUParameter& V1LayerParameter::relu_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.relu_param)
+ return relu_param_ != NULL ? *relu_param_
+ : *::caffe::ReLUParameter::internal_default_instance();
+}
+inline ::caffe::ReLUParameter* V1LayerParameter::mutable_relu_param() {
+ set_has_relu_param();
+ if (relu_param_ == NULL) {
+ relu_param_ = new ::caffe::ReLUParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.relu_param)
+ return relu_param_;
+}
+inline ::caffe::ReLUParameter* V1LayerParameter::release_relu_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.relu_param)
+ clear_has_relu_param();
+ ::caffe::ReLUParameter* temp = relu_param_;
+ relu_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_relu_param(::caffe::ReLUParameter* relu_param) {
+ delete relu_param_;
+ relu_param_ = relu_param;
+ if (relu_param) {
+ set_has_relu_param();
+ } else {
+ clear_has_relu_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.relu_param)
+}
+
+// optional .caffe.SigmoidParameter sigmoid_param = 38;
+inline bool V1LayerParameter::has_sigmoid_param() const {
+ return (_has_bits_[1] & 0x00000004u) != 0;
+}
+inline void V1LayerParameter::set_has_sigmoid_param() {
+ _has_bits_[1] |= 0x00000004u;
+}
+inline void V1LayerParameter::clear_has_sigmoid_param() {
+ _has_bits_[1] &= ~0x00000004u;
+}
+inline void V1LayerParameter::clear_sigmoid_param() {
+ if (sigmoid_param_ != NULL) sigmoid_param_->::caffe::SigmoidParameter::Clear();
+ clear_has_sigmoid_param();
+}
+inline const ::caffe::SigmoidParameter& V1LayerParameter::sigmoid_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.sigmoid_param)
+ return sigmoid_param_ != NULL ? *sigmoid_param_
+ : *::caffe::SigmoidParameter::internal_default_instance();
+}
+inline ::caffe::SigmoidParameter* V1LayerParameter::mutable_sigmoid_param() {
+ set_has_sigmoid_param();
+ if (sigmoid_param_ == NULL) {
+ sigmoid_param_ = new ::caffe::SigmoidParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.sigmoid_param)
+ return sigmoid_param_;
+}
+inline ::caffe::SigmoidParameter* V1LayerParameter::release_sigmoid_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.sigmoid_param)
+ clear_has_sigmoid_param();
+ ::caffe::SigmoidParameter* temp = sigmoid_param_;
+ sigmoid_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_sigmoid_param(::caffe::SigmoidParameter* sigmoid_param) {
+ delete sigmoid_param_;
+ sigmoid_param_ = sigmoid_param;
+ if (sigmoid_param) {
+ set_has_sigmoid_param();
+ } else {
+ clear_has_sigmoid_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.sigmoid_param)
+}
+
+// optional .caffe.SoftmaxParameter softmax_param = 39;
+inline bool V1LayerParameter::has_softmax_param() const {
+ return (_has_bits_[1] & 0x00000008u) != 0;
+}
+inline void V1LayerParameter::set_has_softmax_param() {
+ _has_bits_[1] |= 0x00000008u;
+}
+inline void V1LayerParameter::clear_has_softmax_param() {
+ _has_bits_[1] &= ~0x00000008u;
+}
+inline void V1LayerParameter::clear_softmax_param() {
+ if (softmax_param_ != NULL) softmax_param_->::caffe::SoftmaxParameter::Clear();
+ clear_has_softmax_param();
+}
+inline const ::caffe::SoftmaxParameter& V1LayerParameter::softmax_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.softmax_param)
+ return softmax_param_ != NULL ? *softmax_param_
+ : *::caffe::SoftmaxParameter::internal_default_instance();
+}
+inline ::caffe::SoftmaxParameter* V1LayerParameter::mutable_softmax_param() {
+ set_has_softmax_param();
+ if (softmax_param_ == NULL) {
+ softmax_param_ = new ::caffe::SoftmaxParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.softmax_param)
+ return softmax_param_;
+}
+inline ::caffe::SoftmaxParameter* V1LayerParameter::release_softmax_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.softmax_param)
+ clear_has_softmax_param();
+ ::caffe::SoftmaxParameter* temp = softmax_param_;
+ softmax_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_softmax_param(::caffe::SoftmaxParameter* softmax_param) {
+ delete softmax_param_;
+ softmax_param_ = softmax_param;
+ if (softmax_param) {
+ set_has_softmax_param();
+ } else {
+ clear_has_softmax_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.softmax_param)
+}
+
+// optional .caffe.SliceParameter slice_param = 31;
+inline bool V1LayerParameter::has_slice_param() const {
+ return (_has_bits_[1] & 0x00000010u) != 0;
+}
+inline void V1LayerParameter::set_has_slice_param() {
+ _has_bits_[1] |= 0x00000010u;
+}
+inline void V1LayerParameter::clear_has_slice_param() {
+ _has_bits_[1] &= ~0x00000010u;
+}
+inline void V1LayerParameter::clear_slice_param() {
+ if (slice_param_ != NULL) slice_param_->::caffe::SliceParameter::Clear();
+ clear_has_slice_param();
+}
+inline const ::caffe::SliceParameter& V1LayerParameter::slice_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.slice_param)
+ return slice_param_ != NULL ? *slice_param_
+ : *::caffe::SliceParameter::internal_default_instance();
+}
+inline ::caffe::SliceParameter* V1LayerParameter::mutable_slice_param() {
+ set_has_slice_param();
+ if (slice_param_ == NULL) {
+ slice_param_ = new ::caffe::SliceParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.slice_param)
+ return slice_param_;
+}
+inline ::caffe::SliceParameter* V1LayerParameter::release_slice_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.slice_param)
+ clear_has_slice_param();
+ ::caffe::SliceParameter* temp = slice_param_;
+ slice_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_slice_param(::caffe::SliceParameter* slice_param) {
+ delete slice_param_;
+ slice_param_ = slice_param;
+ if (slice_param) {
+ set_has_slice_param();
+ } else {
+ clear_has_slice_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.slice_param)
+}
+
+// optional .caffe.TanHParameter tanh_param = 37;
+inline bool V1LayerParameter::has_tanh_param() const {
+ return (_has_bits_[1] & 0x00000020u) != 0;
+}
+inline void V1LayerParameter::set_has_tanh_param() {
+ _has_bits_[1] |= 0x00000020u;
+}
+inline void V1LayerParameter::clear_has_tanh_param() {
+ _has_bits_[1] &= ~0x00000020u;
+}
+inline void V1LayerParameter::clear_tanh_param() {
+ if (tanh_param_ != NULL) tanh_param_->::caffe::TanHParameter::Clear();
+ clear_has_tanh_param();
+}
+inline const ::caffe::TanHParameter& V1LayerParameter::tanh_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.tanh_param)
+ return tanh_param_ != NULL ? *tanh_param_
+ : *::caffe::TanHParameter::internal_default_instance();
+}
+inline ::caffe::TanHParameter* V1LayerParameter::mutable_tanh_param() {
+ set_has_tanh_param();
+ if (tanh_param_ == NULL) {
+ tanh_param_ = new ::caffe::TanHParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.tanh_param)
+ return tanh_param_;
+}
+inline ::caffe::TanHParameter* V1LayerParameter::release_tanh_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.tanh_param)
+ clear_has_tanh_param();
+ ::caffe::TanHParameter* temp = tanh_param_;
+ tanh_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_tanh_param(::caffe::TanHParameter* tanh_param) {
+ delete tanh_param_;
+ tanh_param_ = tanh_param;
+ if (tanh_param) {
+ set_has_tanh_param();
+ } else {
+ clear_has_tanh_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.tanh_param)
+}
+
+// optional .caffe.ThresholdParameter threshold_param = 25;
+inline bool V1LayerParameter::has_threshold_param() const {
+ return (_has_bits_[1] & 0x00000040u) != 0;
+}
+inline void V1LayerParameter::set_has_threshold_param() {
+ _has_bits_[1] |= 0x00000040u;
+}
+inline void V1LayerParameter::clear_has_threshold_param() {
+ _has_bits_[1] &= ~0x00000040u;
+}
+inline void V1LayerParameter::clear_threshold_param() {
+ if (threshold_param_ != NULL) threshold_param_->::caffe::ThresholdParameter::Clear();
+ clear_has_threshold_param();
+}
+inline const ::caffe::ThresholdParameter& V1LayerParameter::threshold_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.threshold_param)
+ return threshold_param_ != NULL ? *threshold_param_
+ : *::caffe::ThresholdParameter::internal_default_instance();
+}
+inline ::caffe::ThresholdParameter* V1LayerParameter::mutable_threshold_param() {
+ set_has_threshold_param();
+ if (threshold_param_ == NULL) {
+ threshold_param_ = new ::caffe::ThresholdParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.threshold_param)
+ return threshold_param_;
+}
+inline ::caffe::ThresholdParameter* V1LayerParameter::release_threshold_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.threshold_param)
+ clear_has_threshold_param();
+ ::caffe::ThresholdParameter* temp = threshold_param_;
+ threshold_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_threshold_param(::caffe::ThresholdParameter* threshold_param) {
+ delete threshold_param_;
+ threshold_param_ = threshold_param;
+ if (threshold_param) {
+ set_has_threshold_param();
+ } else {
+ clear_has_threshold_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.threshold_param)
+}
+
+// optional .caffe.WindowDataParameter window_data_param = 20;
+inline bool V1LayerParameter::has_window_data_param() const {
+ return (_has_bits_[1] & 0x00000080u) != 0;
+}
+inline void V1LayerParameter::set_has_window_data_param() {
+ _has_bits_[1] |= 0x00000080u;
+}
+inline void V1LayerParameter::clear_has_window_data_param() {
+ _has_bits_[1] &= ~0x00000080u;
+}
+inline void V1LayerParameter::clear_window_data_param() {
+ if (window_data_param_ != NULL) window_data_param_->::caffe::WindowDataParameter::Clear();
+ clear_has_window_data_param();
+}
+inline const ::caffe::WindowDataParameter& V1LayerParameter::window_data_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.window_data_param)
+ return window_data_param_ != NULL ? *window_data_param_
+ : *::caffe::WindowDataParameter::internal_default_instance();
+}
+inline ::caffe::WindowDataParameter* V1LayerParameter::mutable_window_data_param() {
+ set_has_window_data_param();
+ if (window_data_param_ == NULL) {
+ window_data_param_ = new ::caffe::WindowDataParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.window_data_param)
+ return window_data_param_;
+}
+inline ::caffe::WindowDataParameter* V1LayerParameter::release_window_data_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.window_data_param)
+ clear_has_window_data_param();
+ ::caffe::WindowDataParameter* temp = window_data_param_;
+ window_data_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_window_data_param(::caffe::WindowDataParameter* window_data_param) {
+ delete window_data_param_;
+ window_data_param_ = window_data_param;
+ if (window_data_param) {
+ set_has_window_data_param();
+ } else {
+ clear_has_window_data_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.window_data_param)
+}
+
+// optional .caffe.TransformationParameter transform_param = 36;
+inline bool V1LayerParameter::has_transform_param() const {
+ return (_has_bits_[1] & 0x00000100u) != 0;
+}
+inline void V1LayerParameter::set_has_transform_param() {
+ _has_bits_[1] |= 0x00000100u;
+}
+inline void V1LayerParameter::clear_has_transform_param() {
+ _has_bits_[1] &= ~0x00000100u;
+}
+inline void V1LayerParameter::clear_transform_param() {
+ if (transform_param_ != NULL) transform_param_->::caffe::TransformationParameter::Clear();
+ clear_has_transform_param();
+}
+inline const ::caffe::TransformationParameter& V1LayerParameter::transform_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.transform_param)
+ return transform_param_ != NULL ? *transform_param_
+ : *::caffe::TransformationParameter::internal_default_instance();
+}
+inline ::caffe::TransformationParameter* V1LayerParameter::mutable_transform_param() {
+ set_has_transform_param();
+ if (transform_param_ == NULL) {
+ transform_param_ = new ::caffe::TransformationParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.transform_param)
+ return transform_param_;
+}
+inline ::caffe::TransformationParameter* V1LayerParameter::release_transform_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.transform_param)
+ clear_has_transform_param();
+ ::caffe::TransformationParameter* temp = transform_param_;
+ transform_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_transform_param(::caffe::TransformationParameter* transform_param) {
+ delete transform_param_;
+ transform_param_ = transform_param;
+ if (transform_param) {
+ set_has_transform_param();
+ } else {
+ clear_has_transform_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.transform_param)
+}
+
+// optional .caffe.LossParameter loss_param = 42;
+inline bool V1LayerParameter::has_loss_param() const {
+ return (_has_bits_[1] & 0x00000200u) != 0;
+}
+inline void V1LayerParameter::set_has_loss_param() {
+ _has_bits_[1] |= 0x00000200u;
+}
+inline void V1LayerParameter::clear_has_loss_param() {
+ _has_bits_[1] &= ~0x00000200u;
+}
+inline void V1LayerParameter::clear_loss_param() {
+ if (loss_param_ != NULL) loss_param_->::caffe::LossParameter::Clear();
+ clear_has_loss_param();
+}
+inline const ::caffe::LossParameter& V1LayerParameter::loss_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.loss_param)
+ return loss_param_ != NULL ? *loss_param_
+ : *::caffe::LossParameter::internal_default_instance();
+}
+inline ::caffe::LossParameter* V1LayerParameter::mutable_loss_param() {
+ set_has_loss_param();
+ if (loss_param_ == NULL) {
+ loss_param_ = new ::caffe::LossParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.loss_param)
+ return loss_param_;
+}
+inline ::caffe::LossParameter* V1LayerParameter::release_loss_param() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.loss_param)
+ clear_has_loss_param();
+ ::caffe::LossParameter* temp = loss_param_;
+ loss_param_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_loss_param(::caffe::LossParameter* loss_param) {
+ delete loss_param_;
+ loss_param_ = loss_param;
+ if (loss_param) {
+ set_has_loss_param();
+ } else {
+ clear_has_loss_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.loss_param)
+}
+
+// optional .caffe.V0LayerParameter layer = 1;
+inline bool V1LayerParameter::has_layer() const {
+ return (_has_bits_[1] & 0x00000400u) != 0;
+}
+inline void V1LayerParameter::set_has_layer() {
+ _has_bits_[1] |= 0x00000400u;
+}
+inline void V1LayerParameter::clear_has_layer() {
+ _has_bits_[1] &= ~0x00000400u;
+}
+inline void V1LayerParameter::clear_layer() {
+ if (layer_ != NULL) layer_->::caffe::V0LayerParameter::Clear();
+ clear_has_layer();
+}
+inline const ::caffe::V0LayerParameter& V1LayerParameter::layer() const {
+ // @@protoc_insertion_point(field_get:caffe.V1LayerParameter.layer)
+ return layer_ != NULL ? *layer_
+ : *::caffe::V0LayerParameter::internal_default_instance();
+}
+inline ::caffe::V0LayerParameter* V1LayerParameter::mutable_layer() {
+ set_has_layer();
+ if (layer_ == NULL) {
+ layer_ = new ::caffe::V0LayerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V1LayerParameter.layer)
+ return layer_;
+}
+inline ::caffe::V0LayerParameter* V1LayerParameter::release_layer() {
+ // @@protoc_insertion_point(field_release:caffe.V1LayerParameter.layer)
+ clear_has_layer();
+ ::caffe::V0LayerParameter* temp = layer_;
+ layer_ = NULL;
+ return temp;
+}
+inline void V1LayerParameter::set_allocated_layer(::caffe::V0LayerParameter* layer) {
+ delete layer_;
+ layer_ = layer;
+ if (layer) {
+ set_has_layer();
+ } else {
+ clear_has_layer();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V1LayerParameter.layer)
+}
+
+inline const V1LayerParameter* V1LayerParameter::internal_default_instance() {
+ return &V1LayerParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// V0LayerParameter
+
+// optional string name = 1;
+inline bool V0LayerParameter::has_name() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void V0LayerParameter::set_has_name() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void V0LayerParameter::clear_has_name() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void V0LayerParameter::clear_name() {
+ name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_name();
+}
+inline const ::std::string& V0LayerParameter::name() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.name)
+ return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void V0LayerParameter::set_name(const ::std::string& value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.name)
+}
+inline void V0LayerParameter::set_name(const char* value) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.name)
+}
+inline void V0LayerParameter::set_name(const char* value, size_t size) {
+ set_has_name();
+ name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.name)
+}
+inline ::std::string* V0LayerParameter::mutable_name() {
+ set_has_name();
+ // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.name)
+ return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* V0LayerParameter::release_name() {
+ // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.name)
+ clear_has_name();
+ return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void V0LayerParameter::set_allocated_name(::std::string* name) {
+ if (name != NULL) {
+ set_has_name();
+ } else {
+ clear_has_name();
+ }
+ name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
+ // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.name)
+}
+
+// optional string type = 2;
+inline bool V0LayerParameter::has_type() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void V0LayerParameter::set_has_type() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void V0LayerParameter::clear_has_type() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void V0LayerParameter::clear_type() {
+ type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_type();
+}
+inline const ::std::string& V0LayerParameter::type() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.type)
+ return type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void V0LayerParameter::set_type(const ::std::string& value) {
+ set_has_type();
+ type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.type)
+}
+inline void V0LayerParameter::set_type(const char* value) {
+ set_has_type();
+ type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.type)
+}
+inline void V0LayerParameter::set_type(const char* value, size_t size) {
+ set_has_type();
+ type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.type)
+}
+inline ::std::string* V0LayerParameter::mutable_type() {
+ set_has_type();
+ // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.type)
+ return type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* V0LayerParameter::release_type() {
+ // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.type)
+ clear_has_type();
+ return type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void V0LayerParameter::set_allocated_type(::std::string* type) {
+ if (type != NULL) {
+ set_has_type();
+ } else {
+ clear_has_type();
+ }
+ type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type);
+ // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.type)
+}
+
+// optional uint32 num_output = 3;
+inline bool V0LayerParameter::has_num_output() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void V0LayerParameter::set_has_num_output() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void V0LayerParameter::clear_has_num_output() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void V0LayerParameter::clear_num_output() {
+ num_output_ = 0u;
+ clear_has_num_output();
+}
+inline ::google::protobuf::uint32 V0LayerParameter::num_output() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.num_output)
+ return num_output_;
+}
+inline void V0LayerParameter::set_num_output(::google::protobuf::uint32 value) {
+ set_has_num_output();
+ num_output_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.num_output)
+}
+
+// optional bool biasterm = 4 [default = true];
+inline bool V0LayerParameter::has_biasterm() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void V0LayerParameter::set_has_biasterm() {
+ _has_bits_[0] |= 0x00000008u;
+}
+inline void V0LayerParameter::clear_has_biasterm() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+inline void V0LayerParameter::clear_biasterm() {
+ biasterm_ = true;
+ clear_has_biasterm();
+}
+inline bool V0LayerParameter::biasterm() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.biasterm)
+ return biasterm_;
+}
+inline void V0LayerParameter::set_biasterm(bool value) {
+ set_has_biasterm();
+ biasterm_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.biasterm)
+}
+
+// optional .caffe.FillerParameter weight_filler = 5;
+inline bool V0LayerParameter::has_weight_filler() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+inline void V0LayerParameter::set_has_weight_filler() {
+ _has_bits_[0] |= 0x00000010u;
+}
+inline void V0LayerParameter::clear_has_weight_filler() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+inline void V0LayerParameter::clear_weight_filler() {
+ if (weight_filler_ != NULL) weight_filler_->::caffe::FillerParameter::Clear();
+ clear_has_weight_filler();
+}
+inline const ::caffe::FillerParameter& V0LayerParameter::weight_filler() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.weight_filler)
+ return weight_filler_ != NULL ? *weight_filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+inline ::caffe::FillerParameter* V0LayerParameter::mutable_weight_filler() {
+ set_has_weight_filler();
+ if (weight_filler_ == NULL) {
+ weight_filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.weight_filler)
+ return weight_filler_;
+}
+inline ::caffe::FillerParameter* V0LayerParameter::release_weight_filler() {
+ // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.weight_filler)
+ clear_has_weight_filler();
+ ::caffe::FillerParameter* temp = weight_filler_;
+ weight_filler_ = NULL;
+ return temp;
+}
+inline void V0LayerParameter::set_allocated_weight_filler(::caffe::FillerParameter* weight_filler) {
+ delete weight_filler_;
+ weight_filler_ = weight_filler;
+ if (weight_filler) {
+ set_has_weight_filler();
+ } else {
+ clear_has_weight_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.weight_filler)
+}
+
+// optional .caffe.FillerParameter bias_filler = 6;
+inline bool V0LayerParameter::has_bias_filler() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+inline void V0LayerParameter::set_has_bias_filler() {
+ _has_bits_[0] |= 0x00000020u;
+}
+inline void V0LayerParameter::clear_has_bias_filler() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+inline void V0LayerParameter::clear_bias_filler() {
+ if (bias_filler_ != NULL) bias_filler_->::caffe::FillerParameter::Clear();
+ clear_has_bias_filler();
+}
+inline const ::caffe::FillerParameter& V0LayerParameter::bias_filler() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.bias_filler)
+ return bias_filler_ != NULL ? *bias_filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+inline ::caffe::FillerParameter* V0LayerParameter::mutable_bias_filler() {
+ set_has_bias_filler();
+ if (bias_filler_ == NULL) {
+ bias_filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.bias_filler)
+ return bias_filler_;
+}
+inline ::caffe::FillerParameter* V0LayerParameter::release_bias_filler() {
+ // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.bias_filler)
+ clear_has_bias_filler();
+ ::caffe::FillerParameter* temp = bias_filler_;
+ bias_filler_ = NULL;
+ return temp;
+}
+inline void V0LayerParameter::set_allocated_bias_filler(::caffe::FillerParameter* bias_filler) {
+ delete bias_filler_;
+ bias_filler_ = bias_filler;
+ if (bias_filler) {
+ set_has_bias_filler();
+ } else {
+ clear_has_bias_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.bias_filler)
+}
+
+// optional uint32 pad = 7 [default = 0];
+inline bool V0LayerParameter::has_pad() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+inline void V0LayerParameter::set_has_pad() {
+ _has_bits_[0] |= 0x00000040u;
+}
+inline void V0LayerParameter::clear_has_pad() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+inline void V0LayerParameter::clear_pad() {
+ pad_ = 0u;
+ clear_has_pad();
+}
+inline ::google::protobuf::uint32 V0LayerParameter::pad() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.pad)
+ return pad_;
+}
+inline void V0LayerParameter::set_pad(::google::protobuf::uint32 value) {
+ set_has_pad();
+ pad_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.pad)
+}
+
+// optional uint32 kernelsize = 8;
+inline bool V0LayerParameter::has_kernelsize() const {
+ return (_has_bits_[0] & 0x00000080u) != 0;
+}
+inline void V0LayerParameter::set_has_kernelsize() {
+ _has_bits_[0] |= 0x00000080u;
+}
+inline void V0LayerParameter::clear_has_kernelsize() {
+ _has_bits_[0] &= ~0x00000080u;
+}
+inline void V0LayerParameter::clear_kernelsize() {
+ kernelsize_ = 0u;
+ clear_has_kernelsize();
+}
+inline ::google::protobuf::uint32 V0LayerParameter::kernelsize() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.kernelsize)
+ return kernelsize_;
+}
+inline void V0LayerParameter::set_kernelsize(::google::protobuf::uint32 value) {
+ set_has_kernelsize();
+ kernelsize_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.kernelsize)
+}
+
+// optional uint32 group = 9 [default = 1];
+inline bool V0LayerParameter::has_group() const {
+ return (_has_bits_[0] & 0x00000100u) != 0;
+}
+inline void V0LayerParameter::set_has_group() {
+ _has_bits_[0] |= 0x00000100u;
+}
+inline void V0LayerParameter::clear_has_group() {
+ _has_bits_[0] &= ~0x00000100u;
+}
+inline void V0LayerParameter::clear_group() {
+ group_ = 1u;
+ clear_has_group();
+}
+inline ::google::protobuf::uint32 V0LayerParameter::group() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.group)
+ return group_;
+}
+inline void V0LayerParameter::set_group(::google::protobuf::uint32 value) {
+ set_has_group();
+ group_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.group)
+}
+
+// optional uint32 stride = 10 [default = 1];
+inline bool V0LayerParameter::has_stride() const {
+ return (_has_bits_[0] & 0x00000200u) != 0;
+}
+inline void V0LayerParameter::set_has_stride() {
+ _has_bits_[0] |= 0x00000200u;
+}
+inline void V0LayerParameter::clear_has_stride() {
+ _has_bits_[0] &= ~0x00000200u;
+}
+inline void V0LayerParameter::clear_stride() {
+ stride_ = 1u;
+ clear_has_stride();
+}
+inline ::google::protobuf::uint32 V0LayerParameter::stride() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.stride)
+ return stride_;
+}
+inline void V0LayerParameter::set_stride(::google::protobuf::uint32 value) {
+ set_has_stride();
+ stride_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.stride)
+}
+
+// optional .caffe.V0LayerParameter.PoolMethod pool = 11 [default = MAX];
+inline bool V0LayerParameter::has_pool() const {
+ return (_has_bits_[0] & 0x00000400u) != 0;
+}
+inline void V0LayerParameter::set_has_pool() {
+ _has_bits_[0] |= 0x00000400u;
+}
+inline void V0LayerParameter::clear_has_pool() {
+ _has_bits_[0] &= ~0x00000400u;
+}
+inline void V0LayerParameter::clear_pool() {
+ pool_ = 0;
+ clear_has_pool();
+}
+inline ::caffe::V0LayerParameter_PoolMethod V0LayerParameter::pool() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.pool)
+ return static_cast< ::caffe::V0LayerParameter_PoolMethod >(pool_);
+}
+inline void V0LayerParameter::set_pool(::caffe::V0LayerParameter_PoolMethod value) {
+ assert(::caffe::V0LayerParameter_PoolMethod_IsValid(value));
+ set_has_pool();
+ pool_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.pool)
+}
+
+// optional float dropout_ratio = 12 [default = 0.5];
+inline bool V0LayerParameter::has_dropout_ratio() const {
+ return (_has_bits_[0] & 0x00000800u) != 0;
+}
+inline void V0LayerParameter::set_has_dropout_ratio() {
+ _has_bits_[0] |= 0x00000800u;
+}
+inline void V0LayerParameter::clear_has_dropout_ratio() {
+ _has_bits_[0] &= ~0x00000800u;
+}
+inline void V0LayerParameter::clear_dropout_ratio() {
+ dropout_ratio_ = 0.5f;
+ clear_has_dropout_ratio();
+}
+inline float V0LayerParameter::dropout_ratio() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.dropout_ratio)
+ return dropout_ratio_;
+}
+inline void V0LayerParameter::set_dropout_ratio(float value) {
+ set_has_dropout_ratio();
+ dropout_ratio_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.dropout_ratio)
+}
+
+// optional uint32 local_size = 13 [default = 5];
+inline bool V0LayerParameter::has_local_size() const {
+ return (_has_bits_[0] & 0x00001000u) != 0;
+}
+inline void V0LayerParameter::set_has_local_size() {
+ _has_bits_[0] |= 0x00001000u;
+}
+inline void V0LayerParameter::clear_has_local_size() {
+ _has_bits_[0] &= ~0x00001000u;
+}
+inline void V0LayerParameter::clear_local_size() {
+ local_size_ = 5u;
+ clear_has_local_size();
+}
+inline ::google::protobuf::uint32 V0LayerParameter::local_size() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.local_size)
+ return local_size_;
+}
+inline void V0LayerParameter::set_local_size(::google::protobuf::uint32 value) {
+ set_has_local_size();
+ local_size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.local_size)
+}
+
+// optional float alpha = 14 [default = 1];
+inline bool V0LayerParameter::has_alpha() const {
+ return (_has_bits_[0] & 0x00002000u) != 0;
+}
+inline void V0LayerParameter::set_has_alpha() {
+ _has_bits_[0] |= 0x00002000u;
+}
+inline void V0LayerParameter::clear_has_alpha() {
+ _has_bits_[0] &= ~0x00002000u;
+}
+inline void V0LayerParameter::clear_alpha() {
+ alpha_ = 1;
+ clear_has_alpha();
+}
+inline float V0LayerParameter::alpha() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.alpha)
+ return alpha_;
+}
+inline void V0LayerParameter::set_alpha(float value) {
+ set_has_alpha();
+ alpha_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.alpha)
+}
+
+// optional float beta = 15 [default = 0.75];
+inline bool V0LayerParameter::has_beta() const {
+ return (_has_bits_[0] & 0x00004000u) != 0;
+}
+inline void V0LayerParameter::set_has_beta() {
+ _has_bits_[0] |= 0x00004000u;
+}
+inline void V0LayerParameter::clear_has_beta() {
+ _has_bits_[0] &= ~0x00004000u;
+}
+inline void V0LayerParameter::clear_beta() {
+ beta_ = 0.75f;
+ clear_has_beta();
+}
+inline float V0LayerParameter::beta() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.beta)
+ return beta_;
+}
+inline void V0LayerParameter::set_beta(float value) {
+ set_has_beta();
+ beta_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.beta)
+}
+
+// optional float k = 22 [default = 1];
+inline bool V0LayerParameter::has_k() const {
+ return (_has_bits_[0] & 0x00008000u) != 0;
+}
+inline void V0LayerParameter::set_has_k() {
+ _has_bits_[0] |= 0x00008000u;
+}
+inline void V0LayerParameter::clear_has_k() {
+ _has_bits_[0] &= ~0x00008000u;
+}
+inline void V0LayerParameter::clear_k() {
+ k_ = 1;
+ clear_has_k();
+}
+inline float V0LayerParameter::k() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.k)
+ return k_;
+}
+inline void V0LayerParameter::set_k(float value) {
+ set_has_k();
+ k_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.k)
+}
+
+// optional string source = 16;
+inline bool V0LayerParameter::has_source() const {
+ return (_has_bits_[0] & 0x00010000u) != 0;
+}
+inline void V0LayerParameter::set_has_source() {
+ _has_bits_[0] |= 0x00010000u;
+}
+inline void V0LayerParameter::clear_has_source() {
+ _has_bits_[0] &= ~0x00010000u;
+}
+inline void V0LayerParameter::clear_source() {
+ source_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_source();
+}
+inline const ::std::string& V0LayerParameter::source() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.source)
+ return source_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void V0LayerParameter::set_source(const ::std::string& value) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.source)
+}
+inline void V0LayerParameter::set_source(const char* value) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.source)
+}
+inline void V0LayerParameter::set_source(const char* value, size_t size) {
+ set_has_source();
+ source_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.source)
+}
+inline ::std::string* V0LayerParameter::mutable_source() {
+ set_has_source();
+ // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.source)
+ return source_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* V0LayerParameter::release_source() {
+ // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.source)
+ clear_has_source();
+ return source_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void V0LayerParameter::set_allocated_source(::std::string* source) {
+ if (source != NULL) {
+ set_has_source();
+ } else {
+ clear_has_source();
+ }
+ source_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source);
+ // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.source)
+}
+
+// optional float scale = 17 [default = 1];
+inline bool V0LayerParameter::has_scale() const {
+ return (_has_bits_[0] & 0x00020000u) != 0;
+}
+inline void V0LayerParameter::set_has_scale() {
+ _has_bits_[0] |= 0x00020000u;
+}
+inline void V0LayerParameter::clear_has_scale() {
+ _has_bits_[0] &= ~0x00020000u;
+}
+inline void V0LayerParameter::clear_scale() {
+ scale_ = 1;
+ clear_has_scale();
+}
+inline float V0LayerParameter::scale() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.scale)
+ return scale_;
+}
+inline void V0LayerParameter::set_scale(float value) {
+ set_has_scale();
+ scale_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.scale)
+}
+
+// optional string meanfile = 18;
+inline bool V0LayerParameter::has_meanfile() const {
+ return (_has_bits_[0] & 0x00040000u) != 0;
+}
+inline void V0LayerParameter::set_has_meanfile() {
+ _has_bits_[0] |= 0x00040000u;
+}
+inline void V0LayerParameter::clear_has_meanfile() {
+ _has_bits_[0] &= ~0x00040000u;
+}
+inline void V0LayerParameter::clear_meanfile() {
+ meanfile_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+ clear_has_meanfile();
+}
+inline const ::std::string& V0LayerParameter::meanfile() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.meanfile)
+ return meanfile_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void V0LayerParameter::set_meanfile(const ::std::string& value) {
+ set_has_meanfile();
+ meanfile_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.meanfile)
+}
+inline void V0LayerParameter::set_meanfile(const char* value) {
+ set_has_meanfile();
+ meanfile_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.meanfile)
+}
+inline void V0LayerParameter::set_meanfile(const char* value, size_t size) {
+ set_has_meanfile();
+ meanfile_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.meanfile)
+}
+inline ::std::string* V0LayerParameter::mutable_meanfile() {
+ set_has_meanfile();
+ // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.meanfile)
+ return meanfile_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* V0LayerParameter::release_meanfile() {
+ // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.meanfile)
+ clear_has_meanfile();
+ return meanfile_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void V0LayerParameter::set_allocated_meanfile(::std::string* meanfile) {
+ if (meanfile != NULL) {
+ set_has_meanfile();
+ } else {
+ clear_has_meanfile();
+ }
+ meanfile_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), meanfile);
+ // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.meanfile)
+}
+
+// optional uint32 batchsize = 19;
+inline bool V0LayerParameter::has_batchsize() const {
+ return (_has_bits_[0] & 0x00080000u) != 0;
+}
+inline void V0LayerParameter::set_has_batchsize() {
+ _has_bits_[0] |= 0x00080000u;
+}
+inline void V0LayerParameter::clear_has_batchsize() {
+ _has_bits_[0] &= ~0x00080000u;
+}
+inline void V0LayerParameter::clear_batchsize() {
+ batchsize_ = 0u;
+ clear_has_batchsize();
+}
+inline ::google::protobuf::uint32 V0LayerParameter::batchsize() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.batchsize)
+ return batchsize_;
+}
+inline void V0LayerParameter::set_batchsize(::google::protobuf::uint32 value) {
+ set_has_batchsize();
+ batchsize_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.batchsize)
+}
+
+// optional uint32 cropsize = 20 [default = 0];
+inline bool V0LayerParameter::has_cropsize() const {
+ return (_has_bits_[0] & 0x00100000u) != 0;
+}
+inline void V0LayerParameter::set_has_cropsize() {
+ _has_bits_[0] |= 0x00100000u;
+}
+inline void V0LayerParameter::clear_has_cropsize() {
+ _has_bits_[0] &= ~0x00100000u;
+}
+inline void V0LayerParameter::clear_cropsize() {
+ cropsize_ = 0u;
+ clear_has_cropsize();
+}
+inline ::google::protobuf::uint32 V0LayerParameter::cropsize() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.cropsize)
+ return cropsize_;
+}
+inline void V0LayerParameter::set_cropsize(::google::protobuf::uint32 value) {
+ set_has_cropsize();
+ cropsize_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.cropsize)
+}
+
+// optional bool mirror = 21 [default = false];
+inline bool V0LayerParameter::has_mirror() const {
+ return (_has_bits_[0] & 0x00200000u) != 0;
+}
+inline void V0LayerParameter::set_has_mirror() {
+ _has_bits_[0] |= 0x00200000u;
+}
+inline void V0LayerParameter::clear_has_mirror() {
+ _has_bits_[0] &= ~0x00200000u;
+}
+inline void V0LayerParameter::clear_mirror() {
+ mirror_ = false;
+ clear_has_mirror();
+}
+inline bool V0LayerParameter::mirror() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.mirror)
+ return mirror_;
+}
+inline void V0LayerParameter::set_mirror(bool value) {
+ set_has_mirror();
+ mirror_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.mirror)
+}
+
+// repeated .caffe.BlobProto blobs = 50;
+inline int V0LayerParameter::blobs_size() const {
+ return blobs_.size();
+}
+inline void V0LayerParameter::clear_blobs() {
+ blobs_.Clear();
+}
+inline const ::caffe::BlobProto& V0LayerParameter::blobs(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.blobs)
+ return blobs_.Get(index);
+}
+inline ::caffe::BlobProto* V0LayerParameter::mutable_blobs(int index) {
+ // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.blobs)
+ return blobs_.Mutable(index);
+}
+inline ::caffe::BlobProto* V0LayerParameter::add_blobs() {
+ // @@protoc_insertion_point(field_add:caffe.V0LayerParameter.blobs)
+ return blobs_.Add();
+}
+inline ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >*
+V0LayerParameter::mutable_blobs() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V0LayerParameter.blobs)
+ return &blobs_;
+}
+inline const ::google::protobuf::RepeatedPtrField< ::caffe::BlobProto >&
+V0LayerParameter::blobs() const {
+ // @@protoc_insertion_point(field_list:caffe.V0LayerParameter.blobs)
+ return blobs_;
+}
+
+// repeated float blobs_lr = 51;
+inline int V0LayerParameter::blobs_lr_size() const {
+ return blobs_lr_.size();
+}
+inline void V0LayerParameter::clear_blobs_lr() {
+ blobs_lr_.Clear();
+}
+inline float V0LayerParameter::blobs_lr(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.blobs_lr)
+ return blobs_lr_.Get(index);
+}
+inline void V0LayerParameter::set_blobs_lr(int index, float value) {
+ blobs_lr_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.blobs_lr)
+}
+inline void V0LayerParameter::add_blobs_lr(float value) {
+ blobs_lr_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.V0LayerParameter.blobs_lr)
+}
+inline const ::google::protobuf::RepeatedField< float >&
+V0LayerParameter::blobs_lr() const {
+ // @@protoc_insertion_point(field_list:caffe.V0LayerParameter.blobs_lr)
+ return blobs_lr_;
+}
+inline ::google::protobuf::RepeatedField< float >*
+V0LayerParameter::mutable_blobs_lr() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V0LayerParameter.blobs_lr)
+ return &blobs_lr_;
+}
+
+// repeated float weight_decay = 52;
+inline int V0LayerParameter::weight_decay_size() const {
+ return weight_decay_.size();
+}
+inline void V0LayerParameter::clear_weight_decay() {
+ weight_decay_.Clear();
+}
+inline float V0LayerParameter::weight_decay(int index) const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.weight_decay)
+ return weight_decay_.Get(index);
+}
+inline void V0LayerParameter::set_weight_decay(int index, float value) {
+ weight_decay_.Set(index, value);
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.weight_decay)
+}
+inline void V0LayerParameter::add_weight_decay(float value) {
+ weight_decay_.Add(value);
+ // @@protoc_insertion_point(field_add:caffe.V0LayerParameter.weight_decay)
+}
+inline const ::google::protobuf::RepeatedField< float >&
+V0LayerParameter::weight_decay() const {
+ // @@protoc_insertion_point(field_list:caffe.V0LayerParameter.weight_decay)
+ return weight_decay_;
+}
+inline ::google::protobuf::RepeatedField< float >*
+V0LayerParameter::mutable_weight_decay() {
+ // @@protoc_insertion_point(field_mutable_list:caffe.V0LayerParameter.weight_decay)
+ return &weight_decay_;
+}
+
+// optional uint32 rand_skip = 53 [default = 0];
+inline bool V0LayerParameter::has_rand_skip() const {
+ return (_has_bits_[0] & 0x02000000u) != 0;
+}
+inline void V0LayerParameter::set_has_rand_skip() {
+ _has_bits_[0] |= 0x02000000u;
+}
+inline void V0LayerParameter::clear_has_rand_skip() {
+ _has_bits_[0] &= ~0x02000000u;
+}
+inline void V0LayerParameter::clear_rand_skip() {
+ rand_skip_ = 0u;
+ clear_has_rand_skip();
+}
+inline ::google::protobuf::uint32 V0LayerParameter::rand_skip() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.rand_skip)
+ return rand_skip_;
+}
+inline void V0LayerParameter::set_rand_skip(::google::protobuf::uint32 value) {
+ set_has_rand_skip();
+ rand_skip_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.rand_skip)
+}
+
+// optional float det_fg_threshold = 54 [default = 0.5];
+inline bool V0LayerParameter::has_det_fg_threshold() const {
+ return (_has_bits_[0] & 0x04000000u) != 0;
+}
+inline void V0LayerParameter::set_has_det_fg_threshold() {
+ _has_bits_[0] |= 0x04000000u;
+}
+inline void V0LayerParameter::clear_has_det_fg_threshold() {
+ _has_bits_[0] &= ~0x04000000u;
+}
+inline void V0LayerParameter::clear_det_fg_threshold() {
+ det_fg_threshold_ = 0.5f;
+ clear_has_det_fg_threshold();
+}
+inline float V0LayerParameter::det_fg_threshold() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_fg_threshold)
+ return det_fg_threshold_;
+}
+inline void V0LayerParameter::set_det_fg_threshold(float value) {
+ set_has_det_fg_threshold();
+ det_fg_threshold_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_fg_threshold)
+}
+
+// optional float det_bg_threshold = 55 [default = 0.5];
+inline bool V0LayerParameter::has_det_bg_threshold() const {
+ return (_has_bits_[0] & 0x08000000u) != 0;
+}
+inline void V0LayerParameter::set_has_det_bg_threshold() {
+ _has_bits_[0] |= 0x08000000u;
+}
+inline void V0LayerParameter::clear_has_det_bg_threshold() {
+ _has_bits_[0] &= ~0x08000000u;
+}
+inline void V0LayerParameter::clear_det_bg_threshold() {
+ det_bg_threshold_ = 0.5f;
+ clear_has_det_bg_threshold();
+}
+inline float V0LayerParameter::det_bg_threshold() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_bg_threshold)
+ return det_bg_threshold_;
+}
+inline void V0LayerParameter::set_det_bg_threshold(float value) {
+ set_has_det_bg_threshold();
+ det_bg_threshold_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_bg_threshold)
+}
+
+// optional float det_fg_fraction = 56 [default = 0.25];
+inline bool V0LayerParameter::has_det_fg_fraction() const {
+ return (_has_bits_[0] & 0x10000000u) != 0;
+}
+inline void V0LayerParameter::set_has_det_fg_fraction() {
+ _has_bits_[0] |= 0x10000000u;
+}
+inline void V0LayerParameter::clear_has_det_fg_fraction() {
+ _has_bits_[0] &= ~0x10000000u;
+}
+inline void V0LayerParameter::clear_det_fg_fraction() {
+ det_fg_fraction_ = 0.25f;
+ clear_has_det_fg_fraction();
+}
+inline float V0LayerParameter::det_fg_fraction() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_fg_fraction)
+ return det_fg_fraction_;
+}
+inline void V0LayerParameter::set_det_fg_fraction(float value) {
+ set_has_det_fg_fraction();
+ det_fg_fraction_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_fg_fraction)
+}
+
+// optional uint32 det_context_pad = 58 [default = 0];
+inline bool V0LayerParameter::has_det_context_pad() const {
+ return (_has_bits_[0] & 0x20000000u) != 0;
+}
+inline void V0LayerParameter::set_has_det_context_pad() {
+ _has_bits_[0] |= 0x20000000u;
+}
+inline void V0LayerParameter::clear_has_det_context_pad() {
+ _has_bits_[0] &= ~0x20000000u;
+}
+inline void V0LayerParameter::clear_det_context_pad() {
+ det_context_pad_ = 0u;
+ clear_has_det_context_pad();
+}
+inline ::google::protobuf::uint32 V0LayerParameter::det_context_pad() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_context_pad)
+ return det_context_pad_;
+}
+inline void V0LayerParameter::set_det_context_pad(::google::protobuf::uint32 value) {
+ set_has_det_context_pad();
+ det_context_pad_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_context_pad)
+}
+
+// optional string det_crop_mode = 59 [default = "warp"];
+inline bool V0LayerParameter::has_det_crop_mode() const {
+ return (_has_bits_[0] & 0x40000000u) != 0;
+}
+inline void V0LayerParameter::set_has_det_crop_mode() {
+ _has_bits_[0] |= 0x40000000u;
+}
+inline void V0LayerParameter::clear_has_det_crop_mode() {
+ _has_bits_[0] &= ~0x40000000u;
+}
+inline void V0LayerParameter::clear_det_crop_mode() {
+ det_crop_mode_.ClearToDefaultNoArena(_default_det_crop_mode_);
+ clear_has_det_crop_mode();
+}
+inline const ::std::string& V0LayerParameter::det_crop_mode() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.det_crop_mode)
+ return det_crop_mode_.GetNoArena(_default_det_crop_mode_);
+}
+inline void V0LayerParameter::set_det_crop_mode(const ::std::string& value) {
+ set_has_det_crop_mode();
+ det_crop_mode_.SetNoArena(_default_det_crop_mode_, value);
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.det_crop_mode)
+}
+inline void V0LayerParameter::set_det_crop_mode(const char* value) {
+ set_has_det_crop_mode();
+ det_crop_mode_.SetNoArena(_default_det_crop_mode_, ::std::string(value));
+ // @@protoc_insertion_point(field_set_char:caffe.V0LayerParameter.det_crop_mode)
+}
+inline void V0LayerParameter::set_det_crop_mode(const char* value, size_t size) {
+ set_has_det_crop_mode();
+ det_crop_mode_.SetNoArena(_default_det_crop_mode_,
+ ::std::string(reinterpret_cast<const char*>(value), size));
+ // @@protoc_insertion_point(field_set_pointer:caffe.V0LayerParameter.det_crop_mode)
+}
+inline ::std::string* V0LayerParameter::mutable_det_crop_mode() {
+ set_has_det_crop_mode();
+ // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.det_crop_mode)
+ return det_crop_mode_.MutableNoArena(_default_det_crop_mode_);
+}
+inline ::std::string* V0LayerParameter::release_det_crop_mode() {
+ // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.det_crop_mode)
+ clear_has_det_crop_mode();
+ return det_crop_mode_.ReleaseNoArena(_default_det_crop_mode_);
+}
+inline void V0LayerParameter::set_allocated_det_crop_mode(::std::string* det_crop_mode) {
+ if (det_crop_mode != NULL) {
+ set_has_det_crop_mode();
+ } else {
+ clear_has_det_crop_mode();
+ }
+ det_crop_mode_.SetAllocatedNoArena(_default_det_crop_mode_, det_crop_mode);
+ // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.det_crop_mode)
+}
+
+// optional int32 new_num = 60 [default = 0];
+inline bool V0LayerParameter::has_new_num() const {
+ return (_has_bits_[0] & 0x80000000u) != 0;
+}
+inline void V0LayerParameter::set_has_new_num() {
+ _has_bits_[0] |= 0x80000000u;
+}
+inline void V0LayerParameter::clear_has_new_num() {
+ _has_bits_[0] &= ~0x80000000u;
+}
+inline void V0LayerParameter::clear_new_num() {
+ new_num_ = 0;
+ clear_has_new_num();
+}
+inline ::google::protobuf::int32 V0LayerParameter::new_num() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.new_num)
+ return new_num_;
+}
+inline void V0LayerParameter::set_new_num(::google::protobuf::int32 value) {
+ set_has_new_num();
+ new_num_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.new_num)
+}
+
+// optional int32 new_channels = 61 [default = 0];
+inline bool V0LayerParameter::has_new_channels() const {
+ return (_has_bits_[1] & 0x00000001u) != 0;
+}
+inline void V0LayerParameter::set_has_new_channels() {
+ _has_bits_[1] |= 0x00000001u;
+}
+inline void V0LayerParameter::clear_has_new_channels() {
+ _has_bits_[1] &= ~0x00000001u;
+}
+inline void V0LayerParameter::clear_new_channels() {
+ new_channels_ = 0;
+ clear_has_new_channels();
+}
+inline ::google::protobuf::int32 V0LayerParameter::new_channels() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.new_channels)
+ return new_channels_;
+}
+inline void V0LayerParameter::set_new_channels(::google::protobuf::int32 value) {
+ set_has_new_channels();
+ new_channels_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.new_channels)
+}
+
+// optional int32 new_height = 62 [default = 0];
+inline bool V0LayerParameter::has_new_height() const {
+ return (_has_bits_[1] & 0x00000002u) != 0;
+}
+inline void V0LayerParameter::set_has_new_height() {
+ _has_bits_[1] |= 0x00000002u;
+}
+inline void V0LayerParameter::clear_has_new_height() {
+ _has_bits_[1] &= ~0x00000002u;
+}
+inline void V0LayerParameter::clear_new_height() {
+ new_height_ = 0;
+ clear_has_new_height();
+}
+inline ::google::protobuf::int32 V0LayerParameter::new_height() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.new_height)
+ return new_height_;
+}
+inline void V0LayerParameter::set_new_height(::google::protobuf::int32 value) {
+ set_has_new_height();
+ new_height_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.new_height)
+}
+
+// optional int32 new_width = 63 [default = 0];
+inline bool V0LayerParameter::has_new_width() const {
+ return (_has_bits_[1] & 0x00000004u) != 0;
+}
+inline void V0LayerParameter::set_has_new_width() {
+ _has_bits_[1] |= 0x00000004u;
+}
+inline void V0LayerParameter::clear_has_new_width() {
+ _has_bits_[1] &= ~0x00000004u;
+}
+inline void V0LayerParameter::clear_new_width() {
+ new_width_ = 0;
+ clear_has_new_width();
+}
+inline ::google::protobuf::int32 V0LayerParameter::new_width() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.new_width)
+ return new_width_;
+}
+inline void V0LayerParameter::set_new_width(::google::protobuf::int32 value) {
+ set_has_new_width();
+ new_width_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.new_width)
+}
+
+// optional bool shuffle_images = 64 [default = false];
+inline bool V0LayerParameter::has_shuffle_images() const {
+ return (_has_bits_[1] & 0x00000008u) != 0;
+}
+inline void V0LayerParameter::set_has_shuffle_images() {
+ _has_bits_[1] |= 0x00000008u;
+}
+inline void V0LayerParameter::clear_has_shuffle_images() {
+ _has_bits_[1] &= ~0x00000008u;
+}
+inline void V0LayerParameter::clear_shuffle_images() {
+ shuffle_images_ = false;
+ clear_has_shuffle_images();
+}
+inline bool V0LayerParameter::shuffle_images() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.shuffle_images)
+ return shuffle_images_;
+}
+inline void V0LayerParameter::set_shuffle_images(bool value) {
+ set_has_shuffle_images();
+ shuffle_images_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.shuffle_images)
+}
+
+// optional uint32 concat_dim = 65 [default = 1];
+inline bool V0LayerParameter::has_concat_dim() const {
+ return (_has_bits_[1] & 0x00000010u) != 0;
+}
+inline void V0LayerParameter::set_has_concat_dim() {
+ _has_bits_[1] |= 0x00000010u;
+}
+inline void V0LayerParameter::clear_has_concat_dim() {
+ _has_bits_[1] &= ~0x00000010u;
+}
+inline void V0LayerParameter::clear_concat_dim() {
+ concat_dim_ = 1u;
+ clear_has_concat_dim();
+}
+inline ::google::protobuf::uint32 V0LayerParameter::concat_dim() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.concat_dim)
+ return concat_dim_;
+}
+inline void V0LayerParameter::set_concat_dim(::google::protobuf::uint32 value) {
+ set_has_concat_dim();
+ concat_dim_ = value;
+ // @@protoc_insertion_point(field_set:caffe.V0LayerParameter.concat_dim)
+}
+
+// optional .caffe.HDF5OutputParameter hdf5_output_param = 1001;
+inline bool V0LayerParameter::has_hdf5_output_param() const {
+ return (_has_bits_[1] & 0x00000020u) != 0;
+}
+inline void V0LayerParameter::set_has_hdf5_output_param() {
+ _has_bits_[1] |= 0x00000020u;
+}
+inline void V0LayerParameter::clear_has_hdf5_output_param() {
+ _has_bits_[1] &= ~0x00000020u;
+}
+inline void V0LayerParameter::clear_hdf5_output_param() {
+ if (hdf5_output_param_ != NULL) hdf5_output_param_->::caffe::HDF5OutputParameter::Clear();
+ clear_has_hdf5_output_param();
+}
+inline const ::caffe::HDF5OutputParameter& V0LayerParameter::hdf5_output_param() const {
+ // @@protoc_insertion_point(field_get:caffe.V0LayerParameter.hdf5_output_param)
+ return hdf5_output_param_ != NULL ? *hdf5_output_param_
+ : *::caffe::HDF5OutputParameter::internal_default_instance();
+}
+inline ::caffe::HDF5OutputParameter* V0LayerParameter::mutable_hdf5_output_param() {
+ set_has_hdf5_output_param();
+ if (hdf5_output_param_ == NULL) {
+ hdf5_output_param_ = new ::caffe::HDF5OutputParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.V0LayerParameter.hdf5_output_param)
+ return hdf5_output_param_;
+}
+inline ::caffe::HDF5OutputParameter* V0LayerParameter::release_hdf5_output_param() {
+ // @@protoc_insertion_point(field_release:caffe.V0LayerParameter.hdf5_output_param)
+ clear_has_hdf5_output_param();
+ ::caffe::HDF5OutputParameter* temp = hdf5_output_param_;
+ hdf5_output_param_ = NULL;
+ return temp;
+}
+inline void V0LayerParameter::set_allocated_hdf5_output_param(::caffe::HDF5OutputParameter* hdf5_output_param) {
+ delete hdf5_output_param_;
+ hdf5_output_param_ = hdf5_output_param;
+ if (hdf5_output_param) {
+ set_has_hdf5_output_param();
+ } else {
+ clear_has_hdf5_output_param();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.V0LayerParameter.hdf5_output_param)
+}
+
+inline const V0LayerParameter* V0LayerParameter::internal_default_instance() {
+ return &V0LayerParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// PReLUParameter
+
+// optional .caffe.FillerParameter filler = 1;
+inline bool PReLUParameter::has_filler() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void PReLUParameter::set_has_filler() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void PReLUParameter::clear_has_filler() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void PReLUParameter::clear_filler() {
+ if (filler_ != NULL) filler_->::caffe::FillerParameter::Clear();
+ clear_has_filler();
+}
+inline const ::caffe::FillerParameter& PReLUParameter::filler() const {
+ // @@protoc_insertion_point(field_get:caffe.PReLUParameter.filler)
+ return filler_ != NULL ? *filler_
+ : *::caffe::FillerParameter::internal_default_instance();
+}
+inline ::caffe::FillerParameter* PReLUParameter::mutable_filler() {
+ set_has_filler();
+ if (filler_ == NULL) {
+ filler_ = new ::caffe::FillerParameter;
+ }
+ // @@protoc_insertion_point(field_mutable:caffe.PReLUParameter.filler)
+ return filler_;
+}
+inline ::caffe::FillerParameter* PReLUParameter::release_filler() {
+ // @@protoc_insertion_point(field_release:caffe.PReLUParameter.filler)
+ clear_has_filler();
+ ::caffe::FillerParameter* temp = filler_;
+ filler_ = NULL;
+ return temp;
+}
+inline void PReLUParameter::set_allocated_filler(::caffe::FillerParameter* filler) {
+ delete filler_;
+ filler_ = filler;
+ if (filler) {
+ set_has_filler();
+ } else {
+ clear_has_filler();
+ }
+ // @@protoc_insertion_point(field_set_allocated:caffe.PReLUParameter.filler)
+}
+
+// optional bool channel_shared = 2 [default = false];
+inline bool PReLUParameter::has_channel_shared() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void PReLUParameter::set_has_channel_shared() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void PReLUParameter::clear_has_channel_shared() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void PReLUParameter::clear_channel_shared() {
+ channel_shared_ = false;
+ clear_has_channel_shared();
+}
+inline bool PReLUParameter::channel_shared() const {
+ // @@protoc_insertion_point(field_get:caffe.PReLUParameter.channel_shared)
+ return channel_shared_;
+}
+inline void PReLUParameter::set_channel_shared(bool value) {
+ set_has_channel_shared();
+ channel_shared_ = value;
+ // @@protoc_insertion_point(field_set:caffe.PReLUParameter.channel_shared)
+}
+
+inline const PReLUParameter* PReLUParameter::internal_default_instance() {
+ return &PReLUParameter_default_instance_.get();
+}
+// -------------------------------------------------------------------
+
+// NormalizedBBox
+
+// optional float xmin = 1;
+inline bool NormalizedBBox::has_xmin() const {
+ return (_has_bits_[0] & 0x00000001u) != 0;
+}
+inline void NormalizedBBox::set_has_xmin() {
+ _has_bits_[0] |= 0x00000001u;
+}
+inline void NormalizedBBox::clear_has_xmin() {
+ _has_bits_[0] &= ~0x00000001u;
+}
+inline void NormalizedBBox::clear_xmin() {
+ xmin_ = 0;
+ clear_has_xmin();
+}
+inline float NormalizedBBox::xmin() const {
+ // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.xmin)
+ return xmin_;
+}
+inline void NormalizedBBox::set_xmin(float value) {
+ set_has_xmin();
+ xmin_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.xmin)
+}
+
+// optional float ymin = 2;
+inline bool NormalizedBBox::has_ymin() const {
+ return (_has_bits_[0] & 0x00000002u) != 0;
+}
+inline void NormalizedBBox::set_has_ymin() {
+ _has_bits_[0] |= 0x00000002u;
+}
+inline void NormalizedBBox::clear_has_ymin() {
+ _has_bits_[0] &= ~0x00000002u;
+}
+inline void NormalizedBBox::clear_ymin() {
+ ymin_ = 0;
+ clear_has_ymin();
+}
+inline float NormalizedBBox::ymin() const {
+ // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.ymin)
+ return ymin_;
+}
+inline void NormalizedBBox::set_ymin(float value) {
+ set_has_ymin();
+ ymin_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.ymin)
+}
+
+// optional float xmax = 3;
+inline bool NormalizedBBox::has_xmax() const {
+ return (_has_bits_[0] & 0x00000004u) != 0;
+}
+inline void NormalizedBBox::set_has_xmax() {
+ _has_bits_[0] |= 0x00000004u;
+}
+inline void NormalizedBBox::clear_has_xmax() {
+ _has_bits_[0] &= ~0x00000004u;
+}
+inline void NormalizedBBox::clear_xmax() {
+ xmax_ = 0;
+ clear_has_xmax();
+}
+inline float NormalizedBBox::xmax() const {
+ // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.xmax)
+ return xmax_;
+}
+inline void NormalizedBBox::set_xmax(float value) {
+ set_has_xmax();
+ xmax_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.xmax)
+}
+
+// optional float ymax = 4;
+inline bool NormalizedBBox::has_ymax() const {
+ return (_has_bits_[0] & 0x00000008u) != 0;
+}
+inline void NormalizedBBox::set_has_ymax() {
+ _has_bits_[0] |= 0x00000008u;
+}
+inline void NormalizedBBox::clear_has_ymax() {
+ _has_bits_[0] &= ~0x00000008u;
+}
+inline void NormalizedBBox::clear_ymax() {
+ ymax_ = 0;
+ clear_has_ymax();
+}
+inline float NormalizedBBox::ymax() const {
+ // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.ymax)
+ return ymax_;
+}
+inline void NormalizedBBox::set_ymax(float value) {
+ set_has_ymax();
+ ymax_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.ymax)
+}
+
+// optional int32 label = 5;
+inline bool NormalizedBBox::has_label() const {
+ return (_has_bits_[0] & 0x00000010u) != 0;
+}
+inline void NormalizedBBox::set_has_label() {
+ _has_bits_[0] |= 0x00000010u;
+}
+inline void NormalizedBBox::clear_has_label() {
+ _has_bits_[0] &= ~0x00000010u;
+}
+inline void NormalizedBBox::clear_label() {
+ label_ = 0;
+ clear_has_label();
+}
+inline ::google::protobuf::int32 NormalizedBBox::label() const {
+ // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.label)
+ return label_;
+}
+inline void NormalizedBBox::set_label(::google::protobuf::int32 value) {
+ set_has_label();
+ label_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.label)
+}
+
+// optional bool difficult = 6;
+inline bool NormalizedBBox::has_difficult() const {
+ return (_has_bits_[0] & 0x00000020u) != 0;
+}
+inline void NormalizedBBox::set_has_difficult() {
+ _has_bits_[0] |= 0x00000020u;
+}
+inline void NormalizedBBox::clear_has_difficult() {
+ _has_bits_[0] &= ~0x00000020u;
+}
+inline void NormalizedBBox::clear_difficult() {
+ difficult_ = false;
+ clear_has_difficult();
+}
+inline bool NormalizedBBox::difficult() const {
+ // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.difficult)
+ return difficult_;
+}
+inline void NormalizedBBox::set_difficult(bool value) {
+ set_has_difficult();
+ difficult_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.difficult)
+}
+
+// optional float score = 7;
+inline bool NormalizedBBox::has_score() const {
+ return (_has_bits_[0] & 0x00000040u) != 0;
+}
+inline void NormalizedBBox::set_has_score() {
+ _has_bits_[0] |= 0x00000040u;
+}
+inline void NormalizedBBox::clear_has_score() {
+ _has_bits_[0] &= ~0x00000040u;
+}
+inline void NormalizedBBox::clear_score() {
+ score_ = 0;
+ clear_has_score();
+}
+inline float NormalizedBBox::score() const {
+ // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.score)
+ return score_;
+}
+inline void NormalizedBBox::set_score(float value) {
+ set_has_score();
+ score_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.score)
+}
+
+// optional float size = 8;
+inline bool NormalizedBBox::has_size() const {
+ return (_has_bits_[0] & 0x00000080u) != 0;
+}
+inline void NormalizedBBox::set_has_size() {
+ _has_bits_[0] |= 0x00000080u;
+}
+inline void NormalizedBBox::clear_has_size() {
+ _has_bits_[0] &= ~0x00000080u;
+}
+inline void NormalizedBBox::clear_size() {
+ size_ = 0;
+ clear_has_size();
+}
+inline float NormalizedBBox::size() const {
+ // @@protoc_insertion_point(field_get:caffe.NormalizedBBox.size)
+ return size_;
+}
+inline void NormalizedBBox::set_size(float value) {
+ set_has_size();
+ size_ = value;
+ // @@protoc_insertion_point(field_set:caffe.NormalizedBBox.size)
+}
+
+inline const NormalizedBBox* NormalizedBBox::internal_default_instance() {
+ return &NormalizedBBox_default_instance_.get();
+}
+#endif // !PROTOBUF_INLINE_NOT_IN_HEADERS
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
+
+// @@protoc_insertion_point(namespace_scope)
+
+} // namespace caffe
+
+#ifndef SWIG
+namespace google {
+namespace protobuf {
+
+template <> struct is_proto_enum< ::caffe::PriorBoxParameter_CodeType> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::PriorBoxParameter_CodeType>() {
+ return ::caffe::PriorBoxParameter_CodeType_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::FillerParameter_VarianceNorm> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::FillerParameter_VarianceNorm>() {
+ return ::caffe::FillerParameter_VarianceNorm_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::SolverParameter_SnapshotFormat> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::SolverParameter_SnapshotFormat>() {
+ return ::caffe::SolverParameter_SnapshotFormat_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::SolverParameter_SolverMode> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::SolverParameter_SolverMode>() {
+ return ::caffe::SolverParameter_SolverMode_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::SolverParameter_SolverType> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::SolverParameter_SolverType>() {
+ return ::caffe::SolverParameter_SolverType_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::ParamSpec_DimCheckMode> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::ParamSpec_DimCheckMode>() {
+ return ::caffe::ParamSpec_DimCheckMode_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::LossParameter_NormalizationMode> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::LossParameter_NormalizationMode>() {
+ return ::caffe::LossParameter_NormalizationMode_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::ConvolutionParameter_Engine> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::ConvolutionParameter_Engine>() {
+ return ::caffe::ConvolutionParameter_Engine_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::DataParameter_DB> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::DataParameter_DB>() {
+ return ::caffe::DataParameter_DB_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::EltwiseParameter_EltwiseOp> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::EltwiseParameter_EltwiseOp>() {
+ return ::caffe::EltwiseParameter_EltwiseOp_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::HingeLossParameter_Norm> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::HingeLossParameter_Norm>() {
+ return ::caffe::HingeLossParameter_Norm_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::LRNParameter_NormRegion> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::LRNParameter_NormRegion>() {
+ return ::caffe::LRNParameter_NormRegion_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::LRNParameter_Engine> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::LRNParameter_Engine>() {
+ return ::caffe::LRNParameter_Engine_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::PoolingParameter_PoolMethod> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::PoolingParameter_PoolMethod>() {
+ return ::caffe::PoolingParameter_PoolMethod_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::PoolingParameter_Engine> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::PoolingParameter_Engine>() {
+ return ::caffe::PoolingParameter_Engine_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::ReductionParameter_ReductionOp> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::ReductionParameter_ReductionOp>() {
+ return ::caffe::ReductionParameter_ReductionOp_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::ReLUParameter_Engine> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::ReLUParameter_Engine>() {
+ return ::caffe::ReLUParameter_Engine_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::SigmoidParameter_Engine> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::SigmoidParameter_Engine>() {
+ return ::caffe::SigmoidParameter_Engine_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::SoftmaxParameter_Engine> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::SoftmaxParameter_Engine>() {
+ return ::caffe::SoftmaxParameter_Engine_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::TanHParameter_Engine> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::TanHParameter_Engine>() {
+ return ::caffe::TanHParameter_Engine_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::SPPParameter_PoolMethod> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::SPPParameter_PoolMethod>() {
+ return ::caffe::SPPParameter_PoolMethod_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::SPPParameter_Engine> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::SPPParameter_Engine>() {
+ return ::caffe::SPPParameter_Engine_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::V1LayerParameter_LayerType> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::V1LayerParameter_LayerType>() {
+ return ::caffe::V1LayerParameter_LayerType_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::V1LayerParameter_DimCheckMode> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::V1LayerParameter_DimCheckMode>() {
+ return ::caffe::V1LayerParameter_DimCheckMode_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::V0LayerParameter_PoolMethod> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::V0LayerParameter_PoolMethod>() {
+ return ::caffe::V0LayerParameter_PoolMethod_descriptor();
+}
+template <> struct is_proto_enum< ::caffe::Phase> : ::google::protobuf::internal::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::caffe::Phase>() {
+ return ::caffe::Phase_descriptor();
+}
+
+} // namespace protobuf
+} // namespace google
+#endif // SWIG
+
+// @@protoc_insertion_point(global_scope)
+
+#endif // PROTOBUF_caffe_2eproto__INCLUDED
diff --git a/modules/dnn/misc/java/filelist_common b/modules/dnn/misc/java/filelist_common
new file mode 100644
index 0000000..93b18b6
--- /dev/null
+++ b/modules/dnn/misc/java/filelist_common
@@ -0,0 +1 @@
+misc/java/src/cpp/dnn_converters.hpp
diff --git a/modules/dnn/misc/java/gen_dict.json b/modules/dnn/misc/java/gen_dict.json
new file mode 100644
index 0000000..c0e0a1b
--- /dev/null
+++ b/modules/dnn/misc/java/gen_dict.json
@@ -0,0 +1,55 @@
+{
+ "type_dict": {
+ "MatShape": {
+ "j_type": "MatOfInt",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "MatShape %(n)s",
+ "suffix": "J",
+ "v_type": "Mat",
+ "j_import": "org.opencv.core.MatOfInt"
+ },
+ "vector_MatShape": {
+ "j_type": "List<MatOfInt>",
+ "jn_type": "List<MatOfInt>",
+ "jni_type": "jobject",
+ "jni_var": "std::vector< MatShape > %(n)s",
+ "suffix": "Ljava_util_List",
+ "v_type": "vector_MatShape",
+ "j_import": "org.opencv.core.MatOfInt"
+ },
+ "vector_size_t": {
+ "j_type": "MatOfDouble",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "std::vector<size_t> %(n)s",
+ "suffix": "J",
+ "v_type": "Mat",
+ "j_import": "org.opencv.core.MatOfDouble"
+ },
+ "vector_Ptr_Layer": {
+ "j_type": "List<Layer>",
+ "jn_type": "List<Layer>",
+ "jni_type": "jobject",
+ "jni_var": "std::vector< Ptr<cv::dnn::Layer> > %(n)s",
+ "suffix": "Ljava_util_List",
+ "v_type": "vector_Layer",
+ "j_import": "org.opencv.dnn.Layer"
+ },
+ "LayerId": {
+ "j_type": "DictValue",
+ "jn_type": "long",
+ "jn_args": [
+ [
+ "__int64",
+ ".getNativeObjAddr()"
+ ]
+
+ ],
+ "jni_name": "(*(cv::dnn::DictValue*)%(n)s_nativeObj)",
+ "jni_type": "jlong",
+ "suffix": "J",
+ "j_import": "org.opencv.dnn.DictValue"
+ }
+ }
+}
diff --git a/modules/dnn/misc/java/src/cpp/dnn_converters.cpp b/modules/dnn/misc/java/src/cpp/dnn_converters.cpp
new file mode 100644
index 0000000..584bd57
--- /dev/null
+++ b/modules/dnn/misc/java/src/cpp/dnn_converters.cpp
@@ -0,0 +1,94 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+// Author: abratchik
+
+#include "dnn_converters.hpp"
+
+
+void Mat_to_MatShape(cv::Mat& mat, MatShape& matshape)
+{
+ matshape.clear();
+ CHECK_MAT(mat.type()==CV_32SC1 && mat.cols==1);
+ matshape = (MatShape) mat;
+}
+
+void MatShape_to_Mat(MatShape& matshape, cv::Mat& mat)
+{
+ mat = cv::Mat(matshape, true);
+}
+
+void Mat_to_vector_size_t(cv::Mat& mat, std::vector<size_t>& v_size_t)
+{
+ v_size_t.clear();
+ CHECK_MAT(mat.type()==CV_32SC1 && mat.cols==1);
+ v_size_t = (std::vector<size_t>) mat;
+}
+
+void vector_size_t_to_Mat(std::vector<size_t>& v_size_t, cv::Mat& mat)
+{
+ mat = cv::Mat(v_size_t, true);
+}
+
+std::vector<MatShape> List_to_vector_MatShape(JNIEnv* env, jobject list)
+{
+ static jclass juArrayList = ARRAYLIST(env);
+ jmethodID m_size = LIST_SIZE(env, juArrayList);
+ jmethodID m_get = LIST_GET(env, juArrayList);
+
+ static jclass jMatOfInt = MATOFINT(env);
+
+ jint len = env->CallIntMethod(list, m_size);
+ std::vector<MatShape> result;
+ result.reserve(len);
+ for (jint i=0; i<len; i++)
+ {
+ jobject element = static_cast<jobject>(env->CallObjectMethod(list, m_get, i));
+ cv::Mat& mat = *((cv::Mat*) GETNATIVEOBJ(env, jMatOfInt, element) );
+ MatShape matshape = (MatShape) mat;
+ result.push_back(matshape);
+ env->DeleteLocalRef(element);
+ }
+ return result;
+}
+
+jobject vector_Ptr_Layer_to_List(JNIEnv* env, std::vector<cv::Ptr<cv::dnn::Layer> >& vs)
+{
+ static jclass juArrayList = ARRAYLIST(env);
+ static jmethodID m_create = CONSTRUCTOR(env, juArrayList);
+ jmethodID m_add = LIST_ADD(env, juArrayList);
+
+ static jclass jLayerClass = LAYER(env);
+ static jmethodID m_create_layer = LAYER_CONSTRUCTOR(env, jLayerClass);
+
+ jobject result = env->NewObject(juArrayList, m_create, vs.size());
+ for (std::vector< cv::Ptr<cv::dnn::Layer> >::iterator it = vs.begin(); it != vs.end(); ++it) {
+ jobject element = env->NewObject(jLayerClass, m_create_layer, (*it).get());
+ env->CallBooleanMethod(result, m_add, element);
+ env->DeleteLocalRef(element);
+ }
+ return result;
+}
+
+std::vector<cv::Ptr<cv::dnn::Layer> > List_to_vector_Ptr_Layer(JNIEnv* env, jobject list)
+{
+ static jclass juArrayList = ARRAYLIST(env);
+ jmethodID m_size = LIST_SIZE(env, juArrayList);
+ jmethodID m_get = LIST_GET(env, juArrayList);
+
+ static jclass jLayerClass = LAYER(env);
+
+ jint len = env->CallIntMethod(list, m_size);
+ std::vector< cv::Ptr<cv::dnn::Layer> > result;
+ result.reserve(len);
+ for (jint i=0; i<len; i++)
+ {
+ jobject element = static_cast<jobject>(env->CallObjectMethod(list, m_get, i));
+ cv::Ptr<cv::dnn::Layer>* layer_ptr = (cv::Ptr<cv::dnn::Layer>*) GETNATIVEOBJ(env, jLayerClass, element) ;
+ cv::Ptr<cv::dnn::Layer> layer = *(layer_ptr);
+ result.push_back(layer);
+ env->DeleteLocalRef(element);
+ }
+ return result;
+}
diff --git a/modules/dnn/misc/java/src/cpp/dnn_converters.hpp b/modules/dnn/misc/java/src/cpp/dnn_converters.hpp
new file mode 100644
index 0000000..f590161
--- /dev/null
+++ b/modules/dnn/misc/java/src/cpp/dnn_converters.hpp
@@ -0,0 +1,36 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+// Author: abratchik
+
+#ifndef DNN_CONVERTERS_HPP
+#define DNN_CONVERTERS_HPP
+
+#include <jni.h>
+#include "opencv2/java.hpp"
+#include "opencv2/core.hpp"
+#include "opencv2/dnn/dnn.hpp"
+
+#define LAYER(ENV) static_cast<jclass>(ENV->NewGlobalRef(ENV->FindClass("org/opencv/dnn/Layer")))
+#define LAYER_CONSTRUCTOR(ENV, CLS) ENV->GetMethodID(CLS, "<init>", "(J)V")
+
+
+using namespace cv::dnn;
+
+void Mat_to_MatShape(cv::Mat& mat, MatShape& matshape);
+
+void MatShape_to_Mat(MatShape& matshape, cv::Mat& mat);
+
+void Mat_to_vector_size_t(cv::Mat& mat, std::vector<size_t>& v_size_t);
+
+void vector_size_t_to_Mat(std::vector<size_t>& v_size_t, cv::Mat& mat);
+
+std::vector<MatShape> List_to_vector_MatShape(JNIEnv* env, jobject list);
+
+jobject vector_Ptr_Layer_to_List(JNIEnv* env, std::vector<cv::Ptr<cv::dnn::Layer> >& vs);
+
+std::vector<cv::Ptr<cv::dnn::Layer> > List_to_vector_Ptr_Layer(JNIEnv* env, jobject list);
+
+
+#endif /* DNN_CONVERTERS_HPP */
diff --git a/modules/dnn/misc/java/test/DnnTensorFlowTest.java b/modules/dnn/misc/java/test/DnnTensorFlowTest.java
new file mode 100644
index 0000000..b4116e8
--- /dev/null
+++ b/modules/dnn/misc/java/test/DnnTensorFlowTest.java
@@ -0,0 +1,113 @@
+package org.opencv.test.dnn;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import org.opencv.core.Core;
+import org.opencv.core.Mat;
+import org.opencv.core.Scalar;
+import org.opencv.core.Size;
+import org.opencv.dnn.DictValue;
+import org.opencv.dnn.Dnn;
+import org.opencv.dnn.Importer;
+import org.opencv.dnn.Layer;
+import org.opencv.dnn.Net;
+import org.opencv.imgcodecs.Imgcodecs;
+import org.opencv.imgproc.Imgproc;
+import org.opencv.test.OpenCVTestCase;
+
+public class DnnTensorFlowTest extends OpenCVTestCase {
+
+ private final static String ENV_OPENCV_DNN_TEST_DATA_PATH = "OPENCV_DNN_TEST_DATA_PATH";
+
+ private final static String ENV_OPENCV_TEST_DATA_PATH = "OPENCV_TEST_DATA_PATH";
+
+ String modelFileName = "";
+ String sourceImageFile = "";
+
+ Net net;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ String envDnnTestDataPath = System.getenv(ENV_OPENCV_DNN_TEST_DATA_PATH);
+
+ if(envDnnTestDataPath == null){
+ isTestCaseEnabled = false;
+ return;
+ }
+
+ File dnnTestDataPath = new File(envDnnTestDataPath);
+ modelFileName = new File(dnnTestDataPath, "dnn/tensorflow_inception_graph.pb").toString();
+
+ String envTestDataPath = System.getenv(ENV_OPENCV_TEST_DATA_PATH);
+
+ if(envTestDataPath == null) throw new Exception(ENV_OPENCV_TEST_DATA_PATH + " has to be defined!");
+
+ File testDataPath = new File(envTestDataPath);
+
+ File f = new File(testDataPath, "dnn/space_shuttle.jpg");
+ sourceImageFile = f.toString();
+ if(!f.exists()) throw new Exception("Test image is missing: " + sourceImageFile);
+
+ net = new Net();
+ if(net.empty()) {
+ Importer importer = Dnn.createTensorflowImporter(modelFileName);
+ importer.populateNet(net);
+ }
+
+ }
+
+ public void testGetLayerTypes() {
+ List<String> layertypes = new ArrayList();
+ net.getLayerTypes(layertypes);
+
+ assertFalse("No layer types returned!", layertypes.isEmpty());
+ }
+
+ public void testGetLayer() {
+ List<String> layernames = net.getLayerNames();
+
+ assertFalse("Test net returned no layers!", layernames.isEmpty());
+
+ String testLayerName = layernames.get(0);
+
+ DictValue layerId = new DictValue(testLayerName);
+
+ assertEquals("DictValue did not return the string, which was used in constructor!", testLayerName, layerId.getStringValue());
+
+ Layer layer = net.getLayer(layerId);
+
+ assertEquals("Layer name does not match the expected value!", testLayerName, layer.get_name());
+
+ }
+
+ public void testTestNetForward() {
+ Mat rawImage = Imgcodecs.imread(sourceImageFile);
+
+ assertNotNull("Loading image from file failed!", rawImage);
+
+ Mat image = new Mat();
+ Imgproc.resize(rawImage, image, new Size(224,224));
+
+ Mat inputBlob = Dnn.blobFromImage(image);
+ assertNotNull("Converting image to blob failed!", inputBlob);
+
+ Mat inputBlobP = new Mat();
+ Core.subtract(inputBlob, new Scalar(117.0), inputBlobP);
+
+ net.setInput(inputBlobP, "input" );
+
+ Mat result = net.forward();
+
+ assertNotNull("Net returned no result!", result);
+
+ Core.MinMaxLocResult minmax = Core.minMaxLoc(result.reshape(1, 1));
+
+ assertTrue("No image recognized!", minmax.maxVal > 0.9);
+
+
+ }
+
+}
diff --git a/modules/dnn/misc/python/pyopencv_dnn.hpp b/modules/dnn/misc/python/pyopencv_dnn.hpp
new file mode 100644
index 0000000..312e5fc
--- /dev/null
+++ b/modules/dnn/misc/python/pyopencv_dnn.hpp
@@ -0,0 +1,39 @@
+#ifdef HAVE_OPENCV_DNN
+typedef dnn::DictValue LayerId;
+typedef std::vector<dnn::MatShape> vector_MatShape;
+typedef std::vector<std::vector<dnn::MatShape> > vector_vector_MatShape;
+typedef std::vector<size_t> vector_size_t;
+typedef std::vector<std::vector<Mat> > vector_vector_Mat;
+
+template<>
+bool pyopencv_to(PyObject *o, dnn::DictValue &dv, const char *name)
+{
+ (void)name;
+ if (!o || o == Py_None)
+ return true; //Current state will be used
+ else if (PyLong_Check(o))
+ {
+ dv = dnn::DictValue((int64)PyLong_AsLongLong(o));
+ return true;
+ }
+ else if (PyFloat_Check(o))
+ {
+ dv = dnn::DictValue(PyFloat_AS_DOUBLE(o));
+ return true;
+ }
+ else if (PyString_Check(o))
+ {
+ dv = dnn::DictValue(String(PyString_AsString(o)));
+ return true;
+ }
+ else
+ return false;
+}
+
+template<>
+bool pyopencv_to(PyObject *o, std::vector<Mat> &blobs, const char *name) //required for Layer::blobs RW
+{
+ return pyopencvVecConverter<Mat>::to(o, blobs, ArgInfo(name, false));
+}
+
+#endif
diff --git a/contrib/modules/dnn/misc/tensorflow/attr_value.pb.cc b/modules/dnn/misc/tensorflow/attr_value.pb.cc
similarity index 100%
rename from contrib/modules/dnn/misc/tensorflow/attr_value.pb.cc
rename to modules/dnn/misc/tensorflow/attr_value.pb.cc
diff --git a/contrib/modules/dnn/misc/tensorflow/attr_value.pb.h b/modules/dnn/misc/tensorflow/attr_value.pb.h
similarity index 100%
rename from contrib/modules/dnn/misc/tensorflow/attr_value.pb.h
rename to modules/dnn/misc/tensorflow/attr_value.pb.h
diff --git a/contrib/modules/dnn/misc/tensorflow/function.pb.cc b/modules/dnn/misc/tensorflow/function.pb.cc
similarity index 100%
rename from contrib/modules/dnn/misc/tensorflow/function.pb.cc
rename to modules/dnn/misc/tensorflow/function.pb.cc
diff --git a/contrib/modules/dnn/misc/tensorflow/function.pb.h b/modules/dnn/misc/tensorflow/function.pb.h
similarity index 100%
rename from contrib/modules/dnn/misc/tensorflow/function.pb.h
rename to modules/dnn/misc/tensorflow/function.pb.h
diff --git a/contrib/modules/dnn/misc/tensorflow/graph.pb.cc b/modules/dnn/misc/tensorflow/graph.pb.cc
similarity index 100%
rename from contrib/modules/dnn/misc/tensorflow/graph.pb.cc
rename to modules/dnn/misc/tensorflow/graph.pb.cc
diff --git a/contrib/modules/dnn/misc/tensorflow/graph.pb.h b/modules/dnn/misc/tensorflow/graph.pb.h
similarity index 100%
rename from contrib/modules/dnn/misc/tensorflow/graph.pb.h
rename to modules/dnn/misc/tensorflow/graph.pb.h
diff --git a/contrib/modules/dnn/misc/tensorflow/op_def.pb.cc b/modules/dnn/misc/tensorflow/op_def.pb.cc
similarity index 100%
rename from contrib/modules/dnn/misc/tensorflow/op_def.pb.cc
rename to modules/dnn/misc/tensorflow/op_def.pb.cc
diff --git a/contrib/modules/dnn/misc/tensorflow/op_def.pb.h b/modules/dnn/misc/tensorflow/op_def.pb.h
similarity index 100%
rename from contrib/modules/dnn/misc/tensorflow/op_def.pb.h
rename to modules/dnn/misc/tensorflow/op_def.pb.h
diff --git a/contrib/modules/dnn/misc/tensorflow/tensor.pb.cc b/modules/dnn/misc/tensorflow/tensor.pb.cc
similarity index 100%
rename from contrib/modules/dnn/misc/tensorflow/tensor.pb.cc
rename to modules/dnn/misc/tensorflow/tensor.pb.cc
diff --git a/contrib/modules/dnn/misc/tensorflow/tensor.pb.h b/modules/dnn/misc/tensorflow/tensor.pb.h
similarity index 100%
rename from contrib/modules/dnn/misc/tensorflow/tensor.pb.h
rename to modules/dnn/misc/tensorflow/tensor.pb.h
diff --git a/contrib/modules/dnn/misc/tensorflow/tensor_shape.pb.cc b/modules/dnn/misc/tensorflow/tensor_shape.pb.cc
similarity index 100%
rename from contrib/modules/dnn/misc/tensorflow/tensor_shape.pb.cc
rename to modules/dnn/misc/tensorflow/tensor_shape.pb.cc
diff --git a/contrib/modules/dnn/misc/tensorflow/tensor_shape.pb.h b/modules/dnn/misc/tensorflow/tensor_shape.pb.h
similarity index 100%
rename from contrib/modules/dnn/misc/tensorflow/tensor_shape.pb.h
rename to modules/dnn/misc/tensorflow/tensor_shape.pb.h
diff --git a/contrib/modules/dnn/misc/tensorflow/types.pb.cc b/modules/dnn/misc/tensorflow/types.pb.cc
similarity index 100%
rename from contrib/modules/dnn/misc/tensorflow/types.pb.cc
rename to modules/dnn/misc/tensorflow/types.pb.cc
diff --git a/contrib/modules/dnn/misc/tensorflow/types.pb.h b/modules/dnn/misc/tensorflow/types.pb.h
similarity index 100%
rename from contrib/modules/dnn/misc/tensorflow/types.pb.h
rename to modules/dnn/misc/tensorflow/types.pb.h
diff --git a/contrib/modules/dnn/misc/tensorflow/versions.pb.cc b/modules/dnn/misc/tensorflow/versions.pb.cc
similarity index 100%
rename from contrib/modules/dnn/misc/tensorflow/versions.pb.cc
rename to modules/dnn/misc/tensorflow/versions.pb.cc
diff --git a/contrib/modules/dnn/misc/tensorflow/versions.pb.h b/modules/dnn/misc/tensorflow/versions.pb.h
similarity index 100%
rename from contrib/modules/dnn/misc/tensorflow/versions.pb.h
rename to modules/dnn/misc/tensorflow/versions.pb.h
diff --git a/modules/dnn/perf/perf_convolution.cpp b/modules/dnn/perf/perf_convolution.cpp
new file mode 100644
index 0000000..502c5ef
--- /dev/null
+++ b/modules/dnn/perf/perf_convolution.cpp
@@ -0,0 +1,106 @@
+#include "perf_precomp.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cvtest
+{
+
+using std::tr1::tuple;
+using std::tr1::get;
+using std::tr1::make_tuple;
+using std::make_pair;
+using namespace perf;
+using namespace testing;
+using namespace cv;
+using namespace cv::dnn;
+
+enum {STRIDE_OFF = 1, STRIDE_ON = 2};
+CV_ENUM(StrideSize, STRIDE_OFF, STRIDE_ON);
+
+enum {GROUP_OFF = 1, GROUP_2 = 2};
+CV_ENUM(GroupSize, GROUP_OFF, GROUP_2);
+
+//Squared Size
+#define SSZ(n) cv::Size(n, n)
+
+typedef std::pair<MatShape, int> InpShapeNumOut;
+typedef tuple<Size, InpShapeNumOut, GroupSize, StrideSize> ConvParam; //kernel_size, inp shape, groups, stride
+typedef TestBaseWithParam<ConvParam> ConvolutionPerfTest;
+
+static inline MatShape blobShape(int count, int nplanes, int height, int width)
+{
+ int data[] = {count, nplanes, height, width};
+ return MatShape(data, data+4);
+}
+
+PERF_TEST_P( ConvolutionPerfTest, perf, Combine(
+ Values(Size(1, 1), Size(3, 3), Size(5, 5), Size(11, 11)),
+ Values(make_pair(blobShape(1, 4, 224, 224), 64),
+ make_pair(blobShape(1, 64, 112, 122), 128),
+ make_pair(blobShape(1, 256, 28, 28), 512)),
+ GroupSize::all(),
+ StrideSize::all())
+)
+{
+ RNG rng(0);
+
+ ConvParam params = GetParam();
+ int ksz = get<0>(params).width;
+ MatShape inpShape = get<1>(params).first;
+ int outCn = get<1>(params).second;
+ int groups = get<2>(params);
+ int stride = (ksz >= 11) ? 4 : (int)get<3>(params);
+
+ int inpCn = inpShape[1];
+ int wgtSize[] = { outCn, inpCn/groups, ksz, ksz };
+ int biasSize[] = { outCn, 1, 1, 1 };
+ const int wtype = CV_32F;
+ Mat wgtBlob(4, wgtSize, wtype), biasBlob(4, biasSize, wtype);
+ Mat inpBlob(4, &inpShape[0], wtype);
+ rng.fill(biasBlob, RNG::UNIFORM, -1, +1);
+ rng.fill(wgtBlob, RNG::UNIFORM, -1, +1);
+ rng.fill(inpBlob, RNG::UNIFORM, -1, +1);
+
+ LayerParams lp;
+ lp.set("num_output", outCn);
+ lp.set("group", groups);
+ lp.set("stride", stride);
+ lp.set("kernel_size", ksz);
+ lp.blobs.reserve(2);
+ lp.blobs.push_back(wgtBlob);
+ lp.blobs.push_back(biasBlob);
+
+ std::vector<Mat*> inpBlobs(1, &inpBlob);
+ std::vector<Mat> outBlobs, internalBlobs;
+
+ cv::setNumThreads(cv::getNumberOfCPUs());
+
+ Ptr<Layer> layer = cv::dnn::LayerFactory::createLayerInstance("Convolution", lp);
+ std::vector<MatShape> inputShapes(1, shape(inpBlob)), outShapes, internals;
+ layer->getMemoryShapes(inputShapes, 0, outShapes, internals);
+ for (int i = 0; i < outShapes.size(); i++)
+ {
+ outBlobs.push_back(Mat(outShapes[i], CV_32F));
+ }
+ for (int i = 0; i < internals.size(); i++)
+ {
+ internalBlobs.push_back(Mat());
+ if (total(internals[i]))
+ internalBlobs.back().create(internals[i], CV_32F);
+ }
+
+ layer->finalize(inpBlobs, outBlobs);
+
+ Mat inpBlob2D = inpBlob.reshape(1, outCn);
+ Mat wgtBlob2D = wgtBlob.reshape(1, outCn*(inpCn/groups));
+ Mat outBlob2D = outBlobs[0].reshape(1, outBlobs[0].size[0]);
+ declare.in(inpBlob2D, wgtBlob2D, WARMUP_RNG).out(outBlob2D).tbb_threads(cv::getNumThreads());
+
+ TEST_CYCLE_N(10)
+ {
+ layer->forward(inpBlobs, outBlobs, internalBlobs);
+ }
+
+ SANITY_CHECK_NOTHING();
+}
+
+}
diff --git a/modules/dnn/perf/perf_halide_net.cpp b/modules/dnn/perf/perf_halide_net.cpp
new file mode 100644
index 0000000..53bae9d
--- /dev/null
+++ b/modules/dnn/perf/perf_halide_net.cpp
@@ -0,0 +1,174 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+//
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+
+#include "perf_precomp.hpp"
+
+namespace cvtest
+{
+
+#ifdef HAVE_HALIDE
+using namespace cv;
+using namespace dnn;
+
+static void loadNet(std::string weights, std::string proto, std::string scheduler,
+ int inWidth, int inHeight, const std::string& outputLayer,
+ const std::string& framework, int targetId, Net* net)
+{
+ Mat input(inHeight, inWidth, CV_32FC3);
+ randu(input, 0.0f, 1.0f);
+
+ weights = findDataFile(weights, false);
+ if (!proto.empty())
+ proto = findDataFile(proto, false);
+ if (!scheduler.empty())
+ scheduler = findDataFile(scheduler, false);
+ if (framework == "caffe")
+ {
+ *net = cv::dnn::readNetFromCaffe(proto, weights);
+ }
+ else if (framework == "torch")
+ {
+ *net = cv::dnn::readNetFromTorch(weights);
+ }
+ else if (framework == "tensorflow")
+ {
+ *net = cv::dnn::readNetFromTensorflow(weights);
+ }
+ else
+ CV_Error(Error::StsNotImplemented, "Unknown framework " + framework);
+
+ net->setInput(blobFromImage(input, 1.0, Size(), Scalar(), false));
+ net->setPreferableBackend(DNN_BACKEND_HALIDE);
+ net->setPreferableTarget(targetId);
+ net->setHalideScheduler(scheduler);
+ net->forward(outputLayer);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// CPU target
+////////////////////////////////////////////////////////////////////////////////
+PERF_TEST(GoogLeNet, HalidePerfTest)
+{
+ Net net;
+ loadNet("dnn/bvlc_googlenet.caffemodel", "dnn/bvlc_googlenet.prototxt",
+ "", 227, 227, "prob", "caffe", DNN_TARGET_CPU, &net);
+ TEST_CYCLE() net.forward();
+ SANITY_CHECK_NOTHING();
+}
+
+PERF_TEST(AlexNet, HalidePerfTest)
+{
+ Net net;
+ loadNet("dnn/bvlc_alexnet.caffemodel", "dnn/bvlc_alexnet.prototxt",
+ "dnn/halide_scheduler_alexnet.yml", 227, 227, "prob", "caffe",
+ DNN_TARGET_CPU, &net);
+ TEST_CYCLE() net.forward();
+ SANITY_CHECK_NOTHING();
+}
+
+PERF_TEST(ResNet50, HalidePerfTest)
+{
+ Net net;
+ loadNet("dnn/ResNet-50-model.caffemodel", "dnn/ResNet-50-deploy.prototxt",
+ "dnn/halide_scheduler_resnet_50.yml", 224, 224, "prob", "caffe",
+ DNN_TARGET_CPU, &net);
+ TEST_CYCLE() net.forward();
+ SANITY_CHECK_NOTHING();
+}
+
+PERF_TEST(SqueezeNet_v1_1, HalidePerfTest)
+{
+ Net net;
+ loadNet("dnn/squeezenet_v1.1.caffemodel", "dnn/squeezenet_v1.1.prototxt",
+ "dnn/halide_scheduler_squeezenet_v1_1.yml", 227, 227, "prob",
+ "caffe", DNN_TARGET_CPU, &net);
+ TEST_CYCLE() net.forward();
+ SANITY_CHECK_NOTHING();
+}
+
+PERF_TEST(Inception_5h, HalidePerfTest)
+{
+ Net net;
+ loadNet("dnn/tensorflow_inception_graph.pb", "",
+ "dnn/halide_scheduler_inception_5h.yml",
+ 224, 224, "softmax2", "tensorflow", DNN_TARGET_CPU, &net);
+ TEST_CYCLE() net.forward("softmax2");
+ SANITY_CHECK_NOTHING();
+}
+
+PERF_TEST(ENet, HalidePerfTest)
+{
+ Net net;
+ loadNet("dnn/Enet-model-best.net", "", "dnn/halide_scheduler_enet.yml",
+ 512, 256, "l367_Deconvolution", "torch", DNN_TARGET_CPU, &net);
+ TEST_CYCLE() net.forward();
+ SANITY_CHECK_NOTHING();
+}
+////////////////////////////////////////////////////////////////////////////////
+// OpenCL target
+////////////////////////////////////////////////////////////////////////////////
+PERF_TEST(GoogLeNet_opencl, HalidePerfTest)
+{
+ Net net;
+ loadNet("dnn/bvlc_googlenet.caffemodel", "dnn/bvlc_googlenet.prototxt",
+ "", 227, 227, "prob", "caffe", DNN_TARGET_OPENCL, &net);
+ TEST_CYCLE() net.forward();
+ SANITY_CHECK_NOTHING();
+}
+
+PERF_TEST(AlexNet_opencl, HalidePerfTest)
+{
+ Net net;
+ loadNet("dnn/bvlc_alexnet.caffemodel", "dnn/bvlc_alexnet.prototxt",
+ "dnn/halide_scheduler_opencl_alexnet.yml", 227, 227, "prob", "caffe",
+ DNN_TARGET_OPENCL, &net);
+ TEST_CYCLE() net.forward();
+ SANITY_CHECK_NOTHING();
+}
+
+PERF_TEST(ResNet50_opencl, HalidePerfTest)
+{
+ Net net;
+ loadNet("dnn/ResNet-50-model.caffemodel", "dnn/ResNet-50-deploy.prototxt",
+ "dnn/halide_scheduler_opencl_resnet_50.yml", 224, 224, "prob", "caffe",
+ DNN_TARGET_OPENCL, &net);
+ TEST_CYCLE() net.forward();
+ SANITY_CHECK_NOTHING();
+}
+
+
+PERF_TEST(SqueezeNet_v1_1_opencl, HalidePerfTest)
+{
+ Net net;
+ loadNet("dnn/squeezenet_v1.1.caffemodel", "dnn/squeezenet_v1.1.prototxt",
+ "dnn/halide_scheduler_opencl_squeezenet_v1_1.yml", 227, 227, "prob",
+ "caffe", DNN_TARGET_OPENCL, &net);
+ TEST_CYCLE() net.forward();
+ SANITY_CHECK_NOTHING();
+}
+
+PERF_TEST(Inception_5h_opencl, HalidePerfTest)
+{
+ Net net;
+ loadNet("dnn/tensorflow_inception_graph.pb", "",
+ "dnn/halide_scheduler_opencl_inception_5h.yml",
+ 224, 224, "softmax2", "tensorflow", DNN_TARGET_OPENCL, &net);
+ TEST_CYCLE() net.forward("softmax2");
+ SANITY_CHECK_NOTHING();
+}
+
+PERF_TEST(ENet_opencl, HalidePerfTest)
+{
+ Net net;
+ loadNet("dnn/Enet-model-best.net", "", "dnn/halide_scheduler_opencl_enet.yml",
+ 512, 256, "l367_Deconvolution", "torch", DNN_TARGET_OPENCL, &net);
+ TEST_CYCLE() net.forward();
+ SANITY_CHECK_NOTHING();
+}
+#endif // HAVE_HALIDE
+
+} // namespace cvtest
diff --git a/modules/dnn/perf/perf_main.cpp b/modules/dnn/perf/perf_main.cpp
new file mode 100644
index 0000000..d66f19c
--- /dev/null
+++ b/modules/dnn/perf/perf_main.cpp
@@ -0,0 +1,12 @@
+#include "perf_precomp.hpp"
+
+static const char* extraTestDataPath =
+#ifdef WINRT
+ NULL;
+#else
+ getenv("OPENCV_DNN_TEST_DATA_PATH");
+#endif
+
+CV_PERF_TEST_MAIN(dnn,
+ extraTestDataPath ? (void)cvtest::addDataSearchPath(extraTestDataPath) : (void)0
+)
diff --git a/contrib/modules/dnn/perf/perf_precomp.hpp b/modules/dnn/perf/perf_precomp.hpp
similarity index 100%
rename from contrib/modules/dnn/perf/perf_precomp.hpp
rename to modules/dnn/perf/perf_precomp.hpp
diff --git a/modules/dnn/src/caffe/caffe.proto b/modules/dnn/src/caffe/caffe.proto
new file mode 100644
index 0000000..3d23fb4
--- /dev/null
+++ b/modules/dnn/src/caffe/caffe.proto
@@ -0,0 +1,1581 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//COPYRIGHT
+//
+//All contributions by the University of California:
+//Copyright (c) 2014, The Regents of the University of California (Regents)
+//All rights reserved.
+//
+//All other contributions:
+//Copyright (c) 2014, the respective contributors
+//All rights reserved.
+//
+//Caffe uses a shared copyright model: each contributor holds copyright over
+//their contributions to Caffe. The project versioning records all such
+//contribution and copyright details. If a contributor wants to further mark
+//their specific copyright on a particular contribution, they should indicate
+//their copyright solely in the commit message of the change when it is
+//committed.
+//
+//LICENSE
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions are met:
+//
+//1. Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+//ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+//DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+//ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+//(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+//ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+//(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+//CONTRIBUTION AGREEMENT
+//
+//By contributing to the BVLC/caffe repository through pull-request, comment,
+//or otherwise, the contributor releases their content to the
+//license and copyright terms herein.
+//
+//M*/
+
+syntax = "proto2";
+
+package caffe;
+
+// Specifies the shape (dimensions) of a Blob.
+message BlobShape {
+ repeated int64 dim = 1 [packed = true];
+}
+
+message BlobProto {
+ optional BlobShape shape = 7;
+ repeated float data = 5 [packed = true];
+ repeated float diff = 6 [packed = true];
+ repeated double double_data = 8 [packed = true];
+ repeated double double_diff = 9 [packed = true];
+
+ // 4D dimensions -- deprecated. Use "shape" instead.
+ optional int32 num = 1 [default = 0];
+ optional int32 channels = 2 [default = 0];
+ optional int32 height = 3 [default = 0];
+ optional int32 width = 4 [default = 0];
+}
+
+// The BlobProtoVector is simply a way to pass multiple blobproto instances
+// around.
+message BlobProtoVector {
+ repeated BlobProto blobs = 1;
+}
+
+message PermuteParameter {
+ // The new orders of the axes of data. Notice it should be with
+ // in the same range as the input data, and it starts from 0.
+ // Do not provide repeated order.
+ repeated uint32 order = 1;
+}
+
+// Message that stores parameters used by NormalizeBBoxLayer
+message NormalizeBBoxParameter {
+ optional bool across_spatial = 1 [default = true];
+ // Initial value of scale. Default is 1.0 for all
+ optional FillerParameter scale_filler = 2;
+ // Whether or not scale parameters are shared across channels.
+ optional bool channel_shared = 3 [default = true];
+ // Epsilon for not dividing by zero while normalizing variance
+ optional float eps = 4 [default = 1e-10];
+}
+
+// Message that store parameters used by PriorBoxLayer
+message PriorBoxParameter {
+ // Encode/decode type.
+ enum CodeType {
+ CORNER = 1;
+ CENTER_SIZE = 2;
+ }
+ // Minimum box size (in pixels). Required!
+ optional float min_size = 1;
+ // Maximum box size (in pixels). Required!
+ optional float max_size = 2;
+ // Various of aspect ratios. Duplicate ratios will be ignored.
+ // If none is provided, we use default ratio 1.
+ repeated float aspect_ratio = 3;
+ // If true, will flip each aspect ratio.
+ // For example, if there is aspect ratio "r",
+ // we will generate aspect ratio "1.0/r" as well.
+ optional bool flip = 4 [default = true];
+ // If true, will clip the prior so that it is within [0, 1]
+ optional bool clip = 5 [default = true];
+ // Variance for adjusting the prior bboxes.
+ repeated float variance = 6;
+ // By default, we calculate img_height, img_width, step_x, step_y based on
+ // bottom[0] (feat) and bottom[1] (img). Unless these values are explicitely
+ // provided.
+ // Explicitly provide the img_size.
+ optional uint32 img_size = 7;
+ // Either img_size or img_h/img_w should be specified; not both.
+ optional uint32 img_h = 8;
+ optional uint32 img_w = 9;
+ // Explicitly provide the step size.
+ optional float step = 10;
+ // Either step or step_h/step_w should be specified; not both.
+ optional float step_h = 11;
+ optional float step_w = 12;
+ // Offset to the top left corner of each cell.
+ optional float offset = 13 [default = 0.5];
+}
+
+// Message that store parameters used by DetectionOutputLayer
+message DetectionOutputParameter {
+ // Number of classes to be predicted. Required!
+ optional uint32 num_classes = 1;
+ // If true, bounding box are shared among different classes.
+ optional bool share_location = 2 [default = true];
+ // Background label id. If there is no background class,
+ // set it as -1.
+ optional int32 background_label_id = 3 [default = 0];
+ // Parameters used for non maximum suppression.
+ optional NonMaximumSuppressionParameter nms_param = 4;
+ // Parameters used for saving detection results.
+ optional SaveOutputParameter save_output_param = 5;
+ // Type of coding method for bbox.
+ optional PriorBoxParameter.CodeType code_type = 6 [default = CORNER];
+ // If true, variance is encoded in target; otherwise we need to adjust the
+ // predicted offset accordingly.
+ optional bool variance_encoded_in_target = 8 [default = false];
+ // Number of total bboxes to be kept per image after nms step.
+ // -1 means keeping all bboxes after nms step.
+ optional int32 keep_top_k = 7 [default = -1];
+ // Only consider detections whose confidences are larger than a threshold.
+ // If not provided, consider all boxes.
+ optional float confidence_threshold = 9;
+}
+
+message Datum {
+ optional int32 channels = 1;
+ optional int32 height = 2;
+ optional int32 width = 3;
+ // the actual image data, in bytes
+ optional bytes data = 4;
+ optional int32 label = 5;
+ // Optionally, the datum could also hold float data.
+ repeated float float_data = 6;
+ // If true data contains an encoded image that need to be decoded
+ optional bool encoded = 7 [default = false];
+}
+
+message FillerParameter {
+ // The filler type.
+ optional string type = 1 [default = 'constant'];
+ optional float value = 2 [default = 0]; // the value in constant filler
+ optional float min = 3 [default = 0]; // the min value in uniform filler
+ optional float max = 4 [default = 1]; // the max value in uniform filler
+ optional float mean = 5 [default = 0]; // the mean value in Gaussian filler
+ optional float std = 6 [default = 1]; // the std value in Gaussian filler
+ // The expected number of non-zero output weights for a given input in
+ // Gaussian filler -- the default -1 means don't perform sparsification.
+ optional int32 sparse = 7 [default = -1];
+ // Normalize the filler variance by fan_in, fan_out, or their average.
+ // Applies to 'xavier' and 'msra' fillers.
+ enum VarianceNorm {
+ FAN_IN = 0;
+ FAN_OUT = 1;
+ AVERAGE = 2;
+ }
+ optional VarianceNorm variance_norm = 8 [default = FAN_IN];
+}
+
+message NetParameter {
+ optional string name = 1; // consider giving the network a name
+ // DEPRECATED. See InputParameter. The input blobs to the network.
+ repeated string input = 3;
+ // DEPRECATED. See InputParameter. The shape of the input blobs.
+ repeated BlobShape input_shape = 8;
+
+ // 4D input dimensions -- deprecated. Use "input_shape" instead.
+ // If specified, for each input blob there should be four
+ // values specifying the num, channels, height and width of the input blob.
+ // Thus, there should be a total of (4 * #input) numbers.
+ repeated int32 input_dim = 4;
+
+ // Whether the network will force every layer to carry out backward operation.
+ // If set False, then whether to carry out backward is determined
+ // automatically according to the net structure and learning rates.
+ optional bool force_backward = 5 [default = false];
+ // The current "state" of the network, including the phase, level, and stage.
+ // Some layers may be included/excluded depending on this state and the states
+ // specified in the layers' include and exclude fields.
+ optional NetState state = 6;
+
+ // Print debugging information about results while running Net::Forward,
+ // Net::Backward, and Net::Update.
+ optional bool debug_info = 7 [default = false];
+
+ // The layers that make up the net. Each of their configurations, including
+ // connectivity and behavior, is specified as a LayerParameter.
+ repeated LayerParameter layer = 100; // ID 100 so layers are printed last.
+
+ // DEPRECATED: use 'layer' instead.
+ repeated V1LayerParameter layers = 2;
+}
+
+// NOTE
+// Update the next available ID when you add a new SolverParameter field.
+//
+// SolverParameter next available ID: 41 (last added: type)
+message SolverParameter {
+ //////////////////////////////////////////////////////////////////////////////
+ // Specifying the train and test networks
+ //
+ // Exactly one train net must be specified using one of the following fields:
+ // train_net_param, train_net, net_param, net
+ // One or more test nets may be specified using any of the following fields:
+ // test_net_param, test_net, net_param, net
+ // If more than one test net field is specified (e.g., both net and
+ // test_net are specified), they will be evaluated in the field order given
+ // above: (1) test_net_param, (2) test_net, (3) net_param/net.
+ // A test_iter must be specified for each test_net.
+ // A test_level and/or a test_stage may also be specified for each test_net.
+ //////////////////////////////////////////////////////////////////////////////
+
+ // Proto filename for the train net, possibly combined with one or more
+ // test nets.
+ optional string net = 24;
+ // Inline train net param, possibly combined with one or more test nets.
+ optional NetParameter net_param = 25;
+
+ optional string train_net = 1; // Proto filename for the train net.
+ repeated string test_net = 2; // Proto filenames for the test nets.
+ optional NetParameter train_net_param = 21; // Inline train net params.
+ repeated NetParameter test_net_param = 22; // Inline test net params.
+
+ // The states for the train/test nets. Must be unspecified or
+ // specified once per net.
+ //
+ // By default, all states will have solver = true;
+ // train_state will have phase = TRAIN,
+ // and all test_state's will have phase = TEST.
+ // Other defaults are set according to the NetState defaults.
+ optional NetState train_state = 26;
+ repeated NetState test_state = 27;
+
+ // The number of iterations for each test net.
+ repeated int32 test_iter = 3;
+
+ // The number of iterations between two testing phases.
+ optional int32 test_interval = 4 [default = 0];
+ optional bool test_compute_loss = 19 [default = false];
+ // If true, run an initial test pass before the first iteration,
+ // ensuring memory availability and printing the starting value of the loss.
+ optional bool test_initialization = 32 [default = true];
+ optional float base_lr = 5; // The base learning rate
+ // the number of iterations between displaying info. If display = 0, no info
+ // will be displayed.
+ optional int32 display = 6;
+ // Display the loss averaged over the last average_loss iterations
+ optional int32 average_loss = 33 [default = 1];
+ optional int32 max_iter = 7; // the maximum number of iterations
+ // accumulate gradients over `iter_size` x `batch_size` instances
+ optional int32 iter_size = 36 [default = 1];
+
+ // The learning rate decay policy. The currently implemented learning rate
+ // policies are as follows:
+ // - fixed: always return base_lr.
+ // - step: return base_lr * gamma ^ (floor(iter / step))
+ // - exp: return base_lr * gamma ^ iter
+ // - inv: return base_lr * (1 + gamma * iter) ^ (- power)
+ // - multistep: similar to step but it allows non uniform steps defined by
+ // stepvalue
+ // - poly: the effective learning rate follows a polynomial decay, to be
+ // zero by the max_iter. return base_lr (1 - iter/max_iter) ^ (power)
+ // - sigmoid: the effective learning rate follows a sigmod decay
+ // return base_lr ( 1/(1 + exp(-gamma * (iter - stepsize))))
+ //
+ // where base_lr, max_iter, gamma, step, stepvalue and power are defined
+ // in the solver parameter protocol buffer, and iter is the current iteration.
+ optional string lr_policy = 8;
+ optional float gamma = 9; // The parameter to compute the learning rate.
+ optional float power = 10; // The parameter to compute the learning rate.
+ optional float momentum = 11; // The momentum value.
+ optional float weight_decay = 12; // The weight decay.
+ // regularization types supported: L1 and L2
+ // controlled by weight_decay
+ optional string regularization_type = 29 [default = "L2"];
+ // the stepsize for learning rate policy "step"
+ optional int32 stepsize = 13;
+ // the stepsize for learning rate policy "multistep"
+ repeated int32 stepvalue = 34;
+
+ // Set clip_gradients to >= 0 to clip parameter gradients to that L2 norm,
+ // whenever their actual L2 norm is larger.
+ optional float clip_gradients = 35 [default = -1];
+
+ optional int32 snapshot = 14 [default = 0]; // The snapshot interval
+ optional string snapshot_prefix = 15; // The prefix for the snapshot.
+ // whether to snapshot diff in the results or not. Snapshotting diff will help
+ // debugging but the final protocol buffer size will be much larger.
+ optional bool snapshot_diff = 16 [default = false];
+ enum SnapshotFormat {
+ HDF5 = 0;
+ BINARYPROTO = 1;
+ }
+ optional SnapshotFormat snapshot_format = 37 [default = BINARYPROTO];
+ // the mode solver will use: 0 for CPU and 1 for GPU. Use GPU in default.
+ enum SolverMode {
+ CPU = 0;
+ GPU = 1;
+ }
+ optional SolverMode solver_mode = 17 [default = GPU];
+ // the device_id will that be used in GPU mode. Use device_id = 0 in default.
+ optional int32 device_id = 18 [default = 0];
+ // If non-negative, the seed with which the Solver will initialize the Caffe
+ // random number generator -- useful for reproducible results. Otherwise,
+ // (and by default) initialize using a seed derived from the system clock.
+ optional int64 random_seed = 20 [default = -1];
+
+ // type of the solver
+ optional string type = 40 [default = "SGD"];
+
+ // numerical stability for RMSProp, AdaGrad and AdaDelta and Adam
+ optional float delta = 31 [default = 1e-8];
+ // parameters for the Adam solver
+ optional float momentum2 = 39 [default = 0.999];
+
+ // RMSProp decay value
+ // MeanSquare(t) = rms_decay*MeanSquare(t-1) + (1-rms_decay)*SquareGradient(t)
+ optional float rms_decay = 38 [default = 0.99];
+
+ // If true, print information about the state of the net that may help with
+ // debugging learning problems.
+ optional bool debug_info = 23 [default = false];
+
+ // If false, don't save a snapshot after training finishes.
+ optional bool snapshot_after_train = 28 [default = true];
+
+ // DEPRECATED: old solver enum types, use string instead
+ enum SolverType {
+ SGD = 0;
+ NESTEROV = 1;
+ ADAGRAD = 2;
+ RMSPROP = 3;
+ ADADELTA = 4;
+ ADAM = 5;
+ }
+ // DEPRECATED: use type instead of solver_type
+ optional SolverType solver_type = 30 [default = SGD];
+}
+
+// A message that stores the solver snapshots
+message SolverState {
+ optional int32 iter = 1; // The current iteration
+ optional string learned_net = 2; // The file that stores the learned net.
+ repeated BlobProto history = 3; // The history for sgd solvers
+ optional int32 current_step = 4 [default = 0]; // The current step for learning rate
+}
+
+enum Phase {
+ TRAIN = 0;
+ TEST = 1;
+}
+
+message NetState {
+ optional Phase phase = 1 [default = TEST];
+ optional int32 level = 2 [default = 0];
+ repeated string stage = 3;
+}
+
+message NetStateRule {
+ // Set phase to require the NetState have a particular phase (TRAIN or TEST)
+ // to meet this rule.
+ optional Phase phase = 1;
+
+ // Set the minimum and/or maximum levels in which the layer should be used.
+ // Leave undefined to meet the rule regardless of level.
+ optional int32 min_level = 2;
+ optional int32 max_level = 3;
+
+ // Customizable sets of stages to include or exclude.
+ // The net must have ALL of the specified stages and NONE of the specified
+ // "not_stage"s to meet the rule.
+ // (Use multiple NetStateRules to specify conjunctions of stages.)
+ repeated string stage = 4;
+ repeated string not_stage = 5;
+}
+
+// Specifies training parameters (multipliers on global learning constants,
+// and the name and other settings used for weight sharing).
+message ParamSpec {
+ // The names of the parameter blobs -- useful for sharing parameters among
+ // layers, but never required otherwise. To share a parameter between two
+ // layers, give it a (non-empty) name.
+ optional string name = 1;
+
+ // Whether to require shared weights to have the same shape, or just the same
+ // count -- defaults to STRICT if unspecified.
+ optional DimCheckMode share_mode = 2;
+ enum DimCheckMode {
+ // STRICT (default) requires that num, channels, height, width each match.
+ STRICT = 0;
+ // PERMISSIVE requires only the count (num*channels*height*width) to match.
+ PERMISSIVE = 1;
+ }
+
+ // The multiplier on the global learning rate for this parameter.
+ optional float lr_mult = 3 [default = 1.0];
+
+ // The multiplier on the global weight decay for this parameter.
+ optional float decay_mult = 4 [default = 1.0];
+}
+
+// NOTE
+// Update the next available ID when you add a new LayerParameter field.
+//
+// LayerParameter next available layer-specific ID: 147 (last added: recurrent_param)
+message LayerParameter {
+ optional string name = 1; // the layer name
+ optional string type = 2; // the layer type
+ repeated string bottom = 3; // the name of each bottom blob
+ repeated string top = 4; // the name of each top blob
+
+ // The train / test phase for computation.
+ optional Phase phase = 10;
+
+ // The amount of weight to assign each top blob in the objective.
+ // Each layer assigns a default value, usually of either 0 or 1,
+ // to each top blob.
+ repeated float loss_weight = 5;
+
+ // Specifies training parameters (multipliers on global learning constants,
+ // and the name and other settings used for weight sharing).
+ repeated ParamSpec param = 6;
+
+ // The blobs containing the numeric parameters of the layer.
+ repeated BlobProto blobs = 7;
+
+ // Specifies whether to backpropagate to each bottom. If unspecified,
+ // Caffe will automatically infer whether each input needs backpropagation
+ // to compute parameter gradients. If set to true for some inputs,
+ // backpropagation to those inputs is forced; if set false for some inputs,
+ // backpropagation to those inputs is skipped.
+ //
+ // The size must be either 0 or equal to the number of bottoms.
+ repeated bool propagate_down = 11;
+
+ // Rules controlling whether and when a layer is included in the network,
+ // based on the current NetState. You may specify a non-zero number of rules
+ // to include OR exclude, but not both. If no include or exclude rules are
+ // specified, the layer is always included. If the current NetState meets
+ // ANY (i.e., one or more) of the specified rules, the layer is
+ // included/excluded.
+ repeated NetStateRule include = 8;
+ repeated NetStateRule exclude = 9;
+
+ // Parameters for data pre-processing.
+ optional TransformationParameter transform_param = 100;
+
+ // Parameters shared by loss layers.
+ optional LossParameter loss_param = 101;
+
+ // Layer type-specific parameters.
+ //
+ // Note: certain layers may have more than one computational engine
+ // for their implementation. These layers include an Engine type and
+ // engine parameter for selecting the implementation.
+ // The default for the engine is set by the ENGINE switch at compile-time.
+ optional AccuracyParameter accuracy_param = 102;
+ optional ArgMaxParameter argmax_param = 103;
+ optional BatchNormParameter batch_norm_param = 139;
+ optional BiasParameter bias_param = 141;
+ optional ConcatParameter concat_param = 104;
+ optional ContrastiveLossParameter contrastive_loss_param = 105;
+ optional ConvolutionParameter convolution_param = 106;
+ optional CropParameter crop_param = 144;
+ optional DataParameter data_param = 107;
+ optional DetectionOutputParameter detection_output_param = 147;
+ optional DropoutParameter dropout_param = 108;
+ optional DummyDataParameter dummy_data_param = 109;
+ optional EltwiseParameter eltwise_param = 110;
+ optional ELUParameter elu_param = 140;
+ optional EmbedParameter embed_param = 137;
+ optional ExpParameter exp_param = 111;
+ optional FlattenParameter flatten_param = 135;
+ optional HDF5DataParameter hdf5_data_param = 112;
+ optional HDF5OutputParameter hdf5_output_param = 113;
+ optional HingeLossParameter hinge_loss_param = 114;
+ optional ImageDataParameter image_data_param = 115;
+ optional InfogainLossParameter infogain_loss_param = 116;
+ optional InnerProductParameter inner_product_param = 117;
+ optional InputParameter input_param = 143;
+ optional LogParameter log_param = 134;
+ optional LRNParameter lrn_param = 118;
+ optional MemoryDataParameter memory_data_param = 119;
+ optional MVNParameter mvn_param = 120;
+ optional NormalizeBBoxParameter norm_param = 149;
+ optional PermuteParameter permute_param = 148;
+ optional ParameterParameter parameter_param = 145;
+ optional PoolingParameter pooling_param = 121;
+ optional PowerParameter power_param = 122;
+ optional PReLUParameter prelu_param = 131;
+ optional PriorBoxParameter prior_box_param = 150;
+ optional PythonParameter python_param = 130;
+ optional RecurrentParameter recurrent_param = 146;
+ optional ReductionParameter reduction_param = 136;
+ optional ReLUParameter relu_param = 123;
+ optional ReshapeParameter reshape_param = 133;
+ optional ScaleParameter scale_param = 142;
+ optional SigmoidParameter sigmoid_param = 124;
+ optional SoftmaxParameter softmax_param = 125;
+ optional SPPParameter spp_param = 132;
+ optional SliceParameter slice_param = 126;
+ optional TanHParameter tanh_param = 127;
+ optional ThresholdParameter threshold_param = 128;
+ optional TileParameter tile_param = 138;
+ optional WindowDataParameter window_data_param = 129;
+}
+
+// Message that stores parameters used to apply transformation
+// to the data layer's data
+message TransformationParameter {
+ // For data pre-processing, we can do simple scaling and subtracting the
+ // data mean, if provided. Note that the mean subtraction is always carried
+ // out before scaling.
+ optional float scale = 1 [default = 1];
+ // Specify if we want to randomly mirror data.
+ optional bool mirror = 2 [default = false];
+ // Specify if we would like to randomly crop an image.
+ optional uint32 crop_size = 3 [default = 0];
+ // mean_file and mean_value cannot be specified at the same time
+ optional string mean_file = 4;
+ // if specified can be repeated once (would subtract it from all the channels)
+ // or can be repeated the same number of times as channels
+ // (would subtract them from the corresponding channel)
+ repeated float mean_value = 5;
+ // Force the decoded image to have 3 color channels.
+ optional bool force_color = 6 [default = false];
+ // Force the decoded image to have 1 color channels.
+ optional bool force_gray = 7 [default = false];
+}
+
+// Message that stores parameters shared by loss layers
+message LossParameter {
+ // If specified, ignore instances with the given label.
+ optional int32 ignore_label = 1;
+ // How to normalize the loss for loss layers that aggregate across batches,
+ // spatial dimensions, or other dimensions. Currently only implemented in
+ // SoftmaxWithLoss and SigmoidCrossEntropyLoss layers.
+ enum NormalizationMode {
+ // Divide by the number of examples in the batch times spatial dimensions.
+ // Outputs that receive the ignore label will NOT be ignored in computing
+ // the normalization factor.
+ FULL = 0;
+ // Divide by the total number of output locations that do not take the
+ // ignore_label. If ignore_label is not set, this behaves like FULL.
+ VALID = 1;
+ // Divide by the batch size.
+ BATCH_SIZE = 2;
+ // Do not normalize the loss.
+ NONE = 3;
+ }
+ // For historical reasons, the default normalization for
+ // SigmoidCrossEntropyLoss is BATCH_SIZE and *not* VALID.
+ optional NormalizationMode normalization = 3 [default = VALID];
+ // Deprecated. Ignored if normalization is specified. If normalization
+ // is not specified, then setting this to false will be equivalent to
+ // normalization = BATCH_SIZE to be consistent with previous behavior.
+ optional bool normalize = 2;
+}
+
+// Messages that store parameters used by individual layer types follow, in
+// alphabetical order.
+
+message AccuracyParameter {
+ // When computing accuracy, count as correct by comparing the true label to
+ // the top k scoring classes. By default, only compare to the top scoring
+ // class (i.e. argmax).
+ optional uint32 top_k = 1 [default = 1];
+
+ // The "label" axis of the prediction blob, whose argmax corresponds to the
+ // predicted label -- may be negative to index from the end (e.g., -1 for the
+ // last axis). For example, if axis == 1 and the predictions are
+ // (N x C x H x W), the label blob is expected to contain N*H*W ground truth
+ // labels with integer values in {0, 1, ..., C-1}.
+ optional int32 axis = 2 [default = 1];
+
+ // If specified, ignore instances with the given label.
+ optional int32 ignore_label = 3;
+}
+
+message ArgMaxParameter {
+ // If true produce pairs (argmax, maxval)
+ optional bool out_max_val = 1 [default = false];
+ optional uint32 top_k = 2 [default = 1];
+ // The axis along which to maximise -- may be negative to index from the
+ // end (e.g., -1 for the last axis).
+ // By default ArgMaxLayer maximizes over the flattened trailing dimensions
+ // for each index of the first / num dimension.
+ optional int32 axis = 3;
+}
+
+message ConcatParameter {
+ // The axis along which to concatenate -- may be negative to index from the
+ // end (e.g., -1 for the last axis). Other axes must have the
+ // same dimension for all the bottom blobs.
+ // By default, ConcatLayer concatenates blobs along the "channels" axis (1).
+ optional int32 axis = 2 [default = 1];
+
+ // DEPRECATED: alias for "axis" -- does not support negative indexing.
+ optional uint32 concat_dim = 1 [default = 1];
+}
+
+message BatchNormParameter {
+ // If false, accumulate global mean/variance values via a moving average. If
+ // true, use those accumulated values instead of computing mean/variance
+ // across the batch.
+ optional bool use_global_stats = 1;
+ // How much does the moving average decay each iteration?
+ optional float moving_average_fraction = 2 [default = .999];
+ // Small value to add to the variance estimate so that we don't divide by
+ // zero.
+ optional float eps = 3 [default = 1e-5];
+}
+
+message BiasParameter {
+ // The first axis of bottom[0] (the first input Blob) along which to apply
+ // bottom[1] (the second input Blob). May be negative to index from the end
+ // (e.g., -1 for the last axis).
+ //
+ // For example, if bottom[0] is 4D with shape 100x3x40x60, the output
+ // top[0] will have the same shape, and bottom[1] may have any of the
+ // following shapes (for the given value of axis):
+ // (axis == 0 == -4) 100; 100x3; 100x3x40; 100x3x40x60
+ // (axis == 1 == -3) 3; 3x40; 3x40x60
+ // (axis == 2 == -2) 40; 40x60
+ // (axis == 3 == -1) 60
+ // Furthermore, bottom[1] may have the empty shape (regardless of the value of
+ // "axis") -- a scalar bias.
+ optional int32 axis = 1 [default = 1];
+
+ // (num_axes is ignored unless just one bottom is given and the bias is
+ // a learned parameter of the layer. Otherwise, num_axes is determined by the
+ // number of axes by the second bottom.)
+ // The number of axes of the input (bottom[0]) covered by the bias
+ // parameter, or -1 to cover all axes of bottom[0] starting from `axis`.
+ // Set num_axes := 0, to add a zero-axis Blob: a scalar.
+ optional int32 num_axes = 2 [default = 1];
+
+ // (filler is ignored unless just one bottom is given and the bias is
+ // a learned parameter of the layer.)
+ // The initialization for the learned bias parameter.
+ // Default is the zero (0) initialization, resulting in the BiasLayer
+ // initially performing the identity operation.
+ optional FillerParameter filler = 3;
+}
+
+message ContrastiveLossParameter {
+ // margin for dissimilar pair
+ optional float margin = 1 [default = 1.0];
+ // The first implementation of this cost did not exactly match the cost of
+ // Hadsell et al 2006 -- using (margin - d^2) instead of (margin - d)^2.
+ // legacy_version = false (the default) uses (margin - d)^2 as proposed in the
+ // Hadsell paper. New models should probably use this version.
+ // legacy_version = true uses (margin - d^2). This is kept to support /
+ // reproduce existing models and results
+ optional bool legacy_version = 2 [default = false];
+}
+
+message ConvolutionParameter {
+ optional uint32 num_output = 1; // The number of outputs for the layer
+ optional bool bias_term = 2 [default = true]; // whether to have bias terms
+
+ // Pad, kernel size, and stride are all given as a single value for equal
+ // dimensions in all spatial dimensions, or once per spatial dimension.
+ repeated uint32 pad = 3; // The padding size; defaults to 0
+ repeated uint32 kernel_size = 4; // The kernel size
+ repeated uint32 stride = 6; // The stride; defaults to 1
+ // Factor used to dilate the kernel, (implicitly) zero-filling the resulting
+ // holes. (Kernel dilation is sometimes referred to by its use in the
+ // algorithme à trous from Holschneider et al. 1987.)
+ repeated uint32 dilation = 18; // The dilation; defaults to 1
+
+ // For 2D convolution only, the *_h and *_w versions may also be used to
+ // specify both spatial dimensions.
+ optional uint32 pad_h = 9 [default = 0]; // The padding height (2D only)
+ optional uint32 pad_w = 10 [default = 0]; // The padding width (2D only)
+ optional uint32 kernel_h = 11; // The kernel height (2D only)
+ optional uint32 kernel_w = 12; // The kernel width (2D only)
+ optional uint32 stride_h = 13; // The stride height (2D only)
+ optional uint32 stride_w = 14; // The stride width (2D only)
+
+ optional uint32 group = 5 [default = 1]; // The group size for group conv
+
+ optional FillerParameter weight_filler = 7; // The filler for the weight
+ optional FillerParameter bias_filler = 8; // The filler for the bias
+ enum Engine {
+ DEFAULT = 0;
+ CAFFE = 1;
+ CUDNN = 2;
+ }
+ optional Engine engine = 15 [default = DEFAULT];
+
+ // The axis to interpret as "channels" when performing convolution.
+ // Preceding dimensions are treated as independent inputs;
+ // succeeding dimensions are treated as "spatial".
+ // With (N, C, H, W) inputs, and axis == 1 (the default), we perform
+ // N independent 2D convolutions, sliding C-channel (or (C/g)-channels, for
+ // groups g>1) filters across the spatial axes (H, W) of the input.
+ // With (N, C, D, H, W) inputs, and axis == 1, we perform
+ // N independent 3D convolutions, sliding (C/g)-channels
+ // filters across the spatial axes (D, H, W) of the input.
+ optional int32 axis = 16 [default = 1];
+
+ // Whether to force use of the general ND convolution, even if a specific
+ // implementation for blobs of the appropriate number of spatial dimensions
+ // is available. (Currently, there is only a 2D-specific convolution
+ // implementation; for input blobs with num_axes != 2, this option is
+ // ignored and the ND implementation will be used.)
+ optional bool force_nd_im2col = 17 [default = false];
+}
+
+message CropParameter {
+ // To crop, elements of the first bottom are selected to fit the dimensions
+ // of the second, reference bottom. The crop is configured by
+ // - the crop `axis` to pick the dimensions for cropping
+ // - the crop `offset` to set the shift for all/each dimension
+ // to align the cropped bottom with the reference bottom.
+ // All dimensions up to but excluding `axis` are preserved, while
+ // the dimensions including and trailing `axis` are cropped.
+ // If only one `offset` is set, then all dimensions are offset by this amount.
+ // Otherwise, the number of offsets must equal the number of cropped axes to
+ // shift the crop in each dimension accordingly.
+ // Note: standard dimensions are N,C,H,W so the default is a spatial crop,
+ // and `axis` may be negative to index from the end (e.g., -1 for the last
+ // axis).
+ optional int32 axis = 1 [default = 2];
+ repeated uint32 offset = 2;
+}
+
+message DataParameter {
+ enum DB {
+ LEVELDB = 0;
+ LMDB = 1;
+ }
+ // Specify the data source.
+ optional string source = 1;
+ // Specify the batch size.
+ optional uint32 batch_size = 4;
+ // The rand_skip variable is for the data layer to skip a few data points
+ // to avoid all asynchronous sgd clients to start at the same point. The skip
+ // point would be set as rand_skip * rand(0,1). Note that rand_skip should not
+ // be larger than the number of keys in the database.
+ // DEPRECATED. Each solver accesses a different subset of the database.
+ optional uint32 rand_skip = 7 [default = 0];
+ optional DB backend = 8 [default = LEVELDB];
+ // DEPRECATED. See TransformationParameter. For data pre-processing, we can do
+ // simple scaling and subtracting the data mean, if provided. Note that the
+ // mean subtraction is always carried out before scaling.
+ optional float scale = 2 [default = 1];
+ optional string mean_file = 3;
+ // DEPRECATED. See TransformationParameter. Specify if we would like to randomly
+ // crop an image.
+ optional uint32 crop_size = 5 [default = 0];
+ // DEPRECATED. See TransformationParameter. Specify if we want to randomly mirror
+ // data.
+ optional bool mirror = 6 [default = false];
+ // Force the encoded image to have 3 color channels
+ optional bool force_encoded_color = 9 [default = false];
+ // Prefetch queue (Number of batches to prefetch to host memory, increase if
+ // data access bandwidth varies).
+ optional uint32 prefetch = 10 [default = 4];
+}
+
+message NonMaximumSuppressionParameter {
+ // Threshold to be used in nms.
+ optional float nms_threshold = 1 [default = 0.3];
+ // Maximum number of results to be kept.
+ optional int32 top_k = 2;
+ // Parameter for adaptive nms.
+ optional float eta = 3 [default = 1.0];
+}
+
+message SaveOutputParameter {
+ // Output directory. If not empty, we will save the results.
+ optional string output_directory = 1;
+ // Output name prefix.
+ optional string output_name_prefix = 2;
+ // Output format.
+ // VOC - PASCAL VOC output format.
+ // COCO - MS COCO output format.
+ optional string output_format = 3;
+ // If you want to output results, must also provide the following two files.
+ // Otherwise, we will ignore saving results.
+ // label map file.
+ optional string label_map_file = 4;
+ // A file which contains a list of names and sizes with same order
+ // of the input DB. The file is in the following format:
+ // name height width
+ // ...
+ optional string name_size_file = 5;
+ // Number of test images. It can be less than the lines specified in
+ // name_size_file. For example, when we only want to evaluate on part
+ // of the test images.
+ optional uint32 num_test_image = 6;
+}
+
+message DropoutParameter {
+ optional float dropout_ratio = 1 [default = 0.5]; // dropout ratio
+}
+
+// DummyDataLayer fills any number of arbitrarily shaped blobs with random
+// (or constant) data generated by "Fillers" (see "message FillerParameter").
+message DummyDataParameter {
+ // This layer produces N >= 1 top blobs. DummyDataParameter must specify 1 or N
+ // shape fields, and 0, 1 or N data_fillers.
+ //
+ // If 0 data_fillers are specified, ConstantFiller with a value of 0 is used.
+ // If 1 data_filler is specified, it is applied to all top blobs. If N are
+ // specified, the ith is applied to the ith top blob.
+ repeated FillerParameter data_filler = 1;
+ repeated BlobShape shape = 6;
+
+ // 4D dimensions -- deprecated. Use "shape" instead.
+ repeated uint32 num = 2;
+ repeated uint32 channels = 3;
+ repeated uint32 height = 4;
+ repeated uint32 width = 5;
+}
+
+message EltwiseParameter {
+ enum EltwiseOp {
+ PROD = 0;
+ SUM = 1;
+ MAX = 2;
+ }
+ optional EltwiseOp operation = 1 [default = SUM]; // element-wise operation
+ repeated float coeff = 2; // blob-wise coefficient for SUM operation
+
+ // Whether to use an asymptotically slower (for >2 inputs) but stabler method
+ // of computing the gradient for the PROD operation. (No effect for SUM op.)
+ optional bool stable_prod_grad = 3 [default = true];
+}
+
+// Message that stores parameters used by ELULayer
+message ELUParameter {
+ // Described in:
+ // Clevert, D.-A., Unterthiner, T., & Hochreiter, S. (2015). Fast and Accurate
+ // Deep Network Learning by Exponential Linear Units (ELUs). arXiv
+ optional float alpha = 1 [default = 1];
+}
+
+// Message that stores parameters used by EmbedLayer
+message EmbedParameter {
+ optional uint32 num_output = 1; // The number of outputs for the layer
+ // The input is given as integers to be interpreted as one-hot
+ // vector indices with dimension num_input. Hence num_input should be
+ // 1 greater than the maximum possible input value.
+ optional uint32 input_dim = 2;
+
+ optional bool bias_term = 3 [default = true]; // Whether to use a bias term
+ optional FillerParameter weight_filler = 4; // The filler for the weight
+ optional FillerParameter bias_filler = 5; // The filler for the bias
+
+}
+
+// Message that stores parameters used by ExpLayer
+message ExpParameter {
+ // ExpLayer computes outputs y = base ^ (shift + scale * x), for base > 0.
+ // Or if base is set to the default (-1), base is set to e,
+ // so y = exp(shift + scale * x).
+ optional float base = 1 [default = -1.0];
+ optional float scale = 2 [default = 1.0];
+ optional float shift = 3 [default = 0.0];
+}
+
+/// Message that stores parameters used by FlattenLayer
+message FlattenParameter {
+ // The first axis to flatten: all preceding axes are retained in the output.
+ // May be negative to index from the end (e.g., -1 for the last axis).
+ optional int32 axis = 1 [default = 1];
+
+ // The last axis to flatten: all following axes are retained in the output.
+ // May be negative to index from the end (e.g., the default -1 for the last
+ // axis).
+ optional int32 end_axis = 2 [default = -1];
+}
+
+// Message that stores parameters used by HDF5DataLayer
+message HDF5DataParameter {
+ // Specify the data source.
+ optional string source = 1;
+ // Specify the batch size.
+ optional uint32 batch_size = 2;
+
+ // Specify whether to shuffle the data.
+ // If shuffle == true, the ordering of the HDF5 files is shuffled,
+ // and the ordering of data within any given HDF5 file is shuffled,
+ // but data between different files are not interleaved; all of a file's
+ // data are output (in a random order) before moving onto another file.
+ optional bool shuffle = 3 [default = false];
+}
+
+message HDF5OutputParameter {
+ optional string file_name = 1;
+}
+
+message HingeLossParameter {
+ enum Norm {
+ L1 = 1;
+ L2 = 2;
+ }
+ // Specify the Norm to use L1 or L2
+ optional Norm norm = 1 [default = L1];
+}
+
+message ImageDataParameter {
+ // Specify the data source.
+ optional string source = 1;
+ // Specify the batch size.
+ optional uint32 batch_size = 4 [default = 1];
+ // The rand_skip variable is for the data layer to skip a few data points
+ // to avoid all asynchronous sgd clients to start at the same point. The skip
+ // point would be set as rand_skip * rand(0,1). Note that rand_skip should not
+ // be larger than the number of keys in the database.
+ optional uint32 rand_skip = 7 [default = 0];
+ // Whether or not ImageLayer should shuffle the list of files at every epoch.
+ optional bool shuffle = 8 [default = false];
+ // It will also resize images if new_height or new_width are not zero.
+ optional uint32 new_height = 9 [default = 0];
+ optional uint32 new_width = 10 [default = 0];
+ // Specify if the images are color or gray
+ optional bool is_color = 11 [default = true];
+ // DEPRECATED. See TransformationParameter. For data pre-processing, we can do
+ // simple scaling and subtracting the data mean, if provided. Note that the
+ // mean subtraction is always carried out before scaling.
+ optional float scale = 2 [default = 1];
+ optional string mean_file = 3;
+ // DEPRECATED. See TransformationParameter. Specify if we would like to randomly
+ // crop an image.
+ optional uint32 crop_size = 5 [default = 0];
+ // DEPRECATED. See TransformationParameter. Specify if we want to randomly mirror
+ // data.
+ optional bool mirror = 6 [default = false];
+ optional string root_folder = 12 [default = ""];
+}
+
+message InfogainLossParameter {
+ // Specify the infogain matrix source.
+ optional string source = 1;
+}
+
+message InnerProductParameter {
+ optional uint32 num_output = 1; // The number of outputs for the layer
+ optional bool bias_term = 2 [default = true]; // whether to have bias terms
+ optional FillerParameter weight_filler = 3; // The filler for the weight
+ optional FillerParameter bias_filler = 4; // The filler for the bias
+
+ // The first axis to be lumped into a single inner product computation;
+ // all preceding axes are retained in the output.
+ // May be negative to index from the end (e.g., -1 for the last axis).
+ optional int32 axis = 5 [default = 1];
+ // Specify whether to transpose the weight matrix or not.
+ // If transpose == true, any operations will be performed on the transpose
+ // of the weight matrix. The weight matrix itself is not going to be transposed
+ // but rather the transfer flag of operations will be toggled accordingly.
+ optional bool transpose = 6 [default = false];
+}
+
+message InputParameter {
+ // This layer produces N >= 1 top blob(s) to be assigned manually.
+ // Define N shapes to set a shape for each top.
+ // Define 1 shape to set the same shape for every top.
+ // Define no shape to defer to reshaping manually.
+ repeated BlobShape shape = 1;
+}
+
+// Message that stores parameters used by LogLayer
+message LogParameter {
+ // LogLayer computes outputs y = log_base(shift + scale * x), for base > 0.
+ // Or if base is set to the default (-1), base is set to e,
+ // so y = ln(shift + scale * x) = log_e(shift + scale * x)
+ optional float base = 1 [default = -1.0];
+ optional float scale = 2 [default = 1.0];
+ optional float shift = 3 [default = 0.0];
+}
+
+// Message that stores parameters used by LRNLayer
+message LRNParameter {
+ optional uint32 local_size = 1 [default = 5];
+ optional float alpha = 2 [default = 1.];
+ optional float beta = 3 [default = 0.75];
+ enum NormRegion {
+ ACROSS_CHANNELS = 0;
+ WITHIN_CHANNEL = 1;
+ }
+ optional NormRegion norm_region = 4 [default = ACROSS_CHANNELS];
+ optional float k = 5 [default = 1.];
+ enum Engine {
+ DEFAULT = 0;
+ CAFFE = 1;
+ CUDNN = 2;
+ }
+ optional Engine engine = 6 [default = DEFAULT];
+}
+
+message MemoryDataParameter {
+ optional uint32 batch_size = 1;
+ optional uint32 channels = 2;
+ optional uint32 height = 3;
+ optional uint32 width = 4;
+}
+
+message MVNParameter {
+ // This parameter can be set to false to normalize mean only
+ optional bool normalize_variance = 1 [default = true];
+
+ // This parameter can be set to true to perform DNN-like MVN
+ optional bool across_channels = 2 [default = false];
+
+ // Epsilon for not dividing by zero while normalizing variance
+ optional float eps = 3 [default = 1e-9];
+}
+
+message ParameterParameter {
+ optional BlobShape shape = 1;
+}
+
+message PoolingParameter {
+ enum PoolMethod {
+ MAX = 0;
+ AVE = 1;
+ STOCHASTIC = 2;
+ }
+ optional PoolMethod pool = 1 [default = MAX]; // The pooling method
+ // Pad, kernel size, and stride are all given as a single value for equal
+ // dimensions in height and width or as Y, X pairs.
+ optional uint32 pad = 4 [default = 0]; // The padding size (equal in Y, X)
+ optional uint32 pad_h = 9 [default = 0]; // The padding height
+ optional uint32 pad_w = 10 [default = 0]; // The padding width
+ optional uint32 kernel_size = 2; // The kernel size (square)
+ optional uint32 kernel_h = 5; // The kernel height
+ optional uint32 kernel_w = 6; // The kernel width
+ optional uint32 stride = 3 [default = 1]; // The stride (equal in Y, X)
+ optional uint32 stride_h = 7; // The stride height
+ optional uint32 stride_w = 8; // The stride width
+ enum Engine {
+ DEFAULT = 0;
+ CAFFE = 1;
+ CUDNN = 2;
+ }
+ optional Engine engine = 11 [default = DEFAULT];
+ // If global_pooling then it will pool over the size of the bottom by doing
+ // kernel_h = bottom->height and kernel_w = bottom->width
+ optional bool global_pooling = 12 [default = false];
+}
+
+message PowerParameter {
+ // PowerLayer computes outputs y = (shift + scale * x) ^ power.
+ optional float power = 1 [default = 1.0];
+ optional float scale = 2 [default = 1.0];
+ optional float shift = 3 [default = 0.0];
+}
+
+message PythonParameter {
+ optional string module = 1;
+ optional string layer = 2;
+ // This value is set to the attribute `param_str` of the `PythonLayer` object
+ // in Python before calling the `setup()` method. This could be a number,
+ // string, dictionary in Python dict format, JSON, etc. You may parse this
+ // string in `setup` method and use it in `forward` and `backward`.
+ optional string param_str = 3 [default = ''];
+ // Whether this PythonLayer is shared among worker solvers during data parallelism.
+ // If true, each worker solver sequentially run forward from this layer.
+ // This value should be set true if you are using it as a data layer.
+ optional bool share_in_parallel = 4 [default = false];
+}
+
+// Message that stores parameters used by RecurrentLayer
+message RecurrentParameter {
+ // The dimension of the output (and usually hidden state) representation --
+ // must be explicitly set to non-zero.
+ optional uint32 num_output = 1 [default = 0];
+
+ optional FillerParameter weight_filler = 2; // The filler for the weight
+ optional FillerParameter bias_filler = 3; // The filler for the bias
+
+ // Whether to enable displaying debug_info in the unrolled recurrent net.
+ optional bool debug_info = 4 [default = false];
+
+ // Whether to add as additional inputs (bottoms) the initial hidden state
+ // blobs, and add as additional outputs (tops) the final timestep hidden state
+ // blobs. The number of additional bottom/top blobs required depends on the
+ // recurrent architecture -- e.g., 1 for RNNs, 2 for LSTMs.
+ optional bool expose_hidden = 5 [default = false];
+}
+
+// Message that stores parameters used by ReductionLayer
+message ReductionParameter {
+ enum ReductionOp {
+ SUM = 1;
+ ASUM = 2;
+ SUMSQ = 3;
+ MEAN = 4;
+ }
+
+ optional ReductionOp operation = 1 [default = SUM]; // reduction operation
+
+ // The first axis to reduce to a scalar -- may be negative to index from the
+ // end (e.g., -1 for the last axis).
+ // (Currently, only reduction along ALL "tail" axes is supported; reduction
+ // of axis M through N, where N < num_axes - 1, is unsupported.)
+ // Suppose we have an n-axis bottom Blob with shape:
+ // (d0, d1, d2, ..., d(m-1), dm, d(m+1), ..., d(n-1)).
+ // If axis == m, the output Blob will have shape
+ // (d0, d1, d2, ..., d(m-1)),
+ // and the ReductionOp operation is performed (d0 * d1 * d2 * ... * d(m-1))
+ // times, each including (dm * d(m+1) * ... * d(n-1)) individual data.
+ // If axis == 0 (the default), the output Blob always has the empty shape
+ // (count 1), performing reduction across the entire input --
+ // often useful for creating new loss functions.
+ optional int32 axis = 2 [default = 0];
+
+ optional float coeff = 3 [default = 1.0]; // coefficient for output
+}
+
+// Message that stores parameters used by ReLULayer
+message ReLUParameter {
+ // Allow non-zero slope for negative inputs to speed up optimization
+ // Described in:
+ // Maas, A. L., Hannun, A. Y., & Ng, A. Y. (2013). Rectifier nonlinearities
+ // improve neural network acoustic models. In ICML Workshop on Deep Learning
+ // for Audio, Speech, and Language Processing.
+ optional float negative_slope = 1 [default = 0];
+ enum Engine {
+ DEFAULT = 0;
+ CAFFE = 1;
+ CUDNN = 2;
+ }
+ optional Engine engine = 2 [default = DEFAULT];
+}
+
+message ReshapeParameter {
+ // Specify the output dimensions. If some of the dimensions are set to 0,
+ // the corresponding dimension from the bottom layer is used (unchanged).
+ // Exactly one dimension may be set to -1, in which case its value is
+ // inferred from the count of the bottom blob and the remaining dimensions.
+ // For example, suppose we want to reshape a 2D blob "input" with shape 2 x 8:
+ //
+ // layer {
+ // type: "Reshape" bottom: "input" top: "output"
+ // reshape_param { ... }
+ // }
+ //
+ // If "input" is 2D with shape 2 x 8, then the following reshape_param
+ // specifications are all equivalent, producing a 3D blob "output" with shape
+ // 2 x 2 x 4:
+ //
+ // reshape_param { shape { dim: 2 dim: 2 dim: 4 } }
+ // reshape_param { shape { dim: 0 dim: 2 dim: 4 } }
+ // reshape_param { shape { dim: 0 dim: 2 dim: -1 } }
+ // reshape_param { shape { dim: 0 dim:-1 dim: 4 } }
+ //
+ optional BlobShape shape = 1;
+
+ // axis and num_axes control the portion of the bottom blob's shape that are
+ // replaced by (included in) the reshape. By default (axis == 0 and
+ // num_axes == -1), the entire bottom blob shape is included in the reshape,
+ // and hence the shape field must specify the entire output shape.
+ //
+ // axis may be non-zero to retain some portion of the beginning of the input
+ // shape (and may be negative to index from the end; e.g., -1 to begin the
+ // reshape after the last axis, including nothing in the reshape,
+ // -2 to include only the last axis, etc.).
+ //
+ // For example, suppose "input" is a 2D blob with shape 2 x 8.
+ // Then the following ReshapeLayer specifications are all equivalent,
+ // producing a blob "output" with shape 2 x 2 x 4:
+ //
+ // reshape_param { shape { dim: 2 dim: 2 dim: 4 } }
+ // reshape_param { shape { dim: 2 dim: 4 } axis: 1 }
+ // reshape_param { shape { dim: 2 dim: 4 } axis: -3 }
+ //
+ // num_axes specifies the extent of the reshape.
+ // If num_axes >= 0 (and axis >= 0), the reshape will be performed only on
+ // input axes in the range [axis, axis+num_axes].
+ // num_axes may also be -1, the default, to include all remaining axes
+ // (starting from axis).
+ //
+ // For example, suppose "input" is a 2D blob with shape 2 x 8.
+ // Then the following ReshapeLayer specifications are equivalent,
+ // producing a blob "output" with shape 1 x 2 x 8.
+ //
+ // reshape_param { shape { dim: 1 dim: 2 dim: 8 } }
+ // reshape_param { shape { dim: 1 dim: 2 } num_axes: 1 }
+ // reshape_param { shape { dim: 1 } num_axes: 0 }
+ //
+ // On the other hand, these would produce output blob shape 2 x 1 x 8:
+ //
+ // reshape_param { shape { dim: 2 dim: 1 dim: 8 } }
+ // reshape_param { shape { dim: 1 } axis: 1 num_axes: 0 }
+ //
+ optional int32 axis = 2 [default = 0];
+ optional int32 num_axes = 3 [default = -1];
+}
+
+message ScaleParameter {
+ // The first axis of bottom[0] (the first input Blob) along which to apply
+ // bottom[1] (the second input Blob). May be negative to index from the end
+ // (e.g., -1 for the last axis).
+ //
+ // For example, if bottom[0] is 4D with shape 100x3x40x60, the output
+ // top[0] will have the same shape, and bottom[1] may have any of the
+ // following shapes (for the given value of axis):
+ // (axis == 0 == -4) 100; 100x3; 100x3x40; 100x3x40x60
+ // (axis == 1 == -3) 3; 3x40; 3x40x60
+ // (axis == 2 == -2) 40; 40x60
+ // (axis == 3 == -1) 60
+ // Furthermore, bottom[1] may have the empty shape (regardless of the value of
+ // "axis") -- a scalar multiplier.
+ optional int32 axis = 1 [default = 1];
+
+ // (num_axes is ignored unless just one bottom is given and the scale is
+ // a learned parameter of the layer. Otherwise, num_axes is determined by the
+ // number of axes by the second bottom.)
+ // The number of axes of the input (bottom[0]) covered by the scale
+ // parameter, or -1 to cover all axes of bottom[0] starting from `axis`.
+ // Set num_axes := 0, to multiply with a zero-axis Blob: a scalar.
+ optional int32 num_axes = 2 [default = 1];
+
+ // (filler is ignored unless just one bottom is given and the scale is
+ // a learned parameter of the layer.)
+ // The initialization for the learned scale parameter.
+ // Default is the unit (1) initialization, resulting in the ScaleLayer
+ // initially performing the identity operation.
+ optional FillerParameter filler = 3;
+
+ // Whether to also learn a bias (equivalent to a ScaleLayer+BiasLayer, but
+ // may be more efficient). Initialized with bias_filler (defaults to 0).
+ optional bool bias_term = 4 [default = false];
+ optional FillerParameter bias_filler = 5;
+}
+
+message SigmoidParameter {
+ enum Engine {
+ DEFAULT = 0;
+ CAFFE = 1;
+ CUDNN = 2;
+ }
+ optional Engine engine = 1 [default = DEFAULT];
+}
+
+message SliceParameter {
+ // The axis along which to slice -- may be negative to index from the end
+ // (e.g., -1 for the last axis).
+ // By default, SliceLayer concatenates blobs along the "channels" axis (1).
+ optional int32 axis = 3 [default = 1];
+ repeated uint32 slice_point = 2;
+
+ // DEPRECATED: alias for "axis" -- does not support negative indexing.
+ optional uint32 slice_dim = 1 [default = 1];
+}
+
+// Message that stores parameters used by SoftmaxLayer, SoftmaxWithLossLayer
+message SoftmaxParameter {
+ enum Engine {
+ DEFAULT = 0;
+ CAFFE = 1;
+ CUDNN = 2;
+ }
+ optional Engine engine = 1 [default = DEFAULT];
+
+ // The axis along which to perform the softmax -- may be negative to index
+ // from the end (e.g., -1 for the last axis).
+ // Any other axes will be evaluated as independent softmaxes.
+ optional int32 axis = 2 [default = 1];
+}
+
+message TanHParameter {
+ enum Engine {
+ DEFAULT = 0;
+ CAFFE = 1;
+ CUDNN = 2;
+ }
+ optional Engine engine = 1 [default = DEFAULT];
+}
+
+// Message that stores parameters used by TileLayer
+message TileParameter {
+ // The index of the axis to tile.
+ optional int32 axis = 1 [default = 1];
+
+ // The number of copies (tiles) of the blob to output.
+ optional int32 tiles = 2;
+}
+
+// Message that stores parameters used by ThresholdLayer
+message ThresholdParameter {
+ optional float threshold = 1 [default = 0]; // Strictly positive values
+}
+
+message WindowDataParameter {
+ // Specify the data source.
+ optional string source = 1;
+ // For data pre-processing, we can do simple scaling and subtracting the
+ // data mean, if provided. Note that the mean subtraction is always carried
+ // out before scaling.
+ optional float scale = 2 [default = 1];
+ optional string mean_file = 3;
+ // Specify the batch size.
+ optional uint32 batch_size = 4;
+ // Specify if we would like to randomly crop an image.
+ optional uint32 crop_size = 5 [default = 0];
+ // Specify if we want to randomly mirror data.
+ optional bool mirror = 6 [default = false];
+ // Foreground (object) overlap threshold
+ optional float fg_threshold = 7 [default = 0.5];
+ // Background (non-object) overlap threshold
+ optional float bg_threshold = 8 [default = 0.5];
+ // Fraction of batch that should be foreground objects
+ optional float fg_fraction = 9 [default = 0.25];
+ // Amount of contextual padding to add around a window
+ // (used only by the window_data_layer)
+ optional uint32 context_pad = 10 [default = 0];
+ // Mode for cropping out a detection window
+ // warp: cropped window is warped to a fixed size and aspect ratio
+ // square: the tightest square around the window is cropped
+ optional string crop_mode = 11 [default = "warp"];
+ // cache_images: will load all images in memory for faster access
+ optional bool cache_images = 12 [default = false];
+ // append root_folder to locate images
+ optional string root_folder = 13 [default = ""];
+}
+
+message SPPParameter {
+ enum PoolMethod {
+ MAX = 0;
+ AVE = 1;
+ STOCHASTIC = 2;
+ }
+ optional uint32 pyramid_height = 1;
+ optional PoolMethod pool = 2 [default = MAX]; // The pooling method
+ enum Engine {
+ DEFAULT = 0;
+ CAFFE = 1;
+ CUDNN = 2;
+ }
+ optional Engine engine = 6 [default = DEFAULT];
+}
+
+// DEPRECATED: use LayerParameter.
+message V1LayerParameter {
+ repeated string bottom = 2;
+ repeated string top = 3;
+ optional string name = 4;
+ repeated NetStateRule include = 32;
+ repeated NetStateRule exclude = 33;
+ enum LayerType {
+ NONE = 0;
+ ABSVAL = 35;
+ ACCURACY = 1;
+ ARGMAX = 30;
+ BNLL = 2;
+ CONCAT = 3;
+ CONTRASTIVE_LOSS = 37;
+ CONVOLUTION = 4;
+ DATA = 5;
+ DECONVOLUTION = 39;
+ DROPOUT = 6;
+ DUMMY_DATA = 32;
+ EUCLIDEAN_LOSS = 7;
+ ELTWISE = 25;
+ EXP = 38;
+ FLATTEN = 8;
+ HDF5_DATA = 9;
+ HDF5_OUTPUT = 10;
+ HINGE_LOSS = 28;
+ IM2COL = 11;
+ IMAGE_DATA = 12;
+ INFOGAIN_LOSS = 13;
+ INNER_PRODUCT = 14;
+ LRN = 15;
+ MEMORY_DATA = 29;
+ MULTINOMIAL_LOGISTIC_LOSS = 16;
+ MVN = 34;
+ POOLING = 17;
+ POWER = 26;
+ RELU = 18;
+ SIGMOID = 19;
+ SIGMOID_CROSS_ENTROPY_LOSS = 27;
+ SILENCE = 36;
+ SOFTMAX = 20;
+ SOFTMAX_LOSS = 21;
+ SPLIT = 22;
+ SLICE = 33;
+ TANH = 23;
+ WINDOW_DATA = 24;
+ THRESHOLD = 31;
+ }
+ optional LayerType type = 5;
+ repeated BlobProto blobs = 6;
+ repeated string param = 1001;
+ repeated DimCheckMode blob_share_mode = 1002;
+ enum DimCheckMode {
+ STRICT = 0;
+ PERMISSIVE = 1;
+ }
+ repeated float blobs_lr = 7;
+ repeated float weight_decay = 8;
+ repeated float loss_weight = 35;
+ optional AccuracyParameter accuracy_param = 27;
+ optional ArgMaxParameter argmax_param = 23;
+ optional ConcatParameter concat_param = 9;
+ optional ContrastiveLossParameter contrastive_loss_param = 40;
+ optional ConvolutionParameter convolution_param = 10;
+ optional DataParameter data_param = 11;
+ optional DropoutParameter dropout_param = 12;
+ optional DummyDataParameter dummy_data_param = 26;
+ optional EltwiseParameter eltwise_param = 24;
+ optional ExpParameter exp_param = 41;
+ optional HDF5DataParameter hdf5_data_param = 13;
+ optional HDF5OutputParameter hdf5_output_param = 14;
+ optional HingeLossParameter hinge_loss_param = 29;
+ optional ImageDataParameter image_data_param = 15;
+ optional InfogainLossParameter infogain_loss_param = 16;
+ optional InnerProductParameter inner_product_param = 17;
+ optional LRNParameter lrn_param = 18;
+ optional MemoryDataParameter memory_data_param = 22;
+ optional MVNParameter mvn_param = 34;
+ optional PoolingParameter pooling_param = 19;
+ optional PowerParameter power_param = 21;
+ optional ReLUParameter relu_param = 30;
+ optional SigmoidParameter sigmoid_param = 38;
+ optional SoftmaxParameter softmax_param = 39;
+ optional SliceParameter slice_param = 31;
+ optional TanHParameter tanh_param = 37;
+ optional ThresholdParameter threshold_param = 25;
+ optional WindowDataParameter window_data_param = 20;
+ optional TransformationParameter transform_param = 36;
+ optional LossParameter loss_param = 42;
+ optional V0LayerParameter layer = 1;
+}
+
+// DEPRECATED: V0LayerParameter is the old way of specifying layer parameters
+// in Caffe. We keep this message type around for legacy support.
+message V0LayerParameter {
+ optional string name = 1; // the layer name
+ optional string type = 2; // the string to specify the layer type
+
+ // Parameters to specify layers with inner products.
+ optional uint32 num_output = 3; // The number of outputs for the layer
+ optional bool biasterm = 4 [default = true]; // whether to have bias terms
+ optional FillerParameter weight_filler = 5; // The filler for the weight
+ optional FillerParameter bias_filler = 6; // The filler for the bias
+
+ optional uint32 pad = 7 [default = 0]; // The padding size
+ optional uint32 kernelsize = 8; // The kernel size
+ optional uint32 group = 9 [default = 1]; // The group size for group conv
+ optional uint32 stride = 10 [default = 1]; // The stride
+ enum PoolMethod {
+ MAX = 0;
+ AVE = 1;
+ STOCHASTIC = 2;
+ }
+ optional PoolMethod pool = 11 [default = MAX]; // The pooling method
+ optional float dropout_ratio = 12 [default = 0.5]; // dropout ratio
+
+ optional uint32 local_size = 13 [default = 5]; // for local response norm
+ optional float alpha = 14 [default = 1.]; // for local response norm
+ optional float beta = 15 [default = 0.75]; // for local response norm
+ optional float k = 22 [default = 1.];
+
+ // For data layers, specify the data source
+ optional string source = 16;
+ // For data pre-processing, we can do simple scaling and subtracting the
+ // data mean, if provided. Note that the mean subtraction is always carried
+ // out before scaling.
+ optional float scale = 17 [default = 1];
+ optional string meanfile = 18;
+ // For data layers, specify the batch size.
+ optional uint32 batchsize = 19;
+ // For data layers, specify if we would like to randomly crop an image.
+ optional uint32 cropsize = 20 [default = 0];
+ // For data layers, specify if we want to randomly mirror data.
+ optional bool mirror = 21 [default = false];
+
+ // The blobs containing the numeric parameters of the layer
+ repeated BlobProto blobs = 50;
+ // The ratio that is multiplied on the global learning rate. If you want to
+ // set the learning ratio for one blob, you need to set it for all blobs.
+ repeated float blobs_lr = 51;
+ // The weight decay that is multiplied on the global weight decay.
+ repeated float weight_decay = 52;
+
+ // The rand_skip variable is for the data layer to skip a few data points
+ // to avoid all asynchronous sgd clients to start at the same point. The skip
+ // point would be set as rand_skip * rand(0,1). Note that rand_skip should not
+ // be larger than the number of keys in the database.
+ optional uint32 rand_skip = 53 [default = 0];
+
+ // Fields related to detection (det_*)
+ // foreground (object) overlap threshold
+ optional float det_fg_threshold = 54 [default = 0.5];
+ // background (non-object) overlap threshold
+ optional float det_bg_threshold = 55 [default = 0.5];
+ // Fraction of batch that should be foreground objects
+ optional float det_fg_fraction = 56 [default = 0.25];
+
+ // optional bool OBSOLETE_can_clobber = 57 [default = true];
+
+ // Amount of contextual padding to add around a window
+ // (used only by the window_data_layer)
+ optional uint32 det_context_pad = 58 [default = 0];
+
+ // Mode for cropping out a detection window
+ // warp: cropped window is warped to a fixed size and aspect ratio
+ // square: the tightest square around the window is cropped
+ optional string det_crop_mode = 59 [default = "warp"];
+
+ // For ReshapeLayer, one needs to specify the new dimensions.
+ optional int32 new_num = 60 [default = 0];
+ optional int32 new_channels = 61 [default = 0];
+ optional int32 new_height = 62 [default = 0];
+ optional int32 new_width = 63 [default = 0];
+
+ // Whether or not ImageLayer should shuffle the list of files at every epoch.
+ // It will also resize images if new_height or new_width are not zero.
+ optional bool shuffle_images = 64 [default = false];
+
+ // For ConcatLayer, one needs to specify the dimension for concatenation, and
+ // the other dimensions must be the same for all the bottom blobs.
+ // By default it will concatenate blobs along the channels dimension.
+ optional uint32 concat_dim = 65 [default = 1];
+
+ optional HDF5OutputParameter hdf5_output_param = 1001;
+}
+
+message PReLUParameter {
+ // Parametric ReLU described in K. He et al, Delving Deep into Rectifiers:
+ // Surpassing Human-Level Performance on ImageNet Classification, 2015.
+
+ // Initial value of a_i. Default is a_i=0.25 for all i.
+ optional FillerParameter filler = 1;
+ // Whether or not slope parameters are shared across channels.
+ optional bool channel_shared = 2 [default = false];
+}
+
+// The normalized bounding box [0, 1] w.r.t. the input image size.
+message NormalizedBBox {
+ optional float xmin = 1;
+ optional float ymin = 2;
+ optional float xmax = 3;
+ optional float ymax = 4;
+ optional int32 label = 5;
+ optional bool difficult = 6;
+ optional float score = 7;
+ optional float size = 8;
+}
diff --git a/modules/dnn/src/caffe/caffe_importer.cpp b/modules/dnn/src/caffe/caffe_importer.cpp
new file mode 100644
index 0000000..c075651
--- /dev/null
+++ b/modules/dnn/src/caffe/caffe_importer.cpp
@@ -0,0 +1,393 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "../precomp.hpp"
+
+#ifdef HAVE_PROTOBUF
+#include "caffe.pb.h"
+
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <algorithm>
+#include <google/protobuf/message.h>
+#include <google/protobuf/text_format.h>
+#include <google/protobuf/io/zero_copy_stream_impl.h>
+#include "caffe_io.hpp"
+#endif
+
+namespace cv {
+namespace dnn {
+CV__DNN_EXPERIMENTAL_NS_BEGIN
+
+#ifdef HAVE_PROTOBUF
+using ::google::protobuf::RepeatedField;
+using ::google::protobuf::RepeatedPtrField;
+using ::google::protobuf::Message;
+using ::google::protobuf::Descriptor;
+using ::google::protobuf::FieldDescriptor;
+using ::google::protobuf::Reflection;
+
+namespace
+{
+
+template<typename T>
+static cv::String toString(const T &v)
+{
+ std::ostringstream ss;
+ ss << v;
+ return ss.str();
+}
+
+class CaffeImporter : public Importer
+{
+ caffe::NetParameter net;
+ caffe::NetParameter netBinary;
+
+public:
+
+ CaffeImporter(const char *pototxt, const char *caffeModel)
+ {
+ CV_TRACE_FUNCTION();
+
+ ReadNetParamsFromTextFileOrDie(pototxt, &net);
+
+ if (caffeModel && caffeModel[0])
+ ReadNetParamsFromBinaryFileOrDie(caffeModel, &netBinary);
+ }
+
+ void addParam(const Message &msg, const FieldDescriptor *field, cv::dnn::LayerParams ¶ms)
+ {
+ const Reflection *refl = msg.GetReflection();
+ int type = field->cpp_type();
+ bool isRepeated = field->is_repeated();
+ const std::string &name = field->name();
+
+ #define SET_UP_FILED(getter, arrayConstr, gtype) \
+ if (isRepeated) { \
+ const RepeatedField<gtype> &v = refl->GetRepeatedField<gtype>(msg, field); \
+ params.set(name, DictValue::arrayConstr(v.begin(), (int)v.size())); \
+ } \
+ else { \
+ params.set(name, refl->getter(msg, field)); \
+ }
+
+ switch (type)
+ {
+ case FieldDescriptor::CPPTYPE_INT32:
+ SET_UP_FILED(GetInt32, arrayInt, ::google::protobuf::int32);
+ break;
+ case FieldDescriptor::CPPTYPE_UINT32:
+ SET_UP_FILED(GetUInt32, arrayInt, ::google::protobuf::uint32);
+ break;
+ case FieldDescriptor::CPPTYPE_INT64:
+ SET_UP_FILED(GetInt32, arrayInt, ::google::protobuf::int64);
+ break;
+ case FieldDescriptor::CPPTYPE_UINT64:
+ SET_UP_FILED(GetUInt32, arrayInt, ::google::protobuf::uint64);
+ break;
+ case FieldDescriptor::CPPTYPE_BOOL:
+ SET_UP_FILED(GetBool, arrayInt, bool);
+ break;
+ case FieldDescriptor::CPPTYPE_DOUBLE:
+ SET_UP_FILED(GetDouble, arrayReal, double);
+ break;
+ case FieldDescriptor::CPPTYPE_FLOAT:
+ SET_UP_FILED(GetFloat, arrayReal, float);
+ break;
+ case FieldDescriptor::CPPTYPE_STRING:
+ if (isRepeated) {
+ const RepeatedPtrField<std::string> &v = refl->GetRepeatedPtrField<std::string>(msg, field);
+ params.set(name, DictValue::arrayString(v.begin(), (int)v.size()));
+ }
+ else {
+ params.set(name, refl->GetString(msg, field));
+ }
+ break;
+ case FieldDescriptor::CPPTYPE_ENUM:
+ if (isRepeated) {
+ int size = refl->FieldSize(msg, field);
+ std::vector<cv::String> buf(size);
+ for (int i = 0; i < size; i++)
+ buf[i] = refl->GetRepeatedEnum(msg, field, i)->name();
+ params.set(name, DictValue::arrayString(buf.begin(), size));
+ }
+ else {
+ params.set(name, refl->GetEnum(msg, field)->name());
+ }
+ break;
+ default:
+ CV_Error(Error::StsError, "Unknown type \"" + String(field->type_name()) + "\" in prototxt");
+ break;
+ }
+ }
+
+ inline static bool ends_with_param(const std::string &str)
+ {
+ static const std::string _param("_param");
+ return (str.size() >= _param.size()) && str.compare(str.size() - _param.size(), _param.size(), _param) == 0;
+ }
+
+ void extractLayerParams(const Message &msg, cv::dnn::LayerParams ¶ms, bool isInternal = false)
+ {
+ const Descriptor *msgDesc = msg.GetDescriptor();
+ const Reflection *msgRefl = msg.GetReflection();
+
+ for (int fieldId = 0; fieldId < msgDesc->field_count(); fieldId++)
+ {
+ const FieldDescriptor *fd = msgDesc->field(fieldId);
+
+ if (!isInternal && !ends_with_param(fd->name()))
+ continue;
+
+ bool hasData = fd->is_required() ||
+ (fd->is_optional() && msgRefl->HasField(msg, fd)) ||
+ (fd->is_repeated() && msgRefl->FieldSize(msg, fd) > 0);
+ if (!hasData)
+ continue;
+
+ if (fd->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE)
+ {
+ if (fd->is_repeated()) //Extract only first item!
+ extractLayerParams(msgRefl->GetRepeatedMessage(msg, fd, 0), params, true);
+ else
+ extractLayerParams(msgRefl->GetMessage(msg, fd), params, true);
+ }
+ else
+ {
+ addParam(msg, fd, params);
+ }
+ }
+ }
+
+ void blobShapeFromProto(const caffe::BlobProto &pbBlob, MatShape& shape)
+ {
+ shape.clear();
+ if (pbBlob.has_num() || pbBlob.has_channels() || pbBlob.has_height() || pbBlob.has_width())
+ {
+ shape.push_back(pbBlob.num());
+ shape.push_back(pbBlob.channels());
+ shape.push_back(pbBlob.height());
+ shape.push_back(pbBlob.width());
+ }
+ else if (pbBlob.has_shape())
+ {
+ const caffe::BlobShape &_shape = pbBlob.shape();
+
+ for (int i = 0; i < _shape.dim_size(); i++)
+ shape.push_back((int)_shape.dim(i));
+ }
+ else
+ CV_Error(Error::StsError, "Unknown shape of input blob");
+ }
+
+ void blobFromProto(const caffe::BlobProto &pbBlob, cv::Mat &dstBlob)
+ {
+ MatShape shape;
+ blobShapeFromProto(pbBlob, shape);
+
+ dstBlob.create((int)shape.size(), &shape[0], CV_32F);
+ CV_Assert(pbBlob.data_size() == (int)dstBlob.total());
+
+ CV_DbgAssert(pbBlob.GetDescriptor()->FindFieldByLowercaseName("data")->cpp_type() == FieldDescriptor::CPPTYPE_FLOAT);
+ float *dstData = dstBlob.ptr<float>();
+
+ for (int i = 0; i < pbBlob.data_size(); i++)
+ dstData[i] = pbBlob.data(i);
+ }
+
+ void extractBinaryLayerParms(const caffe::LayerParameter& layer, LayerParams& layerParams)
+ {
+ const std::string &name = layer.name();
+
+ int li;
+ for (li = 0; li != netBinary.layer_size(); li++)
+ {
+ if (netBinary.layer(li).name() == name)
+ break;
+ }
+
+ if (li == netBinary.layer_size() || netBinary.layer(li).blobs_size() == 0)
+ return;
+
+ const caffe::LayerParameter &binLayer = netBinary.layer(li);
+ layerParams.blobs.resize(binLayer.blobs_size());
+ for (int bi = 0; bi < binLayer.blobs_size(); bi++)
+ {
+ blobFromProto(binLayer.blobs(bi), layerParams.blobs[bi]);
+ }
+ }
+
+ struct BlobNote
+ {
+ BlobNote(const std::string &_name, int _layerId, int _outNum) :
+ name(_name.c_str()), layerId(_layerId), outNum(_outNum) {}
+
+ const char *name;
+ int layerId, outNum;
+ };
+
+ std::vector<BlobNote> addedBlobs;
+ std::map<String, int> layerCounter;
+
+ void populateNet(Net dstNet)
+ {
+ CV_TRACE_FUNCTION();
+
+ int layersSize = net.layer_size();
+ layerCounter.clear();
+ addedBlobs.clear();
+ addedBlobs.reserve(layersSize + 1);
+
+ //setup input layer names
+ {
+ std::vector<String> netInputs(net.input_size());
+ for (int inNum = 0; inNum < net.input_size(); inNum++)
+ {
+ addedBlobs.push_back(BlobNote(net.input(inNum), 0, inNum));
+ netInputs[inNum] = net.input(inNum);
+ }
+ dstNet.setInputsNames(netInputs);
+ }
+
+ for (int li = 0; li < layersSize; li++)
+ {
+ const caffe::LayerParameter &layer = net.layer(li);
+ String name = layer.name();
+ String type = layer.type();
+ LayerParams layerParams;
+
+ extractLayerParams(layer, layerParams);
+ extractBinaryLayerParms(layer, layerParams);
+
+ int repetitions = layerCounter[name]++;
+ if (repetitions)
+ name += String("_") + toString(repetitions);
+
+ int id = dstNet.addLayer(name, type, layerParams);
+
+ for (int inNum = 0; inNum < layer.bottom_size(); inNum++)
+ addInput(layer.bottom(inNum), id, inNum, dstNet);
+
+ for (int outNum = 0; outNum < layer.top_size(); outNum++)
+ addOutput(layer, id, outNum);
+ }
+
+ addedBlobs.clear();
+ }
+
+ void addOutput(const caffe::LayerParameter &layer, int layerId, int outNum)
+ {
+ const std::string &name = layer.top(outNum);
+
+ bool haveDups = false;
+ for (int idx = (int)addedBlobs.size() - 1; idx >= 0; idx--)
+ {
+ if (addedBlobs[idx].name == name)
+ {
+ haveDups = true;
+ break;
+ }
+ }
+
+ if (haveDups)
+ {
+ bool isInplace = layer.bottom_size() > outNum && layer.bottom(outNum) == name;
+ if (!isInplace)
+ CV_Error(Error::StsBadArg, "Duplicate blobs produced by multiple sources");
+ }
+
+ addedBlobs.push_back(BlobNote(name, layerId, outNum));
+ }
+
+ void addInput(const std::string &name, int layerId, int inNum, Net &dstNet)
+ {
+ int idx;
+ for (idx = (int)addedBlobs.size() - 1; idx >= 0; idx--)
+ {
+ if (addedBlobs[idx].name == name)
+ break;
+ }
+
+ if (idx < 0)
+ {
+ CV_Error(Error::StsObjectNotFound, "Can't find output blob \"" + name + "\"");
+ return;
+ }
+
+ dstNet.connect(addedBlobs[idx].layerId, addedBlobs[idx].outNum, layerId, inNum);
+ }
+
+ ~CaffeImporter()
+ {
+
+ }
+
+};
+
+}
+
+Ptr<Importer> createCaffeImporter(const String &prototxt, const String &caffeModel)
+{
+ return Ptr<Importer>(new CaffeImporter(prototxt.c_str(), caffeModel.c_str()));
+}
+
+#else //HAVE_PROTOBUF
+
+Ptr<Importer> createCaffeImporter(const String&, const String&)
+{
+ CV_Error(cv::Error::StsNotImplemented, "libprotobuf required to import data from Caffe models");
+ return Ptr<Importer>();
+}
+
+#endif //HAVE_PROTOBUF
+
+Net readNetFromCaffe(const String &prototxt, const String &caffeModel /*= String()*/)
+{
+ Ptr<Importer> caffeImporter = createCaffeImporter(prototxt, caffeModel);
+ Net net;
+ if (caffeImporter)
+ caffeImporter->populateNet(net);
+ return net;
+}
+
+CV__DNN_EXPERIMENTAL_NS_END
+}} // namespace
diff --git a/modules/dnn/src/caffe/caffe_io.cpp b/modules/dnn/src/caffe/caffe_io.cpp
new file mode 100644
index 0000000..0f46ea7
--- /dev/null
+++ b/modules/dnn/src/caffe/caffe_io.cpp
@@ -0,0 +1,1151 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//COPYRIGHT
+//
+//All contributions by the University of California:
+//Copyright (c) 2014, The Regents of the University of California (Regents)
+//All rights reserved.
+//
+//All other contributions:
+//Copyright (c) 2014, the respective contributors
+//All rights reserved.
+//
+//Caffe uses a shared copyright model: each contributor holds copyright over
+//their contributions to Caffe. The project versioning records all such
+//contribution and copyright details. If a contributor wants to further mark
+//their specific copyright on a particular contribution, they should indicate
+//their copyright solely in the commit message of the change when it is
+//committed.
+//
+//LICENSE
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions are met:
+//
+//1. Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+//ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+//DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+//ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+//(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+//ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+//(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+//CONTRIBUTION AGREEMENT
+//
+//By contributing to the BVLC/caffe repository through pull-request, comment,
+//or otherwise, the contributor releases their content to the
+//license and copyright terms herein.
+//
+//M*/
+
+#ifdef HAVE_PROTOBUF
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/io/zero_copy_stream_impl.h>
+#include <google/protobuf/text_format.h>
+
+#include <opencv2/core.hpp>
+
+#include <map>
+#include <string>
+#include <fstream>
+#include <vector>
+
+#include "caffe.pb.h"
+#include "caffe_io.hpp"
+#include "glog_emulator.hpp"
+
+namespace cv {
+namespace dnn {
+
+using std::string;
+using std::map;
+using namespace caffe;
+using namespace ::google::protobuf;
+using namespace ::google::protobuf::io;
+
+// Return true iff the net is not the current version.
+bool NetNeedsUpgrade(const NetParameter& net_param);
+
+// Return true iff any layer contains parameters specified using
+// deprecated V0LayerParameter.
+bool NetNeedsV0ToV1Upgrade(const NetParameter& net_param);
+
+// Perform all necessary transformations to upgrade a V0NetParameter into a
+// NetParameter (including upgrading padding layers and LayerParameters).
+bool UpgradeV0Net(const NetParameter& v0_net_param, NetParameter* net_param);
+
+// Upgrade NetParameter with padding layers to pad-aware conv layers.
+// For any padding layer, remove it and put its pad parameter in any layers
+// taking its top blob as input.
+// Error if any of these above layers are not-conv layers.
+void UpgradeV0PaddingLayers(const NetParameter& param,
+ NetParameter* param_upgraded_pad);
+
+// Upgrade a single V0LayerConnection to the V1LayerParameter format.
+bool UpgradeV0LayerParameter(const V1LayerParameter& v0_layer_connection,
+ V1LayerParameter* layer_param);
+
+V1LayerParameter_LayerType UpgradeV0LayerType(const string& type);
+
+// Return true iff any layer contains deprecated data transformation parameters.
+bool NetNeedsDataUpgrade(const NetParameter& net_param);
+
+// Perform all necessary transformations to upgrade old transformation fields
+// into a TransformationParameter.
+void UpgradeNetDataTransformation(NetParameter* net_param);
+
+// Return true iff the Net contains any layers specified as V1LayerParameters.
+bool NetNeedsV1ToV2Upgrade(const NetParameter& net_param);
+
+// Perform all necessary transformations to upgrade a NetParameter with
+// deprecated V1LayerParameters.
+bool UpgradeV1Net(const NetParameter& v1_net_param, NetParameter* net_param);
+
+bool UpgradeV1LayerParameter(const V1LayerParameter& v1_layer_param,
+ LayerParameter* layer_param);
+
+const char* UpgradeV1LayerType(const V1LayerParameter_LayerType type);
+
+bool NetNeedsBatchNormUpgrade(const NetParameter& net_param);
+
+void UpgradeNetBatchNorm(NetParameter* net_param);
+
+// Check for deprecations and upgrade the NetParameter as needed.
+bool UpgradeNetAsNeeded(const string& param_file, NetParameter* param);
+
+
+bool NetNeedsUpgrade(const NetParameter& net_param) {
+ return NetNeedsV0ToV1Upgrade(net_param) || NetNeedsV1ToV2Upgrade(net_param) ||
+ NetNeedsBatchNormUpgrade(net_param);
+}
+
+bool NetNeedsV0ToV1Upgrade(const NetParameter& net_param) {
+ for (int i = 0; i < net_param.layers_size(); ++i) {
+ if (net_param.layers(i).has_layer()) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool NetNeedsV1ToV2Upgrade(const NetParameter& net_param) {
+ return net_param.layers_size() > 0;
+}
+
+bool UpgradeV0Net(const NetParameter& v0_net_param_padding_layers,
+ NetParameter* net_param) {
+ // First upgrade padding layers to padded conv layers.
+ NetParameter v0_net_param;
+ UpgradeV0PaddingLayers(v0_net_param_padding_layers, &v0_net_param);
+ // Now upgrade layer parameters.
+ bool is_fully_compatible = true;
+ net_param->Clear();
+ if (v0_net_param.has_name()) {
+ net_param->set_name(v0_net_param.name());
+ }
+ for (int i = 0; i < v0_net_param.layers_size(); ++i) {
+ is_fully_compatible &= UpgradeV0LayerParameter(v0_net_param.layers(i),
+ net_param->add_layers());
+ }
+ for (int i = 0; i < v0_net_param.input_size(); ++i) {
+ net_param->add_input(v0_net_param.input(i));
+ }
+ for (int i = 0; i < v0_net_param.input_dim_size(); ++i) {
+ net_param->add_input_dim(v0_net_param.input_dim(i));
+ }
+ if (v0_net_param.has_force_backward()) {
+ net_param->set_force_backward(v0_net_param.force_backward());
+ }
+ return is_fully_compatible;
+}
+
+void UpgradeV0PaddingLayers(const NetParameter& param,
+ NetParameter* param_upgraded_pad) {
+ // Copy everything other than the layers from the original param.
+ param_upgraded_pad->Clear();
+ param_upgraded_pad->CopyFrom(param);
+ param_upgraded_pad->clear_layers();
+ // Figure out which layer each bottom blob comes from.
+ map<string, int> blob_name_to_last_top_idx;
+ for (int i = 0; i < param.input_size(); ++i) {
+ const string& blob_name = param.input(i);
+ blob_name_to_last_top_idx[blob_name] = -1;
+ }
+ for (int i = 0; i < param.layers_size(); ++i) {
+ const V1LayerParameter& layer_connection = param.layers(i);
+ const V0LayerParameter& layer_param = layer_connection.layer();
+ // Add the layer to the new net, unless it's a padding layer.
+ if (layer_param.type() != "padding") {
+ param_upgraded_pad->add_layers()->CopyFrom(layer_connection);
+ }
+ for (int j = 0; j < layer_connection.bottom_size(); ++j) {
+ const string& blob_name = layer_connection.bottom(j);
+ if (blob_name_to_last_top_idx.find(blob_name) ==
+ blob_name_to_last_top_idx.end()) {
+ LOG(FATAL) << "Unknown blob input " << blob_name << " to layer " << j;
+ }
+ const int top_idx = blob_name_to_last_top_idx[blob_name];
+ if (top_idx == -1) {
+ continue;
+ }
+ const V1LayerParameter& source_layer = param.layers(top_idx);
+ if (source_layer.layer().type() == "padding") {
+ // This layer has a padding layer as input -- check that it is a conv
+ // layer or a pooling layer and takes only one input. Also check that
+ // the padding layer input has only one input and one output. Other
+ // cases have undefined behavior in Caffe.
+ CHECK((layer_param.type() == "conv") || (layer_param.type() == "pool"))
+ << "Padding layer input to "
+ "non-convolutional / non-pooling layer type "
+ << layer_param.type();
+ CHECK_EQ(layer_connection.bottom_size(), 1)
+ << "Conv Layer takes a single blob as input.";
+ CHECK_EQ(source_layer.bottom_size(), 1)
+ << "Padding Layer takes a single blob as input.";
+ CHECK_EQ(source_layer.top_size(), 1)
+ << "Padding Layer produces a single blob as output.";
+ int layer_index = param_upgraded_pad->layers_size() - 1;
+ param_upgraded_pad->mutable_layers(layer_index)->mutable_layer()
+ ->set_pad(source_layer.layer().pad());
+ param_upgraded_pad->mutable_layers(layer_index)
+ ->set_bottom(j, source_layer.bottom(0));
+ }
+ }
+ for (int j = 0; j < layer_connection.top_size(); ++j) {
+ const string& blob_name = layer_connection.top(j);
+ blob_name_to_last_top_idx[blob_name] = i;
+ }
+ }
+}
+
+bool UpgradeV0LayerParameter(const V1LayerParameter& v0_layer_connection,
+ V1LayerParameter* layer_param) {
+ bool is_fully_compatible = true;
+ layer_param->Clear();
+ for (int i = 0; i < v0_layer_connection.bottom_size(); ++i) {
+ layer_param->add_bottom(v0_layer_connection.bottom(i));
+ }
+ for (int i = 0; i < v0_layer_connection.top_size(); ++i) {
+ layer_param->add_top(v0_layer_connection.top(i));
+ }
+ if (v0_layer_connection.has_layer()) {
+ const V0LayerParameter& v0_layer_param = v0_layer_connection.layer();
+ if (v0_layer_param.has_name()) {
+ layer_param->set_name(v0_layer_param.name());
+ }
+ const string& type = v0_layer_param.type();
+ if (v0_layer_param.has_type()) {
+ layer_param->set_type(UpgradeV0LayerType(type));
+ }
+ for (int i = 0; i < v0_layer_param.blobs_size(); ++i) {
+ layer_param->add_blobs()->CopyFrom(v0_layer_param.blobs(i));
+ }
+ for (int i = 0; i < v0_layer_param.blobs_lr_size(); ++i) {
+ layer_param->add_blobs_lr(v0_layer_param.blobs_lr(i));
+ }
+ for (int i = 0; i < v0_layer_param.weight_decay_size(); ++i) {
+ layer_param->add_weight_decay(v0_layer_param.weight_decay(i));
+ }
+ if (v0_layer_param.has_num_output()) {
+ if (type == "conv") {
+ layer_param->mutable_convolution_param()->set_num_output(
+ v0_layer_param.num_output());
+ } else if (type == "innerproduct") {
+ layer_param->mutable_inner_product_param()->set_num_output(
+ v0_layer_param.num_output());
+ } else {
+ LOG(ERROR) << "Unknown parameter num_output for layer type " << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_biasterm()) {
+ if (type == "conv") {
+ layer_param->mutable_convolution_param()->set_bias_term(
+ v0_layer_param.biasterm());
+ } else if (type == "innerproduct") {
+ layer_param->mutable_inner_product_param()->set_bias_term(
+ v0_layer_param.biasterm());
+ } else {
+ LOG(ERROR) << "Unknown parameter biasterm for layer type " << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_weight_filler()) {
+ if (type == "conv") {
+ layer_param->mutable_convolution_param()->
+ mutable_weight_filler()->CopyFrom(v0_layer_param.weight_filler());
+ } else if (type == "innerproduct") {
+ layer_param->mutable_inner_product_param()->
+ mutable_weight_filler()->CopyFrom(v0_layer_param.weight_filler());
+ } else {
+ LOG(ERROR) << "Unknown parameter weight_filler for layer type " << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_bias_filler()) {
+ if (type == "conv") {
+ layer_param->mutable_convolution_param()->
+ mutable_bias_filler()->CopyFrom(v0_layer_param.bias_filler());
+ } else if (type == "innerproduct") {
+ layer_param->mutable_inner_product_param()->
+ mutable_bias_filler()->CopyFrom(v0_layer_param.bias_filler());
+ } else {
+ LOG(ERROR) << "Unknown parameter bias_filler for layer type " << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_pad()) {
+ if (type == "conv") {
+ layer_param->mutable_convolution_param()->add_pad(v0_layer_param.pad());
+ } else if (type == "pool") {
+ layer_param->mutable_pooling_param()->set_pad(v0_layer_param.pad());
+ } else {
+ LOG(ERROR) << "Unknown parameter pad for layer type " << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_kernelsize()) {
+ if (type == "conv") {
+ layer_param->mutable_convolution_param()->add_kernel_size(
+ v0_layer_param.kernelsize());
+ } else if (type == "pool") {
+ layer_param->mutable_pooling_param()->set_kernel_size(
+ v0_layer_param.kernelsize());
+ } else {
+ LOG(ERROR) << "Unknown parameter kernelsize for layer type " << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_group()) {
+ if (type == "conv") {
+ layer_param->mutable_convolution_param()->set_group(
+ v0_layer_param.group());
+ } else {
+ LOG(ERROR) << "Unknown parameter group for layer type " << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_stride()) {
+ if (type == "conv") {
+ layer_param->mutable_convolution_param()->add_stride(
+ v0_layer_param.stride());
+ } else if (type == "pool") {
+ layer_param->mutable_pooling_param()->set_stride(
+ v0_layer_param.stride());
+ } else {
+ LOG(ERROR) << "Unknown parameter stride for layer type " << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_pool()) {
+ if (type == "pool") {
+ V0LayerParameter_PoolMethod pool = v0_layer_param.pool();
+ switch (pool) {
+ case V0LayerParameter_PoolMethod_MAX:
+ layer_param->mutable_pooling_param()->set_pool(
+ PoolingParameter_PoolMethod_MAX);
+ break;
+ case V0LayerParameter_PoolMethod_AVE:
+ layer_param->mutable_pooling_param()->set_pool(
+ PoolingParameter_PoolMethod_AVE);
+ break;
+ case V0LayerParameter_PoolMethod_STOCHASTIC:
+ layer_param->mutable_pooling_param()->set_pool(
+ PoolingParameter_PoolMethod_STOCHASTIC);
+ break;
+ default:
+ LOG(ERROR) << "Unknown pool method " << pool;
+ is_fully_compatible = false;
+ }
+ } else {
+ LOG(ERROR) << "Unknown parameter pool for layer type " << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_dropout_ratio()) {
+ if (type == "dropout") {
+ layer_param->mutable_dropout_param()->set_dropout_ratio(
+ v0_layer_param.dropout_ratio());
+ } else {
+ LOG(ERROR) << "Unknown parameter dropout_ratio for layer type " << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_local_size()) {
+ if (type == "lrn") {
+ layer_param->mutable_lrn_param()->set_local_size(
+ v0_layer_param.local_size());
+ } else {
+ LOG(ERROR) << "Unknown parameter local_size for layer type " << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_alpha()) {
+ if (type == "lrn") {
+ layer_param->mutable_lrn_param()->set_alpha(v0_layer_param.alpha());
+ } else {
+ LOG(ERROR) << "Unknown parameter alpha for layer type " << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_beta()) {
+ if (type == "lrn") {
+ layer_param->mutable_lrn_param()->set_beta(v0_layer_param.beta());
+ } else {
+ LOG(ERROR) << "Unknown parameter beta for layer type " << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_k()) {
+ if (type == "lrn") {
+ layer_param->mutable_lrn_param()->set_k(v0_layer_param.k());
+ } else {
+ LOG(ERROR) << "Unknown parameter k for layer type " << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_source()) {
+ if (type == "data") {
+ layer_param->mutable_data_param()->set_source(v0_layer_param.source());
+ } else if (type == "hdf5_data") {
+ layer_param->mutable_hdf5_data_param()->set_source(
+ v0_layer_param.source());
+ } else if (type == "images") {
+ layer_param->mutable_image_data_param()->set_source(
+ v0_layer_param.source());
+ } else if (type == "window_data") {
+ layer_param->mutable_window_data_param()->set_source(
+ v0_layer_param.source());
+ } else if (type == "infogain_loss") {
+ layer_param->mutable_infogain_loss_param()->set_source(
+ v0_layer_param.source());
+ } else {
+ LOG(ERROR) << "Unknown parameter source for layer type " << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_scale()) {
+ layer_param->mutable_transform_param()->
+ set_scale(v0_layer_param.scale());
+ }
+ if (v0_layer_param.has_meanfile()) {
+ layer_param->mutable_transform_param()->
+ set_mean_file(v0_layer_param.meanfile());
+ }
+ if (v0_layer_param.has_batchsize()) {
+ if (type == "data") {
+ layer_param->mutable_data_param()->set_batch_size(
+ v0_layer_param.batchsize());
+ } else if (type == "hdf5_data") {
+ layer_param->mutable_hdf5_data_param()->set_batch_size(
+ v0_layer_param.batchsize());
+ } else if (type == "images") {
+ layer_param->mutable_image_data_param()->set_batch_size(
+ v0_layer_param.batchsize());
+ } else if (type == "window_data") {
+ layer_param->mutable_window_data_param()->set_batch_size(
+ v0_layer_param.batchsize());
+ } else {
+ LOG(ERROR) << "Unknown parameter batchsize for layer type " << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_cropsize()) {
+ layer_param->mutable_transform_param()->
+ set_crop_size(v0_layer_param.cropsize());
+ }
+ if (v0_layer_param.has_mirror()) {
+ layer_param->mutable_transform_param()->
+ set_mirror(v0_layer_param.mirror());
+ }
+ if (v0_layer_param.has_rand_skip()) {
+ if (type == "data") {
+ layer_param->mutable_data_param()->set_rand_skip(
+ v0_layer_param.rand_skip());
+ } else if (type == "images") {
+ layer_param->mutable_image_data_param()->set_rand_skip(
+ v0_layer_param.rand_skip());
+ } else {
+ LOG(ERROR) << "Unknown parameter rand_skip for layer type " << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_shuffle_images()) {
+ if (type == "images") {
+ layer_param->mutable_image_data_param()->set_shuffle(
+ v0_layer_param.shuffle_images());
+ } else {
+ LOG(ERROR) << "Unknown parameter shuffle for layer type " << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_new_height()) {
+ if (type == "images") {
+ layer_param->mutable_image_data_param()->set_new_height(
+ v0_layer_param.new_height());
+ } else {
+ LOG(ERROR) << "Unknown parameter new_height for layer type " << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_new_width()) {
+ if (type == "images") {
+ layer_param->mutable_image_data_param()->set_new_width(
+ v0_layer_param.new_width());
+ } else {
+ LOG(ERROR) << "Unknown parameter new_width for layer type " << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_concat_dim()) {
+ if (type == "concat") {
+ layer_param->mutable_concat_param()->set_concat_dim(
+ v0_layer_param.concat_dim());
+ } else {
+ LOG(ERROR) << "Unknown parameter concat_dim for layer type " << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_det_fg_threshold()) {
+ if (type == "window_data") {
+ layer_param->mutable_window_data_param()->set_fg_threshold(
+ v0_layer_param.det_fg_threshold());
+ } else {
+ LOG(ERROR) << "Unknown parameter det_fg_threshold for layer type "
+ << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_det_bg_threshold()) {
+ if (type == "window_data") {
+ layer_param->mutable_window_data_param()->set_bg_threshold(
+ v0_layer_param.det_bg_threshold());
+ } else {
+ LOG(ERROR) << "Unknown parameter det_bg_threshold for layer type "
+ << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_det_fg_fraction()) {
+ if (type == "window_data") {
+ layer_param->mutable_window_data_param()->set_fg_fraction(
+ v0_layer_param.det_fg_fraction());
+ } else {
+ LOG(ERROR) << "Unknown parameter det_fg_fraction for layer type "
+ << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_det_context_pad()) {
+ if (type == "window_data") {
+ layer_param->mutable_window_data_param()->set_context_pad(
+ v0_layer_param.det_context_pad());
+ } else {
+ LOG(ERROR) << "Unknown parameter det_context_pad for layer type "
+ << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_det_crop_mode()) {
+ if (type == "window_data") {
+ layer_param->mutable_window_data_param()->set_crop_mode(
+ v0_layer_param.det_crop_mode());
+ } else {
+ LOG(ERROR) << "Unknown parameter det_crop_mode for layer type "
+ << type;
+ is_fully_compatible = false;
+ }
+ }
+ if (v0_layer_param.has_hdf5_output_param()) {
+ if (type == "hdf5_output") {
+ layer_param->mutable_hdf5_output_param()->CopyFrom(
+ v0_layer_param.hdf5_output_param());
+ } else {
+ LOG(ERROR) << "Unknown parameter hdf5_output_param for layer type "
+ << type;
+ is_fully_compatible = false;
+ }
+ }
+ }
+ return is_fully_compatible;
+}
+
+V1LayerParameter_LayerType UpgradeV0LayerType(const string& type) {
+ if (type == "accuracy") {
+ return V1LayerParameter_LayerType_ACCURACY;
+ } else if (type == "bnll") {
+ return V1LayerParameter_LayerType_BNLL;
+ } else if (type == "concat") {
+ return V1LayerParameter_LayerType_CONCAT;
+ } else if (type == "conv") {
+ return V1LayerParameter_LayerType_CONVOLUTION;
+ } else if (type == "data") {
+ return V1LayerParameter_LayerType_DATA;
+ } else if (type == "dropout") {
+ return V1LayerParameter_LayerType_DROPOUT;
+ } else if (type == "euclidean_loss") {
+ return V1LayerParameter_LayerType_EUCLIDEAN_LOSS;
+ } else if (type == "flatten") {
+ return V1LayerParameter_LayerType_FLATTEN;
+ } else if (type == "hdf5_data") {
+ return V1LayerParameter_LayerType_HDF5_DATA;
+ } else if (type == "hdf5_output") {
+ return V1LayerParameter_LayerType_HDF5_OUTPUT;
+ } else if (type == "im2col") {
+ return V1LayerParameter_LayerType_IM2COL;
+ } else if (type == "images") {
+ return V1LayerParameter_LayerType_IMAGE_DATA;
+ } else if (type == "infogain_loss") {
+ return V1LayerParameter_LayerType_INFOGAIN_LOSS;
+ } else if (type == "innerproduct") {
+ return V1LayerParameter_LayerType_INNER_PRODUCT;
+ } else if (type == "lrn") {
+ return V1LayerParameter_LayerType_LRN;
+ } else if (type == "multinomial_logistic_loss") {
+ return V1LayerParameter_LayerType_MULTINOMIAL_LOGISTIC_LOSS;
+ } else if (type == "pool") {
+ return V1LayerParameter_LayerType_POOLING;
+ } else if (type == "relu") {
+ return V1LayerParameter_LayerType_RELU;
+ } else if (type == "sigmoid") {
+ return V1LayerParameter_LayerType_SIGMOID;
+ } else if (type == "softmax") {
+ return V1LayerParameter_LayerType_SOFTMAX;
+ } else if (type == "softmax_loss") {
+ return V1LayerParameter_LayerType_SOFTMAX_LOSS;
+ } else if (type == "split") {
+ return V1LayerParameter_LayerType_SPLIT;
+ } else if (type == "tanh") {
+ return V1LayerParameter_LayerType_TANH;
+ } else if (type == "window_data") {
+ return V1LayerParameter_LayerType_WINDOW_DATA;
+ } else {
+ LOG(FATAL) << "Unknown layer name: " << type;
+ return V1LayerParameter_LayerType_NONE;
+ }
+}
+
+bool NetNeedsDataUpgrade(const NetParameter& net_param) {
+ for (int i = 0; i < net_param.layers_size(); ++i) {
+ if (net_param.layers(i).type() == V1LayerParameter_LayerType_DATA) {
+ DataParameter layer_param = net_param.layers(i).data_param();
+ if (layer_param.has_scale()) { return true; }
+ if (layer_param.has_mean_file()) { return true; }
+ if (layer_param.has_crop_size()) { return true; }
+ if (layer_param.has_mirror()) { return true; }
+ }
+ if (net_param.layers(i).type() == V1LayerParameter_LayerType_IMAGE_DATA) {
+ ImageDataParameter layer_param = net_param.layers(i).image_data_param();
+ if (layer_param.has_scale()) { return true; }
+ if (layer_param.has_mean_file()) { return true; }
+ if (layer_param.has_crop_size()) { return true; }
+ if (layer_param.has_mirror()) { return true; }
+ }
+ if (net_param.layers(i).type() == V1LayerParameter_LayerType_WINDOW_DATA) {
+ WindowDataParameter layer_param = net_param.layers(i).window_data_param();
+ if (layer_param.has_scale()) { return true; }
+ if (layer_param.has_mean_file()) { return true; }
+ if (layer_param.has_crop_size()) { return true; }
+ if (layer_param.has_mirror()) { return true; }
+ }
+ }
+ return false;
+}
+
+#define CONVERT_LAYER_TRANSFORM_PARAM(TYPE, Name, param_name) \
+ do { \
+ if (net_param->layers(i).type() == V1LayerParameter_LayerType_##TYPE) { \
+ Name##Parameter* layer_param = \
+ net_param->mutable_layers(i)->mutable_##param_name##_param(); \
+ TransformationParameter* transform_param = \
+ net_param->mutable_layers(i)->mutable_transform_param(); \
+ if (layer_param->has_scale()) { \
+ transform_param->set_scale(layer_param->scale()); \
+ layer_param->clear_scale(); \
+ } \
+ if (layer_param->has_mean_file()) { \
+ transform_param->set_mean_file(layer_param->mean_file()); \
+ layer_param->clear_mean_file(); \
+ } \
+ if (layer_param->has_crop_size()) { \
+ transform_param->set_crop_size(layer_param->crop_size()); \
+ layer_param->clear_crop_size(); \
+ } \
+ if (layer_param->has_mirror()) { \
+ transform_param->set_mirror(layer_param->mirror()); \
+ layer_param->clear_mirror(); \
+ } \
+ } \
+ } while (0)
+
+void UpgradeNetDataTransformation(NetParameter* net_param) {
+ for (int i = 0; i < net_param->layers_size(); ++i) {
+ CONVERT_LAYER_TRANSFORM_PARAM(DATA, Data, data);
+ CONVERT_LAYER_TRANSFORM_PARAM(IMAGE_DATA, ImageData, image_data);
+ CONVERT_LAYER_TRANSFORM_PARAM(WINDOW_DATA, WindowData, window_data);
+ }
+}
+
+bool UpgradeNetAsNeeded(const string& param_file, NetParameter* param) {
+ bool success = true;
+ if (NetNeedsV0ToV1Upgrade(*param)) {
+ // NetParameter was specified using the old style (V0LayerParameter); try to
+ // upgrade it.
+ LOG(ERROR) << "Attempting to upgrade input file specified using deprecated "
+ << "V0LayerParameter: " << param_file;
+ NetParameter original_param(*param);
+ if (!UpgradeV0Net(original_param, param)) {
+ success = false;
+ LOG(ERROR) << "Warning: had one or more problems upgrading "
+ << "V0NetParameter to NetParameter (see above); continuing anyway.";
+ } else {
+ LOG(INFO) << "Successfully upgraded file specified using deprecated "
+ << "V0LayerParameter";
+ }
+ LOG(ERROR) << "Note that future Caffe releases will not support "
+ << "V0NetParameter; use ./build/tools/upgrade_net_proto_text for "
+ << "prototxt and ./build/tools/upgrade_net_proto_binary for model "
+ << "weights upgrade this and any other net protos to the new format.";
+ }
+ // NetParameter uses old style data transformation fields; try to upgrade it.
+ if (NetNeedsDataUpgrade(*param)) {
+ LOG(ERROR) << "Attempting to upgrade input file specified using deprecated "
+ << "transformation parameters: " << param_file;
+ UpgradeNetDataTransformation(param);
+ LOG(INFO) << "Successfully upgraded file specified using deprecated "
+ << "data transformation parameters.";
+ LOG(ERROR) << "Note that future Caffe releases will only support "
+ << "transform_param messages for transformation fields.";
+ }
+ if (NetNeedsV1ToV2Upgrade(*param)) {
+ LOG(ERROR) << "Attempting to upgrade input file specified using deprecated "
+ << "V1LayerParameter: " << param_file;
+ NetParameter original_param(*param);
+ if (!UpgradeV1Net(original_param, param)) {
+ success = false;
+ LOG(ERROR) << "Warning: had one or more problems upgrading "
+ << "V1LayerParameter (see above); continuing anyway.";
+ } else {
+ LOG(INFO) << "Successfully upgraded file specified using deprecated "
+ << "V1LayerParameter";
+ }
+ }
+ // NetParameter uses old style batch norm layers; try to upgrade it.
+ if (NetNeedsBatchNormUpgrade(*param)) {
+ LOG(INFO) << "Attempting to upgrade batch norm layers using deprecated "
+ << "params: " << param_file;
+ UpgradeNetBatchNorm(param);
+ LOG(INFO) << "Successfully upgraded batch norm layers using deprecated "
+ << "params.";
+ }
+ return success;
+}
+
+bool UpgradeV1Net(const NetParameter& v1_net_param, NetParameter* net_param) {
+ bool is_fully_compatible = true;
+ if (v1_net_param.layer_size() > 0) {
+ LOG(ERROR) << "Input NetParameter to be upgraded already specifies 'layer' "
+ << "fields; these will be ignored for the upgrade.";
+ is_fully_compatible = false;
+ }
+ net_param->CopyFrom(v1_net_param);
+ net_param->clear_layers();
+ net_param->clear_layer();
+ for (int i = 0; i < v1_net_param.layers_size(); ++i) {
+ if (!UpgradeV1LayerParameter(v1_net_param.layers(i),
+ net_param->add_layer())) {
+ LOG(ERROR) << "Upgrade of input layer " << i << " failed.";
+ is_fully_compatible = false;
+ }
+ }
+ return is_fully_compatible;
+}
+
+bool NetNeedsBatchNormUpgrade(const NetParameter& net_param) {
+ for (int i = 0; i < net_param.layer_size(); ++i) {
+ // Check if BatchNorm layers declare three parameters, as required by
+ // the previous BatchNorm layer definition.
+ if (net_param.layer(i).type() == "BatchNorm"
+ && net_param.layer(i).param_size() == 3) {
+ return true;
+ }
+ }
+ return false;
+}
+
+void UpgradeNetBatchNorm(NetParameter* net_param) {
+ for (int i = 0; i < net_param->layer_size(); ++i) {
+ // Check if BatchNorm layers declare three parameters, as required by
+ // the previous BatchNorm layer definition.
+ if (net_param->layer(i).type() == "BatchNorm"
+ && net_param->layer(i).param_size() == 3) {
+ net_param->mutable_layer(i)->clear_param();
+ }
+ }
+}
+
+bool UpgradeV1LayerParameter(const V1LayerParameter& v1_layer_param,
+ LayerParameter* layer_param) {
+ layer_param->Clear();
+ bool is_fully_compatible = true;
+ for (int i = 0; i < v1_layer_param.bottom_size(); ++i) {
+ layer_param->add_bottom(v1_layer_param.bottom(i));
+ }
+ for (int i = 0; i < v1_layer_param.top_size(); ++i) {
+ layer_param->add_top(v1_layer_param.top(i));
+ }
+ if (v1_layer_param.has_name()) {
+ layer_param->set_name(v1_layer_param.name());
+ }
+ for (int i = 0; i < v1_layer_param.include_size(); ++i) {
+ layer_param->add_include()->CopyFrom(v1_layer_param.include(i));
+ }
+ for (int i = 0; i < v1_layer_param.exclude_size(); ++i) {
+ layer_param->add_exclude()->CopyFrom(v1_layer_param.exclude(i));
+ }
+ if (v1_layer_param.has_type()) {
+ layer_param->set_type(UpgradeV1LayerType(v1_layer_param.type()));
+ }
+ for (int i = 0; i < v1_layer_param.blobs_size(); ++i) {
+ layer_param->add_blobs()->CopyFrom(v1_layer_param.blobs(i));
+ }
+ for (int i = 0; i < v1_layer_param.param_size(); ++i) {
+ while (layer_param->param_size() <= i) { layer_param->add_param(); }
+ layer_param->mutable_param(i)->set_name(v1_layer_param.param(i));
+ }
+ ParamSpec_DimCheckMode mode;
+ for (int i = 0; i < v1_layer_param.blob_share_mode_size(); ++i) {
+ while (layer_param->param_size() <= i) { layer_param->add_param(); }
+ switch (v1_layer_param.blob_share_mode(i)) {
+ case V1LayerParameter_DimCheckMode_STRICT:
+ mode = ParamSpec_DimCheckMode_STRICT;
+ break;
+ case V1LayerParameter_DimCheckMode_PERMISSIVE:
+ mode = ParamSpec_DimCheckMode_PERMISSIVE;
+ break;
+ default:
+ LOG(FATAL) << "Unknown blob_share_mode: "
+ << v1_layer_param.blob_share_mode(i);
+ break;
+ }
+ layer_param->mutable_param(i)->set_share_mode(mode);
+ }
+ for (int i = 0; i < v1_layer_param.blobs_lr_size(); ++i) {
+ while (layer_param->param_size() <= i) { layer_param->add_param(); }
+ layer_param->mutable_param(i)->set_lr_mult(v1_layer_param.blobs_lr(i));
+ }
+ for (int i = 0; i < v1_layer_param.weight_decay_size(); ++i) {
+ while (layer_param->param_size() <= i) { layer_param->add_param(); }
+ layer_param->mutable_param(i)->set_decay_mult(
+ v1_layer_param.weight_decay(i));
+ }
+ for (int i = 0; i < v1_layer_param.loss_weight_size(); ++i) {
+ layer_param->add_loss_weight(v1_layer_param.loss_weight(i));
+ }
+ if (v1_layer_param.has_accuracy_param()) {
+ layer_param->mutable_accuracy_param()->CopyFrom(
+ v1_layer_param.accuracy_param());
+ }
+ if (v1_layer_param.has_argmax_param()) {
+ layer_param->mutable_argmax_param()->CopyFrom(
+ v1_layer_param.argmax_param());
+ }
+ if (v1_layer_param.has_concat_param()) {
+ layer_param->mutable_concat_param()->CopyFrom(
+ v1_layer_param.concat_param());
+ }
+ if (v1_layer_param.has_contrastive_loss_param()) {
+ layer_param->mutable_contrastive_loss_param()->CopyFrom(
+ v1_layer_param.contrastive_loss_param());
+ }
+ if (v1_layer_param.has_convolution_param()) {
+ layer_param->mutable_convolution_param()->CopyFrom(
+ v1_layer_param.convolution_param());
+ }
+ if (v1_layer_param.has_data_param()) {
+ layer_param->mutable_data_param()->CopyFrom(
+ v1_layer_param.data_param());
+ }
+ if (v1_layer_param.has_dropout_param()) {
+ layer_param->mutable_dropout_param()->CopyFrom(
+ v1_layer_param.dropout_param());
+ }
+ if (v1_layer_param.has_dummy_data_param()) {
+ layer_param->mutable_dummy_data_param()->CopyFrom(
+ v1_layer_param.dummy_data_param());
+ }
+ if (v1_layer_param.has_eltwise_param()) {
+ layer_param->mutable_eltwise_param()->CopyFrom(
+ v1_layer_param.eltwise_param());
+ }
+ if (v1_layer_param.has_exp_param()) {
+ layer_param->mutable_exp_param()->CopyFrom(
+ v1_layer_param.exp_param());
+ }
+ if (v1_layer_param.has_hdf5_data_param()) {
+ layer_param->mutable_hdf5_data_param()->CopyFrom(
+ v1_layer_param.hdf5_data_param());
+ }
+ if (v1_layer_param.has_hdf5_output_param()) {
+ layer_param->mutable_hdf5_output_param()->CopyFrom(
+ v1_layer_param.hdf5_output_param());
+ }
+ if (v1_layer_param.has_hinge_loss_param()) {
+ layer_param->mutable_hinge_loss_param()->CopyFrom(
+ v1_layer_param.hinge_loss_param());
+ }
+ if (v1_layer_param.has_image_data_param()) {
+ layer_param->mutable_image_data_param()->CopyFrom(
+ v1_layer_param.image_data_param());
+ }
+ if (v1_layer_param.has_infogain_loss_param()) {
+ layer_param->mutable_infogain_loss_param()->CopyFrom(
+ v1_layer_param.infogain_loss_param());
+ }
+ if (v1_layer_param.has_inner_product_param()) {
+ layer_param->mutable_inner_product_param()->CopyFrom(
+ v1_layer_param.inner_product_param());
+ }
+ if (v1_layer_param.has_lrn_param()) {
+ layer_param->mutable_lrn_param()->CopyFrom(
+ v1_layer_param.lrn_param());
+ }
+ if (v1_layer_param.has_memory_data_param()) {
+ layer_param->mutable_memory_data_param()->CopyFrom(
+ v1_layer_param.memory_data_param());
+ }
+ if (v1_layer_param.has_mvn_param()) {
+ layer_param->mutable_mvn_param()->CopyFrom(
+ v1_layer_param.mvn_param());
+ }
+ if (v1_layer_param.has_pooling_param()) {
+ layer_param->mutable_pooling_param()->CopyFrom(
+ v1_layer_param.pooling_param());
+ }
+ if (v1_layer_param.has_power_param()) {
+ layer_param->mutable_power_param()->CopyFrom(
+ v1_layer_param.power_param());
+ }
+ if (v1_layer_param.has_relu_param()) {
+ layer_param->mutable_relu_param()->CopyFrom(
+ v1_layer_param.relu_param());
+ }
+ if (v1_layer_param.has_sigmoid_param()) {
+ layer_param->mutable_sigmoid_param()->CopyFrom(
+ v1_layer_param.sigmoid_param());
+ }
+ if (v1_layer_param.has_softmax_param()) {
+ layer_param->mutable_softmax_param()->CopyFrom(
+ v1_layer_param.softmax_param());
+ }
+ if (v1_layer_param.has_slice_param()) {
+ layer_param->mutable_slice_param()->CopyFrom(
+ v1_layer_param.slice_param());
+ }
+ if (v1_layer_param.has_tanh_param()) {
+ layer_param->mutable_tanh_param()->CopyFrom(
+ v1_layer_param.tanh_param());
+ }
+ if (v1_layer_param.has_threshold_param()) {
+ layer_param->mutable_threshold_param()->CopyFrom(
+ v1_layer_param.threshold_param());
+ }
+ if (v1_layer_param.has_window_data_param()) {
+ layer_param->mutable_window_data_param()->CopyFrom(
+ v1_layer_param.window_data_param());
+ }
+ if (v1_layer_param.has_transform_param()) {
+ layer_param->mutable_transform_param()->CopyFrom(
+ v1_layer_param.transform_param());
+ }
+ if (v1_layer_param.has_loss_param()) {
+ layer_param->mutable_loss_param()->CopyFrom(
+ v1_layer_param.loss_param());
+ }
+ if (v1_layer_param.has_layer()) {
+ LOG(ERROR) << "Input NetParameter has V0 layer -- ignoring.";
+ is_fully_compatible = false;
+ }
+ return is_fully_compatible;
+}
+
+const char* UpgradeV1LayerType(const V1LayerParameter_LayerType type) {
+ switch (type) {
+ case V1LayerParameter_LayerType_NONE:
+ return "";
+ case V1LayerParameter_LayerType_ABSVAL:
+ return "AbsVal";
+ case V1LayerParameter_LayerType_ACCURACY:
+ return "Accuracy";
+ case V1LayerParameter_LayerType_ARGMAX:
+ return "ArgMax";
+ case V1LayerParameter_LayerType_BNLL:
+ return "BNLL";
+ case V1LayerParameter_LayerType_CONCAT:
+ return "Concat";
+ case V1LayerParameter_LayerType_CONTRASTIVE_LOSS:
+ return "ContrastiveLoss";
+ case V1LayerParameter_LayerType_CONVOLUTION:
+ return "Convolution";
+ case V1LayerParameter_LayerType_DECONVOLUTION:
+ return "Deconvolution";
+ case V1LayerParameter_LayerType_DATA:
+ return "Data";
+ case V1LayerParameter_LayerType_DROPOUT:
+ return "Dropout";
+ case V1LayerParameter_LayerType_DUMMY_DATA:
+ return "DummyData";
+ case V1LayerParameter_LayerType_EUCLIDEAN_LOSS:
+ return "EuclideanLoss";
+ case V1LayerParameter_LayerType_ELTWISE:
+ return "Eltwise";
+ case V1LayerParameter_LayerType_EXP:
+ return "Exp";
+ case V1LayerParameter_LayerType_FLATTEN:
+ return "Flatten";
+ case V1LayerParameter_LayerType_HDF5_DATA:
+ return "HDF5Data";
+ case V1LayerParameter_LayerType_HDF5_OUTPUT:
+ return "HDF5Output";
+ case V1LayerParameter_LayerType_HINGE_LOSS:
+ return "HingeLoss";
+ case V1LayerParameter_LayerType_IM2COL:
+ return "Im2col";
+ case V1LayerParameter_LayerType_IMAGE_DATA:
+ return "ImageData";
+ case V1LayerParameter_LayerType_INFOGAIN_LOSS:
+ return "InfogainLoss";
+ case V1LayerParameter_LayerType_INNER_PRODUCT:
+ return "InnerProduct";
+ case V1LayerParameter_LayerType_LRN:
+ return "LRN";
+ case V1LayerParameter_LayerType_MEMORY_DATA:
+ return "MemoryData";
+ case V1LayerParameter_LayerType_MULTINOMIAL_LOGISTIC_LOSS:
+ return "MultinomialLogisticLoss";
+ case V1LayerParameter_LayerType_MVN:
+ return "MVN";
+ case V1LayerParameter_LayerType_POOLING:
+ return "Pooling";
+ case V1LayerParameter_LayerType_POWER:
+ return "Power";
+ case V1LayerParameter_LayerType_RELU:
+ return "ReLU";
+ case V1LayerParameter_LayerType_SIGMOID:
+ return "Sigmoid";
+ case V1LayerParameter_LayerType_SIGMOID_CROSS_ENTROPY_LOSS:
+ return "SigmoidCrossEntropyLoss";
+ case V1LayerParameter_LayerType_SILENCE:
+ return "Silence";
+ case V1LayerParameter_LayerType_SOFTMAX:
+ return "Softmax";
+ case V1LayerParameter_LayerType_SOFTMAX_LOSS:
+ return "SoftmaxWithLoss";
+ case V1LayerParameter_LayerType_SPLIT:
+ return "Split";
+ case V1LayerParameter_LayerType_SLICE:
+ return "Slice";
+ case V1LayerParameter_LayerType_TANH:
+ return "TanH";
+ case V1LayerParameter_LayerType_WINDOW_DATA:
+ return "WindowData";
+ case V1LayerParameter_LayerType_THRESHOLD:
+ return "Threshold";
+ default:
+ LOG(FATAL) << "Unknown V1LayerParameter layer type: " << type;
+ return "";
+ }
+}
+
+const int kProtoReadBytesLimit = INT_MAX; // Max size of 2 GB minus 1 byte.
+
+bool ReadProtoFromTextFile(const char* filename, Message* proto) {
+ std::ifstream fs(filename, std::ifstream::in);
+ CHECK(fs.is_open()) << "Can't open \"" << filename << "\"";
+ IstreamInputStream input(&fs);
+ bool success = google::protobuf::TextFormat::Parse(&input, proto);
+ fs.close();
+ return success;
+}
+
+bool ReadProtoFromBinaryFile(const char* filename, Message* proto) {
+ std::ifstream fs(filename, std::ifstream::in | std::ifstream::binary);
+ CHECK(fs.is_open()) << "Can't open \"" << filename << "\"";
+ ZeroCopyInputStream* raw_input = new IstreamInputStream(&fs);
+ CodedInputStream* coded_input = new CodedInputStream(raw_input);
+ coded_input->SetTotalBytesLimit(kProtoReadBytesLimit, 536870912);
+
+ bool success = proto->ParseFromCodedStream(coded_input);
+
+ delete coded_input;
+ delete raw_input;
+ fs.close();
+ return success;
+}
+
+void ReadNetParamsFromTextFileOrDie(const char* param_file,
+ NetParameter* param) {
+ CHECK(ReadProtoFromTextFile(param_file, param))
+ << "Failed to parse NetParameter file: " << param_file;
+ UpgradeNetAsNeeded(param_file, param);
+}
+
+void ReadNetParamsFromBinaryFileOrDie(const char* param_file,
+ NetParameter* param) {
+ CHECK(ReadProtoFromBinaryFile(param_file, param))
+ << "Failed to parse NetParameter file: " << param_file;
+ UpgradeNetAsNeeded(param_file, param);
+}
+
+}
+}
+#endif
diff --git a/modules/dnn/src/caffe/caffe_io.hpp b/modules/dnn/src/caffe/caffe_io.hpp
new file mode 100644
index 0000000..09bc570
--- /dev/null
+++ b/modules/dnn/src/caffe/caffe_io.hpp
@@ -0,0 +1,108 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//COPYRIGHT
+//
+//All contributions by the University of California:
+//Copyright (c) 2014, The Regents of the University of California (Regents)
+//All rights reserved.
+//
+//All other contributions:
+//Copyright (c) 2014, the respective contributors
+//All rights reserved.
+//
+//Caffe uses a shared copyright model: each contributor holds copyright over
+//their contributions to Caffe. The project versioning records all such
+//contribution and copyright details. If a contributor wants to further mark
+//their specific copyright on a particular contribution, they should indicate
+//their copyright solely in the commit message of the change when it is
+//committed.
+//
+//LICENSE
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions are met:
+//
+//1. Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+//ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+//DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+//ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+//(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+//ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+//(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+//CONTRIBUTION AGREEMENT
+//
+//By contributing to the BVLC/caffe repository through pull-request, comment,
+//or otherwise, the contributor releases their content to the
+//license and copyright terms herein.
+//
+//M*/
+
+#ifndef __OPENCV_DNN_CAFFE_IO_HPP__
+#define __OPENCV_DNN_CAFFE_IO_HPP__
+#ifdef HAVE_PROTOBUF
+
+#include "caffe.pb.h"
+
+namespace cv {
+namespace dnn {
+
+// Read parameters from a file into a NetParameter proto message.
+void ReadNetParamsFromTextFileOrDie(const char* param_file,
+ caffe::NetParameter* param);
+void ReadNetParamsFromBinaryFileOrDie(const char* param_file,
+ caffe::NetParameter* param);
+
+}
+}
+#endif
+#endif
diff --git a/modules/dnn/src/caffe/glog_emulator.hpp b/modules/dnn/src/caffe/glog_emulator.hpp
new file mode 100644
index 0000000..44976fb
--- /dev/null
+++ b/modules/dnn/src/caffe/glog_emulator.hpp
@@ -0,0 +1,106 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#ifndef __OPENCV_DNN_CAFFE_GLOG_EMULATOR_HPP__
+#define __OPENCV_DNN_CAFFE_GLOG_EMULATOR_HPP__
+#include <cstdlib>
+#include <iostream>
+#include <sstream>
+#include <opencv2/core.hpp>
+
+#define CHECK(cond) for(cv::dnn::GLogWrapper _logger(__FILE__, CV_Func, __LINE__, "CHECK", #cond, cond); _logger.exit(); _logger.check()) _logger.stream()
+#define CHECK_EQ(a, b) for(cv::dnn::GLogWrapper _logger(__FILE__, CV_Func, __LINE__, "CHECK", #a"="#b, ((a) == (b))); _logger.exit(); _logger.check()) _logger.stream()
+#define LOG(TYPE) for(cv::dnn::GLogWrapper _logger(__FILE__, CV_Func, __LINE__, #TYPE); _logger.exit(); _logger.check()) _logger.stream()
+
+namespace cv
+{
+namespace dnn
+{
+
+class GLogWrapper
+{
+ const char *file, *func, *type, *cond_str;
+ int line;
+ bool cond_status, exit_loop;
+ std::stringstream sstream;
+
+public:
+
+ GLogWrapper(const char *_file, const char *_func, int _line,
+ const char *_type,
+ const char *_cond_str = NULL, bool _cond_status = true
+ ) :
+ file(_file), func(_func), type(_type), cond_str(_cond_str),
+ line(_line), cond_status(_cond_status), exit_loop(true) {}
+
+ std::iostream &stream()
+ {
+ return sstream;
+ }
+
+ bool exit()
+ {
+ return exit_loop;
+ }
+
+ void check()
+ {
+ exit_loop = false;
+
+ if (cond_str && !cond_status)
+ {
+ cv::error(cv::Error::StsError, "FAILED: " + String(cond_str) + ". " + sstream.str(), func, file, line);
+ }
+ else if (!cond_str && strcmp(type, "CHECK"))
+ {
+ #ifndef NDEBUG
+ if (!std::strcmp(type, "INFO"))
+ std::cout << sstream.str() << std::endl;
+ else
+ std::cerr << sstream.str() << std::endl;
+ #endif
+ }
+ }
+};
+
+}
+}
+#endif
diff --git a/modules/dnn/src/dnn.cpp b/modules/dnn/src/dnn.cpp
new file mode 100644
index 0000000..5529cad
--- /dev/null
+++ b/modules/dnn/src/dnn.cpp
@@ -0,0 +1,2263 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "precomp.hpp"
+#include "op_halide.hpp"
+#include "halide_scheduler.hpp"
+#include <set>
+#include <algorithm>
+#include <iostream>
+#include <sstream>
+#include <iterator>
+#include <opencv2/dnn/shape_utils.hpp>
+#include <opencv2/imgproc.hpp>
+
+namespace cv {
+namespace dnn {
+CV__DNN_EXPERIMENTAL_NS_BEGIN
+
+using std::vector;
+using std::map;
+using std::make_pair;
+using std::set;
+
+namespace
+{
+ typedef std::vector<MatShape> ShapesVec;
+
+ struct LayerShapes
+ {
+ ShapesVec in, out, internal;
+ // No guarantees that layer which support in-place computations
+ // will be computed in-place (input.data_ptr == output.data_ptr).
+ // If layer said that it could work in-place and layers after it
+ // no longer use input blob, we'll set output = input.
+ bool supportInPlace;
+ LayerShapes() {supportInPlace = false;}
+ };
+}
+
+template<typename T>
+static String toString(const T &v)
+{
+ std::ostringstream ss;
+ ss << v;
+ return ss.str();
+}
+
+Mat blobFromImage(const Mat& image, double scalefactor, const Size& size,
+ const Scalar& mean, bool swapRB)
+{
+ CV_TRACE_FUNCTION();
+ std::vector<Mat> images(1, image);
+ return blobFromImages(images, scalefactor, size, mean, swapRB);
+}
+
+Mat blobFromImages(const std::vector<Mat>& images_, double scalefactor, Size size,
+ const Scalar& mean_, bool swapRB)
+{
+ CV_TRACE_FUNCTION();
+ std::vector<Mat> images = images_;
+ for (int i = 0; i < images.size(); i++)
+ {
+ Size imgSize = images[i].size();
+ if (size == Size())
+ size = imgSize;
+ if (size != imgSize)
+ {
+ float resizeFactor = std::max(size.width / (float)imgSize.width,
+ size.height / (float)imgSize.height);
+ resize(images[i], images[i], Size(), resizeFactor, resizeFactor);
+ Rect crop(Point(0.5 * (images[i].cols - size.width),
+ 0.5 * (images[i].rows - size.height)),
+ size);
+ images[i] = images[i](crop);
+ }
+ if(images[i].depth() == CV_8U)
+ images[i].convertTo(images[i], CV_32F);
+ Scalar mean = mean_;
+ if (swapRB)
+ std::swap(mean[0], mean[2]);
+
+ images[i] -= mean;
+ images[i] *= scalefactor;
+ }
+
+ size_t i, nimages = images.size();
+ if(nimages == 0)
+ return Mat();
+ Mat image0 = images[0];
+ int nch = image0.channels();
+ CV_Assert(image0.dims == 2);
+ Mat blob, image;
+ if (nch == 3 || nch == 4)
+ {
+ int sz[] = { (int)nimages, 3, image0.rows, image0.cols };
+ blob = Mat(4, sz, CV_32F);
+ Mat ch[4];
+
+ for( i = 0; i < nimages; i++ )
+ {
+ image = images[i];
+ CV_Assert(image.depth() == CV_32F);
+ nch = image.channels();
+ CV_Assert(image.dims == 2 && (nch == 3 || nch == 4));
+ CV_Assert(image.size() == image0.size());
+
+ for( int j = 0; j < 3; j++ )
+ ch[j] = Mat(image.rows, image.cols, CV_32F, blob.ptr((int)i, j));
+ if(swapRB)
+ std::swap(ch[0], ch[2]);
+ split(image, ch);
+ }
+ }
+ else
+ {
+ CV_Assert(nch == 1);
+ int sz[] = { (int)nimages, 1, image0.rows, image0.cols };
+ blob = Mat(4, sz, CV_32F);
+
+ for( i = 0; i < nimages; i++ )
+ {
+ Mat image = images[i];
+ CV_Assert(image.depth() == CV_32F);
+ nch = image.channels();
+ CV_Assert(image.dims == 2 && (nch == 1));
+ CV_Assert(image.size() == image0.size());
+
+ image.copyTo(Mat(image.rows, image.cols, CV_32F, blob.ptr((int)i, 0)));
+ }
+ }
+ return blob;
+}
+
+struct LayerPin
+{
+ int lid;
+ int oid;
+
+ LayerPin(int layerId = -1, int outputId = -1)
+ : lid(layerId), oid(outputId) {}
+
+ bool valid() const
+ {
+ return (lid >= 0 && oid >= 0);
+ }
+
+ bool equal(const LayerPin &r) const
+ {
+ return (lid == r.lid && oid == r.oid);
+ }
+
+ bool operator<(const LayerPin &r) const
+ {
+ return lid < r.lid || lid == r.lid && oid < r.oid;
+ }
+
+ bool operator ==(const LayerPin &r) const
+ {
+ return lid == r.lid && oid == r.oid;
+ }
+};
+
+// Objects of this class manages wrappers. For every CPU memory pointer and shape
+// one and only wrapper. Now it support wrapping for single backend and target.
+class BackendWrapManager
+{
+public:
+ Ptr<BackendWrapper> wrap(const Mat& m, int backendId, int targetId)
+ {
+ CV_TRACE_FUNCTION();
+
+ CV_Assert(backendId != DNN_BACKEND_DEFAULT);
+
+ std::map<void*, Ptr<BackendWrapper> >::iterator hostsIt;
+ // Check that the same CPU memory was previously wrapped.
+ hostsIt = hostWrappers.find(m.data);
+ if (hostsIt == hostWrappers.end())
+ {
+ // If not wrapped before.
+ return (hostWrappers[m.data] = wrapHost(m, backendId, targetId));
+ }
+ else
+ {
+ // Find if wrapper of this host and shape was created before.
+ std::map<std::pair<void*, MatSize>, Ptr<BackendWrapper> >::iterator it;
+ std::pair<void*, MatSize> key(m.data, m.size);
+ it = extraWrappers.find(key);
+ if (it == extraWrappers.end())
+ {
+ MatShape shape(m.dims);
+ for (int i = 0; i < m.dims; ++i)
+ shape[i] = m.size.p[i];
+ return (extraWrappers[key] = wrapUser(hostsIt->second, shape));
+ }
+ else
+ return it->second;
+ }
+ }
+
+ std::vector<Ptr<BackendWrapper> > wrap(const std::vector<Mat*>& mats,
+ int backendId, int targetId)
+ {
+ const int num = mats.size();
+ std::vector<Ptr<BackendWrapper> > dst(num);
+ for (int i = 0; i < num; ++i)
+ {
+ dst[i] = wrap(*mats[i], backendId, targetId);
+ }
+ return dst;
+ }
+
+ std::vector<Ptr<BackendWrapper> > wrap(const std::vector<Mat>& mats,
+ int backendId, int targetId)
+ {
+ const int num = mats.size();
+ std::vector<Ptr<BackendWrapper> > dst(num);
+ for (int i = 0; i < num; ++i)
+ {
+ dst[i] = wrap(mats[i], backendId, targetId);
+ }
+ return dst;
+ }
+
+ void reset()
+ {
+ CV_TRACE_FUNCTION();
+
+ hostWrappers.clear();
+ extraWrappers.clear();
+ }
+
+private:
+ // Backend-specific wrapping function.
+ Ptr<BackendWrapper> wrapHost(const Mat& m, int backendId, int targetId)
+ {
+ if (backendId == DNN_BACKEND_DEFAULT)
+ {
+ return Ptr<BackendWrapper>();
+ }
+ else if (backendId == DNN_BACKEND_HALIDE)
+ {
+ CV_Assert(haveHalide());
+#ifdef HAVE_HALIDE
+ return Ptr<BackendWrapper>(new HalideBackendWrapper(targetId, m));
+#endif // HAVE_HALIDE
+ }
+ else
+ {
+ CV_Error(Error::StsNotImplemented, "Unknown backend identifier");
+ }
+ return Ptr<BackendWrapper>();
+ }
+
+ // Backend-specific wrapping function.
+ Ptr<BackendWrapper> wrapUser(const Ptr<BackendWrapper>& host, const MatShape& shape)
+ {
+ int backendId = host->backendId;
+ if (backendId == DNN_BACKEND_DEFAULT)
+ {
+ return Ptr<BackendWrapper>();
+ }
+ else if (backendId == DNN_BACKEND_HALIDE)
+ {
+ CV_Assert(haveHalide());
+#ifdef HAVE_HALIDE
+ return Ptr<BackendWrapper>(new HalideBackendWrapper(host, shape));
+#endif // HAVE_HALIDE
+ }
+ else
+ {
+ CV_Error(Error::StsNotImplemented, "Unknown backend identifier");
+ }
+ return Ptr<BackendWrapper>();
+ }
+
+ // Wrappers that initialized for memory hosts (first wrapping of CPU data).
+ std::map<void*, Ptr<BackendWrapper> > hostWrappers;
+ // The rest of wrappers. They initialized for non-host cv::Mat.
+ std::map<std::pair<void*, MatSize>, Ptr<BackendWrapper> > extraWrappers;
+};
+
+struct LayerData
+{
+ LayerData() : id(-1), flag(0) {}
+ LayerData(int _id, const String &_name, const String &_type, LayerParams &_params)
+ : id(_id), name(_name), type(_type), params(_params), flag(0)
+ {
+ CV_TRACE_FUNCTION();
+
+ //add logging info
+ params.name = name;
+ params.type = type;
+ }
+
+ int id;
+ String name;
+ String type;
+ LayerParams params;
+
+ std::vector<LayerPin> inputBlobsId;
+ std::set<int> inputLayersId;
+ std::set<int> requiredOutputs;
+ std::vector<LayerPin> consumers;
+
+ Ptr<Layer> layerInstance;
+ std::vector<Mat> outputBlobs;
+ std::vector<Mat*> inputBlobs;
+ std::vector<Mat> internals;
+ // Computation nodes of implemented backends (except DEFAULT).
+ std::map<int, Ptr<BackendNode> > backendNodes;
+ // Flag for skip layer computation for specific backend.
+ std::map<int, bool> skipFlags;
+
+ int flag;
+
+ Ptr<Layer> getLayerInstance()
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(type, "type", type.c_str());
+
+ if (layerInstance)
+ return layerInstance;
+
+ layerInstance = LayerFactory::createLayerInstance(type, params);
+ if (!layerInstance)
+ {
+ CV_Error(Error::StsError, "Can't create layer \"" + name + "\" of type \"" + type + "\"");
+ }
+
+ return layerInstance;
+ }
+};
+
+//fake layer containing network input blobs
+struct DataLayer : public Layer
+{
+ void finalize(const std::vector<Mat*>&, std::vector<Mat>&) {}
+ void forward(std::vector<Mat*>&, std::vector<Mat>&, std::vector<Mat> &) {}
+
+ int outputNameToIndex(String tgtName)
+ {
+ int idx = (int)(std::find(outNames.begin(), outNames.end(), tgtName) - outNames.begin());
+ return (idx < (int)outNames.size()) ? idx : -1;
+ }
+
+ void setNames(const std::vector<String> &names)
+ {
+ outNames.assign(names.begin(), names.end());
+ }
+
+private:
+ std::vector<String> outNames;
+};
+
+struct BlobManager
+{
+public:
+ // Increase references counter to layer output.
+ void addReference(const LayerPin& lp)
+ {
+ std::map<LayerPin, int>::iterator it = refCounter.find(lp);
+ if (it == refCounter.end())
+ refCounter[lp] = 1;
+ else
+ it->second += 1;
+ }
+
+ void addReferences(const std::vector<LayerPin>& pins)
+ {
+ for (int i = 0; i < pins.size(); i++)
+ {
+ addReference(pins[i]);
+ }
+ }
+
+ // Returns number of references to allocated memory that used in specific
+ // layer blob.
+ int numReferences(const LayerPin& lp)
+ {
+ std::map<LayerPin, LayerPin>::iterator mapIt = reuseMap.find(lp);
+ CV_Assert(mapIt != reuseMap.end());
+ LayerPin memHost = mapIt->second;
+
+ std::map<LayerPin, int>::iterator refIt = refCounter.find(memHost);
+ CV_Assert(refIt != refCounter.end());
+ return refIt->second;
+ }
+
+ // Reuse data allocated in <host> inside the <user> blob.
+ void reuse(const LayerPin& host, const LayerPin& user)
+ {
+ CV_Assert(reuseMap.find(user) == reuseMap.end());
+ CV_Assert(reuseMap.find(host) != reuseMap.end());
+ LayerPin memHost = reuseMap[host];
+ reuseMap[user] = memHost;
+ if (refCounter.find(memHost) != refCounter.end())
+ {
+ std::map<LayerPin, int>::iterator userRefIt = refCounter.find(user);
+ if (userRefIt != refCounter.end())
+ {
+ refCounter[memHost] += userRefIt->second;
+ refCounter.erase(userRefIt);
+ }
+ else
+ refCounter[memHost] += 1;
+ }
+ }
+
+ // Decrease references counter to allocated memory inside specific blob.
+ void releaseReference(const LayerPin& lp)
+ {
+ std::map<LayerPin, LayerPin>::iterator mapIt = reuseMap.find(lp);
+ CV_Assert(mapIt != reuseMap.end());
+
+ std::map<LayerPin, int>::iterator refIt = refCounter.find(mapIt->second);
+ CV_Assert(refIt != refCounter.end());
+ CV_Assert(refIt->second > 0);
+ refIt->second -= 1;
+ }
+
+ void releaseReferences(const std::vector<LayerPin>& pins)
+ {
+ for (int i = 0; i < pins.size(); i++)
+ {
+ releaseReference(pins[i]);
+ }
+ }
+
+ void reuseOrCreate(const MatShape& shape, const LayerPin& lp, Mat& dst, bool force)
+ {
+ Mat bestBlob;
+ LayerPin bestBlobPin;
+
+ if( !force )
+ {
+ std::map<LayerPin, Mat>::iterator hostIt;
+ std::map<LayerPin, int>::iterator refIt;
+
+ const int targetTotal = total(shape);
+ int bestBlobTotal = INT_MAX;
+
+ for (hostIt = memHosts.begin(); hostIt != memHosts.end(); ++hostIt)
+ {
+ refIt = refCounter.find(hostIt->first);
+ // Use only blobs that had references before because if not,
+ // it might be used as output.
+ if (refIt != refCounter.end() && refIt->second == 0)
+ {
+ Mat& unusedBlob = hostIt->second;
+ if (unusedBlob.total() >= targetTotal &&
+ unusedBlob.total() < bestBlobTotal)
+ {
+ bestBlobPin = hostIt->first;
+ bestBlob = unusedBlob;
+ bestBlobTotal = unusedBlob.total();
+ }
+ }
+ }
+ }
+ if (!bestBlob.empty())
+ {
+ reuse(bestBlobPin, lp);
+ dst = Mat(shape, CV_32F, bestBlob.data);
+ }
+ else
+ {
+ // if dst already has been allocated with total(shape) elements,
+ // it won't be recrreated and pointer of dst.data remains the same.
+ dst.create(shape, CV_32F);
+ addHost(lp, dst);
+ }
+ }
+
+ void allocateBlobsForLayer(LayerData &ld, const LayerShapes& layerShapes,
+ std::vector<LayerPin>& pinsForInternalBlobs,
+ bool maximizeReuse)
+ {
+ CV_TRACE_FUNCTION();
+
+ pinsForInternalBlobs.clear();
+
+ std::vector<Mat>& outputBlobs = ld.outputBlobs,
+ &internalBlobs = ld.internals;
+
+ const ShapesVec& outShapes = layerShapes.out,
+ internalShapes = layerShapes.internal;
+
+ outputBlobs.resize(std::max((size_t)1, outShapes.size())); //layer produce at least one output blob
+ internalBlobs.resize(internalShapes.size());
+
+ CV_Assert(ld.requiredOutputs.size() <= outShapes.size());
+
+ // Check that layer could work in-place.
+ bool inPlace = false;
+ if (layerShapes.supportInPlace)
+ {
+ if (ld.inputBlobs.size() == 1)
+ {
+ // Get number of references to the input memory.
+ int numRef = numReferences(ld.inputBlobsId[0]);
+ // If current layer is one and only customer of this blob.
+ inPlace = numRef == 1;
+ }
+ }
+
+ ShapesVec shapes(outShapes);
+ shapes.insert(shapes.end(), internalShapes.begin(), internalShapes.end());
+ std::vector<Mat*> blobs;
+ for(int i = 0; i < outputBlobs.size(); i++)
+ {
+ blobs.push_back(&outputBlobs[i]);
+ }
+
+ for(int i = 0; i < internalBlobs.size(); i++)
+ {
+ blobs.push_back(&internalBlobs[i]);
+ if (total(internalShapes[i]))
+ {
+ pinsForInternalBlobs.push_back(LayerPin(ld.id, ld.outputBlobs.size() + i));
+ }
+ }
+
+ addReferences(pinsForInternalBlobs);
+
+ std::map<int, std::vector<int> > idxSizes;
+ for(int i = 0; i < shapes.size(); i++)
+ {
+ idxSizes[total(shapes[i])].push_back(i);
+ }
+
+ std::map<int, std::vector<int> >::reverse_iterator it;
+ bool force = !maximizeReuse && ld.inputBlobsId.size() > 1;
+ for(it = idxSizes.rbegin(); it != idxSizes.rend(); it++)
+ {
+ for(int j = 0; j < it->second.size(); j++)
+ {
+ int index = it->second[j];
+ if (total(shapes[index]))
+ {
+ LayerPin blobPin(ld.id, index);
+ if (index < outShapes.size() && inPlace && !force)
+ {
+ CV_Assert(ld.inputBlobs[0]->total() == total(shapes[index]));
+ ld.outputBlobs[index] = ld.inputBlobs[0]->reshape(1, shapes[index]);
+ reuse(ld.inputBlobsId[0], blobPin);
+ }
+ else
+ {
+ reuseOrCreate(shapes[index], blobPin, *blobs[index], force);
+ }
+ }
+ }
+ }
+ }
+
+ // Clear internal state. Calls before an every reallocation.
+ void reset()
+ {
+ CV_TRACE_FUNCTION();
+
+ refCounter.clear();
+ reuseMap.clear();
+ memHosts.clear();
+ }
+
+private:
+ // Register allocated memory.
+ void addHost(const LayerPin& lp, const Mat& mat)
+ {
+ CV_Assert(memHosts.find(lp) == memHosts.end());
+ reuseMap[lp] = lp;
+ memHosts[lp] = mat;
+ }
+
+ std::map<LayerPin, int> refCounter;
+ // Maps pin to origin blob (for whom memory was allocated firstly).
+ // For origin blobs key == value.
+ std::map<LayerPin, LayerPin> reuseMap;
+ std::map<LayerPin, Mat> memHosts;
+};
+
+struct Net::Impl
+{
+ typedef std::map<int, LayerShapes> LayersShapesMap;
+ typedef std::map<int, LayerData> MapIdToLayerData;
+
+ Impl()
+ {
+ //allocate fake net input layer
+ netInputLayer = Ptr<DataLayer>(new DataLayer());
+ LayerData &inpl = layers.insert( make_pair(0, LayerData()) ).first->second;
+ inpl.id = 0;
+ inpl.name = "_input";
+ inpl.type = "__NetInputLayer__";
+ inpl.layerInstance = netInputLayer;
+ layerNameToId.insert(std::make_pair(inpl.name, inpl.id));
+
+ lastLayerId = 1;
+ netWasAllocated = false;
+ fusion = true;
+ preferableBackend = DNN_BACKEND_DEFAULT;
+ preferableTarget = DNN_TARGET_CPU;
+ }
+
+ Ptr<DataLayer> netInputLayer;
+ std::vector<int> netOutputs;
+ std::vector<LayerPin> blobsToKeep;
+ MapIdToLayerData layers;
+ std::map<String, int> layerNameToId;
+ BlobManager blobManager;
+ int preferableBackend;
+ int preferableTarget;
+ String halideConfigFile;
+ // Backend-specific wrapping manager.
+ BackendWrapManager backendWrapper;
+
+ int lastLayerId;
+
+ bool netWasAllocated;
+ bool fusion;
+
+ void compileHalide()
+ {
+ CV_TRACE_FUNCTION();
+
+ CV_Assert(preferableBackend == DNN_BACKEND_HALIDE);
+
+ HalideScheduler scheduler(halideConfigFile);
+ MapIdToLayerData::iterator it;
+ for (it = layers.begin(); it != layers.end(); ++it)
+ {
+ LayerData &ld = it->second;
+ Ptr<Layer> layer = ld.layerInstance;
+ if (layer->supportBackend(DNN_BACKEND_HALIDE) && !ld.skipFlags[DNN_BACKEND_HALIDE])
+ {
+ CV_Assert(!ld.backendNodes[DNN_BACKEND_HALIDE].empty());
+ bool scheduled = scheduler.process(ld.backendNodes[DNN_BACKEND_HALIDE]);
+ if (!scheduled)
+ {
+ // Use automatic scheduling provided by layer.
+ layer->applyHalideScheduler(ld.backendNodes[DNN_BACKEND_HALIDE],
+ ld.inputBlobs, ld.outputBlobs,
+ preferableTarget);
+ }
+ dnn::compileHalide(ld.outputBlobs, ld.backendNodes[DNN_BACKEND_HALIDE],
+ preferableTarget);
+ }
+ }
+ }
+
+ void clear()
+ {
+ CV_TRACE_FUNCTION();
+
+ MapIdToLayerData::iterator it;
+ for (it = layers.begin(); it != layers.end(); it++)
+ {
+ if (it->second.id != 0) {
+ it->second.inputBlobs.clear();
+ it->second.outputBlobs.clear();
+ it->second.internals.clear();
+ }
+ it->second.skipFlags.clear();
+ //it->second.consumers.clear();
+ Ptr<Layer> currLayer = it->second.layerInstance;
+
+ if( currLayer.empty() )
+ continue;
+
+ currLayer->unsetAttached();
+
+ Ptr<PoolingLayer> poolingLayer = currLayer.dynamicCast<PoolingLayer>();
+ if( !poolingLayer.empty() )
+ {
+ poolingLayer->computeMaxIdx = true;
+ }
+ }
+ it = layers.find(0);
+ CV_Assert(it != layers.end());
+ it->second.skipFlags[DNN_BACKEND_DEFAULT] = true;
+ }
+
+ void setUpNet(const std::vector<LayerPin>& blobsToKeep_ = std::vector<LayerPin>())
+ {
+ CV_TRACE_FUNCTION();
+
+ if (!netWasAllocated || this->blobsToKeep != blobsToKeep_)
+ {
+ clear();
+
+ allocateLayers(blobsToKeep_);
+ computeNetOutputLayers();
+ initBackend();
+
+ if (!netWasAllocated )
+ {
+ // If user didn't call compileHalide() between
+ // setPreferableBackend(DNN_BACKEND_HALIDE) and forward().
+ if (preferableBackend == DNN_BACKEND_HALIDE)
+ compileHalide();
+ }
+
+ netWasAllocated = true;
+ this->blobsToKeep = blobsToKeep_;
+ }
+ }
+
+ int getLayerId(const String &layerName)
+ {
+ std::map<String, int>::iterator it = layerNameToId.find(layerName);
+ return (it != layerNameToId.end()) ? it->second : -1;
+ }
+
+ int getLayerId(int id)
+ {
+ MapIdToLayerData::iterator it = layers.find(id);
+ return (it != layers.end()) ? id : -1;
+ }
+
+ int getLayerId(DictValue &layerDesc)
+ {
+ if (layerDesc.isInt())
+ return getLayerId(layerDesc.get<int>());
+ else if (layerDesc.isString())
+ return getLayerId(layerDesc.get<String>());
+
+ CV_Assert(layerDesc.isInt() || layerDesc.isString());
+ return -1;
+ }
+
+ String getLayerName(int id)
+ {
+ MapIdToLayerData::iterator it = layers.find(id);
+ return (it != layers.end()) ? it->second.name : "(unknown layer)";
+ }
+
+ LayerData& getLayerData(int id)
+ {
+ MapIdToLayerData::iterator it = layers.find(id);
+
+ if (it == layers.end())
+ CV_Error(Error::StsObjectNotFound, format("Layer with requested id=%d not found", id));
+
+ return it->second;
+ }
+
+ LayerData& getLayerData(const String &layerName)
+ {
+ int id = getLayerId(layerName);
+
+ if (id < 0)
+ CV_Error(Error::StsError, "Requsted layer \"" + layerName + "\" not found");
+
+ return getLayerData(id);
+ }
+
+ LayerData& getLayerData(const DictValue &layerDesc)
+ {
+ CV_Assert(layerDesc.isInt() || layerDesc.isString());
+ if (layerDesc.isInt())
+ return getLayerData(layerDesc.get<int>());
+ else /*if (layerDesc.isString())*/
+ return getLayerData(layerDesc.get<String>());
+ }
+
+ static void addLayerInput(LayerData &ld, int inNum, LayerPin from)
+ {
+ if ((int)ld.inputBlobsId.size() <= inNum)
+ {
+ ld.inputBlobsId.resize(inNum + 1);
+ }
+ else
+ {
+ LayerPin storedFrom = ld.inputBlobsId[inNum];
+ if (storedFrom.valid() && !storedFrom.equal(from))
+ CV_Error(Error::StsError, "Input #" + toString(inNum) + "of layer \"" + ld.name + "\" already was connected");
+ }
+
+ ld.inputBlobsId[inNum] = from;
+ }
+
+ static void splitPin(const String &pinAlias, String &layerName, String &outName)
+ {
+ size_t delimPos = pinAlias.find('.');
+ layerName = pinAlias.substr(0, delimPos);
+ outName = (delimPos == String::npos) ? String() : pinAlias.substr(delimPos + 1);
+ }
+
+ int resolvePinOutputName(LayerData &ld, const String &outName)
+ {
+ if (outName.empty())
+ return 0;
+
+ if (std::isdigit(outName[0]))
+ {
+ char *lastChar;
+ long inum = std::strtol(outName.c_str(), &lastChar, 10);
+
+ if (*lastChar == 0)
+ {
+ CV_Assert(inum == (int)inum);
+ return (int)inum;
+ }
+ }
+
+ return ld.getLayerInstance()->outputNameToIndex(outName);
+ }
+
+ LayerPin getPinByAlias(const String &pinAlias)
+ {
+ LayerPin pin;
+ String layerName, outName;
+ splitPin(pinAlias, layerName, outName);
+
+ pin.lid = (layerName.empty()) ? 0 : getLayerId(layerName);
+
+ if (pin.lid >= 0)
+ pin.oid = resolvePinOutputName(getLayerData(pin.lid), outName);
+
+ return pin;
+ }
+
+ std::vector<LayerPin> getLayerOutPins(const String &pinAlias)
+ {
+ String layerName, outName;
+ splitPin(pinAlias, layerName, outName);
+
+ int lid = (layerName.empty()) ? 0 : getLayerId(layerName);
+
+ std::vector<LayerPin> pins;
+
+ for (int i = 0; i < layers[lid].outputBlobs.size(); i++)
+ {
+ pins.push_back(LayerPin(lid, i));
+ }
+
+ return pins;
+ }
+
+ void connect(int outLayerId, int outNum, int inLayerId, int inNum)
+ {
+ CV_Assert(outLayerId < inLayerId);
+ LayerData &ldOut = getLayerData(outLayerId);
+ LayerData &ldInp = getLayerData(inLayerId);
+
+ addLayerInput(ldInp, inNum, LayerPin(outLayerId, outNum));
+ ldOut.requiredOutputs.insert(outNum);
+ ldOut.consumers.push_back(LayerPin(inLayerId, outNum));
+ }
+
+ void computeNetOutputLayers()
+ {
+ CV_TRACE_FUNCTION();
+
+ netOutputs.clear();
+
+ MapIdToLayerData::iterator it;
+ for (it = layers.begin(); it != layers.end(); it++)
+ {
+ int lid = it->first;
+ LayerData &ld = it->second;
+
+ if (ld.requiredOutputs.size() == 0)
+ netOutputs.push_back(lid);
+ }
+
+ #ifndef NDEBUG
+ std::cout << "\nNet Outputs(" << netOutputs.size() << "):\n";
+ for (size_t i = 0; i < netOutputs.size(); i++)
+ std::cout << layers[netOutputs[i]].name << "\n";
+ #endif
+ }
+
+ void initBackend()
+ {
+ CV_TRACE_FUNCTION();
+
+ backendWrapper.reset();
+ if (preferableBackend == DNN_BACKEND_DEFAULT)
+ {
+ CV_Assert(preferableTarget == DNN_TARGET_CPU);
+ return;
+ }
+
+ // Iterator to current layer.
+ MapIdToLayerData::iterator it = layers.begin();
+ // Iterator to base layer for fusion. In example, in case of conv+bn+relu
+ // it'll be a conv layer.
+ MapIdToLayerData::iterator baseIt = layers.begin();
+ for (; it != layers.end(); it++)
+ {
+ LayerData &ldTop = it->second;
+ Ptr<Layer> layerTop = ldTop.layerInstance;
+ if (!layerTop->supportBackend(preferableBackend))
+ {
+ // Move base iterator to layer that don't support preferable
+ // backend to prevent fusion over layer of different backend.
+ baseIt = it;
+ continue;
+ }
+ // Try to do layers fusion.
+ LayerData &ldBot = baseIt->second;
+ Ptr<Layer> layerBot = ldBot.layerInstance;
+ // 1. Check that bottom and top from the same backends.
+ if (it != layers.begin() && layerBot->supportBackend(preferableBackend))
+ {
+ // 2. Check that current layer works in-place.
+ bool inPlace = ldTop.inputBlobs.size() == 1 &&
+ ldBot.outputBlobs.size() == 1 &&
+ ldTop.inputBlobs[0]->data ==
+ ldBot.outputBlobs[0].data;
+ if (inPlace)
+ {
+ // 3. Try to attach node.
+ CV_Assert(!ldBot.backendNodes[preferableBackend].empty());
+ Ptr<BackendNode> fusedNode =
+ layerTop->tryAttach(ldBot.backendNodes[preferableBackend]);
+ if (!fusedNode.empty())
+ {
+ ldTop.skipFlags[preferableBackend] = true;
+ ldBot.backendNodes[preferableBackend] = fusedNode;
+ continue;
+ }
+ }
+ }
+ // No layers fusion.
+ ldTop.skipFlags[preferableBackend] = false;
+ std::vector<Ptr<BackendWrapper> > inputs =
+ backendWrapper.wrap(ldTop.inputBlobs, preferableBackend,
+ preferableTarget);
+ if (preferableBackend == DNN_BACKEND_HALIDE)
+ {
+ ldTop.backendNodes[DNN_BACKEND_HALIDE] = layerTop->initHalide(inputs);
+ baseIt = it;
+ }
+ else
+ {
+ CV_Error(Error::StsNotImplemented, "Unknown backend identifier");
+ }
+ }
+ }
+
+ void allocateLayer(int lid, const LayersShapesMap& layersShapes)
+ {
+ CV_TRACE_FUNCTION();
+
+ LayerData &ld = layers[lid];
+
+ //already allocated
+ if (ld.flag)
+ return;
+
+ size_t ninputs = ld.inputBlobsId.size();
+#if 0
+ printf("layer %s:", ld.name.c_str());
+ for (size_t i = 0; i < ninputs; i++)
+ {
+ int inp_lid = ld.inputBlobsId[i].lid;
+ LayerData &inp_ld = layers[inp_lid];
+ int inp_outputs = (int)inp_ld.outputBlobs.size();
+ std::cout << " " << inp_ld.name << "(" << inp_outputs;
+
+ for( int j = 0; j < inp_outputs; j++ )
+ {
+ std::cout << (j == 0 ? ": " : ", ") << inp_ld.outputBlobs[j].size;
+ }
+ std::cout << ")";
+ }
+ printf("\n");
+#endif
+
+ //determine parent layers
+ for (size_t i = 0; i < ninputs; i++)
+ ld.inputLayersId.insert(ld.inputBlobsId[i].lid);
+
+ //allocate parents
+ for (set<int>::iterator i = ld.inputLayersId.begin(); i != ld.inputLayersId.end(); i++)
+ allocateLayer(*i, layersShapes);
+
+ //bind inputs
+ ld.inputBlobs.resize(ninputs);
+ for (size_t i = 0; i < ninputs; i++)
+ {
+ LayerPin from = ld.inputBlobsId[i];
+ CV_Assert(from.valid());
+ CV_DbgAssert(layers.count(from.lid) && (int)layers[from.lid].outputBlobs.size() > from.oid);
+ ld.inputBlobs[i] = &layers[from.lid].outputBlobs[from.oid];
+ }
+
+ LayersShapesMap::const_iterator layerShapesIt = layersShapes.find(lid);
+
+ CV_Assert(layerShapesIt != layersShapes.end());
+
+ std::vector<LayerPin> pinsForInternalBlobs;
+ bool maximizeReuse = preferableBackend == DNN_BACKEND_HALIDE;
+ blobManager.allocateBlobsForLayer(ld, layerShapesIt->second, pinsForInternalBlobs, maximizeReuse);
+
+ Ptr<Layer> layerPtr = ld.getLayerInstance();
+ {
+ layerPtr->finalize(ld.inputBlobs, ld.outputBlobs);
+#if 0
+ std::cout << "\toutputs:";
+ size_t noutputs = ld.outputBlobs.size();
+ for (size_t j = 0; j < noutputs; j++)
+ {
+ std::cout << (j == 0 ? " " : ", ") << ld.outputBlobs[j].size;
+ }
+ std::cout << "\n";
+#endif
+ }
+
+ // After allocation of layer, we decrease counters to it's input blobs.
+ blobManager.releaseReferences(ld.inputBlobsId);
+ blobManager.releaseReferences(pinsForInternalBlobs);
+
+ ld.flag = 1;
+ }
+
+#if 0
+#define printf_(args) printf args
+#else
+#define printf_(args)
+#endif
+
+ void fuseLayers(const std::vector<LayerPin>& blobsToKeep_)
+ {
+ if( !fusion || preferableBackend == DNN_BACKEND_HALIDE )
+ return;
+
+ CV_TRACE_FUNCTION();
+
+ // scan through all the layers. If there is convolution layer followed by the activation layer,
+ // we try to embed this activation into the convolution and disable separate execution of the activation
+ std::vector<String> outnames;
+ std::set<LayerPin> pinsToKeep(blobsToKeep_.begin(),
+ blobsToKeep_.end());
+ MapIdToLayerData::iterator it;
+ for (it = layers.begin(); it != layers.end(); it++)
+ {
+ int lid = it->first;
+ LayerData& ld = layers[lid];
+ if( ld.skipFlags[DNN_BACKEND_DEFAULT] )
+ {
+ printf_(("skipped %s: %s\n", ld.layerInstance->name.c_str(), ld.layerInstance->type.c_str()));
+ continue;
+ }
+ printf_(("analyzing %s: %s\n", ld.layerInstance->name.c_str(), ld.layerInstance->type.c_str()));
+ if( ld.consumers.size() == 0 )
+ outnames.push_back(ld.layerInstance->name);
+
+ // the optimization #1. try to fuse batch norm, scaling and/or activation layers
+ // with the current layer if they follow it. Normally, the are fused with the convolution layer,
+ // but some of them (like activation) may be fused with fully-connected, elemwise (+) and
+ // some other layers.
+ Ptr<Layer>& currLayer = ld.layerInstance;
+ if( ld.consumers.size() == 1 && pinsToKeep.count(LayerPin(lid, 0)) == 0 )
+ {
+ LayerData* nextData = &layers[ld.consumers[0].lid];
+ Ptr<BatchNormLayer> nextBNormLayer =
+ nextData->layerInstance.dynamicCast<BatchNormLayer>();
+ LayerPin lpNext(ld.consumers[0].lid, 0);
+ if( !nextBNormLayer.empty() && pinsToKeep.count(lpNext) == 0 )
+ {
+ LayerData* bnormData = nextData;
+ nextData = 0;
+ if( currLayer->setBatchNorm(nextBNormLayer) )
+ {
+ printf_(("\tfused with %s\n", nextBNormLayer->name.c_str()));
+ bnormData->skipFlags[DNN_BACKEND_DEFAULT] = true;
+ ld.outputBlobs = layers[lpNext.lid].outputBlobs;
+ if( bnormData->consumers.size() == 1 )
+ {
+ nextData = &layers[bnormData->consumers[0].lid];
+ lpNext = LayerPin(bnormData->consumers[0].lid, 0);
+ }
+ }
+ }
+
+ Ptr<ScaleLayer> nextScaleLayer;
+ if( nextData )
+ nextScaleLayer = nextData->layerInstance.dynamicCast<ScaleLayer>();
+ if( !nextScaleLayer.empty() && pinsToKeep.count(lpNext) == 0 )
+ {
+ LayerData* scaleData = nextData;
+ nextData = 0;
+ if( currLayer->setScale(nextScaleLayer) )
+ {
+ printf_(("\tfused with %s\n", nextScaleLayer->name.c_str()));
+ scaleData->skipFlags[DNN_BACKEND_DEFAULT] = true;
+ ld.outputBlobs = layers[lpNext.lid].outputBlobs;
+ if( scaleData->consumers.size() == 1 )
+ {
+ nextData = &layers[scaleData->consumers[0].lid];
+ lpNext = LayerPin(scaleData->consumers[0].lid, 0);
+ }
+ }
+ }
+
+ Ptr<ActivationLayer> nextActivLayer;
+ if( nextData )
+ nextActivLayer = nextData->layerInstance.dynamicCast<ActivationLayer>();
+
+ if( !nextActivLayer.empty() && pinsToKeep.count(lpNext) == 0
+ && currLayer->setActivation(nextActivLayer) )
+ {
+ printf_(("\tfused with %s\n", nextActivLayer->name.c_str()));
+ nextData->skipFlags[DNN_BACKEND_DEFAULT] = true;
+ ld.outputBlobs = layers[lpNext.lid].outputBlobs;
+ }
+ }
+
+ // the optimization #2. if there is no layer that takes max pooling layer's computed
+ // max indices (and only some semantical segmentation networks might need this;
+ // many others only take the maximum values), then we switch the max pooling
+ // layer to the faster operating mode.
+ Ptr<PoolingLayer> poolingLayer = ld.layerInstance.dynamicCast<PoolingLayer>();
+ if( !poolingLayer.empty() && !ld.consumers.empty() )
+ {
+ size_t i = 0, nconsumers = ld.consumers.size();
+ for( ; i < nconsumers; i++ )
+ if( ld.consumers[i].oid > 0 )
+ break;
+ // if there is no layer that takes the second output pin of the pooling layer
+ // on input then we don't need to compute the indices
+ if( i >= nconsumers )
+ {
+ poolingLayer->computeMaxIdx = false;
+ printf_(("\tsimplified pooling layer %s\n", poolingLayer->name.c_str()));
+ }
+ }
+
+ // the optimization #3. if there is concat layer that concatenates channels
+ // from the inputs together (i.e. axis == 1) then we make the inputs of
+ // the concat layer to write to the concatetion output buffer
+ // (and so we eliminate the concatenation layer, because the channels
+ // are concatenated implicitly).
+ Ptr<ConcatLayer> concatLayer = ld.layerInstance.dynamicCast<ConcatLayer>();
+ if( !concatLayer.empty() && concatLayer->axis == 1 &&
+ ld.outputBlobs.size() == 1 )
+ {
+ Mat& output = ld.outputBlobs[0];
+
+ // TODO: in general, this optimization can always be done, but
+ // many layers currently check that the input/output blobs are
+ // continuous arrays. Unfortunately, this is not true when
+ // the concatenation optimization is applied with batch_size > 1.
+ // so, for now, we only apply this optimization in the most popular
+ // case batch_size == 1.
+ if( output.dims == 4 && output.size[0] == 1 )
+ {
+ size_t i, ninputs = ld.inputBlobsId.size();
+ std::vector<LayerPin> realinputs(ninputs);
+ for( i = 0; i < ninputs; i++ )
+ {
+ LayerPin pin = ld.inputBlobsId[i];
+ LayerData* inp_i_data = &layers[pin.lid];
+ while(inp_i_data->skipFlags[DNN_BACKEND_DEFAULT] &&
+ inp_i_data->inputBlobsId.size() == 1)
+ {
+ pin = inp_i_data->inputBlobsId[0];
+ inp_i_data = &layers[pin.lid];
+ }
+ printf_(("\treal input for %s is %s\n",
+ layers[ld.inputBlobsId[i].lid].getLayerInstance()->name.c_str(),
+ inp_i_data->getLayerInstance()->name.c_str()));
+
+ if(inp_i_data->skipFlags[DNN_BACKEND_DEFAULT])
+ break;
+ realinputs[i] = pin;
+ }
+
+ if( i >= ninputs )
+ {
+ Range chrange[] = { Range::all(), Range::all(), Range::all(), Range::all() };
+ int ofs = 0;
+ for( i = 0; i < ninputs; i++ )
+ {
+ LayerPin pin = realinputs[i];
+ LayerData* inp_i_data = &layers[pin.lid];
+ int channels_i = ld.inputBlobs[i]->size[1];
+ chrange[1] = Range(ofs, ofs + channels_i);
+ printf_(("\toutput %s(%d) to channels (%d, %d)\n", inp_i_data->layerInstance->name.c_str(),
+ pin.oid, ofs, ofs + channels_i));
+ ofs += channels_i;
+ Mat output_slice = output(chrange);
+ Mat& curr_output = inp_i_data->outputBlobs[pin.oid];
+ CV_Assert(output_slice.isContinuous() && output_slice.size == curr_output.size);
+ curr_output = output_slice;
+ }
+ ld.skipFlags[DNN_BACKEND_DEFAULT] = true;
+ printf_(("\toptimized out Concat layer %s\n", concatLayer->name.c_str()));
+ }
+ }
+ }
+ }
+ }
+
+ void allocateLayers(const std::vector<LayerPin>& blobsToKeep_)
+ {
+ CV_TRACE_FUNCTION();
+
+ MapIdToLayerData::iterator it;
+ for (it = layers.begin(); it != layers.end(); it++)
+ it->second.flag = 0;
+
+ CV_Assert(!layers[0].outputBlobs.empty());
+ ShapesVec inputShapes;
+ for(int i = 0; i < layers[0].outputBlobs.size(); i++)
+ {
+ CV_Assert(layers[0].outputBlobs[i].total());
+ inputShapes.push_back(shape(layers[0].outputBlobs[i]));
+ }
+ LayersShapesMap layersShapes;
+ getLayersShapes(inputShapes, layersShapes);
+
+ blobManager.reset();
+ for (it = layers.begin(); it != layers.end(); ++it)
+ {
+ const LayerData& ld = it->second;
+ blobManager.addReferences(ld.inputBlobsId);
+ }
+
+ for (int i = 0; i < blobsToKeep_.size(); i++)
+ {
+ blobManager.addReference(blobsToKeep_[i]);
+ }
+
+ for (it = layers.begin(); it != layers.end(); it++)
+ {
+ int lid = it->first;
+ allocateLayer(lid, layersShapes);
+ }
+
+ fuseLayers(blobsToKeep_);
+ }
+
+ void forwardLayer(LayerData &ld)
+ {
+ CV_TRACE_FUNCTION();
+
+ Ptr<Layer> layer = ld.layerInstance;
+
+ if (preferableBackend == DNN_BACKEND_DEFAULT ||
+ !layer->supportBackend(preferableBackend))
+ {
+ if( !ld.skipFlags[DNN_BACKEND_DEFAULT] )
+ layer->forward(ld.inputBlobs, ld.outputBlobs, ld.internals);
+ }
+ else if (!ld.skipFlags[preferableBackend])
+ {
+ std::vector<Ptr<BackendWrapper> > outputs =
+ backendWrapper.wrap(ld.outputBlobs, preferableBackend, preferableTarget);
+ Ptr<BackendNode> node = ld.backendNodes[preferableBackend];
+ if (preferableBackend == DNN_BACKEND_HALIDE)
+ {
+ forwardHalide(outputs, node);
+ }
+ else
+ {
+ CV_Error(Error::StsNotImplemented, "Unknown backend identifier");
+ }
+ }
+
+ ld.flag = 1;
+ }
+
+ void forwardToLayer(LayerData &ld, bool clearFlags = true)
+ {
+ CV_TRACE_FUNCTION();
+
+ if (clearFlags)
+ {
+ MapIdToLayerData::iterator it;
+ for (it = layers.begin(); it != layers.end(); it++)
+ it->second.flag = 0;
+ }
+
+ //already was forwarded
+ if (ld.flag)
+ return;
+
+ //forward parents
+ MapIdToLayerData::iterator it;
+ for (it = layers.begin(); it->second.id < ld.id; it++)
+ {
+ LayerData &ld = it->second;
+ if (ld.flag)
+ continue;
+ forwardLayer(ld);
+ }
+
+ //forward itself
+ forwardLayer(ld);
+ }
+
+ void forwardAll()
+ {
+ CV_TRACE_FUNCTION();
+
+ forwardToLayer(layers.rbegin()->second, true);
+ }
+
+ void getLayerShapesRecursively(int id, LayersShapesMap& inOutShapes)
+ {
+ std::vector<LayerPin>& inputLayerIds = layers[id].inputBlobsId;
+
+ if (inOutShapes[id].in.empty())
+ {
+ for(int i = 0; i < inputLayerIds.size(); i++)
+ {
+ int layerId = inputLayerIds[i].lid;
+ LayersShapesMap::iterator it =
+ inOutShapes.find(layerId);
+ if(it == inOutShapes.end() ||
+ it->second.out.empty())
+ {
+ getLayerShapesRecursively(layerId, inOutShapes);
+ }
+ const MatShape& shape = inOutShapes[layerId].out[inputLayerIds[i].oid];
+ inOutShapes[id].in.push_back(shape);
+ }
+ }
+ const ShapesVec& is = inOutShapes[id].in;
+ ShapesVec& os = inOutShapes[id].out;
+ ShapesVec& ints = inOutShapes[id].internal;
+ int requiredOutputs = layers[id].requiredOutputs.size();
+ inOutShapes[id].supportInPlace =
+ layers[id].getLayerInstance()->getMemoryShapes(is, requiredOutputs, os, ints);
+ }
+
+ void getLayersShapes(const ShapesVec& netInputShapes,
+ LayersShapesMap& inOutShapes)
+ {
+ inOutShapes.clear();
+
+ inOutShapes[0].in = netInputShapes; //insert shape for first input layer
+ for (MapIdToLayerData::iterator it = layers.begin();
+ it != layers.end(); it++)
+ {
+ getLayerShapesRecursively(it->first, inOutShapes);
+ }
+ }
+
+ void getLayerShapes(const ShapesVec& netInputShapes,
+ const int layerId,
+ LayerShapes& shapes)
+ {
+ LayersShapesMap inOutShapes;
+ inOutShapes[0].in = netInputShapes; //insert shape for first input layer
+ getLayerShapesRecursively(layerId, inOutShapes);
+ shapes = inOutShapes[layerId];
+ }
+
+ LayerPin getLatestLayerPin(const std::vector<LayerPin>& pins)
+ {
+ return *std::max_element(pins.begin(), pins.end());
+ }
+
+ Mat getBlob(const LayerPin& pin)
+ {
+ CV_TRACE_FUNCTION();
+
+ if (!pin.valid())
+ CV_Error(Error::StsObjectNotFound, "Requested blob not found");
+
+ LayerData &ld = layers[pin.lid];
+ if ((size_t)pin.oid >= ld.outputBlobs.size())
+ {
+ CV_Error(Error::StsOutOfRange, "Layer \"" + ld.name + "\" produce only " + toString(ld.outputBlobs.size()) +
+ " outputs, the #" + toString(pin.oid) + " was requsted");
+ }
+ if (preferableBackend != DNN_BACKEND_DEFAULT)
+ {
+ // Transfer data to CPU if it's require.
+ backendWrapper.wrap(ld.outputBlobs[pin.oid], preferableBackend,
+ preferableTarget)->copyToHost();
+ }
+ else
+ {
+ CV_Assert(preferableTarget == DNN_TARGET_CPU);
+ }
+ return ld.outputBlobs[pin.oid];
+ }
+
+ Mat getBlob(String outputName)
+ {
+ return getBlob(getPinByAlias(outputName));
+ }
+};
+
+Net::Net() : impl(new Net::Impl)
+{
+}
+
+Net::~Net()
+{
+}
+
+int Net::addLayer(const String &name, const String &type, LayerParams ¶ms)
+{
+ CV_TRACE_FUNCTION();
+
+ if (name.find('.') != String::npos)
+ {
+ CV_Error(Error::StsBadArg, "Added layer name \"" + name + "\" must not contain dot symbol");
+ return -1;
+ }
+
+ if (impl->getLayerId(name) >= 0)
+ {
+ CV_Error(Error::StsBadArg, "Layer \"" + name + "\" already into net");
+ return -1;
+ }
+
+ int id = ++impl->lastLayerId;
+ impl->layerNameToId.insert(std::make_pair(name, id));
+ impl->layers.insert(std::make_pair(id, LayerData(id, name, type, params)));
+
+ return id;
+}
+
+int Net::addLayerToPrev(const String &name, const String &type, LayerParams ¶ms)
+{
+ CV_TRACE_FUNCTION();
+
+ int prvLid = impl->lastLayerId;
+ int newLid = this->addLayer(name, type, params);
+ this->connect(prvLid, 0, newLid, 0);
+ return newLid;
+}
+
+void Net::connect(int outLayerId, int outNum, int inpLayerId, int inpNum)
+{
+ CV_TRACE_FUNCTION();
+
+ impl->connect(outLayerId, outNum, inpLayerId, inpNum);
+}
+
+void Net::connect(String _outPin, String _inPin)
+{
+ CV_TRACE_FUNCTION();
+
+ LayerPin outPin = impl->getPinByAlias(_outPin);
+ LayerPin inpPin = impl->getPinByAlias(_inPin);
+
+ CV_Assert(outPin.valid() && inpPin.valid());
+
+ impl->connect(outPin.lid, outPin.oid, inpPin.lid, inpPin.oid);
+}
+
+Mat Net::forward(const String& outputName)
+{
+ CV_TRACE_FUNCTION();
+
+ String layerName = outputName;
+
+ if (layerName.empty())
+ layerName = getLayerNames().back();
+
+ impl->setUpNet();
+ impl->forwardToLayer(impl->getLayerData(layerName));
+
+ return impl->getBlob(layerName);
+}
+
+void Net::forward(std::vector<Mat>& outputBlobs, const String& outputName)
+{
+ CV_TRACE_FUNCTION();
+
+ impl->setUpNet();
+
+ String layerName = outputName;
+
+ if (layerName.empty())
+ layerName = getLayerNames().back();
+
+ impl->forwardToLayer(impl->getLayerData(layerName));
+
+ LayerPin pin = impl->getPinByAlias(layerName);
+ LayerData &ld = impl->layers[pin.lid];
+ outputBlobs = ld.outputBlobs;
+}
+
+void Net::forward(std::vector<Mat>& outputBlobs,
+ const std::vector<String>& outBlobNames)
+{
+ CV_TRACE_FUNCTION();
+
+ std::vector<LayerPin> pins;
+ for (int i = 0; i < outBlobNames.size(); i++)
+ {
+ pins.push_back(impl->getPinByAlias(outBlobNames[i]));
+ }
+
+ impl->setUpNet(pins);
+
+ LayerPin out = impl->getLatestLayerPin(pins);
+
+ impl->forwardToLayer(impl->getLayerData(out.lid));
+
+ outputBlobs.clear();
+ for (int i = 0; i < pins.size(); i++)
+ {
+ outputBlobs.push_back(impl->getBlob(pins[i]));
+ }
+}
+
+void Net::forward(std::vector<std::vector<Mat> >& outputBlobs,
+ const std::vector<String>& outBlobNames)
+{
+ CV_TRACE_FUNCTION();
+
+ std::vector<LayerPin> pins;
+ for (int i = 0; i < outBlobNames.size(); i++)
+ {
+ std::vector<LayerPin> lp = impl->getLayerOutPins(outBlobNames[i]);
+ pins.insert(pins.end(), lp.begin(), lp.end());
+ }
+
+ impl->setUpNet(pins);
+
+ LayerPin out = impl->getLatestLayerPin(pins);
+
+ impl->forwardToLayer(impl->getLayerData(out.lid));
+
+ outputBlobs.resize(outBlobNames.size());
+ for (int i = 0; i < outBlobNames.size(); i++)
+ {
+ std::vector<LayerPin> lp = impl->getLayerOutPins(outBlobNames[i]);
+ for (int i = 0; i < lp.size(); i++)
+ {
+ outputBlobs[i].push_back(impl->getBlob(lp[i]));
+ }
+ }
+}
+
+void Net::setPreferableBackend(int backendId)
+{
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG(backendId);
+
+ if( impl->preferableBackend != backendId )
+ {
+ impl->preferableBackend = backendId;
+ impl->netWasAllocated = false;
+ impl->clear();
+ }
+}
+
+void Net::setPreferableTarget(int targetId)
+{
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG(targetId);
+
+ if( impl->preferableTarget != targetId )
+ {
+ impl->preferableTarget = targetId;
+ impl->netWasAllocated = false;
+ impl->clear();
+ }
+}
+
+void Net::setInputsNames(const std::vector<String> &inputBlobNames)
+{
+ CV_TRACE_FUNCTION();
+
+ impl->netInputLayer->setNames(inputBlobNames);
+}
+
+void Net::setInput(const Mat &blob_, const String& name)
+{
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ LayerPin pin;
+ pin.lid = 0;
+ pin.oid = impl->resolvePinOutputName(impl->getLayerData(pin.lid), name);
+
+ if (!pin.valid())
+ CV_Error(Error::StsObjectNotFound, "Requested blob \"" + name + "\" not found");
+
+ LayerData &ld = impl->layers[pin.lid];
+ ld.outputBlobs.resize( std::max(pin.oid+1, (int)ld.requiredOutputs.size()) );
+ MatShape prevShape = shape(ld.outputBlobs[pin.oid]);
+ bool oldShape = prevShape == shape(blob_);
+ if (oldShape)
+ blob_.copyTo(ld.outputBlobs[pin.oid]);
+ else
+ ld.outputBlobs[pin.oid] = blob_.clone();
+
+ impl->netWasAllocated = impl->netWasAllocated && oldShape;
+}
+
+Mat Net::getParam(LayerId layer, int numParam)
+{
+ LayerData &ld = impl->getLayerData(layer);
+
+ std::vector<Mat> &layerBlobs = ld.layerInstance->blobs;
+ CV_Assert(numParam < (int)layerBlobs.size());
+ return layerBlobs[numParam];
+}
+
+void Net::setParam(LayerId layer, int numParam, const Mat &blob)
+{
+ LayerData &ld = impl->getLayerData(layer);
+
+ std::vector<Mat> &layerBlobs = ld.layerInstance->blobs;
+ CV_Assert(numParam < (int)layerBlobs.size());
+ //we don't make strong checks, use this function carefully
+ layerBlobs[numParam] = blob;
+}
+
+int Net::getLayerId(const String &layer)
+{
+ return impl->getLayerId(layer);
+}
+
+void Net::deleteLayer(LayerId)
+{
+ CV_Error(Error::StsNotImplemented, "");
+}
+
+Ptr<Layer> Net::getLayer(LayerId layerId)
+{
+ LayerData &ld = impl->getLayerData(layerId);
+ return ld.getLayerInstance();
+}
+
+std::vector<Ptr<Layer> > Net::getLayerInputs(LayerId layerId)
+{
+ LayerData &ld = impl->getLayerData(layerId);
+ if (!ld.layerInstance)
+ CV_Error(Error::StsNullPtr, format("Requested layer \"%s\" was not initialized", ld.name.c_str()));
+
+ std::vector<Ptr<Layer> > inputLayers;
+ inputLayers.reserve(ld.inputLayersId.size());
+ std::set<int>::iterator it;
+ for (it = ld.inputLayersId.begin(); it != ld.inputLayersId.end(); ++it) {
+ inputLayers.push_back(getLayer(*it));
+ }
+ return inputLayers;
+}
+
+std::vector<String> Net::getLayerNames() const
+{
+ std::vector<String> res;
+ res.reserve(impl->layers.size());
+
+ Impl::MapIdToLayerData::iterator it;
+ for (it = impl->layers.begin(); it != impl->layers.end(); it++)
+ {
+ if (it->second.id) //skip Data layer
+ res.push_back(it->second.name);
+ }
+
+ return res;
+}
+
+bool Net::empty() const
+{
+ return impl->layers.size() <= 1; //first layer is default Data layer
+}
+
+std::vector<int> Net::getUnconnectedOutLayers() const
+{
+ std::vector<int> layersIds;
+
+ Impl::MapIdToLayerData::iterator it;
+ for (it = impl->layers.begin(); it != impl->layers.end(); it++)
+ {
+ int lid = it->first;
+ LayerData &ld = it->second;
+
+ if (ld.requiredOutputs.size() == 0)
+ layersIds.push_back(lid);
+ }
+
+ return layersIds;
+}
+
+void Net::getLayersShapes(const ShapesVec& netInputShapes,
+ std::vector<int>* layersIds,
+ std::vector<ShapesVec>* inLayersShapes,
+ std::vector<ShapesVec>* outLayersShapes) const
+{
+ if ((layersIds || inLayersShapes || outLayersShapes) == false)
+ return;
+
+ if (layersIds) layersIds->clear();
+ if (inLayersShapes) inLayersShapes->clear();
+ if (outLayersShapes) outLayersShapes->clear();
+
+ Impl::LayersShapesMap inOutShapes;
+ impl->getLayersShapes(netInputShapes, inOutShapes);
+
+ for(Impl::LayersShapesMap::const_iterator it = inOutShapes.begin();
+ it != inOutShapes.end(); it++)
+ {
+ if (layersIds)
+ layersIds->push_back(it->first);
+ if (inLayersShapes)
+ inLayersShapes->push_back(it->second.in);
+ if (outLayersShapes)
+ outLayersShapes->push_back(it->second.out);
+ }
+}
+
+void Net::getLayersShapes(const MatShape& netInputShape,
+ std::vector<int>* layerIds,
+ std::vector<ShapesVec>* inLayersShapes,
+ std::vector<ShapesVec>* outLayersShapes) const
+{
+ getLayersShapes(ShapesVec(1, netInputShape),
+ layerIds, inLayersShapes, outLayersShapes);
+}
+
+void Net::getLayerShapes(const MatShape& netInputShape,
+ const int layerId,
+ ShapesVec* inLayerShapes,
+ ShapesVec* outLayerShapes) const
+{
+ getLayerShapes(ShapesVec(1, netInputShape),
+ layerId, inLayerShapes, outLayerShapes);
+
+}
+
+void Net::getLayerShapes(const ShapesVec& netInputShapes,
+ const int layerId,
+ ShapesVec* inLayerShapes,
+ ShapesVec* outLayerShapes) const
+{
+ LayerShapes shapes;
+ impl->getLayerShapes(netInputShapes, layerId, shapes);
+ if (inLayerShapes)
+ *inLayerShapes = shapes.in;
+ if (outLayerShapes)
+ *outLayerShapes = shapes.out;
+}
+
+int64 Net::getFLOPS(const std::vector<MatShape>& netInputShapes) const
+{
+ CV_TRACE_FUNCTION();
+
+ int64 flops = 0;
+ std::vector<int> ids;
+ std::vector<std::vector<MatShape> > inShapes, outShapes;
+ getLayersShapes(netInputShapes, &ids, &inShapes, &outShapes);
+ CV_Assert(inShapes.size() == outShapes.size());
+ CV_Assert(inShapes.size() == ids.size());
+
+ for(int i = 0; i < ids.size(); i++)
+ {
+ flops += impl->layers[ids[i]].getLayerInstance()->getFLOPS(inShapes[i],
+ outShapes[i]);
+ }
+
+ return flops;
+}
+
+int64 Net::getFLOPS(const MatShape& netInputShape) const
+{
+ return getFLOPS(std::vector<MatShape>(1, netInputShape));
+}
+
+int64 Net::getFLOPS(const int layerId,
+ const std::vector<MatShape>& netInputShapes) const
+{
+ Impl::MapIdToLayerData::iterator layer = impl->layers.find(layerId);
+ CV_Assert(layer != impl->layers.end());
+
+ LayerShapes shapes;
+ impl->getLayerShapes(netInputShapes, layerId, shapes);
+
+ return layer->second.getLayerInstance()->getFLOPS(shapes.in, shapes.out);
+}
+
+int64 Net::getFLOPS(const int layerId,
+ const MatShape& netInputShape) const
+{
+ return getFLOPS(layerId, std::vector<MatShape>(1, netInputShape));
+}
+
+void Net::getLayerTypes(std::vector<String>& layersTypes) const
+{
+ layersTypes.clear();
+
+ std::map<String, int> layers;
+ for (Impl::MapIdToLayerData::iterator it = impl->layers.begin();
+ it != impl->layers.end(); it++)
+ {
+ if (layers.find(it->second.type) == layers.end())
+ layers[it->second.type] = 0;
+ layers[it->second.type]++;
+ }
+
+ for (std::map<String, int>::iterator it = layers.begin();
+ it != layers.end(); it++)
+ {
+ layersTypes.push_back(it->first);
+ }
+}
+
+int Net::getLayersCount(const String& layerType) const
+{
+ int count = 0;
+ for (Impl::MapIdToLayerData::iterator it = impl->layers.begin();
+ it != impl->layers.end(); it++)
+ {
+ if (it->second.type == layerType)
+ count++;
+ }
+ return count;
+}
+
+void Net::getMemoryConsumption(const int layerId,
+ const std::vector<MatShape>& netInputShapes,
+ size_t& weights, size_t& blobs) const
+{
+ CV_TRACE_FUNCTION();
+
+ Impl::MapIdToLayerData::iterator layer = impl->layers.find(layerId);
+ CV_Assert(layer != impl->layers.end());
+
+ weights = blobs = 0;
+
+ for(int i = 0; i < layer->second.params.blobs.size(); i++)
+ {
+ const Mat& weightsBlob = layer->second.params.blobs[i];
+ weights += weightsBlob.total()*weightsBlob.elemSize();
+ }
+
+ std::vector<MatShape> outLayerShapes;
+ getLayerShapes(netInputShapes, layerId, 0, &outLayerShapes);
+ for(int i = 0; i < outLayerShapes.size(); i++)
+ {
+ blobs += total(outLayerShapes[i]) * sizeof(float);
+ }
+}
+
+void Net::getMemoryConsumption(const std::vector<MatShape>& netInputShapes,
+ size_t& weights, size_t& blobs) const
+{
+ CV_TRACE_FUNCTION();
+
+ std::vector<int> layerIds;
+ std::vector<size_t> w, b;
+ getMemoryConsumption(netInputShapes, layerIds, w, b);
+
+ weights = blobs = 0;
+ for(int i = 0; i < layerIds.size(); i++)
+ {
+ weights += w[i];
+ blobs += b[i];
+ }
+}
+
+void Net::getMemoryConsumption(const int layerId,
+ const MatShape& netInputShape,
+ size_t& weights, size_t& blobs) const
+{
+ getMemoryConsumption(layerId, std::vector<MatShape>(1, netInputShape),
+ weights, blobs);
+}
+
+void Net::getMemoryConsumption(const MatShape& netInputShape,
+ size_t& weights, size_t& blobs) const
+{
+ getMemoryConsumption(std::vector<MatShape>(1, netInputShape),
+ weights, blobs);
+}
+
+void Net::getMemoryConsumption(const std::vector<MatShape>& netInputShapes,
+ std::vector<int>& layerIds, std::vector<size_t>& weights,
+ std::vector<size_t>& blobs) const
+{
+ CV_TRACE_FUNCTION();
+
+ layerIds.clear();
+ weights.clear();
+ blobs.clear();
+
+ std::vector<std::vector<MatShape> > outLayerShapes;
+
+ getLayersShapes(netInputShapes, &layerIds, 0, &outLayerShapes);
+
+ for(int i = 0; i < layerIds.size(); i++)
+ {
+ int w = 0, b = 0;
+ Impl::MapIdToLayerData::iterator layer = impl->layers.find(layerIds[i]);
+ CV_Assert(layer != impl->layers.end());
+
+ for(int j = 0; j < layer->second.params.blobs.size(); j++)
+ {
+ const Mat& weightsBlob = layer->second.params.blobs[j];
+ w += weightsBlob.total()*weightsBlob.elemSize();
+ }
+
+ for(int j = 0; j < outLayerShapes[i].size(); j++)
+ {
+ b += total(outLayerShapes[i][j]) * sizeof(float);
+ }
+
+ weights.push_back(w);
+ blobs.push_back(b);
+ }
+}
+
+void Net::getMemoryConsumption(const MatShape& netInputShape, std::vector<int>& layerIds,
+ std::vector<size_t>& weights, std::vector<size_t>& blobs) const
+{
+ getMemoryConsumption(std::vector<MatShape>(1, netInputShape), layerIds,
+ weights, blobs);
+}
+
+void Net::enableFusion(bool fusion)
+{
+ if( impl->fusion != fusion )
+ {
+ impl->fusion = fusion;
+ impl->netWasAllocated = false;
+ impl->clear();
+ }
+}
+
+void Net::setHalideScheduler(const String& scheduler)
+{
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(scheduler, "scheduler", scheduler.c_str());
+
+ impl->halideConfigFile = scheduler;
+}
+
+//////////////////////////////////////////////////////////////////////////
+
+Importer::~Importer() {}
+
+Layer::Layer() {}
+
+Layer::Layer(const LayerParams ¶ms)
+ : blobs(params.blobs), name(params.name), type(params.type)
+{
+
+}
+
+void Layer::setParamsFrom(const LayerParams ¶ms)
+{
+ blobs = params.blobs;
+ name = params.name;
+ type = params.type;
+}
+
+int Layer::inputNameToIndex(String)
+{
+ return -1;
+}
+
+int Layer::outputNameToIndex(String)
+{
+ return -1;
+}
+
+bool Layer::supportBackend(int backendId)
+{
+ return backendId == DNN_BACKEND_DEFAULT;
+}
+
+Ptr<BackendNode> Layer::initHalide(const std::vector<Ptr<BackendWrapper> > &)
+{
+ CV_Error(Error::StsNotImplemented, "Halide pipeline of " + type +
+ " layers is not defined.");
+ return Ptr<BackendNode>();
+}
+
+void Layer::applyHalideScheduler(Ptr<BackendNode>& node, const std::vector<Mat*> &inputs,
+ const std::vector<Mat> &outputs, int targetId) const
+{
+#ifdef HAVE_HALIDE
+ CV_TRACE_FUNCTION();
+
+ Halide::Var x("x"), y("y"), c("c"), n("n"), co("co"), ci("ci"),
+ xo("xo"), xi("xi"), yo("yo"), yi("yi"), tile("tile");
+ Halide::Func& top = node.dynamicCast<HalideBackendNode>()->funcs.back();
+
+ int outW, outH, outC, outN;
+ getCanonicalSize(outputs[0].size, &outW, &outH, &outC, &outN);
+
+ if (targetId == DNN_TARGET_CPU)
+ {
+ if (outW == 1 && outH == 1)
+ {
+ if (outC + outN == 1)
+ return;
+
+ if (outC > 8)
+ top.split(c, co, ci, 8)
+ .fuse(x, y, tile).fuse(co, tile, tile).fuse(n, tile, tile)
+ .parallel(tile)
+ .vectorize(ci, 8);
+ else
+ top.fuse(x, y, tile).fuse(c, tile, tile).fuse(n, tile, tile)
+ .parallel(tile);
+ }
+ else
+ {
+ if (outH > 2)
+ {
+ top.reorder(x, c, y)
+ .split(y, yo, yi, 2)
+ .fuse(yo, n, tile)
+ .parallel(tile)
+ .unroll(yi)
+ .vectorize(x, outW >= 16 ? 16 : outW);
+ }
+ }
+ }
+ else if (targetId == DNN_TARGET_OPENCL)
+ {
+ int c_split = outC > 8 ? (outC > 16 ? 8 : 4) : outC;
+ if (outW == 1 && outH == 1)
+ {
+ top.split(c, co, ci, c_split)
+ .fuse(x, y, tile).fuse(co, tile, tile).fuse(n, tile, tile)
+ .gpu_blocks(tile)
+ .gpu_threads(ci);
+ }
+ else
+ {
+ int x_split = outW > 8 ? (outW >= 32 ? 16 : 8) : outW;
+ int y_split = outH > 8 ? (outH >= 32 ? 16 : 8) : outH;
+ top.split(x, xo, xi, x_split).split(y, yo, yi, y_split)
+ .split(c, co, ci, c_split)
+ .gpu_blocks(xo, yo, co)
+ .gpu_threads(xi, yi)
+ .reorder(xi, yi, ci, xo, yo, co)
+ .vectorize(ci);
+ }
+ }
+ else
+ CV_Error(Error::StsNotImplemented, "Unknown target identifier");
+#endif // HAVE_HALIDE
+}
+
+Ptr<BackendNode> Layer::tryAttach(const Ptr<BackendNode>& node)
+{
+ return Ptr<BackendNode>();
+}
+
+bool Layer::setActivation(const Ptr<ActivationLayer>&) { return false; }
+bool Layer::setBatchNorm(const Ptr<BatchNormLayer>&) { return false; }
+bool Layer::setScale(const Ptr<ScaleLayer>&) { return false; }
+void Layer::unsetAttached()
+{
+ setActivation(Ptr<ActivationLayer>());
+ setBatchNorm(Ptr<BatchNormLayer>());
+ setScale(Ptr<ScaleLayer>());
+}
+
+template <typename T>
+static void vecToPVec(const std::vector<T> &v, std::vector<T*> &pv)
+{
+ pv.resize(v.size());
+ for (size_t i = 0; i < v.size(); i++)
+ pv[i] = const_cast<T*>(&v[i]);
+}
+
+void Layer::finalize(const std::vector<Mat> &inputs, std::vector<Mat> &outputs)
+{
+ CV_TRACE_FUNCTION();
+
+ std::vector<Mat*> inputsp;
+ vecToPVec(inputs, inputsp);
+ this->finalize(inputsp, outputs);
+}
+
+void Layer::finalize(const std::vector<Mat*> &input, std::vector<Mat> &output)
+{
+ (void)input;(void)output;
+}
+
+std::vector<Mat> Layer::finalize(const std::vector<Mat> &inputs)
+{
+ CV_TRACE_FUNCTION();
+
+ std::vector<Mat> outputs;
+ this->finalize(inputs, outputs);
+ return outputs;
+}
+
+void Layer::forward(const std::vector<Mat> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+{
+ CV_TRACE_FUNCTION();
+
+ std::vector<Mat*> inputsp;
+ vecToPVec(inputs, inputsp);
+ this->forward(inputsp, outputs, internals);
+}
+
+void Layer::run(const std::vector<Mat> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+{
+ CV_TRACE_FUNCTION();
+
+ std::vector<Mat*> inputsp;
+ vecToPVec(inputs, inputsp);
+ this->finalize(inputsp, outputs);
+ this->forward(inputsp, outputs, internals);
+}
+
+Layer::~Layer() {}
+
+bool Layer::getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+{
+ CV_Assert(inputs.size());
+ outputs.assign(std::max(requiredOutputs, (int)inputs.size()), inputs[0]);
+ return false;
+}
+
+//////////////////////////////////////////////////////////////////////////
+
+static Mutex& getLayerFactoryMutex()
+{
+ static Mutex* volatile instance = NULL;
+ if (instance == NULL)
+ {
+ cv::AutoLock lock(getInitializationMutex());
+ if (instance == NULL)
+ instance = new Mutex();
+ }
+ return *instance;
+}
+
+typedef std::map<String, LayerFactory::Constuctor> LayerFactory_Impl;
+
+static LayerFactory_Impl& getLayerFactoryImpl_()
+{
+ static LayerFactory_Impl impl;
+ return impl;
+}
+
+static LayerFactory_Impl& getLayerFactoryImpl()
+{
+ static LayerFactory_Impl* volatile instance = NULL;
+ if (instance == NULL)
+ {
+ cv::AutoLock lock(getLayerFactoryMutex());
+ if (instance == NULL)
+ {
+ instance = &getLayerFactoryImpl_();
+ initializeLayerFactory();
+ }
+ }
+ return *instance;
+}
+
+void LayerFactory::registerLayer(const String &type, Constuctor constructor)
+{
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(type, "type", type.c_str());
+
+ cv::AutoLock lock(getLayerFactoryMutex());
+ String type_ = type.toLowerCase();
+ LayerFactory_Impl::const_iterator it = getLayerFactoryImpl().find(type_);
+
+ if (it != getLayerFactoryImpl().end() && it->second != constructor)
+ {
+ CV_Error(cv::Error::StsBadArg, "Layer \"" + type_ + "\" already was registered");
+ }
+
+ getLayerFactoryImpl().insert(std::make_pair(type_, constructor));
+}
+
+void LayerFactory::unregisterLayer(const String &type)
+{
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(type, "type", type.c_str());
+
+ cv::AutoLock lock(getLayerFactoryMutex());
+ String type_ = type.toLowerCase();
+ getLayerFactoryImpl().erase(type_);
+}
+
+Ptr<Layer> LayerFactory::createLayerInstance(const String &type, LayerParams& params)
+{
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(type, "type", type.c_str());
+
+ cv::AutoLock lock(getLayerFactoryMutex());
+ String type_ = type.toLowerCase();
+ LayerFactory_Impl::const_iterator it = getLayerFactoryImpl().find(type_);
+
+ if (it != getLayerFactoryImpl().end())
+ {
+ return it->second(params);
+ }
+ else
+ {
+ return Ptr<Layer>(); //NULL
+ }
+}
+
+BackendNode::BackendNode(int backendId) : backendId(backendId) {}
+
+BackendNode::~BackendNode() {};
+
+BackendWrapper::BackendWrapper(int backendId, int targetId)
+ : backendId(backendId), targetId(targetId) {}
+
+BackendWrapper::BackendWrapper(int targetId, const cv::Mat& m)
+{
+ CV_Error(Error::StsNotImplemented,
+ "Constructor of backend wrapper must be implemented");
+}
+
+BackendWrapper::BackendWrapper(const Ptr<BackendWrapper>& base, const MatShape& shape)
+{
+ CV_Error(Error::StsNotImplemented,
+ "Constructor of backend wrapper must be implemented");
+}
+
+BackendWrapper::~BackendWrapper() {}
+
+CV__DNN_EXPERIMENTAL_NS_END
+}} // namespace
diff --git a/modules/dnn/src/halide_scheduler.cpp b/modules/dnn/src/halide_scheduler.cpp
new file mode 100644
index 0000000..a2cb410
--- /dev/null
+++ b/modules/dnn/src/halide_scheduler.cpp
@@ -0,0 +1,285 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+//
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+
+#include "precomp.hpp"
+#include "halide_scheduler.hpp"
+#include "op_halide.hpp"
+
+namespace cv
+{
+namespace dnn
+{
+
+#ifdef HAVE_HALIDE
+static void applySplit(const FileNode& directive, Halide::Func& func,
+ const FileNode& params)
+{
+ for (const auto& varNode : directive)
+ {
+ const std::string varName = varNode.name();
+ const std::string factorName = (std::string)varNode;
+ Halide::Var var(varName);
+ Halide::Var outerVar(varName + "o");
+ Halide::Var innerVar(varName + "i");
+ // If split factor is integer or parameters map has parameter value.
+ CV_Assert(varNode.isString() && !params[factorName].empty() ||
+ varNode.isInt());
+ int factor = (int)(varNode.isInt() ? varNode : params[factorName]);
+ func.split(var, outerVar, innerVar, factor);
+ }
+}
+
+static void applyReorder(const FileNode& directive, Halide::Func& func)
+{
+ std::string varName;
+ const int numVars = directive.size();
+ std::vector<Halide::VarOrRVar> reorderedVars;
+ reorderedVars.reserve(numVars);
+ for (int i = 0; i < numVars; ++i)
+ {
+ directive[i] >> varName;
+ reorderedVars.push_back(Halide::Var(varName));
+ }
+ func.reorder(reorderedVars);
+}
+
+static void applyFuse(const FileNode& directive, Halide::Func& func)
+{
+ CV_Assert(directive["src"].size() >= 2);
+ CV_Assert(directive["dst"].size() == 1);
+
+ std::string str;
+ directive["src"][0] >> str;
+ Halide::Var firstVar(str);
+ directive["src"][1] >> str;
+ Halide::Var secondVar(str);
+ directive["dst"] >> str;
+ Halide::Var dstVar(str);
+
+ func.fuse(firstVar, secondVar, dstVar);
+ for (int i = 2, n = directive["src"].size(); i < n; ++i)
+ {
+ directive["src"][i] >> str;
+ func.fuse(Halide::Var(str), dstVar, dstVar);
+ }
+}
+
+static void applyParallel(const FileNode& directive, Halide::Func& func)
+{
+ std::string varName;
+ for (int i = 0, n = directive.size(); i < n; ++i)
+ {
+ directive[i] >> varName;
+ func.parallel(Halide::Var(varName));
+ }
+}
+
+static void applyUnroll(const FileNode& directive, Halide::Func& func)
+{
+ std::string varName;
+ for (int i = 0, n = directive.size(); i < n; ++i)
+ {
+ directive[i] >> varName;
+ func.unroll(Halide::Var(varName));
+ }
+}
+
+static void applyVectorize(const FileNode& directive, Halide::Func& func,
+ const FileNode& params)
+{
+ for (const auto& varNode : directive)
+ {
+ const std::string varName = varNode.name();
+ const std::string factorName = (std::string)varNode;
+ // If split factor is integer or parameters map has parameter value.
+ CV_Assert(varNode.isString() && !params[factorName].empty() ||
+ varNode.isInt());
+ int factor = (int)(varNode.isInt() ? varNode : params[factorName]);
+ Halide::Var var(varName);
+ Halide::Var inner(varName + "v");
+ func.split(var, var, inner, factor);
+ func.vectorize(inner);
+ }
+}
+
+static void applyStoreAt(const FileNode& directive, Halide::Func& func,
+ std::map<std::string, Halide::Func>& funcsMap)
+{
+ for (const auto& funcNode : directive)
+ {
+ const std::string targetFuncName = funcNode.name();
+ if (funcsMap.find(targetFuncName) == funcsMap.end())
+ CV_Error(cv::Error::StsParseError, "Function " + targetFuncName +
+ " is not represented in Halide pipeline");
+ Halide::Func targetFunc = funcsMap[targetFuncName];
+ func.store_at(targetFunc, (std::string)funcNode);
+ break;
+ }
+}
+
+static void applyComputeAt(const FileNode& directive, Halide::Func& func,
+ std::map<std::string, Halide::Func>& funcsMap)
+{
+ for (const auto& funcNode : directive)
+ {
+ const std::string targetFuncName = funcNode.name();
+ if (funcsMap.find(targetFuncName) == funcsMap.end())
+ CV_Error(cv::Error::StsParseError, "Function " + targetFuncName +
+ " is not represented in Halide pipeline");
+ Halide::Func targetFunc = funcsMap[targetFuncName];
+ func.compute_at(targetFunc, (std::string)funcNode);
+ break;
+ }
+}
+
+static void applyComputeRoot(const FileNode& directive, Halide::Func& func)
+{
+ bool compute_root;
+ directive >> compute_root;
+ if (compute_root)
+ func.compute_root();
+}
+
+static void applyGpuBlocks(const FileNode& directive, Halide::Func& func)
+{
+ std::string varName;
+ for (int i = 0, n = directive.size(); i < n; ++i)
+ {
+ directive[i] >> varName;
+ func.gpu_blocks(Halide::Var(varName));
+ }
+}
+
+static void applyGpuThreads(const FileNode& directive, Halide::Func& func)
+{
+ std::string varName;
+ for (int i = 0, n = directive.size(); i < n; ++i)
+ {
+ directive[i] >> varName;
+ func.gpu_threads(Halide::Var(varName));
+ }
+}
+
+static void apply(const FileNode& directives, Halide::Func& func,
+ std::map<std::string, Halide::Func>& funcsMap,
+ const FileNode& params)
+{
+ for (const auto& directive : directives)
+ {
+ if (directive.name() == "split")
+ applySplit(directive, func, params);
+ else if (directive.name() == "reorder")
+ applyReorder(directive, func);
+ else if (directive.name() == "fuse")
+ applyFuse(directive, func);
+ else if (directive.name() == "parallel")
+ applyParallel(directive, func);
+ else if (directive.name() == "unroll")
+ applyUnroll(directive, func);
+ else if (directive.name() == "vectorize")
+ applyVectorize(directive, func, params);
+ else if (directive.name() == "store_at")
+ applyStoreAt(directive, func, funcsMap);
+ else if (directive.name() == "compute_at")
+ applyComputeAt(directive, func, funcsMap);
+ else if (directive.name() == "compute_root")
+ applyComputeRoot(directive, func);
+ else if (directive.name() == "gpu_blocks")
+ applyGpuBlocks(directive, func);
+ else if (directive.name() == "gpu_threads")
+ applyGpuThreads(directive, func);
+ else
+ CV_Error(Error::StsNotImplemented, "Scheduling directive " +
+ directive.name() + " is not implemented.");
+ }
+}
+
+// Remove any numeric symbols after '$' sign.
+static std::string Deunique(std::string str)
+{
+ int pos = -1;
+ do
+ {
+ pos = str.find('$');
+ if (pos != -1)
+ {
+ int len = str.find_first_not_of("0123456789", pos + 1) - pos;
+ str = str.replace(pos, len, "");
+ }
+ }
+ while (pos != -1);
+ return str;
+}
+#endif // HAVE_HALIDE
+
+HalideScheduler::HalideScheduler(const std::string& configFile)
+{
+ if (!configFile.empty())
+ fs = FileStorage(configFile, FileStorage::READ);
+}
+
+HalideScheduler::~HalideScheduler()
+{
+ if (fs.isOpened())
+ fs.release();
+}
+
+bool HalideScheduler::process(Ptr<BackendNode>& node)
+{
+#ifdef HAVE_HALIDE
+ if (!fs.isOpened())
+ return false;
+
+ const FileNode& scheduleNode = fs["scheduling"];
+ if (scheduleNode.empty())
+ CV_Error(cv::Error::StsParseError, "Scheduling file should has scheduling node");
+
+ std::string str;
+ std::map<std::string, Halide::Func> funcsMap; // Scheduled functions.
+ // For every function, from top to bottom, we try to find a scheduling node.
+ // Scheduling is successful (return true) if for the first function (top)
+ // node is respresented.
+ CV_Assert(!node.empty());
+ std::vector<Halide::Func>& funcs = node.dynamicCast<HalideBackendNode>()->funcs;
+ for (int i = funcs.size() - 1; i >= 0; --i)
+ {
+ Halide::Func& func = funcs[i];
+ // For functions with the same name Halide generates unique names
+ // for example func, func$1, func$2.
+ // They are always formed with '$' and number.
+ std::string funcName = Deunique(func.name());
+
+ const FileNode& funcNode = scheduleNode[funcName];
+ if (!funcNode.empty())
+ {
+ if (!funcNode["pattern"].empty())
+ {
+ funcNode["pattern"] >> str;
+ if (fs["patterns"][str].empty())
+ CV_Error(cv::Error::StsParseError, "Scheduling pattern " + str +
+ " is not defined");
+ apply(fs["patterns"][str], func, funcsMap, funcNode["params"]);
+ }
+ else
+ {
+ apply(funcNode, func, funcsMap, funcNode["params"]);
+ }
+ }
+ else
+ {
+ if (funcsMap.empty())
+ return false;
+ }
+ funcsMap[funcName] = func;
+ }
+ return true;
+#endif // HAVE_HALIDE
+ return false;
+}
+
+} // namespace dnn
+} // namespace cv
diff --git a/modules/dnn/src/halide_scheduler.hpp b/modules/dnn/src/halide_scheduler.hpp
new file mode 100644
index 0000000..9afef30
--- /dev/null
+++ b/modules/dnn/src/halide_scheduler.hpp
@@ -0,0 +1,37 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+//
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+
+#ifndef __OPENCV_DNN_HALIDE_SCHEDULER_HPP__
+#define __OPENCV_DNN_HALIDE_SCHEDULER_HPP__
+
+#include <opencv2/dnn.hpp>
+
+namespace cv
+{
+namespace dnn
+{
+
+class HalideScheduler
+{
+public:
+ HalideScheduler(const std::string& configFile);
+
+ ~HalideScheduler();
+
+ // Returns true if pipeline found in scheduling file.
+ // If more than one function, returns true if the top function scheduled.
+ // Other functions are optional to scheduling.
+ bool process(Ptr<BackendNode>& node);
+
+private:
+ FileStorage fs;
+};
+
+} // namespace dnn
+} // namespace cv
+
+#endif // __OPENCV_DNN_HALIDE_SCHEDULER_HPP__
diff --git a/modules/dnn/src/init.cpp b/modules/dnn/src/init.cpp
new file mode 100644
index 0000000..32ff69e
--- /dev/null
+++ b/modules/dnn/src/init.cpp
@@ -0,0 +1,121 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "precomp.hpp"
+#include <opencv2/dnn/layer.details.hpp>
+
+#include <google/protobuf/stubs/common.h>
+
+namespace cv {
+namespace dnn {
+CV__DNN_EXPERIMENTAL_NS_BEGIN
+
+static Mutex* __initialization_mutex = NULL;
+Mutex& getInitializationMutex()
+{
+ if (__initialization_mutex == NULL)
+ __initialization_mutex = new Mutex();
+ return *__initialization_mutex;
+}
+// force initialization (single-threaded environment)
+Mutex* __initialization_mutex_initializer = &getInitializationMutex();
+
+namespace {
+using namespace google::protobuf;
+class ProtobufShutdown {
+public:
+ bool initialized;
+ ProtobufShutdown() : initialized(true) {}
+ ~ProtobufShutdown()
+ {
+ initialized = false;
+ google::protobuf::ShutdownProtobufLibrary();
+ }
+};
+} // namespace
+
+void initializeLayerFactory()
+{
+ CV_TRACE_FUNCTION();
+
+ static ProtobufShutdown protobufShutdown; (void)protobufShutdown;
+
+ CV_DNN_REGISTER_LAYER_CLASS(Slice, SliceLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(Split, SplitLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(Concat, ConcatLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(Reshape, ReshapeLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(Flatten, FlattenLayer);
+
+ CV_DNN_REGISTER_LAYER_CLASS(Convolution, ConvolutionLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(Deconvolution, DeconvolutionLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(Pooling, PoolingLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(LRN, LRNLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(InnerProduct, InnerProductLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(Softmax, SoftmaxLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(MVN, MVNLayer);
+
+ CV_DNN_REGISTER_LAYER_CLASS(ReLU, ReLULayer);
+ CV_DNN_REGISTER_LAYER_CLASS(ChannelsPReLU, ChannelsPReLULayer);
+ CV_DNN_REGISTER_LAYER_CLASS(Sigmoid, SigmoidLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(TanH, TanHLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(ELU, ELULayer);
+ CV_DNN_REGISTER_LAYER_CLASS(BNLL, BNLLLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(AbsVal, AbsLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(Power, PowerLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(BatchNorm, BatchNormLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(MaxUnpool, MaxUnpoolLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(Dropout, BlankLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(Identity, BlankLayer);
+
+ CV_DNN_REGISTER_LAYER_CLASS(Crop, CropLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(Eltwise, EltwiseLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(Permute, PermuteLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(PriorBox, PriorBoxLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(DetectionOutput, DetectionOutputLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(NormalizeBBox, NormalizeBBoxLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(Normalize, NormalizeBBoxLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(Shift, ShiftLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(Padding, PaddingLayer);
+ CV_DNN_REGISTER_LAYER_CLASS(Scale, ScaleLayer);
+}
+
+CV__DNN_EXPERIMENTAL_NS_END
+}} // namespace
diff --git a/modules/dnn/src/layers/batch_norm_layer.cpp b/modules/dnn/src/layers/batch_norm_layer.cpp
new file mode 100644
index 0000000..bd6133e
--- /dev/null
+++ b/modules/dnn/src/layers/batch_norm_layer.cpp
@@ -0,0 +1,201 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+// Copyright (C) 2016, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+
+/*
+Implementation of Batch Normalization layer.
+*/
+
+#include "../precomp.hpp"
+#include "op_halide.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv
+{
+namespace dnn
+{
+
+class BatchNormLayerImpl : public BatchNormLayer
+{
+public:
+ Mat weights_, bias_;
+
+ BatchNormLayerImpl(const LayerParams& params)
+ {
+ setParamsFrom(params);
+ CV_Assert(blobs.size() >= 3);
+
+ hasWeights = params.get<bool>("has_weight", false);
+ hasBias = params.get<bool>("has_bias", false);
+ epsilon = params.get<float>("eps", 1E-5);
+
+ size_t n = blobs[0].total();
+ CV_Assert(blobs[1].total() == n &&
+ blobs[0].isContinuous() && blobs[1].isContinuous() &&
+ blobs[0].type() == CV_32F && blobs[1].type() == CV_32F);
+
+ float varMeanScale = 1.f;
+ if (!hasWeights && !hasBias) {
+ CV_Assert(blobs[2].type() == CV_32F);
+ varMeanScale = blobs[2].at<float>(0);
+ if (varMeanScale != 0)
+ varMeanScale = 1/varMeanScale;
+ }
+
+ const int weightsBlobIndex = 2;
+ const int biasBlobIndex = weightsBlobIndex + hasWeights;
+
+ if( hasWeights )
+ {
+ CV_Assert((size_t)weightsBlobIndex < blobs.size());
+ const Mat& w = blobs[weightsBlobIndex];
+ CV_Assert(w.isContinuous() && w.type() == CV_32F && w.total() == (size_t)n);
+ }
+
+ if( hasBias )
+ {
+ CV_Assert((size_t)biasBlobIndex < blobs.size());
+ const Mat& b = blobs[weightsBlobIndex];
+ CV_Assert(b.isContinuous() && b.type() == CV_32F && b.total() == (size_t)n);
+ }
+
+ const float* meanData = blobs[0].ptr<float>();
+ const float* stdData = blobs[1].ptr<float>();
+ const float* weightsData = hasWeights ? blobs[weightsBlobIndex].ptr<float>() : 0;
+ const float* biasData = hasBias ? blobs[biasBlobIndex].ptr<float>() : 0;
+
+ weights_.create(1, (int)n, CV_32F);
+ bias_.create(1, (int)n, CV_32F);
+
+ float* dstWeightsData = weights_.ptr<float>();
+ float* dstBiasData = bias_.ptr<float>();
+
+ for (size_t i = 0; i < n; ++i)
+ {
+ float w = (hasWeights ? weightsData[i] : 1.0f) / sqrt(stdData[i] * varMeanScale + epsilon);
+ dstWeightsData[i] = w;
+ dstBiasData[i] = (hasBias ? biasData[i] : 0.0f) - w * meanData[i] * varMeanScale;
+ }
+ }
+
+ void getScaleShift(Mat& scale, Mat& shift) const
+ {
+ scale = weights_;
+ shift = bias_;
+ }
+
+ bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+ {
+ Layer::getMemoryShapes(inputs, requiredOutputs, outputs, internals);
+ return true;
+ }
+
+ virtual bool supportBackend(int backendId)
+ {
+ return backendId == DNN_BACKEND_DEFAULT ||
+ backendId == DNN_BACKEND_HALIDE && haveHalide();
+ }
+
+ void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ CV_Assert(blobs.size() >= 2);
+ CV_Assert(inputs.size() == 1);
+
+ Mat &inpBlob = *inputs[0];
+ int rows = inpBlob.size[2];
+ int cols = inpBlob.size[3];
+
+ for (size_t ii = 0; ii < outputs.size(); ii++)
+ {
+ Mat &outBlob = outputs[ii];
+
+ for(int num = 0; num < outBlob.size[0]; num++)
+ {
+ for (int n = 0; n < outBlob.size[1]; n++)
+ {
+ float w = weights_.at<float>(n);
+ float b = bias_.at<float>(n);
+ Mat inpBlobPlane(rows, cols, CV_32F, inpBlob.ptr<float>(num, n));
+ Mat outBlobPlane(rows, cols, CV_32F, outBlob.ptr<float>(num, n));
+ inpBlobPlane.convertTo(outBlobPlane, CV_32F, w, b);
+ }
+ }
+ }
+ }
+
+ virtual Ptr<BackendNode> tryAttach(const Ptr<BackendNode>& node)
+ {
+ switch (node->backendId)
+ {
+ case DNN_BACKEND_HALIDE:
+ {
+#ifdef HAVE_HALIDE
+ auto base = node.dynamicCast<HalideBackendNode>();
+ Halide::Func& input = base->funcs.back();
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ Halide::Func top = attachHalide(input(x, y, c, n));
+ return Ptr<BackendNode>(new HalideBackendNode(base, top));
+#endif // HAVE_HALIDE
+ break;
+ }
+ }
+ return Ptr<BackendNode>();
+ }
+
+ virtual Ptr<BackendNode> initHalide(const std::vector<Ptr<BackendWrapper> > &inputs)
+ {
+#ifdef HAVE_HALIDE
+ Halide::Buffer<float> input = halideBuffer(inputs[0]);
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ Halide::Func top = attachHalide(input(x, y, c, n));
+ return Ptr<BackendNode>(new HalideBackendNode(top));
+#endif // HAVE_HALIDE
+ return Ptr<BackendNode>();
+ }
+
+#ifdef HAVE_HALIDE
+ // attachHalide can work both with Halide::Buffer and Halide::Func. In the
+ // second case it will be a fusion.
+ Halide::Func attachHalide(const Halide::Expr& input)
+ {
+ Halide::Func top = (name.empty() ? Halide::Func() : Halide::Func(name));
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+
+ const int numChannels = weights_.total();
+ auto weights = wrapToHalideBuffer(weights_, {numChannels});
+ auto bias = wrapToHalideBuffer(bias_, {numChannels});
+ top(x, y, c, n) = input * weights(c) + bias(c);
+ return top;
+ }
+#endif // HAVE_HALIDE
+
+ virtual int64 getFLOPS(const std::vector<MatShape> &inputs,
+ const std::vector<MatShape> &outputs) const
+ {
+ (void)outputs; // suppress unused variable warning
+
+ int64 flops = 0;
+ for(int i = 0; i < inputs.size(); i++)
+ {
+ flops += 3*total(inputs[i]);
+ }
+ return flops;
+ }
+};
+
+Ptr<BatchNormLayer> BatchNormLayer::create(const LayerParams& params)
+{
+ return Ptr<BatchNormLayer>(new BatchNormLayerImpl(params));
+}
+
+} // namespace dnn
+} // namespace cv
diff --git a/modules/dnn/src/layers/blank_layer.cpp b/modules/dnn/src/layers/blank_layer.cpp
new file mode 100644
index 0000000..4c18517
--- /dev/null
+++ b/modules/dnn/src/layers/blank_layer.cpp
@@ -0,0 +1,82 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+#include "../precomp.hpp"
+
+namespace cv
+{
+namespace dnn
+{
+class BlankLayerImpl : public BlankLayer
+{
+public:
+ BlankLayerImpl(const LayerParams& params)
+ {
+ setParamsFrom(params);
+ }
+
+ bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+ {
+ Layer::getMemoryShapes(inputs, requiredOutputs, outputs, internals);
+ return true;
+ }
+
+ void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ for (int i = 0, n = outputs.size(); i < n; ++i)
+ if (outputs[i].data != inputs[i]->data)
+ inputs[i]->copyTo(outputs[i]);
+ }
+};
+
+Ptr<BlankLayer> BlankLayer::create(const LayerParams& params)
+{
+ return Ptr<BlankLayer>(new BlankLayerImpl(params));
+}
+
+}
+}
diff --git a/modules/dnn/src/layers/concat_layer.cpp b/modules/dnn/src/layers/concat_layer.cpp
new file mode 100644
index 0000000..662be1d
--- /dev/null
+++ b/modules/dnn/src/layers/concat_layer.cpp
@@ -0,0 +1,226 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include "op_halide.hpp"
+
+namespace cv
+{
+namespace dnn
+{
+
+class ConcatLayerImpl : public ConcatLayer
+{
+public:
+ ConcatLayerImpl(const LayerParams& params)
+ {
+ setParamsFrom(params);
+ axis = params.get<int>("axis", 1);
+ }
+
+ virtual bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+ {
+ CV_Assert(inputs.size() > 0);
+ outputs.clear();
+ outputs.push_back(inputs[0]);
+ int cAxis = clamp(axis, inputs[0]);
+
+ int axisSum = 0;
+ for (size_t i = 0; i < inputs.size(); i++)
+ {
+ MatShape curShape = inputs[i];
+
+ CV_Assert(curShape.size() == outputs.back().size());
+ for (int curAxis = 0; curAxis < outputs.back().size(); curAxis++)
+ {
+ if (curAxis != cAxis && outputs.back()[curAxis] != curShape[curAxis])
+ CV_Error(Error::StsBadSize, "Inconsitent shape for ConcatLayer");
+ }
+
+ axisSum += curShape[cAxis];
+ }
+
+ outputs.back()[cAxis] = axisSum;
+
+ return false;
+ }
+
+ virtual bool supportBackend(int backendId)
+ {
+ return backendId == DNN_BACKEND_DEFAULT ||
+ backendId == DNN_BACKEND_HALIDE && haveHalide() && axis == 1; // By channels
+ }
+
+ class ChannelConcatInvoker : public ParallelLoopBody
+ {
+ public:
+ std::vector<Mat*>* inputs;
+ Mat* output;
+ int nstripes;
+ std::vector<const float*> chptrs;
+
+ static void run(std::vector<Mat*>& inputs, Mat& output, int nstripes)
+ {
+ ChannelConcatInvoker cc;
+ cc.inputs = &inputs;
+ cc.output = &output;
+ cc.nstripes = nstripes;
+
+ size_t i, ninputs = inputs.size();
+ int nchannels = 0, batchsz = output.size[0];
+ for( i = 0; i < ninputs; i++ )
+ {
+ Mat& inp = *inputs[i];
+ CV_Assert( inp.isContinuous() && inp.type() == CV_32F &&
+ inp.dims == 4 && inp.size[0] == output.size[0] &&
+ inp.size[2] == output.size[2] &&
+ inp.size[3] == output.size[3] );
+ nchannels += inp.size[1];
+ }
+ CV_Assert( nchannels == output.size[1] );
+ CV_Assert( output.isContinuous() && output.type() == CV_32F );
+
+ cc.chptrs.resize(nchannels*batchsz);
+
+ int ofs = 0;
+ for( i = 0; i < ninputs; i++)
+ {
+ Mat& inp = *inputs[i];
+ for( int j = 0; j < batchsz; j++ )
+ for( int k = 0; k < inp.size[1]; k++ )
+ {
+ const float* ptr = inp.ptr<float>(j, k);
+ cc.chptrs[ofs + j*nchannels + k] = ptr;
+ }
+ ofs += inp.size[1];
+ }
+
+ parallel_for_(Range(0, nstripes), cc, nstripes);
+ }
+
+ ChannelConcatInvoker() {}
+
+ void operator()(const Range& r) const
+ {
+ size_t planeSize = (size_t)output->size[2]*output->size[3];
+ size_t nch = chptrs.size();
+ size_t total = nch*planeSize;
+ size_t stripeSize = (total + nstripes - 1)/nstripes;
+ size_t stripeStart = r.start*stripeSize;
+ size_t stripeEnd = std::min(total, r.end*stripeSize);
+ const float** ptrs = (const float**)&chptrs[0];
+ float* outptr = output->ptr<float>();
+ size_t blockSize0 = 1 << 16;
+
+ for( size_t ofs0 = stripeStart; ofs0 < stripeEnd; )
+ {
+ size_t ch = ofs0/planeSize;
+ size_t ofs = ofs0 - ch*planeSize;
+ size_t blockSize = std::min(blockSize0, planeSize - ofs);
+ memcpy(outptr + ofs0, ptrs[ch] + ofs, blockSize*sizeof(outptr[0]));
+ ofs0 += blockSize;
+ }
+ }
+ };
+
+ void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ int cAxis = clamp(axis, inputs[0]->dims);
+ Mat& outMat = outputs[0];
+
+ if( cAxis == 1 && outMat.dims == 4 )
+ {
+ int nstripes = getNumThreads();
+ ChannelConcatInvoker::run(inputs, outMat, nstripes);
+ }
+ else
+ {
+ std::vector<Range> ranges(outputs[0].dims, Range::all());
+
+ ranges[cAxis].start = 0;
+ for (size_t i = 0; i < inputs.size(); i++)
+ {
+ ranges[cAxis].end = ranges[cAxis].start + inputs[i]->size[cAxis];
+ inputs[i]->copyTo(outMat(&ranges[0]));
+ ranges[cAxis].start = ranges[cAxis].end;
+ }
+ }
+ }
+
+ virtual Ptr<BackendNode> initHalide(const std::vector<Ptr<BackendWrapper> > &input)
+ {
+#ifdef HAVE_HALIDE
+ std::vector<Halide::Buffer<> > inputBuffers = halideBuffers(input);
+
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ Halide::Func top = (name.empty() ? Halide::Func() : Halide::Func(name));
+ int offset = inputBuffers[0].channels();
+ Halide::Expr topExpr = select(c < offset,
+ inputBuffers[0](x, y, c, n),
+ inputBuffers[1](x, y, c - offset, n));
+ for (int i = 2; i < input.size(); ++i)
+ {
+ offset += inputBuffers[i - 1].channels();
+ topExpr = select(c < offset, topExpr,
+ inputBuffers[i](x, y, c - offset, n));
+ }
+ top(x, y, c, n) = topExpr;
+ return Ptr<BackendNode>(new HalideBackendNode(top));
+#endif // HAVE_HALIDE
+ return Ptr<BackendNode>();
+ }
+};
+
+Ptr<ConcatLayer> ConcatLayer::create(const LayerParams& params)
+{
+ return Ptr<ConcatLayer>(new ConcatLayerImpl(params));
+}
+
+}
+}
diff --git a/modules/dnn/src/layers/convolution_layer.cpp b/modules/dnn/src/layers/convolution_layer.cpp
new file mode 100644
index 0000000..4bf829c
--- /dev/null
+++ b/modules/dnn/src/layers/convolution_layer.cpp
@@ -0,0 +1,1225 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include "op_halide.hpp"
+#include "opencv2/core/hal/hal.hpp"
+#include "opencv2/core/hal/intrin.hpp"
+#include <iostream>
+
+namespace cv
+{
+namespace dnn
+{
+
+class BaseConvolutionLayerImpl : public ConvolutionLayer
+{
+public:
+ BaseConvolutionLayerImpl() {}
+
+ virtual bool supportBackend(int backendId)
+ {
+ return backendId == DNN_BACKEND_DEFAULT ||
+ backendId == DNN_BACKEND_HALIDE && haveHalide();
+ }
+
+ void finalize(const std::vector<Mat*> &inputs, std::vector<Mat> &outputs)
+ {
+ CV_Assert(inputs.size() > 0);
+
+ CV_Assert(blobs.size() >= 1 && blobs.size() <= 2);
+ CV_Assert(blobs[0].dims == 4 && blobs[0].size[3] == kernel.width && blobs[0].size[2] == kernel.height);
+
+ const Mat &input = *inputs[0];
+ CV_Assert(input.dims == 4 && (input.type() == CV_32F || input.type() == CV_64F));
+ for (size_t i = 0; i < inputs.size(); i++)
+ {
+ CV_Assert(inputs[i]->type() == input.type());
+ CV_Assert(inputs[i]->dims == 4 && inputs[i]->size[1] == input.size[1]);
+ CV_Assert(inputs[i]->size[2] == input.size[2] && inputs[i]->size[3] == input.size[3]);
+ }
+
+ Size outSize = Size(outputs[0].size[3], outputs[0].size[2]);
+ getConvPoolPaddings(Size(input.size[3], input.size[2]), outSize,
+ kernel, stride, padMode, pad);
+ }
+
+ bool hasBias() const
+ {
+ return blobs.size() >= 2;
+ }
+
+ virtual MatShape computeColRowShape(const MatShape &inpShape, const MatShape &outShape) const = 0;
+ bool is1x1() const
+ {
+ return (kernel.height == 1 && kernel.width == 1) &&
+ (stride.height == 1 && stride.width == 1) &&
+ (dilation.height == 1 && dilation.width == 1);
+ }
+
+ virtual void applyHalideScheduler(Ptr<BackendNode>& node,
+ const std::vector<Mat*> &inputs,
+ const std::vector<Mat> &outputs,
+ int targetId) const
+ {
+#ifdef HAVE_HALIDE
+ if (targetId != DNN_TARGET_CPU)
+ {
+ Layer::applyHalideScheduler(node, inputs, outputs, targetId);
+ return;
+ }
+ Halide::Var x("x"), y("y"), c("c"), n("n"), tile("tile"), yi("yi"), yo("yo"), co("co"), ci("ci");
+ Halide::Func& top = node.dynamicCast<HalideBackendNode>()->funcs[1];
+ Halide::Func& padded_input = node.dynamicCast<HalideBackendNode>()->funcs[0];
+
+ int outW, outH, outC, outN;
+ getCanonicalSize(outputs[0].size, &outW, &outH, &outC, &outN);
+
+ if (outW == 1 || outH <= 2)
+ return;
+
+ if (is1x1() || outC <= 16)
+ top.reorder(x, c, y)
+ .split(y, yo, yi, 2)
+ .fuse(yo, n, tile)
+ .parallel(tile)
+ .unroll(yi)
+ .vectorize(x, outW >= 16 ? 16 : outW);
+ else
+ top.reorder(x, c, y)
+ .split(y, yo, yi, 2)
+ .split(c, co, ci, 16)
+ .fuse(yo, co, tile).fuse(n, tile, tile)
+ .parallel(tile)
+ .unroll(yi)
+ .vectorize(x, outW >= 16 ? 16 : outW);
+ padded_input.compute_at(top, yi);
+#endif // HAVE_HALIDE
+ }
+};
+
+//TODO: simultaneously convolution and bias addition for cache optimization
+class ConvolutionLayerImpl : public BaseConvolutionLayerImpl
+{
+public:
+ enum { VEC_ALIGN = 8, DFT_TYPE = CV_32F };
+ Mat weightsMat;
+ std::vector<float> biasvec;
+ std::vector<float> reluslope;
+ Ptr<ActivationLayer> activ;
+ Ptr<BatchNormLayer> bnorm;
+ Ptr<ScaleLayer> scaleLayer;
+
+ MatShape computeColRowShape(const MatShape &inpShape, const MatShape &outShape) const
+ {
+ Size out(outShape[3], outShape[2]);
+ int inpGroupCn = blobs[0].size[1];
+ int ksize = inpGroupCn * kernel.height * kernel.width;
+ return shape(out.area(), ksize);
+ }
+
+ bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+ {
+ CV_Assert(blobs.size() != 0);
+ CV_Assert(!hasBias() || blobs[1].total() == (size_t)blobs[0].size[0]);
+ CV_Assert(inputs.size() == (size_t)1);
+
+ internals.clear();
+
+ int inpCn = inputs[0][1];
+ int inpH = inputs[0][2];
+ int inpW = inputs[0][3];
+
+ int outCn = blobs[0].size[0];
+ Size out;
+
+ if (padMode.empty())
+ {
+ out.height = (inpH + 2 * pad.height - (dilation.height * (kernel.height - 1) + 1)) / stride.height + 1;
+ out.width = (inpW + 2 * pad.width - (dilation.width * (kernel.width - 1) + 1)) / stride.width + 1;
+ }
+ else
+ {
+ getConvPoolOutParams(Size(inpW, inpH), kernel, stride, padMode, out);
+ }
+
+ int ngroups = inpCn / blobs[0].size[1];
+ CV_Assert(inpCn % ngroups == 0 && outCn % ngroups == 0);
+
+ int dims[] = {inputs[0][0], outCn, out.height, out.width};
+ outputs.resize(inputs.size(), shape(dims));
+
+ return false;
+ }
+
+ bool setActivation(const Ptr<ActivationLayer>& layer)
+ {
+ activ = layer;
+ if (activ.empty())
+ reluslope.clear();
+ return !activ.empty();
+ }
+
+ bool setBatchNorm(const Ptr<BatchNormLayer>& layer )
+ {
+ // for now the scale layer followed by the batch norm cannot be fused, only vice versa.
+ if( !scaleLayer.empty() )
+ return false;
+ bnorm = layer;
+ // we will need to re-compute the weights with the batch
+ // norm coefficients taken into account
+ weightsMat.release();
+ return !bnorm.empty();
+ }
+
+ bool setScale(const Ptr<ScaleLayer>& layer)
+ {
+ scaleLayer = layer;
+ // we will need to re-compute the weights with the scaling
+ // coefficients taken into account
+ weightsMat.release();
+ return !scaleLayer.empty();
+ }
+
+ virtual Ptr<BackendNode> initHalide(const std::vector<Ptr<BackendWrapper> > &inputs)
+ {
+#ifdef HAVE_HALIDE
+ Halide::Buffer<float> inputBuffer = halideBuffer(inputs[0]);
+
+ const int inpCn = inputBuffer.channels();
+ const int outCn = blobs[0].size[0];
+ const int inpGroupCn = blobs[0].size[1];
+ const int group = inpCn / inpGroupCn;
+ const int outGroupCn = outCn / group;
+
+ Halide::Buffer<float> weights = wrapToHalideBuffer(blobs[0]);
+
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ Halide::Func top = (name.empty() ? Halide::Func() : Halide::Func(name));
+ Halide::Func padded_input(name + "_constant_exterior");
+ if (pad.width || pad.height)
+ {
+ Halide::Func bounded =
+ Halide::BoundaryConditions::constant_exterior(inputBuffer, 0);
+ padded_input(x, y, c, n) = bounded(x, y, c, n);
+ }
+ else
+ {
+ padded_input(x, y, c, n) = inputBuffer(x, y, c, n);
+ }
+
+ Halide::RDom r(0, kernel.width, 0, kernel.height, 0, inpGroupCn);
+
+ Halide::Expr kc = r.z;
+ if (group > 1)
+ {
+ int outCnBound = outGroupCn;
+ int inpChBound = inpGroupCn;
+ Halide::Expr shift = select(c < outCnBound, 0, inpChBound);
+ for (int i = 2; i < group; ++i)
+ {
+ outCnBound += outGroupCn;
+ inpChBound += inpGroupCn;
+ shift = select(c < outCnBound, shift, inpChBound);
+ }
+ kc += shift;
+ }
+
+ Halide::Expr kx = x * stride.width - pad.width + r.x * dilation.width;
+ Halide::Expr ky = y * stride.height - pad.height + r.y * dilation.height;
+ Halide::Expr topExpr = sum(padded_input(kx, ky, kc, n) *
+ weights(r.x, r.y, r.z, c));
+ if (hasBias())
+ {
+ Halide::Buffer<float> bias = wrapToHalideBuffer(blobs[1], {outCn});
+ topExpr += bias(c);
+ }
+ top(x, y, c, n) = topExpr;
+ Ptr<BackendNode> pp(new HalideBackendNode({ padded_input, top }));
+ return Ptr<BackendNode>(new HalideBackendNode({ padded_input, top }));
+#endif // HAVE_HALIDE
+ return Ptr<BackendNode>();
+ }
+
+ class ParallelConv : public cv::ParallelLoopBody
+ {
+ public:
+ enum { BLK_SIZE = 32, BLK_SIZE_CN = 64 };
+
+ const Mat* input_;
+ const Mat* weights_;
+ Mat* output_;
+ int outShape[4];
+ Size kernel_, pad_, stride_, dilation_;
+ int ngroups_, nstripes_;
+ std::vector<int> ofstab_;
+ const std::vector<float>* biasvec_;
+ const std::vector<float>* reluslope_;
+ const ActivationLayer* activ_;
+ bool is1x1_;
+ bool useAVX;
+ bool useAVX2;
+
+ ParallelConv()
+ : input_(0), weights_(0), output_(0), ngroups_(0), nstripes_(0),
+ biasvec_(0), reluslope_(0), activ_(0), is1x1_(false), useAVX(false), useAVX2(false)
+ {}
+
+ static void run( const Mat& input, Mat& output, const Mat& weights,
+ const std::vector<float>& biasvec,
+ const std::vector<float>& reluslope,
+ Size kernel, Size pad, Size stride, Size dilation,
+ const ActivationLayer* activ, int ngroups, int nstripes )
+ {
+ CV_Assert( input.dims == 4 && output.dims == 4 &&
+ input.size[0] == output.size[0] &&
+ weights.rows == output.size[1] &&
+ weights.cols == (input.size[1]/ngroups)*kernel.width*kernel.height &&
+ input.type() == output.type() &&
+ input.type() == weights.type() &&
+ input.type() == CV_32F &&
+ input.isContinuous() &&
+ output.isContinuous() &&
+ biasvec.size() == (size_t)output.size[1]+2);
+ ParallelConv p;
+
+ p.input_ = &input;
+ p.weights_ = &weights;
+ p.output_ = &output;
+ for( int i = 0; i < 4; i++ ) p.outShape[i] = output.size[i];
+ p.outShape[1] /= ngroups;
+ p.kernel_ = kernel; p.pad_ = pad; p.stride_ = stride; p.dilation_ = dilation;
+ p.ngroups_ = ngroups;
+ p.nstripes_ = nstripes;
+
+ int inpCnAll = input.size[1], width = input.size[3], height = input.size[2];
+ int inpCn = inpCnAll / ngroups;
+ p.is1x1_ = kernel == Size(0,0) && pad == Size(0, 0);
+ p.useAVX = checkHardwareSupport(CPU_AVX);
+ p.useAVX2 = checkHardwareSupport(CPU_AVX2);
+
+ int ncn = std::min(inpCn, (int)BLK_SIZE_CN);
+ p.ofstab_.resize(kernel.width*kernel.height*ncn);
+ int* ofstab = &p.ofstab_[0];
+
+ for( int k = 0; k < ncn; k++ )
+ for( int k_r = 0; k_r < kernel.height; k_r++ )
+ for( int k_c = 0; k_c < kernel.width; k_c++ )
+ ofstab[(k*kernel.height + k_r)*kernel.width + k_c] =
+ (k*height + k_r*dilation.height)*width + k_c*dilation.width;
+
+ p.biasvec_ = &biasvec;
+ p.reluslope_ = &reluslope;
+ p.activ_ = p.reluslope_->empty() ? activ : 0;
+
+ parallel_for_(Range(0, nstripes), p, nstripes);
+ }
+
+ virtual void operator ()(const Range &r0) const
+ {
+ const int valign = ConvolutionLayerImpl::VEC_ALIGN;
+ int ngroups = ngroups_, batchSize = input_->size[0]*ngroups;
+ int outW = output_->size[3], outH = output_->size[2], outCn = output_->size[1]/ngroups;
+ int width = input_->size[3], height = input_->size[2], inpCn = input_->size[1]/ngroups;
+ int nstripes = nstripes_;
+ int kernel_w = kernel_.width, kernel_h = kernel_.height;
+ int pad_w = pad_.width, pad_h = pad_.height;
+ int stride_w = stride_.width, stride_h = stride_.height;
+ int dilation_w = dilation_.width, dilation_h = dilation_.height;
+ int karea = kernel_w*kernel_h;
+ int i, j, k;
+ size_t inpPlaneSize = width*height;
+ size_t outPlaneSize = outW*outH;
+ bool is1x1 = is1x1_;
+
+ int stripesPerSample;
+ size_t stripeSize;
+ Range r = r0;
+
+ if( nstripes >= batchSize*2 )
+ {
+ stripesPerSample = nstripes/batchSize;
+ stripeSize = alignSize((outPlaneSize + stripesPerSample - 1)/stripesPerSample, valign);
+ stripeSize = std::min(stripeSize, outPlaneSize);
+ }
+ else
+ {
+ stripesPerSample = 1;
+ int samplesPerStripe = std::max((batchSize + nstripes - 1)/nstripes, 1);
+ r.start *= samplesPerStripe;
+ r.end *= samplesPerStripe;
+ nstripes *= samplesPerStripe;
+ stripeSize = outPlaneSize;
+ }
+
+ const float* data_inp0_ = input_->ptr<float>();
+ const int* ofstab = &ofstab_[0];
+ const float* wptr_orig_ = weights_->ptr<float>();
+ size_t wstep = weights_->step1();
+ const float* biasptr_ = &biasvec_->at(0);
+ const float* reluptr_ = reluslope_->empty() ? 0 : &reluslope_->at(0);
+ float* data_out0_ = output_->ptr<float>();
+ size_t rowbufsz = (size_t)karea*BLK_SIZE_CN*BLK_SIZE;
+ AutoBuffer<float> rowbuf0_(rowbufsz + valign);
+ float* rowbuf0 = alignPtr((float*)rowbuf0_, (int)(valign*sizeof(float)));
+
+ // we clear the buffer once; ultimately, it lets us to avoid
+ // tail processing after running the unrolled/vectorized loop.
+ // the main idea is to make sure that the tail (a.k.a. padding) of each row
+ // (i.e. the elements with indices between vsz=karea*ncn and vsz_a)
+ // does not contain NaNs or Infs. Because the padding in the weights
+ // matrix is explicitly initialized with 0's, we handle all other
+ // cases nicely, i.e. we can skip expliciting re-initialization
+ // of the padding - we just retain elements from the previous iteration
+ // of the loop over channels (cn0).
+ memset(rowbuf0, 0, rowbufsz*sizeof(rowbuf0[0]) );
+
+ for( int stripe = r.start; stripe < r.end; stripe++ )
+ {
+ int subsampleIdx = stripe/stripesPerSample;
+ if( subsampleIdx >= batchSize )
+ break;
+ int stripeStart = (int)((stripe - subsampleIdx*stripesPerSample)*stripeSize);
+ int stripeEnd = (int)std::min(stripeStart + stripeSize, outPlaneSize);
+ const float* data_inp0 = data_inp0_ + subsampleIdx*inpPlaneSize*inpCn;
+ float* data_out0 = data_out0_ + subsampleIdx*outPlaneSize*outCn;
+ int startOutCn = (subsampleIdx % ngroups)*outCn;
+ const float* wptr_orig = wptr_orig_ + wstep*startOutCn;
+ const float* biasptr = biasptr_ + startOutCn;
+
+ for( int cn0 = 0; cn0 < inpCn; cn0 += BLK_SIZE_CN )
+ {
+ int cn1 = std::min(cn0 + BLK_SIZE_CN, inpCn);
+ int ncn = cn1 - cn0, vsz = karea*ncn;
+ int vsz_a = (int)alignSize(vsz, valign);
+ const float* wptr = wptr_orig + cn0*karea;
+ // we apply [Channels][P]ReLU (if any) during the final pass only.
+ const float* relu = cn1 == inpCn && reluptr_ ? reluptr_ + startOutCn : 0;
+
+ for( int ofs0 = stripeStart; ofs0 < stripeEnd; ofs0 += BLK_SIZE )
+ {
+ int ofs, ofs1 = std::min(ofs0 + BLK_SIZE, stripeEnd);
+ int out_i = ofs0 / outW;
+ int out_j = ofs0 - out_i * outW;
+
+ // do im2row for a part of input tensor
+ float* rowbuf = rowbuf0;
+ for( ofs = ofs0; ofs < ofs1; out_j = 0, ++out_i )
+ {
+ int delta = std::min(ofs1 - ofs, outW - out_j);
+ int out_j1 = out_j + delta;
+ int in_i = out_i * stride_h - pad_h;
+ int in_j = out_j * stride_w - pad_w;
+ const float* imgptr = data_inp0 + (cn0*height + in_i)*width + in_j;
+ ofs += delta;
+
+ // do im2row for a part of input tensor
+ if( is1x1 )
+ {
+ for( ; out_j < out_j1; out_j++, rowbuf += vsz_a, imgptr += stride_w )
+ {
+ for( k = 0; k < vsz; k++ )
+ rowbuf[k] = imgptr[k*inpPlaneSize];
+ }
+ }
+ else
+ {
+ bool ok_i = 0 <= in_i && in_i < height - (kernel_h-1)*dilation_h;
+ int i0 = std::max(0, (-in_i + dilation_h-1)/dilation_h);
+ int i1 = std::min(kernel_h, (height - in_i + dilation_h-1)/dilation_h);
+
+ for( ; out_j < out_j1; out_j++, rowbuf += vsz_a, imgptr += stride_w, in_j += stride_w )
+ {
+ // this condition should be true for most of the tensor elements, i.e.
+ // most of the time the kernel aperture is inside the tensor X-Y plane.
+ if( ok_i && out_j + 2 <= out_j1 && 0 <= in_j && in_j + stride_w*2 <= width - (kernel_w-1)*dilation_w )
+ {
+ for( k = 0; k < vsz; k++ )
+ {
+ int k1 = ofstab[k];
+ float v0 = imgptr[k1];
+ float v1 = imgptr[k1 + stride_w];
+ rowbuf[k] = v0;
+ rowbuf[k+vsz_a] = v1;
+ }
+ out_j++;
+ rowbuf += vsz_a;
+ imgptr += stride_w;
+ in_j += stride_w;
+ }
+ else
+ {
+ int j0 = std::max(0, (-in_j + dilation_w-1)/dilation_w);
+ int j1 = std::min(kernel_w, (width - in_j + dilation_w-1)/dilation_w);
+
+ // here some non-continous sub-row of the row will not be
+ // filled from the tensor; we need to make sure that the uncovered
+ // elements are explicitly set to 0's. the easiest way is to
+ // set all the elements to 0's before the loop.
+ memset(rowbuf, 0, vsz*sizeof(rowbuf[0]));
+ for( k = 0; k < ncn; k++ )
+ {
+ for( i = i0; i < i1; i++ )
+ {
+ for( j = j0; j < j1; j++ )
+ {
+ int imgofs = k*(width*height) + i*(dilation_h*width) + j*dilation_w;
+ rowbuf[(k*kernel_h + i)*kernel_w + j] = imgptr[imgofs];
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // now compute dot product of the weights
+ // and im2row-transformed part of the tensor
+ int bsz = ofs1 - ofs0;
+ #if CV_TRY_AVX2
+ if(useAVX2)
+ opt_AVX2::fastConv(wptr, wstep, biasptr, rowbuf0, data_out0 + ofs0,
+ outShape, bsz, vsz, vsz_a, relu, cn0 == 0);
+ else
+ #endif
+ #if CV_TRY_AVX
+ if(useAVX)
+ opt_AVX::fastConv(wptr, wstep, biasptr, rowbuf0, data_out0 + ofs0,
+ outShape, bsz, vsz, vsz_a, relu, cn0 == 0);
+ else
+ #endif
+ for( int i = 0; i < outCn; i += 2 )
+ {
+ const float* wptr0 = wptr + i*wstep;
+ const float* wptr1 = wptr0 + wstep;
+ float* outptr0 = data_out0 + ofs0 + i*outPlaneSize;
+ float* outptr1 = outptr0 + outPlaneSize;
+ float bias0 = biasptr[i], bias1 = biasptr[i+1];
+ float r0 = 1.f, r1 = 1.f;
+
+ if( i+1 >= outCn )
+ {
+ wptr1 = wptr0;
+ outptr1 = outptr0;
+ bias1 = bias0;
+ }
+
+ if( relu )
+ {
+ r0 = relu[i];
+ r1 = relu[i+1];
+ }
+
+ int j = 0;
+ #if CV_SIMD128
+ v_float32x4 vr0 = v_setall_f32(r0), vr1 = v_setall_f32(r1), z = v_setzero_f32();
+
+ for( ; j <= bsz - 4; j += 4 )
+ {
+ const float* rptr = rowbuf0 + j*vsz_a;
+ v_float32x4 s0, s1;
+
+ if( cn0 == 0 )
+ {
+ s0 = v_setall_f32(bias0);
+ s1 = v_setall_f32(bias1);
+ }
+ else
+ {
+ s0 = v_load(outptr0 + j);
+ s1 = v_load(outptr1 + j);
+ }
+
+ v_float32x4 vs00 = v_setzero_f32(), vs01 = v_setzero_f32(),
+ vs02 = v_setzero_f32(), vs03 = v_setzero_f32(),
+ vs10 = v_setzero_f32(), vs11 = v_setzero_f32(),
+ vs12 = v_setzero_f32(), vs13 = v_setzero_f32();
+ for( k = 0; k < vsz; k += 4, rptr += 4 )
+ {
+ v_float32x4 w0 = v_load_aligned(wptr0 + k), w1 = v_load_aligned(wptr1 + k);
+ v_float32x4 r0 = v_load_aligned(rptr), r1 = v_load_aligned(rptr + vsz_a),
+ r2 = v_load_aligned(rptr + vsz_a*2), r3 = v_load_aligned(rptr + vsz_a*3);
+
+ vs00 += w0*r0;
+ vs01 += w0*r1;
+ vs02 += w0*r2;
+ vs03 += w0*r3;
+
+ vs10 += w1*r0;
+ vs11 += w1*r1;
+ vs12 += w1*r2;
+ vs13 += w1*r3;
+ }
+ s0 += v_reduce_sum4(vs00, vs01, vs02, vs03);
+ s1 += v_reduce_sum4(vs10, vs11, vs12, vs13);
+ if( relu )
+ {
+ s0 = v_select(s0 > z, s0, s0*vr0);
+ s1 = v_select(s1 > z, s1, s1*vr1);
+ }
+
+ v_store(outptr0 + j, s0);
+ v_store(outptr1 + j, s1);
+ }
+ #endif
+ for( ; j < bsz; j++ )
+ {
+ const float* rptr = rowbuf0 + j*vsz_a;
+ float s00, s10;
+
+ if( cn0 == 0 )
+ {
+ s00 = bias0;
+ s10 = bias1;
+ }
+ else
+ {
+ s00 = outptr0[j];
+ s10 = outptr1[j];
+ }
+
+ for( k = 0; k < vsz; k++ )
+ {
+ float r0 = rptr[k];
+ s00 += wptr0[k]*r0;
+ s10 += wptr1[k]*r0;
+ }
+ if( relu )
+ {
+ s00 = s00 > 0.f ? s00 : s00*r0;
+ s10 = s10 > 0.f ? s10 : s10*r1;
+ }
+
+ outptr0[j] = s00;
+ outptr1[j] = s10;
+ }
+ }
+ }
+ }
+
+ if( activ_ )
+ activ_->forwardSlice(data_out0 + stripeStart, data_out0 + stripeStart,
+ (int)(stripeEnd - stripeStart),
+ outPlaneSize, startOutCn, startOutCn + outCn);
+ }
+ }
+ };
+
+ void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ /*printf("conv %s: input (%d x %d x %d x %d), kernel (%d x %d), pad (%d x %d), stride (%d x %d), dilation (%d x %d)\n",
+ name.c_str(), inputs[0]->size[0], inputs[0]->size[1], inputs[0]->size[2], inputs[0]->size[3],
+ kernel.width, kernel.height, pad.width, pad.height,
+ stride.width, stride.height, dilation.width, dilation.height);*/
+ CV_Assert(inputs.size() == (size_t)1 && inputs[0]->size[1] % blobs[0].size[1] == 0);
+ int ngroups = inputs[0]->size[1]/blobs[0].size[1];
+ CV_Assert(outputs[0].size[1] % ngroups == 0);
+
+ int k, outCn = blobs[0].size[0];
+
+ if( weightsMat.empty() )
+ {
+ // prepare weightsMat where each row is aligned and has enough zero padding on the right to
+ // use vectorized (i.e. with intrinsics) loops without tail processing
+ Mat wm = blobs[0].reshape(1, outCn).clone();
+ if( wm.step1() % VEC_ALIGN != 0 )
+ {
+ int newcols = (int)alignSize(wm.step1(), VEC_ALIGN);
+ Mat wm_buffer = Mat(outCn, newcols, wm.type());
+ Mat wm_padding = wm_buffer.colRange(wm.cols, newcols);
+ wm_padding.setTo(Scalar::all(0.));
+ Mat wm_aligned = wm_buffer.colRange(0, wm.cols);
+ wm.copyTo(wm_aligned);
+ wm = wm_aligned;
+ }
+ weightsMat = wm;
+
+ Mat biasMat = hasBias() ? blobs[1].reshape(1, outCn) : Mat();
+ biasvec.resize(outCn+2);
+ if( biasMat.empty() )
+ {
+ for( k = 0; k < outCn; k++ )
+ biasvec[k] = 0.f;
+ }
+ else
+ {
+ for( k = 0; k < outCn; k++ )
+ biasvec[k] = biasMat.at<float>(k);
+ }
+
+ if( !bnorm.empty() || !scaleLayer.empty() )
+ {
+ Mat scale, shift, scale2, shift2;
+ const float *scaleptr = 0, *shiftptr = 0;
+ const float *scaleptr2 = 0, *shiftptr2 = 0;
+
+ if( !bnorm.empty() )
+ {
+ bnorm->getScaleShift(scale, shift);
+ CV_Assert( scale.isContinuous() && shift.isContinuous() &&
+ scale.type() == CV_32F && shift.type() == CV_32F &&
+ scale.total() == (size_t)outCn &&
+ shift.total() == (size_t)outCn );
+ scaleptr = scale.ptr<float>();
+ shiftptr = shift.ptr<float>();
+ }
+ if( !scaleLayer.empty() )
+ {
+ scale2 = scaleLayer->blobs[0];
+ CV_Assert( scale2.isContinuous() && scale2.type() == CV_32F &&
+ scale2.total() == (size_t)outCn );
+ scaleptr2 = scale2.ptr<float>();
+ if( scaleLayer->hasBias )
+ {
+ shift2 = scaleLayer->blobs[1];
+ CV_Assert( shift2.isContinuous() && shift2.type() == CV_32F &&
+ shift2.total() == (size_t)outCn );
+ shiftptr2 = shift2.ptr<float>();
+ }
+ }
+
+ for( int i = 0; i < outCn; i++ )
+ {
+ float s1 = scaleptr ? scaleptr[i] : 1.f;
+ float delta1 = shiftptr ? shiftptr[i] : 0.f;
+ float s2 = scaleptr2 ? scaleptr2[i] : 1.f;
+ float delta2 = shiftptr2 ? shiftptr2[i] : 0.f;
+ float* w_i = weightsMat.ptr<float>(i);
+ int j, wcols = weightsMat.cols;
+
+ for( j = 0; j < wcols; j++ )
+ w_i[j] *= (s1*s2);
+
+ biasvec[i] = biasvec[i]*(s1*s2) + (delta1*s2 + delta2);
+ }
+ }
+ biasvec[outCn] = biasvec[outCn+1] = biasvec[outCn-1];
+ }
+
+ reluslope.clear();
+ if( activ )
+ {
+ Ptr<ReLULayer> activ_relu = activ.dynamicCast<ReLULayer>();
+ if( !activ_relu.empty() )
+ reluslope.assign(outCn+2, activ_relu->negativeSlope);
+
+ Ptr<ChannelsPReLULayer> activ_chprelu = activ.dynamicCast<ChannelsPReLULayer>();
+ if( !activ_chprelu.empty() )
+ {
+ const Mat& m = activ_chprelu->blobs[0];
+ CV_Assert(m.isContinuous() && m.type() == CV_32F && (int)m.total() == outCn);
+ const float* mdata = m.ptr<float>();
+ reluslope.resize(outCn+2);
+ std::copy(mdata, mdata + outCn, reluslope.begin());
+ reluslope[outCn] = reluslope[outCn+1] = reluslope[outCn-1];
+ }
+ }
+
+ int nstripes = std::max(getNumThreads(), 1);
+
+ ParallelConv::run(*inputs[0], outputs[0], weightsMat, biasvec, reluslope,
+ kernel, pad, stride, dilation, activ.get(), ngroups, nstripes);
+ }
+
+ virtual int64 getFLOPS(const std::vector<MatShape> &inputs,
+ const std::vector<MatShape> &outputs) const
+ {
+ CV_Assert(inputs.size() == outputs.size());
+
+ int64 flops = 0;
+ for (int i = 0; i < inputs.size(); i++)
+ {
+ flops += total(outputs[i])*(2*kernel.area()*inputs[i][1] + 1);
+ }
+
+ return flops;
+ }
+};
+
+class DeConvolutionLayerImpl : public BaseConvolutionLayerImpl
+{
+public:
+ Mat weightsMat, biasesMat;
+
+ MatShape computeColRowShape(const MatShape &inpShape, const MatShape &outShape) const
+ {
+ int inpCn = inpShape[1];
+ int inpH = inpShape[2];
+ int inpW = inpShape[3];
+ int outCn = outShape[1];
+ int ngroups = inpCn / blobs[0].size[1];
+ int outGroupCn = outCn / ngroups;
+ int ksize = outGroupCn * kernel.height * kernel.width;
+ return shape(ksize, inpH * inpW);
+ }
+
+ bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+ {
+ CV_Assert(!hasBias() || blobs[1].total() == (size_t)blobs[0].size[0]);
+ CV_Assert(inputs.size() != 0);
+
+ int inpCn = inputs[0][1];
+ int inpH = inputs[0][2];
+ int inpW = inputs[0][3];
+
+ int outH = stride.height * (inpH - 1) + kernel.height - 2 * pad.height + adjustPad.height;
+ int outW = stride.width * (inpW - 1) + kernel.width - 2 * pad.width + adjustPad.width;
+ int outCn = blobs[0].size[0];
+
+ int ngroups = inpCn / blobs[0].size[1];
+
+ CV_Assert(inpCn % ngroups == 0 && outCn % ngroups == 0);
+ CV_Assert(blobs[0].size[0] == outCn && blobs[0].size[1] == inpCn / ngroups);
+
+ int dims[] = {inputs[0][0], outCn, outH, outW};
+ outputs.resize(inputs.size(), shape(dims));
+
+ internals.push_back(MatShape());
+ if (!is1x1())
+ internals[0] = computeColRowShape(inputs[0], outputs[0]);
+
+ if (hasBias())
+ internals.push_back(shape(1, outH*outW));
+
+ return false;
+ }
+
+ class MatMulInvoker : public ParallelLoopBody
+ {
+ public:
+ MatMulInvoker(const Mat& a, const Mat& b, Mat& c, int nstripes)
+ {
+ a_ = &a;
+ b_ = &b;
+ c_ = &c;
+ nstripes_ = nstripes;
+ useAVX = checkHardwareSupport(CPU_AVX);
+ useAVX2 = checkHardwareSupport(CPU_AVX2);
+ }
+
+ void operator()(const Range& range_) const
+ {
+ int stripeSize = (int)alignSize((b_->cols + nstripes_ - 1)/nstripes_, 16);
+ Range range(range_.start*stripeSize, std::min(range_.end*stripeSize, b_->cols));
+ int mmax = a_->rows;
+ int nmax = range.end - range.start;
+ int kmax = a_->cols;
+ int m, n, k;
+ const float* aptr = a_->ptr<float>();
+ const float* bptr = b_->ptr<float>() + range.start;
+ float* cptr = c_->ptr<float>() + range.start;
+ size_t astep = a_->step1();
+ size_t bstep = b_->step1();
+ size_t cstep = c_->step1();
+
+ #if CV_TRY_AVX2
+ if( useAVX2 )
+ opt_AVX2::fastGEMM( aptr, astep, bptr, bstep, cptr, cstep, mmax, kmax, nmax );
+ else
+ #endif
+ #if CV_TRY_AVX
+ if( useAVX )
+ opt_AVX::fastGEMM( aptr, astep, bptr, bstep, cptr, cstep, mmax, kmax, nmax );
+ else
+ #endif
+ for( m = 0; m < mmax; m += 2 )
+ {
+ float* dst0 = cptr + cstep*m;
+ float* dst1 = cptr + cstep*std::min(m+1, mmax-1);
+ const float* aptr0 = aptr + astep*m;
+ const float* aptr1 = aptr + astep*std::min(m+1, mmax-1);
+
+ for( n = 0; n < nmax; n++ )
+ {
+ dst0[n] = 0.f;
+ dst1[n] = 0.f;
+ }
+
+ for( k = 0; k < kmax; k += 4 )
+ {
+ float alpha00 = aptr0[k];
+ float alpha01 = aptr1[k];
+ float alpha10 = 0.f, alpha11 = 0.f;
+ float alpha20 = 0.f, alpha21 = 0.f;
+ float alpha30 = 0.f, alpha31 = 0.f;
+ const float* bptr0 = bptr + k*bstep;
+ const float* bptr1 = bptr0;
+ const float* bptr2 = bptr0;
+ const float* bptr3 = bptr0;
+
+ if( k+1 < kmax )
+ {
+ alpha10 = aptr0[k+1];
+ alpha11 = aptr1[k+1];
+ bptr1 = bptr0 + bstep;
+ if( k+2 < kmax )
+ {
+ alpha20 = aptr0[k+2];
+ alpha21 = aptr1[k+2];
+ bptr2 = bptr1 + bstep;
+ if( k+3 < kmax )
+ {
+ alpha30 = aptr0[k+3];
+ alpha31 = aptr1[k+3];
+ bptr3 = bptr2 + bstep;
+ }
+ }
+ }
+ n = 0;
+
+ #if CV_SIMD128
+ v_float32x4 a00 = v_setall_f32(alpha00);
+ v_float32x4 a01 = v_setall_f32(alpha01);
+ v_float32x4 a10 = v_setall_f32(alpha10);
+ v_float32x4 a11 = v_setall_f32(alpha11);
+ v_float32x4 a20 = v_setall_f32(alpha20);
+ v_float32x4 a21 = v_setall_f32(alpha21);
+ v_float32x4 a30 = v_setall_f32(alpha30);
+ v_float32x4 a31 = v_setall_f32(alpha31);
+
+ for( ; n <= nmax - 4; n += 4 )
+ {
+ v_float32x4 b0 = v_load(bptr0 + n);
+ v_float32x4 b1 = v_load(bptr1 + n);
+ v_float32x4 b2 = v_load(bptr2 + n);
+ v_float32x4 b3 = v_load(bptr3 + n);
+ v_float32x4 d0 = v_load(dst0 + n);
+ v_float32x4 d1 = v_load(dst1 + n);
+ d0 += b0*a00;
+ d1 += b0*a01;
+ d0 += b1*a10;
+ d1 += b1*a11;
+ d0 += b2*a20;
+ d1 += b2*a21;
+ d0 += b3*a30;
+ d1 += b3*a31;
+ v_store(dst0 + n, d0);
+ v_store(dst1 + n, d1);
+ }
+ #endif
+
+ for( ; n < nmax; n++ )
+ {
+ float b0 = bptr0[n], b1 = bptr1[n];
+ float b2 = bptr2[n], b3 = bptr3[n];
+ float d0 = dst0[n] + alpha00*b0 + alpha10*b1 + alpha20*b2 + alpha30*b3;
+ float d1 = dst1[n] + alpha01*b0 + alpha11*b1 + alpha21*b2 + alpha31*b3;
+ dst0[n] = d0;
+ dst1[n] = d1;
+ }
+ }
+ }
+ }
+
+ const Mat *a_, *b_;
+ Mat* c_;
+ int nstripes_;
+ bool useAVX;
+ bool useAVX2;
+ };
+
+ class Col2ImInvoker : public cv::ParallelLoopBody
+ {
+ public:
+ const float* data_col;
+ const float* biasvec;
+ int channels, height, width;
+ int kernel_h, kernel_w;
+ int pad_h, pad_w;
+ int stride_h, stride_w;
+ float* data_im;
+ int height_col, width_col;
+ int nstripes;
+ bool is1x1;
+
+ Col2ImInvoker()
+ : data_col(0), biasvec(0), channels(0), height(0), width(0),
+ kernel_h(0), kernel_w(0), pad_h(0), pad_w(0), stride_h(0), stride_w(0), data_im(0),
+ height_col(0), width_col(0), nstripes(0), is1x1(0)
+ {}
+
+ static void run(const float* data_col,
+ int channels, int height, int width,
+ int kernel_h, int kernel_w,
+ int pad_h, int pad_w,
+ int stride_h, int stride_w,
+ float* data_im,
+ const float* biasvec,
+ bool is1x1)
+ {
+ const int nstripes = getNumThreads();
+
+ Col2ImInvoker t;
+ t.data_col = data_col;
+ t.data_im = data_im;
+ t.channels = channels; t.height = height; t.width = width;
+ t.kernel_h = kernel_h; t.kernel_w = kernel_w;
+ t.pad_h = pad_h; t.pad_w = pad_w;
+ t.stride_h = stride_h; t.stride_w = stride_w;
+ t.height_col = (height + 2 * pad_h - kernel_h) / stride_h + 1;
+ t.width_col = (width + 2 * pad_w - kernel_w) / stride_w + 1;
+ t.nstripes = nstripes;
+ t.is1x1 = is1x1;
+ t.biasvec = biasvec;
+
+ parallel_for_(Range(0, nstripes), t, nstripes);
+ }
+
+ virtual void operator ()(const Range &r) const
+ {
+ const float* data_col_ = data_col;
+ float* data_im_ = data_im;
+ int coeff_h = (1 - stride_h * kernel_w * height_col) * width_col;
+ int coeff_w = (1 - stride_w * height_col * width_col);
+ size_t total = (size_t)channels * height * width;
+ size_t stripeSize = (total + nstripes - 1)/nstripes;
+ size_t startIndex = r.start*stripeSize;
+ size_t endIndex = std::min(r.end*stripeSize, total);
+ int w = (int)(startIndex % width + pad_w);
+ int h = (int)((startIndex / width) % height + pad_h);
+ int c = (int)(startIndex / (width * height));
+ int h_col_start = (h < kernel_h) ? 0 : (h - kernel_h) / stride_h + 1;
+ int h_col_end = std::min(h / stride_h + 1, height_col);
+ int plane_size_col = height_col * width_col;
+ int offset = (c * kernel_h * kernel_w + h * kernel_w + w) * plane_size_col;
+ bool is1x1_ = is1x1;
+ const float* biasvec_ = biasvec;
+
+ for (size_t index = startIndex; index < endIndex; index++)
+ {
+ // compute the start and end of the output
+ int w_col_start = (w < kernel_w) ? 0 : (w - kernel_w) / stride_w + 1;
+ int w_col_end = std::min(w / stride_w + 1, width_col);
+ float val;
+
+ if( is1x1_ )
+ val = data_im_[index];
+ else
+ {
+ val = 0.f;
+ for (int h_col = h_col_start; h_col < h_col_end; ++h_col) {
+ for (int w_col = w_col_start; w_col < w_col_end; ++w_col) {
+ val += data_col_[offset + h_col * coeff_h + w_col * coeff_w];
+ }
+ }
+ }
+ data_im_[index] = val + biasvec_[c];
+
+ offset += plane_size_col;
+ if( ++w >= width + pad_w )
+ {
+ w = (int)((index + 1)% width + pad_w);
+ h = (int)(((index + 1) / width) % height + pad_h);
+ c = (int)((index + 1) / (width * height));
+ h_col_start = (h < kernel_h) ? 0 : (h - kernel_h) / stride_h + 1;
+ h_col_end = std::min(h / stride_h + 1, height_col);
+ offset = (c * kernel_h * kernel_w + h * kernel_w + w) * plane_size_col;
+ }
+ }
+ }
+ };
+
+ void forward(std::vector<Mat *> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ int outCn = blobs[0].size[0];
+ int inpCn = inputs[0]->size[1];
+ bool is1x1flag = is1x1();
+ int nstripes = getNumThreads();
+
+ if( weightsMat.empty() )
+ {
+ transpose(blobs[0].reshape(1, inpCn), weightsMat);
+ biasesMat = hasBias() ? blobs[1].reshape(1, outCn) : Mat::zeros(outCn, 1, CV_32F);
+ }
+
+ for (size_t ii = 0; ii < outputs.size(); ii++)
+ {
+ int ngroups = inpCn / blobs[0].size[1];
+ int inpGroupCn = blobs[0].size[1];
+ int outGroupCn = outCn / ngroups;
+ const Mat& inp = *inputs[ii];
+ Mat& out = outputs[ii];
+ int numImg = inp.size[0];
+ int outH = out.size[2], outW = out.size[3];
+
+ Mat convBlob = inputs[ii]->reshape(1, numImg*inpCn);
+ Mat decnBlob = out.reshape(1, numImg*outCn);
+
+ for (int n = 0; n < numImg; n++)
+ {
+ for (int g = 0; g < ngroups; g++)
+ {
+ Mat dstMat = decnBlob.rowRange(_Range((g + n * ngroups) * outGroupCn, outGroupCn));
+ Mat &colMat = is1x1flag ? dstMat : internals[0];
+
+ Mat convMat = convBlob.rowRange(_Range((g + n * ngroups) * inpGroupCn, inpGroupCn));
+ Mat wghtMat = weightsMat.colRange(_Range(g * inpGroupCn, inpGroupCn));
+ Mat curBiasMat = biasesMat.rowRange(_Range(g * outGroupCn, outGroupCn));
+
+ //gemm(wghtMat, convMat, 1, colMat, 0, colMat, 0);
+ MatMulInvoker mminvoker(wghtMat, convMat, colMat, nstripes);
+ parallel_for_(Range(0, nstripes), mminvoker, nstripes);
+
+ Col2ImInvoker::run(colMat.ptr<float>(), outGroupCn, outH, outW,
+ kernel.height, kernel.width, pad.height, pad.width,
+ stride.height, stride.width, dstMat.ptr<float>(),
+ curBiasMat.ptr<float>(), is1x1flag);
+ }
+ }
+ }
+ }
+
+ virtual Ptr<BackendNode> initHalide(const std::vector<Ptr<BackendWrapper> > &inputs)
+ {
+#ifdef HAVE_HALIDE
+ Halide::Buffer<float> inputBuffer = halideBuffer(inputs[0]);
+
+ int inW, inH, inC, inN, outC = blobs[0].size[0];
+ getCanonicalSize(inputBuffer, &inW, &inH, &inC, &inN);
+
+ if (inC / blobs[0].size[1] != 1)
+ CV_Error(cv::Error::StsNotImplemented,
+ "Halide backend for Deconvolution with group > 1 is not implemented");
+
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ Halide::Func top = (name.empty() ? Halide::Func() : Halide::Func(name));
+ Halide::Func padded_input(name + "_constant_exterior");
+ auto weights = wrapToHalideBuffer(blobs[0], {kernel.width,
+ kernel.height, outC, inC});
+
+ Halide::Func dilated_input("dilated_input");
+ dilated_input(x, y, c, n) = 0.0f;
+ Halide::RDom r1(0, inW, 0, inH);
+ dilated_input(r1.x * stride.width, r1.y * stride.height, c, n) =
+ inputBuffer(r1.x, r1.y, c, n);
+ dilated_input.compute_root();
+
+ Halide::Func bounded =
+ Halide::BoundaryConditions::constant_exterior(dilated_input, 0,
+ 0, (inW - 1) * stride.width + 1,
+ 0, (inH - 1) * stride.height + 1,
+ 0, inC, 0, inN);
+ padded_input(x, y, c, n) = bounded(x, y, c, n);
+
+ Halide::RDom r(0, kernel.width, 0, kernel.height, 0, inC);
+ Halide::Expr topExpr = sum(
+ padded_input(x + pad.width - r.x, y + pad.height - r.y, r.z, n) *
+ weights(r.x, r.y, c, r.z));
+ if (hasBias())
+ {
+ auto bias = wrapToHalideBuffer(blobs[1], {outC});
+ topExpr += bias(c);
+ }
+ top(x, y, c, n) = topExpr;
+ return Ptr<BackendNode>(new HalideBackendNode({ padded_input, top }));
+#endif // HAVE_HALIDE
+ return Ptr<BackendNode>();
+ }
+
+ virtual int64 getFLOPS(const std::vector<MatShape> &inputs,
+ const std::vector<MatShape> &outputs) const
+ {
+ CV_Assert(inputs.size() == outputs.size());
+
+ float flops = 0;
+ int outChannels = blobs[0].size[0];
+
+ for (int i = 0; i < inputs.size(); i++)
+ {
+ flops += 2*outChannels*kernel.area()*total(inputs[i]);
+ }
+
+ return flops;
+ }
+};
+
+//Convolution and Deconvolution
+static void initConvDeconvLayerFromCaffe(Ptr<BaseConvolutionLayer> l, const LayerParams ¶ms)
+{
+ l->setParamsFrom(params);
+ getConvolutionKernelParams(params, l->kernel.height, l->kernel.width, l->pad.height,
+ l->pad.width, l->stride.height, l->stride.width, l->dilation.height,
+ l->dilation.width, l->padMode);
+
+ bool bias = params.get<bool>("bias_term", true);
+ int numOutput = params.get<int>("num_output");
+ int ngroups = params.get<int>("group", 1);
+
+ l->adjustPad.height = params.get<int>("adj_h", 0);
+ l->adjustPad.width = params.get<int>("adj_w", 0);
+
+ CV_Assert(numOutput % ngroups == 0);
+ CV_Assert((bias && l->blobs.size() == 2) || (!bias && l->blobs.size() == 1));
+ CV_Assert(l->adjustPad.width < l->stride.width &&
+ l->adjustPad.height < l->stride.height);
+}
+
+Ptr<BaseConvolutionLayer> ConvolutionLayer::create(const LayerParams ¶ms)
+{
+ Ptr<BaseConvolutionLayer> l(new ConvolutionLayerImpl);
+ initConvDeconvLayerFromCaffe(l, params);
+ return l;
+}
+
+Ptr<BaseConvolutionLayer> DeconvolutionLayer::create(const LayerParams ¶ms)
+{
+ Ptr<BaseConvolutionLayer> l(new DeConvolutionLayerImpl);
+ initConvDeconvLayerFromCaffe(l, params);
+
+ return l;
+}
+
+}
+}
diff --git a/modules/dnn/src/layers/crop_layer.cpp b/modules/dnn/src/layers/crop_layer.cpp
new file mode 100644
index 0000000..1701495
--- /dev/null
+++ b/modules/dnn/src/layers/crop_layer.cpp
@@ -0,0 +1,157 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+
+namespace cv
+{
+namespace dnn
+{
+
+class CropLayerImpl : public CropLayer
+{
+public:
+ CropLayerImpl(const LayerParams& params)
+ {
+ setParamsFrom(params);
+ startAxis = params.get<int>("axis", 2);
+ const DictValue *paramOffset = params.ptr("offset");
+
+ if (paramOffset)
+ {
+ for (int i = 0; i < paramOffset->size(); i++)
+ offset.push_back(paramOffset->get<int>(i));
+ }
+ }
+
+ bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+ {
+ CV_Assert(inputs.size() == 2);
+
+ MatShape dstShape = inputs[0];
+ int start = clamp(startAxis, dstShape);
+ for (int i = start; i < dstShape.size(); i++)
+ {
+ dstShape[i] = inputs[1][i];
+ }
+
+ outputs.resize(1, dstShape);
+
+ return false;
+ }
+
+ void finalize(const std::vector<Mat *> &inputs, std::vector<Mat> &outputs)
+ {
+ CV_Assert(2 == inputs.size());
+
+ const Mat &inpBlob = *inputs[0];
+ const Mat &inpSzBlob = *inputs[1];
+
+ int dims = inpBlob.dims;
+ int start_axis = clamp(startAxis, dims);
+
+ std::vector<int> offset_final(dims, 0);
+ if (offset.size() == 1)
+ {
+ for (int i = start_axis; i < dims; i++)
+ offset_final[i] = offset[0];
+ }
+ else if (offset.size() > 1)
+ {
+ if ((int)offset.size() != dims - start_axis)
+ CV_Error(Error::StsBadArg, "number of offset values specified must be "
+ "equal to the number of dimensions following axis.");
+
+ for (int i = start_axis; i < dims; i++)
+ offset_final[i] = offset[i - start_axis];
+ }
+
+ crop_ranges.resize(dims, Range::all());
+ for (int i = 0; i < dims; i++)
+ {
+ if( i < start_axis )
+ continue;
+
+ if (!offset.empty()) //normal case
+ {
+ if (offset_final[i] < 0 || offset_final[i] + inpSzBlob.size[i] > inpBlob.size[i])
+ CV_Error(Error::StsBadArg, "invalid crop parameters");
+
+ crop_ranges[i] = Range(offset_final[i], offset_final[i] + inpSzBlob.size[i]);
+ }
+ else //detect offset automatically so that cropped image is center of original one
+ {
+ if (inpSzBlob.size[i] > inpBlob.size[i])
+ CV_Error(Error::StsBadArg, "invalid output blob size");
+
+ int cur_crop = (inpBlob.size[i] - inpSzBlob.size[i]) / 2;
+ crop_ranges[i] = Range(cur_crop, cur_crop + inpSzBlob.size[i]);
+ }
+ }
+ }
+
+ void forward(std::vector<Mat *> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ Mat &input = *inputs[0];
+ Mat &output = outputs[0];
+
+ input(&crop_ranges[0]).copyTo(output);
+ }
+
+ std::vector<Range> crop_ranges;
+};
+
+
+Ptr<CropLayer> CropLayer::create(const LayerParams& params)
+{
+ return Ptr<CropLayer>(new CropLayerImpl(params));
+}
+
+}
+}
diff --git a/modules/dnn/src/layers/detection_output_layer.cpp b/modules/dnn/src/layers/detection_output_layer.cpp
new file mode 100644
index 0000000..0b72326
--- /dev/null
+++ b/modules/dnn/src/layers/detection_output_layer.cpp
@@ -0,0 +1,728 @@
+/*M ///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include <float.h>
+#include <string>
+#include <caffe.pb.h>
+
+namespace cv
+{
+namespace dnn
+{
+
+namespace util
+{
+
+template <typename T>
+static inline bool SortScorePairDescend(const std::pair<float, T>& pair1,
+ const std::pair<float, T>& pair2)
+{
+ return pair1.first > pair2.first;
+}
+
+} // namespace
+
+class DetectionOutputLayerImpl : public DetectionOutputLayer
+{
+public:
+ unsigned _numClasses;
+ bool _shareLocation;
+ int _numLocClasses;
+
+ int _backgroundLabelId;
+
+ typedef caffe::PriorBoxParameter_CodeType CodeType;
+ CodeType _codeType;
+
+ bool _varianceEncodedInTarget;
+ int _keepTopK;
+ float _confidenceThreshold;
+
+ float _nmsThreshold;
+ int _topK;
+
+ enum { _numAxes = 4 };
+ static const std::string _layerName;
+
+ typedef std::map<int, std::vector<caffe::NormalizedBBox> > LabelBBox;
+
+ bool getParameterDict(const LayerParams ¶ms,
+ const std::string ¶meterName,
+ DictValue& result)
+ {
+ if (!params.has(parameterName))
+ {
+ return false;
+ }
+
+ result = params.get(parameterName);
+ return true;
+ }
+
+ template<typename T>
+ T getParameter(const LayerParams ¶ms,
+ const std::string ¶meterName,
+ const size_t &idx=0,
+ const bool required=true,
+ const T& defaultValue=T())
+ {
+ DictValue dictValue;
+ bool success = getParameterDict(params, parameterName, dictValue);
+ if(!success)
+ {
+ if(required)
+ {
+ std::string message = _layerName;
+ message += " layer parameter does not contain ";
+ message += parameterName;
+ message += " parameter.";
+ CV_ErrorNoReturn(Error::StsBadArg, message);
+ }
+ else
+ {
+ return defaultValue;
+ }
+ }
+ return dictValue.get<T>(idx);
+ }
+
+ void getCodeType(const LayerParams ¶ms)
+ {
+ String codeTypeString = params.get<String>("code_type").toLowerCase();
+ if (codeTypeString == "corner")
+ _codeType = caffe::PriorBoxParameter_CodeType_CORNER;
+ else if (codeTypeString == "center_size")
+ _codeType = caffe::PriorBoxParameter_CodeType_CENTER_SIZE;
+ else
+ _codeType = caffe::PriorBoxParameter_CodeType_CORNER;
+ }
+
+ DetectionOutputLayerImpl(const LayerParams ¶ms)
+ {
+ _numClasses = getParameter<unsigned>(params, "num_classes");
+ _shareLocation = getParameter<bool>(params, "share_location");
+ _numLocClasses = _shareLocation ? 1 : _numClasses;
+ _backgroundLabelId = getParameter<int>(params, "background_label_id");
+ _varianceEncodedInTarget = getParameter<bool>(params, "variance_encoded_in_target", 0, false, false);
+ _keepTopK = getParameter<int>(params, "keep_top_k");
+ _confidenceThreshold = getParameter<float>(params, "confidence_threshold", 0, false, -FLT_MAX);
+ _topK = getParameter<int>(params, "top_k", 0, false, -1);
+
+ getCodeType(params);
+
+ // Parameters used in nms.
+ _nmsThreshold = getParameter<float>(params, "nms_threshold");
+ CV_Assert(_nmsThreshold > 0.);
+
+ setParamsFrom(params);
+ }
+
+ void checkInputs(const std::vector<Mat*> &inputs)
+ {
+ for (size_t i = 1; i < inputs.size(); i++)
+ {
+ CV_Assert(inputs[i]->size == inputs[0]->size);
+ }
+ }
+
+ bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+ {
+ CV_Assert(inputs.size() > 0);
+ CV_Assert(inputs[0][0] == inputs[1][0]);
+
+ int numPriors = inputs[2][2] / 4;
+ CV_Assert((numPriors * _numLocClasses * 4) == inputs[0][1]);
+ CV_Assert(int(numPriors * _numClasses) == inputs[1][1]);
+
+ // num() and channels() are 1.
+ // Since the number of bboxes to be kept is unknown before nms, we manually
+ // set it to (fake) 1.
+ // Each row is a 7 dimension std::vector, which stores
+ // [image_id, label, confidence, xmin, ymin, xmax, ymax]
+ outputs.resize(1, shape(1, 1, 1, 7));
+
+ return false;
+ }
+
+ void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ std::vector<LabelBBox> allDecodedBBoxes;
+ std::vector<std::vector<std::vector<float> > > allConfidenceScores;
+
+ int num = inputs[0]->size[0];
+
+ // extract predictions from input layers
+ {
+ int numPriors = inputs[2]->size[2] / 4;
+
+ const float* locationData = inputs[0]->ptr<float>();
+ const float* confidenceData = inputs[1]->ptr<float>();
+ const float* priorData = inputs[2]->ptr<float>();
+
+ // Retrieve all location predictions
+ std::vector<LabelBBox> allLocationPredictions;
+ GetLocPredictions(locationData, num, numPriors, _numLocClasses,
+ _shareLocation, allLocationPredictions);
+
+ // Retrieve all confidences
+ GetConfidenceScores(confidenceData, num, numPriors, _numClasses, allConfidenceScores);
+
+ // Retrieve all prior bboxes
+ std::vector<caffe::NormalizedBBox> priorBBoxes;
+ std::vector<std::vector<float> > priorVariances;
+ GetPriorBBoxes(priorData, numPriors, priorBBoxes, priorVariances);
+
+ // Decode all loc predictions to bboxes
+ DecodeBBoxesAll(allLocationPredictions, priorBBoxes, priorVariances, num,
+ _shareLocation, _numLocClasses, _backgroundLabelId,
+ _codeType, _varianceEncodedInTarget, false, allDecodedBBoxes);
+ }
+
+ size_t numKept = 0;
+ std::vector<std::map<int, std::vector<int> > > allIndices;
+ for (int i = 0; i < num; ++i)
+ {
+ numKept += processDetections_(allDecodedBBoxes[i], allConfidenceScores[i], allIndices);
+ }
+
+ if (numKept == 0)
+ {
+ return;
+ }
+ int outputShape[] = {1, 1, (int)numKept, 7};
+ outputs[0].create(4, outputShape, CV_32F);
+ float* outputsData = outputs[0].ptr<float>();
+
+ size_t count = 0;
+ for (int i = 0; i < num; ++i)
+ {
+ count += outputDetections_(i, &outputsData[count * 7],
+ allDecodedBBoxes[i], allConfidenceScores[i],
+ allIndices[i]);
+ }
+ CV_Assert(count == numKept);
+ }
+
+ size_t outputDetections_(
+ const int i, float* outputsData,
+ const LabelBBox& decodeBBoxes, const std::vector<std::vector<float> >& confidenceScores,
+ const std::map<int, std::vector<int> >& indicesMap
+ )
+ {
+ size_t count = 0;
+ for (std::map<int, std::vector<int> >::const_iterator it = indicesMap.begin(); it != indicesMap.end(); ++it)
+ {
+ int label = it->first;
+ if (confidenceScores.size() <= label)
+ CV_ErrorNoReturn_(cv::Error::StsError, ("Could not find confidence predictions for label %d", label));
+ const std::vector<float>& scores = confidenceScores[label];
+ int locLabel = _shareLocation ? -1 : label;
+ LabelBBox::const_iterator label_bboxes = decodeBBoxes.find(locLabel);
+ if (label_bboxes == decodeBBoxes.end())
+ CV_ErrorNoReturn_(cv::Error::StsError, ("Could not find location predictions for label %d", locLabel));
+ const std::vector<int>& indices = it->second;
+
+ for (size_t j = 0; j < indices.size(); ++j, ++count)
+ {
+ int idx = indices[j];
+ const caffe::NormalizedBBox& decode_bbox = label_bboxes->second[idx];
+ outputsData[count * 7] = i;
+ outputsData[count * 7 + 1] = label;
+ outputsData[count * 7 + 2] = scores[idx];
+ outputsData[count * 7 + 3] = decode_bbox.xmin();
+ outputsData[count * 7 + 4] = decode_bbox.ymin();
+ outputsData[count * 7 + 5] = decode_bbox.xmax();
+ outputsData[count * 7 + 6] = decode_bbox.ymax();
+ }
+ }
+ return count;
+ }
+
+ size_t processDetections_(
+ const LabelBBox& decodeBBoxes, const std::vector<std::vector<float> >& confidenceScores,
+ std::vector<std::map<int, std::vector<int> > >& allIndices
+ )
+ {
+ std::map<int, std::vector<int> > indices;
+ size_t numDetections = 0;
+ for (int c = 0; c < (int)_numClasses; ++c)
+ {
+ if (c == _backgroundLabelId)
+ continue; // Ignore background class.
+ if (c >= confidenceScores.size())
+ CV_ErrorNoReturn_(cv::Error::StsError, ("Could not find confidence predictions for label %d", c));
+
+ const std::vector<float>& scores = confidenceScores[c];
+ int label = _shareLocation ? -1 : c;
+
+ LabelBBox::const_iterator label_bboxes = decodeBBoxes.find(label);
+ if (label_bboxes == decodeBBoxes.end())
+ CV_ErrorNoReturn_(cv::Error::StsError, ("Could not find location predictions for label %d", label));
+ ApplyNMSFast(label_bboxes->second, scores, _confidenceThreshold, _nmsThreshold, 1.0, _topK, indices[c]);
+ numDetections += indices[c].size();
+ }
+ if (_keepTopK > -1 && numDetections > (size_t)_keepTopK)
+ {
+ std::vector<std::pair<float, std::pair<int, int> > > scoreIndexPairs;
+ for (std::map<int, std::vector<int> >::iterator it = indices.begin();
+ it != indices.end(); ++it)
+ {
+ int label = it->first;
+ const std::vector<int>& labelIndices = it->second;
+ if (label >= confidenceScores.size())
+ CV_ErrorNoReturn_(cv::Error::StsError, ("Could not find location predictions for label %d", label));
+ const std::vector<float>& scores = confidenceScores[label];
+ for (size_t j = 0; j < labelIndices.size(); ++j)
+ {
+ size_t idx = labelIndices[j];
+ CV_Assert(idx < scores.size());
+ scoreIndexPairs.push_back(std::make_pair(scores[idx], std::make_pair(label, idx)));
+ }
+ }
+ // Keep outputs k results per image.
+ std::sort(scoreIndexPairs.begin(), scoreIndexPairs.end(),
+ util::SortScorePairDescend<std::pair<int, int> >);
+ scoreIndexPairs.resize(_keepTopK);
+
+ std::map<int, std::vector<int> > newIndices;
+ for (size_t j = 0; j < scoreIndexPairs.size(); ++j)
+ {
+ int label = scoreIndexPairs[j].second.first;
+ int idx = scoreIndexPairs[j].second.second;
+ newIndices[label].push_back(idx);
+ }
+ allIndices.push_back(newIndices);
+ return (size_t)_keepTopK;
+ }
+ else
+ {
+ allIndices.push_back(indices);
+ return numDetections;
+ }
+ }
+
+
+ // **************************************************************
+ // Utility functions
+ // **************************************************************
+
+ // Compute bbox size
+ template<bool normalized>
+ static float BBoxSize(const caffe::NormalizedBBox& bbox)
+ {
+ if (bbox.xmax() < bbox.xmin() || bbox.ymax() < bbox.ymin())
+ {
+ return 0; // If bbox is invalid (e.g. xmax < xmin or ymax < ymin), return 0.
+ }
+ else
+ {
+ if (bbox.has_size())
+ {
+ return bbox.size();
+ }
+ else
+ {
+ float width = bbox.xmax() - bbox.xmin();
+ float height = bbox.ymax() - bbox.ymin();
+ if (normalized)
+ {
+ return width * height;
+ }
+ else
+ {
+ // If bbox is not within range [0, 1].
+ return (width + 1) * (height + 1);
+ }
+ }
+ }
+ }
+
+
+ // Decode a bbox according to a prior bbox
+ template<bool variance_encoded_in_target>
+ static void DecodeBBox(
+ const caffe::NormalizedBBox& prior_bbox, const std::vector<float>& prior_variance,
+ const CodeType code_type,
+ const bool clip_bbox, const caffe::NormalizedBBox& bbox,
+ caffe::NormalizedBBox& decode_bbox)
+ {
+ float bbox_xmin = variance_encoded_in_target ? bbox.xmin() : prior_variance[0] * bbox.xmin();
+ float bbox_ymin = variance_encoded_in_target ? bbox.ymin() : prior_variance[1] * bbox.ymin();
+ float bbox_xmax = variance_encoded_in_target ? bbox.xmax() : prior_variance[2] * bbox.xmax();
+ float bbox_ymax = variance_encoded_in_target ? bbox.ymax() : prior_variance[3] * bbox.ymax();
+ switch(code_type)
+ {
+ case caffe::PriorBoxParameter_CodeType_CORNER:
+ decode_bbox.set_xmin(prior_bbox.xmin() + bbox_xmin);
+ decode_bbox.set_ymin(prior_bbox.ymin() + bbox_ymin);
+ decode_bbox.set_xmax(prior_bbox.xmax() + bbox_xmax);
+ decode_bbox.set_ymax(prior_bbox.ymax() + bbox_ymax);
+ break;
+ case caffe::PriorBoxParameter_CodeType_CENTER_SIZE:
+ {
+ float prior_width = prior_bbox.xmax() - prior_bbox.xmin();
+ CV_Assert(prior_width > 0);
+ float prior_height = prior_bbox.ymax() - prior_bbox.ymin();
+ CV_Assert(prior_height > 0);
+ float prior_center_x = (prior_bbox.xmin() + prior_bbox.xmax()) * .5;
+ float prior_center_y = (prior_bbox.ymin() + prior_bbox.ymax()) * .5;
+
+ float decode_bbox_center_x, decode_bbox_center_y;
+ float decode_bbox_width, decode_bbox_height;
+ decode_bbox_center_x = bbox_xmin * prior_width + prior_center_x;
+ decode_bbox_center_y = bbox_ymin * prior_height + prior_center_y;
+ decode_bbox_width = exp(bbox_xmax) * prior_width;
+ decode_bbox_height = exp(bbox_ymax) * prior_height;
+ decode_bbox.set_xmin(decode_bbox_center_x - decode_bbox_width * .5);
+ decode_bbox.set_ymin(decode_bbox_center_y - decode_bbox_height * .5);
+ decode_bbox.set_xmax(decode_bbox_center_x + decode_bbox_width * .5);
+ decode_bbox.set_ymax(decode_bbox_center_y + decode_bbox_height * .5);
+ break;
+ }
+ default:
+ CV_ErrorNoReturn(Error::StsBadArg, "Unknown type.");
+ };
+ if (clip_bbox)
+ {
+ // Clip the caffe::NormalizedBBox such that the range for each corner is [0, 1]
+ decode_bbox.set_xmin(std::max(std::min(decode_bbox.xmin(), 1.f), 0.f));
+ decode_bbox.set_ymin(std::max(std::min(decode_bbox.ymin(), 1.f), 0.f));
+ decode_bbox.set_xmax(std::max(std::min(decode_bbox.xmax(), 1.f), 0.f));
+ decode_bbox.set_ymax(std::max(std::min(decode_bbox.ymax(), 1.f), 0.f));
+ }
+ decode_bbox.clear_size();
+ decode_bbox.set_size(BBoxSize<true>(decode_bbox));
+ }
+
+ // Decode a set of bboxes according to a set of prior bboxes
+ static void DecodeBBoxes(
+ const std::vector<caffe::NormalizedBBox>& prior_bboxes,
+ const std::vector<std::vector<float> >& prior_variances,
+ const CodeType code_type, const bool variance_encoded_in_target,
+ const bool clip_bbox, const std::vector<caffe::NormalizedBBox>& bboxes,
+ std::vector<caffe::NormalizedBBox>& decode_bboxes)
+ {
+ CV_Assert(prior_bboxes.size() == prior_variances.size());
+ CV_Assert(prior_bboxes.size() == bboxes.size());
+ size_t num_bboxes = prior_bboxes.size();
+ CV_Assert(num_bboxes == 0 || prior_variances[0].size() == 4);
+ decode_bboxes.clear(); decode_bboxes.resize(num_bboxes);
+ if(variance_encoded_in_target)
+ {
+ for (int i = 0; i < num_bboxes; ++i)
+ DecodeBBox<true>(prior_bboxes[i], prior_variances[i], code_type,
+ clip_bbox, bboxes[i], decode_bboxes[i]);
+ }
+ else
+ {
+ for (int i = 0; i < num_bboxes; ++i)
+ DecodeBBox<false>(prior_bboxes[i], prior_variances[i], code_type,
+ clip_bbox, bboxes[i], decode_bboxes[i]);
+ }
+ }
+
+ // Decode all bboxes in a batch
+ static void DecodeBBoxesAll(const std::vector<LabelBBox>& all_loc_preds,
+ const std::vector<caffe::NormalizedBBox>& prior_bboxes,
+ const std::vector<std::vector<float> >& prior_variances,
+ const int num, const bool share_location,
+ const int num_loc_classes, const int background_label_id,
+ const CodeType code_type, const bool variance_encoded_in_target,
+ const bool clip, std::vector<LabelBBox>& all_decode_bboxes)
+ {
+ CV_Assert(all_loc_preds.size() == num);
+ all_decode_bboxes.clear();
+ all_decode_bboxes.resize(num);
+ for (int i = 0; i < num; ++i)
+ {
+ // Decode predictions into bboxes.
+ const LabelBBox& loc_preds = all_loc_preds[i];
+ LabelBBox& decode_bboxes = all_decode_bboxes[i];
+ for (int c = 0; c < num_loc_classes; ++c)
+ {
+ int label = share_location ? -1 : c;
+ if (label == background_label_id)
+ continue; // Ignore background class.
+ LabelBBox::const_iterator label_loc_preds = loc_preds.find(label);
+ if (label_loc_preds == loc_preds.end())
+ CV_ErrorNoReturn_(cv::Error::StsError, ("Could not find location predictions for label %d", label));
+ DecodeBBoxes(prior_bboxes, prior_variances,
+ code_type, variance_encoded_in_target, clip,
+ label_loc_preds->second, decode_bboxes[label]);
+ }
+ }
+ }
+
+ // Get prior bounding boxes from prior_data
+ // prior_data: 1 x 2 x num_priors * 4 x 1 blob.
+ // num_priors: number of priors.
+ // prior_bboxes: stores all the prior bboxes in the format of caffe::NormalizedBBox.
+ // prior_variances: stores all the variances needed by prior bboxes.
+ static void GetPriorBBoxes(const float* priorData, const int& numPriors,
+ std::vector<caffe::NormalizedBBox>& priorBBoxes,
+ std::vector<std::vector<float> >& priorVariances)
+ {
+ priorBBoxes.clear(); priorBBoxes.resize(numPriors);
+ priorVariances.clear(); priorVariances.resize(numPriors);
+ for (int i = 0; i < numPriors; ++i)
+ {
+ int startIdx = i * 4;
+ caffe::NormalizedBBox& bbox = priorBBoxes[i];
+ bbox.set_xmin(priorData[startIdx]);
+ bbox.set_ymin(priorData[startIdx + 1]);
+ bbox.set_xmax(priorData[startIdx + 2]);
+ bbox.set_ymax(priorData[startIdx + 3]);
+ bbox.set_size(BBoxSize<true>(bbox));
+ }
+
+ for (int i = 0; i < numPriors; ++i)
+ {
+ int startIdx = (numPriors + i) * 4;
+ // not needed here: priorVariances[i].clear();
+ for (int j = 0; j < 4; ++j)
+ {
+ priorVariances[i].push_back(priorData[startIdx + j]);
+ }
+ }
+ }
+
+ // Get location predictions from loc_data.
+ // loc_data: num x num_preds_per_class * num_loc_classes * 4 blob.
+ // num: the number of images.
+ // num_preds_per_class: number of predictions per class.
+ // num_loc_classes: number of location classes. It is 1 if share_location is
+ // true; and is equal to number of classes needed to predict otherwise.
+ // share_location: if true, all classes share the same location prediction.
+ // loc_preds: stores the location prediction, where each item contains
+ // location prediction for an image.
+ static void GetLocPredictions(const float* locData, const int num,
+ const int numPredsPerClass, const int numLocClasses,
+ const bool shareLocation, std::vector<LabelBBox>& locPreds)
+ {
+ locPreds.clear();
+ if (shareLocation)
+ {
+ CV_Assert(numLocClasses == 1);
+ }
+ locPreds.resize(num);
+ for (int i = 0; i < num; ++i, locData += numPredsPerClass * numLocClasses * 4)
+ {
+ LabelBBox& labelBBox = locPreds[i];
+ for (int p = 0; p < numPredsPerClass; ++p)
+ {
+ int startIdx = p * numLocClasses * 4;
+ for (int c = 0; c < numLocClasses; ++c)
+ {
+ int label = shareLocation ? -1 : c;
+ if (labelBBox.find(label) == labelBBox.end())
+ {
+ labelBBox[label].resize(numPredsPerClass);
+ }
+ caffe::NormalizedBBox& bbox = labelBBox[label][p];
+ bbox.set_xmin(locData[startIdx + c * 4]);
+ bbox.set_ymin(locData[startIdx + c * 4 + 1]);
+ bbox.set_xmax(locData[startIdx + c * 4 + 2]);
+ bbox.set_ymax(locData[startIdx + c * 4 + 3]);
+ }
+ }
+ }
+ }
+
+ // Get confidence predictions from conf_data.
+ // conf_data: num x num_preds_per_class * num_classes blob.
+ // num: the number of images.
+ // num_preds_per_class: number of predictions per class.
+ // num_classes: number of classes.
+ // conf_preds: stores the confidence prediction, where each item contains
+ // confidence prediction for an image.
+ static void GetConfidenceScores(const float* confData, const int num,
+ const int numPredsPerClass, const int numClasses,
+ std::vector<std::vector<std::vector<float> > >& confPreds)
+ {
+ confPreds.clear(); confPreds.resize(num);
+ for (int i = 0; i < num; ++i, confData += numPredsPerClass * numClasses)
+ {
+ std::vector<std::vector<float> >& labelScores = confPreds[i];
+ labelScores.resize(numClasses);
+ for (int c = 0; c < numClasses; ++c)
+ {
+ std::vector<float>& classLabelScores = labelScores[c];
+ classLabelScores.resize(numPredsPerClass);
+ for (int p = 0; p < numPredsPerClass; ++p)
+ {
+ classLabelScores[p] = confData[p * numClasses + c];
+ }
+ }
+ }
+ }
+
+ // Do non maximum suppression given bboxes and scores.
+ // Inspired by Piotr Dollar's NMS implementation in EdgeBox.
+ // https://goo.gl/jV3JYS
+ // bboxes: a set of bounding boxes.
+ // scores: a set of corresponding confidences.
+ // score_threshold: a threshold used to filter detection results.
+ // nms_threshold: a threshold used in non maximum suppression.
+ // top_k: if not -1, keep at most top_k picked indices.
+ // indices: the kept indices of bboxes after nms.
+ static void ApplyNMSFast(const std::vector<caffe::NormalizedBBox>& bboxes,
+ const std::vector<float>& scores, const float score_threshold,
+ const float nms_threshold, const float eta, const int top_k,
+ std::vector<int>& indices)
+ {
+ CV_Assert(bboxes.size() == scores.size());
+
+ // Get top_k scores (with corresponding indices).
+ std::vector<std::pair<float, int> > score_index_vec;
+ GetMaxScoreIndex(scores, score_threshold, top_k, score_index_vec);
+
+ // Do nms.
+ float adaptive_threshold = nms_threshold;
+ indices.clear();
+ while (score_index_vec.size() != 0) {
+ const int idx = score_index_vec.front().second;
+ bool keep = true;
+ for (int k = 0; k < (int)indices.size() && keep; ++k) {
+ const int kept_idx = indices[k];
+ float overlap = JaccardOverlap<true>(bboxes[idx], bboxes[kept_idx]);
+ keep = overlap <= adaptive_threshold;
+ }
+ if (keep)
+ indices.push_back(idx);
+ score_index_vec.erase(score_index_vec.begin());
+ if (keep && eta < 1 && adaptive_threshold > 0.5) {
+ adaptive_threshold *= eta;
+ }
+ }
+ }
+
+ // Get max scores with corresponding indices.
+ // scores: a set of scores.
+ // threshold: only consider scores higher than the threshold.
+ // top_k: if -1, keep all; otherwise, keep at most top_k.
+ // score_index_vec: store the sorted (score, index) pair.
+ static void GetMaxScoreIndex(const std::vector<float>& scores, const float threshold, const int top_k,
+ std::vector<std::pair<float, int> >& score_index_vec)
+ {
+ CV_DbgAssert(score_index_vec.empty());
+ // Generate index score pairs.
+ for (size_t i = 0; i < scores.size(); ++i)
+ {
+ if (scores[i] > threshold)
+ {
+ score_index_vec.push_back(std::make_pair(scores[i], i));
+ }
+ }
+
+ // Sort the score pair according to the scores in descending order
+ std::stable_sort(score_index_vec.begin(), score_index_vec.end(),
+ util::SortScorePairDescend<int>);
+
+ // Keep top_k scores if needed.
+ if (top_k > -1 && top_k < (int)score_index_vec.size())
+ {
+ score_index_vec.resize(top_k);
+ }
+ }
+
+ // Compute the jaccard (intersection over union IoU) overlap between two bboxes.
+ template<bool normalized>
+ static float JaccardOverlap(const caffe::NormalizedBBox& bbox1,
+ const caffe::NormalizedBBox& bbox2)
+ {
+ caffe::NormalizedBBox intersect_bbox;
+ if (bbox2.xmin() > bbox1.xmax() || bbox2.xmax() < bbox1.xmin() ||
+ bbox2.ymin() > bbox1.ymax() || bbox2.ymax() < bbox1.ymin())
+ {
+ // Return [0, 0, 0, 0] if there is no intersection.
+ intersect_bbox.set_xmin(0);
+ intersect_bbox.set_ymin(0);
+ intersect_bbox.set_xmax(0);
+ intersect_bbox.set_ymax(0);
+ }
+ else
+ {
+ intersect_bbox.set_xmin(std::max(bbox1.xmin(), bbox2.xmin()));
+ intersect_bbox.set_ymin(std::max(bbox1.ymin(), bbox2.ymin()));
+ intersect_bbox.set_xmax(std::min(bbox1.xmax(), bbox2.xmax()));
+ intersect_bbox.set_ymax(std::min(bbox1.ymax(), bbox2.ymax()));
+ }
+
+ float intersect_width, intersect_height;
+ intersect_width = intersect_bbox.xmax() - intersect_bbox.xmin();
+ intersect_height = intersect_bbox.ymax() - intersect_bbox.ymin();
+ if (intersect_width > 0 && intersect_height > 0)
+ {
+ if (!normalized)
+ {
+ intersect_width++;
+ intersect_height++;
+ }
+ float intersect_size = intersect_width * intersect_height;
+ float bbox1_size = BBoxSize<true>(bbox1);
+ float bbox2_size = BBoxSize<true>(bbox2);
+ return intersect_size / (bbox1_size + bbox2_size - intersect_size);
+ }
+ else
+ {
+ return 0.;
+ }
+ }
+};
+
+const std::string DetectionOutputLayerImpl::_layerName = std::string("DetectionOutput");
+
+Ptr<DetectionOutputLayer> DetectionOutputLayer::create(const LayerParams ¶ms)
+{
+ return Ptr<DetectionOutputLayer>(new DetectionOutputLayerImpl(params));
+}
+
+}
+}
diff --git a/modules/dnn/src/layers/elementwise_layers.cpp b/modules/dnn/src/layers/elementwise_layers.cpp
new file mode 100644
index 0000000..9c929a0
--- /dev/null
+++ b/modules/dnn/src/layers/elementwise_layers.cpp
@@ -0,0 +1,583 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "../precomp.hpp"
+#include "op_halide.hpp"
+#include "opencv2/imgproc.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv
+{
+namespace dnn
+{
+
+using std::abs;
+using std::exp;
+using std::tanh;
+using std::pow;
+
+template<typename Func>
+class ElementWiseLayer : public Func::Layer
+{
+public:
+ class PBody : public cv::ParallelLoopBody
+ {
+ public:
+ const Func* func_;
+ const Mat* src_;
+ Mat* dst_;
+ int nstripes_;
+
+ PBody(const Func &func, const Mat &src, Mat& dst, int nstripes)
+ {
+ func_ = &func;
+ src_ = &src;
+ dst_ = &dst;
+ nstripes_ = nstripes;
+ }
+
+ void operator()(const Range &r) const
+ {
+ int nstripes = nstripes_, nsamples, outCn;
+ size_t planeSize;
+
+ if( src_->dims == 4 )
+ {
+ nsamples = src_->size[0];
+ outCn = src_->size[1];
+ planeSize = (size_t)src_->size[2]*src_->size[3];
+ }
+ else
+ {
+ nsamples = outCn = 1;
+ planeSize = (size_t)src_->total();
+ }
+
+ size_t stripeSize = (planeSize + nstripes - 1)/nstripes;
+ size_t stripeStart = r.start*stripeSize;
+ size_t stripeEnd = std::min(r.end*stripeSize, planeSize);
+
+ for( int i = 0; i < nsamples; i++ )
+ {
+ const float* srcptr = src_->ptr<float>(i) + stripeStart;
+ float* dstptr = dst_->ptr<float>(i) + stripeStart;
+ func_->apply(srcptr, dstptr, (int)(stripeEnd - stripeStart), planeSize, 0, outCn);
+ }
+ }
+ };
+
+ ElementWiseLayer(const Func &f=Func()) : run_parallel(false) { func = f; }
+
+ virtual bool supportBackend(int backendId)
+ {
+ return backendId == DNN_BACKEND_DEFAULT ||
+ backendId == DNN_BACKEND_HALIDE && haveHalide();
+ }
+
+ virtual Ptr<BackendNode> tryAttach(const Ptr<BackendNode>& node)
+ {
+ switch (node->backendId)
+ {
+ case DNN_BACKEND_HALIDE:
+ {
+#ifdef HAVE_HALIDE
+ auto base = node.dynamicCast<HalideBackendNode>();
+ Halide::Func& input = base->funcs.back();
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ Halide::Func top = (this->name.empty() ? Halide::Func() : Halide::Func(this->name));
+ func.attachHalide(input(x, y, c, n), top);
+ return Ptr<BackendNode>(new HalideBackendNode(base, top));
+#endif // HAVE_HALIDE
+ break;
+ }
+ }
+ return Ptr<BackendNode>();
+ }
+
+ virtual Ptr<BackendNode> initHalide(const std::vector<Ptr<BackendWrapper> > &inputs)
+ {
+#ifdef HAVE_HALIDE
+ Halide::Buffer<float> input = halideBuffer(inputs[0]);
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ Halide::Func top = (this->name.empty() ? Halide::Func() : Halide::Func(this->name));
+ func.attachHalide(input(x, y, c, n), top);
+ return Ptr<BackendNode>(new HalideBackendNode(top));
+#endif // HAVE_HALIDE
+ return Ptr<BackendNode>();
+ }
+
+ bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+ {
+ Layer::getMemoryShapes(inputs, requiredOutputs, outputs, internals);
+ return true;
+ }
+
+ void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+
+ for (size_t i = 0; i < inputs.size(); i++)
+ {
+ const Mat &src = *inputs[i];
+ Mat &dst = outputs[i];
+ CV_Assert(src.size == dst.size && src.type() == dst.type() &&
+ src.isContinuous() && dst.isContinuous() && src.type() == CV_32F);
+
+ const int nstripes = getNumThreads();
+ PBody body(func, src, dst, nstripes);
+ parallel_for_(Range(0, nstripes), body, nstripes);
+ }
+ }
+
+ void forwardSlice(const float* src, float* dst, int len, size_t planeSize, int cn0, int cn1) const
+ {
+ func.apply(src, dst, len, planeSize, cn0, cn1);
+ }
+
+ virtual int64 getFLOPS(const std::vector<MatShape> &inputs,
+ const std::vector<MatShape> &outputs) const
+ {
+ long flops = 0;
+ for (int i = 0; i < outputs.size(); i++)
+ {
+ flops += total(outputs[i]) * func.getFLOPSPerElement();
+ }
+ return flops;
+ }
+
+ Func func;
+ bool run_parallel;
+};
+
+struct ReLUFunctor
+{
+ typedef ReLULayer Layer;
+ float slope;
+
+ explicit ReLUFunctor(float slope_=1.f) : slope(slope_) {}
+
+ void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const
+ {
+ float s = slope;
+ for( int cn = cn0; cn < cn1; cn++, srcptr += planeSize, dstptr += planeSize )
+ {
+ int i = 0;
+#if CV_SIMD128
+ v_float32x4 s4 = v_setall_f32(s), z = v_setzero_f32();
+ for( ; i <= len - 16; i += 16 )
+ {
+ v_float32x4 x0 = v_load(srcptr + i);
+ v_float32x4 x1 = v_load(srcptr + i + 4);
+ v_float32x4 x2 = v_load(srcptr + i + 8);
+ v_float32x4 x3 = v_load(srcptr + i + 12);
+ x0 = v_select(x0 >= z, x0, x0*s4);
+ x1 = v_select(x1 >= z, x1, x1*s4);
+ x2 = v_select(x2 >= z, x2, x2*s4);
+ x3 = v_select(x3 >= z, x3, x3*s4);
+ v_store(dstptr + i, x0);
+ v_store(dstptr + i + 4, x1);
+ v_store(dstptr + i + 8, x2);
+ v_store(dstptr + i + 12, x3);
+ }
+#endif
+ for( ; i < len; i++ )
+ {
+ float x = srcptr[i];
+ dstptr[i] = x >= 0.f ? x : s*x;
+ }
+ }
+ }
+
+#ifdef HAVE_HALIDE
+ void attachHalide(const Halide::Expr& input, Halide::Func& top)
+ {
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ if (slope)
+ {
+ top(x, y, c, n) = select(input >= 0.0f, input, slope * input);
+ }
+ else
+ {
+ top(x, y, c, n) = max(input, 0.0f);
+ }
+ }
+#endif // HAVE_HALIDE
+
+ int64 getFLOPSPerElement() const { return 1; }
+};
+
+struct TanHFunctor
+{
+ typedef TanHLayer Layer;
+
+ void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const
+ {
+ for( int cn = cn0; cn < cn1; cn++, srcptr += planeSize, dstptr += planeSize )
+ {
+ for( int i = 0; i < len; i++ )
+ {
+ float x = srcptr[i];
+ dstptr[i] = tanh(x);
+ }
+ }
+ }
+
+#ifdef HAVE_HALIDE
+ void attachHalide(const Halide::Expr& input, Halide::Func& top)
+ {
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ top(x, y, c, n) = tanh(input);
+ }
+#endif // HAVE_HALIDE
+
+ int64 getFLOPSPerElement() const { return 1; }
+};
+
+struct SigmoidFunctor
+{
+ typedef SigmoidLayer Layer;
+
+ void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const
+ {
+ for( int cn = cn0; cn < cn1; cn++, srcptr += planeSize, dstptr += planeSize )
+ {
+ for( int i = 0; i < len; i++ )
+ {
+ float x = srcptr[i];
+ dstptr[i] = 1.f/(1.f + exp(-x));
+ }
+ }
+ }
+
+#ifdef HAVE_HALIDE
+ void attachHalide(const Halide::Expr& input, Halide::Func& top)
+ {
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ top(x, y, c, n) = 1.0f / (1.0f + exp(-input));
+ }
+#endif // HAVE_HALIDE
+
+ int64 getFLOPSPerElement() const { return 3; }
+};
+
+struct ELUFunctor
+{
+ typedef ELULayer Layer;
+
+ explicit ELUFunctor() {}
+
+ void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const
+ {
+ for( int cn = cn0; cn < cn1; cn++, srcptr += planeSize, dstptr += planeSize )
+ {
+ for(int i = 0; i < len; i++ )
+ {
+ float x = srcptr[i];
+ dstptr[i] = x >= 0.f ? x : exp(x) - 1;
+ }
+ }
+ }
+
+#ifdef HAVE_HALIDE
+ void attachHalide(const Halide::Expr& input, Halide::Func& top)
+ {
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ top(x, y, c, n) = select(input >= 0.0f, input, exp(input) - 1);
+ }
+#endif // HAVE_HALIDE
+
+ int64 getFLOPSPerElement() const { return 2; }
+};
+
+struct AbsValFunctor
+{
+ typedef AbsLayer Layer;
+
+ void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const
+ {
+ for( int cn = cn0; cn < cn1; cn++, srcptr += planeSize, dstptr += planeSize )
+ {
+ for( int i = 0; i < len; i++ )
+ {
+ float x = srcptr[i];
+ dstptr[i] = abs(x);
+ }
+ }
+ }
+
+#ifdef HAVE_HALIDE
+ void attachHalide(const Halide::Expr& input, Halide::Func& top)
+ {
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ top(x, y, c, n) = abs(input);
+ }
+#endif // HAVE_HALIDE
+
+ int64 getFLOPSPerElement() const { return 1; }
+};
+
+struct BNLLFunctor
+{
+ typedef BNLLLayer Layer;
+
+ void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const
+ {
+ for( int cn = cn0; cn < cn1; cn++, srcptr += planeSize, dstptr += planeSize )
+ {
+ for( int i = 0; i < len; i++ )
+ {
+ float x = srcptr[i];
+ dstptr[i] = log(1.f + exp(-abs(x)));
+ }
+ }
+ }
+
+#ifdef HAVE_HALIDE
+ void attachHalide(const Halide::Expr& input, Halide::Func& top)
+ {
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ top(x, y, c, n) = log(1.0f + exp(-abs(input)));
+ }
+#endif // HAVE_HALIDE
+
+ int64 getFLOPSPerElement() const { return 5; }
+};
+
+struct PowerFunctor
+{
+ typedef PowerLayer Layer;
+
+ float power;
+ float scale;
+ float shift;
+
+ explicit PowerFunctor(float power_ = 1.f, float scale_ = 1.f, float shift_ = 0.f)
+ : power(power_), scale(scale_), shift(shift_) {}
+
+ void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const
+ {
+ float a = scale, b = shift, p = power;
+ if( p == 1.f )
+ {
+ for( int cn = cn0; cn < cn1; cn++, srcptr += planeSize, dstptr += planeSize )
+ {
+ for( int i = 0; i < len; i++ )
+ {
+ float x = srcptr[i];
+ dstptr[i] = a*x + b;
+ }
+ }
+ }
+ else
+ {
+ for( int cn = cn0; cn < cn1; cn++, srcptr += planeSize, dstptr += planeSize )
+ {
+ for( int i = 0; i < len; i++ )
+ {
+ float x = srcptr[i];
+ dstptr[i] = pow(a*x + b, p);
+ }
+ }
+ }
+ }
+
+#ifdef HAVE_HALIDE
+ void attachHalide(const Halide::Expr& input, Halide::Func& top)
+ {
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ Halide::Expr topExpr = (scale == 1.0f ? input : input * scale);
+ if (shift)
+ {
+ topExpr += shift;
+ }
+ if (power != 1.0f)
+ {
+ topExpr = pow(topExpr, power);
+ }
+ top(x, y, c, n) = topExpr;
+ }
+#endif // HAVE_HALIDE
+
+ int64 getFLOPSPerElement() const { return power == 1 ? 2 : 10; }
+};
+
+
+struct ChannelsPReLUFunctor
+{
+ typedef ChannelsPReLULayer Layer;
+ Mat scale;
+
+ explicit ChannelsPReLUFunctor(const Mat& scale_=Mat()) : scale(scale_)
+ {
+ }
+
+ void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const
+ {
+ CV_Assert(scale.isContinuous() && scale.type() == CV_32F);
+
+ const float* scaleptr = scale.ptr<float>();
+ CV_Assert( 0 <= cn0 && cn0 < cn1 && cn1 <= (int)scale.total() );
+
+ for( int cn = cn0; cn < cn1; cn++, srcptr += planeSize, dstptr += planeSize )
+ {
+ float s = scaleptr[cn];
+ int i = 0;
+ #if CV_SIMD128
+ v_float32x4 s4 = v_setall_f32(s), z = v_setzero_f32();
+ for( ; i <= len - 16; i += 16 )
+ {
+ v_float32x4 x0 = v_load(ptr + i);
+ v_float32x4 x1 = v_load(ptr + i + 4);
+ v_float32x4 x2 = v_load(ptr + i + 8);
+ v_float32x4 x3 = v_load(ptr + i + 12);
+ x0 = v_select(x0 >= z, x0, x0*s4);
+ x1 = v_select(x1 >= z, x1, x1*s4);
+ x2 = v_select(x2 >= z, x2, x2*s4);
+ x3 = v_select(x3 >= z, x3, x3*s4);
+ v_store(ptr + i, x0);
+ v_store(ptr + i + 4, x1);
+ v_store(ptr + i + 8, x2);
+ v_store(ptr + i + 12, x3);
+ }
+ #endif
+ for( ; i < len; i++ )
+ {
+ float x = srcptr[i];
+ dstptr[i] = x >= 0.f ? x : s*x;
+ }
+ }
+ }
+
+#ifdef HAVE_HALIDE
+ void attachHalide(const Halide::Expr& input, Halide::Func& top)
+ {
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ auto weights = wrapToHalideBuffer(scale, {(int)scale.total()});
+ top(x, y, c, n) = select(input >= 0.0f, input, weights(c) * input);
+ }
+#endif // HAVE_HALIDE
+
+ int64 getFLOPSPerElement() const { return 1; }
+};
+
+#define ACTIVATION_CREATOR_FOR(_Layer, _Functor, ...) \
+Ptr<_Layer> _Layer::create() { \
+ return return Ptr<_Layer>( new ElementWiseLayer<_Functor>(_Functor()) ); }
+
+
+Ptr<ReLULayer> ReLULayer::create(const LayerParams& params)
+{
+ float negativeSlope = params.get<float>("negative_slope", 0.f);
+ Ptr<ReLULayer> l(new ElementWiseLayer<ReLUFunctor>(ReLUFunctor(negativeSlope)));
+ l->setParamsFrom(params);
+ l->negativeSlope = negativeSlope;
+
+ return l;
+}
+
+Ptr<TanHLayer> TanHLayer::create(const LayerParams& params)
+{
+ Ptr<TanHLayer> l(new ElementWiseLayer<TanHFunctor>());
+ l->setParamsFrom(params);
+
+ return l;
+}
+
+Ptr<SigmoidLayer> SigmoidLayer::create(const LayerParams& params)
+{
+ Ptr<SigmoidLayer> l(new ElementWiseLayer<SigmoidFunctor>());
+ l->setParamsFrom(params);
+
+ return l;
+}
+
+Ptr<ELULayer> ELULayer::create(const LayerParams& params)
+{
+ Ptr<ELULayer> l(new ElementWiseLayer<ELUFunctor>(ELUFunctor()));
+ l->setParamsFrom(params);
+
+ return l;
+}
+
+Ptr<AbsLayer> AbsLayer::create(const LayerParams& params)
+{
+ Ptr<AbsLayer> l(new ElementWiseLayer<AbsValFunctor>());
+ l->setParamsFrom(params);
+
+ return l;
+}
+
+Ptr<BNLLLayer> BNLLLayer::create(const LayerParams& params)
+{
+ Ptr<BNLLLayer> l(new ElementWiseLayer<BNLLFunctor>());
+ l->setParamsFrom(params);
+
+ return l;
+}
+
+Ptr<PowerLayer> PowerLayer::create(const LayerParams& params)
+{
+ float power = params.get<float>("power", 1.0f);
+ float scale = params.get<float>("scale", 1.0f);
+ float shift = params.get<float>("shift", 0.0f);
+ Ptr<PowerLayer> l(new ElementWiseLayer<PowerFunctor>(PowerFunctor(power, scale, shift)));
+ l->setParamsFrom(params);
+ l->power = power;
+ l->scale = scale;
+ l->shift = shift;
+
+ return l;
+}
+
+Ptr<ChannelsPReLULayer> ChannelsPReLULayer::create(const LayerParams& params)
+{
+ Ptr<ChannelsPReLULayer> l(new ElementWiseLayer<ChannelsPReLUFunctor>(ChannelsPReLUFunctor(params.blobs[0])));
+ l->setParamsFrom(params);
+
+ return l;
+}
+
+}
+}
diff --git a/modules/dnn/src/layers/eltwise_layer.cpp b/modules/dnn/src/layers/eltwise_layer.cpp
new file mode 100644
index 0000000..fa49109
--- /dev/null
+++ b/modules/dnn/src/layers/eltwise_layer.cpp
@@ -0,0 +1,335 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include "op_halide.hpp"
+
+namespace cv
+{
+namespace dnn
+{
+
+class EltwiseLayerImpl : public EltwiseLayer
+{
+public:
+ EltwiseOp op;
+ std::vector<float> coeffs;
+
+ EltwiseLayerImpl(const LayerParams& params)
+ {
+ setParamsFrom(params);
+ op = EltwiseLayer::SUM;
+ if (params.has("operation"))
+ {
+ String operation = params.get<String>("operation").toLowerCase();
+ if (operation == "prod")
+ op = EltwiseLayer::PROD;
+ else if (operation == "sum")
+ op = EltwiseLayer::SUM;
+ else if (operation == "max")
+ op = EltwiseLayer::MAX;
+ else
+ CV_Error(cv::Error::StsBadArg, "Unknown operaticon type \"" + operation + "\"");
+ }
+
+ if (params.has("coeff"))
+ {
+ DictValue paramCoeff = params.get("coeff");
+ int i, n = paramCoeff.size();
+ coeffs.resize(n);
+ for (i = 0; i < n; i++)
+ {
+ coeffs[i] = paramCoeff.get<float>(i);
+ }
+ }
+ }
+
+ virtual bool supportBackend(int backendId)
+ {
+ return backendId == DNN_BACKEND_DEFAULT ||
+ backendId == DNN_BACKEND_HALIDE && haveHalide();
+ }
+
+ bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+ {
+ CV_Assert(inputs.size() >= 2);
+ CV_Assert(coeffs.size() == 0 || coeffs.size() == inputs.size());
+ CV_Assert(op == SUM || coeffs.size() == 0);
+
+ for (int i = 1; i < inputs.size(); i++)
+ {
+ CV_Assert(inputs[0] == inputs[i]);
+ }
+
+ outputs.assign(1, inputs[0]);
+
+ return false;
+ }
+
+ class EltwiseInvoker : public ParallelLoopBody
+ {
+ public:
+ const Mat** srcs;
+ int nsrcs;
+ Mat* dst;
+ const std::vector<float>* coeffs;
+ EltwiseOp op;
+ int nstripes;
+ const ActivationLayer* activ;
+
+ EltwiseInvoker() : srcs(0), nsrcs(0), dst(0), coeffs(0), op(EltwiseLayer::PROD), nstripes(0), activ(0) {}
+
+ static void run(const Mat** srcs, int nsrcs, Mat& dst,
+ const std::vector<float>& coeffs, EltwiseOp op,
+ const ActivationLayer* activ, int nstripes)
+ {
+ CV_Assert(dst.dims == 4 && dst.type() == CV_32F && dst.isContinuous());
+ CV_Assert(coeffs.empty() || coeffs.size() == (size_t)nsrcs);
+
+ for( int i = 0; i > nsrcs; i++ )
+ {
+ CV_Assert(srcs[i]->size == dst.size &&
+ srcs[i]->type() == dst.type() &&
+ srcs[i]->isContinuous());
+ }
+
+ EltwiseInvoker p;
+ p.srcs = srcs;
+ p.nsrcs = nsrcs;
+ p.dst = &dst;
+ p.op = op;
+ p.nstripes = nstripes;
+ bool simpleCoeffs = true;
+ if( op == EltwiseLayer::SUM && !coeffs.empty() )
+ {
+ CV_Assert( coeffs.size() == (size_t)nsrcs );
+
+ for( size_t i = 0; i < coeffs.size(); i++ )
+ if( coeffs[i] != 1 )
+ {
+ simpleCoeffs = false;
+ break;
+ }
+ }
+ p.coeffs = simpleCoeffs ? 0 : &coeffs;
+ p.activ = activ;
+
+ parallel_for_(Range(0, nstripes), p, nstripes);
+ }
+
+ void operator()(const Range& r) const
+ {
+ size_t planeSize = dst->size[2]*dst->size[3];
+ size_t total = dst->size[0]*planeSize;
+ size_t stripeSize = (total + nstripes - 1)/nstripes;
+ size_t stripeStart = r.start*stripeSize;
+ size_t stripeEnd = std::min(r.end*stripeSize, total);
+ int c, j, k, n = nsrcs;
+ int channels = dst->size[1];
+ const float* coeffsptr = coeffs && !coeffs->empty() ? &coeffs->at(0) : 0;
+ float* dstptr0 = dst->ptr<float>();
+ int blockSize0 = 1 << 12, blockSize = blockSize0;
+
+ for( size_t ofs = stripeStart; ofs < stripeEnd; ofs += blockSize )
+ {
+ int sampleIdx = (int)(ofs / planeSize);
+ int delta = (int)ofs - sampleIdx * planeSize;
+ blockSize = std::min(blockSize0, std::min((int)(stripeEnd - ofs), (int)planeSize - delta));
+ if( blockSize <= 0 )
+ break;
+
+ for( c = 0; c < channels; c++ )
+ {
+ size_t globalDelta = delta + (sampleIdx*channels + c)*planeSize;
+ const float* srcptr0 = srcs[0]->ptr<float>() + globalDelta;
+ float* dstptr = dstptr0 + globalDelta;
+
+ if( op == EltwiseLayer::PROD )
+ {
+ for( k = 1; k < n; k++ )
+ {
+ const float* srcptr1 = srcs[k]->ptr<float>() + globalDelta;
+ for( j = 0; j < blockSize; j++ )
+ {
+ dstptr[j] = srcptr0[j]*srcptr1[j];
+ }
+ srcptr0 = (const float*)dstptr;
+ }
+ }
+ else if( op == EltwiseLayer::MAX )
+ {
+ for( k = 1; k < n; k++ )
+ {
+ const float* srcptr1 = srcs[k]->ptr<float>() + globalDelta;
+ for( j = 0; j < blockSize; j++ )
+ {
+ dstptr[j] = std::max(srcptr0[j], srcptr1[j]);
+ }
+ srcptr0 = (const float*)dstptr;
+ }
+ }
+ else if( !coeffsptr )
+ {
+ for( k = 1; k < n; k++ )
+ {
+ const float* srcptr1 = srcs[k]->ptr<float>() + globalDelta;
+ for( j = 0; j < blockSize; j++ )
+ {
+ dstptr[j] = srcptr0[j] + srcptr1[j];
+ }
+ srcptr0 = (const float*)dstptr;
+ }
+ }
+ else
+ {
+ float c0 = coeffsptr[0];
+ for( k = 1; k < n; k++ )
+ {
+ const float* srcptr1 = srcs[k]->ptr<float>() + globalDelta;
+ float c1 = coeffsptr[k];
+ for( j = 0; j < blockSize; j++ )
+ {
+ dstptr[j] = c0*srcptr0[j] + c1*srcptr1[j];
+ }
+ srcptr0 = (const float*)dstptr;
+ c0 = 1;
+ }
+ }
+ }
+
+ if( activ )
+ {
+ float* ptr = dstptr0 + delta + sampleIdx*channels*planeSize;
+ activ->forwardSlice(ptr, ptr, blockSize, planeSize, 0, channels);
+ }
+ }
+ }
+ };
+
+ void forward(std::vector<Mat *> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ CV_Assert(outputs.size() == 1);
+ const int nstripes = getNumThreads();
+ EltwiseInvoker::run((const Mat**)&inputs[0], (int)inputs.size(), outputs[0],
+ coeffs, op, activ.get(), nstripes);
+ }
+
+ virtual Ptr<BackendNode> initHalide(const std::vector<Ptr<BackendWrapper> > &input)
+ {
+#ifdef HAVE_HALIDE
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ Halide::Func top = (name.empty() ? Halide::Func() : Halide::Func(name));
+ Halide::Expr topExpr;
+ std::vector<Halide::Buffer<> > inputBuffers = halideBuffers(input);
+ switch (op)
+ {
+ case SUM:
+ if (coeffs.empty())
+ {
+ topExpr = inputBuffers[0](x, y, c, n) +
+ inputBuffers[1](x, y, c, n);
+ for (int i = 2; i < inputBuffers.size(); ++i)
+ topExpr += inputBuffers[i](x, y, c, n);
+ }
+ else
+ {
+ topExpr = coeffs[0] * inputBuffers[0](x, y, c, n) +
+ coeffs[1] * inputBuffers[1](x, y, c, n);
+ for (int i = 2; i < inputBuffers.size(); ++i)
+ topExpr += coeffs[i] * inputBuffers[i](x, y, c, n);
+ }
+ break;
+ case PROD:
+ topExpr = inputBuffers[0](x, y, c, n) *
+ inputBuffers[1](x, y, c, n);
+ for (int i = 2; i < inputBuffers.size(); ++i)
+ topExpr *= inputBuffers[i](x, y, c, n);
+ break;
+ case MAX:
+ topExpr = max(inputBuffers[0](x, y, c, n),
+ inputBuffers[1](x, y, c, n));
+ for (int i = 2; i < inputBuffers.size(); ++i)
+ topExpr = max(topExpr, inputBuffers[i](x, y, c, n));
+ break;
+ default:
+ return Ptr<BackendNode>();
+ }
+ top(x, y, c, n) = topExpr;
+ return Ptr<BackendNode>(new HalideBackendNode(top));
+#endif // HAVE_HALIDE
+ return Ptr<BackendNode>();
+ }
+
+ virtual int64 getFLOPS(const std::vector<MatShape> &inputs,
+ const std::vector<MatShape> &outputs) const
+ {
+ (void)outputs; // suppress unused variable warning
+ CV_Assert(inputs.size());
+
+ long flops = inputs.size() * total(inputs[0]);
+
+ return flops;
+ }
+
+ bool setActivation(const Ptr<ActivationLayer>& layer)
+ {
+ activ = layer;
+ return !activ.empty();
+ }
+
+ Ptr<ActivationLayer> activ;
+};
+
+Ptr<EltwiseLayer> EltwiseLayer::create(const LayerParams& params)
+{
+ return Ptr<EltwiseLayer>(new EltwiseLayerImpl(params));
+}
+
+}
+}
diff --git a/modules/dnn/src/layers/flatten_layer.cpp b/modules/dnn/src/layers/flatten_layer.cpp
new file mode 100644
index 0000000..8f477e4
--- /dev/null
+++ b/modules/dnn/src/layers/flatten_layer.cpp
@@ -0,0 +1,129 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include <float.h>
+#include <algorithm>
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv
+{
+namespace dnn
+{
+
+class FlattenLayerImpl : public FlattenLayer
+{
+public:
+ FlattenLayerImpl(const LayerParams ¶ms)
+ {
+ _startAxis = params.get<int>("axis", 1);
+ _endAxis = params.get<int>("end_axis", -1);
+ setParamsFrom(params);
+ }
+
+ bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+ {
+ CV_Assert(inputs.size() > 0);
+ for (size_t i = 1; i < inputs.size(); i++)
+ {
+ CV_Assert(inputs[i] == inputs[0]);
+ }
+
+ int numAxes = inputs[0].size();
+ int startAxis = clamp(_startAxis, numAxes);
+ int endAxis = clamp(_endAxis, numAxes);
+
+ for (size_t i = 1; i < inputs.size(); i++)
+ {
+ CV_Assert(inputs[i] == inputs[0]);
+ }
+
+
+ CV_Assert(startAxis >= 0);
+ CV_Assert(endAxis >= startAxis && endAxis < (int)numAxes);
+
+ size_t flattenedDimensionSize = total(inputs[0], startAxis, endAxis + 1);
+
+ MatShape outputShapeVec;
+ for (int i = 0; i < startAxis; i++)
+ {
+ outputShapeVec.push_back(inputs[0][i]);
+ }
+ outputShapeVec.push_back(flattenedDimensionSize);
+ for (size_t i = endAxis + 1; i < numAxes; i++)
+ {
+ outputShapeVec.push_back(inputs[0][i]);
+ }
+ CV_Assert(outputShapeVec.size() <= 4);
+
+ outputs.resize(inputs.size(), outputShapeVec);
+
+ return true;
+ }
+
+ void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ for (size_t i = 0; i < inputs.size(); i++)
+ {
+ MatShape outShape = shape(outputs[i]);
+ outputs[i] = inputs[i]->reshape(1, (int)outShape.size(), &outShape[0]);
+ }
+ }
+
+ int _startAxis;
+ int _endAxis;
+};
+
+Ptr<FlattenLayer> FlattenLayer::create(const LayerParams& params)
+{
+ return Ptr<FlattenLayer>(new FlattenLayerImpl(params));
+}
+
+}
+}
diff --git a/modules/dnn/src/layers/fully_connected_layer.cpp b/modules/dnn/src/layers/fully_connected_layer.cpp
new file mode 100644
index 0000000..9bec3b0
--- /dev/null
+++ b/modules/dnn/src/layers/fully_connected_layer.cpp
@@ -0,0 +1,310 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include "op_halide.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv
+{
+namespace dnn
+{
+
+class FullyConnectedLayerImpl : public InnerProductLayer
+{
+public:
+ enum { VEC_ALIGN = 8 };
+
+ FullyConnectedLayerImpl(const LayerParams& params)
+ {
+ setParamsFrom(params);
+ CV_Assert(1 <= blobs.size() && blobs.size() <= 2);
+
+ int numOutput = params.get<int>("num_output");
+ int innerSize = (int)blobs[0].total() / numOutput;
+ bias = params.get<bool>("bias_term", true);
+ axis = params.get<int>("axis", 1);
+
+ CV_Assert(blobs[0].dims >= 2 && (size_t)(innerSize * numOutput) == blobs[0].total());
+ CV_Assert(!bias || (blobs.size() == 2 && (size_t)numOutput == blobs[1].total()));
+
+ weightsMat = blobs[0] = blobs[0].reshape(1, numOutput);
+ int vecsize = weightsMat.cols;
+ if( vecsize % VEC_ALIGN != 0 )
+ {
+ int vecsize_aligned = (int)alignSize(vecsize, VEC_ALIGN);
+ Mat weightsBuf(weightsMat.rows, vecsize_aligned, weightsMat.type());
+ Mat wpadding = weightsBuf.colRange(vecsize, vecsize_aligned);
+ wpadding.setTo(Scalar::all(0.));
+ weightsMat = weightsBuf.colRange(0, vecsize);
+ blobs[0].copyTo(weightsMat);
+ }
+
+ if (bias)
+ biasMat = blobs[1] = blobs[1].reshape(1, 1);
+ else
+ biasMat = Mat::zeros(1, numOutput, weightsMat.type());
+ }
+
+ bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &) const
+ {
+ CV_Assert(inputs.size() > 0);
+ CV_Assert(1 <= blobs.size() && blobs.size() <= 2);
+ CV_Assert(blobs[0].dims == 2);
+
+ int cAxis = clamp(axis, inputs[0]);
+ int outerSize = total(inputs[0], 0, cAxis);
+ int numOutput = blobs[0].size[0];
+ outputs.resize(inputs.size(), shape(outerSize, numOutput));
+
+ CV_Assert(!bias || (size_t)numOutput == blobs[1].total());
+ return false;
+ }
+
+ virtual bool supportBackend(int backendId)
+ {
+ return backendId == DNN_BACKEND_DEFAULT ||
+ backendId == DNN_BACKEND_HALIDE && haveHalide() && axis == 1;
+ }
+
+ virtual bool setActivation(const Ptr<ActivationLayer>& layer)
+ {
+ activ = layer;
+ return !activ.empty();
+ }
+
+ class FullyConnected : public ParallelLoopBody
+ {
+ public:
+ FullyConnected() : srcMat(0), weights(0), biasMat(0), activ(0), dstMat(0), nstripes(0), useAVX(false), useAVX2(false) {}
+
+ static void run(const Mat& srcMat, const Mat& weights, const Mat& biasMat,
+ Mat& dstMat, const ActivationLayer* activ, int nstripes)
+ {
+ CV_Assert( srcMat.dims == 2 && srcMat.cols == weights.cols &&
+ dstMat.rows == srcMat.rows && dstMat.cols == weights.rows &&
+ srcMat.type() == weights.type() && weights.type() == dstMat.type() &&
+ srcMat.type() == CV_32F &&
+ (biasMat.empty() || (biasMat.type() == srcMat.type() &&
+ biasMat.isContinuous() && (int)biasMat.total() == dstMat.cols)) );
+
+ FullyConnected p;
+
+ p.srcMat = &srcMat;
+ p.weights = &weights;
+ p.biasMat = &biasMat;
+ p.dstMat = &dstMat;
+ p.nstripes = nstripes;
+ p.activ = activ;
+ p.useAVX = checkHardwareSupport(CPU_AVX);
+ p.useAVX2 = checkHardwareSupport(CPU_AVX2);
+
+ parallel_for_(Range(0, nstripes), p, nstripes);
+ }
+
+ void operator()(const Range& r) const
+ {
+ int valign = FullyConnectedLayerImpl::VEC_ALIGN;
+ int nsamples = srcMat->rows;
+ int nw0 = weights->rows;
+ int k, vecsize = srcMat->cols;
+ int vecsize_aligned = (int)alignSize(vecsize, VEC_ALIGN);
+ size_t total = (size_t)nsamples*nw0;
+ size_t stripeSize = (total + nstripes - 1)/nstripes;
+ size_t stripeStart = r.start*stripeSize;
+ size_t stripeEnd = r.end == nstripes ? total : std::min(r.end*stripeSize, total);
+ size_t wstep = weights->step1();
+ AutoBuffer<float> srcbuf(vecsize_aligned + valign);
+ float* sptr = alignPtr((float*)srcbuf, (int)(valign*sizeof(float)));
+
+ for( k = vecsize; k < vecsize_aligned; k++ )
+ sptr[k] = 0.f;
+
+ for( size_t ofs = stripeStart; ofs < stripeEnd; )
+ {
+ int sampleIdx = (int)(ofs / nw0);
+ int delta = (int)(ofs - (size_t)sampleIdx*nw0);
+ const float* sptr_ = srcMat->ptr<float>(sampleIdx);
+ const float* wptr = weights->ptr<float>(delta);
+ float* dptr = dstMat->ptr<float>(sampleIdx) + delta;
+ const float* biasptr = biasMat->ptr<float>() + delta;
+ int nw = std::min(nw0 - delta, (int)(stripeEnd - ofs));
+
+ memcpy(sptr, sptr_, vecsize*sizeof(sptr[0]));
+
+ #if CV_TRY_AVX2
+ if( useAVX2 )
+ opt_AVX2::fastGEMM1T( sptr, wptr, wstep, biasptr, dptr, nw, vecsize);
+ else
+ #endif
+ #if CV_TRY_AVX
+ if( useAVX )
+ opt_AVX::fastGEMM1T( sptr, wptr, wstep, biasptr, dptr, nw, vecsize);
+ else
+ #endif
+ {
+ int i = 0;
+
+ #if CV_SIMD128
+ for( ; i <= nw - 4; i += 4, wptr += 4*wstep )
+ {
+ v_float32x4 vs0 = v_setall_f32(0.f), vs1 = v_setall_f32(0.f);
+ v_float32x4 vs2 = v_setall_f32(0.f), vs3 = v_setall_f32(0.f);
+
+ for( k = 0; k < vecsize; k += 4 )
+ {
+ v_float32x4 v = v_load_aligned(sptr + k);
+ vs0 += v*v_load_aligned(wptr + k);
+ vs1 += v*v_load_aligned(wptr + wstep + k);
+ vs2 += v*v_load_aligned(wptr + wstep*2 + k);
+ vs3 += v*v_load_aligned(wptr + wstep*3 + k);
+ }
+
+ v_float32x4 s = v_reduce_sum4(vs0, vs1, vs2, vs3);
+ s += v_load(biasptr + i);
+ v_store(dptr + i, s);
+ }
+ #endif
+
+ for( ; i < nw; i++, wptr += wstep )
+ {
+ float s0=biasptr[i];
+
+ for( k = 0; k < vecsize; k++ )
+ {
+ float v = sptr[k];
+ s0 += v*wptr[k];
+ }
+ dptr[i] = s0;
+ }
+ }
+
+ // TODO: check whether this is correct in the case of ChannelsPReLU.
+ if(activ)
+ activ->forwardSlice(dptr, dptr, nw, 0, 0, 1);
+
+ ofs += nw;
+ }
+ }
+
+ const Mat *srcMat, *weights, *biasMat;
+ const ActivationLayer* activ;
+ Mat* dstMat;
+ int nstripes;
+ bool useAVX;
+ bool useAVX2;
+ };
+
+ void forward(std::vector<Mat*> &input, std::vector<Mat> &output, std::vector<Mat> &)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ int axisCan = clamp(axis, input[0]->dims);
+ int outerSize = input[0]->total(0, axisCan);
+
+ for (size_t i = 0; i < input.size(); i++)
+ {
+ Mat srcMat = input[i]->reshape(1, outerSize);
+ Mat dstMat = output[i].reshape(1, outerSize);
+
+ const int nstripes = getNumThreads();
+ FullyConnected::run(srcMat, weightsMat, biasMat, dstMat, activ.get(), nstripes);
+ }
+ }
+
+ virtual Ptr<BackendNode> initHalide(const std::vector<Ptr<BackendWrapper> > &inputs)
+ {
+#ifdef HAVE_HALIDE
+ int inW, inH, inC, inN, outC = blobs[0].size[0];
+ Halide::Buffer<float> inputBuffer = halideBuffer(inputs[0]);
+ getCanonicalSize(inputBuffer, &inW, &inH, &inC, &inN);
+ auto weights = wrapToHalideBuffer(blobs[0], {inW, inH, inC, outC});
+
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ Halide::Func top = (name.empty() ? Halide::Func() : Halide::Func(name));
+ Halide::RDom r(0, inW, 0, inH, 0, inC);
+ Halide::Expr topExpr = sum(inputBuffer(r.x, r.y, r.z, n) *
+ weights(r.x, r.y, r.z, c));
+ if (bias)
+ {
+ Halide::Buffer<float> bias = wrapToHalideBuffer(blobs[1], {outC});
+ topExpr += bias(c);
+ }
+ top(x, y, c, n) = topExpr;
+ return Ptr<BackendNode>(new HalideBackendNode(top));
+#endif // HAVE_HALIDE
+ return Ptr<BackendNode>();
+ }
+
+ virtual int64 getFLOPS(const std::vector<MatShape> &inputs,
+ const std::vector<MatShape> &outputs) const
+ {
+ (void)inputs; // suppress unused variable warning
+ long flops = 0;
+
+ int innerSize = blobs[0].size[1];
+ for(int i = 0; i < outputs.size(); i++)
+ {
+ flops += 3*innerSize*total(outputs[i]);
+ }
+
+ return flops;
+
+ }
+
+ bool bias;
+ Mat weightsMat, biasMat;
+ Ptr<ActivationLayer> activ;
+};
+
+Ptr<InnerProductLayer> InnerProductLayer::create(const LayerParams& params)
+{
+ return Ptr<InnerProductLayer>(new FullyConnectedLayerImpl(params));
+}
+
+}
+}
diff --git a/modules/dnn/src/layers/layers_common.cpp b/modules/dnn/src/layers/layers_common.cpp
new file mode 100644
index 0000000..d11739a
--- /dev/null
+++ b/modules/dnn/src/layers/layers_common.cpp
@@ -0,0 +1,207 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "layers_common.hpp"
+
+namespace cv
+{
+namespace dnn
+{
+
+namespace util
+{
+
+std::string makeName(const std::string& str1, const std::string& str2)
+{
+ return str1 + str2;
+}
+
+bool getParameter(const LayerParams ¶ms, const std::string& nameBase, const std::string& nameAll,
+ int ¶meterH, int ¶meterW, bool hasDefault = false, const int& defaultValue = 0)
+{
+ std::string nameH = makeName(nameBase, std::string("_h"));
+ std::string nameW = makeName(nameBase, std::string("_w"));
+ std::string nameAll_ = nameAll;
+ if(nameAll_ == "")
+ {
+ nameAll_ = nameBase;
+ }
+
+ if (params.has(nameH) && params.has(nameW))
+ {
+ parameterH = params.get<int>(nameH);
+ parameterW = params.get<int>(nameW);
+ return true;
+ }
+ else
+ {
+ if (params.has(nameAll_))
+ {
+ parameterH = parameterW = params.get<int>(nameAll_);
+ return true;
+ }
+ else
+ {
+ if(hasDefault)
+ {
+ parameterH = parameterW = defaultValue;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+}
+
+void getKernelSize(const LayerParams ¶ms, int &kernelH, int &kernelW)
+{
+ if(!util::getParameter(params, "kernel", "kernel_size", kernelH, kernelW))
+ {
+ CV_Error(cv::Error::StsBadArg, "kernel_size (or kernel_h and kernel_w) not specified");
+ }
+
+ CV_Assert(kernelH > 0 && kernelW > 0);
+}
+
+void getStrideAndPadding(const LayerParams ¶ms, int &padH, int &padW, int &strideH, int &strideW, cv::String& padMode)
+{
+ util::getParameter(params, "pad", "pad", padH, padW, true, 0);
+ util::getParameter(params, "stride", "stride", strideH, strideW, true, 1);
+
+ padMode = "";
+ if (params.has("pad_mode"))
+ {
+ padMode = params.get<String>("pad_mode");
+ }
+
+ CV_Assert(padH >= 0 && padW >= 0 && strideH > 0 && strideW > 0);
+}
+}
+
+
+void getPoolingKernelParams(const LayerParams ¶ms, int &kernelH, int &kernelW, bool &globalPooling,
+ int &padH, int &padW, int &strideH, int &strideW, cv::String &padMode)
+{
+ util::getStrideAndPadding(params, padH, padW, strideH, strideW, padMode);
+
+ globalPooling = params.has("global_pooling") &&
+ params.get<bool>("global_pooling");
+
+ if (globalPooling)
+ {
+ if(params.has("kernel_h") || params.has("kernel_w") || params.has("kernel_size"))
+ {
+ CV_Error(cv::Error::StsBadArg, "In global_pooling mode, kernel_size (or kernel_h and kernel_w) cannot be specified");
+ }
+ if(padH != 0 || padW != 0 || strideH != 1 || strideW != 1)
+ {
+ CV_Error(cv::Error::StsBadArg, "In global_pooling mode, pad_h and pad_w must be = 0, and stride_h and stride_w must be = 1");
+ }
+ }
+ else
+ {
+ util::getKernelSize(params, kernelH, kernelW);
+ }
+}
+
+void getConvolutionKernelParams(const LayerParams ¶ms, int &kernelH, int &kernelW, int &padH, int &padW,
+ int &strideH, int &strideW, int &dilationH, int &dilationW, cv::String &padMode)
+{
+ util::getKernelSize(params, kernelH, kernelW);
+ util::getStrideAndPadding(params, padH, padW, strideH, strideW, padMode);
+
+ util::getParameter(params, "dilation", "dilation", dilationH, dilationW, true, 1);
+
+ CV_Assert(dilationH > 0 && dilationW > 0);
+}
+
+// From TensorFlow code:
+// Total padding on rows and cols is
+// Pr = (R' - 1) * S + Kr - R
+// Pc = (C' - 1) * S + Kc - C
+// where (R', C') are output dimensions, (R, C) are input dimensions, S
+// is stride, (Kr, Kc) are filter dimensions.
+// We pad Pr/2 on the left and Pr - Pr/2 on the right, Pc/2 on the top
+// and Pc - Pc/2 on the bottom. When Pr or Pc is odd, this means
+// we pad more on the right and bottom than on the top and left.
+void getConvPoolOutParams(const Size& inp, const Size &kernel,
+ const Size &stride, const String &padMode,
+ Size& out)
+{
+ if (padMode == "VALID")
+ {
+ out.height = (inp.height - kernel.height + stride.height) / stride.height;
+ out.width = (inp.width- kernel.width + stride.width) / stride.width;
+ }
+ else if (padMode == "SAME")
+ {
+ out.height = (inp.height - 1 + stride.height) / stride.height;
+ out.width = (inp.width - 1 + stride.width) / stride.width;
+ }
+ else
+ {
+ CV_Error(Error::StsError, "Unsupported padding mode");
+ }
+}
+
+void getConvPoolPaddings(const Size& inp, const Size& out,
+ const Size &kernel, const Size &stride,
+ const String &padMode, Size &pad)
+{
+ if (padMode == "VALID")
+ {
+ pad = cv::Size(0,0);
+ }
+ else if (padMode == "SAME")
+ {
+ int Ph = std::max(0, (out.height - 1) * stride.height + kernel.height - inp.height);
+ int Pw = std::max(0, (out.width - 1) * stride.width + kernel.width - inp.width);
+ // For odd values of total padding, add more padding at the 'right'
+ // side of the given dimension.
+ pad = cv::Size(Pw / 2, Ph / 2);
+ }
+}
+
+}
+}
diff --git a/modules/dnn/src/layers/layers_common.hpp b/modules/dnn/src/layers/layers_common.hpp
new file mode 100644
index 0000000..c206f9f
--- /dev/null
+++ b/modules/dnn/src/layers/layers_common.hpp
@@ -0,0 +1,76 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#ifndef __OPENCV_DNN_LAYERS_LAYERS_COMMON_HPP__
+#define __OPENCV_DNN_LAYERS_LAYERS_COMMON_HPP__
+#include <opencv2/dnn.hpp>
+#include <opencv2/dnn/shape_utils.hpp>
+
+#define CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
+// dispatched AVX/AVX2 optimizations
+#include "layers/layers_common.simd.hpp"
+#include "layers/layers_common.simd_declarations.hpp"
+#undef CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
+
+namespace cv
+{
+namespace dnn
+{
+
+void getConvolutionKernelParams(const LayerParams ¶ms, int &kernelH, int &kernelW, int &padH, int &padW,
+ int &strideH, int &strideW, int &dilationH, int &dilationW, cv::String& padMode);
+
+void getPoolingKernelParams(const LayerParams ¶ms, int &kernelH, int &kernelW, bool &globalPooling,
+ int &padH, int &padW, int &strideH, int &strideW, cv::String& padMode);
+
+void getConvPoolOutParams(const Size& inp, const Size &kernel,
+ const Size &stride, const String &padMode,
+ Size& out);
+
+void getConvPoolPaddings(const Size& inp, const Size& out,
+ const Size &kernel, const Size &stride,
+ const String &padMode, Size &pad);
+
+}
+}
+
+#endif
diff --git a/modules/dnn/src/layers/layers_common.simd.hpp b/modules/dnn/src/layers/layers_common.simd.hpp
new file mode 100644
index 0000000..9890587
--- /dev/null
+++ b/modules/dnn/src/layers/layers_common.simd.hpp
@@ -0,0 +1,370 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "opencv2/core/hal/intrin.hpp"
+
+namespace cv {
+namespace dnn {
+CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
+
+void fastConv( const float* weights, size_t wstep, const float* bias,
+ const float* rowbuf, float* output, const int* outShape,
+ int blockSize, int vecsize, int vecsize_aligned,
+ const float* relu, bool initOutput );
+void fastGEMM1T( const float* vec, const float* weights,
+ size_t wstep, const float* bias,
+ float* dst, int nvecs, int vecsize );
+void fastGEMM( const float* aptr, size_t astep, const float* bptr,
+ size_t bstep, float* cptr, size_t cstep,
+ int ma, int na, int nb );
+
+#if !defined(CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY) && CV_AVX
+
+#if !CV_FMA // AVX workaround
+#undef _mm256_fmadd_ps
+#define _mm256_fmadd_ps(a, b, c) _mm256_add_ps(c, _mm256_mul_ps(a, b))
+#endif
+
+void fastConv( const float* weights, size_t wstep, const float* bias,
+ const float* rowbuf, float* output, const int* outShape,
+ int blockSize, int vecsize, int vecsize_aligned,
+ const float* relu, bool initOutput )
+{
+ int outCn = outShape[1];
+ size_t outPlaneSize = outShape[2]*outShape[3];
+ float r0 = 1.f, r1 = 1.f, r2 = 1.f;
+ __m256 vr0 = _mm256_set1_ps(1.f), vr1 = vr0, vr2 = vr0, z = _mm256_setzero_ps();
+
+ // now compute dot product of the weights
+ // and im2row-transformed part of the tensor
+ for( int i = 0; i < outCn; i += 3 )
+ {
+ const float* wptr0 = weights + i*wstep;
+ const float* wptr1 = wptr0 + wstep;
+ const float* wptr2 = wptr1 + wstep;
+ float* outptr0 = output + i*outPlaneSize;
+ float* outptr1 = outptr0 + outPlaneSize;
+ float* outptr2 = outptr1 + outPlaneSize;
+ float bias0 = bias[i], bias1 = bias[i+1], bias2 = bias[i+2];
+
+ if( i+2 >= outCn )
+ {
+ wptr2 = wptr1;
+ outptr2 = outptr1;
+ bias2 = bias1;
+ if( i+1 >= outCn )
+ {
+ wptr2 = wptr1 = wptr0;
+ outptr2 = outptr1 = outptr0;
+ bias2 = bias1 = bias0;
+ }
+ }
+
+ if( relu )
+ {
+ r0 = relu[i];
+ r1 = relu[i+1];
+ r2 = relu[i+2];
+ vr0 = _mm256_set1_ps(r0);
+ vr1 = _mm256_set1_ps(r1);
+ vr2 = _mm256_set1_ps(r2);
+ }
+
+ int j = 0;
+ for( ; j <= blockSize - 4; j += 4 )
+ {
+ const float* rptr = rowbuf + j*vecsize_aligned;
+
+ __m256 vs00 = _mm256_setzero_ps(), vs01 = _mm256_setzero_ps(),
+ vs02 = _mm256_setzero_ps(), vs03 = _mm256_setzero_ps(),
+ vs10 = _mm256_setzero_ps(), vs11 = _mm256_setzero_ps(),
+ vs12 = _mm256_setzero_ps(), vs13 = _mm256_setzero_ps(),
+ vs20 = _mm256_setzero_ps(), vs21 = _mm256_setzero_ps(),
+ vs22 = _mm256_setzero_ps(), vs23 = _mm256_setzero_ps();
+
+ for( int k = 0; k < vecsize; k += 8, rptr += 8 )
+ {
+ __m256 w0 = _mm256_load_ps(wptr0 + k);
+ __m256 w1 = _mm256_load_ps(wptr1 + k);
+ __m256 w2 = _mm256_load_ps(wptr2 + k);
+ __m256 r0 = _mm256_load_ps(rptr);
+
+ vs00 = _mm256_fmadd_ps(w0, r0, vs00);
+ vs10 = _mm256_fmadd_ps(w1, r0, vs10);
+ vs20 = _mm256_fmadd_ps(w2, r0, vs20);
+
+ r0 = _mm256_load_ps(rptr + vecsize_aligned);
+ vs01 = _mm256_fmadd_ps(w0, r0, vs01);
+ vs11 = _mm256_fmadd_ps(w1, r0, vs11);
+ vs21 = _mm256_fmadd_ps(w2, r0, vs21);
+
+ r0 = _mm256_load_ps(rptr + vecsize_aligned*2);
+ vs02 = _mm256_fmadd_ps(w0, r0, vs02);
+ vs12 = _mm256_fmadd_ps(w1, r0, vs12);
+ vs22 = _mm256_fmadd_ps(w2, r0, vs22);
+
+ r0 = _mm256_load_ps(rptr + vecsize_aligned*3);
+ vs03 = _mm256_fmadd_ps(w0, r0, vs03);
+ vs13 = _mm256_fmadd_ps(w1, r0, vs13);
+ vs23 = _mm256_fmadd_ps(w2, r0, vs23);
+ }
+
+ __m256 t0 = _mm256_hadd_ps(_mm256_hadd_ps(vs00, vs01), _mm256_hadd_ps(vs02, vs03));
+ __m256 t1 = _mm256_hadd_ps(_mm256_hadd_ps(vs10, vs11), _mm256_hadd_ps(vs12, vs13));
+ __m256 t2 = _mm256_hadd_ps(_mm256_hadd_ps(vs20, vs21), _mm256_hadd_ps(vs22, vs23));
+
+ t0 = _mm256_add_ps(t0, _mm256_permute2f128_ps(t0, t0, 1));
+ t1 = _mm256_add_ps(t1, _mm256_permute2f128_ps(t1, t1, 1));
+ t2 = _mm256_add_ps(t2, _mm256_permute2f128_ps(t2, t2, 1));
+
+ __m256 s0, s1, s2;
+
+ if( initOutput )
+ {
+ s0 = _mm256_set1_ps(bias0);
+ s1 = _mm256_set1_ps(bias1);
+ s2 = _mm256_set1_ps(bias2);
+ }
+ else
+ {
+ s0 = _mm256_castps128_ps256(_mm_loadu_ps(outptr0 + j));
+ s1 = _mm256_castps128_ps256(_mm_loadu_ps(outptr1 + j));
+ s2 = _mm256_castps128_ps256(_mm_loadu_ps(outptr2 + j));
+ }
+
+ s0 = _mm256_add_ps(s0, t0);
+ s1 = _mm256_add_ps(s1, t1);
+ s2 = _mm256_add_ps(s2, t2);
+
+ if( relu )
+ {
+ __m256 m0 = _mm256_cmp_ps(s0, z, _CMP_GT_OS);
+ __m256 m1 = _mm256_cmp_ps(s1, z, _CMP_GT_OS);
+ __m256 m2 = _mm256_cmp_ps(s2, z, _CMP_GT_OS);
+ s0 = _mm256_xor_ps(s0, _mm256_andnot_ps(m0, _mm256_xor_ps(_mm256_mul_ps(s0, vr0), s0)));
+ s1 = _mm256_xor_ps(s1, _mm256_andnot_ps(m1, _mm256_xor_ps(_mm256_mul_ps(s1, vr1), s1)));
+ s2 = _mm256_xor_ps(s2, _mm256_andnot_ps(m2, _mm256_xor_ps(_mm256_mul_ps(s2, vr2), s2)));
+ }
+
+ _mm_storeu_ps(outptr0 + j, _mm256_castps256_ps128(s0));
+ _mm_storeu_ps(outptr1 + j, _mm256_castps256_ps128(s1));
+ _mm_storeu_ps(outptr2 + j, _mm256_castps256_ps128(s2));
+ }
+
+ for( ; j < blockSize; j++ )
+ {
+ const float* rptr = rowbuf + j*vecsize_aligned;
+ float s00, s10, s20;
+
+ if( initOutput )
+ {
+ s00 = bias0;
+ s10 = bias1;
+ s20 = bias2;
+ }
+ else
+ {
+ s00 = outptr0[j];
+ s10 = outptr1[j];
+ s20 = outptr2[j];
+ }
+
+ for( int k = 0; k < vecsize; k++ )
+ {
+ float r0 = rptr[k];
+ s00 += wptr0[k]*r0;
+ s10 += wptr1[k]*r0;
+ s20 += wptr2[k]*r0;
+ }
+
+ if( relu )
+ {
+ s00 = s00 > 0.f ? s00 : s00*r0;
+ s10 = s10 > 0.f ? s10 : s10*r1;
+ s20 = s20 > 0.f ? s20 : s20*r2;
+ }
+
+ outptr0[j] = s00;
+ outptr1[j] = s10;
+ outptr2[j] = s20;
+ }
+ }
+ _mm256_zeroupper();
+}
+
+// dst = vec * weights^t + bias
+void fastGEMM1T( const float* vec, const float* weights,
+ size_t wstep, const float* bias,
+ float* dst, int nvecs, int vecsize )
+{
+ int i = 0;
+
+ for( ; i <= nvecs - 8; i += 8 )
+ {
+ const float* wptr = weights + i*wstep;
+ __m256 vs0 = _mm256_setzero_ps(), vs1 = _mm256_setzero_ps(),
+ vs2 = _mm256_setzero_ps(), vs3 = _mm256_setzero_ps(),
+ vs4 = _mm256_setzero_ps(), vs5 = _mm256_setzero_ps(),
+ vs6 = _mm256_setzero_ps(), vs7 = _mm256_setzero_ps();
+
+ for( int k = 0; k < vecsize; k += 8, wptr += 8 )
+ {
+ __m256 v = _mm256_load_ps(vec + k);
+
+ vs0 = _mm256_fmadd_ps(_mm256_load_ps(wptr), v, vs0);
+ vs1 = _mm256_fmadd_ps(_mm256_load_ps(wptr + wstep), v, vs1);
+ vs2 = _mm256_fmadd_ps(_mm256_load_ps(wptr + wstep*2), v, vs2);
+ vs3 = _mm256_fmadd_ps(_mm256_load_ps(wptr + wstep*3), v, vs3);
+ vs4 = _mm256_fmadd_ps(_mm256_load_ps(wptr + wstep*4), v, vs4);
+ vs5 = _mm256_fmadd_ps(_mm256_load_ps(wptr + wstep*5), v, vs5);
+ vs6 = _mm256_fmadd_ps(_mm256_load_ps(wptr + wstep*6), v, vs6);
+ vs7 = _mm256_fmadd_ps(_mm256_load_ps(wptr + wstep*7), v, vs7);
+ }
+
+ __m256 s0 = _mm256_hadd_ps(_mm256_hadd_ps(vs0, vs1), _mm256_hadd_ps(vs2, vs3));
+ __m256 s1 = _mm256_hadd_ps(_mm256_hadd_ps(vs4, vs5), _mm256_hadd_ps(vs6, vs7));
+
+ s0 = _mm256_add_ps(s0, _mm256_permute2f128_ps(s0, s0, 1));
+ s1 = _mm256_add_ps(s1, _mm256_permute2f128_ps(s1, s1, 1));
+
+ s0 = _mm256_add_ps(s0, _mm256_castps128_ps256(_mm_loadu_ps(bias + i)));
+ s1 = _mm256_add_ps(s1, _mm256_castps128_ps256(_mm_loadu_ps(bias + i + 4)));
+
+ _mm_storeu_ps(dst + i, _mm256_castps256_ps128(s0));
+ _mm_storeu_ps(dst + i + 4, _mm256_castps256_ps128(s1));
+ }
+
+ float temp = 0.f;
+ for( ; i < nvecs; i++ )
+ {
+ const float* wptr = weights + i*wstep;
+ __m256 vs0 = _mm256_setzero_ps();
+
+ for( int k = 0; k < vecsize; k += 8, wptr += 8 )
+ {
+ __m256 v = _mm256_load_ps(vec + k);
+ vs0 = _mm256_fmadd_ps(_mm256_load_ps(wptr), v, vs0);
+ }
+
+ __m256 s0 = _mm256_hadd_ps(_mm256_hadd_ps(vs0, vs0), vs0);
+ s0 = _mm256_add_ps(s0, _mm256_permute2f128_ps(s0, s0, 1));
+ _mm_store_ss(&temp, _mm256_castps256_ps128(s0));
+ dst[i] = temp + bias[i];
+ }
+
+ _mm256_zeroupper();
+}
+
+void fastGEMM( const float* aptr, size_t astep, const float* bptr,
+ size_t bstep, float* cptr, size_t cstep,
+ int ma, int na, int nb )
+{
+ int n = 0;
+ for( ; n <= nb - 16; n += 16 )
+ {
+ for( int m = 0; m < ma; m += 4 )
+ {
+ const float* aptr0 = aptr + astep*m;
+ const float* aptr1 = aptr + astep*std::min(m+1, ma-1);
+ const float* aptr2 = aptr + astep*std::min(m+2, ma-1);
+ const float* aptr3 = aptr + astep*std::min(m+3, ma-1);
+
+ float* cptr0 = cptr + cstep*m;
+ float* cptr1 = cptr + cstep*std::min(m+1, ma-1);
+ float* cptr2 = cptr + cstep*std::min(m+2, ma-1);
+ float* cptr3 = cptr + cstep*std::min(m+3, ma-1);
+
+ __m256 d00 = _mm256_setzero_ps(), d01 = _mm256_setzero_ps();
+ __m256 d10 = _mm256_setzero_ps(), d11 = _mm256_setzero_ps();
+ __m256 d20 = _mm256_setzero_ps(), d21 = _mm256_setzero_ps();
+ __m256 d30 = _mm256_setzero_ps(), d31 = _mm256_setzero_ps();
+
+ for( int k = 0; k < na; k++ )
+ {
+ __m256 a0 = _mm256_set1_ps(aptr0[k]);
+ __m256 a1 = _mm256_set1_ps(aptr1[k]);
+ __m256 a2 = _mm256_set1_ps(aptr2[k]);
+ __m256 a3 = _mm256_set1_ps(aptr3[k]);
+ __m256 b0 = _mm256_loadu_ps(bptr + k*bstep + n);
+ __m256 b1 = _mm256_loadu_ps(bptr + k*bstep + n + 8);
+ d00 = _mm256_fmadd_ps(a0, b0, d00);
+ d01 = _mm256_fmadd_ps(a0, b1, d01);
+ d10 = _mm256_fmadd_ps(a1, b0, d10);
+ d11 = _mm256_fmadd_ps(a1, b1, d11);
+ d20 = _mm256_fmadd_ps(a2, b0, d20);
+ d21 = _mm256_fmadd_ps(a2, b1, d21);
+ d30 = _mm256_fmadd_ps(a3, b0, d30);
+ d31 = _mm256_fmadd_ps(a3, b1, d31);
+ }
+
+ _mm256_storeu_ps(cptr0 + n, d00);
+ _mm256_storeu_ps(cptr0 + n + 8, d01);
+ _mm256_storeu_ps(cptr1 + n, d10);
+ _mm256_storeu_ps(cptr1 + n + 8, d11);
+ _mm256_storeu_ps(cptr2 + n, d20);
+ _mm256_storeu_ps(cptr2 + n + 8, d21);
+ _mm256_storeu_ps(cptr3 + n, d30);
+ _mm256_storeu_ps(cptr3 + n + 8, d31);
+ }
+ }
+
+ for( ; n < nb; n++ )
+ {
+ for( int m = 0; m < ma; m++ )
+ {
+ const float* aptr0 = aptr + astep*m;
+ float* cptr0 = cptr + cstep*m;
+ float d0 = 0.f;
+
+ for( int k = 0; k < na; k++ )
+ d0 += aptr0[k]*bptr[k*bstep + n];
+
+ cptr0[n] = d0;
+ }
+ }
+ _mm256_zeroupper();
+}
+
+#endif // CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
+
+CV_CPU_OPTIMIZATION_NAMESPACE_END
+}} // namespace
diff --git a/modules/dnn/src/layers/lrn_layer.cpp b/modules/dnn/src/layers/lrn_layer.cpp
new file mode 100644
index 0000000..aa7a7cb
--- /dev/null
+++ b/modules/dnn/src/layers/lrn_layer.cpp
@@ -0,0 +1,345 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include "op_halide.hpp"
+#include "opencv2/imgproc.hpp"
+#include "opencv2/dnn/shape_utils.hpp"
+#include "opencv2/core/hal/hal.hpp"
+#include <algorithm>
+
+namespace cv
+{
+namespace dnn
+{
+
+class LRNLayerImpl : public LRNLayer
+{
+public:
+ LRNLayerImpl(const LayerParams& params)
+ {
+ setParamsFrom(params);
+ type = -1;
+ String nrmType = params.get<String>("norm_region", "ACROSS_CHANNELS");
+ if (nrmType == "ACROSS_CHANNELS")
+ type = LRNLayer::CHANNEL_NRM;
+ else if (nrmType == "WITHIN_CHANNEL")
+ type = LRNLayer::SPATIAL_NRM;
+ else
+ CV_Error(Error::StsBadArg, "Unknown region type \"" + nrmType + "\"");
+
+ size = params.get<int>("local_size", 5);
+ if (size % 2 != 1 || size <= 0)
+ CV_Error(Error::StsBadArg, "LRN layer supports only positive odd values for local_size");
+
+ alpha = params.get<double>("alpha", 1);
+ beta = params.get<double>("beta", 0.75);
+ bias = params.get<double>("bias", 1);
+ normBySize = params.get<bool>("norm_by_size", true);
+ }
+
+ virtual bool supportBackend(int backendId)
+ {
+ return backendId == DNN_BACKEND_DEFAULT ||
+ backendId == DNN_BACKEND_HALIDE && haveHalide();
+ }
+
+ void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ CV_Assert(inputs.size() == outputs.size());
+ for (int i = 0; i < inputs.size(); i++)
+ {
+ CV_Assert(inputs[i]->dims == 4);
+
+ Mat &src = *inputs[i];
+ Mat &dst = outputs[i];
+
+ switch (type)
+ {
+ case CHANNEL_NRM:
+ channelNormalization(src, dst);
+ break;
+ case SPATIAL_NRM:
+ spatialNormalization(src, dst);
+ break;
+ default:
+ CV_Error(Error::StsNotImplemented, "Unimplemented mode of LRN layer");
+ break;
+ }
+ }
+ }
+
+ class ChannelLRN : public ParallelLoopBody
+ {
+ public:
+ ChannelLRN(const float* src, float* dst, int channels, int ksize,
+ float alpha1, float bias1, float beta1,
+ size_t planeSize, int nsamples, int nstripes)
+ {
+ src_ = src; dst_ = dst;
+ channels_ = channels;
+ ksize_ = ksize;
+ alpha1_ = alpha1; bias1_ = bias1; beta1_ = beta1;
+ planeSize_ = planeSize; nsamples_ = nsamples; nstripes_ = nstripes;
+ }
+
+ void operator()(const Range& r) const
+ {
+ int nsamples = nsamples_, nstripes = nstripes_;
+ size_t planeSize = planeSize_, planeSize_n = planeSize * nsamples;
+ size_t elemsPerStripe = (planeSize_n + nstripes - 1)/nstripes;
+ size_t rstart = r.start*elemsPerStripe;
+ size_t rend = r.end == nstripes ? planeSize_n : r.end*elemsPerStripe;
+ rstart = std::min(rstart, planeSize_n);
+ rend = std::min(rend, planeSize_n);
+ float alpha1 = alpha1_, bias1 = bias1_, beta1 = beta1_;
+ int k, channels = channels_, ksize = ksize_;
+
+ AutoBuffer<float> buf_((channels + ksize*2 + 4)*2);
+ float* acc = (float*)buf_;
+ float* buf = acc + channels + ksize + 1;
+ for( k = 0; k <= ksize; k++ )
+ buf[-k-1] = buf[channels + k] = 0.f;
+
+ for( size_t ofs = rstart; ofs < rend; )
+ {
+ int sampleIdx = (int)(ofs/planeSize);
+ if( sampleIdx >= nsamples )
+ break;
+ size_t ofs0 = ofs - sampleIdx*planeSize;
+ size_t ofs1 = std::min(planeSize - ofs0, rend - ofs) + ofs;
+ const float* src = src_ + sampleIdx*planeSize*channels + ofs0;
+ float* dst = dst_ + sampleIdx*planeSize*channels + ofs0;
+
+ for( ; ofs < ofs1; ofs++, src++, dst++ )
+ {
+ for( k = 0; k < channels; k++ )
+ buf[k] = src[k*planeSize];
+ float s = 0;
+ for( k = 0; k < ksize; k++ )
+ s += buf[k]*buf[k];
+ for( k = 0; k < channels; k++ )
+ {
+ float x1 = buf[k + ksize];
+ float x0 = buf[k - ksize - 1];
+ s = std::max(s + (x1 + x0)*(x1 - x0), 0.f);
+ acc[k] = (float)(alpha1*s + bias1);
+ }
+
+ hal::log32f(acc, acc, channels);
+ for( k = 0; k < channels; k++ )
+ acc[k] *= beta1;
+ hal::exp32f(acc, acc, channels);
+
+ for( k = 0; k < channels; k++ )
+ dst[k*planeSize] = buf[k]*acc[k];
+ }
+ }
+ }
+
+ const float* src_;
+ float* dst_;
+ float alpha1_, bias1_, beta1_;
+ size_t planeSize_;
+ int channels_, ksize_, nsamples_, nstripes_;
+ };
+
+ void channelNormalization(Mat &srcBlob, Mat &dstBlob)
+ {
+ int num = srcBlob.size[0];
+ int channels = srcBlob.size[1];
+ int ksize = (size - 1) / 2;
+ int sizeNormFactor = normBySize ? size : 1;
+ size_t planeSize = srcBlob.size[2]*srcBlob.size[3];
+
+ int nstripes = std::max(getNumThreads(), 1);
+
+ ChannelLRN clrn(srcBlob.ptr<float>(), dstBlob.ptr<float>(), channels,
+ ksize, alpha/sizeNormFactor, bias, -beta, planeSize, num, nstripes);
+ parallel_for_(Range(0, nstripes), clrn, nstripes);
+ }
+
+ void sqrBoxFilter_(const Mat &src, Mat &dst)
+ {
+ Mat srcRawWrapper(src.rows, src.cols, src.type(), src.data, src.step[0]);
+ cv::sqrBoxFilter(srcRawWrapper, dst, dst.depth(), Size(size, size), Point(-1, -1), false, BORDER_CONSTANT);
+ }
+
+ void spatialNormalization(Mat &srcBlob, Mat &dstBlob)
+ {
+ int num = srcBlob.size[0];
+ int channels = srcBlob.size[1];
+ int sizeNormFactor = normBySize ? size*size : 1;
+
+ Mat srcMat = srcBlob;
+ Mat dstMat = dstBlob;
+
+ for (int n = 0; n < num; n++)
+ {
+ for (int cn = 0; cn < channels; cn++)
+ {
+ Mat src = getPlane(srcMat, n, cn);
+ Mat dst = getPlane(dstMat, n, cn);
+
+ sqrBoxFilter_(src, dst);
+
+ dst.convertTo(dst, dst.type(), alpha/sizeNormFactor, bias);
+ cv::pow(dst, beta, dst);
+ cv::divide(src, dst, dst);
+ }
+ }
+ }
+
+ virtual Ptr<BackendNode> initHalide(const std::vector<Ptr<BackendWrapper> > &inputs)
+ {
+#ifdef HAVE_HALIDE
+ float alphaSize = alpha;
+ if (normBySize)
+ alphaSize /= (type == CHANNEL_NRM ? size : size * size);
+ int width, height, channels, numImgs;
+ Halide::Buffer<float> inputBuffer = halideBuffer(inputs[0]);
+ getCanonicalSize(inputBuffer, &width, &height, &channels, &numImgs);
+
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ Halide::Func top = (name.empty() ? Halide::Func() : Halide::Func(name));
+ Halide::Func padded_sq(name + "_padded_sq");
+ Halide::Func sq("sq");
+ sq(x, y, c, n) = inputBuffer(x, y, c, n) * inputBuffer(x, y, c, n);
+
+ Halide::Func bounded =
+ Halide::BoundaryConditions::constant_exterior(sq, 0, 0, width,
+ 0, height,
+ 0, channels,
+ 0, numImgs);
+ padded_sq(x, y, c, n) = bounded(x, y, c, n);
+
+ Halide::Expr base;
+ if (type == CHANNEL_NRM)
+ {
+ Halide::RDom r((1 - size) / 2, size);
+ base = alphaSize * sum(padded_sq(x, y, c + r, n));
+ }
+ else // SPATIAL_NRM
+ {
+ Halide::RDom r((1 - size) / 2, size, (1 - size) / 2, size);
+ base = alphaSize * sum(padded_sq(x + r.x, y + r.y, c, n));
+ }
+ base += static_cast<float>(bias);
+ top(x, y, c, n) = inputBuffer(x, y, c, n) / pow(base, beta);
+ return Ptr<BackendNode>(new HalideBackendNode({ padded_sq, top }));
+#endif // HAVE_HALIDE
+ return Ptr<BackendNode>();
+ }
+
+ virtual void applyHalideScheduler(Ptr<BackendNode>& node,
+ const std::vector<Mat*> &inputs,
+ const std::vector<Mat> &outputs,
+ int targetId) const
+ {
+#ifdef HAVE_HALIDE
+ if (targetId != DNN_TARGET_CPU)
+ {
+ Layer::applyHalideScheduler(node, inputs, outputs, targetId);
+ return;
+ }
+ int outW, outH, outC, outN;
+ getCanonicalSize(outputs[0].size, &outW, &outH, &outC, &outN);
+
+ Halide::Var x("x"), y("y"), c("c"), n("n"), yo("yo"), yi("yi"), tile("tile");
+ Halide::Func& top = node.dynamicCast<HalideBackendNode>()->funcs[1];
+ Halide::Func& padded_sq = node.dynamicCast<HalideBackendNode>()->funcs[0];
+
+ if (outW < 8 || outH <= 2)
+ return;
+
+ top.reorder(x, c, y, n)
+ .split(y, yo, yi, 2)
+ .fuse(yo, n, tile)
+ .parallel(tile)
+ .unroll(yi)
+ .vectorize(x, 8);
+ padded_sq.store_at(top, tile)
+ .compute_at(top, yi);
+#endif // HAVE_HALIDE
+ }
+
+ virtual int64 getFLOPS(const std::vector<MatShape> &inputs,
+ const std::vector<MatShape> &outputs) const
+ {
+ (void)outputs; // suppress unused variable warning
+ CV_Assert(inputs.size() > 0);
+ long flops = 0;
+
+ for(int i = 0; i < inputs.size(); i++)
+ {
+ if (type == CHANNEL_NRM)
+ {
+ int channels = inputs[i][1];
+ int ksize = (size - 1) / 2;
+
+ flops += inputs[i][0]*(std::min(ksize, channels)*2*total(inputs[i], 2) + channels*4*total(inputs[i], 2));
+
+ if (ksize < channels)
+ {
+ flops += (size + 2*(channels - size))*total(inputs[i], 2);
+ }
+ }
+ else
+ {
+ flops += total(inputs[i])*(2*size*size + 2);
+ }
+ }
+ return flops;
+ }
+};
+
+Ptr<LRNLayer> LRNLayer::create(const LayerParams& params)
+{
+ return Ptr<LRNLayer>(new LRNLayerImpl(params));
+}
+
+}
+}
diff --git a/modules/dnn/src/layers/max_unpooling_layer.cpp b/modules/dnn/src/layers/max_unpooling_layer.cpp
new file mode 100644
index 0000000..9950718
--- /dev/null
+++ b/modules/dnn/src/layers/max_unpooling_layer.cpp
@@ -0,0 +1,131 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+// Copyright (C) 2016, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+
+/*
+Implementation of Batch Normalization layer.
+*/
+
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include "op_halide.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv
+{
+namespace dnn
+{
+
+class MaxUnpoolLayerImpl : public MaxUnpoolLayer
+{
+public:
+ MaxUnpoolLayerImpl(const LayerParams& params)
+ {
+ setParamsFrom(params);
+ poolKernel = Size(params.get<int>("pool_k_w"), params.get<int>("pool_k_h"));
+ poolPad = Size(params.get<int>("pool_pad_w"), params.get<int>("pool_pad_h"));
+ poolStride = Size(params.get<int>("pool_stride_w"), params.get<int>("pool_stride_h"));
+ }
+
+ virtual bool supportBackend(int backendId)
+ {
+ return backendId == DNN_BACKEND_DEFAULT ||
+ backendId == DNN_BACKEND_HALIDE && haveHalide() &&
+ !poolPad.width && !poolPad.height;
+ }
+
+ bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+ {
+ CV_Assert(inputs.size() == 2);
+ CV_Assert(total(inputs[0]) == total(inputs[1]));
+
+ MatShape outShape = inputs[0];
+ outShape[2] = (outShape[2] - 1) * poolStride.height + poolKernel.height - 2 * poolPad.height;
+ outShape[3] = (outShape[3] - 1) * poolStride.width + poolKernel.width - 2 * poolPad.width;
+
+ outputs.clear();
+ outputs.push_back(outShape);
+
+ return false;
+ }
+
+ void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ CV_Assert(inputs.size() == 2);
+ Mat& input = *inputs[0];
+ Mat& indices = *inputs[1];
+
+ CV_Assert(input.total() == indices.total());
+ CV_Assert(input.size[0] == 1);
+ CV_Assert(input.isContinuous());
+
+ for(int i_n = 0; i_n < outputs.size(); i_n++)
+ {
+ Mat& outBlob = outputs[i_n];
+ outBlob.setTo(0);
+ CV_Assert(input.size[1] == outBlob.size[1]);
+ int outPlaneTotal = outBlob.size[2]*outBlob.size[3];
+
+ for (int i_c = 0; i_c < input.size[1]; i_c++)
+ {
+ Mat outPlane = getPlane(outBlob, 0, i_c);
+ int wh_area = input.size[2]*input.size[3];
+ const float* inptr = input.ptr<float>(0, i_c);
+ const float* idxptr = indices.ptr<float>(0, i_c);
+ float* outptr = outPlane.ptr<float>();
+
+ for(int i_wh = 0; i_wh < wh_area; i_wh++)
+ {
+ int index = idxptr[i_wh];
+ CV_Assert(0 <= index && index < outPlaneTotal);
+ outptr[index] = inptr[i_wh];
+ }
+ }
+ }
+ }
+
+ virtual Ptr<BackendNode> initHalide(const std::vector<Ptr<BackendWrapper> > &input)
+ {
+#ifdef HAVE_HALIDE
+ // Meaningless operation if false because if kernel > stride
+ // it is not deterministic and if kernel < stride we just
+ // skip a part of input data (you'd better change your model).
+ if (poolKernel.width != poolStride.width ||
+ poolKernel.height != poolStride.height)
+ CV_Error(cv::Error::StsNotImplemented,
+ "Halide backend for maximum unpooling "
+ "is not support cases when kernel != stride");
+
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ Halide::Func top = (name.empty() ? Halide::Func() : Halide::Func(name));
+ Halide::Buffer<float> inputBuffer = halideBuffer(input[0]);
+ Halide::Buffer<float> indices = halideBuffer(input[1]);
+
+ Halide::Expr pooledX = x / poolKernel.width;
+ Halide::Expr pooledY = y / poolKernel.height;
+
+ const int outW = inputBuffer.width() * poolKernel.width;
+ top(x, y, c, n) = select(y * outW + x == indices(pooledX, pooledY, c, n),
+ inputBuffer(pooledX, pooledY, c, n), 0.0f);
+ return Ptr<BackendNode>(new HalideBackendNode(top));
+#endif // HAVE_HALIDE
+ return Ptr<BackendNode>();
+ }
+};
+
+Ptr<MaxUnpoolLayer> MaxUnpoolLayer::create(const LayerParams& params)
+{
+ return Ptr<MaxUnpoolLayer>(new MaxUnpoolLayerImpl(params));
+}
+
+}
+}
diff --git a/modules/dnn/src/layers/mvn_layer.cpp b/modules/dnn/src/layers/mvn_layer.cpp
new file mode 100644
index 0000000..536a21f
--- /dev/null
+++ b/modules/dnn/src/layers/mvn_layer.cpp
@@ -0,0 +1,112 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv
+{
+namespace dnn
+{
+
+class MVNLayerImpl : public MVNLayer
+{
+public:
+ MVNLayerImpl(const LayerParams& params)
+ {
+ setParamsFrom(params);
+ normVariance = params.get<bool>("normalize_variance", true);
+ acrossChannels = params.get<bool>("across_channels", false);
+ eps = params.get<double>("eps", 1e-9);
+ }
+
+ void forward(std::vector<Mat *> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ for (size_t inpIdx = 0; inpIdx < inputs.size(); inpIdx++)
+ {
+ Mat &inpBlob = *inputs[inpIdx];
+ Mat &outBlob = outputs[inpIdx];
+
+ int splitDim = (acrossChannels) ? 1 : 2;
+ int i, newRows = 1;
+ for( i = 0; i < splitDim; i++ )
+ newRows *= inpBlob.size[i];
+ Mat inpMat = inpBlob.reshape(1, newRows);
+ Mat outMat = outBlob.reshape(1, newRows);
+
+ Scalar mean, dev;
+ for ( i = 0; i < newRows; i++)
+ {
+ Mat inpRow = inpMat.row(i);
+ Mat outRow = outMat.row(i);
+
+ cv::meanStdDev(inpRow, mean, (normVariance) ? dev : noArray());
+ double alpha = (normVariance) ? 1/(eps + dev[0]) : 1;
+ inpRow.convertTo(outRow, outRow.type(), alpha, -mean[0] * alpha);
+ }
+ }
+ }
+
+ virtual int64 getFLOPS(const std::vector<MatShape> &inputs,
+ const std::vector<MatShape> &outputs) const
+ {
+ (void)outputs; // suppress unused variable warning
+ long flops = 0;
+ for(int i = 0; i < inputs.size(); i++)
+ {
+ flops += 6*total(inputs[i]) + 3*total(inputs[i], 0, normVariance ? 2 : 1);
+ }
+ return flops;
+ }
+};
+
+Ptr<MVNLayer> MVNLayer::create(const LayerParams& params)
+{
+ return Ptr<MVNLayer>(new MVNLayerImpl(params));
+}
+
+}
+}
diff --git a/modules/dnn/src/layers/normalize_bbox_layer.cpp b/modules/dnn/src/layers/normalize_bbox_layer.cpp
new file mode 100644
index 0000000..43acd35
--- /dev/null
+++ b/modules/dnn/src/layers/normalize_bbox_layer.cpp
@@ -0,0 +1,227 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+
+#include <float.h>
+#include <algorithm>
+
+namespace cv
+{
+namespace dnn
+{
+
+namespace
+{
+ const std::string layerName = "NormalizeBBox";
+}
+
+class NormalizeBBoxLayerImpl : public NormalizeBBoxLayer
+{
+ float _eps;
+ bool _across_spatial;
+ bool _channel_shared;
+public:
+ bool getParameterDict(const LayerParams ¶ms,
+ const std::string ¶meterName,
+ DictValue& result)
+ {
+ if (!params.has(parameterName))
+ {
+ return false;
+ }
+
+ result = params.get(parameterName);
+ return true;
+ }
+
+ template<typename T>
+ T getParameter(const LayerParams ¶ms,
+ const std::string ¶meterName,
+ const size_t &idx=0,
+ const bool required=true,
+ const T& defaultValue=T())
+ {
+ DictValue dictValue;
+ bool success = getParameterDict(params, parameterName, dictValue);
+ if(!success)
+ {
+ if(required)
+ {
+ std::string message = layerName;
+ message += " layer parameter does not contain ";
+ message += parameterName;
+ message += " parameter.";
+ CV_Error(Error::StsBadArg, message);
+ }
+ else
+ {
+ return defaultValue;
+ }
+ }
+ return dictValue.get<T>(idx);
+ }
+
+ NormalizeBBoxLayerImpl(const LayerParams ¶ms)
+ {
+ _eps = getParameter<float>(params, "eps", 0, false, 1e-10f);
+ _across_spatial = getParameter<bool>(params, "across_spatial");
+ _channel_shared = getParameter<bool>(params, "channel_shared");
+ setParamsFrom(params);
+ }
+
+ void checkInputs(const std::vector<Mat*> &inputs)
+ {
+ CV_Assert(inputs.size() > 0);
+ CV_Assert(inputs[0]->dims == 4 && inputs[0]->type() == CV_32F);
+ for (size_t i = 1; i < inputs.size(); i++)
+ {
+ CV_Assert(inputs[i]->dims == 4 && inputs[i]->type() == CV_32F);
+ CV_Assert(inputs[i]->size == inputs[0]->size);
+ }
+ CV_Assert(inputs[0]->dims > 2);
+ }
+
+ bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+ {
+ bool inplace = Layer::getMemoryShapes(inputs, requiredOutputs, outputs, internals);
+ size_t channels = inputs[0][1];
+ size_t rows = inputs[0][2];
+ size_t cols = inputs[0][3];
+ size_t channelSize = rows * cols;
+
+ internals.assign(1, shape(channels, channelSize));
+ internals.push_back(shape(channels, 1));
+ internals.push_back(shape(1, channelSize));
+
+ return inplace;
+ }
+
+ void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ checkInputs(inputs);
+
+ Mat& buffer = internals[0], sumChannelMultiplier = internals[1],
+ sumSpatialMultiplier = internals[2];
+
+ sumChannelMultiplier.setTo(1.0);
+ sumSpatialMultiplier.setTo(1.0);
+
+ const Mat& inp0 = *inputs[0];
+ size_t num = inp0.size[0];
+ size_t channels = inp0.size[1];
+ size_t channelSize = inp0.size[2] * inp0.size[3];
+
+ Mat zeroBuffer(channels, channelSize, CV_32F, Scalar(0));
+ Mat absDiff;
+ Mat scale = blobs[0];
+ for (size_t j = 0; j < inputs.size(); j++)
+ {
+ for (size_t n = 0; n < num; ++n)
+ {
+ Mat src = Mat(channels, channelSize, CV_32F, inputs[j]->ptr<float>(n));
+ Mat dst = Mat(channels, channelSize, CV_32F, outputs[j].ptr<float>(n));
+
+ buffer = src.mul(src);
+
+ if (_across_spatial)
+ {
+ absdiff(buffer, zeroBuffer, absDiff);
+
+ // add eps to avoid overflow
+ double absSum = sum(absDiff)[0] + _eps;
+
+ float norm = sqrt(absSum);
+ dst = src / norm;
+ }
+ else
+ {
+ Mat norm(channelSize, 1, buffer.type()); // 1 x channelSize
+
+ // (_channels x channelSize)T * _channels x 1 -> channelSize x 1
+ gemm(buffer, sumChannelMultiplier, 1, norm, 0, norm, GEMM_1_T);
+
+ // compute norm
+ pow(norm, 0.5f, norm);
+
+ // scale the layer
+ // _channels x 1 * (channelSize x 1)T -> _channels x channelSize
+ gemm(sumChannelMultiplier, norm, 1, buffer, 0, buffer, GEMM_2_T);
+
+ dst = src / buffer;
+ }
+
+ // scale the output
+ if (_channel_shared)
+ {
+ // _scale: 1 x 1
+ dst *= scale.at<float>(0, 0);
+ }
+ else
+ {
+ // _scale: _channels x 1
+ // _channels x 1 * 1 x channelSize -> _channels x channelSize
+ gemm(scale, sumSpatialMultiplier, 1, buffer, 0, buffer);
+
+ dst = dst.mul(buffer);
+ }
+ }
+ }
+ }
+
+};
+
+
+Ptr<NormalizeBBoxLayer> NormalizeBBoxLayer::create(const LayerParams ¶ms)
+{
+ return Ptr<NormalizeBBoxLayer>(new NormalizeBBoxLayerImpl(params));
+}
+
+}
+}
diff --git a/modules/dnn/src/layers/padding_layer.cpp b/modules/dnn/src/layers/padding_layer.cpp
new file mode 100644
index 0000000..f5a6a52
--- /dev/null
+++ b/modules/dnn/src/layers/padding_layer.cpp
@@ -0,0 +1,134 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+// Copyright (C) 2016, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+
+/*
+Implementation of padding layer, which adds paddings to input blob.
+*/
+
+#include "../precomp.hpp"
+#include "op_halide.hpp"
+#include <vector>
+
+namespace cv
+{
+namespace dnn
+{
+
+class PaddingLayerImpl : public PaddingLayer
+{
+public:
+ PaddingLayerImpl(const LayerParams ¶ms)
+ {
+ setParamsFrom(params);
+ paddingDim = params.get<int>("padding_dim");
+ padding = params.get<int>("padding");
+ inputDims = params.get<int>("input_dims", 0);
+ index = params.get<int>("index", 0);
+ paddingValue = params.get<double>("value", 0);
+
+ if(paddingDim < 0 || padding < 0)
+ CV_Error(cv::Error::StsNotImplemented, "Negative padding and dim aren't supported");
+ }
+
+ bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+ {
+ outputs.clear();
+ for(int i = 0; i < inputs.size(); i++)
+ {
+ MatShape shape = inputs[i];
+ int dim = getPadDim(shape);
+ CV_Assert(dim < shape.size());
+
+ shape[dim] += padding;
+ outputs.push_back(shape);
+ }
+
+ return false;
+ }
+
+ virtual bool supportBackend(int backendId)
+ {
+ return backendId == DNN_BACKEND_DEFAULT ||
+ backendId == DNN_BACKEND_HALIDE && haveHalide();
+ }
+
+ void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ for(int i = 0; i < inputs.size(); i++)
+ {
+ outputs[i] = paddingValue;
+ const Mat& inp = *inputs[i];
+ Mat& out = outputs[i];
+ int dims = inp.dims;
+ MatShape inShape(inp.size.p, inp.size.p + dims);
+ MatShape outShape(out.size.p, out.size.p + dims);
+ int dim = getPadDim(inShape);
+
+ int actualIndex = index;
+ if(index == 0)
+ actualIndex = inShape[dim];
+
+ std::vector<std::pair<Range, Range> > srcDstRanges;
+ srcDstRanges.push_back(std::make_pair(Range(0, actualIndex), Range(0, actualIndex)));
+ srcDstRanges.push_back(std::make_pair(Range(actualIndex, inShape[dim]),
+ Range(actualIndex + padding, outShape[dim])));
+
+ std::vector<Range> srcRanges(dims, Range::all()), dstRanges = srcRanges;
+
+ for(int j = 0; j < srcDstRanges.size(); j++)
+ {
+ if(!srcDstRanges[j].first.empty())
+ {
+ srcRanges[dim] = srcDstRanges[j].first;
+ dstRanges[dim] = srcDstRanges[j].second;
+ Mat dst = out(&dstRanges[0]);
+ Mat src = inp(&srcRanges[0]).clone();
+ src.copyTo(dst);
+ }
+ }
+ }
+ }
+
+ int getPadDim(const MatShape& shape) const
+ {
+ return inputDims > 0 && (int)shape.size() > inputDims ? paddingDim + 1 : paddingDim;
+ }
+
+ virtual Ptr<BackendNode> initHalide(const std::vector<Ptr<BackendWrapper> > &inputs)
+ {
+#ifdef HAVE_HALIDE
+ int inW, inH, inC, inN;
+ Halide::Buffer<float> inputBuffer = halideBuffer(inputs[0]);
+ getCanonicalSize(inputBuffer, &inW, &inH, &inC, &inN);
+
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ Halide::Func top = (name.empty() ? Halide::Func() : Halide::Func(name));
+ Halide::Func padded =
+ Halide::BoundaryConditions::constant_exterior(inputBuffer, paddingValue);
+ top(x, y, c, n) = padded(x, y, c, n);
+ return Ptr<BackendNode>(new HalideBackendNode(top));
+#endif // HAVE_HALIDE
+ return Ptr<BackendNode>();
+ }
+
+ int paddingDim, padding, inputDims, index;
+ float paddingValue;
+};
+
+Ptr<PaddingLayer> PaddingLayer::create(const LayerParams ¶ms)
+{
+ return Ptr<PaddingLayer>(new PaddingLayerImpl(params));
+}
+
+}
+}
diff --git a/modules/dnn/src/layers/permute_layer.cpp b/modules/dnn/src/layers/permute_layer.cpp
new file mode 100644
index 0000000..56a2782
--- /dev/null
+++ b/modules/dnn/src/layers/permute_layer.cpp
@@ -0,0 +1,321 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include <float.h>
+#include <algorithm>
+
+namespace cv
+{
+namespace dnn
+{
+class PermuteLayerImpl : public PermuteLayer
+{
+public:
+ void checkCurrentOrder(int currentOrder)
+ {
+ if(currentOrder < 0 || currentOrder > 3)
+ {
+ CV_Error(
+ Error::StsBadArg,
+ "Orders of dimensions in Permute layer parameter"
+ "must be in [0...3] interval");
+ }
+
+ if(std::find(_order.begin(), _order.end(), currentOrder) != _order.end())
+ {
+ CV_Error(Error::StsBadArg,
+ "Permute layer parameter contains duplicated orders.");
+ }
+ }
+
+ void checkNeedForPermutation()
+ {
+ _needsPermute = false;
+ for (size_t i = 0; i < _numAxes; ++i)
+ {
+ if (_order[i] != i)
+ {
+ _needsPermute = true;
+ break;
+ }
+ }
+ }
+
+ PermuteLayerImpl(const LayerParams ¶ms)
+ : _count(0), _needsPermute(false), _numAxes(0)
+ {
+ if (!params.has("order"))
+ {
+ return;
+ }
+
+ DictValue paramOrder = params.get("order");
+ if(paramOrder.size() > 4)
+ {
+ CV_Error(
+ Error::StsBadArg,
+ "Too many (> 4) orders of dimensions in Permute layer");
+ }
+
+ _numAxes = paramOrder.size();
+
+ for (size_t i = 0; i < _numAxes; i++)
+ {
+ int currentOrder = paramOrder.get<int>(i);
+ checkCurrentOrder(currentOrder);
+ _order.push_back(currentOrder);
+ }
+
+ setParamsFrom(params);
+ checkNeedForPermutation();
+ }
+
+ bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+ {
+ if(!_needsPermute)
+ return true;
+
+ CV_Assert(inputs.size() > 0);
+ CV_Assert((int)_numAxes == inputs[0].size());
+
+ MatShape shapeBefore = inputs[0], shapeAfter;
+ for (size_t i = 0; i < _numAxes; i++)
+ {
+ shapeAfter.push_back(shapeBefore[_order[i]]);
+ }
+
+ outputs.clear();
+
+ for (size_t i = 0; i < inputs.size(); i++)
+ {
+ CV_Assert(inputs[i][2] == shapeBefore[2] && inputs[i][3] == shapeBefore[3]);
+ CV_Assert(total(inputs[i]) == total(shapeAfter));
+ outputs.push_back(shapeAfter);
+ }
+
+ return false;
+ }
+
+ void computeStrides(const MatShape &shapeBefore, const MatShape &shapeAfter)
+ {
+ _oldStride.resize(_numAxes);
+ _newStride.resize(_numAxes);
+
+ _oldStride[_numAxes - 1] = 1;
+ _newStride[_numAxes - 1] = 1;
+
+ for(int i = _numAxes - 2; i >= 0; i--)
+ {
+ _oldStride[i] = _oldStride[i + 1] * shapeBefore[i + 1];
+ _newStride[i] = _newStride[i + 1] * shapeAfter[i + 1];
+ }
+
+ _count = _oldStride[0] * shapeBefore[0];
+ }
+
+ void finalize(const std::vector<Mat*> &inputs, std::vector<Mat> &outputs)
+ {
+ if(!_needsPermute)
+ {
+ return;
+ }
+
+ CV_Assert(inputs.size() > 0);
+ const Mat& inp0 = *inputs[0];
+ CV_Assert((int)_numAxes == inp0.dims);
+
+ computeStrides(shape(*inputs[0]), shape(outputs[0]));
+ }
+
+ class PermuteInvoker : public ParallelLoopBody
+ {
+ public:
+ const Mat* inp;
+ Mat* out;
+ const std::vector<size_t>* order;
+ int nstripes;
+
+ static void run(const Mat& inp, Mat& out, const std::vector<size_t>& order, int nstripes)
+ {
+ PermuteInvoker p;
+ p.inp = &inp;
+ p.out = &out;
+ p.order = ℴ
+ p.nstripes = nstripes;
+
+ CV_Assert( out.size[0] == inp.size[order[0]] &&
+ out.size[1] == inp.size[order[1]] &&
+ out.size[2] == inp.size[order[2]] &&
+ out.size[3] == inp.size[order[3]]);
+
+ parallel_for_(Range(0, nstripes), p, nstripes);
+ }
+
+ PermuteInvoker() : inp(0), out(0), order(0), nstripes(0) {}
+
+ void operator()(const Range& r) const
+ {
+ int n0 = out->size[0], n1 = out->size[1], n2 = out->size[2], n3 = out->size[3];
+
+ size_t orows = (size_t)n0*n1*n2;
+ size_t stripeSize = (orows + nstripes - 1)/nstripes;
+ size_t stripeStart = r.start*stripeSize;
+ size_t stripeEnd = std::min(r.end*stripeSize, orows);
+
+ const size_t esz = sizeof(float);
+ size_t ostep0 = out->step[0]/esz, ostep1 = out->step[1]/esz, ostep2 = out->step[2]/esz;
+ const size_t* ord = &order->at(0);
+ size_t istep0 = inp->step[ord[0]]/esz, istep1 = inp->step[ord[1]]/esz,
+ istep2 = inp->step[ord[2]]/esz, istep3 = inp->step[ord[3]]/esz;
+
+ size_t val = stripeStart;
+ int i2 = (int)(val % n2);
+ val /= n2;
+ int i1 = (int)(val % n1);
+ int i0 = (int)(val / n1);
+
+ const float* inptr_orig = inp->ptr<float>();
+ float* outptr_orig = out->ptr<float>();
+
+ for( size_t ofs = stripeStart; ofs < stripeEnd; ofs++ )
+ {
+ const float* inptr = inptr_orig + i0*istep0 + i1*istep1 + i2*istep2;
+ float* outptr = outptr_orig + i0*ostep0 + i1*ostep1 + i2*ostep2;
+
+ for( int i3 = 0; i3 < n3; i3++ )
+ outptr[i3] = inptr[i3*istep3];
+
+ if( ++i2 >= n2 )
+ {
+ i2 = 0;
+ if( ++i1 >= n1 )
+ {
+ i1 = 0;
+ if( ++i0 >= n0 )
+ break;
+ }
+ }
+ }
+ }
+ };
+
+ void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ size_t k, ninputs = inputs.size();
+ if(!_needsPermute)
+ {
+ for (k = 0; k < ninputs; k++)
+ outputs[k] = *inputs[k];
+ }
+ else
+ {
+ size_t i, j, count = _count, numAxes = _numAxes;
+ const size_t* newStride = &_newStride[0];
+ const size_t* oldStride = &_oldStride[0];
+ const size_t* order = &_order[0];
+
+ for (k = 0; k < ninputs; k++)
+ {
+ const Mat& inp = *inputs[k];
+ Mat& out = outputs[k];
+
+ CV_Assert(inp.dims == numAxes && inp.size == inputs[0]->size);
+ CV_Assert(out.dims == numAxes && out.size == outputs[0].size);
+
+ CV_Assert(inp.isContinuous() && out.isContinuous());
+ CV_Assert(inp.type() == CV_32F && out.type() == CV_32F);
+
+ if( numAxes == 4 )
+ {
+ int nstripes = getNumThreads();
+ PermuteInvoker::run(inp, out, _order, nstripes);
+ }
+ else
+ {
+ const float *srcData = inp.ptr<float>();
+ float *dstData = out.ptr<float>();
+
+ for (i = 0; i < count; ++i)
+ {
+ size_t oldPosition = 0;
+ size_t newPosition = i;
+
+ for (j = 0; j < numAxes; ++j)
+ {
+ oldPosition += (newPosition / newStride[j]) * oldStride[order[j]];
+ newPosition %= newStride[j];
+ }
+ dstData[i] = srcData[oldPosition];
+ }
+ }
+ }
+ }
+ }
+
+ size_t _count;
+ std::vector<size_t> _order;
+
+ std::vector<int> _oldDimensionSize;
+ std::vector<int> _newDimensionSize;
+
+ std::vector<size_t> _oldStride;
+ std::vector<size_t> _newStride;
+ bool _needsPermute;
+
+ size_t _numAxes;
+};
+
+Ptr<PermuteLayer> PermuteLayer::create(const LayerParams ¶ms)
+{
+ return Ptr<PermuteLayer>(new PermuteLayerImpl(params));
+}
+
+}
+}
diff --git a/modules/dnn/src/layers/pooling_layer.cpp b/modules/dnn/src/layers/pooling_layer.cpp
new file mode 100644
index 0000000..ce99552
--- /dev/null
+++ b/modules/dnn/src/layers/pooling_layer.cpp
@@ -0,0 +1,641 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include "opencv2/core/hal/intrin.hpp"
+#include "op_halide.hpp"
+#include <float.h>
+#include <algorithm>
+using std::max;
+using std::min;
+
+namespace cv
+{
+namespace dnn
+{
+
+//TODO: add ceil_mode param
+class PoolingLayerImpl : public PoolingLayer
+{
+public:
+ PoolingLayerImpl(const LayerParams& params)
+ {
+ type = PoolingLayer::MAX;
+ computeMaxIdx = true;
+
+ if (params.has("pool"))
+ {
+ String pool = params.get<String>("pool").toLowerCase();
+ if (pool == "max")
+ type = PoolingLayer::MAX;
+ else if (pool == "ave")
+ type = PoolingLayer::AVE;
+ else if (pool == "stochastic")
+ type = PoolingLayer::STOCHASTIC;
+ else
+ CV_Error(Error::StsBadArg, "Unknown pooling type \"" + pool + "\"");
+ }
+
+ getPoolingKernelParams(params, kernel.height, kernel.width, globalPooling,
+ pad.height, pad.width, stride.height, stride.width, padMode);
+ setParamsFrom(params);
+ }
+
+ void finalize(const std::vector<Mat*> &inputs, std::vector<Mat> &outputs)
+ {
+ CV_Assert(inputs.size() == 1);
+
+ cv::Size inp(inputs[0]->size[3], inputs[0]->size[2]),
+ out(outputs[0].size[3], outputs[0].size[2]);
+
+ if(globalPooling)
+ {
+ kernel = inp;
+ }
+
+ getConvPoolPaddings(inp, out, kernel, stride, padMode, pad);
+ }
+
+ virtual bool supportBackend(int backendId)
+ {
+ return backendId == DNN_BACKEND_DEFAULT ||
+ backendId == DNN_BACKEND_HALIDE && haveHalide() &&
+ (type == PoolingLayer::MAX ||
+ type == PoolingLayer::AVE && !pad.width && !pad.height);
+ }
+
+ void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ for (size_t ii = 0; ii < inputs.size(); ii++)
+ {
+ switch (type)
+ {
+ case MAX:
+ maxPooling(*inputs[ii], outputs[2 * ii], outputs[2 * ii + 1]);
+ break;
+ case AVE:
+ avePooling(*inputs[ii], outputs[ii]);
+ break;
+ default:
+ CV_Error(Error::StsNotImplemented, "Not implemented");
+ break;
+ }
+ }
+ }
+
+ virtual Ptr<BackendNode> initHalide(const std::vector<Ptr<BackendWrapper> > &inputs)
+ {
+ if (type == PoolingLayer::MAX)
+ return initMaxPoolingHalide(inputs);
+ else if (type == PoolingLayer::AVE)
+ return initAvePoolingHalide(inputs);
+ else
+ return Ptr<BackendNode>();
+ }
+
+ class PoolingInvoker : public ParallelLoopBody
+ {
+ public:
+ const Mat* src;
+ Mat *dst, *mask;
+ Size kernel, stride, pad;
+ int nstripes;
+ bool computeMaxIdx;
+ std::vector<int> ofsbuf;
+ int poolingType;
+
+ PoolingInvoker() : src(0), dst(0), mask(0), nstripes(0), computeMaxIdx(0), poolingType(PoolingLayer::MAX) {}
+
+ static void run(const Mat& src, Mat& dst, Mat& mask, Size kernel,
+ Size stride, Size pad, int poolingType,
+ bool computeMaxIdx, int nstripes)
+ {
+ CV_Assert(src.isContinuous() && dst.isContinuous() &&
+ src.type() == CV_32F && src.type() == dst.type() &&
+ src.dims == 4 && dst.dims == 4 &&
+ src.size[0] == dst.size[0] && src.size[1] == dst.size[1] &&
+ (mask.empty() || (mask.type() == src.type() && mask.size == dst.size)));
+
+ PoolingInvoker p;
+
+ p.src = &src;
+ p.dst = &dst;
+ p.mask = &mask;
+ p.kernel = kernel;
+ p.stride = stride;
+ p.pad = pad;
+ p.nstripes = nstripes;
+ p.computeMaxIdx = computeMaxIdx;
+ p.poolingType = poolingType;
+
+ if( !computeMaxIdx )
+ {
+ p.ofsbuf.resize(kernel.width*kernel.height);
+ for( int i = 0; i < kernel.height; i++ )
+ for( int j = 0; j < kernel.width; j++ )
+ p.ofsbuf[i*kernel.width + j] = src.size[3]*i + j;
+ }
+
+ parallel_for_(Range(0, nstripes), p, nstripes);
+ }
+
+ void operator()(const Range& r) const
+ {
+ int channels = dst->size[1], width = dst->size[3], height = dst->size[2];
+ int inp_width = src->size[3], inp_height = src->size[2];
+ size_t total = dst->total();
+ size_t stripeSize = (total + nstripes - 1)/nstripes;
+ size_t stripeStart = r.start*stripeSize;
+ size_t stripeEnd = std::min(r.end*stripeSize, total);
+ int kernel_w = kernel.width, kernel_h = kernel.height;
+ int pad_w = pad.width, pad_h = pad.height;
+ int stride_w = stride.width, stride_h = stride.height;
+ bool compMaxIdx = computeMaxIdx;
+
+#if CV_SIMD128
+ const int* ofsptr = &ofsbuf[0];
+ v_float32x4 idx00(0.f, (float)stride_w, (float)(stride_w*2), (float)(stride_w*3));
+ v_float32x4 ones = v_setall_f32(1.f);
+ v_float32x4 idx_delta = v_setall_f32((float)(inp_width - kernel_w));
+#endif
+
+ for( size_t ofs0 = stripeStart; ofs0 < stripeEnd; )
+ {
+ size_t ofs = ofs0;
+ int x0 = (int)(ofs % width);
+ ofs /= width;
+ int y0 = (int)(ofs % height);
+ ofs /= height;
+ int c = (int)(ofs % channels);
+ int n = (int)(ofs / channels);
+ int ystart = y0 * stride_h - pad_h;
+ int yend = min(ystart + kernel_h, inp_height + pad_h);
+ int ydelta = yend - ystart;
+ ystart = max(ystart, 0);
+ yend = min(yend, inp_height);
+ const float *srcData = src->ptr<float>(n, c);
+ float *dstData = dst->ptr<float>(n, c, y0);
+ float *dstMaskData = mask->data ? mask->ptr<float>(n, c, y0) : 0;
+
+ int delta = std::min((int)(stripeEnd - ofs0), width - x0);
+ ofs0 += delta;
+ int x1 = x0 + delta;
+
+ if( poolingType == PoolingLayer::MAX )
+ for( ; x0 < x1; x0++ )
+ {
+ int xstart = x0 * stride_w - pad_w;
+ int xend = min(xstart + kernel_w, inp_width);
+ xstart = max(xstart, 0);
+
+#if CV_SIMD128
+ if( xstart > 0 && x0 + 7 < x1 && (x0 + 7) * stride_w - pad_w + kernel_w < inp_width )
+ {
+ if( compMaxIdx )
+ {
+ v_float32x4 max_val0 = v_setall_f32(-FLT_MAX);
+ v_float32x4 max_val1 = max_val0;
+ v_float32x4 max_idx0 = v_setall_f32(-1.f);
+ v_float32x4 max_idx1 = max_idx0;
+ int index0 = ystart * inp_width + xstart;
+ v_float32x4 idx0 = idx00 + v_setall_f32((float)index0);
+ v_float32x4 idx1 = idx0 + v_setall_f32((float)(stride_w*4));
+
+ for (int y = ystart; y < yend; ++y)
+ {
+ for (int x = xstart; x < xend; ++x, idx0 += ones, idx1 += ones)
+ {
+ const int index = y * inp_width + x;
+ v_float32x4 v0(srcData[index], srcData[index + stride_w],
+ srcData[index + stride_w*2], srcData[index + stride_w*3]);
+ v_float32x4 v1(srcData[index + stride_w*4], srcData[index + stride_w*5],
+ srcData[index + stride_w*6], srcData[index + stride_w*7]);
+ max_idx0 = v_select(v0 > max_val0, idx0, max_idx0);
+ max_idx1 = v_select(v1 > max_val1, idx1, max_idx1);
+ max_val0 = v_max(max_val0, v0);
+ max_val1 = v_max(max_val1, v1);
+ }
+ idx0 += idx_delta;
+ idx1 += idx_delta;
+ }
+ v_store(dstData + x0, max_val0);
+ v_store(dstData + x0 + 4, max_val1);
+ if (dstMaskData)
+ {
+ v_store(dstMaskData + x0, max_idx0);
+ v_store(dstMaskData + x0 + 4, max_idx1);
+ }
+ x0 += 7;
+ }
+ else
+ {
+ v_float32x4 max_val0 = v_setall_f32(-FLT_MAX);
+ v_float32x4 max_val1 = max_val0;
+
+ if( yend - ystart == kernel_h )
+ {
+ const float* srcData1 = srcData + ystart*inp_width + xstart;
+ if( stride_w == 1 )
+ for (int k = 0; k < kernel_w*kernel_h; k++)
+ {
+ int index = ofsptr[k];
+ v_float32x4 v0 = v_load(srcData1 + index);
+ v_float32x4 v1 = v_load(srcData1 + index + 4);
+ max_val0 = v_max(max_val0, v0);
+ max_val1 = v_max(max_val1, v1);
+ }
+#if CV_SSE2
+ else if( stride_w == 2 )
+ for (int k = 0; k < kernel_w*kernel_h; k++)
+ {
+ int index = ofsptr[k];
+ v_float32x4 v00 = v_load(srcData1 + index), v01 = v_load(srcData1 + index + 4);
+ v_float32x4 v0(_mm_shuffle_ps(v00.val, v01.val, _MM_SHUFFLE(2, 0, 2, 0)));
+ v_float32x4 v10 = v_load(srcData1 + index + 8), v11 = v_load(srcData1 + index + 12);
+ v_float32x4 v1(_mm_shuffle_ps(v10.val, v11.val, _MM_SHUFFLE(2, 0, 2, 0)));
+ max_val0 = v_max(max_val0, v0);
+ max_val1 = v_max(max_val1, v1);
+ }
+#endif
+ else
+ for (int k = 0; k < kernel_w*kernel_h; k++)
+ {
+ int index = ofsptr[k];
+ v_float32x4 v0(srcData1[index], srcData1[index + stride_w],
+ srcData1[index + stride_w*2], srcData1[index + stride_w*3]);
+ v_float32x4 v1(srcData1[index + stride_w*4], srcData1[index + stride_w*5],
+ srcData1[index + stride_w*6], srcData1[index + stride_w*7]);
+ max_val0 = v_max(max_val0, v0);
+ max_val1 = v_max(max_val1, v1);
+ }
+ }
+ else
+ {
+ for (int y = ystart; y < yend; ++y)
+ {
+ for (int x = xstart; x < xend; ++x)
+ {
+ const int index = y * inp_width + x;
+ v_float32x4 v0(srcData[index], srcData[index + stride_w],
+ srcData[index + stride_w*2], srcData[index + stride_w*3]);
+ v_float32x4 v1(srcData[index + stride_w*4], srcData[index + stride_w*5],
+ srcData[index + stride_w*6], srcData[index + stride_w*7]);
+ max_val0 = v_max(max_val0, v0);
+ max_val1 = v_max(max_val1, v1);
+ }
+ }
+ }
+ v_store(dstData + x0, max_val0);
+ v_store(dstData + x0 + 4, max_val1);
+ x0 += 7;
+ }
+ }
+ else
+#endif
+ {
+ float max_val = -FLT_MAX;
+ if( compMaxIdx )
+ {
+ int max_index = -1;
+ for (int y = ystart; y < yend; ++y)
+ for (int x = xstart; x < xend; ++x)
+ {
+ const int index = y * inp_width + x;
+ float val = srcData[index];
+ if (val > max_val)
+ {
+ max_val = val;
+ max_index = index;
+ }
+ }
+
+ dstData[x0] = max_val;
+ if (dstMaskData)
+ dstMaskData[x0] = max_index;
+ }
+ else
+ {
+ for (int y = ystart; y < yend; ++y)
+ for (int x = xstart; x < xend; ++x)
+ {
+ const int index = y * inp_width + x;
+ float val = srcData[index];
+ max_val = std::max(max_val, val);
+ }
+
+ dstData[x0] = max_val;
+ }
+ }
+ }
+ else
+ {
+ for( ; x0 < x1; x0++ )
+ {
+ int xstart = x0 * stride_w - pad_w;
+ int xend = min(xstart + kernel_w, inp_width + pad_w);
+ int xdelta = xend - xstart;
+ xstart = max(xstart, 0);
+ xend = min(xend, inp_width);
+ float inv_kernel_area = 1.f/(ydelta*xdelta);
+
+#if CV_SIMD128
+ if( xstart > 0 && x0 + 7 < x1 && (x0 + 7) * stride_w - pad_w + kernel_w < inp_width )
+ {
+ v_float32x4 sum_val0 = v_setzero_f32(), sum_val1 = v_setzero_f32();
+ v_float32x4 ikarea = v_setall_f32(inv_kernel_area);
+
+ for (int y = ystart; y < yend; ++y)
+ {
+ for (int x = xstart; x < xend; ++x)
+ {
+ const int index = y * inp_width + x;
+ v_float32x4 v0(srcData[index], srcData[index + stride_w],
+ srcData[index + stride_w*2], srcData[index + stride_w*3]);
+ v_float32x4 v1(srcData[index + stride_w*4], srcData[index + stride_w*5],
+ srcData[index + stride_w*6], srcData[index + stride_w*7]);
+ sum_val0 += v0;
+ sum_val1 += v1;
+ }
+ }
+ v_store(dstData + x0, sum_val0*ikarea);
+ v_store(dstData + x0 + 4, sum_val1*ikarea);
+ x0 += 7;
+ }
+ else
+#endif
+ {
+ float sum_val = 0.f;
+ for (int y = ystart; y < yend; ++y)
+ for (int x = xstart; x < xend; ++x)
+ {
+ const int index = y * inp_width + x;
+ float val = srcData[index];
+ sum_val += val;
+ }
+
+ dstData[x0] = sum_val*inv_kernel_area;
+ }
+ }
+ }
+ }
+ }
+ };
+
+ void maxPooling(Mat &src, Mat &dst, Mat &mask)
+ {
+ const int nstripes = getNumThreads();
+ PoolingInvoker::run(src, dst, mask, kernel, stride, pad, type, computeMaxIdx, nstripes);
+ }
+
+ void avePooling(Mat &src, Mat &dst)
+ {
+ const int nstripes = getNumThreads();
+ Mat mask;
+ PoolingInvoker::run(src, dst, mask, kernel, stride, pad, type, computeMaxIdx, nstripes);
+ }
+
+ virtual Ptr<BackendNode> initMaxPoolingHalide(const std::vector<Ptr<BackendWrapper> > &inputs)
+ {
+#ifdef HAVE_HALIDE
+ Halide::Buffer<float> inputBuffer = halideBuffer(inputs[0]);
+ const int inWidth = inputBuffer.width();
+ const int inHeight = inputBuffer.height();
+
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ Halide::Func top = (name.empty() ? Halide::Func() : Halide::Func(name));
+ Halide::RDom r(0, kernel.width, 0, kernel.height);
+ Halide::Expr kx, ky;
+ if (pad.width || pad.height)
+ {
+ kx = clamp(x * stride.width + r.x - pad.width, 0, inWidth - 1);
+ ky = clamp(y * stride.height + r.y - pad.height, 0, inHeight - 1);
+ }
+ else
+ {
+ kx = min(x * stride.width + r.x, inWidth - 1);
+ ky = min(y * stride.height + r.y, inHeight - 1);
+ }
+
+ // Halide::argmax returns tuple (r.x, r.y, max).
+ Halide::Tuple res = argmax(inputBuffer(kx, ky, c, n));
+
+ // Compute offset from argmax in range [0, kernel_size).
+ Halide::Expr max_index;
+ if (pad.width || pad.height)
+ {
+ max_index = clamp(y * stride.height + res[1] - pad.height,
+ 0, inHeight - 1) * inWidth +
+ clamp(x * stride.width + res[0] - pad.width,
+ 0, inWidth - 1);
+ }
+ else
+ {
+ max_index = min(y * stride.height + res[1], inHeight - 1) * inWidth +
+ min(x * stride.width + res[0], inWidth - 1);
+ }
+ top(x, y, c, n) = { res[2], Halide::cast<float>(max_index) };
+ return Ptr<BackendNode>(new HalideBackendNode(top));
+#endif // HAVE_HALIDE
+ return Ptr<BackendNode>();
+ }
+
+ virtual Ptr<BackendNode> initAvePoolingHalide(const std::vector<Ptr<BackendWrapper> > &inputs)
+ {
+#ifdef HAVE_HALIDE
+ Halide::Buffer<float> inputBuffer = halideBuffer(inputs[0]);
+
+ const int inW = inputBuffer.width(), inH = inputBuffer.height();
+ if ((inW - kernel.width) % stride.width || (inH - kernel.height) % stride.height)
+ {
+ CV_Error(cv::Error::StsNotImplemented,
+ "Halide backend for average pooling with partial "
+ "kernels is not implemented");
+ }
+
+ const float norm = 1.0f / (kernel.width * kernel.height);
+
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ Halide::Func top = (name.empty() ? Halide::Func() : Halide::Func(name));
+ Halide::RDom r(0, kernel.width, 0, kernel.height);
+ top(x, y, c, n) = sum(
+ inputBuffer(x * stride.width + r.x,
+ y * stride.height + r.y, c, n)) * norm;
+ return Ptr<BackendNode>(new HalideBackendNode(top));
+#endif // HAVE_HALIDE
+ return Ptr<BackendNode>();
+ }
+
+ virtual void applyHalideScheduler(Ptr<BackendNode>& node,
+ const std::vector<Mat*> &inputs,
+ const std::vector<Mat> &outputs,
+ int targetId) const
+ {
+#ifdef HAVE_HALIDE
+ if (targetId != DNN_TARGET_CPU)
+ {
+ Layer::applyHalideScheduler(node, inputs, outputs, targetId);
+ return;
+ }
+ Halide::Var x("x"), y("y"), c("c"), n("n"), tile("tile"),
+ xi("xi"), yi("yi"), ci("ci"), xo("xo"), yo("yo"), co("co");
+ Halide::Func& top = node.dynamicCast<HalideBackendNode>()->funcs.back();
+
+ int outW, outH, outC, outN;
+ getCanonicalSize(outputs[0].size, &outW, &outH, &outC, &outN);
+
+ if (outW < 8 || outH < 8)
+ {
+ if (outC > 8)
+ top.split(c, co, ci, 8)
+ .fuse(x, y, tile).fuse(co, tile, tile).fuse(n, tile, tile)
+ .parallel(tile)
+ .vectorize(ci);
+ else
+ {
+ top.fuse(y, c, tile).fuse(n, tile, tile)
+ .parallel(tile);
+ if (outW > 1)
+ top.vectorize(x);
+ }
+ }
+ else
+ {
+ if (outC > 8)
+ top.split(x, xo, xi, 8).split(y, yo, yi, 8).split(c, co, ci, 8)
+ .fuse(xo, yo, tile).fuse(co, tile, tile).fuse(n, tile, tile)
+ .parallel(tile)
+ .vectorize(xi);
+ else
+ top.split(x, xo, xi, 8).split(y, yo, yi, 8)
+ .fuse(xo, yo, tile).fuse(c, tile, tile).fuse(n, tile, tile)
+ .parallel(tile)
+ .vectorize(xi);
+ }
+#endif // HAVE_HALIDE
+ }
+
+ bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+ {
+ CV_Assert(inputs.size() != 0);
+ Size in(inputs[0][3], inputs[0][2]), out;
+
+ if (globalPooling)
+ {
+ out.height = 1;
+ out.width = 1;
+ }
+ else if (padMode.empty())
+ {
+ //Yeah, something strange Caffe scheme-)
+ out.height = static_cast<int>(ceil(static_cast<float>(in.height + 2 * pad.height -
+ kernel.height) / stride.height)) + 1;
+ out.width = static_cast<int>(ceil(static_cast<float>(in.width + 2 * pad.width -
+ kernel.width) / stride.width)) + 1;
+
+ if (pad.height || pad.width)
+ {
+ // If we have padding, ensure that the last pooling starts strictly
+ // inside the image (instead of at the padding); otherwise clip the last.
+ if ((out.height - 1) * stride.height >= in.height + pad.height)
+ --out.height;
+ if ((out.width - 1) * stride.width >= in.width + pad.width)
+ --out.width;
+ CV_Assert((out.height - 1) * stride.height < in.height + pad.height);
+ CV_Assert((out.width - 1) * stride.width < in.width + pad.width);
+ }
+ }
+ else
+ {
+ getConvPoolOutParams(in, kernel, stride,
+ padMode, out);
+ }
+
+ outputs.resize(type == MAX ? 2 * inputs.size() : inputs.size());
+ for (size_t i = 0; i < inputs.size(); i++)
+ {
+ size_t index = type == MAX ? 2*i : i;
+ int dims[] = {inputs[i][0], inputs[i][1], out.height, out.width};
+ outputs[index] = shape(dims);
+
+ if (type == MAX)
+ outputs[index + 1] = shape(dims);
+ }
+
+ return false;
+ }
+
+ virtual int64 getFLOPS(const std::vector<MatShape> &inputs,
+ const std::vector<MatShape> &outputs) const
+ {
+ (void)inputs; // suppress unused variable warning
+ long flops = 0;
+
+ for(int i = 0; i < outputs.size(); i++)
+ {
+ if (type == MAX)
+ {
+ if (i%2 == 0)
+ flops += total(outputs[i])*kernel.area();
+ }
+ else
+ {
+ flops += total(outputs[i])*(kernel.area() + 1);
+ }
+ }
+ return flops;
+ }
+};
+
+Ptr<PoolingLayer> PoolingLayer::create(const LayerParams& params)
+{
+ return Ptr<PoolingLayer>(new PoolingLayerImpl(params));
+}
+
+}
+}
diff --git a/modules/dnn/src/layers/prior_box_layer.cpp b/modules/dnn/src/layers/prior_box_layer.cpp
new file mode 100644
index 0000000..8fa99ac
--- /dev/null
+++ b/modules/dnn/src/layers/prior_box_layer.cpp
@@ -0,0 +1,384 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include <float.h>
+#include <algorithm>
+#include <cmath>
+
+namespace cv
+{
+namespace dnn
+{
+
+class PriorBoxLayerImpl : public PriorBoxLayer
+{
+public:
+ bool getParameterDict(const LayerParams ¶ms,
+ const std::string ¶meterName,
+ DictValue& result)
+ {
+ if (!params.has(parameterName))
+ {
+ return false;
+ }
+
+ result = params.get(parameterName);
+ return true;
+ }
+
+ template<typename T>
+ T getParameter(const LayerParams ¶ms,
+ const std::string ¶meterName,
+ const size_t &idx=0,
+ const bool required=true,
+ const T& defaultValue=T())
+ {
+ DictValue dictValue;
+ bool success = getParameterDict(params, parameterName, dictValue);
+ if(!success)
+ {
+ if(required)
+ {
+ std::string message = _layerName;
+ message += " layer parameter does not contain ";
+ message += parameterName;
+ message += " parameter.";
+ CV_Error(Error::StsBadArg, message);
+ }
+ else
+ {
+ return defaultValue;
+ }
+ }
+ return dictValue.get<T>(idx);
+ }
+
+ void getAspectRatios(const LayerParams ¶ms)
+ {
+ DictValue aspectRatioParameter;
+ bool aspectRatioRetieved = getParameterDict(params, "aspect_ratio", aspectRatioParameter);
+ CV_Assert(aspectRatioRetieved);
+
+ for (int i = 0; i < aspectRatioParameter.size(); ++i)
+ {
+ float aspectRatio = aspectRatioParameter.get<float>(i);
+ bool alreadyExists = false;
+
+ for (size_t j = 0; j < _aspectRatios.size(); ++j)
+ {
+ if (fabs(aspectRatio - _aspectRatios[j]) < 1e-6)
+ {
+ alreadyExists = true;
+ break;
+ }
+ }
+ if (!alreadyExists)
+ {
+ _aspectRatios.push_back(aspectRatio);
+ if (_flip)
+ {
+ _aspectRatios.push_back(1./aspectRatio);
+ }
+ }
+ }
+ }
+
+ void getVariance(const LayerParams ¶ms)
+ {
+ DictValue varianceParameter;
+ bool varianceParameterRetrieved = getParameterDict(params, "variance", varianceParameter);
+ CV_Assert(varianceParameterRetrieved);
+
+ int varianceSize = varianceParameter.size();
+ if (varianceSize > 1)
+ {
+ // Must and only provide 4 variance.
+ CV_Assert(varianceSize == 4);
+
+ for (int i = 0; i < varianceSize; ++i)
+ {
+ float variance = varianceParameter.get<float>(i);
+ CV_Assert(variance > 0);
+ _variance.push_back(variance);
+ }
+ }
+ else
+ {
+ if (varianceSize == 1)
+ {
+ float variance = varianceParameter.get<float>(0);
+ CV_Assert(variance > 0);
+ _variance.push_back(variance);
+ }
+ else
+ {
+ // Set default to 0.1.
+ _variance.push_back(0.1f);
+ }
+ }
+ }
+
+ PriorBoxLayerImpl(const LayerParams ¶ms)
+ : _boxWidth(0), _boxHeight(0)
+ {
+ setParamsFrom(params);
+ _minSize = getParameter<unsigned>(params, "min_size");
+ CV_Assert(_minSize > 0);
+
+ _flip = getParameter<bool>(params, "flip");
+ _clip = getParameter<bool>(params, "clip");
+
+ _aspectRatios.clear();
+ _aspectRatios.push_back(1.);
+
+ getAspectRatios(params);
+ getVariance(params);
+
+ _numPriors = _aspectRatios.size();
+
+ _maxSize = -1;
+ if (params.has("max_size"))
+ {
+ _maxSize = params.get("max_size").get<float>(0);
+ CV_Assert(_maxSize > _minSize);
+
+ _numPriors += 1;
+ }
+
+ if (params.has("step_h") || params.has("step_w")) {
+ CV_Assert(!params.has("step"));
+ _stepY = getParameter<float>(params, "step_h");
+ CV_Assert(_stepY > 0.);
+ _stepX = getParameter<float>(params, "step_w");
+ CV_Assert(_stepX > 0.);
+ } else if (params.has("step")) {
+ const float step = getParameter<float>(params, "step");
+ CV_Assert(step > 0);
+ _stepY = step;
+ _stepX = step;
+ } else {
+ _stepY = 0;
+ _stepX = 0;
+ }
+ }
+
+ bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+ {
+ CV_Assert(inputs.size() == 2);
+
+ int layerHeight = inputs[0][2];
+ int layerWidth = inputs[0][3];
+
+ // Since all images in a batch has same height and width, we only need to
+ // generate one set of priors which can be shared across all images.
+ size_t outNum = 1;
+ // 2 channels. First channel stores the mean of each prior coordinate.
+ // Second channel stores the variance of each prior coordinate.
+ size_t outChannels = 2;
+
+ outputs.resize(1, shape(outNum, outChannels,
+ layerHeight * layerWidth * _numPriors * 4));
+
+ return false;
+ }
+
+ void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ int _layerWidth = inputs[0]->size[3];
+ int _layerHeight = inputs[0]->size[2];
+
+ int _imageWidth = inputs[1]->size[3];
+ int _imageHeight = inputs[1]->size[2];
+
+ float stepX, stepY;
+ if (_stepX == 0 || _stepY == 0) {
+ stepX = static_cast<float>(_imageWidth) / _layerWidth;
+ stepY = static_cast<float>(_imageHeight) / _layerHeight;
+ } else {
+ stepX = _stepX;
+ stepY = _stepY;
+ }
+
+ int _outChannelSize = _layerHeight * _layerWidth * _numPriors * 4;
+
+ float* outputPtr = outputs[0].ptr<float>();
+
+ // first prior: aspect_ratio = 1, size = min_size
+ int idx = 0;
+ for (size_t h = 0; h < _layerHeight; ++h)
+ {
+ for (size_t w = 0; w < _layerWidth; ++w)
+ {
+ _boxWidth = _boxHeight = _minSize;
+
+ float center_x = (w + 0.5) * stepX;
+ float center_y = (h + 0.5) * stepY;
+ // xmin
+ outputPtr[idx++] = (center_x - _boxWidth / 2.) / _imageWidth;
+ // ymin
+ outputPtr[idx++] = (center_y - _boxHeight / 2.) / _imageHeight;
+ // xmax
+ outputPtr[idx++] = (center_x + _boxWidth / 2.) / _imageWidth;
+ // ymax
+ outputPtr[idx++] = (center_y + _boxHeight / 2.) / _imageHeight;
+
+ if (_maxSize > 0)
+ {
+ // second prior: aspect_ratio = 1, size = sqrt(min_size * max_size)
+ _boxWidth = _boxHeight = sqrt(_minSize * _maxSize);
+ // xmin
+ outputPtr[idx++] = (center_x - _boxWidth / 2.) / _imageWidth;
+ // ymin
+ outputPtr[idx++] = (center_y - _boxHeight / 2.) / _imageHeight;
+ // xmax
+ outputPtr[idx++] = (center_x + _boxWidth / 2.) / _imageWidth;
+ // ymax
+ outputPtr[idx++] = (center_y + _boxHeight / 2.) / _imageHeight;
+ }
+
+ // rest of priors
+ for (size_t r = 0; r < _aspectRatios.size(); ++r)
+ {
+ float ar = _aspectRatios[r];
+ if (fabs(ar - 1.) < 1e-6)
+ {
+ continue;
+ }
+ _boxWidth = _minSize * sqrt(ar);
+ _boxHeight = _minSize / sqrt(ar);
+ // xmin
+ outputPtr[idx++] = (center_x - _boxWidth / 2.) / _imageWidth;
+ // ymin
+ outputPtr[idx++] = (center_y - _boxHeight / 2.) / _imageHeight;
+ // xmax
+ outputPtr[idx++] = (center_x + _boxWidth / 2.) / _imageWidth;
+ // ymax
+ outputPtr[idx++] = (center_y + _boxHeight / 2.) / _imageHeight;
+ }
+ }
+ }
+ // clip the prior's coordidate such that it is within [0, 1]
+ if (_clip)
+ {
+ for (size_t d = 0; d < _outChannelSize; ++d)
+ {
+ outputPtr[d] = std::min<float>(std::max<float>(outputPtr[d], 0.), 1.);
+ }
+ }
+ // set the variance.
+ outputPtr = outputs[0].ptr<float>(0, 1);
+ if(_variance.size() == 1)
+ {
+ Mat secondChannel(outputs[0].size[2], outputs[0].size[3], CV_32F, outputPtr);
+ secondChannel.setTo(Scalar(_variance[0]));
+ }
+ else
+ {
+ int count = 0;
+ for (size_t h = 0; h < _layerHeight; ++h)
+ {
+ for (size_t w = 0; w < _layerWidth; ++w)
+ {
+ for (size_t i = 0; i < _numPriors; ++i)
+ {
+ for (int j = 0; j < 4; ++j)
+ {
+ outputPtr[count] = _variance[j];
+ ++count;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ virtual int64 getFLOPS(const std::vector<MatShape> &inputs,
+ const std::vector<MatShape> &outputs) const
+ {
+ (void)outputs; // suppress unused variable warning
+ long flops = 0;
+
+ for (int i = 0; i < inputs.size(); i++)
+ {
+ flops += total(inputs[i], 2) * _numPriors * 4;
+ }
+
+ return flops;
+ }
+
+ float _minSize;
+ float _maxSize;
+
+ float _boxWidth;
+ float _boxHeight;
+
+ float _stepX, _stepY;
+
+ std::vector<float> _aspectRatios;
+ std::vector<float> _variance;
+
+ bool _flip;
+ bool _clip;
+
+ size_t _numPriors;
+
+ static const size_t _numAxes = 4;
+ static const std::string _layerName;
+};
+
+const std::string PriorBoxLayerImpl::_layerName = std::string("PriorBox");
+
+Ptr<PriorBoxLayer> PriorBoxLayer::create(const LayerParams ¶ms)
+{
+ return Ptr<PriorBoxLayer>(new PriorBoxLayerImpl(params));
+}
+
+}
+}
diff --git a/modules/dnn/src/layers/recurrent_layers.cpp b/modules/dnn/src/layers/recurrent_layers.cpp
new file mode 100644
index 0000000..10a6f74
--- /dev/null
+++ b/modules/dnn/src/layers/recurrent_layers.cpp
@@ -0,0 +1,452 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "../precomp.hpp"
+#include <iostream>
+#include <iterator>
+#include <cmath>
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv
+{
+namespace dnn
+{
+
+template<typename Dtype>
+static void tanh(const Mat &src, Mat &dst)
+{
+ MatConstIterator_<Dtype> itSrc = src.begin<Dtype>();
+ MatIterator_<Dtype> itDst = dst.begin<Dtype>();
+
+ for (; itSrc != src.end<Dtype>(); itSrc++, itDst++)
+ *itDst = std::tanh(*itSrc);
+}
+
+//TODO: make utils method
+static void tanh(const Mat &src, Mat &dst)
+{
+ dst.create(src.dims, (const int*)src.size, src.type());
+
+ if (src.type() == CV_32F)
+ tanh<float>(src, dst);
+ else if (src.type() == CV_64F)
+ tanh<double>(src, dst);
+ else
+ CV_Error(Error::StsUnsupportedFormat, "Function supports only floating point types");
+}
+
+static void sigmoid(const Mat &src, Mat &dst)
+{
+ cv::exp(-src, dst);
+ cv::pow(1 + dst, -1, dst);
+}
+
+class LSTMLayerImpl : public LSTMLayer
+{
+ int numTimeStamps, numSamples;
+ bool allocated;
+
+ MatShape outTailShape; //shape of single output sample
+ MatShape outTsShape; //shape of N output samples
+
+ bool useTimestampDim;
+ bool produceCellOutput;
+
+public:
+
+ LSTMLayerImpl(const LayerParams& params)
+ : numTimeStamps(0), numSamples(0)
+ {
+ setParamsFrom(params);
+ type = "LSTM";
+ useTimestampDim = true;
+ produceCellOutput = false;
+ allocated = false;
+ outTailShape.clear();
+ }
+
+ void setUseTimstampsDim(bool use)
+ {
+ CV_Assert(!allocated);
+ useTimestampDim = use;
+ }
+
+ void setProduceCellOutput(bool produce)
+ {
+ CV_Assert(!allocated);
+ produceCellOutput = produce;
+ }
+
+ void setOutShape(const MatShape &outTailShape_)
+ {
+ CV_Assert(!allocated || total(outTailShape) == total(outTailShape_));
+ outTailShape = outTailShape_;
+ }
+
+ void setWeights(const Mat &Wh, const Mat &Wx, const Mat &bias)
+ {
+ CV_Assert(Wh.dims == 2 && Wx.dims == 2);
+ CV_Assert(Wh.rows == Wx.rows);
+ CV_Assert(Wh.rows == 4*Wh.cols);
+ CV_Assert(Wh.rows == (int)bias.total());
+ CV_Assert(Wh.type() == Wx.type() && Wx.type() == bias.type());
+
+ blobs.resize(3);
+ blobs[0] = Mat(Wh.clone());
+ blobs[1] = Mat(Wx.clone());
+ blobs[2] = Mat(bias.clone()).reshape(1, 1);
+ }
+
+ bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+ {
+ CV_Assert(blobs.size() == 3);
+ CV_Assert(inputs.size() == 1);
+ const MatShape& inp0 = inputs[0];
+
+ const Mat &Wh = blobs[0], &Wx = blobs[1];
+ int _numOut = Wh.size[1];
+ int _numInp = Wx.size[1];
+ MatShape outTailShape_(outTailShape), outResShape;
+
+ if (!outTailShape_.empty())
+ CV_Assert(total(outTailShape_) == _numOut);
+ else
+ outTailShape_.assign(1, _numOut);
+
+ int _numTimeStamps, _numSamples;
+ if (useTimestampDim)
+ {
+ CV_Assert(inp0.size() >= 2 && total(inp0, 2) == _numInp);
+ _numTimeStamps = inp0[0];
+ _numSamples = inp0[1];
+ outResShape.push_back(_numTimeStamps);
+ }
+ else
+ {
+ CV_Assert(inp0.size() >= 2 && total(inp0, 1) == _numInp);
+ _numTimeStamps = 1;
+ _numSamples = inp0[0];
+ }
+
+ outResShape.push_back(_numSamples);
+ outResShape.insert(outResShape.end(), outTailShape_.begin(), outTailShape_.end());
+
+ size_t noutputs = produceCellOutput ? 2 : 1;
+ outputs.assign(noutputs, outResShape);
+
+ internals.assign(1, shape(_numSamples, _numOut)); // hInternal
+ internals.push_back(shape(_numSamples, _numOut)); // cInternal
+ internals.push_back(shape(_numSamples, 1)); // dummyOnes
+ internals.push_back(shape(_numSamples, 4*_numOut)); // gates
+
+ return false;
+ }
+
+ void finalize(const std::vector<Mat*> &input, std::vector<Mat> &output)
+ {
+ CV_Assert(blobs.size() == 3);
+ CV_Assert(input.size() == 1);
+ const Mat& inp0 = *input[0];
+
+ Mat &Wh = blobs[0], &Wx = blobs[1];
+ int numOut = Wh.size[1];
+ int numInp = Wx.size[1];
+
+ if (!outTailShape.empty())
+ CV_Assert(total(outTailShape) == numOut);
+ else
+ outTailShape.assign(1, numOut);
+
+ if (useTimestampDim)
+ {
+ CV_Assert(inp0.dims >= 2 && (int)inp0.total(2) == numInp);
+ numTimeStamps = inp0.size[0];
+ numSamples = inp0.size[1];
+ }
+ else
+ {
+ CV_Assert(inp0.dims >= 2 && (int)inp0.total(1) == numInp);
+ numTimeStamps = 1;
+ numSamples = inp0.size[0];
+ }
+
+ outTsShape.clear();
+ outTsShape.push_back(numSamples);
+ outTsShape.insert(outTsShape.end(), outTailShape.begin(), outTailShape.end());
+
+ allocated = true;
+ }
+
+ void forward(std::vector<Mat*> &input, std::vector<Mat> &output, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ const Mat &Wh = blobs[0];
+ const Mat &Wx = blobs[1];
+ const Mat &bias = blobs[2];
+
+ int numOut = Wh.size[1];
+
+ Mat hInternal = internals[0], cInternal = internals[1],
+ dummyOnes = internals[2], gates = internals[3];
+ hInternal.setTo(0.);
+ cInternal.setTo(0.);
+ dummyOnes.setTo(1.);
+
+ int numSamplesTotal = numTimeStamps*numSamples;
+ Mat xTs = input[0]->reshape(1, numSamplesTotal);
+
+ Mat hOutTs = output[0].reshape(1, numSamplesTotal);
+ Mat cOutTs = produceCellOutput ? output[1].reshape(1, numSamplesTotal) : Mat();
+
+ for (int ts = 0; ts < numTimeStamps; ts++)
+ {
+ Range curRowRange(ts*numSamples, (ts + 1)*numSamples);
+ Mat xCurr = xTs.rowRange(curRowRange);
+
+ gemm(xCurr, Wx, 1, gates, 0, gates, GEMM_2_T); // Wx * x_t
+ gemm(hInternal, Wh, 1, gates, 1, gates, GEMM_2_T); //+Wh * h_{t-1}
+ gemm(dummyOnes, bias, 1, gates, 1, gates); //+b
+
+ Mat getesIFO = gates.colRange(0, 3*numOut);
+ Mat gateI = gates.colRange(0*numOut, 1*numOut);
+ Mat gateF = gates.colRange(1*numOut, 2*numOut);
+ Mat gateO = gates.colRange(2*numOut, 3*numOut);
+ Mat gateG = gates.colRange(3*numOut, 4*numOut);
+
+ sigmoid(getesIFO, getesIFO);
+ tanh(gateG, gateG);
+
+ //compute c_t
+ multiply(gateF, cInternal, gateF); // f_t (*) c_{t-1}
+ multiply(gateI, gateG, gateI); // i_t (*) g_t
+ add(gateF, gateI, cInternal); // c_t = f_t (*) c_{t-1} + i_t (*) g_t
+
+ //compute h_t
+ tanh(cInternal, hInternal);
+ multiply(gateO, hInternal, hInternal);
+
+ //save results in output blobs
+ hInternal.copyTo(hOutTs.rowRange(curRowRange));
+ if (produceCellOutput)
+ cInternal.copyTo(cOutTs.rowRange(curRowRange));
+ }
+ }
+};
+
+Ptr<LSTMLayer> LSTMLayer::create(const LayerParams& params)
+{
+ return Ptr<LSTMLayer>(new LSTMLayerImpl(params));
+}
+
+int LSTMLayer::inputNameToIndex(String inputName)
+{
+ if (inputName.toLowerCase() == "x")
+ return 0;
+ return -1;
+}
+
+int LSTMLayer::outputNameToIndex(String outputName)
+{
+ if (outputName.toLowerCase() == "h")
+ return 0;
+ else if (outputName.toLowerCase() == "c")
+ return 1;
+ return -1;
+}
+
+
+class RNNLayerImpl : public RNNLayer
+{
+ int numX, numH, numO;
+ int numSamples, numTimestamps, numSamplesTotal;
+ int dtype;
+ Mat Whh, Wxh, bh;
+ Mat Who, bo;
+ bool produceH;
+
+public:
+
+ RNNLayerImpl(const LayerParams& params)
+ : numX(0), numH(0), numO(0), numSamples(0), numTimestamps(0), numSamplesTotal(0), dtype(0)
+ {
+ setParamsFrom(params);
+ type = "RNN";
+ produceH = false;
+ }
+
+ void setProduceHiddenOutput(bool produce = false)
+ {
+ produceH = produce;
+ }
+
+ void setWeights(const Mat &W_xh, const Mat &b_h, const Mat &W_hh, const Mat &W_ho, const Mat &b_o)
+ {
+ CV_Assert(W_hh.dims == 2 && W_xh.dims == 2);
+ CV_Assert(W_hh.size[0] == W_xh.size[0] && W_hh.size[0] == W_hh.size[1] && (int)b_h.total() == W_xh.size[0]);
+ CV_Assert(W_ho.size[0] == (int)b_o.total());
+ CV_Assert(W_ho.size[1] == W_hh.size[1]);
+
+ blobs.resize(5);
+ blobs[0] = Mat(W_xh.clone());
+ blobs[1] = Mat(b_h.clone());
+ blobs[2] = Mat(W_hh.clone());
+ blobs[3] = Mat(W_ho.clone());
+ blobs[4] = Mat(b_o.clone());
+ }
+
+ bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+ {
+ CV_Assert(inputs.size() >= 1 && inputs.size() <= 2);
+
+ Mat Who_ = blobs[3];
+ Mat Wxh_ = blobs[0];
+
+ int numTimestamps_ = inputs[0][0];
+ int numSamples_ = inputs[0][1];
+
+ int numO_ = Who_.rows;
+ int numH_ = Wxh_.rows;
+
+ outputs.clear();
+ int dims[] = {numTimestamps_, numSamples_, numO_};
+ outputs.push_back(shape(dims, 3));
+ dims[2] = numH_;
+ if (produceH)
+ outputs.push_back(shape(dims, 3));
+
+ internals.assign(2, shape(numSamples_, numH_));
+ internals.push_back(shape(numSamples_, 1));
+
+ return false;
+ }
+
+ void finalize(const std::vector<Mat*> &input, std::vector<Mat> &output)
+ {
+ CV_Assert(input.size() >= 1 && input.size() <= 2);
+
+ Wxh = blobs[0];
+ bh = blobs[1];
+ Whh = blobs[2];
+ Who = blobs[3];
+ bo = blobs[4];
+
+ numH = Wxh.rows;
+ numX = Wxh.cols;
+ numO = Who.rows;
+
+ const Mat& inp0 = *input[0];
+
+ CV_Assert(inp0.dims >= 2);
+ CV_Assert(inp0.total(2) == numX);
+ dtype = CV_32F;
+ CV_Assert(inp0.type() == dtype);
+ numTimestamps = inp0.size[0];
+ numSamples = inp0.size[1];
+ numSamplesTotal = numTimestamps * numSamples;
+
+ bh = bh.reshape(1, 1); //is 1 x numH Mat
+ bo = bo.reshape(1, 1); //is 1 x numO Mat
+ }
+
+ void reshapeOutput(std::vector<Mat> &output)
+ {
+ output.resize(produceH ? 2 : 1);
+ int sz0[] = { numTimestamps, numSamples, numO };
+ output[0].create(3, sz0, dtype);
+ if (produceH)
+ {
+ int sz1[] = { numTimestamps, numSamples, numH };
+ output[1].create(3, sz1, dtype);
+ }
+ }
+
+ void forward(std::vector<Mat*> &input, std::vector<Mat> &output, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ Mat xTs = input[0]->reshape(1, numSamplesTotal);
+ Mat oTs = output[0].reshape(1, numSamplesTotal);
+ Mat hTs = produceH ? output[1].reshape(1, numSamplesTotal) : Mat();
+ Mat hCurr = internals[0];
+ Mat hPrev = internals[1];
+ Mat dummyBiasOnes = internals[2];
+
+ hPrev.setTo(0.);
+ dummyBiasOnes.setTo(1.);
+
+ for (int ts = 0; ts < numTimestamps; ts++)
+ {
+ Range curRowRange = Range(ts * numSamples, (ts + 1) * numSamples);
+ Mat xCurr = xTs.rowRange(curRowRange);
+
+ gemm(hPrev, Whh, 1, hCurr, 0, hCurr, GEMM_2_T); // W_{hh} * h_{prev}
+ gemm(xCurr, Wxh, 1, hCurr, 1, hCurr, GEMM_2_T); //+W_{xh} * x_{curr}
+ gemm(dummyBiasOnes, bh, 1, hCurr, 1, hCurr); //+bh
+ tanh(hCurr, hPrev);
+
+ Mat oCurr = oTs.rowRange(curRowRange);
+ gemm(hPrev, Who, 1, oCurr, 0, oCurr, GEMM_2_T); // W_{ho} * h_{prev}
+ gemm(dummyBiasOnes, bo, 1, oCurr, 1, oCurr); //+b_o
+ tanh(oCurr, oCurr);
+
+ if (produceH)
+ hPrev.copyTo(hTs.rowRange(curRowRange));
+ }
+ }
+};
+
+CV_EXPORTS_W Ptr<RNNLayer> RNNLayer::create(const LayerParams& params)
+{
+ return Ptr<RNNLayer>(new RNNLayerImpl(params));
+}
+
+}
+}
diff --git a/modules/dnn/src/layers/reshape_layer.cpp b/modules/dnn/src/layers/reshape_layer.cpp
new file mode 100644
index 0000000..e5212fb
--- /dev/null
+++ b/modules/dnn/src/layers/reshape_layer.cpp
@@ -0,0 +1,251 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv
+{
+namespace dnn
+{
+
+static void computeShapeByReshapeMask(const MatShape &srcShape,
+ const MatShape &maskShape,
+ Range srcRange /*= Range::all()*/,
+ MatShape& dstShape)
+{
+ int srcShapeSize = (int)srcShape.size();
+ int maskShapeSize = (int)maskShape.size();
+
+ if (srcRange == Range::all())
+ srcRange = Range(0, srcShapeSize);
+ else
+ {
+ int sz = srcRange.size();
+ srcRange.start = clamp(srcRange.start, srcShapeSize);
+ srcRange.end = srcRange.end == INT_MAX ? srcShapeSize : srcRange.start + sz;
+ }
+
+ bool explicitMask = !maskShape.empty(); // All mask values are positive.
+ for (int i = 0, n = maskShape.size(); i < n && explicitMask; ++i)
+ {
+ explicitMask = maskShape[i] > 0;
+ }
+ // Working range of source shape is a range where area(src) == area(mask).
+ if (explicitMask)
+ {
+ int maskTotal = total(maskShape);
+ for (int i = srcRange.start + 1; i < srcRange.end; ++i)
+ {
+ if (total(srcShape, i, srcRange.end) != maskTotal)
+ {
+ srcRange.start = i - 1;
+ break;
+ }
+ }
+ CV_Assert(total(srcShape, srcRange.start, srcRange.end) == maskTotal);
+ }
+
+ CV_Assert(0 <= srcRange.start && srcRange.start <= srcRange.end && srcRange.end <= srcShapeSize);
+ int dstShapeSize = srcShapeSize - srcRange.size() + maskShapeSize;
+ dstShape.resize(dstShapeSize);
+
+ std::copy(srcShape.begin(), srcShape.begin() + srcRange.start, dstShape.begin());
+ std::copy(srcShape.begin() + srcRange.end, srcShape.begin() + srcShapeSize, dstShape.begin() + srcRange.start + maskShapeSize);
+
+ int inferDim = -1;
+ for (int i = 0; i < maskShapeSize; i++)
+ {
+ if (maskShape[i] > 0)
+ {
+ dstShape[srcRange.start + i] = maskShape[i];
+ }
+ else if (maskShape[i] == 0)
+ {
+ if (srcRange.start + i >= srcShapeSize)
+ CV_Error(Error::StsBadArg, format("Copy dim[%d] (which has zero size) is out of the source shape bounds", srcRange.start + i));
+ dstShape[srcRange.start + i] = srcShape[srcRange.start + i];
+ }
+ else if (maskShape[i] == -1)
+ {
+ if (inferDim != -1)
+ CV_Error(Error::StsAssert, "Duplicate of inferred dim (which is denoted by -1)");
+ inferDim = srcRange.start + i;
+ dstShape[inferDim] = 1;
+ }
+ else
+ CV_Error(Error::StsBadArg, "maskShape[i] >= -1");
+ }
+
+ size_t srcTotal = total(srcShape);
+ size_t dstTotal = total(dstShape);
+
+ if (inferDim != -1)
+ {
+ if (srcTotal % dstTotal != 0)
+ CV_Error(Error::StsBackTrace, "Can't infer a dim denoted by -1");
+
+ dstShape[inferDim] = (int)(srcTotal / dstTotal);
+ }
+ else
+ {
+ CV_Assert(srcTotal == dstTotal);
+ }
+}
+
+
+class ReshapeLayerImpl : public ReshapeLayer
+{
+public:
+ ReshapeLayerImpl(const LayerParams& params):
+ performReordering(false)
+ {
+ setParamsFrom(params);
+ int axis = params.get<int>("axis", 0);
+ int numAxes = params.get<int>("num_axes", -1);
+ enableReordering = params.get<bool>("reorder_dims", false);
+ CV_Assert(numAxes >= -1);
+ newShapeRange = (numAxes == -1) ? Range(axis, INT_MAX) : Range(axis, axis + numAxes);
+
+ newShapeDesc.clear();
+ if (params.has("dim"))
+ {
+ const DictValue ¶mShape = params.get("dim");
+ int i, dims = paramShape.size();
+ newShapeDesc.resize(dims);
+ for (i = 0; i < dims; i++)
+ newShapeDesc[i] = paramShape.get<int>(i);
+ }
+ }
+
+ bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+ {
+ outputs.clear();
+
+ for (size_t i = 0; i < inputs.size(); i++)
+ {
+ outputs.push_back(MatShape());
+ computeShapeByReshapeMask(inputs[i], newShapeDesc, newShapeRange, outputs.back());
+ }
+ internals = outputs;
+
+ return true;
+ }
+
+ void finalize(const std::vector<Mat*> &inputs, std::vector<Mat> &outputs)
+ {
+ CV_Assert(inputs.size());
+ CV_Assert(outputs.size());
+ Mat srcBlob = *inputs[0];
+ int dims = srcBlob.dims;
+ MatShape inputShape = shape(srcBlob), outShape = shape(outputs[0]);
+
+ // input.total() == output.total(). So if reordering is require,
+ // one of the sizes will be are not equal.
+ // Example where reordering is require: from 1x128x4x4 to 1x2048
+ // Example where reordering is NOT require: from 1x1024x1x1 to 1x1024.
+ bool reorderingRequire = false;
+ const int minDims = min(dims, (int)outShape.size());
+ for (int i = 0; !reorderingRequire && i < minDims; ++i)
+ reorderingRequire = inputShape[i] != outShape[i];
+ performReordering = enableReordering && reorderingRequire;
+ }
+
+ void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ for (size_t i = 0; i < inputs.size(); i++)
+ {
+ Mat srcBlob = *inputs[i];
+ MatShape inputShape = shape(srcBlob), outShape = shape(outputs[i]);
+
+ if (performReordering)
+ {
+ float *dstData = internals[i].ptr<float>();
+ const float *srcData = srcBlob.ptr<float>();
+
+ int num = inputShape[0], channels = inputShape[1], height = inputShape[2], width = inputShape[3];
+ int total = num*channels*height*width;
+ for(int i_n = 0; i_n < num; i_n++) {
+ for(int i_c = 0; i_c < channels; i_c++) {
+ for(int i_h = 0; i_h < height; i_h++) {
+ for(int i_w = 0; i_w < width; i_w++) {
+ int src_i = channels*height*width*i_n + height*width*i_c + width*i_h + i_w;
+ int dst_i = channels*height*width*i_n + i_c + channels*width*i_h + channels*i_w;
+
+ CV_Assert(dst_i < total);
+ CV_Assert(src_i < total);
+
+ dstData[dst_i] = srcData[src_i];
+ }
+ }
+ }
+ }
+ internals[i].copyTo(outputs[i]);
+ }
+ else
+ {
+ if (outputs[i].data != srcBlob.data)
+ srcBlob.reshape(1, outShape).copyTo(outputs[i]);
+ }
+ }
+ }
+
+private:
+ std::vector<std::vector<int> > outShapes;
+ bool enableReordering, performReordering;
+};
+
+Ptr<ReshapeLayer> ReshapeLayer::create(const LayerParams& params)
+{
+ return Ptr<ReshapeLayer>(new ReshapeLayerImpl(params));
+}
+
+
+}
+}
diff --git a/modules/dnn/src/layers/scale_layer.cpp b/modules/dnn/src/layers/scale_layer.cpp
new file mode 100644
index 0000000..2d04c8a
--- /dev/null
+++ b/modules/dnn/src/layers/scale_layer.cpp
@@ -0,0 +1,150 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+// Copyright (C) 2016, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+
+/*
+Implementation of Scale layer.
+*/
+
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include "op_halide.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv
+{
+namespace dnn
+{
+
+class ScaleLayerImpl : public ScaleLayer
+{
+public:
+ ScaleLayerImpl(const LayerParams& params)
+ {
+ setParamsFrom(params);
+ hasBias = params.get<bool>("bias_term", false);
+ }
+
+ bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+ {
+ Layer::getMemoryShapes(inputs, requiredOutputs, outputs, internals);
+ return true;
+ }
+
+ virtual bool supportBackend(int backendId)
+ {
+ return backendId == DNN_BACKEND_DEFAULT ||
+ backendId == DNN_BACKEND_HALIDE && haveHalide();
+ }
+
+ void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ CV_Assert(blobs.size() == 1 + hasBias);
+
+ for (size_t ii = 0; ii < outputs.size(); ii++)
+ {
+ Mat &inpBlob = *inputs[ii];
+ Mat &outBlob = outputs[ii];
+
+ CV_Assert(inpBlob.size[1] == blobs[0].total());
+ if (hasBias)
+ CV_Assert(inpBlob.size[1] == blobs[1].total());
+
+ CV_Assert(inpBlob.type() == CV_32F && outBlob.type() == CV_32F);
+
+ for( int cn = 0; cn < inpBlob.size[0]; cn++ )
+ {
+ for (int n = 0; n < inpBlob.size[1]; n++)
+ {
+ float w = blobs[0].at<float>(n);
+ float b = hasBias ? blobs[1].at<float>(n) : 0;
+ Mat outBlobPlane = getPlane(outBlob, cn, n);
+ Mat inpBlobPlane = getPlane(inpBlob, cn, n);
+ inpBlobPlane.convertTo(outBlobPlane, CV_32F, w, b);
+ }
+ }
+ }
+ }
+
+ virtual Ptr<BackendNode> tryAttach(const Ptr<BackendNode>& node)
+ {
+ switch (node->backendId)
+ {
+ case DNN_BACKEND_HALIDE:
+ {
+#ifdef HAVE_HALIDE
+ auto base = node.dynamicCast<HalideBackendNode>();
+ Halide::Func& input = base->funcs.back();
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ Halide::Func top = attachHalide(input(x, y, c, n));
+ return Ptr<BackendNode>(new HalideBackendNode(base, top));
+#endif // HAVE_HALIDE
+ break;
+ }
+ }
+ return Ptr<BackendNode>();
+ }
+
+ virtual Ptr<BackendNode> initHalide(const std::vector<Ptr<BackendWrapper> > &inputs)
+ {
+#ifdef HAVE_HALIDE
+ Halide::Buffer<float> input = halideBuffer(inputs[0]);
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ Halide::Func top = attachHalide(input(x, y, c, n));
+ return Ptr<BackendNode>(new HalideBackendNode(top));
+#endif // HAVE_HALIDE
+ return Ptr<BackendNode>();
+ }
+
+#ifdef HAVE_HALIDE
+ // attachHalide can work both with Halide::Buffer and Halide::Func. In the
+ // second case it will be a fusion.
+ Halide::Func attachHalide(const Halide::Expr& input)
+ {
+ Halide::Func top = (name.empty() ? Halide::Func() : Halide::Func(name));
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+
+ const int numChannels = blobs[0].total();
+
+ auto weights = wrapToHalideBuffer(blobs[0], {numChannels});
+ Halide::Expr topExpr = input * weights(c);
+ if (hasBias)
+ {
+ auto bias = wrapToHalideBuffer(blobs[1], {numChannels});
+ topExpr += bias(c);
+ }
+ top(x, y, c, n) = topExpr;
+ return top;
+ }
+#endif // HAVE_HALIDE
+
+ virtual int64 getFLOPS(const std::vector<MatShape> &inputs,
+ const std::vector<MatShape> &outputs) const
+ {
+ (void)outputs; // suppress unused variable warning
+ long flops = 0;
+ for(int i = 0; i < inputs.size(); i++)
+ {
+ flops += 2*total(inputs[i]);
+ }
+ return flops;
+ }
+};
+
+
+Ptr<ScaleLayer> ScaleLayer::create(const LayerParams& params)
+{
+ return Ptr<ScaleLayer>(new ScaleLayerImpl(params));
+}
+
+} // namespace dnn
+} // namespace cv
diff --git a/modules/dnn/src/layers/shift_layer.cpp b/modules/dnn/src/layers/shift_layer.cpp
new file mode 100644
index 0000000..0bd9515
--- /dev/null
+++ b/modules/dnn/src/layers/shift_layer.cpp
@@ -0,0 +1,99 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+// Copyright (C) 2016, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+
+/*
+Implementation of shift layer, which adds up const values to blob.
+*/
+
+#include "../precomp.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv
+{
+namespace dnn
+{
+
+class ShiftLayerImpl : public ShiftLayer
+{
+public:
+ ShiftLayerImpl(const LayerParams ¶ms)
+ {
+ setParamsFrom(params);
+ CV_Assert(blobs.size() == 1);
+ }
+
+ bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+ {
+ Layer::getMemoryShapes(inputs, requiredOutputs, outputs, internals);
+ internals.assign(1, shape(1, total(inputs[0], 2)));
+ return true;
+ }
+
+ virtual void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ CV_Assert(inputs.size() > 0);
+ CV_Assert(blobs.size() > 0);
+
+ if(inputs[0]->dims == blobs[0].dims)
+ {
+ for (size_t ii = 0; ii < outputs.size(); ii++)
+ {
+ Mat &inpBlob = *inputs[ii];
+ Mat &outBlob = outputs[ii];
+
+ outBlob = inpBlob + blobs[0];
+ }
+ }
+ else
+ {
+ Mat biasOnesMat = internals[0];
+ biasOnesMat.setTo(1);
+ for (size_t ii = 0; ii < outputs.size(); ii++)
+ {
+ Mat &inpBlob = *inputs[ii];
+ Mat &outBlob = outputs[ii];
+
+ inpBlob.copyTo(outBlob);
+
+ for (int n = 0; n < inpBlob.size[0]; n++)
+ {
+ Mat dstMat(inpBlob.size[1], inpBlob.size[2] * inpBlob.size[3],
+ outBlob.type(), outBlob.ptr(n));
+ gemm(blobs[0], biasOnesMat, 1, dstMat, 1, dstMat); //TODO: gemv
+ }
+ }
+ }
+ }
+
+ virtual int64 getFLOPS(const std::vector<MatShape> &inputs,
+ const std::vector<MatShape> &outputs) const
+ {
+ (void)outputs; // suppress unused variable warning
+ long flops = 0;
+
+ for(int i= 0; i < inputs.size(); i++)
+ {
+ flops += total(inputs[i]);
+ }
+
+ return flops;
+ }
+};
+
+Ptr<ShiftLayer> ShiftLayer::create(const LayerParams& params)
+{
+ return Ptr<ShiftLayer>(new ShiftLayerImpl(params));
+}
+
+}
+}
diff --git a/modules/dnn/src/layers/slice_layer.cpp b/modules/dnn/src/layers/slice_layer.cpp
new file mode 100644
index 0000000..86313e3
--- /dev/null
+++ b/modules/dnn/src/layers/slice_layer.cpp
@@ -0,0 +1,144 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv
+{
+namespace dnn
+{
+
+class SliceLayerImpl : public SliceLayer
+{
+public:
+ SliceLayerImpl(const LayerParams& params)
+ {
+ setParamsFrom(params);
+ axis = params.get<int>("axis", 1);
+
+ if (params.has("slice_point"))
+ {
+ const DictValue &indicesValue = params.get("slice_point");
+ int i, n = indicesValue.size();
+ sliceIndices.resize(n);
+ for (i = 0; i < n; i++)
+ sliceIndices[i] = indicesValue.get<int>(i);
+ }
+ }
+
+ bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+ {
+ CV_Assert(inputs.size() == 1);
+
+ outputs.clear();
+
+ MatShape inpShape = inputs[0];
+ int cAxis = clamp(axis, inpShape.size());
+ int axisSize = inpShape[cAxis];
+
+ if (sliceIndices.size()) //divide blob with respect to passed parameters
+ {
+ std::vector<int> outAxisSize;
+ int prevSlice = 0;
+
+ for (size_t i = 0; i < sliceIndices.size(); i++)
+ {
+ if (!(prevSlice < sliceIndices[i] && sliceIndices[i] < axisSize))
+ CV_Error(Error::StsBadArg, "Slice indices should be positive, increased and don't exceed size of sliced dimension");
+
+ outAxisSize.push_back(sliceIndices[i] - prevSlice);
+ prevSlice = sliceIndices[i];
+ }
+ outAxisSize.push_back(axisSize - prevSlice);
+
+ for (size_t i = 0; i < outAxisSize.size(); i++)
+ {
+ inpShape[cAxis] = outAxisSize[i];
+ outputs.push_back(inpShape);
+ }
+ }
+ else //divide blob with respect to count of output blobs
+ {
+ CV_Assert(requiredOutputs > 0 && axisSize % requiredOutputs == 0);
+ int outAxisSize = axisSize / (int)requiredOutputs;
+
+ for (size_t i = 0; i < requiredOutputs; i++)
+ {
+ inpShape[cAxis] = outAxisSize;
+ outputs.push_back(inpShape);
+ }
+ }
+
+ return false;
+ }
+
+ void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ const Mat& inpMat = *inputs[0];
+ std::vector<Range> ranges(inpMat.dims, Range::all());
+ int cAxis = clamp(axis, inpMat.dims);
+
+ ranges[cAxis].start = 0;
+ for (size_t i = 0; i < outputs.size(); i++)
+ {
+ ranges[cAxis].end = ranges[cAxis].start + outputs[i].size[cAxis];
+ inpMat(&ranges[0]).copyTo(outputs[i]);
+ ranges[cAxis].start = ranges[cAxis].end;
+ }
+ }
+};
+
+Ptr<SliceLayer> SliceLayer::create(const LayerParams& params)
+{
+ return Ptr<SliceLayer>(new SliceLayerImpl(params));
+}
+
+}
+}
diff --git a/modules/dnn/src/layers/softmax_layer.cpp b/modules/dnn/src/layers/softmax_layer.cpp
new file mode 100644
index 0000000..828557d
--- /dev/null
+++ b/modules/dnn/src/layers/softmax_layer.cpp
@@ -0,0 +1,221 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include "op_halide.hpp"
+#include <algorithm>
+#include <stdlib.h>
+using std::max;
+
+namespace cv
+{
+namespace dnn
+{
+
+class SoftMaxLayerImpl : public SoftmaxLayer
+{
+public:
+
+ SoftMaxLayerImpl(const LayerParams& params)
+ {
+ axisRaw = params.get<int>("axis", 1);
+ logSoftMax = params.get<int>("log_softmax", false);
+ setParamsFrom(params);
+ }
+
+ bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+ {
+ bool inplace = Layer::getMemoryShapes(inputs, requiredOutputs, outputs, internals);
+ MatShape shape = inputs[0];
+ int cAxis = clamp(axisRaw, shape.size());
+ shape[cAxis] = 1;
+ internals.assign(1, shape);
+ return inplace;
+ }
+
+ virtual bool supportBackend(int backendId)
+ {
+ return backendId == DNN_BACKEND_DEFAULT ||
+ backendId == DNN_BACKEND_HALIDE && haveHalide() && axisRaw == 1;
+ }
+
+ void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ const Mat &src = *inputs[0];
+ Mat &dst = outputs[0];
+
+ int axis = clamp(axisRaw, src.dims);
+ size_t outerSize = src.total(0, axis), channels = src.size[axis],
+ innerSize = src.total(axis + 1);
+
+ CV_Assert(src.type() == CV_32F);
+ CV_Assert(src.isContinuous() && dst.isContinuous());
+
+ const float *srcPtr = src.ptr<float>();
+ float *dstPtr = dst.ptr<float>();
+ float *bufPtr = internals[0].ptr<float>();
+
+ size_t outerStep = src.total(axis);
+ size_t cnStep = src.total(axis + 1);
+
+ //compute max along axis
+ for (size_t outerDim = 0; outerDim < outerSize; outerDim++)
+ {
+ size_t srcOffset = outerDim * outerStep;
+ size_t bufOffset = outerDim * cnStep;
+
+ memcpy(bufPtr + bufOffset, srcPtr + srcOffset, innerSize * sizeof(float));
+
+ for (size_t cnDim = 1; cnDim < channels; cnDim++)
+ {
+ for (size_t i = 0; i < innerSize; i++)
+ bufPtr[bufOffset + i] = std::max(bufPtr[bufOffset + i], srcPtr[srcOffset + cnDim * cnStep + i]);
+ }
+ }
+
+ //subtract max
+ for (size_t outerDim = 0; outerDim < outerSize; outerDim++)
+ {
+ size_t srcOffset = outerDim * outerStep;
+ size_t bufOffset = outerDim * cnStep;
+
+ for (size_t cnDim = 0; cnDim < channels; cnDim++)
+ {
+ const int offset = srcOffset + cnDim * cnStep;
+ for (size_t i = 0; i < innerSize; i++)
+ dstPtr[offset + i] = srcPtr[offset + i] - bufPtr[bufOffset + i];
+ }
+ }
+
+ cv::exp(dst, dst);
+
+ for (size_t outerDim = 0; outerDim < outerSize; outerDim++)
+ {
+ size_t srcOffset = outerDim * outerStep;
+ size_t bufOffset = outerDim * cnStep;
+
+ //sum exp along axis
+ for (size_t i = 0; i < innerSize; i++)
+ bufPtr[bufOffset + i] = 0.f;
+
+ for (size_t cnDim = 0; cnDim < channels; cnDim++)
+ {
+ const int offset = srcOffset + cnDim * cnStep;
+ for (size_t i = 0; i < innerSize; i++)
+ bufPtr[bufOffset + i] += dstPtr[offset + i];
+ }
+
+ //divide by computed sum
+ for (size_t cnDim = 0; cnDim < channels; cnDim++)
+ {
+ const int offset = srcOffset + cnDim * cnStep;
+ for (size_t i = 0; i < innerSize; i++)
+ dstPtr[offset + i] /= bufPtr[bufOffset + i];
+ }
+ if (logSoftMax)
+ {
+ for (size_t cnDim = 0; cnDim < channels; cnDim++)
+ {
+ const int offset = srcOffset + cnDim * cnStep;
+ for (size_t i = 0; i < innerSize; i++)
+ dstPtr[offset + i] = log(dstPtr[offset + i]);
+ }
+ }
+ }
+ }
+
+ virtual Ptr<BackendNode> initHalide(const std::vector<Ptr<BackendWrapper> > &inputs)
+ {
+#ifdef HAVE_HALIDE
+ Halide::Buffer<float> inputBuffer = halideBuffer(inputs[0]);
+ int inW, inH, inC, inN;
+ getCanonicalSize(inputBuffer, &inW, &inH, &inC, &inN);
+
+ if (inW != 1 || inH != 1)
+ CV_Error(cv::Error::StsNotImplemented,
+ "Halide backend for SoftMax with spatial size "
+ "more than 1x1 is not implemented");
+
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ Halide::Func top = (name.empty() ? Halide::Func() : Halide::Func(name));
+
+ Halide::Func expInput("expInput");
+ Halide::RDom r(0, inW, 0, inH, 0, inC);
+ expInput(x, y, c, n) = exp(inputBuffer(x, y, c, n));
+ Halide::Expr globalSum = sum(expInput(r.x, r.y, r.z, n));
+ top(x, y, c, n) = expInput(x, y, c, n) / globalSum;
+ return Ptr<BackendNode>(new HalideBackendNode(top));
+#endif // HAVE_HALIDE
+ return Ptr<BackendNode>();
+ }
+
+ int64 getFLOPS(const std::vector<MatShape> &inputs,
+ const std::vector<MatShape> &outputs) const
+ {
+ (void)outputs; // suppress unused variable warning
+ int64 flops = 0;
+
+ for (int i = 0; i < inputs.size(); i++)
+ {
+ flops += 4*total(inputs[i]);
+ }
+
+ return flops;
+ }
+
+ int axisRaw;
+};
+
+Ptr<SoftmaxLayer> SoftmaxLayer::create(const LayerParams& params)
+{
+ return Ptr<SoftmaxLayer>(new SoftMaxLayerImpl(params));
+}
+
+}
+}
diff --git a/modules/dnn/src/layers/split_layer.cpp b/modules/dnn/src/layers/split_layer.cpp
new file mode 100644
index 0000000..bae6c87
--- /dev/null
+++ b/modules/dnn/src/layers/split_layer.cpp
@@ -0,0 +1,101 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+
+namespace cv
+{
+namespace dnn
+{
+
+class SplitLayerImpl : public SplitLayer
+{
+public:
+ SplitLayerImpl(const LayerParams ¶ms)
+ {
+ setParamsFrom(params);
+ //TODO: maybe "top_count" param is useless because it can be determined by output connections number
+ if (params.has("top_count"))
+ {
+ outputsCount = params.get<int>("top_count");
+ CV_Assert(outputsCount >= 0);
+ }
+ else
+ {
+ outputsCount = -1;
+ }
+ }
+
+ bool getMemoryShapes(const std::vector<MatShape> &inputs,
+ const int requiredOutputs,
+ std::vector<MatShape> &outputs,
+ std::vector<MatShape> &internals) const
+ {
+ CV_Assert(inputs.size() == 1);
+
+ Layer::getMemoryShapes(inputs, max(1, outputsCount >= 0 ? outputsCount : requiredOutputs),
+ outputs, internals);
+ return true;
+ }
+
+ void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
+ {
+ CV_TRACE_FUNCTION();
+ CV_TRACE_ARG_VALUE(name, "name", name.c_str());
+
+ for (size_t i = 0; i < outputs.size(); i++)
+ {
+ CV_Assert(inputs[0]->total() == outputs[i].total());
+ if (outputs[i].data != inputs[0]->data)
+ inputs[0]->copyTo(outputs[i]);
+ }
+ }
+};
+
+Ptr<SplitLayer> SplitLayer::create(const LayerParams& params)
+{
+ return Ptr<SplitLayer>(new SplitLayerImpl(params));
+}
+
+}
+}
diff --git a/modules/dnn/src/op_halide.cpp b/modules/dnn/src/op_halide.cpp
new file mode 100644
index 0000000..dc46ace
--- /dev/null
+++ b/modules/dnn/src/op_halide.cpp
@@ -0,0 +1,209 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+//
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+
+#include "precomp.hpp"
+#include "op_halide.hpp"
+
+#ifdef HAVE_HALIDE
+#include <HalideRuntimeOpenCL.h>
+#endif // HAVE_HALIDE
+
+namespace cv
+{
+namespace dnn
+{
+
+#ifdef HAVE_HALIDE
+Halide::Buffer<float> wrapToHalideBuffer(const Mat& mat)
+{
+ int n, c, w, h;
+ getCanonicalSize(mat.size, &w, &h, &c, &n);
+ return wrapToHalideBuffer(mat, {w, h, c, n});
+}
+
+Halide::Buffer<float> wrapToHalideBuffer(const Mat& mat,
+ const std::vector<int>& sizes)
+{
+ Halide::Buffer<float> buffer((float*)mat.data, sizes);
+ buffer.set_host_dirty(); // Indicate that data is on CPU.
+ return buffer;
+}
+
+Halide::Buffer<> halideBuffer(const Ptr<BackendWrapper>& ptr)
+{
+ CV_Assert(!ptr.empty());
+ return ptr.dynamicCast<HalideBackendWrapper>()->buffer;
+}
+
+std::vector<Halide::Buffer<> > halideBuffers(const std::vector<Ptr<BackendWrapper> >& ptrs)
+{
+ std::vector<Halide::Buffer<> > vec;
+ vec.reserve(ptrs.size());
+ for (const Ptr<BackendWrapper>& ptr : ptrs)
+ {
+ vec.push_back(halideBuffer(ptr));
+ }
+ return vec;
+}
+
+void getCanonicalSize(const Halide::Buffer<>& buffer, int* width, int* height,
+ int* channels, int* batch)
+{
+ CV_Assert(buffer.dimensions() == 4);
+ *width = buffer.extent(0);
+ *height = buffer.extent(1);
+ *channels = buffer.extent(2);
+ *batch = buffer.extent(3);
+}
+
+HalideBackendNode::HalideBackendNode(const Halide::Func& func)
+ : BackendNode(DNN_BACKEND_HALIDE), funcs(1, func) {}
+
+HalideBackendNode::HalideBackendNode(const std::vector<Halide::Func>& funcs)
+ : BackendNode(DNN_BACKEND_HALIDE), funcs(funcs) {}
+
+HalideBackendNode::HalideBackendNode(const Ptr<HalideBackendNode>& base,
+ const Halide::Func& top)
+ : BackendNode(DNN_BACKEND_HALIDE), funcs(base->funcs)
+{
+ funcs.back() = top;
+}
+
+HalideBackendWrapper::HalideBackendWrapper(int targetId, const cv::Mat& m)
+ : BackendWrapper(DNN_BACKEND_HALIDE, targetId)
+{
+ buffer = wrapToHalideBuffer(m);
+ if (targetId == DNN_TARGET_CPU)
+ {
+ return;
+ }
+ else if (targetId == DNN_TARGET_OPENCL)
+ {
+ Halide::Target t = Halide::get_host_target();
+ t.set_feature(Halide::Target::OpenCL);
+ buffer.copy_to_device(get_default_device_interface_for_target(t));
+ }
+ else
+ CV_Error(Error::StsNotImplemented, "Unknown target identifier");
+}
+
+HalideBackendWrapper::HalideBackendWrapper(const Ptr<BackendWrapper>& base,
+ const MatShape& shape)
+ : BackendWrapper(DNN_BACKEND_HALIDE, base->targetId)
+{
+ int w, h, c, n;
+ getCanonicalSize(shape, &w, &h, &c, &n);
+ Halide::Buffer<float> baseBuffer = halideBuffer(base);
+ buffer = Halide::Buffer<float>((float*)baseBuffer.raw_buffer()->host,
+ {w, h, c, n});
+ if (baseBuffer.has_device_allocation())
+ {
+ buffer.raw_buffer()->device = baseBuffer.raw_buffer()->device;
+ buffer.raw_buffer()->device_interface = baseBuffer.raw_buffer()->device_interface;
+ buffer.set_device_dirty();
+ }
+ else
+ {
+ buffer.set_host_dirty(); // Indicate that data is on CPU.
+ CV_Assert(targetId == DNN_TARGET_CPU);
+ }
+}
+
+void HalideBackendWrapper::copyToHost()
+{
+ CV_Assert(targetId == DNN_TARGET_CPU || buffer.device_dirty());
+ if (buffer.device_dirty())
+ {
+ buffer.device_sync();
+ buffer.copy_to_host();
+ }
+}
+#endif // HAVE_HALIDE
+
+void getCanonicalSize(const MatSize& size, int* width, int* height,
+ int* channels, int* batch)
+{
+ const int dims = size.p[-1];
+ CV_Assert(dims == 2 || dims == 4);
+ *batch = size[0];
+ *channels = size[1];
+ if (dims == 4)
+ {
+ *width = size[3];
+ *height = size[2];
+ }
+ else
+ {
+ *width = 1;
+ *height = 1;
+ }
+}
+
+void getCanonicalSize(const MatShape& shape, int* width, int* height,
+ int* channels, int* batch)
+{
+ const int dims = shape.size();
+ CV_Assert(dims == 2 || dims == 4);
+ *batch = shape[0];
+ *channels = shape[1];
+ if (dims == 4)
+ {
+ *width = shape[3];
+ *height = shape[2];
+ }
+ else
+ {
+ *width = 1;
+ *height = 1;
+ }
+}
+
+void compileHalide(std::vector<Mat> &outputs, Ptr<BackendNode>& node, int targetId)
+{
+#ifdef HAVE_HALIDE
+ CV_Assert(!node.empty());
+ Halide::Func& top = node.dynamicCast<HalideBackendNode>()->funcs.back();
+
+ int outW, outH, outC, outN;
+ Halide::Var x("x"), y("y"), c("c"), n("n");
+ getCanonicalSize(outputs[0].size, &outW, &outH, &outC, &outN);
+ top.bound(x, 0, outW).bound(y, 0, outH)
+ .bound(c, 0, outC).bound(n, 0, outN);
+
+ Halide::Target target = Halide::get_host_target();
+ target.set_feature(Halide::Target::NoAsserts);
+ if (targetId == DNN_TARGET_OPENCL)
+ {
+ target.set_feature(Halide::Target::OpenCL);
+ }
+ CV_Assert(target.supported());
+ top.compile_jit(target);
+#endif // HAVE_HALIDE
+}
+
+void forwardHalide(std::vector<Ptr<BackendWrapper> > &outputs,
+ const Ptr<BackendNode>& node)
+{
+#ifdef HAVE_HALIDE
+ CV_Assert(!node.empty());
+ Halide::Func& top = node.dynamicCast<HalideBackendNode>()->funcs.back();
+ auto outputBuffers = halideBuffers(outputs);
+ top.realize(Halide::Realization(outputBuffers));
+#endif // HAVE_HALIDE
+}
+
+bool haveHalide()
+{
+#ifdef HAVE_HALIDE
+ return true;
+#else
+ return false;
+#endif // HAVE_HALIDE
+}
+
+} // namespace dnn
+} // namespace cv
diff --git a/modules/dnn/src/op_halide.hpp b/modules/dnn/src/op_halide.hpp
new file mode 100644
index 0000000..f91e3fb
--- /dev/null
+++ b/modules/dnn/src/op_halide.hpp
@@ -0,0 +1,84 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+//
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+
+#ifndef __OPENCV_DNN_OP_HALIDE_HPP__
+#define __OPENCV_DNN_OP_HALIDE_HPP__
+
+#include "precomp.hpp"
+
+#ifdef HAVE_HALIDE
+#include <Halide.h>
+#endif // HAVE_HALIDE
+
+namespace cv
+{
+namespace dnn
+{
+#ifdef HAVE_HALIDE
+ // Returns four-dimensional buffer with float32 type that wrap cv::Mat data.
+ // No data copy here.
+ Halide::Buffer<float> wrapToHalideBuffer(const Mat& mat);
+
+ Halide::Buffer<float> wrapToHalideBuffer(const Mat& mat,
+ const std::vector<int>& shape);
+
+ // Extract batch size, number of channels, width and height from buffer.
+ void getCanonicalSize(const Halide::Buffer<>& buffer, int* width, int* height,
+ int* channels, int* batch);
+
+ // Cast pointer and create copy of Halide buffer. No data copy.
+ Halide::Buffer<> halideBuffer(const Ptr<BackendWrapper>& ptr);
+
+ std::vector<Halide::Buffer<> > halideBuffers(const std::vector<Ptr<BackendWrapper> >& ptrs);
+
+ class HalideBackendNode : public BackendNode
+ {
+ public:
+ HalideBackendNode(const Halide::Func& func);
+
+ HalideBackendNode(const std::vector<Halide::Func>& funcs);
+
+ // Initialize from the <base> node but replace last function to <top>.
+ // It's using in case of layers fusing when we want to keep functions of
+ // root layer but replace top by fused one (i.e. conv+padding to relu+padding).
+ HalideBackendNode(const Ptr<HalideBackendNode>& base, const Halide::Func& top);
+
+ std::vector<Halide::Func> funcs;
+ };
+
+ class HalideBackendWrapper : public BackendWrapper
+ {
+ public:
+ HalideBackendWrapper(int targetId, const cv::Mat& m);
+
+ HalideBackendWrapper(const Ptr<BackendWrapper>& base, const MatShape& shape);
+
+ virtual void copyToHost();
+
+ Halide::Buffer<float> buffer;
+ };
+#endif // HAVE_HALIDE
+
+ // Extract batch size, number of channels, width and height from MatSize.
+ void getCanonicalSize(const MatSize& size, int* width, int* height,
+ int* channels, int* batch);
+
+ void getCanonicalSize(const MatShape& shape, int* width, int* height,
+ int* channels, int* batch);
+
+ // Realize Halide pipeline into output blobs.
+ void forwardHalide(std::vector<Ptr<BackendWrapper> > &outputs,
+ const Ptr<BackendNode>& node);
+
+ // Compile Halide pipeline to specific target. Use outputs to set bounds of functions.
+ void compileHalide(std::vector<Mat> &outputs, Ptr<BackendNode>& node, int targetId);
+
+ bool haveHalide();
+} // namespace dnn
+} // namespace cv
+
+#endif // __OPENCV_DNN_OP_HALIDE_HPP__
diff --git a/modules/dnn/src/opencl/activations.cl b/modules/dnn/src/opencl/activations.cl
new file mode 100644
index 0000000..b98e52f
--- /dev/null
+++ b/modules/dnn/src/opencl/activations.cl
@@ -0,0 +1,44 @@
+__kernel void ReLUForward(const int count, __global const T* in, __global T* out
+#ifndef RELU_NO_SLOPE
+, T negative_slope
+#endif
+) {
+ int index = get_global_id(0);
+ if(index < count)
+#ifndef RELU_NO_SLOPE
+ out[index] = in[index] > 0 ? in[index] : in[index] * negative_slope;
+#else
+ out[index] = in[index] > 0 ? in[index] : 0;
+#endif
+}
+
+__kernel void TanHForward(const int count, __global T* in, __global T* out) {
+ int index = get_global_id(0);
+ if(index < count)
+ out[index] = tanh(in[index]);
+}
+
+__kernel void SigmoidForward(const int count, __global const T* in, __global T* out) {
+ int index = get_global_id(0);
+ if(index < count)
+ out[index] = 1.0f / (1.0f + exp(-in[index]));
+}
+
+__kernel void BNLLForward(const int n, __global const T* in, __global T* out) {
+ int index = get_global_id(0);
+ if (index < n) {
+ out[index] = in[index] > 0 ? in[index] + log(1.0f + exp(-in[index])) : log(1.0f + exp(in[index]));
+ }
+}
+
+__kernel void AbsValForward(const int n, __global const T* in, __global T* out) {
+ int index = get_global_id(0);
+ if (index < n)
+ out[index] = fabs(in[index]);
+}
+
+__kernel void PowForward(const int n, __global const T* in, __global T* out, const T power, const T scale, const T shift) {
+ int index = get_global_id(0);
+ if (index < n)
+ out[index] = pow(shift + scale * in[index], power);
+}
diff --git a/contrib/modules/dnn/src/opencl/col2im.cl b/modules/dnn/src/opencl/col2im.cl
similarity index 100%
rename from contrib/modules/dnn/src/opencl/col2im.cl
rename to modules/dnn/src/opencl/col2im.cl
diff --git a/contrib/modules/dnn/src/opencl/im2col.cl b/modules/dnn/src/opencl/im2col.cl
similarity index 100%
rename from contrib/modules/dnn/src/opencl/im2col.cl
rename to modules/dnn/src/opencl/im2col.cl
diff --git a/contrib/modules/dnn/src/opencl/lrn.cl b/modules/dnn/src/opencl/lrn.cl
similarity index 100%
rename from contrib/modules/dnn/src/opencl/lrn.cl
rename to modules/dnn/src/opencl/lrn.cl
diff --git a/modules/dnn/src/opencl/pooling.cl b/modules/dnn/src/opencl/pooling.cl
new file mode 100644
index 0000000..adfd59e
--- /dev/null
+++ b/modules/dnn/src/opencl/pooling.cl
@@ -0,0 +1,106 @@
+/*************************************************************************************
+ * Copyright (c) 2015, Advanced Micro Devices, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ **************************************************************************************/
+
+__kernel void MaxPoolForward(const int nthreads,
+ __global T* bottom_data, const int num, const int channels, const int height, const int width,
+ const int pooled_height, const int pooled_width, const int kernel_h, const int kernel_w,
+ const int stride_h, const int stride_w, const int pad_h, const int pad_w,
+ __global T* top_data
+#ifdef MASK
+ , __global float* mask
+#endif
+ )
+{
+ int index = get_global_id(0);
+ int tmp = get_global_size(0);
+ for(index; index < nthreads; index += tmp) {
+ int pw = index % pooled_width;
+ int ph = (index / pooled_width) % pooled_height;
+ int c = (index / pooled_width / pooled_height) % channels;
+ int n = index / pooled_width / pooled_height / channels;
+ int hstart = ph * stride_h - pad_h;
+ int wstart = pw * stride_w - pad_w;
+ const int hend = min(hstart + kernel_h, height);
+ const int wend = min(wstart + kernel_w, width);
+ hstart = max(hstart, 0);
+ wstart = max(wstart, 0);
+ T maxval = -FLT_MAX;
+ int maxidx = -1;
+ bottom_data =
+ bottom_data + (n * channels + c) * height * width;
+ for (int h = hstart; h < hend; ++h) {
+ for (int w = wstart; w < wend; ++w) {
+ if (bottom_data[h * width + w] > maxval) {
+ maxidx = h * width + w;
+ maxval = bottom_data[maxidx];
+ }
+ }
+ }
+
+ top_data[index] = maxval;
+
+#ifdef MASK
+ mask[index] = maxidx;
+#endif
+ }
+}
+
+__kernel void AvePoolForward(const int nthreads,
+ __global T* bottom_data, const int num, const int channels, const int height, const int width,
+ const int pooled_height, const int pooled_width, const int kernel_h, const int kernel_w,
+ const int stride_h, const int stride_w, const int pad_h, const int pad_w,
+ __global T* top_data
+#ifdef MASK
+ , __global float* mask // NOT USED
+#endif
+ )
+{
+ int index = get_global_id(0);
+ int tmp = get_global_size(0);
+ for(index; index < nthreads; index+=tmp) {
+ int pw = index % pooled_width;
+ int ph = (index / pooled_width) % pooled_height;
+ int c = (index / pooled_width / pooled_height) % channels;
+ int n = index / pooled_width / pooled_height / channels; int hstart = ph * stride_h - pad_h; int wstart = pw * stride_w - pad_w;
+ int hend = min(hstart + kernel_h, height + pad_h);
+ int wend = min(wstart + kernel_w, width + pad_w);
+ const int pool_size = (hend - hstart) * (wend - wstart);
+ hstart = max(hstart, 0);
+ wstart = max(wstart, 0);
+ hend = min(hend, height);
+ wend = min(wend, width);
+ T aveval = 0;
+ bottom_data =
+ bottom_data + (n * channels + c) * height * width;
+ for (int h = hstart; h < hend; ++h) {
+ for (int w = wstart; w < wend; ++w) {
+ aveval += bottom_data[h * width + w];
+ }
+ }
+ top_data[index] = aveval / pool_size;
+ }
+
+}
diff --git a/contrib/modules/dnn/src/opencl/softmax.cl b/modules/dnn/src/opencl/softmax.cl
similarity index 100%
rename from contrib/modules/dnn/src/opencl/softmax.cl
rename to modules/dnn/src/opencl/softmax.cl
diff --git a/modules/dnn/src/precomp.hpp b/modules/dnn/src/precomp.hpp
new file mode 100644
index 0000000..9383a08
--- /dev/null
+++ b/modules/dnn/src/precomp.hpp
@@ -0,0 +1,54 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include <opencv2/core.hpp>
+#include <opencv2/core/utils/trace.hpp>
+#include <opencv2/core/softfloat.hpp> // int32_t (MSVS 2010-2013)
+#include "cvconfig.h"
+#include <opencv2/dnn.hpp>
+#include <opencv2/dnn/all_layers.hpp>
+
+namespace cv { namespace dnn {
+CV__DNN_EXPERIMENTAL_NS_BEGIN
+Mutex& getInitializationMutex();
+void initializeLayerFactory();
+CV__DNN_EXPERIMENTAL_NS_END
+}} // namespace
diff --git a/contrib/modules/dnn/src/tensorflow/attr_value.proto b/modules/dnn/src/tensorflow/attr_value.proto
similarity index 100%
rename from contrib/modules/dnn/src/tensorflow/attr_value.proto
rename to modules/dnn/src/tensorflow/attr_value.proto
diff --git a/contrib/modules/dnn/src/tensorflow/function.proto b/modules/dnn/src/tensorflow/function.proto
similarity index 100%
rename from contrib/modules/dnn/src/tensorflow/function.proto
rename to modules/dnn/src/tensorflow/function.proto
diff --git a/contrib/modules/dnn/src/tensorflow/graph.proto b/modules/dnn/src/tensorflow/graph.proto
similarity index 100%
rename from contrib/modules/dnn/src/tensorflow/graph.proto
rename to modules/dnn/src/tensorflow/graph.proto
diff --git a/contrib/modules/dnn/src/tensorflow/op_def.proto b/modules/dnn/src/tensorflow/op_def.proto
similarity index 100%
rename from contrib/modules/dnn/src/tensorflow/op_def.proto
rename to modules/dnn/src/tensorflow/op_def.proto
diff --git a/contrib/modules/dnn/src/tensorflow/tensor.proto b/modules/dnn/src/tensorflow/tensor.proto
similarity index 100%
rename from contrib/modules/dnn/src/tensorflow/tensor.proto
rename to modules/dnn/src/tensorflow/tensor.proto
diff --git a/contrib/modules/dnn/src/tensorflow/tensor_shape.proto b/modules/dnn/src/tensorflow/tensor_shape.proto
similarity index 100%
rename from contrib/modules/dnn/src/tensorflow/tensor_shape.proto
rename to modules/dnn/src/tensorflow/tensor_shape.proto
diff --git a/modules/dnn/src/tensorflow/tf_importer.cpp b/modules/dnn/src/tensorflow/tf_importer.cpp
new file mode 100644
index 0000000..0f07f33
--- /dev/null
+++ b/modules/dnn/src/tensorflow/tf_importer.cpp
@@ -0,0 +1,915 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+// Copyright (C) 2016, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+
+/*
+Implementation of Tensorflow models parser
+*/
+
+#include "../precomp.hpp"
+
+#ifdef HAVE_PROTOBUF
+#include "graph.pb.h"
+
+#include <iostream>
+#include <fstream>
+#include <algorithm>
+#include <string>
+#include <google/protobuf/message.h>
+#include <google/protobuf/text_format.h>
+#include <google/protobuf/io/zero_copy_stream_impl.h>
+#include "tf_io.hpp"
+#endif
+
+namespace cv {
+namespace dnn {
+CV__DNN_EXPERIMENTAL_NS_BEGIN
+
+#if HAVE_PROTOBUF
+
+using ::google::protobuf::RepeatedField;
+using ::google::protobuf::RepeatedPtrField;
+using ::google::protobuf::Message;
+using ::google::protobuf::Descriptor;
+using ::google::protobuf::FieldDescriptor;
+using ::google::protobuf::Reflection;
+
+namespace
+{
+
+static int toNCHW[] = {0, 2, 3, 1};
+
+typedef std::vector<std::pair<String, int> > StrIntVector;
+
+struct Pin
+{
+ Pin(const std::string &_name, int _blobIndex = 0) :
+ name(_name), blobIndex(_blobIndex) {}
+
+ Pin() :
+ name(""), blobIndex(-1) {}
+
+ std::string name;
+ int blobIndex;
+};
+
+void blobShapeFromTensor(const tensorflow::TensorProto &tensor, MatShape& shape)
+{
+ shape.clear();
+ if (tensor.has_tensor_shape())
+ {
+ const tensorflow::TensorShapeProto &_shape = tensor.tensor_shape();
+ int i, n = _shape.dim_size();
+ shape.resize(n);
+
+ for (i = 0; i < n; i++)
+ shape[i] = (int)_shape.dim(i).size();
+ }
+ else
+ {
+ CV_Error(Error::StsError, "Unknown shape of input tensor");
+ }
+}
+
+template <typename T>
+void parseTensor(const tensorflow::TensorProto &tensor, Mat &dstBlob)
+{
+ MatShape shape;
+ blobShapeFromTensor(tensor, shape);
+ int dims = (int)shape.size();
+
+ if (dims == 4)
+ {
+ // REORDER blob NHWC to NCHW
+ swap(shape[2], shape[3]); // NHCW
+ swap(shape[1], shape[2]); // NCHW
+ }
+
+ dstBlob.create(shape, CV_32F);
+
+ int size = tensor.tensor_content().size() / sizeof(T);
+ CV_Assert(size == (int)dstBlob.total());
+
+ float *dstData = dstBlob.ptr<float>();
+ const T *data = reinterpret_cast<const T*>(tensor.tensor_content().c_str());
+
+ if (dims == 4)
+ {
+ int num = shape[0], channels = shape[1], height = shape[2], width = shape[3];
+ int total = num*channels*height*width;
+ for(int i_n = 0; i_n < shape[0]; i_n++) {
+ for(int i_c = 0; i_c < shape[1]; i_c++) {
+ for(int i_h = 0; i_h < shape[2]; i_h++) {
+ for(int i_w = 0; i_w < shape[3]; i_w++) {
+ int dst_i = channels*height*width*i_n + height*width*i_c + width*i_h + i_w;
+ int src_i = channels*height*width*i_n + i_c + channels*width*i_h + channels*i_w;
+
+ CV_Assert(dst_i < total);
+ CV_Assert(src_i < total);
+
+ dstData[dst_i] = data[src_i];
+ }
+ }
+ }
+ }
+ } else {
+ for (int i = 0; i < size; i++)
+ dstData[i] = data[i];
+ }
+}
+
+void blobFromTensor(const tensorflow::TensorProto &tensor, Mat &dstBlob)
+{
+ switch (tensor.dtype()) {
+ case tensorflow::DT_FLOAT:
+ parseTensor<float>(tensor, dstBlob);
+ break;
+ case tensorflow::DT_DOUBLE:
+ parseTensor<double>(tensor, dstBlob);
+ break;
+ default:
+ CV_Error(Error::StsError, "Tensor's data type is not supported");
+ break;
+ }
+}
+
+void printList(const tensorflow::AttrValue::ListValue &val)
+{
+ std::cout << "(";
+ for (int i = 0; i < val.i_size(); i++)
+ std::cout << " " << val.i(i);
+ std::cout << " )";
+}
+
+void printTensorShape(const tensorflow::TensorShapeProto &shape)
+{
+ std::cout << "[ ";
+ for (int d = 0; d < shape.dim_size(); d++)
+ std::cout << shape.dim(d).name() <<
+ ":" << shape.dim(d).size() << " ";
+ std::cout << "]";
+}
+
+void printTensor(const tensorflow::TensorProto &tensor)
+{
+ printTensorShape(tensor.tensor_shape());
+
+ if (tensor.tensor_content().empty())
+ return;
+
+ switch (tensor.dtype())
+ {
+ case 1: // float
+ {
+ const float *data = reinterpret_cast<const float*>(tensor.tensor_content().c_str());
+ int size = tensor.tensor_content().size() / sizeof(float);
+ for (int i = 0; i < std::min(10, size); i++)
+ std::cout << " " << data[i];
+ if (size > 10)
+ std::cout << " ... " << size - 10 << " more";
+ break;
+ }
+ case 3: // int32
+ {
+ const int *data = reinterpret_cast<const int*>(tensor.tensor_content().c_str());
+ int size = tensor.tensor_content().size() / sizeof(int);
+ for (int i = 0; i < std::min(10, size); i++)
+ std::cout << " " << data[i];
+ if (size > 10)
+ std::cout << " ... " << size - 10 << " more";
+ break;
+ }
+ default:
+ CV_Error(Error::StsError, "Tensor type is not supported");
+ break;
+ }
+}
+
+void printLayerAttr(const tensorflow::NodeDef &layer)
+{
+ std::cout << std::endl << layer.name() << ":" << layer.op();
+ for (int ii = 0; ii < layer.input_size(); ii++)
+ std::cout << "(" << layer.input(ii) << ")";
+ std::cout << std::endl;
+ google::protobuf::Map<std::string, tensorflow::AttrValue> attr
+ = layer.attr();
+ for (google::protobuf::Map<std::string, tensorflow::AttrValue>::const_iterator ai = attr.begin();
+ ai != attr.end(); ++ai)
+ {
+ std::cout << ai->first << ":";
+ if (ai->first == "dtype" || ai->first == "T")
+ std::cout << ai->second.i();
+ else if (ai->first == "padding")
+ std::cout << ai->second.s();
+ else if (ai->first == "transpose_a" || ai->first == "transpose_b")
+ std::cout << ai->second.b();
+ // else if (ai->first == "shape")
+ // printTensorShape(ai->second.shape());
+ else if (ai->first == "strides" || ai->first == "ksize")
+ printList(ai->second.list());
+ else
+ printTensor(ai->second.tensor());
+ std::cout << std::endl;
+ }
+}
+
+bool hasLayerAttr(const tensorflow::NodeDef &layer, const std::string &name)
+{
+ google::protobuf::Map<std::string, tensorflow::AttrValue> attr = layer.attr();
+ return attr.find(name) != attr.end();
+}
+
+const tensorflow::AttrValue& getLayerAttr(const tensorflow::NodeDef &layer, const std::string &name)
+{
+ return layer.attr().at(name);
+}
+
+void setStrides(LayerParams &layerParams, const tensorflow::NodeDef &layer)
+{
+ if (hasLayerAttr(layer, "strides"))
+ {
+ const tensorflow::AttrValue& val = getLayerAttr(layer, "strides");
+ if (val.list().i_size() != 4 ||
+ val.list().i(0) != 1 || val.list().i(3) != 1)
+ CV_Error(Error::StsError, "Unsupported strides");
+ layerParams.set("stride_h", static_cast<int>(val.list().i(1)));
+ layerParams.set("stride_w", static_cast<int>(val.list().i(2)));
+ }
+}
+
+DictValue parseDims(const tensorflow::TensorProto &tensor) {
+ MatShape shape;
+ blobShapeFromTensor(tensor, shape);
+ int dims = (int)shape.size();
+
+ CV_Assert(tensor.dtype() == tensorflow::DT_INT32);
+ CV_Assert(dims == 1);
+
+ int size = tensor.tensor_content().size() / sizeof(int);
+ const int *data = reinterpret_cast<const int*>(tensor.tensor_content().c_str());
+ // TODO: add reordering shape if dims == 4
+ return DictValue::arrayInt(data, size);
+}
+
+void setKSize(LayerParams &layerParams, const tensorflow::NodeDef &layer)
+{
+ if (hasLayerAttr(layer, "ksize"))
+ {
+ const tensorflow::AttrValue& val = getLayerAttr(layer, "ksize");
+ if (val.list().i_size() != 4 ||
+ val.list().i(0) != 1 || val.list().i(3) != 1)
+ CV_Error(Error::StsError, "Unsupported ksize");
+ layerParams.set("kernel_h", static_cast<int>(val.list().i(1)));
+ layerParams.set("kernel_w", static_cast<int>(val.list().i(2)));
+ }
+ else
+ {
+ layerParams.set("kernel_h", 1);
+ layerParams.set("kernel_w", 1);
+ }
+}
+
+void setPadding(LayerParams &layerParams, const tensorflow::NodeDef &layer)
+{
+ if (hasLayerAttr(layer, "padding"))
+ layerParams.set("pad_mode", getLayerAttr(layer, "padding").s());
+}
+
+void RemoveIdentityOps(tensorflow::GraphDef& net) {
+ typedef std::map<String, String> IdentityOpsMap;
+ IdentityOpsMap identity_ops;
+
+ std::vector<int> identity_ops_idx;
+
+ int layersCount = net.node_size();
+ for (int li = 0; li < layersCount; li++)
+ {
+ const tensorflow::NodeDef &layer = net.node(li);
+ String type = layer.op();
+
+ if (type == "Identity") {
+ identity_ops_idx.push_back(li);
+ identity_ops[layer.name()] = layer.input(0);
+ }
+ }
+
+ for (int li = 0; li < layersCount; li++)
+ {
+ tensorflow::NodeDef* layer = net.mutable_node(li);
+ for (int input_id = 0; input_id < layer->input_size(); input_id++) {
+ String input_op_name = layer->input(input_id);
+ IdentityOpsMap::iterator it = identity_ops.find(input_op_name);
+
+ if (it != identity_ops.end()) {
+ layer->set_input(input_id, it->second);
+ }
+ }
+ }
+
+ std::sort(identity_ops_idx.begin(), identity_ops_idx.end());
+
+ int removed_nodes = 0;
+ for(size_t i = 0; i < identity_ops_idx.size(); i++) {
+ int start_id = identity_ops_idx[i] - removed_nodes;
+ net.mutable_node()->DeleteSubrange(start_id, 1);
+ removed_nodes++;
+ }
+}
+
+Pin parsePin(const std::string &name)
+{
+ Pin pin(name);
+
+ size_t delimiter_pos = name.find_first_of(":");
+ if (delimiter_pos != std::string::npos)
+ {
+ pin.name = name.substr(0, delimiter_pos);
+ std::istringstream(name.substr(delimiter_pos + 1)) >> pin.blobIndex;
+ }
+
+ return pin;
+}
+
+StrIntVector getNextLayers(const tensorflow::GraphDef& net, const String& layer_name, const String& type = "")
+{
+ StrIntVector layers;
+
+ for (int li = 0; li < net.node_size(); li++)
+ {
+ const tensorflow::NodeDef& layer = net.node(li);
+ for (int input_id = 0; input_id < layer.input_size(); input_id++) {
+ String input_op_name = parsePin(layer.input(input_id)).name;
+ bool type_ok = type.empty() ? true : type == layer.op();
+ if (input_op_name == layer_name && type_ok)
+ layers.push_back(std::make_pair(layer.name(), li));
+ }
+ }
+
+ return layers;
+}
+
+void ExcludeLayer(tensorflow::GraphDef& net, const int layer_index, const int input_blob_index, bool remove_from_net = true) {
+ String layer_name = net.node(layer_index).name();
+ StrIntVector layers = getNextLayers(net, layer_name);
+
+ String removed_layer_input = net.node(layer_index).input(input_blob_index);
+
+ for (size_t i = 0; i < layers.size(); i++)
+ {
+ tensorflow::NodeDef* layer = net.mutable_node(layers[i].second);
+ for (int input_id = 0; input_id < layer->input_size(); input_id++) {
+ String input_op_name = layer->input(input_id);
+
+ if (input_op_name == layer_name) {
+ layer->set_input(input_id, removed_layer_input);
+ }
+ }
+ }
+
+ if (remove_from_net)
+ net.mutable_node()->DeleteSubrange(layer_index, 1);
+}
+
+class TFImporter : public Importer {
+public:
+ TFImporter(const char *model);
+ void populateNet(Net dstNet);
+ ~TFImporter() {}
+
+private:
+ void kernelFromTensor(const tensorflow::TensorProto &tensor, Mat &dstBlob);
+
+ void connect(const std::map<String, int>& layers_name_id_map, Net& network, const Pin& outPin,
+ const int input_layer_id, const int input_blob_id);
+ void connectToAllBlobs(const std::map<String, int>& layer_id, Net& network, const Pin& outPin,
+ const int input_layer_id, const int input_blobs_count);
+ const tensorflow::TensorProto& getConstBlob(const tensorflow::NodeDef &layer, std::map<String, int> const_layers,
+ int input_blob_index = -1, int* actual_inp_blob_idx = 0);
+
+
+ tensorflow::GraphDef net;
+};
+
+TFImporter::TFImporter(const char *model)
+{
+ if (model && model[0])
+ ReadTFNetParamsFromBinaryFileOrDie(model, &net);
+}
+
+void TFImporter::kernelFromTensor(const tensorflow::TensorProto &tensor, Mat &dstBlob)
+{
+ MatShape shape;
+ blobShapeFromTensor(tensor, shape);
+ int dims = (int)shape.size();
+
+ // TODO: other blob types
+ CV_Assert(tensor.dtype() == tensorflow::DT_FLOAT);
+ CV_Assert(dims == 4);
+
+ // REORDER kernel HWIO to OIHW
+ swap(shape[0], shape[2]); // IWHO
+ swap(shape[1], shape[3]); // IOHW
+ swap(shape[0], shape[1]); // OIHW
+
+ dstBlob.create(shape, CV_32F);
+
+ int size = tensor.tensor_content().size() / sizeof(float);
+ CV_Assert(size == (int)dstBlob.total());
+
+ float *dstData = dstBlob.ptr<float>();
+ const float *data = reinterpret_cast<const float*>(tensor.tensor_content().c_str());
+
+ int out_c = shape[0], input_c = shape[1], height = shape[2], width = shape[3];
+ int total = out_c*input_c*height*width;
+ for(int i_oc = 0; i_oc < out_c; i_oc++) {
+ for(int i_ic = 0; i_ic < input_c; i_ic++) {
+ for(int i_h = 0; i_h < height; i_h++) {
+ for(int i_w = 0; i_w < width; i_w++) {
+ int dst_i = input_c*height*width*i_oc + height*width*i_ic + width*i_h + i_w;
+ int src_i = out_c*input_c*width*i_h + out_c*input_c*i_w + out_c*i_ic + i_oc;
+ CV_Assert(dst_i < total);
+ CV_Assert(src_i < total);
+ dstData[dst_i] = data[src_i];
+ }
+ }
+ }
+ }
+}
+
+void TFImporter::connect(const std::map<String, int>& layers_name_id_map, Net& network, const Pin& outPin,
+ const int input_layer_id, const int input_blob_id)
+{
+ std::map<String, int>::const_iterator it = layers_name_id_map.find(outPin.name);
+ if (it == layers_name_id_map.end())
+ CV_Error(Error::StsError, "Input layer not found: " + outPin.name);
+ network.connect(it->second, outPin.blobIndex, input_layer_id, input_blob_id);
+}
+
+void TFImporter::connectToAllBlobs(const std::map<String, int>& layer_id, Net& network, const Pin& outPin,
+ const int input_layer_id, const int input_blobs_count)
+{
+ for (int input_blob_id = 0; input_blob_id < input_blobs_count; input_blob_id++)
+ connect(layer_id, network, outPin, input_layer_id, input_blob_id);
+}
+
+const tensorflow::TensorProto& TFImporter::getConstBlob(const tensorflow::NodeDef &layer, std::map<String, int> const_layers,
+ int input_blob_index, int* actual_inp_blob_idx) {
+ if (input_blob_index == -1) {
+ for(int i = 0; i < layer.input_size(); i++) {
+ Pin input = parsePin(layer.input(i));
+ if (const_layers.find(input.name) != const_layers.end()) {
+ if (input_blob_index != -1)
+ CV_Error(Error::StsError, "More than one input is Const op");
+
+ input_blob_index = i;
+ }
+ }
+ }
+
+ if (input_blob_index == -1)
+ CV_Error(Error::StsError, "Const input blob for weights not found");
+
+ Pin kernel_inp = parsePin(layer.input(input_blob_index));
+ if (const_layers.find(kernel_inp.name) == const_layers.end())
+ CV_Error(Error::StsError, "Const kernel input not found");
+ if (kernel_inp.blobIndex != 0)
+ CV_Error(Error::StsError, "Unsupported kernel input");
+
+ if(actual_inp_blob_idx) {
+ *actual_inp_blob_idx = input_blob_index;
+ }
+
+ return net.node(const_layers.at(kernel_inp.name)).attr().at("value").tensor();
+}
+
+
+void TFImporter::populateNet(Net dstNet)
+{
+ RemoveIdentityOps(net);
+
+ std::map<int, String> layers_to_ignore;
+
+ int layersSize = net.node_size();
+
+ // find all Const layers for params
+ std::map<String, int> value_id;
+ for (int li = 0; li < layersSize; li++)
+ {
+ const tensorflow::NodeDef &layer = net.node(li);
+ String name = layer.name();
+ String type = layer.op();
+
+ if (type != "Const")
+ continue; // only Const parameters are supported
+
+ if (layer.attr().find("value") != layer.attr().end())
+ {
+ value_id.insert(std::make_pair(name, li));
+ }
+
+ layers_to_ignore[li] = name;
+ }
+
+ std::map<String, int> layer_id;
+
+ for (int li = 0; li < layersSize; li++)
+ {
+ const tensorflow::NodeDef &layer = net.node(li);
+ String name = layer.name();
+ String type = layer.op();
+ LayerParams layerParams;
+
+ if(layers_to_ignore.find(li) != layers_to_ignore.end())
+ continue;
+
+ if (type == "Conv2D")
+ {
+ layerParams.set("bias_term", false);
+ layerParams.blobs.resize(1);
+
+ StrIntVector next_layers = getNextLayers(net, name, "BiasAdd");
+ if (next_layers.size() == 1) {
+ layerParams.set("bias_term", true);
+ layerParams.blobs.resize(2);
+
+ int weights_layer_index = next_layers[0].second;
+
+ blobFromTensor(getConstBlob(net.node(weights_layer_index), value_id), layerParams.blobs[1]);
+ ExcludeLayer(net, weights_layer_index, 0, false);
+ layers_to_ignore[weights_layer_index] = next_layers[0].first;
+ }
+
+ kernelFromTensor(getConstBlob(layer, value_id), layerParams.blobs[0]);
+ const int* kshape = layerParams.blobs[0].size.p;
+ layerParams.set("kernel_h", kshape[2]);
+ layerParams.set("kernel_w", kshape[3]);
+ layerParams.set("num_output", kshape[0]);
+
+ setStrides(layerParams, layer);
+ setPadding(layerParams, layer);
+
+ int id = dstNet.addLayer(name, "Convolution", layerParams);
+ layer_id[name] = id;
+
+ // one input only
+ connect(layer_id, dstNet, parsePin(layer.input(0)), id, 0);
+ }
+ else if (type == "BiasAdd" || type == "Add")
+ {
+ bool haveConst = false;
+ for(int ii = 0; !haveConst && ii < layer.input_size(); ++ii)
+ {
+ Pin input = parsePin(layer.input(ii));
+ haveConst = value_id.find(input.name) != value_id.end();
+ }
+ CV_Assert(!haveConst || layer.input_size() == 2);
+
+ if (haveConst)
+ {
+ layerParams.blobs.resize(1);
+ blobFromTensor(getConstBlob(layer, value_id), layerParams.blobs[0]);
+
+ int id = dstNet.addLayer(name, "Shift", layerParams);
+ layer_id[name] = id;
+
+ // one input only
+ connect(layer_id, dstNet, parsePin(layer.input(0)), id, 0);
+ }
+ else
+ {
+ layerParams.set("operation", "sum");
+ int id = dstNet.addLayer(name, "Eltwise", layerParams);
+ layer_id[name] = id;
+
+ for (int ii = 0; ii < layer.input_size(); ii++)
+ {
+ Pin inp = parsePin(layer.input(ii));
+ if (layer_id.find(inp.name) == layer_id.end())
+ CV_Error(Error::StsError, "Input layer not found: " + inp.name);
+ dstNet.connect(layer_id.at(inp.name), inp.blobIndex, id, ii);
+ }
+ }
+ }
+ else if (type == "MatMul")
+ {
+ CV_Assert(layer.input_size() == 2);
+
+ layerParams.set("bias_term", false);
+ layerParams.blobs.resize(1);
+
+ StrIntVector next_layers = getNextLayers(net, name, "BiasAdd");
+ if (next_layers.size() == 1) {
+ layerParams.set("bias_term", true);
+ layerParams.blobs.resize(2);
+
+ int weights_layer_index = next_layers[0].second;
+ blobFromTensor(getConstBlob(net.node(weights_layer_index), value_id), layerParams.blobs[1]);
+ ExcludeLayer(net, weights_layer_index, 0, false);
+ layers_to_ignore[weights_layer_index] = next_layers[0].first;
+ }
+
+ int kernel_blob_index = -1;
+ blobFromTensor(getConstBlob(layer, value_id, -1, &kernel_blob_index), layerParams.blobs[0]);
+
+ if (kernel_blob_index == 1) { // In this case output is computed by x*W formula - W should be transposed
+ Mat data = layerParams.blobs[0].t();
+ layerParams.blobs[0] = data.clone();
+ }
+
+ layerParams.set("num_output", layerParams.blobs[0].size[0]);
+
+ int id = dstNet.addLayer(name, "InnerProduct", layerParams);
+ layer_id[name] = id;
+
+ // one input only
+ int input_blob_index = kernel_blob_index == 0 ? 1 : 0;
+ connect(layer_id, dstNet, parsePin(layer.input(input_blob_index)), id, 0);
+ }
+ else if (type == "Reshape")
+ {
+ layerParams.set("dim", parseDims(getConstBlob(layer, value_id, 1)));
+ layerParams.set("reorder_dims", true);
+
+ int id = dstNet.addLayer(name, "Reshape", layerParams);
+ layer_id[name] = id;
+
+ // one input only
+ connect(layer_id, dstNet, parsePin(layer.input(0)), id, 0);
+ }
+ else if (type == "Const")
+ {
+ }
+ else if (type == "LRN")
+ {
+ if(hasLayerAttr(layer, "alpha")) {
+ layerParams.set("alpha", getLayerAttr(layer, "alpha").f());
+ }
+ if(hasLayerAttr(layer, "beta")) {
+ layerParams.set("beta", getLayerAttr(layer, "beta").f());
+ }
+ if(hasLayerAttr(layer, "depth_radius")) {
+ int radius = (int)getLayerAttr(layer, "depth_radius").i();
+ layerParams.set("local_size", 2*radius + 1);
+ }
+ if(hasLayerAttr(layer, "bias")) {
+ layerParams.set("bias", getLayerAttr(layer, "bias").f());
+ }
+ layerParams.set("norm_by_size", false);
+
+ int id = dstNet.addLayer(name, "LRN", layerParams);
+ layer_id[name] = id;
+
+ connectToAllBlobs(layer_id, dstNet, parsePin(layer.input(0)), id, layer.input_size());
+ }
+ else if (type == "Concat" || type == "ConcatV2")
+ {
+ int axisId = (type == "Concat" ? 0 : layer.input_size() - 1);
+ int axis = getConstBlob(layer, value_id, axisId).int_val().Get(0);
+ layerParams.set("axis", toNCHW[axis]);
+
+ int id = dstNet.addLayer(name, "Concat", layerParams);
+ layer_id[name] = id;
+
+
+ int from = (type == "Concat" ? 1 : 0);
+ int to = (type == "Concat" ? layer.input_size() : layer.input_size() - 1);
+
+ // input(0) or input(n-1) is concat_dim
+ for (int ii = from; ii < to; ii++)
+ {
+ Pin inp = parsePin(layer.input(ii));
+ if (layer_id.find(inp.name) == layer_id.end())
+ CV_Error(Error::StsError, "Input layer not found: " + inp.name);
+ dstNet.connect(layer_id.at(inp.name), inp.blobIndex, id, ii - from);
+ }
+ }
+ else if (type == "MaxPool")
+ {
+ layerParams.set("pool", "max");
+
+ setKSize(layerParams, layer);
+ setStrides(layerParams, layer);
+ setPadding(layerParams, layer);
+
+ int id = dstNet.addLayer(name, "Pooling", layerParams);
+ layer_id[name] = id;
+
+ connectToAllBlobs(layer_id, dstNet, parsePin(layer.input(0)), id, layer.input_size());
+ }
+ else if (type == "AvgPool")
+ {
+ layerParams.set("pool", "ave");
+
+ setKSize(layerParams, layer);
+ setStrides(layerParams, layer);
+ setPadding(layerParams, layer);
+
+ int id = dstNet.addLayer(name, "Pooling", layerParams);
+ layer_id[name] = id;
+
+ connectToAllBlobs(layer_id, dstNet, parsePin(layer.input(0)), id, layer.input_size());
+ }
+ else if (type == "Placeholder")
+ {
+ std::vector<String> netInputs(1);
+ netInputs[0] = name;
+ layer_id[name] = 0;
+ dstNet.setInputsNames(netInputs);
+ }
+ else if (type == "Split") {
+ // TODO: determing axis index remapping by input dimensions order of input blob
+ // TODO: slicing input may be Const op
+ // TODO: slicing kernels for convolutions - in current implenmentation it is impossible
+ // TODO: add parsing num of slices parameter
+ CV_Assert(layer.input_size() == 2);
+ // num_split
+ // 1st blob is dims tensor
+ layerParams.set("slice_point", DictValue::arrayReal((double*)0, 0));
+
+ int axis = getConstBlob(layer, value_id, 0).int_val().Get(0);
+ layerParams.set("axis", toNCHW[axis]);
+
+ int id = dstNet.addLayer(name, "Slice", layerParams);
+ layer_id[name] = id;
+
+ // one input only
+ connect(layer_id, dstNet, parsePin(layer.input(1)), id, 0);
+ }
+ else if (type == "Mul")
+ {
+ bool haveConst = false;
+ for(int ii = 0; !haveConst && ii < layer.input_size(); ++ii)
+ {
+ Pin input = parsePin(layer.input(ii));
+ haveConst = value_id.find(input.name) != value_id.end();
+ }
+ CV_Assert(!haveConst || layer.input_size() == 2);
+
+ if (haveConst)
+ {
+ // Multiplication by constant.
+ CV_Assert(layer.input_size() == 2);
+
+ float scale = getConstBlob(layer, value_id).float_val()[0];
+ layerParams.set("scale", scale);
+
+ int id = dstNet.addLayer(name, "Power", layerParams);
+ layer_id[name] = id;
+
+ Pin inp0 = parsePin(layer.input(0));
+ if (layer_id.find(inp0.name) != layer_id.end())
+ // First operand is a constant.
+ connect(layer_id, dstNet, parsePin(layer.input(0)), id, 0);
+ else
+ connect(layer_id, dstNet, parsePin(layer.input(1)), id, 0);
+ }
+ else
+ {
+ layerParams.set("operation", "prod");
+ int id = dstNet.addLayer(name, "Eltwise", layerParams);
+ layer_id[name] = id;
+
+ for (int ii = 0; ii < layer.input_size(); ii++)
+ {
+ Pin inp = parsePin(layer.input(ii));
+ if (layer_id.find(inp.name) == layer_id.end())
+ CV_Error(Error::StsError, "Input layer not found: " + inp.name);
+ dstNet.connect(layer_id.at(inp.name), inp.blobIndex, id, ii);
+ }
+ }
+ }
+ else if (type == "Pad")
+ {
+ tensorflow::TensorProto paddings = getConstBlob(layer, value_id, 1);
+ MatShape shape;
+ blobShapeFromTensor(paddings, shape);
+ if (shape[0] != 4)
+ CV_Error(Error::StsError, "Expected NHWC data format");
+
+ // Copy tensor with paddings.
+ std::vector<int32_t> values(shape[0] * 2);
+ CV_Assert(sizeof(int32_t) * values.size() ==
+ paddings.tensor_content().size());
+ memcpy(&values[0], &paddings.tensor_content()[0],
+ paddings.tensor_content().size());
+
+ // Allow only one padding operation per layer.
+ bool padded = false;
+ for (int i = 0; i < values.size(); ++i)
+ {
+ if (values[i])
+ {
+ if (padded)
+ CV_Error(Error::StsError,
+ "Only single padding operation per layer is supported");
+ padded = true;
+
+ int axis = i / 2;
+ // Remap NHWC to NCHW.
+ // 0 -> 0
+ // 1 -> 2
+ // 2 -> 3
+ // 3 -> 1
+ if (axis != 0)
+ axis = axis % 3 + 1;
+
+ layerParams.set("padding_dim", axis);
+ if (i % 2) // Pad after
+ layerParams.set("padding", values[i]);
+ else // Pad before
+ layerParams.set("padding", -1 * values[i]);
+
+ int id = dstNet.addLayer(name, "Padding", layerParams);
+ layer_id[name] = id;
+
+ connect(layer_id, dstNet, parsePin(layer.input(0)), id, 0);
+ }
+ }
+ }
+ else if (type == "FusedBatchNorm")
+ {
+ // op: "FusedBatchNorm"
+ // input: "input"
+ // input: "BatchNorm/gamma"
+ // input: "BatchNorm/beta"
+ // input: "BatchNorm/moving_mean"
+ // input: "BatchNorm/moving_variance"
+ if (layer.input_size() != 5)
+ CV_Error(Error::StsNotImplemented,
+ "Expected gamma, beta, mean and std");
+
+ layerParams.blobs.resize(4);
+ // gamma
+ blobFromTensor(getConstBlob(layer, value_id, 1), layerParams.blobs[2]);
+ // beta
+ blobFromTensor(getConstBlob(layer, value_id, 2), layerParams.blobs[3]);
+ // mean
+ blobFromTensor(getConstBlob(layer, value_id, 3), layerParams.blobs[0]);
+ // std
+ blobFromTensor(getConstBlob(layer, value_id, 4), layerParams.blobs[1]);
+
+ if (hasLayerAttr(layer, "epsilon"))
+ layerParams.set("eps", getLayerAttr(layer, "epsilon").f());
+
+ layerParams.set("has_weight", true);
+ layerParams.set("has_bias", true);
+
+ int id = dstNet.addLayer(name, "BatchNorm", layerParams);
+ layer_id[name] = id;
+
+ // one input only
+ connect(layer_id, dstNet, parsePin(layer.input(0)), id, 0);
+ }
+ else if (type == "Abs" || type == "Tanh" || type == "Sigmoid" ||
+ type == "Relu" || type == "Elu" || type == "Softmax" ||
+ type == "Identity")
+ {
+ std::string dnnType = type;
+ if (type == "Abs") dnnType = "AbsVal";
+ else if (type == "Tanh") dnnType = "TanH";
+ else if (type == "Relu") dnnType = "ReLU";
+ else if (type == "Elu") dnnType = "ELU";
+
+ int id = dstNet.addLayer(name, dnnType, layerParams);
+ layer_id[name] = id;
+ connectToAllBlobs(layer_id, dstNet, parsePin(layer.input(0)), id, layer.input_size());
+ }
+ else
+ {
+ printLayerAttr(layer);
+ CV_Error_(Error::StsError, ("Unknown layer type %s in op %s", type.c_str(), name.c_str()));
+ }
+ }
+}
+
+} // namespace
+
+Ptr<Importer> createTensorflowImporter(const String &model)
+{
+ return Ptr<Importer>(new TFImporter(model.c_str()));
+}
+
+#else //HAVE_PROTOBUF
+
+Ptr<Importer> createTensorflowImporter(const String&)
+{
+ CV_Error(cv::Error::StsNotImplemented, "libprotobuf required to import data from TensorFlow models");
+ return Ptr<Importer>();
+}
+
+#endif //HAVE_PROTOBUF
+
+Net readNetFromTensorflow(const String &model)
+{
+ Ptr<Importer> importer = createTensorflowImporter(model);
+ Net net;
+ if (importer)
+ importer->populateNet(net);
+ return net;
+}
+
+CV__DNN_EXPERIMENTAL_NS_END
+}} // namespace
diff --git a/modules/dnn/src/tensorflow/tf_io.cpp b/modules/dnn/src/tensorflow/tf_io.cpp
new file mode 100644
index 0000000..d96d006
--- /dev/null
+++ b/modules/dnn/src/tensorflow/tf_io.cpp
@@ -0,0 +1,63 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+// Copyright (C) 2016, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+
+/*
+Implementation of various functions which are related to Tensorflow models reading.
+*/
+
+#ifdef HAVE_PROTOBUF
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/io/zero_copy_stream_impl.h>
+#include <google/protobuf/text_format.h>
+
+#include <opencv2/core.hpp>
+
+#include <map>
+#include <string>
+#include <fstream>
+#include <vector>
+
+#include "graph.pb.h"
+#include "tf_io.hpp"
+#include "../caffe/glog_emulator.hpp"
+
+namespace cv {
+namespace dnn {
+
+using std::string;
+using std::map;
+using namespace tensorflow;
+using namespace ::google::protobuf;
+using namespace ::google::protobuf::io;
+
+const int kProtoReadBytesLimit = INT_MAX; // Max size of 2 GB minus 1 byte.
+
+// TODO: remove Caffe duplicate
+bool ReadProtoFromBinaryFileTF(const char* filename, Message* proto) {
+ std::ifstream fs(filename, std::ifstream::in | std::ifstream::binary);
+ CHECK(fs.is_open()) << "Can't open \"" << filename << "\"";
+ ZeroCopyInputStream* raw_input = new IstreamInputStream(&fs);
+ CodedInputStream* coded_input = new CodedInputStream(raw_input);
+ coded_input->SetTotalBytesLimit(kProtoReadBytesLimit, 536870912);
+
+ bool success = proto->ParseFromCodedStream(coded_input);
+
+ delete coded_input;
+ delete raw_input;
+ fs.close();
+ return success;
+}
+
+void ReadTFNetParamsFromBinaryFileOrDie(const char* param_file,
+ tensorflow::GraphDef* param) {
+ CHECK(ReadProtoFromBinaryFileTF(param_file, param))
+ << "Failed to parse GraphDef file: " << param_file;
+}
+
+}
+}
+#endif
diff --git a/modules/dnn/src/tensorflow/tf_io.hpp b/modules/dnn/src/tensorflow/tf_io.hpp
new file mode 100644
index 0000000..a3abd1d
--- /dev/null
+++ b/modules/dnn/src/tensorflow/tf_io.hpp
@@ -0,0 +1,29 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+// Copyright (C) 2016, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+
+/*
+Declaration of various functions which are related to Tensorflow models reading.
+*/
+
+#ifndef __OPENCV_DNN_TF_IO_HPP__
+#define __OPENCV_DNN_TF_IO_HPP__
+#ifdef HAVE_PROTOBUF
+
+#include "graph.pb.h"
+
+namespace cv {
+namespace dnn {
+
+// Read parameters from a file into a GraphDef proto message.
+void ReadTFNetParamsFromBinaryFileOrDie(const char* param_file,
+ tensorflow::GraphDef* param);
+
+}
+}
+
+#endif
+#endif
diff --git a/contrib/modules/dnn/src/tensorflow/types.proto b/modules/dnn/src/tensorflow/types.proto
similarity index 100%
rename from contrib/modules/dnn/src/tensorflow/types.proto
rename to modules/dnn/src/tensorflow/types.proto
diff --git a/contrib/modules/dnn/src/tensorflow/versions.proto b/modules/dnn/src/tensorflow/versions.proto
similarity index 100%
rename from contrib/modules/dnn/src/tensorflow/versions.proto
rename to modules/dnn/src/tensorflow/versions.proto
diff --git a/contrib/modules/dnn/src/torch/COPYRIGHT.txt b/modules/dnn/src/torch/COPYRIGHT.txt
similarity index 100%
rename from contrib/modules/dnn/src/torch/COPYRIGHT.txt
rename to modules/dnn/src/torch/COPYRIGHT.txt
diff --git a/modules/dnn/src/torch/THDiskFile.cpp b/modules/dnn/src/torch/THDiskFile.cpp
new file mode 100644
index 0000000..5f63ced
--- /dev/null
+++ b/modules/dnn/src/torch/THDiskFile.cpp
@@ -0,0 +1,532 @@
+#include "../precomp.hpp"
+#if defined(ENABLE_TORCH_IMPORTER) && ENABLE_TORCH_IMPORTER
+#include "THGeneral.h"
+#include "THDiskFile.h"
+#include "THFilePrivate.h"
+
+namespace TH
+{
+
+typedef struct THDiskFile__
+{
+ THFile file;
+
+ FILE *handle;
+ char *name;
+ int isNativeEncoding;
+ int longSize;
+
+} THDiskFile;
+
+static int THDiskFile_isOpened(THFile *self)
+{
+ THDiskFile *dfself = (THDiskFile*)self;
+ return (dfself->handle != NULL);
+}
+
+const char *THDiskFile_name(THFile *self)
+{
+ THDiskFile *dfself = (THDiskFile*)self;
+ return dfself->name;
+}
+
+/* workaround mac osx lion ***insane*** fread bug */
+#ifdef __APPLE__
+static size_t fread__(void *ptr, size_t size, size_t nitems, FILE *stream)
+{
+ size_t nread = 0;
+ while(!feof(stream) && !ferror(stream) && (nread < nitems))
+ nread += fread((char*)ptr+nread*size, size, std::min<size_t>(2147483648UL/size, nitems-nread), stream);
+ return nread;
+}
+#else
+#define fread__ fread
+#endif
+
+#define READ_WRITE_METHODS(TYPE, TYPEC, ASCII_READ_ELEM, ASCII_WRITE_ELEM) \
+ static long THDiskFile_read##TYPEC(THFile *self, TYPE *data, long n) \
+ { \
+ THDiskFile *dfself = (THDiskFile*)(self); \
+ long nread = 0L; \
+ \
+ THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file"); \
+ THArgCheck(dfself->file.isReadable, 1, "attempt to read in a write-only file"); \
+ \
+ if(dfself->file.isBinary) \
+ { \
+ nread = fread__(data, sizeof(TYPE), n, dfself->handle); \
+ if(!dfself->isNativeEncoding && (sizeof(TYPE) > 1) && (nread > 0)) \
+ THDiskFile_reverseMemory(data, data, sizeof(TYPE), nread); \
+ } \
+ else \
+ { \
+ long i; \
+ for(i = 0; i < n; i++) \
+ { \
+ ASCII_READ_ELEM; /* increment here result and break if wrong */ \
+ } \
+ if(dfself->file.isAutoSpacing && (n > 0)) \
+ { \
+ int c = fgetc(dfself->handle); \
+ if( (c != '\n') && (c != EOF) ) \
+ ungetc(c, dfself->handle); \
+ } \
+ } \
+ \
+ if(nread != n) \
+ { \
+ dfself->file.hasError = 1; /* shouldn't we put hasError to 0 all the time ? */ \
+ if(!dfself->file.isQuiet) \
+ THError("read error: read %d blocks instead of %d", nread, n); \
+ } \
+ \
+ return nread; \
+ }
+
+static int THDiskFile_mode(const char *mode, int *isReadable, int *isWritable)
+{
+ *isReadable = 0;
+ *isWritable = 0;
+ if(strlen(mode) == 1)
+ {
+ if(*mode == 'r')
+ {
+ *isReadable = 1;
+ return 1;
+ }
+ else if(*mode == 'w')
+ {
+ *isWritable = 1;
+ return 1;
+ }
+ }
+ else if(strlen(mode) == 2)
+ {
+ if(mode[0] == 'r' && mode[1] == 'w')
+ {
+ *isReadable = 1;
+ *isWritable = 1;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static void THDiskFile_seek(THFile *self, long position)
+{
+ THDiskFile *dfself = (THDiskFile*)(self);
+
+ THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
+
+#if defined(_WIN64)
+ if(_fseeki64(dfself->handle, (__int64)position, SEEK_SET) < 0)
+#elif defined(_WIN32)
+ if(fseek(dfself->handle, (long)position, SEEK_SET) < 0)
+#else
+ if(fseeko(dfself->handle, (off_t)position, SEEK_SET) < 0)
+#endif
+ {
+ dfself->file.hasError = 1;
+ if(!dfself->file.isQuiet)
+ THError("unable to seek at position %d", position);
+ }
+}
+
+static void THDiskFile_seekEnd(THFile *self)
+{
+ THDiskFile *dfself = (THDiskFile*)(self);
+
+ THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
+
+#if defined(_WIN64)
+ if(_fseeki64(dfself->handle, 0L, SEEK_END) < 0)
+#elif defined(_WIN32)
+ if(fseek(dfself->handle, 0L, SEEK_END) < 0)
+#else
+ if(fseeko(dfself->handle, 0L, SEEK_END) < 0)
+#endif
+ {
+ dfself->file.hasError = 1;
+ if(!dfself->file.isQuiet)
+ THError("unable to seek at end of file");
+ }
+}
+
+static long THDiskFile_position(THFile *self)
+{
+ THDiskFile *dfself = (THDiskFile*)(self);
+ THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
+
+#if defined(_WIN64)
+ __int64 offset = _ftelli64(dfself->handle);
+#elif defined(_WIN32)
+ long offset = ftell(dfself->handle);
+#else
+ off_t offset = ftello(dfself->handle);
+#endif
+ if (offset > -1)
+ return (long)offset;
+ else if(!dfself->file.isQuiet)
+ THError("unable to obtain disk file offset (maybe a long overflow occurred)");
+
+ return 0;
+}
+
+static void THDiskFile_close(THFile *self)
+{
+ THDiskFile *dfself = (THDiskFile*)(self);
+ THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
+ fclose(dfself->handle);
+ dfself->handle = NULL;
+}
+
+/* Little and Big Endian */
+
+static void THDiskFile_reverseMemory(void *dst, const void *src, long blockSize, long numBlocks)
+{
+ if(blockSize != 1)
+ {
+ long halfBlockSize = blockSize/2;
+ char *charSrc = (char*)src;
+ char *charDst = (char*)dst;
+ long b, i;
+ for(b = 0; b < numBlocks; b++)
+ {
+ for(i = 0; i < halfBlockSize; i++)
+ {
+ char z = charSrc[i];
+ charDst[i] = charSrc[blockSize-1-i];
+ charDst[blockSize-1-i] = z;
+ }
+ charSrc += blockSize;
+ charDst += blockSize;
+ }
+ }
+}
+
+int THDiskFile_isLittleEndianCPU(void)
+{
+ int x = 7;
+ char *ptr = (char *)&x;
+
+ if(ptr[0] == 0)
+ return 0;
+ else
+ return 1;
+}
+
+int THDiskFile_isBigEndianCPU(void)
+{
+ return(!THDiskFile_isLittleEndianCPU());
+}
+
+void THDiskFile_nativeEndianEncoding(THFile *self)
+{
+ THDiskFile *dfself = (THDiskFile*)(self);
+ THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
+ dfself->isNativeEncoding = 1;
+}
+
+void THDiskFile_littleEndianEncoding(THFile *self)
+{
+ THDiskFile *dfself = (THDiskFile*)(self);
+ THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
+ dfself->isNativeEncoding = THDiskFile_isLittleEndianCPU();
+}
+
+void THDiskFile_bigEndianEncoding(THFile *self)
+{
+ THDiskFile *dfself = (THDiskFile*)(self);
+ THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
+ dfself->isNativeEncoding = !THDiskFile_isLittleEndianCPU();
+}
+
+/* End of Little and Big Endian Stuff */
+
+void THDiskFile_longSize(THFile *self, int size)
+{
+ THDiskFile *dfself = (THDiskFile*)(self);
+ THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
+ THArgCheck(size == 0 || size == 4 || size == 8, 1, "Invalid long size specified");
+ dfself->longSize = size;
+}
+
+void THDiskFile_noBuffer(THFile *self)
+{
+ THDiskFile *dfself = (THDiskFile*)(self);
+ THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
+ if (setvbuf(dfself->handle, NULL, _IONBF, 0)) {
+ THError("error: cannot disable buffer");
+ }
+}
+
+static void THDiskFile_free(THFile *self)
+{
+ THDiskFile *dfself = (THDiskFile*)(self);
+ if(dfself->handle)
+ fclose(dfself->handle);
+ THFree(dfself->name);
+ THFree(dfself);
+}
+
+/* Note that we do a trick */
+READ_WRITE_METHODS(unsigned char, Byte,
+ nread = fread(data, 1, n, dfself->handle); break,
+ nwrite = fwrite(data, 1, n, dfself->handle); break)
+
+READ_WRITE_METHODS(char, Char,
+ nread = fread(data, 1, n, dfself->handle); break,
+ nwrite = fwrite(data, 1, n, dfself->handle); break)
+
+READ_WRITE_METHODS(short, Short,
+ int ret = fscanf(dfself->handle, "%hd", &data[i]); if(ret <= 0) break; else nread++,
+ int ret = fprintf(dfself->handle, "%hd", data[i]); if(ret <= 0) break; else nwrite++)
+
+READ_WRITE_METHODS(int, Int,
+ int ret = fscanf(dfself->handle, "%d\n\r", &data[i]); if(ret <= 0) break; else nread++,
+ int ret = fprintf(dfself->handle, "%d", data[i]); if(ret <= 0) break; else nwrite++)
+
+/*READ_WRITE_METHODS(long, Long,
+ int ret = fscanf(dfself->handle, "%ld", &data[i]); if(ret <= 0) break; else nread++,
+ int ret = fprintf(dfself->handle, "%ld", data[i]); if(ret <= 0) break; else nwrite++)*/
+
+READ_WRITE_METHODS(float, Float,
+ int ret = fscanf(dfself->handle, "%g", &data[i]); if(ret <= 0) break; else nread++,
+ int ret = fprintf(dfself->handle, "%.9g", data[i]); if(ret <= 0) break; else nwrite++)
+
+READ_WRITE_METHODS(double, Double,
+ int ret = fscanf(dfself->handle, "%lg", &data[i]); if(ret <= 0) break; else nread++,
+ int ret = fprintf(dfself->handle, "%.17g", data[i]); if(ret <= 0) break; else nwrite++)
+
+
+/* For Long we need to rewrite everything, because of the special management of longSize */
+static long THDiskFile_readLong(THFile *self, int64 *data, long n)
+{
+ THDiskFile *dfself = (THDiskFile*)(self);
+ long nread = 0L;
+
+ THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
+ THArgCheck(dfself->file.isReadable, 1, "attempt to read in a write-only file");
+
+ if(dfself->file.isBinary)
+ {
+ if(dfself->longSize == 0 || dfself->longSize == sizeof(int64))
+ {
+ nread = fread__(data, sizeof(int64), n, dfself->handle);
+ if(!dfself->isNativeEncoding && (sizeof(int64) > 1) && (nread > 0))
+ THDiskFile_reverseMemory(data, data, sizeof(int64), nread);
+ } else if(dfself->longSize == 4)
+ {
+ nread = fread__(data, 4, n, dfself->handle);
+ if(!dfself->isNativeEncoding && (nread > 0))
+ THDiskFile_reverseMemory(data, data, 4, nread);
+ long i;
+ for(i = nread; i > 0; i--)
+ data[i-1] = ((int *)data)[i-1];
+ }
+ else /* if(dfself->longSize == 8) */
+ {
+ int big_endian = !THDiskFile_isLittleEndianCPU();
+ int32_t *buffer = (int32_t*)THAlloc(8*n);
+ if (!buffer)
+ THError("can not allocate buffer");
+ nread = fread__(buffer, 8, n, dfself->handle);
+ long i;
+ for(i = nread; i > 0; i--)
+ data[i-1] = buffer[2*(i-1) + big_endian];
+ THFree(buffer);
+ if(!dfself->isNativeEncoding && (nread > 0))
+ THDiskFile_reverseMemory(data, data, 4, nread);
+ }
+ }
+ else
+ {
+ long i;
+ for(i = 0; i < n; i++)
+ {
+ long d;
+ int ret = fscanf(dfself->handle, "%ld", &d); if(ret <= 0) break; else nread++;
+ data[i] = d;
+ }
+ if(dfself->file.isAutoSpacing && (n > 0))
+ {
+ int c = fgetc(dfself->handle);
+ if( (c != '\n') && (c != EOF) )
+ ungetc(c, dfself->handle);
+ }
+ }
+
+ if(nread != n)
+ {
+ dfself->file.hasError = 1; /* shouldn't we put hasError to 0 all the time ? */
+ if(!dfself->file.isQuiet)
+ THError("read error: read %d blocks instead of %d", nread, n);
+ }
+
+ return nread;
+}
+
+
+static long THDiskFile_readString(THFile *self, const char *format, char **str_)
+{
+ THDiskFile *dfself = (THDiskFile*)(self);
+ THArgCheck(dfself->handle != NULL, 1, "attempt to use a closed file");
+ THArgCheck(dfself->file.isReadable, 1, "attempt to read in a write-only file");
+ THArgCheck((strlen(format) >= 2 ? (format[0] == '*') && (format[1] == 'a' || format[1] == 'l') : 0), 2, "format must be '*a' or '*l'");
+
+/* note: the string won't survive long, as it is copied into lua */
+/* so 1024 is not that big... */
+#define TBRS_BSZ 1024L
+
+ if(format[1] == 'a')
+ {
+ char *p = (char*)THAlloc(TBRS_BSZ);
+ long total = TBRS_BSZ;
+ long pos = 0L;
+
+ for (;;)
+ {
+ if(total-pos == 0) /* we need more space! */
+ {
+ total += TBRS_BSZ;
+ p = (char*)THRealloc(p, total);
+ }
+ if (p == NULL)
+ THError("read error: failed to allocate buffer");
+ pos += fread(p+pos, 1, total-pos, dfself->handle);
+ if (pos < total) /* eof? */
+ {
+ if(pos == 0L)
+ {
+ THFree(p);
+ dfself->file.hasError = 1;
+ if(!dfself->file.isQuiet)
+ THError("read error: read 0 blocks instead of 1");
+
+ *str_ = NULL;
+ return 0;
+ }
+ *str_ = p;
+ return pos;
+ }
+ }
+ }
+ else
+ {
+ char *p = (char*)THAlloc(TBRS_BSZ);
+ long total = TBRS_BSZ;
+ long pos = 0L;
+ long size;
+
+ for (;;)
+ {
+ if(total-pos <= 1) /* we can only write '\0' in there! */
+ {
+ total += TBRS_BSZ;
+ p = (char*)THRealloc(p, total);
+ }
+ if (p == NULL)
+ THError("read error: failed to allocate buffer");
+ if (fgets(p+pos, total-pos, dfself->handle) == NULL) /* eof? */
+ {
+ if(pos == 0L)
+ {
+ THFree(p);
+ dfself->file.hasError = 1;
+ if(!dfself->file.isQuiet)
+ THError("read error: read 0 blocks instead of 1");
+
+ *str_ = NULL;
+ return 0;
+ }
+ *str_ = p;
+ return pos;
+ }
+ size = strlen(p+pos);
+ if (size == 0L || (p+pos)[size-1] != '\n')
+ {
+ pos += size;
+ }
+ else
+ {
+ pos += size-1L; /* do not include `eol' */
+ *str_ = p;
+ return pos;
+ }
+ }
+ }
+
+ *str_ = NULL;
+ return 0;
+}
+
+
+THFile *THDiskFile_new(const char *name, const char *mode, int isQuiet)
+{
+ static struct THFileVTable vtable = {
+ THDiskFile_isOpened,
+
+ THDiskFile_readByte,
+ THDiskFile_readChar,
+ THDiskFile_readShort,
+ THDiskFile_readInt,
+ THDiskFile_readLong,
+ THDiskFile_readFloat,
+ THDiskFile_readDouble,
+ THDiskFile_readString,
+
+ THDiskFile_seek,
+ THDiskFile_seekEnd,
+ THDiskFile_position,
+ THDiskFile_close,
+ THDiskFile_free
+ };
+
+ int isReadable;
+ int isWritable;
+ FILE *handle;
+ THDiskFile *self;
+
+ THArgCheck(THDiskFile_mode(mode, &isReadable, &isWritable), 2, "file mode should be 'r','w' or 'rw'");
+
+ CV_Assert(isReadable && !isWritable);
+#ifdef _MSC_VER
+ if (fopen_s(&handle, name, "rb") != 0)
+ handle = NULL;
+#else
+ handle = fopen(name,"rb");
+#endif
+
+ if(!handle)
+ {
+ if(isQuiet)
+ return 0;
+ else
+ THError("cannot open <%s> in mode %c%c", name, (isReadable ? 'r' : ' '), (isWritable ? 'w' : ' '));
+ }
+
+ self = (THDiskFile*)THAlloc(sizeof(THDiskFile));
+ if (!self)
+ THError("cannot allocate memory for self");
+
+ self->handle = handle;
+ self->name = (char*)THAlloc(strlen(name)+1);
+ if (!self->name)
+ THError("cannot allocate memory for self->name");
+ strcpy(self->name, name);
+ self->isNativeEncoding = 1;
+ self->longSize = 0;
+
+ self->file.vtable = &vtable;
+ self->file.isQuiet = isQuiet;
+ self->file.isReadable = isReadable;
+ self->file.isWritable = isWritable;
+ self->file.isBinary = 0;
+ self->file.isAutoSpacing = 1;
+ self->file.hasError = 0;
+
+ return (THFile*)self;
+}
+
+}
+#endif
diff --git a/modules/dnn/src/torch/THDiskFile.h b/modules/dnn/src/torch/THDiskFile.h
new file mode 100644
index 0000000..112d77f
--- /dev/null
+++ b/modules/dnn/src/torch/THDiskFile.h
@@ -0,0 +1,23 @@
+#ifndef TH_DISK_FILE_INC
+#define TH_DISK_FILE_INC
+
+#include "THFile.h"
+
+namespace TH
+{
+
+TH_API THFile *THDiskFile_new(const char *name, const char *mode, int isQuiet);
+
+TH_API const char *THDiskFile_name(THFile *self);
+
+TH_API int THDiskFile_isLittleEndianCPU(void);
+TH_API int THDiskFile_isBigEndianCPU(void);
+TH_API void THDiskFile_nativeEndianEncoding(THFile *self);
+TH_API void THDiskFile_littleEndianEncoding(THFile *self);
+TH_API void THDiskFile_bigEndianEncoding(THFile *self);
+TH_API void THDiskFile_longSize(THFile *self, int size);
+TH_API void THDiskFile_noBuffer(THFile *self);
+
+} // namespace
+
+#endif
diff --git a/modules/dnn/src/torch/THFile.cpp b/modules/dnn/src/torch/THFile.cpp
new file mode 100644
index 0000000..081873f
--- /dev/null
+++ b/modules/dnn/src/torch/THFile.cpp
@@ -0,0 +1,122 @@
+#include "../precomp.hpp"
+#if defined(ENABLE_TORCH_IMPORTER) && ENABLE_TORCH_IMPORTER
+#include "THFile.h"
+#include "THFilePrivate.h"
+
+namespace TH {
+
+#define IMPLEMENT_THFILE_RW(TYPEC, TYPE) \
+ long THFile_read##TYPEC##Raw(THFile *self, TYPE *data, long n) \
+ { \
+ return (*self->vtable->read##TYPEC)(self, data, n); \
+ }
+
+IMPLEMENT_THFILE_RW(Byte, unsigned char)
+IMPLEMENT_THFILE_RW(Char, char)
+IMPLEMENT_THFILE_RW(Short, short)
+IMPLEMENT_THFILE_RW(Int, int)
+IMPLEMENT_THFILE_RW(Long, int64)
+IMPLEMENT_THFILE_RW(Float, float)
+IMPLEMENT_THFILE_RW(Double, double)
+
+long THFile_readStringRaw(THFile *self, const char *format, char **str_)
+{
+ return self->vtable->readString(self, format, str_);
+}
+
+void THFile_seek(THFile *self, long position)
+{
+ self->vtable->seek(self, position);
+}
+
+void THFile_seekEnd(THFile *self)
+{
+ self->vtable->seekEnd(self);
+}
+
+long THFile_position(THFile *self)
+{
+ return self->vtable->position(self);
+}
+
+void THFile_close(THFile *self)
+{
+ self->vtable->close(self);
+}
+
+void THFile_free(THFile *self)
+{
+ self->vtable->free(self);
+}
+
+int THFile_isOpened(THFile *self)
+{
+ return self->vtable->isOpened(self);
+}
+
+#define IMPLEMENT_THFILE_FLAGS(FLAG) \
+ int THFile_##FLAG(THFile *self) \
+ { \
+ return self->FLAG; \
+ }
+
+IMPLEMENT_THFILE_FLAGS(isQuiet)
+IMPLEMENT_THFILE_FLAGS(isReadable)
+IMPLEMENT_THFILE_FLAGS(isWritable)
+IMPLEMENT_THFILE_FLAGS(isBinary)
+IMPLEMENT_THFILE_FLAGS(isAutoSpacing)
+IMPLEMENT_THFILE_FLAGS(hasError)
+
+void THFile_binary(THFile *self)
+{
+ self->isBinary = 1;
+}
+
+void THFile_ascii(THFile *self)
+{
+ self->isBinary = 0;
+}
+
+void THFile_autoSpacing(THFile *self)
+{
+ self->isAutoSpacing = 1;
+}
+
+void THFile_noAutoSpacing(THFile *self)
+{
+ self->isAutoSpacing = 0;
+}
+
+void THFile_quiet(THFile *self)
+{
+ self->isQuiet = 1;
+}
+
+void THFile_pedantic(THFile *self)
+{
+ self->isQuiet = 0;
+}
+
+void THFile_clearError(THFile *self)
+{
+ self->hasError = 0;
+}
+
+#define IMPLEMENT_THFILE_SCALAR(TYPEC, TYPE) \
+ TYPE THFile_read##TYPEC##Scalar(THFile *self) \
+ { \
+ TYPE scalar; \
+ THFile_read##TYPEC##Raw(self, &scalar, 1); \
+ return scalar; \
+ }
+
+IMPLEMENT_THFILE_SCALAR(Byte, unsigned char)
+IMPLEMENT_THFILE_SCALAR(Char, char)
+IMPLEMENT_THFILE_SCALAR(Short, short)
+IMPLEMENT_THFILE_SCALAR(Int, int)
+IMPLEMENT_THFILE_SCALAR(Long, int64)
+IMPLEMENT_THFILE_SCALAR(Float, float)
+IMPLEMENT_THFILE_SCALAR(Double, double)
+
+} // namespace
+#endif
diff --git a/modules/dnn/src/torch/THFile.h b/modules/dnn/src/torch/THFile.h
new file mode 100644
index 0000000..5ac3af2
--- /dev/null
+++ b/modules/dnn/src/torch/THFile.h
@@ -0,0 +1,55 @@
+#ifndef TH_FILE_INC
+#define TH_FILE_INC
+
+//#include "THStorage.h"
+#if defined(ENABLE_TORCH_IMPORTER) && ENABLE_TORCH_IMPORTER
+#include "opencv2/core/hal/interface.h"
+#include "THGeneral.h"
+
+namespace TH
+{
+typedef struct THFile__ THFile;
+
+TH_API int THFile_isOpened(THFile *self);
+TH_API int THFile_isQuiet(THFile *self);
+TH_API int THFile_isReadable(THFile *self);
+TH_API int THFile_isWritable(THFile *self);
+TH_API int THFile_isBinary(THFile *self);
+TH_API int THFile_isAutoSpacing(THFile *self);
+TH_API int THFile_hasError(THFile *self);
+
+TH_API void THFile_binary(THFile *self);
+TH_API void THFile_ascii(THFile *self);
+TH_API void THFile_autoSpacing(THFile *self);
+TH_API void THFile_noAutoSpacing(THFile *self);
+TH_API void THFile_quiet(THFile *self);
+TH_API void THFile_pedantic(THFile *self);
+TH_API void THFile_clearError(THFile *self);
+
+/* scalar */
+TH_API unsigned char THFile_readByteScalar(THFile *self);
+TH_API char THFile_readCharScalar(THFile *self);
+TH_API short THFile_readShortScalar(THFile *self);
+TH_API int THFile_readIntScalar(THFile *self);
+TH_API int64 THFile_readLongScalar(THFile *self);
+TH_API float THFile_readFloatScalar(THFile *self);
+TH_API double THFile_readDoubleScalar(THFile *self);
+
+/* raw */
+TH_API long THFile_readByteRaw(THFile *self, unsigned char *data, long n);
+TH_API long THFile_readCharRaw(THFile *self, char *data, long n);
+TH_API long THFile_readShortRaw(THFile *self, short *data, long n);
+TH_API long THFile_readIntRaw(THFile *self, int *data, long n);
+TH_API long THFile_readLongRaw(THFile *self, int64 *data, long n);
+TH_API long THFile_readFloatRaw(THFile *self, float *data, long n);
+TH_API long THFile_readDoubleRaw(THFile *self, double *data, long n);
+TH_API long THFile_readStringRaw(THFile *self, const char *format, char **str_); /* you must deallocate str_ */
+
+TH_API void THFile_seek(THFile *self, long position);
+TH_API void THFile_seekEnd(THFile *self);
+TH_API long THFile_position(THFile *self);
+TH_API void THFile_close(THFile *self);
+TH_API void THFile_free(THFile *self);
+} // namespace
+#endif //defined(ENABLE_TORCH_IMPORTER) && ENABLE_TORCH_IMPORTER
+#endif //TH_FILE_INC
diff --git a/modules/dnn/src/torch/THFilePrivate.h b/modules/dnn/src/torch/THFilePrivate.h
new file mode 100644
index 0000000..af3890d
--- /dev/null
+++ b/modules/dnn/src/torch/THFilePrivate.h
@@ -0,0 +1,37 @@
+namespace TH {
+
+struct THFile__
+{
+ struct THFileVTable *vtable;
+
+ int isQuiet;
+ int isReadable;
+ int isWritable;
+ int isBinary;
+ int isAutoSpacing;
+ int hasError;
+};
+
+/* virtual table definition */
+
+struct THFileVTable
+{
+ int (*isOpened)(THFile *self);
+
+ long (*readByte)(THFile *self, unsigned char *data, long n);
+ long (*readChar)(THFile *self, char *data, long n);
+ long (*readShort)(THFile *self, short *data, long n);
+ long (*readInt)(THFile *self, int *data, long n);
+ long (*readLong)(THFile *self, int64 *data, long n);
+ long (*readFloat)(THFile *self, float *data, long n);
+ long (*readDouble)(THFile *self, double *data, long n);
+ long (*readString)(THFile *self, const char *format, char **str_);
+
+ void (*seek)(THFile *self, long position);
+ void (*seekEnd)(THFile *self);
+ long (*position)(THFile *self);
+ void (*close)(THFile *self);
+ void (*free)(THFile *self);
+};
+
+} // namespace
diff --git a/modules/dnn/src/torch/THGeneral.cpp b/modules/dnn/src/torch/THGeneral.cpp
new file mode 100644
index 0000000..b0f38e0
--- /dev/null
+++ b/modules/dnn/src/torch/THGeneral.cpp
@@ -0,0 +1,13 @@
+#include "../precomp.hpp"
+#if defined(ENABLE_TORCH_IMPORTER) && ENABLE_TORCH_IMPORTER
+
+#if defined(TH_DISABLE_HEAP_TRACKING)
+#elif (defined(__unix) || defined(_WIN32))
+#include <malloc.h>
+#elif defined(__APPLE__)
+#include <malloc/malloc.h>
+#endif
+
+#include "THGeneral.h"
+
+#endif
diff --git a/modules/dnn/src/torch/THGeneral.h b/modules/dnn/src/torch/THGeneral.h
new file mode 100644
index 0000000..cdcbe3d
--- /dev/null
+++ b/modules/dnn/src/torch/THGeneral.h
@@ -0,0 +1,22 @@
+#ifndef TH_GENERAL_INC
+#define TH_GENERAL_INC
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <math.h>
+#include <limits.h>
+#include <float.h>
+#include <time.h>
+#include <string.h>
+
+#define TH_API
+
+#define THError(...) CV_Error(cv::Error::StsError, cv::format(__VA_ARGS__))
+#define THArgCheck(cond, ...) CV_Assert(cond)
+
+#define THAlloc malloc
+#define THRealloc realloc
+#define THFree free
+
+#endif
diff --git a/modules/dnn/src/torch/torch_importer.cpp b/modules/dnn/src/torch/torch_importer.cpp
new file mode 100644
index 0000000..44fcd8c
--- /dev/null
+++ b/modules/dnn/src/torch/torch_importer.cpp
@@ -0,0 +1,1039 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "../precomp.hpp"
+#include <limits>
+#include <set>
+#include <map>
+#include <algorithm>
+#include <iostream>
+#include <fstream>
+
+#if defined(ENABLE_TORCH_IMPORTER) && ENABLE_TORCH_IMPORTER
+#include "THDiskFile.h"
+#endif
+
+namespace cv {
+namespace dnn {
+CV__DNN_EXPERIMENTAL_NS_BEGIN
+
+#if defined(ENABLE_TORCH_IMPORTER) && ENABLE_TORCH_IMPORTER
+using namespace TH;
+
+//#ifdef NDEBUG
+static bool dbgPrint = false;
+//#else
+//static bool dbgPrint = true;
+//#endif
+
+enum LuaType
+{
+ TYPE_NIL = 0,
+ TYPE_NUMBER = 1,
+ TYPE_STRING = 2,
+ TYPE_TABLE = 3,
+ TYPE_TORCH = 4,
+ TYPE_BOOLEAN = 5,
+ TYPE_FUNCTION = 6,
+ TYPE_RECUR_FUNCTION = 8,
+ LEGACY_TYPE_RECUR_FUNCTION = 7
+};
+
+template<typename T>
+static String toString(const T &v)
+{
+ std::ostringstream ss;
+ ss << v;
+ return ss.str();
+}
+
+static inline bool startsWith(const String &str, const char *substr)
+{
+ return str.find(substr) == 0;
+}
+
+static inline bool endsWith(const String &str, const char *substr)
+{
+ return str.rfind(substr) == str.length() - strlen(substr);
+}
+
+struct TorchImporter : public ::cv::dnn::Importer
+{
+ typedef std::map<String, std::pair<int, Mat> > TensorsMap;
+ Net net;
+
+ cv::Ptr<THFile> file;
+ std::set<int> readedIndexes;
+ std::map<int, Mat> storages;
+ std::map<int, Mat> tensors;
+
+ struct Module
+ {
+ String thName, apiType;
+ dnn::LayerParams params;
+ std::vector<cv::Ptr<Module> > modules;
+
+ Module(const String &_thName, const String &_apiType = String())
+ : thName(_thName), apiType(_apiType) {}
+ };
+
+ Module *rootModule;
+ Module *curModule;
+ int moduleCounter;
+
+ TorchImporter(String filename, bool isBinary)
+ {
+ CV_TRACE_FUNCTION();
+
+ rootModule = curModule = NULL;
+ moduleCounter = 0;
+
+ file = cv::Ptr<THFile>(THDiskFile_new(filename.c_str(), "r", 0), THFile_free);
+ CV_Assert(file && THFile_isOpened(file));
+
+ if (isBinary)
+ THFile_binary(file);
+ else
+ THFile_ascii(file);
+ }
+
+ /* Simple readers */
+
+ inline int readInt()
+ {
+ return THFile_readIntScalar(file);
+ }
+
+ inline long readLong()
+ {
+ return THFile_readLongScalar(file);
+ }
+
+ inline bool readBool()
+ {
+ return readInt() != 0;
+ }
+
+ inline double readDouble()
+ {
+ return THFile_readDoubleScalar(file);
+ }
+
+ inline String readString()
+ {
+ int size = THFile_readIntScalar(file);
+ String str(size, '\0');
+ THFile_readCharRaw(file, const_cast<char*>(str.c_str()), size);
+ return str;
+ }
+
+ inline String readTorchClassName()
+ {
+ String version = readString();
+ return startsWith(version, "V ") ? readString() : version;
+ }
+
+ inline void readFunction()
+ {
+ readString();
+ readObject();
+ }
+
+ void readTable(int index = -1)
+ {
+ index = (index < 0) ? readInt() : index;
+
+ if (readedIndexes.count(index))
+ return;
+
+ readedIndexes.insert(index);
+
+ int size = readInt();
+
+ for (int i = 0; i < size; i++)
+ {
+ readObject(); //key
+ readObject(); //value
+ }
+ }
+
+ /* Special readers */
+
+ static inline int parseTorchType(const String &str, const char *suffix, const char *prefix = "torch.")
+ {
+ if (startsWith(str, prefix) && endsWith(str, suffix))
+ {
+ String typeStr = str.substr(strlen(prefix), str.length() - strlen(prefix) - strlen(suffix));
+
+ if (typeStr == "Double")
+ return CV_64F;
+ else if (typeStr == "Float" || typeStr == "Cuda")
+ return CV_32F;
+ else if (typeStr == "Byte")
+ return CV_8U;
+ else if (typeStr == "Char")
+ return CV_8S;
+ else if (typeStr == "Short")
+ return CV_16S;
+ else if (typeStr == "Int")
+ return CV_32S;
+ else if (typeStr == "Long") //Carefully! CV_64S type coded as CV_USRTYPE1
+ return CV_USRTYPE1;
+ else
+ CV_Error(Error::StsNotImplemented, "Unknown type \"" + typeStr + "\" of torch class \"" + str + "\"");
+ }
+
+ return -1;
+ }
+
+ static int parseTensorType(const String &className)
+ {
+ return parseTorchType(className, "Tensor");
+ }
+
+ static int parseStorageType(const String &className)
+ {
+ return parseTorchType(className, "Storage");
+ }
+
+ void readTorchStorage(int index, int type = -1)
+ {
+ long size = readLong();
+ Mat storageMat(1, size, (type != CV_USRTYPE1) ? type : CV_64F); //handle LongStorage as CV_64F Mat
+
+ switch (type)
+ {
+ case CV_32F:
+ THFile_readFloatRaw(file, (float*)storageMat.data, size);
+ break;
+ case CV_64F:
+ THFile_readDoubleRaw(file, (double*)storageMat.data, size);
+ break;
+ case CV_8S:
+ case CV_8U:
+ THFile_readByteRaw(file, (uchar*)storageMat.data, size);
+ break;
+ case CV_16S:
+ case CV_16U:
+ THFile_readShortRaw(file, (short*)storageMat.data, size);
+ break;
+ case CV_32S:
+ THFile_readIntRaw(file, (int*)storageMat.data, size);
+ break;
+ case CV_USRTYPE1:
+ {
+ double *buf = storageMat.ptr<double>();
+ THFile_readLongRaw(file, (int64*)buf, size);
+
+ for (size_t i = (size_t)size; i-- > 0; )
+ buf[i] = ((int64*)buf)[i];
+ }
+ break;
+ default:
+ CV_Error(Error::StsInternal, "");
+ break;
+ }
+
+ storages.insert(std::make_pair(index, storageMat));
+ }
+
+ void readTorchTable(Dict &scalarParams, TensorsMap &tensorParams)
+ {
+ int luaType = readInt();
+ int index = readInt();
+
+ CV_Assert(luaType == TYPE_TABLE && readedIndexes.count(index) == 0);
+ readedIndexes.insert(index);
+
+ long fpos;
+ int numPairs = readInt();
+
+ for (int i = 0; i < numPairs; i++)
+ {
+ fpos = THFile_position(file);
+ int ktype = readInt();
+
+ if (ktype != TYPE_STRING) //skip non-string fileds
+ {
+ THFile_seek(file, fpos);
+ readObject(); //key
+ readObject(); //value
+ continue;
+ }
+
+ String key = readString();
+ if (dbgPrint)
+ std::cout << i << "th key: " << key << "\n";
+
+ fpos = THFile_position(file);
+ int vtype = readInt();
+
+ if (vtype == TYPE_TORCH)
+ {
+ int index = readInt();
+ readTorchObject(index);
+
+ if (tensors.count(index)) //tensor was readed
+ {
+ tensorParams.insert(std::make_pair(key, std::make_pair(index, tensors[index])));
+ }
+ else if (storages.count(index)) //storage was readed
+ {
+ Mat &matStorage = storages[index];
+ Mat matCasted;
+ matStorage.convertTo(matCasted, CV_64F);
+
+ DictValue scalar = DictValue::arrayReal(matCasted.ptr<double>(), matCasted.total());
+ scalarParams.set(key, scalar);
+ }
+ }
+ else if (vtype == TYPE_NUMBER)
+ {
+ scalarParams.set(key, readDouble());
+ }
+ else if (vtype == TYPE_STRING)
+ {
+ scalarParams.set(key, readString());
+ }
+ else if (vtype == TYPE_BOOLEAN)
+ {
+ scalarParams.set(key, readBool());
+ }
+ else
+ {
+ THFile_seek(file, fpos);
+ readObject();
+ }
+ }
+
+ //Debug output
+ if (dbgPrint)
+ {
+ std::cout << "scalarParams:\n";
+ std::cout << scalarParams;
+
+ std::cout << "#" << tensorParams.size() << " tensorParams:\n";
+ std::map<String,std::pair<int, Mat> >::const_iterator it;
+ for (it = tensorParams.begin(); it != tensorParams.end(); it++)
+ std::cout << it->first << ": Tensor " << it->second.second.size << "\n";
+ }
+ }
+
+ void readTorchTensor(int indexTensor, int typeTensor)
+ {
+ int ndims = readInt();
+ AutoBuffer<int64, 4> sizes(ndims);
+ AutoBuffer<int64, 4> steps(ndims);
+ THFile_readLongRaw(file, sizes, ndims);
+ THFile_readLongRaw(file, steps, ndims);
+ long offset = readLong() - 1;
+
+ //read Storage
+ int typeidx = readInt();
+ CV_Assert(typeidx == TYPE_TORCH || (typeidx == TYPE_NIL && ndims == 0));
+
+ if (typeidx == TYPE_NIL)
+ {
+ tensors.insert(std::make_pair(indexTensor, Mat()));
+ return;
+ }
+
+ int indexStorage = readInt();
+ if (readedIndexes.count(indexStorage) == 0)
+ {
+ String className = readTorchClassName();
+ int typeStorage = parseStorageType(className);
+ CV_Assert(typeStorage >= 0 && typeTensor == typeStorage);
+ readTorchStorage(indexStorage, typeStorage);
+ typeTensor = storages[indexStorage].type();
+ readedIndexes.insert(indexStorage);
+ }
+
+ //small check
+ size_t requireElems = (size_t)offset + (size_t)steps[0] * (size_t)sizes[0];
+ size_t storageElems = storages[indexStorage].total();
+ if (requireElems > storageElems)
+ CV_Error(Error::StsBadSize, "Storage has insufficent number of elemements for requested Tensor");
+
+ //convert sizes
+ AutoBuffer<int, 4> isizes(ndims);
+ AutoBuffer<size_t, 4> ssteps(ndims);
+ for (int i = ndims - 1; i >= 0; i--)
+ {
+ isizes[i] = (int)sizes[i];
+ ssteps[i] = (size_t)steps[i] * CV_ELEM_SIZE(typeTensor);
+ }
+
+ //allocate Blob
+ Mat srcMat(ndims, (int*)isizes, typeTensor , storages[indexStorage].ptr() + offset*CV_ELEM_SIZE(typeTensor), (size_t*)ssteps);
+ int dstType = CV_32F;
+
+ Mat blob;
+ srcMat.convertTo(blob, dstType);
+
+ tensors.insert(std::make_pair(indexTensor, blob));
+ }
+
+ static bool isNNClass(const String &className, String &nnName)
+ {
+ const char *prefixes[] = {"nn.", "cunn.", "cudnn.", "fbcunn.", NULL};
+
+ for (int i = 0; prefixes[i]; i++)
+ {
+ if (startsWith(className, prefixes[i]))
+ {
+ nnName = className.substr(strlen(prefixes[i]));
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ static void convertTorchKernelsParams(const Dict &torchParams, cv::dnn::LayerParams &layerParams)
+ {
+ layerParams.set("kernel_h", torchParams.get<int>("kH"));
+ layerParams.set("kernel_w", torchParams.get<int>("kW"));
+ layerParams.set("stride_h", torchParams.get<int>("dH"));
+ layerParams.set("stride_w", torchParams.get<int>("dW"));
+ layerParams.set("pad_h", torchParams.get<int>("padH", 0));
+ layerParams.set("pad_w", torchParams.get<int>("padW", 0));
+ }
+
+ void readTorchObject(int index)
+ {
+ if(readedIndexes.count(index))
+ return;
+
+ String className = readTorchClassName();
+ String nnName;
+
+ if (dbgPrint)
+ std::cout << "Class: " << className << std::endl;
+
+ int type;
+ if ( (type = parseTensorType(className)) >= 0 ) //is Tensor
+ {
+ readTorchTensor(index, type);
+ }
+ else if ( (type = parseStorageType(className)) >= 0 ) //is Storage
+ {
+ readTorchStorage(index, type);
+ }
+ else if (isNNClass(className, nnName))
+ {
+ Dict scalarParams;
+ TensorsMap tensorParams;
+
+ cv::Ptr<Module> newModule(new Module(nnName));
+ cv::dnn::LayerParams &layerParams = newModule->params;
+
+ layerParams.set("torch_index", index);
+
+ if (nnName == "Sequential" || nnName == "Parallel" ||
+ nnName == "Concat" || nnName == "ConcatTable" || nnName == "JoinTable")
+ {
+ Module *parentModule = curModule;
+ curModule->modules.push_back(newModule);
+ curModule = newModule;
+ readTorchTable(scalarParams, tensorParams);
+ curModule = parentModule;
+
+ if (nnName == "Parallel")
+ {
+ layerParams.set("inputDimension", scalarParams.get<int>("inputDimension"));
+ layerParams.set("outputDimension", scalarParams.get<int>("outputDimension"));
+ }
+ if (nnName == "Concat")
+ {
+ layerParams.set("dimension", scalarParams.get<int>("dimension"));
+ }
+ if (nnName == "JoinTable")
+ {
+ layerParams.set("dimension", scalarParams.get<int>("dimension"));
+ }
+ }
+ else if (nnName == "SpatialConvolution")
+ {
+ newModule->apiType = "Convolution";
+ readTorchTable(scalarParams, tensorParams);
+
+ CV_Assert(tensorParams.count("weight"));
+ layerParams.blobs.push_back(tensorParams["weight"].second);
+
+ bool bias = tensorParams.count("bias") != 0;
+ layerParams.set("bias_term", bias);
+ if (bias)
+ layerParams.blobs.push_back(tensorParams["bias"].second);
+
+ layerParams.set("num_output", scalarParams.get<int>("nOutputPlane"));
+ convertTorchKernelsParams(scalarParams, layerParams);
+
+ curModule->modules.push_back(newModule);
+ }
+ else if (nnName == "SpatialMaxPooling" || nnName == "SpatialAveragePooling")
+ {
+ newModule->apiType = "Pooling";
+ readTorchTable(scalarParams, tensorParams);
+
+ if (nnName == "SpatialMaxPooling") {
+ layerParams.set("pool", "MAX");
+ layerParams.set("indices_blob_id", tensorParams["indices"].first);
+ }
+ if (nnName == "SpatialAveragePooling")
+ layerParams.set("pool", "AVE");
+ convertTorchKernelsParams(scalarParams, layerParams);
+
+ curModule->modules.push_back(newModule);
+ }
+ else if (nnName == "Linear")
+ {
+ newModule->apiType = "InnerProduct";
+ readTorchTable(scalarParams, tensorParams);
+
+ CV_Assert(tensorParams.count("weight"));
+ Mat weightBlob = tensorParams["weight"].second;
+ layerParams.blobs.push_back(weightBlob);
+
+ bool bias = tensorParams.count("bias") != 0;
+ if (bias)
+ layerParams.blobs.push_back(tensorParams["bias"].second);
+ layerParams.set("bias_term", bias);
+
+ layerParams.set("num_output", weightBlob.size[0]);
+ curModule->modules.push_back(newModule);
+ }
+ else if (nnName == "Reshape")
+ {
+ newModule->apiType = "Reshape";
+
+ readTorchTable(scalarParams, tensorParams);
+ CV_Assert(scalarParams.has("size"));
+
+ DictValue dimParam = scalarParams.get("size");
+ layerParams.set("dim", dimParam);
+
+ if (scalarParams.has("batchMode") && scalarParams.get<bool>("batchMode"))
+ layerParams.set("axis", 1);
+
+ curModule->modules.push_back(newModule);
+ }
+ else if (nnName == "ReLU")
+ {
+ curModule->modules.push_back(cv::Ptr<Module>(new Module(nnName, "ReLU")));
+ readObject();
+ }
+ else if (nnName == "Tanh")
+ {
+ curModule->modules.push_back(cv::Ptr<Module>(new Module(nnName, "TanH")));
+ readObject();
+ }
+ else if (nnName == "Sigmoid")
+ {
+ curModule->modules.push_back(cv::Ptr<Module>(new Module(nnName, "Sigmoid")));
+ readObject();
+ }
+ else if (nnName == "SpatialBatchNormalization")
+ {
+ newModule->apiType = "BatchNorm";
+ readTorchTable(scalarParams, tensorParams);
+
+ CV_Assert(tensorParams.count("running_var") &&
+ tensorParams.count("running_mean"));
+ layerParams.blobs.push_back(tensorParams["running_mean"].second);
+ layerParams.blobs.push_back(tensorParams["running_var"].second);
+
+ CV_Assert(scalarParams.has("eps"));
+ float eps = float(scalarParams.get<double>("eps"));
+ layerParams.set("eps", eps);
+
+ if (tensorParams.count("weight"))
+ {
+ layerParams.set("has_weight", true);
+ layerParams.blobs.push_back(tensorParams["weight"].second);
+ }
+
+ if (tensorParams.count("bias"))
+ {
+ layerParams.set("has_bias", true);
+ layerParams.blobs.push_back(tensorParams["bias"].second);
+ }
+
+ curModule->modules.push_back(newModule);
+ }
+ else if (nnName == "PReLU")
+ {
+ readTorchTable(scalarParams, tensorParams);
+
+ CV_Assert(tensorParams.count("weight"));
+
+ size_t outputChannels = static_cast<int>(scalarParams.get<double>("nOutputPlane"));
+ if (outputChannels) {
+
+ CV_Assert(tensorParams["weight"].second.total() == outputChannels);
+ layerParams.blobs.push_back(tensorParams["weight"].second);
+
+ newModule->apiType = "ChannelsPReLU";
+ }
+ else {
+ CV_Assert(tensorParams["weight"].second.total() == 1);
+ float negative_slope = *tensorParams["weight"].second.ptr<float>();
+ layerParams.set("negative_slope", negative_slope);
+
+ newModule->apiType = "ReLU";
+ }
+
+ curModule->modules.push_back(newModule);
+ }
+ else if (nnName == "SpatialDropout")
+ {
+ readTorchTable(scalarParams, tensorParams);
+ CV_Assert(scalarParams.has("p"));
+
+ float scale = 1 - scalarParams.get<double>("p");
+
+ CV_Assert(scale > 0);
+
+ newModule->apiType = "Power";
+ layerParams.set("scale", scale);
+ curModule->modules.push_back(newModule);
+ }
+ else if (nnName == "Identity")
+ {
+ readTorchTable(scalarParams, tensorParams);
+ newModule->apiType = "Identity";
+ curModule->modules.push_back(newModule);
+ }
+ else if (nnName == "Padding")
+ {
+ readTorchTable(scalarParams, tensorParams);
+ newModule->apiType = "Padding";
+
+ CV_Assert(scalarParams.has("pad") &&
+ scalarParams.has("dim"));
+
+ layerParams.set("padding_dim",
+ static_cast<int>(scalarParams.get<double>("dim") - 1));
+ layerParams.set("padding", static_cast<int>(scalarParams.get<double>("pad")));
+
+ if (scalarParams.has("nInputDim"))
+ layerParams.set("input_dims",
+ static_cast<int>(scalarParams.get<double>("nInputDim")));
+
+ if (scalarParams.has("value"))
+ layerParams.set("value", scalarParams.get<double>("value"));
+
+ if (scalarParams.has("index"))
+ layerParams.set("index",
+ static_cast<int>(scalarParams.get<double>("index") - 1));
+
+ curModule->modules.push_back(newModule);
+ }
+ else if (nnName == "CAddTable")
+ {
+ curModule->modules.push_back(newModule);
+ readObject();
+ }
+ else if (nnName == "SpatialDilatedConvolution")
+ {
+ readTorchTable(scalarParams, tensorParams);
+ newModule->apiType = "Convolution";
+ CV_Assert(scalarParams.has("padW") &&
+ scalarParams.has("padH")&&
+ scalarParams.has("dW")&&
+ scalarParams.has("dH")&&
+ scalarParams.has("dilationW")&&
+ scalarParams.has("dilationH")&&
+ scalarParams.has("kW")&&
+ scalarParams.has("kH")&&
+ scalarParams.has("nOutputPlane"));
+
+ layerParams.set("kernel_w", static_cast<int>(scalarParams.get<double>("kW")));
+ layerParams.set("kernel_h", static_cast<int>(scalarParams.get<double>("kH")));
+ layerParams.set("pad_w", static_cast<int>(scalarParams.get<double>("padW")));
+ layerParams.set("pad_h", static_cast<int>(scalarParams.get<double>("padH")));
+ layerParams.set("stride_w", static_cast<int>(scalarParams.get<double>("dW")));
+ layerParams.set("stride_h", static_cast<int>(scalarParams.get<double>("dH")));
+ layerParams.set("dilation_w", static_cast<int>(scalarParams.get<double>("dilationW")));
+ layerParams.set("dilation_h", static_cast<int>(scalarParams.get<double>("dilationH")));
+ layerParams.set("num_output", static_cast<int>(scalarParams.get<double>("nOutputPlane")));
+
+ layerParams.blobs.push_back(tensorParams["weight"].second);
+
+ bool bias = tensorParams.count("bias");
+ layerParams.set("bias_term", bias);
+ if (bias)
+ layerParams.blobs.push_back(tensorParams["bias"].second);
+
+ curModule->modules.push_back(newModule);
+ }
+ else if (nnName == "SpatialFullConvolution")
+ {
+ readTorchTable(scalarParams, tensorParams);
+ newModule->apiType = "Deconvolution";
+ CV_Assert(scalarParams.has("padW") &&
+ scalarParams.has("padH")&&
+ scalarParams.has("dW")&&
+ scalarParams.has("dH")&&
+ scalarParams.has("adjW")&&
+ scalarParams.has("adjH")&&
+ scalarParams.has("kW")&&
+ scalarParams.has("kH")&&
+ scalarParams.has("nOutputPlane"));
+
+ layerParams.set("kernel_w", static_cast<int>(scalarParams.get<double>("kW")));
+ layerParams.set("kernel_h", static_cast<int>(scalarParams.get<double>("kH")));
+ layerParams.set("pad_w", static_cast<int>(scalarParams.get<double>("padW")));
+ layerParams.set("pad_h", static_cast<int>(scalarParams.get<double>("padH")));
+ layerParams.set("stride_w", static_cast<int>(scalarParams.get<double>("dW")));
+ layerParams.set("stride_h", static_cast<int>(scalarParams.get<double>("dH")));
+ layerParams.set("adj_w", static_cast<int>(scalarParams.get<double>("adjW")));
+ layerParams.set("adj_h", static_cast<int>(scalarParams.get<double>("adjH")));
+ layerParams.set("num_output", static_cast<int>(scalarParams.get<double>("nOutputPlane")));
+
+ Mat weights = tensorParams["weight"].second;
+ CV_Assert(weights.dims == 4);
+ int reorderedShape[] = { weights.size[1], weights.size[0], weights.size[2], weights.size[3] };
+ layerParams.blobs.push_back(weights.reshape(1, 4, reorderedShape));
+
+ bool bias = tensorParams.count("bias");
+ layerParams.set("bias_term", bias);
+ if (bias)
+ layerParams.blobs.push_back(tensorParams["bias"].second);
+
+ curModule->modules.push_back(newModule);
+ }
+ else if (nnName == "SpatialMaxUnpooling")
+ {
+ readTorchTable(scalarParams, tensorParams);
+ CV_Assert(tensorParams.count("indices"));
+
+ layerParams.set("indices_blob_id", tensorParams["indices"].first);
+ curModule->modules.push_back(newModule);
+ }
+ else if (nnName == "SoftMax")
+ {
+ newModule->apiType = "SoftMax";
+ curModule->modules.push_back(newModule);
+ }
+ else if (nnName == "LogSoftMax")
+ {
+ newModule->apiType = "SoftMax";
+ layerParams.set("log_softmax", true);
+ curModule->modules.push_back(newModule);
+ }
+ else
+ {
+ CV_Error(Error::StsNotImplemented, "Unknown nn class \"" + className + "\"");
+ }
+ }
+ else
+ {
+ CV_Error(Error::StsNotImplemented, "Unsupported Torch class \"" + className + "\"");
+ }
+
+ readedIndexes.insert(index);
+ }
+
+ void readObject()
+ {
+ int typeidx = readInt();
+
+ if (typeidx == TYPE_TORCH)
+ {
+ int index = readInt();
+ readTorchObject(index);
+ readedIndexes.insert(index);
+ }
+ else if (typeidx == TYPE_NIL)
+ return;
+ else if (typeidx == TYPE_NUMBER)
+ readDouble();
+ else if (typeidx == TYPE_BOOLEAN)
+ readBool();
+ else if (typeidx == TYPE_STRING)
+ readString();
+ else if (typeidx == TYPE_TABLE)
+ readTable();
+ else
+ CV_Error(Error::StsNotImplemented, "Unsupported Lua type");
+ }
+
+ inline String generateLayerName(const String &label = String())
+ {
+ return "l" + toString(++this->moduleCounter) + "_" + label;
+ }
+
+ int fill(Module *module, std::vector<std::pair<int, Module*> >& addedModules, int prevLayerId = 0, int prevOutNum = 0)
+ {
+ if (module == NULL)
+ return prevLayerId;
+
+ if (module->apiType.length())
+ {
+ int newLayerId = net.addLayer(generateLayerName(module->apiType), module->apiType, module->params);
+ net.connect(prevLayerId, prevOutNum, newLayerId, 0);
+ addedModules.push_back(std::make_pair(newLayerId, module));
+ return newLayerId;
+ }
+ else
+ {
+ if (module->thName == "Sequential")
+ {
+ for (size_t i = 0; i < module->modules.size(); i++)
+ {
+ prevLayerId = fill(module->modules[i], addedModules, prevLayerId, prevOutNum);
+ prevOutNum = 0;
+ }
+ return prevLayerId;
+ }
+ else if (module->thName == "Concat")
+ {
+ int newId, splitId, mergeId;
+ LayerParams mergeParams, splitParams;
+ mergeParams.set("axis", module->params.get<int>("dimension") - 1);
+
+ splitId = net.addLayer(generateLayerName("torchSplit"), "Split", splitParams);
+ net.connect(prevLayerId, prevOutNum, splitId, 0);
+
+ std::vector<int> branchIds;
+ for (int i = 0; i < (int)module->modules.size(); i++)
+ {
+ newId = fill(module->modules[i], addedModules, splitId, i);
+ branchIds.push_back(newId);
+ }
+
+ mergeId = net.addLayer(generateLayerName("torchMerge"), "Concat", mergeParams);
+
+ for (int i = 0; i < branchIds.size(); i++)
+ {
+ net.connect(branchIds[i], 0, mergeId, i);
+ }
+
+ addedModules.push_back(std::make_pair(mergeId, module));
+ return mergeId;
+ }
+ else if (module->thName == "Parallel")
+ {
+ int newId, splitId, mergeId, reshapeId;
+
+ LayerParams splitParams, mergeParams, reshapeParams;
+ splitParams.set("axis", module->params.get<int>("inputDimension") - 1);
+ mergeParams.set("axis", module->params.get<int>("outputDimension") - 1);
+ reshapeParams.set("axis", splitParams.get<int>("axis"));
+ reshapeParams.set("num_axes", 1);
+
+ splitId = net.addLayer(generateLayerName("torchSplit"), "Slice", splitParams);
+ reshapeId = net.addLayer(generateLayerName("torchReshape"), "Reshape", reshapeParams);
+ net.connect(prevLayerId, prevOutNum, splitId, 0);
+
+ std::vector<int> branchIds;
+ for (int i = 0; i < (int)module->modules.size(); i++)
+ {
+ net.connect(splitId, i, reshapeId, i);
+ newId = fill(module->modules[i], addedModules, reshapeId, i);
+ branchIds.push_back(newId);
+ }
+
+ mergeId = net.addLayer(generateLayerName("torchMerge"), "Concat", mergeParams);
+
+ for (int i = 0; i < branchIds.size(); i++)
+ {
+ net.connect(branchIds[i], 0, mergeId, i);
+ }
+
+ addedModules.push_back(std::make_pair(mergeId, module));
+ return mergeId;
+ }
+ else if (module->thName == "ConcatTable") {
+ int newId = -1, splitId;
+ LayerParams splitParams;
+
+ splitId = net.addLayer(generateLayerName("torchSplit"), "Split", splitParams);
+ net.connect(prevLayerId, prevOutNum, splitId, 0);
+
+ addedModules.push_back(std::make_pair(splitId, module));
+
+ for (int i = 0; i < (int)module->modules.size(); i++)
+ {
+ newId = fill(module->modules[i], addedModules, splitId, i);
+ }
+
+ return newId;
+ }
+ else if (module->thName == "JoinTable") {
+ std::vector<int> ids = net.getUnconnectedOutLayers();
+
+ int mergeId;
+ LayerParams mergeParams;
+ mergeParams.set("axis", module->params.get<int>("dimension") - 1);
+
+ mergeId = net.addLayer(generateLayerName("torchMerge"), "Concat", mergeParams);
+ addedModules.push_back(std::make_pair(mergeId, module));
+
+ for (int i = 0; i < ids.size(); i++)
+ {
+ net.connect(ids[i], 0, mergeId, i);
+ }
+
+ return mergeId;
+ }
+ else if (module->thName == "CAddTable") {
+ String name = generateLayerName("torchCAddTable");
+ std::vector<int> ids = net.getUnconnectedOutLayers();
+ LayerParams params;
+ params.set("operation", "sum");
+
+
+ int id = net.addLayer(name, "Eltwise", params);
+
+ for (int i = 0; i < ids.size(); i++)
+ {
+ net.connect(ids[i], 0, id, i);
+ }
+
+ addedModules.push_back(std::make_pair(id, module));
+ return id;
+ }
+ else if (module->thName == "SpatialMaxUnpooling") {
+ CV_Assert(module->params.has("indices_blob_id"));
+ int indicesBlobId = module->params.get<int>("indices_blob_id");
+ std::pair<int, Module*> poolingLayer;
+ poolingLayer.first = -1;
+
+ for(int i = 0; i < addedModules.size(); i++)
+ {
+ if (addedModules[i].second->apiType == "Pooling" &&
+ addedModules[i].second->params.has("indices_blob_id") &&
+ addedModules[i].second->params.get<int>("indices_blob_id") == indicesBlobId)
+ {
+ poolingLayer = addedModules[i];
+ break;
+ }
+ }
+
+ module->params.set("pool_k_h", poolingLayer.second->params.get<int>("kernel_h"));
+ module->params.set("pool_k_w", poolingLayer.second->params.get<int>("kernel_w"));
+ module->params.set("pool_stride_h", poolingLayer.second->params.get<int>("stride_h"));
+ module->params.set("pool_stride_w", poolingLayer.second->params.get<int>("stride_w"));
+ module->params.set("pool_pad_h", poolingLayer.second->params.get<int>("pad_h"));
+ module->params.set("pool_pad_w", poolingLayer.second->params.get<int>("pad_w"));
+
+ String name = generateLayerName("torchMaxUnpooling");
+ int id = net.addLayer(name, "MaxUnpool", module->params);
+ net.connect(prevLayerId, 0, id, 0);
+
+ CV_Assert(poolingLayer.first != -1);
+ net.connect(poolingLayer.first, 1, id, 1);
+
+ return id;
+ }
+ }
+
+ CV_Error(Error::StsInternal, "Unexpected torch container: " + module->thName);
+ return -1;
+ }
+
+ void populateNet(Net net_)
+ {
+ CV_TRACE_FUNCTION();
+
+ CV_Assert(rootModule == NULL);
+ cv::Ptr<Module> rootModule_ = cv::makePtr<Module>("Sequential");
+ rootModule = rootModule_.get();
+ curModule = rootModule;
+
+ THFile_seek(file, 0);
+ readObject();
+
+ net = net_;
+ std::vector<std::pair<int, Module*> > addedModules;
+ fill(rootModule, addedModules);
+
+ rootModule = NULL;
+ curModule = NULL;
+ }
+};
+
+Ptr<Importer> createTorchImporter(const String &filename, bool isBinary)
+{
+ return Ptr<Importer>(new TorchImporter(filename, isBinary));
+}
+
+
+Mat readTorchBlob(const String &filename, bool isBinary)
+{
+ Ptr<TorchImporter> importer(new TorchImporter(filename, isBinary));
+ importer->readObject();
+ CV_Assert(importer->tensors.size() == 1);
+
+ return importer->tensors.begin()->second;
+}
+
+#else
+
+Ptr<Importer> createTorchImporter(const String&, bool)
+{
+ CV_Error(Error::StsNotImplemented, "Torch importer is disabled in current build");
+ return Ptr<Importer>();
+}
+
+Mat readTorchBlob(const String&, bool)
+{
+ CV_Error(Error::StsNotImplemented, "Torch importer is disabled in current build");
+ return Mat();
+}
+
+#endif //defined(ENABLE_TORCH_IMPORTER) && ENABLE_TORCH_IMPORTER
+
+Net readNetFromTorch(const String &model, bool isBinary)
+{
+ CV_TRACE_FUNCTION();
+
+ Ptr<Importer> importer = createTorchImporter(model, isBinary);
+ Net net;
+ if (importer)
+ importer->populateNet(net);
+ return net;
+}
+
+CV__DNN_EXPERIMENTAL_NS_END
+}} // namespace
diff --git a/modules/dnn/test/cityscapes_semsegm_test_enet.py b/modules/dnn/test/cityscapes_semsegm_test_enet.py
new file mode 100644
index 0000000..5f0b4ba
--- /dev/null
+++ b/modules/dnn/test/cityscapes_semsegm_test_enet.py
@@ -0,0 +1,140 @@
+import numpy as np
+import sys
+import os
+import fnmatch
+import argparse
+
+try:
+ import cv2 as cv
+except ImportError:
+ raise ImportError('Can\'t find OpenCV Python module. If you\'ve built it from sources without installation, '
+ 'configure environemnt variable PYTHONPATH to "opencv_build_dir/lib" directory (with "python3" subdirectory if required)')
+try:
+ import torch
+except ImportError:
+ raise ImportError('Can\'t find pytorch. Please intall it by following instructions on the official site')
+
+from torch.utils.serialization import load_lua
+from pascal_semsegm_test_fcn import eval_segm_result, get_conf_mat, get_metrics, DatasetImageFetch, SemSegmEvaluation
+from imagenet_cls_test_alexnet import Framework, DnnCaffeModel
+
+
+class NormalizePreproc:
+ def __init__(self):
+ pass
+
+ @staticmethod
+ def process(img):
+ image_data = np.array(img).transpose(2, 0, 1).astype(np.float32)
+ image_data = np.expand_dims(image_data, 0)
+ image_data /= 255.0
+ return image_data
+
+
+class CityscapesDataFetch(DatasetImageFetch):
+ img_dir = ''
+ segm_dir = ''
+ segm_files = []
+ colors = []
+ i = 0
+
+ def __init__(self, img_dir, segm_dir, preproc):
+ self.img_dir = img_dir
+ self.segm_dir = segm_dir
+ self.segm_files = sorted([img for img in self.locate('*_color.png', segm_dir)])
+ self.colors = self.get_colors()
+ self.data_prepoc = preproc
+ self.i = 0
+
+ @staticmethod
+ def get_colors():
+ result = []
+ colors_list = (
+ (0, 0, 0), (128, 64, 128), (244, 35, 232), (70, 70, 70), (102, 102, 156), (190, 153, 153), (153, 153, 153),
+ (250, 170, 30), (220, 220, 0), (107, 142, 35), (152, 251, 152), (70, 130, 180), (220, 20, 60), (255, 0, 0),
+ (0, 0, 142), (0, 0, 70), (0, 60, 100), (0, 80, 100), (0, 0, 230), (119, 11, 32))
+
+ for c in colors_list:
+ result.append(DatasetImageFetch.pix_to_c(c))
+ return result
+
+ def __iter__(self):
+ return self
+
+ def next(self):
+ if self.i < len(self.segm_files):
+ segm_file = self.segm_files[self.i]
+ segm = cv.imread(segm_file, cv.IMREAD_COLOR)[:, :, ::-1]
+ segm = cv.resize(segm, (1024, 512), interpolation=cv.INTER_NEAREST)
+
+ img_file = self.rreplace(self.img_dir + segm_file[len(self.segm_dir):], 'gtFine_color', 'leftImg8bit')
+ assert os.path.exists(img_file)
+ img = cv.imread(img_file, cv.IMREAD_COLOR)[:, :, ::-1]
+ img = cv.resize(img, (1024, 512))
+
+ self.i += 1
+ gt = self.color_to_gt(segm, self.colors)
+ img = self.data_prepoc.process(img)
+ return img, gt
+ else:
+ self.i = 0
+ raise StopIteration
+
+ def get_num_classes(self):
+ return len(self.colors)
+
+ @staticmethod
+ def locate(pattern, root_path):
+ for path, dirs, files in os.walk(os.path.abspath(root_path)):
+ for filename in fnmatch.filter(files, pattern):
+ yield os.path.join(path, filename)
+
+ @staticmethod
+ def rreplace(s, old, new, occurrence=1):
+ li = s.rsplit(old, occurrence)
+ return new.join(li)
+
+
+class TorchModel(Framework):
+ net = object
+
+ def __init__(self, model_file):
+ self.net = load_lua(model_file)
+
+ def get_name(self):
+ return 'Torch'
+
+ def get_output(self, input_blob):
+ tensor = torch.FloatTensor(input_blob)
+ out = self.net.forward(tensor).numpy()
+ return out
+
+
+class DnnTorchModel(DnnCaffeModel):
+ net = cv.dnn.Net()
+
+ def __init__(self, model_file):
+ self.net = cv.dnn.readNetFromTorch(model_file)
+
+ def get_output(self, input_blob):
+ self.net.setBlob("", input_blob)
+ self.net.forward()
+ return self.net.getBlob(self.net.getLayerNames()[-1])
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser()
+ parser.add_argument("--imgs_dir", help="path to Cityscapes validation images dir, imgsfine/leftImg8bit/val")
+ parser.add_argument("--segm_dir", help="path to Cityscapes dir with segmentation, gtfine/gtFine/val")
+ parser.add_argument("--model", help="path to torch model, download it here: "
+ "https://www.dropbox.com/sh/dywzk3gyb12hpe5/AAD5YkUa8XgMpHs2gCRgmCVCa")
+ parser.add_argument("--log", help="path to logging file")
+ args = parser.parse_args()
+
+ prep = NormalizePreproc()
+ df = CityscapesDataFetch(args.imgs_dir, args.segm_dir, prep)
+
+ fw = [TorchModel(args.model),
+ DnnTorchModel(args.model)]
+
+ segm_eval = SemSegmEvaluation(args.log)
+ segm_eval.process(fw, df)
diff --git a/contrib/modules/dnn/test/cnpy.cpp b/modules/dnn/test/cnpy.cpp
similarity index 100%
rename from contrib/modules/dnn/test/cnpy.cpp
rename to modules/dnn/test/cnpy.cpp
diff --git a/contrib/modules/dnn/test/cnpy.h b/modules/dnn/test/cnpy.h
similarity index 100%
rename from contrib/modules/dnn/test/cnpy.h
rename to modules/dnn/test/cnpy.h
diff --git a/modules/dnn/test/imagenet_cls_test_alexnet.py b/modules/dnn/test/imagenet_cls_test_alexnet.py
new file mode 100644
index 0000000..46623b8
--- /dev/null
+++ b/modules/dnn/test/imagenet_cls_test_alexnet.py
@@ -0,0 +1,241 @@
+from abc import ABCMeta, abstractmethod
+import numpy as np
+import sys
+import os
+import argparse
+import time
+
+try:
+ import caffe
+except ImportError:
+ raise ImportError('Can\'t find Caffe Python module. If you\'ve built it from sources without installation, '
+ 'configure environemnt variable PYTHONPATH to "git/caffe/python" directory')
+try:
+ import cv2 as cv
+except ImportError:
+ raise ImportError('Can\'t find OpenCV Python module. If you\'ve built it from sources without installation, '
+ 'configure environemnt variable PYTHONPATH to "opencv_build_dir/lib" directory (with "python3" subdirectory if required)')
+
+
+class DataFetch(object):
+ imgs_dir = ''
+ frame_size = 0
+ bgr_to_rgb = False
+ __metaclass__ = ABCMeta
+
+ @abstractmethod
+ def preprocess(self, img):
+ pass
+
+ def get_batch(self, imgs_names):
+ assert type(imgs_names) is list
+ batch = np.zeros((len(imgs_names), 3, self.frame_size, self.frame_size)).astype(np.float32)
+ for i in range(len(imgs_names)):
+ img_name = imgs_names[i]
+ img_file = self.imgs_dir + img_name
+ assert os.path.exists(img_file)
+ img = cv.imread(img_file, cv.IMREAD_COLOR)
+ min_dim = min(img.shape[-3], img.shape[-2])
+ resize_ratio = self.frame_size / float(min_dim)
+ img = cv.resize(img, (0, 0), fx=resize_ratio, fy=resize_ratio)
+ cols = img.shape[1]
+ rows = img.shape[0]
+ y1 = (rows - self.frame_size) / 2
+ y2 = y1 + self.frame_size
+ x1 = (cols - self.frame_size) / 2
+ x2 = x1 + self.frame_size
+ img = img[y1:y2, x1:x2]
+ if self.bgr_to_rgb:
+ img = img[..., ::-1]
+ image_data = img[:, :, 0:3].transpose(2, 0, 1)
+ batch[i] = self.preprocess(image_data)
+ return batch
+
+
+class MeanBlobFetch(DataFetch):
+ mean_blob = np.ndarray(())
+
+ def __init__(self, frame_size, mean_blob_path, imgs_dir):
+ self.imgs_dir = imgs_dir
+ self.frame_size = frame_size
+ blob = caffe.proto.caffe_pb2.BlobProto()
+ data = open(mean_blob_path, 'rb').read()
+ blob.ParseFromString(data)
+ self.mean_blob = np.array(caffe.io.blobproto_to_array(blob))
+ start = (self.mean_blob.shape[2] - self.frame_size) / 2
+ stop = start + self.frame_size
+ self.mean_blob = self.mean_blob[:, :, start:stop, start:stop][0]
+
+ def preprocess(self, img):
+ return img - self.mean_blob
+
+
+class MeanChannelsFetch(MeanBlobFetch):
+ def __init__(self, frame_size, imgs_dir):
+ self.imgs_dir = imgs_dir
+ self.frame_size = frame_size
+ self.mean_blob = np.ones((3, self.frame_size, self.frame_size)).astype(np.float32)
+ self.mean_blob[0] *= 104
+ self.mean_blob[1] *= 117
+ self.mean_blob[2] *= 123
+
+
+class MeanValueFetch(MeanBlobFetch):
+ def __init__(self, frame_size, imgs_dir, bgr_to_rgb):
+ self.imgs_dir = imgs_dir
+ self.frame_size = frame_size
+ self.mean_blob = np.ones((3, self.frame_size, self.frame_size)).astype(np.float32)
+ self.mean_blob *= 117
+ self.bgr_to_rgb = bgr_to_rgb
+
+
+def get_correct_answers(img_list, img_classes, net_output_blob):
+ correct_answers = 0
+ for i in range(len(img_list)):
+ indexes = np.argsort(net_output_blob[i])[-5:]
+ correct_index = img_classes[img_list[i]]
+ if correct_index in indexes:
+ correct_answers += 1
+ return correct_answers
+
+
+class Framework(object):
+ in_blob_name = ''
+ out_blob_name = ''
+
+ __metaclass__ = ABCMeta
+
+ @abstractmethod
+ def get_name(self):
+ pass
+
+ @abstractmethod
+ def get_output(self, input_blob):
+ pass
+
+
+class CaffeModel(Framework):
+ net = caffe.Net
+ need_reshape = False
+
+ def __init__(self, prototxt, caffemodel, in_blob_name, out_blob_name, need_reshape=False):
+ caffe.set_mode_cpu()
+ self.net = caffe.Net(prototxt, caffemodel, caffe.TEST)
+ self.in_blob_name = in_blob_name
+ self.out_blob_name = out_blob_name
+ self.need_reshape = need_reshape
+
+ def get_name(self):
+ return 'Caffe'
+
+ def get_output(self, input_blob):
+ if self.need_reshape:
+ self.net.blobs[self.in_blob_name].reshape(*input_blob.shape)
+ return self.net.forward_all(**{self.in_blob_name: input_blob})[self.out_blob_name]
+
+
+class DnnCaffeModel(Framework):
+ net = object
+
+ def __init__(self, prototxt, caffemodel, in_blob_name, out_blob_name):
+ self.net = cv.dnn.readNetFromCaffe(prototxt, caffemodel)
+ self.in_blob_name = in_blob_name
+ self.out_blob_name = out_blob_name
+
+ def get_name(self):
+ return 'DNN'
+
+ def get_output(self, input_blob):
+ self.net.setInput(input_blob, self.in_blob_name)
+ return self.net.forward(self.out_blob_name)
+
+
+class ClsAccEvaluation:
+ log = file
+ img_classes = {}
+ batch_size = 0
+
+ def __init__(self, log_path, img_classes_file, batch_size):
+ self.log = open(log_path, 'w')
+ self.img_classes = self.read_classes(img_classes_file)
+ self.batch_size = batch_size
+
+ @staticmethod
+ def read_classes(img_classes_file):
+ result = {}
+ with open(img_classes_file) as file:
+ for l in file.readlines():
+ result[l.split()[0]] = int(l.split()[1])
+ return result
+
+ def process(self, frameworks, data_fetcher):
+ sorted_imgs_names = sorted(self.img_classes.keys())
+ correct_answers = [0] * len(frameworks)
+ samples_handled = 0
+ blobs_l1_diff = [0] * len(frameworks)
+ blobs_l1_diff_count = [0] * len(frameworks)
+ blobs_l_inf_diff = [sys.float_info.min] * len(frameworks)
+ inference_time = [0.0] * len(frameworks)
+
+ for x in xrange(0, len(sorted_imgs_names), self.batch_size):
+ sublist = sorted_imgs_names[x:x + self.batch_size]
+ batch = data_fetcher.get_batch(sublist)
+
+ samples_handled += len(sublist)
+
+ frameworks_out = []
+ fw_accuracy = []
+ for i in range(len(frameworks)):
+ start = time.time()
+ out = frameworks[i].get_output(batch)
+ end = time.time()
+ correct_answers[i] += get_correct_answers(sublist, self.img_classes, out)
+ fw_accuracy.append(100 * correct_answers[i] / float(samples_handled))
+ frameworks_out.append(out)
+ inference_time[i] += end - start
+ print >> self.log, samples_handled, 'Accuracy for', frameworks[i].get_name() + ':', fw_accuracy[i]
+ print >> self.log, "Inference time, ms ", \
+ frameworks[i].get_name(), inference_time[i] / samples_handled * 1000
+
+ for i in range(1, len(frameworks)):
+ log_str = frameworks[0].get_name() + " vs " + frameworks[i].get_name() + ':'
+ diff = np.abs(frameworks_out[0] - frameworks_out[i])
+ l1_diff = np.sum(diff) / diff.size
+ print >> self.log, samples_handled, "L1 difference", log_str, l1_diff
+ blobs_l1_diff[i] += l1_diff
+ blobs_l1_diff_count[i] += 1
+ if np.max(diff) > blobs_l_inf_diff[i]:
+ blobs_l_inf_diff[i] = np.max(diff)
+ print >> self.log, samples_handled, "L_INF difference", log_str, blobs_l_inf_diff[i]
+
+ self.log.flush()
+
+ for i in range(1, len(blobs_l1_diff)):
+ log_str = frameworks[0].get_name() + " vs " + frameworks[i].get_name() + ':'
+ print >> self.log, 'Final l1 diff', log_str, blobs_l1_diff[i] / blobs_l1_diff_count[i]
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser()
+ parser.add_argument("--imgs_dir", help="path to ImageNet validation subset images dir, ILSVRC2012_img_val dir")
+ parser.add_argument("--img_cls_file", help="path to file with classes ids for images, val.txt file from this "
+ "archive: http://dl.caffe.berkeleyvision.org/caffe_ilsvrc12.tar.gz")
+ parser.add_argument("--prototxt", help="path to caffe prototxt, download it here: "
+ "https://github.com/BVLC/caffe/blob/master/models/bvlc_alexnet/deploy.prototxt")
+ parser.add_argument("--caffemodel", help="path to caffemodel file, download it here: "
+ "http://dl.caffe.berkeleyvision.org/bvlc_alexnet.caffemodel")
+ parser.add_argument("--log", help="path to logging file")
+ parser.add_argument("--mean", help="path to ImageNet mean blob caffe file, imagenet_mean.binaryproto file from"
+ "this archive: http://dl.caffe.berkeleyvision.org/caffe_ilsvrc12.tar.gz")
+ parser.add_argument("--batch_size", help="size of images in batch", default=1000)
+ parser.add_argument("--frame_size", help="size of input image", default=227)
+ parser.add_argument("--in_blob", help="name for input blob", default='data')
+ parser.add_argument("--out_blob", help="name for output blob", default='prob')
+ args = parser.parse_args()
+
+ data_fetcher = MeanBlobFetch(args.frame_size, args.mean, args.imgs_dir)
+
+ frameworks = [CaffeModel(args.prototxt, args.caffemodel, args.in_blob, args.out_blob),
+ DnnCaffeModel(args.prototxt, args.caffemodel, '', args.out_blob)]
+
+ acc_eval = ClsAccEvaluation(args.log, args.img_cls_file, args.batch_size)
+ acc_eval.process(frameworks, data_fetcher)
diff --git a/modules/dnn/test/imagenet_cls_test_googlenet.py b/modules/dnn/test/imagenet_cls_test_googlenet.py
new file mode 100644
index 0000000..6c7305b
--- /dev/null
+++ b/modules/dnn/test/imagenet_cls_test_googlenet.py
@@ -0,0 +1,39 @@
+import numpy as np
+import sys
+import os
+import argparse
+from imagenet_cls_test_alexnet import MeanChannelsFetch, CaffeModel, DnnCaffeModel, ClsAccEvaluation
+try:
+ import caffe
+except ImportError:
+ raise ImportError('Can\'t find Caffe Python module. If you\'ve built it from sources without installation, '
+ 'configure environemnt variable PYTHONPATH to "git/caffe/python" directory')
+try:
+ import cv2 as cv
+except ImportError:
+ raise ImportError('Can\'t find OpenCV Python module. If you\'ve built it from sources without installation, '
+ 'configure environemnt variable PYTHONPATH to "opencv_build_dir/lib" directory (with "python3" subdirectory if required)')
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser()
+ parser.add_argument("--imgs_dir", help="path to ImageNet validation subset images dir, ILSVRC2012_img_val dir")
+ parser.add_argument("--img_cls_file", help="path to file with classes ids for images, val.txt file from this "
+ "archive: http://dl.caffe.berkeleyvision.org/caffe_ilsvrc12.tar.gz")
+ parser.add_argument("--prototxt", help="path to caffe prototxt, download it here: "
+ "https://github.com/BVLC/caffe/blob/master/models/bvlc_alexnet/deploy.prototxt")
+ parser.add_argument("--caffemodel", help="path to caffemodel file, download it here: "
+ "http://dl.caffe.berkeleyvision.org/bvlc_alexnet.caffemodel")
+ parser.add_argument("--log", help="path to logging file")
+ parser.add_argument("--batch_size", help="size of images in batch", default=500, type=int)
+ parser.add_argument("--frame_size", help="size of input image", default=224, type=int)
+ parser.add_argument("--in_blob", help="name for input blob", default='data')
+ parser.add_argument("--out_blob", help="name for output blob", default='prob')
+ args = parser.parse_args()
+
+ data_fetcher = MeanChannelsFetch(args.frame_size, args.imgs_dir)
+
+ frameworks = [CaffeModel(args.prototxt, args.caffemodel, args.in_blob, args.out_blob),
+ DnnCaffeModel(args.prototxt, args.caffemodel, '', args.out_blob)]
+
+ acc_eval = ClsAccEvaluation(args.log, args.img_cls_file, args.batch_size)
+ acc_eval.process(frameworks, data_fetcher)
diff --git a/modules/dnn/test/imagenet_cls_test_inception.py b/modules/dnn/test/imagenet_cls_test_inception.py
new file mode 100644
index 0000000..d6f0c55
--- /dev/null
+++ b/modules/dnn/test/imagenet_cls_test_inception.py
@@ -0,0 +1,77 @@
+import numpy as np
+import sys
+import os
+import argparse
+import tensorflow as tf
+from tensorflow.python.platform import gfile
+from imagenet_cls_test_alexnet import MeanValueFetch, DnnCaffeModel, Framework, ClsAccEvaluation
+try:
+ import cv2 as cv
+except ImportError:
+ raise ImportError('Can\'t find OpenCV Python module. If you\'ve built it from sources without installation, '
+ 'configure environemnt variable PYTHONPATH to "opencv_build_dir/lib" directory (with "python3" subdirectory if required)')
+
+# If you've got an exception "Cannot load libmkl_avx.so or libmkl_def.so" or similar, try to export next variable
+# before runnigng the script:
+# LD_PRELOAD=/opt/intel/mkl/lib/intel64/libmkl_core.so:/opt/intel/mkl/lib/intel64/libmkl_sequential.so
+
+
+class TensorflowModel(Framework):
+ sess = tf.Session
+ output = tf.Graph
+
+ def __init__(self, model_file, in_blob_name, out_blob_name):
+ self.in_blob_name = in_blob_name
+ self.sess = tf.Session()
+ with gfile.FastGFile(model_file, 'rb') as f:
+ graph_def = tf.GraphDef()
+ graph_def.ParseFromString(f.read())
+ self.sess.graph.as_default()
+ tf.import_graph_def(graph_def, name='')
+ self.output = self.sess.graph.get_tensor_by_name(out_blob_name + ":0")
+
+ def get_name(self):
+ return 'Tensorflow'
+
+ def get_output(self, input_blob):
+ assert len(input_blob.shape) == 4
+ batch_tf = input_blob.transpose(0, 2, 3, 1)
+ out = self.sess.run(self.output,
+ {self.in_blob_name+':0': batch_tf})
+ out = out[..., 1:1001]
+ return out
+
+
+class DnnTfInceptionModel(DnnCaffeModel):
+ net = cv.dnn.Net()
+
+ def __init__(self, model_file, in_blob_name, out_blob_name):
+ self.net = cv.dnn.readNetFromTensorflow(model_file)
+ self.in_blob_name = in_blob_name
+ self.out_blob_name = out_blob_name
+
+ def get_output(self, input_blob):
+ return super(DnnTfInceptionModel, self).get_output(input_blob)[..., 1:1001]
+
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser()
+ parser.add_argument("--imgs_dir", help="path to ImageNet validation subset images dir, ILSVRC2012_img_val dir")
+ parser.add_argument("--img_cls_file", help="path to file with classes ids for images, download it here:"
+ "https://github.com/opencv/opencv_extra/tree/master/testdata/dnn/img_classes_inception.txt")
+ parser.add_argument("--model", help="path to tensorflow model, download it here:"
+ "https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip")
+ parser.add_argument("--log", help="path to logging file")
+ parser.add_argument("--batch_size", help="size of images in batch", default=1)
+ parser.add_argument("--frame_size", help="size of input image", default=224)
+ parser.add_argument("--in_blob", help="name for input blob", default='input')
+ parser.add_argument("--out_blob", help="name for output blob", default='softmax2')
+ args = parser.parse_args()
+
+ data_fetcher = MeanValueFetch(args.frame_size, args.imgs_dir, True)
+
+ frameworks = [TensorflowModel(args.model, args.in_blob, args.out_blob),
+ DnnTfInceptionModel(args.model, '', args.out_blob)]
+
+ acc_eval = ClsAccEvaluation(args.log, args.img_cls_file, args.batch_size)
+ acc_eval.process(frameworks, data_fetcher)
diff --git a/modules/dnn/test/npy_blob.hpp b/modules/dnn/test/npy_blob.hpp
new file mode 100644
index 0000000..89bd240
--- /dev/null
+++ b/modules/dnn/test/npy_blob.hpp
@@ -0,0 +1,65 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#ifndef __OPENCV_DNN_TEST_NPY_BLOB_HPP__
+#define __OPENCV_DNN_TEST_NPY_BLOB_HPP__
+#include "test_precomp.hpp"
+#include "cnpy.h"
+
+namespace cv
+{
+
+inline Mat blobFromNPY(const String &path)
+{
+ cnpy::NpyArray npyBlob = cnpy::npy_load(path.c_str());
+ Mat blob = Mat((int)npyBlob.shape.size(), (int*)&npyBlob.shape[0], CV_32F, npyBlob.data).clone();
+ npyBlob.destruct();
+ return blob;
+}
+
+inline void saveBlobToNPY(const Mat &blob, const String &path)
+{
+ cnpy::npy_save(path.c_str(), blob.ptr<float>(), (unsigned*)&blob.size.p[0], blob.dims);
+}
+
+}
+
+#endif
diff --git a/modules/dnn/test/pascal_semsegm_test_fcn.py b/modules/dnn/test/pascal_semsegm_test_fcn.py
new file mode 100644
index 0000000..d855786
--- /dev/null
+++ b/modules/dnn/test/pascal_semsegm_test_fcn.py
@@ -0,0 +1,224 @@
+from abc import ABCMeta, abstractmethod
+import numpy as np
+import sys
+import argparse
+import time
+
+from imagenet_cls_test_alexnet import CaffeModel, DnnCaffeModel
+try:
+ import cv2 as cv
+except ImportError:
+ raise ImportError('Can\'t find OpenCV Python module. If you\'ve built it from sources without installation, '
+ 'configure environemnt variable PYTHONPATH to "opencv_build_dir/lib" directory (with "python3" subdirectory if required)')
+
+
+def get_metrics(conf_mat):
+ pix_accuracy = np.trace(conf_mat) / np.sum(conf_mat)
+ t = np.sum(conf_mat, 1)
+ num_cl = np.count_nonzero(t)
+ assert num_cl
+ mean_accuracy = np.sum(np.nan_to_num(np.divide(np.diagonal(conf_mat), t))) / num_cl
+ col_sum = np.sum(conf_mat, 0)
+ mean_iou = np.sum(
+ np.nan_to_num(np.divide(np.diagonal(conf_mat), (t + col_sum - np.diagonal(conf_mat))))) / num_cl
+ return pix_accuracy, mean_accuracy, mean_iou
+
+
+def eval_segm_result(net_out):
+ assert type(net_out) is np.ndarray
+ assert len(net_out.shape) == 4
+
+ channels_dim = 1
+ y_dim = channels_dim + 1
+ x_dim = y_dim + 1
+ res = np.zeros(net_out.shape).astype(np.int)
+ for i in range(net_out.shape[y_dim]):
+ for j in range(net_out.shape[x_dim]):
+ max_ch = np.argmax(net_out[..., i, j])
+ res[0, max_ch, i, j] = 1
+ return res
+
+
+def get_conf_mat(gt, prob):
+ assert type(gt) is np.ndarray
+ assert type(prob) is np.ndarray
+
+ conf_mat = np.zeros((gt.shape[0], gt.shape[0]))
+ for ch_gt in range(conf_mat.shape[0]):
+ gt_channel = gt[ch_gt, ...]
+ for ch_pr in range(conf_mat.shape[1]):
+ prob_channel = prob[ch_pr, ...]
+ conf_mat[ch_gt][ch_pr] = np.count_nonzero(np.multiply(gt_channel, prob_channel))
+ return conf_mat
+
+
+class MeanChannelsPreproc:
+ def __init__(self):
+ pass
+
+ @staticmethod
+ def process(img):
+ image_data = np.array(img).transpose(2, 0, 1).astype(np.float32)
+ mean = np.ones(image_data.shape)
+ mean[0] *= 104
+ mean[1] *= 117
+ mean[2] *= 123
+ image_data -= mean
+ image_data = np.expand_dims(image_data, 0)
+ return image_data
+
+
+class DatasetImageFetch(object):
+ __metaclass__ = ABCMeta
+ data_prepoc = object
+
+ @abstractmethod
+ def __iter__(self):
+ pass
+
+ @abstractmethod
+ def next(self):
+ pass
+
+ @staticmethod
+ def pix_to_c(pix):
+ return pix[0] * 256 * 256 + pix[1] * 256 + pix[2]
+
+ @staticmethod
+ def color_to_gt(color_img, colors):
+ num_classes = len(colors)
+ gt = np.zeros((num_classes, color_img.shape[0], color_img.shape[1])).astype(np.int)
+ for img_y in range(color_img.shape[0]):
+ for img_x in range(color_img.shape[1]):
+ c = DatasetImageFetch.pix_to_c(color_img[img_y][img_x])
+ if c in colors:
+ cls = colors.index(c)
+ gt[cls][img_y][img_x] = 1
+ return gt
+
+
+class PASCALDataFetch(DatasetImageFetch):
+ img_dir = ''
+ segm_dir = ''
+ names = []
+ colors = []
+ i = 0
+
+ def __init__(self, img_dir, segm_dir, names_file, segm_cls_colors_file, preproc):
+ self.img_dir = img_dir
+ self.segm_dir = segm_dir
+ self.colors = self.read_colors(segm_cls_colors_file)
+ self.data_prepoc = preproc
+ self.i = 0
+
+ with open(names_file) as f:
+ for l in f.readlines():
+ self.names.append(l.rstrip())
+
+ @staticmethod
+ def read_colors(img_classes_file):
+ result = []
+ with open(img_classes_file) as f:
+ for l in f.readlines():
+ color = np.array(map(int, l.split()[1:]))
+ result.append(DatasetImageFetch.pix_to_c(color))
+ return result
+
+ def __iter__(self):
+ return self
+
+ def next(self):
+ if self.i < len(self.names):
+ name = self.names[self.i]
+ self.i += 1
+ segm_file = self.segm_dir + name + ".png"
+ img_file = self.img_dir + name + ".jpg"
+ gt = self.color_to_gt(cv.imread(segm_file, cv.IMREAD_COLOR)[:, :, ::-1], self.colors)
+ img = self.data_prepoc.process(cv.imread(img_file, cv.IMREAD_COLOR)[:, :, ::-1])
+ return img, gt
+ else:
+ self.i = 0
+ raise StopIteration
+
+ def get_num_classes(self):
+ return len(self.colors)
+
+
+class SemSegmEvaluation:
+ log = file
+
+ def __init__(self, log_path,):
+ self.log = open(log_path, 'w')
+
+ def process(self, frameworks, data_fetcher):
+ samples_handled = 0
+
+ conf_mats = [np.zeros((data_fetcher.get_num_classes(), data_fetcher.get_num_classes())) for i in range(len(frameworks))]
+ blobs_l1_diff = [0] * len(frameworks)
+ blobs_l1_diff_count = [0] * len(frameworks)
+ blobs_l_inf_diff = [sys.float_info.min] * len(frameworks)
+ inference_time = [0.0] * len(frameworks)
+
+ for in_blob, gt in data_fetcher:
+ frameworks_out = []
+ samples_handled += 1
+ for i in range(len(frameworks)):
+ start = time.time()
+ out = frameworks[i].get_output(in_blob)
+ end = time.time()
+ segm = eval_segm_result(out)
+ conf_mats[i] += get_conf_mat(gt, segm[0])
+ frameworks_out.append(out)
+ inference_time[i] += end - start
+
+ pix_acc, mean_acc, miou = get_metrics(conf_mats[i])
+
+ name = frameworks[i].get_name()
+ print >> self.log, samples_handled, 'Pixel accuracy, %s:' % name, 100 * pix_acc
+ print >> self.log, samples_handled, 'Mean accuracy, %s:' % name, 100 * mean_acc
+ print >> self.log, samples_handled, 'Mean IOU, %s:' % name, 100 * miou
+ print >> self.log, "Inference time, ms ", \
+ frameworks[i].get_name(), inference_time[i] / samples_handled * 1000
+
+ for i in range(1, len(frameworks)):
+ log_str = frameworks[0].get_name() + " vs " + frameworks[i].get_name() + ':'
+ diff = np.abs(frameworks_out[0] - frameworks_out[i])
+ l1_diff = np.sum(diff) / diff.size
+ print >> self.log, samples_handled, "L1 difference", log_str, l1_diff
+ blobs_l1_diff[i] += l1_diff
+ blobs_l1_diff_count[i] += 1
+ if np.max(diff) > blobs_l_inf_diff[i]:
+ blobs_l_inf_diff[i] = np.max(diff)
+ print >> self.log, samples_handled, "L_INF difference", log_str, blobs_l_inf_diff[i]
+
+ self.log.flush()
+
+ for i in range(1, len(blobs_l1_diff)):
+ log_str = frameworks[0].get_name() + " vs " + frameworks[i].get_name() + ':'
+ print >> self.log, 'Final l1 diff', log_str, blobs_l1_diff[i] / blobs_l1_diff_count[i]
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser()
+ parser.add_argument("--imgs_dir", help="path to PASCAL VOC 2012 images dir, data/VOC2012/JPEGImages")
+ parser.add_argument("--segm_dir", help="path to PASCAL VOC 2012 segmentation dir, data/VOC2012/SegmentationClass/")
+ parser.add_argument("--val_names", help="path to file with validation set image names, download it here: "
+ "https://github.com/shelhamer/fcn.berkeleyvision.org/blob/master/data/pascal/seg11valid.txt")
+ parser.add_argument("--cls_file", help="path to file with colors for classes, download it here: "
+ "https://github.com/opencv/opencv/blob/master/samples/data/dnn/pascal-classes.txt")
+ parser.add_argument("--prototxt", help="path to caffe prototxt, download it here: "
+ "https://github.com/opencv/opencv/blob/master/samples/data/dnn/fcn8s-heavy-pascal.prototxt")
+ parser.add_argument("--caffemodel", help="path to caffemodel file, download it here: "
+ "http://dl.caffe.berkeleyvision.org/fcn8s-heavy-pascal.caffemodel")
+ parser.add_argument("--log", help="path to logging file")
+ parser.add_argument("--in_blob", help="name for input blob", default='data')
+ parser.add_argument("--out_blob", help="name for output blob", default='score')
+ args = parser.parse_args()
+
+ prep = MeanChannelsPreproc()
+ df = PASCALDataFetch(args.imgs_dir, args.segm_dir, args.val_names, args.cls_file, prep)
+
+ fw = [CaffeModel(args.prototxt, args.caffemodel, args.in_blob, args.out_blob, True),
+ DnnCaffeModel(args.prototxt, args.caffemodel, '', args.out_blob)]
+
+ segm_eval = SemSegmEvaluation(args.log)
+ segm_eval.process(fw, df)
diff --git a/modules/dnn/test/test_caffe_importer.cpp b/modules/dnn/test/test_caffe_importer.cpp
new file mode 100644
index 0000000..7fe7f1d
--- /dev/null
+++ b/modules/dnn/test/test_caffe_importer.cpp
@@ -0,0 +1,191 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "test_precomp.hpp"
+#include "npy_blob.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cvtest
+{
+
+using namespace cv;
+using namespace cv::dnn;
+
+template<typename TString>
+static std::string _tf(TString filename)
+{
+ return (getOpenCVExtraDir() + "/dnn/") + filename;
+}
+
+TEST(Test_Caffe, read_gtsrb)
+{
+ Net net;
+ {
+ Ptr<Importer> importer = createCaffeImporter(_tf("gtsrb.prototxt"), "");
+ ASSERT_TRUE(importer != NULL);
+ importer->populateNet(net);
+ }
+}
+
+TEST(Test_Caffe, read_googlenet)
+{
+ Net net;
+ {
+ Ptr<Importer> importer = createCaffeImporter(_tf("bvlc_googlenet.prototxt"), "");
+ ASSERT_TRUE(importer != NULL);
+ importer->populateNet(net);
+ }
+}
+
+TEST(Reproducibility_AlexNet, Accuracy)
+{
+ Net net;
+ {
+ const string proto = findDataFile("dnn/bvlc_alexnet.prototxt", false);
+ const string model = findDataFile("dnn/bvlc_alexnet.caffemodel", false);
+ Ptr<Importer> importer = createCaffeImporter(proto, model);
+ ASSERT_TRUE(importer != NULL);
+ importer->populateNet(net);
+ }
+
+ Mat sample = imread(_tf("grace_hopper_227.png"));
+ ASSERT_TRUE(!sample.empty());
+
+ Size inputSize(227, 227);
+
+ if (sample.size() != inputSize)
+ resize(sample, sample, inputSize);
+
+ net.setInput(blobFromImage(sample), "data");
+ Mat out = net.forward("prob");
+ Mat ref = blobFromNPY(_tf("caffe_alexnet_prob.npy"));
+ normAssert(ref, out);
+}
+
+#if !defined(_WIN32) || defined(_WIN64)
+TEST(Reproducibility_FCN, Accuracy)
+{
+ Net net;
+ {
+ const string proto = findDataFile("dnn/fcn8s-heavy-pascal.prototxt", false);
+ const string model = findDataFile("dnn/fcn8s-heavy-pascal.caffemodel", false);
+ Ptr<Importer> importer = createCaffeImporter(proto, model);
+ ASSERT_TRUE(importer != NULL);
+ importer->populateNet(net);
+ }
+
+ Mat sample = imread(_tf("street.png"));
+ ASSERT_TRUE(!sample.empty());
+
+ Size inputSize(500, 500);
+ if (sample.size() != inputSize)
+ resize(sample, sample, inputSize);
+
+ std::vector<int> layerIds;
+ std::vector<size_t> weights, blobs;
+ net.getMemoryConsumption(shape(1,3,227,227), layerIds, weights, blobs);
+
+ net.setInput(blobFromImage(sample), "data");
+ Mat out = net.forward("score");
+ Mat ref = blobFromNPY(_tf("caffe_fcn8s_prob.npy"));
+ normAssert(ref, out);
+}
+#endif
+
+TEST(Reproducibility_SSD, Accuracy)
+{
+ Net net;
+ {
+ const string proto = findDataFile("dnn/ssd_vgg16.prototxt", false);
+ const string model = findDataFile("dnn/VGG_ILSVRC2016_SSD_300x300_iter_440000.caffemodel", false);
+ Ptr<Importer> importer = createCaffeImporter(proto, model);
+ ASSERT_TRUE(importer != NULL);
+ importer->populateNet(net);
+ }
+
+ Mat sample = imread(_tf("street.png"));
+ ASSERT_TRUE(!sample.empty());
+
+ if (sample.channels() == 4)
+ cvtColor(sample, sample, COLOR_BGRA2BGR);
+
+ sample.convertTo(sample, CV_32F);
+ resize(sample, sample, Size(300, 300));
+
+ Mat in_blob = blobFromImage(sample);
+ net.setInput(in_blob, "data");
+ Mat out = net.forward("detection_out");
+
+ Mat ref = blobFromNPY(_tf("ssd_out.npy"));
+ normAssert(ref, out);
+}
+
+TEST(Reproducibility_ResNet50, Accuracy)
+{
+ Net net = readNetFromCaffe(findDataFile("dnn/ResNet-50-deploy.prototxt", false),
+ findDataFile("dnn/ResNet-50-model.caffemodel", false));
+
+ Mat input = blobFromImage(imread(_tf("googlenet_0.png")), 1, Size(224,224));
+ ASSERT_TRUE(!input.empty());
+
+ net.setInput(input);
+ Mat out = net.forward();
+
+ Mat ref = blobFromNPY(_tf("resnet50_prob.npy"));
+ normAssert(ref, out);
+}
+
+TEST(Reproducibility_SqueezeNet_v1_1, Accuracy)
+{
+ Net net = readNetFromCaffe(findDataFile("dnn/squeezenet_v1.1.prototxt", false),
+ findDataFile("dnn/squeezenet_v1.1.caffemodel", false));
+
+ Mat input = blobFromImage(imread(_tf("googlenet_0.png")), 1, Size(227,227));
+ ASSERT_TRUE(!input.empty());
+
+ net.setInput(input);
+ Mat out = net.forward();
+
+ Mat ref = blobFromNPY(_tf("squeezenet_v1.1_prob.npy"));
+ normAssert(ref, out);
+}
+
+}
diff --git a/modules/dnn/test/test_common.hpp b/modules/dnn/test/test_common.hpp
new file mode 100644
index 0000000..a436dae
--- /dev/null
+++ b/modules/dnn/test/test_common.hpp
@@ -0,0 +1,60 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#ifndef __OPENCV_TEST_COMMON_HPP__
+#define __OPENCV_TEST_COMMON_HPP__
+
+inline const std::string &getOpenCVExtraDir()
+{
+ return cvtest::TS::ptr()->get_data_path();
+}
+
+inline void normAssert(cv::InputArray ref, cv::InputArray test, const char *comment = "",
+ double l1 = 0.00001, double lInf = 0.0001)
+{
+ double normL1 = cvtest::norm(ref, test, cv::NORM_L1) / ref.getMat().total();
+ EXPECT_LE(normL1, l1) << comment;
+
+ double normInf = cvtest::norm(ref, test, cv::NORM_INF);
+ EXPECT_LE(normInf, lInf) << comment;
+}
+
+#endif
diff --git a/modules/dnn/test/test_googlenet.cpp b/modules/dnn/test/test_googlenet.cpp
new file mode 100644
index 0000000..2486916
--- /dev/null
+++ b/modules/dnn/test/test_googlenet.cpp
@@ -0,0 +1,131 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "test_precomp.hpp"
+#include "npy_blob.hpp"
+#include <opencv2/core/ocl.hpp>
+#include <opencv2/ts/ocl_test.hpp>
+
+namespace cvtest
+{
+
+using namespace cv;
+using namespace cv::dnn;
+
+template<typename TString>
+static std::string _tf(TString filename)
+{
+ return (getOpenCVExtraDir() + "/dnn/") + filename;
+}
+
+TEST(Reproducibility_GoogLeNet, Accuracy)
+{
+ Net net = readNetFromCaffe(findDataFile("dnn/bvlc_googlenet.prototxt", false),
+ findDataFile("dnn/bvlc_googlenet.caffemodel", false));
+
+ std::vector<Mat> inpMats;
+ inpMats.push_back( imread(_tf("googlenet_0.png")) );
+ inpMats.push_back( imread(_tf("googlenet_1.png")) );
+ ASSERT_TRUE(!inpMats[0].empty() && !inpMats[1].empty());
+
+ net.setInput(blobFromImages(inpMats), "data");
+ Mat out = net.forward("prob");
+
+ Mat ref = blobFromNPY(_tf("googlenet_prob.npy"));
+ normAssert(out, ref);
+}
+
+TEST(IntermediateBlobs_GoogLeNet, Accuracy)
+{
+ Net net = readNetFromCaffe(findDataFile("dnn/bvlc_googlenet.prototxt", false),
+ findDataFile("dnn/bvlc_googlenet.caffemodel", false));
+
+ std::vector<String> blobsNames;
+ blobsNames.push_back("conv1/7x7_s2");
+ blobsNames.push_back("conv1/relu_7x7");
+ blobsNames.push_back("inception_4c/1x1");
+ blobsNames.push_back("inception_4c/relu_1x1");
+ std::vector<Mat> outs;
+ Mat in = blobFromImage(imread(_tf("googlenet_0.png")));
+ net.setInput(in, "data");
+ net.forward(outs, blobsNames);
+ CV_Assert(outs.size() == blobsNames.size());
+
+ for (int i = 0; i < blobsNames.size(); i++)
+ {
+ std::string filename = blobsNames[i];
+ std::replace( filename.begin(), filename.end(), '/', '#');
+ Mat ref = blobFromNPY(_tf("googlenet_" + filename + ".npy"));
+
+ normAssert(outs[i], ref, "", 1E-4, 1E-2);
+ }
+}
+
+TEST(SeveralCalls_GoogLeNet, Accuracy)
+{
+ Net net = readNetFromCaffe(findDataFile("dnn/bvlc_googlenet.prototxt", false),
+ findDataFile("dnn/bvlc_googlenet.caffemodel", false));
+
+ std::vector<Mat> inpMats;
+ inpMats.push_back( imread(_tf("googlenet_0.png")) );
+ inpMats.push_back( imread(_tf("googlenet_1.png")) );
+ ASSERT_TRUE(!inpMats[0].empty() && !inpMats[1].empty());
+
+ net.setInput(blobFromImages(inpMats), "data");
+ Mat out = net.forward();
+
+ Mat ref = blobFromNPY(_tf("googlenet_prob.npy"));
+ normAssert(out, ref);
+
+ std::vector<String> blobsNames;
+ blobsNames.push_back("conv1/7x7_s2");
+ std::vector<Mat> outs;
+ Mat in = blobFromImage(inpMats[0]);
+ net.setInput(in, "data");
+ net.forward(outs, blobsNames);
+ CV_Assert(outs.size() == blobsNames.size());
+
+ ref = blobFromNPY(_tf("googlenet_conv1#7x7_s2.npy"));
+
+ normAssert(outs[0], ref, "", 1E-4, 1E-2);
+}
+
+}
diff --git a/modules/dnn/test/test_halide_layers.cpp b/modules/dnn/test/test_halide_layers.cpp
new file mode 100644
index 0000000..f3dd2bf
--- /dev/null
+++ b/modules/dnn/test/test_halide_layers.cpp
@@ -0,0 +1,651 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+//
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+
+// This tests doesn't require any external data. They just compare outputs of
+// layers using different computation backends. Input and parameters are random.
+
+#include "test_precomp.hpp"
+
+namespace cvtest
+{
+
+#ifdef HAVE_HALIDE
+using namespace cv;
+using namespace cv::dnn;
+using namespace testing;
+
+static void test(LayerParams& params, Mat& input)
+{
+ randu(input, -1.0f, 1.0f);
+
+ Net net;
+ int lid = net.addLayer(params.name, params.type, params);
+ net.connect(0, 0, lid, 0);
+
+ net.setInput(input);
+ Mat outputDefault = net.forward(params.name).clone();
+
+ net.setPreferableBackend(DNN_BACKEND_HALIDE);
+ Mat outputHalide = net.forward(params.name).clone();
+ normAssert(outputDefault, outputHalide);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Convolution
+////////////////////////////////////////////////////////////////////////////////
+typedef TestWithParam<tuple<Vec3i, Size, Size, Size, Size, Size, bool> > Convolution;
+TEST_P(Convolution, Accuracy)
+{
+ int inChannels = get<0>(GetParam())[0];
+ int outChannels = get<0>(GetParam())[1];
+ int group = get<0>(GetParam())[2];
+ Size inSize = get<1>(GetParam());
+ Size kernel = get<2>(GetParam());
+ Size stride = get<3>(GetParam());
+ Size pad = get<4>(GetParam());
+ Size dilation = get<5>(GetParam());
+ bool hasBias = get<6>(GetParam());
+
+ Mat weights({outChannels, inChannels / group, kernel.height, kernel.width}, CV_32F);
+ randu(weights, -1.0f, 1.0f);
+
+ LayerParams lp;
+ lp.set("kernel_w", kernel.width);
+ lp.set("kernel_h", kernel.height);
+ lp.set("pad_w", pad.width);
+ lp.set("pad_h", pad.height);
+ lp.set("stride_w", stride.width);
+ lp.set("stride_h", stride.height);
+ lp.set("dilation_w", dilation.width);
+ lp.set("dilation_h", dilation.height);
+ lp.set("num_output", outChannels);
+ lp.set("group", group);
+ lp.set("bias_term", hasBias);
+ lp.type = "Convolution";
+ lp.name = "testLayer";
+ lp.blobs.push_back(weights);
+ if (hasBias)
+ {
+ Mat bias({outChannels}, CV_32F);
+ randu(bias, -1.0f, 1.0f);
+ lp.blobs.push_back(bias);
+ }
+ Mat input({1, inChannels, inSize.height, inSize.width}, CV_32F);
+ test(lp, input);
+}
+
+INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, Convolution, Combine(
+/*in channels, out channels, group*/
+ Values(Vec3i(6, 4, 1), Vec3i(6, 9, 1),
+ Vec3i(6, 4, 2), Vec3i(6, 9, 3)),
+/*in size*/ Values(Size(5, 6)),
+/*kernel*/ Values(Size(3, 1), Size(1, 3)),
+/*stride*/ Values(Size(1, 1), Size(2, 2)),
+/*pad*/ Values(Size(1, 0), Size(0, 1)),
+/*dilation*/ Values(Size(1, 1), Size(2, 2)),
+/*has bias*/ Bool()
+));
+
+////////////////////////////////////////////////////////////////////////////////
+// Deconvolution
+////////////////////////////////////////////////////////////////////////////////
+typedef TestWithParam<tuple<Vec3i, Size, Size, Size, Size, Vec4i, bool> > Deconvolution;
+TEST_P(Deconvolution, Accuracy)
+{
+ int inChannels = get<0>(GetParam())[0];
+ int outChannels = get<0>(GetParam())[1];
+ int group = get<0>(GetParam())[2];
+ Size inSize = get<1>(GetParam());
+ Size kernel = get<2>(GetParam());
+ Size pad = get<3>(GetParam());
+ Size dilation = get<4>(GetParam());
+ Size stride = Size(get<5>(GetParam())[0], get<5>(GetParam())[1]);
+ Size adjPad = Size(get<5>(GetParam())[2], get<5>(GetParam())[3]);
+ bool hasBias = get<6>(GetParam());
+
+ Mat weights({outChannels, inChannels / group, kernel.height, kernel.width}, CV_32F);
+ randu(weights, -1.0f, 1.0f);
+
+ LayerParams lp;
+ lp.set("kernel_w", kernel.width);
+ lp.set("kernel_h", kernel.height);
+ lp.set("pad_w", pad.width);
+ lp.set("pad_h", pad.height);
+ lp.set("stride_w", stride.width);
+ lp.set("stride_h", stride.height);
+ lp.set("dilation_w", dilation.width);
+ lp.set("dilation_h", dilation.height);
+ lp.set("adj_w", adjPad.width);
+ lp.set("adj_h", adjPad.height);
+ lp.set("num_output", outChannels);
+ lp.set("group", group);
+ lp.set("bias_term", hasBias);
+ lp.type = "Deconvolution";
+ lp.name = "testLayer";
+ lp.blobs.push_back(weights);
+ if (hasBias)
+ {
+ Mat bias({outChannels}, CV_32F);
+ randu(bias, -1.0f, 1.0f);
+ lp.blobs.push_back(bias);
+ }
+ Mat input({1, inChannels, inSize.height, inSize.width}, CV_32F);
+ test(lp, input);
+}
+
+INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, Deconvolution, Combine(
+/*in channels, out channels, group*/
+ Values(Vec3i(6, 4, 1), Vec3i(6, 9, 1)),
+/*in size*/ Values(Size(5, 6)),
+/*kernel*/ Values(Size(3, 1), Size(1, 3)),
+/*pad*/ Values(Size(1, 0), Size(0, 1)),
+/*dilation*/ Values(Size(1, 1), Size(2, 2)),
+/*stride, adj. pad*/ Values(Vec4i(1,1, 0,0), Vec4i(2,2, 1,0), Vec4i(1,2, 0,1)),
+/*has bias*/ Bool()
+));
+
+////////////////////////////////////////////////////////////////////////////////
+// LRN
+////////////////////////////////////////////////////////////////////////////////
+typedef TestWithParam<tuple<Vec3i, int, Vec3f, bool, std::string> > LRN;
+TEST_P(LRN, Accuracy)
+{
+ int inChannels = get<0>(GetParam())[0];
+ Size inSize = Size(get<0>(GetParam())[1], get<0>(GetParam())[2]);
+ int localSize = get<1>(GetParam());
+ float alpha = get<2>(GetParam())[0];
+ float beta = get<2>(GetParam())[1];
+ float bias = get<2>(GetParam())[2];
+ bool normBySize = get<3>(GetParam());
+ std::string nrmType = get<4>(GetParam());
+
+ LayerParams lp;
+ lp.set("norm_region", nrmType);
+ lp.set("local_size", localSize);
+ lp.set("alpha", alpha);
+ lp.set("beta", beta);
+ lp.set("bias", bias);
+ lp.set("norm_by_size", normBySize);
+ lp.type = "LRN";
+ lp.name = "testLayer";
+
+ Mat input({1, inChannels, inSize.height, inSize.width}, CV_32F);
+ test(lp, input);
+}
+
+INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, LRN, Combine(
+/*input ch,w,h*/ Values(Vec3i(6, 5, 8), Vec3i(7, 11, 6)),
+/*local size*/ Values(3, 5),
+ Values(Vec3f(0.9f, 1.0f, 1.1f), Vec3f(0.9f, 1.1f, 1.0f),
+/*alpha, beta,*/ Vec3f(1.0f, 0.9f, 1.1f), Vec3f(1.0f, 1.1f, 0.9f),
+/*bias */ Vec3f(1.1f, 0.9f, 1.0f), Vec3f(1.1f, 1.0f, 0.9f)),
+/*norm_by_size*/ Bool(),
+/*norm_type*/ Values("ACROSS_CHANNELS", "WITHIN_CHANNEL")
+));
+
+////////////////////////////////////////////////////////////////////////////////
+// Average pooling
+////////////////////////////////////////////////////////////////////////////////
+typedef TestWithParam<tuple<int, Size, Size, Size> > AvePooling;
+TEST_P(AvePooling, Accuracy)
+{
+ int inChannels = get<0>(GetParam());
+ Size outSize = get<1>(GetParam());; // Input size will be computed from parameters.
+ Size kernel = get<2>(GetParam());
+ Size stride = get<3>(GetParam());
+
+ const int inWidth = (outSize.width - 1) * stride.width + kernel.width;
+ const int inHeight = (outSize.height - 1) * stride.height + kernel.height;
+
+ LayerParams lp;
+ lp.set("pool", "ave");
+ lp.set("kernel_w", kernel.width);
+ lp.set("kernel_h", kernel.height);
+ lp.set("stride_w", stride.width);
+ lp.set("stride_h", stride.height);
+ lp.type = "Pooling";
+ lp.name = "testLayer";
+
+ Mat input({1, inChannels, inHeight, inWidth}, CV_32F);
+ test(lp, input);
+}
+
+INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, AvePooling, Combine(
+/*in channels*/ Values(3, 4),
+/*out size*/ Values(Size(1, 1), Size(2, 2), Size(3, 2), Size(4, 7)),
+/*kernel*/ Values(Size(1, 1), Size(2, 2), Size(3, 3), Size(3, 2)),
+/*stride*/ Values(Size(1, 1), Size(2, 2), Size(3, 2))
+));
+
+////////////////////////////////////////////////////////////////////////////////
+// Maximum pooling
+////////////////////////////////////////////////////////////////////////////////
+typedef TestWithParam<tuple<int, Size, Size, Size, Size> > MaxPooling;
+TEST_P(MaxPooling, Accuracy)
+{
+ int inChannels = get<0>(GetParam());
+ Size inSize = get<1>(GetParam());
+ Size kernel = get<2>(GetParam());
+ Size stride = get<3>(GetParam());
+ Size pad = get<4>(GetParam());
+
+ LayerParams lp;
+ lp.set("pool", "max");
+ lp.set("kernel_w", kernel.width);
+ lp.set("kernel_h", kernel.height);
+ lp.set("stride_w", stride.width);
+ lp.set("stride_h", stride.height);
+ lp.set("pad_w", pad.width);
+ lp.set("pad_h", pad.height);
+ lp.type = "Pooling";
+ lp.name = "testLayer";
+
+ Mat input({1, inChannels, inSize.height, inSize.width}, CV_32F);
+ test(lp, input);
+}
+
+INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, MaxPooling, Combine(
+/*in channels*/ Values(3, 4),
+/*in size*/ Values(Size(5, 5), Size(7, 6)),
+/*kernel*/ Values(Size(2, 2), Size(3, 3), Size(3, 2)),
+/*stride*/ Values(Size(1, 1), Size(2, 2), Size(3, 2)),
+/*pad*/ Values(Size(0, 0), Size(1, 1), Size(0, 1))
+));
+
+////////////////////////////////////////////////////////////////////////////////
+// Fully-connected
+////////////////////////////////////////////////////////////////////////////////
+typedef TestWithParam<tuple<int, Size, int, bool> > FullyConnected;
+TEST_P(FullyConnected, Accuracy)
+{
+ int inChannels = get<0>(GetParam());
+ Size inSize = get<1>(GetParam());
+ int outChannels = get<2>(GetParam());
+ bool hasBias = get<3>(GetParam());
+
+ Mat weights(outChannels, inChannels * inSize.height * inSize.width, CV_32F);
+ randu(weights, -1.0f, 1.0f);
+
+ Mat bias(1, outChannels, CV_32F);
+ randu(bias, -1.0f, 1.0f);
+
+ LayerParams lp;
+ lp.set("num_output", outChannels);
+ lp.set("bias_term", hasBias);
+ lp.blobs.push_back(weights);
+ lp.blobs.push_back(bias);
+ lp.type = "InnerProduct";
+ lp.name = "testLayer";
+
+ Mat input({1, inChannels, inSize.height, inSize.width}, CV_32F);
+ test(lp, input);
+}
+
+INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, FullyConnected, Combine(
+/*in channels*/ Values(3, 4),
+/*in size*/ Values(Size(5, 4), Size(4, 5), Size(1, 1)),
+/*out channels*/ Values(3, 4),
+/*has bias*/ Bool()
+));
+
+////////////////////////////////////////////////////////////////////////////////
+// SoftMax
+////////////////////////////////////////////////////////////////////////////////
+typedef TestWithParam<tuple<int> > SoftMax;
+TEST_P(SoftMax, Accuracy)
+{
+ int inChannels = get<0>(GetParam());
+ LayerParams lp;
+ lp.type = "SoftMax";
+ lp.name = "testLayer";
+
+ Mat input({1, inChannels, 1, 1}, CV_32F);
+ test(lp, input);
+}
+
+INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, SoftMax, Values(3, 4, 5, 1024));
+
+//////////////////////////////////////////////////////////////////////////////
+// Max pooling - unpooling
+//////////////////////////////////////////////////////////////////////////////
+TEST(MaxPoolUnpool_Halide, Accuracy)
+{
+ LayerParams pool;
+ pool.set("pool", "max");
+ pool.set("kernel_w", 2);
+ pool.set("kernel_h", 2);
+ pool.set("stride_w", 2);
+ pool.set("stride_h", 2);
+ pool.set("pad_w", 0);
+ pool.set("pad_h", 0);
+ pool.type = "Pooling";
+ pool.name = "testPool";
+
+ LayerParams unpool;
+ unpool.set("pool_k_w", 2);
+ unpool.set("pool_k_h", 2);
+ unpool.set("pool_stride_w", 2);
+ unpool.set("pool_stride_h", 2);
+ unpool.set("pool_pad_w", 0);
+ unpool.set("pool_pad_h", 0);
+ unpool.type = "MaxUnpool";
+ unpool.name = "testUnpool";
+
+ Net net;
+ int poolId = net.addLayer(pool.name, pool.type, pool);
+ net.connect(0, 0, poolId, 0);
+
+ int unpoolId = net.addLayer(unpool.name, unpool.type, unpool);
+ net.connect(poolId, 0, unpoolId, 0);
+ net.connect(poolId, 1, unpoolId, 1);
+
+ Mat input({1, 1, 4, 4}, CV_32F);
+ randu(input, -1.0f, 1.0f);
+ net.setInput(input);
+ Mat outputDefault = net.forward("testUnpool").clone();
+
+ net.setPreferableBackend(DNN_BACKEND_HALIDE);
+ net.setInput(input);
+ Mat outputHalide = net.forward("testUnpool").clone();
+ normAssert(outputDefault, outputHalide);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// AvePooling + in-place layers
+////////////////////////////////////////////////////////////////////////////////
+static const int kNumChannels = 3;
+
+void testInPlaceActivation(LayerParams& lp)
+{
+ EXPECT_FALSE(lp.name.empty());
+
+ LayerParams pool;
+ pool.set("pool", "ave");
+ pool.set("kernel_w", 2);
+ pool.set("kernel_h", 2);
+ pool.set("stride_w", 2);
+ pool.set("stride_h", 2);
+ pool.type = "Pooling";
+
+ Net net;
+ int poolId = net.addLayer(pool.name, pool.type, pool);
+ net.connect(0, 0, poolId, 0);
+ net.addLayerToPrev(lp.name, lp.type, lp);
+
+ Mat input({1, kNumChannels, 10, 10}, CV_32F);
+ randu(input, -1.0f, 1.0f);
+ net.setInput(input);
+ Mat outputDefault = net.forward(lp.name).clone();
+
+ net.setInput(input);
+ net.setPreferableBackend(DNN_BACKEND_HALIDE);
+ Mat outputHalide = net.forward(lp.name).clone();
+ normAssert(outputDefault, outputHalide);
+}
+
+typedef TestWithParam<tuple<bool, bool, float> > BatchNorm;
+TEST_P(BatchNorm, Accuracy)
+{
+ bool hasWeights = get<0>(GetParam());
+ bool hasBias = get<1>(GetParam());
+ float epsilon = get<2>(GetParam());
+
+ LayerParams lp;
+ lp.set("has_weight", hasWeights);
+ lp.set("has_bias", hasBias);
+ lp.set("eps", epsilon);
+ lp.type = "BatchNorm";
+ lp.name = "testLayer";
+
+ lp.blobs.reserve(4);
+ for (int i = 0; i < 3; ++i)
+ lp.blobs.push_back(Mat({kNumChannels}, CV_32F));
+ if (hasBias || hasWeights)
+ lp.blobs.push_back(Mat({kNumChannels}, CV_32F));
+
+ for (Mat& m : lp.blobs)
+ randu(m, 0.0f, 1.0f);
+
+ testInPlaceActivation(lp);
+}
+
+INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, BatchNorm, Combine(
+/*has weights*/ Bool(),
+/*has bias*/ Bool(),
+/*epsilon*/ Values(1e-3f, 1e-5f)
+));
+
+typedef TestWithParam<tuple<float> > ReLU;
+TEST_P(ReLU, Accuracy)
+{
+ float negativeSlope = get<0>(GetParam());
+
+ LayerParams lp;
+ lp.set("negative_slope", negativeSlope);
+ lp.type = "ReLU";
+ lp.name = "testLayer";
+ testInPlaceActivation(lp);
+}
+
+INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, ReLU, Values(
+/*negative slope*/ 2.0f, 0.3f, -0.1f, 0.0f
+));
+
+typedef TestWithParam<tuple<std::string> > NoParamActivation;
+TEST_P(NoParamActivation, Accuracy)
+{
+ LayerParams lp;
+ lp.type = get<0>(GetParam());
+ lp.name = "testLayer";
+ testInPlaceActivation(lp);
+}
+INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, NoParamActivation, Values(
+/*type*/ "TanH", "Sigmoid", "AbsVal", "BNLL"
+));
+
+typedef TestWithParam<tuple<Vec3f> > Power;
+TEST_P(Power, Accuracy)
+{
+ float power = get<0>(GetParam())[0];
+ float scale = get<0>(GetParam())[1];
+ float shift = get<0>(GetParam())[2];
+
+ LayerParams lp;
+ lp.set("power", power);
+ lp.set("scale", scale);
+ lp.set("shift", shift);
+ lp.type = "Power";
+ lp.name = "testLayer";
+ testInPlaceActivation(lp);
+}
+
+INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, Power,
+/*power, scale, shift*/ Values(Vec3f(0.9f, 1.0f, 1.1f), Vec3f(0.9f, 1.1f, 1.0f),
+ Vec3f(1.0f, 0.9f, 1.1f), Vec3f(1.0f, 1.1f, 0.9f),
+ Vec3f(1.1f, 0.9f, 1.0f), Vec3f(1.1f, 1.0f, 0.9f))
+);
+
+TEST(ChannelsPReLU, Accuracy)
+{
+ LayerParams lp;
+ lp.type = "ChannelsPReLU";
+ lp.name = "testLayer";
+ lp.blobs.push_back(Mat({kNumChannels}, CV_32F));
+ randu(lp.blobs[0], -1.0f, 1.0f);
+
+ testInPlaceActivation(lp);
+}
+
+typedef TestWithParam<tuple<bool> > Scale;
+TEST_P(Scale, Accuracy)
+{
+ bool hasBias = get<0>(GetParam());
+
+ LayerParams lp;
+ lp.set("bias_term", hasBias);
+ lp.type = "Scale";
+ lp.name = "testLayer";
+ lp.blobs.push_back(Mat({kNumChannels}, CV_32F));
+ randu(lp.blobs[0], -1.0f, 1.0f);
+ if (hasBias)
+ {
+ lp.blobs.push_back(Mat({kNumChannels}, CV_32F));
+ randu(lp.blobs[1], -1.0f, 1.0f);
+ }
+ testInPlaceActivation(lp);
+}
+
+INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, Scale, Values(true, false));
+
+////////////////////////////////////////////////////////////////////////////////
+// Concat layer
+////////////////////////////////////////////////////////////////////////////////
+//
+// input --- conv --- concat --- output
+// `--- conv ----^ ^ ^
+// `---- ... ------' '
+// `-----------------'
+typedef TestWithParam<tuple<Vec3i, Vec3i> > Concat;
+TEST_P(Concat, Accuracy)
+{
+ Vec3i inSize = get<0>(GetParam());
+ Vec3i numChannels = get<1>(GetParam());
+
+ Net net;
+
+ std::vector<int> convLayerIds;
+ convLayerIds.reserve(numChannels.channels);
+ for (int i = 0, n = numChannels.channels; i < n; ++i)
+ {
+ if (!numChannels[i])
+ break;
+
+ Mat weights({numChannels[i], inSize[0], 1, 1}, CV_32F);
+ randu(weights, -1.0f, 1.0f);
+
+ LayerParams convParam;
+ convParam.set("kernel_w", 1);
+ convParam.set("kernel_h", 1);
+ convParam.set("num_output", numChannels[i]);
+ convParam.set("bias_term", false);
+ convParam.type = "Convolution";
+ std::ostringstream ss;
+ ss << "convLayer" << i;
+ convParam.name = ss.str();
+ convParam.blobs.push_back(weights);
+
+ int layerId = net.addLayer(convParam.name, convParam.type, convParam);
+ convLayerIds.push_back(layerId);
+ net.connect(0, 0, layerId, 0);
+ }
+
+ LayerParams concatParam;
+ concatParam.type = "Concat";
+ concatParam.name = "testLayer";
+ int concatId = net.addLayer(concatParam.name, concatParam.type, concatParam);
+ net.connect(0, 0, concatId, 0);
+ for (int i = 0; i < convLayerIds.size(); ++i)
+ {
+ net.connect(convLayerIds[i], 0, concatId, i + 1);
+ }
+
+ Mat input({1, inSize[0], inSize[1], inSize[2]}, CV_32F);
+ randu(input, -1.0f, 1.0f);
+
+ net.setInput(input);
+ Mat outputDefault = net.forward(concatParam.name).clone();
+
+ net.setPreferableBackend(DNN_BACKEND_HALIDE);
+ Mat outputHalide = net.forward(concatParam.name).clone();
+ normAssert(outputDefault, outputHalide);
+}
+
+INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, Concat, Combine(
+/*input size*/ Values(Vec3i(1, 4, 5), Vec3i(2, 8, 6)),
+/*channels*/ Values(Vec3i(2, 0, 0), Vec3i(3, 4, 0), Vec3i(1, 6, 2))
+));
+
+////////////////////////////////////////////////////////////////////////////////
+// Element-wise layers
+////////////////////////////////////////////////////////////////////////////////
+//
+// input --- conv --- eltwise --- output
+// `--- conv ----^ ^ ^
+// `---- ... ------' '
+// `-----------------'
+typedef TestWithParam<tuple<Vec3i, std::string, int, bool> > Eltwise;
+TEST_P(Eltwise, Accuracy)
+{
+ Vec3i inSize = get<0>(GetParam());
+ std::string op = get<1>(GetParam());
+ int numConv = get<2>(GetParam());
+ bool weighted = get<3>(GetParam());
+
+ Net net;
+
+ std::vector<int> convLayerIds(numConv);
+ for (int i = 0; i < numConv; ++i)
+ {
+ Mat weights({inSize[0], inSize[0], 1, 1}, CV_32F);
+ randu(weights, -1.0f, 1.0f);
+
+ LayerParams convParam;
+ convParam.set("kernel_w", 1);
+ convParam.set("kernel_h", 1);
+ convParam.set("num_output", inSize[0]);
+ convParam.set("bias_term", false);
+ convParam.type = "Convolution";
+ std::ostringstream ss;
+ ss << "convLayer" << i;
+ convParam.name = ss.str();
+ convParam.blobs.push_back(weights);
+
+ convLayerIds[i] = net.addLayer(convParam.name, convParam.type, convParam);
+ net.connect(0, 0, convLayerIds[i], 0);
+ }
+
+ LayerParams eltwiseParam;
+ eltwiseParam.set("operation", op);
+ if (op == "sum" && weighted)
+ {
+ RNG rng = cv::theRNG();
+ std::vector<float> coeff(1 + numConv);
+ for (int i = 0; i < coeff.size(); ++i)
+ {
+ coeff[i] = rng.uniform(-2.0f, 2.0f);
+ }
+ eltwiseParam.set("coeff", DictValue::arrayReal<float*>(&coeff[0], coeff.size()));
+ }
+ eltwiseParam.type = "Eltwise";
+ eltwiseParam.name = "testLayer";
+ int eltwiseId = net.addLayer(eltwiseParam.name, eltwiseParam.type, eltwiseParam);
+ net.connect(0, 0, eltwiseId, 0);
+ for (int i = 0; i < numConv; ++i)
+ {
+ net.connect(convLayerIds[i], 0, eltwiseId, i + 1);
+ }
+
+ Mat input({1, inSize[0], inSize[1], inSize[2]}, CV_32F);
+ randu(input, -1.0f, 1.0f);
+
+ net.setInput(input);
+ Mat outputDefault = net.forward(eltwiseParam.name).clone();
+
+ net.setPreferableBackend(DNN_BACKEND_HALIDE);
+ Mat outputHalide = net.forward(eltwiseParam.name).clone();
+ normAssert(outputDefault, outputHalide);
+}
+
+INSTANTIATE_TEST_CASE_P(Layer_Test_Halide, Eltwise, Combine(
+/*input size*/ Values(Vec3i(1, 4, 5), Vec3i(2, 8, 6)),
+/*operation*/ Values("prod", "sum", "max"),
+/*num convs*/ Values(1, 2, 3),
+/*weighted(for sum only)*/ Bool()
+));
+#endif // HAVE_HALIDE
+
+} // namespace cvtest
diff --git a/modules/dnn/test/test_halide_nets.cpp b/modules/dnn/test/test_halide_nets.cpp
new file mode 100644
index 0000000..c1ac2ff
--- /dev/null
+++ b/modules/dnn/test/test_halide_nets.cpp
@@ -0,0 +1,175 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+//
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+
+#include "test_precomp.hpp"
+
+namespace cvtest
+{
+
+#ifdef HAVE_HALIDE
+using namespace cv;
+using namespace dnn;
+
+static void loadNet(const std::string& weights, const std::string& proto,
+ const std::string& framework, Net* net)
+{
+ if (framework == "caffe")
+ {
+ *net = cv::dnn::readNetFromCaffe(proto, weights);
+ }
+ else if (framework == "torch")
+ {
+ *net = cv::dnn::readNetFromTorch(weights);
+ }
+ else if (framework == "tensorflow")
+ {
+ *net = cv::dnn::readNetFromTensorflow(weights);
+ }
+ else
+ CV_Error(Error::StsNotImplemented, "Unknown framework " + framework);
+}
+
+static void test(const std::string& weights, const std::string& proto,
+ const std::string& scheduler, int inWidth, int inHeight,
+ const std::string& outputLayer, const std::string& framework,
+ int targetId, double l1 = 1e-5, double lInf = 1e-4)
+{
+ Mat input(inHeight, inWidth, CV_32FC3), outputDefault, outputHalide;
+ randu(input, 0.0f, 1.0f);
+
+ Net netDefault, netHalide;
+ loadNet(weights, proto, framework, &netDefault);
+ loadNet(weights, proto, framework, &netHalide);
+
+ netDefault.setInput(blobFromImage(input.clone(), 1.0f, Size(), Scalar(), false));
+ outputDefault = netDefault.forward(outputLayer).clone();
+
+ netHalide.setInput(blobFromImage(input.clone(), 1.0f, Size(), Scalar(), false));
+ netHalide.setPreferableBackend(DNN_BACKEND_HALIDE);
+ netHalide.setPreferableTarget(targetId);
+ netHalide.setHalideScheduler(scheduler);
+ outputHalide = netHalide.forward(outputLayer).clone();
+
+ normAssert(outputDefault, outputHalide, "First run", l1, lInf);
+
+ // An extra test: change input.
+ input *= 0.1f;
+ netDefault.setInput(blobFromImage(input.clone(), 1.0, Size(), Scalar(), false));
+ netHalide.setInput(blobFromImage(input.clone(), 1.0, Size(), Scalar(), false));
+
+ normAssert(outputDefault, outputHalide, "Second run", l1, lInf);
+
+ // Swap backends.
+ netHalide.setPreferableBackend(DNN_BACKEND_DEFAULT);
+ netHalide.setPreferableTarget(DNN_TARGET_CPU);
+ outputDefault = netHalide.forward(outputLayer).clone();
+
+ netDefault.setPreferableBackend(DNN_BACKEND_HALIDE);
+ netDefault.setPreferableTarget(targetId);
+ netDefault.setHalideScheduler(scheduler);
+ outputHalide = netDefault.forward(outputLayer).clone();
+
+ normAssert(outputDefault, outputHalide, "Swap backends", l1, lInf);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// CPU target
+////////////////////////////////////////////////////////////////////////////////
+TEST(Reproducibility_GoogLeNet_Halide, Accuracy)
+{
+ test(findDataFile("dnn/bvlc_googlenet.caffemodel", false),
+ findDataFile("dnn/bvlc_googlenet.prototxt", false),
+ "", 227, 227, "prob", "caffe", DNN_TARGET_CPU);
+};
+
+TEST(Reproducibility_AlexNet_Halide, Accuracy)
+{
+ test(findDataFile("dnn/bvlc_alexnet.caffemodel", false),
+ findDataFile("dnn/bvlc_alexnet.prototxt", false),
+ findDataFile("dnn/halide_scheduler_alexnet.yml", false),
+ 227, 227, "prob", "caffe", DNN_TARGET_CPU);
+};
+
+TEST(Reproducibility_ResNet_50_Halide, Accuracy)
+{
+ test(findDataFile("dnn/ResNet-50-model.caffemodel", false),
+ findDataFile("dnn/ResNet-50-deploy.prototxt", false),
+ findDataFile("dnn/halide_scheduler_resnet_50.yml", false),
+ 224, 224, "prob", "caffe", DNN_TARGET_CPU);
+};
+
+TEST(Reproducibility_SqueezeNet_v1_1_Halide, Accuracy)
+{
+ test(findDataFile("dnn/squeezenet_v1.1.caffemodel", false),
+ findDataFile("dnn/squeezenet_v1.1.prototxt", false),
+ findDataFile("dnn/halide_scheduler_squeezenet_v1_1.yml", false),
+ 227, 227, "prob", "caffe", DNN_TARGET_CPU);
+};
+
+TEST(Reproducibility_Inception_5h_Halide, Accuracy)
+{
+ test(findDataFile("dnn/tensorflow_inception_graph.pb", false), "",
+ findDataFile("dnn/halide_scheduler_inception_5h.yml", false),
+ 224, 224, "softmax2", "tensorflow", DNN_TARGET_CPU);
+};
+
+TEST(Reproducibility_ENet_Halide, Accuracy)
+{
+ test(findDataFile("dnn/Enet-model-best.net", false), "",
+ findDataFile("dnn/halide_scheduler_enet.yml", false),
+ 512, 512, "l367_Deconvolution", "torch", DNN_TARGET_CPU, 2e-5, 0.15);
+};
+////////////////////////////////////////////////////////////////////////////////
+// OpenCL target
+////////////////////////////////////////////////////////////////////////////////
+TEST(Reproducibility_GoogLeNet_Halide_opencl, Accuracy)
+{
+ test(findDataFile("dnn/bvlc_googlenet.caffemodel", false),
+ findDataFile("dnn/bvlc_googlenet.prototxt", false),
+ "", 227, 227, "prob", "caffe", DNN_TARGET_OPENCL);
+};
+
+TEST(Reproducibility_AlexNet_Halide_opencl, Accuracy)
+{
+ test(findDataFile("dnn/bvlc_alexnet.caffemodel", false),
+ findDataFile("dnn/bvlc_alexnet.prototxt", false),
+ findDataFile("dnn/halide_scheduler_opencl_alexnet.yml", false),
+ 227, 227, "prob", "caffe", DNN_TARGET_OPENCL);
+};
+
+TEST(Reproducibility_ResNet_50_Halide_opencl, Accuracy)
+{
+ test(findDataFile("dnn/ResNet-50-model.caffemodel", false),
+ findDataFile("dnn/ResNet-50-deploy.prototxt", false),
+ findDataFile("dnn/halide_scheduler_opencl_resnet_50.yml", false),
+ 224, 224, "prob", "caffe", DNN_TARGET_OPENCL);
+};
+
+TEST(Reproducibility_SqueezeNet_v1_1_Halide_opencl, Accuracy)
+{
+ test(findDataFile("dnn/squeezenet_v1.1.caffemodel", false),
+ findDataFile("dnn/squeezenet_v1.1.prototxt", false),
+ findDataFile("dnn/halide_scheduler_opencl_squeezenet_v1_1.yml", false),
+ 227, 227, "prob", "caffe", DNN_TARGET_OPENCL);
+};
+
+TEST(Reproducibility_Inception_5h_Halide_opencl, Accuracy)
+{
+ test(findDataFile("dnn/tensorflow_inception_graph.pb", false), "",
+ findDataFile("dnn/halide_scheduler_opencl_inception_5h.yml", false),
+ 224, 224, "softmax2", "tensorflow", DNN_TARGET_OPENCL);
+};
+
+TEST(Reproducibility_ENet_Halide_opencl, Accuracy)
+{
+ test(findDataFile("dnn/Enet-model-best.net", false), "",
+ findDataFile("dnn/halide_scheduler_opencl_enet.yml", false),
+ 512, 512, "l367_Deconvolution", "torch", DNN_TARGET_OPENCL, 2e-5, 0.14);
+};
+#endif // HAVE_HALIDE
+
+} // namespace cvtest
diff --git a/modules/dnn/test/test_layers.cpp b/modules/dnn/test/test_layers.cpp
new file mode 100644
index 0000000..4ca06ef
--- /dev/null
+++ b/modules/dnn/test/test_layers.cpp
@@ -0,0 +1,435 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "test_precomp.hpp"
+#include <opencv2/core/ocl.hpp>
+#include <iostream>
+#include "npy_blob.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+#include <opencv2/dnn/all_layers.hpp>
+#include <opencv2/ts/ocl_test.hpp>
+
+namespace cvtest
+{
+
+using namespace cv;
+using namespace cv::dnn;
+
+template<typename TString>
+static String _tf(TString filename)
+{
+ String basetestdir = getOpenCVExtraDir();
+ size_t len = basetestdir.size();
+ if(len > 0 && basetestdir[len-1] != '/' && basetestdir[len-1] != '\\')
+ return (basetestdir + "/dnn/layers") + filename;
+ return (basetestdir + "dnn/layers/") + filename;
+}
+
+void runLayer(Ptr<Layer> layer, std::vector<Mat> &inpBlobs, std::vector<Mat> &outBlobs)
+{
+ size_t i, ninputs = inpBlobs.size();
+ std::vector<Mat> inp_(ninputs);
+ std::vector<Mat*> inp(ninputs);
+ std::vector<Mat> outp, intp;
+ std::vector<MatShape> inputs, outputs, internals;
+
+ for( i = 0; i < ninputs; i++ )
+ {
+ inp_[i] = inpBlobs[i].clone();
+ inp[i] = &inp_[i];
+ inputs.push_back(shape(inp_[i]));
+ }
+
+ layer->getMemoryShapes(inputs, 0, outputs, internals);
+ for(int i = 0; i < outputs.size(); i++)
+ {
+ outp.push_back(Mat(outputs[i], CV_32F));
+ }
+ for(int i = 0; i < internals.size(); i++)
+ {
+ intp.push_back(Mat(internals[i], CV_32F));
+ }
+
+ layer->finalize(inp, outp);
+ layer->forward(inp, outp, intp);
+
+ size_t noutputs = outp.size();
+ outBlobs.resize(noutputs);
+ for( i = 0; i < noutputs; i++ )
+ outBlobs[i] = outp[i];
+}
+
+
+void testLayerUsingCaffeModels(String basename, bool useCaffeModel = false, bool useCommonInputBlob = true)
+{
+ String prototxt = _tf(basename + ".prototxt");
+ String caffemodel = _tf(basename + ".caffemodel");
+
+ String inpfile = (useCommonInputBlob) ? _tf("blob.npy") : _tf(basename + ".input.npy");
+ String outfile = _tf(basename + ".npy");
+
+ cv::setNumThreads(cv::getNumberOfCPUs());
+
+ Net net;
+ {
+ Ptr<Importer> importer = createCaffeImporter(prototxt, (useCaffeModel) ? caffemodel : String());
+ ASSERT_TRUE(importer != NULL);
+ importer->populateNet(net);
+ }
+
+ Mat inp = blobFromNPY(inpfile);
+ Mat ref = blobFromNPY(outfile);
+
+ net.setInput(inp, "input");
+ Mat out = net.forward("output");
+
+ normAssert(ref, out);
+}
+
+TEST(Layer_Test_Softmax, Accuracy)
+{
+ testLayerUsingCaffeModels("layer_softmax");
+}
+
+TEST(Layer_Test_LRN_spatial, Accuracy)
+{
+ testLayerUsingCaffeModels("layer_lrn_spatial");
+}
+
+TEST(Layer_Test_LRN_channels, Accuracy)
+{
+ testLayerUsingCaffeModels("layer_lrn_channels");
+}
+
+TEST(Layer_Test_Convolution, Accuracy)
+{
+ testLayerUsingCaffeModels("layer_convolution", true);
+}
+
+TEST(Layer_Test_DeConvolution, Accuracy)
+{
+ testLayerUsingCaffeModels("layer_deconvolution", true, false);
+}
+
+TEST(Layer_Test_InnerProduct, Accuracy)
+{
+ testLayerUsingCaffeModels("layer_inner_product", true);
+}
+
+TEST(Layer_Test_Pooling_max, Accuracy)
+{
+ testLayerUsingCaffeModels("layer_pooling_max");
+}
+
+TEST(Layer_Test_Pooling_ave, Accuracy)
+{
+ testLayerUsingCaffeModels("layer_pooling_ave");
+}
+
+TEST(Layer_Test_MVN, Accuracy)
+{
+ testLayerUsingCaffeModels("layer_mvn");
+}
+
+void testReshape(const MatShape& inputShape, const MatShape& targetShape,
+ int axis = 0, int num_axes = -1, bool reorder_dims = false,
+ MatShape mask = MatShape())
+{
+ LayerParams params;
+ params.set("axis", axis);
+ params.set("num_axes", num_axes);
+ params.set("reorder_dims", reorder_dims);
+ if (!mask.empty())
+ {
+ params.set("dim", DictValue::arrayInt<int*>(&mask[0], mask.size()));
+ }
+
+ Mat inp(inputShape.size(), &inputShape[0], CV_32F);
+ std::vector<Mat> inpVec(1, inp);
+ std::vector<Mat> outVec, intVec;
+
+ Ptr<Layer> rl = LayerFactory::createLayerInstance("Reshape", params);
+ runLayer(rl, inpVec, outVec);
+
+ Mat& out = outVec[0];
+ MatShape shape(out.size.p, out.size.p + out.dims);
+ EXPECT_EQ(shape, targetShape);
+}
+
+TEST(Layer_Test_Reshape, Accuracy)
+{
+ {
+ int inp[] = {4, 3, 1, 2};
+ int out[] = {4, 3, 2};
+ testReshape(MatShape(inp, inp + 4), MatShape(out, out + 3), 2, 1);
+ }
+ {
+ int inp[] = {1, 128, 4, 4};
+ int out[] = {1, 2048};
+ int mask[] = {-1, 2048};
+ testReshape(MatShape(inp, inp + 4), MatShape(out, out + 2), 0, -1, true,
+ MatShape(mask, mask + 2));
+ }
+}
+
+TEST(Layer_Test_BatchNorm, Accuracy)
+{
+ testLayerUsingCaffeModels("layer_batch_norm", true);
+}
+
+TEST(Layer_Test_ReLU, Accuracy)
+{
+ testLayerUsingCaffeModels("layer_relu");
+}
+
+TEST(Layer_Test_Dropout, Accuracy)
+{
+ testLayerUsingCaffeModels("layer_dropout");
+}
+
+TEST(Layer_Test_Concat, Accuracy)
+{
+ testLayerUsingCaffeModels("layer_concat");
+}
+
+//template<typename XMat>
+//static void test_Layer_Concat()
+//{
+// Matx21f a(1.f, 1.f), b(2.f, 2.f), c(3.f, 3.f);
+// std::vector<Blob> res(1), src = { Blob(XMat(a)), Blob(XMat(b)), Blob(XMat(c)) };
+// Blob ref(XMat(Matx23f(1.f, 2.f, 3.f, 1.f, 2.f, 3.f)));
+//
+// runLayer(ConcatLayer::create(1), src, res);
+// normAssert(ref, res[0]);
+//}
+//TEST(Layer_Concat, Accuracy)
+//{
+// test_Layer_Concat<Mat>());
+//}
+//OCL_TEST(Layer_Concat, Accuracy)
+//{
+// OCL_ON(test_Layer_Concat<Mat>());
+// );
+//}
+
+static void test_Reshape_Split_Slice_layers()
+{
+ Net net;
+ {
+ Ptr<Importer> importer = createCaffeImporter(_tf("reshape_and_slice_routines.prototxt"));
+ ASSERT_TRUE(importer != NULL);
+ importer->populateNet(net);
+ }
+
+ Mat input(6, 12, CV_32F);
+ RNG rng(0);
+ rng.fill(input, RNG::UNIFORM, -1, 1);
+
+ net.setInput(input, "input");
+ Mat output = net.forward("output");
+
+ normAssert(input, output);
+}
+
+TEST(Layer_Test_Reshape_Split_Slice, Accuracy)
+{
+ test_Reshape_Split_Slice_layers();
+}
+
+TEST(Layer_Conv_Elu, Accuracy)
+{
+ Net net;
+ {
+ Ptr<Importer> importer = createTensorflowImporter(_tf("layer_elu_model.pb"));
+ ASSERT_TRUE(importer != NULL);
+ importer->populateNet(net);
+ }
+ Mat inp = blobFromNPY(_tf("layer_elu_in.npy"));
+ Mat ref = blobFromNPY(_tf("layer_elu_out.npy"));
+
+ net.setInput(inp, "input");
+ Mat out = net.forward();
+
+ normAssert(ref, out);
+}
+
+class Layer_LSTM_Test : public ::testing::Test
+{
+public:
+ int numInp, numOut;
+ Mat Wh, Wx, b;
+ Ptr<LSTMLayer> layer;
+ std::vector<Mat> inputs, outputs;
+
+ Layer_LSTM_Test() {}
+
+ void init(const MatShape &inpShape_, const MatShape &outShape_)
+ {
+ numInp = total(inpShape_);
+ numOut = total(outShape_);
+
+ Wh = Mat::ones(4 * numOut, numOut, CV_32F);
+ Wx = Mat::ones(4 * numOut, numInp, CV_32F);
+ b = Mat::ones(4 * numOut, 1, CV_32F);
+
+ layer = LSTMLayer::create(LayerParams());
+ layer->setWeights(Wh, Wx, b);
+ layer->setOutShape(outShape_);
+ }
+};
+
+TEST_F(Layer_LSTM_Test, get_set_test)
+{
+ const int TN = 4;
+ MatShape inpShape = shape(5, 3, 2);
+ MatShape outShape = shape(3, 1, 2);
+ MatShape inpResShape = concat(shape(TN), inpShape);
+ MatShape outResShape = concat(shape(TN), outShape);
+
+ init(inpShape, outShape);
+ layer->setProduceCellOutput(true);
+ layer->setUseTimstampsDim(false);
+ layer->setOutShape(outShape);
+
+ Mat C((int)outResShape.size(), &outResShape[0], CV_32F);
+ randu(C, -1., 1.);
+ Mat H = C.clone();
+ randu(H, -1., 1.);
+
+ Mat inp((int)inpResShape.size(), &inpResShape[0], CV_32F);
+ randu(inp, -1., 1.);
+
+ inputs.push_back(inp);
+ runLayer(layer, inputs, outputs);
+
+ EXPECT_EQ(2u, outputs.size());
+
+ print(outResShape, "outResShape");
+ print(shape(outputs[0]), "out0");
+ print(shape(outputs[0]), "out1");
+
+ EXPECT_EQ(outResShape, shape(outputs[0]));
+ EXPECT_EQ(outResShape, shape(outputs[1]));
+
+ EXPECT_EQ(0, layer->inputNameToIndex("x"));
+ EXPECT_EQ(0, layer->outputNameToIndex("h"));
+ EXPECT_EQ(1, layer->outputNameToIndex("c"));
+}
+
+TEST(Layer_LSTM_Test_Accuracy_with_, CaffeRecurrent)
+{
+ Ptr<LSTMLayer> layer = LSTMLayer::create(LayerParams());
+
+ Mat Wx = blobFromNPY(_tf("lstm.prototxt.w_0.npy"));
+ Mat Wh = blobFromNPY(_tf("lstm.prototxt.w_2.npy"));
+ Mat b = blobFromNPY(_tf("lstm.prototxt.w_1.npy"));
+ layer->setWeights(Wh, Wx, b);
+
+ Mat inp = blobFromNPY(_tf("recurrent.input.npy"));
+ std::vector<Mat> inputs(1, inp), outputs;
+ runLayer(layer, inputs, outputs);
+
+ Mat h_t_reference = blobFromNPY(_tf("lstm.prototxt.h_1.npy"));
+ normAssert(h_t_reference, outputs[0]);
+}
+
+TEST(Layer_RNN_Test_Accuracy_with_, CaffeRecurrent)
+{
+ Ptr<RNNLayer> layer = RNNLayer::create(LayerParams());
+
+ layer->setWeights(
+ blobFromNPY(_tf("rnn.prototxt.w_0.npy")),
+ blobFromNPY(_tf("rnn.prototxt.w_1.npy")),
+ blobFromNPY(_tf("rnn.prototxt.w_2.npy")),
+ blobFromNPY(_tf("rnn.prototxt.w_3.npy")),
+ blobFromNPY(_tf("rnn.prototxt.w_4.npy")) );
+
+ std::vector<Mat> output, input(1, blobFromNPY(_tf("recurrent.input.npy")));
+ runLayer(layer, input, output);
+
+ Mat h_ref = blobFromNPY(_tf("rnn.prototxt.h_1.npy"));
+ normAssert(h_ref, output[0]);
+}
+
+
+class Layer_RNN_Test : public ::testing::Test
+{
+public:
+ int nX, nH, nO, nT, nS;
+ Mat Whh, Wxh, bh, Who, bo;
+ Ptr<RNNLayer> layer;
+
+ std::vector<Mat> inputs, outputs;
+
+ Layer_RNN_Test()
+ {
+ nT = 3;
+ nS = 5;
+ nX = 31;
+ nH = 64;
+ nO = 100;
+
+ Whh = Mat::ones(nH, nH, CV_32F);
+ Wxh = Mat::ones(nH, nX, CV_32F);
+ bh = Mat::ones(nH, 1, CV_32F);
+ Who = Mat::ones(nO, nH, CV_32F);
+ bo = Mat::ones(nO, 1, CV_32F);
+
+ layer = RNNLayer::create(LayerParams());
+ layer->setProduceHiddenOutput(true);
+ layer->setWeights(Wxh, bh, Whh, Who, bo);
+ }
+};
+
+TEST_F(Layer_RNN_Test, get_set_test)
+{
+ int sz[] = { nT, nS, 1, nX };
+ Mat inp(4, sz, CV_32F);
+ randu(inp, -1., 1.);
+ inputs.push_back(inp);
+ runLayer(layer, inputs, outputs);
+
+ EXPECT_EQ(outputs.size(), 2u);
+ EXPECT_EQ(shape(outputs[0]), shape(nT, nS, nO));
+ EXPECT_EQ(shape(outputs[1]), shape(nT, nS, nH));
+}
+
+}
diff --git a/modules/dnn/test/test_main.cpp b/modules/dnn/test/test_main.cpp
new file mode 100644
index 0000000..ead7916
--- /dev/null
+++ b/modules/dnn/test/test_main.cpp
@@ -0,0 +1,20 @@
+#include "test_precomp.hpp"
+
+static const char* extraTestDataPath =
+#ifdef WINRT
+ NULL;
+#else
+ getenv("OPENCV_DNN_TEST_DATA_PATH");
+#endif
+
+CV_TEST_MAIN("",
+ extraTestDataPath ? (void)cvtest::addDataSearchPath(extraTestDataPath) : (void)0
+)
+
+namespace cvtest
+{
+
+using namespace cv;
+using namespace cv::dnn;
+
+}
diff --git a/contrib/modules/dnn/test/test_precomp.hpp b/modules/dnn/test/test_precomp.hpp
similarity index 100%
rename from contrib/modules/dnn/test/test_precomp.hpp
rename to modules/dnn/test/test_precomp.hpp
diff --git a/modules/dnn/test/test_tf_importer.cpp b/modules/dnn/test/test_tf_importer.cpp
new file mode 100644
index 0000000..8a6d495
--- /dev/null
+++ b/modules/dnn/test/test_tf_importer.cpp
@@ -0,0 +1,128 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+// Copyright (C) 2016, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+
+/*
+Test for Tensorflow models loading
+*/
+
+#include "test_precomp.hpp"
+#include "npy_blob.hpp"
+
+namespace cvtest
+{
+
+using namespace cv;
+using namespace cv::dnn;
+
+template<typename TString>
+static std::string _tf(TString filename)
+{
+ return (getOpenCVExtraDir() + "/dnn/") + filename;
+}
+
+TEST(Test_TensorFlow, read_inception)
+{
+ Net net;
+ {
+ const string model = findDataFile("dnn/tensorflow_inception_graph.pb", false);
+ Ptr<Importer> importer = createTensorflowImporter(model);
+ ASSERT_TRUE(importer != NULL);
+ importer->populateNet(net);
+ }
+
+ Mat sample = imread(_tf("grace_hopper_227.png"));
+ ASSERT_TRUE(!sample.empty());
+ Mat input;
+ resize(sample, input, Size(224, 224));
+ input -= 128; // mean sub
+
+ Mat inputBlob = blobFromImage(input);
+
+ net.setInput(inputBlob, "input");
+ Mat out = net.forward("softmax2");
+
+ std::cout << out.dims << std::endl;
+}
+
+TEST(Test_TensorFlow, inception_accuracy)
+{
+ Net net;
+ {
+ const string model = findDataFile("dnn/tensorflow_inception_graph.pb", false);
+ Ptr<Importer> importer = createTensorflowImporter(model);
+ ASSERT_TRUE(importer != NULL);
+ importer->populateNet(net);
+ }
+
+ Mat sample = imread(_tf("grace_hopper_227.png"));
+ ASSERT_TRUE(!sample.empty());
+ resize(sample, sample, Size(224, 224));
+ Mat inputBlob = blobFromImage(sample);
+
+ net.setInput(inputBlob, "input");
+ Mat out = net.forward("softmax2");
+
+ Mat ref = blobFromNPY(_tf("tf_inception_prob.npy"));
+
+ normAssert(ref, out);
+}
+
+static std::string path(const std::string& file)
+{
+ return findDataFile("dnn/tensorflow/" + file, false);
+}
+
+static void runTensorFlowNet(const std::string& prefix)
+{
+ std::string netPath = path(prefix + "_net.pb");
+ std::string inpPath = path(prefix + "_in.npy");
+ std::string outPath = path(prefix + "_out.npy");
+
+ Net net = readNetFromTensorflow(netPath);
+
+ cv::Mat input = blobFromNPY(inpPath);
+ cv::Mat target = blobFromNPY(outPath);
+
+ net.setInput(input);
+ cv::Mat output = net.forward();
+ normAssert(target, output);
+}
+
+TEST(Test_TensorFlow, single_conv)
+{
+ runTensorFlowNet("single_conv");
+}
+
+TEST(Test_TensorFlow, padding)
+{
+ runTensorFlowNet("padding_same");
+ runTensorFlowNet("padding_valid");
+}
+
+TEST(Test_TensorFlow, eltwise_add_mul)
+{
+ runTensorFlowNet("eltwise_add_mul");
+}
+
+TEST(Test_TensorFlow, pad_and_concat)
+{
+ runTensorFlowNet("pad_and_concat");
+}
+
+TEST(Test_TensorFlow, fused_batch_norm)
+{
+ runTensorFlowNet("fused_batch_norm");
+}
+
+TEST(Test_TensorFlow, pooling)
+{
+ runTensorFlowNet("max_pool_even");
+ runTensorFlowNet("max_pool_odd_valid");
+ runTensorFlowNet("max_pool_odd_same");
+}
+
+}
diff --git a/modules/dnn/test/test_torch_importer.cpp b/modules/dnn/test/test_torch_importer.cpp
new file mode 100644
index 0000000..5fc3c07
--- /dev/null
+++ b/modules/dnn/test/test_torch_importer.cpp
@@ -0,0 +1,207 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#ifdef ENABLE_TORCH_IMPORTER
+
+#include "test_precomp.hpp"
+#include "npy_blob.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cvtest
+{
+
+using namespace std;
+using namespace testing;
+using namespace cv;
+using namespace cv::dnn;
+
+template<typename TStr>
+static std::string _tf(TStr filename, bool inTorchDir = true)
+{
+ String path = getOpenCVExtraDir() + "/dnn/";
+ if (inTorchDir)
+ path += "torch/";
+ path += filename;
+ return path;
+}
+
+TEST(Torch_Importer, simple_read)
+{
+ Net net;
+ Ptr<Importer> importer;
+
+ ASSERT_NO_THROW( importer = createTorchImporter(_tf("net_simple_net.txt"), false) );
+ ASSERT_TRUE( importer != NULL );
+ importer->populateNet(net);
+}
+
+static void runTorchNet(String prefix, String outLayerName = "",
+ bool check2ndBlob = false, bool isBinary = false)
+{
+ String suffix = (isBinary) ? ".dat" : ".txt";
+
+ Net net;
+ Ptr<Importer> importer = createTorchImporter(_tf(prefix + "_net" + suffix), isBinary);
+ ASSERT_TRUE(importer != NULL);
+ importer->populateNet(net);
+
+ Mat inp, outRef;
+ ASSERT_NO_THROW( inp = readTorchBlob(_tf(prefix + "_input" + suffix), isBinary) );
+ ASSERT_NO_THROW( outRef = readTorchBlob(_tf(prefix + "_output" + suffix), isBinary) );
+
+ if (outLayerName.empty())
+ outLayerName = net.getLayerNames().back();
+
+ net.setInput(inp, "0");
+ std::vector<Mat> outBlobs;
+ net.forward(outBlobs, outLayerName);
+ normAssert(outRef, outBlobs[0]);
+
+ if (check2ndBlob)
+ {
+ Mat out2 = outBlobs[1];
+ Mat ref2 = readTorchBlob(_tf(prefix + "_output_2" + suffix), isBinary);
+ normAssert(out2, ref2);
+ }
+}
+
+TEST(Torch_Importer, run_convolution)
+{
+ runTorchNet("net_conv");
+}
+
+TEST(Torch_Importer, run_pool_max)
+{
+ runTorchNet("net_pool_max", "", true);
+}
+
+TEST(Torch_Importer, run_pool_ave)
+{
+ runTorchNet("net_pool_ave");
+}
+
+TEST(Torch_Importer, run_reshape)
+{
+ runTorchNet("net_reshape");
+ runTorchNet("net_reshape_batch");
+ runTorchNet("net_reshape_single_sample");
+}
+
+TEST(Torch_Importer, run_linear)
+{
+ runTorchNet("net_linear_2d");
+}
+
+TEST(Torch_Importer, run_paralel)
+{
+ runTorchNet("net_parallel", "l5_torchMerge");
+}
+
+TEST(Torch_Importer, run_concat)
+{
+ runTorchNet("net_concat", "l5_torchMerge");
+}
+
+TEST(Torch_Importer, run_deconv)
+{
+ runTorchNet("net_deconv");
+}
+
+TEST(Torch_Importer, run_batch_norm)
+{
+ runTorchNet("net_batch_norm");
+}
+
+TEST(Torch_Importer, net_prelu)
+{
+ runTorchNet("net_prelu");
+}
+
+TEST(Torch_Importer, net_cadd_table)
+{
+ runTorchNet("net_cadd_table");
+}
+
+TEST(Torch_Importer, net_softmax)
+{
+ runTorchNet("net_softmax");
+ runTorchNet("net_softmax_spatial");
+}
+
+TEST(Torch_Importer, net_logsoftmax)
+{
+ runTorchNet("net_logsoftmax");
+ runTorchNet("net_logsoftmax_spatial");
+}
+
+TEST(Torch_Importer, ENet_accuracy)
+{
+ Net net;
+ {
+ const string model = findDataFile("dnn/Enet-model-best.net", false);
+ Ptr<Importer> importer = createTorchImporter(model, true);
+ ASSERT_TRUE(importer != NULL);
+ importer->populateNet(net);
+ }
+
+ Mat sample = imread(_tf("street.png", false));
+ Mat inputBlob = blobFromImage(sample, 1./255);
+
+ net.setInput(inputBlob, "");
+ Mat out = net.forward();
+ Mat ref = blobFromNPY(_tf("torch_enet_prob.npy", false));
+ // Due to numerical instability in Pooling-Unpooling layers (indexes jittering)
+ // thresholds for ENet must be changed. Accuracy of resuults was checked on
+ // Cityscapes dataset and difference in mIOU with Torch is 10E-4%
+ normAssert(ref, out, "", 0.00044, 0.44);
+
+ const int N = 3;
+ for (int i = 0; i < N; i++)
+ {
+ net.setInput(inputBlob, "");
+ Mat out = net.forward();
+ normAssert(ref, out, "", 0.00044, 0.44);
+ }
+}
+
+}
+
+#endif
diff --git a/modules/features2d/CMakeLists.txt b/modules/features2d/CMakeLists.txt
index bf7d66e..caae24a 100644
--- a/modules/features2d/CMakeLists.txt
+++ b/modules/features2d/CMakeLists.txt
@@ -1,2 +1,2 @@
set(the_description "2D Features Framework")
-ocv_define_module(features2d opencv_imgproc opencv_ml opencv_flann OPTIONAL opencv_highgui WRAP java python)
+ocv_define_module(features2d opencv_imgproc opencv_flann OPTIONAL opencv_highgui WRAP java python)
diff --git a/modules/features2d/misc/java/gen_dict.json b/modules/features2d/misc/java/gen_dict.json
new file mode 100644
index 0000000..5ed56c8
--- /dev/null
+++ b/modules/features2d/misc/java/gen_dict.json
@@ -0,0 +1,21 @@
+{
+ "class_ignore_list" : [
+ "SimpleBlobDetector"
+ ],
+ "const_private_list" : [
+ "OPPONENTEXTRACTOR",
+ "GRIDDETECTOR",
+ "PYRAMIDDETECTOR",
+ "DYNAMICDETECTOR"
+ ],
+ "type_dict" : {
+ "Feature2D": {
+ "j_type": "Feature2D",
+ "jn_type": "long",
+ "jni_type": "jlong",
+ "jni_var": "Feature2D %(n)s",
+ "suffix": "J",
+ "j_import": "org.opencv.features2d.Feature2D"
+ }
+ }
+}
diff --git a/modules/features2d/perf/opencl/perf_fast.cpp b/modules/features2d/perf/opencl/perf_fast.cpp
deleted file mode 100644
index be310ba..0000000
--- a/modules/features2d/perf/opencl/perf_fast.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-#include "../perf_precomp.hpp"
-#include "opencv2/ts/ocl_perf.hpp"
-
-#ifdef HAVE_OPENCL
-
-namespace cvtest {
-namespace ocl {
-
-enum { TYPE_5_8 =FastFeatureDetector::TYPE_5_8, TYPE_7_12 = FastFeatureDetector::TYPE_7_12, TYPE_9_16 = FastFeatureDetector::TYPE_9_16 };
-CV_ENUM(FastType, TYPE_5_8, TYPE_7_12)
-
-typedef std::tr1::tuple<string, FastType> File_Type_t;
-typedef TestBaseWithParam<File_Type_t> FASTFixture;
-
-#define FAST_IMAGES \
- "cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\
- "stitching/a3.png"
-
-OCL_PERF_TEST_P(FASTFixture, FastDetect, testing::Combine(
- testing::Values(FAST_IMAGES),
- FastType::all()
- ))
-{
- string filename = getDataPath(get<0>(GetParam()));
- int type = get<1>(GetParam());
- Mat mframe = imread(filename, IMREAD_GRAYSCALE);
-
- if (mframe.empty())
- FAIL() << "Unable to load source image " << filename;
-
- UMat frame;
- mframe.copyTo(frame);
- declare.in(frame);
-
- Ptr<FeatureDetector> fd = FastFeatureDetector::create(20, true, type);
- ASSERT_FALSE( fd.empty() );
- vector<KeyPoint> points;
-
- OCL_TEST_CYCLE() fd->detect(frame, points);
-
- SANITY_CHECK_KEYPOINTS(points);
-}
-
-} // ocl
-} // cvtest
-
-#endif // HAVE_OPENCL
diff --git a/modules/features2d/perf/opencl/perf_feature2d.cpp b/modules/features2d/perf/opencl/perf_feature2d.cpp
new file mode 100644
index 0000000..c1ad793
--- /dev/null
+++ b/modules/features2d/perf/opencl/perf_feature2d.cpp
@@ -0,0 +1,81 @@
+#include "../perf_precomp.hpp"
+#include "opencv2/ts/ocl_perf.hpp"
+#include "../perf_feature2d.hpp"
+
+#ifdef HAVE_OPENCL
+
+namespace cvtest {
+namespace ocl {
+
+OCL_PERF_TEST_P(feature2d, detect, testing::Combine(Feature2DType::all(), TEST_IMAGES))
+{
+ Ptr<Feature2D> detector = getFeature2D(get<0>(GetParam()));
+ std::string filename = getDataPath(get<1>(GetParam()));
+ Mat mimg = imread(filename, IMREAD_GRAYSCALE);
+
+ ASSERT_FALSE(mimg.empty());
+ ASSERT_TRUE(detector);
+
+ UMat img, mask;
+ mimg.copyTo(img);
+ declare.in(img);
+ vector<KeyPoint> points;
+
+ OCL_TEST_CYCLE() detector->detect(img, points, mask);
+
+ EXPECT_GT(points.size(), 20u);
+ SANITY_CHECK_NOTHING();
+}
+
+OCL_PERF_TEST_P(feature2d, extract, testing::Combine(testing::Values(DETECTORS_EXTRACTORS), TEST_IMAGES))
+{
+ Ptr<Feature2D> detector = AKAZE::create();
+ Ptr<Feature2D> extractor = getFeature2D(get<0>(GetParam()));
+ std::string filename = getDataPath(get<1>(GetParam()));
+ Mat mimg = imread(filename, IMREAD_GRAYSCALE);
+
+ ASSERT_FALSE(mimg.empty());
+ ASSERT_TRUE(extractor);
+
+ UMat img, mask;
+ mimg.copyTo(img);
+ declare.in(img);
+ vector<KeyPoint> points;
+ detector->detect(img, points, mask);
+
+ EXPECT_GT(points.size(), 20u);
+
+ UMat descriptors;
+
+ OCL_TEST_CYCLE() extractor->compute(img, points, descriptors);
+
+ EXPECT_EQ((size_t)descriptors.rows, points.size());
+ SANITY_CHECK_NOTHING();
+}
+
+OCL_PERF_TEST_P(feature2d, detectAndExtract, testing::Combine(testing::Values(DETECTORS_EXTRACTORS), TEST_IMAGES))
+{
+ Ptr<Feature2D> detector = getFeature2D(get<0>(GetParam()));
+ std::string filename = getDataPath(get<1>(GetParam()));
+ Mat mimg = imread(filename, IMREAD_GRAYSCALE);
+
+ ASSERT_FALSE(mimg.empty());
+ ASSERT_TRUE(detector);
+
+ UMat img, mask;
+ mimg.copyTo(img);
+ declare.in(img);
+ vector<KeyPoint> points;
+ UMat descriptors;
+
+ OCL_TEST_CYCLE() detector->detectAndCompute(img, mask, points, descriptors, false);
+
+ EXPECT_GT(points.size(), 20u);
+ EXPECT_EQ((size_t)descriptors.rows, points.size());
+ SANITY_CHECK_NOTHING();
+}
+
+} // ocl
+} // cvtest
+
+#endif // HAVE_OPENCL
diff --git a/modules/features2d/perf/opencl/perf_orb.cpp b/modules/features2d/perf/opencl/perf_orb.cpp
deleted file mode 100644
index 5d9aa2f..0000000
--- a/modules/features2d/perf/opencl/perf_orb.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-#include "../perf_precomp.hpp"
-#include "opencv2/ts/ocl_perf.hpp"
-
-#ifdef HAVE_OPENCL
-
-namespace cvtest {
-namespace ocl {
-
-typedef ::perf::TestBaseWithParam<std::string> ORBFixture;
-
-#define ORB_IMAGES OCL_PERF_ENUM("cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png", "stitching/a3.png")
-
-OCL_PERF_TEST_P(ORBFixture, ORB_Detect, ORB_IMAGES)
-{
- string filename = getDataPath(GetParam());
- Mat mframe = imread(filename, IMREAD_GRAYSCALE);
-
- if (mframe.empty())
- FAIL() << "Unable to load source image " << filename;
-
- UMat frame, mask;
- mframe.copyTo(frame);
-
- declare.in(frame);
- Ptr<ORB> detector = ORB::create(1500, 1.3f, 1);
- vector<KeyPoint> points;
-
- OCL_TEST_CYCLE() detector->detect(frame, points, mask);
-
- EXPECT_GT(points.size(), 20u);
- SANITY_CHECK_NOTHING();
-}
-
-OCL_PERF_TEST_P(ORBFixture, ORB_Extract, ORB_IMAGES)
-{
- string filename = getDataPath(GetParam());
- Mat mframe = imread(filename, IMREAD_GRAYSCALE);
-
- if (mframe.empty())
- FAIL() << "Unable to load source image " << filename;
-
- UMat mask, frame;
- mframe.copyTo(frame);
-
- declare.in(frame);
-
- Ptr<ORB> detector = ORB::create(1500, 1.3f, 1);
- vector<KeyPoint> points;
- detector->detect(frame, points, mask);
- EXPECT_GT(points.size(), 20u);
-
- UMat descriptors;
-
- OCL_TEST_CYCLE() detector->compute(frame, points, descriptors);
-
- EXPECT_EQ((size_t)descriptors.rows, points.size());
- SANITY_CHECK_NOTHING();
-}
-
-OCL_PERF_TEST_P(ORBFixture, ORB_Full, ORB_IMAGES)
-{
- string filename = getDataPath(GetParam());
- Mat mframe = imread(filename, IMREAD_GRAYSCALE);
-
- if (mframe.empty())
- FAIL() << "Unable to load source image " << filename;
-
- UMat mask, frame;
- mframe.copyTo(frame);
-
- declare.in(frame);
- Ptr<ORB> detector = ORB::create(1500, 1.3f, 1);
-
- vector<KeyPoint> points;
- UMat descriptors;
-
- OCL_TEST_CYCLE() detector->detectAndCompute(frame, mask, points, descriptors, false);
-
- EXPECT_GT(points.size(), 20u);
- EXPECT_EQ((size_t)descriptors.rows, points.size());
- SANITY_CHECK_NOTHING();
-}
-
-} // ocl
-} // cvtest
-
-#endif // HAVE_OPENCL
diff --git a/modules/features2d/perf/perf_agast.cpp b/modules/features2d/perf/perf_agast.cpp
deleted file mode 100644
index 8e3e82b..0000000
--- a/modules/features2d/perf/perf_agast.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-#include "perf_precomp.hpp"
-
-using namespace std;
-using namespace cv;
-using namespace perf;
-using std::tr1::make_tuple;
-using std::tr1::get;
-
-enum { AGAST_5_8 = AgastFeatureDetector::AGAST_5_8, AGAST_7_12d = AgastFeatureDetector::AGAST_7_12d,
- AGAST_7_12s = AgastFeatureDetector::AGAST_7_12s, OAST_9_16 = AgastFeatureDetector::OAST_9_16 };
-CV_ENUM(AgastType, AGAST_5_8, AGAST_7_12d,
- AGAST_7_12s, OAST_9_16)
-
-typedef std::tr1::tuple<string, AgastType> File_Type_t;
-typedef perf::TestBaseWithParam<File_Type_t> agast;
-
-#define AGAST_IMAGES \
- "cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\
- "stitching/a3.png"
-
-PERF_TEST_P(agast, detect, testing::Combine(
- testing::Values(AGAST_IMAGES),
- AgastType::all()
- ))
-{
- string filename = getDataPath(get<0>(GetParam()));
- int type = get<1>(GetParam());
- Mat frame = imread(filename, IMREAD_GRAYSCALE);
-
- if (frame.empty())
- FAIL() << "Unable to load source image " << filename;
-
- declare.in(frame);
-
- Ptr<FeatureDetector> fd = AgastFeatureDetector::create(70, true, type);
- ASSERT_FALSE( fd.empty() );
- vector<KeyPoint> points;
-
- TEST_CYCLE() fd->detect(frame, points);
-
- SANITY_CHECK_KEYPOINTS(points);
-}
diff --git a/modules/features2d/perf/perf_fast.cpp b/modules/features2d/perf/perf_fast.cpp
deleted file mode 100644
index f706364..0000000
--- a/modules/features2d/perf/perf_fast.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-#include "perf_precomp.hpp"
-
-using namespace std;
-using namespace cv;
-using namespace perf;
-using std::tr1::make_tuple;
-using std::tr1::get;
-
-enum { TYPE_5_8 =FastFeatureDetector::TYPE_5_8, TYPE_7_12 = FastFeatureDetector::TYPE_7_12, TYPE_9_16 = FastFeatureDetector::TYPE_9_16 };
-CV_ENUM(FastType, TYPE_5_8, TYPE_7_12, TYPE_9_16)
-
-typedef std::tr1::tuple<string, FastType> File_Type_t;
-typedef perf::TestBaseWithParam<File_Type_t> fast;
-
-#define FAST_IMAGES \
- "cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\
- "stitching/a3.png"
-
-PERF_TEST_P(fast, detect, testing::Combine(
- testing::Values(FAST_IMAGES),
- FastType::all()
- ))
-{
- string filename = getDataPath(get<0>(GetParam()));
- int type = get<1>(GetParam());
- Mat frame = imread(filename, IMREAD_GRAYSCALE);
-
- if (frame.empty())
- FAIL() << "Unable to load source image " << filename;
-
- declare.in(frame);
-
- Ptr<FeatureDetector> fd = FastFeatureDetector::create(20, true, type);
- ASSERT_FALSE( fd.empty() );
- vector<KeyPoint> points;
-
- TEST_CYCLE() fd->detect(frame, points);
-
- SANITY_CHECK_KEYPOINTS(points);
-}
diff --git a/modules/features2d/perf/perf_feature2d.cpp b/modules/features2d/perf/perf_feature2d.cpp
new file mode 100644
index 0000000..91bb077
--- /dev/null
+++ b/modules/features2d/perf/perf_feature2d.cpp
@@ -0,0 +1,66 @@
+#include "perf_feature2d.hpp"
+
+PERF_TEST_P(feature2d, detect, testing::Combine(Feature2DType::all(), TEST_IMAGES))
+{
+ Ptr<Feature2D> detector = getFeature2D(get<0>(GetParam()));
+ std::string filename = getDataPath(get<1>(GetParam()));
+ Mat img = imread(filename, IMREAD_GRAYSCALE);
+
+ ASSERT_FALSE(img.empty());
+ ASSERT_TRUE(detector);
+
+ declare.in(img);
+ Mat mask;
+ vector<KeyPoint> points;
+
+ TEST_CYCLE() detector->detect(img, points, mask);
+
+ EXPECT_GT(points.size(), 20u);
+ SANITY_CHECK_NOTHING();
+}
+
+PERF_TEST_P(feature2d, extract, testing::Combine(testing::Values(DETECTORS_EXTRACTORS), TEST_IMAGES))
+{
+ Ptr<Feature2D> detector = AKAZE::create();
+ Ptr<Feature2D> extractor = getFeature2D(get<0>(GetParam()));
+ std::string filename = getDataPath(get<1>(GetParam()));
+ Mat img = imread(filename, IMREAD_GRAYSCALE);
+
+ ASSERT_FALSE(img.empty());
+ ASSERT_TRUE(extractor);
+
+ declare.in(img);
+ Mat mask;
+ vector<KeyPoint> points;
+ detector->detect(img, points, mask);
+
+ EXPECT_GT(points.size(), 20u);
+
+ Mat descriptors;
+
+ TEST_CYCLE() extractor->compute(img, points, descriptors);
+
+ EXPECT_EQ((size_t)descriptors.rows, points.size());
+ SANITY_CHECK_NOTHING();
+}
+
+PERF_TEST_P(feature2d, detectAndExtract, testing::Combine(testing::Values(DETECTORS_EXTRACTORS), TEST_IMAGES))
+{
+ Ptr<Feature2D> detector = getFeature2D(get<0>(GetParam()));
+ std::string filename = getDataPath(get<1>(GetParam()));
+ Mat img = imread(filename, IMREAD_GRAYSCALE);
+
+ ASSERT_FALSE(img.empty());
+ ASSERT_TRUE(detector);
+
+ declare.in(img);
+ Mat mask;
+ vector<KeyPoint> points;
+ Mat descriptors;
+
+ TEST_CYCLE() detector->detectAndCompute(img, mask, points, descriptors, false);
+
+ EXPECT_GT(points.size(), 20u);
+ EXPECT_EQ((size_t)descriptors.rows, points.size());
+ SANITY_CHECK_NOTHING();
+}
diff --git a/modules/features2d/perf/perf_feature2d.hpp b/modules/features2d/perf/perf_feature2d.hpp
new file mode 100644
index 0000000..a80b5c2
--- /dev/null
+++ b/modules/features2d/perf/perf_feature2d.hpp
@@ -0,0 +1,87 @@
+#ifndef __OPENCV_PERF_FEATURE2D_HPP__
+#define __OPENCV_PERF_FEATURE2D_HPP__
+
+#include "perf_precomp.hpp"
+
+/* cofiguration for tests of detectors/descriptors. shared between ocl and cpu tests. */
+
+using namespace std;
+using namespace cv;
+using namespace perf;
+using std::tr1::make_tuple;
+using std::tr1::get;
+// detectors/descriptors configurations to test
+#define DETECTORS_ONLY \
+ FAST_DEFAULT, FAST_20_TRUE_TYPE5_8, FAST_20_TRUE_TYPE7_12, FAST_20_TRUE_TYPE9_16, \
+ FAST_20_FALSE_TYPE5_8, FAST_20_FALSE_TYPE7_12, FAST_20_FALSE_TYPE9_16, \
+ \
+ AGAST_DEFAULT, AGAST_5_8, AGAST_7_12d, AGAST_7_12s, AGAST_OAST_9_16, \
+ \
+ MSER_DEFAULT
+
+#define DETECTORS_EXTRACTORS \
+ ORB_DEFAULT, ORB_1500_13_1, \
+ AKAZE_DEFAULT, AKAZE_DESCRIPTOR_KAZE, \
+ BRISK_DEFAULT, \
+ KAZE_DEFAULT
+
+#define CV_ENUM_EXPAND(name, ...) CV_ENUM(name, __VA_ARGS__)
+
+enum Feature2DVals { DETECTORS_ONLY, DETECTORS_EXTRACTORS };
+CV_ENUM_EXPAND(Feature2DType, DETECTORS_ONLY, DETECTORS_EXTRACTORS)
+
+typedef std::tr1::tuple<Feature2DType, string> Feature2DType_String_t;
+typedef perf::TestBaseWithParam<Feature2DType_String_t> feature2d;
+
+#define TEST_IMAGES testing::Values(\
+ "cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\
+ "stitching/a3.png", \
+ "stitching/s2.jpg")
+
+static inline Ptr<Feature2D> getFeature2D(Feature2DType type)
+{
+ switch(type) {
+ case ORB_DEFAULT:
+ return ORB::create();
+ case ORB_1500_13_1:
+ return ORB::create(1500, 1.3f, 1);
+ case FAST_DEFAULT:
+ return FastFeatureDetector::create();
+ case FAST_20_TRUE_TYPE5_8:
+ return FastFeatureDetector::create(20, true, FastFeatureDetector::TYPE_5_8);
+ case FAST_20_TRUE_TYPE7_12:
+ return FastFeatureDetector::create(20, true, FastFeatureDetector::TYPE_7_12);
+ case FAST_20_TRUE_TYPE9_16:
+ return FastFeatureDetector::create(20, true, FastFeatureDetector::TYPE_9_16);
+ case FAST_20_FALSE_TYPE5_8:
+ return FastFeatureDetector::create(20, false, FastFeatureDetector::TYPE_5_8);
+ case FAST_20_FALSE_TYPE7_12:
+ return FastFeatureDetector::create(20, false, FastFeatureDetector::TYPE_7_12);
+ case FAST_20_FALSE_TYPE9_16:
+ return FastFeatureDetector::create(20, false, FastFeatureDetector::TYPE_9_16);
+ case AGAST_DEFAULT:
+ return AgastFeatureDetector::create();
+ case AGAST_5_8:
+ return AgastFeatureDetector::create(70, true, AgastFeatureDetector::AGAST_5_8);
+ case AGAST_7_12d:
+ return AgastFeatureDetector::create(70, true, AgastFeatureDetector::AGAST_7_12d);
+ case AGAST_7_12s:
+ return AgastFeatureDetector::create(70, true, AgastFeatureDetector::AGAST_7_12s);
+ case AGAST_OAST_9_16:
+ return AgastFeatureDetector::create(70, true, AgastFeatureDetector::OAST_9_16);
+ case AKAZE_DEFAULT:
+ return AKAZE::create();
+ case AKAZE_DESCRIPTOR_KAZE:
+ return AKAZE::create(AKAZE::DESCRIPTOR_KAZE);
+ case BRISK_DEFAULT:
+ return BRISK::create();
+ case KAZE_DEFAULT:
+ return KAZE::create();
+ case MSER_DEFAULT:
+ return MSER::create();
+ default:
+ return Ptr<Feature2D>();
+ }
+}
+
+#endif // __OPENCV_PERF_FEATURE2D_HPP__
diff --git a/modules/features2d/perf/perf_orb.cpp b/modules/features2d/perf/perf_orb.cpp
deleted file mode 100644
index 0397125..0000000
--- a/modules/features2d/perf/perf_orb.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-#include "perf_precomp.hpp"
-
-using namespace std;
-using namespace cv;
-using namespace perf;
-using std::tr1::make_tuple;
-using std::tr1::get;
-
-typedef perf::TestBaseWithParam<std::string> orb;
-
-#define ORB_IMAGES \
- "cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\
- "stitching/a3.png"
-
-PERF_TEST_P(orb, detect, testing::Values(ORB_IMAGES))
-{
- string filename = getDataPath(GetParam());
- Mat frame = imread(filename, IMREAD_GRAYSCALE);
-
- if (frame.empty())
- FAIL() << "Unable to load source image " << filename;
-
- Mat mask;
- declare.in(frame);
- Ptr<ORB> detector = ORB::create(1500, 1.3f, 1);
- vector<KeyPoint> points;
-
- TEST_CYCLE() detector->detect(frame, points, mask);
-
- EXPECT_GT(points.size(), 20u);
-
- SANITY_CHECK_NOTHING();
-}
-
-PERF_TEST_P(orb, extract, testing::Values(ORB_IMAGES))
-{
- string filename = getDataPath(GetParam());
- Mat frame = imread(filename, IMREAD_GRAYSCALE);
-
- if (frame.empty())
- FAIL() << "Unable to load source image " << filename;
-
- Mat mask;
- declare.in(frame);
-
- Ptr<ORB> detector = ORB::create(1500, 1.3f, 1);
- vector<KeyPoint> points;
- detector->detect(frame, points, mask);
-
- EXPECT_GT(points.size(), 20u);
-
- Mat descriptors;
-
- TEST_CYCLE() detector->compute(frame, points, descriptors);
-
- EXPECT_EQ((size_t)descriptors.rows, points.size());
- SANITY_CHECK_NOTHING();
-}
-
-PERF_TEST_P(orb, full, testing::Values(ORB_IMAGES))
-{
- string filename = getDataPath(GetParam());
- Mat frame = imread(filename, IMREAD_GRAYSCALE);
-
- if (frame.empty())
- FAIL() << "Unable to load source image " << filename;
-
- Mat mask;
- declare.in(frame);
- Ptr<ORB> detector = ORB::create(1500, 1.3f, 1);
-
- vector<KeyPoint> points;
- Mat descriptors;
-
- TEST_CYCLE() detector->detectAndCompute(frame, mask, points, descriptors, false);
-
- EXPECT_GT(points.size(), 20u);
- EXPECT_EQ((size_t)descriptors.rows, points.size());
- SANITY_CHECK_NOTHING();
-}
diff --git a/modules/features2d/src/agast_score.cpp b/modules/features2d/src/agast_score.cpp
index ad9b448..ac80077 100644
--- a/modules/features2d/src/agast_score.cpp
+++ b/modules/features2d/src/agast_score.cpp
@@ -82,10 +82,15 @@ void makeAgastOffsets(int pixel[16], int rowStride, int type)
type == AgastFeatureDetector::AGAST_7_12s ? offsets12s :
type == AgastFeatureDetector::AGAST_5_8 ? offsets8 : 0;
+ const int offsets_len = type == AgastFeatureDetector::OAST_9_16 ? 16 :
+ type == AgastFeatureDetector::AGAST_7_12d ? 12 :
+ type == AgastFeatureDetector::AGAST_7_12s ? 12 :
+ type == AgastFeatureDetector::AGAST_5_8 ? 8 : 0;
+
CV_Assert(pixel && offsets);
int k = 0;
- for( ; k < 16; k++ )
+ for( ; k < offsets_len; k++ )
pixel[k] = offsets[k][0] + offsets[k][1] * rowStride;
}
diff --git a/modules/features2d/src/akaze.cpp b/modules/features2d/src/akaze.cpp
index 2297194..baca3c6 100644
--- a/modules/features2d/src/akaze.cpp
+++ b/modules/features2d/src/akaze.cpp
@@ -113,12 +113,12 @@ namespace cv
if (descriptor_size == 0)
{
int t = (6 + 36 + 120) * descriptor_channels;
- return (int)ceil(t / 8.);
+ return divUp(t, 8);
}
else
{
// We use the random bit selection length binary descriptor
- return (int)ceil(descriptor_size / 8.);
+ return divUp(descriptor_size, 8);
}
default:
@@ -200,8 +200,7 @@ namespace cv
if (!useProvidedKeypoints)
{
impl.Feature_Detection(keypoints);
- if( !descriptors.needed() )
- impl.Compute_Keypoints_Orientation(keypoints);
+ impl.Compute_Keypoints_Orientation(keypoints);
}
if (!mask.empty())
@@ -211,11 +210,10 @@ namespace cv
if( descriptors.needed() )
{
- Mat& desc = descriptors.getMatRef();
- impl.Compute_Descriptors(keypoints, desc);
+ impl.Compute_Descriptors(keypoints, descriptors);
- CV_Assert((!desc.rows || desc.cols == descriptorSize()));
- CV_Assert((!desc.rows || (desc.type() == descriptorType())));
+ CV_Assert((descriptors.empty() || descriptors.cols() == descriptorSize()));
+ CV_Assert((descriptors.empty() || (descriptors.type() == descriptorType())));
}
}
diff --git a/modules/features2d/src/brisk.cpp b/modules/features2d/src/brisk.cpp
index d6e88a1..f67be9f 100644
--- a/modules/features2d/src/brisk.cpp
+++ b/modules/features2d/src/brisk.cpp
@@ -703,7 +703,6 @@ BRISK_Impl::computeDescriptorsAndOrOrientation(InputArray _image, InputArray _ma
{
cv::KeyPoint& kp = keypoints[k];
const int& scale = kscales[k];
- int* pvalues = _values;
const float& x = kp.pt.x;
const float& y = kp.pt.y;
@@ -712,7 +711,7 @@ BRISK_Impl::computeDescriptorsAndOrOrientation(InputArray _image, InputArray _ma
// get the gray values in the unrotated pattern
for (unsigned int i = 0; i < points_; i++)
{
- *(pvalues++) = smoothedIntensity(image, _integral, x, y, scale, 0, i);
+ _values[i] = smoothedIntensity(image, _integral, x, y, scale, 0, i);
}
int direction0 = 0;
@@ -721,6 +720,7 @@ BRISK_Impl::computeDescriptorsAndOrOrientation(InputArray _image, InputArray _ma
const BriskLongPair* max = longPairs_ + noLongPairs_;
for (BriskLongPair* iter = longPairs_; iter < max; ++iter)
{
+ CV_Assert(iter->i < points_ && iter->j < points_);
t1 = *(_values + iter->i);
t2 = *(_values + iter->j);
const int delta_t = (t1 - t2);
@@ -745,7 +745,7 @@ BRISK_Impl::computeDescriptorsAndOrOrientation(InputArray _image, InputArray _ma
int theta;
if (kp.angle==-1)
{
- // don't compute the gradient direction, just assign a rotation of 0°
+ // don't compute the gradient direction, just assign a rotation of 0
theta = 0;
}
else
@@ -765,11 +765,10 @@ BRISK_Impl::computeDescriptorsAndOrOrientation(InputArray _image, InputArray _ma
int shifter = 0;
//unsigned int mean=0;
- pvalues = _values;
// get the gray values in the rotated pattern
for (unsigned int i = 0; i < points_; i++)
{
- *(pvalues++) = smoothedIntensity(image, _integral, x, y, scale, theta, i);
+ _values[i] = smoothedIntensity(image, _integral, x, y, scale, theta, i);
}
// now iterate through all the pairings
@@ -777,6 +776,7 @@ BRISK_Impl::computeDescriptorsAndOrOrientation(InputArray _image, InputArray _ma
const BriskShortPair* max = shortPairs_ + noShortPairs_;
for (BriskShortPair* iter = shortPairs_; iter < max; ++iter)
{
+ CV_Assert(iter->i < points_ && iter->j < points_);
t1 = *(_values + iter->i);
t2 = *(_values + iter->j);
if (t1 > t2)
diff --git a/modules/features2d/src/evaluation.cpp b/modules/features2d/src/evaluation.cpp
index 5ea8821..6b9a03f 100644
--- a/modules/features2d/src/evaluation.cpp
+++ b/modules/features2d/src/evaluation.cpp
@@ -481,7 +481,7 @@ void cv::evaluateFeatureDetector( const Mat& img1, const Mat& img2, const Mat& H
struct DMatchForEvaluation : public DMatch
{
uchar isCorrect;
- DMatchForEvaluation( const DMatch &dm ) : DMatch( dm ) {}
+ DMatchForEvaluation( const DMatch &dm ) : DMatch( dm ), isCorrect(0) {}
};
static inline float recall( int correctMatchCount, int correspondenceCount )
diff --git a/modules/features2d/src/fast.cpp b/modules/features2d/src/fast.cpp
index e731ded..5b36023 100644
--- a/modules/features2d/src/fast.cpp
+++ b/modules/features2d/src/fast.cpp
@@ -44,6 +44,7 @@ The references are:
#include "precomp.hpp"
#include "fast_score.hpp"
#include "opencl_kernels_features2d.hpp"
+#include "opencv2/core/hal/intrin.hpp"
#include "opencv2/core/openvx/ovx_defs.hpp"
#if defined _MSC_VER
@@ -58,9 +59,10 @@ void FAST_t(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bo
{
Mat img = _img.getMat();
const int K = patternSize/2, N = patternSize + K + 1;
-#if CV_SSE2
+#if CV_SIMD128
const int quarterPatternSize = patternSize/4;
- (void)quarterPatternSize;
+ v_uint8x16 delta = v_setall_u8(0x80), t = v_setall_u8((char)threshold), K16 = v_setall_u8((char)K);
+ bool hasSimd = hasSIMD128();
#endif
int i, j, k, pixel[25];
makeOffsets(pixel, (int)img.step, patternSize);
@@ -69,12 +71,6 @@ void FAST_t(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bo
threshold = std::min(std::max(threshold, 0), 255);
-#if CV_SSE2
- __m128i delta = _mm_set1_epi8(-128), t = _mm_set1_epi8((char)threshold), K16 = _mm_set1_epi8((char)K);
- (void)K16;
- (void)delta;
- (void)t;
-#endif
uchar threshold_tab[512];
for( i = -255; i <= 255; i++ )
threshold_tab[i+255] = (uchar)(i < -threshold ? 1 : i > threshold ? 2 : 0);
@@ -99,66 +95,76 @@ void FAST_t(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bo
if( i < img.rows - 3 )
{
j = 3;
- #if CV_SSE2
- if( patternSize == 16 )
+#if CV_SIMD128
+ if( hasSimd )
{
- for(; j < img.cols - 16 - 3; j += 16, ptr += 16)
+ if( patternSize == 16 )
{
- __m128i m0, m1;
- __m128i v0 = _mm_loadu_si128((const __m128i*)ptr);
- __m128i v1 = _mm_xor_si128(_mm_subs_epu8(v0, t), delta);
- v0 = _mm_xor_si128(_mm_adds_epu8(v0, t), delta);
-
- __m128i x0 = _mm_sub_epi8(_mm_loadu_si128((const __m128i*)(ptr + pixel[0])), delta);
- __m128i x1 = _mm_sub_epi8(_mm_loadu_si128((const __m128i*)(ptr + pixel[quarterPatternSize])), delta);
- __m128i x2 = _mm_sub_epi8(_mm_loadu_si128((const __m128i*)(ptr + pixel[2*quarterPatternSize])), delta);
- __m128i x3 = _mm_sub_epi8(_mm_loadu_si128((const __m128i*)(ptr + pixel[3*quarterPatternSize])), delta);
- m0 = _mm_and_si128(_mm_cmpgt_epi8(x0, v0), _mm_cmpgt_epi8(x1, v0));
- m1 = _mm_and_si128(_mm_cmpgt_epi8(v1, x0), _mm_cmpgt_epi8(v1, x1));
- m0 = _mm_or_si128(m0, _mm_and_si128(_mm_cmpgt_epi8(x1, v0), _mm_cmpgt_epi8(x2, v0)));
- m1 = _mm_or_si128(m1, _mm_and_si128(_mm_cmpgt_epi8(v1, x1), _mm_cmpgt_epi8(v1, x2)));
- m0 = _mm_or_si128(m0, _mm_and_si128(_mm_cmpgt_epi8(x2, v0), _mm_cmpgt_epi8(x3, v0)));
- m1 = _mm_or_si128(m1, _mm_and_si128(_mm_cmpgt_epi8(v1, x2), _mm_cmpgt_epi8(v1, x3)));
- m0 = _mm_or_si128(m0, _mm_and_si128(_mm_cmpgt_epi8(x3, v0), _mm_cmpgt_epi8(x0, v0)));
- m1 = _mm_or_si128(m1, _mm_and_si128(_mm_cmpgt_epi8(v1, x3), _mm_cmpgt_epi8(v1, x0)));
- m0 = _mm_or_si128(m0, m1);
- int mask = _mm_movemask_epi8(m0);
- if( mask == 0 )
- continue;
- if( (mask & 255) == 0 )
+ for(; j < img.cols - 16 - 3; j += 16, ptr += 16)
{
- j -= 8;
- ptr -= 8;
- continue;
- }
+ v_uint8x16 v = v_load(ptr);
+ v_int8x16 v0 = v_reinterpret_as_s8((v + t) ^ delta);
+ v_int8x16 v1 = v_reinterpret_as_s8((v - t) ^ delta);
+
+ v_int8x16 x0 = v_reinterpret_as_s8(v_sub_wrap(v_load(ptr + pixel[0]), delta));
+ v_int8x16 x1 = v_reinterpret_as_s8(v_sub_wrap(v_load(ptr + pixel[quarterPatternSize]), delta));
+ v_int8x16 x2 = v_reinterpret_as_s8(v_sub_wrap(v_load(ptr + pixel[2*quarterPatternSize]), delta));
+ v_int8x16 x3 = v_reinterpret_as_s8(v_sub_wrap(v_load(ptr + pixel[3*quarterPatternSize]), delta));
+
+ v_int8x16 m0, m1;
+ m0 = (v0 < x0) & (v0 < x1);
+ m1 = (x0 < v1) & (x1 < v1);
+ m0 = m0 | ((v0 < x1) & (v0 < x2));
+ m1 = m1 | ((x1 < v1) & (x2 < v1));
+ m0 = m0 | ((v0 < x2) & (v0 < x3));
+ m1 = m1 | ((x2 < v1) & (x3 < v1));
+ m0 = m0 | ((v0 < x3) & (v0 < x0));
+ m1 = m1 | ((x3 < v1) & (x0 < v1));
+ m0 = m0 | m1;
+
+ int mask = v_signmask(m0);
+ if( mask == 0 )
+ continue;
+ if( (mask & 255) == 0 )
+ {
+ j -= 8;
+ ptr -= 8;
+ continue;
+ }
- __m128i c0 = _mm_setzero_si128(), c1 = c0, max0 = c0, max1 = c0;
- for( k = 0; k < N; k++ )
- {
- __m128i x = _mm_xor_si128(_mm_loadu_si128((const __m128i*)(ptr + pixel[k])), delta);
- m0 = _mm_cmpgt_epi8(x, v0);
- m1 = _mm_cmpgt_epi8(v1, x);
+ v_int8x16 c0 = v_setzero_s8();
+ v_int8x16 c1 = v_setzero_s8();
+ v_uint8x16 max0 = v_setzero_u8();
+ v_uint8x16 max1 = v_setzero_u8();
+ for( k = 0; k < N; k++ )
+ {
+ v_int8x16 x = v_reinterpret_as_s8(v_load((ptr + pixel[k])) ^ delta);
+ m0 = v0 < x;
+ m1 = x < v1;
- c0 = _mm_and_si128(_mm_sub_epi8(c0, m0), m0);
- c1 = _mm_and_si128(_mm_sub_epi8(c1, m1), m1);
+ c0 = v_sub_wrap(c0, m0) & m0;
+ c1 = v_sub_wrap(c1, m1) & m1;
- max0 = _mm_max_epu8(max0, c0);
- max1 = _mm_max_epu8(max1, c1);
- }
+ max0 = v_max(max0, v_reinterpret_as_u8(c0));
+ max1 = v_max(max1, v_reinterpret_as_u8(c1));
+ }
- max0 = _mm_max_epu8(max0, max1);
- int m = _mm_movemask_epi8(_mm_cmpgt_epi8(max0, K16));
+ max0 = v_max(max0, max1);
+ int m = v_signmask(K16 < max0);
- for( k = 0; m > 0 && k < 16; k++, m >>= 1 )
- if(m & 1)
+ for( k = 0; m > 0 && k < 16; k++, m >>= 1 )
{
- cornerpos[ncorners++] = j+k;
- if(nonmax_suppression)
- curr[j+k] = (uchar)cornerScore<patternSize>(ptr+k, pixel, threshold);
+ if(m & 1)
+ {
+ cornerpos[ncorners++] = j+k;
+ if(nonmax_suppression)
+ curr[j+k] = (uchar)cornerScore<patternSize>(ptr+k, pixel, threshold);
+ }
}
+ }
}
}
- #endif
+#endif
for( ; j < img.cols - 3; j++, ptr++ )
{
int v = ptr[0];
@@ -332,6 +338,9 @@ static bool ocl_FAST( InputArray _img, std::vector<KeyPoint>& keypoints,
#ifdef HAVE_OPENVX
+namespace ovx {
+ template <> inline bool skipSmallImages<VX_KERNEL_FAST_CORNERS>(int w, int h) { return w*h < 800 * 600; }
+}
static bool openvx_FAST(InputArray _img, std::vector<KeyPoint>& keypoints,
int _threshold, bool nonmaxSuppression, int type)
{
@@ -346,9 +355,12 @@ static bool openvx_FAST(InputArray _img, std::vector<KeyPoint>& keypoints,
if(imgMat.empty() || imgMat.type() != CV_8UC1)
return false;
+ if (ovx::skipSmallImages<VX_KERNEL_FAST_CORNERS>(imgMat.cols, imgMat.rows))
+ return false;
+
try
{
- Context context = Context::create();
+ Context context = ovx::getOpenVXContext();
Image img = Image::createFromHandle(context, Image::matTypeToFormat(imgMat.type()),
Image::createAddressing(imgMat), (void*)imgMat.data);
ivx::Scalar threshold = ivx::Scalar::create<VX_TYPE_FLOAT32>(context, _threshold);
diff --git a/modules/features2d/src/kaze.cpp b/modules/features2d/src/kaze.cpp
index 63b48c3..9e24397 100644
--- a/modules/features2d/src/kaze.cpp
+++ b/modules/features2d/src/kaze.cpp
@@ -151,8 +151,9 @@ namespace cv
if( descriptors.needed() )
{
- Mat& desc = descriptors.getMatRef();
+ Mat desc;
impl.Feature_Description(keypoints, desc);
+ desc.copyTo(descriptors);
CV_Assert((!desc.rows || desc.cols == descriptorSize()));
CV_Assert((!desc.rows || (desc.type() == descriptorType())));
diff --git a/modules/features2d/src/kaze/AKAZEFeatures.cpp b/modules/features2d/src/kaze/AKAZEFeatures.cpp
index 77a68a5..024a5ca 100644
--- a/modules/features2d/src/kaze/AKAZEFeatures.cpp
+++ b/modules/features2d/src/kaze/AKAZEFeatures.cpp
@@ -11,9 +11,14 @@
#include "fed.h"
#include "nldiffusion_functions.h"
#include "utils.h"
+#include "opencl_kernels_features2d.hpp"
#include <iostream>
+#ifdef HAVE_OPENCL // OpenCL is not well supported
+#undef HAVE_OPENCL
+#endif
+
// Namespaces
namespace cv
{
@@ -43,10 +48,20 @@ AKAZEFeatures::AKAZEFeatures(const AKAZEOptions& options) : options_(options) {
* @brief This method allocates the memory for the nonlinear diffusion evolution
*/
void AKAZEFeatures::Allocate_Memory_Evolution(void) {
+ CV_INSTRUMENT_REGION()
float rfactor = 0.0f;
int level_height = 0, level_width = 0;
+ // maximum size of the area for the descriptor computation
+ float smax = 0.0;
+ if (options_.descriptor == AKAZE::DESCRIPTOR_MLDB_UPRIGHT || options_.descriptor == AKAZE::DESCRIPTOR_MLDB) {
+ smax = 10.0f*sqrtf(2.0f);
+ }
+ else if (options_.descriptor == AKAZE::DESCRIPTOR_KAZE_UPRIGHT || options_.descriptor == AKAZE::DESCRIPTOR_KAZE) {
+ smax = 12.0f*sqrtf(2.0f);
+ }
+
// Allocate the dimension of the matrices for the evolution
for (int i = 0, power = 1; i <= options_.omax - 1; i++, power *= 2) {
rfactor = 1.0f / power;
@@ -60,20 +75,16 @@ void AKAZEFeatures::Allocate_Memory_Evolution(void) {
}
for (int j = 0; j < options_.nsublevels; j++) {
- TEvolution step;
- step.Lx = Mat::zeros(level_height, level_width, CV_32F);
- step.Ly = Mat::zeros(level_height, level_width, CV_32F);
- step.Lxx = Mat::zeros(level_height, level_width, CV_32F);
- step.Lxy = Mat::zeros(level_height, level_width, CV_32F);
- step.Lyy = Mat::zeros(level_height, level_width, CV_32F);
- step.Lt = Mat::zeros(level_height, level_width, CV_32F);
- step.Ldet = Mat::zeros(level_height, level_width, CV_32F);
- step.Lsmooth = Mat::zeros(level_height, level_width, CV_32F);
+ Evolution step;
+ step.size = Size(level_width, level_height);
step.esigma = options_.soffset*pow(2.f, (float)(j) / (float)(options_.nsublevels) + i);
- step.sigma_size = fRound(step.esigma);
- step.etime = 0.5f*(step.esigma*step.esigma);
+ step.sigma_size = cvRound(step.esigma * options_.derivative_factor / power); // In fact sigma_size only depends on j
+ step.etime = 0.5f * (step.esigma * step.esigma);
step.octave = i;
step.sublevel = j;
+ step.octave_ratio = (float)power;
+ step.border = cvRound(smax * step.sigma_size) + 1;
+
evolution_.push_back(step);
}
}
@@ -93,363 +104,758 @@ void AKAZEFeatures::Allocate_Memory_Evolution(void) {
/* ************************************************************************* */
/**
+ * @brief Computes kernel size for Gaussian smoothing if the image
+ * @param sigma Kernel standard deviation
+ * @returns kernel size
+ */
+static inline int getGaussianKernelSize(float sigma) {
+ // Compute an appropriate kernel size according to the specified sigma
+ int ksize = (int)cvCeil(2.0f*(1.0f + (sigma - 0.8f) / (0.3f)));
+ ksize |= 1; // kernel should be odd
+ return ksize;
+}
+
+/* ************************************************************************* */
+/**
+* @brief This function computes a scalar non-linear diffusion step
+* @param Lt Base image in the evolution
+* @param Lf Conductivity image
+* @param Lstep Output image that gives the difference between the current
+* Ld and the next Ld being evolved
+* @param row_begin row where to start
+* @param row_end last row to fill exclusive. the range is [row_begin, row_end).
+* @note Forward Euler Scheme 3x3 stencil
+* The function c is a scalar value that depends on the gradient norm
+* dL_by_ds = d(c dL_by_dx)_by_dx + d(c dL_by_dy)_by_dy
+*/
+static inline void
+nld_step_scalar_one_lane(const Mat& Lt, const Mat& Lf, Mat& Lstep, float step_size, int row_begin, int row_end)
+{
+ CV_INSTRUMENT_REGION()
+ /* The labeling scheme for this five star stencil:
+ [ a ]
+ [ -1 c +1 ]
+ [ b ]
+ */
+
+ Lstep.create(Lt.size(), Lt.type());
+ const int cols = Lt.cols - 2;
+ int row = row_begin;
+
+ const float *lt_a, *lt_c, *lt_b;
+ const float *lf_a, *lf_c, *lf_b;
+ float *dst;
+ float step_r = 0.f;
+
+ // Process the top row
+ if (row == 0) {
+ lt_c = Lt.ptr<float>(0) + 1; /* Skip the left-most column by +1 */
+ lf_c = Lf.ptr<float>(0) + 1;
+ lt_b = Lt.ptr<float>(1) + 1;
+ lf_b = Lf.ptr<float>(1) + 1;
+
+ // fill the corner to prevent uninitialized values
+ dst = Lstep.ptr<float>(0);
+ dst[0] = 0.0f;
+ ++dst;
+
+ for (int j = 0; j < cols; j++) {
+ step_r = (lf_c[j] + lf_c[j + 1])*(lt_c[j + 1] - lt_c[j]) +
+ (lf_c[j] + lf_c[j - 1])*(lt_c[j - 1] - lt_c[j]) +
+ (lf_c[j] + lf_b[j ])*(lt_b[j ] - lt_c[j]);
+ dst[j] = step_r * step_size;
+ }
+
+ // fill the corner to prevent uninitialized values
+ dst[cols] = 0.0f;
+ ++row;
+ }
+
+ // Process the middle rows
+ int middle_end = std::min(Lt.rows - 1, row_end);
+ for (; row < middle_end; ++row)
+ {
+ lt_a = Lt.ptr<float>(row - 1);
+ lf_a = Lf.ptr<float>(row - 1);
+ lt_c = Lt.ptr<float>(row );
+ lf_c = Lf.ptr<float>(row );
+ lt_b = Lt.ptr<float>(row + 1);
+ lf_b = Lf.ptr<float>(row + 1);
+ dst = Lstep.ptr<float>(row);
+
+ // The left-most column
+ step_r = (lf_c[0] + lf_c[1])*(lt_c[1] - lt_c[0]) +
+ (lf_c[0] + lf_b[0])*(lt_b[0] - lt_c[0]) +
+ (lf_c[0] + lf_a[0])*(lt_a[0] - lt_c[0]);
+ dst[0] = step_r * step_size;
+
+ lt_a++; lt_c++; lt_b++;
+ lf_a++; lf_c++; lf_b++;
+ dst++;
+
+ // The middle columns
+ for (int j = 0; j < cols; j++)
+ {
+ step_r = (lf_c[j] + lf_c[j + 1])*(lt_c[j + 1] - lt_c[j]) +
+ (lf_c[j] + lf_c[j - 1])*(lt_c[j - 1] - lt_c[j]) +
+ (lf_c[j] + lf_b[j ])*(lt_b[j ] - lt_c[j]) +
+ (lf_c[j] + lf_a[j ])*(lt_a[j ] - lt_c[j]);
+ dst[j] = step_r * step_size;
+ }
+
+ // The right-most column
+ step_r = (lf_c[cols] + lf_c[cols - 1])*(lt_c[cols - 1] - lt_c[cols]) +
+ (lf_c[cols] + lf_b[cols ])*(lt_b[cols ] - lt_c[cols]) +
+ (lf_c[cols] + lf_a[cols ])*(lt_a[cols ] - lt_c[cols]);
+ dst[cols] = step_r * step_size;
+ }
+
+ // Process the bottom row (row == Lt.rows - 1)
+ if (row_end == Lt.rows) {
+ lt_a = Lt.ptr<float>(row - 1) + 1; /* Skip the left-most column by +1 */
+ lf_a = Lf.ptr<float>(row - 1) + 1;
+ lt_c = Lt.ptr<float>(row ) + 1;
+ lf_c = Lf.ptr<float>(row ) + 1;
+
+ // fill the corner to prevent uninitialized values
+ dst = Lstep.ptr<float>(row);
+ dst[0] = 0.0f;
+ ++dst;
+
+ for (int j = 0; j < cols; j++) {
+ step_r = (lf_c[j] + lf_c[j + 1])*(lt_c[j + 1] - lt_c[j]) +
+ (lf_c[j] + lf_c[j - 1])*(lt_c[j - 1] - lt_c[j]) +
+ (lf_c[j] + lf_a[j ])*(lt_a[j ] - lt_c[j]);
+ dst[j] = step_r * step_size;
+ }
+
+ // fill the corner to prevent uninitialized values
+ dst[cols] = 0.0f;
+ }
+}
+
+class NonLinearScalarDiffusionStep : public ParallelLoopBody
+{
+public:
+ NonLinearScalarDiffusionStep(const Mat& Lt, const Mat& Lf, Mat& Lstep, float step_size)
+ : Lt_(&Lt), Lf_(&Lf), Lstep_(&Lstep), step_size_(step_size)
+ {}
+
+ void operator()(const Range& range) const
+ {
+ nld_step_scalar_one_lane(*Lt_, *Lf_, *Lstep_, step_size_, range.start, range.end);
+ }
+
+private:
+ const Mat* Lt_;
+ const Mat* Lf_;
+ Mat* Lstep_;
+ float step_size_;
+};
+
+#ifdef HAVE_OPENCL
+static inline bool
+ocl_non_linear_diffusion_step(InputArray Lt_, InputArray Lf_, OutputArray Lstep_, float step_size)
+{
+ if (!Lt_.isContinuous())
+ return false;
+
+ UMat Lt = Lt_.getUMat(), Lf = Lf_.getUMat(), Lstep = Lstep_.getUMat();
+
+ size_t globalSize[] = {(size_t)Lt.cols, (size_t)Lt.rows};
+
+ ocl::Kernel ker("AKAZE_nld_step_scalar", ocl::features2d::akaze_oclsrc);
+ if (ker.empty())
+ return false;
+
+ return ker.args(
+ ocl::KernelArg::ReadOnly(Lt),
+ ocl::KernelArg::PtrReadOnly(Lf),
+ ocl::KernelArg::PtrWriteOnly(Lstep),
+ step_size)
+ .run(2, globalSize, 0, true);
+}
+#endif // HAVE_OPENCL
+
+static inline void
+non_linear_diffusion_step(InputArray Lt, InputArray Lf, OutputArray Lstep, float step_size)
+{
+ CV_INSTRUMENT_REGION()
+
+ Lstep.create(Lt.size(), Lt.type());
+
+#ifdef HAVE_OPENCL
+ CV_OCL_RUN(OCL_PERFORMANCE_CHECK(Lstep.isUMat()), ocl_non_linear_diffusion_step(Lt, Lf, Lstep, step_size));
+#endif
+
+ Mat Mstep = Lstep.getMat();
+ parallel_for_(Range(0, Lt.rows()), NonLinearScalarDiffusionStep(Lt.getMat(), Lf.getMat(), Mstep, step_size));
+}
+
+/**
+ * @brief This function computes a good empirical value for the k contrast factor
+ * given two gradient images, the percentile (0-1), the temporal storage to hold
+ * gradient norms and the histogram bins
+ * @param Lx Horizontal gradient of the input image
+ * @param Ly Vertical gradient of the input image
+ * @param nbins Number of histogram bins
+ * @return k contrast factor
+ */
+static inline float
+compute_kcontrast(const cv::Mat& Lx, const cv::Mat& Ly, float perc, int nbins)
+{
+ CV_INSTRUMENT_REGION()
+
+ CV_Assert(nbins > 2);
+ CV_Assert(!Lx.empty());
+
+ // temporary square roots of dot product
+ Mat modgs (Lx.rows - 2, Lx.cols - 2, CV_32F);
+ const int total = modgs.cols * modgs.rows;
+ float *modg = modgs.ptr<float>();
+ float hmax = 0.0f;
+
+ for (int i = 1; i < Lx.rows - 1; i++) {
+ const float *lx = Lx.ptr<float>(i) + 1;
+ const float *ly = Ly.ptr<float>(i) + 1;
+ const int cols = Lx.cols - 2;
+
+ for (int j = 0; j < cols; j++) {
+ float dist = sqrtf(lx[j] * lx[j] + ly[j] * ly[j]);
+ *modg++ = dist;
+ hmax = std::max(hmax, dist);
+ }
+ }
+ modg = modgs.ptr<float>();
+
+ if (hmax == 0.0f)
+ return 0.03f; // e.g. a blank image
+
+ // Compute the bin numbers: the value range [0, hmax] -> [0, nbins-1]
+ modgs *= (nbins - 1) / hmax;
+
+ // Count up histogram
+ std::vector<int> hist(nbins, 0);
+ for (int i = 0; i < total; i++)
+ hist[(int)modg[i]]++;
+
+ // Now find the perc of the histogram percentile
+ const int nthreshold = (int)((total - hist[0]) * perc); // Exclude hist[0] as background
+ int nelements = 0;
+ for (int k = 1; k < nbins; k++) {
+ if (nelements >= nthreshold)
+ return (float)hmax * k / nbins;
+
+ nelements += hist[k];
+ }
+
+ return 0.03f;
+}
+
+#ifdef HAVE_OPENCL
+static inline bool
+ocl_pm_g2(InputArray Lx_, InputArray Ly_, OutputArray Lflow_, float kcontrast)
+{
+ UMat Lx = Lx_.getUMat(), Ly = Ly_.getUMat(), Lflow = Lflow_.getUMat();
+
+ int total = Lx.rows * Lx.cols;
+ size_t globalSize[] = {(size_t)total};
+
+ ocl::Kernel ker("AKAZE_pm_g2", ocl::features2d::akaze_oclsrc);
+ if (ker.empty())
+ return false;
+
+ return ker.args(
+ ocl::KernelArg::PtrReadOnly(Lx),
+ ocl::KernelArg::PtrReadOnly(Ly),
+ ocl::KernelArg::PtrWriteOnly(Lflow),
+ kcontrast, total)
+ .run(1, globalSize, 0, true);
+}
+#endif // HAVE_OPENCL
+
+static inline void
+compute_diffusivity(InputArray Lx, InputArray Ly, OutputArray Lflow, float kcontrast, int diffusivity)
+{
+ CV_INSTRUMENT_REGION()
+
+ Lflow.create(Lx.size(), Lx.type());
+
+ switch (diffusivity) {
+ case KAZE::DIFF_PM_G1:
+ pm_g1(Lx, Ly, Lflow, kcontrast);
+ break;
+ case KAZE::DIFF_PM_G2:
+#ifdef HAVE_OPENCL
+ CV_OCL_RUN(OCL_PERFORMANCE_CHECK(Lflow.isUMat()), ocl_pm_g2(Lx, Ly, Lflow, kcontrast));
+#endif
+ pm_g2(Lx, Ly, Lflow, kcontrast);
+ break;
+ case KAZE::DIFF_WEICKERT:
+ weickert_diffusivity(Lx, Ly, Lflow, kcontrast);
+ break;
+ case KAZE::DIFF_CHARBONNIER:
+ charbonnier_diffusivity(Lx, Ly, Lflow, kcontrast);
+ break;
+ default:
+ CV_Error(diffusivity, "Diffusivity is not supported");
+ break;
+ }
+}
+
+/**
* @brief This method creates the nonlinear scale space for a given image
* @param img Input image for which the nonlinear scale space needs to be created
* @return 0 if the nonlinear scale space was created successfully, -1 otherwise
*/
-int AKAZEFeatures::Create_Nonlinear_Scale_Space(const Mat& img)
+void AKAZEFeatures::Create_Nonlinear_Scale_Space(InputArray img)
{
+ CV_INSTRUMENT_REGION()
CV_Assert(evolution_.size() > 0);
- // Copy the original image to the first level of the evolution
- img.copyTo(evolution_[0].Lt);
- gaussian_2D_convolution(evolution_[0].Lt, evolution_[0].Lt, 0, 0, options_.soffset);
- evolution_[0].Lt.copyTo(evolution_[0].Lsmooth);
+ // create first level of the evolution
+ int ksize = getGaussianKernelSize(options_.soffset);
+ GaussianBlur(img, evolution_[0].Lsmooth, Size(ksize, ksize), options_.soffset, options_.soffset, BORDER_REPLICATE);
+ evolution_[0].Lsmooth.copyTo(evolution_[0].Lt);
+
+ if (evolution_.size() == 1) {
+ // we don't need to compute kcontrast factor
+ Compute_Determinant_Hessian_Response();
+ return;
+ }
- // Allocate memory for the flow and step images
- Mat Lflow = Mat::zeros(evolution_[0].Lt.rows, evolution_[0].Lt.cols, CV_32F);
- Mat Lstep = Mat::zeros(evolution_[0].Lt.rows, evolution_[0].Lt.cols, CV_32F);
+ // derivatives, flow and diffusion step
+ Mat Lx, Ly, Lsmooth, Lflow, Lstep;
- // First compute the kcontrast factor
- options_.kcontrast = compute_k_percentile(img, options_.kcontrast_percentile, 1.0f, options_.kcontrast_nbins, 0, 0);
+ // compute derivatives for computing k contrast
+ GaussianBlur(img, Lsmooth, Size(5, 5), 1.0f, 1.0f, BORDER_REPLICATE);
+ Scharr(Lsmooth, Lx, CV_32F, 1, 0, 1, 0, BORDER_DEFAULT);
+ Scharr(Lsmooth, Ly, CV_32F, 0, 1, 1, 0, BORDER_DEFAULT);
+ Lsmooth.release();
+ // compute the kcontrast factor
+ float kcontrast = compute_kcontrast(Lx, Ly, options_.kcontrast_percentile, options_.kcontrast_nbins);
// Now generate the rest of evolution levels
for (size_t i = 1; i < evolution_.size(); i++) {
+ Evolution &e = evolution_[i];
- if (evolution_[i].octave > evolution_[i - 1].octave) {
- halfsample_image(evolution_[i - 1].Lt, evolution_[i].Lt);
- options_.kcontrast = options_.kcontrast*0.75f;
-
- // Allocate memory for the resized flow and step images
- Lflow = Mat::zeros(evolution_[i].Lt.rows, evolution_[i].Lt.cols, CV_32F);
- Lstep = Mat::zeros(evolution_[i].Lt.rows, evolution_[i].Lt.cols, CV_32F);
+ if (e.octave > evolution_[i - 1].octave) {
+ // new octave will be half the size
+ resize(evolution_[i - 1].Lt, e.Lt, e.size, 0, 0, INTER_AREA);
+ kcontrast *= 0.75f;
}
else {
- evolution_[i - 1].Lt.copyTo(evolution_[i].Lt);
+ evolution_[i - 1].Lt.copyTo(e.Lt);
}
- gaussian_2D_convolution(evolution_[i].Lt, evolution_[i].Lsmooth, 0, 0, 1.0f);
+ GaussianBlur(e.Lt, e.Lsmooth, Size(5, 5), 1.0f, 1.0f, BORDER_REPLICATE);
// Compute the Gaussian derivatives Lx and Ly
- image_derivatives_scharr(evolution_[i].Lsmooth, evolution_[i].Lx, 1, 0);
- image_derivatives_scharr(evolution_[i].Lsmooth, evolution_[i].Ly, 0, 1);
+ Scharr(e.Lsmooth, Lx, CV_32F, 1, 0, 1.0, 0, BORDER_DEFAULT);
+ Scharr(e.Lsmooth, Ly, CV_32F, 0, 1, 1.0, 0, BORDER_DEFAULT);
// Compute the conductivity equation
- switch (options_.diffusivity) {
- case KAZE::DIFF_PM_G1:
- pm_g1(evolution_[i].Lx, evolution_[i].Ly, Lflow, options_.kcontrast);
- break;
- case KAZE::DIFF_PM_G2:
- pm_g2(evolution_[i].Lx, evolution_[i].Ly, Lflow, options_.kcontrast);
- break;
- case KAZE::DIFF_WEICKERT:
- weickert_diffusivity(evolution_[i].Lx, evolution_[i].Ly, Lflow, options_.kcontrast);
- break;
- case KAZE::DIFF_CHARBONNIER:
- charbonnier_diffusivity(evolution_[i].Lx, evolution_[i].Ly, Lflow, options_.kcontrast);
- break;
- default:
- CV_Error(options_.diffusivity, "Diffusivity is not supported");
- break;
- }
-
- // Perform FED n inner steps
- for (int j = 0; j < nsteps_[i - 1]; j++) {
- nld_step_scalar(evolution_[i].Lt, Lflow, Lstep, tsteps_[i - 1][j]);
+ compute_diffusivity(Lx, Ly, Lflow, kcontrast, options_.diffusivity);
+
+ // Perform Fast Explicit Diffusion on Lt
+ std::vector<float> &tsteps = tsteps_[i - 1];
+ for (size_t j = 0; j < tsteps.size(); j++) {
+ const float step_size = tsteps[j] * 0.5f;
+ non_linear_diffusion_step(e.Lt, Lflow, Lstep, step_size);
+ add(e.Lt, Lstep, e.Lt);
}
}
- return 0;
+ Compute_Determinant_Hessian_Response();
}
/* ************************************************************************* */
+
+#ifdef HAVE_OPENCL
+static inline bool
+ocl_compute_determinant(InputArray Lxx_, InputArray Lxy_, InputArray Lyy_, OutputArray Ldet_, float sigma)
+{
+ UMat Lxx = Lxx_.getUMat(), Lxy = Lxy_.getUMat(), Lyy = Lyy_.getUMat(), Ldet = Ldet_.getUMat();
+
+ const int total = Lxx.rows * Lxx.cols;
+ size_t globalSize[] = {(size_t)total};
+
+ ocl::Kernel ker("AKAZE_compute_determinant", ocl::features2d::akaze_oclsrc);
+ if (ker.empty())
+ return false;
+
+ return ker.args(
+ ocl::KernelArg::PtrReadOnly(Lxx),
+ ocl::KernelArg::PtrReadOnly(Lxy),
+ ocl::KernelArg::PtrReadOnly(Lyy),
+ ocl::KernelArg::PtrWriteOnly(Ldet),
+ sigma, total)
+ .run(1, globalSize, 0, true);
+}
+#endif // HAVE_OPENCL
+
/**
- * @brief This method selects interesting keypoints through the nonlinear scale space
- * @param kpts Vector of detected keypoints
+ * @brief Compute determinant from hessians
+ * @details Compute Ldet by (Lxx.mul(Lyy) - Lxy.mul(Lxy)) * sigma
+ *
+ * @param Lxx spatial derivates
+ * @param Lxy spatial derivates
+ * @param Lyy spatial derivates
+ * @param Ldet output determinant
+ * @param sigma determinant will be scaled by this sigma
*/
-void AKAZEFeatures::Feature_Detection(std::vector<KeyPoint>& kpts)
+static inline void compute_determinant(InputArray Lxx, InputArray Lxy, InputArray Lyy, OutputArray Ldet, float sigma)
{
- kpts.clear();
- Compute_Determinant_Hessian_Response();
- Find_Scale_Space_Extrema(kpts);
- Do_Subpixel_Refinement(kpts);
+ CV_INSTRUMENT_REGION()
+
+ Ldet.create(Lxx.size(), Lxx.type());
+
+#ifdef HAVE_OPENCL
+ CV_OCL_RUN(OCL_PERFORMANCE_CHECK(Ldet.isUMat()), ocl_compute_determinant(Lxx, Lxy, Lyy, Ldet, sigma));
+#endif
+
+ // output determinant
+ Mat Mxx = Lxx.getMat(), Mxy = Lxy.getMat(), Myy = Lyy.getMat(), Mdet = Ldet.getMat();
+ const int W = Mxx.cols, H = Mxx.rows;
+ for (int y = 0; y < H; y++)
+ {
+ float *lxx = Mxx.ptr<float>(y);
+ float *lxy = Mxy.ptr<float>(y);
+ float *lyy = Myy.ptr<float>(y);
+ float *ldet = Mdet.ptr<float>(y);
+ for (int x = 0; x < W; x++)
+ {
+ ldet[x] = (lxx[x] * lyy[x] - lxy[x] * lxy[x]) * sigma;
+ }
+ }
}
-/* ************************************************************************* */
-class MultiscaleDerivativesAKAZEInvoker : public ParallelLoopBody
+class DeterminantHessianResponse : public ParallelLoopBody
{
public:
- explicit MultiscaleDerivativesAKAZEInvoker(std::vector<TEvolution>& ev, const AKAZEOptions& opt)
+ explicit DeterminantHessianResponse(std::vector<Evolution>& ev)
: evolution_(&ev)
- , options_(opt)
{
}
void operator()(const Range& range) const
{
- std::vector<TEvolution>& evolution = *evolution_;
+ Mat Lxx, Lxy, Lyy;
for (int i = range.start; i < range.end; i++)
{
- float ratio = (float)fastpow(2, evolution[i].octave);
- int sigma_size_ = fRound(evolution[i].esigma * options_.derivative_factor / ratio);
-
- compute_scharr_derivatives(evolution[i].Lsmooth, evolution[i].Lx, 1, 0, sigma_size_);
- compute_scharr_derivatives(evolution[i].Lsmooth, evolution[i].Ly, 0, 1, sigma_size_);
- compute_scharr_derivatives(evolution[i].Lx, evolution[i].Lxx, 1, 0, sigma_size_);
- compute_scharr_derivatives(evolution[i].Ly, evolution[i].Lyy, 0, 1, sigma_size_);
- compute_scharr_derivatives(evolution[i].Lx, evolution[i].Lxy, 0, 1, sigma_size_);
-
- evolution[i].Lx = evolution[i].Lx*((sigma_size_));
- evolution[i].Ly = evolution[i].Ly*((sigma_size_));
- evolution[i].Lxx = evolution[i].Lxx*((sigma_size_)*(sigma_size_));
- evolution[i].Lxy = evolution[i].Lxy*((sigma_size_)*(sigma_size_));
- evolution[i].Lyy = evolution[i].Lyy*((sigma_size_)*(sigma_size_));
+ Evolution &e = (*evolution_)[i];
+
+ // we cannot use cv:Scharr here, because we need to handle also
+ // kernel sizes other than 3, by default we are using 9x9, 5x5 and 7x7
+
+ // compute kernels
+ Mat DxKx, DxKy, DyKx, DyKy;
+ compute_derivative_kernels(DxKx, DxKy, 1, 0, e.sigma_size);
+ compute_derivative_kernels(DyKx, DyKy, 0, 1, e.sigma_size);
+
+ // compute the multiscale derivatives
+ sepFilter2D(e.Lsmooth, e.Lx, CV_32F, DxKx, DxKy);
+ sepFilter2D(e.Lx, Lxx, CV_32F, DxKx, DxKy);
+ sepFilter2D(e.Lx, Lxy, CV_32F, DyKx, DyKy);
+ sepFilter2D(e.Lsmooth, e.Ly, CV_32F, DyKx, DyKy);
+ sepFilter2D(e.Ly, Lyy, CV_32F, DyKx, DyKy);
+
+ // free Lsmooth to same some space in the pyramid, it is not needed anymore
+ e.Lsmooth.release();
+
+ // compute determinant scaled by sigma
+ float sigma_size_quat = (float)(e.sigma_size * e.sigma_size * e.sigma_size * e.sigma_size);
+ compute_determinant(Lxx, Lxy, Lyy, e.Ldet, sigma_size_quat);
}
}
private:
- std::vector<TEvolution>* evolution_;
- AKAZEOptions options_;
+ std::vector<Evolution>* evolution_;
};
-/* ************************************************************************* */
-/**
- * @brief This method computes the multiscale derivatives for the nonlinear scale space
- */
-void AKAZEFeatures::Compute_Multiscale_Derivatives(void)
-{
- parallel_for_(Range(0, (int)evolution_.size()),
- MultiscaleDerivativesAKAZEInvoker(evolution_, options_));
-}
-/* ************************************************************************* */
/**
* @brief This method computes the feature detector response for the nonlinear scale space
* @note We use the Hessian determinant as the feature detector response
*/
void AKAZEFeatures::Compute_Determinant_Hessian_Response(void) {
+ CV_INSTRUMENT_REGION()
- // Firstly compute the multiscale derivatives
- Compute_Multiscale_Derivatives();
-
- for (size_t i = 0; i < evolution_.size(); i++)
- {
- for (int ix = 0; ix < evolution_[i].Ldet.rows; ix++)
- {
- for (int jx = 0; jx < evolution_[i].Ldet.cols; jx++)
- {
- float lxx = *(evolution_[i].Lxx.ptr<float>(ix)+jx);
- float lxy = *(evolution_[i].Lxy.ptr<float>(ix)+jx);
- float lyy = *(evolution_[i].Lyy.ptr<float>(ix)+jx);
- *(evolution_[i].Ldet.ptr<float>(ix)+jx) = (lxx*lyy - lxy*lxy);
- }
- }
+ if (ocl::useOpenCL()) {
+ DeterminantHessianResponse body (evolution_);
+ body(Range(0, (int)evolution_.size()));
+ } else {
+ parallel_for_(Range(0, (int)evolution_.size()), DeterminantHessianResponse(evolution_));
}
}
/* ************************************************************************* */
+
/**
- * @brief This method finds extrema in the nonlinear scale space
+ * @brief This method selects interesting keypoints through the nonlinear scale space
* @param kpts Vector of detected keypoints
*/
-void AKAZEFeatures::Find_Scale_Space_Extrema(std::vector<KeyPoint>& kpts)
+void AKAZEFeatures::Feature_Detection(std::vector<KeyPoint>& kpts)
{
+ CV_INSTRUMENT_REGION()
- float value = 0.0;
- float dist = 0.0, ratio = 0.0, smax = 0.0;
- int npoints = 0, id_repeated = 0;
- int sigma_size_ = 0, left_x = 0, right_x = 0, up_y = 0, down_y = 0;
- bool is_extremum = false, is_repeated = false, is_out = false;
- KeyPoint point;
- vector<KeyPoint> kpts_aux;
+ kpts.clear();
+ std::vector<Mat> keypoints_by_layers;
+ Find_Scale_Space_Extrema(keypoints_by_layers);
+ Do_Subpixel_Refinement(keypoints_by_layers, kpts);
+}
- // Set maximum size
- if (options_.descriptor == AKAZE::DESCRIPTOR_MLDB_UPRIGHT || options_.descriptor == AKAZE::DESCRIPTOR_MLDB) {
- smax = 10.0f*sqrtf(2.0f);
- }
- else if (options_.descriptor == AKAZE::DESCRIPTOR_KAZE_UPRIGHT || options_.descriptor == AKAZE::DESCRIPTOR_KAZE) {
- smax = 12.0f*sqrtf(2.0f);
+/**
+ * @brief This method searches v for a neighbor point of the point candidate p
+ * @param x Coordinates of the keypoint candidate to search a neighbor
+ * @param y Coordinates of the keypoint candidate to search a neighbor
+ * @param mask Matrix holding keypoints positions
+ * @param search_radius neighbour radius for searching keypoints
+ * @param idx The index to mask, pointing to keypoint found.
+ * @return true if a neighbor point is found; false otherwise
+ */
+static inline bool
+find_neighbor_point(const int x, const int y, const Mat &mask, const int search_radius, int &idx)
+{
+ // search neighborhood for keypoints
+ for (int i = y - search_radius; i < y + search_radius; ++i) {
+ const uchar *curr = mask.ptr<uchar>(i);
+ for (int j = x - search_radius; j < x + search_radius; ++j) {
+ if (curr[j] == 0) {
+ continue; // skip non-keypoint
+ }
+ // fine-compare with L2 metric (L2 is smaller than our search window)
+ int dx = j - x;
+ int dy = i - y;
+ if (dx * dx + dy * dy <= search_radius * search_radius) {
+ idx = i * mask.cols + j;
+ return true;
+ }
+ }
}
- for (size_t i = 0; i < evolution_.size(); i++) {
- float* prev = evolution_[i].Ldet.ptr<float>(0);
- float* curr = evolution_[i].Ldet.ptr<float>(1);
- for (int ix = 1; ix < evolution_[i].Ldet.rows - 1; ix++) {
- float* next = evolution_[i].Ldet.ptr<float>(ix + 1);
-
- for (int jx = 1; jx < evolution_[i].Ldet.cols - 1; jx++) {
- is_extremum = false;
- is_repeated = false;
- is_out = false;
- value = *(evolution_[i].Ldet.ptr<float>(ix)+jx);
-
- // Filter the points with the detector threshold
- if (value > options_.dthreshold && value >= options_.min_dthreshold &&
- value > curr[jx-1] &&
- value > curr[jx+1] &&
- value > prev[jx-1] &&
- value > prev[jx] &&
- value > prev[jx+1] &&
- value > next[jx-1] &&
- value > next[jx] &&
- value > next[jx+1]) {
-
- is_extremum = true;
- point.response = fabs(value);
- point.size = evolution_[i].esigma*options_.derivative_factor;
- point.octave = (int)evolution_[i].octave;
- point.class_id = (int)i;
- ratio = (float)fastpow(2, point.octave);
- sigma_size_ = fRound(point.size / ratio);
- point.pt.x = static_cast<float>(jx);
- point.pt.y = static_cast<float>(ix);
-
- // Compare response with the same and lower scale
- for (size_t ik = 0; ik < kpts_aux.size(); ik++) {
-
- if ((point.class_id - 1) == kpts_aux[ik].class_id ||
- point.class_id == kpts_aux[ik].class_id) {
- float distx = point.pt.x*ratio - kpts_aux[ik].pt.x;
- float disty = point.pt.y*ratio - kpts_aux[ik].pt.y;
- dist = distx * distx + disty * disty;
- if (dist <= point.size * point.size) {
- if (point.response > kpts_aux[ik].response) {
- id_repeated = (int)ik;
- is_repeated = true;
- }
- else {
- is_extremum = false;
- }
- break;
- }
+ return false;
+}
+
+/**
+ * @brief Find keypoints in parallel for each pyramid layer
+ */
+class FindKeypointsSameScale : public ParallelLoopBody
+{
+public:
+ explicit FindKeypointsSameScale(const std::vector<Evolution>& ev,
+ std::vector<Mat>& kpts, float dthreshold)
+ : evolution_(&ev), keypoints_by_layers_(&kpts), dthreshold_(dthreshold)
+ {}
+
+ void operator()(const Range& range) const
+ {
+ for (int i = range.start; i < range.end; i++)
+ {
+ const Evolution &e = (*evolution_)[i];
+ Mat &kpts = (*keypoints_by_layers_)[i];
+ // this mask will hold positions of keypoints in this level
+ kpts = Mat::zeros(e.Ldet.size(), CV_8UC1);
+
+ // if border is too big we shouldn't search any keypoints
+ if (e.border + 1 >= e.Ldet.rows)
+ continue;
+
+ const float * prev = e.Ldet.ptr<float>(e.border - 1);
+ const float * curr = e.Ldet.ptr<float>(e.border );
+ const float * next = e.Ldet.ptr<float>(e.border + 1);
+ const float * ldet = e.Ldet.ptr<float>();
+ uchar *mask = kpts.ptr<uchar>();
+ const int search_radius = e.sigma_size; // size of keypoint in this level
+
+ for (int y = e.border; y < e.Ldet.rows - e.border; y++) {
+ for (int x = e.border; x < e.Ldet.cols - e.border; x++) {
+ const float value = curr[x];
+
+ // Filter the points with the detector threshold
+ if (value <= dthreshold_)
+ continue;
+ if (value <= curr[x-1] || value <= curr[x+1])
+ continue;
+ if (value <= prev[x-1] || value <= prev[x ] || value <= prev[x+1])
+ continue;
+ if (value <= next[x-1] || value <= next[x ] || value <= next[x+1])
+ continue;
+
+ int idx = 0;
+ // Compare response with the same scale
+ if (find_neighbor_point(x, y, kpts, search_radius, idx)) {
+ if (value > ldet[idx]) {
+ mask[idx] = 0; // clear old point - we have better candidate now
+ } else {
+ continue; // there already is a better keypoint
}
}
- // Check out of bounds
- if (is_extremum == true) {
+ kpts.at<uchar>(y, x) = 1; // we have a new keypoint
+ }
- // Check that the point is under the image limits for the descriptor computation
- left_x = fRound(point.pt.x - smax*sigma_size_) - 1;
- right_x = fRound(point.pt.x + smax*sigma_size_) + 1;
- up_y = fRound(point.pt.y - smax*sigma_size_) - 1;
- down_y = fRound(point.pt.y + smax*sigma_size_) + 1;
+ prev = curr;
+ curr = next;
+ next += e.Ldet.cols;
+ }
+ }
+ }
- if (left_x < 0 || right_x >= evolution_[i].Ldet.cols ||
- up_y < 0 || down_y >= evolution_[i].Ldet.rows) {
- is_out = true;
- }
+private:
+ const std::vector<Evolution>* evolution_;
+ std::vector<Mat>* keypoints_by_layers_;
+ float dthreshold_; ///< Detector response threshold to accept point
+};
- if (is_out == false) {
- if (is_repeated == false) {
- point.pt.x = (float)(point.pt.x*ratio + .5*(ratio-1.0));
- point.pt.y = (float)(point.pt.y*ratio + .5*(ratio-1.0));
- kpts_aux.push_back(point);
- npoints++;
- }
- else {
- point.pt.x = (float)(point.pt.x*ratio + .5*(ratio-1.0));
- point.pt.y = (float)(point.pt.y*ratio + .5*(ratio-1.0));
- kpts_aux[id_repeated] = point;
- }
- } // if is_out
- } //if is_extremum
+/**
+ * @brief This method finds extrema in the nonlinear scale space
+ * @param keypoints_by_layers Output vectors of detected keypoints; one vector for each evolution level
+ */
+void AKAZEFeatures::Find_Scale_Space_Extrema(std::vector<Mat>& keypoints_by_layers)
+{
+ CV_INSTRUMENT_REGION()
+
+ keypoints_by_layers.resize(evolution_.size());
+
+ // find points in the same level
+ parallel_for_(Range(0, (int)evolution_.size()),
+ FindKeypointsSameScale(evolution_, keypoints_by_layers, options_.dthreshold));
+
+ // Filter points with the lower scale level
+ for (size_t i = 1; i < keypoints_by_layers.size(); i++) {
+ // constants for this level
+ const Mat &keypoints = keypoints_by_layers[i];
+ const uchar *const kpts = keypoints_by_layers[i].ptr<uchar>();
+ uchar *const kpts_prev = keypoints_by_layers[i-1].ptr<uchar>();
+ const float *const ldet = evolution_[i].Ldet.ptr<float>();
+ const float *const ldet_prev = evolution_[i-1].Ldet.ptr<float>();
+ // ratios are just powers of 2
+ const int diff_ratio = (int)evolution_[i].octave_ratio / (int)evolution_[i-1].octave_ratio;
+ const int search_radius = evolution_[i].sigma_size * diff_ratio; // size of keypoint in this level
+
+ size_t j = 0;
+ for (int y = 0; y < keypoints.rows; y++) {
+ for (int x = 0; x < keypoints.cols; x++, j++) {
+ if (kpts[j] == 0) {
+ continue; // skip non-keypoints
}
- } // for jx
- prev = curr;
- curr = next;
- } // for ix
- } // for i
-
- // Now filter points with the upper scale level
- for (size_t i = 0; i < kpts_aux.size(); i++) {
-
- is_repeated = false;
- const KeyPoint& pt = kpts_aux[i];
- for (size_t j = i + 1; j < kpts_aux.size(); j++) {
-
- // Compare response with the upper scale
- if ((pt.class_id + 1) == kpts_aux[j].class_id) {
- float distx = pt.pt.x - kpts_aux[j].pt.x;
- float disty = pt.pt.y - kpts_aux[j].pt.y;
- dist = distx * distx + disty * disty;
- if (dist <= pt.size * pt.size) {
- if (pt.response < kpts_aux[j].response) {
- is_repeated = true;
- break;
+ int idx = 0;
+ // project point to lower scale layer
+ const int p_x = x * diff_ratio;
+ const int p_y = y * diff_ratio;
+ if (find_neighbor_point(p_x, p_y, keypoints_by_layers[i-1], search_radius, idx)) {
+ if (ldet[j] > ldet_prev[idx]) {
+ kpts_prev[idx] = 0; // clear keypoint in lower layer
}
+ // else this pt may be pruned by the upper scale
}
}
}
+ }
- if (is_repeated == false)
- kpts.push_back(pt);
+ // Now filter points with the upper scale level (the other direction)
+ for (int i = (int)keypoints_by_layers.size() - 2; i >= 0; i--) {
+ // constants for this level
+ const Mat &keypoints = keypoints_by_layers[i];
+ const uchar *const kpts = keypoints_by_layers[i].ptr<uchar>();
+ uchar *const kpts_next = keypoints_by_layers[i+1].ptr<uchar>();
+ const float *const ldet = evolution_[i].Ldet.ptr<float>();
+ const float *const ldet_next = evolution_[i+1].Ldet.ptr<float>();
+ // ratios are just powers of 2, i+1 ratio is always greater or equal to i
+ const int diff_ratio = (int)evolution_[i+1].octave_ratio / (int)evolution_[i].octave_ratio;
+ const int search_radius = evolution_[i+1].sigma_size; // size of keypoints in upper level
+
+ size_t j = 0;
+ for (int y = 0; y < keypoints.rows; y++) {
+ for (int x = 0; x < keypoints.cols; x++, j++) {
+ if (kpts[j] == 0) {
+ continue; // skip non-keypoints
+ }
+ int idx = 0;
+ // project point to upper scale layer
+ const int p_x = x / diff_ratio;
+ const int p_y = y / diff_ratio;
+ if (find_neighbor_point(p_x, p_y, keypoints_by_layers[i+1], search_radius, idx)) {
+ if (ldet[j] > ldet_next[idx]) {
+ kpts_next[idx] = 0; // clear keypoint in upper layer
+ }
+ }
+ }
+ }
}
}
/* ************************************************************************* */
/**
* @brief This method performs subpixel refinement of the detected keypoints
- * @param kpts Vector of detected keypoints
+ * @param keypoints_by_layers Input vectors of detected keypoints, sorted by evolution levels
+ * @param kpts Output vector of the final refined keypoints
*/
-void AKAZEFeatures::Do_Subpixel_Refinement(std::vector<KeyPoint>& kpts)
+void AKAZEFeatures::Do_Subpixel_Refinement(
+ std::vector<Mat>& keypoints_by_layers, std::vector<KeyPoint>& output_keypoints)
{
- float Dx = 0.0, Dy = 0.0, ratio = 0.0;
- float Dxx = 0.0, Dyy = 0.0, Dxy = 0.0;
- int x = 0, y = 0;
- Matx22f A(0, 0, 0, 0);
- Vec2f b(0, 0);
- Vec2f dst(0, 0);
-
- for (size_t i = 0; i < kpts.size(); i++) {
- ratio = (float)fastpow(2, kpts[i].octave);
- x = fRound(kpts[i].pt.x / ratio);
- y = fRound(kpts[i].pt.y / ratio);
-
- // Compute the gradient
- Dx = (0.5f)*(*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y)+x + 1)
- - *(evolution_[kpts[i].class_id].Ldet.ptr<float>(y)+x - 1));
- Dy = (0.5f)*(*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y + 1) + x)
- - *(evolution_[kpts[i].class_id].Ldet.ptr<float>(y - 1) + x));
-
- // Compute the Hessian
- Dxx = (*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y)+x + 1)
- + *(evolution_[kpts[i].class_id].Ldet.ptr<float>(y)+x - 1)
- - 2.0f*(*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y)+x)));
-
- Dyy = (*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y + 1) + x)
- + *(evolution_[kpts[i].class_id].Ldet.ptr<float>(y - 1) + x)
- - 2.0f*(*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y)+x)));
-
- Dxy = (0.25f)*(*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y + 1) + x + 1)
- + (*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y - 1) + x - 1)))
- - (0.25f)*(*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y - 1) + x + 1)
- + (*(evolution_[kpts[i].class_id].Ldet.ptr<float>(y + 1) + x - 1)));
-
- // Solve the linear system
- A(0, 0) = Dxx;
- A(1, 1) = Dyy;
- A(0, 1) = A(1, 0) = Dxy;
- b(0) = -Dx;
- b(1) = -Dy;
-
- solve(A, b, dst, DECOMP_LU);
-
- if (fabs(dst(0)) <= 1.0f && fabs(dst(1)) <= 1.0f) {
- kpts[i].pt.x = x + dst(0);
- kpts[i].pt.y = y + dst(1);
- int power = fastpow(2, evolution_[kpts[i].class_id].octave);
- kpts[i].pt.x = (float)(kpts[i].pt.x*power + .5*(power-1));
- kpts[i].pt.y = (float)(kpts[i].pt.y*power + .5*(power-1));
- kpts[i].angle = 0.0;
-
- // In OpenCV the size of a keypoint its the diameter
- kpts[i].size *= 2.0f;
- }
- // Delete the point since its not stable
- else {
- kpts.erase(kpts.begin() + i);
- i--;
+ CV_INSTRUMENT_REGION()
+
+ for (size_t i = 0; i < keypoints_by_layers.size(); i++) {
+ const Evolution &e = evolution_[i];
+ const float * const ldet = e.Ldet.ptr<float>();
+ const float ratio = e.octave_ratio;
+ const int cols = e.Ldet.cols;
+ const Mat& keypoints = keypoints_by_layers[i];
+ const uchar *const kpts = keypoints.ptr<uchar>();
+
+ size_t j = 0;
+ for (int y = 0; y < keypoints.rows; y++) {
+ for (int x = 0; x < keypoints.cols; x++, j++) {
+ if (kpts[j] == 0) {
+ continue; // skip non-keypoints
+ }
+
+ // create a new keypoint
+ KeyPoint kp;
+ kp.pt.x = x * e.octave_ratio;
+ kp.pt.y = y * e.octave_ratio;
+ kp.size = e.esigma * options_.derivative_factor;
+ kp.angle = -1;
+ kp.response = ldet[j];
+ kp.octave = e.octave;
+ kp.class_id = static_cast<int>(i);
+
+ // Compute the gradient
+ float Dx = 0.5f * (ldet[ y *cols + x + 1] - ldet[ y *cols + x - 1]);
+ float Dy = 0.5f * (ldet[(y + 1)*cols + x ] - ldet[(y - 1)*cols + x ]);
+
+ // Compute the Hessian
+ float Dxx = ldet[ y *cols + x + 1] + ldet[ y *cols + x - 1] - 2.0f * ldet[y*cols + x];
+ float Dyy = ldet[(y + 1)*cols + x ] + ldet[(y - 1)*cols + x ] - 2.0f * ldet[y*cols + x];
+ float Dxy = 0.25f * (ldet[(y + 1)*cols + x + 1] + ldet[(y - 1)*cols + x - 1] -
+ ldet[(y - 1)*cols + x + 1] - ldet[(y + 1)*cols + x - 1]);
+
+ // Solve the linear system
+ Matx22f A( Dxx, Dxy,
+ Dxy, Dyy );
+ Vec2f b( -Dx, -Dy );
+ Vec2f dst( 0.0f, 0.0f );
+ solve(A, b, dst, DECOMP_LU);
+
+ float dx = dst(0);
+ float dy = dst(1);
+
+ if (fabs(dx) > 1.0f || fabs(dy) > 1.0f)
+ continue; // Ignore the point that is not stable
+
+ // Refine the coordinates
+ kp.pt.x += dx * ratio + .5f*(ratio-1.f);
+ kp.pt.y += dy * ratio + .5f*(ratio-1.f);
+
+ kp.angle = 0.0;
+ kp.size *= 2.0f; // In OpenCV the size of a keypoint is the diameter
+
+ // Push the refined keypoint to the final storage
+ output_keypoints.push_back(kp);
+ }
}
}
}
@@ -459,7 +865,7 @@ void AKAZEFeatures::Do_Subpixel_Refinement(std::vector<KeyPoint>& kpts)
class SURF_Descriptor_Upright_64_Invoker : public ParallelLoopBody
{
public:
- SURF_Descriptor_Upright_64_Invoker(std::vector<KeyPoint>& kpts, Mat& desc, std::vector<TEvolution>& evolution)
+ SURF_Descriptor_Upright_64_Invoker(std::vector<KeyPoint>& kpts, Mat& desc, std::vector<Evolution>& evolution)
: keypoints_(&kpts)
, descriptors_(&desc)
, evolution_(&evolution)
@@ -470,22 +876,22 @@ public:
{
for (int i = range.start; i < range.end; i++)
{
- Get_SURF_Descriptor_Upright_64((*keypoints_)[i], descriptors_->ptr<float>(i));
+ Get_SURF_Descriptor_Upright_64((*keypoints_)[i], descriptors_->ptr<float>(i), descriptors_->cols);
}
}
- void Get_SURF_Descriptor_Upright_64(const KeyPoint& kpt, float* desc) const;
+ void Get_SURF_Descriptor_Upright_64(const KeyPoint& kpt, float* desc, int desc_size) const;
private:
std::vector<KeyPoint>* keypoints_;
Mat* descriptors_;
- std::vector<TEvolution>* evolution_;
+ std::vector<Evolution>* evolution_;
};
class SURF_Descriptor_64_Invoker : public ParallelLoopBody
{
public:
- SURF_Descriptor_64_Invoker(std::vector<KeyPoint>& kpts, Mat& desc, std::vector<TEvolution>& evolution)
+ SURF_Descriptor_64_Invoker(std::vector<KeyPoint>& kpts, Mat& desc, std::vector<Evolution>& evolution)
: keypoints_(&kpts)
, descriptors_(&desc)
, evolution_(&evolution)
@@ -496,23 +902,22 @@ public:
{
for (int i = range.start; i < range.end; i++)
{
- AKAZEFeatures::Compute_Main_Orientation((*keypoints_)[i], *evolution_);
- Get_SURF_Descriptor_64((*keypoints_)[i], descriptors_->ptr<float>(i));
+ Get_SURF_Descriptor_64((*keypoints_)[i], descriptors_->ptr<float>(i), descriptors_->cols);
}
}
- void Get_SURF_Descriptor_64(const KeyPoint& kpt, float* desc) const;
+ void Get_SURF_Descriptor_64(const KeyPoint& kpt, float* desc, int desc_size) const;
private:
std::vector<KeyPoint>* keypoints_;
Mat* descriptors_;
- std::vector<TEvolution>* evolution_;
+ std::vector<Evolution>* evolution_;
};
class MSURF_Upright_Descriptor_64_Invoker : public ParallelLoopBody
{
public:
- MSURF_Upright_Descriptor_64_Invoker(std::vector<KeyPoint>& kpts, Mat& desc, std::vector<TEvolution>& evolution)
+ MSURF_Upright_Descriptor_64_Invoker(std::vector<KeyPoint>& kpts, Mat& desc, std::vector<Evolution>& evolution)
: keypoints_(&kpts)
, descriptors_(&desc)
, evolution_(&evolution)
@@ -523,22 +928,22 @@ public:
{
for (int i = range.start; i < range.end; i++)
{
- Get_MSURF_Upright_Descriptor_64((*keypoints_)[i], descriptors_->ptr<float>(i));
+ Get_MSURF_Upright_Descriptor_64((*keypoints_)[i], descriptors_->ptr<float>(i), descriptors_->cols);
}
}
- void Get_MSURF_Upright_Descriptor_64(const KeyPoint& kpt, float* desc) const;
+ void Get_MSURF_Upright_Descriptor_64(const KeyPoint& kpt, float* desc, int desc_size) const;
private:
std::vector<KeyPoint>* keypoints_;
Mat* descriptors_;
- std::vector<TEvolution>* evolution_;
+ std::vector<Evolution>* evolution_;
};
class MSURF_Descriptor_64_Invoker : public ParallelLoopBody
{
public:
- MSURF_Descriptor_64_Invoker(std::vector<KeyPoint>& kpts, Mat& desc, std::vector<TEvolution>& evolution)
+ MSURF_Descriptor_64_Invoker(std::vector<KeyPoint>& kpts, Mat& desc, std::vector<Evolution>& evolution)
: keypoints_(&kpts)
, descriptors_(&desc)
, evolution_(&evolution)
@@ -549,23 +954,22 @@ public:
{
for (int i = range.start; i < range.end; i++)
{
- AKAZEFeatures::Compute_Main_Orientation((*keypoints_)[i], *evolution_);
- Get_MSURF_Descriptor_64((*keypoints_)[i], descriptors_->ptr<float>(i));
+ Get_MSURF_Descriptor_64((*keypoints_)[i], descriptors_->ptr<float>(i), descriptors_->cols);
}
}
- void Get_MSURF_Descriptor_64(const KeyPoint& kpt, float* desc) const;
+ void Get_MSURF_Descriptor_64(const KeyPoint& kpt, float* desc, int desc_size) const;
private:
std::vector<KeyPoint>* keypoints_;
Mat* descriptors_;
- std::vector<TEvolution>* evolution_;
+ std::vector<Evolution>* evolution_;
};
class Upright_MLDB_Full_Descriptor_Invoker : public ParallelLoopBody
{
public:
- Upright_MLDB_Full_Descriptor_Invoker(std::vector<KeyPoint>& kpts, Mat& desc, std::vector<TEvolution>& evolution, AKAZEOptions& options)
+ Upright_MLDB_Full_Descriptor_Invoker(std::vector<KeyPoint>& kpts, Mat& desc, std::vector<Evolution>& evolution, AKAZEOptions& options)
: keypoints_(&kpts)
, descriptors_(&desc)
, evolution_(&evolution)
@@ -577,16 +981,16 @@ public:
{
for (int i = range.start; i < range.end; i++)
{
- Get_Upright_MLDB_Full_Descriptor((*keypoints_)[i], descriptors_->ptr<unsigned char>(i));
+ Get_Upright_MLDB_Full_Descriptor((*keypoints_)[i], descriptors_->ptr<unsigned char>(i), descriptors_->cols);
}
}
- void Get_Upright_MLDB_Full_Descriptor(const KeyPoint& kpt, unsigned char* desc) const;
+ void Get_Upright_MLDB_Full_Descriptor(const KeyPoint& kpt, unsigned char* desc, int desc_size) const;
private:
std::vector<KeyPoint>* keypoints_;
Mat* descriptors_;
- std::vector<TEvolution>* evolution_;
+ std::vector<Evolution>* evolution_;
AKAZEOptions* options_;
};
@@ -595,7 +999,7 @@ class Upright_MLDB_Descriptor_Subset_Invoker : public ParallelLoopBody
public:
Upright_MLDB_Descriptor_Subset_Invoker(std::vector<KeyPoint>& kpts,
Mat& desc,
- std::vector<TEvolution>& evolution,
+ std::vector<Evolution>& evolution,
AKAZEOptions& options,
Mat descriptorSamples,
Mat descriptorBits)
@@ -612,16 +1016,16 @@ public:
{
for (int i = range.start; i < range.end; i++)
{
- Get_Upright_MLDB_Descriptor_Subset((*keypoints_)[i], descriptors_->ptr<unsigned char>(i));
+ Get_Upright_MLDB_Descriptor_Subset((*keypoints_)[i], descriptors_->ptr<unsigned char>(i), descriptors_->cols);
}
}
- void Get_Upright_MLDB_Descriptor_Subset(const KeyPoint& kpt, unsigned char* desc) const;
+ void Get_Upright_MLDB_Descriptor_Subset(const KeyPoint& kpt, unsigned char* desc, int desc_size) const;
private:
std::vector<KeyPoint>* keypoints_;
Mat* descriptors_;
- std::vector<TEvolution>* evolution_;
+ std::vector<Evolution>* evolution_;
AKAZEOptions* options_;
Mat descriptorSamples_; // List of positions in the grids to sample LDB bits from.
@@ -631,7 +1035,7 @@ private:
class MLDB_Full_Descriptor_Invoker : public ParallelLoopBody
{
public:
- MLDB_Full_Descriptor_Invoker(std::vector<KeyPoint>& kpts, Mat& desc, std::vector<TEvolution>& evolution, AKAZEOptions& options)
+ MLDB_Full_Descriptor_Invoker(std::vector<KeyPoint>& kpts, Mat& desc, std::vector<Evolution>& evolution, AKAZEOptions& options)
: keypoints_(&kpts)
, descriptors_(&desc)
, evolution_(&evolution)
@@ -643,12 +1047,11 @@ public:
{
for (int i = range.start; i < range.end; i++)
{
- AKAZEFeatures::Compute_Main_Orientation((*keypoints_)[i], *evolution_);
- Get_MLDB_Full_Descriptor((*keypoints_)[i], descriptors_->ptr<unsigned char>(i));
+ Get_MLDB_Full_Descriptor((*keypoints_)[i], descriptors_->ptr<unsigned char>(i), descriptors_->cols);
}
}
- void Get_MLDB_Full_Descriptor(const KeyPoint& kpt, unsigned char* desc) const;
+ void Get_MLDB_Full_Descriptor(const KeyPoint& kpt, unsigned char* desc, int desc_size) const;
void MLDB_Fill_Values(float* values, int sample_step, int level,
float xf, float yf, float co, float si, float scale) const;
void MLDB_Binary_Comparisons(float* values, unsigned char* desc,
@@ -657,7 +1060,7 @@ public:
private:
std::vector<KeyPoint>* keypoints_;
Mat* descriptors_;
- std::vector<TEvolution>* evolution_;
+ std::vector<Evolution>* evolution_;
AKAZEOptions* options_;
};
@@ -666,7 +1069,7 @@ class MLDB_Descriptor_Subset_Invoker : public ParallelLoopBody
public:
MLDB_Descriptor_Subset_Invoker(std::vector<KeyPoint>& kpts,
Mat& desc,
- std::vector<TEvolution>& evolution,
+ std::vector<Evolution>& evolution,
AKAZEOptions& options,
Mat descriptorSamples,
Mat descriptorBits)
@@ -683,17 +1086,16 @@ public:
{
for (int i = range.start; i < range.end; i++)
{
- AKAZEFeatures::Compute_Main_Orientation((*keypoints_)[i], *evolution_);
- Get_MLDB_Descriptor_Subset((*keypoints_)[i], descriptors_->ptr<unsigned char>(i));
+ Get_MLDB_Descriptor_Subset((*keypoints_)[i], descriptors_->ptr<unsigned char>(i), descriptors_->cols);
}
}
- void Get_MLDB_Descriptor_Subset(const KeyPoint& kpt, unsigned char* desc) const;
+ void Get_MLDB_Descriptor_Subset(const KeyPoint& kpt, unsigned char* desc, int desc_size) const;
private:
std::vector<KeyPoint>* keypoints_;
Mat* descriptors_;
- std::vector<TEvolution>* evolution_;
+ std::vector<Evolution>* evolution_;
AKAZEOptions* options_;
Mat descriptorSamples_; // List of positions in the grids to sample LDB bits from.
@@ -705,28 +1107,29 @@ private:
* @param kpts Vector of detected keypoints
* @param desc Matrix to store the descriptors
*/
-void AKAZEFeatures::Compute_Descriptors(std::vector<KeyPoint>& kpts, Mat& desc)
+void AKAZEFeatures::Compute_Descriptors(std::vector<KeyPoint>& kpts, OutputArray descriptors)
{
+ CV_INSTRUMENT_REGION()
+
for(size_t i = 0; i < kpts.size(); i++)
{
CV_Assert(0 <= kpts[i].class_id && kpts[i].class_id < static_cast<int>(evolution_.size()));
}
// Allocate memory for the matrix with the descriptors
- if (options_.descriptor < AKAZE::DESCRIPTOR_MLDB_UPRIGHT) {
- desc = Mat::zeros((int)kpts.size(), 64, CV_32FC1);
- }
- else {
- // We use the full length binary descriptor -> 486 bits
- if (options_.descriptor_size == 0) {
- int t = (6 + 36 + 120)*options_.descriptor_channels;
- desc = Mat::zeros((int)kpts.size(), (int)ceil(t / 8.), CV_8UC1);
- }
- else {
- // We use the random bit selection length binary descriptor
- desc = Mat::zeros((int)kpts.size(), (int)ceil(options_.descriptor_size / 8.), CV_8UC1);
- }
+ int descriptor_size = 64;
+ int descriptor_type = CV_32FC1;
+ if (options_.descriptor >= AKAZE::DESCRIPTOR_MLDB_UPRIGHT)
+ {
+ int descriptor_bits = (options_.descriptor_size == 0)
+ ? (6 + 36 + 120)*options_.descriptor_channels // the full length binary descriptor -> 486 bits
+ : options_.descriptor_size; // the random bit selection length binary descriptor
+ descriptor_size = divUp(descriptor_bits, 8);
+ descriptor_type = CV_8UC1;
}
+ descriptors.create((int)kpts.size(), descriptor_size, descriptor_type);
+
+ Mat desc = descriptors.getMat();
switch (options_.descriptor)
{
@@ -761,12 +1164,20 @@ void AKAZEFeatures::Compute_Descriptors(std::vector<KeyPoint>& kpts, Mat& desc)
/* ************************************************************************* */
/**
- * @brief This method computes the main orientation for a given keypoint
- * @param kpt Input keypoint
- * @note The orientation is computed using a similar approach as described in the
- * original SURF method. See Bay et al., Speeded Up Robust Features, ECCV 2006
+ * @brief This function samples the derivative responses Lx and Ly for the points
+ * within the radius of 6*scale from (x0, y0), then multiply 2D Gaussian weight
+ * @param Lx Horizontal derivative
+ * @param Ly Vertical derivative
+ * @param x0 X-coordinate of the center point
+ * @param y0 Y-coordinate of the center point
+ * @param scale The sampling step
+ * @param resX Output array of the weighted horizontal derivative responses
+ * @param resY Output array of the weighted vertical derivative responses
*/
-void AKAZEFeatures::Compute_Main_Orientation(KeyPoint& kpt, const std::vector<TEvolution>& evolution_)
+static inline
+void Sample_Derivative_Response_Radius6(const Mat &Lx, const Mat &Ly,
+ const int x0, const int y0, const int scale,
+ float *resX, float *resY)
{
/* ************************************************************************* */
/// Lookup table for 2d gaussian (sigma = 2.5) where (0,0) is top left and (6,6) is bottom right
@@ -780,79 +1191,208 @@ void AKAZEFeatures::Compute_Main_Orientation(KeyPoint& kpt, const std::vector<TE
{ 0.00344629f, 0.00318132f, 0.00250252f, 0.00167749f, 0.00095820f, 0.00046640f, 0.00019346f },
{ 0.00142946f, 0.00131956f, 0.00103800f, 0.00069579f, 0.00039744f, 0.00019346f, 0.00008024f }
};
+ static const struct gtable
+ {
+ float weight[109];
+ int xidx[109];
+ int yidx[109];
- int ix = 0, iy = 0, idx = 0, s = 0, level = 0;
- float xf = 0.0, yf = 0.0, gweight = 0.0, ratio = 0.0;
- const int ang_size = 109;
- float resX[ang_size], resY[ang_size], Ang[ang_size];
- const int id[] = { 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6 };
+ explicit gtable(void)
+ {
+ // Generate the weight and indices by one-time initialization
+ int k = 0;
+ for (int i = -6; i <= 6; ++i) {
+ for (int j = -6; j <= 6; ++j) {
+ if (i*i + j*j < 36) {
+ CV_Assert(k < 109);
+ weight[k] = gauss25[abs(i)][abs(j)];
+ yidx[k] = i;
+ xidx[k] = j;
+ ++k;
+ }
+ }
+ }
+ }
+ } g;
- // Variables for computing the dominant direction
- float sumX = 0.0, sumY = 0.0, max = 0.0, ang1 = 0.0, ang2 = 0.0;
+ CV_Assert(x0 - 6 * scale >= 0 && x0 + 6 * scale < Lx.cols);
+ CV_Assert(y0 - 6 * scale >= 0 && y0 + 6 * scale < Lx.rows);
+ for (int i = 0; i < 109; i++)
+ {
+ int y = y0 + g.yidx[i] * scale;
+ int x = x0 + g.xidx[i] * scale;
+
+ float w = g.weight[i];
+ resX[i] = w * Lx.at<float>(y, x);
+ resY[i] = w * Ly.at<float>(y, x);
+ }
+}
+
+/**
+ * @brief This function sorts a[] by quantized float values
+ * @param a[] Input floating point array to sort
+ * @param n The length of a[]
+ * @param quantum The interval to convert a[i]'s float values to integers
+ * @param nkeys a[i] < nkeys * quantum
+ * @param idx[] Output array of the indices: a[idx[i]] forms a sorted array
+ * @param cum[] Output array of the starting indices of quantized floats
+ * @note The values of a[] in [k*quantum, (k + 1)*quantum) is labeled by
+ * the integer k, which is calculated by floor(a[i]/quantum). After sorting,
+ * the values from a[idx[cum[k]]] to a[idx[cum[k+1]-1]] are all labeled by k.
+ * This sorting is unstable to reduce the memory access.
+ */
+static inline
+void quantized_counting_sort(const float a[], const int n,
+ const float quantum, const int nkeys,
+ int idx[/*n*/], int cum[/*nkeys + 1*/])
+{
+ memset(cum, 0, sizeof(cum[0]) * (nkeys + 1));
+
+ // Count up the quantized values
+ for (int i = 0; i < n; i++)
+ {
+ int b = (int)(a[i] / quantum);
+ if (b < 0 || b >= nkeys)
+ b = 0;
+ cum[b]++;
+ }
+
+ // Compute the inclusive prefix sum i.e. the end indices; cum[nkeys] is the total
+ for (int i = 1; i <= nkeys; i++)
+ {
+ cum[i] += cum[i - 1];
+ }
+ CV_Assert(cum[nkeys] == n);
+
+ // Generate the sorted indices; cum[] becomes the exclusive prefix sum i.e. the start indices of keys
+ for (int i = 0; i < n; i++)
+ {
+ int b = (int)(a[i] / quantum);
+ if (b < 0 || b >= nkeys)
+ b = 0;
+ idx[--cum[b]] = i;
+ }
+}
+
+/**
+ * @brief This function computes the main orientation for a given keypoint
+ * @param kpt Input keypoint
+ * @note The orientation is computed using a similar approach as described in the
+ * original SURF method. See Bay et al., Speeded Up Robust Features, ECCV 2006
+ */
+static inline
+void Compute_Main_Orientation(KeyPoint& kpt, const std::vector<Evolution>& evolution)
+{
+ // get the right evolution level for this keypoint
+ const Evolution& e = evolution[kpt.class_id];
// Get the information from the keypoint
- level = kpt.class_id;
- ratio = (float)(1 << evolution_[level].octave);
- s = fRound(0.5f*kpt.size / ratio);
- xf = kpt.pt.x / ratio;
- yf = kpt.pt.y / ratio;
+ int scale = cvRound(0.5f * kpt.size / e.octave_ratio);
+ int x0 = cvRound(kpt.pt.x / e.octave_ratio);
+ int y0 = cvRound(kpt.pt.y / e.octave_ratio);
+
+ // Sample derivatives responses for the points within radius of 6*scale
+ const int ang_size = 109;
+ float resX[ang_size], resY[ang_size];
+ Sample_Derivative_Response_Radius6(e.Lx, e.Ly, x0, y0, scale, resX, resY);
+
+ // Compute the angle of each gradient vector
+ float Ang[ang_size];
+ hal::fastAtan2(resY, resX, Ang, ang_size, false);
+
+ // Sort by the angles; angles are labeled by slices of 0.15 radian
+ const int slices = 42;
+ const float ang_step = (float)(2.0 * CV_PI / slices);
+ int slice[slices + 1];
+ int sorted_idx[ang_size];
+ quantized_counting_sort(Ang, ang_size, ang_step, slices, sorted_idx, slice);
+
+ // Find the main angle by sliding a window of 7-slice size(=PI/3) around the keypoint
+ const int win = 7;
+
+ float maxX = 0.0f, maxY = 0.0f;
+ for (int i = slice[0]; i < slice[win]; i++) {
+ const int idx = sorted_idx[i];
+ maxX += resX[idx];
+ maxY += resY[idx];
+ }
+ float maxNorm = maxX * maxX + maxY * maxY;
- // Calculate derivatives responses for points within radius of 6*scale
- for (int i = -6; i <= 6; ++i) {
- for (int j = -6; j <= 6; ++j) {
- if (i*i + j*j < 36) {
- iy = fRound(yf + j*s);
- ix = fRound(xf + i*s);
+ for (int sn = 1; sn <= slices - win; sn++) {
- gweight = gauss25[id[i + 6]][id[j + 6]];
- resX[idx] = gweight*(*(evolution_[level].Lx.ptr<float>(iy)+ix));
- resY[idx] = gweight*(*(evolution_[level].Ly.ptr<float>(iy)+ix));
+ if (slice[sn] == slice[sn - 1] && slice[sn + win] == slice[sn + win - 1])
+ continue; // The contents of the window didn't change; don't repeat the computation
- ++idx;
- }
+ float sumX = 0.0f, sumY = 0.0f;
+ for (int i = slice[sn]; i < slice[sn + win]; i++) {
+ const int idx = sorted_idx[i];
+ sumX += resX[idx];
+ sumY += resY[idx];
}
+
+ float norm = sumX * sumX + sumY * sumY;
+ if (norm > maxNorm)
+ maxNorm = norm, maxX = sumX, maxY = sumY; // Found bigger one; update
}
- hal::fastAtan32f(resY, resX, Ang, ang_size, false);
- // Loop slides pi/3 window around feature point
- for (ang1 = 0; ang1 < (float)(2.0 * CV_PI); ang1 += 0.15f) {
- ang2 = (ang1 + (float)(CV_PI / 3.0) >(float)(2.0*CV_PI) ? ang1 - (float)(5.0*CV_PI / 3.0) : ang1 + (float)(CV_PI / 3.0));
- sumX = sumY = 0.f;
-
- for (int k = 0; k < ang_size; ++k) {
- // Get angle from the x-axis of the sample point
- const float & ang = Ang[k];
-
- // Determine whether the point is within the window
- if (ang1 < ang2 && ang1 < ang && ang < ang2) {
- sumX += resX[k];
- sumY += resY[k];
- }
- else if (ang2 < ang1 &&
- ((ang > 0 && ang < ang2) || (ang > ang1 && ang < 2.0f*CV_PI))) {
- sumX += resX[k];
- sumY += resY[k];
- }
- }
- // if the vector produced from this window is longer than all
- // previous vectors then this forms the new dominant direction
- if (sumX*sumX + sumY*sumY > max) {
- // store largest orientation
- max = sumX*sumX + sumY*sumY;
- kpt.angle = getAngle(sumX, sumY) * 180.f / static_cast<float>(CV_PI);
+ for (int sn = slices - win + 1; sn < slices; sn++) {
+ int remain = sn + win - slices;
+
+ if (slice[sn] == slice[sn - 1] && slice[remain] == slice[remain - 1])
+ continue;
+
+ float sumX = 0.0f, sumY = 0.0f;
+ for (int i = slice[sn]; i < slice[slices]; i++) {
+ const int idx = sorted_idx[i];
+ sumX += resX[idx];
+ sumY += resY[idx];
+ }
+ for (int i = slice[0]; i < slice[remain]; i++) {
+ const int idx = sorted_idx[i];
+ sumX += resX[idx];
+ sumY += resY[idx];
}
+
+ float norm = sumX * sumX + sumY * sumY;
+ if (norm > maxNorm)
+ maxNorm = norm, maxX = sumX, maxY = sumY;
}
+
+ // Store the final result
+ kpt.angle = fastAtan2(maxY, maxX);
}
-/* ************************************************************************* */
+class ComputeKeypointOrientation : public ParallelLoopBody
+{
+public:
+ ComputeKeypointOrientation(std::vector<KeyPoint>& kpts,
+ const std::vector<Evolution>& evolution)
+ : keypoints_(&kpts)
+ , evolution_(&evolution)
+ {
+ }
+
+ void operator() (const Range& range) const
+ {
+ for (int i = range.start; i < range.end; i++)
+ {
+ Compute_Main_Orientation((*keypoints_)[i], *evolution_);
+ }
+ }
+private:
+ std::vector<KeyPoint>* keypoints_;
+ const std::vector<Evolution>* evolution_;
+};
+
/**
* @brief This method computes the main orientation for a given keypoints
* @param kpts Input keypoints
*/
void AKAZEFeatures::Compute_Keypoints_Orientation(std::vector<KeyPoint>& kpts) const
{
- for(size_t i = 0; i < kpts.size(); i++)
- Compute_Main_Orientation(kpts[i], evolution_);
+ CV_INSTRUMENT_REGION()
+
+ parallel_for_(Range(0, (int)kpts.size()), ComputeKeypointOrientation(kpts, evolution_));
}
/* ************************************************************************* */
@@ -865,7 +1405,10 @@ void AKAZEFeatures::Compute_Keypoints_Orientation(std::vector<KeyPoint>& kpts) c
* from Agrawal et al., CenSurE: Center Surround Extremas for Realtime Feature Detection and Matching,
* ECCV 2008
*/
-void MSURF_Upright_Descriptor_64_Invoker::Get_MSURF_Upright_Descriptor_64(const KeyPoint& kpt, float *desc) const {
+void MSURF_Upright_Descriptor_64_Invoker::Get_MSURF_Upright_Descriptor_64(const KeyPoint& kpt, float *desc, int desc_size) const {
+
+ const int dsize = 64;
+ CV_Assert(desc_size == dsize);
float dx = 0.0, dy = 0.0, mdx = 0.0, mdy = 0.0, gauss_s1 = 0.0, gauss_s2 = 0.0;
float rx = 0.0, ry = 0.0, len = 0.0, xf = 0.0, yf = 0.0, ys = 0.0, xs = 0.0;
@@ -873,22 +1416,23 @@ void MSURF_Upright_Descriptor_64_Invoker::Get_MSURF_Upright_Descriptor_64(const
int x1 = 0, y1 = 0, sample_step = 0, pattern_size = 0;
int x2 = 0, y2 = 0, kx = 0, ky = 0, i = 0, j = 0, dcount = 0;
float fx = 0.0, fy = 0.0, ratio = 0.0, res1 = 0.0, res2 = 0.0, res3 = 0.0, res4 = 0.0;
- int scale = 0, dsize = 0, level = 0;
+ int scale = 0;
// Subregion centers for the 4x4 gaussian weighting
float cx = -0.5f, cy = 0.5f;
- const std::vector<TEvolution>& evolution = *evolution_;
+ const std::vector<Evolution>& evolution = *evolution_;
// Set the descriptor size and the sample and pattern sizes
- dsize = 64;
sample_step = 5;
pattern_size = 12;
// Get the information from the keypoint
ratio = (float)(1 << kpt.octave);
- scale = fRound(0.5f*kpt.size / ratio);
- level = kpt.class_id;
+ scale = cvRound(0.5f*kpt.size / ratio);
+ const int level = kpt.class_id;
+ const Mat Lx = evolution[level].Lx;
+ const Mat Ly = evolution[level].Ly;
yf = kpt.pt.y / ratio;
xf = kpt.pt.x / ratio;
@@ -922,25 +1466,28 @@ void MSURF_Upright_Descriptor_64_Invoker::Get_MSURF_Upright_Descriptor_64(const
//Get the gaussian weighted x and y responses
gauss_s1 = gaussian(xs - sample_x, ys - sample_y, 2.50f*scale);
- y1 = (int)(sample_y - .5);
- x1 = (int)(sample_x - .5);
+ y1 = cvFloor(sample_y);
+ x1 = cvFloor(sample_x);
+
+ y2 = y1 + 1;
+ x2 = x1 + 1;
- y2 = (int)(sample_y + .5);
- x2 = (int)(sample_x + .5);
+ if (x1 < 0 || y1 < 0 || x2 >= Lx.cols || y2 >= Lx.rows)
+ continue; // FIXIT Boundaries
fx = sample_x - x1;
fy = sample_y - y1;
- res1 = *(evolution[level].Lx.ptr<float>(y1)+x1);
- res2 = *(evolution[level].Lx.ptr<float>(y1)+x2);
- res3 = *(evolution[level].Lx.ptr<float>(y2)+x1);
- res4 = *(evolution[level].Lx.ptr<float>(y2)+x2);
+ res1 = Lx.at<float>(y1, x1);
+ res2 = Lx.at<float>(y1, x2);
+ res3 = Lx.at<float>(y2, x1);
+ res4 = Lx.at<float>(y2, x2);
rx = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
- res1 = *(evolution[level].Ly.ptr<float>(y1)+x1);
- res2 = *(evolution[level].Ly.ptr<float>(y1)+x2);
- res3 = *(evolution[level].Ly.ptr<float>(y2)+x1);
- res4 = *(evolution[level].Ly.ptr<float>(y2)+x2);
+ res1 = Ly.at<float>(y1, x1);
+ res2 = Ly.at<float>(y1, x2);
+ res3 = Ly.at<float>(y2, x1);
+ res4 = Ly.at<float>(y2, x2);
ry = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
rx = gauss_s1*rx;
@@ -970,11 +1517,14 @@ void MSURF_Upright_Descriptor_64_Invoker::Get_MSURF_Upright_Descriptor_64(const
i += 9;
}
+ CV_Assert(dcount == desc_size);
+
// convert to unit vector
len = sqrt(len);
+ const float len_inv = 1.0f / len;
for (i = 0; i < dsize; i++) {
- desc[i] /= len;
+ desc[i] *= len_inv;
}
}
@@ -988,7 +1538,10 @@ void MSURF_Upright_Descriptor_64_Invoker::Get_MSURF_Upright_Descriptor_64(const
* from Agrawal et al., CenSurE: Center Surround Extremas for Realtime Feature Detection and Matching,
* ECCV 2008
*/
-void MSURF_Descriptor_64_Invoker::Get_MSURF_Descriptor_64(const KeyPoint& kpt, float *desc) const {
+void MSURF_Descriptor_64_Invoker::Get_MSURF_Descriptor_64(const KeyPoint& kpt, float *desc, int desc_size) const {
+
+ const int dsize = 64;
+ CV_Assert(desc_size == dsize);
float dx = 0.0, dy = 0.0, mdx = 0.0, mdy = 0.0, gauss_s1 = 0.0, gauss_s2 = 0.0;
float rx = 0.0, ry = 0.0, rrx = 0.0, rry = 0.0, len = 0.0, xf = 0.0, yf = 0.0, ys = 0.0, xs = 0.0;
@@ -996,23 +1549,24 @@ void MSURF_Descriptor_64_Invoker::Get_MSURF_Descriptor_64(const KeyPoint& kpt, f
float fx = 0.0, fy = 0.0, ratio = 0.0, res1 = 0.0, res2 = 0.0, res3 = 0.0, res4 = 0.0;
int x1 = 0, y1 = 0, x2 = 0, y2 = 0, sample_step = 0, pattern_size = 0;
int kx = 0, ky = 0, i = 0, j = 0, dcount = 0;
- int scale = 0, dsize = 0, level = 0;
+ int scale = 0;
// Subregion centers for the 4x4 gaussian weighting
float cx = -0.5f, cy = 0.5f;
- const std::vector<TEvolution>& evolution = *evolution_;
+ const std::vector<Evolution>& evolution = *evolution_;
// Set the descriptor size and the sample and pattern sizes
- dsize = 64;
sample_step = 5;
pattern_size = 12;
// Get the information from the keypoint
ratio = (float)(1 << kpt.octave);
- scale = fRound(0.5f*kpt.size / ratio);
- angle = (kpt.angle * static_cast<float>(CV_PI)) / 180.f;
- level = kpt.class_id;
+ scale = cvRound(0.5f*kpt.size / ratio);
+ angle = kpt.angle * static_cast<float>(CV_PI / 180.f);
+ const int level = kpt.class_id;
+ const Mat Lx = evolution[level].Lx;
+ const Mat Ly = evolution[level].Ly;
yf = kpt.pt.y / ratio;
xf = kpt.pt.x / ratio;
co = cos(angle);
@@ -1049,25 +1603,28 @@ void MSURF_Descriptor_64_Invoker::Get_MSURF_Descriptor_64(const KeyPoint& kpt, f
// Get the gaussian weighted x and y responses
gauss_s1 = gaussian(xs - sample_x, ys - sample_y, 2.5f*scale);
- y1 = fRound(sample_y - 0.5f);
- x1 = fRound(sample_x - 0.5f);
+ y1 = cvFloor(sample_y);
+ x1 = cvFloor(sample_x);
+
+ y2 = y1 + 1;
+ x2 = x1 + 1;
- y2 = fRound(sample_y + 0.5f);
- x2 = fRound(sample_x + 0.5f);
+ if (x1 < 0 || y1 < 0 || x2 >= Lx.cols || y2 >= Lx.rows)
+ continue; // FIXIT Boundaries
fx = sample_x - x1;
fy = sample_y - y1;
- res1 = *(evolution[level].Lx.ptr<float>(y1)+x1);
- res2 = *(evolution[level].Lx.ptr<float>(y1)+x2);
- res3 = *(evolution[level].Lx.ptr<float>(y2)+x1);
- res4 = *(evolution[level].Lx.ptr<float>(y2)+x2);
+ res1 = Lx.at<float>(y1, x1);
+ res2 = Lx.at<float>(y1, x2);
+ res3 = Lx.at<float>(y2, x1);
+ res4 = Lx.at<float>(y2, x2);
rx = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
- res1 = *(evolution[level].Ly.ptr<float>(y1)+x1);
- res2 = *(evolution[level].Ly.ptr<float>(y1)+x2);
- res3 = *(evolution[level].Ly.ptr<float>(y2)+x1);
- res4 = *(evolution[level].Ly.ptr<float>(y2)+x2);
+ res1 = Ly.at<float>(y1, x1);
+ res2 = Ly.at<float>(y1, x2);
+ res3 = Ly.at<float>(y2, x1);
+ res4 = Ly.at<float>(y2, x2);
ry = (1.0f - fx)*(1.0f - fy)*res1 + fx*(1.0f - fy)*res2 + (1.0f - fx)*fy*res3 + fx*fy*res4;
// Get the x and y derivatives on the rotated axis
@@ -1097,11 +1654,14 @@ void MSURF_Descriptor_64_Invoker::Get_MSURF_Descriptor_64(const KeyPoint& kpt, f
i += 9;
}
+ CV_Assert(dcount == desc_size);
+
// convert to unit vector
len = sqrt(len);
+ const float len_inv = 1.0f / len;
for (i = 0; i < dsize; i++) {
- desc[i] /= len;
+ desc[i] *= len_inv;
}
}
@@ -1112,244 +1672,145 @@ void MSURF_Descriptor_64_Invoker::Get_MSURF_Descriptor_64(const KeyPoint& kpt, f
* @param kpt Input keypoint
* @param desc Descriptor vector
*/
-void Upright_MLDB_Full_Descriptor_Invoker::Get_Upright_MLDB_Full_Descriptor(const KeyPoint& kpt, unsigned char *desc) const {
-
- float di = 0.0, dx = 0.0, dy = 0.0;
- float ri = 0.0, rx = 0.0, ry = 0.0, xf = 0.0, yf = 0.0;
- float sample_x = 0.0, sample_y = 0.0, ratio = 0.0;
- int x1 = 0, y1 = 0, sample_step = 0, pattern_size = 0;
- int level = 0, nsamples = 0, scale = 0;
- int dcount1 = 0, dcount2 = 0;
+void Upright_MLDB_Full_Descriptor_Invoker::Get_Upright_MLDB_Full_Descriptor(const KeyPoint& kpt, unsigned char *desc, int desc_size) const {
const AKAZEOptions & options = *options_;
- const std::vector<TEvolution>& evolution = *evolution_;
+ const std::vector<Evolution>& evolution = *evolution_;
- // Matrices for the M-LDB descriptor
- Mat values_1 = Mat::zeros(4, options.descriptor_channels, CV_32FC1);
- Mat values_2 = Mat::zeros(9, options.descriptor_channels, CV_32FC1);
- Mat values_3 = Mat::zeros(16, options.descriptor_channels, CV_32FC1);
+ // Buffer for the M-LDB descriptor
+ const int max_channels = 3;
+ CV_Assert(options.descriptor_channels <= max_channels);
+ float values[16*max_channels];
// Get the information from the keypoint
- ratio = (float)(1 << kpt.octave);
- scale = fRound(0.5f*kpt.size / ratio);
- level = kpt.class_id;
- yf = kpt.pt.y / ratio;
- xf = kpt.pt.x / ratio;
-
- // First 2x2 grid
- pattern_size = options_->descriptor_pattern_size;
- sample_step = pattern_size;
-
- for (int i = -pattern_size; i < pattern_size; i += sample_step) {
- for (int j = -pattern_size; j < pattern_size; j += sample_step) {
- di = dx = dy = 0.0;
- nsamples = 0;
-
- for (int k = i; k < i + sample_step; k++) {
- for (int l = j; l < j + sample_step; l++) {
-
- // Get the coordinates of the sample point
- sample_y = yf + l*scale;
- sample_x = xf + k*scale;
-
- y1 = fRound(sample_y);
- x1 = fRound(sample_x);
-
- ri = *(evolution[level].Lt.ptr<float>(y1)+x1);
- rx = *(evolution[level].Lx.ptr<float>(y1)+x1);
- ry = *(evolution[level].Ly.ptr<float>(y1)+x1);
-
- di += ri;
- dx += rx;
- dy += ry;
- nsamples++;
+ const float ratio = (float)(1 << kpt.octave);
+ const int scale = cvRound(0.5f*kpt.size / ratio);
+ const int level = kpt.class_id;
+ const Mat Lx = evolution[level].Lx;
+ const Mat Ly = evolution[level].Ly;
+ const Mat Lt = evolution[level].Lt;
+ const float yf = kpt.pt.y / ratio;
+ const float xf = kpt.pt.x / ratio;
+
+ // For 2x2 grid, 3x3 grid and 4x4 grid
+ const int pattern_size = options_->descriptor_pattern_size;
+ CV_Assert((pattern_size & 1) == 0);
+ const int sample_step[3] = {
+ pattern_size,
+ divUp(pattern_size * 2, 3),
+ divUp(pattern_size, 2)
+ };
+
+ memset(desc, 0, desc_size);
+
+ // For the three grids
+ int dcount1 = 0;
+ for (int z = 0; z < 3; z++) {
+ int dcount2 = 0;
+ const int step = sample_step[z];
+ for (int i = -pattern_size; i < pattern_size; i += step) {
+ for (int j = -pattern_size; j < pattern_size; j += step) {
+ float di = 0.0, dx = 0.0, dy = 0.0;
+
+ int nsamples = 0;
+ for (int k = 0; k < step; k++) {
+ for (int l = 0; l < step; l++) {
+
+ // Get the coordinates of the sample point
+ const float sample_y = yf + (l+j)*scale;
+ const float sample_x = xf + (k+i)*scale;
+
+ const int y1 = cvRound(sample_y);
+ const int x1 = cvRound(sample_x);
+
+ if (y1 < 0 || y1 >= Lt.rows || x1 < 0 || x1 >= Lt.cols)
+ continue; // Boundaries
+
+ const float ri = Lt.at<float>(y1, x1);
+ const float rx = Lx.at<float>(y1, x1);
+ const float ry = Ly.at<float>(y1, x1);
+
+ di += ri;
+ dx += rx;
+ dy += ry;
+ nsamples++;
+ }
}
- }
-
- di /= nsamples;
- dx /= nsamples;
- dy /= nsamples;
-
- *(values_1.ptr<float>(dcount2)) = di;
- *(values_1.ptr<float>(dcount2)+1) = dx;
- *(values_1.ptr<float>(dcount2)+2) = dy;
- dcount2++;
- }
- }
-
- // Do binary comparison first level
- for (int i = 0; i < 4; i++) {
- for (int j = i + 1; j < 4; j++) {
- if (*(values_1.ptr<float>(i)) > *(values_1.ptr<float>(j))) {
- desc[dcount1 / 8] |= (1 << (dcount1 % 8));
- }
- dcount1++;
-
- if (*(values_1.ptr<float>(i)+1) > *(values_1.ptr<float>(j)+1)) {
- desc[dcount1 / 8] |= (1 << (dcount1 % 8));
- }
- dcount1++;
-
- if (*(values_1.ptr<float>(i)+2) > *(values_1.ptr<float>(j)+2)) {
- desc[dcount1 / 8] |= (1 << (dcount1 % 8));
- }
- dcount1++;
- }
- }
-
- // Second 3x3 grid
- sample_step = static_cast<int>(ceil(pattern_size*2. / 3.));
- dcount2 = 0;
- for (int i = -pattern_size; i < pattern_size; i += sample_step) {
- for (int j = -pattern_size; j < pattern_size; j += sample_step) {
- di = dx = dy = 0.0;
- nsamples = 0;
-
- for (int k = i; k < i + sample_step; k++) {
- for (int l = j; l < j + sample_step; l++) {
-
- // Get the coordinates of the sample point
- sample_y = yf + l*scale;
- sample_x = xf + k*scale;
-
- y1 = fRound(sample_y);
- x1 = fRound(sample_x);
-
- ri = *(evolution[level].Lt.ptr<float>(y1)+x1);
- rx = *(evolution[level].Lx.ptr<float>(y1)+x1);
- ry = *(evolution[level].Ly.ptr<float>(y1)+x1);
-
- di += ri;
- dx += rx;
- dy += ry;
- nsamples++;
+ if (nsamples > 0)
+ {
+ const float nsamples_inv = 1.0f / nsamples;
+ di *= nsamples_inv;
+ dx *= nsamples_inv;
+ dy *= nsamples_inv;
}
- }
-
- di /= nsamples;
- dx /= nsamples;
- dy /= nsamples;
-
- *(values_2.ptr<float>(dcount2)) = di;
- *(values_2.ptr<float>(dcount2)+1) = dx;
- *(values_2.ptr<float>(dcount2)+2) = dy;
- dcount2++;
- }
- }
- //Do binary comparison second level
- dcount2 = 0;
- for (int i = 0; i < 9; i++) {
- for (int j = i + 1; j < 9; j++) {
- if (*(values_2.ptr<float>(i)) > *(values_2.ptr<float>(j))) {
- desc[dcount1 / 8] |= (1 << (dcount1 % 8));
+ float *val = &values[dcount2*max_channels];
+ *(val) = di;
+ *(val+1) = dx;
+ *(val+2) = dy;
+ dcount2++;
}
- dcount1++;
-
- if (*(values_2.ptr<float>(i)+1) > *(values_2.ptr<float>(j)+1)) {
- desc[dcount1 / 8] |= (1 << (dcount1 % 8));
- }
- dcount1++;
-
- if (*(values_2.ptr<float>(i)+2) > *(values_2.ptr<float>(j)+2)) {
- desc[dcount1 / 8] |= (1 << (dcount1 % 8));
- }
- dcount1++;
}
- }
- // Third 4x4 grid
- sample_step = pattern_size / 2;
- dcount2 = 0;
-
- for (int i = -pattern_size; i < pattern_size; i += sample_step) {
- for (int j = -pattern_size; j < pattern_size; j += sample_step) {
- di = dx = dy = 0.0;
- nsamples = 0;
-
- for (int k = i; k < i + sample_step; k++) {
- for (int l = j; l < j + sample_step; l++) {
-
- // Get the coordinates of the sample point
- sample_y = yf + l*scale;
- sample_x = xf + k*scale;
-
- y1 = fRound(sample_y);
- x1 = fRound(sample_x);
-
- ri = *(evolution[level].Lt.ptr<float>(y1)+x1);
- rx = *(evolution[level].Lx.ptr<float>(y1)+x1);
- ry = *(evolution[level].Ly.ptr<float>(y1)+x1);
-
- di += ri;
- dx += rx;
- dy += ry;
- nsamples++;
+ // Do binary comparison
+ const int num = (z + 2) * (z + 2);
+ for (int i = 0; i < num; i++) {
+ for (int j = i + 1; j < num; j++) {
+ const float * valI = &values[i*max_channels];
+ const float * valJ = &values[j*max_channels];
+ for (int k = 0; k < 3; ++k) {
+ if (*(valI + k) > *(valJ + k)) {
+ desc[dcount1 / 8] |= (1 << (dcount1 % 8));
+ }
+ dcount1++;
}
}
-
- di /= nsamples;
- dx /= nsamples;
- dy /= nsamples;
-
- *(values_3.ptr<float>(dcount2)) = di;
- *(values_3.ptr<float>(dcount2)+1) = dx;
- *(values_3.ptr<float>(dcount2)+2) = dy;
- dcount2++;
}
- }
- //Do binary comparison third level
- dcount2 = 0;
- for (int i = 0; i < 16; i++) {
- for (int j = i + 1; j < 16; j++) {
- if (*(values_3.ptr<float>(i)) > *(values_3.ptr<float>(j))) {
- desc[dcount1 / 8] |= (1 << (dcount1 % 8));
- }
- dcount1++;
-
- if (*(values_3.ptr<float>(i)+1) > *(values_3.ptr<float>(j)+1)) {
- desc[dcount1 / 8] |= (1 << (dcount1 % 8));
- }
- dcount1++;
+ } // for (int z = 0; z < 3; z++)
- if (*(values_3.ptr<float>(i)+2) > *(values_3.ptr<float>(j)+2)) {
- desc[dcount1 / 8] |= (1 << (dcount1 % 8));
- }
- dcount1++;
- }
- }
+ CV_Assert(dcount1 <= desc_size*8);
+ CV_Assert(divUp(dcount1, 8) == desc_size);
}
-void MLDB_Full_Descriptor_Invoker::MLDB_Fill_Values(float* values, int sample_step, int level,
+void MLDB_Full_Descriptor_Invoker::MLDB_Fill_Values(float* values, int sample_step, const int level,
float xf, float yf, float co, float si, float scale) const
{
- const std::vector<TEvolution>& evolution = *evolution_;
+ const std::vector<Evolution>& evolution = *evolution_;
int pattern_size = options_->descriptor_pattern_size;
int chan = options_->descriptor_channels;
- int valpos = 0;
+ const Mat Lx = evolution[level].Lx;
+ const Mat Ly = evolution[level].Ly;
+ const Mat Lt = evolution[level].Lt;
+
+ const Size size = Lt.size();
+ CV_Assert(size == Lx.size());
+ CV_Assert(size == Ly.size());
+ int valpos = 0;
for (int i = -pattern_size; i < pattern_size; i += sample_step) {
for (int j = -pattern_size; j < pattern_size; j += sample_step) {
- float di, dx, dy;
- di = dx = dy = 0.0;
- int nsamples = 0;
+ float di = 0.0f, dx = 0.0f, dy = 0.0f;
+ int nsamples = 0;
for (int k = i; k < i + sample_step; k++) {
for (int l = j; l < j + sample_step; l++) {
float sample_y = yf + (l*co * scale + k*si*scale);
float sample_x = xf + (-l*si * scale + k*co*scale);
- int y1 = fRound(sample_y);
- int x1 = fRound(sample_x);
+ int y1 = cvRound(sample_y);
+ int x1 = cvRound(sample_x);
- float ri = *(evolution[level].Lt.ptr<float>(y1)+x1);
+ if (y1 < 0 || y1 >= Lt.rows || x1 < 0 || x1 >= Lt.cols)
+ continue; // Boundaries
+
+ float ri = Lt.at<float>(y1, x1);
di += ri;
if(chan > 1) {
- float rx = *(evolution[level].Lx.ptr<float>(y1)+x1);
- float ry = *(evolution[level].Ly.ptr<float>(y1)+x1);
+ float rx = Lx.at<float>(y1, x1);
+ float ry = Ly.at<float>(y1, x1);
if (chan == 2) {
dx += sqrtf(rx*rx + ry*ry);
}
@@ -1363,20 +1824,25 @@ void MLDB_Full_Descriptor_Invoker::MLDB_Fill_Values(float* values, int sample_st
nsamples++;
}
}
- di /= nsamples;
- dx /= nsamples;
- dy /= nsamples;
+
+ if (nsamples > 0)
+ {
+ const float nsamples_inv = 1.0f / nsamples;
+ di *= nsamples_inv;
+ dx *= nsamples_inv;
+ dy *= nsamples_inv;
+ }
values[valpos] = di;
if (chan > 1) {
values[valpos + 1] = dx;
}
if (chan > 2) {
- values[valpos + 2] = dy;
+ values[valpos + 2] = dy;
}
valpos += chan;
- }
}
+ }
}
void MLDB_Full_Descriptor_Invoker::MLDB_Binary_Comparisons(float* values, unsigned char* desc,
@@ -1391,8 +1857,9 @@ void MLDB_Full_Descriptor_Invoker::MLDB_Binary_Comparisons(float* values, unsign
for (int i = 0; i < count; i++) {
int ival = ivalues[chan * i + pos];
for (int j = i + 1; j < count; j++) {
- int res = ival > ivalues[chan * j + pos];
- desc[dpos >> 3] |= (res << (dpos & 7));
+ if (ival > ivalues[chan * j + pos]) {
+ desc[dpos >> 3] |= (1 << (dpos & 7));
+ }
dpos++;
}
}
@@ -1406,30 +1873,41 @@ void MLDB_Full_Descriptor_Invoker::MLDB_Binary_Comparisons(float* values, unsign
* @param kpt Input keypoint
* @param desc Descriptor vector
*/
-void MLDB_Full_Descriptor_Invoker::Get_MLDB_Full_Descriptor(const KeyPoint& kpt, unsigned char *desc) const {
+void MLDB_Full_Descriptor_Invoker::Get_MLDB_Full_Descriptor(const KeyPoint& kpt, unsigned char *desc, int desc_size) const {
const int max_channels = 3;
CV_Assert(options_->descriptor_channels <= max_channels);
+ const int pattern_size = options_->descriptor_pattern_size;
+
float values[16*max_channels];
- const double size_mult[3] = {1, 2.0/3.0, 1.0/2.0};
+ CV_Assert((pattern_size & 1) == 0);
+ //const double size_mult[3] = {1, 2.0/3.0, 1.0/2.0};
+ const int sample_step[3] = { // static_cast<int>(ceil(pattern_size * size_mult[lvl]))
+ pattern_size,
+ divUp(pattern_size * 2, 3),
+ divUp(pattern_size, 2)
+ };
float ratio = (float)(1 << kpt.octave);
- float scale = (float)fRound(0.5f*kpt.size / ratio);
+ float scale = (float)cvRound(0.5f*kpt.size / ratio);
float xf = kpt.pt.x / ratio;
float yf = kpt.pt.y / ratio;
- float angle = (kpt.angle * static_cast<float>(CV_PI)) / 180.f;
+ float angle = kpt.angle * static_cast<float>(CV_PI / 180.f);
float co = cos(angle);
float si = sin(angle);
- int pattern_size = options_->descriptor_pattern_size;
- int dpos = 0;
- for(int lvl = 0; lvl < 3; lvl++) {
+ memset(desc, 0, desc_size);
+ int dpos = 0;
+ for(int lvl = 0; lvl < 3; lvl++)
+ {
int val_count = (lvl + 2) * (lvl + 2);
- int sample_step = static_cast<int>(ceil(pattern_size * size_mult[lvl]));
- MLDB_Fill_Values(values, sample_step, kpt.class_id, xf, yf, co, si, scale);
+ MLDB_Fill_Values(values, sample_step[lvl], kpt.class_id, xf, yf, co, si, scale);
MLDB_Binary_Comparisons(values, desc, val_count, dpos);
}
+
+ CV_Assert(dpos == 486);
+ CV_Assert(divUp(dpos, 8) == desc_size);
}
/* ************************************************************************* */
@@ -1440,41 +1918,48 @@ void MLDB_Full_Descriptor_Invoker::Get_MLDB_Full_Descriptor(const KeyPoint& kpt,
* @param kpt Input keypoint
* @param desc Descriptor vector
*/
-void MLDB_Descriptor_Subset_Invoker::Get_MLDB_Descriptor_Subset(const KeyPoint& kpt, unsigned char *desc) const {
+void MLDB_Descriptor_Subset_Invoker::Get_MLDB_Descriptor_Subset(const KeyPoint& kpt, unsigned char *desc, int desc_size) const {
- float di = 0.f, dx = 0.f, dy = 0.f;
float rx = 0.f, ry = 0.f;
float sample_x = 0.f, sample_y = 0.f;
- int x1 = 0, y1 = 0;
const AKAZEOptions & options = *options_;
- const std::vector<TEvolution>& evolution = *evolution_;
+ const std::vector<Evolution>& evolution = *evolution_;
// Get the information from the keypoint
float ratio = (float)(1 << kpt.octave);
- int scale = fRound(0.5f*kpt.size / ratio);
- float angle = (kpt.angle * static_cast<float>(CV_PI)) / 180.f;
- int level = kpt.class_id;
+ int scale = cvRound(0.5f*kpt.size / ratio);
+ float angle = kpt.angle * static_cast<float>(CV_PI / 180.f);
+ const int level = kpt.class_id;
+ const Mat Lx = evolution[level].Lx;
+ const Mat Ly = evolution[level].Ly;
+ const Mat Lt = evolution[level].Lt;
float yf = kpt.pt.y / ratio;
float xf = kpt.pt.x / ratio;
float co = cos(angle);
float si = sin(angle);
// Allocate memory for the matrix of values
- Mat values = Mat_<float>::zeros((4 + 9 + 16)*options.descriptor_channels, 1);
+ // Buffer for the M-LDB descriptor
+ const int max_channels = 3;
+ const int channels = options.descriptor_channels;
+ CV_Assert(channels <= max_channels);
+ float values[(4 + 9 + 16)*max_channels] = { 0 };
// Sample everything, but only do the comparisons
- vector<int> steps(3);
- steps.at(0) = options.descriptor_pattern_size;
- steps.at(1) = (int)ceil(2.f*options.descriptor_pattern_size / 3.f);
- steps.at(2) = options.descriptor_pattern_size / 2;
+ const int pattern_size = options.descriptor_pattern_size;
+ CV_Assert((pattern_size & 1) == 0);
+ const int sample_steps[3] = {
+ pattern_size,
+ divUp(pattern_size * 2, 3),
+ divUp(pattern_size, 2)
+ };
for (int i = 0; i < descriptorSamples_.rows; i++) {
const int *coords = descriptorSamples_.ptr<int>(i);
- int sample_step = steps.at(coords[0]);
- di = 0.0f;
- dx = 0.0f;
- dy = 0.0f;
+ CV_Assert(coords[0] >= 0 && coords[0] < 3);
+ const int sample_step = sample_steps[coords[0]];
+ float di = 0.f, dx = 0.f, dy = 0.f;
for (int k = coords[1]; k < coords[1] + sample_step; k++) {
for (int l = coords[2]; l < coords[2] + sample_step; l++) {
@@ -1483,14 +1968,17 @@ void MLDB_Descriptor_Subset_Invoker::Get_MLDB_Descriptor_Subset(const KeyPoint&
sample_y = yf + (l*scale*co + k*scale*si);
sample_x = xf + (-l*scale*si + k*scale*co);
- y1 = fRound(sample_y);
- x1 = fRound(sample_x);
+ const int y1 = cvRound(sample_y);
+ const int x1 = cvRound(sample_x);
+
+ if (x1 < 0 || y1 < 0 || x1 >= Lt.cols || y1 >= Lt.rows)
+ continue; // Boundaries
- di += *(evolution[level].Lt.ptr<float>(y1)+x1);
+ di += Lt.at<float>(y1, x1);
if (options.descriptor_channels > 1) {
- rx = *(evolution[level].Lx.ptr<float>(y1)+x1);
- ry = *(evolution[level].Ly.ptr<float>(y1)+x1);
+ rx = Lx.at<float>(y1, x1);
+ ry = Ly.at<float>(y1, x1);
if (options.descriptor_channels == 2) {
dx += sqrtf(rx*rx + ry*ry);
@@ -1504,23 +1992,26 @@ void MLDB_Descriptor_Subset_Invoker::Get_MLDB_Descriptor_Subset(const KeyPoint&
}
}
- *(values.ptr<float>(options.descriptor_channels*i)) = di;
+ float* pValues = &values[channels * i];
+ pValues[0] = di;
- if (options.descriptor_channels == 2) {
- *(values.ptr<float>(options.descriptor_channels*i + 1)) = dx;
+ if (channels == 2) {
+ pValues[1] = dx;
}
- else if (options.descriptor_channels == 3) {
- *(values.ptr<float>(options.descriptor_channels*i + 1)) = dx;
- *(values.ptr<float>(options.descriptor_channels*i + 2)) = dy;
+ else if (channels == 3) {
+ pValues[1] = dx;
+ pValues[2] = dy;
}
}
// Do the comparisons
- const float *vals = values.ptr<float>(0);
const int *comps = descriptorBits_.ptr<int>(0);
+ CV_Assert(divUp(descriptorBits_.rows, 8) == desc_size);
+ memset(desc, 0, desc_size);
+
for (int i = 0; i<descriptorBits_.rows; i++) {
- if (vals[comps[2 * i]] > vals[comps[2 * i + 1]]) {
+ if (values[comps[2 * i]] > values[comps[2 * i + 1]]) {
desc[i / 8] |= (1 << (i % 8));
}
}
@@ -1534,7 +2025,7 @@ void MLDB_Descriptor_Subset_Invoker::Get_MLDB_Descriptor_Subset(const KeyPoint&
* @param kpt Input keypoint
* @param desc Descriptor vector
*/
-void Upright_MLDB_Descriptor_Subset_Invoker::Get_Upright_MLDB_Descriptor_Subset(const KeyPoint& kpt, unsigned char *desc) const {
+void Upright_MLDB_Descriptor_Subset_Invoker::Get_Upright_MLDB_Descriptor_Subset(const KeyPoint& kpt, unsigned char *desc, int desc_size) const {
float di = 0.0f, dx = 0.0f, dy = 0.0f;
float rx = 0.0f, ry = 0.0f;
@@ -1542,26 +2033,36 @@ void Upright_MLDB_Descriptor_Subset_Invoker::Get_Upright_MLDB_Descriptor_Subset(
int x1 = 0, y1 = 0;
const AKAZEOptions & options = *options_;
- const std::vector<TEvolution>& evolution = *evolution_;
+ const std::vector<Evolution>& evolution = *evolution_;
// Get the information from the keypoint
float ratio = (float)(1 << kpt.octave);
- int scale = fRound(0.5f*kpt.size / ratio);
- int level = kpt.class_id;
+ int scale = cvRound(0.5f*kpt.size / ratio);
+ const int level = kpt.class_id;
+ const Mat Lx = evolution[level].Lx;
+ const Mat Ly = evolution[level].Ly;
+ const Mat Lt = evolution[level].Lt;
float yf = kpt.pt.y / ratio;
float xf = kpt.pt.x / ratio;
// Allocate memory for the matrix of values
- Mat values = Mat_<float>::zeros((4 + 9 + 16)*options.descriptor_channels, 1);
-
- vector<int> steps(3);
- steps.at(0) = options.descriptor_pattern_size;
- steps.at(1) = static_cast<int>(ceil(2.f*options.descriptor_pattern_size / 3.f));
- steps.at(2) = options.descriptor_pattern_size / 2;
+ const int max_channels = 3;
+ const int channels = options.descriptor_channels;
+ CV_Assert(channels <= max_channels);
+ float values[(4 + 9 + 16)*max_channels] = { 0 };
+
+ const int pattern_size = options.descriptor_pattern_size;
+ CV_Assert((pattern_size & 1) == 0);
+ const int sample_steps[3] = {
+ pattern_size,
+ divUp(pattern_size * 2, 3),
+ divUp(pattern_size, 2)
+ };
for (int i = 0; i < descriptorSamples_.rows; i++) {
const int *coords = descriptorSamples_.ptr<int>(i);
- int sample_step = steps.at(coords[0]);
+ CV_Assert(coords[0] >= 0 && coords[0] < 3);
+ int sample_step = sample_steps[coords[0]];
di = 0.0f, dx = 0.0f, dy = 0.0f;
for (int k = coords[1]; k < coords[1] + sample_step; k++) {
@@ -1571,13 +2072,17 @@ void Upright_MLDB_Descriptor_Subset_Invoker::Get_Upright_MLDB_Descriptor_Subset(
sample_y = yf + l*scale;
sample_x = xf + k*scale;
- y1 = fRound(sample_y);
- x1 = fRound(sample_x);
- di += *(evolution[level].Lt.ptr<float>(y1)+x1);
+ y1 = cvRound(sample_y);
+ x1 = cvRound(sample_x);
+
+ if (x1 < 0 || y1 < 0 || x1 >= Lt.cols || y1 >= Lt.rows)
+ continue; // Boundaries
+
+ di += Lt.at<float>(y1, x1);
if (options.descriptor_channels > 1) {
- rx = *(evolution[level].Lx.ptr<float>(y1)+x1);
- ry = *(evolution[level].Ly.ptr<float>(y1)+x1);
+ rx = Lx.at<float>(y1, x1);
+ ry = Ly.at<float>(y1, x1);
if (options.descriptor_channels == 2) {
dx += sqrtf(rx*rx + ry*ry);
@@ -1590,23 +2095,26 @@ void Upright_MLDB_Descriptor_Subset_Invoker::Get_Upright_MLDB_Descriptor_Subset(
}
}
- *(values.ptr<float>(options.descriptor_channels*i)) = di;
+ float* pValues = &values[channels * i];
+ pValues[0] = di;
if (options.descriptor_channels == 2) {
- *(values.ptr<float>(options.descriptor_channels*i + 1)) = dx;
+ pValues[1] = dx;
}
else if (options.descriptor_channels == 3) {
- *(values.ptr<float>(options.descriptor_channels*i + 1)) = dx;
- *(values.ptr<float>(options.descriptor_channels*i + 2)) = dy;
+ pValues[1] = dx;
+ pValues[2] = dy;
}
}
// Do the comparisons
- const float *vals = values.ptr<float>(0);
const int *comps = descriptorBits_.ptr<int>(0);
+ CV_Assert(divUp(descriptorBits_.rows, 8) == desc_size);
+ memset(desc, 0, desc_size);
+
for (int i = 0; i<descriptorBits_.rows; i++) {
- if (vals[comps[2 * i]] > vals[comps[2 * i + 1]]) {
+ if (values[comps[2 * i]] > values[comps[2 * i + 1]]) {
desc[i / 8] |= (1 << (i % 8));
}
}
@@ -1636,7 +2144,8 @@ void generateDescriptorSubsample(Mat& sampleList, Mat& comparisons, int nbits,
}
ssz *= nchannels;
- CV_Assert(nbits <= ssz); // Descriptor size can't be bigger than full descriptor
+ CV_Assert(ssz == 162*nchannels);
+ CV_Assert(nbits <= ssz && "Descriptor size can't be bigger than full descriptor (486 = 162*3 - 3 channels)");
// Since the full descriptor is usually under 10k elements, we pick
// the selection from the full matrix. We take as many samples per
@@ -1647,7 +2156,7 @@ void generateDescriptorSubsample(Mat& sampleList, Mat& comparisons, int nbits,
for (int i = 0, c = 0; i < 3; i++) {
int gdiv = i + 2; //grid divisions, per row
int gsz = gdiv*gdiv;
- int psz = (int)ceil(2.f*pattern_size / (float)gdiv);
+ int psz = divUp(2*pattern_size, gdiv);
for (int j = 0; j < gsz; j++) {
for (int k = j + 1; k < gsz; k++, c++) {
@@ -1660,19 +2169,19 @@ void generateDescriptorSubsample(Mat& sampleList, Mat& comparisons, int nbits,
}
}
- srand(1024);
- Mat_<int> comps = Mat_<int>(nchannels * (int)ceil(nbits / (float)nchannels), 2);
+ RNG rng(1024);
+ const int npicks = divUp(nbits, nchannels);
+ Mat_<int> comps = Mat_<int>(nchannels * npicks, 2);
comps = 1000;
// Select some samples. A sample includes all channels
int count = 0;
- int npicks = (int)ceil(nbits / (float)nchannels);
Mat_<int> samples(29, 3);
Mat_<int> fullcopy = fullM.clone();
samples = -1;
for (int i = 0; i < npicks; i++) {
- int k = rand() % (fullM.rows - i);
+ int k = rng(fullM.rows - i);
if (i < 6) {
// Force use of the coarser grid values and comparisons
k = i;
diff --git a/modules/features2d/src/kaze/AKAZEFeatures.h b/modules/features2d/src/kaze/AKAZEFeatures.h
index 16a858f..18dc5fd 100644
--- a/modules/features2d/src/kaze/AKAZEFeatures.h
+++ b/modules/features2d/src/kaze/AKAZEFeatures.h
@@ -12,11 +12,38 @@
/* ************************************************************************* */
// Includes
#include "AKAZEConfig.h"
-#include "TEvolution.h"
namespace cv
{
+/// A-KAZE nonlinear diffusion filtering evolution
+struct Evolution
+{
+ Evolution() {
+ etime = 0.0f;
+ esigma = 0.0f;
+ octave = 0;
+ sublevel = 0;
+ sigma_size = 0;
+ octave_ratio = 0.0f;
+ border = 0;
+ }
+
+ Mat Lx, Ly; ///< First order spatial derivatives
+ Mat Lt; ///< Evolution image
+ Mat Lsmooth; ///< Smoothed image, used only for computing determinant, released afterwards
+ Mat Ldet; ///< Detector response
+
+ Size size; ///< Size of the layer
+ float etime; ///< Evolution time
+ float esigma; ///< Evolution sigma. For linear diffusion t = sigma^2 / 2
+ int octave; ///< Image octave
+ int sublevel; ///< Image sublevel in each octave
+ int sigma_size; ///< Integer esigma. For computing the feature detector responses
+ float octave_ratio; ///< Scaling ratio of this octave. ratio = 2^octave
+ int border; ///< Width of border where descriptors cannot be computed
+};
+
/* ************************************************************************* */
// AKAZE Class Declaration
class AKAZEFeatures {
@@ -24,7 +51,7 @@ class AKAZEFeatures {
private:
AKAZEOptions options_; ///< Configuration options for AKAZE
- std::vector<TEvolution> evolution_; ///< Vector of nonlinear diffusion evolution
+ std::vector<Evolution> evolution_; ///< Vector of nonlinear diffusion evolution
/// FED parameters
int ncycles_; ///< Number of cycles
@@ -44,16 +71,15 @@ public:
/// Scale Space methods
void Allocate_Memory_Evolution();
- int Create_Nonlinear_Scale_Space(const cv::Mat& img);
+ void Create_Nonlinear_Scale_Space(InputArray img);
void Feature_Detection(std::vector<cv::KeyPoint>& kpts);
void Compute_Determinant_Hessian_Response(void);
- void Compute_Multiscale_Derivatives(void);
- void Find_Scale_Space_Extrema(std::vector<cv::KeyPoint>& kpts);
- void Do_Subpixel_Refinement(std::vector<cv::KeyPoint>& kpts);
+ void Find_Scale_Space_Extrema(std::vector<Mat>& keypoints_by_layers);
+ void Do_Subpixel_Refinement(std::vector<Mat>& keypoints_by_layers,
+ std::vector<KeyPoint>& kpts);
/// Feature description methods
- void Compute_Descriptors(std::vector<cv::KeyPoint>& kpts, cv::Mat& desc);
- static void Compute_Main_Orientation(cv::KeyPoint& kpt, const std::vector<TEvolution>& evolution_);
+ void Compute_Descriptors(std::vector<cv::KeyPoint>& kpts, OutputArray desc);
void Compute_Keypoints_Orientation(std::vector<cv::KeyPoint>& kpts) const;
};
diff --git a/modules/features2d/src/kaze/KAZEFeatures.cpp b/modules/features2d/src/kaze/KAZEFeatures.cpp
index 29d85d3..6e7024c 100644
--- a/modules/features2d/src/kaze/KAZEFeatures.cpp
+++ b/modules/features2d/src/kaze/KAZEFeatures.cpp
@@ -68,7 +68,7 @@ void KAZEFeatures::Allocate_Memory_Evolution(void) {
aux.Ldet = Mat::zeros(options_.img_height, options_.img_width, CV_32F);
aux.esigma = options_.soffset*pow((float)2.0f, (float)(j) / (float)(options_.nsublevels)+i);
aux.etime = 0.5f*(aux.esigma*aux.esigma);
- aux.sigma_size = fRound(aux.esigma);
+ aux.sigma_size = cvRound(aux.esigma);
aux.octave = i;
aux.sublevel = j;
evolution_.push_back(aux);
@@ -363,10 +363,10 @@ void KAZEFeatures::Determinant_Hessian(std::vector<KeyPoint>& kpts)
if (is_extremum == true) {
// Check that the point is under the image limits for the descriptor computation
- left_x = fRound(kpts_par_[i][j].pt.x - smax*kpts_par_[i][j].size);
- right_x = fRound(kpts_par_[i][j].pt.x + smax*kpts_par_[i][j].size);
- up_y = fRound(kpts_par_[i][j].pt.y - smax*kpts_par_[i][j].size);
- down_y = fRound(kpts_par_[i][j].pt.y + smax*kpts_par_[i][j].size);
+ left_x = cvRound(kpts_par_[i][j].pt.x - smax*kpts_par_[i][j].size);
+ right_x = cvRound(kpts_par_[i][j].pt.x + smax*kpts_par_[i][j].size);
+ up_y = cvRound(kpts_par_[i][j].pt.y - smax*kpts_par_[i][j].size);
+ down_y = cvRound(kpts_par_[i][j].pt.y + smax*kpts_par_[i][j].size);
if (left_x < 0 || right_x >= evolution_[level].Ldet.cols ||
up_y < 0 || down_y >= evolution_[level].Ldet.rows) {
@@ -587,14 +587,14 @@ void KAZEFeatures::Compute_Main_Orientation(KeyPoint &kpt, const std::vector<TEv
xf = kpt.pt.x;
yf = kpt.pt.y;
level = kpt.class_id;
- s = fRound(kpt.size / 2.0f);
+ s = cvRound(kpt.size / 2.0f);
// Calculate derivatives responses for points within radius of 6*scale
for (int i = -6; i <= 6; ++i) {
for (int j = -6; j <= 6; ++j) {
if (i*i + j*j < 36) {
- iy = fRound(yf + j*s);
- ix = fRound(xf + i*s);
+ iy = cvRound(yf + j*s);
+ ix = cvRound(xf + i*s);
if (iy >= 0 && iy < options.img_height && ix >= 0 && ix < options.img_width) {
gweight = gaussian(iy - yf, ix - xf, 2.5f*s);
@@ -606,7 +606,7 @@ void KAZEFeatures::Compute_Main_Orientation(KeyPoint &kpt, const std::vector<TEv
resY[idx] = 0.0;
}
- Ang[idx] = getAngle(resX[idx], resY[idx]);
+ Ang[idx] = fastAtan2(resX[idx], resY[idx]) * (float)(CV_PI / 180.0f);
++idx;
}
}
@@ -638,7 +638,7 @@ void KAZEFeatures::Compute_Main_Orientation(KeyPoint &kpt, const std::vector<TEv
if (sumX*sumX + sumY*sumY > max) {
// store largest orientation
max = sumX*sumX + sumY*sumY;
- kpt.angle = getAngle(sumX, sumY) * 180.f / static_cast<float>(CV_PI);
+ kpt.angle = fastAtan2(sumX, sumY);
}
}
}
@@ -676,7 +676,7 @@ void KAZE_Descriptor_Invoker::Get_KAZE_Upright_Descriptor_64(const KeyPoint &kpt
// Get the information from the keypoint
yf = kpt.pt.y;
xf = kpt.pt.x;
- scale = fRound(kpt.size / 2.0f);
+ scale = cvRound(kpt.size / 2.0f);
level = kpt.class_id;
i = -8;
@@ -804,8 +804,8 @@ void KAZE_Descriptor_Invoker::Get_KAZE_Descriptor_64(const KeyPoint &kpt, float
// Get the information from the keypoint
yf = kpt.pt.y;
xf = kpt.pt.x;
- scale = fRound(kpt.size / 2.0f);
- angle = (kpt.angle * static_cast<float>(CV_PI)) / 180.f;
+ scale = cvRound(kpt.size / 2.0f);
+ angle = kpt.angle * static_cast<float>(CV_PI / 180.f);
level = kpt.class_id;
co = cos(angle);
si = sin(angle);
@@ -843,13 +843,13 @@ void KAZE_Descriptor_Invoker::Get_KAZE_Descriptor_64(const KeyPoint &kpt, float
// Get the gaussian weighted x and y responses
gauss_s1 = gaussian(xs - sample_x, ys - sample_y, 2.5f*scale);
- y1 = fRound(sample_y - 0.5f);
- x1 = fRound(sample_x - 0.5f);
+ y1 = cvFloor(sample_y);
+ x1 = cvFloor(sample_x);
checkDescriptorLimits(x1, y1, options_.img_width, options_.img_height);
- y2 = (int)(sample_y + 0.5f);
- x2 = (int)(sample_x + 0.5f);
+ y2 = y1 + 1;
+ x2 = x1 + 1;
checkDescriptorLimits(x2, y2, options_.img_width, options_.img_height);
@@ -935,7 +935,7 @@ void KAZE_Descriptor_Invoker::Get_KAZE_Upright_Descriptor_128(const KeyPoint &kp
// Get the information from the keypoint
yf = kpt.pt.y;
xf = kpt.pt.x;
- scale = fRound(kpt.size / 2.0f);
+ scale = cvRound(kpt.size / 2.0f);
level = kpt.class_id;
i = -8;
@@ -1087,8 +1087,8 @@ void KAZE_Descriptor_Invoker::Get_KAZE_Descriptor_128(const KeyPoint &kpt, float
// Get the information from the keypoint
yf = kpt.pt.y;
xf = kpt.pt.x;
- scale = fRound(kpt.size / 2.0f);
- angle = (kpt.angle * static_cast<float>(CV_PI)) / 180.f;
+ scale = cvRound(kpt.size / 2.0f);
+ angle = kpt.angle * static_cast<float>(CV_PI / 180.f);
level = kpt.class_id;
co = cos(angle);
si = sin(angle);
@@ -1129,13 +1129,13 @@ void KAZE_Descriptor_Invoker::Get_KAZE_Descriptor_128(const KeyPoint &kpt, float
// Get the gaussian weighted x and y responses
gauss_s1 = gaussian(xs - sample_x, ys - sample_y, 2.5f*scale);
- y1 = fRound(sample_y - 0.5f);
- x1 = fRound(sample_x - 0.5f);
+ y1 = cvFloor(sample_y);
+ x1 = cvFloor(sample_x);
checkDescriptorLimits(x1, y1, options_.img_width, options_.img_height);
- y2 = (int)(sample_y + 0.5f);
- x2 = (int)(sample_x + 0.5f);
+ y2 = y1 + 1;
+ x2 = x1 + 1;
checkDescriptorLimits(x2, y2, options_.img_width, options_.img_height);
diff --git a/modules/features2d/src/kaze/TEvolution.h b/modules/features2d/src/kaze/TEvolution.h
index b033bce..36052b3 100644
--- a/modules/features2d/src/kaze/TEvolution.h
+++ b/modules/features2d/src/kaze/TEvolution.h
@@ -28,6 +28,7 @@ struct TEvolution
Mat Lt; ///< Evolution image
Mat Lsmooth; ///< Smoothed image
Mat Ldet; ///< Detector response
+
float etime; ///< Evolution time
float esigma; ///< Evolution sigma. For linear diffusion t = sigma^2 / 2
int octave; ///< Image octave
diff --git a/modules/features2d/src/kaze/fed.cpp b/modules/features2d/src/kaze/fed.cpp
index cb47628..2026b83 100644
--- a/modules/features2d/src/kaze/fed.cpp
+++ b/modules/features2d/src/kaze/fed.cpp
@@ -72,7 +72,7 @@ int fed_tau_by_cycle_time(const float& t, const float& tau_max,
float scale = 0.0; // Ratio of t we search to maximal t
// Compute necessary number of time steps
- n = (int)(ceilf(sqrtf(3.0f*t/tau_max+0.25f)-0.5f-1.0e-8f)+ 0.5f);
+ n = cvCeil(sqrtf(3.0f*t/tau_max+0.25f)-0.5f-1.0e-8f);
scale = 3.0f*t/(tau_max*(float)(n*(n+1)));
// Call internal FED time step creation routine
diff --git a/modules/features2d/src/kaze/nldiffusion_functions.cpp b/modules/features2d/src/kaze/nldiffusion_functions.cpp
index 85ed5de..16b9615 100644
--- a/modules/features2d/src/kaze/nldiffusion_functions.cpp
+++ b/modules/features2d/src/kaze/nldiffusion_functions.cpp
@@ -49,7 +49,7 @@ void gaussian_2D_convolution(const cv::Mat& src, cv::Mat& dst, int ksize_x, int
// Compute an appropriate kernel size according to the specified sigma
if (sigma > ksize_x || sigma > ksize_y || ksize_x == 0 || ksize_y == 0) {
- ksize_x_ = (int)ceil(2.0f*(1.0f + (sigma - 0.8f) / (0.3f)));
+ ksize_x_ = cvCeil(2.0f*(1.0f + (sigma - 0.8f) / (0.3f)));
ksize_y_ = ksize_x_;
}
@@ -91,7 +91,11 @@ void image_derivatives_scharr(const cv::Mat& src, cv::Mat& dst, int xorder, int
* @param dst Output image
* @param k Contrast factor parameter
*/
-void pm_g1(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst, float k) {
+void pm_g1(InputArray _Lx, InputArray _Ly, OutputArray _dst, float k) {
+ _dst.create(_Lx.size(), _Lx.type());
+ Mat Lx = _Lx.getMat();
+ Mat Ly = _Ly.getMat();
+ Mat dst = _dst.getMat();
Size sz = Lx.size();
float inv_k = 1.0f / (k*k);
@@ -118,7 +122,13 @@ void pm_g1(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst, float k) {
* @param dst Output image
* @param k Contrast factor parameter
*/
-void pm_g2(const cv::Mat &Lx, const cv::Mat& Ly, cv::Mat& dst, float k) {
+void pm_g2(InputArray _Lx, InputArray _Ly, OutputArray _dst, float k) {
+ CV_INSTRUMENT_REGION()
+
+ _dst.create(_Lx.size(), _Lx.type());
+ Mat Lx = _Lx.getMat();
+ Mat Ly = _Ly.getMat();
+ Mat dst = _dst.getMat();
Size sz = Lx.size();
dst.create(sz, Lx.type());
@@ -144,7 +154,11 @@ void pm_g2(const cv::Mat &Lx, const cv::Mat& Ly, cv::Mat& dst, float k) {
* Applications of nonlinear diffusion in image processing and computer vision,
* Proceedings of Algorithmy 2000
*/
-void weickert_diffusivity(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst, float k) {
+void weickert_diffusivity(InputArray _Lx, InputArray _Ly, OutputArray _dst, float k) {
+ _dst.create(_Lx.size(), _Lx.type());
+ Mat Lx = _Lx.getMat();
+ Mat Ly = _Ly.getMat();
+ Mat dst = _dst.getMat();
Size sz = Lx.size();
float inv_k = 1.0f / (k*k);
@@ -177,7 +191,11 @@ void weickert_diffusivity(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst, fl
* Applications of nonlinear diffusion in image processing and computer vision,
* Proceedings of Algorithmy 2000
*/
-void charbonnier_diffusivity(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst, float k) {
+void charbonnier_diffusivity(InputArray _Lx, InputArray _Ly, OutputArray _dst, float k) {
+ _dst.create(_Lx.size(), _Lx.type());
+ Mat Lx = _Lx.getMat();
+ Mat Ly = _Ly.getMat();
+ Mat dst = _dst.getMat();
Size sz = Lx.size();
float inv_k = 1.0f / (k*k);
@@ -209,6 +227,7 @@ void charbonnier_diffusivity(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst,
* @return k contrast factor
*/
float compute_k_percentile(const cv::Mat& img, float perc, float gscale, int nbins, int ksize_x, int ksize_y) {
+ CV_INSTRUMENT_REGION()
int nbin = 0, nelements = 0, nthreshold = 0, k = 0;
float kperc = 0.0, modg = 0.0;
@@ -307,6 +326,7 @@ void compute_scharr_derivatives(const cv::Mat& src, cv::Mat& dst, int xorder, in
* @param scale_ Scale factor or derivative size
*/
void compute_derivative_kernels(cv::OutputArray _kx, cv::OutputArray _ky, int dx, int dy, int scale) {
+ CV_INSTRUMENT_REGION()
int ksize = 3 + 2 * (scale - 1);
@@ -320,6 +340,7 @@ void compute_derivative_kernels(cv::OutputArray _kx, cv::OutputArray _ky, int dx
_ky.create(ksize, 1, CV_32F, -1, true);
Mat kx = _kx.getMat();
Mat ky = _ky.getMat();
+ std::vector<float> kerI;
float w = 10.0f / 3.0f;
float norm = 1.0f / (2.0f*scale*(w + 2.0f));
@@ -327,7 +348,7 @@ void compute_derivative_kernels(cv::OutputArray _kx, cv::OutputArray _ky, int dx
for (int k = 0; k < 2; k++) {
Mat* kernel = k == 0 ? &kx : &ky;
int order = k == 0 ? dx : dy;
- std::vector<float> kerI(ksize, 0.0f);
+ kerI.assign(ksize, 0.0f);
if (order == 0) {
kerI[0] = norm, kerI[ksize / 2] = w*norm, kerI[ksize - 1] = norm;
@@ -403,6 +424,7 @@ private:
* dL_by_ds = d(c dL_by_dx)_by_dx + d(c dL_by_dy)_by_dy
*/
void nld_step_scalar(cv::Mat& Ld, const cv::Mat& c, cv::Mat& Lstep, float stepsize) {
+ CV_INSTRUMENT_REGION()
cv::parallel_for_(cv::Range(1, Lstep.rows - 1), Nld_Step_Scalar_Invoker(Ld, c, Lstep, stepsize), (double)Ld.total()/(1 << 16));
@@ -472,7 +494,6 @@ void nld_step_scalar(cv::Mat& Ld, const cv::Mat& c, cv::Mat& Lstep, float stepsi
* @param dst Output image with half of the resolution of the input image
*/
void halfsample_image(const cv::Mat& src, cv::Mat& dst) {
-
// Make sure the destination image is of the right size
CV_Assert(src.cols / 2 == dst.cols);
CV_Assert(src.rows / 2 == dst.rows);
diff --git a/modules/features2d/src/kaze/nldiffusion_functions.h b/modules/features2d/src/kaze/nldiffusion_functions.h
index 9dc9fed..97c36a2 100644
--- a/modules/features2d/src/kaze/nldiffusion_functions.h
+++ b/modules/features2d/src/kaze/nldiffusion_functions.h
@@ -21,10 +21,10 @@ namespace cv
void gaussian_2D_convolution(const cv::Mat& src, cv::Mat& dst, int ksize_x, int ksize_y, float sigma);
// Diffusivity functions
-void pm_g1(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst, float k);
-void pm_g2(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst, float k);
-void weickert_diffusivity(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst, float k);
-void charbonnier_diffusivity(const cv::Mat& Lx, const cv::Mat& Ly, cv::Mat& dst, float k);
+void pm_g1(InputArray Lx, InputArray Ly, OutputArray dst, float k);
+void pm_g2(InputArray Lx, InputArray Ly, OutputArray dst, float k);
+void weickert_diffusivity(InputArray Lx, InputArray Ly, OutputArray dst, float k);
+void charbonnier_diffusivity(InputArray Lx, InputArray Ly, OutputArray dst, float k);
float compute_k_percentile(const cv::Mat& img, float perc, float gscale, int nbins, int ksize_x, int ksize_y);
diff --git a/modules/features2d/src/kaze/utils.h b/modules/features2d/src/kaze/utils.h
index d9bfbe4..44e5b76 100644
--- a/modules/features2d/src/kaze/utils.h
+++ b/modules/features2d/src/kaze/utils.h
@@ -3,31 +3,6 @@
/* ************************************************************************* */
/**
- * @brief This function computes the angle from the vector given by (X Y). From 0 to 2*Pi
- */
-inline float getAngle(float x, float y) {
-
- if (x >= 0 && y >= 0) {
- return atanf(y / x);
- }
-
- if (x < 0 && y >= 0) {
- return static_cast<float>(CV_PI)-atanf(-y / x);
- }
-
- if (x < 0 && y < 0) {
- return static_cast<float>(CV_PI)+atanf(y / x);
- }
-
- if (x >= 0 && y < 0) {
- return static_cast<float>(2.0 * CV_PI) - atanf(-y / x);
- }
-
- return 0;
-}
-
-/* ************************************************************************* */
-/**
* @brief This function computes the value of a 2D Gaussian function
* @param x X Position
* @param y Y Position
@@ -64,34 +39,4 @@ inline void checkDescriptorLimits(int &x, int &y, int width, int height) {
}
}
-/* ************************************************************************* */
-/**
- * @brief This funtion rounds float to nearest integer
- * @param flt Input float
- * @return dst Nearest integer
- */
-inline int fRound(float flt) {
- return (int)(flt + 0.5f);
-}
-
-/* ************************************************************************* */
-/**
- * @brief Exponentiation by squaring
- * @param flt Exponentiation base
- * @return dst Exponentiation value
- */
-inline int fastpow(int base, int exp) {
- int res = 1;
- while(exp > 0) {
- if(exp & 1) {
- exp--;
- res *= base;
- } else {
- exp /= 2;
- base *= base;
- }
- }
- return res;
-}
-
#endif
diff --git a/modules/features2d/src/keypoint.cpp b/modules/features2d/src/keypoint.cpp
index 0cf7ae0..4c14344 100644
--- a/modules/features2d/src/keypoint.cpp
+++ b/modules/features2d/src/keypoint.cpp
@@ -156,6 +156,8 @@ private:
void KeyPointsFilter::runByPixelsMask( std::vector<KeyPoint>& keypoints, const Mat& mask )
{
+ CV_INSTRUMENT_REGION()
+
if( mask.empty() )
return;
diff --git a/modules/features2d/src/mser.cpp b/modules/features2d/src/mser.cpp
old mode 100644
new mode 100755
index f16a0d2..9f4a4ca
--- a/modules/features2d/src/mser.cpp
+++ b/modules/features2d/src/mser.cpp
@@ -25,7 +25,7 @@
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
- * Copyright© 2009, Liu Liu All rights reserved.
+ * Copyright (C) 2009, Liu Liu All rights reserved.
*
* OpenCV functions for MSER extraction
*
@@ -262,96 +262,95 @@ public:
}
// add history chunk to a connected component
- void growHistory( CompHistory*& hptr, WParams& wp, int new_gray_level, bool final, bool force=false )
+ void growHistory(CompHistory*& hptr, WParams& wp, int new_gray_level, bool final)
{
- bool update = final;
- if( new_gray_level < 0 )
+ if (new_gray_level < gray_level)
new_gray_level = gray_level;
- if( !history || (history->size != size && size > 0 &&
- (gray_level != history->val || force)))
- {
- CompHistory* h;
-
- if (history && gray_level == history->val)
- h = history;
- else
- {
- h = hptr++;
- h->parent_ = 0;
- h->child_ = history;
- h->next_ = 0;
- if (history)
- history->parent_ = h;
- }
- h->val = gray_level;
- h->size = size;
- h->head = head;
+ CompHistory *h;
+ if (history && history->val == gray_level)
+ {
+ h = history;
+ }
+ else
+ {
+ h = hptr++;
+ h->parent_ = 0;
+ h->child_ = history;
+ h->next_ = 0;
- history = h;
- h->var = FLT_MAX;
- h->checked = true;
- if (h->size >= wp.p.minArea)
+ if (history)
{
- h->var = -1.f;
- h->checked = false;
- update = true;
+ history->parent_ = h;
}
}
+ h->val = gray_level;
+ h->size = size;
+ h->head = head;
+ h->var = FLT_MAX;
+ h->checked = true;
+ if (h->size >= wp.p.minArea)
+ {
+ h->var = -1.f;
+ h->checked = false;
+ }
+
gray_level = new_gray_level;
- if( update && history && gray_level != history->val )
+ history = h;
+ if (history && history->val != gray_level)
+ {
history->updateTree(wp, 0, 0, final);
+ }
}
// merging two connected components
void merge( ConnectedComp* comp1, ConnectedComp* comp2,
CompHistory*& hptr, WParams& wp )
{
- if( comp1->size < comp2->size )
+ if (comp1->gray_level < comp2->gray_level)
std::swap(comp1, comp2);
- if( comp2->size == 0 )
+ gray_level = comp1->gray_level;
+ comp1->growHistory(hptr, wp, gray_level, false);
+ comp2->growHistory(hptr, wp, gray_level, false);
+
+ if (comp1->size == 0)
+ {
+ head = comp2->head;
+ tail = comp2->tail;
+ }
+ else
{
- // only grow comp1's history
- comp1->growHistory(hptr, wp, -1, false);
- gray_level = comp1->gray_level;
head = comp1->head;
- tail = comp1->tail;
- size = comp1->size;
- history = comp1->history;
- return;
+ wp.pix0[comp1->tail].setNext(comp2->head);
+ tail = comp2->tail;
}
- comp1->growHistory( hptr, wp, -1, false );
- comp2->growHistory( hptr, wp, -1, false );
-
- if (comp1->gray_level < comp2->gray_level)
- std::swap(comp1, comp2);
-
- gray_level = comp1->gray_level;
- history = comp1->history;
- wp.pix0[comp1->tail].setNext(comp2->head);
-
- head = comp1->head;
- tail = comp2->tail;
size = comp1->size + comp2->size;
+ history = comp1->history;
CompHistory *h1 = history->child_;
CompHistory *h2 = comp2->history;
- if (h2->size > wp.p.minArea)
+ // the child_'s size should be the large one
+ if (h1 && h1->size > h2->size)
{
- // the child_'s size should be the large one
- if (h1 && h1->size > h2->size)
+ // add h2 as a child only if its size is large enough
+ if(h2->size >= wp.p.minArea)
{
h2->next_ = h1->next_;
h1->next_ = h2;
+ h2->parent_ = history;
}
- else
+ }
+ else
+ {
+ history->child_ = h2;
+ h2->parent_ = history;
+ // reserve h1 as a child only if its size is large enough
+ if (h1 && h1->size >= wp.p.minArea)
{
- history->child_ = h2;
h2->next_ = h1;
}
- h2->parent_ = history;
}
}
@@ -515,30 +514,26 @@ public:
ptr = *heap[curr_gray];
heap[curr_gray]--;
- if( curr_gray < comptr[-1].gray_level )
+ if (curr_gray < comptr[-1].gray_level)
+ {
comptr->growHistory(histptr, wp, curr_gray, false);
+ CV_DbgAssert(comptr->size == comptr->history->size);
+ }
else
{
- // keep merging top two comp in stack until the gray level >= pixel_val
- for(;;)
- {
- comptr--;
- comptr->merge(comptr, comptr+1, histptr, wp);
- if( curr_gray <= comptr[0].gray_level )
- break;
- if( curr_gray < comptr[-1].gray_level )
- {
- comptr->growHistory(histptr, wp, curr_gray, false);
- break;
- }
- }
+ // there must one pixel with the second component's gray level in the heap,
+ // so curr_gray is not large than the second component's gray level
+ comptr--;
+ CV_DbgAssert(curr_gray == comptr->gray_level);
+ comptr->merge(comptr, comptr + 1, histptr, wp);
+ CV_DbgAssert(curr_gray == comptr->gray_level);
}
}
}
for( ; comptr->gray_level != 256; comptr-- )
{
- comptr->growHistory(histptr, wp, 256, true, true);
+ comptr->growHistory(histptr, wp, 256, true);
}
}
diff --git a/modules/features2d/src/opencl/akaze.cl b/modules/features2d/src/opencl/akaze.cl
new file mode 100644
index 0000000..40f5c2b
--- /dev/null
+++ b/modules/features2d/src/opencl/akaze.cl
@@ -0,0 +1,122 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+
+/**
+ * @brief This function computes the Perona and Malik conductivity coefficient g2
+ * g2 = 1 / (1 + dL^2 / k^2)
+ * @param lx First order image derivative in X-direction (horizontal)
+ * @param ly First order image derivative in Y-direction (vertical)
+ * @param dst Output image
+ * @param k Contrast factor parameter
+ */
+__kernel void
+AKAZE_pm_g2(__global const float* lx, __global const float* ly, __global float* dst,
+ float k, int size)
+{
+ int i = get_global_id(0);
+ // OpenCV plays with dimensions so we need explicit check for this
+ if (!(i < size))
+ {
+ return;
+ }
+
+ const float k2inv = 1.0f / (k * k);
+ dst[i] = 1.0f / (1.0f + ((lx[i] * lx[i] + ly[i] * ly[i]) * k2inv));
+}
+
+__kernel void
+AKAZE_nld_step_scalar(__global const float* lt, int lt_step, int lt_offset, int rows, int cols,
+ __global const float* lf, __global float* dst, float step_size)
+{
+ /* The labeling scheme for this five star stencil:
+ [ a ]
+ [ -1 c +1 ]
+ [ b ]
+ */
+ // column-first indexing
+ int i = get_global_id(1);
+ int j = get_global_id(0);
+
+ // OpenCV plays with dimensions so we need explicit check for this
+ if (!(i < rows && j < cols))
+ {
+ return;
+ }
+
+ // get row indexes
+ int a = (i - 1) * cols;
+ int c = (i ) * cols;
+ int b = (i + 1) * cols;
+ // compute stencil
+ float res = 0.0f;
+ if (i == 0) // first rows
+ {
+ if (j == 0 || j == (cols - 1))
+ {
+ res = 0.0f;
+ } else
+ {
+ res = (lf[c + j] + lf[c + j + 1])*(lt[c + j + 1] - lt[c + j]) +
+ (lf[c + j] + lf[c + j - 1])*(lt[c + j - 1] - lt[c + j]) +
+ (lf[c + j] + lf[b + j ])*(lt[b + j ] - lt[c + j]);
+ }
+ } else if (i == (rows - 1)) // last row
+ {
+ if (j == 0 || j == (cols - 1))
+ {
+ res = 0.0f;
+ } else
+ {
+ res = (lf[c + j] + lf[c + j + 1])*(lt[c + j + 1] - lt[c + j]) +
+ (lf[c + j] + lf[c + j - 1])*(lt[c + j - 1] - lt[c + j]) +
+ (lf[c + j] + lf[a + j ])*(lt[a + j ] - lt[c + j]);
+ }
+ } else // inner rows
+ {
+ if (j == 0) // first column
+ {
+ res = (lf[c + 0] + lf[c + 1])*(lt[c + 1] - lt[c + 0]) +
+ (lf[c + 0] + lf[b + 0])*(lt[b + 0] - lt[c + 0]) +
+ (lf[c + 0] + lf[a + 0])*(lt[a + 0] - lt[c + 0]);
+ } else if (j == (cols - 1)) // last column
+ {
+ res = (lf[c + j] + lf[c + j - 1])*(lt[c + j - 1] - lt[c + j]) +
+ (lf[c + j] + lf[b + j ])*(lt[b + j ] - lt[c + j]) +
+ (lf[c + j] + lf[a + j ])*(lt[a + j ] - lt[c + j]);
+ } else // inner stencil
+ {
+ res = (lf[c + j] + lf[c + j + 1])*(lt[c + j + 1] - lt[c + j]) +
+ (lf[c + j] + lf[c + j - 1])*(lt[c + j - 1] - lt[c + j]) +
+ (lf[c + j] + lf[b + j ])*(lt[b + j ] - lt[c + j]) +
+ (lf[c + j] + lf[a + j ])*(lt[a + j ] - lt[c + j]);
+ }
+ }
+
+ dst[c + j] = res * step_size;
+}
+
+/**
+ * @brief Compute determinant from hessians
+ * @details Compute Ldet by (Lxx.mul(Lyy) - Lxy.mul(Lxy)) * sigma
+ *
+ * @param lxx spatial derivates
+ * @param lxy spatial derivates
+ * @param lyy spatial derivates
+ * @param dst output determinant
+ * @param sigma determinant will be scaled by this sigma
+ */
+__kernel void
+AKAZE_compute_determinant(__global const float* lxx, __global const float* lxy, __global const float* lyy,
+ __global float* dst, float sigma, int size)
+{
+ int i = get_global_id(0);
+ // OpenCV plays with dimensions so we need explicit check for this
+ if (!(i < size))
+ {
+ return;
+ }
+
+ dst[i] = (lxx[i] * lyy[i] - lxy[i] * lxy[i]) * sigma;
+}
diff --git a/modules/features2d/test/ocl/test_brute_force_matcher.cpp b/modules/features2d/test/ocl/test_brute_force_matcher.cpp
index 6359533..06ca4be 100644
--- a/modules/features2d/test/ocl/test_brute_force_matcher.cpp
+++ b/modules/features2d/test/ocl/test_brute_force_matcher.cpp
@@ -111,7 +111,7 @@ PARAM_TEST_CASE(BruteForceMatcher, int, int)
}
};
-#ifdef ANDROID
+#ifdef __ANDROID__
OCL_TEST_P(BruteForceMatcher, DISABLED_Match_Single)
#else
OCL_TEST_P(BruteForceMatcher, Match_Single)
@@ -135,7 +135,7 @@ OCL_TEST_P(BruteForceMatcher, Match_Single)
ASSERT_EQ(0, badCount);
}
-#ifdef ANDROID
+#ifdef __ANDROID__
OCL_TEST_P(BruteForceMatcher, DISABLED_KnnMatch_2_Single)
#else
OCL_TEST_P(BruteForceMatcher, KnnMatch_2_Single)
@@ -171,7 +171,7 @@ OCL_TEST_P(BruteForceMatcher, KnnMatch_2_Single)
ASSERT_EQ(0, badCount);
}
-#ifdef ANDROID
+#ifdef __ANDROID__
OCL_TEST_P(BruteForceMatcher, DISABLED_RadiusMatch_Single)
#else
OCL_TEST_P(BruteForceMatcher, RadiusMatch_Single)
diff --git a/modules/features2d/test/test_akaze.cpp b/modules/features2d/test/test_akaze.cpp
new file mode 100644
index 0000000..32d7222
--- /dev/null
+++ b/modules/features2d/test/test_akaze.cpp
@@ -0,0 +1,47 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#include "test_precomp.hpp"
+
+using namespace std;
+using namespace cv;
+
+TEST(Features2d_AKAZE, detect_and_compute_split)
+{
+ Mat testImg(100, 100, CV_8U);
+ RNG rng(101);
+ rng.fill(testImg, RNG::UNIFORM, Scalar(0), Scalar(255), true);
+
+ Ptr<Feature2D> ext = AKAZE::create(AKAZE::DESCRIPTOR_MLDB, 0, 3, 0.001f, 1, 1, KAZE::DIFF_PM_G2);
+ vector<KeyPoint> detAndCompKps;
+ Mat desc;
+ ext->detectAndCompute(testImg, noArray(), detAndCompKps, desc);
+
+ vector<KeyPoint> detKps;
+ ext->detect(testImg, detKps);
+
+ ASSERT_EQ(detKps.size(), detAndCompKps.size());
+
+ for(size_t i = 0; i < detKps.size(); i++)
+ ASSERT_EQ(detKps[i].hash(), detAndCompKps[i].hash());
+}
+
+/**
+ * This test is here to guard propagation of NaNs that happens on this image. NaNs are guarded
+ * by debug asserts in AKAZE, which should fire for you if you are lucky.
+ *
+ * This test also reveals problems with uninitialized memory that happens only on this image.
+ * This is very hard to hit and depends a lot on particular allocator. Run this test in valgrind and check
+ * for uninitialized values if you think you are hitting this problem again.
+ */
+TEST(Features2d_AKAZE, uninitialized_and_nans)
+{
+ Mat b1 = imread(cvtest::TS::ptr()->get_data_path() + "../stitching/b1.png");
+ ASSERT_FALSE(b1.empty());
+
+ vector<KeyPoint> keypoints;
+ Mat desc;
+ Ptr<Feature2D> akaze = AKAZE::create();
+ akaze->detectAndCompute(b1, noArray(), keypoints, desc);
+}
diff --git a/modules/features2d/test/test_descriptors_invariance.cpp b/modules/features2d/test/test_descriptors_invariance.cpp
new file mode 100644
index 0000000..2ab37dd
--- /dev/null
+++ b/modules/features2d/test/test_descriptors_invariance.cpp
@@ -0,0 +1,194 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#include "test_precomp.hpp"
+#include "test_invariance_utils.hpp"
+
+using namespace std;
+using namespace cv;
+using std::tr1::make_tuple;
+using std::tr1::get;
+using namespace testing;
+
+#define SHOW_DEBUG_LOG 1
+
+typedef std::tr1::tuple<std::string, Ptr<FeatureDetector>, Ptr<DescriptorExtractor>, float>
+ String_FeatureDetector_DescriptorExtractor_Float_t;
+const static std::string IMAGE_TSUKUBA = "features2d/tsukuba.png";
+const static std::string IMAGE_BIKES = "detectors_descriptors_evaluation/images_datasets/bikes/img1.png";
+#define Value(...) Values(String_FeatureDetector_DescriptorExtractor_Float_t(__VA_ARGS__))
+
+static
+void rotateKeyPoints(const vector<KeyPoint>& src, const Mat& H, float angle, vector<KeyPoint>& dst)
+{
+ // suppose that H is rotation given from rotateImage() and angle has value passed to rotateImage()
+ vector<Point2f> srcCenters, dstCenters;
+ KeyPoint::convert(src, srcCenters);
+
+ perspectiveTransform(srcCenters, dstCenters, H);
+
+ dst = src;
+ for(size_t i = 0; i < dst.size(); i++)
+ {
+ dst[i].pt = dstCenters[i];
+ float dstAngle = src[i].angle + angle;
+ if(dstAngle >= 360.f)
+ dstAngle -= 360.f;
+ dst[i].angle = dstAngle;
+ }
+}
+
+class DescriptorInvariance : public TestWithParam<String_FeatureDetector_DescriptorExtractor_Float_t>
+{
+protected:
+ virtual void SetUp() {
+ // Read test data
+ const std::string filename = cvtest::TS::ptr()->get_data_path() + get<0>(GetParam());
+ image0 = imread(filename);
+ ASSERT_FALSE(image0.empty()) << "couldn't read input image";
+
+ featureDetector = get<1>(GetParam());
+ descriptorExtractor = get<2>(GetParam());
+ minInliersRatio = get<3>(GetParam());
+ }
+
+ Ptr<FeatureDetector> featureDetector;
+ Ptr<DescriptorExtractor> descriptorExtractor;
+ float minInliersRatio;
+ Mat image0;
+};
+
+typedef DescriptorInvariance DescriptorScaleInvariance;
+typedef DescriptorInvariance DescriptorRotationInvariance;
+
+TEST_P(DescriptorRotationInvariance, rotation)
+{
+ Mat image1, mask1;
+ const int borderSize = 16;
+ Mat mask0(image0.size(), CV_8UC1, Scalar(0));
+ mask0(Rect(borderSize, borderSize, mask0.cols - 2*borderSize, mask0.rows - 2*borderSize)).setTo(Scalar(255));
+
+ vector<KeyPoint> keypoints0;
+ Mat descriptors0;
+ featureDetector->detect(image0, keypoints0, mask0);
+ std::cout << "Keypoints: " << keypoints0.size() << std::endl;
+ EXPECT_GE(keypoints0.size(), 15u);
+ descriptorExtractor->compute(image0, keypoints0, descriptors0);
+
+ BFMatcher bfmatcher(descriptorExtractor->defaultNorm());
+
+ const float minIntersectRatio = 0.5f;
+ const int maxAngle = 360, angleStep = 15;
+ for(int angle = 0; angle < maxAngle; angle += angleStep)
+ {
+ Mat H = rotateImage(image0, mask0, static_cast<float>(angle), image1, mask1);
+
+ vector<KeyPoint> keypoints1;
+ rotateKeyPoints(keypoints0, H, static_cast<float>(angle), keypoints1);
+ Mat descriptors1;
+ descriptorExtractor->compute(image1, keypoints1, descriptors1);
+
+ vector<DMatch> descMatches;
+ bfmatcher.match(descriptors0, descriptors1, descMatches);
+
+ int descInliersCount = 0;
+ for(size_t m = 0; m < descMatches.size(); m++)
+ {
+ const KeyPoint& transformed_p0 = keypoints1[descMatches[m].queryIdx];
+ const KeyPoint& p1 = keypoints1[descMatches[m].trainIdx];
+ if(calcIntersectRatio(transformed_p0.pt, 0.5f * transformed_p0.size,
+ p1.pt, 0.5f * p1.size) >= minIntersectRatio)
+ {
+ descInliersCount++;
+ }
+ }
+
+ float descInliersRatio = static_cast<float>(descInliersCount) / keypoints0.size();
+ EXPECT_GE(descInliersRatio, minInliersRatio);
+#if SHOW_DEBUG_LOG
+ std::cout
+ << "angle = " << angle
+ << ", inliers = " << descInliersCount
+ << ", descInliersRatio = " << static_cast<float>(descInliersCount) / keypoints0.size()
+ << std::endl;
+#endif
+ }
+}
+
+
+TEST_P(DescriptorScaleInvariance, scale)
+{
+ vector<KeyPoint> keypoints0;
+ featureDetector->detect(image0, keypoints0);
+ std::cout << "Keypoints: " << keypoints0.size() << std::endl;
+ EXPECT_GE(keypoints0.size(), 15u);
+ Mat descriptors0;
+ descriptorExtractor->compute(image0, keypoints0, descriptors0);
+
+ BFMatcher bfmatcher(descriptorExtractor->defaultNorm());
+ for(int scaleIdx = 1; scaleIdx <= 3; scaleIdx++)
+ {
+ float scale = 1.f + scaleIdx * 0.5f;
+
+ Mat image1;
+ resize(image0, image1, Size(), 1./scale, 1./scale);
+
+ vector<KeyPoint> keypoints1;
+ scaleKeyPoints(keypoints0, keypoints1, 1.0f/scale);
+ Mat descriptors1;
+ descriptorExtractor->compute(image1, keypoints1, descriptors1);
+
+ vector<DMatch> descMatches;
+ bfmatcher.match(descriptors0, descriptors1, descMatches);
+
+ const float minIntersectRatio = 0.5f;
+ int descInliersCount = 0;
+ for(size_t m = 0; m < descMatches.size(); m++)
+ {
+ const KeyPoint& transformed_p0 = keypoints0[descMatches[m].queryIdx];
+ const KeyPoint& p1 = keypoints0[descMatches[m].trainIdx];
+ if(calcIntersectRatio(transformed_p0.pt, 0.5f * transformed_p0.size,
+ p1.pt, 0.5f * p1.size) >= minIntersectRatio)
+ {
+ descInliersCount++;
+ }
+ }
+
+ float descInliersRatio = static_cast<float>(descInliersCount) / keypoints0.size();
+ EXPECT_GE(descInliersRatio, minInliersRatio);
+#if SHOW_DEBUG_LOG
+ std::cout
+ << "scale = " << scale
+ << ", inliers = " << descInliersCount
+ << ", descInliersRatio = " << static_cast<float>(descInliersCount) / keypoints0.size()
+ << std::endl;
+#endif
+ }
+}
+
+/*
+ * Descriptors's rotation invariance check
+ */
+
+INSTANTIATE_TEST_CASE_P(BRISK, DescriptorRotationInvariance,
+ Value(IMAGE_TSUKUBA, BRISK::create(), BRISK::create(), 0.99f));
+
+INSTANTIATE_TEST_CASE_P(ORB, DescriptorRotationInvariance,
+ Value(IMAGE_TSUKUBA, ORB::create(), ORB::create(), 0.99f));
+
+INSTANTIATE_TEST_CASE_P(AKAZE, DescriptorRotationInvariance,
+ Value(IMAGE_TSUKUBA, AKAZE::create(), AKAZE::create(), 0.99f));
+
+INSTANTIATE_TEST_CASE_P(AKAZE_DESCRIPTOR_KAZE, DescriptorRotationInvariance,
+ Value(IMAGE_TSUKUBA, AKAZE::create(AKAZE::DESCRIPTOR_KAZE), AKAZE::create(AKAZE::DESCRIPTOR_KAZE), 0.99f));
+
+/*
+ * Descriptor's scale invariance check
+ */
+
+INSTANTIATE_TEST_CASE_P(AKAZE, DescriptorScaleInvariance,
+ Value(IMAGE_BIKES, AKAZE::create(), AKAZE::create(), 0.6f));
+
+INSTANTIATE_TEST_CASE_P(AKAZE_DESCRIPTOR_KAZE, DescriptorScaleInvariance,
+ Value(IMAGE_BIKES, AKAZE::create(AKAZE::DESCRIPTOR_KAZE), AKAZE::create(AKAZE::DESCRIPTOR_KAZE), 0.55f));
diff --git a/modules/features2d/test/test_descriptors_regression.cpp b/modules/features2d/test/test_descriptors_regression.cpp
index 7f44bc2..7540d1d 100644
--- a/modules/features2d/test/test_descriptors_regression.cpp
+++ b/modules/features2d/test/test_descriptors_regression.cpp
@@ -43,6 +43,7 @@
using namespace std;
using namespace cv;
+using namespace testing;
const string FEATURES2D_DIR = "features2d";
const string IMAGE_FILENAME = "tsukuba.png";
@@ -56,6 +57,7 @@ static void writeMatInBin( const Mat& mat, const string& filename )
FILE* f = fopen( filename.c_str(), "wb");
if( f )
{
+ CV_Assert(4 == sizeof(int));
int type = mat.type();
fwrite( (void*)&mat.rows, sizeof(int), 1, f );
fwrite( (void*)&mat.cols, sizeof(int), 1, f );
@@ -72,6 +74,7 @@ static Mat readMatFromBin( const string& filename )
FILE* f = fopen( filename.c_str(), "rb" );
if( f )
{
+ CV_Assert(4 == sizeof(int));
int rows, cols, type, dataSize;
size_t elements_read1 = fread( (void*)&rows, sizeof(int), 1, f );
size_t elements_read2 = fread( (void*)&cols, sizeof(int), 1, f );
@@ -123,24 +126,37 @@ protected:
CV_Assert( DataType<ValueType>::type == validDescriptors.type() );
int dimension = validDescriptors.cols;
- DistanceType curMaxDist = std::numeric_limits<DistanceType>::min();
+ DistanceType curMaxDist = 0;
+ size_t exact_count = 0, failed_count = 0;
for( int y = 0; y < validDescriptors.rows; y++ )
{
DistanceType dist = distance( validDescriptors.ptr<ValueType>(y), calcDescriptors.ptr<ValueType>(y), dimension );
+ if (dist == 0)
+ exact_count++;
if( dist > curMaxDist )
+ {
+ if (dist > maxDist)
+ failed_count++;
curMaxDist = dist;
+ }
+#if 0
+ if (dist > 0)
+ {
+ std::cout << "i=" << y << " fail_count=" << failed_count << " dist=" << dist << std::endl;
+ std::cout << "valid: " << validDescriptors.row(y) << std::endl;
+ std::cout << " calc: " << calcDescriptors.row(y) << std::endl;
+ }
+#endif
}
+ float exact_percents = (100 * (float)exact_count / validDescriptors.rows);
+ float failed_percents = (100 * (float)failed_count / validDescriptors.rows);
stringstream ss;
- ss << "Max distance between valid and computed descriptors " << curMaxDist;
- if( curMaxDist <= maxDist )
- ss << "." << endl;
- else
- {
- ss << ">" << maxDist << " - bad accuracy!"<< endl;
- ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );
- }
- ts->printf(cvtest::TS::LOG, ss.str().c_str() );
+ ss << "Exact count (dist == 0): " << exact_count << " (" << (int)exact_percents << "%)" << std::endl
+ << "Failed count (dist > " << maxDist << "): " << failed_count << " (" << (int)failed_percents << "%)" << std::endl
+ << "Max distance between valid and computed descriptors (" << validDescriptors.size() << "): " << curMaxDist;
+ EXPECT_LE(failed_percents, 20.0f);
+ std::cout << ss.str() << std::endl;
}
void emptyDataTest()
@@ -202,22 +218,57 @@ protected:
ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA );
return;
}
+ const std::string keypoints_filename = string(ts->get_data_path()) +
+ (detector.empty()
+ ? (FEATURES2D_DIR + "/" + std::string("keypoints.xml.gz"))
+ : (DESCRIPTOR_DIR + "/" + name + "_keypoints.xml.gz"));
+ FileStorage fs(keypoints_filename, FileStorage::READ);
+
vector<KeyPoint> keypoints;
- FileStorage fs( string(ts->get_data_path()) + FEATURES2D_DIR + "/keypoints.xml.gz", FileStorage::READ );
- if(!detector.empty()) {
- detector->detect(img, keypoints);
- } else {
- read( fs.getFirstTopLevelNode(), keypoints );
+ EXPECT_TRUE(fs.isOpened()) << "Keypoint testdata is missing. Re-computing and re-writing keypoints testdata...";
+ if (!fs.isOpened())
+ {
+ fs.open(keypoints_filename, FileStorage::WRITE);
+ ASSERT_TRUE(fs.isOpened()) << "File for writting keypoints can not be opened.";
+ if (detector.empty())
+ {
+ Ptr<ORB> fd = ORB::create();
+ fd->detect(img, keypoints);
+ }
+ else
+ {
+ detector->detect(img, keypoints);
+ }
+ write(fs, "keypoints", keypoints);
+ fs.release();
+ }
+ else
+ {
+ read(fs.getFirstTopLevelNode(), keypoints);
+ fs.release();
}
- if(!keypoints.empty())
+
+ if(!detector.empty())
+ {
+ vector<KeyPoint> calcKeypoints;
+ detector->detect(img, calcKeypoints);
+ // TODO validate received keypoints
+ int diff = abs((int)calcKeypoints.size() - (int)keypoints.size());
+ if (diff > 0)
+ {
+ std::cout << "Keypoints difference: " << diff << std::endl;
+ EXPECT_LE(diff, (int)(keypoints.size() * 0.03f));
+ }
+ }
+ ASSERT_FALSE(keypoints.empty());
{
Mat calcDescriptors;
double t = (double)getTickCount();
- dextractor->compute( img, keypoints, calcDescriptors );
+ dextractor->compute(img, keypoints, calcDescriptors);
t = getTickCount() - t;
ts->printf(cvtest::TS::LOG, "\nAverage time of computing one descriptor = %g ms.\n", t/((double)getTickFrequency()*1000.)/calcDescriptors.rows);
- if( calcDescriptors.rows != (int)keypoints.size() )
+ if (calcDescriptors.rows != (int)keypoints.size())
{
ts->printf( cvtest::TS::LOG, "Count of computed descriptors and keypoints count must be equal.\n" );
ts->printf( cvtest::TS::LOG, "Count of keypoints is %d.\n", (int)keypoints.size() );
@@ -226,7 +277,7 @@ protected:
return;
}
- if( calcDescriptors.cols != dextractor->descriptorSize() || calcDescriptors.type() != dextractor->descriptorType() )
+ if (calcDescriptors.cols != dextractor->descriptorSize() || calcDescriptors.type() != dextractor->descriptorType())
{
ts->printf( cvtest::TS::LOG, "Incorrect descriptor size or descriptor type.\n" );
ts->printf( cvtest::TS::LOG, "Expected size is %d.\n", dextractor->descriptorSize() );
@@ -239,33 +290,14 @@ protected:
// TODO read and write descriptor extractor parameters and check them
Mat validDescriptors = readDescriptors();
- if( !validDescriptors.empty() )
- compareDescriptors( validDescriptors, calcDescriptors );
- else
- {
- if( !writeDescriptors( calcDescriptors ) )
- {
- ts->printf( cvtest::TS::LOG, "Descriptors can not be written.\n" );
- ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA );
- return;
- }
- }
- }
- if(!fs.isOpened())
- {
- ts->printf( cvtest::TS::LOG, "Compute and write keypoints.\n" );
- fs.open( string(ts->get_data_path()) + FEATURES2D_DIR + "/keypoints.xml.gz", FileStorage::WRITE );
- if( fs.isOpened() )
+ EXPECT_FALSE(validDescriptors.empty()) << "Descriptors testdata is missing. Re-writing descriptors testdata...";
+ if (!validDescriptors.empty())
{
- Ptr<ORB> fd = ORB::create();
- fd->detect(img, keypoints);
- write( fs, "keypoints", keypoints );
+ compareDescriptors(validDescriptors, calcDescriptors);
}
else
{
- ts->printf(cvtest::TS::LOG, "File for writting keypoints can not be opened.\n");
- ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA );
- return;
+ ASSERT_TRUE(writeDescriptors(calcDescriptors)) << "Descriptors can not be written.";
}
}
}
@@ -344,12 +376,20 @@ TEST( Features2d_DescriptorExtractor_KAZE, regression )
TEST( Features2d_DescriptorExtractor_AKAZE, regression )
{
CV_DescriptorExtractorTest<Hamming> test( "descriptor-akaze",
- (CV_DescriptorExtractorTest<Hamming>::DistanceType)12.f,
+ (CV_DescriptorExtractorTest<Hamming>::DistanceType)(486*0.05f),
AKAZE::create(),
Hamming(), AKAZE::create());
test.safe_run();
}
+TEST( Features2d_DescriptorExtractor_AKAZE_DESCRIPTOR_KAZE, regression )
+{
+ CV_DescriptorExtractorTest< L2<float> > test( "descriptor-akaze-with-kaze-desc", 0.03f,
+ AKAZE::create(AKAZE::DESCRIPTOR_KAZE),
+ L2<float>(), AKAZE::create(AKAZE::DESCRIPTOR_KAZE));
+ test.safe_run();
+}
+
TEST( Features2d_DescriptorExtractor, batch )
{
string path = string(cvtest::TS::ptr()->get_data_path() + "detectors_descriptors_evaluation/images_datasets/graf");
@@ -378,68 +418,82 @@ TEST( Features2d_DescriptorExtractor, batch )
}
}
-TEST( Features2d_Feature2d, no_crash )
+class DescriptorImage : public TestWithParam<std::string>
+{
+protected:
+ virtual void SetUp() {
+ pattern = GetParam();
+ }
+
+ std::string pattern;
+};
+
+TEST_P(DescriptorImage, no_crash)
{
- const String& pattern = string(cvtest::TS::ptr()->get_data_path() + "shared/*.png");
vector<String> fnames;
- glob(pattern, fnames, false);
+ glob(cvtest::TS::ptr()->get_data_path() + pattern, fnames, false);
sort(fnames.begin(), fnames.end());
- Ptr<AKAZE> akaze = AKAZE::create();
+ Ptr<AKAZE> akaze_mldb = AKAZE::create(AKAZE::DESCRIPTOR_MLDB);
+ Ptr<AKAZE> akaze_mldb_upright = AKAZE::create(AKAZE::DESCRIPTOR_MLDB_UPRIGHT);
+ Ptr<AKAZE> akaze_mldb_256 = AKAZE::create(AKAZE::DESCRIPTOR_MLDB, 256);
+ Ptr<AKAZE> akaze_mldb_upright_256 = AKAZE::create(AKAZE::DESCRIPTOR_MLDB_UPRIGHT, 256);
+ Ptr<AKAZE> akaze_kaze = AKAZE::create(AKAZE::DESCRIPTOR_KAZE);
+ Ptr<AKAZE> akaze_kaze_upright = AKAZE::create(AKAZE::DESCRIPTOR_KAZE_UPRIGHT);
Ptr<ORB> orb = ORB::create();
Ptr<KAZE> kaze = KAZE::create();
Ptr<BRISK> brisk = BRISK::create();
- size_t i, n = fnames.size();
+ size_t n = fnames.size();
vector<KeyPoint> keypoints;
Mat descriptors;
orb->setMaxFeatures(5000);
- for( i = 0; i < n; i++ )
+ for(size_t i = 0; i < n; i++ )
{
printf("%d. image: %s:\n", (int)i, fnames[i].c_str());
if( strstr(fnames[i].c_str(), "MP.png") != 0 )
+ {
+ printf("\tskip\n");
continue;
+ }
bool checkCount = strstr(fnames[i].c_str(), "templ.png") == 0;
Mat img = imread(fnames[i], -1);
- printf("\tAKAZE ... "); fflush(stdout);
- akaze->detectAndCompute(img, noArray(), keypoints, descriptors);
- printf("(%d keypoints) ", (int)keypoints.size()); fflush(stdout);
- if( checkCount )
- {
- EXPECT_GT((int)keypoints.size(), 0);
- }
- ASSERT_EQ(descriptors.rows, (int)keypoints.size());
- printf("ok\n");
- printf("\tKAZE ... "); fflush(stdout);
- kaze->detectAndCompute(img, noArray(), keypoints, descriptors);
- printf("(%d keypoints) ", (int)keypoints.size()); fflush(stdout);
- if( checkCount )
- {
- EXPECT_GT((int)keypoints.size(), 0);
- }
+ printf("\t%dx%d\n", img.cols, img.rows);
+
+#define TEST_DETECTOR(name, descriptor) \
+ keypoints.clear(); descriptors.release(); \
+ printf("\t" name "\n"); fflush(stdout); \
+ descriptor->detectAndCompute(img, noArray(), keypoints, descriptors); \
+ printf("\t\t\t(%d keypoints, descriptor size = %d)\n", (int)keypoints.size(), descriptors.cols); fflush(stdout); \
+ if (checkCount) \
+ { \
+ EXPECT_GT((int)keypoints.size(), 0); \
+ } \
ASSERT_EQ(descriptors.rows, (int)keypoints.size());
- printf("ok\n");
- printf("\tORB ... "); fflush(stdout);
- orb->detectAndCompute(img, noArray(), keypoints, descriptors);
- printf("(%d keypoints) ", (int)keypoints.size()); fflush(stdout);
- if( checkCount )
- {
- EXPECT_GT((int)keypoints.size(), 0);
- }
- ASSERT_EQ(descriptors.rows, (int)keypoints.size());
- printf("ok\n");
-
- printf("\tBRISK ... "); fflush(stdout);
- brisk->detectAndCompute(img, noArray(), keypoints, descriptors);
- printf("(%d keypoints) ", (int)keypoints.size()); fflush(stdout);
- if( checkCount )
- {
- EXPECT_GT((int)keypoints.size(), 0);
- }
- ASSERT_EQ(descriptors.rows, (int)keypoints.size());
- printf("ok\n");
+ TEST_DETECTOR("AKAZE:MLDB", akaze_mldb);
+ TEST_DETECTOR("AKAZE:MLDB_UPRIGHT", akaze_mldb_upright);
+ TEST_DETECTOR("AKAZE:MLDB_256", akaze_mldb_256);
+ TEST_DETECTOR("AKAZE:MLDB_UPRIGHT_256", akaze_mldb_upright_256);
+ TEST_DETECTOR("AKAZE:KAZE", akaze_kaze);
+ TEST_DETECTOR("AKAZE:KAZE_UPRIGHT", akaze_kaze_upright);
+ TEST_DETECTOR("KAZE", kaze);
+ TEST_DETECTOR("ORB", orb);
+ TEST_DETECTOR("BRISK", brisk);
}
}
+
+INSTANTIATE_TEST_CASE_P(Features2d, DescriptorImage,
+ testing::Values(
+ "shared/lena.png",
+ "shared/box*.png",
+ "shared/fruits*.png",
+ "shared/airplane.png",
+ "shared/graffiti.png",
+ "shared/1_itseez-0001*.png",
+ "shared/pic*.png",
+ "shared/templ.png"
+ )
+);
diff --git a/modules/features2d/test/test_detectors_invariance.cpp b/modules/features2d/test/test_detectors_invariance.cpp
new file mode 100644
index 0000000..873bf46
--- /dev/null
+++ b/modules/features2d/test/test_detectors_invariance.cpp
@@ -0,0 +1,255 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#include "test_precomp.hpp"
+#include "test_invariance_utils.hpp"
+
+using namespace std;
+using namespace cv;
+using std::tr1::make_tuple;
+using std::tr1::get;
+using namespace testing;
+
+#define SHOW_DEBUG_LOG 1
+
+typedef std::tr1::tuple<std::string, Ptr<FeatureDetector>, float, float> String_FeatureDetector_Float_Float_t;
+const static std::string IMAGE_TSUKUBA = "features2d/tsukuba.png";
+const static std::string IMAGE_BIKES = "detectors_descriptors_evaluation/images_datasets/bikes/img1.png";
+#define Value(...) Values(String_FeatureDetector_Float_Float_t(__VA_ARGS__))
+
+static
+void matchKeyPoints(const vector<KeyPoint>& keypoints0, const Mat& H,
+ const vector<KeyPoint>& keypoints1,
+ vector<DMatch>& matches)
+{
+ vector<Point2f> points0;
+ KeyPoint::convert(keypoints0, points0);
+ Mat points0t;
+ if(H.empty())
+ points0t = Mat(points0);
+ else
+ perspectiveTransform(Mat(points0), points0t, H);
+
+ matches.clear();
+ vector<uchar> usedMask(keypoints1.size(), 0);
+ for(int i0 = 0; i0 < static_cast<int>(keypoints0.size()); i0++)
+ {
+ int nearestPointIndex = -1;
+ float maxIntersectRatio = 0.f;
+ const float r0 = 0.5f * keypoints0[i0].size;
+ for(size_t i1 = 0; i1 < keypoints1.size(); i1++)
+ {
+ if(nearestPointIndex >= 0 && usedMask[i1])
+ continue;
+
+ float r1 = 0.5f * keypoints1[i1].size;
+ float intersectRatio = calcIntersectRatio(points0t.at<Point2f>(i0), r0,
+ keypoints1[i1].pt, r1);
+ if(intersectRatio > maxIntersectRatio)
+ {
+ maxIntersectRatio = intersectRatio;
+ nearestPointIndex = static_cast<int>(i1);
+ }
+ }
+
+ matches.push_back(DMatch(i0, nearestPointIndex, maxIntersectRatio));
+ if(nearestPointIndex >= 0)
+ usedMask[nearestPointIndex] = 1;
+ }
+}
+
+class DetectorInvariance : public TestWithParam<String_FeatureDetector_Float_Float_t>
+{
+protected:
+ virtual void SetUp() {
+ // Read test data
+ const std::string filename = cvtest::TS::ptr()->get_data_path() + get<0>(GetParam());
+ image0 = imread(filename);
+ ASSERT_FALSE(image0.empty()) << "couldn't read input image";
+
+ featureDetector = get<1>(GetParam());
+ minKeyPointMatchesRatio = get<2>(GetParam());
+ minInliersRatio = get<3>(GetParam());
+ }
+
+ Ptr<FeatureDetector> featureDetector;
+ float minKeyPointMatchesRatio;
+ float minInliersRatio;
+ Mat image0;
+};
+
+typedef DetectorInvariance DetectorScaleInvariance;
+typedef DetectorInvariance DetectorRotationInvariance;
+
+TEST_P(DetectorRotationInvariance, rotation)
+{
+ Mat image1, mask1;
+ const int borderSize = 16;
+ Mat mask0(image0.size(), CV_8UC1, Scalar(0));
+ mask0(Rect(borderSize, borderSize, mask0.cols - 2*borderSize, mask0.rows - 2*borderSize)).setTo(Scalar(255));
+
+ vector<KeyPoint> keypoints0;
+ featureDetector->detect(image0, keypoints0, mask0);
+ EXPECT_GE(keypoints0.size(), 15u);
+
+ const int maxAngle = 360, angleStep = 15;
+ for(int angle = 0; angle < maxAngle; angle += angleStep)
+ {
+ Mat H = rotateImage(image0, mask0, static_cast<float>(angle), image1, mask1);
+
+ vector<KeyPoint> keypoints1;
+ featureDetector->detect(image1, keypoints1, mask1);
+
+ vector<DMatch> matches;
+ matchKeyPoints(keypoints0, H, keypoints1, matches);
+
+ int angleInliersCount = 0;
+
+ const float minIntersectRatio = 0.5f;
+ int keyPointMatchesCount = 0;
+ for(size_t m = 0; m < matches.size(); m++)
+ {
+ if(matches[m].distance < minIntersectRatio)
+ continue;
+
+ keyPointMatchesCount++;
+
+ // Check does this inlier have consistent angles
+ const float maxAngleDiff = 15.f; // grad
+ float angle0 = keypoints0[matches[m].queryIdx].angle;
+ float angle1 = keypoints1[matches[m].trainIdx].angle;
+ ASSERT_FALSE(angle0 == -1 || angle1 == -1) << "Given FeatureDetector is not rotation invariant, it can not be tested here.";
+ ASSERT_GE(angle0, 0.f);
+ ASSERT_LT(angle0, 360.f);
+ ASSERT_GE(angle1, 0.f);
+ ASSERT_LT(angle1, 360.f);
+
+ float rotAngle0 = angle0 + angle;
+ if(rotAngle0 >= 360.f)
+ rotAngle0 -= 360.f;
+
+ float angleDiff = std::max(rotAngle0, angle1) - std::min(rotAngle0, angle1);
+ angleDiff = std::min(angleDiff, static_cast<float>(360.f - angleDiff));
+ ASSERT_GE(angleDiff, 0.f);
+ bool isAngleCorrect = angleDiff < maxAngleDiff;
+ if(isAngleCorrect)
+ angleInliersCount++;
+ }
+
+ float keyPointMatchesRatio = static_cast<float>(keyPointMatchesCount) / keypoints0.size();
+ EXPECT_GE(keyPointMatchesRatio, minKeyPointMatchesRatio) << "angle: " << angle;
+
+ if(keyPointMatchesCount)
+ {
+ float angleInliersRatio = static_cast<float>(angleInliersCount) / keyPointMatchesCount;
+ EXPECT_GE(angleInliersRatio, minInliersRatio) << "angle: " << angle;
+ }
+#if SHOW_DEBUG_LOG
+ std::cout
+ << "angle = " << angle
+ << ", keypoints = " << keypoints1.size()
+ << ", keyPointMatchesRatio = " << keyPointMatchesRatio
+ << ", angleInliersRatio = " << (keyPointMatchesCount ? (static_cast<float>(angleInliersCount) / keyPointMatchesCount) : 0)
+ << std::endl;
+#endif
+ }
+}
+
+TEST_P(DetectorScaleInvariance, scale)
+{
+ vector<KeyPoint> keypoints0;
+ featureDetector->detect(image0, keypoints0);
+ EXPECT_GE(keypoints0.size(), 15u);
+
+ for(int scaleIdx = 1; scaleIdx <= 3; scaleIdx++)
+ {
+ float scale = 1.f + scaleIdx * 0.5f;
+ Mat image1;
+ resize(image0, image1, Size(), 1./scale, 1./scale);
+
+ vector<KeyPoint> keypoints1, osiKeypoints1; // osi - original size image
+ featureDetector->detect(image1, keypoints1);
+ EXPECT_GE(keypoints1.size(), 15u);
+ EXPECT_LE(keypoints1.size(), keypoints0.size()) << "Strange behavior of the detector. "
+ "It gives more points count in an image of the smaller size.";
+
+ scaleKeyPoints(keypoints1, osiKeypoints1, scale);
+ vector<DMatch> matches;
+ // image1 is query image (it's reduced image0)
+ // image0 is train image
+ matchKeyPoints(osiKeypoints1, Mat(), keypoints0, matches);
+
+ const float minIntersectRatio = 0.5f;
+ int keyPointMatchesCount = 0;
+ int scaleInliersCount = 0;
+
+ for(size_t m = 0; m < matches.size(); m++)
+ {
+ if(matches[m].distance < minIntersectRatio)
+ continue;
+
+ keyPointMatchesCount++;
+
+ // Check does this inlier have consistent sizes
+ const float maxSizeDiff = 0.8f;//0.9f; // grad
+ float size0 = keypoints0[matches[m].trainIdx].size;
+ float size1 = osiKeypoints1[matches[m].queryIdx].size;
+ ASSERT_GT(size0, 0);
+ ASSERT_GT(size1, 0);
+ if(std::min(size0, size1) > maxSizeDiff * std::max(size0, size1))
+ scaleInliersCount++;
+ }
+
+ float keyPointMatchesRatio = static_cast<float>(keyPointMatchesCount) / keypoints1.size();
+ EXPECT_GE(keyPointMatchesRatio, minKeyPointMatchesRatio);
+
+ if(keyPointMatchesCount)
+ {
+ float scaleInliersRatio = static_cast<float>(scaleInliersCount) / keyPointMatchesCount;
+ EXPECT_GE(scaleInliersRatio, minInliersRatio);
+ }
+#if SHOW_DEBUG_LOG
+ std::cout
+ << "scale = " << scale
+ << ", keyPointMatchesRatio = " << keyPointMatchesRatio
+ << ", scaleInliersRatio = " << (keyPointMatchesCount ? static_cast<float>(scaleInliersCount) / keyPointMatchesCount : 0)
+ << std::endl;
+#endif
+ }
+}
+
+/*
+ * Detector's rotation invariance check
+ */
+
+INSTANTIATE_TEST_CASE_P(BRISK, DetectorRotationInvariance,
+ Value(IMAGE_TSUKUBA, BRISK::create(), 0.45f, 0.76f));
+
+INSTANTIATE_TEST_CASE_P(ORB, DetectorRotationInvariance,
+ Value(IMAGE_TSUKUBA, ORB::create(), 0.5f, 0.76f));
+
+INSTANTIATE_TEST_CASE_P(AKAZE, DetectorRotationInvariance,
+ Value(IMAGE_TSUKUBA, AKAZE::create(), 0.5f, 0.71f));
+
+INSTANTIATE_TEST_CASE_P(AKAZE_DESCRIPTOR_KAZE, DetectorRotationInvariance,
+ Value(IMAGE_TSUKUBA, AKAZE::create(AKAZE::DESCRIPTOR_KAZE), 0.5f, 0.71f));
+
+/*
+ * Detector's scale invariance check
+ */
+
+INSTANTIATE_TEST_CASE_P(BRISK, DetectorScaleInvariance,
+ Value(IMAGE_BIKES, BRISK::create(), 0.08f, 0.49f));
+
+INSTANTIATE_TEST_CASE_P(ORB, DetectorScaleInvariance,
+ Value(IMAGE_BIKES, ORB::create(), 0.08f, 0.49f));
+
+INSTANTIATE_TEST_CASE_P(KAZE, DetectorScaleInvariance,
+ Value(IMAGE_BIKES, KAZE::create(), 0.08f, 0.49f));
+
+INSTANTIATE_TEST_CASE_P(AKAZE, DetectorScaleInvariance,
+ Value(IMAGE_BIKES, AKAZE::create(), 0.08f, 0.49f));
+
+INSTANTIATE_TEST_CASE_P(AKAZE_DESCRIPTOR_KAZE, DetectorScaleInvariance,
+ Value(IMAGE_BIKES, AKAZE::create(AKAZE::DESCRIPTOR_KAZE), 0.08f, 0.49f));
diff --git a/modules/features2d/test/test_detectors_regression.cpp b/modules/features2d/test/test_detectors_regression.cpp
index 9b6d489..17a8b09 100644
--- a/modules/features2d/test/test_detectors_regression.cpp
+++ b/modules/features2d/test/test_detectors_regression.cpp
@@ -302,22 +302,8 @@ TEST( Features2d_Detector_AKAZE, regression )
test.safe_run();
}
-TEST( Features2d_Detector_AKAZE, detect_and_compute_split )
+TEST( Features2d_Detector_AKAZE_DESCRIPTOR_KAZE, regression )
{
- Mat testImg(100, 100, CV_8U);
- RNG rng(101);
- rng.fill(testImg, RNG::UNIFORM, Scalar(0), Scalar(255), true);
-
- Ptr<Feature2D> ext = AKAZE::create(AKAZE::DESCRIPTOR_MLDB, 0, 3, 0.001f, 1, 1, KAZE::DIFF_PM_G2);
- vector<KeyPoint> detAndCompKps;
- Mat desc;
- ext->detectAndCompute(testImg, noArray(), detAndCompKps, desc);
-
- vector<KeyPoint> detKps;
- ext->detect(testImg, detKps);
-
- ASSERT_EQ(detKps.size(), detAndCompKps.size());
-
- for(size_t i = 0; i < detKps.size(); i++)
- ASSERT_EQ(detKps[i].hash(), detAndCompKps[i].hash());
+ CV_FeatureDetectorTest test( "detector-akaze-with-kaze-desc", AKAZE::create(AKAZE::DESCRIPTOR_KAZE) );
+ test.safe_run();
}
diff --git a/modules/features2d/test/test_invariance_utils.hpp b/modules/features2d/test/test_invariance_utils.hpp
new file mode 100644
index 0000000..8ace94c
--- /dev/null
+++ b/modules/features2d/test/test_invariance_utils.hpp
@@ -0,0 +1,92 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#ifndef __OPENCV_TEST_INVARIANCE_UTILS_HPP__
+#define __OPENCV_TEST_INVARIANCE_UTILS_HPP__
+
+#include "test_precomp.hpp"
+
+using namespace std;
+using namespace cv;
+
+static
+Mat generateHomography(float angle)
+{
+ // angle - rotation around Oz in degrees
+ float angleRadian = static_cast<float>(angle * CV_PI / 180);
+ Mat H = Mat::eye(3, 3, CV_32FC1);
+ H.at<float>(0,0) = H.at<float>(1,1) = std::cos(angleRadian);
+ H.at<float>(0,1) = -std::sin(angleRadian);
+ H.at<float>(1,0) = std::sin(angleRadian);
+
+ return H;
+}
+
+static
+Mat rotateImage(const Mat& srcImage, const Mat& srcMask, float angle, Mat& dstImage, Mat& dstMask)
+{
+ // angle - rotation around Oz in degrees
+ float diag = std::sqrt(static_cast<float>(srcImage.cols * srcImage.cols + srcImage.rows * srcImage.rows));
+ Mat LUShift = Mat::eye(3, 3, CV_32FC1); // left up
+ LUShift.at<float>(0,2) = static_cast<float>(-srcImage.cols/2);
+ LUShift.at<float>(1,2) = static_cast<float>(-srcImage.rows/2);
+ Mat RDShift = Mat::eye(3, 3, CV_32FC1); // right down
+ RDShift.at<float>(0,2) = diag/2;
+ RDShift.at<float>(1,2) = diag/2;
+ Size sz(cvRound(diag), cvRound(diag));
+
+ Mat H = RDShift * generateHomography(angle) * LUShift;
+ warpPerspective(srcImage, dstImage, H, sz);
+ warpPerspective(srcMask, dstMask, H, sz);
+
+ return H;
+}
+
+static
+float calcCirclesIntersectArea(const Point2f& p0, float r0, const Point2f& p1, float r1)
+{
+ float c = static_cast<float>(norm(p0 - p1)), sqr_c = c * c;
+
+ float sqr_r0 = r0 * r0;
+ float sqr_r1 = r1 * r1;
+
+ if(r0 + r1 <= c)
+ return 0;
+
+ float minR = std::min(r0, r1);
+ float maxR = std::max(r0, r1);
+ if(c + minR <= maxR)
+ return static_cast<float>(CV_PI * minR * minR);
+
+ float cos_halfA0 = (sqr_r0 + sqr_c - sqr_r1) / (2 * r0 * c);
+ float cos_halfA1 = (sqr_r1 + sqr_c - sqr_r0) / (2 * r1 * c);
+
+ float A0 = 2 * acos(cos_halfA0);
+ float A1 = 2 * acos(cos_halfA1);
+
+ return 0.5f * sqr_r0 * (A0 - sin(A0)) +
+ 0.5f * sqr_r1 * (A1 - sin(A1));
+}
+
+static
+float calcIntersectRatio(const Point2f& p0, float r0, const Point2f& p1, float r1)
+{
+ float intersectArea = calcCirclesIntersectArea(p0, r0, p1, r1);
+ float unionArea = static_cast<float>(CV_PI) * (r0 * r0 + r1 * r1) - intersectArea;
+ return intersectArea / unionArea;
+}
+
+static
+void scaleKeyPoints(const vector<KeyPoint>& src, vector<KeyPoint>& dst, float scale)
+{
+ dst.resize(src.size());
+ for (size_t i = 0; i < src.size(); i++) {
+ dst[i] = src[i];
+ dst[i].pt.x *= scale;
+ dst[i].pt.y *= scale;
+ dst[i].size *= scale;
+ }
+}
+
+#endif // __OPENCV_TEST_INVARIANCE_UTILS_HPP__
diff --git a/modules/features2d/test/test_mser.cpp b/modules/features2d/test/test_mser.cpp
index a52c3c3..a92e628 100644
--- a/modules/features2d/test/test_mser.cpp
+++ b/modules/features2d/test/test_mser.cpp
@@ -159,3 +159,26 @@ TEST(Features2d_MSER, cases)
ASSERT_GE(maxRegs, nmsers);
}
}
+
+TEST(Features2d_MSER, history_update_regression)
+{
+ String dataPath = cvtest::TS::ptr()->get_data_path() + "mser/";
+ vector<Mat> tstImages;
+ tstImages.push_back(imread(dataPath + "mser_test.png", IMREAD_GRAYSCALE));
+ tstImages.push_back(imread(dataPath + "mser_test2.png", IMREAD_GRAYSCALE));
+
+ for(size_t j = 0; j < tstImages.size(); j++)
+ {
+ size_t previous_size = 0;
+ for(int minArea = 100; minArea > 10; minArea--)
+ {
+ Ptr<MSER> mser = MSER::create(1, minArea, (int)(tstImages[j].cols * tstImages[j].rows * 0.2));
+ mser->setPass2Only(true);
+ vector<vector<Point> > mserContours;
+ vector<Rect> boxRects;
+ mser->detectRegions(tstImages[j], mserContours, boxRects);
+ ASSERT_LE(previous_size, mserContours.size());
+ previous_size = mserContours.size();
+ }
+ }
+}
diff --git a/modules/features2d/test/test_precomp.hpp b/modules/features2d/test/test_precomp.hpp
index 893b29b..bce72f7 100644
--- a/modules/features2d/test/test_precomp.hpp
+++ b/modules/features2d/test/test_precomp.hpp
@@ -13,7 +13,6 @@
#include "opencv2/imgproc.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/imgcodecs.hpp"
-#include "opencv2/ml.hpp"
#include <iostream>
#endif
diff --git a/modules/features2d/test/test_rotation_and_scale_invariance.cpp b/modules/features2d/test/test_rotation_and_scale_invariance.cpp
deleted file mode 100644
index 072adc4..0000000
--- a/modules/features2d/test/test_rotation_and_scale_invariance.cpp
+++ /dev/null
@@ -1,717 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// Intel License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of Intel Corporation may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-
-using namespace std;
-using namespace cv;
-
-const string IMAGE_TSUKUBA = "/features2d/tsukuba.png";
-const string IMAGE_BIKES = "/detectors_descriptors_evaluation/images_datasets/bikes/img1.png";
-
-#define SHOW_DEBUG_LOG 1
-
-static
-Mat generateHomography(float angle)
-{
- // angle - rotation around Oz in degrees
- float angleRadian = static_cast<float>(angle * CV_PI / 180);
- Mat H = Mat::eye(3, 3, CV_32FC1);
- H.at<float>(0,0) = H.at<float>(1,1) = std::cos(angleRadian);
- H.at<float>(0,1) = -std::sin(angleRadian);
- H.at<float>(1,0) = std::sin(angleRadian);
-
- return H;
-}
-
-static
-Mat rotateImage(const Mat& srcImage, const Mat& srcMask, float angle, Mat& dstImage, Mat& dstMask)
-{
- // angle - rotation around Oz in degrees
- float diag = std::sqrt(static_cast<float>(srcImage.cols * srcImage.cols + srcImage.rows * srcImage.rows));
- Mat LUShift = Mat::eye(3, 3, CV_32FC1); // left up
- LUShift.at<float>(0,2) = static_cast<float>(-srcImage.cols/2);
- LUShift.at<float>(1,2) = static_cast<float>(-srcImage.rows/2);
- Mat RDShift = Mat::eye(3, 3, CV_32FC1); // right down
- RDShift.at<float>(0,2) = diag/2;
- RDShift.at<float>(1,2) = diag/2;
- Size sz(cvRound(diag), cvRound(diag));
-
- Mat H = RDShift * generateHomography(angle) * LUShift;
- warpPerspective(srcImage, dstImage, H, sz);
- warpPerspective(srcMask, dstMask, H, sz);
-
- return H;
-}
-
-void rotateKeyPoints(const vector<KeyPoint>& src, const Mat& H, float angle, vector<KeyPoint>& dst)
-{
- // suppose that H is rotation given from rotateImage() and angle has value passed to rotateImage()
- vector<Point2f> srcCenters, dstCenters;
- KeyPoint::convert(src, srcCenters);
-
- perspectiveTransform(srcCenters, dstCenters, H);
-
- dst = src;
- for(size_t i = 0; i < dst.size(); i++)
- {
- dst[i].pt = dstCenters[i];
- float dstAngle = src[i].angle + angle;
- if(dstAngle >= 360.f)
- dstAngle -= 360.f;
- dst[i].angle = dstAngle;
- }
-}
-
-void scaleKeyPoints(const vector<KeyPoint>& src, vector<KeyPoint>& dst, float scale)
-{
- dst.resize(src.size());
- for(size_t i = 0; i < src.size(); i++)
- dst[i] = KeyPoint(src[i].pt.x * scale, src[i].pt.y * scale, src[i].size * scale, src[i].angle);
-}
-
-static
-float calcCirclesIntersectArea(const Point2f& p0, float r0, const Point2f& p1, float r1)
-{
- float c = static_cast<float>(norm(p0 - p1)), sqr_c = c * c;
-
- float sqr_r0 = r0 * r0;
- float sqr_r1 = r1 * r1;
-
- if(r0 + r1 <= c)
- return 0;
-
- float minR = std::min(r0, r1);
- float maxR = std::max(r0, r1);
- if(c + minR <= maxR)
- return static_cast<float>(CV_PI * minR * minR);
-
- float cos_halfA0 = (sqr_r0 + sqr_c - sqr_r1) / (2 * r0 * c);
- float cos_halfA1 = (sqr_r1 + sqr_c - sqr_r0) / (2 * r1 * c);
-
- float A0 = 2 * acos(cos_halfA0);
- float A1 = 2 * acos(cos_halfA1);
-
- return 0.5f * sqr_r0 * (A0 - sin(A0)) +
- 0.5f * sqr_r1 * (A1 - sin(A1));
-}
-
-static
-float calcIntersectRatio(const Point2f& p0, float r0, const Point2f& p1, float r1)
-{
- float intersectArea = calcCirclesIntersectArea(p0, r0, p1, r1);
- float unionArea = static_cast<float>(CV_PI) * (r0 * r0 + r1 * r1) - intersectArea;
- return intersectArea / unionArea;
-}
-
-static
-void matchKeyPoints(const vector<KeyPoint>& keypoints0, const Mat& H,
- const vector<KeyPoint>& keypoints1,
- vector<DMatch>& matches)
-{
- vector<Point2f> points0;
- KeyPoint::convert(keypoints0, points0);
- Mat points0t;
- if(H.empty())
- points0t = Mat(points0);
- else
- perspectiveTransform(Mat(points0), points0t, H);
-
- matches.clear();
- vector<uchar> usedMask(keypoints1.size(), 0);
- for(int i0 = 0; i0 < static_cast<int>(keypoints0.size()); i0++)
- {
- int nearestPointIndex = -1;
- float maxIntersectRatio = 0.f;
- const float r0 = 0.5f * keypoints0[i0].size;
- for(size_t i1 = 0; i1 < keypoints1.size(); i1++)
- {
- if(nearestPointIndex >= 0 && usedMask[i1])
- continue;
-
- float r1 = 0.5f * keypoints1[i1].size;
- float intersectRatio = calcIntersectRatio(points0t.at<Point2f>(i0), r0,
- keypoints1[i1].pt, r1);
- if(intersectRatio > maxIntersectRatio)
- {
- maxIntersectRatio = intersectRatio;
- nearestPointIndex = static_cast<int>(i1);
- }
- }
-
- matches.push_back(DMatch(i0, nearestPointIndex, maxIntersectRatio));
- if(nearestPointIndex >= 0)
- usedMask[nearestPointIndex] = 1;
- }
-}
-
-class DetectorRotationInvarianceTest : public cvtest::BaseTest
-{
-public:
- DetectorRotationInvarianceTest(const Ptr<FeatureDetector>& _featureDetector,
- float _minKeyPointMatchesRatio,
- float _minAngleInliersRatio) :
- featureDetector(_featureDetector),
- minKeyPointMatchesRatio(_minKeyPointMatchesRatio),
- minAngleInliersRatio(_minAngleInliersRatio)
- {
- CV_Assert(featureDetector);
- }
-
-protected:
-
- void run(int)
- {
- const string imageFilename = string(ts->get_data_path()) + IMAGE_TSUKUBA;
-
- // Read test data
- Mat image0 = imread(imageFilename), image1, mask1;
- if(image0.empty())
- {
- ts->printf(cvtest::TS::LOG, "Image %s can not be read.\n", imageFilename.c_str());
- ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
- return;
- }
- std::cout << "Image: " << image0.size() << std::endl;
-
- const int borderSize = 16;
- Mat mask0(image0.size(), CV_8UC1, Scalar(0));
- mask0(Rect(borderSize, borderSize, mask0.cols - 2*borderSize, mask0.rows - 2*borderSize)).setTo(Scalar(255));
-
- vector<KeyPoint> keypoints0;
- featureDetector->detect(image0, keypoints0, mask0);
- std::cout << "Intial keypoints: " << keypoints0.size() << std::endl;
- if(keypoints0.size() < 15)
- CV_Error(Error::StsAssert, "Detector gives too few points in a test image\n");
-
- const int maxAngle = 360, angleStep = 15;
- for(int angle = 0; angle < maxAngle; angle += angleStep)
- {
- Mat H = rotateImage(image0, mask0, static_cast<float>(angle), image1, mask1);
-
- vector<KeyPoint> keypoints1;
- featureDetector->detect(image1, keypoints1, mask1);
-
- vector<DMatch> matches;
- matchKeyPoints(keypoints0, H, keypoints1, matches);
-
- int angleInliersCount = 0;
-
- const float minIntersectRatio = 0.5f;
- int keyPointMatchesCount = 0;
- for(size_t m = 0; m < matches.size(); m++)
- {
- if(matches[m].distance < minIntersectRatio)
- continue;
-
- keyPointMatchesCount++;
-
- // Check does this inlier have consistent angles
- const float maxAngleDiff = 15.f; // grad
- float angle0 = keypoints0[matches[m].queryIdx].angle;
- float angle1 = keypoints1[matches[m].trainIdx].angle;
- if(angle0 == -1 || angle1 == -1)
- CV_Error(Error::StsBadArg, "Given FeatureDetector is not rotation invariant, it can not be tested here.\n");
- CV_Assert(angle0 >= 0.f && angle0 < 360.f);
- CV_Assert(angle1 >= 0.f && angle1 < 360.f);
-
- float rotAngle0 = angle0 + angle;
- if(rotAngle0 >= 360.f)
- rotAngle0 -= 360.f;
-
- float angleDiff = std::max(rotAngle0, angle1) - std::min(rotAngle0, angle1);
- angleDiff = std::min(angleDiff, static_cast<float>(360.f - angleDiff));
- CV_Assert(angleDiff >= 0.f);
- bool isAngleCorrect = angleDiff < maxAngleDiff;
- if(isAngleCorrect)
- angleInliersCount++;
- }
-
- float keyPointMatchesRatio = static_cast<float>(keyPointMatchesCount) / keypoints0.size();
- if(keyPointMatchesRatio < minKeyPointMatchesRatio)
- {
- ts->printf(cvtest::TS::LOG, "Angle: %f: Incorrect keyPointMatchesRatio: curr = %f, min = %f (matched=%d total=%d - %d).\n",
- (float)angle, keyPointMatchesRatio, minKeyPointMatchesRatio, (int)keyPointMatchesCount, (int)keypoints0.size(), (int)keypoints1.size());
- ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
- }
-
- if(keyPointMatchesCount)
- {
- float angleInliersRatio = static_cast<float>(angleInliersCount) / keyPointMatchesCount;
- if(angleInliersRatio < minAngleInliersRatio)
- {
- ts->printf(cvtest::TS::LOG, "Angle: %f: Incorrect angleInliersRatio: curr = %f, min = %f.\n",
- (float)angle, angleInliersRatio, minAngleInliersRatio);
- ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
- }
- }
-#if SHOW_DEBUG_LOG
- std::cout
- << "angle = " << angle
- << ", keypoints = " << keypoints1.size()
- << ", keyPointMatchesRatio = " << keyPointMatchesRatio
- << ", angleInliersRatio = " << (keyPointMatchesCount ? (static_cast<float>(angleInliersCount) / keyPointMatchesCount) : 0)
- << std::endl;
-#endif
- }
- ts->set_failed_test_info( cvtest::TS::OK );
- }
-
- Ptr<FeatureDetector> featureDetector;
- float minKeyPointMatchesRatio;
- float minAngleInliersRatio;
-};
-
-class DescriptorRotationInvarianceTest : public cvtest::BaseTest
-{
-public:
- DescriptorRotationInvarianceTest(const Ptr<FeatureDetector>& _featureDetector,
- const Ptr<DescriptorExtractor>& _descriptorExtractor,
- int _normType,
- float _minDescInliersRatio) :
- featureDetector(_featureDetector),
- descriptorExtractor(_descriptorExtractor),
- normType(_normType),
- minDescInliersRatio(_minDescInliersRatio)
- {
- CV_Assert(featureDetector);
- CV_Assert(descriptorExtractor);
- }
-
-protected:
-
- void run(int)
- {
- const string imageFilename = string(ts->get_data_path()) + IMAGE_TSUKUBA;
-
- // Read test data
- Mat image0 = imread(imageFilename), image1, mask1;
- if(image0.empty())
- {
- ts->printf(cvtest::TS::LOG, "Image %s can not be read.\n", imageFilename.c_str());
- ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
- return;
- }
- std::cout << "Image: " << image0.size() << std::endl;
-
- const int borderSize = 16;
- Mat mask0(image0.size(), CV_8UC1, Scalar(0));
- mask0(Rect(borderSize, borderSize, mask0.cols - 2*borderSize, mask0.rows - 2*borderSize)).setTo(Scalar(255));
-
- vector<KeyPoint> keypoints0;
- Mat descriptors0;
- featureDetector->detect(image0, keypoints0, mask0);
- std::cout << "Intial keypoints: " << keypoints0.size() << std::endl;
- if(keypoints0.size() < 15)
- CV_Error(Error::StsAssert, "Detector gives too few points in a test image\n");
- descriptorExtractor->compute(image0, keypoints0, descriptors0);
-
- BFMatcher bfmatcher(normType);
-
- const float minIntersectRatio = 0.5f;
- const int maxAngle = 360, angleStep = 15;
- for(int angle = 0; angle < maxAngle; angle += angleStep)
- {
- Mat H = rotateImage(image0, mask0, static_cast<float>(angle), image1, mask1);
-
- vector<KeyPoint> keypoints1;
- rotateKeyPoints(keypoints0, H, static_cast<float>(angle), keypoints1);
- Mat descriptors1;
- descriptorExtractor->compute(image1, keypoints1, descriptors1);
-
- vector<DMatch> descMatches;
- bfmatcher.match(descriptors0, descriptors1, descMatches);
-
- int descInliersCount = 0;
- for(size_t m = 0; m < descMatches.size(); m++)
- {
- const KeyPoint& transformed_p0 = keypoints1[descMatches[m].queryIdx];
- const KeyPoint& p1 = keypoints1[descMatches[m].trainIdx];
- if(calcIntersectRatio(transformed_p0.pt, 0.5f * transformed_p0.size,
- p1.pt, 0.5f * p1.size) >= minIntersectRatio)
- {
- descInliersCount++;
- }
- }
-
- float descInliersRatio = static_cast<float>(descInliersCount) / keypoints0.size();
- if(descInliersRatio < minDescInliersRatio)
- {
- ts->printf(cvtest::TS::LOG, "Incorrect descInliersRatio: curr = %f, min = %f.\n",
- descInliersRatio, minDescInliersRatio);
- ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
- return;
- }
-#if SHOW_DEBUG_LOG
- std::cout
- << "angle = " << angle
- << ", keypoints = " << keypoints1.size()
- << ", descInliersRatio = " << static_cast<float>(descInliersCount) / keypoints0.size()
- << std::endl;
-#endif
- }
- ts->set_failed_test_info( cvtest::TS::OK );
- }
-
- Ptr<FeatureDetector> featureDetector;
- Ptr<DescriptorExtractor> descriptorExtractor;
- int normType;
- float minDescInliersRatio;
-};
-
-class DetectorScaleInvarianceTest : public cvtest::BaseTest
-{
-public:
- DetectorScaleInvarianceTest(const Ptr<FeatureDetector>& _featureDetector,
- float _minKeyPointMatchesRatio,
- float _minScaleInliersRatio) :
- featureDetector(_featureDetector),
- minKeyPointMatchesRatio(_minKeyPointMatchesRatio),
- minScaleInliersRatio(_minScaleInliersRatio)
- {
- CV_Assert(featureDetector);
- }
-
-protected:
-
- void run(int)
- {
- const string imageFilename = string(ts->get_data_path()) + IMAGE_BIKES;
-
- // Read test data
- Mat image0 = imread(imageFilename);
- if(image0.empty())
- {
- ts->printf(cvtest::TS::LOG, "Image %s can not be read.\n", imageFilename.c_str());
- ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
- return;
- }
-
- vector<KeyPoint> keypoints0;
- featureDetector->detect(image0, keypoints0);
- if(keypoints0.size() < 15)
- CV_Error(Error::StsAssert, "Detector gives too few points in a test image\n");
-
- for(int scaleIdx = 1; scaleIdx <= 3; scaleIdx++)
- {
- float scale = 1.f + scaleIdx * 0.5f;
- Mat image1;
- resize(image0, image1, Size(), 1./scale, 1./scale);
-
- vector<KeyPoint> keypoints1, osiKeypoints1; // osi - original size image
- featureDetector->detect(image1, keypoints1);
- if(keypoints1.size() < 15)
- CV_Error(Error::StsAssert, "Detector gives too few points in a test image\n");
-
- if(keypoints1.size() > keypoints0.size())
- {
- ts->printf(cvtest::TS::LOG, "Strange behavior of the detector. "
- "It gives more points count in an image of the smaller size.\n"
- "original size (%d, %d), keypoints count = %d\n"
- "reduced size (%d, %d), keypoints count = %d\n",
- image0.cols, image0.rows, keypoints0.size(),
- image1.cols, image1.rows, keypoints1.size());
- ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);
- return;
- }
-
- scaleKeyPoints(keypoints1, osiKeypoints1, scale);
-
- vector<DMatch> matches;
- // image1 is query image (it's reduced image0)
- // image0 is train image
- matchKeyPoints(osiKeypoints1, Mat(), keypoints0, matches);
-
- const float minIntersectRatio = 0.5f;
- int keyPointMatchesCount = 0;
- int scaleInliersCount = 0;
-
- for(size_t m = 0; m < matches.size(); m++)
- {
- if(matches[m].distance < minIntersectRatio)
- continue;
-
- keyPointMatchesCount++;
-
- // Check does this inlier have consistent sizes
- const float maxSizeDiff = 0.8f;//0.9f; // grad
- float size0 = keypoints0[matches[m].trainIdx].size;
- float size1 = osiKeypoints1[matches[m].queryIdx].size;
- CV_Assert(size0 > 0 && size1 > 0);
- if(std::min(size0, size1) > maxSizeDiff * std::max(size0, size1))
- scaleInliersCount++;
- }
-
- float keyPointMatchesRatio = static_cast<float>(keyPointMatchesCount) / keypoints1.size();
- if(keyPointMatchesRatio < minKeyPointMatchesRatio)
- {
- ts->printf(cvtest::TS::LOG, "Incorrect keyPointMatchesRatio: curr = %f, min = %f.\n",
- keyPointMatchesRatio, minKeyPointMatchesRatio);
- ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
- return;
- }
-
- if(keyPointMatchesCount)
- {
- float scaleInliersRatio = static_cast<float>(scaleInliersCount) / keyPointMatchesCount;
- if(scaleInliersRatio < minScaleInliersRatio)
- {
- ts->printf(cvtest::TS::LOG, "Incorrect scaleInliersRatio: curr = %f, min = %f.\n",
- scaleInliersRatio, minScaleInliersRatio);
- ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
- return;
- }
- }
-#if SHOW_DEBUG_LOG
- std::cout
- << "scale = " << scale
- << ", keyPointMatchesRatio = " << keyPointMatchesRatio
- << ", scaleInliersRatio = " << (keyPointMatchesCount ? static_cast<float>(scaleInliersCount) / keyPointMatchesCount : 0)
- << std::endl;
-#endif
- }
- ts->set_failed_test_info( cvtest::TS::OK );
- }
-
- Ptr<FeatureDetector> featureDetector;
- float minKeyPointMatchesRatio;
- float minScaleInliersRatio;
-};
-
-class DescriptorScaleInvarianceTest : public cvtest::BaseTest
-{
-public:
- DescriptorScaleInvarianceTest(const Ptr<FeatureDetector>& _featureDetector,
- const Ptr<DescriptorExtractor>& _descriptorExtractor,
- int _normType,
- float _minDescInliersRatio) :
- featureDetector(_featureDetector),
- descriptorExtractor(_descriptorExtractor),
- normType(_normType),
- minDescInliersRatio(_minDescInliersRatio)
- {
- CV_Assert(featureDetector);
- CV_Assert(descriptorExtractor);
- }
-
-protected:
-
- void run(int)
- {
- const string imageFilename = string(ts->get_data_path()) + IMAGE_BIKES;
-
- // Read test data
- Mat image0 = imread(imageFilename);
- if(image0.empty())
- {
- ts->printf(cvtest::TS::LOG, "Image %s can not be read.\n", imageFilename.c_str());
- ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
- return;
- }
-
- vector<KeyPoint> keypoints0;
- featureDetector->detect(image0, keypoints0);
- if(keypoints0.size() < 15)
- CV_Error(Error::StsAssert, "Detector gives too few points in a test image\n");
- Mat descriptors0;
- descriptorExtractor->compute(image0, keypoints0, descriptors0);
-
- BFMatcher bfmatcher(normType);
- for(int scaleIdx = 1; scaleIdx <= 3; scaleIdx++)
- {
- float scale = 1.f + scaleIdx * 0.5f;
-
- Mat image1;
- resize(image0, image1, Size(), 1./scale, 1./scale);
-
- vector<KeyPoint> keypoints1;
- scaleKeyPoints(keypoints0, keypoints1, 1.0f/scale);
- Mat descriptors1;
- descriptorExtractor->compute(image1, keypoints1, descriptors1);
-
- vector<DMatch> descMatches;
- bfmatcher.match(descriptors0, descriptors1, descMatches);
-
- const float minIntersectRatio = 0.5f;
- int descInliersCount = 0;
- for(size_t m = 0; m < descMatches.size(); m++)
- {
- const KeyPoint& transformed_p0 = keypoints0[descMatches[m].queryIdx];
- const KeyPoint& p1 = keypoints0[descMatches[m].trainIdx];
- if(calcIntersectRatio(transformed_p0.pt, 0.5f * transformed_p0.size,
- p1.pt, 0.5f * p1.size) >= minIntersectRatio)
- {
- descInliersCount++;
- }
- }
-
- float descInliersRatio = static_cast<float>(descInliersCount) / keypoints0.size();
- if(descInliersRatio < minDescInliersRatio)
- {
- ts->printf(cvtest::TS::LOG, "Incorrect descInliersRatio: curr = %f, min = %f.\n",
- descInliersRatio, minDescInliersRatio);
- ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
- return;
- }
-#if SHOW_DEBUG_LOG
- std::cout
- << "scale = " << scale
- << ", descInliersRatio = " << static_cast<float>(descInliersCount) / keypoints0.size()
- << std::endl;
-#endif
- }
- ts->set_failed_test_info( cvtest::TS::OK );
- }
-
- Ptr<FeatureDetector> featureDetector;
- Ptr<DescriptorExtractor> descriptorExtractor;
- int normType;
- float minKeyPointMatchesRatio;
- float minDescInliersRatio;
-};
-
-// Tests registration
-
-/*
- * Detector's rotation invariance check
- */
-
-TEST(Features2d_RotationInvariance_Detector_BRISK, regression)
-{
- DetectorRotationInvarianceTest test(BRISK::create(),
- 0.45f,
- 0.76f);
- test.safe_run();
-}
-
-TEST(Features2d_RotationInvariance_Detector_ORB, regression)
-{
- DetectorRotationInvarianceTest test(ORB::create(),
- 0.5f,
- 0.76f);
- test.safe_run();
-}
-
-/*
- * Descriptors's rotation invariance check
- */
-
-TEST(Features2d_RotationInvariance_Descriptor_BRISK, regression)
-{
- Ptr<Feature2D> f2d = BRISK::create();
- DescriptorRotationInvarianceTest test(f2d, f2d, f2d->defaultNorm(), 0.99f);
- test.safe_run();
-}
-
-TEST(Features2d_RotationInvariance_Descriptor_ORB, regression)
-{
- Ptr<Feature2D> f2d = ORB::create();
- DescriptorRotationInvarianceTest test(f2d, f2d, f2d->defaultNorm(), 0.99f);
- test.safe_run();
-}
-
-//TEST(Features2d_RotationInvariance_Descriptor_FREAK, regression)
-//{
-// DescriptorRotationInvarianceTest test(Algorithm::create<FeatureDetector>("Feature2D.ORB"),
-// Algorithm::create<DescriptorExtractor>("Feature2D.FREAK"),
-// Algorithm::create<DescriptorExtractor>("Feature2D.FREAK")->defaultNorm(),
-// 0.f);
-// test.safe_run();
-//}
-
-/*
- * Detector's scale invariance check
- */
-
-TEST(Features2d_ScaleInvariance_Detector_BRISK, regression)
-{
- DetectorScaleInvarianceTest test(BRISK::create(), 0.08f, 0.49f);
- test.safe_run();
-}
-
-TEST(Features2d_ScaleInvariance_Detector_KAZE, regression)
-{
- DetectorScaleInvarianceTest test(KAZE::create(), 0.08f, 0.49f);
- test.safe_run();
-}
-
-TEST(Features2d_ScaleInvariance_Detector_AKAZE, regression)
-{
- DetectorScaleInvarianceTest test(AKAZE::create(), 0.08f, 0.49f);
- test.safe_run();
-}
-
-TEST(Features2d_ScaleInvariance_Detector_ORB, regression)
-{
- DetectorScaleInvarianceTest test(ORB::create(), 0.08f, 0.49f);
- test.safe_run();
-}
-
-/*
- * Descriptor's scale invariance check
- */
-
-//TEST(Features2d_ScaleInvariance_Descriptor_BRISK, regression)
-//{
-// DescriptorScaleInvarianceTest test(Algorithm::create<FeatureDetector>("Feature2D.BRISK"),
-// Algorithm::create<DescriptorExtractor>("Feature2D.BRISK"),
-// Algorithm::create<DescriptorExtractor>("Feature2D.BRISK")->defaultNorm(),
-// 0.99f);
-// test.safe_run();
-//}
-
-//TEST(Features2d_ScaleInvariance_Descriptor_ORB, regression)
-//{
-// DescriptorScaleInvarianceTest test(Algorithm::create<FeatureDetector>("Feature2D.ORB"),
-// Algorithm::create<DescriptorExtractor>("Feature2D.ORB"),
-// Algorithm::create<DescriptorExtractor>("Feature2D.ORB")->defaultNorm(),
-// 0.01f);
-// test.safe_run();
-//}
-
-//TEST(Features2d_ScaleInvariance_Descriptor_FREAK, regression)
-//{
-// DescriptorScaleInvarianceTest test(Algorithm::create<FeatureDetector>("Feature2D.ORB"),
-// Algorithm::create<DescriptorExtractor>("Feature2D.FREAK"),
-// Algorithm::create<DescriptorExtractor>("Feature2D.FREAK")->defaultNorm(),
-// 0.01f);
-// test.safe_run();
-//}
diff --git a/modules/flann/include/opencv2/flann.hpp b/modules/flann/include/opencv2/flann.hpp
index 19a98f1..22c6ffc 100644
--- a/modules/flann/include/opencv2/flann.hpp
+++ b/modules/flann/include/opencv2/flann.hpp
@@ -59,7 +59,7 @@ can be found in @cite Muja2009 .
namespace cvflann
{
CV_EXPORTS flann_distance_t flann_distance_type();
- FLANN_DEPRECATED CV_EXPORTS void set_distance_type(flann_distance_t distance_type, int order);
+ CV_DEPRECATED CV_EXPORTS void set_distance_type(flann_distance_t distance_type, int order);
}
@@ -230,7 +230,7 @@ public:
::cvflann::IndexParams getParameters() { return nnIndex->getParameters(); }
- FLANN_DEPRECATED const ::cvflann::IndexParams* getIndexParameters() { return nnIndex->getIndexParameters(); }
+ CV_DEPRECATED const ::cvflann::IndexParams* getIndexParameters() { return nnIndex->getIndexParameters(); }
private:
::cvflann::Index<Distance>* nnIndex;
@@ -344,7 +344,7 @@ public:
typedef typename L2<T>::ElementType ElementType;
typedef typename L2<T>::ResultType DistanceType;
- FLANN_DEPRECATED Index_(const Mat& dataset, const ::cvflann::IndexParams& params)
+ CV_DEPRECATED Index_(const Mat& dataset, const ::cvflann::IndexParams& params)
{
printf("[WARNING] The cv::flann::Index_<T> class is deperecated, use cv::flann::GenericIndex<Distance> instead\n");
@@ -368,13 +368,13 @@ public:
if (nnIndex_L1) nnIndex_L1->buildIndex();
if (nnIndex_L2) nnIndex_L2->buildIndex();
}
- FLANN_DEPRECATED ~Index_()
+ CV_DEPRECATED ~Index_()
{
if (nnIndex_L1) delete nnIndex_L1;
if (nnIndex_L2) delete nnIndex_L2;
}
- FLANN_DEPRECATED void knnSearch(const std::vector<ElementType>& query, std::vector<int>& indices, std::vector<DistanceType>& dists, int knn, const ::cvflann::SearchParams& searchParams)
+ CV_DEPRECATED void knnSearch(const std::vector<ElementType>& query, std::vector<int>& indices, std::vector<DistanceType>& dists, int knn, const ::cvflann::SearchParams& searchParams)
{
::cvflann::Matrix<ElementType> m_query((ElementType*)&query[0], 1, query.size());
::cvflann::Matrix<int> m_indices(&indices[0], 1, indices.size());
@@ -383,7 +383,7 @@ public:
if (nnIndex_L1) nnIndex_L1->knnSearch(m_query,m_indices,m_dists,knn,searchParams);
if (nnIndex_L2) nnIndex_L2->knnSearch(m_query,m_indices,m_dists,knn,searchParams);
}
- FLANN_DEPRECATED void knnSearch(const Mat& queries, Mat& indices, Mat& dists, int knn, const ::cvflann::SearchParams& searchParams)
+ CV_DEPRECATED void knnSearch(const Mat& queries, Mat& indices, Mat& dists, int knn, const ::cvflann::SearchParams& searchParams)
{
CV_Assert(queries.type() == CvType<ElementType>::type());
CV_Assert(queries.isContinuous());
@@ -401,7 +401,7 @@ public:
if (nnIndex_L2) nnIndex_L2->knnSearch(m_queries,m_indices,m_dists,knn, searchParams);
}
- FLANN_DEPRECATED int radiusSearch(const std::vector<ElementType>& query, std::vector<int>& indices, std::vector<DistanceType>& dists, DistanceType radius, const ::cvflann::SearchParams& searchParams)
+ CV_DEPRECATED int radiusSearch(const std::vector<ElementType>& query, std::vector<int>& indices, std::vector<DistanceType>& dists, DistanceType radius, const ::cvflann::SearchParams& searchParams)
{
::cvflann::Matrix<ElementType> m_query((ElementType*)&query[0], 1, query.size());
::cvflann::Matrix<int> m_indices(&indices[0], 1, indices.size());
@@ -411,7 +411,7 @@ public:
if (nnIndex_L2) return nnIndex_L2->radiusSearch(m_query,m_indices,m_dists,radius,searchParams);
}
- FLANN_DEPRECATED int radiusSearch(const Mat& query, Mat& indices, Mat& dists, DistanceType radius, const ::cvflann::SearchParams& searchParams)
+ CV_DEPRECATED int radiusSearch(const Mat& query, Mat& indices, Mat& dists, DistanceType radius, const ::cvflann::SearchParams& searchParams)
{
CV_Assert(query.type() == CvType<ElementType>::type());
CV_Assert(query.isContinuous());
@@ -429,32 +429,32 @@ public:
if (nnIndex_L2) return nnIndex_L2->radiusSearch(m_query,m_indices,m_dists,radius,searchParams);
}
- FLANN_DEPRECATED void save(String filename)
+ CV_DEPRECATED void save(String filename)
{
if (nnIndex_L1) nnIndex_L1->save(filename);
if (nnIndex_L2) nnIndex_L2->save(filename);
}
- FLANN_DEPRECATED int veclen() const
+ CV_DEPRECATED int veclen() const
{
if (nnIndex_L1) return nnIndex_L1->veclen();
if (nnIndex_L2) return nnIndex_L2->veclen();
}
- FLANN_DEPRECATED int size() const
+ CV_DEPRECATED int size() const
{
if (nnIndex_L1) return nnIndex_L1->size();
if (nnIndex_L2) return nnIndex_L2->size();
}
- FLANN_DEPRECATED ::cvflann::IndexParams getParameters()
+ CV_DEPRECATED ::cvflann::IndexParams getParameters()
{
if (nnIndex_L1) return nnIndex_L1->getParameters();
if (nnIndex_L2) return nnIndex_L2->getParameters();
}
- FLANN_DEPRECATED const ::cvflann::IndexParams* getIndexParameters()
+ CV_DEPRECATED const ::cvflann::IndexParams* getIndexParameters()
{
if (nnIndex_L1) return nnIndex_L1->getIndexParameters();
if (nnIndex_L2) return nnIndex_L2->getIndexParameters();
@@ -505,7 +505,7 @@ int hierarchicalClustering(const Mat& features, Mat& centers, const ::cvflann::K
/** @deprecated
*/
template <typename ELEM_TYPE, typename DIST_TYPE>
-FLANN_DEPRECATED int hierarchicalClustering(const Mat& features, Mat& centers, const ::cvflann::KMeansIndexParams& params)
+CV_DEPRECATED int hierarchicalClustering(const Mat& features, Mat& centers, const ::cvflann::KMeansIndexParams& params)
{
printf("[WARNING] cv::flann::hierarchicalClustering<ELEM_TYPE,DIST_TYPE> is deprecated, use "
"cv::flann::hierarchicalClustering<Distance> instead\n");
diff --git a/modules/flann/include/opencv2/flann/allocator.h b/modules/flann/include/opencv2/flann/allocator.h
index 26091d0..aa0f4cc 100644
--- a/modules/flann/include/opencv2/flann/allocator.h
+++ b/modules/flann/include/opencv2/flann/allocator.h
@@ -97,6 +97,7 @@ public:
blocksize = blockSize;
remaining = 0;
base = NULL;
+ loc = NULL;
usedMemory = 0;
wastedMemory = 0;
diff --git a/modules/flann/include/opencv2/flann/any.h b/modules/flann/include/opencv2/flann/any.h
index bfe06c8..e829162 100644
--- a/modules/flann/include/opencv2/flann/any.h
+++ b/modules/flann/include/opencv2/flann/any.h
@@ -246,6 +246,12 @@ public:
return assign(x);
}
+ /// Assignment operator. Template-based version above doesn't work as expected. We need regular assignment operator here.
+ any& operator=(const any& x)
+ {
+ return assign(x);
+ }
+
/// Assignment operator, specialed for literal strings.
/// They have types like const char [6] which don't work as expected.
any& operator=(const char* x)
diff --git a/modules/flann/include/opencv2/flann/autotuned_index.h b/modules/flann/include/opencv2/flann/autotuned_index.h
index 6ffb929..e9abbf7 100644
--- a/modules/flann/include/opencv2/flann/autotuned_index.h
+++ b/modules/flann/include/opencv2/flann/autotuned_index.h
@@ -30,6 +30,8 @@
#ifndef OPENCV_FLANN_AUTOTUNED_INDEX_H_
#define OPENCV_FLANN_AUTOTUNED_INDEX_H_
+#include <sstream>
+
#include "general.h"
#include "nn_index.h"
#include "ground_truth.h"
@@ -81,6 +83,7 @@ public:
memory_weight_ = get_param(params, "memory_weight", 0.0f);
sample_fraction_ = get_param(params,"sample_fraction", 0.1f);
bestIndex_ = NULL;
+ speedup_ = 0;
}
AutotunedIndex(const AutotunedIndex&);
diff --git a/modules/flann/include/opencv2/flann/defines.h b/modules/flann/include/opencv2/flann/defines.h
index f0264f7..6fd53c2 100644
--- a/modules/flann/include/opencv2/flann/defines.h
+++ b/modules/flann/include/opencv2/flann/defines.h
@@ -35,7 +35,7 @@
#ifdef FLANN_EXPORT
#undef FLANN_EXPORT
#endif
-#ifdef WIN32
+#ifdef _WIN32
/* win32 dll export/import directives */
#ifdef FLANN_EXPORTS
#define FLANN_EXPORT __declspec(dllexport)
@@ -50,19 +50,6 @@
#endif
-#ifdef FLANN_DEPRECATED
-#undef FLANN_DEPRECATED
-#endif
-#ifdef __GNUC__
-#define FLANN_DEPRECATED __attribute__ ((deprecated))
-#elif defined(_MSC_VER)
-#define FLANN_DEPRECATED __declspec(deprecated)
-#else
-#pragma message("WARNING: You need to implement FLANN_DEPRECATED for this compiler")
-#define FLANN_DEPRECATED
-#endif
-
-
#undef FLANN_PLATFORM_32_BIT
#undef FLANN_PLATFORM_64_BIT
#if defined __amd64__ || defined __x86_64__ || defined _WIN64 || defined _M_X64
diff --git a/modules/flann/include/opencv2/flann/dist.h b/modules/flann/include/opencv2/flann/dist.h
index 9dbe527..9e2c512 100644
--- a/modules/flann/include/opencv2/flann/dist.h
+++ b/modules/flann/include/opencv2/flann/dist.h
@@ -43,7 +43,7 @@ typedef unsigned __int64 uint64_t;
#include "defines.h"
-#if (defined WIN32 || defined _WIN32) && defined(_M_ARM)
+#if defined _WIN32 && defined(_M_ARM)
# include <Intrin.h>
#endif
@@ -698,7 +698,7 @@ struct KL_Divergence
typedef typename Accumulator<T>::Type ResultType;
/**
- * Compute the Kullback–Leibler divergence
+ * Compute the Kullback-Leibler divergence
*/
template <typename Iterator1, typename Iterator2>
ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const
diff --git a/modules/flann/include/opencv2/flann/dummy.h b/modules/flann/include/opencv2/flann/dummy.h
index 26bd3fa..8b1fa63 100644
--- a/modules/flann/include/opencv2/flann/dummy.h
+++ b/modules/flann/include/opencv2/flann/dummy.h
@@ -5,7 +5,7 @@
namespace cvflann
{
-#if (defined WIN32 || defined _WIN32 || defined WINCE) && defined CVAPI_EXPORTS
+#if (defined _WIN32 || defined WINCE) && defined CVAPI_EXPORTS
__declspec(dllexport)
#endif
void dummyfunc();
diff --git a/modules/flann/include/opencv2/flann/dynamic_bitset.h b/modules/flann/include/opencv2/flann/dynamic_bitset.h
index d795b5d..923b658 100644
--- a/modules/flann/include/opencv2/flann/dynamic_bitset.h
+++ b/modules/flann/include/opencv2/flann/dynamic_bitset.h
@@ -59,7 +59,7 @@ class DynamicBitset
public:
/** default constructor
*/
- DynamicBitset()
+ DynamicBitset() : size_(0)
{
}
diff --git a/modules/flann/include/opencv2/flann/flann_base.hpp b/modules/flann/include/opencv2/flann/flann_base.hpp
index 98c33cf..be5e07f 100644
--- a/modules/flann/include/opencv2/flann/flann_base.hpp
+++ b/modules/flann/include/opencv2/flann/flann_base.hpp
@@ -80,9 +80,11 @@ NNIndex<Distance>* load_saved_index(const Matrix<typename Distance::ElementType>
}
IndexHeader header = load_header(fin);
if (header.data_type != Datatype<ElementType>::type()) {
+ fclose(fin);
throw FLANNException("Datatype of saved index is different than of the one to be created.");
}
if ((size_t(header.rows) != dataset.rows)||(size_t(header.cols) != dataset.cols)) {
+ fclose(fin);
throw FLANNException("The index saved belongs to a different dataset");
}
@@ -241,7 +243,7 @@ public:
/**
* \brief Returns actual index
*/
- FLANN_DEPRECATED NNIndex<Distance>* getIndex()
+ CV_DEPRECATED NNIndex<Distance>* getIndex()
{
return nnIndex_;
}
@@ -250,7 +252,7 @@ public:
* \brief Returns index parameters.
* \deprecated use getParameters() instead.
*/
- FLANN_DEPRECATED const IndexParams* getIndexParameters()
+ CV_DEPRECATED const IndexParams* getIndexParameters()
{
return &index_params_;
}
diff --git a/modules/flann/include/opencv2/flann/kdtree_index.h b/modules/flann/include/opencv2/flann/kdtree_index.h
index dc0971c..3f6ee01 100644
--- a/modules/flann/include/opencv2/flann/kdtree_index.h
+++ b/modules/flann/include/opencv2/flann/kdtree_index.h
@@ -125,7 +125,12 @@ public:
/* Construct the randomized trees. */
for (int i = 0; i < trees_; i++) {
/* Randomize the order of vectors to allow for unbiased sampling. */
+#ifndef OPENCV_FLANN_USE_STD_RAND
+ cv::randShuffle(vind_);
+#else
std::random_shuffle(vind_.begin(), vind_.end());
+#endif
+
tree_roots_[i] = divideTree(&vind_[0], int(size_) );
}
}
diff --git a/modules/flann/include/opencv2/flann/kdtree_single_index.h b/modules/flann/include/opencv2/flann/kdtree_single_index.h
index 30488ad..ef15392 100644
--- a/modules/flann/include/opencv2/flann/kdtree_single_index.h
+++ b/modules/flann/include/opencv2/flann/kdtree_single_index.h
@@ -87,6 +87,7 @@ public:
{
size_ = dataset_.rows;
dim_ = dataset_.cols;
+ root_node_ = 0;
int dim_param = get_param(params,"dim",-1);
if (dim_param>0) dim_ = dim_param;
leaf_max_size_ = get_param(params,"leaf_max_size",10);
diff --git a/modules/flann/include/opencv2/flann/logger.h b/modules/flann/include/opencv2/flann/logger.h
index 24f3fb6..32618db 100644
--- a/modules/flann/include/opencv2/flann/logger.h
+++ b/modules/flann/include/opencv2/flann/logger.h
@@ -63,7 +63,12 @@ class Logger
stream = stdout;
}
else {
+#ifdef _MSC_VER
+ if (fopen_s(&stream, name, "w") != 0)
+ stream = NULL;
+#else
stream = fopen(name,"w");
+#endif
if (stream == NULL) {
stream = stdout;
}
diff --git a/modules/flann/include/opencv2/flann/lsh_table.h b/modules/flann/include/opencv2/flann/lsh_table.h
index 8ef2bd3..fa7cc71 100644
--- a/modules/flann/include/opencv2/flann/lsh_table.h
+++ b/modules/flann/include/opencv2/flann/lsh_table.h
@@ -146,6 +146,9 @@ public:
*/
LshTable()
{
+ key_size_ = 0;
+ feature_size_ = 0;
+ speed_level_ = kArray;
}
/** Default constructor
@@ -155,7 +158,7 @@ public:
*/
LshTable(unsigned int feature_size, unsigned int key_size)
{
- (void)feature_size;
+ feature_size_ = feature_size;
(void)key_size;
std::cerr << "LSH is not implemented for that type" << std::endl;
assert(0);
@@ -330,6 +333,8 @@ private:
*/
unsigned int key_size_;
+ unsigned int feature_size_;
+
// Members only used for the unsigned char specialization
/** The mask to apply to a feature to get the hash key
* Only used in the unsigned char case
@@ -343,14 +348,19 @@ private:
template<>
inline LshTable<unsigned char>::LshTable(unsigned int feature_size, unsigned int subsignature_size)
{
+ feature_size_ = feature_size;
initialize(subsignature_size);
// Allocate the mask
- mask_ = std::vector<size_t>((size_t)ceil((float)(feature_size * sizeof(char)) / (float)sizeof(size_t)), 0);
+ mask_ = std::vector<size_t>((feature_size * sizeof(char) + sizeof(size_t) - 1) / sizeof(size_t), 0);
// A bit brutal but fast to code
std::vector<size_t> indices(feature_size * CHAR_BIT);
for (size_t i = 0; i < feature_size * CHAR_BIT; ++i) indices[i] = i;
+#ifndef OPENCV_FLANN_USE_STD_RAND
+ cv::randShuffle(indices);
+#else
std::random_shuffle(indices.begin(), indices.end());
+#endif
// Generate a random set of order of subsignature_size_ bits
for (unsigned int i = 0; i < key_size_; ++i) {
@@ -386,6 +396,7 @@ inline size_t LshTable<unsigned char>::getKey(const unsigned char* feature) cons
{
// no need to check if T is dividable by sizeof(size_t) like in the Hamming
// distance computation as we have a mask
+ // FIXIT: This is bad assumption, because we reading tail bytes after of the allocated features buffer
const size_t* feature_block_ptr = reinterpret_cast<const size_t*> ((const void*)feature);
// Figure out the subsignature of the feature
@@ -394,10 +405,20 @@ inline size_t LshTable<unsigned char>::getKey(const unsigned char* feature) cons
size_t subsignature = 0;
size_t bit_index = 1;
- for (std::vector<size_t>::const_iterator pmask_block = mask_.begin(); pmask_block != mask_.end(); ++pmask_block) {
+ for (unsigned i = 0; i < feature_size_; i += sizeof(size_t)) {
// get the mask and signature blocks
- size_t feature_block = *feature_block_ptr;
- size_t mask_block = *pmask_block;
+ size_t feature_block;
+ if (i <= feature_size_ - sizeof(size_t))
+ {
+ feature_block = *feature_block_ptr;
+ }
+ else
+ {
+ size_t tmp = 0;
+ memcpy(&tmp, feature_block_ptr, feature_size_ - i); // preserve bytes order
+ feature_block = tmp;
+ }
+ size_t mask_block = mask_[i / sizeof(size_t)];
while (mask_block) {
// Get the lowest set bit in the mask block
size_t lowest_bit = mask_block & (-(ptrdiff_t)mask_block);
diff --git a/modules/flann/include/opencv2/flann/matrix.h b/modules/flann/include/opencv2/flann/matrix.h
index 51b6c63..f6092d1 100644
--- a/modules/flann/include/opencv2/flann/matrix.h
+++ b/modules/flann/include/opencv2/flann/matrix.h
@@ -66,7 +66,7 @@ public:
/**
* Convenience function for deallocating the storage data.
*/
- FLANN_DEPRECATED void free()
+ CV_DEPRECATED void free()
{
fprintf(stderr, "The cvflann::Matrix<T>::free() method is deprecated "
"and it does not do any memory deallocation any more. You are"
diff --git a/modules/flann/include/opencv2/flann/random.h b/modules/flann/include/opencv2/flann/random.h
index a3cf5ec..d678474 100644
--- a/modules/flann/include/opencv2/flann/random.h
+++ b/modules/flann/include/opencv2/flann/random.h
@@ -40,13 +40,31 @@
namespace cvflann
{
+inline int rand()
+{
+#ifndef OPENCV_FLANN_USE_STD_RAND
+# if INT_MAX == RAND_MAX
+ int v = cv::theRNG().next() & INT_MAX;
+# else
+ int v = cv::theRNG().uniform(0, RAND_MAX + 1);
+# endif
+#else
+ int v = std::rand();
+#endif // OPENCV_FLANN_USE_STD_RAND
+ return v;
+}
+
/**
* Seeds the random number generator
* @param seed Random seed
*/
inline void seed_random(unsigned int seed)
{
- srand(seed);
+#ifndef OPENCV_FLANN_USE_STD_RAND
+ cv::theRNG() = cv::RNG(seed);
+#else
+ std::srand(seed);
+#endif
}
/*
@@ -60,7 +78,7 @@ inline void seed_random(unsigned int seed)
*/
inline double rand_double(double high = 1.0, double low = 0)
{
- return low + ((high-low) * (std::rand() / (RAND_MAX + 1.0)));
+ return low + ((high-low) * (rand() / (RAND_MAX + 1.0)));
}
/**
@@ -71,7 +89,7 @@ inline double rand_double(double high = 1.0, double low = 0)
*/
inline int rand_int(int high = RAND_MAX, int low = 0)
{
- return low + (int) ( double(high-low) * (std::rand() / (RAND_MAX + 1.0)));
+ return low + (int) ( double(high-low) * (rand() / (RAND_MAX + 1.0)));
}
/**
@@ -107,7 +125,11 @@ public:
for (int i = 0; i < size_; ++i) vals_[i] = i;
// shuffle the elements in the array
+#ifndef OPENCV_FLANN_USE_STD_RAND
+ cv::randShuffle(vals_);
+#else
std::random_shuffle(vals_.begin(), vals_.end());
+#endif
counter_ = 0;
}
diff --git a/modules/flann/include/opencv2/flann/result_set.h b/modules/flann/include/opencv2/flann/result_set.h
index 9750019..7c09093 100644
--- a/modules/flann/include/opencv2/flann/result_set.h
+++ b/modules/flann/include/opencv2/flann/result_set.h
@@ -303,7 +303,7 @@ public:
/** Default cosntructor */
UniqueResultSet() :
- worst_distance_(std::numeric_limits<DistanceType>::max())
+ is_full_(false), worst_distance_(std::numeric_limits<DistanceType>::max())
{
}
diff --git a/modules/flann/misc/python/pyopencv_flann.hpp b/modules/flann/misc/python/pyopencv_flann.hpp
index a9da8d0..6591b90 100644
--- a/modules/flann/misc/python/pyopencv_flann.hpp
+++ b/modules/flann/misc/python/pyopencv_flann.hpp
@@ -23,6 +23,9 @@ bool pyopencv_to(PyObject *o, cv::flann::IndexParams& p, const char *name)
PyObject* item = NULL;
Py_ssize_t pos = 0;
+ if (!o || o == Py_None)
+ return true;
+
if(PyDict_Check(o)) {
while(PyDict_Next(o, &pos, &key, &item)) {
if( !PyString_Check(key) ) {
diff --git a/modules/highgui/CMakeLists.txt b/modules/highgui/CMakeLists.txt
index eb56177..91a9a1b 100644
--- a/modules/highgui/CMakeLists.txt
+++ b/modules/highgui/CMakeLists.txt
@@ -1,5 +1,5 @@
-set(the_description "High-level GUI and Media I/O")
-ocv_add_module(highgui opencv_imgproc OPTIONAL opencv_imgcodecs opencv_videoio WRAP python)
+set(the_description "High-level GUI")
+ocv_add_module(highgui opencv_imgproc opencv_imgcodecs OPTIONAL opencv_videoio WRAP python)
# ----------------------------------------------------------------------------
# CMake file for highgui. See root CMakeLists.txt
@@ -22,6 +22,7 @@ set(highgui_hdrs
set(highgui_srcs
${CMAKE_CURRENT_LIST_DIR}/src/window.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/src/roiSelector.cpp
)
file(GLOB highgui_ext_hdrs
@@ -65,7 +66,7 @@ elseif(HAVE_QT)
list(APPEND HIGHGUI_LIBRARIES ${QT_LIBRARIES})
list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.cpp ${_MOC_OUTFILES} ${_RCC_OUTFILES})
- ocv_check_flag_support(CXX -Wno-missing-declarations _have_flag)
+ ocv_check_flag_support(CXX -Wno-missing-declarations _have_flag "")
if(${_have_flag})
set_source_files_properties(${_RCC_OUTFILES} PROPERTIES COMPILE_FLAGS -Wno-missing-declarations)
endif()
@@ -138,10 +139,6 @@ if(APPLE)
add_apple_compiler_options(the_module)
endif()
-if(BUILD_SHARED_LIBS)
- add_definitions(-DHIGHGUI_EXPORTS)
-endif()
-
if(MSVC)
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG")
endif()
diff --git a/modules/highgui/include/opencv2/highgui.hpp b/modules/highgui/include/opencv2/highgui.hpp
index 16ef8c4..875a2cd 100644
--- a/modules/highgui/include/opencv2/highgui.hpp
+++ b/modules/highgui/include/opencv2/highgui.hpp
@@ -361,7 +361,7 @@ Otherwise, the image is scaled to fit the window. The function may scale the ima
- If the image is 8-bit unsigned, it is displayed as is.
- If the image is 16-bit unsigned or 32-bit integer, the pixels are divided by 256. That is, the
value range [0,255\*256] is mapped to [0,255].
-- If the image is 32-bit floating-point, the pixel values are multiplied by 255. That is, the
+- If the image is 32-bit or 64-bit floating-point, the pixel values are multiplied by 255. That is, the
value range [0,1] is mapped to [0,255].
If window was created with OpenGL support, cv::imshow also support ogl::Buffer , ogl::Texture2D and
@@ -468,6 +468,44 @@ Mouse-wheel events are currently supported only on Windows.
*/
CV_EXPORTS int getMouseWheelDelta(int flags);
+/** @brief Selects ROI on the given image.
+Function creates a window and allows user to select a ROI using mouse.
+Controls: use `space` or `enter` to finish selection, use key `c` to cancel selection (function will return the zero cv::Rect).
+
+ at param windowName name of the window where selection process will be shown.
+ at param img image to select a ROI.
+ at param showCrosshair if true crosshair of selection rectangle will be shown.
+ at param fromCenter if true center of selection will match initial mouse position. In opposite case a corner of
+selection rectangle will correspont to the initial mouse position.
+ at return selected ROI or empty rect if selection canceled.
+
+ at note The function sets it's own mouse callback for specified window using cv::setMouseCallback(windowName, ...).
+After finish of work an empty callback will be set for the used window.
+ */
+CV_EXPORTS_W Rect selectROI(const String& windowName, InputArray img, bool showCrosshair = true, bool fromCenter = false);
+
+/** @overload
+ */
+CV_EXPORTS_W Rect selectROI(InputArray img, bool showCrosshair = true, bool fromCenter = false);
+
+/** @brief Selects ROIs on the given image.
+Function creates a window and allows user to select a ROIs using mouse.
+Controls: use `space` or `enter` to finish current selection and start a new one,
+use `esc` to terminate multiple ROI selection process.
+
+ at param windowName name of the window where selection process will be shown.
+ at param img image to select a ROI.
+ at param boundingBoxes selected ROIs.
+ at param showCrosshair if true crosshair of selection rectangle will be shown.
+ at param fromCenter if true center of selection will match initial mouse position. In opposite case a corner of
+selection rectangle will correspont to the initial mouse position.
+
+ at note The function sets it's own mouse callback for specified window using cv::setMouseCallback(windowName, ...).
+After finish of work an empty callback will be set for the used window.
+ */
+CV_EXPORTS_W void selectROIs(const String& windowName, InputArray img,
+ CV_OUT std::vector<Rect>& boundingBoxes, bool showCrosshair = true, bool fromCenter = false);
+
/** @brief Creates a trackbar and attaches it to the specified window.
The function createTrackbar creates a trackbar (a slider or range control) with the specified name
diff --git a/modules/highgui/include/opencv2/highgui/highgui_c.h b/modules/highgui/include/opencv2/highgui/highgui_c.h
index 71c08ca..d8323d0 100644
--- a/modules/highgui/include/opencv2/highgui/highgui_c.h
+++ b/modules/highgui/include/opencv2/highgui/highgui_c.h
@@ -239,7 +239,7 @@ CVAPI(void) cvUpdateWindow(const char* window_name);
#define set_preprocess_func cvSetPreprocessFuncWin32
#define set_postprocess_func cvSetPostprocessFuncWin32
-#if defined WIN32 || defined _WIN32
+#if defined _WIN32
CVAPI(void) cvSetPreprocessFuncWin32_(const void* callback);
CVAPI(void) cvSetPostprocessFuncWin32_(const void* callback);
diff --git a/modules/highgui/misc/java/gen_dict.json b/modules/highgui/misc/java/gen_dict.json
new file mode 100644
index 0000000..9256478
--- /dev/null
+++ b/modules/highgui/misc/java/gen_dict.json
@@ -0,0 +1,31 @@
+{
+ "const_ignore_list": [
+ "EVENT_.*",
+ "WINDOW_AUTOSIZE",
+ "CV_WND_PROP_",
+ "CV_WINDOW_",
+ "CV_EVENT_",
+ "CV_GUI_",
+ "CV_PUSH_BUTTON",
+ "CV_CHECKBOX",
+ "CV_RADIOBOX",
+ "WINDOW_.+",
+ "WND_PROP_.+"
+ ],
+ "ManualFuncs" : {
+ "Highgui" : {
+ "namedWindow" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
+ "destroyWindow" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
+ "destroyAllWindows" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
+ "startWindowThread" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
+ "setWindowProperty" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
+ "getWindowProperty" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
+ "getTrackbarPos" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
+ "setTrackbarPos" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
+ "imshow" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
+ "waitKey" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
+ "moveWindow" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] },
+ "resizeWindow" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] }
+ }
+ }
+}
diff --git a/modules/highgui/src/precomp.hpp b/modules/highgui/src/precomp.hpp
index d9e7ad8..e6af8af 100644
--- a/modules/highgui/src/precomp.hpp
+++ b/modules/highgui/src/precomp.hpp
@@ -50,10 +50,8 @@
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/highgui/highgui_c.h"
-#ifdef HAVE_OPENCV_IMGCODECS
#include "opencv2/imgcodecs.hpp"
#include "opencv2/imgcodecs/imgcodecs_c.h"
-#endif
#include <stdlib.h>
#include <stdio.h>
@@ -62,7 +60,7 @@
#include <ctype.h>
#include <assert.h>
-#if defined WIN32 || defined WINCE
+#if defined _WIN32 || defined WINCE
#include <windows.h>
#undef small
#undef min
diff --git a/modules/highgui/src/roiSelector.cpp b/modules/highgui/src/roiSelector.cpp
new file mode 100644
index 0000000..8bc6ba6
--- /dev/null
+++ b/modules/highgui/src/roiSelector.cpp
@@ -0,0 +1,203 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "precomp.hpp"
+#include <opencv2/imgproc.hpp>
+#include <algorithm>
+
+using namespace cv;
+
+namespace
+{
+class ROISelector
+{
+ public:
+ Rect select(const String &windowName, Mat img, bool showCrossair = true, bool fromCenter = true)
+ {
+ // show notice to user
+ printf("Select a ROI and then press SPACE or ENTER button!\n");
+ printf("Cancel the selection process by pressing c button!\n");
+
+ key = 0;
+ imageSize = img.size();
+
+ // set the drawing mode
+ selectorParams.drawFromCenter = fromCenter;
+
+ // show the image and give feedback to user
+ imshow(windowName, img);
+
+ // copy the data, rectangle should be drawn in the fresh image
+ selectorParams.image = img.clone();
+
+ // select the object
+ setMouseCallback(windowName, mouseHandler, (void*)this);
+
+ // end selection process on SPACE (32) ESC (27) or ENTER (13)
+ while (!(key == 32 || key == 27 || key == 13))
+ {
+ // draw the selected object
+ rectangle(selectorParams.image, selectorParams.box, Scalar(255, 0, 0), 2, 1);
+
+ // draw cross air in the middle of bounding box
+ if (showCrossair)
+ {
+ // horizontal line
+ line(selectorParams.image,
+ Point((int)selectorParams.box.x,
+ (int)(selectorParams.box.y + selectorParams.box.height / 2)),
+ Point((int)(selectorParams.box.x + selectorParams.box.width),
+ (int)(selectorParams.box.y + selectorParams.box.height / 2)),
+ Scalar(255, 0, 0), 2, 1);
+
+ // vertical line
+ line(selectorParams.image,
+ Point((int)(selectorParams.box.x + selectorParams.box.width / 2),
+ (int)selectorParams.box.y),
+ Point((int)(selectorParams.box.x + selectorParams.box.width / 2),
+ (int)(selectorParams.box.y + selectorParams.box.height)),
+ Scalar(255, 0, 0), 2, 1);
+ }
+
+ // show the image bouding box
+ imshow(windowName, selectorParams.image);
+
+ // reset the image
+ selectorParams.image = img.clone();
+
+ // get keyboard event
+ key = waitKey(30);
+
+ if (key == 'c' || key == 'C')//cancel selection
+ {
+ selectorParams.box = Rect();
+ break;
+ }
+ }
+
+ //cleanup callback
+ setMouseCallback(windowName, emptyMouseHandler, NULL);
+
+ return selectorParams.box;
+ }
+
+ void select(const String &windowName, Mat img, std::vector<Rect> &boundingBoxes,
+ bool showCrosshair = true, bool fromCenter = true)
+ {
+ printf("Finish the selection process by pressing ESC button!\n");
+ boundingBoxes.clear();
+ key = 0;
+
+ // while key is not ESC (27)
+ for (;;)
+ {
+ Rect temp = select(windowName, img, showCrosshair, fromCenter);
+ if (key == 27)
+ break;
+ if (temp.width > 0 && temp.height > 0)
+ boundingBoxes.push_back(temp);
+ }
+ }
+
+ struct handlerT
+ {
+ // basic parameters
+ bool isDrawing;
+ Rect2d box;
+ Mat image;
+
+ // parameters for drawing from the center
+ bool drawFromCenter;
+ Point2f center;
+
+ // initializer list
+ handlerT() : isDrawing(false), drawFromCenter(true){};
+ } selectorParams;
+
+ private:
+ static void emptyMouseHandler(int, int, int, int, void*)
+ {
+ }
+
+ static void mouseHandler(int event, int x, int y, int flags, void *param)
+ {
+ ROISelector *self = static_cast<ROISelector *>(param);
+ self->opencv_mouse_callback(event, x, y, flags);
+ }
+
+ void opencv_mouse_callback(int event, int x, int y, int)
+ {
+ switch (event)
+ {
+ // update the selected bounding box
+ case EVENT_MOUSEMOVE:
+ if (selectorParams.isDrawing)
+ {
+ if (selectorParams.drawFromCenter)
+ {
+ selectorParams.box.width = 2 * (x - selectorParams.center.x);
+ selectorParams.box.height = 2 * (y - selectorParams.center.y);
+ selectorParams.box.x = std::min(
+ std::max(selectorParams.center.x - selectorParams.box.width / 2.0, 0.), (double)imageSize.width);
+ selectorParams.box.y = std::min(
+ std::max(selectorParams.center.y - selectorParams.box.height / 2.0, 0.), (double)imageSize.height);
+ }
+ else
+ {
+ selectorParams.box.width = std::max(
+ std::min(x - selectorParams.box.x, (double)imageSize.width - selectorParams.box.x), - selectorParams.box.x);
+ selectorParams.box.height = std::max(
+ std::min(y - selectorParams.box.y, (double)imageSize.height - selectorParams.box.y), - selectorParams.box.y);
+ }
+ }
+ break;
+
+ // start to select the bounding box
+ case EVENT_LBUTTONDOWN:
+ selectorParams.isDrawing = true;
+ selectorParams.box = Rect2d(x, y, 0, 0);
+ selectorParams.center = Point2f((float)x, (float)y);
+ break;
+
+ // cleaning up the selected bounding box
+ case EVENT_LBUTTONUP:
+ selectorParams.isDrawing = false;
+ if (selectorParams.box.width < 0)
+ {
+ selectorParams.box.x += selectorParams.box.width;
+ selectorParams.box.width *= -1;
+ }
+ if (selectorParams.box.height < 0)
+ {
+ selectorParams.box.y += selectorParams.box.height;
+ selectorParams.box.height *= -1;
+ }
+ break;
+ }
+ }
+
+ // save the keypressed characted
+ int key;
+ Size imageSize;
+};
+}
+
+Rect cv::selectROI(InputArray img, bool showCrosshair, bool fromCenter)
+{
+ ROISelector selector;
+ return selector.select("ROI selector", img.getMat(), showCrosshair, fromCenter);
+}
+
+Rect cv::selectROI(const String& windowName, InputArray img, bool showCrosshair, bool fromCenter)
+{
+ ROISelector selector;
+ return selector.select(windowName, img.getMat(), showCrosshair, fromCenter);
+}
+
+void cv::selectROIs(const String& windowName, InputArray img,
+ std::vector<Rect>& boundingBox, bool showCrosshair, bool fromCenter)
+{
+ ROISelector selector;
+ selector.select(windowName, img.getMat(), boundingBox, showCrosshair, fromCenter);
+}
diff --git a/modules/highgui/src/window.cpp b/modules/highgui/src/window.cpp
index 9306f8e..25cc030 100644
--- a/modules/highgui/src/window.cpp
+++ b/modules/highgui/src/window.cpp
@@ -168,48 +168,57 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
void cv::namedWindow( const String& winname, int flags )
{
+ CV_TRACE_FUNCTION();
cvNamedWindow( winname.c_str(), flags );
}
void cv::destroyWindow( const String& winname )
{
+ CV_TRACE_FUNCTION();
cvDestroyWindow( winname.c_str() );
}
void cv::destroyAllWindows()
{
+ CV_TRACE_FUNCTION();
cvDestroyAllWindows();
}
void cv::resizeWindow( const String& winname, int width, int height )
{
+ CV_TRACE_FUNCTION();
cvResizeWindow( winname.c_str(), width, height );
}
void cv::moveWindow( const String& winname, int x, int y )
{
+ CV_TRACE_FUNCTION();
cvMoveWindow( winname.c_str(), x, y );
}
void cv::setWindowProperty(const String& winname, int prop_id, double prop_value)
{
+ CV_TRACE_FUNCTION();
cvSetWindowProperty( winname.c_str(), prop_id, prop_value);
}
double cv::getWindowProperty(const String& winname, int prop_id)
{
+ CV_TRACE_FUNCTION();
return cvGetWindowProperty(winname.c_str(), prop_id);
}
int cv::waitKeyEx(int delay)
{
+ CV_TRACE_FUNCTION();
return cvWaitKey(delay);
}
int cv::waitKey(int delay)
{
+ CV_TRACE_FUNCTION();
int code = waitKeyEx(delay);
-#ifndef HAVE_WINRT
+#ifndef WINRT
static int use_legacy = -1;
if (use_legacy < 0)
{
@@ -218,49 +227,57 @@ int cv::waitKey(int delay)
if (use_legacy > 0)
return code;
#endif
- return code & 0xff;
+ return (code != -1) ? (code & 0xff) : -1;
}
int cv::createTrackbar(const String& trackbarName, const String& winName,
int* value, int count, TrackbarCallback callback,
void* userdata)
{
+ CV_TRACE_FUNCTION();
return cvCreateTrackbar2(trackbarName.c_str(), winName.c_str(),
value, count, callback, userdata);
}
void cv::setTrackbarPos( const String& trackbarName, const String& winName, int value )
{
+ CV_TRACE_FUNCTION();
cvSetTrackbarPos(trackbarName.c_str(), winName.c_str(), value );
}
void cv::setTrackbarMax(const String& trackbarName, const String& winName, int maxval)
{
+ CV_TRACE_FUNCTION();
cvSetTrackbarMax(trackbarName.c_str(), winName.c_str(), maxval);
}
void cv::setTrackbarMin(const String& trackbarName, const String& winName, int minval)
{
+ CV_TRACE_FUNCTION();
cvSetTrackbarMin(trackbarName.c_str(), winName.c_str(), minval);
}
int cv::getTrackbarPos( const String& trackbarName, const String& winName )
{
+ CV_TRACE_FUNCTION();
return cvGetTrackbarPos(trackbarName.c_str(), winName.c_str());
}
void cv::setMouseCallback( const String& windowName, MouseCallback onMouse, void* param)
{
+ CV_TRACE_FUNCTION();
cvSetMouseCallback(windowName.c_str(), onMouse, param);
}
int cv::getMouseWheelDelta( int flags )
{
+ CV_TRACE_FUNCTION();
return CV_GET_WHEEL_DELTA(flags);
}
int cv::startWindowThread()
{
+ CV_TRACE_FUNCTION();
return cvStartWindowThread();
}
@@ -268,16 +285,19 @@ int cv::startWindowThread()
void cv::setOpenGlDrawCallback(const String& name, OpenGlDrawCallback callback, void* userdata)
{
+ CV_TRACE_FUNCTION();
cvSetOpenGlDrawCallback(name.c_str(), callback, userdata);
}
void cv::setOpenGlContext(const String& windowName)
{
+ CV_TRACE_FUNCTION();
cvSetOpenGlContext(windowName.c_str());
}
void cv::updateWindow(const String& windowName)
{
+ CV_TRACE_FUNCTION();
cvUpdateWindow(windowName.c_str());
}
@@ -299,6 +319,7 @@ namespace
void cv::imshow( const String& winname, InputArray _img )
{
+ CV_TRACE_FUNCTION();
const Size size = _img.size();
#ifndef HAVE_OPENGL
CV_Assert(size.width>0 && size.height>0);
@@ -355,6 +376,7 @@ void cv::imshow( const String& winname, InputArray _img )
void cv::imshow(const String& winname, const ogl::Texture2D& _tex)
{
+ CV_TRACE_FUNCTION();
#ifndef HAVE_OPENGL
(void) winname;
(void) _tex;
diff --git a/modules/highgui/src/window_QT.cpp b/modules/highgui/src/window_QT.cpp
index 4cfce66..420d2a1 100644
--- a/modules/highgui/src/window_QT.cpp
+++ b/modules/highgui/src/window_QT.cpp
@@ -351,7 +351,7 @@ CV_IMPL int cvWaitKey(int delay)
//to decrease CPU usage
//sleep 1 millisecond
-#if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64
+#if defined _WIN32
Sleep(1);
#else
usleep(1000);
diff --git a/modules/highgui/src/window_QT.h b/modules/highgui/src/window_QT.h
index b08d713..8be4bf4 100644
--- a/modules/highgui/src/window_QT.h
+++ b/modules/highgui/src/window_QT.h
@@ -42,6 +42,10 @@
#include "precomp.hpp"
+#ifndef _DEBUG
+#define QT_NO_DEBUG_OUTPUT
+#endif
+
#if defined( HAVE_QT_OPENGL )
#include <QtOpenGL>
#include <QGLWidget>
diff --git a/modules/highgui/src/window_carbon.cpp b/modules/highgui/src/window_carbon.cpp
index bbc6007..46c509c 100644
--- a/modules/highgui/src/window_carbon.cpp
+++ b/modules/highgui/src/window_carbon.cpp
@@ -282,7 +282,7 @@ static void icvPutImage( CvWindow* window )
static void icvUpdateWindowSize( const CvWindow* window )
{
- int width = 0, height = 240; /* init à al taille de base de l'image*/
+ int width = 0, height = 240;
Rect globalBounds;
GetWindowBounds(window->window, kWindowContentRgn, &globalBounds);
@@ -1031,7 +1031,7 @@ static pascal OSStatus windowEventHandler(EventHandlerCallRef nextHandler, Event
GetWindowBounds(theWindow, kWindowStructureRgn, &structure);
GetWindowBounds(theWindow, kWindowContentRgn, &content);
lx = (int)point.x - content.left + structure.left;
- ly = (int)point.y - window->trackbarheight - content.top + structure.top; /* minus la taille des trackbars */
+ ly = (int)point.y - window->trackbarheight - content.top + structure.top;
if (window->flags & CV_WINDOW_AUTOSIZE) {//FD
//printf("was %d,%d\n", lx, ly);
/* scale the mouse coordinates */
@@ -1039,7 +1039,7 @@ static pascal OSStatus windowEventHandler(EventHandlerCallRef nextHandler, Event
ly = ly * window->imageHeight / (content.bottom - content.top - window->trackbarheight);
}
- if (lx>0 && ly >0){ /* a remettre dans les coordonnées locale */
+ if (lx>0 && ly >0){
window->on_mouse (event, lx, ly, flags, window->on_mouse_param);
return noErr;
}
diff --git a/modules/highgui/src/window_cocoa.mm b/modules/highgui/src/window_cocoa.mm
index a1befc3..a653cd3 100644
--- a/modules/highgui/src/window_cocoa.mm
+++ b/modules/highgui/src/window_cocoa.mm
@@ -82,26 +82,42 @@ static NSAutoreleasePool *pool = nil;
static NSMutableDictionary *windows = nil;
static bool wasInitialized = false;
- at interface CVView : NSView
- at property(strong) NSImage *image;
+ at interface CVView : NSView {
+ NSImage *image;
+}
+ at property(retain) NSImage *image;
- (void)setImageData:(CvArr *)arr;
@end
- at interface CVSlider : NSView
- at property(strong) NSSlider *slider;
- at property(strong) NSTextField *name;
+ at interface CVSlider : NSView {
+ NSSlider *slider;
+ NSTextField *name;
+ int *value;
+ void *userData;
+ CvTrackbarCallback callback;
+ CvTrackbarCallback2 callback2;
+}
+ at property(retain) NSSlider *slider;
+ at property(retain) NSTextField *name;
@property(assign) int *value;
@property(assign) void *userData;
@property(assign) CvTrackbarCallback callback;
@property(assign) CvTrackbarCallback2 callback2;
@end
- at interface CVWindow : NSWindow
+ at interface CVWindow : NSWindow {
+ NSMutableDictionary *sliders;
+ CvMouseCallback mouseCallback;
+ void *mouseParam;
+ BOOL autosize;
+ BOOL firstContent;
+ int status;
+}
@property(assign) CvMouseCallback mouseCallback;
@property(assign) void *mouseParam;
@property(assign) BOOL autosize;
@property(assign) BOOL firstContent;
- at property(strong) NSMutableDictionary *sliders;
+ at property(retain) NSMutableDictionary *sliders;
@property(readwrite) int status;
- (CVView *)contentView;
- (void)cvSendMouseEvent:(NSEvent *)event type:(int)type flags:(int)flags;
diff --git a/modules/highgui/src/window_gtk.cpp b/modules/highgui/src/window_gtk.cpp
index 6e4da8b..0cfa59b 100644
--- a/modules/highgui/src/window_gtk.cpp
+++ b/modules/highgui/src/window_gtk.cpp
@@ -42,7 +42,7 @@
#include "precomp.hpp"
#include "opencv2/imgproc.hpp"
-#ifndef WIN32
+#ifndef _WIN32
#if defined (HAVE_GTK)
@@ -951,7 +951,8 @@ static gboolean cvImageWidget_draw(GtkWidget* widget, cairo_t *cr, gpointer data
}
cairo_paint(cr);
- g_object_unref(pixbuf);
+ if(pixbuf)
+ g_object_unref(pixbuf);
return TRUE;
}
@@ -1005,7 +1006,8 @@ static gboolean cvImageWidget_expose(GtkWidget* widget, GdkEventExpose* event, g
}
cairo_paint(cr);
- g_object_unref(pixbuf);
+ if(pixbuf)
+ g_object_unref(pixbuf);
cairo_destroy(cr);
return TRUE;
}
@@ -1617,6 +1619,10 @@ CV_IMPL void cvSetTrackbarPos( const char* trackbar_name, const char* window_nam
if( pos > trackbar->maxval )
pos = trackbar->maxval;
}
+ else
+ {
+ CV_ERROR( CV_StsNullPtr, "No trackbar found" );
+ }
CV_LOCK_MUTEX();
@@ -2091,6 +2097,6 @@ CV_IMPL int cvWaitKey( int delay )
#endif // HAVE_GTK
-#endif // WIN32
+#endif // _WIN32
/* End of file. */
diff --git a/modules/highgui/src/window_w32.cpp b/modules/highgui/src/window_w32.cpp
index cadbdf7..b1ac3b6 100644
--- a/modules/highgui/src/window_w32.cpp
+++ b/modules/highgui/src/window_w32.cpp
@@ -42,7 +42,7 @@
#include "precomp.hpp"
#include <windowsx.h> // required for GET_X_LPARAM() and GET_Y_LPARAM() macros
-#if defined WIN32 || defined _WIN32
+#if defined _WIN32
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wmissing-declarations"
@@ -65,7 +65,7 @@
#include <vector>
#include <functional>
#include "opencv2/highgui.hpp"
-#include <GL\gl.h>
+#include <GL/gl.h>
#endif
static const char* trackbar_text =
@@ -2426,4 +2426,4 @@ cvSetPostprocessFuncWin32_(const void* callback)
hg_on_postprocess = (CvWin32WindowCallback)callback;
}
-#endif //WIN32
+#endif //_WIN32
diff --git a/modules/highgui/src/window_winrt_bridge.cpp b/modules/highgui/src/window_winrt_bridge.cpp
index b107b1f..13edbe5 100644
--- a/modules/highgui/src/window_winrt_bridge.cpp
+++ b/modules/highgui/src/window_winrt_bridge.cpp
@@ -24,6 +24,8 @@
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
+#include "precomp.hpp"
+
#include "opencv2\highgui\highgui_winrt.hpp"
#include "window_winrt_bridge.hpp"
diff --git a/modules/imgcodecs/CMakeLists.txt b/modules/imgcodecs/CMakeLists.txt
index 7800640..7f53e48 100644
--- a/modules/imgcodecs/CMakeLists.txt
+++ b/modules/imgcodecs/CMakeLists.txt
@@ -1,4 +1,4 @@
-set(the_description "Image codecs")
+set(the_description "Image I/O")
ocv_add_module(imgcodecs opencv_imgproc WRAP java python)
# ----------------------------------------------------------------------------
@@ -23,7 +23,7 @@ if(HAVE_JPEG)
list(APPEND GRFMT_LIBS ${JPEG_LIBRARIES})
endif()
-if(WITH_WEBP)
+if(HAVE_WEBP)
add_definitions(-DHAVE_WEBP)
ocv_include_directories(${WEBP_INCLUDE_DIR})
list(APPEND GRFMT_LIBS ${WEBP_LIBRARIES})
@@ -92,6 +92,9 @@ if(IOS)
list(APPEND imgcodecs_srcs ${CMAKE_CURRENT_LIST_DIR}/src/ios_conversions.mm)
list(APPEND IMGCODECS_LIBRARIES "-framework Accelerate" "-framework CoreGraphics" "-framework QuartzCore" "-framework AssetsLibrary")
endif()
+if(APPLE_FRAMEWORK)
+ list(APPEND IMGCODECS_LIBRARIES "-framework UIKit")
+endif()
if(UNIX)
#these variables are set by CHECK_MODULE macro
@@ -116,10 +119,6 @@ if(APPLE)
add_apple_compiler_options(the_module)
endif()
-if(BUILD_SHARED_LIBS)
- add_definitions(-DIMGCODECS_EXPORTS)
-endif()
-
if(MSVC)
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG")
endif()
diff --git a/modules/imgcodecs/include/opencv2/imgcodecs.hpp b/modules/imgcodecs/include/opencv2/imgcodecs.hpp
index 6359de6..ff6bbca 100644
--- a/modules/imgcodecs/include/opencv2/imgcodecs.hpp
+++ b/modules/imgcodecs/include/opencv2/imgcodecs.hpp
@@ -85,8 +85,8 @@ enum ImwriteFlags {
IMWRITE_JPEG_RST_INTERVAL = 4, //!< JPEG restart interval, 0 - 65535, default is 0 - no restart.
IMWRITE_JPEG_LUMA_QUALITY = 5, //!< Separate luma quality level, 0 - 100, default is 0 - don't use.
IMWRITE_JPEG_CHROMA_QUALITY = 6, //!< Separate chroma quality level, 0 - 100, default is 0 - don't use.
- IMWRITE_PNG_COMPRESSION = 16, //!< For PNG, it can be the compression level from 0 to 9. A higher value means a smaller size and longer compression time. Default value is 3. Also strategy is changed to IMWRITE_PNG_STRATEGY_DEFAULT (Z_DEFAULT_STRATEGY).
- IMWRITE_PNG_STRATEGY = 17, //!< One of cv::ImwritePNGFlags, default is IMWRITE_PNG_STRATEGY_DEFAULT.
+ IMWRITE_PNG_COMPRESSION = 16, //!< For PNG, it can be the compression level from 0 to 9. A higher value means a smaller size and longer compression time. If specified, strategy is changed to IMWRITE_PNG_STRATEGY_DEFAULT (Z_DEFAULT_STRATEGY). Default value is 1 (best speed setting).
+ IMWRITE_PNG_STRATEGY = 17, //!< One of cv::ImwritePNGFlags, default is IMWRITE_PNG_STRATEGY_RLE.
IMWRITE_PNG_BILEVEL = 18, //!< Binary level PNG, 0 or 1, default is 0.
IMWRITE_PXM_BINARY = 32, //!< For PPM, PGM, or PBM, it can be a binary format flag, 0 or 1. Default value is 1.
IMWRITE_WEBP_QUALITY = 64, //!< For WEBP, it can be a quality from 1 to 100 (the higher is the better). By default (without any parameter) and for quality above 100 the lossless compression is used.
diff --git a/modules/imgcodecs/src/bitstrm.cpp b/modules/imgcodecs/src/bitstrm.cpp
index c47744b..a7e187f 100644
--- a/modules/imgcodecs/src/bitstrm.cpp
+++ b/modules/imgcodecs/src/bitstrm.cpp
@@ -76,6 +76,7 @@ RBaseStream::RBaseStream()
{
m_start = m_end = m_current = 0;
m_file = 0;
+ m_block_pos = 0;
m_block_size = BS_DEF_BLOCK_SIZE;
m_is_opened = false;
m_allocated = false;
@@ -336,6 +337,7 @@ WBaseStream::WBaseStream()
{
m_start = m_end = m_current = 0;
m_file = 0;
+ m_block_pos = 0;
m_block_size = BS_DEF_BLOCK_SIZE;
m_is_opened = false;
m_buf = 0;
diff --git a/modules/imgcodecs/src/exif.cpp b/modules/imgcodecs/src/exif.cpp
index 8a4f3f4..e057f8c 100644
--- a/modules/imgcodecs/src/exif.cpp
+++ b/modules/imgcodecs/src/exif.cpp
@@ -61,7 +61,7 @@ ExifEntry_t::ExifEntry_t() :
/**
* @brief ExifReader constructor
*/
-ExifReader::ExifReader(std::string filename) : m_filename(filename), m_format(NONE)
+ExifReader::ExifReader(std::istream& stream) : m_stream(stream), m_format(NONE)
{
}
@@ -121,29 +121,18 @@ ExifEntry_t ExifReader::getTag(const ExifTagName tag)
*/
std::map<int, ExifEntry_t > ExifReader::getExif()
{
- const size_t markerSize = 2;
- const size_t offsetToTiffHeader = 6; //bytes from Exif size field to the first TIFF header
+ const std::streamsize markerSize = 2;
+ const std::streamsize offsetToTiffHeader = 6; //bytes from Exif size field to the first TIFF header
unsigned char appMarker[markerSize];
m_exif.erase( m_exif.begin(), m_exif.end() );
- size_t count;
-
- if (m_filename.size() == 0)
- {
- return m_exif;
- }
-
- FILE* f = fopen( m_filename.c_str(), "rb" );
-
- if( !f )
- {
- return m_exif; //Until this moment the map is empty
- }
+ std::streamsize count;
bool exifFound = false, stopSearch = false;
- while( ( !feof( f ) ) && !exifFound && !stopSearch )
+ while( ( !m_stream.eof() ) && !exifFound && !stopSearch )
{
- count = fread( appMarker, sizeof(unsigned char), markerSize, f );
+ m_stream.read( reinterpret_cast<char*>(appMarker), markerSize );
+ count = m_stream.gcount();
if( count < markerSize )
{
break;
@@ -159,12 +148,14 @@ std::map<int, ExifEntry_t > ExifReader::getExif()
case APP0: case APP2: case APP3: case APP4: case APP5: case APP6: case APP7: case APP8:
case APP9: case APP10: case APP11: case APP12: case APP13: case APP14: case APP15:
case COM:
- bytesToSkip = getFieldSize( f );
+ bytesToSkip = getFieldSize();
if (bytesToSkip < markerSize) {
- fclose(f);
throw ExifParsingError();
}
- fseek( f, static_cast<long>( bytesToSkip - markerSize ), SEEK_CUR );
+ m_stream.seekg( static_cast<long>( bytesToSkip - markerSize ), m_stream.cur );
+ if ( m_stream.fail() ) {
+ throw ExifParsingError();
+ }
break;
//SOI and EOI don't have the size field after the marker
@@ -172,14 +163,17 @@ std::map<int, ExifEntry_t > ExifReader::getExif()
break;
case APP1: //actual Exif Marker
- exifSize = getFieldSize(f);
+ exifSize = getFieldSize();
if (exifSize <= offsetToTiffHeader) {
- fclose(f);
throw ExifParsingError();
}
m_data.resize( exifSize - offsetToTiffHeader );
- fseek(f, static_cast<long>( offsetToTiffHeader ), SEEK_CUR);
- count = fread( &m_data[0], sizeof( unsigned char ), exifSize - offsetToTiffHeader, f );
+ m_stream.seekg( static_cast<long>( offsetToTiffHeader ), m_stream.cur );
+ if ( m_stream.fail() ) {
+ throw ExifParsingError();
+ }
+ m_stream.read( reinterpret_cast<char*>(&m_data[0]), exifSize - offsetToTiffHeader );
+ count = m_stream.gcount();
exifFound = true;
break;
@@ -189,8 +183,6 @@ std::map<int, ExifEntry_t > ExifReader::getExif()
}
}
- fclose(f);
-
if( !exifFound )
{
return m_exif;
@@ -207,10 +199,11 @@ std::map<int, ExifEntry_t > ExifReader::getExif()
*
* @return size of exif field in the file
*/
-size_t ExifReader::getFieldSize (FILE* f) const
+size_t ExifReader::getFieldSize ()
{
unsigned char fieldSize[2];
- size_t count = fread ( fieldSize, sizeof( char ), 2, f );
+ m_stream.read( reinterpret_cast<char*>(fieldSize), 2 );
+ std::streamsize count = m_stream.gcount();
if (count < 2)
{
return 0;
diff --git a/modules/imgcodecs/src/exif.hpp b/modules/imgcodecs/src/exif.hpp
index 43c2857..094236b 100644
--- a/modules/imgcodecs/src/exif.hpp
+++ b/modules/imgcodecs/src/exif.hpp
@@ -51,6 +51,7 @@
#include <stdint.h>
#include <string>
#include <vector>
+#include <iostream>
namespace cv
{
@@ -168,9 +169,9 @@ public:
/**
* @brief ExifReader constructor. Constructs an object of exif reader
*
- * @param [in]filename The name of file to look exif info in
+ * @param [in]stream An istream to look for EXIF bytes from
*/
- explicit ExifReader( std::string filename );
+ explicit ExifReader( std::istream& stream );
~ExifReader();
@@ -190,7 +191,7 @@ public:
ExifEntry_t getTag( const ExifTagName tag );
private:
- std::string m_filename;
+ std::istream& m_stream;
std::vector<unsigned char> m_data;
std::map<int, ExifEntry_t > m_exif;
Endianess_t m_format;
@@ -198,7 +199,7 @@ private:
void parseExif();
bool checkTagMark() const;
- size_t getFieldSize ( FILE* f ) const;
+ size_t getFieldSize ();
size_t getNumDirEntry() const;
uint32_t getStartOffset() const;
uint16_t getExifTag( const size_t offset ) const;
@@ -247,7 +248,6 @@ private:
};
-
}
#endif /* _OPENCV_EXIF_HPP_ */
diff --git a/modules/imgcodecs/src/grfmt_base.cpp b/modules/imgcodecs/src/grfmt_base.cpp
index cda8b10..d3223db 100644
--- a/modules/imgcodecs/src/grfmt_base.cpp
+++ b/modules/imgcodecs/src/grfmt_base.cpp
@@ -96,6 +96,7 @@ ImageDecoder BaseImageDecoder::newDecoder() const
BaseImageEncoder::BaseImageEncoder()
{
+ m_buf = 0;
m_buf_supported = false;
}
diff --git a/modules/imgcodecs/src/grfmt_bmp.cpp b/modules/imgcodecs/src/grfmt_bmp.cpp
index 4063d5b..86cacd3 100644
--- a/modules/imgcodecs/src/grfmt_bmp.cpp
+++ b/modules/imgcodecs/src/grfmt_bmp.cpp
@@ -55,6 +55,9 @@ BmpDecoder::BmpDecoder()
m_signature = fmtSignBmp;
m_offset = -1;
m_buf_supported = true;
+ m_origin = 0;
+ m_bpp = 0;
+ m_rle_code = BMP_RGB;
}
@@ -191,7 +194,7 @@ bool BmpDecoder::readData( Mat& img )
uchar* data = img.ptr();
int step = (int)img.step;
bool color = img.channels() > 1;
- uchar gray_palette[256];
+ uchar gray_palette[256] = {0};
bool result = false;
int src_pitch = ((m_width*(m_bpp != 15 ? m_bpp : 16) + 7)/8 + 3) & -4;
int nch = color ? 3 : 1;
diff --git a/modules/imgcodecs/src/grfmt_exr.cpp b/modules/imgcodecs/src/grfmt_exr.cpp
index 71d8912..0d2ae9f 100644
--- a/modules/imgcodecs/src/grfmt_exr.cpp
+++ b/modules/imgcodecs/src/grfmt_exr.cpp
@@ -81,6 +81,13 @@ ExrDecoder::ExrDecoder()
m_signature = "\x76\x2f\x31\x01";
m_file = 0;
m_red = m_green = m_blue = 0;
+ m_type = ((Imf::PixelType)0);
+ m_iscolor = false;
+ m_bit_depth = 0;
+ m_isfloat = false;
+ m_ischroma = false;
+ m_native_depth = false;
+
}
@@ -201,9 +208,12 @@ bool ExrDecoder::readData( Mat& img )
xstep = m_native_depth ? 4 : 1;
+ AutoBuffer<char> copy_buffer;
+
if( !m_native_depth || (!color && m_iscolor ))
{
- buffer = (char *)new float[ m_width * 3 ];
+ copy_buffer.allocate(sizeof(float) * m_width * 3);
+ buffer = copy_buffer;
ystep = 0;
}
else
@@ -381,11 +391,6 @@ bool ExrDecoder::readData( Mat& img )
close();
- if( !m_native_depth || (!color && m_iscolor ))
- {
- delete[] buffer;
- }
-
return result;
}
diff --git a/modules/imgcodecs/src/grfmt_gdal.cpp b/modules/imgcodecs/src/grfmt_gdal.cpp
index 8865ae4..4bb8dd0 100644
--- a/modules/imgcodecs/src/grfmt_gdal.cpp
+++ b/modules/imgcodecs/src/grfmt_gdal.cpp
@@ -308,6 +308,11 @@ void write_pixel( const double& pixelValue,
// input: 4 channel, output: 4 channel
else if( gdalChannels == 4 && image.channels() == 4 ){
if( image.depth() == CV_8U ){ image.at<Vec4b>(row,col)[channel] = newValue; }
+ else if( image.depth() == CV_16U ){ image.at<Vec4s>(row,col)[channel] = newValue; }
+ else if( image.depth() == CV_16S ){ image.at<Vec4s>(row,col)[channel] = newValue; }
+ else if( image.depth() == CV_32S ){ image.at<Vec4i>(row,col)[channel] = newValue; }
+ else if( image.depth() == CV_32F ){ image.at<Vec4f>(row,col)[channel] = newValue; }
+ else if( image.depth() == CV_64F ){ image.at<Vec4d>(row,col)[channel] = newValue; }
else{ throw std::runtime_error("Unknown image depth, gdal: 4, image: 4"); }
}
@@ -574,4 +579,4 @@ bool GdalDecoder::checkSignature( const String& signature )const{
} /// End of cv Namespace
-#endif /**< End of HAVE_GDAL Definition */
\ No newline at end of file
+#endif /**< End of HAVE_GDAL Definition */
diff --git a/modules/imgcodecs/src/grfmt_jpeg.cpp b/modules/imgcodecs/src/grfmt_jpeg.cpp
index 1f5f1e8..ce942ca 100644
--- a/modules/imgcodecs/src/grfmt_jpeg.cpp
+++ b/modules/imgcodecs/src/grfmt_jpeg.cpp
@@ -57,14 +57,14 @@
#define mingw_getsp(...) 0
#define __builtin_frame_address(...) 0
-#ifdef WIN32
+#ifdef _WIN32
#define XMD_H // prevent redefinition of INT32
#undef FAR // prevent FAR redefinition
#endif
-#if defined WIN32 && defined __GNUC__
+#if defined _WIN32 && defined __GNUC__
typedef unsigned char boolean;
#endif
@@ -341,7 +341,7 @@ int my_jpeg_load_dht (struct jpeg_decompress_struct *info, unsigned char *dht,
JHUFF_TBL **hufftbl;
unsigned char bits[17];
- unsigned char huffval[256];
+ unsigned char huffval[256] = {0};
while (length > 16)
{
@@ -364,7 +364,7 @@ int my_jpeg_load_dht (struct jpeg_decompress_struct *info, unsigned char *dht,
if (index & 0x10)
{
- index -= 0x10;
+ index &= ~0x10;
hufftbl = &ac_tables[index];
}
else
diff --git a/modules/imgcodecs/src/grfmt_jpeg2000.cpp b/modules/imgcodecs/src/grfmt_jpeg2000.cpp
index 24aa457..950ec21 100644
--- a/modules/imgcodecs/src/grfmt_jpeg2000.cpp
+++ b/modules/imgcodecs/src/grfmt_jpeg2000.cpp
@@ -47,7 +47,7 @@
#include "grfmt_jpeg2000.hpp"
#include "opencv2/imgproc.hpp"
-#ifdef WIN32
+#ifdef _WIN32
#define JAS_WIN_MSVC_BUILD 1
#ifdef __GNUC__
#define HAVE_STDINT_H 1
@@ -160,7 +160,7 @@ bool Jpeg2KDecoder::readData( Mat& img )
jas_stream_t* stream = (jas_stream_t*)m_stream;
jas_image_t* image = (jas_image_t*)m_image;
-#ifndef WIN32
+#ifndef _WIN32
// At least on some Linux instances the
// system libjasper segfaults when
// converting color to grey.
@@ -272,7 +272,7 @@ bool Jpeg2KDecoder::readData( Mat& img )
close();
-#ifndef WIN32
+#ifndef _WIN32
if (!clr.empty())
{
cv::cvtColor(clr, img, COLOR_BGR2GRAY);
diff --git a/modules/imgcodecs/src/grfmt_pam.cpp b/modules/imgcodecs/src/grfmt_pam.cpp
index ac7198a..11195dc 100644
--- a/modules/imgcodecs/src/grfmt_pam.cpp
+++ b/modules/imgcodecs/src/grfmt_pam.cpp
@@ -324,6 +324,9 @@ PAMDecoder::PAMDecoder()
m_buf_supported = true;
bit_mode = false;
selected_fmt = CV_IMWRITE_PAM_FORMAT_NULL;
+ m_maxval = 0;
+ m_channels = 0;
+ m_sampledepth = 0;
}
diff --git a/modules/imgcodecs/src/grfmt_png.cpp b/modules/imgcodecs/src/grfmt_png.cpp
index c8ff244..abaf611 100644
--- a/modules/imgcodecs/src/grfmt_png.cpp
+++ b/modules/imgcodecs/src/grfmt_png.cpp
@@ -91,6 +91,7 @@ PngDecoder::PngDecoder()
m_f = 0;
m_buf_supported = true;
m_buf_pos = 0;
+ m_bit_depth = 0;
}
diff --git a/modules/imgcodecs/src/grfmt_pxm.cpp b/modules/imgcodecs/src/grfmt_pxm.cpp
index 8afd7b1..1750cb7 100644
--- a/modules/imgcodecs/src/grfmt_pxm.cpp
+++ b/modules/imgcodecs/src/grfmt_pxm.cpp
@@ -94,6 +94,9 @@ PxMDecoder::PxMDecoder()
{
m_offset = -1;
m_buf_supported = true;
+ m_bpp = 0;
+ m_binary = false;
+ m_maxval = 0;
}
diff --git a/modules/imgcodecs/src/grfmt_sunras.cpp b/modules/imgcodecs/src/grfmt_sunras.cpp
index 34e5c4e..aca9b36 100644
--- a/modules/imgcodecs/src/grfmt_sunras.cpp
+++ b/modules/imgcodecs/src/grfmt_sunras.cpp
@@ -54,6 +54,10 @@ SunRasterDecoder::SunRasterDecoder()
{
m_offset = -1;
m_signature = fmtSignSunRas;
+ m_bpp = 0;
+ m_encoding = RAS_STANDARD;
+ m_maptype = RMT_NONE;
+ m_maplength = 0;
}
@@ -157,7 +161,7 @@ bool SunRasterDecoder::readData( Mat& img )
int color = img.channels() > 1;
uchar* data = img.ptr();
int step = (int)img.step;
- uchar gray_palette[256];
+ uchar gray_palette[256] = {0};
bool result = false;
int src_pitch = ((m_width*m_bpp + 7)/8 + 1) & -2;
int nch = color ? 3 : 1;
diff --git a/modules/imgcodecs/src/grfmt_tiff.cpp b/modules/imgcodecs/src/grfmt_tiff.cpp
index a805274..165cdbd 100644
--- a/modules/imgcodecs/src/grfmt_tiff.cpp
+++ b/modules/imgcodecs/src/grfmt_tiff.cpp
@@ -732,7 +732,7 @@ bool TiffEncoder::write( const Mat& img, const std::vector<int>& /*params*/)
if( m_buf )
m_buf->reserve( alignSize(stripCount*8 + fileStep*height + 256, 256) );
-/*#if defined _DEBUG || !defined WIN32
+/*#if defined _DEBUG || !defined _WIN32
int uncompressedRowSize = rowsPerStrip * fileStep;
#endif*/
int directoryOffset = 0;
diff --git a/modules/imgcodecs/src/grfmt_webp.cpp b/modules/imgcodecs/src/grfmt_webp.cpp
index 6823279..53dd056 100644
--- a/modules/imgcodecs/src/grfmt_webp.cpp
+++ b/modules/imgcodecs/src/grfmt_webp.cpp
@@ -62,6 +62,7 @@ namespace cv
WebPDecoder::WebPDecoder()
{
m_buf_supported = true;
+ channels = 0;
}
WebPDecoder::~WebPDecoder() {}
@@ -116,7 +117,7 @@ bool WebPDecoder::readHeader()
return false;
}
- data.create(1, wfile_size, CV_8U);
+ data.create(1, (int)wfile_size, CV_8U);
size_t data_size = fread(data.ptr(), 1, wfile_size, wfile);
@@ -162,6 +163,8 @@ bool WebPDecoder::readData(Mat &img)
{
if( m_width > 0 && m_height > 0 )
{
+ bool convert_grayscale = (img.type() == CV_8UC1); // IMREAD_GRAYSCALE requested
+
if (img.cols != m_width || img.rows != m_height || img.type() != m_type)
{
img.create(m_height, m_width, m_type);
@@ -184,6 +187,10 @@ bool WebPDecoder::readData(Mat &img)
if(res_ptr == out_data)
{
+ if (convert_grayscale)
+ {
+ cvtColor(img, img, COLOR_BGR2GRAY);
+ }
return true;
}
}
diff --git a/modules/imgcodecs/src/ios_conversions.mm b/modules/imgcodecs/src/ios_conversions.mm
index eed867a..202cfe3 100644
--- a/modules/imgcodecs/src/ios_conversions.mm
+++ b/modules/imgcodecs/src/ios_conversions.mm
@@ -53,7 +53,7 @@ void UIImageToMat(const UIImage* image, cv::Mat& m, bool alphaExist);
UIImage* MatToUIImage(const cv::Mat& image) {
NSData *data = [NSData dataWithBytes:image.data
- length:image.elemSize()*image.total()];
+ length:image.step.p[0] * image.rows];
CGColorSpaceRef colorSpace;
@@ -73,7 +73,7 @@ UIImage* MatToUIImage(const cv::Mat& image) {
// Creating CGImage from cv::Mat
CGImageRef imageRef = CGImageCreate(image.cols,
image.rows,
- 8,
+ 8 * image.elemSize1(),
8 * image.elemSize(),
image.step.p[0],
colorSpace,
@@ -97,7 +97,7 @@ UIImage* MatToUIImage(const cv::Mat& image) {
void UIImageToMat(const UIImage* image,
cv::Mat& m, bool alphaExist) {
CGColorSpaceRef colorSpace = CGImageGetColorSpace(image.CGImage);
- CGFloat cols = image.size.width, rows = image.size.height;
+ CGFloat cols = CGImageGetWidth(image.CGImage), rows = CGImageGetHeight(image.CGImage);
CGContextRef contextRef;
CGBitmapInfo bitmapInfo = kCGImageAlphaPremultipliedLast;
if (CGColorSpaceGetModel(colorSpace) == kCGColorSpaceModelMonochrome)
diff --git a/modules/imgcodecs/src/loadsave.cpp b/modules/imgcodecs/src/loadsave.cpp
index 493ccab..3b23662 100644
--- a/modules/imgcodecs/src/loadsave.cpp
+++ b/modules/imgcodecs/src/loadsave.cpp
@@ -50,10 +50,50 @@
#undef min
#undef max
#include <iostream>
+#include <fstream>
/****************************************************************************************\
* Image Codecs *
\****************************************************************************************/
+namespace {
+
+class ByteStreamBuffer: public std::streambuf
+{
+public:
+ ByteStreamBuffer(char* base, size_t length)
+ {
+ setg(base, base, base + length);
+ }
+
+protected:
+ virtual pos_type seekoff( off_type offset,
+ std::ios_base::seekdir dir,
+ std::ios_base::openmode )
+ {
+ char* whence = eback();
+ if (dir == std::ios_base::cur)
+ {
+ whence = gptr();
+ }
+ else if (dir == std::ios_base::end)
+ {
+ whence = egptr();
+ }
+ char* to = whence + offset;
+
+ // check limits
+ if (to >= eback() && to <= egptr())
+ {
+ setg(eback(), to, egptr());
+ return gptr() - eback();
+ }
+
+ return -1;
+ }
+};
+
+}
+
namespace cv
{
@@ -232,23 +272,8 @@ static ImageEncoder findEncoder( const String& _ext )
enum { LOAD_CVMAT=0, LOAD_IMAGE=1, LOAD_MAT=2 };
-static void ApplyExifOrientation(const String& filename, Mat& img)
+static void ExifTransform(int orientation, Mat& img)
{
- int orientation = IMAGE_ORIENTATION_TL;
-
- if (filename.size() > 0)
- {
- ExifReader reader( filename );
- if( reader.parse() )
- {
- ExifEntry_t entry = reader.getTag( ORIENTATION );
- if (entry.tag != INVALID_TAG)
- {
- orientation = entry.field_u16; //orientation is unsigned short, so check field_u16
- }
- }
- }
-
switch( orientation )
{
case IMAGE_ORIENTATION_TL: //0th row == visual top, 0th column == visual left-hand side
@@ -284,6 +309,50 @@ static void ApplyExifOrientation(const String& filename, Mat& img)
}
}
+static void ApplyExifOrientation(const String& filename, Mat& img)
+{
+ int orientation = IMAGE_ORIENTATION_TL;
+
+ if (filename.size() > 0)
+ {
+ std::ifstream stream( filename.c_str(), std::ios_base::in | std::ios_base::binary );
+ ExifReader reader( stream );
+ if( reader.parse() )
+ {
+ ExifEntry_t entry = reader.getTag( ORIENTATION );
+ if (entry.tag != INVALID_TAG)
+ {
+ orientation = entry.field_u16; //orientation is unsigned short, so check field_u16
+ }
+ }
+ stream.close();
+ }
+
+ ExifTransform(orientation, img);
+}
+
+static void ApplyExifOrientation(const Mat& buf, Mat& img)
+{
+ int orientation = IMAGE_ORIENTATION_TL;
+
+ if( buf.isContinuous() )
+ {
+ ByteStreamBuffer bsb( reinterpret_cast<char*>(buf.data), buf.total() * buf.elemSize() );
+ std::istream stream( &bsb );
+ ExifReader reader( stream );
+ if( reader.parse() )
+ {
+ ExifEntry_t entry = reader.getTag( ORIENTATION );
+ if (entry.tag != INVALID_TAG)
+ {
+ orientation = entry.field_u16; //orientation is unsigned short, so check field_u16
+ }
+ }
+ }
+
+ ExifTransform(orientation, img);
+}
+
/**
* Read an image into memory and return the information
*
@@ -487,6 +556,8 @@ imreadmulti_(const String& filename, int flags, std::vector<Mat>& mats)
*/
Mat imread( const String& filename, int flags )
{
+ CV_TRACE_FUNCTION();
+
/// create the basic container
Mat img;
@@ -494,7 +565,7 @@ Mat imread( const String& filename, int flags )
imread_( filename, flags, LOAD_MAT, &img );
/// optionally rotate the data if EXIF' orientation flag says so
- if( (flags & IMREAD_IGNORE_ORIENTATION) == 0 && flags != IMREAD_UNCHANGED )
+ if( !img.empty() && (flags & IMREAD_IGNORE_ORIENTATION) == 0 && flags != IMREAD_UNCHANGED )
{
ApplyExifOrientation(filename, img);
}
@@ -515,6 +586,8 @@ Mat imread( const String& filename, int flags )
*/
bool imreadmulti(const String& filename, std::vector<Mat>& mats, int flags)
{
+ CV_TRACE_FUNCTION();
+
return imreadmulti_(filename, flags, mats);
}
@@ -552,6 +625,8 @@ static bool imwrite_( const String& filename, const Mat& image,
bool imwrite( const String& filename, InputArray _img,
const std::vector<int>& params )
{
+ CV_TRACE_FUNCTION();
+
Mat img = _img.getMat();
return imwrite_(filename, img, params, false);
}
@@ -576,8 +651,15 @@ imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 )
if( !f )
return 0;
size_t bufSize = buf.cols*buf.rows*buf.elemSize();
- fwrite( buf.ptr(), 1, bufSize, f );
- fclose(f);
+ if( fwrite( buf.ptr(), 1, bufSize, f ) != bufSize )
+ {
+ fclose( f );
+ CV_Error( CV_StsError, "failed to write image data to temporary file" );
+ }
+ if( fclose(f) != 0 )
+ {
+ CV_Error( CV_StsError, "failed to write image data to temporary file" );
+ }
decoder->setSource(filename);
}
@@ -656,22 +738,42 @@ imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 )
Mat imdecode( InputArray _buf, int flags )
{
+ CV_TRACE_FUNCTION();
+
Mat buf = _buf.getMat(), img;
imdecode_( buf, flags, LOAD_MAT, &img );
+
+ /// optionally rotate the data if EXIF' orientation flag says so
+ if( !img.empty() && (flags & IMREAD_IGNORE_ORIENTATION) == 0 && flags != IMREAD_UNCHANGED )
+ {
+ ApplyExifOrientation(buf, img);
+ }
+
return img;
}
Mat imdecode( InputArray _buf, int flags, Mat* dst )
{
+ CV_TRACE_FUNCTION();
+
Mat buf = _buf.getMat(), img;
dst = dst ? dst : &img;
imdecode_( buf, flags, LOAD_MAT, dst );
+
+ /// optionally rotate the data if EXIF' orientation flag says so
+ if( !dst->empty() && (flags & IMREAD_IGNORE_ORIENTATION) == 0 && flags != IMREAD_UNCHANGED )
+ {
+ ApplyExifOrientation(buf, *dst);
+ }
+
return *dst;
}
bool imencode( const String& ext, InputArray _image,
std::vector<uchar>& buf, const std::vector<int>& params )
{
+ CV_TRACE_FUNCTION();
+
Mat image = _image.getMat();
int channels = image.channels();
diff --git a/modules/imgcodecs/src/precomp.hpp b/modules/imgcodecs/src/precomp.hpp
index 6a16ca8..d5ce248 100644
--- a/modules/imgcodecs/src/precomp.hpp
+++ b/modules/imgcodecs/src/precomp.hpp
@@ -58,7 +58,7 @@
#include <ctype.h>
#include <assert.h>
-#if defined WIN32 || defined WINCE
+#if defined _WIN32 || defined WINCE
#include <windows.h>
#undef small
#undef min
diff --git a/modules/imgcodecs/test/test_grfmt.cpp b/modules/imgcodecs/test/test_grfmt.cpp
index faca3d7..64a0c1e 100644
--- a/modules/imgcodecs/test/test_grfmt.cpp
+++ b/modules/imgcodecs/test/test_grfmt.cpp
@@ -42,979 +42,185 @@
#include "test_precomp.hpp"
-#include <fstream>
-#include <sstream>
-#include <iostream>
-
using namespace cv;
using namespace std;
+using namespace std::tr1;
-static
-bool mats_equal(const Mat& lhs, const Mat& rhs)
-{
- if (lhs.channels() != rhs.channels() ||
- lhs.depth() != rhs.depth() ||
- lhs.size().height != rhs.size().height ||
- lhs.size().width != rhs.size().width)
- {
- return false;
- }
+typedef tuple<string, int> File_Mode;
+typedef testing::TestWithParam<File_Mode> Imgcodecs_FileMode;
- Mat diff = (lhs != rhs);
- const Scalar s = sum(diff);
- for (int i = 0; i < s.channels; ++i)
- {
- if (s[i] != 0)
- {
- return false;
- }
- }
+TEST_P(Imgcodecs_FileMode, regression)
+{
+ const string root = cvtest::TS::ptr()->get_data_path();
+ const string filename = root + get<0>(GetParam());
+ const int mode = get<1>(GetParam());
- return true;
-}
+ const Mat single = imread(filename, mode);
+ ASSERT_FALSE(single.empty());
-static
-bool imread_compare(const string& filepath, int flags = IMREAD_COLOR)
-{
vector<Mat> pages;
- if (!imreadmulti(filepath, pages, flags) ||
- pages.empty())
- {
- return false;
- }
-
- const Mat single = imread(filepath, flags);
- return mats_equal(single, pages[0]);
+ ASSERT_TRUE(imreadmulti(filename, pages, mode));
+ ASSERT_FALSE(pages.empty());
+ const Mat page = pages[0];
+ ASSERT_FALSE(page.empty());
+
+ EXPECT_EQ(page.channels(), single.channels());
+ EXPECT_EQ(page.depth(), single.depth());
+ EXPECT_EQ(page.size().height, single.size().height);
+ EXPECT_EQ(page.size().width, single.size().width);
+ EXPECT_PRED_FORMAT2(cvtest::MatComparator(0, 0), page, single);
}
-TEST(Imgcodecs_imread, regression)
+const string all_images[] =
{
- const char* const filenames[] =
- {
#ifdef HAVE_JASPER
- "Rome.jp2",
+ "readwrite/Rome.jp2",
+ "readwrite/Bretagne2.jp2",
+ "readwrite/Bretagne2.jp2",
+ "readwrite/Grey.jp2",
+ "readwrite/Grey.jp2",
#endif
#ifdef HAVE_GDCM
- "int16-mono1.dcm",
- "uint8-mono2.dcm",
- "uint16-mono2.dcm",
- "uint8-rgb.dcm",
+ "readwrite/int16-mono1.dcm",
+ "readwrite/uint8-mono2.dcm",
+ "readwrite/uint16-mono2.dcm",
+ "readwrite/uint8-rgb.dcm",
#endif
- "color_palette_alpha.png",
- "multipage.tif",
- "rle.hdr",
- "ordinary.bmp",
- "rle8.bmp",
- "test_1_c1.jpg"
- };
-
- const string folder = string(cvtest::TS::ptr()->get_data_path()) + "/readwrite/";
-
- for (size_t i = 0; i < sizeof(filenames) / sizeof(filenames[0]); ++i)
- {
- const string path = folder + string(filenames[i]);
- ASSERT_TRUE(imread_compare(path, IMREAD_UNCHANGED));
- ASSERT_TRUE(imread_compare(path, IMREAD_GRAYSCALE));
- ASSERT_TRUE(imread_compare(path, IMREAD_COLOR));
- ASSERT_TRUE(imread_compare(path, IMREAD_ANYDEPTH));
- ASSERT_TRUE(imread_compare(path, IMREAD_ANYCOLOR));
- const string ext = path.substr( path.length() - 3 );
- if ( ext != "hdr" && ext != "dcm" )
- {
- // GDAL does not support hdr nor dcm
- ASSERT_TRUE(imread_compare(path, IMREAD_LOAD_GDAL));
- }
- }
-}
-
-template<class T>
-string to_string(T i)
-{
- stringstream ss;
- string s;
- ss << i;
- s = ss.str();
-
- return s;
-}
-
-
-/**
- * Test for check whether reading exif orientation tag was processed successfully or not
- * The test info is the set of 8 images named testExifRotate_{1 to 8}.jpg
- * The test image is the square 10x10 points divided by four sub-squares:
- * (R corresponds to Red, G to Green, B to Blue, W to white)
- * --------- ---------
- * | R | G | | G | R |
- * |-------| - (tag 1) |-------| - (tag 2)
- * | B | W | | W | B |
- * --------- ---------
- *
- * --------- ---------
- * | W | B | | B | W |
- * |-------| - (tag 3) |-------| - (tag 4)
- * | G | R | | R | G |
- * --------- ---------
- *
- * --------- ---------
- * | R | B | | G | W |
- * |-------| - (tag 5) |-------| - (tag 6)
- * | G | W | | R | B |
- * --------- ---------
- *
- * --------- ---------
- * | W | G | | B | R |
- * |-------| - (tag 7) |-------| - (tag 8)
- * | B | R | | W | G |
- * --------- ---------
- *
- *
- * Every image contains exif field with orientation tag (0x112)
- * After reading each image the corresponding matrix must be read as
- * ---------
- * | R | G |
- * |-------|
- * | B | W |
- * ---------
- *
- */
-class CV_GrfmtJpegExifOrientationTest : public cvtest::BaseTest
-{
-public:
- void run(int)
- {
- try
- {
- for( int i = 1; i <= 8; ++i)
- {
- string fileName = "readwrite/testExifOrientation_" + to_string(i) + ".jpg";
- m_img = imread(string(ts->get_data_path()) + fileName);
- if( !m_img.data )
- {
- ts->set_failed_test_info(cvtest::TS::FAIL_MISSING_TEST_DATA);
- }
- ts->printf(cvtest::TS::LOG, "start reading image\t%s\n", fileName.c_str());
- if( !checkOrientation() )
- {
- ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH);
- }
- }
-
- }
- catch(...)
- {
- ts->set_failed_test_info(cvtest::TS::FAIL_EXCEPTION);
- }
- }
-private:
- bool checkOrientation();
- Mat m_img;
+ "readwrite/color_palette_alpha.png",
+ "readwrite/multipage.tif",
+ "readwrite/ordinary.bmp",
+ "readwrite/rle8.bmp",
+ "readwrite/test_1_c1.jpg",
+ "readwrite/rle.hdr"
};
-
-bool CV_GrfmtJpegExifOrientationTest::checkOrientation()
+const int basic_modes[] =
{
- Vec3b vec;
- int red = 0;
- int green = 0;
- int blue = 0;
-
- const int colorThresholdHigh = 250;
- const int colorThresholdLow = 5;
-
- //Checking the first quadrant (with supposed red)
- vec = m_img.at<Vec3b>(2, 2); //some point inside the square
- red = vec.val[2];
- green = vec.val[1];
- blue = vec.val[0];
-
- ts->printf(cvtest::TS::LOG, "RED QUADRANT:\n");
- ts->printf(cvtest::TS::LOG, "Red calculated:\t\t%d\n", red);
- ts->printf(cvtest::TS::LOG, "Green calculated:\t%d\n", green);
- ts->printf(cvtest::TS::LOG, "Blue calculated:\t%d\n", blue);
- if( red < colorThresholdHigh ) return false;
- if( blue > colorThresholdLow ) return false;
- if( green > colorThresholdLow ) return false;
-
- //Checking the second quadrant (with supposed green)
- vec = m_img.at<Vec3b>(2, 7); //some point inside the square
- red = vec.val[2];
- green = vec.val[1];
- blue = vec.val[0];
- ts->printf(cvtest::TS::LOG, "GREEN QUADRANT:\n");
- ts->printf(cvtest::TS::LOG, "Red calculated:\t\t%d\n", red);
- ts->printf(cvtest::TS::LOG, "Green calculated:\t%d\n", green);
- ts->printf(cvtest::TS::LOG, "Blue calculated:\t%d\n", blue);
- if( green < colorThresholdHigh ) return false;
- if( red > colorThresholdLow ) return false;
- if( blue > colorThresholdLow ) return false;
-
- //Checking the third quadrant (with supposed blue)
- vec = m_img.at<Vec3b>(7, 2); //some point inside the square
- red = vec.val[2];
- green = vec.val[1];
- blue = vec.val[0];
- ts->printf(cvtest::TS::LOG, "BLUE QUADRANT:\n");
- ts->printf(cvtest::TS::LOG, "Red calculated:\t\t%d\n", red);
- ts->printf(cvtest::TS::LOG, "Green calculated:\t%d\n", green);
- ts->printf(cvtest::TS::LOG, "Blue calculated:\t%d\n", blue);
- if( blue < colorThresholdHigh ) return false;
- if( red > colorThresholdLow ) return false;
- if( green > colorThresholdLow ) return false;
-
- return true;
-}
-
-TEST(Imgcodecs_jpeg_exif, setOrientation)
-{
- CV_GrfmtJpegExifOrientationTest test;
- test.safe_run();
-}
-
-#ifdef HAVE_JASPER
-TEST(Imgcodecs_jasper, regression)
-{
- const string folder = string(cvtest::TS::ptr()->get_data_path()) + "/readwrite/";
-
- ASSERT_TRUE(imread_compare(folder + "Bretagne2.jp2", IMREAD_COLOR));
- ASSERT_TRUE(imread_compare(folder + "Bretagne2.jp2", IMREAD_GRAYSCALE));
- ASSERT_TRUE(imread_compare(folder + "Grey.jp2", IMREAD_COLOR));
- ASSERT_TRUE(imread_compare(folder + "Grey.jp2", IMREAD_GRAYSCALE));
-}
-#endif
-
-class CV_GrfmtWriteBigImageTest : public cvtest::BaseTest
-{
-public:
- void run(int)
- {
- try
- {
- ts->printf(cvtest::TS::LOG, "start reading big image\n");
- Mat img = imread(string(ts->get_data_path()) + "readwrite/read.png");
- ts->printf(cvtest::TS::LOG, "finish reading big image\n");
- if (img.empty()) ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
- ts->printf(cvtest::TS::LOG, "start writing big image\n");
- imwrite(cv::tempfile(".png"), img);
- ts->printf(cvtest::TS::LOG, "finish writing big image\n");
- }
- catch(...)
- {
- ts->set_failed_test_info(cvtest::TS::FAIL_EXCEPTION);
- }
- ts->set_failed_test_info(cvtest::TS::OK);
- }
+ IMREAD_UNCHANGED,
+ IMREAD_GRAYSCALE,
+ IMREAD_COLOR,
+ IMREAD_ANYDEPTH,
+ IMREAD_ANYCOLOR
};
-string ext_from_int(int ext)
-{
-#ifdef HAVE_PNG
- if (ext == 0) return ".png";
-#endif
- if (ext == 1) return ".bmp";
- if (ext == 2) return ".pgm";
-#ifdef HAVE_TIFF
- if (ext == 3) return ".tiff";
-#endif
- if (ext == 4) return ".pam";
- return "";
-}
-
-class CV_GrfmtWriteSequenceImageTest : public cvtest::BaseTest
-{
-public:
- void run(int)
- {
- try
- {
- const int img_r = 640;
- const int img_c = 480;
-
- for (int k = 1; k <= 5; ++k)
- {
- for (int ext = 0; ext < 5; ++ext) // 0 - png, 1 - bmp, 2 - pgm, 3 - tiff
- {
- if(ext_from_int(ext).empty())
- continue;
- for (int num_channels = 1; num_channels <= 4; num_channels++)
- {
- if (num_channels == 2) continue;
- if (num_channels == 4 && ext!=3 /*TIFF*/) continue;
-
- ts->printf(ts->LOG, "image type depth:%d channels:%d ext: %s\n", CV_8U, num_channels, ext_from_int(ext).c_str());
- Mat img(img_r * k, img_c * k, CV_MAKETYPE(CV_8U, num_channels), Scalar::all(0));
- circle(img, Point2i((img_c * k) / 2, (img_r * k) / 2), std::min((img_r * k), (img_c * k)) / 4 , Scalar::all(255));
+INSTANTIATE_TEST_CASE_P(All, Imgcodecs_FileMode,
+ testing::Combine(
+ testing::ValuesIn(all_images),
+ testing::ValuesIn(basic_modes)));
- string img_path = cv::tempfile(ext_from_int(ext).c_str());
- ts->printf(ts->LOG, "writing image : %s\n", img_path.c_str());
- imwrite(img_path, img);
-
- ts->printf(ts->LOG, "reading test image : %s\n", img_path.c_str());
- Mat img_test = imread(img_path, IMREAD_UNCHANGED);
-
- if (img_test.empty()) ts->set_failed_test_info(ts->FAIL_MISMATCH);
-
- CV_Assert(img.size() == img_test.size());
- CV_Assert(img.type() == img_test.type());
- CV_Assert(num_channels == img_test.channels());
-
- double n = cvtest::norm(img, img_test, NORM_L2);
- if ( n > 1.0)
- {
- ts->printf(ts->LOG, "norm = %f \n", n);
- ts->set_failed_test_info(ts->FAIL_MISMATCH);
- }
- }
- }
-
-#ifdef HAVE_JPEG
- for (int num_channels = 1; num_channels <= 3; num_channels+=2)
- {
- // jpeg
- ts->printf(ts->LOG, "image type depth:%d channels:%d ext: %s\n", CV_8U, num_channels, ".jpg");
- Mat img(img_r * k, img_c * k, CV_MAKETYPE(CV_8U, num_channels), Scalar::all(0));
- circle(img, Point2i((img_c * k) / 2, (img_r * k) / 2), std::min((img_r * k), (img_c * k)) / 4 , Scalar::all(255));
-
- string filename = cv::tempfile(".jpg");
- imwrite(filename, img);
- ts->printf(ts->LOG, "reading test image : %s\n", filename.c_str());
- Mat img_test = imread(filename, IMREAD_UNCHANGED);
-
- if (img_test.empty()) ts->set_failed_test_info(ts->FAIL_MISMATCH);
-
- CV_Assert(img.size() == img_test.size());
- CV_Assert(img.type() == img_test.type());
-
- // JPEG format does not provide 100% accuracy
- // using fuzzy image comparison
- double n = cvtest::norm(img, img_test, NORM_L1);
- double expected = 0.05 * img.size().area();
- if ( n > expected)
- {
- ts->printf(ts->LOG, "norm = %f > expected = %f \n", n, expected);
- ts->set_failed_test_info(ts->FAIL_MISMATCH);
- }
- }
-#endif
-
-#ifdef HAVE_TIFF
- for (int num_channels = 1; num_channels <= 4; num_channels++)
- {
- if (num_channels == 2) continue;
- // tiff
- ts->printf(ts->LOG, "image type depth:%d channels:%d ext: %s\n", CV_16U, num_channels, ".tiff");
- Mat img(img_r * k, img_c * k, CV_MAKETYPE(CV_16U, num_channels), Scalar::all(0));
- circle(img, Point2i((img_c * k) / 2, (img_r * k) / 2), std::min((img_r * k), (img_c * k)) / 4 , Scalar::all(255));
-
- string filename = cv::tempfile(".tiff");
- imwrite(filename, img);
- ts->printf(ts->LOG, "reading test image : %s\n", filename.c_str());
- Mat img_test = imread(filename, IMREAD_UNCHANGED);
-
- if (img_test.empty()) ts->set_failed_test_info(ts->FAIL_MISMATCH);
-
- CV_Assert(img.size() == img_test.size());
-
- ts->printf(ts->LOG, "img : %d ; %d \n", img.channels(), img.depth());
- ts->printf(ts->LOG, "img_test : %d ; %d \n", img_test.channels(), img_test.depth());
-
- CV_Assert(img.type() == img_test.type());
-
-
- double n = cvtest::norm(img, img_test, NORM_L2);
- if ( n > 1.0)
- {
- ts->printf(ts->LOG, "norm = %f \n", n);
- ts->set_failed_test_info(ts->FAIL_MISMATCH);
- }
- }
-#endif
- }
- }
- catch(const cv::Exception & e)
- {
- ts->printf(ts->LOG, "Exception: %s\n" , e.what());
- ts->set_failed_test_info(ts->FAIL_MISMATCH);
- }
- }
-};
-
-class CV_GrfmtReadBMPRLE8Test : public cvtest::BaseTest
-{
-public:
- void run(int)
- {
- try
- {
- Mat rle = imread(string(ts->get_data_path()) + "readwrite/rle8.bmp");
- Mat bmp = imread(string(ts->get_data_path()) + "readwrite/ordinary.bmp");
- if (cvtest::norm(rle-bmp, NORM_L2)>1.e-10)
- ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
- }
- catch(...)
- {
- ts->set_failed_test_info(cvtest::TS::FAIL_EXCEPTION);
- }
- ts->set_failed_test_info(cvtest::TS::OK);
- }
-};
-
-
-#ifdef HAVE_PNG
-TEST(Imgcodecs_Image, write_big) { CV_GrfmtWriteBigImageTest test; test.safe_run(); }
-#endif
-
-TEST(Imgcodecs_Image, write_imageseq) { CV_GrfmtWriteSequenceImageTest test; test.safe_run(); }
-
-TEST(Imgcodecs_Image, read_bmp_rle8) { CV_GrfmtReadBMPRLE8Test test; test.safe_run(); }
-
-#ifdef HAVE_PNG
-class CV_GrfmtPNGEncodeTest : public cvtest::BaseTest
-{
-public:
- void run(int)
- {
- try
- {
- vector<uchar> buff;
- Mat im = Mat::zeros(1000,1000, CV_8U);
- //randu(im, 0, 256);
- vector<int> param;
- param.push_back(IMWRITE_PNG_COMPRESSION);
- param.push_back(3); //default(3) 0-9.
- cv::imencode(".png" ,im ,buff, param);
-
- // hangs
- Mat im2 = imdecode(buff,IMREAD_ANYDEPTH);
- }
- catch(...)
- {
- ts->set_failed_test_info(cvtest::TS::FAIL_EXCEPTION);
- }
- ts->set_failed_test_info(cvtest::TS::OK);
+// GDAL does not support "hdr", "dcm" and have problems with "jp2"
+struct notForGDAL {
+ bool operator()(const string &name) const {
+ const string &ext = name.substr(name.size() - 3, 3);
+ return ext == "hdr" || ext == "dcm" || ext == "jp2";
}
};
-TEST(Imgcodecs_Image, encode_png) { CV_GrfmtPNGEncodeTest test; test.safe_run(); }
-
-TEST(Imgcodecs_ImreadVSCvtColor, regression)
+inline vector<string> gdal_images()
{
- cvtest::TS& ts = *cvtest::TS::ptr();
-
- const int MAX_MEAN_DIFF = 1;
- const int MAX_ABS_DIFF = 10;
-
- string imgName = string(ts.get_data_path()) + "/../cv/shared/lena.png";
- Mat original_image = imread(imgName);
- Mat gray_by_codec = imread(imgName, 0);
- Mat gray_by_cvt;
-
- cvtColor(original_image, gray_by_cvt, CV_BGR2GRAY);
-
- Mat diff;
- absdiff(gray_by_codec, gray_by_cvt, diff);
-
- double actual_avg_diff = (double)mean(diff)[0];
- double actual_maxval, actual_minval;
- minMaxLoc(diff, &actual_minval, &actual_maxval);
- //printf("actual avg = %g, actual maxdiff = %g, npixels = %d\n", actual_avg_diff, actual_maxval, (int)diff.total());
-
- EXPECT_LT(actual_avg_diff, MAX_MEAN_DIFF);
- EXPECT_LT(actual_maxval, MAX_ABS_DIFF);
+ vector<string> res;
+ back_insert_iterator< vector<string> > it(res);
+ remove_copy_if(all_images, all_images + sizeof(all_images)/sizeof(all_images[0]), it, notForGDAL());
+ return res;
}
-//Test OpenCV issue 3075 is solved
-class CV_GrfmtReadPNGColorPaletteWithAlphaTest : public cvtest::BaseTest
-{
-public:
- void run(int)
- {
- try
- {
- // First Test : Read PNG with alpha, imread flag -1
- Mat img = imread(string(ts->get_data_path()) + "readwrite/color_palette_alpha.png",-1);
- if (img.empty()) ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
-
- ASSERT_TRUE(img.channels() == 4);
-
- unsigned char* img_data = img.ptr();
-
- // Verification first pixel is red in BGRA
- ASSERT_TRUE(img_data[0] == 0x00);
- ASSERT_TRUE(img_data[1] == 0x00);
- ASSERT_TRUE(img_data[2] == 0xFF);
- ASSERT_TRUE(img_data[3] == 0xFF);
-
- // Verification second pixel is red in BGRA
- ASSERT_TRUE(img_data[4] == 0x00);
- ASSERT_TRUE(img_data[5] == 0x00);
- ASSERT_TRUE(img_data[6] == 0xFF);
- ASSERT_TRUE(img_data[7] == 0xFF);
-
- // Second Test : Read PNG without alpha, imread flag -1
- img = imread(string(ts->get_data_path()) + "readwrite/color_palette_no_alpha.png",-1);
- if (img.empty()) ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
-
- ASSERT_TRUE(img.channels() == 3);
-
- img_data = img.ptr();
-
- // Verification first pixel is red in BGR
- ASSERT_TRUE(img_data[0] == 0x00);
- ASSERT_TRUE(img_data[1] == 0x00);
- ASSERT_TRUE(img_data[2] == 0xFF);
-
- // Verification second pixel is red in BGR
- ASSERT_TRUE(img_data[3] == 0x00);
- ASSERT_TRUE(img_data[4] == 0x00);
- ASSERT_TRUE(img_data[5] == 0xFF);
-
- // Third Test : Read PNG with alpha, imread flag 1
- img = imread(string(ts->get_data_path()) + "readwrite/color_palette_alpha.png",1);
- if (img.empty()) ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
-
- ASSERT_TRUE(img.channels() == 3);
-
- img_data = img.ptr();
+INSTANTIATE_TEST_CASE_P(GDAL, Imgcodecs_FileMode,
+ testing::Combine(
+ testing::ValuesIn(gdal_images()),
+ testing::Values(IMREAD_LOAD_GDAL)));
- // Verification first pixel is red in BGR
- ASSERT_TRUE(img_data[0] == 0x00);
- ASSERT_TRUE(img_data[1] == 0x00);
- ASSERT_TRUE(img_data[2] == 0xFF);
+//==================================================================================================
- // Verification second pixel is red in BGR
- ASSERT_TRUE(img_data[3] == 0x00);
- ASSERT_TRUE(img_data[4] == 0x00);
- ASSERT_TRUE(img_data[5] == 0xFF);
+typedef tuple<string, Size> Ext_Size;
+typedef testing::TestWithParam<Ext_Size> Imgcodecs_ExtSize;
- // Fourth Test : Read PNG without alpha, imread flag 1
- img = imread(string(ts->get_data_path()) + "readwrite/color_palette_no_alpha.png",1);
- if (img.empty()) ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
-
- ASSERT_TRUE(img.channels() == 3);
-
- img_data = img.ptr();
-
- // Verification first pixel is red in BGR
- ASSERT_TRUE(img_data[0] == 0x00);
- ASSERT_TRUE(img_data[1] == 0x00);
- ASSERT_TRUE(img_data[2] == 0xFF);
-
- // Verification second pixel is red in BGR
- ASSERT_TRUE(img_data[3] == 0x00);
- ASSERT_TRUE(img_data[4] == 0x00);
- ASSERT_TRUE(img_data[5] == 0xFF);
- }
- catch(...)
- {
- ts->set_failed_test_info(cvtest::TS::FAIL_EXCEPTION);
- }
- ts->set_failed_test_info(cvtest::TS::OK);
- }
-};
-
-TEST(Imgcodecs_Image, read_png_color_palette_with_alpha) { CV_GrfmtReadPNGColorPaletteWithAlphaTest test; test.safe_run(); }
-#endif
-
-#ifdef HAVE_JPEG
-TEST(Imgcodecs_Jpeg, encode_empty)
-{
- cv::Mat img;
- std::vector<uchar> jpegImg;
-
- ASSERT_THROW(cv::imencode(".jpg", img, jpegImg), cv::Exception);
-}
-
-TEST(Imgcodecs_Jpeg, encode_decode_progressive_jpeg)
-{
- cvtest::TS& ts = *cvtest::TS::ptr();
- string input = string(ts.get_data_path()) + "../cv/shared/lena.png";
- cv::Mat img = cv::imread(input);
- ASSERT_FALSE(img.empty());
-
- std::vector<int> params;
- params.push_back(IMWRITE_JPEG_PROGRESSIVE);
- params.push_back(1);
-
- string output_progressive = cv::tempfile(".jpg");
- EXPECT_NO_THROW(cv::imwrite(output_progressive, img, params));
- cv::Mat img_jpg_progressive = cv::imread(output_progressive);
-
- string output_normal = cv::tempfile(".jpg");
- EXPECT_NO_THROW(cv::imwrite(output_normal, img));
- cv::Mat img_jpg_normal = cv::imread(output_normal);
-
- EXPECT_EQ(0, cvtest::norm(img_jpg_progressive, img_jpg_normal, NORM_INF));
-
- remove(output_progressive.c_str());
-}
-
-TEST(Imgcodecs_Jpeg, encode_decode_optimize_jpeg)
-{
- cvtest::TS& ts = *cvtest::TS::ptr();
- string input = string(ts.get_data_path()) + "../cv/shared/lena.png";
- cv::Mat img = cv::imread(input);
- ASSERT_FALSE(img.empty());
-
- std::vector<int> params;
- params.push_back(IMWRITE_JPEG_OPTIMIZE);
- params.push_back(1);
-
- string output_optimized = cv::tempfile(".jpg");
- EXPECT_NO_THROW(cv::imwrite(output_optimized, img, params));
- cv::Mat img_jpg_optimized = cv::imread(output_optimized);
-
- string output_normal = cv::tempfile(".jpg");
- EXPECT_NO_THROW(cv::imwrite(output_normal, img));
- cv::Mat img_jpg_normal = cv::imread(output_normal);
-
- EXPECT_EQ(0, cvtest::norm(img_jpg_optimized, img_jpg_normal, NORM_INF));
-
- remove(output_optimized.c_str());
-}
-
-TEST(Imgcodecs_Jpeg, encode_decode_rst_jpeg)
-{
- cvtest::TS& ts = *cvtest::TS::ptr();
- string input = string(ts.get_data_path()) + "../cv/shared/lena.png";
- cv::Mat img = cv::imread(input);
- ASSERT_FALSE(img.empty());
-
- std::vector<int> params;
- params.push_back(IMWRITE_JPEG_RST_INTERVAL);
- params.push_back(1);
-
- string output_rst = cv::tempfile(".jpg");
- EXPECT_NO_THROW(cv::imwrite(output_rst, img, params));
- cv::Mat img_jpg_rst = cv::imread(output_rst);
-
- string output_normal = cv::tempfile(".jpg");
- EXPECT_NO_THROW(cv::imwrite(output_normal, img));
- cv::Mat img_jpg_normal = cv::imread(output_normal);
-
- EXPECT_EQ(0, cvtest::norm(img_jpg_rst, img_jpg_normal, NORM_INF));
-
- remove(output_rst.c_str());
-}
-
-#endif
-
-
-#ifdef HAVE_TIFF
-
-// these defines are used to resolve conflict between tiff.h and opencv2/core/types_c.h
-#define uint64 uint64_hack_
-#define int64 int64_hack_
-#include "tiff.h"
-
-#ifdef ANDROID
-// Test disabled as it uses a lot of memory.
-// It is killed with SIGKILL by out of memory killer.
-TEST(Imgcodecs_Tiff, DISABLED_decode_tile16384x16384)
-#else
-TEST(Imgcodecs_Tiff, decode_tile16384x16384)
-#endif
+TEST_P(Imgcodecs_ExtSize, write_imageseq)
{
- // see issue #2161
- cv::Mat big(16384, 16384, CV_8UC1, cv::Scalar::all(0));
- string file3 = cv::tempfile(".tiff");
- string file4 = cv::tempfile(".tiff");
+ const string ext = get<0>(GetParam());
+ const Size size = get<1>(GetParam());
+ const Point2i center = Point2i(size.width / 2, size.height / 2);
+ const int radius = std::min(size.height, size.width / 4);
- std::vector<int> params;
- params.push_back(TIFFTAG_ROWSPERSTRIP);
- params.push_back(big.rows);
- cv::imwrite(file4, big, params);
- cv::imwrite(file3, big.colRange(0, big.cols - 1), params);
- big.release();
-
- try
- {
- cv::imread(file3, IMREAD_UNCHANGED);
- EXPECT_NO_THROW(cv::imread(file4, IMREAD_UNCHANGED));
- }
- catch(const std::bad_alloc&)
- {
- // have no enough memory
- }
-
- remove(file3.c_str());
- remove(file4.c_str());
-}
-
-TEST(Imgcodecs_Tiff, write_read_16bit_big_little_endian)
-{
- // see issue #2601 "16-bit Grayscale TIFF Load Failures Due to Buffer Underflow and Endianness"
-
- // Setup data for two minimal 16-bit grayscale TIFF files in both endian formats
- uchar tiff_sample_data[2][86] = { {
- // Little endian
- 0x49, 0x49, 0x2a, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xad, 0xde, 0xef, 0xbe, 0x06, 0x00, 0x00, 0x01,
- 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x00, 0x01, 0x00,
- 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x01, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00,
- 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x01,
- 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x17, 0x01, 0x04, 0x00, 0x01, 0x00,
- 0x00, 0x00, 0x04, 0x00, 0x00, 0x00 }, {
- // Big endian
- 0x4d, 0x4d, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x0c, 0xde, 0xad, 0xbe, 0xef, 0x00, 0x06, 0x01, 0x00,
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x03, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10,
- 0x00, 0x00, 0x01, 0x06, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x11,
- 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x01, 0x17, 0x00, 0x04, 0x00, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x04 }
- };
-
- // Test imread() for both a little endian TIFF and big endian TIFF
- for (int i = 0; i < 2; i++)
+ for (int cn = 1; cn <= 4; cn++)
{
- string filename = cv::tempfile(".tiff");
+ SCOPED_TRACE(format("channels %d", cn));
+ if (cn == 2)
+ continue;
+ if (cn == 4 && ext != ".tiff")
+ continue;
+ string filename = cv::tempfile(format("%d%s", cn, ext.c_str()).c_str());
- // Write sample TIFF file
- FILE* fp = fopen(filename.c_str(), "wb");
- ASSERT_TRUE(fp != NULL);
- ASSERT_EQ((size_t)1, fwrite(tiff_sample_data, 86, 1, fp));
- fclose(fp);
+ Mat img_gt(size, CV_MAKETYPE(CV_8U, cn), Scalar::all(0));
+ circle(img_gt, center, radius, Scalar::all(255));
+ ASSERT_TRUE(imwrite(filename, img_gt));
Mat img = imread(filename, IMREAD_UNCHANGED);
+ ASSERT_FALSE(img.empty());
+ EXPECT_EQ(img.size(), img.size());
+ EXPECT_EQ(img.type(), img.type());
+ EXPECT_EQ(cn, img.channels());
- EXPECT_EQ(1, img.rows);
- EXPECT_EQ(2, img.cols);
- EXPECT_EQ(CV_16U, img.type());
- EXPECT_EQ(sizeof(ushort), img.elemSize());
- EXPECT_EQ(1, img.channels());
- EXPECT_EQ(0xDEAD, img.at<ushort>(0,0));
- EXPECT_EQ(0xBEEF, img.at<ushort>(0,1));
-
- remove(filename.c_str());
- }
-}
-
-class CV_GrfmtReadTifTiledWithNotFullTiles: public cvtest::BaseTest
-{
-public:
- void run(int)
- {
- try
- {
- /* see issue #3472 - dealing with tiled images where the tile size is
- * not a multiple of image size.
- * The tiled images were created with 'convert' from ImageMagick,
- * using the command 'convert <input> -define tiff:tile-geometry=128x128 -depth [8|16] <output>
- * Note that the conversion to 16 bits expands the range from 0-255 to 0-255*255,
- * so the test converts back but rounding errors cause small differences.
- */
- cv::Mat img = imread(string(ts->get_data_path()) + "readwrite/non_tiled.tif",-1);
- if (img.empty()) ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
- ASSERT_TRUE(img.channels() == 3);
- cv::Mat tiled8 = imread(string(ts->get_data_path()) + "readwrite/tiled_8.tif", -1);
- if (tiled8.empty()) ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
- ASSERT_PRED_FORMAT2(cvtest::MatComparator(0, 0), img, tiled8);
-
- cv::Mat tiled16 = imread(string(ts->get_data_path()) + "readwrite/tiled_16.tif", -1);
- if (tiled16.empty()) ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
- ASSERT_TRUE(tiled16.elemSize() == 6);
- tiled16.convertTo(tiled8, CV_8UC3, 1./256.);
- ASSERT_PRED_FORMAT2(cvtest::MatComparator(2, 0), img, tiled8);
- // What about 32, 64 bit?
- }
- catch(...)
+ if (ext == ".jpg")
{
- ts->set_failed_test_info(cvtest::TS::FAIL_EXCEPTION);
+ // JPEG format does not provide 100% accuracy
+ // using fuzzy image comparison
+ double n = cvtest::norm(img, img_gt, NORM_L1);
+ double expected = 0.07 * img.size().area();
+ EXPECT_LT(n, expected);
+ EXPECT_PRED_FORMAT2(cvtest::MatComparator(10, 0), img, img_gt);
}
- ts->set_failed_test_info(cvtest::TS::OK);
- }
-};
-
-TEST(Imgcodecs_Tiff, decode_tile_remainder)
-{
- CV_GrfmtReadTifTiledWithNotFullTiles test; test.safe_run();
-}
-
-TEST(Imgcodecs_Tiff, decode_infinite_rowsperstrip)
-{
- const uchar sample_data[142] = {
- 0x49, 0x49, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x56, 0x54,
- 0x56, 0x5a, 0x59, 0x55, 0x5a, 0x00, 0x0a, 0x00, 0x00, 0x01,
- 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x01, 0x01, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00,
- 0x00, 0x00, 0x02, 0x01, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x00, 0x00, 0x03, 0x01, 0x03, 0x00, 0x01, 0x00,
- 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x01,
- 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x15, 0x01, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00,
- 0x00, 0x00, 0x16, 0x01, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0xff, 0xff, 0xff, 0xff, 0x17, 0x01, 0x04, 0x00, 0x01, 0x00,
- 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x1c, 0x01, 0x03, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00
- };
-
- const string filename = cv::tempfile(".tiff");
- std::ofstream outfile(filename.c_str(), std::ofstream::binary);
- outfile.write(reinterpret_cast<const char *>(sample_data), sizeof sample_data);
- outfile.close();
-
- EXPECT_NO_THROW(cv::imread(filename, IMREAD_UNCHANGED));
-
- remove(filename.c_str());
-}
-
-class CV_GrfmtReadTifMultiPage : public cvtest::BaseTest
-{
-private:
- void compare(int flags)
- {
- const string folder = string(cvtest::TS::ptr()->get_data_path()) + "/readwrite/";
- const int page_count = 6;
-
- vector<Mat> pages;
- bool res = imreadmulti(folder + "multipage.tif", pages, flags);
- ASSERT_TRUE(res == true);
- ASSERT_EQ(static_cast<size_t>(page_count), pages.size());
-
- for (int i = 0; i < page_count; i++)
+ else
{
- char buffer[256];
- sprintf(buffer, "%smultipage_p%d.tif", folder.c_str(), i + 1);
- const string filepath(buffer);
- const Mat page = imread(filepath, flags);
- ASSERT_TRUE(mats_equal(page, pages[i]));
+ double n = cvtest::norm(img, img_gt, NORM_L2);
+ EXPECT_LT(n, 1.);
+ EXPECT_PRED_FORMAT2(cvtest::MatComparator(0, 0), img, img_gt);
}
+ remove(filename.c_str());
}
-
-public:
- void run(int)
- {
- compare(IMREAD_UNCHANGED);
- compare(IMREAD_GRAYSCALE);
- compare(IMREAD_COLOR);
- compare(IMREAD_ANYDEPTH);
- compare(IMREAD_ANYCOLOR);
- // compare(IMREAD_LOAD_GDAL); // GDAL does not support multi-page TIFFs
- }
-};
-
-TEST(Imgcodecs_Tiff, decode_multipage)
-{
- CV_GrfmtReadTifMultiPage test; test.safe_run();
}
-TEST(Imgcodecs_Tiff, imdecode_no_exception_temporary_file_removed)
+const string all_exts[] =
{
- cvtest::TS& ts = *cvtest::TS::ptr();
- string input = string(ts.get_data_path()) + "../cv/shared/lena.png";
- cv::Mat img = cv::imread(input);
- ASSERT_FALSE(img.empty());
-
- std::vector<uchar> buf;
- EXPECT_NO_THROW(cv::imencode(".tiff", img, buf));
-
- EXPECT_NO_THROW(cv::imdecode(buf, IMREAD_UNCHANGED));
-}
-
+#ifdef HAVE_PNG
+ ".png",
#endif
+#ifdef HAVE_TIFF
+ ".tiff",
+#endif
+#ifdef HAVE_JPEG
+ ".jpg",
+#endif
+ ".bmp",
+ ".pgm",
+ ".pam"
+};
-#ifdef HAVE_WEBP
-
-TEST(Imgcodecs_WebP, encode_decode_lossless_webp)
+vector<Size> all_sizes()
{
- cvtest::TS& ts = *cvtest::TS::ptr();
- string input = string(ts.get_data_path()) + "../cv/shared/lena.png";
- cv::Mat img = cv::imread(input);
- ASSERT_FALSE(img.empty());
-
- string output = cv::tempfile(".webp");
- EXPECT_NO_THROW(cv::imwrite(output, img)); // lossless
-
- cv::Mat img_webp = cv::imread(output);
-
- std::vector<unsigned char> buf;
-
- FILE * wfile = NULL;
-
- wfile = fopen(output.c_str(), "rb");
- if (wfile != NULL)
- {
- fseek(wfile, 0, SEEK_END);
- size_t wfile_size = ftell(wfile);
- fseek(wfile, 0, SEEK_SET);
-
- buf.resize(wfile_size);
-
- size_t data_size = fread(&buf[0], 1, wfile_size, wfile);
-
- if(wfile)
- {
- fclose(wfile);
- }
-
- if (data_size != wfile_size)
- {
- EXPECT_TRUE(false);
- }
- }
-
- remove(output.c_str());
-
- cv::Mat decode = cv::imdecode(buf, IMREAD_COLOR);
- ASSERT_FALSE(decode.empty());
- EXPECT_TRUE(cvtest::norm(decode, img_webp, NORM_INF) == 0);
-
- ASSERT_FALSE(img_webp.empty());
-
- EXPECT_TRUE(cvtest::norm(img, img_webp, NORM_INF) == 0);
+ vector<Size> res;
+ for (int k = 1; k <= 5; ++k)
+ res.push_back(Size(640 * k, 480 * k));
+ return res;
}
-TEST(Imgcodecs_WebP, encode_decode_lossy_webp)
-{
- cvtest::TS& ts = *cvtest::TS::ptr();
- std::string input = std::string(ts.get_data_path()) + "../cv/shared/lena.png";
- cv::Mat img = cv::imread(input);
- ASSERT_FALSE(img.empty());
-
- for(int q = 100; q>=0; q-=20)
- {
- std::vector<int> params;
- params.push_back(IMWRITE_WEBP_QUALITY);
- params.push_back(q);
- string output = cv::tempfile(".webp");
+INSTANTIATE_TEST_CASE_P(All, Imgcodecs_ExtSize,
+ testing::Combine(
+ testing::ValuesIn(all_exts),
+ testing::ValuesIn(all_sizes())));
- EXPECT_NO_THROW(cv::imwrite(output, img, params));
- cv::Mat img_webp = cv::imread(output);
- remove(output.c_str());
- EXPECT_FALSE(img_webp.empty());
- EXPECT_EQ(3, img_webp.channels());
- EXPECT_EQ(512, img_webp.cols);
- EXPECT_EQ(512, img_webp.rows);
- }
-}
+//==================================================================================================
-TEST(Imgcodecs_WebP, encode_decode_with_alpha_webp)
+TEST(Imgcodecs_Bmp, read_rle8)
{
- cvtest::TS& ts = *cvtest::TS::ptr();
- std::string input = std::string(ts.get_data_path()) + "../cv/shared/lena.png";
- cv::Mat img = cv::imread(input);
- ASSERT_FALSE(img.empty());
-
- std::vector<cv::Mat> imgs;
- cv::split(img, imgs);
- imgs.push_back(cv::Mat(imgs[0]));
- imgs[imgs.size() - 1] = cv::Scalar::all(128);
- cv::merge(imgs, img);
-
- string output = cv::tempfile(".webp");
-
- EXPECT_NO_THROW(cv::imwrite(output, img));
- cv::Mat img_webp = cv::imread(output);
- remove(output.c_str());
- EXPECT_FALSE(img_webp.empty());
- EXPECT_EQ(4, img_webp.channels());
- EXPECT_EQ(512, img_webp.cols);
- EXPECT_EQ(512, img_webp.rows);
+ const string root = cvtest::TS::ptr()->get_data_path();
+ Mat rle = imread(root + "readwrite/rle8.bmp");
+ ASSERT_FALSE(rle.empty());
+ Mat ord = imread(root + "readwrite/ordinary.bmp");
+ ASSERT_FALSE(ord.empty());
+ EXPECT_LE(cvtest::norm(rle, ord, NORM_L2), 1.e-10);
+ EXPECT_PRED_FORMAT2(cvtest::MatComparator(0, 0), rle, ord);
}
-#endif
-
TEST(Imgcodecs_Hdr, regression)
{
string folder = string(cvtest::TS::ptr()->get_data_path()) + "/readwrite/";
@@ -1038,9 +244,10 @@ TEST(Imgcodecs_Hdr, regression)
minMaxLoc(abs(img_rle - written_img), &min, &max);
ASSERT_FALSE(max > DBL_EPSILON);
}
+ remove(tmp_file_name.c_str());
}
-TEST(Imgcodecs_Pam, readwrite)
+TEST(Imgcodecs_Pam, read_write)
{
string folder = string(cvtest::TS::ptr()->get_data_path()) + "readwrite/";
string filepath = folder + "lena.pam";
@@ -1062,4 +269,7 @@ TEST(Imgcodecs_Pam, readwrite)
EXPECT_EQ(0, cvtest::norm(reread, reread_no_param, NORM_INF));
EXPECT_EQ(0, cvtest::norm(img, reread, NORM_INF));
+
+ remove(writefile.c_str());
+ remove(writefile_no_param.c_str());
}
diff --git a/modules/imgcodecs/test/test_jpeg.cpp b/modules/imgcodecs/test/test_jpeg.cpp
new file mode 100644
index 0000000..5546f2d
--- /dev/null
+++ b/modules/imgcodecs/test/test_jpeg.cpp
@@ -0,0 +1,180 @@
+#include "test_precomp.hpp"
+
+using namespace cv;
+using namespace std;
+using namespace std::tr1;
+
+#ifdef HAVE_JPEG
+
+/**
+ * Test for check whether reading exif orientation tag was processed successfully or not
+ * The test info is the set of 8 images named testExifRotate_{1 to 8}.jpg
+ * The test image is the square 10x10 points divided by four sub-squares:
+ * (R corresponds to Red, G to Green, B to Blue, W to white)
+ * --------- ---------
+ * | R | G | | G | R |
+ * |-------| - (tag 1) |-------| - (tag 2)
+ * | B | W | | W | B |
+ * --------- ---------
+ *
+ * --------- ---------
+ * | W | B | | B | W |
+ * |-------| - (tag 3) |-------| - (tag 4)
+ * | G | R | | R | G |
+ * --------- ---------
+ *
+ * --------- ---------
+ * | R | B | | G | W |
+ * |-------| - (tag 5) |-------| - (tag 6)
+ * | G | W | | R | B |
+ * --------- ---------
+ *
+ * --------- ---------
+ * | W | G | | B | R |
+ * |-------| - (tag 7) |-------| - (tag 8)
+ * | B | R | | W | G |
+ * --------- ---------
+ *
+ *
+ * Every image contains exif field with orientation tag (0x112)
+ * After reading each image the corresponding matrix must be read as
+ * ---------
+ * | R | G |
+ * |-------|
+ * | B | W |
+ * ---------
+ *
+ */
+
+typedef testing::TestWithParam<string> Imgcodecs_Jpeg_Exif;
+
+TEST_P(Imgcodecs_Jpeg_Exif, exif_orientation)
+{
+ const string root = cvtest::TS::ptr()->get_data_path();
+ const string filename = root + GetParam();
+ const int colorThresholdHigh = 250;
+ const int colorThresholdLow = 5;
+
+ Mat m_img = imread(filename);
+ ASSERT_FALSE(m_img.empty());
+ Vec3b vec;
+
+ //Checking the first quadrant (with supposed red)
+ vec = m_img.at<Vec3b>(2, 2); //some point inside the square
+ EXPECT_LE(vec.val[0], colorThresholdLow);
+ EXPECT_LE(vec.val[1], colorThresholdLow);
+ EXPECT_GE(vec.val[2], colorThresholdHigh);
+
+ //Checking the second quadrant (with supposed green)
+ vec = m_img.at<Vec3b>(2, 7); //some point inside the square
+ EXPECT_LE(vec.val[0], colorThresholdLow);
+ EXPECT_GE(vec.val[1], colorThresholdHigh);
+ EXPECT_LE(vec.val[2], colorThresholdLow);
+
+ //Checking the third quadrant (with supposed blue)
+ vec = m_img.at<Vec3b>(7, 2); //some point inside the square
+ EXPECT_GE(vec.val[0], colorThresholdHigh);
+ EXPECT_LE(vec.val[1], colorThresholdLow);
+ EXPECT_LE(vec.val[2], colorThresholdLow);
+}
+
+const string exif_files[] =
+{
+ "readwrite/testExifOrientation_1.jpg",
+ "readwrite/testExifOrientation_2.jpg",
+ "readwrite/testExifOrientation_3.jpg",
+ "readwrite/testExifOrientation_4.jpg",
+ "readwrite/testExifOrientation_5.jpg",
+ "readwrite/testExifOrientation_6.jpg",
+ "readwrite/testExifOrientation_7.jpg",
+ "readwrite/testExifOrientation_8.jpg"
+};
+
+INSTANTIATE_TEST_CASE_P(ExifFiles, Imgcodecs_Jpeg_Exif,
+ testing::ValuesIn(exif_files));
+
+//==================================================================================================
+
+TEST(Imgcodecs_Jpeg, encode_empty)
+{
+ cv::Mat img;
+ std::vector<uchar> jpegImg;
+ ASSERT_THROW(cv::imencode(".jpg", img, jpegImg), cv::Exception);
+}
+
+TEST(Imgcodecs_Jpeg, encode_decode_progressive_jpeg)
+{
+ cvtest::TS& ts = *cvtest::TS::ptr();
+ string input = string(ts.get_data_path()) + "../cv/shared/lena.png";
+ cv::Mat img = cv::imread(input);
+ ASSERT_FALSE(img.empty());
+
+ std::vector<int> params;
+ params.push_back(IMWRITE_JPEG_PROGRESSIVE);
+ params.push_back(1);
+
+ string output_progressive = cv::tempfile(".jpg");
+ EXPECT_NO_THROW(cv::imwrite(output_progressive, img, params));
+ cv::Mat img_jpg_progressive = cv::imread(output_progressive);
+
+ string output_normal = cv::tempfile(".jpg");
+ EXPECT_NO_THROW(cv::imwrite(output_normal, img));
+ cv::Mat img_jpg_normal = cv::imread(output_normal);
+
+ EXPECT_EQ(0, cvtest::norm(img_jpg_progressive, img_jpg_normal, NORM_INF));
+
+ remove(output_progressive.c_str());
+ remove(output_normal.c_str());
+}
+
+TEST(Imgcodecs_Jpeg, encode_decode_optimize_jpeg)
+{
+ cvtest::TS& ts = *cvtest::TS::ptr();
+ string input = string(ts.get_data_path()) + "../cv/shared/lena.png";
+ cv::Mat img = cv::imread(input);
+ ASSERT_FALSE(img.empty());
+
+ std::vector<int> params;
+ params.push_back(IMWRITE_JPEG_OPTIMIZE);
+ params.push_back(1);
+
+ string output_optimized = cv::tempfile(".jpg");
+ EXPECT_NO_THROW(cv::imwrite(output_optimized, img, params));
+ cv::Mat img_jpg_optimized = cv::imread(output_optimized);
+
+ string output_normal = cv::tempfile(".jpg");
+ EXPECT_NO_THROW(cv::imwrite(output_normal, img));
+ cv::Mat img_jpg_normal = cv::imread(output_normal);
+
+ EXPECT_EQ(0, cvtest::norm(img_jpg_optimized, img_jpg_normal, NORM_INF));
+
+ remove(output_optimized.c_str());
+ remove(output_normal.c_str());
+}
+
+TEST(Imgcodecs_Jpeg, encode_decode_rst_jpeg)
+{
+ cvtest::TS& ts = *cvtest::TS::ptr();
+ string input = string(ts.get_data_path()) + "../cv/shared/lena.png";
+ cv::Mat img = cv::imread(input);
+ ASSERT_FALSE(img.empty());
+
+ std::vector<int> params;
+ params.push_back(IMWRITE_JPEG_RST_INTERVAL);
+ params.push_back(1);
+
+ string output_rst = cv::tempfile(".jpg");
+ EXPECT_NO_THROW(cv::imwrite(output_rst, img, params));
+ cv::Mat img_jpg_rst = cv::imread(output_rst);
+
+ string output_normal = cv::tempfile(".jpg");
+ EXPECT_NO_THROW(cv::imwrite(output_normal, img));
+ cv::Mat img_jpg_normal = cv::imread(output_normal);
+
+ EXPECT_EQ(0, cvtest::norm(img_jpg_rst, img_jpg_normal, NORM_INF));
+
+ remove(output_rst.c_str());
+ remove(output_normal.c_str());
+}
+
+#endif // HAVE_JPEG
diff --git a/modules/imgcodecs/test/test_png.cpp b/modules/imgcodecs/test/test_png.cpp
new file mode 100644
index 0000000..c46f901
--- /dev/null
+++ b/modules/imgcodecs/test/test_png.cpp
@@ -0,0 +1,95 @@
+#include "test_precomp.hpp"
+
+using namespace cv;
+using namespace std;
+using namespace std::tr1;
+
+#ifdef HAVE_PNG
+
+TEST(Imgcodecs_Png, write_big)
+{
+ const string root = cvtest::TS::ptr()->get_data_path();
+ const string filename = root + "readwrite/read.png";
+ const string dst_file = cv::tempfile(".png");
+ Mat img;
+ ASSERT_NO_THROW(img = imread(filename));
+ ASSERT_FALSE(img.empty());
+ EXPECT_EQ(13043, img.cols);
+ EXPECT_EQ(13917, img.rows);
+ ASSERT_NO_THROW(imwrite(dst_file, img));
+ remove(dst_file.c_str());
+}
+
+TEST(Imgcodecs_Png, encode)
+{
+ vector<uchar> buff;
+ Mat img_gt = Mat::zeros(1000, 1000, CV_8U);
+ vector<int> param;
+ param.push_back(IMWRITE_PNG_COMPRESSION);
+ param.push_back(3); //default(3) 0-9.
+ EXPECT_NO_THROW(imencode(".png", img_gt, buff, param));
+ Mat img;
+ EXPECT_NO_THROW(img = imdecode(buff, IMREAD_ANYDEPTH)); // hang
+ EXPECT_FALSE(img.empty());
+ EXPECT_PRED_FORMAT2(cvtest::MatComparator(0, 0), img, img_gt);
+}
+
+TEST(Imgcodecs_Png, regression_ImreadVSCvtColor)
+{
+ const string root = cvtest::TS::ptr()->get_data_path();
+ const string imgName = root + "../cv/shared/lena.png";
+ Mat original_image = imread(imgName);
+ Mat gray_by_codec = imread(imgName, IMREAD_GRAYSCALE);
+ Mat gray_by_cvt;
+ cvtColor(original_image, gray_by_cvt, CV_BGR2GRAY);
+
+ Mat diff;
+ absdiff(gray_by_codec, gray_by_cvt, diff);
+ EXPECT_LT(cvtest::mean(diff)[0], 1.);
+ EXPECT_PRED_FORMAT2(cvtest::MatComparator(10, 0), gray_by_codec, gray_by_cvt);
+}
+
+// Test OpenCV issue 3075 is solved
+TEST(Imgcodecs_Png, read_color_palette_with_alpha)
+{
+ const string root = cvtest::TS::ptr()->get_data_path();
+ Mat img;
+
+ // First Test : Read PNG with alpha, imread flag -1
+ img = imread(root + "readwrite/color_palette_alpha.png", IMREAD_UNCHANGED);
+ ASSERT_FALSE(img.empty());
+ ASSERT_TRUE(img.channels() == 4);
+
+ // pixel is red in BGRA
+ EXPECT_EQ(img.at<Vec4b>(0, 0), Vec4b(0, 0, 255, 255));
+ EXPECT_EQ(img.at<Vec4b>(0, 1), Vec4b(0, 0, 255, 255));
+
+ // Second Test : Read PNG without alpha, imread flag -1
+ img = imread(root + "readwrite/color_palette_no_alpha.png", IMREAD_UNCHANGED);
+ ASSERT_FALSE(img.empty());
+ ASSERT_TRUE(img.channels() == 3);
+
+ // pixel is red in BGR
+ EXPECT_EQ(img.at<Vec3b>(0, 0), Vec3b(0, 0, 255));
+ EXPECT_EQ(img.at<Vec3b>(0, 1), Vec3b(0, 0, 255));
+
+ // Third Test : Read PNG with alpha, imread flag 1
+ img = imread(root + "readwrite/color_palette_alpha.png", IMREAD_COLOR);
+ ASSERT_FALSE(img.empty());
+ ASSERT_TRUE(img.channels() == 3);
+
+ // pixel is red in BGR
+ EXPECT_EQ(img.at<Vec3b>(0, 0), Vec3b(0, 0, 255));
+ EXPECT_EQ(img.at<Vec3b>(0, 1), Vec3b(0, 0, 255));
+
+ // Fourth Test : Read PNG without alpha, imread flag 1
+ img = imread(root + "readwrite/color_palette_no_alpha.png", IMREAD_COLOR);
+ ASSERT_FALSE(img.empty());
+ ASSERT_TRUE(img.channels() == 3);
+
+ // pixel is red in BGR
+ EXPECT_EQ(img.at<Vec3b>(0, 0), Vec3b(0, 0, 255));
+ EXPECT_EQ(img.at<Vec3b>(0, 1), Vec3b(0, 0, 255));
+}
+
+#endif // HAVE_PNG
diff --git a/modules/imgcodecs/test/test_precomp.hpp b/modules/imgcodecs/test/test_precomp.hpp
index 2aed614..fd9c18c 100644
--- a/modules/imgcodecs/test/test_precomp.hpp
+++ b/modules/imgcodecs/test/test_precomp.hpp
@@ -9,7 +9,6 @@
#ifndef __OPENCV_TEST_PRECOMP_HPP__
#define __OPENCV_TEST_PRECOMP_HPP__
-#include <iostream>
#include "opencv2/ts.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
@@ -17,4 +16,10 @@
#include "opencv2/core/private.hpp"
+#include <fstream>
+#include <sstream>
+#include <iostream>
+#include <algorithm>
+#include <iterator>
+
#endif
diff --git a/modules/imgcodecs/test/test_read_write.cpp b/modules/imgcodecs/test/test_read_write.cpp
new file mode 100644
index 0000000..38f1022
--- /dev/null
+++ b/modules/imgcodecs/test/test_read_write.cpp
@@ -0,0 +1,122 @@
+#include "test_precomp.hpp"
+
+#include <fstream>
+#include <sstream>
+#include <iostream>
+
+using namespace cv;
+using namespace std;
+using namespace cvtest;
+
+TEST(Imgcodecs_Image, read_write_bmp)
+{
+ const size_t IMAGE_COUNT = 10;
+ const double thresDbell = 32;
+
+ for (size_t i = 0; i < IMAGE_COUNT; ++i)
+ {
+ stringstream s; s << i;
+ const string digit = s.str();
+ const string src_name = TS::ptr()->get_data_path() + "../python/images/QCIF_0" + digit + ".bmp";
+ const string dst_name = cv::tempfile((digit + ".bmp").c_str());
+ Mat image = imread(src_name);
+ ASSERT_FALSE(image.empty());
+
+ resize(image, image, Size(968, 757), 0.0, 0.0, INTER_CUBIC);
+ imwrite(dst_name, image);
+ Mat loaded = imread(dst_name);
+ ASSERT_FALSE(loaded.empty());
+
+ double psnr = cvtest::PSNR(loaded, image);
+ EXPECT_GT(psnr, thresDbell);
+
+ vector<uchar> from_file;
+
+ FILE *f = fopen(dst_name.c_str(), "rb");
+ fseek(f, 0, SEEK_END);
+ long len = ftell(f);
+ from_file.resize((size_t)len);
+ fseek(f, 0, SEEK_SET);
+ from_file.resize(fread(&from_file[0], 1, from_file.size(), f));
+ fclose(f);
+
+ vector<uchar> buf;
+ imencode(".bmp", image, buf);
+ ASSERT_EQ(buf, from_file);
+
+ Mat buf_loaded = imdecode(Mat(buf), 1);
+ ASSERT_FALSE(buf_loaded.empty());
+
+ psnr = cvtest::PSNR(buf_loaded, image);
+ EXPECT_GT(psnr, thresDbell);
+
+ remove(dst_name.c_str());
+ }
+}
+
+//==================================================================================================
+
+typedef string Ext;
+typedef testing::TestWithParam<Ext> Imgcodecs_Image;
+
+TEST_P(Imgcodecs_Image, read_write)
+{
+ const string ext = this->GetParam();
+ const string full_name = cv::tempfile(ext.c_str());
+ const string _name = TS::ptr()->get_data_path() + "../cv/shared/baboon.png";
+ const double thresDbell = 32;
+
+ Mat image = imread(_name);
+ image.convertTo(image, CV_8UC3);
+ ASSERT_FALSE(image.empty());
+
+ imwrite(full_name, image);
+ Mat loaded = imread(full_name);
+ ASSERT_FALSE(loaded.empty());
+
+ double psnr = cvtest::PSNR(loaded, image);
+ EXPECT_GT(psnr, thresDbell);
+
+ vector<uchar> from_file;
+ FILE *f = fopen(full_name.c_str(), "rb");
+ fseek(f, 0, SEEK_END);
+ long len = ftell(f);
+ from_file.resize((size_t)len);
+ fseek(f, 0, SEEK_SET);
+ from_file.resize(fread(&from_file[0], 1, from_file.size(), f));
+ fclose(f);
+ vector<uchar> buf;
+ imencode("." + ext, image, buf);
+ ASSERT_EQ(buf, from_file);
+
+ Mat buf_loaded = imdecode(Mat(buf), 1);
+ ASSERT_FALSE(buf_loaded.empty());
+
+ psnr = cvtest::PSNR(buf_loaded, image);
+ EXPECT_GT(psnr, thresDbell);
+
+ remove(full_name.c_str());
+}
+
+const string exts[] = {
+#ifdef HAVE_PNG
+ "png",
+#endif
+#ifdef HAVE_TIFF
+ "tiff",
+#endif
+#ifdef HAVE_JPEG
+ "jpg",
+#endif
+#ifdef HAVE_JASPER
+ "jp2",
+#endif
+#if 0 /*defined HAVE_OPENEXR && !defined __APPLE__*/
+ "exr",
+#endif
+ "bmp",
+ "ppm",
+ "ras"
+};
+
+INSTANTIATE_TEST_CASE_P(imgcodecs, Imgcodecs_Image, testing::ValuesIn(exts));
diff --git a/modules/imgcodecs/test/test_tiff.cpp b/modules/imgcodecs/test/test_tiff.cpp
new file mode 100644
index 0000000..0264da4
--- /dev/null
+++ b/modules/imgcodecs/test/test_tiff.cpp
@@ -0,0 +1,202 @@
+#include "test_precomp.hpp"
+
+using namespace cv;
+using namespace std;
+using namespace std::tr1;
+
+#ifdef HAVE_TIFF
+
+// these defines are used to resolve conflict between tiff.h and opencv2/core/types_c.h
+#define uint64 uint64_hack_
+#define int64 int64_hack_
+#include "tiff.h"
+
+#ifdef __ANDROID__
+// Test disabled as it uses a lot of memory.
+// It is killed with SIGKILL by out of memory killer.
+TEST(Imgcodecs_Tiff, DISABLED_decode_tile16384x16384)
+#else
+TEST(Imgcodecs_Tiff, decode_tile16384x16384)
+#endif
+{
+ // see issue #2161
+ cv::Mat big(16384, 16384, CV_8UC1, cv::Scalar::all(0));
+ string file3 = cv::tempfile(".tiff");
+ string file4 = cv::tempfile(".tiff");
+
+ std::vector<int> params;
+ params.push_back(TIFFTAG_ROWSPERSTRIP);
+ params.push_back(big.rows);
+ EXPECT_NO_THROW(cv::imwrite(file4, big, params));
+ EXPECT_NO_THROW(cv::imwrite(file3, big.colRange(0, big.cols - 1), params));
+ big.release();
+
+ try
+ {
+ cv::imread(file3, IMREAD_UNCHANGED);
+ EXPECT_NO_THROW(cv::imread(file4, IMREAD_UNCHANGED));
+ }
+ catch(const std::bad_alloc&)
+ {
+ // not enough memory
+ }
+
+ remove(file3.c_str());
+ remove(file4.c_str());
+}
+
+TEST(Imgcodecs_Tiff, write_read_16bit_big_little_endian)
+{
+ // see issue #2601 "16-bit Grayscale TIFF Load Failures Due to Buffer Underflow and Endianness"
+
+ // Setup data for two minimal 16-bit grayscale TIFF files in both endian formats
+ uchar tiff_sample_data[2][86] = { {
+ // Little endian
+ 0x49, 0x49, 0x2a, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xad, 0xde, 0xef, 0xbe, 0x06, 0x00, 0x00, 0x01,
+ 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x00, 0x01, 0x00,
+ 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x01, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00,
+ 0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x01,
+ 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x17, 0x01, 0x04, 0x00, 0x01, 0x00,
+ 0x00, 0x00, 0x04, 0x00, 0x00, 0x00 }, {
+ // Big endian
+ 0x4d, 0x4d, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x0c, 0xde, 0xad, 0xbe, 0xef, 0x00, 0x06, 0x01, 0x00,
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x03, 0x00, 0x00,
+ 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10,
+ 0x00, 0x00, 0x01, 0x06, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x11,
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x01, 0x17, 0x00, 0x04, 0x00, 0x00,
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x04 }
+ };
+
+ // Test imread() for both a little endian TIFF and big endian TIFF
+ for (int i = 0; i < 2; i++)
+ {
+ string filename = cv::tempfile(".tiff");
+
+ // Write sample TIFF file
+ FILE* fp = fopen(filename.c_str(), "wb");
+ ASSERT_TRUE(fp != NULL);
+ ASSERT_EQ((size_t)1, fwrite(tiff_sample_data, 86, 1, fp));
+ fclose(fp);
+
+ Mat img = imread(filename, IMREAD_UNCHANGED);
+
+ EXPECT_EQ(1, img.rows);
+ EXPECT_EQ(2, img.cols);
+ EXPECT_EQ(CV_16U, img.type());
+ EXPECT_EQ(sizeof(ushort), img.elemSize());
+ EXPECT_EQ(1, img.channels());
+ EXPECT_EQ(0xDEAD, img.at<ushort>(0,0));
+ EXPECT_EQ(0xBEEF, img.at<ushort>(0,1));
+
+ remove(filename.c_str());
+ }
+}
+
+TEST(Imgcodecs_Tiff, decode_tile_remainder)
+{
+ /* see issue #3472 - dealing with tiled images where the tile size is
+ * not a multiple of image size.
+ * The tiled images were created with 'convert' from ImageMagick,
+ * using the command 'convert <input> -define tiff:tile-geometry=128x128 -depth [8|16] <output>
+ * Note that the conversion to 16 bits expands the range from 0-255 to 0-255*255,
+ * so the test converts back but rounding errors cause small differences.
+ */
+ const string root = cvtest::TS::ptr()->get_data_path();
+ cv::Mat img = imread(root + "readwrite/non_tiled.tif",-1);
+ ASSERT_FALSE(img.empty());
+ ASSERT_TRUE(img.channels() == 3);
+ cv::Mat tiled8 = imread(root + "readwrite/tiled_8.tif", -1);
+ ASSERT_FALSE(tiled8.empty());
+ ASSERT_PRED_FORMAT2(cvtest::MatComparator(0, 0), img, tiled8);
+ cv::Mat tiled16 = imread(root + "readwrite/tiled_16.tif", -1);
+ ASSERT_FALSE(tiled16.empty());
+ ASSERT_TRUE(tiled16.elemSize() == 6);
+ tiled16.convertTo(tiled8, CV_8UC3, 1./256.);
+ ASSERT_PRED_FORMAT2(cvtest::MatComparator(2, 0), img, tiled8);
+ // What about 32, 64 bit?
+}
+
+TEST(Imgcodecs_Tiff, decode_infinite_rowsperstrip)
+{
+ const uchar sample_data[142] = {
+ 0x49, 0x49, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x56, 0x54,
+ 0x56, 0x5a, 0x59, 0x55, 0x5a, 0x00, 0x0a, 0x00, 0x00, 0x01,
+ 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x01, 0x01, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00,
+ 0x00, 0x00, 0x02, 0x01, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x08, 0x00, 0x00, 0x00, 0x03, 0x01, 0x03, 0x00, 0x01, 0x00,
+ 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x03, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x01,
+ 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x15, 0x01, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00,
+ 0x00, 0x00, 0x16, 0x01, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0x17, 0x01, 0x04, 0x00, 0x01, 0x00,
+ 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x1c, 0x01, 0x03, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00
+ };
+
+ const string filename = cv::tempfile(".tiff");
+ std::ofstream outfile(filename.c_str(), std::ofstream::binary);
+ outfile.write(reinterpret_cast<const char *>(sample_data), sizeof sample_data);
+ outfile.close();
+
+ EXPECT_NO_THROW(cv::imread(filename, IMREAD_UNCHANGED));
+
+ remove(filename.c_str());
+}
+
+//==================================================================================================
+
+typedef testing::TestWithParam<int> Imgcodecs_Tiff_Modes;
+
+TEST_P(Imgcodecs_Tiff_Modes, decode_multipage)
+{
+ const int mode = GetParam();
+ const string root = cvtest::TS::ptr()->get_data_path();
+ const string filename = root + "readwrite/multipage.tif";
+ const string page_files[] = {
+ "readwrite/multipage_p1.tif",
+ "readwrite/multipage_p2.tif",
+ "readwrite/multipage_p3.tif",
+ "readwrite/multipage_p4.tif",
+ "readwrite/multipage_p5.tif",
+ "readwrite/multipage_p6.tif"
+ };
+ const size_t page_count = sizeof(page_files)/sizeof(page_files[0]);
+ vector<Mat> pages;
+ bool res = imreadmulti(filename, pages, mode);
+ ASSERT_TRUE(res == true);
+ ASSERT_EQ(page_count, pages.size());
+ for (size_t i = 0; i < page_count; i++)
+ {
+ const Mat page = imread(root + page_files[i], mode);
+ EXPECT_PRED_FORMAT2(cvtest::MatComparator(0, 0), page, pages[i]);
+ }
+}
+
+const int all_modes[] =
+{
+ IMREAD_UNCHANGED,
+ IMREAD_GRAYSCALE,
+ IMREAD_COLOR,
+ IMREAD_ANYDEPTH,
+ IMREAD_ANYCOLOR
+};
+
+INSTANTIATE_TEST_CASE_P(AllModes, Imgcodecs_Tiff_Modes, testing::ValuesIn(all_modes));
+
+//==================================================================================================
+
+TEST(Imgcodecs_Tiff, imdecode_no_exception_temporary_file_removed)
+{
+ const string root = cvtest::TS::ptr()->get_data_path();
+ const string filename = root + "../cv/shared/lena.png";
+ cv::Mat img = cv::imread(filename);
+ ASSERT_FALSE(img.empty());
+ std::vector<uchar> buf;
+ EXPECT_NO_THROW(cv::imencode(".tiff", img, buf));
+ EXPECT_NO_THROW(cv::imdecode(buf, IMREAD_UNCHANGED));
+}
+
+#endif
diff --git a/modules/imgcodecs/test/test_webp.cpp b/modules/imgcodecs/test/test_webp.cpp
new file mode 100644
index 0000000..6d40ce2
--- /dev/null
+++ b/modules/imgcodecs/test/test_webp.cpp
@@ -0,0 +1,106 @@
+#include "test_precomp.hpp"
+
+using namespace cv;
+using namespace std;
+using namespace std::tr1;
+
+#ifdef HAVE_WEBP
+
+TEST(Imgcodecs_WebP, encode_decode_lossless_webp)
+{
+ const string root = cvtest::TS::ptr()->get_data_path();
+ string filename = root + "../cv/shared/lena.png";
+ cv::Mat img = cv::imread(filename);
+ ASSERT_FALSE(img.empty());
+
+ string output = cv::tempfile(".webp");
+ EXPECT_NO_THROW(cv::imwrite(output, img)); // lossless
+
+ cv::Mat img_webp = cv::imread(output);
+
+ std::vector<unsigned char> buf;
+
+ FILE * wfile = NULL;
+
+ wfile = fopen(output.c_str(), "rb");
+ if (wfile != NULL)
+ {
+ fseek(wfile, 0, SEEK_END);
+ size_t wfile_size = ftell(wfile);
+ fseek(wfile, 0, SEEK_SET);
+
+ buf.resize(wfile_size);
+
+ size_t data_size = fread(&buf[0], 1, wfile_size, wfile);
+
+ if(wfile)
+ {
+ fclose(wfile);
+ }
+
+ if (data_size != wfile_size)
+ {
+ EXPECT_TRUE(false);
+ }
+ }
+
+ remove(output.c_str());
+
+ cv::Mat decode = cv::imdecode(buf, IMREAD_COLOR);
+ ASSERT_FALSE(decode.empty());
+ EXPECT_TRUE(cvtest::norm(decode, img_webp, NORM_INF) == 0);
+
+ ASSERT_FALSE(img_webp.empty());
+
+ EXPECT_TRUE(cvtest::norm(img, img_webp, NORM_INF) == 0);
+}
+
+TEST(Imgcodecs_WebP, encode_decode_lossy_webp)
+{
+ const string root = cvtest::TS::ptr()->get_data_path();
+ std::string input = root + "../cv/shared/lena.png";
+ cv::Mat img = cv::imread(input);
+ ASSERT_FALSE(img.empty());
+
+ for(int q = 100; q>=0; q-=20)
+ {
+ std::vector<int> params;
+ params.push_back(IMWRITE_WEBP_QUALITY);
+ params.push_back(q);
+ string output = cv::tempfile(".webp");
+
+ EXPECT_NO_THROW(cv::imwrite(output, img, params));
+ cv::Mat img_webp = cv::imread(output);
+ remove(output.c_str());
+ EXPECT_FALSE(img_webp.empty());
+ EXPECT_EQ(3, img_webp.channels());
+ EXPECT_EQ(512, img_webp.cols);
+ EXPECT_EQ(512, img_webp.rows);
+ }
+}
+
+TEST(Imgcodecs_WebP, encode_decode_with_alpha_webp)
+{
+ const string root = cvtest::TS::ptr()->get_data_path();
+ std::string input = root + "../cv/shared/lena.png";
+ cv::Mat img = cv::imread(input);
+ ASSERT_FALSE(img.empty());
+
+ std::vector<cv::Mat> imgs;
+ cv::split(img, imgs);
+ imgs.push_back(cv::Mat(imgs[0]));
+ imgs[imgs.size() - 1] = cv::Scalar::all(128);
+ cv::merge(imgs, img);
+
+ string output = cv::tempfile(".webp");
+
+ EXPECT_NO_THROW(cv::imwrite(output, img));
+ cv::Mat img_webp = cv::imread(output);
+ remove(output.c_str());
+ EXPECT_FALSE(img_webp.empty());
+ EXPECT_EQ(4, img_webp.channels());
+ EXPECT_EQ(512, img_webp.cols);
+ EXPECT_EQ(512, img_webp.rows);
+}
+
+#endif // HAVE_WEBP
diff --git a/modules/imgproc/CMakeLists.txt b/modules/imgproc/CMakeLists.txt
index afe89aa..87d0711 100644
--- a/modules/imgproc/CMakeLists.txt
+++ b/modules/imgproc/CMakeLists.txt
@@ -1,2 +1,3 @@
set(the_description "Image Processing")
+ocv_add_dispatched_file(accum SSE2 AVX NEON)
ocv_define_module(imgproc opencv_core WRAP java python)
diff --git a/modules/imgproc/doc/pics/ellipse.png b/modules/imgproc/doc/pics/ellipse.png
deleted file mode 100644
index 2b16c93..0000000
Binary files a/modules/imgproc/doc/pics/ellipse.png and /dev/null differ
diff --git a/modules/imgproc/doc/pics/ellipse.svg b/modules/imgproc/doc/pics/ellipse.svg
new file mode 100644
index 0000000..9ff78ef
--- /dev/null
+++ b/modules/imgproc/doc/pics/ellipse.svg
@@ -0,0 +1,1156 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="892.1438"
+ height="445.24109"
+ viewBox="0 0 892.14381 445.24112"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="ellipse.svg"
+ inkscape:export-filename="Z:\LIBS\OpenCV\PkLab\sources\opencv\modules\imgproc\doc\pics\ellipse.png"
+ inkscape:export-xdpi="91.063904"
+ inkscape:export-ydpi="91.063904">
+ <title
+ id="title10211">OpenCV: Parameters of Elliptic Arc </title>
+ <defs
+ id="defs4">
+ <marker
+ inkscape:stockid="EmptyTriangleOutL"
+ orient="auto"
+ refY="0.0"
+ refX="0.0"
+ id="marker10499"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path10501"
+ d="M 5.77,0.0 L -2.88,5.0 L -2.88,-5.0 L 5.77,0.0 z "
+ style="fill-rule:evenodd;fill:#ffffff;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
+ transform="scale(0.8) translate(-6,0)" />
+ </marker>
+ <marker
+ inkscape:stockid="DotL"
+ orient="auto"
+ refY="0.0"
+ refX="0.0"
+ id="marker10255"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path10257"
+ d="M -2.5,-1.0 C -2.5,1.7600000 -4.7400000,4.0 -7.5,4.0 C -10.260000,4.0 -12.5,1.7600000 -12.5,-1.0 C -12.5,-3.7600000 -10.260000,-6.0 -7.5,-6.0 C -4.7400000,-6.0 -2.5,-3.7600000 -2.5,-1.0 z "
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
+ transform="scale(0.8) translate(7.4, 1)" />
+ </marker>
+ <marker
+ inkscape:isstock="true"
+ style="overflow:visible"
+ id="marker8296"
+ refX="0.0"
+ refY="0.0"
+ orient="auto"
+ inkscape:stockid="DotL"
+ inkscape:collect="always">
+ <path
+ transform="scale(0.8) translate(7.4, 1)"
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
+ d="M -2.5,-1.0 C -2.5,1.7600000 -4.7400000,4.0 -7.5,4.0 C -10.260000,4.0 -12.5,1.7600000 -12.5,-1.0 C -12.5,-3.7600000 -10.260000,-6.0 -7.5,-6.0 C -4.7400000,-6.0 -2.5,-3.7600000 -2.5,-1.0 z "
+ id="path8298" />
+ </marker>
+ <marker
+ inkscape:stockid="DotL"
+ orient="auto"
+ refY="0.0"
+ refX="0.0"
+ id="DotL"
+ style="overflow:visible"
+ inkscape:isstock="true"
+ inkscape:collect="always">
+ <path
+ id="path4998"
+ d="M -2.5,-1.0 C -2.5,1.7600000 -4.7400000,4.0 -7.5,4.0 C -10.260000,4.0 -12.5,1.7600000 -12.5,-1.0 C -12.5,-3.7600000 -10.260000,-6.0 -7.5,-6.0 C -4.7400000,-6.0 -2.5,-3.7600000 -2.5,-1.0 z "
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
+ transform="scale(0.8) translate(7.4, 1)" />
+ </marker>
+ <marker
+ inkscape:stockid="DotM"
+ orient="auto"
+ refY="0.0"
+ refX="0.0"
+ id="DotM"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path5001"
+ d="M -2.5,-1.0 C -2.5,1.7600000 -4.7400000,4.0 -7.5,4.0 C -10.260000,4.0 -12.5,1.7600000 -12.5,-1.0 C -12.5,-3.7600000 -10.260000,-6.0 -7.5,-6.0 C -4.7400000,-6.0 -2.5,-3.7600000 -2.5,-1.0 z "
+ style="fill-rule:evenodd;stroke:#808000;stroke-width:1pt;stroke-opacity:1;fill:#808000;fill-opacity:1"
+ transform="scale(0.4) translate(7.4, 1)" />
+ </marker>
+ <marker
+ inkscape:stockid="EmptyTriangleOutL"
+ orient="auto"
+ refY="0.0"
+ refX="0.0"
+ id="EmptyTriangleOutL"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path5097"
+ d="M 5.77,0.0 L -2.88,5.0 L -2.88,-5.0 L 5.77,0.0 z "
+ style="fill-rule:evenodd;fill:#ffffff;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
+ transform="scale(0.8) translate(-6,0)" />
+ </marker>
+ <marker
+ inkscape:stockid="Tail"
+ orient="auto"
+ refY="0.0"
+ refX="0.0"
+ id="Tail"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <g
+ id="g4973"
+ transform="scale(-1.2)"
+ style="stroke:#808000;stroke-opacity:1;fill:#808000;fill-opacity:1">
+ <path
+ id="path4975"
+ d="M -3.8048674,-3.9585227 L 0.54352094,0"
+ style="fill:#808000;fill-rule:evenodd;stroke:#808000;stroke-width:0.8;stroke-linecap:round;stroke-opacity:1;fill-opacity:1" />
+ <path
+ id="path4977"
+ d="M -1.2866832,-3.9585227 L 3.0617053,0"
+ style="fill:#808000;fill-rule:evenodd;stroke:#808000;stroke-width:0.8;stroke-linecap:round;stroke-opacity:1;fill-opacity:1" />
+ <path
+ id="path4979"
+ d="M 1.3053582,-3.9585227 L 5.6537466,0"
+ style="fill:#808000;fill-rule:evenodd;stroke:#808000;stroke-width:0.8;stroke-linecap:round;stroke-opacity:1;fill-opacity:1" />
+ <path
+ id="path4981"
+ d="M -3.8048674,4.1775838 L 0.54352094,0.21974226"
+ style="fill:#808000;fill-rule:evenodd;stroke:#808000;stroke-width:0.8;stroke-linecap:round;stroke-opacity:1;fill-opacity:1" />
+ <path
+ id="path4983"
+ d="M -1.2866832,4.1775838 L 3.0617053,0.21974226"
+ style="fill:#808000;fill-rule:evenodd;stroke:#808000;stroke-width:0.8;stroke-linecap:round;stroke-opacity:1;fill-opacity:1" />
+ <path
+ id="path4985"
+ d="M 1.3053582,4.1775838 L 5.6537466,0.21974226"
+ style="fill:#808000;fill-rule:evenodd;stroke:#808000;stroke-width:0.8;stroke-linecap:round;stroke-opacity:1;fill-opacity:1" />
+ </g>
+ </marker>
+ <marker
+ inkscape:isstock="true"
+ style="overflow:visible"
+ id="marker5864"
+ refX="0.0"
+ refY="0.0"
+ orient="auto"
+ inkscape:stockid="Arrow2Mstart">
+ <path
+ transform="scale(0.6) translate(0,0)"
+ d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
+ style="fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round;stroke:#000000;stroke-opacity:1;fill:#000000;fill-opacity:1"
+ id="path5866" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow2Mstart"
+ orient="auto"
+ refY="0.0"
+ refX="0.0"
+ id="Arrow2Mstart"
+ style="overflow:visible"
+ inkscape:isstock="true"
+ inkscape:collect="always">
+ <path
+ id="path4820"
+ style="fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round;stroke:#000000;stroke-opacity:1;fill:#000000;fill-opacity:1"
+ d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
+ transform="scale(0.6) translate(0,0)" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow2Mend"
+ orient="auto"
+ refY="0.0"
+ refX="0.0"
+ id="marker5258"
+ style="overflow:visible;"
+ inkscape:isstock="true">
+ <path
+ id="path5260"
+ style="fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round;stroke:#000000;stroke-opacity:1;fill:#000000;fill-opacity:1"
+ d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
+ transform="scale(0.6) rotate(180) translate(0,0)" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow2Mend"
+ orient="auto"
+ refY="0.0"
+ refX="0.0"
+ id="Arrow2Mend"
+ style="overflow:visible;"
+ inkscape:isstock="true">
+ <path
+ id="path4823"
+ style="fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round;stroke:#000000;stroke-opacity:1;fill:#000000;fill-opacity:1"
+ d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
+ transform="scale(0.6) rotate(180) translate(0,0)" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker7736"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path7738"
+ d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"
+ style="fill:#00ffff;fill-opacity:1;fill-rule:evenodd;stroke:#00ffff;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(-0.8,0,0,-0.8,-10,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:isstock="true"
+ style="overflow:visible"
+ id="marker7588"
+ refX="0"
+ refY="0"
+ orient="auto"
+ inkscape:stockid="StopL">
+ <path
+ transform="scale(0.8,0.8)"
+ style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#00ffff;stroke-width:1pt;stroke-opacity:1"
+ d="M 0,5.65 0,-5.65"
+ id="path7590"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:isstock="true"
+ style="overflow:visible"
+ id="marker7330"
+ refX="0"
+ refY="0"
+ orient="auto"
+ inkscape:stockid="Arrow1Lend">
+ <path
+ transform="matrix(-0.8,0,0,-0.8,-10,0)"
+ style="fill:#ff00ff;fill-opacity:1;fill-rule:evenodd;stroke:#ff00ff;stroke-width:1pt;stroke-opacity:1"
+ d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"
+ id="path7332"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="StopL"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker7194"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path7196"
+ d="M 0,5.65 0,-5.65"
+ style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#ff00ff;stroke-width:1pt;stroke-opacity:1"
+ transform="scale(0.8,0.8)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker6280"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ id="path6282"
+ d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"
+ style="fill:#808000;fill-opacity:1;fill-rule:evenodd;stroke:#808000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(-0.8,0,0,-0.8,-10,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:isstock="true"
+ style="overflow:visible"
+ id="marker6198"
+ refX="0"
+ refY="0"
+ orient="auto"
+ inkscape:stockid="StopL">
+ <path
+ transform="scale(0.8,0.8)"
+ style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#808000;stroke-width:1pt;stroke-opacity:1"
+ d="M 0,5.65 0,-5.65"
+ id="path6200"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:isstock="true"
+ style="overflow:visible"
+ id="marker5802"
+ refX="0"
+ refY="0"
+ orient="auto"
+ inkscape:stockid="Arrow1Lend"
+ inkscape:collect="always">
+ <path
+ transform="matrix(-0.8,0,0,-0.8,-10,0)"
+ style="fill:#00ffff;fill-opacity:1;fill-rule:evenodd;stroke:#00ffff;stroke-width:1pt;stroke-opacity:1"
+ d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"
+ id="path5804"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="StopL"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker5732"
+ style="overflow:visible"
+ inkscape:isstock="true"
+ inkscape:collect="always">
+ <path
+ id="path5734"
+ d="M 0,5.65 0,-5.65"
+ style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#00ffff;stroke-width:1pt;stroke-opacity:1"
+ transform="scale(0.8,0.8)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker5348"
+ style="overflow:visible"
+ inkscape:isstock="true"
+ inkscape:collect="always">
+ <path
+ id="path5350"
+ d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"
+ style="fill:#ff00ff;fill-opacity:1;fill-rule:evenodd;stroke:#ff00ff;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(-0.8,0,0,-0.8,-10,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:isstock="true"
+ style="overflow:visible"
+ id="marker5182"
+ refX="0"
+ refY="0"
+ orient="auto"
+ inkscape:stockid="SquareL">
+ <path
+ transform="scale(0.8,0.8)"
+ style="fill:#808000;fill-opacity:1;fill-rule:evenodd;stroke:#808000;stroke-width:1pt;stroke-opacity:1"
+ d="M -5,-5 -5,5 5,5 5,-5 -5,-5 Z"
+ id="path5184"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="SquareL"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="SquareL"
+ style="overflow:visible"
+ inkscape:isstock="true"
+ inkscape:collect="always">
+ <path
+ id="path4253"
+ d="M -5,-5 -5,5 5,5 5,-5 -5,-5 Z"
+ style="fill:#808000;fill-opacity:1;fill-rule:evenodd;stroke:#808000;stroke-width:1pt;stroke-opacity:1"
+ transform="scale(0.8,0.8)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:isstock="true"
+ style="overflow:visible"
+ id="marker4670"
+ refX="0"
+ refY="0"
+ orient="auto"
+ inkscape:stockid="StopL"
+ inkscape:collect="always">
+ <path
+ transform="scale(0.8,0.8)"
+ style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#ff00ff;stroke-width:1pt;stroke-opacity:1"
+ d="M 0,5.65 0,-5.65"
+ id="path4672"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:isstock="true"
+ style="overflow:visible"
+ id="marker4465"
+ refX="0"
+ refY="0"
+ orient="auto"
+ inkscape:stockid="Arrow1Lend"
+ inkscape:collect="always">
+ <path
+ transform="matrix(-0.8,0,0,-0.8,-10,0)"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
+ d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"
+ id="path4467"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Lend"
+ style="overflow:visible"
+ inkscape:isstock="true"
+ inkscape:collect="always">
+ <path
+ id="path4186"
+ d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(-0.8,0,0,-0.8,-10,0)"
+ inkscape:connector-curvature="0" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="Arrow1Lend-7"
+ style="overflow:visible"
+ inkscape:isstock="true"
+ inkscape:collect="always">
+ <path
+ inkscape:connector-curvature="0"
+ id="path4186-9"
+ d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(-0.8,0,0,-0.8,-10,0)" />
+ </marker>
+ <marker
+ inkscape:isstock="true"
+ style="overflow:visible"
+ id="marker4465-9"
+ refX="0"
+ refY="0"
+ orient="auto"
+ inkscape:stockid="Arrow1Lend"
+ inkscape:collect="always">
+ <path
+ inkscape:connector-curvature="0"
+ transform="matrix(-0.8,0,0,-0.8,-10,0)"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
+ d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"
+ id="path4467-5" />
+ </marker>
+ <marker
+ inkscape:stockid="SquareL"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="SquareL-3"
+ style="overflow:visible"
+ inkscape:isstock="true"
+ inkscape:collect="always">
+ <path
+ inkscape:connector-curvature="0"
+ id="path4253-0"
+ d="M -5,-5 -5,5 5,5 5,-5 -5,-5 Z"
+ style="fill:#808000;fill-opacity:1;fill-rule:evenodd;stroke:#808000;stroke-width:1pt;stroke-opacity:1"
+ transform="scale(0.8,0.8)" />
+ </marker>
+ <marker
+ inkscape:isstock="true"
+ style="overflow:visible"
+ id="marker5182-2"
+ refX="0"
+ refY="0"
+ orient="auto"
+ inkscape:stockid="SquareL">
+ <path
+ inkscape:connector-curvature="0"
+ transform="scale(0.8,0.8)"
+ style="fill:#808000;fill-opacity:1;fill-rule:evenodd;stroke:#808000;stroke-width:1pt;stroke-opacity:1"
+ d="M -5,-5 -5,5 5,5 5,-5 -5,-5 Z"
+ id="path5184-3" />
+ </marker>
+ <marker
+ inkscape:stockid="StopL"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker5732-0"
+ style="overflow:visible"
+ inkscape:isstock="true"
+ inkscape:collect="always">
+ <path
+ inkscape:connector-curvature="0"
+ id="path5734-4"
+ d="M 0,5.65 0,-5.65"
+ style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#808000;stroke-width:1pt;stroke-opacity:1"
+ transform="scale(0.8,0.8)" />
+ </marker>
+ <marker
+ inkscape:isstock="true"
+ style="overflow:visible"
+ id="marker5802-7"
+ refX="0"
+ refY="0"
+ orient="auto"
+ inkscape:stockid="Arrow1Lend"
+ inkscape:collect="always">
+ <path
+ inkscape:connector-curvature="0"
+ transform="matrix(-0.8,0,0,-0.8,-10,0)"
+ style="fill:#808000;fill-opacity:1;fill-rule:evenodd;stroke:#808000;stroke-width:1pt;stroke-opacity:1"
+ d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"
+ id="path5804-1" />
+ </marker>
+ <marker
+ inkscape:isstock="true"
+ style="overflow:visible"
+ id="marker6198-4"
+ refX="0"
+ refY="0"
+ orient="auto"
+ inkscape:stockid="StopL">
+ <path
+ inkscape:connector-curvature="0"
+ transform="scale(0.8,0.8)"
+ style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#808000;stroke-width:1pt;stroke-opacity:1"
+ d="M 0,5.65 0,-5.65"
+ id="path6200-9" />
+ </marker>
+ <marker
+ inkscape:stockid="Arrow1Lend"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker6280-2"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ inkscape:connector-curvature="0"
+ id="path6282-9"
+ d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"
+ style="fill:#808000;fill-opacity:1;fill-rule:evenodd;stroke:#808000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(-0.8,0,0,-0.8,-10,0)" />
+ </marker>
+ <path
+ inkscape:connector-curvature="0"
+ id="path4495-6"
+ d="M -1.5544254,814.86219 301.55446,989.86218"
+ style="fill:none;fill-rule:evenodd;stroke:#00ff00;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ sodipodi:open="true"
+ d="m 319.5,902.36218 a 169.5,169.5 0 0 1 -22.70869,84.75"
+ sodipodi:end="0.52359878"
+ sodipodi:start="0"
+ sodipodi:ry="169.5"
+ sodipodi:rx="169.5"
+ sodipodi:cy="902.36218"
+ sodipodi:cx="150"
+ sodipodi:type="arc"
+ id="path6190-6"
+ style="opacity:1;fill:none;fill-opacity:0.96862745;fill-rule:nonzero;stroke:#808000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker-start:url(#marker6198-4);marker-end:url(#marker6280-2)" />
+ <path
+ sodipodi:open="true"
+ d="m 760.55476,706.46857 a 179.46986,179.46986 0 0 1 -41.98797,115.361"
+ sodipodi:end="0.6981317"
+ sodipodi:start="0"
+ sodipodi:ry="179.46986"
+ sodipodi:rx="179.46986"
+ sodipodi:cy="706.46857"
+ sodipodi:cx="581.0849"
+ sodipodi:type="arc"
+ transform="matrix(0.8660254,0.5,-0.5,0.8660254,0,0)"
+ id="path5724-8"
+ style="opacity:1;fill:none;fill-opacity:0.96862745;fill-rule:nonzero;stroke:#808000;stroke-width:1.06025696;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker-start:url(#marker5732-0);marker-end:url(#marker5802-7)" />
+ <marker
+ inkscape:stockid="EmptyTriangleOutL"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="EmptyTriangleOutL-9"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ inkscape:connector-curvature="0"
+ id="path5097-0"
+ d="m 5.77,0 -8.65,5 0,-10 8.65,5 z"
+ style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(0.8,0,0,0.8,-4.8,0)" />
+ </marker>
+ <marker
+ inkscape:stockid="EmptyTriangleOutL"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="EmptyTriangleOutL-0"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ inkscape:connector-curvature="0"
+ id="path5097-4"
+ d="m 5.77,0 -8.65,5 0,-10 8.65,5 z"
+ style="fill:#ffffff;fill-rule:evenodd;stroke:#808000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(0.8,0,0,0.8,-4.8,0)" />
+ </marker>
+ <marker
+ inkscape:stockid="EmptyTriangleOutL"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="EmptyTriangleOutL-0-6"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ inkscape:connector-curvature="0"
+ id="path5097-4-5"
+ d="m 5.77,0 -8.65,5 0,-10 8.65,5 z"
+ style="fill:#ffffff;fill-rule:evenodd;stroke:#808000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(0.8,0,0,0.8,-4.8,0)" />
+ </marker>
+ <marker
+ inkscape:stockid="DotL"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker10255-3"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ inkscape:connector-curvature="0"
+ id="path10257-9"
+ d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(0.8,0,0,0.8,5.92,0.8)" />
+ </marker>
+ <marker
+ inkscape:stockid="EmptyTriangleOutL"
+ orient="auto"
+ refY="0"
+ refX="0"
+ id="marker10499-9"
+ style="overflow:visible"
+ inkscape:isstock="true">
+ <path
+ inkscape:connector-curvature="0"
+ id="path10501-6"
+ d="m 5.77,0 -8.65,5 0,-10 8.65,5 z"
+ style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1"
+ transform="matrix(0.8,0,0,0.8,-4.8,0)" />
+ </marker>
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1.28"
+ inkscape:cx="442.40881"
+ inkscape:cy="258.7933"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ showguides="true"
+ inkscape:guide-bbox="true"
+ inkscape:snap-bbox="true"
+ inkscape:snap-midpoints="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-object-midpoints="true"
+ inkscape:snap-bbox-midpoints="true"
+ inkscape:snap-center="true"
+ inkscape:snap-bbox-edge-midpoints="true"
+ inkscape:object-nodes="true"
+ inkscape:snap-smooth-nodes="true"
+ inkscape:snap-intersection-paths="true"
+ units="px"
+ fit-margin-top="5"
+ fit-margin-bottom="20"
+ fit-margin-left="20"
+ fit-margin-right="20"
+ inkscape:snap-global="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1028"
+ inkscape:window-x="1912"
+ inkscape:window-y="-8"
+ inkscape:window-maximized="1" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title>OpenCV: Parameters of Elliptic Arc </dc:title>
+ <cc:license
+ rdf:resource="OpenCV License" />
+ <dc:date>Feb 2017</dc:date>
+ <dc:creator>
+ <cc:Agent>
+ <dc:title>PkLab.net</dc:title>
+ </cc:Agent>
+ </dc:creator>
+ <dc:publisher>
+ <cc:Agent>
+ <dc:title>PkLab.net</dc:title>
+ </cc:Agent>
+ </dc:publisher>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(40.833559,-707.15463)">
+ <ellipse
+ style="opacity:1;fill:#e6e6e6;fill-opacity:0.96862745;fill-rule:nonzero;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:1, 1;stroke-dashoffset:0;stroke-opacity:1"
+ id="path4151"
+ cx="581.0849"
+ cy="706.46857"
+ rx="149.47528"
+ ry="149.47527"
+ transform="matrix(0.8660254,0.5,-0.5,0.8660254,0,0)" />
+ <ellipse
+ style="opacity:1;fill:none;fill-opacity:0.96862745;fill-rule:nonzero;stroke:#ff0000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path4153"
+ cx="581.0849"
+ cy="706.46857"
+ rx="149.52977"
+ ry="74.52977"
+ transform="matrix(0.8660254,0.5,-0.5,0.8660254,0,0)" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.99999994;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#Arrow1Lend)"
+ d="m 135.80359,902.36221 238.2293,0"
+ id="path4175"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.99999994;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker4465)"
+ d="m 150.00002,888.19052 0,216.79618"
+ id="path4177"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#00ff00;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 62.500014,1053.9166 237.50002,750.80774"
+ id="path4493"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#00ff00;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M -1.5544254,814.86219 301.55446,989.86218"
+ id="path4495"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#808000;stroke-width:1.00000006;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:3.00000018,3.00000018;stroke-dashoffset:0;stroke-opacity:1;marker-end:url(#SquareL)"
+ d="M 5.5030681,959.76375 63.902407,857.80226"
+ id="path4493-1"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#808000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:3, 3;stroke-dashoffset:0;stroke-opacity:1;marker-end:url(#marker5182)"
+ d="m 197.74252,1048.4226 49.16186,-85.32573"
+ id="path4493-1-5"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#00ffff;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:3, 3;stroke-dashoffset:0;stroke-opacity:1"
+ d="m 149.99991,902.36233 61.68111,169.46737"
+ id="path4828"
+ inkscape:connector-curvature="0" />
+ <path
+ style="opacity:1;fill:none;fill-opacity:0.96862745;fill-rule:nonzero;stroke:#0000ff;stroke-width:3;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path4153-8"
+ sodipodi:type="arc"
+ sodipodi:cx="581.0849"
+ sodipodi:cy="706.46875"
+ sodipodi:rx="149.52977"
+ sodipodi:ry="74.52977"
+ sodipodi:start="0.6981317"
+ sodipodi:end="2.268928"
+ d="m 695.63135,754.37556 a 149.52977,74.52977 0 0 1 -210.66233,9.18631"
+ transform="matrix(0.8660254,0.5,-0.5,0.8660254,0,0)"
+ sodipodi:open="true" />
+ <path
+ style="opacity:1;fill:none;fill-opacity:0.96862745;fill-rule:nonzero;stroke:#ff00ff;stroke-width:1.06025696;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker-start:url(#marker4670);marker-end:url(#marker5348)"
+ id="path5094"
+ sodipodi:type="arc"
+ sodipodi:cx="581.08502"
+ sodipodi:cy="706.46863"
+ sodipodi:rx="161.96986"
+ sodipodi:ry="161.96988"
+ sodipodi:start="0"
+ sodipodi:end="2.268928"
+ d="M 743.05489,706.46863 A 161.96986,161.96988 0 0 1 649.53645,853.26319 161.96986,161.96988 0 0 1 476.9728,830.54476"
+ sodipodi:open="true"
+ inkscape:transform-center-x="48.402303"
+ inkscape:transform-center-y="108.68337"
+ transform="matrix(0.8660254,0.5,-0.5,0.8660254,0,0)" />
+ <path
+ style="opacity:1;fill:none;fill-opacity:0.96862745;fill-rule:nonzero;stroke:#00ffff;stroke-width:1.06025696;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker-start:url(#marker5732);marker-end:url(#marker5802)"
+ id="path5724"
+ transform="matrix(0.8660254,0.5,-0.5,0.8660254,0,0)"
+ sodipodi:type="arc"
+ sodipodi:cx="581.0849"
+ sodipodi:cy="706.46857"
+ sodipodi:rx="179.46986"
+ sodipodi:ry="179.46986"
+ sodipodi:start="0"
+ sodipodi:end="0.6981317"
+ d="m 760.55476,706.46857 a 179.46986,179.46986 0 0 1 -41.98797,115.361"
+ sodipodi:open="true" />
+ <path
+ style="opacity:1;fill:none;fill-opacity:0.96862745;fill-rule:nonzero;stroke:#808000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker-start:url(#marker6198);marker-end:url(#marker6280)"
+ id="path6190"
+ sodipodi:type="arc"
+ sodipodi:cx="150"
+ sodipodi:cy="902.36218"
+ sodipodi:rx="169.5"
+ sodipodi:ry="169.5"
+ sodipodi:start="0"
+ sodipodi:end="0.52359878"
+ d="m 319.5,902.36218 a 169.5,169.5 0 0 1 -22.70869,84.75"
+ sodipodi:open="true" />
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.00000095px;line-height:136.00000143%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="text6446"
+ sodipodi:linespacing="136%"><textPath
+ xlink:href="#path4495"
+ id="textPath6450"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.00000095px;line-height:136.00000143%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;writing-mode:lr-tb;text-anchor:start"> FIRST AXIS</textPath></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.0000006px;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
+ x="374.0329"
+ y="902.36218"
+ id="text6453"
+ sodipodi:linespacing="125%"><tspan
+ sodipodi:role="line"
+ id="tspan6455"
+ x="374.0329"
+ y="902.36218"> X</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.0000006px;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
+ x="152.56752"
+ y="1112.6388"
+ id="text6457"
+ sodipodi:linespacing="125%"><tspan
+ sodipodi:role="line"
+ id="tspan6459"
+ x="152.56752"
+ y="1112.6388">Y</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.0000006px;line-height:136%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
+ id="text6492"
+ sodipodi:linespacing="136%"><textPath
+ xlink:href="#path5724"
+ id="textPath6512"><tspan
+ id="tspan6494"
+ dy="0 0 0 0 -2"
+ style="-inkscape-font-specification:'sans-serif, Normal';font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:10.0000006px;text-anchor:start;text-align:start;writing-mode:lr;line-height:136%;"> START ANGLE</tspan></textPath></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.0000006px;line-height:136%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
+ id="text6496"
+ sodipodi:linespacing="136%"><textPath
+ xlink:href="#path5094"
+ id="textPath6527"><tspan
+ id="tspan6498"
+ dy="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2"
+ style="-inkscape-font-specification:'sans-serif, Normal';font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:10.0000006px;text-anchor:start;text-align:start;writing-mode:lr;line-height:136%;"> END ANGLE</tspan></textPath></text>
+ <ellipse
+ style="opacity:1;fill:#e6e6e6;fill-opacity:0.96862745;fill-rule:nonzero;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:1, 1;stroke-dashoffset:0;stroke-opacity:1"
+ id="path4151-7"
+ cx="970.36328"
+ cy="481.71857"
+ rx="149.47528"
+ ry="149.47527"
+ transform="matrix(0.8660254,0.5,-0.5,0.8660254,0,0)" />
+ <ellipse
+ style="opacity:1;fill:none;fill-opacity:0.96862745;fill-rule:nonzero;stroke:#ff0000;stroke-width:0.99999988;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path4153-4"
+ cx="970.36328"
+ cy="481.7186"
+ rx="149.5"
+ ry="199.5"
+ transform="matrix(0.8660254,0.5,-0.5,0.8660254,0,0)" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.99999994;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#Arrow1Lend-7)"
+ d="m 585.30357,902.36221 222.87861,0"
+ id="path4175-8"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker4465-9)"
+ d="m 599.5,888.19052 0,238.01018"
+ id="path4177-3"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#00ff00;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 493.8871,1085.2486 709.21229,712.40469"
+ id="path4493-6"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#00ff00;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 447.94555,814.86219 751.05444,989.86218"
+ id="path6601"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#808000;stroke-width:1.00000006;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:3.00000018,3.00000018;stroke-dashoffset:0;stroke-opacity:1;marker-end:url(#SquareL-3)"
+ d="M 432.66651,996.2203 512.28503,858.86961"
+ id="path4493-1-4"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#808000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:3.00000005, 3.00000005;stroke-dashoffset:0;stroke-opacity:1;marker-end:url(#marker5182-2)"
+ d="M 622.90827,1087.6338 695.04781,964.38683"
+ id="path4493-1-5-7"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#ff00ff;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:3, 3;stroke-dashoffset:0;stroke-opacity:1"
+ d="M 598.72808,902.72337 428.83625,964.0896"
+ id="path4826-6"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#00ffff;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:3, 3;stroke-dashoffset:0;stroke-opacity:1"
+ d="M 599.49989,902.36233 661.181,1071.8297"
+ id="path4828-5"
+ inkscape:connector-curvature="0" />
+ <path
+ style="opacity:1;fill:none;fill-opacity:0.96862745;fill-rule:nonzero;stroke:#ff00ff;stroke-width:1.06025696;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker-start:url(#marker7194);marker-end:url(#marker7330)"
+ id="path6608"
+ sodipodi:type="arc"
+ sodipodi:cx="970.3634"
+ sodipodi:cy="481.71863"
+ sodipodi:rx="161.96986"
+ sodipodi:ry="161.96988"
+ sodipodi:start="0"
+ sodipodi:end="2.268928"
+ d="M 1132.3333,481.71863 A 161.96986,161.96988 0 0 1 1038.8148,628.51319 161.96986,161.96988 0 0 1 866.25119,605.79476"
+ sodipodi:open="true"
+ inkscape:transform-center-x="48.402303"
+ inkscape:transform-center-y="108.68337"
+ transform="matrix(0.8660254,0.5,-0.5,0.8660254,0,0)" />
+ <path
+ style="opacity:1;fill:none;fill-opacity:0.96862745;fill-rule:nonzero;stroke:#00ffff;stroke-width:1.06025696;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker-start:url(#marker7588);marker-end:url(#marker7736)"
+ id="path6610"
+ transform="matrix(0.8660254,0.5,-0.5,0.8660254,0,0)"
+ sodipodi:type="arc"
+ sodipodi:cx="970.36328"
+ sodipodi:cy="481.71857"
+ sodipodi:rx="179.46986"
+ sodipodi:ry="179.46986"
+ sodipodi:start="0"
+ sodipodi:end="0.6981317"
+ d="m 1149.8331,481.71857 a 179.46986,179.46986 0 0 1 -41.9879,115.361"
+ sodipodi:open="true" />
+ <path
+ style="opacity:1;fill:none;fill-opacity:0.96862745;fill-rule:nonzero;stroke:#808000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker-start:url(#marker6198-4);marker-end:url(#marker6280-2)"
+ id="path6612"
+ sodipodi:type="arc"
+ sodipodi:cx="599.5"
+ sodipodi:cy="902.36218"
+ sodipodi:rx="169.5"
+ sodipodi:ry="169.5"
+ sodipodi:start="0"
+ sodipodi:end="0.52359878"
+ d="m 769,902.36218 a 169.5,169.5 0 0 1 -22.70869,84.75"
+ sodipodi:open="true" />
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.00000095px;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="text6446-6"
+ sodipodi:linespacing="125%"
+ transform="translate(449.49998,0)"><textPath
+ xlink:href="#path4495-6"
+ id="textPath6450-7"><tspan
+ id="tspan6448-1"
+ dy="-2"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.00000095px;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;writing-mode:lr-tb;text-anchor:start">FIRST AXIS</tspan></textPath></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.0000006px;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
+ x="806.11353"
+ y="900.2674"
+ id="text6453-8"
+ sodipodi:linespacing="125%"><tspan
+ sodipodi:role="line"
+ id="tspan6455-2"
+ x="806.11353"
+ y="900.2674"> X</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.0000006px;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
+ x="602.14368"
+ y="1132.3958"
+ id="text6457-3"
+ sodipodi:linespacing="125%"><tspan
+ sodipodi:role="line"
+ id="tspan6459-8"
+ x="602.14368"
+ y="1132.3958">Y</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.0000006px;line-height:163%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
+ id="text6492-3"
+ sodipodi:linespacing="163%"
+ transform="translate(449.49998,0)"><textPath
+ xlink:href="#path5724-8"
+ id="textPath6512-5"><tspan
+ id="tspan6494-6"
+ dy="0 0 0 0 -2"
+ style="-inkscape-font-specification:'sans-serif, Normal';font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:10.0000006px;text-anchor:start;text-align:start;writing-mode:lr;line-height:163%;"> START ANGLE</tspan></textPath></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.0000006px;line-height:136%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
+ id="text6496-6"
+ sodipodi:linespacing="136%"><textPath
+ xlink:href="#path6608"
+ id="textPath7500"><tspan
+ id="tspan6498-1"
+ dy="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2"
+ style="-inkscape-font-specification:'sans-serif, Normal';font-family:sans-serif;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:10.0000006px;text-anchor:start;text-align:start;writing-mode:lr;line-height:136%;"> END ANGLE</tspan></textPath></text>
+ <path
+ style="opacity:1;fill:none;fill-opacity:0.96862745;fill-rule:nonzero;stroke:#0000ff;stroke-width:3;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path4153-4-1"
+ transform="matrix(0.8660254,0.5,-0.5,0.8660254,0,0)"
+ sodipodi:type="arc"
+ sodipodi:cx="970.36328"
+ sodipodi:cy="481.7186"
+ sodipodi:rx="149.5"
+ sodipodi:ry="199.5"
+ sodipodi:start="0.70844844"
+ sodipodi:end="2.268928"
+ d="M 1083.8894,611.52454 A 149.5,199.5 0 0 1 874.26654,634.54447"
+ sodipodi:open="true" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#ff00ff;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:3, 3;stroke-dashoffset:0;stroke-opacity:1"
+ d="M 149.2281,902.72337 -20.663726,964.0896"
+ id="path4826"
+ inkscape:connector-curvature="0" />
+ <path
+ style="opacity:1;fill:none;fill-opacity:0.96862745;fill-rule:nonzero;stroke:#000000;stroke-width:2.00000024;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path4151-1"
+ sodipodi:type="arc"
+ sodipodi:cx="581.0849"
+ sodipodi:cy="706.46875"
+ sodipodi:rx="149.47528"
+ sodipodi:ry="149.47527"
+ sodipodi:start="0.6981317"
+ sodipodi:end="2.268928"
+ d="M 695.58961,802.5496 A 149.47528,149.47527 0 0 1 485.00404,820.97345"
+ transform="matrix(0.8660254,0.5,-0.5,0.8660254,0,0)"
+ sodipodi:open="true" />
+ <path
+ style="opacity:1;fill:none;fill-opacity:0.96862745;fill-rule:nonzero;stroke:#000000;stroke-width:2.00000024;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path4151-1-3"
+ sodipodi:type="arc"
+ sodipodi:cx="970.36328"
+ sodipodi:cy="481.71875"
+ sodipodi:rx="149.47528"
+ sodipodi:ry="149.47527"
+ sodipodi:start="0.6981317"
+ sodipodi:end="2.268928"
+ d="M 1084.868,577.7996 A 149.47528,149.47527 0 0 1 874.28243,596.22345"
+ transform="matrix(0.8660254,0.5,-0.5,0.8660254,0,0)"
+ sodipodi:open="true" />
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.0000006px;line-height:136%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
+ id="text7956"
+ sodipodi:linespacing="136%"><textPath
+ xlink:href="#path7960"
+ id="textPath8909"
+ dy="-2"> AXES.WIDTH</textPath></text>
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-start:url(#Arrow2Mstart);marker-end:url(#marker5258)"
+ d="M 42.572298,794.94012 168.8221,867.80578"
+ id="path7960"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000012;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#marker5864);marker-end:url(#Arrow2Mend)"
+ d="m 198.18927,845.65244 -36.13322,63.04388"
+ id="path4493-7"
+ inkscape:connector-curvature="0" />
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.0000006px;line-height:136%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
+ id="text7074"
+ sodipodi:linespacing="136%"><textPath
+ xlink:href="#path4493-7"
+ id="textPath7090"
+ dy="-2"> AXES.EIGHT</textPath></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.00000095px;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ x="18.343853"
+ y="746.41614"
+ id="text10033"
+ sodipodi:linespacing="125%"><tspan
+ sodipodi:role="line"
+ id="tspan10035"
+ x="18.343853"
+ y="746.41614">AXES.WIDTH > AXES.HEIGHT</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.00000095px;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ x="365.59418"
+ y="746.6203"
+ id="text10033-4"
+ sodipodi:linespacing="125%"><tspan
+ sodipodi:role="line"
+ id="tspan10035-2"
+ x="365.59418"
+ y="746.6203">AXES.WIDTH > AXES.HEIGHT</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.0000006px;line-height:136%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
+ id="text6461"
+ sodipodi:linespacing="136%"><textPath
+ xlink:href="#path6190"
+ id="textPath6477"
+ dy="0 0 0 0 0 0 0 0 -2"> ANGLE</textPath></text>
+ <text
+ xml:space="preserve"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.0000006px;line-height:163%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
+ id="text6461-4"
+ sodipodi:linespacing="163%"
+ transform="translate(449.49998,0)"><textPath
+ xlink:href="#path6190-6"
+ id="textPath6477-3"
+ dy="0 0 0 0 0 0 0 0 -2"> ANGLE</textPath></text>
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000006;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker-start:url(#DotL);marker-end:url(#EmptyTriangleOutL)"
+ d="M 9.3696449,953.01295 37.857294,903.27534"
+ id="path4493-1-9"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000006;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker-end:url(#EmptyTriangleOutL-9);marker-start:url(#marker8296)"
+ d="m 200.92867,1042.8927 23.9216,-41.7656"
+ id="path4493-1-9-6"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-start:url(#marker10255);marker-end:url(#marker10499)"
+ d="m 458.42826,951.77509 -18.99218,32.76452"
+ id="path10247"
+ inkscape:connector-curvature="0" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-start:url(#marker10255-3);marker-end:url(#marker10499-9)"
+ d="m 650.05357,1041.2573 -18.99218,32.7645"
+ id="path10247-9"
+ inkscape:connector-curvature="0" />
+ </g>
+</svg>
diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp
index 007a238..1c86adb 100644
--- a/modules/imgproc/include/opencv2/imgproc.hpp
+++ b/modules/imgproc/include/opencv2/imgproc.hpp
@@ -198,8 +198,8 @@ int main(int argc, const char *argv[])
The Subdiv2D class described in this section is used to perform various planar subdivision on
a set of 2D points (represented as vector of Point2f). OpenCV subdivides a plane into triangles
-using the Delaunay’s algorithm, which corresponds to the dual graph of the Voronoi diagram.
-In the figure below, the Delaunay’s triangulation is marked with black lines and the Voronoi
+using the Delaunay's algorithm, which corresponds to the dual graph of the Voronoi diagram.
+In the figure below, the Delaunay's triangulation is marked with black lines and the Voronoi
diagram with red lines.

@@ -245,8 +245,8 @@ enum MorphTypes{
//!< \f[\texttt{dst} = \mathrm{tophat} ( \texttt{src} , \texttt{element} )= \texttt{src} - \mathrm{open} ( \texttt{src} , \texttt{element} )\f]
MORPH_BLACKHAT = 6, //!< "black hat"
//!< \f[\texttt{dst} = \mathrm{blackhat} ( \texttt{src} , \texttt{element} )= \mathrm{close} ( \texttt{src} , \texttt{element} )- \texttt{src}\f]
- MORPH_HITMISS = 7 //!< "hit and miss"
- //!< .- Only supported for CV_8UC1 binary images. Tutorial can be found in [this page](https://web.archive.org/web/20160316070407/http://opencv-code.com/tutorials/hit-or-miss-transform-in-opencv/)
+ MORPH_HITMISS = 7 //!< "hit or miss"
+ //!< .- Only supported for CV_8UC1 binary images. A tutorial can be found in the documentation
};
//! shape of the structuring element
@@ -416,7 +416,7 @@ enum ConnectedComponentsTypes {
//! connected components algorithm
enum ConnectedComponentsAlgorithmsTypes {
CCL_WU = 0, //!< SAUF algorithm for 8-way connectivity, SAUF algorithm for 4-way connectivity
- CCL_DEFAULT = -1, //!< BBDT algortihm for 8-way connectivity, SAUF algorithm for 4-way connectivity
+ CCL_DEFAULT = -1, //!< BBDT algorithm for 8-way connectivity, SAUF algorithm for 4-way connectivity
CCL_GRANA = 1 //!< BBDT algorithm for 8-way connectivity, SAUF algorithm for 4-way connectivity
};
@@ -452,6 +452,20 @@ enum ContourApproximationModes {
CHAIN_APPROX_TC89_KCOS = 4
};
+/** @brief Shape matching methods
+
+\f$A\f$ denotes object1,\f$B\f$ denotes object2
+
+\f$\begin{array}{l} m^A_i = \mathrm{sign} (h^A_i) \cdot \log{h^A_i} \\ m^B_i = \mathrm{sign} (h^B_i) \cdot \log{h^B_i} \end{array}\f$
+
+and \f$h^A_i, h^B_i\f$ are the Hu moments of \f$A\f$ and \f$B\f$ , respectively.
+*/
+enum ShapeMatchModes {
+ CONTOURS_MATCH_I1 =1, //!< \f[I_1(A,B) = \sum _{i=1...7} \left | \frac{1}{m^A_i} - \frac{1}{m^B_i} \right |\f]
+ CONTOURS_MATCH_I2 =2, //!< \f[I_2(A,B) = \sum _{i=1...7} \left | m^A_i - m^B_i \right |\f]
+ CONTOURS_MATCH_I3 =3 //!< \f[I_3(A,B) = \max _{i=1...7} \frac{ \left| m^A_i - m^B_i \right| }{ \left| m^A_i \right| }\f]
+};
+
//! @} imgproc_shape
//! Variants of a Hough transform
@@ -769,8 +783,18 @@ enum ColorConversionCodes {
COLOR_BayerRG2RGB_EA = COLOR_BayerBG2BGR_EA,
COLOR_BayerGR2RGB_EA = COLOR_BayerGB2BGR_EA,
+ //! Demosaicing with alpha channel
+ COLOR_BayerBG2BGRA = 139,
+ COLOR_BayerGB2BGRA = 140,
+ COLOR_BayerRG2BGRA = 141,
+ COLOR_BayerGR2BGRA = 142,
+
+ COLOR_BayerBG2RGBA = COLOR_BayerRG2BGRA,
+ COLOR_BayerGB2RGBA = COLOR_BayerGR2BGRA,
+ COLOR_BayerRG2RGBA = COLOR_BayerBG2BGRA,
+ COLOR_BayerGR2RGBA = COLOR_BayerGB2BGRA,
- COLOR_COLORCVT_MAX = 139
+ COLOR_COLORCVT_MAX = 143
};
/** types of intersection between rectangles
@@ -816,7 +840,7 @@ public:
};
//! Ballard, D.H. (1981). Generalizing the Hough transform to detect arbitrary shapes. Pattern Recognition 13 (2): 111-122.
-//! Detects position only without traslation and rotation
+//! Detects position only without translation and rotation
class CV_EXPORTS GeneralizedHoughBallard : public GeneralizedHough
{
public:
@@ -830,7 +854,7 @@ public:
};
//! Guil, N., González-Linares, J.M. and Zapata, E.L. (1999). Bidimensional shape detection using an invariant approach. Pattern Recognition 32 (6): 1025-1038.
-//! Detects position, traslation and rotation
+//! Detects position, translation and rotation
class CV_EXPORTS GeneralizedHoughGuil : public GeneralizedHough
{
public:
@@ -931,7 +955,7 @@ public:
/** @overload
- @param rect – Rectangle that includes all of the 2D points that are to be added to the subdivision.
+ @param rect Rectangle that includes all of the 2D points that are to be added to the subdivision.
The function creates an empty Delaunay subdivision where 2D points can be added using the function
insert() . All of the points to be added must be within the specified rectangle, otherwise a runtime
@@ -941,14 +965,14 @@ public:
/** @brief Creates a new empty Delaunay subdivision
- @param rect – Rectangle that includes all of the 2D points that are to be added to the subdivision.
+ @param rect Rectangle that includes all of the 2D points that are to be added to the subdivision.
*/
CV_WRAP void initDelaunay(Rect rect);
/** @brief Insert a single point into a Delaunay triangulation.
- @param pt – Point to insert.
+ @param pt Point to insert.
The function inserts a single point into a subdivision and modifies the subdivision topology
appropriately. If a point with the same coordinates exists already, no new point is added.
@@ -960,7 +984,7 @@ public:
/** @brief Insert multiple points into a Delaunay triangulation.
- @param ptvec – Points to insert.
+ @param ptvec Points to insert.
The function inserts a vector of points into a subdivision and modifies the subdivision topology
appropriately.
@@ -969,9 +993,9 @@ public:
/** @brief Returns the location of a point within a Delaunay triangulation.
- @param pt – Point to locate.
- @param edge – Output edge that the point belongs to or is located to the right of it.
- @param vertex – Optional output vertex the input point coincides with.
+ @param pt Point to locate.
+ @param edge Output edge that the point belongs to or is located to the right of it.
+ @param vertex Optional output vertex the input point coincides with.
The function locates the input point within the subdivision and gives one of the triangle edges
or vertices.
@@ -984,15 +1008,15 @@ public:
vertex will contain a pointer to the vertex.
- The point is outside the subdivision reference rectangle. The function returns PTLOC_OUTSIDE_RECT
and no pointers are filled.
- - One of input arguments is invalid. A runtime error is raised or, if silent or “parent” error
- processing mode is selected, CV_PTLOC_ERROR is returnd.
+ - One of input arguments is invalid. A runtime error is raised or, if silent or "parent" error
+ processing mode is selected, CV_PTLOC_ERROR is returned.
*/
CV_WRAP int locate(Point2f pt, CV_OUT int& edge, CV_OUT int& vertex);
/** @brief Finds the subdivision vertex closest to the given point.
- @param pt – Input point.
- @param nearestPt – Output subdivision vertex point.
+ @param pt Input point.
+ @param nearestPt Output subdivision vertex point.
The function is another function that locates the input point within the subdivision. It finds the
subdivision vertex that is the closest to the input point. It is not necessarily one of vertices
@@ -1005,7 +1029,7 @@ public:
/** @brief Returns a list of all edges.
- @param edgeList – Output vector.
+ @param edgeList Output vector.
The function gives each edge as a 4 numbers vector, where each two are one of the edge
vertices. i.e. org_x = v[0], org_y = v[1], dst_x = v[2], dst_y = v[3].
@@ -1014,7 +1038,7 @@ public:
/** @brief Returns a list of the leading edge ID connected to each triangle.
- @param leadingEdgeList – Output vector.
+ @param leadingEdgeList Output vector.
The function gives one edge ID for each triangle.
*/
@@ -1022,7 +1046,7 @@ public:
/** @brief Returns a list of all triangles.
- @param triangleList – Output vector.
+ @param triangleList Output vector.
The function gives each triangle as a 6 numbers vector, where each two are one of the triangle
vertices. i.e. p1_x = v[0], p1_y = v[1], p2_x = v[2], p2_y = v[3], p3_x = v[4], p3_y = v[5].
@@ -1031,9 +1055,9 @@ public:
/** @brief Returns a list of all Voroni facets.
- @param idx – Vector of vertices IDs to consider. For all vertices you can pass empty vector.
- @param facetList – Output vector of the Voroni facets.
- @param facetCenters – Output vector of the Voroni facets center points.
+ @param idx Vector of vertices IDs to consider. For all vertices you can pass empty vector.
+ @param facetList Output vector of the Voroni facets.
+ @param facetCenters Output vector of the Voroni facets center points.
*/
CV_WRAP void getVoronoiFacetList(const std::vector<int>& idx, CV_OUT std::vector<std::vector<Point2f> >& facetList,
@@ -1041,8 +1065,8 @@ public:
/** @brief Returns vertex location from vertex ID.
- @param vertex – vertex ID.
- @param firstEdge – Optional. The first edge ID which is connected to the vertex.
+ @param vertex vertex ID.
+ @param firstEdge Optional. The first edge ID which is connected to the vertex.
@returns vertex (x,y)
*/
@@ -1050,8 +1074,8 @@ public:
/** @brief Returns one of the edges related to the given edge.
- @param edge – Subdivision edge ID.
- @param nextEdgeType - Parameter specifying which of the related edges to return.
+ @param edge Subdivision edge ID.
+ @param nextEdgeType Parameter specifying which of the related edges to return.
The following values are possible:
- NEXT_AROUND_ORG next around the edge origin ( eOnext on the picture below if e is the input edge)
- NEXT_AROUND_DST next around the edge vertex ( eDnext )
@@ -1070,7 +1094,7 @@ public:
/** @brief Returns next edge around the edge origin.
- @param edge – Subdivision edge ID.
+ @param edge Subdivision edge ID.
@returns an integer which is next edge ID around the edge origin: eOnext on the
picture above if e is the input edge).
@@ -1079,8 +1103,8 @@ public:
/** @brief Returns another edge of the same quad-edge.
- @param edge – Subdivision edge ID.
- @param rotate - Parameter specifying which of the edges of the same quad-edge as the input
+ @param edge Subdivision edge ID.
+ @param rotate Parameter specifying which of the edges of the same quad-edge as the input
one to return. The following values are possible:
- 0 - the input edge ( e on the picture below if e is the input edge)
- 1 - the rotated edge ( eRot )
@@ -1094,8 +1118,8 @@ public:
/** @brief Returns the edge origin.
- @param edge – Subdivision edge ID.
- @param orgpt – Output vertex location.
+ @param edge Subdivision edge ID.
+ @param orgpt Output vertex location.
@returns vertex ID.
*/
@@ -1103,8 +1127,8 @@ public:
/** @brief Returns the edge destination.
- @param edge – Subdivision edge ID.
- @param dstpt – Output vertex location.
+ @param edge Subdivision edge ID.
+ @param dstpt Output vertex location.
@returns vertex ID.
*/
@@ -1203,7 +1227,7 @@ public:
OutputArray nfa = noArray()) = 0;
/** @brief Draws the line segments on a given image.
- @param _image The image, where the liens will be drawn. Should be bigger or equal to the image,
+ @param _image The image, where the lines will be drawn. Should be bigger or equal to the image,
where the lines were found.
@param lines A vector of the lines that needed to be drawn.
*/
@@ -1261,7 +1285,7 @@ smoothing kernels (a symmetrical kernel with sum of weights equal to 1) and hand
You may also use the higher-level GaussianBlur.
@param ksize Aperture size. It should be odd ( \f$\texttt{ksize} \mod 2 = 1\f$ ) and positive.
@param sigma Gaussian standard deviation. If it is non-positive, it is computed from ksize as
-`sigma = 0.3\*((ksize-1)\*0.5 - 1) + 0.8`.
+`sigma = 0.3*((ksize-1)*0.5 - 1) + 0.8`.
@param ktype Type of filter coefficients. It can be CV_32F or CV_64F .
@sa sepFilter2D, getDerivKernels, getStructuringElement, GaussianBlur
*/
@@ -1397,7 +1421,7 @@ CV_EXPORTS_W void bilateralFilter( InputArray src, OutputArray dst, int d,
/** @brief Blurs an image using the box filter.
-The function smoothes an image using the kernel:
+The function smooths an image using the kernel:
\f[\texttt{K} = \alpha \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \end{bmatrix}\f]
@@ -1449,7 +1473,7 @@ CV_EXPORTS_W void sqrBoxFilter( InputArray _src, OutputArray _dst, int ddepth,
/** @brief Blurs an image using the normalized box filter.
-The function smoothes an image using the kernel:
+The function smooths an image using the kernel:
\f[\texttt{K} = \frac{1}{\texttt{ksize.width*ksize.height}} \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \end{bmatrix}\f]
@@ -2157,6 +2181,9 @@ kernel center.
@param borderValue Border value in case of a constant border. The default value has a special
meaning.
@sa dilate, erode, getStructuringElement
+ at note The number of iterations is the number of times erosion or dilatation operation will be applied.
+For instance, an opening operation (#MORPH_OPEN) with two iterations is equivalent to apply
+successively: erode -> erode -> dilate -> dilate (and not erode -> dilate -> erode -> dilate).
*/
CV_EXPORTS_W void morphologyEx( InputArray src, OutputArray dst,
int op, InputArray kernel,
@@ -2578,9 +2605,8 @@ The function supports multi-channel images. Each channel is processed independen
The functions accumulate\* can be used, for example, to collect statistics of a scene background
viewed by a still camera and for the further foreground-background segmentation.
- at param src Input image as 1- or 3-channel, 8-bit or 32-bit floating point.
- at param dst %Accumulator image with the same number of channels as input image, 32-bit or 64-bit
-floating-point.
+ at param src Input image of type CV_8UC(n), CV_16UC(n), CV_32FC(n) or CV_64FC(n), where n is a positive integer.
+ at param dst %Accumulator image with the same number of channels as input image, and a depth of CV_32F or CV_64F.
@param mask Optional operation mask.
@sa accumulateSquare, accumulateProduct, accumulateWeighted
@@ -2709,7 +2735,7 @@ CV_EXPORTS_W void createHanningWindow(OutputArray dst, Size winSize, int type);
/** @brief Applies a fixed-level threshold to each array element.
-The function applies fixed-level thresholding to a single-channel array. The function is typically
+The function applies fixed-level thresholding to a multiple-channel array. The function is typically
used to get a bi-level (binary) image out of a grayscale image ( cv::compare could be also used for
this purpose) or for removing a noise, that is, filtering out pixels with too small or too large
values. There are several types of thresholding supported by the function. They are determined by
@@ -2721,8 +2747,10 @@ or Triangle algorithm and uses it instead of the specified thresh . The function
computed threshold value. Currently, the Otsu's and Triangle methods are implemented only for 8-bit
images.
- at param src input array (single-channel, 8-bit or 32-bit floating point).
- at param dst output array of the same size and type as src.
+ at note Input image should be single channel only in case of CV_THRESH_OTSU or CV_THRESH_TRIANGLE flags
+
+ at param src input array (multiple-channel, 8-bit or 32-bit floating point).
+ at param dst output array of the same size and type and the same number of channels as src.
@param thresh threshold value.
@param maxval maximum value to use with the THRESH_BINARY and THRESH_BINARY_INV thresholding
types.
@@ -2767,6 +2795,9 @@ CV_EXPORTS_W void adaptiveThreshold( InputArray src, OutputArray dst,
//! @addtogroup imgproc_filter
//! @{
+/** @example Pyramids.cpp
+An example using pyrDown and pyrUp functions
+ */
/** @brief Blurs an image and downsamples it.
By default, size of the output image is computed as `Size((src.cols+1)/2, (src.rows+1)/2)`, but in
@@ -2920,7 +2951,7 @@ computed by stereoRectify can be passed here. If the matrix is empty, the identi
is assumed. In cvInitUndistortMap R assumed to be an identity matrix.
@param newCameraMatrix New camera matrix \f$A'=\vecthreethree{f_x'}{0}{c_x'}{0}{f_y'}{c_y'}{0}{0}{1}\f$.
@param size Undistorted image size.
- at param m1type Type of the first output map that can be CV_32FC1 or CV_16SC2, see cv::convertMaps
+ at param m1type Type of the first output map that can be CV_32FC1, CV_32FC2 or CV_16SC2, see cv::convertMaps
@param map1 The first output map.
@param map2 The second output map.
*/
@@ -3255,6 +3286,10 @@ CV_EXPORTS float EMD( InputArray signature1, InputArray signature2,
int distType, InputArray cost=noArray(),
float* lowerBound = 0, OutputArray flow = noArray() );
+CV_EXPORTS_AS(EMD) float wrapperEMD( InputArray signature1, InputArray signature2,
+ int distType, InputArray cost=noArray(),
+ CV_IN_OUT Ptr<float> lowerBound = Ptr<float>(), OutputArray flow = noArray() );
+
//! @} imgproc_hist
/** @example watershed.cpp
@@ -3572,7 +3607,7 @@ CV_EXPORTS_W void cvtColor( InputArray src, OutputArray dst, int code, int dstCn
//! @} imgproc_misc
-// main function for all demosaicing procceses
+// main function for all demosaicing processes
CV_EXPORTS_W void demosaicing(InputArray _src, OutputArray _dst, int code, int dcn = 0);
//! @addtogroup imgproc_shape
@@ -3637,6 +3672,9 @@ enum TemplateMatchModes {
TM_CCOEFF_NORMED = 5 //!< \f[R(x,y)= \frac{ \sum_{x',y'} (T'(x',y') \cdot I'(x+x',y+y')) }{ \sqrt{\sum_{x',y'}T'(x',y')^2 \cdot \sum_{x',y'} I'(x+x',y+y')^2} }\f]
};
+/** @example MatchTemplate_Demo.cpp
+An example using Template Matching algorithm
+ */
/** @brief Compares a template against overlapped image regions.
The function slides through image , compares the overlapped patches of size \f$w \times h\f$ against
@@ -3658,7 +3696,7 @@ data type.
is \f$W \times H\f$ and templ is \f$w \times h\f$ , then result is \f$(W-w+1) \times (H-h+1)\f$ .
@param method Parameter specifying the comparison method, see cv::TemplateMatchModes
@param mask Mask of searched template. It must have the same datatype and size with templ. It is
-not set by default.
+not set by default. Currently, only the TM_SQDIFF and TM_CCORR_NORMED methods are supported.
*/
CV_EXPORTS_W void matchTemplate( InputArray image, InputArray templ,
OutputArray result, int method, InputArray mask = noArray() );
@@ -3674,8 +3712,10 @@ image with 4 or 8 way connectivity - returns N, the total number of labels [0, N
represents the background label. ltype specifies the output label image type, an important
consideration based on the total number of labels or alternatively the total number of pixels in
the source image. ccltype specifies the connected components labeling algorithm to use, currently
-Grana's (BBDT) and Wu's (SAUF) algorithms are supported, see the cv::ConnectedComponentsAlgorithmsTypes
+Grana (BBDT) and Wu's (SAUF) algorithms are supported, see the cv::ConnectedComponentsAlgorithmsTypes
for details. Note that SAUF algorithm forces a row major ordering of labels while BBDT does not.
+This function uses parallel version of both Grana and Wu's algorithms if at least one allowed
+parallel framework is enabled and if the rows of the image are at least twice the number returned by getNumberOfCPUs.
@param image the 8-bit single-channel image to be labeled
@param labels destination labeled image
@@ -3706,7 +3746,8 @@ consideration based on the total number of labels or alternatively the total num
the source image. ccltype specifies the connected components labeling algorithm to use, currently
Grana's (BBDT) and Wu's (SAUF) algorithms are supported, see the cv::ConnectedComponentsAlgorithmsTypes
for details. Note that SAUF algorithm forces a row major ordering of labels while BBDT does not.
-
+This function uses parallel version of both Grana and Wu's algorithms (statistics included) if at least one allowed
+parallel framework is enabled and if the rows of the image are at least twice the number returned by getNumberOfCPUs.
@param image the 8-bit single-channel image to be labeled
@param labels destination labeled image
@@ -3744,6 +3785,7 @@ CV_EXPORTS_W int connectedComponentsWithStats(InputArray image, OutputArray labe
The function retrieves contours from the binary image using the algorithm @cite Suzuki85 . The contours
are a useful tool for shape analysis and object detection and recognition. See squares.cpp in the
OpenCV sample directory.
+ at note Since opencv 3.2 source image is not modified by this function.
@param image Source, an 8-bit single-channel image. Non-zero pixels are treated as 1's. Zero
pixels remain 0's, so the image is treated as binary . You can use cv::compare, cv::inRange, cv::threshold ,
@@ -3753,7 +3795,7 @@ If mode equals to cv::RETR_CCOMP or cv::RETR_FLOODFILL, the input can also be a
std::vector<std::vector<cv::Point> >).
@param hierarchy Optional output vector (e.g. std::vector<cv::Vec4i>), containing information about the image topology. It has
as many elements as the number of contours. For each i-th contour contours[i], the elements
-hierarchy[i][0] , hiearchy[i][1] , hiearchy[i][2] , and hiearchy[i][3] are set to 0-based indices
+hierarchy[i][0] , hierarchy[i][1] , hierarchy[i][2] , and hierarchy[i][3] are set to 0-based indices
in contours of the next and previous contours at the same hierarchical level, the first child
contour and the parent contour, respectively. If for the contour i there are no next, previous,
parent, or nested contours, the corresponding elements of hierarchy[i] will be negative.
@@ -3903,7 +3945,7 @@ The function compares two shapes. All three implemented methods use the Hu invar
@param contour1 First contour or grayscale image.
@param contour2 Second contour or grayscale image.
- at param method Comparison method, see ::ShapeMatchModes
+ at param method Comparison method, see cv::ShapeMatchModes
@param parameter Method-specific parameter (not supported now).
*/
CV_EXPORTS_W double matchShapes( InputArray contour1, InputArray contour2,
@@ -4041,7 +4083,7 @@ CV_EXPORTS_W double pointPolygonTest( InputArray contour, Point2f pt, bool measu
/** @brief Finds out if there is any intersection between two rotated rectangles.
-If there is then the vertices of the interesecting region are returned as well.
+If there is then the vertices of the intersecting region are returned as well.
Below are some examples of intersection configurations. The hatched pattern indicates the
intersecting region and the red vertices are returned by the function.
@@ -4061,14 +4103,20 @@ CV_EXPORTS_W int rotatedRectangleIntersection( const RotatedRect& rect1, const R
CV_EXPORTS_W Ptr<CLAHE> createCLAHE(double clipLimit = 40.0, Size tileGridSize = Size(8, 8));
//! Ballard, D.H. (1981). Generalizing the Hough transform to detect arbitrary shapes. Pattern Recognition 13 (2): 111-122.
-//! Detects position only without traslation and rotation
+//! Detects position only without translation and rotation
CV_EXPORTS Ptr<GeneralizedHoughBallard> createGeneralizedHoughBallard();
//! Guil, N., González-Linares, J.M. and Zapata, E.L. (1999). Bidimensional shape detection using an invariant approach. Pattern Recognition 32 (6): 1025-1038.
-//! Detects position, traslation and rotation
+//! Detects position, translation and rotation
CV_EXPORTS Ptr<GeneralizedHoughGuil> createGeneralizedHoughGuil();
-//! Performs linear blending of two images
+//! Performs linear blending of two images:
+//! \f[ \texttt{dst}(i,j) = \texttt{weights1}(i,j)*\texttt{src1}(i,j) + \texttt{weights2}(i,j)*\texttt{src2}(i,j) \f]
+//! @param src1 It has a type of CV_8UC(n) or CV_32FC(n), where n is a positive integer.
+//! @param src2 It has the same type and size as src1.
+//! @param weights1 It has a type of CV_32FC1 and the same size with src1.
+//! @param weights2 It has a type of CV_32FC1 and the same size with src1.
+//! @param dst It is created if it does not have the same size and type with src1.
CV_EXPORTS void blendLinear(InputArray src1, InputArray src2, InputArray weights1, InputArray weights2, OutputArray dst);
//! @addtogroup imgproc_colormap
@@ -4092,14 +4140,25 @@ enum ColormapTypes
COLORMAP_PARULA = 12 //!< 
};
+/** @example falsecolor.cpp
+An example using applyColorMap function
+*/
/** @brief Applies a GNU Octave/MATLAB equivalent colormap on a given image.
@param src The source image, grayscale or colored of type CV_8UC1 or CV_8UC3.
@param dst The result is the colormapped source image. Note: Mat::create is called on dst.
@param colormap The colormap to apply, see cv::ColormapTypes
- */
+*/
CV_EXPORTS_W void applyColorMap(InputArray src, OutputArray dst, int colormap);
+/** @brief Applies a user colormap on a given image.
+
+ at param src The source image, grayscale or colored of type CV_8UC1 or CV_8UC3.
+ at param dst The result is the colormapped source image. Note: Mat::create is called on dst.
+ at param userColor The colormap to apply of type CV_8UC1 or CV_8UC3 and size 256
+*/
+CV_EXPORTS_W void applyColorMap(InputArray src, OutputArray dst, InputArray userColor);
+
//! @} imgproc_colormap
//! @addtogroup imgproc_draw
@@ -4166,6 +4225,9 @@ CV_EXPORTS void rectangle(CV_IN_OUT Mat& img, Rect rec,
const Scalar& color, int thickness = 1,
int lineType = LINE_8, int shift = 0);
+/** @example Drawing_2.cpp
+An example using drawing functions
+ */
/** @brief Draws a circle.
The function circle draws a simple or filled circle with a given center and radius.
@@ -4184,14 +4246,16 @@ CV_EXPORTS_W void circle(InputOutputArray img, Point center, int radius,
/** @brief Draws a simple or thick elliptic arc or fills an ellipse sector.
-The function cv::ellipse with less parameters draws an ellipse outline, a filled ellipse, an elliptic
-arc, or a filled ellipse sector. A piecewise-linear curve is used to approximate the elliptic arc
+The function cv::ellipse with more parameters draws an ellipse outline, a filled ellipse, an elliptic
+arc, or a filled ellipse sector. The drawing code uses general parametric form.
+A piecewise-linear curve is used to approximate the elliptic arc
boundary. If you need more control of the ellipse rendering, you can retrieve the curve using
-ellipse2Poly and then render it with polylines or fill it with fillPoly . If you use the first
-variant of the function and want to draw the whole ellipse, not an arc, pass startAngle=0 and
-endAngle=360 . The figure below explains the meaning of the parameters.
+cv::ellipse2Poly and then render it with polylines or fill it with cv::fillPoly. If you use the first
+variant of the function and want to draw the whole ellipse, not an arc, pass `startAngle=0` and
+`endAngle=360`. If `startAngle` is greater than `endAngle`, they are swapped. The figure below explains
+the meaning of the parameters to draw the blue arc.
-
+
@param img Image.
@param center Center of the ellipse.
@@ -4287,6 +4351,9 @@ CV_EXPORTS void fillPoly(Mat& img, const Point** pts,
const Scalar& color, int lineType = LINE_8, int shift = 0,
Point offset = Point() );
+/** @example Drawing_1.cpp
+An example using drawing functions
+ */
/** @brief Fills the area bounded by one or more polygons.
The function fillPoly fills an area bounded by several polygonal contours. The function can fill
@@ -4431,7 +4498,7 @@ CV_EXPORTS_W bool clipLine(Rect imgRect, CV_OUT CV_IN_OUT Point& pt1, CV_OUT CV_
/** @brief Approximates an elliptic arc with a polyline.
The function ellipse2Poly computes the vertices of a polyline that approximates the specified
-elliptic arc. It is used by cv::ellipse.
+elliptic arc. It is used by cv::ellipse. If `arcStart` is greater than `arcEnd`, they are swapped.
@param center Center of the arc.
@param axes Half of the size of the ellipse main axes. See the ellipse for details.
diff --git a/modules/imgproc/include/opencv2/imgproc/hal/hal.hpp b/modules/imgproc/include/opencv2/imgproc/hal/hal.hpp
index fc6b9d8..5523df2 100644
--- a/modules/imgproc/include/opencv2/imgproc/hal/hal.hpp
+++ b/modules/imgproc/include/opencv2/imgproc/hal/hal.hpp
@@ -10,53 +10,93 @@ namespace cv { namespace hal {
//! @addtogroup imgproc_hal_functions
//! @{
+//---------------------------
+//! @cond IGNORED
+
struct CV_EXPORTS Filter2D
{
- static Ptr<hal::Filter2D> create(uchar * kernel_data, size_t kernel_step, int kernel_type,
- int kernel_width, int kernel_height,
- int max_width, int max_height,
- int stype, int dtype,
- int borderType, double delta,
- int anchor_x, int anchor_y,
- bool isSubmatrix, bool isInplace);
- virtual void apply(uchar * src_data, size_t src_step,
- uchar * dst_data, size_t dst_step,
- int width, int height,
- int full_width, int full_height,
- int offset_x, int offset_y) = 0;
+ CV_DEPRECATED static Ptr<hal::Filter2D> create(uchar * , size_t , int ,
+ int , int ,
+ int , int ,
+ int , int ,
+ int , double ,
+ int , int ,
+ bool , bool );
+ virtual void apply(uchar * , size_t ,
+ uchar * , size_t ,
+ int , int ,
+ int , int ,
+ int , int ) = 0;
virtual ~Filter2D() {}
};
struct CV_EXPORTS SepFilter2D
{
- static Ptr<hal::SepFilter2D> create(int stype, int dtype, int ktype,
- uchar * kernelx_data, int kernelx_len,
- uchar * kernely_data, int kernely_len,
- int anchor_x, int anchor_y,
- double delta, int borderType);
- virtual void apply(uchar * src_data, size_t src_step,
- uchar * dst_data, size_t dst_step,
- int width, int height,
- int full_width, int full_height,
- int offset_x, int offset_y) = 0;
+ CV_DEPRECATED static Ptr<hal::SepFilter2D> create(int , int , int ,
+ uchar * , int ,
+ uchar * , int ,
+ int , int ,
+ double , int );
+ virtual void apply(uchar * , size_t ,
+ uchar * , size_t ,
+ int , int ,
+ int , int ,
+ int , int ) = 0;
virtual ~SepFilter2D() {}
};
-struct CV_EXPORTS Morph
+struct CV_EXPORTS Morph
{
- static Ptr<Morph> create(int op, int src_type, int dst_type, int max_width, int max_height,
- int kernel_type, uchar * kernel_data, size_t kernel_step,
- int kernel_width, int kernel_height,
- int anchor_x, int anchor_y,
- int borderType, const double borderValue[4],
- int iterations, bool isSubmatrix, bool allowInplace);
- virtual void apply(uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height,
- int roi_width, int roi_height, int roi_x, int roi_y,
- int roi_width2, int roi_height2, int roi_x2, int roi_y2) = 0;
+ CV_DEPRECATED static Ptr<hal::Morph> create(int , int , int , int , int ,
+ int , uchar * , size_t ,
+ int , int ,
+ int , int ,
+ int , const double *,
+ int , bool , bool );
+ virtual void apply(uchar * , size_t , uchar * , size_t , int , int ,
+ int , int , int , int ,
+ int , int , int , int ) = 0;
virtual ~Morph() {}
};
+//! @endcond
+//---------------------------
+
+CV_EXPORTS void filter2D(int stype, int dtype, int kernel_type,
+ uchar * src_data, size_t src_step,
+ uchar * dst_data, size_t dst_step,
+ int width, int height,
+ int full_width, int full_height,
+ int offset_x, int offset_y,
+ uchar * kernel_data, size_t kernel_step,
+ int kernel_width, int kernel_height,
+ int anchor_x, int anchor_y,
+ double delta, int borderType,
+ bool isSubmatrix);
+
+CV_EXPORTS void sepFilter2D(int stype, int dtype, int ktype,
+ uchar * src_data, size_t src_step,
+ uchar * dst_data, size_t dst_step,
+ int width, int height,
+ int full_width, int full_height,
+ int offset_x, int offset_y,
+ uchar * kernelx_data, int kernelx_len,
+ uchar * kernely_data, int kernely_len,
+ int anchor_x, int anchor_y,
+ double delta, int borderType);
+
+CV_EXPORTS void morph(int op, int src_type, int dst_type,
+ uchar * src_data, size_t src_step,
+ uchar * dst_data, size_t dst_step,
+ int width, int height,
+ int roi_width, int roi_height, int roi_x, int roi_y,
+ int roi_width2, int roi_height2, int roi_x2, int roi_y2,
+ int kernel_type, uchar * kernel_data, size_t kernel_step,
+ int kernel_width, int kernel_height, int anchor_x, int anchor_y,
+ int borderType, const double borderValue[4],
+ int iterations, bool isSubmatrix);
+
CV_EXPORTS void resize(int src_type,
const uchar * src_data, size_t src_step, int src_width, int src_height,
diff --git a/modules/imgproc/include/opencv2/imgproc/types_c.h b/modules/imgproc/include/opencv2/imgproc/types_c.h
index eacba02..13ffe1b 100644
--- a/modules/imgproc/include/opencv2/imgproc/types_c.h
+++ b/modules/imgproc/include/opencv2/imgproc/types_c.h
@@ -349,7 +349,17 @@ enum
CV_BayerRG2RGB_EA = CV_BayerBG2BGR_EA,
CV_BayerGR2RGB_EA = CV_BayerGB2BGR_EA,
- CV_COLORCVT_MAX = 139
+ CV_BayerBG2BGRA =139,
+ CV_BayerGB2BGRA =140,
+ CV_BayerRG2BGRA =141,
+ CV_BayerGR2BGRA =142,
+
+ CV_BayerBG2RGBA =CV_BayerRG2BGRA,
+ CV_BayerGB2RGBA =CV_BayerGR2BGRA,
+ CV_BayerRG2RGBA =CV_BayerBG2BGRA,
+ CV_BayerGR2RGBA =CV_BayerGB2BGRA,
+
+ CV_COLORCVT_MAX = 143
};
@@ -491,15 +501,8 @@ enum
CV_POLY_APPROX_DP = 0
};
-/** @brief Shape matching methods
-
-\f$A\f$ denotes object1,\f$B\f$ denotes object2
-
-\f$\begin{array}{l} m^A_i = \mathrm{sign} (h^A_i) \cdot \log{h^A_i} \\ m^B_i = \mathrm{sign} (h^B_i) \cdot \log{h^B_i} \end{array}\f$
-
-and \f$h^A_i, h^B_i\f$ are the Hu moments of \f$A\f$ and \f$B\f$ , respectively.
-*/
-enum ShapeMatchModes
+/** Shape matching methods */
+enum
{
CV_CONTOURS_MATCH_I1 =1, //!< \f[I_1(A,B) = \sum _{i=1...7} \left | \frac{1}{m^A_i} - \frac{1}{m^B_i} \right |\f]
CV_CONTOURS_MATCH_I2 =2, //!< \f[I_2(A,B) = \sum _{i=1...7} \left | m^A_i - m^B_i \right |\f]
diff --git a/modules/imgproc/misc/java/gen_dict.json b/modules/imgproc/misc/java/gen_dict.json
new file mode 100644
index 0000000..e3d4871
--- /dev/null
+++ b/modules/imgproc/misc/java/gen_dict.json
@@ -0,0 +1,134 @@
+{
+ "const_ignore_list": [
+ "CV_TM_.+",
+ "CV_COLORCVT_MAX",
+ "CV_.*Bayer.*",
+ "CV_YUV420(i|sp|p)2.+",
+ "CV_L?(BGRA?|RGBA?|GRAY|XYZ|YCrCb|Luv|Lab|HLS|YUV|HSV)\\d*2L?(BGRA?|RGBA?|GRAY|XYZ|YCrCb|Luv|Lab|HLS|YUV|HSV).*",
+ "CV_FLOODFILL_.+",
+ "CV_ADAPTIVE_THRESH_.+"
+ ],
+ "const_private_list" : [
+ "CV_MOP_.+",
+ "CV_INTER_.+",
+ "CV_THRESH_.+",
+ "CV_INPAINT_.+",
+ "CV_RETR_.+",
+ "CV_CHAIN_APPROX_.+"
+ ],
+ "missing_consts" : {
+ "Imgproc" : {
+ "private" : [
+ ["IPL_BORDER_CONSTANT", 0 ],
+ ["IPL_BORDER_REPLICATE", 1 ],
+ ["IPL_BORDER_REFLECT", 2 ],
+ ["IPL_BORDER_WRAP", 3 ],
+ ["IPL_BORDER_REFLECT_101", 4 ],
+ ["IPL_BORDER_TRANSPARENT", 5 ]
+ ],
+ "public" : [
+ ["LINE_AA", 16], ["LINE_8", 8], ["LINE_4", 4]
+ ]
+ }
+ },
+ "ManualFuncs" : {
+ "Imgproc" : {
+ "getTextSize" : {
+ "j_code" : [
+ "\n",
+ "// C++: Size getTextSize(const String& text, int fontFace, double fontScale, int thickness, int* baseLine);",
+ "//javadoc:getTextSize(text, fontFace, fontScale, thickness, baseLine)",
+ "public static Size getTextSize(String text, int fontFace, double fontScale, int thickness, int[] baseLine) {",
+ " if(baseLine != null && baseLine.length != 1)",
+ " throw new java.lang.IllegalArgumentException(\"'baseLine' must be 'int[1]' or 'null'.\");",
+ " Size retVal = new Size(n_getTextSize(text, fontFace, fontScale, thickness, baseLine));",
+ " return retVal;",
+ "}",
+ "\n"
+ ],
+ "jn_code" : [
+ "private static native double[] n_getTextSize(String text, int fontFace, double fontScale, int thickness, int[] baseLine);\n"
+ ],
+ "cpp_code" : [
+ "\n",
+ " // C++: Size getTextSize(const String& text, int fontFace, double fontScale, int thickness, int* baseLine);",
+ " JNIEXPORT jdoubleArray JNICALL Java_org_opencv_imgproc_Imgproc_n_1getTextSize (JNIEnv*, jclass, jstring, jint, jdouble, jint, jintArray);",
+ "\n",
+ " JNIEXPORT jdoubleArray JNICALL Java_org_opencv_imgproc_Imgproc_n_1getTextSize",
+ " (JNIEnv* env, jclass, jstring text, jint fontFace, jdouble fontScale, jint thickness, jintArray baseLine)",
+ " {",
+ " try {",
+ " LOGD(\"Core::n_1getTextSize()\");",
+ " jdoubleArray result;",
+ " result = env->NewDoubleArray(2);",
+ " if (result == NULL) {",
+ " return NULL; /* out of memory error thrown */",
+ " }",
+ "\n",
+ " const char* utf_text = env->GetStringUTFChars(text, 0);",
+ " String n_text( utf_text ? utf_text : \"\" );",
+ " env->ReleaseStringUTFChars(text, utf_text);",
+ "\n",
+ " int _baseLine;",
+ " int* pbaseLine = 0;",
+ "\n",
+ " if (baseLine != NULL)",
+ " pbaseLine = &_baseLine;",
+ "\n",
+ " cv::Size rsize = cv::getTextSize(n_text, (int)fontFace, (double)fontScale, (int)thickness, pbaseLine);",
+ "\n",
+ " jdouble fill[2];",
+ " fill[0]=rsize.width;",
+ " fill[1]=rsize.height;",
+ "\n",
+ " env->SetDoubleArrayRegion(result, 0, 2, fill);",
+ "\n",
+ " if (baseLine != NULL) {",
+ " jint jbaseLine = (jint)(*pbaseLine);",
+ " env->SetIntArrayRegion(baseLine, 0, 1, &jbaseLine);",
+ " }",
+ "\n",
+ " return result;",
+ "\n",
+ " } catch(const cv::Exception& e) {",
+ " LOGD(\"Imgproc::n_1getTextSize() catched cv::Exception: %s\", e.what());",
+ " jclass je = env->FindClass(\"org/opencv/core/CvException\");",
+ " if(!je) je = env->FindClass(\"java/lang/Exception\");",
+ " env->ThrowNew(je, e.what());",
+ " return NULL;",
+ " } catch (...) {",
+ " LOGD(\"Imgproc::n_1getTextSize() catched unknown exception (...)\");",
+ " jclass je = env->FindClass(\"java/lang/Exception\");",
+ " env->ThrowNew(je, \"Unknown exception in JNI code {core::getTextSize()}\");",
+ " return NULL;",
+ " }",
+ " }"
+ ]
+ }
+ }
+ },
+ "func_arg_fix" : {
+ "goodFeaturesToTrack" : { "corners" : {"ctype" : "vector_Point"} },
+ "minEnclosingCircle" : { "points" : {"ctype" : "vector_Point2f"} },
+ "fitEllipse" : { "points" : {"ctype" : "vector_Point2f"} },
+ "fillPoly" : { "pts" : {"ctype" : "vector_vector_Point"} },
+ "polylines" : { "pts" : {"ctype" : "vector_vector_Point"} },
+ "fillConvexPoly" : { "points" : {"ctype" : "vector_Point"} },
+ "approxPolyDP" : { "curve" : {"ctype" : "vector_Point2f"},
+ "approxCurve" : {"ctype" : "vector_Point2f"} },
+ "arcLength" : { "curve" : {"ctype" : "vector_Point2f"} },
+ "pointPolygonTest" : { "contour" : {"ctype" : "vector_Point2f"} },
+ "minAreaRect" : { "points" : {"ctype" : "vector_Point2f"} },
+ "getAffineTransform" : { "src" : {"ctype" : "vector_Point2f"},
+ "dst" : {"ctype" : "vector_Point2f"} },
+ "drawContours" : {"contours" : {"ctype" : "vector_vector_Point"} },
+ "findContours" : {"contours" : {"ctype" : "vector_vector_Point"} },
+ "convexityDefects" : { "contour" : {"ctype" : "vector_Point"},
+ "convexhull" : {"ctype" : "vector_int"},
+ "convexityDefects" : {"ctype" : "vector_Vec4i"} },
+ "isContourConvex" : { "contour" : {"ctype" : "vector_Point"} },
+ "convexHull" : { "points" : {"ctype" : "vector_Point"},
+ "hull" : {"ctype" : "vector_int"},
+ "returnPoints" : {"ctype" : ""} }
+ }
+}
diff --git a/modules/imgproc/perf/opencl/perf_blend.cpp b/modules/imgproc/perf/opencl/perf_blend.cpp
index 6396fef..661aa06 100644
--- a/modules/imgproc/perf/opencl/perf_blend.cpp
+++ b/modules/imgproc/perf/opencl/perf_blend.cpp
@@ -56,7 +56,7 @@ namespace ocl {
typedef Size_MatType BlendLinearFixture;
-OCL_PERF_TEST_P(BlendLinearFixture, BlendLinear, ::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
+OCL_PERF_TEST_P(BlendLinearFixture, BlendLinear, ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134))
{
Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
diff --git a/modules/imgproc/perf/opencl/perf_imgproc.cpp b/modules/imgproc/perf/opencl/perf_imgproc.cpp
index 6d9b1a0..583f12b 100644
--- a/modules/imgproc/perf/opencl/perf_imgproc.cpp
+++ b/modules/imgproc/perf/opencl/perf_imgproc.cpp
@@ -47,8 +47,6 @@
#include "../perf_precomp.hpp"
#include "opencv2/ts/ocl_perf.hpp"
-#ifdef HAVE_OPENCL
-
namespace cvtest {
namespace ocl {
@@ -318,11 +316,11 @@ OCL_PERF_TEST_P(CannyFixture, Canny, ::testing::Combine(OCL_TEST_SIZES, OCL_PERF
declare.in(img).out(edges);
- OCL_TEST_CYCLE() cv::Canny(img, edges, 50.0, 100.0, apertureSize, L2Grad);
+ PERF_SAMPLE_BEGIN();
+ cv::Canny(img, edges, 50.0, 100.0, apertureSize, L2Grad);
+ PERF_SAMPLE_END();
SANITY_CHECK_NOTHING();
}
} } // namespace cvtest::ocl
-
-#endif // HAVE_OPENCL
diff --git a/modules/imgproc/perf/perf_accumulate.cpp b/modules/imgproc/perf/perf_accumulate.cpp
new file mode 100644
index 0000000..fc3ac7f
--- /dev/null
+++ b/modules/imgproc/perf/perf_accumulate.cpp
@@ -0,0 +1,96 @@
+#include "perf_precomp.hpp"
+
+using namespace std;
+using namespace cv;
+using namespace perf;
+using std::tr1::get;
+
+#ifdef HAVE_OPENVX
+PERF_TEST_P(Size_MatType, Accumulate,
+ testing::Combine(
+ testing::Values(::perf::szODD, ::perf::szQVGA, ::perf::szVGA, ::perf::sz1080p),
+ testing::Values(CV_16SC1, CV_32FC1)
+ )
+)
+#else
+PERF_TEST_P( Size_MatType, Accumulate,
+ testing::Combine(
+ testing::Values(::perf::szODD, ::perf::szQVGA, ::perf::szVGA, ::perf::sz1080p),
+ testing::Values(CV_32FC1)
+ )
+ )
+#endif
+{
+ Size sz = get<0>(GetParam());
+ int dstType = get<1>(GetParam());
+
+ Mat src(sz, CV_8UC1);
+ Mat dst(sz, dstType);
+
+ declare.time(100);
+ declare.in(src, WARMUP_RNG).out(dst);
+
+ TEST_CYCLE() accumulate(src, dst);
+
+ SANITY_CHECK_NOTHING();
+}
+
+#ifdef HAVE_OPENVX
+PERF_TEST_P(Size_MatType, AccumulateSquare,
+ testing::Combine(
+ testing::Values(::perf::szODD, ::perf::szQVGA, ::perf::szVGA, ::perf::sz1080p),
+ testing::Values(CV_16SC1, CV_32FC1)
+ )
+)
+#else
+PERF_TEST_P( Size_MatType, AccumulateSquare,
+ testing::Combine(
+ testing::Values(::perf::szODD, ::perf::szQVGA, ::perf::szVGA, ::perf::sz1080p),
+ testing::Values(CV_32FC1)
+ )
+ )
+#endif
+{
+ Size sz = get<0>(GetParam());
+ int dstType = get<1>(GetParam());
+
+ Mat src(sz, CV_8UC1);
+ Mat dst(sz, dstType);
+
+ declare.time(100);
+ declare.in(src, WARMUP_RNG).out(dst);
+
+ TEST_CYCLE() accumulateSquare(src, dst);
+
+ SANITY_CHECK_NOTHING();
+}
+
+#ifdef HAVE_OPENVX
+PERF_TEST_P(Size_MatType, AccumulateWeighted,
+ testing::Combine(
+ testing::Values(::perf::szODD, ::perf::szQVGA, ::perf::szVGA, ::perf::sz1080p),
+ testing::Values(CV_8UC1, CV_32FC1)
+ )
+)
+#else
+PERF_TEST_P( Size_MatType, AccumulateWeighted,
+ testing::Combine(
+ testing::Values(::perf::szODD, ::perf::szQVGA, ::perf::szVGA, ::perf::sz1080p),
+ testing::Values(CV_32FC1)
+ )
+ )
+#endif
+{
+ Size sz = get<0>(GetParam());
+ int dstType = get<1>(GetParam());
+
+ Mat src(sz, CV_8UC1);
+ Mat dst(sz, dstType);
+
+ declare.time(100);
+ declare.in(src, WARMUP_RNG).out(dst);
+
+ TEST_CYCLE() accumulateWeighted(src, dst, 0.314);
+
+ SANITY_CHECK_NOTHING();
+}
diff --git a/modules/imgproc/perf/perf_canny.cpp b/modules/imgproc/perf/perf_canny.cpp
index 2046556..3a25ff2 100644
--- a/modules/imgproc/perf/perf_canny.cpp
+++ b/modules/imgproc/perf/perf_canny.cpp
@@ -31,7 +31,9 @@ PERF_TEST_P(Img_Aperture_L2_thresholds, canny,
declare.in(img).out(edges);
- TEST_CYCLE() Canny(img, edges, thresh_low, thresh_high, aperture, useL2);
+ PERF_SAMPLE_BEGIN();
+ Canny(img, edges, thresh_low, thresh_high, aperture, useL2);
+ PERF_SAMPLE_END();
SANITY_CHECK(edges);
}
diff --git a/modules/imgproc/perf/perf_cvt_color.cpp b/modules/imgproc/perf/perf_cvt_color.cpp
index fc9a2cd..9bc2b89 100644
--- a/modules/imgproc/perf/perf_cvt_color.cpp
+++ b/modules/imgproc/perf/perf_cvt_color.cpp
@@ -103,10 +103,10 @@ CV_ENUM(CvtMode,
CV_ENUM(CvtModeBayer,
- COLOR_BayerBG2BGR, COLOR_BayerBG2BGR_VNG, COLOR_BayerBG2GRAY,
- COLOR_BayerGB2BGR, COLOR_BayerGB2BGR_VNG, COLOR_BayerGB2GRAY,
- COLOR_BayerGR2BGR, COLOR_BayerGR2BGR_VNG, COLOR_BayerGR2GRAY,
- COLOR_BayerRG2BGR, COLOR_BayerRG2BGR_VNG, COLOR_BayerRG2GRAY
+ COLOR_BayerBG2BGR, COLOR_BayerBG2BGRA, COLOR_BayerBG2BGR_VNG, COLOR_BayerBG2GRAY,
+ COLOR_BayerGB2BGR, COLOR_BayerGB2BGRA, COLOR_BayerGB2BGR_VNG, COLOR_BayerGB2GRAY,
+ COLOR_BayerGR2BGR, COLOR_BayerGR2BGRA, COLOR_BayerGR2BGR_VNG, COLOR_BayerGR2GRAY,
+ COLOR_BayerRG2BGR, COLOR_BayerRG2BGRA, COLOR_BayerRG2BGR_VNG, COLOR_BayerRG2GRAY
)
@@ -149,6 +149,8 @@ ChPair getConversionInfo(int cvtMode)
case COLOR_YUV2BGRA_NV21: case COLOR_YUV2RGBA_NV21:
case COLOR_YUV2BGRA_YV12: case COLOR_YUV2RGBA_YV12:
case COLOR_YUV2BGRA_IYUV: case COLOR_YUV2RGBA_IYUV:
+ case COLOR_BayerBG2BGRA: case COLOR_BayerGB2BGRA:
+ case COLOR_BayerGR2BGRA: case COLOR_BayerRG2BGRA:
return ChPair(1,4);
case COLOR_BGR5552GRAY: case COLOR_BGR5652GRAY:
return ChPair(2,1);
diff --git a/modules/imgproc/perf/perf_filter2d.cpp b/modules/imgproc/perf/perf_filter2d.cpp
index 1eec745..44c8d32 100644
--- a/modules/imgproc/perf/perf_filter2d.cpp
+++ b/modules/imgproc/perf/perf_filter2d.cpp
@@ -42,6 +42,33 @@ PERF_TEST_P( TestFilter2d, Filter2d,
SANITY_CHECK(dst, 1);
}
+PERF_TEST_P(TestFilter2d, Filter2d_ovx,
+ Combine(
+ Values(Size(320, 240), sz1080p),
+ Values(3, 5),
+ Values(BORDER_CONSTANT, BORDER_REPLICATE)
+ )
+)
+{
+ Size sz;
+ int borderMode, kSize;
+ sz = get<0>(GetParam());
+ kSize = get<1>(GetParam());
+ borderMode = get<2>(GetParam());
+
+ Mat src(sz, CV_8UC1);
+ Mat dst(sz, CV_16SC1);
+
+ Mat kernel(kSize, kSize, CV_16SC1);
+ randu(kernel, -3, 10);
+
+ declare.in(src, WARMUP_RNG).out(dst).time(20);
+
+ TEST_CYCLE() filter2D(src, dst, CV_16SC1, kernel, Point(kSize / 2, kSize / 2), 0., borderMode);
+
+ SANITY_CHECK(dst, 1);
+}
+
PERF_TEST_P( Image_KernelSize, GaborFilter2d,
Combine(
Values("stitching/a1.png", "cv/shared/pic5.png"),
diff --git a/modules/imgproc/perf/perf_pyramids.cpp b/modules/imgproc/perf/perf_pyramids.cpp
index e23af8e..6b5b759 100644
--- a/modules/imgproc/perf/perf_pyramids.cpp
+++ b/modules/imgproc/perf/perf_pyramids.cpp
@@ -27,6 +27,27 @@ PERF_TEST_P(Size_MatType, pyrDown, testing::Combine(
SANITY_CHECK(dst, eps, error_type);
}
+PERF_TEST_P(Size_MatType, pyrDown_ovx, testing::Combine(
+ testing::Values(sz1080p, sz720p, szVGA, szQVGA, szODD),
+ testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16SC1, CV_16SC3, CV_16SC4, CV_32FC1, CV_32FC3, CV_32FC4)
+)
+)
+{
+ Size sz = get<0>(GetParam());
+ int matType = get<1>(GetParam());
+ const double eps = CV_MAT_DEPTH(matType) <= CV_32S ? 1 : 1e-5;
+ perf::ERROR_TYPE error_type = CV_MAT_DEPTH(matType) <= CV_32S ? ERROR_ABSOLUTE : ERROR_RELATIVE;
+
+ Mat src(sz, matType);
+ Mat dst((sz.height + 1) / 2, (sz.width + 1) / 2, matType);
+
+ declare.in(src, WARMUP_RNG).out(dst);
+
+ TEST_CYCLE() pyrDown(src, dst, cv::Size(), BORDER_REPLICATE);
+
+ SANITY_CHECK(dst, eps, error_type);
+}
+
PERF_TEST_P(Size_MatType, pyrUp, testing::Combine(
testing::Values(sz720p, szVGA, szQVGA, szODD),
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16SC1, CV_16SC3, CV_16SC4, CV_32FC1, CV_32FC3, CV_32FC4)
diff --git a/modules/imgproc/perf/perf_resize.cpp b/modules/imgproc/perf/perf_resize.cpp
index 2212880..7811193 100644
--- a/modules/imgproc/perf/perf_resize.cpp
+++ b/modules/imgproc/perf/perf_resize.cpp
@@ -27,7 +27,7 @@ PERF_TEST_P(MatInfo_Size_Size, resizeUpLinear,
TEST_CYCLE_MULTIRUN(10) resize(src, dst, to);
-#ifdef ANDROID
+#ifdef __ANDROID__
SANITY_CHECK(dst, 5);
#else
SANITY_CHECK(dst, 1 + 1e-6);
@@ -54,7 +54,7 @@ PERF_TEST_P(MatInfo_Size_Size, resizeDownLinear,
TEST_CYCLE_MULTIRUN(10) resize(src, dst, to);
-#ifdef ANDROID
+#ifdef __ANDROID__
SANITY_CHECK(dst, 5);
#else
SANITY_CHECK(dst, 1 + 1e-6);
diff --git a/modules/imgproc/perf/perf_warp.cpp b/modules/imgproc/perf/perf_warp.cpp
index 146528b..f03e64b 100644
--- a/modules/imgproc/perf/perf_warp.cpp
+++ b/modules/imgproc/perf/perf_warp.cpp
@@ -43,13 +43,43 @@ PERF_TEST_P( TestWarpAffine, WarpAffine,
TEST_CYCLE() warpAffine( src, dst, warpMat, sz, interType, borderMode, borderColor );
-#ifdef ANDROID
+#ifdef __ANDROID__
SANITY_CHECK(dst, interType==INTER_LINEAR? 5 : 10);
#else
SANITY_CHECK(dst, 1);
#endif
}
+PERF_TEST_P(TestWarpAffine, WarpAffine_ovx,
+ Combine(
+ Values(szVGA, sz720p, sz1080p),
+ InterType::all(),
+ BorderMode::all()
+ )
+)
+{
+ Size sz, szSrc(512, 512);
+ int borderMode, interType;
+ sz = get<0>(GetParam());
+ interType = get<1>(GetParam());
+ borderMode = get<2>(GetParam());
+ Scalar borderColor = Scalar::all(150);
+
+ Mat src(szSrc, CV_8UC1), dst(sz, CV_8UC1);
+ cvtest::fillGradient(src);
+ if (borderMode == BORDER_CONSTANT) cvtest::smoothBorder(src, borderColor, 1);
+ Mat warpMat = getRotationMatrix2D(Point2f(src.cols / 2.f, src.rows / 2.f), 30., 2.2);
+ declare.in(src).out(dst);
+
+ TEST_CYCLE() warpAffine(src, dst, warpMat, sz, interType, borderMode, borderColor);
+
+#ifdef __ANDROID__
+ SANITY_CHECK(dst, interType == INTER_LINEAR ? 5 : 10);
+#else
+ SANITY_CHECK(dst, 1);
+#endif
+}
+
PERF_TEST_P( TestWarpPerspective, WarpPerspective,
Combine(
Values( szVGA, sz720p, sz1080p ),
@@ -81,13 +111,51 @@ PERF_TEST_P( TestWarpPerspective, WarpPerspective,
TEST_CYCLE() warpPerspective( src, dst, warpMat, sz, interType, borderMode, borderColor );
-#ifdef ANDROID
+#ifdef __ANDROID__
SANITY_CHECK(dst, interType==INTER_LINEAR? 5 : 10);
#else
SANITY_CHECK(dst, 1);
#endif
}
+PERF_TEST_P(TestWarpPerspective, WarpPerspective_ovx,
+ Combine(
+ Values(szVGA, sz720p, sz1080p),
+ InterType::all(),
+ BorderMode::all()
+ )
+)
+{
+ Size sz, szSrc(512, 512);
+ int borderMode, interType;
+ sz = get<0>(GetParam());
+ interType = get<1>(GetParam());
+ borderMode = get<2>(GetParam());
+ Scalar borderColor = Scalar::all(150);
+
+ Mat src(szSrc, CV_8UC1), dst(sz, CV_8UC1);
+ cvtest::fillGradient(src);
+ if (borderMode == BORDER_CONSTANT) cvtest::smoothBorder(src, borderColor, 1);
+ Mat rotMat = getRotationMatrix2D(Point2f(src.cols / 2.f, src.rows / 2.f), 30., 2.2);
+ Mat warpMat(3, 3, CV_64FC1);
+ for (int r = 0; r<2; r++)
+ for (int c = 0; c<3; c++)
+ warpMat.at<double>(r, c) = rotMat.at<double>(r, c);
+ warpMat.at<double>(2, 0) = .3 / sz.width;
+ warpMat.at<double>(2, 1) = .3 / sz.height;
+ warpMat.at<double>(2, 2) = 1;
+
+ declare.in(src).out(dst);
+
+ TEST_CYCLE() warpPerspective(src, dst, warpMat, sz, interType, borderMode, borderColor);
+
+#ifdef __ANDROID__
+ SANITY_CHECK(dst, interType == INTER_LINEAR ? 5 : 10);
+#else
+ SANITY_CHECK(dst, 1);
+#endif
+}
+
PERF_TEST_P( TestWarpPerspectiveNear_t, WarpPerspectiveNear,
Combine(
Values( Size(640,480), Size(1920,1080), Size(2592,1944) ),
@@ -127,7 +195,7 @@ PERF_TEST_P( TestWarpPerspectiveNear_t, WarpPerspectiveNear,
warpPerspective( src, dst, warpMat, size, interType, borderMode, borderColor );
}
-#ifdef ANDROID
+#ifdef __ANDROID__
SANITY_CHECK(dst, interType==INTER_LINEAR? 5 : 10);
#else
SANITY_CHECK(dst, 1);
diff --git a/modules/imgproc/src/accum.cpp b/modules/imgproc/src/accum.cpp
index 8c457e3..2b43f4e 100644
--- a/modules/imgproc/src/accum.cpp
+++ b/modules/imgproc/src/accum.cpp
@@ -44,1718 +44,17 @@
#include "precomp.hpp"
#include "opencl_kernels_imgproc.hpp"
#include "opencv2/core/hal/intrin.hpp"
+#define CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
+#include "accum.simd.hpp"
+#include "accum.simd_declarations.hpp"
+#include "opencv2/core/openvx/ovx_defs.hpp"
-#include "opencv2/core/openvx/ovx_defs.hpp"
-
-namespace cv
-{
-
-template <typename T, typename AT>
-struct Acc_SIMD
-{
- int operator() (const T *, AT *, const uchar *, int, int) const
- {
- return 0;
- }
-};
-
-template <typename T, typename AT>
-struct AccSqr_SIMD
-{
- int operator() (const T *, AT *, const uchar *, int, int) const
- {
- return 0;
- }
-};
-
-template <typename T, typename AT>
-struct AccProd_SIMD
-{
- int operator() (const T *, const T *, AT *, const uchar *, int, int) const
- {
- return 0;
- }
-};
-
-template <typename T, typename AT>
-struct AccW_SIMD
-{
- int operator() (const T *, AT *, const uchar *, int, int, AT) const
- {
- return 0;
- }
-};
-
-#if CV_AVX
-template <>
-struct Acc_SIMD<float, float>
-{
- int operator() (const float * src, float * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 8 ; x += 8)
- {
- __m256 v_src = _mm256_loadu_ps(src + x);
- __m256 v_dst = _mm256_loadu_ps(dst + x);
- v_dst = _mm256_add_ps(v_src, v_dst);
- _mm256_storeu_ps(dst + x, v_dst);
- }
- }
- return x;
- }
-};
-
-template <>
-struct Acc_SIMD<float, double>
-{
- int operator() (const float * src, double * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 8 ; x += 8)
- {
- __m256 v_src = _mm256_loadu_ps(src + x);
- __m256d v_src0 = _mm256_cvtps_pd(_mm256_extractf128_ps(v_src,0));
- __m256d v_src1 = _mm256_cvtps_pd(_mm256_extractf128_ps(v_src,1));
- __m256d v_dst0 = _mm256_loadu_pd(dst + x);
- __m256d v_dst1 = _mm256_loadu_pd(dst + x + 4);
- v_dst0 = _mm256_add_pd(v_src0, v_dst0);
- v_dst1 = _mm256_add_pd(v_src1, v_dst1);
- _mm256_storeu_pd(dst + x, v_dst0);
- _mm256_storeu_pd(dst + x + 4, v_dst1);
- }
- }
- return x;
- }
-};
-
-template <>
-struct Acc_SIMD<double, double>
-{
- int operator() (const double * src, double * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 4; x += 4)
- {
- __m256d v_src = _mm256_loadu_pd(src + x);
- __m256d v_dst = _mm256_loadu_pd(dst + x);
-
- v_dst = _mm256_add_pd(v_dst, v_src);
- _mm256_storeu_pd(dst + x, v_dst);
- }
- }
- return x;
- }
-};
-
-template <>
-struct AccSqr_SIMD<float, float>
-{
- int operator() (const float * src, float * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 8 ; x += 8)
- {
- __m256 v_src = _mm256_loadu_ps(src + x);
- __m256 v_dst = _mm256_loadu_ps(dst + x);
-
- v_src = _mm256_mul_ps(v_src, v_src);
- v_dst = _mm256_add_ps(v_src, v_dst);
- _mm256_storeu_ps(dst + x, v_dst);
- }
- }
- return x;
- }
-};
-
-template <>
-struct AccSqr_SIMD<float, double>
-{
- int operator() (const float * src, double * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 8 ; x += 8)
- {
- __m256 v_src = _mm256_loadu_ps(src + x);
- __m256d v_src0 = _mm256_cvtps_pd(_mm256_extractf128_ps(v_src,0));
- __m256d v_src1 = _mm256_cvtps_pd(_mm256_extractf128_ps(v_src,1));
- __m256d v_dst0 = _mm256_loadu_pd(dst + x);
- __m256d v_dst1 = _mm256_loadu_pd(dst + x + 4);
-
- v_src0 = _mm256_mul_pd(v_src0, v_src0);
- v_src1 = _mm256_mul_pd(v_src1, v_src1);
- v_dst0 = _mm256_add_pd(v_src0, v_dst0);
- v_dst1 = _mm256_add_pd(v_src1, v_dst1);
- _mm256_storeu_pd(dst + x, v_dst0);
- _mm256_storeu_pd(dst + x + 4, v_dst1);
- }
- }
- return x;
- }
-};
-
-template <>
-struct AccSqr_SIMD<double, double>
-{
- int operator() (const double * src, double * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 4; x += 4)
- {
- __m256d v_src = _mm256_loadu_pd(src + x);
- __m256d v_dst = _mm256_loadu_pd(dst + x);
-
- v_src = _mm256_mul_pd(v_src, v_src);
- v_dst = _mm256_add_pd(v_dst, v_src);
- _mm256_storeu_pd(dst + x, v_dst);
- }
- }
- return x;
- }
-};
-
-template <>
-struct AccProd_SIMD<float, float>
-{
- int operator() (const float * src1, const float * src2, float * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 8; x += 8)
- {
- __m256 v_src0 = _mm256_loadu_ps(src1 + x);
- __m256 v_src1 = _mm256_loadu_ps(src2 + x);
- __m256 v_dst = _mm256_loadu_ps(dst + x);
- __m256 v_src = _mm256_mul_ps(v_src0, v_src1);
-
- v_dst = _mm256_add_ps(v_src, v_dst);
- _mm256_storeu_ps(dst + x, v_dst);
- }
- }
-
- return x;
- }
-};
-
-template <>
-struct AccProd_SIMD<float, double>
-{
- int operator() (const float * src1, const float * src2, double * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 8; x += 8)
- {
- __m256 v_1src = _mm256_loadu_ps(src1 + x);
- __m256 v_2src = _mm256_loadu_ps(src2 + x);
- __m256d v_src00 = _mm256_cvtps_pd(_mm256_extractf128_ps(v_1src,0));
- __m256d v_src01 = _mm256_cvtps_pd(_mm256_extractf128_ps(v_1src,1));
- __m256d v_src10 = _mm256_cvtps_pd(_mm256_extractf128_ps(v_2src,0));
- __m256d v_src11 = _mm256_cvtps_pd(_mm256_extractf128_ps(v_2src,1));
- __m256d v_dst0 = _mm256_loadu_pd(dst + x);
- __m256d v_dst1 = _mm256_loadu_pd(dst + x + 4);
-
- __m256d v_src0 = _mm256_mul_pd(v_src00, v_src10);
- __m256d v_src1 = _mm256_mul_pd(v_src01, v_src11);
- v_dst0 = _mm256_add_pd(v_src0, v_dst0);
- v_dst1 = _mm256_add_pd(v_src1, v_dst1);
- _mm256_storeu_pd(dst + x, v_dst0);
- _mm256_storeu_pd(dst + x + 4, v_dst1);
- }
- }
- return x;
- }
-};
-
-template <>
-struct AccProd_SIMD<double, double>
-{
- int operator() (const double * src1, const double * src2, double * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 4; x += 4)
- {
- __m256d v_src0 = _mm256_loadu_pd(src1 + x);
- __m256d v_src1 = _mm256_loadu_pd(src2 + x);
- __m256d v_dst = _mm256_loadu_pd(dst + x);
-
- v_src0 = _mm256_mul_pd(v_src0, v_src1);
- v_dst = _mm256_add_pd(v_dst, v_src0);
- _mm256_storeu_pd(dst + x, v_dst);
- }
- }
- return x;
- }
-};
-
-template <>
-struct AccW_SIMD<float, float>
-{
- int operator() (const float * src, float * dst, const uchar * mask, int len, int cn, float alpha) const
- {
- int x = 0;
- __m256 v_alpha = _mm256_set1_ps(alpha);
- __m256 v_beta = _mm256_set1_ps(1.0f - alpha);
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 16; x += 16)
- {
- _mm256_storeu_ps(dst + x, _mm256_add_ps(_mm256_mul_ps(_mm256_loadu_ps(dst + x), v_beta), _mm256_mul_ps(_mm256_loadu_ps(src + x), v_alpha)));
- _mm256_storeu_ps(dst + x + 8, _mm256_add_ps(_mm256_mul_ps(_mm256_loadu_ps(dst + x + 8), v_beta), _mm256_mul_ps(_mm256_loadu_ps(src + x + 8), v_alpha)));
- }
- }
-
- return x;
- }
-};
-
-template <>
-struct AccW_SIMD<float, double>
-{
- int operator() (const float * src, double * dst, const uchar * mask, int len, int cn, double alpha) const
- {
- int x = 0;
- __m256d v_alpha = _mm256_set1_pd(alpha);
- __m256d v_beta = _mm256_set1_pd(1.0f - alpha);
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 16; x += 16)
- {
- __m256 v_src0 = _mm256_loadu_ps(src + x);
- __m256 v_src1 = _mm256_loadu_ps(src + x + 8);
- __m256d v_src00 = _mm256_cvtps_pd(_mm256_extractf128_ps(v_src0,0));
- __m256d v_src01 = _mm256_cvtps_pd(_mm256_extractf128_ps(v_src0,1));
- __m256d v_src10 = _mm256_cvtps_pd(_mm256_extractf128_ps(v_src1,0));
- __m256d v_src11 = _mm256_cvtps_pd(_mm256_extractf128_ps(v_src1,1));
-
- _mm256_storeu_pd(dst + x, _mm256_add_pd(_mm256_mul_pd(_mm256_loadu_pd(dst + x), v_beta), _mm256_mul_pd(v_src00, v_alpha)));
- _mm256_storeu_pd(dst + x + 4, _mm256_add_pd(_mm256_mul_pd(_mm256_loadu_pd(dst + x + 4), v_beta), _mm256_mul_pd(v_src01, v_alpha)));
- _mm256_storeu_pd(dst + x + 8, _mm256_add_pd(_mm256_mul_pd(_mm256_loadu_pd(dst + x + 8), v_beta), _mm256_mul_pd(v_src10, v_alpha)));
- _mm256_storeu_pd(dst + x + 12, _mm256_add_pd(_mm256_mul_pd(_mm256_loadu_pd(dst + x + 12), v_beta), _mm256_mul_pd(v_src11, v_alpha)));
- }
- }
-
- return x;
- }
-};
-
-template <>
-struct AccW_SIMD<double, double>
-{
- int operator() (const double * src, double * dst, const uchar * mask, int len, int cn, double alpha) const
- {
- int x = 0;
- __m256d v_alpha = _mm256_set1_pd(alpha);
- __m256d v_beta = _mm256_set1_pd(1.0f - alpha);
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 8; x += 8)
- {
- __m256d v_src0 = _mm256_loadu_pd(src + x);
- __m256d v_src1 = _mm256_loadu_pd(src + x + 4);
-
- _mm256_storeu_pd(dst + x, _mm256_add_pd(_mm256_mul_pd(_mm256_loadu_pd(dst + x), v_beta), _mm256_mul_pd(v_src0, v_alpha)));
- _mm256_storeu_pd(dst + x + 4, _mm256_add_pd(_mm256_mul_pd(_mm256_loadu_pd(dst + x + 4), v_beta), _mm256_mul_pd(v_src1, v_alpha)));
- }
- }
-
- return x;
- }
-};
-#elif CV_SIMD128
-template <>
-struct Acc_SIMD<float, float>
-{
- int operator() (const float * src, float * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 8; x += 8)
- {
- v_store(dst + x, v_load(dst + x) + v_load(src + x));
- v_store(dst + x + 4, v_load(dst + x + 4) + v_load(src + x + 4));
- }
- }
-
- return x;
- }
-};
-
-#if CV_SIMD128_64F
-template <>
-struct Acc_SIMD<float, double>
-{
- int operator() (const float * src, double * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 4; x += 4)
- {
- v_float32x4 v_src = v_load(src + x);
- v_float64x2 v_src0 = v_cvt_f64(v_src);
- v_float64x2 v_src1 = v_cvt_f64_high(v_src);
-
- v_store(dst + x, v_load(dst + x) + v_src0);
- v_store(dst + x + 2, v_load(dst + x + 2) + v_src1);
- }
- }
- return x;
- }
-};
-
-template <>
-struct Acc_SIMD<double, double>
-{
- int operator() (const double * src, double * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 4; x += 4)
- {
- v_float64x2 v_src0 = v_load(src + x);
- v_float64x2 v_src1 = v_load(src + x + 2);
-
- v_store(dst + x, v_load(dst + x) + v_src0);
- v_store(dst + x + 2, v_load(dst + x + 2) + v_src1);
- }
- }
- return x;
- }
-};
-#endif //CV_SIMD128_64F
-
-template <>
-struct AccSqr_SIMD<float, float>
-{
- int operator() (const float * src, float * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 8; x += 8)
- {
- v_float32x4 v_src0 = v_load(src + x);
- v_float32x4 v_src1 = v_load(src + x + 4);
- v_src0 = v_src0 * v_src0;
- v_src1 = v_src1 * v_src1;
-
- v_store(dst + x, v_load(dst + x) + v_src0);
- v_store(dst + x + 4, v_load(dst + x + 4) + v_src1);
- }
- }
-
- return x;
- }
-};
-
-#if CV_SIMD128_64F
-template <>
-struct AccSqr_SIMD<float, double>
-{
- int operator() (const float * src, double * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 4; x += 4)
- {
- v_float32x4 v_src = v_load(src + x);
- v_float64x2 v_src0 = v_cvt_f64(v_src);
- v_float64x2 v_src1 = v_cvt_f64_high(v_src);
- v_src0 = v_src0 * v_src0;
- v_src1 = v_src1 * v_src1;
-
- v_store(dst + x, v_load(dst + x) + v_src0);
- v_store(dst + x + 2, v_load(dst + x + 2) + v_src1);
- }
- }
- return x;
- }
-};
-
-template <>
-struct AccSqr_SIMD<double, double>
-{
- int operator() (const double * src, double * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 4; x += 4)
- {
- v_float64x2 v_src0 = v_load(src + x);
- v_float64x2 v_src1 = v_load(src + x + 2);
- v_src0 = v_src0 * v_src0;
- v_src1 = v_src1 * v_src1;
-
- v_store(dst + x, v_load(dst + x) + v_src0);
- v_store(dst + x + 2, v_load(dst + x + 2) + v_src1);
- }
- }
- return x;
- }
-};
-#endif //CV_SIMD128_64F
-
-template <>
-struct AccProd_SIMD<float, float>
-{
- int operator() (const float * src1, const float * src2, float * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 8; x += 8)
- {
- v_store(dst + x, v_load(dst + x) + v_load(src1 + x) * v_load(src2 + x));
- v_store(dst + x + 4, v_load(dst + x + 4) + v_load(src1 + x + 4) * v_load(src2 + x + 4));
- }
- }
-
- return x;
- }
-};
-
-#if CV_SIMD128_64F
-template <>
-struct AccProd_SIMD<float, double>
-{
- int operator() (const float * src1, const float * src2, double * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 4; x += 4)
- {
- v_float32x4 v_1src = v_load(src1 + x);
- v_float32x4 v_2src = v_load(src2 + x);
-
- v_float64x2 v_1src0 = v_cvt_f64(v_1src);
- v_float64x2 v_1src1 = v_cvt_f64_high(v_1src);
- v_float64x2 v_2src0 = v_cvt_f64(v_2src);
- v_float64x2 v_2src1 = v_cvt_f64_high(v_2src);
-
- v_store(dst + x, v_load(dst + x) + (v_1src0 * v_2src0));
- v_store(dst + x + 2, v_load(dst + x + 2) + (v_1src1 * v_2src1));
- }
- }
- return x;
- }
-};
-
-template <>
-struct AccProd_SIMD<double, double>
-{
- int operator() (const double * src1, const double * src2, double * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 4; x += 4)
- {
- v_float64x2 v_src00 = v_load(src1 + x);
- v_float64x2 v_src01 = v_load(src1 + x + 2);
- v_float64x2 v_src10 = v_load(src2 + x);
- v_float64x2 v_src11 = v_load(src2 + x + 2);
-
- v_store(dst + x, v_load(dst + x) + (v_src00 * v_src10));
- v_store(dst + x + 2, v_load(dst + x + 2) + (v_src01 * v_src11));
- }
- }
- return x;
- }
-};
-#endif //CV_SIMD128_64F
-
-template <>
-struct AccW_SIMD<float, float>
-{
- int operator() (const float * src, float * dst, const uchar * mask, int len, int cn, float alpha) const
- {
- int x = 0;
- v_float32x4 v_alpha = v_setall_f32(alpha);
- v_float32x4 v_beta = v_setall_f32(1.0f - alpha);
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 8; x += 8)
- {
- v_store(dst + x, ((v_load(dst + x) * v_beta) + (v_load(src + x) * v_alpha)));
- v_store(dst + x + 4, ((v_load(dst + x + 4) * v_beta) + (v_load(src + x + 4) * v_alpha)));
- }
- }
-
- return x;
- }
-};
-
-#if CV_SIMD128_64F
-template <>
-struct AccW_SIMD<float, double>
-{
- int operator() (const float * src, double * dst, const uchar * mask, int len, int cn, double alpha) const
- {
- int x = 0;
- v_float64x2 v_alpha = v_setall_f64(alpha);
- v_float64x2 v_beta = v_setall_f64(1.0f - alpha);
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 8; x += 8)
- {
- v_float32x4 v_src0 = v_load(src + x);
- v_float32x4 v_src1 = v_load(src + x + 4);
- v_float64x2 v_src00 = v_cvt_f64(v_src0);
- v_float64x2 v_src01 = v_cvt_f64_high(v_src0);
- v_float64x2 v_src10 = v_cvt_f64(v_src1);
- v_float64x2 v_src11 = v_cvt_f64_high(v_src1);
-
- v_store(dst + x, ((v_load(dst + x) * v_beta) + (v_src00 * v_alpha)));
- v_store(dst + x + 2, ((v_load(dst + x + 2) * v_beta) + (v_src01 * v_alpha)));
- v_store(dst + x + 4, ((v_load(dst + x + 4) * v_beta) + (v_src10 * v_alpha)));
- v_store(dst + x + 6, ((v_load(dst + x + 6) * v_beta) + (v_src11 * v_alpha)));
- }
- }
-
- return x;
- }
-};
-
-template <>
-struct AccW_SIMD<double, double>
-{
- int operator() (const double * src, double * dst, const uchar * mask, int len, int cn, double alpha) const
- {
- int x = 0;
- v_float64x2 v_alpha = v_setall_f64(alpha);
- v_float64x2 v_beta = v_setall_f64(1.0f - alpha);
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 4; x += 4)
- {
- v_float64x2 v_src0 = v_load(src + x);
- v_float64x2 v_src1 = v_load(src + x + 2);
-
- v_store(dst + x, ((v_load(dst + x) * v_beta) + (v_src0 * v_alpha)));
- v_store(dst + x + 2, ((v_load(dst + x + 2) * v_beta) + (v_src1 * v_alpha)));
- }
- }
-
- return x;
- }
-};
-#endif //CV_SIMD128_64F
-#endif //CV_SIMD128
-
-#if CV_SIMD128
-template <>
-struct Acc_SIMD<uchar, float>
-{
- int operator() (const uchar * src, float * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 16; x += 16)
- {
- v_uint8x16 v_src = v_load(src + x);
- v_uint16x8 v_src0, v_src1;
- v_expand(v_src, v_src0, v_src1);
-
- v_uint32x4 v_src00, v_src01, v_src10, v_src11;
- v_expand(v_src0, v_src00, v_src01);
- v_expand(v_src1, v_src10, v_src11);
-
- v_store(dst + x, v_load(dst + x) + v_cvt_f32(v_reinterpret_as_s32(v_src00)));
- v_store(dst + x + 4, v_load(dst + x + 4) + v_cvt_f32(v_reinterpret_as_s32(v_src01)));
- v_store(dst + x + 8, v_load(dst + x + 8) + v_cvt_f32(v_reinterpret_as_s32(v_src10)));
- v_store(dst + x + 12, v_load(dst + x + 12) + v_cvt_f32(v_reinterpret_as_s32(v_src11)));
- }
- }
- else if (cn == 1)
- {
- v_uint8x16 v_0 = v_setall_u8(0);
-
- for ( ; x <= len - 16; x += 16)
- {
- v_uint8x16 v_mask = v_load(mask + x);
- v_mask = ~(v_0 == v_mask);
- v_uint8x16 v_src = v_load(src + x);
- v_src = v_src & v_mask;
- v_uint16x8 v_src0, v_src1;
- v_expand(v_src, v_src0, v_src1);
-
- v_uint32x4 v_src00, v_src01, v_src10, v_src11;
- v_expand(v_src0, v_src00, v_src01);
- v_expand(v_src1, v_src10, v_src11);
-
- v_store(dst + x, v_load(dst + x) + v_cvt_f32(v_reinterpret_as_s32(v_src00)));
- v_store(dst + x + 4, v_load(dst + x + 4) + v_cvt_f32(v_reinterpret_as_s32(v_src01)));
- v_store(dst + x + 8, v_load(dst + x + 8) + v_cvt_f32(v_reinterpret_as_s32(v_src10)));
- v_store(dst + x + 12, v_load(dst + x + 12) + v_cvt_f32(v_reinterpret_as_s32(v_src11)));
- }
- }
-
- return x;
- }
-};
-
-template <>
-struct Acc_SIMD<ushort, float>
-{
- int operator() (const ushort * src, float * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 8; x += 8)
- {
- v_uint16x8 v_src = v_load(src + x);
- v_uint32x4 v_src0, v_src1;
- v_expand(v_src, v_src0, v_src1);
-
- v_store(dst + x, v_load(dst + x) + v_cvt_f32(v_reinterpret_as_s32(v_src0)));
- v_store(dst + x + 4, v_load(dst + x + 4) + v_cvt_f32(v_reinterpret_as_s32(v_src1)));
- }
- }
-
- return x;
- }
-};
-
-#if CV_SIMD128_64F
-template <>
-struct Acc_SIMD<uchar, double>
-{
- int operator() (const uchar * src, double * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 16; x += 16)
- {
- v_uint8x16 v_src = v_load(src + x);
- v_uint16x8 v_int0, v_int1;
- v_expand(v_src, v_int0, v_int1);
-
- v_uint32x4 v_int00, v_int01, v_int10, v_int11;
- v_expand(v_int0, v_int00, v_int01);
- v_expand(v_int1, v_int10, v_int11);
-
- v_float64x2 v_src0 = v_cvt_f64(v_reinterpret_as_s32(v_int00));
- v_float64x2 v_src1 = v_cvt_f64_high(v_reinterpret_as_s32(v_int00));
- v_float64x2 v_src2 = v_cvt_f64(v_reinterpret_as_s32(v_int01));
- v_float64x2 v_src3 = v_cvt_f64_high(v_reinterpret_as_s32(v_int01));
- v_float64x2 v_src4 = v_cvt_f64(v_reinterpret_as_s32(v_int10));
- v_float64x2 v_src5 = v_cvt_f64_high(v_reinterpret_as_s32(v_int10));
- v_float64x2 v_src6 = v_cvt_f64(v_reinterpret_as_s32(v_int11));
- v_float64x2 v_src7 = v_cvt_f64_high(v_reinterpret_as_s32(v_int11));
-
- v_float64x2 v_dst0 = v_load(dst + x);
- v_float64x2 v_dst1 = v_load(dst + x + 2);
- v_float64x2 v_dst2 = v_load(dst + x + 4);
- v_float64x2 v_dst3 = v_load(dst + x + 6);
- v_float64x2 v_dst4 = v_load(dst + x + 8);
- v_float64x2 v_dst5 = v_load(dst + x + 10);
- v_float64x2 v_dst6 = v_load(dst + x + 12);
- v_float64x2 v_dst7 = v_load(dst + x + 14);
-
- v_dst0 = v_dst0 + v_src0;
- v_dst1 = v_dst1 + v_src1;
- v_dst2 = v_dst2 + v_src2;
- v_dst3 = v_dst3 + v_src3;
- v_dst4 = v_dst4 + v_src4;
- v_dst5 = v_dst5 + v_src5;
- v_dst6 = v_dst6 + v_src6;
- v_dst7 = v_dst7 + v_src7;
-
- v_store(dst + x, v_dst0);
- v_store(dst + x + 2, v_dst1);
- v_store(dst + x + 4, v_dst2);
- v_store(dst + x + 6, v_dst3);
- v_store(dst + x + 8, v_dst4);
- v_store(dst + x + 10, v_dst5);
- v_store(dst + x + 12, v_dst6);
- v_store(dst + x + 14, v_dst7);
- }
- }
- return x;
- }
-};
-
-template <>
-struct Acc_SIMD<ushort, double>
-{
- int operator() (const ushort * src, double * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 8; x += 8)
- {
- v_uint16x8 v_src = v_load(src + x);
- v_uint32x4 v_int0, v_int1;
- v_expand(v_src, v_int0, v_int1);
-
- v_float64x2 v_src0 = v_cvt_f64(v_reinterpret_as_s32(v_int0));
- v_float64x2 v_src1 = v_cvt_f64_high(v_reinterpret_as_s32(v_int0));
- v_float64x2 v_src2 = v_cvt_f64(v_reinterpret_as_s32(v_int1));
- v_float64x2 v_src3 = v_cvt_f64_high(v_reinterpret_as_s32(v_int1));
-
- v_float64x2 v_dst0 = v_load(dst + x);
- v_float64x2 v_dst1 = v_load(dst + x + 2);
- v_float64x2 v_dst2 = v_load(dst + x + 4);
- v_float64x2 v_dst3 = v_load(dst + x + 6);
-
- v_dst0 = v_dst0 + v_src0;
- v_dst1 = v_dst1 + v_src1;
- v_dst2 = v_dst2 + v_src2;
- v_dst3 = v_dst3 + v_src3;
-
- v_store(dst + x, v_dst0);
- v_store(dst + x + 2, v_dst1);
- v_store(dst + x + 4, v_dst2);
- v_store(dst + x + 6, v_dst3);
- }
- }
- return x;
- }
-};
-#endif
-
-template <>
-struct AccSqr_SIMD<uchar, float>
-{
- int operator() (const uchar * src, float * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 16; x += 16)
- {
- v_uint8x16 v_src = v_load(src + x);
- v_uint16x8 v_src0, v_src1;
- v_expand(v_src, v_src0, v_src1);
- v_src0 = v_src0 * v_src0;
- v_src1 = v_src1 * v_src1;
-
- v_uint32x4 v_src00, v_src01, v_src10, v_src11;
- v_expand(v_src0, v_src00, v_src01);
- v_expand(v_src1, v_src10, v_src11);
-
- v_store(dst + x, v_load(dst + x) + v_cvt_f32(v_reinterpret_as_s32(v_src00)));
- v_store(dst + x + 4, v_load(dst + x + 4) + v_cvt_f32(v_reinterpret_as_s32(v_src01)));
- v_store(dst + x + 8, v_load(dst + x + 8) + v_cvt_f32(v_reinterpret_as_s32(v_src10)));
- v_store(dst + x + 12, v_load(dst + x + 12) + v_cvt_f32(v_reinterpret_as_s32(v_src11)));
- }
- }
- else if (cn == 1)
- {
- v_uint8x16 v_0 = v_setall_u8(0);
- for ( ; x <= len - 16; x += 16)
- {
- v_uint8x16 v_mask = v_load(mask + x);
- v_mask = ~(v_0 == v_mask);
- v_uint8x16 v_src = v_load(src + x);
- v_src = v_src & v_mask;
- v_uint16x8 v_src0, v_src1;
- v_expand(v_src, v_src0, v_src1);
- v_src0 = v_src0 * v_src0;
- v_src1 = v_src1 * v_src1;
-
- v_uint32x4 v_src00, v_src01, v_src10, v_src11;
- v_expand(v_src0, v_src00, v_src01);
- v_expand(v_src1, v_src10, v_src11);
-
- v_store(dst + x, v_load(dst + x) + v_cvt_f32(v_reinterpret_as_s32(v_src00)));
- v_store(dst + x + 4, v_load(dst + x + 4) + v_cvt_f32(v_reinterpret_as_s32(v_src01)));
- v_store(dst + x + 8, v_load(dst + x + 8) + v_cvt_f32(v_reinterpret_as_s32(v_src10)));
- v_store(dst + x + 12, v_load(dst + x + 12) + v_cvt_f32(v_reinterpret_as_s32(v_src11)));
- }
- }
-
- return x;
- }
-};
-
-template <>
-struct AccSqr_SIMD<ushort, float>
-{
- int operator() (const ushort * src, float * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 8; x += 8)
- {
- v_uint16x8 v_src = v_load(src + x);
- v_uint32x4 v_src0, v_src1;
- v_expand(v_src, v_src0, v_src1);
-
- v_float32x4 v_float0, v_float1;
- v_float0 = v_cvt_f32(v_reinterpret_as_s32(v_src0));
- v_float1 = v_cvt_f32(v_reinterpret_as_s32(v_src1));
- v_float0 = v_float0 * v_float0;
- v_float1 = v_float1 * v_float1;
-
- v_store(dst + x, v_load(dst + x) + v_float0);
- v_store(dst + x + 4, v_load(dst + x + 4) + v_float1);
- }
- }
-
- return x;
- }
-};
-
-#if CV_SIMD128_64F
-template <>
-struct AccSqr_SIMD<uchar, double>
-{
- int operator() (const uchar * src, double * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 8; x += 8)
- {
- v_uint8x16 v_src = v_load(src + x);
- v_uint16x8 v_int, dummy;
- v_expand(v_src, v_int, dummy);
-
- v_uint32x4 v_int0, v_int1;
- v_expand(v_int, v_int0, v_int1);
-
- v_float64x2 v_src0 = v_cvt_f64(v_reinterpret_as_s32(v_int0));
- v_float64x2 v_src1 = v_cvt_f64_high(v_reinterpret_as_s32(v_int0));
- v_float64x2 v_src2 = v_cvt_f64(v_reinterpret_as_s32(v_int1));
- v_float64x2 v_src3 = v_cvt_f64_high(v_reinterpret_as_s32(v_int1));
- v_src0 = v_src0 * v_src0;
- v_src1 = v_src1 * v_src1;
- v_src2 = v_src2 * v_src2;
- v_src3 = v_src3 * v_src3;
-
- v_float64x2 v_dst0 = v_load(dst + x);
- v_float64x2 v_dst1 = v_load(dst + x + 2);
- v_float64x2 v_dst2 = v_load(dst + x + 4);
- v_float64x2 v_dst3 = v_load(dst + x + 6);
-
- v_dst0 += v_src0;
- v_dst1 += v_src1;
- v_dst2 += v_src2;
- v_dst3 += v_src3;
-
- v_store(dst + x, v_dst0);
- v_store(dst + x + 2, v_dst1);
- v_store(dst + x + 4, v_dst2);
- v_store(dst + x + 6, v_dst3);
- }
- }
- return x;
- }
-};
-
-template <>
-struct AccSqr_SIMD<ushort, double>
-{
- int operator() (const ushort * src, double * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 8; x += 8)
- {
- v_uint16x8 v_src = v_load(src + x);
- v_uint32x4 v_int_0, v_int_1;
- v_expand(v_src, v_int_0, v_int_1);
-
- v_int32x4 v_int0 = v_reinterpret_as_s32(v_int_0);
- v_int32x4 v_int1 = v_reinterpret_as_s32(v_int_1);
-
- v_float64x2 v_src0 = v_cvt_f64(v_int0);
- v_float64x2 v_src1 = v_cvt_f64_high(v_int0);
- v_float64x2 v_src2 = v_cvt_f64(v_int1);
- v_float64x2 v_src3 = v_cvt_f64_high(v_int1);
- v_src0 = v_src0 * v_src0;
- v_src1 = v_src1 * v_src1;
- v_src2 = v_src2 * v_src2;
- v_src3 = v_src3 * v_src3;
-
- v_float64x2 v_dst0 = v_load(dst + x);
- v_float64x2 v_dst1 = v_load(dst + x + 2);
- v_float64x2 v_dst2 = v_load(dst + x + 4);
- v_float64x2 v_dst3 = v_load(dst + x + 6);
-
- v_dst0 += v_src0;
- v_dst1 += v_src1;
- v_dst2 += v_src2;
- v_dst3 += v_src3;
-
- v_store(dst + x, v_dst0);
- v_store(dst + x + 2, v_dst1);
- v_store(dst + x + 4, v_dst2);
- v_store(dst + x + 6, v_dst3);
- }
- }
- return x;
- }
-};
-#endif
-
-template <>
-struct AccProd_SIMD<uchar, float>
-{
- int operator() (const uchar * src1, const uchar * src2, float * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- len *= cn;
- if (!mask)
- {
- for ( ; x <= len - 16; x += 16)
- {
- v_uint8x16 v_1src = v_load(src1 + x);
- v_uint8x16 v_2src = v_load(src2 + x);
-
- v_uint16x8 v_1src0, v_1src1, v_2src0, v_2src1;
- v_expand(v_1src, v_1src0, v_1src1);
- v_expand(v_2src, v_2src0, v_2src1);
-
- v_uint16x8 v_src0, v_src1;
- v_src0 = v_1src0 * v_2src0;
- v_src1 = v_1src1 * v_2src1;
-
- v_uint32x4 v_src00, v_src01, v_src10, v_src11;
- v_expand(v_src0, v_src00, v_src01);
- v_expand(v_src1, v_src10, v_src11);
-
- v_store(dst + x, v_load(dst + x) + v_cvt_f32(v_reinterpret_as_s32(v_src00)));
- v_store(dst + x + 4, v_load(dst + x + 4) + v_cvt_f32(v_reinterpret_as_s32(v_src01)));
- v_store(dst + x + 8, v_load(dst + x + 8) + v_cvt_f32(v_reinterpret_as_s32(v_src10)));
- v_store(dst + x + 12, v_load(dst + x + 12) + v_cvt_f32(v_reinterpret_as_s32(v_src11)));
- }
- }
- else if (cn == 1)
- {
- v_uint8x16 v_0 = v_setzero_u8();
-
- for ( ; x <= len - 16; x += 16)
- {
- v_uint8x16 v_mask = v_load(mask + x);
- v_mask = ~(v_0 == v_mask);
-
- v_uint8x16 v_1src = v_load(src1 + x) & v_mask;
- v_uint8x16 v_2src = v_load(src2 + x) & v_mask;
-
- v_uint16x8 v_1src0, v_1src1, v_2src0, v_2src1;
- v_expand(v_1src, v_1src0, v_1src1);
- v_expand(v_2src, v_2src0, v_2src1);
-
- v_uint16x8 v_src0, v_src1;
- v_src0 = v_1src0 * v_2src0;
- v_src1 = v_1src1 * v_2src1;
-
- v_uint32x4 v_src00, v_src01, v_src10, v_src11;
- v_expand(v_src0, v_src00, v_src01);
- v_expand(v_src1, v_src10, v_src11);
-
- v_store(dst + x, v_load(dst + x) + v_cvt_f32(v_reinterpret_as_s32(v_src00)));
- v_store(dst + x + 4, v_load(dst + x + 4) + v_cvt_f32(v_reinterpret_as_s32(v_src01)));
- v_store(dst + x + 8, v_load(dst + x + 8) + v_cvt_f32(v_reinterpret_as_s32(v_src10)));
- v_store(dst + x + 12, v_load(dst + x + 12) + v_cvt_f32(v_reinterpret_as_s32(v_src11)));
- }
- }
-
- return x;
- }
-};
-
-template <>
-struct AccProd_SIMD<ushort, float>
-{
- int operator() (const ushort * src1, const ushort * src2, float * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 8; x += 8)
- {
- v_uint16x8 v_1src = v_load(src1 + x);
- v_uint16x8 v_2src = v_load(src2 + x);
-
- v_uint32x4 v_1src0, v_1src1, v_2src0, v_2src1;
- v_expand(v_1src, v_1src0, v_1src1);
- v_expand(v_2src, v_2src0, v_2src1);
-
- v_float32x4 v_1float0 = v_cvt_f32(v_reinterpret_as_s32(v_1src0));
- v_float32x4 v_1float1 = v_cvt_f32(v_reinterpret_as_s32(v_1src1));
- v_float32x4 v_2float0 = v_cvt_f32(v_reinterpret_as_s32(v_2src0));
- v_float32x4 v_2float1 = v_cvt_f32(v_reinterpret_as_s32(v_2src1));
-
- v_float32x4 v_src0 = v_1float0 * v_2float0;
- v_float32x4 v_src1 = v_1float1 * v_2float1;
-
- v_store(dst + x, v_load(dst + x) + v_src0);
- v_store(dst + x + 4, v_load(dst + x + 4) + v_src1);
- }
- }
- else if (cn == 1)
- {
- v_uint16x8 v_0 = v_setzero_u16();
-
- for ( ; x <= len - 8; x += 8)
- {
- v_uint8x16 v_mask = v_load_halves(mask + x, mask + x);
- v_uint16x8 v_mask0, v_mask1;
- v_expand(v_mask, v_mask0, v_mask1);
- v_mask0 = ~(v_0 == v_mask0);
-
- v_uint16x8 v_1src = v_load(src1 + x) & v_mask0;
- v_uint16x8 v_2src = v_load(src2 + x) & v_mask0;
-
- v_uint32x4 v_1src0, v_1src1, v_2src0, v_2src1;
- v_expand(v_1src, v_1src0, v_1src1);
- v_expand(v_2src, v_2src0, v_2src1);
-
- v_float32x4 v_1float0 = v_cvt_f32(v_reinterpret_as_s32(v_1src0));
- v_float32x4 v_1float1 = v_cvt_f32(v_reinterpret_as_s32(v_1src1));
- v_float32x4 v_2float0 = v_cvt_f32(v_reinterpret_as_s32(v_2src0));
- v_float32x4 v_2float1 = v_cvt_f32(v_reinterpret_as_s32(v_2src1));
-
- v_float32x4 v_src0 = v_1float0 * v_2float0;
- v_float32x4 v_src1 = v_1float1 * v_2float1;
-
- v_store(dst + x, v_load(dst + x) + v_src0);
- v_store(dst + x + 4, v_load(dst + x + 4) + v_src1);
- }
- }
-
- return x;
- }
-};
-
-#if CV_SIMD128_64F
-template <>
-struct AccProd_SIMD<uchar, double>
-{
- int operator() (const uchar * src1, const uchar * src2, double * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 8; x += 8)
- {
- v_uint8x16 v_1src = v_load(src1 + x);
- v_uint8x16 v_2src = v_load(src2 + x);
-
- v_uint16x8 v_1int, v_2int, dummy;
- v_expand(v_1src, v_1int, dummy);
- v_expand(v_2src, v_2int, dummy);
-
- v_uint32x4 v_1int_0, v_1int_1, v_2int_0, v_2int_1;
- v_expand(v_1int, v_1int_0, v_1int_1);
- v_expand(v_2int, v_2int_0, v_2int_1);
-
- v_int32x4 v_1int0 = v_reinterpret_as_s32(v_1int_0);
- v_int32x4 v_1int1 = v_reinterpret_as_s32(v_1int_1);
- v_int32x4 v_2int0 = v_reinterpret_as_s32(v_2int_0);
- v_int32x4 v_2int1 = v_reinterpret_as_s32(v_2int_1);
-
- v_float64x2 v_src0 = v_cvt_f64(v_1int0) * v_cvt_f64(v_2int0);
- v_float64x2 v_src1 = v_cvt_f64_high(v_1int0) * v_cvt_f64_high(v_2int0);
- v_float64x2 v_src2 = v_cvt_f64(v_1int1) * v_cvt_f64(v_2int1);
- v_float64x2 v_src3 = v_cvt_f64_high(v_1int1) * v_cvt_f64_high(v_2int1);
-
- v_float64x2 v_dst0 = v_load(dst + x);
- v_float64x2 v_dst1 = v_load(dst + x + 2);
- v_float64x2 v_dst2 = v_load(dst + x + 4);
- v_float64x2 v_dst3 = v_load(dst + x + 6);
-
- v_dst0 += v_src0;
- v_dst1 += v_src1;
- v_dst2 += v_src2;
- v_dst3 += v_src3;
-
- v_store(dst + x, v_dst0);
- v_store(dst + x + 2, v_dst1);
- v_store(dst + x + 4, v_dst2);
- v_store(dst + x + 6, v_dst3);
- }
- }
- return x;
- }
-};
-
-template <>
-struct AccProd_SIMD<ushort, double>
-{
- int operator() (const ushort * src1, const ushort * src2, double * dst, const uchar * mask, int len, int cn) const
- {
- int x = 0;
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 8; x += 8)
- {
- v_uint16x8 v_1src = v_load(src1 + x);
- v_uint16x8 v_2src = v_load(src2 + x);
-
- v_uint32x4 v_1int_0, v_1int_1, v_2int_0, v_2int_1;
- v_expand(v_1src, v_1int_0, v_1int_1);
- v_expand(v_2src, v_2int_0, v_2int_1);
-
- v_int32x4 v_1int0 = v_reinterpret_as_s32(v_1int_0);
- v_int32x4 v_1int1 = v_reinterpret_as_s32(v_1int_1);
- v_int32x4 v_2int0 = v_reinterpret_as_s32(v_2int_0);
- v_int32x4 v_2int1 = v_reinterpret_as_s32(v_2int_1);
-
- v_float64x2 v_src0 = v_cvt_f64(v_1int0) * v_cvt_f64(v_2int0);
- v_float64x2 v_src1 = v_cvt_f64_high(v_1int0) * v_cvt_f64_high(v_2int0);
- v_float64x2 v_src2 = v_cvt_f64(v_1int1) * v_cvt_f64(v_2int1);
- v_float64x2 v_src3 = v_cvt_f64_high(v_1int1) * v_cvt_f64_high(v_2int1);
-
- v_float64x2 v_dst0 = v_load(dst + x);
- v_float64x2 v_dst1 = v_load(dst + x + 2);
- v_float64x2 v_dst2 = v_load(dst + x + 4);
- v_float64x2 v_dst3 = v_load(dst + x + 6);
-
- v_dst0 = v_dst0 + v_src0;
- v_dst1 = v_dst1 + v_src1;
- v_dst2 = v_dst2 + v_src2;
- v_dst3 = v_dst3 + v_src3;
-
- v_store(dst + x, v_dst0);
- v_store(dst + x + 2, v_dst1);
- v_store(dst + x + 4, v_dst2);
- v_store(dst + x + 6, v_dst3);
- }
- }
- return x;
- }
-};
-#endif
-
-template <>
-struct AccW_SIMD<uchar, float>
-{
- int operator() (const uchar * src, float * dst, const uchar * mask, int len, int cn, float alpha) const
- {
- int x = 0;
- v_float32x4 v_alpha = v_setall_f32(alpha);
- v_float32x4 v_beta = v_setall_f32(1.0f - alpha);
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 16; x += 16)
- {
- v_uint8x16 v_src = v_load(src + x);
-
- v_uint16x8 v_src0, v_src1;
- v_expand(v_src, v_src0, v_src1);
-
- v_uint32x4 v_src00, v_src01, v_src10, v_src11;
- v_expand(v_src0, v_src00, v_src01);
- v_expand(v_src1, v_src10, v_src11);
-
- v_float32x4 v_dst00 = v_load(dst + x);
- v_float32x4 v_dst01 = v_load(dst + x + 4);
- v_float32x4 v_dst10 = v_load(dst + x + 8);
- v_float32x4 v_dst11 = v_load(dst + x + 12);
-
- v_dst00 = (v_dst00 * v_beta) + (v_cvt_f32(v_reinterpret_as_s32(v_src00)) * v_alpha);
- v_dst01 = (v_dst01 * v_beta) + (v_cvt_f32(v_reinterpret_as_s32(v_src01)) * v_alpha);
- v_dst10 = (v_dst10 * v_beta) + (v_cvt_f32(v_reinterpret_as_s32(v_src10)) * v_alpha);
- v_dst11 = (v_dst11 * v_beta) + (v_cvt_f32(v_reinterpret_as_s32(v_src11)) * v_alpha);
-
- v_store(dst + x, v_dst00);
- v_store(dst + x + 4, v_dst01);
- v_store(dst + x + 8, v_dst10);
- v_store(dst + x + 12, v_dst11);
- }
- }
-
- return x;
- }
-};
-
-template <>
-struct AccW_SIMD<ushort, float>
-{
- int operator() (const ushort * src, float * dst, const uchar * mask, int len, int cn, float alpha) const
- {
- int x = 0;
- v_float32x4 v_alpha = v_setall_f32(alpha);
- v_float32x4 v_beta = v_setall_f32(1.0f - alpha);
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 8; x += 8)
- {
- v_uint16x8 v_src = v_load(src + x);
- v_uint32x4 v_int0, v_int1;
- v_expand(v_src, v_int0, v_int1);
-
- v_float32x4 v_src0 = v_cvt_f32(v_reinterpret_as_s32(v_int0));
- v_float32x4 v_src1 = v_cvt_f32(v_reinterpret_as_s32(v_int1));
- v_src0 = v_src0 * v_alpha;
- v_src1 = v_src1 * v_alpha;
-
- v_float32x4 v_dst0 = v_load(dst + x) * v_beta;
- v_float32x4 v_dst1 = v_load(dst + x + 4) * v_beta;
-
- v_store(dst + x, v_dst0 + v_src0);
- v_store(dst + x + 4, v_dst1 + v_src1);
- }
- }
-
- return x;
- }
-};
-
-#if CV_SIMD128_64F
-template <>
-struct AccW_SIMD<uchar, double>
-{
- int operator() (const uchar * src, double * dst, const uchar * mask, int len, int cn, double alpha) const
- {
- int x = 0;
- v_float64x2 v_alpha = v_setall_f64(alpha);
- v_float64x2 v_beta = v_setall_f64(1.0f - alpha);
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 8; x += 8)
- {
- v_uint8x16 v_src = v_load(src + x);
- v_uint16x8 v_int, dummy;
- v_expand(v_src, v_int, dummy);
-
- v_uint32x4 v_int_0, v_int_1;
- v_expand(v_int, v_int_0, v_int_1);
-
- v_int32x4 v_int0 = v_reinterpret_as_s32(v_int_0);
- v_int32x4 v_int1 = v_reinterpret_as_s32(v_int_1);
-
- v_float64x2 v_src0 = v_cvt_f64(v_int0);
- v_float64x2 v_src1 = v_cvt_f64_high(v_int0);
- v_float64x2 v_src2 = v_cvt_f64(v_int1);
- v_float64x2 v_src3 = v_cvt_f64_high(v_int1);
-
- v_float64x2 v_dst0 = v_load(dst + x);
- v_float64x2 v_dst1 = v_load(dst + x + 2);
- v_float64x2 v_dst2 = v_load(dst + x + 4);
- v_float64x2 v_dst3 = v_load(dst + x + 6);
-
- v_dst0 = (v_dst0 * v_beta) + (v_src0 * v_alpha);
- v_dst1 = (v_dst1 * v_beta) + (v_src1 * v_alpha);
- v_dst2 = (v_dst2 * v_beta) + (v_src2 * v_alpha);
- v_dst3 = (v_dst3 * v_beta) + (v_src3 * v_alpha);
-
- v_store(dst + x, v_dst0);
- v_store(dst + x + 2, v_dst1);
- v_store(dst + x + 4, v_dst2);
- v_store(dst + x + 6, v_dst3);
- }
- }
-
- return x;
- }
-};
-
-template <>
-struct AccW_SIMD<ushort, double>
-{
- int operator() (const ushort * src, double * dst, const uchar * mask, int len, int cn, double alpha) const
- {
- int x = 0;
- v_float64x2 v_alpha = v_setall_f64(alpha);
- v_float64x2 v_beta = v_setall_f64(1.0f - alpha);
-
- if (!mask)
- {
- len *= cn;
- for ( ; x <= len - 8; x += 8)
- {
- v_uint16x8 v_src = v_load(src + x);
- v_uint32x4 v_int_0, v_int_1;
- v_expand(v_src, v_int_0, v_int_1);
-
- v_int32x4 v_int0 = v_reinterpret_as_s32(v_int_0);
- v_int32x4 v_int1 = v_reinterpret_as_s32(v_int_1);
-
- v_float64x2 v_src00 = v_cvt_f64(v_int0);
- v_float64x2 v_src01 = v_cvt_f64_high(v_int0);
- v_float64x2 v_src10 = v_cvt_f64(v_int1);
- v_float64x2 v_src11 = v_cvt_f64_high(v_int1);
-
- v_float64x2 v_dst00 = v_load(dst + x);
- v_float64x2 v_dst01 = v_load(dst + x + 2);
- v_float64x2 v_dst10 = v_load(dst + x + 4);
- v_float64x2 v_dst11 = v_load(dst + x + 6);
-
- v_dst00 = (v_dst00 * v_beta) + (v_src00 * v_alpha);
- v_dst01 = (v_dst01 * v_beta) + (v_src01 * v_alpha);
- v_dst10 = (v_dst10 * v_beta) + (v_src10 * v_alpha);
- v_dst11 = (v_dst11 * v_beta) + (v_src11 * v_alpha);
-
- v_store(dst + x, v_dst00);
- v_store(dst + x + 2, v_dst01);
- v_store(dst + x + 4, v_dst10);
- v_store(dst + x + 6, v_dst11);
- }
- }
-
- return x;
- }
-};
-#endif //CV_SIMD128_64F
-#endif //CV_SIMD128
-
-template<typename T, typename AT> void
-acc_( const T* src, AT* dst, const uchar* mask, int len, int cn )
-{
- int i = Acc_SIMD<T, AT>()(src, dst, mask, len, cn);
-
- if( !mask )
- {
- len *= cn;
- #if CV_ENABLE_UNROLLED
- for( ; i <= len - 4; i += 4 )
- {
- AT t0, t1;
- t0 = src[i] + dst[i];
- t1 = src[i+1] + dst[i+1];
- dst[i] = t0; dst[i+1] = t1;
-
- t0 = src[i+2] + dst[i+2];
- t1 = src[i+3] + dst[i+3];
- dst[i+2] = t0; dst[i+3] = t1;
- }
- #endif
- for( ; i < len; i++ )
- dst[i] += src[i];
- }
- else if( cn == 1 )
- {
- for( ; i < len; i++ )
- {
- if( mask[i] )
- dst[i] += src[i];
- }
- }
- else if( cn == 3 )
- {
- for( ; i < len; i++, src += 3, dst += 3 )
- {
- if( mask[i] )
- {
- AT t0 = src[0] + dst[0];
- AT t1 = src[1] + dst[1];
- AT t2 = src[2] + dst[2];
-
- dst[0] = t0; dst[1] = t1; dst[2] = t2;
- }
- }
- }
- else
- {
- for( ; i < len; i++, src += cn, dst += cn )
- if( mask[i] )
- {
- for( int k = 0; k < cn; k++ )
- dst[k] += src[k];
- }
- }
-}
-
-
-template<typename T, typename AT> void
-accSqr_( const T* src, AT* dst, const uchar* mask, int len, int cn )
-{
- int i = AccSqr_SIMD<T, AT>()(src, dst, mask, len, cn);
-
- if( !mask )
- {
- len *= cn;
- #if CV_ENABLE_UNROLLED
- for( ; i <= len - 4; i += 4 )
- {
- AT t0, t1;
- t0 = (AT)src[i]*src[i] + dst[i];
- t1 = (AT)src[i+1]*src[i+1] + dst[i+1];
- dst[i] = t0; dst[i+1] = t1;
-
- t0 = (AT)src[i+2]*src[i+2] + dst[i+2];
- t1 = (AT)src[i+3]*src[i+3] + dst[i+3];
- dst[i+2] = t0; dst[i+3] = t1;
- }
- #endif
- for( ; i < len; i++ )
- dst[i] += (AT)src[i]*src[i];
- }
- else if( cn == 1 )
- {
- for( ; i < len; i++ )
- {
- if( mask[i] )
- dst[i] += (AT)src[i]*src[i];
- }
- }
- else if( cn == 3 )
- {
- for( ; i < len; i++, src += 3, dst += 3 )
- {
- if( mask[i] )
- {
- AT t0 = (AT)src[0]*src[0] + dst[0];
- AT t1 = (AT)src[1]*src[1] + dst[1];
- AT t2 = (AT)src[2]*src[2] + dst[2];
-
- dst[0] = t0; dst[1] = t1; dst[2] = t2;
- }
- }
- }
- else
- {
- for( ; i < len; i++, src += cn, dst += cn )
- if( mask[i] )
- {
- for( int k = 0; k < cn; k++ )
- dst[k] += (AT)src[k]*src[k];
- }
- }
-}
-
-
-template<typename T, typename AT> void
-accProd_( const T* src1, const T* src2, AT* dst, const uchar* mask, int len, int cn )
-{
- int i = AccProd_SIMD<T, AT>()(src1, src2, dst, mask, len, cn);
-
- if( !mask )
- {
- len *= cn;
- #if CV_ENABLE_UNROLLED
- for( ; i <= len - 4; i += 4 )
- {
- AT t0, t1;
- t0 = (AT)src1[i]*src2[i] + dst[i];
- t1 = (AT)src1[i+1]*src2[i+1] + dst[i+1];
- dst[i] = t0; dst[i+1] = t1;
-
- t0 = (AT)src1[i+2]*src2[i+2] + dst[i+2];
- t1 = (AT)src1[i+3]*src2[i+3] + dst[i+3];
- dst[i+2] = t0; dst[i+3] = t1;
- }
- #endif
- for( ; i < len; i++ )
- dst[i] += (AT)src1[i]*src2[i];
- }
- else if( cn == 1 )
- {
- for( ; i < len; i++ )
- {
- if( mask[i] )
- dst[i] += (AT)src1[i]*src2[i];
- }
- }
- else if( cn == 3 )
- {
- for( ; i < len; i++, src1 += 3, src2 += 3, dst += 3 )
- {
- if( mask[i] )
- {
- AT t0 = (AT)src1[0]*src2[0] + dst[0];
- AT t1 = (AT)src1[1]*src2[1] + dst[1];
- AT t2 = (AT)src1[2]*src2[2] + dst[2];
-
- dst[0] = t0; dst[1] = t1; dst[2] = t2;
- }
- }
- }
- else
- {
- for( ; i < len; i++, src1 += cn, src2 += cn, dst += cn )
- if( mask[i] )
- {
- for( int k = 0; k < cn; k++ )
- dst[k] += (AT)src1[k]*src2[k];
- }
- }
-}
-
-
-template<typename T, typename AT> void
-accW_( const T* src, AT* dst, const uchar* mask, int len, int cn, double alpha )
+namespace cv
{
- AT a = (AT)alpha, b = 1 - a;
- int i = AccW_SIMD<T, AT>()(src, dst, mask, len, cn, a);
-
- if( !mask )
- {
- len *= cn;
- #if CV_ENABLE_UNROLLED
- for( ; i <= len - 4; i += 4 )
- {
- AT t0, t1;
- t0 = src[i]*a + dst[i]*b;
- t1 = src[i+1]*a + dst[i+1]*b;
- dst[i] = t0; dst[i+1] = t1;
-
- t0 = src[i+2]*a + dst[i+2]*b;
- t1 = src[i+3]*a + dst[i+3]*b;
- dst[i+2] = t0; dst[i+3] = t1;
- }
- #endif
- for( ; i < len; i++ )
- dst[i] = src[i]*a + dst[i]*b;
- }
- else if( cn == 1 )
- {
- for( ; i < len; i++ )
- {
- if( mask[i] )
- dst[i] = src[i]*a + dst[i]*b;
- }
- }
- else if( cn == 3 )
- {
- for( ; i < len; i++, src += 3, dst += 3 )
- {
- if( mask[i] )
- {
- AT t0 = src[0]*a + dst[0]*b;
- AT t1 = src[1]*a + dst[1]*b;
- AT t2 = src[2]*a + dst[2]*b;
-
- dst[0] = t0; dst[1] = t1; dst[2] = t2;
- }
- }
- }
- else
- {
- for( ; i < len; i++, src += cn, dst += cn )
- if( mask[i] )
- {
- for( int k = 0; k < cn; k++ )
- dst[k] = src[k]*a + dst[k]*b;
- }
- }
-}
-
-#define DEF_ACC_FUNCS(suffix, type, acctype) \
-static void acc_##suffix(const type* src, acctype* dst, \
- const uchar* mask, int len, int cn) \
-{ acc_(src, dst, mask, len, cn); } \
-\
-static void accSqr_##suffix(const type* src, acctype* dst, \
- const uchar* mask, int len, int cn) \
-{ accSqr_(src, dst, mask, len, cn); } \
-\
-static void accProd_##suffix(const type* src1, const type* src2, \
- acctype* dst, const uchar* mask, int len, int cn) \
-{ accProd_(src1, src2, dst, mask, len, cn); } \
-\
-static void accW_##suffix(const type* src, acctype* dst, \
- const uchar* mask, int len, int cn, double alpha) \
-{ accW_(src, dst, mask, len, cn, alpha); }
-
-
-DEF_ACC_FUNCS(8u32f, uchar, float)
-DEF_ACC_FUNCS(8u64f, uchar, double)
-DEF_ACC_FUNCS(16u32f, ushort, float)
-DEF_ACC_FUNCS(16u64f, ushort, double)
-DEF_ACC_FUNCS(32f, float, float)
-DEF_ACC_FUNCS(32f64f, float, double)
-DEF_ACC_FUNCS(64f, double, double)
-
-
-typedef void (*AccFunc)(const uchar*, uchar*, const uchar*, int, int);
-typedef void (*AccProdFunc)(const uchar*, const uchar*, uchar*, const uchar*, int, int);
-typedef void (*AccWFunc)(const uchar*, uchar*, const uchar*, int, int, double);
+typedef void(*AccFunc)(const uchar*, uchar*, const uchar*, int, int);
+typedef void(*AccProdFunc)(const uchar*, const uchar*, uchar*, const uchar*, int, int);
+typedef void(*AccWFunc)(const uchar*, uchar*, const uchar*, int, int, double);
static AccFunc accTab[] =
{
@@ -1942,9 +241,14 @@ enum
VX_ACCUMULATE_WEIGHTED_OP = 2
};
+namespace ovx {
+ template <> inline bool skipSmallImages<VX_KERNEL_ACCUMULATE>(int w, int h) { return w*h < 120 * 60; }
+}
static bool openvx_accumulate(InputArray _src, InputOutputArray _dst, InputArray _mask, double _weight, int opType)
{
Mat srcMat = _src.getMat(), dstMat = _dst.getMat();
+ if (ovx::skipSmallImages<VX_KERNEL_ACCUMULATE>(srcMat.cols, srcMat.rows))
+ return false;
if(!_mask.empty() ||
(opType == VX_ACCUMULATE_WEIGHTED_OP && dstMat.type() != CV_8UC1 ) ||
(opType != VX_ACCUMULATE_WEIGHTED_OP && dstMat.type() != CV_16SC1 ) ||
@@ -1958,7 +262,7 @@ static bool openvx_accumulate(InputArray _src, InputOutputArray _dst, InputArray
try
{
- ivx::Context context = ivx::Context::create();
+ ivx::Context context = ovx::getOpenVXContext();
ivx::Image srcImage = ivx::Image::createFromHandle(context, ivx::Image::matTypeToFormat(srcMat.type()),
ivx::Image::createAddressing(srcMat), srcMat.data);
ivx::Image dstImage = ivx::Image::createFromHandle(context, ivx::Image::matTypeToFormat(dstMat.type()),
diff --git a/modules/imgproc/src/accum.dispatch.cpp b/modules/imgproc/src/accum.dispatch.cpp
new file mode 100644
index 0000000..8bbf37c
--- /dev/null
+++ b/modules/imgproc/src/accum.dispatch.cpp
@@ -0,0 +1,20 @@
+ // This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "precomp.hpp"
+
+#include "accum.simd.hpp"
+#include "accum.simd_declarations.hpp" // defines CV_CPU_DISPATCH_MODES_ALL=AVX2,...,BASELINE based on CMakeLists.txt content
+
+namespace cv {
+
+DEF_ACC_INT_FUNCS(8u32f, uchar, float)
+DEF_ACC_INT_FUNCS(8u64f, uchar, double)
+DEF_ACC_INT_FUNCS(16u32f, ushort, float)
+DEF_ACC_INT_FUNCS(16u64f, ushort, double)
+DEF_ACC_FLT_FUNCS(32f, float, float)
+DEF_ACC_FLT_FUNCS(32f64f, float, double)
+DEF_ACC_FLT_FUNCS(64f, double, double)
+
+} //cv::hal
\ No newline at end of file
diff --git a/modules/imgproc/src/accum.simd.hpp b/modules/imgproc/src/accum.simd.hpp
new file mode 100644
index 0000000..7a29447
--- /dev/null
+++ b/modules/imgproc/src/accum.simd.hpp
@@ -0,0 +1,3136 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "opencv2/core/hal/intrin.hpp"
+
+#define DEF_ACC_INT_FUNCS(suffix, type, acctype) \
+void acc_##suffix(const type* src, acctype* dst, \
+ const uchar* mask, int len, int cn) \
+{ \
+ CV_CPU_CALL_NEON(acc_simd_, (src, dst, mask, len, cn)); \
+ CV_CPU_CALL_SSE2(acc_simd_, (src, dst, mask, len, cn)); \
+ CV_CPU_CALL_BASELINE(acc_general_, (src, dst, mask, len, cn)); \
+} \
+void accSqr_##suffix(const type* src, acctype* dst, \
+ const uchar* mask, int len, int cn) \
+{ \
+ CV_CPU_CALL_NEON(accSqr_simd_, (src, dst, mask, len, cn)); \
+ CV_CPU_CALL_SSE2(accSqr_simd_, (src, dst, mask, len, cn)); \
+ CV_CPU_CALL_BASELINE(accSqr_general_, (src, dst, mask, len, cn)); \
+} \
+void accProd_##suffix(const type* src1, const type* src2, \
+ acctype* dst, const uchar* mask, int len, int cn) \
+{ \
+ CV_CPU_CALL_NEON(accProd_simd_, (src1, src2, dst, mask, len, cn)); \
+ CV_CPU_CALL_SSE2(accProd_simd_, (src1, src2, dst, mask, len, cn)); \
+ CV_CPU_CALL_BASELINE(accProd_general_, (src1, src2, dst, mask, len, cn)); \
+} \
+void accW_##suffix(const type* src, acctype* dst, \
+ const uchar* mask, int len, int cn, double alpha) \
+{ \
+ CV_CPU_CALL_NEON(accW_simd_, (src, dst, mask, len, cn, alpha)); \
+ CV_CPU_CALL_SSE2(accW_simd_, (src, dst, mask, len, cn, alpha)); \
+ CV_CPU_CALL_BASELINE(accW_general_, (src, dst, mask, len, cn, alpha)); \
+}
+#define DEF_ACC_FLT_FUNCS(suffix, type, acctype) \
+void acc_##suffix(const type* src, acctype* dst, \
+ const uchar* mask, int len, int cn) \
+{ \
+ CV_CPU_CALL_AVX(acc_avx_##suffix, (src, dst, mask, len, cn)); \
+ CV_CPU_CALL_NEON(acc_simd_, (src, dst, mask, len, cn)); \
+ CV_CPU_CALL_SSE2(acc_simd_, (src, dst, mask, len, cn)); \
+ CV_CPU_CALL_BASELINE(acc_general_, (src, dst, mask, len, cn)); \
+} \
+void accSqr_##suffix(const type* src, acctype* dst, \
+ const uchar* mask, int len, int cn) \
+{ \
+ CV_CPU_CALL_AVX(accSqr_avx_##suffix, (src, dst, mask, len, cn)); \
+ CV_CPU_CALL_NEON(accSqr_simd_, (src, dst, mask, len, cn)); \
+ CV_CPU_CALL_SSE2(accSqr_simd_, (src, dst, mask, len, cn)); \
+ CV_CPU_CALL_BASELINE(accSqr_general_, (src, dst, mask, len, cn)); \
+} \
+void accProd_##suffix(const type* src1, const type* src2, \
+ acctype* dst, const uchar* mask, int len, int cn) \
+{ \
+ CV_CPU_CALL_AVX(accProd_avx_##suffix, (src1, src2, dst, mask, len, cn)); \
+ CV_CPU_CALL_NEON(accProd_simd_, (src1, src2, dst, mask, len, cn)); \
+ CV_CPU_CALL_SSE2(accProd_simd_, (src1, src2, dst, mask, len, cn)); \
+ CV_CPU_CALL_BASELINE(accProd_general_, (src1, src2, dst, mask, len, cn)); \
+} \
+void accW_##suffix(const type* src, acctype* dst, \
+ const uchar* mask, int len, int cn, double alpha) \
+{ \
+ CV_CPU_CALL_AVX(accW_avx_##suffix, (src, dst, mask, len, cn, alpha)); \
+ CV_CPU_CALL_NEON(accW_simd_, (src, dst, mask, len, cn, alpha)); \
+ CV_CPU_CALL_SSE2(accW_simd_, (src, dst, mask, len, cn, alpha)); \
+ CV_CPU_CALL_BASELINE(accW_general_, (src, dst, mask, len, cn, alpha)); \
+}
+#define DECLARATE_ACC_FUNCS(suffix, type, acctype) \
+void acc_##suffix(const type* src, acctype* dst, const uchar* mask, int len, int cn); \
+void accSqr_##suffix(const type* src, acctype* dst, const uchar* mask, int len, int cn); \
+void accProd_##suffix(const type* src1, const type* src2, acctype* dst, const uchar* mask, int len, int cn); \
+void accW_##suffix(const type* src, acctype* dst, const uchar* mask, int len, int cn, double alpha);
+
+
+namespace cv {
+
+DECLARATE_ACC_FUNCS(8u32f, uchar, float)
+DECLARATE_ACC_FUNCS(8u64f, uchar, double)
+DECLARATE_ACC_FUNCS(16u32f, ushort, float)
+DECLARATE_ACC_FUNCS(16u64f, ushort, double)
+DECLARATE_ACC_FUNCS(32f, float, float)
+DECLARATE_ACC_FUNCS(32f64f, float, double)
+DECLARATE_ACC_FUNCS(64f, double, double)
+
+CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
+
+void acc_simd_(const uchar* src, float* dst, const uchar* mask, int len, int cn);
+void acc_simd_(const ushort* src, float* dst, const uchar* mask, int len, int cn);
+void acc_simd_(const uchar* src, double* dst, const uchar* mask, int len, int cn);
+void acc_simd_(const ushort* src, double* dst, const uchar* mask, int len, int cn);
+void acc_simd_(const float* src, float* dst, const uchar* mask, int len, int cn);
+void acc_simd_(const float* src, double* dst, const uchar* mask, int len, int cn);
+void acc_simd_(const double* src, double* dst, const uchar* mask, int len, int cn);
+void accSqr_simd_(const uchar* src, float* dst, const uchar* mask, int len, int cn);
+void accSqr_simd_(const ushort* src, float* dst, const uchar* mask, int len, int cn);
+void accSqr_simd_(const uchar* src, double* dst, const uchar* mask, int len, int cn);
+void accSqr_simd_(const ushort* src, double* dst, const uchar* mask, int len, int cn);
+void accSqr_simd_(const float* src, float* dst, const uchar* mask, int len, int cn);
+void accSqr_simd_(const float* src, double* dst, const uchar* mask, int len, int cn);
+void accSqr_simd_(const double* src, double* dst, const uchar* mask, int len, int cn);
+void accProd_simd_(const uchar* src1, const uchar* src2, float* dst, const uchar* mask, int len, int cn);
+void accProd_simd_(const ushort* src1, const ushort* src2, float* dst, const uchar* mask, int len, int cn);
+void accProd_simd_(const uchar* src1, const uchar* src2, double* dst, const uchar* mask, int len, int cn);
+void accProd_simd_(const ushort* src1, const ushort* src2, double* dst, const uchar* mask, int len, int cn);
+void accProd_simd_(const float* src1, const float* src2, float* dst, const uchar* mask, int len, int cn);
+void accProd_simd_(const float* src1, const float* src2, double* dst, const uchar* mask, int len, int cn);
+void accProd_simd_(const double* src1, const double* src2, double* dst, const uchar* mask, int len, int cn);
+void accW_simd_(const uchar* src, float* dst, const uchar* mask, int len, int cn, double alpha);
+void accW_simd_(const ushort* src, float* dst, const uchar* mask, int len, int cn, double alpha);
+void accW_simd_(const uchar* src, double* dst, const uchar* mask, int len, int cn, double alpha);
+void accW_simd_(const ushort* src, double* dst, const uchar* mask, int len, int cn, double alpha);
+void accW_simd_(const float* src, float* dst, const uchar* mask, int len, int cn, double alpha);
+void accW_simd_(const float* src, double* dst, const uchar* mask, int len, int cn, double alpha);
+void accW_simd_(const double* src, double* dst, const uchar* mask, int len, int cn, double alpha);
+
+// accumulate series optimized by AVX
+void acc_avx_32f(const float* src, float* dst, const uchar* mask, int len, int cn);
+void acc_avx_32f64f(const float* src, double* dst, const uchar* mask, int len, int cn);
+void acc_avx_64f(const double* src, double* dst, const uchar* mask, int len, int cn);
+void accSqr_avx_32f(const float* src, float* dst, const uchar* mask, int len, int cn);
+void accSqr_avx_32f64f(const float* src, double* dst, const uchar* mask, int len, int cn);
+void accSqr_avx_64f(const double* src, double* dst, const uchar* mask, int len, int cn);
+void accProd_avx_32f(const float* src1, const float* src2, float* dst, const uchar* mask, int len, int cn);
+void accProd_avx_32f64f(const float* src1, const float* src2, double* dst, const uchar* mask, int len, int cn);
+void accProd_avx_64f(const double* src1, const double* src2, double* dst, const uchar* mask, int len, int cn);
+void accW_avx_32f(const float* src, float* dst, const uchar* mask, int len, int cn, double alpha);
+void accW_avx_32f64f(const float* src, double* dst, const uchar* mask, int len, int cn, double alpha);
+void accW_avx_64f(const double* src, double* dst, const uchar* mask, int len, int cn, double alpha);
+
+#ifndef CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
+
+template <typename T, typename AT>
+void acc_general_(const T* src, AT* dst, const uchar* mask, int len, int cn, int start = 0 )
+{
+ int i = start;
+
+ if( !mask )
+ {
+ len *= cn;
+ #if CV_ENABLE_UNROLLED
+ for( ; i <= len - 4; i += 4 )
+ {
+ AT t0, t1;
+ t0 = src[i] + dst[i];
+ t1 = src[i+1] + dst[i+1];
+ dst[i] = t0; dst[i+1] = t1;
+
+ t0 = src[i+2] + dst[i+2];
+ t1 = src[i+3] + dst[i+3];
+ dst[i+2] = t0; dst[i+3] = t1;
+ }
+ #endif
+ for( ; i < len; i++ )
+ {
+ dst[i] += src[i];
+ }
+ }
+ else
+ {
+ src += (i * cn);
+ dst += (i * cn);
+ for( ; i < len; i++, src += cn, dst += cn )
+ {
+ if( mask[i] )
+ {
+ for( int k = 0; k < cn; k++ )
+ {
+ dst[k] += src[k];
+ }
+ }
+ }
+ }
+
+}
+
+template<typename T, typename AT> void
+accSqr_general_( const T* src, AT* dst, const uchar* mask, int len, int cn, int start = 0 )
+{
+ int i = start;
+
+ if( !mask )
+ {
+ len *= cn;
+ #if CV_ENABLE_UNROLLED
+ for( ; i <= len - 4; i += 4 )
+ {
+ AT t0, t1;
+ t0 = (AT)src[i]*src[i] + dst[i];
+ t1 = (AT)src[i+1]*src[i+1] + dst[i+1];
+ dst[i] = t0; dst[i+1] = t1;
+
+ t0 = (AT)src[i+2]*src[i+2] + dst[i+2];
+ t1 = (AT)src[i+3]*src[i+3] + dst[i+3];
+ dst[i+2] = t0; dst[i+3] = t1;
+ }
+ #endif
+ for( ; i < len; i++ )
+ {
+ dst[i] += (AT)src[i]*src[i];
+ }
+ }
+ else
+ {
+ src += (i * cn);
+ dst += (i * cn);
+ for( ; i < len; i++, src += cn, dst += cn )
+ {
+ if( mask[i] )
+ {
+ for( int k = 0; k < cn; k++ )
+ {
+ dst[k] += (AT)src[k]*src[k];
+ }
+ }
+ }
+ }
+}
+
+template<typename T, typename AT> void
+accProd_general_( const T* src1, const T* src2, AT* dst, const uchar* mask, int len, int cn, int start = 0 )
+{
+ int i = start;
+
+ if( !mask )
+ {
+ len *= cn;
+ #if CV_ENABLE_UNROLLED
+ for( ; i <= len - 4; i += 4 )
+ {
+ AT t0, t1;
+ t0 = (AT)src1[i]*src2[i] + dst[i];
+ t1 = (AT)src1[i+1]*src2[i+1] + dst[i+1];
+ dst[i] = t0; dst[i+1] = t1;
+
+ t0 = (AT)src1[i+2]*src2[i+2] + dst[i+2];
+ t1 = (AT)src1[i+3]*src2[i+3] + dst[i+3];
+ dst[i+2] = t0; dst[i+3] = t1;
+ }
+ #endif
+ for( ; i < len; i++ )
+ {
+ dst[i] += (AT)src1[i]*src2[i];
+ }
+ }
+ else
+ {
+ src1 += (i * cn);
+ src2 += (i * cn);
+ dst += (i * cn);
+ for( ; i < len; i++, src1 += cn, src2 += cn, dst += cn )
+ {
+ if( mask[i] )
+ {
+ for( int k = 0; k < cn; k++ )
+ {
+ dst[k] += (AT)src1[k]*src2[k];
+ }
+ }
+ }
+ }
+}
+
+template<typename T, typename AT> void
+accW_general_( const T* src, AT* dst, const uchar* mask, int len, int cn, double alpha, int start = 0 )
+{
+ AT a = (AT)alpha, b = 1 - a;
+ int i = start;
+
+ if( !mask )
+ {
+ len *= cn;
+ #if CV_ENABLE_UNROLLED
+ for( ; i <= len - 4; i += 4 )
+ {
+ AT t0, t1;
+ t0 = src[i]*a + dst[i]*b;
+ t1 = src[i+1]*a + dst[i+1]*b;
+ dst[i] = t0; dst[i+1] = t1;
+
+ t0 = src[i+2]*a + dst[i+2]*b;
+ t1 = src[i+3]*a + dst[i+3]*b;
+ dst[i+2] = t0; dst[i+3] = t1;
+ }
+ #endif
+ for( ; i < len; i++ )
+ {
+ dst[i] = src[i]*a + dst[i]*b;
+ }
+ }
+ else
+ {
+ src += (i * cn);
+ dst += (i * cn);
+ for( ; i < len; i++, src += cn, dst += cn )
+ {
+ if( mask[i] )
+ {
+ for( int k = 0; k < cn; k++ )
+ {
+ dst[k] = src[k]*a + dst[k]*b;
+ }
+ }
+ }
+ }
+}
+
+#if CV_SIMD128
+
+void acc_simd_(const uchar* src, float* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 16;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint8x16 v_src = v_load(src + x);
+ v_uint16x8 v_src0, v_src1;
+ v_expand(v_src, v_src0, v_src1);
+
+ v_uint32x4 v_src00, v_src01, v_src10, v_src11;
+ v_expand(v_src0, v_src00, v_src01);
+ v_expand(v_src1, v_src10, v_src11);
+
+ v_store(dst + x, v_load(dst + x) + v_cvt_f32(v_reinterpret_as_s32(v_src00)));
+ v_store(dst + x + 4, v_load(dst + x + 4) + v_cvt_f32(v_reinterpret_as_s32(v_src01)));
+ v_store(dst + x + 8, v_load(dst + x + 8) + v_cvt_f32(v_reinterpret_as_s32(v_src10)));
+ v_store(dst + x + 12, v_load(dst + x + 12) + v_cvt_f32(v_reinterpret_as_s32(v_src11)));
+ }
+ }
+ else
+ {
+ v_uint8x16 v_0 = v_setall_u8(0);
+ if (cn == 1)
+ {
+ for ( ; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint8x16 v_mask = v_load(mask + x);
+ v_mask = ~(v_0 == v_mask);
+ v_uint8x16 v_src = v_load(src + x);
+ v_src = v_src & v_mask;
+ v_uint16x8 v_src0, v_src1;
+ v_expand(v_src, v_src0, v_src1);
+
+ v_uint32x4 v_src00, v_src01, v_src10, v_src11;
+ v_expand(v_src0, v_src00, v_src01);
+ v_expand(v_src1, v_src10, v_src11);
+
+ v_store(dst + x, v_load(dst + x) + v_cvt_f32(v_reinterpret_as_s32(v_src00)));
+ v_store(dst + x + 4, v_load(dst + x + 4) + v_cvt_f32(v_reinterpret_as_s32(v_src01)));
+ v_store(dst + x + 8, v_load(dst + x + 8) + v_cvt_f32(v_reinterpret_as_s32(v_src10)));
+ v_store(dst + x + 12, v_load(dst + x + 12) + v_cvt_f32(v_reinterpret_as_s32(v_src11)));
+ }
+ }
+ else if (cn == 3)
+ {
+ for ( ; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint8x16 v_mask = v_load(mask + x);
+ v_mask = ~(v_0 == v_mask);
+ v_uint8x16 v_src0, v_src1, v_src2;
+ v_load_deinterleave(src + (x * cn), v_src0, v_src1, v_src2);
+ v_src0 = v_src0 & v_mask;
+ v_src1 = v_src1 & v_mask;
+ v_src2 = v_src2 & v_mask;
+ v_uint16x8 v_src00, v_src01, v_src10, v_src11, v_src20, v_src21;
+ v_expand(v_src0, v_src00, v_src01);
+ v_expand(v_src1, v_src10, v_src11);
+ v_expand(v_src2, v_src20, v_src21);
+
+ v_uint32x4 v_src000, v_src001, v_src010, v_src011;
+ v_uint32x4 v_src100, v_src101, v_src110, v_src111;
+ v_uint32x4 v_src200, v_src201, v_src210, v_src211;
+ v_expand(v_src00, v_src000, v_src001);
+ v_expand(v_src01, v_src010, v_src011);
+ v_expand(v_src10, v_src100, v_src101);
+ v_expand(v_src11, v_src110, v_src111);
+ v_expand(v_src20, v_src200, v_src201);
+ v_expand(v_src21, v_src210, v_src211);
+
+ v_float32x4 v_dst000, v_dst001, v_dst010, v_dst011;
+ v_float32x4 v_dst100, v_dst101, v_dst110, v_dst111;
+ v_float32x4 v_dst200, v_dst201, v_dst210, v_dst211;
+ v_load_deinterleave(dst + (x * cn), v_dst000, v_dst100, v_dst200);
+ v_load_deinterleave(dst + ((x + 4) * cn), v_dst001, v_dst101, v_dst201);
+ v_load_deinterleave(dst + ((x + 8) * cn), v_dst010, v_dst110, v_dst210);
+ v_load_deinterleave(dst + ((x + 12) * cn), v_dst011, v_dst111, v_dst211);
+
+ v_store_interleave(dst + (x * cn), v_dst000 + v_cvt_f32(v_reinterpret_as_s32(v_src000)), v_dst100 + v_cvt_f32(v_reinterpret_as_s32(v_src100)), v_dst200 + v_cvt_f32(v_reinterpret_as_s32(v_src200)));
+ v_store_interleave(dst + ((x + 4) * cn), v_dst001 + v_cvt_f32(v_reinterpret_as_s32(v_src001)), v_dst101 + v_cvt_f32(v_reinterpret_as_s32(v_src101)), v_dst201 + v_cvt_f32(v_reinterpret_as_s32(v_src201)));
+ v_store_interleave(dst + ((x + 8) * cn), v_dst010 + v_cvt_f32(v_reinterpret_as_s32(v_src010)), v_dst110 + v_cvt_f32(v_reinterpret_as_s32(v_src110)), v_dst210 + v_cvt_f32(v_reinterpret_as_s32(v_src210)));
+ v_store_interleave(dst + ((x + 12) * cn), v_dst011 + v_cvt_f32(v_reinterpret_as_s32(v_src011)), v_dst111 + v_cvt_f32(v_reinterpret_as_s32(v_src111)), v_dst211 + v_cvt_f32(v_reinterpret_as_s32(v_src211)));
+ }
+ }
+ }
+
+ acc_general_(src, dst, mask, len, cn, x);
+}
+
+void acc_simd_(const ushort* src, float* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 8;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_src = v_load(src + x);
+ v_uint32x4 v_src0, v_src1;
+ v_expand(v_src, v_src0, v_src1);
+
+ v_store(dst + x, v_load(dst + x) + v_cvt_f32(v_reinterpret_as_s32(v_src0)));
+ v_store(dst + x + 4, v_load(dst + x + 4) + v_cvt_f32(v_reinterpret_as_s32(v_src1)));
+ }
+ }
+ else
+ {
+ if (cn == 1)
+ {
+ v_uint16x8 v_0 = v_setall_u16(0);
+ for ( ; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_mask = v_load_expand(mask + x);
+ v_mask = ~(v_mask == v_0);
+ v_uint16x8 v_src = v_load(src + x);
+ v_src = v_src & v_mask;
+ v_uint32x4 v_src0, v_src1;
+ v_expand(v_src, v_src0, v_src1);
+
+ v_store(dst + x, v_load(dst + x) + v_cvt_f32(v_reinterpret_as_s32(v_src0)));
+ v_store(dst + x + 4, v_load(dst + x + 4) + v_cvt_f32(v_reinterpret_as_s32(v_src1)));
+ }
+ }
+ else if (cn == 3)
+ {
+ v_uint16x8 v_0 = v_setall_u16(0);
+ for ( ; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_mask = v_load_expand(mask + x);
+ v_mask = ~(v_mask == v_0);
+ v_uint16x8 v_src0, v_src1, v_src2;
+ v_load_deinterleave(src + x * cn, v_src0, v_src1, v_src2);
+ v_src0 = v_src0 & v_mask;
+ v_src1 = v_src1 & v_mask;
+ v_src2 = v_src2 & v_mask;
+ v_uint32x4 v_src00, v_src01, v_src10, v_src11, v_src20, v_src21;
+ v_expand(v_src0, v_src00, v_src01);
+ v_expand(v_src1, v_src10, v_src11);
+ v_expand(v_src2, v_src20, v_src21);
+
+ v_float32x4 v_dst00, v_dst01, v_dst10, v_dst11, v_dst20, v_dst21;
+ v_load_deinterleave(dst + x * cn, v_dst00, v_dst10, v_dst20);
+ v_load_deinterleave(dst + (x + 4) * cn, v_dst01, v_dst11, v_dst21);
+
+ v_store_interleave(dst + x * cn, v_dst00 + v_cvt_f32(v_reinterpret_as_s32(v_src00)), v_dst10 + v_cvt_f32(v_reinterpret_as_s32(v_src10)), v_dst20 + v_cvt_f32(v_reinterpret_as_s32(v_src20)));
+ v_store_interleave(dst + (x + 4) * cn, v_dst01 + v_cvt_f32(v_reinterpret_as_s32(v_src01)), v_dst11 + v_cvt_f32(v_reinterpret_as_s32(v_src11)), v_dst21 + v_cvt_f32(v_reinterpret_as_s32(v_src21)));
+ }
+ }
+ }
+
+ acc_general_(src, dst, mask, len, cn, x);
+}
+
+void acc_simd_(const float* src, float* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 8;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_store(dst + x, v_load(dst + x) + v_load(src + x));
+ v_store(dst + x + 4, v_load(dst + x + 4) + v_load(src + x + 4));
+ }
+ }
+ else
+ {
+ v_float32x4 v_0 = v_setzero_f32();
+ if (cn == 1)
+ {
+ for ( ; x <= len - cVectorWidth ; x += cVectorWidth)
+ {
+ v_uint16x8 v_masku16 = v_load_expand(mask + x);
+ v_uint32x4 v_masku320, v_masku321;
+ v_expand(v_masku16, v_masku320, v_masku321);
+ v_float32x4 v_mask0 = v_reinterpret_as_f32(~(v_masku320 == v_reinterpret_as_u32(v_0)));
+ v_float32x4 v_mask1 = v_reinterpret_as_f32(~(v_masku321 == v_reinterpret_as_u32(v_0)));
+
+ v_store(dst + x, v_load(dst + x) + (v_load(src + x) & v_mask0));
+ v_store(dst + x + 4, v_load(dst + x + 4) + (v_load(src + x + 4) & v_mask1));
+ }
+ }
+ else if (cn == 3)
+ {
+ for ( ; x <= len - cVectorWidth ; x += cVectorWidth)
+ {
+ v_uint16x8 v_masku16 = v_load_expand(mask + x);
+ v_uint32x4 v_masku320, v_masku321;
+ v_expand(v_masku16, v_masku320, v_masku321);
+ v_float32x4 v_mask0 = v_reinterpret_as_f32(~(v_masku320 == v_reinterpret_as_u32(v_0)));
+ v_float32x4 v_mask1 = v_reinterpret_as_f32(~(v_masku321 == v_reinterpret_as_u32(v_0)));
+
+ v_float32x4 v_src00, v_src01, v_src10, v_src11, v_src20, v_src21;
+ v_load_deinterleave(src + x * cn, v_src00, v_src10, v_src20);
+ v_load_deinterleave(src + (x + 4) * cn, v_src01, v_src11, v_src21);
+ v_src00 = v_src00 & v_mask0;
+ v_src01 = v_src01 & v_mask1;
+ v_src10 = v_src10 & v_mask0;
+ v_src11 = v_src11 & v_mask1;
+ v_src20 = v_src20 & v_mask0;
+ v_src21 = v_src21 & v_mask1;
+
+ v_float32x4 v_dst00, v_dst01, v_dst10, v_dst11, v_dst20, v_dst21;
+ v_load_deinterleave(dst + x * cn, v_dst00, v_dst10, v_dst20);
+ v_load_deinterleave(dst + (x + 4) * cn, v_dst01, v_dst11, v_dst21);
+
+ v_store_interleave(dst + x * cn, v_dst00 + v_src00, v_dst10 + v_src10, v_dst20 + v_src20);
+ v_store_interleave(dst + (x + 4) * cn, v_dst01 + v_src01, v_dst11 + v_src11, v_dst21 + v_src21);
+ }
+ }
+ }
+
+ acc_general_(src, dst, mask, len, cn, x);
+}
+
+#if CV_SIMD128_64F
+void acc_simd_(const uchar* src, double* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 16;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint8x16 v_src = v_load(src + x);
+ v_uint16x8 v_int0, v_int1;
+ v_expand(v_src, v_int0, v_int1);
+
+ v_uint32x4 v_int00, v_int01, v_int10, v_int11;
+ v_expand(v_int0, v_int00, v_int01);
+ v_expand(v_int1, v_int10, v_int11);
+
+ v_float64x2 v_src0 = v_cvt_f64(v_reinterpret_as_s32(v_int00));
+ v_float64x2 v_src1 = v_cvt_f64_high(v_reinterpret_as_s32(v_int00));
+ v_float64x2 v_src2 = v_cvt_f64(v_reinterpret_as_s32(v_int01));
+ v_float64x2 v_src3 = v_cvt_f64_high(v_reinterpret_as_s32(v_int01));
+ v_float64x2 v_src4 = v_cvt_f64(v_reinterpret_as_s32(v_int10));
+ v_float64x2 v_src5 = v_cvt_f64_high(v_reinterpret_as_s32(v_int10));
+ v_float64x2 v_src6 = v_cvt_f64(v_reinterpret_as_s32(v_int11));
+ v_float64x2 v_src7 = v_cvt_f64_high(v_reinterpret_as_s32(v_int11));
+
+ v_float64x2 v_dst0 = v_load(dst + x);
+ v_float64x2 v_dst1 = v_load(dst + x + 2);
+ v_float64x2 v_dst2 = v_load(dst + x + 4);
+ v_float64x2 v_dst3 = v_load(dst + x + 6);
+ v_float64x2 v_dst4 = v_load(dst + x + 8);
+ v_float64x2 v_dst5 = v_load(dst + x + 10);
+ v_float64x2 v_dst6 = v_load(dst + x + 12);
+ v_float64x2 v_dst7 = v_load(dst + x + 14);
+
+ v_dst0 = v_dst0 + v_src0;
+ v_dst1 = v_dst1 + v_src1;
+ v_dst2 = v_dst2 + v_src2;
+ v_dst3 = v_dst3 + v_src3;
+ v_dst4 = v_dst4 + v_src4;
+ v_dst5 = v_dst5 + v_src5;
+ v_dst6 = v_dst6 + v_src6;
+ v_dst7 = v_dst7 + v_src7;
+
+ v_store(dst + x, v_dst0);
+ v_store(dst + x + 2, v_dst1);
+ v_store(dst + x + 4, v_dst2);
+ v_store(dst + x + 6, v_dst3);
+ v_store(dst + x + 8, v_dst4);
+ v_store(dst + x + 10, v_dst5);
+ v_store(dst + x + 12, v_dst6);
+ v_store(dst + x + 14, v_dst7);
+ }
+ }
+ else
+ {
+ v_uint8x16 v_0 = v_setall_u8(0);
+ if (cn == 1)
+ {
+ for ( ; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint8x16 v_mask = v_load(mask + x);
+ v_mask = ~(v_mask == v_0);
+ v_uint8x16 v_src = v_load(src + x);
+ v_src = v_src & v_mask;
+ v_uint16x8 v_int0, v_int1;
+ v_expand(v_src, v_int0, v_int1);
+
+ v_uint32x4 v_int00, v_int01, v_int10, v_int11;
+ v_expand(v_int0, v_int00, v_int01);
+ v_expand(v_int1, v_int10, v_int11);
+
+ v_float64x2 v_src0 = v_cvt_f64(v_reinterpret_as_s32(v_int00));
+ v_float64x2 v_src1 = v_cvt_f64_high(v_reinterpret_as_s32(v_int00));
+ v_float64x2 v_src2 = v_cvt_f64(v_reinterpret_as_s32(v_int01));
+ v_float64x2 v_src3 = v_cvt_f64_high(v_reinterpret_as_s32(v_int01));
+ v_float64x2 v_src4 = v_cvt_f64(v_reinterpret_as_s32(v_int10));
+ v_float64x2 v_src5 = v_cvt_f64_high(v_reinterpret_as_s32(v_int10));
+ v_float64x2 v_src6 = v_cvt_f64(v_reinterpret_as_s32(v_int11));
+ v_float64x2 v_src7 = v_cvt_f64_high(v_reinterpret_as_s32(v_int11));
+
+ v_float64x2 v_dst0 = v_load(dst + x);
+ v_float64x2 v_dst1 = v_load(dst + x + 2);
+ v_float64x2 v_dst2 = v_load(dst + x + 4);
+ v_float64x2 v_dst3 = v_load(dst + x + 6);
+ v_float64x2 v_dst4 = v_load(dst + x + 8);
+ v_float64x2 v_dst5 = v_load(dst + x + 10);
+ v_float64x2 v_dst6 = v_load(dst + x + 12);
+ v_float64x2 v_dst7 = v_load(dst + x + 14);
+
+ v_dst0 = v_dst0 + v_src0;
+ v_dst1 = v_dst1 + v_src1;
+ v_dst2 = v_dst2 + v_src2;
+ v_dst3 = v_dst3 + v_src3;
+ v_dst4 = v_dst4 + v_src4;
+ v_dst5 = v_dst5 + v_src5;
+ v_dst6 = v_dst6 + v_src6;
+ v_dst7 = v_dst7 + v_src7;
+
+ v_store(dst + x, v_dst0);
+ v_store(dst + x + 2, v_dst1);
+ v_store(dst + x + 4, v_dst2);
+ v_store(dst + x + 6, v_dst3);
+ v_store(dst + x + 8, v_dst4);
+ v_store(dst + x + 10, v_dst5);
+ v_store(dst + x + 12, v_dst6);
+ v_store(dst + x + 14, v_dst7);
+ }
+ }
+ else if (cn == 3)
+ {
+ for ( ; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint8x16 v_mask = v_load(mask + x);
+ v_mask = ~(v_0 == v_mask);
+ v_uint8x16 v_src0, v_src1, v_src2;
+ v_load_deinterleave(src + (x * cn), v_src0, v_src1, v_src2);
+ v_src0 = v_src0 & v_mask;
+ v_src1 = v_src1 & v_mask;
+ v_src2 = v_src2 & v_mask;
+ v_uint16x8 v_src00, v_src01, v_src10, v_src11, v_src20, v_src21;
+ v_expand(v_src0, v_src00, v_src01);
+ v_expand(v_src1, v_src10, v_src11);
+ v_expand(v_src2, v_src20, v_src21);
+
+ v_uint32x4 v_src000, v_src001, v_src010, v_src011;
+ v_uint32x4 v_src100, v_src101, v_src110, v_src111;
+ v_uint32x4 v_src200, v_src201, v_src210, v_src211;
+ v_expand(v_src00, v_src000, v_src001);
+ v_expand(v_src01, v_src010, v_src011);
+ v_expand(v_src10, v_src100, v_src101);
+ v_expand(v_src11, v_src110, v_src111);
+ v_expand(v_src20, v_src200, v_src201);
+ v_expand(v_src21, v_src210, v_src211);
+
+ v_float64x2 v_src0000, v_src0001, v_src0010, v_src0011, v_src0100, v_src0101, v_src0110, v_src0111;
+ v_float64x2 v_src1000, v_src1001, v_src1010, v_src1011, v_src1100, v_src1101, v_src1110, v_src1111;
+ v_float64x2 v_src2000, v_src2001, v_src2010, v_src2011, v_src2100, v_src2101, v_src2110, v_src2111;
+ v_src0000 = v_cvt_f64(v_cvt_f32(v_reinterpret_as_s32(v_src000)));
+ v_src0001 = v_cvt_f64_high(v_cvt_f32(v_reinterpret_as_s32(v_src000)));
+ v_src0010 = v_cvt_f64(v_cvt_f32(v_reinterpret_as_s32(v_src001)));
+ v_src0011 = v_cvt_f64_high(v_cvt_f32(v_reinterpret_as_s32(v_src001)));
+ v_src0100 = v_cvt_f64(v_cvt_f32(v_reinterpret_as_s32(v_src010)));
+ v_src0101 = v_cvt_f64_high(v_cvt_f32(v_reinterpret_as_s32(v_src010)));
+ v_src0110 = v_cvt_f64(v_cvt_f32(v_reinterpret_as_s32(v_src011)));
+ v_src0111 = v_cvt_f64_high(v_cvt_f32(v_reinterpret_as_s32(v_src011)));
+ v_src1000 = v_cvt_f64(v_cvt_f32(v_reinterpret_as_s32(v_src100)));
+ v_src1001 = v_cvt_f64_high(v_cvt_f32(v_reinterpret_as_s32(v_src100)));
+ v_src1010 = v_cvt_f64(v_cvt_f32(v_reinterpret_as_s32(v_src101)));
+ v_src1011 = v_cvt_f64_high(v_cvt_f32(v_reinterpret_as_s32(v_src101)));
+ v_src1100 = v_cvt_f64(v_cvt_f32(v_reinterpret_as_s32(v_src110)));
+ v_src1101 = v_cvt_f64_high(v_cvt_f32(v_reinterpret_as_s32(v_src110)));
+ v_src1110 = v_cvt_f64(v_cvt_f32(v_reinterpret_as_s32(v_src111)));
+ v_src1111 = v_cvt_f64_high(v_cvt_f32(v_reinterpret_as_s32(v_src111)));
+ v_src2000 = v_cvt_f64(v_cvt_f32(v_reinterpret_as_s32(v_src200)));
+ v_src2001 = v_cvt_f64_high(v_cvt_f32(v_reinterpret_as_s32(v_src200)));
+ v_src2010 = v_cvt_f64(v_cvt_f32(v_reinterpret_as_s32(v_src201)));
+ v_src2011 = v_cvt_f64_high(v_cvt_f32(v_reinterpret_as_s32(v_src201)));
+ v_src2100 = v_cvt_f64(v_cvt_f32(v_reinterpret_as_s32(v_src210)));
+ v_src2101 = v_cvt_f64_high(v_cvt_f32(v_reinterpret_as_s32(v_src210)));
+ v_src2110 = v_cvt_f64(v_cvt_f32(v_reinterpret_as_s32(v_src211)));
+ v_src2111 = v_cvt_f64_high(v_cvt_f32(v_reinterpret_as_s32(v_src211)));
+
+ v_float64x2 v_dst0000, v_dst0001, v_dst0010, v_dst0011, v_dst0100, v_dst0101, v_dst0110, v_dst0111;
+ v_float64x2 v_dst1000, v_dst1001, v_dst1010, v_dst1011, v_dst1100, v_dst1101, v_dst1110, v_dst1111;
+ v_float64x2 v_dst2000, v_dst2001, v_dst2010, v_dst2011, v_dst2100, v_dst2101, v_dst2110, v_dst2111;
+ v_load_deinterleave(dst + (x * cn), v_dst0000, v_dst1000, v_dst2000);
+ v_load_deinterleave(dst + ((x + 2) * cn), v_dst0001, v_dst1001, v_dst2001);
+ v_load_deinterleave(dst + ((x + 4) * cn), v_dst0010, v_dst1010, v_dst2010);
+ v_load_deinterleave(dst + ((x + 6) * cn), v_dst0011, v_dst1011, v_dst2011);
+ v_load_deinterleave(dst + ((x + 8) * cn), v_dst0100, v_dst1100, v_dst2100);
+ v_load_deinterleave(dst + ((x + 10) * cn), v_dst0101, v_dst1101, v_dst2101);
+ v_load_deinterleave(dst + ((x + 12) * cn), v_dst0110, v_dst1110, v_dst2110);
+ v_load_deinterleave(dst + ((x + 14) * cn), v_dst0111, v_dst1111, v_dst2111);
+
+ v_store_interleave(dst + (x * cn), v_dst0000 + v_src0000, v_dst1000 + v_src1000, v_dst2000 + v_src2000);
+ v_store_interleave(dst + ((x + 2) * cn), v_dst0001 + v_src0001, v_dst1001 + v_src1001, v_dst2001 + v_src2001);
+ v_store_interleave(dst + ((x + 4) * cn), v_dst0010 + v_src0010, v_dst1010 + v_src1010, v_dst2010 + v_src2010);
+ v_store_interleave(dst + ((x + 6) * cn), v_dst0011 + v_src0011, v_dst1011 + v_src1011, v_dst2011 + v_src2011);
+ v_store_interleave(dst + ((x + 8) * cn), v_dst0100 + v_src0100, v_dst1100 + v_src1100, v_dst2100 + v_src2100);
+ v_store_interleave(dst + ((x + 10) * cn), v_dst0101 + v_src0101, v_dst1101 + v_src1101, v_dst2101 + v_src2101);
+ v_store_interleave(dst + ((x + 12) * cn), v_dst0110 + v_src0110, v_dst1110 + v_src1110, v_dst2110 + v_src2110);
+ v_store_interleave(dst + ((x + 14) * cn), v_dst0111 + v_src0111, v_dst1111 + v_src1111, v_dst2111 + v_src2111);
+ }
+ }
+ }
+
+ acc_general_(src, dst, mask, len, cn, x);
+}
+
+void acc_simd_(const ushort* src, double* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 8;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_src = v_load(src + x);
+ v_uint32x4 v_int0, v_int1;
+ v_expand(v_src, v_int0, v_int1);
+
+ v_float64x2 v_src0 = v_cvt_f64(v_reinterpret_as_s32(v_int0));
+ v_float64x2 v_src1 = v_cvt_f64_high(v_reinterpret_as_s32(v_int0));
+ v_float64x2 v_src2 = v_cvt_f64(v_reinterpret_as_s32(v_int1));
+ v_float64x2 v_src3 = v_cvt_f64_high(v_reinterpret_as_s32(v_int1));
+
+ v_float64x2 v_dst0 = v_load(dst + x);
+ v_float64x2 v_dst1 = v_load(dst + x + 2);
+ v_float64x2 v_dst2 = v_load(dst + x + 4);
+ v_float64x2 v_dst3 = v_load(dst + x + 6);
+
+ v_dst0 = v_dst0 + v_src0;
+ v_dst1 = v_dst1 + v_src1;
+ v_dst2 = v_dst2 + v_src2;
+ v_dst3 = v_dst3 + v_src3;
+
+ v_store(dst + x, v_dst0);
+ v_store(dst + x + 2, v_dst1);
+ v_store(dst + x + 4, v_dst2);
+ v_store(dst + x + 6, v_dst3);
+ }
+ }
+ else
+ {
+ v_uint16x8 v_0 = v_setzero_u16();
+ if (cn == 1)
+ {
+ for ( ; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_mask = v_load_expand(mask + x);
+ v_mask = ~(v_mask == v_0);
+ v_uint16x8 v_src = v_load(src + x);
+ v_src = v_src & v_mask;
+ v_uint32x4 v_int0, v_int1;
+ v_expand(v_src, v_int0, v_int1);
+
+ v_float64x2 v_src0 = v_cvt_f64(v_reinterpret_as_s32(v_int0));
+ v_float64x2 v_src1 = v_cvt_f64_high(v_reinterpret_as_s32(v_int0));
+ v_float64x2 v_src2 = v_cvt_f64(v_reinterpret_as_s32(v_int1));
+ v_float64x2 v_src3 = v_cvt_f64_high(v_reinterpret_as_s32(v_int1));
+
+ v_float64x2 v_dst0 = v_load(dst + x);
+ v_float64x2 v_dst1 = v_load(dst + x + 2);
+ v_float64x2 v_dst2 = v_load(dst + x + 4);
+ v_float64x2 v_dst3 = v_load(dst + x + 6);
+
+ v_dst0 = v_dst0 + v_src0;
+ v_dst1 = v_dst1 + v_src1;
+ v_dst2 = v_dst2 + v_src2;
+ v_dst3 = v_dst3 + v_src3;
+
+ v_store(dst + x, v_dst0);
+ v_store(dst + x + 2, v_dst1);
+ v_store(dst + x + 4, v_dst2);
+ v_store(dst + x + 6, v_dst3);
+ }
+ }
+ if (cn == 3)
+ {
+ for ( ; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_mask = v_load_expand(mask + x);
+ v_mask = ~(v_mask == v_0);
+ v_uint16x8 v_src0, v_src1, v_src2;
+ v_load_deinterleave(src + x * cn, v_src0, v_src1, v_src2);
+ v_src0 = v_src0 & v_mask;
+ v_src1 = v_src1 & v_mask;
+ v_src2 = v_src2 & v_mask;
+ v_uint32x4 v_int00, v_int01, v_int10, v_int11, v_int20, v_int21;
+ v_expand(v_src0, v_int00, v_int01);
+ v_expand(v_src1, v_int10, v_int11);
+ v_expand(v_src2, v_int20, v_int21);
+
+ v_float64x2 v_src00 = v_cvt_f64(v_reinterpret_as_s32(v_int00));
+ v_float64x2 v_src01 = v_cvt_f64_high(v_reinterpret_as_s32(v_int00));
+ v_float64x2 v_src02 = v_cvt_f64(v_reinterpret_as_s32(v_int01));
+ v_float64x2 v_src03 = v_cvt_f64_high(v_reinterpret_as_s32(v_int01));
+ v_float64x2 v_src10 = v_cvt_f64(v_reinterpret_as_s32(v_int10));
+ v_float64x2 v_src11 = v_cvt_f64_high(v_reinterpret_as_s32(v_int10));
+ v_float64x2 v_src12 = v_cvt_f64(v_reinterpret_as_s32(v_int11));
+ v_float64x2 v_src13 = v_cvt_f64_high(v_reinterpret_as_s32(v_int11));
+ v_float64x2 v_src20 = v_cvt_f64(v_reinterpret_as_s32(v_int20));
+ v_float64x2 v_src21 = v_cvt_f64_high(v_reinterpret_as_s32(v_int20));
+ v_float64x2 v_src22 = v_cvt_f64(v_reinterpret_as_s32(v_int21));
+ v_float64x2 v_src23 = v_cvt_f64_high(v_reinterpret_as_s32(v_int21));
+
+ v_float64x2 v_dst00, v_dst01, v_dst02, v_dst03, v_dst10, v_dst11, v_dst12, v_dst13, v_dst20, v_dst21, v_dst22, v_dst23;
+ v_load_deinterleave(dst + x * cn, v_dst00, v_dst10, v_dst20);
+ v_load_deinterleave(dst + (x + 2) * cn, v_dst01, v_dst11, v_dst21);
+ v_load_deinterleave(dst + (x + 4) * cn, v_dst02, v_dst12, v_dst22);
+ v_load_deinterleave(dst + (x + 6) * cn, v_dst03, v_dst13, v_dst23);
+
+ v_store_interleave(dst + x * cn, v_dst00 + v_src00, v_dst10 + v_src10, v_dst20 + v_src20);
+ v_store_interleave(dst + (x + 2) * cn, v_dst01 + v_src01, v_dst11 + v_src11, v_dst21 + v_src21);
+ v_store_interleave(dst + (x + 4) * cn, v_dst02 + v_src02, v_dst12 + v_src12, v_dst22 + v_src22);
+ v_store_interleave(dst + (x + 6) * cn, v_dst03 + v_src03, v_dst13 + v_src13, v_dst23 + v_src23);
+ }
+ }
+ }
+
+ acc_general_(src, dst, mask, len, cn, x);
+}
+
+void acc_simd_(const float* src, double* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 4;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_float32x4 v_src = v_load(src + x);
+ v_float64x2 v_src0 = v_cvt_f64(v_src);
+ v_float64x2 v_src1 = v_cvt_f64_high(v_src);
+
+ v_store(dst + x, v_load(dst + x) + v_src0);
+ v_store(dst + x + 2, v_load(dst + x + 2) + v_src1);
+ }
+ }
+ else
+ {
+ v_uint64x2 v_0 = v_setzero_u64();
+ if (cn == 1)
+ {
+ for ( ; x <= len - cVectorWidth ; x += cVectorWidth)
+ {
+ v_uint32x4 v_masku32 = v_load_expand_q(mask + x);
+ v_uint64x2 v_masku640, v_masku641;
+ v_expand(v_masku32, v_masku640, v_masku641);
+ v_float64x2 v_mask0 = v_reinterpret_as_f64(~(v_masku640 == v_0));
+ v_float64x2 v_mask1 = v_reinterpret_as_f64(~(v_masku641 == v_0));
+
+ v_float32x4 v_src = v_load(src + x);
+ v_float64x2 v_src0 = v_cvt_f64(v_src) & v_mask0;
+ v_float64x2 v_src1 = v_cvt_f64_high(v_src) & v_mask1;
+
+ v_store(dst + x, v_load(dst + x) + v_src0);
+ v_store(dst + x + 2, v_load(dst + x + 2) + v_src1);
+ }
+ }
+ else if (cn == 3)
+ {
+ for ( ; x <= len - cVectorWidth ; x += cVectorWidth)
+ {
+ v_uint32x4 v_masku32 = v_load_expand_q(mask + x);
+ v_uint64x2 v_masku640, v_masku641;
+ v_expand(v_masku32, v_masku640, v_masku641);
+ v_float64x2 v_mask0 = v_reinterpret_as_f64(~(v_masku640 == v_0));
+ v_float64x2 v_mask1 = v_reinterpret_as_f64(~(v_masku641 == v_0));
+
+ v_float32x4 v_src0, v_src1, v_src2;
+ v_load_deinterleave(src + x * cn, v_src0, v_src1, v_src2);
+ v_float64x2 v_src00 = v_cvt_f64(v_src0) & v_mask0;
+ v_float64x2 v_src01 = v_cvt_f64_high(v_src0) & v_mask1;
+ v_float64x2 v_src10 = v_cvt_f64(v_src1) & v_mask0;
+ v_float64x2 v_src11 = v_cvt_f64_high(v_src1) & v_mask1;
+ v_float64x2 v_src20 = v_cvt_f64(v_src2) & v_mask0;
+ v_float64x2 v_src21 = v_cvt_f64_high(v_src2) & v_mask1;
+
+ v_float64x2 v_dst00, v_dst01, v_dst10, v_dst11, v_dst20, v_dst21;
+ v_load_deinterleave(dst + x * cn, v_dst00, v_dst10, v_dst20);
+ v_load_deinterleave(dst + (x + 2) * cn, v_dst01, v_dst11, v_dst21);
+
+ v_store_interleave(dst + x * cn, v_dst00 + v_src00, v_dst10 + v_src10, v_dst20 + v_src20);
+ v_store_interleave(dst + (x + 2) * cn, v_dst01 + v_src01, v_dst11 + v_src11, v_dst21 + v_src21);
+ }
+ }
+ }
+
+ acc_general_(src, dst, mask, len, cn, x);
+}
+
+void acc_simd_(const double* src, double* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 4;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_float64x2 v_src0 = v_load(src + x);
+ v_float64x2 v_src1 = v_load(src + x + 2);
+
+ v_store(dst + x, v_load(dst + x) + v_src0);
+ v_store(dst + x + 2, v_load(dst + x + 2) + v_src1);
+ }
+ }
+ else
+ {
+ v_uint64x2 v_0 = v_setzero_u64();
+ if (cn == 1)
+ {
+ for ( ; x <= len - cVectorWidth ; x += cVectorWidth)
+ {
+ v_uint32x4 v_masku32 = v_load_expand_q(mask + x);
+ v_uint64x2 v_masku640, v_masku641;
+ v_expand(v_masku32, v_masku640, v_masku641);
+ v_float64x2 v_mask0 = v_reinterpret_as_f64(~(v_masku640 == v_0));
+ v_float64x2 v_mask1 = v_reinterpret_as_f64(~(v_masku641 == v_0));
+
+ v_float64x2 v_src0 = v_load(src + x);
+ v_float64x2 v_src1 = v_load(src + x + 2);
+
+ v_store(dst + x, v_load(dst + x) + (v_src0 & v_mask0));
+ v_store(dst + x + 2, v_load(dst + x + 2) + (v_src1 & v_mask1));
+ }
+ }
+ else if (cn == 3)
+ {
+ for ( ; x <= len - cVectorWidth ; x += cVectorWidth)
+ {
+ v_uint32x4 v_masku32 = v_load_expand_q(mask + x);
+ v_uint64x2 v_masku640, v_masku641;
+ v_expand(v_masku32, v_masku640, v_masku641);
+ v_float64x2 v_mask0 = v_reinterpret_as_f64(~(v_masku640 == v_0));
+ v_float64x2 v_mask1 = v_reinterpret_as_f64(~(v_masku641 == v_0));
+
+ v_float64x2 v_src00, v_src10, v_src20, v_src01, v_src11, v_src21;
+ v_load_deinterleave(src + x * cn, v_src00, v_src10, v_src20);
+ v_load_deinterleave(src + (x + 2) * cn, v_src01, v_src11, v_src21);
+ v_src00 = v_src00 & v_mask0;
+ v_src01 = v_src01 & v_mask1;
+ v_src10 = v_src10 & v_mask0;
+ v_src11 = v_src11 & v_mask1;
+ v_src20 = v_src20 & v_mask0;
+ v_src21 = v_src21 & v_mask1;
+
+ v_float64x2 v_dst00, v_dst10, v_dst20, v_dst01, v_dst11, v_dst21;
+ v_load_deinterleave(dst + x * cn, v_dst00, v_dst10, v_dst20);
+ v_load_deinterleave(dst + (x + 2) * cn, v_dst01, v_dst11, v_dst21);
+
+ v_store_interleave(dst + x * cn, v_dst00 + v_src00, v_dst10 + v_src10, v_dst20 + v_src20);
+ v_store_interleave(dst + (x + 2) * cn, v_dst01 + v_src01, v_dst11 + v_src11, v_dst21 + v_src21);
+ }
+ }
+ }
+
+ acc_general_(src, dst, mask, len, cn, x);
+}
+#else
+void acc_simd_(const uchar* src, double* dst, const uchar* mask, int len, int cn)
+{
+ acc_general_(src, dst, mask, len, cn, 0);
+}
+
+void acc_simd_(const ushort* src, double* dst, const uchar* mask, int len, int cn)
+{
+ acc_general_(src, dst, mask, len, cn, 0);
+}
+
+void acc_simd_(const float* src, double* dst, const uchar* mask, int len, int cn)
+{
+ acc_general_(src, dst, mask, len, cn, 0);
+}
+
+void acc_simd_(const double* src, double* dst, const uchar* mask, int len, int cn)
+{
+ acc_general_(src, dst, mask, len, cn, 0);
+}
+#endif
+
+// square accumulate optimized by universal intrinsic
+void accSqr_simd_(const uchar* src, float* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 16;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint8x16 v_src = v_load(src + x);
+ v_uint16x8 v_src0, v_src1;
+ v_expand(v_src, v_src0, v_src1);
+ v_src0 = v_src0 * v_src0;
+ v_src1 = v_src1 * v_src1;
+
+ v_uint32x4 v_src00, v_src01, v_src10, v_src11;
+ v_expand(v_src0, v_src00, v_src01);
+ v_expand(v_src1, v_src10, v_src11);
+
+ v_store(dst + x, v_load(dst + x) + v_cvt_f32(v_reinterpret_as_s32(v_src00)));
+ v_store(dst + x + 4, v_load(dst + x + 4) + v_cvt_f32(v_reinterpret_as_s32(v_src01)));
+ v_store(dst + x + 8, v_load(dst + x + 8) + v_cvt_f32(v_reinterpret_as_s32(v_src10)));
+ v_store(dst + x + 12, v_load(dst + x + 12) + v_cvt_f32(v_reinterpret_as_s32(v_src11)));
+ }
+ }
+ else
+ {
+ v_uint8x16 v_0 = v_setall_u8(0);
+ if (cn == 1)
+ {
+ for ( ; x <= len - cVectorWidth ; x += cVectorWidth)
+ {
+ v_uint8x16 v_mask = v_load(mask + x);
+ v_mask = ~(v_0 == v_mask);
+ v_uint8x16 v_src = v_load(src + x);
+ v_src = v_src & v_mask;
+ v_uint16x8 v_src0, v_src1;
+ v_expand(v_src, v_src0, v_src1);
+ v_src0 = v_src0 * v_src0;
+ v_src1 = v_src1 * v_src1;
+
+ v_uint32x4 v_src00, v_src01, v_src10, v_src11;
+ v_expand(v_src0, v_src00, v_src01);
+ v_expand(v_src1, v_src10, v_src11);
+
+ v_store(dst + x, v_load(dst + x) + v_cvt_f32(v_reinterpret_as_s32(v_src00)));
+ v_store(dst + x + 4, v_load(dst + x + 4) + v_cvt_f32(v_reinterpret_as_s32(v_src01)));
+ v_store(dst + x + 8, v_load(dst + x + 8) + v_cvt_f32(v_reinterpret_as_s32(v_src10)));
+ v_store(dst + x + 12, v_load(dst + x + 12) + v_cvt_f32(v_reinterpret_as_s32(v_src11)));
+ }
+ }
+ else if (cn == 3)
+ {
+ for ( ; x <= len - cVectorWidth ; x += cVectorWidth)
+ {
+ v_uint8x16 v_mask = v_load(mask + x);
+ v_mask = ~(v_0 == v_mask);
+
+ v_uint8x16 v_src0, v_src1, v_src2;
+ v_load_deinterleave(src + x * cn, v_src0, v_src1, v_src2);
+ v_src0 = v_src0 & v_mask;
+ v_src1 = v_src1 & v_mask;
+ v_src2 = v_src2 & v_mask;
+
+ v_uint16x8 v_src00, v_src01, v_src10, v_src11, v_src20, v_src21;
+ v_expand(v_src0, v_src00, v_src01);
+ v_expand(v_src1, v_src10, v_src11);
+ v_expand(v_src2, v_src20, v_src21);
+ v_src00 = v_src00 * v_src00;
+ v_src01 = v_src01 * v_src01;
+ v_src10 = v_src10 * v_src10;
+ v_src11 = v_src11 * v_src11;
+ v_src20 = v_src20 * v_src20;
+ v_src21 = v_src21 * v_src21;
+
+ v_uint32x4 v_src000, v_src001, v_src010, v_src011;
+ v_uint32x4 v_src100, v_src101, v_src110, v_src111;
+ v_uint32x4 v_src200, v_src201, v_src210, v_src211;
+ v_expand(v_src00, v_src000, v_src001);
+ v_expand(v_src01, v_src010, v_src011);
+ v_expand(v_src10, v_src100, v_src101);
+ v_expand(v_src11, v_src110, v_src111);
+ v_expand(v_src20, v_src200, v_src201);
+ v_expand(v_src21, v_src210, v_src211);
+
+ v_float32x4 v_dst000, v_dst001, v_dst010, v_dst011;
+ v_float32x4 v_dst100, v_dst101, v_dst110, v_dst111;
+ v_float32x4 v_dst200, v_dst201, v_dst210, v_dst211;
+ v_load_deinterleave(dst + x * cn, v_dst000, v_dst100, v_dst200);
+ v_load_deinterleave(dst + (x + 4) * cn, v_dst001, v_dst101, v_dst201);
+ v_load_deinterleave(dst + (x + 8) * cn, v_dst010, v_dst110, v_dst210);
+ v_load_deinterleave(dst + (x + 12) * cn, v_dst011, v_dst111, v_dst211);
+
+ v_store_interleave(dst + x * cn, v_dst000 + v_cvt_f32(v_reinterpret_as_s32(v_src000)), v_dst100 + v_cvt_f32(v_reinterpret_as_s32(v_src100)), v_dst200 + v_cvt_f32(v_reinterpret_as_s32(v_src200)));
+ v_store_interleave(dst + (x + 4) * cn, v_dst001 + v_cvt_f32(v_reinterpret_as_s32(v_src001)), v_dst101 + v_cvt_f32(v_reinterpret_as_s32(v_src101)), v_dst201 + v_cvt_f32(v_reinterpret_as_s32(v_src201)));
+ v_store_interleave(dst + (x + 8) * cn, v_dst010 + v_cvt_f32(v_reinterpret_as_s32(v_src010)), v_dst110 + v_cvt_f32(v_reinterpret_as_s32(v_src110)), v_dst210 + v_cvt_f32(v_reinterpret_as_s32(v_src210)));
+ v_store_interleave(dst + (x + 12) * cn, v_dst011 + v_cvt_f32(v_reinterpret_as_s32(v_src011)), v_dst111 + v_cvt_f32(v_reinterpret_as_s32(v_src111)), v_dst211 + v_cvt_f32(v_reinterpret_as_s32(v_src211)));
+ }
+ }
+ }
+
+ accSqr_general_(src, dst, mask, len, cn, x);
+}
+
+void accSqr_simd_(const ushort* src, float* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 8;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_src = v_load(src + x);
+ v_uint32x4 v_src0, v_src1;
+ v_expand(v_src, v_src0, v_src1);
+
+ v_float32x4 v_float0, v_float1;
+ v_float0 = v_cvt_f32(v_reinterpret_as_s32(v_src0));
+ v_float1 = v_cvt_f32(v_reinterpret_as_s32(v_src1));
+ v_float0 = v_float0 * v_float0;
+ v_float1 = v_float1 * v_float1;
+
+ v_store(dst + x, v_load(dst + x) + v_float0);
+ v_store(dst + x + 4, v_load(dst + x + 4) + v_float1);
+ }
+ }
+ else
+ {
+ v_uint32x4 v_0 = v_setzero_u32();
+ if (cn == 1)
+ {
+ for ( ; x <= len - cVectorWidth ; x += cVectorWidth)
+ {
+ v_uint16x8 v_mask16 = v_load_expand(mask + x);
+ v_uint32x4 v_mask0, v_mask1;
+ v_expand(v_mask16, v_mask0, v_mask1);
+ v_mask0 = ~(v_mask0 == v_0);
+ v_mask1 = ~(v_mask1 == v_0);
+ v_uint16x8 v_src = v_load(src + x);
+ v_uint32x4 v_src0, v_src1;
+ v_expand(v_src, v_src0, v_src1);
+ v_src0 = v_src0 & v_mask0;
+ v_src1 = v_src1 & v_mask1;
+
+ v_float32x4 v_float0, v_float1;
+ v_float0 = v_cvt_f32(v_reinterpret_as_s32(v_src0));
+ v_float1 = v_cvt_f32(v_reinterpret_as_s32(v_src1));
+ v_float0 = v_float0 * v_float0;
+ v_float1 = v_float1 * v_float1;
+
+ v_store(dst + x, v_load(dst + x) + v_float0);
+ v_store(dst + x + 4, v_load(dst + x + 4) + v_float1);
+ }
+ }
+ else if (cn == 3)
+ {
+ for ( ; x <= len - cVectorWidth ; x += cVectorWidth)
+ {
+ v_uint16x8 v_mask16 = v_load_expand(mask + x);
+ v_uint32x4 v_mask0, v_mask1;
+ v_expand(v_mask16, v_mask0, v_mask1);
+ v_mask0 = ~(v_mask0 == v_0);
+ v_mask1 = ~(v_mask1 == v_0);
+
+ v_uint16x8 v_src0, v_src1, v_src2;
+ v_load_deinterleave(src + x * cn, v_src0, v_src1, v_src2);
+ v_uint32x4 v_int00, v_int01, v_int10, v_int11, v_int20, v_int21;
+ v_expand(v_src0, v_int00, v_int01);
+ v_expand(v_src1, v_int10, v_int11);
+ v_expand(v_src2, v_int20, v_int21);
+ v_int00 = v_int00 & v_mask0;
+ v_int01 = v_int01 & v_mask1;
+ v_int10 = v_int10 & v_mask0;
+ v_int11 = v_int11 & v_mask1;
+ v_int20 = v_int20 & v_mask0;
+ v_int21 = v_int21 & v_mask1;
+
+ v_float32x4 v_src00, v_src01, v_src10, v_src11, v_src20, v_src21;
+ v_src00 = v_cvt_f32(v_reinterpret_as_s32(v_int00));
+ v_src01 = v_cvt_f32(v_reinterpret_as_s32(v_int01));
+ v_src10 = v_cvt_f32(v_reinterpret_as_s32(v_int10));
+ v_src11 = v_cvt_f32(v_reinterpret_as_s32(v_int11));
+ v_src20 = v_cvt_f32(v_reinterpret_as_s32(v_int20));
+ v_src21 = v_cvt_f32(v_reinterpret_as_s32(v_int21));
+ v_src00 = v_src00 * v_src00;
+ v_src01 = v_src01 * v_src01;
+ v_src10 = v_src10 * v_src10;
+ v_src11 = v_src11 * v_src11;
+ v_src20 = v_src20 * v_src20;
+ v_src21 = v_src21 * v_src21;
+
+ v_float32x4 v_dst00, v_dst01, v_dst10, v_dst11, v_dst20, v_dst21;
+ v_load_deinterleave(dst + x * cn, v_dst00, v_dst10, v_dst20);
+ v_load_deinterleave(dst + (x + 4) * cn, v_dst01, v_dst11, v_dst21);
+
+ v_store_interleave(dst + x * cn, v_dst00 + v_src00, v_dst10 + v_src10, v_dst20 + v_src20);
+ v_store_interleave(dst + (x + 4) * cn, v_dst01 + v_src01, v_dst11 + v_src11, v_dst21 + v_src21);
+ }
+ }
+ }
+
+ accSqr_general_(src, dst, mask, len, cn, x);
+}
+
+void accSqr_simd_(const float* src, float* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 8;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_float32x4 v_src0 = v_load(src + x);
+ v_float32x4 v_src1 = v_load(src + x + 4);
+ v_src0 = v_src0 * v_src0;
+ v_src1 = v_src1 * v_src1;
+
+ v_store(dst + x, v_load(dst + x) + v_src0);
+ v_store(dst + x + 4, v_load(dst + x + 4) + v_src1);
+ }
+ }
+ else
+ {
+ v_uint32x4 v_0 = v_setzero_u32();
+ if (cn == 1)
+ {
+ for (; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_mask16 = v_load_expand(mask + x);
+ v_uint32x4 v_mask_0, v_mask_1;
+ v_expand(v_mask16, v_mask_0, v_mask_1);
+ v_float32x4 v_mask0 = v_reinterpret_as_f32(~(v_mask_0 == v_0));
+ v_float32x4 v_mask1 = v_reinterpret_as_f32(~(v_mask_1 == v_0));
+ v_float32x4 v_src0 = v_load(src + x);
+ v_float32x4 v_src1 = v_load(src + x + 4);
+ v_src0 = v_src0 & v_mask0;
+ v_src1 = v_src1 & v_mask1;
+ v_src0 = v_src0 * v_src0;
+ v_src1 = v_src1 * v_src1;
+
+ v_store(dst + x, v_load(dst + x) + v_src0);
+ v_store(dst + x + 4, v_load(dst + x + 4) + v_src1);
+ }
+ }
+ else if (cn == 3)
+ {
+ for (; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_mask16 = v_load_expand(mask + x);
+ v_uint32x4 v_mask_0, v_mask_1;
+ v_expand(v_mask16, v_mask_0, v_mask_1);
+ v_float32x4 v_mask0 = v_reinterpret_as_f32(~(v_mask_0 == v_0));
+ v_float32x4 v_mask1 = v_reinterpret_as_f32(~(v_mask_1 == v_0));
+
+ v_float32x4 v_src00, v_src10, v_src20, v_src01, v_src11, v_src21;
+ v_load_deinterleave(src + x * cn, v_src00, v_src10, v_src20);
+ v_load_deinterleave(src + (x + 4) * cn, v_src01, v_src11, v_src21);
+ v_src00 = v_src00 & v_mask0;
+ v_src01 = v_src01 & v_mask1;
+ v_src10 = v_src10 & v_mask0;
+ v_src11 = v_src11 & v_mask1;
+ v_src20 = v_src20 & v_mask0;
+ v_src21 = v_src21 & v_mask1;
+ v_src00 = v_src00 * v_src00;
+ v_src01 = v_src01 * v_src01;
+ v_src10 = v_src10 * v_src10;
+ v_src11 = v_src11 * v_src11;
+ v_src20 = v_src20 * v_src20;
+ v_src21 = v_src21 * v_src21;
+
+ v_float32x4 v_dst00, v_dst10, v_dst20, v_dst01, v_dst11, v_dst21;
+ v_load_deinterleave(dst + x * cn, v_dst00, v_dst10, v_dst20);
+ v_load_deinterleave(dst + (x + 4) * cn, v_dst01, v_dst11, v_dst21);
+
+ v_store_interleave(dst + x * cn, v_dst00 + v_src00, v_dst10 + v_src10, v_dst20 + v_src20);
+ v_store_interleave(dst + (x + 4) * cn, v_dst01 + v_src01, v_dst11 + v_src11, v_dst21 + v_src21);
+ }
+ }
+ }
+
+ accSqr_general_(src, dst, mask, len, cn, x);
+}
+#if CV_SIMD128_64F
+void accSqr_simd_(const uchar* src, double* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 8;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_int = v_load_expand(src + x);
+
+ v_uint32x4 v_int0, v_int1;
+ v_expand(v_int, v_int0, v_int1);
+
+ v_float64x2 v_src0 = v_cvt_f64(v_reinterpret_as_s32(v_int0));
+ v_float64x2 v_src1 = v_cvt_f64_high(v_reinterpret_as_s32(v_int0));
+ v_float64x2 v_src2 = v_cvt_f64(v_reinterpret_as_s32(v_int1));
+ v_float64x2 v_src3 = v_cvt_f64_high(v_reinterpret_as_s32(v_int1));
+ v_src0 = v_src0 * v_src0;
+ v_src1 = v_src1 * v_src1;
+ v_src2 = v_src2 * v_src2;
+ v_src3 = v_src3 * v_src3;
+
+ v_float64x2 v_dst0 = v_load(dst + x);
+ v_float64x2 v_dst1 = v_load(dst + x + 2);
+ v_float64x2 v_dst2 = v_load(dst + x + 4);
+ v_float64x2 v_dst3 = v_load(dst + x + 6);
+
+ v_dst0 += v_src0;
+ v_dst1 += v_src1;
+ v_dst2 += v_src2;
+ v_dst3 += v_src3;
+
+ v_store(dst + x, v_dst0);
+ v_store(dst + x + 2, v_dst1);
+ v_store(dst + x + 4, v_dst2);
+ v_store(dst + x + 6, v_dst3);
+ }
+ }
+ else
+ {
+ v_uint16x8 v_0 = v_setzero_u16();
+ if (cn == 1)
+ {
+ for (; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_mask = v_load_expand(mask + x);
+ v_mask = ~(v_mask == v_0);
+ v_uint16x8 v_src = v_load_expand(src + x);
+ v_uint16x8 v_int = v_src & v_mask;
+
+ v_uint32x4 v_int0, v_int1;
+ v_expand(v_int, v_int0, v_int1);
+
+ v_float64x2 v_src0 = v_cvt_f64(v_reinterpret_as_s32(v_int0));
+ v_float64x2 v_src1 = v_cvt_f64_high(v_reinterpret_as_s32(v_int0));
+ v_float64x2 v_src2 = v_cvt_f64(v_reinterpret_as_s32(v_int1));
+ v_float64x2 v_src3 = v_cvt_f64_high(v_reinterpret_as_s32(v_int1));
+ v_src0 = v_src0 * v_src0;
+ v_src1 = v_src1 * v_src1;
+ v_src2 = v_src2 * v_src2;
+ v_src3 = v_src3 * v_src3;
+
+ v_float64x2 v_dst0 = v_load(dst + x);
+ v_float64x2 v_dst1 = v_load(dst + x + 2);
+ v_float64x2 v_dst2 = v_load(dst + x + 4);
+ v_float64x2 v_dst3 = v_load(dst + x + 6);
+
+ v_dst0 += v_src0;
+ v_dst1 += v_src1;
+ v_dst2 += v_src2;
+ v_dst3 += v_src3;
+
+ v_store(dst + x, v_dst0);
+ v_store(dst + x + 2, v_dst1);
+ v_store(dst + x + 4, v_dst2);
+ v_store(dst + x + 6, v_dst3);
+ }
+ }
+ else if (cn == 3)
+ {
+ for (; x <= len - /*cVectorWidth*/16; x += cVectorWidth)
+ {
+ v_uint8x16 v_src0, v_src1, v_src2;
+ v_load_deinterleave(src + x * cn, v_src0, v_src1, v_src2);
+ v_uint16x8 v_int0, v_int1, v_int2, dummy;
+ v_expand(v_src0, v_int0, dummy);
+ v_expand(v_src1, v_int1, dummy);
+ v_expand(v_src2, v_int2, dummy);
+ v_uint16x8 v_mask = v_load_expand(mask + x);
+ v_mask = ~(v_mask == v_0);
+ v_int0 = v_int0 & v_mask;
+ v_int1 = v_int1 & v_mask;
+ v_int2 = v_int2 & v_mask;
+
+ v_uint32x4 v_int00, v_int01, v_int10, v_int11, v_int20, v_int21;
+ v_expand(v_int0, v_int00, v_int01);
+ v_expand(v_int1, v_int10, v_int11);
+ v_expand(v_int2, v_int20, v_int21);
+
+ v_float64x2 v_src00 = v_cvt_f64(v_reinterpret_as_s32(v_int00));
+ v_float64x2 v_src01 = v_cvt_f64_high(v_reinterpret_as_s32(v_int00));
+ v_float64x2 v_src02 = v_cvt_f64(v_reinterpret_as_s32(v_int01));
+ v_float64x2 v_src03 = v_cvt_f64_high(v_reinterpret_as_s32(v_int01));
+ v_float64x2 v_src10 = v_cvt_f64(v_reinterpret_as_s32(v_int10));
+ v_float64x2 v_src11 = v_cvt_f64_high(v_reinterpret_as_s32(v_int10));
+ v_float64x2 v_src12 = v_cvt_f64(v_reinterpret_as_s32(v_int11));
+ v_float64x2 v_src13 = v_cvt_f64_high(v_reinterpret_as_s32(v_int11));
+ v_float64x2 v_src20 = v_cvt_f64(v_reinterpret_as_s32(v_int20));
+ v_float64x2 v_src21 = v_cvt_f64_high(v_reinterpret_as_s32(v_int20));
+ v_float64x2 v_src22 = v_cvt_f64(v_reinterpret_as_s32(v_int21));
+ v_float64x2 v_src23 = v_cvt_f64_high(v_reinterpret_as_s32(v_int21));
+ v_src00 = v_src00 * v_src00;
+ v_src01 = v_src01 * v_src01;
+ v_src02 = v_src02 * v_src02;
+ v_src03 = v_src03 * v_src03;
+ v_src10 = v_src10 * v_src10;
+ v_src11 = v_src11 * v_src11;
+ v_src12 = v_src12 * v_src12;
+ v_src13 = v_src13 * v_src13;
+ v_src20 = v_src20 * v_src20;
+ v_src21 = v_src21 * v_src21;
+ v_src22 = v_src22 * v_src22;
+ v_src23 = v_src23 * v_src23;
+
+ v_float64x2 v_dst00, v_dst01, v_dst02, v_dst03, v_dst10, v_dst11, v_dst12, v_dst13, v_dst20, v_dst21, v_dst22, v_dst23;
+ v_load_deinterleave(dst + x * cn, v_dst00, v_dst10, v_dst20);
+ v_load_deinterleave(dst + (x + 2) * cn, v_dst01, v_dst11, v_dst21);
+ v_load_deinterleave(dst + (x + 4) * cn, v_dst02, v_dst12, v_dst22);
+ v_load_deinterleave(dst + (x + 6) * cn, v_dst03, v_dst13, v_dst23);
+
+ v_store_interleave(dst + x * cn, v_dst00 + v_src00, v_dst10 + v_src10, v_dst20 + v_src20);
+ v_store_interleave(dst + (x + 2) * cn, v_dst01 + v_src01, v_dst11 + v_src11, v_dst21 + v_src21);
+ v_store_interleave(dst + (x + 4) * cn, v_dst02 + v_src02, v_dst12 + v_src12, v_dst22 + v_src22);
+ v_store_interleave(dst + (x + 6) * cn, v_dst03 + v_src03, v_dst13 + v_src13, v_dst23 + v_src23);
+ }
+ }
+ }
+
+ accSqr_general_(src, dst, mask, len, cn, x);
+}
+
+void accSqr_simd_(const ushort* src, double* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 8;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_src = v_load(src + x);
+ v_uint32x4 v_int_0, v_int_1;
+ v_expand(v_src, v_int_0, v_int_1);
+
+ v_int32x4 v_int0 = v_reinterpret_as_s32(v_int_0);
+ v_int32x4 v_int1 = v_reinterpret_as_s32(v_int_1);
+
+ v_float64x2 v_src0 = v_cvt_f64(v_int0);
+ v_float64x2 v_src1 = v_cvt_f64_high(v_int0);
+ v_float64x2 v_src2 = v_cvt_f64(v_int1);
+ v_float64x2 v_src3 = v_cvt_f64_high(v_int1);
+ v_src0 = v_src0 * v_src0;
+ v_src1 = v_src1 * v_src1;
+ v_src2 = v_src2 * v_src2;
+ v_src3 = v_src3 * v_src3;
+
+ v_float64x2 v_dst0 = v_load(dst + x);
+ v_float64x2 v_dst1 = v_load(dst + x + 2);
+ v_float64x2 v_dst2 = v_load(dst + x + 4);
+ v_float64x2 v_dst3 = v_load(dst + x + 6);
+
+ v_dst0 += v_src0;
+ v_dst1 += v_src1;
+ v_dst2 += v_src2;
+ v_dst3 += v_src3;
+
+ v_store(dst + x, v_dst0);
+ v_store(dst + x + 2, v_dst1);
+ v_store(dst + x + 4, v_dst2);
+ v_store(dst + x + 6, v_dst3);
+ }
+ }
+ else
+ {
+ v_uint16x8 v_0 = v_setzero_u16();
+ if (cn == 1)
+ {
+ for (; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_mask = v_load_expand(mask + x);
+ v_mask = ~(v_mask == v_0);
+ v_uint16x8 v_src = v_load(src + x);
+ v_src = v_src & v_mask;
+ v_uint32x4 v_int_0, v_int_1;
+ v_expand(v_src, v_int_0, v_int_1);
+
+ v_int32x4 v_int0 = v_reinterpret_as_s32(v_int_0);
+ v_int32x4 v_int1 = v_reinterpret_as_s32(v_int_1);
+
+ v_float64x2 v_src0 = v_cvt_f64(v_int0);
+ v_float64x2 v_src1 = v_cvt_f64_high(v_int0);
+ v_float64x2 v_src2 = v_cvt_f64(v_int1);
+ v_float64x2 v_src3 = v_cvt_f64_high(v_int1);
+ v_src0 = v_src0 * v_src0;
+ v_src1 = v_src1 * v_src1;
+ v_src2 = v_src2 * v_src2;
+ v_src3 = v_src3 * v_src3;
+
+ v_float64x2 v_dst0 = v_load(dst + x);
+ v_float64x2 v_dst1 = v_load(dst + x + 2);
+ v_float64x2 v_dst2 = v_load(dst + x + 4);
+ v_float64x2 v_dst3 = v_load(dst + x + 6);
+
+ v_dst0 += v_src0;
+ v_dst1 += v_src1;
+ v_dst2 += v_src2;
+ v_dst3 += v_src3;
+
+ v_store(dst + x, v_dst0);
+ v_store(dst + x + 2, v_dst1);
+ v_store(dst + x + 4, v_dst2);
+ v_store(dst + x + 6, v_dst3);
+ }
+ }
+ else if (cn == 3)
+ {
+ for (; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_mask = v_load_expand(mask + x);
+ v_mask = ~(v_mask == v_0);
+ v_uint16x8 v_src0, v_src1, v_src2;
+ v_load_deinterleave(src + x * cn, v_src0, v_src1, v_src2);
+ v_src0 = v_src0 & v_mask;
+ v_src1 = v_src1 & v_mask;
+ v_src2 = v_src2 & v_mask;
+ v_uint32x4 v_int00, v_int01, v_int10, v_int11, v_int20, v_int21;
+ v_expand(v_src0, v_int00, v_int01);
+ v_expand(v_src1, v_int10, v_int11);
+ v_expand(v_src2, v_int20, v_int21);
+
+ v_float64x2 v_src00 = v_cvt_f64(v_reinterpret_as_s32(v_int00));
+ v_float64x2 v_src01 = v_cvt_f64_high(v_reinterpret_as_s32(v_int00));
+ v_float64x2 v_src02 = v_cvt_f64(v_reinterpret_as_s32(v_int01));
+ v_float64x2 v_src03 = v_cvt_f64_high(v_reinterpret_as_s32(v_int01));
+ v_float64x2 v_src10 = v_cvt_f64(v_reinterpret_as_s32(v_int10));
+ v_float64x2 v_src11 = v_cvt_f64_high(v_reinterpret_as_s32(v_int10));
+ v_float64x2 v_src12 = v_cvt_f64(v_reinterpret_as_s32(v_int11));
+ v_float64x2 v_src13 = v_cvt_f64_high(v_reinterpret_as_s32(v_int11));
+ v_float64x2 v_src20 = v_cvt_f64(v_reinterpret_as_s32(v_int20));
+ v_float64x2 v_src21 = v_cvt_f64_high(v_reinterpret_as_s32(v_int20));
+ v_float64x2 v_src22 = v_cvt_f64(v_reinterpret_as_s32(v_int21));
+ v_float64x2 v_src23 = v_cvt_f64_high(v_reinterpret_as_s32(v_int21));
+ v_src00 = v_src00 * v_src00;
+ v_src01 = v_src01 * v_src01;
+ v_src02 = v_src02 * v_src02;
+ v_src03 = v_src03 * v_src03;
+ v_src10 = v_src10 * v_src10;
+ v_src11 = v_src11 * v_src11;
+ v_src12 = v_src12 * v_src12;
+ v_src13 = v_src13 * v_src13;
+ v_src20 = v_src20 * v_src20;
+ v_src21 = v_src21 * v_src21;
+ v_src22 = v_src22 * v_src22;
+ v_src23 = v_src23 * v_src23;
+
+ v_float64x2 v_dst00, v_dst01, v_dst02, v_dst03;
+ v_float64x2 v_dst10, v_dst11, v_dst12, v_dst13;
+ v_float64x2 v_dst20, v_dst21, v_dst22, v_dst23;
+ v_load_deinterleave(dst + x * cn, v_dst00, v_dst10, v_dst20);
+ v_load_deinterleave(dst + (x + 2)* cn, v_dst01, v_dst11, v_dst21);
+ v_load_deinterleave(dst + (x + 4)* cn, v_dst02, v_dst12, v_dst22);
+ v_load_deinterleave(dst + (x + 6)* cn, v_dst03, v_dst13, v_dst23);
+
+ v_store_interleave(dst + x * cn, v_dst00 + v_src00, v_dst10 + v_src10, v_dst20 + v_src20);
+ v_store_interleave(dst + (x + 2) * cn, v_dst01 + v_src01, v_dst11 + v_src11, v_dst21 + v_src21);
+ v_store_interleave(dst + (x + 4) * cn, v_dst02 + v_src02, v_dst12 + v_src12, v_dst22 + v_src22);
+ v_store_interleave(dst + (x + 6) * cn, v_dst03 + v_src03, v_dst13 + v_src13, v_dst23 + v_src23);
+ }
+ }
+ }
+
+ accSqr_general_(src, dst, mask, len, cn, x);
+}
+
+void accSqr_simd_(const float* src, double* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 4;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_float32x4 v_src = v_load(src + x);
+ v_float64x2 v_src0 = v_cvt_f64(v_src);
+ v_float64x2 v_src1 = v_cvt_f64_high(v_src);
+ v_src0 = v_src0 * v_src0;
+ v_src1 = v_src1 * v_src1;
+
+ v_store(dst + x, v_load(dst + x) + v_src0);
+ v_store(dst + x + 2, v_load(dst + x + 2) + v_src1);
+ }
+ }
+ else
+ {
+ v_uint32x4 v_0 = v_setzero_u32();
+ if (cn == 1)
+ {
+ for (; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint32x4 v_mask = v_load_expand_q(mask + x);;
+ v_mask = ~(v_mask == v_0);
+ v_float32x4 v_src = v_load(src + x);
+ v_src = v_src & v_reinterpret_as_f32(v_mask);
+ v_float64x2 v_src0 = v_cvt_f64(v_src);
+ v_float64x2 v_src1 = v_cvt_f64_high(v_src);
+ v_src0 = v_src0 * v_src0;
+ v_src1 = v_src1 * v_src1;
+
+ v_store(dst + x, v_load(dst + x) + v_src0);
+ v_store(dst + x + 2, v_load(dst + x + 2) + v_src1);
+ }
+ }
+ else if (cn == 3)
+ {
+ for (; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint32x4 v_mask = v_load_expand_q(mask + x);
+ v_mask = ~(v_mask == v_0);
+
+ v_float32x4 v_src0, v_src1, v_src2;
+ v_load_deinterleave(src + x * cn, v_src0, v_src1, v_src2);
+ v_src0 = v_src0 & v_reinterpret_as_f32(v_mask);
+ v_src1 = v_src1 & v_reinterpret_as_f32(v_mask);
+ v_src2 = v_src2 & v_reinterpret_as_f32(v_mask);
+
+ v_float64x2 v_src00 = v_cvt_f64(v_src0);
+ v_float64x2 v_src01 = v_cvt_f64_high(v_src0);
+ v_float64x2 v_src10 = v_cvt_f64(v_src1);
+ v_float64x2 v_src11 = v_cvt_f64_high(v_src1);
+ v_float64x2 v_src20 = v_cvt_f64(v_src2);
+ v_float64x2 v_src21 = v_cvt_f64_high(v_src2);
+ v_src00 = v_src00 * v_src00;
+ v_src01 = v_src01 * v_src01;
+ v_src10 = v_src10 * v_src10;
+ v_src11 = v_src11 * v_src11;
+ v_src20 = v_src20 * v_src20;
+ v_src21 = v_src21 * v_src21;
+
+ v_float64x2 v_dst00, v_dst01, v_dst10, v_dst11, v_dst20, v_dst21;
+ v_load_deinterleave(dst + x * cn, v_dst00, v_dst10, v_dst20);
+ v_load_deinterleave(dst + (x + 2) * cn, v_dst01, v_dst11, v_dst21);
+
+ v_store_interleave(dst + x * cn, v_dst00 + v_src00, v_dst10 + v_src10, v_dst20 + v_src20);
+ v_store_interleave(dst + (x + 2) * cn, v_dst01 + v_src01, v_dst11 + v_src11, v_dst21 + v_src21);
+ }
+ }
+ }
+
+ accSqr_general_(src, dst, mask, len, cn, x);
+}
+
+void accSqr_simd_(const double* src, double* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 4;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_float64x2 v_src0 = v_load(src + x);
+ v_float64x2 v_src1 = v_load(src + x + 2);
+ v_src0 = v_src0 * v_src0;
+ v_src1 = v_src1 * v_src1;
+
+ v_store(dst + x, v_load(dst + x) + v_src0);
+ v_store(dst + x + 2, v_load(dst + x + 2) + v_src1);
+ }
+ }
+ else
+ {
+ v_uint64x2 v_0 = v_setzero_u64();
+ if (cn == 1)
+ {
+ for (; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint32x4 v_mask32 = v_load_expand_q(mask + x);
+ v_uint64x2 v_masku640, v_masku641;
+ v_expand(v_mask32, v_masku640, v_masku641);
+ v_float64x2 v_mask0 = v_reinterpret_as_f64(~(v_masku640 == v_0));
+ v_float64x2 v_mask1 = v_reinterpret_as_f64(~(v_masku641 == v_0));
+ v_float64x2 v_src0 = v_load(src + x);
+ v_float64x2 v_src1 = v_load(src + x + 2);
+ v_src0 = v_src0 & v_mask0;
+ v_src1 = v_src1 & v_mask1;
+ v_src0 = v_src0 * v_src0;
+ v_src1 = v_src1 * v_src1;
+
+ v_store(dst + x, v_load(dst + x) + v_src0);
+ v_store(dst + x + 2, v_load(dst + x + 2) + v_src1);
+ }
+ }
+ else if (cn == 3)
+ {
+ for (; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint32x4 v_mask32 = v_load_expand_q(mask + x);
+ v_uint64x2 v_masku640, v_masku641;
+ v_expand(v_mask32, v_masku640, v_masku641);
+ v_float64x2 v_mask0 = v_reinterpret_as_f64(~(v_masku640 == v_0));
+ v_float64x2 v_mask1 = v_reinterpret_as_f64(~(v_masku641 == v_0));
+
+ v_float64x2 v_src00, v_src01, v_src10, v_src11, v_src20, v_src21;
+ v_load_deinterleave(src + x * cn, v_src00, v_src10, v_src20);
+ v_load_deinterleave(src + (x + 2) * cn, v_src01, v_src11, v_src21);
+ v_src00 = v_src00 & v_mask0;
+ v_src01 = v_src01 & v_mask1;
+ v_src10 = v_src10 & v_mask0;
+ v_src11 = v_src11 & v_mask1;
+ v_src20 = v_src20 & v_mask0;
+ v_src21 = v_src21 & v_mask1;
+ v_src00 = v_src00 * v_src00;
+ v_src01 = v_src01 * v_src01;
+ v_src10 = v_src10 * v_src10;
+ v_src11 = v_src11 * v_src11;
+ v_src20 = v_src20 * v_src20;
+ v_src21 = v_src21 * v_src21;
+
+ v_float64x2 v_dst00, v_dst01, v_dst10, v_dst11, v_dst20, v_dst21;
+ v_load_deinterleave(dst + x * cn, v_dst00, v_dst10, v_dst20);
+ v_load_deinterleave(dst + (x + 2) * cn, v_dst01, v_dst11, v_dst21);
+
+ v_store_interleave(dst + x * cn, v_dst00 + v_src00, v_dst10 + v_src10, v_dst20 + v_src20);
+ v_store_interleave(dst + (x + 2) * cn, v_dst01 + v_src01, v_dst11 + v_src11, v_dst21 + v_src21);
+ }
+ }
+ }
+
+ accSqr_general_(src, dst, mask, len, cn, x);
+}
+#else
+void accSqr_simd_(const uchar* src, double* dst, const uchar* mask, int len, int cn)
+{
+ accSqr_general_(src, dst, mask, len, cn, 0);
+}
+
+void accSqr_simd_(const ushort* src, double* dst, const uchar* mask, int len, int cn)
+{
+ accSqr_general_(src, dst, mask, len, cn, 0);
+}
+
+void accSqr_simd_(const float* src, double* dst, const uchar* mask, int len, int cn)
+{
+ accSqr_general_(src, dst, mask, len, cn, 0);
+}
+
+void accSqr_simd_(const double* src, double* dst, const uchar* mask, int len, int cn)
+{
+ accSqr_general_(src, dst, mask, len, cn, 0);
+}
+#endif
+
+// product accumulate optimized by universal intrinsic
+void accProd_simd_(const uchar* src1, const uchar* src2, float* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 16;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint8x16 v_1src = v_load(src1 + x);
+ v_uint8x16 v_2src = v_load(src2 + x);
+
+ v_uint16x8 v_1src0, v_1src1, v_2src0, v_2src1;
+ v_expand(v_1src, v_1src0, v_1src1);
+ v_expand(v_2src, v_2src0, v_2src1);
+
+ v_uint16x8 v_src0, v_src1;
+ v_src0 = v_1src0 * v_2src0;
+ v_src1 = v_1src1 * v_2src1;
+
+ v_uint32x4 v_src00, v_src01, v_src10, v_src11;
+ v_expand(v_src0, v_src00, v_src01);
+ v_expand(v_src1, v_src10, v_src11);
+
+ v_store(dst + x, v_load(dst + x) + v_cvt_f32(v_reinterpret_as_s32(v_src00)));
+ v_store(dst + x + 4, v_load(dst + x + 4) + v_cvt_f32(v_reinterpret_as_s32(v_src01)));
+ v_store(dst + x + 8, v_load(dst + x + 8) + v_cvt_f32(v_reinterpret_as_s32(v_src10)));
+ v_store(dst + x + 12, v_load(dst + x + 12) + v_cvt_f32(v_reinterpret_as_s32(v_src11)));
+ }
+ }
+ else
+ {
+ v_uint8x16 v_0 = v_setzero_u8();
+ if (cn == 1)
+ {
+ for (; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint8x16 v_mask = v_load(mask + x);
+ v_mask = ~(v_mask == v_0);
+ v_uint8x16 v_1src = v_load(src1 + x);
+ v_uint8x16 v_2src = v_load(src2 + x);
+ v_1src = v_1src & v_mask;
+ v_2src = v_2src & v_mask;
+
+ v_uint16x8 v_1src0, v_1src1, v_2src0, v_2src1;
+ v_expand(v_1src, v_1src0, v_1src1);
+ v_expand(v_2src, v_2src0, v_2src1);
+
+ v_uint16x8 v_src0, v_src1;
+ v_src0 = v_1src0 * v_2src0;
+ v_src1 = v_1src1 * v_2src1;
+
+ v_uint32x4 v_src00, v_src01, v_src10, v_src11;
+ v_expand(v_src0, v_src00, v_src01);
+ v_expand(v_src1, v_src10, v_src11);
+
+ v_store(dst + x, v_load(dst + x) + v_cvt_f32(v_reinterpret_as_s32(v_src00)));
+ v_store(dst + x + 4, v_load(dst + x + 4) + v_cvt_f32(v_reinterpret_as_s32(v_src01)));
+ v_store(dst + x + 8, v_load(dst + x + 8) + v_cvt_f32(v_reinterpret_as_s32(v_src10)));
+ v_store(dst + x + 12, v_load(dst + x + 12) + v_cvt_f32(v_reinterpret_as_s32(v_src11)));
+ }
+ }
+ else if (cn == 3)
+ {
+ for (; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint8x16 v_mask = v_load(mask + x);
+ v_mask = ~(v_mask == v_0);
+ v_uint8x16 v_1src0, v_1src1, v_1src2, v_2src0, v_2src1, v_2src2;
+ v_load_deinterleave(src1 + x * cn, v_1src0, v_1src1, v_1src2);
+ v_load_deinterleave(src2 + x * cn, v_2src0, v_2src1, v_2src2);
+ v_1src0 = v_1src0 & v_mask;
+ v_1src1 = v_1src1 & v_mask;
+ v_1src2 = v_1src2 & v_mask;
+ v_2src0 = v_2src0 & v_mask;
+ v_2src1 = v_2src1 & v_mask;
+ v_2src2 = v_2src2 & v_mask;
+
+ v_uint16x8 v_1src00, v_1src01, v_1src10, v_1src11, v_1src20, v_1src21, v_2src00, v_2src01, v_2src10, v_2src11, v_2src20, v_2src21;
+ v_expand(v_1src0, v_1src00, v_1src01);
+ v_expand(v_1src1, v_1src10, v_1src11);
+ v_expand(v_1src2, v_1src20, v_1src21);
+ v_expand(v_2src0, v_2src00, v_2src01);
+ v_expand(v_2src1, v_2src10, v_2src11);
+ v_expand(v_2src2, v_2src20, v_2src21);
+
+ v_uint16x8 v_src00, v_src01, v_src10, v_src11, v_src20, v_src21;
+ v_src00 = v_1src00 * v_2src00;
+ v_src01 = v_1src01 * v_2src01;
+ v_src10 = v_1src10 * v_2src10;
+ v_src11 = v_1src11 * v_2src11;
+ v_src20 = v_1src20 * v_2src20;
+ v_src21 = v_1src21 * v_2src21;
+
+ v_uint32x4 v_src000, v_src001, v_src002, v_src003, v_src100, v_src101, v_src102, v_src103, v_src200, v_src201, v_src202, v_src203;
+ v_expand(v_src00, v_src000, v_src001);
+ v_expand(v_src01, v_src002, v_src003);
+ v_expand(v_src10, v_src100, v_src101);
+ v_expand(v_src11, v_src102, v_src103);
+ v_expand(v_src20, v_src200, v_src201);
+ v_expand(v_src21, v_src202, v_src203);
+
+ v_float32x4 v_dst000, v_dst001, v_dst002, v_dst003, v_dst100, v_dst101, v_dst102, v_dst103, v_dst200, v_dst201, v_dst202, v_dst203;
+ v_load_deinterleave(dst + x * cn, v_dst000, v_dst100, v_dst200);
+ v_load_deinterleave(dst + (x + 4) * cn, v_dst001, v_dst101, v_dst201);
+ v_load_deinterleave(dst + (x + 8) * cn, v_dst002, v_dst102, v_dst202);
+ v_load_deinterleave(dst + (x + 12) * cn, v_dst003, v_dst103, v_dst203);
+ v_dst000 = v_dst000 + v_cvt_f32(v_reinterpret_as_s32(v_src000));
+ v_dst001 = v_dst001 + v_cvt_f32(v_reinterpret_as_s32(v_src001));
+ v_dst002 = v_dst002 + v_cvt_f32(v_reinterpret_as_s32(v_src002));
+ v_dst003 = v_dst003 + v_cvt_f32(v_reinterpret_as_s32(v_src003));
+ v_dst100 = v_dst100 + v_cvt_f32(v_reinterpret_as_s32(v_src100));
+ v_dst101 = v_dst101 + v_cvt_f32(v_reinterpret_as_s32(v_src101));
+ v_dst102 = v_dst102 + v_cvt_f32(v_reinterpret_as_s32(v_src102));
+ v_dst103 = v_dst103 + v_cvt_f32(v_reinterpret_as_s32(v_src103));
+ v_dst200 = v_dst200 + v_cvt_f32(v_reinterpret_as_s32(v_src200));
+ v_dst201 = v_dst201 + v_cvt_f32(v_reinterpret_as_s32(v_src201));
+ v_dst202 = v_dst202 + v_cvt_f32(v_reinterpret_as_s32(v_src202));
+ v_dst203 = v_dst203 + v_cvt_f32(v_reinterpret_as_s32(v_src203));
+
+ v_store_interleave(dst + x * cn, v_dst000, v_dst100, v_dst200);
+ v_store_interleave(dst + (x + 4) * cn, v_dst001, v_dst101, v_dst201);
+ v_store_interleave(dst + (x + 8) * cn, v_dst002, v_dst102, v_dst202);
+ v_store_interleave(dst + (x + 12) * cn, v_dst003, v_dst103, v_dst203);
+ }
+ }
+ }
+
+ accProd_general_(src1, src2, dst, mask, len, cn, x);
+}
+
+void accProd_simd_(const ushort* src1, const ushort* src2, float* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 8;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_1src = v_load(src1 + x);
+ v_uint16x8 v_2src = v_load(src2 + x);
+
+ v_uint32x4 v_1src0, v_1src1, v_2src0, v_2src1;
+ v_expand(v_1src, v_1src0, v_1src1);
+ v_expand(v_2src, v_2src0, v_2src1);
+
+ v_float32x4 v_1float0 = v_cvt_f32(v_reinterpret_as_s32(v_1src0));
+ v_float32x4 v_1float1 = v_cvt_f32(v_reinterpret_as_s32(v_1src1));
+ v_float32x4 v_2float0 = v_cvt_f32(v_reinterpret_as_s32(v_2src0));
+ v_float32x4 v_2float1 = v_cvt_f32(v_reinterpret_as_s32(v_2src1));
+
+ v_float32x4 v_src0 = v_1float0 * v_2float0;
+ v_float32x4 v_src1 = v_1float1 * v_2float1;
+
+ v_store(dst + x, v_load(dst + x) + v_src0);
+ v_store(dst + x + 4, v_load(dst + x + 4) + v_src1);
+ }
+ }
+ else
+ {
+ v_uint16x8 v_0 = v_setzero_u16();
+ if (cn == 1)
+ {
+ for (; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_mask = v_load_expand(mask + x);
+ v_mask = ~(v_0 == v_mask);
+
+ v_uint16x8 v_1src = v_load(src1 + x) & v_mask;
+ v_uint16x8 v_2src = v_load(src2 + x) & v_mask;
+
+ v_uint32x4 v_1src0, v_1src1, v_2src0, v_2src1;
+ v_expand(v_1src, v_1src0, v_1src1);
+ v_expand(v_2src, v_2src0, v_2src1);
+
+ v_float32x4 v_1float0 = v_cvt_f32(v_reinterpret_as_s32(v_1src0));
+ v_float32x4 v_1float1 = v_cvt_f32(v_reinterpret_as_s32(v_1src1));
+ v_float32x4 v_2float0 = v_cvt_f32(v_reinterpret_as_s32(v_2src0));
+ v_float32x4 v_2float1 = v_cvt_f32(v_reinterpret_as_s32(v_2src1));
+
+ v_float32x4 v_src0 = v_1float0 * v_2float0;
+ v_float32x4 v_src1 = v_1float1 * v_2float1;
+
+ v_store(dst + x, v_load(dst + x) + v_src0);
+ v_store(dst + x + 4, v_load(dst + x + 4) + v_src1);
+ }
+ }
+ else if (cn == 3)
+ {
+ for (; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_mask = v_load_expand(mask + x);
+ v_mask = ~(v_0 == v_mask);
+
+ v_uint16x8 v_1src0, v_1src1, v_1src2, v_2src0, v_2src1, v_2src2;
+ v_load_deinterleave(src1 + x * cn, v_1src0, v_1src1, v_1src2);
+ v_load_deinterleave(src2 + x * cn, v_2src0, v_2src1, v_2src2);
+ v_1src0 = v_1src0 & v_mask;
+ v_1src1 = v_1src1 & v_mask;
+ v_1src2 = v_1src2 & v_mask;
+ v_2src0 = v_2src0 & v_mask;
+ v_2src1 = v_2src1 & v_mask;
+ v_2src2 = v_2src2 & v_mask;
+
+ v_uint32x4 v_1src00, v_1src01, v_1src10, v_1src11, v_1src20, v_1src21, v_2src00, v_2src01, v_2src10, v_2src11, v_2src20, v_2src21;
+ v_expand(v_1src0, v_1src00, v_1src01);
+ v_expand(v_1src1, v_1src10, v_1src11);
+ v_expand(v_1src2, v_1src20, v_1src21);
+ v_expand(v_2src0, v_2src00, v_2src01);
+ v_expand(v_2src1, v_2src10, v_2src11);
+ v_expand(v_2src2, v_2src20, v_2src21);
+
+ v_float32x4 v_1float00 = v_cvt_f32(v_reinterpret_as_s32(v_1src00));
+ v_float32x4 v_1float01 = v_cvt_f32(v_reinterpret_as_s32(v_1src01));
+ v_float32x4 v_1float10 = v_cvt_f32(v_reinterpret_as_s32(v_1src10));
+ v_float32x4 v_1float11 = v_cvt_f32(v_reinterpret_as_s32(v_1src11));
+ v_float32x4 v_1float20 = v_cvt_f32(v_reinterpret_as_s32(v_1src20));
+ v_float32x4 v_1float21 = v_cvt_f32(v_reinterpret_as_s32(v_1src21));
+ v_float32x4 v_2float00 = v_cvt_f32(v_reinterpret_as_s32(v_2src00));
+ v_float32x4 v_2float01 = v_cvt_f32(v_reinterpret_as_s32(v_2src01));
+ v_float32x4 v_2float10 = v_cvt_f32(v_reinterpret_as_s32(v_2src10));
+ v_float32x4 v_2float11 = v_cvt_f32(v_reinterpret_as_s32(v_2src11));
+ v_float32x4 v_2float20 = v_cvt_f32(v_reinterpret_as_s32(v_2src20));
+ v_float32x4 v_2float21 = v_cvt_f32(v_reinterpret_as_s32(v_2src21));
+
+ v_float32x4 v_src00 = v_1float00 * v_2float00;
+ v_float32x4 v_src01 = v_1float01 * v_2float01;
+ v_float32x4 v_src10 = v_1float10 * v_2float10;
+ v_float32x4 v_src11 = v_1float11 * v_2float11;
+ v_float32x4 v_src20 = v_1float20 * v_2float20;
+ v_float32x4 v_src21 = v_1float21 * v_2float21;
+
+ v_float32x4 v_dst00, v_dst01, v_dst10, v_dst11, v_dst20, v_dst21;
+ v_load_deinterleave(dst + x * cn, v_dst00, v_dst10, v_dst20);
+ v_load_deinterleave(dst + (x + 4) * cn, v_dst01, v_dst11, v_dst21);
+
+ v_store_interleave(dst + x * cn, v_dst00 + v_src00, v_dst10 + v_src10, v_dst20 + v_src20);
+ v_store_interleave(dst + (x + 4) * cn, v_dst01 + v_src01, v_dst11 + v_src11, v_dst21 + v_src21);
+ }
+ }
+ }
+
+ accProd_general_(src1, src2, dst, mask, len, cn, x);
+}
+
+void accProd_simd_(const float* src1, const float* src2, float* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 8;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_store(dst + x, v_load(dst + x) + v_load(src1 + x) * v_load(src2 + x));
+ v_store(dst + x + 4, v_load(dst + x + 4) + v_load(src1 + x + 4) * v_load(src2 + x + 4));
+ }
+ }
+ else
+ {
+ v_uint32x4 v_0 = v_setzero_u32();
+ if (cn == 1)
+ {
+ for (; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint32x4 v_mask32_0 = v_load_expand_q(mask + x);
+ v_uint32x4 v_mask32_1 = v_load_expand_q(mask + x + 4);
+ v_float32x4 v_mask0 = v_reinterpret_as_f32(~(v_mask32_0 == v_0));
+ v_float32x4 v_mask1 = v_reinterpret_as_f32(~(v_mask32_1 == v_0));
+
+ v_store(dst + x, v_load(dst + x) + ((v_load(src1 + x) * v_load(src2 + x)) & v_mask0));
+ v_store(dst + x + 4, v_load(dst + x + 4) + ((v_load(src1 + x + 4) * v_load(src2 + x + 4)) & v_mask1));
+ }
+ }
+ else if (cn == 3)
+ {
+ for (; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint32x4 v_mask32_0 = v_load_expand_q(mask + x);
+ v_uint32x4 v_mask32_1 = v_load_expand_q(mask + x + 4);
+ v_float32x4 v_mask0 = v_reinterpret_as_f32(~(v_mask32_0 == v_0));
+ v_float32x4 v_mask1 = v_reinterpret_as_f32(~(v_mask32_1 == v_0));
+
+ v_float32x4 v_1src00, v_1src01, v_1src10, v_1src11, v_1src20, v_1src21;
+ v_float32x4 v_2src00, v_2src01, v_2src10, v_2src11, v_2src20, v_2src21;
+ v_load_deinterleave(src1 + x * cn, v_1src00, v_1src10, v_1src20);
+ v_load_deinterleave(src2 + x * cn, v_2src00, v_2src10, v_2src20);
+ v_load_deinterleave(src1 + (x + 4) * cn, v_1src01, v_1src11, v_1src21);
+ v_load_deinterleave(src2 + (x + 4) * cn, v_2src01, v_2src11, v_2src21);
+
+ v_float32x4 v_dst00, v_dst01, v_dst10, v_dst11, v_dst20, v_dst21;
+ v_load_deinterleave(dst + x * cn, v_dst00, v_dst10, v_dst20);
+ v_load_deinterleave(dst + (x + 4) * cn, v_dst01, v_dst11, v_dst21);
+
+ v_store_interleave(dst + x * cn, v_dst00 + ((v_1src00 * v_2src00) & v_mask0), v_dst10 + ((v_1src10 * v_2src10) & v_mask0), v_dst20 + ((v_1src20 * v_2src20) & v_mask0));
+ v_store_interleave(dst + (x + 4) * cn, v_dst01 + ((v_1src01 * v_2src01) & v_mask1), v_dst11 + ((v_1src11 * v_2src11) & v_mask1), v_dst21 + ((v_1src21 * v_2src21) & v_mask1));
+ }
+ }
+ }
+
+ accProd_general_(src1, src2, dst, mask, len, cn, x);
+}
+#if CV_SIMD128_64F
+void accProd_simd_(const uchar* src1, const uchar* src2, double* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 8;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_1int = v_load_expand(src1 + x);
+ v_uint16x8 v_2int = v_load_expand(src2 + x);
+
+ v_uint32x4 v_1int_0, v_1int_1, v_2int_0, v_2int_1;
+ v_expand(v_1int, v_1int_0, v_1int_1);
+ v_expand(v_2int, v_2int_0, v_2int_1);
+
+ v_int32x4 v_1int0 = v_reinterpret_as_s32(v_1int_0);
+ v_int32x4 v_1int1 = v_reinterpret_as_s32(v_1int_1);
+ v_int32x4 v_2int0 = v_reinterpret_as_s32(v_2int_0);
+ v_int32x4 v_2int1 = v_reinterpret_as_s32(v_2int_1);
+
+ v_float64x2 v_src0 = v_cvt_f64(v_1int0) * v_cvt_f64(v_2int0);
+ v_float64x2 v_src1 = v_cvt_f64_high(v_1int0) * v_cvt_f64_high(v_2int0);
+ v_float64x2 v_src2 = v_cvt_f64(v_1int1) * v_cvt_f64(v_2int1);
+ v_float64x2 v_src3 = v_cvt_f64_high(v_1int1) * v_cvt_f64_high(v_2int1);
+
+ v_float64x2 v_dst0 = v_load(dst + x);
+ v_float64x2 v_dst1 = v_load(dst + x + 2);
+ v_float64x2 v_dst2 = v_load(dst + x + 4);
+ v_float64x2 v_dst3 = v_load(dst + x + 6);
+
+ v_dst0 += v_src0;
+ v_dst1 += v_src1;
+ v_dst2 += v_src2;
+ v_dst3 += v_src3;
+
+ v_store(dst + x, v_dst0);
+ v_store(dst + x + 2, v_dst1);
+ v_store(dst + x + 4, v_dst2);
+ v_store(dst + x + 6, v_dst3);
+ }
+ }
+ else
+ {
+ v_uint16x8 v_0 = v_setzero_u16();
+ if (cn == 1)
+ {
+ for (; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_mask = v_load_expand(mask + x);
+ v_mask = ~(v_mask == v_0);
+ v_uint16x8 v_1int = v_load_expand(src1 + x) & v_mask;
+ v_uint16x8 v_2int = v_load_expand(src2 + x) & v_mask;
+
+ v_uint32x4 v_1int_0, v_1int_1, v_2int_0, v_2int_1;
+ v_expand(v_1int, v_1int_0, v_1int_1);
+ v_expand(v_2int, v_2int_0, v_2int_1);
+
+ v_int32x4 v_1int0 = v_reinterpret_as_s32(v_1int_0);
+ v_int32x4 v_1int1 = v_reinterpret_as_s32(v_1int_1);
+ v_int32x4 v_2int0 = v_reinterpret_as_s32(v_2int_0);
+ v_int32x4 v_2int1 = v_reinterpret_as_s32(v_2int_1);
+
+ v_float64x2 v_src0 = v_cvt_f64(v_1int0) * v_cvt_f64(v_2int0);
+ v_float64x2 v_src1 = v_cvt_f64_high(v_1int0) * v_cvt_f64_high(v_2int0);
+ v_float64x2 v_src2 = v_cvt_f64(v_1int1) * v_cvt_f64(v_2int1);
+ v_float64x2 v_src3 = v_cvt_f64_high(v_1int1) * v_cvt_f64_high(v_2int1);
+
+ v_float64x2 v_dst0 = v_load(dst + x);
+ v_float64x2 v_dst1 = v_load(dst + x + 2);
+ v_float64x2 v_dst2 = v_load(dst + x + 4);
+ v_float64x2 v_dst3 = v_load(dst + x + 6);
+
+ v_dst0 += v_src0;
+ v_dst1 += v_src1;
+ v_dst2 += v_src2;
+ v_dst3 += v_src3;
+
+ v_store(dst + x, v_dst0);
+ v_store(dst + x + 2, v_dst1);
+ v_store(dst + x + 4, v_dst2);
+ v_store(dst + x + 6, v_dst3);
+ }
+ }
+ else if (cn == 3)
+ {
+ for (; x <= len - /*cVectorWidth*/16; x += cVectorWidth)
+ {
+ v_uint8x16 v_1src0, v_1src1, v_1src2, v_2src0, v_2src1, v_2src2;
+ v_load_deinterleave(src1 + x * cn, v_1src0, v_1src1, v_1src2);
+ v_load_deinterleave(src2 + x * cn, v_2src0, v_2src1, v_2src2);
+
+ v_uint16x8 v_1int0, v_1int1, v_1int2, v_2int0, v_2int1, v_2int2, dummy;
+ v_expand(v_1src0, v_1int0, dummy);
+ v_expand(v_1src1, v_1int1, dummy);
+ v_expand(v_1src2, v_1int2, dummy);
+ v_expand(v_2src0, v_2int0, dummy);
+ v_expand(v_2src1, v_2int1, dummy);
+ v_expand(v_2src2, v_2int2, dummy);
+
+ v_uint16x8 v_mask = v_load_expand(mask + x);
+ v_mask = ~(v_mask == v_0);
+ v_1int0 = v_1int0 & v_mask;
+ v_1int1 = v_1int1 & v_mask;
+ v_1int2 = v_1int2 & v_mask;
+ v_2int0 = v_2int0 & v_mask;
+ v_2int1 = v_2int1 & v_mask;
+ v_2int2 = v_2int2 & v_mask;
+
+ v_uint32x4 v_1int00, v_1int01, v_1int10, v_1int11, v_1int20, v_1int21;
+ v_uint32x4 v_2int00, v_2int01, v_2int10, v_2int11, v_2int20, v_2int21;
+ v_expand(v_1int0, v_1int00, v_1int01);
+ v_expand(v_1int1, v_1int10, v_1int11);
+ v_expand(v_1int2, v_1int20, v_1int21);
+ v_expand(v_2int0, v_2int00, v_2int01);
+ v_expand(v_2int1, v_2int10, v_2int11);
+ v_expand(v_2int2, v_2int20, v_2int21);
+
+ v_float64x2 v_src00 = v_cvt_f64(v_reinterpret_as_s32(v_1int00)) * v_cvt_f64(v_reinterpret_as_s32(v_2int00));
+ v_float64x2 v_src01 = v_cvt_f64_high(v_reinterpret_as_s32(v_1int00)) * v_cvt_f64_high(v_reinterpret_as_s32(v_2int00));
+ v_float64x2 v_src02 = v_cvt_f64(v_reinterpret_as_s32(v_1int01)) * v_cvt_f64(v_reinterpret_as_s32(v_2int01));
+ v_float64x2 v_src03 = v_cvt_f64_high(v_reinterpret_as_s32(v_1int01)) * v_cvt_f64_high(v_reinterpret_as_s32(v_2int01));
+ v_float64x2 v_src10 = v_cvt_f64(v_reinterpret_as_s32(v_1int10)) * v_cvt_f64(v_reinterpret_as_s32(v_2int10));
+ v_float64x2 v_src11 = v_cvt_f64_high(v_reinterpret_as_s32(v_1int10)) * v_cvt_f64_high(v_reinterpret_as_s32(v_2int10));
+ v_float64x2 v_src12 = v_cvt_f64(v_reinterpret_as_s32(v_1int11)) * v_cvt_f64(v_reinterpret_as_s32(v_2int11));
+ v_float64x2 v_src13 = v_cvt_f64_high(v_reinterpret_as_s32(v_1int11)) * v_cvt_f64_high(v_reinterpret_as_s32(v_2int11));
+ v_float64x2 v_src20 = v_cvt_f64(v_reinterpret_as_s32(v_1int20)) * v_cvt_f64(v_reinterpret_as_s32(v_2int20));
+ v_float64x2 v_src21 = v_cvt_f64_high(v_reinterpret_as_s32(v_1int20)) * v_cvt_f64_high(v_reinterpret_as_s32(v_2int20));
+ v_float64x2 v_src22 = v_cvt_f64(v_reinterpret_as_s32(v_1int21)) * v_cvt_f64(v_reinterpret_as_s32(v_2int21));
+ v_float64x2 v_src23 = v_cvt_f64_high(v_reinterpret_as_s32(v_1int21)) * v_cvt_f64_high(v_reinterpret_as_s32(v_2int21));
+
+ v_float64x2 v_dst00, v_dst01, v_dst02, v_dst03, v_dst10, v_dst11, v_dst12, v_dst13, v_dst20, v_dst21, v_dst22, v_dst23;
+ v_load_deinterleave(dst + x * cn, v_dst00, v_dst10, v_dst20);
+ v_load_deinterleave(dst + (x + 2) * cn, v_dst01, v_dst11, v_dst21);
+ v_load_deinterleave(dst + (x + 4) * cn, v_dst02, v_dst12, v_dst22);
+ v_load_deinterleave(dst + (x + 6) * cn, v_dst03, v_dst13, v_dst23);
+
+ v_store_interleave(dst + x * cn, v_dst00 + v_src00, v_dst10 + v_src10, v_dst20 + v_src20);
+ v_store_interleave(dst + (x + 2) * cn, v_dst01 + v_src01, v_dst11 + v_src11, v_dst21 + v_src21);
+ v_store_interleave(dst + (x + 4) * cn, v_dst02 + v_src02, v_dst12 + v_src12, v_dst22 + v_src22);
+ v_store_interleave(dst + (x + 6) * cn, v_dst03 + v_src03, v_dst13 + v_src13, v_dst23 + v_src23);
+ }
+ }
+ }
+
+ accProd_general_(src1, src2, dst, mask, len, cn, x);
+}
+
+void accProd_simd_(const ushort* src1, const ushort* src2, double* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 8;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_1src = v_load(src1 + x);
+ v_uint16x8 v_2src = v_load(src2 + x);
+
+ v_uint32x4 v_1int_0, v_1int_1, v_2int_0, v_2int_1;
+ v_expand(v_1src, v_1int_0, v_1int_1);
+ v_expand(v_2src, v_2int_0, v_2int_1);
+
+ v_int32x4 v_1int0 = v_reinterpret_as_s32(v_1int_0);
+ v_int32x4 v_1int1 = v_reinterpret_as_s32(v_1int_1);
+ v_int32x4 v_2int0 = v_reinterpret_as_s32(v_2int_0);
+ v_int32x4 v_2int1 = v_reinterpret_as_s32(v_2int_1);
+
+ v_float64x2 v_src0 = v_cvt_f64(v_1int0) * v_cvt_f64(v_2int0);
+ v_float64x2 v_src1 = v_cvt_f64_high(v_1int0) * v_cvt_f64_high(v_2int0);
+ v_float64x2 v_src2 = v_cvt_f64(v_1int1) * v_cvt_f64(v_2int1);
+ v_float64x2 v_src3 = v_cvt_f64_high(v_1int1) * v_cvt_f64_high(v_2int1);
+
+ v_float64x2 v_dst0 = v_load(dst + x);
+ v_float64x2 v_dst1 = v_load(dst + x + 2);
+ v_float64x2 v_dst2 = v_load(dst + x + 4);
+ v_float64x2 v_dst3 = v_load(dst + x + 6);
+
+ v_dst0 = v_dst0 + v_src0;
+ v_dst1 = v_dst1 + v_src1;
+ v_dst2 = v_dst2 + v_src2;
+ v_dst3 = v_dst3 + v_src3;
+ v_store(dst + x, v_dst0);
+ v_store(dst + x + 2, v_dst1);
+ v_store(dst + x + 4, v_dst2);
+ v_store(dst + x + 6, v_dst3);
+ }
+ }
+ else
+ {
+ v_uint16x8 v_0 = v_setzero_u16();
+ if (cn == 1)
+ {
+ for (; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_mask = v_load_expand(mask + x);
+ v_mask = ~(v_mask == v_0);
+ v_uint16x8 v_1src = v_load(src1 + x);
+ v_uint16x8 v_2src = v_load(src2 + x);
+ v_1src = v_1src & v_mask;
+ v_2src = v_2src & v_mask;
+
+ v_uint32x4 v_1int_0, v_1int_1, v_2int_0, v_2int_1;
+ v_expand(v_1src, v_1int_0, v_1int_1);
+ v_expand(v_2src, v_2int_0, v_2int_1);
+
+ v_int32x4 v_1int0 = v_reinterpret_as_s32(v_1int_0);
+ v_int32x4 v_1int1 = v_reinterpret_as_s32(v_1int_1);
+ v_int32x4 v_2int0 = v_reinterpret_as_s32(v_2int_0);
+ v_int32x4 v_2int1 = v_reinterpret_as_s32(v_2int_1);
+
+ v_float64x2 v_src0 = v_cvt_f64(v_1int0) * v_cvt_f64(v_2int0);
+ v_float64x2 v_src1 = v_cvt_f64_high(v_1int0) * v_cvt_f64_high(v_2int0);
+ v_float64x2 v_src2 = v_cvt_f64(v_1int1) * v_cvt_f64(v_2int1);
+ v_float64x2 v_src3 = v_cvt_f64_high(v_1int1) * v_cvt_f64_high(v_2int1);
+
+ v_float64x2 v_dst0 = v_load(dst + x);
+ v_float64x2 v_dst1 = v_load(dst + x + 2);
+ v_float64x2 v_dst2 = v_load(dst + x + 4);
+ v_float64x2 v_dst3 = v_load(dst + x + 6);
+
+ v_dst0 = v_dst0 + v_src0;
+ v_dst1 = v_dst1 + v_src1;
+ v_dst2 = v_dst2 + v_src2;
+ v_dst3 = v_dst3 + v_src3;
+ v_store(dst + x, v_dst0);
+ v_store(dst + x + 2, v_dst1);
+ v_store(dst + x + 4, v_dst2);
+ v_store(dst + x + 6, v_dst3);
+ }
+ }
+ else if (cn == 3)
+ {
+ for (; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_mask = v_load_expand(mask + x);
+ v_mask = ~(v_mask == v_0);
+ v_uint16x8 v_1src0, v_1src1, v_1src2, v_2src0, v_2src1, v_2src2;
+ v_load_deinterleave(src1 + x * cn, v_1src0, v_1src1, v_1src2);
+ v_load_deinterleave(src2 + x * cn, v_2src0, v_2src1, v_2src2);
+ v_1src0 = v_1src0 & v_mask;
+ v_1src1 = v_1src1 & v_mask;
+ v_1src2 = v_1src2 & v_mask;
+ v_2src0 = v_2src0 & v_mask;
+ v_2src1 = v_2src1 & v_mask;
+ v_2src2 = v_2src2 & v_mask;
+
+ v_uint32x4 v_1int_00, v_1int_01, v_2int_00, v_2int_01;
+ v_uint32x4 v_1int_10, v_1int_11, v_2int_10, v_2int_11;
+ v_uint32x4 v_1int_20, v_1int_21, v_2int_20, v_2int_21;
+ v_expand(v_1src0, v_1int_00, v_1int_01);
+ v_expand(v_1src1, v_1int_10, v_1int_11);
+ v_expand(v_1src2, v_1int_20, v_1int_21);
+ v_expand(v_2src0, v_2int_00, v_2int_01);
+ v_expand(v_2src1, v_2int_10, v_2int_11);
+ v_expand(v_2src2, v_2int_20, v_2int_21);
+
+ v_int32x4 v_1int00 = v_reinterpret_as_s32(v_1int_00);
+ v_int32x4 v_1int01 = v_reinterpret_as_s32(v_1int_01);
+ v_int32x4 v_1int10 = v_reinterpret_as_s32(v_1int_10);
+ v_int32x4 v_1int11 = v_reinterpret_as_s32(v_1int_11);
+ v_int32x4 v_1int20 = v_reinterpret_as_s32(v_1int_20);
+ v_int32x4 v_1int21 = v_reinterpret_as_s32(v_1int_21);
+ v_int32x4 v_2int00 = v_reinterpret_as_s32(v_2int_00);
+ v_int32x4 v_2int01 = v_reinterpret_as_s32(v_2int_01);
+ v_int32x4 v_2int10 = v_reinterpret_as_s32(v_2int_10);
+ v_int32x4 v_2int11 = v_reinterpret_as_s32(v_2int_11);
+ v_int32x4 v_2int20 = v_reinterpret_as_s32(v_2int_20);
+ v_int32x4 v_2int21 = v_reinterpret_as_s32(v_2int_21);
+
+ v_float64x2 v_src00 = v_cvt_f64(v_1int00) * v_cvt_f64(v_2int00);
+ v_float64x2 v_src01 = v_cvt_f64_high(v_1int00) * v_cvt_f64_high(v_2int00);
+ v_float64x2 v_src02 = v_cvt_f64(v_1int01) * v_cvt_f64(v_2int01);
+ v_float64x2 v_src03 = v_cvt_f64_high(v_1int01) * v_cvt_f64_high(v_2int01);
+ v_float64x2 v_src10 = v_cvt_f64(v_1int10) * v_cvt_f64(v_2int10);
+ v_float64x2 v_src11 = v_cvt_f64_high(v_1int10) * v_cvt_f64_high(v_2int10);
+ v_float64x2 v_src12 = v_cvt_f64(v_1int11) * v_cvt_f64(v_2int11);
+ v_float64x2 v_src13 = v_cvt_f64_high(v_1int11) * v_cvt_f64_high(v_2int11);
+ v_float64x2 v_src20 = v_cvt_f64(v_1int20) * v_cvt_f64(v_2int20);
+ v_float64x2 v_src21 = v_cvt_f64_high(v_1int20) * v_cvt_f64_high(v_2int20);
+ v_float64x2 v_src22 = v_cvt_f64(v_1int21) * v_cvt_f64(v_2int21);
+ v_float64x2 v_src23 = v_cvt_f64_high(v_1int21) * v_cvt_f64_high(v_2int21);
+
+ v_float64x2 v_dst00, v_dst01, v_dst02, v_dst03;
+ v_float64x2 v_dst10, v_dst11, v_dst12, v_dst13;
+ v_float64x2 v_dst20, v_dst21, v_dst22, v_dst23;
+ v_load_deinterleave(dst + x * cn, v_dst00, v_dst10, v_dst20);
+ v_load_deinterleave(dst + (x + 2) * cn, v_dst01, v_dst11, v_dst21);
+ v_load_deinterleave(dst + (x + 4) * cn, v_dst02, v_dst12, v_dst22);
+ v_load_deinterleave(dst + (x + 6) * cn, v_dst03, v_dst13, v_dst23);
+
+ v_store_interleave(dst + x * cn, v_dst00 + v_src00, v_dst10 + v_src10, v_dst20 + v_src20);
+ v_store_interleave(dst + (x + 2) * cn, v_dst01 + v_src01, v_dst11 + v_src11, v_dst21 + v_src21);
+ v_store_interleave(dst + (x + 4) * cn, v_dst02 + v_src02, v_dst12 + v_src12, v_dst22 + v_src22);
+ v_store_interleave(dst + (x + 6) * cn, v_dst03 + v_src03, v_dst13 + v_src13, v_dst23 + v_src23);
+ }
+ }
+ }
+
+ accProd_general_(src1, src2, dst, mask, len, cn, x);
+}
+
+void accProd_simd_(const float* src1, const float* src2, double* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 4;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_float32x4 v_1src = v_load(src1 + x);
+ v_float32x4 v_2src = v_load(src2 + x);
+
+ v_float64x2 v_1src0 = v_cvt_f64(v_1src);
+ v_float64x2 v_1src1 = v_cvt_f64_high(v_1src);
+ v_float64x2 v_2src0 = v_cvt_f64(v_2src);
+ v_float64x2 v_2src1 = v_cvt_f64_high(v_2src);
+
+ v_store(dst + x, v_load(dst + x) + (v_1src0 * v_2src0));
+ v_store(dst + x + 2, v_load(dst + x + 2) + (v_1src1 * v_2src1));
+ }
+ }
+ else
+ {
+ v_uint32x4 v_0 = v_setzero_u32();
+ if (cn == 1)
+ {
+ for (; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint32x4 v_mask = v_load_expand_q(mask + x);
+ v_mask = ~(v_mask == v_0);
+ v_float32x4 v_1src = v_load(src1 + x);
+ v_float32x4 v_2src = v_load(src2 + x);
+ v_1src = v_1src & v_reinterpret_as_f32(v_mask);
+ v_2src = v_2src & v_reinterpret_as_f32(v_mask);
+
+ v_float64x2 v_1src0 = v_cvt_f64(v_1src);
+ v_float64x2 v_1src1 = v_cvt_f64_high(v_1src);
+ v_float64x2 v_2src0 = v_cvt_f64(v_2src);
+ v_float64x2 v_2src1 = v_cvt_f64_high(v_2src);
+
+ v_store(dst + x, v_load(dst + x) + (v_1src0 * v_2src0));
+ v_store(dst + x + 2, v_load(dst + x + 2) + (v_1src1 * v_2src1));
+ }
+ }
+ else if (cn == 3)
+ {
+ for (; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint32x4 v_mask = v_load_expand_q(mask + x);
+ v_mask = ~(v_mask == v_0);
+ v_float32x4 v_1src0, v_1src1, v_1src2, v_2src0, v_2src1, v_2src2;
+ v_load_deinterleave(src1 + x * cn, v_1src0, v_1src1, v_1src2);
+ v_load_deinterleave(src2 + x * cn, v_2src0, v_2src1, v_2src2);
+ v_1src0 = v_1src0 & v_reinterpret_as_f32(v_mask);
+ v_1src1 = v_1src1 & v_reinterpret_as_f32(v_mask);
+ v_1src2 = v_1src2 & v_reinterpret_as_f32(v_mask);
+ v_2src0 = v_2src0 & v_reinterpret_as_f32(v_mask);
+ v_2src1 = v_2src1 & v_reinterpret_as_f32(v_mask);
+ v_2src2 = v_2src2 & v_reinterpret_as_f32(v_mask);
+
+ v_float64x2 v_src00 = v_cvt_f64(v_1src0) * v_cvt_f64(v_2src0);
+ v_float64x2 v_src01 = v_cvt_f64_high(v_1src0) * v_cvt_f64_high(v_2src0);
+ v_float64x2 v_src10 = v_cvt_f64(v_1src1) * v_cvt_f64(v_2src1);
+ v_float64x2 v_src11 = v_cvt_f64_high(v_1src1) * v_cvt_f64_high(v_2src1);
+ v_float64x2 v_src20 = v_cvt_f64(v_1src2) * v_cvt_f64(v_2src2);
+ v_float64x2 v_src21 = v_cvt_f64_high(v_1src2) * v_cvt_f64_high(v_2src2);
+
+ v_float64x2 v_dst00, v_dst01, v_dst10, v_dst11, v_dst20, v_dst21;
+ v_load_deinterleave(dst + x * cn, v_dst00, v_dst10, v_dst20);
+ v_load_deinterleave(dst + (x + 2) * cn, v_dst01, v_dst11, v_dst21);
+
+ v_store_interleave(dst + x * cn, v_dst00 + v_src00, v_dst10 + v_src10, v_dst20 + v_src20);
+ v_store_interleave(dst + (x + 2) * cn, v_dst01 + v_src01, v_dst11 + v_src11, v_dst21 + v_src21);
+ }
+ }
+ }
+
+ accProd_general_(src1, src2, dst, mask, len, cn, x);
+}
+
+void accProd_simd_(const double* src1, const double* src2, double* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 4;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_float64x2 v_src00 = v_load(src1 + x);
+ v_float64x2 v_src01 = v_load(src1 + x + 2);
+ v_float64x2 v_src10 = v_load(src2 + x);
+ v_float64x2 v_src11 = v_load(src2 + x + 2);
+
+ v_store(dst + x, v_load(dst + x) + (v_src00 * v_src10));
+ v_store(dst + x + 2, v_load(dst + x + 2) + (v_src01 * v_src11));
+ }
+ }
+ else
+ {
+ v_uint64x2 v_0 = v_setzero_u64();
+ if (cn == 1)
+ {
+ for (; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint32x4 v_mask32 = v_load_expand_q(mask + x);
+ v_uint64x2 v_masku640, v_masku641;
+ v_expand(v_mask32, v_masku640, v_masku641);
+ v_float64x2 v_mask0 = v_reinterpret_as_f64(~(v_masku640 == v_0));
+ v_float64x2 v_mask1 = v_reinterpret_as_f64(~(v_masku641 == v_0));
+
+ v_float64x2 v_src00 = v_load(src1 + x);
+ v_float64x2 v_src01 = v_load(src1 + x + 2);
+ v_float64x2 v_src10 = v_load(src2 + x);
+ v_float64x2 v_src11 = v_load(src2 + x + 2);
+
+ v_store(dst + x, v_load(dst + x) + ((v_src00 * v_src10) & v_mask0));
+ v_store(dst + x + 2, v_load(dst + x + 2) + ((v_src01 * v_src11) & v_mask1));
+ }
+ }
+ else if (cn == 3)
+ {
+ for (; x <= len - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint32x4 v_mask32 = v_load_expand_q(mask + x);
+ v_uint64x2 v_masku640, v_masku641;
+ v_expand(v_mask32, v_masku640, v_masku641);
+ v_float64x2 v_mask0 = v_reinterpret_as_f64(~(v_masku640 == v_0));
+ v_float64x2 v_mask1 = v_reinterpret_as_f64(~(v_masku641 == v_0));
+
+ v_float64x2 v_1src00, v_1src01, v_1src10, v_1src11, v_1src20, v_1src21;
+ v_float64x2 v_2src00, v_2src01, v_2src10, v_2src11, v_2src20, v_2src21;
+ v_load_deinterleave(src1 + x * cn, v_1src00, v_1src10, v_1src20);
+ v_load_deinterleave(src1 + (x + 2) * cn, v_1src01, v_1src11, v_1src21);
+ v_load_deinterleave(src2 + x * cn, v_2src00, v_2src10, v_2src20);
+ v_load_deinterleave(src2 + (x + 2) * cn, v_2src01, v_2src11, v_2src21);
+ v_float64x2 v_src00 = (v_1src00 & v_mask0) * v_2src00;
+ v_float64x2 v_src01 = (v_1src01 & v_mask1) * v_2src01;
+ v_float64x2 v_src10 = (v_1src10 & v_mask0) * v_2src10;
+ v_float64x2 v_src11 = (v_1src11 & v_mask1) * v_2src11;
+ v_float64x2 v_src20 = (v_1src20 & v_mask0) * v_2src20;
+ v_float64x2 v_src21 = (v_1src21 & v_mask1) * v_2src21;
+
+ v_float64x2 v_dst00, v_dst01, v_dst10, v_dst11, v_dst20, v_dst21;
+ v_load_deinterleave(dst + x * cn, v_dst00, v_dst10, v_dst20);
+ v_load_deinterleave(dst + (x + 2) * cn, v_dst01, v_dst11, v_dst21);
+
+ v_store_interleave(dst + x * cn, v_dst00 + v_src00, v_dst10 + v_src10, v_dst20 + v_src20);
+ v_store_interleave(dst + (x + 2) * cn, v_dst01 + v_src01, v_dst11 + v_src11, v_dst21 + v_src21);
+ }
+ }
+ }
+
+ accProd_general_(src1, src2, dst, mask, len, cn, x);
+}
+#else
+void accProd_simd_(const uchar* src1, const uchar* src2, double* dst, const uchar* mask, int len, int cn)
+{
+ accProd_general_(src1, src2, dst, mask, len, cn, 0);
+}
+
+void accProd_simd_(const ushort* src1, const ushort* src2, double* dst, const uchar* mask, int len, int cn)
+{
+ accProd_general_(src1, src2, dst, mask, len, cn, 0);
+}
+
+void accProd_simd_(const float* src1, const float* src2, double* dst, const uchar* mask, int len, int cn)
+{
+ accProd_general_(src1, src2, dst, mask, len, cn, 0);
+}
+
+void accProd_simd_(const double* src1, const double* src2, double* dst, const uchar* mask, int len, int cn)
+{
+ accProd_general_(src1, src2, dst, mask, len, cn, 0);
+}
+#endif
+
+// running weight accumulate optimized by universal intrinsic
+void accW_simd_(const uchar* src, float* dst, const uchar* mask, int len, int cn, double alpha)
+{
+ int x = 0;
+ const v_float32x4 v_alpha = v_setall_f32((float)alpha);
+ const v_float32x4 v_beta = v_setall_f32((float)(1.0f - alpha));
+ const int cVectorWidth = 16;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint8x16 v_src = v_load(src + x);
+
+ v_uint16x8 v_src0, v_src1;
+ v_expand(v_src, v_src0, v_src1);
+
+ v_uint32x4 v_src00, v_src01, v_src10, v_src11;
+ v_expand(v_src0, v_src00, v_src01);
+ v_expand(v_src1, v_src10, v_src11);
+
+ v_float32x4 v_dst00 = v_load(dst + x);
+ v_float32x4 v_dst01 = v_load(dst + x + 4);
+ v_float32x4 v_dst10 = v_load(dst + x + 8);
+ v_float32x4 v_dst11 = v_load(dst + x + 12);
+
+ v_dst00 = (v_dst00 * v_beta) + (v_cvt_f32(v_reinterpret_as_s32(v_src00)) * v_alpha);
+ v_dst01 = (v_dst01 * v_beta) + (v_cvt_f32(v_reinterpret_as_s32(v_src01)) * v_alpha);
+ v_dst10 = (v_dst10 * v_beta) + (v_cvt_f32(v_reinterpret_as_s32(v_src10)) * v_alpha);
+ v_dst11 = (v_dst11 * v_beta) + (v_cvt_f32(v_reinterpret_as_s32(v_src11)) * v_alpha);
+
+ v_store(dst + x, v_dst00);
+ v_store(dst + x + 4, v_dst01);
+ v_store(dst + x + 8, v_dst10);
+ v_store(dst + x + 12, v_dst11);
+ }
+ }
+
+ accW_general_(src, dst, mask, len, cn, alpha, x);
+}
+
+void accW_simd_(const ushort* src, float* dst, const uchar* mask, int len, int cn, double alpha)
+{
+ int x = 0;
+ const v_float32x4 v_alpha = v_setall_f32((float)alpha);
+ const v_float32x4 v_beta = v_setall_f32((float)(1.0f - alpha));
+ const int cVectorWidth = 8;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_src = v_load(src + x);
+ v_uint32x4 v_int0, v_int1;
+ v_expand(v_src, v_int0, v_int1);
+
+ v_float32x4 v_src0 = v_cvt_f32(v_reinterpret_as_s32(v_int0));
+ v_float32x4 v_src1 = v_cvt_f32(v_reinterpret_as_s32(v_int1));
+ v_src0 = v_src0 * v_alpha;
+ v_src1 = v_src1 * v_alpha;
+
+ v_float32x4 v_dst0 = v_load(dst + x) * v_beta;
+ v_float32x4 v_dst1 = v_load(dst + x + 4) * v_beta;
+
+ v_store(dst + x, v_dst0 + v_src0);
+ v_store(dst + x + 4, v_dst1 + v_src1);
+ }
+ }
+
+ accW_general_(src, dst, mask, len, cn, alpha, x);
+}
+
+void accW_simd_(const float* src, float* dst, const uchar* mask, int len, int cn, double alpha)
+{
+ int x = 0;
+ const v_float32x4 v_alpha = v_setall_f32((float)alpha);
+ const v_float32x4 v_beta = v_setall_f32((float)(1.0f - alpha));
+ const int cVectorWidth = 8;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_store(dst + x, ((v_load(dst + x) * v_beta) + (v_load(src + x) * v_alpha)));
+ v_store(dst + x + 4, ((v_load(dst + x + 4) * v_beta) + (v_load(src + x + 4) * v_alpha)));
+ }
+ }
+
+ accW_general_(src, dst, mask, len, cn, alpha, x);
+}
+#if CV_SIMD128_64F
+void accW_simd_(const uchar* src, double* dst, const uchar* mask, int len, int cn, double alpha)
+{
+ int x = 0;
+ const v_float64x2 v_alpha = v_setall_f64(alpha);
+ const v_float64x2 v_beta = v_setall_f64(1.0f - alpha);
+ const int cVectorWidth = 8;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_src16 = v_load_expand(src + x);
+
+ v_uint32x4 v_int_0, v_int_1;
+ v_expand(v_src16, v_int_0, v_int_1);
+
+ v_int32x4 v_int0 = v_reinterpret_as_s32(v_int_0);
+ v_int32x4 v_int1 = v_reinterpret_as_s32(v_int_1);
+
+ v_float64x2 v_src0 = v_cvt_f64(v_int0);
+ v_float64x2 v_src1 = v_cvt_f64_high(v_int0);
+ v_float64x2 v_src2 = v_cvt_f64(v_int1);
+ v_float64x2 v_src3 = v_cvt_f64_high(v_int1);
+
+ v_float64x2 v_dst0 = v_load(dst + x);
+ v_float64x2 v_dst1 = v_load(dst + x + 2);
+ v_float64x2 v_dst2 = v_load(dst + x + 4);
+ v_float64x2 v_dst3 = v_load(dst + x + 6);
+
+ v_dst0 = (v_dst0 * v_beta) + (v_src0 * v_alpha);
+ v_dst1 = (v_dst1 * v_beta) + (v_src1 * v_alpha);
+ v_dst2 = (v_dst2 * v_beta) + (v_src2 * v_alpha);
+ v_dst3 = (v_dst3 * v_beta) + (v_src3 * v_alpha);
+
+ v_store(dst + x, v_dst0);
+ v_store(dst + x + 2, v_dst1);
+ v_store(dst + x + 4, v_dst2);
+ v_store(dst + x + 6, v_dst3);
+ }
+ }
+
+ accW_general_(src, dst, mask, len, cn, alpha, x);
+}
+
+void accW_simd_(const ushort* src, double* dst, const uchar* mask, int len, int cn, double alpha)
+{
+ int x = 0;
+ const v_float64x2 v_alpha = v_setall_f64(alpha);
+ const v_float64x2 v_beta = v_setall_f64(1.0f - alpha);
+ const int cVectorWidth = 8;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_uint16x8 v_src = v_load(src + x);
+ v_uint32x4 v_int_0, v_int_1;
+ v_expand(v_src, v_int_0, v_int_1);
+
+ v_int32x4 v_int0 = v_reinterpret_as_s32(v_int_0);
+ v_int32x4 v_int1 = v_reinterpret_as_s32(v_int_1);
+
+ v_float64x2 v_src00 = v_cvt_f64(v_int0);
+ v_float64x2 v_src01 = v_cvt_f64_high(v_int0);
+ v_float64x2 v_src10 = v_cvt_f64(v_int1);
+ v_float64x2 v_src11 = v_cvt_f64_high(v_int1);
+
+ v_float64x2 v_dst00 = v_load(dst + x);
+ v_float64x2 v_dst01 = v_load(dst + x + 2);
+ v_float64x2 v_dst10 = v_load(dst + x + 4);
+ v_float64x2 v_dst11 = v_load(dst + x + 6);
+
+ v_dst00 = (v_dst00 * v_beta) + (v_src00 * v_alpha);
+ v_dst01 = (v_dst01 * v_beta) + (v_src01 * v_alpha);
+ v_dst10 = (v_dst10 * v_beta) + (v_src10 * v_alpha);
+ v_dst11 = (v_dst11 * v_beta) + (v_src11 * v_alpha);
+
+ v_store(dst + x, v_dst00);
+ v_store(dst + x + 2, v_dst01);
+ v_store(dst + x + 4, v_dst10);
+ v_store(dst + x + 6, v_dst11);
+ }
+ }
+
+ accW_general_(src, dst, mask, len, cn, alpha, x);
+}
+
+void accW_simd_(const float* src, double* dst, const uchar* mask, int len, int cn, double alpha)
+{
+ int x = 0;
+ const v_float64x2 v_alpha = v_setall_f64(alpha);
+ const v_float64x2 v_beta = v_setall_f64(1.0f - alpha);
+ const int cVectorWidth = 8;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_float32x4 v_src0 = v_load(src + x);
+ v_float32x4 v_src1 = v_load(src + x + 4);
+ v_float64x2 v_src00 = v_cvt_f64(v_src0);
+ v_float64x2 v_src01 = v_cvt_f64_high(v_src0);
+ v_float64x2 v_src10 = v_cvt_f64(v_src1);
+ v_float64x2 v_src11 = v_cvt_f64_high(v_src1);
+
+ v_store(dst + x, ((v_load(dst + x) * v_beta) + (v_src00 * v_alpha)));
+ v_store(dst + x + 2, ((v_load(dst + x + 2) * v_beta) + (v_src01 * v_alpha)));
+ v_store(dst + x + 4, ((v_load(dst + x + 4) * v_beta) + (v_src10 * v_alpha)));
+ v_store(dst + x + 6, ((v_load(dst + x + 6) * v_beta) + (v_src11 * v_alpha)));
+ }
+ }
+
+ accW_general_(src, dst, mask, len, cn, alpha, x);
+}
+
+void accW_simd_(const double* src, double* dst, const uchar* mask, int len, int cn, double alpha)
+{
+ int x = 0;
+ const v_float64x2 v_alpha = v_setall_f64(alpha);
+ const v_float64x2 v_beta = v_setall_f64(1.0f - alpha);
+ const int cVectorWidth = 4;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for (; x <= size - cVectorWidth; x += cVectorWidth)
+ {
+ v_float64x2 v_src0 = v_load(src + x);
+ v_float64x2 v_src1 = v_load(src + x + 2);
+
+ v_store(dst + x, ((v_load(dst + x) * v_beta) + (v_src0 * v_alpha)));
+ v_store(dst + x + 2, ((v_load(dst + x + 2) * v_beta) + (v_src1 * v_alpha)));
+ }
+ }
+
+ accW_general_(src, dst, mask, len, cn, alpha, x);
+}
+#else
+void accW_simd_(const uchar* src, double* dst, const uchar* mask, int len, int cn, double alpha)
+{
+ accW_general_(src, dst, mask, len, cn, alpha, 0);
+}
+
+void accW_simd_(const ushort* src, double* dst, const uchar* mask, int len, int cn, double alpha)
+{
+ accW_general_(src, dst, mask, len, cn, alpha, 0);
+}
+
+void accW_simd_(const float* src, double* dst, const uchar* mask, int len, int cn, double alpha)
+{
+ accW_general_(src, dst, mask, len, cn, alpha, 0);
+}
+
+void accW_simd_(const double* src, double* dst, const uchar* mask, int len, int cn, double alpha)
+{
+ accW_general_(src, dst, mask, len, cn, alpha, 0);
+}
+#endif // CV_SIMD128_64F
+#endif // CV_SIMD128
+#if CV_AVX
+// accumulate optimized by AVX
+void acc_avx_32f(const float* src, float* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 8;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for ( ; x <= size - cVectorWidth ; x += cVectorWidth)
+ {
+ __m256 v_src = _mm256_loadu_ps(src + x);
+ __m256 v_dst = _mm256_loadu_ps(dst + x);
+ v_dst = _mm256_add_ps(v_src, v_dst);
+ _mm256_storeu_ps(dst + x, v_dst);
+ }
+ acc_general_(src, dst, mask, len, cn, x);
+ }
+ else
+ {
+ acc_simd_(src, dst, mask, len, cn);
+ }
+}
+
+void acc_avx_32f64f(const float* src, double* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 8;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for ( ; x <= size - cVectorWidth ; x += cVectorWidth)
+ {
+ __m256 v_src = _mm256_loadu_ps(src + x);
+ __m256d v_src0 = _mm256_cvtps_pd(_mm256_extractf128_ps(v_src, 0));
+ __m256d v_src1 = _mm256_cvtps_pd(_mm256_extractf128_ps(v_src, 1));
+ __m256d v_dst0 = _mm256_loadu_pd(dst + x);
+ __m256d v_dst1 = _mm256_loadu_pd(dst + x + 4);
+ v_dst0 = _mm256_add_pd(v_src0, v_dst0);
+ v_dst1 = _mm256_add_pd(v_src1, v_dst1);
+ _mm256_storeu_pd(dst + x, v_dst0);
+ _mm256_storeu_pd(dst + x + 4, v_dst1);
+ }
+ acc_general_(src, dst, mask, len, cn, x);
+ }
+ else
+ {
+ acc_simd_(src, dst, mask, len, cn);
+ }
+}
+
+void acc_avx_64f(const double* src, double* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 4;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for ( ; x <= size - cVectorWidth ; x += cVectorWidth)
+ {
+ __m256d v_src = _mm256_loadu_pd(src + x);
+ __m256d v_dst = _mm256_loadu_pd(dst + x);
+ v_dst = _mm256_add_pd(v_dst, v_src);
+ _mm256_storeu_pd(dst + x, v_dst);
+ }
+ acc_general_(src, dst, mask, len, cn, x);
+ }
+ else
+ {
+ acc_simd_(src, dst, mask, len, cn);
+ }
+}
+
+// square accumulate optimized by avx
+void accSqr_avx_32f(const float* src, float* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 8;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for ( ; x <= size - cVectorWidth ; x += cVectorWidth)
+ {
+ __m256 v_src = _mm256_loadu_ps(src + x);
+ __m256 v_dst = _mm256_loadu_ps(dst + x);
+ v_src = _mm256_mul_ps(v_src, v_src);
+ v_dst = _mm256_add_ps(v_src, v_dst);
+ _mm256_storeu_ps(dst + x, v_dst);
+ }
+ accSqr_general_(src, dst, mask, len, cn, x);
+ }
+ else
+ {
+ accSqr_simd_(src, dst, mask, len, cn);
+ }
+}
+
+void accSqr_avx_32f64f(const float* src, double* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 8;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for ( ; x <= size - cVectorWidth ; x += cVectorWidth)
+ {
+ __m256 v_src = _mm256_loadu_ps(src + x);
+ __m256d v_src0 = _mm256_cvtps_pd(_mm256_extractf128_ps(v_src,0));
+ __m256d v_src1 = _mm256_cvtps_pd(_mm256_extractf128_ps(v_src,1));
+ __m256d v_dst0 = _mm256_loadu_pd(dst + x);
+ __m256d v_dst1 = _mm256_loadu_pd(dst + x + 4);
+ v_src0 = _mm256_mul_pd(v_src0, v_src0);
+ v_src1 = _mm256_mul_pd(v_src1, v_src1);
+ v_dst0 = _mm256_add_pd(v_src0, v_dst0);
+ v_dst1 = _mm256_add_pd(v_src1, v_dst1);
+ _mm256_storeu_pd(dst + x, v_dst0);
+ _mm256_storeu_pd(dst + x + 4, v_dst1);
+ }
+ accSqr_general_(src, dst, mask, len, cn, x);
+ }
+ else
+ {
+ accSqr_simd_(src, dst, mask, len, cn);
+ }
+}
+
+void accSqr_avx_64f(const double* src, double* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 4;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for ( ; x <= size - cVectorWidth ; x += cVectorWidth)
+ {
+ __m256d v_src = _mm256_loadu_pd(src + x);
+ __m256d v_dst = _mm256_loadu_pd(dst + x);
+ v_src = _mm256_mul_pd(v_src, v_src);
+ v_dst = _mm256_add_pd(v_dst, v_src);
+ _mm256_storeu_pd(dst + x, v_dst);
+ }
+ accSqr_general_(src, dst, mask, len, cn, x);
+ }
+ else
+ {
+ accSqr_simd_(src, dst, mask, len, cn);
+ }
+}
+
+// product accumulate optimized by avx
+void accProd_avx_32f(const float* src1, const float* src2, float* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 8;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for ( ; x <= size - cVectorWidth ; x += cVectorWidth)
+ {
+ __m256 v_src0 = _mm256_loadu_ps(src1 + x);
+ __m256 v_src1 = _mm256_loadu_ps(src2 + x);
+ __m256 v_dst = _mm256_loadu_ps(dst + x);
+ __m256 v_src = _mm256_mul_ps(v_src0, v_src1);
+ v_dst = _mm256_add_ps(v_src, v_dst);
+ _mm256_storeu_ps(dst + x, v_dst);
+ }
+ accProd_general_(src1, src2, dst, mask, len, cn, x);
+ }
+ else
+ {
+ accProd_simd_(src1, src2, dst, mask, len, cn);
+ }
+}
+
+void accProd_avx_32f64f(const float* src1, const float* src2, double* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 8;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for ( ; x <= size - cVectorWidth ; x += cVectorWidth)
+ {
+ __m256 v_1src = _mm256_loadu_ps(src1 + x);
+ __m256 v_2src = _mm256_loadu_ps(src2 + x);
+ __m256d v_src00 = _mm256_cvtps_pd(_mm256_extractf128_ps(v_1src,0));
+ __m256d v_src01 = _mm256_cvtps_pd(_mm256_extractf128_ps(v_1src,1));
+ __m256d v_src10 = _mm256_cvtps_pd(_mm256_extractf128_ps(v_2src,0));
+ __m256d v_src11 = _mm256_cvtps_pd(_mm256_extractf128_ps(v_2src,1));
+ __m256d v_dst0 = _mm256_loadu_pd(dst + x);
+ __m256d v_dst1 = _mm256_loadu_pd(dst + x + 4);
+ __m256d v_src0 = _mm256_mul_pd(v_src00, v_src10);
+ __m256d v_src1 = _mm256_mul_pd(v_src01, v_src11);
+ v_dst0 = _mm256_add_pd(v_src0, v_dst0);
+ v_dst1 = _mm256_add_pd(v_src1, v_dst1);
+ _mm256_storeu_pd(dst + x, v_dst0);
+ _mm256_storeu_pd(dst + x + 4, v_dst1);
+ }
+ accProd_general_(src1, src2, dst, mask, len, cn, x);
+ }
+ else
+ {
+ accProd_simd_(src1, src2, dst, mask, len, cn);
+ }
+}
+
+void accProd_avx_64f(const double* src1, const double* src2, double* dst, const uchar* mask, int len, int cn)
+{
+ int x = 0;
+ const int cVectorWidth = 4;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for ( ; x <= size - cVectorWidth ; x += cVectorWidth)
+ {
+ __m256d v_src0 = _mm256_loadu_pd(src1 + x);
+ __m256d v_src1 = _mm256_loadu_pd(src2 + x);
+ __m256d v_dst = _mm256_loadu_pd(dst + x);
+ v_src0 = _mm256_mul_pd(v_src0, v_src1);
+ v_dst = _mm256_add_pd(v_dst, v_src0);
+ _mm256_storeu_pd(dst + x, v_dst);
+ }
+ accProd_general_(src1, src2, dst, mask, len, cn, x);
+ }
+ else
+ {
+ accProd_simd_(src1, src2, dst, mask, len, cn);
+ }
+}
+
+// running weight accumulate optimized by avx
+void accW_avx_32f(const float* src, float* dst, const uchar* mask, int len, int cn, double alpha)
+{
+ int x = 0;
+ const __m256 v_alpha = _mm256_set1_ps((float)alpha);
+ const __m256 v_beta = _mm256_set1_ps((float)(1.0f - alpha));
+ const int cVectorWidth = 16;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for ( ; x <= size - cVectorWidth ; x += cVectorWidth)
+ {
+ _mm256_storeu_ps(dst + x, _mm256_add_ps(_mm256_mul_ps(_mm256_loadu_ps(dst + x), v_beta), _mm256_mul_ps(_mm256_loadu_ps(src + x), v_alpha)));
+ _mm256_storeu_ps(dst + x + 8, _mm256_add_ps(_mm256_mul_ps(_mm256_loadu_ps(dst + x + 8), v_beta), _mm256_mul_ps(_mm256_loadu_ps(src + x + 8), v_alpha)));
+ }
+ accW_general_(src, dst, mask, len, cn, alpha, x);
+ }
+ else
+ {
+ accW_simd_(src, dst, mask, len, cn, alpha);
+ }
+
+}
+
+void accW_avx_32f64f(const float* src, double* dst, const uchar* mask, int len, int cn, double alpha)
+{
+ int x = 0;
+ const __m256d v_alpha = _mm256_set1_pd(alpha);
+ const __m256d v_beta = _mm256_set1_pd(1.0f - alpha);
+ const int cVectorWidth = 16;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for ( ; x <= size - cVectorWidth ; x += cVectorWidth)
+ {
+ __m256 v_src0 = _mm256_loadu_ps(src + x);
+ __m256 v_src1 = _mm256_loadu_ps(src + x + 8);
+ __m256d v_src00 = _mm256_cvtps_pd(_mm256_extractf128_ps(v_src0,0));
+ __m256d v_src01 = _mm256_cvtps_pd(_mm256_extractf128_ps(v_src0,1));
+ __m256d v_src10 = _mm256_cvtps_pd(_mm256_extractf128_ps(v_src1,0));
+ __m256d v_src11 = _mm256_cvtps_pd(_mm256_extractf128_ps(v_src1,1));
+
+ _mm256_storeu_pd(dst + x, _mm256_add_pd(_mm256_mul_pd(_mm256_loadu_pd(dst + x), v_beta), _mm256_mul_pd(v_src00, v_alpha)));
+ _mm256_storeu_pd(dst + x + 4, _mm256_add_pd(_mm256_mul_pd(_mm256_loadu_pd(dst + x + 4), v_beta), _mm256_mul_pd(v_src01, v_alpha)));
+ _mm256_storeu_pd(dst + x + 8, _mm256_add_pd(_mm256_mul_pd(_mm256_loadu_pd(dst + x + 8), v_beta), _mm256_mul_pd(v_src10, v_alpha)));
+ _mm256_storeu_pd(dst + x + 12, _mm256_add_pd(_mm256_mul_pd(_mm256_loadu_pd(dst + x + 12), v_beta), _mm256_mul_pd(v_src11, v_alpha)));
+ }
+ accW_general_(src, dst, mask, len, cn, alpha, x);
+ }
+ else
+ {
+ accW_simd_(src, dst, mask, len, cn, alpha);
+ }
+}
+
+void accW_avx_64f(const double* src, double* dst, const uchar* mask, int len, int cn, double alpha)
+{
+ int x = 0;
+ const __m256d v_alpha = _mm256_set1_pd(alpha);
+ const __m256d v_beta = _mm256_set1_pd(1.0f - alpha);
+ const int cVectorWidth = 8;
+
+ if (!mask)
+ {
+ int size = len * cn;
+ for ( ; x <= size - cVectorWidth ; x += cVectorWidth)
+ {
+ __m256d v_src0 = _mm256_loadu_pd(src + x);
+ __m256d v_src1 = _mm256_loadu_pd(src + x + 4);
+
+ _mm256_storeu_pd(dst + x, _mm256_add_pd(_mm256_mul_pd(_mm256_loadu_pd(dst + x), v_beta), _mm256_mul_pd(v_src0, v_alpha)));
+ _mm256_storeu_pd(dst + x + 4, _mm256_add_pd(_mm256_mul_pd(_mm256_loadu_pd(dst + x + 4), v_beta), _mm256_mul_pd(v_src1, v_alpha)));
+ }
+ accW_general_(src, dst, mask, len, cn, alpha, x);
+ }
+ else
+ {
+ accW_simd_(src, dst, mask, len, cn, alpha);
+ }
+}
+#endif
+#endif // CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
+
+CV_CPU_OPTIMIZATION_NAMESPACE_END
+
+} // namespace cv
+
+///* End of file. */
diff --git a/modules/imgproc/src/approx.cpp b/modules/imgproc/src/approx.cpp
index ec0db30..0960162 100644
--- a/modules/imgproc/src/approx.cpp
+++ b/modules/imgproc/src/approx.cpp
@@ -83,6 +83,7 @@ CvSeq* icvApproximateChainTC89( CvChain* chain, int header_size,
return cvEndWriteSeq( &writer );
}
+ reader.code = 0;
cvStartReadChainPoints( chain, &reader );
temp.next = 0;
diff --git a/modules/imgproc/src/blend.cpp b/modules/imgproc/src/blend.cpp
index 17e31aa..16ed8c2 100644
--- a/modules/imgproc/src/blend.cpp
+++ b/modules/imgproc/src/blend.cpp
@@ -45,8 +45,257 @@
#include "precomp.hpp"
#include "opencl_kernels_imgproc.hpp"
+#include "opencv2/core/hal/intrin.hpp"
namespace cv {
+#if CV_SIMD128
+static inline v_float32x4 blend(const v_float32x4& v_src1, const v_float32x4& v_src2, const v_float32x4& v_w1, const v_float32x4& v_w2)
+{
+ const v_float32x4 v_eps = v_setall_f32(1e-5f);
+ v_float32x4 v_denom = v_w1 + v_w2 + v_eps;
+ return (v_src1 * v_w1 + v_src2 * v_w2) / v_denom;
+}
+static inline v_float32x4 blend(const v_float32x4& v_src1, const v_float32x4& v_src2, const float* w_ptr1, const float* w_ptr2, int offset)
+{
+ v_float32x4 v_w1 = v_load(w_ptr1 + offset);
+ v_float32x4 v_w2 = v_load(w_ptr2 + offset);
+ return blend(v_src1, v_src2, v_w1, v_w2);
+}
+static inline v_uint32x4 saturate_f32_u32(const v_float32x4& vec)
+{
+ const v_int32x4 z = v_setzero_s32();
+ const v_int32x4 x = v_setall_s32(255);
+ return v_reinterpret_as_u32(v_min(v_max(v_round(vec), z), x));
+}
+static inline v_uint8x16 pack_f32tou8(v_float32x4& val0, v_float32x4& val1, v_float32x4& val2, v_float32x4& val3)
+{
+ v_uint32x4 a = saturate_f32_u32(val0);
+ v_uint32x4 b = saturate_f32_u32(val1);
+ v_uint32x4 c = saturate_f32_u32(val2);
+ v_uint32x4 d = saturate_f32_u32(val3);
+ v_uint16x8 e = v_pack(a, b);
+ v_uint16x8 f = v_pack(c, d);
+ return v_pack(e, f);
+}
+static inline void store_pack_f32tou8(uchar* ptr, v_float32x4& val0, v_float32x4& val1, v_float32x4& val2, v_float32x4& val3)
+{
+ v_store((ptr), pack_f32tou8(val0, val1, val2, val3));
+}
+static inline void expand_u8tof32(const v_uint8x16& src, v_float32x4& dst0, v_float32x4& dst1, v_float32x4& dst2, v_float32x4& dst3)
+{
+ v_uint16x8 a0, a1;
+ v_expand(src, a0, a1);
+ v_uint32x4 b0, b1,b2,b3;
+ v_expand(a0, b0, b1);
+ v_expand(a1, b2, b3);
+ dst0 = v_cvt_f32(v_reinterpret_as_s32(b0));
+ dst1 = v_cvt_f32(v_reinterpret_as_s32(b1));
+ dst2 = v_cvt_f32(v_reinterpret_as_s32(b2));
+ dst3 = v_cvt_f32(v_reinterpret_as_s32(b3));
+}
+static inline void load_expand_u8tof32(const uchar* ptr, v_float32x4& dst0, v_float32x4& dst1, v_float32x4& dst2, v_float32x4& dst3)
+{
+ v_uint8x16 a = v_load((ptr));
+ expand_u8tof32(a, dst0, dst1, dst2, dst3);
+}
+int blendLinearSimd128(const uchar* src1, const uchar* src2, const float* weights1, const float* weights2, uchar* dst, int x, int width, int cn);
+int blendLinearSimd128(const float* src1, const float* src2, const float* weights1, const float* weights2, float* dst, int x, int width, int cn);
+int blendLinearSimd128(const uchar* src1, const uchar* src2, const float* weights1, const float* weights2, uchar* dst, int x, int width, int cn)
+{
+ int step = v_uint8x16::nlanes * cn;
+ int weight_step = v_uint8x16::nlanes;
+ switch(cn)
+ {
+ case 1:
+ for(int weight_offset = 0 ; x <= width - step; x += step, weight_offset += weight_step)
+ {
+ v_float32x4 v_src10, v_src11, v_src12, v_src13;
+ v_float32x4 v_src20, v_src21, v_src22, v_src23;
+ load_expand_u8tof32(src1 + x, v_src10, v_src11, v_src12, v_src13);
+ load_expand_u8tof32(src2 + x, v_src20, v_src21, v_src22, v_src23);
+
+ v_float32x4 v_dst0 = blend(v_src10, v_src20, weights1, weights2, weight_offset);
+ v_float32x4 v_dst1 = blend(v_src11, v_src21, weights1, weights2, weight_offset + 4);
+ v_float32x4 v_dst2 = blend(v_src12, v_src22, weights1, weights2, weight_offset + 8);
+ v_float32x4 v_dst3 = blend(v_src13, v_src23, weights1, weights2, weight_offset + 12);
+
+ store_pack_f32tou8(dst + x, v_dst0, v_dst1, v_dst2, v_dst3);
+ }
+ break;
+ case 2:
+ for(int weight_offset = 0 ; x <= width - step; x += step, weight_offset += weight_step)
+ {
+ v_uint8x16 v_src10, v_src11, v_src20, v_src21;
+ v_load_deinterleave(src1 + x, v_src10, v_src11);
+ v_load_deinterleave(src2 + x, v_src20, v_src21);
+ v_float32x4 v_src100, v_src101, v_src102, v_src103, v_src110, v_src111, v_src112, v_src113;
+ v_float32x4 v_src200, v_src201, v_src202, v_src203, v_src210, v_src211, v_src212, v_src213;
+ expand_u8tof32(v_src10, v_src100, v_src101, v_src102, v_src103);
+ expand_u8tof32(v_src11, v_src110, v_src111, v_src112, v_src113);
+ expand_u8tof32(v_src20, v_src200, v_src201, v_src202, v_src203);
+ expand_u8tof32(v_src21, v_src210, v_src211, v_src212, v_src213);
+
+ v_float32x4 v_dst0 = blend(v_src100, v_src200, weights1, weights2, weight_offset);
+ v_float32x4 v_dst1 = blend(v_src110, v_src210, weights1, weights2, weight_offset);
+ v_float32x4 v_dst2 = blend(v_src101, v_src201, weights1, weights2, weight_offset + 4);
+ v_float32x4 v_dst3 = blend(v_src111, v_src211, weights1, weights2, weight_offset + 4);
+ v_float32x4 v_dst4 = blend(v_src102, v_src202, weights1, weights2, weight_offset + 8);
+ v_float32x4 v_dst5 = blend(v_src112, v_src212, weights1, weights2, weight_offset + 8);
+ v_float32x4 v_dst6 = blend(v_src103, v_src203, weights1, weights2, weight_offset + 12);
+ v_float32x4 v_dst7 = blend(v_src113, v_src213, weights1, weights2, weight_offset + 12);
+
+ v_uint8x16 v_dsta = pack_f32tou8(v_dst0, v_dst2, v_dst4, v_dst6);
+ v_uint8x16 v_dstb = pack_f32tou8(v_dst1, v_dst3, v_dst5, v_dst7);
+ v_store_interleave(dst + x, v_dsta, v_dstb);
+ }
+ break;
+ case 3:
+ for(int weight_offset = 0 ; x <= width - step; x += step, weight_offset += weight_step)
+ {
+ v_uint8x16 v_src10, v_src11, v_src12, v_src20, v_src21, v_src22;
+ v_load_deinterleave(src1 + x, v_src10, v_src11, v_src12);
+ v_load_deinterleave(src2 + x, v_src20, v_src21, v_src22);
+
+ v_float32x4 v_src100, v_src101, v_src102, v_src103, v_src110, v_src111, v_src112, v_src113, v_src120, v_src121, v_src122, v_src123;
+ v_float32x4 v_src200, v_src201, v_src202, v_src203, v_src210, v_src211, v_src212, v_src213, v_src220, v_src221, v_src222, v_src223;
+ expand_u8tof32(v_src10, v_src100, v_src101, v_src102, v_src103);
+ expand_u8tof32(v_src11, v_src110, v_src111, v_src112, v_src113);
+ expand_u8tof32(v_src12, v_src120, v_src121, v_src122, v_src123);
+ expand_u8tof32(v_src20, v_src200, v_src201, v_src202, v_src203);
+ expand_u8tof32(v_src21, v_src210, v_src211, v_src212, v_src213);
+ expand_u8tof32(v_src22, v_src220, v_src221, v_src222, v_src223);
+
+ v_float32x4 v_w10 = v_load(weights1 + weight_offset);
+ v_float32x4 v_w11 = v_load(weights1 + weight_offset + 4);
+ v_float32x4 v_w12 = v_load(weights1 + weight_offset + 8);
+ v_float32x4 v_w13 = v_load(weights1 + weight_offset + 12);
+ v_float32x4 v_w20 = v_load(weights2 + weight_offset);
+ v_float32x4 v_w21 = v_load(weights2 + weight_offset + 4);
+ v_float32x4 v_w22 = v_load(weights2 + weight_offset + 8);
+ v_float32x4 v_w23 = v_load(weights2 + weight_offset + 12);
+ v_src100 = blend(v_src100, v_src200, v_w10, v_w20);
+ v_src110 = blend(v_src110, v_src210, v_w10, v_w20);
+ v_src120 = blend(v_src120, v_src220, v_w10, v_w20);
+ v_src101 = blend(v_src101, v_src201, v_w11, v_w21);
+ v_src111 = blend(v_src111, v_src211, v_w11, v_w21);
+ v_src121 = blend(v_src121, v_src221, v_w11, v_w21);
+ v_src102 = blend(v_src102, v_src202, v_w12, v_w22);
+ v_src112 = blend(v_src112, v_src212, v_w12, v_w22);
+ v_src122 = blend(v_src122, v_src222, v_w12, v_w22);
+ v_src103 = blend(v_src103, v_src203, v_w13, v_w23);
+ v_src113 = blend(v_src113, v_src213, v_w13, v_w23);
+ v_src123 = blend(v_src123, v_src223, v_w13, v_w23);
+
+
+ v_uint8x16 v_dst0 = pack_f32tou8(v_src100, v_src101, v_src102, v_src103);
+ v_uint8x16 v_dst1 = pack_f32tou8(v_src110, v_src111, v_src112, v_src113);
+ v_uint8x16 v_dst2 = pack_f32tou8(v_src120, v_src121, v_src122, v_src123);
+ v_store_interleave(dst + x, v_dst0, v_dst1, v_dst2);
+ }
+ break;
+ case 4:
+ step = v_uint8x16::nlanes;
+ weight_step = v_float32x4::nlanes;
+ for(int weight_offset = 0 ; x <= width - step; x += step, weight_offset += weight_step)
+ {
+ v_float32x4 v_src10, v_src11, v_src12, v_src13, v_src14, v_src15, v_src16, v_src17;
+ v_float32x4 v_src20, v_src21, v_src22, v_src23, v_src24, v_src25, v_src26, v_src27;
+ load_expand_u8tof32(src1 + x, v_src10, v_src11, v_src12, v_src13);
+ load_expand_u8tof32(src2 + x, v_src20, v_src21, v_src22, v_src23);
+
+ v_transpose4x4(v_src10, v_src11, v_src12, v_src13, v_src14, v_src15, v_src16, v_src17);
+ v_transpose4x4(v_src20, v_src21, v_src22, v_src23, v_src24, v_src25, v_src26, v_src27);
+
+ v_float32x4 v_w1 = v_load(weights1 + weight_offset);
+ v_float32x4 v_w2 = v_load(weights2 + weight_offset);
+ v_src10 = blend(v_src14, v_src24, v_w1, v_w2);
+ v_src11 = blend(v_src15, v_src25, v_w1, v_w2);
+ v_src12 = blend(v_src16, v_src26, v_w1, v_w2);
+ v_src13 = blend(v_src17, v_src27, v_w1, v_w2);
+
+ v_float32x4 v_dst0, v_dst1, v_dst2, v_dst3;
+ v_transpose4x4(v_src10, v_src11, v_src12, v_src13, v_dst0, v_dst1, v_dst2, v_dst3);
+ store_pack_f32tou8(dst + x, v_dst0, v_dst1, v_dst2, v_dst3);
+ }
+ break;
+ default:
+ break;
+ }
+ return x;
+}
+
+int blendLinearSimd128(const float* src1, const float* src2, const float* weights1, const float* weights2, float* dst, int x, int width, int cn)
+{
+ int step = v_float32x4::nlanes*cn;
+ switch(cn)
+ {
+ case 1:
+ for(int weight_offset = 0 ; x <= width - step; x += step, weight_offset += v_float32x4::nlanes)
+ {
+ v_float32x4 v_src1 = v_load(src1 + x);
+ v_float32x4 v_src2 = v_load(src2 + x);
+ v_float32x4 v_w1 = v_load(weights1 + weight_offset);
+ v_float32x4 v_w2 = v_load(weights2 + weight_offset);
+
+ v_float32x4 v_dst = blend(v_src1, v_src2, v_w1, v_w2);
+
+ v_store(dst + x, v_dst);
+ }
+ break;
+ case 2:
+ for(int weight_offset = 0 ; x <= width - step; x += step, weight_offset += v_float32x4::nlanes)
+ {
+ v_float32x4 v_src10, v_src11, v_src20, v_src21;
+ v_load_deinterleave(src1 + x, v_src10, v_src11);
+ v_load_deinterleave(src2 + x, v_src20, v_src21);
+ v_float32x4 v_w1 = v_load(weights1 + weight_offset);
+ v_float32x4 v_w2 = v_load(weights2 + weight_offset);
+
+ v_float32x4 v_dst0 = blend(v_src10, v_src20, v_w1, v_w2);
+ v_float32x4 v_dst1 = blend(v_src11, v_src21, v_w1, v_w2);
+
+ v_store_interleave(dst + x, v_dst0, v_dst1);
+ }
+ break;
+ case 3:
+ for(int weight_offset = 0 ; x <= width - step; x += step, weight_offset += v_float32x4::nlanes)
+ {
+ v_float32x4 v_src10, v_src11, v_src12, v_src20, v_src21, v_src22;
+ v_load_deinterleave(src1 + x, v_src10, v_src11, v_src12);
+ v_load_deinterleave(src2 + x, v_src20, v_src21, v_src22);
+ v_float32x4 v_w1 = v_load(weights1 + weight_offset);
+ v_float32x4 v_w2 = v_load(weights2 + weight_offset);
+
+ v_float32x4 v_dst0 = blend(v_src10, v_src20, v_w1, v_w2);
+ v_float32x4 v_dst1 = blend(v_src11, v_src21, v_w1, v_w2);
+ v_float32x4 v_dst2 = blend(v_src12, v_src22, v_w1, v_w2);
+
+ v_store_interleave(dst + x, v_dst0, v_dst1, v_dst2);
+ }
+ break;
+ case 4:
+ for(int weight_offset = 0 ; x <= width - step; x += step, weight_offset += v_float32x4::nlanes)
+ {
+ v_float32x4 v_src10, v_src11, v_src12, v_src13, v_src20, v_src21, v_src22, v_src23;
+ v_load_deinterleave(src1 + x, v_src10, v_src11, v_src12, v_src13);
+ v_load_deinterleave(src2 + x, v_src20, v_src21, v_src22, v_src23);
+ v_float32x4 v_w1 = v_load(weights1 + weight_offset);
+ v_float32x4 v_w2 = v_load(weights2 + weight_offset);
+
+ v_float32x4 v_dst0 = blend(v_src10, v_src20, v_w1, v_w2);
+ v_float32x4 v_dst1 = blend(v_src11, v_src21, v_w1, v_w2);
+ v_float32x4 v_dst2 = blend(v_src12, v_src22, v_w1, v_w2);
+ v_float32x4 v_dst3 = blend(v_src13, v_src23, v_w1, v_w2);
+
+ v_store_interleave(dst + x, v_dst0, v_dst1, v_dst2, v_dst3);
+ }
+ break;
+ default:
+ break;
+ }
+ return x;
+}
+#endif
template <typename T>
class BlendLinearInvoker :
@@ -71,7 +320,12 @@ public:
const T * const src2_row = src2->ptr<T>(y);
T * const dst_row = dst->ptr<T>(y);
- for (int x = 0; x < width; ++x)
+ int x = 0;
+ #if CV_SIMD128
+ x = blendLinearSimd128(src1_row, src2_row, weights1_row, weights2_row, dst_row, x, width, cn);
+ #endif
+
+ for ( ; x < width; ++x)
{
int x1 = x / cn;
float w1 = weights1_row[x1], w2 = weights2_row[x1];
diff --git a/modules/imgproc/src/canny.cpp b/modules/imgproc/src/canny.cpp
index cdc4e7a..c723c2b 100644
--- a/modules/imgproc/src/canny.cpp
+++ b/modules/imgproc/src/canny.cpp
@@ -43,7 +43,7 @@
#include "precomp.hpp"
#include "opencl_kernels_imgproc.hpp"
#include "opencv2/core/hal/intrin.hpp"
-#include <queue>
+#include <deque>
#include "opencv2/core/openvx/ovx_defs.hpp"
@@ -51,88 +51,87 @@
#pragma warning( disable: 4127 ) // conditional expression is constant
#endif
-
-#if defined (HAVE_IPP) && (IPP_VERSION_X100 >= 700)
-#define USE_IPP_CANNY 1
-#else
-#define USE_IPP_CANNY 0
+#if CV_SIMD128
+#define CV_MALLOC_SIMD128 16
#endif
-
namespace cv
{
-static void CannyImpl(Mat& dx_, Mat& dy_, Mat& _dst, double low_thresh, double high_thresh, bool L2gradient);
-
-
#ifdef HAVE_IPP
-template <bool useCustomDeriv>
-static bool ippCanny(const Mat& _src, const Mat& dx_, const Mat& dy_, Mat& _dst, float low, float high)
+static bool ipp_Canny(const Mat& src , const Mat& dx_, const Mat& dy_, Mat& dst, float low, float high, bool L2gradient, int aperture_size)
{
+#ifdef HAVE_IPP_IW
CV_INSTRUMENT_REGION_IPP()
-#if USE_IPP_CANNY
- if (!useCustomDeriv && _src.isSubmatrix())
- return false; // IPP Sobel doesn't support transparent ROI border
+#if IPP_DISABLE_PERF_CANNY_MT
+ if(cv::getNumThreads()>1)
+ return false;
+#endif
- int size = 0, size1 = 0;
- IppiSize roi = { _src.cols, _src.rows };
+ ::ipp::IwiSize size(dst.cols, dst.rows);
+ IppDataType type = ippiGetDataType(dst.depth());
+ int channels = dst.channels();
+ IppNormType norm = (L2gradient)?ippNormL2:ippNormL1;
- if (ippiCannyGetSize(roi, &size) < 0)
+ if(size.width <= 3 || size.height <= 3)
return false;
- if (!useCustomDeriv)
- {
-#if IPP_VERSION_X100 < 900
- if (ippiFilterSobelNegVertGetBufferSize_8u16s_C1R(roi, ippMskSize3x3, &size1) < 0)
- return false;
- size = std::max(size, size1);
- if (ippiFilterSobelHorizGetBufferSize_8u16s_C1R(roi, ippMskSize3x3, &size1) < 0)
- return false;
-#else
- if (ippiFilterSobelNegVertBorderGetBufferSize(roi, ippMskSize3x3, ipp8u, ipp16s, 1, &size1) < 0)
- return false;
- size = std::max(size, size1);
- if (ippiFilterSobelHorizBorderGetBufferSize(roi, ippMskSize3x3, ipp8u, ipp16s, 1, &size1) < 0)
- return false;
-#endif
- size = std::max(size, size1);
- }
+ if(channels != 1)
+ return false;
- AutoBuffer<uchar> buf(size + 64);
- uchar* buffer = alignPtr((uchar*)buf, 32);
+ if(type != ipp8u)
+ return false;
- Mat dx, dy;
- if (!useCustomDeriv)
+ if(src.empty())
{
- Mat _dx(_src.rows, _src.cols, CV_16S);
- if( CV_INSTRUMENT_FUN_IPP(ippiFilterSobelNegVertBorder_8u16s_C1R, _src.ptr(), (int)_src.step,
- _dx.ptr<short>(), (int)_dx.step, roi,
- ippMskSize3x3, ippBorderRepl, 0, buffer) < 0 )
- return false;
+ try
+ {
+ ::ipp::IwiImage iwSrcDx;
+ ::ipp::IwiImage iwSrcDy;
+ ::ipp::IwiImage iwDst;
- Mat _dy(_src.rows, _src.cols, CV_16S);
- if( CV_INSTRUMENT_FUN_IPP(ippiFilterSobelHorizBorder_8u16s_C1R, _src.ptr(), (int)_src.step,
- _dy.ptr<short>(), (int)_dy.step, roi,
- ippMskSize3x3, ippBorderRepl, 0, buffer) < 0 )
- return false;
+ ippiGetImage(dx_, iwSrcDx);
+ ippiGetImage(dy_, iwSrcDy);
+ ippiGetImage(dst, iwDst);
- swap(dx, _dx);
- swap(dy, _dy);
+ CV_INSTRUMENT_FUN_IPP(::ipp::iwiFilterCannyDeriv, &iwSrcDx, &iwSrcDy, &iwDst, norm, low, high);
+ }
+ catch (::ipp::IwException ex)
+ {
+ return false;
+ }
}
else
{
- dx = dx_;
- dy = dy_;
+ IppiMaskSize kernel;
+
+ if(aperture_size == 3)
+ kernel = ippMskSize3x3;
+ else if(aperture_size == 5)
+ kernel = ippMskSize5x5;
+ else
+ return false;
+
+ try
+ {
+ ::ipp::IwiImage iwSrc;
+ ::ipp::IwiImage iwDst;
+
+ ippiGetImage(src, iwSrc);
+ ippiGetImage(dst, iwDst);
+
+ CV_INSTRUMENT_FUN_IPP(::ipp::iwiFilterCanny, &iwSrc, &iwDst, ippFilterSobel, kernel, norm, low, high, ippBorderRepl);
+ }
+ catch (::ipp::IwException)
+ {
+ return false;
+ }
}
- if( CV_INSTRUMENT_FUN_IPP(ippiCanny_16s8u_C1R, dx.ptr<short>(), (int)dx.step,
- dy.ptr<short>(), (int)dy.step,
- _dst.ptr(), (int)_dst.step, roi, low, high, buffer) < 0 )
- return false;
return true;
#else
- CV_UNUSED(_src); CV_UNUSED(dx_); CV_UNUSED(dy_); CV_UNUSED(_dst); CV_UNUSED(low); CV_UNUSED(high);
+ CV_UNUSED(src); CV_UNUSED(dx_); CV_UNUSED(dy_); CV_UNUSED(dst); CV_UNUSED(low); CV_UNUSED(high); CV_UNUSED(L2gradient); CV_UNUSED(aperture_size);
return false;
#endif
}
@@ -287,411 +286,514 @@ static bool ocl_Canny(InputArray _src, const UMat& dx_, const UMat& dy_, OutputA
#endif
+#define CANNY_PUSH(map, stack) *map = 2, stack.push_back(map)
+
+#define CANNY_CHECK_SIMD(m, high, map, stack) \
+ if (m > high) \
+ CANNY_PUSH(map, stack); \
+ else \
+ *map = 0
+
+#define CANNY_CHECK(m, high, map, stack) \
+ if (m > high) \
+ CANNY_PUSH(map, stack); \
+ else \
+ *map = 0; \
+ continue
+
class parallelCanny : public ParallelLoopBody
{
-
public:
- parallelCanny(const Mat& _src, uchar* _map, int _low, int _high, int _aperture_size, bool _L2gradient, std::queue<uchar*> *borderPeaksParallel) :
- src(_src), map(_map), low(_low), high(_high), aperture_size(_aperture_size), L2gradient(_L2gradient), _borderPeaksParallel(borderPeaksParallel)
+ parallelCanny(const Mat &_src, Mat &_map, std::deque<uchar*> &borderPeaksParallel,
+ int _low, int _high, int _aperture_size, bool _L2gradient) :
+ src(_src), src2(_src), map(_map), _borderPeaksParallel(borderPeaksParallel),
+ low(_low), high(_high), aperture_size(_aperture_size), L2gradient(_L2gradient)
{
+#if CV_SIMD128
+ haveSIMD = hasSIMD128();
+ if(haveSIMD)
+ _map.create(src.rows + 2, (int)alignSize((size_t)(src.cols + CV_MALLOC_SIMD128 + 1), CV_MALLOC_SIMD128), CV_8UC1);
+ else
+#endif
+ _map.create(src.rows + 2, src.cols + 2, CV_8UC1);
+ map = _map;
+ map.row(0).setTo(1);
+ map.row(src.rows + 1).setTo(1);
+ mapstep = map.cols;
+ needGradient = true;
+ cn = src.channels();
}
- ~parallelCanny()
+ parallelCanny(const Mat &_dx, const Mat &_dy, Mat &_map, std::deque<uchar*> &borderPeaksParallel,
+ int _low, int _high, bool _L2gradient) :
+ src(_dx), src2(_dy), map(_map), _borderPeaksParallel(borderPeaksParallel),
+ low(_low), high(_high), aperture_size(0), L2gradient(_L2gradient)
{
+#if CV_SIMD128
+ haveSIMD = hasSIMD128();
+ if(haveSIMD)
+ _map.create(src.rows + 2, (int)alignSize((size_t)(src.cols + CV_MALLOC_SIMD128 + 1), CV_MALLOC_SIMD128), CV_8UC1);
+ else
+#endif
+ _map.create(src.rows + 2, src.cols + 2, CV_8UC1);
+ map = _map;
+ map.row(0).setTo(1);
+ map.row(src.rows + 1).setTo(1);
+ mapstep = map.cols;
+ needGradient = false;
+ cn = src.channels();
}
+ ~parallelCanny() {}
+
parallelCanny& operator=(const parallelCanny&) { return *this; }
void operator()(const Range &boundaries) const
{
-#if CV_SIMD128
- bool haveSIMD = hasSIMD128();
-#endif
-
- const int type = src.type(), cn = CV_MAT_CN(type);
+ CV_TRACE_FUNCTION();
Mat dx, dy;
- std::queue<uchar*> borderPeaksLocal;
-
- ptrdiff_t mapstep = src.cols + 2;
-
- // In sobel transform we calculate ksize2 extra lines for the first and last rows of each slice
- // because IPPDerivSobel expects only isolated ROIs, in contrast with the opencv version which
- // uses the pixels outside of the ROI to form a border.
- int ksize2 = aperture_size / 2;
- // If Scharr filter: aperture_size is 3 and ksize2 is 1
- if(aperture_size == -1)
+ AutoBuffer<short> dxMax(0), dyMax(0);
+ std::deque<uchar*> stack, borderPeaksLocal;
+ const int rowStart = max(0, boundaries.start - 1), rowEnd = min(src.rows, boundaries.end + 1);
+ int *_mag_p, *_mag_a, *_mag_n;
+ short *_dx, *_dy, *_dx_a = NULL, *_dy_a = NULL, *_dx_n = NULL, *_dy_n = NULL;
+ uchar *_pmap;
+
+ CV_TRACE_REGION("gradient")
+ if(needGradient)
{
- ksize2 = 1;
- }
-
- if (boundaries.start == 0 && boundaries.end == src.rows)
- {
- Mat tempdx(boundaries.end - boundaries.start + 2, src.cols, CV_16SC(cn));
- Mat tempdy(boundaries.end - boundaries.start + 2, src.cols, CV_16SC(cn));
-
- memset(tempdx.ptr<short>(0), 0, cn * src.cols*sizeof(short));
- memset(tempdy.ptr<short>(0), 0, cn * src.cols*sizeof(short));
- memset(tempdx.ptr<short>(tempdx.rows - 1), 0, cn * src.cols*sizeof(short));
- memset(tempdy.ptr<short>(tempdy.rows - 1), 0, cn * src.cols*sizeof(short));
-
- Sobel(src, tempdx.rowRange(1, tempdx.rows - 1), CV_16S, 1, 0, aperture_size, 1, 0, BORDER_REPLICATE);
- Sobel(src, tempdy.rowRange(1, tempdy.rows - 1), CV_16S, 0, 1, aperture_size, 1, 0, BORDER_REPLICATE);
-
- dx = tempdx;
- dy = tempdy;
+ Sobel(src.rowRange(rowStart, rowEnd), dx, CV_16S, 1, 0, aperture_size, 1, 0, BORDER_REPLICATE);
+ Sobel(src.rowRange(rowStart, rowEnd), dy, CV_16S, 0, 1, aperture_size, 1, 0, BORDER_REPLICATE);
}
- else if (boundaries.start == 0)
+ else
{
- Mat tempdx(boundaries.end - boundaries.start + 2 + ksize2, src.cols, CV_16SC(cn));
- Mat tempdy(boundaries.end - boundaries.start + 2 + ksize2, src.cols, CV_16SC(cn));
-
- memset(tempdx.ptr<short>(0), 0, cn * src.cols*sizeof(short));
- memset(tempdy.ptr<short>(0), 0, cn * src.cols*sizeof(short));
-
- Sobel(src.rowRange(boundaries.start, boundaries.end + 1 + ksize2), tempdx.rowRange(1, tempdx.rows),
- CV_16S, 1, 0, aperture_size, 1, 0, BORDER_REPLICATE);
- Sobel(src.rowRange(boundaries.start, boundaries.end + 1 + ksize2), tempdy.rowRange(1, tempdy.rows),
- CV_16S, 0, 1, aperture_size, 1, 0, BORDER_REPLICATE);
-
- dx = tempdx.rowRange(0, tempdx.rows - ksize2);
- dy = tempdy.rowRange(0, tempdy.rows - ksize2);
+ dx = src.rowRange(rowStart, rowEnd);
+ dy = src2.rowRange(rowStart, rowEnd);
}
- else if (boundaries.end == src.rows)
- {
- Mat tempdx(boundaries.end - boundaries.start + 2 + ksize2, src.cols, CV_16SC(cn));
- Mat tempdy(boundaries.end - boundaries.start + 2 + ksize2, src.cols, CV_16SC(cn));
-
- memset(tempdx.ptr<short>(tempdx.rows - 1), 0, cn * src.cols*sizeof(short));
- memset(tempdy.ptr<short>(tempdy.rows - 1), 0, cn * src.cols*sizeof(short));
- Sobel(src.rowRange(boundaries.start - 1 - ksize2, boundaries.end), tempdx.rowRange(0, tempdx.rows - 1),
- CV_16S, 1, 0, aperture_size, 1, 0, BORDER_REPLICATE);
- Sobel(src.rowRange(boundaries.start - 1 - ksize2, boundaries.end), tempdy.rowRange(0, tempdy.rows - 1),
- CV_16S, 0, 1, aperture_size, 1, 0, BORDER_REPLICATE);
-
- dx = tempdx.rowRange(ksize2, tempdx.rows);
- dy = tempdy.rowRange(ksize2, tempdy.rows);
- }
- else
+ CV_TRACE_REGION_NEXT("magnitude");
+ if(cn > 1)
{
- Mat tempdx(boundaries.end - boundaries.start + 2 + 2*ksize2, src.cols, CV_16SC(cn));
- Mat tempdy(boundaries.end - boundaries.start + 2 + 2*ksize2, src.cols, CV_16SC(cn));
-
- Sobel(src.rowRange(boundaries.start - 1 - ksize2, boundaries.end + 1 + ksize2), tempdx,
- CV_16S, 1, 0, aperture_size, 1, 0, BORDER_REPLICATE);
- Sobel(src.rowRange(boundaries.start - 1 - ksize2, boundaries.end + 1 + ksize2), tempdy,
- CV_16S, 0, 1, aperture_size, 1, 0, BORDER_REPLICATE);
-
- dx = tempdx.rowRange(ksize2, tempdx.rows - ksize2);
- dy = tempdy.rowRange(ksize2, tempdy.rows - ksize2);
+ dxMax.allocate(2 * dx.cols);
+ dyMax.allocate(2 * dy.cols);
+ _dx_a = (short*)dxMax;
+ _dx_n = _dx_a + dx.cols;
+ _dy_a = (short*)dyMax;
+ _dy_n = _dy_a + dy.cols;
}
- int maxsize = std::max(1 << 10, src.cols * (boundaries.end - boundaries.start) / 10);
- std::vector<uchar*> stack(maxsize);
- uchar **stack_top = &stack[0];
- uchar **stack_bottom = &stack[0];
+ // _mag_p: previous row, _mag_a: actual row, _mag_n: next row
+#if CV_SIMD128
+ AutoBuffer<int> buffer(3 * (mapstep * cn + CV_MALLOC_SIMD128));
+ _mag_p = alignPtr((int*)buffer + 1, CV_MALLOC_SIMD128);
+ _mag_a = alignPtr(_mag_p + mapstep * cn, CV_MALLOC_SIMD128);
+ _mag_n = alignPtr(_mag_a + mapstep * cn, CV_MALLOC_SIMD128);
+#else
+ AutoBuffer<int> buffer(3 * (mapstep * cn));
+ _mag_p = (int*)buffer + 1;
+ _mag_a = _mag_p + mapstep * cn;
+ _mag_n = _mag_a + mapstep * cn;
+#endif
- AutoBuffer<uchar> buffer(cn * mapstep * 3 * sizeof(int));
+ // For the first time when just 2 rows are filled and for left and right borders
+ if(rowStart == boundaries.start)
+ memset(_mag_n - 1, 0, mapstep * sizeof(int));
+ else
+ _mag_n[src.cols] = _mag_n[-1] = 0;
- int* mag_buf[3];
- mag_buf[0] = (int*)(uchar*)buffer;
- mag_buf[1] = mag_buf[0] + mapstep*cn;
- mag_buf[2] = mag_buf[1] + mapstep*cn;
+ _mag_a[src.cols] = _mag_a[-1] = _mag_p[src.cols] = _mag_p[-1] = 0;
// calculate magnitude and angle of gradient, perform non-maxima suppression.
// fill the map with one of the following values:
// 0 - the pixel might belong to an edge
// 1 - the pixel can not belong to an edge
// 2 - the pixel does belong to an edge
- for (int i = boundaries.start - 1; i <= boundaries.end; i++)
+ for (int i = rowStart; i <= boundaries.end; ++i)
{
- int* _norm = mag_buf[(i > boundaries.start) - (i == boundaries.start - 1) + 1] + 1;
+ // Scroll the ring buffer
+ std::swap(_mag_n, _mag_a);
+ std::swap(_mag_n, _mag_p);
- short* _dx = dx.ptr<short>(i - boundaries.start + 1);
- short* _dy = dy.ptr<short>(i - boundaries.start + 1);
-
- if (!L2gradient)
+ if(i < rowEnd)
{
- int j = 0, width = src.cols * cn;
+ // Next row calculation
+ _dx = dx.ptr<short>(i - rowStart);
+ _dy = dy.ptr<short>(i - rowStart);
+
+ if (L2gradient)
+ {
+ int j = 0, width = src.cols * cn;
#if CV_SIMD128
- if (haveSIMD)
+ if (haveSIMD)
+ {
+ for ( ; j <= width - 8; j += 8)
+ {
+ v_int16x8 v_dx = v_load((const short*)(_dx + j));
+ v_int16x8 v_dy = v_load((const short*)(_dy + j));
+
+ v_int32x4 v_dxp_low, v_dxp_high;
+ v_int32x4 v_dyp_low, v_dyp_high;
+ v_expand(v_dx, v_dxp_low, v_dxp_high);
+ v_expand(v_dy, v_dyp_low, v_dyp_high);
+
+ v_store_aligned((int *)(_mag_n + j), v_dxp_low*v_dxp_low+v_dyp_low*v_dyp_low);
+ v_store_aligned((int *)(_mag_n + j + 4), v_dxp_high*v_dxp_high+v_dyp_high*v_dyp_high);
+ }
+ }
+#endif
+ for ( ; j < width; ++j)
+ _mag_n[j] = int(_dx[j])*_dx[j] + int(_dy[j])*_dy[j];
+ }
+ else
{
- for ( ; j <= width - 8; j += 8)
+ int j = 0, width = src.cols * cn;
+#if CV_SIMD128
+ if (haveSIMD)
{
- v_int16x8 v_dx = v_load((const short *)(_dx + j));
- v_int16x8 v_dy = v_load((const short *)(_dy + j));
+ for(; j <= width - 8; j += 8)
+ {
+ v_int16x8 v_dx = v_load((const short *)(_dx + j));
+ v_int16x8 v_dy = v_load((const short *)(_dy + j));
- v_dx = v_reinterpret_as_s16(v_abs(v_dx));
- v_dy = v_reinterpret_as_s16(v_abs(v_dy));
+ v_dx = v_reinterpret_as_s16(v_abs(v_dx));
+ v_dy = v_reinterpret_as_s16(v_abs(v_dy));
- v_int32x4 v_dx_ml;
- v_int32x4 v_dy_ml;
- v_int32x4 v_dx_mh;
- v_int32x4 v_dy_mh;
- v_expand(v_dx, v_dx_ml, v_dx_mh);
- v_expand(v_dy, v_dy_ml, v_dy_mh);
+ v_int32x4 v_dx_ml, v_dy_ml, v_dx_mh, v_dy_mh;
+ v_expand(v_dx, v_dx_ml, v_dx_mh);
+ v_expand(v_dy, v_dy_ml, v_dy_mh);
- v_store((int *)(_norm + j), v_dx_ml + v_dy_ml);
- v_store((int *)(_norm + j + 4), v_dx_mh + v_dy_mh);
+ v_store_aligned((int *)(_mag_n + j), v_dx_ml + v_dy_ml);
+ v_store_aligned((int *)(_mag_n + j + 4), v_dx_mh + v_dy_mh);
+ }
}
- }
#endif
- for ( ; j < width; ++j)
- _norm[j] = std::abs(int(_dx[j])) + std::abs(int(_dy[j]));
- }
- else
- {
- int j = 0, width = src.cols * cn;
-#if CV_SIMD128
- if (haveSIMD)
+ for ( ; j < width; ++j)
+ _mag_n[j] = std::abs(int(_dx[j])) + std::abs(int(_dy[j]));
+ }
+
+ if(cn > 1)
{
- for ( ; j <= width - 8; j += 8)
- {
- v_int16x8 v_dx = v_load((const short*)(_dx + j));
- v_int16x8 v_dy = v_load((const short*)(_dy + j));
+ std::swap(_dx_n, _dx_a);
+ std::swap(_dy_n, _dy_a);
- v_int32x4 v_dxp_low, v_dxp_high;
- v_int32x4 v_dyp_low, v_dyp_high;
- v_expand(v_dx, v_dxp_low, v_dxp_high);
- v_expand(v_dy, v_dyp_low, v_dyp_high);
+ for(int j = 0, jn = 0; j < src.cols; ++j, jn += cn)
+ {
+ int maxIdx = jn;
+ for(int k = 1; k < cn; ++k)
+ if(_mag_n[jn + k] > _mag_n[maxIdx]) maxIdx = jn + k;
- v_store((int *)(_norm + j), v_dxp_low*v_dxp_low+v_dyp_low*v_dyp_low);
- v_store((int *)(_norm + j + 4), v_dxp_high*v_dxp_high+v_dyp_high*v_dyp_high);
+ _mag_n[j] = _mag_n[maxIdx];
+ _dx_n[j] = _dx[maxIdx];
+ _dy_n[j] = _dy[maxIdx];
}
+
+ _mag_n[src.cols] = 0;
}
-#endif
- for ( ; j < width; ++j)
- _norm[j] = int(_dx[j])*_dx[j] + int(_dy[j])*_dy[j];
- }
- if (cn > 1)
+ // at the very beginning we do not have a complete ring
+ // buffer of 3 magnitude rows for non-maxima suppression
+ if (i <= boundaries.start)
+ continue;
+ }
+ else
{
- for(int j = 0, jn = 0; j < src.cols; ++j, jn += cn)
+ memset(_mag_n - 1, 0, mapstep * sizeof(int));
+
+ if(cn > 1)
{
- int maxIdx = jn;
- for(int k = 1; k < cn; ++k)
- if(_norm[jn + k] > _norm[maxIdx]) maxIdx = jn + k;
- _norm[j] = _norm[maxIdx];
- _dx[j] = _dx[maxIdx];
- _dy[j] = _dy[maxIdx];
+ std::swap(_dx_n, _dx_a);
+ std::swap(_dy_n, _dy_a);
}
}
- _norm[-1] = _norm[src.cols] = 0;
- // at the very beginning we do not have a complete ring
- // buffer of 3 magnitude rows for non-maxima suppression
- if (i <= boundaries.start)
- continue;
-
- uchar* _map = map + mapstep*i + 1;
- _map[-1] = _map[src.cols] = 1;
-
- int* _mag = mag_buf[1] + 1; // take the central row
- ptrdiff_t magstep1 = mag_buf[2] - mag_buf[1];
- ptrdiff_t magstep2 = mag_buf[0] - mag_buf[1];
+ // From here actual src row is (i - 1)
+ // Set left and right border to 1
+#if CV_SIMD128
+ if(haveSIMD)
+ _pmap = map.ptr<uchar>(i) + CV_MALLOC_SIMD128;
+ else
+#endif
+ _pmap = map.ptr<uchar>(i) + 1;
- const short* _x = dx.ptr<short>(i - boundaries.start);
- const short* _y = dy.ptr<short>(i - boundaries.start);
+ _pmap[src.cols] =_pmap[-1] = 1;
- if ((stack_top - stack_bottom) + src.cols > maxsize)
+ if(cn == 1)
{
- int sz = (int)(stack_top - stack_bottom);
- maxsize = std::max(maxsize * 3/2, sz + src.cols);
- stack.resize(maxsize);
- stack_bottom = &stack[0];
- stack_top = stack_bottom + sz;
+ _dx = dx.ptr<short>(i - rowStart - 1);
+ _dy = dy.ptr<short>(i - rowStart - 1);
+ }
+ else
+ {
+ _dx = _dx_a;
+ _dy = _dy_a;
}
-#define CANNY_PUSH(d) *(d) = uchar(2), *stack_top++ = (d)
-#define CANNY_POP(d) (d) = *--stack_top
-
-#define CANNY_SHIFT 15
- const int TG22 = (int)(0.4142135623730950488016887242097*(1 << CANNY_SHIFT) + 0.5);
-
- int prev_flag = 0, j = 0;
+ const int TG22 = 13573;
+ int j = 0;
#if CV_SIMD128
if (haveSIMD)
{
- v_int32x4 v_low = v_setall_s32(low);
- v_int8x16 v_one = v_setall_s8(1);
+ const v_int32x4 v_low = v_setall_s32(low);
+ const v_int8x16 v_one = v_setall_s8(1);
- for (; j <= src.cols - 16; j += 16)
+ for (; j <= src.cols - 32; j += 32)
{
- v_int32x4 v_m1 = v_load((const int*)(_mag + j));
- v_int32x4 v_m2 = v_load((const int*)(_mag + j + 4));
- v_int32x4 v_m3 = v_load((const int*)(_mag + j + 8));
- v_int32x4 v_m4 = v_load((const int*)(_mag + j + 12));
-
- v_store((signed char*)(_map + j), v_one);
+ v_int32x4 v_m1 = v_load_aligned((const int*)(_mag_a + j));
+ v_int32x4 v_m2 = v_load_aligned((const int*)(_mag_a + j + 4));
+ v_int32x4 v_m3 = v_load_aligned((const int*)(_mag_a + j + 8));
+ v_int32x4 v_m4 = v_load_aligned((const int*)(_mag_a + j + 12));
v_int32x4 v_cmp1 = v_m1 > v_low;
v_int32x4 v_cmp2 = v_m2 > v_low;
v_int32x4 v_cmp3 = v_m3 > v_low;
v_int32x4 v_cmp4 = v_m4 > v_low;
+ v_m1 = v_load_aligned((const int*)(_mag_a + j + 16));
+ v_m2 = v_load_aligned((const int*)(_mag_a + j + 20));
+ v_m3 = v_load_aligned((const int*)(_mag_a + j + 24));
+ v_m4 = v_load_aligned((const int*)(_mag_a + j + 28));
+
+ v_store_aligned((signed char*)(_pmap + j), v_one);
+ v_store_aligned((signed char*)(_pmap + j + 16), v_one);
+
v_int16x8 v_cmp80 = v_pack(v_cmp1, v_cmp2);
v_int16x8 v_cmp81 = v_pack(v_cmp3, v_cmp4);
+ v_cmp1 = v_m1 > v_low;
+ v_cmp2 = v_m2 > v_low;
+ v_cmp3 = v_m3 > v_low;
+ v_cmp4 = v_m4 > v_low;
+
v_int8x16 v_cmp = v_pack(v_cmp80, v_cmp81);
+
+ v_cmp80 = v_pack(v_cmp1, v_cmp2);
+ v_cmp81 = v_pack(v_cmp3, v_cmp4);
+
unsigned int mask = v_signmask(v_cmp);
+ v_cmp = v_pack(v_cmp80, v_cmp81);
+ mask |= v_signmask(v_cmp) << 16;
+
if (mask)
{
- int m, k = j;
+ int k = j;
- for (; mask; ++k, mask >>= 1)
+ do
{
- if (mask & 0x00000001)
- {
- m = _mag[k];
- int xs = _x[k];
- int ys = _y[k];
- int x = std::abs(xs);
- int y = std::abs(ys) << CANNY_SHIFT;
+ int l = trailingZeros32(mask);
+ k += l;
+ mask >>= l;
+
+ int m = _mag_a[k];
+ short xs = _dx[k];
+ short ys = _dy[k];
+ int x = (int)std::abs(xs);
+ int y = (int)std::abs(ys) << 15;
- int tg22x = x * TG22;
+ int tg22x = x * TG22;
- if (y < tg22x)
+ if (y < tg22x)
+ {
+ if (m > _mag_a[k - 1] && m >= _mag_a[k + 1])
{
- if (m > _mag[k - 1] && m >= _mag[k + 1]) goto _canny_push_sse;
+ CANNY_CHECK_SIMD(m, high, (_pmap+k), stack);
}
- else
+ }
+ else
+ {
+ int tg67x = tg22x + (x << 16);
+ if (y > tg67x)
{
- int tg67x = tg22x + (x << (CANNY_SHIFT + 1));
- if (y > tg67x)
+ if (m > _mag_p[k] && m >= _mag_n[k])
{
- if (m > _mag[k + magstep2] && m >= _mag[k + magstep1]) goto _canny_push_sse;
- } else
+ CANNY_CHECK_SIMD(m, high, (_pmap+k), stack);
+ }
+ }
+ else
+ {
+ int s = (xs ^ ys) < 0 ? -1 : 1;
+ if(m > _mag_p[k - s] && m > _mag_n[k + s])
{
- int s = (xs ^ ys) < 0 ? -1 : 1;
- if (m > _mag[k + magstep2 - s] && m > _mag[k + magstep1 + s]) goto _canny_push_sse;
+ CANNY_CHECK_SIMD(m, high, (_pmap+k), stack);
}
}
}
+ ++k;
+ } while((mask >>= 1));
+ }
+ }
- prev_flag = 0;
- continue;
+ if (j <= src.cols - 16)
+ {
+ v_int32x4 v_m1 = v_load_aligned((const int*)(_mag_a + j));
+ v_int32x4 v_m2 = v_load_aligned((const int*)(_mag_a + j + 4));
+ v_int32x4 v_m3 = v_load_aligned((const int*)(_mag_a + j + 8));
+ v_int32x4 v_m4 = v_load_aligned((const int*)(_mag_a + j + 12));
-_canny_push_sse:
- // _map[k-mapstep] is short-circuited at the start because previous thread is
- // responsible for initializing it.
- if (m > high && !prev_flag && (i <= boundaries.start + 1 || _map[k - mapstep] != 2))
- {
- CANNY_PUSH(_map + k);
- prev_flag = 1;
- } else
- _map[k] = 0;
+ v_store_aligned((signed char*)(_pmap + j), v_one);
- }
+ v_int32x4 v_cmp1 = v_m1 > v_low;
+ v_int32x4 v_cmp2 = v_m2 > v_low;
+ v_int32x4 v_cmp3 = v_m3 > v_low;
+ v_int32x4 v_cmp4 = v_m4 > v_low;
+
+ v_int16x8 v_cmp80 = v_pack(v_cmp1, v_cmp2);
+ v_int16x8 v_cmp81 = v_pack(v_cmp3, v_cmp4);
+
+ v_int8x16 v_cmp = v_pack(v_cmp80, v_cmp81);
+ unsigned int mask = v_signmask(v_cmp);
+
+ if (mask)
+ {
+ int k = j;
- if (prev_flag && ((k < j+16) || (k < src.cols && _mag[k] <= high)))
- prev_flag = 0;
+ do
+ {
+ int l = trailingZeros32(mask);
+ k += l;
+ mask >>= l;
+
+ int m = _mag_a[k];
+ short xs = _dx[k];
+ short ys = _dy[k];
+ int x = (int)std::abs(xs);
+ int y = (int)std::abs(ys) << 15;
+
+ int tg22x = x * TG22;
+
+ if (y < tg22x)
+ {
+ if (m > _mag_a[k - 1] && m >= _mag_a[k + 1])
+ {
+ CANNY_CHECK_SIMD(m, high, (_pmap+k), stack);
+ }
+ }
+ else
+ {
+ int tg67x = tg22x + (x << 16);
+ if (y > tg67x)
+ {
+ if (m > _mag_p[k] && m >= _mag_n[k])
+ {
+ CANNY_CHECK_SIMD(m, high, (_pmap+k), stack);
+ }
+ }
+ else
+ {
+ int s = (xs ^ ys) < 0 ? -1 : 1;
+ if(m > _mag_p[k - s] && m > _mag_n[k + s])
+ {
+ CANNY_CHECK_SIMD(m, high, (_pmap+k), stack);
+ }
+ }
+ }
+ ++k;
+ } while((mask >>= 1));
}
+ j += 16;
}
}
#endif
for (; j < src.cols; j++)
{
- int m = _mag[j];
+ int m = _mag_a[j];
if (m > low)
{
- int xs = _x[j];
- int ys = _y[j];
- int x = std::abs(xs);
- int y = std::abs(ys) << CANNY_SHIFT;
+ short xs = _dx[j];
+ short ys = _dy[j];
+ int x = (int)std::abs(xs);
+ int y = (int)std::abs(ys) << 15;
int tg22x = x * TG22;
if (y < tg22x)
{
- if (m > _mag[j-1] && m >= _mag[j+1]) goto _canny_push;
+ if (m > _mag_a[j - 1] && m >= _mag_a[j + 1])
+ {
+ CANNY_CHECK(m, high, (_pmap+j), stack);
+ }
}
else
{
- int tg67x = tg22x + (x << (CANNY_SHIFT+1));
+ int tg67x = tg22x + (x << 16);
if (y > tg67x)
{
- if (m > _mag[j+magstep2] && m >= _mag[j+magstep1]) goto _canny_push;
+ if (m > _mag_p[j] && m >= _mag_n[j])
+ {
+ CANNY_CHECK(m, high, (_pmap+j), stack);
+ }
}
else
{
int s = (xs ^ ys) < 0 ? -1 : 1;
- if (m > _mag[j+magstep2-s] && m > _mag[j+magstep1+s]) goto _canny_push;
+ if(m > _mag_p[j - s] && m > _mag_n[j + s])
+ {
+ CANNY_CHECK(m, high, (_pmap+j), stack);
+ }
}
}
}
-
- prev_flag = 0;
- _map[j] = uchar(1);
- continue;
-
-_canny_push:
- // _map[j-mapstep] is short-circuited at the start because previous thread is
- // responsible for initializing it.
- if (!prev_flag && m > high && (i <= boundaries.start+1 || _map[j-mapstep] != 2) )
- {
- CANNY_PUSH(_map + j);
- prev_flag = 1;
- }
- else
- _map[j] = 0;
+ _pmap[j] = 1;
}
-
- // scroll the ring buffer
- _mag = mag_buf[0];
- mag_buf[0] = mag_buf[1];
- mag_buf[1] = mag_buf[2];
- mag_buf[2] = _mag;
}
+ // Not for first row of first slice or last row of last slice
+ uchar *pmapLower = (rowStart == 0) ? map.data : (map.data + (boundaries.start + 2) * mapstep);
+ uint pmapDiff = (uint)(((rowEnd == src.rows) ? map.datalimit : (map.data + boundaries.end * mapstep)) - pmapLower);
+
// now track the edges (hysteresis thresholding)
- while (stack_top > stack_bottom)
+ CV_TRACE_REGION_NEXT("hysteresis");
+ while (!stack.empty())
{
- if ((stack_top - stack_bottom) + 8 > maxsize)
- {
- int sz = (int)(stack_top - stack_bottom);
- maxsize = maxsize * 3/2;
- stack.resize(maxsize);
- stack_bottom = &stack[0];
- stack_top = stack_bottom + sz;
- }
-
- uchar* m;
- CANNY_POP(m);
+ uchar *m = stack.back();
+ stack.pop_back();
// Stops thresholding from expanding to other slices by sending pixels in the borders of each
// slice in a queue to be serially processed later.
- if ( (m < map + (boundaries.start + 2) * mapstep) || (m >= map + boundaries.end * mapstep) )
+ if((unsigned)(m - pmapLower) < pmapDiff)
{
- borderPeaksLocal.push(m);
- continue;
+ if (!m[-mapstep-1]) CANNY_PUSH((m-mapstep-1), stack);
+ if (!m[-mapstep]) CANNY_PUSH((m-mapstep), stack);
+ if (!m[-mapstep+1]) CANNY_PUSH((m-mapstep+1), stack);
+ if (!m[-1]) CANNY_PUSH((m-1), stack);
+ if (!m[1]) CANNY_PUSH((m+1), stack);
+ if (!m[mapstep-1]) CANNY_PUSH((m+mapstep-1), stack);
+ if (!m[mapstep]) CANNY_PUSH((m+mapstep), stack);
+ if (!m[mapstep+1]) CANNY_PUSH((m+mapstep+1), stack);
+ }
+ else
+ {
+ borderPeaksLocal.push_back(m);
+ ptrdiff_t mapstep2 = m < pmapLower ? mapstep : -mapstep;
+
+ if (!m[-1]) CANNY_PUSH((m-1), stack);
+ if (!m[1]) CANNY_PUSH((m+1), stack);
+ if (!m[mapstep2-1]) CANNY_PUSH((m+mapstep2-1), stack);
+ if (!m[mapstep2]) CANNY_PUSH((m+mapstep2), stack);
+ if (!m[mapstep2+1]) CANNY_PUSH((m+mapstep2+1), stack);
}
-
- if (!m[-1]) CANNY_PUSH(m - 1);
- if (!m[1]) CANNY_PUSH(m + 1);
- if (!m[-mapstep-1]) CANNY_PUSH(m - mapstep - 1);
- if (!m[-mapstep]) CANNY_PUSH(m - mapstep);
- if (!m[-mapstep+1]) CANNY_PUSH(m - mapstep + 1);
- if (!m[mapstep-1]) CANNY_PUSH(m + mapstep - 1);
- if (!m[mapstep]) CANNY_PUSH(m + mapstep);
- if (!m[mapstep+1]) CANNY_PUSH(m + mapstep + 1);
}
- AutoLock lock(mutex);
- while (!borderPeaksLocal.empty()) {
- _borderPeaksParallel->push(borderPeaksLocal.front());
- borderPeaksLocal.pop();
+ if(!borderPeaksLocal.empty())
+ {
+ AutoLock lock(mutex);
+ _borderPeaksParallel.insert(_borderPeaksParallel.end(), borderPeaksLocal.begin(), borderPeaksLocal.end());
}
}
private:
- const Mat& src;
- uchar* map;
+ const Mat &src, &src2;
+ Mat ↦
+ std::deque<uchar*> &_borderPeaksParallel;
int low, high, aperture_size;
- bool L2gradient;
- std::queue<uchar*> *_borderPeaksParallel;
+ bool L2gradient, needGradient;
+ ptrdiff_t mapstep;
+ int cn;
+#if CV_SIMD128
+ bool haveSIMD;
+#endif
mutable Mutex mutex;
};
@@ -699,8 +801,14 @@ class finalPass : public ParallelLoopBody
{
public:
- finalPass(uchar *_map, Mat &_dst, ptrdiff_t _mapstep) :
- map(_map), dst(_dst), mapstep(_mapstep) {}
+ finalPass(const Mat &_map, Mat &_dst) :
+ map(_map), dst(_dst)
+ {
+ dst = _dst;
+#if CV_SIMD128
+ haveSIMD = hasSIMD128();
+#endif
+ }
~finalPass() {}
@@ -709,28 +817,26 @@ public:
void operator()(const Range &boundaries) const
{
// the final pass, form the final image
- const uchar* pmap = map + mapstep + 1 + (ptrdiff_t)(mapstep * boundaries.start);
- uchar* pdst = dst.ptr() + (ptrdiff_t)(dst.step * boundaries.start);
-
-#if CV_SIMD128
- bool haveSIMD = hasSIMD128();
-#endif
-
- for (int i = boundaries.start; i < boundaries.end; i++, pmap += mapstep, pdst += dst.step)
+ for (int i = boundaries.start; i < boundaries.end; i++)
{
int j = 0;
+ uchar *pdst = dst.ptr<uchar>(i);
+ uchar *pmap;
+#if CV_SIMD128
+ if(haveSIMD)
+ pmap = (uchar*)map.ptr<uchar>(i + 1) + CV_MALLOC_SIMD128;
+ else
+#endif
+ pmap = (uchar*)map.ptr<uchar>(i + 1) + 1;
#if CV_SIMD128
if(haveSIMD) {
const v_int8x16 v_zero = v_setzero_s8();
for(; j <= dst.cols - 32; j += 32) {
- v_uint8x16 v_pmap1 = v_load((const unsigned char*)(pmap + j));
- v_uint8x16 v_pmap2 = v_load((const unsigned char*)(pmap + j + 16));
+ v_uint8x16 v_pmap1 = v_load_aligned((const unsigned char*)(pmap + j));
+ v_uint8x16 v_pmap2 = v_load_aligned((const unsigned char*)(pmap + j + 16));
- v_uint16x8 v_pmaplo1;
- v_uint16x8 v_pmaphi1;
- v_uint16x8 v_pmaplo2;
- v_uint16x8 v_pmaphi2;
+ v_uint16x8 v_pmaplo1, v_pmaphi1, v_pmaplo2, v_pmaphi2;
v_expand(v_pmap1, v_pmaplo1, v_pmaphi1);
v_expand(v_pmap2, v_pmaplo2, v_pmaphi2);
@@ -749,8 +855,8 @@ public:
v_store((pdst + j + 16), v_pmap2);
}
- for(; j <= dst.cols - 16; j += 16) {
- v_uint8x16 v_pmap = v_load((const unsigned char*)(pmap + j));
+ if(j <= dst.cols - 16) {
+ v_uint8x16 v_pmap = v_load_aligned((const unsigned char*)(pmap + j));
v_uint16x8 v_pmaplo;
v_uint16x8 v_pmaphi;
@@ -763,6 +869,24 @@ public:
v_pmap = v_reinterpret_as_u8(v_zero - v_reinterpret_as_s8(v_pmap));
v_store((pdst + j), v_pmap);
+ j += 16;
+ }
+
+ if(j <= dst.cols - 8) {
+ v_uint8x16 v_pmap = v_load_halves((const unsigned char*)(pmap + j), (const unsigned char*)(pmap + j));
+
+ v_uint16x8 v_pmaplo;
+ v_uint16x8 v_pmaphi;
+ v_expand(v_pmap, v_pmaplo, v_pmaphi);
+
+ v_pmaplo = v_pmaplo >> 1;
+ v_pmaphi = v_pmaphi >> 1;
+
+ v_pmap = v_pack(v_pmaplo, v_pmaphi);
+ v_pmap = v_reinterpret_as_u8(v_zero - v_reinterpret_as_s8(v_pmap));
+
+ v_store_low((pdst + j), v_pmap);
+ j += 8;
}
}
#endif
@@ -772,17 +896,22 @@ public:
}
private:
- uchar *map;
+ const Mat ↦
Mat &dst;
- ptrdiff_t mapstep;
+#if CV_SIMD128
+ bool haveSIMD;
+#endif
};
#ifdef HAVE_OPENVX
+namespace ovx {
+ template <> inline bool skipSmallImages<VX_KERNEL_CANNY_EDGE_DETECTOR>(int w, int h) { return w*h < 640 * 480; }
+}
static bool openvx_canny(const Mat& src, Mat& dst, int loVal, int hiVal, int kSize, bool useL2)
{
using namespace ivx;
- Context context = Context::create();
+ Context context = ovx::getOpenVXContext();
try
{
Image _src = Image::createFromHandle(
@@ -839,10 +968,13 @@ void Canny( InputArray _src, OutputArray _dst,
{
CV_INSTRUMENT_REGION()
- const int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
+ CV_Assert( _src.depth() == CV_8U );
+
const Size size = _src.size();
- CV_Assert( depth == CV_8U );
+ // we don't support inplace parameters in case with RGB/BGR src
+ CV_Assert((_dst.getObj() != _src.getObj() || _src.type() == CV_8UC1) && "Inplace parameters are not supported");
+
_dst.create(size, CV_8U);
if (!L2gradient && (aperture_size & CV_CANNY_L2_GRADIENT) == CV_CANNY_L2_GRADIENT)
@@ -858,8 +990,8 @@ void Canny( InputArray _src, OutputArray _dst,
if (low_thresh > high_thresh)
std::swap(low_thresh, high_thresh);
- CV_OCL_RUN(_dst.isUMat() && (cn == 1 || cn == 3),
- ocl_Canny<false>(_src, UMat(), UMat(), _dst, (float)low_thresh, (float)high_thresh, aperture_size, L2gradient, cn, size))
+ CV_OCL_RUN(_dst.isUMat() && (_src.channels() == 1 || _src.channels() == 3),
+ ocl_Canny<false>(_src, UMat(), UMat(), _dst, (float)low_thresh, (float)high_thresh, aperture_size, L2gradient, _src.channels(), size))
Mat src = _src.getMat(), dst = _dst.getMat();
@@ -868,7 +1000,8 @@ void Canny( InputArray _src, OutputArray _dst,
src.type() == CV_8UC1 &&
!src.isSubmatrix() &&
src.cols >= aperture_size &&
- src.rows >= aperture_size,
+ src.rows >= aperture_size &&
+ !ovx::skipSmallImages<VX_KERNEL_CANNY_EDGE_DETECTOR>(src.cols, src.rows),
openvx_canny(
src,
dst,
@@ -882,79 +1015,63 @@ void Canny( InputArray _src, OutputArray _dst,
return;
#endif
- CV_IPP_RUN(USE_IPP_CANNY && (aperture_size == 3 && !L2gradient && 1 == cn), ippCanny<false>(src, Mat(), Mat(), dst, (float)low_thresh, (float)high_thresh))
-
-if (L2gradient)
-{
- low_thresh = std::min(32767.0, low_thresh);
- high_thresh = std::min(32767.0, high_thresh);
-
- if (low_thresh > 0) low_thresh *= low_thresh;
- if (high_thresh > 0) high_thresh *= high_thresh;
-}
-int low = cvFloor(low_thresh);
-int high = cvFloor(high_thresh);
-
- ptrdiff_t mapstep = src.cols + 2;
- AutoBuffer<uchar> buffer((src.cols+2)*(src.rows+2) + cn * mapstep * 3 * sizeof(int));
+ CV_IPP_RUN_FAST(ipp_Canny(src, Mat(), Mat(), dst, (float)low_thresh, (float)high_thresh, L2gradient, aperture_size))
- int* mag_buf[3];
- mag_buf[0] = (int*)(uchar*)buffer;
- mag_buf[1] = mag_buf[0] + mapstep*cn;
- mag_buf[2] = mag_buf[1] + mapstep*cn;
- memset(mag_buf[0], 0, /* cn* */mapstep*sizeof(int));
+ if (L2gradient)
+ {
+ low_thresh = std::min(32767.0, low_thresh);
+ high_thresh = std::min(32767.0, high_thresh);
- uchar *map = (uchar*)(mag_buf[2] + mapstep*cn);
- memset(map, 1, mapstep);
- memset(map + mapstep*(src.rows + 1), 1, mapstep);
+ if (low_thresh > 0) low_thresh *= low_thresh;
+ if (high_thresh > 0) high_thresh *= high_thresh;
+ }
+ int low = cvFloor(low_thresh);
+ int high = cvFloor(high_thresh);
+ // If Scharr filter: aperture size is 3, ksize2 is 1
+ int ksize2 = aperture_size < 0 ? 1 : aperture_size / 2;
// Minimum number of threads should be 1, maximum should not exceed number of CPU's, because of overhead
int numOfThreads = std::max(1, std::min(getNumThreads(), getNumberOfCPUs()));
-
// Make a fallback for pictures with too few rows.
int grainSize = src.rows / numOfThreads;
- int ksize2 = aperture_size / 2;
- // If Scharr filter: aperture size is 3, ksize2 is 1
- if(aperture_size == -1)
- {
- ksize2 = 1;
- }
-
int minGrainSize = 2 * (ksize2 + 1);
if (grainSize < minGrainSize)
- {
numOfThreads = std::max(1, src.rows / minGrainSize);
- }
-
- std::queue<uchar*> borderPeaksParallel;
- parallel_for_(Range(0, src.rows), parallelCanny(src, map, low, high, aperture_size, L2gradient, &borderPeaksParallel), numOfThreads);
+ Mat map;
+ std::deque<uchar*> stack;
-#define CANNY_PUSH_SERIAL(d) *(d) = uchar(2), borderPeaksParallel.push(d)
+ parallel_for_(Range(0, src.rows), parallelCanny(src, map, stack, low, high, aperture_size, L2gradient), numOfThreads);
+ CV_TRACE_REGION("global_hysteresis");
// now track the edges (hysteresis thresholding)
- uchar* m;
- while (!borderPeaksParallel.empty())
+ ptrdiff_t mapstep = map.cols;
+
+ while (!stack.empty())
{
- m = borderPeaksParallel.front();
- borderPeaksParallel.pop();
- if (!m[-1]) CANNY_PUSH_SERIAL(m - 1);
- if (!m[1]) CANNY_PUSH_SERIAL(m + 1);
- if (!m[-mapstep-1]) CANNY_PUSH_SERIAL(m - mapstep - 1);
- if (!m[-mapstep]) CANNY_PUSH_SERIAL(m - mapstep);
- if (!m[-mapstep+1]) CANNY_PUSH_SERIAL(m - mapstep + 1);
- if (!m[mapstep-1]) CANNY_PUSH_SERIAL(m + mapstep - 1);
- if (!m[mapstep]) CANNY_PUSH_SERIAL(m + mapstep);
- if (!m[mapstep+1]) CANNY_PUSH_SERIAL(m + mapstep + 1);
-}
+ uchar* m = stack.back();
+ stack.pop_back();
+
+ if (!m[-mapstep-1]) CANNY_PUSH((m-mapstep-1), stack);
+ if (!m[-mapstep]) CANNY_PUSH((m-mapstep), stack);
+ if (!m[-mapstep+1]) CANNY_PUSH((m-mapstep+1), stack);
+ if (!m[-1]) CANNY_PUSH((m-1), stack);
+ if (!m[1]) CANNY_PUSH((m+1), stack);
+ if (!m[mapstep-1]) CANNY_PUSH((m+mapstep-1), stack);
+ if (!m[mapstep]) CANNY_PUSH((m+mapstep), stack);
+ if (!m[mapstep+1]) CANNY_PUSH((m+mapstep+1), stack);
+ }
- parallel_for_(Range(0, dst.rows), finalPass(map, dst, mapstep), dst.total()/(double)(1<<16));
+ CV_TRACE_REGION_NEXT("finalPass");
+ parallel_for_(Range(0, src.rows), finalPass(map, dst), src.total()/(double)(1<<16));
}
void Canny( InputArray _dx, InputArray _dy, OutputArray _dst,
double low_thresh, double high_thresh,
bool L2gradient )
{
+ CV_INSTRUMENT_REGION()
+
CV_Assert(_dx.dims() == 2);
CV_Assert(_dx.type() == CV_16SC1 || _dx.type() == CV_16SC3);
CV_Assert(_dy.type() == _dx.type());
@@ -963,11 +1080,10 @@ void Canny( InputArray _dx, InputArray _dy, OutputArray _dst,
if (low_thresh > high_thresh)
std::swap(low_thresh, high_thresh);
- const int cn = _dx.channels();
const Size size = _dx.size();
CV_OCL_RUN(_dst.isUMat(),
- ocl_Canny<true>(UMat(), _dx.getUMat(), _dy.getUMat(), _dst, (float)low_thresh, (float)high_thresh, 0, L2gradient, cn, size))
+ ocl_Canny<true>(UMat(), _dx.getUMat(), _dy.getUMat(), _dst, (float)low_thresh, (float)high_thresh, 0, L2gradient, _dx.channels(), size))
_dst.create(size, CV_8U);
Mat dst = _dst.getMat();
@@ -975,21 +1091,7 @@ void Canny( InputArray _dx, InputArray _dy, OutputArray _dst,
Mat dx = _dx.getMat();
Mat dy = _dy.getMat();
- CV_IPP_RUN(USE_IPP_CANNY && (!L2gradient && 1 == cn), ippCanny<true>(Mat(), dx, dy, dst, (float)low_thresh, (float)high_thresh))
-
- if (cn > 1)
- {
- dx = dx.clone();
- dy = dy.clone();
- }
- CannyImpl(dx, dy, dst, low_thresh, high_thresh, L2gradient);
-}
-
-static void CannyImpl(Mat& dx, Mat& dy, Mat& dst,
- double low_thresh, double high_thresh, bool L2gradient)
-{
- const int cn = dx.channels();
- const int cols = dx.cols, rows = dx.rows;
+ CV_IPP_RUN_FAST(ipp_Canny(Mat(), dx, dy, dst, (float)low_thresh, (float)high_thresh, L2gradient, 0))
if (L2gradient)
{
@@ -999,316 +1101,41 @@ static void CannyImpl(Mat& dx, Mat& dy, Mat& dst,
if (low_thresh > 0) low_thresh *= low_thresh;
if (high_thresh > 0) high_thresh *= high_thresh;
}
+
int low = cvFloor(low_thresh);
int high = cvFloor(high_thresh);
- ptrdiff_t mapstep = cols + 2;
- AutoBuffer<uchar> buffer((cols+2)*(rows+2) + cn * mapstep * 3 * sizeof(int));
-
- int* mag_buf[3];
- mag_buf[0] = (int*)(uchar*)buffer;
- mag_buf[1] = mag_buf[0] + mapstep*cn;
- mag_buf[2] = mag_buf[1] + mapstep*cn;
- memset(mag_buf[0], 0, /* cn* */mapstep*sizeof(int));
-
- uchar* map = (uchar*)(mag_buf[2] + mapstep*cn);
- memset(map, 1, mapstep);
- memset(map + mapstep*(rows + 1), 1, mapstep);
-
- int maxsize = std::max(1 << 10, cols * rows / 10);
- std::vector<uchar*> stack(maxsize);
- uchar **stack_top = &stack[0];
- uchar **stack_bottom = &stack[0];
-
- /* sector numbers
- (Top-Left Origin)
-
- 1 2 3
- * * *
- * * *
- 0*******0
- * * *
- * * *
- 3 2 1
- */
-
- #define CANNY_PUSH(d) *(d) = uchar(2), *stack_top++ = (d)
- #define CANNY_POP(d) (d) = *--stack_top
-
-#if CV_SIMD128
- bool haveSIMD = hasSIMD128();
-#endif
-
- // calculate magnitude and angle of gradient, perform non-maxima suppression.
- // fill the map with one of the following values:
- // 0 - the pixel might belong to an edge
- // 1 - the pixel can not belong to an edge
- // 2 - the pixel does belong to an edge
- for (int i = 0; i <= rows; i++)
- {
- int* _norm = mag_buf[(i > 0) + 1] + 1;
- if (i < rows)
- {
- short* _dx = dx.ptr<short>(i);
- short* _dy = dy.ptr<short>(i);
-
- if (!L2gradient)
- {
- int j = 0, width = cols * cn;
-#if CV_SIMD128
- if (haveSIMD)
- {
- for ( ; j <= width - 8; j += 8)
- {
- v_int16x8 v_dx = v_load((const short*)(_dx + j));
- v_int16x8 v_dy = v_load((const short*)(_dy + j));
-
- v_int32x4 v_dx0, v_dx1, v_dy0, v_dy1;
- v_expand(v_dx, v_dx0, v_dx1);
- v_expand(v_dy, v_dy0, v_dy1);
-
- v_dx0 = v_reinterpret_as_s32(v_abs(v_dx0));
- v_dx1 = v_reinterpret_as_s32(v_abs(v_dx1));
- v_dy0 = v_reinterpret_as_s32(v_abs(v_dy0));
- v_dy1 = v_reinterpret_as_s32(v_abs(v_dy1));
+ std::deque<uchar*> stack;
+ Mat map;
- v_store(_norm + j, v_dx0 + v_dy0);
- v_store(_norm + j + 4, v_dx1 + v_dy1);
- }
- }
-#endif
- for ( ; j < width; ++j)
- _norm[j] = std::abs(int(_dx[j])) + std::abs(int(_dy[j]));
- }
- else
- {
- int j = 0, width = cols * cn;
-#if CV_SIMD128
- if (haveSIMD)
- {
- for ( ; j <= width - 8; j += 8)
- {
- v_int16x8 v_dx = v_load((const short*)(_dx + j));
- v_int16x8 v_dy = v_load((const short*)(_dy + j));
-
- v_int16x8 v_dx_dy0, v_dx_dy1;
- v_zip(v_dx, v_dy, v_dx_dy0, v_dx_dy1);
-
- v_int32x4 v_dst0 = v_dotprod(v_dx_dy0, v_dx_dy0);
- v_int32x4 v_dst1 = v_dotprod(v_dx_dy1, v_dx_dy1);
-
- v_store(_norm + j, v_dst0);
- v_store(_norm + j + 4, v_dst1);
- }
- }
-#endif
- for ( ; j < width; ++j)
- _norm[j] = int(_dx[j])*_dx[j] + int(_dy[j])*_dy[j];
- }
-
- if (cn > 1)
- {
- for(int j = 0, jn = 0; j < cols; ++j, jn += cn)
- {
- int maxIdx = jn;
- for(int k = 1; k < cn; ++k)
- if(_norm[jn + k] > _norm[maxIdx]) maxIdx = jn + k;
- _norm[j] = _norm[maxIdx];
- _dx[j] = _dx[maxIdx];
- _dy[j] = _dy[maxIdx];
- }
- }
- _norm[-1] = _norm[cols] = 0;
- }
- else
- memset(_norm-1, 0, /* cn* */mapstep*sizeof(int));
-
- // at the very beginning we do not have a complete ring
- // buffer of 3 magnitude rows for non-maxima suppression
- if (i == 0)
- continue;
-
- uchar* _map = map + mapstep*i + 1;
- _map[-1] = _map[cols] = 1;
-
- int* _mag = mag_buf[1] + 1; // take the central row
- ptrdiff_t magstep1 = mag_buf[2] - mag_buf[1];
- ptrdiff_t magstep2 = mag_buf[0] - mag_buf[1];
-
- const short* _x = dx.ptr<short>(i-1);
- const short* _y = dy.ptr<short>(i-1);
-
- if ((stack_top - stack_bottom) + cols > maxsize)
- {
- int sz = (int)(stack_top - stack_bottom);
- maxsize = std::max(maxsize * 3/2, sz + cols);
- stack.resize(maxsize);
- stack_bottom = &stack[0];
- stack_top = stack_bottom + sz;
- }
-
-#define CANNY_SHIFT 15
- const int TG22 = (int)(0.4142135623730950488016887242097*(1<<CANNY_SHIFT) + 0.5);
-
- int prev_flag = 0, j = 0;
-#if CV_SIMD128
- if (haveSIMD)
- {
- v_int32x4 v_low = v_setall_s32(low);
- v_int8x16 v_one = v_setall_s8(1);
-
- for (; j <= cols - 16; j += 16)
- {
- v_int32x4 v_m1 = v_load((const int*)(_mag + j));
- v_int32x4 v_m2 = v_load((const int*)(_mag + j + 4));
- v_int32x4 v_m3 = v_load((const int*)(_mag + j + 8));
- v_int32x4 v_m4 = v_load((const int*)(_mag + j + 12));
-
- v_store((signed char*)(_map + j), v_one);
-
- v_int32x4 v_cmp1 = v_m1 > v_low;
- v_int32x4 v_cmp2 = v_m2 > v_low;
- v_int32x4 v_cmp3 = v_m3 > v_low;
- v_int32x4 v_cmp4 = v_m4 > v_low;
-
- v_int16x8 v_cmp80 = v_pack(v_cmp1, v_cmp2);
- v_int16x8 v_cmp81 = v_pack(v_cmp3, v_cmp4);
-
- v_int8x16 v_cmp = v_pack(v_cmp80, v_cmp81);
- unsigned int mask = v_signmask(v_cmp);
-
- if (mask)
- {
- int m, k = j;
-
- for (; mask; ++k, mask >>= 1)
- {
- if (mask & 0x00000001)
- {
- m = _mag[k];
- int xs = _x[k];
- int ys = _y[k];
- int x = std::abs(xs);
- int y = std::abs(ys) << CANNY_SHIFT;
-
- int tg22x = x * TG22;
-
- if (y < tg22x)
- {
- if (m > _mag[k - 1] && m >= _mag[k + 1]) goto ocv_canny_push_sse;
- }
- else
- {
- int tg67x = tg22x + (x << (CANNY_SHIFT + 1));
- if (y > tg67x)
- {
- if (m > _mag[k + magstep2] && m >= _mag[k + magstep1]) goto ocv_canny_push_sse;
- } else
- {
- int s = (xs ^ ys) < 0 ? -1 : 1;
- if (m > _mag[k + magstep2 - s] && m > _mag[k + magstep1 + s]) goto ocv_canny_push_sse;
- }
- }
- }
-
- prev_flag = 0;
- continue;
-
-ocv_canny_push_sse:
- // _map[k-mapstep] is short-circuited at the start because previous thread is
- // responsible for initializing it.
- if (!prev_flag && m > high && _map[k-mapstep] != 2)
- {
- CANNY_PUSH(_map + k);
- prev_flag = 1;
- } else
- _map[k] = 0;
-
- }
-
- if (prev_flag && ((k < j+16) || (k < cols && _mag[k] <= high)))
- prev_flag = 0;
- }
- }
- }
-#endif
- for (; j < cols; j++)
- {
- int m = _mag[j];
-
- if (m > low)
- {
- int xs = _x[j];
- int ys = _y[j];
- int x = std::abs(xs);
- int y = std::abs(ys) << CANNY_SHIFT;
-
- int tg22x = x * TG22;
-
- if (y < tg22x)
- {
- if (m > _mag[j-1] && m >= _mag[j+1]) goto __ocv_canny_push;
- }
- else
- {
- int tg67x = tg22x + (x << (CANNY_SHIFT+1));
- if (y > tg67x)
- {
- if (m > _mag[j+magstep2] && m >= _mag[j+magstep1]) goto __ocv_canny_push;
- }
- else
- {
- int s = (xs ^ ys) < 0 ? -1 : 1;
- if (m > _mag[j+magstep2-s] && m > _mag[j+magstep1+s]) goto __ocv_canny_push;
- }
- }
- }
- prev_flag = 0;
- _map[j] = uchar(1);
- continue;
-__ocv_canny_push:
- if (!prev_flag && m > high && _map[j-mapstep] != 2)
- {
- CANNY_PUSH(_map + j);
- prev_flag = 1;
- }
- else
- _map[j] = 0;
- }
+ // Minimum number of threads should be 1, maximum should not exceed number of CPU's, because of overhead
+ int numOfThreads = std::max(1, std::min(getNumThreads(), getNumberOfCPUs()));
+ if (dx.rows / numOfThreads < 3)
+ numOfThreads = std::max(1, dx.rows / 3);
- // scroll the ring buffer
- _mag = mag_buf[0];
- mag_buf[0] = mag_buf[1];
- mag_buf[1] = mag_buf[2];
- mag_buf[2] = _mag;
- }
+ parallel_for_(Range(0, dx.rows), parallelCanny(dx, dy, map, stack, low, high, L2gradient), numOfThreads);
+ CV_TRACE_REGION("global_hysteresis")
// now track the edges (hysteresis thresholding)
- while (stack_top > stack_bottom)
- {
- uchar* m;
- if ((stack_top - stack_bottom) + 8 > maxsize)
- {
- int sz = (int)(stack_top - stack_bottom);
- maxsize = maxsize * 3/2;
- stack.resize(maxsize);
- stack_bottom = &stack[0];
- stack_top = stack_bottom + sz;
- }
+ ptrdiff_t mapstep = map.cols;
- CANNY_POP(m);
-
- if (!m[-1]) CANNY_PUSH(m - 1);
- if (!m[1]) CANNY_PUSH(m + 1);
- if (!m[-mapstep-1]) CANNY_PUSH(m - mapstep - 1);
- if (!m[-mapstep]) CANNY_PUSH(m - mapstep);
- if (!m[-mapstep+1]) CANNY_PUSH(m - mapstep + 1);
- if (!m[mapstep-1]) CANNY_PUSH(m + mapstep - 1);
- if (!m[mapstep]) CANNY_PUSH(m + mapstep);
- if (!m[mapstep+1]) CANNY_PUSH(m + mapstep + 1);
+ while (!stack.empty())
+ {
+ uchar* m = stack.back();
+ stack.pop_back();
+
+ if (!m[-mapstep-1]) CANNY_PUSH((m-mapstep-1), stack);
+ if (!m[-mapstep]) CANNY_PUSH((m-mapstep), stack);
+ if (!m[-mapstep+1]) CANNY_PUSH((m-mapstep+1), stack);
+ if (!m[-1]) CANNY_PUSH((m-1), stack);
+ if (!m[1]) CANNY_PUSH((m+1), stack);
+ if (!m[mapstep-1]) CANNY_PUSH((m+mapstep-1), stack);
+ if (!m[mapstep]) CANNY_PUSH((m+mapstep), stack);
+ if (!m[mapstep+1]) CANNY_PUSH((m+mapstep+1), stack);
}
- parallel_for_(Range(0, dst.rows), finalPass(map, dst, mapstep), dst.total()/(double)(1<<16));
+ CV_TRACE_REGION_NEXT("finalPass");
+ parallel_for_(Range(0, dx.rows), finalPass(map, dst), dx.total()/(double)(1<<16));
}
} // namespace cv
diff --git a/modules/imgproc/src/color.cpp b/modules/imgproc/src/color.cpp
index b571e1e..08153fe 100644
--- a/modules/imgproc/src/color.cpp
+++ b/modules/imgproc/src/color.cpp
@@ -94,6 +94,8 @@
#include "opencl_kernels_imgproc.hpp"
#include <limits>
#include "hal_replacement.hpp"
+#include "opencv2/core/hal/intrin.hpp"
+#include "opencv2/core/softfloat.hpp"
#define CV_DESCALE(x,n) (((x) + (1 << ((n)-1))) >> (n))
@@ -138,7 +140,6 @@ const int CB2GI = -5636;
const int CR2GI = -11698;
const int CR2RI = 22987;
-
// computes cubic spline coefficients for a function: (xi=i, yi=f[i]), i=0..n
template<typename _Tp> static void splineBuild(const _Tp* f, int n, _Tp* tab)
{
@@ -164,6 +165,32 @@ template<typename _Tp> static void splineBuild(const _Tp* f, int n, _Tp* tab)
}
}
+static void splineBuild(const softfloat* f, int n, float* tab)
+{
+ const softfloat f2(2), f3(3), f4(4);
+ softfloat cn(0);
+ softfloat* sftab = reinterpret_cast<softfloat*>(tab);
+ int i;
+ tab[0] = tab[1] = 0.0f;
+
+ for(i = 1; i < n-1; i++)
+ {
+ softfloat t = (f[i+1] - f[i]*f2 + f[i-1])*f3;
+ softfloat l = softfloat::one()/(f4 - sftab[(i-1)*4]);
+ sftab[i*4] = l; sftab[i*4+1] = (t - sftab[(i-1)*4+1])*l;
+ }
+
+ for(i = n-1; i >= 0; i--)
+ {
+ softfloat c = sftab[i*4+1] - sftab[i*4]*cn;
+ softfloat b = f[i+1] - f[i] - (cn + c*f2)/f3;
+ softfloat d = (cn - c)/f3;
+ sftab[i*4] = f[i]; sftab[i*4+1] = b;
+ sftab[i*4+2] = c; sftab[i*4+3] = d;
+ cn = c;
+ }
+}
+
// interpolates value of a function at x, 0 <= x <= n using a cubic spline.
template<typename _Tp> static inline _Tp splineInterpolate(_Tp x, const _Tp* tab, int n)
{
@@ -271,6 +298,8 @@ public:
virtual void operator()(const Range& range) const
{
+ CV_TRACE_FUNCTION();
+
const uchar* yS = src_data + static_cast<size_t>(range.start) * src_step;
uchar* yD = dst_data + static_cast<size_t>(range.start) * dst_step;
@@ -446,19 +475,23 @@ static ippiGeneralFunc ippiCopyP3C3RTab[] =
0, (ippiGeneralFunc)ippiCopy_32f_P3C3R, 0, 0
};
+#if !IPP_DISABLE_RGB_XYZ
static ippiGeneralFunc ippiRGB2XYZTab[] =
{
(ippiGeneralFunc)ippiRGBToXYZ_8u_C3R, 0, (ippiGeneralFunc)ippiRGBToXYZ_16u_C3R, 0,
0, (ippiGeneralFunc)ippiRGBToXYZ_32f_C3R, 0, 0
};
+#endif
+#if !IPP_DISABLE_XYZ_RGB
static ippiGeneralFunc ippiXYZ2RGBTab[] =
{
(ippiGeneralFunc)ippiXYZToRGB_8u_C3R, 0, (ippiGeneralFunc)ippiXYZToRGB_16u_C3R, 0,
0, (ippiGeneralFunc)ippiXYZToRGB_32f_C3R, 0, 0
};
+#endif
-#if IPP_DISABLE_BLOCK
+#if !IPP_DISABLE_RGB_HSV
static ippiGeneralFunc ippiRGB2HSVTab[] =
{
(ippiGeneralFunc)ippiRGBToHSV_8u_C3R, 0, (ippiGeneralFunc)ippiRGBToHSV_16u_C3R, 0,
@@ -484,13 +517,15 @@ static ippiGeneralFunc ippiHLS2RGBTab[] =
0, (ippiGeneralFunc)ippiHLSToRGB_32f_C3R, 0, 0
};
-#if IPP_DISABLE_BLOCK
+#if !IPP_DISABLE_RGB_LAB
static ippiGeneralFunc ippiRGBToLUVTab[] =
{
(ippiGeneralFunc)ippiRGBToLUV_8u_C3R, 0, (ippiGeneralFunc)ippiRGBToLUV_16u_C3R, 0,
0, (ippiGeneralFunc)ippiRGBToLUV_32f_C3R, 0, 0
};
+#endif
+#if !IPP_DISABLE_LAB_RGB
static ippiGeneralFunc ippiLUVToRGBTab[] =
{
(ippiGeneralFunc)ippiLUVToRGB_8u_C3R, 0, (ippiGeneralFunc)ippiLUVToRGB_16u_C3R, 0,
@@ -682,7 +717,7 @@ template<typename _Tp> struct RGB2RGB
for( int i = 0; i < n; i += 4 )
{
_Tp t0 = src[i], t1 = src[i+1], t2 = src[i+2], t3 = src[i+3];
- dst[i] = t2; dst[i+1] = t1; dst[i+2] = t0; dst[i+3] = t3;
+ dst[i+bidx] = t0; dst[i+1] = t1; dst[i+(bidx^2)] = t2; dst[i+3] = t3;
}
}
}
@@ -796,25 +831,25 @@ template<> struct RGB2RGB<uchar>
for ( ; i <= n - 64; i += 64 )
{
uint8x16x4_t v_src = vld4q_u8(src + i), v_dst;
- v_dst.val[0] = v_src.val[2];
+ v_dst.val[0] = v_src.val[bidx];
v_dst.val[1] = v_src.val[1];
- v_dst.val[2] = v_src.val[0];
+ v_dst.val[2] = v_src.val[bidx^2];
v_dst.val[3] = v_src.val[3];
vst4q_u8(dst + i, v_dst);
}
for ( ; i <= n - 32; i += 32 )
{
uint8x8x4_t v_src = vld4_u8(src + i), v_dst;
- v_dst.val[0] = v_src.val[2];
+ v_dst.val[0] = v_src.val[bidx];
v_dst.val[1] = v_src.val[1];
- v_dst.val[2] = v_src.val[0];
+ v_dst.val[2] = v_src.val[bidx^2];
v_dst.val[3] = v_src.val[3];
vst4_u8(dst + i, v_dst);
}
for ( ; i < n; i += 4)
{
uchar t0 = src[i], t1 = src[i+1], t2 = src[i+2], t3 = src[i+3];
- dst[i] = t2; dst[i+1] = t1; dst[i+2] = t0; dst[i+3] = t3;
+ dst[i+bidx] = t0; dst[i+1] = t1; dst[i+(bidx^2)] = t2; dst[i+3] = t3;
}
}
}
@@ -3446,7 +3481,7 @@ static const float sRGB2XYZ_D65[] =
static const float XYZ2sRGB_D65[] =
{
3.240479f, -1.53715f, -0.498535f,
- -0.969256f, 1.875991f, 0.041556f,
+ -0.969256f, 1.875991f, 0.041556f,
0.055648f, -0.204043f, 1.057311f
};
@@ -4478,7 +4513,7 @@ struct RGB2HSV_b
{
int b = src[bidx], g = src[1], r = src[bidx^2];
int h, s, v = b;
- int vmin = b, diff;
+ int vmin = b;
int vr, vg;
CV_CALC_MAX_8U( v, g );
@@ -4486,7 +4521,7 @@ struct RGB2HSV_b
CV_CALC_MIN_8U( vmin, g );
CV_CALC_MIN_8U( vmin, r );
- diff = v - vmin;
+ uchar diff = saturate_cast<uchar>(v - vmin);
vr = v == r ? -1 : 0;
vg = v == g ? -1 : 0;
@@ -5780,12 +5815,14 @@ static const float D65[] = { 0.950456f, 1.f, 1.088754f };
enum { LAB_CBRT_TAB_SIZE = 1024, GAMMA_TAB_SIZE = 1024 };
static float LabCbrtTab[LAB_CBRT_TAB_SIZE*4];
-static const float LabCbrtTabScale = LAB_CBRT_TAB_SIZE/1.5f;
+static const float LabCbrtTabScale = softfloat(LAB_CBRT_TAB_SIZE*2)/softfloat(3);
static float sRGBGammaTab[GAMMA_TAB_SIZE*4], sRGBInvGammaTab[GAMMA_TAB_SIZE*4];
-static const float GammaTabScale = (float)GAMMA_TAB_SIZE;
+static const float GammaTabScale((int)GAMMA_TAB_SIZE);
static ushort sRGBGammaTab_b[256], linearGammaTab_b[256];
+enum { inv_gamma_shift = 12, INV_GAMMA_TAB_SIZE = (1 << inv_gamma_shift) };
+static ushort sRGBInvGammaTab_b[INV_GAMMA_TAB_SIZE], linearInvGammaTab_b[INV_GAMMA_TAB_SIZE];
#undef lab_shift
#define lab_shift xyz_shift
#define gamma_shift 3
@@ -5793,46 +5830,389 @@ static ushort sRGBGammaTab_b[256], linearGammaTab_b[256];
#define LAB_CBRT_TAB_SIZE_B (256*3/2*(1<<gamma_shift))
static ushort LabCbrtTab_b[LAB_CBRT_TAB_SIZE_B];
+static const bool enableBitExactness = true;
+static const bool enableRGB2LabInterpolation = true;
+static const bool enablePackedLab = true;
+enum
+{
+ lab_lut_shift = 5,
+ LAB_LUT_DIM = (1 << lab_lut_shift)+1,
+ lab_base_shift = 14,
+ LAB_BASE = (1 << lab_base_shift),
+ trilinear_shift = 8 - lab_lut_shift + 1,
+ TRILINEAR_BASE = (1 << trilinear_shift)
+};
+static int16_t RGB2LabLUT_s16[LAB_LUT_DIM*LAB_LUT_DIM*LAB_LUT_DIM*3*8];
+static int16_t trilinearLUT[TRILINEAR_BASE*TRILINEAR_BASE*TRILINEAR_BASE*8];
+static ushort LabToYF_b[256*2];
+static const int minABvalue = -8145;
+static int abToXZ_b[LAB_BASE*9/4];
+
+#define clip(value) \
+ value < 0.0f ? 0.0f : value > 1.0f ? 1.0f : value;
+
+//all constants should be presented through integers to keep bit-exactness
+static const softdouble gammaThreshold = softdouble(809)/softdouble(20000); // 0.04045
+static const softdouble gammaInvThreshold = softdouble(7827)/softdouble(2500000); // 0.0031308
+static const softdouble gammaLowScale = softdouble(323)/softdouble(25); // 12.92
+static const softdouble gammaPower = softdouble(12)/softdouble(5); // 2.4
+static const softdouble gammaXshift = softdouble(11)/softdouble(200); // 0.055
+
+static inline softfloat applyGamma(softfloat x)
+{
+ //return x <= 0.04045f ? x*(1.f/12.92f) : (float)std::pow((double)(x + 0.055)*(1./1.055), 2.4);
+ softdouble xd = x;
+ return (xd <= gammaThreshold ?
+ xd/gammaLowScale :
+ pow((xd + gammaXshift)/(softdouble::one()+gammaXshift), gammaPower));
+}
+
+static inline softfloat applyInvGamma(softfloat x)
+{
+ //return x <= 0.0031308 ? x*12.92f : (float)(1.055*std::pow((double)x, 1./2.4) - 0.055);
+ softdouble xd = x;
+ return (xd <= gammaInvThreshold ?
+ xd*gammaLowScale :
+ pow(xd, softdouble::one()/gammaPower)*(softdouble::one()+gammaXshift) - gammaXshift);
+}
+
static void initLabTabs()
{
static bool initialized = false;
if(!initialized)
{
- float f[LAB_CBRT_TAB_SIZE+1], g[GAMMA_TAB_SIZE+1], ig[GAMMA_TAB_SIZE+1], scale = 1.f/LabCbrtTabScale;
+ static const softfloat lthresh = softfloat(216) / softfloat(24389); // 0.008856f = (6/29)^3
+ static const softfloat lscale = softfloat(841) / softfloat(108); // 7.787f = (29/3)^3/(29*4)
+ static const softfloat lbias = softfloat(16) / softfloat(116);
+ static const softfloat f255(255);
+
+ softfloat f[LAB_CBRT_TAB_SIZE+1], g[GAMMA_TAB_SIZE+1], ig[GAMMA_TAB_SIZE+1];
+ softfloat scale = softfloat::one()/softfloat(LabCbrtTabScale);
int i;
for(i = 0; i <= LAB_CBRT_TAB_SIZE; i++)
{
- float x = i*scale;
- f[i] = x < 0.008856f ? x*7.787f + 0.13793103448275862f : cvCbrt(x);
+ softfloat x = scale*softfloat(i);
+ f[i] = x < lthresh ? mulAdd(x, lscale, lbias) : cbrt(x);
}
splineBuild(f, LAB_CBRT_TAB_SIZE, LabCbrtTab);
- scale = 1.f/GammaTabScale;
+ scale = softfloat::one()/softfloat(GammaTabScale);
for(i = 0; i <= GAMMA_TAB_SIZE; i++)
{
- float x = i*scale;
- g[i] = x <= 0.04045f ? x*(1.f/12.92f) : (float)std::pow((double)(x + 0.055)*(1./1.055), 2.4);
- ig[i] = x <= 0.0031308 ? x*12.92f : (float)(1.055*std::pow((double)x, 1./2.4) - 0.055);
+ softfloat x = scale*softfloat(i);
+ g[i] = applyGamma(x);
+ ig[i] = applyInvGamma(x);
}
splineBuild(g, GAMMA_TAB_SIZE, sRGBGammaTab);
splineBuild(ig, GAMMA_TAB_SIZE, sRGBInvGammaTab);
+ static const softfloat intScale(255*(1 << gamma_shift));
for(i = 0; i < 256; i++)
{
- float x = i*(1.f/255.f);
- sRGBGammaTab_b[i] = saturate_cast<ushort>(255.f*(1 << gamma_shift)*(x <= 0.04045f ? x*(1.f/12.92f) : (float)std::pow((double)(x + 0.055)*(1./1.055), 2.4)));
+ softfloat x = softfloat(i)/f255;
+ sRGBGammaTab_b[i] = (ushort)(cvRound(intScale*applyGamma(x)));
linearGammaTab_b[i] = (ushort)(i*(1 << gamma_shift));
}
+ static const softfloat invScale = softfloat::one()/softfloat((int)INV_GAMMA_TAB_SIZE);
+ for(i = 0; i < INV_GAMMA_TAB_SIZE; i++)
+ {
+ softfloat x = invScale*softfloat(i);
+ sRGBInvGammaTab_b[i] = (ushort)(cvRound(f255*applyInvGamma(x)));
+ linearInvGammaTab_b[i] = (ushort)(cvTrunc(f255*x));
+ }
+ static const softfloat cbTabScale(softfloat::one()/(f255*(1 << gamma_shift)));
+ static const softfloat lshift2(1 << lab_shift2);
for(i = 0; i < LAB_CBRT_TAB_SIZE_B; i++)
{
- float x = i*(1.f/(255.f*(1 << gamma_shift)));
- LabCbrtTab_b[i] = saturate_cast<ushort>((1 << lab_shift2)*(x < 0.008856f ? x*7.787f + 0.13793103448275862f : cvCbrt(x)));
+ softfloat x = cbTabScale*softfloat(i);
+ LabCbrtTab_b[i] = (ushort)(cvRound(lshift2 * (x < lthresh ? mulAdd(x, lscale, lbias) : cbrt(x))));
+ }
+
+ //Lookup table for L to y and ify calculations
+ static const int BASE = (1 << 14);
+ for(i = 0; i < 256; i++)
+ {
+ int y, ify;
+ //8 * 255.0 / 100.0 == 20.4
+ if( i <= 20)
+ {
+ //yy = li / 903.3f;
+ //y = L*100/903.3f; 903.3f = (29/3)^3, 255 = 17*3*5
+ y = cvRound(softfloat(i*BASE*20*9)/softfloat(17*29*29*29));
+ //fy = 7.787f * yy + 16.0f / 116.0f; 7.787f = (29/3)^3/(29*4)
+ ify = cvRound(softfloat(BASE)*(softfloat(16)/softfloat(116) + softfloat(i*5)/softfloat(3*17*29)));
+ }
+ else
+ {
+ //fy = (li + 16.0f) / 116.0f;
+ softfloat fy = (softfloat(i*100*BASE)/softfloat(255*116) +
+ softfloat(16*BASE)/softfloat(116));
+ ify = cvRound(fy);
+ //yy = fy * fy * fy;
+ y = cvRound(fy*fy*fy/softfloat(BASE*BASE));
+ }
+
+ LabToYF_b[i*2 ] = (ushort)y; // 2260 <= y <= BASE
+ LabToYF_b[i*2+1] = (ushort)ify; // 0 <= ify <= BASE
+ }
+
+ //Lookup table for a,b to x,z conversion
+ for(i = minABvalue; i < LAB_BASE*9/4+minABvalue; i++)
+ {
+ int v;
+ //6.f/29.f*BASE = 3389.730
+ if(i <= 3390)
+ {
+ //fxz[k] = (fxz[k] - 16.0f / 116.0f) / 7.787f;
+ // 7.787f = (29/3)^3/(29*4)
+ v = i*108/841 - BASE*16/116*108/841;
+ }
+ else
+ {
+ //fxz[k] = fxz[k] * fxz[k] * fxz[k];
+ v = i*i/BASE*i/BASE;
+ }
+ abToXZ_b[i-minABvalue] = v; // -1335 <= v <= 88231
+ }
+
+ if(enableRGB2LabInterpolation)
+ {
+ const float* _whitept = D65;
+ softfloat coeffs[9];
+
+ //RGB2Lab coeffs
+ softfloat scaleWhite[] = { softfloat::one()/softfloat(_whitept[0]),
+ softfloat::one(),
+ softfloat::one()/softfloat(_whitept[2]) };
+
+ for(i = 0; i < 3; i++ )
+ {
+ int j = i * 3;
+ coeffs[j + 2] = scaleWhite[i] * softfloat(sRGB2XYZ_D65[j ]);
+ coeffs[j + 1] = scaleWhite[i] * softfloat(sRGB2XYZ_D65[j + 1]);
+ coeffs[j + 0] = scaleWhite[i] * softfloat(sRGB2XYZ_D65[j + 2]);
+ }
+
+ softfloat D0 = coeffs[0], D1 = coeffs[1], D2 = coeffs[2],
+ D3 = coeffs[3], D4 = coeffs[4], D5 = coeffs[5],
+ D6 = coeffs[6], D7 = coeffs[7], D8 = coeffs[8];
+
+ //903.3f = (29/3)^3
+ static const softfloat lld(LAB_LUT_DIM - 1), f116(116), f16(16), f500(500), f200(200);
+ static const softfloat f100(100), f128(128), f256(256), lbase((int)LAB_BASE);
+ static const softfloat f9033 = softfloat(29*29*29)/softfloat(27);
+ AutoBuffer<int16_t> RGB2Labprev(LAB_LUT_DIM*LAB_LUT_DIM*LAB_LUT_DIM*3);
+ for(int p = 0; p < LAB_LUT_DIM; p++)
+ {
+ for(int q = 0; q < LAB_LUT_DIM; q++)
+ {
+ for(int r = 0; r < LAB_LUT_DIM; r++)
+ {
+ //RGB 2 Lab LUT building
+ softfloat R = softfloat(p)/lld;
+ softfloat G = softfloat(q)/lld;
+ softfloat B = softfloat(r)/lld;
+
+ R = applyGamma(R);
+ G = applyGamma(G);
+ B = applyGamma(B);
+
+ softfloat X = R*D0 + G*D1 + B*D2;
+ softfloat Y = R*D3 + G*D4 + B*D5;
+ softfloat Z = R*D6 + G*D7 + B*D8;
+
+ softfloat FX = X > lthresh ? cbrt(X) : mulAdd(X, lscale, lbias);
+ softfloat FY = Y > lthresh ? cbrt(Y) : mulAdd(Y, lscale, lbias);
+ softfloat FZ = Z > lthresh ? cbrt(Z) : mulAdd(Z, lscale, lbias);
+
+ softfloat L = Y > lthresh ? (f116*FY - f16) : (f9033*Y);
+ softfloat a = f500 * (FX - FY);
+ softfloat b = f200 * (FY - FZ);
+
+ int idx = p*3 + q*LAB_LUT_DIM*3 + r*LAB_LUT_DIM*LAB_LUT_DIM*3;
+ RGB2Labprev[idx] = (int16_t)(cvRound(lbase*L/f100));
+ RGB2Labprev[idx+1] = (int16_t)(cvRound(lbase*(a + f128)/f256));
+ RGB2Labprev[idx+2] = (int16_t)(cvRound(lbase*(b + f128)/f256));
+ }
+ }
+ }
+ for(int p = 0; p < LAB_LUT_DIM; p++)
+ {
+ for(int q = 0; q < LAB_LUT_DIM; q++)
+ {
+ for(int r = 0; r < LAB_LUT_DIM; r++)
+ {
+ #define FILL(_p, _q, _r) \
+ do {\
+ int idxold = 0;\
+ idxold += min(p+(_p), (int)(LAB_LUT_DIM-1))*3;\
+ idxold += min(q+(_q), (int)(LAB_LUT_DIM-1))*LAB_LUT_DIM*3;\
+ idxold += min(r+(_r), (int)(LAB_LUT_DIM-1))*LAB_LUT_DIM*LAB_LUT_DIM*3;\
+ int idxnew = p*3*8 + q*LAB_LUT_DIM*3*8 + r*LAB_LUT_DIM*LAB_LUT_DIM*3*8+4*(_p)+2*(_q)+(_r);\
+ RGB2LabLUT_s16[idxnew] = RGB2Labprev[idxold];\
+ RGB2LabLUT_s16[idxnew+8] = RGB2Labprev[idxold+1];\
+ RGB2LabLUT_s16[idxnew+16] = RGB2Labprev[idxold+2];\
+ } while(0)
+
+ FILL(0, 0, 0); FILL(0, 0, 1);
+ FILL(0, 1, 0); FILL(0, 1, 1);
+ FILL(1, 0, 0); FILL(1, 0, 1);
+ FILL(1, 1, 0); FILL(1, 1, 1);
+
+ #undef FILL
+ }
+ }
+ }
+
+ for(int16_t p = 0; p < TRILINEAR_BASE; p++)
+ {
+ int16_t pp = TRILINEAR_BASE - p;
+ for(int16_t q = 0; q < TRILINEAR_BASE; q++)
+ {
+ int16_t qq = TRILINEAR_BASE - q;
+ for(int16_t r = 0; r < TRILINEAR_BASE; r++)
+ {
+ int16_t rr = TRILINEAR_BASE - r;
+ int16_t* w = &trilinearLUT[8*p + 8*TRILINEAR_BASE*q + 8*TRILINEAR_BASE*TRILINEAR_BASE*r];
+ w[0] = pp * qq * rr; w[1] = pp * qq * r ; w[2] = pp * q * rr; w[3] = pp * q * r ;
+ w[4] = p * qq * rr; w[5] = p * qq * r ; w[6] = p * q * rr; w[7] = p * q * r ;
+ }
+ }
+ }
}
+
initialized = true;
}
}
+
+// cx, cy, cz are in [0; LAB_BASE]
+static inline void trilinearInterpolate(int cx, int cy, int cz, int16_t* LUT,
+ int& a, int& b, int& c)
+{
+ //LUT idx of origin pt of cube
+ int tx = cx >> (lab_base_shift - lab_lut_shift);
+ int ty = cy >> (lab_base_shift - lab_lut_shift);
+ int tz = cz >> (lab_base_shift - lab_lut_shift);
+
+ int16_t* baseLUT = &LUT[3*8*tx + (3*8*LAB_LUT_DIM)*ty + (3*8*LAB_LUT_DIM*LAB_LUT_DIM)*tz];
+ int aa[8], bb[8], cc[8];
+ for(int i = 0; i < 8; i++)
+ {
+ aa[i] = baseLUT[i]; bb[i] = baseLUT[i+8]; cc[i] = baseLUT[i+16];
+ }
+
+ //x, y, z are [0; TRILINEAR_BASE)
+ static const int bitMask = (1 << trilinear_shift) - 1;
+ int x = (cx >> (lab_base_shift - 8 - 1)) & bitMask;
+ int y = (cy >> (lab_base_shift - 8 - 1)) & bitMask;
+ int z = (cz >> (lab_base_shift - 8 - 1)) & bitMask;
+
+ int w[8];
+ for(int i = 0; i < 8; i++)
+ {
+ w[i] = trilinearLUT[8*x + 8*TRILINEAR_BASE*y + 8*TRILINEAR_BASE*TRILINEAR_BASE*z + i];
+ }
+
+ a = aa[0]*w[0]+aa[1]*w[1]+aa[2]*w[2]+aa[3]*w[3]+aa[4]*w[4]+aa[5]*w[5]+aa[6]*w[6]+aa[7]*w[7];
+ b = bb[0]*w[0]+bb[1]*w[1]+bb[2]*w[2]+bb[3]*w[3]+bb[4]*w[4]+bb[5]*w[5]+bb[6]*w[6]+bb[7]*w[7];
+ c = cc[0]*w[0]+cc[1]*w[1]+cc[2]*w[2]+cc[3]*w[3]+cc[4]*w[4]+cc[5]*w[5]+cc[6]*w[6]+cc[7]*w[7];
+
+ a = CV_DESCALE(a, trilinear_shift*3);
+ b = CV_DESCALE(b, trilinear_shift*3);
+ c = CV_DESCALE(c, trilinear_shift*3);
+}
+
+
+// 8 inValues are in [0; LAB_BASE]
+static inline void trilinearPackedInterpolate(const v_uint16x8& inX, const v_uint16x8& inY, const v_uint16x8& inZ,
+ const int16_t* LUT,
+ v_uint16x8& outA, v_uint16x8& outB, v_uint16x8& outC)
+{
+ //LUT idx of origin pt of cube
+ v_uint16x8 idxsX = inX >> (lab_base_shift - lab_lut_shift);
+ v_uint16x8 idxsY = inY >> (lab_base_shift - lab_lut_shift);
+ v_uint16x8 idxsZ = inZ >> (lab_base_shift - lab_lut_shift);
+
+ //x, y, z are [0; TRILINEAR_BASE)
+ const uint16_t bitMask = (1 << trilinear_shift) - 1;
+ v_uint16x8 bitMaskReg = v_setall_u16(bitMask);
+ v_uint16x8 fracX = (inX >> (lab_base_shift - 8 - 1)) & bitMaskReg;
+ v_uint16x8 fracY = (inY >> (lab_base_shift - 8 - 1)) & bitMaskReg;
+ v_uint16x8 fracZ = (inZ >> (lab_base_shift - 8 - 1)) & bitMaskReg;
+
+ //load values to interpolate for pix0, pix1, .., pix7
+ v_int16x8 a0, a1, a2, a3, a4, a5, a6, a7;
+ v_int16x8 b0, b1, b2, b3, b4, b5, b6, b7;
+ v_int16x8 c0, c1, c2, c3, c4, c5, c6, c7;
+
+ v_uint32x4 addrDw0, addrDw1, addrDw10, addrDw11;
+ v_mul_expand(v_setall_u16(3*8), idxsX, addrDw0, addrDw1);
+ v_mul_expand(v_setall_u16(3*8*LAB_LUT_DIM), idxsY, addrDw10, addrDw11);
+ addrDw0 += addrDw10; addrDw1 += addrDw11;
+ v_mul_expand(v_setall_u16(3*8*LAB_LUT_DIM*LAB_LUT_DIM), idxsZ, addrDw10, addrDw11);
+ addrDw0 += addrDw10; addrDw1 += addrDw11;
+
+ uint32_t CV_DECL_ALIGNED(16) addrofs[8];
+ v_store_aligned(addrofs, addrDw0);
+ v_store_aligned(addrofs + 4, addrDw1);
+
+ const int16_t* ptr;
+#define LOAD_ABC(n) ptr = LUT + addrofs[n]; a##n = v_load(ptr); b##n = v_load(ptr + 8); c##n = v_load(ptr + 16)
+ LOAD_ABC(0);
+ LOAD_ABC(1);
+ LOAD_ABC(2);
+ LOAD_ABC(3);
+ LOAD_ABC(4);
+ LOAD_ABC(5);
+ LOAD_ABC(6);
+ LOAD_ABC(7);
+#undef LOAD_ABC
+
+ //interpolation weights for pix0, pix1, .., pix7
+ v_int16x8 w0, w1, w2, w3, w4, w5, w6, w7;
+ v_mul_expand(v_setall_u16(8), fracX, addrDw0, addrDw1);
+ v_mul_expand(v_setall_u16(8*TRILINEAR_BASE), fracY, addrDw10, addrDw11);
+ addrDw0 += addrDw10; addrDw1 += addrDw11;
+ v_mul_expand(v_setall_u16(8*TRILINEAR_BASE*TRILINEAR_BASE), fracZ, addrDw10, addrDw11);
+ addrDw0 += addrDw10; addrDw1 += addrDw11;
+
+ v_store_aligned(addrofs, addrDw0);
+ v_store_aligned(addrofs + 4, addrDw1);
+
+#define LOAD_W(n) ptr = trilinearLUT + addrofs[n]; w##n = v_load(ptr)
+ LOAD_W(0);
+ LOAD_W(1);
+ LOAD_W(2);
+ LOAD_W(3);
+ LOAD_W(4);
+ LOAD_W(5);
+ LOAD_W(6);
+ LOAD_W(7);
+#undef LOAD_W
+
+ //outA = descale(v_reg<8>(sum(dot(ai, wi))))
+ v_uint32x4 part0, part1;
+#define DOT_SHIFT_PACK(l, ll) \
+ part0 = v_uint32x4(v_reduce_sum(v_dotprod(l##0, w0)),\
+ v_reduce_sum(v_dotprod(l##1, w1)),\
+ v_reduce_sum(v_dotprod(l##2, w2)),\
+ v_reduce_sum(v_dotprod(l##3, w3)));\
+ part1 = v_uint32x4(v_reduce_sum(v_dotprod(l##4, w4)),\
+ v_reduce_sum(v_dotprod(l##5, w5)),\
+ v_reduce_sum(v_dotprod(l##6, w6)),\
+ v_reduce_sum(v_dotprod(l##7, w7)));\
+ (ll) = v_rshr_pack<trilinear_shift*3>(part0, part1)
+
+ DOT_SHIFT_PACK(a, outA);
+ DOT_SHIFT_PACK(b, outB);
+ DOT_SHIFT_PACK(c, outC);
+
+#undef DOT_SHIFT_PACK
+}
+
+
struct RGB2Lab_b
{
typedef uchar channel_type;
@@ -5849,21 +6229,15 @@ struct RGB2Lab_b
if (!_whitept)
_whitept = D65;
- float scale[] =
- {
- (1 << lab_shift)/_whitept[0],
- (float)(1 << lab_shift),
- (1 << lab_shift)/_whitept[2]
- };
-
+ static const softfloat lshift(1 << lab_shift);
for( int i = 0; i < _3; i++ )
{
- coeffs[i*3+(blueIdx^2)] = cvRound(_coeffs[i*3]*scale[i]);
- coeffs[i*3+1] = cvRound(_coeffs[i*3+1]*scale[i]);
- coeffs[i*3+blueIdx] = cvRound(_coeffs[i*3+2]*scale[i]);
+ coeffs[i*3+(blueIdx^2)] = cvRound((lshift*softfloat(_coeffs[i*3 ]))/softfloat(_whitept[i]));
+ coeffs[i*3+1] = cvRound((lshift*softfloat(_coeffs[i*3+1]))/softfloat(_whitept[i]));
+ coeffs[i*3+blueIdx] = cvRound((lshift*softfloat(_coeffs[i*3+2]))/softfloat(_whitept[i]));
- CV_Assert( coeffs[i] >= 0 && coeffs[i*3+1] >= 0 && coeffs[i*3+2] >= 0 &&
- coeffs[i*3] + coeffs[i*3+1] + coeffs[i*3+2] < 2*(1 << lab_shift) );
+ CV_Assert(coeffs[i*3] >= 0 && coeffs[i*3+1] >= 0 && coeffs[i*3+2] >= 0 &&
+ coeffs[i*3] + coeffs[i*3+1] + coeffs[i*3+2] < 2*(1 << lab_shift));
}
}
@@ -5878,7 +6252,8 @@ struct RGB2Lab_b
C6 = coeffs[6], C7 = coeffs[7], C8 = coeffs[8];
n *= 3;
- for( i = 0; i < n; i += 3, src += scn )
+ i = 0;
+ for(; i < n; i += 3, src += scn )
{
int R = tab[src[0]], G = tab[src[1]], B = tab[src[2]];
int fX = LabCbrtTab_b[CV_DESCALE(R*C0 + G*C1 + B*C2, lab_shift)];
@@ -5901,42 +6276,46 @@ struct RGB2Lab_b
};
-#define clip(value) \
- value < 0.0f ? 0.0f : value > 1.0f ? 1.0f : value;
-
struct RGB2Lab_f
{
typedef float channel_type;
- RGB2Lab_f(int _srccn, int blueIdx, const float* _coeffs,
+ RGB2Lab_f(int _srccn, int _blueIdx, const float* _coeffs,
const float* _whitept, bool _srgb)
- : srccn(_srccn), srgb(_srgb)
+ : srccn(_srccn), srgb(_srgb), blueIdx(_blueIdx)
{
volatile int _3 = 3;
initLabTabs();
+ useInterpolation = (!_coeffs && !_whitept && srgb && enableRGB2LabInterpolation);
+
if (!_coeffs)
_coeffs = sRGB2XYZ_D65;
if (!_whitept)
_whitept = D65;
- float scale[] = { 1.0f / _whitept[0], 1.0f, 1.0f / _whitept[2] };
+ softfloat scale[] = { softfloat::one() / softfloat(_whitept[0]),
+ softfloat::one(),
+ softfloat::one() / softfloat(_whitept[2]) };
for( int i = 0; i < _3; i++ )
{
int j = i * 3;
- coeffs[j + (blueIdx ^ 2)] = _coeffs[j] * scale[i];
- coeffs[j + 1] = _coeffs[j + 1] * scale[i];
- coeffs[j + blueIdx] = _coeffs[j + 2] * scale[i];
+ softfloat c0 = scale[i] * softfloat(_coeffs[j ]);
+ softfloat c1 = scale[i] * softfloat(_coeffs[j + 1]);
+ softfloat c2 = scale[i] * softfloat(_coeffs[j + 2]);
+ coeffs[j + (blueIdx ^ 2)] = c0;
+ coeffs[j + 1] = c1;
+ coeffs[j + blueIdx] = c2;
- CV_Assert( coeffs[j] >= 0 && coeffs[j + 1] >= 0 && coeffs[j + 2] >= 0 &&
- coeffs[j] + coeffs[j + 1] + coeffs[j + 2] < 1.5f*LabCbrtTabScale );
+ CV_Assert( c0 >= 0 && c1 >= 0 && c2 >= 0 &&
+ c0 + c1 + c2 < softfloat((int)LAB_CBRT_TAB_SIZE) );
}
}
void operator()(const float* src, float* dst, int n) const
{
- int i, scn = srccn;
+ int i, scn = srccn, bIdx = blueIdx;
float gscale = GammaTabScale;
const float* gammaTab = srgb ? sRGBGammaTab : 0;
float C0 = coeffs[0], C1 = coeffs[1], C2 = coeffs[2],
@@ -5944,9 +6323,112 @@ struct RGB2Lab_f
C6 = coeffs[6], C7 = coeffs[7], C8 = coeffs[8];
n *= 3;
- static const float _1_3 = 1.0f / 3.0f;
- static const float _a = 16.0f / 116.0f;
- for (i = 0; i < n; i += 3, src += scn )
+ i = 0;
+ if(useInterpolation)
+ {
+ if(enablePackedLab)
+ {
+ static const int nPixels = 4*2;
+ for(; i < n - 3*nPixels; i += 3*nPixels, src += scn*nPixels)
+ {
+ v_float32x4 rvec0, gvec0, bvec0, rvec1, gvec1, bvec1;
+ v_float32x4 dummy0, dummy1;
+ if(scn == 3)
+ {
+ v_load_deinterleave(src, rvec0, gvec0, bvec0);
+ v_load_deinterleave(src + scn*4, rvec1, gvec1, bvec1);
+ }
+ else // scn == 4
+ {
+ v_load_deinterleave(src, rvec0, gvec0, bvec0, dummy0);
+ v_load_deinterleave(src + scn*4, rvec1, gvec1, bvec1, dummy1);
+ }
+
+ if(bIdx)
+ {
+ dummy0 = rvec0; rvec0 = bvec0; bvec0 = dummy0;
+ dummy1 = rvec1; rvec1 = bvec1; bvec1 = dummy1;
+ }
+
+ v_float32x4 zerof = v_setzero_f32(), onef = v_setall_f32(1.0f);
+ /* clip() */
+ #define clipv(r) (r) = v_min(v_max((r), zerof), onef)
+ clipv(rvec0); clipv(rvec1);
+ clipv(gvec0); clipv(gvec1);
+ clipv(bvec0); clipv(bvec1);
+ #undef clipv
+ /* int iR = R*LAB_BASE, iG = G*LAB_BASE, iB = B*LAB_BASE, iL, ia, ib; */
+ v_float32x4 basef = v_setall_f32(LAB_BASE);
+ rvec0 *= basef, gvec0 *= basef, bvec0 *= basef;
+ rvec1 *= basef, gvec1 *= basef, bvec1 *= basef;
+
+ v_int32x4 irvec0, igvec0, ibvec0, irvec1, igvec1, ibvec1;
+ irvec0 = v_round(rvec0); irvec1 = v_round(rvec1);
+ igvec0 = v_round(gvec0); igvec1 = v_round(gvec1);
+ ibvec0 = v_round(bvec0); ibvec1 = v_round(bvec1);
+
+ v_int16x8 irvec, igvec, ibvec;
+ irvec = v_pack(irvec0, irvec1);
+ igvec = v_pack(igvec0, igvec1);
+ ibvec = v_pack(ibvec0, ibvec1);
+
+ v_uint16x8 uirvec = v_reinterpret_as_u16(irvec);
+ v_uint16x8 uigvec = v_reinterpret_as_u16(igvec);
+ v_uint16x8 uibvec = v_reinterpret_as_u16(ibvec);
+
+ v_uint16x8 ui_lvec, ui_avec, ui_bvec;
+ trilinearPackedInterpolate(uirvec, uigvec, uibvec, RGB2LabLUT_s16, ui_lvec, ui_avec, ui_bvec);
+ v_int16x8 i_lvec = v_reinterpret_as_s16(ui_lvec);
+ v_int16x8 i_avec = v_reinterpret_as_s16(ui_avec);
+ v_int16x8 i_bvec = v_reinterpret_as_s16(ui_bvec);
+
+ /* float L = iL*1.0f/LAB_BASE, a = ia*1.0f/LAB_BASE, b = ib*1.0f/LAB_BASE; */
+ v_int32x4 i_lvec0, i_avec0, i_bvec0, i_lvec1, i_avec1, i_bvec1;
+ v_expand(i_lvec, i_lvec0, i_lvec1);
+ v_expand(i_avec, i_avec0, i_avec1);
+ v_expand(i_bvec, i_bvec0, i_bvec1);
+
+ v_float32x4 l_vec0, a_vec0, b_vec0, l_vec1, a_vec1, b_vec1;
+ l_vec0 = v_cvt_f32(i_lvec0); l_vec1 = v_cvt_f32(i_lvec1);
+ a_vec0 = v_cvt_f32(i_avec0); a_vec1 = v_cvt_f32(i_avec1);
+ b_vec0 = v_cvt_f32(i_bvec0); b_vec1 = v_cvt_f32(i_bvec1);
+
+ /* dst[i] = L*100.0f */
+ l_vec0 = l_vec0*v_setall_f32(100.0f/LAB_BASE);
+ l_vec1 = l_vec1*v_setall_f32(100.0f/LAB_BASE);
+ /*
+ dst[i + 1] = a*256.0f - 128.0f;
+ dst[i + 2] = b*256.0f - 128.0f;
+ */
+ a_vec0 = a_vec0*v_setall_f32(256.0f/LAB_BASE) - v_setall_f32(128.0f);
+ a_vec1 = a_vec1*v_setall_f32(256.0f/LAB_BASE) - v_setall_f32(128.0f);
+ b_vec0 = b_vec0*v_setall_f32(256.0f/LAB_BASE) - v_setall_f32(128.0f);
+ b_vec1 = b_vec1*v_setall_f32(256.0f/LAB_BASE) - v_setall_f32(128.0f);
+
+ v_store_interleave(dst + i, l_vec0, a_vec0, b_vec0);
+ v_store_interleave(dst + i + 3*4, l_vec1, a_vec1, b_vec1);
+ }
+ }
+
+ for(; i < n; i += 3, src += scn)
+ {
+ float R = clip(src[bIdx]);
+ float G = clip(src[1]);
+ float B = clip(src[bIdx^2]);
+
+ int iR = cvRound(R*LAB_BASE), iG = cvRound(G*LAB_BASE), iB = cvRound(B*LAB_BASE);
+ int iL, ia, ib;
+ trilinearInterpolate(iR, iG, iB, RGB2LabLUT_s16, iL, ia, ib);
+ float L = iL*1.0f/LAB_BASE, a = ia*1.0f/LAB_BASE, b = ib*1.0f/LAB_BASE;
+
+ dst[i] = L*100.0f;
+ dst[i + 1] = a*256.0f - 128.0f;
+ dst[i + 2] = b*256.0f - 128.0f;
+ }
+ }
+
+ static const float _a = (softfloat(16) / softfloat(116));
+ for (; i < n; i += 3, src += scn )
{
float R = clip(src[0]);
float G = clip(src[1]);
@@ -5961,10 +6443,10 @@ struct RGB2Lab_f
float X = R*C0 + G*C1 + B*C2;
float Y = R*C3 + G*C4 + B*C5;
float Z = R*C6 + G*C7 + B*C8;
-
- float FX = X > 0.008856f ? std::pow(X, _1_3) : (7.787f * X + _a);
- float FY = Y > 0.008856f ? std::pow(Y, _1_3) : (7.787f * Y + _a);
- float FZ = Z > 0.008856f ? std::pow(Z, _1_3) : (7.787f * Z + _a);
+ // 7.787f = (29/3)^3/(29*4), 0.008856f = (6/29)^3, 903.3 = (29/3)^3
+ float FX = X > 0.008856f ? cubeRoot(X) : (7.787f * X + _a);
+ float FY = Y > 0.008856f ? cubeRoot(Y) : (7.787f * Y + _a);
+ float FZ = Z > 0.008856f ? cubeRoot(Z) : (7.787f * Z + _a);
float L = Y > 0.008856f ? (116.f * FY - 16.f) : (903.3f * Y);
float a = 500.f * (FX - FY);
@@ -5979,15 +6461,19 @@ struct RGB2Lab_f
int srccn;
float coeffs[9];
bool srgb;
+ bool useInterpolation;
+ int blueIdx;
};
-struct Lab2RGB_f
+
+// Performs conversion in floats
+struct Lab2RGBfloat
{
typedef float channel_type;
- Lab2RGB_f( int _dstcn, int blueIdx, const float* _coeffs,
+ Lab2RGBfloat( int _dstcn, int _blueIdx, const float* _coeffs,
const float* _whitept, bool _srgb )
- : dstcn(_dstcn), srgb(_srgb)
+ : dstcn(_dstcn), srgb(_srgb), blueIdx(_blueIdx)
{
initLabTabs();
@@ -5998,13 +6484,14 @@ struct Lab2RGB_f
for( int i = 0; i < 3; i++ )
{
- coeffs[i+(blueIdx^2)*3] = _coeffs[i]*_whitept[i];
- coeffs[i+3] = _coeffs[i+3]*_whitept[i];
- coeffs[i+blueIdx*3] = _coeffs[i+6]*_whitept[i];
+ coeffs[i+(blueIdx^2)*3] = (softfloat(_coeffs[i] )*softfloat(_whitept[i]));
+ coeffs[i+3] = (softfloat(_coeffs[i+3])*softfloat(_whitept[i]));
+ coeffs[i+blueIdx*3] = (softfloat(_coeffs[i+6])*softfloat(_whitept[i]));
}
- lThresh = 0.008856f * 903.3f;
- fThresh = 7.787f * 0.008856f + 16.0f / 116.0f;
+ lThresh = softfloat(8); // 0.008856f * 903.3f = (6/29)^3*(29/3)^3 = 8
+ fThresh = softfloat(6)/softfloat(29); // 7.787f * 0.008856f + 16.0f / 116.0f = 6/29
+
#if CV_SSE2
haveSIMD = checkHardwareSupport(CV_CPU_SSE2);
#endif
@@ -6014,6 +6501,7 @@ struct Lab2RGB_f
void process(__m128& v_li0, __m128& v_li1, __m128& v_ai0,
__m128& v_ai1, __m128& v_bi0, __m128& v_bi1) const
{
+ // 903.3 = (29/3)^3, 7.787 = (29/3)^3/(29*4)
__m128 v_y00 = _mm_mul_ps(v_li0, _mm_set1_ps(1.0f/903.3f));
__m128 v_y01 = _mm_mul_ps(v_li1, _mm_set1_ps(1.0f/903.3f));
__m128 v_fy00 = _mm_add_ps(_mm_mul_ps(_mm_set1_ps(7.787f), v_y00), _mm_set1_ps(16.0f/116.0f));
@@ -6179,6 +6667,7 @@ struct Lab2RGB_f
float ai = src[i + 1];
float bi = src[i + 2];
+ // 903.3 = (29/3)^3, 7.787 = (29/3)^3/(29*4)
float y, fy;
if (li <= lThresh)
{
@@ -6199,7 +6688,6 @@ struct Lab2RGB_f
else
fxz[j] = fxz[j] * fxz[j] * fxz[j];
-
float x = fxz[0], z = fxz[1];
float ro = C0 * x + C1 * y + C2 * z;
float go = C3 * x + C4 * y + C5 * z;
@@ -6229,18 +6717,391 @@ struct Lab2RGB_f
#if CV_SSE2
bool haveSIMD;
#endif
+ int blueIdx;
+};
+
+
+// Performs conversion in integers
+struct Lab2RGBinteger
+{
+ typedef uchar channel_type;
+
+ static const int base_shift = 14;
+ static const int BASE = (1 << base_shift);
+ // lThresh == (6/29)^3 * (29/3)^3 * BASE/100
+ static const int lThresh = 1311;
+ // fThresh == ((29/3)^3/(29*4) * (6/29)^3 + 16/116)*BASE
+ static const int fThresh = 3390;
+ // base16_116 == BASE*16/116
+ static const int base16_116 = 2260;
+ static const int shift = lab_shift+(base_shift-inv_gamma_shift);
+
+ Lab2RGBinteger( int _dstcn, int blueIdx, const float* _coeffs,
+ const float* _whitept, bool srgb )
+ : dstcn(_dstcn)
+ {
+ if(!_coeffs)
+ _coeffs = XYZ2sRGB_D65;
+ if(!_whitept)
+ _whitept = D65;
+
+ static const softfloat lshift(1 << lab_shift);
+ for(int i = 0; i < 3; i++)
+ {
+ coeffs[i+(blueIdx)*3] = cvRound(lshift*softfloat(_coeffs[i ])*softfloat(_whitept[i]));
+ coeffs[i+3] = cvRound(lshift*softfloat(_coeffs[i+3])*softfloat(_whitept[i]));
+ coeffs[i+(blueIdx^2)*3] = cvRound(lshift*softfloat(_coeffs[i+6])*softfloat(_whitept[i]));
+ }
+
+ tab = srgb ? sRGBInvGammaTab_b : linearInvGammaTab_b;
+ }
+
+ // L, a, b should be in their natural range
+ inline void process(const uchar LL, const uchar aa, const uchar bb, int& ro, int& go, int& bo) const
+ {
+ int x, y, z;
+ int ify;
+
+ y = LabToYF_b[LL*2 ];
+ ify = LabToYF_b[LL*2+1];
+
+ //float fxz[] = { ai / 500.0f + fy, fy - bi / 200.0f };
+ int adiv, bdiv;
+ adiv = aa*BASE/500 - 128*BASE/500, bdiv = bb*BASE/200 - 128*BASE/200;
+
+ int ifxz[] = {ify + adiv, ify - bdiv};
+
+ for(int k = 0; k < 2; k++)
+ {
+ int& v = ifxz[k];
+ v = abToXZ_b[v-minABvalue];
+ }
+ x = ifxz[0]; /* y = y */; z = ifxz[1];
+
+ int C0 = coeffs[0], C1 = coeffs[1], C2 = coeffs[2];
+ int C3 = coeffs[3], C4 = coeffs[4], C5 = coeffs[5];
+ int C6 = coeffs[6], C7 = coeffs[7], C8 = coeffs[8];
+
+ ro = CV_DESCALE(C0 * x + C1 * y + C2 * z, shift);
+ go = CV_DESCALE(C3 * x + C4 * y + C5 * z, shift);
+ bo = CV_DESCALE(C6 * x + C7 * y + C8 * z, shift);
+
+ ro = max(0, min((int)INV_GAMMA_TAB_SIZE-1, ro));
+ go = max(0, min((int)INV_GAMMA_TAB_SIZE-1, go));
+ bo = max(0, min((int)INV_GAMMA_TAB_SIZE-1, bo));
+
+ ro = tab[ro];
+ go = tab[go];
+ bo = tab[bo];
+ }
+
+ // L, a, b shoule be in their natural range
+ inline void processLabToXYZ(const v_uint8x16& lv, const v_uint8x16& av, const v_uint8x16& bv,
+ v_int32x4& xiv00, v_int32x4& yiv00, v_int32x4& ziv00,
+ v_int32x4& xiv01, v_int32x4& yiv01, v_int32x4& ziv01,
+ v_int32x4& xiv10, v_int32x4& yiv10, v_int32x4& ziv10,
+ v_int32x4& xiv11, v_int32x4& yiv11, v_int32x4& ziv11) const
+ {
+ v_uint16x8 lv0, lv1;
+ v_expand(lv, lv0, lv1);
+ // Load Y and IFY values from lookup-table
+ // y = LabToYF_b[L_value*2], ify = LabToYF_b[L_value*2 + 1]
+ // LabToYF_b[i*2 ] = y; // 2260 <= y <= BASE
+ // LabToYF_b[i*2+1] = ify; // 0 <= ify <= BASE
+ uint16_t CV_DECL_ALIGNED(16) v_lv0[8], v_lv1[8];
+ v_store_aligned(v_lv0, (lv0 << 1)); v_store_aligned(v_lv1, (lv1 << 1));
+ v_int16x8 ify0, ify1;
+
+ yiv00 = v_int32x4(LabToYF_b[v_lv0[0] ], LabToYF_b[v_lv0[1] ], LabToYF_b[v_lv0[2] ], LabToYF_b[v_lv0[3] ]);
+ yiv01 = v_int32x4(LabToYF_b[v_lv0[4] ], LabToYF_b[v_lv0[5] ], LabToYF_b[v_lv0[6] ], LabToYF_b[v_lv0[7] ]);
+ yiv10 = v_int32x4(LabToYF_b[v_lv1[0] ], LabToYF_b[v_lv1[1] ], LabToYF_b[v_lv1[2] ], LabToYF_b[v_lv1[3] ]);
+ yiv11 = v_int32x4(LabToYF_b[v_lv1[4] ], LabToYF_b[v_lv1[5] ], LabToYF_b[v_lv1[6] ], LabToYF_b[v_lv1[7] ]);
+
+ ify0 = v_int16x8(LabToYF_b[v_lv0[0]+1], LabToYF_b[v_lv0[1]+1], LabToYF_b[v_lv0[2]+1], LabToYF_b[v_lv0[3]+1],
+ LabToYF_b[v_lv0[4]+1], LabToYF_b[v_lv0[5]+1], LabToYF_b[v_lv0[6]+1], LabToYF_b[v_lv0[7]+1]);
+ ify1 = v_int16x8(LabToYF_b[v_lv1[0]+1], LabToYF_b[v_lv1[1]+1], LabToYF_b[v_lv1[2]+1], LabToYF_b[v_lv1[3]+1],
+ LabToYF_b[v_lv1[4]+1], LabToYF_b[v_lv1[5]+1], LabToYF_b[v_lv1[6]+1], LabToYF_b[v_lv1[7]+1]);
+
+ v_int16x8 adiv0, adiv1, bdiv0, bdiv1;
+ v_uint16x8 av0, av1, bv0, bv1;
+ v_expand(av, av0, av1); v_expand(bv, bv0, bv1);
+ //adiv = aa*BASE/500 - 128*BASE/500, bdiv = bb*BASE/200 - 128*BASE/200;
+ //approximations with reasonable precision
+ v_uint16x8 mulA = v_setall_u16(53687);
+ v_uint32x4 ma00, ma01, ma10, ma11;
+ v_uint32x4 addA = v_setall_u32(1 << 7);
+ v_mul_expand((av0 + (av0 << 2)), mulA, ma00, ma01);
+ v_mul_expand((av1 + (av1 << 2)), mulA, ma10, ma11);
+ adiv0 = v_reinterpret_as_s16(v_pack(((ma00 + addA) >> 13), ((ma01 + addA) >> 13)));
+ adiv1 = v_reinterpret_as_s16(v_pack(((ma10 + addA) >> 13), ((ma11 + addA) >> 13)));
+
+ v_uint16x8 mulB = v_setall_u16(41943);
+ v_uint32x4 mb00, mb01, mb10, mb11;
+ v_uint32x4 addB = v_setall_u32(1 << 4);
+ v_mul_expand(bv0, mulB, mb00, mb01);
+ v_mul_expand(bv1, mulB, mb10, mb11);
+ bdiv0 = v_reinterpret_as_s16(v_pack((mb00 + addB) >> 9, (mb01 + addB) >> 9));
+ bdiv1 = v_reinterpret_as_s16(v_pack((mb10 + addB) >> 9, (mb11 + addB) >> 9));
+
+ // 0 <= adiv <= 8356, 0 <= bdiv <= 20890
+ /* x = ifxz[0]; y = y; z = ifxz[1]; */
+ v_uint16x8 xiv0, xiv1, ziv0, ziv1;
+ v_int16x8 vSubA = v_setall_s16(-128*BASE/500 - minABvalue), vSubB = v_setall_s16(128*BASE/200-1 - minABvalue);
+
+ // int ifxz[] = {ify + adiv, ify - bdiv};
+ // ifxz[k] = abToXZ_b[ifxz[k]-minABvalue];
+ xiv0 = v_reinterpret_as_u16(v_add_wrap(v_add_wrap(ify0, adiv0), vSubA));
+ xiv1 = v_reinterpret_as_u16(v_add_wrap(v_add_wrap(ify1, adiv1), vSubA));
+ ziv0 = v_reinterpret_as_u16(v_add_wrap(v_sub_wrap(ify0, bdiv0), vSubB));
+ ziv1 = v_reinterpret_as_u16(v_add_wrap(v_sub_wrap(ify1, bdiv1), vSubB));
+
+ uint16_t CV_DECL_ALIGNED(16) v_x0[8], v_x1[8], v_z0[8], v_z1[8];
+ v_store_aligned(v_x0, xiv0 ); v_store_aligned(v_x1, xiv1 );
+ v_store_aligned(v_z0, ziv0 ); v_store_aligned(v_z1, ziv1 );
+
+ xiv00 = v_int32x4(abToXZ_b[v_x0[0]], abToXZ_b[v_x0[1]], abToXZ_b[v_x0[2]], abToXZ_b[v_x0[3]]);
+ xiv01 = v_int32x4(abToXZ_b[v_x0[4]], abToXZ_b[v_x0[5]], abToXZ_b[v_x0[6]], abToXZ_b[v_x0[7]]);
+ xiv10 = v_int32x4(abToXZ_b[v_x1[0]], abToXZ_b[v_x1[1]], abToXZ_b[v_x1[2]], abToXZ_b[v_x1[3]]);
+ xiv11 = v_int32x4(abToXZ_b[v_x1[4]], abToXZ_b[v_x1[5]], abToXZ_b[v_x1[6]], abToXZ_b[v_x1[7]]);
+ ziv00 = v_int32x4(abToXZ_b[v_z0[0]], abToXZ_b[v_z0[1]], abToXZ_b[v_z0[2]], abToXZ_b[v_z0[3]]);
+ ziv01 = v_int32x4(abToXZ_b[v_z0[4]], abToXZ_b[v_z0[5]], abToXZ_b[v_z0[6]], abToXZ_b[v_z0[7]]);
+ ziv10 = v_int32x4(abToXZ_b[v_z1[0]], abToXZ_b[v_z1[1]], abToXZ_b[v_z1[2]], abToXZ_b[v_z1[3]]);
+ ziv11 = v_int32x4(abToXZ_b[v_z1[4]], abToXZ_b[v_z1[5]], abToXZ_b[v_z1[6]], abToXZ_b[v_z1[7]]);
+ // abToXZ_b[i-minABvalue] = v; // -1335 <= v <= 88231
+ }
+
+ void operator()(const float* src, float* dst, int n) const
+ {
+ int dcn = dstcn;
+ float alpha = ColorChannel<float>::max();
+
+ int i = 0;
+ if(enablePackedLab)
+ {
+ v_float32x4 vldiv = v_setall_f32(256.f/100.0f);
+ v_float32x4 vf255 = v_setall_f32(255.f);
+ static const int nPixels = 16;
+ for(; i <= n*3-3*nPixels; i += 3*nPixels, dst += dcn*nPixels)
+ {
+ /*
+ int L = saturate_cast<int>(src[i]*BASE/100.0f);
+ int a = saturate_cast<int>(src[i + 1]*BASE/256);
+ int b = saturate_cast<int>(src[i + 2]*BASE/256);
+ */
+ v_float32x4 vl[4], va[4], vb[4];
+ for(int k = 0; k < 4; k++)
+ {
+ v_load_deinterleave(src + i + k*3*4, vl[k], va[k], vb[k]);
+ vl[k] *= vldiv;
+ }
+
+ v_int32x4 ivl[4], iva[4], ivb[4];
+ for(int k = 0; k < 4; k++)
+ {
+ ivl[k] = v_round(vl[k]), iva[k] = v_round(va[k]), ivb[k] = v_round(vb[k]);
+ }
+ v_int16x8 ivl16[2], iva16[2], ivb16[2];
+ ivl16[0] = v_pack(ivl[0], ivl[1]); iva16[0] = v_pack(iva[0], iva[1]); ivb16[0] = v_pack(ivb[0], ivb[1]);
+ ivl16[1] = v_pack(ivl[2], ivl[3]); iva16[1] = v_pack(iva[2], iva[3]); ivb16[1] = v_pack(ivb[2], ivb[3]);
+ v_uint8x16 ivl8, iva8, ivb8;
+ ivl8 = v_reinterpret_as_u8(v_pack(ivl16[0], ivl16[1]));
+ iva8 = v_reinterpret_as_u8(v_pack(iva16[0], iva16[1]));
+ ivb8 = v_reinterpret_as_u8(v_pack(ivb16[0], ivb16[1]));
+
+ v_int32x4 ixv[4], iyv[4], izv[4];
+
+ processLabToXYZ(ivl8, iva8, ivb8, ixv[0], iyv[0], izv[0],
+ ixv[1], iyv[1], izv[1],
+ ixv[2], iyv[2], izv[2],
+ ixv[3], iyv[3], izv[3]);
+ /*
+ ro = CV_DESCALE(C0 * x + C1 * y + C2 * z, shift);
+ go = CV_DESCALE(C3 * x + C4 * y + C5 * z, shift);
+ bo = CV_DESCALE(C6 * x + C7 * y + C8 * z, shift);
+ */
+ v_int32x4 C0 = v_setall_s32(coeffs[0]), C1 = v_setall_s32(coeffs[1]), C2 = v_setall_s32(coeffs[2]);
+ v_int32x4 C3 = v_setall_s32(coeffs[3]), C4 = v_setall_s32(coeffs[4]), C5 = v_setall_s32(coeffs[5]);
+ v_int32x4 C6 = v_setall_s32(coeffs[6]), C7 = v_setall_s32(coeffs[7]), C8 = v_setall_s32(coeffs[8]);
+ v_int32x4 descaleShift = v_setall_s32(1 << (shift-1)), tabsz = v_setall_s32((int)INV_GAMMA_TAB_SIZE-1);
+ for(int k = 0; k < 4; k++)
+ {
+ v_int32x4 i_r, i_g, i_b;
+ v_uint32x4 r_vecs, g_vecs, b_vecs;
+ i_r = (ixv[k]*C0 + iyv[k]*C1 + izv[k]*C2 + descaleShift) >> shift;
+ i_g = (ixv[k]*C3 + iyv[k]*C4 + izv[k]*C5 + descaleShift) >> shift;
+ i_b = (ixv[k]*C6 + iyv[k]*C7 + izv[k]*C8 + descaleShift) >> shift;
+
+ //limit indices in table and then substitute
+ //ro = tab[ro]; go = tab[go]; bo = tab[bo];
+ int32_t CV_DECL_ALIGNED(16) rshifts[4], gshifts[4], bshifts[4];
+ v_int32x4 rs = v_max(v_setzero_s32(), v_min(tabsz, i_r));
+ v_int32x4 gs = v_max(v_setzero_s32(), v_min(tabsz, i_g));
+ v_int32x4 bs = v_max(v_setzero_s32(), v_min(tabsz, i_b));
+
+ v_store_aligned(rshifts, rs);
+ v_store_aligned(gshifts, gs);
+ v_store_aligned(bshifts, bs);
+
+ r_vecs = v_uint32x4(tab[rshifts[0]], tab[rshifts[1]], tab[rshifts[2]], tab[rshifts[3]]);
+ g_vecs = v_uint32x4(tab[gshifts[0]], tab[gshifts[1]], tab[gshifts[2]], tab[gshifts[3]]);
+ b_vecs = v_uint32x4(tab[bshifts[0]], tab[bshifts[1]], tab[bshifts[2]], tab[bshifts[3]]);
+
+ v_float32x4 v_r, v_g, v_b;
+ v_r = v_cvt_f32(v_reinterpret_as_s32(r_vecs))/vf255;
+ v_g = v_cvt_f32(v_reinterpret_as_s32(g_vecs))/vf255;
+ v_b = v_cvt_f32(v_reinterpret_as_s32(b_vecs))/vf255;
+
+ if(dcn == 4)
+ {
+ v_store_interleave(dst + k*dcn*4, v_b, v_g, v_r, v_setall_f32(alpha));
+ }
+ else // dcn == 3
+ {
+ v_store_interleave(dst + k*dcn*4, v_b, v_g, v_r);
+ }
+ }
+ }
+ }
+
+ for(; i < n*3; i += 3, dst += dcn)
+ {
+ int ro, go, bo;
+ process((uchar)(src[i + 0]*255.f/100.f), (uchar)src[i + 1], (uchar)src[i + 2], ro, go, bo);
+
+ dst[0] = bo/255.f;
+ dst[1] = go/255.f;
+ dst[2] = ro/255.f;
+ if(dcn == 4)
+ dst[3] = alpha;
+ }
+ }
+
+ void operator()(const uchar* src, uchar* dst, int n) const
+ {
+ int i, dcn = dstcn;
+ uchar alpha = ColorChannel<uchar>::max();
+ i = 0;
+
+ if(enablePackedLab)
+ {
+ static const int nPixels = 8*2;
+ for(; i <= n*3-3*nPixels; i += 3*nPixels, dst += dcn*nPixels)
+ {
+ /*
+ int L = src[i + 0];
+ int a = src[i + 1];
+ int b = src[i + 2];
+ */
+ v_uint8x16 u8l, u8a, u8b;
+ v_load_deinterleave(src + i, u8l, u8a, u8b);
+
+ v_int32x4 xiv[4], yiv[4], ziv[4];
+ processLabToXYZ(u8l, u8a, u8b, xiv[0], yiv[0], ziv[0],
+ xiv[1], yiv[1], ziv[1],
+ xiv[2], yiv[2], ziv[2],
+ xiv[3], yiv[3], ziv[3]);
+ /*
+ ro = CV_DESCALE(C0 * x + C1 * y + C2 * z, shift);
+ go = CV_DESCALE(C3 * x + C4 * y + C5 * z, shift);
+ bo = CV_DESCALE(C6 * x + C7 * y + C8 * z, shift);
+ */
+ v_int32x4 C0 = v_setall_s32(coeffs[0]), C1 = v_setall_s32(coeffs[1]), C2 = v_setall_s32(coeffs[2]);
+ v_int32x4 C3 = v_setall_s32(coeffs[3]), C4 = v_setall_s32(coeffs[4]), C5 = v_setall_s32(coeffs[5]);
+ v_int32x4 C6 = v_setall_s32(coeffs[6]), C7 = v_setall_s32(coeffs[7]), C8 = v_setall_s32(coeffs[8]);
+ v_int32x4 descaleShift = v_setall_s32(1 << (shift-1));
+ v_int32x4 tabsz = v_setall_s32((int)INV_GAMMA_TAB_SIZE-1);
+ v_uint32x4 r_vecs[4], g_vecs[4], b_vecs[4];
+ for(int k = 0; k < 4; k++)
+ {
+ v_int32x4 i_r, i_g, i_b;
+ i_r = (xiv[k]*C0 + yiv[k]*C1 + ziv[k]*C2 + descaleShift) >> shift;
+ i_g = (xiv[k]*C3 + yiv[k]*C4 + ziv[k]*C5 + descaleShift) >> shift;
+ i_b = (xiv[k]*C6 + yiv[k]*C7 + ziv[k]*C8 + descaleShift) >> shift;
+
+ //limit indices in table and then substitute
+ //ro = tab[ro]; go = tab[go]; bo = tab[bo];
+ int32_t CV_DECL_ALIGNED(16) rshifts[4], gshifts[4], bshifts[4];
+ v_int32x4 rs = v_max(v_setzero_s32(), v_min(tabsz, i_r));
+ v_int32x4 gs = v_max(v_setzero_s32(), v_min(tabsz, i_g));
+ v_int32x4 bs = v_max(v_setzero_s32(), v_min(tabsz, i_b));
+
+ v_store_aligned(rshifts, rs);
+ v_store_aligned(gshifts, gs);
+ v_store_aligned(bshifts, bs);
+
+ r_vecs[k] = v_uint32x4(tab[rshifts[0]], tab[rshifts[1]], tab[rshifts[2]], tab[rshifts[3]]);
+ g_vecs[k] = v_uint32x4(tab[gshifts[0]], tab[gshifts[1]], tab[gshifts[2]], tab[gshifts[3]]);
+ b_vecs[k] = v_uint32x4(tab[bshifts[0]], tab[bshifts[1]], tab[bshifts[2]], tab[bshifts[3]]);
+ }
+
+ v_uint16x8 u_rvec0 = v_pack(r_vecs[0], r_vecs[1]), u_rvec1 = v_pack(r_vecs[2], r_vecs[3]);
+ v_uint16x8 u_gvec0 = v_pack(g_vecs[0], g_vecs[1]), u_gvec1 = v_pack(g_vecs[2], g_vecs[3]);
+ v_uint16x8 u_bvec0 = v_pack(b_vecs[0], b_vecs[1]), u_bvec1 = v_pack(b_vecs[2], b_vecs[3]);
+
+ v_uint8x16 u8_b, u8_g, u8_r;
+ u8_b = v_pack(u_bvec0, u_bvec1);
+ u8_g = v_pack(u_gvec0, u_gvec1);
+ u8_r = v_pack(u_rvec0, u_rvec1);
+
+ if(dcn == 4)
+ {
+ v_store_interleave(dst, u8_b, u8_g, u8_r, v_setall_u8(alpha));
+ }
+ else
+ {
+ v_store_interleave(dst, u8_b, u8_g, u8_r);
+ }
+ }
+ }
+
+ for (; i < n*3; i += 3, dst += dcn)
+ {
+ int ro, go, bo;
+ process(src[i + 0], src[i + 1], src[i + 2], ro, go, bo);
+
+ dst[0] = saturate_cast<uchar>(bo);
+ dst[1] = saturate_cast<uchar>(go);
+ dst[2] = saturate_cast<uchar>(ro);
+ if( dcn == 4 )
+ dst[3] = alpha;
+ }
+ }
+
+ int dstcn;
+ int coeffs[9];
+ ushort* tab;
+};
+
+
+struct Lab2RGB_f
+{
+ typedef float channel_type;
+
+ Lab2RGB_f( int _dstcn, int _blueIdx, const float* _coeffs,
+ const float* _whitept, bool _srgb )
+ : fcvt(_dstcn, _blueIdx, _coeffs, _whitept, _srgb), dstcn(_dstcn)
+ { }
+
+ void operator()(const float* src, float* dst, int n) const
+ {
+ fcvt(src, dst, n);
+ }
+
+ Lab2RGBfloat fcvt;
+ int dstcn;
};
-#undef clip
struct Lab2RGB_b
{
typedef uchar channel_type;
- Lab2RGB_b( int _dstcn, int blueIdx, const float* _coeffs,
+ Lab2RGB_b( int _dstcn, int _blueIdx, const float* _coeffs,
const float* _whitept, bool _srgb )
- : dstcn(_dstcn), cvt(3, blueIdx, _coeffs, _whitept, _srgb )
+ : fcvt(3, _blueIdx, _coeffs, _whitept, _srgb ), icvt(_dstcn, _blueIdx, _coeffs, _whitept, _srgb), dstcn(_dstcn)
{
+ useBitExactness = (!_coeffs && !_whitept && _srgb && enableBitExactness);
+
#if CV_NEON
v_scale_inv = vdupq_n_f32(100.f/255.f);
v_scale = vdupq_n_f32(255.f);
@@ -6297,6 +7158,12 @@ struct Lab2RGB_b
void operator()(const uchar* src, uchar* dst, int n) const
{
+ if(useBitExactness)
+ {
+ icvt(src, dst, n);
+ return;
+ }
+
int i, j, dcn = dstcn;
uchar alpha = ColorChannel<uchar>::max();
float CV_DECL_ALIGNED(16) buf[3*BLOCK_SIZE];
@@ -6305,7 +7172,8 @@ struct Lab2RGB_b
__m128 v_res = _mm_set_ps(0.f, 128.f, 128.f, 0.f);
#endif
- for( i = 0; i < n; i += BLOCK_SIZE, src += BLOCK_SIZE*3 )
+ i = 0;
+ for(; i < n; i += BLOCK_SIZE, src += BLOCK_SIZE*3 )
{
int dn = std::min(n - i, (int)BLOCK_SIZE);
j = 0;
@@ -6352,7 +7220,7 @@ struct Lab2RGB_b
buf[j+1] = (float)(src[j+1] - 128);
buf[j+2] = (float)(src[j+2] - 128);
}
- cvt(buf, buf, dn);
+ fcvt(buf, buf, dn);
j = 0;
#if CV_NEON
@@ -6445,9 +7313,8 @@ struct Lab2RGB_b
}
}
- int dstcn;
- Lab2RGB_f cvt;
-
+ Lab2RGBfloat fcvt;
+ Lab2RGBinteger icvt;
#if CV_NEON
float32x4_t v_scale, v_scale_inv, v_128;
uint8x8_t v_alpha;
@@ -6457,8 +7324,11 @@ struct Lab2RGB_b
__m128i v_zero;
bool haveSIMD;
#endif
+ bool useBitExactness;
+ int dstcn;
};
+#undef clip
///////////////////////////////////// RGB <-> L*u*v* /////////////////////////////////////
@@ -6484,12 +7354,17 @@ struct RGB2Luv_f
if( blueIdx == 0 )
std::swap(coeffs[i*3], coeffs[i*3+2]);
CV_Assert( coeffs[i*3] >= 0 && coeffs[i*3+1] >= 0 && coeffs[i*3+2] >= 0 &&
- coeffs[i*3] + coeffs[i*3+1] + coeffs[i*3+2] < 1.5f );
+ softfloat(coeffs[i*3]) +
+ softfloat(coeffs[i*3+1]) +
+ softfloat(coeffs[i*3+2]) < softfloat(1.5f) );
}
- float d = 1.f/(whitept[0] + whitept[1]*15 + whitept[2]*3);
- un = 4*whitept[0]*d*13;
- vn = 9*whitept[1]*d*13;
+ softfloat d = softfloat(whitept[0]) +
+ softfloat(whitept[1])*softfloat(15) +
+ softfloat(whitept[2])*softfloat(3);
+ d = softfloat::one()/max(d, softfloat(FLT_EPSILON));
+ un = d*softfloat(13*4)*softfloat(whitept[0]);
+ vn = d*softfloat(13*9)*softfloat(whitept[1]);
#if CV_SSE2
haveSIMD = checkHardwareSupport(CV_CPU_SSE2);
@@ -6599,6 +7474,15 @@ struct RGB2Luv_f
for( ; i <= n - 12; i += 12, src += scn * 4 )
{
float32x4x3_t v_src = vld3q_f32(src);
+
+ v_src.val[0] = vmaxq_f32(v_src.val[0], vdupq_n_f32(0));
+ v_src.val[1] = vmaxq_f32(v_src.val[1], vdupq_n_f32(0));
+ v_src.val[2] = vmaxq_f32(v_src.val[2], vdupq_n_f32(0));
+
+ v_src.val[0] = vminq_f32(v_src.val[0], vdupq_n_f32(1));
+ v_src.val[1] = vminq_f32(v_src.val[1], vdupq_n_f32(1));
+ v_src.val[2] = vminq_f32(v_src.val[2], vdupq_n_f32(1));
+
if( gammaTab )
{
v_src.val[0] = vmulq_f32(v_src.val[0], vdupq_n_f32(gscale));
@@ -6619,6 +7503,15 @@ struct RGB2Luv_f
for( ; i <= n - 12; i += 12, src += scn * 4 )
{
float32x4x4_t v_src = vld4q_f32(src);
+
+ v_src.val[0] = vmaxq_f32(v_src.val[0], vdupq_n_f32(0));
+ v_src.val[1] = vmaxq_f32(v_src.val[1], vdupq_n_f32(0));
+ v_src.val[2] = vmaxq_f32(v_src.val[2], vdupq_n_f32(0));
+
+ v_src.val[0] = vminq_f32(v_src.val[0], vdupq_n_f32(1));
+ v_src.val[1] = vminq_f32(v_src.val[1], vdupq_n_f32(1));
+ v_src.val[2] = vminq_f32(v_src.val[2], vdupq_n_f32(1));
+
if( gammaTab )
{
v_src.val[0] = vmulq_f32(v_src.val[0], vdupq_n_f32(gscale));
@@ -6662,6 +7555,20 @@ struct RGB2Luv_f
_mm_deinterleave_ps(v_r0, v_r1, v_g0, v_g1, v_b0, v_b1, v_a0, v_a1);
}
+ v_r0 = _mm_max_ps(v_r0, _mm_setzero_ps());
+ v_r1 = _mm_max_ps(v_r1, _mm_setzero_ps());
+ v_g0 = _mm_max_ps(v_g0, _mm_setzero_ps());
+ v_g1 = _mm_max_ps(v_g1, _mm_setzero_ps());
+ v_b0 = _mm_max_ps(v_b0, _mm_setzero_ps());
+ v_b1 = _mm_max_ps(v_b1, _mm_setzero_ps());
+
+ v_r0 = _mm_min_ps(v_r0, _mm_set1_ps(1.f));
+ v_r1 = _mm_min_ps(v_r1, _mm_set1_ps(1.f));
+ v_g0 = _mm_min_ps(v_g0, _mm_set1_ps(1.f));
+ v_g1 = _mm_min_ps(v_g1, _mm_set1_ps(1.f));
+ v_b0 = _mm_min_ps(v_b0, _mm_set1_ps(1.f));
+ v_b1 = _mm_min_ps(v_b1, _mm_set1_ps(1.f));
+
if ( gammaTab )
{
__m128 v_gscale = _mm_set1_ps(gscale);
@@ -6696,6 +7603,9 @@ struct RGB2Luv_f
for( ; i < n; i += 3, src += scn )
{
float R = src[0], G = src[1], B = src[2];
+ R = std::min(std::max(R, 0.f), 1.f);
+ G = std::min(std::max(G, 0.f), 1.f);
+ B = std::min(std::max(B, 0.f), 1.f);
if( gammaTab )
{
R = splineInterpolate(R*gscale, gammaTab, GAMMA_TAB_SIZE);
@@ -6747,9 +7657,12 @@ struct Luv2RGB_f
coeffs[i+blueIdx*3] = _coeffs[i+6];
}
- float d = 1.f/(whitept[0] + whitept[1]*15 + whitept[2]*3);
- un = 4*whitept[0]*d;
- vn = 9*whitept[1]*d;
+ softfloat d = softfloat(whitept[0]) +
+ softfloat(whitept[1])*softfloat(15) +
+ softfloat(whitept[2])*softfloat(3);
+ d = softfloat::one()/max(d, softfloat(FLT_EPSILON));
+ un = softfloat(4*13)*d*softfloat(whitept[0]);
+ vn = softfloat(9*13)*d*softfloat(whitept[1]);
#if CV_SSE2
haveSIMD = checkHardwareSupport(CV_CPU_SSE2);
#endif
@@ -6761,23 +7674,42 @@ struct Luv2RGB_f
void process(__m128& v_l0, __m128& v_l1, __m128& v_u0,
__m128& v_u1, __m128& v_v0, __m128& v_v1) const
{
- __m128 v_y0 = _mm_mul_ps(_mm_add_ps(v_l0, _mm_set1_ps(16.0f)), _mm_set1_ps(1.f/116.f));
- __m128 v_y1 = _mm_mul_ps(_mm_add_ps(v_l1, _mm_set1_ps(16.0f)), _mm_set1_ps(1.f/116.f));
- v_y0 = _mm_mul_ps(_mm_mul_ps(v_y0, v_y0), v_y0);
- v_y1 = _mm_mul_ps(_mm_mul_ps(v_y1, v_y1), v_y1);
- __m128 v_d0 = _mm_div_ps(_mm_set1_ps(1.f/13.f), v_l0);
- __m128 v_d1 = _mm_div_ps(_mm_set1_ps(1.f/13.f), v_l1);
- v_u0 = _mm_mul_ps(_mm_add_ps(_mm_mul_ps(v_u0, v_d0), _mm_set1_ps(un)), _mm_set1_ps(3.f));
- v_u1 = _mm_mul_ps(_mm_add_ps(_mm_mul_ps(v_u1, v_d1), _mm_set1_ps(un)), _mm_set1_ps(3.f));
- v_v0 = _mm_add_ps(_mm_mul_ps(v_v0, v_d0), _mm_set1_ps(vn));
- v_v1 = _mm_add_ps(_mm_mul_ps(v_v1, v_d1), _mm_set1_ps(vn));
- __m128 v_iv0 = _mm_div_ps(_mm_set1_ps(0.25f), v_v0);
- __m128 v_iv1 = _mm_div_ps(_mm_set1_ps(0.25f), v_v1);
- __m128 v_x0 = _mm_mul_ps(_mm_mul_ps(_mm_set1_ps(3.f), v_u0), v_iv0);
- __m128 v_x1 = _mm_mul_ps(_mm_mul_ps(_mm_set1_ps(3.f), v_u1), v_iv1);
- __m128 v_z0 = _mm_mul_ps(_mm_sub_ps(_mm_sub_ps(_mm_set1_ps(12.f), v_u0), _mm_mul_ps(_mm_set1_ps(20.f), v_v0)), v_iv0);
- __m128 v_z1 = _mm_mul_ps(_mm_sub_ps(_mm_sub_ps(_mm_set1_ps(12.f), v_u1), _mm_mul_ps(_mm_set1_ps(20.f), v_v1)), v_iv1);
-
+ // L*(3./29.)^3
+ __m128 v_y00 = _mm_mul_ps(v_l0, _mm_set1_ps(1.0f/903.3f));
+ __m128 v_y01 = _mm_mul_ps(v_l1, _mm_set1_ps(1.0f/903.3f));
+ // ((L + 16)/116)^3
+ __m128 v_y10 = _mm_mul_ps(_mm_add_ps(v_l0, _mm_set1_ps(16.0f)), _mm_set1_ps(1.f/116.f));
+ __m128 v_y11 = _mm_mul_ps(_mm_add_ps(v_l1, _mm_set1_ps(16.0f)), _mm_set1_ps(1.f/116.f));
+ v_y10 = _mm_mul_ps(_mm_mul_ps(v_y10, v_y10), v_y10);
+ v_y11 = _mm_mul_ps(_mm_mul_ps(v_y11, v_y11), v_y11);
+ // Y = (L <= 8) ? Y0 : Y1;
+ __m128 v_cmpl0 = _mm_cmplt_ps(v_l0, _mm_set1_ps(8.f));
+ __m128 v_cmpl1 = _mm_cmplt_ps(v_l1, _mm_set1_ps(8.f));
+ v_y00 = _mm_and_ps(v_cmpl0, v_y00);
+ v_y01 = _mm_and_ps(v_cmpl1, v_y01);
+ v_y10 = _mm_andnot_ps(v_cmpl0, v_y10);
+ v_y11 = _mm_andnot_ps(v_cmpl1, v_y11);
+ __m128 v_y0 = _mm_or_ps(v_y00, v_y10);
+ __m128 v_y1 = _mm_or_ps(v_y01, v_y11);
+ // up = 3*(u + L*_un);
+ __m128 v_up0 = _mm_mul_ps(_mm_set1_ps(3.f), _mm_add_ps(v_u0, _mm_mul_ps(v_l0, _mm_set1_ps(un))));
+ __m128 v_up1 = _mm_mul_ps(_mm_set1_ps(3.f), _mm_add_ps(v_u1, _mm_mul_ps(v_l1, _mm_set1_ps(un))));
+ // vp = 0.25/(v + L*_vn);
+ __m128 v_vp0 = _mm_div_ps(_mm_set1_ps(0.25f), _mm_add_ps(v_v0, _mm_mul_ps(v_l0, _mm_set1_ps(vn))));
+ __m128 v_vp1 = _mm_div_ps(_mm_set1_ps(0.25f), _mm_add_ps(v_v1, _mm_mul_ps(v_l1, _mm_set1_ps(vn))));
+ // vp = max(-0.25, min(0.25, vp));
+ v_vp0 = _mm_max_ps(v_vp0, _mm_set1_ps(-0.25f));
+ v_vp1 = _mm_max_ps(v_vp1, _mm_set1_ps(-0.25f));
+ v_vp0 = _mm_min_ps(v_vp0, _mm_set1_ps( 0.25f));
+ v_vp1 = _mm_min_ps(v_vp1, _mm_set1_ps( 0.25f));
+ //X = 3*up*vp; // (*Y) is done later
+ __m128 v_x0 = _mm_mul_ps(_mm_set1_ps(3.f), _mm_mul_ps(v_up0, v_vp0));
+ __m128 v_x1 = _mm_mul_ps(_mm_set1_ps(3.f), _mm_mul_ps(v_up1, v_vp1));
+ //Z = ((12*13*L - up)*vp - 5); // (*Y) is done later
+ __m128 v_z0 = _mm_sub_ps(_mm_mul_ps(_mm_sub_ps(_mm_mul_ps(_mm_set1_ps(12.f*13.f), v_l0), v_up0), v_vp0), _mm_set1_ps(5.f));
+ __m128 v_z1 = _mm_sub_ps(_mm_mul_ps(_mm_sub_ps(_mm_mul_ps(_mm_set1_ps(12.f*13.f), v_l1), v_up1), v_vp1), _mm_set1_ps(5.f));
+
+ // R = (X*C0 + C1 + Z*C2)*Y; // here (*Y) is done
v_l0 = _mm_mul_ps(v_x0, _mm_set1_ps(coeffs[0]));
v_l1 = _mm_mul_ps(v_x1, _mm_set1_ps(coeffs[0]));
v_u0 = _mm_mul_ps(v_x0, _mm_set1_ps(coeffs[3]));
@@ -6894,15 +7826,22 @@ struct Luv2RGB_f
#endif
for( ; i < n; i += 3, dst += dcn )
{
- float L = src[i], u = src[i+1], v = src[i+2], d, X, Y, Z;
- Y = (L + 16.f) * (1.f/116.f);
- Y = Y*Y*Y;
- d = (1.f/13.f)/L;
- u = u*d + _un;
- v = v*d + _vn;
- float iv = 1.f/v;
- X = 2.25f * u * Y * iv ;
- Z = (12 - 3 * u - 20 * v) * Y * 0.25f * iv;
+ float L = src[i], u = src[i+1], v = src[i+2], X, Y, Z;
+ if(L >= 8)
+ {
+ Y = (L + 16.f) * (1.f/116.f);
+ Y = Y*Y*Y;
+ }
+ else
+ {
+ Y = L * (1.0f/903.3f); // L*(3./29.)^3
+ }
+ float up = 3.f*(u + L*_un);
+ float vp = 0.25f/(v + L*_vn);
+ if(vp > 0.25f) vp = 0.25f;
+ if(vp < -0.25f) vp = -0.25f;
+ X = Y*3.f*up*vp;
+ Z = Y*(((12.f*13.f)*L - up)*vp - 5.f);
float R = X*C0 + Y*C1 + Z*C2;
float G = X*C3 + Y*C4 + Z*C5;
@@ -6942,6 +7881,8 @@ struct RGB2Luv_b
const float* _whitept, bool _srgb )
: srccn(_srccn), cvt(3, blueIdx, _coeffs, _whitept, _srgb)
{
+ //0.72033 = 255/(220+134), 96.525 = 134*255/(220+134)
+ //0.9732 = 255/(140+122), 136.259 = 140*255/(140+122)
#if CV_NEON
v_scale_inv = vdupq_n_f32(1.f/255.f);
v_scale = vdupq_n_f32(2.55f);
@@ -7142,6 +8083,8 @@ struct Luv2RGB_b
const float* _whitept, bool _srgb )
: dstcn(_dstcn), cvt(3, blueIdx, _coeffs, _whitept, _srgb )
{
+ // 1.388235294117647 = (220+134)/255
+ // 1.027450980392157 = (140+122)/255
#if CV_NEON
v_scale_inv = vdupq_n_f32(100.f/255.f);
v_coeff1 = vdupq_n_f32(1.388235294117647f);
@@ -8461,21 +9404,15 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
{
int coeffs[9];
const float * const _coeffs = sRGB2XYZ_D65, * const _whitept = D65;
- const float scale[] =
- {
- (1 << lab_shift)/_whitept[0],
- (float)(1 << lab_shift),
- (1 << lab_shift)/_whitept[2]
- };
-
- for (int i = 0; i < 3; i++ )
+ static const softfloat lshift(1 << lab_shift);
+ for( int i = 0; i < 3; i++ )
{
- coeffs[i*3+(bidx^2)] = cvRound(_coeffs[i*3]*scale[i]);
- coeffs[i*3+1] = cvRound(_coeffs[i*3+1]*scale[i]);
- coeffs[i*3+bidx] = cvRound(_coeffs[i*3+2]*scale[i]);
+ coeffs[i*3+(bidx^2)] = cvRound(lshift*softfloat(_coeffs[i*3 ])/softfloat(_whitept[i]));
+ coeffs[i*3+1] = cvRound(lshift*softfloat(_coeffs[i*3+1])/softfloat(_whitept[i]));
+ coeffs[i*3+bidx] = cvRound(lshift*softfloat(_coeffs[i*3+2])/softfloat(_whitept[i]));
- CV_Assert( coeffs[i] >= 0 && coeffs[i*3+1] >= 0 && coeffs[i*3+2] >= 0 &&
- coeffs[i*3] + coeffs[i*3+1] + coeffs[i*3+2] < 2*(1 << lab_shift) );
+ CV_Assert(coeffs[i*3] >= 0 && coeffs[i*3+1] >= 0 && coeffs[i*3+2] >= 0 &&
+ coeffs[i*3] + coeffs[i*3+1] + coeffs[i*3+2] < 2*(1 << lab_shift));
}
Mat(1, 9, CV_32SC1, coeffs).copyTo(ucoeffs);
}
@@ -8500,36 +9437,48 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
{
float coeffs[9];
const float * const _coeffs = sRGB2XYZ_D65, * const _whitept = D65;
- float scale[] = { 1.0f / _whitept[0], 1.0f, 1.0f / _whitept[2] };
+
+ softfloat scale[] = { softfloat::one() / softfloat(_whitept[0]),
+ softfloat::one(),
+ softfloat::one() / softfloat(_whitept[2]) };
for (int i = 0; i < 3; i++)
{
int j = i * 3;
- coeffs[j + (bidx ^ 2)] = _coeffs[j] * (lab ? scale[i] : 1);
- coeffs[j + 1] = _coeffs[j + 1] * (lab ? scale[i] : 1);
- coeffs[j + bidx] = _coeffs[j + 2] * (lab ? scale[i] : 1);
- CV_Assert( coeffs[j] >= 0 && coeffs[j + 1] >= 0 && coeffs[j + 2] >= 0 &&
- coeffs[j] + coeffs[j + 1] + coeffs[j + 2] < 1.5f*(lab ? LabCbrtTabScale : 1) );
+ softfloat c0 = (lab ? scale[i] : softfloat::one()) * softfloat(_coeffs[j ]);
+ softfloat c1 = (lab ? scale[i] : softfloat::one()) * softfloat(_coeffs[j + 1]);
+ softfloat c2 = (lab ? scale[i] : softfloat::one()) * softfloat(_coeffs[j + 2]);
+
+ coeffs[j + (bidx ^ 2)] = c0;
+ coeffs[j + 1] = c1;
+ coeffs[j + bidx] = c2;
+
+ CV_Assert( c0 >= 0 && c1 >= 0 && c2 >= 0 &&
+ c0 + c1 + c2 < (lab ? softfloat((int)LAB_CBRT_TAB_SIZE) : softfloat(3)/softfloat(2)));
}
- float d = 1.f/(_whitept[0] + _whitept[1]*15 + _whitept[2]*3);
- un = 13*4*_whitept[0]*d;
- vn = 13*9*_whitept[1]*d;
+ softfloat d = softfloat(_whitept[0]) +
+ softfloat(_whitept[1])*softfloat(15) +
+ softfloat(_whitept[2])*softfloat(3);
+ d = softfloat::one()/max(d, softfloat(FLT_EPSILON));
+ un = d*softfloat(13*4)*softfloat(_whitept[0]);
+ vn = d*softfloat(13*9)*softfloat(_whitept[1]);
Mat(1, 9, CV_32FC1, coeffs).copyTo(ucoeffs);
}
- float _1_3 = 1.0f / 3.0f, _a = 16.0f / 116.0f;
+ static const float _a = softfloat(16)/softfloat(116);
+ static const float _1_3f = softfloat::one()/softfloat(3);
ocl::KernelArg ucoeffsarg = ocl::KernelArg::PtrReadOnly(ucoeffs);
if (lab)
{
if (srgb)
k.args(srcarg, dstarg, ocl::KernelArg::PtrReadOnly(usRGBGammaTab),
- ucoeffsarg, _1_3, _a);
+ ucoeffsarg, _1_3f, _a);
else
- k.args(srcarg, dstarg, ucoeffsarg, _1_3, _a);
+ k.args(srcarg, dstarg, ucoeffsarg, _1_3f, _a);
}
else
{
@@ -8575,14 +9524,17 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
for( int i = 0; i < 3; i++ )
{
- coeffs[i+(bidx^2)*3] = _coeffs[i] * (lab ? _whitept[i] : 1);
- coeffs[i+3] = _coeffs[i+3] * (lab ? _whitept[i] : 1);
- coeffs[i+bidx*3] = _coeffs[i+6] * (lab ? _whitept[i] : 1);
+ coeffs[i+(bidx^2)*3] = softfloat(_coeffs[i] )*softfloat(lab ? _whitept[i] : 1);
+ coeffs[i+3] = softfloat(_coeffs[i+3])*softfloat(lab ? _whitept[i] : 1);
+ coeffs[i+bidx*3] = softfloat(_coeffs[i+6])*softfloat(lab ? _whitept[i] : 1);
}
- float d = 1.f/(_whitept[0] + _whitept[1]*15 + _whitept[2]*3);
- un = 4*_whitept[0]*d;
- vn = 9*_whitept[1]*d;
+ softfloat d = softfloat(_whitept[0]) +
+ softfloat(_whitept[1])*softfloat(15) +
+ softfloat(_whitept[2])*softfloat(3);
+ d = softfloat::one()/max(d, softfloat(FLT_EPSILON));
+ un = softfloat(4*13)*d*softfloat(_whitept[0]);
+ vn = softfloat(9*13)*d*softfloat(_whitept[1]);
Mat(1, 9, CV_32FC1, coeffs).copyTo(ucoeffs);
}
@@ -8590,8 +9542,8 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
_dst.create(sz, CV_MAKETYPE(depth, dcn));
dst = _dst.getUMat();
- float lThresh = 0.008856f * 903.3f;
- float fThresh = 7.787f * 0.008856f + 16.0f / 116.0f;
+ float lThresh = softfloat(8); // 0.008856f * 903.3f = (6/29)^3*(29/3)^3 = 8
+ float fThresh = softfloat(6)/softfloat(29); // 7.787f * 0.008856f + 16.0f / 116.0f = 6/29
ocl::KernelArg srcarg = ocl::KernelArg::ReadOnlyNoSize(src),
dstarg = ocl::KernelArg::WriteOnly(dst),
@@ -8714,41 +9666,6 @@ void cvtBGRtoBGR5x5(const uchar * src_data, size_t src_step,
CALL_HAL(cvtBGRtoBGR5x5, cv_hal_cvtBGRtoBGR5x5, src_data, src_step, dst_data, dst_step, width, height, scn, swapBlue, greenBits);
-#if defined(HAVE_IPP) && IPP_DISABLE_BLOCK // breaks OCL accuracy tests
- CV_IPP_CHECK()
- {
- CV_SUPPRESS_DEPRECATED_START;
- if (scn == 3 && greenBits == 6 && !swapBlue)
- {
- if (CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPGeneralFunctor((ippiGeneralFunc)ippiBGRToBGR565_8u16u_C3R)))
- return;
- }
- else if (scn == 4 && greenBits == 6 && !swapBlue)
- {
- if (CvtColorIPPLoopCopy(src_data, src_step, CV_MAKETYPE(CV_8U, scn), dst_data, dst_step, width, height,
- IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[CV_8U],
- (ippiGeneralFunc)ippiBGRToBGR565_8u16u_C3R, 0, 1, 2, CV_8U)))
- return;
- }
- else if (scn == 3 && greenBits == 6 && swapBlue)
- {
- if( CvtColorIPPLoopCopy(src_data, src_step, CV_MAKETYPE(CV_8U, scn), dst_data, dst_step, width, height,
- IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[CV_8U],
- (ippiGeneralFunc)ippiBGRToBGR565_8u16u_C3R, 2, 1, 0, CV_8U)) )
- return;
- }
- else if (scn == 4 && greenBits == 6 && swapBlue)
- {
- if( CvtColorIPPLoopCopy(src_data, src_step, CV_MAKETYPE(CV_8U, scn), dst_data, dst_step, width, height,
- IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[CV_8U],
- (ippiGeneralFunc)ippiBGRToBGR565_8u16u_C3R, 2, 1, 0, CV_8U)) )
- return;
- }
- CV_SUPPRESS_DEPRECATED_END;
- }
-#endif
-
CvtColorLoop(src_data, src_step, dst_data, dst_step, width, height, RGB2RGB5x5(scn, swapBlue ? 2 : 0, greenBits));
}
@@ -8762,41 +9679,6 @@ void cvtBGR5x5toBGR(const uchar * src_data, size_t src_step,
CALL_HAL(cvtBGR5x5toBGR, cv_hal_cvtBGR5x5toBGR, src_data, src_step, dst_data, dst_step, width, height, dcn, swapBlue, greenBits);
-#if defined(HAVE_IPP) && IPP_VERSION_X100 < 900
- CV_IPP_CHECK()
- {
- CV_SUPPRESS_DEPRECATED_START;
- if (dcn == 3 && greenBits == 6 && !swapBlue)
- {
- if (CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPGeneralFunctor((ippiGeneralFunc)ippiBGR565ToBGR_16u8u_C3R)))
- return;
- }
- else if (dcn == 3 && greenBits == 6 && swapBlue)
- {
- if (CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPGeneralReorderFunctor((ippiGeneralFunc)ippiBGR565ToBGR_16u8u_C3R,
- ippiSwapChannelsC3RTab[CV_8U], 2, 1, 0, CV_8U)))
- return;
- }
- else if (dcn == 4 && greenBits == 6 && !swapBlue)
- {
- if (CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPGeneralReorderFunctor((ippiGeneralFunc)ippiBGR565ToBGR_16u8u_C3R,
- ippiSwapChannelsC3C4RTab[CV_8U], 0, 1, 2, CV_8U)))
- return;
- }
- else if (dcn == 4 && greenBits == 6 && swapBlue)
- {
- if (CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPGeneralReorderFunctor((ippiGeneralFunc)ippiBGR565ToBGR_16u8u_C3R,
- ippiSwapChannelsC3C4RTab[CV_8U], 2, 1, 0, CV_8U)))
- return;
- }
- CV_SUPPRESS_DEPRECATED_END;
- }
-#endif
-
CvtColorLoop(src_data, src_step, dst_data, dst_step, width, height, RGB5x52RGB(dcn, swapBlue ? 2 : 0, greenBits));
}
@@ -8813,30 +9695,30 @@ void cvtBGRtoGray(const uchar * src_data, size_t src_step,
#if defined(HAVE_IPP) && IPP_VERSION_X100 >= 700
CV_IPP_CHECK()
{
- if(depth == CV_32F && scn == 3 && !swapBlue)
- {
- if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPColor2GrayFunctor(ippiColor2GrayC3Tab[depth])) )
- return;
- }
- else if(depth == CV_32F && scn == 3 && swapBlue)
- {
- if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPGeneralFunctor(ippiRGB2GrayC3Tab[depth])) )
- return;
- }
- else if(depth == CV_32F && scn == 4 && !swapBlue)
- {
- if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPColor2GrayFunctor(ippiColor2GrayC4Tab[depth])) )
- return;
- }
- else if(depth == CV_32F && scn == 4 && swapBlue)
- {
- if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPGeneralFunctor(ippiRGB2GrayC4Tab[depth])) )
- return;
- }
+ if(depth == CV_32F && scn == 3 && !swapBlue)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ IPPColor2GrayFunctor(ippiColor2GrayC3Tab[depth])) )
+ return;
+ }
+ else if(depth == CV_32F && scn == 3 && swapBlue)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ IPPGeneralFunctor(ippiRGB2GrayC3Tab[depth])) )
+ return;
+ }
+ else if(depth == CV_32F && scn == 4 && !swapBlue)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ IPPColor2GrayFunctor(ippiColor2GrayC4Tab[depth])) )
+ return;
+ }
+ else if(depth == CV_32F && scn == 4 && swapBlue)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ IPPGeneralFunctor(ippiRGB2GrayC4Tab[depth])) )
+ return;
+ }
}
#endif
@@ -8862,18 +9744,18 @@ void cvtGraytoBGR(const uchar * src_data, size_t src_step,
#if defined(HAVE_IPP) && IPP_VERSION_X100 >= 700
CV_IPP_CHECK()
{
- if(dcn == 3)
- {
- if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ if(dcn == 3)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
IPPGray2BGRFunctor(ippiCopyP3C3RTab[depth])) )
- return;
- }
- else if(dcn == 4)
- {
- if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ return;
+ }
+ else if(dcn == 4)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
IPPGray2BGRAFunctor(ippiCopyP3C3RTab[depth], ippiSwapChannelsC3C4RTab[depth], depth)) )
- return;
- }
+ return;
+ }
}
#endif
@@ -8919,38 +9801,40 @@ void cvtBGRtoYUV(const uchar * src_data, size_t src_step,
CALL_HAL(cvtBGRtoYUV, cv_hal_cvtBGRtoYUV, src_data, src_step, dst_data, dst_step, width, height, depth, scn, swapBlue, isCbCr);
-#if defined(HAVE_IPP) && IPP_DISABLE_BLOCK
+#if defined(HAVE_IPP)
+#if !IPP_DISABLE_RGB_YUV
CV_IPP_CHECK()
{
- if (scn == 3 && depth == CV_8U && swapBlue && !isCbCr)
- {
- if (CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPGeneralFunctor((ippiGeneralFunc)ippiRGBToYUV_8u_C3R)))
- return;
- }
- else if (scn == 3 && depth == CV_8U && !swapBlue && !isCbCr)
- {
- if (CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth],
- (ippiGeneralFunc)ippiRGBToYUV_8u_C3R, 2, 1, 0, depth)))
- return;
- }
- else if (scn == 4 && depth == CV_8U && swapBlue && !isCbCr)
- {
- if (CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth],
- (ippiGeneralFunc)ippiRGBToYUV_8u_C3R, 0, 1, 2, depth)))
- return;
- }
- else if (scn == 4 && depth == CV_8U && !swapBlue && !isCbCr)
- {
- if (CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth],
- (ippiGeneralFunc)ippiRGBToYUV_8u_C3R, 2, 1, 0, depth)))
- return;
- }
+ if (scn == 3 && depth == CV_8U && swapBlue && !isCbCr)
+ {
+ if (CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ IPPGeneralFunctor((ippiGeneralFunc)ippiRGBToYUV_8u_C3R)))
+ return;
+ }
+ else if (scn == 3 && depth == CV_8U && !swapBlue && !isCbCr)
+ {
+ if (CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth],
+ (ippiGeneralFunc)ippiRGBToYUV_8u_C3R, 2, 1, 0, depth)))
+ return;
+ }
+ else if (scn == 4 && depth == CV_8U && swapBlue && !isCbCr)
+ {
+ if (CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth],
+ (ippiGeneralFunc)ippiRGBToYUV_8u_C3R, 0, 1, 2, depth)))
+ return;
+ }
+ else if (scn == 4 && depth == CV_8U && !swapBlue && !isCbCr)
+ {
+ if (CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth],
+ (ippiGeneralFunc)ippiRGBToYUV_8u_C3R, 2, 1, 0, depth)))
+ return;
+ }
}
#endif
+#endif
int blueIdx = swapBlue ? 2 : 0;
if( depth == CV_8U )
@@ -8971,38 +9855,40 @@ void cvtYUVtoBGR(const uchar * src_data, size_t src_step,
CALL_HAL(cvtYUVtoBGR, cv_hal_cvtYUVtoBGR, src_data, src_step, dst_data, dst_step, width, height, depth, dcn, swapBlue, isCbCr);
-#if defined(HAVE_IPP) && IPP_DISABLE_BLOCK
+#if defined(HAVE_IPP)
+#if !IPP_DISABLE_YUV_RGB
CV_IPP_CHECK()
{
- if (dcn == 3 && depth == CV_8U && swapBlue && !isCbCr)
- {
- if (CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPGeneralFunctor((ippiGeneralFunc)ippiYUVToRGB_8u_C3R)))
- return;
- }
- else if (dcn == 3 && depth == CV_8U && !swapBlue && !isCbCr)
- {
- if (CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPGeneralReorderFunctor((ippiGeneralFunc)ippiYUVToRGB_8u_C3R,
- ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth)))
- return;
- }
- else if (dcn == 4 && depth == CV_8U && swapBlue && !isCbCr)
- {
- if (CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPGeneralReorderFunctor((ippiGeneralFunc)ippiYUVToRGB_8u_C3R,
- ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth)))
- return;
- }
- else if (dcn == 4 && depth == CV_8U && !swapBlue && !isCbCr)
- {
- if (CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPGeneralReorderFunctor((ippiGeneralFunc)ippiYUVToRGB_8u_C3R,
- ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)))
- return;
- }
+ if (dcn == 3 && depth == CV_8U && swapBlue && !isCbCr)
+ {
+ if (CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ IPPGeneralFunctor((ippiGeneralFunc)ippiYUVToRGB_8u_C3R)))
+ return;
+ }
+ else if (dcn == 3 && depth == CV_8U && !swapBlue && !isCbCr)
+ {
+ if (CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ IPPGeneralReorderFunctor((ippiGeneralFunc)ippiYUVToRGB_8u_C3R,
+ ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth)))
+ return;
+ }
+ else if (dcn == 4 && depth == CV_8U && swapBlue && !isCbCr)
+ {
+ if (CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ IPPGeneralReorderFunctor((ippiGeneralFunc)ippiYUVToRGB_8u_C3R,
+ ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth)))
+ return;
+ }
+ else if (dcn == 4 && depth == CV_8U && !swapBlue && !isCbCr)
+ {
+ if (CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ IPPGeneralReorderFunctor((ippiGeneralFunc)ippiYUVToRGB_8u_C3R,
+ ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)))
+ return;
+ }
}
#endif
+#endif
int blueIdx = swapBlue ? 2 : 0;
if( depth == CV_8U )
@@ -9023,34 +9909,36 @@ void cvtBGRtoXYZ(const uchar * src_data, size_t src_step,
CALL_HAL(cvtBGRtoXYZ, cv_hal_cvtBGRtoXYZ, src_data, src_step, dst_data, dst_step, width, height, depth, scn, swapBlue);
#if defined(HAVE_IPP) && IPP_VERSION_X100 >= 700
+#if !IPP_DISABLE_RGB_XYZ
CV_IPP_CHECK()
{
- if(scn == 3 && depth != CV_32F && !swapBlue)
- {
- if( CvtColorIPPLoopCopy(src_data, src_step, CV_MAKETYPE(depth, scn), dst_data, dst_step, width, height,
- IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth], ippiRGB2XYZTab[depth], 2, 1, 0, depth)) )
- return;
- }
- else if(scn == 4 && depth != CV_32F && !swapBlue)
- {
- if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2XYZTab[depth], 2, 1, 0, depth)) )
- return;
- }
- else if(scn == 3 && depth != CV_32F && swapBlue)
- {
- if( CvtColorIPPLoopCopy(src_data, src_step, CV_MAKETYPE(depth, scn), dst_data, dst_step, width, height,
- IPPGeneralFunctor(ippiRGB2XYZTab[depth])) )
- return;
- }
- else if(scn == 4 && depth != CV_32F && swapBlue)
- {
- if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2XYZTab[depth], 0, 1, 2, depth)) )
- return;
- }
+ if(scn == 3 && depth != CV_32F && !swapBlue)
+ {
+ if( CvtColorIPPLoopCopy(src_data, src_step, CV_MAKETYPE(depth, scn), dst_data, dst_step, width, height,
+ IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth], ippiRGB2XYZTab[depth], 2, 1, 0, depth)) )
+ return;
+ }
+ else if(scn == 4 && depth != CV_32F && !swapBlue)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2XYZTab[depth], 2, 1, 0, depth)) )
+ return;
+ }
+ else if(scn == 3 && depth != CV_32F && swapBlue)
+ {
+ if( CvtColorIPPLoopCopy(src_data, src_step, CV_MAKETYPE(depth, scn), dst_data, dst_step, width, height,
+ IPPGeneralFunctor(ippiRGB2XYZTab[depth])) )
+ return;
+ }
+ else if(scn == 4 && depth != CV_32F && swapBlue)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2XYZTab[depth], 0, 1, 2, depth)) )
+ return;
+ }
}
#endif
+#endif
int blueIdx = swapBlue ? 2 : 0;
if( depth == CV_8U )
@@ -9071,34 +9959,36 @@ void cvtXYZtoBGR(const uchar * src_data, size_t src_step,
CALL_HAL(cvtXYZtoBGR, cv_hal_cvtXYZtoBGR, src_data, src_step, dst_data, dst_step, width, height, depth, dcn, swapBlue);
#if defined(HAVE_IPP) && IPP_VERSION_X100 >= 700
+#if !IPP_DISABLE_XYZ_RGB
CV_IPP_CHECK()
{
- if(dcn == 3 && depth != CV_32F && !swapBlue)
- {
- if( CvtColorIPPLoopCopy(src_data, src_step, CV_MAKETYPE(depth, 3), dst_data, dst_step, width, height,
- IPPGeneralReorderFunctor(ippiXYZ2RGBTab[depth], ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth)) )
- return;
- }
- else if(dcn == 4 && depth != CV_32F && !swapBlue)
- {
- if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPGeneralReorderFunctor(ippiXYZ2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)) )
- return;
- }
- if(dcn == 3 && depth != CV_32F && swapBlue)
- {
- if( CvtColorIPPLoopCopy(src_data, src_step, CV_MAKETYPE(depth, 3), dst_data, dst_step, width, height,
- IPPGeneralFunctor(ippiXYZ2RGBTab[depth])) )
- return;
- }
- else if(dcn == 4 && depth != CV_32F && swapBlue)
- {
- if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPGeneralReorderFunctor(ippiXYZ2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth)) )
- return;
- }
+ if(dcn == 3 && depth != CV_32F && !swapBlue)
+ {
+ if( CvtColorIPPLoopCopy(src_data, src_step, CV_MAKETYPE(depth, 3), dst_data, dst_step, width, height,
+ IPPGeneralReorderFunctor(ippiXYZ2RGBTab[depth], ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth)) )
+ return;
+ }
+ else if(dcn == 4 && depth != CV_32F && !swapBlue)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ IPPGeneralReorderFunctor(ippiXYZ2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)) )
+ return;
+ }
+ if(dcn == 3 && depth != CV_32F && swapBlue)
+ {
+ if( CvtColorIPPLoopCopy(src_data, src_step, CV_MAKETYPE(depth, 3), dst_data, dst_step, width, height,
+ IPPGeneralFunctor(ippiXYZ2RGBTab[depth])) )
+ return;
+ }
+ else if(dcn == 4 && depth != CV_32F && swapBlue)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ IPPGeneralReorderFunctor(ippiXYZ2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth)) )
+ return;
+ }
}
#endif
+#endif
int blueIdx = swapBlue ? 2 : 0;
if( depth == CV_8U )
@@ -9122,60 +10012,60 @@ void cvtBGRtoHSV(const uchar * src_data, size_t src_step,
#if defined(HAVE_IPP) && IPP_VERSION_X100 >= 700
CV_IPP_CHECK()
{
- if (depth == CV_8U && isFullRange)
- {
- if (isHSV)
+ if(depth == CV_8U && isFullRange)
{
-#if IPP_DISABLE_BLOCK // breaks OCL accuracy tests
- if(scn == 3 && !swapBlue)
+ if (isHSV)
{
- if( CvtColorIPPLoopCopy(src_data, src_step, CV_MAKE_TYPE(depth, scn), dst_data, dst_step, width, height,
- IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth], ippiRGB2HSVTab[depth], 2, 1, 0, depth)) )
- return;
- }
- else if(scn == 4 && !swapBlue)
- {
- if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2HSVTab[depth], 2, 1, 0, depth)) )
- return;
- }
- else if(scn == 4 && swapBlue)
- {
- if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2HSVTab[depth], 0, 1, 2, depth)) )
- return;
- }
+#if !IPP_DISABLE_RGB_HSV // breaks OCL accuracy tests
+ if(scn == 3 && !swapBlue)
+ {
+ if( CvtColorIPPLoopCopy(src_data, src_step, CV_MAKE_TYPE(depth, scn), dst_data, dst_step, width, height,
+ IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth], ippiRGB2HSVTab[depth], 2, 1, 0, depth)) )
+ return;
+ }
+ else if(scn == 4 && !swapBlue)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2HSVTab[depth], 2, 1, 0, depth)) )
+ return;
+ }
+ else if(scn == 4 && swapBlue)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2HSVTab[depth], 0, 1, 2, depth)) )
+ return;
+ }
#endif
- }
- else
- {
- if(scn == 3 && !swapBlue)
- {
- if( CvtColorIPPLoopCopy(src_data, src_step, CV_MAKE_TYPE(depth, scn), dst_data, dst_step, width, height,
- IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth], ippiRGB2HLSTab[depth], 2, 1, 0, depth)) )
- return;
- }
- else if(scn == 4 && !swapBlue)
- {
- if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2HLSTab[depth], 2, 1, 0, depth)) )
- return;
- }
- else if(scn == 3 && swapBlue)
- {
- if( CvtColorIPPLoopCopy(src_data, src_step, CV_MAKE_TYPE(depth, scn), dst_data, dst_step, width, height,
- IPPGeneralFunctor(ippiRGB2HLSTab[depth])) )
- return;
}
- else if(scn == 4 && swapBlue)
+ else
{
- if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2HLSTab[depth], 0, 1, 2, depth)) )
- return;
+ if(scn == 3 && !swapBlue)
+ {
+ if( CvtColorIPPLoopCopy(src_data, src_step, CV_MAKE_TYPE(depth, scn), dst_data, dst_step, width, height,
+ IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth], ippiRGB2HLSTab[depth], 2, 1, 0, depth)) )
+ return;
+ }
+ else if(scn == 4 && !swapBlue)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2HLSTab[depth], 2, 1, 0, depth)) )
+ return;
+ }
+ else if(scn == 3 && swapBlue)
+ {
+ if( CvtColorIPPLoopCopy(src_data, src_step, CV_MAKE_TYPE(depth, scn), dst_data, dst_step, width, height,
+ IPPGeneralFunctor(ippiRGB2HLSTab[depth])) )
+ return;
+ }
+ else if(scn == 4 && swapBlue)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2HLSTab[depth], 0, 1, 2, depth)) )
+ return;
+ }
}
}
}
- }
#endif
int hrange = depth == CV_32F ? 360 : isFullRange ? 256 : 180;
@@ -9209,64 +10099,64 @@ void cvtHSVtoBGR(const uchar * src_data, size_t src_step,
#if defined(HAVE_IPP) && IPP_VERSION_X100 >= 700
CV_IPP_CHECK()
{
- if (depth == CV_8U && isFullRange)
- {
- if (isHSV)
- {
- if(dcn == 3 && !swapBlue)
- {
- if( CvtColorIPPLoopCopy(src_data, src_step, CV_MAKETYPE(depth, 3), dst_data, dst_step, width, height,
- IPPGeneralReorderFunctor(ippiHSV2RGBTab[depth], ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth)) )
- return;
- }
- else if(dcn == 4 && !swapBlue)
- {
- if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPGeneralReorderFunctor(ippiHSV2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)) )
- return;
- }
- else if(dcn == 3 && swapBlue)
- {
- if( CvtColorIPPLoopCopy(src_data, src_step, CV_MAKETYPE(depth, 3), dst_data, dst_step, width, height,
- IPPGeneralFunctor(ippiHSV2RGBTab[depth])) )
- return;
- }
- else if(dcn == 4 && swapBlue)
- {
- if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPGeneralReorderFunctor(ippiHSV2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth)) )
- return;
- }
- }
- else
+ if (depth == CV_8U && isFullRange)
{
- if(dcn == 3 && !swapBlue)
+ if (isHSV)
{
- if( CvtColorIPPLoopCopy(src_data, src_step, CV_MAKETYPE(depth, 3), dst_data, dst_step, width, height,
- IPPGeneralReorderFunctor(ippiHLS2RGBTab[depth], ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth)) )
- return;
- }
- else if(dcn == 4 && !swapBlue)
- {
- if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPGeneralReorderFunctor(ippiHLS2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)) )
- return;
- }
- else if(dcn == 3 && swapBlue)
- {
- if( CvtColorIPPLoopCopy(src_data, src_step, CV_MAKETYPE(depth, 3), dst_data, dst_step, width, height,
- IPPGeneralFunctor(ippiHLS2RGBTab[depth])) )
- return;
+ if(dcn == 3 && !swapBlue)
+ {
+ if( CvtColorIPPLoopCopy(src_data, src_step, CV_MAKETYPE(depth, 3), dst_data, dst_step, width, height,
+ IPPGeneralReorderFunctor(ippiHSV2RGBTab[depth], ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth)) )
+ return;
+ }
+ else if(dcn == 4 && !swapBlue)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ IPPGeneralReorderFunctor(ippiHSV2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)) )
+ return;
+ }
+ else if(dcn == 3 && swapBlue)
+ {
+ if( CvtColorIPPLoopCopy(src_data, src_step, CV_MAKETYPE(depth, 3), dst_data, dst_step, width, height,
+ IPPGeneralFunctor(ippiHSV2RGBTab[depth])) )
+ return;
+ }
+ else if(dcn == 4 && swapBlue)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ IPPGeneralReorderFunctor(ippiHSV2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth)) )
+ return;
+ }
}
- else if(dcn == 4 && swapBlue)
+ else
{
- if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
- IPPGeneralReorderFunctor(ippiHLS2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth)) )
- return;
+ if(dcn == 3 && !swapBlue)
+ {
+ if( CvtColorIPPLoopCopy(src_data, src_step, CV_MAKETYPE(depth, 3), dst_data, dst_step, width, height,
+ IPPGeneralReorderFunctor(ippiHLS2RGBTab[depth], ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth)) )
+ return;
+ }
+ else if(dcn == 4 && !swapBlue)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ IPPGeneralReorderFunctor(ippiHLS2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)) )
+ return;
+ }
+ else if(dcn == 3 && swapBlue)
+ {
+ if( CvtColorIPPLoopCopy(src_data, src_step, CV_MAKETYPE(depth, 3), dst_data, dst_step, width, height,
+ IPPGeneralFunctor(ippiHLS2RGBTab[depth])) )
+ return;
+ }
+ else if(dcn == 4 && swapBlue)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data, dst_step, width, height,
+ IPPGeneralReorderFunctor(ippiHLS2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth)) )
+ return;
+ }
}
}
}
- }
#endif
int hrange = depth == CV_32F ? 360 : isFullRange ? 255 : 180;
@@ -9297,73 +10187,73 @@ void cvtBGRtoLab(const uchar * src_data, size_t src_step,
CALL_HAL(cvtBGRtoLab, cv_hal_cvtBGRtoLab, src_data, src_step, dst_data, dst_step, width, height, depth, scn, swapBlue, isLab, srgb);
-#if defined(HAVE_IPP) && IPP_DISABLE_BLOCK
+#if defined(HAVE_IPP) && !IPP_DISABLE_RGB_LAB
CV_IPP_CHECK()
{
- if (!srgb)
- {
- if (isLab)
+ if (!srgb)
{
- if (scn == 3 && depth == CV_8U && !swapBlue)
+ if (isLab)
{
- if (CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
- IPPGeneralFunctor((ippiGeneralFunc)ippiBGRToLab_8u_C3R)))
- return;
- }
- else if (scn == 4 && depth == CV_8U && !swapBlue)
- {
- if (CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
- IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth],
- (ippiGeneralFunc)ippiBGRToLab_8u_C3R, 0, 1, 2, depth)))
- return;
- }
- else if (scn == 3 && depth == CV_8U && swapBlue) // slower than OpenCV
- {
- if (CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
- IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth],
- (ippiGeneralFunc)ippiBGRToLab_8u_C3R, 2, 1, 0, depth)))
- return;
- }
- else if (scn == 4 && depth == CV_8U && swapBlue) // slower than OpenCV
- {
- if (CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
- IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth],
- (ippiGeneralFunc)ippiBGRToLab_8u_C3R, 2, 1, 0, depth)))
- return;
- }
- }
- else
- {
- if (scn == 3 && swapBlue)
- {
- if (CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
- IPPGeneralFunctor(ippiRGBToLUVTab[depth])))
- return;
- }
- else if (scn == 4 && swapBlue)
- {
- if (CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
- IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth],
- ippiRGBToLUVTab[depth], 0, 1, 2, depth)))
- return;
- }
- else if (scn == 3 && !swapBlue)
- {
- if (CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
- IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth],
- ippiRGBToLUVTab[depth], 2, 1, 0, depth)))
- return;
+ if (scn == 3 && depth == CV_8U && !swapBlue)
+ {
+ if (CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
+ IPPGeneralFunctor((ippiGeneralFunc)ippiBGRToLab_8u_C3R)))
+ return;
+ }
+ else if (scn == 4 && depth == CV_8U && !swapBlue)
+ {
+ if (CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
+ IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth],
+ (ippiGeneralFunc)ippiBGRToLab_8u_C3R, 0, 1, 2, depth)))
+ return;
+ }
+ else if (scn == 3 && depth == CV_8U && swapBlue) // slower than OpenCV
+ {
+ if (CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
+ IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth],
+ (ippiGeneralFunc)ippiBGRToLab_8u_C3R, 2, 1, 0, depth)))
+ return;
+ }
+ else if (scn == 4 && depth == CV_8U && swapBlue) // slower than OpenCV
+ {
+ if (CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
+ IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth],
+ (ippiGeneralFunc)ippiBGRToLab_8u_C3R, 2, 1, 0, depth)))
+ return;
+ }
}
- else if (scn == 4 && !swapBlue)
+ else
{
- if (CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
- IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth],
- ippiRGBToLUVTab[depth], 2, 1, 0, depth)))
- return;
+ if (scn == 3 && swapBlue)
+ {
+ if (CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
+ IPPGeneralFunctor(ippiRGBToLUVTab[depth])))
+ return;
+ }
+ else if (scn == 4 && swapBlue)
+ {
+ if (CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
+ IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth],
+ ippiRGBToLUVTab[depth], 0, 1, 2, depth)))
+ return;
+ }
+ else if (scn == 3 && !swapBlue)
+ {
+ if (CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
+ IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth],
+ ippiRGBToLUVTab[depth], 2, 1, 0, depth)))
+ return;
+ }
+ else if (scn == 4 && !swapBlue)
+ {
+ if (CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
+ IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth],
+ ippiRGBToLUVTab[depth], 2, 1, 0, depth)))
+ return;
+ }
}
}
}
- }
#endif
@@ -9394,73 +10284,73 @@ void cvtLabtoBGR(const uchar * src_data, size_t src_step,
CALL_HAL(cvtLabtoBGR, cv_hal_cvtLabtoBGR, src_data, src_step, dst_data, dst_step, width, height, depth, dcn, swapBlue, isLab, srgb);
-#if defined(HAVE_IPP) && IPP_DISABLE_BLOCK
+#if defined(HAVE_IPP) && !IPP_DISABLE_LAB_RGB
CV_IPP_CHECK()
{
- if (!srgb)
- {
- if (isLab)
- {
- if( dcn == 3 && depth == CV_8U && !swapBlue)
- {
- if( CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
- IPPGeneralFunctor((ippiGeneralFunc)ippiLabToBGR_8u_C3R)) )
- return;
- }
- else if( dcn == 4 && depth == CV_8U && !swapBlue)
- {
- if( CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
- IPPGeneralReorderFunctor((ippiGeneralFunc)ippiLabToBGR_8u_C3R,
- ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth)) )
- return;
- }
- if( dcn == 3 && depth == CV_8U && swapBlue)
- {
- if( CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
- IPPGeneralReorderFunctor((ippiGeneralFunc)ippiLabToBGR_8u_C3R,
- ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth)) )
- return;
- }
- else if( dcn == 4 && depth == CV_8U && swapBlue)
- {
- if( CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
- IPPGeneralReorderFunctor((ippiGeneralFunc)ippiLabToBGR_8u_C3R,
- ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)) )
- return;
- }
- }
- else
+ if (!srgb)
{
- if( dcn == 3 && swapBlue)
+ if (isLab)
{
- if( CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
- IPPGeneralFunctor(ippiLUVToRGBTab[depth])) )
- return;
- }
- else if( dcn == 4 && swapBlue)
- {
- if( CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
- IPPGeneralReorderFunctor(ippiLUVToRGBTab[depth],
- ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth)) )
- return;
- }
- if( dcn == 3 && !swapBlue)
- {
- if( CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
- IPPGeneralReorderFunctor(ippiLUVToRGBTab[depth],
- ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth)) )
- return;
+ if( dcn == 3 && depth == CV_8U && !swapBlue)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
+ IPPGeneralFunctor((ippiGeneralFunc)ippiLabToBGR_8u_C3R)) )
+ return;
+ }
+ else if( dcn == 4 && depth == CV_8U && !swapBlue)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
+ IPPGeneralReorderFunctor((ippiGeneralFunc)ippiLabToBGR_8u_C3R,
+ ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth)) )
+ return;
+ }
+ if( dcn == 3 && depth == CV_8U && swapBlue)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
+ IPPGeneralReorderFunctor((ippiGeneralFunc)ippiLabToBGR_8u_C3R,
+ ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth)) )
+ return;
+ }
+ else if( dcn == 4 && depth == CV_8U && swapBlue)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
+ IPPGeneralReorderFunctor((ippiGeneralFunc)ippiLabToBGR_8u_C3R,
+ ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)) )
+ return;
+ }
}
- else if( dcn == 4 && !swapBlue)
+ else
{
- if( CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
- IPPGeneralReorderFunctor(ippiLUVToRGBTab[depth],
- ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)) )
- return;
+ if( dcn == 3 && swapBlue)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
+ IPPGeneralFunctor(ippiLUVToRGBTab[depth])) )
+ return;
+ }
+ else if( dcn == 4 && swapBlue)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
+ IPPGeneralReorderFunctor(ippiLUVToRGBTab[depth],
+ ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth)) )
+ return;
+ }
+ if( dcn == 3 && !swapBlue)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
+ IPPGeneralReorderFunctor(ippiLUVToRGBTab[depth],
+ ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth)) )
+ return;
+ }
+ else if( dcn == 4 && !swapBlue)
+ {
+ if( CvtColorIPPLoop(src_data, src_step, dst_data,dst_step, width, height,
+ IPPGeneralReorderFunctor(ippiLUVToRGBTab[depth],
+ ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)) )
+ return;
+ }
}
}
}
- }
#endif
int blueIdx = swapBlue ? 2 : 0;
@@ -9852,6 +10742,7 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
case CV_BayerBG2BGR: case CV_BayerGB2BGR: case CV_BayerRG2BGR: case CV_BayerGR2BGR:
case CV_BayerBG2BGR_VNG: case CV_BayerGB2BGR_VNG: case CV_BayerRG2BGR_VNG: case CV_BayerGR2BGR_VNG:
case CV_BayerBG2BGR_EA: case CV_BayerGB2BGR_EA: case CV_BayerRG2BGR_EA: case CV_BayerGR2BGR_EA:
+ case CV_BayerBG2BGRA: case CV_BayerGB2BGRA: case CV_BayerRG2BGRA: case CV_BayerGR2BGRA:
demosaicing(src, _dst, code, dcn);
break;
@@ -9893,10 +10784,12 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
_dst.create(dstSz, CV_MAKETYPE(depth, dcn));
dst = _dst.getMat();
#ifdef HAVE_IPP
- if (CV_INSTRUMENT_FUN_IPP(ippiCopy_8u_C1R, src.data, (int)src.step, dst.data, (int)dst.step,
- ippiSize(dstSz.width, dstSz.height)) >= 0)
+#if IPP_VERSION_X100 >= 201700
+ if (CV_INSTRUMENT_FUN_IPP(ippiCopy_8u_C1R_L, src.data, (IppSizeL)src.step, dst.data, (IppSizeL)dst.step,
+ ippiSizeL(dstSz.width, dstSz.height)) >= 0)
break;
#endif
+#endif
src(Range(0, dstSz.height), Range::all()).copyTo(dst);
}
break;
diff --git a/modules/imgproc/src/colormap.cpp b/modules/imgproc/src/colormap.cpp
index 3fc9755..f8d5d1b 100644
--- a/modules/imgproc/src/colormap.cpp
+++ b/modules/imgproc/src/colormap.cpp
@@ -490,6 +490,22 @@ namespace colormap
}
};
+ // UserColormap .
+ class UserColorMap : public ColorMap {
+ public:
+
+ UserColorMap(Mat c) : ColorMap() {
+ init(c);
+ }
+
+ void init(Mat c) {
+ this->_lut = c;
+ }
+ void init(int n) {
+ CV_Error(Error::StsAssert, format("unused method in UserColormap init(%d).",n));
+ }
+ };
+
void ColorMap::operator()(InputArray _src, OutputArray _dst) const
{
CV_INSTRUMENT_REGION()
@@ -546,4 +562,16 @@ namespace colormap
delete cm;
}
+
+ void applyColorMap(InputArray src, OutputArray dst, InputArray userColor)
+ {
+ if (userColor.size() != Size(1,256))
+ CV_Error(Error::StsAssert, "cv::LUT only supports tables of size 256.");
+ if (userColor.type() != CV_8UC1 && userColor.type() != CV_8UC3)
+ CV_Error(Error::StsAssert, "cv::LUT only supports tables CV_8UC1 or CV_8UC3.");
+ colormap::UserColorMap cm(userColor.getMat());
+
+ (cm)(src, dst);
+ }
+
}
diff --git a/modules/imgproc/src/connectedcomponents.cpp b/modules/imgproc/src/connectedcomponents.cpp
index bf53704..0ad7f67 100644
--- a/modules/imgproc/src/connectedcomponents.cpp
+++ b/modules/imgproc/src/connectedcomponents.cpp
@@ -42,6 +42,7 @@
// 2016 Federico Bolelli <federico.bolelli at hotmail.com>
// 2016 Lorenzo Baraldi <lorenzo.baraldi at unimore.it>
// 2016 Roberto Vezzani <roberto.vezzani at unimore.it>
+// 2016 Michele Cancilla <cancilla.michele at gmail.com>
//M*/
//
#include "precomp.hpp"
@@ -53,30 +54,50 @@ namespace cv{
struct NoOp{
NoOp(){
}
+
+ inline
void init(int /*labels*/){
}
+
+ inline
+ void initElement(const int /*nlabels*/){
+ }
+
inline
void operator()(int r, int c, int l){
- (void) r;
- (void) c;
- (void) l;
+ (void)r;
+ (void)c;
+ (void)l;
+ }
+
+ void finish(){
+ }
+
+ inline
+ void setNextLoc(const int /*nextLoc*/){
}
- void finish(){}
+
+ inline static
+ void mergeStats(const cv::Mat& /*imgLabels*/, NoOp * /*sopArray*/, NoOp& /*sop*/, const int& /*nLabels*/){
+ }
+
};
struct Point2ui64{
uint64 x, y;
- Point2ui64(uint64 _x, uint64 _y):x(_x), y(_y){}
- };
+ Point2ui64(uint64 _x, uint64 _y) :x(_x), y(_y){}
+ };
struct CCStatsOp{
- const _OutputArray* _mstatsv;
+ const _OutputArray *_mstatsv;
cv::Mat statsv;
- const _OutputArray* _mcentroidsv;
+ const _OutputArray *_mcentroidsv;
cv::Mat centroidsv;
std::vector<Point2ui64> integrals;
+ int _nextLoc;
+
+ CCStatsOp() : _mstatsv(0), _mcentroidsv(0), _nextLoc(0) {}
+ CCStatsOp(OutputArray _statsv, OutputArray _centroidsv) : _mstatsv(&_statsv), _mcentroidsv(&_centroidsv), _nextLoc(0){}
- CCStatsOp(OutputArray _statsv, OutputArray _centroidsv): _mstatsv(&_statsv), _mcentroidsv(&_centroidsv){
- }
inline
void init(int nlabels){
_mstatsv->create(cv::Size(CC_STAT_MAX, nlabels), cv::DataType<int>::type);
@@ -84,8 +105,22 @@ namespace cv{
_mcentroidsv->create(cv::Size(2, nlabels), cv::DataType<double>::type);
centroidsv = _mcentroidsv->getMat();
- for(int l = 0; l < (int) nlabels; ++l){
- int *row = (int *) &statsv.at<int>(l, 0);
+ for (int l = 0; l < (int)nlabels; ++l){
+ int *row = (int *)&statsv.at<int>(l, 0);
+ row[CC_STAT_LEFT] = INT_MAX;
+ row[CC_STAT_TOP] = INT_MAX;
+ row[CC_STAT_WIDTH] = INT_MIN;
+ row[CC_STAT_HEIGHT] = INT_MIN;
+ row[CC_STAT_AREA] = 0;
+ }
+ integrals.resize(nlabels, Point2ui64(0, 0));
+ }
+
+ inline
+ void initElement(const int nlabels){
+ statsv = cv::Mat(nlabels, CC_STAT_MAX, cv::DataType<int>::type);
+ for (int l = 0; l < (int)nlabels; ++l){
+ int *row = (int *)statsv.ptr(l);
row[CC_STAT_LEFT] = INT_MAX;
row[CC_STAT_TOP] = INT_MAX;
row[CC_STAT_WIDTH] = INT_MIN;
@@ -94,30 +129,62 @@ namespace cv{
}
integrals.resize(nlabels, Point2ui64(0, 0));
}
+
void operator()(int r, int c, int l){
- int *row = &statsv.at<int>(l, 0);
+ int *row =& statsv.at<int>(l, 0);
row[CC_STAT_LEFT] = MIN(row[CC_STAT_LEFT], c);
row[CC_STAT_WIDTH] = MAX(row[CC_STAT_WIDTH], c);
row[CC_STAT_TOP] = MIN(row[CC_STAT_TOP], r);
row[CC_STAT_HEIGHT] = MAX(row[CC_STAT_HEIGHT], r);
row[CC_STAT_AREA]++;
- Point2ui64 &integral = integrals[l];
+ Point2ui64& integral = integrals[l];
integral.x += c;
integral.y += r;
}
+
void finish(){
- for(int l = 0; l < statsv.rows; ++l){
- int *row = &statsv.at<int>(l, 0);
+ for (int l = 0; l < statsv.rows; ++l){
+ int *row =& statsv.at<int>(l, 0);
row[CC_STAT_WIDTH] = row[CC_STAT_WIDTH] - row[CC_STAT_LEFT] + 1;
row[CC_STAT_HEIGHT] = row[CC_STAT_HEIGHT] - row[CC_STAT_TOP] + 1;
- Point2ui64 &integral = integrals[l];
+ Point2ui64& integral = integrals[l];
double *centroid = ¢roidsv.at<double>(l, 0);
double area = ((unsigned*)row)[CC_STAT_AREA];
centroid[0] = double(integral.x) / area;
centroid[1] = double(integral.y) / area;
}
}
+
+ inline
+ void setNextLoc(const int nextLoc){
+ _nextLoc = nextLoc;
+ }
+
+ inline static
+ void mergeStats(const cv::Mat& imgLabels, CCStatsOp *sopArray, CCStatsOp& sop, const int& nLabels){
+ const int h = imgLabels.rows;
+
+ if (sop._nextLoc != h){
+ for (int nextLoc = sop._nextLoc; nextLoc < h; nextLoc = sopArray[nextLoc]._nextLoc){
+ //merge between sopNext and sop
+ for (int l = 0; l < nLabels; ++l){
+ int *rowNext = (int*)sopArray[nextLoc].statsv.ptr(l);
+ if (rowNext[CC_STAT_AREA] > 0){ //if changed merge all the stats
+ int *rowMerged = (int*)sop.statsv.ptr(l);
+ rowMerged[CC_STAT_LEFT] = MIN(rowMerged[CC_STAT_LEFT], rowNext[CC_STAT_LEFT]);
+ rowMerged[CC_STAT_WIDTH] = MAX(rowMerged[CC_STAT_WIDTH], rowNext[CC_STAT_WIDTH]);
+ rowMerged[CC_STAT_TOP] = MIN(rowMerged[CC_STAT_TOP], rowNext[CC_STAT_TOP]);
+ rowMerged[CC_STAT_HEIGHT] = MAX(rowMerged[CC_STAT_HEIGHT], rowNext[CC_STAT_HEIGHT]);
+ rowMerged[CC_STAT_AREA] += rowNext[CC_STAT_AREA];
+
+ sop.integrals[l].x += sopArray[nextLoc].integrals[l].x;
+ sop.integrals[l].y += sopArray[nextLoc].integrals[l].y;
+ }
+ }
+ }
+ }
+ }
};
//Find the root of the tree of node i
@@ -125,7 +192,7 @@ namespace cv{
inline static
LabelT findRoot(const LabelT *P, LabelT i){
LabelT root = i;
- while(P[root] < root){
+ while (P[root] < root){
root = P[root];
}
return root;
@@ -135,7 +202,7 @@ namespace cv{
template<typename LabelT>
inline static
void setRoot(LabelT *P, LabelT i, LabelT root){
- while(P[i] < i){
+ while (P[i] < i){
LabelT j = P[i];
P[i] = root;
i = j;
@@ -157,9 +224,9 @@ namespace cv{
inline static
LabelT set_union(LabelT *P, LabelT i, LabelT j){
LabelT root = findRoot(P, i);
- if(i != j){
+ if (i != j){
LabelT rootj = findRoot(P, j);
- if(root > rootj){
+ if (root > rootj){
root = rootj;
}
setRoot(P, j, root);
@@ -173,467 +240,869 @@ namespace cv{
inline static
LabelT flattenL(LabelT *P, LabelT length){
LabelT k = 1;
- for(LabelT i = 1; i < length; ++i){
- if(P[i] < i){
+ for (LabelT i = 1; i < length; ++i){
+ if (P[i] < i){
P[i] = P[P[i]];
- }else{
+ }
+ else{
P[i] = k; k = k + 1;
}
}
return k;
}
+ template<typename LabelT>
+ inline static
+ void flattenL(LabelT *P, const int start, const int nElem, LabelT& k){
+ for (int i = start; i < start + nElem; ++i){
+ if (P[i] < i){//node that point to root
+ P[i] = P[P[i]];
+ }
+ else{ //for root node
+ P[i] = k;
+ k = k + 1;
+ }
+ }
+ }
+
//Based on "Two Strategies to Speed up Connected Components Algorithms", the SAUF (Scan array union find) variant
- //using decision trees
- //Kesheng Wu, et al
- //Note: rows are encoded as position in the "rows" array to save lookup times
- //reference for 4-way: {{-1, 0}, {0, -1}};//b, d neighborhoods
- const int G4[2][2] = {{1, 0}, {0, -1}};//b, d neighborhoods
- //reference for 8-way: {{-1, -1}, {-1, 0}, {-1, 1}, {0, -1}};//a, b, c, d neighborhoods
- const int G8[4][2] = {{1, -1}, {1, 0}, {1, 1}, {0, -1}};//a, b, c, d neighborhoods
+ //using decision trees
+ //Kesheng Wu, et al
template<typename LabelT, typename PixelT, typename StatsOp = NoOp >
- struct LabelingWu{
- LabelT operator()(const cv::Mat &I, cv::Mat &L, int connectivity, StatsOp &sop){
- CV_Assert(L.rows == I.rows);
- CV_Assert(L.cols == I.cols);
- CV_Assert(connectivity == 8 || connectivity == 4);
- const int rows = L.rows;
- const int cols = L.cols;
- //A quick and dirty upper bound for the maximimum number of labels. The 4 comes from
- //the fact that a 3x3 block can never have more than 4 unique labels for both 4 & 8-way
- const size_t Plength = 4 * (size_t(rows + 3 - 1)/3) * (size_t(cols + 3 - 1)/3);
- LabelT *P = (LabelT *) fastMalloc(sizeof(LabelT) * Plength);
- P[0] = 0;
- LabelT lunique = 1;
- //scanning phase
- for(int r_i = 0; r_i < rows; ++r_i){
- LabelT * const Lrow = L.ptr<LabelT>(r_i);
- LabelT * const Lrow_prev = (LabelT *)(((char *)Lrow) - L.step.p[0]);
- const PixelT * const Irow = I.ptr<PixelT>(r_i);
- const PixelT * const Irow_prev = (const PixelT *)(((char *)Irow) - I.step.p[0]);
- LabelT *Lrows[2] = {
- Lrow,
- Lrow_prev
- };
- const PixelT *Irows[2] = {
- Irow,
- Irow_prev
- };
- if(connectivity == 8){
- const int a = 0;
- const int b = 1;
- const int c = 2;
- const int d = 3;
- const bool T_a_r = (r_i - G8[a][0]) >= 0;
- const bool T_b_r = (r_i - G8[b][0]) >= 0;
- const bool T_c_r = (r_i - G8[c][0]) >= 0;
- for(int c_i = 0; Irows[0] != Irow + cols; ++Irows[0], c_i++){
- if(!*Irows[0]){
- Lrow[c_i] = 0;
- continue;
+ struct LabelingWuParallel{
+
+ class FirstScan8Connectivity : public cv::ParallelLoopBody{
+ const cv::Mat& img_;
+ cv::Mat& imgLabels_;
+ LabelT *P_;
+ int *chunksSizeAndLabels_;
+
+ public:
+ FirstScan8Connectivity(const cv::Mat& img, cv::Mat& imgLabels, LabelT *P, int *chunksSizeAndLabels)
+ : img_(img), imgLabels_(imgLabels), P_(P), chunksSizeAndLabels_(chunksSizeAndLabels){}
+
+ FirstScan8Connectivity& operator=(const FirstScan8Connectivity& ) { return *this; }
+
+ void operator()(const cv::Range& range) const{
+
+ int r = range.start;
+ chunksSizeAndLabels_[r] = range.end;
+
+ LabelT label = LabelT((r + 1) / 2) * LabelT((imgLabels_.cols + 1) / 2) + 1;
+
+ const LabelT firstLabel = label;
+ const int w = img_.cols;
+ const int limitLine = r, startR = r;
+
+ // Rosenfeld Mask
+ // +-+-+-+
+ // |p|q|r|
+ // +-+-+-+
+ // |s|x|
+ // +-+-+
+ for (; r != range.end; ++r)
+ {
+ PixelT const * const img_row = img_.ptr<PixelT>(r);
+ PixelT const * const img_row_prev = (PixelT *)(((char *)img_row) - img_.step.p[0]);
+ LabelT * const imgLabels_row = imgLabels_.ptr<LabelT>(r);
+ LabelT * const imgLabels_row_prev = (LabelT *)(((char *)imgLabels_row) - imgLabels_.step.p[0]);
+ for (int c = 0; c < w; ++c) {
+
+#define condition_p c > 0 && r > limitLine && img_row_prev[c - 1] > 0
+#define condition_q r > limitLine && img_row_prev[c] > 0
+#define condition_r c < w - 1 && r > limitLine && img_row_prev[c + 1] > 0
+#define condition_s c > 0 && img_row[c - 1] > 0
+#define condition_x img_row[c] > 0
+
+ if (condition_x){
+ if (condition_q){
+ //copy q
+ imgLabels_row[c] = imgLabels_row_prev[c];
+ }
+ else{
+ //not q
+ if (condition_r){
+ if (condition_p){
+ //concavity p->x->r. Merge
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev[c - 1], imgLabels_row_prev[c + 1]);
+ }
+ else{ //not p and q
+ if (condition_s){
+ //step s->x->r. Merge
+ imgLabels_row[c] = set_union(P_, imgLabels_row[c - 1], imgLabels_row_prev[c + 1]);
+ }
+ else{ //not p, q and s
+ //copy r
+ imgLabels_row[c] = imgLabels_row_prev[c + 1];
+ }
+ }
+ }
+ else{
+ //not r and q
+ if (condition_p){
+ //copy p
+ imgLabels_row[c] = imgLabels_row_prev[c - 1];
+ }
+ else{//not r,q and p
+ if (condition_s){
+ imgLabels_row[c] = imgLabels_row[c - 1];
+ }
+ else{
+ //new label
+ imgLabels_row[c] = label;
+ P_[label] = label;
+ label = label + 1;
+ }
+ }
+ }
+ }
+ }
+ else{
+ //x is a background pixel
+ imgLabels_row[c] = 0;
+ }
}
- Irows[1] = Irow_prev + c_i;
- Lrows[0] = Lrow + c_i;
- Lrows[1] = Lrow_prev + c_i;
- const bool T_a = T_a_r && (c_i + G8[a][1]) >= 0 && *(Irows[G8[a][0]] + G8[a][1]);
- const bool T_b = T_b_r && *(Irows[G8[b][0]] + G8[b][1]);
- const bool T_c = T_c_r && (c_i + G8[c][1]) < cols && *(Irows[G8[c][0]] + G8[c][1]);
- const bool T_d = (c_i + G8[d][1]) >= 0 && *(Irows[G8[d][0]] + G8[d][1]);
-
- //decision tree
- if(T_b){
- //copy(b)
- *Lrows[0] = *(Lrows[G8[b][0]] + G8[b][1]);
- }else{//not b
- if(T_c){
- if(T_a){
- //copy(c, a)
- *Lrows[0] = set_union(P, *(Lrows[G8[c][0]] + G8[c][1]), *(Lrows[G8[a][0]] + G8[a][1]));
- }else{
- if(T_d){
- //copy(c, d)
- *Lrows[0] = set_union(P, *(Lrows[G8[c][0]] + G8[c][1]), *(Lrows[G8[d][0]] + G8[d][1]));
- }else{
- //copy(c)
- *Lrows[0] = *(Lrows[G8[c][0]] + G8[c][1]);
+ }
+ //write in the follower memory location
+ chunksSizeAndLabels_[startR + 1] = label - firstLabel;
+ }
+#undef condition_p
+#undef condition_q
+#undef condition_r
+#undef condition_s
+#undef condition_x
+ };
+
+ class FirstScan4Connectivity : public cv::ParallelLoopBody{
+ const cv::Mat& img_;
+ cv::Mat& imgLabels_;
+ LabelT *P_;
+ int *chunksSizeAndLabels_;
+
+ public:
+ FirstScan4Connectivity(const cv::Mat& img, cv::Mat& imgLabels, LabelT *P, int *chunksSizeAndLabels)
+ : img_(img), imgLabels_(imgLabels), P_(P), chunksSizeAndLabels_(chunksSizeAndLabels){}
+
+ FirstScan4Connectivity& operator=(const FirstScan4Connectivity& ) { return *this; }
+
+ void operator()(const cv::Range& range) const{
+
+ int r = range.start;
+ chunksSizeAndLabels_[r] = range.end;
+
+ LabelT label = LabelT((r * imgLabels_.cols + 1) / 2 + 1);
+
+ const LabelT firstLabel = label;
+ const int w = img_.cols;
+ const int limitLine = r, startR = r;
+
+ // Rosenfeld Mask
+ // +-+-+-+
+ // |-|q|-|
+ // +-+-+-+
+ // |s|x|
+ // +-+-+
+ for (; r != range.end; ++r){
+ PixelT const * const img_row = img_.ptr<PixelT>(r);
+ PixelT const * const img_row_prev = (PixelT *)(((char *)img_row) - img_.step.p[0]);
+ LabelT * const imgLabels_row = imgLabels_.ptr<LabelT>(r);
+ LabelT * const imgLabels_row_prev = (LabelT *)(((char *)imgLabels_row) - imgLabels_.step.p[0]);
+ for (int c = 0; c < w; ++c) {
+
+#define condition_q r > limitLine && img_row_prev[c] > 0
+#define condition_s c > 0 && img_row[c - 1] > 0
+#define condition_x img_row[c] > 0
+
+ if (condition_x){
+ if (condition_q){
+ if (condition_s){
+ //step s->x->q. Merge
+ imgLabels_row[c] = set_union(P_, imgLabels_row[c - 1], imgLabels_row_prev[c]);
+ }
+ else{
+ //copy q
+ imgLabels_row[c] = imgLabels_row_prev[c];
}
}
- }else{//not c
- if(T_a){
- //copy(a)
- *Lrows[0] = *(Lrows[G8[a][0]] + G8[a][1]);
- }else{
- if(T_d){
- //copy(d)
- *Lrows[0] = *(Lrows[G8[d][0]] + G8[d][1]);
- }else{
+ else{
+ if (condition_s){ // copy s
+ imgLabels_row[c] = imgLabels_row[c - 1];
+ }
+ else{
//new label
- *Lrows[0] = lunique;
- P[lunique] = lunique;
- lunique = lunique + 1;
+ imgLabels_row[c] = label;
+ P_[label] = label;
+ label = label + 1;
}
}
}
+ else{
+ //x is a background pixel
+ imgLabels_row[c] = 0;
+ }
+ }
+ }
+ //write in the following memory location
+ chunksSizeAndLabels_[startR + 1] = label - firstLabel;
+ }
+#undef condition_q
+#undef condition_s
+#undef condition_x
+ };
+
+ class SecondScan : public cv::ParallelLoopBody{
+ cv::Mat& imgLabels_;
+ const LabelT *P_;
+ StatsOp& sop_;
+ StatsOp *sopArray_;
+ LabelT& nLabels_;
+ public:
+ SecondScan(cv::Mat& imgLabels, const LabelT *P, StatsOp& sop, StatsOp *sopArray, LabelT& nLabels)
+ : imgLabels_(imgLabels), P_(P), sop_(sop), sopArray_(sopArray), nLabels_(nLabels){}
+
+ SecondScan& operator=(const SecondScan& ) { return *this; }
+
+ void operator()(const cv::Range& range) const{
+
+ int r = range.start;
+ const int rowBegin = r;
+ const int rowEnd = range.end;
+
+ if (rowBegin > 0){
+ sopArray_[rowBegin].initElement(nLabels_);
+ sopArray_[rowBegin].setNextLoc(rowEnd); //_nextLoc = rowEnd;
+
+ for (; r < rowEnd; ++r) {
+ LabelT * img_row_start = imgLabels_.ptr<LabelT>(r);
+ LabelT * const img_row_end = img_row_start + imgLabels_.cols;
+ for (int c = 0; img_row_start != img_row_end; ++img_row_start, ++c){
+ *img_row_start = P_[*img_row_start];
+ sopArray_[rowBegin](r, c, *img_row_start);
+ }
}
}
- }else{
- //B & D only
- const int b = 0;
- const int d = 1;
- const bool T_b_r = (r_i - G4[b][0]) >= 0;
- for(int c_i = 0; Irows[0] != Irow + cols; ++Irows[0], c_i++){
- if(!*Irows[0]){
- Lrow[c_i] = 0;
- continue;
+ else{
+ //the first thread uses sop in order to make less merges
+ sop_.setNextLoc(rowEnd);
+ for (; r < rowEnd; ++r) {
+ LabelT * img_row_start = imgLabels_.ptr<LabelT>(r);
+ LabelT * const img_row_end = img_row_start + imgLabels_.cols;
+ for (int c = 0; img_row_start != img_row_end; ++img_row_start, ++c){
+ *img_row_start = P_[*img_row_start];
+ sop_(r, c, *img_row_start);
+ }
}
- Irows[1] = Irow_prev + c_i;
- Lrows[0] = Lrow + c_i;
- Lrows[1] = Lrow_prev + c_i;
- const bool T_b = T_b_r && *(Irows[G4[b][0]] + G4[b][1]);
- const bool T_d = (c_i + G4[d][1]) >= 0 && *(Irows[G4[d][0]] + G4[d][1]);
- if(T_b){
- if(T_d){
- //copy(d, b)
- *Lrows[0] = set_union(P, *(Lrows[G4[d][0]] + G4[d][1]), *(Lrows[G4[b][0]] + G4[b][1]));
- }else{
- //copy(b)
- *Lrows[0] = *(Lrows[G4[b][0]] + G4[b][1]);
+ }
+ }
+ };
+
+ inline static
+ void mergeLabels8Connectivity(cv::Mat& imgLabels, LabelT *P, const int *chunksSizeAndLabels){
+
+ // Merge Mask
+ // +-+-+-+
+ // |p|q|r|
+ // +-+-+-+
+ // |x|
+ // +-+
+ const int w = imgLabels.cols, h = imgLabels.rows;
+
+ for (int r = chunksSizeAndLabels[0]; r < h; r = chunksSizeAndLabels[r]){
+
+ LabelT * const imgLabels_row = imgLabels.ptr<LabelT>(r);
+ LabelT * const imgLabels_row_prev = (LabelT *)(((char *)imgLabels_row) - imgLabels.step.p[0]);
+
+ for (int c = 0; c < w; ++c){
+
+#define condition_p c > 0 && imgLabels_row_prev[c - 1] > 0
+#define condition_q imgLabels_row_prev[c] > 0
+#define condition_r c < w - 1 && imgLabels_row_prev[c + 1] > 0
+#define condition_x imgLabels_row[c] > 0
+
+ if (condition_x){
+ if (condition_p){
+ //merge of two label
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev[c - 1], imgLabels_row[c]);
+ }
+ if (condition_r){
+ //merge of two label
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev[c + 1], imgLabels_row[c]);
}
- }else{
- if(T_d){
- //copy(d)
- *Lrows[0] = *(Lrows[G4[d][0]] + G4[d][1]);
- }else{
- //new label
- *Lrows[0] = lunique;
- P[lunique] = lunique;
- lunique = lunique + 1;
+ if (condition_q){
+ //merge of two label
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev[c], imgLabels_row[c]);
}
}
}
}
+#undef condition_p
+#undef condition_q
+#undef condition_r
+#undef condition_x
}
- //analysis
- LabelT nLabels = flattenL(P, lunique);
- sop.init(nLabels);
-
- for(int r_i = 0; r_i < rows; ++r_i){
- LabelT *Lrow_start = L.ptr<LabelT>(r_i);
- LabelT *Lrow_end = Lrow_start + cols;
- LabelT *Lrow = Lrow_start;
- for(int c_i = 0; Lrow != Lrow_end; ++Lrow, ++c_i){
- const LabelT l = P[*Lrow];
- *Lrow = l;
- sop(r_i, c_i, l);
+ inline static
+ void mergeLabels4Connectivity(cv::Mat& imgLabels, LabelT *P, const int *chunksSizeAndLabels){
+
+ // Merge Mask
+ // +-+-+-+
+ // |-|q|-|
+ // +-+-+-+
+ // |x|
+ // +-+
+ const int w = imgLabels.cols, h = imgLabels.rows;
+
+ for (int r = chunksSizeAndLabels[0]; r < h; r = chunksSizeAndLabels[r]){
+
+ LabelT * const imgLabels_row = imgLabels.ptr<LabelT>(r);
+ LabelT * const imgLabels_row_prev = (LabelT *)(((char *)imgLabels_row) - imgLabels.step.p[0]);
+
+ for (int c = 0; c < w; ++c){
+
+#define condition_q imgLabels_row_prev[c] > 0
+#define condition_x imgLabels_row[c] > 0
+
+ if (condition_x){
+ if (condition_q){
+ //merge of two label
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev[c], imgLabels_row[c]);
+ }
+ }
+ }
}
+#undef condition_q
+#undef condition_x
}
- sop.finish();
- fastFree(P);
+ LabelT operator()(const cv::Mat& img, cv::Mat& imgLabels, int connectivity, StatsOp& sop){
+ CV_Assert(img.rows == imgLabels.rows);
+ CV_Assert(img.cols == imgLabels.cols);
+ CV_Assert(connectivity == 8 || connectivity == 4);
- return nLabels;
- }//End function LabelingWu operator()
- };//End struct LabelingWu
+ const int nThreads = cv::getNumberOfCPUs();
+ cv::setNumThreads(nThreads);
- // Based on �Optimized Block-based Connected Components Labeling with Decision Trees�, Costantino Grana et al
- // Only for 8-connectivity
+ const int h = img.rows;
+ const int w = img.cols;
+
+ //A quick and dirty upper bound for the maximimum number of labels.
+ //Following formula comes from the fact that a 2x2 block in 4-way connectivity
+ //labeling can never have more than 2 new labels and 1 label for background.
+ //Worst case image example pattern:
+ //1 0 1 0 1...
+ //0 1 0 1 0...
+ //1 0 1 0 1...
+ //............
+ //Obviously, 4-way connectivity upper bound is also good for 8-way connectivity labeling
+ const size_t Plength = (size_t(h) * size_t(w) + 1) / 2 + 1;
+
+ //Array used to store info and labeled pixel by each thread.
+ //Different threads affect different memory location of chunksSizeAndLabels
+ int *chunksSizeAndLabels = (int *)cv::fastMalloc(h * sizeof(int));
+
+ //Tree of labels
+ LabelT *P = (LabelT *)cv::fastMalloc(Plength * sizeof(LabelT));
+ //First label is for background
+ P[0] = 0;
+
+ cv::Range range(0, h);
+ LabelT nLabels = 1;
+
+ if (connectivity == 8){
+ //First scan, each thread works with chunk of img.rows/nThreads rows
+ //e.g. 300 rows, 4 threads -> each chunks is composed of 75 rows
+ cv::parallel_for_(range, FirstScan8Connectivity(img, imgLabels, P, chunksSizeAndLabels), nThreads);
+
+ //merge labels of different chunks
+ mergeLabels8Connectivity(imgLabels, P, chunksSizeAndLabels);
+
+ for (int i = 0; i < h; i = chunksSizeAndLabels[i]){
+ flattenL(P, int((i + 1) / 2) * int((w + 1) / 2) + 1, chunksSizeAndLabels[i + 1], nLabels);
+ }
+ }
+ else{
+ //First scan, each thread works with chunk of img.rows/nThreads rows
+ //e.g. 300 rows, 4 threads -> each chunks is composed of 75 rows
+ cv::parallel_for_(range, FirstScan4Connectivity(img, imgLabels, P, chunksSizeAndLabels), nThreads);
+
+ //merge labels of different chunks
+ mergeLabels4Connectivity(imgLabels, P, chunksSizeAndLabels);
+
+ for (int i = 0; i < h; i = chunksSizeAndLabels[i]){
+ flattenL(P, int(i * w + 1) / 2 + 1, chunksSizeAndLabels[i + 1], nLabels);
+ }
+ }
+
+ //Array for statistics dataof threads
+ StatsOp *sopArray = new StatsOp[h];
+
+ sop.init(nLabels);
+ //Second scan
+ cv::parallel_for_(range, SecondScan(imgLabels, P, sop, sopArray, nLabels), nThreads);
+ StatsOp::mergeStats(imgLabels, sopArray, sop, nLabels);
+ sop.finish();
+
+ delete[] sopArray;
+ cv::fastFree(chunksSizeAndLabels);
+ cv::fastFree(P);
+ return nLabels;
+ }
+ };//End struct LabelingWuParallel
+
+
+ //Based on "Two Strategies to Speed up Connected Components Algorithms", the SAUF (Scan array union find) variant
+ //using decision trees
+ //Kesheng Wu, et al
template<typename LabelT, typename PixelT, typename StatsOp = NoOp >
- struct LabelingGrana{
- LabelT operator()(const cv::Mat &img, cv::Mat &imgLabels, int connectivity, StatsOp &sop){
- CV_Assert(img.rows == imgLabels.rows);
- CV_Assert(img.cols == imgLabels.cols);
- CV_Assert(connectivity == 8 || connectivity == 4);
+ struct LabelingWu{
+ LabelT operator()(const cv::Mat& img, cv::Mat& imgLabels, int connectivity, StatsOp& sop){
+ CV_Assert(imgLabels.rows == img.rows);
+ CV_Assert(imgLabels.cols == img.cols);
+ CV_Assert(connectivity == 8 || connectivity == 4);
- const int h = img.rows;
- const int w = img.cols;
-
- //A quick and dirty upper bound for the maximimum number of labels.
- const size_t Plength = img.rows*img.cols / 4;
- LabelT *P = (LabelT *)fastMalloc(sizeof(LabelT)* Plength);
- P[0] = 0;
- LabelT lunique = 1;
-
- // First scan
- for (int r = 0; r<h; r += 2) {
- // Get rows pointer
- const PixelT* const img_row = img.ptr<PixelT>(r);
- const PixelT* const img_row_prev = (PixelT *)(((char *)img_row) - img.step.p[0]);
- const PixelT* const img_row_prev_prev = (PixelT *)(((char *)img_row_prev) - img.step.p[0]);
- const PixelT* const img_row_fol = (PixelT *)(((char *)img_row) + img.step.p[0]);
- LabelT* const imgLabels_row = imgLabels.ptr<LabelT>(r);
- LabelT* const imgLabels_row_prev_prev = (LabelT *)(((char *)imgLabels_row) - imgLabels.step.p[0] - imgLabels.step.p[0]);
- for (int c = 0; c < w; c += 2) {
-
- // We work with 2x2 blocks
- // +-+-+-+
- // |P|Q|R|
- // +-+-+-+
- // |S|X|
- // +-+-+
+ const int h = img.rows;
+ const int w = img.cols;
- // The pixels are named as follows
- // +---+---+---+
- // |a b|c d|e f|
- // |g h|i j|k l|
- // +---+---+---+
- // |m n|o p|
- // |q r|s t|
- // +---+---+
-
- // Pixels a, f, l, q are not needed, since we need to understand the
- // the connectivity between these blocks and those pixels only metter
- // when considering the outer connectivities
-
- // A bunch of defines used to check if the pixels are foreground,
- // without going outside the image limits.
- #define condition_b c-1>=0 && r-2>=0 && img_row_prev_prev[c-1]>0
- #define condition_c r-2>=0 && img_row_prev_prev[c]>0
- #define condition_d c+1<w && r-2>=0 && img_row_prev_prev[c+1]>0
- #define condition_e c+2<w && r-2>=0 && img_row_prev_prev[c+2]>0
-
- #define condition_g c-2>=0 && r-1>=0 && img_row_prev[c-2]>0
- #define condition_h c-1>=0 && r-1>=0 && img_row_prev[c-1]>0
- #define condition_i r-1>=0 && img_row_prev[c]>0
- #define condition_j c+1<w && r-1>=0 && img_row_prev[c+1]>0
- #define condition_k c+2<w && r-1>=0 && img_row_prev[c+2]>0
-
- #define condition_m c-2>=0 && img_row[c-2]>0
- #define condition_n c-1>=0 && img_row[c-1]>0
- #define condition_o img_row[c]>0
- #define condition_p c+1<w && img_row[c+1]>0
-
- #define condition_r c-1>=0 && r+1<h && img_row_fol[c-1]>0
- #define condition_s r+1<h && img_row_fol[c]>0
- #define condition_t c+1<w && r+1<h && img_row_fol[c+1]>0
-
- // This is a decision tree which allows to choose which action to
- // perform, checking as few conditions as possible.
- // Actions: the blocks label are provisionally stored in the top left
- // pixel of the block in the labels image
-
- if (condition_o) {
- if (condition_n) {
- if (condition_j) {
- if (condition_i) {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
+ //A quick and dirty upper bound for the maximimum number of labels.
+ //Following formula comes from the fact that a 2x2 block in 4-way connectivity
+ //labeling can never have more than 2 new labels and 1 label for background.
+ //Worst case image example pattern:
+ //1 0 1 0 1...
+ //0 1 0 1 0...
+ //1 0 1 0 1...
+ //............
+ //Obviously, 4-way connectivity upper bound is also good for 8-way connectivity labeling
+ const size_t Plength = (size_t(h) * size_t(w) + 1) / 2 + 1;
+ //array P for equivalences resolution
+ LabelT *P = (LabelT *)fastMalloc(sizeof(LabelT) *Plength);
+ //first label is for background pixels
+ P[0] = 0;
+ LabelT lunique = 1;
+
+ if (connectivity == 8){
+ for (int r = 0; r < h; ++r){
+ // Get row pointers
+ PixelT const * const img_row = img.ptr<PixelT>(r);
+ PixelT const * const img_row_prev = (PixelT *)(((char *)img_row) - img.step.p[0]);
+ LabelT * const imgLabels_row = imgLabels.ptr<LabelT>(r);
+ LabelT * const imgLabels_row_prev = (LabelT *)(((char *)imgLabels_row) - imgLabels.step.p[0]);
+
+ for (int c = 0; c < w; ++c){
+
+#define condition_p c>0 && r>0 && img_row_prev[c - 1]>0
+#define condition_q r>0 && img_row_prev[c]>0
+#define condition_r c < w - 1 && r > 0 && img_row_prev[c + 1] > 0
+#define condition_s c > 0 && img_row[c - 1] > 0
+#define condition_x img_row[c] > 0
+
+ if (condition_x){
+ if (condition_q){
+ //x <- q
+ imgLabels_row[c] = imgLabels_row_prev[c];
}
- else {
- if (condition_c) {
- if (condition_h) {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
+ else{
+ // q = 0
+ if (condition_r){
+ if (condition_p){
+ // x <- merge(p,r)
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev[c - 1], imgLabels_row_prev[c + 1]);
}
- else {
- if (condition_g) {
- if (condition_b) {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
- }
- else {
- //Action_11: Merge labels of block Q and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
- continue;
- }
+ else{
+ // p = q = 0
+ if (condition_s){
+ // x <- merge(s,r)
+ imgLabels_row[c] = set_union(P, imgLabels_row[c - 1], imgLabels_row_prev[c + 1]);
}
- else {
- //Action_11: Merge labels of block Q and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
- continue;
+ else{
+ // p = q = s = 0
+ // x <- r
+ imgLabels_row[c] = imgLabels_row_prev[c + 1];
}
}
}
- else {
- //Action_11: Merge labels of block Q and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
- continue;
- }
- }
- }
- else {
- if (condition_p) {
- if (condition_k) {
- if (condition_d) {
- if (condition_i) {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
+ else{
+ // r = q = 0
+ if (condition_p){
+ // x <- p
+ imgLabels_row[c] = imgLabels_row_prev[c - 1];
+ }
+ else{
+ // r = q = p = 0
+ if (condition_s){
+ imgLabels_row[c] = imgLabels_row[c - 1];
}
- else {
- if (condition_c) {
- if (condition_h) {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
- }
- else {
- if (condition_g) {
- if (condition_b) {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
- }
- else {
- //Action_12: Merge labels of block R and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
- continue;
- }
- }
- else {
- //Action_12: Merge labels of block R and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
- continue;
- }
- }
- }
- else {
- //Action_12: Merge labels of block R and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
- continue;
- }
+ else{
+ //new label
+ imgLabels_row[c] = lunique;
+ P[lunique] = lunique;
+ lunique = lunique + 1;
}
}
- else {
- //Action_12: Merge labels of block R and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
- continue;
- }
}
- else {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
- }
- }
- else {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
}
}
- }
- else {
- if (condition_r) {
- if (condition_j) {
- if (condition_m) {
- if (condition_h) {
- if (condition_i) {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
- }
- else {
- if (condition_c) {
+ else{
+ //x is a background pixel
+ imgLabels_row[c] = 0;
+ }
+ }
+ }
+#undef condition_p
+#undef condition_q
+#undef condition_r
+#undef condition_s
+#undef condition_x
+ }
+ else{
+ for (int r = 0; r < h; ++r){
+ PixelT const * const img_row = img.ptr<PixelT>(r);
+ PixelT const * const img_row_prev = (PixelT *)(((char *)img_row) - img.step.p[0]);
+ LabelT * const imgLabels_row = imgLabels.ptr<LabelT>(r);
+ LabelT * const imgLabels_row_prev = (LabelT *)(((char *)imgLabels_row) - imgLabels.step.p[0]);
+ for (int c = 0; c < w; ++c) {
+
+#define condition_q r > 0 && img_row_prev[c] > 0
+#define condition_s c > 0 && img_row[c - 1] > 0
+#define condition_x img_row[c] > 0
+
+ if (condition_x){
+ if (condition_q){
+ if (condition_s){
+ //Merge s->x->q
+ imgLabels_row[c] = set_union(P, imgLabels_row[c - 1], imgLabels_row_prev[c]);
+ }
+ else{
+ //copy q
+ imgLabels_row[c] = imgLabels_row_prev[c];
+ }
+ }
+ else{
+ if (condition_s){
+ // copy s
+ imgLabels_row[c] = imgLabels_row[c - 1];
+ }
+ else{
+ //new label
+ imgLabels_row[c] = lunique;
+ P[lunique] = lunique;
+ lunique = lunique + 1;
+ }
+ }
+ }
+ else{
+ //x is a background pixel
+ imgLabels_row[c] = 0;
+ }
+ }
+ }
+#undef condition_q
+#undef condition_s
+#undef condition_x
+ }
+
+ //analysis
+ LabelT nLabels = flattenL(P, lunique);
+ sop.init(nLabels);
+
+ for (int r = 0; r < h; ++r) {
+ LabelT * img_row_start = imgLabels.ptr<LabelT>(r);
+ LabelT * const img_row_end = img_row_start + w;
+ for (int c = 0; img_row_start != img_row_end; ++img_row_start, ++c){
+ *img_row_start = P[*img_row_start];
+ sop(r, c, *img_row_start);
+ }
+ }
+
+ sop.finish();
+ fastFree(P);
+
+ return nLabels;
+ }//End function LabelingWu operator()
+ };//End struct LabelingWu
+
+
+ // Based on "Optimized Block-based Connected Components Labeling with Decision Trees", Costantino Grana et al
+ // Only for 8-connectivity
+ template<typename LabelT, typename PixelT, typename StatsOp = NoOp >
+ struct LabelingGranaParallel{
+
+ class FirstScan : public cv::ParallelLoopBody{
+ private:
+ const cv::Mat& img_;
+ cv::Mat& imgLabels_;
+ LabelT *P_;
+ int *chunksSizeAndLabels_;
+
+ public:
+ FirstScan(const cv::Mat& img, cv::Mat& imgLabels, LabelT *P, int *chunksSizeAndLabels)
+ : img_(img), imgLabels_(imgLabels), P_(P), chunksSizeAndLabels_(chunksSizeAndLabels){}
+
+ FirstScan& operator=(const FirstScan&) { return *this; }
+
+ void operator()(const cv::Range& range) const{
+
+ int r = range.start;
+ r += (r % 2);
+
+ chunksSizeAndLabels_[r] = range.end + (range.end % 2);
+
+ LabelT label = LabelT((r + 1) / 2) * LabelT((imgLabels_.cols + 1) / 2) + 1;
+
+ const LabelT firstLabel = label;
+ const int h = img_.rows, w = img_.cols;
+ const int limitLine = r + 1, startR = r;
+
+ for (; r < range.end; r += 2){
+ // Get rows pointer
+ const PixelT * const img_row = img_.ptr<uchar>(r);
+ const PixelT * const img_row_prev = (PixelT *)(((char *)img_row) - img_.step.p[0]);
+ const PixelT * const img_row_prev_prev = (PixelT *)(((char *)img_row_prev) - img_.step.p[0]);
+ const PixelT * const img_row_fol = (PixelT *)(((char *)img_row) + img_.step.p[0]);
+ LabelT * const imgLabels_row = imgLabels_.ptr<LabelT>(r);
+ LabelT * const imgLabels_row_prev_prev = (LabelT *)(((char *)imgLabels_row) - imgLabels_.step.p[0] - imgLabels_.step.p[0]);
+ for (int c = 0; c < w; c += 2) {
+
+ // We work with 2x2 blocks
+ // +-+-+-+
+ // |P|Q|R|
+ // +-+-+-+
+ // |S|X|
+ // +-+-+
+
+ // The pixels are named as follows
+ // +---+---+---+
+ // |a b|c d|e f|
+ // |g h|i j|k l|
+ // +---+---+---+
+ // |m n|o p|
+ // |q r|s t|
+ // +---+---+
+
+ // Pixels a, f, l, q are not needed, since we need to understand the
+ // the connectivity between these blocks and those pixels only metter
+ // when considering the outer connectivities
+
+ // A bunch of defines used to check if the pixels are foreground,
+ // without going outside the image limits.
+
+#define condition_b c-1>=0 && r > limitLine && img_row_prev_prev[c-1]>0
+#define condition_c r > limitLine && img_row_prev_prev[c]>0
+#define condition_d c+1<w && r > limitLine && img_row_prev_prev[c+1]>0
+#define condition_e c+2<w && r > limitLine && img_row_prev_prev[c+2]>0
+
+#define condition_g c-2>=0 && r > limitLine - 1 && img_row_prev[c-2]>0
+#define condition_h c-1>=0 && r > limitLine - 1 && img_row_prev[c-1]>0
+#define condition_i r > limitLine - 1 && img_row_prev[c]>0
+#define condition_j c+1<w && r > limitLine - 1 && img_row_prev[c+1]>0
+#define condition_k c+2<w && r > limitLine - 1 && img_row_prev[c+2]>0
+
+#define condition_m c-2>=0 && img_row[c-2]>0
+#define condition_n c-1>=0 && img_row[c-1]>0
+#define condition_o img_row[c]>0
+#define condition_p c+1<w && img_row[c+1]>0
+
+#define condition_r c-1>=0 && r+1<h && img_row_fol[c-1]>0
+#define condition_s r+1<h && img_row_fol[c]>0
+#define condition_t c+1<w && r+1<h && img_row_fol[c+1]>0
+
+ // This is a decision tree which allows to choose which action to
+ // perform, checking as few conditions as possible.
+ // Actions are available after the tree.
+
+ if (condition_o) {
+ if (condition_n) {
+ if (condition_j) {
+ if (condition_i) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_c) {
+ if (condition_h) {
//Action_6: Assign label of block S
imgLabels_row[c] = imgLabels_row[c - 2];
continue;
}
else {
- //Action_11: Merge labels of block Q and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
- continue;
- }
- }
- }
- else {
- if (condition_g) {
- if (condition_b) {
- if (condition_i) {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
- }
- else {
- if (condition_c) {
+ if (condition_g) {
+ if (condition_b) {
//Action_6: Assign label of block S
imgLabels_row[c] = imgLabels_row[c - 2];
continue;
}
else {
//Action_11: Merge labels of block Q and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
continue;
}
}
- }
- else {
- //Action_11: Merge labels of block Q and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
- continue;
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
}
}
else {
//Action_11: Merge labels of block Q and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
continue;
}
}
}
else {
- if (condition_i) {
- //Action_11: Merge labels of block Q and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
- continue;
- }
- else {
- if (condition_h) {
- if (condition_c) {
- //Action_11: Merge labels of block Q and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
- continue;
+ if (condition_p) {
+ if (condition_k) {
+ if (condition_d) {
+ if (condition_i) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_c) {
+ if (condition_h) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_g) {
+ if (condition_b) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
}
else {
- //Action_14: Merge labels of block P, Q and S
- imgLabels_row[c] = set_union(P, set_union(P, imgLabels_row_prev_prev[c - 2], imgLabels_row_prev_prev[c]), imgLabels_row[c - 2]);
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
continue;
}
}
else {
- //Action_11: Merge labels of block Q and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
continue;
}
}
+ else {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
}
}
else {
- if (condition_p) {
- if (condition_k) {
+ if (condition_r) {
+ if (condition_j) {
if (condition_m) {
if (condition_h) {
- if (condition_d) {
- if (condition_i) {
+ if (condition_i) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_c) {
//Action_6: Assign label of block S
imgLabels_row[c] = imgLabels_row[c - 2];
continue;
}
else {
- if (condition_c) {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ if (condition_g) {
+ if (condition_b) {
+ if (condition_i) {
//Action_6: Assign label of block S
imgLabels_row[c] = imgLabels_row[c - 2];
continue;
}
else {
- //Action_12: Merge labels of block R and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
- continue;
+ if (condition_c) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
}
}
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
}
else {
- //Action_12: Merge labels of block R and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
continue;
}
}
+ }
+ else {
+ if (condition_i) {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
else {
- if (condition_d) {
- if (condition_g) {
- if (condition_b) {
+ if (condition_h) {
+ if (condition_c) {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ else {
+ //Action_14: Merge labels of block P_, Q and S
+ imgLabels_row[c] = set_union(P_, set_union(P_, imgLabels_row_prev_prev[c - 2], imgLabels_row_prev_prev[c]), imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ }
+ else {
+ if (condition_p) {
+ if (condition_k) {
+ if (condition_m) {
+ if (condition_h) {
+ if (condition_d) {
if (condition_i) {
//Action_6: Assign label of block S
imgLabels_row[c] = imgLabels_row[c - 2];
@@ -647,40 +1116,1870 @@ namespace cv{
}
else {
//Action_12: Merge labels of block R and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
continue;
}
}
}
else {
//Action_12: Merge labels of block R and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
continue;
}
}
else {
- //Action_12: Merge labels of block R and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
- continue;
- }
- }
- else {
- if (condition_i) {
- if (condition_g) {
- if (condition_b) {
- //Action_12: Merge labels of block R and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
- continue;
- }
- else {
- //Action_16: labels of block Q, R and S
- imgLabels_row[c] = set_union(P, set_union(P, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]), imgLabels_row[c - 2]);
- continue;
- }
- }
- else {
+ if (condition_d) {
+ if (condition_g) {
+ if (condition_b) {
+ if (condition_i) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_c) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ if (condition_i) {
+ if (condition_g) {
+ if (condition_b) {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ else {
+ //Action_16: labels of block Q, R and S
+ imgLabels_row[c] = set_union(P_, set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]), imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_16: labels of block Q, R and S
+ imgLabels_row[c] = set_union(P_, set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]), imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ }
+ else {
+ if (condition_i) {
+ if (condition_d) {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ else {
//Action_16: labels of block Q, R and S
- imgLabels_row[c] = set_union(P, set_union(P, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]), imgLabels_row[c - 2]);
+ imgLabels_row[c] = set_union(P_, set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]), imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ if (condition_h) {
+ if (condition_d) {
+ if (condition_c) {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ else {
+ //Action_15: Merge labels of block P_, R and S
+ imgLabels_row[c] = set_union(P_, set_union(P_, imgLabels_row_prev_prev[c - 2], imgLabels_row_prev_prev[c + 2]), imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_15: Merge labels of block P_, R and S
+ imgLabels_row[c] = set_union(P_, set_union(P_, imgLabels_row_prev_prev[c - 2], imgLabels_row_prev_prev[c + 2]), imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ }
+ else {
+ if (condition_h) {
+ if (condition_m) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ // ACTION_9 Merge labels of block P_ and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c - 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ if (condition_i) {
+ if (condition_m) {
+ if (condition_g) {
+ if (condition_b) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ }
+ }
+ }
+ else {
+ if (condition_h) {
+ if (condition_m) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ // ACTION_9 Merge labels of block P_ and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c - 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ if (condition_i) {
+ if (condition_m) {
+ if (condition_g) {
+ if (condition_b) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ }
+ }
+ }
+ }
+ else {
+ if (condition_j) {
+ if (condition_i) {
+ //Action_4: Assign label of block Q
+ imgLabels_row[c] = imgLabels_row_prev_prev[c];
+ continue;
+ }
+ else {
+ if (condition_h) {
+ if (condition_c) {
+ //Action_4: Assign label of block Q
+ imgLabels_row[c] = imgLabels_row_prev_prev[c];
+ continue;
+ }
+ else {
+ //Action_7: Merge labels of block P_ and Q
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c - 2], imgLabels_row_prev_prev[c]);
+ continue;
+ }
+ }
+ else {
+ //Action_4: Assign label of block Q
+ imgLabels_row[c] = imgLabels_row_prev_prev[c];
+ continue;
+ }
+ }
+ }
+ else {
+ if (condition_p) {
+ if (condition_k) {
+ if (condition_i) {
+ if (condition_d) {
+ //Action_5: Assign label of block R
+ imgLabels_row[c] = imgLabels_row_prev_prev[c + 2];
+ continue;
+ }
+ else {
+ // ACTION_10 Merge labels of block Q and R
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]);
+ continue;
+ }
+ }
+ else {
+ if (condition_h) {
+ if (condition_d) {
+ if (condition_c) {
+ //Action_5: Assign label of block R
+ imgLabels_row[c] = imgLabels_row_prev_prev[c + 2];
+ continue;
+ }
+ else {
+ //Action_8: Merge labels of block P_ and R
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c - 2], imgLabels_row_prev_prev[c + 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_8: Merge labels of block P_ and R
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c - 2], imgLabels_row_prev_prev[c + 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_5: Assign label of block R
+ imgLabels_row[c] = imgLabels_row_prev_prev[c + 2];
+ continue;
+ }
+ }
+ }
+ else {
+ if (condition_i) {
+ //Action_4: Assign label of block Q
+ imgLabels_row[c] = imgLabels_row_prev_prev[c];
+ continue;
+ }
+ else {
+ if (condition_h) {
+ //Action_3: Assign label of block P_
+ imgLabels_row[c] = imgLabels_row_prev_prev[c - 2];
+ continue;
+ }
+ else {
+ //Action_2: New label (the block has foreground pixels and is not connected to anything else)
+ imgLabels_row[c] = label;
+ P_[label] = label;
+ label = label + 1;
+ continue;
+ }
+ }
+ }
+ }
+ else {
+ if (condition_i) {
+ //Action_4: Assign label of block Q
+ imgLabels_row[c] = imgLabels_row_prev_prev[c];
+ continue;
+ }
+ else {
+ if (condition_h) {
+ //Action_3: Assign label of block P_
+ imgLabels_row[c] = imgLabels_row_prev_prev[c - 2];
+ continue;
+ }
+ else {
+ //Action_2: New label (the block has foreground pixels and is not connected to anything else)
+ imgLabels_row[c] = label;
+ P_[label] = label;
+ label = label + 1;
+ continue;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else {
+ if (condition_s) {
+ if (condition_p) {
+ if (condition_n) {
+ if (condition_j) {
+ if (condition_i) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_c) {
+ if (condition_h) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_g) {
+ if (condition_b) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ if (condition_k) {
+ if (condition_d) {
+ if (condition_i) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_c) {
+ if (condition_h) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_g) {
+ if (condition_b) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ }
+ }
+ else {
+ if (condition_r) {
+ if (condition_j) {
+ if (condition_m) {
+ if (condition_h) {
+ if (condition_i) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_c) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ if (condition_g) {
+ if (condition_b) {
+ if (condition_i) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_c) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ if (condition_k) {
+ if (condition_d) {
+ if (condition_m) {
+ if (condition_h) {
+ if (condition_i) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_c) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ if (condition_g) {
+ if (condition_b) {
+ if (condition_i) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_c) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ if (condition_i) {
+ if (condition_m) {
+ if (condition_h) {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ else {
+ if (condition_g) {
+ if (condition_b) {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ else {
+ //Action_16: labels of block Q, R and S
+ imgLabels_row[c] = set_union(P_, set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]), imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_16: labels of block Q, R and S
+ imgLabels_row[c] = set_union(P_, set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]), imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ //Action_16: labels of block Q, R and S
+ imgLabels_row[c] = set_union(P_, set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]), imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ if (condition_i) {
+ if (condition_m) {
+ if (condition_h) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_g) {
+ if (condition_b) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ }
+ }
+ }
+ else {
+ if (condition_j) {
+ //Action_4: Assign label of block Q
+ imgLabels_row[c] = imgLabels_row_prev_prev[c];
+ continue;
+ }
+ else {
+ if (condition_k) {
+ if (condition_i) {
+ if (condition_d) {
+ //Action_5: Assign label of block R
+ imgLabels_row[c] = imgLabels_row_prev_prev[c + 2];
+ continue;
+ }
+ else {
+ // ACTION_10 Merge labels of block Q and R
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_5: Assign label of block R
+ imgLabels_row[c] = imgLabels_row_prev_prev[c + 2];
+ continue;
+ }
+ }
+ else {
+ if (condition_i) {
+ //Action_4: Assign label of block Q
+ imgLabels_row[c] = imgLabels_row_prev_prev[c];
+ continue;
+ }
+ else {
+ //Action_2: New label (the block has foreground pixels and is not connected to anything else)
+ imgLabels_row[c] = label;
+ P_[label] = label;
+ label = label + 1;
+ continue;
+ }
+ }
+ }
+ }
+ }
+ }
+ else {
+ if (condition_r) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_n) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ //Action_2: New label (the block has foreground pixels and is not connected to anything else)
+ imgLabels_row[c] = label;
+ P_[label] = label;
+ label = label + 1;
+ continue;
+ }
+ }
+ }
+ }
+ else {
+ if (condition_p) {
+ if (condition_j) {
+ //Action_4: Assign label of block Q
+ imgLabels_row[c] = imgLabels_row_prev_prev[c];
+ continue;
+ }
+ else {
+ if (condition_k) {
+ if (condition_i) {
+ if (condition_d) {
+ //Action_5: Assign label of block R
+ imgLabels_row[c] = imgLabels_row_prev_prev[c + 2];
+ continue;
+ }
+ else {
+ // ACTION_10 Merge labels of block Q and R
+ imgLabels_row[c] = set_union(P_, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_5: Assign label of block R
+ imgLabels_row[c] = imgLabels_row_prev_prev[c + 2];
+ continue;
+ }
+ }
+ else {
+ if (condition_i) {
+ //Action_4: Assign label of block Q
+ imgLabels_row[c] = imgLabels_row_prev_prev[c];
+ continue;
+ }
+ else {
+ //Action_2: New label (the block has foreground pixels and is not connected to anything else)
+ imgLabels_row[c] = label;
+ P_[label] = label;
+ label = label + 1;
+ continue;
+ }
+ }
+ }
+ }
+ else {
+ if (condition_t) {
+ //Action_2: New label (the block has foreground pixels and is not connected to anything else)
+ imgLabels_row[c] = label;
+ P_[label] = label;
+ label = label + 1;
+ continue;
+ }
+ else {
+ // Action_1: No action (the block has no foreground pixels)
+ imgLabels_row[c] = 0;
+ continue;
+ }
+ }
+ }
+ }
+ }
+ }
+ //write in the follower memory location
+ chunksSizeAndLabels_[startR + 1] = label - firstLabel;
+ }
+#undef condition_k
+#undef condition_j
+#undef condition_i
+#undef condition_h
+#undef condition_g
+#undef condition_e
+#undef condition_d
+#undef condition_c
+#undef condition_b
+ };
+
+ class SecondScan : public cv::ParallelLoopBody{
+ private:
+ const cv::Mat& img_;
+ cv::Mat& imgLabels_;
+ LabelT *P_;
+ StatsOp& sop_;
+ StatsOp *sopArray_;
+ LabelT& nLabels_;
+
+ public:
+ SecondScan(const cv::Mat& img, cv::Mat& imgLabels, LabelT *P, StatsOp& sop, StatsOp *sopArray, LabelT& nLabels)
+ : img_(img), imgLabels_(imgLabels), P_(P), sop_(sop), sopArray_(sopArray), nLabels_(nLabels){}
+
+ SecondScan& operator=(const SecondScan& ) { return *this; }
+
+ void operator()(const cv::Range& range) const{
+
+ int r = range.start;
+ r += (r % 2);
+ const int rowBegin = r;
+ const int rowEnd = range.end + range.end % 2;
+
+ if (rowBegin > 0){
+ sopArray_[rowBegin].initElement(nLabels_);
+ sopArray_[rowBegin].setNextLoc(rowEnd); //_nextLoc = rowEnd;
+
+ if (imgLabels_.rows& 1){
+ if (imgLabels_.cols& 1){
+ //Case 1: both rows and cols odd
+ for (; r < rowEnd; r += 2){
+ // Get rows pointer
+ const PixelT * const img_row = img_.ptr<PixelT>(r);
+ const PixelT * const img_row_fol = (PixelT *)(((char *)img_row) + img_.step.p[0]);
+
+ LabelT * const imgLabels_row = imgLabels_.ptr<LabelT>(r);
+ LabelT * const imgLabels_row_fol = (LabelT *)(((char *)imgLabels_row) + imgLabels_.step.p[0]);
+ // Get rows pointer
+ for (int c = 0; c < imgLabels_.cols; c += 2) {
+ LabelT iLabel = imgLabels_row[c];
+ if (iLabel > 0) {
+ iLabel = P_[iLabel];
+ if (img_row[c] > 0){
+ imgLabels_row[c] = iLabel;
+ sopArray_[rowBegin](r, c, iLabel);
+ }
+ else{
+ imgLabels_row[c] = 0;
+ sopArray_[rowBegin](r, c, 0);
+ }
+ if (c + 1 < imgLabels_.cols) {
+ if (img_row[c + 1] > 0){
+ imgLabels_row[c + 1] = iLabel;
+ sopArray_[rowBegin](r, c + 1, iLabel);
+ }
+ else{
+ imgLabels_row[c + 1] = 0;
+ sopArray_[rowBegin](r, c + 1, 0);
+ }
+ if (r + 1 < imgLabels_.rows) {
+ if (img_row_fol[c] > 0){
+ imgLabels_row_fol[c] = iLabel;
+ sopArray_[rowBegin](r + 1, c, iLabel);
+ }
+ else{
+ imgLabels_row_fol[c] = 0;
+ sopArray_[rowBegin](r + 1, c, 0);
+ }
+ if (img_row_fol[c + 1] > 0){
+ imgLabels_row_fol[c + 1] = iLabel;
+ sopArray_[rowBegin](r + 1, c + 1, iLabel);
+ }
+ else{
+ imgLabels_row_fol[c + 1] = 0;
+ sopArray_[rowBegin](r + 1, c + 1, 0);
+ }
+ }
+ }
+ else if (r + 1 < imgLabels_.rows) {
+ if (img_row_fol[c] > 0){
+ imgLabels_row_fol[c] = iLabel;
+ sopArray_[rowBegin](r + 1, c, iLabel);
+ }
+ else{
+ imgLabels_row_fol[c] = 0;
+ sopArray_[rowBegin](r + 1, c, 0);
+ }
+ }
+ }
+ else {
+ imgLabels_row[c] = 0;
+ sopArray_[rowBegin](r, c, 0);
+ if (c + 1 < imgLabels_.cols) {
+ imgLabels_row[c + 1] = 0;
+ sopArray_[rowBegin](r, c + 1, 0);
+ if (r + 1 < imgLabels_.rows) {
+ imgLabels_row_fol[c] = 0;
+ imgLabels_row_fol[c + 1] = 0;
+ sopArray_[rowBegin](r + 1, c, 0);
+ sopArray_[rowBegin](r + 1, c + 1, 0);
+ }
+ }
+ else if (r + 1 < imgLabels_.rows) {
+ imgLabels_row_fol[c] = 0;
+ sopArray_[rowBegin](r + 1, c, 0);
+ }
+ }
+ }
+ }
+ }//END Case 1
+ else{
+ //Case 2: only rows odd
+ for (; r < rowEnd; r += 2){
+ // Get rows pointer
+ const PixelT * const img_row = img_.ptr<PixelT>(r);
+ const PixelT * const img_row_fol = (PixelT *)(((char *)img_row) + img_.step.p[0]);
+ LabelT * const imgLabels_row = imgLabels_.ptr<LabelT>(r);
+ LabelT * const imgLabels_row_fol = (LabelT *)(((char *)imgLabels_row) + imgLabels_.step.p[0]);
+ // Get rows pointer
+ for (int c = 0; c < imgLabels_.cols; c += 2) {
+ LabelT iLabel = imgLabels_row[c];
+ if (iLabel > 0) {
+ iLabel = P_[iLabel];
+ if (img_row[c] > 0){
+ imgLabels_row[c] = iLabel;
+ sopArray_[rowBegin](r, c, iLabel);
+ }
+ else{
+ imgLabels_row[c] = 0;
+ sopArray_[rowBegin](r, c, 0);
+ }
+ if (img_row[c + 1] > 0){
+ imgLabels_row[c + 1] = iLabel;
+ sopArray_[rowBegin](r, c + 1, iLabel);
+ }
+ else{
+ imgLabels_row[c + 1] = 0;
+ sopArray_[rowBegin](r, c + 1, 0);
+ }
+ if (r + 1 < imgLabels_.rows) {
+ if (img_row_fol[c] > 0){
+ imgLabels_row_fol[c] = iLabel;
+ sopArray_[rowBegin](r + 1, c, iLabel);
+ }
+ else{
+ imgLabels_row_fol[c] = 0;
+ sopArray_[rowBegin](r + 1, c, 0);
+ }
+ if (img_row_fol[c + 1] > 0){
+ imgLabels_row_fol[c + 1] = iLabel;
+ sopArray_[rowBegin](r + 1, c + 1, iLabel);
+ }
+ else{
+ imgLabels_row_fol[c + 1] = 0;
+ sopArray_[rowBegin](r + 1, c + 1, 0);
+ }
+ }
+ }
+ else {
+ imgLabels_row[c] = 0;
+ imgLabels_row[c + 1] = 0;
+ sopArray_[rowBegin](r, c, 0);
+ sopArray_[rowBegin](r, c + 1, 0);
+ if (r + 1 < imgLabels_.rows) {
+ imgLabels_row_fol[c] = 0;
+ imgLabels_row_fol[c + 1] = 0;
+ sopArray_[rowBegin](r + 1, c, 0);
+ sopArray_[rowBegin](r + 1, c + 1, 0);
+ }
+ }
+ }
+ }
+ }// END Case 2
+ }
+ else{
+ if (imgLabels_.cols& 1){
+ //Case 3: only cols odd
+ for (; r < rowEnd; r += 2){
+ // Get rows pointer
+ const PixelT * const img_row = img_.ptr<PixelT>(r);
+ const PixelT * const img_row_fol = (PixelT *)(((char *)img_row) + img_.step.p[0]);
+ LabelT * const imgLabels_row = imgLabels_.ptr<LabelT>(r);
+ LabelT * const imgLabels_row_fol = (LabelT *)(((char *)imgLabels_row) + imgLabels_.step.p[0]);
+ // Get rows pointer
+ for (int c = 0; c < imgLabels_.cols; c += 2) {
+ LabelT iLabel = imgLabels_row[c];
+ if (iLabel > 0) {
+ iLabel = P_[iLabel];
+ if (img_row[c] > 0){
+ imgLabels_row[c] = iLabel;
+ sopArray_[rowBegin](r, c, iLabel);
+ }
+ else{
+ imgLabels_row[c] = 0;
+ sopArray_[rowBegin](r, c, 0);
+ }
+ if (img_row_fol[c] > 0){
+ imgLabels_row_fol[c] = iLabel;
+ sopArray_[rowBegin](r + 1, c, iLabel);
+ }
+ else{
+ imgLabels_row_fol[c] = 0;
+ sopArray_[rowBegin](r + 1, c, 0);
+ }
+ if (c + 1 < imgLabels_.cols) {
+ if (img_row[c + 1] > 0){
+ imgLabels_row[c + 1] = iLabel;
+ sopArray_[rowBegin](r, c + 1, iLabel);
+ }
+ else{
+ imgLabels_row[c + 1] = 0;
+ sopArray_[rowBegin](r, c + 1, 0);
+ }
+ if (img_row_fol[c + 1] > 0){
+ imgLabels_row_fol[c + 1] = iLabel;
+ sopArray_[rowBegin](r + 1, c + 1, iLabel);
+ }
+ else{
+ imgLabels_row_fol[c + 1] = 0;
+ sopArray_[rowBegin](r + 1, c + 1, 0);
+ }
+ }
+ }
+ else{
+ imgLabels_row[c] = 0;
+ imgLabels_row_fol[c] = 0;
+ sopArray_[rowBegin](r, c, 0);
+ sopArray_[rowBegin](r + 1, c, 0);
+ if (c + 1 < imgLabels_.cols) {
+ imgLabels_row[c + 1] = 0;
+ imgLabels_row_fol[c + 1] = 0;
+ sopArray_[rowBegin](r, c + 1, 0);
+ sopArray_[rowBegin](r + 1, c + 1, 0);
+ }
+ }
+ }
+ }
+ }// END case 3
+ else{
+ //Case 4: nothing odd
+ for (; r < rowEnd; r += 2){
+ // Get rows pointer
+ const PixelT * const img_row = img_.ptr<PixelT>(r);
+ const PixelT * const img_row_fol = (PixelT *)(((char *)img_row) + img_.step.p[0]);
+ LabelT * const imgLabels_row = imgLabels_.ptr<LabelT>(r);
+ LabelT * const imgLabels_row_fol = (LabelT *)(((char *)imgLabels_row) + imgLabels_.step.p[0]);
+ // Get rows pointer
+ for (int c = 0; c < imgLabels_.cols; c += 2) {
+ LabelT iLabel = imgLabels_row[c];
+ if (iLabel > 0) {
+ iLabel = P_[iLabel];
+ if (img_row[c] > 0){
+ imgLabels_row[c] = iLabel;
+ sopArray_[rowBegin](r, c, iLabel);
+ }
+ else{
+ imgLabels_row[c] = 0;
+ sopArray_[rowBegin](r, c, 0);
+ }
+ if (img_row[c + 1] > 0){
+ imgLabels_row[c + 1] = iLabel;
+ sopArray_[rowBegin](r, c + 1, iLabel);
+ }
+ else{
+ imgLabels_row[c + 1] = 0;
+ sopArray_[rowBegin](r, c + 1, 0);
+ }
+ if (img_row_fol[c] > 0){
+ imgLabels_row_fol[c] = iLabel;
+ sopArray_[rowBegin](r + 1, c, iLabel);
+ }
+ else{
+ imgLabels_row_fol[c] = 0;
+ sopArray_[rowBegin](r + 1, c, 0);
+ }
+ if (img_row_fol[c + 1] > 0){
+ imgLabels_row_fol[c + 1] = iLabel;
+ sopArray_[rowBegin](r + 1, c + 1, iLabel);
+ }
+ else{
+ imgLabels_row_fol[c + 1] = 0;
+ sopArray_[rowBegin](r + 1, c + 1, 0);
+ }
+ }
+ else {
+ imgLabels_row[c] = 0;
+ imgLabels_row[c + 1] = 0;
+ imgLabels_row_fol[c] = 0;
+ imgLabels_row_fol[c + 1] = 0;
+ sopArray_[rowBegin](r, c, 0);
+ sopArray_[rowBegin](r, c + 1, 0);
+ sopArray_[rowBegin](r + 1, c, 0);
+ sopArray_[rowBegin](r + 1, c + 1, 0);
+ }
+ }
+ }//END case 4
+ }
+ }
+ }
+ else{
+ //the first thread uses sop in order to make less merges
+ sop_.setNextLoc(rowEnd);
+ if (imgLabels_.rows& 1){
+ if (imgLabels_.cols& 1){
+ //Case 1: both rows and cols odd
+ for (; r < rowEnd; r += 2){
+ // Get rows pointer
+ const PixelT * const img_row = img_.ptr<PixelT>(r);
+ const PixelT * const img_row_fol = (PixelT *)(((char *)img_row) + img_.step.p[0]);
+
+ LabelT * const imgLabels_row = imgLabels_.ptr<LabelT>(r);
+ LabelT * const imgLabels_row_fol = (LabelT *)(((char *)imgLabels_row) + imgLabels_.step.p[0]);
+ // Get rows pointer
+ for (int c = 0; c < imgLabels_.cols; c += 2) {
+ LabelT iLabel = imgLabels_row[c];
+ if (iLabel > 0) {
+ iLabel = P_[iLabel];
+ if (img_row[c] > 0){
+ imgLabels_row[c] = iLabel;
+ sop_(r, c, iLabel);
+ }
+ else{
+ imgLabels_row[c] = 0;
+ sop_(r, c, 0);
+ }
+ if (c + 1 < imgLabels_.cols) {
+ if (img_row[c + 1] > 0){
+ imgLabels_row[c + 1] = iLabel;
+ sop_(r, c + 1, iLabel);
+ }
+ else{
+ imgLabels_row[c + 1] = 0;
+ sop_(r, c + 1, 0);
+ }
+ if (r + 1 < imgLabels_.rows) {
+ if (img_row_fol[c] > 0){
+ imgLabels_row_fol[c] = iLabel;
+ sop_(r + 1, c, iLabel);
+ }
+ else{
+ imgLabels_row_fol[c] = 0;
+ sop_(r + 1, c, 0);
+ }
+ if (img_row_fol[c + 1] > 0){
+ imgLabels_row_fol[c + 1] = iLabel;
+ sop_(r + 1, c + 1, iLabel);
+ }
+ else{
+ imgLabels_row_fol[c + 1] = 0;
+ sop_(r + 1, c + 1, 0);
+ }
+ }
+ }
+ else if (r + 1 < imgLabels_.rows) {
+ if (img_row_fol[c] > 0){
+ imgLabels_row_fol[c] = iLabel;
+ sop_(r + 1, c, iLabel);
+ }
+ else{
+ imgLabels_row_fol[c] = 0;
+ sop_(r + 1, c, 0);
+ }
+ }
+ }
+ else {
+ imgLabels_row[c] = 0;
+ sop_(r, c, 0);
+ if (c + 1 < imgLabels_.cols) {
+ imgLabels_row[c + 1] = 0;
+ sop_(r, c + 1, 0);
+ if (r + 1 < imgLabels_.rows) {
+ imgLabels_row_fol[c] = 0;
+ imgLabels_row_fol[c + 1] = 0;
+ sop_(r + 1, c, 0);
+ sop_(r + 1, c + 1, 0);
+ }
+ }
+ else if (r + 1 < imgLabels_.rows) {
+ imgLabels_row_fol[c] = 0;
+ sop_(r + 1, c, 0);
+ }
+ }
+ }
+ }
+ }//END Case 1
+ else{
+ //Case 2: only rows odd
+ for (; r < rowEnd; r += 2){
+ // Get rows pointer
+ const PixelT * const img_row = img_.ptr<PixelT>(r);
+ const PixelT * const img_row_fol = (PixelT *)(((char *)img_row) + img_.step.p[0]);
+ LabelT * const imgLabels_row = imgLabels_.ptr<LabelT>(r);
+ LabelT * const imgLabels_row_fol = (LabelT *)(((char *)imgLabels_row) + imgLabels_.step.p[0]);
+ // Get rows pointer
+ for (int c = 0; c < imgLabels_.cols; c += 2) {
+ LabelT iLabel = imgLabels_row[c];
+ if (iLabel > 0) {
+ iLabel = P_[iLabel];
+ if (img_row[c] > 0){
+ imgLabels_row[c] = iLabel;
+ sop_(r, c, iLabel);
+ }
+ else{
+ imgLabels_row[c] = 0;
+ sop_(r, c, 0);
+ }
+ if (img_row[c + 1] > 0){
+ imgLabels_row[c + 1] = iLabel;
+ sop_(r, c + 1, iLabel);
+ }
+ else{
+ imgLabels_row[c + 1] = 0;
+ sop_(r, c + 1, 0);
+ }
+ if (r + 1 < imgLabels_.rows) {
+ if (img_row_fol[c] > 0){
+ imgLabels_row_fol[c] = iLabel;
+ sop_(r + 1, c, iLabel);
+ }
+ else{
+ imgLabels_row_fol[c] = 0;
+ sop_(r + 1, c, 0);
+ }
+ if (img_row_fol[c + 1] > 0){
+ imgLabels_row_fol[c + 1] = iLabel;
+ sop_(r + 1, c + 1, iLabel);
+ }
+ else{
+ imgLabels_row_fol[c + 1] = 0;
+ sop_(r + 1, c + 1, 0);
+ }
+ }
+ }
+ else {
+ imgLabels_row[c] = 0;
+ imgLabels_row[c + 1] = 0;
+ sop_(r, c, 0);
+ sop_(r, c + 1, 0);
+ if (r + 1 < imgLabels_.rows) {
+ imgLabels_row_fol[c] = 0;
+ imgLabels_row_fol[c + 1] = 0;
+ sop_(r + 1, c, 0);
+ sop_(r + 1, c + 1, 0);
+ }
+ }
+ }
+ }
+ }// END Case 2
+ }
+ else{
+ if (imgLabels_.cols& 1){
+ //Case 3: only cols odd
+ for (; r < rowEnd; r += 2){
+ // Get rows pointer
+ const PixelT * const img_row = img_.ptr<PixelT>(r);
+ const PixelT * const img_row_fol = (PixelT *)(((char *)img_row) + img_.step.p[0]);
+ LabelT * const imgLabels_row = imgLabels_.ptr<LabelT>(r);
+ LabelT * const imgLabels_row_fol = (LabelT *)(((char *)imgLabels_row) + imgLabels_.step.p[0]);
+ // Get rows pointer
+ for (int c = 0; c < imgLabels_.cols; c += 2) {
+ LabelT iLabel = imgLabels_row[c];
+ if (iLabel > 0) {
+ iLabel = P_[iLabel];
+ if (img_row[c] > 0){
+ imgLabels_row[c] = iLabel;
+ sop_(r, c, iLabel);
+ }
+ else{
+ imgLabels_row[c] = 0;
+ sop_(r, c, 0);
+ }
+ if (img_row_fol[c] > 0){
+ imgLabels_row_fol[c] = iLabel;
+ sop_(r + 1, c, iLabel);
+ }
+ else{
+ imgLabels_row_fol[c] = 0;
+ sop_(r + 1, c, 0);
+ }
+ if (c + 1 < imgLabels_.cols) {
+ if (img_row[c + 1] > 0){
+ imgLabels_row[c + 1] = iLabel;
+ sop_(r, c + 1, iLabel);
+ }
+ else{
+ imgLabels_row[c + 1] = 0;
+ sop_(r, c + 1, 0);
+ }
+ if (img_row_fol[c + 1] > 0){
+ imgLabels_row_fol[c + 1] = iLabel;
+ sop_(r + 1, c + 1, iLabel);
+ }
+ else{
+ imgLabels_row_fol[c + 1] = 0;
+ sop_(r + 1, c + 1, 0);
+ }
+ }
+ }
+ else{
+ imgLabels_row[c] = 0;
+ imgLabels_row_fol[c] = 0;
+ sop_(r, c, 0);
+ sop_(r + 1, c, 0);
+ if (c + 1 < imgLabels_.cols) {
+ imgLabels_row[c + 1] = 0;
+ imgLabels_row_fol[c + 1] = 0;
+ sop_(r, c + 1, 0);
+ sop_(r + 1, c + 1, 0);
+ }
+ }
+ }
+ }
+ }// END case 3
+ else{
+ //Case 4: nothing odd
+ for (; r < rowEnd; r += 2){
+ // Get rows pointer
+ const PixelT * const img_row = img_.ptr<PixelT>(r);
+ const PixelT * const img_row_fol = (PixelT *)(((char *)img_row) + img_.step.p[0]);
+ LabelT * const imgLabels_row = imgLabels_.ptr<LabelT>(r);
+ LabelT * const imgLabels_row_fol = (LabelT *)(((char *)imgLabels_row) + imgLabels_.step.p[0]);
+ // Get rows pointer
+ for (int c = 0; c < imgLabels_.cols; c += 2) {
+ LabelT iLabel = imgLabels_row[c];
+ if (iLabel > 0) {
+ iLabel = P_[iLabel];
+ if (img_row[c] > 0){
+ imgLabels_row[c] = iLabel;
+ sop_(r, c, iLabel);
+ }
+ else{
+ imgLabels_row[c] = 0;
+ sop_(r, c, 0);
+ }
+ if (img_row[c + 1] > 0){
+ imgLabels_row[c + 1] = iLabel;
+ sop_(r, c + 1, iLabel);
+ }
+ else{
+ imgLabels_row[c + 1] = 0;
+ sop_(r, c + 1, 0);
+ }
+ if (img_row_fol[c] > 0){
+ imgLabels_row_fol[c] = iLabel;
+ sop_(r + 1, c, iLabel);
+ }
+ else{
+ imgLabels_row_fol[c] = 0;
+ sop_(r + 1, c, 0);
+ }
+ if (img_row_fol[c + 1] > 0){
+ imgLabels_row_fol[c + 1] = iLabel;
+ sop_(r + 1, c + 1, iLabel);
+ }
+ else{
+ imgLabels_row_fol[c + 1] = 0;
+ sop_(r + 1, c + 1, 0);
+ }
+ }
+ else {
+ imgLabels_row[c] = 0;
+ imgLabels_row[c + 1] = 0;
+ imgLabels_row_fol[c] = 0;
+ imgLabels_row_fol[c + 1] = 0;
+ sop_(r, c, 0);
+ sop_(r, c + 1, 0);
+ sop_(r + 1, c, 0);
+ sop_(r + 1, c + 1, 0);
+ }
+ }
+ }//END case 4
+ }
+ }
+ }
+ }
+ };
+
+ inline static
+ void mergeLabels(const cv::Mat& img, cv::Mat& imgLabels, LabelT *P, int *chunksSizeAndLabels){
+
+ // Merge Mask
+ // +---+---+---+
+ // |P -|Q -|R -|
+ // |- -|- -|- -|
+ // +---+---+---+
+ // |X -|
+ // |- -|
+ // +---+
+ const int w = imgLabels.cols, h = imgLabels.rows;
+
+ for (int r = chunksSizeAndLabels[0]; r < h; r = chunksSizeAndLabels[r]){
+
+ LabelT * const imgLabels_row = imgLabels.ptr<LabelT>(r);
+ LabelT * const imgLabels_row_prev_prev = (LabelT *)(((char *)imgLabels_row) - imgLabels.step.p[0] - imgLabels.step.p[0]);
+ const PixelT * const img_row = img.ptr<PixelT>(r);
+ const PixelT * const img_row_prev = (PixelT *)(((char *)img_row) - img.step.p[0]);
+
+ for (int c = 0; c < w; c += 2){
+
+#define condition_x imgLabels_row[c] > 0
+#define condition_pppr c > 1 && imgLabels_row_prev_prev[c - 2] > 0
+#define condition_qppr imgLabels_row_prev_prev[c] > 0
+#define condition_qppr1 c < w - 1
+#define condition_qppr2 c < w
+#define condition_rppr c < w - 2 && imgLabels_row_prev_prev[c + 2] > 0
+
+ if (condition_x){
+ if (condition_pppr){
+ //check in img
+ if (img_row[c] > 0 && img_row_prev[c - 1] > 0)
+ //assign the same label
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c - 2], imgLabels_row[c]);
+ }
+ if (condition_qppr){
+ if (condition_qppr1){
+ if ((img_row[c] > 0 && img_row_prev[c] > 0) || (img_row[c + 1] > 0 && img_row_prev[c] > 0) ||
+ (img_row[c] > 0 && img_row_prev[c + 1] > 0) || (img_row[c + 1] > 0 && img_row_prev[c + 1] > 0)){
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c]);
+ }
+ }
+ else /*if (condition_qppr2)*/{
+ if (img_row[c] > 0 && img_row_prev[c] > 0)
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c]);
+ }
+ }
+ if (condition_rppr){
+ if (img_row[c + 1] > 0 && img_row_prev[c + 2] > 0)
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c]);
+ }
+ }
+ }
+ }
+ }
+
+ LabelT operator()(const cv::Mat& img, cv::Mat& imgLabels, int connectivity, StatsOp& sop){
+ CV_Assert(img.rows == imgLabels.rows);
+ CV_Assert(img.cols == imgLabels.cols);
+ CV_Assert(connectivity == 8);
+
+ const int nThreads = cv::getNumberOfCPUs();
+ cv::setNumThreads(nThreads);
+
+ const int h = img.rows;
+ const int w = img.cols;
+
+ //A quick and dirty upper bound for the maximimum number of labels.
+ //Following formula comes from the fact that a 2x2 block in 8-connectivity case
+ //can never have more than 1 new label and 1 label for background.
+ //Worst case image example pattern:
+ //1 0 1 0 1...
+ //0 0 0 0 0...
+ //1 0 1 0 1...
+ //............
+ const size_t Plength = size_t(((h + 1) / 2) * size_t((w + 1) / 2)) + 1;
+
+ //Array used to store info and labeled pixel by each thread.
+ //Different threads affect different memory location of chunksSizeAndLabels
+ int *chunksSizeAndLabels = (int *)cv::fastMalloc(h * sizeof(int));
+
+ //Tree of labels
+ LabelT *P = (LabelT *)cv::fastMalloc(Plength * sizeof(LabelT));
+ //First label is for background
+ P[0] = 0;
+
+ cv::Range range(0, h);
+
+ //First scan, each thread works with chunk of img.rows/nThreads rows
+ //e.g. 300 rows, 4 threads -> each chunks is composed of 75 rows
+ cv::parallel_for_(range, FirstScan(img, imgLabels, P, chunksSizeAndLabels), nThreads);
+
+ //merge labels of different chunks
+ mergeLabels(img, imgLabels, P, chunksSizeAndLabels);
+
+ LabelT nLabels = 1;
+ for (int i = 0; i < h; i = chunksSizeAndLabels[i]){
+ flattenL(P, LabelT((i + 1) / 2) * LabelT((w + 1) / 2) + 1, chunksSizeAndLabels[i + 1], nLabels);
+ }
+
+ //Array for statistics data
+ StatsOp *sopArray = new StatsOp[h];
+ sop.init(nLabels);
+
+ //Second scan
+ cv::parallel_for_(range, SecondScan(img, imgLabels, P, sop, sopArray, nLabels), nThreads);
+
+ StatsOp::mergeStats(imgLabels, sopArray, sop, nLabels);
+ sop.finish();
+
+ delete[] sopArray;
+ cv::fastFree(chunksSizeAndLabels);
+ cv::fastFree(P);
+ return nLabels;
+ }
+ };//End struct LabelingGranaParallel
+
+ // Based on "Optimized Block-based Connected Components Labeling with Decision Trees", Costantino Grana et al
+ // Only for 8-connectivity
+ template<typename LabelT, typename PixelT, typename StatsOp = NoOp >
+ struct LabelingGrana{
+ LabelT operator()(const cv::Mat& img, cv::Mat& imgLabels, int connectivity, StatsOp& sop){
+ CV_Assert(img.rows == imgLabels.rows);
+ CV_Assert(img.cols == imgLabels.cols);
+ CV_Assert(connectivity == 8);
+
+ const int h = img.rows;
+ const int w = img.cols;
+
+ //A quick and dirty upper bound for the maximimum number of labels.
+ //Following formula comes from the fact that a 2x2 block in 8-connectivity case
+ //can never have more than 1 new label and 1 label for background.
+ //Worst case image example pattern:
+ //1 0 1 0 1...
+ //0 0 0 0 0...
+ //1 0 1 0 1...
+ //............
+ const size_t Plength = size_t(((h + 1) / 2) * size_t((w + 1) / 2)) + 1;
+
+ LabelT *P = (LabelT *)fastMalloc(sizeof(LabelT) *Plength);
+ P[0] = 0;
+ LabelT lunique = 1;
+
+ // First scan
+ for (int r = 0; r < h; r += 2) {
+ // Get rows pointer
+ const PixelT * const img_row = img.ptr<PixelT>(r);
+ const PixelT * const img_row_prev = (PixelT *)(((char *)img_row) - img.step.p[0]);
+ const PixelT * const img_row_prev_prev = (PixelT *)(((char *)img_row_prev) - img.step.p[0]);
+ const PixelT * const img_row_fol = (PixelT *)(((char *)img_row) + img.step.p[0]);
+ LabelT * const imgLabels_row = imgLabels.ptr<LabelT>(r);
+ LabelT * const imgLabels_row_prev_prev = (LabelT *)(((char *)imgLabels_row) - imgLabels.step.p[0] - imgLabels.step.p[0]);
+ for (int c = 0; c < w; c += 2) {
+
+ // We work with 2x2 blocks
+ // +-+-+-+
+ // |P|Q|R|
+ // +-+-+-+
+ // |S|X|
+ // +-+-+
+
+ // The pixels are named as follows
+ // +---+---+---+
+ // |a b|c d|e f|
+ // |g h|i j|k l|
+ // +---+---+---+
+ // |m n|o p|
+ // |q r|s t|
+ // +---+---+
+
+ // Pixels a, f, l, q are not needed, since we need to understand the
+ // the connectivity between these blocks and those pixels only metter
+ // when considering the outer connectivities
+
+ // A bunch of defines used to check if the pixels are foreground,
+ // without going outside the image limits.
+#define condition_b c-1>=0 && r-2>=0 && img_row_prev_prev[c-1]>0
+#define condition_c r-2>=0 && img_row_prev_prev[c]>0
+#define condition_d c+1<w&& r-2>=0 && img_row_prev_prev[c+1]>0
+#define condition_e c+2<w && r-1>=0 && img_row_prev[c-1]>0
+
+#define condition_g c-2>=0 && r-1>=0 && img_row_prev[c-2]>0
+#define condition_h c-1>=0 && r-1>=0 && img_row_prev[c-1]>0
+#define condition_i r-1>=0 && img_row_prev[c]>0
+#define condition_j c+1<w && r-1>=0 && img_row_prev[c+1]>0
+#define condition_k c+2<w && r-1>=0 && img_row_prev[c+2]>0
+
+#define condition_m c-2>=0 && img_row[c-2]>0
+#define condition_n c-1>=0 && img_row[c-1]>0
+#define condition_o img_row[c]>0
+#define condition_p c+1<w && img_row[c+1]>0
+
+#define condition_r c-1>=0 && r+1<h && img_row_fol[c-1]>0
+#define condition_s r+1<h && img_row_fol[c]>0
+#define condition_t c+1<w && r+1<h && img_row_fol[c+1]>0
+
+ // This is a decision tree which allows to choose which action to
+ // perform, checking as few conditions as possible.
+ // Actions: the blocks label are provisionally stored in the top left
+ // pixel of the block in the labels image
+
+ if (condition_o) {
+ if (condition_n) {
+ if (condition_j) {
+ if (condition_i) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_c) {
+ if (condition_h) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_g) {
+ if (condition_b) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ if (condition_p) {
+ if (condition_k) {
+ if (condition_d) {
+ if (condition_i) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_c) {
+ if (condition_h) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_g) {
+ if (condition_b) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ }
+ else {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ }
+ }
+ else {
+ if (condition_r) {
+ if (condition_j) {
+ if (condition_m) {
+ if (condition_h) {
+ if (condition_i) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_c) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ if (condition_g) {
+ if (condition_b) {
+ if (condition_i) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_c) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ if (condition_i) {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ else {
+ if (condition_h) {
+ if (condition_c) {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ else {
+ //Action_14: Merge labels of block P, Q and S
+ imgLabels_row[c] = set_union(P, set_union(P, imgLabels_row_prev_prev[c - 2], imgLabels_row_prev_prev[c]), imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ }
+ else {
+ if (condition_p) {
+ if (condition_k) {
+ if (condition_m) {
+ if (condition_h) {
+ if (condition_d) {
+ if (condition_i) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_c) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ if (condition_d) {
+ if (condition_g) {
+ if (condition_b) {
+ if (condition_i) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_c) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ if (condition_i) {
+ if (condition_g) {
+ if (condition_b) {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ else {
+ //Action_16: labels of block Q, R and S
+ imgLabels_row[c] = set_union(P, set_union(P, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]), imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_16: labels of block Q, R and S
+ imgLabels_row[c] = set_union(P, set_union(P, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]), imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ }
+ else {
+ if (condition_i) {
+ if (condition_d) {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ else {
+ //Action_16: labels of block Q, R and S
+ imgLabels_row[c] = set_union(P, set_union(P, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]), imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ if (condition_h) {
+ if (condition_d) {
+ if (condition_c) {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ else {
+ //Action_15: Merge labels of block P, R and S
+ imgLabels_row[c] = set_union(P, set_union(P, imgLabels_row_prev_prev[c - 2], imgLabels_row_prev_prev[c + 2]), imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_15: Merge labels of block P, R and S
+ imgLabels_row[c] = set_union(P, set_union(P, imgLabels_row_prev_prev[c - 2], imgLabels_row_prev_prev[c + 2]), imgLabels_row[c - 2]);
continue;
}
}
@@ -693,41 +2992,48 @@ namespace cv{
}
}
else {
- if (condition_i) {
- if (condition_d) {
- //Action_12: Merge labels of block R and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ if (condition_h) {
+ if (condition_m) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
continue;
}
else {
- //Action_16: labels of block Q, R and S
- imgLabels_row[c] = set_union(P, set_union(P, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]), imgLabels_row[c - 2]);
+ // ACTION_9 Merge labels of block P and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c - 2], imgLabels_row[c - 2]);
continue;
}
}
else {
- if (condition_h) {
- if (condition_d) {
- if (condition_c) {
- //Action_12: Merge labels of block R and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
- continue;
+ if (condition_i) {
+ if (condition_m) {
+ if (condition_g) {
+ if (condition_b) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
}
else {
- //Action_15: Merge labels of block P, R and S
- imgLabels_row[c] = set_union(P, set_union(P, imgLabels_row_prev_prev[c - 2], imgLabels_row_prev_prev[c + 2]), imgLabels_row[c - 2]);
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
continue;
}
}
else {
- //Action_15: Merge labels of block P, R and S
- imgLabels_row[c] = set_union(P, set_union(P, imgLabels_row_prev_prev[c - 2], imgLabels_row_prev_prev[c + 2]), imgLabels_row[c - 2]);
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
continue;
}
}
else {
- //Action_12: Merge labels of block R and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
continue;
}
}
@@ -772,113 +3078,71 @@ namespace cv{
imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
continue;
}
- }
- else {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
- }
- }
- }
- }
- else {
- if (condition_h) {
- if (condition_m) {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
- }
- else {
- // ACTION_9 Merge labels of block P and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c - 2], imgLabels_row[c - 2]);
- continue;
- }
- }
- else {
- if (condition_i) {
- if (condition_m) {
- if (condition_g) {
- if (condition_b) {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
- }
- else {
- //Action_11: Merge labels of block Q and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
- continue;
- }
- }
- else {
- //Action_11: Merge labels of block Q and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
- continue;
- }
- }
- else {
- //Action_11: Merge labels of block Q and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
- continue;
- }
- }
- else {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
- }
- }
- }
- }
- }
- else {
- if (condition_j) {
- if (condition_i) {
- //Action_4: Assign label of block Q
- imgLabels_row[c] = imgLabels_row_prev_prev[c];
- continue;
- }
- else {
- if (condition_h) {
- if (condition_c) {
- //Action_4: Assign label of block Q
- imgLabels_row[c] = imgLabels_row_prev_prev[c];
- continue;
- }
- else {
- //Action_7: Merge labels of block P and Q
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c - 2], imgLabels_row_prev_prev[c]);
- continue;
+ }
+ else {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
}
}
- else {
+ }
+ }
+ else {
+ if (condition_j) {
+ if (condition_i) {
//Action_4: Assign label of block Q
imgLabels_row[c] = imgLabels_row_prev_prev[c];
continue;
}
- }
- }
- else {
- if (condition_p) {
- if (condition_k) {
- if (condition_i) {
- if (condition_d) {
- //Action_5: Assign label of block R
- imgLabels_row[c] = imgLabels_row_prev_prev[c + 2];
+ else {
+ if (condition_h) {
+ if (condition_c) {
+ //Action_4: Assign label of block Q
+ imgLabels_row[c] = imgLabels_row_prev_prev[c];
continue;
}
else {
- // ACTION_10 Merge labels of block Q and R
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]);
+ //Action_7: Merge labels of block P and Q
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c - 2], imgLabels_row_prev_prev[c]);
continue;
}
}
else {
- if (condition_h) {
+ //Action_4: Assign label of block Q
+ imgLabels_row[c] = imgLabels_row_prev_prev[c];
+ continue;
+ }
+ }
+ }
+ else {
+ if (condition_p) {
+ if (condition_k) {
+ if (condition_i) {
if (condition_d) {
- if (condition_c) {
- //Action_5: Assign label of block R
- imgLabels_row[c] = imgLabels_row_prev_prev[c + 2];
- continue;
+ //Action_5: Assign label of block R
+ imgLabels_row[c] = imgLabels_row_prev_prev[c + 2];
+ continue;
+ }
+ else {
+ // ACTION_10 Merge labels of block Q and R
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]);
+ continue;
+ }
+ }
+ else {
+ if (condition_h) {
+ if (condition_d) {
+ if (condition_c) {
+ //Action_5: Assign label of block R
+ imgLabels_row[c] = imgLabels_row_prev_prev[c + 2];
+ continue;
+ }
+ else {
+ //Action_8: Merge labels of block P and R
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c - 2], imgLabels_row_prev_prev[c + 2]);
+ continue;
+ }
}
else {
//Action_8: Merge labels of block P and R
@@ -887,16 +3151,32 @@ namespace cv{
}
}
else {
- //Action_8: Merge labels of block P and R
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c - 2], imgLabels_row_prev_prev[c + 2]);
+ //Action_5: Assign label of block R
+ imgLabels_row[c] = imgLabels_row_prev_prev[c + 2];
continue;
}
}
- else {
- //Action_5: Assign label of block R
- imgLabels_row[c] = imgLabels_row_prev_prev[c + 2];
+ }
+ else {
+ if (condition_i) {
+ //Action_4: Assign label of block Q
+ imgLabels_row[c] = imgLabels_row_prev_prev[c];
continue;
}
+ else {
+ if (condition_h) {
+ //Action_3: Assign label of block P
+ imgLabels_row[c] = imgLabels_row_prev_prev[c - 2];
+ continue;
+ }
+ else {
+ //Action_2: New label (the block has foreground pixels and is not connected to anything else)
+ imgLabels_row[c] = lunique;
+ P[lunique] = lunique;
+ lunique = lunique + 1;
+ continue;
+ }
+ }
}
}
else {
@@ -921,54 +3201,38 @@ namespace cv{
}
}
}
- else {
- if (condition_i) {
- //Action_4: Assign label of block Q
- imgLabels_row[c] = imgLabels_row_prev_prev[c];
- continue;
- }
- else {
- if (condition_h) {
- //Action_3: Assign label of block P
- imgLabels_row[c] = imgLabels_row_prev_prev[c - 2];
- continue;
- }
- else {
- //Action_2: New label (the block has foreground pixels and is not connected to anything else)
- imgLabels_row[c] = lunique;
- P[lunique] = lunique;
- lunique = lunique + 1;
- continue;
- }
- }
- }
}
}
}
- }
- else {
- if (condition_s) {
- if (condition_p) {
- if (condition_n) {
- if (condition_j) {
- if (condition_i) {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
- }
- else {
- if (condition_c) {
- if (condition_h) {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
- }
- else {
- if (condition_g) {
- if (condition_b) {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
+ else {
+ if (condition_s) {
+ if (condition_p) {
+ if (condition_n) {
+ if (condition_j) {
+ if (condition_i) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_c) {
+ if (condition_h) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_g) {
+ if (condition_b) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
}
else {
//Action_11: Merge labels of block Q and S
@@ -976,80 +3240,17 @@ namespace cv{
continue;
}
}
- else {
- //Action_11: Merge labels of block Q and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
- continue;
- }
- }
- }
- else {
- //Action_11: Merge labels of block Q and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
- continue;
- }
- }
- }
- else {
- if (condition_k) {
- if (condition_d) {
- if (condition_i) {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
}
else {
- if (condition_c) {
- if (condition_h) {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
- }
- else {
- if (condition_g) {
- if (condition_b) {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
- }
- else {
- //Action_12: Merge labels of block R and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
- continue;
- }
- }
- else {
- //Action_12: Merge labels of block R and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
- continue;
- }
- }
- }
- else {
- //Action_12: Merge labels of block R and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
- continue;
- }
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
}
}
- else {
- //Action_12: Merge labels of block R and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
- continue;
- }
}
else {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
- }
- }
- }
- else {
- if (condition_r) {
- if (condition_j) {
- if (condition_m) {
- if (condition_h) {
+ if (condition_k) {
+ if (condition_d) {
if (condition_i) {
//Action_6: Assign label of block S
imgLabels_row[c] = imgLabels_row[c - 2];
@@ -1057,37 +3258,100 @@ namespace cv{
}
else {
if (condition_c) {
+ if (condition_h) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ if (condition_g) {
+ if (condition_b) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ }
+ }
+ else {
+ if (condition_r) {
+ if (condition_j) {
+ if (condition_m) {
+ if (condition_h) {
+ if (condition_i) {
//Action_6: Assign label of block S
imgLabels_row[c] = imgLabels_row[c - 2];
continue;
}
else {
- //Action_11: Merge labels of block Q and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
- continue;
- }
- }
- }
- else {
- if (condition_g) {
- if (condition_b) {
- if (condition_i) {
+ if (condition_c) {
//Action_6: Assign label of block S
imgLabels_row[c] = imgLabels_row[c - 2];
continue;
}
else {
- if (condition_c) {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ if (condition_g) {
+ if (condition_b) {
+ if (condition_i) {
//Action_6: Assign label of block S
imgLabels_row[c] = imgLabels_row[c - 2];
continue;
}
else {
- //Action_11: Merge labels of block Q and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
- continue;
+ if (condition_c) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
}
}
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
+ }
}
else {
//Action_11: Merge labels of block Q and S
@@ -1095,62 +3359,62 @@ namespace cv{
continue;
}
}
- else {
- //Action_11: Merge labels of block Q and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
- continue;
- }
+ }
+ else {
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ continue;
}
}
else {
- //Action_11: Merge labels of block Q and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
- continue;
- }
- }
- else {
- if (condition_k) {
- if (condition_d) {
- if (condition_m) {
- if (condition_h) {
- if (condition_i) {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
- }
- else {
- if (condition_c) {
+ if (condition_k) {
+ if (condition_d) {
+ if (condition_m) {
+ if (condition_h) {
+ if (condition_i) {
//Action_6: Assign label of block S
imgLabels_row[c] = imgLabels_row[c - 2];
continue;
}
else {
- //Action_12: Merge labels of block R and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
- continue;
- }
- }
- }
- else {
- if (condition_g) {
- if (condition_b) {
- if (condition_i) {
+ if (condition_c) {
//Action_6: Assign label of block S
imgLabels_row[c] = imgLabels_row[c - 2];
continue;
}
else {
- if (condition_c) {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
+ else {
+ if (condition_g) {
+ if (condition_b) {
+ if (condition_i) {
//Action_6: Assign label of block S
imgLabels_row[c] = imgLabels_row[c - 2];
continue;
}
else {
- //Action_12: Merge labels of block R and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
- continue;
+ if (condition_c) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
+ continue;
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
}
}
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
}
else {
//Action_12: Merge labels of block R and S
@@ -1158,199 +3422,150 @@ namespace cv{
continue;
}
}
+ }
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ if (condition_i) {
+ if (condition_m) {
+ if (condition_h) {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ else {
+ if (condition_g) {
+ if (condition_b) {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
+ else {
+ //Action_16: labels of block Q, R and S
+ imgLabels_row[c] = set_union(P, set_union(P, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]), imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_16: labels of block Q, R and S
+ imgLabels_row[c] = set_union(P, set_union(P, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]), imgLabels_row[c - 2]);
+ continue;
+ }
+ }
+ }
else {
- //Action_12: Merge labels of block R and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ //Action_16: labels of block Q, R and S
+ imgLabels_row[c] = set_union(P, set_union(P, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]), imgLabels_row[c - 2]);
continue;
}
}
- }
- else {
- //Action_12: Merge labels of block R and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
- continue;
+ else {
+ //Action_12: Merge labels of block R and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ continue;
+ }
}
}
else {
if (condition_i) {
if (condition_m) {
if (condition_h) {
- //Action_12: Merge labels of block R and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
continue;
}
else {
if (condition_g) {
if (condition_b) {
- //Action_12: Merge labels of block R and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
continue;
}
else {
- //Action_16: labels of block Q, R and S
- imgLabels_row[c] = set_union(P, set_union(P, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]), imgLabels_row[c - 2]);
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
continue;
}
}
else {
- //Action_16: labels of block Q, R and S
- imgLabels_row[c] = set_union(P, set_union(P, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]), imgLabels_row[c - 2]);
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
continue;
}
}
}
else {
- //Action_16: labels of block Q, R and S
- imgLabels_row[c] = set_union(P, set_union(P, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]), imgLabels_row[c - 2]);
+ //Action_11: Merge labels of block Q and S
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
continue;
}
}
else {
- //Action_12: Merge labels of block R and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c + 2], imgLabels_row[c - 2]);
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
continue;
}
}
}
+ }
+ else {
+ if (condition_j) {
+ //Action_4: Assign label of block Q
+ imgLabels_row[c] = imgLabels_row_prev_prev[c];
+ continue;
+ }
else {
- if (condition_i) {
- if (condition_m) {
- if (condition_h) {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
+ if (condition_k) {
+ if (condition_i) {
+ if (condition_d) {
+ //Action_5: Assign label of block R
+ imgLabels_row[c] = imgLabels_row_prev_prev[c + 2];
continue;
}
else {
- if (condition_g) {
- if (condition_b) {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
- }
- else {
- //Action_11: Merge labels of block Q and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
- continue;
- }
- }
- else {
- //Action_11: Merge labels of block Q and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
- continue;
- }
+ // ACTION_10 Merge labels of block Q and R
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]);
+ continue;
}
}
else {
- //Action_11: Merge labels of block Q and S
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row[c - 2]);
+ //Action_5: Assign label of block R
+ imgLabels_row[c] = imgLabels_row_prev_prev[c + 2];
continue;
}
}
else {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
- }
- }
- }
- }
- else {
- if (condition_j) {
- //Action_4: Assign label of block Q
- imgLabels_row[c] = imgLabels_row_prev_prev[c];
- continue;
- }
- else {
- if (condition_k) {
- if (condition_i) {
- if (condition_d) {
- //Action_5: Assign label of block R
- imgLabels_row[c] = imgLabels_row_prev_prev[c + 2];
+ if (condition_i) {
+ //Action_4: Assign label of block Q
+ imgLabels_row[c] = imgLabels_row_prev_prev[c];
continue;
}
else {
- // ACTION_10 Merge labels of block Q and R
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]);
- continue;
- }
- }
- else {
- //Action_5: Assign label of block R
- imgLabels_row[c] = imgLabels_row_prev_prev[c + 2];
- continue;
- }
- }
- else {
- if (condition_i) {
- //Action_4: Assign label of block Q
- imgLabels_row[c] = imgLabels_row_prev_prev[c];
- continue;
- }
- else {
- //Action_2: New label (the block has foreground pixels and is not connected to anything else)
- imgLabels_row[c] = lunique;
- P[lunique] = lunique;
- lunique = lunique + 1;
- continue;
+ //Action_2: New label (the block has foreground pixels and is not connected to anything else)
+ imgLabels_row[c] = lunique;
+ P[lunique] = lunique;
+ lunique = lunique + 1;
+ continue;
+ }
}
}
}
}
}
- }
- else {
- if (condition_r) {
- //Action_6: Assign label of block S
- imgLabels_row[c] = imgLabels_row[c - 2];
- continue;
- }
else {
- if (condition_n) {
+ if (condition_r) {
//Action_6: Assign label of block S
imgLabels_row[c] = imgLabels_row[c - 2];
continue;
}
else {
- //Action_2: New label (the block has foreground pixels and is not connected to anything else)
- imgLabels_row[c] = lunique;
- P[lunique] = lunique;
- lunique = lunique + 1;
- continue;
- }
- }
- }
- }
- else {
- if (condition_p) {
- if (condition_j) {
- //Action_4: Assign label of block Q
- imgLabels_row[c] = imgLabels_row_prev_prev[c];
- continue;
- }
- else {
- if (condition_k) {
- if (condition_i) {
- if (condition_d) {
- //Action_5: Assign label of block R
- imgLabels_row[c] = imgLabels_row_prev_prev[c + 2];
- continue;
- }
- else {
- // ACTION_10 Merge labels of block Q and R
- imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]);
- continue;
- }
- }
- else {
- //Action_5: Assign label of block R
- imgLabels_row[c] = imgLabels_row_prev_prev[c + 2];
- continue;
- }
- }
- else {
- if (condition_i) {
- //Action_4: Assign label of block Q
- imgLabels_row[c] = imgLabels_row_prev_prev[c];
+ if (condition_n) {
+ //Action_6: Assign label of block S
+ imgLabels_row[c] = imgLabels_row[c - 2];
continue;
}
else {
@@ -1364,51 +3579,175 @@ namespace cv{
}
}
else {
- if (condition_t) {
- //Action_2: New label (the block has foreground pixels and is not connected to anything else)
- imgLabels_row[c] = lunique;
- P[lunique] = lunique;
- lunique = lunique + 1;
- continue;
+ if (condition_p) {
+ if (condition_j) {
+ //Action_4: Assign label of block Q
+ imgLabels_row[c] = imgLabels_row_prev_prev[c];
+ continue;
+ }
+ else {
+ if (condition_k) {
+ if (condition_i) {
+ if (condition_d) {
+ //Action_5: Assign label of block R
+ imgLabels_row[c] = imgLabels_row_prev_prev[c + 2];
+ continue;
+ }
+ else {
+ // ACTION_10 Merge labels of block Q and R
+ imgLabels_row[c] = set_union(P, imgLabels_row_prev_prev[c], imgLabels_row_prev_prev[c + 2]);
+ continue;
+ }
+ }
+ else {
+ //Action_5: Assign label of block R
+ imgLabels_row[c] = imgLabels_row_prev_prev[c + 2];
+ continue;
+ }
+ }
+ else {
+ if (condition_i) {
+ //Action_4: Assign label of block Q
+ imgLabels_row[c] = imgLabels_row_prev_prev[c];
+ continue;
+ }
+ else {
+ //Action_2: New label (the block has foreground pixels and is not connected to anything else)
+ imgLabels_row[c] = lunique;
+ P[lunique] = lunique;
+ lunique = lunique + 1;
+ continue;
+ }
+ }
+ }
}
else {
- // Action_1: No action (the block has no foreground pixels)
- imgLabels_row[c] = 0;
- continue;
+ if (condition_t) {
+ //Action_2: New label (the block has foreground pixels and is not connected to anything else)
+ imgLabels_row[c] = lunique;
+ P[lunique] = lunique;
+ lunique = lunique + 1;
+ continue;
+ }
+ else {
+ // Action_1: No action (the block has no foreground pixels)
+ imgLabels_row[c] = 0;
+ continue;
+ }
}
}
}
}
+
}
- }
- // Second scan + analysis
- LabelT nLabels = flattenL(P, lunique);
- sop.init(nLabels);
+ // Second scan + analysis
+ LabelT nLabels = flattenL(P, lunique);
+ sop.init(nLabels);
- if (imgLabels.rows & 1){
- if (imgLabels.cols & 1){
- //Case 1: both rows and cols odd
- for (int r = 0; r<imgLabels.rows; r += 2) {
- // Get rows pointer
- const PixelT* const img_row = img.ptr<PixelT>(r);
- const PixelT* const img_row_fol = (PixelT *)(((char *)img_row) + img.step.p[0]);
- LabelT* const imgLabels_row = imgLabels.ptr<LabelT>(r);
- LabelT* const imgLabels_row_fol = (LabelT *)(((char *)imgLabels_row) + imgLabels.step.p[0]);
-
- for (int c = 0; c<imgLabels.cols; c += 2) {
- LabelT iLabel = imgLabels_row[c];
- if (iLabel>0) {
- iLabel = P[iLabel];
- if (img_row[c] > 0){
- imgLabels_row[c] = iLabel;
- sop(r, c, iLabel);
+ if (imgLabels.rows & 1){
+ if (imgLabels.cols & 1){
+ //Case 1: both rows and cols odd
+ for (int r = 0; r < imgLabels.rows; r += 2) {
+ // Get rows pointer
+ const PixelT * const img_row = img.ptr<PixelT>(r);
+ const PixelT * const img_row_fol = (PixelT *)(((char *)img_row) + img.step.p[0]);
+ LabelT * const imgLabels_row = imgLabels.ptr<LabelT>(r);
+ LabelT * const imgLabels_row_fol = (LabelT *)(((char *)imgLabels_row) + imgLabels.step.p[0]);
+
+ for (int c = 0; c < imgLabels.cols; c += 2) {
+ LabelT iLabel = imgLabels_row[c];
+ if (iLabel > 0) {
+ iLabel = P[iLabel];
+ if (img_row[c] > 0){
+ imgLabels_row[c] = iLabel;
+ sop(r, c, iLabel);
+ }
+ else{
+ imgLabels_row[c] = 0;
+ sop(r, c, 0);
+ }
+ if (c + 1 < imgLabels.cols) {
+ if (img_row[c + 1] > 0){
+ imgLabels_row[c + 1] = iLabel;
+ sop(r, c + 1, iLabel);
+ }
+ else{
+ imgLabels_row[c + 1] = 0;
+ sop(r, c + 1, 0);
+ }
+ if (r + 1 < imgLabels.rows) {
+ if (img_row_fol[c] > 0){
+ imgLabels_row_fol[c] = iLabel;
+ sop(r + 1, c, iLabel);
+ }
+ else{
+ imgLabels_row_fol[c] = 0;
+ sop(r + 1, c, 0);
+ }
+ if (img_row_fol[c + 1] > 0){
+ imgLabels_row_fol[c + 1] = iLabel;
+ sop(r + 1, c + 1, iLabel);
+ }
+ else{
+ imgLabels_row_fol[c + 1] = 0;
+ sop(r + 1, c + 1, 0);
+ }
+ }
+ }
+ else if (r + 1 < imgLabels.rows) {
+ if (img_row_fol[c] > 0){
+ imgLabels_row_fol[c] = iLabel;
+ sop(r + 1, c, iLabel);
+ }
+ else{
+ imgLabels_row_fol[c] = 0;
+ sop(r + 1, c, 0);
+ }
+ }
}
- else{
+ else {
imgLabels_row[c] = 0;
sop(r, c, 0);
+ if (c + 1 < imgLabels.cols) {
+ imgLabels_row[c + 1] = 0;
+ sop(r, c + 1, 0);
+ if (r + 1 < imgLabels.rows) {
+ imgLabels_row_fol[c] = 0;
+ imgLabels_row_fol[c + 1] = 0;
+ sop(r + 1, c, 0);
+ sop(r + 1, c + 1, 0);
+ }
+ }
+ else if (r + 1 < imgLabels.rows) {
+ imgLabels_row_fol[c] = 0;
+ sop(r + 1, c, 0);
+ }
}
- if (c + 1<imgLabels.cols) {
+ }
+ }
+ }//END Case 1
+ else{
+ //Case 2: only rows odd
+ for (int r = 0; r < imgLabels.rows; r += 2) {
+ // Get rows pointer
+ const PixelT * const img_row = img.ptr<PixelT>(r);
+ const PixelT * const img_row_fol = (PixelT *)(((char *)img_row) + img.step.p[0]);
+ LabelT * const imgLabels_row = imgLabels.ptr<LabelT>(r);
+ LabelT * const imgLabels_row_fol = (LabelT *)(((char *)imgLabels_row) + imgLabels.step.p[0]);
+
+ for (int c = 0; c < imgLabels.cols; c += 2) {
+ LabelT iLabel = imgLabels_row[c];
+ if (iLabel > 0) {
+ iLabel = P[iLabel];
+ if (img_row[c] > 0){
+ imgLabels_row[c] = iLabel;
+ sop(r, c, iLabel);
+ }
+ else{
+ imgLabels_row[c] = 0;
+ sop(r, c, 0);
+ }
if (img_row[c + 1] > 0){
imgLabels_row[c + 1] = iLabel;
sop(r, c + 1, iLabel);
@@ -1417,297 +3756,247 @@ namespace cv{
imgLabels_row[c + 1] = 0;
sop(r, c + 1, 0);
}
- if (r + 1<imgLabels.rows) {
+ if (r + 1 < imgLabels.rows) {
if (img_row_fol[c] > 0){
imgLabels_row_fol[c] = iLabel;
sop(r + 1, c, iLabel);
- } else{
+ }
+ else{
imgLabels_row_fol[c] = 0;
sop(r + 1, c, 0);
}
- if (img_row_fol[c + 1]>0){
+ if (img_row_fol[c + 1] > 0){
imgLabels_row_fol[c + 1] = iLabel;
sop(r + 1, c + 1, iLabel);
- } else{
+ }
+ else{
imgLabels_row_fol[c + 1] = 0;
sop(r + 1, c + 1, 0);
}
- }
- }
- else if (r + 1<imgLabels.rows) {
- if (img_row_fol[c]>0){
- imgLabels_row_fol[c] = iLabel;
- sop(r + 1, c, iLabel);
- }else{
- imgLabels_row_fol[c] = 0;
- sop(r + 1, c, 0);
}
}
- }
- else {
- imgLabels_row[c] = 0;
- sop(r, c, 0);
- if (c + 1<imgLabels.cols) {
+ else {
+ imgLabels_row[c] = 0;
imgLabels_row[c + 1] = 0;
+ sop(r, c, 0);
sop(r, c + 1, 0);
- if (r + 1<imgLabels.rows) {
+ if (r + 1 < imgLabels.rows) {
imgLabels_row_fol[c] = 0;
imgLabels_row_fol[c + 1] = 0;
sop(r + 1, c, 0);
sop(r + 1, c + 1, 0);
}
- }else if (r + 1<imgLabels.rows) {
- imgLabels_row_fol[c] = 0;
- sop(r + 1, c, 0);
}
}
}
- }
- }//END Case 1
+ }// END Case 2
+ }
else{
- //Case 2: only rows odd
- for (int r = 0; r<imgLabels.rows; r += 2) {
- // Get rows pointer
- const PixelT* const img_row = img.ptr<PixelT>(r);
- const PixelT* const img_row_fol = (PixelT *)(((char *)img_row) + img.step.p[0]);
- LabelT* const imgLabels_row = imgLabels.ptr<LabelT>(r);
- LabelT* const imgLabels_row_fol = (LabelT *)(((char *)imgLabels_row) + imgLabels.step.p[0]);
-
- for (int c = 0; c<imgLabels.cols; c += 2) {
- LabelT iLabel = imgLabels_row[c];
- if (iLabel>0) {
- iLabel = P[iLabel];
- if (img_row[c]>0){
- imgLabels_row[c] = iLabel;
- sop(r, c, iLabel);
- } else{
- imgLabels_row[c] = 0;
- sop(r, c, 0);
- }
- if (img_row[c + 1]>0){
- imgLabels_row[c + 1] = iLabel;
- sop(r, c + 1, iLabel);
- }else{
- imgLabels_row[c + 1] = 0;
- sop(r, c + 1, 0);
- }
- if (r + 1<imgLabels.rows) {
- if (img_row_fol[c]>0){
+ if (imgLabels.cols & 1){
+ //Case 3: only cols odd
+ for (int r = 0; r < imgLabels.rows; r += 2) {
+ // Get rows pointer
+ const PixelT * const img_row = img.ptr<PixelT>(r);
+ const PixelT * const img_row_fol = (PixelT *)(((char *)img_row) + img.step.p[0]);
+ LabelT * const imgLabels_row = imgLabels.ptr<LabelT>(r);
+ LabelT * const imgLabels_row_fol = (LabelT *)(((char *)imgLabels_row) + imgLabels.step.p[0]);
+
+ for (int c = 0; c < imgLabels.cols; c += 2) {
+ LabelT iLabel = imgLabels_row[c];
+ if (iLabel > 0) {
+ iLabel = P[iLabel];
+ if (img_row[c] > 0){
+ imgLabels_row[c] = iLabel;
+ sop(r, c, iLabel);
+ }
+ else{
+ imgLabels_row[c] = 0;
+ sop(r, c, 0);
+ }
+ if (img_row_fol[c] > 0){
imgLabels_row_fol[c] = iLabel;
sop(r + 1, c, iLabel);
- }else{
+ }
+ else{
imgLabels_row_fol[c] = 0;
sop(r + 1, c, 0);
}
- if (img_row_fol[c + 1]>0){
- imgLabels_row_fol[c + 1] = iLabel;
- sop(r + 1, c + 1, iLabel);
- }else{
- imgLabels_row_fol[c + 1] = 0;
- sop(r + 1, c + 1, 0);
+ if (c + 1 < imgLabels.cols) {
+ if (img_row[c + 1] > 0){
+ imgLabels_row[c + 1] = iLabel;
+ sop(r, c + 1, iLabel);
+ }
+ else{
+ imgLabels_row[c + 1] = 0;
+ sop(r, c + 1, 0);
+ }
+ if (img_row_fol[c + 1] > 0){
+ imgLabels_row_fol[c + 1] = iLabel;
+ sop(r + 1, c + 1, iLabel);
+ }
+ else{
+ imgLabels_row_fol[c + 1] = 0;
+ sop(r + 1, c + 1, 0);
+ }
}
}
- }
- else {
- imgLabels_row[c] = 0;
- imgLabels_row[c + 1] = 0;
- sop(r, c, 0);
- sop(r, c + 1, 0);
- if (r + 1<imgLabels.rows) {
+ else{
+ imgLabels_row[c] = 0;
imgLabels_row_fol[c] = 0;
- imgLabels_row_fol[c + 1] = 0;
+ sop(r, c, 0);
sop(r + 1, c, 0);
- sop(r + 1, c + 1, 0);
+ if (c + 1 < imgLabels.cols) {
+ imgLabels_row[c + 1] = 0;
+ imgLabels_row_fol[c + 1] = 0;
+ sop(r, c + 1, 0);
+ sop(r + 1, c + 1, 0);
+ }
}
}
}
- }
- }// END Case 2
- }
- else{
- if (imgLabels.cols & 1){
- //Case 3: only cols odd
- for (int r = 0; r<imgLabels.rows; r += 2) {
- // Get rows pointer
- const PixelT* const img_row = img.ptr<PixelT>(r);
- const PixelT* const img_row_fol = (PixelT *)(((char *)img_row) + img.step.p[0]);
- LabelT* const imgLabels_row = imgLabels.ptr<LabelT>(r);
- LabelT* const imgLabels_row_fol = (LabelT *)(((char *)imgLabels_row) + imgLabels.step.p[0]);
-
- for (int c = 0; c<imgLabels.cols; c += 2) {
- LabelT iLabel = imgLabels_row[c];
- if (iLabel>0) {
- iLabel = P[iLabel];
- if (img_row[c]>0){
- imgLabels_row[c] = iLabel;
- sop(r, c, iLabel);
- }else{
- imgLabels_row[c] = 0;
- sop(r, c, 0);
- }
- if (img_row_fol[c]>0){
- imgLabels_row_fol[c] = iLabel;
- sop(r + 1, c, iLabel);
- }else{
- imgLabels_row_fol[c] = 0;
- sop(r + 1, c, 0);
- }
- if (c + 1<imgLabels.cols) {
- if (img_row[c + 1]>0){
+ }// END case 3
+ else{
+ //Case 4: nothing odd
+ for (int r = 0; r < imgLabels.rows; r += 2) {
+ // Get rows pointer
+ const PixelT * const img_row = img.ptr<PixelT>(r);
+ const PixelT * const img_row_fol = (PixelT *)(((char *)img_row) + img.step.p[0]);
+ LabelT * const imgLabels_row = imgLabels.ptr<LabelT>(r);
+ LabelT * const imgLabels_row_fol = (LabelT *)(((char *)imgLabels_row) + imgLabels.step.p[0]);
+
+ for (int c = 0; c < imgLabels.cols; c += 2) {
+ LabelT iLabel = imgLabels_row[c];
+ if (iLabel > 0) {
+ iLabel = P[iLabel];
+ if (img_row[c] > 0){
+ imgLabels_row[c] = iLabel;
+ sop(r, c, iLabel);
+ }
+ else{
+ imgLabels_row[c] = 0;
+ sop(r, c, 0);
+ }
+ if (img_row[c + 1] > 0){
imgLabels_row[c + 1] = iLabel;
sop(r, c + 1, iLabel);
- }else{
+ }
+ else{
imgLabels_row[c + 1] = 0;
sop(r, c + 1, 0);
}
- if (img_row_fol[c + 1]>0){
+ if (img_row_fol[c] > 0){
+ imgLabels_row_fol[c] = iLabel;
+ sop(r + 1, c, iLabel);
+ }
+ else{
+ imgLabels_row_fol[c] = 0;
+ sop(r + 1, c, 0);
+ }
+ if (img_row_fol[c + 1] > 0){
imgLabels_row_fol[c + 1] = iLabel;
sop(r + 1, c + 1, iLabel);
- }else{
+ }
+ else{
imgLabels_row_fol[c + 1] = 0;
sop(r + 1, c + 1, 0);
}
}
- }
- else{
- imgLabels_row[c] = 0;
- imgLabels_row_fol[c] = 0;
- sop(r, c, 0);
- sop(r + 1, c, 0);
- if (c + 1<imgLabels.cols) {
+ else {
+ imgLabels_row[c] = 0;
imgLabels_row[c + 1] = 0;
+ imgLabels_row_fol[c] = 0;
imgLabels_row_fol[c + 1] = 0;
- sop(r, c + 1, 0);
- sop(r + 1, c + 1, 0);
- }
- }
- }
- }
- }// END case 3
- else{
- //Case 4: nothing odd
- for (int r = 0; r < imgLabels.rows; r += 2) {
- // Get rows pointer
- const PixelT* const img_row = img.ptr<PixelT>(r);
- const PixelT* const img_row_fol = (PixelT *)(((char *)img_row) + img.step.p[0]);
- LabelT* const imgLabels_row = imgLabels.ptr<LabelT>(r);
- LabelT* const imgLabels_row_fol = (LabelT *)(((char *)imgLabels_row) + imgLabels.step.p[0]);
-
- for (int c = 0; c<imgLabels.cols; c += 2) {
- LabelT iLabel = imgLabels_row[c];
- if (iLabel>0) {
- iLabel = P[iLabel];
- if (img_row[c] > 0){
- imgLabels_row[c] = iLabel;
- sop(r, c, iLabel);
- }else{
- imgLabels_row[c] = 0;
sop(r, c, 0);
- }
- if (img_row[c + 1] > 0){
- imgLabels_row[c + 1] = iLabel;
- sop(r, c + 1, iLabel);
- }else{
- imgLabels_row[c + 1] = 0;
sop(r, c + 1, 0);
- }
- if (img_row_fol[c] > 0){
- imgLabels_row_fol[c] = iLabel;
- sop(r + 1, c, iLabel);
- }else{
- imgLabels_row_fol[c] = 0;
sop(r + 1, c, 0);
- }
- if (img_row_fol[c + 1] > 0){
- imgLabels_row_fol[c + 1] = iLabel;
- sop(r + 1, c + 1, iLabel);
- }else{
- imgLabels_row_fol[c + 1] = 0;
sop(r + 1, c + 1, 0);
}
}
- else {
- imgLabels_row[c] = 0;
- imgLabels_row[c + 1] = 0;
- imgLabels_row_fol[c] = 0;
- imgLabels_row_fol[c + 1] = 0;
- sop(r, c, 0);
- sop(r, c + 1, 0);
- sop(r + 1, c, 0);
- sop(r + 1, c + 1, 0);
- }
}
- }
- }//END case 4
- }
+ }//END case 4
+ }
- sop.finish();
- fastFree(P);
+ sop.finish();
+ fastFree(P);
- return nLabels;
+ return nLabels;
- } //End function LabelingGrana operator()
- }; //End struct LabelingGrana
-}//end namespace connectedcomponents
+ } //End function LabelingGrana operator()
+ };//End struct LabelingGrana
+ }//end namespace connectedcomponents
-//L's type must have an appropriate depth for the number of pixels in I
-template<typename StatsOp>
-static
-int connectedComponents_sub1(const cv::Mat &I, cv::Mat &L, int connectivity, int ccltype, StatsOp &sop){
- CV_Assert(L.channels() == 1 && I.channels() == 1);
- CV_Assert(connectivity == 8 || connectivity == 4);
- CV_Assert(ccltype == CCL_GRANA || ccltype == CCL_WU || ccltype == CCL_DEFAULT);
+ //L's type must have an appropriate depth for the number of pixels in I
+ template<typename StatsOp>
+ static
+ int connectedComponents_sub1(const cv::Mat& I, cv::Mat& L, int connectivity, int ccltype, StatsOp& sop){
+ CV_Assert(L.channels() == 1 && I.channels() == 1);
+ CV_Assert(connectivity == 8 || connectivity == 4);
+ CV_Assert(ccltype == CCL_GRANA || ccltype == CCL_WU || ccltype == CCL_DEFAULT);
- int lDepth = L.depth();
- int iDepth = I.depth();
+ int lDepth = L.depth();
+ int iDepth = I.depth();
+ const char *currentParallelFramework = cv::currentParallelFramework();
+ const int numberOfCPUs = cv::getNumberOfCPUs();
- CV_Assert(iDepth == CV_8U || iDepth == CV_8S);
+ CV_Assert(iDepth == CV_8U || iDepth == CV_8S);
- if (ccltype == CCL_WU || connectivity == 4){
- // Wu algorithm is used
- using connectedcomponents::LabelingWu;
- //warn if L's depth is not sufficient?
- if (lDepth == CV_8U){
- return (int)LabelingWu<uchar, uchar, StatsOp>()(I, L, connectivity, sop);
- }
- else if (lDepth == CV_16U){
- return (int)LabelingWu<ushort, uchar, StatsOp>()(I, L, connectivity, sop);
- }
- else if (lDepth == CV_32S){
- //note that signed types don't really make sense here and not being able to use unsigned matters for scientific projects
- //OpenCV: how should we proceed? .at<T> typechecks in debug mode
- return (int)LabelingWu<int, uchar, StatsOp>()(I, L, connectivity, sop);
- }
- }else if ((ccltype == CCL_GRANA || ccltype == CCL_DEFAULT) && connectivity == 8){
- // Grana algorithm is used
- using connectedcomponents::LabelingGrana;
- //warn if L's depth is not sufficient?
- if (lDepth == CV_8U){
- return (int)LabelingGrana<uchar, uchar, StatsOp>()(I, L, connectivity, sop);
- }
- else if (lDepth == CV_16U){
- return (int)LabelingGrana<ushort, uchar, StatsOp>()(I, L, connectivity, sop);
+ //Run parallel labeling only if the rows of the image are at least twice the number returned by getNumberOfCPUs
+ const bool is_parallel = currentParallelFramework != NULL && numberOfCPUs > 1 && L.rows / numberOfCPUs >= 2;
+
+ if (ccltype == CCL_WU || connectivity == 4){
+ // Wu algorithm is used
+ using connectedcomponents::LabelingWu;
+ using connectedcomponents::LabelingWuParallel;
+ //warn if L's depth is not sufficient?
+ if (lDepth == CV_8U){
+ //Not supported yet
+ }
+ else if (lDepth == CV_16U){
+ return (int)LabelingWu<ushort, uchar, StatsOp>()(I, L, connectivity, sop);
+ }
+ else if (lDepth == CV_32S){
+ //note that signed types don't really make sense here and not being able to use unsigned matters for scientific projects
+ //OpenCV: how should we proceed? .at<T> typechecks in debug mode
+ if (!is_parallel)
+ return (int)LabelingWu<int, uchar, StatsOp>()(I, L, connectivity, sop);
+ else
+ return (int)LabelingWuParallel<int, uchar, StatsOp>()(I, L, connectivity, sop);
+ }
}
- else if (lDepth == CV_32S){
- //note that signed types don't really make sense here and not being able to use unsigned matters for scientific projects
- //OpenCV: how should we proceed? .at<T> typechecks in debug mode
- return (int)LabelingGrana<int, uchar, StatsOp>()(I, L, connectivity, sop);
+ else if ((ccltype == CCL_GRANA || ccltype == CCL_DEFAULT) && connectivity == 8){
+ // Grana algorithm is used
+ using connectedcomponents::LabelingGrana;
+ using connectedcomponents::LabelingGranaParallel;
+ //warn if L's depth is not sufficient?
+ if (lDepth == CV_8U){
+ //Not supported yet
+ }
+ else if (lDepth == CV_16U){
+ return (int)LabelingGrana<ushort, uchar, StatsOp>()(I, L, connectivity, sop);
+ }
+ else if (lDepth == CV_32S){
+ //note that signed types don't really make sense here and not being able to use unsigned matters for scientific projects
+ //OpenCV: how should we proceed? .at<T> typechecks in debug mode
+ if (!is_parallel)
+ return (int)LabelingGrana<int, uchar, StatsOp>()(I, L, connectivity, sop);
+ else
+ return (int)LabelingGranaParallel<int, uchar, StatsOp>()(I, L, connectivity, sop);
+ }
}
- }
- CV_Error(CV_StsUnsupportedFormat, "unsupported label/image type");
- return -1;
-}
+ CV_Error(CV_StsUnsupportedFormat, "unsupported label/image type");
+ return -1;
+ }
}
// Simple wrapper to ensure binary and source compatibility (ABI)
-int cv::connectedComponents(InputArray _img, OutputArray _labels, int connectivity, int ltype){
- return cv::connectedComponents(_img, _labels, connectivity, ltype, CCL_DEFAULT);
+int cv::connectedComponents(InputArray img_, OutputArray _labels, int connectivity, int ltype){
+ return cv::connectedComponents(img_, _labels, connectivity, ltype, CCL_DEFAULT);
}
-int cv::connectedComponents(InputArray _img, OutputArray _labels, int connectivity, int ltype, int ccltype){
- const cv::Mat img = _img.getMat();
+int cv::connectedComponents(InputArray img_, OutputArray _labels, int connectivity, int ltype, int ccltype){
+ const cv::Mat img = img_.getMat();
_labels.create(img.size(), CV_MAT_DEPTH(ltype));
cv::Mat labels = _labels.getMat();
connectedcomponents::NoOp sop;
@@ -1724,16 +4013,16 @@ int cv::connectedComponents(InputArray _img, OutputArray _labels, int connectivi
}
// Simple wrapper to ensure binary and source compatibility (ABI)
-int cv::connectedComponentsWithStats(InputArray _img, OutputArray _labels, OutputArray statsv,
- OutputArray centroids, int connectivity, int ltype)
+int cv::connectedComponentsWithStats(InputArray img_, OutputArray _labels, OutputArray statsv,
+ OutputArray centroids, int connectivity, int ltype)
{
- return cv::connectedComponentsWithStats(_img, _labels, statsv, centroids, connectivity, ltype, CCL_DEFAULT);
+ return cv::connectedComponentsWithStats(img_, _labels, statsv, centroids, connectivity, ltype, CCL_DEFAULT);
}
-int cv::connectedComponentsWithStats(InputArray _img, OutputArray _labels, OutputArray statsv,
- OutputArray centroids, int connectivity, int ltype, int ccltype)
+int cv::connectedComponentsWithStats(InputArray img_, OutputArray _labels, OutputArray statsv,
+ OutputArray centroids, int connectivity, int ltype, int ccltype)
{
- const cv::Mat img = _img.getMat();
+ const cv::Mat img = img_.getMat();
_labels.create(img.size(), CV_MAT_DEPTH(ltype));
cv::Mat labels = _labels.getMat();
connectedcomponents::CCStatsOp sop(statsv, centroids);
diff --git a/modules/imgproc/src/contours.cpp b/modules/imgproc/src/contours.cpp
index baa27c4..ea56051 100644
--- a/modules/imgproc/src/contours.cpp
+++ b/modules/imgproc/src/contours.cpp
@@ -39,6 +39,7 @@
//
//M*/
#include "precomp.hpp"
+#include "opencv2/core/hal/intrin.hpp"
/* initializes 8-element array for fast access to 3x3 neighborhood of a pixel */
#define CV_INIT_3X3_DELTAS( deltas, step, nch ) \
@@ -50,33 +51,6 @@
static const CvPoint icvCodeDeltas[8] =
{ CvPoint(1, 0), CvPoint(1, -1), CvPoint(0, -1), CvPoint(-1, -1), CvPoint(-1, 0), CvPoint(-1, 1), CvPoint(0, 1), CvPoint(1, 1) };
-#if CV_SSE2
-static
-inline unsigned int trailingZeros(unsigned int value) {
- CV_DbgAssert(value != 0); // undefined for zero input (https://en.wikipedia.org/wiki/Find_first_set)
-#if defined(_MSC_VER)
-#if (_MSC_VER < 1700)
- unsigned long index = 0;
- _BitScanForward(&index, value);
- return (unsigned int)index;
-#else
- return _tzcnt_u32(value);
-#endif
-#elif defined(__GNUC__) || defined(__GNUG__)
- return __builtin_ctz(value);
-#elif defined(__ICC) || defined(__INTEL_COMPILER)
- return _bit_scan_forward(value);
-#elif defined(__clang__)
- return llvm.cttz.i32(value, true);
-#else
- static const int MultiplyDeBruijnBitPosition[32] = {
- 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
- 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 };
- return MultiplyDeBruijnBitPosition[((uint32_t)((value & -value) * 0x077CB531U)) >> 27];
-#endif
-}
-#endif
-
CV_IMPL void
cvStartReadChainPoints( CvChain * chain, CvChainPtReader * reader )
{
@@ -528,6 +502,7 @@ cvSubstituteContour( CvContourScanner scanner, CvSeq * new_contour )
}
}
+static const int MAX_SIZE = 16;
/*
marks domain border with +/-<constant> and stores the contour into CvSeq.
@@ -544,13 +519,13 @@ icvFetchContour( schar *ptr,
int _method )
{
const schar nbd = 2;
- int deltas[16];
+ int deltas[MAX_SIZE];
CvSeqWriter writer;
schar *i0 = ptr, *i1, *i3, *i4 = 0;
int prev_s = -1, s, s_end;
int method = _method - 1;
- assert( (unsigned) _method <= CV_CHAIN_APPROX_SIMPLE );
+ CV_DbgAssert( (unsigned) _method <= CV_CHAIN_APPROX_SIMPLE );
/* initialize local state */
CV_INIT_3X3_DELTAS( deltas, step, 1 );
@@ -587,11 +562,14 @@ icvFetchContour( schar *ptr,
/* follow border */
for( ;; )
{
+ CV_Assert(i3 != NULL);
s_end = s;
+ s = std::min(s, MAX_SIZE - 1);
- for( ;; )
+ while( s < MAX_SIZE - 1 )
{
i4 = i3 + deltas[++s];
+ CV_Assert(i4 != NULL);
if( *i4 != 0 )
break;
}
@@ -639,7 +617,7 @@ icvFetchContour( schar *ptr,
if( _method != CV_CHAIN_CODE )
cvBoundingRect( contour, 1 );
- assert( (writer.seq->total == 0 && writer.seq->first == 0) ||
+ CV_DbgAssert( (writer.seq->total == 0 && writer.seq->first == 0) ||
writer.seq->total > writer.seq->first->count ||
(writer.seq->first->prev == writer.seq->first &&
writer.seq->first->next == writer.seq->first) );
@@ -654,15 +632,15 @@ icvFetchContour( schar *ptr,
static int
icvTraceContour( schar *ptr, int step, schar *stop_ptr, int is_hole )
{
- int deltas[16];
- schar *i0 = ptr, *i1, *i3, *i4;
+ int deltas[MAX_SIZE];
+ schar *i0 = ptr, *i1, *i3, *i4 = NULL;
int s, s_end;
/* initialize local state */
CV_INIT_3X3_DELTAS( deltas, step, 1 );
memcpy( deltas + 8, deltas, 8 * sizeof( deltas[0] ));
- assert( (*i0 & -2) != 0 );
+ CV_DbgAssert( (*i0 & -2) != 0 );
s_end = s = is_hole ? 0 : 4;
@@ -681,10 +659,13 @@ icvTraceContour( schar *ptr, int step, schar *stop_ptr, int is_hole )
/* follow border */
for( ;; )
{
+ CV_Assert(i3 != NULL);
- for( ;; )
+ s = std::min(s, MAX_SIZE - 1);
+ while( s < MAX_SIZE - 1 )
{
i4 = i3 + deltas[++s];
+ CV_Assert(i4 != NULL);
if( *i4 != 0 )
break;
}
@@ -709,15 +690,15 @@ icvFetchContourEx( schar* ptr,
int nbd,
CvRect* _rect )
{
- int deltas[16];
+ int deltas[MAX_SIZE];
CvSeqWriter writer;
- schar *i0 = ptr, *i1, *i3, *i4;
+ schar *i0 = ptr, *i1, *i3, *i4 = NULL;
CvRect rect;
int prev_s = -1, s, s_end;
int method = _method - 1;
- assert( (unsigned) _method <= CV_CHAIN_APPROX_SIMPLE );
- assert( 1 < nbd && nbd < 128 );
+ CV_DbgAssert( (unsigned) _method <= CV_CHAIN_APPROX_SIMPLE );
+ CV_DbgAssert( 1 < nbd && nbd < 128 );
/* initialize local state */
CV_INIT_3X3_DELTAS( deltas, step, 1 );
@@ -758,11 +739,14 @@ icvFetchContourEx( schar* ptr,
/* follow border */
for( ;; )
{
+ CV_Assert(i3 != NULL);
s_end = s;
+ s = std::min(s, MAX_SIZE - 1);
- for( ;; )
+ while( s < MAX_SIZE - 1 )
{
i4 = i3 + deltas[++s];
+ CV_Assert(i4 != NULL);
if( *i4 != 0 )
break;
}
@@ -821,7 +805,7 @@ icvFetchContourEx( schar* ptr,
if( _method != CV_CHAIN_CODE )
((CvContour*)contour)->rect = rect;
- assert( (writer.seq->total == 0 && writer.seq->first == 0) ||
+ CV_DbgAssert( (writer.seq->total == 0 && writer.seq->first == 0) ||
writer.seq->total > writer.seq->first->count ||
(writer.seq->first->prev == writer.seq->first &&
writer.seq->first->next == writer.seq->first) );
@@ -833,8 +817,9 @@ icvFetchContourEx( schar* ptr,
static int
icvTraceContour_32s( int *ptr, int step, int *stop_ptr, int is_hole )
{
- int deltas[16];
- int *i0 = ptr, *i1, *i3, *i4;
+ CV_Assert(ptr != NULL);
+ int deltas[MAX_SIZE];
+ int *i0 = ptr, *i1, *i3, *i4 = NULL;
int s, s_end;
const int right_flag = INT_MIN;
const int new_flag = (int)((unsigned)INT_MIN >> 1);
@@ -862,11 +847,14 @@ icvTraceContour_32s( int *ptr, int step, int *stop_ptr, int is_hole )
/* follow border */
for( ;; )
{
+ CV_Assert(i3 != NULL);
s_end = s;
+ s = std::min(s, MAX_SIZE - 1);
- for( ;; )
+ while( s < MAX_SIZE - 1 )
{
i4 = i3 + deltas[++s];
+ CV_Assert(i4 != NULL);
if( (*i4 & value_mask) == ccomp_val )
break;
}
@@ -890,7 +878,8 @@ icvFetchContourEx_32s( int* ptr,
int _method,
CvRect* _rect )
{
- int deltas[16];
+ CV_Assert(ptr != NULL);
+ int deltas[MAX_SIZE];
CvSeqWriter writer;
int *i0 = ptr, *i1, *i3, *i4;
CvRect rect;
@@ -903,7 +892,7 @@ icvFetchContourEx_32s( int* ptr,
const int nbd0 = ccomp_val | new_flag;
const int nbd1 = nbd0 | right_flag;
- assert( (unsigned) _method <= CV_CHAIN_APPROX_SIMPLE );
+ CV_DbgAssert( (unsigned) _method <= CV_CHAIN_APPROX_SIMPLE );
/* initialize local state */
CV_INIT_3X3_DELTAS( deltas, step, 1 );
@@ -925,7 +914,7 @@ icvFetchContourEx_32s( int* ptr,
s = (s - 1) & 7;
i1 = i0 + deltas[s];
}
- while( (*i1 & value_mask) != ccomp_val && s != s_end );
+ while( (*i1 & value_mask) != ccomp_val && s != s_end && ( s < MAX_SIZE - 1 ) );
if( s == s_end ) /* single pixel domain */
{
@@ -943,14 +932,15 @@ icvFetchContourEx_32s( int* ptr,
/* follow border */
for( ;; )
{
+ CV_Assert(i3 != NULL);
s_end = s;
- for( ;; )
+ do
{
i4 = i3 + deltas[++s];
- if( (*i4 & value_mask) == ccomp_val )
- break;
+ CV_Assert(i4 != NULL);
}
+ while( (*i4 & value_mask) != ccomp_val && ( s < MAX_SIZE - 1 ) );
s &= 7;
/* check "right" bound */
@@ -1006,7 +996,7 @@ icvFetchContourEx_32s( int* ptr,
if( _method != CV_CHAIN_CODE )
((CvContour*)contour)->rect = rect;
- assert( (writer.seq->total == 0 && writer.seq->first == 0) ||
+ CV_DbgAssert( (writer.seq->total == 0 && writer.seq->first == 0) ||
writer.seq->total > writer.seq->first->count ||
(writer.seq->first->prev == writer.seq->first &&
writer.seq->first->next == writer.seq->first) );
@@ -1093,12 +1083,12 @@ cvFindNextContour( CvContourScanner scanner )
mask2 ^= 0x0000ffff;
if (mask1) {
- p = img[(x += trailingZeros(mask1))];
+ p = img[(x += cv::trailingZeros32(mask1))];
goto _next_contour;
}
if (mask2) {
- p = img[(x += trailingZeros(mask2 << 16))];
+ p = img[(x += cv::trailingZeros32(mask2 << 16))];
goto _next_contour;
}
}
@@ -1109,7 +1099,7 @@ cvFindNextContour( CvContourScanner scanner )
unsigned int mask = _mm_movemask_epi8(_mm_cmpeq_epi8(v_p, v_prev)) ^ 0x0000ffff;
if (mask) {
- p = img[(x += trailingZeros(mask))];
+ p = img[(x += cv::trailingZeros32(mask))];
goto _next_contour;
}
x += 16;
@@ -1189,7 +1179,7 @@ cvFindNextContour( CvContourScanner scanner )
cur = cur->next;
}
- assert( par_info != 0 );
+ CV_Assert( par_info != 0 );
/* if current contour is a hole and previous contour is a hole or
current contour is external and previous contour is external then
@@ -1390,12 +1380,12 @@ inline int findStartContourPoint(uchar *src_data, CvSize img_size, int j, bool h
mask2 ^= 0x0000ffff;
if (mask1) {
- j += trailingZeros(mask1);
+ j += cv::trailingZeros32(mask1);
return j;
}
if (mask2) {
- j += trailingZeros(mask2 << 16);
+ j += cv::trailingZeros32(mask2 << 16);
return j;
}
}
@@ -1406,7 +1396,7 @@ inline int findStartContourPoint(uchar *src_data, CvSize img_size, int j, bool h
unsigned int mask = _mm_movemask_epi8(_mm_cmpeq_epi8(v_p, v_zero)) ^ 0x0000ffff;
if (mask) {
- j += trailingZeros(mask);
+ j += cv::trailingZeros32(mask);
return j;
}
j += 16;
@@ -1439,12 +1429,12 @@ inline int findEndContourPoint(uchar *src_data, CvSize img_size, int j, bool hav
unsigned int mask2 = _mm_movemask_epi8(v_cmp2);
if (mask1) {
- j += trailingZeros(mask1);
+ j += cv::trailingZeros32(mask1);
return j;
}
if (mask2) {
- j += trailingZeros(mask2 << 16);
+ j += cv::trailingZeros32(mask2 << 16);
return j;
}
}
@@ -1455,7 +1445,7 @@ inline int findEndContourPoint(uchar *src_data, CvSize img_size, int j, bool hav
unsigned int mask = _mm_movemask_epi8(_mm_cmpeq_epi8(v_p, v_zero));
if (mask) {
- j += trailingZeros(mask);
+ j += cv::trailingZeros32(mask);
return j;
}
j += 16;
diff --git a/modules/imgproc/src/convhull.cpp b/modules/imgproc/src/convhull.cpp
index 1f8ef7b..e56d3cb 100644
--- a/modules/imgproc/src/convhull.cpp
+++ b/modules/imgproc/src/convhull.cpp
@@ -404,9 +404,6 @@ CV_IMPL CvSeq*
cvConvexHull2( const CvArr* array, void* hull_storage,
int orientation, int return_points )
{
- union { CvContour* c; CvSeq* s; } hull;
- hull.s = 0;
-
CvMat* mat = 0;
CvContour contour_header;
CvSeq hull_header;
@@ -427,7 +424,9 @@ cvConvexHull2( const CvArr* array, void* hull_storage,
ptseq = cvPointSeqFromMat( CV_SEQ_KIND_GENERIC, array, &contour_header, &block );
}
- if( CV_IS_STORAGE( hull_storage ))
+ bool isStorage = isStorageOrMat(hull_storage);
+
+ if(isStorage)
{
if( return_points )
{
@@ -445,9 +444,6 @@ cvConvexHull2( const CvArr* array, void* hull_storage,
}
else
{
- if( !CV_IS_MAT( hull_storage ))
- CV_Error(CV_StsBadArg, "Destination must be valid memory storage or matrix");
-
mat = (CvMat*)hull_storage;
if( (mat->cols != 1 && mat->rows != 1) || !CV_IS_MAT_CONT(mat->type))
@@ -473,10 +469,10 @@ cvConvexHull2( const CvArr* array, void* hull_storage,
int total = ptseq->total;
if( total == 0 )
{
- if( mat )
+ if( !isStorage )
CV_Error( CV_StsBadSize,
"Point sequence can not be empty if the output is matrix" );
- return hull.s;
+ return 0;
}
cv::AutoBuffer<double> _ptbuf;
@@ -498,22 +494,18 @@ cvConvexHull2( const CvArr* array, void* hull_storage,
else
cvSeqPushMulti(hullseq, h0.ptr(), (int)h0.total());
- if( mat )
+ if (isStorage)
+ {
+ return hullseq;
+ }
+ else
{
if( mat->rows > mat->cols )
mat->rows = hullseq->total;
else
mat->cols = hullseq->total;
+ return 0;
}
- else
- {
- hull.s = hullseq;
- hull.c->rect = cvBoundingRect( ptseq,
- ptseq->header_size < (int)sizeof(CvContour) ||
- &ptseq->flags == &contour_header.flags );
- }
-
- return hull.s;
}
@@ -584,7 +576,7 @@ CV_IMPL CvSeq* cvConvexityDefects( const CvArr* array,
hull = cvMakeSeqHeaderForArray(
CV_SEQ_KIND_CURVE|CV_MAT_TYPE(mat->type)|CV_SEQ_FLAG_CLOSED,
- sizeof(CvContour), CV_ELEM_SIZE(mat->type), mat->data.ptr,
+ sizeof(hull_header), CV_ELEM_SIZE(mat->type), mat->data.ptr,
mat->cols + mat->rows - 1, &hull_header, &hullblock );
}
@@ -664,6 +656,7 @@ CV_IMPL CvSeq* cvConvexityDefects( const CvArr* array,
int t = *(int*)hull_reader.ptr;
hull_next = CV_GET_SEQ_ELEM( CvPoint, ptseq, t );
}
+ CV_Assert(hull_next != NULL && hull_cur != NULL);
dx0 = (double)hull_next->x - (double)hull_cur->x;
dy0 = (double)hull_next->y - (double)hull_cur->y;
diff --git a/modules/imgproc/src/corner.avx.cpp b/modules/imgproc/src/corner.avx.cpp
new file mode 100644
index 0000000..a40b66d
--- /dev/null
+++ b/modules/imgproc/src/corner.avx.cpp
@@ -0,0 +1,181 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
+// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
+// Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "precomp.hpp"
+#include "opencv2/core/hal/intrin.hpp"
+#include "corner.hpp"
+
+namespace cv
+{
+
+// load three 8-packed float vector and deinterleave
+// probably it's better to write down somewhere else
+static void load_deinterleave(const float* ptr, __m256& a, __m256& b, __m256& c)
+{
+ __m256 s0 = _mm256_loadu_ps(ptr); // a0, b0, c0, a1, b1, c1, a2, b2,
+ __m256 s1 = _mm256_loadu_ps(ptr + 8); // c2, a3, b3, c3, a4, b4, c4, a5,
+ __m256 s2 = _mm256_loadu_ps(ptr + 16); // b5, c5, a6, b6, c6, a7, b7, c7,
+ __m256 s3 = _mm256_permute2f128_ps(s1, s2, 0x21); // a4, b4, c4, a5, b5, c5, a6, b6,
+ __m256 s4 = _mm256_permute2f128_ps(s2, s2, 0x33); // c6, a7, b7, c7, c6, a7, b7, c7,
+
+ __m256 v00 = _mm256_unpacklo_ps(s0, s3); // a0, a4, b0, b4, b1, b5, c1, c5,
+ __m256 v01 = _mm256_unpackhi_ps(s0, s3); // c0, c4, a1, a5, a2, a6, b2, b6,
+ __m256 v02 = _mm256_unpacklo_ps(s1, s4); // c2, c6, a3, a7, x, x, x, x,
+ __m256 v03 = _mm256_unpackhi_ps(s1, s4); // b3, b7, c3, c7, x, x, x, x,
+ __m256 v04 = _mm256_permute2f128_ps(v02, v03, 0x20); // c2, c6, a3, a7, b3, b7, c3, c7,
+ __m256 v05 = _mm256_permute2f128_ps(v01, v03, 0x21); // a2, a6, b2, b6, b3, b7, c3, c7,
+
+ __m256 v10 = _mm256_unpacklo_ps(v00, v05); // a0, a2, a4, a6, b1, b3, b5, b7,
+ __m256 v11 = _mm256_unpackhi_ps(v00, v05); // b0, b2, b4, b6, c1, c3, c5, c7,
+ __m256 v12 = _mm256_unpacklo_ps(v01, v04); // c0, c2, c4, c6, x, x, x, x,
+ __m256 v13 = _mm256_unpackhi_ps(v01, v04); // a1, a3, a5, a7, x, x, x, x,
+ __m256 v14 = _mm256_permute2f128_ps(v11, v12, 0x20); // b0, b2, b4, b6, c0, c2, c4, c6,
+ __m256 v15 = _mm256_permute2f128_ps(v10, v11, 0x31); // b1, b3, b5, b7, c1, c3, c5, c7,
+
+ __m256 v20 = _mm256_unpacklo_ps(v14, v15); // b0, b1, b2, b3, c0, c1, c2, c3,
+ __m256 v21 = _mm256_unpackhi_ps(v14, v15); // b4, b5, b6, b7, c4, c5, c6, c7,
+ __m256 v22 = _mm256_unpacklo_ps(v10, v13); // a0, a1, a2, a3, x, x, x, x,
+ __m256 v23 = _mm256_unpackhi_ps(v10, v13); // a4, a5, a6, a7, x, x, x, x,
+
+ a = _mm256_permute2f128_ps(v22, v23, 0x20); // a0, a1, a2, a3, a4, a5, a6, a7,
+ b = _mm256_permute2f128_ps(v20, v21, 0x20); // b0, b1, b2, b3, b4, b5, b6, b7,
+ c = _mm256_permute2f128_ps(v20, v21, 0x31); // c0, c1, c2, c3, c4, c5, c6, c7,
+}
+
+// realign four 3-packed vector to three 4-packed vector
+static void v_pack4x3to3x4(const __m128i& s0, const __m128i& s1, const __m128i& s2, const __m128i& s3, __m128i& d0, __m128i& d1, __m128i& d2)
+{
+ d0 = _mm_or_si128(s0, _mm_slli_si128(s1, 12));
+ d1 = _mm_or_si128(_mm_srli_si128(s1, 4), _mm_slli_si128(s2, 8));
+ d2 = _mm_or_si128(_mm_srli_si128(s2, 8), _mm_slli_si128(s3, 4));
+}
+
+// separate high and low 128 bit and cast to __m128i
+static void v_separate_lo_hi(const __m256& src, __m128i& lo, __m128i& hi)
+{
+ lo = _mm_castps_si128(_mm256_castps256_ps128(src));
+ hi = _mm_castps_si128(_mm256_extractf128_ps(src, 1));
+}
+
+// interleave three 8-float vector and store
+static void store_interleave(float* ptr, const __m256& a, const __m256& b, const __m256& c)
+{
+ __m128i a0, a1, b0, b1, c0, c1;
+ v_separate_lo_hi(a, a0, a1);
+ v_separate_lo_hi(b, b0, b1);
+ v_separate_lo_hi(c, c0, c1);
+
+ v_uint32x4 z = v_setzero_u32();
+ v_uint32x4 u0, u1, u2, u3;
+ v_transpose4x4(v_uint32x4(a0), v_uint32x4(b0), v_uint32x4(c0), z, u0, u1, u2, u3);
+ v_pack4x3to3x4(u0.val, u1.val, u2.val, u3.val, a0, b0, c0);
+ v_transpose4x4(v_uint32x4(a1), v_uint32x4(b1), v_uint32x4(c1), z, u0, u1, u2, u3);
+ v_pack4x3to3x4(u0.val, u1.val, u2.val, u3.val, a1, b1, c1);
+
+#if !defined(__GNUC__) || defined(__INTEL_COMPILER)
+ _mm256_storeu_ps(ptr, _mm256_setr_m128(_mm_castsi128_ps(a0), _mm_castsi128_ps(b0)));
+ _mm256_storeu_ps(ptr + 8, _mm256_setr_m128(_mm_castsi128_ps(c0), _mm_castsi128_ps(a1)));
+ _mm256_storeu_ps(ptr + 16, _mm256_setr_m128(_mm_castsi128_ps(b1), _mm_castsi128_ps(c1)));
+#else
+ // GCC: workaround for missing AVX intrinsic: "_mm256_setr_m128()"
+ _mm256_storeu_ps(ptr, _mm256_insertf128_ps(_mm256_castps128_ps256(_mm_castsi128_ps(a0)), _mm_castsi128_ps(b0), 1));
+ _mm256_storeu_ps(ptr + 8, _mm256_insertf128_ps(_mm256_castps128_ps256(_mm_castsi128_ps(c0)), _mm_castsi128_ps(a1), 1));
+ _mm256_storeu_ps(ptr + 16, _mm256_insertf128_ps(_mm256_castps128_ps256(_mm_castsi128_ps(b1)), _mm_castsi128_ps(c1), 1));
+#endif
+}
+
+int calcMinEigenValLine_AVX(const float* cov, float* dst, int width)
+{
+ int j = 0;
+ __m256 half = _mm256_set1_ps(0.5f);
+ for (; j <= width - 8; j += 8)
+ {
+ __m256 v_a, v_b, v_c, v_t;
+ load_deinterleave(cov + j * 3, v_a, v_b, v_c);
+ v_a = _mm256_mul_ps(v_a, half);
+ v_c = _mm256_mul_ps(v_c, half);
+ v_t = _mm256_sub_ps(v_a, v_c);
+ v_t = _mm256_add_ps(_mm256_mul_ps(v_b, v_b), _mm256_mul_ps(v_t, v_t));
+ _mm256_storeu_ps(dst + j, _mm256_sub_ps(_mm256_add_ps(v_a, v_c), _mm256_sqrt_ps(v_t)));
+ }
+ return j;
+}
+
+int calcHarrisLine_AVX(const float* cov, float* dst, double k, int width)
+{
+ int j = 0;
+ __m256 v_k = _mm256_set1_ps((float)k);
+
+ for (; j <= width - 8; j += 8)
+ {
+ __m256 v_a, v_b, v_c;
+ load_deinterleave(cov + j * 3, v_a, v_b, v_c);
+
+ __m256 v_ac_bb = _mm256_sub_ps(_mm256_mul_ps(v_a, v_c), _mm256_mul_ps(v_b, v_b));
+ __m256 v_ac = _mm256_add_ps(v_a, v_c);
+ __m256 v_dst = _mm256_sub_ps(v_ac_bb, _mm256_mul_ps(v_k, _mm256_mul_ps(v_ac, v_ac)));
+ _mm256_storeu_ps(dst + j, v_dst);
+ }
+ return j;
+}
+
+int cornerEigenValsVecsLine_AVX(const float* dxdata, const float* dydata, float* cov_data, int width)
+{
+ int j = 0;
+ for (; j <= width - 8; j += 8)
+ {
+ __m256 v_dx = _mm256_loadu_ps(dxdata + j);
+ __m256 v_dy = _mm256_loadu_ps(dydata + j);
+
+ __m256 v_dst0, v_dst1, v_dst2;
+ v_dst0 = _mm256_mul_ps(v_dx, v_dx);
+ v_dst1 = _mm256_mul_ps(v_dx, v_dy);
+ v_dst2 = _mm256_mul_ps(v_dy, v_dy);
+
+ store_interleave(cov_data + j * 3, v_dst0, v_dst1, v_dst2);
+ }
+ return j;
+}
+
+}
+/* End of file */
diff --git a/modules/imgproc/src/corner.cpp b/modules/imgproc/src/corner.cpp
index 7f3bad5..e784fa2 100644
--- a/modules/imgproc/src/corner.cpp
+++ b/modules/imgproc/src/corner.cpp
@@ -43,6 +43,8 @@
#include "precomp.hpp"
#include "opencl_kernels_imgproc.hpp"
+#include "opencv2/core/hal/intrin.hpp"
+#include "corner.hpp"
namespace cv
{
@@ -51,8 +53,11 @@ static void calcMinEigenVal( const Mat& _cov, Mat& _dst )
{
int i, j;
Size size = _cov.size();
-#if CV_SSE
- volatile bool simd = checkHardwareSupport(CV_CPU_SSE);
+#if CV_TRY_AVX
+ bool haveAvx = CV_CPU_HAS_SUPPORT_AVX;
+#endif
+#if CV_SIMD128
+ bool haveSimd = hasSIMD128();
#endif
if( _cov.isContinuous() && _dst.isContinuous() )
@@ -65,46 +70,30 @@ static void calcMinEigenVal( const Mat& _cov, Mat& _dst )
{
const float* cov = _cov.ptr<float>(i);
float* dst = _dst.ptr<float>(i);
- j = 0;
- #if CV_SSE
- if( simd )
+#if CV_TRY_AVX
+ if( haveAvx )
+ j = calcMinEigenValLine_AVX(cov, dst, size.width);
+ else
+#endif // CV_TRY_AVX
+ j = 0;
+
+#if CV_SIMD128
+ if( haveSimd )
{
- __m128 half = _mm_set1_ps(0.5f);
- for( ; j <= size.width - 4; j += 4 )
+ v_float32x4 half = v_setall_f32(0.5f);
+ for( ; j <= size.width - v_float32x4::nlanes; j += v_float32x4::nlanes )
{
- __m128 t0 = _mm_loadu_ps(cov + j*3); // a0 b0 c0 x
- __m128 t1 = _mm_loadu_ps(cov + j*3 + 3); // a1 b1 c1 x
- __m128 t2 = _mm_loadu_ps(cov + j*3 + 6); // a2 b2 c2 x
- __m128 t3 = _mm_loadu_ps(cov + j*3 + 9); // a3 b3 c3 x
- __m128 a, b, c, t;
- t = _mm_unpacklo_ps(t0, t1); // a0 a1 b0 b1
- c = _mm_unpackhi_ps(t0, t1); // c0 c1 x x
- b = _mm_unpacklo_ps(t2, t3); // a2 a3 b2 b3
- c = _mm_movelh_ps(c, _mm_unpackhi_ps(t2, t3)); // c0 c1 c2 c3
- a = _mm_movelh_ps(t, b);
- b = _mm_movehl_ps(b, t);
- a = _mm_mul_ps(a, half);
- c = _mm_mul_ps(c, half);
- t = _mm_sub_ps(a, c);
- t = _mm_add_ps(_mm_mul_ps(t, t), _mm_mul_ps(b,b));
- a = _mm_sub_ps(_mm_add_ps(a, c), _mm_sqrt_ps(t));
- _mm_storeu_ps(dst + j, a);
+ v_float32x4 v_a, v_b, v_c, v_t;
+ v_load_deinterleave(cov + j*3, v_a, v_b, v_c);
+ v_a *= half;
+ v_c *= half;
+ v_t = v_a - v_c;
+ v_t = v_muladd(v_b, v_b, (v_t * v_t));
+ v_store(dst + j, (v_a + v_c) - v_sqrt(v_t));
}
}
- #elif CV_NEON
- float32x4_t v_half = vdupq_n_f32(0.5f);
- for( ; j <= size.width - 4; j += 4 )
- {
- float32x4x3_t v_src = vld3q_f32(cov + j * 3);
- float32x4_t v_a = vmulq_f32(v_src.val[0], v_half);
- float32x4_t v_b = v_src.val[1];
- float32x4_t v_c = vmulq_f32(v_src.val[2], v_half);
-
- float32x4_t v_t = vsubq_f32(v_a, v_c);
- v_t = vmlaq_f32(vmulq_f32(v_t, v_t), v_b, v_b);
- vst1q_f32(dst + j, vsubq_f32(vaddq_f32(v_a, v_c), cv_vsqrtq_f32(v_t)));
- }
- #endif
+#endif // CV_SIMD128
+
for( ; j < size.width; j++ )
{
float a = cov[j*3]*0.5f;
@@ -120,8 +109,11 @@ static void calcHarris( const Mat& _cov, Mat& _dst, double k )
{
int i, j;
Size size = _cov.size();
-#if CV_SSE
- volatile bool simd = checkHardwareSupport(CV_CPU_SSE);
+#if CV_TRY_AVX
+ bool haveAvx = CV_CPU_HAS_SUPPORT_AVX;
+#endif
+#if CV_SIMD128
+ bool haveSimd = hasSIMD128();
#endif
if( _cov.isContinuous() && _dst.isContinuous() )
@@ -134,44 +126,31 @@ static void calcHarris( const Mat& _cov, Mat& _dst, double k )
{
const float* cov = _cov.ptr<float>(i);
float* dst = _dst.ptr<float>(i);
- j = 0;
- #if CV_SSE
- if( simd )
+#if CV_TRY_AVX
+ if( haveAvx )
+ j = calcHarrisLine_AVX(cov, dst, k, size.width);
+ else
+#endif // CV_TRY_AVX
+ j = 0;
+
+#if CV_SIMD128
+ if( haveSimd )
{
- __m128 k4 = _mm_set1_ps((float)k);
- for( ; j <= size.width - 4; j += 4 )
+ v_float32x4 v_k = v_setall_f32((float)k);
+
+ for( ; j <= size.width - v_float32x4::nlanes; j += v_float32x4::nlanes )
{
- __m128 t0 = _mm_loadu_ps(cov + j*3); // a0 b0 c0 x
- __m128 t1 = _mm_loadu_ps(cov + j*3 + 3); // a1 b1 c1 x
- __m128 t2 = _mm_loadu_ps(cov + j*3 + 6); // a2 b2 c2 x
- __m128 t3 = _mm_loadu_ps(cov + j*3 + 9); // a3 b3 c3 x
- __m128 a, b, c, t;
- t = _mm_unpacklo_ps(t0, t1); // a0 a1 b0 b1
- c = _mm_unpackhi_ps(t0, t1); // c0 c1 x x
- b = _mm_unpacklo_ps(t2, t3); // a2 a3 b2 b3
- c = _mm_movelh_ps(c, _mm_unpackhi_ps(t2, t3)); // c0 c1 c2 c3
- a = _mm_movelh_ps(t, b);
- b = _mm_movehl_ps(b, t);
- t = _mm_add_ps(a, c);
- a = _mm_sub_ps(_mm_mul_ps(a, c), _mm_mul_ps(b, b));
- t = _mm_mul_ps(_mm_mul_ps(k4, t), t);
- a = _mm_sub_ps(a, t);
- _mm_storeu_ps(dst + j, a);
- }
- }
- #elif CV_NEON
- float32x4_t v_k = vdupq_n_f32((float)k);
+ v_float32x4 v_a, v_b, v_c;
+ v_load_deinterleave(cov + j * 3, v_a, v_b, v_c);
- for( ; j <= size.width - 4; j += 4 )
- {
- float32x4x3_t v_src = vld3q_f32(cov + j * 3);
- float32x4_t v_a = v_src.val[0], v_b = v_src.val[1], v_c = v_src.val[2];
- float32x4_t v_ac_bb = vmlsq_f32(vmulq_f32(v_a, v_c), v_b, v_b);
- float32x4_t v_ac = vaddq_f32(v_a, v_c);
- vst1q_f32(dst + j, vmlsq_f32(v_ac_bb, v_k, vmulq_f32(v_ac, v_ac)));
+ v_float32x4 v_ac_bb = v_a * v_c - v_b * v_b;
+ v_float32x4 v_ac = v_a + v_c;
+ v_float32x4 v_dst = v_ac_bb - v_k * v_ac * v_ac;
+ v_store(dst + j, v_dst);
+ }
}
- #endif
+#endif // CV_SIMD128
for( ; j < size.width; j++ )
{
@@ -272,8 +251,11 @@ cornerEigenValsVecs( const Mat& src, Mat& eigenv, int block_size,
if (tegra::useTegra() && tegra::cornerEigenValsVecs(src, eigenv, block_size, aperture_size, op_type, k, borderType))
return;
#endif
-#if CV_SSE2
- bool haveSSE2 = checkHardwareSupport(CV_CPU_SSE2);
+#if CV_TRY_AVX
+ bool haveAvx = CV_CPU_HAS_SUPPORT_AVX;
+#endif
+#if CV_SIMD128
+ bool haveSimd = hasSIMD128();
#endif
int depth = src.depth();
@@ -307,49 +289,31 @@ cornerEigenValsVecs( const Mat& src, Mat& eigenv, int block_size,
float* cov_data = cov.ptr<float>(i);
const float* dxdata = Dx.ptr<float>(i);
const float* dydata = Dy.ptr<float>(i);
- j = 0;
- #if CV_NEON
- for( ; j <= size.width - 4; j += 4 )
- {
- float32x4_t v_dx = vld1q_f32(dxdata + j);
- float32x4_t v_dy = vld1q_f32(dydata + j);
-
- float32x4x3_t v_dst;
- v_dst.val[0] = vmulq_f32(v_dx, v_dx);
- v_dst.val[1] = vmulq_f32(v_dx, v_dy);
- v_dst.val[2] = vmulq_f32(v_dy, v_dy);
+#if CV_TRY_AVX
+ if( haveAvx )
+ j = cornerEigenValsVecsLine_AVX(dxdata, dydata, cov_data, size.width);
+ else
+#endif // CV_TRY_AVX
+ j = 0;
- vst3q_f32(cov_data + j * 3, v_dst);
- }
- #elif CV_SSE2
- if (haveSSE2)
+#if CV_SIMD128
+ if( haveSimd )
{
- for( ; j <= size.width - 8; j += 8 )
+ for( ; j <= size.width - v_float32x4::nlanes; j += v_float32x4::nlanes )
{
- __m128 v_dx_0 = _mm_loadu_ps(dxdata + j);
- __m128 v_dx_1 = _mm_loadu_ps(dxdata + j + 4);
- __m128 v_dy_0 = _mm_loadu_ps(dydata + j);
- __m128 v_dy_1 = _mm_loadu_ps(dydata + j + 4);
-
- __m128 v_dx2_0 = _mm_mul_ps(v_dx_0, v_dx_0);
- __m128 v_dxy_0 = _mm_mul_ps(v_dx_0, v_dy_0);
- __m128 v_dy2_0 = _mm_mul_ps(v_dy_0, v_dy_0);
- __m128 v_dx2_1 = _mm_mul_ps(v_dx_1, v_dx_1);
- __m128 v_dxy_1 = _mm_mul_ps(v_dx_1, v_dy_1);
- __m128 v_dy2_1 = _mm_mul_ps(v_dy_1, v_dy_1);
-
- _mm_interleave_ps(v_dx2_0, v_dx2_1, v_dxy_0, v_dxy_1, v_dy2_0, v_dy2_1);
-
- _mm_storeu_ps(cov_data + j * 3, v_dx2_0);
- _mm_storeu_ps(cov_data + j * 3 + 4, v_dx2_1);
- _mm_storeu_ps(cov_data + j * 3 + 8, v_dxy_0);
- _mm_storeu_ps(cov_data + j * 3 + 12, v_dxy_1);
- _mm_storeu_ps(cov_data + j * 3 + 16, v_dy2_0);
- _mm_storeu_ps(cov_data + j * 3 + 20, v_dy2_1);
+ v_float32x4 v_dx = v_load(dxdata + j);
+ v_float32x4 v_dy = v_load(dydata + j);
+
+ v_float32x4 v_dst0, v_dst1, v_dst2;
+ v_dst0 = v_dx * v_dx;
+ v_dst1 = v_dx * v_dy;
+ v_dst2 = v_dy * v_dy;
+
+ v_store_interleave(cov_data + j * 3, v_dst0, v_dst1, v_dst2);
}
}
- #endif
+#endif // CV_SIMD128
for( ; j < size.width; j++ )
{
@@ -528,9 +492,9 @@ namespace cv
{
static bool ipp_cornerMinEigenVal( InputArray _src, OutputArray _dst, int blockSize, int ksize, int borderType )
{
+#if IPP_VERSION_X100 >= 800
CV_INSTRUMENT_REGION_IPP()
-#if IPP_VERSION_X100 >= 800
Mat src = _src.getMat();
_dst.create( src.size(), CV_32FC1 );
Mat dst = _dst.getMat();
@@ -627,15 +591,11 @@ void cv::cornerMinEigenVal( InputArray _src, OutputArray _dst, int blockSize, in
#if defined(HAVE_IPP)
namespace cv
{
-static bool ipp_cornerHarris( InputArray _src, OutputArray _dst, int blockSize, int ksize, double k, int borderType )
+static bool ipp_cornerHarris( Mat &src, Mat &dst, int blockSize, int ksize, double k, int borderType )
{
+#if IPP_VERSION_X100 >= 810
CV_INSTRUMENT_REGION_IPP()
-#if IPP_VERSION_X100 >= 810 && IPP_DISABLE_BLOCK
- Mat src = _src.getMat();
- _dst.create( src.size(), CV_32FC1 );
- Mat dst = _dst.getMat();
-
{
int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
int borderTypeNI = borderType & ~BORDER_ISOLATED;
@@ -658,17 +618,17 @@ static bool ipp_cornerHarris( InputArray _src, OutputArray _dst, int blockSize,
if (ippiHarrisCornerGetBufferSize(roisize, masksize, blockSize, datatype, cn, &bufsize) >= 0)
{
- Ipp8u * buffer = ippsMalloc_8u(bufsize);
+ Ipp8u * buffer = (Ipp8u*)CV_IPP_MALLOC(bufsize);
IppiDifferentialKernel filterType = ksize > 0 ? ippFilterSobel : ippFilterScharr;
IppiBorderType borderTypeIpp = borderTypeNI == BORDER_CONSTANT ? ippBorderConst : ippBorderRepl;
IppStatus status = (IppStatus)-1;
if (depth == CV_8U)
- status = CV_INSTRUMENT_FUN_IPP(ippiHarrisCorner_8u32f_C1R,((const Ipp8u *)src.data, (int)src.step, (Ipp32f *)dst.data, (int)dst.step, roisize,
- filterType, masksize, blockSize, (Ipp32f)k, (Ipp32f)scale, borderTypeIpp, 0, buffer));
+ status = CV_INSTRUMENT_FUN_IPP(ippiHarrisCorner_8u32f_C1R, (const Ipp8u *)src.data, (int)src.step, (Ipp32f *)dst.data, (int)dst.step, roisize,
+ filterType, masksize, blockSize, (Ipp32f)k, (Ipp32f)scale, borderTypeIpp, 0, buffer);
else if (depth == CV_32F)
- status = CV_INSTRUMENT_FUN_IPP(ippiHarrisCorner_32f_C1R,((const Ipp32f *)src.data, (int)src.step, (Ipp32f *)dst.data, (int)dst.step, roisize,
- filterType, masksize, blockSize, (Ipp32f)k, (Ipp32f)scale, borderTypeIpp, 0, buffer));
+ status = CV_INSTRUMENT_FUN_IPP(ippiHarrisCorner_32f_C1R, (const Ipp32f *)src.data, (int)src.step, (Ipp32f *)dst.data, (int)dst.step, roisize,
+ filterType, masksize, blockSize, (Ipp32f)k, (Ipp32f)scale, borderTypeIpp, 0, buffer);
ippsFree(buffer);
if (status >= 0)
@@ -680,7 +640,7 @@ static bool ipp_cornerHarris( InputArray _src, OutputArray _dst, int blockSize,
}
}
#else
- CV_UNUSED(_src); CV_UNUSED(_dst); CV_UNUSED(blockSize); CV_UNUSED(ksize); CV_UNUSED(k); CV_UNUSED(borderType);
+ CV_UNUSED(src); CV_UNUSED(dst); CV_UNUSED(blockSize); CV_UNUSED(ksize); CV_UNUSED(k); CV_UNUSED(borderType);
#endif
return false;
}
@@ -694,19 +654,17 @@ void cv::cornerHarris( InputArray _src, OutputArray _dst, int blockSize, int ksi
CV_OCL_RUN(_src.dims() <= 2 && _dst.isUMat(),
ocl_cornerMinEigenValVecs(_src, _dst, blockSize, ksize, k, borderType, HARRIS))
+ Mat src = _src.getMat();
+ _dst.create( src.size(), CV_32FC1 );
+ Mat dst = _dst.getMat();
+
#ifdef HAVE_IPP
int borderTypeNI = borderType & ~BORDER_ISOLATED;
bool isolated = (borderType & BORDER_ISOLATED) != 0;
#endif
CV_IPP_RUN(((ksize == 3 || ksize == 5) && (_src.type() == CV_8UC1 || _src.type() == CV_32FC1) &&
(borderTypeNI == BORDER_CONSTANT || borderTypeNI == BORDER_REPLICATE) && CV_MAT_CN(_src.type()) == 1 &&
- (!_src.isSubmatrix() || isolated)) && IPP_VERSION_X100 >= 810 && IPP_DISABLE_BLOCK, ipp_cornerHarris( _src, _dst, blockSize, ksize, k, borderType ));
-
-
- Mat src = _src.getMat();
- _dst.create( src.size(), CV_32FC1 );
- Mat dst = _dst.getMat();
-
+ (!_src.isSubmatrix() || isolated)) && IPP_VERSION_X100 >= 810, ipp_cornerHarris( src, dst, blockSize, ksize, k, borderType ));
cornerEigenValsVecs( src, dst, blockSize, ksize, HARRIS, k, borderType );
}
@@ -751,13 +709,10 @@ void cv::preCornerDetect( InputArray _src, OutputArray _dst, int ksize, int bord
if( src.depth() == CV_8U )
factor *= 255;
factor = 1./(factor * factor * factor);
-#if CV_NEON || CV_SSE2
+#if CV_SIMD128
float factor_f = (float)factor;
-#endif
-
-#if CV_SSE2
- volatile bool haveSSE2 = cv::checkHardwareSupport(CV_CPU_SSE2);
- __m128 v_factor = _mm_set1_ps(factor_f), v_m2 = _mm_set1_ps(-2.0f);
+ bool haveSimd = hasSIMD128();
+ v_float32x4 v_factor = v_setall_f32(factor_f), v_m2 = v_setall_f32(-2.0f);
#endif
Size size = src.size();
@@ -773,30 +728,21 @@ void cv::preCornerDetect( InputArray _src, OutputArray _dst, int ksize, int bord
j = 0;
-#if CV_SSE2
- if (haveSSE2)
+#if CV_SIMD128
+ if (haveSimd)
{
- for( ; j <= size.width - 4; j += 4 )
+ for( ; j <= size.width - v_float32x4::nlanes; j += v_float32x4::nlanes )
{
- __m128 v_dx = _mm_loadu_ps((const float *)(dxdata + j));
- __m128 v_dy = _mm_loadu_ps((const float *)(dydata + j));
-
- __m128 v_s1 = _mm_mul_ps(_mm_mul_ps(v_dx, v_dx), _mm_loadu_ps((const float *)(d2ydata + j)));
- __m128 v_s2 = _mm_mul_ps(_mm_mul_ps(v_dy, v_dy), _mm_loadu_ps((const float *)(d2xdata + j)));
- __m128 v_s3 = _mm_mul_ps(_mm_mul_ps(v_dx, v_dy), _mm_loadu_ps((const float *)(dxydata + j)));
- v_s1 = _mm_mul_ps(v_factor, _mm_add_ps(v_s1, _mm_add_ps(v_s2, _mm_mul_ps(v_s3, v_m2))));
- _mm_storeu_ps(dstdata + j, v_s1);
+ v_float32x4 v_dx = v_load(dxdata + j);
+ v_float32x4 v_dy = v_load(dydata + j);
+
+ v_float32x4 v_s1 = (v_dx * v_dx) * v_load(d2ydata + j);
+ v_float32x4 v_s2 = v_muladd((v_dy * v_dy), v_load(d2xdata + j), v_s1);
+ v_float32x4 v_s3 = v_muladd((v_dy * v_dx) * v_load(dxydata + j), v_m2, v_s2);
+
+ v_store(dstdata + j, v_s3 * v_factor);
}
}
-#elif CV_NEON
- for( ; j <= size.width - 4; j += 4 )
- {
- float32x4_t v_dx = vld1q_f32(dxdata + j), v_dy = vld1q_f32(dydata + j);
- float32x4_t v_s = vmulq_f32(v_dx, vmulq_f32(v_dx, vld1q_f32(d2ydata + j)));
- v_s = vmlaq_f32(v_s, vld1q_f32(d2xdata + j), vmulq_f32(v_dy, v_dy));
- v_s = vmlaq_f32(v_s, vld1q_f32(dxydata + j), vmulq_n_f32(vmulq_f32(v_dy, v_dx), -2));
- vst1q_f32(dstdata + j, vmulq_n_f32(v_s, factor_f));
- }
#endif
for( ; j < size.width; j++ )
diff --git a/modules/imgproc/src/corner.hpp b/modules/imgproc/src/corner.hpp
new file mode 100644
index 0000000..708568a
--- /dev/null
+++ b/modules/imgproc/src/corner.hpp
@@ -0,0 +1,60 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
+// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
+// Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#ifndef OPENCV_IMGPROC_CORNER_HPP
+#define OPENCV_IMGPROC_CORNER_HPP
+
+namespace cv
+{
+
+#if CV_TRY_AVX
+ int calcMinEigenValLine_AVX(const float* cov, float* dst, int width);
+ int calcHarrisLine_AVX(const float* cov, float* dst, double k, int width);
+ int cornerEigenValsVecsLine_AVX(const float* dxdata, const float* dydata, float* cov_data, int width);
+#endif // CV_TRY_AVX
+
+}
+
+#endif
+
+/* End of file */
diff --git a/modules/imgproc/src/demosaicing.cpp b/modules/imgproc/src/demosaicing.cpp
index 296ace8..c096cab 100644
--- a/modules/imgproc/src/demosaicing.cpp
+++ b/modules/imgproc/src/demosaicing.cpp
@@ -1643,6 +1643,7 @@ void cv::demosaicing(InputArray _src, OutputArray _dst, int code, int dcn)
break;
case CV_BayerBG2BGR: case CV_BayerGB2BGR: case CV_BayerRG2BGR: case CV_BayerGR2BGR:
+ case CV_BayerBG2BGRA: case CV_BayerGB2BGRA: case CV_BayerRG2BGRA: case CV_BayerGR2BGRA:
case CV_BayerBG2BGR_VNG: case CV_BayerGB2BGR_VNG: case CV_BayerRG2BGR_VNG: case CV_BayerGR2BGR_VNG:
{
if (dcn <= 0)
@@ -1652,8 +1653,10 @@ void cv::demosaicing(InputArray _src, OutputArray _dst, int code, int dcn)
_dst.create(sz, CV_MAKE_TYPE(depth, dcn));
Mat dst_ = _dst.getMat();
- if( code == CV_BayerBG2BGR || code == CV_BayerGB2BGR ||
- code == CV_BayerRG2BGR || code == CV_BayerGR2BGR )
+ if( code == CV_BayerBG2BGR || code == CV_BayerBG2BGRA ||
+ code == CV_BayerGB2BGR || code == CV_BayerGB2BGRA ||
+ code == CV_BayerRG2BGR || code == CV_BayerRG2BGRA ||
+ code == CV_BayerGR2BGR || code == CV_BayerGR2BGRA )
{
if( depth == CV_8U )
Bayer2RGB_<uchar, SIMDBayerInterpolator_8u>(src, dst_, code);
diff --git a/modules/imgproc/src/deriv.cpp b/modules/imgproc/src/deriv.cpp
index 01352be..25163c4 100644
--- a/modules/imgproc/src/deriv.cpp
+++ b/modules/imgproc/src/deriv.cpp
@@ -184,41 +184,24 @@ cv::Ptr<cv::FilterEngine> cv::createDerivFilter(int srcType, int dstType,
#ifdef HAVE_OPENVX
namespace cv
{
+ namespace ovx {
+ template <> inline bool skipSmallImages<VX_KERNEL_SOBEL_3x3>(int w, int h) { return w*h < 320 * 240; }
+ }
static bool openvx_sobel(InputArray _src, OutputArray _dst,
int dx, int dy, int ksize,
double scale, double delta, int borderType)
{
- int stype = _src.type();
- int dtype = _dst.type();
- if (stype != CV_8UC1 || (dtype != CV_16SC1 && dtype != CV_8UC1) ||
- ksize < 3 || ksize % 2 != 1 || delta != 0.0)
+ if (_src.type() != CV_8UC1 || _dst.type() != CV_16SC1 ||
+ ksize != 3 || scale != 1.0 || delta != 0.0 ||
+ (dx | dy) != 1 || (dx + dy) != 1 ||
+ _src.cols() < ksize || _src.rows() < ksize ||
+ ovx::skipSmallImages<VX_KERNEL_SOBEL_3x3>(_src.cols(), _src.rows())
+ )
return false;
Mat src = _src.getMat();
Mat dst = _dst.getMat();
- if (src.cols < ksize || src.rows < ksize)
- return false;
-
- int iscale = 1;
- vx_uint32 cscale = 1;
- if(scale != 1.0)
- {
- iscale = static_cast<int>(scale);
- if (std::abs(scale - iscale) >= DBL_EPSILON)
- {
- int exp = 0;
- float significand = frexp(scale, &exp);
- if ((significand == 0.5f) && (exp <= 0))
- {
- iscale = 1;
- cscale = 1 << (exp = -exp + 1);
- }
- else
- return false;
- }
- }
-
if ((borderType & BORDER_ISOLATED) == 0 && src.isSubmatrix())
return false; //Process isolated borders only
vx_enum border;
@@ -228,17 +211,17 @@ namespace cv
border = VX_BORDER_CONSTANT;
break;
case BORDER_REPLICATE:
- border = VX_BORDER_REPLICATE;
- break;
+// border = VX_BORDER_REPLICATE;
+// break;
default:
return false;
}
try
{
- ivx::Context ctx = ivx::Context::create();
- if ((vx_size)ksize > ctx.convolutionMaxDimension())
- return false;
+ ivx::Context ctx = ovx::getOpenVXContext();
+ //if ((vx_size)ksize > ctx.convolutionMaxDimension())
+ // return false;
Mat a;
if (dst.data != src.data)
@@ -249,40 +232,17 @@ namespace cv
ivx::Image
ia = ivx::Image::createFromHandle(ctx, VX_DF_IMAGE_U8,
ivx::Image::createAddressing(a.cols, a.rows, 1, (vx_int32)(a.step)), a.data),
- ib = ivx::Image::createFromHandle(ctx, dtype == CV_16SC1 ? VX_DF_IMAGE_S16 : VX_DF_IMAGE_U8,
- ivx::Image::createAddressing(dst.cols, dst.rows, dtype == CV_16SC1 ? 2 : 1, (vx_int32)(dst.step)), dst.data);
+ ib = ivx::Image::createFromHandle(ctx, VX_DF_IMAGE_S16,
+ ivx::Image::createAddressing(dst.cols, dst.rows, 2, (vx_int32)(dst.step)), dst.data);
//ATTENTION: VX_CONTEXT_IMMEDIATE_BORDER attribute change could lead to strange issues in multi-threaded environments
//since OpenVX standart says nothing about thread-safety for now
ivx::border_t prevBorder = ctx.immediateBorder();
ctx.setImmediateBorder(border, (vx_uint8)(0));
- if (dtype == CV_16SC1 && ksize == 3 && ((dx | dy) == 1) && (dx + dy) == 1)
- {
- if(dx)
- ivx::IVX_CHECK_STATUS(vxuSobel3x3(ctx, ia, ib, NULL));
- else
- ivx::IVX_CHECK_STATUS(vxuSobel3x3(ctx, ia, NULL, ib));
- }
+ if(dx)
+ ivx::IVX_CHECK_STATUS(vxuSobel3x3(ctx, ia, ib, NULL));
else
- {
-#if VX_VERSION <= VX_VERSION_1_0
- if (ctx.vendorID() == VX_ID_KHRONOS && ((vx_size)(src.cols) <= ctx.convolutionMaxDimension() || (vx_size)(src.rows) <= ctx.convolutionMaxDimension()))
- {
- ctx.setImmediateBorder(prevBorder);
- return false;
- }
-#endif
- Mat kx, ky;
- getDerivKernels(kx, ky, dx, dy, ksize, false);
- flip(kx, kx, 0);
- flip(ky, ky, 0);
- Mat convData;
- cv::Mat(ky*kx.t()).convertTo(convData, CV_16SC1, iscale);
- ivx::Convolution cnv = ivx::Convolution::create(ctx, convData.cols, convData.rows);
- cnv.copyFrom(convData);
- cnv.setScale(cscale);
- ivx::IVX_CHECK_STATUS(vxuConvolve(ctx, ia, cnv, ib));
- }
+ ivx::IVX_CHECK_STATUS(vxuSobel3x3(ctx, ia, NULL, ib));
ctx.setImmediateBorder(prevBorder);
}
catch (ivx::RuntimeError & e)
@@ -302,337 +262,90 @@ namespace cv
#ifdef HAVE_IPP
namespace cv
{
-static bool IPPDerivScharr(InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, double scale, double delta, int borderType)
+
+static bool ipp_Deriv(InputArray _src, OutputArray _dst, int dx, int dy, int ksize, double scale, double delta, int borderType)
{
+#ifdef HAVE_IPP_IW
CV_INSTRUMENT_REGION_IPP()
-#if IPP_VERSION_X100 >= 810
- if ((0 > dx) || (0 > dy) || (1 != dx + dy))
- return false;
- if (fabs(delta) > FLT_EPSILON)
- return false;
+ ::ipp::IwiSize size(_src.size().width, _src.size().height);
+ IppDataType srcType = ippiGetDataType(_src.depth());
+ IppDataType dstType = ippiGetDataType(_dst.depth());
+ int channels = _src.channels();
+ bool useScale = false;
+ bool useScharr = false;
- IppiBorderType ippiBorderType = ippiGetBorderType(borderType & (~BORDER_ISOLATED));
- if ((int)ippiBorderType < 0)
+ if(channels != _dst.channels() || channels > 1)
return false;
- int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype);
- if (ddepth < 0)
- ddepth = sdepth;
- int dtype = CV_MAKETYPE(ddepth, cn);
+ if(fabs(delta) > FLT_EPSILON || fabs(scale-1) > FLT_EPSILON)
+ useScale = true;
- Mat src = _src.getMat();
- if (0 == (BORDER_ISOLATED & borderType))
+ if(ksize <= 0)
{
- Size size; Point offset;
- src.locateROI(size, offset);
- if (0 < offset.x)
- ippiBorderType = (IppiBorderType)(ippiBorderType | ippBorderInMemLeft);
- if (0 < offset.y)
- ippiBorderType = (IppiBorderType)(ippiBorderType | ippBorderInMemTop);
- if (offset.x + src.cols < size.width)
- ippiBorderType = (IppiBorderType)(ippiBorderType | ippBorderInMemRight);
- if (offset.y + src.rows < size.height)
- ippiBorderType = (IppiBorderType)(ippiBorderType | ippBorderInMemBottom);
+ ksize = 3;
+ useScharr = true;
}
- bool horz = (0 == dx) && (1 == dy);
- IppiSize roiSize = {src.cols, src.rows};
-
- _dst.create( _src.size(), dtype);
- Mat dst = _dst.getMat();
- IppStatus sts = ippStsErr;
- if ((CV_8U == stype) && (CV_16S == dtype))
- {
- int bufferSize = 0; Ipp8u *pBuffer;
- if (horz)
- {
- if (0 > ippiFilterScharrHorizMaskBorderGetBufferSize(roiSize, ippMskSize3x3, ipp8u, ipp16s, 1, &bufferSize))
- return false;
- pBuffer = ippsMalloc_8u(bufferSize);
- if (NULL == pBuffer)
- return false;
- sts = CV_INSTRUMENT_FUN_IPP(ippiFilterScharrHorizMaskBorder_8u16s_C1R, src.ptr(), (int)src.step, dst.ptr<Ipp16s>(), (int)dst.step, roiSize, ippMskSize3x3, ippiBorderType, 0, pBuffer);
- }
- else
- {
- if (0 > ippiFilterScharrVertMaskBorderGetBufferSize(roiSize, ippMskSize3x3, ipp8u, ipp16s, 1, &bufferSize))
- return false;
- pBuffer = ippsMalloc_8u(bufferSize);
- if (NULL == pBuffer)
- return false;
- sts = CV_INSTRUMENT_FUN_IPP(ippiFilterScharrVertMaskBorder_8u16s_C1R, src.ptr(), (int)src.step, dst.ptr<Ipp16s>(), (int)dst.step, roiSize, ippMskSize3x3, ippiBorderType, 0, pBuffer);
- }
- ippsFree(pBuffer);
- }
- else if ((CV_16S == stype) && (CV_16S == dtype))
- {
- int bufferSize = 0; Ipp8u *pBuffer;
- if (horz)
- {
- if (0 > ippiFilterScharrHorizMaskBorderGetBufferSize(roiSize, ippMskSize3x3, ipp16s, ipp16s, 1, &bufferSize))
- return false;
- pBuffer = ippsMalloc_8u(bufferSize);
- if (NULL == pBuffer)
- return false;
- sts = CV_INSTRUMENT_FUN_IPP(ippiFilterScharrHorizMaskBorder_16s_C1R, src.ptr<Ipp16s>(), (int)src.step, dst.ptr<Ipp16s>(), (int)dst.step, roiSize, ippMskSize3x3, ippiBorderType, 0, pBuffer);
- }
- else
- {
- if (0 > ippiFilterScharrVertMaskBorderGetBufferSize(roiSize, ippMskSize3x3, ipp16s, ipp16s, 1, &bufferSize))
- return false;
- pBuffer = ippsMalloc_8u(bufferSize);
- if (NULL == pBuffer)
- return false;
- sts = CV_INSTRUMENT_FUN_IPP(ippiFilterScharrVertMaskBorder_16s_C1R, src.ptr<Ipp16s>(), (int)src.step, dst.ptr<Ipp16s>(), (int)dst.step, roiSize, ippMskSize3x3, ippiBorderType, 0, pBuffer);
- }
- ippsFree(pBuffer);
- }
- else if ((CV_32F == stype) && (CV_32F == dtype))
- {
- int bufferSize = 0; Ipp8u *pBuffer;
- if (horz)
- {
- if (0 > ippiFilterScharrHorizMaskBorderGetBufferSize(roiSize, ippMskSize3x3, ipp32f, ipp32f, 1, &bufferSize))
- return false;
- pBuffer = ippsMalloc_8u(bufferSize);
- if (NULL == pBuffer)
- return false;
- sts = CV_INSTRUMENT_FUN_IPP(ippiFilterScharrHorizMaskBorder_32f_C1R, src.ptr<Ipp32f>(), (int)src.step, dst.ptr<Ipp32f>(), (int)dst.step, roiSize, ippMskSize3x3, ippiBorderType, 0, pBuffer);
- }
- else
- {
- if (0 > ippiFilterScharrVertMaskBorderGetBufferSize(roiSize, ippMskSize3x3, ipp32f, ipp32f, 1, &bufferSize))
- return false;
- pBuffer = ippsMalloc_8u(bufferSize);
- if (NULL == pBuffer)
- return false;
- sts = CV_INSTRUMENT_FUN_IPP(ippiFilterScharrVertMaskBorder_32f_C1R, src.ptr<Ipp32f>(), (int)src.step, dst.ptr<Ipp32f>(), (int)dst.step, roiSize, ippMskSize3x3, ippiBorderType, 0, pBuffer);
- }
- ippsFree(pBuffer);
- if (sts < 0)
- return false;;
-
- if (FLT_EPSILON < fabs(scale - 1.0))
- sts = CV_INSTRUMENT_FUN_IPP(ippiMulC_32f_C1R, dst.ptr<Ipp32f>(), (int)dst.step, (Ipp32f)scale, dst.ptr<Ipp32f>(), (int)dst.step, roiSize);
- }
- return (0 <= sts);
-#else
- CV_UNUSED(_src); CV_UNUSED(_dst); CV_UNUSED(ddepth); CV_UNUSED(dx); CV_UNUSED(dy); CV_UNUSED(scale); CV_UNUSED(delta); CV_UNUSED(borderType);
- return false;
-#endif
-}
-
-static bool IPPDerivSobel(InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, int ksize, double scale, double delta, int borderType)
-{
- CV_INSTRUMENT_REGION_IPP()
-
- if (((borderType & ~BORDER_ISOLATED) != BORDER_REPLICATE) || ((3 != ksize) && (5 != ksize)))
- return false;
- if (fabs(delta) > FLT_EPSILON)
+ IppiMaskSize maskSize = ippiGetMaskSize(ksize, ksize);
+ if(maskSize < 0)
return false;
- if (1 != _src.channels())
- return false;
-
- int bufSize = 0;
- cv::AutoBuffer<char> buffer;
- Mat src = _src.getMat(), dst = _dst.getMat();
- if ((borderType & BORDER_ISOLATED) == 0 && src.isSubmatrix())
+#if IPP_VERSION_X100 <= 201703
+ // Bug with mirror wrap
+ if(borderType == BORDER_REFLECT_101 && (ksize/2+1 > size.width || ksize/2+1 > size.height))
return false;
-
- if ( ddepth < 0 )
- ddepth = src.depth();
-
- IppiSize roi = {src.cols, src.rows};
- IppiMaskSize kernel = (IppiMaskSize)(ksize*10+ksize);
-
- if (src.type() == CV_8U && dst.type() == CV_16S && scale == 1)
- {
- if ((dx == 1) && (dy == 0))
- {
-#if IPP_VERSION_X100 >= 900
- if (0 > ippiFilterSobelNegVertBorderGetBufferSize(roi, kernel, ipp8u, ipp16s, 1,&bufSize))
- return false;
- buffer.allocate(bufSize);
-#else
- if (0 > ippiFilterSobelNegVertGetBufferSize_8u16s_C1R(roi, kernel,&bufSize))
- return false;
- buffer.allocate(bufSize);
-#endif
-
- if (0 > CV_INSTRUMENT_FUN_IPP(ippiFilterSobelNegVertBorder_8u16s_C1R, src.ptr<Ipp8u>(), (int)src.step,
- dst.ptr<Ipp16s>(), (int)dst.step, roi, kernel,
- ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
- return false;
- return true;
- }
-
- if ((dx == 0) && (dy == 1))
- {
-#if IPP_VERSION_X100 >= 900
- if (0 > ippiFilterSobelHorizBorderGetBufferSize(roi, kernel, ipp8u, ipp16s, 1,&bufSize))
- return false;
- buffer.allocate(bufSize);
-#else
- if (0 > ippiFilterSobelHorizGetBufferSize_8u16s_C1R(roi, kernel,&bufSize))
- return false;
- buffer.allocate(bufSize);
#endif
- if (0 > CV_INSTRUMENT_FUN_IPP(ippiFilterSobelHorizBorder_8u16s_C1R, src.ptr<Ipp8u>(), (int)src.step,
- dst.ptr<Ipp16s>(), (int)dst.step, roi, kernel,
- ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
- return false;
- return true;
- }
-
- if ((dx == 2) && (dy == 0))
- {
-#if IPP_VERSION_X100 >= 900
- if (0 > ippiFilterSobelVertSecondBorderGetBufferSize(roi, kernel, ipp8u, ipp16s, 1,&bufSize))
- return false;
- buffer.allocate(bufSize);
-#else
- if (0 > ippiFilterSobelVertSecondGetBufferSize_8u16s_C1R(roi, kernel,&bufSize))
- return false;
- buffer.allocate(bufSize);
-#endif
-
- if (0 > CV_INSTRUMENT_FUN_IPP(ippiFilterSobelVertSecondBorder_8u16s_C1R, src.ptr<Ipp8u>(), (int)src.step,
- dst.ptr<Ipp16s>(), (int)dst.step, roi, kernel,
- ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
- return false;
- return true;
- }
-
- if ((dx == 0) && (dy == 2))
- {
-#if IPP_VERSION_X100 >= 900
- if (0 > ippiFilterSobelHorizSecondBorderGetBufferSize(roi, kernel, ipp8u, ipp16s, 1,&bufSize))
- return false;
- buffer.allocate(bufSize);
-#else
- if (0 > ippiFilterSobelHorizSecondGetBufferSize_8u16s_C1R(roi, kernel,&bufSize))
- return false;
- buffer.allocate(bufSize);
-#endif
-
- if (0 > CV_INSTRUMENT_FUN_IPP(ippiFilterSobelHorizSecondBorder_8u16s_C1R, src.ptr<Ipp8u>(), (int)src.step,
- dst.ptr<Ipp16s>(), (int)dst.step, roi, kernel,
- ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
- return false;
- return true;
- }
- }
+ IwiDerivativeType derivType = ippiGetDerivType(dx, dy, (useScharr)?false:true);
+ if(derivType < 0)
+ return false;
- if (src.type() == CV_32F && dst.type() == CV_32F)
+ // Acquire data and begin processing
+ try
{
-#if IPP_DISABLE_BLOCK
- if ((dx == 1) && (dy == 0))
- {
-#if IPP_VERSION_X100 >= 900
- if (0 > ippiFilterSobelNegVertBorderGetBufferSize(roi, kernel, ipp32f, ipp32f, 1,&bufSize))
- return false;
- buffer.allocate(bufSize);
-#else
- if (0 > ippiFilterSobelNegVertGetBufferSize_32f_C1R(roi, kernel, &bufSize))
- return false;
- buffer.allocate(bufSize);
-#endif
-
- if (0 > ippiFilterSobelNegVertBorder_32f_C1R(src.ptr<Ipp32f>(), (int)src.step,
- dst.ptr<Ipp32f>(), (int)dst.step, roi, kernel,
- ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
- return false;
- if(scale != 1)
- ippiMulC_32f_C1R(dst.ptr<Ipp32f>(), (int)dst.step, (Ipp32f)scale, dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
- return true;
- }
+ Mat src = _src.getMat();
+ Mat dst = _dst.getMat();
+ ::ipp::IwiImage iwSrc = ippiGetImage(src);
+ ::ipp::IwiImage iwDst = ippiGetImage(dst);
+ ::ipp::IwiImage iwSrcProc = iwSrc;
+ ::ipp::IwiImage iwDstProc = iwDst;
+ ::ipp::IwiBorderSize borderSize(maskSize);
+ ::ipp::IwiBorderType ippBorder(ippiGetBorder(iwSrc, borderType, borderSize));
+ if(!ippBorder.m_borderType)
+ return false;
- if ((dx == 0) && (dy == 1))
+ if(srcType == ipp8u && dstType == ipp8u)
{
-#if IPP_VERSION_X100 >= 900
- if (0 > ippiFilterSobelHorizBorderGetBufferSize(roi, kernel, ipp32f, ipp32f, 1,&bufSize))
- return false;
- buffer.allocate(bufSize);
-#else
- if (0 > ippiFilterSobelHorizGetBufferSize_32f_C1R(roi, kernel,&bufSize))
- return false;
- buffer.allocate(bufSize);
-#endif
-
- if (0 > ippiFilterSobelHorizBorder_32f_C1R(src.ptr<Ipp32f>(), (int)src.step,
- dst.ptr<Ipp32f>(), (int)dst.step, roi, kernel,
- ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
- return false;
- if(scale != 1)
- ippiMulC_32f_C1R(dst.ptr<Ipp32f>(), (int)dst.step, (Ipp32f)scale, dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
- return true;
+ iwDstProc.Alloc(iwDst.m_size, ipp16s, channels);
+ useScale = true;
}
-#endif
-
- if((dx == 2) && (dy == 0))
+ else if(srcType == ipp8u && dstType == ipp32f)
{
-#if IPP_VERSION_X100 >= 900
- if (0 > ippiFilterSobelVertSecondBorderGetBufferSize(roi, kernel, ipp32f, ipp32f, 1,&bufSize))
- return false;
- buffer.allocate(bufSize);
-#else
- if (0 > ippiFilterSobelVertSecondGetBufferSize_32f_C1R(roi, kernel,&bufSize))
- return false;
- buffer.allocate(bufSize);
-#endif
-
- if (0 > CV_INSTRUMENT_FUN_IPP(ippiFilterSobelVertSecondBorder_32f_C1R, src.ptr<Ipp32f>(), (int)src.step,
- dst.ptr<Ipp32f>(), (int)dst.step, roi, kernel,
- ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
- return false;
- if(scale != 1)
- CV_INSTRUMENT_FUN_IPP(ippiMulC_32f_C1R, dst.ptr<Ipp32f>(), (int)dst.step, (Ipp32f)scale, dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
- return true;
+ iwSrc -= borderSize;
+ iwSrcProc.Alloc(iwSrc.m_size, ipp32f, channels);
+ CV_INSTRUMENT_FUN_IPP(::ipp::iwiScale, &iwSrc, &iwSrcProc, 1, 0, ippAlgHintFast);
+ iwSrcProc += borderSize;
}
- if((dx == 0) && (dy == 2))
- {
-#if IPP_VERSION_X100 >= 900
- if (0 > ippiFilterSobelHorizSecondBorderGetBufferSize(roi, kernel, ipp32f, ipp32f, 1,&bufSize))
- return false;
- buffer.allocate(bufSize);
-#else
- if (0 > ippiFilterSobelHorizSecondGetBufferSize_32f_C1R(roi, kernel,&bufSize))
- return false;
- buffer.allocate(bufSize);
-#endif
-
- if (0 > CV_INSTRUMENT_FUN_IPP(ippiFilterSobelHorizSecondBorder_32f_C1R, src.ptr<Ipp32f>(), (int)src.step,
- dst.ptr<Ipp32f>(), (int)dst.step, roi, kernel,
- ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
- return false;
-
- if(scale != 1)
- CV_INSTRUMENT_FUN_IPP(ippiMulC_32f_C1R, dst.ptr<Ipp32f>(), (int)dst.step, (Ipp32f)scale, dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
- return true;
- }
- }
- return false;
-}
-
-static bool ipp_sobel(InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, int ksize, double scale, double delta, int borderType)
-{
- CV_INSTRUMENT_REGION_IPP()
+ if(useScharr)
+ CV_INSTRUMENT_FUN_IPP(::ipp::iwiFilterScharr, &iwSrcProc, &iwDstProc, derivType, maskSize, ippBorder);
+ else
+ CV_INSTRUMENT_FUN_IPP(::ipp::iwiFilterSobel, &iwSrcProc, &iwDstProc, derivType, maskSize, ippBorder);
- if (ksize < 0)
- {
- if (IPPDerivScharr(_src, _dst, ddepth, dx, dy, scale, delta, borderType))
- return true;
+ if(useScale)
+ CV_INSTRUMENT_FUN_IPP(::ipp::iwiScale, &iwDstProc, &iwDst, scale, delta, ippAlgHintFast);
}
- else if (0 < ksize)
+ catch (::ipp::IwException)
{
- if (IPPDerivSobel(_src, _dst, ddepth, dx, dy, ksize, scale, delta, borderType))
- return true;
+ return false;
}
+
+ return true;
+#else
+ CV_UNUSED(_src); CV_UNUSED(_dst); CV_UNUSED(dx); CV_UNUSED(dy); CV_UNUSED(ksize); CV_UNUSED(scale); CV_UNUSED(delta); CV_UNUSED(borderType);
return false;
+#endif
}
}
#endif
@@ -722,7 +435,7 @@ void cv::Sobel( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy,
CV_OVX_RUN(true,
openvx_sobel(_src, _dst, dx, dy, ksize, scale, delta, borderType))
- CV_IPP_RUN(!(ocl::useOpenCL() && _dst.isUMat()), ipp_sobel(_src, _dst, ddepth, dx, dy, ksize, scale, delta, borderType));
+ CV_IPP_RUN(!(ocl::useOpenCL() && _dst.isUMat()), ipp_Deriv(_src, _dst, dx, dy, ksize, scale, delta, borderType));
int ktype = std::max(CV_32F, std::max(ddepth, sdepth));
@@ -766,7 +479,7 @@ void cv::Scharr( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy,
}
#endif
- CV_IPP_RUN(!(ocl::useOpenCL() && _dst.isUMat()), IPPDerivScharr(_src, _dst, ddepth, dx, dy, scale, delta, borderType));
+ CV_IPP_RUN(!(ocl::useOpenCL() && _dst.isUMat()), ipp_Deriv(_src, _dst, dx, dy, 0, scale, delta, borderType));
int ktype = std::max(CV_32F, std::max(ddepth, sdepth));
@@ -986,69 +699,71 @@ static bool ocl_Laplacian3_8UC1(InputArray _src, OutputArray _dst, int ddepth,
#if defined(HAVE_IPP)
namespace cv
{
-static bool ipp_Laplacian(InputArray _src, OutputArray _dst, int ddepth, int ksize,
- double scale, double delta, int borderType)
+
+static bool ipp_Laplacian(InputArray _src, OutputArray _dst, int ksize, double scale, double delta, int borderType)
{
+#ifdef HAVE_IPP_IW
CV_INSTRUMENT_REGION_IPP()
- int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype);
- if (ddepth < 0)
- ddepth = sdepth;
- _dst.create( _src.size(), CV_MAKETYPE(ddepth, cn) );
+ ::ipp::IwiSize size(_src.size().width, _src.size().height);
+ IppDataType srcType = ippiGetDataType(_src.depth());
+ IppDataType dstType = ippiGetDataType(_dst.depth());
+ int channels = _src.channels();
+ bool useScale = false;
- int iscale = saturate_cast<int>(scale), idelta = saturate_cast<int>(delta);
- bool floatScale = std::fabs(scale - iscale) > DBL_EPSILON, needScale = iscale != 1;
- bool floatDelta = std::fabs(delta - idelta) > DBL_EPSILON, needDelta = delta != 0;
- int borderTypeNI = borderType & ~BORDER_ISOLATED;
- Mat src = _src.getMat(), dst = _dst.getMat();
+ if(channels != _dst.channels() || channels > 1)
+ return false;
+
+ if(fabs(delta) > FLT_EPSILON || fabs(scale-1) > FLT_EPSILON)
+ useScale = true;
- if (src.data != dst.data)
+ IppiMaskSize maskSize = ippiGetMaskSize(ksize, ksize);
+ if(maskSize < 0)
+ return false;
+
+ // Acquire data and begin processing
+ try
{
- Ipp32s bufsize;
- IppStatus status = (IppStatus)-1;
- IppiSize roisize = { src.cols, src.rows };
- IppiMaskSize masksize = ksize == 3 ? ippMskSize3x3 : ippMskSize5x5;
- IppiBorderType borderTypeIpp = ippiGetBorderType(borderTypeNI);
-
-#define IPP_FILTER_LAPLACIAN(ippsrctype, ippdsttype, ippfavor) \
- do \
- { \
- if (borderTypeIpp >= 0 && ippiFilterLaplacianGetBufferSize_##ippfavor##_C1R(roisize, masksize, &bufsize) >= 0) \
- { \
- Ipp8u * buffer = ippsMalloc_8u(bufsize); \
- status = CV_INSTRUMENT_FUN_IPP(ippiFilterLaplacianBorder_##ippfavor##_C1R, src.ptr<ippsrctype>(), (int)src.step, dst.ptr<ippdsttype>(), \
- (int)dst.step, roisize, masksize, borderTypeIpp, 0, buffer); \
- ippsFree(buffer); \
- } \
- } while ((void)0, 0)
-
- CV_SUPPRESS_DEPRECATED_START
- if (sdepth == CV_8U && ddepth == CV_16S && !floatScale && !floatDelta)
- {
- IPP_FILTER_LAPLACIAN(Ipp8u, Ipp16s, 8u16s);
+ Mat src = _src.getMat();
+ Mat dst = _dst.getMat();
+ ::ipp::IwiImage iwSrc = ippiGetImage(src);
+ ::ipp::IwiImage iwDst = ippiGetImage(dst);
+ ::ipp::IwiImage iwSrcProc = iwSrc;
+ ::ipp::IwiImage iwDstProc = iwDst;
+ ::ipp::IwiBorderSize borderSize(maskSize);
+ ::ipp::IwiBorderType ippBorder(ippiGetBorder(iwSrc, borderType, borderSize));
+ if(!ippBorder.m_borderType)
+ return false;
- if (needScale && status >= 0)
- status = CV_INSTRUMENT_FUN_IPP(ippiMulC_16s_C1IRSfs, (Ipp16s)iscale, dst.ptr<Ipp16s>(), (int)dst.step, roisize, 0);
- if (needDelta && status >= 0)
- status = CV_INSTRUMENT_FUN_IPP(ippiAddC_16s_C1IRSfs, (Ipp16s)idelta, dst.ptr<Ipp16s>(), (int)dst.step, roisize, 0);
+ if(srcType == ipp8u && dstType == ipp8u)
+ {
+ iwDstProc.Alloc(iwDst.m_size, ipp16s, channels);
+ useScale = true;
}
- else if (sdepth == CV_32F && ddepth == CV_32F)
+ else if(srcType == ipp8u && dstType == ipp32f)
{
- IPP_FILTER_LAPLACIAN(Ipp32f, Ipp32f, 32f);
-
- if (needScale && status >= 0)
- status = CV_INSTRUMENT_FUN_IPP(ippiMulC_32f_C1IR, (Ipp32f)scale, dst.ptr<Ipp32f>(), (int)dst.step, roisize);
- if (needDelta && status >= 0)
- status = CV_INSTRUMENT_FUN_IPP(ippiAddC_32f_C1IR, (Ipp32f)delta, dst.ptr<Ipp32f>(), (int)dst.step, roisize);
+ iwSrc -= borderSize;
+ iwSrcProc.Alloc(iwSrc.m_size, ipp32f, channels);
+ CV_INSTRUMENT_FUN_IPP(::ipp::iwiScale, &iwSrc, &iwSrcProc, 1, 0);
+ iwSrcProc += borderSize;
}
- CV_SUPPRESS_DEPRECATED_END
- if (status >= 0)
- return true;
+ CV_INSTRUMENT_FUN_IPP(::ipp::iwiFilterLaplacian, &iwSrcProc, &iwDstProc, maskSize, ippBorder);
+
+ if(useScale)
+ CV_INSTRUMENT_FUN_IPP(::ipp::iwiScale, &iwDstProc, &iwDst, scale, delta);
+
+ }
+ catch (::ipp::IwException ex)
+ {
+ return false;
}
-#undef IPP_FILTER_LAPLACIAN
+ return true;
+#else
+ CV_UNUSED(_src); CV_UNUSED(_dst); CV_UNUSED(ksize); CV_UNUSED(scale); CV_UNUSED(delta); CV_UNUSED(borderType);
return false;
+#endif
}
}
#endif
@@ -1080,9 +795,7 @@ void cv::Laplacian( InputArray _src, OutputArray _dst, int ddepth, int ksize,
ocl_Laplacian3_8UC1(_src, _dst, ddepth, kernel, delta, borderType));
}
- CV_IPP_RUN((ksize == 3 || ksize == 5) && ((borderType & BORDER_ISOLATED) != 0 || !_src.isSubmatrix()) &&
- ((stype == CV_8UC1 && ddepth == CV_16S) || (ddepth == CV_32F && stype == CV_32FC1)) && (!cv::ocl::useOpenCL()),
- ipp_Laplacian(_src, _dst, ddepth, ksize, scale, delta, borderType));
+ CV_IPP_RUN(!(cv::ocl::useOpenCL() && _dst.isUMat()), ipp_Laplacian(_src, _dst, ksize, scale, delta, borderType));
#ifdef HAVE_TEGRA_OPTIMIZATION
diff --git a/modules/imgproc/src/distransform.cpp b/modules/imgproc/src/distransform.cpp
index 36914d8..aba0a77 100644
--- a/modules/imgproc/src/distransform.cpp
+++ b/modules/imgproc/src/distransform.cpp
@@ -681,6 +681,8 @@ namespace cv
{
static void distanceTransform_L1_8U(InputArray _src, OutputArray _dst)
{
+ CV_INSTRUMENT_REGION()
+
Mat src = _src.getMat();
CV_Assert( src.type() == CV_8UC1);
@@ -745,7 +747,9 @@ void cv::distanceTransform( InputArray _src, OutputArray _dst, OutputArray _labe
#ifdef HAVE_IPP
CV_IPP_CHECK()
{
- if ((currentParallelFramework()==NULL) || (src.total()<(int)(1<<14)))
+#if IPP_DISABLE_PERF_TRUE_DIST_MT
+ if(cv::getNumThreads()<=1 || (src.total()<(int)(1<<14)))
+#endif
{
IppStatus status;
IppiSize roi = { src.cols, src.rows };
@@ -755,7 +759,7 @@ void cv::distanceTransform( InputArray _src, OutputArray _dst, OutputArray _labe
status = ippiTrueDistanceTransformGetBufferSize_8u32f_C1R(roi, &bufSize);
if (status>=0)
{
- pBuffer = (Ipp8u *)ippMalloc( bufSize );
+ pBuffer = (Ipp8u *)CV_IPP_MALLOC( bufSize );
status = CV_INSTRUMENT_FUN_IPP(ippiTrueDistanceTransform_8u32f_C1R, src.ptr<uchar>(), (int)src.step, dst.ptr<float>(), (int)dst.step, roi, pBuffer);
ippFree( pBuffer );
if (status>=0)
diff --git a/modules/imgproc/src/drawing.cpp b/modules/imgproc/src/drawing.cpp
index 113f499..5856668 100644
--- a/modules/imgproc/src/drawing.cpp
+++ b/modules/imgproc/src/drawing.cpp
@@ -40,6 +40,8 @@
//M*/
#include "precomp.hpp"
+#include <stdint.h>
+
namespace cv
{
@@ -109,14 +111,14 @@ bool clipLine( Size2l img_size, Point2l& pt1, Point2l& pt2 )
if( c1 & 12 )
{
a = c1 < 8 ? 0 : bottom;
- x1 += (a - y1) * (x2 - x1) / (y2 - y1);
+ x1 += (int64)((double)(a - y1) * (x2 - x1) / (y2 - y1));
y1 = a;
c1 = (x1 < 0) + (x1 > right) * 2;
}
if( c2 & 12 )
{
a = c2 < 8 ? 0 : bottom;
- x2 += (a - y2) * (x2 - x1) / (y2 - y1);
+ x2 += (int64)((double)(a - y2) * (x2 - x1) / (y2 - y1));
y2 = a;
c2 = (x2 < 0) + (x2 > right) * 2;
}
@@ -125,14 +127,14 @@ bool clipLine( Size2l img_size, Point2l& pt1, Point2l& pt2 )
if( c1 )
{
a = c1 == 1 ? 0 : right;
- y1 += (a - x1) * (y2 - y1) / (x2 - x1);
+ y1 += (int64)((double)(a - x1) * (y2 - y1) / (x2 - x1));
x1 = a;
c1 = 0;
}
if( c2 )
{
a = c2 == 1 ? 0 : right;
- y2 += (a - x2) * (y2 - y1) / (x2 - x1);
+ y2 += (int64)((double)(a - x2) * (y2 - y1) / (x2 - x1));
x2 = a;
c2 = 0;
}
@@ -176,6 +178,9 @@ LineIterator::LineIterator(const Mat& img, Point pt1, Point pt2,
{
ptr = img.data;
err = plusDelta = minusDelta = plusStep = minusStep = count = 0;
+ ptr0 = 0;
+ step = 0;
+ elemSize = 0;
return;
}
}
@@ -309,7 +314,7 @@ LineAA( Mat& img, Point2l pt1, Point2l pt2, const void* color )
if( !((nch == 1 || nch == 3 || nch == 4) && img.depth() == CV_8U) )
{
- Line(img, Point((int)(pt1.x<<XY_SHIFT), (int)(pt1.y<<XY_SHIFT)), Point((int)(pt2.x<<XY_SHIFT), (int)(pt2.y<<XY_SHIFT)), color);
+ Line(img, Point((int)(pt1.x>>XY_SHIFT), (int)(pt1.y>>XY_SHIFT)), Point((int)(pt2.x>>XY_SHIFT), (int)(pt2.y>>XY_SHIFT)), color);
return;
}
@@ -1069,22 +1074,36 @@ EllipseEx( Mat& img, Point2l center, Size2l axes,
* Polygons filling *
\****************************************************************************************/
-/* helper macros: filling horizontal row */
-#define ICV_HLINE( ptr, xl, xr, color, pix_size ) \
-{ \
- uchar* hline_ptr = (uchar*)(ptr) + (xl)*(pix_size); \
- uchar* hline_max_ptr = (uchar*)(ptr) + (xr)*(pix_size); \
- \
- for( ; hline_ptr <= hline_max_ptr; hline_ptr += (pix_size))\
- { \
- int hline_j; \
- for( hline_j = 0; hline_j < (pix_size); hline_j++ ) \
- { \
- hline_ptr[hline_j] = ((uchar*)color)[hline_j]; \
- } \
- } \
+static inline void ICV_HLINE_X(uchar* ptr, int xl, int xr, const uchar* color, int pix_size)
+{
+ uchar* hline_min_ptr = (uchar*)(ptr) + (xl)*(pix_size);
+ uchar* hline_end_ptr = (uchar*)(ptr) + (xr+1)*(pix_size);
+ uchar* hline_ptr = hline_min_ptr;
+ if (pix_size == 1)
+ memset(hline_min_ptr, *color, hline_end_ptr-hline_min_ptr);
+ else//if (pix_size != 1)
+ {
+ if (hline_min_ptr < hline_end_ptr)
+ {
+ memcpy(hline_ptr, color, pix_size);
+ hline_ptr += pix_size;
+ }//end if (hline_min_ptr < hline_end_ptr)
+ size_t sizeToCopy = pix_size;
+ while(hline_ptr < hline_end_ptr)
+ {
+ memcpy(hline_ptr, hline_min_ptr, sizeToCopy);
+ hline_ptr += sizeToCopy;
+ sizeToCopy = std::min(2*sizeToCopy, static_cast<size_t>(hline_end_ptr-hline_ptr));
+ }//end while(hline_ptr < hline_end_ptr)
+ }//end if (pix_size != 1)
}
+//end ICV_HLINE_X()
+static inline void ICV_HLINE(uchar* ptr, int xl, int xr, const void* color, int pix_size)
+{
+ ICV_HLINE_X(ptr, xl, xr, reinterpret_cast<const uchar*>(color), pix_size);
+}
+//end ICV_HLINE()
/* filling convex polygon. v - array of vertices, ntps - number of points */
static void
@@ -1171,6 +1190,9 @@ FillConvexPoly( Mat& img, const Point2l* v, int npts, const void* color, int lin
edge[0].di = 1;
edge[1].di = npts - 1;
+ edge[0].x = edge[1].x = -XY_ONE;
+ edge[0].dx = edge[1].dx = 0;
+
ptr += img.step*y;
do
@@ -1213,6 +1235,9 @@ FillConvexPoly( Mat& img, const Point2l* v, int npts, const void* color, int lin
}
}
+ if (edges < 0)
+ break;
+
if (y >= 0)
{
int left = 0, right = 1;
@@ -2575,6 +2600,7 @@ cvDrawContours( void* _img, CvSeq* contour,
void* clr = (contour->flags & CV_SEQ_FLAG_HOLE) == 0 ? ext_buf : hole_buf;
cvStartReadSeq( contour, &reader, 0 );
+ CV_Assert(reader.ptr != NULL);
if( thickness < 0 )
pts.resize(0);
diff --git a/modules/imgproc/src/emd.cpp b/modules/imgproc/src/emd.cpp
index 96eda61..3b1e4af 100644
--- a/modules/imgproc/src/emd.cpp
+++ b/modules/imgproc/src/emd.cpp
@@ -730,7 +730,7 @@ icvNewSolution( CvEMDState * state )
int i, j;
float min_val = CV_EMD_INF;
int steps;
- CvNode2D head, *cur_x, *next_x, *leave_x = 0;
+ CvNode2D head = {0, {0}, 0, 0}, *cur_x, *next_x, *leave_x = 0;
CvNode2D *enter_x = state->enter_x;
CvNode2D **loop = state->loop;
@@ -773,6 +773,7 @@ icvNewSolution( CvEMDState * state )
}
/* remove the leaving basic variable */
+ CV_Assert(leave_x != NULL);
i = leave_x->i;
j = leave_x->j;
state->is_x[i][j] = 0;
@@ -782,7 +783,7 @@ icvNewSolution( CvEMDState * state )
while( (next_x = cur_x->next[0]) != leave_x )
{
cur_x = next_x;
- assert( cur_x );
+ CV_Assert( cur_x );
}
cur_x->next[0] = next_x->next[0];
state->rows_x[i] = head.next[0];
@@ -792,7 +793,7 @@ icvNewSolution( CvEMDState * state )
while( (next_x = cur_x->next[1]) != leave_x )
{
cur_x = next_x;
- assert( cur_x );
+ CV_Assert( cur_x );
}
cur_x->next[1] = next_x->next[1];
state->cols_x[j] = head.next[1];
@@ -1164,4 +1165,11 @@ float cv::EMD( InputArray _signature1, InputArray _signature2,
_flow.needed() ? &_cflow : 0, lowerBound, 0 );
}
+float cv::wrapperEMD(InputArray _signature1, InputArray _signature2,
+ int distType, InputArray _cost,
+ Ptr<float> lowerBound, OutputArray _flow)
+{
+ return EMD(_signature1, _signature2, distType, _cost, lowerBound.get(), _flow);
+}
+
/* End of file. */
diff --git a/modules/imgproc/src/featureselect.cpp b/modules/imgproc/src/featureselect.cpp
index fc1b034..8bdd517 100644
--- a/modules/imgproc/src/featureselect.cpp
+++ b/modules/imgproc/src/featureselect.cpp
@@ -286,7 +286,7 @@ static bool openvx_harris(Mat image, OutputArray _corners,
try
{
- Context context = Context::create();
+ Context context = ovx::getOpenVXContext();
Image ovxImage = Image::createFromHandle(context, Image::matTypeToFormat(image.type()),
Image::createAddressing(image), image.data);
@@ -377,7 +377,8 @@ void cv::goodFeaturesToTrack( InputArray _image, OutputArray _corners,
}
// Disabled due to bad accuracy
- CV_OVX_RUN(false && useHarrisDetector && _mask.empty(),
+ CV_OVX_RUN(false && useHarrisDetector && _mask.empty() &&
+ !ovx::skipSmallImages<VX_KERNEL_HARRIS_CORNERS>(image.cols, image.rows),
openvx_harris(image, _corners, maxCorners, qualityLevel, minDistance, blockSize, harrisK))
if( useHarrisDetector )
diff --git a/modules/imgproc/src/filter.avx2.cpp b/modules/imgproc/src/filter.avx2.cpp
new file mode 100644
index 0000000..b469329
--- /dev/null
+++ b/modules/imgproc/src/filter.avx2.cpp
@@ -0,0 +1,200 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
+// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "precomp.hpp"
+#include "filter.hpp"
+
+namespace cv
+{
+
+int RowVec_32f_AVX(const float* src0, const float* _kx, float* dst, int width, int cn, int _ksize)
+{
+ int i = 0, k;
+ for (; i <= width - 8; i += 8)
+ {
+ const float* src = src0 + i;
+ __m256 f, x0;
+ __m256 s0 = _mm256_set1_ps(0.0f);
+ for (k = 0; k < _ksize; k++, src += cn)
+ {
+ f = _mm256_set1_ps(_kx[k]);
+ x0 = _mm256_loadu_ps(src);
+#if CV_FMA3
+ s0 = _mm256_fmadd_ps(x0, f, s0);
+#else
+ s0 = _mm256_add_ps(s0, _mm256_mul_ps(x0, f));
+#endif
+ }
+ _mm256_storeu_ps(dst + i, s0);
+ }
+ _mm256_zeroupper();
+ return i;
+}
+
+int SymmColumnVec_32f_Symm_AVX(const float** src, const float* ky, float* dst, float delta, int width, int ksize2)
+{
+ int i = 0, k;
+ const float *S, *S2;
+ const __m128 d4 = _mm_set1_ps(delta);
+ const __m256 d8 = _mm256_set1_ps(delta);
+
+ for( ; i <= width - 16; i += 16 )
+ {
+ __m256 f = _mm256_set1_ps(ky[0]);
+ __m256 s0, s1;
+ __m256 x0;
+ S = src[0] + i;
+ s0 = _mm256_loadu_ps(S);
+#if CV_FMA3
+ s0 = _mm256_fmadd_ps(s0, f, d8);
+#else
+ s0 = _mm256_add_ps(_mm256_mul_ps(s0, f), d8);
+#endif
+ s1 = _mm256_loadu_ps(S+8);
+#if CV_FMA3
+ s1 = _mm256_fmadd_ps(s1, f, d8);
+#else
+ s1 = _mm256_add_ps(_mm256_mul_ps(s1, f), d8);
+#endif
+
+ for( k = 1; k <= ksize2; k++ )
+ {
+ S = src[k] + i;
+ S2 = src[-k] + i;
+ f = _mm256_set1_ps(ky[k]);
+ x0 = _mm256_add_ps(_mm256_loadu_ps(S), _mm256_loadu_ps(S2));
+#if CV_FMA3
+ s0 = _mm256_fmadd_ps(x0, f, s0);
+#else
+ s0 = _mm256_add_ps(s0, _mm256_mul_ps(x0, f));
+#endif
+ x0 = _mm256_add_ps(_mm256_loadu_ps(S+8), _mm256_loadu_ps(S2+8));
+#if CV_FMA3
+ s1 = _mm256_fmadd_ps(x0, f, s1);
+#else
+ s1 = _mm256_add_ps(s1, _mm256_mul_ps(x0, f));
+#endif
+ }
+
+ _mm256_storeu_ps(dst + i, s0);
+ _mm256_storeu_ps(dst + i + 8, s1);
+ }
+
+ for( ; i <= width - 4; i += 4 )
+ {
+ __m128 f = _mm_set1_ps(ky[0]);
+ __m128 x0, s0 = _mm_load_ps(src[0] + i);
+ s0 = _mm_add_ps(_mm_mul_ps(s0, f), d4);
+
+ for( k = 1; k <= ksize2; k++ )
+ {
+ f = _mm_set1_ps(ky[k]);
+ S = src[k] + i;
+ S2 = src[-k] + i;
+ x0 = _mm_add_ps(_mm_load_ps(src[k]+i), _mm_load_ps(src[-k] + i));
+ s0 = _mm_add_ps(s0, _mm_mul_ps(x0, f));
+ }
+
+ _mm_storeu_ps(dst + i, s0);
+ }
+
+ _mm256_zeroupper();
+ return i;
+}
+
+int SymmColumnVec_32f_Unsymm_AVX(const float** src, const float* ky, float* dst, float delta, int width, int ksize2)
+{
+ int i = 0, k;
+ const float *S, *S2;
+ const __m128 d4 = _mm_set1_ps(delta);
+ const __m256 d8 = _mm256_set1_ps(delta);
+
+ for (; i <= width - 16; i += 16)
+ {
+ __m256 f, s0 = d8, s1 = d8;
+ __m256 x0;
+ S = src[0] + i;
+
+ for (k = 1; k <= ksize2; k++)
+ {
+ S = src[k] + i;
+ S2 = src[-k] + i;
+ f = _mm256_set1_ps(ky[k]);
+ x0 = _mm256_sub_ps(_mm256_loadu_ps(S), _mm256_loadu_ps(S2));
+#if CV_FMA3
+ s0 = _mm256_fmadd_ps(x0, f, s0);
+#else
+ s0 = _mm256_add_ps(s0, _mm256_mul_ps(x0, f));
+#endif
+ x0 = _mm256_sub_ps(_mm256_loadu_ps(S + 8), _mm256_loadu_ps(S2 + 8));
+#if CV_FMA3
+ s1 = _mm256_fmadd_ps(x0, f, s1);
+#else
+ s1 = _mm256_add_ps(s1, _mm256_mul_ps(x0, f));
+#endif
+ }
+
+ _mm256_storeu_ps(dst + i, s0);
+ _mm256_storeu_ps(dst + i + 8, s1);
+ }
+
+ for (; i <= width - 4; i += 4)
+ {
+ __m128 f, x0, s0 = d4;
+
+ for (k = 1; k <= ksize2; k++)
+ {
+ f = _mm_set1_ps(ky[k]);
+ x0 = _mm_sub_ps(_mm_load_ps(src[k] + i), _mm_load_ps(src[-k] + i));
+ s0 = _mm_add_ps(s0, _mm_mul_ps(x0, f));
+ }
+
+ _mm_storeu_ps(dst + i, s0);
+ }
+
+ _mm256_zeroupper();
+ return i;
+}
+
+}
+
+/* End of file. */
diff --git a/modules/imgproc/src/filter.cpp b/modules/imgproc/src/filter.cpp
index e379df2..da14b57 100644
--- a/modules/imgproc/src/filter.cpp
+++ b/modules/imgproc/src/filter.cpp
@@ -44,6 +44,8 @@
#include "opencv2/core/opencl/ocl_defs.hpp"
#include "opencl_kernels_imgproc.hpp"
#include "hal_replacement.hpp"
+#include "filter.hpp"
+
/****************************************************************************************\
Base Image Filter
@@ -70,13 +72,10 @@ BaseFilter::~BaseFilter() {}
void BaseFilter::reset() {}
FilterEngine::FilterEngine()
+ : srcType(-1), dstType(-1), bufType(-1), maxWidth(0), wholeSize(-1, -1), dx1(0), dx2(0),
+ rowBorderType(BORDER_REPLICATE), columnBorderType(BORDER_REPLICATE),
+ borderElemSize(0), bufStep(0), startY(0), startY0(0), endY(0), rowCount(0), dstY(0)
{
- srcType = dstType = bufType = -1;
- rowBorderType = columnBorderType = BORDER_REPLICATE;
- bufStep = startY = startY0 = endY = rowCount = dstY = 0;
- maxWidth = 0;
-
- wholeSize = Size(-1,-1);
}
@@ -86,6 +85,9 @@ FilterEngine::FilterEngine( const Ptr<BaseFilter>& _filter2D,
int _srcType, int _dstType, int _bufType,
int _rowBorderType, int _columnBorderType,
const Scalar& _borderValue )
+ : srcType(-1), dstType(-1), bufType(-1), maxWidth(0), wholeSize(-1, -1), dx1(0), dx2(0),
+ rowBorderType(BORDER_REPLICATE), columnBorderType(BORDER_REPLICATE),
+ borderElemSize(0), bufStep(0), startY(0), startY0(0), endY(0), rowCount(0), dstY(0)
{
init(_filter2D, _rowFilter, _columnFilter, _srcType, _dstType, _bufType,
_rowBorderType, _columnBorderType, _borderValue);
@@ -186,6 +188,7 @@ int FilterEngine::start(const Size &_wholeSize, const Size &sz, const Point &ofs
srcRow.resize(esz*(maxWidth + ksize.width - 1));
if( columnBorderType == BORDER_CONSTANT )
{
+ CV_Assert(constVal != NULL);
constBorderRow.resize(getElemSize(bufType)*(maxWidth + ksize.width - 1 + VEC_ALIGN));
uchar *dst = alignPtr(&constBorderRow[0], VEC_ALIGN), *tdst;
int n = (int)constBorderValue.size(), N;
@@ -219,6 +222,7 @@ int FilterEngine::start(const Size &_wholeSize, const Size &sz, const Point &ofs
{
if( rowBorderType == BORDER_CONSTANT )
{
+ CV_Assert(constVal != NULL);
int nr = isSeparable() ? 1 : (int)rows.size();
for( i = 0; i < nr; i++ )
{
@@ -566,7 +570,7 @@ struct RowVec_8u32s
struct SymmRowSmallVec_8u32s
{
- SymmRowSmallVec_8u32s() { smallValues = false; }
+ SymmRowSmallVec_8u32s() { smallValues = false; symmetryType = 0; }
SymmRowSmallVec_8u32s( const Mat& _kernel, int _symmetryType )
{
kernel = _kernel;
@@ -870,7 +874,7 @@ struct SymmRowSmallVec_8u32s
struct SymmColumnVec_32s8u
{
- SymmColumnVec_32s8u() { symmetryType=0; }
+ SymmColumnVec_32s8u() { symmetryType=0; delta = 0; }
SymmColumnVec_32s8u(const Mat& _kernel, int _symmetryType, int _bits, double _delta)
{
symmetryType = _symmetryType;
@@ -1018,7 +1022,7 @@ struct SymmColumnVec_32s8u
struct SymmColumnSmallVec_32s16s
{
- SymmColumnSmallVec_32s16s() { symmetryType=0; }
+ SymmColumnSmallVec_32s16s() { symmetryType=0; delta = 0; }
SymmColumnSmallVec_32s16s(const Mat& _kernel, int _symmetryType, int _bits, double _delta)
{
symmetryType = _symmetryType;
@@ -1152,7 +1156,7 @@ struct SymmColumnSmallVec_32s16s
struct RowVec_16s32f
{
- RowVec_16s32f() {}
+ RowVec_16s32f() { sse2_supported = false; }
RowVec_16s32f( const Mat& _kernel )
{
kernel = _kernel;
@@ -1199,7 +1203,7 @@ struct RowVec_16s32f
struct SymmColumnVec_32f16s
{
- SymmColumnVec_32f16s() { symmetryType=0; }
+ SymmColumnVec_32f16s() { symmetryType=0; delta = 0; sse2_supported = false; }
SymmColumnVec_32f16s(const Mat& _kernel, int _symmetryType, int, double _delta)
{
symmetryType = _symmetryType;
@@ -1354,20 +1358,25 @@ struct RowVec_32f
RowVec_32f()
{
haveSSE = checkHardwareSupport(CV_CPU_SSE);
+ haveAVX2 = CV_CPU_HAS_SUPPORT_AVX2;
+#if defined USE_IPP_SEP_FILTERS
+ bufsz = -1;
+#endif
}
RowVec_32f( const Mat& _kernel )
{
kernel = _kernel;
haveSSE = checkHardwareSupport(CV_CPU_SSE);
-#if defined USE_IPP_SEP_FILTERS && IPP_DISABLE_BLOCK
+ haveAVX2 = CV_CPU_HAS_SUPPORT_AVX2;
+#if defined USE_IPP_SEP_FILTERS
bufsz = -1;
#endif
}
int operator()(const uchar* _src, uchar* _dst, int width, int cn) const
{
-#if defined USE_IPP_SEP_FILTERS && IPP_DISABLE_BLOCK
+#if defined USE_IPP_SEP_FILTERS
CV_IPP_CHECK()
{
int ret = ippiOperator(_src, _dst, width, cn);
@@ -1386,14 +1395,17 @@ struct RowVec_32f
int i = 0, k;
width *= cn;
+#if CV_TRY_AVX2
+ if (haveAVX2)
+ return RowVec_32f_AVX(src0, _kx, dst, width, cn, _ksize);
+#endif
for( ; i <= width - 8; i += 8 )
{
const float* src = src0 + i;
__m128 f, s0 = _mm_setzero_ps(), s1 = s0, x0, x1;
for( k = 0; k < _ksize; k++, src += cn )
{
- f = _mm_load_ss(_kx+k);
- f = _mm_shuffle_ps(f, f, 0);
+ f = _mm_set1_ps(_kx[k]);
x0 = _mm_loadu_ps(src);
x1 = _mm_loadu_ps(src + 4);
@@ -1408,7 +1420,8 @@ struct RowVec_32f
Mat kernel;
bool haveSSE;
-#if defined USE_IPP_SEP_FILTERS && IPP_DISABLE_BLOCK
+ bool haveAVX2;
+#if defined USE_IPP_SEP_FILTERS
private:
mutable int bufsz;
int ippiOperator(const uchar* _src, uchar* _dst, int width, int cn) const
@@ -1436,10 +1449,10 @@ private:
float borderValue[] = {0.f, 0.f, 0.f};
// here is the trick. IPP needs border type and extrapolates the row. We did it already.
// So we pass anchor=0 and ignore the right tail of results since they are incorrect there.
- if( (cn == 1 && CV_INSTRUMENT_FUN_IPP(ippiFilterRowBorderPipeline_32f_C1R,(src, step, &dst, roisz, _kx, _ksize, 0,
- ippBorderRepl, borderValue[0], bufptr)) < 0) ||
- (cn == 3 && CV_INSTRUMENT_FUN_IPP(ippiFilterRowBorderPipeline_32f_C3R,(src, step, &dst, roisz, _kx, _ksize, 0,
- ippBorderRepl, borderValue, bufptr)) < 0))
+ if( (cn == 1 && CV_INSTRUMENT_FUN_IPP(ippiFilterRowBorderPipeline_32f_C1R, src, step, &dst, roisz, _kx, _ksize, 0,
+ ippBorderRepl, borderValue[0], bufptr) < 0) ||
+ (cn == 3 && CV_INSTRUMENT_FUN_IPP(ippiFilterRowBorderPipeline_32f_C3R, src, step, &dst, roisz, _kx, _ksize, 0,
+ ippBorderRepl, borderValue, bufptr) < 0))
{
setIppErrorStatus();
return 0;
@@ -1453,7 +1466,7 @@ private:
struct SymmRowSmallVec_32f
{
- SymmRowSmallVec_32f() {}
+ SymmRowSmallVec_32f() { symmetryType = 0; }
SymmRowSmallVec_32f( const Mat& _kernel, int _symmetryType )
{
kernel = _kernel;
@@ -1646,18 +1659,25 @@ struct SymmRowSmallVec_32f
struct SymmColumnVec_32f
{
- SymmColumnVec_32f() { symmetryType=0; }
+ SymmColumnVec_32f() {
+ symmetryType=0;
+ haveSSE = checkHardwareSupport(CV_CPU_SSE);
+ haveAVX2 = CV_CPU_HAS_SUPPORT_AVX2;
+ delta = 0;
+ }
SymmColumnVec_32f(const Mat& _kernel, int _symmetryType, int, double _delta)
{
symmetryType = _symmetryType;
kernel = _kernel;
delta = (float)_delta;
+ haveSSE = checkHardwareSupport(CV_CPU_SSE);
+ haveAVX2 = CV_CPU_HAS_SUPPORT_AVX2;
CV_Assert( (symmetryType & (KERNEL_SYMMETRICAL | KERNEL_ASYMMETRICAL)) != 0 );
}
int operator()(const uchar** _src, uchar* _dst, int width) const
{
- if( !checkHardwareSupport(CV_CPU_SSE) )
+ if( !haveSSE )
return 0;
int ksize2 = (kernel.rows + kernel.cols - 1)/2;
@@ -1667,14 +1687,18 @@ struct SymmColumnVec_32f
const float** src = (const float**)_src;
const float *S, *S2;
float* dst = (float*)_dst;
- __m128 d4 = _mm_set1_ps(delta);
if( symmetrical )
{
+
+#if CV_TRY_AVX2
+ if (haveAVX2)
+ return SymmColumnVec_32f_Symm_AVX(src, ky, dst, delta, width, ksize2);
+#endif
+ const __m128 d4 = _mm_set1_ps(delta);
for( ; i <= width - 16; i += 16 )
{
- __m128 f = _mm_load_ss(ky);
- f = _mm_shuffle_ps(f, f, 0);
+ __m128 f = _mm_set1_ps(ky[0]);
__m128 s0, s1, s2, s3;
__m128 x0, x1;
S = src[0] + i;
@@ -1691,8 +1715,7 @@ struct SymmColumnVec_32f
{
S = src[k] + i;
S2 = src[-k] + i;
- f = _mm_load_ss(ky+k);
- f = _mm_shuffle_ps(f, f, 0);
+ f = _mm_set1_ps(ky[k]);
x0 = _mm_add_ps(_mm_load_ps(S), _mm_load_ps(S2));
x1 = _mm_add_ps(_mm_load_ps(S+4), _mm_load_ps(S2+4));
s0 = _mm_add_ps(s0, _mm_mul_ps(x0, f));
@@ -1711,15 +1734,13 @@ struct SymmColumnVec_32f
for( ; i <= width - 4; i += 4 )
{
- __m128 f = _mm_load_ss(ky);
- f = _mm_shuffle_ps(f, f, 0);
+ __m128 f = _mm_set1_ps(ky[0]);
__m128 x0, s0 = _mm_load_ps(src[0] + i);
s0 = _mm_add_ps(_mm_mul_ps(s0, f), d4);
for( k = 1; k <= ksize2; k++ )
{
- f = _mm_load_ss(ky+k);
- f = _mm_shuffle_ps(f, f, 0);
+ f = _mm_set1_ps(ky[k]);
S = src[k] + i;
S2 = src[-k] + i;
x0 = _mm_add_ps(_mm_load_ps(src[k]+i), _mm_load_ps(src[-k] + i));
@@ -1731,6 +1752,11 @@ struct SymmColumnVec_32f
}
else
{
+#if CV_TRY_AVX2
+ if (haveAVX2)
+ return SymmColumnVec_32f_Unsymm_AVX(src, ky, dst, delta, width, ksize2);
+#endif
+ const __m128 d4 = _mm_set1_ps(delta);
for( ; i <= width - 16; i += 16 )
{
__m128 f, s0 = d4, s1 = d4, s2 = d4, s3 = d4;
@@ -1741,8 +1767,7 @@ struct SymmColumnVec_32f
{
S = src[k] + i;
S2 = src[-k] + i;
- f = _mm_load_ss(ky+k);
- f = _mm_shuffle_ps(f, f, 0);
+ f = _mm_set1_ps(ky[k]);
x0 = _mm_sub_ps(_mm_load_ps(S), _mm_load_ps(S2));
x1 = _mm_sub_ps(_mm_load_ps(S+4), _mm_load_ps(S2+4));
s0 = _mm_add_ps(s0, _mm_mul_ps(x0, f));
@@ -1765,8 +1790,7 @@ struct SymmColumnVec_32f
for( k = 1; k <= ksize2; k++ )
{
- f = _mm_load_ss(ky+k);
- f = _mm_shuffle_ps(f, f, 0);
+ f = _mm_set1_ps(ky[k]);
x0 = _mm_sub_ps(_mm_load_ps(src[k]+i), _mm_load_ps(src[-k] + i));
s0 = _mm_add_ps(s0, _mm_mul_ps(x0, f));
}
@@ -1781,12 +1805,14 @@ struct SymmColumnVec_32f
int symmetryType;
float delta;
Mat kernel;
+ bool haveSSE;
+ bool haveAVX2;
};
struct SymmColumnSmallVec_32f
{
- SymmColumnSmallVec_32f() { symmetryType=0; }
+ SymmColumnSmallVec_32f() { symmetryType=0; delta = 0; }
SymmColumnSmallVec_32f(const Mat& _kernel, int _symmetryType, int, double _delta)
{
symmetryType = _symmetryType;
@@ -1918,7 +1944,7 @@ struct SymmColumnSmallVec_32f
struct FilterVec_8u
{
- FilterVec_8u() {}
+ FilterVec_8u() { delta = 0; _nz = 0; }
FilterVec_8u(const Mat& _kernel, int _bits, double _delta)
{
Mat kernel;
@@ -2001,7 +2027,7 @@ struct FilterVec_8u
struct FilterVec_8u16s
{
- FilterVec_8u16s() {}
+ FilterVec_8u16s() { delta = 0; _nz = 0; }
FilterVec_8u16s(const Mat& _kernel, int _bits, double _delta)
{
Mat kernel;
@@ -2084,7 +2110,7 @@ struct FilterVec_8u16s
struct FilterVec_32f
{
- FilterVec_32f() {}
+ FilterVec_32f() { delta = 0; _nz = 0; }
FilterVec_32f(const Mat& _kernel, int, double _delta)
{
delta = (float)_delta;
@@ -4145,7 +4171,7 @@ static bool ocl_sepRowFilter2D(const UMat & src, UMat & buf, const Mat & kernelX
if (!doubleSupport && (sdepth == CV_64F || ddepth == CV_64F))
return false;
-#ifdef ANDROID
+#ifdef __ANDROID__
size_t localsize[2] = {16, 10};
#else
size_t localsize[2] = {16, 16};
@@ -4210,7 +4236,7 @@ static bool ocl_sepColFilter2D(const UMat & buf, UMat & dst, const Mat & kernelY
if (dst.depth() == CV_64F && !doubleSupport)
return false;
-#ifdef ANDROID
+#ifdef __ANDROID__
size_t localsize[2] = { 16, 10 };
#else
size_t localsize[2] = { 16, 16 };
@@ -4509,39 +4535,29 @@ cv::Ptr<cv::FilterEngine> cv::createLinearFilter( int _srcType, int _dstType,
using namespace cv;
-struct ReplacementFilter : public hal::Filter2D
+static bool replacementFilter2D(int stype, int dtype, int kernel_type,
+ uchar * src_data, size_t src_step,
+ uchar * dst_data, size_t dst_step,
+ int width, int height,
+ int full_width, int full_height,
+ int offset_x, int offset_y,
+ uchar * kernel_data, size_t kernel_step,
+ int kernel_width, int kernel_height,
+ int anchor_x, int anchor_y,
+ double delta, int borderType, bool isSubmatrix)
{
cvhalFilter2D* ctx;
- bool isInitialized;
- ReplacementFilter() : ctx(0), isInitialized(false) { }
- bool init(uchar* kernel_data, size_t kernel_step, int kernel_type, int kernel_width,
- int kernel_height, int max_width, int max_height, int stype, int dtype, int borderType, double delta,
- int anchor_x, int anchor_y, bool isSubmatrix, bool isInplace)
- {
- int res = cv_hal_filterInit(&ctx, kernel_data, kernel_step, kernel_type, kernel_width, kernel_height, max_width, max_height,
- stype, dtype, borderType, delta, anchor_x, anchor_y, isSubmatrix, isInplace);
- isInitialized = (res == CV_HAL_ERROR_OK);
- return isInitialized;
- }
- void apply(uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step, int width, int height, int full_width, int full_height, int offset_x, int offset_y)
- {
- if (isInitialized)
- {
- int res = cv_hal_filter(ctx, src_data, src_step, dst_data, dst_step, width, height, full_width, full_height, offset_x, offset_y);
- if (res != CV_HAL_ERROR_OK)
- CV_Error(Error::StsNotImplemented, "HAL Filter returned an error");
- }
- }
- ~ReplacementFilter()
- {
- if (isInitialized)
- {
- int res = cv_hal_filterFree(ctx);
- if (res != CV_HAL_ERROR_OK)
- CV_Error(Error::StsNotImplemented, "HAL Filter Free returned an error");
- }
- }
-};
+ int res = cv_hal_filterInit(&ctx, kernel_data, kernel_step, kernel_type, kernel_width, kernel_height, width, height,
+ stype, dtype, borderType, delta, anchor_x, anchor_y, isSubmatrix, src_data == dst_data);
+ if (res != CV_HAL_ERROR_OK)
+ return false;
+ res = cv_hal_filter(ctx, src_data, src_step, dst_data, dst_step, width, height, full_width, full_height, offset_x, offset_y);
+ bool success = (res == CV_HAL_ERROR_OK);
+ res = cv_hal_filterFree(ctx);
+ if (res != CV_HAL_ERROR_OK)
+ return false;
+ return success;
+}
#ifdef HAVE_IPP
typedef IppStatus(CV_STDCALL* IppiFilterBorder)(
@@ -4613,8 +4629,17 @@ struct IppFilterTrait<CV_32F>
};
template <int kdepth>
-struct IppFilter : public hal::Filter2D
+static bool ippFilter2D(int stype, int dtype,
+ uchar * src_data, size_t src_step,
+ uchar * dst_data, size_t dst_step,
+ int width, int height,
+ uchar * kernel_data, size_t kernel_step,
+ int kernel_width, int kernel_height,
+ int anchor_x, int anchor_y,
+ double delta, int borderType, bool isSubmatrix)
{
+ CV_INSTRUMENT_REGION_IPP();
+
typedef IppFilterTrait<kdepth> trait;
typedef typename trait::kernel_type kernel_type;
@@ -4624,105 +4649,93 @@ struct IppFilter : public hal::Filter2D
IppiBorderType ippBorderType;
int src_type;
- bool init(uchar* kernel_data, size_t kernel_step, int, int kernel_width, int kernel_height,
- int max_width, int max_height, int stype, int dtype,
- int borderType, double delta, int anchor_x, int anchor_y, bool isSubmatrix, bool isInplace)
- {
- Point anchor(anchor_x, anchor_y);
+ Point anchor(anchor_x, anchor_y);
#if IPP_VERSION_X100 >= 900
- Point ippAnchor((kernel_width - 1) / 2, (kernel_height - 1) / 2);
+ Point ippAnchor((kernel_width - 1) / 2, (kernel_height - 1) / 2);
#else
- Point ippAnchor(kernel_width >> 1, kernel_height >> 1);
+ Point ippAnchor(kernel_width >> 1, kernel_height >> 1);
#endif
- bool isIsolated = (borderType & BORDER_ISOLATED) != 0;
- int borderTypeNI = borderType & ~BORDER_ISOLATED;
- ippBorderType = ippiGetBorderType(borderTypeNI);
- int ddepth = CV_MAT_DEPTH(dtype);
- int sdepth = CV_MAT_DEPTH(stype);
-
-#if IPP_VERSION_X100 >= 201700 && IPP_VERSION_X100 < 201702 // IPP bug with 1x1 kernel
- if(kernel_width == 1 && kernel_height == 1)
- return false;
+ bool isIsolated = (borderType & BORDER_ISOLATED) != 0;
+ int borderTypeNI = borderType & ~BORDER_ISOLATED;
+ ippBorderType = ippiGetBorderType(borderTypeNI);
+ int ddepth = CV_MAT_DEPTH(dtype);
+ int sdepth = CV_MAT_DEPTH(stype);
+
+#if IPP_VERSION_X100 >= 201700 && IPP_VERSION_X100 <= 201702 // IPP bug with 1x1 kernel
+ if(kernel_width == 1 && kernel_height == 1)
+ return false;
#endif
- bool runIpp = true
- && (borderTypeNI == BORDER_CONSTANT || borderTypeNI == BORDER_REPLICATE)
- && (sdepth == ddepth)
- && (getIppFunc(stype))
- && ((int)ippBorderType > 0)
- && (!isSubmatrix || isIsolated)
- && (std::fabs(delta - 0) < DBL_EPSILON)
- && (ippAnchor == anchor)
- && !isInplace;
-
- if (!runIpp)
- return false;
+ bool runIpp = true
+ && (borderTypeNI == BORDER_CONSTANT || borderTypeNI == BORDER_REPLICATE)
+ && (sdepth == ddepth)
+ && (getIppFunc(stype))
+ && ((int)ippBorderType > 0)
+ && (!isSubmatrix || isIsolated)
+ && (std::fabs(delta - 0) < DBL_EPSILON)
+ && (ippAnchor == anchor)
+ && src_data != dst_data;
+
+ if (!runIpp)
+ return false;
- src_type = stype;
- int cn = CV_MAT_CN(stype);
- IppiSize kernelSize = { kernel_width, kernel_height };
- IppDataType dataType = ippiGetDataType(ddepth);
- IppDataType kernelType = ippiGetDataType(kdepth);
- Ipp32s specSize = 0;
- Ipp32s bufsize = 0;
- IppiSize dstRoiSize = { max_width, max_height };
- IppStatus status;
- status = ippiFilterBorderGetSize(kernelSize, dstRoiSize, dataType, kernelType, cn, &specSize, &bufsize);
- if (status >= 0) {
- kernel_type* pKerBuffer = (kernel_type*)kernel_data;
- size_t good_kernel_step = sizeof(kernel_type) * static_cast<size_t>(kernelSize.width);
+ src_type = stype;
+ int cn = CV_MAT_CN(stype);
+ IppiSize kernelSize = { kernel_width, kernel_height };
+ IppDataType dataType = ippiGetDataType(ddepth);
+ IppDataType kernelType = ippiGetDataType(kdepth);
+ Ipp32s specSize = 0;
+ Ipp32s bufsize = 0;
+ IppiSize dstRoiSize = { width, height };
+ IppStatus status;
+
+ status = ippiFilterBorderGetSize(kernelSize, dstRoiSize, dataType, kernelType, cn, &specSize, &bufsize);
+ if (status < 0)
+ return false;
+
+ kernel_type* pKerBuffer = (kernel_type*)kernel_data;
+ size_t good_kernel_step = sizeof(kernel_type) * static_cast<size_t>(kernelSize.width);
#if IPP_VERSION_X100 >= 900
- if (kernel_step != good_kernel_step) {
- kernelBuffer.Alloc((int)good_kernel_step * kernelSize.height);
- status = trait::get_copy_fun()((kernel_type*)kernel_data, (int)kernel_step, kernelBuffer, (int)good_kernel_step, kernelSize);
- if (status < 0)
- return false;
- pKerBuffer = kernelBuffer;
- }
+ if (kernel_step != good_kernel_step) {
+ kernelBuffer.allocate((int)good_kernel_step * kernelSize.height);
+ status = trait::get_copy_fun()((kernel_type*)kernel_data, (int)kernel_step, kernelBuffer, (int)good_kernel_step, kernelSize);
+ if (status < 0)
+ return false;
+ pKerBuffer = kernelBuffer;
+ }
#else
- kernelBuffer.Alloc(good_kernel_step * kernelSize.height);
- Mat kerFlip(Size(kernelSize.width, kernelSize.height), trait::kernel_type_id, kernelBuffer, (int)good_kernel_step);
- Mat kernel(Size(kernel_width, kernel_height), trait::kernel_type_id, kernel_data, kernel_step);
- flip(kernel, kerFlip, -1);
- pKerBuffer = kernelBuffer;
+ kernelBuffer.Alloc(good_kernel_step * kernelSize.height);
+ Mat kerFlip(Size(kernelSize.width, kernelSize.height), trait::kernel_type_id, kernelBuffer, (int)good_kernel_step);
+ Mat kernel(Size(kernel_width, kernel_height), trait::kernel_type_id, kernel_data, kernel_step);
+ flip(kernel, kerFlip, -1);
+ pKerBuffer = kernelBuffer;
#endif
- spec.Alloc(specSize);
- buffer.Alloc(bufsize);
- status = trait::runInit(pKerBuffer, kernelSize, 0, dataType, cn, ippRndFinancial, spec);
- if (status >= 0) {
- return true;
- }
- }
+ spec.allocate(specSize);
+ buffer.allocate(bufsize);
+ status = trait::runInit(pKerBuffer, kernelSize, 0, dataType, cn, ippRndFinancial, spec);
+ if (status < 0) {
return false;
}
-
- void apply(uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step, int width, int height, int, int, int, int)
- {
- CV_INSTRUMENT_REGION_IPP()
-
- if (dst_data == src_data)
- CV_Error(Error::StsBadArg, "Inplace IPP Filter2D is not supported");
- IppiFilterBorder ippiFilterBorder = getIppFunc(src_type);
- IppiSize dstRoiSize = { width, height };
- kernel_type borderValue[4] = { 0, 0, 0, 0 };
- IppStatus status = CV_INSTRUMENT_FUN_IPP(ippiFilterBorder, src_data, (int)src_step, dst_data, (int)dst_step, dstRoiSize, ippBorderType, borderValue, spec, buffer);
- if (status >= 0) {
- CV_IMPL_ADD(CV_IMPL_IPP);
- }
+ IppiFilterBorder ippiFilterBorder = getIppFunc(src_type);
+ kernel_type borderValue[4] = { 0, 0, 0, 0 };
+ status = CV_INSTRUMENT_FUN_IPP(ippiFilterBorder, src_data, (int)src_step, dst_data, (int)dst_step, dstRoiSize, ippBorderType, borderValue, spec, buffer);
+ if (status >= 0) {
+ CV_IMPL_ADD(CV_IMPL_IPP);
+ return true;
}
-};
+ return false;
+}
#endif
-struct DftFilter : public hal::Filter2D
+static bool dftFilter2D(int stype, int dtype, int kernel_type,
+ uchar * src_data, size_t src_step,
+ uchar * dst_data, size_t dst_step,
+ int width, int height,
+ uchar * kernel_data, size_t kernel_step,
+ int kernel_width, int kernel_height,
+ int anchor_x, int anchor_y,
+ double delta, int borderType)
{
- int src_type;
- int dst_type;
- double delta;
- Mat kernel;
- Point anchor;
- int borderType;
-
- static bool isAppropriate(int stype, int dtype, int kernel_width, int kernel_height)
{
#if CV_SSE2
int sdepth = CV_MAT_DEPTH(stype);
@@ -4733,162 +4746,112 @@ struct DftFilter : public hal::Filter2D
CV_UNUSED(dtype);
int dft_filter_size = 50;
#endif
- return kernel_width * kernel_height >= dft_filter_size;
- }
-
- bool init(uchar* kernel_data, size_t kernel_step, int kernel_type, int kernel_width, int kernel_height,
- int, int, int stype, int dtype,
- int borderType_, double delta_, int anchor_x, int anchor_y, bool, bool)
- {
- anchor = Point(anchor_x, anchor_y);
- borderType = borderType_;
- kernel = Mat(Size(kernel_width, kernel_height), kernel_type, kernel_data, kernel_step);
- src_type = stype;
- dst_type = dtype;
- delta = delta_;
- if (isAppropriate(stype, dtype, kernel_width, kernel_height))
- return true;
- return false;
+ if (kernel_width * kernel_height < dft_filter_size)
+ return false;
}
- void apply(uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step, int width, int height, int, int, int, int)
- {
- Mat src(Size(width, height), src_type, src_data, src_step);
- Mat dst(Size(width, height), dst_type, dst_data, dst_step);
- Mat temp;
- int src_channels = CV_MAT_CN(src_type);
- int dst_channels = CV_MAT_CN(dst_type);
- int ddepth = CV_MAT_DEPTH(dst_type);
- // crossCorr doesn't accept non-zero delta with multiple channels
- if (src_channels != 1 && delta != 0) {
- // The semantics of filter2D require that the delta be applied
- // as floating-point math. So wee need an intermediate Mat
- // with a float datatype. If the dest is already floats,
- // we just use that.
- int corrDepth = ddepth;
- if ((ddepth == CV_32F || ddepth == CV_64F) && src_data != dst_data) {
- temp = Mat(Size(width, height), dst_type, dst_data, dst_step);
- } else {
- corrDepth = ddepth == CV_64F ? CV_64F : CV_32F;
- temp.create(Size(width, height), CV_MAKETYPE(corrDepth, dst_channels));
- }
- crossCorr(src, kernel, temp, src.size(),
- CV_MAKETYPE(corrDepth, src_channels),
- anchor, 0, borderType);
- add(temp, delta, temp);
- if (temp.data != dst_data) {
- temp.convertTo(dst, dst.type());
- }
+ Point anchor = Point(anchor_x, anchor_y);
+ Mat kernel = Mat(Size(kernel_width, kernel_height), kernel_type, kernel_data, kernel_step);
+
+ Mat src(Size(width, height), stype, src_data, src_step);
+ Mat dst(Size(width, height), dtype, dst_data, dst_step);
+ Mat temp;
+ int src_channels = CV_MAT_CN(stype);
+ int dst_channels = CV_MAT_CN(dtype);
+ int ddepth = CV_MAT_DEPTH(dtype);
+ // crossCorr doesn't accept non-zero delta with multiple channels
+ if (src_channels != 1 && delta != 0) {
+ // The semantics of filter2D require that the delta be applied
+ // as floating-point math. So wee need an intermediate Mat
+ // with a float datatype. If the dest is already floats,
+ // we just use that.
+ int corrDepth = ddepth;
+ if ((ddepth == CV_32F || ddepth == CV_64F) && src_data != dst_data) {
+ temp = Mat(Size(width, height), dtype, dst_data, dst_step);
} else {
- if (src_data != dst_data)
- temp = Mat(Size(width, height), dst_type, dst_data, dst_step);
- else
- temp.create(Size(width, height), dst_type);
- crossCorr(src, kernel, temp, src.size(),
- CV_MAKETYPE(ddepth, src_channels),
- anchor, delta, borderType);
- if (temp.data != dst_data)
- temp.copyTo(dst);
+ corrDepth = ddepth == CV_64F ? CV_64F : CV_32F;
+ temp.create(Size(width, height), CV_MAKETYPE(corrDepth, dst_channels));
+ }
+ crossCorr(src, kernel, temp, src.size(),
+ CV_MAKETYPE(corrDepth, src_channels),
+ anchor, 0, borderType);
+ add(temp, delta, temp);
+ if (temp.data != dst_data) {
+ temp.convertTo(dst, dst.type());
}
+ } else {
+ if (src_data != dst_data)
+ temp = Mat(Size(width, height), dtype, dst_data, dst_step);
+ else
+ temp.create(Size(width, height), dtype);
+ crossCorr(src, kernel, temp, src.size(),
+ CV_MAKETYPE(ddepth, src_channels),
+ anchor, delta, borderType);
+ if (temp.data != dst_data)
+ temp.copyTo(dst);
}
-};
+ return true;
+}
-struct OcvFilter : public hal::Filter2D
+static void ocvFilter2D(int stype, int dtype, int kernel_type,
+ uchar * src_data, size_t src_step,
+ uchar * dst_data, size_t dst_step,
+ int width, int height,
+ int full_width, int full_height,
+ int offset_x, int offset_y,
+ uchar * kernel_data, size_t kernel_step,
+ int kernel_width, int kernel_height,
+ int anchor_x, int anchor_y,
+ double delta, int borderType)
{
- Ptr<FilterEngine> f;
- int src_type;
- int dst_type;
- bool isIsolated;
-
- bool init(uchar* kernel_data, size_t kernel_step, int kernel_type, int kernel_width,
- int kernel_height, int, int, int stype, int dtype, int borderType, double delta,
- int anchor_x, int anchor_y, bool, bool)
- {
- isIsolated = (borderType & BORDER_ISOLATED) != 0;
- src_type = stype;
- dst_type = dtype;
- int borderTypeValue = borderType & ~BORDER_ISOLATED;
- Mat kernel = Mat(Size(kernel_width, kernel_height), kernel_type, kernel_data, kernel_step);
- f = createLinearFilter(src_type, dst_type, kernel, Point(anchor_x, anchor_y), delta,
- borderTypeValue);
- return true;
- }
- void apply(uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step, int width, int height, int full_width, int full_height, int offset_x, int offset_y)
- {
- Mat src(Size(width, height), src_type, src_data, src_step);
- Mat dst(Size(width, height), dst_type, dst_data, dst_step);
- f->apply(src, dst, Size(full_width, full_height), Point(offset_x, offset_y));
- }
-};
-
+ int borderTypeValue = borderType & ~BORDER_ISOLATED;
+ Mat kernel = Mat(Size(kernel_width, kernel_height), kernel_type, kernel_data, kernel_step);
+ Ptr<FilterEngine> f = createLinearFilter(stype, dtype, kernel, Point(anchor_x, anchor_y), delta,
+ borderTypeValue);
+ Mat src(Size(width, height), stype, src_data, src_step);
+ Mat dst(Size(width, height), dtype, dst_data, dst_step);
+ f->apply(src, dst, Size(full_width, full_height), Point(offset_x, offset_y));
+}
-struct ReplacementSepFilter : public hal::SepFilter2D
+static bool replacementSepFilter(int stype, int dtype, int ktype,
+ uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step,
+ int width, int height, int full_width, int full_height,
+ int offset_x, int offset_y,
+ uchar * kernelx_data, int kernelx_len,
+ uchar * kernely_data, int kernely_len,
+ int anchor_x, int anchor_y, double delta, int borderType)
{
cvhalFilter2D *ctx;
- bool isInitialized;
- ReplacementSepFilter() : ctx(0), isInitialized(false) {}
- bool init(int stype, int dtype, int ktype,
- uchar * kernelx_data, int kernelx_len,
- uchar * kernely_data, int kernely_len,
- int anchor_x, int anchor_y, double delta, int borderType)
- {
- int res = cv_hal_sepFilterInit(&ctx, stype, dtype, ktype,
- kernelx_data, kernelx_len,
- kernely_data, kernely_len,
- anchor_x, anchor_y, delta, borderType);
- isInitialized = (res == CV_HAL_ERROR_OK);
- return isInitialized;
- }
- void apply(uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step,
- int width, int height, int full_width, int full_height,
- int offset_x, int offset_y)
- {
- if (isInitialized)
- {
- int res = cv_hal_sepFilter(ctx, src_data, src_step, dst_data, dst_step, width, height, full_width, full_height, offset_x, offset_y);
- if (res != CV_HAL_ERROR_OK)
- CV_Error(Error::StsNotImplemented, "Failed to run HAL sepFilter implementation");
- }
- }
- ~ReplacementSepFilter()
- {
- if (isInitialized)
- {
- int res = cv_hal_sepFilterFree(ctx);
- if (res != CV_HAL_ERROR_OK)
- CV_Error(Error::StsNotImplemented, "Failed to run HAL sepFilter implementation");
- }
- }
-};
+ int res = cv_hal_sepFilterInit(&ctx, stype, dtype, ktype,
+ kernelx_data, kernelx_len,
+ kernely_data, kernely_len,
+ anchor_x, anchor_y, delta, borderType);
+ if (res != CV_HAL_ERROR_OK)
+ return false;
+ res = cv_hal_sepFilter(ctx, src_data, src_step, dst_data, dst_step, width, height, full_width, full_height, offset_x, offset_y);
+ bool success = (res == CV_HAL_ERROR_OK);
+ res = cv_hal_sepFilterFree(ctx);
+ if (res != CV_HAL_ERROR_OK)
+ return false;
+ return success;
+}
-struct OcvSepFilter : public hal::SepFilter2D
+static void ocvSepFilter(int stype, int dtype, int ktype,
+ uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step,
+ int width, int height, int full_width, int full_height,
+ int offset_x, int offset_y,
+ uchar * kernelx_data, int kernelx_len,
+ uchar * kernely_data, int kernely_len,
+ int anchor_x, int anchor_y, double delta, int borderType)
{
- Ptr<FilterEngine> f;
- int src_type;
- int dst_type;
- bool init(int stype, int dtype, int ktype,
- uchar * kernelx_data, int kernelx_len,
- uchar * kernely_data, int kernely_len,
- int anchor_x, int anchor_y, double delta, int borderType)
- {
- src_type = stype;
- dst_type = dtype;
- Mat kernelX(Size(kernelx_len, 1), ktype, kernelx_data);
- Mat kernelY(Size(kernely_len, 1), ktype, kernely_data);
-
- f = createSeparableLinearFilter( stype, dtype, kernelX, kernelY,
- Point(anchor_x, anchor_y),
- delta, borderType & ~BORDER_ISOLATED );
- return true;
- }
- void apply(uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step,
- int width, int height, int full_width, int full_height,
- int offset_x, int offset_y)
- {
- Mat src(Size(width, height), src_type, src_data, src_step);
- Mat dst(Size(width, height), dst_type, dst_data, dst_step);
- f->apply(src, dst, Size(full_width, full_height), Point(offset_x, offset_y));
- }
+ Mat kernelX(Size(kernelx_len, 1), ktype, kernelx_data);
+ Mat kernelY(Size(kernely_len, 1), ktype, kernely_data);
+ Ptr<FilterEngine> f = createSeparableLinearFilter(stype, dtype, kernelX, kernelY,
+ Point(anchor_x, anchor_y),
+ delta, borderType & ~BORDER_ISOLATED);
+ Mat src(Size(width, height), stype, src_data, src_step);
+ Mat dst(Size(width, height), dtype, dst_data, dst_step);
+ f->apply(src, dst, Size(full_width, full_height), Point(offset_x, offset_y));
};
//===================================================================
@@ -4898,97 +4861,124 @@ struct OcvSepFilter : public hal::SepFilter2D
namespace cv {
namespace hal {
-Ptr<hal::Filter2D> Filter2D::create(uchar* kernel_data, size_t kernel_step, int kernel_type,
- int kernel_width, int kernel_height,
- int max_width, int max_height,
- int stype, int dtype,
- int borderType, double delta, int anchor_x, int anchor_y, bool isSubmatrix, bool isInplace)
-{
- {
- ReplacementFilter* impl = new ReplacementFilter();
- if (impl->init(kernel_data, kernel_step, kernel_type, kernel_width, kernel_height,
- max_width, max_height, stype, dtype,
- borderType, delta, anchor_x, anchor_y, isSubmatrix, isInplace))
- {
- return Ptr<hal::Filter2D>(impl);
- }
- delete impl;
- }
+CV_DEPRECATED Ptr<hal::Filter2D> Filter2D::create(uchar * , size_t , int ,
+ int , int ,
+ int , int ,
+ int , int ,
+ int , double ,
+ int , int ,
+ bool , bool ) { return Ptr<hal::Filter2D>(); }
+
+CV_DEPRECATED Ptr<hal::SepFilter2D> SepFilter2D::create(int , int , int ,
+ uchar * , int ,
+ uchar * , int ,
+ int , int ,
+ double , int ) { return Ptr<hal::SepFilter2D>(); }
+
+
+void filter2D(int stype, int dtype, int kernel_type,
+ uchar * src_data, size_t src_step,
+ uchar * dst_data, size_t dst_step,
+ int width, int height,
+ int full_width, int full_height,
+ int offset_x, int offset_y,
+ uchar * kernel_data, size_t kernel_step,
+ int kernel_width, int kernel_height,
+ int anchor_x, int anchor_y,
+ double delta, int borderType,
+ bool isSubmatrix)
+{
+ bool res;
+ res = replacementFilter2D(stype, dtype, kernel_type,
+ src_data, src_step,
+ dst_data, dst_step,
+ width, height,
+ full_width, full_height,
+ offset_x, offset_y,
+ kernel_data, kernel_step,
+ kernel_width, kernel_height,
+ anchor_x, anchor_y,
+ delta, borderType, isSubmatrix);
+ if (res)
+ return;
#ifdef HAVE_IPP
CV_IPP_CHECK()
{
+ res = false;
if (kernel_type == CV_32FC1) {
- IppFilter<CV_32F>* impl = new IppFilter<CV_32F>();
- if (impl->init(kernel_data, kernel_step, kernel_type, kernel_width, kernel_height,
- max_width, max_height, stype, dtype,
- borderType, delta, anchor_x, anchor_y, isSubmatrix, isInplace))
- {
- return Ptr<hal::Filter2D>(impl);
- }
- delete impl;
+ res = ippFilter2D<CV_32F>(stype, dtype,
+ src_data, src_step,
+ dst_data, dst_step,
+ width, height,
+ kernel_data, kernel_step,
+ kernel_width, kernel_height,
+ anchor_x, anchor_y,
+ delta, borderType, isSubmatrix);
}
-
- if (kernel_type == CV_16SC1) {
- IppFilter<CV_16S>* impl = new IppFilter<CV_16S>();
- if (impl->init(kernel_data, kernel_step, kernel_type, kernel_width, kernel_height,
- max_width, max_height, stype, dtype,
- borderType, delta, anchor_x, anchor_y, isSubmatrix, isInplace))
- {
- return Ptr<hal::Filter2D>(impl);
- }
- delete impl;
+ else if (kernel_type == CV_16SC1) {
+ res = ippFilter2D<CV_16S>(stype, dtype,
+ src_data, src_step,
+ dst_data, dst_step,
+ width, height,
+ kernel_data, kernel_step,
+ kernel_width, kernel_height,
+ anchor_x, anchor_y,
+ delta, borderType, isSubmatrix);
}
+ if (res)
+ return;
}
#endif
-
- if (DftFilter::isAppropriate(stype, dtype, kernel_width, kernel_height))
- {
- DftFilter* impl = new DftFilter();
- if (impl->init(kernel_data, kernel_step, kernel_type, kernel_width, kernel_height,
- max_width, max_height, stype, dtype,
- borderType, delta, anchor_x, anchor_y, isSubmatrix, isInplace))
- {
- return Ptr<hal::Filter2D>(impl);
- }
- delete impl;
- }
-
- {
- OcvFilter* impl = new OcvFilter();
- impl->init(kernel_data, kernel_step, kernel_type, kernel_width, kernel_height,
- max_width, max_height, stype, dtype,
- borderType, delta, anchor_x, anchor_y, isSubmatrix, isInplace);
- return Ptr<hal::Filter2D>(impl);
- }
+ res = dftFilter2D(stype, dtype, kernel_type,
+ src_data, src_step,
+ dst_data, dst_step,
+ width, height,
+ kernel_data, kernel_step,
+ kernel_width, kernel_height,
+ anchor_x, anchor_y,
+ delta, borderType);
+ if (res)
+ return;
+ ocvFilter2D(stype, dtype, kernel_type,
+ src_data, src_step,
+ dst_data, dst_step,
+ width, height,
+ full_width, full_height,
+ offset_x, offset_y,
+ kernel_data, kernel_step,
+ kernel_width, kernel_height,
+ anchor_x, anchor_y,
+ delta, borderType);
}
//---------------------------------------------------------------
-Ptr<SepFilter2D> SepFilter2D::create(int stype, int dtype, int ktype,
- uchar * kernelx_data, int kernelx_len,
- uchar * kernely_data, int kernely_len,
- int anchor_x, int anchor_y, double delta, int borderType)
+void sepFilter2D(int stype, int dtype, int ktype,
+ uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step,
+ int width, int height, int full_width, int full_height,
+ int offset_x, int offset_y,
+ uchar * kernelx_data, int kernelx_len,
+ uchar * kernely_data, int kernely_len,
+ int anchor_x, int anchor_y, double delta, int borderType)
{
- {
- ReplacementSepFilter * impl = new ReplacementSepFilter();
- if (impl->init(stype, dtype, ktype,
- kernelx_data, kernelx_len,
- kernely_data, kernely_len,
- anchor_x, anchor_y, delta, borderType))
- {
- return Ptr<hal::SepFilter2D>(impl);
- }
- delete impl;
- }
- {
- OcvSepFilter * impl = new OcvSepFilter();
- impl->init(stype, dtype, ktype,
- kernelx_data, kernelx_len,
- kernely_data, kernely_len,
- anchor_x, anchor_y, delta, borderType);
- return Ptr<hal::SepFilter2D>(impl);
- }
+
+ bool res = replacementSepFilter(stype, dtype, ktype,
+ src_data, src_step, dst_data, dst_step,
+ width, height, full_width, full_height,
+ offset_x, offset_y,
+ kernelx_data, kernelx_len,
+ kernely_data, kernely_len,
+ anchor_x, anchor_y, delta, borderType);
+ if (res)
+ return;
+ ocvSepFilter(stype, dtype, ktype,
+ src_data, src_step, dst_data, dst_step,
+ width, height, full_width, full_height,
+ offset_x, offset_y,
+ kernelx_data, kernelx_len,
+ kernely_data, kernely_len,
+ anchor_x, anchor_y, delta, borderType);
}
} // cv::hal::
@@ -5021,10 +5011,12 @@ void cv::filter2D( InputArray _src, OutputArray _dst, int ddepth,
if( (borderType & BORDER_ISOLATED) == 0 )
src.locateROI( wsz, ofs );
- Ptr<hal::Filter2D> c = hal::Filter2D::create(kernel.data, kernel.step, kernel.type(), kernel.cols, kernel.rows,
- dst.cols, dst.rows, src.type(), dst.type(),
- borderType, delta, anchor.x, anchor.y, src.isSubmatrix(), src.data == dst.data);
- c->apply(src.data, src.step, dst.data, dst.step, dst.cols, dst.rows, wsz.width, wsz.height, ofs.x, ofs.y);
+ hal::filter2D(src.type(), dst.type(), kernel.type(),
+ src.data, src.step, dst.data, dst.step,
+ dst.cols, dst.rows, wsz.width, wsz.height, ofs.x, ofs.y,
+ kernel.data, kernel.step, kernel.cols, kernel.rows,
+ anchor.x, anchor.y,
+ delta, borderType, src.isSubmatrix());
}
void cv::sepFilter2D( InputArray _src, OutputArray _dst, int ddepth,
@@ -5055,11 +5047,13 @@ void cv::sepFilter2D( InputArray _src, OutputArray _dst, int ddepth,
Mat contKernelX = kernelX.isContinuous() ? kernelX : kernelX.clone();
Mat contKernelY = kernelY.isContinuous() ? kernelY : kernelY.clone();
- Ptr<hal::SepFilter2D> c = hal::SepFilter2D::create(src.type(), dst.type(), kernelX.type(),
- contKernelX.data, kernelX.cols + kernelX.rows - 1,
- contKernelY.data, kernelY.cols + kernelY.rows - 1,
- anchor.x, anchor.y, delta, borderType & ~BORDER_ISOLATED);
- c->apply(src.data, src.step, dst.data, dst.step, dst.cols, dst.rows, wsz.width, wsz.height, ofs.x, ofs.y);
+
+ hal::sepFilter2D(src.type(), dst.type(), kernelX.type(),
+ src.data, src.step, dst.data, dst.step,
+ dst.cols, dst.rows, wsz.width, wsz.height, ofs.x, ofs.y,
+ contKernelX.data, kernelX.cols + kernelX.rows - 1,
+ contKernelY.data, kernelY.cols + kernelY.rows - 1,
+ anchor.x, anchor.y, delta, borderType & ~BORDER_ISOLATED);
}
diff --git a/modules/imgproc/src/filter.hpp b/modules/imgproc/src/filter.hpp
new file mode 100644
index 0000000..c878fea
--- /dev/null
+++ b/modules/imgproc/src/filter.hpp
@@ -0,0 +1,57 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
+// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#ifndef OPENCV_IMGPROC_FILTER_HPP
+#define OPENCV_IMGPROC_FILTER_HPP
+
+namespace cv
+{
+#if CV_TRY_AVX2
+ int RowVec_32f_AVX(const float* src0, const float* _kx, float* dst, int width, int cn, int _ksize);
+ int SymmColumnVec_32f_Symm_AVX(const float** src, const float* ky, float* dst, float delta, int width, int ksize2);
+ int SymmColumnVec_32f_Unsymm_AVX(const float** src, const float* ky, float* dst, float delta, int width, int ksize2);
+#endif
+}
+
+#endif
+
+/* End of file. */
diff --git a/modules/imgproc/src/grabcut.cpp b/modules/imgproc/src/grabcut.cpp
index ca9b05c..615b52e 100644
--- a/modules/imgproc/src/grabcut.cpp
+++ b/modules/imgproc/src/grabcut.cpp
@@ -47,7 +47,7 @@ using namespace cv;
/*
This is implementation of image segmentation algorithm GrabCut described in
-"GrabCut — Interactive Foreground Extraction using Iterated Graph Cuts".
+"GrabCut - Interactive Foreground Extraction using Iterated Graph Cuts".
Carsten Rother, Vladimir Kolmogorov, Andrew Blake.
*/
@@ -104,6 +104,7 @@ GMM::GMM( Mat& _model )
for( int ci = 0; ci < componentsCount; ci++ )
if( coefs[ci] > 0 )
calcInverseCovAndDeterm( ci );
+ totalSampleCount = 0;
}
double GMM::operator()( const Vec3d color ) const
diff --git a/modules/imgproc/src/histogram.cpp b/modules/imgproc/src/histogram.cpp
index 235f347..33f15c5 100644
--- a/modules/imgproc/src/histogram.cpp
+++ b/modules/imgproc/src/histogram.cpp
@@ -83,7 +83,7 @@ calcHistLookupTables_8u( const Mat& hist, const SparseMat& shist,
}
}
}
- else
+ else if (ranges)
{
for( i = 0; i < dims; i++ )
{
@@ -111,6 +111,10 @@ calcHistLookupTables_8u( const Mat& hist, const SparseMat& shist,
}
}
}
+ else
+ {
+ CV_Error(Error::StsBadArg, "Either ranges, either uniform ranges should be provided");
+ }
}
@@ -938,7 +942,7 @@ calcHist_( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas,
}
}
}
- else
+ else if (_ranges)
{
// non-uniform histogram
const float* ranges[CV_MAX_DIM];
@@ -980,6 +984,10 @@ calcHist_( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas,
ptrs[i] += deltas[i*2 + 1];
}
}
+ else
+ {
+ CV_Error(Error::StsBadArg, "Either ranges, either uniform ranges should be provided");
+ }
}
@@ -1178,86 +1186,149 @@ calcHist_8u( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas,
}
#ifdef HAVE_IPP
-class IPPCalcHistInvoker :
- public ParallelLoopBody
+
+typedef IppStatus(CV_STDCALL * IppiHistogram_C1)(const void* pSrc, int srcStep,
+ IppiSize roiSize, Ipp32u* pHist, const IppiHistogramSpec* pSpec, Ipp8u* pBuffer);
+
+static IppiHistogram_C1 getIppiHistogramFunction_C1(int type)
+{
+ IppiHistogram_C1 ippFunction =
+ (type == CV_8UC1) ? (IppiHistogram_C1)ippiHistogram_8u_C1R :
+#if IPP_VERSION_X100 >= 201700 || !(defined HAVE_IPP_ICV_ONLY)
+ (type == CV_16UC1) ? (IppiHistogram_C1)ippiHistogram_16u_C1R :
+ (type == CV_32FC1) ? (IppiHistogram_C1)ippiHistogram_32f_C1R :
+#endif
+ NULL;
+
+ return ippFunction;
+}
+
+class ipp_calcHistParallelTLS
{
public:
- IPPCalcHistInvoker(const Mat & _src, Mat & _hist, AutoBuffer<Ipp32f> & _levels, Ipp32s _histSize, Ipp32f _low, Ipp32f _high, bool * _ok) :
- ParallelLoopBody(), src(&_src), hist(&_hist), levels(&_levels), histSize(_histSize), low(_low), high(_high), ok(_ok)
- {
- *ok = true;
- }
+ ipp_calcHistParallelTLS() {}
- virtual void operator() (const Range & range) const
- {
- Ipp32s levelNum = histSize + 1;
- Mat phist(hist->size(), hist->type(), Scalar::all(0));
-#if IPP_VERSION_X100 >= 900
- IppiSize roi = {src->cols, range.end - range.start};
- int bufferSize = 0;
- int specSize = 0;
- IppiHistogramSpec *pSpec = NULL;
- Ipp8u *pBuffer = NULL;
+ IppAutoBuffer<IppiHistogramSpec> spec;
+ IppAutoBuffer<Ipp8u> buffer;
+ IppAutoBuffer<Ipp32u> thist;
+};
- if(ippiHistogramGetBufferSize(ipp8u, roi, &levelNum, 1, 1, &specSize, &bufferSize) < 0)
+class ipp_calcHistParallel: public ParallelLoopBody
+{
+public:
+ ipp_calcHistParallel(const Mat &src, Mat &hist, Ipp32s histSize, const float *ranges, bool uniform, bool &ok):
+ ParallelLoopBody(), m_src(src), m_hist(hist), m_ok(ok)
+ {
+ ok = true;
+
+ m_uniform = uniform;
+ m_ranges = ranges;
+ m_histSize = histSize;
+ m_type = ippiGetDataType(src.type());
+ m_levelsNum = histSize+1;
+ ippiHistogram_C1 = getIppiHistogramFunction_C1(src.type());
+ m_fullRoi = ippiSize(src.size());
+ m_bufferSize = 0;
+ m_specSize = 0;
+ if(!ippiHistogram_C1)
{
- *ok = false;
+ ok = false;
return;
}
- pBuffer = (Ipp8u*)ippMalloc(bufferSize);
- if(!pBuffer && bufferSize)
+ if(ippiHistogramGetBufferSize(m_type, m_fullRoi, &m_levelsNum, 1, 1, &m_specSize, &m_bufferSize) < 0)
{
- *ok = false;
+ ok = false;
return;
}
- pSpec = (IppiHistogramSpec*)ippMalloc(specSize);
- if(!pSpec && specSize)
- {
- if(pBuffer) ippFree(pBuffer);
- *ok = false;
+ hist.setTo(0);
+ }
+
+ virtual void operator() (const Range & range) const
+ {
+ CV_INSTRUMENT_REGION_IPP()
+
+ if(!m_ok)
return;
- }
- if(ippiHistogramUniformInit(ipp8u, (Ipp32f*)&low, (Ipp32f*)&high, (Ipp32s*)&levelNum, 1, pSpec) < 0)
+ ipp_calcHistParallelTLS *pTls = m_tls.get();
+
+ IppiSize roi = {m_src.cols, range.end - range.start };
+ bool mtLoop = false;
+ if(m_fullRoi.height != roi.height)
+ mtLoop = true;
+
+ if(!pTls->spec)
{
- if(pSpec) ippFree(pSpec);
- if(pBuffer) ippFree(pBuffer);
- *ok = false;
- return;
- }
+ pTls->spec.allocate(m_specSize);
+ if(!pTls->spec.get())
+ {
+ m_ok = false;
+ return;
+ }
- IppStatus status = CV_INSTRUMENT_FUN_IPP(ippiHistogram_8u_C1R, src->ptr(range.start), (int)src->step, ippiSize(src->cols, range.end - range.start),
- phist.ptr<Ipp32u>(), pSpec, pBuffer);
+ pTls->buffer.allocate(m_bufferSize);
+ if(!pTls->buffer.get() && m_bufferSize)
+ {
+ m_ok = false;
+ return;
+ }
- if(pSpec) ippFree(pSpec);
- if(pBuffer) ippFree(pBuffer);
-#else
- CV_SUPPRESS_DEPRECATED_START
- IppStatus status = ippiHistogramEven_8u_C1R(src->ptr(range.start), (int)src->step, ippiSize(src->cols, range.end - range.start),
- phist.ptr<Ipp32s>(), (Ipp32s*)(Ipp32f*)*levels, levelNum, (Ipp32s)low, (Ipp32s)high);
- CV_SUPPRESS_DEPRECATED_END
-#endif
- if(status < 0)
+ if(m_uniform)
+ {
+ if(ippiHistogramUniformInit(m_type, (Ipp32f*)&m_ranges[0], (Ipp32f*)&m_ranges[1], (Ipp32s*)&m_levelsNum, 1, pTls->spec) < 0)
+ {
+ m_ok = false;
+ return;
+ }
+ }
+ else
+ {
+ if(ippiHistogramInit(m_type, (const Ipp32f**)&m_ranges, (Ipp32s*)&m_levelsNum, 1, pTls->spec) < 0)
+ {
+ m_ok = false;
+ return;
+ }
+ }
+
+ pTls->thist.allocate(m_histSize*sizeof(Ipp32u));
+ }
+
+ if(CV_INSTRUMENT_FUN_IPP(ippiHistogram_C1, m_src.ptr(range.start), (int)m_src.step, roi, pTls->thist, pTls->spec, pTls->buffer) < 0)
{
- *ok = false;
+ m_ok = false;
return;
}
- for (int i = 0; i < histSize; ++i)
- CV_XADD((int *)(hist->data + i * hist->step), *(int *)(phist.data + i * phist.step));
+ if(mtLoop)
+ {
+ for(int i = 0; i < m_histSize; i++)
+ CV_XADD((int*)(m_hist.ptr(i)), *(int*)((Ipp32u*)pTls->thist + i));
+ }
+ else
+ ippiCopy_32s_C1R((Ipp32s*)pTls->thist.get(), sizeof(Ipp32u), (Ipp32s*)m_hist.ptr(), (int)m_hist.step, ippiSize(1, m_histSize));
}
private:
- const Mat * src;
- Mat * hist;
- AutoBuffer<Ipp32f> * levels;
- Ipp32s histSize;
- Ipp32f low, high;
- bool * ok;
-
- const IPPCalcHistInvoker & operator = (const IPPCalcHistInvoker & );
+ const Mat &m_src;
+ Mat &m_hist;
+ Ipp32s m_histSize;
+ const float *m_ranges;
+ bool m_uniform;
+
+ IppiHistogram_C1 ippiHistogram_C1;
+ IppiSize m_fullRoi;
+ IppDataType m_type;
+ Ipp32s m_levelsNum;
+ int m_bufferSize;
+ int m_specSize;
+
+ mutable Mutex m_syncMutex;
+ TLSData<ipp_calcHistParallelTLS> m_tls;
+
+ volatile bool &m_ok;
+ const ipp_calcHistParallel & operator = (const ipp_calcHistParallel & );
};
#endif
@@ -1267,6 +1338,9 @@ private:
#ifdef HAVE_OPENVX
namespace cv
{
+ namespace ovx {
+ template <> inline bool skipSmallImages<VX_KERNEL_HISTOGRAM>(int w, int h) { return w*h < 2048 * 1536; }
+ }
static bool openvx_calchist(const Mat& image, OutputArray _hist, const int histSize,
const float* _range)
{
@@ -1282,7 +1356,7 @@ namespace cv
try
{
- ivx::Context ctx = ivx::Context::create();
+ ivx::Context ctx = ovx::getOpenVXContext();
#if VX_VERSION <= VX_VERSION_1_0
if (ctx.vendorID() == VX_ID_KHRONOS && (range % histSize))
return false;
@@ -1319,49 +1393,49 @@ namespace cv
}
#endif
-#if defined(HAVE_IPP)
+#ifdef HAVE_IPP
+#define IPP_HISTOGRAM_PARALLEL 1
namespace cv
{
-static bool ipp_calchist(const Mat* images, int nimages, const int* channels,
- InputArray _mask, OutputArray _hist, int dims, const int* histSize,
- const float** ranges, bool uniform, bool accumulate )
+static bool ipp_calchist(const Mat &image, Mat &hist, int histSize, const float** ranges, bool uniform, bool accumulate)
{
CV_INSTRUMENT_REGION_IPP()
- Mat mask = _mask.getMat();
+ // No SSE42 optimization for uniform 32f
+#if IPP_DISABLE_PERF_HISTU32F_SSE42
+ if(uniform && image.depth() == CV_32F && !(ipp::getIppFeatures()&ippCPUID_AVX))
+ return false;
+#endif
- CV_Assert(dims > 0 && histSize);
+ Mat ihist = hist;
+ if(accumulate)
+ ihist.create(1, &histSize, CV_32S);
- _hist.create(dims, histSize, CV_32F);
- Mat hist = _hist.getMat(), ihist = hist;
- ihist.flags = (ihist.flags & ~CV_MAT_TYPE_MASK)|CV_32S;
+ bool ok = true;
+ int threads = ippiSuggestThreadsNum(image, (1+((double)ihist.total()/image.total()))*2);
+ Range range(0, image.rows);
+ ipp_calcHistParallel invoker(image, ihist, histSize, ranges[0], uniform, ok);
+ if(!ok)
+ return false;
+
+ if(IPP_HISTOGRAM_PARALLEL && threads > 1)
+ parallel_for_(range, invoker, threads*2);
+ else
+ invoker(range);
+ if(ok)
{
- if (nimages == 1 && images[0].type() == CV_8UC1 && dims == 1 && channels &&
- channels[0] == 0 && mask.empty() && images[0].dims <= 2 &&
- !accumulate && uniform)
+ if(accumulate)
{
- ihist.setTo(Scalar::all(0));
- AutoBuffer<Ipp32f> levels(histSize[0]);
-
- bool ok = true;
- const Mat & src = images[0];
- int nstripes = std::min<int>(8, static_cast<int>(src.total() / (1 << 16)));
-#ifdef HAVE_CONCURRENCY
- nstripes = 1;
-#endif
- IPPCalcHistInvoker invoker(src, ihist, levels, histSize[0], ranges[0][0], ranges[0][1], &ok);
- Range range(0, src.rows);
- parallel_for_(range, invoker, nstripes);
-
- if (ok)
- {
- ihist.convertTo(hist, CV_32F);
- return true;
- }
+ IppiSize histRoi = ippiSize(1, histSize);
+ IppAutoBuffer<Ipp32f> fhist(histSize*sizeof(Ipp32f));
+ CV_INSTRUMENT_FUN_IPP(ippiConvert_32s32f_C1R, (Ipp32s*)ihist.ptr(), (int)ihist.step, (Ipp32f*)fhist, sizeof(Ipp32f), histRoi);
+ CV_INSTRUMENT_FUN_IPP(ippiAdd_32f_C1IR, (Ipp32f*)fhist, sizeof(Ipp32f), (Ipp32f*)hist.ptr(), (int)hist.step, histRoi);
}
+ else
+ CV_INSTRUMENT_FUN_IPP(ippiConvert_32s32f_C1R, (Ipp32s*)ihist.ptr(), (int)ihist.step, (Ipp32f*)hist.ptr(), (int)hist.step, ippiSize(1, histSize));
}
- return false;
+ return ok;
}
}
#endif
@@ -1376,26 +1450,30 @@ void cv::calcHist( const Mat* images, int nimages, const int* channels,
images && histSize &&
nimages == 1 && images[0].type() == CV_8UC1 && dims == 1 && _mask.getMat().empty() &&
(!channels || channels[0] == 0) && !accumulate && uniform &&
- ranges && ranges[0],
+ ranges && ranges[0] &&
+ !ovx::skipSmallImages<VX_KERNEL_HISTOGRAM>(images[0].cols, images[0].rows),
openvx_calchist(images[0], _hist, histSize[0], ranges[0]))
- CV_IPP_RUN(nimages == 1 && images[0].type() == CV_8UC1 && dims == 1 && channels &&
- channels[0] == 0 && _mask.getMat().empty() && images[0].dims <= 2 &&
- !accumulate && uniform,
- ipp_calchist(images, nimages, channels,
- _mask, _hist, dims, histSize,
- ranges, uniform, accumulate));
-
Mat mask = _mask.getMat();
CV_Assert(dims > 0 && histSize);
const uchar* const histdata = _hist.getMat().ptr();
_hist.create(dims, histSize, CV_32F);
- Mat hist = _hist.getMat(), ihist = hist;
+ Mat hist = _hist.getMat();
+
+ if(histdata != hist.data)
+ accumulate = false;
+
+ CV_IPP_RUN(
+ nimages == 1 && dims == 1 && channels && channels[0] == 0
+ && _mask.empty() && images[0].dims <= 2 && ranges && ranges[0],
+ ipp_calchist(images[0], hist, histSize[0], ranges, uniform, accumulate));
+
+ Mat ihist = hist;
ihist.flags = (ihist.flags & ~CV_MAT_TYPE_MASK)|CV_32S;
- if( !accumulate || histdata != hist.data )
+ if(!accumulate)
hist = Scalar(0.);
else
hist.convertTo(ihist, CV_32S);
@@ -1469,7 +1547,7 @@ calcSparseHist_( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas,
ptrs[i] += deltas[i*2 + 1];
}
}
- else
+ else if (_ranges)
{
// non-uniform histogram
const float* ranges[CV_MAX_DIM];
@@ -1509,6 +1587,10 @@ calcSparseHist_( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas,
ptrs[i] += deltas[i*2 + 1];
}
}
+ else
+ {
+ CV_Error(Error::StsBadArg, "Either ranges, either uniform ranges should be provided");
+ }
}
@@ -1568,6 +1650,7 @@ static void calcHist( const Mat* images, int nimages, const int* channels,
SparseMatIterator it = hist.begin();
for( i = 0, N = hist.nzcount(); i < N; i++, ++it )
{
+ CV_Assert(it.ptr != NULL);
Cv32suf* val = (Cv32suf*)it.ptr;
val->i = cvRound(val->f);
}
@@ -1598,6 +1681,7 @@ static void calcHist( const Mat* images, int nimages, const int* channels,
SparseMatIterator it = hist.begin();
for( i = 0, N = hist.nzcount(); i < N; i++, ++it )
{
+ CV_Assert(it.ptr != NULL);
Cv32suf* val = (Cv32suf*)it.ptr;
val->f = (float)val->i;
}
@@ -1639,6 +1723,7 @@ static bool ocl_calcHist1(InputArray _src, OutputArray _hist, int ddepth = CV_32
if (!k1.run(1, &globalsize, &wgs, false))
return false;
+ wgs = std::min<size_t>(ocl::Device::getDefault().maxWorkGroupSize(), BINS);
char cvt[40];
ocl::Kernel k2("merge_histogram", ocl::imgproc::histogram_oclsrc,
format("-D BINS=%d -D HISTS_COUNT=%d -D WGS=%d -D convertToHT=%s -D HT=%s",
@@ -1839,7 +1924,7 @@ calcBackProj_( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas,
}
}
}
- else
+ else if (_ranges)
{
// non-uniform histogram
const float* ranges[CV_MAX_DIM];
@@ -1881,6 +1966,10 @@ calcBackProj_( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas,
ptrs[i] += deltas[i*2 + 1];
}
}
+ else
+ {
+ CV_Error(Error::StsBadArg, "Either ranges, either uniform ranges should be provided");
+ }
}
@@ -2085,7 +2174,7 @@ calcSparseBackProj_( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas
ptrs[i] += deltas[i*2 + 1];
}
}
- else
+ else if (_ranges)
{
// non-uniform histogram
const float* ranges[CV_MAX_DIM];
@@ -2125,6 +2214,10 @@ calcSparseBackProj_( std::vector<uchar*>& _ptrs, const std::vector<int>& _deltas
ptrs[i] += deltas[i*2 + 1];
}
}
+ else
+ {
+ CV_Error(Error::StsBadArg, "Either ranges, either uniform ranges should be provided");
+ }
}
@@ -2192,7 +2285,6 @@ void cv::calcBackProject( const Mat* images, int nimages, const int* channels,
dims, hist.hdr->size, ranges,
uniform, ptrs, deltas, imsize, uniranges );
const double* _uniranges = uniform ? &uniranges[0] : 0;
-
int depth = images[0].depth();
if( depth == CV_8U )
calcSparseBackProj_8u(ptrs, deltas, imsize, hist, dims, ranges,
@@ -2634,12 +2726,14 @@ double cv::compareHist( const SparseMat& H1, const SparseMat& H2, int method )
std::swap(PH1, PH2);
SparseMatConstIterator it = PH1->begin();
+
int N1 = (int)PH1->nzcount(), N2 = (int)PH2->nzcount();
if( (method == CV_COMP_CHISQR) || (method == CV_COMP_CHISQR_ALT) )
{
for( i = 0; i < N1; i++, ++it )
{
+ CV_Assert(it.ptr != NULL);
float v1 = it.value<float>();
const SparseMat::Node* node = it.node();
float v2 = PH2->value<float>(node->idx, (size_t*)&node->hashval);
@@ -2655,6 +2749,7 @@ double cv::compareHist( const SparseMat& H1, const SparseMat& H2, int method )
for( i = 0; i < N1; i++, ++it )
{
+ CV_Assert(it.ptr != NULL);
double v1 = it.value<float>();
const SparseMat::Node* node = it.node();
s12 += v1*PH2->value<float>(node->idx, (size_t*)&node->hashval);
@@ -2665,6 +2760,7 @@ double cv::compareHist( const SparseMat& H1, const SparseMat& H2, int method )
it = PH2->begin();
for( i = 0; i < N2; i++, ++it )
{
+ CV_Assert(it.ptr != NULL);
double v2 = it.value<float>();
s2 += v2;
s22 += v2*v2;
@@ -2682,6 +2778,7 @@ double cv::compareHist( const SparseMat& H1, const SparseMat& H2, int method )
{
for( i = 0; i < N1; i++, ++it )
{
+ CV_Assert(it.ptr != NULL);
float v1 = it.value<float>();
const SparseMat::Node* node = it.node();
float v2 = PH2->value<float>(node->idx, (size_t*)&node->hashval);
@@ -2695,6 +2792,7 @@ double cv::compareHist( const SparseMat& H1, const SparseMat& H2, int method )
for( i = 0; i < N1; i++, ++it )
{
+ CV_Assert(it.ptr != NULL);
double v1 = it.value<float>();
const SparseMat::Node* node = it.node();
double v2 = PH2->value<float>(node->idx, (size_t*)&node->hashval);
@@ -2704,7 +2802,10 @@ double cv::compareHist( const SparseMat& H1, const SparseMat& H2, int method )
it = PH2->begin();
for( i = 0; i < N2; i++, ++it )
+ {
+ CV_Assert(it.ptr != NULL);
s2 += it.value<float>();
+ }
s1 *= s2;
s1 = fabs(s1) > FLT_EPSILON ? 1./std::sqrt(s1) : 1.;
@@ -2714,6 +2815,7 @@ double cv::compareHist( const SparseMat& H1, const SparseMat& H2, int method )
{
for( i = 0; i < N1; i++, ++it )
{
+ CV_Assert(it.ptr != NULL);
double v1 = it.value<float>();
const SparseMat::Node* node = it.node();
double v2 = PH2->value<float>(node->idx, (size_t*)&node->hashval);
@@ -3376,7 +3478,10 @@ cvCalcArrHist( CvArr** img, CvHistogram* hist, int accumulate, const CvArr* mask
cv::SparseMatConstIterator it = sH.begin();
int nz = (int)sH.nzcount();
for( i = 0; i < nz; i++, ++it )
+ {
+ CV_Assert(it.ptr != NULL);
*(float*)cvPtrND(sparsemat, it.node()->idx, 0, -2) = (float)*(const int*)it.ptr;
+ }
}
}
@@ -3461,6 +3566,8 @@ cvCalcArrBackProjectPatch( CvArr** arr, CvArr* dst, CvSize patch_size, CvHistogr
CV_Error( CV_StsBadSize, "The patch width and height must be positive" );
dims = cvGetDims( hist->bins );
+ if (dims < 1)
+ CV_Error( CV_StsOutOfRange, "Invalid number of dimensions");
cvNormalizeHist( hist, norm_factor );
for( i = 0; i < dims; i++ )
@@ -3773,7 +3880,7 @@ static bool openvx_equalize_hist(Mat srcMat, Mat dstMat)
try
{
- Context context = Context::create();
+ Context context = ovx::getOpenVXContext();
Image srcImage = Image::createFromHandle(context, Image::matTypeToFormat(srcMat.type()),
Image::createAddressing(srcMat), srcMat.data);
Image dstImage = Image::createFromHandle(context, Image::matTypeToFormat(dstMat.type()),
@@ -3817,7 +3924,7 @@ void cv::equalizeHist( InputArray _src, OutputArray _dst )
_dst.create( src.size(), src.type() );
Mat dst = _dst.getMat();
- CV_OVX_RUN(true,
+ CV_OVX_RUN(!ovx::skipSmallImages<VX_KERNEL_EQUALIZE_HISTOGRAM>(src.cols, src.rows),
openvx_equalize_hist(src, dst))
Mutex histogramLockInstance;
diff --git a/modules/imgproc/src/hough.cpp b/modules/imgproc/src/hough.cpp
index 13c11db..665e9a3 100644
--- a/modules/imgproc/src/hough.cpp
+++ b/modules/imgproc/src/hough.cpp
@@ -96,7 +96,7 @@ HoughLinesStandard( const Mat& img, float rho, float theta,
int numangle = cvRound((max_theta - min_theta) / theta);
int numrho = cvRound(((width + height) * 2 + 1) / rho);
-#if defined HAVE_IPP && IPP_VERSION_X100 >= 810 && IPP_DISABLE_BLOCK
+#if defined HAVE_IPP && IPP_VERSION_X100 >= 810 && !IPP_DISABLE_HOUGH
CV_IPP_CHECK()
{
IppiSize srcSize = { width, height };
@@ -108,8 +108,8 @@ HoughLinesStandard( const Mat& img, float rho, float theta,
int linesCount = 0;
lines.resize(ipp_linesMax);
IppStatus ok = ippiHoughLineGetSize_8u_C1R(srcSize, delta, ipp_linesMax, &bufferSize);
- Ipp8u* buffer = ippsMalloc_8u(bufferSize);
- if (ok >= 0) {ok = CV_INSTRUMENT_FUN_IPP(ippiHoughLine_Region_8u32f_C1R,(image, step, srcSize, (IppPointPolar*) &lines[0], dstRoi, ipp_linesMax, &linesCount, delta, threshold, buffer))};
+ Ipp8u* buffer = ippsMalloc_8u_L(bufferSize);
+ if (ok >= 0) {ok = CV_INSTRUMENT_FUN_IPP(ippiHoughLine_Region_8u32f_C1R, image, step, srcSize, (IppPointPolar*) &lines[0], dstRoi, ipp_linesMax, &linesCount, delta, threshold, buffer);};
ippsFree(buffer);
if (ok >= 0)
{
@@ -429,7 +429,7 @@ HoughLinesProbabilistic( Mat& image,
int numangle = cvRound(CV_PI / theta);
int numrho = cvRound(((width + height) * 2 + 1) / rho);
-#if defined HAVE_IPP && IPP_VERSION_X100 >= 810 && IPP_DISABLE_BLOCK
+#if defined HAVE_IPP && IPP_VERSION_X100 >= 810 && !IPP_DISABLE_HOUGH
CV_IPP_CHECK()
{
IppiSize srcSize = { width, height };
@@ -440,12 +440,12 @@ HoughLinesProbabilistic( Mat& image,
int linesCount = 0;
lines.resize(ipp_linesMax);
IppStatus ok = ippiHoughProbLineGetSize_8u_C1R(srcSize, delta, &specSize, &bufferSize);
- Ipp8u* buffer = ippsMalloc_8u(bufferSize);
- pSpec = (IppiHoughProbSpec*) malloc(specSize);
+ Ipp8u* buffer = ippsMalloc_8u_L(bufferSize);
+ pSpec = (IppiHoughProbSpec*) ippsMalloc_8u_L(specSize);
if (ok >= 0) ok = ippiHoughProbLineInit_8u32f_C1R(srcSize, delta, ippAlgHintNone, pSpec);
- if (ok >= 0) {ok = CV_INSTRUMENT_FUN_IPP(ippiHoughProbLine_8u32f_C1R,(image.data, image.step, srcSize, threshold, lineLength, lineGap, (IppiPoint*) &lines[0], ipp_linesMax, &linesCount, buffer, pSpec))};
+ if (ok >= 0) {ok = CV_INSTRUMENT_FUN_IPP(ippiHoughProbLine_8u32f_C1R, image.data, (int)image.step, srcSize, threshold, lineLength, lineGap, (IppiPoint*) &lines[0], ipp_linesMax, &linesCount, buffer, pSpec);};
- free(pSpec);
+ ippsFree(pSpec);
ippsFree(buffer);
if (ok >= 0)
{
@@ -894,7 +894,6 @@ cvHoughLines2( CvArr* src_image, void* lineStorage, int method,
cv::Mat image = cv::cvarrToMat(src_image);
std::vector<cv::Vec2f> l2;
std::vector<cv::Vec4i> l4;
- CvSeq* result = 0;
CvMat* mat = 0;
CvSeq* lines = 0;
@@ -921,11 +920,13 @@ cvHoughLines2( CvArr* src_image, void* lineStorage, int method,
elemSize = sizeof(int)*4;
}
- if( CV_IS_STORAGE( lineStorage ))
+ bool isStorage = isStorageOrMat(lineStorage);
+
+ if( isStorage )
{
lines = cvCreateSeq( lineType, sizeof(CvSeq), elemSize, (CvMemStorage*)lineStorage );
}
- else if( CV_IS_MAT( lineStorage ))
+ else
{
mat = (CvMat*)lineStorage;
@@ -942,8 +943,6 @@ cvHoughLines2( CvArr* src_image, void* lineStorage, int method,
linesMax = lines->total;
cvClearSeq( lines );
}
- else
- CV_Error( CV_StsBadArg, "Destination is not CvMemStorage* nor CvMat*" );
iparam1 = cvRound(param1);
iparam2 = cvRound(param2);
@@ -968,7 +967,7 @@ cvHoughLines2( CvArr* src_image, void* lineStorage, int method,
int nlines = (int)(l2.size() + l4.size());
- if( mat )
+ if( !isStorage )
{
if( mat->cols > mat->rows )
mat->cols = nlines;
@@ -981,20 +980,20 @@ cvHoughLines2( CvArr* src_image, void* lineStorage, int method,
cv::Mat lx = method == CV_HOUGH_STANDARD || method == CV_HOUGH_MULTI_SCALE ?
cv::Mat(nlines, 1, CV_32FC2, &l2[0]) : cv::Mat(nlines, 1, CV_32SC4, &l4[0]);
- if( mat )
+ if (isStorage)
{
- cv::Mat dst(nlines, 1, lx.type(), mat->data.ptr);
- lx.copyTo(dst);
+ cvSeqPushMulti(lines, lx.ptr(), nlines);
}
else
{
- cvSeqPushMulti(lines, lx.ptr(), nlines);
+ cv::Mat dst(nlines, 1, lx.type(), mat->data.ptr);
+ lx.copyTo(dst);
}
}
- if( !mat )
- result = lines;
- return result;
+ if( isStorage )
+ return lines;
+ return 0;
}
@@ -1227,8 +1226,6 @@ cvHoughCircles( CvArr* src_image, void* circle_storage,
double param1, double param2,
int min_radius, int max_radius )
{
- CvSeq* result = 0;
-
CvMat stub, *img = (CvMat*)src_image;
CvMat* mat = 0;
CvSeq* circles = 0;
@@ -1255,12 +1252,14 @@ cvHoughCircles( CvArr* src_image, void* circle_storage,
else if( max_radius <= min_radius )
max_radius = min_radius + 2;
- if( CV_IS_STORAGE( circle_storage ))
+ bool isStorage = isStorageOrMat(circle_storage);
+
+ if(isStorage)
{
circles = cvCreateSeq( CV_32FC3, sizeof(CvSeq),
sizeof(float)*3, (CvMemStorage*)circle_storage );
}
- else if( CV_IS_MAT( circle_storage ))
+ else
{
mat = (CvMat*)circle_storage;
@@ -1274,8 +1273,6 @@ cvHoughCircles( CvArr* src_image, void* circle_storage,
circles_max = circles->total;
cvClearSeq( circles );
}
- else
- CV_Error( CV_StsBadArg, "Destination is not CvMemStorage* nor CvMat*" );
switch( method )
{
@@ -1288,17 +1285,17 @@ cvHoughCircles( CvArr* src_image, void* circle_storage,
CV_Error( CV_StsBadArg, "Unrecognized method id" );
}
- if( mat )
+ if (isStorage)
+ return circles;
+ else
{
if( mat->cols > mat->rows )
mat->cols = circles->total;
else
mat->rows = circles->total;
}
- else
- result = circles;
- return result;
+ return 0;
}
diff --git a/modules/imgproc/src/imgwarp.avx2.cpp b/modules/imgproc/src/imgwarp.avx2.cpp
new file mode 100644
index 0000000..63ef2ae
--- /dev/null
+++ b/modules/imgproc/src/imgwarp.avx2.cpp
@@ -0,0 +1,299 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
+// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
+// Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+/* ////////////////////////////////////////////////////////////////////
+//
+// Geometrical transforms on images and matrices: rotation, zoom etc.
+//
+// */
+
+#include "precomp.hpp"
+#include "imgwarp.hpp"
+
+namespace cv
+{
+namespace opt_AVX2
+{
+
+class resizeNNInvokerAVX4 :
+ public ParallelLoopBody
+{
+public:
+ resizeNNInvokerAVX4(const Mat& _src, Mat &_dst, int *_x_ofs, int _pix_size4, double _ify) :
+ ParallelLoopBody(), src(_src), dst(_dst), x_ofs(_x_ofs), pix_size4(_pix_size4),
+ ify(_ify)
+ {
+ }
+
+#if defined(__INTEL_COMPILER)
+#pragma optimization_parameter target_arch=AVX
+#endif
+ virtual void operator() (const Range& range) const
+ {
+ Size ssize = src.size(), dsize = dst.size();
+ int y, x;
+ int width = dsize.width;
+ int avxWidth = width - (width & 0x7);
+ const __m256i CV_DECL_ALIGNED(64) mask = _mm256_set1_epi32(-1);
+ if(((int64)(dst.data + dst.step) & 0x1f) == 0)
+ {
+ for(y = range.start; y < range.end; y++)
+ {
+ uchar* D = dst.data + dst.step*y;
+ uchar* Dstart = D;
+ int sy = std::min(cvFloor(y*ify), ssize.height-1);
+ const uchar* S = src.data + sy*src.step;
+#ifdef CV_ICC
+#pragma unroll(4)
+#endif
+ for(x = 0; x < avxWidth; x += 8)
+ {
+ const __m256i CV_DECL_ALIGNED(64) *addr = (__m256i*)(x_ofs + x);
+ __m256i CV_DECL_ALIGNED(64) indices = _mm256_lddqu_si256(addr);
+ __m256i CV_DECL_ALIGNED(64) pixels = _mm256_i32gather_epi32((const int*)S, indices, 1);
+ _mm256_maskstore_epi32((int*)D, mask, pixels);
+ D += 32;
+ }
+ for(; x < width; x++)
+ {
+ *(int*)(Dstart + x*4) = *(int*)(S + x_ofs[x]);
+ }
+ }
+ }
+ else
+ {
+ for(y = range.start; y < range.end; y++)
+ {
+ uchar* D = dst.data + dst.step*y;
+ uchar* Dstart = D;
+ int sy = std::min(cvFloor(y*ify), ssize.height-1);
+ const uchar* S = src.data + sy*src.step;
+#ifdef CV_ICC
+#pragma unroll(4)
+#endif
+ for(x = 0; x < avxWidth; x += 8)
+ {
+ const __m256i CV_DECL_ALIGNED(64) *addr = (__m256i*)(x_ofs + x);
+ __m256i CV_DECL_ALIGNED(64) indices = _mm256_lddqu_si256(addr);
+ __m256i CV_DECL_ALIGNED(64) pixels = _mm256_i32gather_epi32((const int*)S, indices, 1);
+ _mm256_storeu_si256((__m256i*)D, pixels);
+ D += 32;
+ }
+ for(; x < width; x++)
+ {
+ *(int*)(Dstart + x*4) = *(int*)(S + x_ofs[x]);
+ }
+ }
+ }
+ _mm256_zeroupper();
+ }
+
+private:
+ const Mat src;
+ Mat dst;
+ int* x_ofs, pix_size4;
+ double ify;
+
+ resizeNNInvokerAVX4(const resizeNNInvokerAVX4&);
+ resizeNNInvokerAVX4& operator=(const resizeNNInvokerAVX4&);
+};
+
+class resizeNNInvokerAVX2 :
+ public ParallelLoopBody
+{
+public:
+ resizeNNInvokerAVX2(const Mat& _src, Mat &_dst, int *_x_ofs, int _pix_size4, double _ify) :
+ ParallelLoopBody(), src(_src), dst(_dst), x_ofs(_x_ofs), pix_size4(_pix_size4),
+ ify(_ify)
+ {
+ }
+
+#if defined(__INTEL_COMPILER)
+#pragma optimization_parameter target_arch=AVX
+#endif
+ virtual void operator() (const Range& range) const
+ {
+ Size ssize = src.size(), dsize = dst.size();
+ int y, x;
+ int width = dsize.width;
+ //int avxWidth = (width - 1) - ((width - 1) & 0x7);
+ int avxWidth = width - (width & 0xf);
+ const __m256i CV_DECL_ALIGNED(64) mask = _mm256_set1_epi32(-1);
+ const __m256i CV_DECL_ALIGNED(64) shuffle_mask = _mm256_set_epi8(15,14,11,10,13,12,9,8,7,6,3,2,5,4,1,0,
+ 15,14,11,10,13,12,9,8,7,6,3,2,5,4,1,0);
+ const __m256i CV_DECL_ALIGNED(64) permute_mask = _mm256_set_epi32(7, 5, 3, 1, 6, 4, 2, 0);
+ //const __m256i CV_DECL_ALIGNED(64) shift_shuffle_mask = _mm256_set_epi8(13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2,
+ // 13,12,15,14,9,8,11,10,5,4,7,6,1,0,3,2);
+ if(((int64)(dst.data + dst.step) & 0x1f) == 0)
+ {
+ for(y = range.start; y < range.end; y++)
+ {
+ uchar* D = dst.data + dst.step*y;
+ uchar* Dstart = D;
+ int sy = std::min(cvFloor(y*ify), ssize.height-1);
+ const uchar* S = src.data + sy*src.step;
+ const uchar* S2 = S - 2;
+#ifdef CV_ICC
+#pragma unroll(4)
+#endif
+ for(x = 0; x < avxWidth; x += 16)
+ {
+ const __m256i CV_DECL_ALIGNED(64) *addr = (__m256i*)(x_ofs + x);
+ __m256i CV_DECL_ALIGNED(64) indices = _mm256_lddqu_si256(addr);
+ __m256i CV_DECL_ALIGNED(64) pixels1 = _mm256_i32gather_epi32((const int*)S, indices, 1);
+ const __m256i CV_DECL_ALIGNED(64) *addr2 = (__m256i*)(x_ofs + x + 8);
+ __m256i CV_DECL_ALIGNED(64) indices2 = _mm256_lddqu_si256(addr2);
+ __m256i CV_DECL_ALIGNED(64) pixels2 = _mm256_i32gather_epi32((const int*)S2, indices2, 1);
+ __m256i CV_DECL_ALIGNED(64) unpacked = _mm256_blend_epi16(pixels1, pixels2, 0xaa);
+
+ __m256i CV_DECL_ALIGNED(64) bytes_shuffled = _mm256_shuffle_epi8(unpacked, shuffle_mask);
+ __m256i CV_DECL_ALIGNED(64) ints_permuted = _mm256_permutevar8x32_epi32(bytes_shuffled, permute_mask);
+ _mm256_maskstore_epi32((int*)D, mask, ints_permuted);
+ D += 32;
+ }
+ for(; x < width; x++)
+ {
+ *(ushort*)(Dstart + x*2) = *(ushort*)(S + x_ofs[x]);
+ }
+
+ }
+ }
+ else
+ {
+ for(y = range.start; y < range.end; y++)
+ {
+ uchar* D = dst.data + dst.step*y;
+ uchar* Dstart = D;
+ int sy = std::min(cvFloor(y*ify), ssize.height-1);
+ const uchar* S = src.data + sy*src.step;
+ const uchar* S2 = S - 2;
+#ifdef CV_ICC
+#pragma unroll(4)
+#endif
+ for(x = 0; x < avxWidth; x += 16)
+ {
+ const __m256i CV_DECL_ALIGNED(64) *addr = (__m256i*)(x_ofs + x);
+ __m256i CV_DECL_ALIGNED(64) indices = _mm256_lddqu_si256(addr);
+ __m256i CV_DECL_ALIGNED(64) pixels1 = _mm256_i32gather_epi32((const int*)S, indices, 1);
+ const __m256i CV_DECL_ALIGNED(64) *addr2 = (__m256i*)(x_ofs + x + 8);
+ __m256i CV_DECL_ALIGNED(64) indices2 = _mm256_lddqu_si256(addr2);
+ __m256i CV_DECL_ALIGNED(64) pixels2 = _mm256_i32gather_epi32((const int*)S2, indices2, 1);
+ __m256i CV_DECL_ALIGNED(64) unpacked = _mm256_blend_epi16(pixels1, pixels2, 0xaa);
+
+ __m256i CV_DECL_ALIGNED(64) bytes_shuffled = _mm256_shuffle_epi8(unpacked, shuffle_mask);
+ __m256i CV_DECL_ALIGNED(64) ints_permuted = _mm256_permutevar8x32_epi32(bytes_shuffled, permute_mask);
+ _mm256_storeu_si256((__m256i*)D, ints_permuted);
+ D += 32;
+ }
+ for(; x < width; x++)
+ {
+ *(ushort*)(Dstart + x*2) = *(ushort*)(S + x_ofs[x]);
+ }
+ }
+ }
+ _mm256_zeroupper();
+ }
+
+private:
+ const Mat src;
+ Mat dst;
+ int* x_ofs, pix_size4;
+ double ify;
+
+ resizeNNInvokerAVX2(const resizeNNInvokerAVX2&);
+ resizeNNInvokerAVX2& operator=(const resizeNNInvokerAVX2&);
+};
+
+void resizeNN2_AVX2(const Range& range, const Mat& src, Mat &dst, int *x_ofs, int pix_size4, double ify)
+{
+ resizeNNInvokerAVX2 invoker(src, dst, x_ofs, pix_size4, ify);
+ parallel_for_(range, invoker, dst.total() / (double)(1 << 16));
+}
+
+void resizeNN4_AVX2(const Range& range, const Mat& src, Mat &dst, int *x_ofs, int pix_size4, double ify)
+{
+ resizeNNInvokerAVX4 invoker(src, dst, x_ofs, pix_size4, ify);
+ parallel_for_(range, invoker, dst.total() / (double)(1 << 16));
+}
+
+int warpAffineBlockline(int *adelta, int *bdelta, short* xy, short* alpha, int X0, int Y0, int bw)
+{
+ const int AB_BITS = MAX(10, (int)INTER_BITS);
+ int x1 = 0;
+ __m256i fxy_mask = _mm256_set1_epi32(INTER_TAB_SIZE - 1);
+ __m256i XX = _mm256_set1_epi32(X0), YY = _mm256_set1_epi32(Y0);
+ for (; x1 <= bw - 16; x1 += 16)
+ {
+ __m256i tx0, tx1, ty0, ty1;
+ tx0 = _mm256_add_epi32(_mm256_loadu_si256((const __m256i*)(adelta + x1)), XX);
+ ty0 = _mm256_add_epi32(_mm256_loadu_si256((const __m256i*)(bdelta + x1)), YY);
+ tx1 = _mm256_add_epi32(_mm256_loadu_si256((const __m256i*)(adelta + x1 + 8)), XX);
+ ty1 = _mm256_add_epi32(_mm256_loadu_si256((const __m256i*)(bdelta + x1 + 8)), YY);
+
+ tx0 = _mm256_srai_epi32(tx0, AB_BITS - INTER_BITS);
+ ty0 = _mm256_srai_epi32(ty0, AB_BITS - INTER_BITS);
+ tx1 = _mm256_srai_epi32(tx1, AB_BITS - INTER_BITS);
+ ty1 = _mm256_srai_epi32(ty1, AB_BITS - INTER_BITS);
+
+ __m256i fx_ = _mm256_packs_epi32(_mm256_and_si256(tx0, fxy_mask),
+ _mm256_and_si256(tx1, fxy_mask));
+ __m256i fy_ = _mm256_packs_epi32(_mm256_and_si256(ty0, fxy_mask),
+ _mm256_and_si256(ty1, fxy_mask));
+ tx0 = _mm256_packs_epi32(_mm256_srai_epi32(tx0, INTER_BITS),
+ _mm256_srai_epi32(tx1, INTER_BITS));
+ ty0 = _mm256_packs_epi32(_mm256_srai_epi32(ty0, INTER_BITS),
+ _mm256_srai_epi32(ty1, INTER_BITS));
+ fx_ = _mm256_adds_epi16(fx_, _mm256_slli_epi16(fy_, INTER_BITS));
+ fx_ = _mm256_permute4x64_epi64(fx_, (3 << 6) + (1 << 4) + (2 << 2) + 0);
+
+ _mm256_storeu_si256((__m256i*)(xy + x1 * 2), _mm256_unpacklo_epi16(tx0, ty0));
+ _mm256_storeu_si256((__m256i*)(xy + x1 * 2 + 16), _mm256_unpackhi_epi16(tx0, ty0));
+ _mm256_storeu_si256((__m256i*)(alpha + x1), fx_);
+ }
+ _mm256_zeroupper();
+ return x1;
+}
+
+}
+}
+/* End of file. */
diff --git a/modules/imgproc/src/imgwarp.cpp b/modules/imgproc/src/imgwarp.cpp
index 0fa5202..a960c01 100644
--- a/modules/imgproc/src/imgwarp.cpp
+++ b/modules/imgproc/src/imgwarp.cpp
@@ -52,78 +52,72 @@
#include "hal_replacement.hpp"
#include "opencv2/core/openvx/ovx_defs.hpp"
+#include "imgwarp.hpp"
using namespace cv;
namespace cv
{
-#if IPP_VERSION_X100 >= 710
- typedef IppStatus (CV_STDCALL* ippiResizeFunc)(const void*, int, const void*, int, IppiPoint, IppiSize, IppiBorderType, void*, void*, Ipp8u*);
- typedef IppStatus (CV_STDCALL* ippiResizeGetBufferSize)(void*, IppiSize, Ipp32u, int*);
- typedef IppStatus (CV_STDCALL* ippiResizeGetSrcOffset)(void*, IppiPoint, IppiPoint*);
-#endif
-#if defined (HAVE_IPP) && (IPP_VERSION_X100 >= 700) && IPP_DISABLE_BLOCK
- typedef IppStatus (CV_STDCALL* ippiSetFunc)(const void*, void *, int, IppiSize);
- typedef IppStatus (CV_STDCALL* ippiWarpPerspectiveFunc)(const void*, IppiSize, int, IppiRect, void *, int, IppiRect, double [3][3], int);
- typedef IppStatus (CV_STDCALL* ippiWarpAffineBackFunc)(const void*, IppiSize, int, IppiRect, void *, int, IppiRect, double [2][3], int);
+#if defined (HAVE_IPP) && (!IPP_DISABLE_WARPAFFINE || !IPP_DISABLE_WARPPERSPECTIVE || !IPP_DISABLE_REMAP)
+typedef IppStatus (CV_STDCALL* ippiSetFunc)(const void*, void *, int, IppiSize);
- template <int channels, typename Type>
- bool IPPSetSimple(cv::Scalar value, void *dataPointer, int step, IppiSize &size, ippiSetFunc func)
- {
- CV_INSTRUMENT_REGION_IPP()
+template <int channels, typename Type>
+bool IPPSetSimple(cv::Scalar value, void *dataPointer, int step, IppiSize &size, ippiSetFunc func)
+{
+ CV_INSTRUMENT_REGION_IPP()
- Type values[channels];
- for( int i = 0; i < channels; i++ )
- values[i] = saturate_cast<Type>(value[i]);
- return func(values, dataPointer, step, size) >= 0;
- }
+ Type values[channels];
+ for( int i = 0; i < channels; i++ )
+ values[i] = saturate_cast<Type>(value[i]);
+ return func(values, dataPointer, step, size) >= 0;
+}
- static bool IPPSet(const cv::Scalar &value, void *dataPointer, int step, IppiSize &size, int channels, int depth)
- {
- CV_INSTRUMENT_REGION_IPP()
+static bool IPPSet(const cv::Scalar &value, void *dataPointer, int step, IppiSize &size, int channels, int depth)
+{
+ CV_INSTRUMENT_REGION_IPP()
- if( channels == 1 )
+ if( channels == 1 )
+ {
+ switch( depth )
+ {
+ case CV_8U:
+ return CV_INSTRUMENT_FUN_IPP(ippiSet_8u_C1R, saturate_cast<Ipp8u>(value[0]), (Ipp8u *)dataPointer, step, size) >= 0;
+ case CV_16U:
+ return CV_INSTRUMENT_FUN_IPP(ippiSet_16u_C1R, saturate_cast<Ipp16u>(value[0]), (Ipp16u *)dataPointer, step, size) >= 0;
+ case CV_32F:
+ return CV_INSTRUMENT_FUN_IPP(ippiSet_32f_C1R, saturate_cast<Ipp32f>(value[0]), (Ipp32f *)dataPointer, step, size) >= 0;
+ }
+ }
+ else
+ {
+ if( channels == 3 )
{
switch( depth )
{
case CV_8U:
- return CV_INSTRUMENT_FUN_IPP(ippiSet_8u_C1R,(saturate_cast<Ipp8u>(value[0]), (Ipp8u *)dataPointer, step, size)) >= 0;
+ return IPPSetSimple<3, Ipp8u>(value, dataPointer, step, size, (ippiSetFunc)ippiSet_8u_C3R);
case CV_16U:
- return CV_INSTRUMENT_FUN_IPP(ippiSet_16u_C1R,(saturate_cast<Ipp16u>(value[0]), (Ipp16u *)dataPointer, step, size)) >= 0;
+ return IPPSetSimple<3, Ipp16u>(value, dataPointer, step, size, (ippiSetFunc)ippiSet_16u_C3R);
case CV_32F:
- return CV_INSTRUMENT_FUN_IPP(ippiSet_32f_C1R,(saturate_cast<Ipp32f>(value[0]), (Ipp32f *)dataPointer, step, size)) >= 0;
+ return IPPSetSimple<3, Ipp32f>(value, dataPointer, step, size, (ippiSetFunc)ippiSet_32f_C3R);
}
}
- else
+ else if( channels == 4 )
{
- if( channels == 3 )
- {
- switch( depth )
- {
- case CV_8U:
- return IPPSetSimple<3, Ipp8u>(value, dataPointer, step, size, (ippiSetFunc)ippiSet_8u_C3R);
- case CV_16U:
- return IPPSetSimple<3, Ipp16u>(value, dataPointer, step, size, (ippiSetFunc)ippiSet_16u_C3R);
- case CV_32F:
- return IPPSetSimple<3, Ipp32f>(value, dataPointer, step, size, (ippiSetFunc)ippiSet_32f_C3R);
- }
- }
- else if( channels == 4 )
+ switch( depth )
{
- switch( depth )
- {
- case CV_8U:
- return IPPSetSimple<4, Ipp8u>(value, dataPointer, step, size, (ippiSetFunc)ippiSet_8u_C4R);
- case CV_16U:
- return IPPSetSimple<4, Ipp16u>(value, dataPointer, step, size, (ippiSetFunc)ippiSet_16u_C4R);
- case CV_32F:
- return IPPSetSimple<4, Ipp32f>(value, dataPointer, step, size, (ippiSetFunc)ippiSet_32f_C4R);
- }
+ case CV_8U:
+ return IPPSetSimple<4, Ipp8u>(value, dataPointer, step, size, (ippiSetFunc)ippiSet_8u_C4R);
+ case CV_16U:
+ return IPPSetSimple<4, Ipp16u>(value, dataPointer, step, size, (ippiSetFunc)ippiSet_16u_C4R);
+ case CV_32F:
+ return IPPSetSimple<4, Ipp32f>(value, dataPointer, step, size, (ippiSetFunc)ippiSet_32f_C4R);
}
}
- return false;
}
+ return false;
+}
#endif
/************** interpolation formulas and tables ***************/
@@ -442,8 +436,30 @@ resizeNN( const Mat& src, Mat& dst, double fx, double fy )
}
Range range(0, dsize.height);
- resizeNNInvoker invoker(src, dst, x_ofs, pix_size4, ify);
- parallel_for_(range, invoker, dst.total()/(double)(1<<16));
+#if CV_TRY_AVX2
+ if(CV_CPU_HAS_SUPPORT_AVX2 && ((pix_size == 2) || (pix_size == 4)))
+ {
+ if(pix_size == 2)
+ opt_AVX2::resizeNN2_AVX2(range, src, dst, x_ofs, pix_size4, ify);
+ else
+ opt_AVX2::resizeNN4_AVX2(range, src, dst, x_ofs, pix_size4, ify);
+ }
+ else
+#endif
+#if CV_TRY_SSE4_1
+ if(CV_CPU_HAS_SUPPORT_SSE4_1 && ((pix_size == 2) || (pix_size == 4)))
+ {
+ if(pix_size == 2)
+ opt_SSE4_1::resizeNN2_SSE4_1(range, src, dst, x_ofs, pix_size4, ify);
+ else
+ opt_SSE4_1::resizeNN4_SSE4_1(range, src, dst, x_ofs, pix_size4, ify);
+ }
+ else
+#endif
+ {
+ resizeNNInvoker invoker(src, dst, x_ofs, pix_size4, ify);
+ parallel_for_(range, invoker, dst.total()/(double)(1<<16));
+ }
}
@@ -900,50 +916,14 @@ struct VResizeCubicVec_32f
}
};
-#if CV_SSE4_1
+#if CV_TRY_SSE4_1
struct VResizeLanczos4Vec_32f16u
{
int operator()(const uchar** _src, uchar* _dst, const uchar* _beta, int width ) const
{
- const float** src = (const float**)_src;
- const float* beta = (const float*)_beta;
- const float *S0 = src[0], *S1 = src[1], *S2 = src[2], *S3 = src[3],
- *S4 = src[4], *S5 = src[5], *S6 = src[6], *S7 = src[7];
- short * dst = (short*)_dst;
- int x = 0;
- __m128 v_b0 = _mm_set1_ps(beta[0]), v_b1 = _mm_set1_ps(beta[1]),
- v_b2 = _mm_set1_ps(beta[2]), v_b3 = _mm_set1_ps(beta[3]),
- v_b4 = _mm_set1_ps(beta[4]), v_b5 = _mm_set1_ps(beta[5]),
- v_b6 = _mm_set1_ps(beta[6]), v_b7 = _mm_set1_ps(beta[7]);
-
- for( ; x <= width - 8; x += 8 )
- {
- __m128 v_dst0 = _mm_mul_ps(v_b0, _mm_loadu_ps(S0 + x));
- v_dst0 = _mm_add_ps(v_dst0, _mm_mul_ps(v_b1, _mm_loadu_ps(S1 + x)));
- v_dst0 = _mm_add_ps(v_dst0, _mm_mul_ps(v_b2, _mm_loadu_ps(S2 + x)));
- v_dst0 = _mm_add_ps(v_dst0, _mm_mul_ps(v_b3, _mm_loadu_ps(S3 + x)));
- v_dst0 = _mm_add_ps(v_dst0, _mm_mul_ps(v_b4, _mm_loadu_ps(S4 + x)));
- v_dst0 = _mm_add_ps(v_dst0, _mm_mul_ps(v_b5, _mm_loadu_ps(S5 + x)));
- v_dst0 = _mm_add_ps(v_dst0, _mm_mul_ps(v_b6, _mm_loadu_ps(S6 + x)));
- v_dst0 = _mm_add_ps(v_dst0, _mm_mul_ps(v_b7, _mm_loadu_ps(S7 + x)));
-
- __m128 v_dst1 = _mm_mul_ps(v_b0, _mm_loadu_ps(S0 + x + 4));
- v_dst1 = _mm_add_ps(v_dst1, _mm_mul_ps(v_b1, _mm_loadu_ps(S1 + x + 4)));
- v_dst1 = _mm_add_ps(v_dst1, _mm_mul_ps(v_b2, _mm_loadu_ps(S2 + x + 4)));
- v_dst1 = _mm_add_ps(v_dst1, _mm_mul_ps(v_b3, _mm_loadu_ps(S3 + x + 4)));
- v_dst1 = _mm_add_ps(v_dst1, _mm_mul_ps(v_b4, _mm_loadu_ps(S4 + x + 4)));
- v_dst1 = _mm_add_ps(v_dst1, _mm_mul_ps(v_b5, _mm_loadu_ps(S5 + x + 4)));
- v_dst1 = _mm_add_ps(v_dst1, _mm_mul_ps(v_b6, _mm_loadu_ps(S6 + x + 4)));
- v_dst1 = _mm_add_ps(v_dst1, _mm_mul_ps(v_b7, _mm_loadu_ps(S7 + x + 4)));
-
- __m128i v_dsti0 = _mm_cvtps_epi32(v_dst0);
- __m128i v_dsti1 = _mm_cvtps_epi32(v_dst1);
-
- _mm_storeu_si128((__m128i *)(dst + x), _mm_packus_epi32(v_dsti0, v_dsti1));
- }
-
- return x;
+ if (CV_CPU_HAS_SUPPORT_SSE4_1) return opt_SSE4_1::VResizeLanczos4Vec_32f16u_SSE41(_src, _dst, _beta, width);
+ else return 0;
}
};
@@ -1649,7 +1629,7 @@ struct VResizeLanczos4
{
CastOp castOp;
VecOp vecOp;
- int k, x = vecOp((const uchar**)src, (uchar*)dst, (const uchar*)beta, width);
+ int x = vecOp((const uchar**)src, (uchar*)dst, (const uchar*)beta, width);
#if CV_ENABLE_UNROLLED
for( ; x <= width - 4; x += 4 )
{
@@ -1657,7 +1637,7 @@ struct VResizeLanczos4
const WT* S = src[0];
WT s0 = S[x]*b, s1 = S[x+1]*b, s2 = S[x+2]*b, s3 = S[x+3]*b;
- for( k = 1; k < 8; k++ )
+ for( int k = 1; k < 8; k++ )
{
b = beta[k]; S = src[k];
s0 += S[x]*b; s1 += S[x+1]*b;
@@ -1704,10 +1684,6 @@ public:
CV_Assert(ksize <= MAX_ESIZE);
}
-#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Warray-bounds"
-#endif
virtual void operator() (const Range& range) const
{
int dy, cn = src.channels();
@@ -1737,7 +1713,7 @@ public:
int sy = clip(sy0 - ksize2 + 1 + k, 0, ssize.height);
for( k1 = std::max(k1, k); k1 < ksize; k1++ )
{
- if( sy == prev_sy[k1] ) // if the sy-th row has been computed already, reuse it.
+ if( k1 < MAX_ESIZE && sy == prev_sy[k1] ) // if the sy-th row has been computed already, reuse it.
{
if( k1 > k )
memcpy( rows[k], rows[k1], bufstep*sizeof(rows[0][0]) );
@@ -1756,9 +1732,6 @@ public:
vresize( (const WT**)rows, (T*)(dst.data + dst.step*dy), beta, dsize.width );
}
}
-#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
-# pragma GCC diagnostic pop
-#endif
private:
Mat src;
@@ -2715,135 +2688,7 @@ static int computeResizeAreaTab( int ssize, int dsize, int cn, double scale, Dec
return k;
}
-#define CHECK_IPP_STATUS(STATUS) if (STATUS < 0) { *ok = false; return; }
-
-#define SET_IPP_RESIZE_LINEAR_FUNC_PTR(TYPE, CN) \
- ippiResize = (ippiResizeFunc)ippiResizeLinear_##TYPE##_##CN##R; \
- CHECK_IPP_STATUS(ippiResizeGetSize_##TYPE(srcSize, dstSize, (IppiInterpolationType)mode, 0, &specSize, &initSize));\
- specBuf.allocate(specSize);\
- pSpec = (uchar*)specBuf;\
- CHECK_IPP_STATUS(ippiResizeLinearInit_##TYPE(srcSize, dstSize, (IppiResizeSpec_32f*)pSpec));
-
-#define SET_IPP_RESIZE_LINEAR_FUNC_64_PTR(TYPE, CN) \
- if (mode == (int)ippCubic) { *ok = false; return; } \
- ippiResize = (ippiResizeFunc)ippiResizeLinear_##TYPE##_##CN##R; \
- CHECK_IPP_STATUS(ippiResizeGetSize_##TYPE(srcSize, dstSize, (IppiInterpolationType)mode, 0, &specSize, &initSize));\
- specBuf.allocate(specSize);\
- pSpec = (uchar*)specBuf;\
- CHECK_IPP_STATUS(ippiResizeLinearInit_##TYPE(srcSize, dstSize, (IppiResizeSpec_64f*)pSpec));\
- getBufferSizeFunc = (ippiResizeGetBufferSize)ippiResizeGetBufferSize_##TYPE;\
- getSrcOffsetFunc = (ippiResizeGetSrcOffset) ippiResizeGetSrcOffset_##TYPE;
-
-#define SET_IPP_RESIZE_CUBIC_FUNC_PTR(TYPE, CN) \
- ippiResize = (ippiResizeFunc)ippiResizeCubic_##TYPE##_##CN##R; \
- CHECK_IPP_STATUS(ippiResizeGetSize_##TYPE(srcSize, dstSize, (IppiInterpolationType)mode, 0, &specSize, &initSize));\
- specBuf.allocate(specSize);\
- pSpec = (uchar*)specBuf;\
- AutoBuffer<uchar> buf(initSize);\
- uchar* pInit = (uchar*)buf;\
- CHECK_IPP_STATUS(ippiResizeCubicInit_##TYPE(srcSize, dstSize, 0.f, 0.75f, (IppiResizeSpec_32f*)pSpec, pInit));
-
-#define SET_IPP_RESIZE_PTR(TYPE, CN) \
- if (mode == (int)ippLinear) { SET_IPP_RESIZE_LINEAR_FUNC_PTR(TYPE, CN);} \
- else if (mode == (int)ippCubic) { SET_IPP_RESIZE_CUBIC_FUNC_PTR(TYPE, CN);} \
- else { *ok = false; return; } \
- getBufferSizeFunc = (ippiResizeGetBufferSize)ippiResizeGetBufferSize_##TYPE; \
- getSrcOffsetFunc = (ippiResizeGetSrcOffset)ippiResizeGetSrcOffset_##TYPE;
-
-#if IPP_VERSION_X100 >= 710
-class IPPresizeInvoker :
- public ParallelLoopBody
-{
-public:
- IPPresizeInvoker(const Mat & _src, Mat & _dst, double _inv_scale_x, double _inv_scale_y, int _mode, bool *_ok) :
- ParallelLoopBody(), src(_src), dst(_dst), inv_scale_x(_inv_scale_x),
- inv_scale_y(_inv_scale_y), pSpec(NULL), mode(_mode),
- ippiResize(NULL), getBufferSizeFunc(NULL), getSrcOffsetFunc(NULL), ok(_ok)
- {
- *ok = true;
- IppiSize srcSize, dstSize;
- int type = src.type(), specSize = 0, initSize = 0;
- srcSize.width = src.cols;
- srcSize.height = src.rows;
- dstSize.width = dst.cols;
- dstSize.height = dst.rows;
-
- switch (type)
- {
-#if IPP_DISABLE_BLOCK // disabled since it breaks tests for CascadeClassifier
- case CV_8UC1: SET_IPP_RESIZE_PTR(8u,C1); break;
- case CV_8UC3: SET_IPP_RESIZE_PTR(8u,C3); break;
- case CV_8UC4: SET_IPP_RESIZE_PTR(8u,C4); break;
-#endif
- case CV_16UC1: SET_IPP_RESIZE_PTR(16u,C1); break;
- case CV_16UC3: SET_IPP_RESIZE_PTR(16u,C3); break;
- case CV_16UC4: SET_IPP_RESIZE_PTR(16u,C4); break;
- case CV_16SC1: SET_IPP_RESIZE_PTR(16s,C1); break;
- case CV_16SC3: SET_IPP_RESIZE_PTR(16s,C3); break;
- case CV_16SC4: SET_IPP_RESIZE_PTR(16s,C4); break;
- case CV_32FC1: SET_IPP_RESIZE_PTR(32f,C1); break;
- case CV_32FC3: SET_IPP_RESIZE_PTR(32f,C3); break;
- case CV_32FC4: SET_IPP_RESIZE_PTR(32f,C4); break;
- case CV_64FC1: SET_IPP_RESIZE_LINEAR_FUNC_64_PTR(64f,C1); break;
- case CV_64FC3: SET_IPP_RESIZE_LINEAR_FUNC_64_PTR(64f,C3); break;
- case CV_64FC4: SET_IPP_RESIZE_LINEAR_FUNC_64_PTR(64f,C4); break;
- default: { *ok = false; return; } break;
- }
- }
-
- ~IPPresizeInvoker()
- {
- }
-
- virtual void operator() (const Range& range) const
- {
- if (*ok == false)
- return;
-
- int cn = src.channels();
- int dsty = min(cvRound(range.start * inv_scale_y), dst.rows);
- int dstwidth = min(cvRound(src.cols * inv_scale_x), dst.cols);
- int dstheight = min(cvRound(range.end * inv_scale_y), dst.rows);
-
- IppiPoint dstOffset = { 0, dsty }, srcOffset = {0, 0};
- IppiSize dstSize = { dstwidth, dstheight - dsty };
- int bufsize = 0, itemSize = (int)src.elemSize1();
-
- CHECK_IPP_STATUS(getBufferSizeFunc(pSpec, dstSize, cn, &bufsize));
- CHECK_IPP_STATUS(getSrcOffsetFunc(pSpec, dstOffset, &srcOffset));
-
- const Ipp8u* pSrc = src.ptr<Ipp8u>(srcOffset.y) + srcOffset.x * cn * itemSize;
- Ipp8u* pDst = dst.ptr<Ipp8u>(dstOffset.y) + dstOffset.x * cn * itemSize;
-
- AutoBuffer<uchar> buf(bufsize + 64);
- uchar* bufptr = alignPtr((uchar*)buf, 32);
-
- if( CV_INSTRUMENT_FUN_IPP(ippiResize, pSrc, (int)src.step[0], pDst, (int)dst.step[0], dstOffset, dstSize, ippBorderRepl, 0, pSpec, bufptr) < 0 )
- *ok = false;
- else
- {
- CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
- }
- }
-private:
- const Mat & src;
- Mat & dst;
- double inv_scale_x;
- double inv_scale_y;
- void *pSpec;
- AutoBuffer<uchar> specBuf;
- int mode;
- ippiResizeFunc ippiResize;
- ippiResizeGetBufferSize getBufferSizeFunc;
- ippiResizeGetSrcOffset getSrcOffsetFunc;
- bool *ok;
- const IPPresizeInvoker& operator= (const IPPresizeInvoker&);
-};
-
-#endif
-
#ifdef HAVE_OPENCL
-
static void ocl_computeResizeAreaTabs(int ssize, int dsize, double scale, int * const map_tab,
float * const alpha_tab, int * const ofs_tab)
{
@@ -3097,28 +2942,190 @@ static bool ocl_resize( InputArray _src, OutputArray _dst, Size dsize,
#endif
-#if IPP_VERSION_X100 >= 710
-static bool ipp_resize_mt(Mat & src, Mat & dst,
- double inv_scale_x, double inv_scale_y, int interpolation)
+#ifdef HAVE_IPP
+#define IPP_RESIZE_PARALLEL 1
+
+#ifdef HAVE_IPP_IW
+class ipp_resizeParallel: public ParallelLoopBody
+{
+public:
+ ipp_resizeParallel(::ipp::IwiImage &src, ::ipp::IwiImage &dst, bool &ok):
+ m_src(src), m_dst(dst), m_ok(ok) {}
+ ~ipp_resizeParallel()
+ {
+ }
+
+ void Init(IppiInterpolationType inter)
+ {
+ iwiResize.InitAlloc(m_src.m_size, m_dst.m_size, m_src.m_dataType, m_src.m_channels, inter, ::ipp::IwiResizeParams(0, 0, 0.75, 4), ippBorderRepl);
+
+ m_ok = true;
+ }
+
+ virtual void operator() (const Range& range) const
+ {
+ CV_INSTRUMENT_REGION_IPP()
+
+ if(!m_ok)
+ return;
+
+ try
+ {
+ ::ipp::IwiRoi roi = ::ipp::IwiRect(0, range.start, m_dst.m_size.width, range.end - range.start);
+ CV_INSTRUMENT_FUN_IPP(iwiResize, &m_src, &m_dst, &roi);
+ }
+ catch(::ipp::IwException)
+ {
+ m_ok = false;
+ return;
+ }
+ }
+private:
+ ::ipp::IwiImage &m_src;
+ ::ipp::IwiImage &m_dst;
+
+ mutable ::ipp::IwiResize iwiResize;
+
+ volatile bool &m_ok;
+ const ipp_resizeParallel& operator= (const ipp_resizeParallel&);
+};
+
+class ipp_resizeAffineParallel: public ParallelLoopBody
+{
+public:
+ ipp_resizeAffineParallel(::ipp::IwiImage &src, ::ipp::IwiImage &dst, bool &ok):
+ m_src(src), m_dst(dst), m_ok(ok) {}
+ ~ipp_resizeAffineParallel()
+ {
+ }
+
+ void Init(IppiInterpolationType inter, double scaleX, double scaleY)
+ {
+ double shift = (inter == ippNearest)?-1e-10:-0.5;
+ double coeffs[2][3] = {
+ {scaleX, 0, shift+0.5*scaleX},
+ {0, scaleY, shift+0.5*scaleY}
+ };
+
+ iwiWarpAffine.InitAlloc(m_src.m_size, m_dst.m_size, m_src.m_dataType, m_src.m_channels, coeffs, ippWarpForward, inter, ::ipp::IwiWarpAffineParams(0, 0.75, 0), ippBorderRepl);
+
+ m_ok = true;
+ }
+
+ virtual void operator() (const Range& range) const
+ {
+ CV_INSTRUMENT_REGION_IPP()
+
+ if(!m_ok)
+ return;
+
+ try
+ {
+ ::ipp::IwiRoi roi = ::ipp::IwiRect(0, range.start, m_dst.m_size.width, range.end - range.start);
+ CV_INSTRUMENT_FUN_IPP(iwiWarpAffine, &m_src, &m_dst, &roi);
+ }
+ catch(::ipp::IwException)
+ {
+ m_ok = false;
+ return;
+ }
+ }
+private:
+ ::ipp::IwiImage &m_src;
+ ::ipp::IwiImage &m_dst;
+
+ mutable ::ipp::IwiWarpAffine iwiWarpAffine;
+
+ volatile bool &m_ok;
+ const ipp_resizeAffineParallel& operator= (const ipp_resizeAffineParallel&);
+};
+#endif
+
+static bool ipp_resize(const uchar * src_data, size_t src_step, int src_width, int src_height,
+ uchar * dst_data, size_t dst_step, int dst_width, int dst_height, double inv_scale_x, double inv_scale_y,
+ int depth, int channels, int interpolation)
{
+#ifdef HAVE_IPP_IW
CV_INSTRUMENT_REGION_IPP()
- int mode = -1;
- if (interpolation == INTER_LINEAR && src.rows >= 2 && src.cols >= 2)
- mode = ippLinear;
- else if (interpolation == INTER_CUBIC && src.rows >= 4 && src.cols >= 4)
- mode = ippCubic;
- else
+ IppDataType ippDataType = ippiGetDataType(depth);
+ IppiInterpolationType ippInter = ippiGetInterpolation(interpolation);
+ if(ippInter < 0)
return false;
- bool ok = true;
- Range range(0, src.rows);
- IPPresizeInvoker invoker(src, dst, inv_scale_x, inv_scale_y, mode, &ok);
- parallel_for_(range, invoker, dst.total()/(double)(1<<16));
- if( ok )
- return true;
+#if IPP_DISABLE_RESIZE_NEAREST
+ if(ippInter == ippNearest)
+ return false;
+#endif
+
+#if IPP_DISABLE_RESIZE_AREA
+ if(ippInter == ippSuper)
+ return false;
+#endif
+
+ if(ippInter != ippLinear && ippDataType == ipp64f)
+ return false;
+
+ // Accuracy mismatch is 1 but affects detectors greatly
+#if IPP_DISABLE_RESIZE_8U
+ if(ippDataType == ipp8u && ippInter == ippLinear)
+ return false;
+#endif
+
+ bool affine = false;
+ const double IPP_RESIZE_EPS = (depth == CV_64F)?0:1e-10;
+ double ex = fabs((double)dst_width / src_width - inv_scale_x) / inv_scale_x;
+ double ey = fabs((double)dst_height / src_height - inv_scale_y) / inv_scale_y;
+
+ // Use affine transform resize to allow sub-pixel accuracy
+ if(ex > IPP_RESIZE_EPS || ey > IPP_RESIZE_EPS)
+ affine = true;
+
+ // Affine doesn't support Lanczos and Super interpolations
+ if(affine && (ippInter == ippLanczos || ippInter == ippSuper))
+ return false;
+ try
+ {
+ ::ipp::IwiImage iwSrc(::ipp::IwiSize(src_width, src_height), ippDataType, channels, 0, (void*)src_data, src_step);
+ ::ipp::IwiImage iwDst(::ipp::IwiSize(dst_width, dst_height), ippDataType, channels, 0, (void*)dst_data, dst_step);
+
+ bool ok;
+ int threads = ippiSuggestThreadsNum(iwDst, 1+((double)(src_width*src_height)/(dst_width*dst_height)));
+ Range range(0, dst_height);
+ ipp_resizeParallel invokerGeneral(iwSrc, iwDst, ok);
+ ipp_resizeAffineParallel invokerAffine(iwSrc, iwDst, ok);
+ ParallelLoopBody *pInvoker = NULL;
+ if(affine)
+ {
+ pInvoker = &invokerAffine;
+ invokerAffine.Init(ippInter, inv_scale_x, inv_scale_y);
+ }
+ else
+ {
+ pInvoker = &invokerGeneral;
+ invokerGeneral.Init(ippInter);
+ }
+
+ if(IPP_RESIZE_PARALLEL && threads > 1)
+ parallel_for_(range, *pInvoker, threads*4);
+ else
+ pInvoker->operator()(range);
+
+ if(!ok)
+ return false;
+ }
+ catch(::ipp::IwException)
+ {
+ return false;
+ }
+ return true;
+#else
+ CV_UNUSED(src_data); CV_UNUSED(src_step); CV_UNUSED(src_width); CV_UNUSED(src_height); CV_UNUSED(dst_data); CV_UNUSED(dst_step);
+ CV_UNUSED(dst_width); CV_UNUSED(dst_height); CV_UNUSED(inv_scale_x); CV_UNUSED(inv_scale_y); CV_UNUSED(depth);
+ CV_UNUSED(channels); CV_UNUSED(interpolation);
return false;
+#endif
}
#endif
@@ -3142,6 +3149,13 @@ void resize(int src_type,
CALL_HAL(resize, cv_hal_resize, src_type, src_data, src_step, src_width, src_height, dst_data, dst_step, dst_width, dst_height, inv_scale_x, inv_scale_y, interpolation);
+ int depth = CV_MAT_DEPTH(src_type), cn = CV_MAT_CN(src_type);
+ Size dsize = Size(saturate_cast<int>(src_width*inv_scale_x),
+ saturate_cast<int>(src_height*inv_scale_y));
+ CV_Assert( dsize.area() > 0 );
+
+ CV_IPP_RUN_FAST(ipp_resize(src_data, src_step, src_width, src_height, dst_data, dst_step, dsize.width, dsize.height, inv_scale_x, inv_scale_y, depth, cn, interpolation))
+
static ResizeFunc linear_tab[] =
{
resizeGeneric_<
@@ -3246,7 +3260,6 @@ void resize(int src_type,
resizeArea_<double, double>, 0
};
- int depth = CV_MAT_DEPTH(src_type), cn = CV_MAT_CN(src_type);
double scale_x = 1./inv_scale_x, scale_y = 1./inv_scale_y;
int iscale_x = saturate_cast<int>(scale_x);
@@ -3255,31 +3268,9 @@ void resize(int src_type,
bool is_area_fast = std::abs(scale_x - iscale_x) < DBL_EPSILON &&
std::abs(scale_y - iscale_y) < DBL_EPSILON;
- Size dsize = Size(saturate_cast<int>(src_width*inv_scale_x),
- saturate_cast<int>(src_height*inv_scale_y));
- CV_Assert( dsize.area() > 0 );
-
Mat src(Size(src_width, src_height), src_type, const_cast<uchar*>(src_data), src_step);
Mat dst(dsize, src_type, dst_data, dst_step);
-#ifdef HAVE_IPP
- int mode = -1;
- if (interpolation == INTER_LINEAR && src_height >= 2 && src_width >= 2)
- mode = INTER_LINEAR;
- else if (interpolation == INTER_CUBIC && src_height >= 4 && src_width >= 4)
- mode = INTER_CUBIC;
-
- const double IPP_RESIZE_EPS = 1e-10;
- double ex = fabs((double)dsize.width / src_width - inv_scale_x) / inv_scale_x;
- double ey = fabs((double)dsize.height / src_height - inv_scale_y) / inv_scale_y;
-#endif
- CV_IPP_RUN(IPP_VERSION_X100 >= 710 && ((ex < IPP_RESIZE_EPS && ey < IPP_RESIZE_EPS && depth != CV_64F) || (ex == 0 && ey == 0 && depth == CV_64F)) &&
- (interpolation == INTER_LINEAR || interpolation == INTER_CUBIC) &&
- !(interpolation == INTER_LINEAR && is_area_fast && iscale_x == 2 && iscale_y == 2 && depth == CV_8U) &&
- mode >= 0 && (cn == 1 || cn == 3 || cn == 4) && (depth == CV_16U || depth == CV_16S || depth == CV_32F ||
- (depth == CV_64F && mode == INTER_LINEAR)),
- ipp_resize_mt(src, dst, inv_scale_x, inv_scale_y, interpolation))
-
if( interpolation == INTER_NEAREST )
{
resizeNN( src, dst, inv_scale_x, inv_scale_y );
@@ -3533,14 +3524,13 @@ static void remapNearest( const Mat& _src, Mat& _dst, const Mat& _xy,
int borderType, const Scalar& _borderValue )
{
Size ssize = _src.size(), dsize = _dst.size();
- int cn = _src.channels();
+ const int cn = _src.channels();
const T* S0 = _src.ptr<T>();
+ T cval[CV_CN_MAX];
size_t sstep = _src.step/sizeof(S0[0]);
- Scalar_<T> cval(saturate_cast<T>(_borderValue[0]),
- saturate_cast<T>(_borderValue[1]),
- saturate_cast<T>(_borderValue[2]),
- saturate_cast<T>(_borderValue[3]));
- int dx, dy;
+
+ for(int k = 0; k < cn; k++ )
+ cval[k] = saturate_cast<T>(_borderValue[k & 3]);
unsigned width1 = ssize.width, height1 = ssize.height;
@@ -3550,14 +3540,14 @@ static void remapNearest( const Mat& _src, Mat& _dst, const Mat& _xy,
dsize.height = 1;
}
- for( dy = 0; dy < dsize.height; dy++ )
+ for(int dy = 0; dy < dsize.height; dy++ )
{
T* D = _dst.ptr<T>(dy);
const short* XY = _xy.ptr<short>(dy);
if( cn == 1 )
{
- for( dx = 0; dx < dsize.width; dx++ )
+ for(int dx = 0; dx < dsize.width; dx++ )
{
int sx = XY[dx*2], sy = XY[dx*2+1];
if( (unsigned)sx < width1 && (unsigned)sy < height1 )
@@ -3583,9 +3573,9 @@ static void remapNearest( const Mat& _src, Mat& _dst, const Mat& _xy,
}
else
{
- for( dx = 0; dx < dsize.width; dx++, D += cn )
+ for(int dx = 0; dx < dsize.width; dx++, D += cn )
{
- int sx = XY[dx*2], sy = XY[dx*2+1], k;
+ int sx = XY[dx*2], sy = XY[dx*2+1];
const T *S;
if( (unsigned)sx < width1 && (unsigned)sy < height1 )
{
@@ -3602,7 +3592,7 @@ static void remapNearest( const Mat& _src, Mat& _dst, const Mat& _xy,
else
{
S = S0 + sy*sstep + sx*cn;
- for( k = 0; k < cn; k++ )
+ for(int k = 0; k < cn; k++ )
D[k] = S[k];
}
}
@@ -3622,7 +3612,7 @@ static void remapNearest( const Mat& _src, Mat& _dst, const Mat& _xy,
sy = borderInterpolate(sy, ssize.height, borderType);
S = S0 + sy*sstep + sx*cn;
}
- for( k = 0; k < cn; k++ )
+ for(int k = 0; k < cn; k++ )
D[k] = S[k];
}
}
@@ -3852,16 +3842,15 @@ static void remapBilinear( const Mat& _src, Mat& _dst, const Mat& _xy,
typedef typename CastOp::rtype T;
typedef typename CastOp::type1 WT;
Size ssize = _src.size(), dsize = _dst.size();
- int k, cn = _src.channels();
+ const int cn = _src.channels();
const AT* wtab = (const AT*)_wtab;
const T* S0 = _src.ptr<T>();
size_t sstep = _src.step/sizeof(S0[0]);
T cval[CV_CN_MAX];
- int dx, dy;
CastOp castOp;
VecOp vecOp;
- for( k = 0; k < cn; k++ )
+ for(int k = 0; k < cn; k++ )
cval[k] = saturate_cast<T>(_borderValue[k & 3]);
unsigned width1 = std::max(ssize.width-1, 0), height1 = std::max(ssize.height-1, 0);
@@ -3871,7 +3860,7 @@ static void remapBilinear( const Mat& _src, Mat& _dst, const Mat& _xy,
width1 = std::max(ssize.width-2, 0);
#endif
- for( dy = 0; dy < dsize.height; dy++ )
+ for(int dy = 0; dy < dsize.height; dy++ )
{
T* D = _dst.ptr<T>(dy);
const short* XY = _xy.ptr<short>(dy);
@@ -3879,7 +3868,7 @@ static void remapBilinear( const Mat& _src, Mat& _dst, const Mat& _xy,
int X0 = 0;
bool prevInlier = false;
- for( dx = 0; dx <= dsize.width; dx++ )
+ for(int dx = 0; dx <= dsize.width; dx++ )
{
bool curInlier = dx < dsize.width ?
(unsigned)XY[dx*2] < width1 &&
@@ -3948,7 +3937,7 @@ static void remapBilinear( const Mat& _src, Mat& _dst, const Mat& _xy,
int sx = XY[dx*2], sy = XY[dx*2+1];
const AT* w = wtab + FXY[dx]*4;
const T* S = S0 + sy*sstep + sx*cn;
- for( k = 0; k < cn; k++ )
+ for(int k = 0; k < cn; k++ )
{
WT t0 = S[k]*w[0] + S[k+cn]*w[1] + S[sstep+k]*w[2] + S[sstep+k+cn]*w[3];
D[k] = castOp(t0);
@@ -4012,7 +4001,7 @@ static void remapBilinear( const Mat& _src, Mat& _dst, const Mat& _xy,
(sx >= ssize.width || sx+1 < 0 ||
sy >= ssize.height || sy+1 < 0) )
{
- for( k = 0; k < cn; k++ )
+ for(int k = 0; k < cn; k++ )
D[k] = cval[k];
}
else
@@ -4046,7 +4035,7 @@ static void remapBilinear( const Mat& _src, Mat& _dst, const Mat& _xy,
v2 = sx0 >= 0 && sy1 >= 0 ? S0 + sy1*sstep + sx0*cn : &cval[0];
v3 = sx1 >= 0 && sy1 >= 0 ? S0 + sy1*sstep + sx1*cn : &cval[0];
}
- for( k = 0; k < cn; k++ )
+ for(int k = 0; k < cn; k++ )
D[k] = castOp(WT(v0[k]*w[0] + v1[k]*w[1] + v2[k]*w[2] + v3[k]*w[3]));
}
}
@@ -4064,16 +4053,16 @@ static void remapBicubic( const Mat& _src, Mat& _dst, const Mat& _xy,
typedef typename CastOp::rtype T;
typedef typename CastOp::type1 WT;
Size ssize = _src.size(), dsize = _dst.size();
- int cn = _src.channels();
+ const int cn = _src.channels();
const AT* wtab = (const AT*)_wtab;
const T* S0 = _src.ptr<T>();
size_t sstep = _src.step/sizeof(S0[0]);
- Scalar_<T> cval(saturate_cast<T>(_borderValue[0]),
- saturate_cast<T>(_borderValue[1]),
- saturate_cast<T>(_borderValue[2]),
- saturate_cast<T>(_borderValue[3]));
- int dx, dy;
+ T cval[CV_CN_MAX];
CastOp castOp;
+
+ for(int k = 0; k < cn; k++ )
+ cval[k] = saturate_cast<T>(_borderValue[k & 3]);
+
int borderType1 = borderType != BORDER_TRANSPARENT ? borderType : BORDER_REFLECT_101;
unsigned width1 = std::max(ssize.width-3, 0), height1 = std::max(ssize.height-3, 0);
@@ -4084,21 +4073,20 @@ static void remapBicubic( const Mat& _src, Mat& _dst, const Mat& _xy,
dsize.height = 1;
}
- for( dy = 0; dy < dsize.height; dy++ )
+ for(int dy = 0; dy < dsize.height; dy++ )
{
T* D = _dst.ptr<T>(dy);
const short* XY = _xy.ptr<short>(dy);
const ushort* FXY = _fxy.ptr<ushort>(dy);
- for( dx = 0; dx < dsize.width; dx++, D += cn )
+ for(int dx = 0; dx < dsize.width; dx++, D += cn )
{
int sx = XY[dx*2]-1, sy = XY[dx*2+1]-1;
const AT* w = wtab + FXY[dx]*16;
- int i, k;
if( (unsigned)sx < width1 && (unsigned)sy < height1 )
{
const T* S = S0 + sy*sstep + sx*cn;
- for( k = 0; k < cn; k++ )
+ for(int k = 0; k < cn; k++ )
{
WT sum = S[0]*w[0] + S[cn]*w[1] + S[cn*2]*w[2] + S[cn*3]*w[3];
S += sstep;
@@ -4123,21 +4111,21 @@ static void remapBicubic( const Mat& _src, Mat& _dst, const Mat& _xy,
(sx >= ssize.width || sx+4 <= 0 ||
sy >= ssize.height || sy+4 <= 0))
{
- for( k = 0; k < cn; k++ )
+ for(int k = 0; k < cn; k++ )
D[k] = cval[k];
continue;
}
- for( i = 0; i < 4; i++ )
+ for(int i = 0; i < 4; i++ )
{
x[i] = borderInterpolate(sx + i, ssize.width, borderType1)*cn;
y[i] = borderInterpolate(sy + i, ssize.height, borderType1);
}
- for( k = 0; k < cn; k++, S0++, w -= 16 )
+ for(int k = 0; k < cn; k++, S0++, w -= 16 )
{
WT cv = cval[k], sum = cv*ONE;
- for( i = 0; i < 4; i++, w += 4 )
+ for(int i = 0; i < 4; i++, w += 4 )
{
int yi = y[i];
const T* S = S0 + yi*sstep;
@@ -4169,16 +4157,16 @@ static void remapLanczos4( const Mat& _src, Mat& _dst, const Mat& _xy,
typedef typename CastOp::rtype T;
typedef typename CastOp::type1 WT;
Size ssize = _src.size(), dsize = _dst.size();
- int cn = _src.channels();
+ const int cn = _src.channels();
const AT* wtab = (const AT*)_wtab;
const T* S0 = _src.ptr<T>();
size_t sstep = _src.step/sizeof(S0[0]);
- Scalar_<T> cval(saturate_cast<T>(_borderValue[0]),
- saturate_cast<T>(_borderValue[1]),
- saturate_cast<T>(_borderValue[2]),
- saturate_cast<T>(_borderValue[3]));
- int dx, dy;
+ T cval[CV_CN_MAX];
CastOp castOp;
+
+ for(int k = 0; k < cn; k++ )
+ cval[k] = saturate_cast<T>(_borderValue[k & 3]);
+
int borderType1 = borderType != BORDER_TRANSPARENT ? borderType : BORDER_REFLECT_101;
unsigned width1 = std::max(ssize.width-7, 0), height1 = std::max(ssize.height-7, 0);
@@ -4189,21 +4177,20 @@ static void remapLanczos4( const Mat& _src, Mat& _dst, const Mat& _xy,
dsize.height = 1;
}
- for( dy = 0; dy < dsize.height; dy++ )
+ for(int dy = 0; dy < dsize.height; dy++ )
{
T* D = _dst.ptr<T>(dy);
const short* XY = _xy.ptr<short>(dy);
const ushort* FXY = _fxy.ptr<ushort>(dy);
- for( dx = 0; dx < dsize.width; dx++, D += cn )
+ for(int dx = 0; dx < dsize.width; dx++, D += cn )
{
int sx = XY[dx*2]-3, sy = XY[dx*2+1]-3;
const AT* w = wtab + FXY[dx]*64;
const T* S = S0 + sy*sstep + sx*cn;
- int i, k;
if( (unsigned)sx < width1 && (unsigned)sy < height1 )
{
- for( k = 0; k < cn; k++ )
+ for(int k = 0; k < cn; k++ )
{
WT sum = 0;
for( int r = 0; r < 8; r++, S += sstep, w += 8 )
@@ -4226,21 +4213,21 @@ static void remapLanczos4( const Mat& _src, Mat& _dst, const Mat& _xy,
(sx >= ssize.width || sx+8 <= 0 ||
sy >= ssize.height || sy+8 <= 0))
{
- for( k = 0; k < cn; k++ )
+ for(int k = 0; k < cn; k++ )
D[k] = cval[k];
continue;
}
- for( i = 0; i < 8; i++ )
+ for(int i = 0; i < 8; i++ )
{
x[i] = borderInterpolate(sx + i, ssize.width, borderType1)*cn;
y[i] = borderInterpolate(sy + i, ssize.height, borderType1);
}
- for( k = 0; k < cn; k++, S0++, w -= 64 )
+ for(int k = 0; k < cn; k++, S0++, w -= 64 )
{
WT cv = cval[k], sum = cv*ONE;
- for( i = 0; i < 8; i++, w += 8 )
+ for(int i = 0; i < 8; i++, w += 8 )
{
int yi = y[i];
const T* S1 = S0 + yi*sstep;
@@ -4795,7 +4782,7 @@ static bool openvx_remap(Mat src, Mat dst, Mat map1, Mat map2, int interpolation
try
{
- ivx::Context ctx = ivx::Context::create();
+ ivx::Context ctx = ovx::getOpenVXContext();
Mat a;
if (dst.data != src.data)
@@ -4840,7 +4827,7 @@ static bool openvx_remap(Mat src, Mat dst, Mat map1, Mat map2, int interpolation
}
#endif
-#if defined HAVE_IPP && IPP_DISABLE_BLOCK
+#if defined HAVE_IPP && !IPP_DISABLE_REMAP
typedef IppStatus (CV_STDCALL * ippiRemap)(const void * pSrc, IppiSize srcSize, int srcStep, IppiRect srcRoi,
const Ipp32f* pxMap, int xMapStep, const Ipp32f* pyMap, int yMapStep,
@@ -4872,9 +4859,9 @@ public:
return;
}
- if (CV_INSTRUMENT_FUN_PTR_CALL_IPP(ippFunc,(src.ptr(), ippiSize(src.size()), (int)src.step, srcRoiRect,
+ if (CV_INSTRUMENT_FUN_IPP(ippFunc, src.ptr(), ippiSize(src.size()), (int)src.step, srcRoiRect,
map1.ptr<Ipp32f>(), (int)map1.step, map2.ptr<Ipp32f>(), (int)map2.step,
- dstRoi.ptr(), (int)dstRoi.step, dstRoiSize, ippInterpolation)) < 0)
+ dstRoi.ptr(), (int)dstRoi.step, dstRoiSize, ippInterpolation) < 0)
*ok = false;
else
{
@@ -4946,6 +4933,7 @@ void cv::remap( InputArray _src, OutputArray _dst,
CV_OVX_RUN(
src.type() == CV_8UC1 && dst.type() == CV_8UC1 &&
+ !ovx::skipSmallImages<VX_KERNEL_REMAP>(src.cols, src.rows) &&
(borderType& ~BORDER_ISOLATED) == BORDER_CONSTANT &&
((map1.type() == CV_32FC2 && map2.empty() && map1.size == dst.size) ||
(map1.type() == CV_32FC1 && map2.type() == CV_32FC1 && map1.size == dst.size && map2.size == dst.size) ||
@@ -4963,7 +4951,7 @@ void cv::remap( InputArray _src, OutputArray _dst,
int type = src.type(), depth = CV_MAT_DEPTH(type);
-#if defined HAVE_IPP && IPP_DISABLE_BLOCK
+#if defined HAVE_IPP && !IPP_DISABLE_REMAP
CV_IPP_CHECK()
{
if ((interpolation == INTER_LINEAR || interpolation == INTER_CUBIC || interpolation == INTER_NEAREST) &&
@@ -5019,10 +5007,14 @@ void cv::remap( InputArray _src, OutputArray _dst,
{
if( interpolation == INTER_LINEAR )
ifunc = linear_tab[depth];
- else if( interpolation == INTER_CUBIC )
+ else if( interpolation == INTER_CUBIC ){
ifunc = cubic_tab[depth];
- else if( interpolation == INTER_LANCZOS4 )
+ CV_Assert( _src.channels() <= 4 );
+ }
+ else if( interpolation == INTER_LANCZOS4 ){
ifunc = lanczos4_tab[depth];
+ CV_Assert( _src.channels() <= 4 );
+ }
else
CV_Error( CV_StsBadArg, "Unknown interpolation method" );
CV_Assert( ifunc != 0 );
@@ -5121,8 +5113,8 @@ void cv::convertMaps( InputArray _map1, InputArray _map2,
#if CV_SSE2
bool useSSE2 = checkHardwareSupport(CV_CPU_SSE2);
#endif
-#if CV_SSE4_1
- bool useSSE4_1 = checkHardwareSupport(CV_CPU_SSE4_1);
+#if CV_TRY_SSE4_1
+ bool useSSE4_1 = CV_CPU_HAS_SUPPORT_SSE4_1;
#endif
const float scale = 1.f/INTER_TAB_SIZE;
@@ -5155,29 +5147,10 @@ void cv::convertMaps( InputArray _map1, InputArray _map2,
vst2q_s16(dst1 + (x << 1), v_dst);
}
- #elif CV_SSE4_1
+ #elif CV_TRY_SSE4_1
if (useSSE4_1)
- {
- for( ; x <= size.width - 16; x += 16 )
- {
- __m128i v_dst0 = _mm_packs_epi32(_mm_cvtps_epi32(_mm_loadu_ps(src1f + x)),
- _mm_cvtps_epi32(_mm_loadu_ps(src1f + x + 4)));
- __m128i v_dst1 = _mm_packs_epi32(_mm_cvtps_epi32(_mm_loadu_ps(src1f + x + 8)),
- _mm_cvtps_epi32(_mm_loadu_ps(src1f + x + 12)));
-
- __m128i v_dst2 = _mm_packs_epi32(_mm_cvtps_epi32(_mm_loadu_ps(src2f + x)),
- _mm_cvtps_epi32(_mm_loadu_ps(src2f + x + 4)));
- __m128i v_dst3 = _mm_packs_epi32(_mm_cvtps_epi32(_mm_loadu_ps(src2f + x + 8)),
- _mm_cvtps_epi32(_mm_loadu_ps(src2f + x + 12)));
-
- _mm_interleave_epi16(v_dst0, v_dst1, v_dst2, v_dst3);
-
- _mm_storeu_si128((__m128i *)(dst1 + x * 2), v_dst0);
- _mm_storeu_si128((__m128i *)(dst1 + x * 2 + 8), v_dst1);
- _mm_storeu_si128((__m128i *)(dst1 + x * 2 + 16), v_dst2);
- _mm_storeu_si128((__m128i *)(dst1 + x * 2 + 24), v_dst3);
- }
- }
+ opt_SSE4_1::convertMaps_nninterpolate32f1c16s_SSE41(src1f, src2f, dst1, size.width);
+ else
#endif
for( ; x < size.width; x++ )
{
@@ -5212,52 +5185,10 @@ void cv::convertMaps( InputArray _map1, InputArray _map2,
vandq_s32(v_ix1, v_mask)));
vst1q_u16(dst2 + x, vcombine_u16(v_dst0, v_dst1));
}
- #elif CV_SSE4_1
+ #elif CV_TRY_SSE4_1
if (useSSE4_1)
- {
- __m128 v_its = _mm_set1_ps(INTER_TAB_SIZE);
- __m128i v_its1 = _mm_set1_epi32(INTER_TAB_SIZE-1);
-
- for( ; x <= size.width - 16; x += 16 )
- {
- __m128i v_ix0 = _mm_cvtps_epi32(_mm_mul_ps(_mm_loadu_ps(src1f + x), v_its));
- __m128i v_ix1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_loadu_ps(src1f + x + 4), v_its));
- __m128i v_iy0 = _mm_cvtps_epi32(_mm_mul_ps(_mm_loadu_ps(src2f + x), v_its));
- __m128i v_iy1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_loadu_ps(src2f + x + 4), v_its));
-
- __m128i v_dst10 = _mm_packs_epi32(_mm_srai_epi32(v_ix0, INTER_BITS),
- _mm_srai_epi32(v_ix1, INTER_BITS));
- __m128i v_dst12 = _mm_packs_epi32(_mm_srai_epi32(v_iy0, INTER_BITS),
- _mm_srai_epi32(v_iy1, INTER_BITS));
- __m128i v_dst20 = _mm_add_epi32(_mm_slli_epi32(_mm_and_si128(v_iy0, v_its1), INTER_BITS),
- _mm_and_si128(v_ix0, v_its1));
- __m128i v_dst21 = _mm_add_epi32(_mm_slli_epi32(_mm_and_si128(v_iy1, v_its1), INTER_BITS),
- _mm_and_si128(v_ix1, v_its1));
- _mm_storeu_si128((__m128i *)(dst2 + x), _mm_packus_epi32(v_dst20, v_dst21));
-
- v_ix0 = _mm_cvtps_epi32(_mm_mul_ps(_mm_loadu_ps(src1f + x + 8), v_its));
- v_ix1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_loadu_ps(src1f + x + 12), v_its));
- v_iy0 = _mm_cvtps_epi32(_mm_mul_ps(_mm_loadu_ps(src2f + x + 8), v_its));
- v_iy1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_loadu_ps(src2f + x + 12), v_its));
-
- __m128i v_dst11 = _mm_packs_epi32(_mm_srai_epi32(v_ix0, INTER_BITS),
- _mm_srai_epi32(v_ix1, INTER_BITS));
- __m128i v_dst13 = _mm_packs_epi32(_mm_srai_epi32(v_iy0, INTER_BITS),
- _mm_srai_epi32(v_iy1, INTER_BITS));
- v_dst20 = _mm_add_epi32(_mm_slli_epi32(_mm_and_si128(v_iy0, v_its1), INTER_BITS),
- _mm_and_si128(v_ix0, v_its1));
- v_dst21 = _mm_add_epi32(_mm_slli_epi32(_mm_and_si128(v_iy1, v_its1), INTER_BITS),
- _mm_and_si128(v_ix1, v_its1));
- _mm_storeu_si128((__m128i *)(dst2 + x + 8), _mm_packus_epi32(v_dst20, v_dst21));
-
- _mm_interleave_epi16(v_dst10, v_dst11, v_dst12, v_dst13);
-
- _mm_storeu_si128((__m128i *)(dst1 + x * 2), v_dst10);
- _mm_storeu_si128((__m128i *)(dst1 + x * 2 + 8), v_dst11);
- _mm_storeu_si128((__m128i *)(dst1 + x * 2 + 16), v_dst12);
- _mm_storeu_si128((__m128i *)(dst1 + x * 2 + 24), v_dst13);
- }
- }
+ opt_SSE4_1::convertMaps_32f1c16s_SSE41(src1f, src2f, dst1, dst2, size.width);
+ else
#endif
for( ; x < size.width; x++ )
{
@@ -5318,30 +5249,10 @@ void cv::convertMaps( InputArray _map1, InputArray _map2,
vandq_s32(v_ix1, v_mask)));
vst1q_u16(dst2 + x, vcombine_u16(v_dst0, v_dst1));
}
- #elif CV_SSE4_1
+ #elif CV_TRY_SSE4_1
if (useSSE4_1)
- {
- __m128 v_its = _mm_set1_ps(INTER_TAB_SIZE);
- __m128i v_its1 = _mm_set1_epi32(INTER_TAB_SIZE-1);
- __m128i v_y_mask = _mm_set1_epi32((INTER_TAB_SIZE-1) << 16);
-
- for( ; x <= size.width - 4; x += 4 )
- {
- __m128i v_src0 = _mm_cvtps_epi32(_mm_mul_ps(_mm_loadu_ps(src1f + x * 2), v_its));
- __m128i v_src1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_loadu_ps(src1f + x * 2 + 4), v_its));
-
- __m128i v_dst1 = _mm_packs_epi32(_mm_srai_epi32(v_src0, INTER_BITS),
- _mm_srai_epi32(v_src1, INTER_BITS));
- _mm_storeu_si128((__m128i *)(dst1 + x * 2), v_dst1);
-
- // x0 y0 x1 y1 . . .
- v_src0 = _mm_packs_epi32(_mm_and_si128(v_src0, v_its1),
- _mm_and_si128(v_src1, v_its1));
- __m128i v_dst2 = _mm_or_si128(_mm_srli_epi32(_mm_and_si128(v_src0, v_y_mask), 16 - INTER_BITS), // y0 0 y1 0 . . .
- _mm_and_si128(v_src0, v_its1)); // 0 x0 0 x1 . . .
- _mm_storel_epi64((__m128i *)(dst2 + x), _mm_packus_epi32(v_dst2, v_dst2));
- }
- }
+ opt_SSE4_1::convertMaps_32f2c16s_SSE41(src1f, dst1, dst2, size.width);
+ else
#endif
for( ; x < size.width; x++ )
{
@@ -5523,11 +5434,14 @@ public:
const int AB_BITS = MAX(10, (int)INTER_BITS);
const int AB_SCALE = 1 << AB_BITS;
int round_delta = interpolation == INTER_NEAREST ? AB_SCALE/2 : AB_SCALE/INTER_TAB_SIZE/2, x, y, x1, y1;
+ #if CV_TRY_AVX2
+ bool useAVX2 = CV_CPU_HAS_SUPPORT_AVX2;
+ #endif
#if CV_SSE2
bool useSSE2 = checkHardwareSupport(CV_CPU_SSE2);
#endif
- #if CV_SSE4_1
- bool useSSE4_1 = checkHardwareSupport(CV_CPU_SSE4_1);
+ #if CV_TRY_SSE4_1
+ bool useSSE4_1 = CV_CPU_HAS_SUPPORT_SSE4_1;
#endif
int bh0 = std::min(BLOCK_SZ/2, dst.rows);
@@ -5565,31 +5479,10 @@ public:
vst2q_s16(xy + (x1 << 1), v_dst);
}
- #elif CV_SSE4_1
+ #elif CV_TRY_SSE4_1
if (useSSE4_1)
- {
- __m128i v_X0 = _mm_set1_epi32(X0);
- __m128i v_Y0 = _mm_set1_epi32(Y0);
- for ( ; x1 <= bw - 16; x1 += 16)
- {
- __m128i v_x0 = _mm_packs_epi32(_mm_srai_epi32(_mm_add_epi32(v_X0, _mm_loadu_si128((__m128i const *)(adelta + x + x1))), AB_BITS),
- _mm_srai_epi32(_mm_add_epi32(v_X0, _mm_loadu_si128((__m128i const *)(adelta + x + x1 + 4))), AB_BITS));
- __m128i v_x1 = _mm_packs_epi32(_mm_srai_epi32(_mm_add_epi32(v_X0, _mm_loadu_si128((__m128i const *)(adelta + x + x1 + 8))), AB_BITS),
- _mm_srai_epi32(_mm_add_epi32(v_X0, _mm_loadu_si128((__m128i const *)(adelta + x + x1 + 12))), AB_BITS));
-
- __m128i v_y0 = _mm_packs_epi32(_mm_srai_epi32(_mm_add_epi32(v_Y0, _mm_loadu_si128((__m128i const *)(bdelta + x + x1))), AB_BITS),
- _mm_srai_epi32(_mm_add_epi32(v_Y0, _mm_loadu_si128((__m128i const *)(bdelta + x + x1 + 4))), AB_BITS));
- __m128i v_y1 = _mm_packs_epi32(_mm_srai_epi32(_mm_add_epi32(v_Y0, _mm_loadu_si128((__m128i const *)(bdelta + x + x1 + 8))), AB_BITS),
- _mm_srai_epi32(_mm_add_epi32(v_Y0, _mm_loadu_si128((__m128i const *)(bdelta + x + x1 + 12))), AB_BITS));
-
- _mm_interleave_epi16(v_x0, v_x1, v_y0, v_y1);
-
- _mm_storeu_si128((__m128i *)(xy + x1 * 2), v_x0);
- _mm_storeu_si128((__m128i *)(xy + x1 * 2 + 8), v_x1);
- _mm_storeu_si128((__m128i *)(xy + x1 * 2 + 16), v_y0);
- _mm_storeu_si128((__m128i *)(xy + x1 * 2 + 24), v_y1);
- }
- }
+ opt_SSE4_1::WarpAffineInvoker_Blockline_SSE41(adelta + x, bdelta + x, xy, X0, Y0, bw);
+ else
#endif
for( ; x1 < bw; x1++ )
{
@@ -5603,6 +5496,10 @@ public:
{
short* alpha = A + y1*bw;
x1 = 0;
+ #if CV_TRY_AVX2
+ if ( useAVX2 )
+ x1 = opt_AVX2::warpAffineBlockline(adelta + x, bdelta + x, xy, alpha, X0, Y0, bw);
+ #endif
#if CV_SSE2
if( useSSE2 )
{
@@ -5691,7 +5588,9 @@ private:
};
-#if defined (HAVE_IPP) && IPP_VERSION_X100 >= 810 && IPP_DISABLE_BLOCK
+#if defined (HAVE_IPP) && IPP_VERSION_X100 >= 810 && !IPP_DISABLE_WARPAFFINE
+typedef IppStatus (CV_STDCALL* ippiWarpAffineBackFunc)(const void*, IppiSize, int, IppiRect, void *, int, IppiRect, double [2][3], int);
+
class IPPWarpAffineInvoker :
public ParallelLoopBody
{
@@ -5722,7 +5621,7 @@ public:
}
// Aug 2013: problem in IPP 7.1, 8.0 : sometimes function return ippStsCoeffErr
- IppStatus status = CV_INSTRUMENT_FUN_PTR_CALL_IPP(func,( src.ptr(), srcsize, (int)src.step[0], srcroi, dst.ptr(),
+ IppStatus status = CV_INSTRUMENT_FUN_IPP(func,( src.ptr(), srcsize, (int)src.step[0], srcroi, dst.ptr(),
(int)dst.step[0], dstroi, coeffs, mode ));
if( status < 0)
*ok = false;
@@ -5789,7 +5688,7 @@ static bool ocl_warpTransform_cols4(InputArray _src, OutputArray _dst, InputArra
_dst.create( dsize.area() == 0 ? src.size() : dsize, src.type() );
UMat dst = _dst.getUMat();
- float M[9];
+ float M[9] = {0};
int matRows = (op_type == OCL_OP_AFFINE ? 2 : 3);
Mat matM(matRows, 3, CV_32F, M), M1 = _M0.getMat();
CV_Assert( (M1.type() == CV_32F || M1.type() == CV_64F) && M1.rows == matRows && M1.cols == 3 );
@@ -5814,7 +5713,7 @@ static bool ocl_warpTransform_cols4(InputArray _src, OutputArray _dst, InputArra
matM.convertTo(M0, CV_32F);
k.args(ocl::KernelArg::ReadOnly(src), ocl::KernelArg::WriteOnly(dst), ocl::KernelArg::PtrReadOnly(M0),
- ocl::KernelArg(0, 0, 0, 0, borderBuf, CV_ELEM_SIZE(sctype)));
+ ocl::KernelArg(ocl::KernelArg::CONSTANT, 0, 0, 0, borderBuf, CV_ELEM_SIZE(sctype)));
size_t globalThreads[2];
globalThreads[0] = (size_t)(dst.cols / 4);
@@ -5887,7 +5786,7 @@ static bool ocl_warpTransform(InputArray _src, OutputArray _dst, InputArray _M0,
_dst.create( dsize.area() == 0 ? src.size() : dsize, src.type() );
UMat dst = _dst.getUMat();
- double M[9];
+ double M[9] = {0};
int matRows = (op_type == OCL_OP_AFFINE ? 2 : 3);
Mat matM(matRows, 3, CV_64F, M), M1 = _M0.getMat();
CV_Assert( (M1.type() == CV_32F || M1.type() == CV_64F) &&
@@ -5913,7 +5812,7 @@ static bool ocl_warpTransform(InputArray _src, OutputArray _dst, InputArray _M0,
matM.convertTo(M0, doubleSupport ? CV_64F : CV_32F);
k.args(ocl::KernelArg::ReadOnly(src), ocl::KernelArg::WriteOnly(dst), ocl::KernelArg::PtrReadOnly(M0),
- ocl::KernelArg(0, 0, 0, 0, borderBuf, CV_ELEM_SIZE(sctype)));
+ ocl::KernelArg(ocl::KernelArg::CONSTANT, 0, 0, 0, borderBuf, CV_ELEM_SIZE(sctype)));
size_t globalThreads[2] = { (size_t)dst.cols, ((size_t)dst.rows + rowsPerWI - 1) / rowsPerWI };
return k.run(2, globalThreads, NULL, false);
@@ -5962,6 +5861,10 @@ void cv::warpAffine( InputArray _src, OutputArray _dst,
{
CV_INSTRUMENT_REGION()
+ int interpolation = flags & INTER_MAX;
+ CV_Assert( _src.channels() <= 4 || (interpolation != INTER_LANCZOS4 &&
+ interpolation != INTER_CUBIC) );
+
CV_OCL_RUN(_src.dims() <= 2 && _dst.isUMat() &&
_src.cols() <= SHRT_MAX && _src.rows() <= SHRT_MAX,
ocl_warpTransform_cols4(_src, _dst, _M0, dsize, flags, borderType,
@@ -5978,9 +5881,8 @@ void cv::warpAffine( InputArray _src, OutputArray _dst,
if( dst.data == src.data )
src = src.clone();
- double M[6];
+ double M[6] = {0};
Mat matM(2, 3, CV_64F, M);
- int interpolation = flags & INTER_MAX;
if( interpolation == INTER_AREA )
interpolation = INTER_LINEAR;
@@ -5999,7 +5901,7 @@ void cv::warpAffine( InputArray _src, OutputArray _dst,
M[2] = b1; M[5] = b2;
}
-#if defined (HAVE_IPP) && IPP_VERSION_X100 >= 810 && IPP_DISABLE_BLOCK
+#if defined (HAVE_IPP) && IPP_VERSION_X100 >= 810 && !IPP_DISABLE_WARPAFFINE
CV_IPP_CHECK()
{
int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
@@ -6092,18 +5994,10 @@ public:
int bw0 = std::min(BLOCK_SZ*BLOCK_SZ/bh0, width);
bh0 = std::min(BLOCK_SZ*BLOCK_SZ/bw0, height);
- #if CV_SSE4_1
- bool haveSSE4_1 = checkHardwareSupport(CV_CPU_SSE4_1);
- __m128d v_M0 = _mm_set1_pd(M[0]);
- __m128d v_M3 = _mm_set1_pd(M[3]);
- __m128d v_M6 = _mm_set1_pd(M[6]);
- __m128d v_intmax = _mm_set1_pd((double)INT_MAX);
- __m128d v_intmin = _mm_set1_pd((double)INT_MIN);
- __m128d v_2 = _mm_set1_pd(2),
- v_zero = _mm_setzero_pd(),
- v_1 = _mm_set1_pd(1),
- v_its = _mm_set1_pd(INTER_TAB_SIZE);
- __m128i v_itsi1 = _mm_set1_epi32(INTER_TAB_SIZE - 1);
+ #if CV_TRY_SSE4_1
+ Ptr<opt_SSE4_1::WarpPerspectiveLine_SSE4> pwarp_impl_sse4;
+ if(CV_CPU_HAS_SUPPORT_SSE4_1)
+ pwarp_impl_sse4 = opt_SSE4_1::WarpPerspectiveLine_SSE4::getImpl(M);
#endif
for( y = range.start; y < range.end; y += bh0 )
@@ -6127,116 +6021,11 @@ public:
{
x1 = 0;
- #if CV_SSE4_1
- if (haveSSE4_1)
- {
- __m128d v_X0d = _mm_set1_pd(X0);
- __m128d v_Y0d = _mm_set1_pd(Y0);
- __m128d v_W0 = _mm_set1_pd(W0);
- __m128d v_x1 = _mm_set_pd(1, 0);
-
- for( ; x1 <= bw - 16; x1 += 16 )
- {
- // 0-3
- __m128i v_X0, v_Y0;
- {
- __m128d v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
- v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_1, v_W));
- __m128d v_fX0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
- __m128d v_fY0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
- v_x1 = _mm_add_pd(v_x1, v_2);
-
- v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
- v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_1, v_W));
- __m128d v_fX1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
- __m128d v_fY1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
- v_x1 = _mm_add_pd(v_x1, v_2);
-
- v_X0 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fX0)),
- _mm_castsi128_ps(_mm_cvtpd_epi32(v_fX1))));
- v_Y0 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fY0)),
- _mm_castsi128_ps(_mm_cvtpd_epi32(v_fY1))));
- }
-
- // 4-8
- __m128i v_X1, v_Y1;
- {
- __m128d v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
- v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_1, v_W));
- __m128d v_fX0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
- __m128d v_fY0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
- v_x1 = _mm_add_pd(v_x1, v_2);
-
- v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
- v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_1, v_W));
- __m128d v_fX1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
- __m128d v_fY1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
- v_x1 = _mm_add_pd(v_x1, v_2);
-
- v_X1 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fX0)),
- _mm_castsi128_ps(_mm_cvtpd_epi32(v_fX1))));
- v_Y1 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fY0)),
- _mm_castsi128_ps(_mm_cvtpd_epi32(v_fY1))));
- }
-
- // 8-11
- __m128i v_X2, v_Y2;
- {
- __m128d v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
- v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_1, v_W));
- __m128d v_fX0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
- __m128d v_fY0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
- v_x1 = _mm_add_pd(v_x1, v_2);
-
- v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
- v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_1, v_W));
- __m128d v_fX1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
- __m128d v_fY1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
- v_x1 = _mm_add_pd(v_x1, v_2);
-
- v_X2 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fX0)),
- _mm_castsi128_ps(_mm_cvtpd_epi32(v_fX1))));
- v_Y2 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fY0)),
- _mm_castsi128_ps(_mm_cvtpd_epi32(v_fY1))));
- }
-
- // 12-15
- __m128i v_X3, v_Y3;
- {
- __m128d v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
- v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_1, v_W));
- __m128d v_fX0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
- __m128d v_fY0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
- v_x1 = _mm_add_pd(v_x1, v_2);
-
- v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
- v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_1, v_W));
- __m128d v_fX1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
- __m128d v_fY1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
- v_x1 = _mm_add_pd(v_x1, v_2);
-
- v_X3 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fX0)),
- _mm_castsi128_ps(_mm_cvtpd_epi32(v_fX1))));
- v_Y3 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fY0)),
- _mm_castsi128_ps(_mm_cvtpd_epi32(v_fY1))));
- }
-
- // convert to 16s
- v_X0 = _mm_packs_epi32(v_X0, v_X1);
- v_X1 = _mm_packs_epi32(v_X2, v_X3);
- v_Y0 = _mm_packs_epi32(v_Y0, v_Y1);
- v_Y1 = _mm_packs_epi32(v_Y2, v_Y3);
-
- _mm_interleave_epi16(v_X0, v_X1, v_Y0, v_Y1);
-
- _mm_storeu_si128((__m128i *)(xy + x1 * 2), v_X0);
- _mm_storeu_si128((__m128i *)(xy + x1 * 2 + 8), v_X1);
- _mm_storeu_si128((__m128i *)(xy + x1 * 2 + 16), v_Y0);
- _mm_storeu_si128((__m128i *)(xy + x1 * 2 + 24), v_Y1);
- }
- }
+ #if CV_TRY_SSE4_1
+ if (pwarp_impl_sse4)
+ pwarp_impl_sse4->processNN(M, xy, X0, Y0, W0, bw);
+ else
#endif
-
for( ; x1 < bw; x1++ )
{
double W = W0 + M[6]*x1;
@@ -6255,129 +6044,11 @@ public:
short* alpha = A + y1*bw;
x1 = 0;
- #if CV_SSE4_1
- if (haveSSE4_1)
- {
- __m128d v_X0d = _mm_set1_pd(X0);
- __m128d v_Y0d = _mm_set1_pd(Y0);
- __m128d v_W0 = _mm_set1_pd(W0);
- __m128d v_x1 = _mm_set_pd(1, 0);
-
- for( ; x1 <= bw - 16; x1 += 16 )
- {
- // 0-3
- __m128i v_X0, v_Y0;
- {
- __m128d v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
- v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_its, v_W));
- __m128d v_fX0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
- __m128d v_fY0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
- v_x1 = _mm_add_pd(v_x1, v_2);
-
- v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
- v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_its, v_W));
- __m128d v_fX1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
- __m128d v_fY1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
- v_x1 = _mm_add_pd(v_x1, v_2);
-
- v_X0 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fX0)),
- _mm_castsi128_ps(_mm_cvtpd_epi32(v_fX1))));
- v_Y0 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fY0)),
- _mm_castsi128_ps(_mm_cvtpd_epi32(v_fY1))));
- }
-
- // 4-8
- __m128i v_X1, v_Y1;
- {
- __m128d v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
- v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_its, v_W));
- __m128d v_fX0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
- __m128d v_fY0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
- v_x1 = _mm_add_pd(v_x1, v_2);
-
- v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
- v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_its, v_W));
- __m128d v_fX1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
- __m128d v_fY1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
- v_x1 = _mm_add_pd(v_x1, v_2);
-
- v_X1 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fX0)),
- _mm_castsi128_ps(_mm_cvtpd_epi32(v_fX1))));
- v_Y1 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fY0)),
- _mm_castsi128_ps(_mm_cvtpd_epi32(v_fY1))));
- }
-
- // 8-11
- __m128i v_X2, v_Y2;
- {
- __m128d v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
- v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_its, v_W));
- __m128d v_fX0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
- __m128d v_fY0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
- v_x1 = _mm_add_pd(v_x1, v_2);
-
- v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
- v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_its, v_W));
- __m128d v_fX1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
- __m128d v_fY1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
- v_x1 = _mm_add_pd(v_x1, v_2);
-
- v_X2 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fX0)),
- _mm_castsi128_ps(_mm_cvtpd_epi32(v_fX1))));
- v_Y2 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fY0)),
- _mm_castsi128_ps(_mm_cvtpd_epi32(v_fY1))));
- }
-
- // 12-15
- __m128i v_X3, v_Y3;
- {
- __m128d v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
- v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_its, v_W));
- __m128d v_fX0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
- __m128d v_fY0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
- v_x1 = _mm_add_pd(v_x1, v_2);
-
- v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
- v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_its, v_W));
- __m128d v_fX1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
- __m128d v_fY1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
- v_x1 = _mm_add_pd(v_x1, v_2);
-
- v_X3 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fX0)),
- _mm_castsi128_ps(_mm_cvtpd_epi32(v_fX1))));
- v_Y3 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fY0)),
- _mm_castsi128_ps(_mm_cvtpd_epi32(v_fY1))));
- }
-
- // store alpha
- __m128i v_alpha0 = _mm_add_epi32(_mm_slli_epi32(_mm_and_si128(v_Y0, v_itsi1), INTER_BITS),
- _mm_and_si128(v_X0, v_itsi1));
- __m128i v_alpha1 = _mm_add_epi32(_mm_slli_epi32(_mm_and_si128(v_Y1, v_itsi1), INTER_BITS),
- _mm_and_si128(v_X1, v_itsi1));
- _mm_storeu_si128((__m128i *)(alpha + x1), _mm_packs_epi32(v_alpha0, v_alpha1));
-
- v_alpha0 = _mm_add_epi32(_mm_slli_epi32(_mm_and_si128(v_Y2, v_itsi1), INTER_BITS),
- _mm_and_si128(v_X2, v_itsi1));
- v_alpha1 = _mm_add_epi32(_mm_slli_epi32(_mm_and_si128(v_Y3, v_itsi1), INTER_BITS),
- _mm_and_si128(v_X3, v_itsi1));
- _mm_storeu_si128((__m128i *)(alpha + x1 + 8), _mm_packs_epi32(v_alpha0, v_alpha1));
-
- // convert to 16s
- v_X0 = _mm_packs_epi32(_mm_srai_epi32(v_X0, INTER_BITS), _mm_srai_epi32(v_X1, INTER_BITS));
- v_X1 = _mm_packs_epi32(_mm_srai_epi32(v_X2, INTER_BITS), _mm_srai_epi32(v_X3, INTER_BITS));
- v_Y0 = _mm_packs_epi32(_mm_srai_epi32(v_Y0, INTER_BITS), _mm_srai_epi32(v_Y1, INTER_BITS));
- v_Y1 = _mm_packs_epi32(_mm_srai_epi32(v_Y2, INTER_BITS), _mm_srai_epi32(v_Y3, INTER_BITS));
-
- _mm_interleave_epi16(v_X0, v_X1, v_Y0, v_Y1);
-
- _mm_storeu_si128((__m128i *)(xy + x1 * 2), v_X0);
- _mm_storeu_si128((__m128i *)(xy + x1 * 2 + 8), v_X1);
- _mm_storeu_si128((__m128i *)(xy + x1 * 2 + 16), v_Y0);
- _mm_storeu_si128((__m128i *)(xy + x1 * 2 + 24), v_Y1);
- }
- }
+ #if CV_TRY_SSE4_1
+ if (pwarp_impl_sse4)
+ pwarp_impl_sse4->process(M, xy, alpha, X0, Y0, W0, bw);
+ else
#endif
-
for( ; x1 < bw; x1++ )
{
double W = W0 + M[6]*x1;
@@ -6414,7 +6085,9 @@ private:
Scalar borderValue;
};
-#if defined (HAVE_IPP) && IPP_VERSION_X100 >= 810 && IPP_DISABLE_BLOCK
+#if defined (HAVE_IPP) && IPP_VERSION_X100 >= 810 && !IPP_DISABLE_WARPPERSPECTIVE
+typedef IppStatus (CV_STDCALL* ippiWarpPerspectiveFunc)(const void*, IppiSize, int, IppiRect, void *, int, IppiRect, double [3][3], int);
+
class IPPWarpPerspectiveInvoker :
public ParallelLoopBody
{
@@ -6445,7 +6118,7 @@ public:
}
}
- IppStatus status = CV_INSTRUMENT_FUN_PTR_CALL_IPP(func,(src.ptr(), srcsize, (int)src.step[0], srcroi, dst.ptr(), (int)dst.step[0], dstroi, coeffs, mode));
+ IppStatus status = CV_INSTRUMENT_FUN_IPP(func,(src.ptr(), srcsize, (int)src.step[0], srcroi, dst.ptr(), (int)dst.step[0], dstroi, coeffs, mode));
if (status != ippStsNoErr)
*ok = false;
else
@@ -6518,7 +6191,7 @@ void cv::warpPerspective( InputArray _src, OutputArray _dst, InputArray _M0,
CV_Assert( (M0.type() == CV_32F || M0.type() == CV_64F) && M0.rows == 3 && M0.cols == 3 );
M0.convertTo(matM, matM.type());
-#if defined (HAVE_IPP) && IPP_VERSION_X100 >= 810 && IPP_DISABLE_BLOCK
+#if defined (HAVE_IPP) && IPP_VERSION_X100 >= 810 && !IPP_DISABLE_WARPPERSPECTIVE
CV_IPP_CHECK()
{
int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
diff --git a/modules/imgproc/src/imgwarp.hpp b/modules/imgproc/src/imgwarp.hpp
new file mode 100644
index 0000000..ed1146d
--- /dev/null
+++ b/modules/imgproc/src/imgwarp.hpp
@@ -0,0 +1,89 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
+// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
+// Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+/* ////////////////////////////////////////////////////////////////////
+//
+// Geometrical transforms on images and matrices: rotation, zoom etc.
+//
+// */
+
+#ifndef OPENCV_IMGPROC_IMGWARP_HPP
+#define OPENCV_IMGPROC_IMGWARP_HPP
+#include "precomp.hpp"
+
+namespace cv
+{
+namespace opt_AVX2
+{
+#if CV_TRY_AVX2
+void resizeNN2_AVX2(const Range&, const Mat&, Mat&, int*, int, double);
+void resizeNN4_AVX2(const Range&, const Mat&, Mat&, int*, int, double);
+int warpAffineBlockline(int *adelta, int *bdelta, short* xy, short* alpha, int X0, int Y0, int bw);
+#endif
+}
+
+namespace opt_SSE4_1
+{
+#if CV_TRY_SSE4_1
+void resizeNN2_SSE4_1(const Range&, const Mat&, Mat&, int*, int, double);
+void resizeNN4_SSE4_1(const Range&, const Mat&, Mat&, int*, int, double);
+
+int VResizeLanczos4Vec_32f16u_SSE41(const uchar** _src, uchar* _dst, const uchar* _beta, int width);
+void convertMaps_nninterpolate32f1c16s_SSE41(const float* src1f, const float* src2f, short* dst1, int width);
+void convertMaps_32f1c16s_SSE41(const float* src1f, const float* src2f, short* dst1, ushort* dst2, int width);
+void convertMaps_32f2c16s_SSE41(const float* src1f, short* dst1, ushort* dst2, int width);
+void WarpAffineInvoker_Blockline_SSE41(int *adelta, int *bdelta, short* xy, int X0, int Y0, int bw);
+
+class WarpPerspectiveLine_SSE4
+{
+public:
+ static Ptr<WarpPerspectiveLine_SSE4> getImpl(const double *M);
+ virtual void processNN(const double *M, short* xy, double X0, double Y0, double W0, int bw) = 0;
+ virtual void process(const double *M, short* xy, short* alpha, double X0, double Y0, double W0, int bw) = 0;
+ virtual ~WarpPerspectiveLine_SSE4() {};
+};
+#endif
+}
+}
+#endif
+/* End of file. */
diff --git a/modules/imgproc/src/imgwarp.sse4_1.cpp b/modules/imgproc/src/imgwarp.sse4_1.cpp
new file mode 100644
index 0000000..49954b1
--- /dev/null
+++ b/modules/imgproc/src/imgwarp.sse4_1.cpp
@@ -0,0 +1,678 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
+// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
+// Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+/* ////////////////////////////////////////////////////////////////////
+//
+// Geometrical transforms on images and matrices: rotation, zoom etc.
+//
+// */
+
+#include "precomp.hpp"
+#include "imgwarp.hpp"
+
+namespace cv
+{
+namespace opt_SSE4_1
+{
+
+class resizeNNInvokerSSE2 :
+ public ParallelLoopBody
+{
+public:
+ resizeNNInvokerSSE2(const Mat& _src, Mat &_dst, int *_x_ofs, int _pix_size4, double _ify) :
+ ParallelLoopBody(), src(_src), dst(_dst), x_ofs(_x_ofs), pix_size4(_pix_size4),
+ ify(_ify)
+ {
+ }
+
+#if defined(__INTEL_COMPILER)
+#pragma optimization_parameter target_arch=SSE4.2
+#endif
+ virtual void operator() (const Range& range) const
+ {
+ Size ssize = src.size(), dsize = dst.size();
+ int y, x;
+ int width = dsize.width;
+ int sseWidth = width - (width & 0x7);
+ for(y = range.start; y < range.end; y++)
+ {
+ uchar* D = dst.data + dst.step*y;
+ uchar* Dstart = D;
+ int sy = std::min(cvFloor(y*ify), ssize.height-1);
+ const uchar* S = src.data + sy*src.step;
+ __m128i CV_DECL_ALIGNED(64) pixels = _mm_set1_epi16(0);
+ for(x = 0; x < sseWidth; x += 8)
+ {
+ ushort imm = *(ushort*)(S + x_ofs[x + 0]);
+ pixels = _mm_insert_epi16(pixels, imm, 0);
+ imm = *(ushort*)(S + x_ofs[x + 1]);
+ pixels = _mm_insert_epi16(pixels, imm, 1);
+ imm = *(ushort*)(S + x_ofs[x + 2]);
+ pixels = _mm_insert_epi16(pixels, imm, 2);
+ imm = *(ushort*)(S + x_ofs[x + 3]);
+ pixels = _mm_insert_epi16(pixels, imm, 3);
+ imm = *(ushort*)(S + x_ofs[x + 4]);
+ pixels = _mm_insert_epi16(pixels, imm, 4);
+ imm = *(ushort*)(S + x_ofs[x + 5]);
+ pixels = _mm_insert_epi16(pixels, imm, 5);
+ imm = *(ushort*)(S + x_ofs[x + 6]);
+ pixels = _mm_insert_epi16(pixels, imm, 6);
+ imm = *(ushort*)(S + x_ofs[x + 7]);
+ pixels = _mm_insert_epi16(pixels, imm, 7);
+ _mm_storeu_si128((__m128i*)D, pixels);
+ D += 16;
+ }
+ for(; x < width; x++)
+ {
+ *(ushort*)(Dstart + x*2) = *(ushort*)(S + x_ofs[x]);
+ }
+ }
+ }
+
+private:
+ const Mat src;
+ Mat dst;
+ int* x_ofs, pix_size4;
+ double ify;
+
+ resizeNNInvokerSSE2(const resizeNNInvokerSSE2&);
+ resizeNNInvokerSSE2& operator=(const resizeNNInvokerSSE2&);
+};
+
+class resizeNNInvokerSSE4 :
+ public ParallelLoopBody
+{
+public:
+ resizeNNInvokerSSE4(const Mat& _src, Mat &_dst, int *_x_ofs, int _pix_size4, double _ify) :
+ ParallelLoopBody(), src(_src), dst(_dst), x_ofs(_x_ofs), pix_size4(_pix_size4),
+ ify(_ify)
+ {
+ }
+#if defined(__INTEL_COMPILER)
+#pragma optimization_parameter target_arch=SSE4.2
+#endif
+ virtual void operator() (const Range& range) const
+ {
+ Size ssize = src.size(), dsize = dst.size();
+ int y, x;
+ int width = dsize.width;
+ int sseWidth = width - (width & 0x3);
+ for(y = range.start; y < range.end; y++)
+ {
+ uchar* D = dst.data + dst.step*y;
+ uchar* Dstart = D;
+ int sy = std::min(cvFloor(y*ify), ssize.height-1);
+ const uchar* S = src.data + sy*src.step;
+ __m128i CV_DECL_ALIGNED(64) pixels = _mm_set1_epi16(0);
+ for(x = 0; x < sseWidth; x += 4)
+ {
+ int imm = *(int*)(S + x_ofs[x + 0]);
+ pixels = _mm_insert_epi32(pixels, imm, 0);
+ imm = *(int*)(S + x_ofs[x + 1]);
+ pixels = _mm_insert_epi32(pixels, imm, 1);
+ imm = *(int*)(S + x_ofs[x + 2]);
+ pixels = _mm_insert_epi32(pixels, imm, 2);
+ imm = *(int*)(S + x_ofs[x + 3]);
+ pixels = _mm_insert_epi32(pixels, imm, 3);
+ _mm_storeu_si128((__m128i*)D, pixels);
+ D += 16;
+ }
+ for(; x < width; x++)
+ {
+ *(int*)(Dstart + x*4) = *(int*)(S + x_ofs[x]);
+ }
+ }
+ }
+
+private:
+ const Mat src;
+ Mat dst;
+ int* x_ofs, pix_size4;
+ double ify;
+
+ resizeNNInvokerSSE4(const resizeNNInvokerSSE4&);
+ resizeNNInvokerSSE4& operator=(const resizeNNInvokerSSE4&);
+};
+
+void resizeNN2_SSE4_1(const Range& range, const Mat& src, Mat &dst, int *x_ofs, int pix_size4, double ify)
+{
+ resizeNNInvokerSSE2 invoker(src, dst, x_ofs, pix_size4, ify);
+ parallel_for_(range, invoker, dst.total() / (double)(1 << 16));
+}
+
+void resizeNN4_SSE4_1(const Range& range, const Mat& src, Mat &dst, int *x_ofs, int pix_size4, double ify)
+{
+ resizeNNInvokerSSE4 invoker(src, dst, x_ofs, pix_size4, ify);
+ parallel_for_(range, invoker, dst.total() / (double)(1 << 16));
+}
+
+int VResizeLanczos4Vec_32f16u_SSE41(const uchar** _src, uchar* _dst, const uchar* _beta, int width)
+{
+ const float** src = (const float**)_src;
+ const float* beta = (const float*)_beta;
+ const float *S0 = src[0], *S1 = src[1], *S2 = src[2], *S3 = src[3],
+ *S4 = src[4], *S5 = src[5], *S6 = src[6], *S7 = src[7];
+ short * dst = (short*)_dst;
+ int x = 0;
+ __m128 v_b0 = _mm_set1_ps(beta[0]), v_b1 = _mm_set1_ps(beta[1]),
+ v_b2 = _mm_set1_ps(beta[2]), v_b3 = _mm_set1_ps(beta[3]),
+ v_b4 = _mm_set1_ps(beta[4]), v_b5 = _mm_set1_ps(beta[5]),
+ v_b6 = _mm_set1_ps(beta[6]), v_b7 = _mm_set1_ps(beta[7]);
+
+ for (; x <= width - 8; x += 8)
+ {
+ __m128 v_dst0 = _mm_mul_ps(v_b0, _mm_loadu_ps(S0 + x));
+ v_dst0 = _mm_add_ps(v_dst0, _mm_mul_ps(v_b1, _mm_loadu_ps(S1 + x)));
+ v_dst0 = _mm_add_ps(v_dst0, _mm_mul_ps(v_b2, _mm_loadu_ps(S2 + x)));
+ v_dst0 = _mm_add_ps(v_dst0, _mm_mul_ps(v_b3, _mm_loadu_ps(S3 + x)));
+ v_dst0 = _mm_add_ps(v_dst0, _mm_mul_ps(v_b4, _mm_loadu_ps(S4 + x)));
+ v_dst0 = _mm_add_ps(v_dst0, _mm_mul_ps(v_b5, _mm_loadu_ps(S5 + x)));
+ v_dst0 = _mm_add_ps(v_dst0, _mm_mul_ps(v_b6, _mm_loadu_ps(S6 + x)));
+ v_dst0 = _mm_add_ps(v_dst0, _mm_mul_ps(v_b7, _mm_loadu_ps(S7 + x)));
+
+ __m128 v_dst1 = _mm_mul_ps(v_b0, _mm_loadu_ps(S0 + x + 4));
+ v_dst1 = _mm_add_ps(v_dst1, _mm_mul_ps(v_b1, _mm_loadu_ps(S1 + x + 4)));
+ v_dst1 = _mm_add_ps(v_dst1, _mm_mul_ps(v_b2, _mm_loadu_ps(S2 + x + 4)));
+ v_dst1 = _mm_add_ps(v_dst1, _mm_mul_ps(v_b3, _mm_loadu_ps(S3 + x + 4)));
+ v_dst1 = _mm_add_ps(v_dst1, _mm_mul_ps(v_b4, _mm_loadu_ps(S4 + x + 4)));
+ v_dst1 = _mm_add_ps(v_dst1, _mm_mul_ps(v_b5, _mm_loadu_ps(S5 + x + 4)));
+ v_dst1 = _mm_add_ps(v_dst1, _mm_mul_ps(v_b6, _mm_loadu_ps(S6 + x + 4)));
+ v_dst1 = _mm_add_ps(v_dst1, _mm_mul_ps(v_b7, _mm_loadu_ps(S7 + x + 4)));
+
+ __m128i v_dsti0 = _mm_cvtps_epi32(v_dst0);
+ __m128i v_dsti1 = _mm_cvtps_epi32(v_dst1);
+
+ _mm_storeu_si128((__m128i *)(dst + x), _mm_packus_epi32(v_dsti0, v_dsti1));
+ }
+
+ return x;
+}
+
+void convertMaps_nninterpolate32f1c16s_SSE41(const float* src1f, const float* src2f, short* dst1, int width)
+{
+ int x = 0;
+ for (; x <= width - 16; x += 16)
+ {
+ __m128i v_dst0 = _mm_packs_epi32(_mm_cvtps_epi32(_mm_loadu_ps(src1f + x)),
+ _mm_cvtps_epi32(_mm_loadu_ps(src1f + x + 4)));
+ __m128i v_dst1 = _mm_packs_epi32(_mm_cvtps_epi32(_mm_loadu_ps(src1f + x + 8)),
+ _mm_cvtps_epi32(_mm_loadu_ps(src1f + x + 12)));
+
+ __m128i v_dst2 = _mm_packs_epi32(_mm_cvtps_epi32(_mm_loadu_ps(src2f + x)),
+ _mm_cvtps_epi32(_mm_loadu_ps(src2f + x + 4)));
+ __m128i v_dst3 = _mm_packs_epi32(_mm_cvtps_epi32(_mm_loadu_ps(src2f + x + 8)),
+ _mm_cvtps_epi32(_mm_loadu_ps(src2f + x + 12)));
+
+ _mm_interleave_epi16(v_dst0, v_dst1, v_dst2, v_dst3);
+
+ _mm_storeu_si128((__m128i *)(dst1 + x * 2), v_dst0);
+ _mm_storeu_si128((__m128i *)(dst1 + x * 2 + 8), v_dst1);
+ _mm_storeu_si128((__m128i *)(dst1 + x * 2 + 16), v_dst2);
+ _mm_storeu_si128((__m128i *)(dst1 + x * 2 + 24), v_dst3);
+ }
+
+ for (; x < width; x++)
+ {
+ dst1[x * 2] = saturate_cast<short>(src1f[x]);
+ dst1[x * 2 + 1] = saturate_cast<short>(src2f[x]);
+ }
+}
+
+void convertMaps_32f1c16s_SSE41(const float* src1f, const float* src2f, short* dst1, ushort* dst2, int width)
+{
+ int x = 0;
+ __m128 v_its = _mm_set1_ps(INTER_TAB_SIZE);
+ __m128i v_its1 = _mm_set1_epi32(INTER_TAB_SIZE - 1);
+
+ for (; x <= width - 16; x += 16)
+ {
+ __m128i v_ix0 = _mm_cvtps_epi32(_mm_mul_ps(_mm_loadu_ps(src1f + x), v_its));
+ __m128i v_ix1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_loadu_ps(src1f + x + 4), v_its));
+ __m128i v_iy0 = _mm_cvtps_epi32(_mm_mul_ps(_mm_loadu_ps(src2f + x), v_its));
+ __m128i v_iy1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_loadu_ps(src2f + x + 4), v_its));
+
+ __m128i v_dst10 = _mm_packs_epi32(_mm_srai_epi32(v_ix0, INTER_BITS),
+ _mm_srai_epi32(v_ix1, INTER_BITS));
+ __m128i v_dst12 = _mm_packs_epi32(_mm_srai_epi32(v_iy0, INTER_BITS),
+ _mm_srai_epi32(v_iy1, INTER_BITS));
+ __m128i v_dst20 = _mm_add_epi32(_mm_slli_epi32(_mm_and_si128(v_iy0, v_its1), INTER_BITS),
+ _mm_and_si128(v_ix0, v_its1));
+ __m128i v_dst21 = _mm_add_epi32(_mm_slli_epi32(_mm_and_si128(v_iy1, v_its1), INTER_BITS),
+ _mm_and_si128(v_ix1, v_its1));
+ _mm_storeu_si128((__m128i *)(dst2 + x), _mm_packus_epi32(v_dst20, v_dst21));
+
+ v_ix0 = _mm_cvtps_epi32(_mm_mul_ps(_mm_loadu_ps(src1f + x + 8), v_its));
+ v_ix1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_loadu_ps(src1f + x + 12), v_its));
+ v_iy0 = _mm_cvtps_epi32(_mm_mul_ps(_mm_loadu_ps(src2f + x + 8), v_its));
+ v_iy1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_loadu_ps(src2f + x + 12), v_its));
+
+ __m128i v_dst11 = _mm_packs_epi32(_mm_srai_epi32(v_ix0, INTER_BITS),
+ _mm_srai_epi32(v_ix1, INTER_BITS));
+ __m128i v_dst13 = _mm_packs_epi32(_mm_srai_epi32(v_iy0, INTER_BITS),
+ _mm_srai_epi32(v_iy1, INTER_BITS));
+ v_dst20 = _mm_add_epi32(_mm_slli_epi32(_mm_and_si128(v_iy0, v_its1), INTER_BITS),
+ _mm_and_si128(v_ix0, v_its1));
+ v_dst21 = _mm_add_epi32(_mm_slli_epi32(_mm_and_si128(v_iy1, v_its1), INTER_BITS),
+ _mm_and_si128(v_ix1, v_its1));
+ _mm_storeu_si128((__m128i *)(dst2 + x + 8), _mm_packus_epi32(v_dst20, v_dst21));
+
+ _mm_interleave_epi16(v_dst10, v_dst11, v_dst12, v_dst13);
+
+ _mm_storeu_si128((__m128i *)(dst1 + x * 2), v_dst10);
+ _mm_storeu_si128((__m128i *)(dst1 + x * 2 + 8), v_dst11);
+ _mm_storeu_si128((__m128i *)(dst1 + x * 2 + 16), v_dst12);
+ _mm_storeu_si128((__m128i *)(dst1 + x * 2 + 24), v_dst13);
+ }
+ for (; x < width; x++)
+ {
+ int ix = saturate_cast<int>(src1f[x] * INTER_TAB_SIZE);
+ int iy = saturate_cast<int>(src2f[x] * INTER_TAB_SIZE);
+ dst1[x * 2] = saturate_cast<short>(ix >> INTER_BITS);
+ dst1[x * 2 + 1] = saturate_cast<short>(iy >> INTER_BITS);
+ dst2[x] = (ushort)((iy & (INTER_TAB_SIZE - 1))*INTER_TAB_SIZE + (ix & (INTER_TAB_SIZE - 1)));
+ }
+}
+
+void convertMaps_32f2c16s_SSE41(const float* src1f, short* dst1, ushort* dst2, int width)
+{
+ int x = 0;
+ __m128 v_its = _mm_set1_ps(INTER_TAB_SIZE);
+ __m128i v_its1 = _mm_set1_epi32(INTER_TAB_SIZE - 1);
+ __m128i v_y_mask = _mm_set1_epi32((INTER_TAB_SIZE - 1) << 16);
+
+ for (; x <= width - 4; x += 4)
+ {
+ __m128i v_src0 = _mm_cvtps_epi32(_mm_mul_ps(_mm_loadu_ps(src1f + x * 2), v_its));
+ __m128i v_src1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_loadu_ps(src1f + x * 2 + 4), v_its));
+
+ __m128i v_dst1 = _mm_packs_epi32(_mm_srai_epi32(v_src0, INTER_BITS),
+ _mm_srai_epi32(v_src1, INTER_BITS));
+ _mm_storeu_si128((__m128i *)(dst1 + x * 2), v_dst1);
+
+ // x0 y0 x1 y1 . . .
+ v_src0 = _mm_packs_epi32(_mm_and_si128(v_src0, v_its1),
+ _mm_and_si128(v_src1, v_its1));
+ __m128i v_dst2 = _mm_or_si128(_mm_srli_epi32(_mm_and_si128(v_src0, v_y_mask), 16 - INTER_BITS), // y0 0 y1 0 . . .
+ _mm_and_si128(v_src0, v_its1)); // 0 x0 0 x1 . . .
+ _mm_storel_epi64((__m128i *)(dst2 + x), _mm_packus_epi32(v_dst2, v_dst2));
+ }
+ for (; x < width; x++)
+ {
+ int ix = saturate_cast<int>(src1f[x * 2] * INTER_TAB_SIZE);
+ int iy = saturate_cast<int>(src1f[x * 2 + 1] * INTER_TAB_SIZE);
+ dst1[x * 2] = saturate_cast<short>(ix >> INTER_BITS);
+ dst1[x * 2 + 1] = saturate_cast<short>(iy >> INTER_BITS);
+ dst2[x] = (ushort)((iy & (INTER_TAB_SIZE - 1))*INTER_TAB_SIZE + (ix & (INTER_TAB_SIZE - 1)));
+ }
+}
+
+void WarpAffineInvoker_Blockline_SSE41(int *adelta, int *bdelta, short* xy, int X0, int Y0, int bw)
+{
+ const int AB_BITS = MAX(10, (int)INTER_BITS);
+ int x1 = 0;
+
+ __m128i v_X0 = _mm_set1_epi32(X0);
+ __m128i v_Y0 = _mm_set1_epi32(Y0);
+ for (; x1 <= bw - 16; x1 += 16)
+ {
+ __m128i v_x0 = _mm_packs_epi32(_mm_srai_epi32(_mm_add_epi32(v_X0, _mm_loadu_si128((__m128i const *)(adelta + x1))), AB_BITS),
+ _mm_srai_epi32(_mm_add_epi32(v_X0, _mm_loadu_si128((__m128i const *)(adelta + x1 + 4))), AB_BITS));
+ __m128i v_x1 = _mm_packs_epi32(_mm_srai_epi32(_mm_add_epi32(v_X0, _mm_loadu_si128((__m128i const *)(adelta + x1 + 8))), AB_BITS),
+ _mm_srai_epi32(_mm_add_epi32(v_X0, _mm_loadu_si128((__m128i const *)(adelta + x1 + 12))), AB_BITS));
+
+ __m128i v_y0 = _mm_packs_epi32(_mm_srai_epi32(_mm_add_epi32(v_Y0, _mm_loadu_si128((__m128i const *)(bdelta + x1))), AB_BITS),
+ _mm_srai_epi32(_mm_add_epi32(v_Y0, _mm_loadu_si128((__m128i const *)(bdelta + x1 + 4))), AB_BITS));
+ __m128i v_y1 = _mm_packs_epi32(_mm_srai_epi32(_mm_add_epi32(v_Y0, _mm_loadu_si128((__m128i const *)(bdelta + x1 + 8))), AB_BITS),
+ _mm_srai_epi32(_mm_add_epi32(v_Y0, _mm_loadu_si128((__m128i const *)(bdelta + x1 + 12))), AB_BITS));
+
+ _mm_interleave_epi16(v_x0, v_x1, v_y0, v_y1);
+
+ _mm_storeu_si128((__m128i *)(xy + x1 * 2), v_x0);
+ _mm_storeu_si128((__m128i *)(xy + x1 * 2 + 8), v_x1);
+ _mm_storeu_si128((__m128i *)(xy + x1 * 2 + 16), v_y0);
+ _mm_storeu_si128((__m128i *)(xy + x1 * 2 + 24), v_y1);
+ }
+ for (; x1 < bw; x1++)
+ {
+ int X = (X0 + adelta[x1]) >> AB_BITS;
+ int Y = (Y0 + bdelta[x1]) >> AB_BITS;
+ xy[x1 * 2] = saturate_cast<short>(X);
+ xy[x1 * 2 + 1] = saturate_cast<short>(Y);
+ }
+}
+
+
+class WarpPerspectiveLine_SSE4_Impl: public WarpPerspectiveLine_SSE4
+{
+public:
+ WarpPerspectiveLine_SSE4_Impl(const double *M)
+ {
+ CV_UNUSED(M);
+ }
+ virtual void processNN(const double *M, short* xy, double X0, double Y0, double W0, int bw)
+ {
+ const __m128d v_M0 = _mm_set1_pd(M[0]);
+ const __m128d v_M3 = _mm_set1_pd(M[3]);
+ const __m128d v_M6 = _mm_set1_pd(M[6]);
+ const __m128d v_intmax = _mm_set1_pd((double)INT_MAX);
+ const __m128d v_intmin = _mm_set1_pd((double)INT_MIN);
+ const __m128d v_2 = _mm_set1_pd(2);
+ const __m128d v_zero = _mm_setzero_pd();
+ const __m128d v_1 = _mm_set1_pd(1);
+
+ int x1 = 0;
+ __m128d v_X0d = _mm_set1_pd(X0);
+ __m128d v_Y0d = _mm_set1_pd(Y0);
+ __m128d v_W0 = _mm_set1_pd(W0);
+ __m128d v_x1 = _mm_set_pd(1, 0);
+
+ for (; x1 <= bw - 16; x1 += 16)
+ {
+ // 0-3
+ __m128i v_X0, v_Y0;
+ {
+ __m128d v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
+ v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_1, v_W));
+ __m128d v_fX0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
+ __m128d v_fY0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
+ v_x1 = _mm_add_pd(v_x1, v_2);
+
+ v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
+ v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_1, v_W));
+ __m128d v_fX1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
+ __m128d v_fY1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
+ v_x1 = _mm_add_pd(v_x1, v_2);
+
+ v_X0 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fX0)),
+ _mm_castsi128_ps(_mm_cvtpd_epi32(v_fX1))));
+ v_Y0 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fY0)),
+ _mm_castsi128_ps(_mm_cvtpd_epi32(v_fY1))));
+ }
+
+ // 4-8
+ __m128i v_X1, v_Y1;
+ {
+ __m128d v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
+ v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_1, v_W));
+ __m128d v_fX0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
+ __m128d v_fY0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
+ v_x1 = _mm_add_pd(v_x1, v_2);
+
+ v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
+ v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_1, v_W));
+ __m128d v_fX1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
+ __m128d v_fY1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
+ v_x1 = _mm_add_pd(v_x1, v_2);
+
+ v_X1 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fX0)),
+ _mm_castsi128_ps(_mm_cvtpd_epi32(v_fX1))));
+ v_Y1 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fY0)),
+ _mm_castsi128_ps(_mm_cvtpd_epi32(v_fY1))));
+ }
+
+ // 8-11
+ __m128i v_X2, v_Y2;
+ {
+ __m128d v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
+ v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_1, v_W));
+ __m128d v_fX0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
+ __m128d v_fY0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
+ v_x1 = _mm_add_pd(v_x1, v_2);
+
+ v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
+ v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_1, v_W));
+ __m128d v_fX1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
+ __m128d v_fY1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
+ v_x1 = _mm_add_pd(v_x1, v_2);
+
+ v_X2 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fX0)),
+ _mm_castsi128_ps(_mm_cvtpd_epi32(v_fX1))));
+ v_Y2 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fY0)),
+ _mm_castsi128_ps(_mm_cvtpd_epi32(v_fY1))));
+ }
+
+ // 12-15
+ __m128i v_X3, v_Y3;
+ {
+ __m128d v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
+ v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_1, v_W));
+ __m128d v_fX0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
+ __m128d v_fY0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
+ v_x1 = _mm_add_pd(v_x1, v_2);
+
+ v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
+ v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_1, v_W));
+ __m128d v_fX1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
+ __m128d v_fY1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
+ v_x1 = _mm_add_pd(v_x1, v_2);
+
+ v_X3 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fX0)),
+ _mm_castsi128_ps(_mm_cvtpd_epi32(v_fX1))));
+ v_Y3 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fY0)),
+ _mm_castsi128_ps(_mm_cvtpd_epi32(v_fY1))));
+ }
+
+ // convert to 16s
+ v_X0 = _mm_packs_epi32(v_X0, v_X1);
+ v_X1 = _mm_packs_epi32(v_X2, v_X3);
+ v_Y0 = _mm_packs_epi32(v_Y0, v_Y1);
+ v_Y1 = _mm_packs_epi32(v_Y2, v_Y3);
+
+ _mm_interleave_epi16(v_X0, v_X1, v_Y0, v_Y1);
+
+ _mm_storeu_si128((__m128i *)(xy + x1 * 2), v_X0);
+ _mm_storeu_si128((__m128i *)(xy + x1 * 2 + 8), v_X1);
+ _mm_storeu_si128((__m128i *)(xy + x1 * 2 + 16), v_Y0);
+ _mm_storeu_si128((__m128i *)(xy + x1 * 2 + 24), v_Y1);
+ }
+
+ for (; x1 < bw; x1++)
+ {
+ double W = W0 + M[6] * x1;
+ W = W ? 1. / W : 0;
+ double fX = std::max((double)INT_MIN, std::min((double)INT_MAX, (X0 + M[0] * x1)*W));
+ double fY = std::max((double)INT_MIN, std::min((double)INT_MAX, (Y0 + M[3] * x1)*W));
+ int X = saturate_cast<int>(fX);
+ int Y = saturate_cast<int>(fY);
+
+ xy[x1 * 2] = saturate_cast<short>(X);
+ xy[x1 * 2 + 1] = saturate_cast<short>(Y);
+ }
+ }
+ virtual void process(const double *M, short* xy, short* alpha, double X0, double Y0, double W0, int bw)
+ {
+ const __m128d v_M0 = _mm_set1_pd(M[0]);
+ const __m128d v_M3 = _mm_set1_pd(M[3]);
+ const __m128d v_M6 = _mm_set1_pd(M[6]);
+ const __m128d v_intmax = _mm_set1_pd((double)INT_MAX);
+ const __m128d v_intmin = _mm_set1_pd((double)INT_MIN);
+ const __m128d v_2 = _mm_set1_pd(2);
+ const __m128d v_zero = _mm_setzero_pd();
+ const __m128d v_its = _mm_set1_pd(INTER_TAB_SIZE);
+ const __m128i v_itsi1 = _mm_set1_epi32(INTER_TAB_SIZE - 1);
+
+ int x1 = 0;
+
+ __m128d v_X0d = _mm_set1_pd(X0);
+ __m128d v_Y0d = _mm_set1_pd(Y0);
+ __m128d v_W0 = _mm_set1_pd(W0);
+ __m128d v_x1 = _mm_set_pd(1, 0);
+
+ for (; x1 <= bw - 16; x1 += 16)
+ {
+ // 0-3
+ __m128i v_X0, v_Y0;
+ {
+ __m128d v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
+ v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_its, v_W));
+ __m128d v_fX0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
+ __m128d v_fY0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
+ v_x1 = _mm_add_pd(v_x1, v_2);
+
+ v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
+ v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_its, v_W));
+ __m128d v_fX1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
+ __m128d v_fY1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
+ v_x1 = _mm_add_pd(v_x1, v_2);
+
+ v_X0 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fX0)),
+ _mm_castsi128_ps(_mm_cvtpd_epi32(v_fX1))));
+ v_Y0 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fY0)),
+ _mm_castsi128_ps(_mm_cvtpd_epi32(v_fY1))));
+ }
+
+ // 4-8
+ __m128i v_X1, v_Y1;
+ {
+ __m128d v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
+ v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_its, v_W));
+ __m128d v_fX0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
+ __m128d v_fY0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
+ v_x1 = _mm_add_pd(v_x1, v_2);
+
+ v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
+ v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_its, v_W));
+ __m128d v_fX1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
+ __m128d v_fY1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
+ v_x1 = _mm_add_pd(v_x1, v_2);
+
+ v_X1 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fX0)),
+ _mm_castsi128_ps(_mm_cvtpd_epi32(v_fX1))));
+ v_Y1 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fY0)),
+ _mm_castsi128_ps(_mm_cvtpd_epi32(v_fY1))));
+ }
+
+ // 8-11
+ __m128i v_X2, v_Y2;
+ {
+ __m128d v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
+ v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_its, v_W));
+ __m128d v_fX0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
+ __m128d v_fY0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
+ v_x1 = _mm_add_pd(v_x1, v_2);
+
+ v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
+ v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_its, v_W));
+ __m128d v_fX1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
+ __m128d v_fY1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
+ v_x1 = _mm_add_pd(v_x1, v_2);
+
+ v_X2 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fX0)),
+ _mm_castsi128_ps(_mm_cvtpd_epi32(v_fX1))));
+ v_Y2 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fY0)),
+ _mm_castsi128_ps(_mm_cvtpd_epi32(v_fY1))));
+ }
+
+ // 12-15
+ __m128i v_X3, v_Y3;
+ {
+ __m128d v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
+ v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_its, v_W));
+ __m128d v_fX0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
+ __m128d v_fY0 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
+ v_x1 = _mm_add_pd(v_x1, v_2);
+
+ v_W = _mm_add_pd(_mm_mul_pd(v_M6, v_x1), v_W0);
+ v_W = _mm_andnot_pd(_mm_cmpeq_pd(v_W, v_zero), _mm_div_pd(v_its, v_W));
+ __m128d v_fX1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_X0d, _mm_mul_pd(v_M0, v_x1)), v_W)));
+ __m128d v_fY1 = _mm_max_pd(v_intmin, _mm_min_pd(v_intmax, _mm_mul_pd(_mm_add_pd(v_Y0d, _mm_mul_pd(v_M3, v_x1)), v_W)));
+ v_x1 = _mm_add_pd(v_x1, v_2);
+
+ v_X3 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fX0)),
+ _mm_castsi128_ps(_mm_cvtpd_epi32(v_fX1))));
+ v_Y3 = _mm_castps_si128(_mm_movelh_ps(_mm_castsi128_ps(_mm_cvtpd_epi32(v_fY0)),
+ _mm_castsi128_ps(_mm_cvtpd_epi32(v_fY1))));
+ }
+
+ // store alpha
+ __m128i v_alpha0 = _mm_add_epi32(_mm_slli_epi32(_mm_and_si128(v_Y0, v_itsi1), INTER_BITS),
+ _mm_and_si128(v_X0, v_itsi1));
+ __m128i v_alpha1 = _mm_add_epi32(_mm_slli_epi32(_mm_and_si128(v_Y1, v_itsi1), INTER_BITS),
+ _mm_and_si128(v_X1, v_itsi1));
+ _mm_storeu_si128((__m128i *)(alpha + x1), _mm_packs_epi32(v_alpha0, v_alpha1));
+
+ v_alpha0 = _mm_add_epi32(_mm_slli_epi32(_mm_and_si128(v_Y2, v_itsi1), INTER_BITS),
+ _mm_and_si128(v_X2, v_itsi1));
+ v_alpha1 = _mm_add_epi32(_mm_slli_epi32(_mm_and_si128(v_Y3, v_itsi1), INTER_BITS),
+ _mm_and_si128(v_X3, v_itsi1));
+ _mm_storeu_si128((__m128i *)(alpha + x1 + 8), _mm_packs_epi32(v_alpha0, v_alpha1));
+
+ // convert to 16s
+ v_X0 = _mm_packs_epi32(_mm_srai_epi32(v_X0, INTER_BITS), _mm_srai_epi32(v_X1, INTER_BITS));
+ v_X1 = _mm_packs_epi32(_mm_srai_epi32(v_X2, INTER_BITS), _mm_srai_epi32(v_X3, INTER_BITS));
+ v_Y0 = _mm_packs_epi32(_mm_srai_epi32(v_Y0, INTER_BITS), _mm_srai_epi32(v_Y1, INTER_BITS));
+ v_Y1 = _mm_packs_epi32(_mm_srai_epi32(v_Y2, INTER_BITS), _mm_srai_epi32(v_Y3, INTER_BITS));
+
+ _mm_interleave_epi16(v_X0, v_X1, v_Y0, v_Y1);
+
+ _mm_storeu_si128((__m128i *)(xy + x1 * 2), v_X0);
+ _mm_storeu_si128((__m128i *)(xy + x1 * 2 + 8), v_X1);
+ _mm_storeu_si128((__m128i *)(xy + x1 * 2 + 16), v_Y0);
+ _mm_storeu_si128((__m128i *)(xy + x1 * 2 + 24), v_Y1);
+ }
+ for (; x1 < bw; x1++)
+ {
+ double W = W0 + M[6] * x1;
+ W = W ? INTER_TAB_SIZE / W : 0;
+ double fX = std::max((double)INT_MIN, std::min((double)INT_MAX, (X0 + M[0] * x1)*W));
+ double fY = std::max((double)INT_MIN, std::min((double)INT_MAX, (Y0 + M[3] * x1)*W));
+ int X = saturate_cast<int>(fX);
+ int Y = saturate_cast<int>(fY);
+
+ xy[x1 * 2] = saturate_cast<short>(X >> INTER_BITS);
+ xy[x1 * 2 + 1] = saturate_cast<short>(Y >> INTER_BITS);
+ alpha[x1] = (short)((Y & (INTER_TAB_SIZE - 1))*INTER_TAB_SIZE +
+ (X & (INTER_TAB_SIZE - 1)));
+ }
+ }
+ virtual ~WarpPerspectiveLine_SSE4_Impl() {};
+};
+
+Ptr<WarpPerspectiveLine_SSE4> WarpPerspectiveLine_SSE4::getImpl(const double *M)
+{
+ return Ptr<WarpPerspectiveLine_SSE4>(new WarpPerspectiveLine_SSE4_Impl(M));
+}
+
+}
+}
+/* End of file. */
diff --git a/modules/imgproc/src/lsd.cpp b/modules/imgproc/src/lsd.cpp
index e504018..a8ea384 100644
--- a/modules/imgproc/src/lsd.cpp
+++ b/modules/imgproc/src/lsd.cpp
@@ -398,8 +398,9 @@ CV_EXPORTS Ptr<LineSegmentDetector> createLineSegmentDetector(
LineSegmentDetectorImpl::LineSegmentDetectorImpl(int _refine, double _scale, double _sigma_scale, double _quant,
double _ang_th, double _log_eps, double _density_th, int _n_bins)
- :SCALE(_scale), doRefine(_refine), SIGMA_SCALE(_sigma_scale), QUANT(_quant),
- ANG_TH(_ang_th), LOG_EPS(_log_eps), DENSITY_TH(_density_th), N_BINS(_n_bins)
+ : img_width(0), img_height(0), LOG_NT(0), w_needed(false), p_needed(false), n_needed(false),
+ SCALE(_scale), doRefine(_refine), SIGMA_SCALE(_sigma_scale), QUANT(_quant),
+ ANG_TH(_ang_th), LOG_EPS(_log_eps), DENSITY_TH(_density_th), N_BINS(_n_bins)
{
CV_Assert(_scale > 0 && _sigma_scale > 0 && _quant >= 0 &&
_ang_th > 0 && _ang_th < 180 && _density_th >= 0 && _density_th < 1 &&
@@ -999,6 +1000,7 @@ double LineSegmentDetectorImpl::rect_nfa(const rect& rec) const
}
}
}
+ CV_Assert(leftmost != NULL);
leftmost->taken = true;
// Find rightmost untaken point;
@@ -1017,6 +1019,7 @@ double LineSegmentDetectorImpl::rect_nfa(const rect& rec) const
}
}
}
+ CV_Assert(rightmost != NULL);
rightmost->taken = true;
// Find last untaken point;
@@ -1035,6 +1038,7 @@ double LineSegmentDetectorImpl::rect_nfa(const rect& rec) const
}
}
}
+ CV_Assert(tailp != NULL);
tailp->taken = true;
double flstep = (min_y->p.y != leftmost->p.y) ?
diff --git a/modules/imgproc/src/matchcontours.cpp b/modules/imgproc/src/matchcontours.cpp
index 1a37167..2a0c5df 100644
--- a/modules/imgproc/src/matchcontours.cpp
+++ b/modules/imgproc/src/matchcontours.cpp
@@ -50,6 +50,7 @@ double cv::matchShapes(InputArray contour1, InputArray contour2, int method, dou
double eps = 1.e-5;
double mmm;
double result = 0;
+ bool anyA = false, anyB = false;
HuMoments( moments(contour1), ma );
HuMoments( moments(contour2), mb );
@@ -62,6 +63,11 @@ double cv::matchShapes(InputArray contour1, InputArray contour2, int method, dou
double ama = fabs( ma[i] );
double amb = fabs( mb[i] );
+ if (ama > 0)
+ anyA = true;
+ if (amb > 0)
+ anyB = true;
+
if( ma[i] > 0 )
sma = 1;
else if( ma[i] < 0 )
@@ -90,6 +96,11 @@ double cv::matchShapes(InputArray contour1, InputArray contour2, int method, dou
double ama = fabs( ma[i] );
double amb = fabs( mb[i] );
+ if (ama > 0)
+ anyA = true;
+ if (amb > 0)
+ anyB = true;
+
if( ma[i] > 0 )
sma = 1;
else if( ma[i] < 0 )
@@ -118,6 +129,11 @@ double cv::matchShapes(InputArray contour1, InputArray contour2, int method, dou
double ama = fabs( ma[i] );
double amb = fabs( mb[i] );
+ if (ama > 0)
+ anyA = true;
+ if (amb > 0)
+ anyB = true;
+
if( ma[i] > 0 )
sma = 1;
else if( ma[i] < 0 )
@@ -145,6 +161,12 @@ double cv::matchShapes(InputArray contour1, InputArray contour2, int method, dou
CV_Error( CV_StsBadArg, "Unknown comparison method" );
}
+ //If anyA and anyB are both true, the result is correct.
+ //If anyA and anyB are both false, the distance is 0, perfect match.
+ //If only one is true, then it's a false 0 and return large error.
+ if (anyA != anyB)
+ result = DBL_MAX;
+
return result;
}
diff --git a/modules/imgproc/src/min_enclosing_triangle.cpp b/modules/imgproc/src/min_enclosing_triangle.cpp
index fb94fa0..ed4d5b9 100644
--- a/modules/imgproc/src/min_enclosing_triangle.cpp
+++ b/modules/imgproc/src/min_enclosing_triangle.cpp
@@ -727,7 +727,7 @@ static bool isValidMinimalTriangle(const cv::Point2f &vertexA, const cv::Point2f
? (areEqualPoints(midpointSideB, polygon[b]))
: (isPointOnLineSegment(midpointSideB, sideBStartVertex, sideBEndVertex));
- bool sideCValid = isPointOnLineSegment(midpointSideC, sideCStartVertex, sideCEndVertex);
+ bool sideCValid = (validationFlag == VALIDATION_SIDES_FLUSH) || isPointOnLineSegment(midpointSideC, sideCStartVertex, sideCEndVertex);
return (sideAValid && sideBValid && sideCValid);
}
diff --git a/modules/imgproc/src/moments.cpp b/modules/imgproc/src/moments.cpp
index d445ed2..d9ae2e2 100644
--- a/modules/imgproc/src/moments.cpp
+++ b/modules/imgproc/src/moments.cpp
@@ -556,13 +556,94 @@ static bool ocl_moments( InputArray _src, Moments& m, bool binary)
m.m03 += mom[9] + y * (3. * mom[5] + y * (3. * mom[2] + ym));
}
+ completeMomentState( &m );
+
return true;
}
#endif
+#ifdef HAVE_IPP
+typedef IppStatus (CV_STDCALL * ippiMoments)(const void* pSrc, int srcStep, IppiSize roiSize, IppiMomentState_64f* pCtx);
+
+static bool ipp_moments(Mat &src, Moments &m )
+{
+#if IPP_VERSION_X100 >= 900
+ CV_INSTRUMENT_REGION_IPP()
+
+ IppiSize roi = { src.cols, src.rows };
+ IppiPoint point = { 0, 0 };
+ int type = src.type();
+ IppStatus ippStatus;
+
+ IppAutoBuffer<IppiMomentState_64f> state;
+ int stateSize = 0;
+
+ ippiMoments ippiMoments64f =
+ (type == CV_8UC1)?(ippiMoments)ippiMoments64f_8u_C1R:
+ (type == CV_16UC1)?(ippiMoments)ippiMoments64f_16u_C1R:
+ (type == CV_32FC1)?(ippiMoments)ippiMoments64f_32f_C1R:
+ NULL;
+ if(!ippiMoments64f)
+ return false;
+
+ ippStatus = ippiMomentGetStateSize_64f(ippAlgHintAccurate, &stateSize);
+ if(ippStatus < 0)
+ return false;
+
+ if(!state.allocate(stateSize) && stateSize)
+ return false;
+
+ ippStatus = ippiMomentInit_64f(state, ippAlgHintAccurate);
+ if(ippStatus < 0)
+ return false;
+
+ ippStatus = CV_INSTRUMENT_FUN_IPP(ippiMoments64f, src.ptr<Ipp8u>(), (int)src.step, roi, state);
+ if(ippStatus < 0)
+ return false;
+
+ ippStatus = ippiGetSpatialMoment_64f(state, 0, 0, 0, point, &m.m00);
+ if(ippStatus < 0)
+ return false;
+ ippiGetSpatialMoment_64f(state, 1, 0, 0, point, &m.m10);
+ ippiGetSpatialMoment_64f(state, 0, 1, 0, point, &m.m01);
+ ippiGetSpatialMoment_64f(state, 2, 0, 0, point, &m.m20);
+ ippiGetSpatialMoment_64f(state, 1, 1, 0, point, &m.m11);
+ ippiGetSpatialMoment_64f(state, 0, 2, 0, point, &m.m02);
+ ippiGetSpatialMoment_64f(state, 3, 0, 0, point, &m.m30);
+ ippiGetSpatialMoment_64f(state, 2, 1, 0, point, &m.m21);
+ ippiGetSpatialMoment_64f(state, 1, 2, 0, point, &m.m12);
+ ippiGetSpatialMoment_64f(state, 0, 3, 0, point, &m.m03);
+
+ ippStatus = ippiGetCentralMoment_64f(state, 2, 0, 0, &m.mu20);
+ if(ippStatus < 0)
+ return false;
+ ippiGetCentralMoment_64f(state, 1, 1, 0, &m.mu11);
+ ippiGetCentralMoment_64f(state, 0, 2, 0, &m.mu02);
+ ippiGetCentralMoment_64f(state, 3, 0, 0, &m.mu30);
+ ippiGetCentralMoment_64f(state, 2, 1, 0, &m.mu21);
+ ippiGetCentralMoment_64f(state, 1, 2, 0, &m.mu12);
+ ippiGetCentralMoment_64f(state, 0, 3, 0, &m.mu03);
+
+ ippStatus = ippiGetNormalizedCentralMoment_64f(state, 2, 0, 0, &m.nu20);
+ if(ippStatus < 0)
+ return false;
+ ippiGetNormalizedCentralMoment_64f(state, 1, 1, 0, &m.nu11);
+ ippiGetNormalizedCentralMoment_64f(state, 0, 2, 0, &m.nu02);
+ ippiGetNormalizedCentralMoment_64f(state, 3, 0, 0, &m.nu30);
+ ippiGetNormalizedCentralMoment_64f(state, 2, 1, 0, &m.nu21);
+ ippiGetNormalizedCentralMoment_64f(state, 1, 2, 0, &m.nu12);
+ ippiGetNormalizedCentralMoment_64f(state, 0, 3, 0, &m.nu03);
+
+ return true;
+#else
+ CV_UNUSED(src); CV_UNUSED(m);
+ return false;
+#endif
}
+#endif
+}
cv::Moments cv::moments( InputArray _src, bool binary )
{
@@ -579,159 +660,93 @@ cv::Moments cv::moments( InputArray _src, bool binary )
return m;
#ifdef HAVE_OPENCL
- if( !(ocl::useOpenCL() && type == CV_8UC1 &&
- _src.isUMat() && ocl_moments(_src, m, binary)) )
+ CV_OCL_RUN_(type == CV_8UC1 && _src.isUMat(), ocl_moments(_src, m, binary), m);
#endif
- {
- Mat mat = _src.getMat();
- if( mat.checkVector(2) >= 0 && (depth == CV_32F || depth == CV_32S))
- return contourMoments(mat);
-
- if( cn > 1 )
- CV_Error( CV_StsBadArg, "Invalid image type (must be single-channel)" );
-#if IPP_VERSION_X100 >= 810 && IPP_DISABLE_BLOCK
- CV_IPP_CHECK()
- {
- if (!binary)
- {
- IppiSize roi = { mat.cols, mat.rows };
- IppiMomentState_64f * moment = NULL;
- // ippiMomentInitAlloc_64f, ippiMomentFree_64f are deprecated in 8.1, but there are not another way
- // to initialize IppiMomentState_64f. When GetStateSize and Init functions will appear we have to
- // change our code.
- CV_SUPPRESS_DEPRECATED_START
- if (ippiMomentInitAlloc_64f(&moment, ippAlgHintAccurate) >= 0)
- {
- typedef IppStatus (CV_STDCALL * ippiMoments)(const void * pSrc, int srcStep, IppiSize roiSize, IppiMomentState_64f* pCtx);
- ippiMoments ippFunc =
- type == CV_8UC1 ? (ippiMoments)ippiMoments64f_8u_C1R :
- type == CV_16UC1 ? (ippiMoments)ippiMoments64f_16u_C1R :
- type == CV_32FC1? (ippiMoments)ippiMoments64f_32f_C1R : 0;
-
- if (ippFunc)
- {
- if (CV_INSTRUMENT_FUN_IPP(ippFunc,(mat.data, (int)mat.step, roi, moment)) >= 0)
- {
- IppiPoint point = { 0, 0 };
- ippiGetSpatialMoment_64f(moment, 0, 0, 0, point, &m.m00);
- ippiGetSpatialMoment_64f(moment, 1, 0, 0, point, &m.m10);
- ippiGetSpatialMoment_64f(moment, 0, 1, 0, point, &m.m01);
-
- ippiGetSpatialMoment_64f(moment, 2, 0, 0, point, &m.m20);
- ippiGetSpatialMoment_64f(moment, 1, 1, 0, point, &m.m11);
- ippiGetSpatialMoment_64f(moment, 0, 2, 0, point, &m.m02);
-
- ippiGetSpatialMoment_64f(moment, 3, 0, 0, point, &m.m30);
- ippiGetSpatialMoment_64f(moment, 2, 1, 0, point, &m.m21);
- ippiGetSpatialMoment_64f(moment, 1, 2, 0, point, &m.m12);
- ippiGetSpatialMoment_64f(moment, 0, 3, 0, point, &m.m03);
- ippiGetCentralMoment_64f(moment, 2, 0, 0, &m.mu20);
- ippiGetCentralMoment_64f(moment, 1, 1, 0, &m.mu11);
- ippiGetCentralMoment_64f(moment, 0, 2, 0, &m.mu02);
- ippiGetCentralMoment_64f(moment, 3, 0, 0, &m.mu30);
- ippiGetCentralMoment_64f(moment, 2, 1, 0, &m.mu21);
- ippiGetCentralMoment_64f(moment, 1, 2, 0, &m.mu12);
- ippiGetCentralMoment_64f(moment, 0, 3, 0, &m.mu03);
- ippiGetNormalizedCentralMoment_64f(moment, 2, 0, 0, &m.nu20);
- ippiGetNormalizedCentralMoment_64f(moment, 1, 1, 0, &m.nu11);
- ippiGetNormalizedCentralMoment_64f(moment, 0, 2, 0, &m.nu02);
- ippiGetNormalizedCentralMoment_64f(moment, 3, 0, 0, &m.nu30);
- ippiGetNormalizedCentralMoment_64f(moment, 2, 1, 0, &m.nu21);
- ippiGetNormalizedCentralMoment_64f(moment, 1, 2, 0, &m.nu12);
- ippiGetNormalizedCentralMoment_64f(moment, 0, 3, 0, &m.nu03);
-
- ippiMomentFree_64f(moment);
- CV_IMPL_ADD(CV_IMPL_IPP);
- return m;
- }
- setIppErrorStatus();
- }
- ippiMomentFree_64f(moment);
- }
- else
- setIppErrorStatus();
- CV_SUPPRESS_DEPRECATED_END
- }
- }
-#endif
+ Mat mat = _src.getMat();
+ if( mat.checkVector(2) >= 0 && (depth == CV_32F || depth == CV_32S))
+ return contourMoments(mat);
+
+ if( cn > 1 )
+ CV_Error( CV_StsBadArg, "Invalid image type (must be single-channel)" );
+
+ CV_IPP_RUN(!binary, ipp_moments(mat, m), m);
+
+ if( binary || depth == CV_8U )
+ func = momentsInTile<uchar, int, int>;
+ else if( depth == CV_16U )
+ func = momentsInTile<ushort, int, int64>;
+ else if( depth == CV_16S )
+ func = momentsInTile<short, int, int64>;
+ else if( depth == CV_32F )
+ func = momentsInTile<float, double, double>;
+ else if( depth == CV_64F )
+ func = momentsInTile<double, double, double>;
+ else
+ CV_Error( CV_StsUnsupportedFormat, "" );
- if( binary || depth == CV_8U )
- func = momentsInTile<uchar, int, int>;
- else if( depth == CV_16U )
- func = momentsInTile<ushort, int, int64>;
- else if( depth == CV_16S )
- func = momentsInTile<short, int, int64>;
- else if( depth == CV_32F )
- func = momentsInTile<float, double, double>;
- else if( depth == CV_64F )
- func = momentsInTile<double, double, double>;
- else
- CV_Error( CV_StsUnsupportedFormat, "" );
+ Mat src0(mat);
- Mat src0(mat);
+ for( int y = 0; y < size.height; y += TILE_SIZE )
+ {
+ Size tileSize;
+ tileSize.height = std::min(TILE_SIZE, size.height - y);
- for( int y = 0; y < size.height; y += TILE_SIZE )
+ for( int x = 0; x < size.width; x += TILE_SIZE )
{
- Size tileSize;
- tileSize.height = std::min(TILE_SIZE, size.height - y);
+ tileSize.width = std::min(TILE_SIZE, size.width - x);
+ Mat src(src0, cv::Rect(x, y, tileSize.width, tileSize.height));
- for( int x = 0; x < size.width; x += TILE_SIZE )
+ if( binary )
{
- tileSize.width = std::min(TILE_SIZE, size.width - x);
- Mat src(src0, cv::Rect(x, y, tileSize.width, tileSize.height));
-
- if( binary )
- {
- cv::Mat tmp(tileSize, CV_8U, nzbuf);
- cv::compare( src, 0, tmp, CV_CMP_NE );
- src = tmp;
- }
+ cv::Mat tmp(tileSize, CV_8U, nzbuf);
+ cv::compare( src, 0, tmp, CV_CMP_NE );
+ src = tmp;
+ }
- double mom[10];
- func( src, mom );
+ double mom[10];
+ func( src, mom );
- if(binary)
- {
- double s = 1./255;
- for( int k = 0; k < 10; k++ )
- mom[k] *= s;
- }
+ if(binary)
+ {
+ double s = 1./255;
+ for( int k = 0; k < 10; k++ )
+ mom[k] *= s;
+ }
- double xm = x * mom[0], ym = y * mom[0];
+ double xm = x * mom[0], ym = y * mom[0];
- // accumulate moments computed in each tile
+ // accumulate moments computed in each tile
- // + m00 ( = m00' )
- m.m00 += mom[0];
+ // + m00 ( = m00' )
+ m.m00 += mom[0];
- // + m10 ( = m10' + x*m00' )
- m.m10 += mom[1] + xm;
+ // + m10 ( = m10' + x*m00' )
+ m.m10 += mom[1] + xm;
- // + m01 ( = m01' + y*m00' )
- m.m01 += mom[2] + ym;
+ // + m01 ( = m01' + y*m00' )
+ m.m01 += mom[2] + ym;
- // + m20 ( = m20' + 2*x*m10' + x*x*m00' )
- m.m20 += mom[3] + x * (mom[1] * 2 + xm);
+ // + m20 ( = m20' + 2*x*m10' + x*x*m00' )
+ m.m20 += mom[3] + x * (mom[1] * 2 + xm);
- // + m11 ( = m11' + x*m01' + y*m10' + x*y*m00' )
- m.m11 += mom[4] + x * (mom[2] + ym) + y * mom[1];
+ // + m11 ( = m11' + x*m01' + y*m10' + x*y*m00' )
+ m.m11 += mom[4] + x * (mom[2] + ym) + y * mom[1];
- // + m02 ( = m02' + 2*y*m01' + y*y*m00' )
- m.m02 += mom[5] + y * (mom[2] * 2 + ym);
+ // + m02 ( = m02' + 2*y*m01' + y*y*m00' )
+ m.m02 += mom[5] + y * (mom[2] * 2 + ym);
- // + m30 ( = m30' + 3*x*m20' + 3*x*x*m10' + x*x*x*m00' )
- m.m30 += mom[6] + x * (3. * mom[3] + x * (3. * mom[1] + xm));
+ // + m30 ( = m30' + 3*x*m20' + 3*x*x*m10' + x*x*x*m00' )
+ m.m30 += mom[6] + x * (3. * mom[3] + x * (3. * mom[1] + xm));
- // + m21 ( = m21' + x*(2*m11' + 2*y*m10' + x*m01' + x*y*m00') + y*m20')
- m.m21 += mom[7] + x * (2 * (mom[4] + y * mom[1]) + x * (mom[2] + ym)) + y * mom[3];
+ // + m21 ( = m21' + x*(2*m11' + 2*y*m10' + x*m01' + x*y*m00') + y*m20')
+ m.m21 += mom[7] + x * (2 * (mom[4] + y * mom[1]) + x * (mom[2] + ym)) + y * mom[3];
- // + m12 ( = m12' + y*(2*m11' + 2*x*m01' + y*m10' + x*y*m00') + x*m02')
- m.m12 += mom[8] + y * (2 * (mom[4] + x * mom[2]) + y * (mom[1] + xm)) + x * mom[5];
+ // + m12 ( = m12' + y*(2*m11' + 2*x*m01' + y*m10' + x*y*m00') + x*m02')
+ m.m12 += mom[8] + y * (2 * (mom[4] + x * mom[2]) + y * (mom[1] + xm)) + x * mom[5];
- // + m03 ( = m03' + 3*y*m02' + 3*y*y*m01' + y*y*y*m00' )
- m.m03 += mom[9] + y * (3. * mom[5] + y * (3. * mom[2] + ym));
- }
+ // + m03 ( = m03' + 3*y*m02' + 3*y*y*m01' + y*y*y*m00' )
+ m.m03 += mom[9] + y * (3. * mom[5] + y * (3. * mom[2] + ym));
}
}
diff --git a/modules/imgproc/src/morph.cpp b/modules/imgproc/src/morph.cpp
index 52c3411..bf35ee3 100644
--- a/modules/imgproc/src/morph.cpp
+++ b/modules/imgproc/src/morph.cpp
@@ -1079,396 +1079,270 @@ namespace cv
// ===== 1. replacement implementation
-struct ReplacementMorphImpl : public hal::Morph
+static bool halMorph(int op, int src_type, int dst_type,
+ uchar * src_data, size_t src_step,
+ uchar * dst_data, size_t dst_step,
+ int width, int height,
+ int roi_width, int roi_height, int roi_x, int roi_y,
+ int roi_width2, int roi_height2, int roi_x2, int roi_y2,
+ int kernel_type, uchar * kernel_data, size_t kernel_step,
+ int kernel_width, int kernel_height, int anchor_x, int anchor_y,
+ int borderType, const double borderValue[4], int iterations, bool isSubmatrix)
{
cvhalFilter2D * ctx;
- bool isInitialized;
- bool init(int op, int src_type, int dst_type, int max_width, int max_height,
- int kernel_type, uchar * kernel_data, size_t kernel_step, int kernel_width, int kernel_height,
- int anchor_x, int anchor_y,
- int borderType, const double borderValue[4],
- int iterations, bool isSubmatrix, bool allowInplace)
- {
- int res = cv_hal_morphInit(&ctx, op, src_type, dst_type, max_width, max_height,
- kernel_type, kernel_data, kernel_step, kernel_width, kernel_height,
- anchor_x, anchor_y,
- borderType, borderValue,
- iterations, isSubmatrix, allowInplace);
- isInitialized = (res == CV_HAL_ERROR_OK);
- return isInitialized;
- }
- void apply(uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height,
- int roi_width, int roi_height, int roi_x, int roi_y,
- int roi_width2, int roi_height2, int roi_x2, int roi_y2)
- {
- if (isInitialized)
- {
- int res = cv_hal_morph(ctx, src_data, src_step, dst_data, dst_step, width, height,
- roi_width, roi_height,
- roi_x, roi_y,
- roi_width2, roi_height2,
- roi_x2, roi_y2);
- if (res != CV_HAL_ERROR_OK)
- CV_Error(Error::StsNotImplemented, "Failed to run HAL morph implementation");
- }
- }
- ~ReplacementMorphImpl()
- {
- if (isInitialized)
- {
- int res = cv_hal_morphFree(ctx);
- if (res != CV_HAL_ERROR_OK)
- CV_Error(Error::StsNotImplemented, "Failed to run HAL morph implementation");
- }
- }
-};
+ int res = cv_hal_morphInit(&ctx, op, src_type, dst_type, width, height,
+ kernel_type, kernel_data, kernel_step, kernel_width, kernel_height,
+ anchor_x, anchor_y,
+ borderType, borderValue,
+ iterations, isSubmatrix, src_data == dst_data);
+ if (res != CV_HAL_ERROR_OK)
+ return false;
-// ===== 2. IPP implementation
+ res = cv_hal_morph(ctx, src_data, src_step, dst_data, dst_step, width, height,
+ roi_width, roi_height,
+ roi_x, roi_y,
+ roi_width2, roi_height2,
+ roi_x2, roi_y2);
+ bool success = (res == CV_HAL_ERROR_OK);
-#ifdef HAVE_IPP
+ res = cv_hal_morphFree(ctx);
+ if (res != CV_HAL_ERROR_OK)
+ return false;
-#if IPP_VERSION_X100 >= 810
-
-template <int cvtype> struct IppMorphTrait {};
-
-#if IPP_VERSION_X100 >= 900
-
-#define INIT_TRAIT(cvtype, ipptype, flavor, channels, zerodef)\
-template <>\
-struct IppMorphTrait<cvtype>\
-{\
- typedef Ipp##ipptype ipp_data_type;\
- enum { cn = channels };\
- IppDataType getDataType() {return ipp##ipptype;}\
-\
- IppStatus getMorphSize(IppiSize roiSize, IppiSize maskSize, int* pSpecSize, int* pBufferSize) {return ippiMorphologyBorderGetSize_##flavor(roiSize, maskSize, pSpecSize, pBufferSize);}\
- IppStatus morphInit(IppiSize roiSize, const Ipp8u* pMask, IppiSize maskSize, IppiMorphState* pMorphSpec, Ipp8u* pBuffer) {return ippiMorphologyBorderInit_##flavor(roiSize, pMask, maskSize, pMorphSpec, pBuffer);}\
- IppStatus filterGetMinSize(IppiSize dstRoiSize, IppiSize maskSize, IppDataType dataType, int numChannels, int* pBufferSize) {return ippiFilterMinBorderGetBufferSize(dstRoiSize, maskSize, dataType, numChannels, pBufferSize);}\
- IppStatus filterGetMaxSize(IppiSize dstRoiSize, IppiSize maskSize, IppDataType dataType, int numChannels, int* pBufferSize) {return ippiFilterMaxBorderGetBufferSize(dstRoiSize, maskSize, dataType, numChannels, pBufferSize);}\
- IppStatus filterMinBorder(const ipp_data_type* pSrc, int srcStep, ipp_data_type* pDst, int dstStep, IppiSize dstRoiSize, IppiSize maskSize, IppiPoint, Ipp8u* pBuffer) { ipp_data_type zerodef; return CV_INSTRUMENT_FUN_IPP(ippiFilterMinBorder_##flavor, pSrc, srcStep, pDst, dstStep, dstRoiSize, maskSize, ippBorderRepl, zero, pBuffer); }\
- IppStatus filterMaxBorder(const ipp_data_type* pSrc, int srcStep, ipp_data_type* pDst, int dstStep, IppiSize dstRoiSize, IppiSize maskSize, IppiPoint, Ipp8u* pBuffer) { ipp_data_type zerodef; return CV_INSTRUMENT_FUN_IPP(ippiFilterMaxBorder_##flavor, pSrc, srcStep, pDst, dstStep, dstRoiSize, maskSize, ippBorderRepl, zero, pBuffer); }\
- IppStatus morphDilate(const ipp_data_type* pSrc, int srcStep, ipp_data_type* pDst, int dstStep, IppiSize roiSize, const IppiMorphState* pMorphSpec, Ipp8u* pBuffer) { ipp_data_type zerodef; return CV_INSTRUMENT_FUN_IPP(ippiDilateBorder_##flavor, pSrc, srcStep, pDst, dstStep, roiSize, ippBorderRepl, zero, pMorphSpec, pBuffer); }\
- IppStatus morphErode(const ipp_data_type* pSrc, int srcStep, ipp_data_type* pDst, int dstStep, IppiSize roiSize, const IppiMorphState* pMorphSpec, Ipp8u* pBuffer) { ipp_data_type zerodef; return CV_INSTRUMENT_FUN_IPP(ippiErodeBorder_##flavor, pSrc, srcStep, pDst, dstStep, roiSize, ippBorderRepl, zero, pMorphSpec, pBuffer); }\
-};
+ return success;
+}
-#else
+// ===== 2. IPP implementation
+#ifdef HAVE_IPP
+#ifdef HAVE_IPP_IW
+static inline IwiMorphologyType ippiGetMorphologyType(int morphOp)
+{
+ return morphOp == MORPH_ERODE ? iwiMorphErode :
+ morphOp == MORPH_DILATE ? iwiMorphDilate :
+ morphOp == MORPH_OPEN ? iwiMorphOpen :
+ morphOp == MORPH_CLOSE ? iwiMorphClose :
+ morphOp == MORPH_GRADIENT ? iwiMorphGradient :
+ morphOp == MORPH_TOPHAT ? iwiMorphTophat :
+ morphOp == MORPH_BLACKHAT ? iwiMorphBlackhat : (IwiMorphologyType)-1;
+}
+#endif
-#define INIT_TRAIT(cvtype, ipptype, flavor, channels, zerodef)\
-template <>\
-struct IppMorphTrait<cvtype>\
-{\
- typedef Ipp##ipptype ipp_data_type;\
- enum { cn = channels };\
- IppDataType getDataType() {return ipp##ipptype;}\
-\
- IppStatus getMorphSize(IppiSize roiSize, IppiSize maskSize, int* pSpecSize, int* pBufferSize) {return ippiMorphologyBorderGetSize_##flavor(roiSize.width, maskSize, pSpecSize, pBufferSize);}\
- IppStatus morphInit(IppiSize roiSize, const Ipp8u* pMask, IppiSize maskSize, IppiMorphState* pMorphSpec, Ipp8u* pBuffer) {return ippiMorphologyBorderInit_##flavor(roiSize.width, pMask, maskSize, pMorphSpec, pBuffer);}\
- IppStatus filterGetMinSize(IppiSize dstRoiSize, IppiSize maskSize, IppDataType, int, int* pBufferSize) {return ippiFilterMinGetBufferSize_##flavor(dstRoiSize.width, maskSize, pBufferSize);}\
- IppStatus filterGetMaxSize(IppiSize dstRoiSize, IppiSize maskSize, IppDataType, int, int* pBufferSize) {return ippiFilterMinGetBufferSize_##flavor(dstRoiSize.width, maskSize, pBufferSize);}\
- IppStatus filterMinBorder(const ipp_data_type* pSrc, int srcStep, ipp_data_type* pDst, int dstStep, IppiSize dstRoiSize, IppiSize maskSize, IppiPoint anchor, Ipp8u* pBuffer) { return ippiFilterMinBorderReplicate_##flavor(pSrc, srcStep, pDst, dstStep, dstRoiSize, maskSize, anchor, pBuffer); }\
- IppStatus filterMaxBorder(const ipp_data_type* pSrc, int srcStep, ipp_data_type* pDst, int dstStep, IppiSize dstRoiSize, IppiSize maskSize, IppiPoint anchor, Ipp8u* pBuffer) { return ippiFilterMaxBorderReplicate_##flavor(pSrc, srcStep, pDst, dstStep, dstRoiSize, maskSize, anchor, pBuffer); }\
- IppStatus morphDilate(const ipp_data_type* pSrc, int srcStep, ipp_data_type* pDst, int dstStep, IppiSize roiSize, const IppiMorphState* pMorphSpec, Ipp8u* pBuffer) {return ippiDilateBorder_##flavor(pSrc, srcStep, pDst, dstStep, roiSize, ippBorderRepl, 0, pMorphSpec, pBuffer);}\
- IppStatus morphErode(const ipp_data_type* pSrc, int srcStep, ipp_data_type* pDst, int dstStep, IppiSize roiSize, const IppiMorphState* pMorphSpec, Ipp8u* pBuffer) {return ippiErodeBorder_##flavor(pSrc, srcStep, pDst, dstStep, roiSize, ippBorderRepl, 0, pMorphSpec, pBuffer);}\
-};
+static bool ippMorph(int op, int src_type, int dst_type,
+ const uchar * src_data, size_t src_step,
+ uchar * dst_data, size_t dst_step,
+ int width, int height,
+ int roi_width, int roi_height, int roi_x, int roi_y,
+ int roi_width2, int roi_height2, int roi_x2, int roi_y2,
+ int kernel_type, uchar * kernel_data, size_t kernel_step,
+ int kernel_width, int kernel_height, int anchor_x, int anchor_y,
+ int borderType, const double borderValue[4], int iterations, bool isSubmatrix)
+{
+#ifdef HAVE_IPP_IW
+ CV_INSTRUMENT_REGION_IPP()
+ // Problem with SSE42 optimizations
+#if IPP_DISABLE_PERF_MORPH_SSE42
+ if(!(ipp::getIppFeatures()&ippCPUID_AVX))
+ return false;
#endif
-INIT_TRAIT(CV_8UC1, 8u, 8u_C1R, 1, zero = 0)
-INIT_TRAIT(CV_8UC3, 8u, 8u_C3R, 3, zero[3] = {0})
-INIT_TRAIT(CV_8UC4, 8u, 8u_C4R, 4, zero[4] = {0})
-INIT_TRAIT(CV_32FC1, 32f, 32f_C1R, 1, zero = 0)
-INIT_TRAIT(CV_32FC3, 32f, 32f_C3R, 3, zero[3] = {0})
-INIT_TRAIT(CV_32FC4, 32f, 32f_C4R, 4, zero[4] = {0})
-
-#undef INIT_TRAIT
+ ::ipp::IwAutoBuffer<Ipp8u> kernelTempBuffer;
+ ::ipp::IwiBorderSize iwBorderSize;
+ ::ipp::IwiBorderType iwBorderType;
+ ::ipp::IwiImage iwMask;
+ ::ipp::IwiImage iwInter;
+ ::ipp::IwiSize initSize(width, height);
+ ::ipp::IwiSize kernelSize(kernel_width, kernel_height);
+ ::ipp::IwiPoint anchor(anchor_x, anchor_y);
+ IppDataType type = ippiGetDataType(CV_MAT_DEPTH(src_type));
+ int channels = CV_MAT_CN(src_type);
+ IwiMorphologyType morphType = ippiGetMorphologyType(op);
+
+ CV_UNUSED(isSubmatrix);
+
+ if(morphType < 0)
+ return false;
-//--------------------------------------
+ if(iterations > 1 && morphType != iwiMorphErode && morphType != iwiMorphDilate)
+ return false;
-struct IppMorphBaseImpl : public hal::Morph
-{
- virtual bool init(int _op, int _src_type, int dst_type, int max_width, int max_height,
- int kernel_type, uchar * kernel_data, size_t kernel_step, int kernel_width, int kernel_height,
- int anchor_x, int anchor_y,
- int borderType, const double borderValue[4],
- int iterations, bool isSubmatrix, bool allowInplace) = 0;
-};
+ if(src_type != dst_type)
+ return false;
-template <int cvtype>
-struct IppMorphImpl : public IppMorphBaseImpl
-{
- IppMorphTrait<cvtype> trait;
- typedef typename IppMorphTrait<cvtype>::ipp_data_type ipp_data_type;
- IppAutoBuffer<IppiMorphState> specBuf;
- IppAutoBuffer<Ipp8u> workBuf;
- IppiSize kernelSize;
- bool rectKernel;
- IppiPoint anchor;
- int op;
- int src_type;
- int border;
-
- bool init(int _op, int _src_type, int dst_type, int max_width, int max_height,
- int kernel_type, uchar * kernel_data, size_t kernel_step, int kernel_width, int kernel_height,
- int anchor_x, int anchor_y,
- int borderType, const double borderValue[4],
- int iterations, bool isSubmatrix, bool allowInplace)
+ try
{
- border = borderType; // TODO: remove
- anchor = ippiPoint(anchor_x, anchor_y);
- CV_UNUSED(dst_type);
- src_type = _src_type;
-
- Mat kernel(Size(kernel_width, kernel_height), kernel_type, kernel_data, kernel_step);
- int depth = CV_MAT_DEPTH(src_type), cn = CV_MAT_CN(src_type);
-
- if( !( depth == CV_8U || depth == CV_32F )
- || !(cn == 1 || cn == 3 || cn == 4)
- || !( borderType == cv::BORDER_REPLICATE
- || (borderType == cv::BORDER_CONSTANT && Vec<double, 4>(borderValue) == morphologyDefaultBorderValue() && kernel.size() == Size(3,3)))
- || !( op == MORPH_DILATE || op == MORPH_ERODE)
- || isSubmatrix
- || allowInplace)
- return false;
+ ::ipp::IwiImage iwSrc(initSize, type, channels, ::ipp::IwiBorderSize(roi_x, roi_y, roi_width-roi_x-width, roi_height-roi_y-height), (void*)src_data, src_step);
+ ::ipp::IwiImage iwDst(initSize, type, channels, ::ipp::IwiBorderSize(roi_x2, roi_y2, roi_width2-roi_x2-width, roi_height2-roi_y2-height), (void*)dst_data, dst_step);
- // In case BORDER_CONSTANT, IPPMorphReplicate works correct with kernels of size 3*3 only
- if( borderType == cv::BORDER_CONSTANT && kernel.data )
+ ::ipp::iwiFilterMorphology_GetBorderSize(morphType, kernelSize, iwBorderSize);
+ if(morphType != iwiMorphErode && morphType != iwiMorphDilate)
{
- int x, y;
- for( y = 0; y < kernel.rows; y++ )
- {
- if( kernel.at<uchar>(y, anchor.x) != 0 )
- continue;
- for( x = 0; x < kernel.cols; x++ )
- {
- if( kernel.at<uchar>(y,x) != 0 )
- return false;
- }
- }
- for( x = 0; x < kernel.cols; x++ )
- {
- if( kernel.at<uchar>(anchor.y, x) != 0 )
- continue;
- for( y = 0; y < kernel.rows; y++ )
- {
- if( kernel.at<uchar>(y,x) != 0 )
- return false;
- }
- }
-
+ iwBorderSize.borderLeft /= 2;
+ iwBorderSize.borderTop /= 2;
+ iwBorderSize.borderRight /= 2;
+ iwBorderSize.borderBottom /= 2;
}
- Size ksize = !kernel.empty() ? kernel.size() : Size(3,3);
+ iwBorderType = ippiGetBorder(iwSrc, borderType, iwBorderSize);
+ if(!iwBorderType.m_borderType || ((iwBorderType.m_borderFlags&ippBorderInMem) && (iwBorderType.m_borderFlags&ippBorderInMem) != ippBorderInMem))
+ return false;
- rectKernel = false;
- if( kernel.empty() )
+ if(iwBorderType.m_borderType == ippBorderConst)
{
- ksize = Size(1+iterations*2,1+iterations*2);
- anchor = ippiPoint(iterations, iterations);
- rectKernel = true;
- iterations = 1;
+ if(Vec<double, 4>(borderValue) == morphologyDefaultBorderValue())
+ iwBorderType.m_borderType = ippBorderDefault;
+ else
+ iwBorderType.SetValue(borderValue[0], borderValue[1], borderValue[2], borderValue[3]);
}
- else if( iterations >= 1 && countNonZero(kernel) == kernel.rows*kernel.cols )
+ if(morphType != iwiMorphErode && morphType != iwiMorphDilate)
{
- ksize = Size(ksize.width + (iterations-1)*(ksize.width-1),
- ksize.height + (iterations-1)*(ksize.height-1)),
- anchor = ippiPoint(anchor.x*iterations, anchor.y*iterations);
- kernel = Mat();
- rectKernel = true;
- iterations = 1;
+ if((iwBorderType.m_borderFlags&ippBorderInMem) == ippBorderInMem)
+ iwBorderType.m_borderFlags = ippBorderFirstStageInMem;
}
- // TODO: implement the case of iterations > 1.
- if( iterations > 1 )
- return false;
-
- IppiSize roiSize = {max_width, max_height};
- kernelSize = ippiSize(ksize);
- op = _op;
-
- IppStatus res;
- if (!rectKernel)
+ // Test input parameters on dummy structures
{
- if (((kernel.cols - 1) / 2 != anchor.x) || ((kernel.rows - 1) / 2 != anchor.y))
- return false;
- int specSize = 0, bufferSize = 0;
- res = trait.getMorphSize(roiSize, kernelSize, &specSize, &bufferSize);
- if (res >= 0)
- {
- specBuf.Alloc(specSize);
- workBuf.Alloc(bufferSize);
- res = trait.morphInit(roiSize, kernel.ptr(), kernelSize, specBuf, workBuf);
- if (res >= 0)
- return true;
- }
+ ::ipp::IwiImage testSrc(initSize, type, channels);
+ ::ipp::IwiImage testDst(initSize, type, channels);
+ ::ipp::IwiImage testMask(ippiSize(kernel_width, kernel_height), ipp8u, CV_MAT_CN(kernel_type));
+
+ ::ipp::iwiFilterMorphology(&testSrc, &testDst, morphType, &testMask, &anchor, iwBorderType);
}
- else
+
+ iwMask.Init(ippiSize(kernel_width, kernel_height), ippiGetDataType(CV_MAT_DEPTH(kernel_type)), CV_MAT_CN(kernel_type), 0, kernel_data, kernel_step);
+ if((int)kernel_step != kernel_width || CV_MAT_DEPTH(kernel_type) != CV_8U)
{
- if (((kernelSize.width - 1) / 2 != anchor.x) || ((kernelSize.height - 1) / 2 != anchor.y))
- return false;
- if (op == MORPH_ERODE)
- {
- int bufSize = 0;
- res = trait.filterGetMinSize(roiSize, kernelSize, trait.getDataType(), trait.cn, &bufSize);
- if (res >= 0)
- {
- workBuf.Alloc(bufSize);
- return true;
- }
- }
- else
- {
- int bufSize = 0;
- res = trait.filterGetMaxSize(roiSize, kernelSize, trait.getDataType(), trait.cn, &bufSize);
- if (res >= 0)
- {
- workBuf.Alloc(bufSize);
- return true;
- }
- }
+ kernelTempBuffer.Alloc(kernel_width*kernel_height);
+ ::ipp::IwiImage iwMaskTmp(ippiSize(kernel_width, kernel_height), ipp8u, 1, 0, kernelTempBuffer, kernel_width);
+ ::ipp::iwiScale(&iwMask, &iwMaskTmp, 1, 0);
+ iwMask = iwMaskTmp;
}
- return false;
- }
-
- void apply(uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height,
- int roi_width, int roi_height, int roi_x, int roi_y,
- int roi_width2, int roi_height2, int roi_x2, int roi_y2)
- {
- CV_INSTRUMENT_REGION_IPP()
- CV_UNUSED(roi_width); CV_UNUSED(roi_height); CV_UNUSED(roi_x); CV_UNUSED(roi_y);
- CV_UNUSED(roi_width2); CV_UNUSED(roi_height2); CV_UNUSED(roi_x2); CV_UNUSED(roi_y2);
- if (src_data == dst_data)
- CV_Error(Error::StsBadArg, "IPP Morph inplace is not alowed");
+ if(iterations > 1)
+ {
+ iwInter.Alloc(initSize, type, channels);
- IppiSize roiSize = {width, height};
+ ::ipp::IwiImage *pSwap[2] = {&iwInter, &iwDst};
+ ::ipp::IwiBorderType iterBorder = iwBorderType;
+ iterBorder.m_borderFlags = 0;
+ CV_INSTRUMENT_FUN_IPP(::ipp::iwiFilterMorphology, &iwSrc, &iwInter, morphType, &iwMask, NULL, iwBorderType);
- IppStatus res;
- if (!rectKernel)
- {
- if (op == MORPH_ERODE)
- res = (trait.morphErode((ipp_data_type*)src_data, (int)src_step, (ipp_data_type*)dst_data, (int)dst_step, roiSize, specBuf, workBuf));
- else
- res = (trait.morphDilate((ipp_data_type*)src_data, (int)src_step, (ipp_data_type*)dst_data, (int)dst_step, roiSize, specBuf, workBuf));
+ for(int i = 0; i < iterations-1; i++)
+ CV_INSTRUMENT_FUN_IPP(::ipp::iwiFilterMorphology, pSwap[i&0x1], pSwap[(i+1)&0x1], morphType, &iwMask, NULL, iterBorder);
+ if(iterations&0x1)
+ CV_INSTRUMENT_FUN_IPP(::ipp::iwiCopyMask, &iwInter, &iwDst);
}
else
{
- if (op == MORPH_ERODE)
- res = (trait.filterMinBorder((ipp_data_type*)src_data, (int)src_step, (ipp_data_type*)dst_data, (int)dst_step, roiSize, kernelSize, anchor, workBuf));
+ if(src_data == dst_data)
+ {
+ iwInter.Alloc(initSize, type, channels);
+
+ CV_INSTRUMENT_FUN_IPP(::ipp::iwiFilterMorphology, &iwSrc, &iwInter, morphType, &iwMask, NULL, iwBorderType);
+ CV_INSTRUMENT_FUN_IPP(::ipp::iwiCopyMask, &iwInter, &iwDst);
+ }
else
- res = (trait.filterMaxBorder((ipp_data_type*)src_data, (int)src_step, (ipp_data_type*)dst_data, (int)dst_step, roiSize, kernelSize, anchor, workBuf));
+ CV_INSTRUMENT_FUN_IPP(::ipp::iwiFilterMorphology, &iwSrc, &iwDst, morphType, &iwMask, NULL, iwBorderType);
}
- if (res < 0)
- CV_Error(Error::StsBadArg, "Failed to run IPP morph");
}
-};
-
-static IppMorphBaseImpl * createIppImpl(int type)
-{
- switch (type)
+ catch(::ipp::IwException ex)
{
- case CV_8UC1: return new IppMorphImpl<CV_8UC1>();
- case CV_8UC3: return new IppMorphImpl<CV_8UC3>();
- case CV_8UC4: return new IppMorphImpl<CV_8UC4>();
- case CV_32FC1: return new IppMorphImpl<CV_32FC1>();
- case CV_32FC3: return new IppMorphImpl<CV_32FC3>();
- case CV_32FC4: return new IppMorphImpl<CV_32FC4>();
+ return false;
}
- return 0;
-}
-#endif // IPP_VERSION_X100 >= 810
+ return true;
+#else
+ CV_UNUSED(op); CV_UNUSED(src_type); CV_UNUSED(dst_type); CV_UNUSED(src_data); CV_UNUSED(src_step); CV_UNUSED(dst_data);
+ CV_UNUSED(dst_step); CV_UNUSED(width); CV_UNUSED(height); CV_UNUSED(roi_width); CV_UNUSED(roi_height);
+ CV_UNUSED(roi_x); CV_UNUSED(roi_y); CV_UNUSED(roi_width2); CV_UNUSED(roi_height2); CV_UNUSED(roi_x2); CV_UNUSED(roi_y2);
+ CV_UNUSED(kernel_type); CV_UNUSED(kernel_data); CV_UNUSED(kernel_step); CV_UNUSED(kernel_width); CV_UNUSED(kernel_height);
+ CV_UNUSED(anchor_x); CV_UNUSED(anchor_y); CV_UNUSED(borderType); CV_UNUSED(borderValue); CV_UNUSED(iterations);
+ CV_UNUSED(isSubmatrix);
+ return false;
+#endif
+};
+
#endif // HAVE_IPP
// ===== 3. Fallback implementation
-struct OcvMorphImpl : public hal::Morph
+static void ocvMorph(int op, int src_type, int dst_type,
+ uchar * src_data, size_t src_step,
+ uchar * dst_data, size_t dst_step,
+ int width, int height,
+ int roi_width, int roi_height, int roi_x, int roi_y,
+ int roi_width2, int roi_height2, int roi_x2, int roi_y2,
+ int kernel_type, uchar * kernel_data, size_t kernel_step,
+ int kernel_width, int kernel_height, int anchor_x, int anchor_y,
+ int borderType, const double borderValue[4], int iterations)
{
- Ptr<FilterEngine> f;
- int iterations;
- int src_type;
- int dst_type;
- bool init(int op, int _src_type, int _dst_type, int, int,
- int kernel_type, uchar * kernel_data, size_t kernel_step, int kernel_width, int kernel_height,
- int anchor_x, int anchor_y,
- int borderType, const double _borderValue[4],
- int _iterations, bool, bool)
+ Mat kernel(Size(kernel_width, kernel_height), kernel_type, kernel_data, kernel_step);
+ Point anchor(anchor_x, anchor_y);
+ Vec<double, 4> borderVal(borderValue);
+ Ptr<FilterEngine> f = createMorphologyFilter(op, src_type, kernel, anchor, borderType, borderType, borderVal);
+ Mat src(Size(width, height), src_type, src_data, src_step);
+ Mat dst(Size(width, height), dst_type, dst_data, dst_step);
{
- iterations = _iterations;
- src_type = _src_type;
- dst_type = _dst_type;
- Mat kernel(Size(kernel_width, kernel_height), kernel_type, kernel_data, kernel_step);
- Point anchor(anchor_x, anchor_y);
- Vec<double, 4> borderValue(_borderValue);
- f = createMorphologyFilter(op, src_type, kernel, anchor, borderType, borderType, borderValue );
- return true;
+ Point ofs(roi_x, roi_y);
+ Size wsz(roi_width, roi_height);
+ f->apply( src, dst, wsz, ofs );
}
-
- void apply(uchar * src_data, size_t src_step, uchar * dst_data, size_t dst_step, int width, int height,
- int roi_width, int roi_height, int roi_x, int roi_y,
- int roi_width2, int roi_height2, int roi_x2, int roi_y2)
{
- Mat src(Size(width, height), src_type, src_data, src_step);
- Mat dst(Size(width, height), dst_type, dst_data, dst_step);
- {
- Point ofs(roi_x, roi_y);
- Size wsz(roi_width, roi_height);
- f->apply( src, dst, wsz, ofs );
- }
- {
- Point ofs(roi_x2, roi_y2);
- Size wsz(roi_width2, roi_height2);
- for( int i = 1; i < iterations; i++ )
- f->apply( dst, dst, wsz, ofs );
- }
+ Point ofs(roi_x2, roi_y2);
+ Size wsz(roi_width2, roi_height2);
+ for( int i = 1; i < iterations; i++ )
+ f->apply( dst, dst, wsz, ofs );
}
-};
+}
+
// ===== HAL interface implementation
namespace hal {
-Ptr<Morph> Morph ::create(int op, int src_type, int dst_type, int max_width, int max_height,
- int kernel_type, uchar * kernel_data, size_t kernel_step, int kernel_width, int kernel_height,
- int anchor_x, int anchor_y,
- int borderType, const double borderValue[4],
- int iterations, bool isSubmatrix, bool allowInplace)
+
+CV_DEPRECATED Ptr<Morph> Morph::create(int , int , int , int , int ,
+ int , uchar * , size_t ,
+ int , int ,
+ int , int ,
+ int , const double *,
+ int , bool , bool ) { return Ptr<hal::Morph>(); }
+
+
+void morph(int op, int src_type, int dst_type,
+ uchar * src_data, size_t src_step,
+ uchar * dst_data, size_t dst_step,
+ int width, int height,
+ int roi_width, int roi_height, int roi_x, int roi_y,
+ int roi_width2, int roi_height2, int roi_x2, int roi_y2,
+ int kernel_type, uchar * kernel_data, size_t kernel_step,
+ int kernel_width, int kernel_height, int anchor_x, int anchor_y,
+ int borderType, const double borderValue[4], int iterations, bool isSubmatrix)
{
{
- ReplacementMorphImpl * impl = new ReplacementMorphImpl();
- if (impl->init(op, src_type, dst_type, max_width, max_height,
- kernel_type, kernel_data, kernel_step, kernel_width, kernel_height,
- anchor_x, anchor_y,
- borderType, borderValue, iterations, isSubmatrix, allowInplace))
- {
- return Ptr<Morph>(impl);
- }
- delete impl;
- }
-#if defined(HAVE_IPP) && IPP_VERSION_X100 >= 810
- CV_IPP_CHECK()
- {
- IppMorphBaseImpl * impl = createIppImpl(src_type);
- if (impl)
- {
- if (impl->init(op, src_type, dst_type, max_width, max_height,
- kernel_type, kernel_data, kernel_step, kernel_width, kernel_height,
- anchor_x, anchor_y,
- borderType, borderValue, iterations, isSubmatrix, allowInplace))
- {
- return Ptr<Morph>(impl);
- }
- delete impl;
- }
- }
-#endif
- {
- OcvMorphImpl * impl = new OcvMorphImpl();
- impl->init(op, src_type, dst_type, max_width, max_height,
- kernel_type, kernel_data, kernel_step, kernel_width, kernel_height,
- anchor_x, anchor_y,
- borderType, borderValue, iterations, isSubmatrix, allowInplace);
- return Ptr<Morph>(impl);
+ bool res = halMorph(op, src_type, dst_type, src_data, src_step, dst_data, dst_step, width, height,
+ roi_width, roi_height, roi_x, roi_y,
+ roi_width2, roi_height2, roi_x2, roi_y2,
+ kernel_type, kernel_data, kernel_step,
+ kernel_width, kernel_height, anchor_x, anchor_y,
+ borderType, borderValue, iterations, isSubmatrix);
+ if (res)
+ return;
}
+
+ CV_IPP_RUN_FAST(ippMorph(op, src_type, dst_type, src_data, src_step, dst_data, dst_step, width, height,
+ roi_width, roi_height, roi_x, roi_y,
+ roi_width2, roi_height2, roi_x2, roi_y2,
+ kernel_type, kernel_data, kernel_step,
+ kernel_width, kernel_height, anchor_x, anchor_y,
+ borderType, borderValue, iterations, isSubmatrix));
+
+ ocvMorph(op, src_type, dst_type, src_data, src_step, dst_data, dst_step, width, height,
+ roi_width, roi_height, roi_x, roi_y,
+ roi_width2, roi_height2, roi_x2, roi_y2,
+ kernel_type, kernel_data, kernel_step,
+ kernel_width, kernel_height, anchor_x, anchor_y,
+ borderType, borderValue, iterations);
}
} // cv::hal
@@ -1761,7 +1635,7 @@ static bool ocl_morphOp(InputArray _src, OutputArray _dst, InputArray _kernel,
return true;
}
-#ifdef ANDROID
+#ifdef __ANDROID__
size_t localThreads[2] = { 16, 8 };
#else
size_t localThreads[2] = { 16, 16 };
@@ -1776,7 +1650,7 @@ static bool ocl_morphOp(InputArray _src, OutputArray _dst, InputArray _kernel,
if (localThreads[0]*localThreads[1] * 2 < (localThreads[0] + ksize.width - 1) * (localThreads[1] + ksize.height - 1))
return false;
-#ifdef ANDROID
+#ifdef __ANDROID__
if (dev.isNVidia())
return false;
#endif
@@ -1892,6 +1766,8 @@ static void morphOp( int op, InputArray _src, OutputArray _dst,
Point anchor, int iterations,
int borderType, const Scalar& borderValue )
{
+ CV_INSTRUMENT_REGION()
+
Mat kernel = _kernel.getMat();
Size ksize = !kernel.empty() ? kernel.size() : Size(3,3);
anchor = normalizeAnchor(anchor, ksize);
@@ -1941,13 +1817,15 @@ static void morphOp( int op, InputArray _src, OutputArray _dst,
dst.locateROI(d_wsz, d_ofs);
}
- Ptr<hal::Morph> ctx = hal::Morph::create(op, src.type(), dst.type(), src.cols, src.rows,
- kernel.type(), kernel.data, kernel.step, kernel.cols, kernel.rows,
- anchor.x, anchor.y, borderType, borderValue.val, iterations,
- (src.isSubmatrix() && !isolated), src.data == dst.data);
- ctx->apply(src.data, src.step, dst.data, dst.step, src.cols, src.rows,
+ hal::morph(op, src.type(), dst.type(),
+ src.data, src.step,
+ dst.data, dst.step,
+ src.cols, src.rows,
s_wsz.width, s_wsz.height, s_ofs.x, s_ofs.y,
- d_wsz.width, d_wsz.height, d_ofs.x, d_ofs.y);
+ d_wsz.width, d_wsz.height, d_ofs.x, d_ofs.y,
+ kernel.type(), kernel.data, kernel.step, kernel.cols, kernel.rows, anchor.x, anchor.y,
+ borderType, borderValue.val, iterations,
+ (src.isSubmatrix() && !isolated));
}
}
@@ -2032,7 +1910,77 @@ static bool ocl_morphologyEx(InputArray _src, OutputArray _dst, int op,
}
}
+#endif
+
+#ifdef HAVE_IPP
+#if !IPP_DISABLE_MORPH_ADV
+namespace cv {
+static bool ipp_morphologyEx(int op, InputArray _src, OutputArray _dst,
+ InputArray _kernel,
+ Point anchor, int iterations,
+ int borderType, const Scalar& borderValue)
+{
+#if defined HAVE_IPP_IW
+ Mat kernel = _kernel.getMat();
+ Size ksize = !kernel.empty() ? kernel.size() : Size(3,3);
+ anchor = normalizeAnchor(anchor, ksize);
+
+ if (iterations == 0 || kernel.rows*kernel.cols == 1)
+ {
+ _src.copyTo(_dst);
+ return true;
+ }
+
+ if (kernel.empty())
+ {
+ kernel = getStructuringElement(MORPH_RECT, Size(1+iterations*2,1+iterations*2));
+ anchor = Point(iterations, iterations);
+ iterations = 1;
+ }
+ else if( iterations > 1 && countNonZero(kernel) == kernel.rows*kernel.cols )
+ {
+ anchor = Point(anchor.x*iterations, anchor.y*iterations);
+ kernel = getStructuringElement(MORPH_RECT,
+ Size(ksize.width + (iterations-1)*(ksize.width-1),
+ ksize.height + (iterations-1)*(ksize.height-1)),
+ anchor);
+ iterations = 1;
+ }
+
+ Mat src = _src.getMat();
+ _dst.create( src.size(), src.type() );
+ Mat dst = _dst.getMat();
+
+ Point s_ofs;
+ Size s_wsz(src.cols, src.rows);
+ Point d_ofs;
+ Size d_wsz(dst.cols, dst.rows);
+ bool isolated = (borderType&BORDER_ISOLATED)?true:false;
+ borderType = (borderType&~BORDER_ISOLATED);
+ if(!isolated)
+ {
+ src.locateROI(s_wsz, s_ofs);
+ dst.locateROI(d_wsz, d_ofs);
+ }
+
+ return ippMorph(op, src.type(), dst.type(),
+ src.data, src.step,
+ dst.data, dst.step,
+ src.cols, src.rows,
+ s_wsz.width, s_wsz.height, s_ofs.x, s_ofs.y,
+ d_wsz.width, d_wsz.height, d_ofs.x, d_ofs.y,
+ kernel.type(), kernel.data, kernel.step, kernel.cols, kernel.rows, anchor.x, anchor.y,
+ borderType, borderValue.val, iterations,
+ (src.isSubmatrix() && !isolated));
+#else
+ CV_UNUSED(op); CV_UNUSED(_src); CV_UNUSED(_dst); CV_UNUSED(_kernel); CV_UNUSED(anchor);
+ CV_UNUSED(iterations); CV_UNUSED(borderType); CV_UNUSED(borderValue);
+ return false;
+#endif
+}
+}
+#endif
#endif
void cv::morphologyEx( InputArray _src, OutputArray _dst, int op,
@@ -2060,7 +2008,9 @@ void cv::morphologyEx( InputArray _src, OutputArray _dst, int op,
_dst.create(src.size(), src.type());
Mat dst = _dst.getMat();
- Mat k1, k2, e1, e2; //only for hit and miss op
+#if !IPP_DISABLE_MORPH_ADV
+ CV_IPP_RUN_FAST(ipp_morphologyEx(op, src, dst, kernel, anchor, iterations, borderType, borderValue));
+#endif
switch( op )
{
@@ -2099,21 +2049,29 @@ void cv::morphologyEx( InputArray _src, OutputArray _dst, int op,
break;
case MORPH_HITMISS:
CV_Assert(src.type() == CV_8UC1);
- k1 = (kernel == 1);
- k2 = (kernel == -1);
- if (countNonZero(k1) <= 0)
- e1 = src;
- else
- erode(src, e1, k1, anchor, iterations, borderType, borderValue);
- if (countNonZero(k2) <= 0)
- e2 = src;
- else
+ if(countNonZero(kernel) <=0)
+ {
+ src.copyTo(dst);
+ break;
+ }
{
+ Mat k1, k2, e1, e2;
+ k1 = (kernel == 1);
+ k2 = (kernel == -1);
+
+ if (countNonZero(k1) <= 0)
+ e1 = src;
+ else
+ erode(src, e1, k1, anchor, iterations, borderType, borderValue);
+
Mat src_complement;
bitwise_not(src, src_complement);
- erode(src_complement, e2, k2, anchor, iterations, borderType, borderValue);
+ if (countNonZero(k2) <= 0)
+ e2 = src_complement;
+ else
+ erode(src_complement, e2, k2, anchor, iterations, borderType, borderValue);
+ dst = e1 & e2;
}
- dst = e1 & e2;
break;
default:
CV_Error( CV_StsBadArg, "unknown morphological operation" );
diff --git a/modules/imgproc/src/opencl/clahe.cl b/modules/imgproc/src/opencl/clahe.cl
index 187933c..ba69085 100644
--- a/modules/imgproc/src/opencl/clahe.cl
+++ b/modules/imgproc/src/opencl/clahe.cl
@@ -186,21 +186,13 @@ __kernel void calcLut(__global __const uchar * src, const int srcStep,
#else
clipped = smem[0];
#endif
-
- // broadcast evaluated value
-
- __local int totalClipped;
-
- if (tid == 0)
- totalClipped = clipped;
barrier(CLK_LOCAL_MEM_FENCE);
// redistribute clipped samples evenly
-
- int redistBatch = totalClipped / 256;
+ int redistBatch = clipped / 256;
tHistVal += redistBatch;
- int residual = totalClipped - redistBatch * 256;
+ int residual = clipped - redistBatch * 256;
int rStep = 256 / residual;
if (rStep < 1)
rStep = 1;
diff --git a/modules/imgproc/src/opencl/cvtcolor.cl b/modules/imgproc/src/opencl/cvtcolor.cl
index 9ceafd7..52bef00 100644
--- a/modules/imgproc/src/opencl/cvtcolor.cl
+++ b/modules/imgproc/src/opencl/cvtcolor.cl
@@ -132,16 +132,10 @@ enum
#define R_COMP z
#define G_COMP y
#define B_COMP x
-#elif bidx == 2
+#else
#define R_COMP x
#define G_COMP y
#define B_COMP z
-#elif bidx == 3
-// The only kernel that uses bidx == 3 doesn't use these macros.
-// But we still need to make the compiler happy.
-#define R_COMP w
-#define G_COMP w
-#define B_COMP w
#endif
#ifndef uidx
@@ -160,6 +154,7 @@ enum
#define CAT(x, y) __CAT(x, y)
#define DATA_TYPE_4 CAT(DATA_TYPE, 4)
+#define DATA_TYPE_3 CAT(DATA_TYPE, 3)
///////////////////////////////////// RGB <-> GRAY //////////////////////////////////////
@@ -182,7 +177,7 @@ __kernel void RGB2Gray(__global const uchar * srcptr, int src_step, int src_offs
{
__global const DATA_TYPE* src = (__global const DATA_TYPE*)(srcptr + src_index);
__global DATA_TYPE* dst = (__global DATA_TYPE*)(dstptr + dst_index);
- DATA_TYPE_4 src_pix = vload4(0, src);
+ DATA_TYPE_3 src_pix = vload3(0, src);
#ifdef DEPTH_5
dst[0] = fma(src_pix.B_COMP, B2YF, fma(src_pix.G_COMP, G2YF, src_pix.R_COMP * R2YF));
#else
@@ -256,7 +251,7 @@ __kernel void RGB2YUV(__global const uchar* srcptr, int src_step, int src_offset
{
__global const DATA_TYPE* src = (__global const DATA_TYPE*)(srcptr + src_index);
__global DATA_TYPE* dst = (__global DATA_TYPE*)(dstptr + dst_index);
- DATA_TYPE_4 src_pix = vload4(0, src);
+ DATA_TYPE_3 src_pix = vload3(0, src);
DATA_TYPE b = src_pix.B_COMP, g = src_pix.G_COMP, r = src_pix.R_COMP;
#ifdef DEPTH_5
@@ -1760,6 +1755,7 @@ __kernel void BGR2Lab(__global const uchar * srcptr, int src_step, int src_offse
B = splineInterpolate(B * GammaTabScale, gammaTab, GAMMA_TAB_SIZE);
#endif
+ // 7.787f = (29/3)^3/(29*4), 0.008856f = (6/29)^3, 903.3 = (29/3)^3
float X = fma(R, C0, fma(G, C1, B*C2));
float Y = fma(R, C3, fma(G, C4, B*C5));
float Z = fma(R, C6, fma(G, C7, B*C8));
@@ -1799,6 +1795,7 @@ inline void Lab2BGR_f(const float * srcbuf, float * dstbuf,
C6 = coeffs[6], C7 = coeffs[7], C8 = coeffs[8];
float y, fy;
+ // 903.3 = (29/3)^3, 7.787 = (29/3)^3/(29*4)
if (li <= lThresh)
{
y = li / 903.3f;
@@ -1968,6 +1965,10 @@ __kernel void BGR2Luv(__global const uchar * srcptr, int src_step, int src_offse
float R = src[0], G = src[1], B = src[2];
+ R = clamp(R, 0.f, 1.f);
+ G = clamp(G, 0.f, 1.f);
+ B = clamp(B, 0.f, 1.f);
+
#ifdef SRGB
R = splineInterpolate(R*GammaTabScale, gammaTab, GAMMA_TAB_SIZE);
G = splineInterpolate(G*GammaTabScale, gammaTab, GAMMA_TAB_SIZE);
@@ -2036,7 +2037,9 @@ __kernel void BGR2Luv(__global const uchar * src, int src_step, int src_offset,
float v = L*fma(2.25f, Y*d, -_vn);
dst[0] = SAT_CAST(L * 2.55f);
+ //0.72033 = 255/(220+134), 96.525 = 134*255/(220+134)
dst[1] = SAT_CAST(fma(u, 0.72033898305084743f, 96.525423728813564f));
+ //0.9732 = 255/(140+122), 136.259 = 140*255/(140+122)
dst[2] = SAT_CAST(fma(v, 0.9732824427480916f, 136.259541984732824f));
++y;
@@ -2072,15 +2075,21 @@ __kernel void Luv2BGR(__global const uchar * srcptr, int src_step, int src_offse
__global const float * src = (__global const float *)(srcptr + src_index);
__global float * dst = (__global float *)(dstptr + dst_index);
- float L = src[0], u = src[1], v = src[2], d, X, Y, Z;
- Y = (L + 16.f) * (1.f/116.f);
- Y = Y*Y*Y;
- d = (1.f/13.f)/L;
- u = fma(u, d, _un);
- v = fma(v, d, _vn);
- float iv = 1.f/v;
- X = 2.25f * u * Y * iv;
- Z = (12 - fma(3.0f, u, 20.0f * v)) * Y * 0.25f * iv;
+ float L = src[0], u = src[1], v = src[2], X, Y, Z;
+ if(L >= 8)
+ {
+ Y = fma(L, 1.f/116.f, 16.f/116.f);
+ Y = Y*Y*Y;
+ }
+ else
+ {
+ Y = L * (1.0f/903.3f); // L*(3./29.)^3
+ }
+ float up = 3.f*fma(L, _un, u);
+ float vp = 0.25f/fma(L, _vn, v);
+ vp = clamp(vp, -0.25f, 0.25f);
+ X = 3.f*Y*up*vp;
+ Z = Y*fma(fma(12.f*13.f, L, -up), vp, -5.f);
float R = fma(X, coeffs[0], fma(Y, coeffs[1], Z * coeffs[2]));
float G = fma(X, coeffs[3], fma(Y, coeffs[4], Z * coeffs[5]));
@@ -2132,16 +2141,24 @@ __kernel void Luv2BGR(__global const uchar * src, int src_step, int src_offset,
{
float d, X, Y, Z;
float L = src[0]*(100.f/255.f);
+ // 1.388235294117647 = (220+134)/255
float u = fma(convert_float(src[1]), 1.388235294117647f, -134.f);
+ // 1.027450980392157 = (140+122)/255
float v = fma(convert_float(src[2]), 1.027450980392157f, - 140.f);
- Y = (L + 16.f) * (1.f/116.f);
- Y = Y*Y*Y;
- d = (1.f/13.f)/L;
- u = fma(u, d, _un);
- v = fma(v, d, _vn);
- float iv = 1.f/v;
- X = 2.25f * u * Y * iv ;
- Z = (12 - fma(3.0f, u, 20.0f * v)) * Y * 0.25f * iv;
+ if(L >= 8)
+ {
+ Y = fma(L, 1.f/116.f, 16.f/116.f);
+ Y = Y*Y*Y;
+ }
+ else
+ {
+ Y = L * (1.0f/903.3f); // L*(3./29.)^3
+ }
+ float up = 3.f*fma(L, _un, u);
+ float vp = 0.25f/fma(L, _vn, v);
+ vp = clamp(vp, -0.25f, 0.25f);
+ X = 3.f*Y*up*vp;
+ Z = Y*fma(fma(12.f*13.f, L, -up), vp, -5.f);
float R = fma(X, coeffs[0], fma(Y, coeffs[1], Z * coeffs[2]));
float G = fma(X, coeffs[3], fma(Y, coeffs[4], Z * coeffs[5]));
diff --git a/modules/imgproc/src/precomp.hpp b/modules/imgproc/src/precomp.hpp
index 20a43a6..55241d9 100644
--- a/modules/imgproc/src/precomp.hpp
+++ b/modules/imgproc/src/precomp.hpp
@@ -69,7 +69,7 @@
/* helper tables */
extern const uchar icvSaturate8u_cv[];
-#define CV_FAST_CAST_8U(t) (assert(-256 <= (t) && (t) <= 512), icvSaturate8u_cv[(t)+256])
+#define CV_FAST_CAST_8U(t) ( (-256 <= (t) && (t) <= 512) ? icvSaturate8u_cv[(t)+256] : 0 )
#define CV_CALC_MIN_8U(a,b) (a) -= CV_FAST_CAST_8U((a) - (b))
#define CV_CALC_MAX_8U(a,b) (a) += CV_FAST_CAST_8U((b) - (a))
@@ -93,9 +93,33 @@ extern const float icv8x32fSqrTab[];
#undef CV_CALC_MAX
#define CV_CALC_MAX(a, b) if((a) < (b)) (a) = (b)
+#ifdef HAVE_IPP
+static inline IppiInterpolationType ippiGetInterpolation(int inter)
+{
+ inter &= cv::INTER_MAX;
+ return inter == cv::INTER_NEAREST ? ippNearest :
+ inter == cv::INTER_LINEAR ? ippLinear :
+ inter == cv::INTER_CUBIC ? ippCubic :
+ inter == cv::INTER_LANCZOS4 ? ippLanczos :
+ inter == cv::INTER_AREA ? ippSuper :
+ (IppiInterpolationType)-1;
+}
+#endif
+
#include "_geom.h"
#include "filterengine.hpp"
#include "opencv2/core/sse_utils.hpp"
+inline bool isStorageOrMat(void * arr)
+{
+ if (CV_IS_STORAGE( arr ))
+ return true;
+ else if (CV_IS_MAT( arr ))
+ return false;
+ else
+ CV_Error( CV_StsBadArg, "Destination is not CvMemStorage* nor CvMat*" );
+ return false;
+}
+
#endif /*__OPENCV_CV_INTERNAL_H_*/
diff --git a/modules/imgproc/src/pyramids.cpp b/modules/imgproc/src/pyramids.cpp
index c0e18c1..7f42f56 100644
--- a/modules/imgproc/src/pyramids.cpp
+++ b/modules/imgproc/src/pyramids.cpp
@@ -1200,7 +1200,7 @@ static bool ipp_pyrdown( InputArray _src, OutputArray _dst, const Size& _dsz, in
{
CV_INSTRUMENT_REGION_IPP()
-#if IPP_VERSION_X100 >= 810 && IPP_DISABLE_BLOCK
+#if IPP_VERSION_X100 >= 810 && !IPP_DISABLE_PYRAMIDS_DOWN
Size dsz = _dsz.area() == 0 ? Size((_src.cols() + 1)/2, (_src.rows() + 1)/2) : _dsz;
bool isolated = (borderType & BORDER_ISOLATED) != 0;
int borderTypeNI = borderType & ~BORDER_ISOLATED;
@@ -1235,7 +1235,7 @@ static bool ipp_pyrdown( InputArray _src, OutputArray _dst, const Size& _dsz, in
CV_SUPPRESS_DEPRECATED_END
if (ok >= 0)
{
- Ipp8u* buffer = ippsMalloc_8u(bufferSize);
+ Ipp8u* buffer = ippsMalloc_8u_L(bufferSize);
ok = pyrUpFunc(src.data, (int) src.step, dst.data, (int) dst.step, srcRoi, buffer);
ippsFree(buffer);
@@ -1265,6 +1265,9 @@ static bool openvx_pyrDown( InputArray _src, OutputArray _dst, const Size& _dsz,
Mat srcMat = _src.getMat();
+ if (ovx::skipSmallImages<VX_KERNEL_HALFSCALE_GAUSSIAN>(srcMat.cols, srcMat.rows))
+ return false;
+
CV_Assert(!srcMat.empty());
Size ssize = _src.size();
@@ -1290,7 +1293,7 @@ static bool openvx_pyrDown( InputArray _src, OutputArray _dst, const Size& _dsz,
try
{
- Context context = Context::create();
+ Context context = ovx::getOpenVXContext();
if(context.vendorID() == VX_ID_KHRONOS)
{
// This implementation performs floor-like rounding
@@ -1388,7 +1391,7 @@ static bool ipp_pyrup( InputArray _src, OutputArray _dst, const Size& _dsz, int
{
CV_INSTRUMENT_REGION_IPP()
-#if IPP_VERSION_X100 >= 810 && IPP_DISABLE_BLOCK
+#if IPP_VERSION_X100 >= 810 && !IPP_DISABLE_PYRAMIDS_UP
Size sz = _src.dims() <= 2 ? _src.size() : Size();
Size dsz = _dsz.area() == 0 ? Size(_src.cols()*2, _src.rows()*2) : _dsz;
@@ -1421,7 +1424,7 @@ static bool ipp_pyrup( InputArray _src, OutputArray _dst, const Size& _dsz, int
CV_SUPPRESS_DEPRECATED_END
if (ok >= 0)
{
- Ipp8u* buffer = ippsMalloc_8u(bufferSize);
+ Ipp8u* buffer = ippsMalloc_8u_L(bufferSize);
ok = pyrUpFunc(src.data, (int) src.step, dst.data, (int) dst.step, srcRoi, buffer);
ippsFree(buffer);
@@ -1496,7 +1499,7 @@ static bool ipp_buildpyramid( InputArray _src, OutputArrayOfArrays _dst, int max
{
CV_INSTRUMENT_REGION_IPP()
-#if IPP_VERSION_X100 >= 810 && IPP_DISABLE_BLOCK
+#if IPP_VERSION_X100 >= 810 && !IPP_DISABLE_PYRAMIDS_BUILD
Mat src = _src.getMat();
_dst.create( maxlevel + 1, 1, 0 );
_dst.getMatRef(0) = src;
@@ -1626,7 +1629,7 @@ void cv::buildPyramid( InputArray _src, OutputArrayOfArrays _dst, int maxlevel,
int i=1;
- CV_IPP_RUN(((IPP_VERSION_X100 >= 810 && IPP_DISABLE_BLOCK) && ((borderType & ~BORDER_ISOLATED) == BORDER_DEFAULT && (!_src.isSubmatrix() || ((borderType & BORDER_ISOLATED) != 0)))),
+ CV_IPP_RUN(((IPP_VERSION_X100 >= 810) && ((borderType & ~BORDER_ISOLATED) == BORDER_DEFAULT && (!_src.isSubmatrix() || ((borderType & BORDER_ISOLATED) != 0)))),
ipp_buildpyramid( _src, _dst, maxlevel, borderType));
for( ; i <= maxlevel; i++ )
diff --git a/modules/imgproc/src/samplers.cpp b/modules/imgproc/src/samplers.cpp
index df9a2ef..818b29d 100644
--- a/modules/imgproc/src/samplers.cpp
+++ b/modules/imgproc/src/samplers.cpp
@@ -441,7 +441,7 @@ cvGetQuadrangleSubPix( const void* srcarr, void* dstarr, const CvMat* mat )
CV_Assert( src.channels() == dst.channels() );
cv::Size win_size = dst.size();
- double matrix[6];
+ double matrix[6] = {0};
cv::Mat M(2, 3, CV_64F, matrix);
m.convertTo(M, CV_64F);
double dx = (win_size.width - 1)*0.5;
diff --git a/modules/imgproc/src/shapedescr.cpp b/modules/imgproc/src/shapedescr.cpp
index 56186bb..9661c26 100644
--- a/modules/imgproc/src/shapedescr.cpp
+++ b/modules/imgproc/src/shapedescr.cpp
@@ -359,7 +359,7 @@ cv::RotatedRect cv::fitEllipse( InputArray _points )
// New fitellipse algorithm, contributed by Dr. Daniel Weiss
Point2f c(0,0);
- double gfp[5], rp[5], t;
+ double gfp[5] = {0}, rp[5] = {0}, t;
const double min_eps = 1e-8;
bool is_float = depth == CV_32F;
const Point* ptsi = points.ptr<Point>();
diff --git a/modules/imgproc/src/smooth.cpp b/modules/imgproc/src/smooth.cpp
index d8514da..dbddd33 100644
--- a/modules/imgproc/src/smooth.cpp
+++ b/modules/imgproc/src/smooth.cpp
@@ -42,6 +42,7 @@
//M*/
#include "precomp.hpp"
+#include "opencv2/core/hal/intrin.hpp"
#include "opencl_kernels_imgproc.hpp"
#include "opencv2/core/openvx/ovx_defs.hpp"
@@ -467,6 +468,8 @@ template<>
struct ColumnSum<ushort, uchar> :
public BaseColumnFilter
{
+ enum { SHIFT = 23 };
+
ColumnSum( int _ksize, int _anchor, double _scale ) :
BaseColumnFilter()
{
@@ -479,7 +482,7 @@ public BaseColumnFilter
if( scale != 1 )
{
int d = cvRound(1./scale);
- double scalef = ((double)(1 << 16))/d;
+ double scalef = ((double)(1 << SHIFT))/d;
divScale = cvFloor(scalef);
scalef -= divScale;
divDelta = d/2;
@@ -554,35 +557,43 @@ public BaseColumnFilter
if( haveScale )
{
int i = 0;
- #if CV_SSE2
- if(haveSSE2)
+ #if CV_SIMD128
+ v_uint32x4 ds4 = v_setall_u32((unsigned)ds);
+ v_uint16x8 dd8 = v_setall_u16((ushort)dd);
+
+ for( ; i <= width-16; i+=16 )
{
- __m128i ds8 = _mm_set1_epi16((short)ds);
- __m128i dd8 = _mm_set1_epi16((short)dd);
+ v_uint16x8 _sm0 = v_load(Sm + i);
+ v_uint16x8 _sm1 = v_load(Sm + i + 8);
- for( ; i <= width-16; i+=16 )
- {
- __m128i _sm0 = _mm_loadu_si128((const __m128i*)(Sm+i));
- __m128i _sm1 = _mm_loadu_si128((const __m128i*)(Sm+i+8));
+ v_uint16x8 _s0 = v_add_wrap(v_load(SUM + i), v_load(Sp + i));
+ v_uint16x8 _s1 = v_add_wrap(v_load(SUM + i + 8), v_load(Sp + i + 8));
- __m128i _s0 = _mm_add_epi16(_mm_loadu_si128((const __m128i*)(SUM+i)),
- _mm_loadu_si128((const __m128i*)(Sp+i)));
- __m128i _s1 = _mm_add_epi16(_mm_loadu_si128((const __m128i*)(SUM+i+8)),
- _mm_loadu_si128((const __m128i*)(Sp+i+8)));
- __m128i _s2 = _mm_mulhi_epu16(_mm_adds_epu16(_s0, dd8), ds8);
- __m128i _s3 = _mm_mulhi_epu16(_mm_adds_epu16(_s1, dd8), ds8);
- _s0 = _mm_sub_epi16(_s0, _sm0);
- _s1 = _mm_sub_epi16(_s1, _sm1);
- _mm_storeu_si128((__m128i*)(D+i), _mm_packus_epi16(_s2, _s3));
- _mm_storeu_si128((__m128i*)(SUM+i), _s0);
- _mm_storeu_si128((__m128i*)(SUM+i+8), _s1);
- }
+ v_uint32x4 _s00, _s01, _s10, _s11;
+
+ v_expand(_s0 + dd8, _s00, _s01);
+ v_expand(_s1 + dd8, _s10, _s11);
+
+ _s00 = v_shr<SHIFT>(_s00*ds4);
+ _s01 = v_shr<SHIFT>(_s01*ds4);
+ _s10 = v_shr<SHIFT>(_s10*ds4);
+ _s11 = v_shr<SHIFT>(_s11*ds4);
+
+ v_int16x8 r0 = v_pack(v_reinterpret_as_s32(_s00), v_reinterpret_as_s32(_s01));
+ v_int16x8 r1 = v_pack(v_reinterpret_as_s32(_s10), v_reinterpret_as_s32(_s11));
+
+ _s0 = v_sub_wrap(_s0, _sm0);
+ _s1 = v_sub_wrap(_s1, _sm1);
+
+ v_store(D + i, v_pack_u(r0, r1));
+ v_store(SUM + i, _s0);
+ v_store(SUM + i + 8, _s1);
}
- #endif
+ #endif
for( ; i < width; i++ )
{
int s0 = SUM[i] + Sp[i];
- D[i] = (uchar)((s0 + dd)*ds >> 16);
+ D[i] = (uchar)((s0 + dd)*ds >> SHIFT);
SUM[i] = (ushort)(s0 - Sm[i]);
}
}
@@ -1639,26 +1650,24 @@ cv::Ptr<cv::FilterEngine> cv::createBoxFilter( int srcType, int dstType, Size ks
#ifdef HAVE_OPENVX
namespace cv
{
+ namespace ovx {
+ template <> inline bool skipSmallImages<VX_KERNEL_BOX_3x3>(int w, int h) { return w*h < 640 * 480; }
+ }
static bool openvx_boxfilter(InputArray _src, OutputArray _dst, int ddepth,
Size ksize, Point anchor,
bool normalize, int borderType)
{
- int stype = _src.type();
if (ddepth < 0)
ddepth = CV_8UC1;
- if (stype != CV_8UC1 || (ddepth != CV_8U && ddepth != CV_16S) ||
- (anchor.x >= 0 && anchor.x != ksize.width / 2) ||
- (anchor.y >= 0 && anchor.y != ksize.height / 2) ||
- ksize.width % 2 != 1 || ksize.height % 2 != 1 ||
- ksize.width < 3 || ksize.height < 3)
+ if (_src.type() != CV_8UC1 || ddepth != CV_8U || !normalize ||
+ _src.cols() < 3 || _src.rows() < 3 ||
+ ksize.width != 3 || ksize.height != 3 ||
+ (anchor.x >= 0 && anchor.x != 1) ||
+ (anchor.y >= 0 && anchor.y != 1) ||
+ ovx::skipSmallImages<VX_KERNEL_BOX_3x3>(_src.cols(), _src.rows()))
return false;
Mat src = _src.getMat();
- _dst.create(src.size(), CV_MAKETYPE(ddepth, 1));
- Mat dst = _dst.getMat();
-
- if (src.cols < ksize.width || src.rows < ksize.height)
- return false;
if ((borderType & BORDER_ISOLATED) == 0 && src.isSubmatrix())
return false; //Process isolated borders only
@@ -1675,11 +1684,12 @@ namespace cv
return false;
}
+ _dst.create(src.size(), CV_8UC1);
+ Mat dst = _dst.getMat();
+
try
{
- ivx::Context ctx = ivx::Context::create();
- if ((vx_size)(ksize.width) > ctx.convolutionMaxDimension() || (vx_size)(ksize.height) > ctx.convolutionMaxDimension())
- return false;
+ ivx::Context ctx = ovx::getOpenVXContext();
Mat a;
if (dst.data != src.data)
@@ -1690,34 +1700,14 @@ namespace cv
ivx::Image
ia = ivx::Image::createFromHandle(ctx, VX_DF_IMAGE_U8,
ivx::Image::createAddressing(a.cols, a.rows, 1, (vx_int32)(a.step)), a.data),
- ib = ivx::Image::createFromHandle(ctx, ddepth == CV_16S ? VX_DF_IMAGE_S16 : VX_DF_IMAGE_U8,
- ivx::Image::createAddressing(dst.cols, dst.rows, ddepth == CV_16S ? 2 : 1, (vx_int32)(dst.step)), dst.data);
+ ib = ivx::Image::createFromHandle(ctx, VX_DF_IMAGE_U8,
+ ivx::Image::createAddressing(dst.cols, dst.rows, 1, (vx_int32)(dst.step)), dst.data);
//ATTENTION: VX_CONTEXT_IMMEDIATE_BORDER attribute change could lead to strange issues in multi-threaded environments
//since OpenVX standart says nothing about thread-safety for now
ivx::border_t prevBorder = ctx.immediateBorder();
ctx.setImmediateBorder(border, (vx_uint8)(0));
- if (ddepth == CV_8U && ksize.width == 3 && ksize.height == 3 && normalize)
- {
- ivx::IVX_CHECK_STATUS(vxuBox3x3(ctx, ia, ib));
- }
- else
- {
-#if VX_VERSION <= VX_VERSION_1_0
- if (ctx.vendorID() == VX_ID_KHRONOS && ((vx_size)(src.cols) <= ctx.convolutionMaxDimension() || (vx_size)(src.rows) <= ctx.convolutionMaxDimension()))
- {
- ctx.setImmediateBorder(prevBorder);
- return false;
- }
-#endif
- Mat convData(ksize, CV_16SC1);
- convData = normalize ? (1 << 15) / (ksize.width * ksize.height) : 1;
- ivx::Convolution cnv = ivx::Convolution::create(ctx, convData.cols, convData.rows);
- cnv.copyFrom(convData);
- if (normalize)
- cnv.setScale(1 << 15);
- ivx::IVX_CHECK_STATUS(vxuConvolve(ctx, ia, cnv, ib));
- }
+ ivx::IVX_CHECK_STATUS(vxuBox3x3(ctx, ia, ib));
ctx.setImmediateBorder(prevBorder);
}
catch (ivx::RuntimeError & e)
@@ -1734,98 +1724,84 @@ namespace cv
}
#endif
-// TODO: IPP performance regression
-#if defined(HAVE_IPP) && IPP_DISABLE_BLOCK
+#if defined(HAVE_IPP)
namespace cv
{
-static bool ipp_boxfilter( InputArray _src, OutputArray _dst, int ddepth,
- Size ksize, Point anchor,
- bool normalize, int borderType )
+static bool ipp_boxfilter(Mat &src, Mat &dst, Size ksize, Point anchor, bool normalize, int borderType)
{
CV_INSTRUMENT_REGION_IPP()
- int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype);
- if( ddepth < 0 )
- ddepth = sdepth;
- int ippBorderType = borderType & ~BORDER_ISOLATED;
+ // Problem with SSE42 optimization for 16s
+#if IPP_DISABLE_PERF_BOX16S_SSE42
+ if(src.depth() == CV_16S && !(ipp::getIppFeatures()&ippCPUID_AVX))
+ return false;
+#endif
+
+ int stype = src.type(), cn = CV_MAT_CN(stype);
+ IppiBorderType ippBorderType = ippiGetBorderType(borderType & ~BORDER_ISOLATED);
+ IppDataType ippType = ippiGetDataType(stype);
Point ocvAnchor, ippAnchor;
ocvAnchor.x = anchor.x < 0 ? ksize.width / 2 : anchor.x;
ocvAnchor.y = anchor.y < 0 ? ksize.height / 2 : anchor.y;
ippAnchor.x = ksize.width / 2 - (ksize.width % 2 == 0 ? 1 : 0);
ippAnchor.y = ksize.height / 2 - (ksize.height % 2 == 0 ? 1 : 0);
- Mat src = _src.getMat();
- _dst.create( src.size(), CV_MAKETYPE(ddepth, cn) );
- Mat dst = _dst.getMat();
- if( borderType != BORDER_CONSTANT && normalize && (borderType & BORDER_ISOLATED) != 0 )
+ if(normalize && (!src.isSubmatrix() || borderType&BORDER_ISOLATED) && stype == dst.type() &&
+ (ippBorderType == ippBorderRepl || /* returns ippStsStepErr: Step value is not valid */
+ ippBorderType == ippBorderConst ||
+ ippBorderType == ippBorderMirror) && ocvAnchor == ippAnchor) // returns ippStsMaskSizeErr: mask has an illegal value
{
- if( src.rows == 1 )
- ksize.height = 1;
- if( src.cols == 1 )
- ksize.width = 1;
- }
+ IppStatus status;
+ Ipp32s bufSize = 0;
+ IppiSize roiSize = { dst.cols, dst.rows };
+ IppiSize maskSize = { ksize.width, ksize.height };
+ IppAutoBuffer<Ipp8u> buffer;
- {
- if (normalize && !src.isSubmatrix() && ddepth == sdepth &&
- (/*ippBorderType == BORDER_REPLICATE ||*/ /* returns ippStsStepErr: Step value is not valid */
- ippBorderType == BORDER_CONSTANT) && ocvAnchor == ippAnchor &&
- dst.cols != ksize.width && dst.rows != ksize.height) // returns ippStsMaskSizeErr: mask has an illegal value
- {
- Ipp32s bufSize = 0;
- IppiSize roiSize = { dst.cols, dst.rows }, maskSize = { ksize.width, ksize.height };
-
-#define IPP_FILTER_BOX_BORDER(ippType, ippDataType, flavor) \
- do \
- { \
- if (ippiFilterBoxBorderGetBufferSize(roiSize, maskSize, ippDataType, cn, &bufSize) >= 0) \
- { \
- Ipp8u * buffer = ippsMalloc_8u(bufSize); \
- ippType borderValue[4] = { 0, 0, 0, 0 }; \
- ippBorderType = ippBorderType == BORDER_CONSTANT ? ippBorderConst : ippBorderRepl; \
- IppStatus status = CV_INSTRUMENT_FUN_IPP(ippiFilterBoxBorder_##flavor, src.ptr<ippType>(), (int)src.step, dst.ptr<ippType>(), \
- (int)dst.step, roiSize, maskSize, \
- (IppiBorderType)ippBorderType, borderValue, buffer); \
- ippsFree(buffer); \
- if (status >= 0) \
- { \
- CV_IMPL_ADD(CV_IMPL_IPP); \
- return true; \
- } \
- } \
- } while ((void)0, 0)
-
- if (stype == CV_8UC1)
- IPP_FILTER_BOX_BORDER(Ipp8u, ipp8u, 8u_C1R);
- else if (stype == CV_8UC3)
- IPP_FILTER_BOX_BORDER(Ipp8u, ipp8u, 8u_C3R);
- else if (stype == CV_8UC4)
- IPP_FILTER_BOX_BORDER(Ipp8u, ipp8u, 8u_C4R);
-
- // Oct 2014: performance with BORDER_CONSTANT
- //else if (stype == CV_16UC1)
- // IPP_FILTER_BOX_BORDER(Ipp16u, ipp16u, 16u_C1R);
- else if (stype == CV_16UC3)
- IPP_FILTER_BOX_BORDER(Ipp16u, ipp16u, 16u_C3R);
- else if (stype == CV_16UC4)
- IPP_FILTER_BOX_BORDER(Ipp16u, ipp16u, 16u_C4R);
-
- // Oct 2014: performance with BORDER_CONSTANT
- //else if (stype == CV_16SC1)
- // IPP_FILTER_BOX_BORDER(Ipp16s, ipp16s, 16s_C1R);
- else if (stype == CV_16SC3)
- IPP_FILTER_BOX_BORDER(Ipp16s, ipp16s, 16s_C3R);
- else if (stype == CV_16SC4)
- IPP_FILTER_BOX_BORDER(Ipp16s, ipp16s, 16s_C4R);
-
- else if (stype == CV_32FC1)
- IPP_FILTER_BOX_BORDER(Ipp32f, ipp32f, 32f_C1R);
- else if (stype == CV_32FC3)
- IPP_FILTER_BOX_BORDER(Ipp32f, ipp32f, 32f_C3R);
- else if (stype == CV_32FC4)
- IPP_FILTER_BOX_BORDER(Ipp32f, ipp32f, 32f_C4R);
+ if(ippiFilterBoxBorderGetBufferSize(roiSize, maskSize, ippType, cn, &bufSize) < 0)
+ return false;
+
+ buffer.allocate(bufSize);
+
+ #define IPP_FILTER_BOX_BORDER(ippType, flavor)\
+ {\
+ ippType borderValue[4] = { 0, 0, 0, 0 };\
+ status = CV_INSTRUMENT_FUN_IPP(ippiFilterBoxBorder_##flavor, src.ptr<ippType>(), (int)src.step, dst.ptr<ippType>(),\
+ (int)dst.step, roiSize, maskSize,\
+ ippBorderType, borderValue, buffer);\
}
-#undef IPP_FILTER_BOX_BORDER
+
+ if (stype == CV_8UC1)
+ IPP_FILTER_BOX_BORDER(Ipp8u, 8u_C1R)
+ else if (stype == CV_8UC3)
+ IPP_FILTER_BOX_BORDER(Ipp8u, 8u_C3R)
+ else if (stype == CV_8UC4)
+ IPP_FILTER_BOX_BORDER(Ipp8u, 8u_C4R)
+ else if (stype == CV_16UC1)
+ IPP_FILTER_BOX_BORDER(Ipp16u, 16u_C1R)
+ else if (stype == CV_16UC3)
+ IPP_FILTER_BOX_BORDER(Ipp16u, 16u_C3R)
+ else if (stype == CV_16UC4)
+ IPP_FILTER_BOX_BORDER(Ipp16u, 16u_C4R)
+ else if (stype == CV_16SC1)
+ IPP_FILTER_BOX_BORDER(Ipp16s, 16s_C1R)
+ else if (stype == CV_16SC3)
+ IPP_FILTER_BOX_BORDER(Ipp16s, 16s_C3R)
+ else if (stype == CV_16SC4)
+ IPP_FILTER_BOX_BORDER(Ipp16s, 16s_C4R)
+ else if (stype == CV_32FC1)
+ IPP_FILTER_BOX_BORDER(Ipp32f, 32f_C1R)
+ else if (stype == CV_32FC3)
+ IPP_FILTER_BOX_BORDER(Ipp32f, 32f_C3R)
+ else if (stype == CV_32FC4)
+ IPP_FILTER_BOX_BORDER(Ipp32f, 32f_C4R)
+ else
+ return false;
+
+ if(status >= 0)
+ return true;
}
+#undef IPP_FILTER_BOX_BORDER
+
return false;
}
}
@@ -1866,19 +1842,7 @@ void cv::boxFilter( InputArray _src, OutputArray _dst, int ddepth,
return;
#endif
-#if defined HAVE_IPP && IPP_DISABLE_BLOCK
- int ippBorderType = borderType & ~BORDER_ISOLATED;
- Point ocvAnchor, ippAnchor;
- ocvAnchor.x = anchor.x < 0 ? ksize.width / 2 : anchor.x;
- ocvAnchor.y = anchor.y < 0 ? ksize.height / 2 : anchor.y;
- ippAnchor.x = ksize.width / 2 - (ksize.width % 2 == 0 ? 1 : 0);
- ippAnchor.y = ksize.height / 2 - (ksize.height % 2 == 0 ? 1 : 0);
- CV_IPP_RUN((normalize && !_src.isSubmatrix() && ddepth == sdepth &&
- (/*ippBorderType == BORDER_REPLICATE ||*/ /* returns ippStsStepErr: Step value is not valid */
- ippBorderType == BORDER_CONSTANT) && ocvAnchor == ippAnchor &&
- _dst.cols() != ksize.width && _dst.rows() != ksize.height),
- ipp_boxfilter( _src, _dst, ddepth, ksize, anchor, normalize, borderType));
-#endif
+ CV_IPP_RUN_FAST(ipp_boxfilter(src, dst, ksize, anchor, normalize, borderType));
Point ofs;
Size wsz(src.cols, src.rows);
@@ -2196,10 +2160,12 @@ static bool ocl_GaussianBlur_8UC1(InputArray _src, OutputArray _dst, Size ksize,
#ifdef HAVE_OPENVX
+namespace ovx {
+ template <> inline bool skipSmallImages<VX_KERNEL_GAUSSIAN_3x3>(int w, int h) { return w*h < 320 * 240; }
+}
static bool openvx_gaussianBlur(InputArray _src, OutputArray _dst, Size ksize,
double sigma1, double sigma2, int borderType)
{
- int stype = _src.type();
if (sigma2 <= 0)
sigma2 = sigma1;
// automatic detection of kernel size from sigma
@@ -2208,20 +2174,21 @@ static bool openvx_gaussianBlur(InputArray _src, OutputArray _dst, Size ksize,
if (ksize.height <= 0 && sigma2 > 0)
ksize.height = cvRound(sigma2*6 + 1) | 1;
- if (stype != CV_8UC1 ||
- ksize.width < 3 || ksize.height < 3 ||
- ksize.width % 2 != 1 || ksize.height % 2 != 1)
+ if (_src.type() != CV_8UC1 ||
+ _src.cols() < 3 || _src.rows() < 3 ||
+ ksize.width != 3 || ksize.height != 3)
return false;
sigma1 = std::max(sigma1, 0.);
sigma2 = std::max(sigma2, 0.);
+ if (!(sigma1 == 0.0 || (sigma1 - 0.8) < DBL_EPSILON) || !(sigma2 == 0.0 || (sigma2 - 0.8) < DBL_EPSILON) ||
+ ovx::skipSmallImages<VX_KERNEL_GAUSSIAN_3x3>(_src.cols(), _src.rows()))
+ return false;
+
Mat src = _src.getMat();
Mat dst = _dst.getMat();
- if (src.cols < ksize.width || src.rows < ksize.height)
- return false;
-
if ((borderType & BORDER_ISOLATED) == 0 && src.isSubmatrix())
return false; //Process isolated borders only
vx_enum border;
@@ -2239,9 +2206,7 @@ static bool openvx_gaussianBlur(InputArray _src, OutputArray _dst, Size ksize,
try
{
- ivx::Context ctx = ivx::Context::create();
- if ((vx_size)(ksize.width) > ctx.convolutionMaxDimension() || (vx_size)(ksize.height) > ctx.convolutionMaxDimension())
- return false;
+ ivx::Context ctx = ovx::getOpenVXContext();
Mat a;
if (dst.data != src.data)
@@ -2259,26 +2224,7 @@ static bool openvx_gaussianBlur(InputArray _src, OutputArray _dst, Size ksize,
//since OpenVX standart says nothing about thread-safety for now
ivx::border_t prevBorder = ctx.immediateBorder();
ctx.setImmediateBorder(border, (vx_uint8)(0));
- if (ksize.width == 3 && ksize.height == 3 && (sigma1 == 0.0 || (sigma1 - 0.8) < DBL_EPSILON) && (sigma2 == 0.0 || (sigma2 - 0.8) < DBL_EPSILON))
- {
- ivx::IVX_CHECK_STATUS(vxuGaussian3x3(ctx, ia, ib));
- }
- else
- {
-#if VX_VERSION <= VX_VERSION_1_0
- if (ctx.vendorID() == VX_ID_KHRONOS && ((vx_size)(a.cols) <= ctx.convolutionMaxDimension() || (vx_size)(a.rows) <= ctx.convolutionMaxDimension()))
- {
- ctx.setImmediateBorder(prevBorder);
- return false;
- }
-#endif
- Mat convData;
- cv::Mat(cv::getGaussianKernel(ksize.height, sigma2)*cv::getGaussianKernel(ksize.width, sigma1).t()).convertTo(convData, CV_16SC1, (1 << 15));
- ivx::Convolution cnv = ivx::Convolution::create(ctx, convData.cols, convData.rows);
- cnv.copyFrom(convData);
- cnv.setScale(1 << 15);
- ivx::IVX_CHECK_STATUS(vxuConvolve(ctx, ia, cnv, ib));
- }
+ ivx::IVX_CHECK_STATUS(vxuGaussian3x3(ctx, ia, ib));
ctx.setImmediateBorder(prevBorder);
}
catch (ivx::RuntimeError & e)
@@ -2295,101 +2241,118 @@ static bool openvx_gaussianBlur(InputArray _src, OutputArray _dst, Size ksize,
#endif
#ifdef HAVE_IPP
+#define IPP_DISABLE_FILTERING_INMEM_PARTIAL 1 // IW 2017u2 has bug which doesn't allow use of partial inMem with tiling
+#define IPP_GAUSSIANBLUR_PARALLEL 1
-static bool ipp_GaussianBlur( InputArray _src, OutputArray _dst, Size ksize,
- double sigma1, double sigma2,
- int borderType )
+#ifdef HAVE_IPP_IW
+
+class ipp_gaussianBlurParallel: public ParallelLoopBody
{
- CV_INSTRUMENT_REGION_IPP()
+public:
+ ipp_gaussianBlurParallel(::ipp::IwiImage &src, ::ipp::IwiImage &dst, int kernelSize, float sigma, ::ipp::IwiBorderType &border, bool *pOk):
+ m_src(src), m_dst(dst), m_kernelSize(kernelSize), m_sigma(sigma), m_border(border), m_pOk(pOk) {
+ *m_pOk = true;
+ }
+ ~ipp_gaussianBlurParallel()
+ {
+ }
-#if IPP_VERSION_X100 >= 810
- if ((borderType & BORDER_ISOLATED) == 0 && _src.isSubmatrix())
- return false;
+ virtual void operator() (const Range& range) const
+ {
+ CV_INSTRUMENT_REGION_IPP()
- int type = _src.type();
- Size size = _src.size();
+ if(!*m_pOk)
+ return;
- if( borderType != BORDER_CONSTANT && (borderType & BORDER_ISOLATED) != 0 )
- {
- if( size.height == 1 )
- ksize.height = 1;
- if( size.width == 1 )
- ksize.width = 1;
+ try
+ {
+ ::ipp::IwiRoi roi = ::ipp::IwiRect(0, range.start, m_dst.m_size.width, range.end - range.start);
+ CV_INSTRUMENT_FUN_IPP(::ipp::iwiFilterGaussian, &m_src, &m_dst, m_kernelSize, m_sigma, m_border, &roi);
+ }
+ catch(::ipp::IwException e)
+ {
+ *m_pOk = false;
+ return;
+ }
}
+private:
+ ::ipp::IwiImage &m_src;
+ ::ipp::IwiImage &m_dst;
- int depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
+ int m_kernelSize;
+ float m_sigma;
+ ::ipp::IwiBorderType &m_border;
- if ((depth == CV_8U || depth == CV_16U || depth == CV_16S || depth == CV_32F) && (cn == 1 || cn == 3) &&
- sigma1 == sigma2 && ksize.width == ksize.height && sigma1 != 0.0 )
- {
- IppiBorderType ippBorder = ippiGetBorderType(borderType);
- if (ippBorderConst == ippBorder || ippBorderRepl == ippBorder)
- {
- Mat src = _src.getMat(), dst = _dst.getMat();
- IppiSize roiSize = { src.cols, src.rows };
- IppDataType dataType = ippiGetDataType(depth);
- Ipp32s specSize = 0, bufferSize = 0;
+ volatile bool *m_pOk;
+ const ipp_gaussianBlurParallel& operator= (const ipp_gaussianBlurParallel&);
+};
- if (ippiFilterGaussianGetBufferSize(roiSize, (Ipp32u)ksize.width, dataType, cn, &specSize, &bufferSize) >= 0)
- {
- IppAutoBuffer<IppFilterGaussianSpec> spec(specSize);
- IppAutoBuffer<Ipp8u> buffer(bufferSize);
+#endif
- if (ippiFilterGaussianInit(roiSize, (Ipp32u)ksize.width, (Ipp32f)sigma1, ippBorder, dataType, cn, spec, buffer) >= 0)
- {
-#define IPP_FILTER_GAUSS_C1(ippfavor) \
- { \
- Ipp##ippfavor borderValues = 0; \
- status = CV_INSTRUMENT_FUN_IPP(ippiFilterGaussianBorder_##ippfavor##_C1R, src.ptr<Ipp##ippfavor>(), (int)src.step, \
- dst.ptr<Ipp##ippfavor>(), (int)dst.step, roiSize, borderValues, spec, buffer); \
- }
+static bool ipp_GaussianBlur(InputArray _src, OutputArray _dst, Size ksize,
+ double sigma1, double sigma2, int borderType )
+{
+#ifdef HAVE_IPP_IW
+ CV_INSTRUMENT_REGION_IPP()
-#define IPP_FILTER_GAUSS_CN(ippfavor, ippcn) \
- { \
- Ipp##ippfavor borderValues[] = { 0, 0, 0 }; \
- status = CV_INSTRUMENT_FUN_IPP(ippiFilterGaussianBorder_##ippfavor##_C##ippcn##R, src.ptr<Ipp##ippfavor>(), (int)src.step, \
- dst.ptr<Ipp##ippfavor>(), (int)dst.step, roiSize, borderValues, spec, buffer); \
- }
+#if IPP_VERSION_X100 <= 201702 && ((defined _MSC_VER && defined _M_IX86) || (defined __GNUC__ && defined __i386__))
+ CV_UNUSED(_src); CV_UNUSED(_dst); CV_UNUSED(ksize); CV_UNUSED(sigma1); CV_UNUSED(sigma2); CV_UNUSED(borderType);
+ return false; // bug on ia32
+#else
+ if(sigma1 != sigma2)
+ return false;
- IppStatus status = ippStsErr;
-#if IPP_VERSION_X100 > 900 // Buffer overflow may happen in IPP 9.0.0 and less
- if (type == CV_8UC1)
- IPP_FILTER_GAUSS_C1(8u)
- else
-#endif
- if (type == CV_8UC3)
- IPP_FILTER_GAUSS_CN(8u, 3)
- else if (type == CV_16UC1)
- IPP_FILTER_GAUSS_C1(16u)
- else if (type == CV_16UC3)
- IPP_FILTER_GAUSS_CN(16u, 3)
- else if (type == CV_16SC1)
- IPP_FILTER_GAUSS_C1(16s)
- else if (type == CV_16SC3)
- IPP_FILTER_GAUSS_CN(16s, 3)
- else if (type == CV_32FC3)
- IPP_FILTER_GAUSS_CN(32f, 3)
- else if (type == CV_32FC1)
- IPP_FILTER_GAUSS_C1(32f)
-
- if(status >= 0)
- return true;
-
-#undef IPP_FILTER_GAUSS_C1
-#undef IPP_FILTER_GAUSS_CN
- }
- }
+ if(sigma1 < FLT_EPSILON)
+ return false;
+
+ if(ksize.width != ksize.height)
+ return false;
+
+ // Acquire data and begin processing
+ try
+ {
+ Mat src = _src.getMat();
+ Mat dst = _dst.getMat();
+ ::ipp::IwiImage iwSrc = ippiGetImage(src);
+ ::ipp::IwiImage iwDst = ippiGetImage(dst);
+ ::ipp::IwiBorderSize borderSize(::ipp::IwiSize(ippiSize(ksize)));
+ ::ipp::IwiBorderType ippBorder(ippiGetBorder(iwSrc, borderType, borderSize));
+ if(!ippBorder.m_borderType)
+ return false;
+
+ const bool disableThreading = IPP_DISABLE_FILTERING_INMEM_PARTIAL &&
+ ((ippBorder.m_borderFlags)&ippBorderInMem) && ((ippBorder.m_borderFlags)&ippBorderInMem) != ippBorderInMem;
+ const int threads = ippiSuggestThreadsNum(iwDst, 2);
+ if(!disableThreading && IPP_GAUSSIANBLUR_PARALLEL && threads > 1) {
+ bool ok;
+ ipp_gaussianBlurParallel invoker(iwSrc, iwDst, ksize.width, (float) sigma1, ippBorder, &ok);
+
+ if(!ok)
+ return false;
+ const Range range(0, (int) iwDst.m_size.height);
+ parallel_for_(range, invoker, threads*4);
+
+ if(!ok)
+ return false;
+ } else {
+ CV_INSTRUMENT_FUN_IPP(::ipp::iwiFilterGaussian, &iwSrc, &iwDst, ksize.width, (float) sigma1, ippBorder);
}
}
+ catch (::ipp::IwException ex)
+ {
+ return false;
+ }
+
+ return true;
+#endif
#else
CV_UNUSED(_src); CV_UNUSED(_dst); CV_UNUSED(ksize); CV_UNUSED(sigma1); CV_UNUSED(sigma2); CV_UNUSED(borderType);
-#endif
return false;
+#endif
}
#endif
}
-
void cv::GaussianBlur( InputArray _src, OutputArray _dst, Size ksize,
double sigma1, double sigma2,
int borderType )
@@ -2423,17 +2386,18 @@ void cv::GaussianBlur( InputArray _src, OutputArray _dst, Size ksize,
if(sigma1 == 0 && sigma2 == 0 && tegra::useTegra() && tegra::gaussian(src, dst, ksize, borderType))
return;
#endif
+ bool useOpenCL = (ocl::useOpenCL() && _dst.isUMat() && _src.dims() <= 2 &&
+ ((ksize.width == 3 && ksize.height == 3) ||
+ (ksize.width == 5 && ksize.height == 5)) &&
+ _src.rows() > ksize.height && _src.cols() > ksize.width);
+ (void)useOpenCL;
- CV_IPP_RUN(!(ocl::useOpenCL() && _dst.isUMat()), ipp_GaussianBlur( _src, _dst, ksize, sigma1, sigma2, borderType));
+ CV_IPP_RUN(!useOpenCL, ipp_GaussianBlur( _src, _dst, ksize, sigma1, sigma2, borderType));
Mat kx, ky;
createGaussianKernels(kx, ky, type, ksize, sigma1, sigma2);
- CV_OCL_RUN(_dst.isUMat() && _src.dims() <= 2 &&
- ((ksize.width == 3 && ksize.height == 3) ||
- (ksize.width == 5 && ksize.height == 5)) &&
- (size_t)_src.rows() > ky.total() && (size_t)_src.cols() > kx.total(),
- ocl_GaussianBlur_8UC1(_src, _dst, ksize, CV_MAT_DEPTH(type), kx, ky, borderType));
+ CV_OCL_RUN(useOpenCL, ocl_GaussianBlur_8UC1(_src, _dst, ksize, CV_MAT_DEPTH(type), kx, ky, borderType));
sepFilter2D(_src, _dst, CV_MAT_DEPTH(type), kx, ky, Point(-1,-1), 0, borderType );
}
@@ -2543,6 +2507,7 @@ medianBlur_8u_O1( const Mat& _src, Mat& _dst, int ksize )
h_fine[ 16 * (n*(16*c+(x>>4)) + j) + (x & 0xF) ] op
int cn = _dst.channels(), m = _dst.rows, r = (ksize-1)/2;
+ CV_Assert(cn > 0 && cn <= 4);
size_t sstep = _src.step, dstep = _dst.step;
Histogram CV_DECL_ALIGNED(16) H[4];
HT CV_DECL_ALIGNED(16) luc[4][16];
@@ -2748,6 +2713,7 @@ medianBlur_8u_Om( const Mat& _src, Mat& _dst, int m )
int src_step = (int)_src.step, dst_step = (int)_dst.step;
int cn = _src.channels();
const uchar* src_max = src + size.height*src_step;
+ CV_Assert(cn > 0 && cn <= 4);
#define UPDATE_ACC01( pix, cn, op ) \
{ \
@@ -3347,6 +3313,9 @@ static bool ocl_medianFilter(InputArray _src, OutputArray _dst, int m)
#ifdef HAVE_OPENVX
namespace cv
{
+ namespace ovx {
+ template <> inline bool skipSmallImages<VX_KERNEL_MEDIAN_3x3>(int w, int h) { return w*h < 1280 * 720; }
+ }
static bool openvx_medianFilter(InputArray _src, OutputArray _dst, int ksize)
{
if (_src.type() != CV_8UC1 || _dst.type() != CV_8U
@@ -3359,9 +3328,17 @@ namespace cv
Mat src = _src.getMat();
Mat dst = _dst.getMat();
+ if (
+#ifdef VX_VERSION_1_1
+ ksize != 3 ? ovx::skipSmallImages<VX_KERNEL_NON_LINEAR_FILTER>(src.cols, src.rows) :
+#endif
+ ovx::skipSmallImages<VX_KERNEL_MEDIAN_3x3>(src.cols, src.rows)
+ )
+ return false;
+
try
{
- ivx::Context ctx = ivx::Context::create();
+ ivx::Context ctx = ovx::getOpenVXContext();
#ifdef VX_VERSION_1_1
if ((vx_size)ksize > ctx.nonlinearMaxDimension())
return false;
@@ -3430,60 +3407,69 @@ namespace cv
#ifdef HAVE_IPP
namespace cv
{
-static bool ipp_medianFilter( InputArray _src0, OutputArray _dst, int ksize )
+static bool ipp_medianFilter(Mat &src0, Mat &dst, int ksize)
{
CV_INSTRUMENT_REGION_IPP()
-#if IPP_VERSION_X100 >= 810
- Mat src0 = _src0.getMat();
- _dst.create( src0.size(), src0.type() );
- Mat dst = _dst.getMat();
-
-#define IPP_FILTER_MEDIAN_BORDER(ippType, ippDataType, flavor) \
- do \
- { \
- if (ippiFilterMedianBorderGetBufferSize(dstRoiSize, maskSize, \
- ippDataType, CV_MAT_CN(type), &bufSize) >= 0) \
- { \
- Ipp8u * buffer = ippsMalloc_8u(bufSize); \
- IppStatus status = CV_INSTRUMENT_FUN_IPP(ippiFilterMedianBorder_##flavor, src.ptr<ippType>(), (int)src.step, \
- dst.ptr<ippType>(), (int)dst.step, dstRoiSize, maskSize, \
- ippBorderRepl, (ippType)0, buffer); \
- ippsFree(buffer); \
- if (status >= 0) \
- { \
- CV_IMPL_ADD(CV_IMPL_IPP); \
- return true; \
- } \
- } \
- } \
- while ((void)0, 0)
-
- if( ksize <= 5 )
{
- Ipp32s bufSize;
- IppiSize dstRoiSize = ippiSize(dst.cols, dst.rows), maskSize = ippiSize(ksize, ksize);
+ int bufSize;
+ IppiSize dstRoiSize = ippiSize(dst.cols, dst.rows), maskSize = ippiSize(ksize, ksize);
+ IppDataType ippType = ippiGetDataType(src0.type());
+ int channels = src0.channels();
+ IppAutoBuffer<Ipp8u> buffer;
+
+ if(src0.isSubmatrix())
+ return false;
+
Mat src;
- if( dst.data != src0.data )
+ if(dst.data != src0.data)
src = src0;
else
src0.copyTo(src);
- int type = src0.type();
- if (type == CV_8UC1)
- IPP_FILTER_MEDIAN_BORDER(Ipp8u, ipp8u, 8u_C1R);
- else if (type == CV_16UC1)
- IPP_FILTER_MEDIAN_BORDER(Ipp16u, ipp16u, 16u_C1R);
- else if (type == CV_16SC1)
- IPP_FILTER_MEDIAN_BORDER(Ipp16s, ipp16s, 16s_C1R);
- else if (type == CV_32FC1)
- IPP_FILTER_MEDIAN_BORDER(Ipp32f, ipp32f, 32f_C1R);
+ if(ippiFilterMedianBorderGetBufferSize(dstRoiSize, maskSize, ippType, channels, &bufSize) < 0)
+ return false;
+
+ buffer.allocate(bufSize);
+
+ switch(ippType)
+ {
+ case ipp8u:
+ if(channels == 1)
+ return CV_INSTRUMENT_FUN_IPP(ippiFilterMedianBorder_8u_C1R, src.ptr<Ipp8u>(), (int)src.step, dst.ptr<Ipp8u>(), (int)dst.step, dstRoiSize, maskSize, ippBorderRepl, 0, buffer) >= 0;
+ else if(channels == 3)
+ return CV_INSTRUMENT_FUN_IPP(ippiFilterMedianBorder_8u_C3R, src.ptr<Ipp8u>(), (int)src.step, dst.ptr<Ipp8u>(), (int)dst.step, dstRoiSize, maskSize, ippBorderRepl, 0, buffer) >= 0;
+ else if(channels == 4)
+ return CV_INSTRUMENT_FUN_IPP(ippiFilterMedianBorder_8u_C4R, src.ptr<Ipp8u>(), (int)src.step, dst.ptr<Ipp8u>(), (int)dst.step, dstRoiSize, maskSize, ippBorderRepl, 0, buffer) >= 0;
+ else
+ return false;
+ case ipp16u:
+ if(channels == 1)
+ return CV_INSTRUMENT_FUN_IPP(ippiFilterMedianBorder_16u_C1R, src.ptr<Ipp16u>(), (int)src.step, dst.ptr<Ipp16u>(), (int)dst.step, dstRoiSize, maskSize, ippBorderRepl, 0, buffer) >= 0;
+ else if(channels == 3)
+ return CV_INSTRUMENT_FUN_IPP(ippiFilterMedianBorder_16u_C3R, src.ptr<Ipp16u>(), (int)src.step, dst.ptr<Ipp16u>(), (int)dst.step, dstRoiSize, maskSize, ippBorderRepl, 0, buffer) >= 0;
+ else if(channels == 4)
+ return CV_INSTRUMENT_FUN_IPP(ippiFilterMedianBorder_16u_C4R, src.ptr<Ipp16u>(), (int)src.step, dst.ptr<Ipp16u>(), (int)dst.step, dstRoiSize, maskSize, ippBorderRepl, 0, buffer) >= 0;
+ else
+ return false;
+ case ipp16s:
+ if(channels == 1)
+ return CV_INSTRUMENT_FUN_IPP(ippiFilterMedianBorder_16s_C1R, src.ptr<Ipp16s>(), (int)src.step, dst.ptr<Ipp16s>(), (int)dst.step, dstRoiSize, maskSize, ippBorderRepl, 0, buffer) >= 0;
+ else if(channels == 3)
+ return CV_INSTRUMENT_FUN_IPP(ippiFilterMedianBorder_16s_C3R, src.ptr<Ipp16s>(), (int)src.step, dst.ptr<Ipp16s>(), (int)dst.step, dstRoiSize, maskSize, ippBorderRepl, 0, buffer) >= 0;
+ else if(channels == 4)
+ return CV_INSTRUMENT_FUN_IPP(ippiFilterMedianBorder_16s_C4R, src.ptr<Ipp16s>(), (int)src.step, dst.ptr<Ipp16s>(), (int)dst.step, dstRoiSize, maskSize, ippBorderRepl, 0, buffer) >= 0;
+ else
+ return false;
+ case ipp32f:
+ if(channels == 1)
+ return CV_INSTRUMENT_FUN_IPP(ippiFilterMedianBorder_32f_C1R, src.ptr<Ipp32f>(), (int)src.step, dst.ptr<Ipp32f>(), (int)dst.step, dstRoiSize, maskSize, ippBorderRepl, 0, buffer) >= 0;
+ else
+ return false;
+ default:
+ return false;
+ }
}
-#undef IPP_FILTER_MEDIAN_BORDER
-#else
- CV_UNUSED(_src0); CV_UNUSED(_dst); CV_UNUSED(ksize);
-#endif
- return false;
}
}
#endif
@@ -3494,7 +3480,7 @@ void cv::medianBlur( InputArray _src0, OutputArray _dst, int ksize )
CV_Assert( (ksize % 2 == 1) && (_src0.dims() <= 2 ));
- if( ksize <= 1 )
+ if( ksize <= 1 || _src0.empty() )
{
_src0.copyTo(_dst);
return;
@@ -3510,7 +3496,7 @@ void cv::medianBlur( InputArray _src0, OutputArray _dst, int ksize )
CV_OVX_RUN(true,
openvx_medianFilter(_src0, _dst, ksize))
- CV_IPP_RUN(IPP_VERSION_X100 >= 810 && ksize <= 5, ipp_medianFilter(_src0,_dst, ksize));
+ CV_IPP_RUN_FAST(ipp_medianFilter(src0, dst, ksize));
#ifdef HAVE_TEGRA_OPTIMIZATION
if (tegra::useTegra() && tegra::medianBlur(src0, dst, ksize))
@@ -3728,60 +3714,13 @@ private:
float *space_weight, *color_weight;
};
-#if defined (HAVE_IPP) && IPP_DISABLE_BLOCK
-class IPPBilateralFilter_8u_Invoker :
- public ParallelLoopBody
-{
-public:
- IPPBilateralFilter_8u_Invoker(Mat &_src, Mat &_dst, double _sigma_color, double _sigma_space, int _radius, bool *_ok) :
- ParallelLoopBody(), src(_src), dst(_dst), sigma_color(_sigma_color), sigma_space(_sigma_space), radius(_radius), ok(_ok)
- {
- *ok = true;
- }
-
- virtual void operator() (const Range& range) const
- {
- int d = radius * 2 + 1;
- IppiSize kernel = {d, d};
- IppiSize roi={dst.cols, range.end - range.start};
- int bufsize=0;
- if (0 > ippiFilterBilateralGetBufSize_8u_C1R( ippiFilterBilateralGauss, roi, kernel, &bufsize))
- {
- *ok = false;
- return;
- }
- AutoBuffer<uchar> buf(bufsize);
- IppiFilterBilateralSpec *pSpec = (IppiFilterBilateralSpec *)alignPtr(&buf[0], 32);
- if (0 > ippiFilterBilateralInit_8u_C1R( ippiFilterBilateralGauss, kernel, (Ipp32f)sigma_color, (Ipp32f)sigma_space, 1, pSpec ))
- {
- *ok = false;
- return;
- }
- if (0 > ippiFilterBilateral_8u_C1R( src.ptr<uchar>(range.start) + radius * ((int)src.step[0] + 1), (int)src.step[0], dst.ptr<uchar>(range.start), (int)dst.step[0], roi, kernel, pSpec ))
- *ok = false;
- else
- {
- CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
- }
- }
-private:
- Mat &src;
- Mat &dst;
- double sigma_color;
- double sigma_space;
- int radius;
- bool *ok;
- const IPPBilateralFilter_8u_Invoker& operator= (const IPPBilateralFilter_8u_Invoker&);
-};
-#endif
-
#ifdef HAVE_OPENCL
static bool ocl_bilateralFilter_8u(InputArray _src, OutputArray _dst, int d,
double sigma_color, double sigma_space,
int borderType)
{
-#ifdef ANDROID
+#ifdef __ANDROID__
if (ocl::Device::getDefault().isNVidia())
return false;
#endif
@@ -3898,24 +3837,6 @@ bilateralFilter_8u( const Mat& src, Mat& dst, int d,
Mat temp;
copyMakeBorder( src, temp, radius, radius, radius, radius, borderType );
-#if defined HAVE_IPP && (IPP_VERSION_X100 >= 700) && IPP_DISABLE_BLOCK
- CV_IPP_CHECK()
- {
- if( cn == 1 )
- {
- bool ok;
- IPPBilateralFilter_8u_Invoker body(temp, dst, sigma_color * sigma_color, sigma_space * sigma_space, radius, &ok );
- parallel_for_(Range(0, dst.rows), body, dst.total()/(double)(1<<16));
- if( ok )
- {
- CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
- return;
- }
- setIppErrorStatus();
- }
- }
-#endif
-
std::vector<float> _color_weight(cn*256);
std::vector<float> _space_weight(d*d);
std::vector<int> _space_ofs(d*d);
@@ -4330,6 +4251,106 @@ bilateralFilter_32f( const Mat& src, Mat& dst, int d,
parallel_for_(Range(0, size.height), body, dst.total()/(double)(1<<16));
}
+#ifdef HAVE_IPP
+#define IPP_BILATERAL_PARALLEL 1
+
+#ifdef HAVE_IPP_IW
+class ipp_bilateralFilterParallel: public ParallelLoopBody
+{
+public:
+ ipp_bilateralFilterParallel(::ipp::IwiImage &_src, ::ipp::IwiImage &_dst, int _radius, Ipp32f _valSquareSigma, Ipp32f _posSquareSigma, ::ipp::IwiBorderType _borderType, bool *_ok):
+ src(_src), dst(_dst)
+ {
+ pOk = _ok;
+
+ radius = _radius;
+ valSquareSigma = _valSquareSigma;
+ posSquareSigma = _posSquareSigma;
+ borderType = _borderType;
+
+ *pOk = true;
+ }
+ ~ipp_bilateralFilterParallel() {}
+
+ virtual void operator() (const Range& range) const
+ {
+ if(*pOk == false)
+ return;
+
+ try
+ {
+ ::ipp::IwiRoi roi = ::ipp::IwiRect(0, range.start, dst.m_size.width, range.end - range.start);
+ CV_INSTRUMENT_FUN_IPP(::ipp::iwiFilterBilateral, &src, &dst, radius, valSquareSigma, posSquareSigma, ippiFilterBilateralGauss, ippDistNormL1, borderType, &roi);
+ }
+ catch(::ipp::IwException)
+ {
+ *pOk = false;
+ return;
+ }
+ }
+private:
+ ::ipp::IwiImage &src;
+ ::ipp::IwiImage &dst;
+
+ int radius;
+ Ipp32f valSquareSigma;
+ Ipp32f posSquareSigma;
+ ::ipp::IwiBorderType borderType;
+
+ bool *pOk;
+ const ipp_bilateralFilterParallel& operator= (const ipp_bilateralFilterParallel&);
+};
+#endif
+
+static bool ipp_bilateralFilter(Mat &src, Mat &dst, int d, double sigmaColor, double sigmaSpace, int borderType)
+{
+#ifdef HAVE_IPP_IW
+ CV_INSTRUMENT_REGION_IPP()
+
+ int radius = IPP_MAX(((d <= 0)?cvRound(sigmaSpace*1.5):d/2), 1);
+ Ipp32f valSquareSigma = (Ipp32f)((sigmaColor <= 0)?1:sigmaColor*sigmaColor);
+ Ipp32f posSquareSigma = (Ipp32f)((sigmaSpace <= 0)?1:sigmaSpace*sigmaSpace);
+
+ // Acquire data and begin processing
+ try
+ {
+ ::ipp::IwiImage iwSrc = ippiGetImage(src);
+ ::ipp::IwiImage iwDst = ippiGetImage(dst);
+ ::ipp::IwiBorderSize borderSize(radius);
+ ::ipp::IwiBorderType ippBorder(ippiGetBorder(iwSrc, borderType, borderSize));
+ if(!ippBorder.m_borderType)
+ return false;
+
+ const bool disableThreading = IPP_DISABLE_FILTERING_INMEM_PARTIAL &&
+ ((ippBorder.m_borderFlags)&ippBorderInMem) && ((ippBorder.m_borderFlags)&ippBorderInMem) != ippBorderInMem;
+ const int threads = ippiSuggestThreadsNum(iwDst, 2);
+ if(!disableThreading && IPP_BILATERAL_PARALLEL && threads > 1) {
+ bool ok = true;
+ Range range(0, (int)iwDst.m_size.height);
+ ipp_bilateralFilterParallel invoker(iwSrc, iwDst, radius, valSquareSigma, posSquareSigma, ippBorder, &ok);
+ if(!ok)
+ return false;
+
+ parallel_for_(range, invoker, threads*4);
+
+ if(!ok)
+ return false;
+ } else {
+ CV_INSTRUMENT_FUN_IPP(::ipp::iwiFilterBilateral, &iwSrc, &iwDst, radius, valSquareSigma, posSquareSigma, ippiFilterBilateralGauss, ippDistNormL1, ippBorder);
+ }
+ }
+ catch (::ipp::IwException)
+ {
+ return false;
+ }
+ return true;
+#else
+ CV_UNUSED(src); CV_UNUSED(dst); CV_UNUSED(d); CV_UNUSED(sigmaColor); CV_UNUSED(sigmaSpace); CV_UNUSED(borderType);
+ return false;
+#endif
+}
+#endif
+
}
void cv::bilateralFilter( InputArray _src, OutputArray _dst, int d,
@@ -4345,6 +4366,8 @@ void cv::bilateralFilter( InputArray _src, OutputArray _dst, int d,
Mat src = _src.getMat(), dst = _dst.getMat();
+ CV_IPP_RUN_FAST(ipp_bilateralFilter(src, dst, d, sigmaColor, sigmaSpace, borderType));
+
if( src.depth() == CV_8U )
bilateralFilter_8u( src, dst, d, sigmaColor, sigmaSpace, borderType );
else if( src.depth() == CV_32F )
diff --git a/modules/imgproc/src/spatialgradient.cpp b/modules/imgproc/src/spatialgradient.cpp
index 9217558..a84bd70 100644
--- a/modules/imgproc/src/spatialgradient.cpp
+++ b/modules/imgproc/src/spatialgradient.cpp
@@ -129,7 +129,7 @@ void spatialGradient( InputArray _src, OutputArray _dx, OutputArray _dy,
int i_start = 0;
int j_start = 0;
-#if CV_SIMD128 && CV_SSE2
+#if CV_SIMD128
if(hasSIMD128())
{
uchar *m_src;
@@ -160,18 +160,13 @@ void spatialGradient( InputArray _src, OutputArray _dx, OutputArray _dy,
n_dx = dx.ptr<short>(i+1);
n_dy = dy.ptr<short>(i+1);
- v_uint8x16 v_select_m = v_uint8x16(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0xFF);
-
// Process rest of columns 16-column chunks at a time
for ( j = 1; j < W - 16; j += 16 )
{
// Load top row for 3x3 Sobel filter
v_uint8x16 v_um = v_load(&p_src[j-1]);
+ v_uint8x16 v_un = v_load(&p_src[j]);
v_uint8x16 v_up = v_load(&p_src[j+1]);
- // TODO: Replace _mm_slli_si128 with hal method
- v_uint8x16 v_un = v_select(v_select_m, v_uint8x16(_mm_slli_si128(v_up.val, 1)),
- v_uint8x16(_mm_srli_si128(v_um.val, 1)));
v_uint16x8 v_um1, v_um2, v_un1, v_un2, v_up1, v_up2;
v_expand(v_um, v_um1, v_um2);
v_expand(v_un, v_un1, v_un2);
@@ -185,10 +180,8 @@ void spatialGradient( InputArray _src, OutputArray _dx, OutputArray _dy,
// Load second row for 3x3 Sobel filter
v_um = v_load(&c_src[j-1]);
+ v_un = v_load(&c_src[j]);
v_up = v_load(&c_src[j+1]);
- // TODO: Replace _mm_slli_si128 with hal method
- v_un = v_select(v_select_m, v_uint8x16(_mm_slli_si128(v_up.val, 1)),
- v_uint8x16(_mm_srli_si128(v_um.val, 1)));
v_expand(v_um, v_um1, v_um2);
v_expand(v_un, v_un1, v_un2);
v_expand(v_up, v_up1, v_up2);
@@ -201,10 +194,8 @@ void spatialGradient( InputArray _src, OutputArray _dx, OutputArray _dy,
// Load third row for 3x3 Sobel filter
v_um = v_load(&n_src[j-1]);
+ v_un = v_load(&n_src[j]);
v_up = v_load(&n_src[j+1]);
- // TODO: Replace _mm_slli_si128 with hal method
- v_un = v_select(v_select_m, v_uint8x16(_mm_slli_si128(v_up.val, 1)),
- v_uint8x16(_mm_srli_si128(v_um.val, 1)));
v_expand(v_um, v_um1, v_um2);
v_expand(v_un, v_un1, v_un2);
v_expand(v_up, v_up1, v_up2);
@@ -236,10 +227,8 @@ void spatialGradient( InputArray _src, OutputArray _dx, OutputArray _dy,
// Load fourth row for 3x3 Sobel filter
v_um = v_load(&m_src[j-1]);
+ v_un = v_load(&m_src[j]);
v_up = v_load(&m_src[j+1]);
- // TODO: Replace _mm_slli_si128 with hal method
- v_un = v_select(v_select_m, v_uint8x16(_mm_slli_si128(v_up.val, 1)),
- v_uint8x16(_mm_srli_si128(v_um.val, 1)));
v_expand(v_um, v_um1, v_um2);
v_expand(v_un, v_un1, v_un2);
v_expand(v_up, v_up1, v_up2);
diff --git a/modules/imgproc/src/sumpixels.cpp b/modules/imgproc/src/sumpixels.cpp
index c9793b2..d19ef3b 100755
--- a/modules/imgproc/src/sumpixels.cpp
+++ b/modules/imgproc/src/sumpixels.cpp
@@ -405,58 +405,43 @@ static bool ipp_integral(
const uchar* src, size_t srcstep,
uchar* sum, size_t sumstep,
uchar* sqsum, size_t sqsumstep,
+ uchar* tilted, size_t tstep,
int width, int height, int cn)
{
CV_INSTRUMENT_REGION_IPP()
-#if IPP_VERSION_X100 != 900 // Disabled on ICV due invalid results
- if( sdepth <= 0 )
- sdepth = depth == CV_8U ? CV_32S : CV_64F;
- if ( sqdepth <= 0 )
- sqdepth = CV_64F;
- sdepth = CV_MAT_DEPTH(sdepth), sqdepth = CV_MAT_DEPTH(sqdepth);
+ IppiSize size = {width, height};
- if( ( depth == CV_8U ) && ( sdepth == CV_32F || sdepth == CV_32S ) && ( !sqsum || sqdepth == CV_64F ) && ( cn == 1 ) )
+ if(cn > 1)
+ return false;
+ if(tilted)
{
- IppStatus status = ippStsErr;
- IppiSize srcRoiSize = ippiSize( width, height );
- if( sdepth == CV_32F )
- {
- if( sqsum )
- {
- status = CV_INSTRUMENT_FUN_IPP(ippiSqrIntegral_8u32f64f_C1R, (const Ipp8u*)src, (int)srcstep, (Ipp32f*)sum, (int)sumstep, (Ipp64f*)sqsum, (int)sqsumstep, srcRoiSize, 0, 0);
- }
- else
- {
- status = CV_INSTRUMENT_FUN_IPP(ippiIntegral_8u32f_C1R, (const Ipp8u*)src, (int)srcstep, (Ipp32f*)sum, (int)sumstep, srcRoiSize, 0);
- }
- }
- else if( sdepth == CV_32S )
- {
- if( sqsum )
- {
- status = CV_INSTRUMENT_FUN_IPP(ippiSqrIntegral_8u32s64f_C1R, (const Ipp8u*)src, (int)srcstep, (Ipp32s*)sum, (int)sumstep, (Ipp64f*)sqsum, (int)sqsumstep, srcRoiSize, 0, 0);
- }
- else
- {
- status = CV_INSTRUMENT_FUN_IPP(ippiIntegral_8u32s_C1R, (const Ipp8u*)src, (int)srcstep, (Ipp32s*)sum, (int)sumstep, srcRoiSize, 0);
- }
- }
- if (0 <= status)
- {
- CV_IMPL_ADD(CV_IMPL_IPP);
- return true;
- }
+ CV_UNUSED(tstep);
+ return false;
+ }
+
+ if(!sqsum)
+ {
+ if(depth == CV_8U && sdepth == CV_32S)
+ return CV_INSTRUMENT_FUN_IPP(ippiIntegral_8u32s_C1R, (const Ipp8u*)src, (int)srcstep, (Ipp32s*)sum, (int)sumstep, size, 0) >= 0;
+ else if(depth == CV_8UC1 && sdepth == CV_32F)
+ return CV_INSTRUMENT_FUN_IPP(ippiIntegral_8u32f_C1R, (const Ipp8u*)src, (int)srcstep, (Ipp32f*)sum, (int)sumstep, size, 0) >= 0;
+ else if(depth == CV_32FC1 && sdepth == CV_32F)
+ return CV_INSTRUMENT_FUN_IPP(ippiIntegral_32f_C1R, (const Ipp32f*)src, (int)srcstep, (Ipp32f*)sum, (int)sumstep, size) >= 0;
+ else
+ return false;
+ }
+ else
+ {
+ if(depth == CV_8U && sdepth == CV_32S && sqdepth == CV_32S)
+ return CV_INSTRUMENT_FUN_IPP(ippiSqrIntegral_8u32s_C1R, (const Ipp8u*)src, (int)srcstep, (Ipp32s*)sum, (int)sumstep, (Ipp32s*)sqsum, (int)sqsumstep, size, 0, 0) >= 0;
+ else if(depth == CV_8U && sdepth == CV_32S && sqdepth == CV_64F)
+ return CV_INSTRUMENT_FUN_IPP(ippiSqrIntegral_8u32s64f_C1R, (const Ipp8u*)src, (int)srcstep, (Ipp32s*)sum, (int)sumstep, (Ipp64f*)sqsum, (int)sqsumstep, size, 0, 0) >= 0;
+ else if(depth == CV_8U && sdepth == CV_32F && sqdepth == CV_64F)
+ return CV_INSTRUMENT_FUN_IPP(ippiSqrIntegral_8u32f64f_C1R, (const Ipp8u*)src, (int)srcstep, (Ipp32f*)sum, (int)sumstep, (Ipp64f*)sqsum, (int)sqsumstep, size, 0, 0) >= 0;
+ else
+ return false;
}
-#else
- CV_UNUSED(depth); CV_UNUSED(sdepth); CV_UNUSED(sqdepth);
- CV_UNUSED(src); CV_UNUSED(srcstep);
- CV_UNUSED(sum); CV_UNUSED(sumstep);
- CV_UNUSED(sqsum); CV_UNUSED(sqsumstep);
- CV_UNUSED(tilted); CV_UNUSED(tstep);
- CV_UNUSED(width); CV_UNUSED(height); CV_UNUSED(cn);
-#endif
- return false;
}
}
#endif
@@ -471,12 +456,7 @@ void integral(int depth, int sdepth, int sqdepth,
int width, int height, int cn)
{
CALL_HAL(integral, cv_hal_integral, depth, sdepth, sqdepth, src, srcstep, sum, sumstep, sqsum, sqsumstep, tilted, tstep, width, height, cn);
- CV_IPP_RUN(( depth == CV_8U )
- && ( sdepth == CV_32F || sdepth == CV_32S )
- && ( !tilted )
- && ( !sqsum || sqdepth == CV_64F )
- && ( cn == 1 ),
- ipp_integral(depth, sdepth, sqdepth, src, srcstep, sum, sumstep, sqsum, sqsumstep, width, height, cn));
+ CV_IPP_RUN_FAST(ipp_integral(depth, sdepth, sqdepth, src, srcstep, sum, sumstep, sqsum, sqsumstep, tilted, tstep, width, height, cn));
#define ONE_CALL(A, B, C) integral_<A, B, C>((const A*)src, srcstep, (B*)sum, sumstep, (C*)sqsum, sqsumstep, (B*)tilted, tstep, width, height, cn)
diff --git a/modules/imgproc/src/templmatch.cpp b/modules/imgproc/src/templmatch.cpp
index 5bae692..302e26e 100644
--- a/modules/imgproc/src/templmatch.cpp
+++ b/modules/imgproc/src/templmatch.cpp
@@ -135,7 +135,7 @@ void ConvolveBuf::create(Size image_size, Size templ_size)
const double blockScale = 4.5;
const int minBlockSize = 256;
- block_size.width = cvRound(result_size.width*blockScale);
+ block_size.width = cvRound(templ_size.width*blockScale);
block_size.width = std::max( block_size.width, minBlockSize - templ_size.width + 1 );
block_size.width = std::min( block_size.width, result_size.width );
block_size.height = cvRound(templ_size.height*blockScale);
@@ -477,6 +477,7 @@ static bool matchTemplate_CCOEFF_NORMED(InputArray _image, InputArray _templ, Ou
integral(_image, image_sums, image_sqsums, CV_32F, CV_32F);
int type = image_sums.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
+ CV_Assert(cn >= 1 && cn <= 4);
ocl::Kernel k("matchTemplate_CCOEFF_NORMED", ocl::imgproc::match_template_oclsrc,
format("-D CCOEFF_NORMED -D T=%s -D T1=%s -D cn=%d", ocl::typeToStr(type), ocl::typeToStr(depth), cn));
@@ -560,82 +561,6 @@ static bool ocl_matchTemplate( InputArray _img, InputArray _templ, OutputArray _
#endif
-#if defined HAVE_IPP
-
-typedef IppStatus (CV_STDCALL * ippimatchTemplate)(const void*, int, IppiSize, const void*, int, IppiSize, Ipp32f* , int , IppEnum , Ipp8u*);
-
-static bool ipp_crossCorr(const Mat& src, const Mat& tpl, Mat& dst)
-{
- CV_INSTRUMENT_REGION_IPP()
-
- IppStatus status;
-
- IppiSize srcRoiSize = {src.cols,src.rows};
- IppiSize tplRoiSize = {tpl.cols,tpl.rows};
-
- Ipp8u *pBuffer;
- int bufSize=0;
-
- int depth = src.depth();
-
- ippimatchTemplate ippiCrossCorrNorm =
- depth==CV_8U ? (ippimatchTemplate)ippiCrossCorrNorm_8u32f_C1R:
- depth==CV_32F? (ippimatchTemplate)ippiCrossCorrNorm_32f_C1R: 0;
-
- if (ippiCrossCorrNorm==0)
- return false;
-
- IppEnum funCfg = (IppEnum)(ippAlgAuto | ippiNormNone | ippiROIValid);
-
- status = ippiCrossCorrNormGetBufferSize(srcRoiSize, tplRoiSize, funCfg, &bufSize);
- if ( status < 0 )
- return false;
-
- pBuffer = ippsMalloc_8u( bufSize );
-
- status = CV_INSTRUMENT_FUN_IPP(ippiCrossCorrNorm, src.ptr(), (int)src.step, srcRoiSize, tpl.ptr(), (int)tpl.step, tplRoiSize, dst.ptr<Ipp32f>(), (int)dst.step, funCfg, pBuffer);
-
- ippsFree( pBuffer );
- return status >= 0;
-}
-
-static bool ipp_sqrDistance(const Mat& src, const Mat& tpl, Mat& dst)
-{
- CV_INSTRUMENT_REGION_IPP()
-
- IppStatus status;
-
- IppiSize srcRoiSize = {src.cols,src.rows};
- IppiSize tplRoiSize = {tpl.cols,tpl.rows};
-
- Ipp8u *pBuffer;
- int bufSize=0;
-
- int depth = src.depth();
-
- ippimatchTemplate ippiSqrDistanceNorm =
- depth==CV_8U ? (ippimatchTemplate)ippiSqrDistanceNorm_8u32f_C1R:
- depth==CV_32F? (ippimatchTemplate)ippiSqrDistanceNorm_32f_C1R: 0;
-
- if (ippiSqrDistanceNorm==0)
- return false;
-
- IppEnum funCfg = (IppEnum)(ippAlgAuto | ippiNormNone | ippiROIValid);
-
- status = ippiSqrDistanceNormGetBufferSize(srcRoiSize, tplRoiSize, funCfg, &bufSize);
- if ( status < 0 )
- return false;
-
- pBuffer = ippsMalloc_8u( bufSize );
-
- status = CV_INSTRUMENT_FUN_IPP(ippiSqrDistanceNorm, src.ptr(), (int)src.step, srcRoiSize, tpl.ptr(), (int)tpl.step, tplRoiSize, dst.ptr<Ipp32f>(), (int)dst.step, funCfg, pBuffer);
-
- ippsFree( pBuffer );
- return status >= 0;
-}
-
-#endif
-
#include "opencv2/core/hal/hal.hpp"
void crossCorr( const Mat& img, const Mat& _templ, Mat& corr,
@@ -915,11 +840,7 @@ static void matchTemplateMask( InputArray _img, InputArray _templ, OutputArray _
else
CV_Error(Error::StsNotImplemented, "");
}
-}
-
-namespace cv
-{
static void common_matchTemplate( Mat& img, Mat& templ, Mat& result, int method, int cn )
{
if( method == CV_TM_CCORR )
@@ -968,12 +889,14 @@ static void common_matchTemplate( Mat& img, Mat& templ, Mat& result, int method,
templNorm = std::sqrt(templNorm);
templNorm /= std::sqrt(invArea); // care of accuracy here
+ CV_Assert(sqsum.data != NULL);
q0 = (double*)sqsum.data;
q1 = q0 + templ.cols*cn;
q2 = (double*)(sqsum.data + templ.rows*sqsum.step);
q3 = q2 + templ.cols*cn;
}
+ CV_Assert(sum.data != NULL);
double* p0 = (double*)sum.data;
double* p1 = p0 + templ.cols*cn;
double* p2 = (double*)(sum.data + templ.rows*sum.step);
@@ -1043,26 +966,117 @@ static void common_matchTemplate( Mat& img, Mat& templ, Mat& result, int method,
#if defined HAVE_IPP
namespace cv
{
-static bool ipp_matchTemplate( Mat& img, Mat& templ, Mat& result, int method, int cn )
+typedef IppStatus (CV_STDCALL * ippimatchTemplate)(const void*, int, IppiSize, const void*, int, IppiSize, Ipp32f* , int , IppEnum , Ipp8u*);
+
+static bool ipp_crossCorr(const Mat& src, const Mat& tpl, Mat& dst, bool normed)
{
CV_INSTRUMENT_REGION_IPP()
- bool useIppMT = (templ.rows < img.rows/2 && templ.cols < img.cols/2);
+ IppStatus status;
- if(cn == 1 && useIppMT)
+ IppiSize srcRoiSize = {src.cols,src.rows};
+ IppiSize tplRoiSize = {tpl.cols,tpl.rows};
+
+ IppAutoBuffer<Ipp8u> buffer;
+ int bufSize=0;
+
+ int depth = src.depth();
+
+ ippimatchTemplate ippiCrossCorrNorm =
+ depth==CV_8U ? (ippimatchTemplate)ippiCrossCorrNorm_8u32f_C1R:
+ depth==CV_32F? (ippimatchTemplate)ippiCrossCorrNorm_32f_C1R: 0;
+
+ if (ippiCrossCorrNorm==0)
+ return false;
+
+ IppEnum funCfg = (IppEnum)(ippAlgAuto | ippiROIValid);
+ if(normed)
+ funCfg |= ippiNorm;
+ else
+ funCfg |= ippiNormNone;
+
+ status = ippiCrossCorrNormGetBufferSize(srcRoiSize, tplRoiSize, funCfg, &bufSize);
+ if ( status < 0 )
+ return false;
+
+ buffer.allocate( bufSize );
+
+ status = CV_INSTRUMENT_FUN_IPP(ippiCrossCorrNorm, src.ptr(), (int)src.step, srcRoiSize, tpl.ptr(), (int)tpl.step, tplRoiSize, dst.ptr<Ipp32f>(), (int)dst.step, funCfg, buffer);
+ return status >= 0;
+}
+
+static bool ipp_sqrDistance(const Mat& src, const Mat& tpl, Mat& dst)
+{
+ CV_INSTRUMENT_REGION_IPP()
+
+ IppStatus status;
+
+ IppiSize srcRoiSize = {src.cols,src.rows};
+ IppiSize tplRoiSize = {tpl.cols,tpl.rows};
+
+ IppAutoBuffer<Ipp8u> buffer;
+ int bufSize=0;
+
+ int depth = src.depth();
+
+ ippimatchTemplate ippiSqrDistanceNorm =
+ depth==CV_8U ? (ippimatchTemplate)ippiSqrDistanceNorm_8u32f_C1R:
+ depth==CV_32F? (ippimatchTemplate)ippiSqrDistanceNorm_32f_C1R: 0;
+
+ if (ippiSqrDistanceNorm==0)
+ return false;
+
+ IppEnum funCfg = (IppEnum)(ippAlgAuto | ippiROIValid | ippiNormNone);
+ status = ippiSqrDistanceNormGetBufferSize(srcRoiSize, tplRoiSize, funCfg, &bufSize);
+ if ( status < 0 )
+ return false;
+
+ buffer.allocate( bufSize );
+
+ status = CV_INSTRUMENT_FUN_IPP(ippiSqrDistanceNorm, src.ptr(), (int)src.step, srcRoiSize, tpl.ptr(), (int)tpl.step, tplRoiSize, dst.ptr<Ipp32f>(), (int)dst.step, funCfg, buffer);
+ return status >= 0;
+}
+
+static bool ipp_matchTemplate( Mat& img, Mat& templ, Mat& result, int method)
+{
+ CV_INSTRUMENT_REGION_IPP()
+
+ if(img.channels() != 1)
+ return false;
+
+ // These functions are not efficient if template size is comparable with image size
+ if(templ.size().area()*4 > img.size().area())
+ return false;
+
+ if(method == CV_TM_SQDIFF)
+ {
+ if(ipp_sqrDistance(img, templ, result))
+ return true;
+ }
+ else if(method == CV_TM_SQDIFF_NORMED)
{
- if(method == CV_TM_SQDIFF)
+ if(ipp_crossCorr(img, templ, result, false))
{
- if (ipp_sqrDistance(img, templ, result))
- return true;
+ common_matchTemplate(img, templ, result, CV_TM_SQDIFF_NORMED, 1);
+ return true;
}
- else
+ }
+ else if(method == CV_TM_CCORR)
+ {
+ if(ipp_crossCorr(img, templ, result, false))
+ return true;
+ }
+ else if(method == CV_TM_CCORR_NORMED)
+ {
+ if(ipp_crossCorr(img, templ, result, true))
+ return true;
+ }
+ else if(method == CV_TM_CCOEFF || method == CV_TM_CCOEFF_NORMED)
+ {
+ if(ipp_crossCorr(img, templ, result, false))
{
- if(ipp_crossCorr(img, templ, result))
- {
- common_matchTemplate(img, templ, result, method, cn);
- return true;
- }
+ common_matchTemplate(img, templ, result, method, 1);
+ return true;
}
}
@@ -1109,7 +1123,7 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result,
return;
#endif
- CV_IPP_RUN(true, ipp_matchTemplate(img, templ, result, method, cn))
+ CV_IPP_RUN_FAST(ipp_matchTemplate(img, templ, result, method))
crossCorr( img, templ, result, result.size(), result.type(), Point(0,0), 0, 0);
diff --git a/modules/imgproc/src/thresh.cpp b/modules/imgproc/src/thresh.cpp
index f4f3297..674d12b 100644
--- a/modules/imgproc/src/thresh.cpp
+++ b/modules/imgproc/src/thresh.cpp
@@ -206,7 +206,7 @@ thresh_8u( const Mat& _src, Mat& _dst, uchar thresh, uchar maxval, int type )
if( j_scalar < roi.width )
{
const int thresh_pivot = thresh + 1;
- uchar tab[256];
+ uchar tab[256] = {0};
switch( type )
{
case THRESH_BINARY:
@@ -463,7 +463,7 @@ thresh_16s( const Mat& _src, Mat& _dst, short thresh, short maxval, int type )
}
break;
default:
- return CV_Error( CV_StsBadArg, "" );
+ CV_Error( CV_StsBadArg, "" ); return;
}
}
else
@@ -517,7 +517,7 @@ thresh_16s( const Mat& _src, Mat& _dst, short thresh, short maxval, int type )
}
break;
default:
- return CV_Error( CV_StsBadArg, "" );
+ CV_Error( CV_StsBadArg, "" ); return;
}
}
}
@@ -698,7 +698,7 @@ thresh_32f( const Mat& _src, Mat& _dst, float thresh, float maxval, int type )
}
break;
default:
- return CV_Error( CV_StsBadArg, "" );
+ CV_Error( CV_StsBadArg, "" ); return;
}
}
else
@@ -752,7 +752,7 @@ thresh_32f( const Mat& _src, Mat& _dst, float thresh, float maxval, int type )
}
break;
default:
- return CV_Error( CV_StsBadArg, "" );
+ CV_Error( CV_StsBadArg, "" ); return;
}
}
}
@@ -893,7 +893,7 @@ thresh_64f(const Mat& _src, Mat& _dst, double thresh, double maxval, int type)
}
break;
default:
- return CV_Error(CV_StsBadArg, "");
+ CV_Error(CV_StsBadArg, ""); return;
}
}
else
@@ -952,7 +952,7 @@ thresh_64f(const Mat& _src, Mat& _dst, double thresh, double maxval, int type)
}
break;
default:
- return CV_Error(CV_StsBadArg, "");
+ CV_Error(CV_StsBadArg, ""); return;
}
}
}
@@ -1301,7 +1301,7 @@ static bool openvx_threshold(Mat src, Mat dst, int thresh, int maxval, int type)
try
{
- ivx::Context ctx = ivx::Context::create();
+ ivx::Context ctx = ovx::getOpenVXContext();
ivx::Threshold thh = ivx::Threshold::createBinary(ctx, VX_TYPE_UINT8, thresh);
thh.setValueTrue(trueVal);
@@ -1390,7 +1390,7 @@ double cv::threshold( InputArray _src, OutputArray _dst, double thresh, double m
return thresh;
}
- CV_OVX_RUN(true,
+ CV_OVX_RUN(!ovx::skipSmallImages<VX_KERNEL_THRESHOLD>(src.cols, src.rows),
openvx_threshold(src, dst, ithresh, imaxval, type), (double)ithresh)
thresh = ithresh;
diff --git a/modules/imgproc/src/undistort.avx2.cpp b/modules/imgproc/src/undistort.avx2.cpp
new file mode 100644
index 0000000..c26fe75
--- /dev/null
+++ b/modules/imgproc/src/undistort.avx2.cpp
@@ -0,0 +1,200 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
+// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "precomp.hpp"
+#include "undistort.hpp"
+
+namespace cv
+{
+
+int initUndistortRectifyMapLine_AVX(float* m1f, float* m2f, short* m1, ushort* m2, double* matTilt, const double* ir,
+ double& _x, double& _y, double& _w, int width, int m1type,
+ double& k1, double& k2, double& k3, double& k4, double& k5, double& k6,
+ double& p1, double& p2, double& s1, double& s2, double& s3, double& s4,
+ double& u0, double& v0, double& fx, double& fy)
+{
+ int j = 0;
+
+ static const __m256d __one = _mm256_set1_pd(1.0);
+ static const __m256d __two = _mm256_set1_pd(2.0);
+
+ const __m256d __matTilt_00 = _mm256_set1_pd(matTilt[0]);
+ const __m256d __matTilt_10 = _mm256_set1_pd(matTilt[3]);
+ const __m256d __matTilt_20 = _mm256_set1_pd(matTilt[6]);
+
+ const __m256d __matTilt_01 = _mm256_set1_pd(matTilt[1]);
+ const __m256d __matTilt_11 = _mm256_set1_pd(matTilt[4]);
+ const __m256d __matTilt_21 = _mm256_set1_pd(matTilt[7]);
+
+ const __m256d __matTilt_02 = _mm256_set1_pd(matTilt[2]);
+ const __m256d __matTilt_12 = _mm256_set1_pd(matTilt[5]);
+ const __m256d __matTilt_22 = _mm256_set1_pd(matTilt[8]);
+
+ for (; j <= width - 4; j += 4, _x += 4 * ir[0], _y += 4 * ir[3], _w += 4 * ir[6])
+ {
+ // Question: Should we load the constants first?
+ __m256d __w = _mm256_div_pd(__one, _mm256_set_pd(_w + 3 * ir[6], _w + 2 * ir[6], _w + ir[6], _w));
+ __m256d __x = _mm256_mul_pd(_mm256_set_pd(_x + 3 * ir[0], _x + 2 * ir[0], _x + ir[0], _x), __w);
+ __m256d __y = _mm256_mul_pd(_mm256_set_pd(_y + 3 * ir[3], _y + 2 * ir[3], _y + ir[3], _y), __w);
+ __m256d __x2 = _mm256_mul_pd(__x, __x);
+ __m256d __y2 = _mm256_mul_pd(__y, __y);
+ __m256d __r2 = _mm256_add_pd(__x2, __y2);
+ __m256d __2xy = _mm256_mul_pd(__two, _mm256_mul_pd(__x, __y));
+ __m256d __kr = _mm256_div_pd(
+#if CV_FMA3
+ _mm256_fmadd_pd(_mm256_fmadd_pd(_mm256_fmadd_pd(_mm256_set1_pd(k3), __r2, _mm256_set1_pd(k2)), __r2, _mm256_set1_pd(k1)), __r2, __one),
+ _mm256_fmadd_pd(_mm256_fmadd_pd(_mm256_fmadd_pd(_mm256_set1_pd(k6), __r2, _mm256_set1_pd(k5)), __r2, _mm256_set1_pd(k4)), __r2, __one)
+#else
+ _mm256_add_pd(__one, _mm256_mul_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(k3), __r2), _mm256_set1_pd(k2)), __r2), _mm256_set1_pd(k1)), __r2)),
+ _mm256_add_pd(__one, _mm256_mul_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(k6), __r2), _mm256_set1_pd(k5)), __r2), _mm256_set1_pd(k4)), __r2))
+#endif
+ );
+ __m256d __r22 = _mm256_mul_pd(__r2, __r2);
+#if CV_FMA3
+ __m256d __xd = _mm256_fmadd_pd(__x, __kr,
+ _mm256_add_pd(
+ _mm256_fmadd_pd(_mm256_set1_pd(p1), __2xy, _mm256_mul_pd(_mm256_set1_pd(p2), _mm256_fmadd_pd(__two, __x2, __r2))),
+ _mm256_fmadd_pd(_mm256_set1_pd(s1), __r2, _mm256_mul_pd(_mm256_set1_pd(s2), __r22))));
+ __m256d __yd = _mm256_fmadd_pd(__y, __kr,
+ _mm256_add_pd(
+ _mm256_fmadd_pd(_mm256_set1_pd(p1), _mm256_fmadd_pd(__two, __y2, __r2), _mm256_mul_pd(_mm256_set1_pd(p2), __2xy)),
+ _mm256_fmadd_pd(_mm256_set1_pd(s3), __r2, _mm256_mul_pd(_mm256_set1_pd(s4), __r22))));
+
+ __m256d __vecTilt2 = _mm256_fmadd_pd(__matTilt_20, __xd, _mm256_fmadd_pd(__matTilt_21, __yd, __matTilt_22));
+#else
+ __m256d __xd = _mm256_add_pd(
+ _mm256_mul_pd(__x, __kr),
+ _mm256_add_pd(
+ _mm256_add_pd(
+ _mm256_mul_pd(_mm256_set1_pd(p1), __2xy),
+ _mm256_mul_pd(_mm256_set1_pd(p2), _mm256_add_pd(__r2, _mm256_mul_pd(__two, __x2)))),
+ _mm256_add_pd(
+ _mm256_mul_pd(_mm256_set1_pd(s1), __r2),
+ _mm256_mul_pd(_mm256_set1_pd(s2), __r22))));
+ __m256d __yd = _mm256_add_pd(
+ _mm256_mul_pd(__y, __kr),
+ _mm256_add_pd(
+ _mm256_add_pd(
+ _mm256_mul_pd(_mm256_set1_pd(p1), _mm256_add_pd(__r2, _mm256_mul_pd(__two, __y2))),
+ _mm256_mul_pd(_mm256_set1_pd(p2), __2xy)),
+ _mm256_add_pd(
+ _mm256_mul_pd(_mm256_set1_pd(s3), __r2),
+ _mm256_mul_pd(_mm256_set1_pd(s4), __r22))));
+
+ __m256d __vecTilt2 = _mm256_add_pd(_mm256_add_pd(
+ _mm256_mul_pd(__matTilt_20, __xd), _mm256_mul_pd(__matTilt_21, __yd)), __matTilt_22);
+#endif
+ __m256d __invProj = _mm256_blendv_pd(
+ __one, _mm256_div_pd(__one, __vecTilt2),
+ _mm256_cmp_pd(__vecTilt2, _mm256_setzero_pd(), _CMP_EQ_OQ));
+
+#if CV_FMA3
+ __m256d __u = _mm256_fmadd_pd(__matTilt_00, __xd, _mm256_fmadd_pd(__matTilt_01, __yd, __matTilt_02));
+ __u = _mm256_fmadd_pd(_mm256_mul_pd(_mm256_set1_pd(fx), __invProj), __u, _mm256_set1_pd(u0));
+
+ __m256d __v = _mm256_fmadd_pd(__matTilt_10, __xd, _mm256_fmadd_pd(__matTilt_11, __yd, __matTilt_12));
+ __v = _mm256_fmadd_pd(_mm256_mul_pd(_mm256_set1_pd(fy), __invProj), __v, _mm256_set1_pd(v0));
+#else
+ __m256d __u = _mm256_add_pd(_mm256_add_pd(
+ _mm256_mul_pd(__matTilt_00, __xd), _mm256_mul_pd(__matTilt_01, __yd)), __matTilt_02);
+ __u = _mm256_add_pd(_mm256_mul_pd(_mm256_mul_pd(_mm256_set1_pd(fx), __invProj), __u), _mm256_set1_pd(u0));
+
+ __m256d __v = _mm256_add_pd(_mm256_add_pd(
+ _mm256_mul_pd(__matTilt_10, __xd), _mm256_mul_pd(__matTilt_11, __yd)), __matTilt_12);
+ __v = _mm256_add_pd(_mm256_mul_pd(_mm256_mul_pd(_mm256_set1_pd(fy), __invProj), __v), _mm256_set1_pd(v0));
+#endif
+
+ if (m1type == CV_32FC1)
+ {
+ _mm_storeu_ps(&m1f[j], _mm256_cvtpd_ps(__u));
+ _mm_storeu_ps(&m2f[j], _mm256_cvtpd_ps(__v));
+ }
+ else if (m1type == CV_32FC2)
+ {
+ __m128 __u_float = _mm256_cvtpd_ps(__u);
+ __m128 __v_float = _mm256_cvtpd_ps(__v);
+
+ _mm_storeu_ps(&m1f[j * 2], _mm_unpacklo_ps(__u_float, __v_float));
+ _mm_storeu_ps(&m1f[j * 2 + 4], _mm_unpackhi_ps(__u_float, __v_float));
+ }
+ else // m1type == CV_16SC2
+ {
+ __u = _mm256_mul_pd(__u, _mm256_set1_pd(INTER_TAB_SIZE));
+ __v = _mm256_mul_pd(__v, _mm256_set1_pd(INTER_TAB_SIZE));
+
+ __m128 __u_float = _mm256_cvtpd_ps(__u);
+ __m128 __v_float = _mm256_cvtpd_ps(__v);
+ _mm256_zeroupper();
+ static const __m128 __int_max = _mm_set1_ps((float)(std::numeric_limits<int>::max()));
+ static const __m128 __int_min = _mm_set1_ps((float)(std::numeric_limits<int>::min()));
+ __u_float = _mm_max_ps(_mm_min_ps(__u_float, __int_max), __int_min);
+ __v_float = _mm_max_ps(_mm_min_ps(__v_float, __int_max), __int_min);
+
+ __m128i __iu = _mm_cvtps_epi32(__u_float);
+ __m128i __iv = _mm_cvtps_epi32(__v_float);
+
+ static const __m128i __INTER_TAB_SIZE_m1 = _mm_set1_epi32(INTER_TAB_SIZE - 1);
+ __m128i __m2 = _mm_add_epi32(
+ _mm_mullo_epi32(_mm_and_si128(__iv, __INTER_TAB_SIZE_m1), _mm_set1_epi32(INTER_TAB_SIZE)),
+ _mm_and_si128(__iu, __INTER_TAB_SIZE_m1));
+ __m2 = _mm_packus_epi32(__m2, __m2);
+ _mm_maskstore_epi64((long long int*) &m2[j], _mm_set_epi32(0, 0, 0xFFFFFFFF, 0xFFFFFFFF), __m2);
+
+ // gcc4.9 does not support _mm256_set_m128
+ // __m256i __m1 = _mm256_set_m128i(__iv, __iu);
+ __m256i __m1 = _mm256_setzero_si256();
+ __m1 = _mm256_inserti128_si256(__m1, __iu, 0);
+ __m1 = _mm256_inserti128_si256(__m1, __iv, 1);
+ __m1 = _mm256_srai_epi32(__m1, INTER_BITS); // v3 v2 v1 v0 u3 u2 u1 u0 (int32_t)
+ static const __m256i __permute_mask = _mm256_set_epi32(7, 3, 6, 2, 5, 1, 4, 0);
+ __m1 = _mm256_permutevar8x32_epi32(__m1, __permute_mask); // v3 u3 v2 u2 v1 u1 v0 u0 (int32_t)
+ __m1 = _mm256_packs_epi32(__m1, __m1); // x x x x v3 u3 v2 u2 x x x x v1 u1 v0 u0 (int16_t)
+ _mm_storeu_si128((__m128i*) &m1[j * 2], _mm256_extracti128_si256(_mm256_permute4x64_epi64(__m1, (2 << 2) + 0), 0));
+ }
+ }
+
+ return j;
+}
+
+}
+
+/* End of file */
diff --git a/modules/imgproc/src/undistort.cpp b/modules/imgproc/src/undistort.cpp
index 127481f..4931d02 100644
--- a/modules/imgproc/src/undistort.cpp
+++ b/modules/imgproc/src/undistort.cpp
@@ -42,6 +42,7 @@
#include "precomp.hpp"
#include "opencv2/imgproc/detail/distortion_model.hpp"
+#include "undistort.hpp"
cv::Mat cv::getDefaultNewCameraMatrix( InputArray _cameraMatrix, Size imgsize,
bool centerPrincipalPoint )
@@ -136,6 +137,10 @@ void cv::initUndistortRectifyMap( InputArray _cameraMatrix, InputArray _distCoef
cv::Matx33d matTilt = cv::Matx33d::eye();
cv::detail::computeTiltProjectionMatrix(tauX, tauY, &matTilt);
+#if CV_TRY_AVX2
+ bool USE_AVX2 = cv::checkHardwareSupport(CV_CPU_AVX2);
+#endif
+
for( int i = 0; i < size.height; i++ )
{
float* m1f = map1.ptr<float>(i);
@@ -144,7 +149,21 @@ void cv::initUndistortRectifyMap( InputArray _cameraMatrix, InputArray _distCoef
ushort* m2 = (ushort*)m2f;
double _x = i*ir[1] + ir[2], _y = i*ir[4] + ir[5], _w = i*ir[7] + ir[8];
- for( int j = 0; j < size.width; j++, _x += ir[0], _y += ir[3], _w += ir[6] )
+ int j = 0;
+
+ if (m1type == CV_16SC2)
+ CV_Assert(m1 != NULL && m2 != NULL);
+ else if (m1type == CV_32FC1)
+ CV_Assert(m1f != NULL && m2f != NULL);
+ else
+ CV_Assert(m1 != NULL);
+
+#if CV_TRY_AVX2
+ if( USE_AVX2 )
+ j = cv::initUndistortRectifyMapLine_AVX(m1f, m2f, m1, m2, matTilt.val, ir, _x, _y, _w, size.width, m1type,
+ k1, k2, k3, k4, k5, k6, p1, p2, s1, s2, s3, s4, u0, v0, fx, fy);
+#endif
+ for( ; j < size.width; j++, _x += ir[0], _y += ir[3], _w += ir[6] )
{
double w = 1./_w, x = _x*w, y = _y*w;
double x2 = x*x, y2 = y*y;
@@ -476,8 +495,6 @@ static Point2f mapPointSpherical(const Point2f& p, float alpha, Vec4d* J, int pr
static Point2f invMapPointSpherical(Point2f _p, float alpha, int projType)
{
- static int avgiter = 0, avgn = 0;
-
double eps = 1e-12;
Vec2d p(_p.x, _p.y), q(_p.x, _p.y), err;
Vec4d J;
@@ -502,14 +519,6 @@ static Point2f invMapPointSpherical(Point2f _p, float alpha, int projType)
//q -= Vec2d((J.t()*J).inv()*(J.t()*err));
}
- if( i < maxiter )
- {
- avgiter += i;
- avgn++;
- if( avgn == 1500 )
- printf("avg iters = %g\n", (double)avgiter/avgn);
- }
-
return i < maxiter ? Point2f((float)q[0], (float)q[1]) : Point2f(-FLT_MAX, -FLT_MAX);
}
diff --git a/modules/imgproc/src/undistort.hpp b/modules/imgproc/src/undistort.hpp
new file mode 100644
index 0000000..c17de04
--- /dev/null
+++ b/modules/imgproc/src/undistort.hpp
@@ -0,0 +1,59 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
+// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#ifndef OPENCV_IMGPROC_UNDISTORT_HPP
+#define OPENCV_IMGPROC_UNDISTORT_HPP
+
+namespace cv
+{
+#if CV_TRY_AVX2
+ int initUndistortRectifyMapLine_AVX(float* m1f, float* m2f, short* m1, ushort* m2, double* matTilt, const double* ir,
+ double& _x, double& _y, double& _w, int width, int m1type,
+ double& k1, double& k2, double& k3, double& k4, double& k5, double& k6,
+ double& p1, double& p2, double& s1, double& s2, double& s3, double& s4,
+ double& u0, double& v0, double& fx, double& fy);
+#endif
+}
+
+#endif
+
+/* End of file */
diff --git a/modules/imgproc/test/ocl/test_warp.cpp b/modules/imgproc/test/ocl/test_warp.cpp
index c69d597..26f9462 100644
--- a/modules/imgproc/test/ocl/test_warp.cpp
+++ b/modules/imgproc/test/ocl/test_warp.cpp
@@ -414,7 +414,7 @@ OCL_TEST_P(Remap_INTER_LINEAR, Mat)
random_roi();
double eps = 2.0;
-#ifdef ANDROID
+#ifdef __ANDROID__
// TODO investigate accuracy
if (cv::ocl::Device::getDefault().isNVidia())
eps = 8.0;
diff --git a/modules/imgproc/test/test_bilateral_filter.cpp b/modules/imgproc/test/test_bilateral_filter.cpp
index 994f854..48f066b 100644
--- a/modules/imgproc/test/test_bilateral_filter.cpp
+++ b/modules/imgproc/test/test_bilateral_filter.cpp
@@ -251,20 +251,23 @@ namespace cvtest
int CV_BilateralFilterTest::validate_test_results(int test_case_index)
{
- static const double eps = 4;
-
+ double eps = (_src.depth() < CV_32F)?1:5e-3;
+ double e;
Mat reference_dst, reference_src;
if (_src.depth() == CV_32F)
+ {
reference_bilateral_filter(_src, reference_dst, _d, _sigma_color, _sigma_space);
+ e = cvtest::norm(reference_dst, _parallel_dst, NORM_INF|NORM_RELATIVE);
+ }
else
{
int type = _src.type();
_src.convertTo(reference_src, CV_32F);
reference_bilateral_filter(reference_src, reference_dst, _d, _sigma_color, _sigma_space);
reference_dst.convertTo(reference_dst, type);
+ e = cvtest::norm(reference_dst, _parallel_dst, NORM_INF);
}
- double e = cvtest::norm(reference_dst, _parallel_dst, NORM_L2);
if (e > eps)
{
ts->printf(cvtest::TS::CONSOLE, "actual error: %g, expected: %g", e, eps);
diff --git a/modules/imgproc/test/test_color.cpp b/modules/imgproc/test/test_color.cpp
index 2af2990..75ae3dd 100644
--- a/modules/imgproc/test/test_color.cpp
+++ b/modules/imgproc/test/test_color.cpp
@@ -2190,3 +2190,28 @@ TEST(ImgProc_Bayer2RGBA, accuracy)
}
}
}
+
+TEST(ImgProc_BGR2RGBA, regression_8696)
+{
+ Mat src(Size(80, 10), CV_8UC4);
+ src.setTo(Scalar(255, 0, 200, 100));
+
+ Mat dst;
+ cvtColor(src, dst, COLOR_BGR2BGRA);
+
+ EXPECT_DOUBLE_EQ(norm(dst - src, NORM_INF), 0.);
+}
+
+TEST(ImgProc_BGR2RGBA, 3ch24ch)
+{
+ Mat src(Size(80, 10), CV_8UC3);
+ src.setTo(Scalar(200, 0, 200));
+
+ Mat dst;
+ cvtColor(src, dst, COLOR_BGR2BGRA);
+
+ Mat expected(Size(80, 10), CV_8UC4);
+ expected.setTo(Scalar(80, 0, 200, 255));
+
+ EXPECT_DOUBLE_EQ(norm(expected - dst, NORM_INF), 0.);
+}
diff --git a/modules/imgproc/test/test_drawing.cpp b/modules/imgproc/test/test_drawing.cpp
index 1d6a2a8..2bd309a 100644
--- a/modules/imgproc/test/test_drawing.cpp
+++ b/modules/imgproc/test/test_drawing.cpp
@@ -709,6 +709,31 @@ TEST(Drawing, polylines)
ASSERT_EQ(cnt, 21);
}
+TEST(Drawing, longline)
+{
+ Mat mat = Mat::zeros(256, 256, CV_8UC1);
+
+ line(mat, cv::Point(34, 204), cv::Point(46400, 47400), cv::Scalar(255), 3);
+ EXPECT_EQ(310, cv::countNonZero(mat));
+
+ Point pt[6];
+ pt[0].x = 32;
+ pt[0].y = 204;
+ pt[1].x = 34;
+ pt[1].y = 202;
+ pt[2].x = 87;
+ pt[2].y = 255;
+ pt[3].x = 82;
+ pt[3].y = 255;
+ pt[4].x = 37;
+ pt[4].y = 210;
+ pt[5].x = 37;
+ pt[5].y = 209;
+ fillConvexPoly(mat, pt, 6, cv::Scalar(0));
+
+ EXPECT_EQ(0, cv::countNonZero(mat));
+}
+
TEST(Drawing, putText_no_garbage)
{
diff --git a/modules/imgproc/test/test_filter.cpp b/modules/imgproc/test/test_filter.cpp
index 886c5ab..c995feb 100644
--- a/modules/imgproc/test/test_filter.cpp
+++ b/modules/imgproc/test/test_filter.cpp
@@ -715,7 +715,7 @@ void CV_SmoothBaseTest::get_test_array_types_and_sizes( int test_case_idx,
double CV_SmoothBaseTest::get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ )
{
int depth = test_mat[INPUT][0].depth();
- return depth <= CV_8S ? 1 : 1e-5;
+ return depth < CV_32F ? 1 : 1e-5;
}
@@ -2065,3 +2065,36 @@ TEST(Imgproc_Sobel, borderTypes)
EXPECT_EQ(expected_dst.size(), dst.size());
EXPECT_DOUBLE_EQ(0.0, cvtest::norm(expected_dst, dst, NORM_INF));
}
+
+TEST(Imgproc_MorphEx, hitmiss_regression_8957)
+{
+ Mat_<uchar> src(3, 3);
+ src << 0, 255, 0,
+ 0, 0, 0,
+ 0, 255, 0;
+
+ Mat_<uchar> kernel = src / 255;
+
+ Mat dst;
+ morphologyEx(src, dst, MORPH_HITMISS, kernel);
+
+ Mat ref = Mat::zeros(3, 3, CV_8U);
+ ref.at<uchar>(1, 1) = 255;
+
+ ASSERT_DOUBLE_EQ(norm(dst, ref, NORM_INF), 0.);
+}
+
+TEST(Imgproc_MorphEx, hitmiss_zero_kernel)
+{
+ Mat_<uchar> src(3, 3);
+ src << 0, 255, 0,
+ 0, 0, 0,
+ 0, 255, 0;
+
+ Mat_<uchar> kernel = Mat_<uchar>::zeros(3, 3);
+
+ Mat dst;
+ morphologyEx(src, dst, MORPH_HITMISS, kernel);
+
+ ASSERT_DOUBLE_EQ(norm(dst, src, NORM_INF), 0.);
+}
diff --git a/modules/imgproc/test/test_houghLines.cpp b/modules/imgproc/test/test_houghLines.cpp
index 93a1202..a233342 100644
--- a/modules/imgproc/test/test_houghLines.cpp
+++ b/modules/imgproc/test/test_houghLines.cpp
@@ -189,7 +189,7 @@ void BaseHoughLineTest::run_test(int type)
else if (type == PROBABILISTIC)
count = countMatIntersection<Vec4i>(exp_lines, lines, 1e-4f, 0.f);
-#if defined HAVE_IPP && IPP_VERSION_X100 >= 810 && IPP_DISABLE_BLOCK
+#if defined HAVE_IPP && IPP_VERSION_X100 >= 810 && !IPP_DISABLE_HOUGH
EXPECT_GE( count, (int) (exp_lines.total() * 0.8) );
#else
EXPECT_EQ( count, (int) exp_lines.total());
diff --git a/modules/imgproc/test/test_imgwarp.cpp b/modules/imgproc/test/test_imgwarp.cpp
index 8246754..8200e56 100644
--- a/modules/imgproc/test/test_imgwarp.cpp
+++ b/modules/imgproc/test/test_imgwarp.cpp
@@ -1686,22 +1686,35 @@ TEST(Resize, Area_half)
TEST(Imgproc_Warp, multichannel)
{
+ static const int inter_types[] = {INTER_NEAREST, INTER_AREA, INTER_CUBIC,
+ INTER_LANCZOS4, INTER_LINEAR};
+ static const int inter_n = sizeof(inter_types) / sizeof(int);
+
+ static const int border_types[] = {BORDER_CONSTANT, BORDER_DEFAULT,
+ BORDER_REFLECT, BORDER_REPLICATE,
+ BORDER_WRAP, BORDER_WRAP};
+ static const int border_n = sizeof(border_types) / sizeof(int);
+
RNG& rng = theRNG();
- for( int iter = 0; iter < 30; iter++ )
+ for( int iter = 0; iter < 100; iter++ )
{
+ int inter = inter_types[rng.uniform(0, inter_n)];
+ int border = border_types[rng.uniform(0, border_n)];
int width = rng.uniform(3, 333);
int height = rng.uniform(3, 333);
- int cn = rng.uniform(1, 10);
+ int cn = rng.uniform(1, 15);
+ if(inter == INTER_CUBIC || inter == INTER_LANCZOS4)
+ cn = rng.uniform(1, 5);
Mat src(height, width, CV_8UC(cn)), dst;
//randu(src, 0, 256);
src.setTo(0.);
- Mat rot = getRotationMatrix2D(Point2f(0.f, 0.f), 1, 1);
- warpAffine(src, dst, rot, src.size());
+ Mat rot = getRotationMatrix2D(Point2f(0.f, 0.f), 1.0, 1.0);
+ warpAffine(src, dst, rot, src.size(), inter, border);
ASSERT_EQ(0.0, norm(dst, NORM_INF));
Mat rot2 = Mat::eye(3, 3, rot.type());
rot.copyTo(rot2.rowRange(0, 2));
- warpPerspective(src, dst, rot2, src.size());
+ warpPerspective(src, dst, rot2, src.size(), inter, border);
ASSERT_EQ(0.0, norm(dst, NORM_INF));
}
}
diff --git a/modules/java/CMakeLists.txt b/modules/java/CMakeLists.txt
index ed92e05..74bc0ef 100644
--- a/modules/java/CMakeLists.txt
+++ b/modules/java/CMakeLists.txt
@@ -8,6 +8,9 @@ if(APPLE_FRAMEWORK OR WINRT OR NOT PYTHON_DEFAULT_AVAILABLE OR NOT ANT_EXECUTABL
ocv_module_disable(java)
endif()
+set(the_description "The java bindings")
+ocv_add_module(java BINDINGS opencv_core opencv_imgproc)
+
if(EXISTS ${CMAKE_BINARY_DIR}/src)
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_BINARY_DIR}/src")
endif()
@@ -15,8 +18,12 @@ if(EXISTS ${CMAKE_BINARY_DIR}/gen)
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_BINARY_DIR}/gen")
endif()
-set(the_description "The java bindings")
-ocv_add_module(java BINDINGS opencv_core opencv_imgproc)
+if(ANDROID)
+ set(LIB_NAME_SUFIX "${OPENCV_VERSION_MAJOR}")
+else()
+ set(LIB_NAME_SUFIX "${OPENCV_VERSION_MAJOR}${OPENCV_VERSION_MINOR}${OPENCV_VERSION_PATCH}")
+endif()
+
ocv_module_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/generator/src/cpp")
ocv_module_include_directories("${OpenCV_SOURCE_DIR}/include")
@@ -68,7 +75,7 @@ macro(glob_more_specific_sources _type _root _output)
elseif(${_type} STREQUAL "CPP")
set(_masks "${_root}/src/cpp/*.cpp")
elseif(${_type} STREQUAL "JAVA")
- set(_masks "${_root}/src/java/*.java")
+ set(_masks "${_root}/src/java/*.java" "${_root}/src/java/*.java.in")
elseif(${_type} STREQUAL "AIDL")
set(_masks "${_root}/src/java/*.aidl")
endif()
@@ -139,16 +146,30 @@ glob_more_specific_sources(AIDL "${CMAKE_CURRENT_SOURCE_DIR}/generator" handwrit
# headers of OpenCV modules
set(opencv_public_headers "")
+set(opencv_type_dicts "")
set(generated_cpp_sources "")
set(generated_java_sources "")
foreach(module ${OPENCV_JAVA_MODULES})
set(module_java_dir "${OPENCV_MODULE_opencv_${module}_LOCATION}/misc/java")
+ # custom mappings between c and java/JNI types
+ set(custom_type_dict "${module_java_dir}/gen_dict.json")
+ if(EXISTS "${custom_type_dict}")
+ list(APPEND opencv_java_type_dict_${module} ${custom_type_dict})
+ endif()
+
set(custom_header_list "${module_java_dir}/filelist")
if(EXISTS "${custom_header_list}")
file(STRINGS "${custom_header_list}" module_headers)
ocv_list_add_prefix(module_headers "${OPENCV_MODULE_opencv_${module}_LOCATION}/")
else()
- set(module_headers "${OPENCV_MODULE_opencv_${module}_HEADERS}")
+ set(module_headers "")
+ # TODO Implement module's "_HEADERS_PUBLIC" variable (OpenCVModule.cmake)
+ foreach(hdr ${OPENCV_MODULE_opencv_${module}_HEADERS})
+ string(REGEX REPLACE "^.*opencv2/" "opencv2/" hdr2 "${hdr}")
+ if(NOT hdr2 MATCHES "opencv2/${m}/private.*" AND hdr2 MATCHES "^(opencv2/?.*)/[^/]+.h(..)?$" )
+ list(APPEND module_headers "${hdr}")
+ endif()
+ endforeach()
endif()
if(NOT module_headers)
@@ -163,6 +184,13 @@ foreach(module ${OPENCV_JAVA_MODULES})
include_directories("${module_java_dir}/src/cpp")
+ set(common_header_list "${module_java_dir}/filelist_common")
+ if(EXISTS "${common_header_list}")
+ file(STRINGS "${common_header_list}" __headers)
+ ocv_list_add_prefix(__headers "${OPENCV_MODULE_opencv_${module}_LOCATION}/")
+ list(APPEND opencv_java_common_headers_${module} ${__headers})
+ endif()
+
foreach(m ${OPENCV_MODULE_opencv_${module}_DEPS})
set(common_header_list "${OPENCV_MODULE_${m}_LOCATION}/misc/java/filelist_common")
if(EXISTS "${common_header_list}")
@@ -170,6 +198,11 @@ foreach(module ${OPENCV_JAVA_MODULES})
ocv_list_add_prefix(__headers "${OPENCV_MODULE_${m}_LOCATION}/")
list(APPEND opencv_java_common_headers_${module} ${__headers})
endif()
+ set(custom_type_dict "${OPENCV_MODULE_${m}_LOCATION}/misc/java/gen_dict.json")
+ if(EXISTS "${custom_type_dict}")
+ list(APPEND opencv_java_type_dict_${module} ${custom_type_dict})
+ list(APPEND opencv_type_dicts ${custom_type_dicts})
+ endif()
endforeach()
glob_more_specific_sources(H "${module_java_dir}" handwritten_h_sources)
@@ -180,7 +213,7 @@ foreach(module ${OPENCV_JAVA_MODULES})
# first run of gen_java.py (to get list of generated files)
file(REMOVE_RECURSE "${probe_dir}")
file(MAKE_DIRECTORY "${probe_dir}")
- execute_process(COMMAND ${PYTHON_DEFAULT_EXECUTABLE} "${scripts_gen_java}" "${scripts_hdr_parser}" ${module} ${opencv_public_headers_${module}} "--common" ${opencv_java_common_headers_${module}}
+ execute_process(COMMAND ${PYTHON_DEFAULT_EXECUTABLE} "${scripts_gen_java}" "-p" "${scripts_hdr_parser}" "-m" ${module} "-s" ${opencv_public_headers_${module}} "-c" ${opencv_java_common_headers_${module}} "-t" ${opencv_java_type_dict_${module}}
WORKING_DIRECTORY "${probe_dir}"
OUTPUT_QUIET ERROR_QUIET)
file(GLOB_RECURSE generated_java_sources_${module} RELATIVE "${probe_dir}" "${probe_dir}/*.java")
@@ -208,20 +241,20 @@ else()
endif()
endif()
-# IMPORTANT: add dependencies to cmake (we should rerun cmake if any of these files is modified)
-add_cmake_dependencies(${scripts_gen_java} ${scripts_hdr_parser} ${opencv_public_headers})
+# IMPORTANT: add dependencies to cmake (we should rerun cmake if any of these files are modified)
+add_cmake_dependencies(${scripts_gen_java} ${scripts_hdr_parser} ${opencv_public_headers} ${opencv_type_dicts})
######################################################################################################################################
# step 1: generate .cpp/.java from OpenCV headers
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/gen")
-set(step1_depends "${scripts_gen_java}" "${scripts_hdr_parser}" ${opencv_public_headers})
+set(step1_depends "${scripts_gen_java}" "${scripts_hdr_parser}" ${opencv_public_headers} ${opencv_type_dicts})
foreach(module ${OPENCV_JAVA_MODULES})
# second run of gen_java.py (at build time)
add_custom_command(OUTPUT ${generated_java_sources_${module}} "${CMAKE_CURRENT_BINARY_DIR}/gen/${module}.cpp"
- COMMAND ${PYTHON_DEFAULT_EXECUTABLE} "${scripts_gen_java}" "${scripts_hdr_parser}" ${module} ${opencv_public_headers_${module}} "--common" ${opencv_java_common_headers_${module}}
+ COMMAND ${PYTHON_DEFAULT_EXECUTABLE} "${scripts_gen_java}" "-p" "${scripts_hdr_parser}" "-m" ${module} "-s" ${opencv_public_headers_${module}} "-c" ${opencv_java_common_headers_${module}} "-t" ${opencv_java_type_dict_${module}}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/gen/"
- DEPENDS "${scripts_gen_java}" "${scripts_hdr_parser}" ${opencv_public_headers_${module}} ${opencv_java_common_headers_${module}}
+ DEPENDS "${scripts_gen_java}" "${scripts_hdr_parser}" ${opencv_public_headers_${module}} ${opencv_java_common_headers_${module}} ${opencv_java_type_dict_${module}}
)
endforeach()
@@ -230,22 +263,49 @@ endforeach()
# step 3: copy files to destination
set(step3_input_files ${generated_java_sources} ${handwritten_java_sources} ${handwritten_aidl_sources})
set(copied_files "")
+set(java_src_dir "${OpenCV_BINARY_DIR}/src")
foreach(java_file ${step3_input_files})
get_filename_component(java_file_name "${java_file}" NAME)
+ set(__configure 0)
+ if (java_file_name MATCHES "\\.in$")
+ string(REGEX REPLACE "\\.in$" "" java_file_name "${java_file_name}")
+ set(__configure 1)
+ endif()
string(REPLACE "-jdoc.java" ".java" java_file_name "${java_file_name}")
- string(REPLACE "+" "/" java_file_name "${java_file_name}")
- set(output_name "${OpenCV_BINARY_DIR}/src/org/opencv/${java_file_name}")
- add_custom_command(OUTPUT "${output_name}"
- COMMAND ${CMAKE_COMMAND} -E copy_if_different "${java_file}" "${output_name}"
- MAIN_DEPENDENCY "${java_file}"
- DEPENDS ${step1_depends} ${generated_java_sources} ${handwritten_java_sources}
- COMMENT "Generating src/org/opencv/${java_file_name}"
- )
- list(APPEND copied_files "${output_name}")
+ if(EXISTS "${java_file}")
+ file(STRINGS "${java_file}" PACKAGE_STR LIMIT_COUNT 1 REGEX "package.*;$")
+ else()
+ set(PACKAGE_STR "")
+ endif()
+ if(PACKAGE_STR)
+ list(GET PACKAGE_STR 0 package_name)
+ string(REGEX REPLACE "^package[ ]+" "" package_name "${package_name}")
+ string(REGEX REPLACE ";$" "" package_name "${package_name}")
+
+ string(REGEX REPLACE ".*\\+" "" java_file_name "${java_file_name}")
+ string(REPLACE "." "/" package_path "${package_name}")
+ set(output_name "${package_path}/${java_file_name}")
+ else()
+ string(REPLACE "+" "/" java_file_name "${java_file_name}")
+ set(output_name "org/opencv/${java_file_name}")
+ endif()
+ if(__configure)
+ configure_file("${java_file}" "${java_src_dir}/${output_name}" @ONLY)
+ elseif(NOT "${java_file}" MATCHES "${OpenCV_BINARY_DIR}/")
+ configure_file("${java_file}" "${java_src_dir}/${output_name}" COPYONLY)
+ else()
+ add_custom_command(OUTPUT "${java_src_dir}/${output_name}"
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different "${java_file}" "${java_src_dir}/${output_name}"
+ MAIN_DEPENDENCY "${java_file}"
+ DEPENDS "${java_file}"
+ COMMENT "Generating src/${output_name}"
+ )
+ endif()
+ list(APPEND copied_files "${java_src_dir}/${output_name}")
if(ANDROID)
- get_filename_component(install_subdir "${java_file_name}" PATH)
- install(FILES "${output_name}" DESTINATION "${JAVA_INSTALL_ROOT}/src/org/opencv/${install_subdir}" COMPONENT java)
+ get_filename_component(install_subdir "${output_name}" PATH)
+ install(FILES "${java_src_dir}/${output_name}" DESTINATION "${JAVA_INSTALL_ROOT}/src/${install_subdir}" COMPONENT java)
endif()
endforeach()
@@ -307,12 +367,6 @@ endif(ANDROID AND ANDROID_EXECUTABLE)
set(step3_depends ${step2_depends} ${step3_input_files} ${copied_files})
-if(ANDROID)
- set(LIB_NAME_SUFIX "${OPENCV_VERSION_MAJOR}")
-else()
- set(LIB_NAME_SUFIX "${OPENCV_VERSION_MAJOR}${OPENCV_VERSION_MINOR}${OPENCV_VERSION_PATCH}")
-endif()
-
file(MAKE_DIRECTORY "${OpenCV_BINARY_DIR}/bin")
# step 4: build jar
@@ -345,7 +399,7 @@ else(ANDROID)
list(APPEND step3_depends "${OpenCV_BINARY_DIR}/build.xml")
add_custom_command(OUTPUT "${JAR_FILE}" "${JAR_FILE}.dephelper"
- COMMAND ${ANT_EXECUTABLE} -q -noinput -k jar
+ COMMAND ${ANT_EXECUTABLE} -q -noinput -k jar javadoc
COMMAND ${CMAKE_COMMAND} -E touch "${JAR_FILE}.dephelper"
WORKING_DIRECTORY "${OpenCV_BINARY_DIR}"
DEPENDS ${step3_depends}
@@ -359,7 +413,7 @@ endif(ANDROID)
# workarounding lack of `__attribute__ ((visibility("default")))` in jni_md.h/JNIEXPORT
string(REPLACE "-fvisibility=hidden" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
-ocv_warnings_disable(CMAKE_CXX_FLAGS -Wunused-const-variable)
+ocv_warnings_disable(CMAKE_CXX_FLAGS -Wunused-const-variable -Wundef)
ocv_add_library(${the_module} SHARED ${handwritten_h_sources} ${handwritten_cpp_sources} ${generated_cpp_sources}
${copied_files}
diff --git a/modules/java/android_lib/jni/Android.mk b/modules/java/android_lib/jni/Android.mk
index 72418c8..129f567 100644
--- a/modules/java/android_lib/jni/Android.mk
+++ b/modules/java/android_lib/jni/Android.mk
@@ -2,7 +2,6 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
-OPENCV_CAMERA_MODULES := off
include OpenCV.mk
LOCAL_MODULE := opencv_java
diff --git a/modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java b/modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java
index 22f1229..d5c1ecd 100644
--- a/modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java
+++ b/modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java
@@ -82,7 +82,7 @@ public class OpenCVTestRunner extends InstrumentationTestRunner {
// Using OpenCV Manager for initialization;
Log("Internal OpenCV library not found. Using OpenCV Manager for initialization");
- OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_0_0, getContext(), mLoaderCallback);
+ OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION, getContext(), mLoaderCallback);
synchronized (this) {
try {
diff --git a/modules/java/build.xml.in b/modules/java/build.xml.in
index c1c1854..954ff62 100644
--- a/modules/java/build.xml.in
+++ b/modules/java/build.xml.in
@@ -2,6 +2,7 @@
<!-- process, this config is used to package the autogenerated .java -->
<!-- interface files into OpenCV.jar -->
<project name="OpenCV">
+
<target name="jar">
<!-- This is to make a jar with a source attachment, for e.g. easy -->
<!-- navigation in Eclipse. See this question: -->
@@ -10,7 +11,21 @@
<include name="**/*.java"/>
<compilerarg line="-encoding utf-8"/>
</javac>
-
<jar basedir="src" destfile="bin/@JAR_NAME@"/>
</target>
+
+ <target name="javadoc">
+ <tstamp>
+ <format property="doctimestamp" pattern="EEE MMM d yyyy HH:mm:ss z"/>
+ </tstamp>
+ <javadoc
+ packagenames="org.opencv.*"
+ sourcepath="src"
+ destdir="doc/javadoc"
+ Windowtitle="OpenCV @OPENCV_VERSION_PLAIN@ Java documentation"
+ Doctitle="OpenCV Java documentation (@OPENCV_VERSION@)"
+ bottom="Generated on ${doctimestamp} / OpenCV @OPENCV_VCSVERSION@"
+ />
+ </target>
+
</project>
diff --git a/modules/java/generator/gen_java.py b/modules/java/generator/gen_java.py
index fc8cc14..0bfb25e 100755
--- a/modules/java/generator/gen_java.py
+++ b/modules/java/generator/gen_java.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
import sys, re, os.path
+import json
import logging
from pprint import pformat
from string import Template
@@ -10,175 +11,23 @@ if sys.version_info[0] >= 3:
else:
from cStringIO import StringIO
-class_ignore_list = (
- #core
- "FileNode", "FileStorage", "KDTree", "KeyPoint", "DMatch",
- #features2d
- "SimpleBlobDetector"
-)
-
-const_ignore_list = (
- "CV_CAP_OPENNI",
- "CV_CAP_PROP_OPENNI_",
- "CV_CAP_INTELPERC",
- "CV_CAP_PROP_INTELPERC_"
- "WINDOW_AUTOSIZE",
- "CV_WND_PROP_",
- "CV_WINDOW_",
- "CV_EVENT_",
- "CV_GUI_",
- "CV_PUSH_BUTTON",
- "CV_CHECKBOX",
- "CV_RADIOBOX",
-
- #attention!
- #the following constants are added to this list using code automatic generation
- #TODO: should be checked
- "CV_CAP_ANY",
- "CV_CAP_MIL",
- "CV_CAP_VFW",
- "CV_CAP_V4L",
- "CV_CAP_V4L2",
- "CV_CAP_FIREWARE",
- "CV_CAP_FIREWIRE",
- "CV_CAP_IEEE1394",
- "CV_CAP_DC1394",
- "CV_CAP_CMU1394",
- "CV_CAP_STEREO",
- "CV_CAP_TYZX",
- "CV_TYZX_LEFT",
- "CV_TYZX_RIGHT",
- "CV_TYZX_COLOR",
- "CV_TYZX_Z",
- "CV_CAP_QT",
- "CV_CAP_UNICAP",
- "CV_CAP_DSHOW",
- "CV_CAP_PVAPI",
- "CV_CAP_PROP_DC1394_OFF",
- "CV_CAP_PROP_DC1394_MODE_MANUAL",
- "CV_CAP_PROP_DC1394_MODE_AUTO",
- "CV_CAP_PROP_DC1394_MODE_ONE_PUSH_AUTO",
- "CV_CAP_PROP_POS_MSEC",
- "CV_CAP_PROP_POS_FRAMES",
- "CV_CAP_PROP_POS_AVI_RATIO",
- "CV_CAP_PROP_FPS",
- "CV_CAP_PROP_FOURCC",
- "CV_CAP_PROP_FRAME_COUNT",
- "CV_CAP_PROP_FORMAT",
- "CV_CAP_PROP_MODE",
- "CV_CAP_PROP_BRIGHTNESS",
- "CV_CAP_PROP_CONTRAST",
- "CV_CAP_PROP_SATURATION",
- "CV_CAP_PROP_HUE",
- "CV_CAP_PROP_GAIN",
- "CV_CAP_PROP_EXPOSURE",
- "CV_CAP_PROP_CONVERT_RGB",
- "CV_CAP_PROP_WHITE_BALANCE_BLUE_U",
- "CV_CAP_PROP_RECTIFICATION",
- "CV_CAP_PROP_MONOCHROME",
- "CV_CAP_PROP_SHARPNESS",
- "CV_CAP_PROP_AUTO_EXPOSURE",
- "CV_CAP_PROP_GAMMA",
- "CV_CAP_PROP_TEMPERATURE",
- "CV_CAP_PROP_TRIGGER",
- "CV_CAP_PROP_TRIGGER_DELAY",
- "CV_CAP_PROP_WHITE_BALANCE_RED_V",
- "CV_CAP_PROP_MAX_DC1394",
- "CV_CAP_GSTREAMER_QUEUE_LENGTH",
- "CV_CAP_PROP_PVAPI_MULTICASTIP",
- "CV_CAP_PROP_SUPPORTED_PREVIEW_SIZES_STRING",
- "EVENT_.*",
- "CV_L?(BGRA?|RGBA?|GRAY|XYZ|YCrCb|Luv|Lab|HLS|YUV|HSV)\d*2L?(BGRA?|RGBA?|GRAY|XYZ|YCrCb|Luv|Lab|HLS|YUV|HSV).*",
- "CV_COLORCVT_MAX",
- "CV_.*Bayer.*",
- "CV_YUV420(i|sp|p)2.+",
- "CV_TM_.+",
- "CV_FLOODFILL_.+",
- "CV_ADAPTIVE_THRESH_.+",
- "WINDOW_.+",
- "WND_PROP_.+",
-)
-
-const_private_list = (
- "CV_MOP_.+",
- "CV_INTER_.+",
- "CV_THRESH_.+",
- "CV_INPAINT_.+",
- "CV_RETR_.+",
- "CV_CHAIN_APPROX_.+",
- "OPPONENTEXTRACTOR",
- "GRIDDETECTOR",
- "PYRAMIDDETECTOR",
- "DYNAMICDETECTOR",
-)
+# list of class names, which should be skipped by wrapper generator
+# the list is loaded from misc/java/gen_dict.json defined for the module and its dependencies
+class_ignore_list = []
-# { Module : { public : [[name, val],...], private : [[]...] } }
-missing_consts = \
-{
- 'Core' :
- {
- 'private' :
- (
- ('CV_8U', 0 ), ('CV_8S', 1 ),
- ('CV_16U', 2 ), ('CV_16S', 3 ),
- ('CV_32S', 4 ),
- ('CV_32F', 5 ), ('CV_64F', 6 ),
- ('CV_USRTYPE1', 7 ),
- ), # private
- 'public' :
- (
- ('SVD_MODIFY_A', 1), ('SVD_NO_UV', 2), ('SVD_FULL_UV', 4),
- ('FILLED', -1),
- ('REDUCE_SUM', 0), ('REDUCE_AVG', 1), ('REDUCE_MAX', 2), ('REDUCE_MIN', 3),
- ) #public
- }, # Core
-
- "Imgproc":
- {
- 'private' :
- (
- ('IPL_BORDER_CONSTANT', 0 ),
- ('IPL_BORDER_REPLICATE', 1 ),
- ('IPL_BORDER_REFLECT', 2 ),
- ('IPL_BORDER_WRAP', 3 ),
- ('IPL_BORDER_REFLECT_101', 4 ),
- ('IPL_BORDER_TRANSPARENT', 5 ),
- ), # private
- 'public' :
- (
- ('LINE_AA', 16), ('LINE_8', 8), ('LINE_4', 4),
- ) #public
- }, # Imgproc
-
- "Calib3d":
- {
- 'public' :
- (
- ('CALIB_USE_INTRINSIC_GUESS', '1'),
- ('CALIB_RECOMPUTE_EXTRINSIC', '2'),
- ('CALIB_CHECK_COND', '4'),
- ('CALIB_FIX_SKEW', '8'),
- ('CALIB_FIX_K1', '16'),
- ('CALIB_FIX_K2', '32'),
- ('CALIB_FIX_K3', '64'),
- ('CALIB_FIX_K4', '128'),
- ('CALIB_FIX_INTRINSIC', '256')
- )
- }, # Calib3d
-
- "Video":
- {
- 'private' :
- (
- ('CV_LKFLOW_INITIAL_GUESSES', 4 ),
- ('CV_LKFLOW_GET_MIN_EIGENVALS', 8 ),
- ) # private
- }, # Video
+# list of constant names, which should be skipped by wrapper generator
+# ignored constants can be defined using regular expressions
+const_ignore_list = []
-}
+# list of private constants
+const_private_list = []
+# { Module : { public : [[name, val],...], private : [[]...] } }
+missing_consts = {}
# c_type : { java/jni correspondence }
+# Complex data types are configured for each module using misc/java/gen_dict.json
+
type_dict = {
# "simple" : { j_type : "?", jn_type : "?", jni_type : "?", suffix : "?" },
"" : { "j_type" : "", "jn_type" : "long", "jni_type" : "jlong" }, # c-tor ret_type
@@ -194,393 +43,14 @@ type_dict = {
"size_t" : { "j_type" : "long", "jn_type" : "long", "jni_type" : "jlong", "suffix" : "J" },
"__int64" : { "j_type" : "long", "jn_type" : "long", "jni_type" : "jlong", "suffix" : "J" },
"int64" : { "j_type" : "long", "jn_type" : "long", "jni_type" : "jlong", "suffix" : "J" },
- "double[]": { "j_type" : "double[]", "jn_type" : "double[]", "jni_type" : "jdoubleArray", "suffix" : "_3D" },
-
-# "complex" : { j_type : "?", jn_args : (("", ""),), jn_name : "", jni_var : "", jni_name : "", "suffix" : "?" },
-
- "vector_Point" : { "j_type" : "MatOfPoint", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<Point> %(n)s", "suffix" : "J" },
- "vector_Point2f" : { "j_type" : "MatOfPoint2f", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<Point2f> %(n)s", "suffix" : "J" },
- #"vector_Point2d" : { "j_type" : "MatOfPoint2d", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<Point2d> %(n)s", "suffix" : "J" },
- "vector_Point3i" : { "j_type" : "MatOfPoint3", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<Point3i> %(n)s", "suffix" : "J" },
- "vector_Point3f" : { "j_type" : "MatOfPoint3f", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<Point3f> %(n)s", "suffix" : "J" },
- #"vector_Point3d" : { "j_type" : "MatOfPoint3d", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<Point3d> %(n)s", "suffix" : "J" },
- "vector_KeyPoint" : { "j_type" : "MatOfKeyPoint", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<KeyPoint> %(n)s", "suffix" : "J" },
- "vector_DMatch" : { "j_type" : "MatOfDMatch", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<DMatch> %(n)s", "suffix" : "J" },
- "vector_Rect" : { "j_type" : "MatOfRect", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<Rect> %(n)s", "suffix" : "J" },
- "vector_uchar" : { "j_type" : "MatOfByte", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<uchar> %(n)s", "suffix" : "J" },
- "vector_char" : { "j_type" : "MatOfByte", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<char> %(n)s", "suffix" : "J" },
- "vector_int" : { "j_type" : "MatOfInt", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<int> %(n)s", "suffix" : "J" },
- "vector_float" : { "j_type" : "MatOfFloat", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<float> %(n)s", "suffix" : "J" },
- "vector_double" : { "j_type" : "MatOfDouble", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<double> %(n)s", "suffix" : "J" },
- "vector_Vec4i" : { "j_type" : "MatOfInt4", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<Vec4i> %(n)s", "suffix" : "J" },
- "vector_Vec4f" : { "j_type" : "MatOfFloat4", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<Vec4f> %(n)s", "suffix" : "J" },
- "vector_Vec6f" : { "j_type" : "MatOfFloat6", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<Vec6f> %(n)s", "suffix" : "J" },
-
- "vector_Mat" : { "j_type" : "List<Mat>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector<Mat> %(n)s", "suffix" : "J" },
-
- "vector_vector_KeyPoint": { "j_type" : "List<MatOfKeyPoint>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector< std::vector<KeyPoint> > %(n)s" },
- "vector_vector_DMatch" : { "j_type" : "List<MatOfDMatch>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector< std::vector<DMatch> > %(n)s" },
- "vector_vector_char" : { "j_type" : "List<MatOfByte>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector< std::vector<char> > %(n)s" },
- "vector_vector_Point" : { "j_type" : "List<MatOfPoint>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector< std::vector<Point> > %(n)s" },
- "vector_vector_Point2f" : { "j_type" : "List<MatOfPoint2f>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector< std::vector<Point2f> > %(n)s" },
- "vector_vector_Point3f" : { "j_type" : "List<MatOfPoint3f>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "std::vector< std::vector<Point3f> > %(n)s" },
-
- "Mat" : { "j_type" : "Mat", "jn_type" : "long", "jn_args" : (("__int64", ".nativeObj"),),
- "jni_var" : "Mat& %(n)s = *((Mat*)%(n)s_nativeObj)",
- "jni_type" : "jlong", #"jni_name" : "*%(n)s",
- "suffix" : "J" },
-
- "Point" : { "j_type" : "Point", "jn_args" : (("double", ".x"), ("double", ".y")),
- "jni_var" : "Point %(n)s((int)%(n)s_x, (int)%(n)s_y)", "jni_type" : "jdoubleArray",
- "suffix" : "DD"},
- "Point2f" : { "j_type" : "Point", "jn_args" : (("double", ".x"), ("double", ".y")),
- "jni_var" : "Point2f %(n)s((float)%(n)s_x, (float)%(n)s_y)", "jni_type" : "jdoubleArray",
- "suffix" : "DD"},
- "Point2d" : { "j_type" : "Point", "jn_args" : (("double", ".x"), ("double", ".y")),
- "jni_var" : "Point2d %(n)s(%(n)s_x, %(n)s_y)", "jni_type" : "jdoubleArray",
- "suffix" : "DD"},
- "Point3i" : { "j_type" : "Point3", "jn_args" : (("double", ".x"), ("double", ".y"), ("double", ".z")),
- "jni_var" : "Point3i %(n)s((int)%(n)s_x, (int)%(n)s_y, (int)%(n)s_z)", "jni_type" : "jdoubleArray",
- "suffix" : "DDD"},
- "Point3f" : { "j_type" : "Point3", "jn_args" : (("double", ".x"), ("double", ".y"), ("double", ".z")),
- "jni_var" : "Point3f %(n)s((float)%(n)s_x, (float)%(n)s_y, (float)%(n)s_z)", "jni_type" : "jdoubleArray",
- "suffix" : "DDD"},
- "Point3d" : { "j_type" : "Point3", "jn_args" : (("double", ".x"), ("double", ".y"), ("double", ".z")),
- "jni_var" : "Point3d %(n)s(%(n)s_x, %(n)s_y, %(n)s_z)", "jni_type" : "jdoubleArray",
- "suffix" : "DDD"},
- "KeyPoint": { "j_type" : "KeyPoint", "jn_args" : (("float", ".x"), ("float", ".y"), ("float", ".size"),
- ("float", ".angle"), ("float", ".response"), ("int", ".octave"), ("int", ".class_id")),
- "jni_var" : "KeyPoint %(n)s(%(n)s_x, %(n)s_y, %(n)s_size, %(n)s_angle, %(n)s_response, %(n)s_octave, %(n)s_class_id)",
- "jni_type" : "jdoubleArray",
- "suffix" : "FFFFFII"},
- "DMatch" : { "j_type" : "DMatch", "jn_args" : ( ('int', 'queryIdx'), ('int', 'trainIdx'),
- ('int', 'imgIdx'), ('float', 'distance'), ),
- "jni_var" : "DMatch %(n)s(%(n)s_queryIdx, %(n)s_trainIdx, %(n)s_imgIdx, %(n)s_distance)",
- "jni_type" : "jdoubleArray",
- "suffix" : "IIIF"},
- "Rect" : { "j_type" : "Rect", "jn_args" : (("int", ".x"), ("int", ".y"), ("int", ".width"), ("int", ".height")),
- "jni_var" : "Rect %(n)s(%(n)s_x, %(n)s_y, %(n)s_width, %(n)s_height)", "jni_type" : "jdoubleArray",
- "suffix" : "IIII"},
- "Size" : { "j_type" : "Size", "jn_args" : (("double", ".width"), ("double", ".height")),
- "jni_var" : "Size %(n)s((int)%(n)s_width, (int)%(n)s_height)", "jni_type" : "jdoubleArray",
- "suffix" : "DD"},
- "Size2f" : { "j_type" : "Size", "jn_args" : (("double", ".width"), ("double", ".height")),
- "jni_var" : "Size2f %(n)s((float)%(n)s_width, (float)%(n)s_height)", "jni_type" : "jdoubleArray",
- "suffix" : "DD"},
- "RotatedRect": { "j_type" : "RotatedRect", "jn_args" : (("double", ".center.x"), ("double", ".center.y"), ("double", ".size.width"), ("double", ".size.height"), ("double", ".angle")),
- "jni_var" : "RotatedRect %(n)s(cv::Point2f(%(n)s_center_x, %(n)s_center_y), cv::Size2f(%(n)s_size_width, %(n)s_size_height), %(n)s_angle)",
- "jni_type" : "jdoubleArray", "suffix" : "DDDDD"},
- "Scalar" : { "j_type" : "Scalar", "jn_args" : (("double", ".val[0]"), ("double", ".val[1]"), ("double", ".val[2]"), ("double", ".val[3]")),
- "jni_var" : "Scalar %(n)s(%(n)s_val0, %(n)s_val1, %(n)s_val2, %(n)s_val3)", "jni_type" : "jdoubleArray",
- "suffix" : "DDDD"},
- "Range" : { "j_type" : "Range", "jn_args" : (("int", ".start"), ("int", ".end")),
- "jni_var" : "Range %(n)s(%(n)s_start, %(n)s_end)", "jni_type" : "jdoubleArray",
- "suffix" : "II"},
- "CvSlice" : { "j_type" : "Range", "jn_args" : (("int", ".start"), ("int", ".end")),
- "jni_var" : "Range %(n)s(%(n)s_start, %(n)s_end)", "jni_type" : "jdoubleArray",
- "suffix" : "II"},
- "String" : { "j_type" : "String", "jn_type" : "String",
- "jni_type" : "jstring", "jni_name" : "n_%(n)s",
- "jni_var" : 'const char* utf_%(n)s = env->GetStringUTFChars(%(n)s, 0); String n_%(n)s( utf_%(n)s ? utf_%(n)s : "" ); env->ReleaseStringUTFChars(%(n)s, utf_%(n)s)',
- "suffix" : "Ljava_lang_String_2"},
- "c_string": { "j_type" : "String", "jn_type" : "String",
- "jni_type" : "jstring", "jni_name" : "n_%(n)s.c_str()",
- "jni_var" : 'const char* utf_%(n)s = env->GetStringUTFChars(%(n)s, 0); String n_%(n)s( utf_%(n)s ? utf_%(n)s : "" ); env->ReleaseStringUTFChars(%(n)s, utf_%(n)s)',
- "suffix" : "Ljava_lang_String_2"},
-"TermCriteria": { "j_type" : "TermCriteria", "jn_args" : (("int", ".type"), ("int", ".maxCount"), ("double", ".epsilon")),
- "jni_var" : "TermCriteria %(n)s(%(n)s_type, %(n)s_maxCount, %(n)s_epsilon)", "jni_type" : "jdoubleArray",
- "suffix" : "IID"},
-"CvTermCriteria": { "j_type" : "TermCriteria", "jn_args" : (("int", ".type"), ("int", ".maxCount"), ("double", ".epsilon")),
- "jni_var" : "TermCriteria %(n)s(%(n)s_type, %(n)s_maxCount, %(n)s_epsilon)", "jni_type" : "jdoubleArray",
- "suffix" : "IID"},
- "Vec2d" : { "j_type" : "double[]", "jn_args" : (("double", ".val[0]"), ("double", ".val[1]")),
- "jn_type" : "double[]",
- "jni_var" : "Vec2d %(n)s(%(n)s_val0, %(n)s_val1)", "jni_type" : "jdoubleArray",
- "suffix" : "DD"},
- "Vec3d" : { "j_type" : "double[]", "jn_args" : (("double", ".val[0]"), ("double", ".val[1]"), ("double", ".val[2]")),
- "jn_type" : "double[]",
- "jni_var" : "Vec3d %(n)s(%(n)s_val0, %(n)s_val1, %(n)s_val2)", "jni_type" : "jdoubleArray",
- "suffix" : "DDD"},
- "Moments" : {
- "j_type" : "Moments",
- "jn_args" : (("double", ".m00"), ("double", ".m10"), ("double", ".m01"), ("double", ".m20"), ("double", ".m11"),
- ("double", ".m02"), ("double", ".m30"), ("double", ".m21"), ("double", ".m12"), ("double", ".m03")),
- "jni_var" : "Moments %(n)s(%(n)s_m00, %(n)s_m10, %(n)s_m01, %(n)s_m20, %(n)s_m11, %(n)s_m02, %(n)s_m30, %(n)s_m21, %(n)s_m12, %(n)s_m03)",
- "jni_type" : "jdoubleArray",
- "suffix" : "DDDDDDDDDD"},
-
+ "double[]": { "j_type" : "double[]", "jn_type" : "double[]", "jni_type" : "jdoubleArray", "suffix" : "_3D" }
}
# { class : { func : {j_code, jn_code, cpp_code} } }
-ManualFuncs = {
- 'Core' :
- {
- 'minMaxLoc' : {
- 'j_code' : """
- // manual port
- public static class MinMaxLocResult {
- public double minVal;
- public double maxVal;
- public Point minLoc;
- public Point maxLoc;
-
- public MinMaxLocResult() {
- minVal=0; maxVal=0;
- minLoc=new Point();
- maxLoc=new Point();
- }
- }
-
- // C++: minMaxLoc(Mat src, double* minVal, double* maxVal=0, Point* minLoc=0, Point* maxLoc=0, InputArray mask=noArray())
-
- //javadoc: minMaxLoc(src, mask)
- public static MinMaxLocResult minMaxLoc(Mat src, Mat mask) {
- MinMaxLocResult res = new MinMaxLocResult();
- long maskNativeObj=0;
- if (mask != null) {
- maskNativeObj=mask.nativeObj;
- }
- double resarr[] = n_minMaxLocManual(src.nativeObj, maskNativeObj);
- res.minVal=resarr[0];
- res.maxVal=resarr[1];
- res.minLoc.x=resarr[2];
- res.minLoc.y=resarr[3];
- res.maxLoc.x=resarr[4];
- res.maxLoc.y=resarr[5];
- return res;
- }
-
- //javadoc: minMaxLoc(src)
- public static MinMaxLocResult minMaxLoc(Mat src) {
- return minMaxLoc(src, null);
- }
-
-""",
- 'jn_code' :
-""" private static native double[] n_minMaxLocManual(long src_nativeObj, long mask_nativeObj);\n""",
- 'cpp_code' :
-"""
-// C++: minMaxLoc(Mat src, double* minVal, double* maxVal=0, Point* minLoc=0, Point* maxLoc=0, InputArray mask=noArray())
-JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1minMaxLocManual (JNIEnv*, jclass, jlong, jlong);
-
-JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1minMaxLocManual
- (JNIEnv* env, jclass, jlong src_nativeObj, jlong mask_nativeObj)
-{
- try {
- LOGD("Core::n_1minMaxLoc()");
- jdoubleArray result;
- result = env->NewDoubleArray(6);
- if (result == NULL) {
- return NULL; /* out of memory error thrown */
- }
-
- Mat& src = *((Mat*)src_nativeObj);
-
- double minVal, maxVal;
- Point minLoc, maxLoc;
- if (mask_nativeObj != 0) {
- Mat& mask = *((Mat*)mask_nativeObj);
- minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc, mask);
- } else {
- minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc);
- }
-
- jdouble fill[6];
- fill[0]=minVal;
- fill[1]=maxVal;
- fill[2]=minLoc.x;
- fill[3]=minLoc.y;
- fill[4]=maxLoc.x;
- fill[5]=maxLoc.y;
-
- env->SetDoubleArrayRegion(result, 0, 6, fill);
-
- return result;
-
- } catch(const cv::Exception& e) {
- LOGD("Core::n_1minMaxLoc() catched cv::Exception: %s", e.what());
- jclass je = env->FindClass("org/opencv/core/CvException");
- if(!je) je = env->FindClass("java/lang/Exception");
- env->ThrowNew(je, e.what());
- return NULL;
- } catch (...) {
- LOGD("Core::n_1minMaxLoc() catched unknown exception (...)");
- jclass je = env->FindClass("java/lang/Exception");
- env->ThrowNew(je, "Unknown exception in JNI code {core::minMaxLoc()}");
- return NULL;
- }
-}
-
-""",
- }, # minMaxLoc
-
-
-## "checkRange" : #TBD
-## {'j_code' : '/* TBD: checkRange() */', 'jn_code' : '', 'cpp_code' : '' },
-
- "checkHardwareSupport" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
- "setUseOptimized" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
- "useOptimized" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
-
- }, # Core
-
- 'Imgproc' :
- {
- 'getTextSize' :
- {
- 'j_code' :
- """
- // C++: Size getTextSize(const String& text, int fontFace, double fontScale, int thickness, int* baseLine);
- //javadoc:getTextSize(text, fontFace, fontScale, thickness, baseLine)
- public static Size getTextSize(String text, int fontFace, double fontScale, int thickness, int[] baseLine) {
- if(baseLine != null && baseLine.length != 1)
- throw new java.lang.IllegalArgumentException("'baseLine' must be 'int[1]' or 'null'.");
- Size retVal = new Size(n_getTextSize(text, fontFace, fontScale, thickness, baseLine));
- return retVal;
- }
- """,
- 'jn_code' :
- """ private static native double[] n_getTextSize(String text, int fontFace, double fontScale, int thickness, int[] baseLine);\n""",
- 'cpp_code' :
- """
- // C++: Size getTextSize(const String& text, int fontFace, double fontScale, int thickness, int* baseLine);
- JNIEXPORT jdoubleArray JNICALL Java_org_opencv_imgproc_Imgproc_n_1getTextSize (JNIEnv*, jclass, jstring, jint, jdouble, jint, jintArray);
-
- JNIEXPORT jdoubleArray JNICALL Java_org_opencv_imgproc_Imgproc_n_1getTextSize
- (JNIEnv* env, jclass, jstring text, jint fontFace, jdouble fontScale, jint thickness, jintArray baseLine)
- {
- try {
- LOGD("Core::n_1getTextSize()");
- jdoubleArray result;
- result = env->NewDoubleArray(2);
- if (result == NULL) {
- return NULL; /* out of memory error thrown */
- }
-
- const char* utf_text = env->GetStringUTFChars(text, 0);
- String n_text( utf_text ? utf_text : "" );
- env->ReleaseStringUTFChars(text, utf_text);
-
- int _baseLine;
- int* pbaseLine = 0;
-
- if (baseLine != NULL)
- pbaseLine = &_baseLine;
-
- cv::Size rsize = cv::getTextSize(n_text, (int)fontFace, (double)fontScale, (int)thickness, pbaseLine);
-
- jdouble fill[2];
- fill[0]=rsize.width;
- fill[1]=rsize.height;
-
- env->SetDoubleArrayRegion(result, 0, 2, fill);
-
- if (baseLine != NULL) {
- jint jbaseLine = (jint)(*pbaseLine);
- env->SetIntArrayRegion(baseLine, 0, 1, &jbaseLine);
- }
-
- return result;
-
- } catch(const cv::Exception& e) {
- LOGD("Imgproc::n_1getTextSize() catched cv::Exception: %s", e.what());
- jclass je = env->FindClass("org/opencv/core/CvException");
- if(!je) je = env->FindClass("java/lang/Exception");
- env->ThrowNew(je, e.what());
- return NULL;
- } catch (...) {
- LOGD("Imgproc::n_1getTextSize() catched unknown exception (...)");
- jclass je = env->FindClass("java/lang/Exception");
- env->ThrowNew(je, "Unknown exception in JNI code {core::getTextSize()}");
- return NULL;
- }
- }
- """,
- }, # getTextSize
-
- }, # Imgproc
-
- 'Highgui' :
- {
- "namedWindow" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
- "destroyWindow" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
- "destroyAllWindows" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
- "startWindowThread" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
- "setWindowProperty" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
- "getWindowProperty" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
- "getTrackbarPos" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
- "setTrackbarPos" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
- "imshow" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
- "waitKey" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
- "moveWindow" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
- "resizeWindow" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
- }, # Highgui
-}
+ManualFuncs = {}
# { class : { func : { arg_name : {"ctype" : ctype, "attrib" : [attrib]} } } }
-func_arg_fix = {
- '' : {
- 'randu' : { 'low' : {"ctype" : 'double'},
- 'high' : {"ctype" : 'double'} },
- 'randn' : { 'mean' : {"ctype" : 'double'},
- 'stddev' : {"ctype" : 'double'} },
- 'inRange' : { 'lowerb' : {"ctype" : 'Scalar'},
- 'upperb' : {"ctype" : 'Scalar'} },
- 'goodFeaturesToTrack' : { 'corners' : {"ctype" : 'vector_Point'} },
- 'findFundamentalMat' : { 'points1' : {"ctype" : 'vector_Point2f'},
- 'points2' : {"ctype" : 'vector_Point2f'} },
- 'cornerSubPix' : { 'corners' : {"ctype" : 'vector_Point2f'} },
- 'minEnclosingCircle' : { 'points' : {"ctype" : 'vector_Point2f'} },
- 'findHomography' : { 'srcPoints' : {"ctype" : 'vector_Point2f'},
- 'dstPoints' : {"ctype" : 'vector_Point2f'} },
- 'solvePnP' : { 'objectPoints' : {"ctype" : 'vector_Point3f'},
- 'imagePoints' : {"ctype" : 'vector_Point2f'},
- 'distCoeffs' : {"ctype" : 'vector_double' } },
- 'solvePnPRansac' : { 'objectPoints' : {"ctype" : 'vector_Point3f'},
- 'imagePoints' : {"ctype" : 'vector_Point2f'},
- 'distCoeffs' : {"ctype" : 'vector_double' } },
- 'calcOpticalFlowPyrLK' : { 'prevPts' : {"ctype" : 'vector_Point2f'},
- 'nextPts' : {"ctype" : 'vector_Point2f'},
- 'status' : {"ctype" : 'vector_uchar'},
- 'err' : {"ctype" : 'vector_float'} },
- 'fitEllipse' : { 'points' : {"ctype" : 'vector_Point2f'} },
- 'fillPoly' : { 'pts' : {"ctype" : 'vector_vector_Point'} },
- 'polylines' : { 'pts' : {"ctype" : 'vector_vector_Point'} },
- 'fillConvexPoly' : { 'points' : {"ctype" : 'vector_Point'} },
- 'boundingRect' : { 'points' : {"ctype" : 'vector_Point'} },
- 'approxPolyDP' : { 'curve' : {"ctype" : 'vector_Point2f'},
- 'approxCurve' : {"ctype" : 'vector_Point2f'} },
- 'arcLength' : { 'curve' : {"ctype" : 'vector_Point2f'} },
- 'pointPolygonTest' : { 'contour' : {"ctype" : 'vector_Point2f'} },
- 'minAreaRect' : { 'points' : {"ctype" : 'vector_Point2f'} },
- 'getAffineTransform' : { 'src' : {"ctype" : 'vector_Point2f'},
- 'dst' : {"ctype" : 'vector_Point2f'} },
- 'hconcat' : { 'src' : {"ctype" : 'vector_Mat'} },
- 'vconcat' : { 'src' : {"ctype" : 'vector_Mat'} },
- 'undistortPoints' : { 'src' : {"ctype" : 'vector_Point2f'},
- 'dst' : {"ctype" : 'vector_Point2f'} },
- 'checkRange' : {'pos' : {"ctype" : '*'} },
- 'meanStdDev' : { 'mean' : {"ctype" : 'vector_double'},
- 'stddev' : {"ctype" : 'vector_double'} },
- 'drawContours' : {'contours' : {"ctype" : 'vector_vector_Point'} },
- 'findContours' : {'contours' : {"ctype" : 'vector_vector_Point'} },
- 'convexityDefects' : { 'contour' : {"ctype" : 'vector_Point'},
- 'convexhull' : {"ctype" : 'vector_int'},
- 'convexityDefects' : {"ctype" : 'vector_Vec4i'} },
- 'isContourConvex' : { 'contour' : {"ctype" : 'vector_Point'} },
- 'convexHull' : { 'points' : {"ctype" : 'vector_Point'},
- 'hull' : {"ctype" : 'vector_int'},
- 'returnPoints' : {"ctype" : ''} },
- 'projectPoints' : { 'objectPoints' : {"ctype" : 'vector_Point3f'},
- 'imagePoints' : {"ctype" : 'vector_Point2f'},
- 'distCoeffs' : {"ctype" : 'vector_double' } },
- 'initCameraMatrix2D' : { 'objectPoints' : {"ctype" : 'vector_vector_Point3f'},
- 'imagePoints' : {"ctype" : 'vector_vector_Point2f'} },
- 'findChessboardCorners' : { 'corners' : {"ctype" : 'vector_Point2f'} },
- 'drawChessboardCorners' : { 'corners' : {"ctype" : 'vector_Point2f'} },
- 'mixChannels' : { 'dst' : {"attrib" : []} },
- }, # '', i.e. no class
-} # func_arg_fix
+func_arg_fix = {}
def getLibVersion(version_hpp_path):
version_file = open(version_hpp_path, "rt").read()
@@ -644,6 +114,7 @@ public class $jname {
protected final long nativeObj;
protected $jname(long addr) { nativeObj = addr; }
+ public long getNativeObjAddr() { return nativeObj; }
"""
T_JAVA_START_MODULE = """
@@ -802,33 +273,15 @@ class ClassInfo(GeneralInfo):
return ["import %s;" % c for c in sorted(self.imports) if not c.startswith('org.opencv.'+module)]
def addImports(self, ctype):
- if ctype.startswith('vector_vector'):
- self.imports.add("org.opencv.core.Mat")
- self.imports.add("org.opencv.utils.Converters")
- self.imports.add("java.util.List")
- self.imports.add("java.util.ArrayList")
- self.addImports(ctype.replace('vector_vector', 'vector'))
- elif ctype.startswith('Feature2D'):
- self.imports.add("org.opencv.features2d.Feature2D")
- elif ctype.startswith('vector'):
- self.imports.add("org.opencv.core.Mat")
- self.imports.add('java.util.ArrayList')
- if type_dict[ctype]['j_type'].startswith('MatOf'):
- self.imports.add("org.opencv.core." + type_dict[ctype]['j_type'])
- else:
+ if ctype in type_dict:
+ if "j_import" in type_dict[ctype]:
+ self.imports.add(type_dict[ctype]["j_import"])
+ if "v_type" in type_dict[ctype]:
self.imports.add("java.util.List")
+ self.imports.add("java.util.ArrayList")
self.imports.add("org.opencv.utils.Converters")
- self.addImports(ctype.replace('vector_', ''))
- else:
- j_type = ''
- if ctype in type_dict:
- j_type = type_dict[ctype]['j_type']
- elif ctype in ("Algorithm"):
- j_type = ctype
- if j_type in ( "CvType", "Mat", "Point", "Point3", "Range", "Rect", "RotatedRect", "Scalar", "Size", "TermCriteria", "Algorithm" ):
- self.imports.add("org.opencv.core." + j_type)
- if j_type == 'String':
- self.imports.add("java.lang.String")
+ if type_dict[ctype]["v_type"] in ("Mat", "vector_Mat"):
+ self.imports.add("org.opencv.core.Mat")
def getAllMethods(self):
result = []
@@ -858,10 +311,13 @@ class ClassInfo(GeneralInfo):
self.j_code = StringIO()
self.jn_code = StringIO()
self.cpp_code = StringIO();
- if self.name != Module:
- self.j_code.write(T_JAVA_START_INHERITED if self.base else T_JAVA_START_ORPHAN)
+ if self.base:
+ self.j_code.write(T_JAVA_START_INHERITED)
else:
- self.j_code.write(T_JAVA_START_MODULE)
+ if self.name != Module:
+ self.j_code.write(T_JAVA_START_ORPHAN)
+ else:
+ self.j_code.write(T_JAVA_START_MODULE)
# misc handling
if self.name == 'Core':
self.imports.add("java.lang.String")
@@ -891,10 +347,6 @@ class ArgInfo():
if ctype.endswith("*"):
ctype = ctype[:-1]
self.pointer = True
- if ctype == 'vector_Point2d':
- ctype = 'vector_Point2f'
- elif ctype == 'vector_Point3d':
- ctype = 'vector_Point3f'
self.ctype = ctype
self.name = arg_tuple[1]
self.defval = arg_tuple[2]
@@ -924,7 +376,7 @@ class FuncInfo(GeneralInfo):
self.static = ["","static"][ "/S" in decl[2] ]
self.ctype = re.sub(r"^CvTermCriteria", "TermCriteria", decl[1] or "")
self.args = []
- func_fix_map = func_arg_fix.get(self.classname, {}).get(self.jname, {})
+ func_fix_map = func_arg_fix.get(self.jname, {})
for a in decl[3]:
arg = a[:]
arg_fix_map = func_fix_map.get(arg[1], {})
@@ -958,11 +410,11 @@ class JavaWrapperGenerator(object):
logging.info('ignored: %s', classinfo)
return
name = classinfo.name
- if self.isWrapped(name):
+ if self.isWrapped(name) and not classinfo.base:
logging.warning('duplicated: %s', classinfo)
return
self.classes[name] = classinfo
- if name in type_dict:
+ if name in type_dict and not classinfo.base:
logging.warning('duplicated: %s', classinfo)
return
type_dict[name] = \
@@ -996,8 +448,8 @@ class JavaWrapperGenerator(object):
classinfo.addImports(classinfo.base)
type_dict["Ptr_"+name] = \
{ "j_type" : classinfo.jname,
- "jn_type" : "long", "jn_args" : (("__int64", ".nativeObj"),),
- "jni_name" : "Ptr<"+classinfo.fullName(isCPP=True)+">(("+classinfo.fullName(isCPP=True)+"*)%(n)s_nativeObj)", "jni_type" : "jlong",
+ "jn_type" : "long", "jn_args" : (("__int64", ".getNativeObjAddr()"),),
+ "jni_name" : "*((Ptr<"+classinfo.fullName(isCPP=True)+">*)%(n)s_nativeObj)", "jni_type" : "jlong",
"suffix" : "J" }
logging.info('ok: class %s, name: %s, base: %s', classinfo, name, classinfo.base)
@@ -1190,46 +642,55 @@ class JavaWrapperGenerator(object):
if not a.ctype: # hidden
continue
ci.addImports(a.ctype)
- if "vector" in a.ctype: # pass as Mat
- jn_args.append ( ArgInfo([ "__int64", "%s_mat.nativeObj" % a.name, "", [], "" ]) )
- jni_args.append ( ArgInfo([ "__int64", "%s_mat_nativeObj" % a.name, "", [], "" ]) )
- c_prologue.append( type_dict[a.ctype]["jni_var"] % {"n" : a.name} + ";" )
- c_prologue.append( "Mat& %(n)s_mat = *((Mat*)%(n)s_mat_nativeObj)" % {"n" : a.name} + ";" )
- if "I" in a.out or not a.out:
- if a.ctype.startswith("vector_vector_"):
- j_prologue.append( "List<Mat> %(n)s_tmplm = new ArrayList<Mat>((%(n)s != null) ? %(n)s.size() : 0);" % {"n" : a.name } )
- j_prologue.append( "Mat %(n)s_mat = Converters.%(t)s_to_Mat(%(n)s, %(n)s_tmplm);" % {"n" : a.name, "t" : a.ctype} )
+ if "v_type" in type_dict[a.ctype]: # pass as vector
+ if type_dict[a.ctype]["v_type"] in ("Mat", "vector_Mat"): #pass as Mat or vector_Mat
+ jn_args.append ( ArgInfo([ "__int64", "%s_mat.nativeObj" % a.name, "", [], "" ]) )
+ jni_args.append ( ArgInfo([ "__int64", "%s_mat_nativeObj" % a.name, "", [], "" ]) )
+ c_prologue.append( type_dict[a.ctype]["jni_var"] % {"n" : a.name} + ";" )
+ c_prologue.append( "Mat& %(n)s_mat = *((Mat*)%(n)s_mat_nativeObj)" % {"n" : a.name} + ";" )
+ if "I" in a.out or not a.out:
+ if type_dict[a.ctype]["v_type"] == "vector_Mat":
+ j_prologue.append( "List<Mat> %(n)s_tmplm = new ArrayList<Mat>((%(n)s != null) ? %(n)s.size() : 0);" % {"n" : a.name } )
+ j_prologue.append( "Mat %(n)s_mat = Converters.%(t)s_to_Mat(%(n)s, %(n)s_tmplm);" % {"n" : a.name, "t" : a.ctype} )
+ else:
+ if not type_dict[a.ctype]["j_type"].startswith("MatOf"):
+ j_prologue.append( "Mat %(n)s_mat = Converters.%(t)s_to_Mat(%(n)s);" % {"n" : a.name, "t" : a.ctype} )
+ else:
+ j_prologue.append( "Mat %s_mat = %s;" % (a.name, a.name) )
+ c_prologue.append( "Mat_to_%(t)s( %(n)s_mat, %(n)s );" % {"n" : a.name, "t" : a.ctype} )
else:
if not type_dict[a.ctype]["j_type"].startswith("MatOf"):
- j_prologue.append( "Mat %(n)s_mat = Converters.%(t)s_to_Mat(%(n)s);" % {"n" : a.name, "t" : a.ctype} )
+ j_prologue.append( "Mat %s_mat = new Mat();" % a.name )
else:
j_prologue.append( "Mat %s_mat = %s;" % (a.name, a.name) )
- c_prologue.append( "Mat_to_%(t)s( %(n)s_mat, %(n)s );" % {"n" : a.name, "t" : a.ctype} )
- else:
- if not type_dict[a.ctype]["j_type"].startswith("MatOf"):
- j_prologue.append( "Mat %s_mat = new Mat();" % a.name )
- else:
- j_prologue.append( "Mat %s_mat = %s;" % (a.name, a.name) )
- if "O" in a.out:
- if not type_dict[a.ctype]["j_type"].startswith("MatOf"):
- j_epilogue.append("Converters.Mat_to_%(t)s(%(n)s_mat, %(n)s);" % {"t" : a.ctype, "n" : a.name})
- j_epilogue.append( "%s_mat.release();" % a.name )
- c_epilogue.append( "%(t)s_to_Mat( %(n)s, %(n)s_mat );" % {"n" : a.name, "t" : a.ctype} )
+ if "O" in a.out:
+ if not type_dict[a.ctype]["j_type"].startswith("MatOf"):
+ j_epilogue.append("Converters.Mat_to_%(t)s(%(n)s_mat, %(n)s);" % {"t" : a.ctype, "n" : a.name})
+ j_epilogue.append( "%s_mat.release();" % a.name )
+ c_epilogue.append( "%(t)s_to_Mat( %(n)s, %(n)s_mat );" % {"n" : a.name, "t" : a.ctype} )
+ else: #pass as list
+ jn_args.append ( ArgInfo([ a.ctype, a.name, "", [], "" ]) )
+ jni_args.append ( ArgInfo([ a.ctype, "%s_list" % a.name , "", [], "" ]) )
+ c_prologue.append(type_dict[a.ctype]["jni_var"] % {"n" : a.name} + ";")
+ if "I" in a.out or not a.out:
+ c_prologue.append("%(n)s = List_to_%(t)s(env, %(n)s_list);" % {"n" : a.name, "t" : a.ctype})
+ if "O" in a.out:
+ c_epilogue.append("Copy_%s_to_List(env,%s,%s_list);" % (a.ctype, a.name, a.name))
else:
fields = type_dict[a.ctype].get("jn_args", ((a.ctype, ""),))
if "I" in a.out or not a.out or self.isWrapped(a.ctype): # input arg, pass by primitive fields
for f in fields:
jn_args.append ( ArgInfo([ f[0], a.name + f[1], "", [], "" ]) )
- jni_args.append( ArgInfo([ f[0], a.name + f[1].replace(".","_").replace("[","").replace("]",""), "", [], "" ]) )
- if a.out and not self.isWrapped(a.ctype): # out arg, pass as double[]
+ jni_args.append( ArgInfo([ f[0], a.name + f[1].replace(".","_").replace("[","").replace("]","").replace("_getNativeObjAddr()","_nativeObj"), "", [], "" ]) )
+ if "O" in a.out and not self.isWrapped(a.ctype): # out arg, pass as double[]
jn_args.append ( ArgInfo([ "double[]", "%s_out" % a.name, "", [], "" ]) )
jni_args.append ( ArgInfo([ "double[]", "%s_out" % a.name, "", [], "" ]) )
j_prologue.append( "double[] %s_out = new double[%i];" % (a.name, len(fields)) )
c_epilogue.append( \
"jdouble tmp_%(n)s[%(cnt)i] = {%(args)s}; env->SetDoubleArrayRegion(%(n)s_out, 0, %(cnt)i, tmp_%(n)s);" %
{ "n" : a.name, "cnt" : len(fields), "args" : ", ".join(["(jdouble)" + a.name + f[1] for f in fields]) } )
- if a.ctype in ('bool', 'int', 'long', 'float', 'double'):
- j_epilogue.append('if(%(n)s!=null) %(n)s[0] = (%(t)s)%(n)s_out[0];' % {'n':a.name,'t':a.ctype})
+ if type_dict[a.ctype]["j_type"] in ('bool', 'int', 'long', 'float', 'double'):
+ j_epilogue.append('if(%(n)s!=null) %(n)s[0] = (%(t)s)%(n)s_out[0];' % {'n':a.name,'t':type_dict[a.ctype]["j_type"]})
else:
set_vals = []
i = 0
@@ -1246,7 +707,7 @@ class JavaWrapperGenerator(object):
if not a.ctype: #hidden
continue
jt = type_dict[a.ctype]["j_type"]
- if a.out and a.ctype in ('bool', 'int', 'long', 'float', 'double'):
+ if a.out and jt in ('bool', 'int', 'long', 'float', 'double'):
jt += '[]'
j_args.append( jt + ' ' + a.name )
j_signature = type_dict[fi.ctype]["j_type"] + " " + \
@@ -1268,7 +729,7 @@ class JavaWrapperGenerator(object):
" private static native $type $name($args);\n").substitute(\
type = type_dict[fi.ctype].get("jn_type", "double[]"), \
name = fi.jname + '_' + str(suffix_counter), \
- args = ", ".join(["%s %s" % (type_dict[a.ctype]["jn_type"], a.name.replace(".","_").replace("[","").replace("]","")) for a in jn_args])
+ args = ", ".join(["%s %s" % (type_dict[a.ctype]["jn_type"], a.name.replace(".","_").replace("[","").replace("]","").replace("_getNativeObjAddr()","_nativeObj")) for a in jn_args])
) );
# java part:
@@ -1290,15 +751,16 @@ class JavaWrapperGenerator(object):
ret_val = type_dict[ret_type]["j_type"] + " retVal = "
tail = ""
ret = "return retVal;"
- if ret_type.startswith('vector'):
- tail = ")"
+ if "v_type" in type_dict[ret_type]:
j_type = type_dict[ret_type]["j_type"]
- if j_type.startswith('MatOf'):
- ret_val += j_type + ".fromNativeAddr("
- else:
- ret_val = "Mat retValMat = new Mat("
- j_prologue.append( j_type + ' retVal = new Array' + j_type+'();')
- j_epilogue.append('Converters.Mat_to_' + ret_type + '(retValMat, retVal);')
+ if type_dict[ret_type]["v_type"] in ("Mat", "vector_Mat"):
+ tail = ")"
+ if j_type.startswith('MatOf'):
+ ret_val += j_type + ".fromNativeAddr("
+ else:
+ ret_val = "Mat retValMat = new Mat("
+ j_prologue.append( j_type + ' retVal = new Array' + j_type+'();')
+ j_epilogue.append('Converters.Mat_to_' + ret_type + '(retValMat, retVal);')
elif ret_type.startswith("Ptr_"):
ret_val = type_dict[fi.ctype]["j_type"] + " retVal = new " + type_dict[ret_type]["j_type"] + "("
tail = ")"
@@ -1358,8 +820,11 @@ class JavaWrapperGenerator(object):
default = "return;"
elif not fi.ctype: # c-tor
ret = "return (jlong) _retval_;"
- elif fi.ctype.startswith('vector'): # c-tor
- ret = "return (jlong) _retval_;"
+ elif "v_type" in type_dict[fi.ctype]: # c-tor
+ if type_dict[fi.ctype]["v_type"] in ("Mat", "vector_Mat"):
+ ret = "return (jlong) _retval_;"
+ else: # returned as jobject
+ ret = "return _retval_;"
elif fi.ctype == "String":
ret = "return env->NewStringUTF(_retval_.c_str());"
default = 'return env->NewStringUTF("");'
@@ -1387,10 +852,13 @@ class JavaWrapperGenerator(object):
retval = ""
elif fi.ctype == "String":
retval = "cv::" + retval
- elif fi.ctype.startswith('vector'):
+ elif "v_type" in type_dict[fi.ctype]: # vector is returned
retval = type_dict[fi.ctype]['jni_var'] % {"n" : '_ret_val_vector_'} + " = "
- c_epilogue.append("Mat* _retval_ = new Mat();")
- c_epilogue.append(fi.ctype+"_to_Mat(_ret_val_vector_, *_retval_);")
+ if type_dict[fi.ctype]["v_type"] in ("Mat", "vector_Mat"):
+ c_epilogue.append("Mat* _retval_ = new Mat();")
+ c_epilogue.append(fi.ctype+"_to_Mat(_ret_val_vector_, *_retval_);")
+ else:
+ c_epilogue.append("jobject _retval_ = " + fi.ctype + "_to_List(env, _ret_val_vector_);")
if len(fi.classname)>0:
if not fi.ctype: # c-tor
retval = fi.fullClass(isCPP=True) + "* _retval_ = "
@@ -1416,7 +884,7 @@ class JavaWrapperGenerator(object):
if not a.ctype: # hidden
jni_name = a.defval
cvargs.append( type_dict[a.ctype].get("jni_name", jni_name) % {"n" : a.name})
- if "vector" not in a.ctype :
+ if "v_type" not in type_dict[a.ctype]:
if ("I" in a.out or not a.out or self.isWrapped(a.ctype)) and "jni_var" in type_dict[a.ctype]: # complex type
c_prologue.append(type_dict[a.ctype]["jni_var"] % {"n" : a.name} + ";")
if a.out and "I" not in a.out and not self.isWrapped(a.ctype) and a.ctype:
@@ -1512,11 +980,11 @@ JNIEXPORT $rtype JNICALL Java_org_opencv_${module}_${clazz}_$fname
# manual ports
if ci.name in ManualFuncs:
for func in ManualFuncs[ci.name].keys():
- ci.j_code.write ( ManualFuncs[ci.name][func]["j_code"] )
- ci.jn_code.write( ManualFuncs[ci.name][func]["jn_code"] )
- ci.cpp_code.write( ManualFuncs[ci.name][func]["cpp_code"] )
+ ci.j_code.write ( "\n".join(ManualFuncs[ci.name][func]["j_code"]) )
+ ci.jn_code.write( "\n".join(ManualFuncs[ci.name][func]["jn_code"]) )
+ ci.cpp_code.write( "\n".join(ManualFuncs[ci.name][func]["cpp_code"]) )
- if ci.name != self.Module:
+ if ci.name != self.Module or ci.base:
# finalize()
ci.j_code.write(
"""
@@ -1567,7 +1035,7 @@ JNIEXPORT void JNICALL Java_org_opencv_%(module)s_%(j_cls)s_delete
# if parents are smart (we hope) then children are!
# if not we believe the class is smart if it has "create" method
ci.smart = False
- if ci.base:
+ if ci.base or ci.name == 'Algorithm':
ci.smart = True
else:
for fi in ci.methods:
@@ -1587,30 +1055,57 @@ JNIEXPORT void JNICALL Java_org_opencv_%(module)s_%(j_cls)s_delete
if __name__ == "__main__":
- if len(sys.argv) < 4:
- print("Usage:\n", \
- os.path.basename(sys.argv[0]), \
- "<full path to hdr_parser.py> <module name> <C++ header> [<C++ header>...]")
- print("Current args are: ", ", ".join(["'"+a+"'" for a in sys.argv]))
- exit(0)
- dstdir = "."
- hdr_parser_path = os.path.abspath(sys.argv[1])
+ # parse command line parameters
+ import argparse
+ arg_parser = argparse.ArgumentParser(description='OpenCV Java Wrapper Generator')
+ arg_parser.add_argument('-p', '--parser', required=True, help='OpenCV header parser')
+ arg_parser.add_argument('-m', '--module', required=True, help='OpenCV module name')
+ arg_parser.add_argument('-s', '--srcfiles', required=True, nargs='+', help='Source headers to be wrapped')
+ arg_parser.add_argument('-c', '--common', nargs='*', help='Common headers')
+ arg_parser.add_argument('-t', '--gendict', nargs='*', help='Custom module dictionaries for C++ to Java conversion')
+
+ args=arg_parser.parse_args()
+
+ # import header parser
+ hdr_parser_path = os.path.abspath(args.parser)
if hdr_parser_path.endswith(".py"):
hdr_parser_path = os.path.dirname(hdr_parser_path)
sys.path.append(hdr_parser_path)
import hdr_parser
- module = sys.argv[2]
- srcfiles = sys.argv[3:]
- common_headers = []
- if '--common' in srcfiles:
- pos = srcfiles.index('--common')
- common_headers = srcfiles[pos+1:]
- srcfiles = srcfiles[:pos]
+
+ module = args.module
+ srcfiles = args.srcfiles
+ common_headers= args.common
+ gen_dict_files = args.gendict
+
+ dstdir = "."
+
+ # initialize logger
logging.basicConfig(filename='%s/%s.log' % (dstdir, module), format=None, filemode='w', level=logging.INFO)
handler = logging.StreamHandler()
handler.setLevel(logging.WARNING)
logging.getLogger().addHandler(handler)
- #print("Generating module '" + module + "' from headers:\n\t" + "\n\t".join(srcfiles))
+
+ # load dictionaries
+ for gdf in gen_dict_files:
+ with open(gdf) as f:
+ gen_type_dict = json.load(f)
+ if "class_ignore_list" in gen_type_dict:
+ class_ignore_list += gen_type_dict["class_ignore_list"]
+ if "const_ignore_list" in gen_type_dict:
+ const_ignore_list += gen_type_dict["const_ignore_list"]
+ if "const_private_list" in gen_type_dict:
+ const_private_list += gen_type_dict["const_private_list"]
+ if "missing_consts" in gen_type_dict:
+ missing_consts.update(gen_type_dict["missing_consts"])
+ if "type_dict" in gen_type_dict:
+ type_dict.update(gen_type_dict["type_dict"])
+ if "ManualFuncs" in gen_type_dict:
+ ManualFuncs.update(gen_type_dict["ManualFuncs"])
+ if "func_arg_fix" in gen_type_dict:
+ func_arg_fix.update(gen_type_dict["func_arg_fix"])
+
+ # launch Java Wrapper generator
generator = JavaWrapperGenerator()
generator.gen(srcfiles, module, dstdir, common_headers)
diff --git a/modules/java/generator/src/cpp/common.h b/modules/java/generator/src/cpp/common.h
index 4142b8c..b629d94 100644
--- a/modules/java/generator/src/cpp/common.h
+++ b/modules/java/generator/src/cpp/common.h
@@ -7,22 +7,11 @@
#endif
#include <jni.h>
-#ifdef __ANDROID__
-# include <android/log.h>
-# define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
-# ifdef DEBUG
-# define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
-# else
-# define LOGD(...)
-# endif
-#else
-# define LOGE(...)
-# define LOGD(...)
-#endif
-
+#include "opencv2/java.hpp"
#include "opencv2/core/utility.hpp"
#include "converters.h"
+#include "listconverters.hpp"
#ifdef _MSC_VER
# pragma warning(disable:4800 4244)
diff --git a/modules/java/generator/src/cpp/converters.cpp b/modules/java/generator/src/cpp/converters.cpp
index 3c771ce..5929cf4 100644
--- a/modules/java/generator/src/cpp/converters.cpp
+++ b/modules/java/generator/src/cpp/converters.cpp
@@ -3,9 +3,6 @@
using namespace cv;
-#define CHECK_MAT(cond) if(!(cond)){ LOGD("FAILED: " #cond); return; }
-
-
// vector_int
void Mat_to_vector_int(Mat& mat, std::vector<int>& v_int)
@@ -92,6 +89,19 @@ void vector_Rect_to_Mat(std::vector<Rect>& v_rect, Mat& mat)
mat = Mat(v_rect, true);
}
+//vector_Rect2d
+
+void Mat_to_vector_Rect2d(Mat& mat, std::vector<Rect2d>& v_rect)
+{
+ v_rect.clear();
+ CHECK_MAT(mat.type()==CV_64FC4 && mat.cols==1);
+ v_rect = (std::vector<Rect2d>) mat;
+}
+
+void vector_Rect2d_to_Mat(std::vector<Rect2d>& v_rect, Mat& mat)
+{
+ mat = Mat(v_rect, true);
+}
//vector_Point
void Mat_to_vector_Point(Mat& mat, std::vector<Point>& v_point)
diff --git a/modules/java/generator/src/cpp/converters.h b/modules/java/generator/src/cpp/converters.h
index 257f944..25077b1 100644
--- a/modules/java/generator/src/cpp/converters.h
+++ b/modules/java/generator/src/cpp/converters.h
@@ -19,6 +19,9 @@ void vector_char_to_Mat(std::vector<char>& v_char, cv::Mat& mat);
void Mat_to_vector_Rect(cv::Mat& mat, std::vector<cv::Rect>& v_rect);
void vector_Rect_to_Mat(std::vector<cv::Rect>& v_rect, cv::Mat& mat);
+void Mat_to_vector_Rect2d(cv::Mat& mat, std::vector<cv::Rect2d>& v_rect);
+void vector_Rect2d_to_Mat(std::vector<cv::Rect2d>& v_rect, cv::Mat& mat);
+
void Mat_to_vector_Point(cv::Mat& mat, std::vector<cv::Point>& v_point);
void Mat_to_vector_Point2f(cv::Mat& mat, std::vector<cv::Point2f>& v_point);
diff --git a/modules/java/generator/src/cpp/listconverters.cpp b/modules/java/generator/src/cpp/listconverters.cpp
new file mode 100644
index 0000000..a1d1140
--- /dev/null
+++ b/modules/java/generator/src/cpp/listconverters.cpp
@@ -0,0 +1,59 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+// Author: abratchik
+
+#define LOG_TAG "org.opencv.utils.Converters"
+#include "common.h"
+
+
+jobject vector_String_to_List(JNIEnv* env, std::vector<cv::String>& vs) {
+
+ static jclass juArrayList = ARRAYLIST(env);
+ static jmethodID m_create = CONSTRUCTOR(env, juArrayList);
+ jmethodID m_add = LIST_ADD(env, juArrayList);
+
+ jobject result = env->NewObject(juArrayList, m_create, vs.size());
+ for (std::vector<cv::String>::iterator it = vs.begin(); it != vs.end(); ++it) {
+ jstring element = env->NewStringUTF((*it).c_str());
+ env->CallBooleanMethod(result, m_add, element);
+ env->DeleteLocalRef(element);
+ }
+ return result;
+}
+
+std::vector<cv::String> List_to_vector_String(JNIEnv* env, jobject list)
+{
+ static jclass juArrayList = ARRAYLIST(env);
+ jmethodID m_size = LIST_SIZE(env,juArrayList);
+ jmethodID m_get = LIST_GET(env, juArrayList);
+
+ jint len = env->CallIntMethod(list, m_size);
+ std::vector<cv::String> result;
+ result.reserve(len);
+ for (jint i=0; i<len; i++)
+ {
+ jstring element = static_cast<jstring>(env->CallObjectMethod(list, m_get, i));
+ const char* pchars = env->GetStringUTFChars(element, NULL);
+ result.push_back(pchars);
+ env->ReleaseStringUTFChars(element, pchars);
+ env->DeleteLocalRef(element);
+ }
+ return result;
+}
+
+void Copy_vector_String_to_List(JNIEnv* env, std::vector<cv::String>& vs, jobject list)
+{
+ static jclass juArrayList = ARRAYLIST(env);
+ jmethodID m_clear = LIST_CLEAR(env, juArrayList);
+ jmethodID m_add = LIST_ADD(env, juArrayList);
+
+ env->CallVoidMethod(list, m_clear);
+ for (std::vector<cv::String>::iterator it = vs.begin(); it != vs.end(); ++it)
+ {
+ jstring element = env->NewStringUTF((*it).c_str());
+ env->CallBooleanMethod(list, m_add, element);
+ env->DeleteLocalRef(element);
+ }
+}
\ No newline at end of file
diff --git a/modules/java/generator/src/cpp/listconverters.hpp b/modules/java/generator/src/cpp/listconverters.hpp
new file mode 100644
index 0000000..655f87a
--- /dev/null
+++ b/modules/java/generator/src/cpp/listconverters.hpp
@@ -0,0 +1,19 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+// Author: abratchik
+
+#ifndef LISTCONVERTERS_HPP
+#define LISTCONVERTERS_HPP
+
+#include "opencv2/opencv_modules.hpp"
+#include "opencv2/core.hpp"
+
+jobject vector_String_to_List(JNIEnv* env, std::vector<cv::String>& vs);
+
+std::vector<cv::String> List_to_vector_String(JNIEnv* env, jobject list);
+
+void Copy_vector_String_to_List(JNIEnv* env, std::vector<cv::String>& vs, jobject list);
+
+#endif /* LISTCONVERTERS_HPP */
\ No newline at end of file
diff --git a/modules/java/generator/src/java/android+AsyncServiceHelper.java b/modules/java/generator/src/java/android+AsyncServiceHelper.java
index 4d9d115..ebee2bb 100644
--- a/modules/java/generator/src/java/android+AsyncServiceHelper.java
+++ b/modules/java/generator/src/java/android+AsyncServiceHelper.java
@@ -131,7 +131,7 @@ class AsyncServiceHelper
}
public void cancel()
{
- Log.d(TAG, "Wating for OpenCV canceled by user");
+ Log.d(TAG, "Waiting for OpenCV canceled by user");
mServiceInstallationProgress = false;
int Status = LoaderCallbackInterface.INSTALL_CANCELED;
Log.d(TAG, "Init finished with status " + Status);
@@ -197,7 +197,7 @@ class AsyncServiceHelper
if (mEngineService.installVersion(mOpenCVersion))
{
mLibraryInstallationProgress = true;
- Log.d(TAG, "Package installation statred");
+ Log.d(TAG, "Package installation started");
Log.d(TAG, "Unbind from service");
mAppContext.unbindService(mServiceConnection);
}
@@ -228,7 +228,7 @@ class AsyncServiceHelper
mUserAppCallback.onManagerConnected(LoaderCallbackInterface.INSTALL_CANCELED);
}
public void wait_install() {
- Log.e(TAG, "Instalation was not started! Nothing to wait!");
+ Log.e(TAG, "Installation was not started! Nothing to wait!");
}
};
diff --git a/modules/java/generator/src/java/android+BaseLoaderCallback.java b/modules/java/generator/src/java/android+BaseLoaderCallback.java
index 6d6a9b8..0b8aeed 100644
--- a/modules/java/generator/src/java/android+BaseLoaderCallback.java
+++ b/modules/java/generator/src/java/android+BaseLoaderCallback.java
@@ -43,7 +43,7 @@ public abstract class BaseLoaderCallback implements LoaderCallbackInterface {
/** Package installation has been canceled. **/
case LoaderCallbackInterface.INSTALL_CANCELED:
{
- Log.d(TAG, "OpenCV library instalation was canceled by user");
+ Log.d(TAG, "OpenCV library installation was canceled by user");
finish();
} break;
/** Application is incompatible with this version of OpenCV Manager. Possibly, a service update is required. **/
diff --git a/modules/java/generator/src/java/android+CameraBridgeViewBase.java b/modules/java/generator/src/java/android+CameraBridgeViewBase.java
index ef2af81..5487105 100644
--- a/modules/java/generator/src/java/android+CameraBridgeViewBase.java
+++ b/modules/java/generator/src/java/android+CameraBridgeViewBase.java
@@ -38,7 +38,7 @@ public abstract class CameraBridgeViewBase extends SurfaceView implements Surfac
private Bitmap mCacheBitmap;
private CvCameraViewListener2 mListener;
private boolean mSurfaceExist;
- private Object mSyncObject = new Object();
+ private final Object mSyncObject = new Object();
protected int mFrameWidth;
protected int mFrameHeight;
diff --git a/modules/java/generator/src/java/android+JavaCameraView.java b/modules/java/generator/src/java/android+JavaCameraView.java
index 7b0ecd4..a7c72e4 100644
--- a/modules/java/generator/src/java/android+JavaCameraView.java
+++ b/modules/java/generator/src/java/android+JavaCameraView.java
@@ -41,6 +41,7 @@ public class JavaCameraView extends CameraBridgeViewBase implements PreviewCallb
protected Camera mCamera;
protected JavaCameraFrame[] mCameraFrame;
private SurfaceTexture mSurfaceTexture;
+ private int mPreviewFormat = ImageFormat.NV21;
public static class JavaCameraSizeAccessor implements ListItemAccessor {
@@ -145,7 +146,21 @@ public class JavaCameraView extends CameraBridgeViewBase implements PreviewCallb
/* Select the size that fits surface considering maximum size allowed */
Size frameSize = calculateCameraFrameSize(sizes, new JavaCameraSizeAccessor(), width, height);
- params.setPreviewFormat(ImageFormat.NV21);
+ /* Image format NV21 causes issues in the Android emulators */
+ if (Build.FINGERPRINT.startsWith("generic")
+ || Build.FINGERPRINT.startsWith("unknown")
+ || Build.MODEL.contains("google_sdk")
+ || Build.MODEL.contains("Emulator")
+ || Build.MODEL.contains("Android SDK built for x86")
+ || Build.MANUFACTURER.contains("Genymotion")
+ || (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"))
+ || "google_sdk".equals(Build.PRODUCT))
+ params.setPreviewFormat(ImageFormat.YV12); // "generic" or "android" = android emulator
+ else
+ params.setPreviewFormat(ImageFormat.NV21);
+
+ mPreviewFormat = params.getPreviewFormat();
+
Log.d(TAG, "Set preview size to " + Integer.valueOf((int)frameSize.width) + "x" + Integer.valueOf((int)frameSize.height));
params.setPreviewSize((int)frameSize.width, (int)frameSize.height);
@@ -267,7 +282,7 @@ public class JavaCameraView extends CameraBridgeViewBase implements PreviewCallb
synchronized (this) {
this.notify();
}
- Log.d(TAG, "Wating for thread");
+ Log.d(TAG, "Waiting for thread");
if (mThread != null)
mThread.join();
} catch (InterruptedException e) {
@@ -303,7 +318,13 @@ public class JavaCameraView extends CameraBridgeViewBase implements PreviewCallb
@Override
public Mat rgba() {
- Imgproc.cvtColor(mYuvFrameData, mRgba, Imgproc.COLOR_YUV2RGBA_NV21, 4);
+ if (mPreviewFormat == ImageFormat.NV21)
+ Imgproc.cvtColor(mYuvFrameData, mRgba, Imgproc.COLOR_YUV2RGBA_NV21, 4);
+ else if (mPreviewFormat == ImageFormat.YV12)
+ Imgproc.cvtColor(mYuvFrameData, mRgba, Imgproc.COLOR_YUV2RGB_I420, 4); // COLOR_YUV2RGBA_YV12 produces inverted colors
+ else
+ throw new IllegalArgumentException("Preview Format can be NV21 or YV12");
+
return mRgba;
}
diff --git a/modules/java/generator/src/java/android+OpenCVLoader.java b/modules/java/generator/src/java/android+OpenCVLoader.java
deleted file mode 100644
index a84a49e..0000000
--- a/modules/java/generator/src/java/android+OpenCVLoader.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package org.opencv.android;
-
-import android.content.Context;
-
-/**
- * Helper class provides common initialization methods for OpenCV library.
- */
-public class OpenCVLoader
-{
- /**
- * OpenCV Library version 2.4.2.
- */
- public static final String OPENCV_VERSION_2_4_2 = "2.4.2";
-
- /**
- * OpenCV Library version 2.4.3.
- */
- public static final String OPENCV_VERSION_2_4_3 = "2.4.3";
-
- /**
- * OpenCV Library version 2.4.4.
- */
- public static final String OPENCV_VERSION_2_4_4 = "2.4.4";
-
- /**
- * OpenCV Library version 2.4.5.
- */
- public static final String OPENCV_VERSION_2_4_5 = "2.4.5";
-
- /**
- * OpenCV Library version 2.4.6.
- */
- public static final String OPENCV_VERSION_2_4_6 = "2.4.6";
-
- /**
- * OpenCV Library version 2.4.7.
- */
- public static final String OPENCV_VERSION_2_4_7 = "2.4.7";
-
- /**
- * OpenCV Library version 2.4.8.
- */
- public static final String OPENCV_VERSION_2_4_8 = "2.4.8";
-
- /**
- * OpenCV Library version 2.4.9.
- */
- public static final String OPENCV_VERSION_2_4_9 = "2.4.9";
-
- /**
- * OpenCV Library version 2.4.10.
- */
- public static final String OPENCV_VERSION_2_4_10 = "2.4.10";
-
- /**
- * OpenCV Library version 2.4.11.
- */
- public static final String OPENCV_VERSION_2_4_11 = "2.4.11";
-
- /**
- * OpenCV Library version 2.4.12.
- */
- public static final String OPENCV_VERSION_2_4_12 = "2.4.12";
-
- /**
- * OpenCV Library version 2.4.13.
- */
- public static final String OPENCV_VERSION_2_4_13 = "2.4.13";
-
- /**
- * OpenCV Library version 3.0.0.
- */
- public static final String OPENCV_VERSION_3_0_0 = "3.0.0";
-
- /**
- * OpenCV Library version 3.1.0.
- */
- public static final String OPENCV_VERSION_3_1_0 = "3.1.0";
-
- /**
- * OpenCV Library version 3.2.0.
- */
- public static final String OPENCV_VERSION_3_2_0 = "3.2.0";
-
- /**
- * Loads and initializes OpenCV library from current application package. Roughly, it's an analog of system.loadLibrary("opencv_java").
- * @return Returns true is initialization of OpenCV was successful.
- */
- public static boolean initDebug()
- {
- return StaticHelper.initOpenCV(false);
- }
-
- /**
- * Loads and initializes OpenCV library from current application package. Roughly, it's an analog of system.loadLibrary("opencv_java").
- * @param InitCuda load and initialize CUDA runtime libraries.
- * @return Returns true is initialization of OpenCV was successful.
- */
- public static boolean initDebug(boolean InitCuda)
- {
- return StaticHelper.initOpenCV(InitCuda);
- }
-
- /**
- * Loads and initializes OpenCV library using OpenCV Engine service.
- * @param Version OpenCV library version.
- * @param AppContext application context for connecting to the service.
- * @param Callback object, that implements LoaderCallbackInterface for handling the connection status.
- * @return Returns true if initialization of OpenCV is successful.
- */
- public static boolean initAsync(String Version, Context AppContext,
- LoaderCallbackInterface Callback)
- {
- return AsyncServiceHelper.initOpenCV(Version, AppContext, Callback);
- }
-}
diff --git a/modules/java/generator/src/java/android+OpenCVLoader.java.in b/modules/java/generator/src/java/android+OpenCVLoader.java.in
new file mode 100644
index 0000000..8f8cd05
--- /dev/null
+++ b/modules/java/generator/src/java/android+OpenCVLoader.java.in
@@ -0,0 +1,127 @@
+package org.opencv.android;
+
+import android.content.Context;
+
+/**
+ * Helper class provides common initialization methods for OpenCV library.
+ */
+public class OpenCVLoader
+{
+ /**
+ * OpenCV Library version 2.4.2.
+ */
+ public static final String OPENCV_VERSION_2_4_2 = "2.4.2";
+
+ /**
+ * OpenCV Library version 2.4.3.
+ */
+ public static final String OPENCV_VERSION_2_4_3 = "2.4.3";
+
+ /**
+ * OpenCV Library version 2.4.4.
+ */
+ public static final String OPENCV_VERSION_2_4_4 = "2.4.4";
+
+ /**
+ * OpenCV Library version 2.4.5.
+ */
+ public static final String OPENCV_VERSION_2_4_5 = "2.4.5";
+
+ /**
+ * OpenCV Library version 2.4.6.
+ */
+ public static final String OPENCV_VERSION_2_4_6 = "2.4.6";
+
+ /**
+ * OpenCV Library version 2.4.7.
+ */
+ public static final String OPENCV_VERSION_2_4_7 = "2.4.7";
+
+ /**
+ * OpenCV Library version 2.4.8.
+ */
+ public static final String OPENCV_VERSION_2_4_8 = "2.4.8";
+
+ /**
+ * OpenCV Library version 2.4.9.
+ */
+ public static final String OPENCV_VERSION_2_4_9 = "2.4.9";
+
+ /**
+ * OpenCV Library version 2.4.10.
+ */
+ public static final String OPENCV_VERSION_2_4_10 = "2.4.10";
+
+ /**
+ * OpenCV Library version 2.4.11.
+ */
+ public static final String OPENCV_VERSION_2_4_11 = "2.4.11";
+
+ /**
+ * OpenCV Library version 2.4.12.
+ */
+ public static final String OPENCV_VERSION_2_4_12 = "2.4.12";
+
+ /**
+ * OpenCV Library version 2.4.13.
+ */
+ public static final String OPENCV_VERSION_2_4_13 = "2.4.13";
+
+ /**
+ * OpenCV Library version 3.0.0.
+ */
+ public static final String OPENCV_VERSION_3_0_0 = "3.0.0";
+
+ /**
+ * OpenCV Library version 3.1.0.
+ */
+ public static final String OPENCV_VERSION_3_1_0 = "3.1.0";
+
+ /**
+ * OpenCV Library version 3.2.0.
+ */
+ public static final String OPENCV_VERSION_3_2_0 = "3.2.0";
+
+ /**
+ * OpenCV Library version 3.3.0.
+ */
+ public static final String OPENCV_VERSION_3_3_0 = "3.3.0";
+
+ /**
+ * Current OpenCV Library version
+ */
+ public static final String OPENCV_VERSION = "@OPENCV_VERSION_MAJOR at .@OPENCV_VERSION_MINOR at .@OPENCV_VERSION_PATCH@";
+
+
+ /**
+ * Loads and initializes OpenCV library from current application package. Roughly, it's an analog of system.loadLibrary("opencv_java").
+ * @return Returns true is initialization of OpenCV was successful.
+ */
+ public static boolean initDebug()
+ {
+ return StaticHelper.initOpenCV(false);
+ }
+
+ /**
+ * Loads and initializes OpenCV library from current application package. Roughly, it's an analog of system.loadLibrary("opencv_java").
+ * @param InitCuda load and initialize CUDA runtime libraries.
+ * @return Returns true is initialization of OpenCV was successful.
+ */
+ public static boolean initDebug(boolean InitCuda)
+ {
+ return StaticHelper.initOpenCV(InitCuda);
+ }
+
+ /**
+ * Loads and initializes OpenCV library using OpenCV Engine service.
+ * @param Version OpenCV library version.
+ * @param AppContext application context for connecting to the service.
+ * @param Callback object, that implements LoaderCallbackInterface for handling the connection status.
+ * @return Returns true if initialization of OpenCV is successful.
+ */
+ public static boolean initAsync(String Version, Context AppContext,
+ LoaderCallbackInterface Callback)
+ {
+ return AsyncServiceHelper.initOpenCV(Version, AppContext, Callback);
+ }
+}
diff --git a/modules/java/generator/src/java/android+sync.py b/modules/java/generator/src/java/android+sync.py
deleted file mode 100755
index ed78537..0000000
--- a/modules/java/generator/src/java/android+sync.py
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/python
-
-import os
-import shutil
-
-for f in os.listdir("."):
- shutil.copyfile(f, os.path.join("../../../../../../modules/java/generator/src/java/", "android+" + f));
diff --git a/modules/java/generator/src/java/osgi+OpenCVInterface.java b/modules/java/generator/src/java/osgi+OpenCVInterface.java
new file mode 100644
index 0000000..83ffee1
--- /dev/null
+++ b/modules/java/generator/src/java/osgi+OpenCVInterface.java
@@ -0,0 +1,8 @@
+package org.opencv.osgi;
+
+/**
+ * Dummy interface to allow some integration testing within OSGi implementation.
+ */
+public interface OpenCVInterface
+{
+}
diff --git a/modules/java/generator/src/java/osgi+OpenCVNativeLoader.java.in b/modules/java/generator/src/java/osgi+OpenCVNativeLoader.java.in
new file mode 100644
index 0000000..77e290b
--- /dev/null
+++ b/modules/java/generator/src/java/osgi+OpenCVNativeLoader.java.in
@@ -0,0 +1,18 @@
+package org.opencv.osgi;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * This class is intended to provide a convenient way to load OpenCV's native
+ * library from the Java bundle. If Blueprint is enabled in the OSGi container
+ * this class will be instantiated automatically and the init() method called
+ * loading the native library.
+ */
+public class OpenCVNativeLoader implements OpenCVInterface {
+
+ public void init() {
+ System.loadLibrary("opencv_java at LIB_NAME_SUFIX@");
+ Logger.getLogger("org.opencv.osgi").log(Level.INFO, "Successfully loaded OpenCV native library.");
+ }
+}
diff --git a/modules/java/generator/src/java/utils+Converters.java b/modules/java/generator/src/java/utils+Converters.java
index bd3bb64..c0575a6 100644
--- a/modules/java/generator/src/java/utils+Converters.java
+++ b/modules/java/generator/src/java/utils+Converters.java
@@ -14,6 +14,7 @@ import org.opencv.core.MatOfPoint3f;
import org.opencv.core.Point;
import org.opencv.core.Point3;
import org.opencv.core.Rect;
+import org.opencv.core.Rect2d;
import org.opencv.core.DMatch;
import org.opencv.core.KeyPoint;
@@ -435,6 +436,42 @@ public class Converters {
}
}
+ public static Mat vector_Rect2d_to_Mat(List<Rect2d> rs) {
+ Mat res;
+ int count = (rs != null) ? rs.size() : 0;
+ if (count > 0) {
+ res = new Mat(count, 1, CvType.CV_64FC4);
+ double[] buff = new double[4 * count];
+ for (int i = 0; i < count; i++) {
+ Rect2d r = rs.get(i);
+ buff[4 * i] = r.x;
+ buff[4 * i + 1] = r.y;
+ buff[4 * i + 2] = r.width;
+ buff[4 * i + 3] = r.height;
+ }
+ res.put(0, 0, buff);
+ } else {
+ res = new Mat();
+ }
+ return res;
+ }
+
+ public static void Mat_to_vector_Rect2d(Mat m, List<Rect2d> rs) {
+ if (rs == null)
+ throw new java.lang.IllegalArgumentException("rs == null");
+ int count = m.rows();
+ if (CvType.CV_64FC4 != m.type() || m.cols() != 1)
+ throw new java.lang.IllegalArgumentException(
+ "CvType.CV_64FC4 != m.type() || m.rows()!=1\n" + m);
+
+ rs.clear();
+ double[] buff = new double[4 * count];
+ m.get(0, 0, buff);
+ for (int i = 0; i < count; i++) {
+ rs.add(new Rect2d(buff[4 * i], buff[4 * i + 1], buff[4 * i + 2], buff[4 * i + 3]));
+ }
+ }
+
public static Mat vector_KeyPoint_to_Mat(List<KeyPoint> kps) {
Mat res;
int count = (kps != null) ? kps.size() : 0;
diff --git a/modules/java/include/opencv2/java.hpp b/modules/java/include/opencv2/java.hpp
new file mode 100644
index 0000000..28cf9e5
--- /dev/null
+++ b/modules/java/include/opencv2/java.hpp
@@ -0,0 +1,49 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+// Author: abratchik
+
+#ifndef JAVA_HPP
+#define JAVA_HPP
+
+#ifdef __ANDROID__
+# include <android/log.h>
+# define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
+# ifdef DEBUG
+# define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
+# else
+# define LOGD(...)
+# endif
+#else
+# define LOGE(...)
+# define LOGD(...)
+#endif
+
+
+#define MATOFINT(ENV) static_cast<jclass>(ENV->NewGlobalRef(ENV->FindClass("org/opencv/core/MatOfInt")))
+#define GETNATIVEOBJ(ENV, CLS, MAT) ENV->GetLongField(MAT, ENV->GetFieldID(CLS, "nativeObj", "J"))
+
+#define CONSTRUCTOR(ENV, CLS) ENV->GetMethodID(CLS, "<init>", "(I)V")
+
+#define ARRAYLIST(ENV) static_cast<jclass>(ENV->NewGlobalRef(ENV->FindClass("java/util/ArrayList")))
+#define LIST_ADD(ENV, LIST) ENV->GetMethodID(LIST, "add", "(Ljava/lang/Object;)Z")
+#define LIST_GET(ENV, LIST) ENV->GetMethodID(LIST, "get", "((I)Ljava/lang/Object;")
+#define LIST_SIZE(ENV, LIST) ENV->GetMethodID(LIST, "size", "()I")
+#define LIST_CLEAR(ENV, LIST) ENV->GetMethodID(LIST, "clear", "()V")
+
+#define CHECK_MAT(cond) if(!(cond)){ LOGD("FAILED: " #cond); return; }
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* JAVA_HPP */
\ No newline at end of file
diff --git a/modules/java/pure_test/CMakeLists.txt b/modules/java/pure_test/CMakeLists.txt
index 7d78414..95b7e47 100644
--- a/modules/java/pure_test/CMakeLists.txt
+++ b/modules/java/pure_test/CMakeLists.txt
@@ -1,4 +1,6 @@
-if(NOT ANT_EXECUTABLE)
+if(NOT ANT_EXECUTABLE
+ OR NOT BUILD_opencv_imgcodecs
+ OR NOT BUILD_opencv_calib3d)
return()
endif()
diff --git a/modules/ml/include/opencv2/ml.hpp b/modules/ml/include/opencv2/ml.hpp
index 99f5883..a8b7114 100644
--- a/modules/ml/include/opencv2/ml.hpp
+++ b/modules/ml/include/opencv2/ml.hpp
@@ -104,7 +104,7 @@ enum SampleTypes
It is used for optimizing statmodel accuracy by varying model parameters, the accuracy estimate
being computed by cross-validation.
*/
-class CV_EXPORTS ParamGrid
+class CV_EXPORTS_W ParamGrid
{
public:
/** @brief Default constructor */
@@ -112,8 +112,8 @@ public:
/** @brief Constructor with parameters */
ParamGrid(double _minVal, double _maxVal, double _logStep);
- double minVal; //!< Minimum value of the statmodel parameter. Default value is 0.
- double maxVal; //!< Maximum value of the statmodel parameter. Default value is 0.
+ CV_PROP_RW double minVal; //!< Minimum value of the statmodel parameter. Default value is 0.
+ CV_PROP_RW double maxVal; //!< Maximum value of the statmodel parameter. Default value is 0.
/** @brief Logarithmic step for iterating the statmodel parameter.
The grid determines the following iteration sequence of the statmodel parameter values:
@@ -122,7 +122,15 @@ public:
\f[\texttt{minVal} * \texttt{logStep} ^n < \texttt{maxVal}\f]
The grid is logarithmic, so logStep must always be greater then 1. Default value is 1.
*/
- double logStep;
+ CV_PROP_RW double logStep;
+
+ /** @brief Creates a ParamGrid Ptr that can be given to the %SVM::trainAuto method
+
+ @param minVal minimum value of the parameter grid
+ @param maxVal maximum value of the parameter grid
+ @param logstep Logarithmic step for iterating the statmodel parameter
+ */
+ CV_WRAP static Ptr<ParamGrid> create(double minVal=0., double maxVal=0., double logstep=1.);
};
/** @brief Class encapsulating training data.
@@ -393,6 +401,17 @@ public:
/** Creates empty model
Use StatModel::train to train the model after creation. */
CV_WRAP static Ptr<NormalBayesClassifier> create();
+
+ /** @brief Loads and creates a serialized NormalBayesClassifier from a file
+ *
+ * Use NormalBayesClassifier::save to serialize and store an NormalBayesClassifier to disk.
+ * Load the NormalBayesClassifier from this file again, by calling this function with the path to the file.
+ * Optionally specify the node for the file containing the classifier
+ *
+ * @param filepath path to serialized NormalBayesClassifier
+ * @param nodeName name of node containing the classifier
+ */
+ CV_WRAP static Ptr<NormalBayesClassifier> load(const String& filepath , const String& nodeName = String());
};
/****************************************************************************************\
@@ -672,14 +691,54 @@ public:
the usual %SVM with parameters specified in params is executed.
*/
virtual bool trainAuto( const Ptr<TrainData>& data, int kFold = 10,
- ParamGrid Cgrid = SVM::getDefaultGrid(SVM::C),
- ParamGrid gammaGrid = SVM::getDefaultGrid(SVM::GAMMA),
- ParamGrid pGrid = SVM::getDefaultGrid(SVM::P),
- ParamGrid nuGrid = SVM::getDefaultGrid(SVM::NU),
- ParamGrid coeffGrid = SVM::getDefaultGrid(SVM::COEF),
- ParamGrid degreeGrid = SVM::getDefaultGrid(SVM::DEGREE),
+ ParamGrid Cgrid = getDefaultGrid(C),
+ ParamGrid gammaGrid = getDefaultGrid(GAMMA),
+ ParamGrid pGrid = getDefaultGrid(P),
+ ParamGrid nuGrid = getDefaultGrid(NU),
+ ParamGrid coeffGrid = getDefaultGrid(COEF),
+ ParamGrid degreeGrid = getDefaultGrid(DEGREE),
bool balanced=false) = 0;
+ /** @brief Trains an %SVM with optimal parameters
+
+ @param samples training samples
+ @param layout See ml::SampleTypes.
+ @param responses vector of responses associated with the training samples.
+ @param kFold Cross-validation parameter. The training set is divided into kFold subsets. One
+ subset is used to test the model, the others form the train set. So, the %SVM algorithm is
+ @param Cgrid grid for C
+ @param gammaGrid grid for gamma
+ @param pGrid grid for p
+ @param nuGrid grid for nu
+ @param coeffGrid grid for coeff
+ @param degreeGrid grid for degree
+ @param balanced If true and the problem is 2-class classification then the method creates more
+ balanced cross-validation subsets that is proportions between classes in subsets are close
+ to such proportion in the whole train dataset.
+
+ The method trains the %SVM model automatically by choosing the optimal parameters C, gamma, p,
+ nu, coef0, degree. Parameters are considered optimal when the cross-validation
+ estimate of the test set error is minimal.
+
+ This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only
+ offers rudimentary parameter options.
+
+ This function works for the classification (SVM::C_SVC or SVM::NU_SVC) as well as for the
+ regression (SVM::EPS_SVR or SVM::NU_SVR). If it is SVM::ONE_CLASS, no optimization is made and
+ the usual %SVM with parameters specified in params is executed.
+ */
+ CV_WRAP bool trainAuto(InputArray samples,
+ int layout,
+ InputArray responses,
+ int kFold = 10,
+ Ptr<ParamGrid> Cgrid = SVM::getDefaultGridPtr(SVM::C),
+ Ptr<ParamGrid> gammaGrid = SVM::getDefaultGridPtr(SVM::GAMMA),
+ Ptr<ParamGrid> pGrid = SVM::getDefaultGridPtr(SVM::P),
+ Ptr<ParamGrid> nuGrid = SVM::getDefaultGridPtr(SVM::NU),
+ Ptr<ParamGrid> coeffGrid = SVM::getDefaultGridPtr(SVM::COEF),
+ Ptr<ParamGrid> degreeGrid = SVM::getDefaultGridPtr(SVM::DEGREE),
+ bool balanced=false);
+
/** @brief Retrieves all the support vectors
The method returns all the support vectors as a floating-point matrix, where support vectors are
@@ -722,6 +781,16 @@ public:
*/
static ParamGrid getDefaultGrid( int param_id );
+ /** @brief Generates a grid for %SVM parameters.
+
+ @param param_id %SVM parameters IDs that must be one of the SVM::ParamTypes. The grid is
+ generated for the parameter with this ID.
+
+ The function generates a grid pointer for the specified parameter of the %SVM algorithm.
+ The grid may be passed to the function SVM::trainAuto.
+ */
+ CV_WRAP static Ptr<ParamGrid> getDefaultGridPtr( int param_id );
+
/** Creates empty model.
Use StatModel::train to train the model. Since %SVM has several parameters, you may want to
find the best parameters for your problem, it can be done with SVM::trainAuto. */
@@ -818,6 +887,15 @@ public:
*/
CV_WRAP virtual void getCovs(CV_OUT std::vector<Mat>& covs) const = 0;
+ /** @brief Returns posterior probabilities for the provided samples
+
+ @param samples The input samples, floating-point matrix
+ @param results The optional output \f$ nSamples \times nClusters\f$ matrix of results. It contains
+ posterior probabilities for each sample from the input
+ @param flags This parameter will be ignored
+ */
+ CV_WRAP virtual float predict( InputArray samples, OutputArray results=noArray(), int flags=0 ) const = 0;
+
/** @brief Returns a likelihood logarithm value and an index of the most probable mixture component
for the given sample.
@@ -927,6 +1005,17 @@ public:
can use one of the EM::train\* methods or load it from file using Algorithm::load\<EM\>(filename).
*/
CV_WRAP static Ptr<EM> create();
+
+ /** @brief Loads and creates a serialized EM from a file
+ *
+ * Use EM::save to serialize and store an EM to disk.
+ * Load the EM from this file again, by calling this function with the path to the file.
+ * Optionally specify the node for the file containing the classifier
+ *
+ * @param filepath path to serialized EM
+ * @param nodeName name of node containing the classifier
+ */
+ CV_WRAP static Ptr<EM> load(const String& filepath , const String& nodeName = String());
};
/****************************************************************************************\
@@ -1115,6 +1204,17 @@ public:
file using Algorithm::load\<DTrees\>(filename).
*/
CV_WRAP static Ptr<DTrees> create();
+
+ /** @brief Loads and creates a serialized DTrees from a file
+ *
+ * Use DTree::save to serialize and store an DTree to disk.
+ * Load the DTree from this file again, by calling this function with the path to the file.
+ * Optionally specify the node for the file containing the classifier
+ *
+ * @param filepath path to serialized DTree
+ * @param nodeName name of node containing the classifier
+ */
+ CV_WRAP static Ptr<DTrees> load(const String& filepath , const String& nodeName = String());
};
/****************************************************************************************\
@@ -1164,11 +1264,33 @@ public:
*/
CV_WRAP virtual Mat getVarImportance() const = 0;
+ /** Returns the result of each individual tree in the forest.
+ In case the model is a regression problem, the method will return each of the trees'
+ results for each of the sample cases. If the model is a classifier, it will return
+ a Mat with samples + 1 rows, where the first row gives the class number and the
+ following rows return the votes each class had for each sample.
+ @param samples Array containg the samples for which votes will be calculated.
+ @param results Array where the result of the calculation will be written.
+ @param flags Flags for defining the type of RTrees.
+ */
+ CV_WRAP void getVotes(InputArray samples, OutputArray results, int flags) const;
+
/** Creates the empty model.
Use StatModel::train to train the model, StatModel::train to create and train the model,
Algorithm::load to load the pre-trained model.
*/
CV_WRAP static Ptr<RTrees> create();
+
+ /** @brief Loads and creates a serialized RTree from a file
+ *
+ * Use RTree::save to serialize and store an RTree to disk.
+ * Load the RTree from this file again, by calling this function with the path to the file.
+ * Optionally specify the node for the file containing the classifier
+ *
+ * @param filepath path to serialized RTree
+ * @param nodeName name of node containing the classifier
+ */
+ CV_WRAP static Ptr<RTrees> load(const String& filepath , const String& nodeName = String());
};
/****************************************************************************************\
@@ -1218,6 +1340,17 @@ public:
/** Creates the empty model.
Use StatModel::train to train the model, Algorithm::load\<Boost\>(filename) to load the pre-trained model. */
CV_WRAP static Ptr<Boost> create();
+
+ /** @brief Loads and creates a serialized Boost from a file
+ *
+ * Use Boost::save to serialize and store an RTree to disk.
+ * Load the Boost from this file again, by calling this function with the path to the file.
+ * Optionally specify the node for the file containing the classifier
+ *
+ * @param filepath path to serialized Boost
+ * @param nodeName name of node containing the classifier
+ */
+ CV_WRAP static Ptr<Boost> load(const String& filepath , const String& nodeName = String());
};
/****************************************************************************************\
@@ -1501,6 +1634,17 @@ public:
Creates Logistic Regression model with parameters given.
*/
CV_WRAP static Ptr<LogisticRegression> create();
+
+ /** @brief Loads and creates a serialized LogisticRegression from a file
+ *
+ * Use LogisticRegression::save to serialize and store an LogisticRegression to disk.
+ * Load the LogisticRegression from this file again, by calling this function with the path to the file.
+ * Optionally specify the node for the file containing the classifier
+ *
+ * @param filepath path to serialized LogisticRegression
+ * @param nodeName name of node containing the classifier
+ */
+ CV_WRAP static Ptr<LogisticRegression> load(const String& filepath , const String& nodeName = String());
};
@@ -1616,6 +1760,17 @@ public:
*/
CV_WRAP static Ptr<SVMSGD> create();
+ /** @brief Loads and creates a serialized SVMSGD from a file
+ *
+ * Use SVMSGD::save to serialize and store an SVMSGD to disk.
+ * Load the SVMSGD from this file again, by calling this function with the path to the file.
+ * Optionally specify the node for the file containing the classifier
+ *
+ * @param filepath path to serialized SVMSGD
+ * @param nodeName name of node containing the classifier
+ */
+ CV_WRAP static Ptr<SVMSGD> load(const String& filepath , const String& nodeName = String());
+
/** @brief Function sets optimal parameters values for chosen SVM SGD model.
* @param svmsgdType is the type of SVMSGD classifier.
* @param marginType is the type of margin constraint.
diff --git a/modules/ml/misc/java/test/MLTest.java b/modules/ml/misc/java/test/MLTest.java
new file mode 100644
index 0000000..2b08543
--- /dev/null
+++ b/modules/ml/misc/java/test/MLTest.java
@@ -0,0 +1,42 @@
+package org.opencv.test.ml;
+
+import org.opencv.ml.Ml;
+import org.opencv.ml.SVM;
+import org.opencv.core.Mat;
+import org.opencv.core.MatOfFloat;
+import org.opencv.core.MatOfInt;
+import org.opencv.core.CvType;
+import org.opencv.test.OpenCVTestCase;
+import org.opencv.test.OpenCVTestRunner;
+
+public class MLTest extends OpenCVTestCase {
+
+ public void testSaveLoad() {
+ Mat samples = new MatOfFloat(new float[] {
+ 5.1f, 3.5f, 1.4f, 0.2f,
+ 4.9f, 3.0f, 1.4f, 0.2f,
+ 4.7f, 3.2f, 1.3f, 0.2f,
+ 4.6f, 3.1f, 1.5f, 0.2f,
+ 5.0f, 3.6f, 1.4f, 0.2f,
+ 7.0f, 3.2f, 4.7f, 1.4f,
+ 6.4f, 3.2f, 4.5f, 1.5f,
+ 6.9f, 3.1f, 4.9f, 1.5f,
+ 5.5f, 2.3f, 4.0f, 1.3f,
+ 6.5f, 2.8f, 4.6f, 1.5f
+ }).reshape(1, 10);
+ Mat responses = new MatOfInt(new int[] {
+ 0, 0, 0, 0, 0, 1, 1, 1, 1, 1
+ }).reshape(1, 10);
+ SVM saved = SVM.create();
+ assertFalse(saved.isTrained());
+
+ saved.train(samples, Ml.ROW_SAMPLE, responses);
+ assertTrue(saved.isTrained());
+
+ String filename = OpenCVTestRunner.getTempFileName("yml");
+ saved.save(filename);
+ SVM loaded = SVM.load(filename);
+ assertTrue(saved.isTrained());
+ }
+
+}
diff --git a/modules/ml/src/boost.cpp b/modules/ml/src/boost.cpp
index 3b6bd7a..bc0ba00 100644
--- a/modules/ml/src/boost.cpp
+++ b/modules/ml/src/boost.cpp
@@ -507,6 +507,11 @@ Ptr<Boost> Boost::create()
return makePtr<BoostImpl>();
}
+Ptr<Boost> Boost::load(const String& filepath, const String& nodeName)
+{
+ return Algorithm::load<Boost>(filepath, nodeName);
+}
+
}}
/* End of file. */
diff --git a/modules/ml/src/data.cpp b/modules/ml/src/data.cpp
index 5e1b6d2..07858a0 100644
--- a/modules/ml/src/data.cpp
+++ b/modules/ml/src/data.cpp
@@ -403,7 +403,7 @@ public:
Mat(tempCatMap).copyTo(catMap);
}
- if( varType.at<uchar>(ninputvars) == VAR_CATEGORICAL )
+ if( noutputvars > 0 && varType.at<uchar>(ninputvars) == VAR_CATEGORICAL )
{
preprocessCategorical(responses, &normCatResponses, labels, &counters, sortbuf);
Mat(labels).copyTo(classLabels);
@@ -1028,6 +1028,7 @@ Ptr<TrainData> TrainData::loadFromCSV(const String& filename,
const String& varTypeSpec,
char delimiter, char missch)
{
+ CV_TRACE_FUNCTION_SKIP_NESTED();
Ptr<TrainDataImpl> td = makePtr<TrainDataImpl>();
if(!td->loadCSV(filename, headerLines, responseStartIdx, responseEndIdx, varTypeSpec, delimiter, missch))
td.release();
@@ -1038,6 +1039,7 @@ Ptr<TrainData> TrainData::create(InputArray samples, int layout, InputArray resp
InputArray varIdx, InputArray sampleIdx, InputArray sampleWeights,
InputArray varType)
{
+ CV_TRACE_FUNCTION_SKIP_NESTED();
Ptr<TrainDataImpl> td = makePtr<TrainDataImpl>();
td->setData(samples, layout, responses, varIdx, sampleIdx, sampleWeights, varType, noArray());
return td;
diff --git a/modules/ml/src/em.cpp b/modules/ml/src/em.cpp
index 5b833cd..40993ff 100644
--- a/modules/ml/src/em.cpp
+++ b/modules/ml/src/em.cpp
@@ -845,6 +845,11 @@ Ptr<EM> EM::create()
return makePtr<EMImpl>();
}
+Ptr<EM> EM::load(const String& filepath, const String& nodeName)
+{
+ return Algorithm::load<EM>(filepath, nodeName);
+}
+
}
} // namespace cv
diff --git a/modules/ml/src/inner_functions.cpp b/modules/ml/src/inner_functions.cpp
index 3966906..e9e8d4b 100644
--- a/modules/ml/src/inner_functions.cpp
+++ b/modules/ml/src/inner_functions.cpp
@@ -45,28 +45,36 @@ namespace cv { namespace ml {
ParamGrid::ParamGrid() { minVal = maxVal = 0.; logStep = 1; }
ParamGrid::ParamGrid(double _minVal, double _maxVal, double _logStep)
{
+ CV_TRACE_FUNCTION();
minVal = std::min(_minVal, _maxVal);
maxVal = std::max(_minVal, _maxVal);
logStep = std::max(_logStep, 1.);
}
+Ptr<ParamGrid> ParamGrid::create(double minval, double maxval, double logstep) {
+ return makePtr<ParamGrid>(minval, maxval, logstep);
+}
+
bool StatModel::empty() const { return !isTrained(); }
int StatModel::getVarCount() const { return 0; }
bool StatModel::train( const Ptr<TrainData>&, int )
{
+ CV_TRACE_FUNCTION();
CV_Error(CV_StsNotImplemented, "");
return false;
}
bool StatModel::train( InputArray samples, int layout, InputArray responses )
{
+ CV_TRACE_FUNCTION();
return train(TrainData::create(samples, layout, responses));
}
float StatModel::calcError( const Ptr<TrainData>& data, bool testerr, OutputArray _resp ) const
{
+ CV_TRACE_FUNCTION_SKIP_NESTED();
Mat samples = data->getSamples();
int layout = data->getLayout();
Mat sidx = testerr ? data->getTestSampleIdx() : data->getTrainSampleIdx();
@@ -115,6 +123,7 @@ float StatModel::calcError( const Ptr<TrainData>& data, bool testerr, OutputArra
/* Calculates upper triangular matrix S, where A is a symmetrical matrix A=S'*S */
static void Cholesky( const Mat& A, Mat& S )
{
+ CV_TRACE_FUNCTION();
CV_Assert(A.type() == CV_32F);
S = A.clone();
@@ -129,6 +138,7 @@ static void Cholesky( const Mat& A, Mat& S )
average row vector, <cov> - symmetric covariation matrix */
void randMVNormal( InputArray _mean, InputArray _cov, int nsamples, OutputArray _samples )
{
+ CV_TRACE_FUNCTION();
// check mean vector and covariance matrix
Mat mean = _mean.getMat(), cov = _cov.getMat();
int dim = (int)mean.total(); // dimensionality
diff --git a/modules/ml/src/lr.cpp b/modules/ml/src/lr.cpp
index 99692f3..00c092d 100644
--- a/modules/ml/src/lr.cpp
+++ b/modules/ml/src/lr.cpp
@@ -127,11 +127,21 @@ Ptr<LogisticRegression> LogisticRegression::create()
return makePtr<LogisticRegressionImpl>();
}
+Ptr<LogisticRegression> LogisticRegression::load(const String& filepath, const String& nodeName)
+{
+ return Algorithm::load<LogisticRegression>(filepath, nodeName);
+}
+
+
bool LogisticRegressionImpl::train(const Ptr<TrainData>& trainData, int)
{
+ CV_TRACE_FUNCTION_SKIP_NESTED();
// return value
bool ok = false;
+ if (trainData.empty()) {
+ return false;
+ }
clear();
Mat _data_i = trainData->getSamples();
Mat _labels_i = trainData->getResponses();
@@ -304,6 +314,7 @@ float LogisticRegressionImpl::predict(InputArray samples, OutputArray results, i
Mat LogisticRegressionImpl::calc_sigmoid(const Mat& data) const
{
+ CV_TRACE_FUNCTION();
Mat dest;
exp(-data, dest);
return 1.0/(1.0+dest);
@@ -311,7 +322,8 @@ Mat LogisticRegressionImpl::calc_sigmoid(const Mat& data) const
double LogisticRegressionImpl::compute_cost(const Mat& _data, const Mat& _labels, const Mat& _init_theta)
{
- int llambda = 0;
+ CV_TRACE_FUNCTION();
+ float llambda = 0; /*changed llambda from int to float to solve issue #7924*/
int m;
int n;
double cost = 0;
@@ -401,6 +413,7 @@ struct LogisticRegressionImpl_ComputeDradient_Impl : ParallelLoopBody
void LogisticRegressionImpl::compute_gradient(const Mat& _data, const Mat& _labels, const Mat &_theta, const double _lambda, Mat & _gradient )
{
+ CV_TRACE_FUNCTION();
const int m = _data.rows;
Mat pcal_a, pcal_b, pcal_ab;
@@ -422,6 +435,7 @@ void LogisticRegressionImpl::compute_gradient(const Mat& _data, const Mat& _labe
Mat LogisticRegressionImpl::batch_gradient_descent(const Mat& _data, const Mat& _labels, const Mat& _init_theta)
{
+ CV_TRACE_FUNCTION();
// implements batch gradient descent
if(this->params.alpha<=0)
{
@@ -579,7 +593,7 @@ void LogisticRegressionImpl::write(FileStorage& fs) const
CV_Error(CV_StsBadArg,"file can't open. Check file path");
}
writeFormat(fs);
- string desc = "Logisitic Regression Classifier";
+ string desc = "Logistic Regression Classifier";
fs<<"classifier"<<desc.c_str();
fs<<"alpha"<<this->params.alpha;
fs<<"iterations"<<this->params.num_iters;
diff --git a/modules/ml/src/nbayes.cpp b/modules/ml/src/nbayes.cpp
index c46367c..dc70db2 100644
--- a/modules/ml/src/nbayes.cpp
+++ b/modules/ml/src/nbayes.cpp
@@ -203,6 +203,7 @@ public:
results = &_results;
results_prob = !_results_prob.empty() ? &_results_prob : 0;
rawOutput = _rawOutput;
+ value = 0;
}
const Mat* c;
@@ -458,6 +459,11 @@ Ptr<NormalBayesClassifier> NormalBayesClassifier::create()
return p;
}
+Ptr<NormalBayesClassifier> NormalBayesClassifier::load(const String& filepath, const String& nodeName)
+{
+ return Algorithm::load<NormalBayesClassifier>(filepath, nodeName);
+}
+
}
}
diff --git a/modules/ml/src/rtrees.cpp b/modules/ml/src/rtrees.cpp
index cab33ab..6aa3c96 100644
--- a/modules/ml/src/rtrees.cpp
+++ b/modules/ml/src/rtrees.cpp
@@ -41,7 +41,6 @@
//M*/
#include "precomp.hpp"
-
namespace cv {
namespace ml {
@@ -50,6 +49,7 @@ namespace ml {
//////////////////////////////////////////////////////////////////////////////////////////
RTreeParams::RTreeParams()
{
+ CV_TRACE_FUNCTION();
calcVarImportance = false;
nactiveVars = 0;
termCrit = TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 50, 0.1);
@@ -59,6 +59,7 @@ RTreeParams::RTreeParams(bool _calcVarImportance,
int _nactiveVars,
TermCriteria _termCrit )
{
+ CV_TRACE_FUNCTION();
calcVarImportance = _calcVarImportance;
nactiveVars = _nactiveVars;
termCrit = _termCrit;
@@ -70,6 +71,7 @@ class DTreesImplForRTrees : public DTreesImpl
public:
DTreesImplForRTrees()
{
+ CV_TRACE_FUNCTION();
params.setMaxDepth(5);
params.setMinSampleCount(10);
params.setRegressionAccuracy(0.f);
@@ -79,11 +81,13 @@ public:
params.use1SERule = false;
params.truncatePrunedTree = false;
params.priors = Mat();
+ oobError = 0;
}
virtual ~DTreesImplForRTrees() {}
void clear()
{
+ CV_TRACE_FUNCTION();
DTreesImpl::clear();
oobError = 0.;
rng = RNG((uint64)-1);
@@ -91,6 +95,7 @@ public:
const vector<int>& getActiveVars()
{
+ CV_TRACE_FUNCTION();
int i, nvars = (int)allVars.size(), m = (int)activeVars.size();
for( i = 0; i < nvars; i++ )
{
@@ -105,6 +110,7 @@ public:
void startTraining( const Ptr<TrainData>& trainData, int flags )
{
+ CV_TRACE_FUNCTION();
DTreesImpl::startTraining(trainData, flags);
int nvars = w->data->getNVars();
int i, m = rparams.nactiveVars > 0 ? rparams.nactiveVars : cvRound(std::sqrt((double)nvars));
@@ -117,6 +123,7 @@ public:
void endTraining()
{
+ CV_TRACE_FUNCTION();
DTreesImpl::endTraining();
vector<int> a, b;
std::swap(allVars, a);
@@ -125,6 +132,7 @@ public:
bool train( const Ptr<TrainData>& trainData, int flags )
{
+ CV_TRACE_FUNCTION();
startTraining(trainData, flags);
int treeidx, ntrees = (rparams.termCrit.type & TermCriteria::COUNT) != 0 ?
rparams.termCrit.maxCount : 10000;
@@ -287,12 +295,14 @@ public:
void writeTrainingParams( FileStorage& fs ) const
{
+ CV_TRACE_FUNCTION();
DTreesImpl::writeTrainingParams(fs);
fs << "nactive_vars" << rparams.nactiveVars;
}
void write( FileStorage& fs ) const
{
+ CV_TRACE_FUNCTION();
if( roots.empty() )
CV_Error( CV_StsBadArg, "RTrees have not been trained" );
@@ -320,6 +330,7 @@ public:
void readParams( const FileNode& fn )
{
+ CV_TRACE_FUNCTION();
DTreesImpl::readParams(fn);
FileNode tparams_node = fn["training_params"];
@@ -328,6 +339,7 @@ public:
void read( const FileNode& fn )
{
+ CV_TRACE_FUNCTION();
clear();
//int nclasses = (int)fn["nclasses"];
@@ -350,6 +362,61 @@ public:
}
}
+ void getVotes( InputArray input, OutputArray output, int flags ) const
+ {
+ CV_TRACE_FUNCTION();
+ CV_Assert( !roots.empty() );
+ int nclasses = (int)classLabels.size(), ntrees = (int)roots.size();
+ Mat samples = input.getMat(), results;
+ int i, j, nsamples = samples.rows;
+
+ int predictType = flags & PREDICT_MASK;
+ if( predictType == PREDICT_AUTO )
+ {
+ predictType = !_isClassifier || (classLabels.size() == 2 && (flags & RAW_OUTPUT) != 0) ?
+ PREDICT_SUM : PREDICT_MAX_VOTE;
+ }
+
+ if( predictType == PREDICT_SUM )
+ {
+ output.create(nsamples, ntrees, CV_32F);
+ results = output.getMat();
+ for( i = 0; i < nsamples; i++ )
+ {
+ for( j = 0; j < ntrees; j++ )
+ {
+ float val = predictTrees( Range(j, j+1), samples.row(i), flags);
+ results.at<float> (i, j) = val;
+ }
+ }
+ } else
+ {
+ vector<int> votes;
+ output.create(nsamples+1, nclasses, CV_32S);
+ results = output.getMat();
+
+ for ( j = 0; j < nclasses; j++)
+ {
+ results.at<int> (0, j) = classLabels[j];
+ }
+
+ for( i = 0; i < nsamples; i++ )
+ {
+ votes.clear();
+ for( j = 0; j < ntrees; j++ )
+ {
+ int val = (int)predictTrees( Range(j, j+1), samples.row(i), flags);
+ votes.push_back(val);
+ }
+
+ for ( j = 0; j < nclasses; j++)
+ {
+ results.at<int> (i+1, j) = (int)std::count(votes.begin(), votes.end(), classLabels[j]);
+ }
+ }
+ }
+ }
+
RTreeParams rparams;
double oobError;
vector<float> varImportance;
@@ -382,6 +449,7 @@ public:
bool train( const Ptr<TrainData>& trainData, int flags )
{
+ CV_TRACE_FUNCTION();
if (impl.getCVFolds() != 0)
CV_Error(Error::StsBadArg, "Cross validation for RTrees is not implemented");
return impl.train(trainData, flags);
@@ -389,19 +457,28 @@ public:
float predict( InputArray samples, OutputArray results, int flags ) const
{
+ CV_TRACE_FUNCTION();
return impl.predict(samples, results, flags);
}
void write( FileStorage& fs ) const
{
+ CV_TRACE_FUNCTION();
impl.write(fs);
}
void read( const FileNode& fn )
{
+ CV_TRACE_FUNCTION();
impl.read(fn);
}
+ void getVotes_( InputArray samples, OutputArray results, int flags ) const
+ {
+ CV_TRACE_FUNCTION();
+ impl.getVotes(samples, results, flags);
+ }
+
Mat getVarImportance() const { return Mat_<float>(impl.varImportance, true); }
int getVarCount() const { return impl.getVarCount(); }
@@ -419,9 +496,26 @@ public:
Ptr<RTrees> RTrees::create()
{
+ CV_TRACE_FUNCTION();
return makePtr<RTreesImpl>();
}
+//Function needed for Python and Java wrappers
+Ptr<RTrees> RTrees::load(const String& filepath, const String& nodeName)
+{
+ CV_TRACE_FUNCTION();
+ return Algorithm::load<RTrees>(filepath, nodeName);
+}
+
+void RTrees::getVotes(InputArray input, OutputArray output, int flags) const
+{
+ CV_TRACE_FUNCTION();
+ const RTreesImpl* this_ = dynamic_cast<const RTreesImpl*>(this);
+ if(!this_)
+ CV_Error(Error::StsNotImplemented, "the class is not RTreesImpl");
+ return this_->getVotes_(input, output, flags);
+}
+
}}
// End of file.
diff --git a/modules/ml/src/svm.cpp b/modules/ml/src/svm.cpp
index 5e5b891..d486d26 100644
--- a/modules/ml/src/svm.cpp
+++ b/modules/ml/src/svm.cpp
@@ -362,6 +362,12 @@ static void sortSamplesByClasses( const Mat& _samples, const Mat& _responses,
//////////////////////// SVM implementation //////////////////////////////
+Ptr<ParamGrid> SVM::getDefaultGridPtr( int param_id)
+{
+ ParamGrid grid = getDefaultGrid(param_id); // this is not a nice solution..
+ return makePtr<ParamGrid>(grid.minVal, grid.maxVal, grid.logStep);
+}
+
ParamGrid SVM::getDefaultGrid( int param_id )
{
ParamGrid grid;
@@ -1920,6 +1926,24 @@ public:
bool returnDFVal;
};
+ bool trainAuto_(InputArray samples, int layout,
+ InputArray responses, int kfold, Ptr<ParamGrid> Cgrid,
+ Ptr<ParamGrid> gammaGrid, Ptr<ParamGrid> pGrid, Ptr<ParamGrid> nuGrid,
+ Ptr<ParamGrid> coeffGrid, Ptr<ParamGrid> degreeGrid, bool balanced)
+ {
+ Ptr<TrainData> data = TrainData::create(samples, layout, responses);
+ return this->trainAuto(
+ data, kfold,
+ *Cgrid.get(),
+ *gammaGrid.get(),
+ *pGrid.get(),
+ *nuGrid.get(),
+ *coeffGrid.get(),
+ *degreeGrid.get(),
+ balanced);
+ }
+
+
float predict( InputArray _samples, OutputArray _results, int flags ) const
{
float result = 0;
@@ -2281,6 +2305,19 @@ Mat SVM::getUncompressedSupportVectors() const
return this_->getUncompressedSupportVectors_();
}
+bool SVM::trainAuto(InputArray samples, int layout,
+ InputArray responses, int kfold, Ptr<ParamGrid> Cgrid,
+ Ptr<ParamGrid> gammaGrid, Ptr<ParamGrid> pGrid, Ptr<ParamGrid> nuGrid,
+ Ptr<ParamGrid> coeffGrid, Ptr<ParamGrid> degreeGrid, bool balanced)
+{
+ SVMImpl* this_ = dynamic_cast<SVMImpl*>(this);
+ if (!this_) {
+ CV_Error(Error::StsNotImplemented, "the class is not SVMImpl");
+ }
+ return this_->trainAuto_(samples, layout, responses,
+ kfold, Cgrid, gammaGrid, pGrid, nuGrid, coeffGrid, degreeGrid, balanced);
+}
+
}
}
diff --git a/modules/ml/src/svmsgd.cpp b/modules/ml/src/svmsgd.cpp
index 0ef9175..4b92079 100644
--- a/modules/ml/src/svmsgd.cpp
+++ b/modules/ml/src/svmsgd.cpp
@@ -134,6 +134,12 @@ Ptr<SVMSGD> SVMSGD::create()
return makePtr<SVMSGDImpl>();
}
+Ptr<SVMSGD> SVMSGD::load(const String& filepath, const String& nodeName)
+{
+ return Algorithm::load<SVMSGD>(filepath, nodeName);
+}
+
+
void SVMSGDImpl::normalizeSamples(Mat &samples, Mat &average, float &multiplier)
{
int featuresCount = samples.cols;
diff --git a/modules/ml/src/tree.cpp b/modules/ml/src/tree.cpp
index c02b744..4faf9b3 100644
--- a/modules/ml/src/tree.cpp
+++ b/modules/ml/src/tree.cpp
@@ -115,7 +115,7 @@ DTreesImpl::WorkData::WorkData(const Ptr<TrainData>& _data)
maxSubsetSize = 0;
}
-DTreesImpl::DTreesImpl() {}
+DTreesImpl::DTreesImpl() : _isClassifier(false) {}
DTreesImpl::~DTreesImpl() {}
void DTreesImpl::clear()
{
@@ -1442,6 +1442,7 @@ float DTreesImpl::predictTrees( const Range& range, const Mat& sample, int flags
CV_Error( CV_StsBadArg,
"one of input categorical variable is not an integer" );
+ CV_Assert(cmap != NULL);
while( a < b )
{
c = (a + b) >> 1;
@@ -1941,6 +1942,12 @@ Ptr<DTrees> DTrees::create()
return makePtr<DTreesImpl>();
}
+Ptr<DTrees> DTrees::load(const String& filepath, const String& nodeName)
+{
+ return Algorithm::load<DTrees>(filepath, nodeName);
+}
+
+
}
}
diff --git a/modules/ml/test/test_emknearestkmeans.cpp b/modules/ml/test/test_emknearestkmeans.cpp
index 6537175..eaed926 100644
--- a/modules/ml/test/test_emknearestkmeans.cpp
+++ b/modules/ml/test/test_emknearestkmeans.cpp
@@ -50,6 +50,7 @@ using cv::ml::KNearest;
static
void defaultDistribs( Mat& means, vector<Mat>& covs, int type=CV_32FC1 )
{
+ CV_TRACE_FUNCTION();
float mp0[] = {0.0f, 0.0f}, cp0[] = {0.67f, 0.0f, 0.0f, 0.67f};
float mp1[] = {5.0f, 0.0f}, cp1[] = {1.0f, 0.0f, 0.0f, 1.0f};
float mp2[] = {1.0f, 5.0f}, cp2[] = {1.0f, 0.0f, 0.0f, 1.0f};
@@ -76,6 +77,7 @@ void defaultDistribs( Mat& means, vector<Mat>& covs, int type=CV_32FC1 )
static
void generateData( Mat& data, Mat& labels, const vector<int>& sizes, const Mat& _means, const vector<Mat>& covs, int dataType, int labelType )
{
+ CV_TRACE_FUNCTION();
vector<int>::const_iterator sit = sizes.begin();
int total = 0;
for( ; sit != sizes.end(); ++sit )
@@ -226,6 +228,7 @@ protected:
void CV_KMeansTest::run( int /*start_from*/ )
{
+ CV_TRACE_FUNCTION();
const int iters = 100;
int sizesArr[] = { 5000, 7000, 8000 };
int pointsCount = sizesArr[0]+ sizesArr[1] + sizesArr[2];
@@ -618,6 +621,7 @@ protected:
{
ts->printf(cvtest::TS::LOG, "File with spambase dataset cann't be read.\n");
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
+ return;
}
Mat samples = data->getSamples();
diff --git a/modules/ml/test/test_lr.cpp b/modules/ml/test/test_lr.cpp
index 1bca905..130c155 100644
--- a/modules/ml/test/test_lr.cpp
+++ b/modules/ml/test/test_lr.cpp
@@ -64,6 +64,7 @@ using namespace cv::ml;
static bool calculateError( const Mat& _p_labels, const Mat& _o_labels, float& error)
{
+ CV_TRACE_FUNCTION();
error = 0.0f;
float accuracy = 0.0f;
Mat _p_labels_temp;
@@ -91,10 +92,16 @@ protected:
void CV_LRTest::run( int /*start_from*/ )
{
+ CV_TRACE_FUNCTION();
// initialize varibles from the popular Iris Dataset
string dataFileName = ts->get_data_path() + "iris.data";
Ptr<TrainData> tdata = TrainData::loadFromCSV(dataFileName, 0);
+ if (tdata.empty()) {
+ ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
+ return;
+ }
+
// run LR classifier train classifier
Ptr<LogisticRegression> p = LogisticRegression::create();
p->setLearningRate(1.0);
@@ -145,6 +152,7 @@ protected:
void CV_LRTest_SaveLoad::run( int /*start_from*/ )
{
+ CV_TRACE_FUNCTION();
int code = cvtest::TS::OK;
// initialize varibles from the popular Iris Dataset
diff --git a/modules/ml/test/test_mltests.cpp b/modules/ml/test/test_mltests.cpp
index 70cc0f7..5e863f6 100644
--- a/modules/ml/test/test_mltests.cpp
+++ b/modules/ml/test/test_mltests.cpp
@@ -51,6 +51,7 @@ CV_AMLTest::CV_AMLTest( const char* _modelName ) : CV_MLBaseTest( _modelName )
int CV_AMLTest::run_test_case( int testCaseIdx )
{
+ CV_TRACE_FUNCTION();
int code = cvtest::TS::OK;
code = prepare_test_case( testCaseIdx );
@@ -91,6 +92,7 @@ int CV_AMLTest::run_test_case( int testCaseIdx )
int CV_AMLTest::validate_test_results( int testCaseIdx )
{
+ CV_TRACE_FUNCTION();
int iters;
float mean, sigma;
// read validation params
@@ -172,4 +174,49 @@ TEST(ML_NBAYES, regression_5911)
EXPECT_EQ(sum(P1 == P3)[0], 255 * P3.total());
}
+TEST(ML_RTrees, getVotes)
+{
+ int n = 12;
+ int count, i;
+ int label_size = 3;
+ int predicted_class = 0;
+ int max_votes = -1;
+ int val;
+ // RTrees for classification
+ Ptr<ml::RTrees> rt = cv::ml::RTrees::create();
+
+ //data
+ Mat data(n, 4, CV_32F);
+ randu(data, 0, 10);
+
+ //labels
+ Mat labels = (Mat_<int>(n,1) << 0,0,0,0, 1,1,1,1, 2,2,2,2);
+
+ rt->train(data, ml::ROW_SAMPLE, labels);
+
+ //run function
+ Mat test(1, 4, CV_32F);
+ Mat result;
+ randu(test, 0, 10);
+ rt->getVotes(test, result, 0);
+
+ //count vote amount and find highest vote
+ count = 0;
+ const int* result_row = result.ptr<int>(1);
+ for( i = 0; i < label_size; i++ )
+ {
+ val = result_row[i];
+ //predicted_class = max_votes < val? i;
+ if( max_votes < val )
+ {
+ max_votes = val;
+ predicted_class = i;
+ }
+ count += val;
+ }
+
+ EXPECT_EQ(count, (int)rt->getRoots().size());
+ EXPECT_EQ(result.at<float>(0, predicted_class), rt->predict(test));
+}
+
/* End of file. */
diff --git a/modules/ml/test/test_mltests2.cpp b/modules/ml/test/test_mltests2.cpp
index 15ae200..b823b84 100644
--- a/modules/ml/test/test_mltests2.cpp
+++ b/modules/ml/test/test_mltests2.cpp
@@ -87,6 +87,7 @@ int str_to_ann_train_method( String& str )
void ann_check_data( Ptr<TrainData> _data )
{
+ CV_TRACE_FUNCTION();
Mat values = _data->getSamples();
Mat var_idx = _data->getVarIdx();
int nvars = (int)var_idx.total();
@@ -99,6 +100,7 @@ void ann_check_data( Ptr<TrainData> _data )
// unroll the categorical responses to binary vectors
Mat ann_get_new_responses( Ptr<TrainData> _data, map<int, int>& cls_map )
{
+ CV_TRACE_FUNCTION();
Mat train_sidx = _data->getTrainSampleIdx();
int* train_sidx_ptr = train_sidx.ptr<int>();
Mat responses = _data->getResponses();
@@ -130,6 +132,7 @@ Mat ann_get_new_responses( Ptr<TrainData> _data, map<int, int>& cls_map )
float ann_calc_error( Ptr<StatModel> ann, Ptr<TrainData> _data, map<int, int>& cls_map, int type, vector<float> *resp_labels )
{
+ CV_TRACE_FUNCTION();
float err = 0;
Mat samples = _data->getSamples();
Mat responses = _data->getResponses();
@@ -241,6 +244,7 @@ CV_MLBaseTest::~CV_MLBaseTest()
int CV_MLBaseTest::read_params( CvFileStorage* __fs )
{
+ CV_TRACE_FUNCTION();
FileStorage _fs(__fs, false);
if( !_fs.isOpened() )
test_case_count = -1;
@@ -265,6 +269,7 @@ int CV_MLBaseTest::read_params( CvFileStorage* __fs )
void CV_MLBaseTest::run( int )
{
+ CV_TRACE_FUNCTION();
string filename = ts->get_data_path();
filename += get_validation_filename();
validationFS.open( filename, FileStorage::READ );
@@ -273,6 +278,7 @@ void CV_MLBaseTest::run( int )
int code = cvtest::TS::OK;
for (int i = 0; i < test_case_count; i++)
{
+ CV_TRACE_REGION("iteration");
int temp_code = run_test_case( i );
if (temp_code == cvtest::TS::OK)
temp_code = validate_test_results( i );
@@ -289,6 +295,7 @@ void CV_MLBaseTest::run( int )
int CV_MLBaseTest::prepare_test_case( int test_case_idx )
{
+ CV_TRACE_FUNCTION();
clear();
string dataPath = ts->get_data_path();
@@ -331,6 +338,7 @@ string& CV_MLBaseTest::get_validation_filename()
int CV_MLBaseTest::train( int testCaseIdx )
{
+ CV_TRACE_FUNCTION();
bool is_trained = false;
FileNode modelParamsNode =
validationFS.getFirstTopLevelNode()["validation"][modelName][dataSetNames[testCaseIdx]]["model_params"];
@@ -489,6 +497,7 @@ int CV_MLBaseTest::train( int testCaseIdx )
float CV_MLBaseTest::get_test_error( int /*testCaseIdx*/, vector<float> *resp )
{
+ CV_TRACE_FUNCTION();
int type = CV_TEST_ERROR;
float err = 0;
Mat _resp;
@@ -506,11 +515,13 @@ float CV_MLBaseTest::get_test_error( int /*testCaseIdx*/, vector<float> *resp )
void CV_MLBaseTest::save( const char* filename )
{
+ CV_TRACE_FUNCTION();
model->save( filename );
}
void CV_MLBaseTest::load( const char* filename )
{
+ CV_TRACE_FUNCTION();
if( modelName == CV_NBAYES )
model = Algorithm::load<NormalBayesClassifier>( filename );
else if( modelName == CV_KNEAREST )
diff --git a/modules/objdetect/CMakeLists.txt b/modules/objdetect/CMakeLists.txt
index d42e9e8..862d564 100644
--- a/modules/objdetect/CMakeLists.txt
+++ b/modules/objdetect/CMakeLists.txt
@@ -1,2 +1,2 @@
set(the_description "Object Detection")
-ocv_define_module(objdetect opencv_core opencv_imgproc opencv_ml OPTIONAL opencv_highgui WRAP java python)
+ocv_define_module(objdetect opencv_core opencv_imgproc WRAP java python)
diff --git a/modules/objdetect/include/opencv2/objdetect.hpp b/modules/objdetect/include/opencv2/objdetect.hpp
index cd444d2..0747d67 100644
--- a/modules/objdetect/include/opencv2/objdetect.hpp
+++ b/modules/objdetect/include/opencv2/objdetect.hpp
@@ -215,6 +215,8 @@ public:
virtual Ptr<MaskGenerator> getMaskGenerator() = 0;
};
+/** @example facedetect.cpp
+*/
/** @brief Cascade classifier class for object detection.
*/
class CV_EXPORTS_W CascadeClassifier
@@ -294,7 +296,21 @@ public:
Size maxSize=Size() );
/** @overload
- if `outputRejectLevels` is `true` returns `rejectLevels` and `levelWeights`
+ This function allows you to retrieve the final stage decision certainty of classification.
+ For this, one needs to set `outputRejectLevels` on true and provide the `rejectLevels` and `levelWeights` parameter.
+ For each resulting detection, `levelWeights` will then contain the certainty of classification at the final stage.
+ This value can then be used to separate strong from weaker classifications.
+
+ A code sample on how to use it efficiently can be found below:
+ @code
+ Mat img;
+ vector<double> weights;
+ vector<int> levels;
+ vector<Rect> detections;
+ CascadeClassifier model("/path/to/your/model.xml");
+ model.detectMultiScale(img, detections, levels, weights, 1.1, 3, 0, Size(), Size(), true);
+ cerr << "Detection " << detections[0] << " with weight " << weights[0] << endl;
+ @endcode
*/
CV_WRAP_AS(detectMultiScale3) void detectMultiScale( InputArray image,
CV_OUT std::vector<Rect>& objects,
@@ -334,6 +350,8 @@ struct DetectionROI
std::vector<double> confidences;
};
+/**@example peopledetect.cpp
+ */
struct CV_EXPORTS_W HOGDescriptor
{
public:
diff --git a/modules/objdetect/include/opencv2/objdetect/objdetect_c.h b/modules/objdetect/include/opencv2/objdetect/objdetect_c.h
index b3ee7f4..67dc2f4 100644
--- a/modules/objdetect/include/opencv2/objdetect/objdetect_c.h
+++ b/modules/objdetect/include/opencv2/objdetect/objdetect_c.h
@@ -69,6 +69,7 @@ extern "C" {
(((const CvHaarClassifierCascade*)(haar))->flags & CV_MAGIC_MASK)==CV_HAAR_MAGIC_VAL)
#define CV_HAAR_FEATURE_MAX 3
+#define CV_HAAR_STAGE_MAX 1000
typedef struct CvHaarFeature
{
diff --git a/modules/objdetect/src/cascadedetect.cpp b/modules/objdetect/src/cascadedetect.cpp
index 1670ddf..76011bd 100644
--- a/modules/objdetect/src/cascadedetect.cpp
+++ b/modules/objdetect/src/cascadedetect.cpp
@@ -316,7 +316,7 @@ protected:
}
};
//new grouping function with using meanshift
-static void groupRectangles_meanshift(std::vector<Rect>& rectList, double detectThreshold, std::vector<double>* foundWeights,
+static void groupRectangles_meanshift(std::vector<Rect>& rectList, double detectThreshold, std::vector<double>& foundWeights,
std::vector<double>& scales, Size winDetSize)
{
int detectionCount = (int)rectList.size();
@@ -326,14 +326,13 @@ static void groupRectangles_meanshift(std::vector<Rect>& rectList, double detect
for (int i=0; i < detectionCount; i++)
{
- hitWeights[i] = (*foundWeights)[i];
+ hitWeights[i] = foundWeights[i];
hitCenter = (rectList[i].tl() + rectList[i].br())*(0.5); //center of rectangles
hits[i] = Point3d(hitCenter.x, hitCenter.y, std::log(scales[i]));
}
rectList.clear();
- if (foundWeights)
- foundWeights->clear();
+ foundWeights.clear();
double logZ = std::log(1.3);
Point3d smothing(8, 16, logZ);
@@ -355,7 +354,7 @@ static void groupRectangles_meanshift(std::vector<Rect>& rectList, double detect
if (resultWeights[i] > detectThreshold)
{
rectList.push_back(resultRect);
- foundWeights->push_back(resultWeights[i]);
+ foundWeights.push_back(resultWeights[i]);
}
}
}
@@ -387,7 +386,7 @@ void groupRectangles_meanshift(std::vector<Rect>& rectList, std::vector<double>&
{
CV_INSTRUMENT_REGION()
- groupRectangles_meanshift(rectList, detectThreshold, &foundWeights, foundScales, winDetSize);
+ groupRectangles_meanshift(rectList, detectThreshold, foundWeights, foundScales, winDetSize);
}
@@ -484,6 +483,8 @@ bool FeatureEvaluator::updateScaleData( Size imgsz, const std::vector<float>& _s
bool FeatureEvaluator::setImage( InputArray _image, const std::vector<float>& _scales )
{
+ CV_INSTRUMENT_REGION()
+
Size imgsz = _image.size();
bool recalcOptFeatures = updateScaleData(imgsz, _scales);
@@ -567,6 +568,9 @@ HaarEvaluator::HaarEvaluator()
lbufSize = Size(0, 0);
nchannels = 0;
tofs = 0;
+ sqofs = 0;
+ varianceNormFactor = 0;
+ hasTiltedFeatures = false;
}
HaarEvaluator::~HaarEvaluator()
@@ -628,6 +632,8 @@ Ptr<FeatureEvaluator> HaarEvaluator::clone() const
void HaarEvaluator::computeChannels(int scaleIdx, InputArray img)
{
+ CV_INSTRUMENT_REGION()
+
const ScaleData& s = scaleData->at(scaleIdx);
sqofs = hasTiltedFeatures ? sbufSize.area() * 2 : sbufSize.area();
@@ -670,6 +676,8 @@ void HaarEvaluator::computeChannels(int scaleIdx, InputArray img)
void HaarEvaluator::computeOptFeatures()
{
+ CV_INSTRUMENT_REGION()
+
if (hasTiltedFeatures)
tofs = sbufSize.area();
@@ -764,6 +772,8 @@ LBPEvaluator::LBPEvaluator()
features = makePtr<std::vector<Feature> >();
optfeatures = makePtr<std::vector<OptFeature> >();
scaleData = makePtr<std::vector<ScaleData> >();
+ optfeaturesPtr = 0;
+ pwin = 0;
}
LBPEvaluator::~LBPEvaluator()
@@ -879,6 +889,9 @@ Ptr<FeatureEvaluator> FeatureEvaluator::create( int featureType )
CascadeClassifierImpl::CascadeClassifierImpl()
{
+#ifdef HAVE_OPENCL
+ tryOpenCL = false;
+#endif
}
CascadeClassifierImpl::~CascadeClassifierImpl()
@@ -916,6 +929,8 @@ void CascadeClassifierImpl::read(const FileNode& node)
int CascadeClassifierImpl::runAt( Ptr<FeatureEvaluator>& evaluator, Point pt, int scaleIdx, double& weight )
{
+ CV_INSTRUMENT_REGION()
+
assert( !oldCascade &&
(data.featureType == FeatureEvaluator::HAAR ||
data.featureType == FeatureEvaluator::LBP ||
@@ -984,6 +999,8 @@ public:
void operator()(const Range& range) const
{
+ CV_INSTRUMENT_REGION()
+
Ptr<FeatureEvaluator> evaluator = classifier->featureEvaluator->clone();
double gypWeight = 0.;
Size origWinSize = classifier->data.origWinSize;
@@ -1430,7 +1447,7 @@ void CascadeClassifierImpl::detectMultiScale( InputArray _image, std::vector<Rec
CascadeClassifierImpl::Data::Data()
{
- stageType = featureType = ncategories = maxNodesPerTree = 0;
+ stageType = featureType = ncategories = maxNodesPerTree = minNodesPerTree = 0;
}
bool CascadeClassifierImpl::Data::read(const FileNode &root)
diff --git a/modules/objdetect/src/cascadedetect.hpp b/modules/objdetect/src/cascadedetect.hpp
index a395428..af0aaee 100644
--- a/modules/objdetect/src/cascadedetect.hpp
+++ b/modules/objdetect/src/cascadedetect.hpp
@@ -184,7 +184,7 @@ protected:
struct Stump
{
- Stump() { }
+ Stump() : featureIdx(0), threshold(0), left(0), right(0) { }
Stump(int _featureIdx, float _threshold, float _left, float _right)
: featureIdx(_featureIdx), threshold(_threshold), left(_left), right(_right) {}
@@ -489,6 +489,8 @@ template<class FEval>
inline int predictOrdered( CascadeClassifierImpl& cascade,
Ptr<FeatureEvaluator> &_featureEvaluator, double& sum )
{
+ CV_INSTRUMENT_REGION()
+
int nstages = (int)cascade.data.stages.size();
int nodeOfs = 0, leafOfs = 0;
FEval& featureEvaluator = (FEval&)*_featureEvaluator;
@@ -529,6 +531,8 @@ template<class FEval>
inline int predictCategorical( CascadeClassifierImpl& cascade,
Ptr<FeatureEvaluator> &_featureEvaluator, double& sum )
{
+ CV_INSTRUMENT_REGION()
+
int nstages = (int)cascade.data.stages.size();
int nodeOfs = 0, leafOfs = 0;
FEval& featureEvaluator = (FEval&)*_featureEvaluator;
@@ -571,6 +575,8 @@ template<class FEval>
inline int predictOrderedStump( CascadeClassifierImpl& cascade,
Ptr<FeatureEvaluator> &_featureEvaluator, double& sum )
{
+ CV_INSTRUMENT_REGION()
+
CV_Assert(!cascade.data.stumps.empty());
FEval& featureEvaluator = (FEval&)*_featureEvaluator;
const CascadeClassifierImpl::Data::Stump* cascadeStumps = &cascade.data.stumps[0];
@@ -608,6 +614,8 @@ template<class FEval>
inline int predictCategoricalStump( CascadeClassifierImpl& cascade,
Ptr<FeatureEvaluator> &_featureEvaluator, double& sum )
{
+ CV_INSTRUMENT_REGION()
+
CV_Assert(!cascade.data.stumps.empty());
int nstages = (int)cascade.data.stages.size();
FEval& featureEvaluator = (FEval&)*_featureEvaluator;
diff --git a/modules/objdetect/src/detection_based_tracker.cpp b/modules/objdetect/src/detection_based_tracker.cpp
index 88c7923..8583e50 100644
--- a/modules/objdetect/src/detection_based_tracker.cpp
+++ b/modules/objdetect/src/detection_based_tracker.cpp
@@ -48,7 +48,7 @@
#define USE_STD_THREADS
#endif
-#if defined(__linux__) || defined(LINUX) || defined(__APPLE__) || defined(ANDROID) || defined(USE_STD_THREADS)
+#if defined(__linux__) || defined(LINUX) || defined(__APPLE__) || defined(__ANDROID__) || defined(USE_STD_THREADS)
#include "opencv2/core/utility.hpp"
@@ -69,7 +69,7 @@
#define DEBUGLOGS 0
#endif
-#ifdef ANDROID
+#ifdef __ANDROID__
#include <android/log.h>
#define LOG_TAG "OBJECT_DETECTOR"
#define LOGD0(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
@@ -218,6 +218,7 @@ cv::DetectionBasedTracker::SeparateDetectionWork::SeparateDetectionWork(Detectio
cascadeInThread = _detector;
#ifndef USE_STD_THREADS
+ second_workthread = 0;
int res=0;
res=pthread_mutex_init(&mutex, NULL);//TODO: should be attributes?
if (res) {
@@ -609,7 +610,8 @@ cv::DetectionBasedTracker::DetectionBasedTracker(cv::Ptr<IDetector> mainDetector
&& trackingDetector );
if (mainDetector) {
- separateDetectionWork.reset(new SeparateDetectionWork(*this, mainDetector, params));
+ Ptr<SeparateDetectionWork> tmp(new SeparateDetectionWork(*this, mainDetector, params));
+ separateDetectionWork.swap(tmp);
}
weightsPositionsSmoothing.push_back(1);
diff --git a/modules/objdetect/src/haar.avx.cpp b/modules/objdetect/src/haar.avx.cpp
new file mode 100644
index 0000000..23dddfa
--- /dev/null
+++ b/modules/objdetect/src/haar.avx.cpp
@@ -0,0 +1,369 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// Intel License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of Intel Corporation may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+/* Haar features calculation */
+
+#include "precomp.hpp"
+#include "haar.hpp"
+
+namespace cv_haar_avx
+{
+
+// AVX version icvEvalHidHaarClassifier. Process 8 CvHidHaarClassifiers per call. Check AVX support before invocation!!
+#if CV_HAAR_USE_AVX
+double icvEvalHidHaarClassifierAVX(CvHidHaarClassifier* classifier,
+ double variance_norm_factor, size_t p_offset)
+{
+ int CV_DECL_ALIGNED(32) idxV[8] = { 0,0,0,0,0,0,0,0 };
+ uchar flags[8] = { 0,0,0,0,0,0,0,0 };
+ CvHidHaarTreeNode* nodes[8];
+ double res = 0;
+ uchar exitConditionFlag = 0;
+ for (;;)
+ {
+ float CV_DECL_ALIGNED(32) tmp[8] = { 0,0,0,0,0,0,0,0 };
+ nodes[0] = (classifier + 0)->node + idxV[0];
+ nodes[1] = (classifier + 1)->node + idxV[1];
+ nodes[2] = (classifier + 2)->node + idxV[2];
+ nodes[3] = (classifier + 3)->node + idxV[3];
+ nodes[4] = (classifier + 4)->node + idxV[4];
+ nodes[5] = (classifier + 5)->node + idxV[5];
+ nodes[6] = (classifier + 6)->node + idxV[6];
+ nodes[7] = (classifier + 7)->node + idxV[7];
+
+ __m256 t = _mm256_set1_ps(static_cast<float>(variance_norm_factor));
+
+ t = _mm256_mul_ps(t, _mm256_set_ps(nodes[7]->threshold,
+ nodes[6]->threshold,
+ nodes[5]->threshold,
+ nodes[4]->threshold,
+ nodes[3]->threshold,
+ nodes[2]->threshold,
+ nodes[1]->threshold,
+ nodes[0]->threshold));
+
+ __m256 offset = _mm256_set_ps(calc_sumf(nodes[7]->feature.rect[0], p_offset),
+ calc_sumf(nodes[6]->feature.rect[0], p_offset),
+ calc_sumf(nodes[5]->feature.rect[0], p_offset),
+ calc_sumf(nodes[4]->feature.rect[0], p_offset),
+ calc_sumf(nodes[3]->feature.rect[0], p_offset),
+ calc_sumf(nodes[2]->feature.rect[0], p_offset),
+ calc_sumf(nodes[1]->feature.rect[0], p_offset),
+ calc_sumf(nodes[0]->feature.rect[0], p_offset));
+
+ __m256 weight = _mm256_set_ps(nodes[7]->feature.rect[0].weight,
+ nodes[6]->feature.rect[0].weight,
+ nodes[5]->feature.rect[0].weight,
+ nodes[4]->feature.rect[0].weight,
+ nodes[3]->feature.rect[0].weight,
+ nodes[2]->feature.rect[0].weight,
+ nodes[1]->feature.rect[0].weight,
+ nodes[0]->feature.rect[0].weight);
+
+ __m256 sum = _mm256_mul_ps(offset, weight);
+
+ offset = _mm256_set_ps(calc_sumf(nodes[7]->feature.rect[1], p_offset),
+ calc_sumf(nodes[6]->feature.rect[1], p_offset),
+ calc_sumf(nodes[5]->feature.rect[1], p_offset),
+ calc_sumf(nodes[4]->feature.rect[1], p_offset),
+ calc_sumf(nodes[3]->feature.rect[1], p_offset),
+ calc_sumf(nodes[2]->feature.rect[1], p_offset),
+ calc_sumf(nodes[1]->feature.rect[1], p_offset),
+ calc_sumf(nodes[0]->feature.rect[1], p_offset));
+
+ weight = _mm256_set_ps(nodes[7]->feature.rect[1].weight,
+ nodes[6]->feature.rect[1].weight,
+ nodes[5]->feature.rect[1].weight,
+ nodes[4]->feature.rect[1].weight,
+ nodes[3]->feature.rect[1].weight,
+ nodes[2]->feature.rect[1].weight,
+ nodes[1]->feature.rect[1].weight,
+ nodes[0]->feature.rect[1].weight);
+
+ sum = _mm256_add_ps(sum, _mm256_mul_ps(offset, weight));
+
+ if (nodes[0]->feature.rect[2].p0)
+ tmp[0] = calc_sumf(nodes[0]->feature.rect[2], p_offset) * nodes[0]->feature.rect[2].weight;
+ if (nodes[1]->feature.rect[2].p0)
+ tmp[1] = calc_sumf(nodes[1]->feature.rect[2], p_offset) * nodes[1]->feature.rect[2].weight;
+ if (nodes[2]->feature.rect[2].p0)
+ tmp[2] = calc_sumf(nodes[2]->feature.rect[2], p_offset) * nodes[2]->feature.rect[2].weight;
+ if (nodes[3]->feature.rect[2].p0)
+ tmp[3] = calc_sumf(nodes[3]->feature.rect[2], p_offset) * nodes[3]->feature.rect[2].weight;
+ if (nodes[4]->feature.rect[2].p0)
+ tmp[4] = calc_sumf(nodes[4]->feature.rect[2], p_offset) * nodes[4]->feature.rect[2].weight;
+ if (nodes[5]->feature.rect[2].p0)
+ tmp[5] = calc_sumf(nodes[5]->feature.rect[2], p_offset) * nodes[5]->feature.rect[2].weight;
+ if (nodes[6]->feature.rect[2].p0)
+ tmp[6] = calc_sumf(nodes[6]->feature.rect[2], p_offset) * nodes[6]->feature.rect[2].weight;
+ if (nodes[7]->feature.rect[2].p0)
+ tmp[7] = calc_sumf(nodes[7]->feature.rect[2], p_offset) * nodes[7]->feature.rect[2].weight;
+
+ sum = _mm256_add_ps(sum, _mm256_load_ps(tmp));
+
+ __m256 left = _mm256_set_ps(static_cast<float>(nodes[7]->left), static_cast<float>(nodes[6]->left),
+ static_cast<float>(nodes[5]->left), static_cast<float>(nodes[4]->left),
+ static_cast<float>(nodes[3]->left), static_cast<float>(nodes[2]->left),
+ static_cast<float>(nodes[1]->left), static_cast<float>(nodes[0]->left));
+ __m256 right = _mm256_set_ps(static_cast<float>(nodes[7]->right), static_cast<float>(nodes[6]->right),
+ static_cast<float>(nodes[5]->right), static_cast<float>(nodes[4]->right),
+ static_cast<float>(nodes[3]->right), static_cast<float>(nodes[2]->right),
+ static_cast<float>(nodes[1]->right), static_cast<float>(nodes[0]->right));
+
+ _mm256_store_si256((__m256i*)idxV, _mm256_cvttps_epi32(_mm256_blendv_ps(right, left, _mm256_cmp_ps(sum, t, _CMP_LT_OQ))));
+
+ for (int i = 0; i < 8; i++)
+ {
+ if (idxV[i] <= 0)
+ {
+ if (!flags[i])
+ {
+ exitConditionFlag++;
+ flags[i] = 1;
+ res += (classifier + i)->alpha[-idxV[i]];
+ }
+ idxV[i] = 0;
+ }
+ }
+ if (exitConditionFlag == 8)
+ return res;
+ }
+}
+
+double icvEvalHidHaarStumpClassifierAVX(CvHidHaarClassifier* classifier,
+ double variance_norm_factor, size_t p_offset)
+{
+ float CV_DECL_ALIGNED(32) tmp[8] = { 0,0,0,0,0,0,0,0 };
+ CvHidHaarTreeNode* nodes[8];
+
+ nodes[0] = classifier[0].node;
+ nodes[1] = classifier[1].node;
+ nodes[2] = classifier[2].node;
+ nodes[3] = classifier[3].node;
+ nodes[4] = classifier[4].node;
+ nodes[5] = classifier[5].node;
+ nodes[6] = classifier[6].node;
+ nodes[7] = classifier[7].node;
+
+ __m256 t = _mm256_set1_ps(static_cast<float>(variance_norm_factor));
+
+ t = _mm256_mul_ps(t, _mm256_set_ps(nodes[7]->threshold,
+ nodes[6]->threshold,
+ nodes[5]->threshold,
+ nodes[4]->threshold,
+ nodes[3]->threshold,
+ nodes[2]->threshold,
+ nodes[1]->threshold,
+ nodes[0]->threshold));
+
+ __m256 offset = _mm256_set_ps(calc_sumf(nodes[7]->feature.rect[0], p_offset),
+ calc_sumf(nodes[6]->feature.rect[0], p_offset),
+ calc_sumf(nodes[5]->feature.rect[0], p_offset),
+ calc_sumf(nodes[4]->feature.rect[0], p_offset),
+ calc_sumf(nodes[3]->feature.rect[0], p_offset),
+ calc_sumf(nodes[2]->feature.rect[0], p_offset),
+ calc_sumf(nodes[1]->feature.rect[0], p_offset),
+ calc_sumf(nodes[0]->feature.rect[0], p_offset));
+
+ __m256 weight = _mm256_set_ps(nodes[7]->feature.rect[0].weight,
+ nodes[6]->feature.rect[0].weight,
+ nodes[5]->feature.rect[0].weight,
+ nodes[4]->feature.rect[0].weight,
+ nodes[3]->feature.rect[0].weight,
+ nodes[2]->feature.rect[0].weight,
+ nodes[1]->feature.rect[0].weight,
+ nodes[0]->feature.rect[0].weight);
+
+ __m256 sum = _mm256_mul_ps(offset, weight);
+
+ offset = _mm256_set_ps(calc_sumf(nodes[7]->feature.rect[1], p_offset),
+ calc_sumf(nodes[6]->feature.rect[1], p_offset),
+ calc_sumf(nodes[5]->feature.rect[1], p_offset),
+ calc_sumf(nodes[4]->feature.rect[1], p_offset),
+ calc_sumf(nodes[3]->feature.rect[1], p_offset),
+ calc_sumf(nodes[2]->feature.rect[1], p_offset),
+ calc_sumf(nodes[1]->feature.rect[1], p_offset),
+ calc_sumf(nodes[0]->feature.rect[1], p_offset));
+
+ weight = _mm256_set_ps(nodes[7]->feature.rect[1].weight,
+ nodes[6]->feature.rect[1].weight,
+ nodes[5]->feature.rect[1].weight,
+ nodes[4]->feature.rect[1].weight,
+ nodes[3]->feature.rect[1].weight,
+ nodes[2]->feature.rect[1].weight,
+ nodes[1]->feature.rect[1].weight,
+ nodes[0]->feature.rect[1].weight);
+
+ sum = _mm256_add_ps(sum, _mm256_mul_ps(offset, weight));
+
+ if (nodes[0]->feature.rect[2].p0)
+ tmp[0] = calc_sumf(nodes[0]->feature.rect[2], p_offset) * nodes[0]->feature.rect[2].weight;
+ if (nodes[1]->feature.rect[2].p0)
+ tmp[1] = calc_sumf(nodes[1]->feature.rect[2], p_offset) * nodes[1]->feature.rect[2].weight;
+ if (nodes[2]->feature.rect[2].p0)
+ tmp[2] = calc_sumf(nodes[2]->feature.rect[2], p_offset) * nodes[2]->feature.rect[2].weight;
+ if (nodes[3]->feature.rect[2].p0)
+ tmp[3] = calc_sumf(nodes[3]->feature.rect[2], p_offset) * nodes[3]->feature.rect[2].weight;
+ if (nodes[4]->feature.rect[2].p0)
+ tmp[4] = calc_sumf(nodes[4]->feature.rect[2], p_offset) * nodes[4]->feature.rect[2].weight;
+ if (nodes[5]->feature.rect[2].p0)
+ tmp[5] = calc_sumf(nodes[5]->feature.rect[2], p_offset) * nodes[5]->feature.rect[2].weight;
+ if (nodes[6]->feature.rect[2].p0)
+ tmp[6] = calc_sumf(nodes[6]->feature.rect[2], p_offset) * nodes[6]->feature.rect[2].weight;
+ if (nodes[7]->feature.rect[2].p0)
+ tmp[7] = calc_sumf(nodes[7]->feature.rect[2], p_offset) * nodes[7]->feature.rect[2].weight;
+
+ sum = _mm256_add_ps(sum, _mm256_load_ps(tmp));
+
+ __m256 alpha0 = _mm256_set_ps(classifier[7].alpha[0],
+ classifier[6].alpha[0],
+ classifier[5].alpha[0],
+ classifier[4].alpha[0],
+ classifier[3].alpha[0],
+ classifier[2].alpha[0],
+ classifier[1].alpha[0],
+ classifier[0].alpha[0]);
+ __m256 alpha1 = _mm256_set_ps(classifier[7].alpha[1],
+ classifier[6].alpha[1],
+ classifier[5].alpha[1],
+ classifier[4].alpha[1],
+ classifier[3].alpha[1],
+ classifier[2].alpha[1],
+ classifier[1].alpha[1],
+ classifier[0].alpha[1]);
+
+ __m256 outBuf = _mm256_blendv_ps(alpha0, alpha1, _mm256_cmp_ps(t, sum, _CMP_LE_OQ));
+ outBuf = _mm256_hadd_ps(outBuf, outBuf);
+ outBuf = _mm256_hadd_ps(outBuf, outBuf);
+ _mm256_store_ps(tmp, outBuf);
+ return (tmp[0] + tmp[4]);
+}
+
+double icvEvalHidHaarStumpClassifierTwoRectAVX(CvHidHaarClassifier* classifier,
+ double variance_norm_factor, size_t p_offset)
+{
+ float CV_DECL_ALIGNED(32) buf[8];
+ CvHidHaarTreeNode* nodes[8];
+ nodes[0] = classifier[0].node;
+ nodes[1] = classifier[1].node;
+ nodes[2] = classifier[2].node;
+ nodes[3] = classifier[3].node;
+ nodes[4] = classifier[4].node;
+ nodes[5] = classifier[5].node;
+ nodes[6] = classifier[6].node;
+ nodes[7] = classifier[7].node;
+
+ __m256 t = _mm256_set1_ps(static_cast<float>(variance_norm_factor));
+ t = _mm256_mul_ps(t, _mm256_set_ps(nodes[7]->threshold,
+ nodes[6]->threshold,
+ nodes[5]->threshold,
+ nodes[4]->threshold,
+ nodes[3]->threshold,
+ nodes[2]->threshold,
+ nodes[1]->threshold,
+ nodes[0]->threshold));
+
+ __m256 offset = _mm256_set_ps(calc_sumf(nodes[7]->feature.rect[0], p_offset),
+ calc_sumf(nodes[6]->feature.rect[0], p_offset),
+ calc_sumf(nodes[5]->feature.rect[0], p_offset),
+ calc_sumf(nodes[4]->feature.rect[0], p_offset),
+ calc_sumf(nodes[3]->feature.rect[0], p_offset),
+ calc_sumf(nodes[2]->feature.rect[0], p_offset),
+ calc_sumf(nodes[1]->feature.rect[0], p_offset),
+ calc_sumf(nodes[0]->feature.rect[0], p_offset));
+
+ __m256 weight = _mm256_set_ps(nodes[7]->feature.rect[0].weight,
+ nodes[6]->feature.rect[0].weight,
+ nodes[5]->feature.rect[0].weight,
+ nodes[4]->feature.rect[0].weight,
+ nodes[3]->feature.rect[0].weight,
+ nodes[2]->feature.rect[0].weight,
+ nodes[1]->feature.rect[0].weight,
+ nodes[0]->feature.rect[0].weight);
+
+ __m256 sum = _mm256_mul_ps(offset, weight);
+
+ offset = _mm256_set_ps(calc_sumf(nodes[7]->feature.rect[1], p_offset),
+ calc_sumf(nodes[6]->feature.rect[1], p_offset),
+ calc_sumf(nodes[5]->feature.rect[1], p_offset),
+ calc_sumf(nodes[4]->feature.rect[1], p_offset),
+ calc_sumf(nodes[3]->feature.rect[1], p_offset),
+ calc_sumf(nodes[2]->feature.rect[1], p_offset),
+ calc_sumf(nodes[1]->feature.rect[1], p_offset),
+ calc_sumf(nodes[0]->feature.rect[1], p_offset));
+
+ weight = _mm256_set_ps(nodes[7]->feature.rect[1].weight,
+ nodes[6]->feature.rect[1].weight,
+ nodes[5]->feature.rect[1].weight,
+ nodes[4]->feature.rect[1].weight,
+ nodes[3]->feature.rect[1].weight,
+ nodes[2]->feature.rect[1].weight,
+ nodes[1]->feature.rect[1].weight,
+ nodes[0]->feature.rect[1].weight);
+
+ sum = _mm256_add_ps(sum, _mm256_mul_ps(offset, weight));
+
+ __m256 alpha0 = _mm256_set_ps(classifier[7].alpha[0],
+ classifier[6].alpha[0],
+ classifier[5].alpha[0],
+ classifier[4].alpha[0],
+ classifier[3].alpha[0],
+ classifier[2].alpha[0],
+ classifier[1].alpha[0],
+ classifier[0].alpha[0]);
+ __m256 alpha1 = _mm256_set_ps(classifier[7].alpha[1],
+ classifier[6].alpha[1],
+ classifier[5].alpha[1],
+ classifier[4].alpha[1],
+ classifier[3].alpha[1],
+ classifier[2].alpha[1],
+ classifier[1].alpha[1],
+ classifier[0].alpha[1]);
+
+ _mm256_store_ps(buf, _mm256_blendv_ps(alpha0, alpha1, _mm256_cmp_ps(t, sum, _CMP_LE_OQ)));
+ return (buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6] + buf[7]);
+}
+
+#endif //CV_HAAR_USE_AVX
+
+}
+
+/* End of file. */
diff --git a/modules/objdetect/src/haar.cpp b/modules/objdetect/src/haar.cpp
index 51843fa..eea71c4 100644
--- a/modules/objdetect/src/haar.cpp
+++ b/modules/objdetect/src/haar.cpp
@@ -45,6 +45,10 @@
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/objdetect/objdetect_c.h"
#include <stdio.h>
+#include "haar.hpp"
+#if CV_HAAR_FEATURE_MAX_LOCAL != CV_HAAR_FEATURE_MAX
+ #error CV_HAAR_FEATURE_MAX definition changed. Adjust CV_HAAR_FEATURE_MAX_LOCAL value please.
+#endif
#if CV_SSE2
# if 1 /*!CV_SSE4_1 && !CV_SSE4_2*/
@@ -53,8 +57,7 @@
# endif
#endif
-#if 0 /*CV_AVX*/
-# define CV_HAAR_USE_AVX 1
+#if CV_HAAR_USE_AVX
# if defined _MSC_VER
# pragma warning( disable : 4752 )
# endif
@@ -68,38 +71,6 @@
#define CV_ADJUST_FEATURES 1
#define CV_ADJUST_WEIGHTS 0
-typedef int sumtype;
-typedef double sqsumtype;
-
-typedef struct CvHidHaarFeature
-{
- struct
- {
- sumtype *p0, *p1, *p2, *p3;
- float weight;
- }
- rect[CV_HAAR_FEATURE_MAX];
-} CvHidHaarFeature;
-
-
-typedef struct CvHidHaarTreeNode
-{
- CvHidHaarFeature feature;
- float threshold;
- int left;
- int right;
-} CvHidHaarTreeNode;
-
-
-typedef struct CvHidHaarClassifier
-{
- int count;
- //CvHaarFeature* orig_feature;
- CvHidHaarTreeNode* node;
- float* alpha;
-} CvHidHaarClassifier;
-
-
typedef struct CvHidHaarStageClassifier
{
int count;
@@ -340,8 +311,8 @@ icvCreateHidHaarClassifierCascade( CvHaarClassifierCascade* cascade )
out->isStumpBased &= node_count == 1;
}
}
-/*
-#ifdef HAVE_IPP
+
+#if defined HAVE_IPP && !IPP_DISABLE_HAAR
int can_use_ipp = CV_IPP_CHECK_COND && (!out->has_tilted_features && !out->is_tree && out->isStumpBased);
if( can_use_ipp )
@@ -396,7 +367,7 @@ icvCreateHidHaarClassifierCascade( CvHaarClassifierCascade* cascade )
}
}
#endif
-*/
+
cascade->hid_cascade = out;
assert( (char*)haar_node_ptr - (char*)out <= datasize );
@@ -420,10 +391,6 @@ icvCreateHidHaarClassifierCascade( CvHaarClassifierCascade* cascade )
#define calc_sum(rect,offset) \
((rect).p0[offset] - (rect).p1[offset] - (rect).p2[offset] + (rect).p3[offset])
-#define calc_sumf(rect,offset) \
- static_cast<float>((rect).p0[offset] - (rect).p1[offset] - (rect).p2[offset] + (rect).p3[offset])
-
-
CV_IMPL void
cvSetImagesForHaarClassifierCascade( CvHaarClassifierCascade* _cascade,
const CvArr* _sum,
@@ -640,129 +607,6 @@ cvSetImagesForHaarClassifierCascade( CvHaarClassifierCascade* _cascade,
}
-// AVX version icvEvalHidHaarClassifier. Process 8 CvHidHaarClassifiers per call. Check AVX support before invocation!!
-#ifdef CV_HAAR_USE_AVX
-CV_INLINE
-double icvEvalHidHaarClassifierAVX( CvHidHaarClassifier* classifier,
- double variance_norm_factor, size_t p_offset )
-{
- int CV_DECL_ALIGNED(32) idxV[8] = {0,0,0,0,0,0,0,0};
- uchar flags[8] = {0,0,0,0,0,0,0,0};
- CvHidHaarTreeNode* nodes[8];
- double res = 0;
- uchar exitConditionFlag = 0;
- for(;;)
- {
- float CV_DECL_ALIGNED(32) tmp[8] = {0,0,0,0,0,0,0,0};
- nodes[0] = (classifier+0)->node + idxV[0];
- nodes[1] = (classifier+1)->node + idxV[1];
- nodes[2] = (classifier+2)->node + idxV[2];
- nodes[3] = (classifier+3)->node + idxV[3];
- nodes[4] = (classifier+4)->node + idxV[4];
- nodes[5] = (classifier+5)->node + idxV[5];
- nodes[6] = (classifier+6)->node + idxV[6];
- nodes[7] = (classifier+7)->node + idxV[7];
-
- __m256 t = _mm256_set1_ps(static_cast<float>(variance_norm_factor));
-
- t = _mm256_mul_ps(t, _mm256_set_ps(nodes[7]->threshold,
- nodes[6]->threshold,
- nodes[5]->threshold,
- nodes[4]->threshold,
- nodes[3]->threshold,
- nodes[2]->threshold,
- nodes[1]->threshold,
- nodes[0]->threshold));
-
- __m256 offset = _mm256_set_ps(calc_sumf(nodes[7]->feature.rect[0], p_offset),
- calc_sumf(nodes[6]->feature.rect[0], p_offset),
- calc_sumf(nodes[5]->feature.rect[0], p_offset),
- calc_sumf(nodes[4]->feature.rect[0], p_offset),
- calc_sumf(nodes[3]->feature.rect[0], p_offset),
- calc_sumf(nodes[2]->feature.rect[0], p_offset),
- calc_sumf(nodes[1]->feature.rect[0], p_offset),
- calc_sumf(nodes[0]->feature.rect[0], p_offset));
-
- __m256 weight = _mm256_set_ps(nodes[7]->feature.rect[0].weight,
- nodes[6]->feature.rect[0].weight,
- nodes[5]->feature.rect[0].weight,
- nodes[4]->feature.rect[0].weight,
- nodes[3]->feature.rect[0].weight,
- nodes[2]->feature.rect[0].weight,
- nodes[1]->feature.rect[0].weight,
- nodes[0]->feature.rect[0].weight);
-
- __m256 sum = _mm256_mul_ps(offset, weight);
-
- offset = _mm256_set_ps(calc_sumf(nodes[7]->feature.rect[1], p_offset),
- calc_sumf(nodes[6]->feature.rect[1], p_offset),
- calc_sumf(nodes[5]->feature.rect[1], p_offset),
- calc_sumf(nodes[4]->feature.rect[1], p_offset),
- calc_sumf(nodes[3]->feature.rect[1], p_offset),
- calc_sumf(nodes[2]->feature.rect[1], p_offset),
- calc_sumf(nodes[1]->feature.rect[1], p_offset),
- calc_sumf(nodes[0]->feature.rect[1], p_offset));
-
- weight = _mm256_set_ps(nodes[7]->feature.rect[1].weight,
- nodes[6]->feature.rect[1].weight,
- nodes[5]->feature.rect[1].weight,
- nodes[4]->feature.rect[1].weight,
- nodes[3]->feature.rect[1].weight,
- nodes[2]->feature.rect[1].weight,
- nodes[1]->feature.rect[1].weight,
- nodes[0]->feature.rect[1].weight);
-
- sum = _mm256_add_ps(sum, _mm256_mul_ps(offset, weight));
-
- if( nodes[0]->feature.rect[2].p0 )
- tmp[0] = calc_sumf(nodes[0]->feature.rect[2], p_offset) * nodes[0]->feature.rect[2].weight;
- if( nodes[1]->feature.rect[2].p0 )
- tmp[1] = calc_sumf(nodes[1]->feature.rect[2], p_offset) * nodes[1]->feature.rect[2].weight;
- if( nodes[2]->feature.rect[2].p0 )
- tmp[2] = calc_sumf(nodes[2]->feature.rect[2], p_offset) * nodes[2]->feature.rect[2].weight;
- if( nodes[3]->feature.rect[2].p0 )
- tmp[3] = calc_sumf(nodes[3]->feature.rect[2], p_offset) * nodes[3]->feature.rect[2].weight;
- if( nodes[4]->feature.rect[2].p0 )
- tmp[4] = calc_sumf(nodes[4]->feature.rect[2], p_offset) * nodes[4]->feature.rect[2].weight;
- if( nodes[5]->feature.rect[2].p0 )
- tmp[5] = calc_sumf(nodes[5]->feature.rect[2], p_offset) * nodes[5]->feature.rect[2].weight;
- if( nodes[6]->feature.rect[2].p0 )
- tmp[6] = calc_sumf(nodes[6]->feature.rect[2], p_offset) * nodes[6]->feature.rect[2].weight;
- if( nodes[7]->feature.rect[2].p0 )
- tmp[7] = calc_sumf(nodes[7]->feature.rect[2], p_offset) * nodes[7]->feature.rect[2].weight;
-
- sum = _mm256_add_ps(sum,_mm256_load_ps(tmp));
-
- __m256 left = _mm256_set_ps(static_cast<float>(nodes[7]->left), static_cast<float>(nodes[6]->left),
- static_cast<float>(nodes[5]->left), static_cast<float>(nodes[4]->left),
- static_cast<float>(nodes[3]->left), static_cast<float>(nodes[2]->left),
- static_cast<float>(nodes[1]->left), static_cast<float>(nodes[0]->left));
- __m256 right = _mm256_set_ps(static_cast<float>(nodes[7]->right),static_cast<float>(nodes[6]->right),
- static_cast<float>(nodes[5]->right),static_cast<float>(nodes[4]->right),
- static_cast<float>(nodes[3]->right),static_cast<float>(nodes[2]->right),
- static_cast<float>(nodes[1]->right),static_cast<float>(nodes[0]->right));
-
- _mm256_store_si256((__m256i*)idxV, _mm256_cvttps_epi32(_mm256_blendv_ps(right, left, _mm256_cmp_ps(sum, t, _CMP_LT_OQ))));
-
- for(int i = 0; i < 8; i++)
- {
- if(idxV[i]<=0)
- {
- if(!flags[i])
- {
- exitConditionFlag++;
- flags[i] = 1;
- res += (classifier+i)->alpha[-idxV[i]];
- }
- idxV[i]=0;
- }
- }
- if(exitConditionFlag == 8)
- return res;
- }
-}
-#endif //CV_HAAR_USE_AVX
-
CV_INLINE
double icvEvalHidHaarClassifier( CvHidHaarClassifier* classifier,
double variance_norm_factor,
@@ -823,11 +667,8 @@ static int
cvRunHaarClassifierCascadeSum( const CvHaarClassifierCascade* _cascade,
CvPoint pt, double& stage_sum, int start_stage )
{
-#ifdef CV_HAAR_USE_AVX
- bool haveAVX = false;
- if(cv::checkHardwareSupport(CV_CPU_AVX))
- if(__xgetbv()&0x6)// Check if the OS will save the YMM registers
- haveAVX = true;
+#if CV_HAAR_USE_AVX
+ bool haveAVX = CV_CPU_HAS_SUPPORT_AVX;
#else
# ifdef CV_HAAR_USE_SSE
bool haveSSE2 = cv::checkHardwareSupport(CV_CPU_SSE2);
@@ -873,14 +714,14 @@ cvRunHaarClassifierCascadeSum( const CvHaarClassifierCascade* _cascade,
stage_sum = 0.0;
j = 0;
-#ifdef CV_HAAR_USE_AVX
+#if CV_HAAR_USE_AVX
if(haveAVX)
{
for( ; j <= ptr->count - 8; j += 8 )
{
- stage_sum += icvEvalHidHaarClassifierAVX(
- ptr->classifier + j,
- variance_norm_factor, p_offset );
+ stage_sum += cv_haar_avx::icvEvalHidHaarClassifierAVX(
+ ptr->classifier + j,
+ variance_norm_factor, p_offset );
}
}
#endif
@@ -904,106 +745,20 @@ cvRunHaarClassifierCascadeSum( const CvHaarClassifierCascade* _cascade,
}
else if( cascade->isStumpBased )
{
-#ifdef CV_HAAR_USE_AVX
+#if CV_HAAR_USE_AVX
if(haveAVX)
{
- CvHidHaarClassifier* classifiers[8];
- CvHidHaarTreeNode* nodes[8];
for( i = start_stage; i < cascade->count; i++ )
{
stage_sum = 0.0;
j = 0;
- float CV_DECL_ALIGNED(32) buf[8];
if( cascade->stage_classifier[i].two_rects )
{
for( ; j <= cascade->stage_classifier[i].count - 8; j += 8 )
{
- classifiers[0] = cascade->stage_classifier[i].classifier + j;
- nodes[0] = classifiers[0]->node;
- classifiers[1] = cascade->stage_classifier[i].classifier + j + 1;
- nodes[1] = classifiers[1]->node;
- classifiers[2] = cascade->stage_classifier[i].classifier + j + 2;
- nodes[2] = classifiers[2]->node;
- classifiers[3] = cascade->stage_classifier[i].classifier + j + 3;
- nodes[3] = classifiers[3]->node;
- classifiers[4] = cascade->stage_classifier[i].classifier + j + 4;
- nodes[4] = classifiers[4]->node;
- classifiers[5] = cascade->stage_classifier[i].classifier + j + 5;
- nodes[5] = classifiers[5]->node;
- classifiers[6] = cascade->stage_classifier[i].classifier + j + 6;
- nodes[6] = classifiers[6]->node;
- classifiers[7] = cascade->stage_classifier[i].classifier + j + 7;
- nodes[7] = classifiers[7]->node;
-
- __m256 t = _mm256_set1_ps(static_cast<float>(variance_norm_factor));
- t = _mm256_mul_ps(t, _mm256_set_ps(nodes[7]->threshold,
- nodes[6]->threshold,
- nodes[5]->threshold,
- nodes[4]->threshold,
- nodes[3]->threshold,
- nodes[2]->threshold,
- nodes[1]->threshold,
- nodes[0]->threshold));
-
- __m256 offset = _mm256_set_ps(calc_sumf(nodes[7]->feature.rect[0], p_offset),
- calc_sumf(nodes[6]->feature.rect[0], p_offset),
- calc_sumf(nodes[5]->feature.rect[0], p_offset),
- calc_sumf(nodes[4]->feature.rect[0], p_offset),
- calc_sumf(nodes[3]->feature.rect[0], p_offset),
- calc_sumf(nodes[2]->feature.rect[0], p_offset),
- calc_sumf(nodes[1]->feature.rect[0], p_offset),
- calc_sumf(nodes[0]->feature.rect[0], p_offset));
-
- __m256 weight = _mm256_set_ps(nodes[7]->feature.rect[0].weight,
- nodes[6]->feature.rect[0].weight,
- nodes[5]->feature.rect[0].weight,
- nodes[4]->feature.rect[0].weight,
- nodes[3]->feature.rect[0].weight,
- nodes[2]->feature.rect[0].weight,
- nodes[1]->feature.rect[0].weight,
- nodes[0]->feature.rect[0].weight);
-
- __m256 sum = _mm256_mul_ps(offset, weight);
-
- offset = _mm256_set_ps(calc_sumf(nodes[7]->feature.rect[1], p_offset),
- calc_sumf(nodes[6]->feature.rect[1], p_offset),
- calc_sumf(nodes[5]->feature.rect[1], p_offset),
- calc_sumf(nodes[4]->feature.rect[1], p_offset),
- calc_sumf(nodes[3]->feature.rect[1], p_offset),
- calc_sumf(nodes[2]->feature.rect[1], p_offset),
- calc_sumf(nodes[1]->feature.rect[1], p_offset),
- calc_sumf(nodes[0]->feature.rect[1], p_offset));
-
- weight = _mm256_set_ps(nodes[7]->feature.rect[1].weight,
- nodes[6]->feature.rect[1].weight,
- nodes[5]->feature.rect[1].weight,
- nodes[4]->feature.rect[1].weight,
- nodes[3]->feature.rect[1].weight,
- nodes[2]->feature.rect[1].weight,
- nodes[1]->feature.rect[1].weight,
- nodes[0]->feature.rect[1].weight);
-
- sum = _mm256_add_ps(sum, _mm256_mul_ps(offset,weight));
-
- __m256 alpha0 = _mm256_set_ps(classifiers[7]->alpha[0],
- classifiers[6]->alpha[0],
- classifiers[5]->alpha[0],
- classifiers[4]->alpha[0],
- classifiers[3]->alpha[0],
- classifiers[2]->alpha[0],
- classifiers[1]->alpha[0],
- classifiers[0]->alpha[0]);
- __m256 alpha1 = _mm256_set_ps(classifiers[7]->alpha[1],
- classifiers[6]->alpha[1],
- classifiers[5]->alpha[1],
- classifiers[4]->alpha[1],
- classifiers[3]->alpha[1],
- classifiers[2]->alpha[1],
- classifiers[1]->alpha[1],
- classifiers[0]->alpha[1]);
-
- _mm256_store_ps(buf, _mm256_blendv_ps(alpha0, alpha1, _mm256_cmp_ps(t, sum, _CMP_LE_OQ)));
- stage_sum += (buf[0]+buf[1]+buf[2]+buf[3]+buf[4]+buf[5]+buf[6]+buf[7]);
+ stage_sum += cv_haar_avx::icvEvalHidHaarStumpClassifierTwoRectAVX(
+ cascade->stage_classifier[i].classifier + j,
+ variance_norm_factor, p_offset);
}
for( ; j < cascade->stage_classifier[i].count; j++ )
@@ -1021,117 +776,9 @@ cvRunHaarClassifierCascadeSum( const CvHaarClassifierCascade* _cascade,
{
for( ; j <= (cascade->stage_classifier[i].count)-8; j+=8 )
{
- float CV_DECL_ALIGNED(32) tmp[8] = {0,0,0,0,0,0,0,0};
-
- classifiers[0] = cascade->stage_classifier[i].classifier + j;
- nodes[0] = classifiers[0]->node;
- classifiers[1] = cascade->stage_classifier[i].classifier + j + 1;
- nodes[1] = classifiers[1]->node;
- classifiers[2] = cascade->stage_classifier[i].classifier + j + 2;
- nodes[2] = classifiers[2]->node;
- classifiers[3] = cascade->stage_classifier[i].classifier + j + 3;
- nodes[3] = classifiers[3]->node;
- classifiers[4] = cascade->stage_classifier[i].classifier + j + 4;
- nodes[4] = classifiers[4]->node;
- classifiers[5] = cascade->stage_classifier[i].classifier + j + 5;
- nodes[5] = classifiers[5]->node;
- classifiers[6] = cascade->stage_classifier[i].classifier + j + 6;
- nodes[6] = classifiers[6]->node;
- classifiers[7] = cascade->stage_classifier[i].classifier + j + 7;
- nodes[7] = classifiers[7]->node;
-
- __m256 t = _mm256_set1_ps(static_cast<float>(variance_norm_factor));
-
- t = _mm256_mul_ps(t, _mm256_set_ps(nodes[7]->threshold,
- nodes[6]->threshold,
- nodes[5]->threshold,
- nodes[4]->threshold,
- nodes[3]->threshold,
- nodes[2]->threshold,
- nodes[1]->threshold,
- nodes[0]->threshold));
-
- __m256 offset = _mm256_set_ps(calc_sumf(nodes[7]->feature.rect[0], p_offset),
- calc_sumf(nodes[6]->feature.rect[0], p_offset),
- calc_sumf(nodes[5]->feature.rect[0], p_offset),
- calc_sumf(nodes[4]->feature.rect[0], p_offset),
- calc_sumf(nodes[3]->feature.rect[0], p_offset),
- calc_sumf(nodes[2]->feature.rect[0], p_offset),
- calc_sumf(nodes[1]->feature.rect[0], p_offset),
- calc_sumf(nodes[0]->feature.rect[0], p_offset));
-
- __m256 weight = _mm256_set_ps(nodes[7]->feature.rect[0].weight,
- nodes[6]->feature.rect[0].weight,
- nodes[5]->feature.rect[0].weight,
- nodes[4]->feature.rect[0].weight,
- nodes[3]->feature.rect[0].weight,
- nodes[2]->feature.rect[0].weight,
- nodes[1]->feature.rect[0].weight,
- nodes[0]->feature.rect[0].weight);
-
- __m256 sum = _mm256_mul_ps(offset, weight);
-
- offset = _mm256_set_ps(calc_sumf(nodes[7]->feature.rect[1], p_offset),
- calc_sumf(nodes[6]->feature.rect[1], p_offset),
- calc_sumf(nodes[5]->feature.rect[1], p_offset),
- calc_sumf(nodes[4]->feature.rect[1], p_offset),
- calc_sumf(nodes[3]->feature.rect[1], p_offset),
- calc_sumf(nodes[2]->feature.rect[1], p_offset),
- calc_sumf(nodes[1]->feature.rect[1], p_offset),
- calc_sumf(nodes[0]->feature.rect[1], p_offset));
-
- weight = _mm256_set_ps(nodes[7]->feature.rect[1].weight,
- nodes[6]->feature.rect[1].weight,
- nodes[5]->feature.rect[1].weight,
- nodes[4]->feature.rect[1].weight,
- nodes[3]->feature.rect[1].weight,
- nodes[2]->feature.rect[1].weight,
- nodes[1]->feature.rect[1].weight,
- nodes[0]->feature.rect[1].weight);
-
- sum = _mm256_add_ps(sum, _mm256_mul_ps(offset, weight));
-
- if( nodes[0]->feature.rect[2].p0 )
- tmp[0] = calc_sumf(nodes[0]->feature.rect[2],p_offset) * nodes[0]->feature.rect[2].weight;
- if( nodes[1]->feature.rect[2].p0 )
- tmp[1] = calc_sumf(nodes[1]->feature.rect[2],p_offset) * nodes[1]->feature.rect[2].weight;
- if( nodes[2]->feature.rect[2].p0 )
- tmp[2] = calc_sumf(nodes[2]->feature.rect[2],p_offset) * nodes[2]->feature.rect[2].weight;
- if( nodes[3]->feature.rect[2].p0 )
- tmp[3] = calc_sumf(nodes[3]->feature.rect[2],p_offset) * nodes[3]->feature.rect[2].weight;
- if( nodes[4]->feature.rect[2].p0 )
- tmp[4] = calc_sumf(nodes[4]->feature.rect[2],p_offset) * nodes[4]->feature.rect[2].weight;
- if( nodes[5]->feature.rect[2].p0 )
- tmp[5] = calc_sumf(nodes[5]->feature.rect[2],p_offset) * nodes[5]->feature.rect[2].weight;
- if( nodes[6]->feature.rect[2].p0 )
- tmp[6] = calc_sumf(nodes[6]->feature.rect[2],p_offset) * nodes[6]->feature.rect[2].weight;
- if( nodes[7]->feature.rect[2].p0 )
- tmp[7] = calc_sumf(nodes[7]->feature.rect[2],p_offset) * nodes[7]->feature.rect[2].weight;
-
- sum = _mm256_add_ps(sum, _mm256_load_ps(tmp));
-
- __m256 alpha0 = _mm256_set_ps(classifiers[7]->alpha[0],
- classifiers[6]->alpha[0],
- classifiers[5]->alpha[0],
- classifiers[4]->alpha[0],
- classifiers[3]->alpha[0],
- classifiers[2]->alpha[0],
- classifiers[1]->alpha[0],
- classifiers[0]->alpha[0]);
- __m256 alpha1 = _mm256_set_ps(classifiers[7]->alpha[1],
- classifiers[6]->alpha[1],
- classifiers[5]->alpha[1],
- classifiers[4]->alpha[1],
- classifiers[3]->alpha[1],
- classifiers[2]->alpha[1],
- classifiers[1]->alpha[1],
- classifiers[0]->alpha[1]);
-
- __m256 outBuf = _mm256_blendv_ps(alpha0, alpha1, _mm256_cmp_ps(t, sum, _CMP_LE_OQ ));
- outBuf = _mm256_hadd_ps(outBuf, outBuf);
- outBuf = _mm256_hadd_ps(outBuf, outBuf);
- _mm256_store_ps(buf, outBuf);
- stage_sum += (buf[0] + buf[4]);
+ stage_sum += cv_haar_avx::icvEvalHidHaarStumpClassifierAVX(
+ cascade->stage_classifier[i].classifier + j,
+ variance_norm_factor, p_offset);
}
for( ; j < cascade->stage_classifier[i].count; j++ )
@@ -1244,14 +891,14 @@ cvRunHaarClassifierCascadeSum( const CvHaarClassifierCascade* _cascade,
stage_sum = 0.0;
int k = 0;
-#ifdef CV_HAAR_USE_AVX
+#if CV_HAAR_USE_AVX
if(haveAVX)
{
for( ; k < cascade->stage_classifier[i].count - 8; k += 8 )
{
- stage_sum += icvEvalHidHaarClassifierAVX(
- cascade->stage_classifier[i].classifier + k,
- variance_norm_factor, p_offset );
+ stage_sum += cv_haar_avx::icvEvalHidHaarClassifierAVX(
+ cascade->stage_classifier[i].classifier + k,
+ variance_norm_factor, p_offset );
}
}
#endif
@@ -1851,7 +1498,7 @@ icvLoadCascadeCART( const char** input_cascade, int n, CvSize orig_window_size )
sscanf( stage, "%d%n", &count, &dl );
stage += dl;
- assert( count > 0 );
+ CV_Assert( count > 0 && count < CV_HAAR_STAGE_MAX);
cascade->stage_classifier[i].count = count;
cascade->stage_classifier[i].classifier =
(CvHaarClassifier*)cvAlloc( count*sizeof(cascade->stage_classifier[i].classifier[0]));
@@ -1865,6 +1512,7 @@ icvLoadCascadeCART( const char** input_cascade, int n, CvSize orig_window_size )
sscanf( stage, "%d%n", &classifier->count, &dl );
stage += dl;
+ CV_Assert( classifier->count > 0 && classifier->count< CV_HAAR_STAGE_MAX);
classifier->haar_feature = (CvHaarFeature*) cvAlloc(
classifier->count * ( sizeof( *classifier->haar_feature ) +
sizeof( *classifier->threshold ) +
@@ -1881,7 +1529,7 @@ icvLoadCascadeCART( const char** input_cascade, int n, CvSize orig_window_size )
sscanf( stage, "%d%n", &rects, &dl );
stage += dl;
- assert( rects >= 2 && rects <= CV_HAAR_FEATURE_MAX );
+ CV_Assert( rects >= 2 && rects <= CV_HAAR_FEATURE_MAX );
for( k = 0; k < rects; k++ )
{
@@ -1893,7 +1541,7 @@ icvLoadCascadeCART( const char** input_cascade, int n, CvSize orig_window_size )
stage += dl;
classifier->haar_feature[l].rect[k].r = r;
}
- sscanf( stage, "%s%n", str, &dl );
+ sscanf( stage, "%99s%n", str, &dl );
stage += dl;
classifier->haar_feature[l].tilted = strncmp( str, "tilted", 6 ) == 0;
@@ -1929,6 +1577,7 @@ icvLoadCascadeCART( const char** input_cascade, int n, CvSize orig_window_size )
}
stage += dl;
+ CV_Assert(parent >= 0 && parent < i);
cascade->stage_classifier[i].parent = parent;
cascade->stage_classifier[i].next = next;
cascade->stage_classifier[i].child = -1;
diff --git a/modules/objdetect/src/haar.hpp b/modules/objdetect/src/haar.hpp
new file mode 100644
index 0000000..72a0af4
--- /dev/null
+++ b/modules/objdetect/src/haar.hpp
@@ -0,0 +1,101 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// Intel License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of Intel Corporation may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+/* Haar features calculation */
+
+#ifndef OPENCV_OBJDETECT_HAAR_HPP
+#define OPENCV_OBJDETECT_HAAR_HPP
+
+#define CV_HAAR_FEATURE_MAX_LOCAL 3
+
+typedef int sumtype;
+typedef double sqsumtype;
+
+typedef struct CvHidHaarFeature
+{
+ struct
+ {
+ sumtype *p0, *p1, *p2, *p3;
+ float weight;
+ }
+ rect[CV_HAAR_FEATURE_MAX_LOCAL];
+} CvHidHaarFeature;
+
+
+typedef struct CvHidHaarTreeNode
+{
+ CvHidHaarFeature feature;
+ float threshold;
+ int left;
+ int right;
+} CvHidHaarTreeNode;
+
+
+typedef struct CvHidHaarClassifier
+{
+ int count;
+ //CvHaarFeature* orig_feature;
+ CvHidHaarTreeNode* node;
+ float* alpha;
+} CvHidHaarClassifier;
+
+#define calc_sumf(rect,offset) \
+ static_cast<float>((rect).p0[offset] - (rect).p1[offset] - (rect).p2[offset] + (rect).p3[offset])
+
+namespace cv_haar_avx
+{
+#if 0 /*CV_TRY_AVX*/
+ #define CV_HAAR_USE_AVX 1
+#else
+ #define CV_HAAR_USE_AVX 0
+#endif
+
+#if CV_HAAR_USE_AVX
+ // AVX version icvEvalHidHaarClassifier. Process 8 CvHidHaarClassifiers per call. Check AVX support before invocation!!
+ double icvEvalHidHaarClassifierAVX(CvHidHaarClassifier* classifier, double variance_norm_factor, size_t p_offset);
+ double icvEvalHidHaarStumpClassifierAVX(CvHidHaarClassifier* classifier, double variance_norm_factor, size_t p_offset);
+ double icvEvalHidHaarStumpClassifierTwoRectAVX(CvHidHaarClassifier* classifier, double variance_norm_factor, size_t p_offset);
+#endif
+}
+
+#endif
+
+/* End of file. */
diff --git a/modules/objdetect/src/hog.cpp b/modules/objdetect/src/hog.cpp
index 84baed6..ac02e67 100644
--- a/modules/objdetect/src/hog.cpp
+++ b/modules/objdetect/src/hog.cpp
@@ -325,8 +325,14 @@ void HOGDescriptor::computeGradient(const Mat& img, Mat& grad, Mat& qangle,
#if CV_SSE2
__m128i ithree = _mm_set1_epi32(3);
for ( ; x <= end - 4; x += 4)
- _mm_storeu_si128((__m128i*)(xmap + x), _mm_mullo_epi16(ithree,
- _mm_loadu_si128((const __m128i*)(xmap + x))));
+ {
+ //emulation of _mm_mullo_epi32
+ __m128i mul_res = _mm_loadu_si128((const __m128i*)(xmap + x));
+ __m128i tmp1 = _mm_mul_epu32(ithree, mul_res);
+ __m128i tmp2 = _mm_mul_epu32( _mm_srli_si128(ithree,4), _mm_srli_si128(mul_res,4));
+ mul_res = _mm_unpacklo_epi32(_mm_shuffle_epi32(tmp1, _MM_SHUFFLE (0,0,2,0)), _mm_shuffle_epi32(tmp2, _MM_SHUFFLE (0,0,2,0)));
+ _mm_storeu_si128((__m128i*)(xmap + x), mul_res);
+ }
#elif CV_NEON
int32x4_t ithree = vdupq_n_s32(3);
for ( ; x <= end - 4; x += 4)
@@ -3688,23 +3694,31 @@ void HOGDescriptor::readALTModel(String modelfile)
String eerr("version?");
String efile(__FILE__);
String efunc(__FUNCTION__);
+ fclose(modelfl);
+
throw Exception(Error::StsError, eerr, efile, efunc, __LINE__);
}
if(strcmp(version_buffer,"V6.01")) {
String eerr("version doesnot match");
String efile(__FILE__);
String efunc(__FUNCTION__);
+ fclose(modelfl);
+
throw Exception(Error::StsError, eerr, efile, efunc, __LINE__);
}
/* read version number */
int version = 0;
if (!fread (&version,sizeof(int),1,modelfl))
- { throw Exception(); }
+ {
+ fclose(modelfl);
+ throw Exception();
+ }
if (version < 200)
{
String eerr("version doesnot match");
String efile(__FILE__);
String efunc(__FUNCTION__);
+ fclose(modelfl);
throw Exception();
}
int kernel_type;
@@ -3723,6 +3737,7 @@ void HOGDescriptor::readALTModel(String modelfile)
nread=fread(&(coef_const),sizeof(double),1,modelfl);
int l;
nread=fread(&l,sizeof(int),1,modelfl);
+ CV_Assert(l >= 0 && l < 0xFFFF);
char* custom = new char[l];
nread=fread(custom,sizeof(char),l,modelfl);
delete[] custom;
@@ -3743,11 +3758,13 @@ void HOGDescriptor::readALTModel(String modelfile)
detector.clear();
if(kernel_type == 0) { /* linear kernel */
/* save linear wts also */
+ CV_Assert(totwords + 1 > 0 && totwords < 0xFFFF);
double *linearwt = new double[totwords+1];
int length = totwords;
nread = fread(linearwt, sizeof(double), totwords + 1, modelfl);
if(nread != static_cast<size_t>(length) + 1) {
delete [] linearwt;
+ fclose(modelfl);
throw Exception();
}
@@ -3758,6 +3775,7 @@ void HOGDescriptor::readALTModel(String modelfile)
setSVMDetector(detector);
delete [] linearwt;
} else {
+ fclose(modelfl);
throw Exception();
}
fclose(modelfl);
diff --git a/modules/objdetect/src/precomp.hpp b/modules/objdetect/src/precomp.hpp
index 97b976b..448d8b1 100644
--- a/modules/objdetect/src/precomp.hpp
+++ b/modules/objdetect/src/precomp.hpp
@@ -46,16 +46,8 @@
#include "opencv2/objdetect.hpp"
#include "opencv2/imgproc.hpp"
-#include "opencv2/ml.hpp"
-
#include "opencv2/core/utility.hpp"
#include "opencv2/core/ocl.hpp"
-
-#include "opencv2/opencv_modules.hpp"
-#ifdef HAVE_OPENCV_HIGHGUI
-# include "opencv2/highgui.hpp"
-#endif
-
#include "opencv2/core/private.hpp"
#ifdef HAVE_TEGRA_OPTIMIZATION
diff --git a/modules/photo/CMakeLists.txt b/modules/photo/CMakeLists.txt
index 88ac35d..c15c01d 100644
--- a/modules/photo/CMakeLists.txt
+++ b/modules/photo/CMakeLists.txt
@@ -1,7 +1,7 @@
set(the_description "Computational Photography")
if(HAVE_CUDA)
- ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wmissing-declarations)
+ ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wmissing-declarations -Wshadow)
endif()
ocv_define_module(photo opencv_imgproc OPTIONAL opencv_cudaarithm opencv_cudaimgproc WRAP java python)
diff --git a/modules/photo/include/opencv2/photo.hpp b/modules/photo/include/opencv2/photo.hpp
index a445dd3..6651ac8 100644
--- a/modules/photo/include/opencv2/photo.hpp
+++ b/modules/photo/include/opencv2/photo.hpp
@@ -89,7 +89,7 @@ enum
/** @brief Restores the selected region in an image using the region neighborhood.
- at param src Input 8-bit 1-channel or 3-channel image.
+ at param src Input 8-bit, 16-bit unsigned or 32-bit float 1-channel or 8-bit 3-channel image.
@param inpaintMask Inpainting mask, 8-bit 1-channel image. Non-zero pixels indicate the area that
needs to be inpainted.
@param dst Output image with the same size and type as src .
@@ -591,7 +591,7 @@ public:
@param samples number of pixel locations to use
@param lambda smoothness term weight. Greater values produce smoother results, but can alter the
response.
- at param random if true sample pixel locations are chosen at random, otherwise the form a
+ at param random if true sample pixel locations are chosen at random, otherwise they form a
rectangular grid.
*/
CV_EXPORTS_W Ptr<CalibrateDebevec> createCalibrateDebevec(int samples = 70, float lambda = 10.0f, bool random = false);
@@ -730,6 +730,9 @@ CV_EXPORTS_W void decolor( InputArray src, OutputArray grayscale, OutputArray co
//! @addtogroup photo_clone
//! @{
+/** @example cloning_demo.cpp
+An example using seamlessClone function
+*/
/** @brief Image editing tasks concern either global changes (color/intensity corrections, filters,
deformations) or local changes concerned to a selection. Here we are interested in achieving local
changes, ones that are restricted to a region manually selected (ROI), in a seamless and effortless
@@ -748,7 +751,7 @@ complex outlines into a new background
consuming and often leaves an undesirable halo. Seamless cloning, even averaged with the
original image, is not effective. Mixed seamless cloning based on a loose selection proves
effective.
-- **FEATURE_EXCHANGE** Feature exchange allows the user to easily replace certain features of
+- **MONOCHROME_TRANSFER** Monochrome transfer allows the user to easily replace certain features of
one object by alternative features.
*/
CV_EXPORTS_W void seamlessClone( InputArray src, InputArray dst, InputArray mask, Point p,
@@ -833,6 +836,9 @@ CV_EXPORTS_W void edgePreservingFilter(InputArray src, OutputArray dst, int flag
CV_EXPORTS_W void detailEnhance(InputArray src, OutputArray dst, float sigma_s = 10,
float sigma_r = 0.15f);
+/** @example npr_demo.cpp
+An example using non-photorealistic line drawing functions
+*/
/** @brief Pencil-like non-photorealistic line drawing
@param src Input 8-bit 3-channel image.
diff --git a/modules/photo/src/calibrate.cpp b/modules/photo/src/calibrate.cpp
index dd30005..a17f138 100644
--- a/modules/photo/src/calibrate.cpp
+++ b/modules/photo/src/calibrate.cpp
@@ -43,7 +43,6 @@
#include "precomp.hpp"
#include "opencv2/photo.hpp"
#include "opencv2/imgproc.hpp"
-//#include "opencv2/highgui.hpp"
#include "hdr_common.hpp"
namespace cv
@@ -57,7 +56,7 @@ public:
samples(_samples),
lambda(_lambda),
random(_random),
- w(tringleWeights())
+ w(triangleWeights())
{
}
@@ -65,6 +64,7 @@ public:
{
CV_INSTRUMENT_REGION()
+ // check inputs
std::vector<Mat> images;
src.getMatVector(images);
Mat times = _times.getMat();
@@ -72,62 +72,88 @@ public:
CV_Assert(images.size() == times.total());
checkImageDimensions(images);
CV_Assert(images[0].depth() == CV_8U);
+ CV_Assert(times.type() == CV_32FC1);
+ // create output
int channels = images[0].channels();
int CV_32FCC = CV_MAKETYPE(CV_32F, channels);
+ int rows = images[0].rows;
+ int cols = images[0].cols;
dst.create(LDR_SIZE, 1, CV_32FCC);
Mat result = dst.getMat();
- std::vector<Point> sample_points;
+ // pick pixel locations (either random or in a rectangular grid)
+ std::vector<Point> points;
+ points.reserve(samples);
if(random) {
for(int i = 0; i < samples; i++) {
- sample_points.push_back(Point(rand() % images[0].cols, rand() % images[0].rows));
+ points.push_back(Point(rand() % cols, rand() % rows));
}
} else {
- int x_points = static_cast<int>(sqrt(static_cast<double>(samples) * images[0].cols / images[0].rows));
+ int x_points = static_cast<int>(sqrt(static_cast<double>(samples) * cols / rows));
+ CV_Assert(0 < x_points && x_points <= cols);
int y_points = samples / x_points;
- int step_x = images[0].cols / x_points;
- int step_y = images[0].rows / y_points;
-
+ CV_Assert(0 < y_points && y_points <= rows);
+ int step_x = cols / x_points;
+ int step_y = rows / y_points;
for(int i = 0, x = step_x / 2; i < x_points; i++, x += step_x) {
for(int j = 0, y = step_y / 2; j < y_points; j++, y += step_y) {
- if( 0 <= x && x < images[0].cols &&
- 0 <= y && y < images[0].rows )
- sample_points.push_back(Point(x, y));
+ if( 0 <= x && x < cols && 0 <= y && y < rows ) {
+ points.push_back(Point(x, y));
+ }
}
}
+ // we can have slightly less grid points than specified
+ //samples = static_cast<int>(points.size());
}
+ // we need enough equations to ensure a sufficiently overdetermined system
+ // (maybe only as a warning)
+ //CV_Assert(points.size() * (images.size() - 1) >= LDR_SIZE);
+
+ // solve for imaging system response function, over each channel separately
std::vector<Mat> result_split(channels);
- for(int channel = 0; channel < channels; channel++) {
- Mat A = Mat::zeros((int)sample_points.size() * (int)images.size() + LDR_SIZE + 1, LDR_SIZE + (int)sample_points.size(), CV_32F);
+ for(int ch = 0; ch < channels; ch++) {
+ // initialize system of linear equations
+ Mat A = Mat::zeros((int)points.size() * (int)images.size() + LDR_SIZE + 1,
+ LDR_SIZE + (int)points.size(), CV_32F);
Mat B = Mat::zeros(A.rows, 1, CV_32F);
- int eq = 0;
- for(size_t i = 0; i < sample_points.size(); i++) {
+ // include the data-fitting equations
+ int k = 0;
+ for(size_t i = 0; i < points.size(); i++) {
for(size_t j = 0; j < images.size(); j++) {
-
- int val = images[j].ptr()[3*(sample_points[i].y * images[j].cols + sample_points[i].x) + channel];
- A.at<float>(eq, val) = w.at<float>(val);
- A.at<float>(eq, LDR_SIZE + (int)i) = -w.at<float>(val);
- B.at<float>(eq, 0) = w.at<float>(val) * log(times.at<float>((int)j));
- eq++;
+ // val = images[j].at<Vec3b>(points[i].y, points[i].x)[ch]
+ int val = images[j].ptr()[channels*(points[i].y * cols + points[i].x) + ch];
+ float wij = w.at<float>(val);
+ A.at<float>(k, val) = wij;
+ A.at<float>(k, LDR_SIZE + (int)i) = -wij;
+ B.at<float>(k, 0) = wij * log(times.at<float>((int)j));
+ k++;
}
}
- A.at<float>(eq, LDR_SIZE / 2) = 1;
- eq++;
-
- for(int i = 0; i < 254; i++) {
- A.at<float>(eq, i) = lambda * w.at<float>(i + 1);
- A.at<float>(eq, i + 1) = -2 * lambda * w.at<float>(i + 1);
- A.at<float>(eq, i + 2) = lambda * w.at<float>(i + 1);
- eq++;
+
+ // fix the curve by setting its middle value to 0
+ A.at<float>(k, LDR_SIZE / 2) = 1;
+ k++;
+
+ // include the smoothness equations
+ for(int i = 0; i < (LDR_SIZE - 2); i++) {
+ float wi = w.at<float>(i + 1);
+ A.at<float>(k, i) = lambda * wi;
+ A.at<float>(k, i + 1) = -2 * lambda * wi;
+ A.at<float>(k, i + 2) = lambda * wi;
+ k++;
}
+
+ // solve the overdetermined system using SVD (least-squares problem)
Mat solution;
solve(A, B, solution, DECOMP_SVD);
- solution.rowRange(0, LDR_SIZE).copyTo(result_split[channel]);
+ solution.rowRange(0, LDR_SIZE).copyTo(result_split[ch]);
}
+
+ // combine log-exposures and take its exponent
merge(result_split, result);
exp(result, result);
}
@@ -161,11 +187,11 @@ public:
}
protected:
- String name;
- int samples;
- float lambda;
- bool random;
- Mat w;
+ String name; // calibration algorithm identifier
+ int samples; // number of pixel locations to sample
+ float lambda; // constant that determines the amount of smoothness
+ bool random; // whether to sample locations randomly or in a grid shape
+ Mat w; // weighting function for corresponding pixel values
};
Ptr<CalibrateDebevec> createCalibrateDebevec(int samples, float lambda, bool random)
@@ -198,6 +224,7 @@ public:
int channels = images[0].channels();
int CV_32FCC = CV_MAKETYPE(CV_32F, channels);
+ CV_Assert(channels >= 1 && channels <= 3);
dst.create(LDR_SIZE, 1, CV_32FCC);
Mat response = dst.getMat();
diff --git a/modules/photo/src/denoise_tvl1.cpp b/modules/photo/src/denoise_tvl1.cpp
index 03bd747..df756c4 100644
--- a/modules/photo/src/denoise_tvl1.cpp
+++ b/modules/photo/src/denoise_tvl1.cpp
@@ -56,21 +56,8 @@ namespace cv{
double _scale;
};
-#ifndef OPENCV_NOSTL
using std::transform;
-#else
- template <class InputIterator, class InputIterator2, class OutputIterator, class BinaryOperator>
- static OutputIterator transform (InputIterator first1, InputIterator last1, InputIterator2 first2,
- OutputIterator result, BinaryOperator binary_op)
- {
- while (first1 != last1)
- {
- *result = binary_op(*first1, *first2);
- ++result; ++first1; ++first2;
- }
- return result;
- }
-#endif
+
void denoise_TVL1(const std::vector<Mat>& observations,Mat& result, double lambda, int niters){
CV_Assert(observations.size()>0 && niters>0 && lambda>0);
diff --git a/modules/photo/src/denoising.cpp b/modules/photo/src/denoising.cpp
index ebf345c..ee9e573 100644
--- a/modules/photo/src/denoising.cpp
+++ b/modules/photo/src/denoising.cpp
@@ -116,6 +116,7 @@ void cv::fastNlMeansDenoising( InputArray _src, OutputArray _dst, const std::vec
CV_INSTRUMENT_REGION()
int hn = (int)h.size(), type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
+ CV_Assert(!_src.empty());
CV_Assert(hn == 1 || hn == cn);
Size src_size = _src.size();
diff --git a/modules/photo/src/fast_nlmeans_denoising_invoker.hpp b/modules/photo/src/fast_nlmeans_denoising_invoker.hpp
index cfa9826..b875ebc 100644
--- a/modules/photo/src/fast_nlmeans_denoising_invoker.hpp
+++ b/modules/photo/src/fast_nlmeans_denoising_invoker.hpp
@@ -205,6 +205,10 @@ void FastNlMeansDenoisingInvoker<T, IT, UIT, D, WT>::operator() (const Range& ra
const T * b_up_ptr = extended_src_.ptr<T>(start_by - template_window_half_size_ - 1 + y);
const T * b_down_ptr = extended_src_.ptr<T>(start_by + template_window_half_size_ + y);
+// MSVC 2015 generates unaligned destination for "movaps" instruction for 32-bit builds
+#if defined _MSC_VER && _MSC_VER == 1900 && !defined _WIN64
+#pragma loop(no_vector)
+#endif
for (int x = 0; x < search_window_size; x++)
{
// remove from current pixel sum column sum with index "first_col_num"
diff --git a/modules/photo/src/fast_nlmeans_denoising_invoker_commons.hpp b/modules/photo/src/fast_nlmeans_denoising_invoker_commons.hpp
index d8eb344..d36c85a 100644
--- a/modules/photo/src/fast_nlmeans_denoising_invoker_commons.hpp
+++ b/modules/photo/src/fast_nlmeans_denoising_invoker_commons.hpp
@@ -397,7 +397,7 @@ template <typename ET, typename IT, typename EW> struct incWithWeight_<Vec<ET, 4
template <typename T, typename IT, typename WT>
static inline void incWithWeight(IT* estimation, IT* weights_sum, WT weight, T p)
{
- return incWithWeight_<T, IT, WT>::f(estimation, weights_sum, weight, p);
+ incWithWeight_<T, IT, WT>::f(estimation, weights_sum, weight, p);
}
template <typename IT, typename UIT, int nc, int nw> struct divByWeightsSum_
@@ -434,7 +434,7 @@ template <typename IT, typename UIT, int n> struct divByWeightsSum_<IT, UIT, n,
template <typename IT, typename UIT, int nc, int nw>
static inline void divByWeightsSum(IT* estimation, IT* weights_sum)
{
- return divByWeightsSum_<IT, UIT, nc, nw>::f(estimation, weights_sum);
+ divByWeightsSum_<IT, UIT, nc, nw>::f(estimation, weights_sum);
}
template <typename T, typename IT> struct saturateCastFromArray_
diff --git a/modules/photo/src/fast_nlmeans_denoising_opencl.hpp b/modules/photo/src/fast_nlmeans_denoising_opencl.hpp
index f012de5..b19adbd 100644
--- a/modules/photo/src/fast_nlmeans_denoising_opencl.hpp
+++ b/modules/photo/src/fast_nlmeans_denoising_opencl.hpp
@@ -23,11 +23,6 @@ enum
CTA_SIZE_DEFAULT = 256
};
-static int divUp(int a, int b)
-{
- return (a + b - 1) / b;
-}
-
template <typename FT, typename ST, typename WT>
static bool ocl_calcAlmostDist2Weight(UMat & almostDist2Weight,
int searchWindowSize, int templateWindowSize,
@@ -52,8 +47,8 @@ static bool ocl_calcAlmostDist2Weight(UMat & almostDist2Weight,
FT almostDist2ActualDistMultiplier = (FT)(1 << almostTemplateWindowSizeSqBinShift) / templateWindowSizeSq;
const FT WEIGHT_THRESHOLD = 1e-3f;
- int maxDist = normType == NORM_L1 ? std::numeric_limits<ST>::max() * cn :
- std::numeric_limits<ST>::max() * std::numeric_limits<ST>::max() * cn;
+ WT maxDist = normType == NORM_L1 ? (WT)std::numeric_limits<ST>::max() * cn :
+ (WT)std::numeric_limits<ST>::max() * (WT)std::numeric_limits<ST>::max() * cn;
int almostMaxDist = (int)(maxDist / almostDist2ActualDistMultiplier + 1);
FT den[4];
CV_Assert(hn > 0 && hn <= 4);
diff --git a/modules/photo/src/hdr_common.cpp b/modules/photo/src/hdr_common.cpp
index 9a2d720..983efe3 100644
--- a/modules/photo/src/hdr_common.cpp
+++ b/modules/photo/src/hdr_common.cpp
@@ -59,8 +59,9 @@ void checkImageDimensions(const std::vector<Mat>& images)
}
}
-Mat tringleWeights()
+Mat triangleWeights()
{
+ // hat function
Mat w(LDR_SIZE, 1, CV_32F);
int half = LDR_SIZE / 2;
for(int i = 0; i < LDR_SIZE; i++) {
@@ -73,9 +74,13 @@ Mat RobertsonWeights()
{
Mat weight(LDR_SIZE, 1, CV_32FC3);
float q = (LDR_SIZE - 1) / 4.0f;
+ float e4 = exp(4.f);
+ float scale = e4/(e4 - 1.f);
+ float shift = 1 / (1.f - e4);
+
for(int i = 0; i < LDR_SIZE; i++) {
float value = i / q - 2.0f;
- value = exp(-value * value);
+ value = scale*exp(-value * value) + shift;
weight.at<Vec3f>(i) = Vec3f::all(value);
}
return weight;
diff --git a/modules/photo/src/hdr_common.hpp b/modules/photo/src/hdr_common.hpp
index 26fb8e4..b9846fd 100644
--- a/modules/photo/src/hdr_common.hpp
+++ b/modules/photo/src/hdr_common.hpp
@@ -50,7 +50,7 @@ namespace cv
void checkImageDimensions(const std::vector<Mat>& images);
-Mat tringleWeights();
+Mat triangleWeights();
void mapLuminance(Mat src, Mat dst, Mat lum, Mat new_lum, float saturation);
diff --git a/modules/photo/src/inpaint.cpp b/modules/photo/src/inpaint.cpp
index 4ae3cf3..9669d02 100644
--- a/modules/photo/src/inpaint.cpp
+++ b/modules/photo/src/inpaint.cpp
@@ -277,7 +277,7 @@ icvCalcFMM(const CvMat *f, CvMat *t, CvPriorityQueueFloat *Heap, bool negate) {
}
}
-
+template <typename data_type>
static void
icvTeleaInpaintFMM(const CvMat *f, CvMat *t, CvMat *out, int range, CvPriorityQueueFloat *Heap ) {
int i = 0, j = 0, ii = 0, jj = 0, k, l, q, color = 0;
@@ -463,31 +463,31 @@ icvTeleaInpaintFMM(const CvMat *f, CvMat *t, CvMat *out, int range, CvPriorityQu
if (CV_MAT_ELEM(*f,uchar,k,l+1)!=INSIDE) {
if (CV_MAT_ELEM(*f,uchar,k,l-1)!=INSIDE) {
- gradI.x=(float)((CV_MAT_ELEM(*out,uchar,km,lp+1)-CV_MAT_ELEM(*out,uchar,km,lm-1)))*2.0f;
+ gradI.x=(float)((CV_MAT_ELEM(*out,data_type,km,lp+1)-CV_MAT_ELEM(*out,data_type,km,lm-1)))*2.0f;
} else {
- gradI.x=(float)((CV_MAT_ELEM(*out,uchar,km,lp+1)-CV_MAT_ELEM(*out,uchar,km,lm)));
+ gradI.x=(float)((CV_MAT_ELEM(*out,data_type,km,lp+1)-CV_MAT_ELEM(*out,data_type,km,lm)));
}
} else {
if (CV_MAT_ELEM(*f,uchar,k,l-1)!=INSIDE) {
- gradI.x=(float)((CV_MAT_ELEM(*out,uchar,km,lp)-CV_MAT_ELEM(*out,uchar,km,lm-1)));
+ gradI.x=(float)((CV_MAT_ELEM(*out,data_type,km,lp)-CV_MAT_ELEM(*out,data_type,km,lm-1)));
} else {
gradI.x=0;
}
}
if (CV_MAT_ELEM(*f,uchar,k+1,l)!=INSIDE) {
if (CV_MAT_ELEM(*f,uchar,k-1,l)!=INSIDE) {
- gradI.y=(float)((CV_MAT_ELEM(*out,uchar,kp+1,lm)-CV_MAT_ELEM(*out,uchar,km-1,lm)))*2.0f;
+ gradI.y=(float)((CV_MAT_ELEM(*out,data_type,kp+1,lm)-CV_MAT_ELEM(*out,data_type,km-1,lm)))*2.0f;
} else {
- gradI.y=(float)((CV_MAT_ELEM(*out,uchar,kp+1,lm)-CV_MAT_ELEM(*out,uchar,km,lm)));
+ gradI.y=(float)((CV_MAT_ELEM(*out,data_type,kp+1,lm)-CV_MAT_ELEM(*out,data_type,km,lm)));
}
} else {
if (CV_MAT_ELEM(*f,uchar,k-1,l)!=INSIDE) {
- gradI.y=(float)((CV_MAT_ELEM(*out,uchar,kp,lm)-CV_MAT_ELEM(*out,uchar,km-1,lm)));
+ gradI.y=(float)((CV_MAT_ELEM(*out,data_type,kp,lm)-CV_MAT_ELEM(*out,data_type,km-1,lm)));
} else {
gradI.y=0;
}
}
- Ia += (float)w * (float)(CV_MAT_ELEM(*out,uchar,km,lm));
+ Ia += (float)w * (float)(CV_MAT_ELEM(*out,data_type,km,lm));
Jx -= (float)w * (float)(gradI.x*r.x);
Jy -= (float)w * (float)(gradI.y*r.y);
s += w;
@@ -497,7 +497,7 @@ icvTeleaInpaintFMM(const CvMat *f, CvMat *t, CvMat *out, int range, CvPriorityQu
}
sat = (float)((Ia/s+(Jx+Jy)/(sqrt(Jx*Jx+Jy*Jy)+1.0e-20f)+0.5f));
{
- CV_MAT_ELEM(*out,uchar,i-1,j-1) = cv::saturate_cast<uchar>(sat);
+ CV_MAT_ELEM(*out,data_type,i-1,j-1) = cv::saturate_cast<data_type>(sat);
}
}
@@ -509,7 +509,7 @@ icvTeleaInpaintFMM(const CvMat *f, CvMat *t, CvMat *out, int range, CvPriorityQu
}
}
-
+template <typename data_type>
static void
icvNSInpaintFMM(const CvMat *f, CvMat *t, CvMat *out, int range, CvPriorityQueueFloat *Heap) {
int i = 0, j = 0, ii = 0, jj = 0, k, l, q, color = 0;
@@ -640,28 +640,28 @@ icvNSInpaintFMM(const CvMat *f, CvMat *t, CvMat *out, int range, CvPriorityQueue
if (CV_MAT_ELEM(*f,uchar,k+1,l)!=INSIDE) {
if (CV_MAT_ELEM(*f,uchar,k-1,l)!=INSIDE) {
- gradI.x=(float)(abs(CV_MAT_ELEM(*out,uchar,kp+1,lm)-CV_MAT_ELEM(*out,uchar,kp,lm))+
- abs(CV_MAT_ELEM(*out,uchar,kp,lm)-CV_MAT_ELEM(*out,uchar,km-1,lm)));
+ gradI.x=(float)(std::abs(CV_MAT_ELEM(*out,data_type,kp+1,lm)-CV_MAT_ELEM(*out,data_type,kp,lm))+
+ std::abs(CV_MAT_ELEM(*out,data_type,kp,lm)-CV_MAT_ELEM(*out,data_type,km-1,lm)));
} else {
- gradI.x=(float)(abs(CV_MAT_ELEM(*out,uchar,kp+1,lm)-CV_MAT_ELEM(*out,uchar,kp,lm)))*2.0f;
+ gradI.x=(float)(std::abs(CV_MAT_ELEM(*out,data_type,kp+1,lm)-CV_MAT_ELEM(*out,data_type,kp,lm)))*2.0f;
}
} else {
if (CV_MAT_ELEM(*f,uchar,k-1,l)!=INSIDE) {
- gradI.x=(float)(abs(CV_MAT_ELEM(*out,uchar,kp,lm)-CV_MAT_ELEM(*out,uchar,km-1,lm)))*2.0f;
+ gradI.x=(float)(std::abs(CV_MAT_ELEM(*out,data_type,kp,lm)-CV_MAT_ELEM(*out,data_type,km-1,lm)))*2.0f;
} else {
gradI.x=0;
}
}
if (CV_MAT_ELEM(*f,uchar,k,l+1)!=INSIDE) {
if (CV_MAT_ELEM(*f,uchar,k,l-1)!=INSIDE) {
- gradI.y=(float)(abs(CV_MAT_ELEM(*out,uchar,km,lp+1)-CV_MAT_ELEM(*out,uchar,km,lm))+
- abs(CV_MAT_ELEM(*out,uchar,km,lm)-CV_MAT_ELEM(*out,uchar,km,lm-1)));
+ gradI.y=(float)(std::abs(CV_MAT_ELEM(*out,data_type,km,lp+1)-CV_MAT_ELEM(*out,data_type,km,lm))+
+ std::abs(CV_MAT_ELEM(*out,data_type,km,lm)-CV_MAT_ELEM(*out,data_type,km,lm-1)));
} else {
- gradI.y=(float)(abs(CV_MAT_ELEM(*out,uchar,km,lp+1)-CV_MAT_ELEM(*out,uchar,km,lm)))*2.0f;
+ gradI.y=(float)(std::abs(CV_MAT_ELEM(*out,data_type,km,lp+1)-CV_MAT_ELEM(*out,data_type,km,lm)))*2.0f;
}
} else {
if (CV_MAT_ELEM(*f,uchar,k,l-1)!=INSIDE) {
- gradI.y=(float)(abs(CV_MAT_ELEM(*out,uchar,km,lm)-CV_MAT_ELEM(*out,uchar,km,lm-1)))*2.0f;
+ gradI.y=(float)(std::abs(CV_MAT_ELEM(*out,data_type,km,lm)-CV_MAT_ELEM(*out,data_type,km,lm-1)))*2.0f;
} else {
gradI.y=0;
}
@@ -676,13 +676,13 @@ icvNSInpaintFMM(const CvMat *f, CvMat *t, CvMat *out, int range, CvPriorityQueue
dir = (float)fabs(VectorScalMult(r,gradI)/sqrt(VectorLength(r)*VectorLength(gradI)));
}
w = dst*dir;
- Ia += (float)w * (float)(CV_MAT_ELEM(*out,uchar,km,lm));
+ Ia += (float)w * (float)(CV_MAT_ELEM(*out,data_type,km,lm));
s += w;
}
}
}
}
- CV_MAT_ELEM(*out,uchar,i-1,j-1) = cv::saturate_cast<uchar>((double)Ia/s);
+ CV_MAT_ELEM(*out,data_type,i-1,j-1) = cv::saturate_cast<data_type>((double)Ia/s);
}
CV_MAT_ELEM(*f,uchar,i,j) = BAND;
@@ -744,11 +744,13 @@ cvInpaint( const CvArr* _input_img, const CvArr* _inpaint_mask, CvArr* _output_i
if( !CV_ARE_SIZES_EQ(input_img,output_img) || !CV_ARE_SIZES_EQ(input_img,inpaint_mask))
CV_Error( CV_StsUnmatchedSizes, "All the input and output images must have the same size" );
- if( (CV_MAT_TYPE(input_img->type) != CV_8UC1 &&
+ if( (CV_MAT_TYPE(input_img->type) != CV_8U &&
+ CV_MAT_TYPE(input_img->type) != CV_16U &&
+ CV_MAT_TYPE(input_img->type) != CV_32F &&
CV_MAT_TYPE(input_img->type) != CV_8UC3) ||
!CV_ARE_TYPES_EQ(input_img,output_img) )
CV_Error( CV_StsUnsupportedFormat,
- "Only 8-bit 1-channel and 3-channel input/output images are supported" );
+ "8-bit, 16-bit unsigned or 32-bit float 1-channel and 8-bit 3-channel input/output images are supported" );
if( CV_MAT_TYPE(inpaint_mask->type) != CV_8UC1 )
CV_Error( CV_StsUnsupportedFormat, "The mask must be 8-bit 1-channel image" );
@@ -798,10 +800,36 @@ cvInpaint( const CvArr* _input_img, const CvArr* _inpaint_mask, CvArr* _output_i
cvSub(out,band,out,NULL);
SET_BORDER1_C1(out,uchar,0);
icvCalcFMM(out,t,Out,true);
- icvTeleaInpaintFMM(mask,t,output_img,range,Heap);
+ switch(CV_MAT_DEPTH(output_img->type))
+ {
+ case CV_8U:
+ icvTeleaInpaintFMM<uchar>(mask,t,output_img,range,Heap);
+ break;
+ case CV_16U:
+ icvTeleaInpaintFMM<ushort>(mask,t,output_img,range,Heap);
+ break;
+ case CV_32F:
+ icvTeleaInpaintFMM<float>(mask,t,output_img,range,Heap);
+ break;
+ default:
+ CV_Error( cv::Error::StsBadArg, "Unsupportedformat of the input image" );
+ }
}
else if (flags == cv::INPAINT_NS) {
- icvNSInpaintFMM(mask,t,output_img,range,Heap);
+ switch(CV_MAT_DEPTH(output_img->type))
+ {
+ case CV_8U:
+ icvNSInpaintFMM<uchar>(mask,t,output_img,range,Heap);
+ break;
+ case CV_16U:
+ icvNSInpaintFMM<ushort>(mask,t,output_img,range,Heap);
+ break;
+ case CV_32F:
+ icvNSInpaintFMM<float>(mask,t,output_img,range,Heap);
+ break;
+ default:
+ CV_Error( cv::Error::StsBadArg, "Unsupported format of the input image" );
+ }
} else {
CV_Error( cv::Error::StsBadArg, "The flags argument must be one of CV_INPAINT_TELEA or CV_INPAINT_NS" );
}
diff --git a/modules/photo/src/merge.cpp b/modules/photo/src/merge.cpp
index 3e59180..d04e7b8 100644
--- a/modules/photo/src/merge.cpp
+++ b/modules/photo/src/merge.cpp
@@ -52,7 +52,7 @@ class MergeDebevecImpl : public MergeDebevec
public:
MergeDebevecImpl() :
name("MergeDebevec"),
- weights(tringleWeights())
+ weights(triangleWeights())
{
}
diff --git a/modules/photo/test/test_hdr.cpp b/modules/photo/test/test_hdr.cpp
index 27773fb..d1e1bb5 100644
--- a/modules/photo/test/test_hdr.cpp
+++ b/modules/photo/test/test_hdr.cpp
@@ -141,9 +141,10 @@ TEST(Photo_AlignMTB, regression)
int errors = 0;
Ptr<AlignMTB> align = createAlignMTB(max_bits);
+ RNG rng = ::theRNG();
for(int i = 0; i < TESTS_COUNT; i++) {
- Point shift(rand() % max_shift, rand() % max_shift);
+ Point shift(rng.uniform(0, max_shift), rng.uniform(0, max_shift));
Mat res;
align->shiftMat(img, res, shift);
Point calc = align->calculateShift(img, res);
@@ -208,17 +209,17 @@ TEST(Photo_MergeRobertson, regression)
vector<Mat> images;
vector<float> times;
loadExposureSeq(test_path + "exposures/", images, times);
-
Ptr<MergeRobertson> merge = createMergeRobertson();
-
Mat result, expected;
loadImage(test_path + "merge/robertson.hdr", expected);
merge->process(images, result, times);
- Ptr<Tonemap> map = createTonemap();
- map->process(result, result);
- map->process(expected, expected);
- checkEqual(expected, result, 1e-2f, "MergeRobertson");
+#ifdef __aarch64__
+ const float eps = 6.f;
+#else
+ const float eps = 5.f;
+#endif
+ checkEqual(expected, result, eps, "MergeRobertson");
}
TEST(Photo_CalibrateDebevec, regression)
@@ -252,5 +253,5 @@ TEST(Photo_CalibrateRobertson, regression)
Ptr<CalibrateRobertson> calibrate = createCalibrateRobertson();
calibrate->process(images, response, times);
- checkEqual(expected, response, 1e-3f, "CalibrateRobertson");
+ checkEqual(expected, response, 1e-1f, "CalibrateRobertson");
}
diff --git a/modules/photo/test/test_inpaint.cpp b/modules/photo/test/test_inpaint.cpp
index 8f031e8..6c3426f 100644
--- a/modules/photo/test/test_inpaint.cpp
+++ b/modules/photo/test/test_inpaint.cpp
@@ -117,3 +117,26 @@ void CV_InpaintTest::run( int )
}
TEST(Photo_Inpaint, regression) { CV_InpaintTest test; test.safe_run(); }
+
+typedef testing::TestWithParam<std::tr1::tuple<int> > formats;
+
+TEST_P(formats, 1c)
+{
+ const int type = std::tr1::get<0>(GetParam());
+ Mat src(100, 100, type);
+ src.setTo(Scalar::all(128));
+ Mat ref = src.clone();
+ Mat dst, mask = Mat::zeros(src.size(), CV_8U);
+
+ circle(src, Point(50, 50), 5, Scalar(200), 6);
+ circle(mask, Point(50, 50), 5, Scalar(200), 6);
+ inpaint(src, mask, dst, 10, INPAINT_NS);
+
+ Mat dst2;
+ inpaint(src, mask, dst2, 10, INPAINT_TELEA);
+
+ ASSERT_LE(cv::norm(dst, ref, NORM_INF), 3.);
+ ASSERT_LE(cv::norm(dst2, ref, NORM_INF), 3.);
+}
+
+INSTANTIATE_TEST_CASE_P(Photo_Inpaint, formats, testing::Values(CV_32F, CV_16U, CV_8U));
diff --git a/modules/photo/test/test_npr.cpp b/modules/photo/test/test_npr.cpp
index 24f6f88..a733505 100755
--- a/modules/photo/test/test_npr.cpp
+++ b/modules/photo/test/test_npr.cpp
@@ -62,8 +62,9 @@ TEST(Photo_NPR_EdgePreserveSmoothing_RecursiveFilter, regression)
edgePreservingFilter(source,result,1);
Mat reference = imread(folder + "smoothened_RF_reference.png");
- double error = cvtest::norm(reference, result, NORM_L1);
- EXPECT_LE(error, numerical_precision);
+
+ double psnr = cvtest::PSNR(reference, result);
+ EXPECT_GT(psnr, 60.0);
}
TEST(Photo_NPR_EdgePreserveSmoothing_NormConvFilter, regression)
@@ -79,9 +80,9 @@ TEST(Photo_NPR_EdgePreserveSmoothing_NormConvFilter, regression)
edgePreservingFilter(source,result,2);
Mat reference = imread(folder + "smoothened_NCF_reference.png");
- double error = cvtest::norm(reference, result, NORM_L1);
- EXPECT_LE(error, numerical_precision);
+ double psnr = cvtest::PSNR(reference, result);
+ EXPECT_GT(psnr, 60.0);
}
TEST(Photo_NPR_DetailEnhance, regression)
@@ -97,8 +98,8 @@ TEST(Photo_NPR_DetailEnhance, regression)
detailEnhance(source,result);
Mat reference = imread(folder + "detail_enhanced_reference.png");
- double error = cvtest::norm(reference, result, NORM_L1);
- EXPECT_LE(error, numerical_precision);
+ double psnr = cvtest::PSNR(reference, result);
+ EXPECT_GT(psnr, 60.0);
}
TEST(Photo_NPR_PencilSketch, regression)
diff --git a/modules/python/CMakeLists.txt b/modules/python/CMakeLists.txt
index 1da5e32..d85a516 100644
--- a/modules/python/CMakeLists.txt
+++ b/modules/python/CMakeLists.txt
@@ -2,16 +2,26 @@
# CMake file for python support
# ----------------------------------------------------------------------------
-if((WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
- OR BUILD_opencv_world
- )
- ocv_module_disable(python2)
- ocv_module_disable(python3)
+if(ANDROID OR APPLE_FRAMEWORK OR WINRT)
+ set(__disable_python2 ON)
+ set(__disable_python3 ON)
+elseif(BUILD_opencv_world OR (WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug"))
+ if(NOT DEFINED BUILD_opencv_python2)
+ set(__disable_python2 ON)
+ endif()
+ if(NOT DEFINED BUILD_opencv_python3)
+ set(__disable_python3 ON)
+ endif()
endif()
-if(ANDROID OR APPLE_FRAMEWORK OR WINRT)
- ocv_module_disable(python2)
- ocv_module_disable(python3)
+if(__disable_python2)
+ ocv_module_disable_(python2)
+endif()
+if(__disable_python3)
+ ocv_module_disable_(python3)
+endif()
+if(__disable_python2 AND __disable_python3)
+ return()
endif()
add_subdirectory(python2)
diff --git a/modules/python/common.cmake b/modules/python/common.cmake
index e014d0e..454c0d4 100644
--- a/modules/python/common.cmake
+++ b/modules/python/common.cmake
@@ -32,12 +32,16 @@ foreach(m ${OPENCV_PYTHON_MODULES})
endforeach(m)
# header blacklist
-ocv_list_filterout(opencv_hdrs "modules/.*.h$")
+ocv_list_filterout(opencv_hdrs "modules/.*\\\\.h$")
ocv_list_filterout(opencv_hdrs "modules/core/.*/cuda")
ocv_list_filterout(opencv_hdrs "modules/cuda.*")
ocv_list_filterout(opencv_hdrs "modules/cudev")
ocv_list_filterout(opencv_hdrs "modules/core/.*/hal/")
-ocv_list_filterout(opencv_hdrs "modules/.*/detection_based_tracker.hpp") # Conditional compilation
+ocv_list_filterout(opencv_hdrs "modules/.+/utils/.*")
+ocv_list_filterout(opencv_hdrs "modules/.*\\\\.inl\\\\.h*")
+ocv_list_filterout(opencv_hdrs "modules/.*_inl\\\\.h*")
+ocv_list_filterout(opencv_hdrs "modules/.*\\\\.details\\\\.h*")
+ocv_list_filterout(opencv_hdrs "modules/.*/detection_based_tracker\\\\.hpp") # Conditional compilation
set(cv2_generated_hdrs
"${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_include.h"
@@ -46,7 +50,8 @@ set(cv2_generated_hdrs
"${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_type_reg.h"
"${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_ns_reg.h")
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/headers.txt" "${opencv_hdrs}")
+string(REPLACE ";" "\n" opencv_hdrs_ "${opencv_hdrs}")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/headers.txt" "${opencv_hdrs_}")
add_custom_command(
OUTPUT ${cv2_generated_hdrs}
COMMAND ${PYTHON_DEFAULT_EXECUTABLE} "${PYTHON_SOURCE_DIR}/src2/gen2.py" ${CMAKE_CURRENT_BINARY_DIR} "${CMAKE_CURRENT_BINARY_DIR}/headers.txt" "${PYTHON}"
diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp
index e69e933..be8965c 100644
--- a/modules/python/src2/cv2.cpp
+++ b/modules/python/src2/cv2.cpp
@@ -149,7 +149,7 @@ public:
{
if( data != 0 )
{
- CV_Error(Error::StsAssert, "The data should normally be NULL!");
+ // issue #6969: CV_Error(Error::StsAssert, "The data should normally be NULL!");
// probably this is safe to do in such extreme case
return stdAllocator->allocate(dims0, sizes, type, data, step, flags, usageFlags);
}
@@ -394,6 +394,15 @@ bool pyopencv_to(PyObject* o, Mat& m, const char* name)
return pyopencv_to(o, m, ArgInfo(name, 0));
}
+template <typename T>
+bool pyopencv_to(PyObject *o, Ptr<T>& p, const char *name)
+{
+ if (!o || o == Py_None)
+ return true;
+ p = makePtr<T>();
+ return pyopencv_to(o, *p, name);
+}
+
template<>
PyObject* pyopencv_from(const Mat& m)
{
@@ -411,40 +420,93 @@ PyObject* pyopencv_from(const Mat& m)
return o;
}
+template<typename _Tp, int m, int n>
+PyObject* pyopencv_from(const Matx<_Tp, m, n>& matx)
+{
+ return pyopencv_from(Mat(matx));
+}
+
+template<typename T>
+PyObject* pyopencv_from(const cv::Ptr<T>& p)
+{
+ if (!p)
+ Py_RETURN_NONE;
+ return pyopencv_from(*p);
+}
typedef struct {
PyObject_HEAD
UMat* um;
} cv2_UMatWrapperObject;
-// UMatWrapper init - takes one optional argument, that converts to Mat, that converts to UMat and stored inside.
-// If no argument given - empty UMat created.
+static bool PyObject_IsUMat(PyObject *o);
+
+// UMatWrapper init - try to map arguments from python to UMat constructors
static int UMatWrapper_init(cv2_UMatWrapperObject *self, PyObject *args, PyObject *kwds)
{
- self->um = new UMat();
-
- PyObject *np_mat = NULL;
-
- static char *kwlist[] = {new char[3], NULL};
- strcpy(kwlist[0], "mat");
-
- if (! PyArg_ParseTupleAndKeywords(args, kwds, "|O", kwlist, &np_mat))
- return -1;
-
- if (np_mat) {
- Mat m;
- if (!pyopencv_to(np_mat, m, ArgInfo("UMatWrapper.np_mat", 0)))
- return -1;
-
- m.copyTo(*self->um);
+ self->um = NULL;
+ {
+ // constructor ()
+ const char *kwlist[] = {NULL};
+ if (PyArg_ParseTupleAndKeywords(args, kwds, "", (char**) kwlist)) {
+ self->um = new UMat();
+ return 0;
+ }
+ PyErr_Clear();
}
-
- return 0;
+ {
+ // constructor (rows, cols, type)
+ const char *kwlist[] = {"rows", "cols", "type", NULL};
+ int rows, cols, type;
+ if (PyArg_ParseTupleAndKeywords(args, kwds, "iii", (char**) kwlist, &rows, &cols, &type)) {
+ self->um = new UMat(rows, cols, type);
+ return 0;
+ }
+ PyErr_Clear();
+ }
+ {
+ // constructor (m, rowRange, colRange)
+ const char *kwlist[] = {"m", "rowRange", "colRange", NULL};
+ PyObject *obj = NULL;
+ int y0 = -1, y1 = -1, x0 = -1, x1 = -1;
+ if (PyArg_ParseTupleAndKeywords(args, kwds, "O(ii)|(ii)", (char**) kwlist, &obj, &y0, &y1, &x0, &x1) && PyObject_IsUMat(obj)) {
+ UMat *um_other = ((cv2_UMatWrapperObject *) obj)->um;
+ Range rowRange(y0, y1);
+ Range colRange = (x0 >= 0 && x1 >= 0) ? Range(x0, x1) : Range::all();
+ self->um = new UMat(*um_other, rowRange, colRange);
+ return 0;
+ }
+ PyErr_Clear();
+ }
+ {
+ // constructor (m)
+ const char *kwlist[] = {"m", NULL};
+ PyObject *obj = NULL;
+ if (PyArg_ParseTupleAndKeywords(args, kwds, "O", (char**) kwlist, &obj)) {
+ // constructor (UMat m)
+ if (PyObject_IsUMat(obj)) {
+ UMat *um_other = ((cv2_UMatWrapperObject *) obj)->um;
+ self->um = new UMat(*um_other);
+ return 0;
+ }
+ // python specific constructor from array like object
+ Mat m;
+ if (pyopencv_to(obj, m, ArgInfo("UMatWrapper.np_mat", 0))) {
+ self->um = new UMat();
+ m.copyTo(*self->um);
+ return 0;
+ }
+ }
+ PyErr_Clear();
+ }
+ PyErr_SetString(PyExc_TypeError, "no matching UMat constructor found/supported");
+ return -1;
}
static void UMatWrapper_dealloc(cv2_UMatWrapperObject* self)
{
- delete self->um;
+ if (self->um)
+ delete self->um;
#if PY_MAJOR_VERSION >= 3
Py_TYPE(self)->tp_free((PyObject*)self);
#else
@@ -463,13 +525,71 @@ static PyObject * UMatWrapper_get(cv2_UMatWrapperObject* self)
return pyopencv_from(m);
}
+// UMatWrapper.handle() - returns the OpenCL handle of the UMat object
+static PyObject * UMatWrapper_handle(cv2_UMatWrapperObject* self, PyObject *args, PyObject *kwds)
+{
+ const char *kwlist[] = {"accessFlags", NULL};
+ int accessFlags;
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", (char**) kwlist, &accessFlags))
+ return 0;
+ return PyLong_FromVoidPtr(self->um->handle(accessFlags));
+}
+
+// UMatWrapper.isContinuous() - returns true if the matrix data is continuous
+static PyObject * UMatWrapper_isContinuous(cv2_UMatWrapperObject* self)
+{
+ return PyBool_FromLong(self->um->isContinuous());
+}
+
+// UMatWrapper.isContinuous() - returns true if the matrix is a submatrix of another matrix
+static PyObject * UMatWrapper_isSubmatrix(cv2_UMatWrapperObject* self)
+{
+ return PyBool_FromLong(self->um->isSubmatrix());
+}
+
+// UMatWrapper.context() - returns the OpenCL context used by OpenCV UMat
+static PyObject * UMatWrapper_context(cv2_UMatWrapperObject*)
+{
+ return PyLong_FromVoidPtr(cv::ocl::Context::getDefault().ptr());
+}
+
+// UMatWrapper.context() - returns the OpenCL queue used by OpenCV UMat
+static PyObject * UMatWrapper_queue(cv2_UMatWrapperObject*)
+{
+ return PyLong_FromVoidPtr(cv::ocl::Queue::getDefault().ptr());
+}
+
+static PyObject * UMatWrapper_offset_getter(cv2_UMatWrapperObject* self, void*)
+{
+ return PyLong_FromSsize_t(self->um->offset);
+}
+
static PyMethodDef UMatWrapper_methods[] = {
{"get", (PyCFunction)UMatWrapper_get, METH_NOARGS,
"Returns numpy array"
},
+ {"handle", (PyCFunction)UMatWrapper_handle, METH_VARARGS | METH_KEYWORDS,
+ "Returns UMat native handle"
+ },
+ {"isContinuous", (PyCFunction)UMatWrapper_isContinuous, METH_NOARGS,
+ "Returns true if the matrix data is continuous"
+ },
+ {"isSubmatrix", (PyCFunction)UMatWrapper_isSubmatrix, METH_NOARGS,
+ "Returns true if the matrix is a submatrix of another matrix"
+ },
+ {"context", (PyCFunction)UMatWrapper_context, METH_NOARGS | METH_STATIC,
+ "Returns OpenCL context handle"
+ },
+ {"queue", (PyCFunction)UMatWrapper_queue, METH_NOARGS | METH_STATIC,
+ "Returns OpenCL queue handle"
+ },
{NULL, NULL, 0, NULL} /* Sentinel */
};
+static PyGetSetDef UMatWrapper_getset[] = {
+ {(char*) "offset", (getter) UMatWrapper_offset_getter, NULL, NULL, NULL},
+ {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
+};
static PyTypeObject cv2_UMatWrapperType = {
#if PY_MAJOR_VERSION >= 3
@@ -506,7 +626,7 @@ static PyTypeObject cv2_UMatWrapperType = {
0, /* tp_iternext */
UMatWrapper_methods, /* tp_methods */
0, /* tp_members */
- 0, /* tp_getset */
+ UMatWrapper_getset, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
@@ -529,8 +649,12 @@ static PyTypeObject cv2_UMatWrapperType = {
#endif
};
+static bool PyObject_IsUMat(PyObject *o) {
+ return (o != NULL) && PyObject_TypeCheck(o, &cv2_UMatWrapperType);
+}
+
static bool pyopencv_to(PyObject* o, UMat& um, const ArgInfo info) {
- if (o != NULL && PyObject_TypeCheck(o, &cv2_UMatWrapperType) ) {
+ if (PyObject_IsUMat(o)) {
um = *((cv2_UMatWrapperObject *) o)->um;
return true;
}
@@ -750,6 +874,21 @@ PyObject* pyopencv_from(const Size& sz)
}
template<>
+bool pyopencv_to(PyObject* obj, Size_<float>& sz, const char* name)
+{
+ (void)name;
+ if(!obj || obj == Py_None)
+ return true;
+ return PyArg_ParseTuple(obj, "ff", &sz.width, &sz.height) > 0;
+}
+
+template<>
+PyObject* pyopencv_from(const Size_<float>& sz)
+{
+ return Py_BuildValue("(ff)", sz.width, sz.height);
+}
+
+template<>
bool pyopencv_to(PyObject* obj, Rect& r, const char* name)
{
(void)name;
@@ -913,7 +1052,7 @@ PyObject* pyopencv_from(const Point2d& p)
template<>
PyObject* pyopencv_from(const Point3d& p)
{
- return Py_BuildValue("(ddd)", p.x, p.y, p.y);
+ return Py_BuildValue("(ddd)", p.x, p.y, p.z);
}
template<typename _Tp> struct pyopencvVecConverter
@@ -1207,13 +1346,6 @@ PyObject* pyopencv_from(const Moments& m)
"nu30", m.nu30, "nu21", m.nu21, "nu12", m.nu12, "nu03", m.nu03);
}
-template <typename T>
-bool pyopencv_to(PyObject *o, Ptr<T>& p, const char *name)
-{
- p = makePtr<T>();
- return pyopencv_to(o, *p, name);
-}
-
#include "pyopencv_custom_headers.h"
static void OnMouse(int event, int x, int y, int flags, void* param)
@@ -1318,7 +1450,7 @@ static PyObject *pycvCreateButton(PyObject*, PyObject *args, PyObject *kw)
PyObject *userdata = NULL;
char* button_name;
int button_type = 0;
- bool initial_button_state = false;
+ int initial_button_state = 0;
if (!PyArg_ParseTupleAndKeywords(args, kw, "sO|Oii", (char**)keywords, &button_name, &on_change, &userdata, &button_type, &initial_button_state))
return NULL;
@@ -1330,7 +1462,7 @@ static PyObject *pycvCreateButton(PyObject*, PyObject *args, PyObject *kw)
userdata = Py_None;
}
- ERRWRAP2(createButton(button_name, OnButtonChange, Py_BuildValue("OO", on_change, userdata), button_type, initial_button_state));
+ ERRWRAP2(createButton(button_name, OnButtonChange, Py_BuildValue("OO", on_change, userdata), button_type, initial_button_state != 0));
Py_RETURN_NONE;
}
#endif
diff --git a/modules/python/src2/gen2.py b/modules/python/src2/gen2.py
index 888fb40..da7a923 100755
--- a/modules/python/src2/gen2.py
+++ b/modules/python/src2/gen2.py
@@ -11,14 +11,18 @@ else:
ignored_arg_types = ["RNG*"]
-gen_template_check_self = Template(""" if(!PyObject_TypeCheck(self, &pyopencv_${name}_Type))
+gen_template_check_self = Template(""" $cname* _self_ = NULL;
+ if(PyObject_TypeCheck(self, &pyopencv_${name}_Type))
+ _self_ = ${amp}((pyopencv_${name}_t*)self)->v${get};
+ if (_self_ == NULL)
return failmsgp("Incorrect type of self (must be '${name}' or its derivative)");
- $cname* _self_ = ${amp}((pyopencv_${name}_t*)self)->v${get};
""")
-gen_template_check_self_algo = Template(""" if(!PyObject_TypeCheck(self, &pyopencv_${name}_Type))
+gen_template_check_self_algo = Template(""" $cname* _self_ = NULL;
+ if(PyObject_TypeCheck(self, &pyopencv_${name}_Type))
+ _self_ = dynamic_cast<$cname*>(${amp}((pyopencv_${name}_t*)self)->v.get());
+ if (_self_ == NULL)
return failmsgp("Incorrect type of self (must be '${name}' or its derivative)");
- $cname* _self_ = dynamic_cast<$cname*>(${amp}((pyopencv_${name}_t*)self)->v.get());
""")
gen_template_call_constructor_prelude = Template("""self = PyObject_NEW(pyopencv_${name}_t, &pyopencv_${name}_Type);
@@ -200,7 +204,10 @@ static PyObject* pyopencv_${name}_get_${member}(pyopencv_${name}_t* p, void *clo
gen_template_get_prop_algo = Template("""
static PyObject* pyopencv_${name}_get_${member}(pyopencv_${name}_t* p, void *closure)
{
- return pyopencv_from(dynamic_cast<$cname*>(p->v.get())${access}${member});
+ $cname* _self_ = dynamic_cast<$cname*>(p->v.get());
+ if (_self_ == NULL)
+ return failmsgp("Incorrect type of object (must be '${name}' or its derivative)");
+ return pyopencv_from(_self_${access}${member});
}
""")
@@ -224,7 +231,13 @@ static int pyopencv_${name}_set_${member}(pyopencv_${name}_t* p, PyObject *value
PyErr_SetString(PyExc_TypeError, "Cannot delete the ${member} attribute");
return -1;
}
- return pyopencv_to(value, dynamic_cast<$cname*>(p->v.get())${access}${member}) ? 0 : -1;
+ $cname* _self_ = dynamic_cast<$cname*>(p->v.get());
+ if (_self_ == NULL)
+ {
+ failmsgp("Incorrect type of object (must be '${name}' or its derivative)");
+ return -1;
+ }
+ return pyopencv_to(value, _self_${access}${member}) ? 0 : -1;
}
""")
@@ -405,7 +418,9 @@ class FuncVariant(object):
self.name = self.wname = name
self.isconstructor = isconstructor
- self.rettype = decl[4] if len(decl) >=5 else handle_ptr(decl[1])
+ self.docstring = decl[5]
+
+ self.rettype = decl[4] or handle_ptr(decl[1])
if self.rettype == "void":
self.rettype = ""
self.args = []
@@ -494,7 +509,7 @@ class FuncVariant(object):
else:
outstr = "None"
- self.py_docstring = "%s(%s) -> %s" % (self.wname, argstr, outstr)
+ self.py_prototype = "%s(%s) -> %s" % (self.wname, argstr, outstr)
self.py_noptargs = noptargs
self.py_arglist = arglist
for aname, argno in arglist:
@@ -536,28 +551,49 @@ class FuncInfo(object):
return "static PyObject* %s(PyObject* %s, PyObject* args, PyObject* kw)" % (full_fname, self_arg)
def get_tab_entry(self):
+ prototype_list = []
docstring_list = []
+
have_empty_constructor = False
for v in self.variants:
- s = v.py_docstring
+ s = v.py_prototype
if (not v.py_arglist) and self.isconstructor:
have_empty_constructor = True
- if s not in docstring_list:
- docstring_list.append(s)
+ if s not in prototype_list:
+ prototype_list.append(s)
+ docstring_list.append(v.docstring)
+
# if there are just 2 constructors: default one and some other,
# we simplify the notation.
# Instead of ClassName(args ...) -> object or ClassName() -> object
# we write ClassName([args ...]) -> object
if have_empty_constructor and len(self.variants) == 2:
idx = self.variants[1].py_arglist != []
- s = self.variants[idx].py_docstring
+ s = self.variants[idx].py_prototype
p1 = s.find("(")
p2 = s.rfind(")")
- docstring_list = [s[:p1+1] + "[" + s[p1+1:p2] + "]" + s[p2:]]
+ prototype_list = [s[:p1+1] + "[" + s[p1+1:p2] + "]" + s[p2:]]
+
+ # The final docstring will be: Each prototype, followed by
+ # their relevant doxygen comment
+ full_docstring = ""
+ for prototype, body in zip(prototype_list, docstring_list):
+ full_docstring += Template("$prototype\n$docstring\n\n\n\n").substitute(
+ prototype=prototype,
+ docstring='\n'.join(
+ ['. ' + line
+ for line in body.split('\n')]
+ )
+ )
+
+ # Escape backslashes, newlines, and double quotes
+ full_docstring = full_docstring.strip().replace("\\", "\\\\").replace('\n', '\\n').replace("\"", "\\\"")
+ # Convert unicode chars to xml representation, but keep as string instead of bytes
+ full_docstring = full_docstring.encode('ascii', errors='xmlcharrefreplace').decode()
return Template(' {"$py_funcname", (PyCFunction)$wrap_funcname, METH_VARARGS | METH_KEYWORDS, "$py_docstring"},\n'
).substitute(py_funcname = self.variants[0].wname, wrap_funcname=self.get_wrapper_name(),
- py_docstring = " or ".join(docstring_list))
+ py_docstring = full_docstring)
def gen_code(self, all_classes):
proto = self.get_wrapper_prototype()
@@ -954,6 +990,6 @@ if __name__ == "__main__":
if len(sys.argv) > 1:
dstdir = sys.argv[1]
if len(sys.argv) > 2:
- srcfiles = open(sys.argv[2], 'r').read().split(';')
+ srcfiles = [f.strip() for f in open(sys.argv[2], 'r').readlines()]
generator = PythonWrapperGenerator()
generator.gen(srcfiles, dstdir)
diff --git a/modules/python/src2/hdr_parser.py b/modules/python/src2/hdr_parser.py
index da90d80..0999a43 100755
--- a/modules/python/src2/hdr_parser.py
+++ b/modules/python/src2/hdr_parser.py
@@ -21,12 +21,13 @@ opencv_hdr_list = [
]
"""
-Each declaration is [funcname, return_value_type /* in C, not in Python */, <list_of_modifiers>, <list_of_arguments>],
+Each declaration is [funcname, return_value_type /* in C, not in Python */, <list_of_modifiers>, <list_of_arguments>, original_return_type, docstring],
where each element of <list_of_arguments> is 4-element list itself:
[argtype, argname, default_value /* or "" if none */, <list_of_modifiers>]
where the list of modifiers is yet another nested list of strings
(currently recognized are "/O" for output argument, "/S" for static (i.e. class) methods
and "/A value" for the plain C arrays with counters)
+original_return_type is None if the original_return_type is the same as return_value_type
"""
class CppHeaderParser(object):
@@ -226,7 +227,7 @@ class CppHeaderParser(object):
else:
prev_val_delta = 0
prev_val = val = pv[1].strip()
- decl.append(["const " + self.get_dotted_name(pv[0].strip()), val, [], []])
+ decl.append(["const " + self.get_dotted_name(pv[0].strip()), val, [], [], None, ""])
return decl
def parse_class_decl(self, decl_str):
@@ -256,7 +257,7 @@ class CppHeaderParser(object):
bases = ll[2:]
return classname, bases, modlist
- def parse_func_decl_no_wrap(self, decl_str, static_method = False):
+ def parse_func_decl_no_wrap(self, decl_str, static_method=False, docstring=""):
decl_str = (decl_str or "").strip()
virtual_method = False
explicit_method = False
@@ -299,7 +300,7 @@ class CppHeaderParser(object):
apos = fdecl.find("(", apos+1)
fname = "cv." + fname.replace("::", ".")
- decl = [fname, rettype, [], []]
+ decl = [fname, rettype, [], [], None, docstring]
# inline constructor implementation
implmatch = re.match(r"(\(.*?\))\s*:\s*(\w+\(.*?\),?\s*)+", fdecl[apos:])
@@ -370,7 +371,7 @@ class CppHeaderParser(object):
print(decl_str)
return decl
- def parse_func_decl(self, decl_str, use_umat=False):
+ def parse_func_decl(self, decl_str, use_umat=False, docstring=""):
"""
Parses the function or method declaration in the form:
[([CV_EXPORTS] <rettype>) | CVAPI(rettype)]
@@ -379,7 +380,7 @@ class CppHeaderParser(object):
[const] {; | <function_body>}
Returns the function declaration entry:
- [<func name>, <return value C-type>, <list of modifiers>, <list of arguments>] (see above)
+ [<func name>, <return value C-type>, <list of modifiers>, <list of arguments>, <original return type>, <docstring>] (see above)
"""
if self.wrap_mode:
@@ -484,7 +485,7 @@ class CppHeaderParser(object):
funcname = self.get_dotted_name(funcname)
if not self.wrap_mode:
- decl = self.parse_func_decl_no_wrap(decl_str, static_method)
+ decl = self.parse_func_decl_no_wrap(decl_str, static_method, docstring)
decl[0] = funcname
return decl
@@ -574,10 +575,7 @@ class CppHeaderParser(object):
if static_method:
func_modlist.append("/S")
- if original_type is None:
- return [funcname, rettype, func_modlist, args]
- else:
- return [funcname, rettype, func_modlist, args, original_type]
+ return [funcname, rettype, func_modlist, args, original_type, docstring]
def get_dotted_name(self, name):
"""
@@ -612,7 +610,7 @@ class CppHeaderParser(object):
n = "cv.Algorithm"
return n
- def parse_stmt(self, stmt, end_token, use_umat=False):
+ def parse_stmt(self, stmt, end_token, use_umat=False, docstring=""):
"""
parses the statement (ending with ';' or '}') or a block head (ending with '{')
@@ -659,7 +657,7 @@ class CppHeaderParser(object):
exit(1)
if classname.startswith("_Ipl"):
classname = classname[1:]
- decl = [stmt_type + " " + self.get_dotted_name(classname), "", modlist, []]
+ decl = [stmt_type + " " + self.get_dotted_name(classname), "", modlist, [], None, docstring]
if bases:
decl[1] = ": " + ", ".join([self.get_dotted_name(b).replace(".","::") for b in bases])
return stmt_type, classname, True, decl
@@ -674,7 +672,7 @@ class CppHeaderParser(object):
exit(1)
decl = []
if ("CV_EXPORTS_W" in stmt) or ("CV_EXPORTS_AS" in stmt) or (not self.wrap_mode):# and ("CV_EXPORTS" in stmt)):
- decl = [stmt_type + " " + self.get_dotted_name(classname), "", modlist, []]
+ decl = [stmt_type + " " + self.get_dotted_name(classname), "", modlist, [], None, docstring]
if bases:
decl[1] = ": " + ", ".join([self.get_dotted_name(b).replace(".","::") for b in bases])
return stmt_type, classname, True, decl
@@ -704,7 +702,7 @@ class CppHeaderParser(object):
# since we filtered off the other places where '(' can normally occur:
# - code blocks
# - function pointer typedef's
- decl = self.parse_func_decl(stmt, use_umat=use_umat)
+ decl = self.parse_func_decl(stmt, use_umat=use_umat, docstring=docstring)
# we return parse_flag == False to prevent the parser to look inside function/method bodies
# (except for tracking the nested blocks)
return stmt_type, "", False, decl
@@ -759,17 +757,19 @@ class CppHeaderParser(object):
SCAN = 0 # outside of a comment or preprocessor directive
COMMENT = 1 # inside a multi-line comment
DIRECTIVE = 2 # inside a multi-line preprocessor directive
+ DOCSTRING = 3 # inside a multi-line docstring
state = SCAN
self.block_stack = [["file", hname, True, True, None]]
block_head = ""
+ docstring = ""
self.lineno = 0
self.wrap_mode = wmode
for l0 in linelist:
self.lineno += 1
- #print self.lineno
+ #print(state, self.lineno, l0)
l = l0.strip()
@@ -789,8 +789,22 @@ class CppHeaderParser(object):
l = l[pos+2:]
state = SCAN
+ if state == DOCSTRING:
+ pos = l.find("*/")
+ if pos < 0:
+ docstring += l + "\n"
+ continue
+ docstring += l[:pos] + "\n"
+ l = l[pos+2:]
+ state = SCAN
+
+ if l.startswith('CV__'): # just ignore this lines
+ #print('IGNORE: ' + l)
+ state = SCAN
+ continue
+
if state != SCAN:
- print("Error at %d: invlid state = %d" % (self.lineno, state))
+ print("Error at %d: invalid state = %d" % (self.lineno, state))
sys.exit(-1)
while 1:
@@ -806,11 +820,20 @@ class CppHeaderParser(object):
if token == "/*":
block_head += " " + l[:pos]
- pos = l.find("*/", pos+2)
- if pos < 0:
+ end_pos = l.find("*/", pos+2)
+ if len(l) > pos + 2 and l[pos+2] == "*":
+ # '/**', it's a docstring
+ if end_pos < 0:
+ state = DOCSTRING
+ docstring = l[pos+3:] + "\n"
+ break
+ else:
+ docstring = l[pos+3:end_pos]
+
+ elif end_pos < 0:
state = COMMENT
break
- l = l[pos+2:]
+ l = l[end_pos+2:]
continue
if token == "\"":
@@ -830,6 +853,7 @@ class CppHeaderParser(object):
stmt = (block_head + " " + l[:pos]).strip()
stmt = " ".join(stmt.split()) # normalize the statement
+ #print(stmt)
stack_top = self.block_stack[-1]
if stmt.startswith("@"):
@@ -840,7 +864,8 @@ class CppHeaderParser(object):
if stack_top[self.PROCESS_FLAG]:
# even if stack_top[PUBLIC_SECTION] is False, we still try to process the statement,
# since it can start with "public:"
- stmt_type, name, parse_flag, decl = self.parse_stmt(stmt, token)
+ docstring = docstring.strip()
+ stmt_type, name, parse_flag, decl = self.parse_stmt(stmt, token, docstring=docstring)
if decl:
if stmt_type == "enum":
for d in decl:
@@ -854,8 +879,9 @@ class CppHeaderParser(object):
args = decl[3]
has_mat = len(list(filter(lambda x: x[0] in {"Mat", "vector_Mat"}, args))) > 0
if has_mat:
- _, _, _, umat_decl = self.parse_stmt(stmt, token, use_umat=True)
+ _, _, _, umat_decl = self.parse_stmt(stmt, token, use_umat=True, docstring=docstring)
decls.append(umat_decl)
+ docstring = ""
if stmt_type == "namespace":
chunks = [block[1] for block in self.block_stack if block[0] == 'namespace'] + [name]
self.namespaces.add('.'.join(chunks))
@@ -887,6 +913,8 @@ class CppHeaderParser(object):
"""
for d in decls:
print(d[0], d[1], ";".join(d[2]))
+ # Uncomment below line to see docstrings
+ # print('"""\n' + d[5] + '\n"""')
for a in d[3]:
print(" ", a[0], a[1], a[2], end="")
if a[3]:
diff --git a/modules/python/test/test.py b/modules/python/test/test.py
index 5a66769..be3f821 100755
--- a/modules/python/test/test.py
+++ b/modules/python/test/test.py
@@ -123,6 +123,26 @@ class Hackathon244Tests(NewOpenCVTests):
boost.getMaxDepth() # from ml::DTrees
boost.isClassifier() # from ml::StatModel
+ def test_umat_construct(self):
+ data = np.random.random([512, 512])
+ # UMat constructors
+ data_um = cv2.UMat(data) # from ndarray
+ data_sub_um = cv2.UMat(data_um, [128, 256], [128, 256]) # from UMat
+ data_dst_um = cv2.UMat(128, 128, cv2.CV_64F) # from size/type
+ # test continuous and submatrix flags
+ assert data_um.isContinuous() and not data_um.isSubmatrix()
+ assert not data_sub_um.isContinuous() and data_sub_um.isSubmatrix()
+ # test operation on submatrix
+ cv2.multiply(data_sub_um, 2., dst=data_dst_um)
+ assert np.allclose(2. * data[128:256, 128:256], data_dst_um.get())
+
+ def test_umat_handle(self):
+ a_um = cv2.UMat(256, 256, cv2.CV_32F)
+ ctx_handle = cv2.UMat.context() # obtain context handle
+ queue_handle = cv2.UMat.queue() # obtain queue handle
+ a_handle = a_um.handle(cv2.ACCESS_READ) # obtain buffer handle
+ offset = a_um.offset # obtain buffer offset
+
def test_umat_matching(self):
img1 = self.get_sample("samples/data/right01.jpg")
img2 = self.get_sample("samples/data/right02.jpg")
diff --git a/modules/python/test/test_shape.py b/modules/python/test/test_shape.py
new file mode 100644
index 0000000..ad0f0be
--- /dev/null
+++ b/modules/python/test/test_shape.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+import cv2
+
+from tests_common import NewOpenCVTests
+
+class shape_test(NewOpenCVTests):
+
+ def test_computeDistance(self):
+
+ a = self.get_sample('samples/data/shape_sample/1.png', cv2.IMREAD_GRAYSCALE);
+ b = self.get_sample('samples/data/shape_sample/2.png', cv2.IMREAD_GRAYSCALE);
+
+ _, ca, _ = cv2.findContours(a, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_TC89_KCOS)
+ _, cb, _ = cv2.findContours(b, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_TC89_KCOS)
+
+ hd = cv2.createHausdorffDistanceExtractor()
+ sd = cv2.createShapeContextDistanceExtractor()
+
+ d1 = hd.computeDistance(ca[0], cb[0])
+ d2 = sd.computeDistance(ca[0], cb[0])
+
+ self.assertAlmostEqual(d1, 26.4196891785, 3, "HausdorffDistanceExtractor")
+ self.assertAlmostEqual(d2, 0.25804194808, 3, "ShapeContextDistanceExtractor")
diff --git a/modules/python/test/test_stitching.py b/modules/python/test/test_stitching.py
new file mode 100644
index 0000000..9a35357
--- /dev/null
+++ b/modules/python/test/test_stitching.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+import cv2
+
+from tests_common import NewOpenCVTests
+
+class stitching_test(NewOpenCVTests):
+
+ def test_simple(self):
+
+ img1 = self.get_sample('stitching/a1.png')
+ img2 = self.get_sample('stitching/a2.png')
+
+ stitcher = cv2.createStitcher(False)
+ (result, pano) = stitcher.stitch((img1, img2))
+
+ #cv2.imshow("pano", pano)
+ #cv2.waitKey()
+
+ self.assertAlmostEqual(pano.shape[0], 685, delta=100, msg="rows: %r" % list(pano.shape))
+ self.assertAlmostEqual(pano.shape[1], 1025, delta=100, msg="cols: %r" % list(pano.shape))
diff --git a/modules/shape/CMakeLists.txt b/modules/shape/CMakeLists.txt
index fcd3170..527a0c2 100644
--- a/modules/shape/CMakeLists.txt
+++ b/modules/shape/CMakeLists.txt
@@ -1,2 +1,2 @@
-set(the_description "Shape descriptors and matchers.")
+set(the_description "Shape descriptors and matchers")
ocv_define_module(shape opencv_core opencv_imgproc opencv_video WRAP python)
diff --git a/modules/shape/include/opencv2/shape/shape_distance.hpp b/modules/shape/include/opencv2/shape/shape_distance.hpp
index e4c3a87..3a778f0 100644
--- a/modules/shape/include/opencv2/shape/shape_distance.hpp
+++ b/modules/shape/include/opencv2/shape/shape_distance.hpp
@@ -53,6 +53,9 @@ namespace cv
//! @addtogroup shape
//! @{
+/** @example shape_example.cpp
+An example using shape distance algorithm
+*/
/** @brief Abstract base class for shape distance algorithms.
*/
class CV_EXPORTS_W ShapeDistanceExtractor : public Algorithm
diff --git a/modules/shape/src/aff_trans.cpp b/modules/shape/src/aff_trans.cpp
index bbcd8ab..888d634 100644
--- a/modules/shape/src/aff_trans.cpp
+++ b/modules/shape/src/aff_trans.cpp
@@ -53,12 +53,14 @@ public:
{
fullAffine = true;
name_ = "ShapeTransformer.AFF";
+ transformCost = 0;
}
AffineTransformerImpl(bool _fullAffine)
{
fullAffine = _fullAffine;
name_ = "ShapeTransformer.AFF";
+ transformCost = 0;
}
/* Destructor */
diff --git a/modules/shape/src/emdL1.cpp b/modules/shape/src/emdL1.cpp
index 7baa97f..cfb71ff 100644
--- a/modules/shape/src/emdL1.cpp
+++ b/modules/shape/src/emdL1.cpp
@@ -494,6 +494,7 @@ void EmdL1::initBVTree()
}
if(pNxtN != pCurN->pParent)
{
+ CV_Assert(pNxtN != NULL);
pNxtE = pNxtN->pChild;
if(pNxtE && pNxtE->pChild==pCurN) // has connection
{
@@ -592,6 +593,7 @@ void EmdL1::findNewSolution()
findLoopFromEnterBV();
// Modify flow values along the loop
cvPEmdEdge pE = NULL;
+ CV_Assert(m_pLeave != NULL);
float minFlow = m_pLeave->flow;
int k;
for(k=0; k<m_iFrom; k++)
diff --git a/modules/shape/src/emdL1_def.hpp b/modules/shape/src/emdL1_def.hpp
index 38f78cc..a5031b1 100644
--- a/modules/shape/src/emdL1_def.hpp
+++ b/modules/shape/src/emdL1_def.hpp
@@ -90,6 +90,14 @@ public:
binsDim3 = 0;
dimension = 0;
nMaxIt = 500;
+
+ m_pLeave = 0;
+ m_iEnter = 0;
+ nNBV = 0;
+ m_nItr = 0;
+ m_iTo = 0;
+ m_iFrom = 0;
+ m_pEnter = 0;
}
~EmdL1()
diff --git a/modules/shape/src/haus_dis.cpp b/modules/shape/src/haus_dis.cpp
index 6f372c4..732f288 100644
--- a/modules/shape/src/haus_dis.cpp
+++ b/modules/shape/src/haus_dis.cpp
@@ -138,6 +138,13 @@ float HausdorffDistanceExtractorImpl::computeDistance(InputArray contour1, Input
set2.convertTo(set2, CV_32F);
CV_Assert((set1.channels()==2) && (set1.cols>0));
CV_Assert((set2.channels()==2) && (set2.cols>0));
+
+ // Force vectors column-based
+ if (set1.dims > 1)
+ set1 = set1.reshape(2, 1);
+ if (set2.dims > 1)
+ set2 = set2.reshape(2, 1);
+
return std::max( _apply(set1, set2, distanceFlag, rankProportion),
_apply(set2, set1, distanceFlag, rankProportion) );
}
diff --git a/modules/shape/src/precomp.cpp b/modules/shape/src/precomp.cpp
deleted file mode 100644
index 730edbb..0000000
--- a/modules/shape/src/precomp.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-/* End of file. */
diff --git a/modules/shape/src/sc_dis.cpp b/modules/shape/src/sc_dis.cpp
index 89c6d91..ecdcace 100644
--- a/modules/shape/src/sc_dis.cpp
+++ b/modules/shape/src/sc_dis.cpp
@@ -72,6 +72,7 @@ public:
shapeContextWeight=1.0f;
sigma=10.0f;
name_ = "ShapeDistanceExtractor.SCD";
+ costFlag = 0;
}
/* Destructor */
@@ -202,6 +203,13 @@ float ShapeContextDistanceExtractorImpl::computeDistance(InputArray contour1, In
CV_Assert((set1.channels()==2) && (set1.cols>0));
CV_Assert((set2.channels()==2) && (set2.cols>0));
+
+ // Force vectors column-based
+ if (set1.dims > 1)
+ set1 = set1.reshape(2, 1);
+ if (set2.dims > 1)
+ set2 = set2.reshape(2, 1);
+
if (imageAppearanceWeight!=0)
{
CV_Assert((!image1.empty()) && (!image2.empty()));
diff --git a/modules/shape/src/scd_def.hpp b/modules/shape/src/scd_def.hpp
index d5bb5e4..882ef00 100644
--- a/modules/shape/src/scd_def.hpp
+++ b/modules/shape/src/scd_def.hpp
@@ -61,6 +61,7 @@ public:
setInnerRadius(_innerRadius);
setOuterRadius(_outerRadius);
setRotationInvariant(_rotationInvariant);
+ meanDistance = 0;
}
void extractSCD(cv::Mat& contour, cv::Mat& descriptors,
@@ -107,7 +108,7 @@ class SCDMatcher
{
public:
// the full constructor
- SCDMatcher()
+ SCDMatcher() : minMatchCost(0)
{
}
diff --git a/modules/shape/src/tps_trans.cpp b/modules/shape/src/tps_trans.cpp
index 06cc6d7..ea5a364 100644
--- a/modules/shape/src/tps_trans.cpp
+++ b/modules/shape/src/tps_trans.cpp
@@ -54,6 +54,7 @@ public:
regularizationParameter=0;
name_ = "ShapeTransformer.TPS";
tpsComputed=false;
+ transformCost = 0;
}
ThinPlateSplineShapeTransformerImpl(double _regularizationParameter)
@@ -61,6 +62,7 @@ public:
regularizationParameter=_regularizationParameter;
name_ = "ShapeTransformer.TPS";
tpsComputed=false;
+ transformCost = 0;
}
/* Destructor */
diff --git a/modules/shape/test/test_shape.cpp b/modules/shape/test/test_shape.cpp
index 0601594..2495320 100644
--- a/modules/shape/test/test_shape.cpp
+++ b/modules/shape/test/test_shape.cpp
@@ -83,6 +83,9 @@ protected:
vector<PointType> convertContourType(const Mat& currentQuery) const
{
+ if (currentQuery.empty()) {
+ return vector<PointType>();
+ }
vector<vector<Point> > _contoursQuery;
findContours(currentQuery, _contoursQuery, RETR_LIST, CHAIN_APPROX_NONE);
@@ -299,3 +302,22 @@ TEST(Hauss, regression)
ShapeBaseTest<int, computeShapeDistance_Haussdorf> test(NSN_val, NP_val, CURRENT_MAX_ACCUR_val);
test.safe_run();
}
+
+TEST(computeDistance, regression_4976)
+{
+ Mat a = imread(cvtest::findDataFile("shape/samples/1.png"), 0);
+ Mat b = imread(cvtest::findDataFile("shape/samples/2.png"), 0);
+
+ vector<vector<Point> > ca,cb;
+ findContours(a, ca, cv::RETR_CCOMP, cv::CHAIN_APPROX_TC89_KCOS);
+ findContours(b, cb, cv::RETR_CCOMP, cv::CHAIN_APPROX_TC89_KCOS);
+
+ Ptr<HausdorffDistanceExtractor> hd = createHausdorffDistanceExtractor();
+ Ptr<ShapeContextDistanceExtractor> sd = createShapeContextDistanceExtractor();
+
+ double d1 = hd->computeDistance(ca[0],cb[0]);
+ double d2 = sd->computeDistance(ca[0],cb[0]);
+
+ EXPECT_NEAR(d1, 26.4196891785, 1e-3) << "HausdorffDistanceExtractor";
+ EXPECT_NEAR(d2, 0.25804194808, 1e-3) << "ShapeContextDistanceExtractor";
+}
diff --git a/modules/stitching/CMakeLists.txt b/modules/stitching/CMakeLists.txt
index 76c7bc8..7dfdd08 100644
--- a/modules/stitching/CMakeLists.txt
+++ b/modules/stitching/CMakeLists.txt
@@ -5,9 +5,9 @@ if(HAVE_CUDA)
endif()
set(STITCHING_CONTRIB_DEPS "opencv_xfeatures2d")
-if(BUILD_SHARED_LIBS AND BUILD_opencv_world)
+if(BUILD_SHARED_LIBS AND BUILD_opencv_world AND OPENCV_WORLD_EXCLUDE_EXTRA_MODULES)
set(STITCHING_CONTRIB_DEPS "")
endif()
-ocv_define_module(stitching opencv_imgproc opencv_features2d opencv_calib3d opencv_objdetect
- OPTIONAL opencv_cudaarithm opencv_cudafilters opencv_cudafeatures2d opencv_cudalegacy ${STITCHING_CONTRIB_DEPS}
+ocv_define_module(stitching opencv_imgproc opencv_features2d opencv_calib3d
+ OPTIONAL opencv_cudaarithm opencv_cudawarping opencv_cudafeatures2d opencv_cudalegacy ${STITCHING_CONTRIB_DEPS}
WRAP python)
diff --git a/modules/stitching/include/opencv2/stitching/detail/blenders.hpp b/modules/stitching/include/opencv2/stitching/detail/blenders.hpp
index 4ccaa70..c89e003 100644
--- a/modules/stitching/include/opencv2/stitching/detail/blenders.hpp
+++ b/modules/stitching/include/opencv2/stitching/detail/blenders.hpp
@@ -142,6 +142,10 @@ private:
Rect dst_roi_final_;
bool can_use_gpu_;
int weight_type_; //CV_32F or CV_16S
+#if defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING)
+ std::vector<cuda::GpuMat> gpu_dst_pyr_laplace_;
+ std::vector<cuda::GpuMat> gpu_dst_band_weights_;
+#endif
};
diff --git a/modules/stitching/include/opencv2/stitching/detail/motion_estimators.hpp b/modules/stitching/include/opencv2/stitching/detail/motion_estimators.hpp
index 5276fd1..a0e6900 100644
--- a/modules/stitching/include/opencv2/stitching/detail/motion_estimators.hpp
+++ b/modules/stitching/include/opencv2/stitching/detail/motion_estimators.hpp
@@ -149,8 +149,10 @@ protected:
@param num_errs_per_measurement Number of error terms (components) per match
*/
BundleAdjusterBase(int num_params_per_cam, int num_errs_per_measurement)
- : num_params_per_cam_(num_params_per_cam),
- num_errs_per_measurement_(num_errs_per_measurement)
+ : num_images_(0), total_num_matches_(0),
+ num_params_per_cam_(num_params_per_cam),
+ num_errs_per_measurement_(num_errs_per_measurement),
+ features_(0), pairwise_matches_(0), conf_thresh_(0)
{
setRefinementMask(Mat::ones(3, 3, CV_8U));
setConfThresh(1.);
@@ -199,7 +201,7 @@ protected:
// Threshold to filter out poorly matched image pairs
double conf_thresh_;
- //Levenberg–Marquardt algorithm termination criteria
+ //Levenberg-Marquardt algorithm termination criteria
TermCriteria term_criteria_;
// Camera parameters matrix (CV_64F)
diff --git a/modules/stitching/include/opencv2/stitching/detail/warpers.hpp b/modules/stitching/include/opencv2/stitching/detail/warpers.hpp
index 1515d76..cfaf225 100644
--- a/modules/stitching/include/opencv2/stitching/detail/warpers.hpp
+++ b/modules/stitching/include/opencv2/stitching/detail/warpers.hpp
@@ -243,7 +243,7 @@ struct CV_EXPORTS SphericalProjector : ProjectorBase
/** @brief Warper that maps an image onto the unit sphere located at the origin.
Projects image onto unit sphere with origin at (0, 0, 0) and radius scale, measured in pixels.
- A 360° panorama would therefore have a resulting width of 2 * scale * PI pixels.
+ A 360 panorama would therefore have a resulting width of 2 * scale * PI pixels.
Poles are located at (0, -1, 0) and (0, 1, 0) points.
*/
class CV_EXPORTS SphericalWarper : public RotationWarperBase<SphericalProjector>
diff --git a/modules/stitching/perf/opencl/perf_stitch.cpp b/modules/stitching/perf/opencl/perf_stitch.cpp
index 8b25c50..314e5a0 100644
--- a/modules/stitching/perf/opencl/perf_stitch.cpp
+++ b/modules/stitching/perf/opencl/perf_stitch.cpp
@@ -24,9 +24,9 @@ using namespace std::tr1;
typedef TestBaseWithParam<string> stitch;
#ifdef HAVE_OPENCV_XFEATURES2D
-#define TEST_DETECTORS testing::Values("surf", "orb")
+#define TEST_DETECTORS testing::Values("surf", "orb", "akaze")
#else
-#define TEST_DETECTORS testing::Values<string>("orb")
+#define TEST_DETECTORS testing::Values("orb", "akaze")
#endif
OCL_PERF_TEST_P(stitch, a123, TEST_DETECTORS)
@@ -39,10 +39,7 @@ OCL_PERF_TEST_P(stitch, a123, TEST_DETECTORS)
_imgs.push_back( imread( getDataPath("stitching/a3.png") ) );
vector<UMat> imgs = ToUMat(_imgs);
- Ptr<detail::FeaturesFinder> featuresFinder = GetParam() == "orb"
- ? Ptr<detail::FeaturesFinder>(new detail::OrbFeaturesFinder())
- : Ptr<detail::FeaturesFinder>(new detail::SurfFeaturesFinder());
-
+ Ptr<detail::FeaturesFinder> featuresFinder = getFeatureFinder(GetParam());
Ptr<detail::FeaturesMatcher> featuresMatcher = GetParam() == "orb"
? makePtr<detail::BestOf2NearestMatcher>(false, ORB_MATCH_CONFIDENCE)
: makePtr<detail::BestOf2NearestMatcher>(false, SURF_MATCH_CONFIDENCE);
@@ -76,10 +73,7 @@ OCL_PERF_TEST_P(stitch, b12, TEST_DETECTORS)
imgs.push_back( imread( getDataPath("stitching/b1.png") ) );
imgs.push_back( imread( getDataPath("stitching/b2.png") ) );
- Ptr<detail::FeaturesFinder> featuresFinder = GetParam() == "orb"
- ? Ptr<detail::FeaturesFinder>(new detail::OrbFeaturesFinder())
- : Ptr<detail::FeaturesFinder>(new detail::SurfFeaturesFinder());
-
+ Ptr<detail::FeaturesFinder> featuresFinder = getFeatureFinder(GetParam());
Ptr<detail::FeaturesMatcher> featuresMatcher = GetParam() == "orb"
? makePtr<detail::BestOf2NearestMatcher>(false, ORB_MATCH_CONFIDENCE)
: makePtr<detail::BestOf2NearestMatcher>(false, SURF_MATCH_CONFIDENCE);
@@ -107,6 +101,14 @@ OCL_PERF_TEST_P(stitch, b12, TEST_DETECTORS)
OCL_PERF_TEST_P(stitch, boat, TEST_DETECTORS)
{
+ Size expected_dst_size(10789, 2663);
+ checkDeviceMaxMemoryAllocSize(expected_dst_size, CV_16SC3, 4);
+
+#if defined(_WIN32) && !defined(_WIN64)
+ if (cv::ocl::useOpenCL())
+ throw ::perf::TestBase::PerfSkipTestException();
+#endif
+
UMat pano;
vector<Mat> _imgs;
@@ -118,10 +120,7 @@ OCL_PERF_TEST_P(stitch, boat, TEST_DETECTORS)
_imgs.push_back( imread( getDataPath("stitching/boat6.jpg") ) );
vector<UMat> imgs = ToUMat(_imgs);
- Ptr<detail::FeaturesFinder> featuresFinder = GetParam() == "orb"
- ? Ptr<detail::FeaturesFinder>(new detail::OrbFeaturesFinder())
- : Ptr<detail::FeaturesFinder>(new detail::SurfFeaturesFinder());
-
+ Ptr<detail::FeaturesFinder> featuresFinder = getFeatureFinder(GetParam());
Ptr<detail::FeaturesMatcher> featuresMatcher = GetParam() == "orb"
? makePtr<detail::BestOf2NearestMatcher>(false, ORB_MATCH_CONFIDENCE)
: makePtr<detail::BestOf2NearestMatcher>(false, SURF_MATCH_CONFIDENCE);
@@ -141,8 +140,8 @@ OCL_PERF_TEST_P(stitch, boat, TEST_DETECTORS)
stopTimer();
}
- EXPECT_NEAR(pano.size().width, 10789, 200);
- EXPECT_NEAR(pano.size().height, 2663, 100);
+ EXPECT_NEAR(pano.size().width, expected_dst_size.width, 200);
+ EXPECT_NEAR(pano.size().height, expected_dst_size.height, 100);
SANITY_CHECK_NOTHING();
}
diff --git a/modules/stitching/perf/perf_precomp.hpp b/modules/stitching/perf/perf_precomp.hpp
index ba34acb..9e52cc7 100644
--- a/modules/stitching/perf/perf_precomp.hpp
+++ b/modules/stitching/perf/perf_precomp.hpp
@@ -16,4 +16,21 @@
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
#endif
+namespace cv
+{
+
+static inline Ptr<detail::FeaturesFinder> getFeatureFinder(const std::string& name)
+{
+ if (name == "orb")
+ return makePtr<detail::OrbFeaturesFinder>();
+ else if (name == "surf")
+ return makePtr<detail::SurfFeaturesFinder>();
+ else if (name == "akaze")
+ return makePtr<detail::AKAZEFeaturesFinder>();
+ else
+ return Ptr<detail::FeaturesFinder>();
+}
+
+} // namespace cv
+
#endif
diff --git a/modules/stitching/perf/perf_stich.cpp b/modules/stitching/perf/perf_stich.cpp
index ded2571..f0ac656 100644
--- a/modules/stitching/perf/perf_stich.cpp
+++ b/modules/stitching/perf/perf_stich.cpp
@@ -2,6 +2,8 @@
#include "opencv2/imgcodecs.hpp"
#include "opencv2/opencv_modules.hpp"
+#include "opencv2/core/ocl.hpp"
+
using namespace std;
using namespace cv;
using namespace perf;
@@ -16,9 +18,9 @@ typedef TestBaseWithParam<string> stitch;
typedef TestBaseWithParam<tuple<string, string> > stitchDatasets;
#ifdef HAVE_OPENCV_XFEATURES2D
-#define TEST_DETECTORS testing::Values("surf", "orb")
+#define TEST_DETECTORS testing::Values("surf", "orb", "akaze")
#else
-#define TEST_DETECTORS testing::Values<string>("orb")
+#define TEST_DETECTORS testing::Values("orb", "akaze")
#endif
#define AFFINE_DATASETS testing::Values("s", "budapest", "newspaper", "prague")
@@ -31,9 +33,7 @@ PERF_TEST_P(stitch, a123, TEST_DETECTORS)
imgs.push_back( imread( getDataPath("stitching/a2.png") ) );
imgs.push_back( imread( getDataPath("stitching/a3.png") ) );
- Ptr<detail::FeaturesFinder> featuresFinder = GetParam() == "orb"
- ? Ptr<detail::FeaturesFinder>(new detail::OrbFeaturesFinder())
- : Ptr<detail::FeaturesFinder>(new detail::SurfFeaturesFinder());
+ Ptr<detail::FeaturesFinder> featuresFinder = getFeatureFinder(GetParam());
Ptr<detail::FeaturesMatcher> featuresMatcher = GetParam() == "orb"
? makePtr<detail::BestOf2NearestMatcher>(false, ORB_MATCH_CONFIDENCE)
@@ -68,9 +68,7 @@ PERF_TEST_P(stitch, b12, TEST_DETECTORS)
imgs.push_back( imread( getDataPath("stitching/b1.png") ) );
imgs.push_back( imread( getDataPath("stitching/b2.png") ) );
- Ptr<detail::FeaturesFinder> featuresFinder = GetParam() == "orb"
- ? Ptr<detail::FeaturesFinder>(new detail::OrbFeaturesFinder())
- : Ptr<detail::FeaturesFinder>(new detail::SurfFeaturesFinder());
+ Ptr<detail::FeaturesFinder> featuresFinder = getFeatureFinder(GetParam());
Ptr<detail::FeaturesMatcher> featuresMatcher = GetParam() == "orb"
? makePtr<detail::BestOf2NearestMatcher>(false, ORB_MATCH_CONFIDENCE)
@@ -104,13 +102,8 @@ PERF_TEST_P(stitchDatasets, affine, testing::Combine(AFFINE_DATASETS, TEST_DETEC
Mat pano;
vector<Mat> imgs;
- int width, height, allowed_diff = 10;
- Ptr<detail::FeaturesFinder> featuresFinder;
-
- if(detector == "orb")
- featuresFinder = makePtr<detail::OrbFeaturesFinder>();
- else
- featuresFinder = makePtr<detail::SurfFeaturesFinder>();
+ int width, height, allowed_diff = 20;
+ Ptr<detail::FeaturesFinder> featuresFinder = getFeatureFinder(detector);
if(dataset == "budapest")
{
@@ -124,7 +117,7 @@ PERF_TEST_P(stitchDatasets, affine, testing::Combine(AFFINE_DATASETS, TEST_DETEC
height = 1158;
// this dataset is big, the results between surf and orb differ slightly,
// but both are still good
- allowed_diff = 27;
+ allowed_diff = 50;
}
else if (dataset == "newspaper")
{
@@ -161,6 +154,9 @@ PERF_TEST_P(stitchDatasets, affine, testing::Combine(AFFINE_DATASETS, TEST_DETEC
Ptr<Stitcher> stitcher = Stitcher::create(Stitcher::SCANS, false);
stitcher->setFeaturesFinder(featuresFinder);
+ if (cv::ocl::useOpenCL())
+ cv::theRNG() = cv::RNG(12345); // prevent fails of Windows OpenCL builds (see #8294)
+
startTimer();
stitcher->stitch(imgs, pano);
stopTimer();
diff --git a/modules/stitching/src/blenders.cpp b/modules/stitching/src/blenders.cpp
index 1d2fe9e..858c150 100644
--- a/modules/stitching/src/blenders.cpp
+++ b/modules/stitching/src/blenders.cpp
@@ -43,6 +43,23 @@
#include "precomp.hpp"
#include "opencl_kernels_stitching.hpp"
+#ifdef HAVE_CUDA
+ namespace cv { namespace cuda { namespace device
+ {
+ namespace blend
+ {
+ void addSrcWeightGpu16S(const PtrStep<short> src, const PtrStep<short> src_weight,
+ PtrStep<short> dst, PtrStep<short> dst_weight, cv::Rect &rc);
+ void addSrcWeightGpu32F(const PtrStep<short> src, const PtrStepf src_weight,
+ PtrStep<short> dst, PtrStepf dst_weight, cv::Rect &rc);
+ void normalizeUsingWeightMapGpu16S(const PtrStep<short> weight, PtrStep<short> src,
+ const int width, const int height);
+ void normalizeUsingWeightMapGpu32F(const PtrStepf weight, PtrStep<short> src,
+ const int width, const int height);
+ }
+ }}}
+#endif
+
namespace cv {
namespace detail {
@@ -200,6 +217,7 @@ Rect FeatherBlender::createWeightMaps(const std::vector<UMat> &masks, const std:
MultiBandBlender::MultiBandBlender(int try_gpu, int num_bands, int weight_type)
{
+ num_bands_ = 0;
setNumBands(num_bands);
#if defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING)
@@ -228,21 +246,46 @@ void MultiBandBlender::prepare(Rect dst_roi)
Blender::prepare(dst_roi);
- dst_pyr_laplace_.resize(num_bands_ + 1);
- dst_pyr_laplace_[0] = dst_;
+#if defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING)
+ if (can_use_gpu_)
+ {
+ gpu_dst_pyr_laplace_.resize(num_bands_ + 1);
+ gpu_dst_pyr_laplace_[0].create(dst_roi.size(), CV_16SC3);
+ gpu_dst_pyr_laplace_[0].setTo(Scalar::all(0));
- dst_band_weights_.resize(num_bands_ + 1);
- dst_band_weights_[0].create(dst_roi.size(), weight_type_);
- dst_band_weights_[0].setTo(0);
+ gpu_dst_band_weights_.resize(num_bands_ + 1);
+ gpu_dst_band_weights_[0].create(dst_roi.size(), weight_type_);
+ gpu_dst_band_weights_[0].setTo(0);
- for (int i = 1; i <= num_bands_; ++i)
+ for (int i = 1; i <= num_bands_; ++i)
+ {
+ gpu_dst_pyr_laplace_[i].create((gpu_dst_pyr_laplace_[i - 1].rows + 1) / 2,
+ (gpu_dst_pyr_laplace_[i - 1].cols + 1) / 2, CV_16SC3);
+ gpu_dst_band_weights_[i].create((gpu_dst_band_weights_[i - 1].rows + 1) / 2,
+ (gpu_dst_band_weights_[i - 1].cols + 1) / 2, weight_type_);
+ gpu_dst_pyr_laplace_[i].setTo(Scalar::all(0));
+ gpu_dst_band_weights_[i].setTo(0);
+ }
+ }
+ else
+#endif
{
- dst_pyr_laplace_[i].create((dst_pyr_laplace_[i - 1].rows + 1) / 2,
- (dst_pyr_laplace_[i - 1].cols + 1) / 2, CV_16SC3);
- dst_band_weights_[i].create((dst_band_weights_[i - 1].rows + 1) / 2,
- (dst_band_weights_[i - 1].cols + 1) / 2, weight_type_);
- dst_pyr_laplace_[i].setTo(Scalar::all(0));
- dst_band_weights_[i].setTo(0);
+ dst_pyr_laplace_.resize(num_bands_ + 1);
+ dst_pyr_laplace_[0] = dst_;
+
+ dst_band_weights_.resize(num_bands_ + 1);
+ dst_band_weights_[0].create(dst_roi.size(), weight_type_);
+ dst_band_weights_[0].setTo(0);
+
+ for (int i = 1; i <= num_bands_; ++i)
+ {
+ dst_pyr_laplace_[i].create((dst_pyr_laplace_[i - 1].rows + 1) / 2,
+ (dst_pyr_laplace_[i - 1].cols + 1) / 2, CV_16SC3);
+ dst_band_weights_[i].create((dst_band_weights_[i - 1].rows + 1) / 2,
+ (dst_band_weights_[i - 1].cols + 1) / 2, weight_type_);
+ dst_pyr_laplace_[i].setTo(Scalar::all(0));
+ dst_band_weights_[i].setTo(0);
+ }
}
}
@@ -312,6 +355,76 @@ void MultiBandBlender::feed(InputArray _img, InputArray mask, Point tl)
int bottom = br_new.y - tl.y - img.rows;
int right = br_new.x - tl.x - img.cols;
+#if defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING)
+ if (can_use_gpu_)
+ {
+ // Create the source image Laplacian pyramid
+ cuda::GpuMat gpu_img;
+ gpu_img.upload(img);
+ cuda::GpuMat img_with_border;
+ cuda::copyMakeBorder(gpu_img, img_with_border, top, bottom, left, right, BORDER_REFLECT);
+ std::vector<cuda::GpuMat> gpu_src_pyr_laplace(num_bands_ + 1);
+ img_with_border.convertTo(gpu_src_pyr_laplace[0], CV_16S);
+ for (int i = 0; i < num_bands_; ++i)
+ cuda::pyrDown(gpu_src_pyr_laplace[i], gpu_src_pyr_laplace[i + 1]);
+ for (int i = 0; i < num_bands_; ++i)
+ {
+ cuda::GpuMat up;
+ cuda::pyrUp(gpu_src_pyr_laplace[i + 1], up);
+ cuda::subtract(gpu_src_pyr_laplace[i], up, gpu_src_pyr_laplace[i]);
+ }
+
+ // Create the weight map Gaussian pyramid
+ cuda::GpuMat gpu_mask;
+ gpu_mask.upload(mask);
+ cuda::GpuMat weight_map;
+ std::vector<cuda::GpuMat> gpu_weight_pyr_gauss(num_bands_ + 1);
+
+ if (weight_type_ == CV_32F)
+ {
+ gpu_mask.convertTo(weight_map, CV_32F, 1. / 255.);
+ }
+ else // weight_type_ == CV_16S
+ {
+ gpu_mask.convertTo(weight_map, CV_16S);
+ cuda::GpuMat add_mask;
+ cuda::compare(gpu_mask, 0, add_mask, CMP_NE);
+ cuda::add(weight_map, Scalar::all(1), weight_map, add_mask);
+ }
+ cuda::copyMakeBorder(weight_map, gpu_weight_pyr_gauss[0], top, bottom, left, right, BORDER_CONSTANT);
+ for (int i = 0; i < num_bands_; ++i)
+ cuda::pyrDown(gpu_weight_pyr_gauss[i], gpu_weight_pyr_gauss[i + 1]);
+
+ int y_tl = tl_new.y - dst_roi_.y;
+ int y_br = br_new.y - dst_roi_.y;
+ int x_tl = tl_new.x - dst_roi_.x;
+ int x_br = br_new.x - dst_roi_.x;
+
+ // Add weighted layer of the source image to the final Laplacian pyramid layer
+ for (int i = 0; i <= num_bands_; ++i)
+ {
+ Rect rc(x_tl, y_tl, x_br - x_tl, y_br - y_tl);
+ cuda::GpuMat &_src_pyr_laplace = gpu_src_pyr_laplace[i];
+ cuda::GpuMat _dst_pyr_laplace = gpu_dst_pyr_laplace_[i](rc);
+ cuda::GpuMat &_weight_pyr_gauss = gpu_weight_pyr_gauss[i];
+ cuda::GpuMat _dst_band_weights = gpu_dst_band_weights_[i](rc);
+
+ using namespace cv::cuda::device::blend;
+ if (weight_type_ == CV_32F)
+ {
+ addSrcWeightGpu32F(_src_pyr_laplace, _weight_pyr_gauss, _dst_pyr_laplace, _dst_band_weights, rc);
+ }
+ else
+ {
+ addSrcWeightGpu16S(_src_pyr_laplace, _weight_pyr_gauss, _dst_pyr_laplace, _dst_band_weights, rc);
+ }
+ x_tl /= 2; y_tl /= 2;
+ x_br /= 2; y_br /= 2;
+ }
+ return;
+ }
+#endif
+
// Create the source image Laplacian pyramid
UMat img_with_border;
copyMakeBorder(_img, img_with_border, top, bottom, left, right,
@@ -322,10 +435,7 @@ void MultiBandBlender::feed(InputArray _img, InputArray mask, Point tl)
#endif
std::vector<UMat> src_pyr_laplace;
- if (can_use_gpu_ && img_with_border.depth() == CV_16S)
- createLaplacePyrGpu(img_with_border, num_bands_, src_pyr_laplace);
- else
- createLaplacePyr(img_with_border, num_bands_, src_pyr_laplace);
+ createLaplacePyr(img_with_border, num_bands_, src_pyr_laplace);
LOGLN(" Create the source image Laplacian pyramid, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");
#if ENABLE_LOG
@@ -431,20 +541,57 @@ void MultiBandBlender::feed(InputArray _img, InputArray mask, Point tl)
void MultiBandBlender::blend(InputOutputArray dst, InputOutputArray dst_mask)
{
- for (int i = 0; i <= num_bands_; ++i)
- normalizeUsingWeightMap(dst_band_weights_[i], dst_pyr_laplace_[i]);
-
+ cv::UMat dst_band_weights_0;
+ Rect dst_rc(0, 0, dst_roi_final_.width, dst_roi_final_.height);
+#if defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING)
if (can_use_gpu_)
- restoreImageFromLaplacePyrGpu(dst_pyr_laplace_);
+ {
+ for (int i = 0; i <= num_bands_; ++i)
+ {
+ cuda::GpuMat dst_i = gpu_dst_pyr_laplace_[i];
+ cuda::GpuMat weight_i = gpu_dst_band_weights_[i];
+
+ using namespace ::cv::cuda::device::blend;
+ if (weight_type_ == CV_32F)
+ {
+ normalizeUsingWeightMapGpu32F(weight_i, dst_i, weight_i.cols, weight_i.rows);
+ }
+ else
+ {
+ normalizeUsingWeightMapGpu16S(weight_i, dst_i, weight_i.cols, weight_i.rows);
+ }
+ }
+
+ // Restore image from Laplacian pyramid
+ for (size_t i = num_bands_; i > 0; --i)
+ {
+ cuda::GpuMat up;
+ cuda::pyrUp(gpu_dst_pyr_laplace_[i], up);
+ cuda::add(up, gpu_dst_pyr_laplace_[i - 1], gpu_dst_pyr_laplace_[i - 1]);
+ }
+
+ gpu_dst_pyr_laplace_[0](dst_rc).download(dst_);
+ gpu_dst_band_weights_[0].download(dst_band_weights_0);
+
+ gpu_dst_pyr_laplace_.clear();
+ gpu_dst_band_weights_.clear();
+ }
else
+#endif
+ {
+ for (int i = 0; i <= num_bands_; ++i)
+ normalizeUsingWeightMap(dst_band_weights_[i], dst_pyr_laplace_[i]);
+
restoreImageFromLaplacePyr(dst_pyr_laplace_);
- Rect dst_rc(0, 0, dst_roi_final_.width, dst_roi_final_.height);
- dst_ = dst_pyr_laplace_[0](dst_rc);
- UMat _dst_mask;
- compare(dst_band_weights_[0](dst_rc), WEIGHT_EPS, dst_mask_, CMP_GT);
- dst_pyr_laplace_.clear();
- dst_band_weights_.clear();
+ dst_ = dst_pyr_laplace_[0](dst_rc);
+ dst_band_weights_0 = dst_band_weights_[0];
+
+ dst_pyr_laplace_.clear();
+ dst_band_weights_.clear();
+ }
+
+ compare(dst_band_weights_0(dst_rc), WEIGHT_EPS, dst_mask_, CMP_GT);
Blender::blend(dst, dst_mask);
}
diff --git a/modules/stitching/src/cuda/multiband_blend.cu b/modules/stitching/src/cuda/multiband_blend.cu
new file mode 100644
index 0000000..27eb920
--- /dev/null
+++ b/modules/stitching/src/cuda/multiband_blend.cu
@@ -0,0 +1,112 @@
+#if !defined CUDA_DISABLER
+
+#include "opencv2/core/cuda/common.hpp"
+#include "opencv2/core/types.hpp"
+
+namespace cv { namespace cuda { namespace device
+{
+ namespace blend
+ {
+ __global__ void addSrcWeightKernel16S(const PtrStep<short> src, const PtrStep<short> src_weight,
+ PtrStep<short> dst, PtrStep<short> dst_weight, int rows, int cols)
+ {
+ int x = blockIdx.x * blockDim.x + threadIdx.x;
+ int y = blockIdx.y * blockDim.y + threadIdx.y;
+
+ if (y < rows && x < cols)
+ {
+ const short3 v = ((const short3*)src.ptr(y))[x];
+ short w = src_weight.ptr(y)[x];
+ ((short3*)dst.ptr(y))[x].x += short((v.x * w) >> 8);
+ ((short3*)dst.ptr(y))[x].y += short((v.y * w) >> 8);
+ ((short3*)dst.ptr(y))[x].z += short((v.z * w) >> 8);
+ dst_weight.ptr(y)[x] += w;
+ }
+ }
+
+ void addSrcWeightGpu16S(const PtrStep<short> src, const PtrStep<short> src_weight,
+ PtrStep<short> dst, PtrStep<short> dst_weight, cv::Rect &rc)
+ {
+ dim3 threads(16, 16);
+ dim3 grid(divUp(rc.width, threads.x), divUp(rc.height, threads.y));
+ addSrcWeightKernel16S<<<grid, threads>>>(src, src_weight, dst, dst_weight, rc.height, rc.width);
+ cudaSafeCall(cudaGetLastError());
+ }
+
+ __global__ void addSrcWeightKernel32F(const PtrStep<short> src, const PtrStepf src_weight,
+ PtrStep<short> dst, PtrStepf dst_weight, int rows, int cols)
+ {
+ int x = blockIdx.x * blockDim.x + threadIdx.x;
+ int y = blockIdx.y * blockDim.y + threadIdx.y;
+
+ if (y < rows && x < cols)
+ {
+ const short3 v = ((const short3*)src.ptr(y))[x];
+ float w = src_weight.ptr(y)[x];
+ ((short3*)dst.ptr(y))[x].x += static_cast<short>(v.x * w);
+ ((short3*)dst.ptr(y))[x].y += static_cast<short>(v.y * w);
+ ((short3*)dst.ptr(y))[x].z += static_cast<short>(v.z * w);
+ dst_weight.ptr(y)[x] += w;
+ }
+ }
+
+ void addSrcWeightGpu32F(const PtrStep<short> src, const PtrStepf src_weight,
+ PtrStep<short> dst, PtrStepf dst_weight, cv::Rect &rc)
+ {
+ dim3 threads(16, 16);
+ dim3 grid(divUp(rc.width, threads.x), divUp(rc.height, threads.y));
+ addSrcWeightKernel32F<<<grid, threads>>>(src, src_weight, dst, dst_weight, rc.height, rc.width);
+ cudaSafeCall(cudaGetLastError());
+ }
+
+ __global__ void normalizeUsingWeightKernel16S(const PtrStep<short> weight, PtrStep<short> src,
+ const int width, const int height)
+ {
+ int x = (blockIdx.x * blockDim.x) + threadIdx.x;
+ int y = (blockIdx.y * blockDim.y) + threadIdx.y;
+
+ if (x < width && y < height)
+ {
+ const short3 v = ((short3*)src.ptr(y))[x];
+ short w = weight.ptr(y)[x];
+ ((short3*)src.ptr(y))[x] = make_short3(short((v.x << 8) / w),
+ short((v.y << 8) / w), short((v.z << 8) / w));
+ }
+ }
+
+ void normalizeUsingWeightMapGpu16S(const PtrStep<short> weight, PtrStep<short> src,
+ const int width, const int height)
+ {
+ dim3 threads(16, 16);
+ dim3 grid(divUp(width, threads.x), divUp(height, threads.y));
+ normalizeUsingWeightKernel16S<<<grid, threads>>> (weight, src, width, height);
+ }
+
+ __global__ void normalizeUsingWeightKernel32F(const PtrStepf weight, PtrStep<short> src,
+ const int width, const int height)
+ {
+ int x = (blockIdx.x * blockDim.x) + threadIdx.x;
+ int y = (blockIdx.y * blockDim.y) + threadIdx.y;
+
+ if (x < width && y < height)
+ {
+ const float WEIGHT_EPS = 1e-5f;
+ const short3 v = ((short3*)src.ptr(y))[x];
+ float w = weight.ptr(y)[x];
+ ((short3*)src.ptr(y))[x] = make_short3(static_cast<short>(v.x / (w + WEIGHT_EPS)),
+ static_cast<short>(v.y / (w + WEIGHT_EPS)),
+ static_cast<short>(v.z / (w + WEIGHT_EPS)));
+ }
+ }
+
+ void normalizeUsingWeightMapGpu32F(const PtrStepf weight, PtrStep<short> src,
+ const int width, const int height)
+ {
+ dim3 threads(16, 16);
+ dim3 grid(divUp(width, threads.x), divUp(height, threads.y));
+ normalizeUsingWeightKernel32F<<<grid, threads>>> (weight, src, width, height);
+ }
+ }
+}}}
+
+#endif
diff --git a/modules/stitching/src/matchers.cpp b/modules/stitching/src/matchers.cpp
index edd6b61..47ef253 100644
--- a/modules/stitching/src/matchers.cpp
+++ b/modules/stitching/src/matchers.cpp
@@ -70,9 +70,12 @@ struct MatchPairsBody : ParallelLoopBody
void operator ()(const Range &r) const
{
+ cv::RNG rng = cv::theRNG(); // save entry rng state
const int num_images = static_cast<int>(features.size());
for (int i = r.start; i < r.end; ++i)
{
+ cv::theRNG() = cv::RNG(rng.state + i); // force "stable" RNG seed for each processed pair
+
int from = near_pairs[i].first;
int to = near_pairs[i].second;
int pair_idx = from*num_images + to;
@@ -555,10 +558,7 @@ AKAZEFeaturesFinder::AKAZEFeaturesFinder(int descriptor_type,
void AKAZEFeaturesFinder::find(InputArray image, detail::ImageFeatures &features)
{
CV_Assert((image.type() == CV_8UC3) || (image.type() == CV_8UC1));
- Mat descriptors;
- UMat uimage = image.getUMat();
- akaze->detectAndCompute(uimage, UMat(), features.keypoints, descriptors);
- features.descriptors = descriptors.getUMat(ACCESS_READ);
+ akaze->detectAndCompute(image, noArray(), features.keypoints, features.descriptors);
}
#ifdef HAVE_OPENCV_XFEATURES2D
diff --git a/modules/stitching/src/motion_estimators.cpp b/modules/stitching/src/motion_estimators.cpp
index f76309f..925bb44 100644
--- a/modules/stitching/src/motion_estimators.cpp
+++ b/modules/stitching/src/motion_estimators.cpp
@@ -199,7 +199,7 @@ bool AffineBasedEstimator::estimate(const std::vector<ImageFeatures> &features,
const std::vector<MatchesInfo> &pairwise_matches,
std::vector<CameraParams> &cameras)
{
- cameras.resize(features.size());
+ cameras.assign(features.size(), CameraParams());
const int num_images = static_cast<int>(features.size());
// find maximum spaning tree on pairwise matches
diff --git a/modules/stitching/src/seam_finders.cpp b/modules/stitching/src/seam_finders.cpp
index 90bf599..9de34d5 100644
--- a/modules/stitching/src/seam_finders.cpp
+++ b/modules/stitching/src/seam_finders.cpp
@@ -162,7 +162,7 @@ void VoronoiSeamFinder::findInPair(size_t first, size_t second, Rect roi)
}
-DpSeamFinder::DpSeamFinder(CostFunction costFunc) : costFunc_(costFunc) {}
+DpSeamFinder::DpSeamFinder(CostFunction costFunc) : costFunc_(costFunc), ncomps_(0) {}
void DpSeamFinder::find(const std::vector<UMat> &src, const std::vector<Point> &corners, std::vector<UMat> &masks)
diff --git a/modules/stitching/src/stitcher.cpp b/modules/stitching/src/stitcher.cpp
index f7b9172..591b5fe 100644
--- a/modules/stitching/src/stitcher.cpp
+++ b/modules/stitching/src/stitcher.cpp
@@ -261,6 +261,8 @@ Stitcher::Status Stitcher::composePanorama(InputArrayOfArrays images, OutputArra
double compose_scale = 1;
bool is_compose_scale_set = false;
+ std::vector<detail::CameraParams> cameras_scaled(cameras_);
+
UMat full_img, img;
for (size_t img_idx = 0; img_idx < imgs_.size(); ++img_idx)
{
@@ -282,16 +284,16 @@ Stitcher::Status Stitcher::composePanorama(InputArrayOfArrays images, OutputArra
compose_work_aspect = compose_scale / work_scale_;
// Update warped image scale
- warped_image_scale_ *= static_cast<float>(compose_work_aspect);
- w = warper_->create((float)warped_image_scale_);
+ float warp_scale = static_cast<float>(warped_image_scale_ * compose_work_aspect);
+ w = warper_->create(warp_scale);
// Update corners and sizes
for (size_t i = 0; i < imgs_.size(); ++i)
{
// Update intrinsics
- cameras_[i].focal *= compose_work_aspect;
- cameras_[i].ppx *= compose_work_aspect;
- cameras_[i].ppy *= compose_work_aspect;
+ cameras_scaled[i].ppx *= compose_work_aspect;
+ cameras_scaled[i].ppy *= compose_work_aspect;
+ cameras_scaled[i].focal *= compose_work_aspect;
// Update corner and size
Size sz = full_img_sizes_[i];
@@ -302,8 +304,8 @@ Stitcher::Status Stitcher::composePanorama(InputArrayOfArrays images, OutputArra
}
Mat K;
- cameras_[i].K().convertTo(K, CV_32F);
- Rect roi = w->warpRoi(sz, K, cameras_[i].R);
+ cameras_scaled[i].K().convertTo(K, CV_32F);
+ Rect roi = w->warpRoi(sz, K, cameras_scaled[i].R);
corners[i] = roi.tl();
sizes[i] = roi.size();
}
@@ -324,7 +326,7 @@ Stitcher::Status Stitcher::composePanorama(InputArrayOfArrays images, OutputArra
LOGLN(" after resize time: " << ((getTickCount() - compositing_t) / getTickFrequency()) << " sec");
Mat K;
- cameras_[img_idx].K().convertTo(K, CV_32F);
+ cameras_scaled[img_idx].K().convertTo(K, CV_32F);
#if ENABLE_LOG
int64 pt = getTickCount();
diff --git a/modules/stitching/src/util_log.hpp b/modules/stitching/src/util_log.hpp
index da45477..edaaf38 100644
--- a/modules/stitching/src/util_log.hpp
+++ b/modules/stitching/src/util_log.hpp
@@ -11,7 +11,7 @@
// TODO remove LOG macros, add logging class
#if ENABLE_LOG
-#ifdef ANDROID
+#ifdef __ANDROID__
#include <iostream>
#include <sstream>
#include <android/log.h>
diff --git a/modules/stitching/test/test_blenders.cuda.cpp b/modules/stitching/test/test_blenders.cuda.cpp
new file mode 100644
index 0000000..1b60838
--- /dev/null
+++ b/modules/stitching/test/test_blenders.cuda.cpp
@@ -0,0 +1,93 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// Intel License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of Intel Corporation may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "test_precomp.hpp"
+#include "opencv2/ts/cuda_test.hpp"
+
+#if defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING)
+
+using namespace cv;
+using namespace std;
+
+namespace
+{
+ void multiBandBlend(const cv::Mat& im1, const cv::Mat& im2, const cv::Mat& mask1, const cv::Mat& mask2, cv::Mat& result, bool try_cuda)
+ {
+ detail::MultiBandBlender blender(try_cuda, 5);
+
+ blender.prepare(Rect(0, 0, max(im1.cols, im2.cols), max(im1.rows, im2.rows)));
+ blender.feed(im1, mask1, Point(0,0));
+ blender.feed(im2, mask2, Point(0,0));
+
+ Mat result_s, result_mask;
+ blender.blend(result_s, result_mask);
+ result_s.convertTo(result, CV_8U);
+ }
+}
+
+TEST(CUDA_MultiBandBlender, Accuracy)
+{
+ Mat image1 = imread(string(cvtest::TS::ptr()->get_data_path()) + "cv/shared/baboon.png");
+ Mat image2 = imread(string(cvtest::TS::ptr()->get_data_path()) + "cv/shared/lena.png");
+ ASSERT_EQ(image1.rows, image2.rows); ASSERT_EQ(image1.cols, image2.cols);
+
+ Mat image1s, image2s;
+ image1.convertTo(image1s, CV_16S);
+ image2.convertTo(image2s, CV_16S);
+
+ Mat mask1(image1s.size(), CV_8U);
+ mask1(Rect(0, 0, mask1.cols/2, mask1.rows)).setTo(255);
+ mask1(Rect(mask1.cols/2, 0, mask1.cols - mask1.cols/2, mask1.rows)).setTo(0);
+
+ Mat mask2(image2s.size(), CV_8U);
+ mask2(Rect(0, 0, mask2.cols/2, mask2.rows)).setTo(0);
+ mask2(Rect(mask2.cols/2, 0, mask2.cols - mask2.cols/2, mask2.rows)).setTo(255);
+
+ cv::Mat result;
+ multiBandBlend(image1s, image2s, mask1, mask2, result, false);
+
+ cv::Mat result_cuda;
+ multiBandBlend(image1s, image2s, mask1, mask2, result_cuda, true);
+
+ EXPECT_MAT_NEAR(result, result_cuda, 3);
+}
+
+#endif
diff --git a/modules/superres/CMakeLists.txt b/modules/superres/CMakeLists.txt
index 7c3fc14..028274b 100644
--- a/modules/superres/CMakeLists.txt
+++ b/modules/superres/CMakeLists.txt
@@ -3,7 +3,9 @@ if(IOS OR WINRT)
endif()
set(the_description "Super Resolution")
-ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 -Wundef -Wshadow)
+if(HAVE_CUDA)
+ ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wshadow)
+endif()
ocv_define_module(superres opencv_imgproc opencv_video
OPTIONAL opencv_videoio opencv_cudaarithm opencv_cudafilters opencv_cudawarping opencv_cudaimgproc opencv_cudaoptflow opencv_cudacodec
WRAP python)
diff --git a/modules/superres/src/btv_l1.cpp b/modules/superres/src/btv_l1.cpp
index 9c86341..558bbe0 100644
--- a/modules/superres/src/btv_l1.cpp
+++ b/modules/superres/src/btv_l1.cpp
@@ -447,17 +447,19 @@ namespace
{
CV_OCL_RUN(_dst.isUMat(),
ocl_calcBtvRegularization(_src, _dst, btvKernelSize, ubtvWeights))
- (void)ubtvWeights;
-
- typedef void (*func_t)(InputArray _src, OutputArray _dst, int btvKernelSize, const std::vector<float>& btvWeights);
- static const func_t funcs[] =
+ CV_UNUSED(ubtvWeights);
+ if (_src.channels() == 1)
{
- 0, calcBtvRegularizationImpl<float>, 0, calcBtvRegularizationImpl<Point3f>, 0
- };
-
- const func_t func = funcs[_src.channels()];
- CV_Assert(func != 0);
- func(_src, _dst, btvKernelSize, btvWeights);
+ calcBtvRegularizationImpl<float>(_src, _dst, btvKernelSize, btvWeights);
+ }
+ else if (_src.channels() == 3)
+ {
+ calcBtvRegularizationImpl<Point3f>(_src, _dst, btvKernelSize, btvWeights);
+ }
+ else
+ {
+ CV_Error(Error::StsBadArg, "Unsupported number of channels in _src");
+ }
}
class BTVL1_Base : public cv::superres::SuperResolution
@@ -854,6 +856,9 @@ namespace
BTVL1::BTVL1()
{
temporalAreaRadius_ = 4;
+ procPos_ = 0;
+ outPos_ = 0;
+ storePos_ = 0;
}
void BTVL1::collectGarbage()
diff --git a/modules/superres/src/input_array_utility.cpp b/modules/superres/src/input_array_utility.cpp
index b3ea4bb..b73993b 100644
--- a/modules/superres/src/input_array_utility.cpp
+++ b/modules/superres/src/input_array_utility.cpp
@@ -200,10 +200,11 @@ namespace
void convertToDepth(InputArray src, OutputArray dst, int depth)
{
- CV_Assert( src.depth() <= CV_64F );
+ const int sdepth = src.depth();
+ CV_Assert( sdepth <= CV_64F );
CV_Assert( depth == CV_8U || depth == CV_32F );
- static const double maxVals[] =
+ static const double maxVals[CV_64F + 1] =
{
(double)std::numeric_limits<uchar>::max(),
(double)std::numeric_limits<schar>::max(),
@@ -214,7 +215,7 @@ namespace
1.0,
};
- const double scale = maxVals[depth] / maxVals[src.depth()];
+ const double scale = maxVals[depth] / maxVals[sdepth];
switch (src.kind())
{
diff --git a/modules/superres/test/test_precomp.hpp b/modules/superres/test/test_precomp.hpp
index b1c8257..9e89b42 100644
--- a/modules/superres/test/test_precomp.hpp
+++ b/modules/superres/test/test_precomp.hpp
@@ -59,17 +59,4 @@
#include "cvconfig.h"
#include "../src/input_array_utility.hpp"
-#if defined(HAVE_XINE) || \
- defined(HAVE_GSTREAMER) || \
- defined(HAVE_QUICKTIME) || \
- defined(HAVE_QTKIT) || \
- defined(HAVE_AVFOUNDATION) || \
- defined(HAVE_FFMPEG) || \
- defined(HAVE_MSMF) || \
- defined(HAVE_VFW)
-# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
-#else
-# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
-#endif
-
#endif
diff --git a/modules/superres/test/test_superres.cpp b/modules/superres/test/test_superres.cpp
index 56e9f54..0c6128c 100644
--- a/modules/superres/test/test_superres.cpp
+++ b/modules/superres/test/test_superres.cpp
@@ -43,7 +43,7 @@
#include "test_precomp.hpp"
#include "opencv2/ts/ocl_test.hpp"
-#if BUILD_WITH_VIDEO_INPUT_SUPPORT
+#ifdef HAVE_VIDEO_INPUT
class AllignedFrameSource : public cv::superres::FrameSource
{
@@ -295,4 +295,4 @@ OCL_TEST_F(SuperResolution, BTVL1)
#endif
-#endif // BUILD_WITH_VIDEO_INPUT_SUPPORT
+#endif // HAVE_VIDEO_INPUT
diff --git a/modules/ts/include/opencv2/ts.hpp b/modules/ts/include/opencv2/ts.hpp
index c573905..41a76b1 100644
--- a/modules/ts/include/opencv2/ts.hpp
+++ b/modules/ts/include/opencv2/ts.hpp
@@ -1,11 +1,34 @@
#ifndef OPENCV_TS_HPP
#define OPENCV_TS_HPP
-#include "opencv2/core/cvdef.h"
+#ifndef __OPENCV_TESTS
+#define __OPENCV_TESTS 1
+#endif
+
+#include "opencv2/opencv_modules.hpp"
+
+#include "opencv2/core.hpp"
+#include "opencv2/imgproc.hpp"
+#include "opencv2/imgcodecs.hpp"
+#include "opencv2/videoio.hpp"
+#include "opencv2/highgui.hpp"
+
+#include "opencv2/core/utility.hpp"
+
+#include "opencv2/core/utils/trace.hpp"
+
#include <stdarg.h> // for va_list
#include "cvconfig.h"
+#include <string>
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <iterator>
+#include <limits>
+#include <numeric>
+
#ifdef WINRT
#pragma warning(disable:4447) // Disable warning 'main' signature found without threading model
#endif
@@ -38,22 +61,15 @@
#define PARAM_TEST_CASE(name, ...) struct name : testing::TestWithParam< std::tr1::tuple< __VA_ARGS__ > >
#define GET_PARAM(k) std::tr1::get< k >(GetParam())
-#include "opencv2/core.hpp"
-#include "opencv2/core/utility.hpp"
-
namespace cvtest
{
using std::vector;
using std::string;
-using cv::RNG;
-using cv::Mat;
-using cv::Scalar;
-using cv::Size;
-using cv::Point;
-using cv::Rect;
-using cv::InputArray;
-using cv::noArray;
+using namespace cv;
+using testing::Values;
+using testing::Combine;
+
class SkipTestException: public cv::Exception
{
@@ -604,17 +620,25 @@ void dumpOpenCLDevice();
void parseCustomOptions(int argc, char **argv);
-#define CV_TEST_MAIN(resourcesubdir, ...) \
+#define CV_TEST_INIT0_NOOP (void)0
+
+#define CV_TEST_MAIN(resourcesubdir, ...) CV_TEST_MAIN_EX(resourcesubdir, NOOP, __VA_ARGS__)
+
+#define CV_TEST_MAIN_EX(resourcesubdir, INIT0, ...) \
int main(int argc, char **argv) \
{ \
+ CV_TRACE_FUNCTION(); \
+ { CV_TRACE_REGION("INIT"); \
using namespace cvtest; \
TS* ts = TS::ptr(); \
ts->init(resourcesubdir); \
+ __CV_TEST_EXEC_ARGS(CV_TEST_INIT0_ ## INIT0) \
::testing::InitGoogleTest(&argc, argv); \
cvtest::printVersionInfo(); \
TEST_DUMP_OCL_INFO \
__CV_TEST_EXEC_ARGS(__VA_ARGS__) \
parseCustomOptions(argc, argv); \
+ } \
return RUN_ALL_TESTS(); \
}
@@ -627,10 +651,12 @@ int main(int argc, char **argv) \
} //namespace cvtest
-#endif // OPENCV_TS_HPP
-
#include "opencv2/ts/ts_perf.hpp"
+namespace cvtest {
+using perf::MatDepth;
+}
+
#ifdef WINRT
#ifndef __FSTREAM_EMULATED__
#define __FSTREAM_EMULATED__
@@ -729,3 +755,5 @@ public:
} // namespace std
#endif // __FSTREAM_EMULATED__
#endif // WINRT
+
+#endif // OPENCV_TS_HPP
diff --git a/modules/ts/include/opencv2/ts/cuda_perf.hpp b/modules/ts/include/opencv2/ts/cuda_perf.hpp
index 672b9ff..3c162ad 100644
--- a/modules/ts/include/opencv2/ts/cuda_perf.hpp
+++ b/modules/ts/include/opencv2/ts/cuda_perf.hpp
@@ -43,12 +43,9 @@
#ifndef OPENCV_CUDA_PERF_UTILITY_HPP
#define OPENCV_CUDA_PERF_UTILITY_HPP
-#include "opencv2/core.hpp"
-#include "opencv2/imgcodecs.hpp"
-#include "opencv2/videoio.hpp"
-#include "opencv2/imgproc.hpp"
+#include "opencv2/ts.hpp"
+
#include "opencv2/ts/ts_perf.hpp"
-#include "cvconfig.h"
namespace perf
{
diff --git a/modules/ts/include/opencv2/ts/cuda_test.hpp b/modules/ts/include/opencv2/ts/cuda_test.hpp
index b459bb3..4100d29 100644
--- a/modules/ts/include/opencv2/ts/cuda_test.hpp
+++ b/modules/ts/include/opencv2/ts/cuda_test.hpp
@@ -43,14 +43,10 @@
#ifndef OPENCV_CUDA_TEST_UTILITY_HPP
#define OPENCV_CUDA_TEST_UTILITY_HPP
+#include "opencv2/ts.hpp"
+
#include <stdexcept>
-#include "cvconfig.h"
-#include "opencv2/core.hpp"
#include "opencv2/core/cuda.hpp"
-#include "opencv2/imgcodecs.hpp"
-#include "opencv2/highgui.hpp"
-#include "opencv2/imgproc.hpp"
-#include "opencv2/ts.hpp"
namespace cvtest
{
@@ -109,6 +105,7 @@ namespace cvtest
CV_EXPORTS testing::AssertionResult assertMatNear(const char* expr1, const char* expr2, const char* eps_expr, cv::InputArray m1, cv::InputArray m2, double eps);
+ #undef EXPECT_MAT_NEAR
#define EXPECT_MAT_NEAR(m1, m2, eps) EXPECT_PRED_FORMAT3(cvtest::assertMatNear, m1, m2, eps)
#define ASSERT_MAT_NEAR(m1, m2, eps) ASSERT_PRED_FORMAT3(cvtest::assertMatNear, m1, m2, eps)
@@ -153,6 +150,7 @@ namespace cvtest
CV_EXPORTS double checkSimilarity(cv::InputArray m1, cv::InputArray m2);
+ #undef EXPECT_MAT_SIMILAR
#define EXPECT_MAT_SIMILAR(mat1, mat2, eps) \
{ \
ASSERT_EQ(mat1.type(), mat2.type()); \
@@ -351,8 +349,10 @@ namespace cv { namespace cuda
#ifdef HAVE_CUDA
-#define CV_CUDA_TEST_MAIN(resourcesubdir) \
- CV_TEST_MAIN(resourcesubdir, cvtest::parseCudaDeviceOptions(argc, argv), cvtest::printCudaInfo(), cv::setUseOptimized(false))
+#define CV_TEST_INIT0_CUDA cvtest::parseCudaDeviceOptions(argc, argv), cvtest::printCudaInfo(), cv::setUseOptimized(false)
+
+#define CV_CUDA_TEST_MAIN(resourcesubdir, ...) \
+ CV_TEST_MAIN_EX(resourcesubdir, CUDA, __VA_ARGS__)
#else // HAVE_CUDA
diff --git a/modules/ts/include/opencv2/ts/ocl_perf.hpp b/modules/ts/include/opencv2/ts/ocl_perf.hpp
index 58091f3..4d57aaa 100644
--- a/modules/ts/include/opencv2/ts/ocl_perf.hpp
+++ b/modules/ts/include/opencv2/ts/ocl_perf.hpp
@@ -42,6 +42,8 @@
#ifndef OPENCV_TS_OCL_PERF_HPP
#define OPENCV_TS_OCL_PERF_HPP
+#include "opencv2/ts.hpp"
+
#include "ocl_test.hpp"
#include "ts_perf.hpp"
@@ -67,7 +69,7 @@ using std::tr1::tuple;
protected: \
virtual void PerfTestBody(); \
}; \
- TEST_F(OCL##_##fixture##_##name, name) { declare.strategy(OCL_PERF_STRATEGY); RunPerfTestBody(); } \
+ TEST_F(OCL##_##fixture##_##name, name) { CV_TRACE_REGION("PERF_TEST: " #fixture "_" #name); declare.strategy(OCL_PERF_STRATEGY); RunPerfTestBody(); } \
void OCL##_##fixture##_##name::PerfTestBody()
#define SIMPLE_PERF_TEST_P(fixture, name, params) \
@@ -79,7 +81,7 @@ using std::tr1::tuple;
protected: \
virtual void PerfTestBody(); \
}; \
- TEST_P(OCL##_##fixture##_##name, name) { declare.strategy(OCL_PERF_STRATEGY); RunPerfTestBody(); } \
+ TEST_P(OCL##_##fixture##_##name, name) { CV_TRACE_REGION("PERF_TEST_P: " #fixture "_" #name); declare.strategy(OCL_PERF_STRATEGY); RunPerfTestBody(); } \
INSTANTIATE_TEST_CASE_P(/*none*/, OCL##_##fixture##_##name, params); \
void OCL##_##fixture##_##name::PerfTestBody()
@@ -95,17 +97,27 @@ using std::tr1::tuple;
#define OCL_PERF_ENUM ::testing::Values
-// TODO Replace finish call to dstUMat.wait()
+//! deprecated
#define OCL_TEST_CYCLE() \
for (cvtest::ocl::perf::safeFinish(); next() && startTimer(); cvtest::ocl::perf::safeFinish(), stopTimer())
-
+//! deprecated
#define OCL_TEST_CYCLE_N(n) \
for (declare.iterations(n), cvtest::ocl::perf::safeFinish(); next() && startTimer(); cvtest::ocl::perf::safeFinish(), stopTimer())
-
+//! deprecated
#define OCL_TEST_CYCLE_MULTIRUN(runsNum) \
for (declare.runs(runsNum), cvtest::ocl::perf::safeFinish(); next() && startTimer(); cvtest::ocl::perf::safeFinish(), stopTimer()) \
for (int r = 0; r < runsNum; cvtest::ocl::perf::safeFinish(), ++r)
+#undef PERF_SAMPLE_BEGIN
+#undef PERF_SAMPLE_END
+#define PERF_SAMPLE_BEGIN() \
+ cvtest::ocl::perf::safeFinish(); \
+ for(; next() && startTimer(); cvtest::ocl::perf::safeFinish(), stopTimer()) \
+ { \
+ CV_TRACE_REGION("iteration");
+#define PERF_SAMPLE_END() \
+ }
+
namespace perf {
diff --git a/modules/ts/include/opencv2/ts/ocl_test.hpp b/modules/ts/include/opencv2/ts/ocl_test.hpp
index c967cd7..54b33ec 100644
--- a/modules/ts/include/opencv2/ts/ocl_test.hpp
+++ b/modules/ts/include/opencv2/ts/ocl_test.hpp
@@ -42,8 +42,6 @@
#ifndef OPENCV_TS_OCL_TEST_HPP
#define OPENCV_TS_OCL_TEST_HPP
-#include "opencv2/opencv_modules.hpp"
-
#include "opencv2/ts.hpp"
#include "opencv2/imgcodecs.hpp"
@@ -94,6 +92,7 @@ do \
EXPECT_LE(TestUtils::checkNorm1(mat), eps) \
} while ((void)0, 0)
+#undef EXPECT_MAT_NEAR
#define EXPECT_MAT_NEAR(mat1, mat2, eps) \
do \
{ \
@@ -178,6 +177,7 @@ do \
<< "Size: " << name ## _roi.size() << std::endl; \
} while ((void)0, 0)
+#undef EXPECT_MAT_SIMILAR
#define EXPECT_MAT_SIMILAR(mat1, mat2, eps) \
do \
{ \
@@ -325,7 +325,7 @@ struct CV_EXPORTS TSTestWithParam : public TestUtils, public ::testing::TestWith
};
#undef PARAM_TEST_CASE
-#define PARAM_TEST_CASE(name, ...) struct name : public TSTestWithParam< std::tr1::tuple< __VA_ARGS__ > >
+#define PARAM_TEST_CASE(name, ...) struct name : public ::cvtest::ocl::TSTestWithParam< std::tr1::tuple< __VA_ARGS__ > >
#ifndef IMPLEMENT_PARAM_CLASS
#define IMPLEMENT_PARAM_CLASS(name, type) \
diff --git a/modules/ts/include/opencv2/ts/ts_ext.hpp b/modules/ts/include/opencv2/ts/ts_ext.hpp
index 05ccc63..0bdd346 100644
--- a/modules/ts/include/opencv2/ts/ts_ext.hpp
+++ b/modules/ts/include/opencv2/ts/ts_ext.hpp
@@ -16,8 +16,9 @@ void checkIppStatus();
cv::ipp::setIppStatus(0); \
cv::theRNG().state = cvtest::param_seed;
#define CV_TEST_CLEANUP ::cvtest::checkIppStatus();
-#define CV_TEST_BODY_IMPL \
+#define CV_TEST_BODY_IMPL(name) \
{ \
+ CV__TRACE_APP_FUNCTION_NAME(name); \
try { \
CV_TEST_INIT \
Body(); \
@@ -53,7 +54,7 @@ void checkIppStatus();
::testing::Test::TearDownTestCase, \
new ::testing::internal::TestFactoryImpl<\
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>);\
- void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() CV_TEST_BODY_IMPL \
+ void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() CV_TEST_BODY_IMPL( #test_case_name "_" #test_name ) \
void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::Body()
#undef TEST_F
@@ -79,7 +80,7 @@ void checkIppStatus();
test_fixture::TearDownTestCase, \
new ::testing::internal::TestFactoryImpl<\
GTEST_TEST_CLASS_NAME_(test_fixture, test_name)>);\
- void GTEST_TEST_CLASS_NAME_(test_fixture, test_name)::TestBody() CV_TEST_BODY_IMPL \
+ void GTEST_TEST_CLASS_NAME_(test_fixture, test_name)::TestBody() CV_TEST_BODY_IMPL( #test_fixture "_" #test_name ) \
void GTEST_TEST_CLASS_NAME_(test_fixture, test_name)::Body()
#undef TEST_P
@@ -111,7 +112,7 @@ void checkIppStatus();
int GTEST_TEST_CLASS_NAME_(test_case_name, \
test_name)::gtest_registering_dummy_ = \
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \
- void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() CV_TEST_BODY_IMPL \
+ void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() CV_TEST_BODY_IMPL( #test_case_name "_" #test_name ) \
void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::Body()
#endif // OPENCV_TS_EXT_HPP
diff --git a/modules/ts/include/opencv2/ts/ts_gtest.h b/modules/ts/include/opencv2/ts/ts_gtest.h
index d886c97..9f54cbb 100644
--- a/modules/ts/include/opencv2/ts/ts_gtest.h
+++ b/modules/ts/include/opencv2/ts/ts_gtest.h
@@ -720,10 +720,16 @@
# include <io.h>
# endif
// In order to avoid having to include <windows.h>, use forward declaration
-// assuming CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION.
-// This assumption is verified by
-// WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION.
-struct _RTL_CRITICAL_SECTION;
+#if GTEST_OS_WINDOWS_MINGW && !defined(__MINGW64_VERSION_MAJOR)
+ // MinGW defined _CRITICAL_SECTION and _RTL_CRITICAL_SECTION as two
+ // separate (equivalent) structs, instead of using typedef
+ typedef struct _CRITICAL_SECTION GTEST_CRITICAL_SECTION;
+# else
+ // assuming CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION.
+ // This assumption is verified by
+ // WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION.
+ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
+# endif
#else
// This assumes that non-Windows OSes provide unistd.h. For OSes where this
// is not the case, we need to include headers that provide the functions
@@ -3057,7 +3063,7 @@ class GTEST_API_ Mutex {
// by the linker.
MutexType type_;
long critical_section_init_phase_; // NOLINT
- _RTL_CRITICAL_SECTION* critical_section_;
+ GTEST_CRITICAL_SECTION* critical_section_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex);
};
@@ -8009,7 +8015,7 @@ namespace edit_distance {
// Returns the optimal edits to go from 'left' to 'right'.
// All edits cost the same, with replace having lower priority than
// add/remove.
-// Simple implementation of the Wagner–Fischer algorithm.
+// Simple implementation of the Wagner-Fischer algorithm.
// See http://en.wikipedia.org/wiki/Wagner-Fischer_algorithm
enum EditType { kMatch, kAdd, kRemove, kReplace };
GTEST_API_ std::vector<EditType> CalculateOptimalEdits(
@@ -10328,7 +10334,7 @@ class TypeWithoutFormatter<T, kConvertibleToInteger> {
// T is not an enum, printing it as an integer is the best we can do
// given that it has no user-defined printer.
static void PrintValue(const T& value, ::std::ostream* os) {
- const internal::BiggestInt kBigInt = value;
+ const internal::BiggestInt kBigInt = static_cast<internal::BiggestInt>(value);
*os << kBigInt;
}
};
diff --git a/modules/ts/include/opencv2/ts/ts_perf.hpp b/modules/ts/include/opencv2/ts/ts_perf.hpp
index bfa1811..288d8d7 100644
--- a/modules/ts/include/opencv2/ts/ts_perf.hpp
+++ b/modules/ts/include/opencv2/ts/ts_perf.hpp
@@ -1,14 +1,15 @@
#ifndef OPENCV_TS_PERF_HPP
#define OPENCV_TS_PERF_HPP
-#include "opencv2/core.hpp"
+#include "opencv2/ts.hpp"
+
#include "ts_gtest.h"
#include "ts_ext.hpp"
#include <functional>
#if !(defined(LOGD) || defined(LOGI) || defined(LOGW) || defined(LOGE))
-# if defined(ANDROID) && defined(USE_ANDROID_LOGGING)
+# if defined(__ANDROID__) && defined(USE_ANDROID_LOGGING)
# include <android/log.h>
# define PERF_TESTS_LOG_TAG "OpenCV_perf"
@@ -537,7 +538,7 @@ CV_EXPORTS void PrintTo(const Size& sz, ::std::ostream* os);
protected:\
virtual void PerfTestBody();\
};\
- TEST_F(test_case_name, test_name){ RunPerfTestBody(); }\
+ TEST_F(test_case_name, test_name){ CV_TRACE_REGION("PERF_TEST: " #test_case_name "_" #test_name); RunPerfTestBody(); }\
}\
void PERF_PROXY_NAMESPACE_NAME_(test_case_name, test_name)::test_case_name::PerfTestBody()
@@ -575,7 +576,7 @@ CV_EXPORTS void PrintTo(const Size& sz, ::std::ostream* os);
protected:\
virtual void PerfTestBody();\
};\
- TEST_F(fixture, testname){ RunPerfTestBody(); }\
+ TEST_F(fixture, testname){ CV_TRACE_REGION("PERF_TEST: " #fixture "_" #testname); RunPerfTestBody(); }\
}\
void PERF_PROXY_NAMESPACE_NAME_(fixture, testname)::fixture::PerfTestBody()
@@ -608,7 +609,7 @@ CV_EXPORTS void PrintTo(const Size& sz, ::std::ostream* os);
protected:\
virtual void PerfTestBody();\
};\
- TEST_P(fixture##_##name, name /*perf*/){ RunPerfTestBody(); }\
+ TEST_P(fixture##_##name, name /*perf*/){ CV_TRACE_REGION("PERF_TEST: " #fixture "_" #name); RunPerfTestBody(); }\
INSTANTIATE_TEST_CASE_P(/*none*/, fixture##_##name, params);\
void fixture##_##name::PerfTestBody()
@@ -631,7 +632,10 @@ void dumpOpenCLDevice();
#define TEST_DUMP_OCL_INFO
#endif
+
#define CV_PERF_TEST_MAIN_INTERNALS(modulename, impls, ...) \
+ CV_TRACE_FUNCTION(); \
+ { CV_TRACE_REGION("INIT"); \
::perf::Regression::Init(#modulename); \
::perf::TestBase::Init(std::vector<std::string>(impls, impls + sizeof impls / sizeof *impls), \
argc, argv); \
@@ -641,6 +645,7 @@ void dumpOpenCLDevice();
::perf::TestBase::RecordRunParameters(); \
__CV_TEST_EXEC_ARGS(__VA_ARGS__) \
TEST_DUMP_OCL_INFO \
+ } \
return RUN_ALL_TESTS();
// impls must be an array, not a pointer; "plain" should always be one of the implementations
@@ -657,10 +662,20 @@ int main(int argc, char **argv)\
CV_PERF_TEST_MAIN_INTERNALS(modulename, plain_only, __VA_ARGS__)\
}
+//! deprecated
#define TEST_CYCLE_N(n) for(declare.iterations(n); next() && startTimer(); stopTimer())
+//! deprecated
#define TEST_CYCLE() for(; next() && startTimer(); stopTimer())
+//! deprecated
#define TEST_CYCLE_MULTIRUN(runsNum) for(declare.runs(runsNum); next() && startTimer(); stopTimer()) for(int r = 0; r < runsNum; ++r)
+#define PERF_SAMPLE_BEGIN() \
+ for(; next() && startTimer(); stopTimer()) \
+ { \
+ CV_TRACE_REGION("iteration");
+#define PERF_SAMPLE_END() \
+ }
+
namespace perf
{
namespace comparators
diff --git a/modules/ts/misc/run.py b/modules/ts/misc/run.py
index ad6a38d..0befa79 100755
--- a/modules/ts/misc/run.py
+++ b/modules/ts/misc/run.py
@@ -37,7 +37,7 @@ if __name__ == "__main__":
# Valgrind
parser.add_argument("--valgrind", action="store_true", default=False, help="Run C++ tests in valgrind")
- parser.add_argument("--valgrind_supp", metavar="FILE", help="Path to valgrind suppression file (example: --valgrind_supp opencv/platforms/scripts/valgrind.supp)")
+ parser.add_argument("--valgrind_supp", metavar="FILE", action='append', help="Path to valgrind suppression file (example: --valgrind_supp opencv/platforms/scripts/valgrind.supp)")
parser.add_argument("--valgrind_opt", metavar="OPT", action="append", default=[], help="Add command line option to valgrind (example: --valgrind_opt=--leak-check=full)")
# Android
@@ -49,6 +49,9 @@ if __name__ == "__main__":
parser.add_argument("--serial", metavar="serial number", default="", help="Android: directs command to the USB device or emulator with the given serial number")
parser.add_argument("--package", metavar="package", default="", help="Android: run jUnit tests for specified package")
+ parser.add_argument("--trace", action="store_true", default=False, help="Trace: enable OpenCV tracing")
+ parser.add_argument("--trace_dump", metavar="trace_dump", default=-1, help="Trace: dump highlight calls (specify max entries count, 0 - dump all)")
+
args, other_args = parser.parse_known_args()
log.setLevel(logging.DEBUG if args.verbose else logging.INFO)
diff --git a/modules/ts/misc/run_long.py b/modules/ts/misc/run_long.py
index 6ae76ae..5640ea3 100644
--- a/modules/ts/misc/run_long.py
+++ b/modules/ts/misc/run_long.py
@@ -7,7 +7,14 @@ from pprint import PrettyPrinter as PP
LONG_TESTS_DEBUG_VALGRIND = [
('calib3d', 'Calib3d_InitUndistortRectifyMap.accuracy', 2017.22),
- ('features2d', 'Features2d_Feature2d.no_crash', 1235.68),
+ ('dnn', 'Reproducibility*', 1000), # large DNN models
+ ('features2d', 'Features2d/DescriptorImage.no_crash/3', 1000),
+ ('features2d', 'Features2d/DescriptorImage.no_crash/4', 1000),
+ ('features2d', 'Features2d/DescriptorImage.no_crash/5', 1000),
+ ('features2d', 'Features2d/DescriptorImage.no_crash/6', 1000),
+ ('features2d', 'Features2d/DescriptorImage.no_crash/7', 1000),
+ ('imgcodecs', 'Imgcodecs_Png.write_big', 1000), # memory limit
+ ('imgcodecs', 'Imgcodecs_Tiff.decode_tile16384x16384', 1000), # memory limit
('ml', 'ML_RTrees.regression', 1423.47),
('optflow', 'DenseOpticalFlow_DeepFlow.ReferenceAccuracy', 1360.95),
('optflow', 'DenseOpticalFlow_DeepFlow_perf.perf/0', 1881.59),
@@ -23,6 +30,7 @@ LONG_TESTS_DEBUG_VALGRIND = [
('shape', 'Shape_SCD.regression', 3311.46),
('tracking', 'AUKF.br_mean_squared_error', 10764.6),
('tracking', 'UKF.br_mean_squared_error', 5228.27),
+ ('videoio', 'Videoio_Video.ffmpeg_writebig', 1000),
('xfeatures2d', 'Features2d_RotationInvariance_Descriptor_BoostDesc_LBGM.regression', 1124.51),
('xfeatures2d', 'Features2d_RotationInvariance_Descriptor_VGG120.regression', 2198.1),
('xfeatures2d', 'Features2d_RotationInvariance_Descriptor_VGG48.regression', 1958.52),
@@ -43,10 +51,8 @@ LONG_TESTS_DEBUG_VALGRIND = [
]
-def longTestFilter(data):
- res = ['*', '-']
- for _, v, _ in data:
- res.append(v)
+def longTestFilter(data, module = None):
+ res = ['*', '-'] + [v for _, v, m in data if module is None or m == module]
return '--gtest_filter={}'.format(':'.join(res))
diff --git a/modules/ts/misc/run_suite.py b/modules/ts/misc/run_suite.py
index ca0841d..8242c3a 100644
--- a/modules/ts/misc/run_suite.py
+++ b/modules/ts/misc/run_suite.py
@@ -4,6 +4,8 @@ import datetime
from run_utils import *
from run_long import LONG_TESTS_DEBUG_VALGRIND, longTestFilter
+timestamp = datetime.datetime.now()
+
class TestSuite(object):
def __init__(self, options, cache):
self.options = options
@@ -20,7 +22,8 @@ class TestSuite(object):
res.append("CUDA")
return res
- def getLogName(self, app, timestamp):
+ def getLogBaseName(self, app):
+ global timestamp
app = self.getAlias(app)
rev = self.cache.getGitVersion()
if isinstance(timestamp, datetime.datetime):
@@ -34,7 +37,10 @@ class TestSuite(object):
lname = "_".join([p for p in pieces if p])
lname = re.sub(r'[\(\)\[\]\s,]', '_', lname)
l = re.sub(r'_+', '_', lname)
- return l + ".xml"
+ return l
+
+ def getLogName(self, app):
+ return self.getLogBaseName(app) + '.xml'
def listTests(self, short = False, main = False):
if len(self.tests) == 0:
@@ -97,10 +103,15 @@ class TestSuite(object):
def wrapInValgrind(self, cmd = []):
if self.options.valgrind:
res = ['valgrind']
- if self.options.valgrind_supp:
- res.append("--suppressions=%s" % self.options.valgrind_supp)
+ supp = self.options.valgrind_supp or []
+ for f in supp:
+ if os.path.isfile(f):
+ res.append("--suppressions=%s" % f)
+ else:
+ print("WARNING: Valgrind suppression file is missing, SKIP: %s" % f)
res.extend(self.options.valgrind_opt)
- return res + cmd + [longTestFilter(LONG_TESTS_DEBUG_VALGRIND)]
+ has_gtest_filter = next((True for x in cmd if x.startswith('--gtest_filter=')), False)
+ return res + cmd + ([longTestFilter(LONG_TESTS_DEBUG_VALGRIND)] if not has_gtest_filter else [])
return cmd
def tryCommand(self, cmd):
@@ -138,10 +149,25 @@ class TestSuite(object):
if isColorEnabled(args):
args.append("--gtest_color=yes")
cmd = self.wrapInValgrind([exe] + args)
+ env = {}
+ if not self.options.valgrind and self.options.trace:
+ env['OPENCV_TRACE'] = '1'
+ env['OPENCV_TRACE_LOCATION'] = 'OpenCVTrace-{}'.format(self.getLogBaseName(exe))
+ env['OPENCV_TRACE_SYNC_OPENCL'] = '1'
tempDir = TempEnvDir('OPENCV_TEMP_PATH', "__opencv_temp.")
tempDir.init()
log.warning("Run: %s" % " ".join(cmd))
- ret = execute(cmd, cwd = workingDir)
+ ret = execute(cmd, cwd = workingDir, env=env)
+ try:
+ if not self.options.valgrind and self.options.trace and int(self.options.trace_dump) >= 0:
+ import trace_profiler
+ trace = trace_profiler.Trace(env['OPENCV_TRACE_LOCATION']+'.txt')
+ trace.process()
+ trace.dump(max_entries=int(self.options.trace_dump))
+ except:
+ import traceback
+ traceback.print_exc()
+ pass
tempDir.clean()
hostlogpath = os.path.join(workingDir, logfile)
if os.path.isfile(hostlogpath):
@@ -157,7 +183,6 @@ class TestSuite(object):
args = args[:]
logs = []
test_list = self.getTestList(tests, black)
- date = datetime.datetime.now()
if len(test_list) != 1:
args = [a for a in args if not a.startswith("--gtest_output=")]
ret = 0
@@ -170,7 +195,7 @@ class TestSuite(object):
else:
userlog = [a for a in args if a.startswith("--gtest_output=")]
if len(userlog) == 0:
- logname = self.getLogName(exe, date)
+ logname = self.getLogName(exe)
more_args.append("--gtest_output=xml:" + logname)
else:
logname = userlog[0][userlog[0].find(":")+1:]
diff --git a/modules/ts/misc/run_utils.py b/modules/ts/misc/run_utils.py
index 8740aa7..8c07763 100644
--- a/modules/ts/misc/run_utils.py
+++ b/modules/ts/misc/run_utils.py
@@ -25,10 +25,12 @@ class Err(Exception):
def execute(cmd, silent = False, cwd = ".", env = None):
try:
log.debug("Run: %s", cmd)
- if env:
+ if env is not None:
for k in env:
log.debug(" Environ: %s=%s", k, env[k])
- env = os.environ.update(env)
+ new_env = os.environ.copy()
+ new_env.update(env)
+ env = new_env
if silent:
return check_output(cmd, stderr = STDOUT, cwd = cwd, env = env).decode("latin-1")
else:
@@ -193,7 +195,7 @@ class CMakeCache:
self.tests_dir = os.path.normpath(path)
def read(self, path, fname):
- rx = re.compile(r'^opencv_(\w+)_SOURCE_DIR:STATIC=(.*)$')
+ rx = re.compile(r'^OPENCV_MODULE_opencv_(\w+)_LOCATION:INTERNAL=(.*)$')
module_paths = {} # name -> path
with open(fname, "rt") as cachefile:
for l in cachefile.readlines():
diff --git a/modules/ts/misc/trace_profiler.py b/modules/ts/misc/trace_profiler.py
new file mode 100644
index 0000000..1d10890
--- /dev/null
+++ b/modules/ts/misc/trace_profiler.py
@@ -0,0 +1,435 @@
+from __future__ import print_function
+
+import os
+import sys
+import csv
+from pprint import pprint
+from collections import deque
+
+# trace.hpp
+REGION_FLAG_IMPL_MASK = 15 << 16;
+REGION_FLAG_IMPL_IPP = 1 << 16;
+REGION_FLAG_IMPL_OPENCL = 2 << 16;
+
+DEBUG = False
+
+if DEBUG:
+ dprint = print
+ dpprint = pprint
+else:
+ def dprint(args, **kwargs):
+ pass
+ def dpprint(args, **kwargs):
+ pass
+
+def tryNum(s):
+ if s.startswith('0x'):
+ try:
+ return int(s, 16)
+ except ValueError:
+ pass
+ try:
+ return int(s)
+ except ValueError:
+ pass
+ if sys.version_info[0] < 3:
+ try:
+ return long(s)
+ except ValueError:
+ pass
+ return s
+
+def formatTimestamp(t):
+ return "%.3f" % (t * 1e-6)
+
+try:
+ from statistics import median
+except ImportError:
+ def median(lst):
+ sortedLst = sorted(lst)
+ lstLen = len(lst)
+ index = (lstLen - 1) // 2
+ if (lstLen % 2):
+ return sortedLst[index]
+ else:
+ return (sortedLst[index] + sortedLst[index + 1]) * 0.5
+
+def getCXXFunctionName(spec):
+ def dropParams(spec):
+ pos = len(spec) - 1
+ depth = 0
+ while pos >= 0:
+ if spec[pos] == ')':
+ depth = depth + 1
+ elif spec[pos] == '(':
+ depth = depth - 1
+ if depth == 0:
+ if pos == 0 or spec[pos - 1] in ['#', ':']:
+ res = dropParams(spec[pos+1:-1])
+ return (spec[:pos] + res[0], res[1])
+ return (spec[:pos], spec[pos:])
+ pos = pos - 1
+ return (spec, '')
+
+ def extractName(spec):
+ pos = len(spec) - 1
+ inName = False
+ while pos >= 0:
+ if spec[pos] == ' ':
+ if inName:
+ return spec[pos+1:]
+ elif spec[pos].isalnum():
+ inName = True
+ pos = pos - 1
+ return spec
+
+ if spec.startswith('IPP') or spec.startswith('OpenCL'):
+ prefix_size = len('IPP') if spec.startswith('IPP') else len('OpenCL')
+ prefix = spec[:prefix_size]
+ if prefix_size < len(spec) and spec[prefix_size] in ['#', ':']:
+ prefix = prefix + spec[prefix_size]
+ prefix_size = prefix_size + 1
+ begin = prefix_size
+ while begin < len(spec):
+ if spec[begin].isalnum() or spec[begin] in ['_', ':']:
+ break
+ begin = begin + 1
+ if begin == len(spec):
+ return spec
+ end = begin
+ while end < len(spec):
+ if not (spec[end].isalnum() or spec[end] in ['_', ':']):
+ break
+ end = end + 1
+ return prefix + spec[begin:end]
+
+ spec = spec.replace(') const', ')') # const methods
+ (ret_type_name, params) = dropParams(spec)
+ name = extractName(ret_type_name)
+ if 'operator' in name:
+ return name + params
+ if name.startswith('&'):
+ return name[1:]
+ return name
+
+stack_size = 10
+
+class Trace:
+ def __init__(self, filename=None):
+ self.tasks = {}
+ self.tasks_list = []
+ self.locations = {}
+ self.threads_stack = {}
+ self.pending_files = deque()
+ if filename:
+ self.load(filename)
+
+ class TraceTask:
+ def __init__(self, threadID, taskID, locationID, beginTimestamp):
+ self.threadID = threadID
+ self.taskID = taskID
+ self.locationID = locationID
+ self.beginTimestamp = beginTimestamp
+ self.endTimestamp = None
+ self.parentTaskID = None
+ self.parentThreadID = None
+ self.childTask = []
+ self.selfTimeIPP = 0
+ self.selfTimeOpenCL = 0
+ self.totalTimeIPP = 0
+ self.totalTimeOpenCL = 0
+
+ def __repr__(self):
+ return "TID={} ID={} loc={} parent={}:{} begin={} end={} IPP={}/{} OpenCL={}/{}".format(
+ self.threadID, self.taskID, self.locationID, self.parentThreadID, self.parentTaskID,
+ self.beginTimestamp, self.endTimestamp, self.totalTimeIPP, self.selfTimeIPP, self.totalTimeOpenCL, self.selfTimeOpenCL)
+
+
+ class TraceLocation:
+ def __init__(self, locationID, filename, line, name, flags):
+ self.locationID = locationID
+ self.filename = os.path.split(filename)[1]
+ self.line = line
+ self.name = getCXXFunctionName(name)
+ self.flags = flags
+
+ def __str__(self):
+ return "{}#{}:{}".format(self.name, self.filename, self.line)
+
+ def __repr__(self):
+ return "ID={} {}:{}:{}".format(self.locationID, self.filename, self.line, self.name)
+
+ def parse_file(self, filename):
+ dprint("Process file: '{}'".format(filename))
+ with open(filename) as infile:
+ for line in infile:
+ line = str(line).strip()
+ if line[0] == "#":
+ if line.startswith("#thread file:"):
+ name = str(line.split(':', 1)[1]).strip()
+ self.pending_files.append(os.path.join(os.path.split(filename)[0], name))
+ continue
+ self.parse_line(line)
+
+ def parse_line(self, line):
+ opts = line.split(',')
+ dpprint(opts)
+ if opts[0] == 'l':
+ opts = list(csv.reader([line]))[0] # process quote more
+ locationID = int(opts[1])
+ filename = str(opts[2])
+ line = int(opts[3])
+ name = opts[4]
+ flags = tryNum(opts[5])
+ self.locations[locationID] = self.TraceLocation(locationID, filename, line, name, flags)
+ return
+ extra_opts = {}
+ for e in opts[5:]:
+ if not '=' in e:
+ continue
+ (k, v) = e.split('=')
+ extra_opts[k] = tryNum(v)
+ if extra_opts:
+ dpprint(extra_opts)
+ threadID = None
+ taskID = None
+ locationID = None
+ ts = None
+ if opts[0] in ['b', 'e']:
+ threadID = int(opts[1])
+ taskID = int(opts[4])
+ locationID = int(opts[3])
+ ts = tryNum(opts[2])
+ thread_stack = None
+ currentTask = (None, None)
+ if threadID is not None:
+ if not threadID in self.threads_stack:
+ thread_stack = deque()
+ self.threads_stack[threadID] = thread_stack
+ else:
+ thread_stack = self.threads_stack[threadID]
+ currentTask = None if not thread_stack else thread_stack[-1]
+ t = (threadID, taskID)
+ if opts[0] == 'b':
+ assert not t in self.tasks, "Duplicate task: " + str(t) + repr(self.tasks[t])
+ task = self.TraceTask(threadID, taskID, locationID, ts)
+ self.tasks[t] = task
+ self.tasks_list.append(task)
+ thread_stack.append((threadID, taskID))
+ if currentTask:
+ task.parentThreadID = currentTask[0]
+ task.parentTaskID = currentTask[1]
+ if 'parentThread' in extra_opts:
+ task.parentThreadID = extra_opts['parentThread']
+ if 'parent' in extra_opts:
+ task.parentTaskID = extra_opts['parent']
+ if opts[0] == 'e':
+ task = self.tasks[t]
+ task.endTimestamp = ts
+ if 'tIPP' in extra_opts:
+ task.selfTimeIPP = extra_opts['tIPP']
+ if 'tOCL' in extra_opts:
+ task.selfTimeOpenCL = extra_opts['tOCL']
+ thread_stack.pop()
+
+ def load(self, filename):
+ self.pending_files.append(filename)
+ if DEBUG:
+ with open(filename, 'r') as f:
+ print(f.read(), end='')
+ while self.pending_files:
+ self.parse_file(self.pending_files.pop())
+
+ def getParentTask(self, task):
+ return self.tasks.get((task.parentThreadID, task.parentTaskID), None)
+
+ def process(self):
+ self.tasks_list.sort(key=lambda x: x.beginTimestamp)
+
+ parallel_for_location = None
+ for (id, l) in self.locations.items():
+ if l.name == 'parallel_for':
+ parallel_for_location = l.locationID
+ break
+
+ for task in self.tasks_list:
+ try:
+ task.duration = task.endTimestamp - task.beginTimestamp
+ task.selfDuration = task.duration
+ except:
+ task.duration = None
+ task.selfDuration = None
+ task.totalTimeIPP = task.selfTimeIPP
+ task.totalTimeOpenCL = task.selfTimeOpenCL
+
+ dpprint(self.tasks)
+ dprint("Calculate total times")
+
+ for task in self.tasks_list:
+ parentTask = self.getParentTask(task)
+ if parentTask:
+ parentTask.selfDuration = parentTask.selfDuration - task.duration
+ parentTask.childTask.append(task)
+ timeIPP = task.selfTimeIPP
+ timeOpenCL = task.selfTimeOpenCL
+ while parentTask:
+ if parentTask.locationID == parallel_for_location: # TODO parallel_for
+ break
+ parentLocation = self.locations[parentTask.locationID]
+ if (parentLocation.flags & REGION_FLAG_IMPL_MASK) == REGION_FLAG_IMPL_IPP:
+ parentTask.selfTimeIPP = parentTask.selfTimeIPP - timeIPP
+ timeIPP = 0
+ else:
+ parentTask.totalTimeIPP = parentTask.totalTimeIPP + timeIPP
+ if (parentLocation.flags & REGION_FLAG_IMPL_MASK) == REGION_FLAG_IMPL_OPENCL:
+ parentTask.selfTimeOpenCL = parentTask.selfTimeOpenCL - timeOpenCL
+ timeOpenCL = 0
+ else:
+ parentTask.totalTimeOpenCL = parentTask.totalTimeOpenCL + timeOpenCL
+ parentTask = self.getParentTask(parentTask)
+
+ dpprint(self.tasks)
+ dprint("Calculate total times (parallel_for)")
+
+ for task in self.tasks_list:
+ if task.locationID == parallel_for_location:
+ task.selfDuration = 0
+ childDuration = sum([t.duration for t in task.childTask])
+ if task.duration == 0 or childDuration == 0:
+ continue
+ timeCoef = task.duration / float(childDuration)
+ childTimeIPP = sum([t.totalTimeIPP for t in task.childTask])
+ childTimeOpenCL = sum([t.totalTimeOpenCL for t in task.childTask])
+ if childTimeIPP == 0 and childTimeOpenCL == 0:
+ continue
+ timeIPP = childTimeIPP * timeCoef
+ timeOpenCL = childTimeOpenCL * timeCoef
+ parentTask = task
+ while parentTask:
+ parentLocation = self.locations[parentTask.locationID]
+ if (parentLocation.flags & REGION_FLAG_IMPL_MASK) == REGION_FLAG_IMPL_IPP:
+ parentTask.selfTimeIPP = parentTask.selfTimeIPP - timeIPP
+ timeIPP = 0
+ else:
+ parentTask.totalTimeIPP = parentTask.totalTimeIPP + timeIPP
+ if (parentLocation.flags & REGION_FLAG_IMPL_MASK) == REGION_FLAG_IMPL_OPENCL:
+ parentTask.selfTimeOpenCL = parentTask.selfTimeOpenCL - timeOpenCL
+ timeOpenCL = 0
+ else:
+ parentTask.totalTimeOpenCL = parentTask.totalTimeOpenCL + timeOpenCL
+ parentTask = self.getParentTask(parentTask)
+
+ dpprint(self.tasks)
+ dprint("Done")
+
+ def dump(self, max_entries):
+ assert isinstance(max_entries, int)
+
+ class CallInfo():
+ def __init__(self, callID):
+ self.callID = callID
+ self.totalTimes = []
+ self.selfTimes = []
+ self.threads = set()
+ self.selfTimesIPP = []
+ self.selfTimesOpenCL = []
+ self.totalTimesIPP = []
+ self.totalTimesOpenCL = []
+
+ calls = {}
+
+ for currentTask in self.tasks_list:
+ task = currentTask
+ callID = []
+ for i in range(stack_size):
+ callID.append(task.locationID)
+ task = self.getParentTask(task)
+ if not task:
+ break
+ callID = tuple(callID)
+ if not callID in calls:
+ call = CallInfo(callID)
+ calls[callID] = call
+ else:
+ call = calls[callID]
+ call.totalTimes.append(currentTask.duration)
+ call.selfTimes.append(currentTask.selfDuration)
+ call.threads.add(currentTask.threadID)
+ call.selfTimesIPP.append(currentTask.selfTimeIPP)
+ call.selfTimesOpenCL.append(currentTask.selfTimeOpenCL)
+ call.totalTimesIPP.append(currentTask.totalTimeIPP)
+ call.totalTimesOpenCL.append(currentTask.totalTimeOpenCL)
+
+ dpprint(self.tasks)
+ dpprint(self.locations)
+ dpprint(calls)
+
+ calls_self_sum = {k: sum(v.selfTimes) for (k, v) in calls.items()}
+ calls_total_sum = {k: sum(v.totalTimes) for (k, v) in calls.items()}
+ calls_median = {k: median(v.selfTimes) for (k, v) in calls.items()}
+ calls_sorted = sorted(calls.keys(), key=lambda x: calls_self_sum[x], reverse=True)
+
+ calls_self_sum_IPP = {k: sum(v.selfTimesIPP) for (k, v) in calls.items()}
+ calls_total_sum_IPP = {k: sum(v.totalTimesIPP) for (k, v) in calls.items()}
+
+ calls_self_sum_OpenCL = {k: sum(v.selfTimesOpenCL) for (k, v) in calls.items()}
+ calls_total_sum_OpenCL = {k: sum(v.totalTimesOpenCL) for (k, v) in calls.items()}
+
+ if max_entries > 0 and len(calls_sorted) > max_entries:
+ calls_sorted = calls_sorted[:max_entries]
+
+ def formatPercents(p):
+ if p is not None:
+ return "{:>3d}".format(int(p*100))
+ return ''
+
+ name_width = 70
+ timestamp_width = 12
+ def fmtTS():
+ return '{:>' + str(timestamp_width) + '}'
+ fmt = "{:>3} {:<"+str(name_width)+"} {:>8} {:>3}"+((' '+fmtTS())*5)+((' '+fmtTS()+' {:>3}')*2)
+ fmt2 = "{:>3} {:<"+str(name_width)+"} {:>8} {:>3}"+((' '+fmtTS())*5)+((' '+fmtTS()+' {:>3}')*2)
+ print(fmt.format("ID", "name", "count", "thr", "min", "max", "median", "avg", "*self*", "IPP", "%", "OpenCL", "%"))
+ print(fmt2.format("", "", "", "", "t-min", "t-max", "t-median", "t-avg", "total", "t-IPP", "%", "t-OpenCL", "%"))
+ for (index, callID) in enumerate(calls_sorted):
+ call_self_times = calls[callID].selfTimes
+ loc0 = self.locations[callID[0]]
+ loc_array = [] # [str(callID)]
+ for (i, l) in enumerate(callID):
+ loc = self.locations[l]
+ loc_array.append(loc.name if i > 0 else str(loc))
+ loc_str = '|'.join(loc_array)
+ if len(loc_str) > name_width: loc_str = loc_str[:name_width-3]+'...'
+ print(fmt.format(index + 1, loc_str, len(call_self_times),
+ len(calls[callID].threads),
+ formatTimestamp(min(call_self_times)),
+ formatTimestamp(max(call_self_times)),
+ formatTimestamp(calls_median[callID]),
+ formatTimestamp(sum(call_self_times)/float(len(call_self_times))),
+ formatTimestamp(sum(call_self_times)),
+ formatTimestamp(calls_self_sum_IPP[callID]),
+ formatPercents(calls_self_sum_IPP[callID] / float(calls_self_sum[callID])) if calls_self_sum[callID] > 0 else formatPercents(None),
+ formatTimestamp(calls_self_sum_OpenCL[callID]),
+ formatPercents(calls_self_sum_OpenCL[callID] / float(calls_self_sum[callID])) if calls_self_sum[callID] > 0 else formatPercents(None),
+ ))
+ call_total_times = calls[callID].totalTimes
+ print(fmt2.format("", "", "", "",
+ formatTimestamp(min(call_total_times)),
+ formatTimestamp(max(call_total_times)),
+ formatTimestamp(median(call_total_times)),
+ formatTimestamp(sum(call_total_times)/float(len(call_total_times))),
+ formatTimestamp(sum(call_total_times)),
+ formatTimestamp(calls_total_sum_IPP[callID]),
+ formatPercents(calls_total_sum_IPP[callID] / float(calls_total_sum[callID])) if calls_total_sum[callID] > 0 else formatPercents(None),
+ formatTimestamp(calls_total_sum_OpenCL[callID]),
+ formatPercents(calls_total_sum_OpenCL[callID] / float(calls_total_sum[callID])) if calls_total_sum[callID] > 0 else formatPercents(None),
+ ))
+ print()
+
+if __name__ == "__main__":
+ tracefile = sys.argv[1] if len(sys.argv) > 1 else 'OpenCVTrace.txt'
+ count = int(sys.argv[2]) if len(sys.argv) > 2 else 10
+ trace = Trace(tracefile)
+ trace.process()
+ trace.dump(max_entries = count)
+ print("OK")
diff --git a/modules/ts/src/cuda_perf.cpp b/modules/ts/src/cuda_perf.cpp
index 5d19334..db2af5e 100644
--- a/modules/ts/src/cuda_perf.cpp
+++ b/modules/ts/src/cuda_perf.cpp
@@ -237,7 +237,7 @@ namespace perf
# else
printf("[----------]\n[ GPU INFO ] \tRun on OS Windows x32.\n[----------]\n"), fflush(stdout);
# endif
- #elif defined ANDROID
+ #elif defined __ANDROID__
# if defined _LP64 || defined __LP64__
printf("[----------]\n[ GPU INFO ] \tRun on OS Android x64.\n[----------]\n"), fflush(stdout);
# else
diff --git a/modules/ts/src/ocl_test.cpp b/modules/ts/src/ocl_test.cpp
index abc8d95..9f0acde 100644
--- a/modules/ts/src/ocl_test.cpp
+++ b/modules/ts/src/ocl_test.cpp
@@ -156,6 +156,9 @@ void dumpOpenCLDevice()
DUMP_MESSAGE_STDOUT(" Version = " << device.version());
DUMP_PROPERTY_XML("cv_ocl_current_deviceVersion", device.version());
+ DUMP_MESSAGE_STDOUT(" Driver version = " << device.driverVersion());
+ DUMP_PROPERTY_XML("cv_ocl_current_driverVersion", device.driverVersion());
+
DUMP_MESSAGE_STDOUT(" Compute units = "<< device.maxComputeUnits());
DUMP_PROPERTY_XML("cv_ocl_current_maxComputeUnits", device.maxComputeUnits());
diff --git a/modules/ts/src/precomp.hpp b/modules/ts/src/precomp.hpp
index fbb13ec..155c377 100644
--- a/modules/ts/src/precomp.hpp
+++ b/modules/ts/src/precomp.hpp
@@ -1,7 +1,5 @@
-#include "opencv2/core/utility.hpp"
-#include "opencv2/core/private.hpp"
#include "opencv2/ts.hpp"
-#include "cvconfig.h"
+#include "opencv2/core/private.hpp"
#ifdef GTEST_LINKED_AS_SHARED_LIBRARY
#error ts module should not have GTEST_LINKED_AS_SHARED_LIBRARY defined
diff --git a/modules/ts/src/ts.cpp b/modules/ts/src/ts.cpp
index b2763d4..5251102 100644
--- a/modules/ts/src/ts.cpp
+++ b/modules/ts/src/ts.cpp
@@ -47,7 +47,7 @@
#include <stdlib.h>
#include <fcntl.h>
#include <time.h>
-#if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64
+#if defined _WIN32
#include <io.h>
#include <windows.h>
@@ -67,7 +67,7 @@
#endif
// isDirectory
-#if defined WIN32 || defined _WIN32 || defined WINCE
+#if defined _WIN32 || defined WINCE
# include <windows.h>
#else
# include <dirent.h>
@@ -100,7 +100,7 @@ static std::string path_join(const std::string& prefix, const std::string& subpa
// a few platform-dependent declarations
-#if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64
+#if defined _WIN32
#ifdef _MSC_VER
static void SEHTranslator( unsigned int /*u*/, EXCEPTION_POINTERS* pExp )
{
@@ -225,6 +225,7 @@ bool BaseTest::can_do_fast_forward()
void BaseTest::safe_run( int start_from )
{
+ CV_TRACE_FUNCTION();
read_params( ts->get_file_storage() );
ts->update_context( 0, -1, true );
ts->update_context( this, -1, true );
@@ -235,7 +236,7 @@ void BaseTest::safe_run( int start_from )
{
try
{
- #if !defined WIN32 && !defined _WIN32
+ #if !defined _WIN32
int _code = setjmp( tsJmpMark );
if( !_code )
run( start_from );
@@ -490,7 +491,7 @@ void TS::init( const string& modulename )
if( ::testing::GTEST_FLAG(catch_exceptions) )
{
-#if defined WIN32 || defined _WIN32
+#if defined _WIN32
#ifdef _MSC_VER
_set_se_translator( SEHTranslator );
#endif
@@ -501,7 +502,7 @@ void TS::init( const string& modulename )
}
else
{
-#if defined WIN32 || defined _WIN32
+#if defined _WIN32
#ifdef _MSC_VER
_set_se_translator( 0 );
#endif
@@ -721,7 +722,7 @@ void parseCustomOptions(int argc, char **argv)
static bool isDirectory(const std::string& path)
{
-#if defined WIN32 || defined _WIN32 || defined WINCE
+#if defined _WIN32 || defined WINCE
WIN32_FILE_ATTRIBUTE_DATA all_attrs;
#ifdef WINRT
wchar_t wpath[MAX_PATH];
diff --git a/modules/ts/src/ts_func.cpp b/modules/ts/src/ts_func.cpp
index a8f1460..702bdf3 100644
--- a/modules/ts/src/ts_func.cpp
+++ b/modules/ts/src/ts_func.cpp
@@ -2947,9 +2947,9 @@ MatComparator::operator()(const char* expr1, const char* expr2,
return ::testing::AssertionFailure()
<< "too big relative difference (" << realmaxdiff << " > "
<< maxdiff << ") between "
- << MatInfo(m1) << " '" << expr1 << "' and '" << expr2 << "' at " << Mat(loc0) << ".\n\n"
- << "'" << expr1 << "': " << MatPart(m1part, border > 0 ? &loc : 0) << ".\n\n"
- << "'" << expr2 << "': " << MatPart(m2part, border > 0 ? &loc : 0) << ".\n";
+ << MatInfo(m1) << " '" << expr1 << "' and '" << expr2 << "' at " << Mat(loc0).t() << ".\n"
+ << "- " << expr1 << ":\n" << MatPart(m1part, border > 0 ? &loc : 0) << ".\n"
+ << "- " << expr2 << ":\n" << MatPart(m2part, border > 0 ? &loc : 0) << ".\n";
}
void printVersionInfo(bool useStdOut)
diff --git a/modules/ts/src/ts_perf.cpp b/modules/ts/src/ts_perf.cpp
index 6a41bc9..7fbf2c7 100644
--- a/modules/ts/src/ts_perf.cpp
+++ b/modules/ts/src/ts_perf.cpp
@@ -4,7 +4,7 @@
#include <iostream>
#include <fstream>
-#if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64
+#if defined _WIN32
#ifndef NOMINMAX
#define NOMINMAX
#endif
@@ -15,7 +15,7 @@
#include "opencv2/core/cuda.hpp"
#endif
-#ifdef ANDROID
+#ifdef __ANDROID__
# include <sys/time.h>
#endif
@@ -57,7 +57,7 @@ extern bool test_ipp_check;
static int param_cuda_device;
#endif
-#ifdef ANDROID
+#ifdef __ANDROID__
static int param_affinity_mask;
static bool log_power_checkpoints;
@@ -197,6 +197,10 @@ void Regression::init(const std::string& testSuitName, const std::string& ext)
#else
const char *data_path_dir = OPENCV_TEST_DATA_PATH;
#endif
+
+ cvtest::addDataSearchSubDirectory("");
+ cvtest::addDataSearchSubDirectory(testSuitName);
+
const char *path_separator = "/";
if (data_path_dir)
@@ -954,6 +958,8 @@ void TestBase::Init(int argc, const char* const argv[])
void TestBase::Init(const std::vector<std::string> & availableImpls,
int argc, const char* const argv[])
{
+ CV_TRACE_FUNCTION();
+
available_impls = availableImpls;
const std::string command_line_keys =
@@ -971,7 +977,7 @@ void TestBase::Init(const std::vector<std::string> & availableImpls,
"{ perf_strategy |default |specifies performance measuring strategy: default, base or simple (weak restrictions)}"
"{ perf_read_validation_results | |specifies file name with performance results from previous run}"
"{ perf_write_validation_results | |specifies file name to write performance validation results}"
-#ifdef ANDROID
+#ifdef __ANDROID__
"{ perf_time_limit |6.0 |default time limit for a single test (in seconds)}"
"{ perf_affinity_mask |0 |set affinity mask for the main thread}"
"{ perf_log_power_checkpoints | |additional xml logging for power measurement}"
@@ -1042,7 +1048,7 @@ void TestBase::Init(const std::vector<std::string> & availableImpls,
#ifdef ENABLE_INSTRUMENTATION
param_instrument = args.get<int>("perf_instrument");
#endif
-#ifdef ANDROID
+#ifdef __ANDROID__
param_affinity_mask = args.get<int>("perf_affinity_mask");
log_power_checkpoints = args.has("perf_log_power_checkpoints");
#endif
@@ -1182,6 +1188,7 @@ enum PERF_STRATEGY TestBase::getCurrentModulePerformanceStrategy()
int64 TestBase::_calibrate()
{
+ CV_TRACE_FUNCTION();
class _helper : public ::perf::TestBase
{
public:
@@ -1205,6 +1212,18 @@ int64 TestBase::_calibrate()
}
};
+ // Initialize ThreadPool
+ class _dummyParallel : public ParallelLoopBody
+ {
+ public:
+ void operator()(const cv::Range& range) const
+ {
+ // nothing
+ CV_UNUSED(range);
+ }
+ };
+ parallel_for_(cv::Range(0, 1000), _dummyParallel());
+
_timeadjustment = 0;
_helper h;
h.PerfTestBody();
@@ -1248,6 +1267,7 @@ void TestBase::declareArray(SizeVector& sizes, cv::InputOutputArray a, WarmUpTyp
void TestBase::warmup(cv::InputOutputArray a, WarmUpType wtype)
{
+ CV_TRACE_FUNCTION();
if (a.empty())
return;
else if (a.isUMat())
@@ -1419,9 +1439,10 @@ bool TestBase::next()
median_ms > perf_validation_time_threshold_ms &&
(grow || metrics.stddev > perf_stability_criteria * fabs(metrics.mean)))
{
+ CV_TRACE_REGION("idle_delay");
printf("Performance is unstable, it may be a result of overheat problems\n");
printf("Idle delay for %d ms... \n", perf_validation_idle_delay_ms);
-#if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64
+#if defined _WIN32
#ifndef WINRT_8_0
Sleep(perf_validation_idle_delay_ms);
#else
@@ -1456,7 +1477,7 @@ bool TestBase::next()
}
}
-#ifdef ANDROID
+#ifdef __ANDROID__
if (log_power_checkpoints)
{
timeval tim;
@@ -1682,8 +1703,17 @@ void TestBase::validateMetrics()
void TestBase::reportMetrics(bool toJUnitXML)
{
+ CV_TRACE_FUNCTION();
+
performance_metrics& m = calcMetrics();
+ CV_TRACE_ARG_VALUE(samples, "samples", (int64)m.samples);
+ CV_TRACE_ARG_VALUE(outliers, "outliers", (int64)m.outliers);
+ CV_TRACE_ARG_VALUE(median, "mean_ms", (double)(m.mean * 1000.0f / metrics.frequency));
+ CV_TRACE_ARG_VALUE(median, "median_ms", (double)(m.median * 1000.0f / metrics.frequency));
+ CV_TRACE_ARG_VALUE(stddev, "stddev_ms", (double)(m.stddev * 1000.0f / metrics.frequency));
+ CV_TRACE_ARG_VALUE(stddev_percents, "stddev_percents", (double)(m.stddev / (double)m.mean * 100.0f));
+
if (m.terminationReason == performance_metrics::TERM_SKIP_TEST)
{
if (toJUnitXML)
@@ -1744,7 +1774,7 @@ void TestBase::reportMetrics(bool toJUnitXML)
const char* type_param = test_info->type_param();
const char* value_param = test_info->value_param();
-#if defined(ANDROID) && defined(USE_ANDROID_LOGGING)
+#if defined(__ANDROID__) && defined(USE_ANDROID_LOGGING)
LOGD("[ FAILED ] %s.%s", test_info->test_case_name(), test_info->name());
#endif
@@ -1820,8 +1850,10 @@ void TestBase::SetUp()
if (param_threads >= 0)
cv::setNumThreads(param_threads);
+ else
+ cv::setNumThreads(-1);
-#ifdef ANDROID
+#ifdef __ANDROID__
if (param_affinity_mask)
setCurrentThreadAffinityMask(param_affinity_mask);
#endif
@@ -1958,6 +1990,11 @@ void TestBase::RunPerfTestBody()
implConf.GetImpl();
#endif
}
+ catch(SkipTestException&)
+ {
+ metrics.terminationReason = performance_metrics::TERM_SKIP_TEST;
+ return;
+ }
catch(PerfSkipTestException&)
{
metrics.terminationReason = performance_metrics::TERM_SKIP_TEST;
diff --git a/modules/video/include/opencv2/video/background_segm.hpp b/modules/video/include/opencv2/video/background_segm.hpp
index 2952d57..8a2d40b 100644
--- a/modules/video/include/opencv2/video/background_segm.hpp
+++ b/modules/video/include/opencv2/video/background_segm.hpp
@@ -188,13 +188,24 @@ public:
A shadow is detected if pixel is a darker version of the background. The shadow threshold (Tau in
the paper) is a threshold defining how much darker the shadow can be. Tau= 0.5 means that if a pixel
- is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiarra,
+ is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiara,
*Detecting Moving Shadows...*, IEEE PAMI,2003.
*/
CV_WRAP virtual double getShadowThreshold() const = 0;
/** @brief Sets the shadow threshold
*/
CV_WRAP virtual void setShadowThreshold(double threshold) = 0;
+
+ /** @brief Computes a foreground mask.
+
+ @param image Next video frame. Floating point frame will be used without scaling and should be in range \f$[0,255]\f$.
+ @param fgmask The output foreground mask as an 8-bit binary image.
+ @param learningRate The value between 0 and 1 that indicates how fast the background model is
+ learnt. Negative parameter value makes the algorithm to use some automatically chosen learning
+ rate. 0 means that the background model is not updated at all, 1 means that the background model
+ is completely reinitialized from the last frame.
+ */
+ CV_WRAP virtual void apply(InputArray image, OutputArray fgmask, double learningRate=-1) = 0;
};
/** @brief Creates MOG2 Background Subtractor
@@ -278,7 +289,7 @@ public:
A shadow is detected if pixel is a darker version of the background. The shadow threshold (Tau in
the paper) is a threshold defining how much darker the shadow can be. Tau= 0.5 means that if a pixel
- is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiarra,
+ is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiara,
*Detecting Moving Shadows...*, IEEE PAMI,2003.
*/
CV_WRAP virtual double getShadowThreshold() const = 0;
diff --git a/modules/video/include/opencv2/video/tracking.hpp b/modules/video/include/opencv2/video/tracking.hpp
index c6ead3a..d397ac7 100644
--- a/modules/video/include/opencv2/video/tracking.hpp
+++ b/modules/video/include/opencv2/video/tracking.hpp
@@ -78,7 +78,9 @@ See the OpenCV sample camshiftdemo.c that tracks colored objects.
*/
CV_EXPORTS_W RotatedRect CamShift( InputArray probImage, CV_IN_OUT Rect& window,
TermCriteria criteria );
-
+/** @example camshiftdemo.cpp
+An example using the mean-shift tracking algorithm
+*/
/** @brief Finds an object on a back projection image.
@param probImage Back projection of the object histogram. See calcBackProject for details.
@@ -97,8 +99,6 @@ projection and remove the noise. For example, you can do this by retrieving conn
with findContours , throwing away contours with small area ( contourArea ), and rendering the
remaining contours with drawContours.
- at note
-- A mean-shift tracking sample can be found at opencv_source_code/samples/cpp/camshiftdemo.cpp
*/
CV_EXPORTS_W int meanShift( InputArray probImage, CV_IN_OUT Rect& window, TermCriteria criteria );
@@ -123,6 +123,9 @@ CV_EXPORTS_W int buildOpticalFlowPyramid( InputArray img, OutputArrayOfArrays py
int derivBorder = BORDER_CONSTANT,
bool tryReuseInputImage = true );
+/** @example lkdemo.cpp
+An example using the Lucas-Kanade optical flow algorithm
+ */
/** @brief Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with
pyramids.
@@ -258,6 +261,10 @@ enum
MOTION_HOMOGRAPHY = 3
};
+/** @example image_alignment.cpp
+An example using the image alignment ECC algorithm
+ */
+
/** @brief Finds the geometric transform (warp) between two images in terms of the ECC criterion @cite EP08 .
@param templateImage single-channel template image; CV_8U or CV_32F array.
@@ -297,7 +304,7 @@ row is ignored.
Unlike findHomography and estimateRigidTransform, the function findTransformECC implements an
area-based alignment that builds on intensity similarities. In essence, the function updates the
initial transformation that roughly aligns the images. If this information is missing, the identity
-warp (unity matrix) should be given as input. Note that if images undergo strong
+warp (unity matrix) is used as an initialization. Note that if images undergo strong
displacements/rotations, an initial transformation that roughly aligns the images is necessary
(e.g., a simple euclidean/similarity transform that allows for the images showing the same image
content approximately). Use inverse warping in the second image to take an image close to the first
@@ -313,25 +320,20 @@ CV_EXPORTS_W double findTransformECC( InputArray templateImage, InputArray input
TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 50, 0.001),
InputArray inputMask = noArray());
+/** @example kalman.cpp
+An example using the standard Kalman filter
+*/
/** @brief Kalman filter class.
The class implements a standard Kalman filter <http://en.wikipedia.org/wiki/Kalman_filter>,
@cite Welch95 . However, you can modify transitionMatrix, controlMatrix, and measurementMatrix to get
-an extended Kalman filter functionality. See the OpenCV sample kalman.cpp.
-
- at note
-
-- An example using the standard Kalman filter can be found at
- opencv_source_code/samples/cpp/kalman.cpp
+an extended Kalman filter functionality.
+ at note In C API when CvKalman\* kalmanFilter structure is not needed anymore, it should be released
+with cvReleaseKalman(&kalmanFilter)
*/
class CV_EXPORTS_W KalmanFilter
{
public:
- /** @brief The constructors.
-
- @note In C API when CvKalman\* kalmanFilter structure is not needed anymore, it should be released
- with cvReleaseKalman(&kalmanFilter)
- */
CV_WRAP KalmanFilter();
/** @overload
@param dynamParams Dimensionality of the state.
@@ -544,7 +546,7 @@ public:
*/
CV_EXPORTS_W Ptr<DualTVL1OpticalFlow> createOptFlow_DualTVL1();
-/** @brief Class computing a dense optical flow using the Gunnar Farneback’s algorithm.
+/** @brief Class computing a dense optical flow using the Gunnar Farneback's algorithm.
*/
class CV_EXPORTS_W FarnebackOpticalFlow : public DenseOpticalFlow
{
diff --git a/modules/video/misc/java/gen_dict.json b/modules/video/misc/java/gen_dict.json
new file mode 100644
index 0000000..2754b5b
--- /dev/null
+++ b/modules/video/misc/java/gen_dict.json
@@ -0,0 +1,16 @@
+{
+ "missing_consts": {
+ "Video" : {
+ "private" : [
+ ["CV_LKFLOW_INITIAL_GUESSES", 4 ],
+ ["CV_LKFLOW_GET_MIN_EIGENVALS", 8 ]
+ ]
+ }
+ },
+ "func_arg_fix" : {
+ "calcOpticalFlowPyrLK" : { "prevPts" : {"ctype" : "vector_Point2f"},
+ "nextPts" : {"ctype" : "vector_Point2f"},
+ "status" : {"ctype" : "vector_uchar"},
+ "err" : {"ctype" : "vector_float"} }
+ }
+}
diff --git a/modules/video/perf/opencl/perf_bgfg_mog2.cpp b/modules/video/perf/opencl/perf_bgfg_mog2.cpp
index 12223d6..e80972d 100644
--- a/modules/video/perf/opencl/perf_bgfg_mog2.cpp
+++ b/modules/video/perf/opencl/perf_bgfg_mog2.cpp
@@ -2,20 +2,7 @@
#include "opencv2/ts/ocl_perf.hpp"
#ifdef HAVE_OPENCL
-
-#if defined(HAVE_XINE) || \
-defined(HAVE_GSTREAMER) || \
-defined(HAVE_QUICKTIME) || \
-defined(HAVE_AVFOUNDATION) || \
-defined(HAVE_FFMPEG) || \
-defined(WIN32)
-
-# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
-#else
-# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
-#endif
-
-#if BUILD_WITH_VIDEO_INPUT_SUPPORT
+#ifdef HAVE_VIDEO_INPUT
namespace cvtest {
namespace ocl {
@@ -116,5 +103,5 @@ OCL_PERF_TEST_P(MOG2_GetBackgroundImage, Mog2, Combine(Values("gpu/video/768x576
}}// namespace cvtest::ocl
- #endif
-#endif
\ No newline at end of file
+#endif
+#endif
diff --git a/modules/video/perf/perf_optflowpyrlk.cpp b/modules/video/perf/perf_optflowpyrlk.cpp
index 08ffd04..a17a0f3 100644
--- a/modules/video/perf/perf_optflowpyrlk.cpp
+++ b/modules/video/perf/perf_optflowpyrlk.cpp
@@ -97,6 +97,58 @@ PERF_TEST_P(Path_Idx_Cn_NPoints_WSize, OpticalFlowPyrLK_full, testing::Combine(
SANITY_CHECK(err, 2);
}
+typedef tr1::tuple<std::string, int, tr1::tuple<int, int>, int> Path_Idx_NPoints_WSize_t;
+typedef TestBaseWithParam<Path_Idx_NPoints_WSize_t> Path_Idx_NPoints_WSize;
+
+PERF_TEST_P(Path_Idx_NPoints_WSize, OpticalFlowPyrLK_ovx, testing::Combine(
+ testing::Values<std::string>("cv/optflow/frames/VGA_%02d.png", "cv/optflow/frames/720p_%02d.png"),
+ testing::Range(1, 3),
+ testing::Values(make_tuple(9, 9), make_tuple(15, 15)),
+ testing::Values(7, 11)
+ )
+ )
+{
+ string filename1 = getDataPath(cv::format(get<0>(GetParam()).c_str(), get<1>(GetParam())));
+ string filename2 = getDataPath(cv::format(get<0>(GetParam()).c_str(), get<1>(GetParam()) + 1));
+ Mat img1 = imread(filename1);
+ Mat img2 = imread(filename2);
+ if (img1.empty()) FAIL() << "Unable to load source image " << filename1;
+ if (img2.empty()) FAIL() << "Unable to load source image " << filename2;
+
+ int nPointsX = min(get<0>(get<2>(GetParam())), img1.cols);
+ int nPointsY = min(get<1>(get<2>(GetParam())), img1.rows);
+ int winSize = get<3>(GetParam());
+
+ int maxLevel = 2;
+ TermCriteria criteria(TermCriteria::COUNT|TermCriteria::EPS, 7, 0.001);
+ int flags = 0;
+ double minEigThreshold = 1e-4;
+
+ Mat frame1, frame2;
+ cvtColor(img1, frame1, COLOR_BGR2GRAY, 1);
+ cvtColor(img2, frame2, COLOR_BGR2GRAY, 1);
+
+ vector<Point2f> inPoints;
+ vector<Point2f> outPoints;
+ vector<uchar> status;
+
+ FormTrackingPointsArray(inPoints, frame1.cols, frame1.rows, nPointsX, nPointsY);
+ outPoints.resize(inPoints.size());
+ status.resize(inPoints.size());
+
+ declare.in(frame1, frame2, inPoints).out(outPoints);
+
+ TEST_CYCLE_N(30)
+ {
+ calcOpticalFlowPyrLK(frame1, frame2, inPoints, outPoints, status, cv::noArray(),
+ Size(winSize, winSize), maxLevel, criteria,
+ flags, minEigThreshold);
+ }
+
+ SANITY_CHECK(outPoints, 0.3);
+ SANITY_CHECK(status);
+}
+
typedef tr1::tuple<std::string, int, int, tr1::tuple<int,int>, int, bool> Path_Idx_Cn_NPoints_WSize_Deriv_t;
typedef TestBaseWithParam<Path_Idx_Cn_NPoints_WSize_Deriv_t> Path_Idx_Cn_NPoints_WSize_Deriv;
diff --git a/modules/video/src/bgfg_KNN.cpp b/modules/video/src/bgfg_KNN.cpp
index 66be34a..fa1a6db 100755
--- a/modules/video/src/bgfg_KNN.cpp
+++ b/modules/video/src/bgfg_KNN.cpp
@@ -89,6 +89,9 @@ public:
nShadowDetection = defaultnShadowDetection2;
fTau = defaultfTau;// Tau - shadow threshold
name_ = "BackgroundSubtractor.KNN";
+ nLongCounter = 0;
+ nMidCounter = 0;
+ nShortCounter = 0;
}
//! the full constructor that takes the length of the history,
// the number of gaussian mixtures, the background ratio parameter and the noise strength
@@ -113,6 +116,9 @@ public:
nShadowDetection = defaultnShadowDetection2;
fTau = defaultfTau;
name_ = "BackgroundSubtractor.KNN";
+ nLongCounter = 0;
+ nMidCounter = 0;
+ nShortCounter = 0;
}
//! the destructor
~BackgroundSubtractorKNNImpl() {}
@@ -122,7 +128,7 @@ public:
//! computes a background image which are the mean of all background gaussians
virtual void getBackgroundImage(OutputArray backgroundImage) const;
- //! re-initiaization method
+ //! re-initialization method
void initialize(Size _frameSize, int _frameType)
{
frameSize = _frameSize;
@@ -137,6 +143,7 @@ public:
// for each sample of 3 speed pixel models each pixel bg model we store ...
// values + flag (nchannels+1 values)
bgmodel.create( 1,(nN * 3) * (nchannels+1)* size,CV_8U);
+ bgmodel = Scalar::all(0);
//index through the three circular lists
aModelIndexShort.create(1,size,CV_8U);
@@ -235,7 +242,7 @@ protected:
// Tau - shadow threshold. The shadow is detected if the pixel is darker
//version of the background. Tau is a threshold on how much darker the shadow can be.
//Tau= 0.5 means that if pixel is more than 2 times darker then it is not shadow
- //See: Prati,Mikic,Trivedi,Cucchiarra,"Detecting Moving Shadows...",IEEE PAMI,2003.
+ //See: Prati,Mikic,Trivedi,Cucchiara,"Detecting Moving Shadows...",IEEE PAMI,2003.
//model data
int nLongCounter;//circular counter
diff --git a/modules/video/src/bgfg_gaussmix2.cpp b/modules/video/src/bgfg_gaussmix2.cpp
index ebe4498..51ec9f9 100644
--- a/modules/video/src/bgfg_gaussmix2.cpp
+++ b/modules/video/src/bgfg_gaussmix2.cpp
@@ -386,7 +386,7 @@ protected:
// Tau - shadow threshold. The shadow is detected if the pixel is darker
//version of the background. Tau is a threshold on how much darker the shadow can be.
//Tau= 0.5 means that if pixel is more than 2 times darker then it is not shadow
- //See: Prati,Mikic,Trivedi,Cucchiarra,"Detecting Moving Shadows...",IEEE PAMI,2003.
+ //See: Prati,Mikic,Trivedi,Cucchiara,"Detecting Moving Shadows...",IEEE PAMI,2003.
String name_;
@@ -461,7 +461,7 @@ struct GaussBGStatModel2Params
// Tau - shadow threshold. The shadow is detected if the pixel is darker
//version of the background. Tau is a threshold on how much darker the shadow can be.
//Tau= 0.5 means that if pixel is more than 2 times darker then it is not shadow
- //See: Prati,Mikic,Trivedi,Cucchiarra,"Detecting Moving Shadows...",IEEE PAMI,2003.
+ //See: Prati,Mikic,Trivedi,Cucchiara,"Detecting Moving Shadows...",IEEE PAMI,2003.
};
struct GMM
@@ -472,7 +472,7 @@ struct GMM
// shadow detection performed per pixel
// should work for rgb data, could be usefull for gray scale and depth data as well
-// See: Prati,Mikic,Trivedi,Cucchiarra,"Detecting Moving Shadows...",IEEE PAMI,2003.
+// See: Prati,Mikic,Trivedi,Cucchiara,"Detecting Moving Shadows...",IEEE PAMI,2003.
CV_INLINE bool
detectShadowGMM(const float* data, int nchannels, int nmodes,
const GMM* gmm, const float* mean,
@@ -693,11 +693,16 @@ public:
//go through all modes
//////
- //renormalize weights
- totalWeight = 1.f/totalWeight;
+ // Renormalize weights. In the special case that the pixel does
+ // not agree with any modes, set weights to zero (a new mode will be added below).
+ float invWeight = 0.f;
+ if (std::abs(totalWeight) > FLT_EPSILON) {
+ invWeight = 1.f/totalWeight;
+ }
+
for( int mode = 0; mode < nmodes; mode++ )
{
- gmm[mode].weight *= totalWeight;
+ gmm[mode].weight *= invWeight;
}
//make new mode if needed and exit
@@ -900,7 +905,10 @@ void BackgroundSubtractorMOG2Impl::getBackgroundImage_intern(OutputArray backgro
if(totalWeight > backgroundRatio)
break;
}
- float invWeight = 1.f/totalWeight;
+ float invWeight = 0.f;
+ if (std::abs(totalWeight) > FLT_EPSILON) {
+ invWeight = 1.f/totalWeight;
+ }
meanBackground.at<Vec<T,CN> >(row, col) = Vec<T,CN>(meanVal * invWeight);
meanVal = 0.f;
diff --git a/modules/video/src/ecc.cpp b/modules/video/src/ecc.cpp
index d11419e..377b775 100644
--- a/modules/video/src/ecc.cpp
+++ b/modules/video/src/ecc.cpp
@@ -325,6 +325,16 @@ double cv::findTransformECC(InputArray templateImage,
CV_Assert(!src.empty());
CV_Assert(!dst.empty());
+ // If the user passed an un-initialized warpMatrix, initialize to identity
+ if(map.empty()) {
+ int rowCount = 2;
+ if(motionType == MOTION_HOMOGRAPHY)
+ rowCount = 3;
+
+ warpMatrix.create(rowCount, 3, CV_32FC1);
+ map = warpMatrix.getMat();
+ map = Mat::eye(rowCount, 3, CV_32F);
+ }
if( ! (src.type()==dst.type()))
CV_Error( Error::StsUnmatchedFormats, "Both input images must have the same data type" );
diff --git a/modules/video/src/lkpyramid.cpp b/modules/video/src/lkpyramid.cpp
index 7c89bc3..e34803b 100644
--- a/modules/video/src/lkpyramid.cpp
+++ b/modules/video/src/lkpyramid.cpp
@@ -654,6 +654,7 @@ void cv::detail::LKTrackerInvoker::operator()(const Range& range) const
prevDelta = delta;
}
+ CV_Assert(status != NULL);
if( status[ptidx] && err && level == 0 && (flags & OPTFLOW_LK_GET_MIN_EIGENVALS) == 0 )
{
Point2f nextPoint = nextPts[ptidx] - halfWin;
@@ -849,6 +850,9 @@ namespace
return false;
if (maxLevel < 0 || winSize.width <= 2 || winSize.height <= 2)
return false;
+ if (winSize.width < 8 || winSize.height < 8 ||
+ winSize.width > 24 || winSize.height > 24)
+ return false;
calcPatchSize();
if (patch.x <= 0 || patch.x >= 6 || patch.y <= 0 || patch.y >= 6)
return false;
@@ -964,11 +968,17 @@ namespace
size_t globalThreads[3] = { 8 * (size_t)ptcount, 8};
char calcErr = (0 == level) ? 1 : 0;
+ int wsx = 1, wsy = 1;
+ if(winSize.width < 16)
+ wsx = 0;
+ if(winSize.height < 16)
+ wsy = 0;
cv::String build_options;
if (isDeviceCPU())
build_options = " -D CPU";
else
- build_options = cv::format("-D WAVE_SIZE=%d", waveSize);
+ build_options = cv::format("-D WAVE_SIZE=%d -D WSX=%d -D WSY=%d",
+ waveSize, wsx, wsy);
ocl::Kernel kernel;
if (!kernel.create("lkSparse", cv::ocl::video::pyrlk_oclsrc, build_options))
@@ -1074,6 +1084,9 @@ namespace
if(prevImgMat.type() != CV_8UC1 || nextImgMat.type() != CV_8UC1)
return false;
+ if (ovx::skipSmallImages<VX_KERNEL_OPTICAL_FLOW_PYR_LK>(prevImgMat.cols, prevImgMat.rows))
+ return false;
+
CV_Assert(prevImgMat.size() == nextImgMat.size());
Mat prevPtsMat = _prevPts.getMat();
int checkPrev = prevPtsMat.checkVector(2, CV_32F, false);
@@ -1099,7 +1112,7 @@ namespace
try
{
- Context context = Context::create();
+ Context context = ovx::getOpenVXContext();
if(context.vendorID() == VX_ID_KHRONOS)
{
@@ -1439,7 +1452,7 @@ getRTMatrix( const Point2f* a, const Point2f* b,
}
else
{
- double sa[4][4]={{0.}}, sb[4]={0.}, m[4];
+ double sa[4][4]={{0.}}, sb[4]={0.}, m[4] = {0};
Mat A( 4, 4, CV_64F, sa ), B( 4, 1, CV_64F, sb );
Mat MM( 4, 1, CV_64F, m );
diff --git a/modules/video/src/opencl/pyrlk.cl b/modules/video/src/opencl/pyrlk.cl
index 80ec48a..e1d934a 100644
--- a/modules/video/src/opencl/pyrlk.cl
+++ b/modules/video/src/opencl/pyrlk.cl
@@ -258,9 +258,9 @@ inline void GetPatch(image2d_t J, float x, float y,
*b2 = mad(diff, *Dy, *b2);
}
-inline void GetError(image2d_t J, const float x, const float y, const float* Pch, float* errval)
+inline void GetError(image2d_t J, const float x, const float y, const float* Pch, float* errval, float w)
{
- float diff = read_imagef(J, sampler, (float2)(x,y)).x-*Pch;
+ float diff = ((((read_imagef(J, sampler, (float2)(x,y)).x * 16384) + 256) / 512) - (((*Pch * 16384) + 256) /512)) * w;
*errval += fabs(diff);
}
@@ -310,10 +310,34 @@ __kernel void lkSparse(image2d_t I, image2d_t J,
int xsize=get_local_size(0);
int ysize=get_local_size(1);
int k;
+
+#ifdef CPU
+ float wx0 = 1.0f;
+ float wy0 = 1.0f;
int xBase = mad24(xsize, 2, xid);
int yBase = mad24(ysize, 2, yid);
- float wx = (xBase < c_winSize_x) ? 1 : 0;
- float wy = (yBase < c_winSize_y) ? 1 : 0;
+ float wx1 = (xBase < c_winSize_x) ? 1 : 0;
+ float wy1 = (yBase < c_winSize_y) ? 1 : 0;
+#else
+#if WSX == 1
+ float wx0 = 1.0f;
+ int xBase = mad24(xsize, 2, xid);
+ float wx1 = (xBase < c_winSize_x) ? 1 : 0;
+#else
+ int xBase = mad24(xsize, 1, xid);
+ float wx0 = (xBase < c_winSize_x) ? 1 : 0;
+ float wx1 = 0.0f;
+#endif
+#if WSY == 1
+ float wy0 = 1.0f;
+ int yBase = mad24(ysize, 2, yid);
+ float wy1 = (yBase < c_winSize_y) ? 1 : 0;
+#else
+ int yBase = mad24(ysize, 1, yid);
+ float wy0 = (yBase < c_winSize_y) ? 1 : 0;
+ float wy1 = 0.0f;
+#endif
+#endif
float2 c_halfWin = (float2)((c_winSize_x - 1)>>1, (c_winSize_y - 1)>>1);
@@ -354,39 +378,39 @@ __kernel void lkSparse(image2d_t I, image2d_t J,
SetPatch(IPatchLocal, 0, 1,
&I_patch[0][1], &dIdx_patch[0][1], &dIdy_patch[0][1],
- &A11, &A12, &A22,1);
+ &A11, &A12, &A22,wx0);
SetPatch(IPatchLocal, 0, 2,
&I_patch[0][2], &dIdx_patch[0][2], &dIdy_patch[0][2],
- &A11, &A12, &A22,wx);
+ &A11, &A12, &A22,wx1);
}
{
SetPatch(IPatchLocal, 1, 0,
&I_patch[1][0], &dIdx_patch[1][0], &dIdy_patch[1][0],
- &A11, &A12, &A22,1);
+ &A11, &A12, &A22,wy0);
SetPatch(IPatchLocal, 1,1,
&I_patch[1][1], &dIdx_patch[1][1], &dIdy_patch[1][1],
- &A11, &A12, &A22,1);
+ &A11, &A12, &A22,wx0*wy0);
SetPatch(IPatchLocal, 1,2,
&I_patch[1][2], &dIdx_patch[1][2], &dIdy_patch[1][2],
- &A11, &A12, &A22,wx);
+ &A11, &A12, &A22,wx1*wy0);
}
{
SetPatch(IPatchLocal, 2,0,
&I_patch[2][0], &dIdx_patch[2][0], &dIdy_patch[2][0],
- &A11, &A12, &A22,wy);
+ &A11, &A12, &A22,wy1);
SetPatch(IPatchLocal, 2,1,
&I_patch[2][1], &dIdx_patch[2][1], &dIdy_patch[2][1],
- &A11, &A12, &A22,wy);
+ &A11, &A12, &A22,wx0*wy1);
SetPatch(IPatchLocal, 2,2,
&I_patch[2][2], &dIdx_patch[2][2], &dIdy_patch[2][2],
- &A11, &A12, &A22,wx*wy);
+ &A11, &A12, &A22,wx1*wy1);
}
@@ -496,24 +520,24 @@ __kernel void lkSparse(image2d_t I, image2d_t J,
if (calcErr)
{
{
- GetError(J, loc0.x, loc0.y, &I_patch[0][0], &D);
- GetError(J, loc1.x, loc0.y, &I_patch[0][1], &D);
+ GetError(J, loc0.x, loc0.y, &I_patch[0][0], &D, 1);
+ GetError(J, loc1.x, loc0.y, &I_patch[0][1], &D, wx0);
}
{
- GetError(J, loc0.x, loc1.y, &I_patch[1][0], &D);
- GetError(J, loc1.x, loc1.y, &I_patch[1][1], &D);
+ GetError(J, loc0.x, loc1.y, &I_patch[1][0], &D, wy0);
+ GetError(J, loc1.x, loc1.y, &I_patch[1][1], &D, wx0*wy0);
}
if(xBase < c_winSize_x)
{
- GetError(J, loc2.x, loc0.y, &I_patch[0][2], &D);
- GetError(J, loc2.x, loc1.y, &I_patch[1][2], &D);
+ GetError(J, loc2.x, loc0.y, &I_patch[0][2], &D, wx1);
+ GetError(J, loc2.x, loc1.y, &I_patch[1][2], &D, wx1*wy0);
}
if(yBase < c_winSize_y)
{
- GetError(J, loc0.x, loc2.y, &I_patch[2][0], &D);
- GetError(J, loc1.x, loc2.y, &I_patch[2][1], &D);
+ GetError(J, loc0.x, loc2.y, &I_patch[2][0], &D, wy1);
+ GetError(J, loc1.x, loc2.y, &I_patch[2][1], &D, wx0*wy1);
if(xBase < c_winSize_x)
- GetError(J, loc2.x, loc2.y, &I_patch[2][2], &D);
+ GetError(J, loc2.x, loc2.y, &I_patch[2][2], &D, wx1*wy1);
}
reduce1(D, smem1, tid);
@@ -526,6 +550,6 @@ __kernel void lkSparse(image2d_t I, image2d_t J,
nextPts[gid] = prevPt;
if (calcErr)
- err[gid] = smem1[0] / (float)(c_winSize_x * c_winSize_y);
+ err[gid] = smem1[0] / (float)(32 * c_winSize_x * c_winSize_y);
}
}
diff --git a/modules/video/src/optflowgf.cpp b/modules/video/src/optflowgf.cpp
index 69a7ea6..cb2dc59 100644
--- a/modules/video/src/optflowgf.cpp
+++ b/modules/video/src/optflowgf.cpp
@@ -43,7 +43,7 @@
#include "precomp.hpp"
#include "opencl_kernels_video.hpp"
-#if defined __APPLE__ || defined ANDROID
+#if defined __APPLE__ || defined __ANDROID__
#define SMALL_LOCALSIZE
#endif
diff --git a/modules/video/test/ocl/test_bgfg_mog2.cpp b/modules/video/test/ocl/test_bgfg_mog2.cpp
index 030cd09..3c9c004 100644
--- a/modules/video/test/ocl/test_bgfg_mog2.cpp
+++ b/modules/video/test/ocl/test_bgfg_mog2.cpp
@@ -2,20 +2,7 @@
#include "opencv2/ts/ocl_test.hpp"
#ifdef HAVE_OPENCL
-
-#if defined(HAVE_XINE) || \
-defined(HAVE_GSTREAMER) || \
-defined(HAVE_QUICKTIME) || \
-defined(HAVE_AVFOUNDATION) || \
-defined(HAVE_FFMPEG) || \
-defined(WIN32)
-
-# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
-#else
-# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
-#endif
-
-#if BUILD_WITH_VIDEO_INPUT_SUPPORT
+#ifdef HAVE_VIDEO_INPUT
namespace cvtest {
namespace ocl {
@@ -154,5 +141,5 @@ OCL_INSTANTIATE_TEST_CASE_P(OCL_Video, Mog2_getBackgroundImage, Combine(
}}// namespace cvtest::ocl
- #endif
+#endif
#endif
diff --git a/modules/video/test/ocl/test_optflowpyrlk.cpp b/modules/video/test/ocl/test_optflowpyrlk.cpp
index 3c264a5..20b0cea 100644
--- a/modules/video/test/ocl/test_optflowpyrlk.cpp
+++ b/modules/video/test/ocl/test_optflowpyrlk.cpp
@@ -77,6 +77,7 @@ OCL_TEST_P(PyrLKOpticalFlow, Mat)
{
static const int npoints = 1000;
static const float eps = 0.03f;
+ static const float erreps = 0.1f;
cv::Mat frame0 = readImage("optflow/RubberWhale1.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(frame0.empty());
@@ -104,6 +105,8 @@ OCL_TEST_P(PyrLKOpticalFlow, Mat)
ASSERT_EQ(cpuStatusCPU.size(), status.size());
size_t mistmatch = 0;
+ size_t errmatch = 0;
+
for (size_t i = 0; i < nextPts.size(); ++i)
{
if (status[i] != cpuStatusCPU[i])
@@ -121,18 +124,27 @@ OCL_TEST_P(PyrLKOpticalFlow, Mat)
float errdiff = 0.0f;
if (!eq || errdiff > 1e-1)
+ {
++mistmatch;
+ continue;
+ }
+
+ eq = std::abs(cpuErr[i] - err[i]) < 0.01;
+ if(!eq)
+ ++errmatch;
}
}
double bad_ratio = static_cast<double>(mistmatch) / (nextPts.size());
+ double err_ratio = static_cast<double>(errmatch) / (nextPts.size());
ASSERT_LE(bad_ratio, eps);
+ ASSERT_LE(err_ratio, erreps);
}
OCL_INSTANTIATE_TEST_CASE_P(Video, PyrLKOpticalFlow,
Combine(
- Values(21, 25),
+ Values(11, 15, 21, 25),
Values(3, 5)
)
);
diff --git a/modules/video/test/test_camshift.cpp b/modules/video/test/test_camshift.cpp
index f003286..e3f55c7 100644
--- a/modules/video/test/test_camshift.cpp
+++ b/modules/video/test/test_camshift.cpp
@@ -346,7 +346,7 @@ _exit_:
if( code < 0 )
{
-#if 0 //defined _DEBUG && defined WIN32
+#if 0 //defined _DEBUG && defined _WIN32
IplImage* dst = cvCreateImage( img_size, 8, 3 );
cvNamedWindow( "test", 1 );
cvCmpS( img, 0, img, CV_CMP_GT );
@@ -485,7 +485,7 @@ _exit_:
if( code < 0 )
{
-#if 0// defined _DEBUG && defined WIN32
+#if 0// defined _DEBUG && defined _WIN32
IplImage* dst = cvCreateImage( img_size, 8, 3 );
cvNamedWindow( "test", 1 );
cvCmpS( img, 0, img, CV_CMP_GT );
diff --git a/modules/videoio/CMakeLists.txt b/modules/videoio/CMakeLists.txt
index fb64894..086e223 100644
--- a/modules/videoio/CMakeLists.txt
+++ b/modules/videoio/CMakeLists.txt
@@ -61,6 +61,16 @@ if(DEFINED WINRT AND NOT DEFINED WINRT_8_0 AND NOT DEFINED ENABLE_WINRT_MODE_NAT
${CMAKE_CURRENT_LIST_DIR}/src/cap_winrt/MediaStreamSink.hpp)
endif()
+if(HAVE_MFX)
+ list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_mfx_common.cpp)
+ list(APPEND videoio_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/cap_mfx_common.hpp)
+ list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_mfx_reader.cpp)
+ list(APPEND videoio_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/cap_mfx_reader.hpp)
+ list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_mfx_writer.cpp)
+ list(APPEND videoio_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/cap_mfx_writer.hpp)
+ list(APPEND VIDEOIO_LIBRARIES mfx)
+endif()
+
if(WIN32 AND NOT ARM)
list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_cmu.cpp)
endif()
@@ -208,7 +218,11 @@ if(IOS)
${CMAKE_CURRENT_LIST_DIR}/src/cap_ios_abstract_camera.mm
${CMAKE_CURRENT_LIST_DIR}/src/cap_ios_photo_camera.mm
${CMAKE_CURRENT_LIST_DIR}/src/cap_ios_video_camera.mm)
+
list(APPEND VIDEOIO_LIBRARIES "-framework Accelerate" "-framework AVFoundation" "-framework CoreGraphics" "-framework CoreImage" "-framework CoreMedia" "-framework CoreVideo" "-framework QuartzCore" "-framework AssetsLibrary")
+ if(APPLE_FRAMEWORK)
+ list(APPEND VIDEOIO_LIBRARIES "-framework UIKit")
+ endif()
endif()
if(WIN32)
@@ -240,12 +254,11 @@ if(APPLE)
add_apple_compiler_options(the_module)
endif()
-if(BUILD_SHARED_LIBS)
- add_definitions(-DVIDEOIO_EXPORTS)
-endif()
-
if(MSVC)
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG")
+ if(DEFINED WINRT AND NOT DEFINED ENABLE_WINRT_MODE_NATIVE)
+ set_target_properties(${the_module} PROPERTIES VS_DESKTOP_EXTENSIONS_VERSION "${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
+ endif()
endif()
#stop automatic dependencies propagation for this module
@@ -255,15 +268,16 @@ endif()
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations)
-if(WIN32 AND WITH_FFMPEG)
+if(WIN32 AND HAVE_FFMPEG)
#copy ffmpeg dll to the output folder
if(MSVC64 OR MINGW64)
set(FFMPEG_SUFFIX _64)
endif()
+ set(ffmpeg_dir "${OpenCV_BINARY_DIR}/3rdparty/ffmpeg")
set(ffmpeg_bare_name "opencv_ffmpeg${FFMPEG_SUFFIX}.dll")
set(ffmpeg_bare_name_ver "opencv_ffmpeg${OPENCV_DLLVERSION}${FFMPEG_SUFFIX}.dll")
- set(ffmpeg_path "${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/${ffmpeg_bare_name}")
+ set(ffmpeg_path "${ffmpeg_dir}/${ffmpeg_bare_name}")
if(MSVC_IDE)
add_custom_command(TARGET ${the_module} POST_BUILD
@@ -283,8 +297,8 @@ if(WIN32 AND WITH_FFMPEG)
install(FILES "${ffmpeg_path}" DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT libs RENAME "${ffmpeg_bare_name_ver}")
if(INSTALL_CREATE_DISTRIB)
- install(FILES "${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/opencv_ffmpeg.dll" DESTINATION "bin/" COMPONENT libs RENAME "opencv_ffmpeg${OPENCV_DLLVERSION}.dll")
- install(FILES "${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/opencv_ffmpeg_64.dll" DESTINATION "bin/" COMPONENT libs RENAME "opencv_ffmpeg${OPENCV_DLLVERSION}_64.dll")
+ install(FILES "${ffmpeg_dir}/opencv_ffmpeg.dll" DESTINATION "bin/" COMPONENT libs RENAME "opencv_ffmpeg${OPENCV_DLLVERSION}.dll")
+ install(FILES "${ffmpeg_dir}/opencv_ffmpeg_64.dll" DESTINATION "bin/" COMPONENT libs RENAME "opencv_ffmpeg${OPENCV_DLLVERSION}_64.dll")
endif()
endif()
endmacro()
diff --git a/modules/videoio/include/opencv2/videoio.hpp b/modules/videoio/include/opencv2/videoio.hpp
index 458e63d..96d8df6 100644
--- a/modules/videoio/include/opencv2/videoio.hpp
+++ b/modules/videoio/include/opencv2/videoio.hpp
@@ -114,10 +114,15 @@ enum VideoCaptureAPIs {
CAP_GSTREAMER = 1800, //!< GStreamer
CAP_FFMPEG = 1900, //!< Open and record video file or stream using the FFMPEG library
CAP_IMAGES = 2000, //!< OpenCV Image Sequence (e.g. img_%02d.jpg)
- CAP_ARAVIS = 2100 //!< Aravis SDK
+ CAP_ARAVIS = 2100, //!< Aravis SDK
+ CAP_OPENCV_MJPEG = 2200, //!< Built-in OpenCV MotionJPEG codec
+ CAP_INTEL_MFX = 2300 //!< Intel MediaSDK
};
/** @brief %VideoCapture generic properties identifier.
+
+ Reading / writing properties involves many layers. Some unexpected result might happens along this chain.
+ Effective behaviour depends from device hardware, driver and API Backend.
@sa videoio_flags_others, VideoCapture::get(), VideoCapture::set()
*/
enum VideoCaptureProperties {
@@ -131,12 +136,12 @@ enum VideoCaptureProperties {
CAP_PROP_FRAME_COUNT =7, //!< Number of frames in the video file.
CAP_PROP_FORMAT =8, //!< Format of the %Mat objects returned by VideoCapture::retrieve().
CAP_PROP_MODE =9, //!< Backend-specific value indicating the current capture mode.
- CAP_PROP_BRIGHTNESS =10, //!< Brightness of the image (only for cameras).
+ CAP_PROP_BRIGHTNESS =10, //!< Brightness of the image (only for those cameras that support).
CAP_PROP_CONTRAST =11, //!< Contrast of the image (only for cameras).
CAP_PROP_SATURATION =12, //!< Saturation of the image (only for cameras).
CAP_PROP_HUE =13, //!< Hue of the image (only for cameras).
- CAP_PROP_GAIN =14, //!< Gain of the image (only for cameras).
- CAP_PROP_EXPOSURE =15, //!< Exposure (only for cameras).
+ CAP_PROP_GAIN =14, //!< Gain of the image (only for those cameras that support).
+ CAP_PROP_EXPOSURE =15, //!< Exposure (only for those cameras that support).
CAP_PROP_CONVERT_RGB =16, //!< Boolean flags indicating whether images should be converted to RGB.
CAP_PROP_WHITE_BALANCE_BLUE_U =17, //!< Currently unsupported.
CAP_PROP_RECTIFICATION =18, //!< Rectification flag for stereo cameras (note: only supported by DC1394 v 2.x backend currently).
@@ -157,7 +162,7 @@ enum VideoCaptureProperties {
CAP_PROP_TILT =34,
CAP_PROP_ROLL =35,
CAP_PROP_IRIS =36,
- CAP_PROP_SETTINGS =37, //! Pop up video/camera filter dialog (note: only supported by DSHOW backend currently. Property value is ignored)
+ CAP_PROP_SETTINGS =37, //!< Pop up video/camera filter dialog (note: only supported by DSHOW backend currently. The property value is ignored)
CAP_PROP_BUFFERSIZE =38,
CAP_PROP_AUTOFOCUS =39
};
@@ -668,9 +673,9 @@ public:
@overload
- This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Parameters are similar as the constructor VideoCapture(int index),except it takes an additional argument apiPreference.
- @return open(cameraNum + apiPreference).
+ Definitely, is same as open(int index) where `index=cameraNum + apiPreference`
+ @return `true` if the camera has been successfully opened.
*/
CV_WRAP bool open(int cameraNum, int apiPreference);
@@ -803,12 +808,12 @@ protected:
class IVideoWriter;
+/** @example videowriter_basic.cpp
+An example using VideoCapture and VideoWriter class
+ */
/** @brief Video writer class.
The class provides C++ API for writing video files or image sequences.
-
-Here is how the class can be used:
- at include samples/cpp/videowriter_basic.cpp
*/
class CV_EXPORTS_W VideoWriter
{
@@ -846,6 +851,13 @@ public:
CV_WRAP VideoWriter(const String& filename, int fourcc, double fps,
Size frameSize, bool isColor = true);
+ /** @overload
+ The `apiPreference` parameter allows to specify API backends to use. Can be used to enforce a specific reader implementation
+ if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_GSTREAMER.
+ */
+ CV_WRAP VideoWriter(const String& filename, int apiPreference, int fourcc, double fps,
+ Size frameSize, bool isColor = true);
+
/** @brief Default destructor
The method first calls VideoWriter::release to close the already opened file.
@@ -863,6 +875,11 @@ public:
CV_WRAP virtual bool open(const String& filename, int fourcc, double fps,
Size frameSize, bool isColor = true);
+ /** @overload
+ */
+ CV_WRAP bool open(const String& filename, int apiPreference, int fourcc, double fps,
+ Size frameSize, bool isColor = true);
+
/** @brief Returns true if video writer has been successfully initialized.
*/
CV_WRAP virtual bool isOpened() const;
diff --git a/modules/videoio/include/opencv2/videoio/cap_ios.h b/modules/videoio/include/opencv2/videoio/cap_ios.h
index c90ad2e..0691420 100644
--- a/modules/videoio/include/opencv2/videoio/cap_ios.h
+++ b/modules/videoio/include/opencv2/videoio/cap_ios.h
@@ -39,7 +39,7 @@
@class CvAbstractCamera;
- at interface CvAbstractCamera : NSObject
+CV_EXPORTS @interface CvAbstractCamera : NSObject
{
UIDeviceOrientation currentDeviceOrientation;
@@ -87,7 +87,7 @@
@class CvVideoCamera;
- at protocol CvVideoCameraDelegate <NSObject>
+CV_EXPORTS @protocol CvVideoCameraDelegate <NSObject>
#ifdef __cplusplus
// delegate method for processing image frames
@@ -96,7 +96,7 @@
@end
- at interface CvVideoCamera : CvAbstractCamera<AVCaptureVideoDataOutputSampleBufferDelegate>
+CV_EXPORTS @interface CvVideoCamera : CvAbstractCamera<AVCaptureVideoDataOutputSampleBufferDelegate>
{
AVCaptureVideoDataOutput *videoDataOutput;
@@ -129,14 +129,14 @@
@class CvPhotoCamera;
- at protocol CvPhotoCameraDelegate <NSObject>
+CV_EXPORTS @protocol CvPhotoCameraDelegate <NSObject>
- (void)photoCamera:(CvPhotoCamera*)photoCamera capturedImage:(UIImage *)image;
- (void)photoCameraCancel:(CvPhotoCamera*)photoCamera;
@end
- at interface CvPhotoCamera : CvAbstractCamera
+CV_EXPORTS @interface CvPhotoCamera : CvAbstractCamera
{
AVCaptureStillImageOutput *stillImageOutput;
}
diff --git a/modules/videoio/misc/gen_dict.json b/modules/videoio/misc/gen_dict.json
new file mode 100644
index 0000000..4d81516
--- /dev/null
+++ b/modules/videoio/misc/gen_dict.json
@@ -0,0 +1,63 @@
+{
+ "const_ignore_list": [
+ "CV_CAP_OPENNI",
+ "CV_CAP_OPENNI2",
+ "CV_CAP_PROP_OPENNI_",
+ "CV_CAP_INTELPERC",
+ "CV_CAP_PROP_INTELPERC_",
+ "CV_CAP_ANY",
+ "CV_CAP_MIL",
+ "CV_CAP_VFW",
+ "CV_CAP_V4L",
+ "CV_CAP_V4L2",
+ "CV_CAP_FIREWARE",
+ "CV_CAP_FIREWIRE",
+ "CV_CAP_IEEE1394",
+ "CV_CAP_DC1394",
+ "CV_CAP_CMU1394",
+ "CV_CAP_STEREO",
+ "CV_CAP_TYZX",
+ "CV_CAP_QT",
+ "CV_CAP_UNICAP",
+ "CV_CAP_DSHOW",
+ "CV_CAP_PVAPI",
+ "CV_CAP_ARAVIS",
+ "CV_CAP_PROP_DC1394_OFF",
+ "CV_CAP_PROP_DC1394_MODE_MANUAL",
+ "CV_CAP_PROP_DC1394_MODE_AUTO",
+ "CV_CAP_PROP_DC1394_MODE_ONE_PUSH_AUTO",
+ "CV_CAP_PROP_POS_MSEC",
+ "CV_CAP_PROP_POS_FRAMES",
+ "CV_CAP_PROP_POS_AVI_RATIO",
+ "CV_CAP_PROP_FPS",
+ "CV_CAP_PROP_FOURCC",
+ "CV_CAP_PROP_FRAME_COUNT",
+ "CV_CAP_PROP_FORMAT",
+ "CV_CAP_PROP_MODE",
+ "CV_CAP_PROP_BRIGHTNESS",
+ "CV_CAP_PROP_CONTRAST",
+ "CV_CAP_PROP_SATURATION",
+ "CV_CAP_PROP_HUE",
+ "CV_CAP_PROP_GAIN",
+ "CV_CAP_PROP_EXPOSURE",
+ "CV_CAP_PROP_CONVERT_RGB",
+ "CV_CAP_PROP_WHITE_BALANCE_BLUE_U",
+ "CV_CAP_PROP_RECTIFICATION",
+ "CV_CAP_PROP_MONOCHROME",
+ "CV_CAP_PROP_SHARPNESS",
+ "CV_CAP_PROP_AUTO_EXPOSURE",
+ "CV_CAP_PROP_GAMMA",
+ "CV_CAP_PROP_TEMPERATURE",
+ "CV_CAP_PROP_TRIGGER",
+ "CV_CAP_PROP_TRIGGER_DELAY",
+ "CV_CAP_PROP_WHITE_BALANCE_RED_V",
+ "CV_CAP_PROP_MAX_DC1394",
+ "CV_CAP_GSTREAMER_QUEUE_LENGTH",
+ "CV_CAP_PROP_PVAPI_MULTICASTIP",
+ "CV_CAP_PROP_SUPPORTED_PREVIEW_SIZES_STRING",
+ "CV_TYZX_LEFT",
+ "CV_TYZX_RIGHT",
+ "CV_TYZX_COLOR",
+ "CV_TYZX_Z"
+ ]
+}
diff --git a/modules/videoio/perf/perf_input.cpp b/modules/videoio/perf/perf_input.cpp
index 10ce30a..8b7d984 100644
--- a/modules/videoio/perf/perf_input.cpp
+++ b/modules/videoio/perf/perf_input.cpp
@@ -1,6 +1,6 @@
#include "perf_precomp.hpp"
-#if BUILD_WITH_VIDEO_INPUT_SUPPORT
+#ifdef HAVE_VIDEO_INPUT
using namespace std;
using namespace cv;
@@ -11,21 +11,19 @@ using std::tr1::get;
typedef perf::TestBaseWithParam<std::string> VideoCapture_Reading;
-#if defined(HAVE_MSMF)
-// MPEG2 is not supported by Media Foundation yet
-// http://social.msdn.microsoft.com/Forums/en-US/mediafoundationdevelopment/thread/39a36231-8c01-40af-9af5-3c105d684429
-PERF_TEST_P(VideoCapture_Reading, ReadFile, testing::Values( "highgui/video/big_buck_bunny.avi",
- "highgui/video/big_buck_bunny.mov",
- "highgui/video/big_buck_bunny.mp4",
- "highgui/video/big_buck_bunny.wmv" ) )
-
-#else
-PERF_TEST_P(VideoCapture_Reading, ReadFile, testing::Values( "highgui/video/big_buck_bunny.avi",
- "highgui/video/big_buck_bunny.mov",
- "highgui/video/big_buck_bunny.mp4",
- "highgui/video/big_buck_bunny.mpg",
- "highgui/video/big_buck_bunny.wmv" ) )
+const string bunny_files[] = {
+ "highgui/video/big_buck_bunny.avi",
+ "highgui/video/big_buck_bunny.mov",
+ "highgui/video/big_buck_bunny.mp4",
+#ifndef HAVE_MSMF
+ // MPEG2 is not supported by Media Foundation yet
+ // http://social.msdn.microsoft.com/Forums/en-US/mediafoundationdevelopment/thread/39a36231-8c01-40af-9af5-3c105d684429
+ "highgui/video/big_buck_bunny.mpg",
#endif
+ "highgui/video/big_buck_bunny.wmv"
+};
+
+PERF_TEST_P(VideoCapture_Reading, ReadFile, testing::ValuesIn(bunny_files) )
{
string filename = getDataPath(GetParam());
@@ -33,8 +31,7 @@ PERF_TEST_P(VideoCapture_Reading, ReadFile, testing::Values( "highgui/video/big_
TEST_CYCLE() cap.open(filename);
- bool dummy = cap.isOpened();
- SANITY_CHECK(dummy);
+ SANITY_CHECK_NOTHING();
}
-#endif // BUILD_WITH_VIDEO_INPUT_SUPPORT
+#endif // HAVE_VIDEO_INPUT
diff --git a/modules/videoio/perf/perf_output.cpp b/modules/videoio/perf/perf_output.cpp
index 8e7ec54..b99b752 100644
--- a/modules/videoio/perf/perf_output.cpp
+++ b/modules/videoio/perf/perf_output.cpp
@@ -1,6 +1,6 @@
#include "perf_precomp.hpp"
-#if BUILD_WITH_VIDEO_OUTPUT_SUPPORT
+#ifdef HAVE_VIDEO_OUTPUT
using namespace std;
using namespace cv;
@@ -11,30 +11,35 @@ using std::tr1::get;
typedef std::tr1::tuple<std::string, bool> VideoWriter_Writing_t;
typedef perf::TestBaseWithParam<VideoWriter_Writing_t> VideoWriter_Writing;
+const string image_files[] = {
+ "python/images/QCIF_00.bmp",
+ "python/images/QCIF_01.bmp",
+ "python/images/QCIF_02.bmp",
+ "python/images/QCIF_03.bmp",
+ "python/images/QCIF_04.bmp",
+ "python/images/QCIF_05.bmp"
+};
+
PERF_TEST_P(VideoWriter_Writing, WriteFrame,
- testing::Combine( testing::Values( "python/images/QCIF_00.bmp",
- "python/images/QCIF_01.bmp",
- "python/images/QCIF_02.bmp",
- "python/images/QCIF_03.bmp",
- "python/images/QCIF_04.bmp",
- "python/images/QCIF_05.bmp" ),
- testing::Bool()))
+ testing::Combine(
+ testing::ValuesIn(image_files),
+ testing::Bool()))
{
- string filename = getDataPath(get<0>(GetParam()));
- bool isColor = get<1>(GetParam());
+ const string filename = getDataPath(get<0>(GetParam()));
+ const bool isColor = get<1>(GetParam());
Mat image = imread(filename, 1);
#if defined(HAVE_MSMF) && !defined(HAVE_VFW) && !defined(HAVE_FFMPEG) // VFW has greater priority
- VideoWriter writer(cv::tempfile(".wmv"), VideoWriter::fourcc('W', 'M', 'V', '3'),
- 25, cv::Size(image.cols, image.rows), isColor);
+ const string outfile = cv::tempfile(".wmv");
+ const int fourcc = VideoWriter::fourcc('W', 'M', 'V', '3');
#else
- VideoWriter writer(cv::tempfile(".avi"), VideoWriter::fourcc('X', 'V', 'I', 'D'),
- 25, cv::Size(image.cols, image.rows), isColor);
+ const string outfile = cv::tempfile(".avi");
+ const int fourcc = VideoWriter::fourcc('X', 'V', 'I', 'D');
#endif
- TEST_CYCLE() { image = imread(filename, 1); writer << image; }
-
- bool dummy = writer.isOpened();
- SANITY_CHECK(dummy);
+ VideoWriter writer(outfile, fourcc, 25, cv::Size(image.cols, image.rows), isColor);
+ TEST_CYCLE_N(100) { writer << image; }
+ SANITY_CHECK_NOTHING();
+ remove(outfile.c_str());
}
-#endif // BUILD_WITH_VIDEO_OUTPUT_SUPPORT
+#endif // HAVE_VIDEO_OUTPUT
diff --git a/modules/videoio/perf/perf_precomp.hpp b/modules/videoio/perf/perf_precomp.hpp
index bd27700..52ba934 100644
--- a/modules/videoio/perf/perf_precomp.hpp
+++ b/modules/videoio/perf/perf_precomp.hpp
@@ -17,33 +17,4 @@
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
#endif
-#if defined(HAVE_XINE) || \
- defined(HAVE_GSTREAMER) || \
- defined(HAVE_QUICKTIME) || \
- defined(HAVE_QTKIT) || \
- defined(HAVE_AVFOUNDATION) || \
- defined(HAVE_FFMPEG) || \
- defined(HAVE_MSMF) || \
- defined(HAVE_VFW)
- /*defined(HAVE_OPENNI) too specialized */ \
-
-# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
-#else
-# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
-#endif
-
-#if /*defined(HAVE_XINE) || */\
- defined(HAVE_GSTREAMER) || \
- defined(HAVE_QUICKTIME) || \
- defined(HAVE_QTKIT) || \
- defined(HAVE_AVFOUNDATION) || \
- defined(HAVE_FFMPEG) || \
- defined(HAVE_MSMF) || \
- defined(HAVE_VFW)
-# define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 1
-#else
-# define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 0
-#endif
-
-
#endif
diff --git a/modules/videoio/src/cap.cpp b/modules/videoio/src/cap.cpp
index f1218fd..97c3a64 100644
--- a/modules/videoio/src/cap.cpp
+++ b/modules/videoio/src/cap.cpp
@@ -43,6 +43,11 @@
#include "cap_intelperc.hpp"
#include "cap_dshow.hpp"
+#ifdef HAVE_MFX
+#include "cap_mfx_reader.hpp"
+#include "cap_mfx_writer.hpp"
+#endif
+
// All WinRT versions older than 8.0 should provide classes used for video support
#if defined(WINRT) && !defined(WINRT_8_0) && defined(__cplusplus_winrt)
# include "cap_winrt_capture.hpp"
@@ -55,6 +60,8 @@
#pragma warning(disable: 4748)
#endif
+using namespace cv;
+
namespace cv
{
@@ -173,16 +180,11 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
if (pref) break;
#ifdef HAVE_MSMF
- case CV_CAP_MSMF:
+ case CAP_MSMF:
TRY_OPEN(capture, cvCreateCameraCapture_MSMF(index))
if (pref) break;
#endif
-#ifdef HAVE_TYZX
- case CV_CAP_STEREO:
- TRY_OPEN(capture, cvCreateCameraCapture_TYZX(index))
- if (pref) break;
-#endif
- case CV_CAP_VFW:
+ case CAP_VFW: // or CAP_V4L or CAP_V4L2
#ifdef HAVE_VFW
TRY_OPEN(capture, cvCreateCameraCapture_VFW(index))
#endif
@@ -190,7 +192,6 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
#if defined HAVE_LIBV4L || defined HAVE_CAMV4L || defined HAVE_CAMV4L2 || defined HAVE_VIDEOIO
TRY_OPEN(capture, cvCreateCameraCapture_V4L(index))
#endif
- if (pref) break; // CV_CAP_VFW
#ifdef HAVE_GSTREAMER
TRY_OPEN(capture, cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L2, reinterpret_cast<char *>(index)))
@@ -198,7 +199,9 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
TRY_OPEN(capture, cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L, reinterpret_cast<char *>(index)))
#endif
- case CV_CAP_FIREWIRE:
+ if (pref) break; // CAP_VFW or CAP_V4L or CAP_V4L2
+
+ case CAP_FIREWIRE:
#ifdef HAVE_DC1394_2
TRY_OPEN(capture, cvCreateCameraCapture_DC1394_2(index))
#endif
@@ -216,64 +219,64 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
TRY_OPEN(capture, cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_1394, 0))
#endif
- if (pref) break; // CV_CAP_FIREWIRE
+ if (pref) break; // CAP_FIREWIRE
#ifdef HAVE_MIL
- case CV_CAP_MIL:
+ case CAP_MIL:
TRY_OPEN(capture, cvCreateCameraCapture_MIL(index))
if (pref) break;
#endif
#if defined(HAVE_QUICKTIME) || defined(HAVE_QTKIT)
- case CV_CAP_QT:
+ case CAP_QT:
TRY_OPEN(capture, cvCreateCameraCapture_QT(index))
if (pref) break;
#endif
#ifdef HAVE_UNICAP
- case CV_CAP_UNICAP:
+ case CAP_UNICAP:
TRY_OPEN(capture, cvCreateCameraCapture_Unicap(index))
if (pref) break;
#endif
#ifdef HAVE_PVAPI
- case CV_CAP_PVAPI:
+ case CAP_PVAPI:
TRY_OPEN(capture, cvCreateCameraCapture_PvAPI(index))
if (pref) break;
#endif
#ifdef HAVE_OPENNI
- case CV_CAP_OPENNI:
+ case CAP_OPENNI:
TRY_OPEN(capture, cvCreateCameraCapture_OpenNI(index))
if (pref) break;
#endif
#ifdef HAVE_OPENNI2
- case CV_CAP_OPENNI2:
+ case CAP_OPENNI2:
TRY_OPEN(capture, cvCreateCameraCapture_OpenNI2(index))
if (pref) break;
#endif
#ifdef HAVE_XIMEA
- case CV_CAP_XIAPI:
+ case CAP_XIAPI:
TRY_OPEN(capture, cvCreateCameraCapture_XIMEA(index))
if (pref) break;
#endif
#ifdef HAVE_AVFOUNDATION
- case CV_CAP_AVFOUNDATION:
+ case CAP_AVFOUNDATION:
TRY_OPEN(capture, cvCreateCameraCapture_AVFoundation(index))
if (pref) break;
#endif
#ifdef HAVE_GIGE_API
- case CV_CAP_GIGANETIX:
+ case CAP_GIGANETIX:
TRY_OPEN(capture, cvCreateCameraCapture_Giganetix(index))
- if (pref) break; // CV_CAP_GIGANETIX
+ if (pref) break; // CAP_GIGANETIX
#endif
#ifdef HAVE_ARAVIS_API
- case CV_CAP_ARAVIS:
+ case CAP_ARAVIS:
TRY_OPEN(capture, cvCreateCameraCapture_Aravis(index))
if (pref) break;
#endif
@@ -297,12 +300,12 @@ CV_IMPL CvCapture * cvCreateFileCaptureWithPreference (const char * filename, in
if (apiPreference) break;
#ifdef HAVE_FFMPEG
- case CV_CAP_FFMPEG:
+ case CAP_FFMPEG:
TRY_OPEN(result, cvCreateFileCapture_FFMPEG_proxy (filename))
if (apiPreference) break;
#endif
- case CV_CAP_VFW:
+ case CAP_VFW:
#ifdef HAVE_VFW
TRY_OPEN(result, cvCreateFileCapture_VFW (filename))
#endif
@@ -312,7 +315,7 @@ CV_IMPL CvCapture * cvCreateFileCaptureWithPreference (const char * filename, in
#endif
if (apiPreference) break;
- case CV_CAP_MSMF:
+ case CAP_MSMF:
#ifdef HAVE_MSMF
TRY_OPEN(result, cvCreateFileCapture_MSMF (filename))
#endif
@@ -323,36 +326,36 @@ CV_IMPL CvCapture * cvCreateFileCaptureWithPreference (const char * filename, in
if (apiPreference) break;
#ifdef HAVE_GSTREAMER
- case CV_CAP_GSTREAMER:
+ case CAP_GSTREAMER:
TRY_OPEN(result, cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename))
if (apiPreference) break;
#endif
#if defined(HAVE_QUICKTIME) || defined(HAVE_QTKIT)
- case CV_CAP_QT:
+ case CAP_QT:
TRY_OPEN(result, cvCreateFileCapture_QT (filename))
if (apiPreference) break;
#endif
#ifdef HAVE_AVFOUNDATION
- case CV_CAP_AVFOUNDATION:
+ case CAP_AVFOUNDATION:
TRY_OPEN(result, cvCreateFileCapture_AVFoundation (filename))
if (apiPreference) break;
#endif
#ifdef HAVE_OPENNI
- case CV_CAP_OPENNI:
+ case CAP_OPENNI:
TRY_OPEN(result, cvCreateFileCapture_OpenNI (filename))
if (apiPreference) break;
#endif
#ifdef HAVE_OPENNI2
- case CV_CAP_OPENNI2:
+ case CAP_OPENNI2:
TRY_OPEN(result, cvCreateFileCapture_OpenNI2 (filename))
if (apiPreference) break;
#endif
- case CV_CAP_IMAGES:
+ case CAP_IMAGES:
TRY_OPEN(result, cvCreateFileCapture_Images (filename))
}
@@ -361,61 +364,73 @@ CV_IMPL CvCapture * cvCreateFileCaptureWithPreference (const char * filename, in
CV_IMPL CvCapture * cvCreateFileCapture (const char * filename)
{
- return cvCreateFileCaptureWithPreference(filename, CV_CAP_ANY);
+ return cvCreateFileCaptureWithPreference(filename, CAP_ANY);
}
/**
* Videowriter dispatching method: it tries to find the first
* API that can write a given stream.
*/
-CV_IMPL CvVideoWriter* cvCreateVideoWriter( const char* filename, int fourcc,
+static CvVideoWriter* cvCreateVideoWriterWithPreference(const char* filename, int apiPreference, int fourcc,
double fps, CvSize frameSize, int is_color )
{
- // If none of the writers is used
- // these statements suppress 'unused parameter' warnings.
CV_UNUSED(frameSize);
CV_UNUSED(is_color);
- //CV_FUNCNAME( "cvCreateVideoWriter" );
-
CvVideoWriter *result = 0;
if(!fourcc || !fps)
TRY_OPEN(result, cvCreateVideoWriter_Images(filename))
-#ifdef HAVE_FFMPEG
- TRY_OPEN(result, cvCreateVideoWriter_FFMPEG_proxy (filename, fourcc, fps, frameSize, is_color))
-#endif
-
-#ifdef HAVE_VFW
- TRY_OPEN(result, cvCreateVideoWriter_VFW(filename, fourcc, fps, frameSize, is_color))
-#endif
-
-#ifdef HAVE_MSMF
- TRY_OPEN(result, cvCreateVideoWriter_MSMF(filename, fourcc, fps, frameSize, is_color))
-#endif
-
-/* #ifdef HAVE_XINE
- TRY_OPEN(result, cvCreateVideoWriter_XINE(filename, fourcc, fps, frameSize, is_color))
- #endif
-*/
-#ifdef HAVE_AVFOUNDATION
- TRY_OPEN(result, cvCreateVideoWriter_AVFoundation(filename, fourcc, fps, frameSize, is_color))
-#endif
-
-#if defined(HAVE_QUICKTIME) || defined(HAVE_QTKIT)
- TRY_OPEN(result, cvCreateVideoWriter_QT(filename, fourcc, fps, frameSize, is_color))
-#endif
-
-#ifdef HAVE_GSTREAMER
- TRY_OPEN(result, cvCreateVideoWriter_GStreamer(filename, fourcc, fps, frameSize, is_color))
-#endif
-
- TRY_OPEN(result, cvCreateVideoWriter_Images(filename))
+ switch(apiPreference)
+ {
+ default:
+ //exit if the specified API is unavaliable
+ if (apiPreference != CAP_ANY) break;
+ #ifdef HAVE_FFMPEG
+ case CAP_FFMPEG:
+ TRY_OPEN(result, cvCreateVideoWriter_FFMPEG_proxy (filename, fourcc, fps, frameSize, is_color))
+ if (apiPreference != CAP_ANY) break;
+ #endif
+ #ifdef HAVE_VFW
+ case CAP_VFW:
+ TRY_OPEN(result, cvCreateVideoWriter_VFW(filename, fourcc, fps, frameSize, is_color))
+ if (apiPreference != CAP_ANY) break;
+ #endif
+ #ifdef HAVE_MSMF
+ case CAP_MSMF:
+ TRY_OPEN(result, cvCreateVideoWriter_MSMF(filename, fourcc, fps, frameSize, is_color))
+ if (apiPreference != CAP_ANY) break;
+ #endif
+ #ifdef HAVE_AVFOUNDATION
+ case CAP_AVFOUNDATION:
+ TRY_OPEN(result, cvCreateVideoWriter_AVFoundation(filename, fourcc, fps, frameSize, is_color))
+ if (apiPreference != CAP_ANY) break;
+ #endif
+ #if defined(HAVE_QUICKTIME) || defined(HAVE_QTKIT)
+ case(CAP_QT):
+ TRY_OPEN(result, cvCreateVideoWriter_QT(filename, fourcc, fps, frameSize, is_color))
+ if (apiPreference != CAP_ANY) break;
+ #endif
+ #ifdef HAVE_GSTREAMER
+ case CAP_GSTREAMER:
+ TRY_OPEN(result, cvCreateVideoWriter_GStreamer (filename, fourcc, fps, frameSize, is_color))
+ if (apiPreference != CAP_ANY) break;
+ #endif
+ case CAP_IMAGES:
+ TRY_OPEN(result, cvCreateVideoWriter_Images(filename))
+ if (apiPreference != CAP_ANY) break;
+ }
return result;
}
+CV_IMPL CvVideoWriter* cvCreateVideoWriter( const char* filename, int fourcc,
+ double fps, CvSize frameSize, int is_color )
+{
+ return cvCreateVideoWriterWithPreference(filename, CAP_ANY, fourcc, fps, frameSize, is_color);
+}
+
CV_IMPL int cvWriteFrame( CvVideoWriter* writer, const IplImage* image )
{
return writer ? writer->writeFrame(image) : 0;
@@ -438,16 +453,16 @@ static Ptr<IVideoCapture> IVideoCapture_create(int index)
int domains[] =
{
#ifdef HAVE_DSHOW
- CV_CAP_DSHOW,
+ CAP_DSHOW,
#endif
#ifdef HAVE_INTELPERC
- CV_CAP_INTELPERC,
+ CAP_INTELPERC,
#endif
#ifdef WINRT_VIDEO
CAP_WINRT,
#endif
#ifdef HAVE_GPHOTO2
- CV_CAP_GPHOTO2,
+ CAP_GPHOTO2,
#endif
-1, -1
};
@@ -474,14 +489,14 @@ static Ptr<IVideoCapture> IVideoCapture_create(int index)
switch (domains[i])
{
#ifdef HAVE_DSHOW
- case CV_CAP_DSHOW:
+ case CAP_DSHOW:
capture = makePtr<VideoCapture_DShow>(index);
- break; // CV_CAP_DSHOW
+ break; // CAP_DSHOW
#endif
#ifdef HAVE_INTELPERC
- case CV_CAP_INTELPERC:
+ case CAP_INTELPERC:
capture = makePtr<VideoCapture_IntelPerC>();
- break; // CV_CAP_INTEL_PERC
+ break; // CAP_INTEL_PERC
#endif
#ifdef WINRT_VIDEO
case CAP_WINRT:
@@ -491,7 +506,7 @@ static Ptr<IVideoCapture> IVideoCapture_create(int index)
break; // CAP_WINRT
#endif
#ifdef HAVE_GPHOTO2
- case CV_CAP_GPHOTO2:
+ case CAP_GPHOTO2:
capture = createGPhoto2Capture(index);
break;
#endif
@@ -510,9 +525,12 @@ static Ptr<IVideoCapture> IVideoCapture_create(const String& filename)
{
int domains[] =
{
- CV_CAP_ANY,
+ CAP_ANY,
#ifdef HAVE_GPHOTO2
- CV_CAP_GPHOTO2,
+ CAP_GPHOTO2,
+#endif
+#ifdef HAVE_MFX
+ CAP_INTEL_MFX,
#endif
-1, -1
};
@@ -524,14 +542,19 @@ static Ptr<IVideoCapture> IVideoCapture_create(const String& filename)
switch (domains[i])
{
- case CV_CAP_ANY:
+ case CAP_ANY:
capture = createMotionJpegCapture(filename);
break;
#ifdef HAVE_GPHOTO2
- case CV_CAP_GPHOTO2:
+ case CAP_GPHOTO2:
capture = createGPhoto2Capture(filename);
break;
#endif
+#ifdef HAVE_MFX
+ case CAP_INTEL_MFX:
+ capture = makePtr<VideoCapture_IntelMFX>(filename);
+ break;
+#endif
}
if (capture && capture->isOpened())
@@ -543,11 +566,22 @@ static Ptr<IVideoCapture> IVideoCapture_create(const String& filename)
return Ptr<IVideoCapture>();
}
-static Ptr<IVideoWriter> IVideoWriter_create(const String& filename, int _fourcc, double fps, Size frameSize, bool isColor)
+static Ptr<IVideoWriter> IVideoWriter_create(const String& filename, int apiPreference, int _fourcc, double fps, Size frameSize, bool isColor)
{
Ptr<IVideoWriter> iwriter;
- if( _fourcc == CV_FOURCC('M', 'J', 'P', 'G') )
+#ifdef HAVE_MFX
+ if (apiPreference == CAP_INTEL_MFX || apiPreference == CAP_ANY)
+ {
+ iwriter = VideoWriter_IntelMFX::create(filename, _fourcc, fps, frameSize, isColor);
+ if (!iwriter.empty())
+ return iwriter;
+ }
+#endif
+
+ if( (apiPreference == CAP_OPENCV_MJPEG || apiPreference == CAP_ANY)
+ && _fourcc == CV_FOURCC('M', 'J', 'P', 'G') )
iwriter = createMotionJpegWriter(filename, fps, frameSize, isColor);
+
return iwriter;
}
@@ -556,28 +590,33 @@ VideoCapture::VideoCapture()
VideoCapture::VideoCapture(const String& filename, int apiPreference)
{
+ CV_TRACE_FUNCTION();
open(filename, apiPreference);
}
VideoCapture::VideoCapture(const String& filename)
{
+ CV_TRACE_FUNCTION();
open(filename, CAP_ANY);
}
VideoCapture::VideoCapture(int index)
{
+ CV_TRACE_FUNCTION();
open(index);
}
VideoCapture::~VideoCapture()
{
+ CV_TRACE_FUNCTION();
+
icap.release();
cap.release();
}
bool VideoCapture::open(const String& filename, int apiPreference)
{
- CV_INSTRUMENT_REGION()
+ CV_TRACE_FUNCTION();
if (isOpened()) release();
icap = IVideoCapture_create(filename);
@@ -590,14 +629,14 @@ bool VideoCapture::open(const String& filename, int apiPreference)
bool VideoCapture::open(const String& filename)
{
- CV_INSTRUMENT_REGION()
+ CV_TRACE_FUNCTION();
return open(filename, CAP_ANY);
}
bool VideoCapture::open(int index)
{
- CV_INSTRUMENT_REGION()
+ CV_TRACE_FUNCTION();
if (isOpened()) release();
icap = IVideoCapture_create(index);
@@ -608,6 +647,8 @@ bool VideoCapture::open(int index)
}
bool VideoCapture::open(int cameraNum, int apiPreference)
{
+ CV_TRACE_FUNCTION();
+
cameraNum = cameraNum + apiPreference;
return open(cameraNum);
}
@@ -619,6 +660,7 @@ bool VideoCapture::isOpened() const
void VideoCapture::release()
{
+ CV_TRACE_FUNCTION();
icap.release();
cap.release();
}
@@ -725,6 +767,12 @@ VideoWriter::VideoWriter(const String& filename, int _fourcc, double fps, Size f
open(filename, _fourcc, fps, frameSize, isColor);
}
+
+VideoWriter::VideoWriter(const String& filename, int apiPreference, int _fourcc, double fps, Size frameSize, bool isColor)
+{
+ open(filename, apiPreference, _fourcc, fps, frameSize, isColor);
+}
+
void VideoWriter::release()
{
iwriter.release();
@@ -738,13 +786,18 @@ VideoWriter::~VideoWriter()
bool VideoWriter::open(const String& filename, int _fourcc, double fps, Size frameSize, bool isColor)
{
+ return open(filename, CAP_ANY, _fourcc, fps, frameSize, isColor);
+}
+
+bool VideoWriter::open(const String& filename, int apiPreference, int _fourcc, double fps, Size frameSize, bool isColor)
+{
CV_INSTRUMENT_REGION()
if (isOpened()) release();
- iwriter = IVideoWriter_create(filename, _fourcc, fps, frameSize, isColor);
+ iwriter = IVideoWriter_create(filename, apiPreference, _fourcc, fps, frameSize, isColor);
if (!iwriter.empty())
return true;
- writer.reset(cvCreateVideoWriter(filename.c_str(), _fourcc, fps, frameSize, isColor));
+ writer.reset(cvCreateVideoWriterWithPreference(filename.c_str(), apiPreference, _fourcc, fps, frameSize, isColor));
return isOpened();
}
diff --git a/modules/videoio/src/cap_aravis.cpp b/modules/videoio/src/cap_aravis.cpp
index c272bee..cb6098e 100644
--- a/modules/videoio/src/cap_aravis.cpp
+++ b/modules/videoio/src/cap_aravis.cpp
@@ -64,6 +64,7 @@
// read/write
// CAP_PROP_AUTO_EXPOSURE(0|1)
// CAP_PROP_EXPOSURE(t), t in seconds
+// CAP_PROP_BRIGHTNESS (ev), exposure compensation in EV for auto exposure algorithm
// CAP_PROP_GAIN(g), g >=0 or -1 for automatic control if CAP_PROP_AUTO_EXPOSURE is true
// CAP_PROP_FPS(f)
// CAP_PROP_FOURCC(type)
@@ -77,11 +78,15 @@
// video/x-raw, fourcc:'GREY' -> 8bit, 1 channel
// video/x-raw, fourcc:'Y800' -> 8bit, 1 channel
// video/x-raw, fourcc:'Y12 ' -> 12bit, 1 channel
+// video/x-raw, fourcc:'Y16 ' -> 16bit, 1 channel
+// video/x-raw, fourcc:'GRBG' -> 8bit, 1 channel
//
#define MODE_GREY CV_FOURCC_MACRO('G','R','E','Y')
#define MODE_Y800 CV_FOURCC_MACRO('Y','8','0','0')
#define MODE_Y12 CV_FOURCC_MACRO('Y','1','2',' ')
+#define MODE_Y16 CV_FOURCC_MACRO('Y','1','6',' ')
+#define MODE_GRBG CV_FOURCC_MACRO('G','R','B','G')
#define CLIP(a,b,c) (cv::max(cv::min((a),(c)),(b)))
@@ -104,7 +109,7 @@ public:
virtual IplImage* retrieveFrame(int);
virtual int getCaptureDomain()
{
- return CV_CAP_ARAVIS;
+ return cv::CAP_ARAVIS;
}
protected:
@@ -139,6 +144,7 @@ protected:
double exposureMax; // Camera's maximum exposure time.
bool controlExposure; // Flag if automatic exposure shall be done by this SW
+ double exposureCompensation;
bool autoGain;
double targetGrey; // Target grey value (mid grey))
@@ -179,10 +185,11 @@ CvCaptureCAM_Aravis::CvCaptureCAM_Aravis()
xoffset = yoffset = width = height = 0;
fpsMin = fpsMax = gainMin = gainMax = exposureMin = exposureMax = 0;
controlExposure = false;
+ exposureCompensation = 0;
targetGrey = 0;
frameID = prevFrameID = 0;
- num_buffers = 50;
+ num_buffers = 10;
frame = NULL;
}
@@ -310,10 +317,12 @@ IplImage* CvCaptureCAM_Aravis::retrieveFrame(int)
int depth = 0, channels = 0;
switch(pixelFormat) {
case ARV_PIXEL_FORMAT_MONO_8:
+ case ARV_PIXEL_FORMAT_BAYER_GR_8:
depth = IPL_DEPTH_8U;
channels = 1;
break;
case ARV_PIXEL_FORMAT_MONO_12:
+ case ARV_PIXEL_FORMAT_MONO_16:
depth = IPL_DEPTH_16U;
channels = 1;
break;
@@ -334,8 +343,8 @@ IplImage* CvCaptureCAM_Aravis::retrieveFrame(int)
}
cvCopy(&src, frame);
- if(controlExposure && ((frameID - prevFrameID) > 1)) {
- // control exposure every second frame
+ if(controlExposure && ((frameID - prevFrameID) >= 3)) {
+ // control exposure every third frame
// i.e. skip frame taken with previous exposure setup
autoExposureControl(frame);
}
@@ -372,15 +381,15 @@ void CvCaptureCAM_Aravis::autoExposureControl(IplImage* image)
midGrey = brightness;
double maxe = 1e6 / fps;
- double ne = CLIP( ( exposure * d ) / dmid, exposureMin, maxe);
+ double ne = CLIP( ( exposure * d ) / ( dmid * pow(sqrt(2), -2 * exposureCompensation) ), exposureMin, maxe);
// if change of value requires intervention
- if(fabs(d-dmid) > 5) {
+ if(std::fabs(d-dmid) > 5) {
double ev, ng = 0;
if(gainAvailable && autoGain) {
ev = log( d / dmid ) / log(2);
- ng = CLIP( gain + ev, gainMin, gainMax);
+ ng = CLIP( gain + ev + exposureCompensation, gainMin, gainMax);
if( ng < gain ) {
// piority 1 - reduce gain
@@ -390,8 +399,9 @@ void CvCaptureCAM_Aravis::autoExposureControl(IplImage* image)
}
if(exposureAvailable) {
- if(abs(exposure - ne) > 2) {
- // priority 2 - control of exposure time
+ // priority 2 - control of exposure time
+ if(std::fabs(exposure - ne) > 2) {
+ // we have not yet reach the max-e level
arv_camera_set_exposure_time(camera, (exposure = ne) );
return;
}
@@ -436,6 +446,9 @@ double CvCaptureCAM_Aravis::getProperty( int property_id ) const
case CV_CAP_PROP_AUTO_EXPOSURE:
return (controlExposure ? 1 : 0);
+ case CV_CAP_PROP_BRIGHTNESS:
+ return exposureCompensation;
+
case CV_CAP_PROP_EXPOSURE:
if(exposureAvailable) {
/* exposure time in seconds, like 1/100 s */
@@ -463,6 +476,10 @@ double CvCaptureCAM_Aravis::getProperty( int property_id ) const
return MODE_Y800;
case ARV_PIXEL_FORMAT_MONO_12:
return MODE_Y12;
+ case ARV_PIXEL_FORMAT_MONO_16:
+ return MODE_Y16;
+ case ARV_PIXEL_FORMAT_BAYER_GR_8:
+ return MODE_GRBG;
}
}
break;
@@ -490,6 +507,9 @@ bool CvCaptureCAM_Aravis::setProperty( int property_id, double value )
}
}
break;
+ case CV_CAP_PROP_BRIGHTNESS:
+ exposureCompensation = CLIP(value, -3., 3.);
+ break;
case CV_CAP_PROP_EXPOSURE:
if(exposureAvailable) {
@@ -528,6 +548,14 @@ bool CvCaptureCAM_Aravis::setProperty( int property_id, double value )
newFormat = ARV_PIXEL_FORMAT_MONO_12;
targetGrey = 2048;
break;
+ case MODE_Y16:
+ newFormat = ARV_PIXEL_FORMAT_MONO_16;
+ targetGrey = 32768;
+ break;
+ case MODE_GRBG:
+ newFormat = ARV_PIXEL_FORMAT_BAYER_GR_8;
+ targetGrey = 128;
+ break;
}
if(newFormat != pixelFormat) {
stopCapture();
@@ -570,7 +598,6 @@ bool CvCaptureCAM_Aravis::startCapture()
{
if(init_buffers() ) {
arv_camera_set_acquisition_mode(camera, ARV_ACQUISITION_MODE_CONTINUOUS);
- arv_device_set_string_feature_value(arv_camera_get_device (camera), "TriggerMode" , "Off");
arv_camera_start_acquisition(camera);
return true;
diff --git a/modules/videoio/src/cap_avfoundation.mm b/modules/videoio/src/cap_avfoundation.mm
index 867fcfb..0866782 100644
--- a/modules/videoio/src/cap_avfoundation.mm
+++ b/modules/videoio/src/cap_avfoundation.mm
@@ -317,7 +317,8 @@ int CvCaptureCAM::startCaptureDevice(int cameraNum) {
capture = [[CaptureDelegate alloc] init];
AVCaptureDevice *device;
- NSArray* devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
+ NSArray* devices = [[AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]
+ arrayByAddingObjectsFromArray:[AVCaptureDevice devicesWithMediaType:AVMediaTypeMuxed]];
if ([devices count] == 0) {
std::cout << "AV Foundation didn't find any attached Video Input Devices!" << std::endl;
[localpool drain];
diff --git a/modules/videoio/src/cap_avfoundation_mac.mm b/modules/videoio/src/cap_avfoundation_mac.mm
index ce6e3d0..0ef461c 100644
--- a/modules/videoio/src/cap_avfoundation_mac.mm
+++ b/modules/videoio/src/cap_avfoundation_mac.mm
@@ -293,7 +293,7 @@ void CvCaptureCAM::stopCaptureDevice() {
[mCaptureSession release];
[mCaptureDeviceInput release];
- [mCaptureDevice release];
+ // [mCaptureDevice release]; fix #7833
[mCaptureVideoDataOutput release];
[mCapture release];
@@ -305,7 +305,8 @@ int CvCaptureCAM::startCaptureDevice(int cameraNum) {
NSAutoreleasePool *localpool = [[NSAutoreleasePool alloc] init];
// get capture device
- NSArray *devices = [AVCaptureDevice devicesWithMediaType: AVMediaTypeVideo];
+ NSArray *devices = [[AVCaptureDevice devicesWithMediaType: AVMediaTypeVideo]
+ arrayByAddingObjectsFromArray:[AVCaptureDevice devicesWithMediaType:AVMediaTypeMuxed]];
if ( devices.count == 0 ) {
fprintf(stderr, "OpenCV: AVFoundation didn't find any attached Video Input Devices!\n");
@@ -693,7 +694,15 @@ CvCaptureFile::CvCaptureFile(const char* filename) {
return;
}
- mAssetTrack = [[mAsset tracksWithMediaType: AVMediaTypeVideo][0] retain];
+ NSArray *tracks = [mAsset tracksWithMediaType:AVMediaTypeVideo];
+ if ([tracks count] == 0) {
+ fprintf(stderr, "OpenCV: Couldn't read video stream from file \"%s\"\n", filename);
+ [localpool drain];
+ started = 0;
+ return;
+ }
+
+ mAssetTrack = [tracks[0] retain];
if ( ! setupReadingAt(kCMTimeZero) ) {
fprintf(stderr, "OpenCV: Couldn't read movie file \"%s\"\n", filename);
diff --git a/modules/videoio/src/cap_cmu.cpp b/modules/videoio/src/cap_cmu.cpp
index 8c8a1be..90bb1ce 100644
--- a/modules/videoio/src/cap_cmu.cpp
+++ b/modules/videoio/src/cap_cmu.cpp
@@ -41,7 +41,7 @@
#include "precomp.hpp"
-#ifdef WIN32
+#ifdef _WIN32
/****************** Capturing video from camera via CMU lib *******************/
@@ -548,4 +548,4 @@ CvCapture * cvCreateCameraCapture_CMU (int index)
}
#endif // CMU
-#endif // WIN32
+#endif // _WIN32
diff --git a/modules/videoio/src/cap_dc1394.cpp b/modules/videoio/src/cap_dc1394.cpp
index 06fbe43..7e593d6 100644
--- a/modules/videoio/src/cap_dc1394.cpp
+++ b/modules/videoio/src/cap_dc1394.cpp
@@ -97,7 +97,7 @@ Tested with 2.6.12 with libdc1394-1.0.0, libraw1394-0.10.1 using a Point Grey Fl
#include "precomp.hpp"
-#if !defined WIN32 && defined HAVE_DC1394
+#if !defined _WIN32 && defined HAVE_DC1394
#include <unistd.h>
#include <stdint.h>
diff --git a/modules/videoio/src/cap_dc1394_v2.cpp b/modules/videoio/src/cap_dc1394_v2.cpp
index d120b59..b3fc18c 100644
--- a/modules/videoio/src/cap_dc1394_v2.cpp
+++ b/modules/videoio/src/cap_dc1394_v2.cpp
@@ -45,7 +45,7 @@
#include <unistd.h>
#include <stdint.h>
-#ifdef WIN32
+#ifdef _WIN32
// On Windows, we have no sys/select.h, but we need to pick up
// select() which is in winsock2.
#ifndef __SYS_SELECT_H__
@@ -54,7 +54,7 @@
#endif
#else
#include <sys/select.h>
-#endif /*WIN32*/
+#endif /*_WIN32*/
#include <dc1394/dc1394.h>
#include <stdlib.h>
#include <string.h>
diff --git a/modules/videoio/src/cap_dshow.cpp b/modules/videoio/src/cap_dshow.cpp
index 8360e43..d8a9e84 100644
--- a/modules/videoio/src/cap_dshow.cpp
+++ b/modules/videoio/src/cap_dshow.cpp
@@ -41,7 +41,7 @@
#include "precomp.hpp"
-#if (defined WIN32 || defined _WIN32) && defined HAVE_DSHOW
+#if defined _WIN32 && defined HAVE_DSHOW
#include "cap_dshow.hpp"
/*
@@ -108,55 +108,11 @@ Thanks to:
#include <vector>
//Include Directshow stuff here so we don't worry about needing all the h files.
-#if defined _MSC_VER && _MSC_VER >= 1500
-# include "DShow.h"
-# include "strmif.h"
-# include "Aviriff.h"
-# include "dvdmedia.h"
-# include "bdaiface.h"
-#else
-# ifdef _MSC_VER
-# define __extension__
- typedef BOOL WINBOOL;
-#endif
-
-#include "dshow/dshow.h"
-#include "dshow/dvdmedia.h"
-#include "dshow/bdatypes.h"
-
-interface IEnumPIDMap : public IUnknown
-{
-public:
- virtual HRESULT STDMETHODCALLTYPE Next(
- /* [in] */ ULONG cRequest,
- /* [size_is][out][in] */ PID_MAP *pPIDMap,
- /* [out] */ ULONG *pcReceived) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Skip(
- /* [in] */ ULONG cRecords) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Reset( void) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE Clone(
- /* [out] */ IEnumPIDMap **ppIEnumPIDMap) = 0;
-};
-
-interface IMPEG2PIDMap : public IUnknown
-{
- virtual HRESULT STDMETHODCALLTYPE MapPID(
- /* [in] */ ULONG culPID,
- /* [in] */ ULONG *pulPID,
- /* [in] */ MEDIA_SAMPLE_CONTENT MediaSampleContent) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE UnmapPID(
- /* [in] */ ULONG culPID,
- /* [in] */ ULONG *pulPID) = 0;
-
- virtual HRESULT STDMETHODCALLTYPE EnumPIDMap(
- /* [out] */ IEnumPIDMap **pIEnumPIDMap) = 0;
-};
-
-#endif
+#include "DShow.h"
+#include "strmif.h"
+#include "Aviriff.h"
+#include "dvdmedia.h"
+#include "bdaiface.h"
//for threading
#include <process.h>
@@ -337,11 +293,17 @@ interface ISampleGrabber : public IUnknown
#ifdef _DEBUG
#include <strsafe.h>
-//change for verbose debug info
-static bool gs_verbose = true;
-
static void DebugPrintOut(const char *format, ...)
{
+ static int gs_verbose = -1;
+ if (gs_verbose < 0)
+ {
+ // Fetch initial debug state from environment - defaults to disabled
+ const char* s = getenv("OPENCV_DSHOW_DEBUG");
+ gs_verbose = s != NULL && atoi(s) != 0;
+ }
+
+
if (gs_verbose)
{
va_list args;
@@ -487,9 +449,6 @@ class videoInput{
videoInput();
~videoInput();
- //turns off console messages - default is to print messages
- static void setVerbose(bool _verbose);
-
//Functions in rough order they should be used.
static int listDevices(bool silent = false);
@@ -608,9 +567,9 @@ class videoInput{
GUID CAPTURE_MODE;
//Extra video subtypes
- GUID MEDIASUBTYPE_Y800;
- GUID MEDIASUBTYPE_Y8;
- GUID MEDIASUBTYPE_GREY;
+ // GUID MEDIASUBTYPE_Y800;
+ // GUID MEDIASUBTYPE_Y8;
+ // GUID MEDIASUBTYPE_GREY;
videoDevice * VDList[VI_MAX_CAMERAS];
GUID mediaSubtypes[VI_NUM_TYPES];
@@ -665,6 +624,9 @@ public:
latestBufferLength = 0;
hEvent = CreateEvent(NULL, true, false, NULL);
+ pixels = 0;
+ ptrBuffer = 0;
+ numBytes = 0;
}
@@ -798,6 +760,10 @@ videoDevice::videoDevice(){
autoReconnect = false;
requestedFrameTime = -1;
+ pBuffer = 0;
+ pixels = 0;
+ formatType = 0;
+
memset(wDeviceName, 0, sizeof(WCHAR) * 255);
memset(nDeviceName, 0, sizeof(char) * 255);
@@ -877,14 +843,12 @@ void videoDevice::NukeDownstream(IBaseFilter *pBF){
void videoDevice::destroyGraph(){
HRESULT hr = 0;
- //int FuncRetval=0;
- //int NumFilters=0;
int i = 0;
while (hr == NOERROR)
{
IEnumFilters * pEnum = 0;
- ULONG cFetched;
+ ULONG cFetched = 0;
// We must get the enumerator again every time because removing a filter from the graph
// invalidates the enumerator. We always get only the first filter from each enumerator.
@@ -917,9 +881,11 @@ void videoDevice::destroyGraph(){
pFilter->Release();
pFilter = NULL;
}
- else break;
pEnum->Release();
pEnum = NULL;
+
+ if (cFetched == 0)
+ break;
i++;
}
@@ -1060,15 +1026,18 @@ videoInput::videoInput(){
callbackSetCount = 0;
bCallback = true;
+ connection = PhysConn_Video_Composite;
+ CAPTURE_MODE = PIN_CATEGORY_PREVIEW;
+
//setup a max no of device objects
for(int i=0; i<VI_MAX_CAMERAS; i++) VDList[i] = new videoDevice();
DebugPrintOut("\n***** VIDEOINPUT LIBRARY - %2.04f - TFW07 *****\n\n",VI_VERSION);
//added for the pixelink firewire camera
- //MEDIASUBTYPE_Y800 = (GUID)FOURCCMap(FCC('Y800'));
- //MEDIASUBTYPE_Y8 = (GUID)FOURCCMap(FCC('Y8'));
- //MEDIASUBTYPE_GREY = (GUID)FOURCCMap(FCC('GREY'));
+ // MEDIASUBTYPE_Y800 = (GUID)FOURCCMap(FCC('Y800'));
+ // MEDIASUBTYPE_Y8 = (GUID)FOURCCMap(FCC('Y8'));
+ // MEDIASUBTYPE_GREY = (GUID)FOURCCMap(FCC('GREY'));
//The video types we support
//in order of preference
@@ -1120,20 +1089,6 @@ videoInput::videoInput(){
}
-
-// ----------------------------------------------------------------------
-// static - set whether messages get printed to console or not
-//
-// ----------------------------------------------------------------------
-
-void videoInput::setVerbose(bool _verbose){
-#ifdef _DEBUG
- gs_verbose = _verbose;
-#else
- (void)_verbose; // Suppress 'unreferenced parameter' warning
-#endif
-}
-
// ----------------------------------------------------------------------
// change to use callback or regular capture
// callback tells you when a new frame has arrived
diff --git a/modules/videoio/src/cap_ffmpeg.cpp b/modules/videoio/src/cap_ffmpeg.cpp
index 26e2ead..a70cbdf 100644
--- a/modules/videoio/src/cap_ffmpeg.cpp
+++ b/modules/videoio/src/cap_ffmpeg.cpp
@@ -43,7 +43,7 @@
#include <string>
-#if defined HAVE_FFMPEG && !defined WIN32
+#if defined HAVE_FFMPEG && !defined _WIN32
#include "cap_ffmpeg_impl.hpp"
#else
#include "cap_ffmpeg_api.hpp"
@@ -61,7 +61,7 @@ static CvWriteFrame_Plugin icvWriteFrame_FFMPEG_p = 0;
static cv::Mutex _icvInitFFMPEG_mutex;
-#if defined WIN32 || defined _WIN32
+#if defined _WIN32
static const HMODULE cv_GetCurrentModule()
{
HMODULE h = 0;
@@ -84,7 +84,7 @@ public:
}
private:
- #if defined WIN32 || defined _WIN32
+ #if defined _WIN32
HMODULE icvFFOpenCV;
~icvInitFFMPEG()
@@ -99,7 +99,7 @@ private:
icvInitFFMPEG()
{
- #if defined WIN32 || defined _WIN32
+ #if defined _WIN32
const wchar_t* module_name_ = L"opencv_ffmpeg"
CVAUX_STRW(CV_MAJOR_VERSION) CVAUX_STRW(CV_MINOR_VERSION) CVAUX_STRW(CV_SUBMINOR_VERSION)
#if (defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__)
diff --git a/modules/videoio/src/cap_ffmpeg_api.hpp b/modules/videoio/src/cap_ffmpeg_api.hpp
index 0b7f45c..7144f4a 100644
--- a/modules/videoio/src/cap_ffmpeg_api.hpp
+++ b/modules/videoio/src/cap_ffmpeg_api.hpp
@@ -6,7 +6,7 @@ extern "C"
{
#endif
-#if defined WIN32 || defined _WIN32
+#if defined _WIN32
# define OPENCV_FFMPEG_API __declspec(dllexport)
#elif defined __GNUC__ && __GNUC__ >= 4
# define OPENCV_FFMPEG_API __attribute__ ((visibility ("default")))
diff --git a/modules/videoio/src/cap_ffmpeg_impl.hpp b/modules/videoio/src/cap_ffmpeg_impl.hpp
index fc5141e..5a9b10f 100644
--- a/modules/videoio/src/cap_ffmpeg_impl.hpp
+++ b/modules/videoio/src/cap_ffmpeg_impl.hpp
@@ -41,7 +41,7 @@
//M*/
#include "cap_ffmpeg_api.hpp"
-#if !(defined(WIN32) || defined(_WIN32) || defined(WINCE))
+#if !(defined(_WIN32) || defined(WINCE))
# include <pthread.h>
#endif
#include <assert.h>
@@ -92,7 +92,7 @@ extern "C" {
#define CV_WARN(message) fprintf(stderr, "warning: %s (%s:%d)\n", message, __FILE__, __LINE__)
#endif
-#if defined WIN32 || defined _WIN32
+#if defined _WIN32
#include <windows.h>
#if defined _MSC_VER && _MSC_VER < 1900
struct timespec
@@ -172,7 +172,7 @@ extern "C" {
#define LIBAVFORMAT_INTERRUPT_OPEN_TIMEOUT_MS 30000
#define LIBAVFORMAT_INTERRUPT_READ_TIMEOUT_MS 30000
-#ifdef WIN32
+#ifdef _WIN32
// http://stackoverflow.com/questions/5404277/porting-clock-gettime-to-windows
static
@@ -289,7 +289,7 @@ static int get_number_of_cpus(void)
{
#if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION(52, 111, 0)
return 1;
-#elif defined WIN32 || defined _WIN32
+#elif defined _WIN32
SYSTEM_INFO sysinfo;
GetSystemInfo( &sysinfo );
@@ -584,7 +584,7 @@ private:
ImplMutex& operator = (const ImplMutex& m);
};
-#if defined WIN32 || defined _WIN32 || defined WINCE
+#if defined _WIN32 || defined WINCE
struct ImplMutex::Impl
{
@@ -635,7 +635,7 @@ struct ImplMutex::Impl
int refcount;
};
-#elif defined __linux__ && !defined ANDROID
+#elif defined __linux__ && !defined __ANDROID__
struct ImplMutex::Impl
{
@@ -669,13 +669,13 @@ struct ImplMutex::Impl
void ImplMutex::init()
{
- impl = (Impl*)malloc(sizeof(Impl));
+ impl = new Impl();
impl->init();
}
void ImplMutex::destroy()
{
impl->destroy();
- free(impl);
+ delete(impl);
impl = NULL;
}
void ImplMutex::lock() { impl->lock(); }
@@ -716,12 +716,25 @@ static int LockCallBack(void **mutex, AVLockOp op)
static ImplMutex _mutex;
static bool _initialized = false;
+class AutoLock
+{
+public:
+ AutoLock(ImplMutex& m) : mutex(&m) { mutex->lock(); }
+ ~AutoLock() { mutex->unlock(); }
+protected:
+ ImplMutex* mutex;
+private:
+ AutoLock(const AutoLock&); // disabled
+ AutoLock& operator = (const AutoLock&); // disabled
+};
+
+
class InternalFFMpegRegister
{
public:
InternalFFMpegRegister()
{
- _mutex.lock();
+ AutoLock lock(_mutex);
if (!_initialized)
{
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 13, 0)
@@ -738,7 +751,6 @@ public:
_initialized = true;
}
- _mutex.unlock();
}
~InternalFFMpegRegister()
@@ -752,6 +764,7 @@ static InternalFFMpegRegister _init;
bool CvCapture_FFMPEG::open( const char* _filename )
{
+ AutoLock lock(_mutex);
unsigned i;
bool valid = false;
@@ -1374,7 +1387,7 @@ void CvVideoWriter_FFMPEG::init()
static AVFrame * icv_alloc_picture_FFMPEG(int pix_fmt, int width, int height, bool alloc)
{
AVFrame * picture;
- uint8_t * picture_buf;
+ uint8_t * picture_buf = 0;
int size;
#if LIBAVCODEC_BUILD >= (LIBAVCODEC_VERSION_MICRO >= 100 \
@@ -1403,6 +1416,7 @@ static AVFrame * icv_alloc_picture_FFMPEG(int pix_fmt, int width, int height, bo
}
else {
}
+
return picture;
}
@@ -1498,6 +1512,8 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc,
best= p;
}
}
+ if (best == NULL)
+ return NULL;
c->time_base.den= best->num;
c->time_base.num= best->den;
}
@@ -1783,24 +1799,27 @@ void CvVideoWriter_FFMPEG::close()
av_free(outbuf);
- if (!(fmt->flags & AVFMT_NOFILE))
+ if (oc)
{
- /* close the output file */
+ if (!(fmt->flags & AVFMT_NOFILE))
+ {
+ /* close the output file */
#if LIBAVCODEC_VERSION_INT < ((52<<16)+(123<<8)+0)
#if LIBAVCODEC_VERSION_INT >= ((51<<16)+(49<<8)+0)
- url_fclose(oc->pb);
+ url_fclose(oc->pb);
#else
- url_fclose(&oc->pb);
+ url_fclose(&oc->pb);
#endif
#else
- avio_close(oc->pb);
+ avio_close(oc->pb);
#endif
- }
+ }
- /* free the stream */
- avformat_free_context(oc);
+ /* free the stream */
+ avformat_free_context(oc);
+ }
av_freep(&aligned_input);
@@ -2101,6 +2120,8 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
CvCapture_FFMPEG* cvCreateFileCapture_FFMPEG( const char* filename )
{
CvCapture_FFMPEG* capture = (CvCapture_FFMPEG*)malloc(sizeof(*capture));
+ if (!capture)
+ return 0;
capture->init();
if( capture->open( filename ))
return capture;
@@ -2145,6 +2166,8 @@ CvVideoWriter_FFMPEG* cvCreateVideoWriter_FFMPEG( const char* filename, int four
int width, int height, int isColor )
{
CvVideoWriter_FFMPEG* writer = (CvVideoWriter_FFMPEG*)malloc(sizeof(*writer));
+ if (!writer)
+ return 0;
writer->init();
if( writer->open( filename, fourcc, fps, width, height, isColor != 0 ))
return writer;
@@ -2309,6 +2332,8 @@ AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CV_CODEC
}
}
+ if (best == NULL)
+ return NULL;
c->time_base.den= best->num;
c->time_base.num= best->den;
}
@@ -2450,6 +2475,8 @@ void OutputMediaStream_FFMPEG::write(unsigned char* data, int size, int keyFrame
struct OutputMediaStream_FFMPEG* create_OutputMediaStream_FFMPEG(const char* fileName, int width, int height, double fps)
{
OutputMediaStream_FFMPEG* stream = (OutputMediaStream_FFMPEG*) malloc(sizeof(OutputMediaStream_FFMPEG));
+ if (!stream)
+ return 0;
if (stream->open(fileName, width, height, fps))
return stream;
@@ -2717,6 +2744,8 @@ bool InputMediaStream_FFMPEG::read(unsigned char** data, int* size, int* endOfFi
InputMediaStream_FFMPEG* create_InputMediaStream_FFMPEG(const char* fileName, int* codec, int* chroma_format, int* width, int* height)
{
InputMediaStream_FFMPEG* stream = (InputMediaStream_FFMPEG*) malloc(sizeof(InputMediaStream_FFMPEG));
+ if (!stream)
+ return 0;
if (stream && stream->open(fileName, codec, chroma_format, width, height))
return stream;
diff --git a/modules/videoio/src/cap_giganetix.cpp b/modules/videoio/src/cap_giganetix.cpp
index 4356b92..10af21d 100644
--- a/modules/videoio/src/cap_giganetix.cpp
+++ b/modules/videoio/src/cap_giganetix.cpp
@@ -48,7 +48,7 @@
#include <GigEVisionSDK.h>
#include <GigEVisionSDK.cpp>
-#ifdef WIN32
+#ifdef _WIN32
#include <io.h>
#else
#include <stdio.h>
diff --git a/modules/videoio/src/cap_gphoto2.cpp b/modules/videoio/src/cap_gphoto2.cpp
index 7fa94f5..974d185 100644
--- a/modules/videoio/src/cap_gphoto2.cpp
+++ b/modules/videoio/src/cap_gphoto2.cpp
@@ -1184,7 +1184,7 @@ void DigitalCameraCapture::message(MsgType msgType, const char * msg,
msgsBuffer << out;
}
#if !defined(NDEBUG)
-#if defined(WIN32) || defined(_WIN32)
+#if defined(_WIN32)
::OutputDebugString(out.c_str());
#else
fputs(out.c_str(), stderr);
diff --git a/modules/videoio/src/cap_gstreamer.cpp b/modules/videoio/src/cap_gstreamer.cpp
index 552c1cb..a3ece26 100644
--- a/modules/videoio/src/cap_gstreamer.cpp
+++ b/modules/videoio/src/cap_gstreamer.cpp
@@ -168,6 +168,10 @@ protected:
gint width;
gint height;
double fps;
+
+ bool isPosFramesSupported;
+ bool isPosFramesEmulated;
+ gint64 emulatedFrameNumber;
};
/*!
@@ -191,6 +195,10 @@ void CvCapture_GStreamer::init()
width = -1;
height = -1;
fps = -1;
+
+ isPosFramesSupported = false;
+ isPosFramesEmulated = false;
+ emulatedFrameNumber = -1;
}
/*!
@@ -212,6 +220,9 @@ void CvCapture_GStreamer::close()
width = -1;
height = -1;
fps = -1;
+ isPosFramesSupported = false;
+ isPosFramesEmulated = false;
+ emulatedFrameNumber = -1;
}
/*!
@@ -253,6 +264,9 @@ bool CvCapture_GStreamer::grabFrame()
if(!buffer)
return false;
+ if (isPosFramesEmulated)
+ emulatedFrameNumber++;
+
return true;
}
@@ -287,6 +301,8 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int)
}
int depth = 3;
+ bool height_extend = false;
+
#if GST_VERSION_MAJOR > 0
depth = 0;
const gchar* name = gst_structure_get_name(structure);
@@ -295,9 +311,16 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int)
if (!name)
return 0;
- // we support 3 types of data:
+ // we support 11 types of data:
// video/x-raw, format=BGR -> 8bit, 3 channels
// video/x-raw, format=GRAY8 -> 8bit, 1 channel
+ // video/x-raw, format=UYVY -> 8bit, 2 channel
+ // video/x-raw, format=YUY2 -> 8bit, 2 channel
+ // video/x-raw, format=YVYU -> 8bit, 2 channel
+ // video/x-raw, format=NV12 -> 8bit, 1 channel (height is 1.5x larger than true height)
+ // video/x-raw, format=NV21 -> 8bit, 1 channel (height is 1.5x larger than true height)
+ // video/x-raw, format=YV12 -> 8bit, 1 channel (height is 1.5x larger than true height)
+ // video/x-raw, format=I420 -> 8bit, 1 channel (height is 1.5x larger than true height)
// video/x-bayer -> 8bit, 1 channel
// image/jpeg -> 8bit, mjpeg: buffer_size x 1 x 1
// bayer data is never decoded, the user is responsible for that
@@ -311,6 +334,13 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int)
if (strcasecmp(format, "BGR") == 0) {
depth = 3;
}
+ else if( (strcasecmp(format, "UYVY") == 0) || (strcasecmp(format, "YUY2") == 0) || (strcasecmp(format, "YVYU") == 0) ){
+ depth = 2;
+ }
+ else if( (strcasecmp(format, "NV12") == 0) || (strcasecmp(format, "NV21") == 0) || (strcasecmp(format, "YV12") == 0) || (strcasecmp(format, "I420") == 0) ){
+ depth = 1;
+ height_extend = true;
+ }
else if(strcasecmp(format, "GRAY8") == 0){
depth = 1;
}
@@ -324,7 +354,11 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int)
}
#endif
if (depth > 0) {
- frame = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, depth);
+ if(height_extend){
+ frame = cvCreateImageHeader(cvSize(width, height*3/2), IPL_DEPTH_8U, depth);
+ }else{
+ frame = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, depth);
+ }
} else {
gst_caps_unref(buffer_caps);
return 0;
@@ -408,6 +442,9 @@ void CvCapture_GStreamer::startPipeline()
return;
}
+ if (isPosFramesEmulated)
+ emulatedFrameNumber = 0;
+
//printf("state now playing\n");
handleMessage(pipeline);
__END__;
@@ -810,8 +847,20 @@ bool CvCapture_GStreamer::open( int type, const char* filename )
"blue_mask", G_TYPE_INT, 0xFF0000,
NULL);
#else
- // support 1 and 3 channel 8 bit data, as well as bayer (also 1 channel, 8bit)
+
caps = gst_caps_from_string("video/x-raw, format=(string){BGR, GRAY8}; video/x-bayer,format=(string){rggb,bggr,grbg,gbrg}; image/jpeg");
+
+ if(manualpipeline){
+ GstPad* sink_pad = gst_element_get_static_pad(sink, "sink");
+ GstCaps* peer_caps = gst_pad_peer_query_caps(sink_pad,NULL);
+ if (!gst_caps_can_intersect(caps, peer_caps)) {
+ gst_caps_unref(caps);
+ caps = gst_caps_from_string("video/x-raw, format=(string){UYVY,YUY2,YVYU,NV12,NV21,YV12,I420}");
+ }
+ gst_object_unref(sink_pad);
+ gst_caps_unref(peer_caps);
+ }
+
#endif
gst_app_sink_set_caps(GST_APP_SINK(sink), caps);
gst_caps_unref(caps);
@@ -847,6 +896,8 @@ bool CvCapture_GStreamer::open( int type, const char* filename )
duration = -1;
}
+ handleMessage(pipeline);
+
GstPad* pad = gst_element_get_static_pad(sink, "sink");
#if GST_VERSION_MAJOR == 0
GstCaps* buffer_caps = gst_pad_get_caps(pad);
@@ -873,9 +924,32 @@ bool CvCapture_GStreamer::open( int type, const char* filename )
fps = (double)num/(double)denom;
- // GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "pipeline")
- if (file)
- stopPipeline();
+ {
+ GstFormat format_;
+ gint64 value_ = -1;
+ gboolean status_;
+
+ format_ = GST_FORMAT_DEFAULT;
+#if GST_VERSION_MAJOR == 0
+#define FORMAT &format_
+#else
+#define FORMAT format_
+#endif
+ status_ = gst_element_query_position(pipeline, FORMAT, &value_);
+#undef FORMAT
+ if (!status_ || value_ != 0 || duration < 0)
+ {
+ CV_WARN(cv::format("Cannot query video position: status=%d value=%lld duration=%lld\n",
+ (int)status_, (long long int)value_, (long long int)duration).c_str());
+ isPosFramesSupported = false;
+ isPosFramesEmulated = true;
+ emulatedFrameNumber = 0;
+ }
+ else
+ isPosFramesSupported = true;
+ }
+
+ GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "pipeline");
}
__END__;
@@ -914,14 +988,22 @@ double CvCapture_GStreamer::getProperty( int propId ) const
format = GST_FORMAT_TIME;
status = gst_element_query_position(sink, FORMAT, &value);
if(!status) {
+ handleMessage(pipeline);
CV_WARN("GStreamer: unable to query position of stream");
return 0;
}
return value * 1e-6; // nano seconds to milli seconds
case CV_CAP_PROP_POS_FRAMES:
+ if (!isPosFramesSupported)
+ {
+ if (isPosFramesEmulated)
+ return emulatedFrameNumber;
+ return 0; // TODO getProperty() "unsupported" value should be changed
+ }
format = GST_FORMAT_DEFAULT;
status = gst_element_query_position(sink, FORMAT, &value);
if(!status) {
+ handleMessage(pipeline);
CV_WARN("GStreamer: unable to query position of stream");
return 0;
}
@@ -930,6 +1012,7 @@ double CvCapture_GStreamer::getProperty( int propId ) const
format = GST_FORMAT_PERCENT;
status = gst_element_query_position(sink, FORMAT, &value);
if(!status) {
+ handleMessage(pipeline);
CV_WARN("GStreamer: unable to query position of stream");
return 0;
}
@@ -1013,24 +1096,75 @@ bool CvCapture_GStreamer::setProperty( int propId, double value )
flags = (GstSeekFlags) (GST_SEEK_FLAG_FLUSH|GST_SEEK_FLAG_ACCURATE);
if(!gst_element_seek_simple(GST_ELEMENT(pipeline), format,
flags, (gint64) (value * GST_MSECOND))) {
+ handleMessage(pipeline);
CV_WARN("GStreamer: unable to seek");
}
+ else
+ {
+ if (isPosFramesEmulated)
+ {
+ if (value == 0)
+ {
+ emulatedFrameNumber = 0;
+ return true;
+ }
+ else
+ {
+ isPosFramesEmulated = false; // reset frame counter emulation
+ }
+ }
+ }
break;
case CV_CAP_PROP_POS_FRAMES:
+ {
+ if (!isPosFramesSupported)
+ {
+ if (isPosFramesEmulated)
+ {
+ if (value == 0)
+ {
+ restartPipeline();
+ emulatedFrameNumber = 0;
+ return true;
+ }
+ }
+ return false;
+ }
format = GST_FORMAT_DEFAULT;
flags = (GstSeekFlags) (GST_SEEK_FLAG_FLUSH|GST_SEEK_FLAG_ACCURATE);
if(!gst_element_seek_simple(GST_ELEMENT(pipeline), format,
flags, (gint64) value)) {
+ handleMessage(pipeline);
CV_WARN("GStreamer: unable to seek");
+ break;
}
- break;
+ // wait for status update
+ gst_element_get_state(pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
+ return true;
+ }
case CV_CAP_PROP_POS_AVI_RATIO:
format = GST_FORMAT_PERCENT;
flags = (GstSeekFlags) (GST_SEEK_FLAG_FLUSH|GST_SEEK_FLAG_ACCURATE);
if(!gst_element_seek_simple(GST_ELEMENT(pipeline), format,
flags, (gint64) (value * GST_FORMAT_PERCENT_MAX))) {
+ handleMessage(pipeline);
CV_WARN("GStreamer: unable to seek");
}
+ else
+ {
+ if (isPosFramesEmulated)
+ {
+ if (value == 0)
+ {
+ emulatedFrameNumber = 0;
+ return true;
+ }
+ else
+ {
+ isPosFramesEmulated = false; // reset frame counter emulation
+ }
+ }
+ }
break;
case CV_CAP_PROP_FRAME_WIDTH:
if(value > 0)
@@ -1719,7 +1853,7 @@ void handleMessage(GstElement * pipeline)
while(gst_bus_have_pending(bus)) {
msg = gst_bus_pop(bus);
- //printf("Got %s message\n", GST_MESSAGE_TYPE_NAME(msg));
+ //printf("\t\tGot %s message\n", GST_MESSAGE_TYPE_NAME(msg));
if(gst_is_missing_plugin_message(msg))
{
@@ -1731,13 +1865,15 @@ void handleMessage(GstElement * pipeline)
case GST_MESSAGE_STATE_CHANGED:
GstState oldstate, newstate, pendstate;
gst_message_parse_state_changed(msg, &oldstate, &newstate, &pendstate);
- //fprintf(stderr, "state changed from %s to %s (pending: %s)\n", gst_element_state_get_name(oldstate),
+ //fprintf(stderr, "\t\t%s: state changed from %s to %s (pending: %s)\n",
+ // gst_element_get_name(GST_MESSAGE_SRC (msg)),
+ // gst_element_state_get_name(oldstate),
// gst_element_state_get_name(newstate), gst_element_state_get_name(pendstate));
break;
case GST_MESSAGE_ERROR:
gst_message_parse_error(msg, &err, &debug);
- fprintf(stderr, "GStreamer Plugin: Embedded video playback halted; module %s reported: %s\n",
- gst_element_get_name(GST_MESSAGE_SRC (msg)), err->message);
+ //fprintf(stderr, "\t\tGStreamer Plugin: Embedded video playback halted; module %s reported: %s\n",
+ // gst_element_get_name(GST_MESSAGE_SRC (msg)), err->message);
g_error_free(err);
g_free(debug);
@@ -1745,14 +1881,14 @@ void handleMessage(GstElement * pipeline)
gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL);
break;
case GST_MESSAGE_EOS:
- //fprintf(stderr, "reached the end of the stream.");
+ //fprintf(stderr, "\t\treached the end of the stream.");
break;
case GST_MESSAGE_STREAM_STATUS:
gst_message_parse_stream_status(msg,&tp,&elem);
- //fprintf(stderr, "stream status: elem %s, %i\n", GST_ELEMENT_NAME(elem), tp);
+ //fprintf(stderr, "\t\tstream status: elem %s, %i\n", GST_ELEMENT_NAME(elem), tp);
break;
default:
- //fprintf(stderr, "unhandled message %s\n",GST_MESSAGE_TYPE_NAME(msg));
+ //fprintf(stderr, "\t\tunhandled message %s\n",GST_MESSAGE_TYPE_NAME(msg));
break;
}
}
diff --git a/modules/videoio/src/cap_images.cpp b/modules/videoio/src/cap_images.cpp
index f87c554..9eac7db 100644
--- a/modules/videoio/src/cap_images.cpp
+++ b/modules/videoio/src/cap_images.cpp
@@ -209,7 +209,7 @@ static char* icvExtractPattern(const char *filename, unsigned *offset)
char *at = strchr(name, '%');
if(at)
{
- int dummy;
+ unsigned int dummy;
if(sscanf(at + 1, "%ud", &dummy) != 1)
return 0;
name = strdup(filename);
@@ -236,6 +236,7 @@ static char* icvExtractPattern(const char *filename, unsigned *offset)
int size = (int)strlen(filename) + 20;
name = (char *)malloc(size);
+ CV_Assert(name != NULL);
strncpy(name, filename, at - filename);
name[at - filename] = 0;
@@ -245,7 +246,7 @@ static char* icvExtractPattern(const char *filename, unsigned *offset)
char *extension;
for(i = 0, extension = at; isdigit(at[i]); i++, extension++)
;
- char places[10];
+ char places[13] = {0};
sprintf(places, "%dd", i);
strcat(name, places);
diff --git a/modules/videoio/src/cap_libv4l.cpp b/modules/videoio/src/cap_libv4l.cpp
index 3ff564b..d82ad43 100644
--- a/modules/videoio/src/cap_libv4l.cpp
+++ b/modules/videoio/src/cap_libv4l.cpp
@@ -239,7 +239,7 @@ make & enjoy!
#include "precomp.hpp"
-#if !defined WIN32 && defined HAVE_LIBV4L
+#if !defined _WIN32 && defined HAVE_LIBV4L
#define CLEAR(x) memset (&(x), 0, sizeof (x))
@@ -312,6 +312,7 @@ typedef struct CvCaptureCAM_V4L
int deviceHandle;
int bufferIndex;
int FirstCapture;
+ bool returnFrame;
int width; int height;
int mode;
@@ -1094,6 +1095,8 @@ static CvCaptureCAM_V4L * icvCaptureFromCAM_V4L (const char* deviceName)
capture->is_v4l2_device = 1;
}
+ capture->returnFrame = true;
+
return capture;
}; /* End icvOpenCAM_V4L */
@@ -1119,6 +1122,7 @@ static int read_frame_v4l2(CvCaptureCAM_V4L* capture) {
default:
/* display the error and stop processing */
+ capture->returnFrame = false;
perror ("VIDIOC_DQBUF");
return -1;
}
@@ -1360,7 +1364,10 @@ static IplImage* icvRetrieveFrameCAM_V4L( CvCaptureCAM_V4L* capture, int) {
}
- return(&capture->frame);
+ if (capture->returnFrame)
+ return(&capture->frame);
+ else
+ return 0;
}
static int zeroPropertyQuietly(CvCaptureCAM_V4L* capture, int property_id, int value)
diff --git a/modules/videoio/src/cap_mfx_common.cpp b/modules/videoio/src/cap_mfx_common.cpp
new file mode 100644
index 0000000..dda0cc2
--- /dev/null
+++ b/modules/videoio/src/cap_mfx_common.cpp
@@ -0,0 +1,183 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#include "cap_mfx_common.hpp"
+
+// Linux specific
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+using namespace std;
+using namespace cv;
+
+bool DeviceHandler::init(MFXVideoSession &session)
+{
+ mfxStatus res = MFX_ERR_NONE;
+ mfxIMPL impl = MFX_IMPL_AUTO;
+ mfxVersion ver = { {19, 1} };
+
+ res = session.Init(impl, &ver);
+ DBG(cout << "MFX SessionInit: " << res << endl);
+
+ res = session.QueryIMPL(&impl);
+ DBG(cout << "MFX QueryIMPL: " << res << " => " << asHex(impl) << endl);
+
+ res = session.QueryVersion(&ver);
+ DBG(cout << "MFX QueryVersion: " << res << " => " << ver.Major << "." << ver.Minor << endl);
+
+ if (res != MFX_ERR_NONE)
+ return false;
+
+ return initDeviceSession(session);
+}
+
+//==================================================================================================
+
+VAHandle::VAHandle() {
+ // TODO: provide a way of modifying this path
+ const string filename = "/dev/dri/card0";
+ file = open(filename.c_str(), O_RDWR);
+ if (file < 0)
+ CV_Error(Error::StsError, "Can't open file: " + filename);
+ display = vaGetDisplayDRM(file);
+}
+
+VAHandle::~VAHandle() {
+ if (display) {
+ vaTerminate(display);
+ }
+ if (file >= 0) {
+ close(file);
+ }
+}
+
+bool VAHandle::initDeviceSession(MFXVideoSession &session) {
+ int majorVer = 0, minorVer = 0;
+ VAStatus va_res = vaInitialize(display, &majorVer, &minorVer);
+ DBG(cout << "vaInitialize: " << va_res << endl << majorVer << '.' << minorVer << endl);
+ if (va_res == VA_STATUS_SUCCESS) {
+ mfxStatus mfx_res = session.SetHandle(static_cast<mfxHandleType>(MFX_HANDLE_VA_DISPLAY), display);
+ DBG(cout << "MFX SetHandle: " << mfx_res << endl);
+ if (mfx_res == MFX_ERR_NONE) {
+ return true;
+ }
+ }
+ return false;
+}
+
+//==================================================================================================
+
+SurfacePool::SurfacePool(ushort width_, ushort height_, ushort count, const mfxFrameInfo &frameInfo, uchar bpp)
+ : width(alignSize(width_, 32)),
+ height(alignSize(height_, 32)),
+ oneSize(width * height * bpp / 8),
+ buffers(count * oneSize),
+ surfaces(count)
+{
+ for(int i = 0; i < count; ++i)
+ {
+ mfxFrameSurface1 &surface = surfaces[i];
+ uint8_t * dataPtr = buffers + oneSize * i;
+ memset(&surface, 0, sizeof(mfxFrameSurface1));
+ surface.Info = frameInfo;
+ surface.Data.Y = dataPtr;
+ surface.Data.UV = dataPtr + width * height;
+ surface.Data.Pitch = width;
+ DBG(cout << "allocate surface " << (void*)&surface << ", Y = " << (void*)dataPtr << " (" << width << "x" << height << ")" << endl);
+ }
+ DBG(cout << "Allocated: " << endl
+ << "- surface data: " << buffers.size() << " bytes" << endl
+ << "- surface headers: " << surfaces.size() * sizeof(mfxFrameSurface1) << " bytes" << endl);
+}
+
+SurfacePool::~SurfacePool()
+{
+}
+
+mfxFrameSurface1 *SurfacePool::getFreeSurface()
+{
+ for(std::vector<mfxFrameSurface1>::iterator i = surfaces.begin(); i != surfaces.end(); ++i)
+ if (!i->Data.Locked)
+ return &(*i);
+ return 0;
+}
+
+//==================================================================================================
+
+ReadBitstream::ReadBitstream(const char *filename, size_t maxSize) : drain(false)
+{
+ input.open(filename, std::ios::in | std::ios::binary);
+ DBG(cout << "Open " << filename << " -> " << input.is_open() << std::endl);
+ memset(&stream, 0, sizeof(stream));
+ stream.MaxLength = maxSize;
+ stream.Data = new mfxU8[stream.MaxLength];
+ CV_Assert(stream.Data);
+}
+
+ReadBitstream::~ReadBitstream()
+{
+ delete[] stream.Data;
+}
+
+bool ReadBitstream::isOpened() const
+{
+ return input.is_open();
+}
+
+bool ReadBitstream::isDone() const
+{
+ return input.eof();
+}
+
+bool ReadBitstream::read()
+{
+ memmove(stream.Data, stream.Data + stream.DataOffset, stream.DataLength);
+ stream.DataOffset = 0;
+ input.read((char*)(stream.Data + stream.DataLength), stream.MaxLength - stream.DataLength);
+ if (input.eof() || input.good())
+ {
+ mfxU32 bytesRead = input.gcount();
+ if (bytesRead > 0)
+ {
+ stream.DataLength += bytesRead;
+ DBG(cout << "read " << bytesRead << " bytes" << endl);
+ return true;
+ }
+ }
+ return false;
+}
+
+//==================================================================================================
+
+WriteBitstream::WriteBitstream(const char * filename, size_t maxSize)
+{
+ output.open(filename, std::ios::out | std::ios::binary);
+ DBG(cout << "BS Open " << filename << " -> " << output.is_open() << std::endl);
+ memset(&stream, 0, sizeof(stream));
+ stream.MaxLength = maxSize;
+ stream.Data = new mfxU8[stream.MaxLength];
+ DBG(cout << "BS Allocate " << maxSize << " bytes (" << ((float)maxSize / (1 << 20)) << " Mb)" << endl);
+ CV_Assert(stream.Data);
+}
+
+WriteBitstream::~WriteBitstream()
+{
+ delete[] stream.Data;
+}
+
+bool WriteBitstream::write()
+{
+ output.write((char*)(stream.Data + stream.DataOffset), stream.DataLength);
+ stream.DataLength = 0;
+ return output.good();
+}
+
+bool WriteBitstream::isOpened() const
+{
+ return output.is_open();
+}
+
+//==================================================================================================
diff --git a/modules/videoio/src/cap_mfx_common.hpp b/modules/videoio/src/cap_mfx_common.hpp
new file mode 100644
index 0000000..aea0164
--- /dev/null
+++ b/modules/videoio/src/cap_mfx_common.hpp
@@ -0,0 +1,318 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#ifndef MFXHELPER_H
+#define MFXHELPER_H
+
+#include "opencv2/core.hpp"
+
+#include <iostream>
+#include <fstream>
+#include <sstream>
+
+#include <mfxcommon.h>
+#include <mfxstructures.h>
+#include <mfxvideo++.h>
+#include <mfxvp8.h>
+#include <mfxjpeg.h>
+#include <mfxplugin++.h>
+
+// //
+// Debug helpers //
+// //
+
+#if 0
+# define DBG(i) i
+#else
+# define DBG(i)
+#endif
+
+#if 1
+# define MSG(i) i
+#else
+# define MSG(i)
+#endif
+
+template <typename T>
+struct HexWrap {
+ HexWrap(T val_) : val(val_) {}
+ T val;
+};
+
+template <typename T>
+inline std::ostream & operator<<(std::ostream &out, const HexWrap<T> &wrap) {
+ std::ios_base::fmtflags flags = out.flags(std::ios::hex | std::ios::showbase);
+ out << wrap.val;
+ out.flags(flags);
+ return out;
+}
+
+template <typename T>
+inline ::HexWrap<T> asHex(const T & val) {
+ return ::HexWrap<T>(val);
+}
+
+struct FourCC
+{
+ FourCC(uint val) : val32(val) {}
+ FourCC(char a, char b, char c, char d) { val8[0] = a; val8[1] = b; val8[2] = c; val8[3] = d; }
+ union {
+ uint val32;
+ int vali32;
+ uchar val8[4];
+ };
+};
+
+inline std::ostream & operator<<(std::ostream &out, FourCC cc) {
+ for (size_t i = 0; i < 4; out << cc.val8[i++]) {}
+ out << " (" << asHex(cc.val32) << ")";
+ return out;
+}
+
+inline std::string mfxStatusToString(mfxStatus s) {
+ switch (s)
+ {
+ case MFX_ERR_NONE: return "MFX_ERR_NONE";
+ case MFX_ERR_UNKNOWN: return "MFX_ERR_UNKNOWN";
+ case MFX_ERR_NULL_PTR: return "MFX_ERR_NULL_PTR";
+ case MFX_ERR_UNSUPPORTED: return "MFX_ERR_UNSUPPORTED";
+ case MFX_ERR_MEMORY_ALLOC: return "MFX_ERR_MEMORY_ALLOC";
+ case MFX_ERR_NOT_ENOUGH_BUFFER: return "MFX_ERR_NOT_ENOUGH_BUFFER";
+ case MFX_ERR_INVALID_HANDLE: return "MFX_ERR_INVALID_HANDLE";
+ case MFX_ERR_LOCK_MEMORY: return "MFX_ERR_LOCK_MEMORY";
+ case MFX_ERR_NOT_INITIALIZED: return "MFX_ERR_NOT_INITIALIZED";
+ case MFX_ERR_NOT_FOUND: return "MFX_ERR_NOT_FOUND";
+ case MFX_ERR_MORE_DATA: return "MFX_ERR_MORE_DATA";
+ case MFX_ERR_MORE_SURFACE: return "MFX_ERR_MORE_SURFACE";
+ case MFX_ERR_ABORTED: return "MFX_ERR_ABORTED";
+ case MFX_ERR_DEVICE_LOST: return "MFX_ERR_DEVICE_LOST";
+ case MFX_ERR_INCOMPATIBLE_VIDEO_PARAM: return "MFX_ERR_INCOMPATIBLE_VIDEO_PARAM";
+ case MFX_ERR_INVALID_VIDEO_PARAM: return "MFX_ERR_INVALID_VIDEO_PARAM";
+ case MFX_ERR_UNDEFINED_BEHAVIOR: return "MFX_ERR_UNDEFINED_BEHAVIOR";
+ case MFX_ERR_DEVICE_FAILED: return "MFX_ERR_DEVICE_FAILED";
+ case MFX_ERR_MORE_BITSTREAM: return "MFX_ERR_MORE_BITSTREAM";
+ case MFX_ERR_INCOMPATIBLE_AUDIO_PARAM: return "MFX_ERR_INCOMPATIBLE_AUDIO_PARAM";
+ case MFX_ERR_INVALID_AUDIO_PARAM: return "MFX_ERR_INVALID_AUDIO_PARAM";
+ case MFX_ERR_GPU_HANG: return "MFX_ERR_GPU_HANG";
+ case MFX_ERR_REALLOC_SURFACE: return "MFX_ERR_REALLOC_SURFACE";
+ case MFX_WRN_IN_EXECUTION: return "MFX_WRN_IN_EXECUTION";
+ case MFX_WRN_DEVICE_BUSY: return "MFX_WRN_DEVICE_BUSY";
+ case MFX_WRN_VIDEO_PARAM_CHANGED: return "MFX_WRN_VIDEO_PARAM_CHANGED";
+ case MFX_WRN_PARTIAL_ACCELERATION: return "MFX_WRN_PARTIAL_ACCELERATION";
+ case MFX_WRN_INCOMPATIBLE_VIDEO_PARAM: return "MFX_WRN_INCOMPATIBLE_VIDEO_PARAM";
+ case MFX_WRN_VALUE_NOT_CHANGED: return "MFX_WRN_VALUE_NOT_CHANGED";
+ case MFX_WRN_OUT_OF_RANGE: return "MFX_WRN_OUT_OF_RANGE";
+ case MFX_WRN_FILTER_SKIPPED: return "MFX_WRN_FILTER_SKIPPED";
+ case MFX_WRN_INCOMPATIBLE_AUDIO_PARAM: return "MFX_WRN_INCOMPATIBLE_AUDIO_PARAM";
+ default: return "<Invalid mfxStatus>";
+ }
+}
+
+inline std::ostream & operator<<(std::ostream &out, mfxStatus s) {
+ out << mfxStatusToString(s) << " (" << (int)s << ")"; return out;
+}
+
+inline std::ostream & operator<<(std::ostream &out, const mfxInfoMFX &info) {
+ out << "InfoMFX:" << std::endl
+ << "| Codec: " << FourCC(info.CodecId) << " / " << info.CodecProfile << " / " << info.CodecLevel << std::endl
+ << "| DecodedOrder: " << info.DecodedOrder << std::endl
+ << "| TimeStampCalc: " << info.TimeStampCalc << std::endl
+ ;
+ return out;
+}
+
+inline std::ostream & operator<<(std::ostream & out, const mfxFrameInfo & info) {
+ out << "FrameInfo: " << std::endl
+ << "| FourCC: " << FourCC(info.FourCC) << std::endl
+ << "| Size: " << info.Width << "x" << info.Height << std::endl
+ << "| ROI: " << "(" << info.CropX << ";" << info.CropY << ") " << info.CropW << "x" << info.CropH << std::endl
+ << "| BitDepth(L/C): " << info.BitDepthLuma << " / " << info.BitDepthChroma << std::endl
+ << "| Shift: " << info.Shift << std::endl
+ << "| TemporalID: " << info.FrameId.TemporalId << std::endl
+ << "| FrameRate: " << info.FrameRateExtN << "/" << info.FrameRateExtD << std::endl
+ << "| AspectRatio: " << info.AspectRatioW << "x" << info.AspectRatioH << std::endl
+ << "| PicStruct: " << info.PicStruct << std::endl
+ << "| ChromaFormat: " << info.ChromaFormat << std::endl
+ ;
+ return out;
+}
+
+inline std::ostream & operator<<(std::ostream &out, const mfxFrameData &data) {
+ out << "FrameData:" << std::endl
+ << "| NumExtParam: " << data.NumExtParam << std::endl
+ << "| MemType: " << data.MemType << std::endl
+ << "| PitchHigh: " << data.PitchHigh << std::endl
+ << "| TimeStamp: " << data.TimeStamp << std::endl
+ << "| FrameOrder: " << data.FrameOrder << std::endl
+ << "| Locked: " << data.Locked << std::endl
+ << "| Pitch: " << data.PitchHigh << ", " << data.PitchLow << std::endl
+ << "| Y: " << (void*)data.Y << std::endl
+ << "| U: " << (void*)data.U << std::endl
+ << "| V: " << (void*)data.V << std::endl
+ ;
+ return out;
+}
+
+//==================================================================================================
+
+static const int CC_MPG2 = FourCC('M', 'P', 'G', '2').vali32;
+static const int CC_H264 = FourCC('H', '2', '6', '4').vali32;
+static const int CC_X264 = FourCC('X', '2', '6', '4').vali32;
+static const int CC_AVC = FourCC('A', 'V', 'C', ' ').vali32;
+static const int CC_H265 = FourCC('H', '2', '6', '5').vali32;
+static const int CC_HEVC = FourCC('H', 'E', 'V', 'C').vali32;
+static const int CC_VC1 = FourCC('V', 'C', '1', ' ').vali32;
+
+//==================================================================================================
+
+template <typename T>
+inline void cleanup(T * &ptr)
+{
+ if (ptr)
+ {
+ delete ptr;
+ ptr = 0;
+ }
+}
+
+//==================================================================================================
+
+struct Plugin
+{
+public:
+ static Plugin * loadEncoderPlugin(MFXVideoSession &session, mfxU32 codecId)
+ {
+ static const mfxPluginUID hevc_enc_uid = { 0x6f, 0xad, 0xc7, 0x91, 0xa0, 0xc2, 0xeb, 0x47, 0x9a, 0xb6, 0xdc, 0xd5, 0xea, 0x9d, 0xa3, 0x47 };
+ if (codecId == MFX_CODEC_HEVC)
+ return new Plugin(session, hevc_enc_uid);
+ return 0;
+ }
+ static Plugin * loadDecoderPlugin(MFXVideoSession &session, mfxU32 codecId)
+ {
+ static const mfxPluginUID hevc_dec_uid = { 0x33, 0xa6, 0x1c, 0x0b, 0x4c, 0x27, 0x45, 0x4c, 0xa8, 0xd8, 0x5d, 0xde, 0x75, 0x7c, 0x6f, 0x8e };
+ if (codecId == MFX_CODEC_HEVC)
+ return new Plugin(session, hevc_dec_uid);
+ return 0;
+ }
+ ~Plugin()
+ {
+ if (isGood())
+ MFXVideoUSER_UnLoad(session, &uid);
+ }
+ bool isGood() const { return res >= MFX_ERR_NONE; }
+private:
+ MFXVideoSession &session;
+ mfxPluginUID uid;
+ mfxStatus res;
+private:
+ Plugin(MFXVideoSession &_session, mfxPluginUID _uid) : session(_session), uid(_uid)
+ {
+ res = MFXVideoUSER_Load(session, &uid, 1);
+ }
+ Plugin(const Plugin &);
+ Plugin &operator=(const Plugin &);
+};
+
+//==================================================================================================
+
+struct ReadBitstream
+{
+public:
+ ReadBitstream(const char * filename, size_t maxSize = 10 * 1024 * 1024);
+ ~ReadBitstream();
+ bool isOpened() const;
+ bool isDone() const;
+ bool read();
+private:
+ ReadBitstream(const ReadBitstream &);
+ ReadBitstream &operator=(const ReadBitstream &);
+public:
+ std::fstream input;
+ mfxBitstream stream;
+ bool drain;
+};
+
+//==================================================================================================
+
+struct WriteBitstream
+{
+public:
+ WriteBitstream(const char * filename, size_t maxSize);
+ ~WriteBitstream();
+ bool write();
+ bool isOpened() const;
+private:
+ WriteBitstream(const WriteBitstream &);
+ WriteBitstream &operator=(const WriteBitstream &);
+public:
+ std::fstream output;
+ mfxBitstream stream;
+};
+
+//==================================================================================================
+
+class SurfacePool
+{
+public:
+ SurfacePool(ushort width_, ushort height_, ushort count, const mfxFrameInfo & frameInfo, uchar bpp = 12);
+ ~SurfacePool();
+ mfxFrameSurface1 *getFreeSurface();
+
+ template <typename T>
+ static SurfacePool * create(T * instance, mfxVideoParam ¶ms)
+ {
+ CV_Assert(instance);
+ mfxFrameAllocRequest request;
+ memset(&request, 0, sizeof(request));
+ mfxStatus res = instance->QueryIOSurf(¶ms, &request);
+ DBG(std::cout << "MFX QueryIOSurf: " << res << std::endl);
+ if (res < MFX_ERR_NONE)
+ return 0;
+ return new SurfacePool(request.Info.Width,
+ request.Info.Height,
+ request.NumFrameSuggested,
+ params.mfx.FrameInfo);
+ }
+private:
+ SurfacePool(const SurfacePool &);
+ SurfacePool &operator=(const SurfacePool &);
+public:
+ ushort width, height;
+ size_t oneSize;
+ cv::AutoBuffer<uchar, 0> buffers;
+ std::vector<mfxFrameSurface1> surfaces;
+};
+
+//==================================================================================================
+
+class DeviceHandler {
+public:
+ virtual ~DeviceHandler() {}
+ bool init(MFXVideoSession &session);
+protected:
+ virtual bool initDeviceSession(MFXVideoSession &session) = 0;
+};
+
+
+// Linux specific
+
+#include <va/va_drm.h>
+
+class VAHandle : public DeviceHandler {
+public:
+ VAHandle();
+ ~VAHandle();
+private:
+ VAHandle(const VAHandle &);
+ VAHandle &operator=(const VAHandle &);
+ virtual bool initDeviceSession(MFXVideoSession &session);
+private:
+ VADisplay display;
+ int file;
+};
+
+// TODO: Windows specific
+
+
+#endif // MFXHELPER_H
diff --git a/modules/videoio/src/cap_mfx_reader.cpp b/modules/videoio/src/cap_mfx_reader.cpp
new file mode 100644
index 0000000..b5c39ca
--- /dev/null
+++ b/modules/videoio/src/cap_mfx_reader.cpp
@@ -0,0 +1,273 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#include "cap_mfx_reader.hpp"
+#include "opencv2/core/base.hpp"
+#include "cap_mfx_common.hpp"
+
+using namespace cv;
+using namespace std;
+
+inline bool hasExtension(const String &filename, const String &ext)
+{
+ if (filename.size() <= ext.size())
+ return false;
+ const size_t diff = filename.size() - ext.size();
+ const size_t found_at = filename.rfind(ext);
+ return found_at == diff;
+}
+
+inline mfxU32 determineCodecId(const String &filename)
+{
+ if (hasExtension(filename, ".h264") || hasExtension(filename, ".264"))
+ return MFX_CODEC_AVC;
+ else if (hasExtension(filename, ".mp2") || hasExtension(filename, ".mpeg2"))
+ return MFX_CODEC_MPEG2;
+ else if (hasExtension(filename, ".265") || hasExtension(filename, ".hevc"))
+ return MFX_CODEC_HEVC;
+ else
+ return (mfxU32)-1;
+}
+
+//==========================================================================
+
+VideoCapture_IntelMFX::VideoCapture_IntelMFX(const cv::String &filename)
+ : session(0), plugin(0), deviceHandler(0), bs(0), decoder(0), pool(0), outSurface(0), good(false)
+{
+ mfxStatus res = MFX_ERR_NONE;
+
+ // Init device and session
+
+ deviceHandler = new VAHandle();
+ session = new MFXVideoSession();
+ if (!deviceHandler->init(*session))
+ {
+ MSG(cerr << "MFX: Can't initialize session" << endl);
+ return;
+ }
+
+ // Load appropriate plugin
+
+ mfxU32 codecId = determineCodecId(filename);
+ if (codecId == (mfxU32)-1)
+ {
+ MSG(cerr << "MFX: Unsupported extension: " << filename << endl);
+ return;
+ }
+ plugin = Plugin::loadDecoderPlugin(*session, codecId);
+ if (plugin && !plugin->isGood())
+ {
+ MSG(cerr << "MFX: LoadPlugin failed for codec: " << codecId << " (" << filename << ")" << endl);
+ return;
+ }
+
+ // Read some content from file
+
+ bs = new ReadBitstream(filename.c_str());
+ if (!bs->read())
+ {
+ MSG(cerr << "MFX: Failed to read bitstream" << endl);
+ return;
+ }
+
+ // Create decoder and decode stream header
+
+ decoder = new MFXVideoDECODE(*session);
+ mfxVideoParam params;
+ memset(¶ms, 0, sizeof(params));
+ params.mfx.CodecId = codecId;
+ params.IOPattern = MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
+ res = decoder->DecodeHeader(&bs->stream, ¶ms);
+ DBG(cout << "DecodeHeader: " << res << endl << params.mfx << params.mfx.FrameInfo << endl);
+ if (res < MFX_ERR_NONE)
+ {
+ MSG(cerr << "MFX: Failed to decode stream header: " << res << endl);
+ return;
+ }
+
+ // Adjust parameters
+
+ res = decoder->Query(¶ms, ¶ms);
+ DBG(cout << "MFX Query: " << res << endl << params.mfx << params.mfx.FrameInfo);
+ CV_Assert(res >= MFX_ERR_NONE);
+
+ // Init surface pool
+
+ pool = SurfacePool::create(decoder, params);
+ if (!pool)
+ {
+ MSG(cerr << "MFX: Failed to create surface pool" << endl);
+ return;
+ }
+
+ // Init decoder
+
+ res = decoder->Init(¶ms);
+ DBG(cout << "MFX Init: " << res << endl << params.mfx.FrameInfo);
+ if (res < MFX_ERR_NONE)
+ {
+ MSG(cerr << "MFX: Failed to init decoder: " << res << endl);
+ return;
+ }
+
+ good = true;
+}
+
+
+VideoCapture_IntelMFX::~VideoCapture_IntelMFX()
+{
+ cleanup(plugin);
+ cleanup(bs);
+ cleanup(decoder);
+ cleanup(pool);
+ session->Close();
+ cleanup(session);
+ cleanup(deviceHandler);
+}
+
+double VideoCapture_IntelMFX::getProperty(int) const
+{
+ MSG(cerr << "MFX: getProperty() is not implemented" << endl);
+ return 0;
+}
+
+bool VideoCapture_IntelMFX::setProperty(int, double)
+{
+ MSG(cerr << "MFX: setProperty() is not implemented" << endl);
+ return false;
+}
+
+bool VideoCapture_IntelMFX::grabFrame()
+{
+ mfxStatus res;
+ mfxFrameSurface1 *workSurface = 0;
+ mfxSyncPoint sync;
+
+ workSurface = pool->getFreeSurface();
+
+ while (true)
+ {
+ if (!workSurface)
+ {
+ // not enough surfaces
+ MSG(cerr << "MFX: Failed to get free surface" << endl);
+ return false;
+ }
+
+ outSurface = 0;
+ res = decoder->DecodeFrameAsync(bs->drain ? 0 : &bs->stream, workSurface, (mfxFrameSurface1**)&outSurface, &sync);
+ if (res == MFX_ERR_NONE)
+ {
+ res = session->SyncOperation(sync, 1000); // 1 sec, TODO: provide interface to modify timeout
+ if (res == MFX_ERR_NONE)
+ {
+ // ready to retrieve
+ DBG(cout << "Frame ready to retrieve" << endl);
+ return true;
+ }
+ else
+ {
+ MSG(cerr << "MFX: Sync error: " << res << endl);
+ return false;
+ }
+ }
+ else if (res == MFX_ERR_MORE_DATA)
+ {
+ if (bs->isDone())
+ {
+ if (bs->drain)
+ {
+ // finish
+ DBG(cout << "Drain finished" << endl);
+ return false;
+ }
+ else
+ {
+ DBG(cout << "Bitstream finished - Drain started" << endl);
+ bs->drain = true;
+ continue;
+ }
+ }
+ else
+ {
+ bool read_res = bs->read();
+ if (!read_res)
+ {
+ // failed to read
+ MSG(cerr << "MFX: Bitstream read failure" << endl);
+ return false;
+ }
+ else
+ {
+ DBG(cout << "Bitstream read success" << endl);
+ continue;
+ }
+ }
+ }
+ else if (res == MFX_ERR_MORE_SURFACE)
+ {
+ DBG(cout << "Getting another surface" << endl);
+ workSurface = pool->getFreeSurface();
+ continue;
+ }
+ else if (res == MFX_WRN_DEVICE_BUSY)
+ {
+ DBG(cout << "Waiting for device" << endl);
+ sleep(1);
+ continue;
+ }
+ else if (res == MFX_WRN_VIDEO_PARAM_CHANGED)
+ {
+ DBG(cout << "Video param changed" << endl);
+ continue;
+ }
+ else
+ {
+ MSG(cerr << "MFX: Bad status: " << res << endl);
+ return false;
+ }
+ return false;
+ }
+}
+
+
+bool VideoCapture_IntelMFX::retrieveFrame(int, OutputArray out)
+{
+ if (!outSurface)
+ {
+ MSG(cerr << "MFX: No frame ready to retrieve" << endl);
+ return false;
+ }
+ mfxFrameSurface1 * s = (mfxFrameSurface1*)outSurface;
+ mfxFrameInfo &info = s->Info;
+ mfxFrameData &data = s->Data;
+
+ const int cols = info.CropW;
+ const int rows = info.CropH;
+ Mat nv12(rows * 3 / 2, cols, CV_8UC1);
+
+ Mat Y(rows, cols, CV_8UC1, data.Y, data.Pitch);
+ Mat UV(rows / 2, cols, CV_8UC1, data.UV, data.Pitch);
+
+ Y.copyTo(Mat(nv12, Rect(0, 0, cols, rows)));
+ UV.copyTo(Mat(nv12, Rect(0, rows, cols, rows / 2)));
+
+ Mat u_and_v[2];
+ split(UV.reshape(2), u_and_v);
+ cvtColor(nv12, out, COLOR_YUV2BGR_NV12);
+
+ return true;
+}
+
+bool VideoCapture_IntelMFX::isOpened() const
+{
+ return good;
+}
+
+int VideoCapture_IntelMFX::getCaptureDomain()
+{
+ return CAP_INTEL_MFX;
+}
+
+//==================================================================================================
diff --git a/modules/videoio/src/cap_mfx_reader.hpp b/modules/videoio/src/cap_mfx_reader.hpp
new file mode 100644
index 0000000..1d2fa8b
--- /dev/null
+++ b/modules/videoio/src/cap_mfx_reader.hpp
@@ -0,0 +1,41 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#ifndef CAP_MFX_HPP
+#define CAP_MFX_HPP
+
+#include "precomp.hpp"
+
+
+class MFXVideoSession;
+class Plugin;
+class DeviceHandler;
+class ReadBitstream;
+class SurfacePool;
+class MFXVideoDECODE;
+
+class VideoCapture_IntelMFX : public cv::IVideoCapture
+{
+public:
+ VideoCapture_IntelMFX(const cv::String &filename);
+ virtual ~VideoCapture_IntelMFX();
+ virtual double getProperty(int) const;
+ virtual bool setProperty(int, double);
+ virtual bool grabFrame();
+ virtual bool retrieveFrame(int, cv::OutputArray out);
+ virtual bool isOpened() const;
+ virtual int getCaptureDomain();
+private:
+ MFXVideoSession *session;
+ Plugin *plugin;
+ DeviceHandler *deviceHandler;
+ ReadBitstream *bs;
+ MFXVideoDECODE *decoder;
+ SurfacePool *pool;
+ void *outSurface;
+ bool good;
+};
+
+
+#endif
diff --git a/modules/videoio/src/cap_mfx_writer.cpp b/modules/videoio/src/cap_mfx_writer.cpp
new file mode 100644
index 0000000..9fc0063
--- /dev/null
+++ b/modules/videoio/src/cap_mfx_writer.cpp
@@ -0,0 +1,272 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#include "cap_mfx_writer.hpp"
+#include "opencv2/core/base.hpp"
+#include "cap_mfx_common.hpp"
+
+using namespace std;
+using namespace cv;
+
+inline mfxU32 codecIdByFourCC(int fourcc)
+{
+ if (fourcc == CC_X264 || fourcc == CC_H264 || fourcc == CC_AVC)
+ return MFX_CODEC_AVC;
+ else if (fourcc == CC_H265 || fourcc == CC_HEVC)
+ return MFX_CODEC_HEVC;
+ else if (fourcc == CC_MPG2)
+ return MFX_CODEC_MPEG2;
+ else
+ return (mfxU32)-1;
+}
+
+VideoWriter_IntelMFX::VideoWriter_IntelMFX(const String &filename, int _fourcc, double fps, Size frameSize_, bool)
+ : session(0), plugin(0), deviceHandler(0), bs(0), encoder(0), pool(0), frameSize(frameSize_), good(false)
+{
+ mfxStatus res = MFX_ERR_NONE;
+
+ if (frameSize.width % 2 || frameSize.height % 2)
+ {
+ MSG(cerr << "MFX: Invalid frame size passed to encoder" << endl);
+ return;
+ }
+
+ // Init device and session
+
+ deviceHandler = new VAHandle();
+ session = new MFXVideoSession();
+ if (!deviceHandler->init(*session))
+ {
+ MSG(cerr << "MFX: Can't initialize session" << endl);
+ return;
+ }
+
+ // Load appropriate plugin
+
+ mfxU32 codecId = codecIdByFourCC(_fourcc);
+ if (codecId == (mfxU32)-1)
+ {
+ MSG(cerr << "MFX: Unsupported FourCC: " << FourCC(_fourcc) << endl);
+ return;
+ }
+ plugin = Plugin::loadEncoderPlugin(*session, codecId);
+ if (plugin && !plugin->isGood())
+ {
+ MSG(cerr << "MFX: LoadPlugin failed for codec: " << codecId << " (" << FourCC(_fourcc) << ")" << endl);
+ return;
+ }
+
+ // Init encoder
+
+ encoder = new MFXVideoENCODE(*session);
+ mfxVideoParam params;
+ memset(¶ms, 0, sizeof(params));
+ params.mfx.CodecId = codecId;
+ params.mfx.TargetUsage = MFX_TARGETUSAGE_BALANCED;
+ params.mfx.TargetKbps = frameSize.area() * fps / 500; // TODO: set in options
+ params.mfx.RateControlMethod = MFX_RATECONTROL_VBR;
+ params.mfx.FrameInfo.FrameRateExtN = cvRound(fps * 1000);
+ params.mfx.FrameInfo.FrameRateExtD = 1000;
+ params.mfx.FrameInfo.FourCC = MFX_FOURCC_NV12;
+ params.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420;
+ params.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
+ params.mfx.FrameInfo.CropX = 0;
+ params.mfx.FrameInfo.CropY = 0;
+ params.mfx.FrameInfo.CropW = frameSize.width;
+ params.mfx.FrameInfo.CropH = frameSize.height;
+ params.mfx.FrameInfo.Width = alignSize(frameSize.width, 32);
+ params.mfx.FrameInfo.Height = alignSize(frameSize.height, 32);
+ params.IOPattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY;
+ res = encoder->Query(¶ms, ¶ms);
+ DBG(cout << "MFX Query: " << res << endl << params.mfx << params.mfx.FrameInfo);
+ if (res < MFX_ERR_NONE)
+ {
+ MSG(cerr << "MFX: Query failed: " << res << endl);
+ return;
+ }
+
+ // Init surface pool
+ pool = SurfacePool::create(encoder, params);
+ if (!pool)
+ {
+ MSG(cerr << "MFX: Failed to create surface pool" << endl);
+ return;
+ }
+
+ // Init encoder
+ res = encoder->Init(¶ms);
+ DBG(cout << "MFX Init: " << res << endl << params.mfx.FrameInfo);
+ if (res < MFX_ERR_NONE)
+ {
+ MSG(cerr << "MFX: Failed to init encoder: " << res << endl);
+ return;
+ }
+
+ // Open output bitstream
+ {
+ mfxVideoParam par;
+ memset(&par, 0, sizeof(par));
+ res = encoder->GetVideoParam(&par);
+ DBG(cout << "MFX GetVideoParam: " << res << endl << "requested " << par.mfx.BufferSizeInKB << " kB" << endl);
+ CV_Assert(res >= MFX_ERR_NONE);
+ bs = new WriteBitstream(filename.c_str(), par.mfx.BufferSizeInKB * 1024 * 2);
+ if (!bs->isOpened())
+ {
+ MSG(cerr << "MFX: Failed to open output file: " << filename << endl);
+ return;
+ }
+ }
+
+ good = true;
+}
+
+VideoWriter_IntelMFX::~VideoWriter_IntelMFX()
+{
+ if (isOpened())
+ {
+ DBG(cout << "====== Drain bitstream..." << endl);
+ Mat dummy;
+ while (write_one(dummy)) {}
+ DBG(cout << "====== Drain Finished" << endl);
+ }
+ cleanup(bs);
+ cleanup(pool);
+ cleanup(encoder);
+ cleanup(plugin);
+ cleanup(session);
+ cleanup(deviceHandler);
+}
+
+double VideoWriter_IntelMFX::getProperty(int) const
+{
+ MSG(cerr << "MFX: getProperty() is not implemented" << endl);
+ return 0;
+}
+
+bool VideoWriter_IntelMFX::setProperty(int, double)
+{
+ MSG(cerr << "MFX: setProperty() is not implemented" << endl);
+ return false;
+}
+
+bool VideoWriter_IntelMFX::isOpened() const
+{
+ return good;
+}
+
+void VideoWriter_IntelMFX::write(cv::InputArray input)
+{
+ write_one(input);
+}
+
+inline static void to_nv12(cv::InputArray bgr, cv::Mat & Y, cv::Mat & UV)
+{
+ const int height = bgr.rows();
+ const int width = bgr.cols();
+ Mat yuv;
+ cvtColor(bgr, yuv, CV_BGR2YUV_I420);
+ CV_Assert(yuv.isContinuous());
+ Mat Y_(Y, Rect(0, 0, width, height));
+ yuv.rowRange(0, height).copyTo(Y_);
+ Mat UV_planar(height, width / 2, CV_8UC1, yuv.ptr(height));
+ Mat u_and_v[2] = {
+ UV_planar.rowRange(0, height / 2),
+ UV_planar.rowRange(height / 2, height),
+ };
+ Mat uv;
+ cv::merge(u_and_v, 2, uv);
+ Mat UV_(UV, Rect(0, 0, width, height / 2));
+ uv.reshape(1).copyTo(UV_);
+}
+
+bool VideoWriter_IntelMFX::write_one(cv::InputArray bgr)
+{
+ mfxStatus res;
+ mfxFrameSurface1 *workSurface = 0;
+ mfxSyncPoint sync;
+
+ if (!bgr.empty() && (bgr.dims() != 2 || bgr.type() != CV_8UC3 || bgr.size() != frameSize))
+ {
+ MSG(cerr << "MFX: invalid frame passed to encoder: "
+ << "dims/depth/cn=" << bgr.dims() << "/" << bgr.depth() << "/" << bgr.channels()
+ << ", size=" << bgr.size() << endl);
+ return false;
+
+ }
+ if (!bgr.empty())
+ {
+ workSurface = pool->getFreeSurface();
+ if (!workSurface)
+ {
+ // not enough surfaces
+ MSG(cerr << "MFX: Failed to get free surface" << endl);
+ return false;
+ }
+ const int rows = workSurface->Info.Height;
+ const int cols = workSurface->Info.Width;
+ Mat Y(rows, cols, CV_8UC1, workSurface->Data.Y, workSurface->Data.Pitch);
+ Mat UV(rows / 2, cols, CV_8UC1, workSurface->Data.UV, workSurface->Data.Pitch);
+ to_nv12(bgr, Y, UV);
+ CV_Assert(Y.ptr() == workSurface->Data.Y);
+ CV_Assert(UV.ptr() == workSurface->Data.UV);
+ }
+
+ while (true)
+ {
+ outSurface = 0;
+ DBG(cout << "Calling with surface: " << workSurface << endl);
+ res = encoder->EncodeFrameAsync(NULL, workSurface, &bs->stream, &sync);
+ if (res == MFX_ERR_NONE)
+ {
+ res = session->SyncOperation(sync, 1000); // 1 sec, TODO: provide interface to modify timeout
+ if (res == MFX_ERR_NONE)
+ {
+ // ready to write
+ if (!bs->write())
+ {
+ MSG(cerr << "MFX: Failed to write bitstream" << endl);
+ return false;
+ }
+ else
+ {
+ DBG(cout << "Write bitstream" << endl);
+ return true;
+ }
+ }
+ else
+ {
+ MSG(cerr << "MFX: Sync error: " << res << endl);
+ return false;
+ }
+ }
+ else if (res == MFX_ERR_MORE_DATA)
+ {
+ DBG(cout << "ERR_MORE_DATA" << endl);
+ return false;
+ }
+ else if (res == MFX_WRN_DEVICE_BUSY)
+ {
+ DBG(cout << "Waiting for device" << endl);
+ sleep(1);
+ continue;
+ }
+ else
+ {
+ MSG(cerr << "MFX: Bad status: " << res << endl);
+ return false;
+ }
+ return true;
+ }
+}
+
+Ptr<VideoWriter_IntelMFX> VideoWriter_IntelMFX::create(const String &filename, int _fourcc, double fps, Size frameSize, bool isColor)
+{
+ if (codecIdByFourCC(_fourcc) > 0)
+ {
+ Ptr<VideoWriter_IntelMFX> a = makePtr<VideoWriter_IntelMFX>(filename, _fourcc, fps, frameSize, isColor);
+ if (a->isOpened())
+ return a;
+ }
+ return Ptr<VideoWriter_IntelMFX>();
+}
diff --git a/modules/videoio/src/cap_mfx_writer.hpp b/modules/videoio/src/cap_mfx_writer.hpp
new file mode 100644
index 0000000..6a60960
--- /dev/null
+++ b/modules/videoio/src/cap_mfx_writer.hpp
@@ -0,0 +1,48 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#ifndef CAP_MFX_WRITER_HPP
+#define CAP_MFX_WRITER_HPP
+
+#include "precomp.hpp"
+
+class MFXVideoSession;
+class Plugin;
+class DeviceHandler;
+class WriteBitstream;
+class SurfacePool;
+class MFXVideoDECODE;
+class MFXVideoENCODE;
+
+class VideoWriter_IntelMFX : public cv::IVideoWriter
+{
+public:
+ VideoWriter_IntelMFX(const cv::String &filename, int _fourcc, double fps, cv::Size frameSize, bool isColor);
+ virtual ~VideoWriter_IntelMFX();
+ virtual double getProperty(int) const;
+ virtual bool setProperty(int, double);
+ virtual bool isOpened() const;
+ virtual void write(cv::InputArray input);
+ static cv::Ptr<VideoWriter_IntelMFX> create(const cv::String& filename, int _fourcc, double fps, cv::Size frameSize, bool isColor);
+
+protected:
+ bool write_one(cv::InputArray bgr);
+
+private:
+ VideoWriter_IntelMFX(const VideoWriter_IntelMFX &);
+ VideoWriter_IntelMFX & operator=(const VideoWriter_IntelMFX &);
+
+private:
+ MFXVideoSession *session;
+ Plugin *plugin;
+ DeviceHandler *deviceHandler;
+ WriteBitstream *bs;
+ MFXVideoENCODE *encoder;
+ SurfacePool *pool;
+ void *outSurface;
+ cv::Size frameSize;
+ bool good;
+};
+
+#endif // CAP_MFX_WRITER_HPP
diff --git a/modules/videoio/src/cap_mjpeg_decoder.cpp b/modules/videoio/src/cap_mjpeg_decoder.cpp
index 7abce20..b5c5ff9 100644
--- a/modules/videoio/src/cap_mjpeg_decoder.cpp
+++ b/modules/videoio/src/cap_mjpeg_decoder.cpp
@@ -553,6 +553,7 @@ bool AviMjpegStream::parseHdrlList(MjpegInputStream& in_str)
{
m_is_indx_present = ((avi_hdr.dwFlags & 0x10) != 0);
DWORD number_of_streams = avi_hdr.dwStreams;
+ CV_Assert(number_of_streams < 0xFF);
m_width = avi_hdr.dwWidth;
m_height = avi_hdr.dwHeight;
@@ -821,7 +822,7 @@ bool MotionJpegCapture::retrieveFrame(int, OutputArray output_frame)
if(data.size())
{
- m_current_frame = imdecode(data, CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_COLOR);
+ m_current_frame = imdecode(data, CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_COLOR | IMREAD_IGNORE_ORIENTATION);
}
m_current_frame.copyTo(output_frame);
diff --git a/modules/videoio/src/cap_mjpeg_encoder.cpp b/modules/videoio/src/cap_mjpeg_encoder.cpp
index 201b284..8899092 100644
--- a/modules/videoio/src/cap_mjpeg_encoder.cpp
+++ b/modules/videoio/src/cap_mjpeg_encoder.cpp
@@ -96,6 +96,8 @@ public:
m_end = m_start + DEFAULT_BLOCK_SIZE;
m_is_opened = false;
m_f = 0;
+ m_current = 0;
+ m_pos = 0;
}
~BitStream()
@@ -384,7 +386,7 @@ public:
}
else
{
- data[m_pos] |= (tempval << bits_free);
+ data[m_pos] |= (bits_free == 32) ? tempval : (tempval << bits_free);
}
}
@@ -591,6 +593,12 @@ public:
{
rawstream = false;
nstripes = -1;
+ height = 0;
+ width = 0;
+ moviPointer = 0;
+ channels = 0;
+ outfps = 0;
+ quality = 0;
}
MotionJpegWriter(const String& filename, double fps, Size size, bool iscolor)
@@ -720,7 +728,7 @@ public:
strm.putInt(height);
strm.putShort(1); // planes (1 means interleaved data (after decompression))
- strm.putShort(channels); // bits per pixel
+ strm.putShort(8 * channels); // bits per pixel
strm.putInt(fourCC('M', 'J', 'P', 'G'));
strm.putInt(width * height * channels);
strm.putInt(0);
diff --git a/modules/videoio/src/cap_msmf.cpp b/modules/videoio/src/cap_msmf.cpp
index a63e4fa..701c159 100644
--- a/modules/videoio/src/cap_msmf.cpp
+++ b/modules/videoio/src/cap_msmf.cpp
@@ -39,7 +39,7 @@
//
//M*/
#include "precomp.hpp"
-#if (defined WIN32 || defined _WIN32) && defined HAVE_MSMF
+#if defined _WIN32 && defined HAVE_MSMF
/*
Media Foundation-based Video Capturing module is based on
videoInput library by Evgeny Pereguda:
diff --git a/modules/videoio/src/cap_pvapi.cpp b/modules/videoio/src/cap_pvapi.cpp
index a6577fc..d64842f 100644
--- a/modules/videoio/src/cap_pvapi.cpp
+++ b/modules/videoio/src/cap_pvapi.cpp
@@ -46,7 +46,7 @@
#include "precomp.hpp"
#ifdef HAVE_PVAPI
-#if !defined WIN32 && !defined _WIN32 && !defined _LINUX
+#if !defined _WIN32 && !defined _LINUX
#define _LINUX
#endif
@@ -57,7 +57,7 @@
#endif
#include <PvApi.h>
-#ifdef WIN32
+#ifdef _WIN32
# include <io.h>
#else
# include <time.h>
@@ -91,7 +91,7 @@ public:
}
protected:
-#ifndef WIN32
+#ifndef _WIN32
virtual void Sleep(unsigned int time);
#endif
@@ -118,7 +118,7 @@ CvCaptureCAM_PvAPI::CvCaptureCAM_PvAPI()
memset(&this->Camera, 0, sizeof(this->Camera));
}
-#ifndef WIN32
+#ifndef _WIN32
void CvCaptureCAM_PvAPI::Sleep(unsigned int time)
{
struct timespec t,r;
diff --git a/modules/videoio/src/cap_qtkit.mm b/modules/videoio/src/cap_qtkit.mm
index ad6037b..d998b4c 100644
--- a/modules/videoio/src/cap_qtkit.mm
+++ b/modules/videoio/src/cap_qtkit.mm
@@ -270,8 +270,6 @@ CvCaptureCAM::CvCaptureCAM(int cameraNum) {
CvCaptureCAM::~CvCaptureCAM() {
stopCaptureDevice();
-
- std::cout << "Cleaned up camera." << std::endl;
}
int CvCaptureCAM::didStart() {
diff --git a/modules/videoio/src/cap_v4l.cpp b/modules/videoio/src/cap_v4l.cpp
index 59202e2..37d93cd 100644
--- a/modules/videoio/src/cap_v4l.cpp
+++ b/modules/videoio/src/cap_v4l.cpp
@@ -209,7 +209,7 @@ make & enjoy!
#include "precomp.hpp"
-#if !defined WIN32 && (defined HAVE_CAMV4L2 || defined HAVE_VIDEOIO)
+#if !defined _WIN32 && (defined HAVE_CAMV4L2 || defined HAVE_VIDEOIO)
#include <stdio.h>
#include <unistd.h>
@@ -280,6 +280,7 @@ struct CvCaptureCAM_V4L : public CvCapture
__u32 fps;
bool convert_rgb;
bool frame_allocated;
+ bool returnFrame;
/* V4L2 variables */
buffer buffers[MAX_V4L_BUFFERS + 1];
@@ -820,6 +821,7 @@ bool CvCaptureCAM_V4L::open(const char* _deviceName)
fps = DEFAULT_V4L_FPS;
convert_rgb = true;
deviceName = _deviceName;
+ returnFrame = true;
return _capture_V4L2(this) == 1;
}
@@ -847,6 +849,7 @@ static int read_frame_v4l2(CvCaptureCAM_V4L* capture) {
default:
/* display the error and stop processing */
+ capture->returnFrame = false;
perror ("VIDIOC_DQBUF");
return -1;
}
@@ -861,12 +864,12 @@ static int read_frame_v4l2(CvCaptureCAM_V4L* capture) {
//printf("got data in buff %d, len=%d, flags=0x%X, seq=%d, used=%d)\n",
// buf.index, buf.length, buf.flags, buf.sequence, buf.bytesused);
- if (-1 == ioctl (capture->deviceHandle, VIDIOC_QBUF, &buf))
- perror ("VIDIOC_QBUF");
-
//set timestamp in capture struct to be timestamp of most recent frame
capture->timestamp = buf.timestamp;
+ if (-1 == ioctl (capture->deviceHandle, VIDIOC_QBUF, &buf))
+ perror ("VIDIOC_QBUF");
+
return 1;
}
@@ -1581,7 +1584,10 @@ static IplImage* icvRetrieveFrameCAM_V4L( CvCaptureCAM_V4L* capture, int) {
break;
}
- return(&capture->frame);
+ if (capture->returnFrame)
+ return(&capture->frame);
+ else
+ return 0;
}
static inline __u32 capPropertyToV4L2(int prop) {
@@ -1772,6 +1778,7 @@ static int icvSetPropertyCAM_V4L( CvCaptureCAM_V4L* capture,
switch (property_id) {
case CV_CAP_PROP_FRAME_WIDTH:
width = cvRound(value);
+ retval = width != 0;
if(width !=0 && height != 0) {
capture->width = width;
capture->height = height;
@@ -1781,6 +1788,7 @@ static int icvSetPropertyCAM_V4L( CvCaptureCAM_V4L* capture,
break;
case CV_CAP_PROP_FRAME_HEIGHT:
height = cvRound(value);
+ retval = height != 0;
if(width !=0 && height != 0) {
capture->width = width;
capture->height = height;
diff --git a/modules/videoio/src/cap_vfw.cpp b/modules/videoio/src/cap_vfw.cpp
index 555e848..43a9772 100644
--- a/modules/videoio/src/cap_vfw.cpp
+++ b/modules/videoio/src/cap_vfw.cpp
@@ -312,8 +312,16 @@ CvCapture* cvCreateFileCapture_VFW (const char* filename)
class CvCaptureCAM_VFW : public CvCapture
{
public:
- CvCaptureCAM_VFW() { init(); }
- virtual ~CvCaptureCAM_VFW() { close(); }
+ CvCaptureCAM_VFW()
+ {
+ CoInitialize(NULL);
+ init();
+ }
+ virtual ~CvCaptureCAM_VFW()
+ {
+ close();
+ CoUninitialize();
+ }
virtual bool open( int index );
virtual void close();
@@ -673,8 +681,16 @@ CvCapture* cvCreateCameraCapture_VFW( int index )
class CvVideoWriter_VFW : public CvVideoWriter
{
public:
- CvVideoWriter_VFW() { init(); }
- virtual ~CvVideoWriter_VFW() { close(); }
+ CvVideoWriter_VFW()
+ {
+ CoInitialize(NULL);
+ init();
+ }
+ virtual ~CvVideoWriter_VFW()
+ {
+ close();
+ CoUninitialize();
+ }
virtual bool open( const char* filename, int fourcc,
double fps, CvSize frameSize, bool isColor );
diff --git a/modules/videoio/src/cap_ximea.cpp b/modules/videoio/src/cap_ximea.cpp
index e31c01a..1d1aeea 100644
--- a/modules/videoio/src/cap_ximea.cpp
+++ b/modules/videoio/src/cap_ximea.cpp
@@ -1,7 +1,7 @@
#include "precomp.hpp"
-#ifdef WIN32
+#ifdef _WIN32
#include <xiApi.h>
#else
#include <m3api/xiApi.h>
@@ -55,7 +55,7 @@ CvCapture* cvCreateCameraCapture_XIMEA( int index )
// Enumerate connected devices
void CvCaptureCAM_XIMEA::init()
{
-#if defined WIN32 || defined _WIN32
+#if defined _WIN32
xiGetNumberDevices( &numDevices);
#else
// try second re-enumeration if first one fails
@@ -84,7 +84,7 @@ bool CvCaptureCAM_XIMEA::open( int wIndex )
if((mvret = xiOpenDevice( wIndex, &hmv)) != XI_OK)
{
-#if defined WIN32 || defined _WIN32
+#if defined _WIN32
errMsg("Open XI_DEVICE failed", mvret);
return false;
#else
@@ -1751,7 +1751,7 @@ void CvCaptureCAM_XIMEA::errMsg(const char* msg, int errNum) const
error_message = "Unknown error value";
}
- #if defined WIN32 || defined _WIN32
+ #if defined _WIN32
char buf[512]="";
sprintf( buf, "%s : %d, %s\n", msg, errNum, error_message.c_str());
OutputDebugString(buf);
diff --git a/modules/videoio/src/ffmpeg_codecs.hpp b/modules/videoio/src/ffmpeg_codecs.hpp
index a2a7a3b..61788e0 100644
--- a/modules/videoio/src/ffmpeg_codecs.hpp
+++ b/modules/videoio/src/ffmpeg_codecs.hpp
@@ -44,7 +44,7 @@
extern "C" {
#endif
-#if !defined(WIN32) || defined(__MINGW32__)
+#if !defined(_WIN32) || defined(__MINGW32__)
// some versions of FFMPEG assume a C99 compiler, and don't define INT64_C
#include <stdint.h>
diff --git a/modules/videoio/src/precomp.hpp b/modules/videoio/src/precomp.hpp
index 8a10d20..10babee 100644
--- a/modules/videoio/src/precomp.hpp
+++ b/modules/videoio/src/precomp.hpp
@@ -61,7 +61,7 @@
#include <ctype.h>
#include <assert.h>
-#if defined WIN32 || defined WINCE
+#if defined _WIN32 || defined WINCE
#if !defined _WIN32_WINNT
#ifdef HAVE_MSMF
#define _WIN32_WINNT 0x0600 // Windows Vista
@@ -90,7 +90,7 @@ struct CvCapture
virtual bool setProperty(int, double) { return 0; }
virtual bool grabFrame() { return true; }
virtual IplImage* retrieveFrame(int) { return 0; }
- virtual int getCaptureDomain() { return CV_CAP_ANY; } // Return the type of the capture object: CV_CAP_VFW, etc...
+ virtual int getCaptureDomain() { return cv::CAP_ANY; } // Return the type of the capture object: CAP_VFW, etc...
};
/*************************** CvVideoWriter structure ****************************/
@@ -108,7 +108,6 @@ CvCapture * cvCreateCameraCapture_DC1394_2( int index );
CvCapture* cvCreateCameraCapture_MIL( int index );
CvCapture* cvCreateCameraCapture_Giganetix( int index );
CvCapture * cvCreateCameraCapture_CMU( int index );
-CV_IMPL CvCapture * cvCreateCameraCapture_TYZX( int index );
CvCapture* cvCreateFileCapture_Win32( const char* filename );
CvCapture* cvCreateCameraCapture_VFW( int index );
CvCapture* cvCreateFileCapture_VFW( const char* filename );
@@ -164,6 +163,7 @@ CvCapture * cvCreateCameraCapture_PvAPI (const int index);
CvVideoWriter* cvCreateVideoWriter_GStreamer( const char* filename, int fourcc,
double fps, CvSize frameSize, int is_color );
+
namespace cv
{
class IVideoCapture
diff --git a/modules/videoio/test/test_basic_props.cpp b/modules/videoio/test/test_basic_props.cpp
deleted file mode 100644
index ef2fabe..0000000
--- a/modules/videoio/test/test_basic_props.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-#include "opencv2/videoio.hpp"
-#include "opencv2/ts.hpp"
-#include <stdio.h>
-
-#if BUILD_WITH_VIDEO_INPUT_SUPPORT
-
-using namespace cv;
-using namespace std;
-using namespace cvtest;
-
-#ifdef HAVE_GSTREAMER
-const string ext[] = {"avi"};
-#else
-const string ext[] = {"avi", "mov", "mp4"};
-#endif
-
-TEST(Videoio_Video, prop_resolution)
-{
- const size_t n = sizeof(ext)/sizeof(ext[0]);
- const string src_dir = TS::ptr()->get_data_path();
-
- TS::ptr()->printf(cvtest::TS::LOG, "\n\nSource files directory: %s\n", (src_dir+"video/").c_str());
-
- for (size_t i = 0; i < n; ++i)
- {
- string file_path = src_dir+"video/big_buck_bunny."+ext[i];
- VideoCapture cap(file_path);
- if (!cap.isOpened())
- {
- TS::ptr()->printf(cvtest::TS::LOG, "\nFile information (video %d): \n\nName: big_buck_bunny.%s\nFAILED\n\n", i+1, ext[i].c_str());
- TS::ptr()->printf(cvtest::TS::LOG, "Error: cannot read source video file.\n");
- TS::ptr()->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
- return;
- }
-
- ASSERT_EQ(672, cap.get(CAP_PROP_FRAME_WIDTH));
- ASSERT_EQ(384, cap.get(CAP_PROP_FRAME_HEIGHT));
- }
-}
-
-TEST(Videoio_Video, actual_resolution)
-{
- const size_t n = sizeof(ext)/sizeof(ext[0]);
- const string src_dir = TS::ptr()->get_data_path();
-
- TS::ptr()->printf(cvtest::TS::LOG, "\n\nSource files directory: %s\n", (src_dir+"video/").c_str());
-
- for (size_t i = 0; i < n; ++i)
- {
- string file_path = src_dir+"video/big_buck_bunny."+ext[i];
- VideoCapture cap(file_path);
- if (!cap.isOpened())
- {
- TS::ptr()->printf(cvtest::TS::LOG, "\nFile information (video %d): \n\nName: big_buck_bunny.%s\nFAILED\n\n", i+1, ext[i].c_str());
- TS::ptr()->printf(cvtest::TS::LOG, "Error: cannot read source video file.\n");
- TS::ptr()->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
- return;
- }
-
- Mat frame;
- cap >> frame;
-
- ASSERT_EQ(672, frame.cols);
- ASSERT_EQ(384, frame.rows);
- }
-}
-
-TEST(Videoio_Video, DISABLED_prop_fps)
-{
- const size_t n = sizeof(ext)/sizeof(ext[0]);
- const string src_dir = TS::ptr()->get_data_path();
-
- TS::ptr()->printf(cvtest::TS::LOG, "\n\nSource files directory: %s\n", (src_dir+"video/").c_str());
-
- for (size_t i = 0; i < n; ++i)
- {
- string file_path = src_dir+"video/big_buck_bunny."+ext[i];
- VideoCapture cap(file_path);
- if (!cap.isOpened())
- {
- TS::ptr()->printf(cvtest::TS::LOG, "\nFile information (video %d): \n\nName: big_buck_bunny.%s\nFAILED\n\n", i+1, ext[i].c_str());
- TS::ptr()->printf(cvtest::TS::LOG, "Error: cannot read source video file.\n");
- TS::ptr()->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
- return;
- }
-
- ASSERT_EQ(24, cap.get(CAP_PROP_FPS));
- }
-}
-
-TEST(Videoio_Video, prop_framecount)
-{
- const size_t n = sizeof(ext)/sizeof(ext[0]);
- const string src_dir = TS::ptr()->get_data_path();
-
- TS::ptr()->printf(cvtest::TS::LOG, "\n\nSource files directory: %s\n", (src_dir+"video/").c_str());
-
- for (size_t i = 0; i < n; ++i)
- {
- string file_path = src_dir+"video/big_buck_bunny."+ext[i];
- VideoCapture cap(file_path);
- if (!cap.isOpened())
- {
- TS::ptr()->printf(cvtest::TS::LOG, "\nFile information (video %d): \n\nName: big_buck_bunny.%s\nFAILED\n\n", i+1, ext[i].c_str());
- TS::ptr()->printf(cvtest::TS::LOG, "Error: cannot read source video file.\n");
- TS::ptr()->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
- return;
- }
-
- ASSERT_EQ(125, cap.get(CAP_PROP_FRAME_COUNT));
- }
-}
-
-#endif
diff --git a/modules/videoio/test/test_ffmpeg.cpp b/modules/videoio/test/test_ffmpeg.cpp
index fce8cf4..483ac43 100644
--- a/modules/videoio/test/test_ffmpeg.cpp
+++ b/modules/videoio/test/test_ffmpeg.cpp
@@ -138,7 +138,7 @@ public:
fprintf(stderr, "\n\nFile name: %s\n", filename.c_str());
fprintf(stderr, "Codec id: %d Codec tag: %c%c%c%c\n", (int)j,
tag & 255, (tag >> 8) & 255, (tag >> 16) & 255, (tag >> 24) & 255);
- fprintf(stderr, "Error: cannot create video file.");
+ fprintf(stderr, "Error: cannot create video file.\n");
if (entries[j].required)
ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
}
diff --git a/modules/videoio/test/test_framecount.cpp b/modules/videoio/test/test_framecount.cpp
deleted file mode 100644
index 94ddbf8..0000000
--- a/modules/videoio/test/test_framecount.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-#include "opencv2/videoio/videoio_c.h"
-#include <stdio.h>
-
-using namespace cv;
-using namespace std;
-
-class CV_FramecountTest: public cvtest::BaseTest
-{
-public:
- void run(int);
-};
-
-void CV_FramecountTest::run(int)
-{
- const int time_sec = 5, fps = 25;
-
- const string ext[] = {"avi", "mov", "mp4"};
-
- const size_t n = sizeof(ext)/sizeof(ext[0]);
-
- const string src_dir = ts->get_data_path();
-
- ts->printf(cvtest::TS::LOG, "\n\nSource files directory: %s\n", (src_dir+"video/").c_str());
-
- Ptr<CvCapture> cap;
-
- for (size_t i = 0; i < n; ++i)
- {
- string file_path = src_dir+"video/big_buck_bunny."+ext[i];
-
- cap.reset(cvCreateFileCapture(file_path.c_str()));
- if (!cap)
- {
- ts->printf(cvtest::TS::LOG, "\nFile information (video %d): \n\nName: big_buck_bunny.%s\nFAILED\n\n", i+1, ext[i].c_str());
- ts->printf(cvtest::TS::LOG, "Error: cannot read source video file.\n");
- ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
- return;
- }
-
- //cvSetCaptureProperty(cap, CV_CAP_PROP_POS_FRAMES, 0);
- IplImage* frame; int FrameCount = 0;
-
- for(;;)
- {
- frame = cvQueryFrame(cap);
- if( !frame )
- break;
- FrameCount++;
- }
-
- int framecount = (int)cvGetCaptureProperty(cap, CAP_PROP_FRAME_COUNT);
-
- ts->printf(cvtest::TS::LOG, "\nFile information (video %d): \n"\
- "\nName: big_buck_bunny.%s\nActual frame count: %d\n"\
- "Frame count computed in the cycle of queries of frames: %d\n"\
- "Frame count returned by cvGetCaptureProperty function: %d\n",
- i+1, ext[i].c_str(), time_sec*fps, FrameCount, framecount);
-
- if( (FrameCount != cvRound(time_sec*fps) ||
- FrameCount != framecount) && ext[i] != "mpg" )
- {
- ts->printf(cvtest::TS::LOG, "FAILED\n");
- ts->printf(cvtest::TS::LOG, "\nError: actual frame count and returned frame count are not matched.\n");
- ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);
- return;
- }
- }
-}
-#if BUILD_WITH_VIDEO_INPUT_SUPPORT && defined HAVE_FFMPEG
-TEST(Videoio_Video, framecount) {CV_FramecountTest test; test.safe_run();}
-#endif
diff --git a/modules/videoio/test/test_mfx.cpp b/modules/videoio/test/test_mfx.cpp
new file mode 100644
index 0000000..875b692
--- /dev/null
+++ b/modules/videoio/test/test_mfx.cpp
@@ -0,0 +1,154 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#include "test_precomp.hpp"
+#include "opencv2/videoio.hpp"
+#include "opencv2/highgui.hpp"
+#include <sstream>
+#include <queue>
+#include <cstdio>
+
+#ifdef HAVE_MFX
+
+using namespace cv;
+using namespace std;
+using namespace std::tr1;
+
+
+TEST(Videoio_MFX, read_invalid)
+{
+ VideoCapture cap;
+ ASSERT_NO_THROW(cap.open("nonexistent-file", CAP_INTEL_MFX));
+ ASSERT_FALSE(cap.isOpened());
+ Mat img;
+ ASSERT_NO_THROW(cap >> img);
+ ASSERT_TRUE(img.empty());
+}
+
+TEST(Videoio_MFX, write_invalid)
+{
+ const string filename = cv::tempfile(".264");
+ VideoWriter writer;
+ bool res;
+ ASSERT_NO_THROW(res = writer.open(CAP_INTEL_MFX, filename, VideoWriter::fourcc('H', '2', '6', '4'), 1, Size(641, 480), true));
+ EXPECT_FALSE(res);
+ EXPECT_FALSE(writer.isOpened());
+ ASSERT_NO_THROW(res = writer.open(CAP_INTEL_MFX,filename, VideoWriter::fourcc('H', '2', '6', '4'), 1, Size(640, 481), true));
+ EXPECT_FALSE(res);
+ EXPECT_FALSE(writer.isOpened());
+ ASSERT_NO_THROW(res = writer.open(CAP_INTEL_MFX,filename, VideoWriter::fourcc('A', 'B', 'C', 'D'), 1, Size(640, 480), true));
+ EXPECT_FALSE(res);
+ EXPECT_FALSE(writer.isOpened());
+ ASSERT_NO_THROW(res = writer.open(CAP_INTEL_MFX,String(), VideoWriter::fourcc('H', '2', '6', '4'), 1, Size(640, 480), true));
+ EXPECT_FALSE(res);
+ EXPECT_FALSE(writer.isOpened());
+ ASSERT_NO_THROW(res = writer.open(CAP_INTEL_MFX,filename, VideoWriter::fourcc('H', '2', '6', '4'), 0, Size(640, 480), true));
+ EXPECT_FALSE(res);
+ EXPECT_FALSE(writer.isOpened());
+
+ ASSERT_NO_THROW(res = writer.open(CAP_INTEL_MFX,filename, VideoWriter::fourcc('H', '2', '6', '4'), 30, Size(640, 480), true));
+ ASSERT_TRUE(res);
+ ASSERT_TRUE(writer.isOpened());
+ Mat t;
+ // write some bad frames
+ t = Mat(Size(1024, 768), CV_8UC3);
+ EXPECT_NO_THROW(writer << t);
+ t = Mat(Size(320, 240), CV_8UC3);
+ EXPECT_NO_THROW(writer << t);
+ t = Mat(Size(640, 480), CV_8UC2);
+ EXPECT_NO_THROW(writer << t);
+
+ // cleanup
+ ASSERT_NO_THROW(writer.release());
+ remove(filename.c_str());
+}
+
+
+//==================================================================================================
+
+const int FRAME_COUNT = 20;
+
+inline void generateFrame(int i, Mat & frame)
+{
+ generateFrame(i, FRAME_COUNT, frame);
+}
+
+inline int fourccByExt(const String &ext)
+{
+ if (ext == ".mpeg2")
+ return VideoWriter::fourcc('M', 'P', 'G', '2');
+ else if (ext == ".264")
+ return VideoWriter::fourcc('H', '2', '6', '4');
+ else if (ext == ".265")
+ return VideoWriter::fourcc('H', '2', '6', '5');
+ return -1;
+}
+
+//==================================================================================================
+
+typedef tuple<Size, double, const char *> Size_FPS_Ext;
+typedef testing::TestWithParam< Size_FPS_Ext > Videoio_MFX;
+
+TEST_P(Videoio_MFX, read_write_raw)
+{
+ const Size FRAME_SIZE = get<0>(GetParam());
+ const double FPS = get<1>(GetParam());
+ const char *ext = get<2>(GetParam());
+ const String filename = cv::tempfile(ext);
+ const int fourcc = fourccByExt(ext);
+
+ bool isColor = true;
+ queue<Mat> goodFrames;
+
+ // Write video
+ VideoWriter writer;
+ writer.open(CAP_INTEL_MFX, filename, fourcc, FPS, FRAME_SIZE, isColor);
+ ASSERT_TRUE(writer.isOpened());
+ Mat frame(FRAME_SIZE, CV_8UC3);
+ for (int i = 0; i < FRAME_COUNT; ++i)
+ {
+ generateFrame(i, frame);
+ goodFrames.push(frame.clone());
+ writer << frame;
+ }
+ writer.release();
+ EXPECT_FALSE(writer.isOpened());
+
+ // Read video
+ VideoCapture cap;
+ cap.open(filename, CAP_INTEL_MFX);
+ ASSERT_TRUE(cap.isOpened());
+ for (int i = 0; i < FRAME_COUNT; ++i)
+ {
+ ASSERT_TRUE(cap.read(frame));
+ ASSERT_FALSE(frame.empty());
+ ASSERT_EQ(FRAME_SIZE.width, frame.cols);
+ ASSERT_EQ(FRAME_SIZE.height, frame.rows);
+ // verify
+ ASSERT_NE(goodFrames.size(), 0u);
+ const Mat &goodFrame = goodFrames.front();
+ EXPECT_EQ(goodFrame.depth(), frame.depth());
+ EXPECT_EQ(goodFrame.channels(), frame.channels());
+ EXPECT_EQ(goodFrame.type(), frame.type());
+ double psnr = cvtest::PSNR(goodFrame, frame);
+ if (fourcc == VideoWriter::fourcc('M', 'P', 'G', '2'))
+ EXPECT_GT(psnr, 37); // experimentally chosen value
+ else
+ EXPECT_GT(psnr, 43); // experimentally chosen value
+ goodFrames.pop();
+ }
+ EXPECT_FALSE(cap.read(frame));
+ EXPECT_TRUE(frame.empty());
+ cap.release();
+ EXPECT_FALSE(cap.isOpened());
+ remove(filename.c_str());
+}
+
+INSTANTIATE_TEST_CASE_P(videoio, Videoio_MFX,
+ testing::Combine(
+ testing::Values(Size(640, 480), Size(638, 478), Size(636, 476), Size(1920, 1080)),
+ testing::Values(1, 30, 100),
+ testing::Values(".mpeg2", ".264", ".265")));
+
+#endif
diff --git a/modules/videoio/test/test_positioning.cpp b/modules/videoio/test/test_positioning.cpp
deleted file mode 100644
index 5cead8d..0000000
--- a/modules/videoio/test/test_positioning.cpp
+++ /dev/null
@@ -1,223 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-#include "opencv2/videoio/videoio_c.h"
-#include <stdio.h>
-
-using namespace cv;
-using namespace std;
-
-class CV_VideoPositioningTest: public cvtest::BaseTest
-{
-public:
- enum {PROGRESSIVE, RANDOM};
-
- CV_VideoPositioningTest();
- ~CV_VideoPositioningTest();
- virtual void run(int) = 0;
-
-protected:
- vector <int> idx;
- void run_test(int method);
-
-private:
- void generate_idx_seq(CvCapture *cap, int method);
-};
-
-class CV_VideoProgressivePositioningTest: public CV_VideoPositioningTest
-{
-public:
- CV_VideoProgressivePositioningTest() : CV_VideoPositioningTest() { }
- ~CV_VideoProgressivePositioningTest();
- void run(int);
-};
-
-class CV_VideoRandomPositioningTest: public CV_VideoPositioningTest
-{
-public:
- CV_VideoRandomPositioningTest(): CV_VideoPositioningTest() { }
- ~CV_VideoRandomPositioningTest();
- void run(int);
-};
-
-CV_VideoPositioningTest::CV_VideoPositioningTest() {}
-CV_VideoPositioningTest::~CV_VideoPositioningTest() {}
-CV_VideoProgressivePositioningTest::~CV_VideoProgressivePositioningTest() {}
-CV_VideoRandomPositioningTest::~CV_VideoRandomPositioningTest() {}
-
-void CV_VideoPositioningTest::generate_idx_seq(CvCapture* cap, int method)
-{
- idx.clear();
- int N = (int)cvGetCaptureProperty(cap, CAP_PROP_FRAME_COUNT);
- switch(method)
- {
- case PROGRESSIVE:
- {
- int pos = 1, step = 20;
- do
- {
- idx.push_back(pos);
- pos += step;
- }
- while (pos <= N);
- break;
- }
- case RANDOM:
- {
- RNG rng(N);
- idx.clear();
- for( int i = 0; i >= 0 && i < N-1; i++ )
- idx.push_back(rng.uniform(0, N));
- idx.push_back(N-1);
- std::swap(idx.at(rng.uniform(0, N-1)), idx.at(N-1));
- break;
- }
- default:break;
- }
-}
-
-void CV_VideoPositioningTest::run_test(int method)
-{
- const string& src_dir = ts->get_data_path();
-
- ts->printf(cvtest::TS::LOG, "\n\nSource files directory: %s\n", (src_dir+"video/").c_str());
-
- const string ext[] = {"avi", "mov", "mp4", "mpg"};
-
- int n = (int)(sizeof(ext)/sizeof(ext[0]));
-
- int failed_videos = 0;
-
- for (int i = 0; i < n; ++i)
- {
- // skip random positioning test in plain mpegs
- if( method == RANDOM && ext[i] == "mpg" )
- continue;
- string file_path = src_dir + "video/big_buck_bunny." + ext[i];
-
- ts->printf(cvtest::TS::LOG, "\nReading video file in %s...\n", file_path.c_str());
-
- CvCapture* cap = cvCreateFileCapture(file_path.c_str());
-
- if (!cap)
- {
- ts->printf(cvtest::TS::LOG, "\nFile information (video %d): \n\nName: big_buck_bunny.%s\nFAILED\n\n", i+1, ext[i].c_str());
- ts->printf(cvtest::TS::LOG, "Error: cannot read source video file.\n");
- ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
- failed_videos++; continue;
- }
-
- cvSetCaptureProperty(cap, CAP_PROP_POS_FRAMES, 0);
-
- generate_idx_seq(cap, method);
-
- int N = (int)idx.size(), failed_frames = 0, failed_positions = 0, failed_iterations = 0;
-
- for (int j = 0; j < N; ++j)
- {
- bool flag = false;
-
- cvSetCaptureProperty(cap, CAP_PROP_POS_FRAMES, idx.at(j));
-
- /* IplImage* frame = cvRetrieveFrame(cap);
-
- if (!frame)
- {
- if (!failed_frames)
- {
- ts->printf(cvtest::TS::LOG, "\nFile information (video %d): \n\nName: big_buck_bunny.%s\n", i+1, ext[i].c_str());
- }
- failed_frames++;
- ts->printf(cvtest::TS::LOG, "\nIteration: %d\n\nError: cannot read a frame with index %d.\n", j, idx.at(j));
- ts->set_failed_test_info(cvtest::TS::FAIL_EXCEPTION);
- flag = !flag;
- } */
-
- int val = (int)cvGetCaptureProperty(cap, CAP_PROP_POS_FRAMES);
-
- if (idx.at(j) != val)
- {
- if (!(failed_frames||failed_positions))
- {
- ts->printf(cvtest::TS::LOG, "\nFile information (video %d): \n\nName: big_buck_bunny.%s\n", i+1, ext[i].c_str());
- }
- failed_positions++;
- if (!failed_frames)
- {
- ts->printf(cvtest::TS::LOG, "\nIteration: %d\n", j);
- }
- ts->printf(cvtest::TS::LOG, "Required pos: %d\nReturned pos: %d\n", idx.at(j), val);
- ts->printf(cvtest::TS::LOG, "Error: required and returned positions are not matched.\n");
- ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);
- flag = true;
- }
-
- if (flag)
- {
- failed_iterations++;
- failed_videos++;
- break;
- }
- }
-
- cvReleaseCapture(&cap);
- }
-
- ts->printf(cvtest::TS::LOG, "\nSuccessfull experiments: %d (%d%%)\n", n-failed_videos, 100*(n-failed_videos)/n);
- ts->printf(cvtest::TS::LOG, "Failed experiments: %d (%d%%)\n", failed_videos, 100*failed_videos/n);
-}
-
-void CV_VideoProgressivePositioningTest::run(int)
-{
- run_test(PROGRESSIVE);
-}
-
-void CV_VideoRandomPositioningTest::run(int)
-{
- run_test(RANDOM);
-}
-
-#if BUILD_WITH_VIDEO_INPUT_SUPPORT && defined HAVE_FFMPEG
-TEST (Videoio_Video, seek_progressive) { CV_VideoProgressivePositioningTest test; test.safe_run(); }
-TEST (Videoio_Video, seek_random) { CV_VideoRandomPositioningTest test; test.safe_run(); }
-#endif
diff --git a/modules/videoio/test/test_precomp.hpp b/modules/videoio/test/test_precomp.hpp
index a6a5b44..bd56a72 100644
--- a/modules/videoio/test/test_precomp.hpp
+++ b/modules/videoio/test/test_precomp.hpp
@@ -18,74 +18,35 @@
#include "opencv2/core/private.hpp"
-#if defined(HAVE_DSHOW) || \
- defined(HAVE_TYZX) || \
- defined(HAVE_VFW) || \
- defined(HAVE_LIBV4L) || \
- (defined(HAVE_CAMV4L) && defined(HAVE_CAMV4L2)) || \
- defined(HAVE_GSTREAMER) || \
- defined(HAVE_DC1394_2) || \
- defined(HAVE_DC1394) || \
- defined(HAVE_CMU1394) || \
- defined(HAVE_MIL) || \
- defined(HAVE_QUICKTIME) || \
- defined(HAVE_QTKIT) || \
- defined(HAVE_UNICAP) || \
- defined(HAVE_PVAPI) || \
- defined(HAVE_OPENNI) || \
- defined(HAVE_XIMEA) || \
- defined(HAVE_AVFOUNDATION) || \
- defined(HAVE_GIGE_API) || \
- defined(HAVE_INTELPERC) || \
- defined(HAVE_GPHOTO2) || \
- (0)
-# define BUILD_WITH_CAMERA_SUPPORT 1
-#else
-# define BUILD_WITH_CAMERA_SUPPORT 0
-#endif
-
-#if defined(HAVE_XINE) || \
- defined(HAVE_GSTREAMER) || \
- defined(HAVE_QUICKTIME) || \
- defined(HAVE_QTKIT) || \
- defined(HAVE_AVFOUNDATION) || \
- /*defined(HAVE_OPENNI) || too specialized */ \
- defined(HAVE_FFMPEG) || \
- defined(HAVE_MSMF)
-# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
-#else
-# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
-#endif
-
-#if /*defined(HAVE_XINE) || */\
- defined(HAVE_GSTREAMER) || \
- defined(HAVE_QUICKTIME) || \
- defined(HAVE_QTKIT) || \
- defined(HAVE_AVFOUNDATION) || \
- defined(HAVE_FFMPEG) || \
- defined(HAVE_MSMF)
-# define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 1
-#else
-# define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 0
-#endif
-
-namespace cvtest
+inline std::string fourccToString(int fourcc)
{
+ return cv::format("%c%c%c%c", fourcc & 255, (fourcc >> 8) & 255, (fourcc >> 16) & 255, (fourcc >> 24) & 255);
+}
-string fourccToString(int fourcc);
-
-struct VideoFormat
+inline int fourccFromString(const std::string &fourcc)
{
- VideoFormat() { fourcc = -1; }
- VideoFormat(const string& _ext, int _fourcc) : ext(_ext), fourcc(_fourcc) {}
- bool empty() const { return ext.empty(); }
-
- string ext;
- int fourcc;
-};
-
-extern const VideoFormat g_specific_fmt_list[];
+ if (fourcc.size() != 4) return 0;
+ return cv::VideoWriter::fourcc(fourcc[0], fourcc[1], fourcc[2], fourcc[3]);
+}
+inline void generateFrame(int i, int FRAME_COUNT, cv::Mat & frame)
+{
+ using namespace cv;
+ using namespace std;
+ int offset = (((i * 5) % FRAME_COUNT) - FRAME_COUNT / 2) * (frame.cols / 2) / FRAME_COUNT;
+ frame(cv::Rect(0, 0, frame.cols / 2 + offset, frame.rows)) = Scalar(255, 255, 255);
+ frame(cv::Rect(frame.cols / 2 + offset, 0, frame.cols - frame.cols / 2 - offset, frame.rows)) = Scalar(0, 0, 0);
+ ostringstream buf; buf << "Frame " << setw(2) << setfill('0') << i + 1;
+ int baseLine = 0;
+ Size box = getTextSize(buf.str(), FONT_HERSHEY_COMPLEX, 2, 5, &baseLine);
+ putText(frame, buf.str(), Point((frame.cols - box.width) / 2, (frame.rows - box.height) / 2 + baseLine),
+ FONT_HERSHEY_COMPLEX, 2, Scalar(0, 0, 255), 5, LINE_AA);
+ Point p(i * frame.cols / (FRAME_COUNT - 1), i * frame.rows / (FRAME_COUNT - 1));
+ circle(frame, p, 50, Scalar(200, 25, 55), 8, LINE_AA);
+#if 0
+ imshow("frame", frame);
+ waitKey();
+#endif
}
#endif
diff --git a/modules/videoio/test/test_video_io.cpp b/modules/videoio/test/test_video_io.cpp
index ba50b4b..d2eae6f 100644
--- a/modules/videoio/test/test_video_io.cpp
+++ b/modules/videoio/test/test_video_io.cpp
@@ -42,546 +42,303 @@
#include "test_precomp.hpp"
#include "opencv2/videoio/videoio_c.h"
+#include "opencv2/highgui.hpp"
+#include <cstdio>
using namespace cv;
using namespace std;
+using namespace std::tr1;
-namespace cvtest
-{
-
-string fourccToString(int fourcc)
-{
- return format("%c%c%c%c", fourcc & 255, (fourcc >> 8) & 255, (fourcc >> 16) & 255, (fourcc >> 24) & 255);
-}
-
-#ifdef HAVE_MSMF
-const VideoFormat g_specific_fmt_list[] =
-{
- /*VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', '2', '5')),
- VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', '5', '0')),
- VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 'c', ' ')),
- VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 'h', '1')),
- VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 'h', 'd')),
- VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 's', 'd')),
- VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 's', 'l')),
- VideoFormat("wmv", CV_FOURCC_MACRO('H', '2', '6', '3')),
- VideoFormat("wmv", CV_FOURCC_MACRO('M', '4', 'S', '2')),
- VideoFormat("avi", CV_FOURCC_MACRO('M', 'J', 'P', 'G')),
- VideoFormat("mp4", CV_FOURCC_MACRO('M', 'P', '4', 'S')),
- VideoFormat("mp4", CV_FOURCC_MACRO('M', 'P', '4', 'V')),
- VideoFormat("wmv", CV_FOURCC_MACRO('M', 'P', '4', '3')),
- VideoFormat("wmv", CV_FOURCC_MACRO('M', 'P', 'G', '1')),
- VideoFormat("wmv", CV_FOURCC_MACRO('M', 'S', 'S', '1')),
- VideoFormat("wmv", CV_FOURCC_MACRO('M', 'S', 'S', '2')),*/
-#if !defined(_M_ARM)
- VideoFormat("wmv", CV_FOURCC_MACRO('W', 'M', 'V', '1')),
- VideoFormat("wmv", CV_FOURCC_MACRO('W', 'M', 'V', '2')),
-#endif
- VideoFormat("wmv", CV_FOURCC_MACRO('W', 'M', 'V', '3')),
- VideoFormat("avi", CV_FOURCC_MACRO('H', '2', '6', '4')),
- //VideoFormat("wmv", CV_FOURCC_MACRO('W', 'V', 'C', '1')),
- VideoFormat()
-};
-#else
-const VideoFormat g_specific_fmt_list[] =
-{
- VideoFormat("avi", VideoWriter::fourcc('X', 'V', 'I', 'D')),
- VideoFormat("avi", VideoWriter::fourcc('M', 'P', 'E', 'G')),
- VideoFormat("avi", VideoWriter::fourcc('M', 'J', 'P', 'G')),
- //VideoFormat("avi", VideoWriter::fourcc('I', 'Y', 'U', 'V')),
- VideoFormat("mkv", VideoWriter::fourcc('X', 'V', 'I', 'D')),
- VideoFormat("mkv", VideoWriter::fourcc('M', 'P', 'E', 'G')),
- VideoFormat("mkv", VideoWriter::fourcc('M', 'J', 'P', 'G')),
-#ifndef HAVE_GSTREAMER
- VideoFormat("mov", VideoWriter::fourcc('m', 'p', '4', 'v')),
-#endif
- VideoFormat()
-};
-#endif
-
-}
-
-class CV_VideoIOTest : public cvtest::BaseTest
+class Videoio_Test_Base
{
protected:
- void ImageTest (const string& dir);
- void VideoTest (const string& dir, const cvtest::VideoFormat& fmt);
- void SpecificImageTest (const string& dir);
- void SpecificVideoTest (const string& dir, const cvtest::VideoFormat& fmt);
-
- CV_VideoIOTest() {}
- ~CV_VideoIOTest() {}
- virtual void run(int) = 0;
-};
-
-class CV_ImageTest : public CV_VideoIOTest
-{
-public:
- CV_ImageTest() {}
- ~CV_ImageTest() {}
- void run(int);
-};
-
-class CV_SpecificImageTest : public CV_VideoIOTest
-{
-public:
- CV_SpecificImageTest() {}
- ~CV_SpecificImageTest() {}
- void run(int);
-};
-
-class CV_VideoTest : public CV_VideoIOTest
-{
-public:
- CV_VideoTest() {}
- ~CV_VideoTest() {}
- void run(int);
-};
-
-class CV_SpecificVideoTest : public CV_VideoIOTest
-{
-public:
- CV_SpecificVideoTest() {}
- ~CV_SpecificVideoTest() {}
- void run(int);
-};
-
-
-void CV_VideoIOTest::ImageTest(const string& dir)
-{
- string _name = dir + string("../cv/shared/baboon.png");
- ts->printf(ts->LOG, "reading image : %s\n", _name.c_str());
-
- Mat image = imread(_name);
- image.convertTo(image, CV_8UC3);
-
- if (image.empty())
+ string ext;
+ string video_file;
+protected:
+ Videoio_Test_Base() {}
+ virtual ~Videoio_Test_Base() {}
+ virtual void checkFrameContent(Mat &, int) {}
+ virtual void checkFrameCount(int &) {}
+ void checkFrameRead(int idx, VideoCapture & cap)
{
- ts->set_failed_test_info(ts->FAIL_MISSING_TEST_DATA);
- return;
+ //int frameID = (int)cap.get(CAP_PROP_POS_FRAMES);
+ Mat img; cap >> img;
+ //std::cout << "idx=" << idx << " img=" << img.size() << " frameID=" << frameID << std::endl;
+ ASSERT_FALSE(img.empty()) << "idx=" << idx;
+ checkFrameContent(img, idx);
}
-
- const string exts[] = {
-#ifdef HAVE_PNG
- "png",
-#endif
-#ifdef HAVE_TIFF
- "tiff",
-#endif
-#ifdef HAVE_JPEG
- "jpg",
-#endif
-#ifdef HAVE_JASPER
- "jp2",
-#endif
-#if 0 /*defined HAVE_OPENEXR && !defined __APPLE__*/
- "exr",
-#endif
- "bmp",
- "ppm",
- "ras"
- };
- const size_t ext_num = sizeof(exts)/sizeof(exts[0]);
-
- for(size_t i = 0; i < ext_num; ++i)
+ void checkFrameSeek(int idx, VideoCapture & cap)
{
- string ext = exts[i];
- string full_name = cv::tempfile(ext.c_str());
- ts->printf(ts->LOG, " full_name : %s\n", full_name.c_str());
-
- imwrite(full_name, image);
-
- Mat loaded = imread(full_name);
- if (loaded.empty())
+ bool canSeek = cap.set(CAP_PROP_POS_FRAMES, idx);
+ if (!canSeek)
{
- ts->printf(ts->LOG, "Reading failed at fmt=%s\n", ext.c_str());
- ts->set_failed_test_info(ts->FAIL_MISMATCH);
- continue;
+ std::cout << "Seek to frame '" << idx << "' is not supported. SKIP." << std::endl;
+ return;
}
-
- const double thresDbell = 20;
- double psnr = cvtest::PSNR(loaded, image);
- if (psnr < thresDbell)
+ EXPECT_EQ(idx, (int)cap.get(CAP_PROP_POS_FRAMES));
+ checkFrameRead(idx, cap);
+ }
+public:
+ void doTest()
+ {
+ VideoCapture cap(video_file);
+ if (!cap.isOpened())
{
- ts->printf(ts->LOG, "Reading image from file: too big difference (=%g) with fmt=%s\n", psnr, ext.c_str());
- ts->set_failed_test_info(ts->FAIL_BAD_ACCURACY);
- continue;
+ std::cout << "SKIP test: Can't open video: " << video_file << std::endl;
+ return;
}
- vector<uchar> from_file;
-
- FILE *f = fopen(full_name.c_str(), "rb");
- fseek(f, 0, SEEK_END);
- long len = ftell(f);
- from_file.resize((size_t)len);
- fseek(f, 0, SEEK_SET);
- from_file.resize(fread(&from_file[0], 1, from_file.size(), f));
- fclose(f);
-
- vector<uchar> buf;
- imencode("." + exts[i], image, buf);
-
- if (buf != from_file)
+ int n_frames = (int)cap.get(CAP_PROP_FRAME_COUNT);
+ if (n_frames > 0)
{
- ts->printf(ts->LOG, "Encoding failed with fmt=%s\n", ext.c_str());
- ts->set_failed_test_info(ts->FAIL_MISMATCH);
- continue;
+ ASSERT_GT(n_frames, 0);
+ checkFrameCount(n_frames);
}
-
- Mat buf_loaded = imdecode(Mat(buf), 1);
-
- if (buf_loaded.empty())
+ else
{
- ts->printf(ts->LOG, "Decoding failed with fmt=%s\n", ext.c_str());
- ts->set_failed_test_info(ts->FAIL_MISMATCH);
- continue;
+ std::cout << "CAP_PROP_FRAME_COUNT is not supported by backend. Assume 50 frames." << std::endl;
+ n_frames = 50;
}
- psnr = cvtest::PSNR(buf_loaded, image);
-
- if (psnr < thresDbell)
{
- ts->printf(ts->LOG, "Decoding image from memory: too small PSNR (=%gdb) with fmt=%s\n", psnr, ext.c_str());
- ts->set_failed_test_info(ts->FAIL_MISMATCH);
- continue;
+ SCOPED_TRACE("consecutive read");
+ for (int k = 0; k < n_frames; ++k)
+ {
+ checkFrameRead(k, cap);
+ }
}
- }
-
- ts->printf(ts->LOG, "end test function : ImagesTest \n");
- ts->set_failed_test_info(ts->OK);
-}
-
-
-void CV_VideoIOTest::VideoTest(const string& dir, const cvtest::VideoFormat& fmt)
-{
- string src_file = dir + "../cv/shared/video_for_test.avi";
- string tmp_name = cv::tempfile((cvtest::fourccToString(fmt.fourcc) + "." + fmt.ext).c_str());
-
- ts->printf(ts->LOG, "reading video : %s and converting it to %s\n", src_file.c_str(), tmp_name.c_str());
-
- CvCapture* cap = cvCaptureFromFile(src_file.c_str());
-
- if (!cap)
- {
- ts->set_failed_test_info(ts->FAIL_MISMATCH);
- return;
- }
-
- CvVideoWriter* writer = 0;
- vector<Mat> frames;
-
- for(;;)
- {
- IplImage* img = cvQueryFrame( cap );
-
- if (!img)
- break;
-
- frames.push_back(cv::cvarrToMat(img, true));
+ bool canSeek = cap.set(CAP_PROP_POS_FRAMES, 0);
+ if (!canSeek)
+ {
+ std::cout << "Seek to frame '0' is not supported. SKIP all 'seek' tests." << std::endl;
+ return;
+ }
- if (writer == NULL)
+ if (ext != "wmv")
{
- writer = cvCreateVideoWriter(tmp_name.c_str(), fmt.fourcc, 24, cvGetSize(img));
- if (writer == NULL)
+ SCOPED_TRACE("progressive seek");
+ ASSERT_TRUE(cap.set(CAP_PROP_POS_FRAMES, 0));
+ for (int k = 0; k < n_frames; k += 20)
{
- ts->printf(ts->LOG, "can't create writer (with fourcc : %s)\n",
- cvtest::fourccToString(fmt.fourcc).c_str());
- cvReleaseCapture( &cap );
- ts->set_failed_test_info(ts->FAIL_MISMATCH);
- return;
+ checkFrameSeek(k, cap);
}
}
- cvWriteFrame(writer, img);
- }
-
- cvReleaseVideoWriter( &writer );
- cvReleaseCapture( &cap );
-
- CvCapture *saved = cvCaptureFromFile(tmp_name.c_str());
- if (!saved)
- {
- ts->set_failed_test_info(ts->FAIL_MISMATCH);
- return;
- }
-
- const double thresDbell = 20;
-
- for(int i = 0;; i++)
- {
- IplImage* ipl1 = cvQueryFrame( saved );
-
- if (!ipl1)
- break;
-
- Mat img = frames[i];
- Mat img1 = cv::cvarrToMat(ipl1);
-
- double psnr = cvtest::PSNR(img1, img);
- if (psnr < thresDbell)
+ if (ext != "mpg" && ext != "wmv")
{
- ts->printf(ts->LOG, "Too low frame %d psnr = %gdb\n", i, psnr);
- ts->set_failed_test_info(ts->FAIL_MISMATCH);
-
- //imwrite("original.png", img);
- //imwrite("after_test.png", img1);
- //Mat diff;
- //absdiff(img, img1, diff);
- //imwrite("diff.png", diff);
-
- break;
+ SCOPED_TRACE("random seek");
+ ASSERT_TRUE(cap.set(CAP_PROP_POS_FRAMES, 0));
+ for (int k = 0; k < 10; ++k)
+ {
+ checkFrameSeek(cvtest::TS::ptr()->get_rng().uniform(0, n_frames), cap);
+ }
}
}
+};
- cvReleaseCapture( &saved );
+//==================================================================================================
- ts->printf(ts->LOG, "end test function : ImagesVideo \n");
-}
-
-void CV_VideoIOTest::SpecificImageTest(const string& dir)
+class Videoio_Bunny : public Videoio_Test_Base, public testing::TestWithParam<string>
{
- const size_t IMAGE_COUNT = 10;
-
- for (size_t i = 0; i < IMAGE_COUNT; ++i)
+public:
+ Videoio_Bunny()
{
- stringstream s; s << i;
- string file_path = dir+"../python/images/QCIF_0"+s.str()+".bmp";
- Mat image = imread(file_path);
-
- if (image.empty())
+ ext = GetParam();
+ video_file = cvtest::TS::ptr()->get_data_path() + "video/big_buck_bunny." + ext;
+ }
+ void doFrameCountTest()
+ {
+ VideoCapture cap(video_file);
+ if (!cap.isOpened())
{
- ts->set_failed_test_info(ts->FAIL_MISSING_TEST_DATA);
+ std::cout << "SKIP test: Can't open video: " << video_file << std::endl;
return;
}
- resize(image, image, Size(968, 757), 0.0, 0.0, INTER_CUBIC);
+ const int width_gt = 672;
+ const int height_gt = 384;
+ const int fps_gt = 24;
+ const double time_gt = 5.21;
+ const int count_gt = cvRound(fps_gt * time_gt); // 5.21 sec * 24 fps
- stringstream s_digit; s_digit << i;
-
- string full_name = cv::tempfile((s_digit.str() + ".bmp").c_str());
- ts->printf(ts->LOG, " full_name : %s\n", full_name.c_str());
-
- imwrite(full_name, image);
-
- Mat loaded = imread(full_name);
- if (loaded.empty())
- {
- ts->printf(ts->LOG, "Reading failed at fmt=bmp\n");
- ts->set_failed_test_info(ts->FAIL_MISMATCH);
- continue;
- }
+ EXPECT_EQ(width_gt, cap.get(CAP_PROP_FRAME_WIDTH));
+ EXPECT_EQ(height_gt, cap.get(CAP_PROP_FRAME_HEIGHT));
- const double thresDbell = 20;
- double psnr = cvtest::PSNR(loaded, image);
- if (psnr < thresDbell)
- {
- ts->printf(ts->LOG, "Reading image from file: too big difference (=%g) with fmt=bmp\n", psnr);
- ts->set_failed_test_info(ts->FAIL_BAD_ACCURACY);
- continue;
- }
-
- vector<uchar> from_file;
-
- FILE *f = fopen(full_name.c_str(), "rb");
- fseek(f, 0, SEEK_END);
- long len = ftell(f);
- from_file.resize((size_t)len);
- fseek(f, 0, SEEK_SET);
- from_file.resize(fread(&from_file[0], 1, from_file.size(), f));
- fclose(f);
-
- vector<uchar> buf;
- imencode(".bmp", image, buf);
-
- if (buf != from_file)
- {
- ts->printf(ts->LOG, "Encoding failed with fmt=bmp\n");
- ts->set_failed_test_info(ts->FAIL_MISMATCH);
- continue;
- }
+ double fps_prop = cap.get(CAP_PROP_FPS);
+ if (fps_prop > 0)
+ EXPECT_NEAR(fps_prop, fps_gt, 1);
+ else
+ std::cout << "FPS is not available. SKIP check." << std::endl;
- Mat buf_loaded = imdecode(Mat(buf), 1);
+ int count_prop = (int)cap.get(CAP_PROP_FRAME_COUNT);
- if (buf_loaded.empty())
+ // mpg file reports 5.08 sec * 24 fps => property returns 122 frames
+ // but actual number of frames returned is 125
+ if (ext != "mpg")
{
- ts->printf(ts->LOG, "Decoding failed with fmt=bmp\n");
- ts->set_failed_test_info(ts->FAIL_MISMATCH);
- continue;
+ if (count_prop > 0)
+ EXPECT_EQ(count_gt, count_prop);
}
- psnr = cvtest::PSNR(buf_loaded, image);
-
- if (psnr < thresDbell)
+ int count_actual = 0;
+ while (cap.isOpened())
{
- ts->printf(ts->LOG, "Decoding image from memory: too small PSNR (=%gdb) with fmt=bmp\n", psnr);
- ts->set_failed_test_info(ts->FAIL_MISMATCH);
- continue;
+ Mat frame;
+ cap >> frame;
+ if (frame.empty())
+ break;
+ EXPECT_EQ(width_gt, frame.cols);
+ EXPECT_EQ(height_gt, frame.rows);
+ count_actual += 1;
}
+ if (count_prop > 0)
+ EXPECT_NEAR(count_gt, count_actual, 1);
+ else
+ std::cout << "Frames counter is not available. Actual frames: " << count_actual << ". SKIP check." << std::endl;
}
+};
- ts->printf(ts->LOG, "end test function : SpecificImageTest \n");
- ts->set_failed_test_info(ts->OK);
-}
-
+typedef tuple<string, string, float> Ext_Fourcc_PSNR;
+typedef tuple<Size, Ext_Fourcc_PSNR> Size_Ext_Fourcc_PSNR;
-void CV_VideoIOTest::SpecificVideoTest(const string& dir, const cvtest::VideoFormat& fmt)
+class Videoio_Synthetic : public Videoio_Test_Base, public testing::TestWithParam<Size_Ext_Fourcc_PSNR>
{
- string ext = fmt.ext;
- int fourcc = fmt.fourcc;
-
- string fourcc_str = cvtest::fourccToString(fourcc);
- const string video_file = cv::tempfile((fourcc_str + "." + ext).c_str());
-
- Size frame_size(968 & -2, 757 & -2);
- VideoWriter writer(video_file, fourcc, 25, frame_size, true);
-
- if (!writer.isOpened())
+ Size frame_size;
+ int fourcc;
+ float PSNR_GT;
+ int frame_count;
+ double fps;
+public:
+ Videoio_Synthetic()
{
- // call it repeatedly for easier debugging
- VideoWriter writer2(video_file, fourcc, 25, frame_size, true);
- ts->printf(ts->LOG, "Creating a video in %s...\n", video_file.c_str());
- ts->printf(ts->LOG, "Cannot create VideoWriter object with codec %s.\n", fourcc_str.c_str());
- ts->set_failed_test_info(ts->FAIL_MISMATCH);
- return;
+ frame_size = get<0>(GetParam());
+ const Ext_Fourcc_PSNR ¶m = get<1>(GetParam());
+ ext = get<0>(param);
+ fourcc = fourccFromString(get<1>(param));
+ PSNR_GT = get<2>(param);
+ video_file = cv::tempfile((fourccToString(fourcc) + "." + ext).c_str());
+ frame_count = 100;
+ fps = 25.;
}
-
- const size_t IMAGE_COUNT = 30;
- vector<Mat> images;
-
- for( size_t i = 0; i < IMAGE_COUNT; ++i )
+ void SetUp()
{
- string file_path = format("%s../python/images/QCIF_%02d.bmp", dir.c_str(), i);
- Mat img = imread(file_path, IMREAD_COLOR);
-
- if (img.empty())
+ Mat img(frame_size, CV_8UC3);
+ VideoWriter writer(video_file, fourcc, fps, frame_size, true);
+ ASSERT_TRUE(writer.isOpened());
+ for(int i = 0; i < frame_count; ++i )
{
- ts->printf(ts->LOG, "Creating a video in %s...\n", video_file.c_str());
- ts->printf(ts->LOG, "Error: cannot read frame from %s.\n", file_path.c_str());
- ts->printf(ts->LOG, "Continue creating the video file...\n");
- ts->set_failed_test_info(ts->FAIL_INVALID_TEST_DATA);
- break;
+ generateFrame(i, frame_count, img);
+ writer << img;
}
-
- for (int k = 0; k < img.rows; ++k)
- for (int l = 0; l < img.cols; ++l)
- if (img.at<Vec3b>(k, l) == Vec3b::all(0))
- img.at<Vec3b>(k, l) = Vec3b(0, 255, 0);
- else img.at<Vec3b>(k, l) = Vec3b(0, 0, 255);
-
- resize(img, img, frame_size, 0.0, 0.0, INTER_CUBIC);
-
- images.push_back(img);
- writer << img;
+ writer.release();
+ }
+ void TearDown()
+ {
+ remove(video_file.c_str());
+ }
+ virtual void checkFrameContent(Mat & img, int idx)
+ {
+ Mat imgGT(frame_size, CV_8UC3);
+ generateFrame(idx, frame_count, imgGT);
+ double psnr = cvtest::PSNR(img, imgGT);
+ ASSERT_GT(psnr, PSNR_GT) << "frame " << idx;
}
+ virtual void checkFrameCount(int &actual)
+ {
+ Range expected_frame_count = Range(frame_count, frame_count);
+
+ // Hack! Newer FFmpeg versions in this combination produce a file
+ // whose reported duration is one frame longer than needed, and so
+ // the calculated frame count is also off by one. Ideally, we'd want
+ // to fix both writing (to produce the correct duration) and reading
+ // (to correctly report frame count for such files), but I don't know
+ // how to do either, so this is a workaround for now.
+ if (fourcc == VideoWriter::fourcc('M', 'P', 'E', 'G') && ext == "mkv")
+ expected_frame_count.end += 1;
+
+ // Hack! Some GStreamer encoding pipelines drop last frame in the video
+#ifdef HAVE_GSTREAMER
+ expected_frame_count.start -= 1;
+#endif
- writer.release();
- VideoCapture cap(video_file);
+ ASSERT_LE(expected_frame_count.start, actual);
+ ASSERT_GE(expected_frame_count.end, actual);
- size_t FRAME_COUNT = (size_t)cap.get(CAP_PROP_FRAME_COUNT);
+ actual = expected_frame_count.start; // adjust actual frame boundary to possible minimum
+ }
+};
- size_t allowed_extra_frames = 0;
+//==================================================================================================
- // Hack! Newer FFmpeg versions in this combination produce a file
- // whose reported duration is one frame longer than needed, and so
- // the calculated frame count is also off by one. Ideally, we'd want
- // to fix both writing (to produce the correct duration) and reading
- // (to correctly report frame count for such files), but I don't know
- // how to do either, so this is a workaround for now.
- // See also the same hack in CV_PositioningTest::run.
- if (fourcc == VideoWriter::fourcc('M', 'P', 'E', 'G') && ext == "mkv")
- allowed_extra_frames = 1;
- // Hack! Some GStreamer encoding pipelines drop last frame in the video
- int allowed_frame_frop = 0;
-#ifdef HAVE_GSTREAMER
- allowed_frame_frop = 1;
+string bunny_params[] = {
+#ifdef HAVE_VIDEO_INPUT
+ string("avi"),
+ string("mov"),
+ string("mp4"),
+ string("mpg"),
+ string("wmv"),
#endif
+ string("mjpg.avi")
+};
- if (FRAME_COUNT < IMAGE_COUNT - allowed_frame_frop || FRAME_COUNT > IMAGE_COUNT + allowed_extra_frames)
- {
- ts->printf(ts->LOG, "\nFrame count checking for video_%s.%s...\n", fourcc_str.c_str(), ext.c_str());
- ts->printf(ts->LOG, "Video codec: %s\n", fourcc_str.c_str());
- if (allowed_extra_frames != 0)
- ts->printf(ts->LOG, "Required frame count: %d-%d; Returned frame count: %d\n",
- IMAGE_COUNT, IMAGE_COUNT + allowed_extra_frames, FRAME_COUNT);
- else
- ts->printf(ts->LOG, "Required frame count: %d; Returned frame count: %d\n", IMAGE_COUNT, FRAME_COUNT);
- ts->printf(ts->LOG, "Error: Incorrect frame count in the video.\n");
- ts->printf(ts->LOG, "Continue checking...\n");
- ts->set_failed_test_info(ts->FAIL_BAD_ACCURACY);
- return;
- }
+TEST_P(Videoio_Bunny, read_position) { doTest(); }
- for (int i = 0; (size_t)i < IMAGE_COUNT-allowed_frame_frop; i++)
- {
- Mat frame; cap >> frame;
- if (frame.empty())
- {
- ts->printf(ts->LOG, "\nVideo file directory: %s\n", ".");
- ts->printf(ts->LOG, "File name: video_%s.%s\n", fourcc_str.c_str(), ext.c_str());
- ts->printf(ts->LOG, "Video codec: %s\n", fourcc_str.c_str());
- ts->printf(ts->LOG, "Error: cannot read the next frame with index %d.\n", i+1);
- ts->set_failed_test_info(ts->FAIL_MISSING_TEST_DATA);
- break;
- }
+TEST_P(Videoio_Bunny, frame_count) { doFrameCountTest(); }
- Mat img = images[i];
+INSTANTIATE_TEST_CASE_P(videoio, Videoio_Bunny,
+ testing::ValuesIn(bunny_params));
- const double thresDbell = 40;
- double psnr = cvtest::PSNR(img, frame);
- if (psnr > thresDbell)
- {
- ts->printf(ts->LOG, "\nReading frame from the file video_%s.%s...\n", fourcc_str.c_str(), ext.c_str());
- ts->printf(ts->LOG, "Frame index: %d\n", i+1);
- ts->printf(ts->LOG, "Difference between saved and original images: %g\n", psnr);
- ts->printf(ts->LOG, "Maximum allowed difference: %g\n", thresDbell);
- ts->printf(ts->LOG, "Error: too big difference between saved and original images.\n");
- break;
- }
- }
-}
+//==================================================================================================
-void CV_ImageTest::run(int)
+inline Ext_Fourcc_PSNR makeParam(const char * ext, const char * fourcc, float psnr)
{
- ImageTest(ts->get_data_path());
+ return make_tuple(string(ext), string(fourcc), (float)psnr);
}
-void CV_SpecificImageTest::run(int)
-{
- SpecificImageTest(ts->get_data_path());
-}
+Ext_Fourcc_PSNR synthetic_params[] = {
-void CV_VideoTest::run(int)
-{
- for (int i = 0; ; ++i)
- {
- const cvtest::VideoFormat& fmt = cvtest::g_specific_fmt_list[i];
- if( fmt.empty() )
- break;
- VideoTest(ts->get_data_path(), fmt);
- }
-}
+#if defined(HAVE_VIDEO_INPUT) && defined(HAVE_VIDEO_OUTPUT) && !defined(__APPLE__)
-void CV_SpecificVideoTest::run(int)
-{
- for (int i = 0; ; ++i)
- {
- const cvtest::VideoFormat& fmt = cvtest::g_specific_fmt_list[i];
- if( fmt.empty() )
- break;
- SpecificVideoTest(ts->get_data_path(), fmt);
- }
-}
+#ifdef HAVE_MSMF
-#ifdef HAVE_JPEG
-TEST(Videoio_Image, regression) { CV_ImageTest test; test.safe_run(); }
+#if !defined(_M_ARM)
+ makeParam("wmv", "WMV1", 30.f),
+ makeParam("wmv", "WMV2", 30.f),
#endif
-
-#if BUILD_WITH_VIDEO_INPUT_SUPPORT && BUILD_WITH_VIDEO_OUTPUT_SUPPORT && !defined(__APPLE__)
-TEST(Videoio_Video, regression) { CV_VideoTest test; test.safe_run(); }
-TEST(Videoio_Video, write_read) { CV_SpecificVideoTest test; test.safe_run(); }
+ makeParam("wmv", "WMV3", 30.f),
+ makeParam("avi", "H264", 30.f),
+ makeParam("wmv", "WVC1", 30.f),
+
+#else // HAVE_MSMF
+
+ makeParam("avi", "XVID", 30.f),
+ makeParam("avi", "MPEG", 30.f),
+ makeParam("avi", "IYUV", 30.f),
+ makeParam("mkv", "XVID", 30.f),
+ makeParam("mkv", "MPEG", 30.f),
+ makeParam("mkv", "MJPG", 30.f),
+#ifndef HAVE_GSTREAMER
+ makeParam("mov", "mp4v", 30.f),
#endif
-TEST(Videoio_Image, write_read) { CV_SpecificImageTest test; test.safe_run(); }
+#endif // HAVE_MSMF
+
+#endif // HAVE_VIDEO_INPUT && HAVE_VIDEO_OUTPUT ...
+
+ makeParam("avi", "MJPG", 30.f)
+};
+
+Size all_sizes[] = {
+ Size(640, 480),
+ Size(976, 768)
+};
+
+TEST_P(Videoio_Synthetic, write_read_position) { doTest(); }
+
+INSTANTIATE_TEST_CASE_P(videoio, Videoio_Synthetic,
+ testing::Combine(
+ testing::ValuesIn(all_sizes),
+ testing::ValuesIn(synthetic_params)));
diff --git a/modules/videoio/test/test_video_pos.cpp b/modules/videoio/test/test_video_pos.cpp
deleted file mode 100644
index cd21bc2..0000000
--- a/modules/videoio/test/test_video_pos.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
- //
- // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
- //
- // By downloading, copying, installing or using the software you agree to this license.
- // If you do not agree to this license, do not download, install,
- // copy or use the software.
- //
- //
- // License Agreement
- // For Open Source Computer Vision Library
- //
- // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
- // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
- // Third party copyrights are property of their respective owners.
- //
- // Redistribution and use in source and binary forms, with or without modification,
- // are permitted provided that the following conditions are met:
- //
- // * Redistribution's of source code must retain the above copyright notice,
- // this list of conditions and the following disclaimer.
- //
- // * Redistribution's in binary form must reproduce the above copyright notice,
- // this list of conditions and the following disclaimer in the documentation
- // and/or other materials provided with the distribution.
- //
- // * The name of the copyright holders may not be used to endorse or promote products
- // derived from this software without specific prior written permission.
- //
- // This software is provided by the copyright holders and contributors "as is" and
- // any express or implied warranties, including, but not limited to, the implied
- // warranties of merchantability and fitness for a particular purpose are disclaimed.
- // In no event shall the Intel Corporation or contributors be liable for any direct,
- // indirect, incidental, special, exemplary, or consequential damages
- // (including, but not limited to, procurement of substitute goods or services;
- // loss of use, data, or profits; or business interruption) however caused
- // and on any theory of liability, whether in contract, strict liability,
- // or tort (including negligence or otherwise) arising in any way out of
- // the use of this software, even if advised of the possibility of such damage.
- //
- //M*/
-
-#include "test_precomp.hpp"
-#include "opencv2/videoio.hpp"
-
-using namespace cv;
-using namespace std;
-
-class CV_PositioningTest : public cvtest::BaseTest
-{
-public:
- CV_PositioningTest()
- {
- framesize = Size(640, 480);
- }
-
- Mat drawFrame(int i)
- {
- Mat mat = Mat::zeros(framesize, CV_8UC3);
-
- mat = Scalar(fabs(cos(i*0.08)*255), fabs(sin(i*0.05)*255), i);
- putText(mat, format("%03d", i), Point(10, 350), 0, 10, Scalar(128, 255, 255), 15);
- return mat;
- }
-
- string getFilename(const cvtest::VideoFormat& fmt)
- {
- return cv::tempfile((cvtest::fourccToString(fmt.fourcc) + "." + fmt.ext).c_str());
- }
-
- bool CreateTestVideo(const cvtest::VideoFormat& fmt, int framecount, string filename)
- {
- VideoWriter writer(filename, fmt.fourcc, 25, framesize, true);
- if( !writer.isOpened() )
- return false;
-
- for (int i = 0; i < framecount; ++i)
- {
- Mat img = drawFrame(i);
- writer << img;
- }
- return true;
- }
-
- void run(int)
- {
- int n_frames = 100;
-
- for( int testcase = 0; ; testcase++ )
- {
- const cvtest::VideoFormat& fmt = cvtest::g_specific_fmt_list[testcase];
- if( fmt.empty() )
- break;
- string filename = getFilename(fmt);
- ts->printf(ts->LOG, "\nFile: %s\n", filename.c_str());
-
- if( !CreateTestVideo(fmt, n_frames, filename) )
- {
- ts->printf(ts->LOG, "\nError: cannot create video file");
- ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
- return;
- }
-
- VideoCapture cap(filename);
-
- if (!cap.isOpened())
- {
- ts->printf(ts->LOG, "\nError: cannot read video file.");
- ts->set_failed_test_info(ts->FAIL_INVALID_TEST_DATA);
- return;
- }
-
- int N0 = (int)cap.get(CAP_PROP_FRAME_COUNT);
- cap.set(CAP_PROP_POS_FRAMES, 0);
- int N = (int)cap.get(CAP_PROP_FRAME_COUNT);
-
- // See the same hack in CV_VideoIOTest::SpecificVideoTest for explanation.
- int allowed_extra_frames = 0;
- if (fmt.fourcc == VideoWriter::fourcc('M', 'P', 'E', 'G') && fmt.ext == "mkv")
- allowed_extra_frames = 1;
-
- if (N < n_frames || N > n_frames + allowed_extra_frames || N != N0)
- {
- ts->printf(ts->LOG, "\nError: returned frame count (N0=%d, N=%d) is different from the reference number %d\n", N0, N, n_frames);
- ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
- return;
- }
-
- for (int k = 0; k < n_frames; ++k)
- {
- int idx = theRNG().uniform(0, n_frames);
-
- if( !cap.set(CAP_PROP_POS_FRAMES, idx) )
- {
- ts->printf(ts->LOG, "\nError: cannot seek to frame %d.\n", idx);
- ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
- return;
- }
-
- int idx1 = (int)cap.get(CAP_PROP_POS_FRAMES);
-
- Mat img; cap >> img;
- Mat img0 = drawFrame(idx);
-
- if( idx != idx1 )
- {
- ts->printf(ts->LOG, "\nError: the current position (%d) after seek is different from specified (%d)\n",
- idx1, idx);
- ts->printf(ts->LOG, "Saving both frames ...\n");
- ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
- return;
- }
-
- if (img.empty())
- {
- ts->printf(ts->LOG, "\nError: cannot read a frame at position %d.\n", idx);
- ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
- return;
- }
-
- double err = cvtest::PSNR(img, img0);
-
- if( err < 20 )
- {
- ts->printf(ts->LOG, "The frame read after positioning to %d is incorrect (PSNR=%g)\n", idx, err);
- ts->printf(ts->LOG, "Saving both frames ...\n");
- ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
- return;
- }
- }
- }
- }
-
- Size framesize;
-};
-
-#if BUILD_WITH_VIDEO_INPUT_SUPPORT && BUILD_WITH_VIDEO_OUTPUT_SUPPORT && defined HAVE_FFMPEG
-TEST(Videoio_Video, seek_random_synthetic) { CV_PositioningTest test; test.safe_run(); }
-#endif
diff --git a/modules/videostab/include/opencv2/videostab/fast_marching.hpp b/modules/videostab/include/opencv2/videostab/fast_marching.hpp
index 526b10b..43f8e4a 100644
--- a/modules/videostab/include/opencv2/videostab/fast_marching.hpp
+++ b/modules/videostab/include/opencv2/videostab/fast_marching.hpp
@@ -63,7 +63,7 @@ namespace videostab
class CV_EXPORTS FastMarchingMethod
{
public:
- FastMarchingMethod() : inf_(1e6f) {}
+ FastMarchingMethod() : inf_(1e6f), size_(0) {}
/** @brief Template method that runs the Fast Marching Method.
diff --git a/modules/videostab/include/opencv2/videostab/global_motion.hpp b/modules/videostab/include/opencv2/videostab/global_motion.hpp
index 80b147a..8250654 100644
--- a/modules/videostab/include/opencv2/videostab/global_motion.hpp
+++ b/modules/videostab/include/opencv2/videostab/global_motion.hpp
@@ -236,6 +236,7 @@ public:
Ptr<IOutlierRejector> outlierRejector() const { return outlierRejector_; }
virtual Mat estimate(const Mat &frame0, const Mat &frame1, bool *ok = 0);
+ Mat estimate(InputArray frame0, InputArray frame1, bool *ok = 0);
private:
Ptr<MotionEstimatorBase> motionEstimator_;
diff --git a/modules/videostab/src/global_motion.cpp b/modules/videostab/src/global_motion.cpp
index 5360338..f40ef4c 100644
--- a/modules/videostab/src/global_motion.cpp
+++ b/modules/videostab/src/global_motion.cpp
@@ -402,8 +402,8 @@ Mat estimateGlobalMotionRansac(
std::vector<Point2f> subset1(params.size);
// best hypothesis
- std::vector<Point2f> subset0best(params.size);
- std::vector<Point2f> subset1best(params.size);
+ std::vector<int> bestIndices(params.size);
+
Mat_<float> bestM;
int ninliersMax = -1;
@@ -447,14 +447,20 @@ Mat estimateGlobalMotionRansac(
{
bestM = M;
ninliersMax = numinliers;
- subset0best.swap(subset0);
- subset1best.swap(subset1);
+ bestIndices.swap(indices);
}
}
if (ninliersMax < params.size)
+ {
// compute RMSE
- bestM = estimateGlobalMotionLeastSquares(subset0best, subset1best, model, rmse);
+ for (int i = 0; i < params.size; ++i)
+ {
+ subset0[i] = points0_[bestIndices[i]];
+ subset1[i] = points1_[bestIndices[i]];
+ }
+ bestM = estimateGlobalMotionLeastSquares(subset0, subset1, model, rmse);
+ }
else
{
subset0.resize(ninliersMax);
@@ -711,6 +717,14 @@ KeypointBasedMotionEstimator::KeypointBasedMotionEstimator(Ptr<MotionEstimatorBa
Mat KeypointBasedMotionEstimator::estimate(const Mat &frame0, const Mat &frame1, bool *ok)
{
+ InputArray image0 = frame0;
+ InputArray image1 = frame1;
+
+ return estimate(image0, image1, ok);
+}
+
+Mat KeypointBasedMotionEstimator::estimate(InputArray frame0, InputArray frame1, bool *ok)
+{
// find keypoints
detector_->detect(frame0, keypointsPrev_);
if (keypointsPrev_.empty())
diff --git a/modules/videostab/src/stabilizer.cpp b/modules/videostab/src/stabilizer.cpp
index f9c09ba..cf25b48 100644
--- a/modules/videostab/src/stabilizer.cpp
+++ b/modules/videostab/src/stabilizer.cpp
@@ -63,6 +63,11 @@ StabilizerBase::StabilizerBase()
setTrimRatio(0);
setCorrectionForInclusion(false);
setBorderMode(BORDER_REPLICATE);
+ curPos_ = 0;
+ doDeblurring_ = false;
+ doInpainting_ = false;
+ processingStartTime_ = 0;
+ curStabilizedPos_ = 0;
}
diff --git a/modules/videostab/src/wobble_suppression.cpp b/modules/videostab/src/wobble_suppression.cpp
index 86067fb..079c511 100644
--- a/modules/videostab/src/wobble_suppression.cpp
+++ b/modules/videostab/src/wobble_suppression.cpp
@@ -85,7 +85,7 @@ namespace cv
namespace videostab
{
-WobbleSuppressorBase::WobbleSuppressorBase() : motions_(0), stabilizationMotions_(0)
+WobbleSuppressorBase::WobbleSuppressorBase() : frameCount_(0), motions_(0), motions2_(0), stabilizationMotions_(0)
{
setMotionEstimator(makePtr<KeypointBasedMotionEstimator>(makePtr<MotionEstimatorRansacL2>(MM_HOMOGRAPHY)));
}
diff --git a/modules/videostab/test/test_main.cpp b/modules/videostab/test/test_main.cpp
new file mode 100644
index 0000000..6b24993
--- /dev/null
+++ b/modules/videostab/test/test_main.cpp
@@ -0,0 +1,3 @@
+#include "test_precomp.hpp"
+
+CV_TEST_MAIN("cv")
diff --git a/modules/videostab/test/test_motion_estimation.cpp b/modules/videostab/test/test_motion_estimation.cpp
new file mode 100644
index 0000000..78d25bc
--- /dev/null
+++ b/modules/videostab/test/test_motion_estimation.cpp
@@ -0,0 +1,171 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+#include "test_precomp.hpp"
+
+namespace testUtil
+{
+
+cv::RNG rng(/*std::time(0)*/0);
+
+const float sigma = 1.f;
+const float pointsMaxX = 500.f;
+const float pointsMaxY = 500.f;
+const int testRun = 5000;
+
+void generatePoints(cv::Mat points);
+void addNoise(cv::Mat points);
+
+cv::Mat generateTransform(const cv::videostab::MotionModel model);
+
+double performTest(const cv::videostab::MotionModel model, int size);
+
+}
+
+void testUtil::generatePoints(cv::Mat points)
+{
+ CV_Assert(!points.empty());
+ for(int i = 0; i < points.cols; ++i)
+ {
+ points.at<float>(0, i) = rng.uniform(0.f, pointsMaxX);
+ points.at<float>(1, i) = rng.uniform(0.f, pointsMaxY);
+ points.at<float>(2, i) = 1.f;
+ }
+}
+
+void testUtil::addNoise(cv::Mat points)
+{
+ CV_Assert(!points.empty());
+ for(int i = 0; i < points.cols; i++)
+ {
+ points.at<float>(0, i) += static_cast<float>(rng.gaussian(sigma));
+ points.at<float>(1, i) += static_cast<float>(rng.gaussian(sigma));
+
+ }
+}
+
+
+cv::Mat testUtil::generateTransform(const cv::videostab::MotionModel model)
+{
+ /*----------Params----------*/
+ const float minAngle = 0.f, maxAngle = static_cast<float>(CV_PI);
+ const float minScale = 0.5f, maxScale = 2.f;
+ const float maxTranslation = 100.f;
+ const float affineCoeff = 3.f;
+ /*----------Params----------*/
+
+ cv::Mat transform = cv::Mat::eye(3, 3, CV_32F);
+
+ if(model != cv::videostab::MM_ROTATION)
+ {
+ transform.at<float>(0,2) = rng.uniform(-maxTranslation, maxTranslation);
+ transform.at<float>(1,2) = rng.uniform(-maxTranslation, maxTranslation);
+ }
+
+ if(model != cv::videostab::MM_AFFINE)
+ {
+
+ if(model != cv::videostab::MM_TRANSLATION_AND_SCALE &&
+ model != cv::videostab::MM_TRANSLATION)
+ {
+ const float angle = rng.uniform(minAngle, maxAngle);
+
+ transform.at<float>(1,1) = transform.at<float>(0,0) = std::cos(angle);
+ transform.at<float>(0,1) = std::sin(angle);
+ transform.at<float>(1,0) = -transform.at<float>(0,1);
+
+ }
+
+ if(model == cv::videostab::MM_TRANSLATION_AND_SCALE ||
+ model == cv::videostab::MM_SIMILARITY)
+ {
+ const float scale = rng.uniform(minScale, maxScale);
+
+ transform.at<float>(0,0) *= scale;
+ transform.at<float>(1,1) *= scale;
+
+ }
+
+ }
+ else
+ {
+ transform.at<float>(0,0) = rng.uniform(-affineCoeff, affineCoeff);
+ transform.at<float>(0,1) = rng.uniform(-affineCoeff, affineCoeff);
+ transform.at<float>(1,0) = rng.uniform(-affineCoeff, affineCoeff);
+ transform.at<float>(1,1) = rng.uniform(-affineCoeff, affineCoeff);
+ }
+
+ return transform;
+}
+
+
+double testUtil::performTest(const cv::videostab::MotionModel model, int size)
+{
+ cv::Ptr<cv::videostab::MotionEstimatorRansacL2> estimator = cv::makePtr<cv::videostab::MotionEstimatorRansacL2>(model);
+
+ estimator->setRansacParams(cv::videostab::RansacParams(size, 3.f*testUtil::sigma /*3 sigma rule*/, 0.5f, 0.5f));
+
+ double disparity = 0.;
+
+ for(int attempt = 0; attempt < testUtil::testRun; attempt++)
+ {
+ const cv::Mat transform = testUtil::generateTransform(model);
+
+ const int pointsNumber = testUtil::rng.uniform(10, 100);
+
+ cv::Mat points(3, pointsNumber, CV_32F);
+
+ testUtil::generatePoints(points);
+
+ cv::Mat transformedPoints = transform * points;
+
+ testUtil::addNoise(transformedPoints);
+
+ const cv::Mat src = points.rowRange(0,2).t();
+ const cv::Mat dst = transformedPoints.rowRange(0,2).t();
+
+ bool isOK = false;
+ const cv::Mat estTransform = estimator->estimate(src.reshape(2), dst.reshape(2), &isOK);
+
+ CV_Assert(isOK);
+ const cv::Mat testPoints = estTransform * points;
+
+ const double norm = cv::norm(testPoints, transformedPoints, cv::NORM_INF);
+
+ disparity = std::max(disparity, norm);
+ }
+
+ return disparity;
+
+}
+
+TEST(Regression, MM_TRANSLATION)
+{
+ EXPECT_LT(testUtil::performTest(cv::videostab::MM_TRANSLATION, 2), 7.f);
+}
+
+TEST(Regression, MM_TRANSLATION_AND_SCALE)
+{
+ EXPECT_LT(testUtil::performTest(cv::videostab::MM_TRANSLATION_AND_SCALE, 3), 7.f);
+}
+
+TEST(Regression, MM_ROTATION)
+{
+ EXPECT_LT(testUtil::performTest(cv::videostab::MM_ROTATION, 2), 7.f);
+}
+
+TEST(Regression, MM_RIGID)
+{
+ EXPECT_LT(testUtil::performTest(cv::videostab::MM_RIGID, 3), 7.f);
+}
+
+TEST(Regression, MM_SIMILARITY)
+{
+ EXPECT_LT(testUtil::performTest(cv::videostab::MM_SIMILARITY, 4), 7.f);
+}
+
+TEST(Regression, MM_AFFINE)
+{
+ EXPECT_LT(testUtil::performTest(cv::videostab::MM_AFFINE, 6), 9.f);
+}
diff --git a/modules/videostab/test/test_precomp.hpp b/modules/videostab/test/test_precomp.hpp
new file mode 100644
index 0000000..c84b5e9
--- /dev/null
+++ b/modules/videostab/test/test_precomp.hpp
@@ -0,0 +1,16 @@
+#ifdef __GNUC__
+# pragma GCC diagnostic ignored "-Wmissing-declarations"
+# if defined __clang__ || defined __APPLE__
+# pragma GCC diagnostic ignored "-Wmissing-prototypes"
+# pragma GCC diagnostic ignored "-Wextra"
+# endif
+#endif
+
+#ifndef __OPENCV_TEST_PRECOMP_HPP__
+#define __OPENCV_TEST_PRECOMP_HPP__
+
+#include <iostream>
+#include "opencv2/ts.hpp"
+#include "opencv2/videostab.hpp"
+
+#endif
diff --git a/modules/viz/CMakeLists.txt b/modules/viz/CMakeLists.txt
index 9fd0301..68bd8d3 100644
--- a/modules/viz/CMakeLists.txt
+++ b/modules/viz/CMakeLists.txt
@@ -2,12 +2,33 @@ if(NOT WITH_VTK OR NOT DEFINED HAVE_VTK OR NOT HAVE_VTK)
ocv_module_disable(viz)
endif()
-include(${VTK_USE_FILE})
set(the_description "Viz")
-ocv_define_module(viz opencv_core ${VTK_LIBRARIES} WRAP python)
+include(${VTK_USE_FILE})
+
+if(NOT BUILD_SHARED_LIBS)
+ # We observed conflict between builtin 3rdparty libraries and
+ # system-wide similar libraries (but with different versions) from VTK dependencies
+ set(_conflicts "")
+ foreach(dep ${VTK_LIBRARIES})
+ if(("${dep}" MATCHES "libz\\." AND BUILD_ZLIB)
+ OR ("${dep}" MATCHES "libjpeg\\." AND BUILD_JPEG)
+ OR ("${dep}" MATCHES "libpng\\." AND BUILD_PNG)
+ OR ("${dep}" MATCHES "libtiff\\." AND BUILD_TIFF)
+ )
+ list(APPEND _conflicts "${dep}")
+ endif()
+ endforeach()
+ if(_conflicts)
+ message(STATUS "Disabling VIZ module due conflicts with VTK dependencies: ${_conflicts}")
+ ocv_module_disable(viz)
+ endif()
+endif()
+
+ocv_define_module(viz opencv_core WRAP python)
+ocv_target_link_libraries(${the_module} ${VTK_LIBRARIES})
if(APPLE AND BUILD_opencv_viz)
- ocv_target_link_libraries(opencv_viz "-framework Cocoa")
+ ocv_target_link_libraries(${the_module} "-framework Cocoa")
endif()
if(TARGET opencv_test_viz)
diff --git a/modules/viz/test/test_precomp.cpp b/modules/viz/test/test_common.cpp
similarity index 100%
rename from modules/viz/test/test_precomp.cpp
rename to modules/viz/test/test_common.cpp
diff --git a/modules/viz/test/test_common.hpp b/modules/viz/test/test_common.hpp
new file mode 100644
index 0000000..87a7d49
--- /dev/null
+++ b/modules/viz/test/test_common.hpp
@@ -0,0 +1,92 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+// Authors:
+// * Ozan Tonkal, ozantonkal at gmail.com
+// * Anatoly Baksheev, Itseez Inc. myname.mysurname <> mycompany.com
+//
+//M*/
+
+#ifndef OPENCV_VIZ_TEST_COMMON_HPP
+#define OPENCV_VIZ_TEST_COMMON_HPP
+
+#include <opencv2/viz/vizcore.hpp>
+
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <limits>
+
+namespace cv
+{
+ struct Path
+ {
+ static String combine(const String& item1, const String& item2);
+ static String combine(const String& item1, const String& item2, const String& item3);
+ static String change_extension(const String& file, const String& ext);
+ };
+
+ inline cv::String get_dragon_ply_file_path()
+ {
+ return Path::combine(cvtest::TS::ptr()->get_data_path(), "dragon.ply");
+ }
+
+ template<typename _Tp>
+ inline std::vector< Affine3<_Tp> > generate_test_trajectory()
+ {
+ std::vector< Affine3<_Tp> > result;
+
+ for (int i = 0, j = 0; i <= 270; i += 3, j += 10)
+ {
+ double x = 2 * cos(i * 3 * CV_PI/180.0) * (1.0 + 0.5 * cos(1.2 + i * 1.2 * CV_PI/180.0));
+ double y = 0.25 + i/270.0 + sin(j * CV_PI/180.0) * 0.2 * sin(0.6 + j * 1.5 * CV_PI/180.0);
+ double z = 2 * sin(i * 3 * CV_PI/180.0) * (1.0 + 0.5 * cos(1.2 + i * CV_PI/180.0));
+ result.push_back(viz::makeCameraPose(Vec3d(x, y, z), Vec3d::all(0.0), Vec3d(0.0, 1.0, 0.0)));
+ }
+ return result;
+ }
+
+ inline Mat make_gray(const Mat& image)
+ {
+ Mat chs[3]; split(image, chs);
+ return 0.114 * chs[0] + 0.58 * chs[1] + 0.3 * chs[2];
+ }
+}
+
+#endif
diff --git a/modules/viz/test/test_precomp.hpp b/modules/viz/test/test_precomp.hpp
index 05914e2..d2b33a5 100644
--- a/modules/viz/test/test_precomp.hpp
+++ b/modules/viz/test/test_precomp.hpp
@@ -1,112 +1,2 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of the copyright holders may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-// Authors:
-// * Ozan Tonkal, ozantonkal at gmail.com
-// * Anatoly Baksheev, Itseez Inc. myname.mysurname <> mycompany.com
-//
-//M*/
-
-#ifdef __GNUC__
-# pragma GCC diagnostic ignored "-Wmissing-declarations"
-# if defined __clang__ || defined __APPLE__
-# pragma GCC diagnostic ignored "-Wmissing-prototypes"
-# pragma GCC diagnostic ignored "-Wextra"
-# endif
-#endif
-
-#ifndef __OPENCV_TEST_PRECOMP_HPP__
-#define __OPENCV_TEST_PRECOMP_HPP__
-
-#include <opencv2/core/version.hpp>
-#include <opencv2/viz/vizcore.hpp>
-
-namespace cv
-{
- Mat imread(const String& filename, int flags = 1);
-}
-
-#if CV_MAJOR_VERSION < 3
- #include "opencv2/ts/ts.hpp"
-#else
- #include "opencv2/ts.hpp"
-#endif
-
-#include <iostream>
-#include <fstream>
-#include <string>
-#include <limits>
-
-namespace cv
-{
- struct Path
- {
- static String combine(const String& item1, const String& item2);
- static String combine(const String& item1, const String& item2, const String& item3);
- static String change_extension(const String& file, const String& ext);
- };
-
- inline cv::String get_dragon_ply_file_path()
- {
- return Path::combine(cvtest::TS::ptr()->get_data_path(), "dragon.ply");
- }
-
- template<typename _Tp>
- inline std::vector< Affine3<_Tp> > generate_test_trajectory()
- {
- std::vector< Affine3<_Tp> > result;
-
- for (int i = 0, j = 0; i <= 270; i += 3, j += 10)
- {
- double x = 2 * cos(i * 3 * CV_PI/180.0) * (1.0 + 0.5 * cos(1.2 + i * 1.2 * CV_PI/180.0));
- double y = 0.25 + i/270.0 + sin(j * CV_PI/180.0) * 0.2 * sin(0.6 + j * 1.5 * CV_PI/180.0);
- double z = 2 * sin(i * 3 * CV_PI/180.0) * (1.0 + 0.5 * cos(1.2 + i * CV_PI/180.0));
- result.push_back(viz::makeCameraPose(Vec3d(x, y, z), Vec3d::all(0.0), Vec3d(0.0, 1.0, 0.0)));
- }
- return result;
- }
-
- inline Mat make_gray(const Mat& image)
- {
- Mat chs[3]; split(image, chs);
- return 0.114 * chs[0] + 0.58 * chs[1] + 0.3 * chs[2];
- }
-}
-
-#endif
+#include "opencv2/ts.hpp"
+#include "test_common.hpp"
diff --git a/modules/viz/test/test_tutorial2.cpp b/modules/viz/test/test_tutorial2.cpp
index a901adc..6c5cecc 100644
--- a/modules/viz/test/test_tutorial2.cpp
+++ b/modules/viz/test/test_tutorial2.cpp
@@ -3,7 +3,7 @@
using namespace cv;
using namespace std;
-void tutorial2()
+static void tutorial2()
{
/// Create a window
viz::Viz3d myWindow("Coordinate Frame");
diff --git a/modules/viz/test/test_tutorial3.cpp b/modules/viz/test/test_tutorial3.cpp
index b20e8d7..8ee042f 100644
--- a/modules/viz/test/test_tutorial3.cpp
+++ b/modules/viz/test/test_tutorial3.cpp
@@ -6,7 +6,7 @@ using namespace std;
/**
* @function main
*/
-void tutorial3(bool camera_pov)
+static void tutorial3(bool camera_pov)
{
/// Create a window
viz::Viz3d myWindow("Coordinate Frame");
diff --git a/modules/world/CMakeLists.txt b/modules/world/CMakeLists.txt
index db8928d..96d12f8 100644
--- a/modules/world/CMakeLists.txt
+++ b/modules/world/CMakeLists.txt
@@ -1,8 +1,8 @@
-set(the_description "All the selected OpenCV modules in a single binary")
+set(the_description "All OpenCV modules")
set(OPENCV_MODULE_IS_PART_OF_WORLD FALSE)
set(BUILD_opencv_world_INIT OFF)
-if(APPLE_FRAMEWORK OR NOT BUILD_SHARED_LIBS)
+if(NOT BUILD_SHARED_LIBS)
set(OPENCV_MODULE_TYPE STATIC)
set(OPENCV_WORLD_FLAGS_PROPERTY STATIC_LIBRARY_FLAGS)
else()
@@ -11,6 +11,11 @@ endif()
function(include_one_module m)
include("${OPENCV_MODULE_${m}_LOCATION}/CMakeLists.txt")
+ foreach(var
+ CMAKE_CXX_FLAGS CMAKE_C_FLAGS # Propagate warnings settings
+ )
+ set(${var} "${${var}}" PARENT_SCOPE)
+ endforeach()
endfunction()
if(NOT OPENCV_INITIAL_PASS)
@@ -19,6 +24,7 @@ if(NOT OPENCV_INITIAL_PASS)
message(STATUS "Processing WORLD modules...")
foreach(m ${OPENCV_MODULES_BUILD})
+ set(the_module ${m})
if(OPENCV_MODULE_${m}_IS_PART_OF_WORLD)
message(STATUS " module ${m}...")
set(CMAKE_CURRENT_SOURCE_DIR "${OPENCV_MODULE_${m}_LOCATION}")
@@ -35,12 +41,14 @@ ocv_add_module(world opencv_core)
set(headers_list "HEADERS")
set(sources_list "SOURCES")
set(link_deps "")
-foreach(m ${OPENCV_MODULE_${the_module}_DEPS})
+foreach(m ${OPENCV_MODULE_${the_module}_DEPS} opencv_world)
if(OPENCV_MODULE_${m}_IS_PART_OF_WORLD)
set(headers_list "${headers_list};${OPENCV_MODULE_${m}_HEADERS}")
set(sources_list "${sources_list};${OPENCV_MODULE_${m}_SOURCES}")
endif()
- set(link_deps "${link_deps};${OPENCV_MODULE_${m}_LINK_DEPS}")
+ if(NOT " ${OPENCV_MODULE_${m}_LINK_DEPS}" STREQUAL " ")
+ list(APPEND link_deps ${OPENCV_MODULE_${m}_LINK_DEPS})
+ endif()
endforeach()
ocv_glob_module_sources(${headers_list} ${sources_list})
diff --git a/platforms/android/README.android b/platforms/android/README.android
index 564fc3a..c572577 100644
--- a/platforms/android/README.android
+++ b/platforms/android/README.android
@@ -1 +1 @@
-See http://opencv.org/platforms/android.html
+See http://opencv.org/platforms/android
diff --git a/platforms/android/android.toolchain.cmake b/platforms/android/android.toolchain.cmake
index 1d69b75..6d64f92 100644
--- a/platforms/android/android.toolchain.cmake
+++ b/platforms/android/android.toolchain.cmake
@@ -1150,8 +1150,10 @@ if( APPLE )
endif()
# Force set compilers because standard identification works badly for us
-include( CMakeForceCompiler )
-CMAKE_FORCE_C_COMPILER( "${CMAKE_C_COMPILER}" GNU )
+if( CMAKE_VERSION VERSION_LESS 3.5.0 )
+ include( CMakeForceCompiler )
+ CMAKE_FORCE_C_COMPILER( "${CMAKE_C_COMPILER}" GNU )
+endif()
if( ANDROID_COMPILER_IS_CLANG )
set( CMAKE_C_COMPILER_ID Clang )
endif()
@@ -1163,7 +1165,9 @@ else()
endif()
set( CMAKE_C_HAS_ISYSROOT 1 )
set( CMAKE_C_COMPILER_ABI ELF )
-CMAKE_FORCE_CXX_COMPILER( "${CMAKE_CXX_COMPILER}" GNU )
+if( CMAKE_VERSION VERSION_LESS 3.5.0 )
+ CMAKE_FORCE_CXX_COMPILER( "${CMAKE_CXX_COMPILER}" GNU )
+endif()
if( ANDROID_COMPILER_IS_CLANG )
set( CMAKE_CXX_COMPILER_ID Clang)
endif()
diff --git a/platforms/android/build-tests/test_ndk_build.py b/platforms/android/build-tests/test_ndk_build.py
index 60b76e7..cbc2b7c 100644
--- a/platforms/android/build-tests/test_ndk_build.py
+++ b/platforms/android/build-tests/test_ndk_build.py
@@ -73,12 +73,12 @@ class TestNDKBuild(unittest.TestCase):
p = []
if self.libtype == "static":
p.append("OPENCV_LIB_TYPE := STATIC")
- elif self.libtype == "shared_debug":
+ elif self.libtype == "shared":
p.append("OPENCV_LIB_TYPE := SHARED")
- p.append("OPENCV_CAMERA_MODULES:=on")
p.append("OPENCV_INSTALL_MODULES:=on")
- elif self.libtype == "shared":
+ elif self.libtype == "shared_opencv_manager":
p.append("OPENCV_LIB_TYPE := SHARED")
+ p.append("OPENCV_INSTALL_MODULES:=off")
p.append("include %s" % os.path.join(self.opencv_mk_path, "OpenCV.mk"))
return TEMPLATE_ANDROID_MK.format(cut = "\n".join(p), cpp1 = self.cpp1, cpp2 = self.cpp2)
@@ -115,14 +115,17 @@ class TestNDKBuild(unittest.TestCase):
def suite(workdir, opencv_mk_path):
abis = ["armeabi", "armeabi-v7a", "x86", "mips"]
ndk_path = os.environ["ANDROID_NDK"]
- with open(os.path.join(ndk_path, "RELEASE.TXT"), "r") as f:
- s = f.read()
- if re.search(r'r10[b-e]', s):
- abis.extend(["arm64-v8a", "x86", "x86_64"])
+ if os.path.exists(os.path.join(ndk_path, "RELEASE.TXT")):
+ with open(os.path.join(ndk_path, "RELEASE.TXT"), "r") as f:
+ s = f.read()
+ if re.search(r'r10[b-e]', s):
+ abis.extend(["arm64-v8a", "x86_64"])
+ if os.path.exists(os.path.join(ndk_path, "source.properties")): # Android NDK 11+
+ abis.extend(["arm64-v8a", "x86_64"])
abis.append("all")
suite = unittest.TestSuite()
- for libtype in ["static", "shared", "shared_debug"]:
+ for libtype in ["static", "shared", "shared_opencv_manager"]:
for abi in abis:
suite.addTest(TestNDKBuild(abi, libtype, opencv_mk_path, workdir))
return suite
diff --git a/platforms/android/build_sdk.py b/platforms/android/build_sdk.py
index e78e3b9..a96ee84 100755
--- a/platforms/android/build_sdk.py
+++ b/platforms/android/build_sdk.py
@@ -171,7 +171,7 @@ class Builder:
# Add extra data
apkxmldest = check_dir(os.path.join(apkdest, "res", "xml"), create=True)
apklibdest = check_dir(os.path.join(apkdest, "libs", abi.name), create=True)
- for ver, d in self.extra_packs + [("3.2.0", os.path.join(self.libdest, "lib"))]:
+ for ver, d in self.extra_packs + [("3.3.0", os.path.join(self.libdest, "lib"))]:
r = ET.Element("library", attrib={"version": ver})
log.info("Adding libraries from %s", d)
diff --git a/platforms/android/service/engine/AndroidManifest.xml b/platforms/android/service/engine/AndroidManifest.xml
index 6c90858..7a52ecc 100644
--- a/platforms/android/service/engine/AndroidManifest.xml
+++ b/platforms/android/service/engine/AndroidManifest.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.opencv.engine"
- android:versionCode="320 at ANDROID_PLATFORM_ID@"
- android:versionName="3.20">
+ android:versionCode="330 at ANDROID_PLATFORM_ID@"
+ android:versionName="3.30">
<uses-sdk android:minSdkVersion="@ANDROID_NATIVE_API_LEVEL@" android:targetSdkVersion="22"/>
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
diff --git a/platforms/android/service/engine/src/org/opencv/engine/OpenCVEngineService.java b/platforms/android/service/engine/src/org/opencv/engine/OpenCVEngineService.java
index c604fa9..5283cc2 100644
--- a/platforms/android/service/engine/src/org/opencv/engine/OpenCVEngineService.java
+++ b/platforms/android/service/engine/src/org/opencv/engine/OpenCVEngineService.java
@@ -134,7 +134,7 @@ public class OpenCVEngineService extends Service {
@Override
public int getEngineVersion() throws RemoteException {
- int version = 3200;
+ int version = 3300;
try {
version = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
} catch (NameNotFoundException e) {
diff --git a/platforms/android/service/readme.txt b/platforms/android/service/readme.txt
index f7e886a..88ee35e 100644
--- a/platforms/android/service/readme.txt
+++ b/platforms/android/service/readme.txt
@@ -12,7 +12,7 @@ manually using adb tool:
adb install <path-to-OpenCV-sdk>/apk/OpenCV_<version>_Manager_<app_version>_<platform>.apk
-Example: OpenCV_3.2.0-dev_Manager_3.20_armeabi-v7a.apk
+Example: OpenCV_3.3.0-dev_Manager_3.30_armeabi-v7a.apk
Use the list of platforms below to determine proper OpenCV Manager package for your device:
diff --git a/platforms/ios/Info.Dynamic.plist.in b/platforms/ios/Info.Dynamic.plist.in
new file mode 100644
index 0000000..4ff68cc
--- /dev/null
+++ b/platforms/ios/Info.Dynamic.plist.in
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleExecutable</key>
+ <string>opencv2</string>
+ <key>CFBundleName</key>
+ <string>${OPENCV_APPLE_BUNDLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>${OPENCV_APPLE_BUNDLE_ID}</string>
+ <key>CFBundleVersion</key>
+ <string>${OPENCV_LIBVERSION}</string>
+ <key>CFBundleShortVersionString</key>
+ <string>${OPENCV_LIBVERSION}</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundlePackageType</key>
+ <string>FMWK</string>
+ <key>CFBundleSupportedPlatforms</key>
+ <array>
+ <string>iPhoneOS</string>
+ </array>
+ <key>MinimumOSVersion</key>
+ <string>8.0</string>
+</dict>
+</plist>
\ No newline at end of file
diff --git a/platforms/ios/build_framework.py b/platforms/ios/build_framework.py
index f8886b6..78d9ec6 100644
--- a/platforms/ios/build_framework.py
+++ b/platforms/ios/build_framework.py
@@ -23,10 +23,12 @@ Script will create <outputdir>, if it's missing, and a few its subdirectories:
The script should handle minor OpenCV updates efficiently
- it does not recompile the library from scratch each time.
However, opencv2.framework directory is erased and recreated on each run.
+
+Adding --dynamic parameter will build opencv2.framework as App Store dynamic framework. Only iOS 8+ versions are supported.
"""
from __future__ import print_function
-import glob, re, os, os.path, shutil, string, sys, argparse, traceback
+import glob, re, os, os.path, shutil, string, sys, argparse, traceback, multiprocessing
from subprocess import check_call, check_output, CalledProcessError
def execute(cmd, cwd = None):
@@ -43,7 +45,7 @@ def getXCodeMajor():
return 0
class Builder:
- def __init__(self, opencv, contrib, exclude, targets):
+ def __init__(self, opencv, contrib, dynamic, bitcodedisabled, exclude, targets):
self.opencv = os.path.abspath(opencv)
self.contrib = None
if contrib:
@@ -52,11 +54,18 @@ class Builder:
self.contrib = os.path.abspath(modpath)
else:
print("Note: contrib repository is bad - modules subfolder not found", file=sys.stderr)
+ self.dynamic = dynamic
+ self.bitcodedisabled = bitcodedisabled
self.exclude = exclude
self.targets = targets
def getBD(self, parent, t):
- res = os.path.join(parent, '%s-%s' % t)
+
+ if len(t[0]) == 1:
+ res = os.path.join(parent, 'build-%s-%s' % (t[0][0].lower(), t[1].lower()))
+ else:
+ res = os.path.join(parent, 'build-%s' % t[1].lower())
+
if not os.path.isdir(res):
os.makedirs(res)
return os.path.abspath(res)
@@ -70,17 +79,32 @@ class Builder:
xcode_ver = getXCodeMajor()
- for t in self.targets:
+ if self.dynamic:
+ alltargets = self.targets
+ else:
+ # if we are building a static library, we must build each architecture separately
+ alltargets = []
+
+ for t in self.targets:
+ for at in t[0]:
+ current = ( [at], t[1] )
+
+ alltargets.append(current)
+
+ for t in alltargets:
mainBD = self.getBD(mainWD, t)
dirs.append(mainBD)
+
cmake_flags = []
if self.contrib:
cmake_flags.append("-DOPENCV_EXTRA_MODULES_PATH=%s" % self.contrib)
- if xcode_ver >= 7 and t[1] == 'iPhoneOS':
+ if xcode_ver >= 7 and t[1] == 'iPhoneOS' and self.bitcodedisabled == False:
cmake_flags.append("-DCMAKE_C_FLAGS=-fembed-bitcode")
cmake_flags.append("-DCMAKE_CXX_FLAGS=-fembed-bitcode")
self.buildOne(t[0], t[1], mainBD, cmake_flags)
- self.mergeLibs(mainBD)
+
+ if self.dynamic == False:
+ self.mergeLibs(mainBD)
self.makeFramework(outdir, dirs)
def build(self, outdir):
@@ -97,30 +121,54 @@ class Builder:
return None
def getCMakeArgs(self, arch, target):
+
args = [
"cmake",
"-GXcode",
"-DAPPLE_FRAMEWORK=ON",
"-DCMAKE_INSTALL_PREFIX=install",
"-DCMAKE_BUILD_TYPE=Release",
- ]
+ ] + ([
+ "-DBUILD_SHARED_LIBS=ON",
+ "-DCMAKE_MACOSX_BUNDLE=ON",
+ "-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=NO",
+ ] if self.dynamic else [])
if len(self.exclude) > 0:
- args += ["-DBUILD_opencv_world=OFF"]
- args += ("-DBUILD_opencv_%s=OFF" % m for m in self.exclude)
+ args += ["-DBUILD_opencv_world=OFF"] if not self.dynamic else []
+ args += ["-DBUILD_opencv_%s=OFF" % m for m in self.exclude]
return args
- def getBuildCommand(self, arch, target):
+ def getBuildCommand(self, archs, target):
+
buildcmd = [
"xcodebuild",
- "IPHONEOS_DEPLOYMENT_TARGET=6.0",
- "ARCHS=%s" % arch,
- "-sdk", target.lower(),
- "-configuration", "Release",
- "-parallelizeTargets",
- "-jobs", "4"
]
+
+ if self.dynamic:
+ buildcmd += [
+ "IPHONEOS_DEPLOYMENT_TARGET=8.0",
+ "ONLY_ACTIVE_ARCH=NO",
+ ]
+
+ for arch in archs:
+ buildcmd.append("-arch")
+ buildcmd.append(arch.lower())
+ else:
+ arch = ";".join(archs)
+ buildcmd += [
+ "IPHONEOS_DEPLOYMENT_TARGET=6.0",
+ "ARCHS=%s" % arch,
+ ]
+
+ buildcmd += [
+ "-sdk", target.lower(),
+ "-configuration", "Release",
+ "-parallelizeTargets",
+ "-jobs", str(multiprocessing.cpu_count()),
+ ] + (["-target","ALL_BUILD"] if self.dynamic else [])
+
return buildcmd
def getInfoPlist(self, builddirs):
@@ -131,11 +179,12 @@ class Builder:
toolchain = self.getToolchain(arch, target)
cmakecmd = self.getCMakeArgs(arch, target) + \
(["-DCMAKE_TOOLCHAIN_FILE=%s" % toolchain] if toolchain is not None else [])
- if arch.startswith("armv") or arch.startswith("arm64"):
+ if target.lower().startswith("iphoneos"):
cmakecmd.append("-DENABLE_NEON=ON")
cmakecmd.append(self.opencv)
cmakecmd.extend(cmakeargs)
execute(cmakecmd, cwd = builddir)
+
# Clean and build
clean_dir = os.path.join(builddir, "install")
if os.path.isdir(clean_dir):
@@ -153,7 +202,6 @@ class Builder:
def makeFramework(self, outdir, builddirs):
name = "opencv2"
- libname = "libopencv_merged.a"
# set the current dir to the dst root
framework_dir = os.path.join(outdir, "%s.framework" % name)
@@ -161,7 +209,12 @@ class Builder:
shutil.rmtree(framework_dir)
os.makedirs(framework_dir)
- dstdir = os.path.join(framework_dir, "Versions", "A")
+ if self.dynamic:
+ dstdir = framework_dir
+ libname = "opencv2.framework/opencv2"
+ else:
+ dstdir = os.path.join(framework_dir, "Versions", "A")
+ libname = "libopencv_merged.a"
# copy headers from one of build folders
shutil.copytree(os.path.join(builddirs[0], "install", "include", "opencv2"), os.path.join(dstdir, "Headers"))
@@ -174,22 +227,27 @@ class Builder:
print("Creating universal library from:\n\t%s" % "\n\t".join(libs), file=sys.stderr)
execute(lipocmd)
- # copy Info.plist
- resdir = os.path.join(dstdir, "Resources")
- os.makedirs(resdir)
- shutil.copyfile(self.getInfoPlist(builddirs), os.path.join(resdir, "Info.plist"))
-
- # make symbolic links
- links = [
- (["A"], ["Versions", "Current"]),
- (["Versions", "Current", "Headers"], ["Headers"]),
- (["Versions", "Current", "Resources"], ["Resources"]),
- (["Versions", "Current", name], [name])
- ]
- for l in links:
- s = os.path.join(*l[0])
- d = os.path.join(framework_dir, *l[1])
- os.symlink(s, d)
+ # dynamic framework has different structure, just copy the Plist directly
+ if self.dynamic:
+ resdir = dstdir
+ shutil.copyfile(self.getInfoPlist(builddirs), os.path.join(resdir, "Info.plist"))
+ else:
+ # copy Info.plist
+ resdir = os.path.join(dstdir, "Resources")
+ os.makedirs(resdir)
+ shutil.copyfile(self.getInfoPlist(builddirs), os.path.join(resdir, "Info.plist"))
+
+ # make symbolic links
+ links = [
+ (["A"], ["Versions", "Current"]),
+ (["Versions", "Current", "Headers"], ["Headers"]),
+ (["Versions", "Current", "Resources"], ["Resources"]),
+ (["Versions", "Current", name], [name])
+ ]
+ for l in links:
+ s = os.path.join(*l[0])
+ d = os.path.join(framework_dir, *l[1])
+ os.symlink(s, d)
class iOSBuilder(Builder):
@@ -198,6 +256,8 @@ class iOSBuilder(Builder):
return toolchain
def getCMakeArgs(self, arch, target):
+ arch = ";".join(arch)
+
args = Builder.getCMakeArgs(self, arch, target)
args = args + [
'-DIOS_ARCH=%s' % arch
@@ -212,18 +272,16 @@ if __name__ == "__main__":
parser.add_argument('--opencv', metavar='DIR', default=folder, help='folder with opencv repository (default is "../.." relative to script location)')
parser.add_argument('--contrib', metavar='DIR', default=None, help='folder with opencv_contrib repository (default is "None" - build only main framework)')
parser.add_argument('--without', metavar='MODULE', default=[], action='append', help='OpenCV modules to exclude from the framework')
+ parser.add_argument('--dynamic', default=False, action='store_true', help='build dynamic framework (default is "False" - builds static framework)')
+ parser.add_argument('--disable-bitcode', default=False, dest='bitcodedisabled', action='store_true', help='disable bitcode (enabled by default)')
args = parser.parse_args()
- b = iOSBuilder(args.opencv, args.contrib, args.without,
+ b = iOSBuilder(args.opencv, args.contrib, args.dynamic, args.bitcodedisabled, args.without,
[
- ("armv7", "iPhoneOS"),
- ("arm64", "iPhoneOS"),
+ (["armv7", "arm64"], "iPhoneOS"),
] if os.environ.get('BUILD_PRECOMMIT', None) else
[
- ("armv7", "iPhoneOS"),
- ("armv7s", "iPhoneOS"),
- ("arm64", "iPhoneOS"),
- ("i386", "iPhoneSimulator"),
- ("x86_64", "iPhoneSimulator"),
+ (["armv7", "armv7s", "arm64"], "iPhoneOS"),
+ (["i386", "x86_64"], "iPhoneSimulator"),
])
b.build(args.out)
diff --git a/platforms/ios/cmake/Modules/Platform/iOS.cmake b/platforms/ios/cmake/Modules/Platform/iOS.cmake
index 63cf1d8..6915adf 100644
--- a/platforms/ios/cmake/Modules/Platform/iOS.cmake
+++ b/platforms/ios/cmake/Modules/Platform/iOS.cmake
@@ -38,6 +38,14 @@ set (CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
set (CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
set (CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
+# Additional flags for dynamic framework
+if (APPLE_FRAMEWORK AND BUILD_SHARED_LIBS)
+ set (CMAKE_MODULE_LINKER_FLAGS "-rpath @executable_path/Frameworks -rpath @loader_path/Frameworks")
+ set (CMAKE_SHARED_LINKER_FLAGS "-rpath @executable_path/Frameworks -rpath @loader_path/Frameworks")
+ set (CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG 1)
+ set (CMAKE_INSTALL_NAME_DIR "@rpath")
+endif()
+
# Hidden visibilty is required for cxx on iOS
set (no_warn "-Wno-unused-function -Wno-overloaded-virtual")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${no_warn}")
@@ -144,7 +152,6 @@ set (CMAKE_C_CREATE_MACOSX_FRAMEWORK
set (CMAKE_CXX_CREATE_MACOSX_FRAMEWORK
"<CMAKE_CXX_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <LINK_FLAGS> -o <TARGET> -install_name <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>")
-
# Add the install directory of the running cmake to the search directories
# CMAKE_ROOT is CMAKE_INSTALL_PREFIX/share/cmake, so we need to go two levels up
get_filename_component (_CMAKE_INSTALL_DIR "${CMAKE_ROOT}" PATH)
diff --git a/platforms/ios/cmake/Toolchains/common-ios-toolchain.cmake b/platforms/ios/cmake/Toolchains/common-ios-toolchain.cmake
index 24dab91..44ad57c 100644
--- a/platforms/ios/cmake/Toolchains/common-ios-toolchain.cmake
+++ b/platforms/ios/cmake/Toolchains/common-ios-toolchain.cmake
@@ -86,24 +86,52 @@ endif()
set(CMAKE_MACOSX_BUNDLE YES)
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
-set(CMAKE_OSX_ARCHITECTURES "${IOS_ARCH}" CACHE INTERNAL "Build architecture for iOS" FORCE)
+if(APPLE_FRAMEWORK AND NOT BUILD_SHARED_LIBS)
+ set(CMAKE_OSX_ARCHITECTURES "${IOS_ARCH}" CACHE INTERNAL "Build architecture for iOS" FORCE)
+endif()
if(NOT __IN_TRY_COMPILE)
set(_xcodebuild_wrapper "${CMAKE_BINARY_DIR}/xcodebuild_wrapper")
if(NOT CMAKE_MAKE_PROGRAM STREQUAL _xcodebuild_wrapper)
- set(_xcodebuild_wrapper_tmp "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/xcodebuild_wrapper")
- file(WRITE "${_xcodebuild_wrapper_tmp}" "#!/bin/sh
+ if(APPLE_FRAMEWORK AND BUILD_SHARED_LIBS)
+ set(_xcodebuild_wrapper_tmp "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/xcodebuild_wrapper")
+ file(WRITE "${_xcodebuild_wrapper_tmp}" "#!/bin/sh
+${CMAKE_MAKE_PROGRAM} IPHONEOS_DEPLOYMENT_TARGET=8.0 -sdk ${CMAKE_OSX_SYSROOT} \$*")
+ # Make executable
+ file(COPY "${_xcodebuild_wrapper_tmp}" DESTINATION ${CMAKE_BINARY_DIR} FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+ set(CMAKE_MAKE_PROGRAM "${_xcodebuild_wrapper}" CACHE INTERNAL "" FORCE)
+ else()
+ set(_xcodebuild_wrapper_tmp "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/xcodebuild_wrapper")
+ file(WRITE "${_xcodebuild_wrapper_tmp}" "#!/bin/sh
${CMAKE_MAKE_PROGRAM} IPHONEOS_DEPLOYMENT_TARGET=6.0 ARCHS=${IOS_ARCH} -sdk ${CMAKE_OSX_SYSROOT} \$*")
- # Make executable
- file(COPY "${_xcodebuild_wrapper_tmp}" DESTINATION ${CMAKE_BINARY_DIR} FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
- set(CMAKE_MAKE_PROGRAM "${_xcodebuild_wrapper}" CACHE INTERNAL "" FORCE)
+ # Make executable
+ file(COPY "${_xcodebuild_wrapper_tmp}" DESTINATION ${CMAKE_BINARY_DIR} FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+ set(CMAKE_MAKE_PROGRAM "${_xcodebuild_wrapper}" CACHE INTERNAL "" FORCE)
+ endif()
endif()
endif()
# Standard settings
set(CMAKE_SYSTEM_NAME iOS)
-set(CMAKE_SYSTEM_VERSION 6.0)
-set(CMAKE_SYSTEM_PROCESSOR "${IOS_ARCH}")
+
+# Apple Framework settings
+if(APPLE_FRAMEWORK AND BUILD_SHARED_LIBS)
+ set(CMAKE_SYSTEM_VERSION 8.0)
+ set(CMAKE_C_SIZEOF_DATA_PTR 4)
+ set(CMAKE_CXX_SIZEOF_DATA_PTR 4)
+else()
+ set(CMAKE_SYSTEM_VERSION 6.0)
+ set(CMAKE_SYSTEM_PROCESSOR "${IOS_ARCH}")
+
+ if(AARCH64 OR X86_64)
+ set(CMAKE_C_SIZEOF_DATA_PTR 8)
+ set(CMAKE_CXX_SIZEOF_DATA_PTR 8)
+ else()
+ set(CMAKE_C_SIZEOF_DATA_PTR 4)
+ set(CMAKE_CXX_SIZEOF_DATA_PTR 4)
+ endif()
+endif()
+
# Include extra modules for the iOS platform files
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/platforms/ios/cmake/Modules")
@@ -112,13 +140,6 @@ include(CMakeForceCompiler)
#CMAKE_FORCE_C_COMPILER (clang GNU)
#CMAKE_FORCE_CXX_COMPILER (clang++ GNU)
-if(AARCH64 OR X86_64)
- set(CMAKE_C_SIZEOF_DATA_PTR 8)
- set(CMAKE_CXX_SIZEOF_DATA_PTR 8)
-else()
- set(CMAKE_C_SIZEOF_DATA_PTR 4)
- set(CMAKE_CXX_SIZEOF_DATA_PTR 4)
-endif()
set(CMAKE_C_HAS_ISYSROOT 1)
set(CMAKE_CXX_HAS_ISYSROOT 1)
set(CMAKE_C_COMPILER_ABI ELF)
@@ -134,4 +155,4 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
-toolchain_save_config(IOS_ARCH)
+toolchain_save_config(IOS_ARCH)
\ No newline at end of file
diff --git a/platforms/maven/README.md b/platforms/maven/README.md
index 54f151a..30a6c6a 100644
--- a/platforms/maven/README.md
+++ b/platforms/maven/README.md
@@ -4,16 +4,24 @@ This page describes the how to build OpenCV using [Apache Maven](http://maven.ap
The following assumes building on Debian-based Linux platform.
-## Overview
+## 1 - Overview
The Maven build process aims to:
1. Provide a simpler route to build OpenCV and Java bundles.
2. Automatically check the required native dependencies.
3. Make the Java libraries OSGi compatible.
4. Include the native OpenCV native library inside the Java bundle.
- 5. Allow the build to function on x86, x86_64 or amd architectures, Debian-based Linux platform.
+ 5. Integration testing of the bundle within an OSGi environment.
+ 6. Allow the build to function on x86, x86_64 or amd architectures, Debian-based Linux platform.
-### Starting the build
-#### Environment variables
+### 2 - Preparing The Build environment
+To build using the Maven build process both `Maven` and and up-to-date `JDK` (Java Development Kit) need to be installed. If you know you already have these installed then continue to `Environment Variable` otherwise the easiest solution is to install them using the aptitude package manager:
+
+`sudo aptitude install maven default-jdk`
+
+Note that installing via `aptitude` you are unlikely to get the latest version of Maven or JDK although if you are not developing Java code this shouldn't matter for this build process.
+
+### 3 - Starting the build
+#### 3.1 - Environment variables
**Applicability:** All processors.
The following environment variables must be set otherwise the build will fail and halt:
@@ -28,37 +36,36 @@ It is recommended that advantage is taken of multiple processor cores to reduce
However if this flag is not set the build will NOT fail. On a RaspberryPi 2 typical build times are 5 hours with `-j1` (which is the default if `$MAKEFLAGS` is not specified) and a little over 2 hours with `-j4`.
All of the above environment variables can be set on an ad-hoc basis using 'export'.
-#### Build Directory
+#### 3.2 - Build Directory
**Applicability:** All processors
By default the following build directories are created.
`<OpenCV_root_dir>/build`
-`<OpenCV_root_dir>/build/target`
+`<OpenCV_root_dir>/build/maven/opencv/target`
-Under `build` are the standard OpenCV artifacts. Under `build/target` can be found the OSGi compatible Java bundle. When deploying the bundle into an OSGi framework e.g. [Apache Karaf](http://karaf.apache.org/), loading of the native library is automatically taken care of. The standard Java library as created by the CMake process is also available as specified in the existing OpenCV documentation.
+`<OpenCV_root_dir>/build/maven/opencv-it/target`
+
+Under `build` are the standard OpenCV artifacts. Under `build/maven/opencv/target` can be found the OSGi compatible Java bundle. When deploying the bundle into an OSGi framework e.g. [Apache Karaf](http://karaf.apache.org/), loading of the native library is automatically taken care of. An integration testing module is created under the `open-cv` directory and is only of use during the build. The standard Java library as created by the CMake process is also available as specified in the e [...]
The Maven build is initiated from the directory contain the `pom.xml` file.
-#### x86 or x86_64 Architecture:
+#### 3.3 - x86 or x86_64 Architecture:
Generally all that is required is the standard Maven command:
-`mvn clean install`
+`mvn clean install -Ddownload.cmake=false`
One of the first things the build will do is check the required native dependencies. The Maven build indicates the status of the required dependencies and will fail at this point if any are missing. Install using the package manager e.g. aptitude or apt-get, and restart the build with the above command.
Once the build succesfully completes the OSGi compatible artifacts are available as described above in 'Build Directory'.
-#### ARM 32-bit Architecture - Raspbian Distribution
+#### 3.4 - ARM 32-bit Architecture - Raspbian Distribution
Similar to the x86 architecture the native dependencies are first checked so install any that are missing, however at the time of writing there are no official `libtbb2` and `libtbb-dev` packages in Raspbian. Version 4.4.3 of Intel's Thread Building Blocks library are available [here](http://www.javatechnics.com/thread-building-blocks-tbb-4-4-3-for-raspbian) as a Raspbian-compatible Debian packages.
**PLEASE NOTE THESE ARE NOT OFFICIAL RASPBIAN PACKAGES. INSTALL AT YOUR OWN RISK.**
OpenCV is built using CMake and the Maven build process uses the the [cmake-maven plugin](https://github.com/cmake-maven-project/cmake-maven-project). The cmake-maven plugin by default downloads CMake at build time but unfortunately there is no binary for ARM architecture currently available. As a work around it is possible to use the native CMake (which is checked for availability in the above dependency checks). Assuming all native dependencies are available the build can be started wi [...]
-`mvn clean install -Duse.native.cmake=true`
+`mvn clean install -Ddownload.cmake=false`
Upon a successful build the libraries will be available as described above in 'Build Directory'.
-
-#### cmake-mave-plugin 3.4.1-b2-SNAPSHOT
-Should this plugin not be available in Maven central, the source can be found at my GitHub page [here](https://github.com/jtkb/cmake-maven-project), checkout the `raspberrypi` branch and install. On x86 it is a standard Maven build and install command. If building on Raspbian you also need to supply the `-Duse.native.cmake=true` command-line option.
diff --git a/platforms/maven/opencv-it/pom.xml b/platforms/maven/opencv-it/pom.xml
new file mode 100644
index 0000000..c1522a2
--- /dev/null
+++ b/platforms/maven/opencv-it/pom.xml
@@ -0,0 +1,98 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opencv</groupId>
+ <artifactId>opencv-parent</artifactId>
+ <version>3.3.0</version>
+ </parent>
+ <groupId>org.opencv</groupId>
+ <artifactId>opencv-it</artifactId>
+ <name>OpenCV Integration Test</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-container-karaf</artifactId>
+ <version>${pax.exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-junit4</artifactId>
+ <version>${pax.exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-atinject_1.0_spec</artifactId>
+ <version>1.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.url</groupId>
+ <artifactId>pax-url-aether</artifactId>
+ <version>1.6.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>4.3.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>4.3.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.24</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.7.24</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <artifactId>org.apache.karaf.log.core</artifactId>
+ <groupId>org.apache.karaf.log</groupId>
+ <version>4.0.6</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.logging</groupId>
+ <artifactId>pax-logging-api</artifactId>
+ <version>1.8.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>opencv</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <directory>../../../build/maven/opencv-it/target</directory>
+ <testSourceDirectory>src/test/java</testSourceDirectory>
+ <testOutputDirectory>../../../build/maven/opencv-it/target</testOutputDirectory>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.15</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/platforms/maven/opencv-it/src/test/java/org/opencv/osgi/DeployOpenCVTest.java b/platforms/maven/opencv-it/src/test/java/org/opencv/osgi/DeployOpenCVTest.java
new file mode 100644
index 0000000..be05ba6
--- /dev/null
+++ b/platforms/maven/opencv-it/src/test/java/org/opencv/osgi/DeployOpenCVTest.java
@@ -0,0 +1,97 @@
+package org.opencv.osgi;
+
+import java.io.File;
+import javax.inject.Inject;
+import junit.framework.TestCase;
+import org.apache.karaf.log.core.LogService;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import static org.ops4j.pax.exam.CoreOptions.maven;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
+import org.ops4j.pax.exam.karaf.options.LogLevelOption;
+import org.ops4j.pax.exam.options.MavenArtifactUrlReference;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.ops4j.pax.logging.spi.PaxLoggingEvent;
+import org.osgi.framework.BundleContext;
+
+/**
+ *
+ * @author Kerry Billingham <contact at AvionicEngineers.com>
+ */
+ at ExamReactorStrategy(PerClass.class)
+ at RunWith(PaxExam.class)
+public class DeployOpenCVTest {
+
+ /*
+ The expected string in Karaf logs when the bundle has deployed and native library loaded.
+ */
+ private static final String OPENCV_SUCCESSFUL_LOAD_STRING = "Successfully loaded OpenCV native library.";
+
+ private static final String KARAF_VERSION = "4.0.6";
+
+ @Inject
+ protected BundleContext bundleContext;
+
+ @Inject
+ private LogService logService;
+
+ /*
+ This service is required to ensure that the native library has been loaded
+ before any test is carried out.
+ */
+ @Inject
+ private OpenCVInterface openCVInterface;
+
+ @Configuration
+ public static Option[] configuration() throws Exception {
+ MavenArtifactUrlReference karafUrl = maven()
+ .groupId("org.apache.karaf")
+ .artifactId("apache-karaf")
+ .version(KARAF_VERSION)
+ .type("tar.gz");
+ return new Option[]{
+ karafDistributionConfiguration()
+ .frameworkUrl(karafUrl)
+ .unpackDirectory(new File("../../../build/target/exam"))
+ .useDeployFolder(false),
+ keepRuntimeFolder(),
+ mavenBundle()
+ .groupId("org.opencv")
+ .artifactId("opencv")
+ .version("3.3.0"),
+ logLevel(LogLevelOption.LogLevel.INFO)
+ };
+ }
+
+ /**
+ * Tests that the OpenCV bundle has been successfully deployed and that the
+ * native library has been loaded.
+ */
+ @Test
+ public void testOpenCVNativeLibraryLoadSuccess() {
+
+ Iterable<PaxLoggingEvent> loggingEvents = logService.getEvents();
+ boolean loadSuccessful = logsContainsMessage(loggingEvents, OPENCV_SUCCESSFUL_LOAD_STRING);
+
+ TestCase.assertTrue("Could not determine if OpenCV library successfully loaded from the logs.", loadSuccessful);
+
+ }
+
+ private boolean logsContainsMessage(Iterable<PaxLoggingEvent> logEnumeration, final String logMessageString) {
+ boolean contains = false;
+ for (PaxLoggingEvent logEntry : logEnumeration) {
+ if (logEntry.getMessage().contains(logMessageString)) {
+ contains = true;
+ break;
+ }
+ }
+ return contains;
+ }
+}
diff --git a/platforms/maven/opencv/pom.xml b/platforms/maven/opencv/pom.xml
new file mode 100644
index 0000000..33d9162
--- /dev/null
+++ b/platforms/maven/opencv/pom.xml
@@ -0,0 +1,270 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opencv</groupId>
+ <artifactId>opencv-parent</artifactId>
+ <version>3.3.0</version>
+ </parent>
+ <groupId>org.opencv</groupId>
+ <artifactId>opencv</artifactId>
+ <packaging>bundle</packaging>
+ <name>OpenCV</name>
+
+ <properties>
+ <source.path>../../..</source.path>
+ <build.directory>${source.path}/build</build.directory>
+ <nativelibrary.name>libopencv_java${lib.version.string}.so</nativelibrary.name>
+ <resources.directory>${build.directory}/src</resources.directory>
+ </properties>
+ <build>
+ <directory>../../../build/maven/opencv/target</directory>
+ <outputDirectory>../../../build/src</outputDirectory>
+ <sourceDirectory>../../../build/src</sourceDirectory>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-clean-plugin</artifactId>
+ <version>3.0.0</version>
+ <configuration>
+ <filesets>
+ <fileset>
+ <directory>${build.directory}</directory>
+ </fileset>
+ </filesets>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.4.0</version>
+ <executions>
+ <execution>
+ <id>get-opencv-version</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <executable>bash</executable>
+ <workingDirectory>${project.basedir}/scripts</workingDirectory>
+ <arguments>
+ <argument>properties</argument>
+ <argument>../../../../modules/core/include/opencv2/core/version.hpp</argument>
+ <argument>${build.directory}</argument>
+ <argument>build.properties</argument>
+ </arguments>
+ </configuration>
+ </execution>
+ <execution>
+ <id>setup-environment</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <executable>bash</executable>
+ <workingDirectory>${project.basedir}/scripts</workingDirectory>
+ <arguments>
+ <argument>deb_package_check</argument>
+ <argument>-olibpng-dev|libpng12-dev</argument>
+ <argument>-olibopenjp2-7-dev|libjasper-dev</argument>
+ <argument>-opython-dev</argument>
+ <argument>-opython-numpy</argument>
+ <argument>build-essential</argument>
+ <argument>cmake</argument>
+ <argument>git</argument>
+ <argument>libgtk2.0-dev</argument>
+ <argument>pkg-config</argument>
+ <argument>libavcodec-dev</argument>
+ <argument>libavformat-dev</argument>
+ <argument>libswscale-dev</argument>
+ <argument>libtbb2</argument>
+ <argument>libtbb-dev</argument>
+ <argument>libjpeg-dev</argument>
+ <argument>libtiff5-dev</argument>
+ <argument>libdc1394-22-dev</argument>
+ <argument>execstack</argument>
+ <argument>ant</argument>
+ </arguments>
+ </configuration>
+ </execution>
+ <execution>
+ <id>check-execstack</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <workingDirectory>${project.basedir}/scripts</workingDirectory>
+ <executable>bash</executable>
+ <arguments>
+ <argument>execstack_check</argument>
+ <argument>${build.directory}/lib/libopencv_java${lib.version.string}.so</argument>
+ </arguments>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>3.0.2</version>
+ <executions>
+ <execution>
+ <id>copy-resources</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${resources.directory}</outputDirectory>
+ <resources>
+ <resource>
+ <directory>resources</directory>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>properties-maven-plugin</artifactId>
+ <version>1.0.0</version>
+ <executions>
+ <execution>
+ <id>set-arch-properties</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>read-project-properties</goal>
+ </goals>
+ <configuration>
+ <files>
+ <file>${build.directory}/build.properties</file>
+ </files>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>1.4.1</version>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <id>enforce-os</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireOS>
+ <family>unix</family>
+ <message>This POM is written to function on UNIX family of OS.
+ More specifically it should be a Debian flavour of Linux.</message>
+ </requireOS>
+ </rules>
+ </configuration>
+ </execution>
+ <execution>
+ <id>enforce-environment</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireEnvironmentVariable>
+ <level>WARN</level>
+ <variableName>ANT_HOME</variableName>
+ <message>$ANT_HOME is not set. Build may fail.</message>
+ </requireEnvironmentVariable>
+ <requireEnvironmentVariable>
+ <level>WARN</level>
+ <variableName>JAVA_HOME</variableName>
+ <message>$JAVA_HOME is not set. Build may fail.</message>
+ </requireEnvironmentVariable>
+ <requireEnvironmentVariable>
+ <level>WARN</level>
+ <variableName>MAKEFLAGS</variableName>
+ <message>No MAKEFLAGS environment variable. Build may be slow.
+To speed up the build you can try exporting MAKEFLAGS=-jX where X equals the number of parallel builds.</message>
+ </requireEnvironmentVariable>
+ </rules>
+ </configuration>
+ </execution>
+ <execution>
+ <phase>process-resources</phase>
+ <id>check-versions-match</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireProperty>
+ <property>project.version</property>
+ <regex>${opencv.version}</regex>
+ <regexMessage>The Maven POM version ${project.version} does not match the extracted OpenCV version ${opencv.version}.</regexMessage>
+ </requireProperty>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.3.7</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>*</Export-Package>
+ <Bundle-NativeCode>${nativelibrary.name};osname=linux;processor=${osgi.processor}</Bundle-NativeCode>
+ <Include-Resource>${build.directory}/lib/${nativelibrary.name}</Include-Resource>
+ </instructions>
+ <manifestLocation>${build.directory}/manifest</manifestLocation>
+ <niceManifest>true</niceManifest>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>com.googlecode.cmake-maven-project</groupId>
+ <artifactId>cmake-maven-plugin</artifactId>
+ <version>3.4.1-b2</version>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <id>cmake-generate</id>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <sourcePath>../../..</sourcePath>
+ <targetPath>../../../build</targetPath>
+ <generator>Unix Makefiles</generator>
+ <options>
+ <option>-DBUILD_SHARED_LIBS:BOOL=OFF</option>
+ <option>-DWITH_CUDA=OFF</option>
+ </options>
+ </configuration>
+ </execution>
+ <execution>
+ <phase>generate-sources</phase>
+ <id>cmake-compile</id>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ <configuration>
+ <target>opencv_java</target>
+ <projectDirectory>../../../build</projectDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.15</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/platforms/maven/opencv/resources/OSGI-INF/blueprint/blueprint.xml b/platforms/maven/opencv/resources/OSGI-INF/blueprint/blueprint.xml
new file mode 100644
index 0000000..cdd9978
--- /dev/null
+++ b/platforms/maven/opencv/resources/OSGI-INF/blueprint/blueprint.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint
+ xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
+ xmlns='http://www.osgi.org/xmlns/blueprint/v1.0.0'
+ xsi:schemaLocation='http://www.osgi.org/xmlns/blueprint/v1.0.0 https://osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd'>
+
+ <bean id="opencvnativeloader" class="org.opencv.osgi.OpenCVNativeLoader" scope="singleton" init-method="init" />
+
+ <service id="opencvtestservice" ref="opencvnativeloader" interface="org.opencv.osgi.OpenCVInterface" />
+
+</blueprint>
diff --git a/platforms/maven/opencv/scripts/deb_package_check b/platforms/maven/opencv/scripts/deb_package_check
new file mode 100755
index 0000000..ced31ac
--- /dev/null
+++ b/platforms/maven/opencv/scripts/deb_package_check
@@ -0,0 +1,102 @@
+#!/bin/bash
+##################################################################################################
+#
+# This script checks for the required Debian packages are installed
+# to build OpenCV.
+# Commandline parameters:
+# $@ These are the names of the packages to check with 'dpkg'. Multiple values may
+# be specified per package by using pipe as a delimiter, e.g. libpng-dev|libpng12-dev.
+# Multiple values are evaluated left-to-right and the first found prevents checking of
+# the remaining package options.
+#
+# -o <package_name> Specifying this switch with a package name marks it as optional
+# i.e. it is not required to be installed.
+#
+# Returns:
+# 0 - All packages installed (success)
+# 1 - One or more packages missing (failure)
+#
+# Kerry Billingham <contact (at) avionicengineers (d0t) com>
+# 20 April 2016
+#
+##################################################################################################
+red=$'\e[1;31m'
+green=$'\e[1;32m'
+yellow=$'\e[1;33m'
+end=$'\e[0m'
+check_message="Checking for "
+declare -i packageMissing=0
+declare -i installed=1
+
+#########################
+# Function declarations.
+#########################
+function check_package() {
+ check_message="Checking for package "
+ dpkg -s $1 &>/dev/null
+ is_installed=$?
+ if [ ${is_installed} -ne 0 ]; then
+ printf "%-80s%s\n" "$2${check_message}${red}$1" " MISSING.${end}"
+ packageMissing=1
+ else
+ printf "%-80s%s\n" "$2${check_message}${green}$1" " INSTALLED.${end}"
+ packageMissing=0
+ fi
+ return $is_installed
+}
+
+# Main part of script.
+ORIGINAL_IFS=$IFS
+
+dpkg -? &>/dev/null
+if [ $? -ne 0 ]; then
+ printf "%-80s%s\n" "${check_message} ${red}'dpkg'" " MISSING.${end}"
+ exit 1
+else
+ printf "%-80s%s\n" "${check_message} ${green}'dpkg'" " INSTALLED.${end}"
+fi
+
+while getopts o: option; do
+ case $option in
+ o)
+ IFS="|"
+ packageChoices=( ${OPTARG} )
+ if [ ${#packageChoices[@]} -gt 1 ]; then
+ echo "Optional package. One of ${yellow}${packageChoices[@]}${end} can be installed."
+ for choice in ${packageChoices[@]}; do
+ check_package ${choice} " "
+ if [ $? -eq 0 ]; then
+ break
+ fi
+ done
+ else
+ echo "Optional package ${yellow}${packageChoices}${end}"
+ check_package ${OPTARG} " "
+ fi
+ IFS=$ORIGINAL_IFS
+ ;;
+ \?)
+ echo "No option found"
+ ;;
+ esac
+done
+
+shift $((OPTIND-1))
+packageArray=( $@ )
+for package in ${packageArray[@]}; do
+ IFS="|"
+ packageChoices=( ${package} )
+ if [ ${#packageChoices[@]} -gt 1 ]; then
+ echo "Multiple options. One of ${yellow}${packageChoices[@]}${end} must be installed."
+ for choice in ${packageChoices[@]}; do
+ check_package ${choice} " "
+ if [ $? -eq 0 ]; then
+ break
+ fi
+ done
+ else
+ check_package ${package} ""
+ fi
+done
+
+exit $packageMissing
diff --git a/platforms/maven/opencv/scripts/execstack_check b/platforms/maven/opencv/scripts/execstack_check
new file mode 100755
index 0000000..04faeff
--- /dev/null
+++ b/platforms/maven/opencv/scripts/execstack_check
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+##################################################################
+#
+# This script will clear the executable flag on
+# the specified library and then check it has
+# been cleared as a separate operation.
+#
+# $1 - The absolute path to the OpenCV native library.
+#
+# Returns:
+# 0 - The executable flag has been cleared
+# 1 - The executable flag could NOT be cleared (failure).
+#
+# Kerry Billingham <contact (at) avionicengineers (d0t) com>
+# 11 March 2017
+#
+##################################################################
+red=$'\e[1;31m'
+green=$'\e[1;32m'
+end=$'\e[0m'
+echo "${green}[INFO] Checking that the native library executable stack flag is NOT set.${end}"
+BINARY=execstack
+$BINARY --help > /dev/null || BINARY=/usr/sbin/execstack
+$BINARY -c $1
+$BINARY -q $1 | grep -o ^-
+if [ $? -ne 0 ]; then
+ echo
+ echo "${red}[ERROR] The Executable Flag could not be cleared on the library $1.${end}"
+ exit 1
+fi
+exit 0
diff --git a/platforms/maven/scripts/properties b/platforms/maven/opencv/scripts/properties
similarity index 100%
rename from platforms/maven/scripts/properties
rename to platforms/maven/opencv/scripts/properties
diff --git a/platforms/maven/pom.xml b/platforms/maven/pom.xml
index d070acf..cf5bf6b 100644
--- a/platforms/maven/pom.xml
+++ b/platforms/maven/pom.xml
@@ -1,21 +1,21 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>opencv.org</groupId>
- <artifactId>opencv</artifactId>
- <packaging>bundle</packaging>
- <version>3.2.0</version>
- <name>OpenCV</name>
+ <groupId>org.opencv</groupId>
+ <artifactId>opencv-parent</artifactId>
+ <version>3.3.0</version>
+ <packaging>pom</packaging>
+ <name>OpenCV Parent POM</name>
<licenses>
<license>
<name>License Agreement For Open Source Computer Vision Library (3-clause BSD License)</name>
- <url></url>
+ <url>http://opencv.org/license.html</url>
</license>
</licenses>
<url>http://opencv.org/</url>
<scm>
- <connection>scm:git:https://github.com/Itseez/opencv.git</connection>
- <url>https://github.com/Itseez/opencv</url>
+ <connection>scm:git:https://github.com/opencv/opencv.git</connection>
+ <url>https://github.com/opencv/opencv</url>
</scm>
<contributors>
<contributor>
@@ -25,17 +25,12 @@
<url>www.javatechnics.com</url>
</contributor>
</contributors>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
+
<properties>
- <build.directory>../../build</build.directory>
<nativelibrary.name>libopencv_java${lib.version.string}.so</nativelibrary.name>
+ <pax.exam.version>4.8.0</pax.exam.version>
+ <maven.compiler.source>1.7</maven.compiler.source>
+ <maven.compiler.target>1.7</maven.compiler.target>
</properties>
<distributionManagement>
<snapshotRepository>
@@ -43,221 +38,9 @@
<url>${repo.url}</url>
</snapshotRepository>
</distributionManagement>
- <build>
- <directory>../../build/target</directory>
- <outputDirectory>../../build/src</outputDirectory>
- <sourceDirectory>../../build/src</sourceDirectory>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-clean-plugin</artifactId>
- <version>3.0.0</version>
- <configuration>
- <filesets>
- <fileset>
- <directory>${build.directory}</directory>
- </fileset>
- </filesets>
- </configuration>
- </plugin>
- <plugin>
- <groupId>com.github.maven-nar</groupId>
- <artifactId>nar-maven-plugin</artifactId>
- <version>3.3.0</version>
- <extensions>true</extensions>
- <executions>
- <execution>
- <id>nar-initiliase</id>
- <phase>validate</phase>
- <goals>
- <goal>nar-validate</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.4.0</version>
- <executions>
- <execution>
- <id>get-opencv-version</id>
- <phase>generate-resources</phase>
- <goals>
- <goal>exec</goal>
- </goals>
- <configuration>
- <executable>bash</executable>
- <workingDirectory>${project.basedir}/scripts</workingDirectory>
- <arguments>
- <argument>properties</argument>
- <argument>../../../modules/core/include/opencv2/core/version.hpp</argument>
- <argument>${build.directory}</argument>
- <argument>build.properties</argument>
- </arguments>
- </configuration>
- </execution>
- <execution>
- <id>setup-environment</id>
- <phase>validate</phase>
- <goals>
- <goal>exec</goal>
- </goals>
- <configuration>
- <executable>bash</executable>
- <workingDirectory>${project.basedir}/scripts</workingDirectory>
- <arguments>
- <argument>deb_package_check</argument>
- <argument>build-essential</argument>
- <argument>cmake</argument>
- <argument>git</argument>
- <argument>libgtk2.0-dev</argument>
- <argument>pkg-config</argument>
- <argument>libavcodec-dev</argument>
- <argument>libavformat-dev</argument>
- <argument>libswscale-dev</argument>
- <argument>python-dev</argument>
- <argument>python-numpy</argument>
- <argument>libtbb2</argument>
- <argument>libtbb-dev</argument>
- <argument>libjpeg-dev</argument>
- <argument>libpng12-dev</argument>
- <argument>libtiff5-dev</argument>
- <argument>libjasper-dev</argument>
- <argument>libdc1394-22-dev</argument>
- <argument>ant</argument>
- </arguments>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>properties-maven-plugin</artifactId>
- <version>1.0.0</version>
- <executions>
- <execution>
- <id>set-arch-properties</id>
- <phase>process-resources</phase>
- <goals>
- <goal>read-project-properties</goal>
- </goals>
- <configuration>
- <files>
- <file>${build.directory}/build.properties</file>
- </files>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin</artifactId>
- <version>1.4.1</version>
- <executions>
- <execution>
- <phase>validate</phase>
- <id>enforce-os</id>
- <goals>
- <goal>enforce</goal>
- </goals>
- <configuration>
- <rules>
- <requireOS>
- <family>unix</family>
- <message>This POM is written to function on UNIX family of OS.
- More specifically it should be a Debian flavour of Linux.</message>
- </requireOS>
- </rules>
- </configuration>
- </execution>
- <execution>
- <id>enforce-environment</id>
- <goals>
- <goal>enforce</goal>
- </goals>
- <configuration>
- <rules>
- <requireEnvironmentVariable>
- <variableName>ANT_HOME</variableName>
- <message>$ANT_HOME is not set. Build may fail.</message>
- </requireEnvironmentVariable>
- <requireEnvironmentVariable>
- <variableName>JAVA_HOME</variableName>
- <message>$JAVA_HOME is not set. Build WILL fail.</message>
- </requireEnvironmentVariable>
- <requireEnvironmentVariable>
- <level>WARN</level>
- <variableName>MAKEFLAGS</variableName>
- <message>No MAKEFLAGS environment variable. Build may be slow.
-To speed up the build you can try exporting MAKEFLAGS=-jX where X equals the number of parallel builds.</message>
- </requireEnvironmentVariable>
- </rules>
- </configuration>
- </execution>
- <execution>
- <phase>process-resources</phase>
- <id>check-versions-match</id>
- <goals>
- <goal>enforce</goal>
- </goals>
- <configuration>
- <rules>
- <requireProperty>
- <property>project.version</property>
- <regex>${opencv.version}</regex>
- <regexMessage>The Maven POM version ${project.version} does not match the extracted OpenCV version ${opencv.version}.</regexMessage>
- </requireProperty>
- </rules>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>2.3.7</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>*</Export-Package>
- <Bundle-NativeCode>${nativelibrary.name};osname=linux;processor=${osgi.processor}</Bundle-NativeCode>
- <Include-Resource>${build.directory}/lib/${nativelibrary.name}</Include-Resource>
- </instructions>
- <manifestLocation>${build.directory}/manifest</manifestLocation>
- <niceManifest>true</niceManifest>
- </configuration>
- </plugin>
- <plugin>
- <groupId>com.googlecode.cmake-maven-project</groupId>
- <artifactId>cmake-maven-plugin</artifactId>
- <version>3.4.1-b2-SNAPSHOT</version>
- <executions>
- <execution>
- <id>cmake-generate</id>
- <goals>
- <goal>generate</goal>
- </goals>
- <configuration>
- <sourcePath>../..</sourcePath>
- <targetPath>../../build</targetPath>
- <generator>Unix Makefiles</generator>
- <options>
- <option>-DBUILD_SHARED_LIBS:BOOL=OFF</option>
- </options>
- </configuration>
- </execution>
- <execution>
- <id>cmake-compile</id>
- <goals>
- <goal>compile</goal>
- </goals>
- <configuration>
- <projectDirectory>../../build</projectDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
+
+ <modules>
+ <module>opencv</module>
+ <module>opencv-it</module>
+ </modules>
</project>
diff --git a/platforms/maven/scripts/deb_package_check b/platforms/maven/scripts/deb_package_check
deleted file mode 100755
index 504e758..0000000
--- a/platforms/maven/scripts/deb_package_check
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/bash
-###########################################################################################
-#
-# This script checks for the required Debian packages are installed
-# to build OpenCV.
-# Commandline parameters:
-# $@ - These are the names of the packages to check with 'dpkg'
-#
-# Returns:
-# 0 - All packages installed (success)
-# 1 - One or more packages missing (failure)
-#
-# Kerry Billingham <contact (at) avionicengineers (d0t) com>
-# 20 April 2016
-#
-###########################################################################################
-red=$'\e[1;31m'
-green=$'\e[1;32m'
-end=$'\e[0m'
-check_message="Checking for 'dpkg'"
-dpkg -? &>/dev/null
-if [ $? -ne 0 ]; then
- printf "%-80s%s\n" "${check_message}" "${red} MISSING.${end}"
- exit 1
-else
- printf "%-80s%s\n" "${check_message}" "${green} INSTALLED.${end}"
-fi
-
-declare -i packageMissing=0
-packageArray=( "$@" )
-for package in ${packageArray[@]}; do
- check_message="Checking for package ${package}"
- dpkg -s ${package} &>/dev/null
- if [ $? -ne 0 ]; then
- printf "%-80s%s\n" "${check_message}" "${red} MISSING.${end}"
- packageMissing=1
- else
- printf "%-80s%s\n" "${check_message}" "${green} INSTALLED.${end}"
- fi
-done
-
-exit $packageMissing
diff --git a/platforms/osx/build_framework.py b/platforms/osx/build_framework.py
index 2d39be5..2db5cd2 100644
--- a/platforms/osx/build_framework.py
+++ b/platforms/osx/build_framework.py
@@ -4,7 +4,7 @@ The script builds OpenCV.framework for OSX.
"""
from __future__ import print_function
-import os, os.path, sys, argparse, traceback
+import os, os.path, sys, argparse, traceback, multiprocessing
# import common code
sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../ios'))
@@ -15,14 +15,15 @@ class OSXBuilder(Builder):
def getToolchain(self, arch, target):
return None
- def getBuildCommand(self, arch, target):
+ def getBuildCommand(self, archs, target):
buildcmd = [
"xcodebuild",
- "ARCHS=%s" % arch,
+ "MACOSX_DEPLOYMENT_TARGET=10.9",
+ "ARCHS=%s" % archs[0],
"-sdk", target.lower(),
"-configuration", "Release",
"-parallelizeTargets",
- "-jobs", "4"
+ "-jobs", str(multiprocessing.cpu_count())
]
return buildcmd
@@ -39,8 +40,8 @@ if __name__ == "__main__":
parser.add_argument('--without', metavar='MODULE', default=[], action='append', help='OpenCV modules to exclude from the framework')
args = parser.parse_args()
- b = OSXBuilder(args.opencv, args.contrib, args.without,
+ b = OSXBuilder(args.opencv, args.contrib, False, False, args.without,
[
- ("x86_64", "MacOSX")
+ (["x86_64"], "MacOSX")
])
b.build(args.out)
diff --git a/platforms/scripts/valgrind.supp b/platforms/scripts/valgrind.supp
index 54833e0..e78d047 100644
--- a/platforms/scripts/valgrind.supp
+++ b/platforms/scripts/valgrind.supp
@@ -1,13 +1,203 @@
{
- IPP static init
+ OpenCV-IPP static init
Memcheck:Cond
fun:ippicvGetCpuFeatures
fun:ippicvStaticInit
}
{
- TBB - allocate_via_handler_v3 issue
+ OpenCV-getInitializationMutex
Memcheck:Leak
- fun:malloc
- fun:_ZN3tbb8internal23allocate_via_handler_v3Em
+ ...
+ fun:_ZN2cv22getInitializationMutexEv
+}
+
+{
+ OpenCV-getStdAllocator
+ Memcheck:Leak
+ ...
+ fun:_ZN2cv3Mat15getStdAllocatorEv
+}
+
+{
+ OpenCV-getOpenCLAllocator
+ Memcheck:Leak
+ ...
+ fun:_ZN2cv3ocl18getOpenCLAllocatorEv
+}
+
+{
+ OpenCV-getCoreTlsData
+ Memcheck:Leak
+ fun:_Znwm
+ fun:_ZN2cv14getCoreTlsDataEv
+}
+
+{
+ OpenCV-TLS-getTlsStorage
+ Memcheck:Leak
+ ...
+ fun:_ZN2cvL13getTlsStorageEv
+}
+
+{
+ OpenCV-TLS-getData()
+ Memcheck:Leak
+ ...
+ fun:*setData*
+ fun:_ZNK2cv16TLSDataContainer7getDataEv
+}
+
+{
+ OpenCV-parallel_for
+ Memcheck:Leak
+ ...
+ fun:_ZN2cv13ThreadManager8initPoolEv*
+}
+
+{
+ OpenCV-parallel_for
+ Memcheck:Leak
+ fun:_Znwm
+ fun:*instance*
+ fun:_ZN2cv21parallel_for_pthreadsERKNS_5RangeERKNS_16ParallelLoopBodyEd
+ fun:_ZN2cv13parallel_for_ERKNS_5RangeERKNS_16ParallelLoopBodyEd
+}
+
+{
+ OpenCV-parallel_for-ThreadManager::TLS
+ Memcheck:Leak
+ fun:_Znwm
+ fun:_ZNK2cv7TLSDataINS_13ThreadManager13work_thread_tEE18createDataInstanceEv
+}
+
+{
+ OpenCV-parallel_for-setNumThreads()
+ Memcheck:Leak
+ fun:_Znwm
+ fun:_ZN2cv13ThreadManager8instanceEv
+ fun:_ZN2cv33parallel_pthreads_set_threads_numEi
+ fun:_ZN2cv13setNumThreadsEi
+}
+
+{
+ OpenCV-parallel_for-getNumThreads()
+ Memcheck:Leak
+ ...
+ fun:_ZN2cv13getNumThreadsEv
+}
+
+{
+ OpenCV-getIPPSingelton
+ Memcheck:Leak
+ ...
+ fun:_ZN2cv3ippL15getIPPSingeltonEv
+}
+
+{
+ OpenCV-getGlobalMatOpInitializer
+ Memcheck:Leak
+ fun:_Znwm
+ fun:_ZN2cvL25getGlobalMatOpInitializerEv
+}
+
+{
+ OpenCV-CoreTLSData
+ Memcheck:Leak
+ ...
+ fun:_ZNK2cv7TLSDataINS_11CoreTLSDataEE3getEv
+}
+
+{
+ OpenCV-ThreadID
+ Memcheck:Leak
+ fun:_Znwm
+ fun:_ZNK2cv7TLSDataINS_12_GLOBAL__N_18ThreadIDEE18createDataInstanceEv
+}
+
+{
+ OpenCV-ThreadID-TLS
+ Memcheck:Leak
+ fun:_Znwm
+ fun:getThreadIDTLS
+}
+
+{
+ OpenCV-CoreTLS
+ Memcheck:Leak
+ fun:_Znwm
+ fun:_ZNK2cv7TLSDataINS_11CoreTLSDataEE18createDataInstanceEv
+}
+
+{
+ OpenCV-haveOpenCL
+ Memcheck:Leak
+ ...
+ fun:_ZN2cv3ocl10haveOpenCLEv
+}
+
+{
+ OpenCV-DNN-getLayerFactoryMutex
+ Memcheck:Leak
+ ...
+ fun:_ZN2cv3dnn*L20getLayerFactoryMutexEv
+}
+
+{
+ OpenCV-ocl::Context
+ Memcheck:Leak
+ ...
+ fun:_ZN2cv3ocl7Context10getDefaultEb
+}
+
+{
+ OpenCV-ocl::Device
+ Memcheck:Leak
+ ...
+ fun:_ZN2cv3ocl6Device10getDefaultEv
+}
+
+{
+ OpenCV-ocl::Queue
+ Memcheck:Leak
+ ...
+ fun:_ZN2cv3ocl5Queue6createERKNS0_7ContextERKNS0_6DeviceE
+}
+
+{
+ OpenCV-ocl::Program
+ Memcheck:Leak
+ ...
+ fun:_ZN2cv3ocl6Kernel6createEPKcRKNS0_7ProgramE
+}
+
+{
+ OpenCV-ocl::ProgramEntry
+ Memcheck:Leak
+ ...
+ fun:_ZNK2cv3ocl8internal12ProgramEntrycvRNS0_13ProgramSourceEEv
+}
+
+{
+ OpenCV-ocl::Context::getProg
+ Memcheck:Leak
+ ...
+ fun:_ZN2cv3ocl7Context7getProgERKNS0_13ProgramSourceERKNS_6StringERS5_
+}
+
+
+{
+ OpenCV-ITT
+ Memcheck:Leak
+ ...
+ fun:__itt_*create*
+}
+
+{
+ OpenCV-FFmpeg-swsscale
+ Memcheck:Addr16
+ ...
+ fun:sws_scale
+ fun:_ZN20CvVideoWriter_FFMPEG10writeFrameEPKhiiiii
+ fun:cvWriteFrame_FFMPEG
}
diff --git a/platforms/scripts/valgrind_3rdparty.supp b/platforms/scripts/valgrind_3rdparty.supp
new file mode 100644
index 0000000..7b6472d
--- /dev/null
+++ b/platforms/scripts/valgrind_3rdparty.supp
@@ -0,0 +1,113 @@
+{
+ IPP static init
+ Memcheck:Cond
+ fun:ippicvGetCpuFeatures
+ fun:ippicvStaticInit
+}
+
+{
+ TBB - allocate_via_handler_v3 issue
+ Memcheck:Leak
+ fun:malloc
+ fun:_ZN3tbb8internal23allocate_via_handler_v3Em
+}
+
+{
+ GTest
+ Memcheck:Cond
+ fun:_ZN7testing8internal11CmpHelperLEIddEENS_15AssertionResultEPKcS4_RKT_RKT0_
+}
+
+{
+ OpenCL
+ Memcheck:Cond
+ ...
+ obj:**/libOpenCL.so*
+}
+
+{
+ OpenCL-Intel
+ Memcheck:Cond
+ ...
+ obj:**/libigdrcl.so
+}
+
+{
+ OpenCL-Intel
+ Memcheck:Leak
+ ...
+ obj:*/libigdrcl.so*
+}
+
+{
+ OpenCL
+ Memcheck:Param
+ ioctl(generic)
+ ...
+ fun:clGetPlatformIDs
+}
+
+{
+ OpenCL-Init
+ Memcheck:Leak
+ ...
+ fun:clGetPlatformIDs
+}
+
+{
+ glib
+ Memcheck:Leak
+ fun:*alloc
+ obj:*/libglib*
+}
+
+{
+ gcrypt
+ Memcheck:Leak
+ ...
+ obj:*/libgcrypt*
+}
+
+{
+ p11-kit
+ Memcheck:Leak
+ fun:*alloc
+ obj:*/libp11-kit*
+}
+
+{
+ gobject
+ Memcheck:Leak
+ fun:*alloc
+ ...
+ obj:*/libgobject*
+}
+
+{
+ tasn
+ Memcheck:Leak
+ fun:*alloc
+ obj:*/libtasn*.so*
+}
+
+{
+ dl_init
+ Memcheck:Leak
+ ...
+ fun:_dl_init
+}
+
+{
+ dl_open
+ Memcheck:Leak
+ ...
+ fun:_dl_open
+}
+
+{
+ GDAL
+ Memcheck:Leak
+ fun:*alloc
+ ...
+ obj:/usr/lib/libgdal.so.1.17.1
+}
diff --git a/platforms/winrt/setup_winrt.ps1 b/platforms/winrt/setup_winrt.ps1
index 47a9946..ca62a71 100644
--- a/platforms/winrt/setup_winrt.ps1
+++ b/platforms/winrt/setup_winrt.ps1
@@ -58,8 +58,8 @@ Param(
[parameter(Mandatory=$False)]
[String]
[ValidateNotNull()]
- [ValidateSet("Visual Studio 12 2013","Visual Studio 11 2012")]
- $GENERATOR = "Visual Studio 12 2013",
+ [ValidateSet("Visual Studio 15 2017","Visual Studio 14 2015","Visual Studio 12 2013","Visual Studio 11 2012")]
+ $GENERATOR = "Visual Studio 15 2017",
[parameter(Mandatory=$False)]
[String]
@@ -168,11 +168,11 @@ Function Execute() {
$versions = New-Object System.Collections.ArrayList
$VERSIONS_IN.Split("," ,[System.StringSplitOptions]::RemoveEmptyEntries) | ForEach {
$_ = $_.Trim()
- if ("8.0","8.1" -Contains $_) {
+ if ("8.0","8.1","10.0" -Contains $_) {
[void]$versions.Add($_)
D "$_ is valid"
} else {
- Throw "$($_) is not valid! Please use 8.0, 8.1"
+ Throw "$($_) is not valid! Please use 8.0, 8.1, 10.0"
}
}
D "Processed Versions: $versions"
@@ -345,7 +345,7 @@ Function ShowHelp() {
Write-Host " setup_winrt -b 'WP' 'x86,ARM' -test PERF "
Write-Host " setup_winrt -architecture x86 -platform WP "
Write-Host " setup_winrt -arc x86 -plat 'WP,WS' "
- Write-Host " setup_winrt -a x86 -g 'Visual Studio 11 2012' -pl WP "
+ Write-Host " setup_winrt -a x86 -g 'Visual Studio 15 2017' -pl WP "
Write-Host " WHERE: "
Write-Host " options - Options to call "
Write-Host " -h: diplays command line help "
@@ -358,7 +358,7 @@ Function ShowHelp() {
Write-Host " version - Array of platform versions. "
Write-Host " Default: 8.1 "
Write-Host " Example: '8.0,8.1' "
- Write-Host " Options: 8.0, 8.1. Available options may be limited depending on your local setup (e.g. SDK availability). "
+ Write-Host " Options: 8.0, 8.1, 10.0. Available options may be limited depending on your local setup (e.g. SDK availability). "
Write-Host " Note that you'll need to use quotes to specify more than one version. "
Write-Host " architecture - Array of target architectures to build for. "
Write-Host " Default: x86 "
diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt
index b1f98e9..1ce0489 100644
--- a/samples/CMakeLists.txt
+++ b/samples/CMakeLists.txt
@@ -11,6 +11,8 @@ if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_LIST_DIR)
# ----------------------------------------------------------------------------
add_subdirectory(cpp)
+add_subdirectory(java/tutorial_code)
+add_subdirectory(dnn)
add_subdirectory(gpu)
add_subdirectory(tapi)
@@ -53,7 +55,9 @@ option(BUILD_EXAMPLES "Build samples" ON)
find_package(OpenCV REQUIRED)
if(MSVC)
- add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+ if(NOT ENABLE_BUILD_HARDENING)
+ add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+ endif()
if(NOT OpenCV_SHARED)
foreach(flag_var
@@ -76,6 +80,7 @@ if(MSVC)
endif()
add_subdirectory(cpp)
+add_subdirectory(dnn)
# FIXIT: can't use cvconfig.h in samples: add_subdirectory(gpu)
add_subdirectory(opencl)
diff --git a/samples/android/face-detection/jni/Android.mk b/samples/android/face-detection/jni/Android.mk
index 0686b22..e882cac 100644
--- a/samples/android/face-detection/jni/Android.mk
+++ b/samples/android/face-detection/jni/Android.mk
@@ -2,7 +2,6 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
-#OPENCV_CAMERA_MODULES:=off
#OPENCV_INSTALL_MODULES:=off
#OPENCV_LIB_TYPE:=SHARED
ifdef OPENCV_ANDROID_SDK
diff --git a/samples/cpp/application_trace.cpp b/samples/cpp/application_trace.cpp
new file mode 100644
index 0000000..ddddd51
--- /dev/null
+++ b/samples/cpp/application_trace.cpp
@@ -0,0 +1,92 @@
+/* OpenCV Application Tracing support demo. */
+#include <iostream>
+
+#include <opencv2/opencv.hpp>
+#include <opencv2/core/utils/trace.hpp>
+
+using namespace cv;
+using namespace std;
+
+static void process_frame(const cv::UMat& frame)
+{
+ CV_TRACE_FUNCTION(); // OpenCV Trace macro for function
+
+ imshow("Live", frame);
+
+ UMat gray, processed;
+ cv::cvtColor(frame, gray, COLOR_BGR2GRAY);
+ Canny(gray, processed, 32, 64, 3);
+ imshow("Processed", processed);
+}
+
+int main(int argc, char** argv)
+{
+ CV_TRACE_FUNCTION();
+
+ cv::CommandLineParser parser(argc, argv,
+ "{help h ? | | help message}"
+ "{n | 100 | number of frames to process }"
+ "{@video | 0 | video filename or cameraID }"
+ );
+ if (parser.has("help"))
+ {
+ parser.printMessage();
+ return 0;
+ }
+
+ VideoCapture capture;
+ std::string video = parser.get<string>("@video");
+ if (video.size() == 1 && isdigit(video[0]))
+ capture.open(parser.get<int>("@video"));
+ else
+ capture.open(video);
+ int nframes = 0;
+ if (capture.isOpened())
+ {
+ nframes = (int)capture.get(CAP_PROP_FRAME_COUNT);
+ cout << "Video " << video <<
+ ": width=" << capture.get(CAP_PROP_FRAME_WIDTH) <<
+ ", height=" << capture.get(CAP_PROP_FRAME_HEIGHT) <<
+ ", nframes=" << nframes << endl;
+ }
+ else
+ {
+ cout << "Could not initialize video capturing...\n";
+ return -1;
+ }
+
+ int N = parser.get<int>("n");
+ if (nframes > 0 && N > nframes)
+ N = nframes;
+
+ cout << "Start processing..." << endl
+ << "Press ESC key to terminate" << endl;
+
+ UMat frame;
+ for (int i = 0; N > 0 ? (i < N) : true; i++)
+ {
+ CV_TRACE_REGION("FRAME"); // OpenCV Trace macro for named "scope" region
+ {
+ CV_TRACE_REGION("read");
+ capture.read(frame);
+
+ if (frame.empty())
+ {
+ cerr << "Can't capture frame: " << i << std::endl;
+ break;
+ }
+
+ // OpenCV Trace macro for NEXT named region in the same C++ scope
+ // Previous "read" region will be marked complete on this line.
+ // Use this to eliminate unnecessary curly braces.
+ CV_TRACE_REGION_NEXT("process");
+ process_frame(frame);
+
+ CV_TRACE_REGION_NEXT("delay");
+ if (waitKey(1) == 27/*ESC*/)
+ break;
+ }
+ }
+
+ return 0;
+}
diff --git a/samples/cpp/create_mask.cpp b/samples/cpp/create_mask.cpp
index 7d6a61c..c87d0fd 100644
--- a/samples/cpp/create_mask.cpp
+++ b/samples/cpp/create_mask.cpp
@@ -33,8 +33,6 @@ int flag1 = 0;
int minx,miny,maxx,maxy,lenx,leny;
-int channel;
-
void mouseHandler(int, int, int, int, void*);
void mouseHandler(int event, int x, int y, int, void*)
@@ -121,14 +119,22 @@ void mouseHandler(int event, int x, int y, int, void*)
}
}
+static void help()
+{
+ cout << "\nThis program demonstrates using mouse events"
+ "\nCall:\n"
+ "./create_mask <image_name>\n"
+ "\n"
+ "\tleft mouse button - set a point to create mask shape"
+ "\n"
+ "\tright mouse button - create mask from points\n"
+ "\tmiddle mouse button - reset\n" << endl;
+}
+
int main(int argc, char **argv)
{
- cv::CommandLineParser parser(argc, argv, "{help h | | show help message}{@input | | input image}");
- if (parser.has("help"))
- {
- parser.printMessage();
- return 0;
- }
+ cv::CommandLineParser parser(argc, argv, "{@input | ../data/lena.jpg | input image}");
+ help();
string input_image = parser.get<string>("@input");
if (input_image.empty())
{
@@ -143,8 +149,6 @@ int main(int argc, char **argv)
img0 = src;
- channel = img0.channels();
-
res1 = Mat::zeros(img0.size(),CV_8UC1);
final = Mat::zeros(img0.size(),CV_8UC3);
//////////// source image ///////////////////
@@ -154,6 +158,5 @@ int main(int argc, char **argv)
imshow("Source", img0);
waitKey(0);
- img0.release();
- img1.release();
+ return 0;
}
diff --git a/samples/cpp/detect_mser.cpp b/samples/cpp/detect_mser.cpp
index 04429cc..daa3708 100644
--- a/samples/cpp/detect_mser.cpp
+++ b/samples/cpp/detect_mser.cpp
@@ -6,7 +6,7 @@
#include <map>
#include <iostream>
#ifdef HAVE_OPENGL
-#ifdef WIN32
+#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN 1
#define NOMINMAX 1
#include <windows.h>
@@ -271,7 +271,7 @@ static void DrawOpenGLMSER(Mat img, Mat result)
data->tex.bind();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glDisable(GL_CULL_FACE);
setOpenGlDrawCallback("OpenGL", draw, data);
diff --git a/samples/cpp/drawing.cpp b/samples/cpp/drawing.cpp
index 236bcbc..93f09fe 100644
--- a/samples/cpp/drawing.cpp
+++ b/samples/cpp/drawing.cpp
@@ -2,6 +2,7 @@
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include <stdio.h>
+
using namespace cv;
static void help()
@@ -16,14 +17,9 @@ static Scalar randomColor(RNG& rng)
return Scalar(icolor&255, (icolor>>8)&255, (icolor>>16)&255);
}
-int main(int argc, char** argv)
+int main()
{
- cv::CommandLineParser parser(argc, argv, "{help h||}");
- if (parser.has("help"))
- {
- help();
- return 0;
- }
+ help();
char wndname[] = "Drawing Demo";
const int NUMBER = 100;
const int DELAY = 5;
@@ -36,7 +32,7 @@ int main(int argc, char** argv)
imshow(wndname, image);
waitKey(DELAY);
- for (i = 0; i < NUMBER; i++)
+ for (i = 0; i < NUMBER * 2; i++)
{
Point pt1, pt2;
pt1.x = rng.uniform(x1, x2);
@@ -44,14 +40,19 @@ int main(int argc, char** argv)
pt2.x = rng.uniform(x1, x2);
pt2.y = rng.uniform(y1, y2);
- line( image, pt1, pt2, randomColor(rng), rng.uniform(1,10), lineType );
+ int arrowed = rng.uniform(0, 6);
+
+ if( arrowed < 3 )
+ line( image, pt1, pt2, randomColor(rng), rng.uniform(1,10), lineType );
+ else
+ arrowedLine(image, pt1, pt2, randomColor(rng), rng.uniform(1, 10), lineType);
imshow(wndname, image);
if(waitKey(DELAY) >= 0)
return 0;
}
- for (i = 0; i < NUMBER; i++)
+ for (i = 0; i < NUMBER * 2; i++)
{
Point pt1, pt2;
pt1.x = rng.uniform(x1, x2);
@@ -59,8 +60,13 @@ int main(int argc, char** argv)
pt2.x = rng.uniform(x1, x2);
pt2.y = rng.uniform(y1, y2);
int thickness = rng.uniform(-3, 10);
+ int marker = rng.uniform(0, 10);
+ int marker_size = rng.uniform(30, 80);
- rectangle( image, pt1, pt2, randomColor(rng), MAX(thickness, -1), lineType );
+ if (marker > 5)
+ rectangle(image, pt1, pt2, randomColor(rng), MAX(thickness, -1), lineType);
+ else
+ drawMarker(image, pt1, randomColor(rng), marker, marker_size );
imshow(wndname, image);
if(waitKey(DELAY) >= 0)
@@ -181,7 +187,3 @@ int main(int argc, char** argv)
waitKey();
return 0;
}
-
-#ifdef _EiC
-main(1,"drawing.c");
-#endif
diff --git a/samples/cpp/edge.cpp b/samples/cpp/edge.cpp
index 4fbef93..78bc4b6 100644
--- a/samples/cpp/edge.cpp
+++ b/samples/cpp/edge.cpp
@@ -53,15 +53,11 @@ const char* keys =
int main( int argc, const char** argv )
{
+ help();
CommandLineParser parser(argc, argv, keys);
- if (parser.has("help"))
- {
- help();
- return 0;
- }
string filename = parser.get<string>(0);
- image = imread(filename, 1);
+ image = imread(filename, IMREAD_COLOR);
if(image.empty())
{
printf("Cannot read image file: %s\n", filename.c_str());
diff --git a/samples/cpp/falsecolor.cpp b/samples/cpp/falsecolor.cpp
new file mode 100644
index 0000000..3e62434
--- /dev/null
+++ b/samples/cpp/falsecolor.cpp
@@ -0,0 +1,150 @@
+#include <opencv2/opencv.hpp>
+
+using namespace cv;
+using namespace std;
+
+enum MyShape{MyCIRCLE=0,MyRECTANGLE,MyELLIPSE};
+
+struct ParamColorMar {
+ int iColormap;
+ Mat img;
+};
+
+Ptr<Mat> lutRND;
+String winName="False color";
+
+static void TrackColorMap(int x, void *r)
+{
+ ParamColorMar *p = (ParamColorMar*)r;
+ Mat dst;
+ p->iColormap= x;
+ if (x == cv::COLORMAP_PARULA + 1)
+ {
+ if (!lutRND)
+ {
+ RNG ra;
+ Mat *palette = new Mat(256, 1, CV_8UC3);
+ ra.fill(*palette, RNG::UNIFORM, 0, 256);
+ lutRND = Ptr<Mat>(palette);
+ }
+ applyColorMap(p->img, dst, *lutRND.get());
+ }
+ else
+ applyColorMap(p->img,dst,p->iColormap);
+ String colorMapName;
+
+ switch (p->iColormap) {
+ case COLORMAP_AUTUMN :
+ colorMapName = "Colormap : Autumn";
+ break;
+ case COLORMAP_BONE :
+ colorMapName = "Colormap : Bone";
+ break;
+ case COLORMAP_JET :
+ colorMapName = "Colormap : Jet";
+ break;
+ case COLORMAP_WINTER :
+ colorMapName = "Colormap : Winter";
+ break;
+ case COLORMAP_RAINBOW :
+ colorMapName = "Colormap : Rainbow";
+ break;
+ case COLORMAP_OCEAN :
+ colorMapName = "Colormap : Ocean";
+ break;
+ case COLORMAP_SUMMER :
+ colorMapName = "Colormap : Summer";
+ break;
+ case COLORMAP_SPRING :
+ colorMapName = "Colormap : Spring";
+ break;
+ case COLORMAP_COOL :
+ colorMapName = "Colormap : Cool";
+ break;
+ case COLORMAP_HSV :
+ colorMapName = "Colormap : HSV";
+ break;
+ case COLORMAP_PINK :
+ colorMapName = "Colormap : Pink";
+ break;
+ case COLORMAP_HOT :
+ colorMapName = "Colormap : Hot";
+ break;
+ case COLORMAP_PARULA :
+ colorMapName = "Colormap : Parula";
+ break;
+ default:
+ colorMapName = "User colormap : random";
+ break;
+ }
+ putText(dst, colorMapName, Point(10, 20), cv::FONT_HERSHEY_SIMPLEX, 1, Scalar(255, 255, 255));
+ imshow(winName, dst);
+}
+
+
+static Mat DrawMyImage(int thickness,int nbShape)
+{
+ Mat img=Mat::zeros(500,256*thickness+100,CV_8UC1);
+ int offsetx = 50, offsety = 25;
+ int lineLenght = 50;
+
+ for (int i=0;i<256;i++)
+ line(img,Point(thickness*i+ offsetx, offsety),Point(thickness*i+ offsetx, offsety+ lineLenght),Scalar(i), thickness);
+ RNG r;
+ Point center;
+ int radius;
+ int width,height;
+ int angle;
+ Rect rc;
+
+ for (int i=1;i<=nbShape;i++)
+ {
+ int typeShape = r.uniform(MyCIRCLE, MyELLIPSE+1);
+ switch (typeShape) {
+ case MyCIRCLE:
+ center = Point(r.uniform(offsetx,img.cols- offsetx), r.uniform(offsety + lineLenght, img.rows - offsety));
+ radius = r.uniform(1, min(offsetx, offsety));
+ circle(img,center,radius,Scalar(i),-1);
+ break;
+ case MyRECTANGLE:
+ center = Point(r.uniform(offsetx, img.cols - offsetx), r.uniform(offsety + lineLenght, img.rows - offsety));
+ width = r.uniform(1, min(offsetx, offsety));
+ height = r.uniform(1, min(offsetx, offsety));
+ rc = Rect(center-Point(width ,height )/2, center + Point(width , height )/2);
+ rectangle(img,rc, Scalar(i), -1);
+ break;
+ case MyELLIPSE:
+ center = Point(r.uniform(offsetx, img.cols - offsetx), r.uniform(offsety + lineLenght, img.rows - offsety));
+ width = r.uniform(1, min(offsetx, offsety));
+ height = r.uniform(1, min(offsetx, offsety));
+ angle = r.uniform(0, 180);
+ ellipse(img, center,Size(width/2,height/2),angle,0,360, Scalar(i), -1);
+ break;
+ }
+ }
+ return img;
+}
+
+int main(int argc, char** argv)
+{
+ ParamColorMar p;
+
+ Mat img;
+ if (argc > 1)
+ img = imread(argv[1], 0);
+ else
+ img = DrawMyImage(2,256);
+ p.img=img;
+ p.iColormap=0;
+
+ imshow("Gray image",img);
+ namedWindow(winName);
+ createTrackbar("colormap", winName,&p.iColormap,1,TrackColorMap,(void*)&p);
+ setTrackbarMin("colormap", winName, cv::COLORMAP_AUTUMN);
+ setTrackbarMax("colormap", winName, cv::COLORMAP_PARULA+1);
+ setTrackbarPos("colormap", winName, -1);
+
+ TrackColorMap(0,(void*)&p);
+ waitKey(0);
+ return 0;
+}
diff --git a/samples/cpp/grabcut.cpp b/samples/cpp/grabcut.cpp
index 54edbf6..c5b68fc 100644
--- a/samples/cpp/grabcut.cpp
+++ b/samples/cpp/grabcut.cpp
@@ -276,12 +276,9 @@ static void on_mouse( int event, int x, int y, int flags, void* param )
int main( int argc, char** argv )
{
- cv::CommandLineParser parser(argc, argv, "{help h||}{@input||}");
- if (parser.has("help"))
- {
- help();
- return 0;
- }
+ cv::CommandLineParser parser(argc, argv, "{@input| ../data/messi5.jpg |}");
+ help();
+
string filename = parser.get<string>("@input");
if( filename.empty() )
{
@@ -295,8 +292,6 @@ int main( int argc, char** argv )
return 1;
}
- help();
-
const string winName = "image";
namedWindow( winName, WINDOW_AUTOSIZE );
setMouseCallback( winName, on_mouse, 0 );
diff --git a/samples/cpp/image_alignment.cpp b/samples/cpp/image_alignment.cpp
index c62a160..2f0aa50 100644
--- a/samples/cpp/image_alignment.cpp
+++ b/samples/cpp/image_alignment.cpp
@@ -51,7 +51,7 @@ const std::string keys =
"{e epsilon | 0.0001 | ECC's convergence epsilon }"
"{o outputWarp | outWarp.ecc | output warp (matrix) filename }"
"{m motionType | affine | type of motion (translation, euclidean, affine, homography) }"
- "{v verbose | 0 | display initial and final images }"
+ "{v verbose | 1 | display initial and final images }"
"{w warpedImfile | warpedECC.png | warped input image }"
"{h help | | print help message }"
;
@@ -165,10 +165,10 @@ static void draw_warped_roi(Mat& image, const int width, const int height, Mat&
GET_HOMO_VALUES(U, bottom_right.x, bottom_right.y);
// draw the warped perimeter
- line(image, top_left, top_right, Scalar(255,0,255));
- line(image, top_right, bottom_right, Scalar(255,0,255));
- line(image, bottom_right, bottom_left, Scalar(255,0,255));
- line(image, bottom_left, top_left, Scalar(255,0,255));
+ line(image, top_left, top_right, Scalar(255));
+ line(image, top_right, bottom_right, Scalar(255));
+ line(image, bottom_right, bottom_left, Scalar(255));
+ line(image, bottom_left, top_left, Scalar(255));
}
int main (const int argc, const char * argv[])
@@ -177,17 +177,9 @@ int main (const int argc, const char * argv[])
CommandLineParser parser(argc, argv, keys);
parser.about("ECC demo");
- if (argc < 2) {
- parser.printMessage();
- help();
- return 1;
- }
- if (parser.has("help"))
- {
- parser.printMessage();
- help();
- return 1;
- }
+ parser.printMessage();
+ help();
+
string imgFile = parser.get<string>(0);
string tempImgFile = parser.get<string>(1);
string inWarpFile = parser.get<string>(2);
@@ -239,10 +231,10 @@ int main (const int argc, const char * argv[])
}
}
- else{ //apply random waro to input image
+ else{ //apply random warp to input image
resize(inputImage, target_image, Size(216, 216));
Mat warpGround;
- cv::RNG rng;
+ RNG rng(getTickCount());
double angle;
switch (mode_temp) {
case MOTION_TRANSLATION:
@@ -299,7 +291,7 @@ int main (const int argc, const char * argv[])
}
else {
- printf("\n ->Perfomarnce Warning: Identity warp ideally assumes images of "
+ printf("\n ->Performance Warning: Identity warp ideally assumes images of "
"similar size. If the deformation is strong, the identity warp may not "
"be a good initialization. \n");
@@ -363,7 +355,8 @@ int main (const int argc, const char * argv[])
namedWindow ("warped image", WINDOW_AUTOSIZE);
namedWindow ("error (black: no error)", WINDOW_AUTOSIZE);
- moveWindow ("template", 350, 350);
+ moveWindow ("image", 20, 300);
+ moveWindow ("template", 300, 300);
moveWindow ("warped image", 600, 300);
moveWindow ("error (black: no error)", 900, 300);
diff --git a/samples/cpp/image_sequence.cpp b/samples/cpp/image_sequence.cpp
index 6a84fab..ac99f78 100644
--- a/samples/cpp/image_sequence.cpp
+++ b/samples/cpp/image_sequence.cpp
@@ -18,17 +18,12 @@ static void help(char** argv)
int main(int argc, char** argv)
{
- cv::CommandLineParser parser(argc, argv, "{help h||}{@image||}");
- if (parser.has("help"))
- {
- help(argv);
- return 0;
- }
+ help(argv);
+ cv::CommandLineParser parser(argc, argv, "{@image| ../data/left%02d.jpg |}");
string first_file = parser.get<string>("@image");
if(first_file.empty())
{
- help(argv);
return 1;
}
diff --git a/samples/cpp/inpaint.cpp b/samples/cpp/inpaint.cpp
index 86e6e37..61c4c45 100644
--- a/samples/cpp/inpaint.cpp
+++ b/samples/cpp/inpaint.cpp
@@ -47,12 +47,9 @@ static void onMouse( int event, int x, int y, int flags, void* )
int main( int argc, char** argv )
{
- cv::CommandLineParser parser(argc, argv, "{help h||}{@image|../data/fruits.jpg|}");
- if (parser.has("help"))
- {
- help();
- return 0;
- }
+ cv::CommandLineParser parser(argc, argv, "{@image|../data/fruits.jpg|}");
+ help();
+
string filename = parser.get<string>("@image");
Mat img0 = imread(filename, -1);
if(img0.empty())
diff --git a/samples/cpp/kmeans.cpp b/samples/cpp/kmeans.cpp
index e90ec2c..eeba97a 100644
--- a/samples/cpp/kmeans.cpp
+++ b/samples/cpp/kmeans.cpp
@@ -53,7 +53,7 @@ int main( int /*argc*/, char** /*argv*/ )
randShuffle(points, 1, &rng);
- kmeans(points, clusterCount, labels,
+ double compactness = kmeans(points, clusterCount, labels,
TermCriteria( TermCriteria::EPS+TermCriteria::COUNT, 10, 1.0),
3, KMEANS_PP_CENTERS, centers);
@@ -65,6 +65,12 @@ int main( int /*argc*/, char** /*argv*/ )
Point ipt = points.at<Point2f>(i);
circle( img, ipt, 2, colorTab[clusterIdx], FILLED, LINE_AA );
}
+ for (i = 0; i < centers.rows; ++i)
+ {
+ Point2f c = centers.at<Point2f>(i);
+ circle( img, c, 40, colorTab[i], 1, LINE_AA );
+ }
+ cout << "Compactness: " << compactness << endl;
imshow("clusters", img);
diff --git a/samples/cpp/laplace.cpp b/samples/cpp/laplace.cpp
index 958fccb..d50029c 100644
--- a/samples/cpp/laplace.cpp
+++ b/samples/cpp/laplace.cpp
@@ -26,12 +26,9 @@ int smoothType = GAUSSIAN;
int main( int argc, char** argv )
{
VideoCapture cap;
- cv::CommandLineParser parser(argc, argv, "{help h | | }{ c | 0 | }{ p | | }");
- if ( parser.has("help") )
- {
- help();
- return 0;
- }
+ cv::CommandLineParser parser(argc, argv, "{ c | 0 | }{ p | | }");
+ help();
+
if( parser.get<string>("c").size() == 1 && isdigit(parser.get<string>("c")[0]) )
cap.open(parser.get<int>("c"));
else
diff --git a/samples/cpp/letter_recog.cpp b/samples/cpp/letter_recog.cpp
index 0eb67d1..32ccf6b 100644
--- a/samples/cpp/letter_recog.cpp
+++ b/samples/cpp/letter_recog.cpp
@@ -521,7 +521,7 @@ int main( int argc, char *argv[] )
int method = 0;
cv::CommandLineParser parser(argc, argv, "{data|../data/letter-recognition.data|}{save||}{load||}{boost||}"
- "{mlp||}{knn knearest||}{nbayes||}{svm||}{help h||}");
+ "{mlp||}{knn knearest||}{nbayes||}{svm||}");
data_filename = parser.get<string>("data");
if (parser.has("save"))
filename_to_save = parser.get<string>("save");
@@ -537,11 +537,9 @@ int main( int argc, char *argv[] )
method = 4;
else if (parser.has("svm"))
method = 5;
- if (parser.has("help"))
- {
- help();
- return 0;
- }
+
+ help();
+
if( (method == 0 ?
build_rtrees_classifier( data_filename, filename_to_save, filename_to_load ) :
method == 1 ?
@@ -555,8 +553,6 @@ int main( int argc, char *argv[] )
method == 5 ?
build_svm_classifier( data_filename, filename_to_save, filename_to_load ):
-1) < 0)
- {
- help();
- }
+
return 0;
}
diff --git a/samples/cpp/lkdemo.cpp b/samples/cpp/lkdemo.cpp
index 5e57aa8..f8ba732 100644
--- a/samples/cpp/lkdemo.cpp
+++ b/samples/cpp/lkdemo.cpp
@@ -45,16 +45,11 @@ int main( int argc, char** argv )
bool needToInit = false;
bool nightMode = false;
- cv::CommandLineParser parser(argc, argv, "{@input||}{help h||}");
+ help();
+ cv::CommandLineParser parser(argc, argv, "{@input|0|}");
string input = parser.get<string>("@input");
- if (parser.has("help"))
- {
- help();
- return 0;
- }
- if( input.empty() )
- cap.open(0);
- else if( input.size() == 1 && isdigit(input[0]) )
+
+ if( input.size() == 1 && isdigit(input[0]) )
cap.open(input[0] - '0');
else
cap.open(input);
diff --git a/samples/cpp/mask_tmpl.cpp b/samples/cpp/mask_tmpl.cpp
index 6617783..b20c3ee 100644
--- a/samples/cpp/mask_tmpl.cpp
+++ b/samples/cpp/mask_tmpl.cpp
@@ -19,16 +19,12 @@ static void help()
int main( int argc, const char** argv )
{
+ help();
cv::CommandLineParser parser(argc, argv,
- "{help h||}"
"{ i | ../data/lena_tmpl.jpg | }"
"{ t | ../data/tmpl.png | }"
"{ m | ../data/mask.png | }");
- if (parser.has("help"))
- {
- help();
- return 0;
- }
+
string filename = parser.get<string>("i");
string tmplname = parser.get<string>("t");
string maskname = parser.get<string>("m");
diff --git a/samples/cpp/npr_demo.cpp b/samples/cpp/npr_demo.cpp
index 64a3e05..c343969 100644
--- a/samples/cpp/npr_demo.cpp
+++ b/samples/cpp/npr_demo.cpp
@@ -28,7 +28,7 @@ using namespace cv;
int main(int argc, char* argv[])
{
- cv::CommandLineParser parser(argc, argv, "{help h||show help message}{@image||input image}");
+ cv::CommandLineParser parser(argc, argv, "{help h||show help message}{@image|../data/lena.jpg|input image}");
if (parser.has("help"))
{
parser.printMessage();
diff --git a/samples/cpp/polar_transforms.cpp b/samples/cpp/polar_transforms.cpp
index adbc955..d860e27 100644
--- a/samples/cpp/polar_transforms.cpp
+++ b/samples/cpp/polar_transforms.cpp
@@ -53,14 +53,13 @@ int main( int argc, char** argv )
break;
Point2f center( (float)frame.cols / 2, (float)frame.rows / 2 );
- double radius = (double)frame.cols / 4;
- double M = (double)frame.cols / log(radius);
+ double M = 70;
logPolar(frame,log_polar_img, center, M, INTER_LINEAR + WARP_FILL_OUTLIERS);
- linearPolar(frame,lin_polar_img, center, radius, INTER_LINEAR + WARP_FILL_OUTLIERS);
+ linearPolar(frame,lin_polar_img, center, M, INTER_LINEAR + WARP_FILL_OUTLIERS);
logPolar(log_polar_img, recovered_log_polar, center, M, WARP_INVERSE_MAP + INTER_LINEAR);
- linearPolar(lin_polar_img, recovered_lin_polar_img, center, radius, WARP_INVERSE_MAP + INTER_LINEAR + WARP_FILL_OUTLIERS);
+ linearPolar(lin_polar_img, recovered_lin_polar_img, center, M, WARP_INVERSE_MAP + INTER_LINEAR + WARP_FILL_OUTLIERS);
imshow("Log-Polar", log_polar_img );
imshow("Linear-Polar", lin_polar_img );
diff --git a/samples/cpp/shape_example.cpp b/samples/cpp/shape_example.cpp
index cb6cfbe..120d947 100644
--- a/samples/cpp/shape_example.cpp
+++ b/samples/cpp/shape_example.cpp
@@ -115,6 +115,7 @@ int main(int argc, char** argv)
resize(iiIm, bestToShow, sz2Sh);
imshow("BEST MATCH", bestToShow);
moveWindow("BEST MATCH", sz2Sh.width+50,0);
+ waitKey();
return 0;
}
diff --git a/samples/cpp/tutorial_code/HighGUI/BasicLinearTransformsTrackbar.cpp b/samples/cpp/tutorial_code/HighGUI/BasicLinearTransformsTrackbar.cpp
index 1834e35..563e35d 100644
--- a/samples/cpp/tutorial_code/HighGUI/BasicLinearTransformsTrackbar.cpp
+++ b/samples/cpp/tutorial_code/HighGUI/BasicLinearTransformsTrackbar.cpp
@@ -40,10 +40,15 @@ static void on_trackbar( int, void* )
* @function main
* @brief Main function
*/
-int main( int, char** argv )
+int main( int argc, char** argv )
{
/// Read image given by user
- image = imread( argv[1] );
+ String imageName("../data/lena.jpg"); // by default
+ if (argc > 1)
+ {
+ imageName = argv[1];
+ }
+ image = imread( imageName );
/// Initialize values
alpha = 1;
@@ -54,8 +59,8 @@ int main( int, char** argv )
namedWindow("New Image", 1);
/// Create Trackbars
- createTrackbar( "Contrast Trackbar", "New Image", &alpha, alpha_max, on_trackbar );
- createTrackbar( "Brightness Trackbar", "New Image", &beta, beta_max, on_trackbar );
+ createTrackbar( "Contrast", "New Image", &alpha, alpha_max, on_trackbar );
+ createTrackbar( "Brightness", "New Image", &beta, beta_max, on_trackbar );
/// Show some stuff
imshow("Original Image", image);
diff --git a/samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp b/samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp
index 1042e2c..c60e45b 100644
--- a/samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp
+++ b/samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp
@@ -12,6 +12,7 @@
using namespace std;
using namespace cv;
+//! [declare]
/// Global Variables
bool use_mask;
Mat img; Mat templ; Mat mask; Mat result;
@@ -20,6 +21,7 @@ const char* result_window = "Result window";
int match_method;
int max_Trackbar = 5;
+//! [declare]
/// Function Headers
void MatchingMethod( int, void* );
@@ -36,6 +38,7 @@ int main( int argc, char** argv )
return -1;
}
+ //! [load_image]
/// Load image and template
img = imread( argv[1], IMREAD_COLOR );
templ = imread( argv[2], IMREAD_COLOR );
@@ -50,19 +53,26 @@ int main( int argc, char** argv )
cout << "Can't read one of the images" << endl;
return -1;
}
+ //! [load_image]
+ //! [create_windows]
/// Create windows
namedWindow( image_window, WINDOW_AUTOSIZE );
namedWindow( result_window, WINDOW_AUTOSIZE );
+ //! [create_windows]
+ //! [create_trackbar]
/// Create Trackbar
const char* trackbar_label = "Method: \n 0: SQDIFF \n 1: SQDIFF NORMED \n 2: TM CCORR \n 3: TM CCORR NORMED \n 4: TM COEFF \n 5: TM COEFF NORMED";
createTrackbar( trackbar_label, image_window, &match_method, max_Trackbar, MatchingMethod );
+ //! [create_trackbar]
MatchingMethod( 0, 0 );
+ //! [wait_key]
waitKey(0);
return 0;
+ //! [wait_key]
}
/**
@@ -71,44 +81,57 @@ int main( int argc, char** argv )
*/
void MatchingMethod( int, void* )
{
+ //! [copy_source]
/// Source image to display
Mat img_display;
img.copyTo( img_display );
+ //! [copy_source]
+ //! [create_result_matrix]
/// Create the result matrix
int result_cols = img.cols - templ.cols + 1;
int result_rows = img.rows - templ.rows + 1;
result.create( result_rows, result_cols, CV_32FC1 );
+ //! [create_result_matrix]
+ //! [match_template]
/// Do the Matching and Normalize
bool method_accepts_mask = (CV_TM_SQDIFF == match_method || match_method == CV_TM_CCORR_NORMED);
if (use_mask && method_accepts_mask)
{ matchTemplate( img, templ, result, match_method, mask); }
else
{ matchTemplate( img, templ, result, match_method); }
+ //! [match_template]
+ //! [normalize]
normalize( result, result, 0, 1, NORM_MINMAX, -1, Mat() );
+ //! [normalize]
+ //! [best_match]
/// Localizing the best match with minMaxLoc
double minVal; double maxVal; Point minLoc; Point maxLoc;
Point matchLoc;
minMaxLoc( result, &minVal, &maxVal, &minLoc, &maxLoc, Mat() );
+ //! [best_match]
-
+ //! [match_loc]
/// For SQDIFF and SQDIFF_NORMED, the best matches are lower values. For all the other methods, the higher the better
if( match_method == TM_SQDIFF || match_method == TM_SQDIFF_NORMED )
{ matchLoc = minLoc; }
else
{ matchLoc = maxLoc; }
+ //! [match_loc]
+ //! [imshow]
/// Show me what you got
rectangle( img_display, matchLoc, Point( matchLoc.x + templ.cols , matchLoc.y + templ.rows ), Scalar::all(0), 2, 8, 0 );
rectangle( result, matchLoc, Point( matchLoc.x + templ.cols , matchLoc.y + templ.rows ), Scalar::all(0), 2, 8, 0 );
imshow( image_window, img_display );
imshow( result_window, result );
+ //! [imshow]
return;
}
diff --git a/samples/cpp/tutorial_code/ImgProc/BasicLinearTransforms.cpp b/samples/cpp/tutorial_code/ImgProc/BasicLinearTransforms.cpp
index b24451d..0f32554 100644
--- a/samples/cpp/tutorial_code/ImgProc/BasicLinearTransforms.cpp
+++ b/samples/cpp/tutorial_code/ImgProc/BasicLinearTransforms.cpp
@@ -8,51 +8,65 @@
#include "opencv2/highgui.hpp"
#include <iostream>
+using namespace std;
using namespace cv;
-double alpha; /**< Simple contrast control */
-int beta; /**< Simple brightness control */
-
/**
* @function main
* @brief Main function
*/
-int main( int, char** argv )
+int main( int argc, char** argv )
{
- /// Read image given by user
- Mat image = imread( argv[1] );
- Mat new_image = Mat::zeros( image.size(), image.type() );
-
- /// Initialize values
- std::cout<<" Basic Linear Transforms "<<std::endl;
- std::cout<<"-------------------------"<<std::endl;
- std::cout<<"* Enter the alpha value [1.0-3.0]: ";std::cin>>alpha;
- std::cout<<"* Enter the beta value [0-100]: "; std::cin>>beta;
-
-
- /// Do the operation new_image(i,j) = alpha*image(i,j) + beta
- /// Instead of these 'for' loops we could have used simply:
- /// image.convertTo(new_image, -1, alpha, beta);
- /// but we wanted to show you how to access the pixels :)
- for( int y = 0; y < image.rows; y++ )
- { for( int x = 0; x < image.cols; x++ )
- { for( int c = 0; c < 3; c++ )
- {
- new_image.at<Vec3b>(y,x)[c] = saturate_cast<uchar>( alpha*( image.at<Vec3b>(y,x)[c] ) + beta );
- }
- }
- }
-
- /// Create Windows
- namedWindow("Original Image", 1);
- namedWindow("New Image", 1);
-
- /// Show stuff
- imshow("Original Image", image);
- imshow("New Image", new_image);
-
-
- /// Wait until user press some key
- waitKey();
- return 0;
+ //! [basic-linear-transform-parameters]
+ double alpha = 1.0; /*< Simple contrast control */
+ int beta = 0; /*< Simple brightness control */
+ //! [basic-linear-transform-parameters]
+
+ /// Read image given by user
+ //! [basic-linear-transform-load]
+ String imageName("../data/lena.jpg"); // by default
+ if (argc > 1)
+ {
+ imageName = argv[1];
+ }
+ Mat image = imread( imageName );
+ //! [basic-linear-transform-load]
+ //! [basic-linear-transform-output]
+ Mat new_image = Mat::zeros( image.size(), image.type() );
+ //! [basic-linear-transform-output]
+
+ /// Initialize values
+ cout << " Basic Linear Transforms " << endl;
+ cout << "-------------------------" << endl;
+ cout << "* Enter the alpha value [1.0-3.0]: "; cin >> alpha;
+ cout << "* Enter the beta value [0-100]: "; cin >> beta;
+
+ /// Do the operation new_image(i,j) = alpha*image(i,j) + beta
+ /// Instead of these 'for' loops we could have used simply:
+ /// image.convertTo(new_image, -1, alpha, beta);
+ /// but we wanted to show you how to access the pixels :)
+ //! [basic-linear-transform-operation]
+ for( int y = 0; y < image.rows; y++ ) {
+ for( int x = 0; x < image.cols; x++ ) {
+ for( int c = 0; c < 3; c++ ) {
+ new_image.at<Vec3b>(y,x)[c] =
+ saturate_cast<uchar>( alpha*( image.at<Vec3b>(y,x)[c] ) + beta );
+ }
+ }
+ }
+ //! [basic-linear-transform-operation]
+
+ //! [basic-linear-transform-display]
+ /// Create Windows
+ namedWindow("Original Image", WINDOW_AUTOSIZE);
+ namedWindow("New Image", WINDOW_AUTOSIZE);
+
+ /// Show stuff
+ imshow("Original Image", image);
+ imshow("New Image", new_image);
+
+ /// Wait until user press some key
+ waitKey();
+ //! [basic-linear-transform-display]
+ return 0;
}
diff --git a/samples/cpp/tutorial_code/ImgProc/HitMiss.cpp b/samples/cpp/tutorial_code/ImgProc/HitMiss.cpp
new file mode 100644
index 0000000..c2c3e1d
--- /dev/null
+++ b/samples/cpp/tutorial_code/ImgProc/HitMiss.cpp
@@ -0,0 +1,37 @@
+#include <opencv2/core.hpp>
+#include <opencv2/imgproc.hpp>
+#include <opencv2/highgui.hpp>
+
+using namespace cv;
+
+int main(){
+ Mat input_image = (Mat_<uchar>(8, 8) <<
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 255, 255, 255, 0, 0, 0, 255,
+ 0, 255, 255, 255, 0, 0, 0, 0,
+ 0, 255, 255, 255, 0, 255, 0, 0,
+ 0, 0, 255, 0, 0, 0, 0, 0,
+ 0, 0, 255, 0, 0, 255, 255, 0,
+ 0, 255, 0, 255, 0, 0, 255, 0,
+ 0, 255, 255, 255, 0, 0, 0, 0);
+
+ Mat kernel = (Mat_<int>(3, 3) <<
+ 0, 1, 0,
+ 1, -1, 1,
+ 0, 1, 0);
+
+ Mat output_image;
+ morphologyEx(input_image, output_image, MORPH_HITMISS, kernel);
+
+ const int rate = 10;
+ kernel = (kernel + 1) * 127;
+ kernel.convertTo(kernel, CV_8U);
+ resize(kernel, kernel, Size(), rate, rate, INTER_NEAREST);
+ imshow("kernel", kernel);
+ resize(input_image, input_image, Size(), rate, rate, INTER_NEAREST);
+ imshow("Original", input_image);
+ resize(output_image, output_image, Size(), rate, rate, INTER_NEAREST);
+ imshow("Hit or Miss", output_image);
+ waitKey(0);
+ return 0;
+}
diff --git a/samples/cpp/tutorial_code/ImgProc/Morphology_2.cpp b/samples/cpp/tutorial_code/ImgProc/Morphology_2.cpp
index 7a8fb57..6f843f6 100644
--- a/samples/cpp/tutorial_code/ImgProc/Morphology_2.cpp
+++ b/samples/cpp/tutorial_code/ImgProc/Morphology_2.cpp
@@ -29,10 +29,15 @@ void Morphology_Operations( int, void* );
/**
* @function main
*/
-int main( int, char** argv )
+int main( int argc, char** argv )
{
//![load]
- src = imread( argv[1], IMREAD_COLOR ); // Load an image
+ String imageName("../data/baboon.jpg"); // by default
+ if (argc > 1)
+ {
+ imageName = argv[1];
+ }
+ src = imread(imageName, IMREAD_COLOR); // Load an image
if( src.empty() )
{ return -1; }
diff --git a/samples/cpp/tutorial_code/ImgProc/Threshold.cpp b/samples/cpp/tutorial_code/ImgProc/Threshold.cpp
index d057ebc..c127b7d 100644
--- a/samples/cpp/tutorial_code/ImgProc/Threshold.cpp
+++ b/samples/cpp/tutorial_code/ImgProc/Threshold.cpp
@@ -30,10 +30,15 @@ void Threshold_Demo( int, void* );
/**
* @function main
*/
-int main( int, char** argv )
+int main( int argc, char** argv )
{
//! [load]
- src = imread( argv[1], IMREAD_COLOR ); // Load an image
+ String imageName("../data/stuff.jpg"); // by default
+ if (argc > 1)
+ {
+ imageName = argv[1];
+ }
+ src = imread( imageName, IMREAD_COLOR ); // Load an image
if( src.empty() )
{ return -1; }
diff --git a/samples/cpp/tutorial_code/ImgProc/changing_contrast_brightness_image/changing_contrast_brightness_image.cpp b/samples/cpp/tutorial_code/ImgProc/changing_contrast_brightness_image/changing_contrast_brightness_image.cpp
new file mode 100644
index 0000000..7ee22a2
--- /dev/null
+++ b/samples/cpp/tutorial_code/ImgProc/changing_contrast_brightness_image/changing_contrast_brightness_image.cpp
@@ -0,0 +1,98 @@
+#include <iostream>
+#include "opencv2/imgcodecs.hpp"
+#include "opencv2/highgui.hpp"
+
+using namespace std;
+using namespace cv;
+
+namespace
+{
+/** Global Variables */
+int alpha = 100;
+int beta = 100;
+int gamma_cor = 100;
+Mat img_original, img_corrected, img_gamma_corrected;
+
+void basicLinearTransform(const Mat &img, const double alpha_, const int beta_)
+{
+ Mat res;
+ img.convertTo(res, -1, alpha_, beta_);
+
+ hconcat(img, res, img_corrected);
+}
+
+void gammaCorrection(const Mat &img, const double gamma_)
+{
+ CV_Assert(gamma_ >= 0);
+ //![changing-contrast-brightness-gamma-correction]
+ Mat lookUpTable(1, 256, CV_8U);
+ uchar* p = lookUpTable.ptr();
+ for( int i = 0; i < 256; ++i)
+ p[i] = saturate_cast<uchar>(pow(i / 255.0, gamma_) * 255.0);
+
+ Mat res = img.clone();
+ LUT(img, lookUpTable, res);
+ //![changing-contrast-brightness-gamma-correction]
+
+ hconcat(img, res, img_gamma_corrected);
+}
+
+void on_linear_transform_alpha_trackbar(int, void *)
+{
+ double alpha_value = alpha / 100.0;
+ int beta_value = beta - 100;
+ basicLinearTransform(img_original, alpha_value, beta_value);
+}
+
+void on_linear_transform_beta_trackbar(int, void *)
+{
+ double alpha_value = alpha / 100.0;
+ int beta_value = beta - 100;
+ basicLinearTransform(img_original, alpha_value, beta_value);
+}
+
+void on_gamma_correction_trackbar(int, void *)
+{
+ double gamma_value = gamma_cor / 100.0;
+ gammaCorrection(img_original, gamma_value);
+}
+}
+
+int main( int argc, char** argv )
+{
+
+ String imageName("../data/lena.jpg"); // by default
+ if (argc > 1)
+ {
+ imageName = argv[1];
+ }
+
+ img_original = imread( imageName );
+ img_corrected = Mat(img_original.rows, img_original.cols*2, img_original.type());
+ img_gamma_corrected = Mat(img_original.rows, img_original.cols*2, img_original.type());
+
+ hconcat(img_original, img_original, img_corrected);
+ hconcat(img_original, img_original, img_gamma_corrected);
+
+ namedWindow("Brightness and contrast adjustments", WINDOW_AUTOSIZE);
+ namedWindow("Gamma correction", WINDOW_AUTOSIZE);
+
+ createTrackbar("Alpha gain (contrast)", "Brightness and contrast adjustments", &alpha, 500, on_linear_transform_alpha_trackbar);
+ createTrackbar("Beta bias (brightness)", "Brightness and contrast adjustments", &beta, 200, on_linear_transform_beta_trackbar);
+ createTrackbar("Gamma correction", "Gamma correction", &gamma_cor, 200, on_gamma_correction_trackbar);
+
+ while (true)
+ {
+ imshow("Brightness and contrast adjustments", img_corrected);
+ imshow("Gamma correction", img_gamma_corrected);
+
+ int c = waitKey(30);
+ if (c == 27)
+ break;
+ }
+
+ imwrite("linear_transform_correction.png", img_corrected);
+ imwrite("gamma_correction.png", img_gamma_corrected);
+
+ return 0;
+}
diff --git a/samples/cpp/tutorial_code/ImgTrans/HoughCircle_Demo.cpp b/samples/cpp/tutorial_code/ImgTrans/HoughCircle_Demo.cpp
index 2911b9d..604b57f 100644
--- a/samples/cpp/tutorial_code/ImgTrans/HoughCircle_Demo.cpp
+++ b/samples/cpp/tutorial_code/ImgTrans/HoughCircle_Demo.cpp
@@ -21,7 +21,7 @@ namespace
const std::string usage = "Usage : tutorial_HoughCircle_Demo <path_to_input_image>\n";
// initial and max values of the parameters of interests.
- const int cannyThresholdInitialValue = 200;
+ const int cannyThresholdInitialValue = 100;
const int accumulatorThresholdInitialValue = 50;
const int maxAccumulatorThreshold = 200;
const int maxCannyThreshold = 255;
@@ -55,15 +55,13 @@ int main(int argc, char** argv)
{
Mat src, src_gray;
- if (argc < 2)
+ // Read the image
+ String imageName("../data/stuff.jpg"); // by default
+ if (argc > 1)
{
- std::cerr<<"No input image specified\n";
- std::cout<<usage;
- return -1;
+ imageName = argv[1];
}
-
- // Read the image
- src = imread( argv[1], IMREAD_COLOR );
+ src = imread( imageName, IMREAD_COLOR );
if( src.empty() )
{
diff --git a/samples/cpp/tutorial_code/ImgTrans/HoughLines_Demo.cpp b/samples/cpp/tutorial_code/ImgTrans/HoughLines_Demo.cpp
index 5610cfe..213d07c 100644
--- a/samples/cpp/tutorial_code/ImgTrans/HoughLines_Demo.cpp
+++ b/samples/cpp/tutorial_code/ImgTrans/HoughLines_Demo.cpp
@@ -35,10 +35,15 @@ void Probabilistic_Hough( int, void* );
/**
* @function main
*/
-int main( int, char** argv )
+int main( int argc, char** argv )
{
- /// Read the image
- src = imread( argv[1], IMREAD_COLOR );
+ // Read the image
+ String imageName("../data/building.jpg"); // by default
+ if (argc > 1)
+ {
+ imageName = argv[1];
+ }
+ src = imread( imageName, IMREAD_COLOR );
if( src.empty() )
{ help();
diff --git a/samples/cpp/tutorial_code/ImgTrans/Laplace_Demo.cpp b/samples/cpp/tutorial_code/ImgTrans/Laplace_Demo.cpp
index 6a41c3a..0f56c49 100644
--- a/samples/cpp/tutorial_code/ImgTrans/Laplace_Demo.cpp
+++ b/samples/cpp/tutorial_code/ImgTrans/Laplace_Demo.cpp
@@ -13,7 +13,7 @@ using namespace cv;
/**
* @function main
*/
-int main( int, char** argv )
+int main( int argc, char** argv )
{
//![variables]
Mat src, src_gray, dst;
@@ -25,7 +25,12 @@ int main( int, char** argv )
//![variables]
//![load]
- src = imread( argv[1], IMREAD_COLOR ); // Load an image
+ String imageName("../data/lena.jpg"); // by default
+ if (argc > 1)
+ {
+ imageName = argv[1];
+ }
+ src = imread( imageName, IMREAD_COLOR ); // Load an image
if( src.empty() )
{ return -1; }
diff --git a/samples/cpp/tutorial_code/ImgTrans/Remap_Demo.cpp b/samples/cpp/tutorial_code/ImgTrans/Remap_Demo.cpp
index afe7024..4cc3bb8 100644
--- a/samples/cpp/tutorial_code/ImgTrans/Remap_Demo.cpp
+++ b/samples/cpp/tutorial_code/ImgTrans/Remap_Demo.cpp
@@ -23,10 +23,12 @@ void update_map( void );
/**
* @function main
*/
-int main( int, char** argv )
+int main(int argc, const char** argv)
{
/// Load the image
- src = imread( argv[1], IMREAD_COLOR );
+ CommandLineParser parser(argc, argv, "{@image |../data/chicky_512.png|input image name}");
+ std::string filename = parser.get<std::string>(0);
+ src = imread( filename, IMREAD_COLOR );
/// Create dst, map_x and map_y with the same size as src:
dst.create( src.size(), src.type() );
diff --git a/samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp b/samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp
index ad45452..d5a3776 100644
--- a/samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp
+++ b/samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp
@@ -13,7 +13,7 @@ using namespace cv;
/**
* @function main
*/
-int main( int, char** argv )
+int main( int argc, char** argv )
{
//![variables]
Mat src, src_gray;
@@ -25,7 +25,12 @@ int main( int, char** argv )
//![variables]
//![load]
- src = imread( argv[1], IMREAD_COLOR ); // Load an image
+ String imageName("../data/lena.jpg"); // by default
+ if (argc > 1)
+ {
+ imageName = argv[1];
+ }
+ src = imread( imageName, IMREAD_COLOR ); // Load an image
if( src.empty() )
{ return -1; }
diff --git a/samples/cpp/tutorial_code/ImgTrans/copyMakeBorder_demo.cpp b/samples/cpp/tutorial_code/ImgTrans/copyMakeBorder_demo.cpp
index 3b9ad0d..ca78078 100644
--- a/samples/cpp/tutorial_code/ImgTrans/copyMakeBorder_demo.cpp
+++ b/samples/cpp/tutorial_code/ImgTrans/copyMakeBorder_demo.cpp
@@ -21,10 +21,15 @@ RNG rng(12345);
/**
* @function main
*/
-int main( int, char** argv )
+int main( int argc, char** argv )
{
//![load]
- src = imread( argv[1], IMREAD_COLOR ); // Load an image
+ String imageName("../data/lena.jpg"); // by default
+ if (argc > 1)
+ {
+ imageName = argv[1];
+ }
+ src = imread( imageName, IMREAD_COLOR ); // Load an image
if( src.empty() )
{
diff --git a/samples/cpp/tutorial_code/ImgTrans/filter2D_demo.cpp b/samples/cpp/tutorial_code/ImgTrans/filter2D_demo.cpp
index 81a6fc0..24aef46 100644
--- a/samples/cpp/tutorial_code/ImgTrans/filter2D_demo.cpp
+++ b/samples/cpp/tutorial_code/ImgTrans/filter2D_demo.cpp
@@ -13,7 +13,7 @@ using namespace cv;
/**
* @function main
*/
-int main ( int, char** argv )
+int main ( int argc, char** argv )
{
/// Declare variables
Mat src, dst;
@@ -26,7 +26,12 @@ int main ( int, char** argv )
const char* window_name = "filter2D Demo";
//![load]
- src = imread( argv[1], IMREAD_COLOR ); // Load an image
+ String imageName("../data/lena.jpg"); // by default
+ if (argc > 1)
+ {
+ imageName = argv[1];
+ }
+ src = imread( imageName, IMREAD_COLOR ); // Load an image
if( src.empty() )
{ return -1; }
diff --git a/samples/cpp/tutorial_code/ImgTrans/imageSegmentation.cpp b/samples/cpp/tutorial_code/ImgTrans/imageSegmentation.cpp
index 424a490..01783cc 100644
--- a/samples/cpp/tutorial_code/ImgTrans/imageSegmentation.cpp
+++ b/samples/cpp/tutorial_code/ImgTrans/imageSegmentation.cpp
@@ -10,11 +10,11 @@
using namespace std;
using namespace cv;
-int main(int, char** argv)
+int main()
{
//! [load_image]
// Load the image
- Mat src = imread(argv[1]);
+ Mat src = imread("../data/cards.png");
// Check if everything was fine
if (!src.data)
diff --git a/samples/cpp/tutorial_code/ShapeDescriptors/findContours_demo.cpp b/samples/cpp/tutorial_code/ShapeDescriptors/findContours_demo.cpp
index b831441..233800e 100644
--- a/samples/cpp/tutorial_code/ShapeDescriptors/findContours_demo.cpp
+++ b/samples/cpp/tutorial_code/ShapeDescriptors/findContours_demo.cpp
@@ -23,10 +23,16 @@ void thresh_callback(int, void* );
/**
* @function main
*/
-int main( int, char** argv )
+int main( int argc, char** argv )
{
/// Load source image
- src = imread(argv[1], IMREAD_COLOR);
+ String imageName("../data/happyfish.jpg"); // by default
+ if (argc > 1)
+ {
+ imageName = argv[1];
+ }
+ src = imread(imageName, IMREAD_COLOR);
+
if (src.empty())
{
cerr << "No image supplied ..." << endl;
diff --git a/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp b/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp
index b5647b5..3524781 100644
--- a/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp
+++ b/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp
@@ -109,7 +109,7 @@ public:
}
else
{
- if (readStringList(input, imageList))
+ if (isListOfImages(input) && readStringList(input, imageList))
{
inputType = IMAGE_LIST;
nrFrames = (nrFrames < (int)imageList.size()) ? nrFrames : (int)imageList.size();
@@ -143,10 +143,11 @@ public:
if (useFisheye) {
// the fisheye model has its own enum, so overwrite the flags
flag = fisheye::CALIB_FIX_SKEW | fisheye::CALIB_RECOMPUTE_EXTRINSIC;
- if(fixK1) flag |= fisheye::CALIB_FIX_K1;
- if(fixK2) flag |= fisheye::CALIB_FIX_K2;
- if(fixK3) flag |= fisheye::CALIB_FIX_K3;
- if(fixK4) flag |= fisheye::CALIB_FIX_K4;
+ if(fixK1) flag |= fisheye::CALIB_FIX_K1;
+ if(fixK2) flag |= fisheye::CALIB_FIX_K2;
+ if(fixK3) flag |= fisheye::CALIB_FIX_K3;
+ if(fixK4) flag |= fisheye::CALIB_FIX_K4;
+ if (calibFixPrincipalPoint) flag |= fisheye::CALIB_FIX_PRINCIPAL_POINT;
}
calibrationPattern = NOT_EXISTING;
@@ -190,6 +191,16 @@ public:
l.push_back((string)*it);
return true;
}
+
+ static bool isListOfImages( const string& filename)
+ {
+ string s(filename);
+ // Look for file extension
+ if( s.find(".xml") == string::npos && s.find(".yaml") == string::npos && s.find(".yml") == string::npos )
+ return false;
+ else
+ return true;
+ }
public:
Size boardSize; // The size of the board -> Number of items by width and height
Pattern calibrationPattern; // One of the Chessboard, circles, or asymmetric circle pattern
diff --git a/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/PnPProblem.cpp b/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/PnPProblem.cpp
index 0978da9..a53250a 100644
--- a/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/PnPProblem.cpp
+++ b/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/PnPProblem.cpp
@@ -20,7 +20,7 @@ cv::Point3f SUB(cv::Point3f v1, cv::Point3f v2);
cv::Point3f get_nearest_3D_point(std::vector<cv::Point3f> &points_list, cv::Point3f origin);
-/* Functions for Möller–Trumbore intersection algorithm */
+/* Functions for Möller-Trumbore intersection algorithm */
cv::Point3f CROSS(cv::Point3f v1, cv::Point3f v2)
{
@@ -45,7 +45,7 @@ cv::Point3f SUB(cv::Point3f v1, cv::Point3f v2)
return tmp_p;
}
-/* End functions for Möller–Trumbore intersection algorithm
+/* End functions for Möller-Trumbore intersection algorithm
* */
// Function to get the nearest 3D point to the Ray origin
@@ -258,7 +258,7 @@ bool PnPProblem::backproject2DPoint(const Mesh *mesh, const cv::Point2f &point2d
}
}
-// Möller–Trumbore intersection algorithm
+// Möller-Trumbore intersection algorithm
bool PnPProblem::intersect_MollerTrumbore(Ray &Ray, Triangle &Triangle, double *out)
{
const double EPSILON = 0.000001;
diff --git a/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/PnPProblem.h b/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/PnPProblem.h
index 7add0ac..63d47c4 100644
--- a/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/PnPProblem.h
+++ b/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/PnPProblem.h
@@ -50,7 +50,7 @@ private:
cv::Mat _P_matrix;
};
-// Functions for Möller–Trumbore intersection algorithm
+// Functions for Möller-Trumbore intersection algorithm
cv::Point3f CROSS(cv::Point3f v1, cv::Point3f v2);
double DOT(cv::Point3f v1, cv::Point3f v2);
cv::Point3f SUB(cv::Point3f v1, cv::Point3f v2);
diff --git a/samples/cpp/tutorial_code/calib3d/stereoBM/SBM_Sample.cpp b/samples/cpp/tutorial_code/calib3d/stereoBM/SBM_Sample.cpp
index d114a95..e024b21 100644
--- a/samples/cpp/tutorial_code/calib3d/stereoBM/SBM_Sample.cpp
+++ b/samples/cpp/tutorial_code/calib3d/stereoBM/SBM_Sample.cpp
@@ -19,14 +19,13 @@ void readme();
* @function main
* @brief Main function
*/
-int main( int argc, char** argv )
+int main()
{
- if( argc != 3 )
- { readme(); return -1; }
+ readme();
//-- 1. Read the images
- Mat imgLeft = imread( argv[1], IMREAD_GRAYSCALE );
- Mat imgRight = imread( argv[2], IMREAD_GRAYSCALE );
+ Mat imgLeft = imread( "../data/rubberwhale1.png", IMREAD_GRAYSCALE );
+ Mat imgRight = imread( "../data/rubberwhale2.png", IMREAD_GRAYSCALE );
//-- And create the image in which we will save our disparities
Mat imgDisparity16S = Mat( imgLeft.rows, imgLeft.cols, CV_16S );
Mat imgDisparity8U = Mat( imgLeft.rows, imgLeft.cols, CV_8UC1 );
diff --git a/samples/cpp/tutorial_code/core/AddingImages/AddingImages.cpp b/samples/cpp/tutorial_code/core/AddingImages/AddingImages.cpp
index 491ae7a..4ddb6f0 100644
--- a/samples/cpp/tutorial_code/core/AddingImages/AddingImages.cpp
+++ b/samples/cpp/tutorial_code/core/AddingImages/AddingImages.cpp
@@ -9,6 +9,7 @@
#include <iostream>
using namespace cv;
+using namespace std;
/**
* @function main
@@ -21,23 +22,23 @@ int main( void )
Mat src1, src2, dst;
/// Ask the user enter alpha
- std::cout<<" Simple Linear Blender "<<std::endl;
- std::cout<<"-----------------------"<<std::endl;
- std::cout<<"* Enter alpha [0-1]: ";
- std::cin>>input;
+ cout << " Simple Linear Blender " << endl;
+ cout << "-----------------------" << endl;
+ cout << "* Enter alpha [0-1]: ";
+ cin >> input;
// We use the alpha provided by the user if it is between 0 and 1
- if( alpha >= 0 && alpha <= 1 )
+ if( input >= 0 && input <= 1 )
{ alpha = input; }
//![load]
/// Read images ( both have to be of the same size and type )
- src1 = imread("../data/LinuxLogo.jpg");
- src2 = imread("../data/WindowsLogo.jpg");
+ src1 = imread( "../data/LinuxLogo.jpg" );
+ src2 = imread( "../data/WindowsLogo.jpg" );
//![load]
- if( src1.empty() ) { std::cout<< "Error loading src1"<<std::endl; return -1; }
- if( src2.empty() ) { std::cout<< "Error loading src2"<<std::endl; return -1; }
+ if( src1.empty() ) { cout << "Error loading src1" << endl; return -1; }
+ if( src2.empty() ) { cout << "Error loading src2" << endl; return -1; }
//![blend_images]
beta = ( 1.0 - alpha );
diff --git a/samples/cpp/tutorial_code/core/how_to_use_OpenCV_parallel_for_/how_to_use_OpenCV_parallel_for_.cpp b/samples/cpp/tutorial_code/core/how_to_use_OpenCV_parallel_for_/how_to_use_OpenCV_parallel_for_.cpp
new file mode 100644
index 0000000..ed7d4a0
--- /dev/null
+++ b/samples/cpp/tutorial_code/core/how_to_use_OpenCV_parallel_for_/how_to_use_OpenCV_parallel_for_.cpp
@@ -0,0 +1,147 @@
+#include <iostream>
+#include <opencv2/core.hpp>
+#include <opencv2/imgcodecs.hpp>
+
+using namespace std;
+using namespace cv;
+
+namespace
+{
+//! [mandelbrot-escape-time-algorithm]
+int mandelbrot(const complex<float> &z0, const int max)
+{
+ complex<float> z = z0;
+ for (int t = 0; t < max; t++)
+ {
+ if (z.real()*z.real() + z.imag()*z.imag() > 4.0f) return t;
+ z = z*z + z0;
+ }
+
+ return max;
+}
+//! [mandelbrot-escape-time-algorithm]
+
+//! [mandelbrot-grayscale-value]
+int mandelbrotFormula(const complex<float> &z0, const int maxIter=500) {
+ int value = mandelbrot(z0, maxIter);
+ if(maxIter - value == 0)
+ {
+ return 0;
+ }
+
+ return cvRound(sqrt(value / (float) maxIter) * 255);
+}
+//! [mandelbrot-grayscale-value]
+
+//! [mandelbrot-parallel]
+class ParallelMandelbrot : public ParallelLoopBody
+{
+public:
+ ParallelMandelbrot (Mat &img, const float x1, const float y1, const float scaleX, const float scaleY)
+ : m_img(img), m_x1(x1), m_y1(y1), m_scaleX(scaleX), m_scaleY(scaleY)
+ {
+ }
+
+ virtual void operator ()(const Range& range) const
+ {
+ for (int r = range.start; r < range.end; r++)
+ {
+ int i = r / m_img.cols;
+ int j = r % m_img.cols;
+
+ float x0 = j / m_scaleX + m_x1;
+ float y0 = i / m_scaleY + m_y1;
+
+ complex<float> z0(x0, y0);
+ uchar value = (uchar) mandelbrotFormula(z0);
+ m_img.ptr<uchar>(i)[j] = value;
+ }
+ }
+
+ ParallelMandelbrot& operator=(const ParallelMandelbrot &) {
+ return *this;
+ };
+
+private:
+ Mat &m_img;
+ float m_x1;
+ float m_y1;
+ float m_scaleX;
+ float m_scaleY;
+};
+//! [mandelbrot-parallel]
+
+//! [mandelbrot-sequential]
+void sequentialMandelbrot(Mat &img, const float x1, const float y1, const float scaleX, const float scaleY)
+{
+ for (int i = 0; i < img.rows; i++)
+ {
+ for (int j = 0; j < img.cols; j++)
+ {
+ float x0 = j / scaleX + x1;
+ float y0 = i / scaleY + y1;
+
+ complex<float> z0(x0, y0);
+ uchar value = (uchar) mandelbrotFormula(z0);
+ img.ptr<uchar>(i)[j] = value;
+ }
+ }
+}
+//! [mandelbrot-sequential]
+}
+
+int main()
+{
+ //! [mandelbrot-transformation]
+ Mat mandelbrotImg(4800, 5400, CV_8U);
+ float x1 = -2.1f, x2 = 0.6f;
+ float y1 = -1.2f, y2 = 1.2f;
+ float scaleX = mandelbrotImg.cols / (x2 - x1);
+ float scaleY = mandelbrotImg.rows / (y2 - y1);
+ //! [mandelbrot-transformation]
+
+ double t1 = (double) getTickCount();
+
+ #ifdef CV_CXX11
+
+ //! [mandelbrot-parallel-call-cxx11]
+ parallel_for_(Range(0, mandelbrotImg.rows*mandelbrotImg.cols), [&](const Range& range){
+ for (int r = range.start; r < range.end; r++)
+ {
+ int i = r / mandelbrotImg.cols;
+ int j = r % mandelbrotImg.cols;
+
+ float x0 = j / scaleX + x1;
+ float y0 = i / scaleY + y1;
+
+ complex<float> z0(x0, y0);
+ uchar value = (uchar) mandelbrotFormula(z0);
+ mandelbrotImg.ptr<uchar>(i)[j] = value;
+ }
+ });
+ //! [mandelbrot-parallel-call-cxx11]
+
+ #else
+
+ //! [mandelbrot-parallel-call]
+ ParallelMandelbrot parallelMandelbrot(mandelbrotImg, x1, y1, scaleX, scaleY);
+ parallel_for_(Range(0, mandelbrotImg.rows*mandelbrotImg.cols), parallelMandelbrot);
+ //! [mandelbrot-parallel-call]
+
+ #endif
+
+ t1 = ((double) getTickCount() - t1) / getTickFrequency();
+ cout << "Parallel Mandelbrot: " << t1 << " s" << endl;
+
+ Mat mandelbrotImgSequential(4800, 5400, CV_8U);
+ double t2 = (double) getTickCount();
+ sequentialMandelbrot(mandelbrotImgSequential, x1, y1, scaleX, scaleY);
+ t2 = ((double) getTickCount() - t2) / getTickFrequency();
+ cout << "Sequential Mandelbrot: " << t2 << " s" << endl;
+ cout << "Speed-up: " << t2/t1 << " X" << endl;
+
+ imwrite("Mandelbrot_parallel.png", mandelbrotImg);
+ imwrite("Mandelbrot_sequential.png", mandelbrotImgSequential);
+
+ return EXIT_SUCCESS;
+}
diff --git a/samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp b/samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp
index 77ea938..d65e9b5 100644
--- a/samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp
+++ b/samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp
@@ -58,7 +58,13 @@ int main(int,char**)
Mat C = (Mat_<double>(3,3) << 0, -1, 0, -1, 5, -1, 0, -1, 0);
cout << "C = " << endl << " " << C << endl << endl;
//! [comma]
-
+ // do the same with initializer_list
+#ifdef CV_CXX11
+ //! [list]
+ C = (Mat_<double>({0, -1, 0, -1, 5, -1, 0, -1, 0})).reshape(3);
+ cout << "C = " << endl << " " << C << endl << endl;
+ //! [list]
+#endif
//! [clone]
Mat RowClone = C.row(1).clone();
cout << "RowClone = " << endl << " " << RowClone << endl << endl;
diff --git a/samples/cpp/tutorial_code/features2D/AKAZE_match.cpp b/samples/cpp/tutorial_code/features2D/AKAZE_match.cpp
index 7018b70..f0e0ff1 100755
--- a/samples/cpp/tutorial_code/features2D/AKAZE_match.cpp
+++ b/samples/cpp/tutorial_code/features2D/AKAZE_match.cpp
@@ -63,7 +63,7 @@ int main(void)
Mat res;
drawMatches(img1, inliers1, img2, inliers2, good_matches, res);
- imwrite("res.png", res);
+ imwrite("akaze_result.png", res);
double inlier_ratio = inliers1.size() * 1.0 / matched1.size();
cout << "A-KAZE Matching Results" << endl;
@@ -75,5 +75,8 @@ int main(void)
cout << "# Inliers Ratio: \t" << inlier_ratio << endl;
cout << endl;
+ imshow("result", res);
+ waitKey();
+
return 0;
}
diff --git a/samples/cpp/tutorial_code/features2D/AKAZE_tracking/planar_tracking.cpp b/samples/cpp/tutorial_code/features2D/AKAZE_tracking/planar_tracking.cpp
index 77bd9a6..e4673f8 100755
--- a/samples/cpp/tutorial_code/features2D/AKAZE_tracking/planar_tracking.cpp
+++ b/samples/cpp/tutorial_code/features2D/AKAZE_tracking/planar_tracking.cpp
@@ -120,27 +120,27 @@ Mat Tracker::process(const Mat frame, Stats& stats)
int main(int argc, char **argv)
{
- if(argc < 2) {
- cerr << "Usage: " << endl
- << "akaze_track input_path" << endl
- << " (input_path can be a camera id, like 0,1,2 or a video filename)" << endl;
- return 1;
- }
+ cerr << "Usage: " << endl
+ << "akaze_track input_path" << endl
+ << " (input_path can be a camera id, like 0,1,2 or a video filename)" << endl;
- std::string video_name = argv[1];
- std::stringstream ssFormat;
- ssFormat << atoi(argv[1]);
+ CommandLineParser parser(argc, argv, "{@input_path |0|input path can be a camera id, like 0,1,2 or a video filename}");
+ string input_path = parser.get<string>(0);
+ string video_name = input_path;
VideoCapture video_in;
- if (video_name.compare(ssFormat.str())==0) { //test str==str(num)
- video_in.open(atoi(argv[1]));
+
+ if ( ( isdigit(input_path[0]) && input_path.size() == 1 ) )
+ {
+ int camera_no = input_path[0] - '0';
+ video_in.open( camera_no );
}
else {
video_in.open(video_name);
}
if(!video_in.isOpened()) {
- cerr << "Couldn't open " << argv[1] << endl;
+ cerr << "Couldn't open " << video_name << endl;
return 1;
}
@@ -159,7 +159,7 @@ int main(int argc, char **argv)
cout << "Please select a bounding box, and press any key to continue." << endl;
vector<Point2f> bb;
- cv::Rect2d uBox = selectROI(video_name, frame);
+ cv::Rect uBox = cv::selectROI(video_name, frame);
bb.push_back(cv::Point2f(static_cast<float>(uBox.x), static_cast<float>(uBox.y)));
bb.push_back(cv::Point2f(static_cast<float>(uBox.x+uBox.width), static_cast<float>(uBox.y)));
bb.push_back(cv::Point2f(static_cast<float>(uBox.x+uBox.width), static_cast<float>(uBox.y+uBox.height)));
diff --git a/samples/cpp/tutorial_code/features2D/AKAZE_tracking/utils.h b/samples/cpp/tutorial_code/features2D/AKAZE_tracking/utils.h
index 2142e98..a3e9d7d 100644
--- a/samples/cpp/tutorial_code/features2D/AKAZE_tracking/utils.h
+++ b/samples/cpp/tutorial_code/features2D/AKAZE_tracking/utils.h
@@ -56,59 +56,4 @@ vector<Point2f> Points(vector<KeyPoint> keypoints)
}
return res;
}
-
-Rect2d selectROI(const String &video_name, const Mat &frame)
-{
- struct Data
- {
- Point center;
- Rect2d box;
-
- static void mouseHandler(int event, int x, int y, int flags, void *param)
- {
- Data *data = (Data*)param;
- switch( event )
- {
- // start to select the bounding box
- case EVENT_LBUTTONDOWN:
- data->box = cvRect( x, y, 0, 0 );
- data->center = Point2f((float)x,(float)y);
- break;
- // update the selected bounding box
- case EVENT_MOUSEMOVE:
- if(flags == 1)
- {
- data->box.width = 2 * (x - data->center.x);
- data->box.height = 2 * (y - data->center.y);
- data->box.x = data->center.x - data->box.width / 2.0;
- data->box.y = data->center.y - data->box.height / 2.0;
- }
- break;
- // cleaning up the selected bounding box
- case EVENT_LBUTTONUP:
- if( data->box.width < 0 )
- {
- data->box.x += data->box.width;
- data->box.width *= -1;
- }
- if( data->box.height < 0 )
- {
- data->box.y += data->box.height;
- data->box.height *= -1;
- }
- break;
- }
- }
- } data;
-
- setMouseCallback(video_name, Data::mouseHandler, &data);
- while(waitKey(1) < 0)
- {
- Mat draw = frame.clone();
- rectangle(draw, data.box, Scalar(255,0,0), 2, 1);
- imshow(video_name, draw);
- }
- return data.box;
-}
-
#endif // UTILS_H
diff --git a/samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp b/samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp
index 52f9e49..851b32c 100644
--- a/samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp
+++ b/samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp
@@ -73,7 +73,7 @@ double getOrientation(const vector<Point> &pts, Mat &img)
eigen_vecs[i] = Point2d(pca_analysis.eigenvectors.at<double>(i, 0),
pca_analysis.eigenvectors.at<double>(i, 1));
- eigen_val[i] = pca_analysis.eigenvalues.at<double>(0, i);
+ eigen_val[i] = pca_analysis.eigenvalues.at<double>(i);
}
//! [pca]
@@ -94,12 +94,16 @@ double getOrientation(const vector<Point> &pts, Mat &img)
/**
* @function main
*/
-int main(int, char** argv)
+int main(int argc, char** argv)
{
//! [pre-process]
// Load image
-// Mat src = imread("pca_test1.jpg");
- Mat src = imread(argv[1]);
+ String imageName("../data/pca_test1.jpg"); // by default
+ if (argc > 1)
+ {
+ imageName = argv[1];
+ }
+ Mat src = imread( imageName );
// Check if image is loaded successfully
if(!src.data || src.empty())
@@ -143,4 +147,4 @@ int main(int, char** argv)
waitKey(0);
return 0;
-}
\ No newline at end of file
+}
diff --git a/samples/cpp/tutorial_code/objectDetection/objectDetection.cpp b/samples/cpp/tutorial_code/objectDetection/objectDetection.cpp
index fe321ec..71097a8 100644
--- a/samples/cpp/tutorial_code/objectDetection/objectDetection.cpp
+++ b/samples/cpp/tutorial_code/objectDetection/objectDetection.cpp
@@ -13,15 +13,25 @@ using namespace cv;
void detectAndDisplay( Mat frame );
/** Global variables */
-String face_cascade_name = "haarcascade_frontalface_alt.xml";
-String eyes_cascade_name = "haarcascade_eye_tree_eyeglasses.xml";
+String face_cascade_name, eyes_cascade_name;
CascadeClassifier face_cascade;
CascadeClassifier eyes_cascade;
String window_name = "Capture - Face detection";
/** @function main */
-int main( void )
+int main( int argc, const char** argv )
{
+ CommandLineParser parser(argc, argv,
+ "{help h||}"
+ "{face_cascade|../../data/haarcascades/haarcascade_frontalface_alt.xml|}"
+ "{eyes_cascade|../../data/haarcascades/haarcascade_eye_tree_eyeglasses.xml|}");
+
+ cout << "\nThis program demonstrates using the cv::CascadeClassifier class to detect objects (Face + eyes) in a video stream.\n"
+ "You can use Haar or LBP features.\n\n";
+ parser.printMessage();
+
+ face_cascade_name = parser.get<string>("face_cascade");
+ eyes_cascade_name = parser.get<string>("eyes_cascade");
VideoCapture capture;
Mat frame;
@@ -30,7 +40,7 @@ int main( void )
if( !eyes_cascade.load( eyes_cascade_name ) ){ printf("--(!)Error loading eyes cascade\n"); return -1; };
//-- 2. Read the video stream
- capture.open( -1 );
+ capture.open( 0 );
if ( ! capture.isOpened() ) { printf("--(!)Error opening video capture\n"); return -1; }
while ( capture.read(frame) )
diff --git a/samples/cpp/tutorial_code/objectDetection/objectDetection2.cpp b/samples/cpp/tutorial_code/objectDetection/objectDetection2.cpp
deleted file mode 100644
index e57139b..0000000
--- a/samples/cpp/tutorial_code/objectDetection/objectDetection2.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * @file objectDetection2.cpp
- * @author A. Huaman ( based in the classic facedetect.cpp in samples/c )
- * @brief A simplified version of facedetect.cpp, show how to load a cascade classifier and how to find objects (Face + eyes) in a video stream - Using LBP here
- */
-#include "opencv2/objdetect.hpp"
-#include "opencv2/videoio.hpp"
-#include "opencv2/highgui.hpp"
-#include "opencv2/imgproc.hpp"
-
-#include <iostream>
-#include <stdio.h>
-
-using namespace std;
-using namespace cv;
-
-/** Function Headers */
-void detectAndDisplay( Mat frame );
-
-/** Global variables */
-String face_cascade_name = "lbpcascade_frontalface.xml";
-String eyes_cascade_name = "haarcascade_eye_tree_eyeglasses.xml";
-CascadeClassifier face_cascade;
-CascadeClassifier eyes_cascade;
-String window_name = "Capture - Face detection";
-/**
- * @function main
- */
-int main( void )
-{
- VideoCapture capture;
- Mat frame;
-
- //-- 1. Load the cascade
- if( !face_cascade.load( face_cascade_name ) ){ printf("--(!)Error loading face cascade\n"); return -1; };
- if( !eyes_cascade.load( eyes_cascade_name ) ){ printf("--(!)Error loading eyes cascade\n"); return -1; };
-
- //-- 2. Read the video stream
- capture.open( -1 );
- if ( ! capture.isOpened() ) { printf("--(!)Error opening video capture\n"); return -1; }
-
- while ( capture.read(frame) )
- {
- if( frame.empty() )
- {
- printf(" --(!) No captured frame -- Break!");
- break;
- }
-
- //-- 3. Apply the classifier to the frame
- detectAndDisplay( frame );
-
- //-- bail out if escape was pressed
- char c = (char)waitKey(10);
- if( c == 27 ) { break; }
- }
- return 0;
-}
-
-/**
- * @function detectAndDisplay
- */
-void detectAndDisplay( Mat frame )
-{
- std::vector<Rect> faces;
- Mat frame_gray;
-
- cvtColor( frame, frame_gray, COLOR_BGR2GRAY );
- equalizeHist( frame_gray, frame_gray );
-
- //-- Detect faces
- face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0, Size(80, 80) );
-
- for( size_t i = 0; i < faces.size(); i++ )
- {
- Mat faceROI = frame_gray( faces[i] );
- std::vector<Rect> eyes;
-
- //-- In each face, detect eyes
- eyes_cascade.detectMultiScale( faceROI, eyes, 1.1, 2, 0 |CASCADE_SCALE_IMAGE, Size(30, 30) );
- if( eyes.size() == 2)
- {
- //-- Draw the face
- Point center( faces[i].x + faces[i].width/2, faces[i].y + faces[i].height/2 );
- ellipse( frame, center, Size( faces[i].width/2, faces[i].height/2 ), 0, 0, 360, Scalar( 255, 0, 0 ), 2, 8, 0 );
-
- for( size_t j = 0; j < eyes.size(); j++ )
- { //-- Draw the eyes
- Point eye_center( faces[i].x + eyes[j].x + eyes[j].width/2, faces[i].y + eyes[j].y + eyes[j].height/2 );
- int radius = cvRound( (eyes[j].width + eyes[j].height)*0.25 );
- circle( frame, eye_center, radius, Scalar( 255, 0, 255 ), 3, 8, 0 );
- }
- }
-
- }
- //-- Show what you got
- imshow( window_name, frame );
-}
diff --git a/samples/cpp/tutorial_code/xfeatures2D/LATCH_match.cpp b/samples/cpp/tutorial_code/xfeatures2D/LATCH_match.cpp
index 2fd0bb9..c118b76 100644
--- a/samples/cpp/tutorial_code/xfeatures2D/LATCH_match.cpp
+++ b/samples/cpp/tutorial_code/xfeatures2D/LATCH_match.cpp
@@ -81,7 +81,7 @@ int main(void)
Mat res;
drawMatches(img1, inliers1, img2, inliers2, good_matches, res);
- imwrite("../../samples/data/latch_res.png", res);
+ imwrite("latch_result.png", res);
double inlier_ratio = inliers1.size() * 1.0 / matched1.size();
@@ -93,6 +93,10 @@ int main(void)
cout << "# Inliers: \t" << inliers1.size() << endl;
cout << "# Inliers Ratio: \t" << inlier_ratio << endl;
cout << endl;
+
+ imshow("result", res);
+ waitKey();
+
return 0;
}
diff --git a/samples/data/dnn/MobileNetSSD_300x300.prototxt b/samples/data/dnn/MobileNetSSD_300x300.prototxt
new file mode 100644
index 0000000..def1941
--- /dev/null
+++ b/samples/data/dnn/MobileNetSSD_300x300.prototxt
@@ -0,0 +1,3102 @@
+name: "MobileNet-SSD"
+input: "data"
+input_shape {
+ dim: 1
+ dim: 3
+ dim: 300
+ dim: 300
+}
+layer {
+ name: "conv0"
+ type: "Convolution"
+ bottom: "data"
+ top: "conv0"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 32
+ bias_term: false
+ pad: 1
+ kernel_size: 3
+ stride: 2
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv0/bn"
+ type: "BatchNorm"
+ bottom: "conv0"
+ top: "conv0"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv0/scale"
+ type: "Scale"
+ bottom: "conv0"
+ top: "conv0"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv0/relu"
+ type: "ReLU"
+ bottom: "conv0"
+ top: "conv0"
+}
+layer {
+ name: "conv1/dw"
+ type: "Convolution"
+ bottom: "conv0"
+ top: "conv1/dw"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 32
+ bias_term: false
+ pad: 1
+ kernel_size: 3
+ group: 32
+ engine: CAFFE
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv1/dw/bn"
+ type: "BatchNorm"
+ bottom: "conv1/dw"
+ top: "conv1/dw"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv1/dw/scale"
+ type: "Scale"
+ bottom: "conv1/dw"
+ top: "conv1/dw"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv1/dw/relu"
+ type: "ReLU"
+ bottom: "conv1/dw"
+ top: "conv1/dw"
+}
+layer {
+ name: "conv1"
+ type: "Convolution"
+ bottom: "conv1/dw"
+ top: "conv1"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 64
+ bias_term: false
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv1/bn"
+ type: "BatchNorm"
+ bottom: "conv1"
+ top: "conv1"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv1/scale"
+ type: "Scale"
+ bottom: "conv1"
+ top: "conv1"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv1/relu"
+ type: "ReLU"
+ bottom: "conv1"
+ top: "conv1"
+}
+layer {
+ name: "conv2/dw"
+ type: "Convolution"
+ bottom: "conv1"
+ top: "conv2/dw"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 64
+ bias_term: false
+ pad: 1
+ kernel_size: 3
+ stride: 2
+ group: 64
+ engine: CAFFE
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv2/dw/bn"
+ type: "BatchNorm"
+ bottom: "conv2/dw"
+ top: "conv2/dw"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv2/dw/scale"
+ type: "Scale"
+ bottom: "conv2/dw"
+ top: "conv2/dw"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv2/dw/relu"
+ type: "ReLU"
+ bottom: "conv2/dw"
+ top: "conv2/dw"
+}
+layer {
+ name: "conv2"
+ type: "Convolution"
+ bottom: "conv2/dw"
+ top: "conv2"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 128
+ bias_term: false
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv2/bn"
+ type: "BatchNorm"
+ bottom: "conv2"
+ top: "conv2"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv2/scale"
+ type: "Scale"
+ bottom: "conv2"
+ top: "conv2"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv2/relu"
+ type: "ReLU"
+ bottom: "conv2"
+ top: "conv2"
+}
+layer {
+ name: "conv3/dw"
+ type: "Convolution"
+ bottom: "conv2"
+ top: "conv3/dw"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 128
+ bias_term: false
+ pad: 1
+ kernel_size: 3
+ group: 128
+ engine: CAFFE
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv3/dw/bn"
+ type: "BatchNorm"
+ bottom: "conv3/dw"
+ top: "conv3/dw"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv3/dw/scale"
+ type: "Scale"
+ bottom: "conv3/dw"
+ top: "conv3/dw"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv3/dw/relu"
+ type: "ReLU"
+ bottom: "conv3/dw"
+ top: "conv3/dw"
+}
+layer {
+ name: "conv3"
+ type: "Convolution"
+ bottom: "conv3/dw"
+ top: "conv3"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 128
+ bias_term: false
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv3/bn"
+ type: "BatchNorm"
+ bottom: "conv3"
+ top: "conv3"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv3/scale"
+ type: "Scale"
+ bottom: "conv3"
+ top: "conv3"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv3/relu"
+ type: "ReLU"
+ bottom: "conv3"
+ top: "conv3"
+}
+layer {
+ name: "conv4/dw"
+ type: "Convolution"
+ bottom: "conv3"
+ top: "conv4/dw"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 128
+ bias_term: false
+ pad: 1
+ kernel_size: 3
+ stride: 2
+ group: 128
+ engine: CAFFE
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv4/dw/bn"
+ type: "BatchNorm"
+ bottom: "conv4/dw"
+ top: "conv4/dw"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv4/dw/scale"
+ type: "Scale"
+ bottom: "conv4/dw"
+ top: "conv4/dw"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv4/dw/relu"
+ type: "ReLU"
+ bottom: "conv4/dw"
+ top: "conv4/dw"
+}
+layer {
+ name: "conv4"
+ type: "Convolution"
+ bottom: "conv4/dw"
+ top: "conv4"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 256
+ bias_term: false
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv4/bn"
+ type: "BatchNorm"
+ bottom: "conv4"
+ top: "conv4"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv4/scale"
+ type: "Scale"
+ bottom: "conv4"
+ top: "conv4"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv4/relu"
+ type: "ReLU"
+ bottom: "conv4"
+ top: "conv4"
+}
+layer {
+ name: "conv5/dw"
+ type: "Convolution"
+ bottom: "conv4"
+ top: "conv5/dw"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 256
+ bias_term: false
+ pad: 1
+ kernel_size: 3
+ group: 256
+ engine: CAFFE
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv5/dw/bn"
+ type: "BatchNorm"
+ bottom: "conv5/dw"
+ top: "conv5/dw"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv5/dw/scale"
+ type: "Scale"
+ bottom: "conv5/dw"
+ top: "conv5/dw"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv5/dw/relu"
+ type: "ReLU"
+ bottom: "conv5/dw"
+ top: "conv5/dw"
+}
+layer {
+ name: "conv5"
+ type: "Convolution"
+ bottom: "conv5/dw"
+ top: "conv5"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 256
+ bias_term: false
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv5/bn"
+ type: "BatchNorm"
+ bottom: "conv5"
+ top: "conv5"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv5/scale"
+ type: "Scale"
+ bottom: "conv5"
+ top: "conv5"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv5/relu"
+ type: "ReLU"
+ bottom: "conv5"
+ top: "conv5"
+}
+layer {
+ name: "conv6/dw"
+ type: "Convolution"
+ bottom: "conv5"
+ top: "conv6/dw"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 256
+ bias_term: false
+ pad: 1
+ kernel_size: 3
+ stride: 2
+ group: 256
+ engine: CAFFE
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv6/dw/bn"
+ type: "BatchNorm"
+ bottom: "conv6/dw"
+ top: "conv6/dw"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv6/dw/scale"
+ type: "Scale"
+ bottom: "conv6/dw"
+ top: "conv6/dw"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv6/dw/relu"
+ type: "ReLU"
+ bottom: "conv6/dw"
+ top: "conv6/dw"
+}
+layer {
+ name: "conv6"
+ type: "Convolution"
+ bottom: "conv6/dw"
+ top: "conv6"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 512
+ bias_term: false
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv6/bn"
+ type: "BatchNorm"
+ bottom: "conv6"
+ top: "conv6"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv6/scale"
+ type: "Scale"
+ bottom: "conv6"
+ top: "conv6"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv6/relu"
+ type: "ReLU"
+ bottom: "conv6"
+ top: "conv6"
+}
+layer {
+ name: "conv7/dw"
+ type: "Convolution"
+ bottom: "conv6"
+ top: "conv7/dw"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 512
+ bias_term: false
+ pad: 1
+ kernel_size: 3
+ group: 512
+ engine: CAFFE
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv7/dw/bn"
+ type: "BatchNorm"
+ bottom: "conv7/dw"
+ top: "conv7/dw"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv7/dw/scale"
+ type: "Scale"
+ bottom: "conv7/dw"
+ top: "conv7/dw"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv7/dw/relu"
+ type: "ReLU"
+ bottom: "conv7/dw"
+ top: "conv7/dw"
+}
+layer {
+ name: "conv7"
+ type: "Convolution"
+ bottom: "conv7/dw"
+ top: "conv7"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 512
+ bias_term: false
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv7/bn"
+ type: "BatchNorm"
+ bottom: "conv7"
+ top: "conv7"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv7/scale"
+ type: "Scale"
+ bottom: "conv7"
+ top: "conv7"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv7/relu"
+ type: "ReLU"
+ bottom: "conv7"
+ top: "conv7"
+}
+layer {
+ name: "conv8/dw"
+ type: "Convolution"
+ bottom: "conv7"
+ top: "conv8/dw"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 512
+ bias_term: false
+ pad: 1
+ kernel_size: 3
+ group: 512
+ engine: CAFFE
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv8/dw/bn"
+ type: "BatchNorm"
+ bottom: "conv8/dw"
+ top: "conv8/dw"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv8/dw/scale"
+ type: "Scale"
+ bottom: "conv8/dw"
+ top: "conv8/dw"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv8/dw/relu"
+ type: "ReLU"
+ bottom: "conv8/dw"
+ top: "conv8/dw"
+}
+layer {
+ name: "conv8"
+ type: "Convolution"
+ bottom: "conv8/dw"
+ top: "conv8"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 512
+ bias_term: false
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv8/bn"
+ type: "BatchNorm"
+ bottom: "conv8"
+ top: "conv8"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv8/scale"
+ type: "Scale"
+ bottom: "conv8"
+ top: "conv8"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv8/relu"
+ type: "ReLU"
+ bottom: "conv8"
+ top: "conv8"
+}
+layer {
+ name: "conv9/dw"
+ type: "Convolution"
+ bottom: "conv8"
+ top: "conv9/dw"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 512
+ bias_term: false
+ pad: 1
+ kernel_size: 3
+ group: 512
+ engine: CAFFE
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv9/dw/bn"
+ type: "BatchNorm"
+ bottom: "conv9/dw"
+ top: "conv9/dw"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv9/dw/scale"
+ type: "Scale"
+ bottom: "conv9/dw"
+ top: "conv9/dw"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv9/dw/relu"
+ type: "ReLU"
+ bottom: "conv9/dw"
+ top: "conv9/dw"
+}
+layer {
+ name: "conv9"
+ type: "Convolution"
+ bottom: "conv9/dw"
+ top: "conv9"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 512
+ bias_term: false
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv9/bn"
+ type: "BatchNorm"
+ bottom: "conv9"
+ top: "conv9"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv9/scale"
+ type: "Scale"
+ bottom: "conv9"
+ top: "conv9"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv9/relu"
+ type: "ReLU"
+ bottom: "conv9"
+ top: "conv9"
+}
+layer {
+ name: "conv10/dw"
+ type: "Convolution"
+ bottom: "conv9"
+ top: "conv10/dw"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 512
+ bias_term: false
+ pad: 1
+ kernel_size: 3
+ group: 512
+ engine: CAFFE
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv10/dw/bn"
+ type: "BatchNorm"
+ bottom: "conv10/dw"
+ top: "conv10/dw"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv10/dw/scale"
+ type: "Scale"
+ bottom: "conv10/dw"
+ top: "conv10/dw"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv10/dw/relu"
+ type: "ReLU"
+ bottom: "conv10/dw"
+ top: "conv10/dw"
+}
+layer {
+ name: "conv10"
+ type: "Convolution"
+ bottom: "conv10/dw"
+ top: "conv10"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 512
+ bias_term: false
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv10/bn"
+ type: "BatchNorm"
+ bottom: "conv10"
+ top: "conv10"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv10/scale"
+ type: "Scale"
+ bottom: "conv10"
+ top: "conv10"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv10/relu"
+ type: "ReLU"
+ bottom: "conv10"
+ top: "conv10"
+}
+layer {
+ name: "conv11/dw"
+ type: "Convolution"
+ bottom: "conv10"
+ top: "conv11/dw"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 512
+ bias_term: false
+ pad: 1
+ kernel_size: 3
+ group: 512
+ engine: CAFFE
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv11/dw/bn"
+ type: "BatchNorm"
+ bottom: "conv11/dw"
+ top: "conv11/dw"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv11/dw/scale"
+ type: "Scale"
+ bottom: "conv11/dw"
+ top: "conv11/dw"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv11/dw/relu"
+ type: "ReLU"
+ bottom: "conv11/dw"
+ top: "conv11/dw"
+}
+layer {
+ name: "conv11"
+ type: "Convolution"
+ bottom: "conv11/dw"
+ top: "conv11"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 512
+ bias_term: false
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv11/bn"
+ type: "BatchNorm"
+ bottom: "conv11"
+ top: "conv11"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv11/scale"
+ type: "Scale"
+ bottom: "conv11"
+ top: "conv11"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv11/relu"
+ type: "ReLU"
+ bottom: "conv11"
+ top: "conv11"
+}
+layer {
+ name: "conv12/dw"
+ type: "Convolution"
+ bottom: "conv11"
+ top: "conv12/dw"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 512
+ bias_term: false
+ pad: 1
+ kernel_size: 3
+ stride: 2
+ group: 512
+ engine: CAFFE
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv12/dw/bn"
+ type: "BatchNorm"
+ bottom: "conv12/dw"
+ top: "conv12/dw"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv12/dw/scale"
+ type: "Scale"
+ bottom: "conv12/dw"
+ top: "conv12/dw"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv12/dw/relu"
+ type: "ReLU"
+ bottom: "conv12/dw"
+ top: "conv12/dw"
+}
+layer {
+ name: "conv12"
+ type: "Convolution"
+ bottom: "conv12/dw"
+ top: "conv12"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 1024
+ bias_term: false
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv12/bn"
+ type: "BatchNorm"
+ bottom: "conv12"
+ top: "conv12"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv12/scale"
+ type: "Scale"
+ bottom: "conv12"
+ top: "conv12"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv12/relu"
+ type: "ReLU"
+ bottom: "conv12"
+ top: "conv12"
+}
+layer {
+ name: "conv13/dw"
+ type: "Convolution"
+ bottom: "conv12"
+ top: "conv13/dw"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 1024
+ bias_term: false
+ pad: 1
+ kernel_size: 3
+ group: 1024
+ engine: CAFFE
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv13/dw/bn"
+ type: "BatchNorm"
+ bottom: "conv13/dw"
+ top: "conv13/dw"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv13/dw/scale"
+ type: "Scale"
+ bottom: "conv13/dw"
+ top: "conv13/dw"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv13/dw/relu"
+ type: "ReLU"
+ bottom: "conv13/dw"
+ top: "conv13/dw"
+}
+layer {
+ name: "conv13"
+ type: "Convolution"
+ bottom: "conv13/dw"
+ top: "conv13"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 1024
+ bias_term: false
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv13/bn"
+ type: "BatchNorm"
+ bottom: "conv13"
+ top: "conv13"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv13/scale"
+ type: "Scale"
+ bottom: "conv13"
+ top: "conv13"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv13/relu"
+ type: "ReLU"
+ bottom: "conv13"
+ top: "conv13"
+}
+layer {
+ name: "conv14_1"
+ type: "Convolution"
+ bottom: "conv13"
+ top: "conv14_1"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 256
+ bias_term: false
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv14_1/bn"
+ type: "BatchNorm"
+ bottom: "conv14_1"
+ top: "conv14_1"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv14_1/scale"
+ type: "Scale"
+ bottom: "conv14_1"
+ top: "conv14_1"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv14_1/relu"
+ type: "ReLU"
+ bottom: "conv14_1"
+ top: "conv14_1"
+}
+layer {
+ name: "conv14_2"
+ type: "Convolution"
+ bottom: "conv14_1"
+ top: "conv14_2"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 512
+ bias_term: false
+ pad: 1
+ kernel_size: 3
+ stride: 2
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv14_2/bn"
+ type: "BatchNorm"
+ bottom: "conv14_2"
+ top: "conv14_2"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv14_2/scale"
+ type: "Scale"
+ bottom: "conv14_2"
+ top: "conv14_2"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv14_2/relu"
+ type: "ReLU"
+ bottom: "conv14_2"
+ top: "conv14_2"
+}
+layer {
+ name: "conv15_1"
+ type: "Convolution"
+ bottom: "conv14_2"
+ top: "conv15_1"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 128
+ bias_term: false
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv15_1/bn"
+ type: "BatchNorm"
+ bottom: "conv15_1"
+ top: "conv15_1"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv15_1/scale"
+ type: "Scale"
+ bottom: "conv15_1"
+ top: "conv15_1"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv15_1/relu"
+ type: "ReLU"
+ bottom: "conv15_1"
+ top: "conv15_1"
+}
+layer {
+ name: "conv15_2"
+ type: "Convolution"
+ bottom: "conv15_1"
+ top: "conv15_2"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 256
+ bias_term: false
+ pad: 1
+ kernel_size: 3
+ stride: 2
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv15_2/bn"
+ type: "BatchNorm"
+ bottom: "conv15_2"
+ top: "conv15_2"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv15_2/scale"
+ type: "Scale"
+ bottom: "conv15_2"
+ top: "conv15_2"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv15_2/relu"
+ type: "ReLU"
+ bottom: "conv15_2"
+ top: "conv15_2"
+}
+layer {
+ name: "conv16_1"
+ type: "Convolution"
+ bottom: "conv15_2"
+ top: "conv16_1"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 128
+ bias_term: false
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv16_1/bn"
+ type: "BatchNorm"
+ bottom: "conv16_1"
+ top: "conv16_1"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv16_1/scale"
+ type: "Scale"
+ bottom: "conv16_1"
+ top: "conv16_1"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv16_1/relu"
+ type: "ReLU"
+ bottom: "conv16_1"
+ top: "conv16_1"
+}
+layer {
+ name: "conv16_2"
+ type: "Convolution"
+ bottom: "conv16_1"
+ top: "conv16_2"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 256
+ bias_term: false
+ pad: 1
+ kernel_size: 3
+ stride: 2
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv16_2/bn"
+ type: "BatchNorm"
+ bottom: "conv16_2"
+ top: "conv16_2"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv16_2/scale"
+ type: "Scale"
+ bottom: "conv16_2"
+ top: "conv16_2"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv16_2/relu"
+ type: "ReLU"
+ bottom: "conv16_2"
+ top: "conv16_2"
+}
+layer {
+ name: "conv17_1"
+ type: "Convolution"
+ bottom: "conv16_2"
+ top: "conv17_1"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 64
+ bias_term: false
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv17_1/bn"
+ type: "BatchNorm"
+ bottom: "conv17_1"
+ top: "conv17_1"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv17_1/scale"
+ type: "Scale"
+ bottom: "conv17_1"
+ top: "conv17_1"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv17_1/relu"
+ type: "ReLU"
+ bottom: "conv17_1"
+ top: "conv17_1"
+}
+layer {
+ name: "conv17_2"
+ type: "Convolution"
+ bottom: "conv17_1"
+ top: "conv17_2"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ convolution_param {
+ num_output: 128
+ bias_term: false
+ pad: 1
+ kernel_size: 3
+ stride: 2
+ weight_filler {
+ type: "msra"
+ }
+ }
+}
+layer {
+ name: "conv17_2/bn"
+ type: "BatchNorm"
+ bottom: "conv17_2"
+ top: "conv17_2"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+}
+layer {
+ name: "conv17_2/scale"
+ type: "Scale"
+ bottom: "conv17_2"
+ top: "conv17_2"
+ param {
+ lr_mult: 0.1
+ decay_mult: 0.0
+ }
+ param {
+ lr_mult: 0.2
+ decay_mult: 0.0
+ }
+ scale_param {
+ filler {
+ value: 1
+ }
+ bias_term: true
+ bias_filler {
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv17_2/relu"
+ type: "ReLU"
+ bottom: "conv17_2"
+ top: "conv17_2"
+}
+layer {
+ name: "conv11_mbox_loc"
+ type: "Convolution"
+ bottom: "conv11"
+ top: "conv11_mbox_loc"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ param {
+ lr_mult: 2.0
+ decay_mult: 0.0
+ }
+ convolution_param {
+ num_output: 12
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.0
+ }
+ }
+}
+layer {
+ name: "conv11_mbox_loc_perm"
+ type: "Permute"
+ bottom: "conv11_mbox_loc"
+ top: "conv11_mbox_loc_perm"
+ permute_param {
+ order: 0
+ order: 2
+ order: 3
+ order: 1
+ }
+}
+layer {
+ name: "conv11_mbox_loc_flat"
+ type: "Flatten"
+ bottom: "conv11_mbox_loc_perm"
+ top: "conv11_mbox_loc_flat"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "conv11_mbox_conf"
+ type: "Convolution"
+ bottom: "conv11"
+ top: "conv11_mbox_conf"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ param {
+ lr_mult: 2.0
+ decay_mult: 0.0
+ }
+ convolution_param {
+ num_output: 63
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.0
+ }
+ }
+}
+layer {
+ name: "conv11_mbox_conf_perm"
+ type: "Permute"
+ bottom: "conv11_mbox_conf"
+ top: "conv11_mbox_conf_perm"
+ permute_param {
+ order: 0
+ order: 2
+ order: 3
+ order: 1
+ }
+}
+layer {
+ name: "conv11_mbox_conf_flat"
+ type: "Flatten"
+ bottom: "conv11_mbox_conf_perm"
+ top: "conv11_mbox_conf_flat"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "conv11_mbox_priorbox"
+ type: "PriorBox"
+ bottom: "conv11"
+ bottom: "data"
+ top: "conv11_mbox_priorbox"
+ prior_box_param {
+ min_size: 60.0
+ aspect_ratio: 2.0
+ flip: true
+ clip: false
+ variance: 0.1
+ variance: 0.1
+ variance: 0.2
+ variance: 0.2
+ offset: 0.5
+ }
+}
+layer {
+ name: "conv13_mbox_loc"
+ type: "Convolution"
+ bottom: "conv13"
+ top: "conv13_mbox_loc"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ param {
+ lr_mult: 2.0
+ decay_mult: 0.0
+ }
+ convolution_param {
+ num_output: 24
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.0
+ }
+ }
+}
+layer {
+ name: "conv13_mbox_loc_perm"
+ type: "Permute"
+ bottom: "conv13_mbox_loc"
+ top: "conv13_mbox_loc_perm"
+ permute_param {
+ order: 0
+ order: 2
+ order: 3
+ order: 1
+ }
+}
+layer {
+ name: "conv13_mbox_loc_flat"
+ type: "Flatten"
+ bottom: "conv13_mbox_loc_perm"
+ top: "conv13_mbox_loc_flat"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "conv13_mbox_conf"
+ type: "Convolution"
+ bottom: "conv13"
+ top: "conv13_mbox_conf"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ param {
+ lr_mult: 2.0
+ decay_mult: 0.0
+ }
+ convolution_param {
+ num_output: 126
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.0
+ }
+ }
+}
+layer {
+ name: "conv13_mbox_conf_perm"
+ type: "Permute"
+ bottom: "conv13_mbox_conf"
+ top: "conv13_mbox_conf_perm"
+ permute_param {
+ order: 0
+ order: 2
+ order: 3
+ order: 1
+ }
+}
+layer {
+ name: "conv13_mbox_conf_flat"
+ type: "Flatten"
+ bottom: "conv13_mbox_conf_perm"
+ top: "conv13_mbox_conf_flat"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "conv13_mbox_priorbox"
+ type: "PriorBox"
+ bottom: "conv13"
+ bottom: "data"
+ top: "conv13_mbox_priorbox"
+ prior_box_param {
+ min_size: 105.0
+ max_size: 150.0
+ aspect_ratio: 2.0
+ aspect_ratio: 3.0
+ flip: true
+ clip: false
+ variance: 0.1
+ variance: 0.1
+ variance: 0.2
+ variance: 0.2
+ offset: 0.5
+ }
+}
+layer {
+ name: "conv14_2_mbox_loc"
+ type: "Convolution"
+ bottom: "conv14_2"
+ top: "conv14_2_mbox_loc"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ param {
+ lr_mult: 2.0
+ decay_mult: 0.0
+ }
+ convolution_param {
+ num_output: 24
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.0
+ }
+ }
+}
+layer {
+ name: "conv14_2_mbox_loc_perm"
+ type: "Permute"
+ bottom: "conv14_2_mbox_loc"
+ top: "conv14_2_mbox_loc_perm"
+ permute_param {
+ order: 0
+ order: 2
+ order: 3
+ order: 1
+ }
+}
+layer {
+ name: "conv14_2_mbox_loc_flat"
+ type: "Flatten"
+ bottom: "conv14_2_mbox_loc_perm"
+ top: "conv14_2_mbox_loc_flat"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "conv14_2_mbox_conf"
+ type: "Convolution"
+ bottom: "conv14_2"
+ top: "conv14_2_mbox_conf"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ param {
+ lr_mult: 2.0
+ decay_mult: 0.0
+ }
+ convolution_param {
+ num_output: 126
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.0
+ }
+ }
+}
+layer {
+ name: "conv14_2_mbox_conf_perm"
+ type: "Permute"
+ bottom: "conv14_2_mbox_conf"
+ top: "conv14_2_mbox_conf_perm"
+ permute_param {
+ order: 0
+ order: 2
+ order: 3
+ order: 1
+ }
+}
+layer {
+ name: "conv14_2_mbox_conf_flat"
+ type: "Flatten"
+ bottom: "conv14_2_mbox_conf_perm"
+ top: "conv14_2_mbox_conf_flat"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "conv14_2_mbox_priorbox"
+ type: "PriorBox"
+ bottom: "conv14_2"
+ bottom: "data"
+ top: "conv14_2_mbox_priorbox"
+ prior_box_param {
+ min_size: 150.0
+ max_size: 195.0
+ aspect_ratio: 2.0
+ aspect_ratio: 3.0
+ flip: true
+ clip: false
+ variance: 0.1
+ variance: 0.1
+ variance: 0.2
+ variance: 0.2
+ offset: 0.5
+ }
+}
+layer {
+ name: "conv15_2_mbox_loc"
+ type: "Convolution"
+ bottom: "conv15_2"
+ top: "conv15_2_mbox_loc"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ param {
+ lr_mult: 2.0
+ decay_mult: 0.0
+ }
+ convolution_param {
+ num_output: 24
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.0
+ }
+ }
+}
+layer {
+ name: "conv15_2_mbox_loc_perm"
+ type: "Permute"
+ bottom: "conv15_2_mbox_loc"
+ top: "conv15_2_mbox_loc_perm"
+ permute_param {
+ order: 0
+ order: 2
+ order: 3
+ order: 1
+ }
+}
+layer {
+ name: "conv15_2_mbox_loc_flat"
+ type: "Flatten"
+ bottom: "conv15_2_mbox_loc_perm"
+ top: "conv15_2_mbox_loc_flat"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "conv15_2_mbox_conf"
+ type: "Convolution"
+ bottom: "conv15_2"
+ top: "conv15_2_mbox_conf"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ param {
+ lr_mult: 2.0
+ decay_mult: 0.0
+ }
+ convolution_param {
+ num_output: 126
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.0
+ }
+ }
+}
+layer {
+ name: "conv15_2_mbox_conf_perm"
+ type: "Permute"
+ bottom: "conv15_2_mbox_conf"
+ top: "conv15_2_mbox_conf_perm"
+ permute_param {
+ order: 0
+ order: 2
+ order: 3
+ order: 1
+ }
+}
+layer {
+ name: "conv15_2_mbox_conf_flat"
+ type: "Flatten"
+ bottom: "conv15_2_mbox_conf_perm"
+ top: "conv15_2_mbox_conf_flat"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "conv15_2_mbox_priorbox"
+ type: "PriorBox"
+ bottom: "conv15_2"
+ bottom: "data"
+ top: "conv15_2_mbox_priorbox"
+ prior_box_param {
+ min_size: 195.0
+ max_size: 240.0
+ aspect_ratio: 2.0
+ aspect_ratio: 3.0
+ flip: true
+ clip: false
+ variance: 0.1
+ variance: 0.1
+ variance: 0.2
+ variance: 0.2
+ offset: 0.5
+ }
+}
+layer {
+ name: "conv16_2_mbox_loc"
+ type: "Convolution"
+ bottom: "conv16_2"
+ top: "conv16_2_mbox_loc"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ param {
+ lr_mult: 2.0
+ decay_mult: 0.0
+ }
+ convolution_param {
+ num_output: 24
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.0
+ }
+ }
+}
+layer {
+ name: "conv16_2_mbox_loc_perm"
+ type: "Permute"
+ bottom: "conv16_2_mbox_loc"
+ top: "conv16_2_mbox_loc_perm"
+ permute_param {
+ order: 0
+ order: 2
+ order: 3
+ order: 1
+ }
+}
+layer {
+ name: "conv16_2_mbox_loc_flat"
+ type: "Flatten"
+ bottom: "conv16_2_mbox_loc_perm"
+ top: "conv16_2_mbox_loc_flat"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "conv16_2_mbox_conf"
+ type: "Convolution"
+ bottom: "conv16_2"
+ top: "conv16_2_mbox_conf"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ param {
+ lr_mult: 2.0
+ decay_mult: 0.0
+ }
+ convolution_param {
+ num_output: 126
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.0
+ }
+ }
+}
+layer {
+ name: "conv16_2_mbox_conf_perm"
+ type: "Permute"
+ bottom: "conv16_2_mbox_conf"
+ top: "conv16_2_mbox_conf_perm"
+ permute_param {
+ order: 0
+ order: 2
+ order: 3
+ order: 1
+ }
+}
+layer {
+ name: "conv16_2_mbox_conf_flat"
+ type: "Flatten"
+ bottom: "conv16_2_mbox_conf_perm"
+ top: "conv16_2_mbox_conf_flat"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "conv16_2_mbox_priorbox"
+ type: "PriorBox"
+ bottom: "conv16_2"
+ bottom: "data"
+ top: "conv16_2_mbox_priorbox"
+ prior_box_param {
+ min_size: 240.0
+ max_size: 285.0
+ aspect_ratio: 2.0
+ aspect_ratio: 3.0
+ flip: true
+ clip: false
+ variance: 0.1
+ variance: 0.1
+ variance: 0.2
+ variance: 0.2
+ offset: 0.5
+ }
+}
+layer {
+ name: "conv17_2_mbox_loc"
+ type: "Convolution"
+ bottom: "conv17_2"
+ top: "conv17_2_mbox_loc"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ param {
+ lr_mult: 2.0
+ decay_mult: 0.0
+ }
+ convolution_param {
+ num_output: 24
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.0
+ }
+ }
+}
+layer {
+ name: "conv17_2_mbox_loc_perm"
+ type: "Permute"
+ bottom: "conv17_2_mbox_loc"
+ top: "conv17_2_mbox_loc_perm"
+ permute_param {
+ order: 0
+ order: 2
+ order: 3
+ order: 1
+ }
+}
+layer {
+ name: "conv17_2_mbox_loc_flat"
+ type: "Flatten"
+ bottom: "conv17_2_mbox_loc_perm"
+ top: "conv17_2_mbox_loc_flat"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "conv17_2_mbox_conf"
+ type: "Convolution"
+ bottom: "conv17_2"
+ top: "conv17_2_mbox_conf"
+ param {
+ lr_mult: 1.0
+ decay_mult: 1.0
+ }
+ param {
+ lr_mult: 2.0
+ decay_mult: 0.0
+ }
+ convolution_param {
+ num_output: 126
+ kernel_size: 1
+ weight_filler {
+ type: "msra"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.0
+ }
+ }
+}
+layer {
+ name: "conv17_2_mbox_conf_perm"
+ type: "Permute"
+ bottom: "conv17_2_mbox_conf"
+ top: "conv17_2_mbox_conf_perm"
+ permute_param {
+ order: 0
+ order: 2
+ order: 3
+ order: 1
+ }
+}
+layer {
+ name: "conv17_2_mbox_conf_flat"
+ type: "Flatten"
+ bottom: "conv17_2_mbox_conf_perm"
+ top: "conv17_2_mbox_conf_flat"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "conv17_2_mbox_priorbox"
+ type: "PriorBox"
+ bottom: "conv17_2"
+ bottom: "data"
+ top: "conv17_2_mbox_priorbox"
+ prior_box_param {
+ min_size: 285.0
+ max_size: 300.0
+ aspect_ratio: 2.0
+ aspect_ratio: 3.0
+ flip: true
+ clip: false
+ variance: 0.1
+ variance: 0.1
+ variance: 0.2
+ variance: 0.2
+ offset: 0.5
+ }
+}
+layer {
+ name: "mbox_loc"
+ type: "Concat"
+ bottom: "conv11_mbox_loc_flat"
+ bottom: "conv13_mbox_loc_flat"
+ bottom: "conv14_2_mbox_loc_flat"
+ bottom: "conv15_2_mbox_loc_flat"
+ bottom: "conv16_2_mbox_loc_flat"
+ bottom: "conv17_2_mbox_loc_flat"
+ top: "mbox_loc"
+ concat_param {
+ axis: 1
+ }
+}
+layer {
+ name: "mbox_conf"
+ type: "Concat"
+ bottom: "conv11_mbox_conf_flat"
+ bottom: "conv13_mbox_conf_flat"
+ bottom: "conv14_2_mbox_conf_flat"
+ bottom: "conv15_2_mbox_conf_flat"
+ bottom: "conv16_2_mbox_conf_flat"
+ bottom: "conv17_2_mbox_conf_flat"
+ top: "mbox_conf"
+ concat_param {
+ axis: 1
+ }
+}
+layer {
+ name: "mbox_priorbox"
+ type: "Concat"
+ bottom: "conv11_mbox_priorbox"
+ bottom: "conv13_mbox_priorbox"
+ bottom: "conv14_2_mbox_priorbox"
+ bottom: "conv15_2_mbox_priorbox"
+ bottom: "conv16_2_mbox_priorbox"
+ bottom: "conv17_2_mbox_priorbox"
+ top: "mbox_priorbox"
+ concat_param {
+ axis: 2
+ }
+}
+layer {
+ name: "mbox_conf_reshape"
+ type: "Reshape"
+ bottom: "mbox_conf"
+ top: "mbox_conf_reshape"
+ reshape_param {
+ shape {
+ dim: 0
+ dim: -1
+ dim: 21
+ }
+ }
+}
+layer {
+ name: "mbox_conf_softmax"
+ type: "Softmax"
+ bottom: "mbox_conf_reshape"
+ top: "mbox_conf_softmax"
+ softmax_param {
+ axis: 2
+ }
+}
+layer {
+ name: "mbox_conf_flatten"
+ type: "Flatten"
+ bottom: "mbox_conf_softmax"
+ top: "mbox_conf_flatten"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "detection_out"
+ type: "DetectionOutput"
+ bottom: "mbox_loc"
+ bottom: "mbox_conf_flatten"
+ bottom: "mbox_priorbox"
+ top: "detection_out"
+ include {
+ phase: TEST
+ }
+ detection_output_param {
+ num_classes: 21
+ share_location: true
+ background_label_id: 0
+ nms_param {
+ nms_threshold: 0.45
+ top_k: 100
+ }
+ code_type: CENTER_SIZE
+ keep_top_k: 100
+ confidence_threshold: 0.25
+ }
+}
\ No newline at end of file
diff --git a/samples/data/dnn/VGG_VOC0712_SSD_300x300_iter_60000.prototxt b/samples/data/dnn/VGG_VOC0712_SSD_300x300_iter_60000.prototxt
new file mode 100644
index 0000000..77a2365
--- /dev/null
+++ b/samples/data/dnn/VGG_VOC0712_SSD_300x300_iter_60000.prototxt
@@ -0,0 +1,1546 @@
+name: "VGG_VOC0712_SSD_300x300_deploy"
+input: "data"
+input_dim: 1
+input_dim: 3
+input_dim: 300
+input_dim: 300
+layer {
+ name: "conv1_1"
+ type: "Convolution"
+ bottom: "data"
+ top: "conv1_1"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 64
+ pad: 1
+ kernel_size: 3
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "relu1_1"
+ type: "ReLU"
+ bottom: "conv1_1"
+ top: "conv1_1"
+}
+layer {
+ name: "conv1_2"
+ type: "Convolution"
+ bottom: "conv1_1"
+ top: "conv1_2"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 64
+ pad: 1
+ kernel_size: 3
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "relu1_2"
+ type: "ReLU"
+ bottom: "conv1_2"
+ top: "conv1_2"
+}
+layer {
+ name: "pool1"
+ type: "Pooling"
+ bottom: "conv1_2"
+ top: "pool1"
+ pooling_param {
+ pool: MAX
+ kernel_size: 2
+ stride: 2
+ }
+}
+layer {
+ name: "conv2_1"
+ type: "Convolution"
+ bottom: "pool1"
+ top: "conv2_1"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 128
+ pad: 1
+ kernel_size: 3
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "relu2_1"
+ type: "ReLU"
+ bottom: "conv2_1"
+ top: "conv2_1"
+}
+layer {
+ name: "conv2_2"
+ type: "Convolution"
+ bottom: "conv2_1"
+ top: "conv2_2"
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ param {
+ lr_mult: 0
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 128
+ pad: 1
+ kernel_size: 3
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "relu2_2"
+ type: "ReLU"
+ bottom: "conv2_2"
+ top: "conv2_2"
+}
+layer {
+ name: "pool2"
+ type: "Pooling"
+ bottom: "conv2_2"
+ top: "pool2"
+ pooling_param {
+ pool: MAX
+ kernel_size: 2
+ stride: 2
+ }
+}
+layer {
+ name: "conv3_1"
+ type: "Convolution"
+ bottom: "pool2"
+ top: "conv3_1"
+ 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"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "relu3_1"
+ type: "ReLU"
+ bottom: "conv3_1"
+ top: "conv3_1"
+}
+layer {
+ name: "conv3_2"
+ type: "Convolution"
+ bottom: "conv3_1"
+ top: "conv3_2"
+ 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"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "relu3_2"
+ type: "ReLU"
+ bottom: "conv3_2"
+ top: "conv3_2"
+}
+layer {
+ name: "conv3_3"
+ type: "Convolution"
+ bottom: "conv3_2"
+ top: "conv3_3"
+ 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"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "relu3_3"
+ type: "ReLU"
+ bottom: "conv3_3"
+ top: "conv3_3"
+}
+layer {
+ name: "pool3"
+ type: "Pooling"
+ bottom: "conv3_3"
+ top: "pool3"
+ pooling_param {
+ pool: MAX
+ kernel_size: 2
+ stride: 2
+ }
+}
+layer {
+ name: "conv4_1"
+ type: "Convolution"
+ bottom: "pool3"
+ top: "conv4_1"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 512
+ pad: 1
+ kernel_size: 3
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "relu4_1"
+ type: "ReLU"
+ bottom: "conv4_1"
+ top: "conv4_1"
+}
+layer {
+ name: "conv4_2"
+ type: "Convolution"
+ bottom: "conv4_1"
+ top: "conv4_2"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 512
+ pad: 1
+ kernel_size: 3
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "relu4_2"
+ type: "ReLU"
+ bottom: "conv4_2"
+ top: "conv4_2"
+}
+layer {
+ name: "conv4_3"
+ type: "Convolution"
+ bottom: "conv4_2"
+ top: "conv4_3"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 512
+ pad: 1
+ kernel_size: 3
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "relu4_3"
+ type: "ReLU"
+ bottom: "conv4_3"
+ top: "conv4_3"
+}
+layer {
+ name: "pool4"
+ type: "Pooling"
+ bottom: "conv4_3"
+ top: "pool4"
+ pooling_param {
+ pool: MAX
+ kernel_size: 2
+ stride: 2
+ }
+}
+layer {
+ name: "conv5_1"
+ type: "Convolution"
+ bottom: "pool4"
+ top: "conv5_1"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 512
+ pad: 1
+ kernel_size: 3
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "relu5_1"
+ type: "ReLU"
+ bottom: "conv5_1"
+ top: "conv5_1"
+}
+layer {
+ name: "conv5_2"
+ type: "Convolution"
+ bottom: "conv5_1"
+ top: "conv5_2"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 512
+ pad: 1
+ kernel_size: 3
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "relu5_2"
+ type: "ReLU"
+ bottom: "conv5_2"
+ top: "conv5_2"
+}
+layer {
+ name: "conv5_3"
+ type: "Convolution"
+ bottom: "conv5_2"
+ top: "conv5_3"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 512
+ pad: 1
+ kernel_size: 3
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "relu5_3"
+ type: "ReLU"
+ bottom: "conv5_3"
+ top: "conv5_3"
+}
+layer {
+ name: "pool5"
+ type: "Pooling"
+ bottom: "conv5_3"
+ top: "pool5"
+ pooling_param {
+ pool: MAX
+ kernel_size: 3
+ stride: 1
+ pad: 1
+ }
+}
+layer {
+ name: "fc6"
+ type: "Convolution"
+ bottom: "pool5"
+ top: "fc6"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 1024
+ pad: 6
+ kernel_size: 3
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ dilation: 6
+ }
+}
+layer {
+ name: "relu6"
+ type: "ReLU"
+ bottom: "fc6"
+ top: "fc6"
+}
+layer {
+ name: "fc7"
+ type: "Convolution"
+ bottom: "fc6"
+ top: "fc7"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 1024
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "relu7"
+ type: "ReLU"
+ bottom: "fc7"
+ top: "fc7"
+}
+layer {
+ name: "conv6_1"
+ type: "Convolution"
+ bottom: "fc7"
+ top: "conv6_1"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 256
+ pad: 0
+ kernel_size: 1
+ stride: 1
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv6_1_relu"
+ type: "ReLU"
+ bottom: "conv6_1"
+ top: "conv6_1"
+}
+layer {
+ name: "conv6_2"
+ type: "Convolution"
+ bottom: "conv6_1"
+ top: "conv6_2"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 512
+ pad: 1
+ kernel_size: 3
+ stride: 2
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv6_2_relu"
+ type: "ReLU"
+ bottom: "conv6_2"
+ top: "conv6_2"
+}
+layer {
+ name: "conv7_1"
+ type: "Convolution"
+ bottom: "conv6_2"
+ top: "conv7_1"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 128
+ pad: 0
+ kernel_size: 1
+ stride: 1
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv7_1_relu"
+ type: "ReLU"
+ bottom: "conv7_1"
+ top: "conv7_1"
+}
+layer {
+ name: "conv7_2"
+ type: "Convolution"
+ bottom: "conv7_1"
+ top: "conv7_2"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 256
+ pad: 1
+ kernel_size: 3
+ stride: 2
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv7_2_relu"
+ type: "ReLU"
+ bottom: "conv7_2"
+ top: "conv7_2"
+}
+layer {
+ name: "conv8_1"
+ type: "Convolution"
+ bottom: "conv7_2"
+ top: "conv8_1"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 128
+ pad: 0
+ kernel_size: 1
+ stride: 1
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv8_1_relu"
+ type: "ReLU"
+ bottom: "conv8_1"
+ top: "conv8_1"
+}
+layer {
+ name: "conv8_2"
+ type: "Convolution"
+ bottom: "conv8_1"
+ top: "conv8_2"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 256
+ pad: 1
+ kernel_size: 3
+ stride: 2
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv8_2_relu"
+ type: "ReLU"
+ bottom: "conv8_2"
+ top: "conv8_2"
+}
+layer {
+ name: "pool6"
+ type: "Pooling"
+ bottom: "conv8_2"
+ top: "pool6"
+ pooling_param {
+ pool: AVE
+ global_pooling: true
+ }
+}
+layer {
+ name: "conv4_3_norm"
+ type: "NormalizeBBox"
+ bottom: "conv4_3"
+ top: "conv4_3_norm"
+ normalize_bbox_param {
+ across_spatial: false
+ scale_filler {
+ type: "constant"
+ value: 20
+ }
+ channel_shared: false
+ }
+}
+layer {
+ name: "conv4_3_norm_mbox_loc"
+ type: "Convolution"
+ bottom: "conv4_3_norm"
+ top: "conv4_3_norm_mbox_loc"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 12
+ pad: 1
+ kernel_size: 3
+ stride: 1
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv4_3_norm_mbox_loc_perm"
+ type: "Permute"
+ bottom: "conv4_3_norm_mbox_loc"
+ top: "conv4_3_norm_mbox_loc_perm"
+ permute_param {
+ order: 0
+ order: 2
+ order: 3
+ order: 1
+ }
+}
+layer {
+ name: "conv4_3_norm_mbox_loc_flat"
+ type: "Flatten"
+ bottom: "conv4_3_norm_mbox_loc_perm"
+ top: "conv4_3_norm_mbox_loc_flat"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "conv4_3_norm_mbox_conf"
+ type: "Convolution"
+ bottom: "conv4_3_norm"
+ top: "conv4_3_norm_mbox_conf"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 63
+ pad: 1
+ kernel_size: 3
+ stride: 1
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv4_3_norm_mbox_conf_perm"
+ type: "Permute"
+ bottom: "conv4_3_norm_mbox_conf"
+ top: "conv4_3_norm_mbox_conf_perm"
+ permute_param {
+ order: 0
+ order: 2
+ order: 3
+ order: 1
+ }
+}
+layer {
+ name: "conv4_3_norm_mbox_conf_flat"
+ type: "Flatten"
+ bottom: "conv4_3_norm_mbox_conf_perm"
+ top: "conv4_3_norm_mbox_conf_flat"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "conv4_3_norm_mbox_priorbox"
+ type: "PriorBox"
+ bottom: "conv4_3_norm"
+ bottom: "data"
+ top: "conv4_3_norm_mbox_priorbox"
+ prior_box_param {
+ min_size: 30.0
+ aspect_ratio: 2
+ flip: true
+ clip: true
+ variance: 0.1
+ variance: 0.1
+ variance: 0.2
+ variance: 0.2
+ }
+}
+layer {
+ name: "fc7_mbox_loc"
+ type: "Convolution"
+ bottom: "fc7"
+ top: "fc7_mbox_loc"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 24
+ pad: 1
+ kernel_size: 3
+ stride: 1
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "fc7_mbox_loc_perm"
+ type: "Permute"
+ bottom: "fc7_mbox_loc"
+ top: "fc7_mbox_loc_perm"
+ permute_param {
+ order: 0
+ order: 2
+ order: 3
+ order: 1
+ }
+}
+layer {
+ name: "fc7_mbox_loc_flat"
+ type: "Flatten"
+ bottom: "fc7_mbox_loc_perm"
+ top: "fc7_mbox_loc_flat"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "fc7_mbox_conf"
+ type: "Convolution"
+ bottom: "fc7"
+ top: "fc7_mbox_conf"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 126
+ pad: 1
+ kernel_size: 3
+ stride: 1
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "fc7_mbox_conf_perm"
+ type: "Permute"
+ bottom: "fc7_mbox_conf"
+ top: "fc7_mbox_conf_perm"
+ permute_param {
+ order: 0
+ order: 2
+ order: 3
+ order: 1
+ }
+}
+layer {
+ name: "fc7_mbox_conf_flat"
+ type: "Flatten"
+ bottom: "fc7_mbox_conf_perm"
+ top: "fc7_mbox_conf_flat"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "fc7_mbox_priorbox"
+ type: "PriorBox"
+ bottom: "fc7"
+ bottom: "data"
+ top: "fc7_mbox_priorbox"
+ prior_box_param {
+ min_size: 60.0
+ max_size: 114.0
+ aspect_ratio: 2
+ aspect_ratio: 3
+ flip: true
+ clip: true
+ variance: 0.1
+ variance: 0.1
+ variance: 0.2
+ variance: 0.2
+ }
+}
+layer {
+ name: "conv6_2_mbox_loc"
+ type: "Convolution"
+ bottom: "conv6_2"
+ top: "conv6_2_mbox_loc"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 24
+ pad: 1
+ kernel_size: 3
+ stride: 1
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv6_2_mbox_loc_perm"
+ type: "Permute"
+ bottom: "conv6_2_mbox_loc"
+ top: "conv6_2_mbox_loc_perm"
+ permute_param {
+ order: 0
+ order: 2
+ order: 3
+ order: 1
+ }
+}
+layer {
+ name: "conv6_2_mbox_loc_flat"
+ type: "Flatten"
+ bottom: "conv6_2_mbox_loc_perm"
+ top: "conv6_2_mbox_loc_flat"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "conv6_2_mbox_conf"
+ type: "Convolution"
+ bottom: "conv6_2"
+ top: "conv6_2_mbox_conf"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 126
+ pad: 1
+ kernel_size: 3
+ stride: 1
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv6_2_mbox_conf_perm"
+ type: "Permute"
+ bottom: "conv6_2_mbox_conf"
+ top: "conv6_2_mbox_conf_perm"
+ permute_param {
+ order: 0
+ order: 2
+ order: 3
+ order: 1
+ }
+}
+layer {
+ name: "conv6_2_mbox_conf_flat"
+ type: "Flatten"
+ bottom: "conv6_2_mbox_conf_perm"
+ top: "conv6_2_mbox_conf_flat"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "conv6_2_mbox_priorbox"
+ type: "PriorBox"
+ bottom: "conv6_2"
+ bottom: "data"
+ top: "conv6_2_mbox_priorbox"
+ prior_box_param {
+ min_size: 114.0
+ max_size: 168.0
+ aspect_ratio: 2
+ aspect_ratio: 3
+ flip: true
+ clip: true
+ variance: 0.1
+ variance: 0.1
+ variance: 0.2
+ variance: 0.2
+ }
+}
+layer {
+ name: "conv7_2_mbox_loc"
+ type: "Convolution"
+ bottom: "conv7_2"
+ top: "conv7_2_mbox_loc"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 24
+ pad: 1
+ kernel_size: 3
+ stride: 1
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv7_2_mbox_loc_perm"
+ type: "Permute"
+ bottom: "conv7_2_mbox_loc"
+ top: "conv7_2_mbox_loc_perm"
+ permute_param {
+ order: 0
+ order: 2
+ order: 3
+ order: 1
+ }
+}
+layer {
+ name: "conv7_2_mbox_loc_flat"
+ type: "Flatten"
+ bottom: "conv7_2_mbox_loc_perm"
+ top: "conv7_2_mbox_loc_flat"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "conv7_2_mbox_conf"
+ type: "Convolution"
+ bottom: "conv7_2"
+ top: "conv7_2_mbox_conf"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 126
+ pad: 1
+ kernel_size: 3
+ stride: 1
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv7_2_mbox_conf_perm"
+ type: "Permute"
+ bottom: "conv7_2_mbox_conf"
+ top: "conv7_2_mbox_conf_perm"
+ permute_param {
+ order: 0
+ order: 2
+ order: 3
+ order: 1
+ }
+}
+layer {
+ name: "conv7_2_mbox_conf_flat"
+ type: "Flatten"
+ bottom: "conv7_2_mbox_conf_perm"
+ top: "conv7_2_mbox_conf_flat"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "conv7_2_mbox_priorbox"
+ type: "PriorBox"
+ bottom: "conv7_2"
+ bottom: "data"
+ top: "conv7_2_mbox_priorbox"
+ prior_box_param {
+ min_size: 168.0
+ max_size: 222.0
+ aspect_ratio: 2
+ aspect_ratio: 3
+ flip: true
+ clip: true
+ variance: 0.1
+ variance: 0.1
+ variance: 0.2
+ variance: 0.2
+ }
+}
+layer {
+ name: "conv8_2_mbox_loc"
+ type: "Convolution"
+ bottom: "conv8_2"
+ top: "conv8_2_mbox_loc"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 24
+ pad: 1
+ kernel_size: 3
+ stride: 1
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv8_2_mbox_loc_perm"
+ type: "Permute"
+ bottom: "conv8_2_mbox_loc"
+ top: "conv8_2_mbox_loc_perm"
+ permute_param {
+ order: 0
+ order: 2
+ order: 3
+ order: 1
+ }
+}
+layer {
+ name: "conv8_2_mbox_loc_flat"
+ type: "Flatten"
+ bottom: "conv8_2_mbox_loc_perm"
+ top: "conv8_2_mbox_loc_flat"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "conv8_2_mbox_conf"
+ type: "Convolution"
+ bottom: "conv8_2"
+ top: "conv8_2_mbox_conf"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 126
+ pad: 1
+ kernel_size: 3
+ stride: 1
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "conv8_2_mbox_conf_perm"
+ type: "Permute"
+ bottom: "conv8_2_mbox_conf"
+ top: "conv8_2_mbox_conf_perm"
+ permute_param {
+ order: 0
+ order: 2
+ order: 3
+ order: 1
+ }
+}
+layer {
+ name: "conv8_2_mbox_conf_flat"
+ type: "Flatten"
+ bottom: "conv8_2_mbox_conf_perm"
+ top: "conv8_2_mbox_conf_flat"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "conv8_2_mbox_priorbox"
+ type: "PriorBox"
+ bottom: "conv8_2"
+ bottom: "data"
+ top: "conv8_2_mbox_priorbox"
+ prior_box_param {
+ min_size: 222.0
+ max_size: 276.0
+ aspect_ratio: 2
+ aspect_ratio: 3
+ flip: true
+ clip: true
+ variance: 0.1
+ variance: 0.1
+ variance: 0.2
+ variance: 0.2
+ }
+}
+layer {
+ name: "pool6_mbox_loc"
+ type: "Convolution"
+ bottom: "pool6"
+ top: "pool6_mbox_loc"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 24
+ pad: 1
+ kernel_size: 3
+ stride: 1
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "pool6_mbox_loc_perm"
+ type: "Permute"
+ bottom: "pool6_mbox_loc"
+ top: "pool6_mbox_loc_perm"
+ permute_param {
+ order: 0
+ order: 2
+ order: 3
+ order: 1
+ }
+}
+layer {
+ name: "pool6_mbox_loc_flat"
+ type: "Flatten"
+ bottom: "pool6_mbox_loc_perm"
+ top: "pool6_mbox_loc_flat"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "pool6_mbox_conf"
+ type: "Convolution"
+ bottom: "pool6"
+ top: "pool6_mbox_conf"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 126
+ pad: 1
+ kernel_size: 3
+ stride: 1
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "pool6_mbox_conf_perm"
+ type: "Permute"
+ bottom: "pool6_mbox_conf"
+ top: "pool6_mbox_conf_perm"
+ permute_param {
+ order: 0
+ order: 2
+ order: 3
+ order: 1
+ }
+}
+layer {
+ name: "pool6_mbox_conf_flat"
+ type: "Flatten"
+ bottom: "pool6_mbox_conf_perm"
+ top: "pool6_mbox_conf_flat"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "pool6_mbox_priorbox"
+ type: "PriorBox"
+ bottom: "pool6"
+ bottom: "data"
+ top: "pool6_mbox_priorbox"
+ prior_box_param {
+ min_size: 276.0
+ max_size: 330.0
+ aspect_ratio: 2
+ aspect_ratio: 3
+ flip: true
+ clip: true
+ variance: 0.1
+ variance: 0.1
+ variance: 0.2
+ variance: 0.2
+ }
+}
+layer {
+ name: "mbox_loc"
+ type: "Concat"
+ bottom: "conv4_3_norm_mbox_loc_flat"
+ bottom: "fc7_mbox_loc_flat"
+ bottom: "conv6_2_mbox_loc_flat"
+ bottom: "conv7_2_mbox_loc_flat"
+ bottom: "conv8_2_mbox_loc_flat"
+ bottom: "pool6_mbox_loc_flat"
+ top: "mbox_loc"
+ concat_param {
+ axis: 1
+ }
+}
+layer {
+ name: "mbox_conf"
+ type: "Concat"
+ bottom: "conv4_3_norm_mbox_conf_flat"
+ bottom: "fc7_mbox_conf_flat"
+ bottom: "conv6_2_mbox_conf_flat"
+ bottom: "conv7_2_mbox_conf_flat"
+ bottom: "conv8_2_mbox_conf_flat"
+ bottom: "pool6_mbox_conf_flat"
+ top: "mbox_conf"
+ concat_param {
+ axis: 1
+ }
+}
+layer {
+ name: "mbox_priorbox"
+ type: "Concat"
+ bottom: "conv4_3_norm_mbox_priorbox"
+ bottom: "fc7_mbox_priorbox"
+ bottom: "conv6_2_mbox_priorbox"
+ bottom: "conv7_2_mbox_priorbox"
+ bottom: "conv8_2_mbox_priorbox"
+ bottom: "pool6_mbox_priorbox"
+ top: "mbox_priorbox"
+ concat_param {
+ axis: 2
+ }
+}
+layer {
+ name: "mbox_conf_reshape"
+ type: "Reshape"
+ bottom: "mbox_conf"
+ top: "mbox_conf_reshape"
+ reshape_param {
+ shape {
+ dim: 0
+ dim: -1
+ dim: 21
+ }
+ }
+}
+layer {
+ name: "mbox_conf_softmax"
+ type: "Softmax"
+ bottom: "mbox_conf_reshape"
+ top: "mbox_conf_softmax"
+ softmax_param {
+ axis: 2
+ }
+}
+layer {
+ name: "mbox_conf_flatten"
+ type: "Flatten"
+ bottom: "mbox_conf_softmax"
+ top: "mbox_conf_flatten"
+ flatten_param {
+ axis: 1
+ }
+}
+layer {
+ name: "detection_out"
+ type: "DetectionOutput"
+ bottom: "mbox_loc"
+ bottom: "mbox_conf_flatten"
+ bottom: "mbox_priorbox"
+ top: "detection_out"
+ include {
+ phase: TEST
+ }
+ detection_output_param {
+ num_classes: 21
+ share_location: true
+ background_label_id: 0
+ nms_threshold: 0.45
+ top_k: 400
+ code_type: CENTER_SIZE
+ keep_top_k: 200
+ confidence_threshold: 0.01
+ }
+}
diff --git a/contrib/modules/dnn/samples/bvlc_googlenet.prototxt b/samples/data/dnn/bvlc_googlenet.prototxt
similarity index 100%
rename from contrib/modules/dnn/samples/bvlc_googlenet.prototxt
rename to samples/data/dnn/bvlc_googlenet.prototxt
diff --git a/samples/data/dnn/enet-classes.txt b/samples/data/dnn/enet-classes.txt
new file mode 100644
index 0000000..303bf6f
--- /dev/null
+++ b/samples/data/dnn/enet-classes.txt
@@ -0,0 +1,20 @@
+Unlabeled 0 0 0
+Road 128 64 128
+Sidewalk 244 35 232
+Building 70 70 70
+Wall 102 102 156
+Fence 190 153 153
+Pole 153 153 153
+TrafficLight 250 170 30
+TrafficSign 220 220 0
+Vegetation 107 142 35
+Terrain 152 251 152
+Sky 70 130 180
+Person 220 20 60
+Rider 255 0 0
+Car 0 0 142
+Truck 0 0 70
+Bus 0 60 100
+Train 0 80 100
+Motorcycle 0 0 230
+Bicycle 119 11 32
\ No newline at end of file
diff --git a/contrib/modules/dnn/samples/fcn32s-heavy-pascal.prototxt b/samples/data/dnn/fcn32s-heavy-pascal.prototxt
old mode 100755
new mode 100644
similarity index 100%
rename from contrib/modules/dnn/samples/fcn32s-heavy-pascal.prototxt
rename to samples/data/dnn/fcn32s-heavy-pascal.prototxt
diff --git a/contrib/modules/dnn/samples/fcn8s-heavy-pascal.prototxt b/samples/data/dnn/fcn8s-heavy-pascal.prototxt
old mode 100755
new mode 100644
similarity index 100%
rename from contrib/modules/dnn/samples/fcn8s-heavy-pascal.prototxt
rename to samples/data/dnn/fcn8s-heavy-pascal.prototxt
diff --git a/contrib/modules/dnn/samples/pascal-classes.txt b/samples/data/dnn/pascal-classes.txt
old mode 100755
new mode 100644
similarity index 100%
rename from contrib/modules/dnn/samples/pascal-classes.txt
rename to samples/data/dnn/pascal-classes.txt
diff --git a/contrib/modules/dnn/samples/rgb.jpg b/samples/data/dnn/rgb.jpg
old mode 100755
new mode 100644
similarity index 100%
rename from contrib/modules/dnn/samples/rgb.jpg
rename to samples/data/dnn/rgb.jpg
diff --git a/contrib/modules/dnn/tutorials/images/space_shuttle.jpg b/samples/data/dnn/space_shuttle.jpg
similarity index 100%
rename from contrib/modules/dnn/tutorials/images/space_shuttle.jpg
rename to samples/data/dnn/space_shuttle.jpg
diff --git a/contrib/modules/dnn/samples/synset_words.txt b/samples/data/dnn/synset_words.txt
similarity index 100%
rename from contrib/modules/dnn/samples/synset_words.txt
rename to samples/data/dnn/synset_words.txt
diff --git a/samples/data/lena_tmpl.jpg b/samples/data/lena_tmpl.jpg
deleted file mode 100644
index 0c9fc20..0000000
Binary files a/samples/data/lena_tmpl.jpg and /dev/null differ
diff --git a/samples/dnn/CMakeLists.txt b/samples/dnn/CMakeLists.txt
new file mode 100644
index 0000000..83ac3cd
--- /dev/null
+++ b/samples/dnn/CMakeLists.txt
@@ -0,0 +1,55 @@
+SET(OPENCV_DNN_SAMPLES_REQUIRED_DEPS opencv_core opencv_imgproc opencv_dnn
+ opencv_imgcodecs opencv_videoio opencv_highgui
+ ${OpenCV_LIB_COMPONENTS})
+
+ocv_check_dependencies(${OPENCV_DNN_SAMPLES_REQUIRED_DEPS})
+
+
+if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
+ project(dnn_samples)
+
+ ocv_include_directories("${OpenCV_SOURCE_DIR}/include")
+ ocv_include_modules_recurse(${OPENCV_DNN_SAMPLES_REQUIRED_DEPS})
+
+ # ---------------------------------------------
+ # Define executable targets
+ # ---------------------------------------------
+ MACRO(OPENCV_DEFINE_DNN_EXAMPLE name srcs)
+ set(sample_kind example_dnn)
+ set(sample_subfolder "dnn")
+
+ set(the_target "${sample_kind}_${name}")
+ add_executable(${the_target} ${srcs})
+ ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_DNN_SAMPLES_REQUIRED_DEPS})
+
+ set_target_properties(${the_target} PROPERTIES
+ OUTPUT_NAME "${sample_kind}-${name}"
+ PROJECT_LABEL "(${sample_KIND}) ${name}")
+
+ if(ENABLE_SOLUTION_FOLDERS)
+ set_target_properties(${the_target} PROPERTIES FOLDER "samples/${sample_subfolder}")
+ endif()
+
+ if(WIN32)
+ if (MSVC AND NOT BUILD_SHARED_LIBS)
+ set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
+ endif()
+ install(TARGETS ${the_target}
+ RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${sample_subfolder}" COMPONENT samples)
+ endif()
+ ENDMACRO()
+
+ file(GLOB_RECURSE dnn_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
+
+ foreach(sample_filename ${dnn_samples})
+ get_filename_component(sample ${sample_filename} NAME_WE)
+ OPENCV_DEFINE_DNN_EXAMPLE(${sample} ${sample_filename})
+ endforeach()
+endif()
+
+if(INSTALL_C_EXAMPLES AND NOT WIN32)
+ file(GLOB C_SAMPLES *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd )
+ install(FILES ${C_SAMPLES}
+ DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/dnn
+ PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples)
+endif()
diff --git a/samples/dnn/caffe_googlenet.cpp b/samples/dnn/caffe_googlenet.cpp
new file mode 100644
index 0000000..256bcb4
--- /dev/null
+++ b/samples/dnn/caffe_googlenet.cpp
@@ -0,0 +1,152 @@
+/**M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+#include <opencv2/dnn.hpp>
+#include <opencv2/imgproc.hpp>
+#include <opencv2/highgui.hpp>
+#include <opencv2/core/utils/trace.hpp>
+using namespace cv;
+using namespace cv::dnn;
+
+#include <fstream>
+#include <iostream>
+#include <cstdlib>
+using namespace std;
+
+/* Find best class for the blob (i. e. class with maximal probability) */
+static void getMaxClass(const Mat &probBlob, int *classId, double *classProb)
+{
+ Mat probMat = probBlob.reshape(1, 1); //reshape the blob to 1x1000 matrix
+ Point classNumber;
+
+ minMaxLoc(probMat, NULL, classProb, NULL, &classNumber);
+ *classId = classNumber.x;
+}
+
+static std::vector<String> readClassNames(const char *filename = "synset_words.txt")
+{
+ std::vector<String> classNames;
+
+ std::ifstream fp(filename);
+ if (!fp.is_open())
+ {
+ std::cerr << "File with classes labels not found: " << filename << std::endl;
+ exit(-1);
+ }
+
+ std::string name;
+ while (!fp.eof())
+ {
+ std::getline(fp, name);
+ if (name.length())
+ classNames.push_back( name.substr(name.find(' ')+1) );
+ }
+
+ fp.close();
+ return classNames;
+}
+
+int main(int argc, char **argv)
+{
+ CV_TRACE_FUNCTION();
+
+ String modelTxt = "bvlc_googlenet.prototxt";
+ String modelBin = "bvlc_googlenet.caffemodel";
+ String imageFile = (argc > 1) ? argv[1] : "space_shuttle.jpg";
+
+ //! [Read and initialize network]
+ Net net = dnn::readNetFromCaffe(modelTxt, modelBin);
+ //! [Read and initialize network]
+
+ //! [Check that network was read successfully]
+ if (net.empty())
+ {
+ std::cerr << "Can't load network by using the following files: " << std::endl;
+ std::cerr << "prototxt: " << modelTxt << std::endl;
+ std::cerr << "caffemodel: " << modelBin << std::endl;
+ std::cerr << "bvlc_googlenet.caffemodel can be downloaded here:" << std::endl;
+ std::cerr << "http://dl.caffe.berkeleyvision.org/bvlc_googlenet.caffemodel" << std::endl;
+ exit(-1);
+ }
+ //! [Check that network was read successfully]
+
+ //! [Prepare blob]
+ Mat img = imread(imageFile);
+ if (img.empty())
+ {
+ std::cerr << "Can't read image from the file: " << imageFile << std::endl;
+ exit(-1);
+ }
+
+ //GoogLeNet accepts only 224x224 RGB-images
+ Mat inputBlob = blobFromImage(img, 1, Size(224, 224),
+ Scalar(104, 117, 123)); //Convert Mat to batch of images
+ //! [Prepare blob]
+
+ Mat prob;
+ cv::TickMeter t;
+ for (int i = 0; i < 10; i++)
+ {
+ CV_TRACE_REGION("forward");
+ //! [Set input blob]
+ net.setInput(inputBlob, "data"); //set the network input
+ //! [Set input blob]
+ t.start();
+ //! [Make forward pass]
+ prob = net.forward("prob"); //compute output
+ //! [Make forward pass]
+ t.stop();
+ }
+
+ //! [Gather output]
+ int classId;
+ double classProb;
+ getMaxClass(prob, &classId, &classProb);//find the best class
+ //! [Gather output]
+
+ //! [Print results]
+ std::vector<String> classNames = readClassNames();
+ std::cout << "Best class: #" << classId << " '" << classNames.at(classId) << "'" << std::endl;
+ std::cout << "Probability: " << classProb * 100 << "%" << std::endl;
+ //! [Print results]
+ std::cout << "Time: " << (double)t.getTimeMilli() / t.getCounter() << " ms (average from " << t.getCounter() << " iterations)" << std::endl;
+
+ return 0;
+} //main
diff --git a/samples/dnn/fcn_semsegm.cpp b/samples/dnn/fcn_semsegm.cpp
new file mode 100644
index 0000000..e8ae04e
--- /dev/null
+++ b/samples/dnn/fcn_semsegm.cpp
@@ -0,0 +1,152 @@
+#include <opencv2/dnn.hpp>
+#include <opencv2/imgproc.hpp>
+#include <opencv2/highgui.hpp>
+using namespace cv;
+using namespace cv::dnn;
+
+#include <fstream>
+#include <iostream>
+#include <cstdlib>
+using namespace std;
+
+static const string fcnType = "fcn8s";
+
+static vector<cv::Vec3b> readColors(const string &filename = "pascal-classes.txt")
+{
+ vector<cv::Vec3b> colors;
+
+ ifstream fp(filename.c_str());
+ if (!fp.is_open())
+ {
+ cerr << "File with colors not found: " << filename << endl;
+ exit(-1);
+ }
+
+ string line;
+ while (!fp.eof())
+ {
+ getline(fp, line);
+ if (line.length())
+ {
+ stringstream ss(line);
+
+ string name; ss >> name;
+ int temp;
+ cv::Vec3b color;
+ ss >> temp; color[0] = (uchar)temp;
+ ss >> temp; color[1] = (uchar)temp;
+ ss >> temp; color[2] = (uchar)temp;
+ colors.push_back(color);
+ }
+ }
+
+ fp.close();
+ return colors;
+}
+
+static void colorizeSegmentation(const Mat &score, const vector<cv::Vec3b> &colors, cv::Mat &segm)
+{
+ const int rows = score.size[2];
+ const int cols = score.size[3];
+ const int chns = score.size[1];
+
+ cv::Mat maxCl(rows, cols, CV_8UC1);
+ cv::Mat maxVal(rows, cols, CV_32FC1);
+ for (int ch = 0; ch < chns; ch++)
+ {
+ for (int row = 0; row < rows; row++)
+ {
+ const float *ptrScore = score.ptr<float>(0, ch, row);
+ uchar *ptrMaxCl = maxCl.ptr<uchar>(row);
+ float *ptrMaxVal = maxVal.ptr<float>(row);
+ for (int col = 0; col < cols; col++)
+ {
+ if (ptrScore[col] > ptrMaxVal[col])
+ {
+ ptrMaxVal[col] = ptrScore[col];
+ ptrMaxCl[col] = (uchar)ch;
+ }
+ }
+ }
+ }
+
+ segm.create(rows, cols, CV_8UC3);
+ for (int row = 0; row < rows; row++)
+ {
+ const uchar *ptrMaxCl = maxCl.ptr<uchar>(row);
+ cv::Vec3b *ptrSegm = segm.ptr<cv::Vec3b>(row);
+ for (int col = 0; col < cols; col++)
+ {
+ ptrSegm[col] = colors[ptrMaxCl[col]];
+ }
+ }
+
+}
+
+int main(int argc, char **argv)
+{
+ String modelTxt = fcnType + "-heavy-pascal.prototxt";
+ String modelBin = fcnType + "-heavy-pascal.caffemodel";
+ String imageFile = (argc > 1) ? argv[1] : "rgb.jpg";
+
+ vector<cv::Vec3b> colors = readColors();
+
+ //! [Create the importer of Caffe model]
+ Ptr<dnn::Importer> importer;
+ try //Try to import Caffe GoogleNet model
+ {
+ importer = dnn::createCaffeImporter(modelTxt, modelBin);
+ }
+ catch (const cv::Exception &err) //Importer can throw errors, we will catch them
+ {
+ cerr << err.msg << endl;
+ }
+ //! [Create the importer of Caffe model]
+
+ if (!importer)
+ {
+ cerr << "Can't load network by using the following files: " << endl;
+ cerr << "prototxt: " << modelTxt << endl;
+ cerr << "caffemodel: " << modelBin << endl;
+ cerr << fcnType << "-heavy-pascal.caffemodel can be downloaded here:" << endl;
+ cerr << "http://dl.caffe.berkeleyvision.org/" << fcnType << "-heavy-pascal.caffemodel" << endl;
+ exit(-1);
+ }
+
+ //! [Initialize network]
+ dnn::Net net;
+ importer->populateNet(net);
+ importer.release(); //We don't need importer anymore
+ //! [Initialize network]
+
+ //! [Prepare blob]
+ Mat img = imread(imageFile);
+ if (img.empty())
+ {
+ cerr << "Can't read image from the file: " << imageFile << endl;
+ exit(-1);
+ }
+
+ resize(img, img, Size(500, 500)); //FCN accepts 500x500 RGB-images
+ Mat inputBlob = blobFromImage(img); //Convert Mat to batch of images
+ //! [Prepare blob]
+
+ //! [Set input blob]
+ net.setInput(inputBlob, "data"); //set the network input
+ //! [Set input blob]
+
+ //! [Make forward pass]
+ double t = (double)cv::getTickCount();
+ Mat score = net.forward("score"); //compute output
+ t = (double)cv::getTickCount() - t;
+ printf("processing time: %.1fms\n", t*1000./getTickFrequency());
+ //! [Make forward pass]
+
+ Mat colorize;
+ colorizeSegmentation(score, colors, colorize);
+ Mat show;
+ addWeighted(img, 0.4, colorize, 0.6, 0.0, show);
+ imshow("show", show);
+ waitKey(0);
+ return 0;
+} //main
diff --git a/samples/dnn/googlenet_python.py b/samples/dnn/googlenet_python.py
new file mode 100644
index 0000000..1db2cbf
--- /dev/null
+++ b/samples/dnn/googlenet_python.py
@@ -0,0 +1,24 @@
+from __future__ import print_function
+import numpy as np
+import cv2
+from cv2 import dnn
+import timeit
+
+def timeit_forward(net):
+ print("Runtime:", timeit.timeit(lambda: net.forward(), number=10))
+
+def get_class_list():
+ with open('synset_words.txt', 'rt') as f:
+ return [x[x.find(" ") + 1:] for x in f]
+
+blob = dnn.blobFromImage(cv2.imread('space_shuttle.jpg'), 1, (224, 224), (104, 117, 123))
+print("Input:", blob.shape, blob.dtype)
+
+net = dnn.readNetFromCaffe('bvlc_googlenet.prototxt', 'bvlc_googlenet.caffemodel')
+net.setInput(blob)
+prob = net.forward()
+#timeit_forward(net) #Uncomment to check performance
+
+print("Output:", prob.shape, prob.dtype)
+classes = get_class_list()
+print("Best match", classes[prob.argmax()])
\ No newline at end of file
diff --git a/samples/dnn/mobilenet_ssd_python.py b/samples/dnn/mobilenet_ssd_python.py
new file mode 100644
index 0000000..44b5b60
--- /dev/null
+++ b/samples/dnn/mobilenet_ssd_python.py
@@ -0,0 +1,87 @@
+import numpy as np
+import argparse
+
+try:
+ import cv2 as cv
+except ImportError:
+ raise ImportError('Can\'t find OpenCV Python module. If you\'ve built it from sources without installation, '
+ 'configure environemnt variable PYTHONPATH to "opencv_build_dir/lib" directory (with "python3" subdirectory if required)')
+
+inWidth = 300
+inHeight = 300
+WHRatio = inWidth / float(inHeight)
+inScaleFactor = 0.007843
+meanVal = 127.5
+
+classNames = ('background',
+ 'aeroplane', 'bicycle', 'bird', 'boat',
+ 'bottle', 'bus', 'car', 'cat', 'chair',
+ 'cow', 'diningtable', 'dog', 'horse',
+ 'motorbike', 'person', 'pottedplant',
+ 'sheep', 'sofa', 'train', 'tvmonitor')
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser()
+ parser.add_argument("--video", help="path to video file. If empty, camera's stream will be used")
+ parser.add_argument("--prototxt", default="MobileNetSSD_300x300.prototxt",
+ help="path to caffe prototxt")
+ parser.add_argument("-c", "--caffemodel", help="path to caffemodel file, download it here: "
+ "https://github.com/chuanqi305/MobileNet-SSD/blob/master/MobileNetSSD_train.caffemodel")
+ parser.add_argument("--thr", default=0.2, help="confidence threshold to filter out weak detections")
+ args = parser.parse_args()
+
+ net = dnn.readNetFromCaffe(args.prototxt, args.caffemodel)
+
+ if len(args.video):
+ cap = cv2.VideoCapture(args.video)
+ else:
+ cap = cv2.VideoCapture(0)
+
+ while True:
+ # Capture frame-by-frame
+ ret, frame = cap.read()
+ blob = dnn.blobFromImage(frame, inScaleFactor, (inWidth, inHeight), meanVal)
+ net.setInput(blob)
+ detections = net.forward()
+
+ cols = frame.shape[1]
+ rows = frame.shape[0]
+
+ if cols / float(rows) > WHRatio:
+ cropSize = (int(rows * WHRatio), rows)
+ else:
+ cropSize = (cols, int(cols / WHRatio))
+
+ y1 = (rows - cropSize[1]) / 2
+ y2 = y1 + cropSize[1]
+ x1 = (cols - cropSize[0]) / 2
+ x2 = x1 + cropSize[0]
+ frame = frame[y1:y2, x1:x2]
+
+ cols = frame.shape[1]
+ rows = frame.shape[0]
+
+ for i in range(detections.shape[2]):
+ confidence = detections[0, 0, i, 2]
+ if confidence > args.thr:
+ class_id = int(detections[0, 0, i, 1])
+
+ xLeftBottom = int(detections[0, 0, i, 3] * cols)
+ yLeftBottom = int(detections[0, 0, i, 4] * rows)
+ xRightTop = int(detections[0, 0, i, 5] * cols)
+ yRightTop = int(detections[0, 0, i, 6] * rows)
+
+ cv2.rectangle(frame, (xLeftBottom, yLeftBottom), (xRightTop, yRightTop),
+ (0, 255, 0))
+ label = classNames[class_id] + ": " + str(confidence)
+ labelSize, baseLine = cv2.getTextSize(label, cv2.FONT_HERSHEY_SIMPLEX, 0.5, 1)
+
+ cv2.rectangle(frame, (xLeftBottom, yLeftBottom - labelSize[1]),
+ (xLeftBottom + labelSize[0], yLeftBottom + baseLine),
+ (255, 255, 255), cv2.FILLED)
+ cv2.putText(frame, label, (xLeftBottom, yLeftBottom),
+ cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 0))
+
+ cv2.imshow("detections", frame)
+ if cv2.waitKey(1) >= 0:
+ break
diff --git a/samples/dnn/squeezenet_halide.cpp b/samples/dnn/squeezenet_halide.cpp
new file mode 100644
index 0000000..ecc730c
--- /dev/null
+++ b/samples/dnn/squeezenet_halide.cpp
@@ -0,0 +1,118 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+//
+// Copyright (C) 2017, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+
+// Sample of using Halide backend in OpenCV deep learning module.
+// Based on caffe_googlenet.cpp.
+
+#include <opencv2/dnn.hpp>
+#include <opencv2/imgproc.hpp>
+#include <opencv2/highgui.hpp>
+using namespace cv;
+using namespace cv::dnn;
+
+#include <fstream>
+#include <iostream>
+#include <cstdlib>
+
+/* Find best class for the blob (i. e. class with maximal probability) */
+static void getMaxClass(const Mat &probBlob, int *classId, double *classProb)
+{
+ Mat probMat = probBlob.reshape(1, 1); //reshape the blob to 1x1000 matrix
+ Point classNumber;
+
+ minMaxLoc(probMat, NULL, classProb, NULL, &classNumber);
+ *classId = classNumber.x;
+}
+
+static std::vector<std::string> readClassNames(const char *filename = "synset_words.txt")
+{
+ std::vector<std::string> classNames;
+
+ std::ifstream fp(filename);
+ if (!fp.is_open())
+ {
+ std::cerr << "File with classes labels not found: " << filename << std::endl;
+ exit(-1);
+ }
+
+ std::string name;
+ while (!fp.eof())
+ {
+ std::getline(fp, name);
+ if (name.length())
+ classNames.push_back( name.substr(name.find(' ')+1) );
+ }
+
+ fp.close();
+ return classNames;
+}
+
+int main(int argc, char **argv)
+{
+ std::string modelTxt = "train_val.prototxt";
+ std::string modelBin = "squeezenet_v1.1.caffemodel";
+ std::string imageFile = (argc > 1) ? argv[1] : "space_shuttle.jpg";
+
+ //! [Read and initialize network]
+ Net net = dnn::readNetFromCaffe(modelTxt, modelBin);
+ //! [Read and initialize network]
+
+ //! [Check that network was read successfully]
+ if (net.empty())
+ {
+ std::cerr << "Can't load network by using the following files: " << std::endl;
+ std::cerr << "prototxt: " << modelTxt << std::endl;
+ std::cerr << "caffemodel: " << modelBin << std::endl;
+ std::cerr << "SqueezeNet v1.1 can be downloaded from:" << std::endl;
+ std::cerr << "https://github.com/DeepScale/SqueezeNet/tree/master/SqueezeNet_v1.1" << std::endl;
+ exit(-1);
+ }
+ //! [Check that network was read successfully]
+
+ //! [Prepare blob]
+ Mat img = imread(imageFile);
+ if (img.empty())
+ {
+ std::cerr << "Can't read image from the file: " << imageFile << std::endl;
+ exit(-1);
+ }
+ if (img.channels() != 3)
+ {
+ std::cerr << "Image " << imageFile << " isn't 3-channel" << std::endl;
+ exit(-1);
+ }
+
+ resize(img, img, Size(227, 227)); // SqueezeNet v1.1 predict class by 3x227x227 input image.
+ Mat inputBlob = blobFromImage(img, 1.0, Size(), Scalar(), false); // Convert Mat to 4-dimensional batch.
+ //! [Prepare blob]
+
+ //! [Set input blob]
+ net.setInput(inputBlob); // Set the network input.
+ //! [Set input blob]
+
+ //! [Enable Halide backend]
+ net.setPreferableBackend(DNN_BACKEND_HALIDE); // Tell engine to use Halide where it possible.
+ //! [Enable Halide backend]
+
+ //! [Make forward pass]
+ Mat prob = net.forward("prob"); // Compute output.
+ //! [Make forward pass]
+
+ //! [Determine the best class]
+ int classId;
+ double classProb;
+ getMaxClass(prob, &classId, &classProb); // Find the best class.
+ //! [Determine the best class]
+
+ //! [Print results]
+ std::vector<std::string> classNames = readClassNames();
+ std::cout << "Best class: #" << classId << " '" << classNames.at(classId) << "'" << std::endl;
+ std::cout << "Probability: " << classProb * 100 << "%" << std::endl;
+ //! [Print results]
+
+ return 0;
+} //main
diff --git a/samples/dnn/ssd_mobilenet_object_detection.cpp b/samples/dnn/ssd_mobilenet_object_detection.cpp
new file mode 100644
index 0000000..423b34d
--- /dev/null
+++ b/samples/dnn/ssd_mobilenet_object_detection.cpp
@@ -0,0 +1,161 @@
+#include <opencv2/dnn.hpp>
+#include <opencv2/dnn/shape_utils.hpp>
+#include <opencv2/imgproc.hpp>
+#include <opencv2/highgui.hpp>
+
+using namespace cv;
+using namespace cv::dnn;
+
+#include <fstream>
+#include <iostream>
+#include <cstdlib>
+using namespace std;
+
+const size_t inWidth = 300;
+const size_t inHeight = 300;
+const float WHRatio = inWidth / (float)inHeight;
+const float inScaleFactor = 0.007843f;
+const float meanVal = 127.5;
+const char* classNames[] = {"background",
+ "aeroplane", "bicycle", "bird", "boat",
+ "bottle", "bus", "car", "cat", "chair",
+ "cow", "diningtable", "dog", "horse",
+ "motorbike", "person", "pottedplant",
+ "sheep", "sofa", "train", "tvmonitor"};
+
+const char* about = "This sample uses Single-Shot Detector "
+ "(https://arxiv.org/abs/1512.02325)"
+ "to detect objects on image.\n"
+ ".caffemodel model's file is avaliable here: "
+ "https://github.com/chuanqi305/MobileNet-SSD/blob/master/MobileNetSSD_train.caffemodel\n";
+
+const char* params
+ = "{ help | false | print usage }"
+ "{ proto | MobileNetSSD_300x300.prototxt | model configuration }"
+ "{ model | | model weights }"
+ "{ video | | video for detection }"
+ "{ out | | path to output video file}"
+ "{ min_confidence | 0.2 | min confidence }";
+
+int main(int argc, char** argv)
+{
+ cv::CommandLineParser parser(argc, argv, params);
+
+ if (parser.get<bool>("help"))
+ {
+ cout << about << endl;
+ parser.printMessage();
+ return 0;
+ }
+
+ String modelConfiguration = parser.get<string>("proto");
+ String modelBinary = parser.get<string>("model");
+
+ //! [Initialize network]
+ dnn::Net net = readNetFromCaffe(modelConfiguration, modelBinary);
+ //! [Initialize network]
+
+ VideoCapture cap(parser.get<String>("video"));
+ if(!cap.isOpened()) // check if we succeeded
+ {
+ cap = VideoCapture(0);
+ if(!cap.isOpened())
+ {
+ cout << "Couldn't find camera" << endl;
+ return -1;
+ }
+ }
+
+ Size inVideoSize = Size((int) cap.get(CV_CAP_PROP_FRAME_WIDTH), //Acquire input size
+ (int) cap.get(CV_CAP_PROP_FRAME_HEIGHT));
+
+ Size cropSize;
+ if (inVideoSize.width / (float)inVideoSize.height > WHRatio)
+ {
+ cropSize = Size(static_cast<int>(inVideoSize.height * WHRatio),
+ inVideoSize.height);
+ }
+ else
+ {
+ cropSize = Size(inVideoSize.width,
+ static_cast<int>(inVideoSize.width / WHRatio));
+ }
+
+ Rect crop(Point((inVideoSize.width - cropSize.width) / 2,
+ (inVideoSize.height - cropSize.height) / 2),
+ cropSize);
+
+ VideoWriter outputVideo;
+ outputVideo.open(parser.get<String>("out") ,
+ static_cast<int>(cap.get(CV_CAP_PROP_FOURCC)),
+ cap.get(CV_CAP_PROP_FPS), cropSize, true);
+
+ for(;;)
+ {
+ Mat frame;
+ cap >> frame; // get a new frame from camera
+ //! [Prepare blob]
+
+ Mat inputBlob = blobFromImage(frame, inScaleFactor,
+ Size(inWidth, inHeight), meanVal); //Convert Mat to batch of images
+ //! [Prepare blob]
+
+ //! [Set input blob]
+ net.setInput(inputBlob, "data"); //set the network input
+ //! [Set input blob]
+
+ TickMeter tm;
+ tm.start();
+ //! [Make forward pass]
+ Mat detection = net.forward("detection_out"); //compute output
+ tm.stop();
+ cout << "Inference time, ms: " << tm.getTimeMilli() << endl;
+ //! [Make forward pass]
+
+ Mat detectionMat(detection.size[2], detection.size[3], CV_32F, detection.ptr<float>());
+
+ frame = frame(crop);
+
+ float confidenceThreshold = parser.get<float>("min_confidence");
+ for(int i = 0; i < detectionMat.rows; i++)
+ {
+ float confidence = detectionMat.at<float>(i, 2);
+
+ if(confidence > confidenceThreshold)
+ {
+ size_t objectClass = (size_t)(detectionMat.at<float>(i, 1));
+
+ int xLeftBottom = static_cast<int>(detectionMat.at<float>(i, 3) * frame.cols);
+ int yLeftBottom = static_cast<int>(detectionMat.at<float>(i, 4) * frame.rows);
+ int xRightTop = static_cast<int>(detectionMat.at<float>(i, 5) * frame.cols);
+ int yRightTop = static_cast<int>(detectionMat.at<float>(i, 6) * frame.rows);
+
+ ostringstream ss;
+ ss << confidence;
+ String conf(ss.str());
+
+ Rect object((int)xLeftBottom, (int)yLeftBottom,
+ (int)(xRightTop - xLeftBottom),
+ (int)(yRightTop - yLeftBottom));
+
+ rectangle(frame, object, Scalar(0, 255, 0));
+ String label = String(classNames[objectClass]) + ": " + conf;
+ int baseLine = 0;
+ Size labelSize = getTextSize(label, FONT_HERSHEY_SIMPLEX, 0.5, 1, &baseLine);
+ rectangle(frame, Rect(Point(xLeftBottom, yLeftBottom - labelSize.height),
+ Size(labelSize.width, labelSize.height + baseLine)),
+ Scalar(255, 255, 255), CV_FILLED);
+ putText(frame, label, Point(xLeftBottom, yLeftBottom),
+ FONT_HERSHEY_SIMPLEX, 0.5, Scalar(0,0,0));
+ }
+ }
+
+ if (outputVideo.isOpened())
+ outputVideo << frame;
+
+ imshow("detections", frame);
+ if (waitKey(1) >= 0) break;
+ }
+
+ return 0;
+} // main
diff --git a/samples/dnn/ssd_object_detection.cpp b/samples/dnn/ssd_object_detection.cpp
new file mode 100644
index 0000000..7a51d3d
--- /dev/null
+++ b/samples/dnn/ssd_object_detection.cpp
@@ -0,0 +1,152 @@
+#include <opencv2/dnn.hpp>
+#include <opencv2/dnn/shape_utils.hpp>
+#include <opencv2/imgproc.hpp>
+#include <opencv2/highgui.hpp>
+using namespace cv;
+using namespace cv::dnn;
+
+#include <fstream>
+#include <iostream>
+#include <cstdlib>
+using namespace std;
+
+const size_t width = 300;
+const size_t height = 300;
+
+static Mat getMean(const size_t& imageHeight, const size_t& imageWidth)
+{
+ Mat mean;
+
+ const int meanValues[3] = {104, 117, 123};
+ vector<Mat> meanChannels;
+ for(int i = 0; i < 3; i++)
+ {
+ Mat channel((int)imageHeight, (int)imageWidth, CV_32F, Scalar(meanValues[i]));
+ meanChannels.push_back(channel);
+ }
+ cv::merge(meanChannels, mean);
+ return mean;
+}
+
+static Mat preprocess(const Mat& frame)
+{
+ Mat preprocessed;
+ frame.convertTo(preprocessed, CV_32F);
+ resize(preprocessed, preprocessed, Size(width, height)); //SSD accepts 300x300 RGB-images
+
+ Mat mean = getMean(width, height);
+ cv::subtract(preprocessed, mean, preprocessed);
+
+ return preprocessed;
+}
+
+const char* about = "This sample uses Single-Shot Detector "
+ "(https://arxiv.org/abs/1512.02325)"
+ "to detect objects on image\n"; // TODO: link
+
+const char* params
+ = "{ help | false | print usage }"
+ "{ proto | | model configuration }"
+ "{ model | | model weights }"
+ "{ image | | image for detection }"
+ "{ min_confidence | 0.5 | min confidence }";
+
+int main(int argc, char** argv)
+{
+ cv::CommandLineParser parser(argc, argv, params);
+
+ if (parser.get<bool>("help"))
+ {
+ std::cout << about << std::endl;
+ parser.printMessage();
+ return 0;
+ }
+
+ String modelConfiguration = parser.get<string>("proto");
+ String modelBinary = parser.get<string>("model");
+
+ //! [Create the importer of Caffe model]
+ Ptr<dnn::Importer> importer;
+
+ // Import Caffe SSD model
+ try
+ {
+ importer = dnn::createCaffeImporter(modelConfiguration, modelBinary);
+ }
+ catch (const cv::Exception &err) //Importer can throw errors, we will catch them
+ {
+ cerr << err.msg << endl;
+ }
+ //! [Create the importer of Caffe model]
+
+ if (!importer)
+ {
+ cerr << "Can't load network by using the following files: " << endl;
+ cerr << "prototxt: " << modelConfiguration << endl;
+ cerr << "caffemodel: " << modelBinary << endl;
+ cerr << "Models can be downloaded here:" << endl;
+ cerr << "https://github.com/weiliu89/caffe/tree/ssd#models" << endl;
+ exit(-1);
+ }
+
+ //! [Initialize network]
+ dnn::Net net;
+ importer->populateNet(net);
+ importer.release(); //We don't need importer anymore
+ //! [Initialize network]
+
+ cv::Mat frame = cv::imread(parser.get<string>("image"), -1);
+
+ if (frame.channels() == 4)
+ cvtColor(frame, frame, COLOR_BGRA2BGR);
+ //! [Prepare blob]
+ Mat preprocessedFrame = preprocess(frame);
+
+ Mat inputBlob = blobFromImage(preprocessedFrame); //Convert Mat to batch of images
+ //! [Prepare blob]
+
+ //! [Set input blob]
+ net.setInput(inputBlob, "data"); //set the network input
+ //! [Set input blob]
+
+ //! [Make forward pass]
+ Mat detection = net.forward("detection_out"); //compute output
+ //! [Make forward pass]
+
+ Mat detectionMat(detection.size[2], detection.size[3], CV_32F, detection.ptr<float>());
+
+ float confidenceThreshold = parser.get<float>("min_confidence");
+ for(int i = 0; i < detectionMat.rows; i++)
+ {
+ float confidence = detectionMat.at<float>(i, 2);
+
+ if(confidence > confidenceThreshold)
+ {
+ size_t objectClass = (size_t)(detectionMat.at<float>(i, 1));
+
+ float xLeftBottom = detectionMat.at<float>(i, 3) * frame.cols;
+ float yLeftBottom = detectionMat.at<float>(i, 4) * frame.rows;
+ float xRightTop = detectionMat.at<float>(i, 5) * frame.cols;
+ float yRightTop = detectionMat.at<float>(i, 6) * frame.rows;
+
+ std::cout << "Class: " << objectClass << std::endl;
+ std::cout << "Confidence: " << confidence << std::endl;
+
+ std::cout << " " << xLeftBottom
+ << " " << yLeftBottom
+ << " " << xRightTop
+ << " " << yRightTop << std::endl;
+
+ Rect object((int)xLeftBottom, (int)yLeftBottom,
+ (int)(xRightTop - xLeftBottom),
+ (int)(yRightTop - yLeftBottom));
+
+ rectangle(frame, object, Scalar(0, 255, 0));
+ }
+ }
+
+ imshow("detections", frame);
+ waitKey();
+
+ return 0;
+} // main
diff --git a/samples/dnn/tf_inception.cpp b/samples/dnn/tf_inception.cpp
new file mode 100644
index 0000000..44af4ce
--- /dev/null
+++ b/samples/dnn/tf_inception.cpp
@@ -0,0 +1,173 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+// Copyright (C) 2016, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+
+/*
+Sample of using OpenCV dnn module with Tensorflow Inception model.
+*/
+
+#include <opencv2/dnn.hpp>
+#include <opencv2/imgproc.hpp>
+#include <opencv2/highgui.hpp>
+using namespace cv;
+using namespace cv::dnn;
+
+#include <fstream>
+#include <iostream>
+#include <cstdlib>
+using namespace std;
+
+const String keys =
+ "{help h || Sample app for loading Inception TensorFlow model. "
+ "The model and class names list can be downloaded here: "
+ "https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip }"
+ "{model m |tensorflow_inception_graph.pb| path to TensorFlow .pb model file }"
+ "{image i || path to image file }"
+ "{i_blob | input | input blob name) }"
+ "{o_blob | softmax2 | output blob name) }"
+ "{c_names c | imagenet_comp_graph_label_strings.txt | path to file with classnames for class id }"
+ "{result r || path to save output blob (optional, binary format, NCHW order) }"
+ ;
+
+void getMaxClass(const Mat &probBlob, int *classId, double *classProb);
+std::vector<String> readClassNames(const char *filename);
+
+int main(int argc, char **argv)
+{
+ cv::CommandLineParser parser(argc, argv, keys);
+
+ if (parser.has("help"))
+ {
+ parser.printMessage();
+ return 0;
+ }
+
+ String modelFile = parser.get<String>("model");
+ String imageFile = parser.get<String>("image");
+ String inBlobName = parser.get<String>("i_blob");
+ String outBlobName = parser.get<String>("o_blob");
+
+ if (!parser.check())
+ {
+ parser.printErrors();
+ return 0;
+ }
+
+ String classNamesFile = parser.get<String>("c_names");
+ String resultFile = parser.get<String>("result");
+
+ //! [Create the importer of TensorFlow model]
+ Ptr<dnn::Importer> importer;
+ try //Try to import TensorFlow AlexNet model
+ {
+ importer = dnn::createTensorflowImporter(modelFile);
+ }
+ catch (const cv::Exception &err) //Importer can throw errors, we will catch them
+ {
+ std::cerr << err.msg << std::endl;
+ }
+ //! [Create the importer of Caffe model]
+
+ if (!importer)
+ {
+ std::cerr << "Can't load network by using the mode file: " << std::endl;
+ std::cerr << modelFile << std::endl;
+ exit(-1);
+ }
+
+ //! [Initialize network]
+ dnn::Net net;
+ importer->populateNet(net);
+ importer.release(); //We don't need importer anymore
+ //! [Initialize network]
+
+ //! [Prepare blob]
+ Mat img = imread(imageFile);
+ if (img.empty())
+ {
+ std::cerr << "Can't read image from the file: " << imageFile << std::endl;
+ exit(-1);
+ }
+
+ cv::Size inputImgSize = cv::Size(224, 224);
+
+ if (inputImgSize != img.size())
+ resize(img, img, inputImgSize); //Resize image to input size
+
+ Mat inputBlob = blobFromImage(img); //Convert Mat to image batch
+ //! [Prepare blob]
+ inputBlob -= 117.0;
+ //! [Set input blob]
+ net.setInput(inputBlob, inBlobName); //set the network input
+ //! [Set input blob]
+
+ cv::TickMeter tm;
+ tm.start();
+
+ //! [Make forward pass]
+ Mat result = net.forward(outBlobName); //compute output
+ //! [Make forward pass]
+
+ tm.stop();
+
+ if (!resultFile.empty()) {
+ CV_Assert(result.isContinuous());
+
+ ofstream fout(resultFile.c_str(), ios::out | ios::binary);
+ fout.write((char*)result.data, result.total() * sizeof(float));
+ fout.close();
+ }
+
+ std::cout << "Output blob shape " << result.size[0] << " x " << result.size[1] << " x " << result.size[2] << " x " << result.size[3] << std::endl;
+ std::cout << "Inference time, ms: " << tm.getTimeMilli() << std::endl;
+
+ if (!classNamesFile.empty()) {
+ std::vector<String> classNames = readClassNames(classNamesFile.c_str());
+
+ int classId;
+ double classProb;
+ getMaxClass(result, &classId, &classProb);//find the best class
+
+ //! [Print results]
+ std::cout << "Best class: #" << classId << " '" << classNames.at(classId) << "'" << std::endl;
+ std::cout << "Probability: " << classProb * 100 << "%" << std::endl;
+ }
+ return 0;
+} //main
+
+
+/* Find best class for the blob (i. e. class with maximal probability) */
+void getMaxClass(const Mat &probBlob, int *classId, double *classProb)
+{
+ Mat probMat = probBlob.reshape(1, 1); //reshape the blob to 1x1000 matrix
+ Point classNumber;
+
+ minMaxLoc(probMat, NULL, classProb, NULL, &classNumber);
+ *classId = classNumber.x;
+}
+
+std::vector<String> readClassNames(const char *filename)
+{
+ std::vector<String> classNames;
+
+ std::ifstream fp(filename);
+ if (!fp.is_open())
+ {
+ std::cerr << "File with classes labels not found: " << filename << std::endl;
+ exit(-1);
+ }
+
+ std::string name;
+ while (!fp.eof())
+ {
+ std::getline(fp, name);
+ if (name.length())
+ classNames.push_back( name );
+ }
+
+ fp.close();
+ return classNames;
+}
diff --git a/samples/dnn/torch_enet.cpp b/samples/dnn/torch_enet.cpp
new file mode 100644
index 0000000..4f9ad21
--- /dev/null
+++ b/samples/dnn/torch_enet.cpp
@@ -0,0 +1,209 @@
+/*
+Sample of using OpenCV dnn module with Torch ENet model.
+*/
+
+#include <opencv2/dnn.hpp>
+#include <opencv2/imgproc.hpp>
+#include <opencv2/highgui.hpp>
+using namespace cv;
+using namespace cv::dnn;
+
+#include <fstream>
+#include <iostream>
+#include <cstdlib>
+#include <sstream>
+using namespace std;
+
+const String keys =
+ "{help h || Sample app for loading ENet Torch model. "
+ "The model and class names list can be downloaded here: "
+ "https://www.dropbox.com/sh/dywzk3gyb12hpe5/AAD5YkUa8XgMpHs2gCRgmCVCa }"
+ "{model m || path to Torch .net model file (model_best.net) }"
+ "{image i || path to image file }"
+ "{c_names c || path to file with classnames for channels (optional, categories.txt) }"
+ "{result r || path to save output blob (optional, binary format, NCHW order) }"
+ "{show s || whether to show all output channels or not}"
+ "{o_blob || output blob's name. If empty, last blob's name in net is used}"
+ ;
+
+static void colorizeSegmentation(const Mat &score, Mat &segm,
+ Mat &legend, vector<String> &classNames, vector<Vec3b> &colors);
+static vector<Vec3b> readColors(const String &filename, vector<String>& classNames);
+
+int main(int argc, char **argv)
+{
+ CommandLineParser parser(argc, argv, keys);
+
+ if (parser.has("help"))
+ {
+ parser.printMessage();
+ return 0;
+ }
+
+ String modelFile = parser.get<String>("model");
+ String imageFile = parser.get<String>("image");
+
+ if (!parser.check())
+ {
+ parser.printErrors();
+ return 0;
+ }
+
+ String classNamesFile = parser.get<String>("c_names");
+ String resultFile = parser.get<String>("result");
+
+ //! [Read model and initialize network]
+ dnn::Net net = dnn::readNetFromTorch(modelFile);
+
+ //! [Prepare blob]
+ Mat img = imread(imageFile), input;
+ if (img.empty())
+ {
+ std::cerr << "Can't read image from the file: " << imageFile << std::endl;
+ exit(-1);
+ }
+
+ Size origSize = img.size();
+ Size inputImgSize = cv::Size(1024, 512);
+
+ if (inputImgSize != origSize)
+ resize(img, img, inputImgSize); //Resize image to input size
+
+ Mat inputBlob = blobFromImage(img, 1./255); //Convert Mat to image batch
+ //! [Prepare blob]
+
+ //! [Set input blob]
+ net.setInput(inputBlob, ""); //set the network input
+ //! [Set input blob]
+
+ TickMeter tm;
+
+ String oBlob = net.getLayerNames().back();
+ if (!parser.get<String>("o_blob").empty())
+ {
+ oBlob = parser.get<String>("o_blob");
+ }
+
+ //! [Make forward pass]
+ tm.start();
+ Mat result = net.forward(oBlob);
+ tm.stop();
+
+ if (!resultFile.empty()) {
+ CV_Assert(result.isContinuous());
+
+ ofstream fout(resultFile.c_str(), ios::out | ios::binary);
+ fout.write((char*)result.data, result.total() * sizeof(float));
+ fout.close();
+ }
+
+ std::cout << "Output blob: " << result.size[0] << " x " << result.size[1] << " x " << result.size[2] << " x " << result.size[3] << "\n";
+ std::cout << "Inference time, ms: " << tm.getTimeMilli() << std::endl;
+
+ if (parser.has("show"))
+ {
+ std::vector<String> classNames;
+ vector<cv::Vec3b> colors;
+ if(!classNamesFile.empty()) {
+ colors = readColors(classNamesFile, classNames);
+ }
+ Mat segm, legend;
+ colorizeSegmentation(result, segm, legend, classNames, colors);
+
+ Mat show;
+ addWeighted(img, 0.1, segm, 0.9, 0.0, show);
+
+ cv::resize(show, show, origSize, 0, 0, cv::INTER_NEAREST);
+ imshow("Result", show);
+ if(classNames.size())
+ imshow("Legend", legend);
+ waitKey();
+ }
+
+ return 0;
+} //main
+
+static void colorizeSegmentation(const Mat &score, Mat &segm, Mat &legend, vector<String> &classNames, vector<Vec3b> &colors)
+{
+ const int rows = score.size[2];
+ const int cols = score.size[3];
+ const int chns = score.size[1];
+
+ cv::Mat maxCl(rows, cols, CV_8UC1);
+ cv::Mat maxVal(rows, cols, CV_32FC1);
+ for (int ch = 0; ch < chns; ch++)
+ {
+ for (int row = 0; row < rows; row++)
+ {
+ const float *ptrScore = score.ptr<float>(0, ch, row);
+ uchar *ptrMaxCl = maxCl.ptr<uchar>(row);
+ float *ptrMaxVal = maxVal.ptr<float>(row);
+ for (int col = 0; col < cols; col++)
+ {
+ if (ptrScore[col] > ptrMaxVal[col])
+ {
+ ptrMaxVal[col] = ptrScore[col];
+ ptrMaxCl[col] = (uchar)ch;
+ }
+ }
+ }
+ }
+
+ segm.create(rows, cols, CV_8UC3);
+ for (int row = 0; row < rows; row++)
+ {
+ const uchar *ptrMaxCl = maxCl.ptr<uchar>(row);
+ cv::Vec3b *ptrSegm = segm.ptr<cv::Vec3b>(row);
+ for (int col = 0; col < cols; col++)
+ {
+ ptrSegm[col] = colors[ptrMaxCl[col]];
+ }
+ }
+
+ if (classNames.size() == colors.size())
+ {
+ int blockHeight = 30;
+ legend.create(blockHeight*(int)classNames.size(), 200, CV_8UC3);
+ for(int i = 0; i < (int)classNames.size(); i++)
+ {
+ cv::Mat block = legend.rowRange(i*blockHeight, (i+1)*blockHeight);
+ block = colors[i];
+ putText(block, classNames[i], Point(0, blockHeight/2), FONT_HERSHEY_SIMPLEX, 0.5, Scalar());
+ }
+ }
+}
+
+static vector<Vec3b> readColors(const String &filename, vector<String>& classNames)
+{
+ vector<cv::Vec3b> colors;
+ classNames.clear();
+
+ ifstream fp(filename.c_str());
+ if (!fp.is_open())
+ {
+ cerr << "File with colors not found: " << filename << endl;
+ exit(-1);
+ }
+
+ string line;
+ while (!fp.eof())
+ {
+ getline(fp, line);
+ if (line.length())
+ {
+ stringstream ss(line);
+
+ string name; ss >> name;
+ int temp;
+ cv::Vec3b color;
+ ss >> temp; color[0] = (uchar)temp;
+ ss >> temp; color[1] = (uchar)temp;
+ ss >> temp; color[2] = (uchar)temp;
+ classNames.push_back(name);
+ colors.push_back(color);
+ }
+ }
+
+ fp.close();
+ return colors;
+}
diff --git a/samples/gpu/CMakeLists.txt b/samples/gpu/CMakeLists.txt
index 8c97ea8..0f73467 100644
--- a/samples/gpu/CMakeLists.txt
+++ b/samples/gpu/CMakeLists.txt
@@ -14,27 +14,19 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
project("${project}_samples")
ocv_include_modules_recurse(${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})
- ocv_include_directories(
- "${OpenCV_SOURCE_DIR}/modules/gpu/src/nvidia"
- "${OpenCV_SOURCE_DIR}/modules/gpu/src/nvidia/core"
- )
if(HAVE_opencv_xfeatures2d)
- ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/xfeatures2d/include")
+ ocv_include_modules_recurse(opencv_xfeatures2d)
endif()
if(HAVE_opencv_cudacodec)
- ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudacodec/include")
+ ocv_include_modules_recurse(opencv_cudacodec)
endif()
if(HAVE_CUDA)
ocv_include_directories(${CUDA_INCLUDE_DIRS})
endif()
- if(HAVE_OPENCL)
- ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/ocl/include")
- endif()
-
if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
endif()
diff --git a/samples/gpu/cascadeclassifier.cpp b/samples/gpu/cascadeclassifier.cpp
index f59ff55..0f0b8f5 100644
--- a/samples/gpu/cascadeclassifier.cpp
+++ b/samples/gpu/cascadeclassifier.cpp
@@ -20,7 +20,7 @@ using namespace cv::cuda;
static void help()
{
- cout << "Usage: ./cascadeclassifier_gpu \n\t--cascade <cascade_file>\n\t(<image>|--video <video>|--camera <camera_id>)\n"
+ cout << "Usage: ./cascadeclassifier \n\t--cascade <cascade_file>\n\t(<image>|--video <video>|--camera <camera_id>)\n"
"Using OpenCV version " << CV_VERSION << endl << endl;
}
diff --git a/samples/gpu/driver_api_stereo_multi.cpp b/samples/gpu/driver_api_stereo_multi.cpp
index e487c31..b4fb34d 100644
--- a/samples/gpu/driver_api_stereo_multi.cpp
+++ b/samples/gpu/driver_api_stereo_multi.cpp
@@ -85,7 +85,7 @@ GpuMat d_result[2];
static void printHelp()
{
- std::cout << "Usage: driver_api_stereo_multi_gpu --left <left_image> --right <right_image>\n";
+ std::cout << "Usage: driver_api_stereo_multi --left <left_image> --right <right_image>\n";
}
int main(int argc, char** argv)
diff --git a/samples/gpu/farneback_optical_flow.cpp b/samples/gpu/farneback_optical_flow.cpp
index 798b108..b3d67b6 100644
--- a/samples/gpu/farneback_optical_flow.cpp
+++ b/samples/gpu/farneback_optical_flow.cpp
@@ -1,6 +1,7 @@
#include <iostream>
#include <vector>
#include <sstream>
+#include <cmath>
#include "opencv2/core.hpp"
#include "opencv2/core/utility.hpp"
diff --git a/samples/gpu/hog.cpp b/samples/gpu/hog.cpp
index 8f857da..b50ce72 100644
--- a/samples/gpu/hog.cpp
+++ b/samples/gpu/hog.cpp
@@ -99,7 +99,7 @@ private:
static void printHelp()
{
cout << "Histogram of Oriented Gradients descriptor and detector sample.\n"
- << "\nUsage: hog_gpu\n"
+ << "\nUsage: hog\n"
<< " (<image>|--video <vide>|--camera <camera_id>) # frames source\n"
<< " or"
<< " (--folder <folder_path>) # load images from folder\n"
diff --git a/samples/gpu/opengl.cpp b/samples/gpu/opengl.cpp
index 6bed4e3..dd2f913 100644
--- a/samples/gpu/opengl.cpp
+++ b/samples/gpu/opengl.cpp
@@ -1,13 +1,10 @@
#include <iostream>
-#ifdef WIN32
+#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN 1
#define NOMINMAX 1
#include <windows.h>
#endif
-#if defined(_WIN64)
- #include <windows.h>
-#endif
#if defined(__APPLE__)
#include <OpenGL/gl.h>
diff --git a/samples/gpu/performance/CMakeLists.txt b/samples/gpu/performance/CMakeLists.txt
index 9c9fb5b..2b1bf0b 100644
--- a/samples/gpu/performance/CMakeLists.txt
+++ b/samples/gpu/performance/CMakeLists.txt
@@ -4,11 +4,11 @@ file(GLOB sources "performance/*.cpp")
file(GLOB headers "performance/*.h")
if(HAVE_opencv_xfeatures2d)
- ocv_include_directories("${opencv_xfeatures2d_SOURCE_DIR}/include")
+ ocv_include_modules_recurse(opencv_xfeatures2d)
endif()
if(HAVE_opencv_bgsegm)
- ocv_include_directories("${opencv_bgsegm_SOURCE_DIR}/include")
+ ocv_include_modules_recurse(opencv_bgsegm)
endif()
add_executable(${the_target} ${sources} ${headers})
diff --git a/samples/gpu/pyrlk_optical_flow.cpp b/samples/gpu/pyrlk_optical_flow.cpp
index f13487b..fa6b376 100644
--- a/samples/gpu/pyrlk_optical_flow.cpp
+++ b/samples/gpu/pyrlk_optical_flow.cpp
@@ -1,13 +1,14 @@
#include <iostream>
#include <vector>
-#include "opencv2/core.hpp"
+#include <opencv2/core.hpp>
#include <opencv2/core/utility.hpp>
-#include "opencv2/imgproc.hpp"
-#include "opencv2/highgui.hpp"
-#include "opencv2/video.hpp"
-#include "opencv2/cudaoptflow.hpp"
-#include "opencv2/cudaimgproc.hpp"
+#include <opencv2/imgproc.hpp>
+#include <opencv2/highgui.hpp>
+#include <opencv2/video.hpp>
+#include <opencv2/cudaoptflow.hpp>
+#include <opencv2/cudaimgproc.hpp>
+#include <opencv2/cudaarithm.hpp>
using namespace std;
using namespace cv;
@@ -66,6 +67,132 @@ static void drawArrows(Mat& frame, const vector<Point2f>& prevPts, const vector<
}
}
+inline bool isFlowCorrect(Point2f u)
+{
+ return !cvIsNaN(u.x) && !cvIsNaN(u.y) && fabs(u.x) < 1e9 && fabs(u.y) < 1e9;
+}
+
+static Vec3b computeColor(float fx, float fy)
+{
+ static bool first = true;
+
+ // relative lengths of color transitions:
+ // these are chosen based on perceptual similarity
+ // (e.g. one can distinguish more shades between red and yellow
+ // than between yellow and green)
+ const int RY = 15;
+ const int YG = 6;
+ const int GC = 4;
+ const int CB = 11;
+ const int BM = 13;
+ const int MR = 6;
+ const int NCOLS = RY + YG + GC + CB + BM + MR;
+ static Vec3i colorWheel[NCOLS];
+
+ if (first)
+ {
+ int k = 0;
+
+ for (int i = 0; i < RY; ++i, ++k)
+ colorWheel[k] = Vec3i(255, 255 * i / RY, 0);
+
+ for (int i = 0; i < YG; ++i, ++k)
+ colorWheel[k] = Vec3i(255 - 255 * i / YG, 255, 0);
+
+ for (int i = 0; i < GC; ++i, ++k)
+ colorWheel[k] = Vec3i(0, 255, 255 * i / GC);
+
+ for (int i = 0; i < CB; ++i, ++k)
+ colorWheel[k] = Vec3i(0, 255 - 255 * i / CB, 255);
+
+ for (int i = 0; i < BM; ++i, ++k)
+ colorWheel[k] = Vec3i(255 * i / BM, 0, 255);
+
+ for (int i = 0; i < MR; ++i, ++k)
+ colorWheel[k] = Vec3i(255, 0, 255 - 255 * i / MR);
+
+ first = false;
+ }
+
+ const float rad = sqrt(fx * fx + fy * fy);
+ const float a = atan2(-fy, -fx) / (float)CV_PI;
+
+ const float fk = (a + 1.0f) / 2.0f * (NCOLS - 1);
+ const int k0 = static_cast<int>(fk);
+ const int k1 = (k0 + 1) % NCOLS;
+ const float f = fk - k0;
+
+ Vec3b pix;
+
+ for (int b = 0; b < 3; b++)
+ {
+ const float col0 = colorWheel[k0][b] / 255.0f;
+ const float col1 = colorWheel[k1][b] / 255.0f;
+
+ float col = (1 - f) * col0 + f * col1;
+
+ if (rad <= 1)
+ col = 1 - rad * (1 - col); // increase saturation with radius
+ else
+ col *= .75; // out of range
+
+ pix[2 - b] = static_cast<uchar>(255.0 * col);
+ }
+
+ return pix;
+}
+
+static void drawOpticalFlow(const Mat_<float>& flowx, const Mat_<float>& flowy, Mat& dst, float maxmotion = -1)
+{
+ dst.create(flowx.size(), CV_8UC3);
+ dst.setTo(Scalar::all(0));
+
+ // determine motion range:
+ float maxrad = maxmotion;
+
+ if (maxmotion <= 0)
+ {
+ maxrad = 1;
+ for (int y = 0; y < flowx.rows; ++y)
+ {
+ for (int x = 0; x < flowx.cols; ++x)
+ {
+ Point2f u(flowx(y, x), flowy(y, x));
+
+ if (!isFlowCorrect(u))
+ continue;
+
+ maxrad = max(maxrad, sqrt(u.x * u.x + u.y * u.y));
+ }
+ }
+ }
+
+ for (int y = 0; y < flowx.rows; ++y)
+ {
+ for (int x = 0; x < flowx.cols; ++x)
+ {
+ Point2f u(flowx(y, x), flowy(y, x));
+
+ if (isFlowCorrect(u))
+ dst.at<Vec3b>(y, x) = computeColor(u.x / maxrad, u.y / maxrad);
+ }
+ }
+}
+
+static void showFlow(const char* name, const GpuMat& d_flow)
+{
+ GpuMat planes[2];
+ cuda::split(d_flow, planes);
+
+ Mat flowx(planes[0]);
+ Mat flowy(planes[1]);
+
+ Mat out;
+ drawOpticalFlow(flowx, flowy, out, 10);
+
+ imshow(name, out);
+}
+
template <typename T> inline T clamp (T x, T a, T b)
{
return ((x) > (a) ? ((x) < (b) ? (x) : (b)) : (a));
@@ -80,15 +207,16 @@ template <typename T> inline T mapValue(T x, T a, T b, T c, T d)
int main(int argc, const char* argv[])
{
const char* keys =
- "{ h help | | print help message }"
+ "{ h help | | print help message }"
"{ l left | ../data/pic1.png | specify left image }"
"{ r right | ../data/pic2.png | specify right image }"
- "{ gray | | use grayscale sources [PyrLK Sparse] }"
- "{ win_size | 21 | specify windows size [PyrLK] }"
- "{ max_level | 3 | specify max level [PyrLK] }"
- "{ iters | 30 | specify iterations count [PyrLK] }"
- "{ points | 4000 | specify points count [GoodFeatureToTrack] }"
- "{ min_dist | 0 | specify minimal distance between points [GoodFeatureToTrack] }";
+ "{ flow | sparse | specify flow type [PyrLK] }"
+ "{ gray | | use grayscale sources [PyrLK Sparse] }"
+ "{ win_size | 21 | specify windows size [PyrLK] }"
+ "{ max_level | 3 | specify max level [PyrLK] }"
+ "{ iters | 30 | specify iterations count [PyrLK] }"
+ "{ points | 4000 | specify points count [GoodFeatureToTrack] }"
+ "{ min_dist | 0 | specify minimal distance between points [GoodFeatureToTrack] }";
CommandLineParser cmd(argc, argv, keys);
@@ -108,6 +236,22 @@ int main(int argc, const char* argv[])
return -1;
}
+ string flow_type = cmd.get<string>("flow");
+ bool is_sparse = true;
+ if (flow_type == "sparse")
+ {
+ is_sparse = true;
+ }
+ else if (flow_type == "dense")
+ {
+ is_sparse = false;
+ }
+ else
+ {
+ cerr << "please specify 'sparse' or 'dense' as flow type" << endl;
+ return -1;
+ }
+
bool useGray = cmd.has("gray");
int winSize = cmd.get<int>("win_size");
int maxLevel = cmd.get<int>("max_level");
@@ -124,9 +268,6 @@ int main(int argc, const char* argv[])
return -1;
}
- namedWindow("PyrLK [Sparse]", WINDOW_NORMAL);
- namedWindow("PyrLK [Dense] Flow Field", WINDOW_NORMAL);
-
cout << "Image size : " << frame0.cols << " x " << frame0.rows << endl;
cout << "Points count : " << points << endl;
@@ -138,43 +279,53 @@ int main(int argc, const char* argv[])
cv::cvtColor(frame1, frame1Gray, COLOR_BGR2GRAY);
// goodFeaturesToTrack
-
GpuMat d_frame0Gray(frame0Gray);
GpuMat d_prevPts;
Ptr<cuda::CornersDetector> detector = cuda::createGoodFeaturesToTrackDetector(d_frame0Gray.type(), points, 0.01, minDist);
-
detector->detect(d_frame0Gray, d_prevPts);
- // Sparse
-
- Ptr<cuda::SparsePyrLKOpticalFlow> d_pyrLK = cuda::SparsePyrLKOpticalFlow::create(
- Size(winSize, winSize), maxLevel, iters);
-
GpuMat d_frame0(frame0);
GpuMat d_frame1(frame1);
GpuMat d_frame1Gray(frame1Gray);
GpuMat d_nextPts;
GpuMat d_status;
+ GpuMat d_flow(frame0.size(), CV_32FC2);
- d_pyrLK->calc(useGray ? d_frame0Gray : d_frame0, useGray ? d_frame1Gray : d_frame1, d_prevPts, d_nextPts, d_status);
-
- // Draw arrows
-
- vector<Point2f> prevPts(d_prevPts.cols);
- download(d_prevPts, prevPts);
+ if (is_sparse)
+ {
+ // Sparse
+ Ptr<cuda::SparsePyrLKOpticalFlow> d_pyrLK_sparse = cuda::SparsePyrLKOpticalFlow::create(
+ Size(winSize, winSize), maxLevel, iters);
+ d_pyrLK_sparse->calc(useGray ? d_frame0Gray : d_frame0, useGray ? d_frame1Gray : d_frame1, d_prevPts, d_nextPts, d_status);
- vector<Point2f> nextPts(d_nextPts.cols);
- download(d_nextPts, nextPts);
+ // Draw arrows
+ vector<Point2f> prevPts(d_prevPts.cols);
+ download(d_prevPts, prevPts);
- vector<uchar> status(d_status.cols);
- download(d_status, status);
+ vector<Point2f> nextPts(d_nextPts.cols);
+ download(d_nextPts, nextPts);
- drawArrows(frame0, prevPts, nextPts, status, Scalar(255, 0, 0));
+ vector<uchar> status(d_status.cols);
+ download(d_status, status);
- imshow("PyrLK [Sparse]", frame0);
+ namedWindow("PyrLK [Sparse]", WINDOW_NORMAL);
+ drawArrows(frame0, prevPts, nextPts, status, Scalar(255, 0, 0));
+ imshow("PyrLK [Sparse]", frame0);
+ }
+ else
+ {
+ // Dense
+ Ptr<cuda::DensePyrLKOpticalFlow> d_pyrLK_dense = cuda::DensePyrLKOpticalFlow::create(
+ Size(winSize, winSize), maxLevel, iters);
+ d_pyrLK_dense->calc(d_frame0Gray, d_frame1Gray, d_flow);
+
+ // Draw flows
+ namedWindow("PyrLK [Dense] Flow Field", WINDOW_NORMAL);
+ showFlow("PyrLK [Dense] Flow Field", d_flow);
+ }
- waitKey();
+ waitKey(0);
return 0;
-}
+}
\ No newline at end of file
diff --git a/samples/gpu/stereo_match.cpp b/samples/gpu/stereo_match.cpp
index 012fda1..6a79a46 100644
--- a/samples/gpu/stereo_match.cpp
+++ b/samples/gpu/stereo_match.cpp
@@ -76,7 +76,7 @@ private:
static void printHelp()
{
- cout << "Usage: stereo_match_gpu\n"
+ cout << "Usage: stereo_match\n"
<< "\t--left <left_view> --right <right_view> # must be rectified\n"
<< "\t--method <stereo_match_method> # BM | BP | CSBP\n"
<< "\t--ndisp <number> # number of disparity levels\n";
@@ -212,7 +212,7 @@ void App::run()
// Show results
d_disp.download(disp);
putText(disp, text(), Point(5, 25), FONT_HERSHEY_SIMPLEX, 1.0, Scalar::all(255));
- imshow("disparity", disp);
+ imshow("disparity", (Mat_<uchar>)disp);
handleKey((char)waitKey(3));
}
diff --git a/samples/gpu/stereo_multi.cpp b/samples/gpu/stereo_multi.cpp
index 7ef6567..d64b358 100644
--- a/samples/gpu/stereo_multi.cpp
+++ b/samples/gpu/stereo_multi.cpp
@@ -1,7 +1,7 @@
// This sample demonstrates working on one piece of data using two GPUs.
// It splits input into two parts and processes them separately on different GPUs.
-#ifdef WIN32
+#ifdef _WIN32
#define NOMINMAX
#include <windows.h>
#else
@@ -25,7 +25,7 @@ using namespace cv::cuda;
// Thread
// OS-specific wrappers for multi-threading
-#ifdef WIN32
+#ifdef _WIN32
class Thread
{
struct UserData
@@ -355,7 +355,7 @@ int main(int argc, char** argv)
{
if (argc != 3)
{
- cerr << "Usage: stereo_multi_gpu <left_video> <right_video>" << endl;
+ cerr << "Usage: stereo_multi <left_video> <right_video>" << endl;
return -1;
}
diff --git a/samples/gpu/surf_keypoint_matcher.cpp b/samples/gpu/surf_keypoint_matcher.cpp
index 009568b..3288025 100644
--- a/samples/gpu/surf_keypoint_matcher.cpp
+++ b/samples/gpu/surf_keypoint_matcher.cpp
@@ -17,7 +17,7 @@ using namespace cv::cuda;
static void help()
{
cout << "\nThis program demonstrates using SURF_CUDA features detector, descriptor extractor and BruteForceMatcher_CUDA" << endl;
- cout << "\nUsage:\n\tmatcher_simple_gpu --left <image1> --right <image2>" << endl;
+ cout << "\nUsage:\n\tsurf_keypoint_matcher --left <image1> --right <image2>" << endl;
}
int main(int argc, char* argv[])
diff --git a/samples/gpu/video_writer.cpp b/samples/gpu/video_writer.cpp
index 6b9cca3..fa1d709 100644
--- a/samples/gpu/video_writer.cpp
+++ b/samples/gpu/video_writer.cpp
@@ -2,7 +2,7 @@
#include "opencv2/opencv_modules.hpp"
-#if defined(HAVE_OPENCV_CUDACODEC) && defined(WIN32)
+#if defined(HAVE_OPENCV_CUDACODEC) && defined(_WIN32)
#include <vector>
#include <numeric>
diff --git a/samples/java/tutorial_code/CMakeLists.txt b/samples/java/tutorial_code/CMakeLists.txt
new file mode 100644
index 0000000..31424f9
--- /dev/null
+++ b/samples/java/tutorial_code/CMakeLists.txt
@@ -0,0 +1,39 @@
+# ----------------------------------------------------------------------------
+# CMake file for Java tutorials compilation.
+#
+# ----------------------------------------------------------------------------
+if(NOT ANT_EXECUTABLE OR NOT TARGET opencv_java)
+ return()
+endif()
+
+project(compile_java_tutorials)
+
+set(curdir "${CMAKE_CURRENT_SOURCE_DIR}")
+set(opencv_tutorial_java_bin_dir "${CMAKE_CURRENT_BINARY_DIR}/.compiled")
+set(TUTORIALS_DIRS "")
+
+file(GLOB children RELATIVE ${curdir} ${curdir}/*/*)
+foreach(child ${children})
+ if(IS_DIRECTORY ${curdir}/${child})
+ file(GLOB contains_java_files "${child}/*.java")
+ if(contains_java_files)
+ list(APPEND TUTORIALS_DIRS ${child})
+ endif()
+ endif()
+endforeach()
+
+add_custom_target("${PROJECT_NAME}"
+ DEPENDS opencv_java
+ )
+
+foreach(TUTORIAL_DIR ${TUTORIALS_DIRS})
+ get_filename_component(TUTORIAL_NAME ${TUTORIAL_DIR} NAME_WE)
+ add_custom_command(TARGET "${PROJECT_NAME}"
+ COMMAND ${ANT_EXECUTABLE} -q
+ -DocvJarDir="${OpenCV_BINARY_DIR}/bin"
+ -DsrcDir="${TUTORIAL_DIR}"
+ -DdstDir="${opencv_tutorial_java_bin_dir}/${TUTORIAL_NAME}"
+ WORKING_DIRECTORY "${curdir}"
+ COMMENT "Compile the tutorial: ${TUTORIAL_NAME}"
+ )
+endforeach()
diff --git a/samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java b/samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java
new file mode 100644
index 0000000..b323aeb
--- /dev/null
+++ b/samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java
@@ -0,0 +1,196 @@
+import org.opencv.core.*;
+import org.opencv.core.Point;
+import org.opencv.imgcodecs.Imgcodecs;
+import org.opencv.imgproc.Imgproc;
+
+import javax.swing.*;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBufferByte;
+
+import java.util.*;
+
+class MatchTemplateDemoRun implements ChangeListener{
+
+ //! [declare]
+ /// Global Variables
+ Boolean use_mask = false;
+ Mat img = new Mat(), templ = new Mat();
+ Mat mask = new Mat();
+
+ int match_method;
+
+ JLabel imgDisplay = new JLabel(), resultDisplay = new JLabel();
+ //! [declare]
+
+ public void run(String[] args) {
+
+ if (args.length < 2)
+ {
+ System.out.println("Not enough parameters");
+ System.out.println("Program arguments:\n<image_name> <template_name> [<mask_name>]");
+ System.exit(-1);
+ }
+
+ //! [load_image]
+ /// Load image and template
+ img = Imgcodecs.imread( args[0], Imgcodecs.IMREAD_COLOR );
+ templ = Imgcodecs.imread( args[1], Imgcodecs.IMREAD_COLOR );
+ //! [load_image]
+
+ if(args.length > 2) {
+ use_mask = true;
+ mask = Imgcodecs.imread( args[2], Imgcodecs.IMREAD_COLOR );
+ }
+
+ if(img.empty() || templ.empty() || (use_mask && mask.empty()))
+ {
+ System.out.println("Can't read one of the images");
+ System.exit(-1);
+ }
+
+ matchingMethod();
+ createJFrame();
+
+ }
+
+ private void matchingMethod() {
+
+ Mat result = new Mat();
+
+ //! [copy_source]
+ /// Source image to display
+ Mat img_display = new Mat();
+ img.copyTo( img_display );
+ //! [copy_source]
+
+ //! [create_result_matrix]
+ /// Create the result matrix
+ int result_cols = img.cols() - templ.cols() + 1;
+ int result_rows = img.rows() - templ.rows() + 1;
+
+ result.create( result_rows, result_cols, CvType.CV_32FC1 );
+ //! [create_result_matrix]
+
+ //! [match_template]
+ /// Do the Matching and Normalize
+ Boolean method_accepts_mask = (Imgproc.TM_SQDIFF == match_method ||
+ match_method == Imgproc.TM_CCORR_NORMED);
+ if (use_mask && method_accepts_mask)
+ { Imgproc.matchTemplate( img, templ, result, match_method, mask); }
+ else
+ { Imgproc.matchTemplate( img, templ, result, match_method); }
+ //! [match_template]
+
+ //! [normalize]
+ Core.normalize( result, result, 0, 1, Core.NORM_MINMAX, -1, new Mat() );
+ //! [normalize]
+
+ //! [best_match]
+ /// Localizing the best match with minMaxLoc
+ double minVal; double maxVal;
+ Point matchLoc;
+
+ Core.MinMaxLocResult mmr = Core.minMaxLoc( result );
+ //! [best_match]
+
+ //! [match_loc]
+ /// For SQDIFF and SQDIFF_NORMED, the best matches are lower values.
+ // For all the other methods, the higher the better
+ if( match_method == Imgproc.TM_SQDIFF || match_method == Imgproc.TM_SQDIFF_NORMED )
+ { matchLoc = mmr.minLoc; }
+ else
+ { matchLoc = mmr.maxLoc; }
+ //! [match_loc]
+
+ //! [imshow]
+ /// Show me what you got
+ Imgproc.rectangle(img_display, matchLoc, new Point(matchLoc.x + templ.cols(),
+ matchLoc.y + templ.rows()), new Scalar(0, 0, 0), 2, 8, 0);
+ Imgproc.rectangle(result, matchLoc, new Point(matchLoc.x + templ.cols(),
+ matchLoc.y + templ.rows()), new Scalar(0, 0, 0), 2, 8, 0);
+
+ Image tmpImg = toBufferedImage(img_display);
+ ImageIcon icon = new ImageIcon(tmpImg);
+ imgDisplay.setIcon(icon);
+
+ result.convertTo(result, CvType.CV_8UC1, 255.0);
+ tmpImg = toBufferedImage(result);
+ icon = new ImageIcon(tmpImg);
+ resultDisplay.setIcon(icon);
+ //! [imshow]
+ }
+
+ public void stateChanged(ChangeEvent e) {
+ JSlider source = (JSlider) e.getSource();
+ if (!source.getValueIsAdjusting()) {
+ match_method = (int)source.getValue();
+ matchingMethod();
+ }
+ }
+
+ public Image toBufferedImage(Mat m) {
+ int type = BufferedImage.TYPE_BYTE_GRAY;
+ if ( m.channels() > 1 ) {
+ type = BufferedImage.TYPE_3BYTE_BGR;
+ }
+ int bufferSize = m.channels()*m.cols()*m.rows();
+ byte [] b = new byte[bufferSize];
+ m.get(0,0,b); // get all the pixels
+ BufferedImage image = new BufferedImage(m.cols(),m.rows(), type);
+ final byte[] targetPixels = ((DataBufferByte) image.getRaster().getDataBuffer()).getData();
+ System.arraycopy(b, 0, targetPixels, 0, b.length);
+ return image;
+ }
+
+ private void createJFrame() {
+
+ String title = "Source image; Control; Result image";
+ JFrame frame = new JFrame(title);
+ frame.setLayout(new GridLayout(2, 2));
+ frame.add(imgDisplay);
+
+ //! [create_trackbar]
+ int min = 0, max = 5;
+ JSlider slider = new JSlider(JSlider.VERTICAL, min, max, match_method);
+ //! [create_trackbar]
+
+ slider.setPaintTicks(true);
+ slider.setPaintLabels(true);
+
+ // Set the spacing for the minor tick mark
+ slider.setMinorTickSpacing(1);
+
+ // Customizing the labels
+ Hashtable labelTable = new Hashtable();
+ labelTable.put( new Integer( 0 ), new JLabel("0 - SQDIFF") );
+ labelTable.put( new Integer( 1 ), new JLabel("1 - SQDIFF NORMED") );
+ labelTable.put( new Integer( 2 ), new JLabel("2 - TM CCORR") );
+ labelTable.put( new Integer( 3 ), new JLabel("3 - TM CCORR NORMED") );
+ labelTable.put( new Integer( 4 ), new JLabel("4 - TM COEFF") );
+ labelTable.put( new Integer( 5 ), new JLabel("5 - TM COEFF NORMED : (Method)") );
+ slider.setLabelTable( labelTable );
+
+ slider.addChangeListener(this);
+
+ frame.add(slider);
+
+ frame.add(resultDisplay);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.pack();
+ frame.setVisible(true);
+ }
+}
+
+public class MatchTemplateDemo
+{
+ public static void main(String[] args) {
+ // load the native OpenCV library
+ System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
+
+ // run code
+ new MatchTemplateDemoRun().run(args);
+ }
+}
diff --git a/samples/java/tutorial_code/build.xml b/samples/java/tutorial_code/build.xml
new file mode 100644
index 0000000..4bba3c9
--- /dev/null
+++ b/samples/java/tutorial_code/build.xml
@@ -0,0 +1,13 @@
+<project default="compile">
+
+ <property name="lib.dir" value="${ocvJarDir}"/>
+ <path id="classpath">
+ <fileset dir="${lib.dir}" includes="**/*.jar"/>
+ </path>
+
+ <target name="compile">
+ <mkdir dir="${dstDir}"/>
+ <javac includeantruntime="false" srcdir="${srcDir}" destdir="${dstDir}" classpathref="classpath"/>
+ </target>
+
+</project>
diff --git a/samples/opengl/opengl_interop.cpp b/samples/opengl/opengl_interop.cpp
index 1345c2d..ccfbccd 100644
--- a/samples/opengl/opengl_interop.cpp
+++ b/samples/opengl/opengl_interop.cpp
@@ -5,7 +5,7 @@
// and call cv::Blur function. The result is mapped back to OpenGL texture
// and rendered through OpenGL API.
*/
-#if defined(WIN32) || defined(_WIN32)
+#if defined(_WIN32)
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#elif defined(__linux__)
@@ -27,7 +27,7 @@
#include "winapp.hpp"
-#if defined(WIN32) || defined(_WIN32)
+#if defined(_WIN32)
# pragma comment(lib, "opengl32.lib")
# pragma comment(lib, "glu32.lib")
#endif
@@ -74,7 +74,7 @@ public:
WinApp::cleanup();
}
-#if defined(WIN32) || defined(_WIN32)
+#if defined(_WIN32)
virtual LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
@@ -169,7 +169,7 @@ public:
int init()
{
-#if defined(WIN32) || defined(_WIN32)
+#if defined(_WIN32)
m_hDC = GetDC(m_hWnd);
if (setup_pixel_format() != 0)
@@ -219,7 +219,7 @@ public:
void print_info(MODE mode, float time, cv::String& oclDevName)
{
-#if defined(WIN32) || defined(_WIN32)
+#if defined(_WIN32)
HDC hDC = m_hDC;
HFONT hFont = (HFONT)::GetStockObject(SYSTEM_FONT);
@@ -323,7 +323,7 @@ public:
glTexCoord2f(1.0f, 0.0f); glVertex3f(1.0f, 1.0f, 0.1f);
glEnd();
-#if defined(WIN32) || defined(_WIN32)
+#if defined(_WIN32)
SwapBuffers(m_hDC);
#elif defined(__linux__)
glXSwapBuffers(m_display, m_window);
@@ -394,7 +394,7 @@ protected:
m_timer.stop();
}
-#if defined(WIN32) || defined(_WIN32)
+#if defined(_WIN32)
int setup_pixel_format()
{
PIXELFORMATDESCRIPTOR pfd;
@@ -459,7 +459,7 @@ private:
bool m_demo_processing;
MODE m_mode;
cv::String m_modeStr[2];
-#if defined(WIN32) || defined(_WIN32)
+#if defined(_WIN32)
HDC m_hDC;
HGLRC m_hRC;
#elif defined(__linux__)
@@ -524,7 +524,7 @@ int main(int argc, char** argv)
int width = (int)cap.get(CAP_PROP_FRAME_WIDTH);
int height = (int)cap.get(CAP_PROP_FRAME_HEIGHT);
-#if defined(WIN32) || defined(_WIN32)
+#if defined(_WIN32)
string wndname = "WGL Window";
#elif defined(__linux__)
string wndname = "GLX Window";
diff --git a/samples/opengl/winapp.hpp b/samples/opengl/winapp.hpp
index 2133104..75df353 100644
--- a/samples/opengl/winapp.hpp
+++ b/samples/opengl/winapp.hpp
@@ -1,4 +1,4 @@
-#if defined(WIN32) || defined(_WIN32)
+#if defined(_WIN32)
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#elif defined(__linux__)
@@ -10,13 +10,13 @@
#include <string>
#include <GL/gl.h>
-#if defined(WIN32) || defined(_WIN32)
+#if defined(_WIN32)
# include <GL/glu.h>
#elif defined(__linux__)
# include <GL/glx.h>
#endif
-#if defined(WIN32) || defined(_WIN32)
+#if defined(_WIN32)
# define WINCLASS "WinAppWnd"
#endif
@@ -78,21 +78,21 @@ public:
m_width = width;
m_height = height;
m_window_name = window_name;
-#if defined(WIN32) || defined(_WIN32)
+#if defined(_WIN32)
m_hInstance = ::GetModuleHandle(NULL);
#endif
}
virtual ~WinApp()
{
-#if defined(WIN32) || defined(_WIN32)
+#if defined(_WIN32)
::UnregisterClass(WINCLASS, m_hInstance);
#endif
}
int create()
{
-#if defined(WIN32) || defined(_WIN32)
+#if defined(_WIN32)
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
@@ -166,7 +166,7 @@ public:
virtual void cleanup()
{
-#if defined(WIN32) || defined(_WIN32)
+#if defined(_WIN32)
::DestroyWindow(m_hWnd);
#elif defined(__linux__)
XDestroyWindow(m_display, m_window);
@@ -174,13 +174,13 @@ public:
#endif
}
-#if defined(WIN32) || defined(_WIN32)
+#if defined(_WIN32)
virtual LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) = 0;
#endif
int run()
{
-#if defined(WIN32) || defined(_WIN32)
+#if defined(_WIN32)
MSG msg;
::ZeroMemory(&msg, sizeof(msg));
@@ -217,7 +217,7 @@ public:
protected:
-#if defined(WIN32) || defined(_WIN32)
+#if defined(_WIN32)
static LRESULT CALLBACK StaticWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
WinApp* pWnd;
@@ -252,7 +252,7 @@ protected:
virtual void idle() = 0;
-#if defined(WIN32) || defined(_WIN32)
+#if defined(_WIN32)
HINSTANCE m_hInstance;
HWND m_hWnd;
#elif defined(__linux__)
diff --git a/samples/python/digits.py b/samples/python/digits.py
index 5cc98b7..16d76a1 100755
--- a/samples/python/digits.py
+++ b/samples/python/digits.py
@@ -109,7 +109,7 @@ def evaluate_model(model, digits, samples, labels):
confusion = np.zeros((10, 10), np.int32)
for i, j in zip(labels, resp):
- confusion[i, j] += 1
+ confusion[i, int(j)] += 1
print('confusion matrix:')
print(confusion)
print()
diff --git a/samples/python/mosse.py b/samples/python/mosse.py
index 46e22d3..816c8e4 100755
--- a/samples/python/mosse.py
+++ b/samples/python/mosse.py
@@ -18,7 +18,7 @@ Keys:
c - clear targets
[1] David S. Bolme et al. "Visual Object Tracking using Adaptive Correlation Filters"
- http://www.cs.colostate.edu/~bolme/publications/Bolme2010Tracking.pdf
+ http://www.cs.colostate.edu/~draper/papers/bolme_cvpr10.pdf
'''
# Python 2/3 compatibility
diff --git a/samples/python/tutorial_code/imgProc/hough_line_transform/hough_line_transform.py b/samples/python/tutorial_code/imgProc/hough_line_transform/hough_line_transform.py
new file mode 100644
index 0000000..0bcf6c5
--- /dev/null
+++ b/samples/python/tutorial_code/imgProc/hough_line_transform/hough_line_transform.py
@@ -0,0 +1,22 @@
+import cv2
+import numpy as np
+
+img = cv2.imread('../data/sudoku.png')
+gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
+edges = cv2.Canny(gray,50,150,apertureSize = 3)
+
+lines = cv2.HoughLines(edges,1,np.pi/180,200)
+for line in lines:
+ rho,theta = line[0]
+ a = np.cos(theta)
+ b = np.sin(theta)
+ x0 = a*rho
+ y0 = b*rho
+ x1 = int(x0 + 1000*(-b))
+ y1 = int(y0 + 1000*(a))
+ x2 = int(x0 - 1000*(-b))
+ y2 = int(y0 - 1000*(a))
+
+ cv2.line(img,(x1,y1),(x2,y2),(0,0,255),2)
+
+cv2.imwrite('houghlines3.jpg',img)
diff --git a/samples/python/tutorial_code/imgProc/hough_line_transform/probabilistic_hough_line_transform.py b/samples/python/tutorial_code/imgProc/hough_line_transform/probabilistic_hough_line_transform.py
new file mode 100644
index 0000000..2d000a1
--- /dev/null
+++ b/samples/python/tutorial_code/imgProc/hough_line_transform/probabilistic_hough_line_transform.py
@@ -0,0 +1,12 @@
+import cv2
+import numpy as np
+
+img = cv2.imread('../data/sudoku.png')
+gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
+edges = cv2.Canny(gray,50,150,apertureSize = 3)
+lines = cv2.HoughLinesP(edges,1,np.pi/180,100,minLineLength=100,maxLineGap=10)
+for line in lines:
+ x1,y1,x2,y2 = line[0]
+ cv2.line(img,(x1,y1),(x2,y2),(0,255,0),2)
+
+cv2.imwrite('houghlines5.jpg',img)
diff --git a/samples/python/tutorial_code/imgProc/match_template/match_template.py b/samples/python/tutorial_code/imgProc/match_template/match_template.py
new file mode 100644
index 0000000..5c649a0
--- /dev/null
+++ b/samples/python/tutorial_code/imgProc/match_template/match_template.py
@@ -0,0 +1,96 @@
+import sys
+import cv2
+
+## [global_variables]
+use_mask = False
+img = None
+templ = None
+mask = None
+image_window = "Source Image"
+result_window = "Result window"
+
+match_method = 0
+max_Trackbar = 5
+## [global_variables]
+
+def main(argv):
+
+ if (len(sys.argv) < 3):
+ print 'Not enough parameters'
+ print 'Usage:\nmatch_template_demo.py <image_name> <template_name> [<mask_name>]'
+ return -1
+
+ ## [load_image]
+ global img
+ global templ
+ img = cv2.imread(sys.argv[1], cv2.IMREAD_COLOR)
+ templ = cv2.imread(sys.argv[2], cv2.IMREAD_COLOR)
+
+ if (len(sys.argv) > 3):
+ global use_mask
+ use_mask = True
+ global mask
+ mask = cv2.imread( sys.argv[3], cv2.IMREAD_COLOR )
+
+ if ((img is None) or (templ is None) or (use_mask and (mask is None))):
+ print 'Can\'t read one of the images'
+ return -1
+ ## [load_image]
+
+ ## [create_windows]
+ cv2.namedWindow( image_window, cv2.WINDOW_AUTOSIZE )
+ cv2.namedWindow( result_window, cv2.WINDOW_AUTOSIZE )
+ ## [create_windows]
+
+ ## [create_trackbar]
+ trackbar_label = 'Method: \n 0: SQDIFF \n 1: SQDIFF NORMED \n 2: TM CCORR \n 3: TM CCORR NORMED \n 4: TM COEFF \n 5: TM COEFF NORMED'
+ cv2.createTrackbar( trackbar_label, image_window, match_method, max_Trackbar, MatchingMethod )
+ ## [create_trackbar]
+
+ MatchingMethod(match_method)
+
+ ## [wait_key]
+ cv2.waitKey(0)
+ return 0
+ ## [wait_key]
+
+def MatchingMethod(param):
+
+ global match_method
+ match_method = param
+
+ ## [copy_source]
+ img_display = img.copy()
+ ## [copy_source]
+ ## [match_template]
+ method_accepts_mask = (cv2.TM_SQDIFF == match_method or match_method == cv2.TM_CCORR_NORMED)
+ if (use_mask and method_accepts_mask):
+ result = cv2.matchTemplate(img, templ, match_method, None, mask)
+ else:
+ result = cv2.matchTemplate(img, templ, match_method)
+ ## [match_template]
+
+ ## [normalize]
+ cv2.normalize( result, result, 0, 1, cv2.NORM_MINMAX, -1 )
+ ## [normalize]
+ ## [best_match]
+ minVal, maxVal, minLoc, maxLoc = cv2.minMaxLoc(result, None)
+ ## [best_match]
+
+ ## [match_loc]
+ if (match_method == cv2.TM_SQDIFF or match_method == cv2.TM_SQDIFF_NORMED):
+ matchLoc = minLoc
+ else:
+ matchLoc = maxLoc
+ ## [match_loc]
+
+ ## [imshow]
+ cv2.rectangle(img_display, matchLoc, (matchLoc[0] + templ.shape[0], matchLoc[1] + templ.shape[1]), (0,0,0), 2, 8, 0 )
+ cv2.rectangle(result, matchLoc, (matchLoc[0] + templ.shape[0], matchLoc[1] + templ.shape[1]), (0,0,0), 2, 8, 0 )
+ cv2.imshow(image_window, img_display)
+ cv2.imshow(result_window, result)
+ ## [imshow]
+ pass
+
+if __name__ == "__main__":
+ main(sys.argv[1:])
diff --git a/samples/python/tutorial_code/ml/py_svm_opencv/hogsvm.py b/samples/python/tutorial_code/ml/py_svm_opencv/hogsvm.py
new file mode 100644
index 0000000..00586c8
--- /dev/null
+++ b/samples/python/tutorial_code/ml/py_svm_opencv/hogsvm.py
@@ -0,0 +1,71 @@
+import cv2
+import numpy as np
+
+SZ=20
+bin_n = 16 # Number of bins
+
+
+affine_flags = cv2.WARP_INVERSE_MAP|cv2.INTER_LINEAR
+
+## [deskew]
+def deskew(img):
+ m = cv2.moments(img)
+ if abs(m['mu02']) < 1e-2:
+ return img.copy()
+ skew = m['mu11']/m['mu02']
+ M = np.float32([[1, skew, -0.5*SZ*skew], [0, 1, 0]])
+ img = cv2.warpAffine(img,M,(SZ, SZ),flags=affine_flags)
+ return img
+## [deskew]
+
+## [hog]
+def hog(img):
+ gx = cv2.Sobel(img, cv2.CV_32F, 1, 0)
+ gy = cv2.Sobel(img, cv2.CV_32F, 0, 1)
+ mag, ang = cv2.cartToPolar(gx, gy)
+ bins = np.int32(bin_n*ang/(2*np.pi)) # quantizing binvalues in (0...16)
+ bin_cells = bins[:10,:10], bins[10:,:10], bins[:10,10:], bins[10:,10:]
+ mag_cells = mag[:10,:10], mag[10:,:10], mag[:10,10:], mag[10:,10:]
+ hists = [np.bincount(b.ravel(), m.ravel(), bin_n) for b, m in zip(bin_cells, mag_cells)]
+ hist = np.hstack(hists) # hist is a 64 bit vector
+ return hist
+## [hog]
+
+img = cv2.imread('digits.png',0)
+if img is None:
+ raise Exception("we need the digits.png image from samples/data here !")
+
+
+cells = [np.hsplit(row,100) for row in np.vsplit(img,50)]
+
+# First half is trainData, remaining is testData
+train_cells = [ i[:50] for i in cells ]
+test_cells = [ i[50:] for i in cells]
+
+###### Now training ########################
+
+deskewed = [map(deskew,row) for row in train_cells]
+hogdata = [map(hog,row) for row in deskewed]
+trainData = np.float32(hogdata).reshape(-1,64)
+responses = np.repeat(np.arange(10),250)[:,np.newaxis]
+
+svm = cv2.ml.SVM_create()
+svm.setKernel(cv2.ml.SVM_LINEAR)
+svm.setType(cv2.ml.SVM_C_SVC)
+svm.setC(2.67)
+svm.setGamma(5.383)
+
+svm.train(trainData, cv2.ml.ROW_SAMPLE, responses)
+svm.save('svm_data.dat')
+
+###### Now testing ########################
+
+deskewed = [map(deskew,row) for row in test_cells]
+hogdata = [map(hog,row) for row in deskewed]
+testData = np.float32(hogdata).reshape(-1,bin_n*4)
+result = svm.predict(testData)[1]
+
+####### Check Accuracy ########################
+mask = result==responses
+correct = np.count_nonzero(mask)
+print correct*100.0/result.size
diff --git a/samples/tapi/hog.cpp b/samples/tapi/hog.cpp
index 1ead0d9..9273e67 100644
--- a/samples/tapi/hog.cpp
+++ b/samples/tapi/hog.cpp
@@ -28,16 +28,6 @@ public:
void workBegin();
void workEnd();
string workFps() const;
- string message() const;
-
-
-// This function test if gpu_rst matches cpu_rst.
-// If the two vectors are not equal, it will return the difference in vector size
-// Else if will return
-// (total diff of each cpu and gpu rects covered pixels)/(total cpu rects covered pixels)
- double checkRectSimilarity(Size sz,
- std::vector<Rect>& cpu_rst,
- std::vector<Rect>& gpu_rst);
private:
App operator=(App&);
diff --git a/samples/tapi/tvl1_optical_flow.cpp b/samples/tapi/tvl1_optical_flow.cpp
index 5efa4e2..925745f 100644
--- a/samples/tapi/tvl1_optical_flow.cpp
+++ b/samples/tapi/tvl1_optical_flow.cpp
@@ -105,7 +105,7 @@ int main(int argc, const char* argv[])
string fname1 = cmd.get<string>("r");
string vdofile = cmd.get<string>("v");
string outpath = cmd.get<string>("o");
- bool useCPU = cmd.get<bool>("s");
+ bool useCPU = cmd.get<bool>("m");
bool useCamera = cmd.get<bool>("c");
int inputName = cmd.get<int>("c");
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/opencv.git
More information about the debian-science-commits
mailing list